Алгоритм: dup export file to fasm dd table
Синтаксис: delphi -> fasm
Описание:
данная процедурка(delphi) генерит таблицу смещений и пат4ей по экспортируемому DUPом файлу такого вида:
RAW Offset | Old Byte | New Byte
-----------------+----------+----------
00000149 20 30
000001F6 00 12
00000217 60 E0
0000023C 40 20
0000023F 40 E0
00000246 00 12
00000264 40 20
и сохраняет в удобном для использования в fasm'е
Offsets dd 0x00000149, 0x000001F6, 0x00000217, 0x0000023C, 0x0000023F
dd 0x00000246, 0x00000264
Patch db 0x30, 0x12, 0xE0, 0x20, 0xE0, 0x12, 0x20
Очень полезно при создании пат4ей, лоадеров с большим коли4естов байт для пат4а, которые вру4ную вводить утомительно.
Пример вызова:
Код:
procedure make_fasm_patch_table(dup_filename, offsets, pat4es: string);
var
f, offs, patches: textfile;
s, temp: string;
i: integer;
begin
assignfile(f, dup_filename);
assignfile(offs, offsets);
assignfile(patches, pat4es);
rewrite(offs);
rewrite(patches);
reset(f);
readln(f, s); //skip dup banner
readln(f, s);
i :=0;
write(offs, 'Offsets dd ');
write(patches, 'Patch db ');
while not eof(f) do
begin
readln(f, s);
inc(i);
temp := '0x' + copy(s, 6, 8)+', ';
if i mod 7 <> 0 then
write(offs, temp) else
begin
writeln(offs, copy(temp, 1, length(temp)-2));
write(offs, ' dd ');
end;
temp := '0x' + copy(s, 34, 2)+', ';
if i mod 15 <> 0 then
write(patches, temp) else
begin
writeln(patches, copy(temp, 1, length(temp)-2));
write(patches, ' db ');
end;
end;
closefile(f);
closefile(offs);
closefile(patches);
end;