El 18/02/2011 17:59, Andrew Haines escribió:
From the other comments it seems like you are writing some assembly to
memory at runtime then calling that code?
That is right.
If so then maybe the following
can help you.
...code...
so the usage would be like so
function TTrampolineManager.GenerateCode(args: ....): Pointer;
begin
try
Result := CurrentBlock.Position; // = @Block + Block.Cursor
repeat
WriteData(your_data, size_of_data);
until done;
except
on e: TrampolineBlockFullException do
begin
TrampolineManager.AllocateBlock;
Result := GenerateCode(args);
end;
end;
end;
Hope this helps :)
A lot! I understand that for purposes other than trampolining, the
essence of this is the the way of building an almost contiguous list, say
Block: array[0..lastCodePiece] of Pointer;
of DEP executable codes inside an authorized chunk of memory, and that
the call for assigning one of them, Block[i], to some function declared as
otherObject.thisFunction(other args): Double;
would be
@otherObjectInstance.thisFunction:= Block[i];
And also the way to obtain another block when one of them has
been exhausted, and the way of disposing of them, right?
Many thanks, Andrew. I intend to apply this to my old programs in 32
bit Windows. I'll tell you about the outcome.
--
montesin at uv dot es
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal