All pastes #75052 Raw Edit

Gopneg

public text v1 · immutable
#75052 ·published 2006-06-29 19:15 UTC
rendered paste body
unit Exchange;

interface

uses Windows;

type
  PHookInfo = ^THookInfo;
  THookInfo = packed record
    hDrawWindow: THandle;
    hHookedWindow: THandle;
    HookHandle: THandle;
    DLLsPath: array [0..MAX_PATH - 1] of char;
  end;

var
  CommonArea: PHookInfo = NIL;

implementation

var
  Mapping: THandle = 0;

const
  UniqueHookId = '{8FA5AD09-26EB-43E5-A977-91FCF972D32C}';
  UniqueID     = '{CE18D4DE-4C07-4F08-B18C-C07C29D3441E}';

initialization     
  Mapping := CreateFileMapping(INVALID_HANDLE_VALUE, NIL, PAGE_READWRITE, 0,
                               SizeOf(CommonArea), UniqueHookId);
  CommonArea := MapViewOfFile(Mapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);

finalization
  if Assigned(CommonArea) then UnmapViewOfFile(CommonArea);
  if Mapping <> 0 then CloseHandle(Mapping);
end.
.........
........


function UnSetHook: BOOL;
begin
  Result := false;
  if CommonArea^.HookHandle <> 0 then
     begin
       Result := UnhookWindowsHookEx(CommonArea^.HookHandle);
       if Result then CommonArea^.HookHandle := 0;
     end;
end;
.....
....
 FillChar(CommonArea^, SizeOf(CommonArea^), 0);
  tmp := PChar(ExtractFilePath(ParamStr(0)));
  lstrcpy(CommonArea^.DLLsPath, tmp);