thunker.pas
来自「Yahoo Messenger for Mobile」· PAS 代码 · 共 74 行
PAS
74 行
unit thunker;
interface
const
SYSres = 0;
USERres = 2;
GDIres = 1;
function GetSystemResources(Res: Word): Word;
function UserPercentage : Integer;
function SystemPercentage : Integer;
function GDIPercentage : Integer;
procedure DisplayFreeResources;
implementation
uses Windows,SysUtils,Dialogs;
function ThunkLoadLibrary(LibraryName: PChar): THandle; stdcall; external kernel32 index 35;
procedure ThunkFreeLibrary(HInstance: THandle); stdcall; external kernel32 index 36;
function ThunkGetProcAddress(Hinstance: THandle; ProcName: PChar): Pointer; stdcall; external
kernel32 index 37;
procedure Thunk; cdecl; external kernel32 name 'QT_Thunk';
{$StackFrames On}
var
Th : THandle = 0;
P: Pointer = nil;
function GetSystemResources(Res: Word): Word;
var
Ar : array[0..$40] of Word;
begin
Ar[0] := Th; //get major error without this ?
Th := ThunkLoadLibrary('user.exe');
if Th < 32 then
raise Exception.Create('Error loading User.exe');
ThunkFreeLibrary(Th);
P := ThunkGetProcAddress(Th,'GetFreeSystemResources');
if P = nil then
raise Exception.Create('GetSystemResources function not found');
asm
push Res
mov edx, P
call Thunk
mov Result, ax
end;
end;
function UserPercentage : Integer;
begin
Result := GetSystemResources(USERres);
end;
function SystemPercentage : Integer;
begin
Result := GetSystemResources(SYSres);
end;
function GDIPercentage : Integer;
begin
Result := GetSystemResources(GDIres);
end;
Procedure DisplayFreeResources;
begin
ShowMessage('SYSTEM : '+inttostr(SystemPercentage)+'%'+'USER : '+inttostr(UserPercentage)+'%'+'GDI : '+inttostr(GDIPercentage)+'%');
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?