diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e045ae..d8650f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,8 +47,8 @@ add_definitions( include_directories( . - vnr - vnr/texthook + + texthook ${CMAKE_BINARY_DIR}/gui ) @@ -76,6 +76,13 @@ set(nexthooker_src gui/window.h gui/TextBuffer.cpp gui/TextBuffer.h + gui/profile/Profile.h + gui/profile/Profile.cpp + gui/profile/pugiconfig.h + gui/profile/pugixml.cpp + gui/profile/pugixml.h + gui/profile/misc.h + gui/profile/misc.cpp ${resource_src} ) @@ -83,7 +90,8 @@ source_group("Resource Files" FILES ${resource_src}) add_executable(${PROJECT_NAME} ${nexthooker_src}) -add_subdirectory(vnr) +add_subdirectory(texthook) +add_subdirectory(vnrhook) # add_subdirectory(profile) set_target_properties(${PROJECT_NAME} PROPERTIES @@ -97,7 +105,7 @@ target_compile_definitions(${PROJECT_NAME} ) target_link_libraries(${PROJECT_NAME} - profile + #profile vnrhost #ithsys #${WDK_HOME}/lib/wxp/i386/ntdll.lib diff --git a/vnr/profile/Profile.cpp b/gui/profile/Profile.cpp similarity index 100% rename from vnr/profile/Profile.cpp rename to gui/profile/Profile.cpp diff --git a/vnr/profile/Profile.h b/gui/profile/Profile.h similarity index 100% rename from vnr/profile/Profile.h rename to gui/profile/Profile.h diff --git a/vnr/profile/misc.cpp b/gui/profile/misc.cpp similarity index 100% rename from vnr/profile/misc.cpp rename to gui/profile/misc.cpp diff --git a/vnr/profile/misc.h b/gui/profile/misc.h similarity index 100% rename from vnr/profile/misc.h rename to gui/profile/misc.h diff --git a/vnr/profile/pugiconfig.h b/gui/profile/pugiconfig.h similarity index 100% rename from vnr/profile/pugiconfig.h rename to gui/profile/pugiconfig.h diff --git a/vnr/profile/pugixml.cpp b/gui/profile/pugixml.cpp similarity index 100% rename from vnr/profile/pugixml.cpp rename to gui/profile/pugixml.cpp diff --git a/vnr/profile/pugixml.h b/gui/profile/pugixml.h similarity index 100% rename from vnr/profile/pugixml.h rename to gui/profile/pugixml.h diff --git a/gui/window.cpp b/gui/window.cpp index ba0c222..81d9a5e 100644 --- a/gui/window.cpp +++ b/gui/window.cpp @@ -347,9 +347,10 @@ void ClickButton(HWND hWnd, HWND h) } } -void ThreadOutput(TextThread* thread, std::wstring output) +std::wstring ThreadOutput(TextThread* thread, std::wstring output) { if (thread->Status() & CURRENT_SELECT) texts->AddText(output, false); + return output; } bool GetHookParam(DWORD pid, DWORD hook_addr, HookParam& hp) diff --git a/vnr/texthook/CMakeLists.txt b/texthook/CMakeLists.txt similarity index 85% rename from vnr/texthook/CMakeLists.txt rename to texthook/CMakeLists.txt index d577ea8..0982464 100644 --- a/vnr/texthook/CMakeLists.txt +++ b/texthook/CMakeLists.txt @@ -6,20 +6,22 @@ # # TODO: Get rid of dependence on msvc's swprintf # DEFINES += _CRT_NON_CONFORMING_SWPRINTFS +project(host) + set(vnrhost_src hookman.h host.h pipe.h textthread.h + winmutex.h hookman.cc host.cc pipe.cc textthread.cc - ${PROJECT_SOURCE_DIR}/winmutex/winmutex.h - ${PROJECT_SOURCE_DIR}/extensions/Extensions.cpp - ${PROJECT_SOURCE_DIR}/extensions/Extensions.h ) +include_directories(../) + add_library(vnrhost SHARED ${vnrhost_src}) set_target_properties(vnrhost PROPERTIES LINK_FLAGS /SUBSYSTEM:WINDOWS) diff --git a/vnr/texthook/hookman.cc b/texthook/hookman.cc similarity index 99% rename from vnr/texthook/hookman.cc rename to texthook/hookman.cc index 53e71fd..7566695 100644 --- a/vnr/texthook/hookman.cc +++ b/texthook/hookman.cc @@ -12,7 +12,7 @@ #include "vnrhook/include/const.h" #include "vnrhook/include/defs.h" #include "vnrhook/include/types.h" -#include "winmutex/winmutex.h" +#include "winmutex.h" #include #define HM_LOCK CriticalSectionLocker hmLocker(hmCs) // Synchronized scope for accessing private data diff --git a/vnr/texthook/hookman.h b/texthook/hookman.h similarity index 100% rename from vnr/texthook/hookman.h rename to texthook/hookman.h diff --git a/vnr/texthook/host.cc b/texthook/host.cc similarity index 98% rename from vnr/texthook/host.cc rename to texthook/host.cc index 71c73fc..74e6cc1 100644 --- a/vnr/texthook/host.cc +++ b/texthook/host.cc @@ -7,7 +7,6 @@ #include "vnrhook/include/const.h" #include "vnrhook/include/defs.h" #include "vnrhook/include/types.h" -#include "extensions/Extensions.h" HANDLE preventDuplicationMutex; @@ -58,7 +57,6 @@ DLLEXPORT bool StartHost() } else { - LoadExtensions(); ::running = true; ::man = new HookManager; return true; diff --git a/vnr/texthook/host.h b/texthook/host.h similarity index 100% rename from vnr/texthook/host.h rename to texthook/host.h diff --git a/vnr/texthook/pipe.cc b/texthook/pipe.cc similarity index 100% rename from vnr/texthook/pipe.cc rename to texthook/pipe.cc diff --git a/vnr/texthook/pipe.h b/texthook/pipe.h similarity index 100% rename from vnr/texthook/pipe.h rename to texthook/pipe.h diff --git a/vnr/texthook/textthread.cc b/texthook/textthread.cc similarity index 91% rename from vnr/texthook/textthread.cc rename to texthook/textthread.cc index ed35928..7481d5c 100644 --- a/vnr/texthook/textthread.cc +++ b/texthook/textthread.cc @@ -8,8 +8,7 @@ #include "host.h" #include "textthread.h" #include "vnrhook/include/const.h" -#include "extensions/Extensions.h" -#include "winmutex/winmutex.h" +#include "winmutex.h" extern HookManager* man; extern HWND dummyWindow; @@ -54,7 +53,7 @@ void TextThread::AddSentence() sentence = std::wstring(converted, MultiByteToWideChar(932, 0, sentenceBuffer.data(), sentenceBuffer.size(), converted, sentenceBuffer.size())); delete[] converted; } - AddSentence(DispatchSentenceToExtensions(sentence, status)); + AddSentence(sentence); sentenceBuffer.clear(); } @@ -62,7 +61,7 @@ void TextThread::AddSentence(std::wstring sentence) { TT_LOCK; sentence.append(L"\r\n"); - if (output) output(this, sentence); + if (output) sentence = output(this, sentence); storage.append(sentence); } diff --git a/vnr/texthook/textthread.h b/texthook/textthread.h similarity index 95% rename from vnr/texthook/textthread.h rename to texthook/textthread.h index 4409d7d..be7857e 100644 --- a/vnr/texthook/textthread.h +++ b/texthook/textthread.h @@ -25,7 +25,7 @@ struct ThreadParameter #define CURRENT_SELECT 0x1000 class TextThread; -typedef void(*ThreadOutputCallback)(TextThread*, std::wstring data); +typedef std::wstring(*ThreadOutputCallback)(TextThread*, std::wstring data); //extern DWORD split_time,repeat_count,global_filter,cyclic_remove; diff --git a/texthook/winmutex.h b/texthook/winmutex.h new file mode 100644 index 0000000..a3b79b9 --- /dev/null +++ b/texthook/winmutex.h @@ -0,0 +1,35 @@ +#pragma once +// winmutex.h +// 12/11/2011 jichi + +#include + +#ifdef _MSC_VER +# pragma warning(disable:4800) // C4800: forcing value to bool +#endif // _MSC_VER + +// Artikash 7/20/2018: these are similar to std::lock guard but use Winapi objects + +class MutexLocker +{ + HANDLE m; +public: + explicit MutexLocker(HANDLE mutex) : m(mutex) + { + WaitForSingleObject(m, 0); + } + ~MutexLocker() { if (m != INVALID_HANDLE_VALUE && m != nullptr) ReleaseMutex(m); } +}; + +class CriticalSectionLocker +{ + CRITICAL_SECTION cs; +public: + explicit CriticalSectionLocker(CRITICAL_SECTION cs) : cs(cs) + { + EnterCriticalSection(&cs); + } + ~CriticalSectionLocker() { LeaveCriticalSection(&cs); } +}; + +// EOF diff --git a/vnr/CMakeLists.txt b/vnr/CMakeLists.txt deleted file mode 100644 index ca0cdf5..0000000 --- a/vnr/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# config.pri -# DEFINES += _SECURE_SCL=0 _SCL_SECURE_NO_WARNINGS -# DEFINES += _CRT_SECURE_NO_WARNINGS - -cmake_minimum_required(VERSION 2.8) - -set(CMAKE_CONFIGURATION_TYPES Debug Release) - -project(vnr) - -set(WDK_HOME "C:\\WinDDK\\7600.16385.1" CACHE FILEPATH "Windows Driver Kit path") - -add_definitions( - /DUNICODE - /D_UNICODE - /D_SECURE_SCL=0 - /D_SCL_SECURE_NO_WARNINGS - /D_CRT_SECURE_NO_WARNINGS -) - -include_directories( - ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/texthook -) - -add_subdirectory(vnrhook) -add_subdirectory(texthook) -add_subdirectory(profile) diff --git a/vnr/extensions/Extensions.cpp b/vnr/extensions/Extensions.cpp deleted file mode 100644 index aa22733..0000000 --- a/vnr/extensions/Extensions.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "Extensions.h" -#include -#include -#include - -std::map extensionFunctions; - -void LoadExtensions() -{ - wchar_t path[MAX_PATH]; - wchar_t* end = path + GetModuleFileNameW(nullptr, path, MAX_PATH); - while (*(--end) != L'\\'); - *(end + 1) = L'*'; - *(end + 2) = L'\0'; - WIN32_FIND_DATAW fileData; - HANDLE file = FindFirstFileW(path, &fileData); - do - { - if (!(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - if (wcsstr(fileData.cFileName, L"_nexthooker_extension.dll")) - { - extensionFunctions[wcstoul(fileData.cFileName, nullptr, 10)] = (ExtensionFunction)GetProcAddress(LoadLibraryW(fileData.cFileName), "NewSentence"); - } - } - } while (FindNextFileW(file, &fileData) != 0); -} - -std::wstring DispatchSentenceToExtensions(std::wstring sentence, DWORD64 info) -{ - for (auto extension : extensionFunctions) - { - sentence = extension.second(sentence, info); - } - return sentence; -} \ No newline at end of file diff --git a/vnr/extensions/Extensions.h b/vnr/extensions/Extensions.h deleted file mode 100644 index 4a08691..0000000 --- a/vnr/extensions/Extensions.h +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -typedef std::wstring (*ExtensionFunction)(std::wstring, DWORD64); -void LoadExtensions(); -std::wstring DispatchSentenceToExtensions(std::wstring sentence, DWORD64 info); \ No newline at end of file diff --git a/vnr/profile/CMakeLists.txt b/vnr/profile/CMakeLists.txt deleted file mode 100644 index a69f2b1..0000000 --- a/vnr/profile/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -set(profile_src - Profile.h - Profile.cpp - pugiconfig.h - pugixml.cpp - pugixml.h - misc.h - misc.cpp -) - -add_library(profile STATIC ${profile_src}) - -target_compile_options(profile PRIVATE - $<$:> - $<$:> -) - -#target_link_libraries(profile comctl32.lib) - -#target_compile_definitions(profile -# PRIVATE -# _CRT_NON_CONFORMING_SWPRINTFS -#) diff --git a/vnr/winmutex/winmutex.h b/vnr/winmutex/winmutex.h deleted file mode 100644 index 78dfd10..0000000 --- a/vnr/winmutex/winmutex.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -// winmutex.h -// 12/11/2011 jichi - -#include - -#ifdef _MSC_VER -# pragma warning(disable:4800) // C4800: forcing value to bool -#endif // _MSC_VER - - class MutexLocker - { - HANDLE m; - public: - explicit MutexLocker(HANDLE mutex) : m(mutex) - { - WaitForSingleObject(m, 0); - } - ~MutexLocker() { if (m != INVALID_HANDLE_VALUE && m != nullptr) ReleaseMutex(m); } - }; - - class CriticalSectionLocker - { - CRITICAL_SECTION cs; - public: - explicit CriticalSectionLocker(CRITICAL_SECTION cs) : cs(cs) - { - EnterCriticalSection(&cs); - } - ~CriticalSectionLocker() { LeaveCriticalSection(&cs); } - }; - -// EOF diff --git a/vnr/vnrhook/CMakeLists.txt b/vnrhook/CMakeLists.txt similarity index 86% rename from vnr/vnrhook/CMakeLists.txt rename to vnrhook/CMakeLists.txt index 1100fb9..9efcc1d 100644 --- a/vnr/vnrhook/CMakeLists.txt +++ b/vnrhook/CMakeLists.txt @@ -17,6 +17,8 @@ # QMAKE_CXXFLAGS_EXCEPTIONS_ON += /EHa # } +project(engine) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(vnrhook_src @@ -42,15 +44,17 @@ set(vnrhook_src src/util/growl.h src/util/util.cc src/util/util.h - ${PROJECT_SOURCE_DIR}/ithsys/ithsys.cc - ${PROJECT_SOURCE_DIR}/disasm/disasm.cc - ${PROJECT_SOURCE_DIR}/memdbg/memdbg.h - ${PROJECT_SOURCE_DIR}/memdbg/memsearch.cc - ${PROJECT_SOURCE_DIR}/memdbg/memsearch.h - ${PROJECT_SOURCE_DIR}/mono/monoobject.h - ${PROJECT_SOURCE_DIR}/mono/monotype.h + src/util/ithsys/ithsys.cc + src/util/disasm/disasm.cc + src/util/memdbg/memdbg.h + src/util/memdbg/memsearch.cc + src/util/memdbg/memsearch.h + src/util/mono/monoobject.h + src/util/mono/monotype.h ) +include_directories(src/util) + add_library(vnrhook SHARED ${vnrhook_src}) enable_language(ASM_MASM) diff --git a/vnr/vnrhook/include/const.h b/vnrhook/include/const.h similarity index 100% rename from vnr/vnrhook/include/const.h rename to vnrhook/include/const.h diff --git a/vnr/vnrhook/include/defs.h b/vnrhook/include/defs.h similarity index 100% rename from vnr/vnrhook/include/defs.h rename to vnrhook/include/defs.h diff --git a/vnr/vnrhook/include/types.h b/vnrhook/include/types.h similarity index 100% rename from vnr/vnrhook/include/types.h rename to vnrhook/include/types.h diff --git a/vnr/vnrhook/src/engine/engine.cc b/vnrhook/src/engine/engine.cc similarity index 100% rename from vnr/vnrhook/src/engine/engine.cc rename to vnrhook/src/engine/engine.cc diff --git a/vnr/vnrhook/src/engine/engine.h b/vnrhook/src/engine/engine.h similarity index 100% rename from vnr/vnrhook/src/engine/engine.h rename to vnrhook/src/engine/engine.h diff --git a/vnr/vnrhook/src/engine/hookdefs.h b/vnrhook/src/engine/hookdefs.h similarity index 100% rename from vnr/vnrhook/src/engine/hookdefs.h rename to vnrhook/src/engine/hookdefs.h diff --git a/vnr/vnrhook/src/engine/match.cc b/vnrhook/src/engine/match.cc similarity index 100% rename from vnr/vnrhook/src/engine/match.cc rename to vnrhook/src/engine/match.cc diff --git a/vnr/vnrhook/src/engine/match.h b/vnrhook/src/engine/match.h similarity index 100% rename from vnr/vnrhook/src/engine/match.h rename to vnrhook/src/engine/match.h diff --git a/vnr/vnrhook/src/engine/mono/funcinfo.h b/vnrhook/src/engine/mono/funcinfo.h similarity index 100% rename from vnr/vnrhook/src/engine/mono/funcinfo.h rename to vnrhook/src/engine/mono/funcinfo.h diff --git a/vnr/vnrhook/src/engine/mono/types.h b/vnrhook/src/engine/mono/types.h similarity index 100% rename from vnr/vnrhook/src/engine/mono/types.h rename to vnrhook/src/engine/mono/types.h diff --git a/vnr/vnrhook/src/engine/pchooks.cc b/vnrhook/src/engine/pchooks.cc similarity index 100% rename from vnr/vnrhook/src/engine/pchooks.cc rename to vnrhook/src/engine/pchooks.cc diff --git a/vnr/vnrhook/src/engine/pchooks.h b/vnrhook/src/engine/pchooks.h similarity index 100% rename from vnr/vnrhook/src/engine/pchooks.h rename to vnrhook/src/engine/pchooks.h diff --git a/vnr/vnrhook/src/engine/ppsspp/funcinfo.h b/vnrhook/src/engine/ppsspp/funcinfo.h similarity index 100% rename from vnr/vnrhook/src/engine/ppsspp/funcinfo.h rename to vnrhook/src/engine/ppsspp/funcinfo.h diff --git a/vnr/vnrhook/src/except.h b/vnrhook/src/except.h similarity index 100% rename from vnr/vnrhook/src/except.h rename to vnrhook/src/except.h diff --git a/vnr/vnrhook/src/hijack/texthook.cc b/vnrhook/src/hijack/texthook.cc similarity index 100% rename from vnr/vnrhook/src/hijack/texthook.cc rename to vnrhook/src/hijack/texthook.cc diff --git a/vnr/vnrhook/src/hijack/texthook.h b/vnrhook/src/hijack/texthook.h similarity index 100% rename from vnr/vnrhook/src/hijack/texthook.h rename to vnrhook/src/hijack/texthook.h diff --git a/vnr/vnrhook/src/main.cc b/vnrhook/src/main.cc similarity index 100% rename from vnr/vnrhook/src/main.cc rename to vnrhook/src/main.cc diff --git a/vnr/vnrhook/src/main.h b/vnrhook/src/main.h similarity index 100% rename from vnr/vnrhook/src/main.h rename to vnrhook/src/main.h diff --git a/vnr/vnrhook/src/pipe.cc b/vnrhook/src/pipe.cc similarity index 100% rename from vnr/vnrhook/src/pipe.cc rename to vnrhook/src/pipe.cc diff --git a/vnr/cpputil/cppcstring.h b/vnrhook/src/util/cpputil/cppcstring.h similarity index 100% rename from vnr/cpputil/cppcstring.h rename to vnrhook/src/util/cpputil/cppcstring.h diff --git a/vnr/disasm/disasm.cc b/vnrhook/src/util/disasm/disasm.cc similarity index 100% rename from vnr/disasm/disasm.cc rename to vnrhook/src/util/disasm/disasm.cc diff --git a/vnr/disasm/disasm.h b/vnrhook/src/util/disasm/disasm.h similarity index 100% rename from vnr/disasm/disasm.h rename to vnrhook/src/util/disasm/disasm.h diff --git a/vnr/vnrhook/src/util/growl.h b/vnrhook/src/util/growl.h similarity index 100% rename from vnr/vnrhook/src/util/growl.h rename to vnrhook/src/util/growl.h diff --git a/vnr/ithsys/ithsys.cc b/vnrhook/src/util/ithsys/ithsys.cc similarity index 100% rename from vnr/ithsys/ithsys.cc rename to vnrhook/src/util/ithsys/ithsys.cc diff --git a/vnr/ithsys/ithsys.h b/vnrhook/src/util/ithsys/ithsys.h similarity index 100% rename from vnr/ithsys/ithsys.h rename to vnrhook/src/util/ithsys/ithsys.h diff --git a/vnr/memdbg/memdbg.h b/vnrhook/src/util/memdbg/memdbg.h similarity index 100% rename from vnr/memdbg/memdbg.h rename to vnrhook/src/util/memdbg/memdbg.h diff --git a/vnr/memdbg/memsearch.cc b/vnrhook/src/util/memdbg/memsearch.cc similarity index 100% rename from vnr/memdbg/memsearch.cc rename to vnrhook/src/util/memdbg/memsearch.cc diff --git a/vnr/memdbg/memsearch.h b/vnrhook/src/util/memdbg/memsearch.h similarity index 100% rename from vnr/memdbg/memsearch.h rename to vnrhook/src/util/memdbg/memsearch.h diff --git a/vnr/mono/monoobject.h b/vnrhook/src/util/mono/monoobject.h similarity index 100% rename from vnr/mono/monoobject.h rename to vnrhook/src/util/mono/monoobject.h diff --git a/vnr/mono/monotype.h b/vnrhook/src/util/mono/monotype.h similarity index 100% rename from vnr/mono/monotype.h rename to vnrhook/src/util/mono/monotype.h diff --git a/vnr/ntdll/ntdll.h b/vnrhook/src/util/ntdll/ntdll.h similarity index 100% rename from vnr/ntdll/ntdll.h rename to vnrhook/src/util/ntdll/ntdll.h diff --git a/vnr/vnrhook/src/util/util.cc b/vnrhook/src/util/util.cc similarity index 100% rename from vnr/vnrhook/src/util/util.cc rename to vnrhook/src/util/util.cc diff --git a/vnr/vnrhook/src/util/util.h b/vnrhook/src/util/util.h similarity index 100% rename from vnr/vnrhook/src/util/util.h rename to vnrhook/src/util/util.h