1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| program test;
// mes fonctions à tester
function fchar (c: byte): char;
begin
fchar := char(c);
end;
function fchr (c: byte): char;
begin
fchr := chr(c);
end;
// ma fonction de dump
Function ReadByteAtAddress( adresse: dword): byte;
var
d: dword;
begin
asm
push eax // sauvegarde de eax sur la pile
push edi // sauvegarde d'edi sur la pile
mov edi, dword ptr[adresse] // edi reçoit l'adresse de la fonction
mov eax, dword ptr[edi] // eax reçoit le dword à cette adresse
mov d, eax // je stocke le resultat dans d
pop edi // restauration de edi depuis la pile
pop eax // restauration de eax depuis la pile
end;
// ici je met un dword dans un byte, je perds donc les informations de 3 bytes
// suivants que je lirai ensuite.
// j'ai choisi de lire byte par byte juste parceque la fonction
// hexstr me renverrai sinon un resultat à lire de droite à gauche...
ReadByteAtAddress := d;
end;
// variables du programme
Var
i : integer;
buffchar : array[1..13] of byte;
buffchr : array[1..13] of byte;
// programme principal
begin
i:=0;
writeln('adresse de fchar : ', hexstr(integer(@fchar),8));
writeln('adresse de fchr : ', hexstr(integer(@fchr),8));
writeln;
writeln(' Dump fchar Dump fchr');
writeln;
writeln('adresse byte adresse byte');
writeln;
repeat
inc(i);
buffchar[I]:= ReadByteAtAddress(integer(@fchar)+i-1);
buffchr[I]:= ReadByteAtAddress(integer(@fchr)+i-1);
writeln(hexstr(integer(@fchar)+i-1,8),' ', hexstr(buffchar[i],2),
' ',
hexstr(integer(@fchr)+i-1,8),' ', hexstr(buffchr[i],2));
until i = 13;
readln;
end. |
Partager