23.10.2012, 11:36
|
Начинающий
|
|
Регистрация: 13.02.2010
Сообщения: 104
Репутация: 10
|
|
сделал библиотеку с простенькой функцией, пробовал использовать ваш пример, но неудачно( значения в библиотеку приходят искажёнными
Код:
Function SetFunction(dll,adress,param:string):boolean;
var
proc: pointer;
_dll:integer;
Params: array of DWORD;
count:integer;
p1,p2:string;
//param = integer:8;boolean:true; ...
begin
_dll:=LoadLibrary(PChar(dll));
if(_dll<>0)then
begin
proc:=getProcAddress(_dll,PChar(adress));
if(proc<>nil)then
begin
count:=0;
if(param<>'')then
repeat
p1:=copy(param,1,pos(':',param)-1);
delete(param,1,pos(':',param));
p2:=copy(param,1,pos(';',param)-1);
delete(param,1,pos(';',param));
inc(count);
setlength(params,count);
if(p1='Integer')then
Params[count-1]:=strtoint(p2)
else
if(p1='Boolean')then
Params[count-1]:=strtoint(p2)
else
if(p1='PChar')then
Params[count-1]:=integer(PChar(p2));
until(param='');
asm
mov esi, Params
mov ecx, count
lea esp, [esp - ecx * 4]
mov edi, esp
cld
rep movsd
mov eax, proc
call eax
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetFunction('Project2.dll','func','Boolean:1;Integer:10;PChar:rgtrhtyh;');
// SetFunction('shell32.dll','ShellExecuteA','Integer:0;PChar:;PChar:calc.exe;PChar:;Integer:0;');//а если так вообще ругается громко(
end;
что не так?(
|