Convert a delegate to a function (i.e. make a thunk)

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Apr 25 16:15:01 PDT 2012


On Thu, Apr 26, 2012 at 12:47:42AM +0200, David Nadlinger wrote:
> On Wednesday, 25 April 2012 at 22:31:59 UTC, H. S. Teoh wrote:
> >I believe nowadays heap memory is non-executable due to security
> >concerns with heap overflow exploits, right? So this may require
> >special treatment.
> 
> Yes; it usually boils down to allocating a dedicated page and then
> setting the executable flag after you are done with setting up your
> code (e.g. using VirtualAlloc/VirtualProtect on Windows).
[...]

Does turning on the executable flag also make it read-only?  If so, we'd
need to allocate a page per wrapper function, which seems a bit
excessive. Or is it possible to turn it off temporarily, add more code,
and turn it back on? (Seems like that should be prohibited, since
otherwise it would just be too easy to exploit, and would defeat the
purpose of protecting it in the first place.)


T

-- 
Arise, you prisoners of Windows
Arise, you slaves of Redmond, Wash,
The day and hour soon are coming
When all the IT folks say "Gosh!"
It isn't from a clever lawsuit
That Windowsland will finally fall,
But thousands writing open source code
Like mice who nibble through a wall.
-- The Linux-nationale by Greg Baker


More information about the Digitalmars-d mailing list