├── .gitignore ├── vnr ├── exclude.txt ├── winmutex │ ├── winmutex │ └── winmutex.pri ├── ntdll │ └── ntdll.pri ├── ccutil │ ├── ccutil.pri │ └── ccmacro.h ├── mono │ ├── mono.pri │ ├── monotype.h │ └── monoobject.h ├── hashutil │ ├── hashutil.pri │ ├── hashutil.h │ └── hashstr.h ├── winkey │ ├── winkey.pri │ └── winkey.h ├── disasm │ ├── disasm.pri │ ├── disasm.pro │ └── disasm.h ├── vnrhook │ ├── vnrhook.pri │ ├── TRASH │ │ ├── xp.txt │ │ ├── dllconfig.pri │ │ ├── string.h │ │ ├── hookxp.pro │ │ └── memory.h │ ├── src │ │ ├── engine │ │ │ ├── hookdefs.h │ │ │ ├── pchooks.h │ │ │ ├── match.h │ │ │ └── mono │ │ │ │ ├── types.h │ │ │ │ └── funcinfo.h │ │ ├── except.h │ │ ├── main.h │ │ ├── util │ │ │ ├── util.h │ │ │ └── growl.h │ │ └── hijack │ │ │ └── texthook.h │ ├── include │ │ ├── defs.h │ │ └── types.h │ ├── vnrhook.pro │ └── CMakeLists.txt ├── winversion │ ├── winversion.pri │ ├── winversion.h │ └── winversion.cc ├── winmaker │ ├── winmaker.pri │ ├── winmaker.h │ └── winmaker.cc ├── memdbg │ ├── memdbg.pri │ └── memdbg.h ├── ntinspect │ ├── ntinspect.pri │ └── ntinspect.h ├── ithsys │ ├── ithsys.pri │ ├── CMakeLists.txt │ ├── ithsys.pro │ └── ithsys.h ├── windbg │ ├── unload.h │ ├── windbg.h │ ├── windbg.pri │ ├── unload.cc │ ├── windbg_p.h │ ├── hijack.h │ ├── util.h │ ├── util.cc │ ├── inject.h │ ├── hijack.cc │ └── inject.cc ├── winseh │ ├── winseh_safe.cc │ ├── winseh_unsafe.cc │ ├── winseh_unsafe.pri │ ├── safeseh.asm │ ├── Makefile │ ├── winseh_safe.pri │ └── winseh.cc ├── wintimer │ ├── wintimer.pri │ ├── wintimer.pro │ ├── wintimer.cc │ ├── wintimerbase.h │ ├── wintimerbase.cc │ └── wintimer.h ├── cpputil │ ├── cpputil.pri │ ├── cppstring.h │ ├── cppmath.h │ ├── cpptype.h │ ├── cppunicode.h │ ├── cpppath.h │ ├── cpplocale.h │ ├── cppmarshal.h │ └── cppcstring.h ├── texthook │ ├── host │ │ ├── settings.h │ │ ├── config.h │ │ ├── host.pri │ │ ├── host.h │ │ ├── host_p.h │ │ ├── CMakeLists.txt │ │ ├── textthread_p.h │ │ └── textthread.h │ ├── texthook.pri │ ├── texthook_config.h │ ├── winapi_p.h │ ├── ihf.txt │ ├── ith_p.h │ ├── winapi_p.cc │ ├── texthook.rc │ ├── texthook_p.h │ ├── texthook.pro │ ├── texthook_static.pri │ ├── textthread_p.h │ ├── growl.h │ ├── texthook.h │ └── ihf_p.h ├── profile │ ├── CMakeLists.txt │ ├── misc.h │ ├── pugiconfig.hpp │ └── Profile.h ├── CMakeLists.txt ├── sakurakit │ ├── skautorun.h │ ├── skhash.h │ ├── sakurakit.pri │ ├── skdebug.h │ └── skglobal.h └── copy_vnr.cmd ├── gui ├── icon1.ico ├── version.h.in ├── TextBuffer.h ├── ProcessWindow.h ├── window.h ├── TextBuffer.cpp ├── ProfileManager.h ├── resource.h ├── CustomFilter.h ├── ITH.h ├── CustomFilter.cpp ├── command.cpp ├── utility.h ├── language.h ├── ITHVNR.rc └── ProcessWindow.cpp ├── i18n └── gui_korean │ ├── ITHVNR.rc │ ├── icon1.ico │ ├── window.cpp │ ├── version.h.in │ ├── TextBuffer.h │ ├── ProcessWindow.h │ ├── window.h │ ├── TextBuffer.cpp │ ├── ProfileManager.h │ ├── resource.h │ ├── CustomFilter.h │ ├── ITH.h │ ├── CustomFilter.cpp │ ├── command.cpp │ ├── utility.h │ ├── language.h │ └── ProcessWindow.cpp ├── .gitattributes ├── README.md └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | gui/command.cpp -------------------------------------------------------------------------------- /vnr/exclude.txt: -------------------------------------------------------------------------------- 1 | .bak 2 | -------------------------------------------------------------------------------- /vnr/winmutex/winmutex: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "winmutex/winmutex.h" 3 | -------------------------------------------------------------------------------- /gui/icon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mireado/ITHVNR/HEAD/gui/icon1.ico -------------------------------------------------------------------------------- /i18n/gui_korean/ITHVNR.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mireado/ITHVNR/HEAD/i18n/gui_korean/ITHVNR.rc -------------------------------------------------------------------------------- /i18n/gui_korean/icon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mireado/ITHVNR/HEAD/i18n/gui_korean/icon1.ico -------------------------------------------------------------------------------- /i18n/gui_korean/window.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mireado/ITHVNR/HEAD/i18n/gui_korean/window.cpp -------------------------------------------------------------------------------- /vnr/ntdll/ntdll.pri: -------------------------------------------------------------------------------- 1 | # ntdll.pri 2 | # 4/9/2012 jichi 3 | 4 | DEFINES += WITH_LIB_NTDLL 5 | 6 | DEPENDPATH += $$PWD 7 | 8 | HEADERS += $$PWD/ntdll.h 9 | 10 | # EOF 11 | -------------------------------------------------------------------------------- /gui/version.h.in: -------------------------------------------------------------------------------- 1 | const wchar_t* build_date=L"27.01.2013"; 2 | const WCHAR program_version[] = L"@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"; 3 | -------------------------------------------------------------------------------- /vnr/ccutil/ccutil.pri: -------------------------------------------------------------------------------- 1 | # ccutil.pri 2 | # 1/31/2012 jichi 3 | 4 | DEFINES += WITH_LIB_CCUTIL 5 | 6 | DEPENDPATH += $$PWD 7 | 8 | HEADERS += \ 9 | $$PWD/ccmacro.h 10 | 11 | # EOF 12 | -------------------------------------------------------------------------------- /i18n/gui_korean/version.h.in: -------------------------------------------------------------------------------- 1 | const wchar_t* build_date=L"27.01.2013"; 2 | const WCHAR program_version[] = L"@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"; 3 | -------------------------------------------------------------------------------- /vnr/mono/mono.pri: -------------------------------------------------------------------------------- 1 | # mono.pri 2 | # 9/26/2012 jichi 3 | 4 | DEFINES += WITH_LIB_MONO 5 | 6 | DEPENDPATH += $$PWD 7 | 8 | HEADERS += \ 9 | $$PWD/monoobject.h \ 10 | $$PWD/monotype.h 11 | 12 | # EOF 13 | -------------------------------------------------------------------------------- /vnr/hashutil/hashutil.pri: -------------------------------------------------------------------------------- 1 | # hashutil.pri 2 | # 6/28/2011 jichi 3 | 4 | DEFINES += WITH_LIB_HASHUTIL 5 | DEPENDPATH += $$PWD 6 | 7 | HEADERS += \ 8 | $$PWD/hashstr.h \ 9 | $$PWD/hashutil.h 10 | 11 | # EOF 12 | -------------------------------------------------------------------------------- /vnr/winmutex/winmutex.pri: -------------------------------------------------------------------------------- 1 | # winmutex.pri 2 | # 3/8/2013 jichi 3 | 4 | DEFINES += WITH_LIB_WINMUTEX 5 | 6 | DEPENDPATH += $$PWD 7 | #LIBS += -lkernel32 -luser32 8 | 9 | HEADERS += \ 10 | $$PWD/winmutex \ 11 | $$PWD/winmutex.h 12 | 13 | # EOF 14 | -------------------------------------------------------------------------------- /vnr/winkey/winkey.pri: -------------------------------------------------------------------------------- 1 | # winkey.pri 2 | # 7/20/2011 jichi 3 | win32 { 4 | 5 | DEFINES += WITH_LIB_WINKEY 6 | 7 | LIBS += -luser32 8 | 9 | DEPENDPATH += $$PWD 10 | 11 | HEADERS += $$PWD/winkey.h 12 | #SOURCES += $$PWD/winkey.cc 13 | } 14 | 15 | # EOF 16 | -------------------------------------------------------------------------------- /vnr/disasm/disasm.pri: -------------------------------------------------------------------------------- 1 | # disasm.pri 2 | # 1/31/2012 jichi 3 | win32 { 4 | 5 | DEFINES += WITH_LIB_DISASM 6 | LIBS += -ldisasm 7 | DEPENDPATH += $$PWD 8 | HEADERS += $$PWD/disasm.h 9 | #SOURCES += $$PWD/disasm.cc 10 | 11 | } 12 | 13 | # EOF 14 | -------------------------------------------------------------------------------- /vnr/vnrhook/vnrhook.pri: -------------------------------------------------------------------------------- 1 | # vnrhook.pri 2 | # 8/21/2013 jichi 3 | 4 | DEFINES += WITH_LIB_VNRHOOK 5 | DEPENDPATH += $$PWD/include 6 | 7 | HEADERS += \ 8 | $$PWD/include/const.h \ 9 | $$PWD/include/defs.h \ 10 | $$PWD/include/types.h 11 | 12 | # EOF 13 | -------------------------------------------------------------------------------- /vnr/winversion/winversion.pri: -------------------------------------------------------------------------------- 1 | # winversion.pri 2 | # 9/5/2014 jichi 3 | win32 { 4 | DEFINES += WITH_LIB_WINVERSION 5 | 6 | LIBS += -lversion 7 | 8 | DEPENDPATH += $$PWD 9 | 10 | HEADERS += $$PWD/winversion.h 11 | SOURCES += $$PWD/winversion.cc 12 | } 13 | 14 | # EOF 15 | -------------------------------------------------------------------------------- /vnr/winmaker/winmaker.pri: -------------------------------------------------------------------------------- 1 | # wintimer.pri 2 | # 7/20/2011 jichi 3 | win32 { 4 | 5 | DEFINES += WITH_LIB_WINMAKER 6 | 7 | #LIBS += -lkernel32 -luser32 8 | 9 | DEPENDPATH += $$PWD 10 | 11 | HEADERS += $$PWD/winmaker.h 12 | SOURCES += $$PWD/winmaker.cc 13 | } 14 | 15 | # EOF 16 | -------------------------------------------------------------------------------- /vnr/memdbg/memdbg.pri: -------------------------------------------------------------------------------- 1 | # ntinspect.pri 2 | # 4/20/2014 jichi 3 | win32 { 4 | 5 | DEFINES += WITH_LIB_MEMDBG 6 | 7 | DEPENDPATH += $$PWD 8 | 9 | HEADERS += \ 10 | $$PWD/memdbg.h \ 11 | $$PWD/memsearch.h 12 | 13 | SOURCES += \ 14 | $$PWD/memsearch.cc 15 | } 16 | 17 | # EOF 18 | -------------------------------------------------------------------------------- /vnr/disasm/disasm.pro: -------------------------------------------------------------------------------- 1 | # sys.pro 2 | # 8/21/2013 jichi 3 | # Build ITH_engine.dll 4 | 5 | CONFIG += noqt noeh staticlib 6 | include(../../../config.pri) 7 | 8 | ## Sources 9 | 10 | TEMPLATE = lib 11 | TARGET = disasm 12 | 13 | HEADERS += disasm.h 14 | SOURCES += disasm.cc 15 | 16 | # EOF 17 | -------------------------------------------------------------------------------- /vnr/ntinspect/ntinspect.pri: -------------------------------------------------------------------------------- 1 | # ntinspect.pri 2 | # 4/20/2014 jichi 3 | win32 { 4 | 5 | DEFINES += WITH_LIB_NTINSPECT 6 | 7 | DEPENDPATH += $$PWD 8 | 9 | HEADERS += $$PWD/ntinspect.h 10 | SOURCES += $$PWD/ntinspect.cc 11 | 12 | LIBS += -L$$WDK7_HOME/lib/wxp/i386 -lntdll 13 | 14 | } 15 | 16 | # EOF 17 | -------------------------------------------------------------------------------- /vnr/ithsys/ithsys.pri: -------------------------------------------------------------------------------- 1 | # ithsys.pri 2 | # 8/21/2013 jichi 3 | 4 | DEFINES += WITH_LIB_ITHSYS 5 | LIBS += -lithsys 6 | DEPENDPATH += $$PWD 7 | HEADERS += $$PWD/ithsys.h 8 | #SOURCES += $$PWD/ithsys.cc 9 | 10 | #include($$LIBDIR/winddk/winddk.pri) 11 | #LIBS += -L$$WDK/lib/wxp/i386 12 | 13 | # EOF 14 | -------------------------------------------------------------------------------- /vnr/vnrhook/TRASH/xp.txt: -------------------------------------------------------------------------------- 1 | 12/16/2013 2 | 3 | Differences between xp.dll and non-xp.dll for vnrhook. 4 | 5 | non-xp: 6 | CONFIG += eh 7 | 8 | xp: 9 | CONFIG += noeh 10 | CONFIG -= embed_manifest_dll # Pure dynamic determined. The manifest would break Windows XP support 11 | include($$LIBDIR/winseh/winseh_safe.pri) 12 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/engine/hookdefs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // engine/hookdefs.h 4 | // 7/20/2014 jichi 5 | 6 | // For HookParam user flags 7 | enum HookParamFlag : unsigned long { 8 | HPF_Null = 0 // never used 9 | , HPF_IgnoreSameAddress = 1 // ignore the last same text address 10 | }; 11 | 12 | // EOF 13 | -------------------------------------------------------------------------------- /vnr/winversion/winversion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // winversion.h 4 | // 9/5/2014 jichi 5 | 6 | #ifdef _MSC_VER 7 | # include // for wchar_t 8 | #endif // _MSC_VER 9 | 10 | namespace WinVersion { 11 | 12 | bool queryFileVersion(const wchar_t *path, int ver[4]); 13 | 14 | } // namespace WinVersion 15 | 16 | // EOF 17 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/engine/pchooks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // pchooks.h 4 | // 8/1/2014 jichi 5 | 6 | namespace PcHooks { 7 | 8 | void hookGDIFunctions(); 9 | void hookGDIPlusFunctions(); 10 | void hookLstrFunctions(); 11 | void hookWcharFunctions(); 12 | void hookCharNextFunctions(); 13 | 14 | } // namespace PcHooks 15 | 16 | // EOF 17 | -------------------------------------------------------------------------------- /vnr/windbg/unload.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // unload.h 4 | // 5/2/2014 jichi 5 | 6 | #include "windbg/windbg.h" 7 | #include 8 | 9 | WINDBG_BEGIN_NAMESPACE 10 | 11 | /** 12 | * Unload current injected DLL. 13 | * @return BOOL 14 | */ 15 | BOOL unloadCurrentModule(); 16 | 17 | WINDBG_END_NAMESPACE 18 | 19 | // EOF 20 | -------------------------------------------------------------------------------- /vnr/winseh/winseh_safe.cc: -------------------------------------------------------------------------------- 1 | // winseh_safe.cc 2 | // 12/13/2013 jichi 3 | // See: http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh 4 | 5 | #include "winseh/winseh.h" 6 | 7 | extern "C" int __stdcall _seh_asm_handler(); 8 | seh_dword_t seh_handler = reinterpret_cast(_seh_asm_handler); 9 | 10 | // EOF 11 | -------------------------------------------------------------------------------- /vnr/windbg/windbg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // windbg.h 4 | // 1/27/2013 jichi 5 | 6 | #ifndef WINDBG_BEGIN_NAMESPACE 7 | # define WINDBG_BEGIN_NAMESPACE namespace WinDbg { 8 | #endif 9 | #ifndef WINDBG_END_NAMESPACE 10 | # define WINDBG_END_NAMESPACE } // namespace WinDbg 11 | #endif 12 | 13 | WINDBG_BEGIN_NAMESPACE 14 | WINDBG_END_NAMESPACE 15 | 16 | // EOF 17 | -------------------------------------------------------------------------------- /vnr/wintimer/wintimer.pri: -------------------------------------------------------------------------------- 1 | # wintimer.pri 2 | # 7/20/2011 jichi 3 | win32 { 4 | 5 | DEFINES += WITH_LIB_WINTIMER 6 | 7 | LIBS += -lkernel32 -luser32 -lwintimer 8 | 9 | DEPENDPATH += $$PWD 10 | 11 | HEADERS += \ 12 | $$PWD/wintimer.h \ 13 | $$PWD/wintimerbase.h 14 | 15 | #SOURCES += \ 16 | # $$PWD/wintimer.cc \ 17 | # $$PWD/wintimerbase.cc 18 | } 19 | 20 | # EOF 21 | -------------------------------------------------------------------------------- /vnr/cpputil/cpputil.pri: -------------------------------------------------------------------------------- 1 | # cpputil.pri 2 | # 9/26/2012 jichi 3 | 4 | DEFINES += WITH_LIB_CPPUTIL 5 | 6 | DEPENDPATH += $$PWD 7 | 8 | HEADERS += \ 9 | $$PWD/cppcstring.h \ 10 | $$PWD/cpplocale.h \ 11 | $$PWD/cppmarshal.h \ 12 | $$PWD/cpppath.h \ 13 | $$PWD/cppregex.h \ 14 | $$PWD/cppstring.h \ 15 | $$PWD/cpptype.h \ 16 | $$PWD/cppunicode.h 17 | 18 | # EOF 19 | -------------------------------------------------------------------------------- /vnr/texthook/host/settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // settings.h 4 | // 8/24/2013 jichi 5 | 6 | struct Settings { 7 | //bool debug; // whether output debug messages using pipes 8 | int splittingInterval;// time to split text into sentences 9 | bool clipboardFlag; 10 | 11 | Settings() : splittingInterval(200), 12 | clipboardFlag(false) 13 | {} 14 | 15 | }; 16 | 17 | // EOF 18 | -------------------------------------------------------------------------------- /vnr/texthook/host/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // config.h 4 | // 8/23/2013 jichi 5 | // The first header file that are included by all source files. 6 | 7 | #define IHF // for dll import 8 | //#include "ith/dllconfig.h" 9 | #define IHFAPI __stdcall 10 | #ifdef IHF 11 | # define IHFSERVICE __declspec(dllexport) 12 | #else 13 | # define IHFSERVICE __declspec(dllimport) 14 | #endif 15 | 16 | // EOF 17 | -------------------------------------------------------------------------------- /vnr/wintimer/wintimer.pro: -------------------------------------------------------------------------------- 1 | # sys.pro 2 | # 8/21/2013 jichi 3 | # Build ITH_engine.dll 4 | 5 | #CONFIG += noqt noeh staticlib 6 | CONFIG += staticlib 7 | include(../../../config.pri) 8 | 9 | ## Sources 10 | 11 | TEMPLATE = lib 12 | TARGET = wintimer 13 | 14 | HEADERS += \ 15 | wintimer.h \ 16 | wintimerbase.h 17 | 18 | SOURCES += \ 19 | wintimer.cc \ 20 | wintimerbase.cc 21 | 22 | # EOF 23 | -------------------------------------------------------------------------------- /vnr/winseh/winseh_unsafe.cc: -------------------------------------------------------------------------------- 1 | // winseh_unsafe.cc 2 | // 12/13/2013 jichi 3 | // See: http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c 4 | 5 | #include "winseh/winseh.h" 6 | #include 7 | 8 | extern "C" EXCEPTION_DISPOSITION _seh_handler(PEXCEPTION_RECORD, PVOID, PCONTEXT, PVOID); 9 | seh_dword_t seh_handler = reinterpret_cast(_seh_handler); 10 | 11 | // EOF 12 | -------------------------------------------------------------------------------- /vnr/texthook/texthook.pri: -------------------------------------------------------------------------------- 1 | # texthook.pri 2 | # 10/13/2011 jichi 3 | 4 | DEFINES += WITH_LIB_TEXTHOOK 5 | 6 | INCLUDEPATH += $$PWD 7 | DEPENDPATH += $$PWD 8 | 9 | QT += core 10 | LIBS += -ltexthook 11 | 12 | HEADERS += \ 13 | $$PWD/texthook_config.h 14 | 15 | # texthook.h should not be in HEADERS, or it will be processed by moc 16 | OTHER_FILES += \ 17 | $$PWD/texthook.h \ 18 | $$PWD/texthook.pro 19 | 20 | # EOF 21 | -------------------------------------------------------------------------------- /vnr/winseh/winseh_unsafe.pri: -------------------------------------------------------------------------------- 1 | # winseh_unsafe.pri 2 | # 12/13/2013 jichi 3 | # 4 | # Need compile with /SAFESEH:NO 5 | # See: http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c 6 | #CONFIG += nosafeseh 7 | win32 { 8 | DEFINES += WITH_LIB_WINSEH 9 | 10 | DEPENDPATH += $$PWD 11 | 12 | HEADERS += $$PWD/winseh.h 13 | SOURCES += \ 14 | $$PWD/winseh.cc \ 15 | $$PWD/winseh_unsafe.cc 16 | } 17 | 18 | # EOF 19 | -------------------------------------------------------------------------------- /vnr/hashutil/hashutil.h: -------------------------------------------------------------------------------- 1 | #ifndef HASHUTIL_H 2 | #define HASHUTIL_H 3 | 4 | // hashutil.h 5 | // 6/16/2015 jichi 6 | 7 | // Redefine HASHUTIL_BEGIN_NAMESPACE/HASHUTIL_END_NAMESPACE if need custom namespace 8 | #ifndef HASHUTIL_BEGIN_NAMESPACE 9 | # define HASHUTIL_BEGIN_NAMESPACE namespace hashutil { 10 | #endif 11 | #ifndef HASHUTIL_END_NAMESPACE 12 | # define HASHUTIL_END_NAMESPACE } // namespace hashutil 13 | #endif 14 | 15 | #endif // HASHUTIL_H 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /vnr/texthook/host/host.pri: -------------------------------------------------------------------------------- 1 | # host.pri 2 | # 8/9/2011 jichi 3 | 4 | DEFINES += WITH_LIB_VNRHOST 5 | 6 | DEPENDPATH += $$PWD 7 | 8 | HEADERS += \ 9 | $$PWD/avl_p.h \ 10 | $$PWD/hookman.h \ 11 | $$PWD/settings.h \ 12 | $$PWD/host.h \ 13 | $$PWD/host_p.h \ 14 | $$PWD/textthread.h \ 15 | $$PWD/textthread_p.h 16 | 17 | SOURCES += \ 18 | $$PWD/hookman.cc \ 19 | $$PWD/host.cc \ 20 | $$PWD/pipe.cc \ 21 | $$PWD/textthread.cc 22 | 23 | # EOF 24 | -------------------------------------------------------------------------------- /vnr/texthook/texthook_config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // texthook_config.h 4 | // 10/20/2011 jichi 5 | 6 | //#define TEXTHOOK_EXPORT 7 | 8 | #ifndef TEXTHOOK_EXPORT 9 | # ifdef TEXTHOOK_STATIC_LIB 10 | # define TEXTHOOK_EXPORT 11 | # elif defined(TEXTHOOK_BUILD_LIB) 12 | # define TEXTHOOK_EXPORT Q_DECL_EXPORT 13 | # else 14 | # define TEXTHOOK_EXPORT Q_DECL_IMPORT 15 | # endif 16 | #endif // TEXTHOOK_EXPORT 17 | 18 | #define TEXTHOOK_DEFAULT_NAME "H-code" 19 | 20 | // EOF 21 | -------------------------------------------------------------------------------- /vnr/texthook/winapi_p.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // winapi_p.h 3 | // 10/5/2012 jichi 4 | // Internal header. 5 | // Wrapper of 6 | 7 | #ifndef WINAPI_BEGIN_NAMESPACE 8 | # define WINAPI_BEGIN_NAMESPACE namespace winapi { 9 | #endif 10 | #ifndef WINAPI_END_NAMESPACE 11 | # define WINAPI_END_NAMESPACE } // namespace winapi 12 | #endif 13 | 14 | WINAPI_BEGIN_NAMESPACE 15 | bool IsProcessActiveWithId(unsigned long dwProcessId); 16 | WINAPI_END_NAMESPACE 17 | 18 | // EOF 19 | -------------------------------------------------------------------------------- /vnr/windbg/windbg.pri: -------------------------------------------------------------------------------- 1 | # windbg.pri 2 | # 4/21/2014 jichi 3 | win32 { 4 | 5 | DEFINES += WITH_LIB_WINDBG 6 | 7 | LIBS += -lkernel32 -luser32 8 | 9 | DEPENDPATH += $$PWD 10 | 11 | HEADERS += \ 12 | $$PWD/hijack.h \ 13 | $$PWD/inject.h \ 14 | $$PWD/util.h \ 15 | $$PWD/unload.h \ 16 | $$PWD/windbg_p.h \ 17 | $$PWD/windbg.h 18 | 19 | SOURCES += \ 20 | $$PWD/hijack.cc \ 21 | $$PWD/inject.cc \ 22 | $$PWD/util.cc \ 23 | $$PWD/unload.cc 24 | } 25 | 26 | # EOF 27 | -------------------------------------------------------------------------------- /gui/TextBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ITH.h" 4 | #include "utility.h" // UniqueHandle, CriticalSection 5 | 6 | class TextBuffer 7 | { 8 | public: 9 | TextBuffer(HWND edit); 10 | ~TextBuffer(); 11 | void Flush(); 12 | void AddText(LPCWSTR str, int len, bool line); 13 | void ClearBuffer(); 14 | bool Running() { return running; } 15 | private: 16 | CriticalSection cs; 17 | bool line_break, running; 18 | UniqueHandle hThread; 19 | HWND hEdit; 20 | std::wstring str; 21 | }; 22 | -------------------------------------------------------------------------------- /vnr/cpputil/cppstring.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPSTRING_H 2 | #define CPPSTRING_H 3 | 4 | // cppstring.h 5 | // 10/12/2014 jichi 6 | 7 | /#include 8 | 9 | // Initializers 10 | 11 | template 12 | inline std::basic_string cpp_basic_string_of(const std::string &s) 13 | { return std::basic_string(s.begin(), s.end()); } 14 | 15 | inline std::wstring cpp_wstring_of(const std::string &s) 16 | { return std::wstring(s.begin(), s.end()); } 17 | 18 | #endif // CPPSTRING_H 19 | -------------------------------------------------------------------------------- /vnr/profile/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(profile_src 2 | Profile.h 3 | Profile.cpp 4 | pugiconfig.hpp 5 | pugixml.cpp 6 | pugixml.hpp 7 | misc.h 8 | misc.cpp 9 | ) 10 | 11 | add_library(profile STATIC ${profile_src}) 12 | 13 | target_compile_options(profile PRIVATE 14 | $<$:> 15 | $<$:> 16 | ) 17 | 18 | #target_link_libraries(profile comctl32.lib) 19 | 20 | #target_compile_definitions(profile 21 | # PRIVATE 22 | # _CRT_NON_CONFORMING_SWPRINTFS 23 | #) 24 | -------------------------------------------------------------------------------- /i18n/gui_korean/TextBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ITH.h" 4 | #include "utility.h" // UniqueHandle, CriticalSection 5 | 6 | class TextBuffer 7 | { 8 | public: 9 | TextBuffer(HWND edit); 10 | ~TextBuffer(); 11 | void Flush(); 12 | void AddText(LPCWSTR str, int len, bool line); 13 | void ClearBuffer(); 14 | bool Running() { return running; } 15 | private: 16 | CriticalSection cs; 17 | bool line_break, running; 18 | UniqueHandle hThread; 19 | HWND hEdit; 20 | std::wstring str; 21 | }; 22 | -------------------------------------------------------------------------------- /vnr/texthook/ihf.txt: -------------------------------------------------------------------------------- 1 | # 6/6/2012 2 | # IHF.dll 3 | # Skip swprintf and MessageBox statements in GetDebugPriv 4 | # 5 | # SVN checkout: 2012/6/6 6 | # - IHF/main.cpp: 2012/4/8 7 | # - IHF.{dll,lib}: 2012/6/5 8 | 9 | 6F753055 CALL DWORD PTR DS:ntdll.ZwAdjustPrivilegesTOken 10 | 6F75305B TEST EAX,EAX 11 | 6F75305B JNE SHORT 6F753077 => JNE SHORT 6F75309F 12 | ... 13 | 6F753077 PUSH EAX 14 | ... 15 | 6F75309F MOVE EAX,DWORD PTR SS:[ESP] 16 | 6F7530A2 PUSH EAX 17 | 6F7530A3 CALL DWORD PTR DS:ntdll.NtClose 18 | ... 19 | 20 | # EOF 21 | -------------------------------------------------------------------------------- /vnr/texthook/ith_p.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // ith_p.h 4 | // 10/15/2011 jichi 5 | // Internal header. 6 | // Wrapper of functions from ITH. 7 | 8 | #include 9 | 10 | struct HookParam; // opaque, declared in ITH/common.h 11 | 12 | namespace Ith { 13 | 14 | /// Parse hook code, and save the result to hook param if succeeded. 15 | bool parseHookCode(_In_ const QString &code, _Out_ HookParam *hp, bool verbose = true); 16 | bool verifyHookCode(_In_ const QString &code); 17 | 18 | } // namespace Ith 19 | 20 | // EOF 21 | -------------------------------------------------------------------------------- /vnr/mono/monotype.h: -------------------------------------------------------------------------------- 1 | #ifndef MONOTYPE_H 2 | #define MONOTYPE_H 3 | 4 | // monotype.h 5 | // 12/26/2014 jichi 6 | // https://github.com/mono/mono/blob/master/mono/metadata/object.h 7 | 8 | #include "mono/monoobject.h" 9 | 10 | // Function typedefs 11 | typedef MonoDomain *(* mono_object_get_domain_fun_t)(MonoObject *obj); 12 | 13 | typedef MonoString *(* mono_string_new_utf16_fun_t)(MonoDomain *domain, const mono_unichar2 *text, int32_t len); 14 | 15 | typedef char * (* mono_string_to_utf8_fun_t)(MonoString *string_obj); 16 | 17 | #endif // MONOTYPE_H 18 | -------------------------------------------------------------------------------- /vnr/texthook/winapi_p.cc: -------------------------------------------------------------------------------- 1 | // apiwin_p.cc 2 | // 10/6/2012 jichi 3 | #include "texthook/winapi_p.h" 4 | #include 5 | 6 | WINAPI_BEGIN_NAMESPACE 7 | 8 | bool IsProcessActiveWithId(DWORD dwProcessId) 9 | { 10 | bool ret = false; 11 | if (HANDLE hProc = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId)) { 12 | DWORD dwExitCode; 13 | ret = ::GetExitCodeProcess(hProc, &dwExitCode) && (dwExitCode == STILL_ACTIVE); 14 | ::CloseHandle(hProc); 15 | } 16 | return ret; 17 | } 18 | 19 | WINAPI_END_NAMESPACE 20 | 21 | // EOF 22 | -------------------------------------------------------------------------------- /vnr/memdbg/memdbg.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMDBG_H 2 | #define _MEMDBG_H 3 | 4 | // memdbg.h 5 | // 4/20/2014 jichi 6 | 7 | #ifndef MEMDBG_BEGIN_NAMESPACE 8 | # define MEMDBG_BEGIN_NAMESPACE namespace MemDbg { 9 | #endif 10 | #ifndef MEMDBG_END_NAMESPACE 11 | # define MEMDBG_END_NAMESPACE } // MemDbg 12 | #endif 13 | 14 | MEMDBG_BEGIN_NAMESPACE 15 | 16 | typedef unsigned char byte_t; 17 | typedef unsigned long dword_t; 18 | 19 | //typedef void *address_t; // LPVOID 20 | //typedef const void *const_address_t; // LPCVOID 21 | 22 | MEMDBG_END_NAMESPACE 23 | 24 | 25 | #endif // _MEMDBG_H 26 | -------------------------------------------------------------------------------- /vnr/windbg/unload.cc: -------------------------------------------------------------------------------- 1 | // unload.cc 2 | // 5/2/2014 jichi 3 | #include "windbg/unload.h" 4 | 5 | WINDBG_BEGIN_NAMESPACE 6 | 7 | EXTERN_C IMAGE_DOS_HEADER __ImageBase; 8 | // See: http://stackoverflow.com/questions/3410130/dll-unloading-itself 9 | BOOL unloadCurrentModule() 10 | { 11 | auto fun = ::FreeLibrary; 12 | //auto fun = ::LdrUnloadDll; 13 | if (HANDLE h = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)fun, &__ImageBase, 0, NULL)) { 14 | ::CloseHandle(h); 15 | return TRUE; 16 | } 17 | return FALSE; 18 | } 19 | 20 | WINDBG_END_NAMESPACE 21 | 22 | // EOF 23 | -------------------------------------------------------------------------------- /gui/ProcessWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ITH.h" 4 | 5 | class ProcessWindow 6 | { 7 | public: 8 | ProcessWindow(HWND hDialog); 9 | void InitProcessDlg(); 10 | void RefreshProcess(); 11 | void AttachProcess(); 12 | void DetachProcess(); 13 | void CreateProfileForSelectedProcess(); 14 | void DeleteProfileForSelectedProcess(); 15 | void RefreshThread(int index); 16 | private: 17 | void RefreshThreadWithPID(DWORD pid, bool isAttached); 18 | DWORD GetSelectedPID(); 19 | HWND hDlg; 20 | HWND hlProcess; 21 | HWND hbRefresh,hbAttach,hbDetach,hbAddProfile,hbRemoveProfile; 22 | HWND heOutput; 23 | }; 24 | -------------------------------------------------------------------------------- /vnr/ccutil/ccmacro.h: -------------------------------------------------------------------------------- 1 | #ifndef CCMACRO_H 2 | #define CCMACRO_H 3 | 4 | // ccmacro.h 5 | // 12/9/2011 jichi 6 | 7 | #define CC_UNUSED(_var) (void)(_var) 8 | #define CC_NOP CC_UNUSED(0) 9 | 10 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 11 | # define CC_LIKELY(expr) __builtin_expect(!!(expr), true) 12 | # define CC_UNLIKELY(expr) __builtin_expect(!!(expr), false) 13 | #else 14 | # define CC_LIKELY(x) (x) 15 | # define CC_UNLIKELY(x) (x) 16 | #endif 17 | 18 | #define CC_MIN(x, y) ((x) < (y) ? (x) : (y)) 19 | #define CC_MAX(x, y) ((x) < (y) ? (y) : (x)) 20 | 21 | #endif // CCMACRO_H 22 | -------------------------------------------------------------------------------- /i18n/gui_korean/ProcessWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ITH.h" 4 | 5 | class ProcessWindow 6 | { 7 | public: 8 | ProcessWindow(HWND hDialog); 9 | void InitProcessDlg(); 10 | void RefreshProcess(); 11 | void AttachProcess(); 12 | void DetachProcess(); 13 | void CreateProfileForSelectedProcess(); 14 | void DeleteProfileForSelectedProcess(); 15 | void RefreshThread(int index); 16 | private: 17 | void RefreshThreadWithPID(DWORD pid, bool isAttached); 18 | DWORD GetSelectedPID(); 19 | HWND hDlg; 20 | HWND hlProcess; 21 | HWND hbRefresh,hbAttach,hbDetach,hbAddProfile,hbRemoveProfile; 22 | HWND heOutput; 23 | }; 24 | -------------------------------------------------------------------------------- /vnr/ithsys/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # # ithsys.pro 2 | # CONFIG += noqt staticlib 3 | # include(../../../config.pri) 4 | 5 | # # jichi 7/12/2015: Always enable SEH 6 | # DEFINES += ITH_HAS_SEH 7 | 8 | # DEFINES += _CRT_NON_CONFORMING_SWPRINTFS 9 | 10 | set(ithsys_src 11 | ithsys.h 12 | ithsys.cc 13 | ) 14 | 15 | add_library(ithsys STATIC ${ithsys_src}) 16 | 17 | target_compile_options(ithsys PRIVATE 18 | $<$:> 19 | $<$:> 20 | ) 21 | 22 | target_link_libraries(ithsys comctl32.lib) 23 | 24 | target_compile_definitions(ithsys 25 | PRIVATE 26 | ITH_HAS_SEH 27 | _CRT_NON_CONFORMING_SWPRINTFS 28 | ) 29 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/engine/match.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // engine/match.h 4 | // 8/23/2013 jichi 5 | // TODO: Clean up the interface to match game engines. 6 | // Split the engine match logic out of hooks. 7 | // Modify the game hook to allow replace functions for arbitary purpose 8 | // instead of just extracting text. 9 | 10 | #include 11 | 12 | namespace Engine { 13 | 14 | // jichi 10/21/2014: Return whether found the engine 15 | void hijack(); 16 | void terminate(); 17 | 18 | // jichi 10/21/2014: Return 0 if failed 19 | DWORD InsertDynamicHook(LPVOID addr, DWORD frame, DWORD stack); 20 | 21 | } // namespace Engine 22 | 23 | // EOF 24 | -------------------------------------------------------------------------------- /vnr/windbg/windbg_p.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // windbg_p.h 4 | // 1/27/2013 jichi 5 | 6 | #include "windbg/windbg.h" 7 | #include 8 | 9 | WINDBG_BEGIN_NAMESPACE 10 | 11 | namespace details { // unnamed 12 | 13 | /// Return the address of func in module. 14 | inline FARPROC getModuleFunctionAddressA(LPCSTR func, LPCSTR module = nullptr) 15 | { return ::GetProcAddress(::GetModuleHandleA(module), func); } 16 | 17 | inline FARPROC getModuleFunctionAddressW(LPCSTR func, LPCWSTR module = nullptr) 18 | { return ::GetProcAddress(::GetModuleHandleW(module), func); } 19 | 20 | } // unamed namespace details 21 | 22 | WINDBG_END_NAMESPACE 23 | 24 | // EOF 25 | -------------------------------------------------------------------------------- /vnr/winseh/safeseh.asm: -------------------------------------------------------------------------------- 1 | ; safeseh.asm 2 | ; 12/13/2013 jichi 3 | ; see: http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh 4 | ; see: http://code.metager.de/source/xref/WebKit/Source/WebCore/platform/win/makesafeseh.asm 5 | ; see: http://jpassing.com/2008/05/20/fun-with-low-level-seh/ 6 | .386 7 | .model flat, stdcall 8 | option casemap :none 9 | 10 | ; The symbol name can be found out using: dumpbin /symbols winseh.obj 11 | extern _seh_handler:near ; defined in winseh.cc 12 | 13 | _seh_asm_handler proto 14 | .safeseh _seh_asm_handler 15 | 16 | .code 17 | _seh_asm_handler proc 18 | jmp _seh_handler 19 | _seh_asm_handler endp 20 | 21 | end 22 | -------------------------------------------------------------------------------- /vnr/winseh/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 12/13/2013 jichi 3 | # This file is for Windows only. 4 | # Compile SAFESEH table from the ASM file. 5 | # See: http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c 6 | # See: http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh 7 | # See: http://msdn.microsoft.com/en-us/library/16aexws6.aspx 8 | 9 | BUILDDIR = ../../../build 10 | OBJ = $(BUILDDIR)/safeseh.obj 11 | 12 | ML = ml 13 | CFLAGS = 14 | 15 | .PHONY: all compile clean 16 | 17 | all: compile 18 | 19 | compile: $(OBJ) 20 | 21 | $(OBJ): safeseh.asm 22 | $(ML) $(CFLAGS) -Fo $@ -c -safeseh $^ 23 | 24 | clean: 25 | 26 | # EOF 27 | -------------------------------------------------------------------------------- /vnr/profile/misc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct HookParam; 8 | struct ProcessRecord; 9 | 10 | bool Parse(const std::wstring& cmd, HookParam& hp); 11 | DWORD Hash(const std::wstring& module, int length = -1); 12 | std::wstring ParseCode(const HookParam& hp); 13 | std::string toMultiByteString(const std::wstring& unicodeString); 14 | std::wstring toUnicodeString(const std::string& mbString); 15 | std::wstring GetHookNameByAddress(const ProcessRecord& pr, DWORD hook_address); 16 | 17 | template 18 | std::wstring ToHexString(T i) { 19 | std::wstringstream ss; 20 | ss << std::uppercase << std::hex << i; 21 | return ss.str(); 22 | } 23 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/except.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // except.h 4 | // 9/17/2013 jichi 5 | 6 | #define ITH_RAISE (*(int*)0 = 0) // raise C000005, for debugging only 7 | 8 | #ifdef ITH_HAS_SEH 9 | 10 | # define ITH_TRY __try 11 | # define ITH_EXCEPT __except(EXCEPTION_EXECUTE_HANDLER) 12 | # define ITH_WITH_SEH(...) \ 13 | ITH_TRY { __VA_ARGS__; } ITH_EXCEPT {} 14 | 15 | #else // for old msvcrt.dll on Windows XP that does not have exception handler 16 | 17 | // Currently, only with_seh is implemented. Try and catch are not. 18 | # define ITH_TRY if (true) 19 | # define ITH_EXCEPT else 20 | # include "winseh/winseh.h" 21 | # define ITH_WITH_SEH(...) seh_with(__VA_ARGS__) 22 | 23 | #endif // ITH_HAS_SEH 24 | 25 | // EOF 26 | -------------------------------------------------------------------------------- /vnr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # config.pri 2 | # DEFINES += _SECURE_SCL=0 _SCL_SECURE_NO_WARNINGS 3 | # DEFINES += _CRT_SECURE_NO_WARNINGS 4 | 5 | cmake_minimum_required(VERSION 2.8) 6 | 7 | set(CMAKE_CONFIGURATION_TYPES Debug Release) 8 | 9 | project(vnr) 10 | 11 | set(WDK_HOME "C:\\WinDDK\\7600.16385.1" CACHE FILEPATH "Windows Driver Kit path") 12 | 13 | add_definitions( 14 | /DUNICODE 15 | /D_UNICODE 16 | /D_SECURE_SCL=0 17 | /D_SCL_SECURE_NO_WARNINGS 18 | /D_CRT_SECURE_NO_WARNINGS 19 | ) 20 | 21 | include_directories( 22 | ${PROJECT_SOURCE_DIR} 23 | ${PROJECT_SOURCE_DIR}/texthook 24 | ) 25 | 26 | add_subdirectory(vnrhook) 27 | add_subdirectory(texthook/host) 28 | add_subdirectory(ithsys) 29 | add_subdirectory(profile) 30 | -------------------------------------------------------------------------------- /vnr/winmaker/winmaker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // winmaker.h 4 | // 2/1/2013 jichi 5 | 6 | #include 7 | typedef void *wm_window_t; // HWMD 8 | typedef void *wm_module_t; // HMODULE 9 | 10 | bool wm_register_hidden_class(LPCWSTR className = L"hidden_class"); 11 | 12 | wm_window_t wm_create_hidden_window( 13 | LPCWSTR windowName = L"hidden_window", 14 | LPCWSTR className = L"Button", // bust be one of the common control widgets 15 | wm_module_t dllHandle = nullptr); 16 | 17 | bool wm_destroy_window(wm_window_t hwnd); 18 | 19 | // EOF 20 | 21 | //#ifdef QT_CORE_LIB 22 | //#include 23 | //WId wm_create_hidden_window(const char *className = "Button", const char *windowName = "hidden_window"); 24 | -------------------------------------------------------------------------------- /vnr/windbg/hijack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // hijack.h 4 | // 1/27/2013 jichi 5 | 6 | #include "windbg/windbg.h" 7 | #include 8 | 9 | WINDBG_BEGIN_NAMESPACE 10 | 11 | /** 12 | * Replace the named function entry with the new one. 13 | * @param stealFrom instance of target module 14 | * @param oldFunctionModule TODO 15 | * @param functionName name of the target function 16 | * @return the orignal address if succeed, else nullptr 17 | * 18 | * See: http://www.codeproject.com/KB/DLL/DLL_Injection_tutorial.aspx 19 | */ 20 | PVOID overrideFunctionA(_In_ HMODULE stealFrom, _In_ LPCSTR oldFunctionModule, 21 | _In_ LPCSTR functionName, _In_ LPCVOID newFunction); 22 | 23 | WINDBG_END_NAMESPACE 24 | 25 | // EOF 26 | -------------------------------------------------------------------------------- /vnr/cpputil/cppmath.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPMATH_H 2 | #define CPPMATH_H 3 | 4 | // cppmacro.h 5 | // 10/12/2014 jichi 6 | #include 7 | 8 | // The same as qMin 9 | template 10 | inline const T &cpp_min(const T &a, const T &b) { return (a < b) ? a : b; } 11 | 12 | // The same as qMax 13 | template 14 | inline const T &cpp_max(const T &a, const T &b) { return (a < b) ? b : a; } 15 | 16 | // The same as qBound 17 | template 18 | inline const T &cpp_bound(const T &min, const T &val, const T &max) 19 | { return cpp_max(min, cpp_min(max, val)); } 20 | 21 | // The same as qFuzzyCompare 22 | inline bool cpp_fuzzy_compare(float p1, float p2) 23 | { return (abs(p1 - p2) <= 0.00001f * cpp_min(abs(p1), abs(p2))); } 24 | 25 | #endif // CPPMATH_H 26 | -------------------------------------------------------------------------------- /vnr/winseh/winseh_safe.pri: -------------------------------------------------------------------------------- 1 | # winseh_safe.pri 2 | # 12/13/2013 jichi 3 | # 4 | # Need link with with SEH assembly 5 | # See: http://stackoverflow.com/questions/12019689/custom-seh-handler-with-safeseh 6 | # See: http://stackoverflow.com/questions/19722308/exception-handler-not-called-in-c 7 | win32 { 8 | #include(../../../config.pri) 9 | 10 | # Disable buffer security check: http://msdn.microsoft.com/en-us/library/8dbf701c.aspx 11 | #QMAKE_CXXFLAGS += /GS- 12 | 13 | LIBS += safeseh.obj # compiled from safeseh.asm using ml -safeseh 14 | 15 | DEFINES += WITH_LIB_WINSEH 16 | 17 | DEPENDPATH += $$PWD 18 | 19 | HEADERS += $$PWD/winseh.h 20 | SOURCES += \ 21 | $$PWD/winseh.cc \ 22 | $$PWD/winseh_safe.cc 23 | 24 | OTHER_FILES += \ 25 | $$PWD/safeseh.asm \ 26 | $$PWD/Makefile 27 | } 28 | 29 | # EOF 30 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // main.h 4 | // 8/23/2013 jichi 5 | // Branch: ITH/IHF_DLL.h, rev 66 6 | 7 | #include "include/const.h" 8 | #include "include/types.h" 9 | 10 | void ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text 11 | DWORD NotifyHookInsert(DWORD addr); 12 | DWORD NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE); 13 | DWORD RemoveHook(DWORD addr); 14 | DWORD SwitchTrigger(DWORD on); 15 | DWORD GetFunctionAddr(const char *name, DWORD *addr, DWORD *base, DWORD *size, LPWSTR *base_name); 16 | 17 | // 10/14/2014 jichi: disable GDI hooks 18 | void EnableGDIHooks(); 19 | void EnableGDIPlusHooks(); 20 | void DisableGDIHooks(); 21 | void DisableGDIPlusHooks(); 22 | bool GDIHooksEnabled(); 23 | bool GDIPlusHooksEnabled(); 24 | 25 | // EOF 26 | -------------------------------------------------------------------------------- /vnr/windbg/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // windbg/util.h 4 | // 1/27/2013 jichi 5 | 6 | #include "windbg/windbg.h" 7 | #include "sakurakit/skglobal.h" 8 | 9 | #include 10 | 11 | WINDBG_BEGIN_NAMESPACE 12 | 13 | class ThreadsSuspenderPrivate; 14 | /** 15 | * When created, automatically suspends all threads in the current process. 16 | * When destroyed, resume suspended threads. 17 | */ 18 | class ThreadsSuspender 19 | { 20 | SK_CLASS(ThreadsSuspender) 21 | SK_DISABLE_COPY(ThreadsSuspender) 22 | SK_DECLARE_PRIVATE(ThreadsSuspenderPrivate) 23 | 24 | public: 25 | explicit ThreadsSuspender(bool autoSuspend = true); 26 | ~ThreadsSuspender(); 27 | 28 | void resume(); ///< Manually resume all threads 29 | void suspend(); ///< Manually suspend all threads 30 | }; 31 | 32 | WINDBG_END_NAMESPACE 33 | 34 | // EOF 35 | -------------------------------------------------------------------------------- /vnr/disasm/disasm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // disasm.h 3 | // 1/27/2013 jichi 4 | 5 | // Include typedef of BYTE 6 | //#include 7 | //#include 8 | 9 | //#ifdef QT_CORE_LIB 10 | //# include 11 | //#else 12 | //# include 13 | //#endif 14 | 15 | #ifndef DISASM_BEGIN_NAMESPACE 16 | # define DISASM_BEGIN_NAMESPACE 17 | #endif 18 | #ifndef DISASM_END_NAMESPACE 19 | # define DISASM_END_NAMESPACE 20 | #endif 21 | 22 | DISASM_BEGIN_NAMESPACE 23 | /** 24 | * This function can do more, but currently only used to estimate the length of an instruction. 25 | * Warning: The current implementation is stateful and hence not thread-safe. 26 | * @param address of the instruction to look at 27 | * @return length of the instruction at the address or 0 if failed 28 | */ 29 | size_t disasm(const void *address); 30 | DISASM_END_NAMESPACE 31 | 32 | // EOF 33 | -------------------------------------------------------------------------------- /gui/window.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "ITH.h" 21 | -------------------------------------------------------------------------------- /i18n/gui_korean/window.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "ITH.h" 21 | -------------------------------------------------------------------------------- /gui/TextBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "TextBuffer.h" 2 | 3 | DWORD WINAPI FlushThread(LPVOID lParam); // window.cpp 4 | 5 | TextBuffer::TextBuffer(HWND edit) : hThread(IthCreateThread(FlushThread, (DWORD)this)), 6 | hEdit(edit), 7 | running(true) 8 | { 9 | } 10 | 11 | TextBuffer::~TextBuffer() 12 | { 13 | running = false; 14 | WaitForSingleObject(hThread.get(), 0); 15 | } 16 | 17 | void TextBuffer::AddText(LPCWSTR str, int len, bool line) 18 | { 19 | CSLock lock(cs); 20 | if (len > 0) 21 | this->str.append(str, len); 22 | line_break = line; 23 | } 24 | 25 | void TextBuffer::Flush() 26 | { 27 | CSLock lock(cs); 28 | if (line_break || str.empty()) 29 | return; 30 | DWORD t = Edit_GetTextLength(hEdit); 31 | Edit_SetSel(hEdit, t, -1); 32 | Edit_ReplaceSel(hEdit, str.c_str()); 33 | str.clear(); 34 | } 35 | 36 | void TextBuffer::ClearBuffer() 37 | { 38 | CSLock lock(cs); 39 | str.clear(); 40 | line_break = false; 41 | } 42 | -------------------------------------------------------------------------------- /i18n/gui_korean/TextBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "TextBuffer.h" 2 | 3 | DWORD WINAPI FlushThread(LPVOID lParam); // window.cpp 4 | 5 | TextBuffer::TextBuffer(HWND edit) : hThread(IthCreateThread(FlushThread, (DWORD)this)), 6 | hEdit(edit), 7 | running(true) 8 | { 9 | } 10 | 11 | TextBuffer::~TextBuffer() 12 | { 13 | running = false; 14 | WaitForSingleObject(hThread.get(), 0); 15 | } 16 | 17 | void TextBuffer::AddText(LPCWSTR str, int len, bool line) 18 | { 19 | CSLock lock(cs); 20 | if (len > 0) 21 | this->str.append(str, len); 22 | line_break = line; 23 | } 24 | 25 | void TextBuffer::Flush() 26 | { 27 | CSLock lock(cs); 28 | if (line_break || str.empty()) 29 | return; 30 | DWORD t = Edit_GetTextLength(hEdit); 31 | Edit_SetSel(hEdit, t, -1); 32 | Edit_ReplaceSel(hEdit, str.c_str()); 33 | str.clear(); 34 | } 35 | 36 | void TextBuffer::ClearBuffer() 37 | { 38 | CSLock lock(cs); 39 | str.clear(); 40 | line_break = false; 41 | } 42 | -------------------------------------------------------------------------------- /vnr/cpputil/cpptype.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPTYPE_H 2 | #define CPPTYPE_H 3 | 4 | // cpptype.h 5 | // 10/12/2014 jichi 6 | #include 7 | 8 | // Platform-dependent 9 | 10 | typedef char cpp_char; 11 | typedef unsigned char cpp_uchar; 12 | 13 | typedef short cpp_short; 14 | typedef unsigned short cpp_ushort; 15 | 16 | typedef int cpp_int; 17 | typedef unsigned int cpp_uint; 18 | 19 | typedef long cpp_long; 20 | typedef unsigned long cpp_ulong; 21 | 22 | typedef long long cpp_llong; 23 | typedef unsigned long long cpp_ullong; 24 | 25 | typedef float cpp_float; 26 | typedef double cpp_double; 27 | 28 | // Platform-independent 29 | 30 | typedef int8_t cpp_int8; 31 | typedef uint8_t cpp_uint8; 32 | 33 | typedef cpp_int8 cpp_byte; 34 | typedef cpp_uint8 cpp_ubyte; 35 | 36 | typedef int32_t cpp_int32; 37 | typedef uint32_t cpp_uint32; 38 | 39 | typedef int64_t cpp_int64; 40 | typedef uint64_t cpp_uint64; 41 | 42 | #endif // CPPTYPE_H 43 | -------------------------------------------------------------------------------- /vnr/texthook/texthook.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * texthook.rc 3 | * 10/20/2011 jichi 4 | */ 5 | #if defined(UNDER_CE) 6 | # include 7 | #else 8 | # include 9 | #endif 10 | 11 | VS_VERSION_INFO VERSIONINFO 12 | FILEVERSION 1,0,0,0 13 | PRODUCTVERSION 1,0,0,0 14 | FILEFLAGSMASK 0x3fL 15 | #ifdef _DEBUG 16 | FILEFLAGS VS_FF_DEBUG 17 | #else 18 | FILEFLAGS 0x0L 19 | #endif 20 | FILEOS VOS__WINDOWS32 21 | FILETYPE VFT_DLL 22 | FILESUBTYPE 0x0L 23 | BEGIN 24 | BLOCK "StringFileInfo" 25 | BEGIN 26 | BLOCK "040904B0" 27 | BEGIN 28 | VALUE "CompanyName", "Sakuradite\0" 29 | VALUE "FileDescription", "Text Hook\0" 30 | VALUE "FileVersion", "1.0.0.0\0" 31 | VALUE "LegalCopyright", "Copyright (C) 2012.\0" 32 | VALUE "OriginalFilename", "texthook.dll\0" 33 | VALUE "ProductName", "texthook\0" 34 | END 35 | END 36 | END 37 | 38 | /* End of Version info */ 39 | -------------------------------------------------------------------------------- /vnr/sakurakit/skautorun.h: -------------------------------------------------------------------------------- 1 | #ifndef SKAUTORUN_H 2 | #define SKAUTORUN_H 3 | 4 | // skautorun.h 5 | // 9/30/2012 jichi 6 | 7 | #include "sakurakit/skglobal.h" 8 | #include 9 | 10 | SK_BEGIN_NAMESPACE 11 | 12 | class SkAutoRun 13 | { 14 | public: 15 | typedef std::function function_type; 16 | SkAutoRun(const function_type &start, const function_type &exit) 17 | : exit_(exit) { start(); } 18 | ~SkAutoRun() { exit_(); } 19 | private: 20 | function_type exit_; 21 | }; 22 | 23 | class SkAutoRunAtStartup 24 | { 25 | public: 26 | typedef SkAutoRun::function_type function_type; 27 | explicit SkAutoRunAtStartup(const function_type &start) { start(); } 28 | }; 29 | 30 | class SkAutoRunAtExit 31 | { 32 | public: 33 | typedef SkAutoRun::function_type function_type; 34 | explicit SkAutoRunAtExit(const function_type &exit) : exit_(exit) {} 35 | ~SkAutoRunAtExit() { exit_(); } 36 | private: 37 | function_type exit_; 38 | }; 39 | 40 | SK_END_NAMESPACE 41 | 42 | #endif // SkAUTORUN_H 43 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/engine/mono/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // mono/types.h 4 | // 12/26/2014 5 | // https://github.com/mono/mono/blob/master/mono/metadata/object.h 6 | // http://api.xamarin.com/index.aspx?link=xhtml%3Adeploy%2Fmono-api-string.html 7 | 8 | #include 9 | 10 | // mono/io-layer/uglify.h 11 | typedef int8_t gint8; 12 | typedef int32_t gint32; 13 | typedef wchar_t gunichar2; // either char or wchar_t, depending on how mono is compiled 14 | 15 | typedef gint8 mono_byte; 16 | typedef gunichar2 mono_unichar2; 17 | 18 | // mono/metadata/object.h 19 | 20 | typedef mono_byte MonoBoolean; 21 | 22 | struct MonoArray; 23 | struct MonoDelegate; 24 | struct MonoException; 25 | struct MonoString; 26 | struct MonoThreadsSync; 27 | struct MonoThread; 28 | struct MonoVTable; 29 | 30 | struct MonoObject { 31 | MonoVTable *vtable; 32 | MonoThreadsSync *synchronisation; 33 | }; 34 | 35 | struct MonoString { 36 | MonoObject object; 37 | gint32 length; 38 | gunichar2 chars[0]; 39 | }; 40 | 41 | // EOF 42 | -------------------------------------------------------------------------------- /vnr/winversion/winversion.cc: -------------------------------------------------------------------------------- 1 | // winversion.cc 2 | // 9/5/2014 jichi 3 | 4 | #include "winversion/winversion.h" 5 | #include 6 | 7 | // http://stackoverflow.com/questions/940707/how-do-i-programatically-get-the-version-of-a-dll-or-exe-file 8 | bool WinVersion::queryFileVersion(const wchar_t *path, int ver[]) 9 | { 10 | bool ok = false; 11 | // get the version info for the file requested 12 | if (DWORD dwSize = ::GetFileVersionInfoSizeW(path, nullptr)) { 13 | UINT len = 0; 14 | BYTE *buf = new BYTE[dwSize]; 15 | VS_FIXEDFILEINFO *info = nullptr; 16 | ok = ::GetFileVersionInfoW(path, 0, dwSize, buf) 17 | && ::VerQueryValueW(buf, L"\\", (LPVOID*)&info, &len) 18 | && info; 19 | if (ok) { 20 | ver[0] = HIWORD(info->dwFileVersionMS), 21 | ver[1] = LOWORD(info->dwFileVersionMS), 22 | ver[2] = HIWORD(info->dwFileVersionLS), 23 | ver[3] = LOWORD(info->dwFileVersionLS); 24 | } 25 | delete[] buf; 26 | } 27 | return ok; 28 | } 29 | 30 | // EOF 31 | -------------------------------------------------------------------------------- /vnr/wintimer/wintimer.cc: -------------------------------------------------------------------------------- 1 | // wintimer.cc 2 | // 6/6/2012 jichi 3 | 4 | #include "wintimer/wintimer.h" 5 | 6 | //#define DEBUG "wintimer.cc" 7 | #include "sakurakit/skdebug.h" 8 | #include 9 | WINTIMER_BEGIN_NAMESPACE 10 | 11 | void WinTimer::singleShot(int msecs, const function_type &f, WId parent) 12 | { 13 | Self *t = new Self(parent); 14 | t->setInterval(msecs); 15 | t->setSingleShot(true); 16 | t->setFunction([=] { // Copy function f instead of pass by reference. 17 | f(); 18 | delete t; 19 | }); 20 | t->start(); 21 | } 22 | 23 | WINTIMER_END_NAMESPACE 24 | 25 | // EOF 26 | 27 | /* 28 | // - Single shot - 29 | 30 | namespace { // unnamed 31 | 32 | class apply_delete 33 | { 34 | typedef WinTimer::function_type function_type; 35 | function_type f_; 36 | WinTimer *t_; 37 | public: 38 | apply_delete(const function_type &f, WinTimer *t) 39 | : f_(f), t_(t) { Q_ASSERT(t); } 40 | 41 | void operator()() 42 | { 43 | f_(); 44 | delete t_; 45 | } 46 | }; 47 | 48 | } // unnamed namespace 49 | */ 50 | -------------------------------------------------------------------------------- /vnr/texthook/texthook_p.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // texthook_p.h 4 | // 10/14/2011 jichi 5 | // Internal header. 6 | // Defines TextHook private data. 7 | 8 | #include "texthook/texthook.h" 9 | #include 10 | #include 11 | 12 | // - Private - 13 | 14 | class TextHookPrivate 15 | { 16 | SK_CLASS(TextHookPrivate) 17 | SK_DECLARE_PUBLIC(TextHook) 18 | 19 | static Self *instance_; // global instance 20 | 21 | bool enabled; 22 | QString source; 23 | QSet pids; 24 | QHash hooks; // ITH hook code, indexed by pid 25 | 26 | explicit TextHookPrivate(Q *q) 27 | : q_(q), enabled(true), source(TEXTHOOK_DEFAULT_NAME) { instance_ = this; } 28 | 29 | ~TextHookPrivate() { instance_ = nullptr; } 30 | 31 | public: 32 | static void sendData(const QByteArray &rawData, const QByteArray &renderedData, qint32 signature, const QString &name) 33 | { 34 | if (instance_ && instance_->q_->isEnabled()) 35 | emit instance_->q_->dataReceived(rawData, renderedData, signature, name); 36 | } 37 | }; 38 | 39 | // EOF 40 | -------------------------------------------------------------------------------- /vnr/copy_vnr.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | if [%1] == [] ( 4 | echo usage: copy_vnr path_to_Sakura 5 | goto :EOF 6 | ) 7 | xcopy %1\config.pri . /S /Y /I 8 | xcopy %1\cpp\libs\ccutil ccutil /S /Y /I 9 | xcopy %1\cpp\libs\cpputil cpputil /S /Y /I 10 | xcopy %1\cpp\libs\disasm disasm /S /Y /I /EXCLUDE:exclude.txt 11 | xcopy %1\cpp\libs\hashutil hashutil /S /Y /I 12 | xcopy %1\cpp\plugins\ithsys ithsys /S /Y /I 13 | xcopy %1\cpp\plugins\vnrhook vnrhook /S /Y /I 14 | xcopy %1\cpp\plugins\texthook texthook /S /Y /I /EXCLUDE:exclude.txt 15 | xcopy %1\cpp\libs\memdbg memdbg /S /Y /I 16 | xcopy %1\cpp\libs\ntdll ntdll /S /Y /I 17 | xcopy %1\cpp\libs\ntinspect ntinspect /S /Y /I 18 | xcopy %1\cpp\libs\winkey winkey /S /Y /I 19 | xcopy %1\cpp\libs\winmaker winmaker /S /Y /I 20 | xcopy %1\cpp\libs\winmutex winmutex /S /Y /I 21 | xcopy %1\cpp\libs\winversion winversion /S /Y /I 22 | xcopy %1\cpp\libs\winseh winseh /S /Y /I 23 | xcopy %1\cpp\libs\wintimer wintimer /S /Y /I 24 | xcopy %1\cpp\libs\windbg windbg /S /Y /I 25 | xcopy %1\cpp\libs\sakurakit sakurakit /S /Y /I 26 | xcopy %1\cpp\libs\mono mono /S /Y /I 27 | 28 | endlocal 29 | -------------------------------------------------------------------------------- /gui/ProfileManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ITH.h" 4 | #include "utility.h" // UniqueHandle, CriticalSection 5 | 6 | class Profile; 7 | 8 | class ProfileManager 9 | { 10 | public: 11 | ProfileManager(); 12 | ~ProfileManager(); 13 | Profile* CreateProfile(DWORD pid); 14 | Profile* GetProfile(DWORD pid); 15 | Profile* GetProfile(const std::wstring& path); 16 | void LoadProfiles(); 17 | void SaveProfiles(); 18 | void DeleteProfile(const std::wstring& path); 19 | void UpdateHookAddresses(DWORD pid); 20 | bool HasProfile(const std::wstring& path); 21 | private: 22 | typedef std::unique_ptr profile_ptr; 23 | typedef std::map profile_map; 24 | 25 | ProfileManager(const ProfileManager&); 26 | ProfileManager operator=(const ProfileManager&); 27 | 28 | DWORD CountProfiles(); 29 | bool CreateProfile(pugi::xml_node game); 30 | void WriteProfileXml(const std::wstring& path, Profile& pf, pugi::xml_node doc); 31 | // locate profile with executable path 32 | profile_map profile_tree; 33 | CriticalSection cs; 34 | UniqueHandle hMonitorThread; 35 | }; 36 | -------------------------------------------------------------------------------- /i18n/gui_korean/ProfileManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ITH.h" 4 | #include "utility.h" // UniqueHandle, CriticalSection 5 | 6 | class Profile; 7 | 8 | class ProfileManager 9 | { 10 | public: 11 | ProfileManager(); 12 | ~ProfileManager(); 13 | Profile* CreateProfile(DWORD pid); 14 | Profile* GetProfile(DWORD pid); 15 | Profile* GetProfile(const std::wstring& path); 16 | void LoadProfiles(); 17 | void SaveProfiles(); 18 | void DeleteProfile(const std::wstring& path); 19 | void UpdateHookAddresses(DWORD pid); 20 | bool HasProfile(const std::wstring& path); 21 | private: 22 | typedef std::unique_ptr profile_ptr; 23 | typedef std::map profile_map; 24 | 25 | ProfileManager(const ProfileManager&); 26 | ProfileManager operator=(const ProfileManager&); 27 | 28 | DWORD CountProfiles(); 29 | bool CreateProfile(pugi::xml_node game); 30 | void WriteProfileXml(const std::wstring& path, Profile& pf, pugi::xml_node doc); 31 | // locate profile with executable path 32 | profile_map profile_tree; 33 | CriticalSection cs; 34 | UniqueHandle hMonitorThread; 35 | }; 36 | -------------------------------------------------------------------------------- /vnr/cpputil/cppunicode.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPUNICODE_H 2 | #define CPPUNICODE_H 3 | 4 | #include 5 | typedef std::basic_string, std::allocator > cpp_u16string; 6 | typedef std::basic_string, std::allocator > cpp_u32string; 7 | 8 | // 9 | #if defined(_FSTREAM_) || defined(_LIBCPP_FSTREAM) || defined(_GLIBCXX_FSTREAM) 10 | typedef std::basic_ifstream > cpp_u16ifstream; 11 | typedef std::basic_ifstream > cpp_u32ifstream; 12 | 13 | typedef std::basic_ofstream > cpp_u16ofstream; 14 | typedef std::basic_ofstream > cpp_u32ofstream; 15 | 16 | typedef std::basic_fstream > cpp_u16fstream; 17 | typedef std::basic_fstream > cpp_u32fstream; 18 | #endif // 19 | 20 | inline char16_t cpp_u32low(char32_t c) { return c; } 21 | inline char16_t cpp_u32high(char32_t c) { return c >> 16; } 22 | 23 | #endif // CPPUNICODE_H 24 | -------------------------------------------------------------------------------- /gui/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef IDC_STATIC 2 | #define IDC_STATIC (-1) 3 | #endif 4 | 5 | #define IDD_DIALOG2 102 6 | #define IDD_DIALOG4 104 7 | #define IDI_ICON1 110 8 | #define IDC_CHECK1 1000 9 | #define IDC_CHECK2 1001 10 | #define IDC_CHECK3 1002 11 | #define IDC_CHECK4 1003 12 | #define IDC_CHECK5 1004 13 | #define IDC_EDIT1 1011 14 | #define IDC_EDIT2 1012 15 | #define IDC_EDIT3 1013 16 | #define IDC_EDIT4 1014 17 | #define IDC_BUTTON1 1020 18 | #define IDC_BUTTON2 1021 19 | #define IDC_BUTTON3 1022 20 | #define IDC_BUTTON5 1024 21 | #define IDC_LIST1 1028 22 | #define IDC_BUTTON6 40000 23 | #define IDC_CHECK6 40001 24 | -------------------------------------------------------------------------------- /i18n/gui_korean/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef IDC_STATIC 2 | #define IDC_STATIC (-1) 3 | #endif 4 | 5 | #define IDD_DIALOG2 102 6 | #define IDD_DIALOG4 104 7 | #define IDI_ICON1 110 8 | #define IDC_CHECK1 1000 9 | #define IDC_CHECK2 1001 10 | #define IDC_CHECK3 1002 11 | #define IDC_CHECK4 1003 12 | #define IDC_CHECK5 1004 13 | #define IDC_EDIT1 1011 14 | #define IDC_EDIT2 1012 15 | #define IDC_EDIT3 1013 16 | #define IDC_EDIT4 1014 17 | #define IDC_BUTTON1 1020 18 | #define IDC_BUTTON2 1021 19 | #define IDC_BUTTON3 1022 20 | #define IDC_BUTTON5 1024 21 | #define IDC_LIST1 1028 22 | #define IDC_BUTTON6 40000 23 | #define IDC_CHECK6 40001 24 | -------------------------------------------------------------------------------- /vnr/winkey/winkey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // winkey.h 4 | // 7/21/2011 5 | 6 | #include 7 | 8 | #ifndef WINKEY_BEGIN_NAMESPACE 9 | # define WINKEY_BEGIN_NAMESPACE namespace WinKey { 10 | #endif 11 | #ifndef WINKEY_END_NAMESPACE 12 | # define WINKEY_END_NAMESPACE } // namespace WinKey 13 | #endif 14 | 15 | 16 | WINKEY_BEGIN_NAMESPACE 17 | 18 | inline bool isKeyPressed(int vk) { return ::GetKeyState(vk) & 0xf0; } 19 | inline bool isKeyToggled(int vk) { return ::GetKeyState(vk) & 0x0f; } 20 | 21 | inline bool isKeyReturnPressed() { return isKeyPressed(VK_RETURN); } 22 | inline bool isKeyControlPressed() { return isKeyPressed(VK_CONTROL); } 23 | inline bool isKeyShiftPressed() { return isKeyPressed(VK_SHIFT); } 24 | inline bool isKeyAltPressed() { return isKeyPressed(VK_MENU); } 25 | //inline bool sKeyCapslockToggled() { return isKeyToggled(VK_CAPITAL); } 26 | inline bool isKeyWinPressed() { return isKeyPressed(VK_LWIN) || isKeyPressed(VK_RWIN); } 27 | 28 | inline bool isMouseLeftButtonPressed() { return isKeyPressed(VK_LBUTTON); } 29 | inline bool isMouseMiddleButtonPressed() { return isKeyPressed(VK_MBUTTON); } 30 | inline bool isMouseRightButtonPressed() { return isKeyPressed(VK_RBUTTON); } 31 | 32 | WINKEY_END_NAMESPACE 33 | -------------------------------------------------------------------------------- /gui/CustomFilter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "ITH.h" 21 | 22 | typedef void (*CustomFilterCallBack) (WORD, PVOID); 23 | 24 | class CustomFilter 25 | { 26 | public: 27 | bool Find(WORD number) const; 28 | void Insert(WORD number); 29 | void Erase(WORD number); 30 | void Clear(); 31 | void Traverse(CustomFilterCallBack callback, PVOID param); 32 | private: 33 | std::set set; 34 | }; 35 | -------------------------------------------------------------------------------- /i18n/gui_korean/CustomFilter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "ITH.h" 21 | 22 | typedef void (*CustomFilterCallBack) (WORD, PVOID); 23 | 24 | class CustomFilter 25 | { 26 | public: 27 | bool Find(WORD number) const; 28 | void Insert(WORD number); 29 | void Erase(WORD number); 30 | void Clear(); 31 | void Traverse(CustomFilterCallBack callback, PVOID param); 32 | private: 33 | std::set set; 34 | }; 35 | -------------------------------------------------------------------------------- /vnr/texthook/host/host.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // host.h 4 | // 8/23/2013 jichi 5 | // Branch: ITH/IHF.h, rev 105 6 | 7 | //#include "host/settings.h" 8 | #include "config.h" 9 | #include "host/hookman.h" 10 | 11 | struct Settings; 12 | struct HookParam; 13 | 14 | IHFSERVICE void IHFAPI Host_Init(); 15 | IHFSERVICE void IHFAPI Host_Destroy(); 16 | 17 | IHFSERVICE DWORD IHFAPI Host_Start(); 18 | IHFSERVICE BOOL IHFAPI Host_Open(); 19 | IHFSERVICE DWORD IHFAPI Host_Close(); 20 | IHFSERVICE DWORD IHFAPI Host_GetHookManager(HookManager **hookman); 21 | IHFSERVICE bool IHFAPI Host_GetSettings(Settings **settings); 22 | IHFSERVICE DWORD IHFAPI Host_GetPIDByName(LPCWSTR pwcTarget); 23 | IHFSERVICE bool IHFAPI Host_InjectByPID(DWORD pid); 24 | IHFSERVICE bool IHFAPI Host_ActiveDetachProcess(DWORD pid); 25 | IHFSERVICE bool IHFAPI Host_HijackProcess(DWORD pid); 26 | IHFSERVICE DWORD IHFAPI Host_InsertHook(DWORD pid, HookParam *hp, LPCSTR name = nullptr); 27 | IHFSERVICE DWORD IHFAPI Host_ModifyHook(DWORD pid, HookParam *hp); 28 | IHFSERVICE DWORD IHFAPI Host_RemoveHook(DWORD pid, DWORD addr); 29 | IHFSERVICE DWORD IHFAPI Host_AddLink(DWORD from, DWORD to); 30 | IHFSERVICE DWORD IHFAPI Host_UnLink(DWORD from); 31 | IHFSERVICE DWORD IHFAPI Host_UnLinkAll(DWORD from); 32 | 33 | // EOF 34 | -------------------------------------------------------------------------------- /vnr/vnrhook/TRASH/dllconfig.pri: -------------------------------------------------------------------------------- 1 | # dllconfig.pri 2 | # 8/9/2013 jichi 3 | # For linking ITH injectable dlls. 4 | # The dll is self-contained and Windows-independent. 5 | 6 | CONFIG += dll noqt #noeh nosafeseh 7 | CONFIG -= embed_manifest_dll # dynamically load dlls 8 | win32 { 9 | CONFIG(eh): DEFINES += ITH_HAS_SEH # Do have exception handler in msvcrt.dll on Windows Vista and later 10 | CONFIG(noeh): DEFINES -= ITH_HAS_SEH # Do not have exception handler in msvcrt.dll on Windows XP and before 11 | } 12 | include(../../../config.pri) 13 | #win32 { 14 | # CONFIG(noeh): include($$LIBDIR/winseh/winseh_safe.pri) 15 | #} 16 | 17 | # jichi 11/24/2013: Disable manual heap 18 | DEFINES -= ITH_HAS_HEAP 19 | 20 | # jichi 11/13/2011: disable swprinf warning 21 | DEFINES += _CRT_NON_CONFORMING_SWPRINTFS 22 | 23 | ## Libraries 24 | 25 | #LIBS += -lkernel32 -luser32 -lgdi32 26 | LIBS += -L$$WDK7_HOME/lib/wxp/i386 -lntdll 27 | LIBS += $$WDK7_HOME/lib/crt/i386/msvcrt.lib # Override msvcrt10 28 | #LIBS += -L$$WDK7_HOME/lib/crt/i386 -lmsvcrt 29 | #QMAKE_LFLAGS += $$WDK7_HOME/lib/crt/i386/msvcrt.lib # This will leave runtime flags in the dll 30 | 31 | #LIBS += -L$$WDK8_HOME/lib/winv6.3/um/x86 -lntdll 32 | 33 | HEADERS += $$PWD/dllconfig.h 34 | 35 | # EOF 36 | -------------------------------------------------------------------------------- /vnr/ithsys/ithsys.pro: -------------------------------------------------------------------------------- 1 | # ithsys.pro 2 | # 8/21/2013 jichi 3 | # Build ithsys.lib 4 | 5 | #CONFIG += noqt noeh staticlib 6 | CONFIG += noqt staticlib 7 | 8 | include(../../../config.pri) 9 | include($$LIBDIR/ntdll/ntdll.pri) 10 | 11 | #LIBS += -L$$WDK7_HOME/lib/wxp/i386 -lntdll 12 | 13 | #include($$LIBDIR/winddk/winddk.pri) 14 | #LIBS += -L$$WDK/lib/wxp/i386 15 | 16 | # jichi 9/22/2013: When ITH is on wine, certain NT functions are replaced 17 | #DEFINES += ITH_WINE 18 | 19 | # jichi 7/12/2015: Always enable SEH 20 | DEFINES += ITH_HAS_SEH 21 | 22 | # jichi 11/24/2013: Disable manual heap 23 | DEFINES -= ITH_HAS_HEAP 24 | 25 | ## Libraries 26 | 27 | #INCLUDEPATH += $$ITH_HOME/include 28 | #INCLUDEPATH += $$WDK7_HOME/inc/ddk 29 | 30 | #LIBS += -lgdi32 -luser32 -lkernel32 31 | #LIBS += -L$$WDK7_HOME/lib/wxp/i386 -lntdll 32 | #LIBS += $$WDK7_HOME/lib/crt/i386/msvcrt.lib # Override msvcrt10 33 | 34 | #DEFINES += ITH_HAS_CXX 35 | 36 | #LIBS += -lith_sys -lntdll 37 | #LIBS += -lith_tls -lntdll 38 | #LIBS += -lntoskrnl 39 | 40 | DEFINES += _CRT_NON_CONFORMING_SWPRINTFS 41 | 42 | ## Sources 43 | 44 | TEMPLATE = lib 45 | TARGET = ithsys 46 | 47 | HEADERS += ithsys.h 48 | SOURCES += ithsys.cc 49 | 50 | OTHER_FILES += ithsys.pri 51 | 52 | # EOF 53 | -------------------------------------------------------------------------------- /vnr/mono/monoobject.h: -------------------------------------------------------------------------------- 1 | #ifndef MONOOBJECT_H 2 | #define MONOOBJECT_H 3 | 4 | // monoobject.h 5 | // 12/26/2014 jichi 6 | // https://github.com/mono/mono/blob/master/mono/metadata/object.h 7 | // https://github.com/mono/mono/blob/master/mono/metadata/object-internals.h 8 | // https://github.com/mono/mono/blob/master/mono/util/mono-publib.h 9 | 10 | #include 11 | 12 | #define MONO_ZERO_LEN_ARRAY 1 13 | 14 | // mono/io-layer/uglify.h 15 | //typedef int8_t gint8; 16 | //typedef int32_t gint32; 17 | //typedef wchar_t gunichar2; // either char or wchar_t, depending on how mono is compiled 18 | 19 | typedef int32_t mono_bool; 20 | typedef uint8_t mono_byte; 21 | typedef uint16_t mono_unichar2; 22 | typedef uint32_t mono_unichar4; 23 | 24 | // mono/metadata/object.h 25 | 26 | typedef mono_bool MonoBoolean; 27 | 28 | struct MonoArray; 29 | struct MonoDelegate; 30 | struct MonoDomain; 31 | struct MonoException; 32 | struct MonoString; 33 | struct MonoThreadsSync; 34 | struct MonoThread; 35 | struct MonoVTable; 36 | 37 | struct MonoObject { 38 | MonoVTable *vtable; 39 | MonoThreadsSync *synchronisation; 40 | }; 41 | 42 | struct MonoString { 43 | MonoObject object; 44 | int32_t length; 45 | mono_unichar2 chars[MONO_ZERO_LEN_ARRAY]; 46 | }; 47 | 48 | #endif // MONOOBJECT_H 49 | -------------------------------------------------------------------------------- /vnr/texthook/host/host_p.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // host_p.h 3 | // 8/24/2013 jichi 4 | // Branch IHF/main.h, rev 111 5 | #include 6 | 7 | #define GLOBAL extern 8 | #define SHIFT_JIS 0x3A4 9 | class HookManager; 10 | //class CommandQueue; 11 | class SettingManager; 12 | class TextHook; 13 | //class BitMap; 14 | //class CustomFilterMultiByte; 15 | //class CustomFilterUnicode; 16 | //#define TextHook Hook 17 | GLOBAL BOOL running; 18 | //GLOBAL BitMap *pid_map; 19 | //GLOBAL CustomFilterMultiByte *mb_filter; 20 | //GLOBAL CustomFilterUnicode *uni_filter; 21 | GLOBAL HookManager *man; 22 | //GLOBAL CommandQueue *cmdq; 23 | GLOBAL SettingManager *setman; 24 | GLOBAL WCHAR recv_pipe[]; 25 | GLOBAL WCHAR command[]; 26 | GLOBAL HANDLE hPipeExist; 27 | GLOBAL DWORD split_time, 28 | cyclic_remove, 29 | clipboard_flag, 30 | global_filter; 31 | GLOBAL CRITICAL_SECTION detach_cs; 32 | 33 | DWORD WINAPI RecvThread(LPVOID lpThreadParameter); 34 | DWORD WINAPI CmdThread(LPVOID lpThreadParameter); 35 | 36 | DWORD GetCurrentPID(); 37 | //DWORD GetProcessIDByPath(LPWSTR str); 38 | HANDLE GetCmdHandleByPID(DWORD pid); 39 | //DWORD Inject(HANDLE hProc); 40 | //DWORD InjectByPID(DWORD pid); 41 | //DWORD PIDByName(LPWSTR target); 42 | //DWORD Hash(LPCWSTR module, int length=-1); 43 | 44 | // EOF 45 | -------------------------------------------------------------------------------- /gui/ITH.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "profile/pugixml.hpp" 37 | #pragma warning(disable: 4146) 38 | -------------------------------------------------------------------------------- /i18n/gui_korean/ITH.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "profile/pugixml.hpp" 37 | #pragma warning(disable: 4146) 38 | -------------------------------------------------------------------------------- /vnr/hashutil/hashstr.h: -------------------------------------------------------------------------------- 1 | #ifndef HASHSTR_H 2 | #define HASHSTR_H 3 | 4 | // hashstr.h 5 | // 8/1/2011 6 | // See: http://www.cse.yorku.ca/~oz/hash.html 7 | 8 | #include "hashutil/hashutil.h" 9 | #include 10 | 11 | HASHUTIL_BEGIN_NAMESPACE 12 | 13 | enum : uint64_t { djb2_hash0 = 5381 }; 14 | 15 | /// djb2: h = h*33 + c 16 | template 17 | inline uint64_t djb2(const charT *str, uint64_t hash = djb2_hash0) 18 | { 19 | charT c; 20 | while ((c = *str++)) 21 | hash = ((hash << 5) + hash) + c; // hash * 33 + c 22 | return hash; 23 | } 24 | 25 | /// n: length 26 | template 27 | inline uint64_t djb2_n(const charT *str, size_t len, uint64_t hash = djb2_hash0) 28 | { 29 | while (len--) 30 | hash = ((hash << 5) + hash) + (*str++); // hash * 33 + c 31 | return hash; 32 | } 33 | 34 | /// sdbm: hash(i) = hash(i - 1) * 65599 + str[i]; 35 | template 36 | inline uint64_t sdbm(const charT *str, uint64_t hash = 0) 37 | { 38 | charT c; 39 | while ((c = *str++)) 40 | hash = c + (hash << 6) + (hash << 16) - hash; 41 | return hash; 42 | } 43 | 44 | template 45 | inline uint64_t loselose(const charT *str, uint64_t hash = 0) 46 | { 47 | charT c; 48 | while ((c = *str++)) 49 | hash += c; 50 | return hash; 51 | } 52 | 53 | HASHUTIL_END_NAMESPACE 54 | 55 | #endif // HASHSTR_H 56 | -------------------------------------------------------------------------------- /vnr/sakurakit/skhash.h: -------------------------------------------------------------------------------- 1 | #ifndef SKHASH_H 2 | #define SKHASH_H 3 | 4 | // skhash.h 5 | // 8/1/2011 6 | 7 | #include "sakurakit/skglobal.h" 8 | #include 9 | 10 | SK_BEGIN_NAMESPACE 11 | 12 | enum : quint64 { djb2_hash0 = 5381 }; 13 | 14 | /// djb2: h = h*33 + c 15 | inline quint64 djb2(const quint8 *str, quint64 hash = djb2_hash0) 16 | { 17 | quint8 c; 18 | while ((c = *str++)) 19 | hash = ((hash << 5) + hash) + c; // hash * 33 + c 20 | return hash; 21 | } 22 | 23 | /// s: signed char 24 | inline quint64 djb2_s(const char *str, quint64 hash = djb2_hash0) 25 | { 26 | char c; 27 | while ((c = *str++)) 28 | hash = ((hash << 5) + hash) + c; // hash * 33 + c 29 | return hash; 30 | } 31 | 32 | /// n: length 33 | inline quint64 djb2_n(const quint8 *str, size_t len, quint64 hash = djb2_hash0) 34 | { 35 | while (len--) 36 | hash = ((hash << 5) + hash) + (*str++); // hash * 33 + c 37 | return hash; 38 | } 39 | 40 | /// sdbm: hash(i) = hash(i - 1) * 65599 + str[i]; 41 | inline quint64 sdbm(const quint8 *str, quint64 hash = 0) 42 | { 43 | quint8 c; 44 | while ((c = *str++)) 45 | hash = c + (hash << 6) + (hash << 16) - hash; 46 | return hash; 47 | } 48 | 49 | inline quint64 loselose(const quint8 *str, quint64 hash = 0) 50 | { 51 | quint8 c; 52 | while ((c = *str++)) 53 | hash += c; 54 | return hash; 55 | } 56 | 57 | SK_END_NAMESPACE 58 | 59 | #endif // SKHASH_H 60 | -------------------------------------------------------------------------------- /gui/CustomFilter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "CustomFilter.h" 19 | 20 | void CustomFilter::Insert(WORD number) 21 | { 22 | set.insert(number); 23 | } 24 | 25 | void CustomFilter::Erase(WORD number) 26 | { 27 | set.erase(number); 28 | } 29 | 30 | bool CustomFilter::Find(WORD number) const 31 | { 32 | return set.find(number) != set.end(); 33 | } 34 | 35 | void CustomFilter::Clear() 36 | { 37 | set.clear(); 38 | } 39 | 40 | void CustomFilter::Traverse(CustomFilterCallBack callback, PVOID param) 41 | { 42 | for (auto ch = set.begin(); ch != set.end(); ++ch) 43 | callback(*ch, param); 44 | } 45 | -------------------------------------------------------------------------------- /i18n/gui_korean/CustomFilter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "CustomFilter.h" 19 | 20 | void CustomFilter::Insert(WORD number) 21 | { 22 | set.insert(number); 23 | } 24 | 25 | void CustomFilter::Erase(WORD number) 26 | { 27 | set.erase(number); 28 | } 29 | 30 | bool CustomFilter::Find(WORD number) const 31 | { 32 | return set.find(number) != set.end(); 33 | } 34 | 35 | void CustomFilter::Clear() 36 | { 37 | set.clear(); 38 | } 39 | 40 | void CustomFilter::Traverse(CustomFilterCallBack callback, PVOID param) 41 | { 42 | for (auto ch = set.begin(); ch != set.end(); ++ch) 43 | callback(*ch, param); 44 | } 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ITHVNR 2 | 3 | ## Compiling 4 | 5 | Before compiling *ITHVNR*, You should get CMake, [Windows Driver Kit 7.1](http://www.microsoft.com/en-us/download/details.aspx?id=11800), and Visual Studio. 6 | 7 | ## Downloads 8 | 9 | Releases of *ITHVNR* can be found [here](https://github.com/mireado/ITHVNR/releases). 10 | 11 | ~~mireado build server can be found [here](http://mireado.blog.me).~~ 12 | 13 | ## Overview 14 | 15 | *ITHVNR* is an open-source x32~~/x64~~ text hooker for Windows. 16 | 17 | Basically, ITHVNR base on [Stomp](http://www.hongfire.com/forum/showthread.php/438331-ITHVNR-ITH-with-the-VNR-engine)'s version. 18 | 19 | ## Activity Graph 20 | 21 | [![Throughput Graph](https://graphs.waffle.io/mireado/ITHVNR/throughput.svg)](https://waffle.io/mireado/ITHVNR/metrics/throughput) 22 | 23 | ## Features 24 | 25 | - Open-source 26 | - Hook text 27 | 28 | ## License 29 | 30 | 31 | ## Developers 32 | 33 | - Copyright (C) 2010-2012 [kaosu](qiupf2000@gmail.com) 34 | - Copyright (C) 2015 [zorkzero](zorkzero@hotmail.com) 35 | - VNR engine making by [jichi](http://sakuradite.com/topic) 36 | - ITH updating by [Andys](http://www.hongfire.com/forum/member/126633-andys) 37 | - ITHVNR new GUI & VNR engine migration by [Stomp](http://www.hongfire.com/forum/member/325894-stomp) 38 | 39 | ## Special Thanks 40 | 41 | - Everybody adding issues! 42 | - [IJEMIN](https://github.com/IJEMIN) 43 | - [Eguni](https://github.com/Eguni) 44 | -------------------------------------------------------------------------------- /vnr/vnrhook/TRASH/string.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // ith/common/string.h 4 | // 8/9/2013 jichi 5 | // Branch: ITH/string.h, rev 66 6 | 7 | #ifdef ITH_HAS_CRT // ITH is linked with msvcrt dlls 8 | # include 9 | # include 10 | 11 | #else 12 | # define _INC_SWPRINTF_INL_ 13 | # define CRT_IMPORT __declspec(dllimport) 14 | 15 | #include // for wchar_t 16 | extern "C" { 17 | CRT_IMPORT int swprintf(wchar_t *src, const wchar_t *fmt, ...); 18 | CRT_IMPORT int sprintf(char *src, const char *fmt, ...); 19 | CRT_IMPORT int swscanf(const wchar_t *src, const wchar_t *fmt, ...); 20 | CRT_IMPORT int sscanf(const char *src, const char *fmt, ...); 21 | CRT_IMPORT int wprintf(const wchar_t *fmt, ...); 22 | CRT_IMPORT int printf(const char *fmt, ...); 23 | CRT_IMPORT int _wputs(const wchar_t *src); 24 | CRT_IMPORT int puts(const char *src); 25 | CRT_IMPORT int _stricmp(const char *x, const char *y); 26 | CRT_IMPORT int _wcsicmp(const wchar_t *x, const wchar_t *y); 27 | //CRT_IMPORT size_t strlen(const char *); 28 | //CRT_IMPORT size_t wcslen(const wchar_t *); 29 | //CRT_IMPORT char *strcpy(char *,const char *); 30 | //CRT_IMPORT wchar_t *wcscpy(wchar_t *,const wchar_t *); 31 | CRT_IMPORT void *memmove(void *dst, const void *src, size_t sz); 32 | CRT_IMPORT const char *strchr(const char *src, int val); 33 | CRT_IMPORT int strncmp(const char *x, const char *y, size_t sz); 34 | } // extern "C" 35 | 36 | #endif // ITH_HAS_CRT 37 | -------------------------------------------------------------------------------- /vnr/texthook/texthook.pro: -------------------------------------------------------------------------------- 1 | # texthook.pro 2 | # 10/13/2011 jichi 3 | # Build ith texthook dll. 4 | 5 | CONFIG += noqtgui dll #eha # eha will catch all exceptions, but does not work on Windows XP 6 | include(../../../config.pri) 7 | include(host/host.pri) 8 | include($$LIBDIR/winmutex/winmutex.pri) 9 | include($$LIBDIR/wintimer/wintimer.pri) 10 | include($$LIBDIR/windbg/windbg.pri) 11 | #include($$LIBDIR/winmaker/winmaker.pri) 12 | 13 | # TODO: Get rid of dependence on ITHSYS and NT APIs 14 | include($$PLUGINDIR/vnrhook/vnrhook.pri) 15 | include($$PLUGINDIR/ithsys/ithsys.pri) 16 | LIBS += -L$$WDK7_HOME/lib/wxp/i386 -lntdll 17 | 18 | DEFINES += ITH_HAS_CRT # Use native CRT 19 | 20 | # TODO: Get rid of dependence on msvc's swprintf 21 | DEFINES += _CRT_NON_CONFORMING_SWPRINTFS 22 | 23 | ## Libraries 24 | 25 | QT += core 26 | QT -= gui 27 | 28 | ## Sources 29 | 30 | TEMPLATE = lib 31 | TARGET = texthook 32 | 33 | #CONFIG += staticlib 34 | DEFINES += TEXTHOOK_BUILD_LIB 35 | 36 | HEADERS += \ 37 | growl.h \ 38 | ihf_p.h \ 39 | ith_p.h \ 40 | texthook_config.h \ 41 | texthook.h \ 42 | texthook_p.h \ 43 | textthread_p.h \ 44 | winapi_p.h 45 | 46 | SOURCES += \ 47 | ihf_p.cc \ 48 | ith_p.cc \ 49 | texthook.cc \ 50 | textthread_p.cc \ 51 | winapi_p.cc 52 | 53 | #!wince*: LIBS += -lshell32 54 | #RC_FILE += texthook.rc 55 | 56 | OTHER_FILES += \ 57 | texthook.pri \ 58 | texthook_static.pri \ 59 | texthook.rc 60 | 61 | # EOF 62 | -------------------------------------------------------------------------------- /vnr/vnrhook/TRASH/hookxp.pro: -------------------------------------------------------------------------------- 1 | # hookxp.pro 2 | # 8/9/2013 jichi 3 | # Build vnrhookxp.dll for Windows XP 4 | 5 | CONFIG += noeh # msvcrt on Windows XP does not has exception handler 6 | include(../dllconfig.pri) 7 | include(../sys/sys.pri) 8 | include($$LIBDIR/disasm/disasm.pri) 9 | include($$LIBDIR/memdbg/memdbg.pri) 10 | include($$LIBDIR/ntinspect/ntinspect.pri) 11 | include($$LIBDIR/winkey/winkey.pri) 12 | include($$LIBDIR/winseh/winseh_safe.pri) 13 | include($$LIBDIR/winversion/winversion.pri) 14 | 15 | VPATH += ../hook 16 | INCLUDEPATH += ../hook 17 | 18 | # 9/27/2013: disable ITH this game engine, only for debugging purpose 19 | #DEFINES += ITH_DISABLE_ENGINE 20 | 21 | # jichi 9/22/2013: When ITH is on wine, mutex is needed to protect NtWriteFile 22 | #DEFINES += ITH_WINE 23 | #DEFINES += ITH_SYNC_PIPE 24 | 25 | DEFINES += MEMDBG_NO_STL NTINSPECT_NO_STL 26 | 27 | ## Libraries 28 | 29 | LIBS += -lkernel32 -luser32 -lgdi32 #-lgdiplus 30 | 31 | ## Sources 32 | 33 | TEMPLATE = lib 34 | TARGET = vnrhookxp 35 | 36 | #CONFIG += staticlib 37 | 38 | HEADERS += \ 39 | config.h \ 40 | cli.h \ 41 | hook.h \ 42 | engine/engine.h \ 43 | engine/hookdefs.h \ 44 | engine/match.h \ 45 | engine/pchooks.h \ 46 | engine/util.h \ 47 | tree/avl.h 48 | 49 | SOURCES += \ 50 | main.cc \ 51 | rpc/pipe.cc \ 52 | hijack/texthook.cc \ 53 | engine/engine.cc \ 54 | engine/match.cc \ 55 | engine/pchooks.cc \ 56 | engine/util.cc 57 | 58 | #RC_FILE += vnrhook.rc 59 | #OTHER_FILES += vnrhook.rc 60 | 61 | # EOF 62 | -------------------------------------------------------------------------------- /vnr/cpputil/cpppath.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPPATH_H 2 | #define CPPPATH_H 3 | 4 | // cpppath.h 5 | // 5/7/2014 jichi 6 | 7 | #include // for size_t 8 | 9 | enum : char { cpp_pathsep_unix = '/' , cpp_pathsep_win = '\\' }; 10 | 11 | // basename 12 | 13 | template 14 | inline const charT *cpp_basic_basename(const charT *s) 15 | { 16 | const charT *p = s; 17 | //if (s) // not checked 18 | for (; *s; s++) 19 | if (*s == cpp_pathsep_unix || *s == cpp_pathsep_win) 20 | p = s + 1; 21 | return p; 22 | } 23 | 24 | //if (const char *r = ::strrchr(s, pathsep)) 25 | // return r + 1; // skip the path seperator 26 | //else 27 | // return s; 28 | inline const char *cpp_basename(const char *s) { return cpp_basic_basename(s); } 29 | 30 | //if (const wchar_t *r = ::wcsrchr(s, pathsep)) 31 | // return r + 1; // skip the path seperator 32 | //else 33 | // return s; 34 | inline const wchar_t *cpp_wbasename(const wchar_t *s) { return cpp_basic_basename(s); } 35 | 36 | // dirmame 37 | 38 | /// Return the length so that s[len] == pathsep 39 | template 40 | inline size_t cpp_basic_dirlen(const charT *s) 41 | { 42 | const charT *p = s, 43 | *t = s; 44 | //if (s) // not checked 45 | for (; *s; s++) 46 | if (*s == cpp_pathsep_unix || *s == cpp_pathsep_win) 47 | p = s + 1; 48 | return p - t; 49 | } 50 | 51 | inline size_t cpp_wdirlen(const char *s) { return cpp_basic_dirlen(s); } 52 | inline size_t cpp_wdirlen(const wchar_t *s) { return cpp_basic_dirlen(s); } 53 | 54 | #endif // CPPPATH_H 55 | -------------------------------------------------------------------------------- /vnr/sakurakit/sakurakit.pri: -------------------------------------------------------------------------------- 1 | # sakurakit.pri 2 | # 6/28/2011 jichi 3 | # 4 | # config: 5 | # - sakurakit_qml 6 | # - sakurakit_gui 7 | # - sakurakit_widgets 8 | 9 | DEFINES += WITH_LIB_SAKURAKIT 10 | DEPENDPATH += $$PWD 11 | 12 | #QT += core 13 | HEADERS += \ 14 | $$PWD/skautorun.h \ 15 | $$PWD/skdebug.h \ 16 | $$PWD/skglobal.h \ 17 | $$PWD/skhash.h 18 | 19 | #CONFIG(sakurakit_gui) { 20 | # DEFINES += SK_ENABLE_GUI 21 | # QT += gui 22 | # HEADERS += \ 23 | # $$PWD/skuiutil.h 24 | # 25 | # CONFIG(sakurakit_qml) { 26 | # DEFINES += SK_ENABLE_QML 27 | # QT += qml quick 28 | # HEADERS += \ 29 | # $$PWD/skdraggablequickview.h 30 | # SOURCES += \ 31 | # $$PWD/skdraggablequickview.cc 32 | # } 33 | # 34 | # CONFIG(sakurakit_widgets) { 35 | # DEFINES += SK_ENABLE_WIDGETS 36 | # QT += widgets 37 | # HEADERS += \ 38 | # $$PWD/skdraggabledialog.h \ 39 | # $$PWD/skdraggablemainwindow.h \ 40 | # $$PWD/skdraggablewidget.h \ 41 | # $$PWD/skpushbutton.h \ 42 | # $$PWD/sksystemtrayicon.h \ 43 | # $$PWD/sktoolbutton.h \ 44 | # $$PWD/skwindowcontainer.h 45 | # SOURCES += \ 46 | # $$PWD/skdraggablewidget.cc \ 47 | # $$PWD/skpushbutton.cc \ 48 | # $$PWD/sktoolbutton.cc \ 49 | # $$PWD/skwindowcontainer.cc \ 50 | # $$PWD/skdraggabledialog.cc \ 51 | # $$PWD/skdraggablemainwindow.cc 52 | # 53 | # CONFIG(sakurakit_qml) { 54 | # HEADERS += \ 55 | # $$PWD/skquickwidget.h 56 | # SOURCES += \ 57 | # $$PWD/skquickwidget.cc 58 | # } 59 | # } 60 | #} 61 | 62 | # EOF 63 | -------------------------------------------------------------------------------- /vnr/vnrhook/TRASH/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // ith/common/memory.h 4 | // 8/23/2013 jichi 5 | // Branch: ITH/mem.h, revision 66 6 | 7 | #ifndef ITH_HAS_HEAP 8 | # define ITH_MEMSET_HEAP(...) ::memset(__VA_ARGS__) 9 | #else 10 | # define ITH_MEMSET_HEAP(...) (void)0 11 | 12 | // Defined in kernel32.lilb 13 | extern "C" { 14 | // PVOID RtlAllocateHeap( _In_ PVOID HeapHandle, _In_opt_ ULONG Flags, _In_ SIZE_T Size); 15 | __declspec(dllimport) void * __stdcall RtlAllocateHeap(void *HeapHandle, unsigned long Flags, unsigned long Size); 16 | 17 | // BOOLEAN RtlFreeHeap( _In_ PVOID HeapHandle, _In_opt_ ULONG Flags, _In_ PVOID HeapBase); 18 | __declspec(dllimport) int __stdcall RtlFreeHeap(void *HeapHandle, unsigned long Flags, void *HeapBase); 19 | } // extern "C" 20 | 21 | //NTSYSAPI 22 | //BOOL 23 | //NTAPI 24 | //RtlFreeHeap( 25 | // _In_ HANDLE hHeap, 26 | // _In_ DWORD dwFlags, 27 | // _In_ LPVOID lpMem 28 | //); 29 | 30 | extern void *hHeap; // defined in ith/sys.cc 31 | 32 | inline void * __cdecl operator new(size_t lSize) 33 | { 34 | // http://msdn.microsoft.com/en-us/library/windows/desktop/aa366597%28v=vs.85%29.aspx 35 | // HEAP_ZERO_MEMORY flag is critical. All new objects are assumed with zero initialized. 36 | enum { HEAP_ZERO_MEMORY = 0x00000008 }; 37 | return RtlAllocateHeap(::hHeap, HEAP_ZERO_MEMORY, lSize); 38 | } 39 | 40 | inline void __cdecl operator delete(void *pBlock) 41 | { RtlFreeHeap(::hHeap, 0, pBlock); } 42 | 43 | inline void __cdecl operator delete[](void *pBlock) 44 | { RtlFreeHeap(::hHeap, 0, pBlock); } 45 | 46 | #endif // ITH_HAS_HEAP 47 | -------------------------------------------------------------------------------- /vnr/winmaker/winmaker.cc: -------------------------------------------------------------------------------- 1 | // winmaker.cc 2 | // 2/1/2013 jichi 3 | 4 | #include "winmaker/winmaker.h" 5 | #include 6 | //#include 7 | 8 | #ifdef _MSC_VER 9 | # pragma warning (disable:4800) // C4800: forcing value to bool 10 | #endif // _MSC_VER 11 | 12 | // See: http://www.codeguru.com/cpp/w-p/dll/tips/article.php/c3635/Tip-Detecting-a-HMODULEHINSTANCE-Handle-Within-the-Module-Youre-Running-In.htm 13 | extern "C" IMAGE_DOS_HEADER __ImageBase; 14 | namespace { // unnamed 15 | inline HMODULE _get_module() { return reinterpret_cast(&__ImageBase); } 16 | } // unnamed 17 | 18 | bool wm_register_hidden_class(LPCWSTR className) 19 | { 20 | WNDCLASSEX wx = {}; 21 | wx.cbSize = sizeof(wx); 22 | wx.lpfnWndProc = ::DefWindowProc; 23 | wx.hInstance = ::GetModuleHandle(nullptr); 24 | wx.lpszClassName = className; 25 | return ::RegisterClassEx(&wx); 26 | } 27 | 28 | wm_window_t wm_create_hidden_window(LPCWSTR windowName, LPCWSTR className, wm_module_t dllHandle) 29 | { 30 | //return ::CreateWindowExA(0, className, windowName, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, dllHandle, nullptr); 31 | HINSTANCE module = reinterpret_cast(dllHandle); 32 | if (!module) 33 | module = _get_module(); 34 | return ::CreateWindowEx(0, className, windowName, 0, 0, 0, 0, 0, 0, NULL, module, NULL); 35 | } 36 | 37 | bool wm_destroy_window(wm_window_t hwnd) 38 | { return ::DestroyWindow(reinterpret_cast(hwnd)); } 39 | 40 | 41 | // EOF 42 | // 43 | //void wm_init() { ::InitCommonControls(); } 44 | //void wm_destroy() {} 45 | //bool wm_destroy_window() { return ::DestroyWindow(hwnd); } 46 | 47 | -------------------------------------------------------------------------------- /vnr/cpputil/cpplocale.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPLOCALE_H 2 | #define CPPLOCALE_H 3 | 4 | // cpplocale.h 5 | // 9/26/2014 jichi 6 | 7 | #include 8 | 9 | #ifdef WITHOUT_CXX_CODECVT 10 | // http://www.boost.org/doc/libs/1_48_0/libs/serialization/doc/codecvt.html 11 | # define BOOST_UTF8_BEGIN_NAMESPACE 12 | # define BOOST_UTF8_END_NAMESPACE 13 | # define BOOST_UTF8_DECL 14 | # include 15 | # include // WARNING: This implementation should only be included ONCE 16 | # define CPPLOCALE_NEW_FACET_UTF8(charT) (new utf8_codecvt_facet) // charT is ignored and assumed to be wchar_t 17 | //# include 18 | //# define CPPLOCALE_NEW_FACET_UTF8(charT) (new utf8_codecvt_facet) 19 | #else 20 | # include 21 | # define CPPLOCALE_NEW_FACET_UTF8(charT) (new std::codecvt_utf8) 22 | #endif // WITHOUT_CXX_CODECVT 23 | 24 | //#include 25 | 26 | // See: http://stackoverflow.com/questions/20195262/how-to-read-an-utf-8-encoded-file-containing-chinese-characters-and-output-them 27 | // The same as boost::locale::generator().generate("UTF-8"), which require linking 28 | // See: http://en.cppreference.com/w/cpp/locale/codecvt_utf8 29 | // - 0x10ffff is the default maximum value. 30 | // - std::consume_header will skip the leading encoding byte from the input. 31 | template 32 | inline std::locale cpp_utf8_locale(std::locale init = std::locale()) //::empty()) 33 | { return std::locale(init, CPPLOCALE_NEW_FACET_UTF8(charT)); } 34 | 35 | #endif // CPPLOCALE_H 36 | -------------------------------------------------------------------------------- /vnr/windbg/util.cc: -------------------------------------------------------------------------------- 1 | // windbg/util.cc 2 | // 1/27/2013 jichi 3 | #include "windbg/util.h" 4 | #include 5 | #include 6 | #include 7 | 8 | WINDBG_BEGIN_NAMESPACE 9 | 10 | class ThreadsSuspenderPrivate 11 | { 12 | public: 13 | std::list threads; 14 | }; 15 | 16 | ThreadsSuspender::ThreadsSuspender(bool autoSuspend) 17 | : d_(new D) 18 | { if (autoSuspend) suspend(); } 19 | 20 | ThreadsSuspender::~ThreadsSuspender() 21 | { 22 | resume(); 23 | delete d_; 24 | } 25 | 26 | void ThreadsSuspender::suspend() 27 | { 28 | HANDLE hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); 29 | if (hSnap == INVALID_HANDLE_VALUE) 30 | return; 31 | THREADENTRY32 entry; 32 | entry.dwSize = sizeof(entry); 33 | DWORD pid = ::GetCurrentProcessId(); 34 | DWORD tid = ::GetCurrentThreadId(); 35 | if (::Thread32First(hSnap, &entry)) 36 | do if (entry.dwSize >= 4 * sizeof(DWORD) && entry.th32OwnerProcessID == pid && entry.th32ThreadID != tid) { 37 | if (HANDLE hThread = ::OpenThread(THREAD_SUSPEND_RESUME, 0, entry.th32ThreadID)) { 38 | if (::SuspendThread(hThread) != DWORD(-1)) 39 | d_->threads.push_back(hThread); 40 | else 41 | ::CloseHandle(hThread); 42 | } 43 | entry.dwSize = sizeof(entry); 44 | } while (::Thread32Next(hSnap, &entry)); 45 | ::CloseHandle(hSnap); 46 | } 47 | 48 | void ThreadsSuspender::resume() 49 | { 50 | if (!d_->threads.empty()) { 51 | BOOST_FOREACH (HANDLE hThread, d_->threads) { 52 | ::ResumeThread(hThread); 53 | ::CloseHandle(hThread); 54 | } 55 | d_->threads.clear(); 56 | } 57 | } 58 | 59 | WINDBG_END_NAMESPACE 60 | 61 | // EOF 62 | -------------------------------------------------------------------------------- /vnr/wintimer/wintimerbase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // wintimerbase.h 4 | // 6/6/2012 jichi 5 | // 6 | // Internal header for wintimer base class. 7 | 8 | #include "sakurakit/skglobal.h" 9 | #include 10 | 11 | #ifdef QT_CORE_LIB 12 | # include 13 | #else 14 | # include 15 | #endif // QT_CORE_LIB 16 | 17 | #ifndef WINTIMER_BEGIN_NAMESPACE 18 | # define WINTIMER_BEGIN_NAMESPACE 19 | #endif 20 | #ifndef WINTIMER_END_NAMESPACE 21 | # define WINTIMER_END_NAMESPACE 22 | #endif 23 | 24 | WINTIMER_BEGIN_NAMESPACE 25 | 26 | /// Internal base class for WinTimer 27 | class WinTimerBase 28 | { 29 | SK_CLASS(WinTimerBase) 30 | SK_DISABLE_COPY(WinTimerBase) 31 | 32 | // - Types - 33 | public: 34 | typedef std::function function_type; 35 | #ifndef QT_CORE_LIB 36 | typedef HWND WId; 37 | #endif // QT_CORE_LIB 38 | 39 | // - Methods - 40 | public: 41 | /// Construct a timer with the parent window handle. 42 | WinTimerBase() 43 | : parentWindow(0), // use 0 instead of nullptr to be consistent with Qt5 44 | interval(0), singleShot(false), active(false) {} 45 | 46 | bool isSingleShot() const { return singleShot; } 47 | bool isActive() const { return active; } 48 | 49 | /// Start TimerProc 50 | void start(); 51 | /// Stop TimerProc 52 | void stop(); 53 | /// Invoke the callback. This function is the callback of the underlying TimerProc 54 | void trigger() { function(); } 55 | 56 | // - Fields - 57 | protected: 58 | static WId globalWindow; 59 | 60 | WId parentWindow; 61 | int interval; 62 | bool singleShot; 63 | bool active; 64 | function_type function; 65 | 66 | }; 67 | 68 | WINTIMER_END_NAMESPACE 69 | -------------------------------------------------------------------------------- /vnr/wintimer/wintimerbase.cc: -------------------------------------------------------------------------------- 1 | // wintimerbase.cc 2 | // 6/6/2012 jichi 3 | 4 | #include "wintimer/wintimerbase.h" 5 | #ifdef QT_CORE_LIB 6 | # include 7 | #else 8 | # include 9 | #endif // QT_CORE_LIB 10 | #include "ccutil/ccmacro.h" 11 | 12 | //#define DEBUG "wintimerbase.cc" 13 | #include "sakurakit/skdebug.h" 14 | 15 | static VOID CALLBACK WinTimerProc( 16 | HWND hwnd, // ウィンドウのハンドル 17 | UINT uMsg, // WM_TIMER メッセージ 18 | UINT_PTR idEvent, // Timer ID 19 | DWORD dwTime // 現在のシステム時刻 20 | ) 21 | { 22 | Q_UNUSED(hwnd) 23 | Q_UNUSED(dwTime) 24 | Q_UNUSED(uMsg) 25 | Q_ASSERT(idEvent); 26 | if (CC_UNLIKELY(!idEvent)) 27 | return; 28 | DOUT("enter"); 29 | WinTimerBase *t = reinterpret_cast(idEvent); 30 | 31 | if (t->isSingleShot() && t->isActive()) 32 | t->stop(); 33 | t->trigger(); 34 | DOUT("leave"); 35 | } 36 | 37 | WINTIMER_BEGIN_NAMESPACE 38 | 39 | // - Construction - 40 | 41 | WId WinTimerBase::globalWindow; 42 | 43 | //WId WinTimer::createHiddenWindow() 44 | //{ 45 | // DOUT("enter: warning: hidden window used"); 46 | // QWidget *w = new QWidget; 47 | // w->resize(QSize()); 48 | // w->show(); 49 | // DOUT("leave"); 50 | // return w->winId(); 51 | //} 52 | 53 | // - Timer - 54 | 55 | void WinTimerBase::start() 56 | { 57 | DOUT("enter: active =" << active << ", interval =" << interval); 58 | active = true; 59 | ::SetTimer(parentWindow, reinterpret_cast(this), interval, WinTimerProc); 60 | DOUT("leave"); 61 | } 62 | 63 | void WinTimerBase::stop() 64 | { 65 | DOUT("enter: active =" << active); 66 | active = false; 67 | ::KillTimer(parentWindow, reinterpret_cast(this)); 68 | DOUT("leave"); 69 | } 70 | 71 | WINTIMER_END_NAMESPACE 72 | 73 | // EOF 74 | -------------------------------------------------------------------------------- /vnr/texthook/texthook_static.pri: -------------------------------------------------------------------------------- 1 | # texthook_static.pri 2 | # 10/13/2011 jichi 3 | 4 | include(../../../config.pri) 5 | include($$LIBDIR/wintimer/wintimer.pri) 6 | 7 | ## Libraries 8 | 9 | #DEFINES += _ITH_DEBUG_MEMORY 10 | 11 | QT += core 12 | 13 | INCLUDEPATH += $$PWD 14 | DEPENDPATH += $$PWD 15 | 16 | #WDK_HOME = c:/winddk 17 | #LIBS += -L$$WDK_HOME/lib 18 | # override folder must come before winddk/inc/api 19 | #INCLUDEPATH += $$PWD/override/wdk/vc10 20 | #INCLUDEPATH += $$WDK_HOME/include/api 21 | #INCLUDEPATH += $$WDK_HOME/include/crt 22 | #INCLUDEPATH += $$WDK_HOME/include/ddk 23 | 24 | #ITH_HOME = c:/dev/ith 25 | #INCLUDEPATH += $$ITH_HOME/include 26 | #LIBS += -L$$ITH_HOME/lib 27 | #LIBS += -lITH_DLL #-lITH_SYS 28 | 29 | #INCLUDEPATH += $$ITH_HOME/include 30 | #LIBS += -L$$ITH_HOME/lib -lihf 31 | 32 | # Tell IHF not to override new operators, see: ith/mem.h 33 | DEFINES += DEFAULT_MM 34 | 35 | #LIBS += -lmsvcrtd 36 | #LIBS += -lmsvcrt 37 | #QMAKE_LFLAGS += /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib 38 | DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_NON_CONFORMING_SWPRINTFS 39 | 40 | ## Sources 41 | 42 | #TEMPLATE = lib 43 | #TARGET = texthook 44 | #CONFIG += dll 45 | #CONFIG += staticlib 46 | #DEFINES += TEXTHOOK_BUILD_LIB 47 | DEFINES += TEXTHOOK_STATIC_LIB 48 | 49 | HEADERS += \ 50 | $$PWD/ihf_p.h \ 51 | $$PWD/ith_p.h \ 52 | $$PWD/texthook_config.h \ 53 | $$PWD/texthook.h \ 54 | $$PWD/texthook_p.h \ 55 | $$PWD/textthread_p.h \ 56 | $$PWD/winapi_p.h 57 | 58 | SOURCES += \ 59 | $$PWD/ihf_p.cc \ 60 | $$PWD/ith_p.cc \ 61 | $$PWD/texthook.cc \ 62 | $$PWD/textthread_p.cc \ 63 | $$PWD/winapi_p.cc 64 | 65 | #!wince*: LIBS += -lshell32 66 | #RC_FILE += texthook.rc 67 | 68 | OTHER_FILES += \ 69 | $$PWD/texthook.pri \ 70 | $$PWD/texthook.pro \ 71 | $$PWD/texthook.rc 72 | 73 | # EOF 74 | -------------------------------------------------------------------------------- /vnr/windbg/inject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // inject.h 4 | // 1/27/2013 jichi 5 | 6 | #include "windbg/windbg.h" 7 | 8 | #include 9 | 10 | WINDBG_BEGIN_NAMESPACE 11 | 12 | enum { PROCESS_INJECT_ACCESS = PROCESS_CREATE_THREAD|PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ }; 13 | enum { INJECT_TIMEOUT = 3000 }; // wait at most 3 seconds for creating remote threads 14 | 15 | /** 16 | * Inject function with 1 argument 17 | * Either pid or the process handle should be specified 18 | * @param addr LONG function memory address 19 | * @param arg LPVOID arg1 data 20 | * @param argSize int arg1 data size 21 | * @param pid process id 22 | * @param hProcess process handle 23 | * @param timeout msec 24 | * @return BOOL 25 | */ 26 | BOOL injectFunction1(_In_ LPCVOID addr, _In_ LPCVOID arg, _In_ SIZE_T argSize, 27 | _In_ DWORD pid = 0, _In_ HANDLE hProcess = INVALID_HANDLE_VALUE, 28 | _In_ INT timeout = INJECT_TIMEOUT); 29 | 30 | /** 31 | * Either pid or the process handle should be specified 32 | * @param dllpath ABSOLUTE path to dll 33 | * @param pid process id 34 | * @param hProcess process handle 35 | * @param timeout msec 36 | * @return BOOL 37 | */ 38 | BOOL injectDllW(_In_ LPCWSTR dllPath, 39 | _In_ DWORD pid = 0, _In_ HANDLE hProcess = INVALID_HANDLE_VALUE, 40 | _In_ INT timeout = INJECT_TIMEOUT); 41 | 42 | /** 43 | * Either pid or the process handle should be specified 44 | * @param hDll dll module handle 45 | * @param pid process id 46 | * @param hProcess process handle 47 | * @param timeout msec 48 | * @return BOOL 49 | */ 50 | BOOL ejectDll(_In_ HANDLE hDll, 51 | _In_ DWORD pid = 0, _In_ HANDLE hProcess = INVALID_HANDLE_VALUE, 52 | _In_ INT timeout = INJECT_TIMEOUT); 53 | 54 | WINDBG_END_NAMESPACE 55 | 56 | // EOF 57 | -------------------------------------------------------------------------------- /vnr/vnrhook/include/defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // vnrhook/defs.h 4 | // 8/23/2013 jichi 5 | 6 | // DLL files 7 | 8 | //#define ITH_SERVER_DLL L"vnrsrv.dll" 9 | //#define ITH_CLIENT_DLL L"vnrcli.dll" 10 | //#define ITH_CLIENT_XP_DLL L"vnrclixp.dll" 11 | ////#define ITH_CLIENT_UX_DLL L"vnrcliux.dll" 12 | //#define ITH_ENGINE_DLL L"vnreng.dll" 13 | //#define ITH_ENGINE_XP_DLL L"vnrengxp.dll" 14 | //#define ITH_ENGINE_UX_DLL L"vnrengux.dll" 15 | 16 | #define ITH_DLL L"vnrhook.dll" 17 | #define ITH_DLL_XP L"vnrhookxp.dll" 18 | 19 | // Pipes 20 | 21 | #define ITH_TEXT_PIPE L"\\??\\pipe\\VNR_TEXT" 22 | #define ITH_COMMAND_PIPE L"\\??\\pipe\\VNR_COMMAND" 23 | 24 | // Sections 25 | 26 | #define ITH_SECTION_ L"VNR_SECTION_" // _%d 27 | 28 | // Mutex 29 | 30 | // jichi 7/12/2015: 31 | // ITH IO name prefix, needed by Windows 10 for NT event and mutex APIs 32 | // Otherwise, NT functions will return status = STATUS_OBJECT_PATH_SYNTAX_BAD 33 | //#define ITH_PATH_ L"\\BaseNamedObjects\\" 34 | #define ITH_PATH_ L"" 35 | 36 | #define ITH_PROCESS_MUTEX_ ITH_PATH_ L"VNR_PROCESS_" // ITH_%d 37 | #define ITH_HOOKMAN_MUTEX_ ITH_PATH_ L"VNR_HOOKMAN_" // ITH_HOOKMAN_%d 38 | #define ITH_DETACH_MUTEX_ ITH_PATH_ L"VNR_DETACH_" // ITH_DETACH_%d 39 | 40 | #define ITH_GRANTPIPE_MUTEX ITH_PATH_ L"VNR_GRANT_PIPE" // ITH_GRANT_PIPE 41 | 42 | #define ITH_CLIENT_MUTEX ITH_PATH_ L"VNR_CLIENT" // ITH_DLL_RUNNING 43 | #define ITH_SERVER_MUTEX ITH_PATH_ L"VNR_SERVER" // ITH_RUNNING 44 | #define ITH_SERVER_HOOK_MUTEX ITH_PATH_ L"VNR_SERVER_HOOK" // original 45 | 46 | // Events 47 | 48 | #define ITH_REMOVEHOOK_EVENT ITH_PATH_ L"VNR_REMOVE_HOOK" // ITH_REMOVE_HOOK 49 | #define ITH_MODIFYHOOK_EVENT ITH_PATH_ L"VNR_MODIFY_HOOK" // ITH_MODIFY_HOOK 50 | #define ITH_PIPEEXISTS_EVENT ITH_PATH_ L"VNR_PIPE_EXISTS" // ITH_PIPE_EXIST 51 | 52 | // EOF 53 | -------------------------------------------------------------------------------- /vnr/winseh/winseh.cc: -------------------------------------------------------------------------------- 1 | // winseh.cc 2 | // 12/13/2013 jichi 3 | 4 | #include "winseh/winseh.h" 5 | #include "ntdll/ntdll.h" 6 | //#include 7 | 8 | // - Define global variables - 9 | 10 | seh_dword_t seh_esp[seh_capacity], 11 | seh_eip[seh_capacity], 12 | seh_eh[seh_capacity]; 13 | seh_dword_t seh_count; 14 | 15 | // - Exception handlers - 16 | 17 | // VC 2013: http://msdn.microsoft.com/en-us/library/b6sf5kbd.aspx 18 | // typedef EXCEPTION_DISPOSITION (*PEXCEPTION_ROUTINE) ( 19 | // _In_ PEXCEPTION_RECORD ExceptionRecord, 20 | // _In_ ULONG64 EstablisherFrame, 21 | // _Inout_ PCONTEXT ContextRecord, 22 | // _Inout_ PDISPATCHER_CONTEXT DispatcherContext 23 | // ); 24 | // 25 | // winnt.h: http://www.codemachine.com/downloads/win81/ntdef.h 26 | // typedef 27 | // __drv_sameIRQL 28 | // __drv_functionClass(EXCEPTION_ROUTINE) 29 | // EXCEPTION_DISPOSITION 30 | // NTAPI 31 | // EXCEPTION_ROUTINE ( 32 | // _Inout_ struct _EXCEPTION_RECORD *ExceptionRecord, 33 | // _In_ PVOID EstablisherFrame, 34 | // _In_ struct _CONTEXT *ContextRecord, 35 | // _In_ PVOID DispatcherContext 36 | // ); 37 | extern "C" EXCEPTION_DISPOSITION _seh_handler( // extern C is needed to avoid name hashing in C++ 38 | _In_ PEXCEPTION_RECORD ExceptionRecord, 39 | _In_ PVOID EstablisherFrame, // do not work if I use ULONG64 40 | _Inout_ PCONTEXT ContextRecord, 41 | _In_ PVOID DispatcherContext) // PDISPATCHER_CONTEXT is not declared in windows.h, use PVOID instead 42 | { 43 | //assert(::seh_count > 0); 44 | ContextRecord->Esp = ::seh_esp[::seh_count - 1]; 45 | ContextRecord->Eip = ::seh_eip[::seh_count - 1]; 46 | //printf("seh_handler:%i,%x,%x\n", ::seh_count, ContextRecord->Esp, ContextRecord->Eip); 47 | return ::seh_eh[::seh_count - 1] ? 48 | reinterpret_cast(::seh_eh[::seh_count - 1])(ExceptionRecord, EstablisherFrame, ContextRecord, DispatcherContext) : 49 | ExceptionContinueExecution; 50 | } 51 | 52 | // EOF 53 | -------------------------------------------------------------------------------- /vnr/sakurakit/skdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef SKDEBUG_H 2 | #define SKDEBUG_H 3 | 4 | // skdebug.h 5 | // 10/16/2011 jichi 6 | // Macros for debug. 7 | 8 | // Debug I/O 9 | // - DPRINT: similar to fprintf, or KDPrint. Print to qDebug 10 | // - DOUT: similar to std::cout. Print to qDebug 11 | // - DERR: similar to std::cerr. Print to qWarning 12 | #if defined(DEBUG) && !defined(SK_NO_DEBUG) 13 | 14 | # if defined(QT_CORE_LIB) && !defined(SK_NO_QT) 15 | # include 16 | # define DPRINT(...) qDebug(QString("%1:%2:").arg((DEBUG), (__FUNCTION__)).toLocal8Bit().constData(), __VA_ARGS__) 17 | # define DOUT(_msg) qDebug() << QString("%1:%2:").arg((DEBUG), (__FUNCTION__)).toLocal8Bit().constData() << _msg 18 | # define DERR(_msg) qWarning() << QString("%1:%2:").arg((DEBUG), (__FUNCTION__)).toLocal8Bit().constData() << _msg 19 | # else 20 | # include 21 | # include 22 | # define DPRINT(...) fprintf(stderr, DEBUG ":" __FUNCTION__ ": " __VA_ARGS__) 23 | # define DWPRINT(...) fwprintf(stderr, DEBUG ":" __FUNCTION__ ": " __VA_ARGS__) 24 | # define DOUT(_msg) std::cout << DEBUG << ":" << __FUNCTION__ << ": " << _msg << std::endl 25 | # define DWOUT(_msg) std::wcout << DEBUG << ":" << __FUNCTION__ << ": " << _msg << std::endl 26 | # define DERR(_msg) std::cerr << DEBUG << ":" << __FUNCTION__ << ": " << _msg << std::endl 27 | # define DWERR(_msg) std::wcerr << DEBUG << ":" << __FUNCTION__ << ": " << _msg << std::endl 28 | # endif // QT_CORE_LIB 29 | 30 | #else // DEBUG 31 | 32 | # define DPRINT(_dummy) (void)0 33 | # define DOUT(_dummy) (void)0 34 | # define DERR(_dummy) (void)0 35 | 36 | //#ifdef _MSC_VER 37 | //# pragma warning (disable:4390) // C4390: empty controlled statement found: is this the intent? 38 | //#endif // _MSC_VER 39 | 40 | //#ifdef __GNUC__ 41 | //# pragma GCC diagnostic ignored "-Wempty-body" // empty body in an if or else statement 42 | //#endif // __GNUC__ 43 | 44 | #endif // DEBUG 45 | 46 | #endif // SKDEBUG_H 47 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/util/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // util.h 4 | // 8/23/2013 jichi 5 | 6 | #include "ntdll/ntdll.h" 7 | 8 | namespace Util { 9 | 10 | bool unloadCurrentModule(); 11 | 12 | DWORD GetCodeRange(DWORD hModule,DWORD *low, DWORD *high); 13 | DWORD FindCallAndEntryBoth(DWORD fun, DWORD size, DWORD pt, DWORD sig); 14 | DWORD FindCallOrJmpRel(DWORD fun, DWORD size, DWORD pt, bool jmp); 15 | DWORD FindCallOrJmpAbs(DWORD fun, DWORD size, DWORD pt, bool jmp); 16 | DWORD FindCallBoth(DWORD fun, DWORD size, DWORD pt); 17 | DWORD FindCallAndEntryAbs(DWORD fun, DWORD size, DWORD pt, DWORD sig); 18 | DWORD FindCallAndEntryRel(DWORD fun, DWORD size, DWORD pt, DWORD sig); 19 | DWORD FindEntryAligned(DWORD start, DWORD back_range); 20 | DWORD FindImportEntry(DWORD hModule, DWORD fun); 21 | 22 | // jichi 4/15/2014: Copied from ITH CLI, for debugging purpose 23 | DWORD FindModuleBase(DWORD hash); 24 | 25 | bool SearchResourceString(LPCWSTR str); 26 | 27 | /** 28 | * @param name process name without path deliminator 29 | */ 30 | inline void GetProcessName(wchar_t *name) 31 | { 32 | //assert(name); 33 | PLDR_DATA_TABLE_ENTRY it; 34 | __asm 35 | { 36 | mov eax,fs:[0x30] 37 | mov eax,[eax+0xc] 38 | mov eax,[eax+0xc] 39 | mov it,eax 40 | } 41 | ::wcscpy(name, it->BaseDllName.Buffer); 42 | } 43 | 44 | /** 45 | * @param path with process name and directy name 46 | */ 47 | inline void GetProcessPath(wchar_t *path) 48 | { 49 | //assert(path); 50 | PLDR_DATA_TABLE_ENTRY it; 51 | __asm 52 | { 53 | mov eax,fs:[0x30] 54 | mov eax,[eax+0xc] 55 | mov eax,[eax+0xc] 56 | mov it,eax 57 | } 58 | ::wcscpy(path, it->FullDllName.Buffer); 59 | } 60 | 61 | /** 62 | * @return HANDLE module handle 63 | */ 64 | inline DWORD GetModuleBase() 65 | { 66 | __asm 67 | { 68 | mov eax,fs:[0x18] 69 | mov eax,[eax+0x30] 70 | mov eax,[eax+0xc] 71 | mov eax,[eax+0xc] 72 | mov eax,[eax+0x18] 73 | } 74 | } 75 | 76 | } // namespace Util 77 | 78 | // EOF 79 | -------------------------------------------------------------------------------- /vnr/texthook/host/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # texthook.pro 2 | # CONFIG += noqtgui dll #eha # eha will catch all exceptions, but does not work on Windows XP 3 | 4 | # DEFINES += ITH_HAS_CRT # Use native CRT 5 | 6 | # # TODO: Get rid of dependence on msvc's swprintf 7 | # DEFINES += _CRT_NON_CONFORMING_SWPRINTFS 8 | 9 | set(vnrhost_src 10 | avl_p.h 11 | config.h 12 | hookman.h 13 | host.h 14 | host_p.h 15 | settings.h 16 | textthread.h 17 | textthread_p.h 18 | hookman.cc 19 | host.cc 20 | pipe.cc 21 | textthread.cc 22 | ${PROJECT_SOURCE_DIR}/winmaker/winmaker.h 23 | ${PROJECT_SOURCE_DIR}/winmaker/winmaker.cc 24 | ${PROJECT_SOURCE_DIR}/winmutex/winmutex.h 25 | # ${PROJECT_SOURCE_DIR}/wintimer/wintimer.h 26 | # ${PROJECT_SOURCE_DIR}/wintimer/wintimer.cc 27 | # ${PROJECT_SOURCE_DIR}/wintimer/wintimerbase.cc 28 | # ${PROJECT_SOURCE_DIR}/wintimer/wintimerbase.h 29 | ${PROJECT_SOURCE_DIR}/windbg/windbg.h 30 | ${PROJECT_SOURCE_DIR}/windbg/windbg_p.h 31 | ${PROJECT_SOURCE_DIR}/windbg/inject.h 32 | ${PROJECT_SOURCE_DIR}/windbg/inject.cc 33 | ${PROJECT_SOURCE_DIR}/windbg/hijack.h 34 | ${PROJECT_SOURCE_DIR}/windbg/hijack.cc 35 | ${PROJECT_SOURCE_DIR}/windbg/util.h 36 | # ${PROJECT_SOURCE_DIR}/windbg/util.cc 37 | ${PROJECT_SOURCE_DIR}/windbg/unload.h 38 | ${PROJECT_SOURCE_DIR}/windbg/unload.cc 39 | ${PROJECT_SOURCE_DIR}/sakurakit/skdebug.h 40 | ) 41 | 42 | add_library(vnrhost SHARED ${vnrhost_src}) 43 | 44 | set_target_properties(vnrhost PROPERTIES LINK_FLAGS /SUBSYSTEM:WINDOWS) 45 | 46 | target_compile_options(vnrhost PRIVATE 47 | # /GR- 48 | $<$:> 49 | $<$:> 50 | ) 51 | 52 | #STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) 53 | 54 | target_link_libraries(vnrhost 55 | ithsys 56 | profile 57 | ${WDK_HOME}/lib/wxp/i386/ntdll.lib 58 | ) 59 | 60 | target_compile_definitions(vnrhost 61 | PRIVATE 62 | ITH_HAS_CRT 63 | _CRT_NON_CONFORMING_SWPRINTFS 64 | ) 65 | 66 | install(TARGETS vnrhost RUNTIME 67 | DESTINATION . 68 | CONFIGURATIONS Release 69 | ) 70 | -------------------------------------------------------------------------------- /vnr/texthook/textthread_p.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // textthread_p.h 4 | // 6/6/2012 jichi 5 | // Internal header. 6 | // Defines TextHook delegate class. 7 | 8 | #include "sakurakit/skglobal.h" 9 | #include 10 | 11 | //QT_FORWARD_DECLARE_CLASS(QByteArray) 12 | 13 | class SharedRef 14 | { 15 | SK_CLASS(SharedRef) 16 | int count_; 17 | public: 18 | SharedRef(): count_(1) {} 19 | int retainCount() const { return count_; } 20 | void retain() { count_++; } 21 | //void release() { count_--; } 22 | static void release(Self *x) { if (--x->count_ <= 0) delete x; } 23 | }; 24 | 25 | // FIXME: This class is not thread-safe! 26 | class TextThread; 27 | class TextThreadDelegatePrivate; 28 | class TextThreadDelegate : public SharedRef 29 | { 30 | SK_EXTEND_CLASS(TextThreadDelegate, SharedRef) 31 | SK_DISABLE_COPY(TextThreadDelegate) 32 | SK_DECLARE_PRIVATE(TextThreadDelegatePrivate) 33 | public: 34 | explicit TextThreadDelegate(TextThread *t); 35 | ~TextThreadDelegate(); 36 | 37 | bool delegateOf(const Self *t) const; 38 | 39 | // - Properties - 40 | 41 | //TextThread *t() const; 42 | int threadNumber() const; 43 | qint32 signature() const; 44 | QString name() const; 45 | bool nameEquals(const char *that) const; // optimized 46 | 47 | // Maximum text size 48 | static int capacity(); 49 | static void setCapacity(int value); 50 | 51 | static bool wideCharacter(); 52 | static void setWideCharacter(bool value); 53 | 54 | static bool removesRepeat(); 55 | static void setRemovesRepeat(bool value); 56 | 57 | static bool keepsSpace(); 58 | static void setKeepsSpace(bool value); 59 | 60 | //TextThread *t() const; 61 | 62 | //int interval() const; 63 | void setInterval(int msecs); 64 | 65 | //WId parentWindow() const; 66 | void setParentWindow(WId winId); 67 | 68 | // - Actions - 69 | 70 | //void append(const QByteArray &data); 71 | /** Add data to the text thread 72 | * @param data raw data 73 | * @param len length of the data 74 | * @param space Whether have LEADING space 75 | */ 76 | void append(const char *data, int len, bool space=false); 77 | void flush(); 78 | void touch(); // keep timer running 79 | }; 80 | 81 | // EOF 82 | -------------------------------------------------------------------------------- /vnr/vnrhook/vnrhook.pro: -------------------------------------------------------------------------------- 1 | # hook.pro 2 | # 8/9/2013 jichi 3 | # Build vnrhook.dll for Windows 7+ 4 | 5 | # Exception handler to catch all exceptions 6 | CONFIG += dll noqt eh eha # noeh nosafeseh 7 | 8 | #CONFIG += noeh # msvcrt on Windows XP does not has exception handler 9 | include(../../../config.pri) 10 | include($$PLUGINDIR/ithsys/ithsys.pri) 11 | include($$LIBDIR/disasm/disasm.pri) 12 | include($$LIBDIR/memdbg/memdbg.pri) 13 | include($$LIBDIR/ntdll/ntdll.pri) 14 | include($$LIBDIR/ntinspect/ntinspect.pri) 15 | include($$LIBDIR/winkey/winkey.pri) 16 | #include($$LIBDIR/winseh/winseh_safe.pri) 17 | include($$LIBDIR/winversion/winversion.pri) 18 | 19 | # 9/27/2013: disable ITH this game engine, only for debugging purpose 20 | #DEFINES += ITH_DISABLE_ENGINE 21 | 22 | # jichi 9/22/2013: When ITH is on wine, mutex is needed to protect NtWriteFile 23 | #DEFINES += ITH_WINE 24 | #DEFINES += ITH_SYNC_PIPE 25 | 26 | DEFINES += ITH_HAS_CRT ITH_HAS_SEH 27 | DEFINES += MEMDBG_NO_STL NTINSPECT_NO_STL # disabled as not used 28 | 29 | # jichi 11/24/2013: Disable manual heap 30 | DEFINES -= ITH_HAS_HEAP 31 | 32 | # jichi 11/13/2011: disable swprinf warning 33 | DEFINES += _CRT_NON_CONFORMING_SWPRINTFS 34 | 35 | ## Libraries 36 | 37 | #LIBS += -L$$WDK7_HOME/lib/wxp/i386 -lntdll 38 | #LIBS += $$WDK7_HOME/lib/crt/i386/msvcrt.lib # Override msvcrt10 39 | 40 | LIBS += -lkernel32 -luser32 -lgdi32 #-lgdiplus 41 | 42 | ## Sources 43 | 44 | TEMPLATE = lib 45 | TARGET = vnrhook 46 | 47 | #CONFIG += staticlib 48 | 49 | HEADERS += \ 50 | include/const.h \ 51 | include/defs.h \ 52 | include/types.h \ 53 | src/except.h \ 54 | src/main.h \ 55 | src/util/growl.h \ 56 | src/util/util.h \ 57 | src/tree/avl.h \ 58 | src/hijack/texthook.h \ 59 | src/engine/engine.h \ 60 | src/engine/hookdefs.h \ 61 | src/engine/match.h \ 62 | src/engine/pchooks.h \ 63 | src/engine/mono/funcinfo.h \ 64 | src/engine/ppsspp/funcinfo.h 65 | 66 | SOURCES += \ 67 | src/main.cc \ 68 | src/pipe.cc \ 69 | src/util/util.cc \ 70 | src/hijack/texthook.cc \ 71 | src/engine/engine.cc \ 72 | src/engine/match.cc \ 73 | src/engine/pchooks.cc 74 | 75 | #RC_FILE += vnrhook.rc 76 | #OTHER_FILES += vnrhook.rc 77 | 78 | OTHER_FILES += vnrhook.pri 79 | 80 | # EOF 81 | -------------------------------------------------------------------------------- /gui/command.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "ITH.h" 19 | #include "host/host.h" 20 | #include "vnrhook/include/const.h" 21 | #include "vnrhook/include/types.h" 22 | #include "language.h" 23 | #include "utility.h" 24 | #include "profile/misc.h" 25 | 26 | extern HookManager* man; 27 | extern HWND hwndProcessComboBox; 28 | 29 | DWORD ProcessCommand(const std::wstring& cmd, DWORD pid) 30 | { 31 | using std::wregex; 32 | using std::regex_match; 33 | std::match_results m; 34 | 35 | if (regex_match(cmd, m, wregex(L"/pn(.+)", wregex::icase))) 36 | { 37 | pid = Host_GetPIDByName(m[1].str().c_str()); 38 | if (pid == 0) 39 | return 0; 40 | Host_InjectByPID(pid); 41 | } 42 | else if (regex_match(cmd, m, wregex(L"/p(\\d+)", wregex::icase))) 43 | { 44 | pid = std::stoul(m[1].str()); 45 | Host_InjectByPID(pid); 46 | } 47 | else if (regex_match(cmd, m, wregex(L"/h(.+)", wregex::icase))) 48 | { 49 | HookParam hp = {}; 50 | if (Parse(m[1].str(), hp)) 51 | Host_InsertHook(pid, &hp); 52 | } 53 | else if (regex_match(cmd, m, wregex(L":l([[:xdigit:]]+)-([[:xdigit:]]+)", wregex::icase))) 54 | { 55 | DWORD from = std::stoul(m[1].str(), NULL, 16); 56 | DWORD to = std::stoul(m[2].str(), NULL, 16); 57 | Host_AddLink(from, to); 58 | } 59 | else if (regex_match(cmd, m, wregex(L":u([[:xdigit:]]+)", wregex::icase))) 60 | { 61 | DWORD from = std::stoul(m[1].str(), NULL, 16); 62 | Host_UnLink(from); 63 | } 64 | else if (regex_match(cmd, m, wregex(L":(?:h|help)", wregex::icase))) 65 | { 66 | ConsoleOutput(Usage); 67 | } 68 | else 69 | { 70 | ConsoleOutput(L"Unknown command. Type :h or :help for help."); 71 | } 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /i18n/gui_korean/command.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "ITH.h" 19 | #include "host/host.h" 20 | #include "vnrhook/include/const.h" 21 | #include "vnrhook/include/types.h" 22 | #include "language.h" 23 | #include "utility.h" 24 | #include "profile/misc.h" 25 | 26 | extern HookManager* man; 27 | extern HWND hwndProcessComboBox; 28 | 29 | DWORD ProcessCommand(const std::wstring& cmd, DWORD pid) 30 | { 31 | using std::wregex; 32 | using std::regex_match; 33 | std::match_results m; 34 | 35 | if (regex_match(cmd, m, wregex(L"/pn(.+)", wregex::icase))) 36 | { 37 | pid = Host_GetPIDByName(m[1].str().c_str()); 38 | if (pid == 0) 39 | return 0; 40 | Host_InjectByPID(pid); 41 | } 42 | else if (regex_match(cmd, m, wregex(L"/p(\\d+)", wregex::icase))) 43 | { 44 | pid = std::stoul(m[1].str()); 45 | Host_InjectByPID(pid); 46 | } 47 | else if (regex_match(cmd, m, wregex(L"/h(.+)", wregex::icase))) 48 | { 49 | HookParam hp = {}; 50 | if (Parse(m[1].str(), hp)) 51 | Host_InsertHook(pid, &hp); 52 | } 53 | else if (regex_match(cmd, m, wregex(L"(?::|)(?:ㅇ|연|l|)([[:xdigit:]]+)(?:-| )([[:xdigit:]]+)", wregex::icase))) 54 | { 55 | DWORD from = std::stoul(m[1].str(), NULL, 16); 56 | DWORD to = std::stoul(m[2].str(), NULL, 16); 57 | Host_AddLink(from, to); 58 | } 59 | else if (regex_match(cmd, m, wregex(L"(?::|)(?:ㅎ|해|해제|u)([[:xdigit:]]+)", wregex::icase))) 60 | { 61 | DWORD from = std::stoul(m[1].str(), NULL, 16); 62 | Host_UnLink(from); 63 | } 64 | else if (regex_match(cmd, m, wregex(L"(?::|)(?:ㄷ|도|도움|도움말|h|help)", wregex::icase))) 65 | { 66 | ConsoleOutput(Usage); 67 | } 68 | else 69 | { 70 | ConsoleOutput(L"알 수 없는 명령어. 도움말을 보시려면, :h 나 :help를 입력하세요."); 71 | } 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /vnr/texthook/growl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // growl.h 4 | // 9/17/2013 jichi 5 | 6 | //#ifdef GROWL_HAS_GROWL 7 | 8 | #include 9 | #include 10 | 11 | #define GROWL_MSG_A(_msg) MessageBoxA(nullptr, _msg, "VNR Message", MB_OK) 12 | #define GROWL_MSG(_msg) MessageBoxW(nullptr, _msg, L"VNR Message", MB_OK) 13 | #define GROWL_WARN(_msg) MessageBoxW(nullptr, _msg, L"VNR Warning", MB_OK) 14 | #define GROWL_ERROR(_msg) MessageBoxW(nullptr, _msg, L"VNR Error", MB_OK) 15 | 16 | inline void GROWL_DWORD(DWORD value) 17 | { 18 | WCHAR buf[100]; 19 | swprintf(buf, L"DWORD: %x", value); 20 | GROWL_MSG(buf); 21 | } 22 | 23 | inline void GROWL_DWORD2(DWORD v, DWORD v2) 24 | { 25 | WCHAR buf[100]; 26 | swprintf(buf, L"DWORD2: %x,%x", v, v2); 27 | GROWL_MSG(buf); 28 | } 29 | 30 | inline void GROWL_DWORD3(DWORD v, DWORD v2, DWORD v3) 31 | { 32 | WCHAR buf[100]; 33 | swprintf(buf, L"DWORD3: %x,%x,%x", v, v2, v3); 34 | GROWL_MSG(buf); 35 | } 36 | 37 | inline void GROWL_DWORD4(DWORD v, DWORD v2, DWORD v3, DWORD v4) 38 | { 39 | WCHAR buf[100]; 40 | swprintf(buf, L"DWORD4: %x,%x,%x,%x", v, v2, v3, v4); 41 | GROWL_MSG(buf); 42 | } 43 | 44 | inline void GROWL_DWORD5(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5) 45 | { 46 | WCHAR buf[100]; 47 | swprintf(buf, L"DWORD5: %x,%x,%x,%x,%x", v, v2, v3, v4, v5); 48 | GROWL_MSG(buf); 49 | } 50 | 51 | inline void GROWL_DWORD6(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6) 52 | { 53 | WCHAR buf[100]; 54 | swprintf(buf, L"DWORD6: %x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6); 55 | GROWL_MSG(buf); 56 | } 57 | 58 | inline void GROWL_DWORD7(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7) 59 | { 60 | WCHAR buf[100]; 61 | swprintf(buf, L"DWORD7: %x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7); 62 | GROWL_MSG(buf); 63 | } 64 | 65 | inline void GROWL_DWORD8(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7, DWORD v8) 66 | { 67 | WCHAR buf[100]; 68 | swprintf(buf, L"DWORD8: %x,%x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7, v8); 69 | GROWL_MSG(buf); 70 | } 71 | 72 | inline void GROWL_DWORD9(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7, DWORD v8, DWORD v9) 73 | { 74 | WCHAR buf[100]; 75 | swprintf(buf, L"DWORD9: %x,%x,%x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7, v8, v9); 76 | GROWL_MSG(buf); 77 | } 78 | 79 | inline void GROWL(DWORD v) { GROWL_DWORD(v); } 80 | inline void GROWL(LPCWSTR v) { GROWL_MSG(v); } 81 | inline void GROWL(LPCSTR v) { GROWL_MSG_A(v); } 82 | 83 | //#endif // GROWL_HAS_GROWL 84 | 85 | // EOF 86 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/util/growl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // growl.h 4 | // 9/17/2013 jichi 5 | 6 | //#ifdef GROWL_HAS_GROWL 7 | 8 | #include 9 | #include 10 | 11 | #define GROWL_MSG_A(_msg) MessageBoxA(nullptr, _msg, "VNR Message", MB_OK) 12 | #define GROWL_MSG(_msg) MessageBoxW(nullptr, _msg, L"VNR Message", MB_OK) 13 | #define GROWL_WARN(_msg) MessageBoxW(nullptr, _msg, L"VNR Warning", MB_OK) 14 | #define GROWL_ERROR(_msg) MessageBoxW(nullptr, _msg, L"VNR Error", MB_OK) 15 | 16 | inline void GROWL_DWORD(DWORD value) 17 | { 18 | WCHAR buf[100]; 19 | swprintf(buf, L"DWORD: %x", value); 20 | GROWL_MSG(buf); 21 | } 22 | 23 | inline void GROWL_DWORD2(DWORD v, DWORD v2) 24 | { 25 | WCHAR buf[100]; 26 | swprintf(buf, L"DWORD2: %x,%x", v, v2); 27 | GROWL_MSG(buf); 28 | } 29 | 30 | inline void GROWL_DWORD3(DWORD v, DWORD v2, DWORD v3) 31 | { 32 | WCHAR buf[100]; 33 | swprintf(buf, L"DWORD3: %x,%x,%x", v, v2, v3); 34 | GROWL_MSG(buf); 35 | } 36 | 37 | inline void GROWL_DWORD4(DWORD v, DWORD v2, DWORD v3, DWORD v4) 38 | { 39 | WCHAR buf[100]; 40 | swprintf(buf, L"DWORD4: %x,%x,%x,%x", v, v2, v3, v4); 41 | GROWL_MSG(buf); 42 | } 43 | 44 | inline void GROWL_DWORD5(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5) 45 | { 46 | WCHAR buf[100]; 47 | swprintf(buf, L"DWORD5: %x,%x,%x,%x,%x", v, v2, v3, v4, v5); 48 | GROWL_MSG(buf); 49 | } 50 | 51 | inline void GROWL_DWORD6(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6) 52 | { 53 | WCHAR buf[100]; 54 | swprintf(buf, L"DWORD6: %x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6); 55 | GROWL_MSG(buf); 56 | } 57 | 58 | inline void GROWL_DWORD7(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7) 59 | { 60 | WCHAR buf[100]; 61 | swprintf(buf, L"DWORD7: %x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7); 62 | GROWL_MSG(buf); 63 | } 64 | 65 | inline void GROWL_DWORD8(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7, DWORD v8) 66 | { 67 | WCHAR buf[100]; 68 | swprintf(buf, L"DWORD8: %x,%x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7, v8); 69 | GROWL_MSG(buf); 70 | } 71 | 72 | inline void GROWL_DWORD9(DWORD v, DWORD v2, DWORD v3, DWORD v4, DWORD v5, DWORD v6, DWORD v7, DWORD v8, DWORD v9) 73 | { 74 | WCHAR buf[100]; 75 | swprintf(buf, L"DWORD9: %x,%x,%x,%x,%x,%x,%x,%x,%x", v, v2, v3, v4, v5, v6, v7, v8, v9); 76 | GROWL_MSG(buf); 77 | } 78 | 79 | inline void GROWL(DWORD v) { GROWL_DWORD(v); } 80 | inline void GROWL(LPCWSTR v) { GROWL_MSG(v); } 81 | inline void GROWL(LPCSTR v) { GROWL_MSG_A(v); } 82 | 83 | //#endif // GROWL_HAS_GROWL 84 | 85 | // EOF 86 | -------------------------------------------------------------------------------- /gui/utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ITH.h" 4 | 5 | struct HookParam; 6 | struct ProcessRecord; 7 | 8 | DWORD ProcessCommand(const std::wstring& cmd, DWORD pid); 9 | std::wstring GetProcessPath(DWORD pid); 10 | void ConsoleOutput(LPCWSTR); 11 | void ConsoleOutput(LPCSTR text); 12 | std::wstring GetProcessTitle(DWORD pid); 13 | std::wstring GetCode(const HookParam& hp, DWORD pid = 0); 14 | 15 | // http://codesequoia.wordpress.com/2012/08/26/stdunique_ptr-for-windows-handles/ 16 | struct HandleDeleter 17 | { 18 | typedef HANDLE pointer; 19 | void operator() (HANDLE h) 20 | { 21 | if (h != INVALID_HANDLE_VALUE) { 22 | CloseHandle(h); 23 | } 24 | } 25 | }; 26 | 27 | typedef std::unique_ptr UniqueHandle; 28 | 29 | class FileWriter : public pugi::xml_writer 30 | { 31 | HANDLE hFile; 32 | public: 33 | FileWriter(HANDLE hFile) : hFile(hFile) {}; 34 | ~FileWriter() {}; 35 | 36 | virtual void write(const void* data, size_t size) 37 | { 38 | DWORD dwNumberOfBytesWritten; 39 | WriteFile(hFile, data, size, &dwNumberOfBytesWritten, NULL); 40 | } 41 | }; 42 | 43 | class WindowsError : public std::exception 44 | { 45 | private: 46 | std::string msg; 47 | DWORD error_code; 48 | public: 49 | WindowsError(DWORD error_code); 50 | virtual const char *what() const; 51 | }; 52 | 53 | HANDLE IthCreateThread(LPVOID start_addr, DWORD param); 54 | bool IthCreateDirectory(LPCWSTR name); 55 | HANDLE IthCreateFile(LPCWSTR name, DWORD option, DWORD share, DWORD disposition); 56 | int MB_WC(const char* mb, wchar_t* wc, int wc_length); 57 | int MB_WC_count(const char* mb, int mb_length); 58 | int WC_MB(const wchar_t *wc, char* mb, int mb_length); 59 | bool Parse(const std::wstring& cmd, HookParam& hp); 60 | 61 | // http://jrdodds.blogs.com/blog/2004/08/raii_in_c.html 62 | class CriticalSection 63 | { 64 | public: 65 | CriticalSection() 66 | { 67 | ::InitializeCriticalSection(&m_rep); 68 | } 69 | ~CriticalSection() 70 | { 71 | ::DeleteCriticalSection(&m_rep); 72 | } 73 | void Enter() 74 | { 75 | ::EnterCriticalSection(&m_rep); 76 | } 77 | void Leave() 78 | { 79 | ::LeaveCriticalSection(&m_rep); 80 | } 81 | private: 82 | CriticalSection(const CriticalSection&); 83 | CriticalSection& operator=(const CriticalSection&); 84 | 85 | CRITICAL_SECTION m_rep; 86 | }; 87 | 88 | class CSLock 89 | { 90 | public: 91 | CSLock(CriticalSection& a_section) 92 | : m_section(a_section) 93 | { 94 | m_section.Enter(); 95 | } 96 | ~CSLock() 97 | { 98 | m_section.Leave(); 99 | } 100 | private: 101 | CSLock(const CSLock&); 102 | CSLock& operator=(const CSLock&); 103 | 104 | CriticalSection& m_section; 105 | }; 106 | -------------------------------------------------------------------------------- /i18n/gui_korean/utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ITH.h" 4 | 5 | struct HookParam; 6 | struct ProcessRecord; 7 | 8 | DWORD ProcessCommand(const std::wstring& cmd, DWORD pid); 9 | std::wstring GetProcessPath(DWORD pid); 10 | void ConsoleOutput(LPCWSTR); 11 | void ConsoleOutput(LPCSTR text); 12 | std::wstring GetProcessTitle(DWORD pid); 13 | std::wstring GetCode(const HookParam& hp, DWORD pid = 0); 14 | 15 | // http://codesequoia.wordpress.com/2012/08/26/stdunique_ptr-for-windows-handles/ 16 | struct HandleDeleter 17 | { 18 | typedef HANDLE pointer; 19 | void operator() (HANDLE h) 20 | { 21 | if (h != INVALID_HANDLE_VALUE) { 22 | CloseHandle(h); 23 | } 24 | } 25 | }; 26 | 27 | typedef std::unique_ptr UniqueHandle; 28 | 29 | class FileWriter : public pugi::xml_writer 30 | { 31 | HANDLE hFile; 32 | public: 33 | FileWriter(HANDLE hFile) : hFile(hFile) {}; 34 | ~FileWriter() {}; 35 | 36 | virtual void write(const void* data, size_t size) 37 | { 38 | DWORD dwNumberOfBytesWritten; 39 | WriteFile(hFile, data, size, &dwNumberOfBytesWritten, NULL); 40 | } 41 | }; 42 | 43 | class WindowsError : public std::exception 44 | { 45 | private: 46 | std::string msg; 47 | DWORD error_code; 48 | public: 49 | WindowsError(DWORD error_code); 50 | virtual const char *what() const; 51 | }; 52 | 53 | HANDLE IthCreateThread(LPVOID start_addr, DWORD param); 54 | bool IthCreateDirectory(LPCWSTR name); 55 | HANDLE IthCreateFile(LPCWSTR name, DWORD option, DWORD share, DWORD disposition); 56 | int MB_WC(const char* mb, wchar_t* wc, int wc_length); 57 | int MB_WC_count(const char* mb, int mb_length); 58 | int WC_MB(const wchar_t *wc, char* mb, int mb_length); 59 | bool Parse(const std::wstring& cmd, HookParam& hp); 60 | 61 | // http://jrdodds.blogs.com/blog/2004/08/raii_in_c.html 62 | class CriticalSection 63 | { 64 | public: 65 | CriticalSection() 66 | { 67 | ::InitializeCriticalSection(&m_rep); 68 | } 69 | ~CriticalSection() 70 | { 71 | ::DeleteCriticalSection(&m_rep); 72 | } 73 | void Enter() 74 | { 75 | ::EnterCriticalSection(&m_rep); 76 | } 77 | void Leave() 78 | { 79 | ::LeaveCriticalSection(&m_rep); 80 | } 81 | private: 82 | CriticalSection(const CriticalSection&); 83 | CriticalSection& operator=(const CriticalSection&); 84 | 85 | CRITICAL_SECTION m_rep; 86 | }; 87 | 88 | class CSLock 89 | { 90 | public: 91 | CSLock(CriticalSection& a_section) 92 | : m_section(a_section) 93 | { 94 | m_section.Enter(); 95 | } 96 | ~CSLock() 97 | { 98 | m_section.Leave(); 99 | } 100 | private: 101 | CSLock(const CSLock&); 102 | CSLock& operator=(const CSLock&); 103 | 104 | CriticalSection& m_section; 105 | }; 106 | -------------------------------------------------------------------------------- /vnr/sakurakit/skglobal.h: -------------------------------------------------------------------------------- 1 | #ifndef SKGLOBAL_H 2 | #define SKGLOBAL_H 3 | 4 | // skglobal.h 5 | // 9/15/2012 jichi 6 | // Similar to QtGlobal from Qt. 7 | // 8 | // Conventions: 9 | // - All classes in sakurakit will be wrapped with SK_BEGIN_NAMESPACE and SK_END_NAMESPACE 10 | // - All classes from sakurakit begin with Sk, such as SkClassA. 11 | // All functions from sakurakit begin with sk, such as skFuncA. 12 | 13 | // Redefine SK_BEGIN_NAMESPACE/SK_END_NAMESPACE if need custom namespace 14 | #ifndef SK_BEGIN_NAMESPACE 15 | # define SK_BEGIN_NAMESPACE namespace Sk { 16 | #endif 17 | #ifndef SK_END_NAMESPACE 18 | # define SK_END_NAMESPACE } // namespace Sk 19 | #endif 20 | 21 | #define SK_FORWARD_DECLARE_CLASS(_name) SK_BEGIN_NAMESPACE class _name; SK_END_NAMESPACE 22 | #define SK_FORWARD_DECLARE_STRUCT(_name) SK_BEGIN_NAMESPACE struct _name; SK_END_NAMESPACE 23 | 24 | SK_BEGIN_NAMESPACE 25 | namespace Sk {} 26 | SK_END_NAMESPACE 27 | 28 | // In case Qt is not avaliable 29 | 30 | //inline void sk_noop(void) {} 31 | // 32 | //template 33 | //inline void skUnused(T &x) { (void)x; } 34 | 35 | #define SK_UNUSED(_var) (void)(_var) 36 | #define SK_NOP SK_UNUSED(0) 37 | 38 | // same as Q_DISABLE_COPY and boost::noncopyable 39 | // Disable when BOOST_PYTHON is enabled 40 | #ifdef BOOST_PYTHON 41 | # define SK_DISABLE_COPY(_class) 42 | #else 43 | # define SK_DISABLE_COPY(_class) \ 44 | _class(const _class &); \ 45 | _class &operator=(const _class &); 46 | #endif // BOOST_PYTHON 47 | 48 | // - Qt-like Pimp - 49 | 50 | // Similar to QT_DECLARE_PRIVATE 51 | #define SK_DECLARE_PRIVATE(_class) \ 52 | friend class _class; \ 53 | typedef _class D; \ 54 | D *const d_; 55 | 56 | // Similar to QT_DECLARE_PUBLIC 57 | #define SK_DECLARE_PUBLIC(_class) \ 58 | friend class _class; \ 59 | typedef _class Q; \ 60 | Q *const q_; 61 | 62 | // - Self and Base - 63 | 64 | #define SK_CLASS(_self) \ 65 | typedef _self Self; \ 66 | Self *self() const { return const_cast(this); } 67 | 68 | #define SK_EXTEND_CLASS(_self, _base) \ 69 | SK_CLASS(_self) \ 70 | typedef _base Base; 71 | 72 | #define SK_UNDEF_POS QPoint(-1, -1) 73 | #define SK_UNDEF_POSF QPointF(-1, -1) 74 | 75 | // - QWidget Style Class for QSS - 76 | 77 | // Read-only property 78 | #define SK_STYLE_CLASS(_class) \ 79 | Q_PROPERTY(QString class READ styleClass) \ 80 | public: \ 81 | QString styleClass() const { return #_class; } \ 82 | private: 83 | 84 | // Read-write property 85 | #define SK_SYNTHESIZE_STYLE_CLASS \ 86 | Q_PROPERTY(QString class READ styleClass WRITE setStyleClass) \ 87 | QString styleClass_; \ 88 | public: \ 89 | QString styleClass() const { return styleClass_; } \ 90 | public slots: \ 91 | void seStyleClass(const QString &value) { styleClass_ = value; } \ 92 | private: 93 | 94 | #endif // SKGLOBAL_H 95 | -------------------------------------------------------------------------------- /vnr/profile/pugiconfig.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * pugixml parser - version 1.6 3 | * -------------------------------------------------------- 4 | * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 5 | * Report bugs and download new versions at http://pugixml.org/ 6 | * 7 | * This library is distributed under the MIT License. See notice at the end 8 | * of this file. 9 | * 10 | * This work is based on the pugxml parser, which is: 11 | * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) 12 | */ 13 | 14 | #ifndef HEADER_PUGICONFIG_HPP 15 | #define HEADER_PUGICONFIG_HPP 16 | 17 | // Uncomment this to enable wchar_t mode 18 | #define PUGIXML_WCHAR_MODE 19 | 20 | // Uncomment this to disable XPath 21 | // #define PUGIXML_NO_XPATH 22 | 23 | // Uncomment this to disable STL 24 | // #define PUGIXML_NO_STL 25 | 26 | // Uncomment this to disable exceptions 27 | // #define PUGIXML_NO_EXCEPTIONS 28 | 29 | // Set this to control attributes for public classes/functions, i.e.: 30 | // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL 31 | // #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL 32 | // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall 33 | // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead 34 | 35 | // Tune these constants to adjust memory-related behavior 36 | // #define PUGIXML_MEMORY_PAGE_SIZE 32768 37 | // #define PUGIXML_MEMORY_OUTPUT_STACK 10240 38 | // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 39 | 40 | // Uncomment this to switch to header-only version 41 | // #define PUGIXML_HEADER_ONLY 42 | 43 | // Uncomment this to enable long long support 44 | // #define PUGIXML_HAS_LONG_LONG 45 | 46 | #endif 47 | 48 | /** 49 | * Copyright (c) 2006-2015 Arseny Kapoulkine 50 | * 51 | * Permission is hereby granted, free of charge, to any person 52 | * obtaining a copy of this software and associated documentation 53 | * files (the "Software"), to deal in the Software without 54 | * restriction, including without limitation the rights to use, 55 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 56 | * copies of the Software, and to permit persons to whom the 57 | * Software is furnished to do so, subject to the following 58 | * conditions: 59 | * 60 | * The above copyright notice and this permission notice shall be 61 | * included in all copies or substantial portions of the Software. 62 | * 63 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 64 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 65 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 66 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 67 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 68 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 69 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 70 | * OTHER DEALINGS IN THE SOFTWARE. 71 | */ 72 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/engine/mono/funcinfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // mono/funcinfo.h 4 | // 12/26/2014 5 | // https://github.com/mono/mono/blob/master/mono/metadata/object.h 6 | // http://api.xamarin.com/index.aspx?link=xhtml%3Adeploy%2Fmono-api-string.html 7 | 8 | //#include "ith/import/mono/types.h" 9 | 10 | // MonoString* mono_string_new (MonoDomain *domain, 11 | // const char *text); 12 | // MonoString* mono_string_new_len (MonoDomain *domain, 13 | // const char *text, 14 | // guint length); 15 | // MonoString* mono_string_new_size (MonoDomain *domain, 16 | // gint32 len); 17 | // MonoString* mono_string_new_utf16 (MonoDomain *domain, 18 | // const guint16 *text, 19 | // gint32 len); 20 | // MonoString* mono_string_from_utf16 (gunichar2 *data); 21 | // mono_unichar2* mono_string_to_utf16 (MonoString *s); 22 | // char* mono_string_to_utf8 (MonoString *s); 23 | // gboolean mono_string_equal (MonoString *s1, 24 | // MonoString *s2); 25 | // guint mono_string_hash (MonoString *s); 26 | // MonoString* mono_string_intern (MonoString *str); 27 | // MonoString* mono_string_is_interned (MonoString *o); 28 | // MonoString* mono_string_new_wrapper (const char *text); 29 | // gunichar2* mono_string_chars (MonoString *s); 30 | // int mono_string_length (MonoString *s); 31 | // gunichar2* mono_unicode_from_external (const gchar *in, gsize *bytes); 32 | // gchar* mono_unicode_to_external (const gunichar2 *uni); 33 | // gchar* mono_utf8_from_external (const gchar *in); 34 | 35 | struct MonoFunction { 36 | const char *functionName; 37 | size_t textIndex; // argument index, starting from 0 38 | size_t lengthIndex; // argument index, start from 0 39 | unsigned long hookType; // HookParam type 40 | void *text_fun; // HookParam::text_fun_t 41 | }; 42 | 43 | #define MONO_FUNCTIONS_INITIALIZER \ 44 | { "mono_string_to_utf8", 0, 0, USING_UNICODE|NO_CONTEXT, SpecialHookMonoString } \ 45 | , { "mono_string_to_utf8_checked", 0, 0, USING_UNICODE|NO_CONTEXT, SpecialHookMonoString } \ 46 | , { "mono_string_to_utf16", 0, 0, USING_UNICODE|NO_CONTEXT, SpecialHookMonoString } \ 47 | , { "mono_utf8_from_external", 1, 0, USING_STRING|USING_UTF8, nullptr } \ 48 | , { "mono_string_from_utf16", 1, 0, USING_UNICODE, nullptr } \ 49 | , { "mono_string_new_utf16", 2, 3, USING_UNICODE, nullptr } \ 50 | , { "mono_unicode_from_external", 1, 0, USING_UNICODE, nullptr } \ 51 | , { "mono_unicode_to_external", 1, 0, USING_UNICODE, nullptr } 52 | //, { "mono_string_new", 2, 0, USING_STRING|USING_UTF8, nullptr } 53 | //, { "mono_string_new_wrapper", 1, 0, USING_STRING|USING_UTF8, nullptr } 54 | 55 | // EOF 56 | -------------------------------------------------------------------------------- /vnr/vnrhook/src/hijack/texthook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // texthook.h 4 | // 8/24/2013 jichi 5 | // Branch: IHF_DLL/IHF_CLIENT.h, rev 133 6 | // 7 | // 8/24/2013 TODO: 8 | // - Clean up this file 9 | // - Reduce global variables. Use namespaces or singleton classes instead. 10 | 11 | #include "src/tree/avl.h" 12 | #include "include/types.h" 13 | #include 14 | 15 | // jichi 12/25/2013: Header in each message sent to vnrsrv 16 | // There are totally three elements 17 | // - 0x0 dwAddr hook address 18 | // - 0x4 dwRetn return address 19 | // - 0x8 dwSplit split value 20 | #define HEADER_SIZE 0xc 21 | 22 | extern int current_hook; 23 | extern WCHAR dll_mutex[]; 24 | //extern WCHAR dll_name[]; 25 | extern DWORD trigger; 26 | //extern DWORD current_process_id; 27 | 28 | // jichi 6/3/2014: Get memory range of the current module 29 | extern DWORD processStartAddress, 30 | processStopAddress; 31 | 32 | template 33 | class AVLTree; 34 | struct FunctionInfo { 35 | DWORD addr; 36 | DWORD module; 37 | DWORD size; 38 | LPWSTR name; 39 | }; 40 | struct SCMP; 41 | struct SCPY; 42 | struct SLEN; 43 | extern AVLTree *tree; 44 | 45 | void InitFilterTable(); 46 | 47 | // jichi 9/25/2013: This class will be used by NtMapViewOfSectionfor 48 | // interprocedure communication, where constructor/destructor will NOT work. 49 | class TextHook : public Hook 50 | { 51 | int UnsafeInsertHookCode(); 52 | DWORD UnsafeSend(DWORD dwDataBase, DWORD dwRetn); 53 | public: 54 | int InsertHook(); 55 | int InsertHookCode(); 56 | int InitHook(const HookParam &hp, LPCSTR name = 0, WORD set_flag = 0); 57 | int InitHook(LPVOID addr, DWORD data, DWORD data_ind, 58 | DWORD split_off, DWORD split_ind, WORD type, DWORD len_off = 0); 59 | DWORD Send(DWORD dwDataBase, DWORD dwRetn); 60 | int RecoverHook(); 61 | int RemoveHook(); 62 | int ClearHook(); 63 | int ModifyHook(const HookParam&); 64 | int SetHookName(LPCSTR name); 65 | int GetLength(DWORD base, DWORD in); // jichi 12/25/2013: Return 0 if failed 66 | void CoolDown(); // jichi 9/28/2013: flush instruction cache on wine 67 | }; 68 | 69 | extern TextHook *hookman, 70 | *current_available; 71 | 72 | //void InitDefaultHook(); 73 | 74 | struct FilterRange { DWORD lower, upper; }; 75 | extern FilterRange *filter; 76 | 77 | extern bool running, 78 | live; 79 | 80 | extern HANDLE hPipe, 81 | hmMutex; 82 | 83 | DWORD WINAPI WaitForPipe(LPVOID lpThreadParameter); 84 | DWORD WINAPI CommandPipe(LPVOID lpThreadParameter); 85 | 86 | //void RequestRefreshProfile(); 87 | 88 | //typedef DWORD (*InsertHookFun)(DWORD); 89 | //typedef DWORD (*IdentifyEngineFun)(); 90 | //typedef DWORD (*InsertDynamicHookFun)(LPVOID addr, DWORD frame, DWORD stack); 91 | //extern IdentifyEngineFun IdentifyEngine; 92 | //extern InsertDynamicHookFun InsertDynamicHook; 93 | 94 | // jichi 9/28/2013: Protect pipeline in wine 95 | void CliLockPipe(); 96 | void CliUnlockPipe(); 97 | 98 | // EOF 99 | -------------------------------------------------------------------------------- /vnr/vnrhook/include/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // vnrhook/types.h 4 | // 8/23/2013 jichi 5 | // Branch: ITH/common.h, rev 128 6 | 7 | #include // needed for windef types 8 | 9 | /** jichi 3/7/2014: Add guessed comment 10 | * 11 | * DWORD addr absolute or relative address 12 | * DWORD split esp offset of the split character 13 | * 14 | * http://faydoc.tripod.com/cpu/pushad.htm 15 | * http://agth.wikia.com/wiki/Cheat_Engine_AGTH_Tutorial 16 | * The order is the same as pushd 17 | * EAX, ECX, EDX, EBX, ESP (original value), EBP, ESI, and EDI (if the current operand-size attribute is 32) and AX, CX, DX, BX, SP 18 | * Negative values of 'data_offset' and 'sub_offset' refer to registers:-4 for EAX, -8 for ECX, -C for EDX, -10 for EBX, -14 for ESP, -18 for EBP, -1C for ESI, -20 for EDI 19 | */ 20 | struct HookParam { 21 | // jichi 8/24/2013: For special hooks. 22 | typedef void (*text_fun_t)(DWORD esp, HookParam *hp, BYTE index, DWORD *data, DWORD *split, DWORD *len); 23 | 24 | // jichi 10/24/2014: Add filter function. Return the if skip the text 25 | typedef bool (*filter_fun_t)(LPVOID str, DWORD *len, HookParam *hp, BYTE index); 26 | 27 | // jichi 10/24/2014: Add generic hook function, return false if stop execution. 28 | typedef bool (*hook_fun_t)(DWORD esp, HookParam *hp); 29 | 30 | DWORD address; // absolute or relative address 31 | DWORD offset, // offset of the data in the memory 32 | index, // ? 33 | split, // esp offset of the split character = pusha offset - 4 34 | split_index; // ? 35 | DWORD module, // hash of the module 36 | function; 37 | text_fun_t text_fun; 38 | filter_fun_t filter_fun; 39 | hook_fun_t hook_fun; 40 | DWORD type; // flags 41 | WORD length_offset; // index of the string length 42 | BYTE hook_len, // ? 43 | recover_len; // ? 44 | 45 | // 2/2/2015: jichi number of times - 1 to run the hook 46 | BYTE extra_text_count; 47 | BYTE _unused; // jichi 2/2/2015: add a BYTE type to make to total sizeof(HookParam) even. 48 | 49 | // 7/20/2014: jichi additional parameters for PSP games 50 | DWORD user_flags, 51 | user_value; 52 | }; 53 | 54 | // jichi 6/1/2014: Structure of the esp for extern functions 55 | struct HookStack 56 | { 57 | // pushad 58 | DWORD edi, // -0x24 59 | esi, // -0x20 60 | ebp, // -0x1c 61 | esp, // -0x18 62 | ebx, // -0x14 63 | edx, // -0x10 64 | ecx, // -0xc 65 | eax; // -0x8 66 | // pushfd 67 | DWORD eflags; // -0x4 68 | DWORD retaddr; // 0 69 | DWORD args[1]; // 0x4 70 | }; 71 | 72 | struct SendParam { 73 | DWORD type; 74 | HookParam hp; 75 | }; 76 | 77 | struct Hook { // size: 0x80 78 | HookParam hp; 79 | LPSTR hook_name; 80 | int name_length; 81 | BYTE recover[0x68 - sizeof(HookParam)]; 82 | BYTE original[0x10]; 83 | 84 | DWORD Address() const { return hp.address; } 85 | DWORD Type() const { return hp.type; } 86 | WORD Length() const { return hp.hook_len; } 87 | LPSTR Name() const { return hook_name; } 88 | int NameLength() const { return name_length; } 89 | }; 90 | 91 | // EOF 92 | -------------------------------------------------------------------------------- /gui/language.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | #pragma once 18 | 19 | extern const wchar_t* Warning; 20 | //command.cpp 21 | extern const wchar_t* ErrorSyntax; 22 | extern const wchar_t* Usage; 23 | extern const wchar_t* ExtendedUsage; 24 | //inject.cpp 25 | extern const wchar_t* ErrorRemoteThread; 26 | extern const wchar_t* ErrorOpenProcess; 27 | extern const wchar_t* ErrorNoProcess; 28 | extern const wchar_t* SelfAttach; 29 | extern const wchar_t* AlreadyAttach; 30 | extern const wchar_t* FormatInject; 31 | //main.cpp 32 | extern const wchar_t* NotAdmin; 33 | //pipe.cpp 34 | extern const wchar_t* ErrorCreatePipe; 35 | extern const wchar_t* FormatDetach; 36 | extern const wchar_t* ErrorCmdQueueFull; 37 | extern const wchar_t* ErrorNoAttach; 38 | 39 | //profile.cpp 40 | extern const wchar_t* ErrorMonitor; 41 | 42 | //utility.cpp 43 | extern const wchar_t* InitMessage; 44 | extern const wchar_t* BackgroundMsg; 45 | extern const wchar_t* ErrorLinkExist; 46 | extern const wchar_t* ErrorCylicLink; 47 | extern const wchar_t* FormatLink; 48 | extern const wchar_t* ErrorLink; 49 | extern const wchar_t* ErrorDeleteCombo; 50 | 51 | //window.cpp 52 | extern const wchar_t* ClassName; 53 | extern const wchar_t* ClassNameAdmin; 54 | extern const wchar_t* ErrorNotSplit; 55 | extern const wchar_t* ErrorNotModule; 56 | //Main window buttons 57 | extern const wchar_t* ButtonTitleProcess; 58 | extern const wchar_t* ButtonTitleThread; 59 | extern const wchar_t* ButtonTitleHook; 60 | extern const wchar_t* ButtonTitleProfile; 61 | extern const wchar_t* ButtonTitleOption; 62 | extern const wchar_t* ButtonTitleClear; 63 | extern const wchar_t* ButtonTitleSave; 64 | extern const wchar_t* ButtonTitleTop; 65 | //Hook window 66 | extern const wchar_t* SpecialHook; 67 | //Process window 68 | extern const wchar_t* TabTitlePID; 69 | extern const wchar_t* TabTitleMemory; 70 | extern const wchar_t* TabTitleName; 71 | extern const wchar_t* TabTitleTID; 72 | extern const wchar_t* TabTitleStart; 73 | extern const wchar_t* TabTitleModule; 74 | extern const wchar_t* TabTitleState; 75 | extern const wchar_t* SuccessAttach; 76 | extern const wchar_t* FailAttach; 77 | extern const wchar_t* SuccessDetach; 78 | extern const wchar_t* FailDetach; 79 | //Profile window 80 | extern const wchar_t* ProfileExist; 81 | extern const wchar_t* SuccessAddProfile; 82 | extern const wchar_t* FailAddProfile; 83 | extern const wchar_t* TabTitleNumber; 84 | extern const wchar_t* NoFile; 85 | extern const wchar_t* PathDismatch; 86 | extern const wchar_t* SuccessImportProfile; -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(CMAKE_CONFIGURATION_TYPES Debug Release) 4 | 5 | project(ITHVNR) 6 | 7 | set(WDK_HOME "C:\\WinDDK\\7600.16385.1" CACHE FILEPATH "Windows Driver Kit path") 8 | set(CMAKE_INSTALL_PREFIX "" CACHE FILEPATH "installation path") 9 | 10 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Debug") 11 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Release") 12 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Debug") 13 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Release") 14 | 15 | set(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ON) 16 | 17 | 18 | set(CPACK_GENERATOR "ZIP") 19 | set(CPACK_PACKAGE_VERSION_MAJOR 3) 20 | set(CPACK_PACKAGE_VERSION_MINOR 5640) 21 | set(CPACK_PACKAGE_VERSION_PATCH 1) 22 | set(CPACK_SOURCE_GENERATOR "ZIP") 23 | set(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.swp$;\\\\.#;/#" ".*\\\\.user$" "\\\\.gitignore$" "\\\\.gitmodules$" "\\\\.git$") 24 | include(CPack) 25 | 26 | add_compile_options( 27 | #/Zc:auto # config.pri 28 | /wd4819 # config.pri 29 | /MP 30 | /GS- 31 | # $<$:/MT> 32 | # $<$:/MTd> 33 | ) 34 | 35 | add_definitions( 36 | /D_SECURE_SCL=0 # config.pri 37 | /D_SCL_SECURE_NO_WARNINGS # config.pri 38 | /D_CRT_SECURE_NO_WARNINGS # config.pri 39 | /DUNICODE # config.pri 40 | /D_UNICODE 41 | /D_CRT_NON_CONFORMING_SWPRINTFS # common.pri 42 | /DITH_HAS_CRT 43 | ) 44 | 45 | include_directories( 46 | . 47 | vnr 48 | vnr/texthook 49 | ${CMAKE_BINARY_DIR}/gui 50 | ) 51 | 52 | set(resource_src 53 | gui/ITHVNR.rc 54 | gui/icon1.ico 55 | ) 56 | 57 | set(ithvnr_src 58 | gui/command.cpp 59 | gui/CustomFilter.cpp 60 | gui/CustomFilter.h 61 | gui/ITH.h 62 | gui/language.cpp 63 | gui/language.h 64 | gui/main.cpp 65 | gui/ProcessWindow.cpp 66 | gui/ProcessWindow.h 67 | gui/ProfileManager.cpp 68 | gui/ProfileManager.h 69 | gui/resource.h 70 | gui/utility.cpp 71 | gui/utility.h 72 | ${CMAKE_BINARY_DIR}/gui/version.h 73 | gui/version.h.in 74 | gui/window.cpp 75 | gui/window.h 76 | gui/TextBuffer.cpp 77 | gui/TextBuffer.h 78 | ${resource_src} 79 | ) 80 | 81 | source_group("Resource Files" FILES ${resource_src}) 82 | 83 | add_executable(${PROJECT_NAME} ${ithvnr_src}) 84 | 85 | add_subdirectory(vnr) 86 | # add_subdirectory(profile) 87 | 88 | set_target_properties(${PROJECT_NAME} PROPERTIES 89 | LINK_FLAGS "/SUBSYSTEM:WINDOWS /MANIFESTDEPENDENCY:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"" 90 | ) 91 | 92 | target_compile_definitions(${PROJECT_NAME} 93 | PRIVATE 94 | PSAPI_VERSION=1 95 | DEFAULT_MM 96 | ) 97 | 98 | target_link_libraries(${PROJECT_NAME} 99 | profile 100 | vnrhost 101 | ithsys 102 | ${WDK_HOME}/lib/wxp/i386/ntdll.lib 103 | comctl32.lib 104 | psapi.lib 105 | ) 106 | 107 | target_compile_options(${PROJECT_NAME} 108 | PRIVATE 109 | /EHsc 110 | ) 111 | 112 | install(TARGETS ${PROJECT_NAME} 113 | DESTINATION . 114 | CONFIGURATIONS Release 115 | ) 116 | 117 | configure_file(gui/version.h.in gui/version.h) 118 | -------------------------------------------------------------------------------- /i18n/gui_korean/language.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | #pragma once 18 | 19 | extern const wchar_t* Warning; 20 | //command.cpp 21 | extern const wchar_t* ErrorSyntax; 22 | extern const wchar_t* Usage; 23 | extern const wchar_t* ExtendedUsage; 24 | //inject.cpp 25 | extern const wchar_t* ErrorRemoteThread; 26 | extern const wchar_t* ErrorOpenProcess; 27 | extern const wchar_t* ErrorNoProcess; 28 | extern const wchar_t* SelfAttach; 29 | extern const wchar_t* AlreadyAttach; 30 | extern const wchar_t* FormatInject; 31 | //main.cpp 32 | extern const wchar_t* NotAdmin; 33 | //pipe.cpp 34 | extern const wchar_t* ErrorCreatePipe; 35 | extern const wchar_t* FormatDetach; 36 | extern const wchar_t* ErrorCmdQueueFull; 37 | extern const wchar_t* ErrorNoAttach; 38 | 39 | //profile.cpp 40 | extern const wchar_t* ErrorMonitor; 41 | 42 | //utility.cpp 43 | extern const wchar_t* InitMessage; 44 | extern const wchar_t* BackgroundMsg; 45 | extern const wchar_t* ErrorLinkExist; 46 | extern const wchar_t* ErrorCylicLink; 47 | extern const wchar_t* FormatLink; 48 | extern const wchar_t* ErrorLink; 49 | extern const wchar_t* ErrorDeleteCombo; 50 | 51 | //window.cpp 52 | extern const wchar_t* ClassName; 53 | extern const wchar_t* ClassNameAdmin; 54 | extern const wchar_t* ErrorNotSplit; 55 | extern const wchar_t* ErrorNotModule; 56 | //Main window buttons 57 | extern const wchar_t* ButtonTitleProcess; 58 | extern const wchar_t* ButtonTitleThread; 59 | extern const wchar_t* ButtonTitleHook; 60 | extern const wchar_t* ButtonTitleProfile; 61 | extern const wchar_t* ButtonTitleOption; 62 | extern const wchar_t* ButtonTitleClear; 63 | extern const wchar_t* ButtonTitleSave; 64 | extern const wchar_t* ButtonTitleTop; 65 | //Hook window 66 | extern const wchar_t* SpecialHook; 67 | //Process window 68 | extern const wchar_t* TabTitlePID; 69 | extern const wchar_t* TabTitleMemory; 70 | extern const wchar_t* TabTitleName; 71 | extern const wchar_t* TabTitleTID; 72 | extern const wchar_t* TabTitleStart; 73 | extern const wchar_t* TabTitleModule; 74 | extern const wchar_t* TabTitleState; 75 | extern const wchar_t* SuccessAttach; 76 | extern const wchar_t* FailAttach; 77 | extern const wchar_t* SuccessDetach; 78 | extern const wchar_t* FailDetach; 79 | //Profile window 80 | extern const wchar_t* ProfileExist; 81 | extern const wchar_t* SuccessAddProfile; 82 | extern const wchar_t* FailAddProfile; 83 | extern const wchar_t* TabTitleNumber; 84 | extern const wchar_t* NoFile; 85 | extern const wchar_t* PathDismatch; 86 | extern const wchar_t* SuccessImportProfile; -------------------------------------------------------------------------------- /vnr/ntinspect/ntinspect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // ntinspect.h 4 | // 4/20/2014 jichi 5 | 6 | #include 7 | #ifndef MEMDBG_NO_STL 8 | # include 9 | #endif // MEMDBG_NO_STL 10 | 11 | #ifndef NTINSPECT_BEGIN_NAMESPACE 12 | # define NTINSPECT_BEGIN_NAMESPACE namespace NtInspect { 13 | #endif 14 | #ifndef NTINSPECT_END_NAMESPACE 15 | # define NTINSPECT_END_NAMESPACE } // NtInspect 16 | #endif 17 | 18 | NTINSPECT_BEGIN_NAMESPACE 19 | 20 | // Get the module handle of the current module (not the current process that is GetModuleHandleA(0)) 21 | HMODULE getCurrentModuleHandle(); 22 | 23 | /// Get current module name in fs:0x30 24 | BOOL getProcessName(_Out_ LPWSTR buffer, _In_ int bufferSize); 25 | 26 | /** 27 | * Get the memory range of the module if succeed 28 | * @param moduleName 29 | * @param[out[ lowerBound 30 | * @param[out] upperBound 31 | * @return if succeed 32 | */ 33 | BOOL getModuleMemoryRange(_In_ LPCWSTR moduleName, _Out_ DWORD *lowerBound, _Out_ DWORD *upperBound); 34 | 35 | /// Get memory of the current process module 36 | BOOL getProcessMemoryRange(_Out_ DWORD *lowerBound, _Out_ DWORD *upperBound); 37 | 38 | #ifndef NTINSPECT_NO_STL 39 | /// Iterate module information and return false if abort iteration. 40 | typedef std::function iter_module_fun_t; 41 | #else 42 | typedef bool (* iter_module_fun_t)(HMODULE hModule, LPCWSTR moduleName); 43 | #endif // NTINSPECT_NO_STL 44 | 45 | /** 46 | * Iterate all modules 47 | * @param fun the first parameter is the address of the caller, and the second parameter is the address of the call itself 48 | * @return false if return early, and true if iterate all elements 49 | */ 50 | bool iterModule(const iter_module_fun_t &fun); 51 | 52 | /** 53 | * Return the absolute address of the function imported from the given module 54 | * @param functionName 55 | * @param* hModule find from any module when null 56 | * @return function address or 0 57 | */ 58 | DWORD getModuleExportFunction(HMODULE hModule, LPCSTR functionName); 59 | 60 | inline DWORD getModuleExportFunctionA(LPCSTR moduleName, LPCSTR functionName) 61 | { return getModuleExportFunction(::GetModuleHandleA(moduleName), functionName); } 62 | 63 | inline DWORD getModuleExportFunctionW(LPCWSTR moduleName, LPCSTR functionName) 64 | { return getModuleExportFunction(::GetModuleHandleW(moduleName), functionName); } 65 | 66 | /// Get the function address exported from any module 67 | DWORD getExportFunction(LPCSTR functionName); 68 | 69 | /** 70 | * Get the import address in the specified module 71 | * @param hModule 72 | * @param exportAddress absolute address of the function exported from other modules 73 | * @return function address or 0 74 | */ 75 | DWORD getModuleImportAddress(HMODULE hModule, DWORD exportAddress); 76 | 77 | inline DWORD getModuleImportAddressA(LPCSTR moduleName, DWORD exportAddress) 78 | { return getModuleImportAddress(::GetModuleHandleA(moduleName), exportAddress); } 79 | 80 | inline DWORD getModuleImportAddressW(LPCWSTR moduleName, DWORD exportAddress) 81 | { return getModuleImportAddress(::GetModuleHandleW(moduleName), exportAddress); } 82 | 83 | /// Get the import address in the current executable 84 | inline DWORD getProcessImportAddress(DWORD exportAddress) 85 | { return getModuleImportAddress(::GetModuleHandleA(nullptr), exportAddress); } 86 | 87 | 88 | NTINSPECT_END_NAMESPACE 89 | 90 | // EOF 91 | -------------------------------------------------------------------------------- /vnr/wintimer/wintimer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // wintimer.h 4 | // 6/6/2012 jichi 5 | // 6 | // A light-weighted native windows timer as a replacement of QTimer from Qt. 7 | // Implementation is based on Windows Messaging. A visible parent hwnd is required. 8 | // 9 | // This timer is critical where QTimer or event loop are not available, or need to 10 | // warp to different event loop. Some usage cases follow: 11 | // - Used by texthook as a replacement of QTimer in non-QThread 12 | // - Used by qapplicationloader to implement pseudo event loop 13 | // - Used by winhook to synchronize with window event loop across threads 14 | 15 | #include "wintimer/wintimerbase.h" 16 | #include 17 | 18 | /** 19 | * @brief A light-weighted native windows timer as a replacement of QTimer. 20 | * 21 | * Needed when in a thread where event loop is not accessible. 22 | * Implemented using extensive inlining over pimp, so that the entire class 23 | * could be put on the stack without heap. 24 | * 25 | * Each timer requires an valid visible window's handle to synchronize with. 26 | * Either specify the window handle with the parent window or a global window. 27 | */ 28 | class WinTimer : protected WinTimerBase 29 | { 30 | SK_EXTEND_CLASS(WinTimer, WinTimerBase) 31 | SK_DISABLE_COPY(WinTimer) 32 | 33 | // - Construction - 34 | public: 35 | //typedef std::function function_type; 36 | using Base::function_type; ///< std::function 37 | 38 | /// Default parent window of all timers. 39 | static WId globalWindow() { return Base::globalWindow; } 40 | static void setGlobalWindow(WId winId) { Base::globalWindow = winId; } 41 | 42 | //static WId createHiddenWindow(); 43 | 44 | public: 45 | /// Construct a timer with the parent window handle. 46 | explicit WinTimer(WId parentWindow = 0) { setParentWindow(parentWindow); } 47 | 48 | static void singleShot(int msecs, const function_type &f, WId parent = 0); 49 | 50 | // - Properties - 51 | public: 52 | using Base::isActive; 53 | using Base::isSingleShot; 54 | 55 | void setSingleShot(bool t) { Base::singleShot = t; } 56 | 57 | //bool isEmpty() const { return Base::function.empty(); } 58 | 59 | WId parentWindow() const { return Base::parentWindow; } 60 | void setParentWindow(WId winId) { Base::parentWindow = winId ? winId : Base::globalWindow; } 61 | 62 | int interval() const { return Base::interval; } 63 | void setInterval(int msecs) { Base::interval = msecs; } 64 | 65 | /// Timeout callback when trigger. 66 | void setFunction(const function_type &f) { Base::function = f; } 67 | 68 | /// @overload Set callback to a class method 69 | template 70 | void setMethod(Class *obj, Member mfunc) 71 | { setFunction(boost::bind(mfunc, obj)); } 72 | 73 | /// @overload Set callback to a const class method 74 | template 75 | void setMethod(const Class *obj, Member mfunc) 76 | { setFunction(boost::bind(mfunc, obj)); } 77 | 78 | // - Actions - 79 | public: 80 | /// Start TimerProc 81 | using Base::start; 82 | 83 | /// Stop TimerProc 84 | using Base::stop; 85 | 86 | /// Reset interval and start TimerProc 87 | void start(int interval) { setInterval(interval); start(); } 88 | 89 | /// Invoke the callback. This function is the callback of the underlying TimerProc 90 | using Base::trigger; 91 | }; 92 | 93 | WINTIMER_END_NAMESPACE 94 | -------------------------------------------------------------------------------- /gui/ITHVNR.rc: -------------------------------------------------------------------------------- 1 | // Generated by ResEdit 1.6.5 2 | // Copyright (C) 2006-2015 3 | // http://www.resedit.net 4 | 5 | #include 6 | #include 7 | #include 8 | #include "resource.h" 9 | 10 | 11 | 12 | 13 | // 14 | // Dialog resources 15 | // 16 | LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN 17 | IDD_DIALOG2 DIALOGEX 100, 100, 341, 210 18 | STYLE DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU 19 | CAPTION "Process Explorer" 20 | FONT 8, "MS Shell Dlg", 400, 0, 1 21 | { 22 | DEFPUSHBUTTON "OK", IDOK, 281, 189, 53, 14, 0, WS_EX_LEFT 23 | PUSHBUTTON "Remove Profile", IDC_BUTTON6, 226, 189, 53, 14, 0, WS_EX_LEFT 24 | CONTROL "", IDC_LIST1, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 7, 20, 327, 164, WS_EX_LEFT 25 | LTEXT "Process", IDC_STATIC, 7, 7, 65, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT 26 | PUSHBUTTON "Attach", IDC_BUTTON2, 61, 189, 53, 14, 0, WS_EX_LEFT 27 | PUSHBUTTON "Detach", IDC_BUTTON3, 116, 189, 53, 14, 0, WS_EX_LEFT 28 | PUSHBUTTON "Add Profile", IDC_BUTTON5, 171, 189, 53, 14, 0, WS_EX_LEFT 29 | PUSHBUTTON "Refresh", IDC_BUTTON1, 7, 189, 53, 14, 0, WS_EX_LEFT 30 | } 31 | 32 | 33 | 34 | LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN 35 | IDD_DIALOG4 DIALOGEX 150, 100, 123, 185 36 | STYLE DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU 37 | CAPTION "Option" 38 | FONT 8, "MS Shell Dlg", 400, 0, 1 39 | { 40 | DEFPUSHBUTTON "OK", IDOK, 8, 164, 50, 14, 0, WS_EX_LEFT 41 | PUSHBUTTON "Cancel", IDCANCEL, 65, 164, 50, 14, 0, WS_EX_LEFT 42 | EDITTEXT IDC_EDIT1, 60, 7, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT 43 | LTEXT "Split time", IDC_STATIC, 7, 7, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT 44 | EDITTEXT IDC_EDIT2, 60, 25, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT 45 | LTEXT "Process delay", IDC_STATIC, 7, 26, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT 46 | EDITTEXT IDC_EDIT3, 60, 45, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT 47 | LTEXT "Inject delay", IDC_STATIC, 7, 45, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT 48 | EDITTEXT IDC_EDIT4, 60, 65, 55, 14, ES_AUTOHSCROLL, WS_EX_LEFT 49 | LTEXT "Insert delay", IDC_STATIC, 7, 65, 47, 13, SS_LEFT | SS_CENTERIMAGE, WS_EX_LEFT 50 | AUTOCHECKBOX "Auto attach", IDC_CHECK1, 7, 87, 54, 10, 0, WS_EX_LEFT 51 | AUTOCHECKBOX "Auto insert", IDC_CHECK2, 62, 87, 50, 10, 0, WS_EX_LEFT 52 | AUTOCHECKBOX "Auto copy to clipboard", IDC_CHECK3, 7, 103, 88, 10, 0, WS_EX_LEFT 53 | AUTOCHECKBOX "Auto suppress repetition", IDC_CHECK4, 7, 119, 95, 10, 0, WS_EX_LEFT 54 | AUTOCHECKBOX "Reset character filter", IDC_CHECK6, 7, 149, 81, 8, 0, WS_EX_LEFT 55 | AUTOCHECKBOX "Enable global filter", IDC_CHECK5, 7, 134, 75, 10, 0, WS_EX_LEFT 56 | } 57 | 58 | 59 | 60 | // 61 | // Icon resources 62 | // 63 | LANGUAGE LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN 64 | IDI_ICON1 ICON "icon1.ico" 65 | 66 | 67 | 68 | // 69 | // Version Information resources 70 | // 71 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 72 | 1 VERSIONINFO 73 | FILEVERSION 0,0,0,0 74 | PRODUCTVERSION 0,0,0,0 75 | FILEOS VOS_UNKNOWN 76 | FILETYPE VFT_UNKNOWN 77 | FILESUBTYPE VFT2_UNKNOWN 78 | FILEFLAGSMASK 0 79 | FILEFLAGS 0 80 | { 81 | 82 | } 83 | -------------------------------------------------------------------------------- /vnr/texthook/texthook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // texthook.h 4 | // 10/14/2011 jichi 5 | 6 | #include "texthook_config.h" 7 | #include "sakurakit/skglobal.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include // for WId 13 | 14 | class TextHookPrivate; 15 | /// Singleton class. Only one instance is allowed. 16 | class TEXTHOOK_EXPORT TextHook : public QObject 17 | { 18 | Q_OBJECT 19 | Q_DISABLE_COPY(TextHook) 20 | SK_EXTEND_CLASS(TextHook, QObject) 21 | SK_DECLARE_PRIVATE(TextHookPrivate) 22 | 23 | // - Construction - 24 | public: 25 | explicit TextHook(QObject *parent = nullptr); 26 | ~TextHook(); 27 | 28 | signals: 29 | void dataReceived(QByteArray raw, QByteArray rendered, qint32 signature, QString source); 30 | void processAttached(qint64 pid); 31 | void processDetached(qint64 pid); 32 | 33 | // - Properties - 34 | public: 35 | /// Limited by ITH 36 | int capacity() const; 37 | 38 | bool isEnabled() const; 39 | void setEnabled(bool t); 40 | 41 | WId parentWinId() const; ///< Must be set to a valid window so that ::SetTimer works 42 | void setParentWinId(WId hwnd); 43 | 44 | int interval() const; ///< Time to differentiate sentences 45 | void setInterval(int msecs); 46 | 47 | int dataCapacity() const; ///< Maximum text length 48 | void setDataCapacity(int value); 49 | 50 | bool removesRepeat() const; 51 | void setRemovesRepeat(bool value); 52 | 53 | bool keepsSpace() const; 54 | void setKeepsSpace(bool value); 55 | 56 | bool wideCharacter() const; 57 | void setWideCharacter(bool value); 58 | 59 | QString defaultHookName() const; ///< The default one is "H-code" 60 | void setDefaultHookName(const QString &name); 61 | 62 | bool isActive() const; 63 | void start(); 64 | void stop(); 65 | void clear(); 66 | 67 | // - Injection - 68 | public: 69 | //bool attachOneProcess(ulong pid, bool checkActive = false); 70 | bool attachProcess(ulong pid, bool checkActive = false); 71 | bool detachProcess(ulong pid, bool checkActive = false); 72 | bool hijackProcess(ulong pid); 73 | //void detachAllProcesses(); 74 | //QList attachedProcesses(bool checkActive = false) const; 75 | //ulong anyAttachedProcess(bool checkActive = false) const; 76 | //ulong currentProccess() const; 77 | 78 | bool containsProcess(ulong pid) const; 79 | bool isEmpty() const; ///< Return true if at least one process is attached 80 | 81 | bool addHookCode(ulong pid, const QString &code, const QString &name = QString(), bool verbose = true); 82 | static bool verifyHookCode(const QString &code); ///< Return if hcode is valid 83 | //bool containsHook(ulong pid) const; 84 | //bool containsHook(ulong pid, const QString &code) const; 85 | //QString processHook(ulong pid) const; 86 | //QString currentHook() const { return processHook(currentProccess()); } 87 | bool removeHookCode(ulong pid); ///< Assume atmost one hcode per process 88 | 89 | // - Whitelist - 90 | public: 91 | bool isThreadWhitelistEnabled() const; 92 | void setThreadWhitelistEnabled(bool t); 93 | QList threadWhitelist() const; 94 | void setThreadWhitelist(const QList &signatures); 95 | void clearThreadWhitelist(); 96 | // Note: len(v) must be smaller than 0x200 97 | void setKeptThreadName(const QString &v); 98 | QString keptThreadName() const; 99 | }; 100 | 101 | // EOF 102 | -------------------------------------------------------------------------------- /vnr/vnrhook/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # # hook.pro 2 | # # Exception handler to catch all exceptions 3 | # CONFIG += dll noqt eh eha # noeh nosafeseh 4 | 5 | # DEFINES += ITH_HAS_CRT ITH_HAS_SEH 6 | # DEFINES += MEMDBG_NO_STL NTINSPECT_NO_STL # disabled as not used 7 | 8 | # # jichi 11/13/2011: disable swprinf warning 9 | # DEFINES += _CRT_NON_CONFORMING_SWPRINTFS 10 | 11 | # config.pri 12 | # CONFIG(eha) { 13 | # message(CONFIG eha) 14 | # QMAKE_CXXFLAGS_STL_ON -= /EHsc 15 | # QMAKE_CXXFLAGS_EXCEPTIONS_ON -= /EHsc 16 | # QMAKE_CXXFLAGS_STL_ON += /EHa 17 | # QMAKE_CXXFLAGS_EXCEPTIONS_ON += /EHa 18 | # } 19 | 20 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 21 | 22 | set(vnrhook_src 23 | include/const.h 24 | include/defs.h 25 | include/types.h 26 | src/except.h 27 | src/main.cc 28 | src/main.h 29 | src/pipe.cc 30 | src/engine/engine.cc 31 | src/engine/engine.h 32 | src/engine/hookdefs.h 33 | src/engine/match.cc 34 | src/engine/match.h 35 | src/engine/pchooks.cc 36 | src/engine/pchooks.h 37 | src/engine/mono/funcinfo.h 38 | src/engine/mono/types.h 39 | src/engine/ppsspp/funcinfo.h 40 | src/hijack/texthook.cc 41 | src/hijack/texthook.h 42 | src/tree/avl.h 43 | src/util/growl.h 44 | src/util/util.cc 45 | src/util/util.h 46 | ${PROJECT_SOURCE_DIR}/ccutil/ccmacro.h 47 | ${PROJECT_SOURCE_DIR}/cpputil/cpplocale.h 48 | ${PROJECT_SOURCE_DIR}/cpputil/cppmarshal.h 49 | ${PROJECT_SOURCE_DIR}/cpputil/cppmath.h 50 | ${PROJECT_SOURCE_DIR}/cpputil/cpppath.h 51 | ${PROJECT_SOURCE_DIR}/cpputil/cppstring.h 52 | ${PROJECT_SOURCE_DIR}/cpputil/cpptype.h 53 | ${PROJECT_SOURCE_DIR}/cpputil/cppunicode.h 54 | ${PROJECT_SOURCE_DIR}/disasm/disasm.cc 55 | ${PROJECT_SOURCE_DIR}/hashutil/hashstr.h 56 | ${PROJECT_SOURCE_DIR}/hashutil/hashutil.h 57 | ${PROJECT_SOURCE_DIR}/memdbg/memdbg.h 58 | ${PROJECT_SOURCE_DIR}/memdbg/memsearch.cc 59 | ${PROJECT_SOURCE_DIR}/memdbg/memsearch.h 60 | ${PROJECT_SOURCE_DIR}/ntinspect/ntinspect.cc 61 | ${PROJECT_SOURCE_DIR}/ntinspect/ntinspect.h 62 | ${PROJECT_SOURCE_DIR}/winkey/winkey.h 63 | ${PROJECT_SOURCE_DIR}/winversion/winversion.cc 64 | ${PROJECT_SOURCE_DIR}/winversion/winversion.h 65 | ${PROJECT_SOURCE_DIR}/winseh/winseh.h 66 | ${PROJECT_SOURCE_DIR}/winseh/winseh.cc 67 | ${PROJECT_SOURCE_DIR}/winseh/winseh_safe.cc 68 | ${PROJECT_SOURCE_DIR}/winseh/safeseh.asm 69 | ${PROJECT_SOURCE_DIR}/mono/monoobject.h 70 | ${PROJECT_SOURCE_DIR}/mono/monotype.h 71 | ) 72 | 73 | add_library(vnrhook SHARED ${vnrhook_src}) 74 | 75 | enable_language(ASM_MASM) 76 | 77 | set_source_files_properties( 78 | ${PROJECT_SOURCE_DIR}/winseh/safeseh.asm 79 | PROPERTIES 80 | # CMAKE_ASM_MASM_FLAGS /safeseh # CMake bug 14711: http://www.cmake.org/Bug/view.php?id=14711 81 | COMPILE_FLAGS /safeseh 82 | ) 83 | 84 | set_target_properties(vnrhook PROPERTIES 85 | LINK_FLAGS "/SUBSYSTEM:WINDOWS /MANIFEST:NO" 86 | ) 87 | 88 | target_compile_options(vnrhook PRIVATE 89 | /EHa 90 | $<$:> 91 | $<$:> 92 | ) 93 | 94 | set(vnrhook_libs 95 | ithsys 96 | ${WDK_HOME}/lib/wxp/i386/ntdll.lib 97 | Version.lib 98 | ) 99 | 100 | target_link_libraries(vnrhook ${vnrhook_libs}) 101 | 102 | target_compile_definitions(vnrhook 103 | PRIVATE 104 | ITH_HAS_CRT 105 | ITH_HAS_SEH 106 | _CRT_NON_CONFORMING_SWPRINTFS 107 | ) 108 | 109 | install(TARGETS vnrhook RUNTIME 110 | DESTINATION . 111 | CONFIGURATIONS Release 112 | ) 113 | -------------------------------------------------------------------------------- /vnr/cpputil/cppmarshal.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPMARSHAL_H 2 | #define CPPMARSHAL_H 3 | 4 | // cppmarshal.h 5 | // 10/12/2014 jichi 6 | // 7 | // Functions are by default big-endian, the same as memory layout. 8 | #include "cpputil/cppcstring.h" 9 | #include "cpputil/cpptype.h" 10 | #include 11 | 12 | /* Read */ 13 | 14 | // Read number 15 | 16 | template 17 | inline const byteT *cpp_marshal_getval(const byteT *p, valT *v) 18 | { *v = *reinterpret_cast(p); return p + sizeof(valT); } 19 | 20 | // Read pointer 21 | 22 | template \ 23 | inline const byteT *cpp_marshal_getptr(const byteT *p, ptrT v) 24 | { return cpp_marshal_getval(p, reinterpret_cast(v)); } 25 | 26 | // Read string 27 | 28 | template 29 | inline const byteT *cpp_marshal_getstr(const byteT *p, charT *s) 30 | { 31 | size_t n = cpp_basic_strlen(p); 32 | ::memcpy(s, p, n + 1); // including '\0' 33 | return p + n + 1; 34 | } 35 | 36 | template 37 | inline const byteT *cpp_marshal_getnstr(const byteT *p, charT *s, size_t n) 38 | { 39 | if (n = cpp_basic_strnlen(p, n)) 40 | ::memcpy(s, p, n); // including '\0' 41 | s[n] = 0; 42 | return p + n + 1; 43 | } 44 | 45 | /* Write */ 46 | 47 | // Write number 48 | 49 | template 50 | inline byteT *cpp_marshal_putval(byteT *p, valT v) 51 | { *reinterpret_cast(p) = v; return p + sizeof(valT); } 52 | 53 | // Write pointer 54 | 55 | template \ 56 | inline byteT *cpp_marshal_putptr(byteT *p, ptrT v) 57 | { return cpp_marshal_putval(p, reinterpret_cast(v)); } 58 | 59 | // Write string 60 | 61 | template 62 | inline byteT *cpp_marshal_putstr(byteT *p, charT *s) 63 | { 64 | size_t n = cpp_basic_strlen(s); 65 | ::memcpy(p, s, n + 1); // including '\0' 66 | return p + n + 1; 67 | } 68 | 69 | template 70 | inline byteT *cpp_marshal_putstr(byteT *p, charT *s, size_t n) 71 | { 72 | if (n = cpp_basic_strnlen(s, n)) 73 | ::memcpy(p, s, n); // including '\0' 74 | s[n] = 0; 75 | return p + n + 1; 76 | } 77 | 78 | /* Expansion */ 79 | 80 | #define CPP_DECLARE_MARSHAL_GETVAL(type) \ 81 | template \ 82 | inline const byteT *cpp_marshal_get##type(const byteT *p, cpp_##type *v) { return cpp_marshal_getval(p, v); } 83 | 84 | #define CPP_DECLARE_MARSHAL_PUTVAL(type) \ 85 | template \ 86 | inline byteT *cpp_marshal_put##type(byteT *p, cpp_##type v) { return cpp_marshal_putval(p, v); } 87 | 88 | CPP_DECLARE_MARSHAL_PUTVAL(float) 89 | CPP_DECLARE_MARSHAL_PUTVAL(double) 90 | CPP_DECLARE_MARSHAL_GETVAL(float) 91 | CPP_DECLARE_MARSHAL_GETVAL(double) 92 | CPP_DECLARE_MARSHAL_GETVAL(int) 93 | CPP_DECLARE_MARSHAL_GETVAL(int8) 94 | CPP_DECLARE_MARSHAL_GETVAL(int32) 95 | CPP_DECLARE_MARSHAL_GETVAL(int64) 96 | CPP_DECLARE_MARSHAL_GETVAL(uint) 97 | CPP_DECLARE_MARSHAL_GETVAL(uint8) 98 | CPP_DECLARE_MARSHAL_GETVAL(uint32) 99 | CPP_DECLARE_MARSHAL_GETVAL(uint64) 100 | 101 | CPP_DECLARE_MARSHAL_PUTVAL(int) 102 | CPP_DECLARE_MARSHAL_PUTVAL(int8) 103 | CPP_DECLARE_MARSHAL_PUTVAL(int32) 104 | CPP_DECLARE_MARSHAL_PUTVAL(int64) 105 | CPP_DECLARE_MARSHAL_PUTVAL(uint) 106 | CPP_DECLARE_MARSHAL_PUTVAL(uint8) 107 | CPP_DECLARE_MARSHAL_PUTVAL(uint32) 108 | CPP_DECLARE_MARSHAL_PUTVAL(uint64) 109 | 110 | #endif // CPPMARSHAL_H 111 | -------------------------------------------------------------------------------- /vnr/windbg/hijack.cc: -------------------------------------------------------------------------------- 1 | // hijack.cc 2 | // 1/27/2013 jichi 3 | #include "windbg/hijack.h" 4 | #include "windbg/windbg_p.h" 5 | 6 | #ifdef _MSC_VER 7 | # pragma warning (disable:4996) // C4996: use POSIX function (stricmp) 8 | #endif // _MSC_VER 9 | 10 | //#define DEBUG "winsec" 11 | #include "sakurakit/skdebug.h" 12 | 13 | WINDBG_BEGIN_NAMESPACE 14 | 15 | // - Inline Hook - 16 | // See: http://asdf.wkeya.com/code/apihook6.html 17 | PVOID overrideFunctionA(HMODULE stealFrom, LPCSTR oldFunctionModule, LPCSTR functionName, LPCVOID newFunction) 18 | { 19 | if (!stealFrom) 20 | return nullptr; 21 | //HMODULE oldModule = GetModuleHandleA(oldFunctionModule); 22 | //if (!oldModule) 23 | // return nullptr; 24 | //void *originalAddress = GetProcAddress(oldModule, functionName); 25 | LPVOID originalAddress = details::getModuleFunctionAddressA(functionName, oldFunctionModule); 26 | if (!originalAddress) 27 | return nullptr; 28 | IMAGE_DOS_HEADER *dosHeader = reinterpret_cast(stealFrom); 29 | char *base = reinterpret_cast(stealFrom); 30 | if (::IsBadReadPtr(dosHeader, sizeof(IMAGE_DOS_HEADER)) || dosHeader->e_magic != IMAGE_DOS_SIGNATURE) 31 | return nullptr; 32 | IMAGE_NT_HEADERS *ntHeader = 33 | reinterpret_cast(base + dosHeader->e_lfanew); 34 | if (::IsBadReadPtr(ntHeader, sizeof(IMAGE_NT_HEADERS)) || ntHeader->Signature != IMAGE_NT_SIGNATURE) 35 | return nullptr; 36 | if (!ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress) 37 | return nullptr; 38 | // See: http://msdn.microsoft.com/en-us/magazine/cc301808.aspx 39 | IMAGE_IMPORT_DESCRIPTOR *import = 40 | reinterpret_cast(base + ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); 41 | 42 | // scan memory 43 | // TODO: add a maximum loop counter here! 44 | while (import->Name) { 45 | char *name = base + import->Name; 46 | if (!::stricmp(name, oldFunctionModule)) 47 | break; 48 | import++; 49 | } 50 | if (!import->Name) 51 | return nullptr; 52 | IMAGE_THUNK_DATA *thunk = reinterpret_cast(base + import->FirstThunk); 53 | while (thunk->u1.Function) { 54 | if ((ULONG_PTR)thunk->u1.Function == (ULONG_PTR)originalAddress) { 55 | ULONG_PTR *addr = reinterpret_cast(&thunk->u1.Function); 56 | 57 | // See: http://asdf.wkeya.com/code/apihook6.html 58 | // Inline hook mechanism: 59 | // 60 | // LPVOID InlineHook3( PUINT8 mem, DWORD dwLen, PUINT8 pfOld, PUINT8 pfNew ) 61 | // { 62 | // DWORD dwOldProtect; 63 | // VirtualProtect( ( PUINT8 )( pfOld ), dwLen, PAGE_READWRITE, &dwOldProtect ); 64 | // // 関数のエントリーから指定したbyte数をメモリの前方にコピー 65 | // // メモリの数byte後方からオリジナルへのジャンプを作成 66 | // // 指定の関数アドレスから5byteをフックへのjmp命令に書き換え 67 | // VirtualProtect( ( PUINT8 )( pfOld ), dwLen, dwOldProtect, &dwOldProtect ); 68 | // return ( PVOID )mem; 69 | // } 70 | 71 | MEMORY_BASIC_INFORMATION mbi; 72 | if (::VirtualQuery((LPVOID)addr, &mbi, sizeof(mbi)) == sizeof(mbi)) { 73 | DWORD dwOldProtect; 74 | if (::VirtualProtect(mbi.BaseAddress, ((ULONG_PTR)addr + 8)-(ULONG_PTR)mbi.BaseAddress, PAGE_EXECUTE_READWRITE, &dwOldProtect)) { 75 | *addr = (ULONG_PTR)newFunction; 76 | ::VirtualProtect(mbi.BaseAddress, ((ULONG_PTR)addr + 8)-(ULONG_PTR)mbi.BaseAddress, dwOldProtect, &dwOldProtect); 77 | return originalAddress; 78 | } 79 | } 80 | 81 | } 82 | thunk++; 83 | } 84 | return nullptr; 85 | } 86 | 87 | WINDBG_END_NAMESPACE 88 | 89 | // EOF 90 | -------------------------------------------------------------------------------- /vnr/texthook/host/textthread_p.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // textthread_p.h 3 | // 8/14/2013 jichi 4 | // Branch: ITH/main_template.h, rev 66 5 | 6 | #include 7 | 8 | template 9 | void Release(const T &p) { delete p; } 10 | 11 | // Prevent memory release. 12 | // Used when T is basic types and will be automatically released (on stack). 13 | #define MK_BASIC_TYPE(T) \ 14 | template<> \ 15 | void Release(const T &p) {} 16 | 17 | template 18 | struct BinaryEqual { 19 | bool operator ()(const T &a, const T &b, DWORD) { return a == b; } 20 | }; 21 | 22 | template > 23 | class MyVector 24 | { 25 | public: 26 | MyVector() : size(default_size), used(0) 27 | { 28 | InitializeCriticalSection(&cs_store); 29 | storage = new T[size]; 30 | // jichi 9/21/2013: zero memory 31 | // This would cause trouble if T is not an atomic type 32 | ::memset(storage, 0, sizeof(T) * size); 33 | } 34 | 35 | virtual ~MyVector() 36 | { 37 | if (storage) 38 | delete[] storage; 39 | DeleteCriticalSection(&cs_store); 40 | storage = 0; 41 | } 42 | 43 | void Reset() 44 | { 45 | EnterCriticalSection(&cs_store); 46 | for (int i = 0; i < used; i++) { 47 | Release(storage[i]); 48 | storage[i] = T(); 49 | } 50 | used = 0; 51 | LeaveCriticalSection(&cs_store); 52 | } 53 | void Remove(int index) 54 | { 55 | if (index>=used) 56 | return; 57 | Release(storage[index]); 58 | for (int i = index; i < used; i++) 59 | storage[i] = storage[i+1]; 60 | used--; 61 | } 62 | void ClearMemory(int offset, int clear_size) 63 | { 64 | if (clear_size < 0) 65 | return; 66 | EnterCriticalSection(&cs_store); 67 | if (offset+clear_size <= size) 68 | ::memset(storage+offset, 0, clear_size * sizeof(T)); // jichi 11/30/2013: This is the original code of ITH 69 | LeaveCriticalSection(&cs_store); 70 | //else __asm int 3 71 | } 72 | int AddToStore(T *con,int amount) 73 | { 74 | if (amount <= 0 || con == 0) 75 | return 0; 76 | int status = 0; 77 | EnterCriticalSection(&cs_store); 78 | if (amount + used + 2 >= size) { 79 | while (amount + used + 2 >= size) 80 | size<<=1; 81 | T *temp; 82 | if (size * sizeof(T) < 0x1000000) { 83 | temp = new T[size]; 84 | if (size > used) 85 | ::memset(temp, 0, (size - used) * sizeof(T)); // jichi 9/25/2013: zero memory 86 | memcpy(temp, storage, used * sizeof(T)); 87 | } else { 88 | size = default_size; 89 | temp = new T[size]; 90 | ::memset(temp, 0, sizeof(T) * size); // jichi 9/25/2013: zero memory 91 | used = 0; 92 | status = 1; 93 | } 94 | delete[] storage; 95 | storage = temp; 96 | } 97 | memcpy(storage+used, con, amount * sizeof(T)); 98 | used += amount; 99 | LeaveCriticalSection(&cs_store); 100 | return status; 101 | } 102 | int Find(const T &item, int start = 0, DWORD control = 0) 103 | { 104 | int c = -1; 105 | for (int i=start; i < used; i++) 106 | if (fCmp(storage[i],item,control)) { 107 | c=i; 108 | break; 109 | } 110 | //if (storage[i]==item) {c=i;break;} 111 | return c; 112 | } 113 | int Used() const { return used; } 114 | T *Storage() const { return storage; } 115 | void LockVector() { EnterCriticalSection(&cs_store); } 116 | void UnlockVector() { LeaveCriticalSection(&cs_store); } 117 | protected: 118 | CRITICAL_SECTION cs_store; 119 | int size, 120 | used; 121 | T *storage; 122 | fComp fCmp; 123 | }; 124 | 125 | // EOF 126 | 127 | /* 128 | #ifndef ITH_STACK 129 | #define ITH_STACK 130 | template 131 | class MyStack 132 | { 133 | public: 134 | MyStack(): index(0) {} 135 | void push_back(const T& e) 136 | { 137 | if (index 9 | #include 10 | #include 11 | #include // for WId 12 | 13 | //struct Settings; // opaque in ith/host/settings.h 14 | class HookManager; // opaque in ith/host/hookman.h 15 | class TextThread; // opaque in ith/host/textthread.h 16 | class TextThreadDelegate; 17 | 18 | enum { ITH_THREAD_NAME_CAPACITY = 0x200 }; // used internally by ITH 19 | 20 | class Ihf 21 | { 22 | Ihf() {} // Singleton 23 | 24 | static bool enabled_; 25 | 26 | //static Settings *settings_; 27 | static HookManager *hookManager_; 28 | static qint64 messageInterval_; 29 | static WId parentWindow_; 30 | 31 | static QHash threadDelegates_; 32 | //static QHash linkedDelegates_; 33 | static QHash hookAddresses_; 34 | 35 | enum { WhitelistSize = 0x20 + 1 }; // ITH capacity is 0x20 36 | static qint32 whitelist_[WhitelistSize]; // List of signatures. The last element is zero. I.e., at most BlackSize-1 threads. 37 | static bool whitelistEnabled_; 38 | static char keptThreadName_[ITH_THREAD_NAME_CAPACITY]; 39 | //static QString userDefinedThreadName_; 40 | 41 | public: 42 | 43 | // - Initialization - 44 | static void init(); 45 | static void destroy(); 46 | 47 | static bool load(); 48 | static bool isLoaded() { return hookManager_; } 49 | static void unload(); 50 | 51 | // - Properties - 52 | 53 | static bool isEnabled() { return enabled_; } 54 | static void setEnabled(bool t) { enabled_ = t; } 55 | 56 | /// A valid window handle is required to make ITH work 57 | static WId parentWindow() { return parentWindow_; } 58 | static void setParentWindow(WId hwnd) { parentWindow_ = hwnd; } 59 | 60 | /// Timeout (msecs) for a text message 61 | static qint64 messageInterval() { return messageInterval_; } 62 | static void setMessageInterval(qint64 msecs) { messageInterval_ = msecs; } 63 | 64 | // - Injection - 65 | static bool attachProcess(ulong pid); 66 | static bool detachProcess(ulong pid); 67 | static bool hijackProcess(ulong pid); 68 | 69 | /// Add hook code 70 | static bool addHook(ulong pid, const QString &code, const QString &name = QString(), bool verbose = true); 71 | static bool updateHook(ulong pid, const QString &code); // not used 72 | static bool removeHook(ulong pid, const QString &code); 73 | static bool verifyHookCode(const QString &code); 74 | 75 | // - Whitelist - 76 | static bool isWhitelistEnabled() { return whitelistEnabled_; } 77 | static void setWhitelistEnabled(bool t) { whitelistEnabled_ = t; } 78 | 79 | static QList whitelist(); 80 | static void setWhitelist(const QList &l); 81 | static void clearWhitelist(); 82 | 83 | //static QString userDefinedThreadName() { return userDefinedThreadName_; } 84 | //static void setUserDefinedThreadName(const QString &val) { userDefinedThreadName_ = val; } 85 | static const char *keptThreadName() { return keptThreadName_; } 86 | 87 | static void setKeptThreadName(const QString &v) 88 | { 89 | if (v.size() < ITH_THREAD_NAME_CAPACITY) 90 | ::strcpy(keptThreadName_, v.toAscii()); 91 | else 92 | setKeptThreadName(v.left(ITH_THREAD_NAME_CAPACITY - 1)); 93 | } 94 | 95 | private: 96 | static bool whitelistContains(qint32 signature); 97 | 98 | // - Callbacks - 99 | //static ulong processAttach(ulong pid); 100 | //static ulong processDetach(ulong pid); 101 | //static ulong processNewHook(ulong pid); 102 | 103 | static ulong threadCreate(_In_ TextThread *t); 104 | static ulong threadRemove(_In_ TextThread *t); 105 | static ulong threadOutput(_In_ TextThread *t, _In_ uchar *data, _In_ ulong dataLength, _In_ ulong bNewLine, _In_ void *pUserData, _In_ bool space); 106 | //static ulong threadFilter(_In_ TextThread *t, _Out_ uchar *data, _In_ ulong dataLength, _In_ ulong bNewLine, _In_ void *pUserData); 107 | //static ulong threadReset(TextThread *t); 108 | //static void consoleOutput(const char *text); 109 | //static void consoleOutputW(const wchar_t *text); 110 | 111 | // - Linked threasds - 112 | private: 113 | //static TextThreadDelegate *findLinkedDelegate(TextThreadDelegate *d); 114 | static void updateLinkedDelegate(TextThreadDelegate *d); 115 | }; 116 | 117 | // EOF 118 | -------------------------------------------------------------------------------- /gui/ProcessWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "ProcessWindow.h" 2 | #include "resource.h" 3 | #include "host/host.h" 4 | #include "host/hookman.h" 5 | #include "ProfileManager.h" 6 | #include "profile/Profile.h" 7 | 8 | extern HookManager* man; // main.cpp 9 | extern ProfileManager* pfman; // ProfileManager.cpp 10 | 11 | ProcessWindow::ProcessWindow(HWND hDialog) : hDlg(hDialog) 12 | { 13 | hbRefresh = GetDlgItem(hDlg, IDC_BUTTON1); 14 | hbAttach = GetDlgItem(hDlg, IDC_BUTTON2); 15 | hbDetach = GetDlgItem(hDlg, IDC_BUTTON3); 16 | hbAddProfile = GetDlgItem(hDlg, IDC_BUTTON5); 17 | hbRemoveProfile = GetDlgItem(hDlg, IDC_BUTTON6); 18 | EnableWindow(hbAddProfile, FALSE); 19 | EnableWindow(hbRemoveProfile, FALSE); 20 | hlProcess = GetDlgItem(hDlg, IDC_LIST1); 21 | heOutput = GetDlgItem(hDlg, IDC_EDIT1); 22 | ListView_SetExtendedListViewStyleEx(hlProcess, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); 23 | InitProcessDlg(); 24 | RefreshProcess(); 25 | EnableWindow(hbDetach, FALSE); 26 | EnableWindow(hbAttach, FALSE); 27 | } 28 | 29 | void ProcessWindow::InitProcessDlg() 30 | { 31 | LVCOLUMN lvc = {}; 32 | lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; 33 | lvc.fmt = LVCFMT_RIGHT; // left-aligned column 34 | lvc.cx = 40; 35 | lvc.pszText = L"PID"; 36 | ListView_InsertColumn(hlProcess, 0, &lvc); 37 | lvc.cx = 100; 38 | lvc.fmt = LVCFMT_LEFT; // left-aligned column 39 | lvc.pszText = L"Name"; 40 | ListView_InsertColumn(hlProcess, 1, &lvc); 41 | } 42 | 43 | void ProcessWindow::RefreshProcess() 44 | { 45 | ListView_DeleteAllItems(hlProcess); 46 | LVITEM item = {}; 47 | item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; 48 | DWORD idProcess[1024], cbNeeded; 49 | WCHAR path[MAX_PATH]; 50 | 51 | if (EnumProcesses(idProcess, sizeof(idProcess), &cbNeeded)) 52 | { 53 | DWORD len = cbNeeded / sizeof(DWORD); 54 | for (DWORD i = 0; i < len; ++i) 55 | { 56 | DWORD pid = idProcess[i]; 57 | UniqueHandle hProcess(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); 58 | if (hProcess) 59 | { 60 | if (GetProcessImageFileName(hProcess.get(), path, MAX_PATH)) 61 | { 62 | WCHAR buffer[256]; 63 | std::swprintf(buffer, L"%d", pid); 64 | PWCHAR name = wcsrchr(path, L'\\') + 1; 65 | item.pszText = buffer; 66 | item.lParam = pid; 67 | ListView_InsertItem(hlProcess, &item); 68 | ListView_SetItemText(hlProcess, item.iItem, 1, name); 69 | } 70 | } 71 | } 72 | } 73 | } 74 | 75 | void ProcessWindow::AttachProcess() 76 | { 77 | DWORD pid = GetSelectedPID(); 78 | if (Host_InjectByPID(pid)) 79 | { 80 | Host_HijackProcess(pid); 81 | RefreshThreadWithPID(pid, true); 82 | } 83 | } 84 | 85 | void ProcessWindow::DetachProcess() 86 | { 87 | DWORD pid = GetSelectedPID(); 88 | if (Host_ActiveDetachProcess(pid) == 0) 89 | RefreshThreadWithPID(pid, false); 90 | } 91 | 92 | void ProcessWindow::CreateProfileForSelectedProcess() 93 | { 94 | DWORD pid = GetSelectedPID(); 95 | auto path = GetProcessPath(pid); 96 | if (!path.empty()) 97 | { 98 | Profile* pf = pfman->CreateProfile(pid); 99 | pfman->SaveProfiles(); 100 | RefreshThread(ListView_GetSelectionMark(hlProcess)); 101 | } 102 | } 103 | 104 | void ProcessWindow::DeleteProfileForSelectedProcess() 105 | { 106 | DWORD pid = GetSelectedPID(); 107 | auto path = GetProcessPath(pid); 108 | if (!path.empty()) 109 | { 110 | pfman->DeleteProfile(path); 111 | RefreshThread(ListView_GetSelectionMark(hlProcess)); 112 | } 113 | } 114 | 115 | void ProcessWindow::RefreshThread(int index) 116 | { 117 | LVITEM item = {}; 118 | item.mask = LVIF_PARAM; 119 | item.iItem = index; 120 | ListView_GetItem(hlProcess, &item); 121 | DWORD pid = item.lParam; 122 | bool isAttached = man->GetProcessRecord(pid) != NULL; 123 | RefreshThreadWithPID(pid, isAttached); 124 | } 125 | 126 | void ProcessWindow::RefreshThreadWithPID(DWORD pid, bool isAttached) 127 | { 128 | EnableWindow(hbDetach, isAttached); 129 | EnableWindow(hbAttach, !isAttached); 130 | auto path = GetProcessPath(pid); 131 | bool hasProfile = !path.empty() && pfman->HasProfile(path); 132 | EnableWindow(hbAddProfile, isAttached && !hasProfile); 133 | EnableWindow(hbRemoveProfile, hasProfile); 134 | if (pid == GetCurrentProcessId()) 135 | EnableWindow(hbAttach, FALSE); 136 | } 137 | 138 | DWORD ProcessWindow::GetSelectedPID() 139 | { 140 | LVITEM item = {}; 141 | item.mask = LVIF_PARAM; 142 | item.iItem = ListView_GetSelectionMark(hlProcess); 143 | ListView_GetItem(hlProcess, &item); 144 | return item.lParam; 145 | } 146 | -------------------------------------------------------------------------------- /i18n/gui_korean/ProcessWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "ProcessWindow.h" 2 | #include "resource.h" 3 | #include "host/host.h" 4 | #include "host/hookman.h" 5 | #include "ProfileManager.h" 6 | #include "profile/Profile.h" 7 | 8 | extern HookManager* man; // main.cpp 9 | extern ProfileManager* pfman; // ProfileManager.cpp 10 | 11 | ProcessWindow::ProcessWindow(HWND hDialog) : hDlg(hDialog) 12 | { 13 | hbRefresh = GetDlgItem(hDlg, IDC_BUTTON1); 14 | hbAttach = GetDlgItem(hDlg, IDC_BUTTON2); 15 | hbDetach = GetDlgItem(hDlg, IDC_BUTTON3); 16 | hbAddProfile = GetDlgItem(hDlg, IDC_BUTTON5); 17 | hbRemoveProfile = GetDlgItem(hDlg, IDC_BUTTON6); 18 | EnableWindow(hbAddProfile, FALSE); 19 | EnableWindow(hbRemoveProfile, FALSE); 20 | hlProcess = GetDlgItem(hDlg, IDC_LIST1); 21 | heOutput = GetDlgItem(hDlg, IDC_EDIT1); 22 | ListView_SetExtendedListViewStyleEx(hlProcess, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); 23 | InitProcessDlg(); 24 | RefreshProcess(); 25 | EnableWindow(hbDetach, FALSE); 26 | EnableWindow(hbAttach, FALSE); 27 | } 28 | 29 | void ProcessWindow::InitProcessDlg() 30 | { 31 | LVCOLUMN lvc = {}; 32 | lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; 33 | lvc.fmt = LVCFMT_RIGHT; // left-aligned column 34 | lvc.cx = 40; 35 | lvc.pszText = L"PID"; 36 | ListView_InsertColumn(hlProcess, 0, &lvc); 37 | lvc.cx = 100; 38 | lvc.fmt = LVCFMT_LEFT; // left-aligned column 39 | lvc.pszText = L"Name"; 40 | ListView_InsertColumn(hlProcess, 1, &lvc); 41 | } 42 | 43 | void ProcessWindow::RefreshProcess() 44 | { 45 | ListView_DeleteAllItems(hlProcess); 46 | LVITEM item = {}; 47 | item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; 48 | DWORD idProcess[1024], cbNeeded; 49 | WCHAR path[MAX_PATH]; 50 | 51 | if (EnumProcesses(idProcess, sizeof(idProcess), &cbNeeded)) 52 | { 53 | DWORD len = cbNeeded / sizeof(DWORD); 54 | for (DWORD i = 0; i < len; ++i) 55 | { 56 | DWORD pid = idProcess[i]; 57 | UniqueHandle hProcess(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); 58 | if (hProcess) 59 | { 60 | if (GetProcessImageFileName(hProcess.get(), path, MAX_PATH)) 61 | { 62 | WCHAR buffer[256]; 63 | std::swprintf(buffer, L"%d", pid); 64 | PWCHAR name = wcsrchr(path, L'\\') + 1; 65 | item.pszText = buffer; 66 | item.lParam = pid; 67 | ListView_InsertItem(hlProcess, &item); 68 | ListView_SetItemText(hlProcess, item.iItem, 1, name); 69 | } 70 | } 71 | } 72 | } 73 | } 74 | 75 | void ProcessWindow::AttachProcess() 76 | { 77 | DWORD pid = GetSelectedPID(); 78 | if (Host_InjectByPID(pid)) 79 | { 80 | Host_HijackProcess(pid); 81 | RefreshThreadWithPID(pid, true); 82 | } 83 | } 84 | 85 | void ProcessWindow::DetachProcess() 86 | { 87 | DWORD pid = GetSelectedPID(); 88 | if (Host_ActiveDetachProcess(pid) == 0) 89 | RefreshThreadWithPID(pid, false); 90 | } 91 | 92 | void ProcessWindow::CreateProfileForSelectedProcess() 93 | { 94 | DWORD pid = GetSelectedPID(); 95 | auto path = GetProcessPath(pid); 96 | if (!path.empty()) 97 | { 98 | Profile* pf = pfman->CreateProfile(pid); 99 | pfman->SaveProfiles(); 100 | RefreshThread(ListView_GetSelectionMark(hlProcess)); 101 | } 102 | } 103 | 104 | void ProcessWindow::DeleteProfileForSelectedProcess() 105 | { 106 | DWORD pid = GetSelectedPID(); 107 | auto path = GetProcessPath(pid); 108 | if (!path.empty()) 109 | { 110 | pfman->DeleteProfile(path); 111 | RefreshThread(ListView_GetSelectionMark(hlProcess)); 112 | } 113 | } 114 | 115 | void ProcessWindow::RefreshThread(int index) 116 | { 117 | LVITEM item = {}; 118 | item.mask = LVIF_PARAM; 119 | item.iItem = index; 120 | ListView_GetItem(hlProcess, &item); 121 | DWORD pid = item.lParam; 122 | bool isAttached = man->GetProcessRecord(pid) != NULL; 123 | RefreshThreadWithPID(pid, isAttached); 124 | } 125 | 126 | void ProcessWindow::RefreshThreadWithPID(DWORD pid, bool isAttached) 127 | { 128 | EnableWindow(hbDetach, isAttached); 129 | EnableWindow(hbAttach, !isAttached); 130 | auto path = GetProcessPath(pid); 131 | bool hasProfile = !path.empty() && pfman->HasProfile(path); 132 | EnableWindow(hbAddProfile, isAttached && !hasProfile); 133 | EnableWindow(hbRemoveProfile, hasProfile); 134 | if (pid == GetCurrentProcessId()) 135 | EnableWindow(hbAttach, FALSE); 136 | } 137 | 138 | DWORD ProcessWindow::GetSelectedPID() 139 | { 140 | LVITEM item = {}; 141 | item.mask = LVIF_PARAM; 142 | item.iItem = ListView_GetSelectionMark(hlProcess); 143 | ListView_GetItem(hlProcess, &item); 144 | return item.lParam; 145 | } 146 | -------------------------------------------------------------------------------- /vnr/cpputil/cppcstring.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPCSTRING_H 2 | #define CPPCSTRING_H 3 | 4 | // cppcstring.h 5 | // 10/12/2014 jichi 6 | 7 | #include // for size_t 8 | #include 9 | //#include // for std::min 10 | #include "ccutil/ccmacro.h" 11 | 12 | // strlen 13 | 14 | template 15 | inline size_t cpp_basic_strlen(const charT *s) 16 | { 17 | const charT *p = s; 18 | while (*p) p++; 19 | return p - s; 20 | } 21 | 22 | inline size_t cpp_strlen(const char *s) { return cpp_basic_strlen(s); } 23 | inline size_t cpp_wstrlen(const wchar_t *s) { return cpp_basic_strlen(s); } 24 | 25 | template 26 | inline size_t cpp_basic_strnlen(const charT *s, size_t n) 27 | { 28 | const charT *p = s; 29 | while (*p && n) p++, n--; 30 | return p - s; 31 | } 32 | 33 | inline size_t cpp_strnlen(const char *s, size_t n) { return cpp_basic_strnlen(s, n); } 34 | inline size_t cpp_wstrnlen(const wchar_t *s, size_t n) { return cpp_basic_strnlen(s, n); } 35 | 36 | // strnchr 37 | 38 | #define cpp_basic_strnchr_(s, c, n) \ 39 | { \ 40 | while (*s && n) { \ 41 | if (*s == c) \ 42 | return s; \ 43 | s++, n--; \ 44 | } \ 45 | return nullptr; \ 46 | } 47 | template 48 | inline charT *cpp_basic_strnchr(charT *s, charT c, size_t n) cpp_basic_strnchr_(s, c, n) 49 | template 50 | inline const charT *cpp_basic_strnchr(const charT *s, charT c, size_t n) cpp_basic_strnchr_(s, c, n) 51 | 52 | // The same as memchr 53 | inline char *cpp_strnchr(char *s, char c, size_t n) { return cpp_basic_strnchr(s, c, n); } 54 | inline const char *cpp_strnchr(const char *s, char c, size_t n) { return cpp_basic_strnchr(s, c, n); } 55 | inline wchar_t *cpp_wcsnchr(wchar_t *s, wchar_t c, size_t n) { return cpp_basic_strnchr(s, c, n); } 56 | inline const wchar_t *cpp_wcsnchr(const wchar_t *s, wchar_t c, size_t n) { return cpp_basic_strnchr(s, c, n); } 57 | 58 | // strnstr 59 | 60 | #define cpp_basic_strnstr_(s, slen, r, rlen, ncmp) \ 61 | { \ 62 | while (*s && slen >= rlen) { \ 63 | if (ncmp(s, r, CC_MIN(slen, rlen)) == 0) \ 64 | return s; \ 65 | s++, slen--; \ 66 | } \ 67 | return nullptr; \ 68 | } 69 | 70 | template 71 | inline charT *cpp_basic_strnstr(charT *s, const charT *r, size_t n) cpp_basic_strnstr_(s, n, r, ::strlen(r), ::strncmp) 72 | template 73 | inline const charT *cpp_basic_strnstr(const charT *s, const charT *r, size_t n) cpp_basic_strnstr_(s, n, r, ::strlen(r), ::strncmp) 74 | 75 | template <> 76 | inline wchar_t *cpp_basic_strnstr(wchar_t *s, const wchar_t *r, size_t n) cpp_basic_strnstr_(s, n, r, ::wcslen(r), ::wcsncmp) 77 | template <> 78 | inline const wchar_t *cpp_basic_strnstr(const wchar_t *s, const wchar_t *r, size_t n) cpp_basic_strnstr_(s, n, r, ::wcslen(r), ::wcsncmp) 79 | 80 | inline char *cpp_strnstr(char *s, const char *r, size_t n) { return cpp_basic_strnstr(s, r, n); } 81 | inline const char *cpp_strnstr(const char *s, const char *r, size_t n) { return cpp_basic_strnstr(s, r, n); } 82 | inline wchar_t *cpp_wcsnstr(wchar_t *s, const wchar_t *r, size_t n) { return cpp_basic_strnstr(s, r, n); } 83 | inline const wchar_t *cpp_wcsnstr(const wchar_t *s, const wchar_t *r, size_t n) { return cpp_basic_strnstr(s, r, n); } 84 | 85 | // strnpbrk 86 | 87 | // it might be faster to use strchr functions, which is not portable though 88 | #define cpp_basic_strnpbrk_(s, sep, n) \ 89 | { \ 90 | while (*s && n) { \ 91 | for (auto p = sep; *p; p++) \ 92 | if (*s == *p) \ 93 | return s; \ 94 | s++, n--; \ 95 | } \ 96 | return nullptr; \ 97 | } 98 | 99 | template 100 | inline charT *cpp_basic_strnpbrk(charT *dest, const char2T *breakset, size_t n) 101 | cpp_basic_strnpbrk_(dest, breakset, n) 102 | 103 | template 104 | inline const charT *cpp_basic_strnpbrk(const charT *dest, const char2T *breakset, size_t n) 105 | cpp_basic_strnpbrk_(dest, breakset, n) 106 | 107 | inline char *cpp_strnpbrk(char *dest, const char *breakset, size_t n) { return cpp_basic_strnpbrk(dest, breakset, n); } 108 | inline const char *cpp_strnpbrk(const char *dest, const char *breakset, size_t n) { return cpp_basic_strnpbrk(dest, breakset, n); } 109 | inline wchar_t *cpp_wcsnpbrk(wchar_t *dest, const wchar_t *breakset, size_t n) { return cpp_basic_strnpbrk(dest, breakset, n); } 110 | inline const wchar_t *cpp_wcsnpbrk(const wchar_t *dest, const wchar_t *breakset, size_t n) { return cpp_basic_strnpbrk(dest, breakset, n); } 111 | 112 | #endif // CPPCSTRING_H 113 | -------------------------------------------------------------------------------- /vnr/ithsys/ithsys.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // ithsys.h 4 | // 8/23/2013 jichi 5 | // Branch: ITH/IHF_SYS.h, rev 111 6 | 7 | #ifdef _MSC_VER 8 | # pragma warning(disable:4800) // C4800: forcing value to bool 9 | #endif // _MSC_VER 10 | 11 | #include "ntdll/ntdll.h" 12 | 13 | // jichi 8/24/2013: Why extern "C"? Any specific reason to use C instead of C++ naming? 14 | extern "C" { 15 | //int disasm(BYTE *opcode0); // jichi 8/15/2013: move disasm to separate file 16 | extern WORD *NlsAnsiCodePage; 17 | int FillRange(LPCWSTR name,DWORD *lower, DWORD *upper); 18 | int MB_WC(char *mb, wchar_t *wc); 19 | //int MB_WC_count(char *mb, int mb_length); 20 | int WC_MB(wchar_t *wc, char *mb); 21 | 22 | // jichi 10/1/2013: Return 0 if failed. So, it is ambiguous if the search pattern starts at 0 23 | DWORD SearchPattern(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length); // KMP 24 | 25 | // jichi 2/5/2014: The same as SearchPattern except it uses 0xff to match everything 26 | // According to @Andys, 0xff seldom appear in the source code: http://sakuradite.com/topic/124 27 | enum : BYTE { SP_ANY = 0xff }; 28 | #define SP_ANY_2 SP_ANY,SP_ANY 29 | #define SP_ANY_3 SP_ANY,SP_ANY,SP_ANY 30 | #define SP_ANY_4 SP_ANY,SP_ANY,SP_ANY,SP_ANY 31 | DWORD SearchPatternEx(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length, BYTE wildcard=SP_ANY); 32 | 33 | BOOL IthInitSystemService(); 34 | void IthCloseSystemService(); 35 | DWORD IthGetMemoryRange(LPCVOID mem, DWORD *base, DWORD *size); 36 | BOOL IthCheckFile(LPCWSTR file); 37 | BOOL IthFindFile(LPCWSTR file); 38 | BOOL IthGetFileInfo(LPCWSTR file, LPVOID info, DWORD size = 0x1000); 39 | BOOL IthCheckFileFullPath(LPCWSTR file); 40 | HANDLE IthCreateFile(LPCWSTR name, DWORD option, DWORD share, DWORD disposition); 41 | HANDLE IthCreateFileInDirectory(LPCWSTR name, HANDLE dir, DWORD option, DWORD share, DWORD disposition); 42 | HANDLE IthCreateDirectory(LPCWSTR name); 43 | HANDLE IthCreateFileFullPath(LPCWSTR fullpath, DWORD option, DWORD share, DWORD disposition); 44 | HANDLE IthPromptCreateFile(DWORD option, DWORD share, DWORD disposition); 45 | HANDLE IthCreateSection(LPCWSTR name, DWORD size, DWORD right); 46 | HANDLE IthCreateEvent(LPCWSTR name, DWORD auto_reset=0, DWORD init_state=0); 47 | HANDLE IthOpenEvent(LPCWSTR name); 48 | void IthSetEvent(HANDLE hEvent); 49 | void IthResetEvent(HANDLE hEvent); 50 | HANDLE IthCreateMutex(LPCWSTR name, BOOL InitialOwner, DWORD *exist=0); 51 | HANDLE IthOpenMutex(LPCWSTR name); 52 | BOOL IthReleaseMutex(HANDLE hMutex); 53 | //DWORD IthWaitForSingleObject(HANDLE hObject, DWORD dwTime); 54 | HANDLE IthCreateThread(LPCVOID start_addr, DWORD param, HANDLE hProc=(HANDLE)-1); 55 | DWORD GetExportAddress(DWORD hModule,DWORD hash); 56 | void IthSleep(int time); // jichi 9/28/2013: in ms 57 | void IthSystemTimeToLocalTime(LARGE_INTEGER *ptime); 58 | void FreeThreadStart(HANDLE hProc); 59 | void CheckThreadStart(); 60 | } // extern "C" 61 | 62 | #ifdef ITH_HAS_HEAP 63 | extern HANDLE hHeap; // used in ith/common/memory.h 64 | #endif // ITH_HAS_HEAP 65 | 66 | extern DWORD current_process_id; 67 | extern DWORD debug; 68 | extern BYTE LeadByteTable[]; 69 | extern LPVOID page; 70 | extern BYTE launch_time[]; 71 | 72 | inline DWORD GetHash(LPSTR str) 73 | { 74 | DWORD hash = 0; 75 | //for (; *str; str++) 76 | while (*str) 77 | hash = ((hash>>7) | (hash<<25)) + *str++; 78 | return hash; 79 | } 80 | 81 | inline DWORD GetHash(LPCWSTR str) 82 | { 83 | DWORD hash = 0; 84 | //for (; *str; str++) 85 | while (*str) 86 | hash = ((hash>>7) | (hash<<25)) + *str++; 87 | return hash; 88 | } 89 | 90 | inline void IthBreak() 91 | { if (debug) __debugbreak(); } 92 | 93 | inline LPCWSTR GetMainModulePath() 94 | { 95 | __asm 96 | { 97 | mov eax, fs:[0x30] 98 | mov eax, [eax + 0xC] 99 | mov eax, [eax + 0xC] 100 | mov eax, [eax + 0x28] 101 | } 102 | } 103 | 104 | // jichi 9/28/2013: Add this to lock NtWriteFile in wine 105 | class IthMutexLocker 106 | { 107 | HANDLE m; 108 | public: 109 | explicit IthMutexLocker(HANDLE mutex) : m(mutex) 110 | { NtWaitForSingleObject(m, 0, 0); } 111 | 112 | ~IthMutexLocker() { if (m != INVALID_HANDLE_VALUE) IthReleaseMutex(m); } 113 | 114 | bool locked() const { return m != INVALID_HANDLE_VALUE; } 115 | 116 | void unlock() { if (m != INVALID_HANDLE_VALUE) { IthReleaseMutex(m); m = INVALID_HANDLE_VALUE; } } 117 | }; 118 | 119 | void IthCoolDown(); 120 | 121 | BOOL IthIsWine(); 122 | BOOL IthIsWindowsXp(); 123 | //BOOL IthIsWindows8OrGreater(); // not public 124 | 125 | /** Get current dll path. 126 | * @param buf 127 | * @param len 128 | * @return length of the path excluding \0 129 | */ 130 | size_t IthGetCurrentModulePath(wchar_t *buf, size_t len); 131 | 132 | // EOF 133 | -------------------------------------------------------------------------------- /vnr/texthook/host/textthread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // textthread.h 4 | // 8/23/2013 jichi 5 | // Branch: ITH/TextThread.h, rev 120 6 | 7 | #include "host/textthread_p.h" 8 | #include // require _InterlockedExchange 9 | 10 | struct RepeatCountNode { 11 | short repeat; 12 | short count; 13 | RepeatCountNode *next; 14 | 15 | //RepeatCountNode() : repeat(0), count(0), next(nullptr) {} 16 | }; 17 | 18 | struct ThreadParameter { 19 | DWORD pid; // jichi: 5/11/2014: The process ID 20 | DWORD hook; 21 | DWORD retn; // jichi 5/11/2014: The return address of the hook 22 | DWORD spl; // jichi 5/11/2014: the processed split value of the hook parameter 23 | }; 24 | 25 | #define CURRENT_SELECT 0x1000 26 | #define REPEAT_NUMBER_DECIDED 0x2000 27 | #define BUFF_NEWLINE 0x4000 28 | #define CYCLIC_REPEAT 0x8000 29 | #define COUNT_PER_FOWARD 0x200 30 | #define REPEAT_DETECT 0x10000 31 | #define REPEAT_SUPPRESS 0x20000 32 | #define REPEAT_NEWLINE 0x40000 33 | 34 | class TextThread; 35 | typedef void (* ConsoleCallback)(LPCSTR text); 36 | typedef void (* ConsoleWCallback)(LPCWSTR text); 37 | typedef DWORD (* ThreadOutputFilterCallback)(TextThread *, BYTE *, DWORD, DWORD, PVOID, bool space); // jichi 10/27/2013: Add space 38 | typedef DWORD (* ThreadEventCallback)(TextThread *); 39 | 40 | //extern DWORD split_time,repeat_count,global_filter,cyclic_remove; 41 | 42 | class TextThread : public MyVector 43 | { 44 | public: 45 | TextThread(DWORD pid, DWORD hook, DWORD retn, DWORD spl, WORD num); 46 | ~TextThread(); 47 | //virtual void CopyLastSentence(LPWSTR str); 48 | //virtual void SetComment(LPWSTR); 49 | //virtual void ExportTextToFile(LPWSTR filename); 50 | 51 | virtual bool CheckCycle(TextThread *start); 52 | virtual DWORD GetThreadString(LPSTR str, DWORD max); 53 | virtual DWORD GetEntryString(LPSTR str, DWORD max = 0x200); 54 | 55 | void Reset(); 56 | void AddText(const BYTE *con,int len, bool new_line, bool space); // jichi 10/27/2013: add const; remove console; add space 57 | void RemoveSingleRepeatAuto(const BYTE *con, int &len); // jichi 10/27/2013: add const 58 | void RemoveSingleRepeatForce(BYTE *con, int &len); 59 | void RemoveCyclicRepeat(BYTE *&con, int &len); 60 | void ResetRepeatStatus(); 61 | void AddLineBreak(); 62 | //void ResetEditText(); 63 | void ComboSelectCurrent(); 64 | void UnLinkAll(); 65 | void CopyLastToClipboard(); 66 | 67 | //void AdjustPrevRepeat(DWORD len); 68 | //void PrevRepeatLength(DWORD &len); 69 | 70 | //bool AddToCombo(); 71 | bool RemoveFromCombo(); 72 | 73 | void SetNewLineFlag(); 74 | void SetNewLineTimer(); 75 | 76 | BYTE *GetStore(DWORD *len) { if (len) *len = used; return storage; } 77 | DWORD LastSentenceLen() { return used - last_sentence; } 78 | DWORD PID() const { return tp.pid; } 79 | DWORD Addr() const {return tp.hook; } 80 | DWORD &Status() { return status; } 81 | WORD Number() const { return thread_number; } 82 | WORD &Last() { return last; } 83 | WORD &LinkNumber() { return link_number; } 84 | UINT_PTR &Timer() { return timer; } 85 | ThreadParameter *GetThreadParameter() { return &tp; } 86 | TextThread *&Link() { return link; } 87 | //LPCWSTR GetComment() { return comment; } 88 | 89 | ThreadOutputFilterCallback RegisterOutputCallBack(ThreadOutputFilterCallback cb, PVOID data) 90 | { 91 | app_data = data; 92 | return (ThreadOutputFilterCallback)_InterlockedExchange((long*)&output,(long)cb); 93 | } 94 | 95 | ThreadOutputFilterCallback RegisterFilterCallBack(ThreadOutputFilterCallback cb, PVOID data) 96 | { 97 | app_data = data; 98 | return (ThreadOutputFilterCallback)_InterlockedExchange((long*)&filter,(long)cb); 99 | } 100 | 101 | void SetRepeatFlag() { status |= CYCLIC_REPEAT; } 102 | void ClearNewLineFlag() { status &= ~BUFF_NEWLINE; } 103 | void ClearRepeatFlag() { status &= ~CYCLIC_REPEAT; } 104 | 105 | protected: 106 | void AddTextDirect(const BYTE *con, int len, bool space); // jichi 10/27/2013: add const; add space; change to protected 107 | 108 | private: 109 | ThreadParameter tp; 110 | 111 | WORD thread_number, 112 | link_number; 113 | WORD last, 114 | align_space; 115 | WORD repeat_single; 116 | WORD repeat_single_current; 117 | WORD repeat_single_count; 118 | WORD repeat_detect_count; 119 | RepeatCountNode *head; 120 | 121 | TextThread *link; 122 | ThreadOutputFilterCallback filter; // jichi 10/27/2013: Remove filter 123 | ThreadOutputFilterCallback output; 124 | PVOID app_data; 125 | LPSTR thread_string; 126 | UINT_PTR timer; 127 | DWORD status,repeat_detect_limit; 128 | DWORD last_sentence, 129 | prev_sentence, 130 | sentence_length, 131 | repeat_index, 132 | last_time; 133 | }; 134 | 135 | // EOF 136 | -------------------------------------------------------------------------------- /vnr/profile/Profile.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2012 kaosu (qiupf2000@gmail.com) 2 | * This file is part of the Interactive Text Hooker. 3 | 4 | * Interactive Text Hooker is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published 6 | * by the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "vnrhook/include/types.h" // HookParam 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | struct ThreadParameter; 27 | class TextThread; 28 | class HookProfile; 29 | class ThreadProfile; 30 | class LinkProfile; 31 | typedef std::unique_ptr hook_ptr; 32 | typedef std::unique_ptr thread_ptr; 33 | typedef std::unique_ptr link_ptr; 34 | typedef std::vector::const_iterator thread_ptr_iter; 35 | namespace pugi { 36 | class xml_node; 37 | } 38 | 39 | #define THREAD_MASK_RETN 1 40 | #define THREAD_MASK_SPLIT 2 41 | 42 | class HookProfile 43 | { 44 | HookParam hp; 45 | std::wstring name; 46 | public: 47 | HookProfile(const HookParam& hp, const std::wstring& name) : 48 | hp(hp), 49 | name(name) 50 | {} 51 | const HookParam& HP() const { return hp; }; 52 | const std::wstring& Name() const { return name; }; 53 | }; 54 | 55 | class ThreadProfile 56 | { 57 | std::wstring hook_name; 58 | DWORD retn; 59 | DWORD split; 60 | DWORD hook_addr; 61 | WORD hm_index, flags; 62 | std::wstring comment; 63 | public: 64 | ThreadProfile(const std::wstring& hook_name, 65 | DWORD retn, 66 | DWORD split, 67 | DWORD hook_addr, 68 | WORD hm_index, 69 | WORD flags, 70 | const std::wstring& comment) : 71 | hook_name(hook_name), 72 | retn(retn), 73 | split(split), 74 | hook_addr(hook_addr), 75 | hm_index(hm_index), 76 | flags(flags), 77 | comment(comment) 78 | { 79 | } 80 | const std::wstring& HookName() const { return hook_name; } 81 | const std::wstring& Comment() const { return comment; } 82 | DWORD Return() const { return retn; } 83 | DWORD Split() const { return split; } 84 | DWORD& HookAddress() { return hook_addr; } 85 | WORD& HookManagerIndex() { return hm_index; } 86 | WORD Flags() const { return flags; } 87 | }; 88 | 89 | class LinkProfile 90 | { 91 | WORD from_index, to_index; 92 | public: 93 | LinkProfile(WORD from_index, WORD to_index) : 94 | from_index(from_index), 95 | to_index(to_index) 96 | {} 97 | WORD FromIndex() const { return from_index; } 98 | WORD ToIndex() const { return to_index; } 99 | }; 100 | 101 | namespace std { 102 | template<> 103 | struct hash { 104 | size_t operator()(const hook_ptr &r) const 105 | { 106 | return hash{}(r->HP().address) 107 | ^ hash{}(r->HP().module) 108 | ^ hash{}(r->HP().function); 109 | } 110 | }; 111 | template<> 112 | struct equal_to { 113 | bool operator()(const hook_ptr& r, const hook_ptr& r2) const 114 | { 115 | return r->HP().address == r2->HP().address 116 | && r->HP().module == r2->HP().module 117 | && r->HP().function == r2->HP().function; 118 | } 119 | }; 120 | 121 | template<> 122 | struct hash { 123 | size_t operator()(const link_ptr &r) const 124 | { 125 | return hash{}(r->FromIndex()) 126 | ^ hash{}(r->ToIndex()); 127 | } 128 | }; 129 | template<> 130 | struct equal_to { 131 | bool operator()(const link_ptr& r, const link_ptr& r2) const 132 | { 133 | return r->FromIndex() == r2->FromIndex() 134 | && r->ToIndex() == r2->ToIndex(); 135 | } 136 | }; 137 | } 138 | 139 | class Profile 140 | { 141 | public: 142 | Profile(const std::wstring& title); 143 | bool XmlReadProfile(pugi::xml_node profile_node); 144 | bool XmlWriteProfile(pugi::xml_node profile_node); 145 | void AddHook(hook_ptr hook); 146 | int AddThread(thread_ptr tp); 147 | void AddLink(link_ptr lp); 148 | void Clear(); 149 | const std::unordered_set& Hooks() const; 150 | const std::vector& Threads() const; 151 | const std::unordered_set& Links() const; 152 | const std::wstring& Title() const; 153 | thread_ptr_iter FindThread(const ThreadParameter* tp, const std::wstring& hook_name) const; 154 | WORD& SelectedIndex() { return select_index; } 155 | bool IsThreadSelected(thread_ptr_iter thread_profile); 156 | 157 | private: 158 | bool XmlReadProfileHook(pugi::xml_node hooks_node); 159 | bool XmlReadProfileThread(pugi::xml_node threads_node); 160 | bool XmlReadProfileLink(pugi::xml_node links_node); 161 | bool XmlWriteProfileHook(pugi::xml_node hooks_node); 162 | bool XmlWriteProfileThread(pugi::xml_node threads_node); 163 | bool XmlWriteProfileLink(pugi::xml_node links_node); 164 | 165 | std::wstring title; 166 | std::unordered_set hooks; 167 | std::vector threads; 168 | std::unordered_set links; 169 | 170 | WORD select_index; 171 | }; 172 | -------------------------------------------------------------------------------- /vnr/windbg/inject.cc: -------------------------------------------------------------------------------- 1 | // inject.cc 2 | // 1/27/2013 jichi 3 | #include "windbg/inject.h" 4 | #include "windbg/windbg_p.h" 5 | #include // for wcslen 6 | 7 | //#define DEBUG "windbg::inject" 8 | #include "sakurakit/skdebug.h" 9 | 10 | WINDBG_BEGIN_NAMESPACE 11 | 12 | // - Remote Injection - 13 | 14 | BOOL InjectFunction1(LPCVOID addr, LPCVOID data, SIZE_T dataSize, DWORD pid, HANDLE hProcess, INT timeout) 15 | { 16 | DOUT("enter: pid =" << pid); 17 | if (hProcess == INVALID_HANDLE_VALUE && pid) { 18 | hProcess = ::OpenProcess(PROCESS_INJECT_ACCESS, FALSE, pid); 19 | // TODO: Privilege elevation is not implemented. See: skwinsec.py. 20 | //if (!hProcess) { 21 | // priv = SkProcessElevator('SeDebugPrivilege') 22 | // if not priv.isEmpty(): 23 | // handle = win32api.OpenProcess(PROCESS_INJECT_ACCESS, 0, pid) 24 | //} 25 | } 26 | if (hProcess == INVALID_HANDLE_VALUE) { 27 | DOUT("exit: error: failed to get process handle"); 28 | return FALSE; 29 | } 30 | 31 | BOOL ret = FALSE; 32 | if (LPVOID remoteData = ::VirtualAllocEx(hProcess, nullptr, dataSize, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE)) { 33 | if (::WriteProcessMemory(hProcess, remoteData, data, dataSize, nullptr)) 34 | if (HANDLE hThread = ::CreateRemoteThread( 35 | hProcess, 36 | nullptr, 0, 37 | reinterpret_cast(addr), 38 | remoteData, 39 | 0, nullptr)) { 40 | ::WaitForSingleObject(hThread, timeout); 41 | ::CloseHandle(hThread); 42 | ret = TRUE; 43 | } 44 | ::VirtualFreeEx(hProcess, remoteData, dataSize, MEM_RELEASE); 45 | } 46 | ::CloseHandle(hProcess); 47 | DOUT("exit: ret =" << ret); 48 | return ret; 49 | } 50 | 51 | BOOL injectDllW(LPCWSTR dllPath, DWORD pid, HANDLE hProcess, INT timeout) 52 | { 53 | DOUT("enter: pid =" << pid); 54 | LPCVOID fun = details::getModuleFunctionAddressA("LoadLibraryW", "kernel32.dll"); 55 | if (!fun) { 56 | DOUT("exit error: cannot find function"); 57 | return FALSE; 58 | } 59 | LPCVOID data = dllPath; 60 | SIZE_T dataSize = ::wcslen(dllPath) * 2 + 2; // L'\0' 61 | BOOL ok = InjectFunction1(fun, data, dataSize, pid, hProcess, timeout); 62 | DOUT("exit: ret =" << ok); 63 | return ok; 64 | } 65 | 66 | BOOL ejectDll(HANDLE hDll, DWORD pid, HANDLE hProcess, INT timeout) 67 | { 68 | DOUT("enter: pid =" << pid); 69 | LPCVOID fun = details::getModuleFunctionAddressA("FreeLibrary", "kernel32.dll"); 70 | if (!fun) { 71 | DOUT("exit error: cannot find function"); 72 | return FALSE; 73 | } 74 | LPCVOID data = &hDll; 75 | SIZE_T dataSize = sizeof(hDll); 76 | BOOL ok = InjectFunction1(fun, data, dataSize, pid, hProcess, timeout); 77 | DOUT("exit: ret =" << ok); 78 | return ok; 79 | } 80 | 81 | WINDBG_END_NAMESPACE 82 | 83 | // EOF 84 | 85 | /* 86 | enum { CREATE_THREAD_ACCESS = (PROCESS_CREATE_THREAD | 87 | PROCESS_QUERY_INFORMATION | 88 | PROCESS_VM_OPERATION | 89 | PROCESS_VM_WRITE | 90 | PROCESS_VM_READ ) }; 91 | 92 | 93 | int InjectDll(HANDLE hProcess, HINSTANCE hInst) { 94 | HANDLE hThread; 95 | 96 | wchar_t dllFile[2*MAX_PATH]; 97 | if (GetModuleFileNameW(hInst, dllFile, sizeof(dllFile)/2) > sizeof(dllFile)/2) return 0; 98 | 99 | void *loadLibraryW = GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "LoadLibraryW"); 100 | if (!loadLibraryW) return 0; 101 | 102 | wchar_t *name; 103 | if (!(name = wcsrchr(dllFile, '\\'))) return 0; 104 | name ++; 105 | wcscpy(name, DLL_NAME); 106 | if (GetFileAttributes(dllFile) == INVALID_FILE_ATTRIBUTES) return 0; 107 | 108 | size_t len = sizeof(wchar_t)*(1+wcslen(dllFile)); 109 | void *remoteString = (LPVOID)VirtualAllocEx(hProcess, 110 | NULL, 111 | len, 112 | MEM_RESERVE|MEM_COMMIT, 113 | PAGE_READWRITE 114 | ); 115 | if (remoteString) { 116 | if (WriteProcessMemory(hProcess, (LPVOID)remoteString, dllFile, len, NULL)) { 117 | if (hThread = CreateRemoteThread(hProcess, 0, 0, (LPTHREAD_START_ROUTINE)loadLibraryW, (LPVOID)remoteString, 0,0)) { 118 | WaitForSingleObject(hThread, 3000); 119 | CloseHandle(hThread); 120 | VirtualFreeEx(hProcess, remoteString, len, MEM_FREE); 121 | // Make sure it's injected before resuming. 122 | return 1; 123 | } 124 | } 125 | VirtualFreeEx(hProcess, remoteString, len, MEM_FREE); 126 | } 127 | return 0; 128 | } 129 | 130 | int getPriv(const char * name) { 131 | HANDLE hToken; 132 | LUID seValue; 133 | TOKEN_PRIVILEGES tkp; 134 | 135 | if (!LookupPrivilegeValueA(NULL, name, &seValue) || 136 | !OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { 137 | return 0; 138 | } 139 | 140 | tkp.PrivilegeCount = 1; 141 | tkp.Privileges[0].Luid = seValue; 142 | tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 143 | 144 | int res = AdjustTokenPrivileges(hToken, 0, &tkp, sizeof(tkp), NULL, NULL); 145 | 146 | CloseHandle(hToken); 147 | return res; 148 | } 149 | 150 | inline int getDebugPriv() { 151 | return getPriv("SeDebugPrivilege"); 152 | } 153 | 154 | int InjectIntoProcess(int pid) { 155 | HANDLE hProcess = OpenProcess(CREATE_THREAD_ACCESS, 0, pid); 156 | if (hProcess == 0) { 157 | getDebugPriv(); 158 | hProcess = OpenProcess(CREATE_THREAD_ACCESS, 0, pid); 159 | if (!hProcess) return 0; 160 | } 161 | 162 | int out = InjectDll(hProcess); 163 | 164 | CloseHandle(hProcess); 165 | return out; 166 | } 167 | */ 168 | --------------------------------------------------------------------------------