⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thunker.pas

📁 Yahoo Messenger for Mobile
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -