diff --git a/GUI.sln b/GUI.sln index 1a657a6..22cde48 100644 --- a/GUI.sln +++ b/GUI.sln @@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 15.0.27703.2042 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GUI", "GUI\GUI.csproj", "{D847D0DC-78F5-4722-8E06-1A124B957353}" + ProjectSection(ProjectDependencies) = postProject + {0DF42D0B-0F87-475E-9E2C-9E32776B2AD5} = {0DF42D0B-0F87-475E-9E2C-9E32776B2AD5} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HostInterop", "HostInterop\HostInterop.vcxproj", "{0DF42D0B-0F87-475E-9E2C-9E32776B2AD5}" EndProject diff --git a/GUI/GUI.csproj b/GUI/GUI.csproj index 3a00a0d..16eeb66 100644 --- a/GUI/GUI.csproj +++ b/GUI/GUI.csproj @@ -52,6 +52,10 @@ true + + False + ..\Builds\Debug\Debug\HostInterop.dll + @@ -95,11 +99,5 @@ - - - {0df42d0b-0f87-475e-9e2c-9e32776b2ad5} - HostInterop - - \ No newline at end of file diff --git a/HostInterop/AssemblyInfo.cpp b/HostInterop/AssemblyInfo.cpp index c11d2a3..58c692e 100644 Binary files a/HostInterop/AssemblyInfo.cpp and b/HostInterop/AssemblyInfo.cpp differ diff --git a/HostInterop/HostInterop.cpp b/HostInterop/HostInterop.cpp index bef4b40..5667ebe 100644 Binary files a/HostInterop/HostInterop.cpp and b/HostInterop/HostInterop.cpp differ diff --git a/HostInterop/HostInterop.h b/HostInterop/HostInterop.h index 1f9aad4..e6daf99 100644 Binary files a/HostInterop/HostInterop.h and b/HostInterop/HostInterop.h differ diff --git a/HostInterop/HostInterop.vcxproj b/HostInterop/HostInterop.vcxproj index 6ccee25..9bf83ac 100644 --- a/HostInterop/HostInterop.vcxproj +++ b/HostInterop/HostInterop.vcxproj @@ -92,7 +92,7 @@ Level3 Disabled WIN32;_DEBUG;%(PreprocessorDefinitions) - Use + NotUsing ..\Builds\Debug\texthook\vnrhost.lib;%(AdditionalDependencies) @@ -134,19 +134,12 @@ - - - - - - Create - Create - Create - Create - + + + diff --git a/HostInterop/HostInterop.vcxproj.filters b/HostInterop/HostInterop.vcxproj.filters index a76d3b0..68e44a6 100644 --- a/HostInterop/HostInterop.vcxproj.filters +++ b/HostInterop/HostInterop.vcxproj.filters @@ -6,18 +6,10 @@ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - {93995380-89BD-4b04-88EB-625FBE52EBFB} + {344ee2d7-eda2-4003-8c18-092ff651deb3} h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - Header Files - - - Header Files - - Source Files @@ -25,8 +17,10 @@ Source Files - - Source Files - + + + + Header Files + \ No newline at end of file diff --git a/HostInterop/stdafx.cpp b/HostInterop/stdafx.cpp deleted file mode 100644 index 08343af..0000000 Binary files a/HostInterop/stdafx.cpp and /dev/null differ diff --git a/HostInterop/stdafx.h b/HostInterop/stdafx.h deleted file mode 100644 index 866b7f5..0000000 Binary files a/HostInterop/stdafx.h and /dev/null differ diff --git a/oldgui/ProcessWindow.cpp b/oldgui/ProcessWindow.cpp index 91eccee..06e62f9 100644 --- a/oldgui/ProcessWindow.cpp +++ b/oldgui/ProcessWindow.cpp @@ -75,7 +75,7 @@ void ProcessWindow::RefreshProcess() void ProcessWindow::AttachProcess() { DWORD pid = GetSelectedPID(); - if (InjectProcessById(pid)) + if (InjectProcess(pid)) RefreshThreadWithPID(pid, true); else ConsoleOutput(L"NextHooker: could not inject"); @@ -84,7 +84,7 @@ void ProcessWindow::AttachProcess() void ProcessWindow::DetachProcess() { DWORD pid = GetSelectedPID(); - DetachProcessById(pid); + ::DetachProcess(pid); RefreshThreadWithPID(pid, false); } diff --git a/oldgui/command.cpp b/oldgui/command.cpp index 3b791f8..02197d4 100644 --- a/oldgui/command.cpp +++ b/oldgui/command.cpp @@ -35,13 +35,13 @@ DWORD ProcessCommand(const std::wstring& cmd, DWORD pid) if (regex_match(cmd, m, wregex(L"/p(\\d+)", wregex::icase))) { pid = std::stoul(m[1].str()); - InjectProcessById(pid); + InjectProcess(pid); } else if (regex_match(cmd, m, wregex(L"/h(.+)", wregex::icase))) { 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))) { diff --git a/oldgui/main.cpp b/oldgui/main.cpp index a884736..bc72605 100644 --- a/oldgui/main.cpp +++ b/oldgui/main.cpp @@ -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(); diff --git a/oldgui/window.cpp b/oldgui/window.cpp index 81d9a5e..ba0abc1 100644 --- a/oldgui/window.cpp +++ b/oldgui/window.cpp @@ -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())); } } } diff --git a/texthook/hookman.cc b/texthook/hookman.cc index 9d723ca..ea0ec1b 100644 --- a/texthook/hookman.cc +++ b/texthook/hookman.cc @@ -141,10 +141,9 @@ void HookManager::DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD spl, con it->AddText(text, len); } -void HookManager::AddConsoleOutput(LPCWSTR text) +void HookManager::AddConsoleOutput(std::wstring text) { HM_LOCK; - int len = wcslen(text) * 2; TextThread *console = textThreadsByParams[{ 0, -1UL, -1UL, -1UL }]; console->AddSentence(std::wstring(text)); } diff --git a/texthook/hookman.h b/texthook/hookman.h index fb5328a..f2b1241 100644 --- a/texthook/hookman.h +++ b/texthook/hookman.h @@ -42,7 +42,7 @@ public: void ClearCurrent(); void SelectCurrent(DWORD num); void SetCurrent(TextThread *it); - void AddConsoleOutput(LPCWSTR text); + void AddConsoleOutput(std::wstring text); void DispatchText(DWORD pid, DWORD hook, DWORD retn, DWORD split, const BYTE *text, int len); void RemoveProcessContext(DWORD pid); // private void RemoveSingleHook(DWORD pid, DWORD addr); diff --git a/texthook/host.cc b/texthook/host.cc index 5e5393b..8a691e0 100644 --- a/texthook/host.cc +++ b/texthook/host.cc @@ -78,7 +78,7 @@ DLLEXPORT void CloseHost() } } -DLLEXPORT bool InjectProcessById(DWORD processId, DWORD timeout) +DLLEXPORT bool InjectProcess(DWORD processId, DWORD timeout) { if (processId == GetCurrentProcessId()) return false; @@ -110,26 +110,26 @@ DLLEXPORT bool InjectProcessById(DWORD processId, DWORD timeout) return false; } -DLLEXPORT bool DetachProcessById(DWORD processId) +DLLEXPORT bool DetachProcess(DWORD processId) { DWORD command = HOST_COMMAND_DETACH; DWORD unused; 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); diff --git a/texthook/host.h b/texthook/host.h index 3919943..1166693 100644 --- a/texthook/host.h +++ b/texthook/host.h @@ -12,10 +12,10 @@ DLLEXPORT void OpenHost(); DLLEXPORT bool StartHost(); DLLEXPORT void CloseHost(); -DLLEXPORT void GetHostHookManager(HookManager **hookman); -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 HookManager* GetHostHookManager(); +DLLEXPORT bool InjectProcess(DWORD pid, DWORD timeout = 5000); +DLLEXPORT bool DetachProcess(DWORD pid); +DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = ""); DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr); // EOF