📄 autoassemblerconverter.pas
字号:
unit autoassemblerconverter;
interface
uses autoassembler,classes,windows,symbolhandler,sysutils;
function CEAutoAsm(script: pchar; enable: boolean;allocid: pinteger):boolean; stdcall;
function CEInitialize(pid: dword; phandle: dword):boolean; stdcall;
function CEReloadSymbolsAndModules:boolean; stdcall;
function CEReloadModuleListOnly:boolean; stdcall;
var allocs: array of record
used: boolean;
allocarray: TCEAllocArray;
end;
implementation
function CEInitialize(pid: dword; phandle: dword):boolean; stdcall;
begin
symbolhandler.processid:=pid;
symbolhandler.processhandle:=phandle;
symhandler:=TSymhandler.create;
symhandler.reinitialize;
result:=true;
end;
function CEReloadSymbolsAndModules:boolean; stdcall;
begin
result:=false;
if symhandler=nil then exit;
symhandler.reinitialize;
symhandler.waitforsymbolsloaded;
result:=true;
end;
function CEReloadModuleListOnly:boolean; stdcall;
begin
result:=false;
if symhandler=nil then exit;
symhandler.reinitialize;
symhandler.loadmodulelist;
result:=true;
end;
function CEAutoAsm(script: pchar; enable: boolean;allocid: pinteger):boolean; stdcall;
var code: tstringlist;
i,j: integer;
var x: integer;
tempa: TCEAllocArray;
resourcestring strinvallocid='You gave a invalid allocid';
begin
result:=false;
code:=tstringlist.create;
code.Text:=script; //0 terminated string gets copied\
try
if allocid<>nil then
begin
if enable then
begin
allocid^:=-1;
for i:=0 to length(allocs)-1 do
begin
if not allocs[i].used then
begin
allocid^:=i;
break;
end;
end;
if allocid^=-1 then
begin
//i need more space
j:=length(allocs);
setlength(allocs,length(allocs)*2);
for i:=j to length(allocs)-1 do
begin
setlength(allocs[i].allocarray,0);
allocs[i].used:=false;
end;
allocid^:=j;
end;
end
else
begin
if allocid^>=length(allocs) then
begin
outputdebugstring(pchar(strinvallocid));
exit;
end;
if not allocs[allocid^].used then
begin
outputdebugstring(pchar(strinvallocid));
exit;
end;
end;
end
else
begin
allocid:=@x;
allocid^:=-1;
end;
try
if allocid^<>-1 then
begin
setlength(allocs[allocid^].allocarray,1);
result:=autoassemble(code,false,enable,false,allocs[allocid^].allocarray);
end
else
begin
setlength(tempa,0); //nil
result:=autoassemble(code,false,enable,false,tempa);
end;
except
on e: exception do
begin
outputdebugstring(pchar('A exception happened while assembling: '+e.message));
exit;
end;
end;
if not result then
begin
outputdebugstring('the internal auto assembler returned false. Check the script');
exit;
end;
if allocid^<>-1 then
begin
if enable then
begin
allocs[allocid^].used:=true;
end
else
begin
allocs[allocid^].used:=false;
setlength(allocs[allocid^].allocarray,0);
end;
end;
finally
code.free;
end;
end;
var i:integer;
initialization
setlength(allocs,8);
for i:=0 to 7 do
begin
allocs[i].used:=false;
setlength(allocs[i].allocarray,0);
end;
symhandler:=nil;
finalization
for i:=0 to length(allocs)-1 do
setlength(allocs[i].allocarray,0);
setlength(allocs,0);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -