start implementing hostinterop

This commit is contained in:
Akash Mozumdar 2018-07-20 17:18:27 -04:00
parent a8cdee67e8
commit 62b5f5fe8f
6 changed files with 9 additions and 9 deletions

Binary file not shown.

View File

@ -41,7 +41,7 @@ DWORD ProcessCommand(const std::wstring& cmd, DWORD pid)
{
HookParam hp = {};
if (Parse(m[1].str(), hp))
InsertHook(pid, &hp);
InsertHook(pid, hp);
}
else if (regex_match(cmd, m, wregex(L":(?:h|help)", wregex::icase)))
{

View File

@ -149,7 +149,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (StartHost())
{
SetUnhandledExceptionFilter(UnhandledExcept);
GetHostHookManager(&man);
man = GetHostHookManager();
pfman = new ProfileManager();
DefaultSettings();
LoadSettings();

View File

@ -488,7 +488,7 @@ void RegisterProcess(DWORD pid)
{
for (auto i = pf->Hooks().begin(); i != pf->Hooks().end(); ++i)
{
InsertHook(pid, &i->get()->HP(), toMultiByteString(i->get()->Name()));
InsertHook(pid, i->get()->HP(), toMultiByteString(i->get()->Name()));
}
}
}

View File

@ -117,19 +117,19 @@ DLLEXPORT bool DetachProcessById(DWORD processId)
return WriteFile(man->GetHostPipe(processId), &command, sizeof(command), &unused, nullptr);
}
DLLEXPORT void GetHostHookManager(HookManager** hookman)
DLLEXPORT HookManager* GetHostHookManager()
{
*hookman = man;
return man;
}
DLLEXPORT bool InsertHook(DWORD pid, const HookParam *hp, std::string name)
DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name)
{
HANDLE commandPipe = man->GetHostPipe(pid);
if (commandPipe == nullptr) return false;
BYTE buffer[PIPE_BUFFER_SIZE] = {};
*(DWORD*)buffer = HOST_COMMAND_NEW_HOOK;
*(HookParam*)(buffer + sizeof(DWORD)) = *hp;
*(HookParam*)(buffer + sizeof(DWORD)) = hp;
if (name.size()) strcpy((char*)buffer + sizeof(DWORD) + sizeof(HookParam), name.c_str());
DWORD unused;
return WriteFile(commandPipe, buffer, sizeof(DWORD) + sizeof(HookParam) + name.size(), &unused, nullptr);

View File

@ -12,10 +12,10 @@
DLLEXPORT void OpenHost();
DLLEXPORT bool StartHost();
DLLEXPORT void CloseHost();
DLLEXPORT void GetHostHookManager(HookManager **hookman);
DLLEXPORT HookManager* GetHostHookManager();
DLLEXPORT bool InjectProcessById(DWORD pid, DWORD timeout = 5000);
DLLEXPORT bool DetachProcessById(DWORD pid);
DLLEXPORT bool InsertHook(DWORD pid, const HookParam *hp, std::string name = "");
DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = "");
DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr);
// EOF