メモリ内のルーチン コードを別の場所にコピーしたい。例えば
procedure OldShowMessage;
begin
ShowMessage('Old message..');
end;
ルーチンをメモリ内の別の場所にコピーしたいとします。私は次のようなことを宣言しました
var
lopShowMessage : procedure; // procedural pointer.
いくつかの擬似コードは次のようになります
// VirtualProtect(@OldShowMessage, <length of routine>, ..., ...);
// Allocate memory
// lopShowMessage := AllocMem(<length of routine>);
// Move(@OldMessage, Pointer(lopShowMessage)^, <length of routine>);
// FlushInstructioncache.....
これを行う可能性があるかどうかを知りたいだけです。新しいルーチンを呼び出すルーチンにパッチを当てましたが、コード迂回路を使用して JMP 命令を配置しているため、古いルーチンで提供されていた機能を使用できない場合があります。
私の以前の質問の参照はここにあります