├── .gitignore ├── Common ├── Defines.h ├── Logger.h ├── SimpleIni.h ├── StringUtil.h ├── Timer.h ├── Types.h ├── WinUtil.h └── WinVer.h ├── LICENSE ├── MinHook ├── .editorconfig ├── .gitignore ├── AUTHORS.txt ├── LICENSE.txt ├── README.md ├── build │ ├── MinGW │ │ ├── Makefile │ │ └── make.bat │ ├── VC10 │ │ ├── MinHook.vcxproj │ │ ├── MinHookVC10.sln │ │ ├── libMinHook.vcxproj │ │ └── libMinHook.vcxproj.filters │ ├── VC11 │ │ ├── MinHook.vcxproj │ │ ├── MinHookVC11.sln │ │ ├── libMinHook.vcxproj │ │ └── libMinHook.vcxproj.filters │ ├── VC12 │ │ ├── MinHook.vcxproj │ │ ├── MinHookVC12.sln │ │ ├── libMinHook.vcxproj │ │ └── libMinHook.vcxproj.filters │ ├── VC14 │ │ ├── MinHook.vcxproj │ │ ├── MinHookVC14.sln │ │ ├── libMinHook.vcxproj │ │ └── libMinHook.vcxproj.filters │ ├── VC15 │ │ ├── MinHook.vcxproj │ │ ├── MinHookVC15.sln │ │ ├── libMinHook.vcxproj │ │ └── libMinHook.vcxproj.filters │ └── VC9 │ │ ├── MinHook.vcproj │ │ ├── MinHookVC9.sln │ │ └── libMinHook.vcproj ├── dll_resources │ ├── MinHook.def │ └── MinHook.rc ├── include │ └── MinHook.h └── src │ ├── HDE │ ├── hde32.c │ ├── hde32.h │ ├── hde64.c │ ├── hde64.h │ ├── pstdint.h │ ├── table32.h │ └── table64.h │ ├── buffer.c │ ├── buffer.h │ ├── hook.c │ ├── trampoline.c │ └── trampoline.h ├── d3d9ex.sln └── d3d9ex ├── AutoFix.cpp ├── AutoFix.h ├── Context.cpp ├── Context.h ├── IDirect3D9.cpp ├── IDirect3D9.h ├── IDirect3DDevice9.cpp ├── IDirect3DDevice9.h ├── IDirect3DVertexBuffer9.cpp ├── IDirect3DVertexBuffer9.h ├── ReadMe.txt ├── Settings.h ├── Wrapper.h ├── d3d9ex.vcxproj ├── d3d9ex.vcxproj.filters ├── dllmain.cpp ├── exports.def ├── stdafx.cpp ├── stdafx.h └── targetver.h /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | # Uncomment if you have tasks that create the project's static files in wwwroot 27 | #wwwroot/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opendb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | # NuGet v3's project.json files produces more ignoreable files 154 | *.nuget.props 155 | *.nuget.targets 156 | 157 | # Microsoft Azure Build Output 158 | csx/ 159 | *.build.csdef 160 | 161 | # Microsoft Azure Emulator 162 | ecf/ 163 | rcf/ 164 | 165 | # Microsoft Azure ApplicationInsights config file 166 | ApplicationInsights.config 167 | 168 | # Windows Store app package directory 169 | AppPackages/ 170 | BundleArtifacts/ 171 | 172 | # Visual Studio cache files 173 | # files ending in .cache can be ignored 174 | *.[Cc]ache 175 | # but keep track of directories ending in .cache 176 | !*.[Cc]ache/ 177 | 178 | # Others 179 | ClientBin/ 180 | ~$* 181 | *~ 182 | *.dbmdl 183 | *.dbproj.schemaview 184 | *.pfx 185 | *.publishsettings 186 | node_modules/ 187 | orleans.codegen.cs 188 | 189 | # RIA/Silverlight projects 190 | Generated_Code/ 191 | 192 | # Backup & report files from converting an old project file 193 | # to a newer Visual Studio version. Backup files are not needed, 194 | # because we have git ;-) 195 | _UpgradeReport_Files/ 196 | Backup*/ 197 | UpgradeLog*.XML 198 | UpgradeLog*.htm 199 | 200 | # SQL Server files 201 | *.mdf 202 | *.ldf 203 | 204 | # Business Intelligence projects 205 | *.rdl.data 206 | *.bim.layout 207 | *.bim_*.settings 208 | 209 | # Microsoft Fakes 210 | FakesAssemblies/ 211 | 212 | # GhostDoc plugin setting file 213 | *.GhostDoc.xml 214 | 215 | # Node.js Tools for Visual Studio 216 | .ntvs_analysis.dat 217 | 218 | # Visual Studio 6 build log 219 | *.plg 220 | 221 | # Visual Studio 6 workspace options file 222 | *.opt 223 | 224 | # Visual Studio LightSwitch build output 225 | **/*.HTMLClient/GeneratedArtifacts 226 | **/*.DesktopClient/GeneratedArtifacts 227 | **/*.DesktopClient/ModelManifest.xml 228 | **/*.Server/GeneratedArtifacts 229 | **/*.Server/ModelManifest.xml 230 | _Pvt_Extensions 231 | 232 | # Paket dependency manager 233 | .paket/paket.exe 234 | 235 | # FAKE - F# Make 236 | .fake/ 237 | -------------------------------------------------------------------------------- /Common/Defines.h: -------------------------------------------------------------------------------- 1 | #define DIR_SEP "\\" 2 | #define DIR_SEP_CHR '\\' 3 | 4 | #define strcasecmp _stricmp 5 | #define strncasecmp _strnicmp 6 | #define unlink _unlink 7 | #define snprintf _snprintf 8 | #define vscprintf _vscprintf 9 | 10 | #define fseeko _fseeki64 11 | #define ftello _ftelli64 12 | #define atoll _atoi64 13 | #define stat64 _stat64 14 | #define fstat64 _fstat64 15 | #define fileno _fileno 16 | -------------------------------------------------------------------------------- /Common/Logger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include "StringUtil.h" 10 | #include "WinUtil.h" 11 | 12 | #ifndef LOGGER_DISABLE 13 | class Logger 14 | { 15 | public: 16 | Logger(const Logger&) = delete; 17 | const Logger& operator=(Logger& other) = delete; 18 | 19 | Logger() : m_systime(), m_console(INVALID_HANDLE_VALUE), m_file(INVALID_HANDLE_VALUE) {} 20 | 21 | Logger::~Logger() 22 | { 23 | if (m_console) 24 | FreeConsole(); 25 | 26 | if (m_file) 27 | CloseHandle(m_file); 28 | } 29 | 30 | static Logger& Logger::Get() 31 | { 32 | static Logger instance; 33 | return instance; 34 | }; 35 | 36 | bool File(const std::string& filename) 37 | { 38 | std::string logpath = FullPathFromPath(filename); 39 | m_file = CreateFileA(logpath.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 40 | OutputDebugStringA(logpath.c_str()); 41 | 42 | if (m_file != INVALID_HANDLE_VALUE) 43 | PrintStamp(false); 44 | 45 | return m_file != INVALID_HANDLE_VALUE; 46 | } 47 | 48 | bool Console(const char* title) 49 | { 50 | AllocConsole(); 51 | 52 | m_console = GetStdHandle(STD_OUTPUT_HANDLE); 53 | if (m_console != INVALID_HANDLE_VALUE) 54 | { 55 | ShowWindow(GetConsoleWindow(), SW_MAXIMIZE); 56 | if (title) SetConsoleTitleA(title); 57 | } 58 | 59 | if (m_console != INVALID_HANDLE_VALUE) 60 | PrintStamp(true); 61 | 62 | return m_console != INVALID_HANDLE_VALUE; 63 | } 64 | 65 | void Print(const char* format, va_list args) 66 | { 67 | bool to_console = m_console != INVALID_HANDLE_VALUE; 68 | bool to_file = m_file != INVALID_HANDLE_VALUE; 69 | 70 | if ((to_console || to_file) && format) 71 | { 72 | int outsize = _vscprintf(format, args) + 1; 73 | std::unique_ptr buffer(new char[outsize]); 74 | CharArrayFromFormatV(buffer.get(), outsize, format, args); 75 | 76 | #ifdef LOGGER_DISABLE_TIME 77 | std::string to_print(buffer.get(), outsize - 1); 78 | #else 79 | std::string to_print; 80 | GetTime(&to_print); 81 | to_print.append(buffer.get(), outsize - 1); 82 | #endif 83 | 84 | to_print.append("\r\n"); 85 | 86 | DWORD lenout = 0; 87 | if (to_console) WriteConsoleA(m_console, to_print.c_str(), (DWORD)to_print.size(), &lenout, NULL); 88 | if (to_file) WriteFile(m_file, to_print.c_str(), (DWORD)to_print.size(), &lenout, NULL); 89 | } 90 | } 91 | 92 | private: 93 | void PrintStamp(bool console) 94 | { 95 | static char stamp[] = "[TIME]\t\t[THREAD]\t[LOG]\r\n"; 96 | DWORD lenout = 0; 97 | 98 | if (console) WriteConsoleA(m_console, stamp, _countof(stamp) - 1, &lenout, NULL); 99 | else WriteFile(m_file, stamp, _countof(stamp) - 1, &lenout, NULL); 100 | } 101 | 102 | void GetTime(std::string* out) 103 | { 104 | GetLocalTime(&m_systime); 105 | *out = StringFromFormat("%02u:%02u:%02u.%03u\t%08u\t", m_systime.wHour, m_systime.wMinute, 106 | m_systime.wSecond, m_systime.wMilliseconds, GetCurrentThreadId()); 107 | 108 | } 109 | 110 | SYSTEMTIME m_systime; 111 | HANDLE m_console; 112 | HANDLE m_file; 113 | }; 114 | 115 | inline void LogFile(const std::string& logname) 116 | { 117 | Logger::Get().File(logname); 118 | } 119 | 120 | inline void LogConsole(const char* title = nullptr) 121 | { 122 | Logger::Get().Console(title); 123 | } 124 | 125 | inline void PrintLog(const char* format, ...) 126 | { 127 | va_list args; 128 | va_start(args, format); 129 | Logger::Get().Print(format, args); 130 | va_end(args); 131 | } 132 | 133 | #else 134 | #define LogFile(logname) (logname) 135 | #define LogConsole(title, notice) (title) 136 | #define PrintLog(format, ...) (format) 137 | #endif -------------------------------------------------------------------------------- /Common/StringUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /// Try to find in the Haystack the Needle - ignore case 9 | inline bool StringSearchIgnoreCase(const std::string & strHaystack, const std::string & strNeedle) 10 | { 11 | auto it = std::search( 12 | strHaystack.begin(), strHaystack.end(), 13 | strNeedle.begin(), strNeedle.end(), 14 | [](char ch1, char ch2) { return ::toupper(ch1) == ::toupper(ch2); } 15 | ); 16 | return (it != strHaystack.end()); 17 | } 18 | 19 | inline bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args) 20 | { 21 | int writtenCount = _vsnprintf_s(out, outsize, outsize, format, args); 22 | if (writtenCount > 0 && writtenCount < outsize) 23 | { 24 | out[writtenCount] = '\0'; 25 | return true; 26 | } 27 | else 28 | { 29 | out[outsize - 1] = '\0'; 30 | return false; 31 | } 32 | } 33 | 34 | inline bool CharArrayFromFormatV(wchar_t* out, int outsize, const wchar_t* format, va_list args) 35 | { 36 | int writtenCount = _vsnwprintf_s(out, outsize, outsize, format, args); 37 | if (writtenCount > 0 && writtenCount < outsize) 38 | { 39 | out[writtenCount] = '\0'; 40 | return true; 41 | } 42 | else 43 | { 44 | out[outsize - 1] = '\0'; 45 | return false; 46 | } 47 | } 48 | 49 | template 50 | inline void CharArrayFromFormat(char(&out)[Count], const char* format, ...) 51 | { 52 | va_list args; 53 | va_start(args, format); 54 | CharArrayFromFormatV(out, Count, format, args); 55 | va_end(args); 56 | } 57 | 58 | template 59 | inline void CharArrayFromFormat(wchar_t(&out)[Count], const wchar_t* format, ...) 60 | { 61 | va_list args; 62 | va_start(args, format); 63 | CharArrayFromFormatV(out, Count, format, args); 64 | va_end(args); 65 | } 66 | 67 | inline std::string StringFromFormatV(const char* format, va_list args) 68 | { 69 | int required = _vscprintf(format, args); 70 | std::unique_ptr buf(new char[required + 1]); 71 | CharArrayFromFormatV(buf.get(), required + 1, format, args); 72 | 73 | std::string temp = buf.get(); 74 | return std::move(temp); 75 | } 76 | 77 | inline std::wstring StringFromFormatV(const wchar_t* format, va_list args) 78 | { 79 | int required = _vscwprintf(format, args); 80 | std::unique_ptr buf(new wchar_t[required + 1]); 81 | CharArrayFromFormatV(buf.get(), required + 1, format, args); 82 | 83 | std::wstring temp = buf.get(); 84 | return std::move(temp); 85 | } 86 | 87 | inline std::string StringFromFormat(const char* format, ...) 88 | { 89 | va_list args; 90 | va_start(args, format); 91 | std::string res = StringFromFormatV(format, args); 92 | va_end(args); 93 | return std::move(res); 94 | } 95 | 96 | inline std::wstring StringFromFormat(const wchar_t* format, ...) 97 | { 98 | va_list args; 99 | va_start(args, format); 100 | std::wstring res = StringFromFormatV(format, args); 101 | va_end(args); 102 | return std::move(res); 103 | } 104 | 105 | inline std::string UTF16ToUTF8(const std::wstring& input) 106 | { 107 | auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), (int)input.size(), nullptr, 0, nullptr, nullptr); 108 | 109 | std::string output; 110 | output.resize(size); 111 | 112 | if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), (int)input.size(), &output[0], (int)output.size(), nullptr, nullptr)) 113 | { 114 | output.clear(); 115 | } 116 | 117 | return output; 118 | } 119 | 120 | inline std::wstring CPToUTF16(DWORD code_page, const std::string& input) 121 | { 122 | auto const size = MultiByteToWideChar(code_page, 0, input.data(), (int)input.size(), nullptr, 0); 123 | 124 | std::wstring output; 125 | output.resize(size); 126 | 127 | if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), (int)input.size(), &output[0], (int)output.size())) 128 | { 129 | output.clear(); 130 | } 131 | 132 | return output; 133 | } 134 | 135 | inline std::wstring UTF8ToUTF16(const std::string& input) 136 | { 137 | return CPToUTF16(CP_UTF8, input); 138 | } 139 | 140 | inline std::string SHIFTJISToUTF8(const std::string& input) 141 | { 142 | return UTF16ToUTF8(CPToUTF16(932, input)); 143 | } 144 | 145 | inline std::string CP1252ToUTF8(const std::string& input) 146 | { 147 | return UTF16ToUTF8(CPToUTF16(1252, input)); 148 | } 149 | 150 | // trim from start 151 | static inline std::string <rim(std::string &s) { 152 | s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(std::isspace)))); 153 | return s; 154 | } 155 | 156 | // trim from end 157 | static inline std::string &rtrim(std::string &s) { 158 | s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); 159 | return s; 160 | } 161 | 162 | // trim from both ends 163 | static inline std::string &trim(std::string &s) { 164 | return ltrim(rtrim(s)); 165 | } 166 | -------------------------------------------------------------------------------- /Common/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Timer 6 | { 7 | public: 8 | Timer() 9 | { 10 | QueryPerformanceFrequency(&m_frequency); 11 | m_startCount.QuadPart = 0; 12 | m_endCount.QuadPart = 0; 13 | 14 | m_stopped = 0; 15 | m_startTimeInMicroSec = 0; 16 | m_endTimeInMicroSec = 0; 17 | } 18 | 19 | ~Timer() 20 | { 21 | 22 | } 23 | 24 | void Start() 25 | { 26 | m_startCount.QuadPart = 0; 27 | QueryPerformanceCounter(&m_startCount); 28 | } 29 | 30 | void Stop() 31 | { 32 | m_stopped = true; 33 | QueryPerformanceCounter(&m_endCount); 34 | } 35 | 36 | double GetElapsedTimeInMicroSec() 37 | { 38 | if (!m_stopped) 39 | QueryPerformanceCounter(&m_endCount); 40 | 41 | m_startTimeInMicroSec = m_startCount.QuadPart * (1000000.0 / m_frequency.QuadPart); 42 | m_endTimeInMicroSec = m_endCount.QuadPart * (1000000.0 / m_frequency.QuadPart); 43 | 44 | return m_endTimeInMicroSec - m_startTimeInMicroSec; 45 | } 46 | 47 | double GetElapsedTimeInMilliSec() 48 | { 49 | return GetElapsedTimeInMicroSec() * 0.001; 50 | } 51 | 52 | double GetElapsedTimeInSec() 53 | { 54 | return GetElapsedTimeInMicroSec() * 0.000001; 55 | } 56 | 57 | double GetElapsedTime() 58 | { 59 | return GetElapsedTimeInSec(); 60 | } 61 | 62 | private: 63 | double m_startTimeInMicroSec; 64 | double m_endTimeInMicroSec; 65 | bool m_stopped; 66 | LARGE_INTEGER m_frequency; 67 | LARGE_INTEGER m_startCount; 68 | LARGE_INTEGER m_endCount; 69 | }; -------------------------------------------------------------------------------- /Common/Types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef int8_t s8; 6 | typedef uint8_t u8; 7 | typedef int16_t s16; 8 | typedef uint16_t u16; 9 | typedef int32_t s32; 10 | typedef uint32_t u32; 11 | typedef int64_t s64; 12 | typedef uint64_t u64; 13 | 14 | typedef intptr_t sPointer; 15 | typedef uintptr_t uPointer; 16 | 17 | typedef float f32; 18 | typedef double f64; 19 | 20 | union Word 21 | { 22 | f32 float32; 23 | u32 bits32; 24 | u16 bits16[2]; 25 | u8 bits8[4]; 26 | }; 27 | 28 | union DWord 29 | { 30 | u64 bits64; 31 | f64 float64; 32 | f32 float32[2]; 33 | u32 bits32[2]; 34 | u16 bits16[4]; 35 | u8 bits8[8]; 36 | 37 | Word word[2]; 38 | }; 39 | 40 | union QWord 41 | { 42 | u64 bits64[2]; 43 | f64 float64[2]; 44 | f32 float32[4]; 45 | u32 bits32[4]; 46 | u16 bits16[8]; 47 | u8 bits8[16]; 48 | 49 | Word word[4]; 50 | DWord dword[2]; 51 | }; 52 | -------------------------------------------------------------------------------- /Common/WinUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "Windows.h" 6 | #include "tchar.h" 7 | #include "Types.h" 8 | #include "Defines.h" 9 | 10 | #include 11 | #pragma comment(lib, "shell32.lib") 12 | 13 | template 14 | T clamp(const T& n, const T& lower, const T& upper) { 15 | return n <= lower ? lower : n >= upper ? upper : n; 16 | } 17 | 18 | inline HMODULE& CurrentModule() 19 | { 20 | static HMODULE hModule = 0; 21 | if (!hModule) 22 | GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)&hModule, &hModule); 23 | return hModule; 24 | } 25 | 26 | inline void RemoveFileSpec(char* path) 27 | { 28 | if (path[strlen(path) - 4] == '.') 29 | { 30 | char* p = strrchr(path, '\\'); 31 | if (p) *p = '\0'; 32 | } 33 | } 34 | 35 | inline void RemoveFileSpec(wchar_t* path) 36 | { 37 | if (path[wcslen(path) - 4] == L'.') 38 | { 39 | wchar_t* p = wcsrchr(path, L'\\'); 40 | if (p) *p = L'\0'; 41 | } 42 | } 43 | 44 | inline void RemovePath(char* path) 45 | { 46 | char* p = strrchr(path, '\\'); 47 | if (p) 48 | { 49 | strcpy_s(path, strlen(p), p + 1); 50 | path[strlen(p)] = '\0'; 51 | } 52 | } 53 | 54 | inline void RemovePath(wchar_t* path) 55 | { 56 | wchar_t* p = wcsrchr(path, L'\\'); 57 | if (p) 58 | { 59 | wcscpy_s(path, wcslen(p), p + 1); 60 | path[wcslen(p)] = L'\0'; 61 | } 62 | } 63 | 64 | inline void StringPathAppend(std::string* path, const std::string& more) 65 | { 66 | if (path->back() != DIR_SEP_CHR) 67 | path->push_back(DIR_SEP_CHR); 68 | 69 | path->append(more); 70 | } 71 | 72 | inline void StringPathAppend(std::wstring* path, const std::wstring& more) 73 | { 74 | if (path->back() != _T(DIR_SEP_CHR)) 75 | path->push_back(_T(DIR_SEP_CHR)); 76 | 77 | path->append(more); 78 | } 79 | 80 | inline bool FileExists(const std::string& path) 81 | { 82 | FILE* filep; 83 | if (fopen_s(&filep, path.c_str(), "rb") == 0 && filep != 0) 84 | { 85 | fclose(filep); 86 | return true; 87 | } 88 | return false; 89 | } 90 | 91 | inline std::string ModulePathA(HMODULE hModule) 92 | { 93 | std::unique_ptr buffer(new char[MAX_PATH]); 94 | if (GetModuleFileNameA(hModule, buffer.get(), MAX_PATH)) 95 | { 96 | std::string res = buffer.get(); 97 | return std::move(res); 98 | } 99 | return ""; 100 | } 101 | 102 | inline std::wstring ModulePathW(HMODULE hModule) 103 | { 104 | std::unique_ptr buffer(new wchar_t[MAX_PATH]); 105 | if (GetModuleFileNameW(hModule, buffer.get(), MAX_PATH)) 106 | { 107 | std::wstring res = buffer.get(); 108 | return std::move(res); 109 | } 110 | return L""; 111 | } 112 | 113 | inline std::string ModuleDirectoryA(HMODULE hModule) 114 | { 115 | std::unique_ptr buffer(new char[MAX_PATH]); 116 | if (GetModuleFileNameA(hModule, buffer.get(), MAX_PATH)) 117 | { 118 | RemoveFileSpec(buffer.get()); 119 | 120 | std::string res = buffer.get(); 121 | return std::move(res); 122 | } 123 | return ""; 124 | } 125 | 126 | inline std::wstring ModuleDirectoryW(HMODULE hModule) 127 | { 128 | std::unique_ptr buffer(new wchar_t[MAX_PATH]); 129 | if (GetModuleFileNameW(hModule, buffer.get(), MAX_PATH)) 130 | { 131 | RemoveFileSpec(buffer.get()); 132 | 133 | std::wstring res = buffer.get(); 134 | return std::move(res); 135 | } 136 | return L""; 137 | } 138 | 139 | inline std::string ModuleNameA(HMODULE hModule) 140 | { 141 | std::unique_ptr buffer(new char[MAX_PATH]); 142 | if (GetModuleFileNameA(hModule, buffer.get(), MAX_PATH)) 143 | { 144 | RemovePath(buffer.get()); 145 | 146 | std::string res = buffer.get(); 147 | return std::move(res); 148 | } 149 | return ""; 150 | } 151 | 152 | inline std::wstring ModuleNameW(HMODULE hModule) 153 | { 154 | std::unique_ptr buffer(new wchar_t[MAX_PATH]); 155 | if (GetModuleFileNameW(hModule, buffer.get(), MAX_PATH)) 156 | { 157 | RemovePath(buffer.get()); 158 | 159 | std::wstring res = buffer.get(); 160 | return std::move(res); 161 | } 162 | return L""; 163 | } 164 | 165 | inline std::string CreateSystemModulePath(const char* module_name) 166 | { 167 | std::unique_ptr buffer(new char[MAX_PATH]); 168 | GetSystemDirectoryA(buffer.get(), MAX_PATH); 169 | 170 | std::string path(buffer.get()); 171 | StringPathAppend(&path, module_name); 172 | 173 | return std::move(path); 174 | } 175 | 176 | inline std::wstring CreateSystemModulePath(const wchar_t* module_name) 177 | { 178 | std::unique_ptr buffer(new wchar_t[MAX_PATH]); 179 | GetSystemDirectoryW(buffer.get(), MAX_PATH); 180 | 181 | std::wstring path(buffer.get()); 182 | StringPathAppend(&path, module_name); 183 | 184 | return std::move(path); 185 | } 186 | 187 | inline HMODULE LoadLibraryFromDirectory(const char* dir, const char* module_name) 188 | { 189 | std::string path(dir); 190 | StringPathAppend(&path, module_name); 191 | return LoadLibraryA(path.c_str()); 192 | } 193 | 194 | inline HMODULE LoadLibraryFromSystemDir(const char* module_name) 195 | { 196 | std::unique_ptr buffer(new char[MAX_PATH]); 197 | GetSystemDirectoryA(buffer.get(), MAX_PATH); 198 | return LoadLibraryFromDirectory(buffer.get(), module_name); 199 | } 200 | 201 | inline std::string FullPathFromPath(const std::string& path) 202 | { 203 | // check it already full path 204 | if (path[1] == ':' || path[1] == '?') 205 | return path; 206 | 207 | std::string out_path = ModuleDirectoryA(CurrentModule()); 208 | 209 | if (out_path.back() != '\\' && path.front() != '\\') 210 | out_path.push_back('\\'); 211 | 212 | std::string res = out_path + path; 213 | return std::move(res); 214 | } 215 | 216 | inline void StringToGUID(GUID* id, const std::string& szBuf) 217 | { 218 | const char* p = szBuf.c_str(); 219 | if (strchr(p, '{')) p++; 220 | 221 | u32 d1; 222 | s32 d2, d3; 223 | s32 b[8]; 224 | 225 | if (sscanf_s(p, "%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", 226 | &d1, &d2, &d3, &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], &b[6], &b[7]) != 11) 227 | { 228 | *id = GUID_NULL; 229 | return; 230 | } 231 | 232 | id->Data1 = d1; 233 | id->Data2 = (u16)d2; 234 | id->Data3 = (u16)d3; 235 | 236 | for (int i = 0; i < 8; ++i) 237 | id->Data4[i] = (u8)b[i]; 238 | } 239 | 240 | inline void StringToGUID(GUID* id, const std::wstring& szBuf) 241 | { 242 | const wchar_t* p = szBuf.c_str(); 243 | if (wcschr(p, L'{')) p++; 244 | 245 | u32 d1; 246 | s32 d2, d3; 247 | s32 b[8]; 248 | 249 | if (swscanf_s(p, L"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", 250 | &d1, &d2, &d3, &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], &b[6], &b[7]) != 11) 251 | { 252 | *id = GUID_NULL; 253 | return; 254 | } 255 | 256 | id->Data1 = d1; 257 | id->Data2 = (u16)d2; 258 | id->Data3 = (u16)d3; 259 | 260 | for (int i = 0; i < 8; ++i) 261 | id->Data4[i] = (u8)b[i]; 262 | } 263 | 264 | inline std::string GUIDtoStringA(const GUID &g) 265 | { 266 | std::unique_ptr buffer(new char[40]); 267 | sprintf_s(buffer.get(), 40, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", 268 | g.Data1, g.Data2, g.Data3, g.Data4[0], g.Data4[1], g.Data4[2], g.Data4[3], g.Data4[4], g.Data4[5], g.Data4[6], g.Data4[7]); 269 | 270 | return buffer.get(); 271 | } 272 | 273 | inline std::wstring GUIDtoStringW(const GUID &g) 274 | { 275 | std::unique_ptr buffer(new wchar_t[40]); 276 | swprintf_s(buffer.get(), 40, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", 277 | g.Data1, g.Data2, g.Data3, g.Data4[0], g.Data4[1], g.Data4[2], g.Data4[3], g.Data4[4], g.Data4[5], g.Data4[6], g.Data4[7]); 278 | 279 | return buffer.get(); 280 | } 281 | 282 | 283 | -------------------------------------------------------------------------------- /Common/WinVer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | inline BOOL EqualsMajorVersion(DWORD majorVersion) 8 | { 9 | OSVERSIONINFOEX osVersionInfo; 10 | ::ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFOEX)); 11 | osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 12 | osVersionInfo.dwMajorVersion = majorVersion; 13 | ULONGLONG maskCondition = ::VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL); 14 | return ::VerifyVersionInfo(&osVersionInfo, VER_MAJORVERSION, maskCondition); 15 | } 16 | 17 | inline BOOL EqualsMinorVersion(DWORD minorVersion) 18 | { 19 | OSVERSIONINFOEX osVersionInfo; 20 | ::ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFOEX)); 21 | osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 22 | osVersionInfo.dwMinorVersion = minorVersion; 23 | ULONGLONG maskCondition = ::VerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL); 24 | return ::VerifyVersionInfo(&osVersionInfo, VER_MINORVERSION, maskCondition); 25 | } 26 | 27 | inline BOOL EqualsServicePack(WORD servicePackMajor) 28 | { 29 | OSVERSIONINFOEX osVersionInfo; 30 | ::ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFOEX)); 31 | osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 32 | osVersionInfo.wServicePackMajor = servicePackMajor; 33 | ULONGLONG maskCondition = ::VerSetConditionMask(0, VER_SERVICEPACKMAJOR, VER_EQUAL); 34 | return ::VerifyVersionInfo(&osVersionInfo, VER_SERVICEPACKMAJOR, maskCondition); 35 | } 36 | 37 | inline BOOL EqualsProductType(BYTE productType) 38 | { 39 | OSVERSIONINFOEX osVersionInfo; 40 | ::ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFOEX)); 41 | osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 42 | osVersionInfo.wProductType = productType; 43 | ULONGLONG maskCondition = ::VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL); 44 | return ::VerifyVersionInfo(&osVersionInfo, VER_PRODUCT_TYPE, maskCondition); 45 | } 46 | 47 | inline BYTE GetProductType() 48 | { 49 | if (EqualsProductType(VER_NT_WORKSTATION)) 50 | { 51 | return VER_NT_WORKSTATION; 52 | } 53 | else if (EqualsProductType(VER_NT_SERVER)) 54 | { 55 | return VER_NT_SERVER; 56 | } 57 | return 0; 58 | } 59 | 60 | typedef BOOL(WINAPI* GetVersionExA_t) (OSVERSIONINFOEXA* lpVersionInformation); 61 | typedef BOOL(WINAPI* GetProductInfo_t)(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType); 62 | 63 | inline BOOL MyGetVersionExA(OSVERSIONINFOEXA* lpVersionInformation) 64 | { 65 | GetVersionExA_t RealGetVersionExA = (GetVersionExA_t)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetVersionExA"); 66 | if (!RealGetVersionExA) return FALSE; 67 | return RealGetVersionExA(lpVersionInformation); 68 | } 69 | 70 | inline BOOL MyGetProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType) 71 | { 72 | GetProductInfo_t RealGetProductInfo = (GetProductInfo_t)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); 73 | if (!RealGetProductInfo) return FALSE; 74 | return RealGetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType); 75 | } 76 | 77 | inline bool GetWindowsVersionName(std::string* out) 78 | { 79 | if (!out) return false; 80 | 81 | *out = "Microsoft "; 82 | 83 | BYTE dwType = GetProductType(); 84 | DWORD dwSubType = 0; 85 | 86 | SYSTEM_INFO si; 87 | ZeroMemory(&si, sizeof(SYSTEM_INFO)); 88 | GetNativeSystemInfo(&si); 89 | 90 | if (EqualsMajorVersion(6) && EqualsMinorVersion(3)) 91 | { 92 | MyGetProductInfo(6, 3, 0, 0, &dwSubType); 93 | 94 | if (dwType == VER_NT_WORKSTATION) 95 | { 96 | out->append("Windows 8.1"); 97 | if (dwSubType == PRODUCT_PROFESSIONAL) 98 | out->append(" Pro"); 99 | } 100 | else if (dwType == VER_NT_SERVER) 101 | { 102 | out->append("Windows Server 2012 R2"); 103 | } 104 | } 105 | else if (EqualsMajorVersion(6) && EqualsMinorVersion(2)) 106 | { 107 | MyGetProductInfo(6, 2, 0, 0, &dwSubType); 108 | 109 | if (dwType == VER_NT_WORKSTATION) 110 | { 111 | out->append("Windows 8"); 112 | if (dwSubType == PRODUCT_PROFESSIONAL) 113 | out->append(" Pro"); 114 | } 115 | else if (dwType == VER_NT_SERVER) 116 | { 117 | out->append("Windows Server 2012"); 118 | } 119 | } 120 | else // older than Windows 8 use GetVersionExA 121 | { 122 | OSVERSIONINFOEXA osvi; 123 | ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXA)); 124 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); 125 | MyGetVersionExA(&osvi); 126 | 127 | if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1) 128 | { 129 | MyGetProductInfo(6, 1, 0, 0, &dwSubType); 130 | 131 | if (dwType == VER_NT_WORKSTATION) 132 | out->append("Windows 7"); 133 | else out->append("Windows Server 2008 R2"); 134 | 135 | switch (dwSubType) 136 | { 137 | case PRODUCT_ULTIMATE: 138 | out->append(" Ultimate Edition"); 139 | break; 140 | case PRODUCT_PROFESSIONAL: 141 | out->append(" Professional"); 142 | break; 143 | case PRODUCT_HOME_PREMIUM: 144 | out->append(" Home Premium Edition"); 145 | break; 146 | case PRODUCT_HOME_BASIC: 147 | out->append(" Home Basic Edition"); 148 | break; 149 | case PRODUCT_ENTERPRISE: 150 | out->append(" Enterprise Edition"); 151 | break; 152 | case PRODUCT_BUSINESS: 153 | out->append(" Business Edition"); 154 | break; 155 | case PRODUCT_STARTER: 156 | out->append(" Starter Edition"); 157 | break; 158 | } 159 | } 160 | else if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) 161 | { 162 | if (dwType == VER_NT_WORKSTATION) 163 | out->append("Windows Vista"); 164 | else out->append("Windows Server 2008"); 165 | } 166 | else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) 167 | { 168 | 169 | if (GetSystemMetrics(SM_SERVERR2)) 170 | out->append("Windows Server 2003 R2"); 171 | else if (osvi.wSuiteMask & VER_SUITE_STORAGE_SERVER) 172 | out->append("Windows Storage Server 2003"); 173 | else if (osvi.wSuiteMask & VER_SUITE_WH_SERVER) 174 | out->append("Windows Home Server"); 175 | else if (osvi.wProductType == VER_NT_WORKSTATION && 176 | si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) 177 | { 178 | out->append("Windows XP Professional x64 Edition"); 179 | } 180 | else out->append("Windows Server 2003 "); 181 | } 182 | else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) 183 | { 184 | out->append("Windows XP"); 185 | if (osvi.wSuiteMask & VER_SUITE_PERSONAL) 186 | out->append(" Home Edition"); 187 | else out->append(" Professional"); 188 | } 189 | 190 | } 191 | if (EqualsMajorVersion(6)) 192 | { 193 | if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) 194 | out->append(" (x64)"); 195 | else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) 196 | out->append(" (x86)"); 197 | } 198 | 199 | return true; 200 | } -------------------------------------------------------------------------------- /MinHook/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Windows-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = crlf 9 | insert_final_newline = true 10 | 11 | # 4 space indentation 12 | [*.{c,h,def}] 13 | indent_style = space 14 | indent_size = 4 15 | 16 | # Trim trailing whitespaces 17 | [*.{c,h,def,txt}] 18 | trim_trailing_whitespace = true 19 | 20 | # UTF-8 with BOM 21 | [*.{c,h,def,txt}] 22 | charset=utf-8-bom 23 | -------------------------------------------------------------------------------- /MinHook/.gitignore: -------------------------------------------------------------------------------- 1 | #OS junk files 2 | [Tt]humbs.db 3 | *.DS_Store 4 | 5 | #Visual Studio files 6 | *.[Oo]bj 7 | *.user 8 | *.aps 9 | *.pch 10 | *.vspscc 11 | *.vssscc 12 | *_i.c 13 | *_p.c 14 | *.ncb 15 | *.suo 16 | *.tlb 17 | *.tlh 18 | *.bak 19 | *.[Cc]ache 20 | *.ilk 21 | *.log 22 | *.sbr 23 | *.sdf 24 | *.opensdf 25 | *.unsuccessfulbuild 26 | ipch/ 27 | obj/ 28 | [Ll]ib 29 | [Bb]in 30 | [Dd]ebug*/ 31 | [Rr]elease*/ 32 | Ankh.NoLoad 33 | *.VC.db 34 | 35 | #GCC files 36 | *.o 37 | *.d 38 | *.res 39 | *.dll 40 | *.a 41 | 42 | #Visual Studio Code files 43 | .vscode/ 44 | -------------------------------------------------------------------------------- /MinHook/AUTHORS.txt: -------------------------------------------------------------------------------- 1 | Tsuda Kageyu 2 | Creator, maintainer 3 | 4 | Michael Maltsev 5 | Added "Queue" functions. A lot of bug fixes. 6 | 7 | Andrey Unis 8 | Rewrote the hook engine in plain C. 9 | -------------------------------------------------------------------------------- /MinHook/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MinHook - The Minimalistic API Hooking Library for x64/x86 2 | Copyright (C) 2009-2017 Tsuda Kageyu. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 18 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ================================================================================ 28 | Portions of this software are Copyright (c) 2008-2009, Vyacheslav Patkov. 29 | ================================================================================ 30 | Hacker Disassembler Engine 32 C 31 | Copyright (c) 2008-2009, Vyacheslav Patkov. 32 | All rights reserved. 33 | 34 | Redistribution and use in source and binary forms, with or without 35 | modification, are permitted provided that the following conditions 36 | are met: 37 | 38 | 1. Redistributions of source code must retain the above copyright 39 | notice, this list of conditions and the following disclaimer. 40 | 2. Redistributions in binary form must reproduce the above copyright 41 | notice, this list of conditions and the following disclaimer in the 42 | documentation and/or other materials provided with the distribution. 43 | 44 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 45 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 46 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 47 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 48 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 49 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 50 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 51 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 52 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 53 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 54 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 | 56 | ------------------------------------------------------------------------------- 57 | Hacker Disassembler Engine 64 C 58 | Copyright (c) 2008-2009, Vyacheslav Patkov. 59 | All rights reserved. 60 | 61 | Redistribution and use in source and binary forms, with or without 62 | modification, are permitted provided that the following conditions 63 | are met: 64 | 65 | 1. Redistributions of source code must retain the above copyright 66 | notice, this list of conditions and the following disclaimer. 67 | 2. Redistributions in binary form must reproduce the above copyright 68 | notice, this list of conditions and the following disclaimer in the 69 | documentation and/or other materials provided with the distribution. 70 | 71 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 72 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 73 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 74 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 75 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 76 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 77 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 78 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 79 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 80 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 81 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 82 | -------------------------------------------------------------------------------- /MinHook/README.md: -------------------------------------------------------------------------------- 1 | # MinHook 2 | 3 | [![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause) 4 | 5 | The Minimalistic x86/x64 API Hooking Library for Windows 6 | 7 | http://www.codeproject.com/KB/winsdk/LibMinHook.aspx 8 | 9 | ### Donation please 10 | 11 | I need some funds to continue developing this library. All contributions gratefully accepted. 12 | 13 | Click here to lend your support to: MinHook - Help me continue to develop this library and make a donation at pledgie.com ! 14 | 15 | ### Version history 16 | 17 | - ####v1.3.3 - 8 Jan 2017 18 | * Added a helper function ```MH_CreateHookApiEx```. (Thanks to asm256) 19 | * Support Visual Studio 2017 RC. 20 | 21 | - ####v1.3.2.1 - 9 Nov 2015 (Nuget package only) 22 | * Fixed an insufficient support for Visual Studio 2015. 23 | 24 | - ####v1.3.2 - 1 Nov 2015 25 | * Support Visual Studio 2015. 26 | * Support MinGW. 27 | 28 | - ####v1.3.2-beta3 - 21 Jul 2015 (Nuget package only) 29 | * Support MinGW. (Experimental) 30 | 31 | - ####v1.3.2-beta2 - 18 May 2015 32 | * Fixed some subtle bugs. (Thanks to RaMMicHaeL) 33 | * Added a helper function ```MH_StatusToString```. (Thanks to Jan Klass) 34 | 35 | - ####v1.3.2-beta - 12 May 2015 36 | * Fixed a possible thread deadlock in x64 mode. (Thanks to Aleh Kazakevich) 37 | * Reduced the footprint a little more. 38 | * Support Visual Studio 2015 RC. (Experimental) 39 | 40 | - ####v1.3.1.1 - 7 Apr 2015 (Nuget package only) 41 | * Support for WDK8.0 and 8.1. 42 | 43 | - ####v1.3.1 - 19 Mar 2015 44 | * No major changes from v1.3.1-beta. 45 | 46 | - ####v1.3.1-beta - 11 Mar 2015 47 | * Added a helper function ```MH_CreateHookApi```. (Thanks to uniskz). 48 | * Fixed a false memory leak reported by some tools. 49 | * Fixed a degradated compatibility issue. 50 | 51 | - ####v1.3 - 13 Sep 2014 52 | * No major changes from v1.3-beta3. 53 | 54 | - ####v1.3-beta3 - 31 Jul 2014 55 | 56 | * Fixed some small bugs. 57 | * Improved the memory management. 58 | 59 | - ####v1.3-beta2 - 21 Jul 2014 60 | 61 | * Changed the parameters to Windows-friendly types. (void* to LPVOID) 62 | * Fixed some small bugs. 63 | * Reorganized the source files. 64 | * Reduced the footprint a little more. 65 | 66 | - ####v1.3-beta - 17 Jul 2014 67 | 68 | * Rewrote in plain C to reduce the footprint and memory usage. (suggested by Andrey Unis) 69 | * Simplified the overall code base to make it more readable and maintainable. 70 | * Changed the license from 3-clause to 2-clause BSD License. 71 | 72 | - ####v1.2 - 28 Sep 2013 73 | 74 | * Removed boost dependency ([jarredholman](https://github.com/jarredholman/minhook)). 75 | * Fixed a small bug in the GetRelativeBranchDestination function ([pillbug99](http://www.codeproject.com/Messages/4058892/Small-Bug-Found.aspx)). 76 | * Added the ```MH_RemoveHook``` function, which removes a hook created with the ```MH_CreateHook``` function. 77 | * Added the following functions to enable or disable multiple hooks in one go: ```MH_QueueEnableHook```, ```MH_QueueDisableHook```, ```MH_ApplyQueued```. This is the preferred way of handling multiple hooks as every call to `MH_EnableHook` or `MH_DisableHook` suspends and resumes all threads. 78 | * Made the functions ```MH_EnableHook``` and ```MH_DisableHook``` enable/disable all created hooks when the ```MH_ALL_HOOKS``` parameter is passed. This, too, is an efficient way of handling multiple hooks. 79 | * If the target function is too small to be patched with a jump, MinHook tries to place the jump above the function. If that fails as well, the ```MH_CreateHook``` function returns ```MH_ERROR_UNSUPPORTED_FUNCTION```. This fixes an issue of hooking the LoadLibraryExW function on Windows 7 x64 ([reported by Obble](http://www.codeproject.com/Messages/4578613/Re-Bug-LoadLibraryExW-hook-fails-on-windows-2008-r.aspx)). 80 | 81 | - ####v1.1 - 26 Nov 2009 82 | 83 | * Changed the interface to create a hook and a trampoline function in one go to prevent the detour function from being called before the trampoline function is created. ([reported by xliqz](http://www.codeproject.com/Messages/3280374/Unsafe.aspx)) 84 | * Shortened the function names from ```MinHook_*``` to ```MH_*``` to make them handier. 85 | 86 | - ####v1.0 - 22 Nov 2009 87 | 88 | * Initial release. 89 | -------------------------------------------------------------------------------- /MinHook/build/MinGW/Makefile: -------------------------------------------------------------------------------- 1 | WINDRES:=$(CROSS_PREFIX)windres 2 | DLLTOOL:=$(CROSS_PREFIX)dlltool 3 | AR:=$(CROSS_PREFIX)ar 4 | CC:=$(CROSS_PREFIX)gcc 5 | CCLD:=$(CC) 6 | SRCS:=$(wildcard src/*.c src/hde/*.c) 7 | OBJS:=$(SRCS:%.c=%.o) 8 | DEPS:=$(SRCS:%.c=%.d) 9 | INCS:=-Isrc -Iinclude 10 | CFLAGS:=-masm=intel -Wall -Werror -std=c11 11 | LDFLAGS:=-Wl,-enable-stdcall-fixup -s -static-libgcc 12 | 13 | all: MinHook.dll libMinHook.dll.a libMinHook.a 14 | 15 | -include $(DEPS) 16 | 17 | libMinHook.a: $(OBJS) 18 | $(AR) r $@ $^ 19 | libMinHook.dll.a: MinHook.dll dll_resources/MinHook.def 20 | $(DLLTOOL) --dllname MinHook.dll --def dll_resources/MinHook.def --output-lib $@ 21 | MinHook.dll: $(OBJS) dll_resources/MinHook.res dll_resources/MinHook.def 22 | $(CCLD) -o $@ -shared $(LDFLAGS) $^ 23 | 24 | .rc.res: 25 | $(WINDRES) -o $@ --input-format=rc --output-format=coff $< 26 | .c.o: 27 | $(CC) -o $@ -c -MMD -MP $(INCS) $(CFLAGS) $< 28 | 29 | clean: 30 | rm -f $(OBJS) $(DEPS) MinHook.dll libMinHook.dll.a libMinHook.a dll_resources/MinHook.res 31 | 32 | .PHONY: clean 33 | .SUFFIXES: .rc .res 34 | -------------------------------------------------------------------------------- /MinHook/build/MinGW/make.bat: -------------------------------------------------------------------------------- 1 | windres -i ../../dll_resources/MinHook.rc -o MinHook_rc.o && dllwrap --driver-name g++ -o MinHook.dll -masm=intel --def ../../dll_resources/MinHook.def -Wl,-enable-stdcall-fixup -Wall MinHook_rc.o ../../src/*.c ../../src/HDE/*.c -I../../include -I../../src -Werror -std=c++11 -s -static-libgcc -static-libstdc++|| pause -------------------------------------------------------------------------------- /MinHook/build/VC10/MinHookVC10.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinHook", "MinHook.vcxproj", "{027FAC75-3FDB-4044-8DD0-BC297BD4C461}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Debug|x64 = Debug|x64 15 | Release|Win32 = Release|Win32 16 | Release|x64 = Release|x64 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.ActiveCfg = Debug|Win32 20 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.Build.0 = Debug|Win32 21 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64 23 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.ActiveCfg = Release|Win32 24 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.Build.0 = Release|Win32 25 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64 26 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64 27 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.Build.0 = Debug|Win32 29 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.ActiveCfg = Debug|x64 30 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.Build.0 = Debug|x64 31 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.ActiveCfg = Release|Win32 32 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.Build.0 = Release|Win32 33 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.ActiveCfg = Release|x64 34 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.Build.0 = Release|x64 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /MinHook/build/VC10/libMinHook.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 23 | libMinHook 24 | Win32Proj 25 | 26 | 27 | 28 | StaticLibrary 29 | Unicode 30 | true 31 | 32 | 33 | StaticLibrary 34 | Unicode 35 | 36 | 37 | StaticLibrary 38 | Unicode 39 | true 40 | 41 | 42 | StaticLibrary 43 | Unicode 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | <_ProjectFileVersion>10.0.40219.1 63 | $(SolutionDir)lib\$(Configuration)\ 64 | $(Platform)\$(Configuration)\$(ProjectName)\ 65 | $(SolutionDir)lib\$(Configuration)\ 66 | $(Platform)\$(Configuration)\$(ProjectName)\ 67 | $(SolutionDir)lib\$(Configuration)\ 68 | $(Platform)\$(Configuration)\$(ProjectName)\ 69 | $(SolutionDir)lib\$(Configuration)\ 70 | $(Platform)\$(Configuration)\$(ProjectName)\ 71 | $(ProjectName).x86 72 | $(ProjectName).x86 73 | $(ProjectName).x64 74 | $(ProjectName).x64 75 | 76 | 77 | 78 | Disabled 79 | %(AdditionalIncludeDirectories) 80 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 81 | false 82 | EnableFastChecks 83 | MultiThreadedDebug 84 | Level3 85 | 86 | 87 | false 88 | 89 | 90 | 91 | 92 | 93 | X64 94 | 95 | 96 | Disabled 97 | %(AdditionalIncludeDirectories) 98 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 99 | false 100 | EnableFastChecks 101 | MultiThreadedDebug 102 | Level3 103 | 104 | 105 | false 106 | 107 | 108 | 109 | 110 | 111 | MinSpace 112 | true 113 | %(AdditionalIncludeDirectories) 114 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 115 | false 116 | MultiThreaded 117 | true 118 | Level3 119 | 120 | 121 | true 122 | AnySuitable 123 | 124 | 125 | 126 | 127 | 128 | X64 129 | 130 | 131 | MinSpace 132 | true 133 | %(AdditionalIncludeDirectories) 134 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 135 | false 136 | MultiThreaded 137 | true 138 | Level3 139 | 140 | 141 | true 142 | AnySuitable 143 | 144 | 145 | 146 | 147 | 148 | 149 | true 150 | true 151 | 152 | 153 | true 154 | true 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /MinHook/build/VC10/libMinHook.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | HDE 15 | 16 | 17 | HDE 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | HDE 30 | 31 | 32 | HDE 33 | 34 | 35 | HDE 36 | 37 | 38 | HDE 39 | 40 | 41 | HDE 42 | 43 | 44 | 45 | 46 | {9d24b740-be2e-4cfd-b9a4-340a50946ee9} 47 | 48 | 49 | {76381bc7-2863-4cc5-aede-926ec2c506e4} 50 | 51 | 52 | {56ddb326-6179-430d-ae19-e13bfd767bfa} 53 | 54 | 55 | -------------------------------------------------------------------------------- /MinHook/build/VC11/MinHookVC11.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinHook", "MinHook.vcxproj", "{027FAC75-3FDB-4044-8DD0-BC297BD4C461}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Debug|x64 = Debug|x64 15 | Release|Win32 = Release|Win32 16 | Release|x64 = Release|x64 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.ActiveCfg = Debug|Win32 20 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.Build.0 = Debug|Win32 21 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64 23 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.ActiveCfg = Release|Win32 24 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.Build.0 = Release|Win32 25 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64 26 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64 27 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.Build.0 = Debug|Win32 29 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.ActiveCfg = Debug|x64 30 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.Build.0 = Debug|x64 31 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.ActiveCfg = Release|Win32 32 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.Build.0 = Release|Win32 33 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.ActiveCfg = Release|x64 34 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.Build.0 = Release|x64 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /MinHook/build/VC11/libMinHook.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 23 | libMinHook 24 | Win32Proj 25 | 26 | 27 | 28 | StaticLibrary 29 | Unicode 30 | true 31 | v110_xp 32 | 33 | 34 | StaticLibrary 35 | Unicode 36 | v110_xp 37 | 38 | 39 | StaticLibrary 40 | Unicode 41 | true 42 | v110_xp 43 | 44 | 45 | StaticLibrary 46 | Unicode 47 | v110_xp 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | <_ProjectFileVersion>10.0.40219.1 67 | $(SolutionDir)lib\$(Configuration)\ 68 | $(Platform)\$(Configuration)\$(ProjectName)\ 69 | $(SolutionDir)lib\$(Configuration)\ 70 | $(Platform)\$(Configuration)\$(ProjectName)\ 71 | $(SolutionDir)lib\$(Configuration)\ 72 | $(Platform)\$(Configuration)\$(ProjectName)\ 73 | $(SolutionDir)lib\$(Configuration)\ 74 | $(Platform)\$(Configuration)\$(ProjectName)\ 75 | $(ProjectName).x86 76 | $(ProjectName).x86 77 | $(ProjectName).x64 78 | $(ProjectName).x64 79 | 80 | 81 | 82 | Disabled 83 | %(AdditionalIncludeDirectories) 84 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 85 | false 86 | EnableFastChecks 87 | MultiThreadedDebug 88 | Level3 89 | None 90 | NoExtensions 91 | 92 | 93 | 94 | 95 | 96 | X64 97 | 98 | 99 | Disabled 100 | %(AdditionalIncludeDirectories) 101 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 102 | false 103 | EnableFastChecks 104 | MultiThreadedDebug 105 | Level3 106 | None 107 | 108 | 109 | 110 | 111 | 112 | MinSpace 113 | true 114 | %(AdditionalIncludeDirectories) 115 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 116 | false 117 | MultiThreaded 118 | true 119 | Level3 120 | None 121 | true 122 | AnySuitable 123 | NoExtensions 124 | 125 | 126 | 127 | 128 | 129 | X64 130 | 131 | 132 | MinSpace 133 | true 134 | %(AdditionalIncludeDirectories) 135 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 136 | false 137 | MultiThreaded 138 | true 139 | Level3 140 | None 141 | true 142 | AnySuitable 143 | 144 | 145 | 146 | 147 | 148 | 149 | true 150 | true 151 | 152 | 153 | true 154 | true 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /MinHook/build/VC11/libMinHook.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | HDE 15 | 16 | 17 | HDE 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | HDE 30 | 31 | 32 | HDE 33 | 34 | 35 | HDE 36 | 37 | 38 | HDE 39 | 40 | 41 | HDE 42 | 43 | 44 | 45 | 46 | {9d24b740-be2e-4cfd-b9a4-340a50946ee9} 47 | 48 | 49 | {76381bc7-2863-4cc5-aede-926ec2c506e4} 50 | 51 | 52 | {56ddb326-6179-430d-ae19-e13bfd767bfa} 53 | 54 | 55 | -------------------------------------------------------------------------------- /MinHook/build/VC12/MinHookVC12.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinHook", "MinHook.vcxproj", "{027FAC75-3FDB-4044-8DD0-BC297BD4C461}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.Build.0 = Debug|Win32 23 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64 24 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64 25 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.ActiveCfg = Release|Win32 26 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.Build.0 = Release|Win32 27 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64 28 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64 29 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.Build.0 = Debug|Win32 31 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.ActiveCfg = Debug|x64 32 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.Build.0 = Debug|x64 33 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.ActiveCfg = Release|Win32 34 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.Build.0 = Release|Win32 35 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.ActiveCfg = Release|x64 36 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.Build.0 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /MinHook/build/VC12/libMinHook.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 23 | libMinHook 24 | Win32Proj 25 | 26 | 27 | 28 | StaticLibrary 29 | Unicode 30 | true 31 | v120_xp 32 | 33 | 34 | StaticLibrary 35 | Unicode 36 | v120_xp 37 | 38 | 39 | StaticLibrary 40 | Unicode 41 | true 42 | v120_xp 43 | 44 | 45 | StaticLibrary 46 | Unicode 47 | v120_xp 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | <_ProjectFileVersion>10.0.40219.1 67 | $(SolutionDir)lib\$(Configuration)\ 68 | $(Platform)\$(Configuration)\$(ProjectName)\ 69 | $(SolutionDir)lib\$(Configuration)\ 70 | $(Platform)\$(Configuration)\$(ProjectName)\ 71 | $(SolutionDir)lib\$(Configuration)\ 72 | $(Platform)\$(Configuration)\$(ProjectName)\ 73 | $(SolutionDir)lib\$(Configuration)\ 74 | $(Platform)\$(Configuration)\$(ProjectName)\ 75 | $(ProjectName).x86 76 | $(ProjectName).x86 77 | $(ProjectName).x64 78 | $(ProjectName).x64 79 | 80 | 81 | 82 | Disabled 83 | %(AdditionalIncludeDirectories) 84 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 85 | false 86 | EnableFastChecks 87 | MultiThreadedDebug 88 | Level3 89 | None 90 | NoExtensions 91 | 92 | 93 | 94 | 95 | 96 | X64 97 | 98 | 99 | Disabled 100 | %(AdditionalIncludeDirectories) 101 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 102 | false 103 | EnableFastChecks 104 | MultiThreadedDebug 105 | Level3 106 | None 107 | NotSet 108 | 109 | 110 | 111 | 112 | 113 | MinSpace 114 | true 115 | %(AdditionalIncludeDirectories) 116 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 117 | false 118 | MultiThreaded 119 | true 120 | Level3 121 | None 122 | AnySuitable 123 | CompileAsC 124 | true 125 | NoExtensions 126 | 127 | 128 | 129 | 130 | 131 | X64 132 | 133 | 134 | MinSpace 135 | true 136 | %(AdditionalIncludeDirectories) 137 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 138 | false 139 | MultiThreaded 140 | true 141 | Level3 142 | None 143 | true 144 | AnySuitable 145 | 146 | 147 | 148 | 149 | 150 | 151 | true 152 | true 153 | 154 | 155 | true 156 | true 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /MinHook/build/VC12/libMinHook.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | HDE 15 | 16 | 17 | HDE 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | HDE 30 | 31 | 32 | HDE 33 | 34 | 35 | HDE 36 | 37 | 38 | HDE 39 | 40 | 41 | HDE 42 | 43 | 44 | 45 | 46 | {9d24b740-be2e-4cfd-b9a4-340a50946ee9} 47 | 48 | 49 | {76381bc7-2863-4cc5-aede-926ec2c506e4} 50 | 51 | 52 | {56ddb326-6179-430d-ae19-e13bfd767bfa} 53 | 54 | 55 | -------------------------------------------------------------------------------- /MinHook/build/VC14/MinHookVC14.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.22823.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinHook", "MinHook.vcxproj", "{027FAC75-3FDB-4044-8DD0-BC297BD4C461}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.Build.0 = Debug|Win32 23 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64 24 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64 25 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.ActiveCfg = Release|Win32 26 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.Build.0 = Release|Win32 27 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64 28 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64 29 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.Build.0 = Debug|Win32 31 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.ActiveCfg = Debug|x64 32 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.Build.0 = Debug|x64 33 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.ActiveCfg = Release|Win32 34 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.Build.0 = Release|Win32 35 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.ActiveCfg = Release|x64 36 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.Build.0 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /MinHook/build/VC14/libMinHook.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 23 | libMinHook 24 | Win32Proj 25 | 26 | 27 | 28 | StaticLibrary 29 | Unicode 30 | true 31 | v140_xp 32 | 33 | 34 | StaticLibrary 35 | Unicode 36 | v140_xp 37 | 38 | 39 | StaticLibrary 40 | Unicode 41 | true 42 | v140_xp 43 | 44 | 45 | StaticLibrary 46 | Unicode 47 | v140_xp 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | <_ProjectFileVersion>10.0.40219.1 67 | $(SolutionDir)lib\$(Configuration)\ 68 | $(Platform)\$(Configuration)\$(ProjectName)\ 69 | $(SolutionDir)lib\$(Configuration)\ 70 | $(Platform)\$(Configuration)\$(ProjectName)\ 71 | $(SolutionDir)lib\$(Configuration)\ 72 | $(Platform)\$(Configuration)\$(ProjectName)\ 73 | $(SolutionDir)lib\$(Configuration)\ 74 | $(Platform)\$(Configuration)\$(ProjectName)\ 75 | $(ProjectName).x86 76 | $(ProjectName).x86 77 | $(ProjectName).x64 78 | $(ProjectName).x64 79 | 80 | 81 | 82 | Disabled 83 | %(AdditionalIncludeDirectories) 84 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 85 | false 86 | EnableFastChecks 87 | MultiThreadedDebug 88 | Level3 89 | None 90 | NoExtensions 91 | 92 | 93 | 94 | 95 | 96 | X64 97 | 98 | 99 | Disabled 100 | %(AdditionalIncludeDirectories) 101 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 102 | false 103 | EnableFastChecks 104 | MultiThreadedDebug 105 | Level3 106 | None 107 | NotSet 108 | 109 | 110 | 111 | 112 | 113 | MinSpace 114 | true 115 | %(AdditionalIncludeDirectories) 116 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 117 | false 118 | MultiThreaded 119 | true 120 | Level3 121 | None 122 | AnySuitable 123 | CompileAsC 124 | true 125 | NoExtensions 126 | 127 | 128 | 129 | 130 | 131 | X64 132 | 133 | 134 | MinSpace 135 | true 136 | %(AdditionalIncludeDirectories) 137 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 138 | false 139 | MultiThreaded 140 | true 141 | Level3 142 | None 143 | true 144 | AnySuitable 145 | 146 | 147 | 148 | 149 | 150 | 151 | true 152 | true 153 | 154 | 155 | true 156 | true 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /MinHook/build/VC14/libMinHook.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | HDE 15 | 16 | 17 | HDE 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | HDE 30 | 31 | 32 | HDE 33 | 34 | 35 | HDE 36 | 37 | 38 | HDE 39 | 40 | 41 | HDE 42 | 43 | 44 | 45 | 46 | {9d24b740-be2e-4cfd-b9a4-340a50946ee9} 47 | 48 | 49 | {76381bc7-2863-4cc5-aede-926ec2c506e4} 50 | 51 | 52 | {56ddb326-6179-430d-ae19-e13bfd767bfa} 53 | 54 | 55 | -------------------------------------------------------------------------------- /MinHook/build/VC15/MinHookVC15.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinHook", "MinHook.vcxproj", "{027FAC75-3FDB-4044-8DD0-BC297BD4C461}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Debug|x64 = Debug|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.ActiveCfg = Debug|Win32 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.Build.0 = Debug|Win32 23 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64 24 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64 25 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.ActiveCfg = Release|Win32 26 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.Build.0 = Release|Win32 27 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64 28 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64 29 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.Build.0 = Debug|Win32 31 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.ActiveCfg = Debug|x64 32 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.Build.0 = Debug|x64 33 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.ActiveCfg = Release|Win32 34 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.Build.0 = Release|Win32 35 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.ActiveCfg = Release|x64 36 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.Build.0 = Release|x64 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /MinHook/build/VC15/libMinHook.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 23 | libMinHook 24 | Win32Proj 25 | 10.0 26 | 27 | 28 | 29 | StaticLibrary 30 | Unicode 31 | true 32 | v142 33 | false 34 | 35 | 36 | StaticLibrary 37 | Unicode 38 | v142 39 | 40 | 41 | StaticLibrary 42 | Unicode 43 | true 44 | v142 45 | 46 | 47 | StaticLibrary 48 | Unicode 49 | v142 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | <_ProjectFileVersion>10.0.40219.1 69 | $(SolutionDir)lib\$(Configuration)\ 70 | $(Platform)\$(Configuration)\$(ProjectName)\ 71 | $(SolutionDir)lib\$(Configuration)\ 72 | $(Platform)\$(Configuration)\$(ProjectName)\ 73 | $(SolutionDir)lib\$(Configuration)\ 74 | $(Platform)\$(Configuration)\$(ProjectName)\ 75 | $(SolutionDir)lib\$(Configuration)\ 76 | $(Platform)\$(Configuration)\$(ProjectName)\ 77 | $(ProjectName).x86 78 | $(ProjectName).x86 79 | $(ProjectName).x64 80 | $(ProjectName).x64 81 | 82 | 83 | 84 | Disabled 85 | %(AdditionalIncludeDirectories) 86 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 87 | Level3 88 | None 89 | 90 | 91 | 92 | 93 | 94 | X64 95 | 96 | 97 | Disabled 98 | %(AdditionalIncludeDirectories) 99 | WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 100 | false 101 | EnableFastChecks 102 | MultiThreadedDebug 103 | Level3 104 | None 105 | NotSet 106 | 107 | 108 | 109 | 110 | 111 | MinSpace 112 | true 113 | %(AdditionalIncludeDirectories) 114 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 115 | false 116 | true 117 | Level3 118 | None 119 | AnySuitable 120 | CompileAsC 121 | true 122 | MultiThreaded 123 | 124 | 125 | 126 | 127 | 128 | X64 129 | 130 | 131 | MinSpace 132 | true 133 | %(AdditionalIncludeDirectories) 134 | WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions) 135 | false 136 | MultiThreaded 137 | true 138 | Level3 139 | None 140 | true 141 | AnySuitable 142 | 143 | 144 | 145 | 146 | 147 | 148 | true 149 | true 150 | 151 | 152 | true 153 | true 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /MinHook/build/VC15/libMinHook.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | HDE 15 | 16 | 17 | HDE 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | HDE 30 | 31 | 32 | HDE 33 | 34 | 35 | HDE 36 | 37 | 38 | HDE 39 | 40 | 41 | HDE 42 | 43 | 44 | 45 | 46 | {9d24b740-be2e-4cfd-b9a4-340a50946ee9} 47 | 48 | 49 | {76381bc7-2863-4cc5-aede-926ec2c506e4} 50 | 51 | 52 | {56ddb326-6179-430d-ae19-e13bfd767bfa} 53 | 54 | 55 | -------------------------------------------------------------------------------- /MinHook/build/VC9/MinHook.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 18 | 19 | 20 | 21 | 22 | 29 | 32 | 35 | 38 | 41 | 44 | 55 | 58 | 61 | 64 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 94 | 95 | 102 | 105 | 108 | 111 | 114 | 118 | 129 | 132 | 135 | 138 | 147 | 150 | 153 | 156 | 159 | 162 | 165 | 168 | 169 | 177 | 180 | 183 | 186 | 189 | 192 | 204 | 207 | 210 | 213 | 226 | 229 | 232 | 235 | 238 | 241 | 244 | 247 | 248 | 256 | 259 | 262 | 265 | 268 | 272 | 284 | 287 | 290 | 293 | 306 | 309 | 312 | 315 | 318 | 321 | 324 | 327 | 328 | 329 | 330 | 331 | 332 | 335 | 336 | 339 | 340 | 341 | 342 | 343 | 344 | -------------------------------------------------------------------------------- /MinHook/build/VC9/MinHookVC9.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "libMinHook.vcproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinHook", "MinHook.vcproj", "{027FAC75-3FDB-4044-8DD0-BC297BD4C461}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Win32 = Debug|Win32 14 | Debug|x64 = Debug|x64 15 | Release|Win32 = Release|Win32 16 | Release|x64 = Release|x64 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.ActiveCfg = Debug|Win32 20 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.Build.0 = Debug|Win32 21 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64 22 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64 23 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.ActiveCfg = Release|Win32 24 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.Build.0 = Release|Win32 25 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64 26 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64 27 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.Build.0 = Debug|Win32 29 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.ActiveCfg = Debug|x64 30 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.Build.0 = Debug|x64 31 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.ActiveCfg = Release|Win32 32 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.Build.0 = Release|Win32 33 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.ActiveCfg = Release|x64 34 | {027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.Build.0 = Release|x64 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /MinHook/build/VC9/libMinHook.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 18 | 19 | 20 | 21 | 22 | 29 | 32 | 35 | 38 | 41 | 44 | 56 | 59 | 62 | 65 | 69 | 72 | 75 | 78 | 81 | 84 | 85 | 92 | 95 | 98 | 101 | 104 | 108 | 121 | 124 | 127 | 130 | 134 | 137 | 140 | 143 | 146 | 149 | 150 | 158 | 161 | 164 | 167 | 170 | 173 | 189 | 192 | 195 | 198 | 202 | 205 | 208 | 211 | 214 | 217 | 218 | 226 | 229 | 232 | 235 | 238 | 242 | 258 | 261 | 264 | 267 | 271 | 274 | 277 | 280 | 283 | 286 | 287 | 288 | 289 | 290 | 291 | 296 | 299 | 300 | 303 | 306 | 310 | 311 | 314 | 318 | 319 | 320 | 323 | 324 | 325 | 330 | 333 | 334 | 337 | 338 | 339 | 342 | 345 | 349 | 352 | 353 | 357 | 360 | 361 | 362 | 365 | 366 | 369 | 373 | 376 | 377 | 381 | 384 | 385 | 386 | 389 | 390 | 393 | 394 | 397 | 398 | 401 | 402 | 403 | 406 | 407 | 408 | 409 | 410 | 411 | -------------------------------------------------------------------------------- /MinHook/dll_resources/MinHook.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | MH_Initialize 3 | MH_Uninitialize 4 | 5 | MH_CreateHook 6 | MH_CreateHookApi 7 | MH_CreateHookApiEx 8 | MH_RemoveHook 9 | MH_EnableHook 10 | MH_DisableHook 11 | MH_QueueEnableHook 12 | MH_QueueDisableHook 13 | MH_ApplyQueued 14 | MH_StatusToString 15 | -------------------------------------------------------------------------------- /MinHook/dll_resources/MinHook.rc: -------------------------------------------------------------------------------- 1 | 1 VERSIONINFO 2 | FILEVERSION 1,3,3,0 3 | PRODUCTVERSION 1,3,3,0 4 | FILEFLAGSMASK 0x17L 5 | #ifdef _DEBUG 6 | FILEFLAGS 0x1L 7 | #else 8 | FILEFLAGS 0x0L 9 | #endif 10 | FILEOS 0x4L 11 | FILETYPE 0x2L 12 | FILESUBTYPE 0x0L 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "040904b0" 17 | BEGIN 18 | VALUE "CompanyName", "Tsuda Kageyu" 19 | VALUE "FileDescription", "MinHook - The Minimalistic API Hook Library for x64/x86" 20 | VALUE "FileVersion", "1.3.3.0" 21 | VALUE "InternalName", "MinHookD" 22 | VALUE "LegalCopyright", "Copyright (C) 2009-2017 Tsuda Kageyu. All rights reserved." 23 | VALUE "LegalTrademarks", "Tsuda Kageyu" 24 | VALUE "ProductName", "MinHook DLL" 25 | VALUE "ProductVersion", "1.3.3.0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x409, 1200 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /MinHook/include/MinHook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__) 32 | #error MinHook supports only x86 and x64 systems. 33 | #endif 34 | 35 | #include 36 | 37 | // MinHook Error Codes. 38 | typedef enum MH_STATUS 39 | { 40 | // Unknown error. Should not be returned. 41 | MH_UNKNOWN = -1, 42 | 43 | // Successful. 44 | MH_OK = 0, 45 | 46 | // MinHook is already initialized. 47 | MH_ERROR_ALREADY_INITIALIZED, 48 | 49 | // MinHook is not initialized yet, or already uninitialized. 50 | MH_ERROR_NOT_INITIALIZED, 51 | 52 | // The hook for the specified target function is already created. 53 | MH_ERROR_ALREADY_CREATED, 54 | 55 | // The hook for the specified target function is not created yet. 56 | MH_ERROR_NOT_CREATED, 57 | 58 | // The hook for the specified target function is already enabled. 59 | MH_ERROR_ENABLED, 60 | 61 | // The hook for the specified target function is not enabled yet, or already 62 | // disabled. 63 | MH_ERROR_DISABLED, 64 | 65 | // The specified pointer is invalid. It points the address of non-allocated 66 | // and/or non-executable region. 67 | MH_ERROR_NOT_EXECUTABLE, 68 | 69 | // The specified target function cannot be hooked. 70 | MH_ERROR_UNSUPPORTED_FUNCTION, 71 | 72 | // Failed to allocate memory. 73 | MH_ERROR_MEMORY_ALLOC, 74 | 75 | // Failed to change the memory protection. 76 | MH_ERROR_MEMORY_PROTECT, 77 | 78 | // The specified module is not loaded. 79 | MH_ERROR_MODULE_NOT_FOUND, 80 | 81 | // The specified function is not found. 82 | MH_ERROR_FUNCTION_NOT_FOUND 83 | } 84 | MH_STATUS; 85 | 86 | // Can be passed as a parameter to MH_EnableHook, MH_DisableHook, 87 | // MH_QueueEnableHook or MH_QueueDisableHook. 88 | #define MH_ALL_HOOKS NULL 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | 94 | // Initialize the MinHook library. You must call this function EXACTLY ONCE 95 | // at the beginning of your program. 96 | MH_STATUS WINAPI MH_Initialize(VOID); 97 | 98 | // Uninitialize the MinHook library. You must call this function EXACTLY 99 | // ONCE at the end of your program. 100 | MH_STATUS WINAPI MH_Uninitialize(VOID); 101 | 102 | // Creates a Hook for the specified target function, in disabled state. 103 | // Parameters: 104 | // pTarget [in] A pointer to the target function, which will be 105 | // overridden by the detour function. 106 | // pDetour [in] A pointer to the detour function, which will override 107 | // the target function. 108 | // ppOriginal [out] A pointer to the trampoline function, which will be 109 | // used to call the original target function. 110 | // This parameter can be NULL. 111 | MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal); 112 | 113 | // Creates a Hook for the specified API function, in disabled state. 114 | // Parameters: 115 | // pszModule [in] A pointer to the loaded module name which contains the 116 | // target function. 117 | // pszTarget [in] A pointer to the target function name, which will be 118 | // overridden by the detour function. 119 | // pDetour [in] A pointer to the detour function, which will override 120 | // the target function. 121 | // ppOriginal [out] A pointer to the trampoline function, which will be 122 | // used to call the original target function. 123 | // This parameter can be NULL. 124 | MH_STATUS WINAPI MH_CreateHookApi( 125 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal); 126 | 127 | // Creates a Hook for the specified API function, in disabled state. 128 | // Parameters: 129 | // pszModule [in] A pointer to the loaded module name which contains the 130 | // target function. 131 | // pszTarget [in] A pointer to the target function name, which will be 132 | // overridden by the detour function. 133 | // pDetour [in] A pointer to the detour function, which will override 134 | // the target function. 135 | // ppOriginal [out] A pointer to the trampoline function, which will be 136 | // used to call the original target function. 137 | // This parameter can be NULL. 138 | // ppTarget [out] A pointer to the target function, which will be used 139 | // with other functions. 140 | // This parameter can be NULL. 141 | MH_STATUS WINAPI MH_CreateHookApiEx( 142 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget); 143 | 144 | // Removes an already created hook. 145 | // Parameters: 146 | // pTarget [in] A pointer to the target function. 147 | MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget); 148 | 149 | // Enables an already created hook. 150 | // Parameters: 151 | // pTarget [in] A pointer to the target function. 152 | // If this parameter is MH_ALL_HOOKS, all created hooks are 153 | // enabled in one go. 154 | MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget); 155 | 156 | // Disables an already created hook. 157 | // Parameters: 158 | // pTarget [in] A pointer to the target function. 159 | // If this parameter is MH_ALL_HOOKS, all created hooks are 160 | // disabled in one go. 161 | MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget); 162 | 163 | // Queues to enable an already created hook. 164 | // Parameters: 165 | // pTarget [in] A pointer to the target function. 166 | // If this parameter is MH_ALL_HOOKS, all created hooks are 167 | // queued to be enabled. 168 | MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget); 169 | 170 | // Queues to disable an already created hook. 171 | // Parameters: 172 | // pTarget [in] A pointer to the target function. 173 | // If this parameter is MH_ALL_HOOKS, all created hooks are 174 | // queued to be disabled. 175 | MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget); 176 | 177 | // Applies all queued changes in one go. 178 | MH_STATUS WINAPI MH_ApplyQueued(VOID); 179 | 180 | // Translates the MH_STATUS to its name as a string. 181 | const char * WINAPI MH_StatusToString(MH_STATUS status); 182 | 183 | #ifdef __cplusplus 184 | } 185 | #endif 186 | 187 | -------------------------------------------------------------------------------- /MinHook/src/HDE/hde32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 32 3 | * Copyright (c) 2006-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | * hde32.h: C/C++ header file 7 | * 8 | */ 9 | 10 | #ifndef _HDE32_H_ 11 | #define _HDE32_H_ 12 | 13 | /* stdint.h - C99 standard header 14 | * http://en.wikipedia.org/wiki/stdint.h 15 | * 16 | * if your compiler doesn't contain "stdint.h" header (for 17 | * example, Microsoft Visual C++), you can download file: 18 | * http://www.azillionmonkeys.com/qed/pstdint.h 19 | * and change next line to: 20 | * #include "pstdint.h" 21 | */ 22 | #include "pstdint.h" 23 | 24 | #define F_MODRM 0x00000001 25 | #define F_SIB 0x00000002 26 | #define F_IMM8 0x00000004 27 | #define F_IMM16 0x00000008 28 | #define F_IMM32 0x00000010 29 | #define F_DISP8 0x00000020 30 | #define F_DISP16 0x00000040 31 | #define F_DISP32 0x00000080 32 | #define F_RELATIVE 0x00000100 33 | #define F_2IMM16 0x00000800 34 | #define F_ERROR 0x00001000 35 | #define F_ERROR_OPCODE 0x00002000 36 | #define F_ERROR_LENGTH 0x00004000 37 | #define F_ERROR_LOCK 0x00008000 38 | #define F_ERROR_OPERAND 0x00010000 39 | #define F_PREFIX_REPNZ 0x01000000 40 | #define F_PREFIX_REPX 0x02000000 41 | #define F_PREFIX_REP 0x03000000 42 | #define F_PREFIX_66 0x04000000 43 | #define F_PREFIX_67 0x08000000 44 | #define F_PREFIX_LOCK 0x10000000 45 | #define F_PREFIX_SEG 0x20000000 46 | #define F_PREFIX_ANY 0x3f000000 47 | 48 | #define PREFIX_SEGMENT_CS 0x2e 49 | #define PREFIX_SEGMENT_SS 0x36 50 | #define PREFIX_SEGMENT_DS 0x3e 51 | #define PREFIX_SEGMENT_ES 0x26 52 | #define PREFIX_SEGMENT_FS 0x64 53 | #define PREFIX_SEGMENT_GS 0x65 54 | #define PREFIX_LOCK 0xf0 55 | #define PREFIX_REPNZ 0xf2 56 | #define PREFIX_REPX 0xf3 57 | #define PREFIX_OPERAND_SIZE 0x66 58 | #define PREFIX_ADDRESS_SIZE 0x67 59 | 60 | #pragma pack(push,1) 61 | 62 | typedef struct { 63 | uint8_t len; 64 | uint8_t p_rep; 65 | uint8_t p_lock; 66 | uint8_t p_seg; 67 | uint8_t p_66; 68 | uint8_t p_67; 69 | uint8_t opcode; 70 | uint8_t opcode2; 71 | uint8_t modrm; 72 | uint8_t modrm_mod; 73 | uint8_t modrm_reg; 74 | uint8_t modrm_rm; 75 | uint8_t sib; 76 | uint8_t sib_scale; 77 | uint8_t sib_index; 78 | uint8_t sib_base; 79 | union { 80 | uint8_t imm8; 81 | uint16_t imm16; 82 | uint32_t imm32; 83 | } imm; 84 | union { 85 | uint8_t disp8; 86 | uint16_t disp16; 87 | uint32_t disp32; 88 | } disp; 89 | uint32_t flags; 90 | } hde32s; 91 | 92 | #pragma pack(pop) 93 | 94 | #ifdef __cplusplus 95 | extern "C" { 96 | #endif 97 | 98 | /* __cdecl */ 99 | unsigned int hde32_disasm(const void *code, hde32s *hs); 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /* _HDE32_H_ */ 106 | -------------------------------------------------------------------------------- /MinHook/src/HDE/hde64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 64 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | * hde64.h: C/C++ header file 7 | * 8 | */ 9 | 10 | #ifndef _HDE64_H_ 11 | #define _HDE64_H_ 12 | 13 | /* stdint.h - C99 standard header 14 | * http://en.wikipedia.org/wiki/stdint.h 15 | * 16 | * if your compiler doesn't contain "stdint.h" header (for 17 | * example, Microsoft Visual C++), you can download file: 18 | * http://www.azillionmonkeys.com/qed/pstdint.h 19 | * and change next line to: 20 | * #include "pstdint.h" 21 | */ 22 | #include "pstdint.h" 23 | 24 | #define F_MODRM 0x00000001 25 | #define F_SIB 0x00000002 26 | #define F_IMM8 0x00000004 27 | #define F_IMM16 0x00000008 28 | #define F_IMM32 0x00000010 29 | #define F_IMM64 0x00000020 30 | #define F_DISP8 0x00000040 31 | #define F_DISP16 0x00000080 32 | #define F_DISP32 0x00000100 33 | #define F_RELATIVE 0x00000200 34 | #define F_ERROR 0x00001000 35 | #define F_ERROR_OPCODE 0x00002000 36 | #define F_ERROR_LENGTH 0x00004000 37 | #define F_ERROR_LOCK 0x00008000 38 | #define F_ERROR_OPERAND 0x00010000 39 | #define F_PREFIX_REPNZ 0x01000000 40 | #define F_PREFIX_REPX 0x02000000 41 | #define F_PREFIX_REP 0x03000000 42 | #define F_PREFIX_66 0x04000000 43 | #define F_PREFIX_67 0x08000000 44 | #define F_PREFIX_LOCK 0x10000000 45 | #define F_PREFIX_SEG 0x20000000 46 | #define F_PREFIX_REX 0x40000000 47 | #define F_PREFIX_ANY 0x7f000000 48 | 49 | #define PREFIX_SEGMENT_CS 0x2e 50 | #define PREFIX_SEGMENT_SS 0x36 51 | #define PREFIX_SEGMENT_DS 0x3e 52 | #define PREFIX_SEGMENT_ES 0x26 53 | #define PREFIX_SEGMENT_FS 0x64 54 | #define PREFIX_SEGMENT_GS 0x65 55 | #define PREFIX_LOCK 0xf0 56 | #define PREFIX_REPNZ 0xf2 57 | #define PREFIX_REPX 0xf3 58 | #define PREFIX_OPERAND_SIZE 0x66 59 | #define PREFIX_ADDRESS_SIZE 0x67 60 | 61 | #pragma pack(push,1) 62 | 63 | typedef struct { 64 | uint8_t len; 65 | uint8_t p_rep; 66 | uint8_t p_lock; 67 | uint8_t p_seg; 68 | uint8_t p_66; 69 | uint8_t p_67; 70 | uint8_t rex; 71 | uint8_t rex_w; 72 | uint8_t rex_r; 73 | uint8_t rex_x; 74 | uint8_t rex_b; 75 | uint8_t opcode; 76 | uint8_t opcode2; 77 | uint8_t modrm; 78 | uint8_t modrm_mod; 79 | uint8_t modrm_reg; 80 | uint8_t modrm_rm; 81 | uint8_t sib; 82 | uint8_t sib_scale; 83 | uint8_t sib_index; 84 | uint8_t sib_base; 85 | union { 86 | uint8_t imm8; 87 | uint16_t imm16; 88 | uint32_t imm32; 89 | uint64_t imm64; 90 | } imm; 91 | union { 92 | uint8_t disp8; 93 | uint16_t disp16; 94 | uint32_t disp32; 95 | } disp; 96 | uint32_t flags; 97 | } hde64s; 98 | 99 | #pragma pack(pop) 100 | 101 | #ifdef __cplusplus 102 | extern "C" { 103 | #endif 104 | 105 | /* __cdecl */ 106 | unsigned int hde64_disasm(const void *code, hde64s *hs); 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* _HDE64_H_ */ 113 | -------------------------------------------------------------------------------- /MinHook/src/HDE/pstdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | // Integer types for HDE. 32 | typedef INT8 int8_t; 33 | typedef INT16 int16_t; 34 | typedef INT32 int32_t; 35 | typedef INT64 int64_t; 36 | typedef UINT8 uint8_t; 37 | typedef UINT16 uint16_t; 38 | typedef UINT32 uint32_t; 39 | typedef UINT64 uint64_t; 40 | -------------------------------------------------------------------------------- /MinHook/src/HDE/table32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 32 C 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | */ 7 | 8 | #define C_NONE 0x00 9 | #define C_MODRM 0x01 10 | #define C_IMM8 0x02 11 | #define C_IMM16 0x04 12 | #define C_IMM_P66 0x10 13 | #define C_REL8 0x20 14 | #define C_REL32 0x40 15 | #define C_GROUP 0x80 16 | #define C_ERROR 0xff 17 | 18 | #define PRE_ANY 0x00 19 | #define PRE_NONE 0x01 20 | #define PRE_F2 0x02 21 | #define PRE_F3 0x04 22 | #define PRE_66 0x08 23 | #define PRE_67 0x10 24 | #define PRE_LOCK 0x20 25 | #define PRE_SEG 0x40 26 | #define PRE_ALL 0xff 27 | 28 | #define DELTA_OPCODES 0x4a 29 | #define DELTA_FPU_REG 0xf1 30 | #define DELTA_FPU_MODRM 0xf8 31 | #define DELTA_PREFIXES 0x130 32 | #define DELTA_OP_LOCK_OK 0x1a1 33 | #define DELTA_OP2_LOCK_OK 0x1b9 34 | #define DELTA_OP_ONLY_MEM 0x1cb 35 | #define DELTA_OP2_ONLY_MEM 0x1da 36 | 37 | unsigned char hde32_table[] = { 38 | 0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3, 39 | 0xa8,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xac,0xaa,0xb2,0xaa,0x9f,0x9f, 40 | 0x9f,0x9f,0xb5,0xa3,0xa3,0xa4,0xaa,0xaa,0xba,0xaa,0x96,0xaa,0xa8,0xaa,0xc3, 41 | 0xc3,0x96,0x96,0xb7,0xae,0xd6,0xbd,0xa3,0xc5,0xa3,0xa3,0x9f,0xc3,0x9c,0xaa, 42 | 0xaa,0xac,0xaa,0xbf,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0x90, 43 | 0x82,0x7d,0x97,0x59,0x59,0x59,0x59,0x59,0x7f,0x59,0x59,0x60,0x7d,0x7f,0x7f, 44 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x9a,0x88,0x7d, 45 | 0x59,0x50,0x50,0x50,0x50,0x59,0x59,0x59,0x59,0x61,0x94,0x61,0x9e,0x59,0x59, 46 | 0x85,0x59,0x92,0xa3,0x60,0x60,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59, 47 | 0x59,0x59,0x9f,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xcc,0x01,0xbc,0x03,0xf0, 48 | 0x10,0x10,0x10,0x10,0x50,0x50,0x50,0x50,0x14,0x20,0x20,0x20,0x20,0x01,0x01, 49 | 0x01,0x01,0xc4,0x02,0x10,0x00,0x00,0x00,0x00,0x01,0x01,0xc0,0xc2,0x10,0x11, 50 | 0x02,0x03,0x11,0x03,0x03,0x04,0x00,0x00,0x14,0x00,0x02,0x00,0x00,0xc6,0xc8, 51 | 0x02,0x02,0x02,0x02,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xca, 52 | 0x01,0x01,0x01,0x00,0x06,0x00,0x04,0x00,0xc0,0xc2,0x01,0x01,0x03,0x01,0xff, 53 | 0xff,0x01,0x00,0x03,0xc4,0xc4,0xc6,0x03,0x01,0x01,0x01,0xff,0x03,0x03,0x03, 54 | 0xc8,0x40,0x00,0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00, 55 | 0x00,0x00,0x00,0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00, 56 | 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 57 | 0x00,0xff,0xff,0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 58 | 0x7f,0x00,0x00,0xff,0x4a,0x4a,0x4a,0x4a,0x4b,0x52,0x4a,0x4a,0x4a,0x4a,0x4f, 59 | 0x4c,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x55,0x45,0x40,0x4a,0x4a,0x4a, 60 | 0x45,0x59,0x4d,0x46,0x4a,0x5d,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a, 61 | 0x4a,0x4a,0x4a,0x4a,0x4a,0x61,0x63,0x67,0x4e,0x4a,0x4a,0x6b,0x6d,0x4a,0x4a, 62 | 0x45,0x6d,0x4a,0x4a,0x44,0x45,0x4a,0x4a,0x00,0x00,0x00,0x02,0x0d,0x06,0x06, 63 | 0x06,0x06,0x0e,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x00,0x06,0x06,0x02,0x06, 64 | 0x00,0x0a,0x0a,0x07,0x07,0x06,0x02,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04, 65 | 0x04,0x04,0x00,0x00,0x00,0x0e,0x05,0x06,0x06,0x06,0x01,0x06,0x00,0x00,0x08, 66 | 0x00,0x10,0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01, 67 | 0x86,0x00,0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba, 68 | 0xf8,0xbb,0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00, 69 | 0xc4,0xff,0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00, 70 | 0x13,0x09,0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07, 71 | 0xb2,0xff,0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf, 72 | 0xe7,0x08,0x00,0xf0,0x02,0x00 73 | }; 74 | -------------------------------------------------------------------------------- /MinHook/src/HDE/table64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 64 C 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | */ 7 | 8 | #define C_NONE 0x00 9 | #define C_MODRM 0x01 10 | #define C_IMM8 0x02 11 | #define C_IMM16 0x04 12 | #define C_IMM_P66 0x10 13 | #define C_REL8 0x20 14 | #define C_REL32 0x40 15 | #define C_GROUP 0x80 16 | #define C_ERROR 0xff 17 | 18 | #define PRE_ANY 0x00 19 | #define PRE_NONE 0x01 20 | #define PRE_F2 0x02 21 | #define PRE_F3 0x04 22 | #define PRE_66 0x08 23 | #define PRE_67 0x10 24 | #define PRE_LOCK 0x20 25 | #define PRE_SEG 0x40 26 | #define PRE_ALL 0xff 27 | 28 | #define DELTA_OPCODES 0x4a 29 | #define DELTA_FPU_REG 0xfd 30 | #define DELTA_FPU_MODRM 0x104 31 | #define DELTA_PREFIXES 0x13c 32 | #define DELTA_OP_LOCK_OK 0x1ae 33 | #define DELTA_OP2_LOCK_OK 0x1c6 34 | #define DELTA_OP_ONLY_MEM 0x1d8 35 | #define DELTA_OP2_ONLY_MEM 0x1e7 36 | 37 | unsigned char hde64_table[] = { 38 | 0xa5,0xaa,0xa5,0xb8,0xa5,0xaa,0xa5,0xaa,0xa5,0xb8,0xa5,0xb8,0xa5,0xb8,0xa5, 39 | 0xb8,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xac,0xc0,0xcc,0xc0,0xa1,0xa1, 40 | 0xa1,0xa1,0xb1,0xa5,0xa5,0xa6,0xc0,0xc0,0xd7,0xda,0xe0,0xc0,0xe4,0xc0,0xea, 41 | 0xea,0xe0,0xe0,0x98,0xc8,0xee,0xf1,0xa5,0xd3,0xa5,0xa5,0xa1,0xea,0x9e,0xc0, 42 | 0xc0,0xc2,0xc0,0xe6,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0xab, 43 | 0x8b,0x90,0x64,0x5b,0x5b,0x5b,0x5b,0x5b,0x92,0x5b,0x5b,0x76,0x90,0x92,0x92, 44 | 0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x6a,0x73,0x90, 45 | 0x5b,0x52,0x52,0x52,0x52,0x5b,0x5b,0x5b,0x5b,0x77,0x7c,0x77,0x85,0x5b,0x5b, 46 | 0x70,0x5b,0x7a,0xaf,0x76,0x76,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b, 47 | 0x5b,0x5b,0x86,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xd5,0x03,0xcc,0x01,0xbc, 48 | 0x03,0xf0,0x03,0x03,0x04,0x00,0x50,0x50,0x50,0x50,0xff,0x20,0x20,0x20,0x20, 49 | 0x01,0x01,0x01,0x01,0xc4,0x02,0x10,0xff,0xff,0xff,0x01,0x00,0x03,0x11,0xff, 50 | 0x03,0xc4,0xc6,0xc8,0x02,0x10,0x00,0xff,0xcc,0x01,0x01,0x01,0x00,0x00,0x00, 51 | 0x00,0x01,0x01,0x03,0x01,0xff,0xff,0xc0,0xc2,0x10,0x11,0x02,0x03,0x01,0x01, 52 | 0x01,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x10, 53 | 0x10,0x10,0x10,0x02,0x10,0x00,0x00,0xc6,0xc8,0x02,0x02,0x02,0x02,0x06,0x00, 54 | 0x04,0x00,0x02,0xff,0x00,0xc0,0xc2,0x01,0x01,0x03,0x03,0x03,0xca,0x40,0x00, 55 | 0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00,0x00,0x00,0x00, 56 | 0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xff,0x00, 57 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff, 58 | 0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00, 59 | 0xff,0x40,0x40,0x40,0x40,0x41,0x49,0x40,0x40,0x40,0x40,0x4c,0x42,0x40,0x40, 60 | 0x40,0x40,0x40,0x40,0x40,0x40,0x4f,0x44,0x53,0x40,0x40,0x40,0x44,0x57,0x43, 61 | 0x5c,0x40,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, 62 | 0x40,0x40,0x64,0x66,0x6e,0x6b,0x40,0x40,0x6a,0x46,0x40,0x40,0x44,0x46,0x40, 63 | 0x40,0x5b,0x44,0x40,0x40,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x01,0x06, 64 | 0x06,0x02,0x06,0x06,0x00,0x06,0x00,0x0a,0x0a,0x00,0x00,0x00,0x02,0x07,0x07, 65 | 0x06,0x02,0x0d,0x06,0x06,0x06,0x0e,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04, 66 | 0x04,0x04,0x05,0x06,0x06,0x06,0x00,0x00,0x00,0x0e,0x00,0x00,0x08,0x00,0x10, 67 | 0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01,0x86,0x00, 68 | 0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba,0xf8,0xbb, 69 | 0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00,0xc4,0xff, 70 | 0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00,0x13,0x09, 71 | 0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07,0xb2,0xff, 72 | 0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf,0xe7,0x08, 73 | 0x00,0xf0,0x02,0x00 74 | }; 75 | -------------------------------------------------------------------------------- /MinHook/src/buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | // Size of each memory slot. 32 | #if defined(_M_X64) || defined(__x86_64__) 33 | #define MEMORY_SLOT_SIZE 64 34 | #else 35 | #define MEMORY_SLOT_SIZE 32 36 | #endif 37 | 38 | VOID InitializeBuffer(VOID); 39 | VOID UninitializeBuffer(VOID); 40 | LPVOID AllocateBuffer(LPVOID pOrigin); 41 | VOID FreeBuffer(LPVOID pBuffer); 42 | BOOL IsExecutableAddress(LPVOID pAddress); 43 | -------------------------------------------------------------------------------- /MinHook/src/trampoline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #pragma pack(push, 1) 32 | 33 | // Structs for writing x86/x64 instructions. 34 | 35 | // 8-bit relative jump. 36 | typedef struct _JMP_REL_SHORT 37 | { 38 | UINT8 opcode; // EB xx: JMP +2+xx 39 | UINT8 operand; 40 | } JMP_REL_SHORT, *PJMP_REL_SHORT; 41 | 42 | // 32-bit direct relative jump/call. 43 | typedef struct _JMP_REL 44 | { 45 | UINT8 opcode; // E9/E8 xxxxxxxx: JMP/CALL +5+xxxxxxxx 46 | UINT32 operand; // Relative destination address 47 | } JMP_REL, *PJMP_REL, CALL_REL; 48 | 49 | // 64-bit indirect absolute jump. 50 | typedef struct _JMP_ABS 51 | { 52 | UINT8 opcode0; // FF25 00000000: JMP [+6] 53 | UINT8 opcode1; 54 | UINT32 dummy; 55 | UINT64 address; // Absolute destination address 56 | } JMP_ABS, *PJMP_ABS; 57 | 58 | // 64-bit indirect absolute call. 59 | typedef struct _CALL_ABS 60 | { 61 | UINT8 opcode0; // FF15 00000002: CALL [+6] 62 | UINT8 opcode1; 63 | UINT32 dummy0; 64 | UINT8 dummy1; // EB 08: JMP +10 65 | UINT8 dummy2; 66 | UINT64 address; // Absolute destination address 67 | } CALL_ABS; 68 | 69 | // 32-bit direct relative conditional jumps. 70 | typedef struct _JCC_REL 71 | { 72 | UINT8 opcode0; // 0F8* xxxxxxxx: J** +6+xxxxxxxx 73 | UINT8 opcode1; 74 | UINT32 operand; // Relative destination address 75 | } JCC_REL; 76 | 77 | // 64bit indirect absolute conditional jumps that x64 lacks. 78 | typedef struct _JCC_ABS 79 | { 80 | UINT8 opcode; // 7* 0E: J** +16 81 | UINT8 dummy0; 82 | UINT8 dummy1; // FF25 00000000: JMP [+6] 83 | UINT8 dummy2; 84 | UINT32 dummy3; 85 | UINT64 address; // Absolute destination address 86 | } JCC_ABS; 87 | 88 | #pragma pack(pop) 89 | 90 | typedef struct _TRAMPOLINE 91 | { 92 | LPVOID pTarget; // [In] Address of the target function. 93 | LPVOID pDetour; // [In] Address of the detour function. 94 | LPVOID pTrampoline; // [In] Buffer address for the trampoline and relay function. 95 | 96 | #if defined(_M_X64) || defined(__x86_64__) 97 | LPVOID pRelay; // [Out] Address of the relay function. 98 | #endif 99 | BOOL patchAbove; // [Out] Should use the hot patch area? 100 | UINT nIP; // [Out] Number of the instruction boundaries. 101 | UINT8 oldIPs[8]; // [Out] Instruction boundaries of the target function. 102 | UINT8 newIPs[8]; // [Out] Instruction boundaries of the trampoline function. 103 | } TRAMPOLINE, *PTRAMPOLINE; 104 | 105 | BOOL CreateTrampolineFunction(PTRAMPOLINE ct); 106 | -------------------------------------------------------------------------------- /d3d9ex.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29215.179 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OneTweakNG", "d3d9ex\d3d9ex.vcxproj", "{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5DB3A8C9-CF87-4AB6-A7C2-07B81A0DA625}" 9 | ProjectSection(SolutionItems) = preProject 10 | Common\Defines.h = Common\Defines.h 11 | Common\Logger.h = Common\Logger.h 12 | Common\SimpleIni.h = Common\SimpleIni.h 13 | Common\StringUtil.h = Common\StringUtil.h 14 | Common\Timer.h = Common\Timer.h 15 | Common\Types.h = Common\Types.h 16 | Common\WinUtil.h = Common\WinUtil.h 17 | Common\WinVer.h = Common\WinVer.h 18 | EndProjectSection 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "MinHook\build\VC15\libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}" 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|Win32 = Debug|Win32 25 | Debug|x64 = Debug|x64 26 | Release|Win32 = Release|Win32 27 | Release|x64 = Release|x64 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|Win32.Build.0 = Debug|Win32 32 | {6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|x64.ActiveCfg = Debug|x64 33 | {6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|x64.Build.0 = Debug|x64 34 | {6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|Win32.ActiveCfg = Release|Win32 35 | {6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|Win32.Build.0 = Release|Win32 36 | {6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|x64.ActiveCfg = Release|x64 37 | {6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|x64.Build.0 = Release|x64 38 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.Build.0 = Debug|Win32 40 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64 41 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64 42 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.ActiveCfg = Release|Win32 43 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.Build.0 = Release|Win32 44 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64 45 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64 46 | EndGlobalSection 47 | GlobalSection(SolutionProperties) = preSolution 48 | HideSolutionNode = FALSE 49 | EndGlobalSection 50 | GlobalSection(ExtensibilityGlobals) = postSolution 51 | SolutionGuid = {CC332D21-3B2D-4534-AD8E-2525081AECA5} 52 | VisualSVNWorkingCopyRoot = . 53 | EndGlobalSection 54 | EndGlobal 55 | -------------------------------------------------------------------------------- /d3d9ex/AutoFix.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include "Context.h" 4 | #include "IDirect3DVertexBuffer9.h" 5 | 6 | void MainContext::EnableAutoFix() 7 | { 8 | std::string exe_name = ModuleNameA(NULL); 9 | std::transform(exe_name.begin(), exe_name.end(), exe_name.begin(), std::tolower); 10 | 11 | if (exe_name == "game.exe" || exe_name == "game.dat") 12 | { 13 | autofix = RESIDENT_EVIL_4; 14 | PrintLog("AutoFix for \"Resident Evil 4\" enabled"); 15 | } 16 | 17 | if (exe_name == "kb.exe") 18 | { 19 | autofix = KINGS_BOUNTY_LEGEND; 20 | PrintLog("AutoFix for \"Kings Bounty: Legend\" enabled"); 21 | } 22 | 23 | if (exe_name == "ffxiiiimg.exe") 24 | { 25 | autofix = FINAL_FANTASY_XIII; 26 | PrintLog("AutoFix for \"Final Fantasy XIII\" enabled"); 27 | } 28 | } 29 | 30 | const std::map MainContext::behaviorflags_fixes = 31 | { 32 | { RESIDENT_EVIL_4, D3DCREATE_SOFTWARE_VERTEXPROCESSING }, 33 | { KINGS_BOUNTY_LEGEND, D3DCREATE_MIXED_VERTEXPROCESSING } 34 | }; 35 | 36 | void MainContext::FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out) 37 | { 38 | if (flags_in & D3DCREATE_SOFTWARE_VERTEXPROCESSING) 39 | { 40 | *flags_out &= ~(D3DCREATE_PUREDEVICE | D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MIXED_VERTEXPROCESSING); 41 | *flags_out |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; 42 | } 43 | else if (flags_in & D3DCREATE_MIXED_VERTEXPROCESSING) 44 | { 45 | *flags_out &= ~(D3DCREATE_PUREDEVICE | D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_SOFTWARE_VERTEXPROCESSING); 46 | *flags_out |= D3DCREATE_MIXED_VERTEXPROCESSING; 47 | } 48 | else if (flags_in & D3DCREATE_HARDWARE_VERTEXPROCESSING) 49 | { 50 | *flags_out &= ~(D3DCREATE_MIXED_VERTEXPROCESSING | D3DCREATE_SOFTWARE_VERTEXPROCESSING); 51 | *flags_out |= D3DCREATE_HARDWARE_VERTEXPROCESSING; 52 | } 53 | } 54 | 55 | bool MainContext::ApplyBehaviorFlagsFix(DWORD* flags) 56 | { 57 | if (autofix == AutoFixes::NONE) return false; 58 | 59 | auto && fix = behaviorflags_fixes.find(autofix); 60 | if (fix != behaviorflags_fixes.end()) 61 | { 62 | FixBehaviorFlagConflict(fix->second, flags); 63 | return true; 64 | } 65 | 66 | return false; 67 | } 68 | 69 | HRESULT APIENTRY MainContext::ApplyVertexBufferFix(IDirect3DDevice9 *pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) 70 | { 71 | if (autofix == AutoFixes::NONE) return pIDirect3DDevice9->CreateVertexBuffer(Length,Usage,FVF,Pool,ppVertexBuffer,pSharedHandle); 72 | 73 | // Final Fantasy XIII 74 | if (autofix == FINAL_FANTASY_XIII) 75 | { 76 | if (Length == 358400 && Pool == D3DPOOL_MANAGED) { 77 | Usage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY; 78 | Pool = D3DPOOL_SYSTEMMEM; 79 | 80 | //IDirect3DVertexBuffer9* buffer = nullptr; 81 | //HRESULT hr = pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, &buffer, NULL); 82 | //if (FAILED(hr)) 83 | //{ 84 | // return pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle); 85 | //} 86 | 87 | //if(ppVertexBuffer) *ppVertexBuffer = new hkIDirect3DVertexBuffer9(pIDirect3DDevice9, buffer); 88 | //return hr; 89 | } 90 | } 91 | return pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle); 92 | } -------------------------------------------------------------------------------- /d3d9ex/AutoFix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | bool CheckFix(DWORD* flags); 4 | -------------------------------------------------------------------------------- /d3d9ex/Context.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include "Wrapper.h" 4 | 5 | #include "Context.h" 6 | #include "IDirect3D9.h" 7 | 8 | MainContext context; 9 | 10 | Config::Config() 11 | { 12 | std::string inifile = FullPathFromPath(inifilename); 13 | 14 | CSimpleIniW ini; 15 | ini.LoadFile(inifile.c_str()); 16 | 17 | u32 config_version = ini.GetLongValue(L"Version", L"Config"); 18 | if (config_version != CONFIG_VERSION) 19 | { 20 | // save file and reload 21 | ini.Reset(); 22 | 23 | #define SETTING(_type, _func, _var, _section, _defaultval) \ 24 | ini.Set##_func(L#_section, L#_var, _defaultval) 25 | #include "Settings.h" 26 | #undef SETTING 27 | 28 | ini.SetLongValue(L"Version", L"Config", CONFIG_VERSION); 29 | ini.SaveFile(inifile.c_str()); 30 | ini.Reset(); 31 | ini.LoadFile(inifile.c_str()); 32 | } 33 | 34 | #define SETTING(_type, _func, _var, _section, _defaultval) \ 35 | _var = ini.Get##_func(L#_section, L#_var) 36 | #include "Settings.h" 37 | #undef SETTING 38 | } 39 | 40 | MainContext::MainContext() : oldWndProc(nullptr) 41 | { 42 | LogFile("OneTweakNG.log"); 43 | 44 | if(config.GetAutoFix()) EnableAutoFix(); 45 | 46 | MH_Initialize(); 47 | 48 | MH_CreateHook(D3D9DLL::Get().Direct3DCreate9, HookDirect3DCreate9, reinterpret_cast(&TrueDirect3DCreate9)); 49 | MH_EnableHook(D3D9DLL::Get().Direct3DCreate9); 50 | 51 | MH_CreateHook(CreateWindowExA, HookCreateWindowExA, reinterpret_cast(&TrueCreateWindowExA)); 52 | MH_EnableHook(CreateWindowExA); 53 | 54 | MH_CreateHook(CreateWindowExW, HookCreateWindowExW, reinterpret_cast(&TrueCreateWindowExW)); 55 | MH_EnableHook(CreateWindowExW); 56 | 57 | MH_CreateHook(SetWindowLongA, HookSetWindowLongA, reinterpret_cast(&TrueSetWindowLongA)); 58 | MH_EnableHook(SetWindowLongA); 59 | 60 | MH_CreateHook(SetWindowLongW, HookSetWindowLongW, reinterpret_cast(&TrueSetWindowLongW)); 61 | MH_EnableHook(SetWindowLongW); 62 | } 63 | 64 | MainContext::~MainContext() 65 | { 66 | while (::ShowCursor(TRUE) <= 0); 67 | } 68 | 69 | IDirect3D9 * WINAPI MainContext::HookDirect3DCreate9(UINT SDKVersion) 70 | { 71 | IDirect3D9* d3d9 = context.TrueDirect3DCreate9(SDKVersion); 72 | if (d3d9) 73 | { 74 | return new hkIDirect3D9(d3d9); 75 | } 76 | 77 | return d3d9; 78 | } 79 | 80 | bool MainContext::BehaviorFlagsToString(DWORD BehaviorFlags, std::string* BehaviorFlagsString) 81 | { 82 | #define BF2STR(x) if (BehaviorFlags & x) BehaviorFlagsString->append(#x" "); 83 | 84 | BF2STR(D3DCREATE_ADAPTERGROUP_DEVICE); 85 | BF2STR(D3DCREATE_DISABLE_DRIVER_MANAGEMENT); 86 | BF2STR(D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX); 87 | BF2STR(D3DCREATE_DISABLE_PRINTSCREEN); 88 | BF2STR(D3DCREATE_DISABLE_PSGP_THREADING); 89 | BF2STR(D3DCREATE_ENABLE_PRESENTSTATS); 90 | BF2STR(D3DCREATE_FPU_PRESERVE); 91 | BF2STR(D3DCREATE_HARDWARE_VERTEXPROCESSING); 92 | BF2STR(D3DCREATE_MIXED_VERTEXPROCESSING); 93 | BF2STR(D3DCREATE_SOFTWARE_VERTEXPROCESSING); 94 | BF2STR(D3DCREATE_MULTITHREADED); 95 | BF2STR(D3DCREATE_NOWINDOWCHANGES); 96 | BF2STR(D3DCREATE_PUREDEVICE); 97 | BF2STR(D3DCREATE_SCREENSAVER); 98 | 99 | #undef BF2STR 100 | 101 | if (BehaviorFlagsString->back() == ' ') 102 | BehaviorFlagsString->pop_back(); 103 | 104 | return false; 105 | } 106 | 107 | bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentationParameters) 108 | { 109 | if (pPresentationParameters) 110 | { 111 | if (config.GetTrippleBuffering()) 112 | { 113 | pPresentationParameters->BackBufferCount = 3; 114 | } 115 | 116 | if (config.GetMultisample() > 0) 117 | { 118 | pPresentationParameters->SwapEffect = D3DSWAPEFFECT_DISCARD; 119 | pPresentationParameters->MultiSampleType = (D3DMULTISAMPLE_TYPE)config.GetMultisample(); 120 | pPresentationParameters->MultiSampleQuality = 0; 121 | 122 | PrintLog("MultiSampleType %u, MultiSampleQuality %u", pPresentationParameters->MultiSampleType, pPresentationParameters->MultiSampleQuality); 123 | } 124 | 125 | if (config.GetPresentationInterval() != -1) 126 | { 127 | pPresentationParameters->PresentationInterval = config.GetPresentationInterval(); 128 | PrintLog("PresentationInterval: PresentationInterval set to %u", pPresentationParameters->PresentationInterval); 129 | } 130 | 131 | if (config.GetBorderless()) 132 | { 133 | int cx = GetSystemMetrics(SM_CXSCREEN); 134 | int cy = GetSystemMetrics(SM_CYSCREEN); 135 | 136 | SetWindowPos(pPresentationParameters->hDeviceWindow, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); 137 | 138 | if (config.GetForceWindowedMode()) 139 | { 140 | pPresentationParameters->SwapEffect = pPresentationParameters->MultiSampleType == D3DMULTISAMPLE_NONE ? D3DSWAPEFFECT_DISCARD : D3DSWAPEFFECT_FLIP; 141 | pPresentationParameters->Windowed = TRUE; 142 | pPresentationParameters->FullScreen_RefreshRateInHz = 0; 143 | PrintLog("ForceWindowedMode"); 144 | } 145 | } 146 | 147 | if (config.GetHideCursor()) while (::ShowCursor(FALSE) >= 0); // ShowCursor < 0 -> hidden 148 | 149 | return true; 150 | } 151 | return false; 152 | } 153 | 154 | bool MainContext::CheckWindow(HWND hWnd) 155 | { 156 | std::unique_ptr className(new wchar_t[MAX_PATH]); 157 | std::unique_ptr windowName(new wchar_t[MAX_PATH]); 158 | 159 | GetClassNameW(hWnd, className.get(), MAX_PATH); 160 | GetWindowTextW(hWnd, windowName.get(), MAX_PATH); 161 | 162 | PrintLog("HWND 0x%p: ClassName \"%ls\", WindowName: \"%ls\"", hWnd, className.get(), windowName.get()); 163 | 164 | bool class_found = config.GetWindowClass().compare(className.get()) == 0; 165 | bool window_found = config.GetWindowName().compare(windowName.get()) == 0; 166 | bool force = config.GetAllWindows(); 167 | 168 | return class_found || window_found || force; 169 | } 170 | 171 | void MainContext::ApplyWndProc(HWND hWnd) 172 | { 173 | if (config.GetAlwaysActive() || config.GetHideCursor()) 174 | { 175 | context.oldWndProc = (WNDPROC)context.TrueSetWindowLongA(hWnd, GWLP_WNDPROC, (LONG_PTR)context.WindowProc); 176 | } 177 | } 178 | 179 | void MainContext::ApplyBorderless(HWND hWnd) 180 | { 181 | if (config.GetBorderless()) 182 | { 183 | LONG_PTR dwStyle = GetWindowLongPtr(hWnd, GWL_STYLE); 184 | LONG_PTR dwExStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE); 185 | 186 | DWORD new_dwStyle = dwStyle & ~WS_OVERLAPPEDWINDOW; 187 | DWORD new_dwExStyle = dwExStyle & ~(WS_EX_OVERLAPPEDWINDOW); 188 | 189 | context.TrueSetWindowLongW(hWnd, GWL_STYLE, new_dwStyle); 190 | context.TrueSetWindowLongW(hWnd, GWL_EXSTYLE, new_dwExStyle); 191 | 192 | int cx = GetSystemMetrics(SM_CXSCREEN); 193 | int cy = GetSystemMetrics(SM_CYSCREEN); 194 | 195 | SetWindowPos(hWnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); 196 | SetFocus(hWnd); 197 | 198 | PrintLog("HWND 0x%p: Borderless dwStyle: %lX->%lX", hWnd, dwStyle, new_dwStyle); 199 | PrintLog("HWND 0x%p: Borderless dwExStyle: %lX->%lX", hWnd, dwExStyle, new_dwExStyle); 200 | MessageBeep(MB_ICONASTERISK); 201 | } 202 | } 203 | 204 | LRESULT CALLBACK MainContext::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 205 | { 206 | switch (uMsg) 207 | { 208 | 209 | case WM_ACTIVATE: 210 | switch (LOWORD(wParam)) 211 | { 212 | case WA_ACTIVE: 213 | case WA_CLICKACTIVE: 214 | while (::ShowCursor(FALSE) >= 0); 215 | break; 216 | 217 | case WA_INACTIVE: 218 | if (context.config.GetAlwaysActive()) 219 | return TRUE; 220 | 221 | if (!context.config.GetForceHideCursor()) 222 | while (::ShowCursor(TRUE) < 0); 223 | break; 224 | } 225 | 226 | case WM_ACTIVATEAPP: 227 | if (context.config.GetAlwaysActive()) 228 | return TRUE; 229 | 230 | } 231 | 232 | if (context.config.GetForceHideCursor()) 233 | while (::ShowCursor(FALSE) >= 0); 234 | 235 | return CallWindowProc(context.oldWndProc, hWnd, uMsg, wParam, lParam); 236 | } 237 | 238 | LONG WINAPI MainContext::HookSetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong) 239 | { 240 | if (context.config.GetBorderless()) 241 | { 242 | DWORD olddwNewLong = dwNewLong; 243 | if (nIndex == GWL_STYLE) 244 | { 245 | dwNewLong &= ~WS_OVERLAPPEDWINDOW; 246 | PrintLog("SetWindowLongA dwStyle: %lX->%lX", olddwNewLong, dwNewLong); 247 | } 248 | 249 | if (nIndex == GWL_EXSTYLE) 250 | { 251 | dwNewLong &= ~(WS_EX_OVERLAPPEDWINDOW); 252 | PrintLog("SetWindowLongA dwExStyle: %lX->%lX", olddwNewLong, dwNewLong); 253 | } 254 | } 255 | return context.TrueSetWindowLongA(hWnd, nIndex, dwNewLong); 256 | } 257 | 258 | LONG WINAPI MainContext::HookSetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong) 259 | { 260 | if (context.config.GetBorderless()) 261 | { 262 | DWORD olddwNewLong = dwNewLong; 263 | if (nIndex == GWL_STYLE) 264 | { 265 | dwNewLong &= ~WS_OVERLAPPEDWINDOW; 266 | PrintLog("SetWindowLongW dwStyle: %lX->%lX", olddwNewLong, dwNewLong); 267 | } 268 | 269 | if (nIndex == GWL_EXSTYLE) 270 | { 271 | dwNewLong &= ~(WS_EX_OVERLAPPEDWINDOW); 272 | PrintLog("SetWindowLongW dwExStyle: %lX->%lX", olddwNewLong, dwNewLong); 273 | } 274 | } 275 | return context.TrueSetWindowLongW(hWnd, nIndex, dwNewLong); 276 | } 277 | 278 | HWND WINAPI MainContext::HookCreateWindowExA(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam) 279 | { 280 | HWND hWnd = context.TrueCreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); 281 | if (!hWnd) 282 | { 283 | PrintLog("CreateWindowExA failed"); 284 | return hWnd; 285 | } 286 | 287 | if (context.CheckWindow(hWnd)) 288 | { 289 | context.ApplyWndProc(hWnd); 290 | context.ApplyBorderless(hWnd); 291 | } 292 | 293 | return hWnd; 294 | } 295 | 296 | HWND WINAPI MainContext::HookCreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam) 297 | { 298 | HWND hWnd = context.TrueCreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); 299 | if (!hWnd) 300 | { 301 | PrintLog("CreateWindowExW failed"); 302 | return hWnd; 303 | } 304 | 305 | if (context.CheckWindow(hWnd)) 306 | { 307 | context.ApplyWndProc(hWnd); 308 | context.ApplyBorderless(hWnd); 309 | } 310 | 311 | return hWnd; 312 | } 313 | -------------------------------------------------------------------------------- /d3d9ex/Context.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "d3d9.h" 5 | #include 6 | #include "SimpleIni.h" 7 | 8 | struct hkIDirect3D9; 9 | 10 | static const char* inifilename = "OneTweakNG.ini"; 11 | #define CONFIG_VERSION 3 12 | 13 | class Config 14 | { 15 | public: 16 | Config(const Config&) = delete; 17 | const Config& operator=(Config& other) = delete; 18 | 19 | Config(); 20 | 21 | #define SETTING(_type, _func, _var, _section, _defaultval) \ 22 | private: _type _var; \ 23 | public: const _type& Get##_var() const { return _var; }; 24 | #include "Settings.h" 25 | #undef SETTING 26 | }; 27 | 28 | #define DECLARE_HOOK(type, callconv, name, ...) \ 29 | public: type(callconv* True##name)(__VA_ARGS__) = name; \ 30 | private: static type callconv Hook##name(__VA_ARGS__); 31 | 32 | class MainContext 33 | { 34 | MainContext(const MainContext&) = delete; 35 | const MainContext& operator=(MainContext& other) = delete; 36 | 37 | DECLARE_HOOK(IDirect3D9*, WINAPI, Direct3DCreate9, UINT SDKVersion); 38 | DECLARE_HOOK(LONG, WINAPI, SetWindowLongA, HWND hWnd, int nIndex, LONG dwNewLong); 39 | DECLARE_HOOK(LONG, WINAPI, SetWindowLongW, HWND hWnd, int nIndex, LONG dwNewLong); 40 | DECLARE_HOOK(HWND, WINAPI, CreateWindowExA, DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, 41 | DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); 42 | DECLARE_HOOK(HWND, WINAPI, CreateWindowExW, DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, 43 | DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); 44 | 45 | public: 46 | MainContext(); 47 | ~MainContext(); 48 | 49 | bool ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentationParameters); 50 | bool ApplyBehaviorFlagsFix(DWORD* flags); 51 | HRESULT APIENTRY ApplyVertexBufferFix(IDirect3DDevice9* pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); 52 | bool BehaviorFlagsToString(DWORD BehaviorFlags, std::string* BehaviorFlagsString); 53 | 54 | bool CheckWindow(HWND hWnd); 55 | 56 | void ApplyWndProc(HWND hWnd); 57 | void ApplyBorderless(HWND hWnd); 58 | 59 | Config config; 60 | 61 | private: 62 | enum AutoFixes : u32 63 | { 64 | NONE = 0, 65 | RESIDENT_EVIL_4, 66 | KINGS_BOUNTY_LEGEND, 67 | FINAL_FANTASY_XIII 68 | }; 69 | 70 | void EnableAutoFix(); 71 | AutoFixes autofix = AutoFixes::NONE; 72 | 73 | void FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out); 74 | static const std::map behaviorflags_fixes; 75 | 76 | static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 77 | WNDPROC oldWndProc; 78 | }; 79 | 80 | extern MainContext context; -------------------------------------------------------------------------------- /d3d9ex/IDirect3D9.cpp: -------------------------------------------------------------------------------- 1 | // wrapper for IDirect3D9 in d3d9.h 2 | // generated using wrapper_gen.rb 3 | 4 | #include "stdafx.h" 5 | #include "Context.h" 6 | 7 | #include "IDirect3D9.h" 8 | #include "IDirect3DDevice9.h" 9 | 10 | #define IDirect3D9_PrintLog(format, ...) //PrintLog(format, __VA_ARGS__); 11 | 12 | HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) { 13 | PrintLog(__FUNCTION__); 14 | if (ppvObj == nullptr) return E_POINTER; 15 | 16 | if (riid == __uuidof(IUnknown) || 17 | riid == __uuidof(IDirect3D9)) 18 | { 19 | *ppvObj = static_cast(this); 20 | AddRef(); 21 | return S_OK; 22 | } 23 | 24 | *ppvObj = nullptr; 25 | return E_NOINTERFACE; 26 | } 27 | 28 | ULONG APIENTRY hkIDirect3D9::AddRef() { 29 | PrintLog(__FUNCTION__); 30 | return _InterlockedIncrement(&m_refCount); 31 | } 32 | 33 | ULONG APIENTRY hkIDirect3D9::Release() { 34 | PrintLog(__FUNCTION__); 35 | const LONG ref = _InterlockedDecrement(&m_refCount); 36 | if (ref == 0) 37 | { 38 | delete this; 39 | } 40 | return ref; 41 | } 42 | 43 | HRESULT APIENTRY hkIDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) { 44 | IDirect3D9_PrintLog(__FUNCTION__); 45 | return m_pWrapped->RegisterSoftwareDevice(pInitializeFunction); 46 | } 47 | 48 | UINT APIENTRY hkIDirect3D9::GetAdapterCount() { 49 | IDirect3D9_PrintLog(__FUNCTION__); 50 | return m_pWrapped->GetAdapterCount(); 51 | } 52 | 53 | HRESULT APIENTRY hkIDirect3D9::GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) { 54 | PrintLog(__FUNCTION__); 55 | HRESULT rt = m_pWrapped->GetAdapterIdentifier(Adapter, Flags, pIdentifier); 56 | if (context.config.GetAdapter() && SUCCEEDED(rt) && pIdentifier) 57 | { 58 | pIdentifier->VendorId = context.config.GetVendorId(); 59 | pIdentifier->DeviceId = context.config.GetDeviceId(); 60 | } 61 | 62 | return rt; 63 | } 64 | 65 | UINT APIENTRY hkIDirect3D9::GetAdapterModeCount(UINT Adapter, D3DFORMAT Format) { 66 | IDirect3D9_PrintLog(__FUNCTION__); 67 | return m_pWrapped->GetAdapterModeCount(Adapter, Format); 68 | } 69 | 70 | HRESULT APIENTRY hkIDirect3D9::EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) { 71 | IDirect3D9_PrintLog(__FUNCTION__); 72 | return m_pWrapped->EnumAdapterModes(Adapter, Format, Mode, pMode); 73 | } 74 | 75 | HRESULT APIENTRY hkIDirect3D9::GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode) { 76 | IDirect3D9_PrintLog(__FUNCTION__); 77 | return m_pWrapped->GetAdapterDisplayMode(Adapter, pMode); 78 | } 79 | 80 | HRESULT APIENTRY hkIDirect3D9::CheckDeviceType(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) { 81 | IDirect3D9_PrintLog(__FUNCTION__); 82 | if (context.config.GetForceWindowedMode()) bWindowed = TRUE; 83 | return m_pWrapped->CheckDeviceType(Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed); 84 | } 85 | 86 | HRESULT APIENTRY hkIDirect3D9::CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) { 87 | IDirect3D9_PrintLog(__FUNCTION__); 88 | return m_pWrapped->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat); 89 | } 90 | 91 | HRESULT APIENTRY hkIDirect3D9::CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) { 92 | IDirect3D9_PrintLog(__FUNCTION__); 93 | return m_pWrapped->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels); 94 | } 95 | 96 | HRESULT APIENTRY hkIDirect3D9::CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) { 97 | IDirect3D9_PrintLog(__FUNCTION__); 98 | return m_pWrapped->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); 99 | } 100 | 101 | HRESULT APIENTRY hkIDirect3D9::CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) { 102 | IDirect3D9_PrintLog(__FUNCTION__); 103 | return m_pWrapped->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat); 104 | } 105 | 106 | HRESULT APIENTRY hkIDirect3D9::GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) { 107 | IDirect3D9_PrintLog(__FUNCTION__); 108 | return m_pWrapped->GetDeviceCaps(Adapter, DeviceType, pCaps); 109 | } 110 | 111 | HMONITOR APIENTRY hkIDirect3D9::GetAdapterMonitor(UINT Adapter) { 112 | IDirect3D9_PrintLog(__FUNCTION__); 113 | return m_pWrapped->GetAdapterMonitor(Adapter); 114 | } 115 | 116 | HRESULT APIENTRY hkIDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface) { 117 | PrintLog(__FUNCTION__); 118 | 119 | DWORD OriginalBehaviorFlags = BehaviorFlags; 120 | std::string BehaviorFlagsString; 121 | context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString); 122 | 123 | PrintLog("BehaviorFlags: %08X %s", BehaviorFlags, BehaviorFlagsString.c_str()); 124 | 125 | if (context.config.GetBehaviorFlags() > 0) 126 | { 127 | BehaviorFlags = context.config.GetBehaviorFlags(); 128 | PrintLog("Advanced Mode: BehaviorFlags set"); 129 | } 130 | else 131 | { 132 | context.ApplyBehaviorFlagsFix(&BehaviorFlags); 133 | } 134 | 135 | if (hFocusWindow == NULL) hFocusWindow = pPresentationParameters->hDeviceWindow; 136 | context.ApplyPresentationParameters(pPresentationParameters); 137 | 138 | if (OriginalBehaviorFlags != BehaviorFlags) 139 | { 140 | std::string BehaviorFlagsString; 141 | context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString); 142 | PrintLog("BehaviorFlags changed: %08X %s", BehaviorFlags, BehaviorFlagsString.c_str()); 143 | } 144 | 145 | IDirect3DDevice9* device = nullptr; 146 | HRESULT hr = m_pWrapped->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, &device); 147 | if (FAILED(hr)) 148 | { 149 | PrintLog("CreateDevice fail with HRESULT: %08X", hr); 150 | *ppReturnedDeviceInterface = nullptr; 151 | return hr; 152 | } 153 | 154 | *ppReturnedDeviceInterface = new hkIDirect3DDevice9(device); 155 | return hr; 156 | } 157 | -------------------------------------------------------------------------------- /d3d9ex/IDirect3D9.h: -------------------------------------------------------------------------------- 1 | // wrapper for IDirect3D9 in d3d9.h 2 | // generated using wrapper_gen.rb 3 | 4 | #include "d3d9.h" 5 | #include "IDirect3DDevice9.h" 6 | 7 | interface hkIDirect3D9 final : public IDirect3D9 { 8 | public: 9 | // original interface 10 | STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj); 11 | STDMETHOD_(ULONG, AddRef)(); 12 | STDMETHOD_(ULONG, Release)(); 13 | STDMETHOD(RegisterSoftwareDevice)(void* pInitializeFunction); 14 | STDMETHOD_(UINT, GetAdapterCount)(); 15 | STDMETHOD(GetAdapterIdentifier)(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier); 16 | STDMETHOD_(UINT, GetAdapterModeCount)(UINT Adapter, D3DFORMAT Format); 17 | STDMETHOD(EnumAdapterModes)(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode); 18 | STDMETHOD(GetAdapterDisplayMode)(UINT Adapter, D3DDISPLAYMODE* pMode); 19 | STDMETHOD(CheckDeviceType)(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed); 20 | STDMETHOD(CheckDeviceFormat)(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); 21 | STDMETHOD(CheckDeviceMultiSampleType)(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels); 22 | STDMETHOD(CheckDepthStencilMatch)(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); 23 | STDMETHOD(CheckDeviceFormatConversion)(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); 24 | STDMETHOD(GetDeviceCaps)(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps); 25 | STDMETHOD_(HMONITOR, GetAdapterMonitor)(UINT Adapter); 26 | STDMETHOD(CreateDevice)(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface); 27 | 28 | public: 29 | hkIDirect3D9(IDirect3D9 *pIDirect3D9) 30 | : m_pWrapped(pIDirect3D9) 31 | { 32 | } 33 | 34 | private: 35 | ~hkIDirect3D9() 36 | { 37 | m_pWrapped->Release(); 38 | } 39 | 40 | LONG m_refCount = 1; 41 | IDirect3D9 *m_pWrapped; 42 | }; 43 | 44 | 45 | -------------------------------------------------------------------------------- /d3d9ex/IDirect3DVertexBuffer9.cpp: -------------------------------------------------------------------------------- 1 | // wrapper for IDirect3DVertexBuffer9 in d3d9.h 2 | // generated using wrapper_gen.rb 3 | 4 | #include "stdafx.h" 5 | #include "Context.h" 6 | 7 | #include "IDirect3D9.h" 8 | #include "IDirect3DDevice9.h" 9 | #include "IDirect3DVertexBuffer9.h" 10 | 11 | #define IDirect3DVertexBuffer9_PrintLog(format, ...) PrintLog(format, __VA_ARGS__); 12 | 13 | HRESULT APIENTRY hkIDirect3DVertexBuffer9::QueryInterface(REFIID riid, void** ppvObj) { 14 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 15 | if (ppvObj == nullptr) return E_POINTER; 16 | 17 | if (riid == __uuidof(IUnknown) || 18 | riid == __uuidof(IDirect3DResource9) || 19 | riid == __uuidof(IDirect3DVertexBuffer9)) 20 | { 21 | *ppvObj = static_cast(this); 22 | AddRef(); 23 | return S_OK; 24 | } 25 | 26 | *ppvObj = nullptr; 27 | return E_NOINTERFACE; 28 | } 29 | 30 | ULONG APIENTRY hkIDirect3DVertexBuffer9::AddRef() { 31 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 32 | return _InterlockedIncrement(&m_refCount); 33 | } 34 | 35 | ULONG APIENTRY hkIDirect3DVertexBuffer9::Release() { 36 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 37 | const LONG ref = _InterlockedDecrement(&m_refCount); 38 | if (ref == 0) 39 | { 40 | delete this; 41 | } 42 | return ref; 43 | } 44 | 45 | HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetDevice(IDirect3DDevice9** ppDevice) { 46 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 47 | 48 | if (ppDevice == nullptr) 49 | return D3DERR_INVALIDCALL; 50 | 51 | m_pIDirect3DDevice9->AddRef(); 52 | *ppDevice = m_pIDirect3DDevice9; 53 | return D3D_OK; 54 | } 55 | 56 | HRESULT APIENTRY hkIDirect3DVertexBuffer9::SetPrivateData(REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { 57 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__ " %s", GUIDtoStringA(refguid)); 58 | return m_pWrapped->SetPrivateData(refguid, pData, SizeOfData, Flags); 59 | } 60 | 61 | HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetPrivateData(REFGUID refguid, void* pData, DWORD* pSizeOfData) { 62 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__ " %s", GUIDtoStringA(refguid)); 63 | return m_pWrapped->GetPrivateData(refguid, pData, pSizeOfData); 64 | } 65 | 66 | HRESULT APIENTRY hkIDirect3DVertexBuffer9::FreePrivateData(REFGUID refguid) { 67 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 68 | return m_pWrapped->FreePrivateData(refguid); 69 | } 70 | 71 | DWORD APIENTRY hkIDirect3DVertexBuffer9::SetPriority(DWORD PriorityNew) { 72 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 73 | return m_pWrapped->SetPriority(PriorityNew); 74 | } 75 | 76 | DWORD APIENTRY hkIDirect3DVertexBuffer9::GetPriority() { 77 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 78 | return m_pWrapped->GetPriority(); 79 | } 80 | 81 | void APIENTRY hkIDirect3DVertexBuffer9::PreLoad() { 82 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 83 | return m_pWrapped->PreLoad(); 84 | } 85 | 86 | D3DRESOURCETYPE APIENTRY hkIDirect3DVertexBuffer9::GetType() { 87 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 88 | return m_pWrapped->GetType(); 89 | } 90 | 91 | HRESULT APIENTRY hkIDirect3DVertexBuffer9::Lock(UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) { 92 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 93 | return m_pWrapped->Lock(OffsetToLock, SizeToLock, ppbData, Flags); 94 | } 95 | 96 | HRESULT APIENTRY hkIDirect3DVertexBuffer9::Unlock() { 97 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 98 | return m_pWrapped->Unlock(); 99 | } 100 | 101 | HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetDesc(D3DVERTEXBUFFER_DESC *pDesc) { 102 | IDirect3DVertexBuffer9_PrintLog(__FUNCTION__); 103 | return m_pWrapped->GetDesc(pDesc); 104 | } 105 | -------------------------------------------------------------------------------- /d3d9ex/IDirect3DVertexBuffer9.h: -------------------------------------------------------------------------------- 1 | // wrapper for IDirect3DVertexBuffer9 in d3d9.h 2 | // generated using wrapper_gen.rb 3 | 4 | #pragma once 5 | #include "d3d9.h" 6 | 7 | interface hkIDirect3DVertexBuffer9 final : public IDirect3DVertexBuffer9 { 8 | public: 9 | /*** IUnknown methods ***/ 10 | STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj); 11 | STDMETHOD_(ULONG, AddRef)(THIS); 12 | STDMETHOD_(ULONG, Release)(THIS); 13 | 14 | /*** IDirect3DResource9 methods ***/ 15 | STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice); 16 | STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags); 17 | STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData); 18 | STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid); 19 | STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew); 20 | STDMETHOD_(DWORD, GetPriority)(THIS); 21 | STDMETHOD_(void, PreLoad)(THIS); 22 | STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS); 23 | STDMETHOD(Lock)(THIS_ UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags); 24 | STDMETHOD(Unlock)(THIS); 25 | STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC* pDesc); 26 | 27 | public: 28 | hkIDirect3DVertexBuffer9(IDirect3DDevice9* pIDirect3DDevice9, IDirect3DVertexBuffer9* pIDirect3DVertexBuffer9) 29 | : m_pWrapped(pIDirect3DVertexBuffer9), m_pIDirect3DDevice9(pIDirect3DDevice9) 30 | {} 31 | 32 | private: 33 | ~hkIDirect3DVertexBuffer9() 34 | { 35 | m_pWrapped->Release(); 36 | } 37 | 38 | LONG m_refCount = 1; 39 | IDirect3DVertexBuffer9 *m_pWrapped; 40 | IDirect3DDevice9* m_pIDirect3DDevice9; 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /d3d9ex/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DYNAMIC LINK LIBRARY : d3d9ex Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this d3d9ex DLL for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your d3d9ex application. 9 | 10 | 11 | d3d9ex.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | d3d9ex.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | d3d9ex.cpp 25 | This is the main DLL source file. 26 | 27 | When created, this DLL does not export any symbols. As a result, it 28 | will not produce a .lib file when it is built. If you wish this project 29 | to be a project dependency of some other project, you will either need to 30 | add code to export some symbols from the DLL so that an export library 31 | will be produced, or you can set the Ignore Input Library property to Yes 32 | on the General propert page of the Linker folder in the project's Property 33 | Pages dialog box. 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | Other standard files: 37 | 38 | StdAfx.h, StdAfx.cpp 39 | These files are used to build a precompiled header (PCH) file 40 | named d3d9ex.pch and a precompiled types file named StdAfx.obj. 41 | 42 | ///////////////////////////////////////////////////////////////////////////// 43 | Other notes: 44 | 45 | AppWizard uses "TODO:" comments to indicate parts of the source code you 46 | should add to or customize. 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | -------------------------------------------------------------------------------- /d3d9ex/Settings.h: -------------------------------------------------------------------------------- 1 | 2 | SETTING(u32, LongValue, PresentationInterval, Options, -1); 3 | SETTING(bool, BoolValue, TrippleBuffering, Options, false); 4 | SETTING(bool, BoolValue, AlwaysActive, Options, false); 5 | SETTING(bool, BoolValue, AutoFix, Options, true); 6 | SETTING(u32, LongValue, Multisample, Options, 0); 7 | SETTING(bool, BoolValue, HideCursor, Options, false); 8 | SETTING(bool, BoolValue, ForceHideCursor, Options, false); 9 | SETTING(u32, LongValue, BehaviorFlags, Options, 0); 10 | 11 | SETTING(bool, BoolValue, Adapter, Adapter, false); 12 | SETTING(u32, LongValue, VendorId, Adapter, 0); 13 | SETTING(u32, LongValue, DeviceId, Adapter, 0); 14 | 15 | SETTING(bool, BoolValue, Borderless, Borderless, false); 16 | SETTING(bool, BoolValue, ForceWindowedMode, Borderless, false); 17 | SETTING(bool, BoolValue, AllWindows, Borderless, false); 18 | SETTING(bool, BoolValue, TopMost, Borderless, false); 19 | SETTING(std::wstring, StringValue, WindowClass, Borderless, L""); 20 | SETTING(std::wstring, StringValue, WindowName, Borderless, L""); 21 | 22 | -------------------------------------------------------------------------------- /d3d9ex/Wrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "comdef.h" 4 | 5 | #include "d3d9.h" 6 | #include "dinput.h" 7 | #include "xinput.h" 8 | 9 | template 10 | class WrapperBase 11 | { 12 | public: 13 | WrapperBase(const WrapperBase&) = delete; 14 | const WrapperBase& operator=(WrapperBase& other) = delete; 15 | 16 | WrapperBase(): m_module(nullptr) {} 17 | 18 | ~WrapperBase() 19 | { 20 | if (m_module) 21 | { 22 | FreeLibrary(m_module); 23 | PrintLog("Unloaded %s", module_path.c_str()); 24 | } 25 | } 26 | 27 | static T& Get() 28 | { 29 | static T instance; 30 | return instance; 31 | } 32 | 33 | protected: 34 | void WrapperLoad(const char* module_name) 35 | { 36 | module_path = CreateSystemModulePath(module_name); 37 | m_module = LoadLibraryA(module_path.c_str()); 38 | 39 | if (!m_module) 40 | { 41 | HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); 42 | _com_error err(hr); 43 | 44 | std::string msg = StringFromFormat("Cannot load %s\nHRESULT 0x%08X: \"%s\"", module_path.c_str(), err.Error(), err.ErrorMessage()); 45 | 46 | PrintLog(msg.c_str()); 47 | MessageBoxA(NULL, msg.c_str(), "Error", MB_ICONERROR); 48 | ExitProcess(hr); 49 | } 50 | 51 | PrintLog("Loaded %s", module_path.c_str()); 52 | } 53 | 54 | template 55 | void StoreAddress(T* dest, const char* name) 56 | { 57 | *dest = reinterpret_cast(::GetProcAddress(m_module, name)); 58 | } 59 | 60 | private: 61 | HMODULE m_module; 62 | std::string module_path; 63 | }; 64 | 65 | class D3D9DLL : public WrapperBase 66 | { 67 | public: 68 | IDirect3D9* (WINAPI* Direct3DCreate9)(UINT SDKVersion); 69 | HRESULT(WINAPI* Direct3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex **ppD3D); 70 | 71 | int (WINAPI* D3DPERF_BeginEvent)(D3DCOLOR col, LPCWSTR wszName); 72 | int (WINAPI* D3DPERF_EndEvent)(void); 73 | 74 | DWORD(WINAPI* D3DPERF_GetStatus)(); 75 | BOOL(WINAPI* D3DPERF_QueryRepeatFrame)(); 76 | void (WINAPI* D3DPERF_SetMarker)(D3DCOLOR col, LPCWSTR wszName); 77 | void (WINAPI* D3DPERF_SetOptions)(DWORD dwOptions); 78 | void (WINAPI* D3DPERF_SetRegion)(D3DCOLOR col, LPCWSTR wszName); 79 | 80 | D3D9DLL() 81 | { 82 | WrapperLoad("d3d9.dll"); 83 | 84 | StoreAddress(&Direct3DCreate9, "Direct3DCreate9"); 85 | StoreAddress(&Direct3DCreate9Ex, "Direct3DCreate9Ex"); 86 | 87 | StoreAddress(&D3DPERF_BeginEvent, "D3DPERF_BeginEvent"); 88 | StoreAddress(&D3DPERF_EndEvent, "D3DPERF_EndEvent"); 89 | 90 | StoreAddress(&D3DPERF_GetStatus, "D3DPERF_GetStatus"); 91 | StoreAddress(&D3DPERF_QueryRepeatFrame, "D3DPERF_QueryRepeatFrame"); 92 | StoreAddress(&D3DPERF_SetMarker, "D3DPERF_SetMarker"); 93 | StoreAddress(&D3DPERF_SetOptions, "D3DPERF_SetOptions"); 94 | StoreAddress(&D3DPERF_SetRegion, "D3DPERF_SetRegion"); 95 | } 96 | }; 97 | 98 | extern "C" 99 | { 100 | 101 | IDirect3D9 * WINAPI _Direct3DCreate9(UINT SDKVersion) 102 | { 103 | return D3D9DLL::Get().Direct3DCreate9(SDKVersion); 104 | } 105 | 106 | HRESULT WINAPI _Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex **ppD3D) 107 | { 108 | return D3D9DLL::Get().Direct3DCreate9Ex(SDKVersion, ppD3D); 109 | } 110 | 111 | int WINAPI _D3DPERF_BeginEvent(D3DCOLOR col, LPCWSTR wszName) 112 | { 113 | return D3D9DLL::Get().D3DPERF_BeginEvent(col, wszName); 114 | } 115 | 116 | int WINAPI _D3DPERF_EndEvent() 117 | { 118 | return D3D9DLL::Get().D3DPERF_EndEvent(); 119 | } 120 | 121 | DWORD WINAPI _D3DPERF_GetStatus() 122 | { 123 | return D3D9DLL::Get().D3DPERF_GetStatus(); 124 | } 125 | 126 | BOOL WINAPI _D3DPERF_QueryRepeatFrame() 127 | { 128 | return D3D9DLL::Get().D3DPERF_QueryRepeatFrame(); 129 | } 130 | 131 | void WINAPI _D3DPERF_SetMarker(D3DCOLOR col, LPCWSTR wszName) 132 | { 133 | return D3D9DLL::Get().D3DPERF_SetMarker(col, wszName); 134 | } 135 | 136 | void WINAPI _D3DPERF_SetOptions(DWORD dwOptions) 137 | { 138 | return D3D9DLL::Get().D3DPERF_SetOptions(dwOptions); 139 | } 140 | 141 | void WINAPI _D3DPERF_SetRegion(D3DCOLOR col, LPCWSTR wszName) 142 | { 143 | return D3D9DLL::Get().D3DPERF_SetRegion(col, wszName); 144 | } 145 | } 146 | 147 | class DINPUT8DLL : public WrapperBase 148 | { 149 | public: 150 | 151 | HRESULT (WINAPI* DirectInput8Create)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); 152 | 153 | DINPUT8DLL() 154 | { 155 | WrapperLoad("dinput8.dll"); 156 | 157 | StoreAddress(&DirectInput8Create, "DirectInput8Create"); 158 | } 159 | }; 160 | 161 | extern "C" 162 | { 163 | HRESULT WINAPI _DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter) 164 | { 165 | return DINPUT8DLL::Get().DirectInput8Create(hinst, dwVersion, riidltf, ppvOut, punkOuter); 166 | } 167 | } 168 | 169 | class XINPUTDLL : public WrapperBase 170 | { 171 | public: 172 | 173 | // XInput 1.3 and older functions 174 | DWORD(WINAPI* XInputGetState)(DWORD dwUserIndex, XINPUT_STATE* pState); 175 | DWORD(WINAPI* XInputSetState)(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration); 176 | DWORD(WINAPI* XInputGetCapabilities)(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities); 177 | VOID(WINAPI* XInputEnable)(BOOL enable); 178 | DWORD(WINAPI* XInputGetDSoundAudioDeviceGuids)(DWORD dwUserIndex, GUID* pDSoundRenderGuid, GUID* pDSoundCaptureGuid); 179 | DWORD(WINAPI* XInputGetBatteryInformation)(DWORD dwUserIndex, BYTE devType, XINPUT_BATTERY_INFORMATION* pBatteryInformation); 180 | DWORD(WINAPI* XInputGetKeystroke)(DWORD dwUserIndex, DWORD dwReserved, PXINPUT_KEYSTROKE pKeystroke); 181 | 182 | // XInput 1.3 undocumented functions 183 | DWORD(WINAPI* XInputGetStateEx)(DWORD dwUserIndex, XINPUT_STATE *pState); // 100 184 | DWORD(WINAPI* XInputWaitForGuideButton)(DWORD dwUserIndex, DWORD dwFlag, LPVOID pVoid); // 101 185 | DWORD(WINAPI* XInputCancelGuideButtonWait)(DWORD dwUserIndex); // 102 186 | DWORD(WINAPI* XInputPowerOffController)(DWORD dwUserIndex); // 103 187 | 188 | // XInput 1.4 functions 189 | DWORD(WINAPI* XInputGetAudioDeviceIds)(DWORD dwUserIndex, LPWSTR pRenderDeviceId, UINT* pRenderCount, LPWSTR pCaptureDeviceId, UINT* pCaptureCount); 190 | 191 | // XInput 1.4 undocumented functionss 192 | DWORD(WINAPI* XInputGetBaseBusInformation)(DWORD dwUserIndex, struct XINPUT_BUSINFO* pBusinfo); // 104 193 | DWORD(WINAPI* XInputGetCapabilitiesEx)(DWORD unk1, DWORD dwUserIndex, DWORD dwFlags, struct XINPUT_CAPABILITIESEX* pCapabilitiesEx); // 108 194 | 195 | XINPUTDLL() 196 | { 197 | WrapperLoad("xinput1_3.dll"); 198 | 199 | // XInput 1.3 and older functions 200 | StoreAddress(&XInputGetState, "XInputGetState"); 201 | StoreAddress(&XInputSetState, "XInputSetState"); 202 | StoreAddress(&XInputGetCapabilities, "XInputGetCapabilities"); 203 | StoreAddress(&XInputEnable, "XInputEnable"); 204 | StoreAddress(&XInputGetDSoundAudioDeviceGuids, "XInputGetDSoundAudioDeviceGuids"); 205 | StoreAddress(&XInputGetBatteryInformation, "XInputGetBatteryInformation"); 206 | StoreAddress(&XInputGetKeystroke, "XInputGetKeystroke"); 207 | 208 | // XInput 1.3 undocumented functions 209 | StoreAddress(&XInputGetStateEx, (const char*)100); 210 | StoreAddress(&XInputWaitForGuideButton, (const char*)101); 211 | StoreAddress(&XInputCancelGuideButtonWait, (const char*)102); 212 | StoreAddress(&XInputPowerOffController, (const char*)103); 213 | 214 | // XInput 1.4 functions 215 | StoreAddress(&XInputGetAudioDeviceIds, "XInputGetAudioDeviceIds"); 216 | 217 | // XInput 1.4 undocumented functionss 218 | StoreAddress(&XInputGetBaseBusInformation, (const char*)104); 219 | StoreAddress(&XInputGetCapabilitiesEx, (const char*)108); 220 | } 221 | }; 222 | 223 | extern "C" 224 | { 225 | // XInput 1.3 and older functions 226 | DWORD WINAPI _XInputGetState(DWORD dwUserIndex, XINPUT_STATE* pState) 227 | { 228 | return XINPUTDLL::Get().XInputGetState(dwUserIndex, pState); 229 | } 230 | 231 | DWORD WINAPI _XInputSetState(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) 232 | { 233 | return XINPUTDLL::Get().XInputSetState(dwUserIndex, pVibration); 234 | } 235 | 236 | DWORD WINAPI _XInputGetCapabilities(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities) 237 | { 238 | return XINPUTDLL::Get().XInputGetCapabilities(dwUserIndex, dwFlags, pCapabilities); 239 | } 240 | 241 | VOID WINAPI _XInputEnable(BOOL enable) 242 | { 243 | return XINPUTDLL::Get().XInputEnable(enable); 244 | } 245 | 246 | DWORD WINAPI _XInputGetDSoundAudioDeviceGuids(DWORD dwUserIndex, GUID* pDSoundRenderGuid, GUID* pDSoundCaptureGuid) 247 | { 248 | return XINPUTDLL::Get().XInputGetDSoundAudioDeviceGuids(dwUserIndex, pDSoundRenderGuid, pDSoundCaptureGuid); 249 | } 250 | 251 | DWORD WINAPI _XInputGetBatteryInformation(DWORD dwUserIndex, BYTE devType, XINPUT_BATTERY_INFORMATION* pBatteryInformation) 252 | { 253 | return XINPUTDLL::Get().XInputGetBatteryInformation(dwUserIndex, devType, pBatteryInformation); 254 | } 255 | 256 | DWORD WINAPI _XInputGetKeystroke(DWORD dwUserIndex, DWORD dwReserved, PXINPUT_KEYSTROKE pKeystroke) 257 | { 258 | return XINPUTDLL::Get().XInputGetKeystroke(dwUserIndex, dwReserved, pKeystroke); 259 | } 260 | } 261 | -------------------------------------------------------------------------------- /d3d9ex/d3d9ex.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | 70 | 71 | Source Files 72 | 73 | 74 | -------------------------------------------------------------------------------- /d3d9ex/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | 10 | switch (ul_reason_for_call) 11 | { 12 | case DLL_PROCESS_ATTACH: 13 | static HMODULE current; 14 | GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPTSTR)¤t, ¤t); 15 | break; 16 | case DLL_THREAD_ATTACH: 17 | case DLL_THREAD_DETACH: 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | return TRUE; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /d3d9ex/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | Direct3DCreate9=_Direct3DCreate9 @30 3 | Direct3DCreate9Ex=_Direct3DCreate9Ex @31 4 | 5 | D3DPERF_BeginEvent=_D3DPERF_BeginEvent @20 6 | D3DPERF_EndEvent=_D3DPERF_EndEvent @21 7 | 8 | D3DPERF_GetStatus=_D3DPERF_GetStatus @22 9 | D3DPERF_QueryRepeatFrame=_D3DPERF_QueryRepeatFrame @23 10 | D3DPERF_SetMarker=_D3DPERF_SetMarker @24 11 | D3DPERF_SetOptions=_D3DPERF_SetOptions @25 12 | D3DPERF_SetRegion=_D3DPERF_SetRegion @26 13 | 14 | DirectInput8Create=_DirectInput8Create 15 | 16 | XInputGetState=_XInputGetState @2 17 | XInputSetState=_XInputSetState @3 18 | XInputGetCapabilities=_XInputGetCapabilities @4 19 | XInputEnable=_XInputEnable @5 20 | XInputGetDSoundAudioDeviceGuids=_XInputGetDSoundAudioDeviceGuids @6 21 | XInputGetBatteryInformation=_XInputGetBatteryInformation @7 22 | XInputGetKeystroke=_XInputGetKeystroke @8 23 | -------------------------------------------------------------------------------- /d3d9ex/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // d3d9ex.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /d3d9ex/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define NOMINMAX 11 | #define STRICT 12 | #define VC_EXTRALEAN 13 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 14 | // Windows Header Files: 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include "WinUtil.h" 32 | #include "Logger.h" -------------------------------------------------------------------------------- /d3d9ex/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | 10 | #define DIRECTINPUT_VERSION 0x0800 11 | --------------------------------------------------------------------------------