我希望能够将一行 ASM 转换为 shellcode。即:
CALL EBX
我该如何做到这一点,并且能够正确转换此 shellcode,以便我可以将其存储在 delphi 应用程序中的变量中。即:
var ShellCodeArray: array[0..3] of Byte = ($55,$8B,$EC,$81);
最佳答案
如果我没理解错的话,您想使用 Delphi 内置汇编器获取单个汇编器指令 CALL EBX
的机器码。
function CodeSize: Integer;
asm
lea EAX, @@end
lea EDX, @@start
sub EAX, EDX
JMP @@end
@@start:
call EBX
@@end:
end;
procedure Code;
asm
call EBX
end;
function CodeToBytes: TBytes;
var
I, N: Integer;
P: PByte;
begin
N:= CodeSize;
SetLength(Result, N);
P:= @Code;
for I:= 0 to N - 1 do begin
Result[I]:= P^;
Inc(P);
end;
end;
关于delphi - 如何获取编译时已知的汇编指令的机器代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13275948/