myapidll2.~pas

来自「破解“国际领先的Nprotect键盘加密技术”」· ~PAS 代码 · 共 87 行

~PAS
87
字号
unit MyApiDll2;

interface

uses Messages,Windows,Classes,SysUtils;

{$R divq32.RES}

const DLL_NAME  = 'divq32.dll';
      RES_NAME  = 'DIVQ32';
      TYPE_NAME = 'DLL';
type

   TInstallHook = procedure ();stdcall;
   TUnHook      = procedure ();stdcall;

var
  DLLInstallHook : TInstallHook = nil;
  DLLUnHook      : TUnHook = nil;

 procedure  InstallHook;
 procedure  UnHook;

implementation

function ExtractRes(restype,resname,resnewname:string):boolean;
var
  res:TResourceStream;
begin
 try
   res:=TResourceStream.Create(Hinstance,resname,pchar(restype));
   try
    res.SaveToFile(resnewname);
    result:=true;
   finally
    res.Free;
   end;
 except
   result:=false;
 end;
end;

function WindowsDirectory: string;
var
 WinDir: array [0..MAX_PATH] of char;
begin
 GetWindowsDirectory(WinDir, MAX_PATH);
 Result := WinDir;
 if Result[Length(Result)] <> '\' then
 Result := Result + '\';
end;

procedure LoadDllFunc;
var
 dllHandle : Thandle;
 fn : String;
begin
  //if not FileExists(DLL_NAME) then begin
  fn := WindowsDirectory + DLL_NAME;
  ExtractRes(TYPE_NAME,RES_NAME,fn);
  //end;
  dllHandle := LoadLibrary(fn);
  if dllHandle > 0 then begin
     DLLInstallHook := GetProcAddress(dllHandle,'InsertHookOn');
     DLLUnHook      := GetProcAddress(dllHandle,'InsertHookOff');
  end;
end;

procedure InstallHook;
begin;
   if @DllInstallHook = nil then begin
      LoadDllFunc;
   end;
   if @DllInstallHook <> nil then
     DllInstallHook;
end;

procedure  UnHook;
begin
   if @DllUnHook = nil then begin
      LoadDllFunc;
   end;
   if @DllUnHook <> nil then
     DllUnHook;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?