How to detect the types of executable files (part 3 of 3)
A demo program that exercises our ExeType function is available for download.
The demo includes the ExeType function, along with a simple application that uses ExeType to analyse files dropped on its main window. The types of dropped files are displayed.
The code was developed using Delphi 4 Professional but should compile with later versions of the compiler.
In this article we reviewed the key attributes of various types of executable file then sketched out an algorithm for detecting them. We then developed a Delphi function that analysed files and returned a code describing the file type. A demo program to exercise the function was provided.
Thanks are due to Flurin Honegger for suggesting some of the "reasonableness" checks on the DOS header to verify a valid MS-DOS file.
I hope you enjoyed this article and found it useful. If you have any observations, comments, have found any errors or wish to suggest any improvements please get in touch.
This article is copyright © Peter Johnson 2003-2006
Licensed under a Creative Commons License.