C
coolbaby
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是调用hook时用到的一段代码,
里面这段代码主要是什么作用?
// In the entry point proc we create or destroy the file mapping in which we store the
// hook ID and the handle of our main window according to whether we're attaching or
// detaching
procedure EntryPointProc(Reason: Integer);
const
hMapObject: THandle = 0;
begin
case reason of
DLL_PROCESS_ATTACH:
begin
hMapObject := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, SizeOf(THookRec), '_CBT');
rHookRec := MapViewOfFile(hMapObject, FILE_MAP_WRITE, 0, 0, 0);
end;
DLL_PROCESS_DETACH:
begin
try
UnMapViewOfFile(rHookRec);
CloseHandle(hMapObject);
except
end;
end;
end;
end;
// we have to tell the DLL where our entry point proc is and call it as an attach
begin
DllProc := @EntryPointProc;
EntryPointProc(DLL_PROCESS_ATTACH);
end.
里面这段代码主要是什么作用?
// In the entry point proc we create or destroy the file mapping in which we store the
// hook ID and the handle of our main window according to whether we're attaching or
// detaching
procedure EntryPointProc(Reason: Integer);
const
hMapObject: THandle = 0;
begin
case reason of
DLL_PROCESS_ATTACH:
begin
hMapObject := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, SizeOf(THookRec), '_CBT');
rHookRec := MapViewOfFile(hMapObject, FILE_MAP_WRITE, 0, 0, 0);
end;
DLL_PROCESS_DETACH:
begin
try
UnMapViewOfFile(rHookRec);
CloseHandle(hMapObject);
except
end;
end;
end;
end;
// we have to tell the DLL where our entry point proc is and call it as an attach
begin
DllProc := @EntryPointProc;
EntryPointProc(DLL_PROCESS_ATTACH);
end.