Utilisé la fonction GetInstrLen pour connaitre la talle de instruction ASM situé a une adresse précise. Ce n'est qu'un encapsulage de la fonction ASM de ZOMBIE dans une unité Delphi
Source / Exemple :
unit LDE32;
// Original Coder :
// LDE32, Length-Disassembler Engine, 32-bit, (x) 1999-2000 Z0MBiE
// special edition for REVERT tool
//
// version 1.05
//
// Delphi Convertion - DevNull - 2004
interface
Uses types;
const
table_1: array[$00..$FF] of DWord =
($4000, $4000, $4000, $4000, $8000, $8000, 0, 0,
$4000, $4000, $4000, $4000, $8000, $8000, 0, 0,
$4000, $4000, $4000, $4000, $8000, $8000, 0, 0,
$4000, $4000, $4000, $4000, $8000, $8000, 0, 0,
$4000, $4000, $4000, $4000, $8000, $8000, $0008, 0,
$4000, $4000, $4000, $4000, $8000, $8000, $0008, 0,
$4000, $4000, $4000, $4000, $8000, $8000, $0008, 0,
$4000, $4000, $4000, $4000, $8000, $8000, $0008, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, $4000, $4000, $0008, $0008, $1008, $1008,
$2000, $6000, $0100, $4100, 0, 0, 0, 0,
$0100, $0100, $0100, $0100, $0100, $0100, $0100, $0100,
$0100, $0100, $0100, $0100, $0100, $0100, $0100, $0100,
$4100, $6000, $4100, $4100, $4000, $4000, $4000, $4000,
$4000, $4000, $4000, $4000, $4000, $4000, $4000, $4000,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, $2002, 0, 0, 0, 0, 0,
$0020, $0020, $0020, $0020, 0, 0, 0, 0,
$0100, $2000, 0, 0, 0, 0, 0, 0,
$0100, $0100, $0100, $0100, $0100, $0100, $0100, $0100,
$2000, $2000, $2000, $2000, $2000, $2000, $2000, $2000,
$4100, $4100, $0200, 0, $4000, $4000, $4100, $6000,
$0300, 0, $0200, 0, 0, 0, 0, 0,
$4000, $4000, $4000, $4000, $0100, $0100, 0, 0,
$4000, $4000, $4000, $4000, $4000, $4000, $4000, $4000,
$0100, $0100, $0100, $0100, $0100, $0100, $0100, $0100,
$2000, $2000, $2002, $0100, 0, 0, 0, 0,
$0008, 0, $0008, $0008, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, $4000, $4000);
table_0F: array[$00..$FF] of Integer =
($4000, $4000, $4000, $4000, -1, -1, 0, -1,
0, 0, 0, 0, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
$2000, $2000, $2000, $2000, $2000, $2000, $2000, $2000,
$2000, $2000, $2000, $2000, $2000, $2000, $2000, $2000,
$4000, $4000, $4000, $4000, $4000, $4000, $4000, $4000,
$4000, $4000, $4000, $4000, $4000, $4000, $4000, $4000,
0, 0, 0, $4000, $4100, $4000, -1, -1,
0, 0, 0, $4000, $4100, $4000, -1, $4000,
$4000, $4000, $4000, $4000, $4000, $4000, $4000, $4000,
-1, -1, $4100, $4000, $4000, $4000, $4000, $4000,
$4000, $4000, -1, -1, -1, -1, -1, -1,
0, 0, 0, 0, 0, 0, 0, 0,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1) ;
Function GetInstrLen(Pos : Pointer): byte;
implementation
Function GetInstrLen(Pos : Pointer): byte;
Var
pOpCode: pointer;
asm
mov pOpCode, Pos
mov ecx, Pos // ECX = opcode ptr
xor edx, edx // EDX = 0
xor eax, eax // EAX = 0
@@Prefix:
and dl , not $0008
mov al, [ecx]
inc ecx
or edx, DWord(table_1[eax*4])
test dl, $0008
jnz @@Prefix
cmp al, 0F6h
je @@test
cmp al, 0F7h
je @@test
cmp al, 0CDh
je @@int
cmp al, 0Fh
je @@0F
@@cont:
test dh, $8000 shr 8
jnz @@dataw0
@@dataw0done:
test dh, $4000 shr 8
jnz @@modrm
@@exitmodrm:
test dl, $0020
jnz @@mem67
@@mem67done:
test dh, $2000 shr 8
jnz @@data66
@@data66done:
mov eax, ecx
sub eax, pOpCode
and edx,$0001+$0002+$0004+$0100+$0200+$0400
add al, dl
add al, dh
@@exit: pop ecx
pop ebp
ret
@@test: or dh, $4000 shr 8
test byte ptr [ecx], 00111000b // F6/F7 -- test
jnz @@cont
or dh, $8000 shr 8
jmp @@cont
@@int: or dh, $0100 shr 8
cmp byte ptr [ecx], 20h
jne @@cont
or dh, $0400 shr 8
jmp @@cont
@@0F: mov al, [ecx]
inc ecx
or edx, DWord(table_0F[eax*4])
cmp edx, -1
jne @@cont
@@error: mov eax, edx
jmp @@exit
@@dataw0: xor dh, $2000 shr 8
test al, 00000001b
jnz @@dataw0done
xor dh, ($2000+$0100) shr 8
jmp @@dataw0done
@@mem67: xor dl, $0002
test dl, $0010
jnz @@mem67done
xor dl, $0004+$0002
jmp @@mem67done
@@data66: xor dh, $0200 shr 8
test dh, $1000 shr 8
jnz @@data66done
xor dh, ($0400+$0200) shr 8
jmp @@data66done
@@modrm: mov al, [ecx]
inc ecx
mov ah, al // ah=mod, al=rm
and ax, 0C007h
cmp ah, 0C0h
je @@exitmodrm
test dl, $0010
jnz @@modrm16
@@modrm32: cmp al, 04h
jne @@a
mov al, [ecx] // sib
inc ecx
and al, 07h
@@a: cmp ah, 40h
je @@mem1
cmp ah, 80h
je @@mem4
cmp ax, 0005h
jne @@exitmodrm
@@mem4: or dl, $0004
jmp @@exitmodrm
@@mem1: or dl, $0001
jmp @@exitmodrm
@@modrm16: cmp ax, 0006h
je @@mem2
cmp ah, 40h
je @@mem1
cmp ah, 80h
jne @@exitmodrm
@@mem2: or dl, $0002
jmp @@exitmodrm
end;
end.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.