mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-24 01:14:12 +08:00
notify hook removal via pipe - fix hook rewrite bug
This commit is contained in:
parent
971e35dc10
commit
11d75c2987
@ -82,6 +82,7 @@ enum HostNotificationType {
|
|||||||
HOST_NOTIFICATION = -1 // null type
|
HOST_NOTIFICATION = -1 // null type
|
||||||
, HOST_NOTIFICATION_TEXT = 0
|
, HOST_NOTIFICATION_TEXT = 0
|
||||||
, HOST_NOTIFICATION_NEWHOOK = 1
|
, HOST_NOTIFICATION_NEWHOOK = 1
|
||||||
|
, HOST_NOTIFICATION_RMVHOOK = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
// jichi 9/8/2013: The meaning are guessed
|
// jichi 9/8/2013: The meaning are guessed
|
||||||
|
@ -725,6 +725,7 @@ int TextHook::ClearHook()
|
|||||||
// current_available = this;
|
// current_available = this;
|
||||||
currentHook--;
|
currentHook--;
|
||||||
ReleaseMutex(hmMutex);
|
ReleaseMutex(hmMutex);
|
||||||
|
NotifyHookRemove(hp.address);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
void ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text
|
void ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text
|
||||||
void NotifyHookInsert(HookParam hp, LPCSTR name);
|
void NotifyHookInsert(HookParam hp, LPCSTR name);
|
||||||
|
void NotifyHookRemove(DWORD addr);
|
||||||
DWORD NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE);
|
DWORD NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE);
|
||||||
DWORD RemoveHook(DWORD addr);
|
DWORD RemoveHook(DWORD addr);
|
||||||
DWORD SwitchTrigger(DWORD on);
|
DWORD SwitchTrigger(DWORD on);
|
||||||
|
@ -69,8 +69,6 @@ DWORD WINAPI PipeManager(LPVOID unused)
|
|||||||
break;
|
break;
|
||||||
case HOST_COMMAND_REMOVE_HOOK:
|
case HOST_COMMAND_REMOVE_HOOK:
|
||||||
{
|
{
|
||||||
HANDLE hookRemovalEvent = OpenEventW(SYNCHRONIZE | EVENT_MODIFY_STATE, FALSE, ITH_REMOVEHOOK_EVENT);
|
|
||||||
|
|
||||||
TextHook *in = hookman;
|
TextHook *in = hookman;
|
||||||
for (int i = 0; i < currentHook; in++)
|
for (int i = 0; i < currentHook; in++)
|
||||||
{
|
{
|
||||||
@ -84,9 +82,6 @@ DWORD WINAPI PipeManager(LPVOID unused)
|
|||||||
{
|
{
|
||||||
in->ClearHook();
|
in->ClearHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEvent(hookRemovalEvent);
|
|
||||||
CloseHandle(hookRemovalEvent);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HOST_COMMAND_DETACH:
|
case HOST_COMMAND_DETACH:
|
||||||
@ -111,7 +106,6 @@ void ConsoleOutput(LPCSTR text)
|
|||||||
WriteFile(::hookPipe, buffer, strlen(text) + sizeof(DWORD) * 2, &unused, nullptr);
|
WriteFile(::hookPipe, buffer, strlen(text) + sizeof(DWORD) * 2, &unused, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Artikash 7/3/2018: TODO: Finish using this in vnrhost instead of section to deliver hook info
|
|
||||||
void NotifyHookInsert(HookParam hp, LPCSTR name)
|
void NotifyHookInsert(HookParam hp, LPCSTR name)
|
||||||
{
|
{
|
||||||
BYTE buffer[PIPE_BUFFER_SIZE];
|
BYTE buffer[PIPE_BUFFER_SIZE];
|
||||||
@ -124,4 +118,15 @@ void NotifyHookInsert(HookParam hp, LPCSTR name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotifyHookRemove(DWORD addr)
|
||||||
|
{
|
||||||
|
BYTE buffer[sizeof(DWORD) * 3];
|
||||||
|
*(DWORD*)buffer = HOST_NOTIFICATION;
|
||||||
|
*(DWORD*)(buffer + sizeof(DWORD)) = HOST_NOTIFICATION_RMVHOOK;
|
||||||
|
*(DWORD*)(buffer + sizeof(DWORD) * 2) = addr;
|
||||||
|
DWORD unused;
|
||||||
|
WriteFile(::hookPipe, buffer, sizeof(DWORD) * 3, &unused, nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user