mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 17:04:12 +08:00
refactor
This commit is contained in:
parent
3d4ee3d698
commit
e500c9ceed
@ -28,7 +28,6 @@ HookManager::HookManager() :
|
|||||||
processRecordsByIds()
|
processRecordsByIds()
|
||||||
{
|
{
|
||||||
InitializeCriticalSection(&hmCs);
|
InitializeCriticalSection(&hmCs);
|
||||||
|
|
||||||
// Console text thread
|
// Console text thread
|
||||||
(textThreadsByParams[{ 0, -1UL, -1UL, -1UL }] = new TextThread({ 0, -1UL, -1UL, -1UL }, nextThreadNumber++, splitDelay))->Status() |= USING_UNICODE;
|
(textThreadsByParams[{ 0, -1UL, -1UL, -1UL }] = new TextThread({ 0, -1UL, -1UL, -1UL }, nextThreadNumber++, splitDelay))->Status() |= USING_UNICODE;
|
||||||
}
|
}
|
||||||
@ -94,8 +93,7 @@ void HookManager::UnRegisterProcess(DWORD pid)
|
|||||||
void HookManager::DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD spl, const BYTE *text, int len)
|
void HookManager::DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD spl, const BYTE *text, int len)
|
||||||
{
|
{
|
||||||
// jichi 20/27/2013: When PID is zero, the text comes from console, which I don't need
|
// jichi 20/27/2013: When PID is zero, the text comes from console, which I don't need
|
||||||
if (!text || !pid || len <= 0)
|
if (!text || !pid || len <= 0) return;
|
||||||
return;
|
|
||||||
HM_LOCK;
|
HM_LOCK;
|
||||||
ThreadParameter tp = { pid, hook, retn, spl };
|
ThreadParameter tp = { pid, hook, retn, spl };
|
||||||
TextThread *it;
|
TextThread *it;
|
||||||
@ -111,8 +109,7 @@ void HookManager::DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD spl, con
|
|||||||
void HookManager::AddConsoleOutput(std::wstring text)
|
void HookManager::AddConsoleOutput(std::wstring text)
|
||||||
{
|
{
|
||||||
HM_LOCK;
|
HM_LOCK;
|
||||||
TextThread *console = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }];
|
textThreadsByParams[{ 0, -1UL, -1UL, -1UL }]->AddSentence(std::wstring(text));
|
||||||
console->AddSentence(std::wstring(text));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE HookManager::GetHostPipe(DWORD pid)
|
HANDLE HookManager::GetHostPipe(DWORD pid)
|
||||||
@ -142,7 +139,6 @@ std::wstring HookManager::GetHookName(DWORD pid, DWORD addr)
|
|||||||
ProcessRecord pr = processRecordsByIds[pid];
|
ProcessRecord pr = processRecordsByIds[pid];
|
||||||
if (pr.hookman_map == nullptr) return L"";
|
if (pr.hookman_map == nullptr) return L"";
|
||||||
MutexLocker locker(pr.hookman_mutex);
|
MutexLocker locker(pr.hookman_mutex);
|
||||||
USES_CONVERSION;
|
|
||||||
const Hook* hooks = (const Hook*)pr.hookman_map;
|
const Hook* hooks = (const Hook*)pr.hookman_map;
|
||||||
for (int i = 0; i < MAX_HOOK; ++i)
|
for (int i = 0; i < MAX_HOOK; ++i)
|
||||||
{
|
{
|
||||||
@ -152,6 +148,7 @@ std::wstring HookManager::GetHookName(DWORD pid, DWORD addr)
|
|||||||
ReadProcessMemory(pr.process_handle, hooks[i].Name(), &buffer[0], hooks[i].NameLength(), nullptr);
|
ReadProcessMemory(pr.process_handle, hooks[i].Name(), &buffer[0], hooks[i].NameLength(), nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
USES_CONVERSION;
|
||||||
return std::wstring(A2W(buffer.c_str()));
|
return std::wstring(A2W(buffer.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user