Calculation of size of function
-
-
At run time it is difficult to do, unless you have access to the .obj file. If you do, you can parse the file (see Microsoft Portable Executable and Common Object File Format Specification) and look for the size record for the function you are interested in. To experiment with this, take a .obj file that contains a single function, and run this from the command line:
dumpdin /all myobj.obj > foo.txt
The file foo.txt will contain a complete dump of the file, and you should see a record that looks like
0F2 00000000 SECT27 notype () External | ?GetFontProperties@@YAHPBDPAU_tagFONT_PROPERTIES@@@Z (int __cdecl GetFontProperties(char const *,struct _tagFONT_PROPERTIES *))
tag index 00000106 size 00000C7D lines 0000856D next function 00000111In this example, I used the XFont.obj from my XFont article. You can see that the size of
GetFontProperties()
is given as hex 00000C7D. Note that these sizes are not exact - if you read the PE Format spec, you will find more info. Just out of curiosity, why do you want to do this?Best wishes, Hans
[CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]
-