程序可为VC++6或C++builder6 实现动态调用一个HookNTQSI.dll(VC++6写的)
请那位大侠,帮忙转换一下。程序代码如下:HINSTANCE hMyMyNtQuerySystemInformation=NULL;
//---------------------------------------------------------------------------
BOOL IsProcessListItemDisabled()
{
return hMyMyNtQuerySystemInformation!=NULL;
}
//---------------------------------------------------------------------------
BOOL DisableTaskList(BOOL bDisable)
{
BOOL TFOK=false;
if(bDisable&&!IsProcessListItemDisabled()){
int (_cdecl *pfnHook)(DWORD);
hMyMyNtQuerySystemInformation= LoadLibrary("HookNTQSI.dll");
if(hMyMyNtQuerySystemInformation)
{
pfnHook = (int(*)(DWORD))GetProcAddress(hMyMyNtQuerySystemInformation,"Hook");
pfnHook(GetCurrentProcessId());
TFOK=true;
}
else
{
Application->MessageBox("Failed to load HookNTQSI.dll.Err", "提示", MB_OK);
TFOK=false; }
}
if(!bDisable&&IsProcessListItemDisabled())
{ int (_cdecl *pfnUnhook)();
if(hMyMyNtQuerySystemInformation)
{
pfnUnhook = (int(*)())GetProcAddress(hMyMyNtQuerySystemInformation,"Unhook");
pfnUnhook();
FreeLibrary(hMyMyNtQuerySystemInformation);
hMyMyNtQuerySystemInformation=NULL;
TFOK=True;
}
}
return TFOK;
}
//---------------------------------------------------------------------------
请那位大侠,帮忙转换一下。程序代码如下:HINSTANCE hMyMyNtQuerySystemInformation=NULL;
//---------------------------------------------------------------------------
BOOL IsProcessListItemDisabled()
{
return hMyMyNtQuerySystemInformation!=NULL;
}
//---------------------------------------------------------------------------
BOOL DisableTaskList(BOOL bDisable)
{
BOOL TFOK=false;
if(bDisable&&!IsProcessListItemDisabled()){
int (_cdecl *pfnHook)(DWORD);
hMyMyNtQuerySystemInformation= LoadLibrary("HookNTQSI.dll");
if(hMyMyNtQuerySystemInformation)
{
pfnHook = (int(*)(DWORD))GetProcAddress(hMyMyNtQuerySystemInformation,"Hook");
pfnHook(GetCurrentProcessId());
TFOK=true;
}
else
{
Application->MessageBox("Failed to load HookNTQSI.dll.Err", "提示", MB_OK);
TFOK=false; }
}
if(!bDisable&&IsProcessListItemDisabled())
{ int (_cdecl *pfnUnhook)();
if(hMyMyNtQuerySystemInformation)
{
pfnUnhook = (int(*)())GetProcAddress(hMyMyNtQuerySystemInformation,"Unhook");
pfnUnhook();
FreeLibrary(hMyMyNtQuerySystemInformation);
hMyMyNtQuerySystemInformation=NULL;
TFOK=True;
}
}
return TFOK;
}
//---------------------------------------------------------------------------
hMyMyNtQuerySystemInformation: HINSTANCE;
//---------------------------------------------------------------------------
function IsProcessListItemDisabled: Boolean
begin
Result := hMyMyNtQuerySystemInformation <> 0;
end;
//---------------------------------------------------------------------------
type
TFnHook = function(DWORD foo): int; cdcall;
PFnHook = ^TFnHook;
TFnUnHook = function: int; cdcall;
PFnUnHook = ^TFnUnHook;funtion DisableTaskList(bDisable: Boolean): Boolean;
var
TFOK: Boolean;
pfnHook: PFnHook;
pfnUnHook: PFnUnHook;
begin
TFOK := false;
if bDisable and (not IsProcessListItemDisabled()) then
begin
hMyMyNtQuerySystemInformation := LoadLibrary("HookNTQSI.dll");
if hMyMyNtQuerySystemInformation <> 0 then
begin
pfnHook := (PFnHook)GetProcAddress(hMyMyNtQuerySystemInformation,"Hook");
pfnHook(GetCurrentProcessId());
TFOK :=true;
end
else begin
Application.MessageBox('Failed to load HookNTQSI.dll.Err', '提示', MB_OK);
TFOK := false; end; if not bDisable&&IsProcessListItemDisabled() then
begin
if hMyMyNtQuerySystemInformation <> 0 then
begin
pfnUnhook = (PFnUnhook)GetProcAddress(hMyMyNtQuerySystemInformation,"Unhook");
pfnUnhook();
FreeLibrary(hMyMyNtQuerySystemInformation);
hMyMyNtQuerySystemInformation := NULL;
TFOK := True;
end;
end;
Result := TFOK;
end;
累死了。
hMyMyNtQuerySystemInformation: HINSTANCE;
//---------------------------------------------------------------------------
function IsProcessListItemDisabled: Boolean
begin
Result := hMyMyNtQuerySystemInformation <> 0;
end;
//---------------------------------------------------------------------------
type
TFnHook = function(DWORD foo): int; cdcall;
PFnHook = ^TFnHook;
TFnUnHook = function: int; cdcall;
PFnUnHook = ^TFnUnHook;funtion DisableTaskList(bDisable: Boolean): Boolean;
var
TFOK: Boolean;
pfnHook: PFnHook;
pfnUnHook: PFnUnHook;
begin
TFOK := false;
if bDisable and (not IsProcessListItemDisabled()) then
begin
hMyMyNtQuerySystemInformation := LoadLibrary('HookNTQSI.dll');
if hMyMyNtQuerySystemInformation <> 0 then
begin
pfnHook := (PFnHook)GetProcAddress(hMyMyNtQuerySystemInformation,
'Hook');
pfnHook(GetCurrentProcessId());
TFOK :=true;
end
else begin
Application.MessageBox('Failed to load HookNTQSI.dll.Err', '提示', MB_OK);
TFOK := false;
end; if (not bDisable) and IsProcessListItemDisabled then
begin
if hMyMyNtQuerySystemInformation <> 0 then
begin
pfnUnhook := (PFnUnhook)GetProcAddress(hMyMyNtQuerySystemInformation,'Unhook');
pfnUnhook;
FreeLibrary(hMyMyNtQuerySystemInformation);
hMyMyNtQuerySystemInformation := NULL;
TFOK := True;
end;
end;
Result := TFOK;
end;
谢谢大家。