Skip to main content
gamedev.net
🔒 Locked

Function Address And Size

Started by Cornutopia 2 replies 400+ views
Original Post
Cornutopia
Cornutopia
I can take a pointer to a global function call but anyone know if there is any way to tell how long in bytes the compiled function is? If I take a pointer to the function that is placed just after the one I want it will that always follow the function I want in memory when the program is compliled? My goal is to duplicate or compare a function by copying or examining it in memory. Mark Cornutopia Games http://www.cornutopia.net Sound Effects For Game Developers http://www.indiesfx.co.uk
Zahlman
Zahlman
No, the compiler is allowed to arrange the code in memory however it likes (in case it gains some optimization that way, in order to make the implementor's life easier, etc.) If you want self-modifying code then you either have to use a lower-level language (assembly, where you can control how things line up in memory) or a higher-level one (an interpreted scripting language where you can re-invoke the interpreter on some string).

... What do you hope to accomplish by "duplicating or comparing" pieces of code anyway? Seems to me like you just need to duplicate/compare the function pointer values, for any reasonable task...

[edited by - Zahlman on February 1, 2004 11:54:26 AM]
ironfroggy
ironfroggy
You could probably write a simple library that would read through the function instructions, stoping when it hits a return that must be reached (no conditional). Of course, if there is a jmp outside the function, then all bets are off.
(http://www.ironfroggy.com/)(http://www.ironfroggy.com/pinch)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.