Revert "remove unused code"

This reverts commit b3496222ec1b24df40365d77e8ea6c902873cbc1.
This commit is contained in:
Akash Mozumdar 2018-05-24 05:35:50 -04:00
parent b3496222ec
commit fe552f6e19
3 changed files with 13 additions and 21 deletions

View File

@ -36,6 +36,15 @@ void ConsoleOutput(LPCWSTR text)
man->AddConsoleOutput(text); man->AddConsoleOutput(text);
} }
void ConsoleOutput(LPCSTR text)
{
int wc_length = MB_WC_count(text, -1);
LPWSTR wc = new WCHAR[wc_length];
MB_WC(text, wc, wc_length);
man->AddConsoleOutput(wc);
delete wc;
}
std::wstring GetProcessPath(DWORD pid) std::wstring GetProcessPath(DWORD pid)
{ {
UniqueHandle hProc(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); UniqueHandle hProc(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid));

View File

@ -752,6 +752,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
man->RegisterProcessDetachCallback(RemoveProcessList); man->RegisterProcessDetachCallback(RemoveProcessList);
man->RegisterProcessNewHookCallback(RefreshProfileOnNewHook); man->RegisterProcessNewHookCallback(RefreshProfileOnNewHook);
man->RegisterAddRemoveLinkCallback(AddRemoveLink); man->RegisterAddRemoveLinkCallback(AddRemoveLink);
man->RegisterConsoleCallback(ConsoleOutput);
StartHost(); StartHost();
{ {
static const WCHAR program_name[] = L"Interactive Text Hooker"; static const WCHAR program_name[] = L"Interactive Text Hooker";

View File

@ -7,7 +7,6 @@
#include "host/avl_p.h" #include "host/avl_p.h"
#include "host/textthread.h" #include "host/textthread.h"
#include "winmutex/winmutex.h" #include "winmutex/winmutex.h"
#include <unordered_map>
namespace pugi { namespace pugi {
class xml_node; class xml_node;
@ -26,9 +25,6 @@ struct ProcessRecord {
HANDLE hookman_mutex; HANDLE hookman_mutex;
HANDLE hookman_section; HANDLE hookman_section;
LPVOID hookman_map; LPVOID hookman_map;
HANDLE hostPipe;
HANDLE hookPipe;
HANDLE processThread;
}; };
class ThreadTable : public MyVector<TextThread *, 0x40> class ThreadTable : public MyVector<TextThread *, 0x40>
@ -44,19 +40,6 @@ struct IHFSERVICE TLen { int operator()(const ThreadParameter *t); };
typedef DWORD (*ProcessEventCallback)(DWORD pid); typedef DWORD (*ProcessEventCallback)(DWORD pid);
struct ThreadParameterHasher
{
size_t operator()(const ThreadParameter& threadParam) const
{
return std::hash<DWORD>()((threadParam.pid << 4) + threadParam.hook + threadParam.retn + threadParam.spl);
}
};
//bool operator==(const ThreadParameter& one, const ThreadParameter& two)
//{
// return one.pid == two.pid && one.hook == two.hook && one.retn == two.retn && one.spl == two.spl;
//}
class IHFSERVICE HookManager : public AVLTree<ThreadParameter, DWORD, TCmp, TCpy, TLen> class IHFSERVICE HookManager : public AVLTree<ThreadParameter, DWORD, TCmp, TCpy, TLen>
{ {
public: public:
@ -90,6 +73,9 @@ public:
HANDLE GetCmdHandleByPID(DWORD pid); HANDLE GetCmdHandleByPID(DWORD pid);
ConsoleCallback RegisterConsoleCallback(ConsoleCallback cf)
{ return (ConsoleCallback)_InterlockedExchange((long*)&console,(long)cf); }
ThreadEventCallback RegisterThreadCreateCallback(ThreadEventCallback cf) ThreadEventCallback RegisterThreadCreateCallback(ThreadEventCallback cf)
{ return (ThreadEventCallback)_InterlockedExchange((long*)&create,(long)cf); } { return (ThreadEventCallback)_InterlockedExchange((long*)&create,(long)cf); }
@ -120,10 +106,6 @@ public:
void GetProfile(DWORD pid, pugi::xml_node profile_node); void GetProfile(DWORD pid, pugi::xml_node profile_node);
private: private:
std::unordered_map<DWORD, ProcessRecord*> processRecords;
std::unordered_map<ThreadParameter, TextThread*, ThreadParameterHasher> threadTable;
typedef win_mutex<CRITICAL_SECTION> mutex_type; typedef win_mutex<CRITICAL_SECTION> mutex_type;
mutex_type hmcs; mutex_type hmcs;