Hack Forums
[C#] Detecting PE architecture/type/subsystem (64/32/gui/console/net/native) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Detecting PE architecture/type/subsystem (64/32/gui/console/net/native) (/showthread.php?tid=5817130)



Detecting PE architecture/type/subsystem (64/32/gui/console/net/native) - gigajew - Mar 27, 2018

Detect whether an executable is .NET or native, detect subsystem (console,gui), and whether it's 32-bit or 64-bit (PEPLUS)



RE: Detecting PE architecture/type/subsystem (64/32/gui/console/net/native) - Ninja - Mar 28, 2018

Call me a nitpicker, and I know it doesn't matter, but the empty line on line 24 bothers me.

Also, in my opinion, though this is purely preference, I prefer an if statement without brackets if there is only a single line of code that needs to be in it. And the if statement starting from line 89 can be shortened using a ternary operator, though that is also preference as well.

The only comments I have on this is that you should use an ArgumentException instead of a normal Exception for when Streams are not seekable, and that there is no exception handling. I don't know what kind of exceptions get thrown by for example the BitConverter class but I can imagine that developers using this will not always immediately understand what is wrong. Catching and then throwing your own, more detailed exception is something you can do.


RE: Detecting PE architecture/type/subsystem (64/32/gui/console/net/native) - gigajew - Mar 28, 2018

Thanks for the input Ninja


RE: Detecting PE architecture/type/subsystem (64/32/gui/console/net/native) - Ninja - Mar 28, 2018

(Mar 28, 2018 11:25 AM)gigajew Wrote:  Thanks for the input Ninja

No problem broski. Thanks for the great release! :^)