This commit is contained in:
Pavel 2023-11-10 16:48:37 +03:00
parent 7ef791f250
commit 3b795b43c3
2 changed files with 41 additions and 30 deletions

View File

@ -193,6 +193,11 @@ begin
end;
end;
procedure trim_flow(var ctx:t_jit_context2);
begin
ctx.trim:=True;
end;
procedure op_push_rip(var ctx:t_jit_context2);
var
stack:TRegValue;
@ -364,7 +369,7 @@ begin
//
op_jmp_dispatcher(ctx);
//
ctx.trim:=True;
trim_flow(ctx);
end;
procedure op_jmp(var ctx:t_jit_context2);
@ -433,7 +438,7 @@ begin
op_jmp_dispatcher(ctx);
end;
//
ctx.trim:=True;
trim_flow(ctx);
end;
procedure op_jcc(var ctx:t_jit_context2);
@ -799,13 +804,13 @@ begin
begin
//
ctx.builder.call_far(@jit_system_error); //TODO error dispatcher
ctx.trim:=True;
trim_flow(ctx);
end;
else
begin
ctx.builder.call_far(@jit_unknow_int);
ctx.trim:=True;
trim_flow(ctx);
end;
end;
end;
@ -814,14 +819,14 @@ procedure op_ud2(var ctx:t_jit_context2);
begin
//exit proc?
ctx.builder.call_far(@jit_exit_proc); //TODO exit dispatcher
ctx.trim:=True;
trim_flow(ctx);
end;
procedure op_iretq(var ctx:t_jit_context2);
begin
//exit proc?
ctx.builder.call_far(@jit_exit_proc); //TODO exit dispatcher
ctx.trim:=True;
trim_flow(ctx);
end;
procedure op_hlt(var ctx:t_jit_context2);
@ -1080,6 +1085,12 @@ begin
while True do
begin
if not ctx.is_text_addr(QWORD(ptr)) then
begin
writeln('not excec:0x',HexStr(ptr));
goto _invalid;
end;
if ((pmap_get_raw(QWORD(ptr)) and PAGE_PROT_EXECUTE)=0) then
begin
writeln('not excec:0x',HexStr(ptr));

View File

@ -79,31 +79,31 @@ function IS_JIT_FUNC(rip:qword):Boolean;
const
copyout_mov_size:array[TOperandSize] of Pointer=(
@copyout_mov_1 ,
@copyout_mov_1 ,
@copyout_mov_2 ,
@copyout_mov_4 ,
@copyout_mov_8 ,
@copyout_mov_6 ,
@copyout_mov_10,
@copyout_mov_16,
@copyout_mov_32,
@copyout_mov_64,
@copyout_mov_512
@copyout_mov_1 , //os0
@copyout_mov_1 , //os8
@copyout_mov_2 , //os16
@copyout_mov_4 , //os32
@copyout_mov_8 , //os64
@copyout_mov_6 , //os48
@copyout_mov_10, //os80
@copyout_mov_16, //os128
@copyout_mov_32, //os256
@copyout_mov_64, //os512
@copyout_mov_512 //os4096
);
copyin_mov_size:array[TOperandSize] of Pointer=(
@copyin_mov_1 ,
@copyin_mov_1 ,
@copyin_mov_2 ,
@copyin_mov_4 ,
@copyin_mov_8 ,
@copyin_mov_6 ,
@copyin_mov_10,
@copyin_mov_16,
@copyin_mov_32,
@copyin_mov_64,
@copyin_mov_512
@copyin_mov_1 , //os0
@copyin_mov_1 , //os8
@copyin_mov_2 , //os16
@copyin_mov_4 , //os32
@copyin_mov_8 , //os64
@copyin_mov_6 , //os48
@copyin_mov_10, //os80
@copyin_mov_16, //os128
@copyin_mov_32, //os256
@copyin_mov_64, //os512
@copyin_mov_512 //os4096
);
implementation
@ -275,7 +275,7 @@ label
var
addr:Pointer;
size:QWORD;
data:array[0..31] of Byte;
data:array[0..511] of Byte;
asm
pushfq
//
@ -392,7 +392,7 @@ label
_simple,
_exit;
var
data:array[0..31] of Byte;
data:array[0..511] of Byte;
asm
pushfq
//