Source code of a method.

Baz burg.basile at yahoo.com
Mon Nov 4 10:00:16 PST 2013


On Monday, 4 November 2013 at 16:42:42 UTC, Jacob Carlborg wrote:
> On 2013-11-04 16:09, Baz wrote:
>> On Saturday, 26 October 2013 at 16:36:35 UTC, TheFlyingFiddle 
>> wrote:
>>> Is there a way to extract the source code of a method at 
>>> compiletime?
>>
>> Yep, at least on win32. (tested in win7 32 with DEP set to 
>> "ON" for
>> everything)
>>
>> http://dpaste.dzfl.pl/19c77eee
>>
>> It doesn't run on DPaste (linux x86_64) that's why I restrict 
>> the "yes"
>> to my own local test (on win32).
>>
>> basically:
>> - set memory mode for reading code and grab it.
>> - transform. (in my example I patch a bool as return value).
>> - set memory mode for writing and patch it with your 
>> "patched-grabed-code".
>> - call new code.
>>
>> :)
>
> That can't work at compile time?

No it's only a run-time trick.
interesting example: turn mad a cracker who makes static analysic 
of the code.
Because the code disasm from the exe is different from the code 
executed at run-time...



More information about the Digitalmars-d-learn mailing list