[fpc-pascal] assign code to a method
Sven Barth
pascaldragon at googlemail.com
Fri Feb 18 13:46:02 CET 2011
Am 18.02.2011 12:16, schrieb Marco van de Voort:
> In our previous episode, Jonas Maebe said:
>>> because this is not a problem in Delphi nor it was in an old version
>>> of fpc-Lazarus 32 bits. Please give me a tip.
>>> Many thanks in advance.
>>
>> You probably have to mark the memory in which you write the code as
>> "executable" first (this has to be done using an OS-specific function;
>> I know next to nothing about Windows programming, but you should be
>> able to find the necessary information in MSDN).
>>
>> In fact, you should also do this on 32 bit platforms, since more and
>> more systems mark memory by default as not executable for security
>> purposes.
>
> This is called DEP (Data Execution Protection, which is an amalgam of resp
> AMD and Intel hardware protection and some software forms). IIRC it is
> always on for 64-bit, and for 32-bit server versions that use a PAE kernel.
> (client OSes don't have PAE version on windows afaik)
>
This is not entirely correct. Quote from Wikipedia regarding PAE:
===quote begin===
Windows XP SP2 and later, by default, on processors with the no-execute
(NX) or execute-disable (XD) feature, runs in PAE mode in order to allow NX.
===quote end===
> Afaik it can only be turned on before starting a binary. An executable can't
> disable it while running (since then it would be useless, as a virus could
> simply disable it)
>
> See e.g.
> http://techblissonline.com/enable-disable-dep-in-windows-xp-vista/
>
> Searching for "disable dep" or so will probably yield more results.
>
> Of course, this is not healthy and supportable application behaviour, but I
> assume this is already known.
I personally would say that mapping a page with the Execute flag set and
storing the to-be-executed content there should be enough. After all JIT
compilers must do that as well. ;)
Regards,
Sven
More information about the fpc-pascal
mailing list