📄 unitmain.pas
字号:
unit UnitMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,wjsthunk;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
DLLHandle: THandle;
ProcAddress: Pointer; {函数指针}
implementation
{$R *.DFM}
function proc32:boolean;
begin
DLLHandle := LoadLibrary16('MyDll.DLL');
if DLLHandle<32 then raise exception.create('MyDll.DLL没找到');
ProcAddress := GetProcAddress16(DLLHandle, 'Proc16');
if ProcAddress=nil then
begin
FreeLibrary16(DLLHandle);
raise exception.create('指定的函数没找到');
end;
result:=false;
asm //以下汇编代码中,只有第一参数、第二参数、pFunc的值是需要改变的,
//其余都是固定的写法
pushad
push es
push ds
push ebp //#2,保存ebp
sub esp,$2c //#1,预留2c字节的栈空间
mov edx,ProcAddress//函数地址
mov ebp,esp //#0
add ebp,$2c //#0,ebp放至2c字节栈的顶部
call QT_Thunk
add esp,$2c //#1,释放上面预留的2c字节的栈空间
pop ebp //#2,恢复ebp
mov byte ptr @result,al //result前要加上@
pop ds
pop es
popad
end;
if result then showmessage('OK!');
FreeLibrary16(DLLHandle);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
proc32;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -