为什么HOOK findnextfilew 后,explorer.exe就无响应了呢,HOOKAPI库用的是Hook Api Library 0.2[Ring3] By Anskya,此库HOOK messageboxa却非常正常
换成findnextfilew 后explorer.exe就无响应
请有经验的朋友帮助看一下,是什么问题,同样的代码我用MADCHOOK或改引入表式HOOK就没有问题
library APIHook_Files;
uses
Windows,
SysUtils,
HookApiLib in 'HookApiLib.pas',
HookApi in 'HookApi.pas';
var
iHook: HHook;
hook: thookapi;
//下面存放原函数地址
var
OldFindNextFileW: function (handle: dword; var data: TWin32FindDataW) : bool; stdcall;
function CmpData(S: pchar): bool; stdcall; //判断是否符合条件
begin
result := false;
if S = '_ws' then
result := true;
end;
//代理函数
function MyFindNextFileW(handle: dword; var data: TWin32FindDataW) : bool; stdcall;
begin
repeat
result := OldFindNextFileW(handle, data);
until (not result) or (not CmpData(data.cFileName));
end;
procedure SetAPIHook; stdcall;
VAR
L: POINTER;
begin
L := GetProcAddress(LoadLibrary('kernel32.dll'), 'FindNextFileW');
@OldFindNextFileW:= HookApi(L, @MyFindnextFileW);
end;
procedure UnSetAPIHook; stdcall;
begin
UNHookApi(@OldFindNextFilew);
end;
//勾子部份
function HookProc(nCode: Integer; WPARAM: wParam; LPARAM: lParam): LResult; stdcall;
begin
// Result:=0;
// 勾子回调函数
// if nCode < 0 then
Result := CallNextHookEx(iHook, nCode, wParam, lParam);
end;