├── DivaImGui ├── stdafx.cpp ├── DivaImGui.rc ├── Keyboard │ ├── IInputDevice.h │ ├── KeyboardState.cpp │ ├── KeyboardState.h │ ├── Keyboard.h │ └── Keyboard.cpp ├── GLComponent.h ├── GLComponent101.h ├── GLComponentDummy.h ├── GLComponentGCST.h ├── GLComponentLight.h ├── targetver.h ├── resource.h ├── FileSystem │ ├── TextFile.h │ ├── ConfigFile.h │ ├── TextFile.cpp │ └── ConfigFile.cpp ├── stdafx.h ├── Utilities │ ├── Operations.h │ ├── Stopwatch.h │ ├── Stopwatch.cpp │ ├── Operations.cpp │ └── HookHelper.h ├── DX11 │ ├── inputclass.h │ ├── inputclass.cpp │ ├── graphicsclass.h │ ├── d3dclass.h │ ├── systemclass.h │ ├── graphicsclass.cpp │ └── systemclass.cpp ├── dllmain.cpp ├── DivaImGui.cpp ├── MainModule.h ├── GLHook │ └── GLHook.h ├── Constants101.h ├── Constants.h ├── DebugHook │ └── DebugHook701.h ├── MainModule.cpp └── DivaImGui.vcxproj.filters ├── Depedencies ├── detours │ ├── disolarm.cpp │ ├── disolarm64.cpp │ ├── disolia64.cpp │ ├── disolx86.cpp │ ├── disolx64.cpp │ ├── detver.h │ ├── Makefile │ └── uimports.cpp ├── imgui │ ├── imgui_impl_win32.h │ ├── imgui_impl_opengl2.h │ ├── imgui_impl_opengl3.h │ ├── imconfig.h │ └── imgui_impl_opengl2.cpp ├── snappy │ ├── snappy-stubs-internal.cc │ ├── snappy_uncompress_fuzzer.cc │ ├── snappy_compress_fuzzer.cc │ ├── snappy-stubs-public.h │ ├── snappy-sinksource.cc │ ├── snappy-c.cc │ ├── snappy-c.h │ ├── snappy-sinksource.h │ ├── snappy.h │ └── snappy-internal.h ├── MinHook.h ├── KHR │ └── khrplatform.h └── parser.hpp ├── Libraries ├── glew32.lib ├── libMinHook-x64-v141-md.lib ├── libMinHook-x64-v141-mdd.lib ├── libMinHook-x64-v141-mt.lib ├── libMinHook-x64-v141-mtd.lib ├── libMinHook-x86-v141-md.lib ├── libMinHook-x86-v141-mdd.lib ├── libMinHook-x86-v141-mt.lib └── libMinHook-x86-v141-mtd.lib ├── x64 └── Release │ ├── res_scale.csv │ └── graphics.ini ├── .gitattributes ├── Release ├── graphics.ini └── ShaderPatch.ini ├── README.md ├── DivaImGui.sln ├── LICENSE └── .gitignore /DivaImGui/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /Depedencies/detours/disolarm.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_ARM_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /DivaImGui/DivaImGui.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/DivaImGui/DivaImGui.rc -------------------------------------------------------------------------------- /Libraries/glew32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/glew32.lib -------------------------------------------------------------------------------- /Depedencies/detours/disolarm64.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_ARM64_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /Depedencies/detours/disolia64.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_IA64_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /Depedencies/detours/disolx86.cpp: -------------------------------------------------------------------------------- 1 | #if _WIN32 2 | #define DETOURS_X86_OFFLINE_LIBRARY 3 | #include "disasm.cpp" 4 | #endif -------------------------------------------------------------------------------- /Depedencies/detours/disolx64.cpp: -------------------------------------------------------------------------------- 1 | #if _WIN64 2 | #define DETOURS_X64_OFFLINE_LIBRARY 3 | #include "disasm.cpp" 4 | #endif 5 | -------------------------------------------------------------------------------- /Libraries/libMinHook-x64-v141-md.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/libMinHook-x64-v141-md.lib -------------------------------------------------------------------------------- /Libraries/libMinHook-x64-v141-mdd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/libMinHook-x64-v141-mdd.lib -------------------------------------------------------------------------------- /Libraries/libMinHook-x64-v141-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/libMinHook-x64-v141-mt.lib -------------------------------------------------------------------------------- /Libraries/libMinHook-x64-v141-mtd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/libMinHook-x64-v141-mtd.lib -------------------------------------------------------------------------------- /Libraries/libMinHook-x86-v141-md.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/libMinHook-x86-v141-md.lib -------------------------------------------------------------------------------- /Libraries/libMinHook-x86-v141-mdd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/libMinHook-x86-v141-mdd.lib -------------------------------------------------------------------------------- /Libraries/libMinHook-x86-v141-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/libMinHook-x86-v141-mt.lib -------------------------------------------------------------------------------- /Libraries/libMinHook-x86-v141-mtd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lybxlpsv/DivaImGui/HEAD/Libraries/libMinHook-x86-v141-mtd.lib -------------------------------------------------------------------------------- /DivaImGui/Keyboard/IInputDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace DivaImGui::Input 4 | { 5 | class IInputDevice 6 | { 7 | public: 8 | virtual bool PollInput() = 0; 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /x64/Release/res_scale.csv: -------------------------------------------------------------------------------- 1 | 249,0.9 2 | 253,0.95 3 | 254,0.9 4 | 255,0.66667 5 | 266,0.75 6 | 710,0.9 7 | 728,0.85 8 | 729,0.85 9 | 731,0.66667 10 | 733,0.9 11 | 734,0.75 12 | 737,0.8 13 | 740,0.9 -------------------------------------------------------------------------------- /DivaImGui/GLComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace DivaImGui 3 | { 4 | class GLComponent 5 | { 6 | public: 7 | GLComponent(); 8 | ~GLComponent(); 9 | void Initialize(); 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /DivaImGui/Keyboard/KeyboardState.cpp: -------------------------------------------------------------------------------- 1 | #include "KeyboardState.h" 2 | 3 | namespace DivaImGui::Input 4 | { 5 | bool KeyboardState::IsDown(BYTE keycode) 6 | { 7 | return KeyStates[keycode]; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /DivaImGui/GLComponent101.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace DivaImGui::V101 3 | { 4 | class GLComponent101 5 | { 6 | public: 7 | GLComponent101(); 8 | ~GLComponent101(); 9 | void Initialize(); 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /DivaImGui/GLComponentDummy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "GLHook/GLHook.h" 3 | 4 | namespace DivaImGui::Vdummy 5 | { 6 | class GLComponentDummy 7 | { 8 | public: 9 | GLComponentDummy(); 10 | ~GLComponentDummy(); 11 | void Initialize(); 12 | static int gamever; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /DivaImGui/Keyboard/KeyboardState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace DivaImGui::Input 5 | { 6 | const int KEYBOARD_KEYS = 0xFF; 7 | 8 | struct KeyboardState 9 | { 10 | BYTE KeyStates[KEYBOARD_KEYS]; 11 | 12 | bool IsDown(BYTE keycode); 13 | }; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /DivaImGui/GLComponentGCST.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "GLHook/GLHook.h" 3 | 4 | namespace DivaImGui::VGCST 5 | { 6 | class GLComponentLight 7 | { 8 | public: 9 | GLComponentLight(); 10 | ~GLComponentLight(); 11 | void Initialize(); 12 | static GLHook::GLCtrl glctrl; 13 | static int gamever; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /DivaImGui/GLComponentLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "GLHook/GLHook.h" 3 | 4 | namespace DivaImGui::VLight 5 | { 6 | class GLComponentLight 7 | { 8 | public: 9 | GLComponentLight(); 10 | ~GLComponentLight(); 11 | void Initialize(); 12 | static GLHook::GLCtrl glctrl; 13 | static int gamever; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /DivaImGui/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 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Source files 2 | *.c text diff=cpp 3 | *.cc text diff=cpp 4 | *.cxx text diff=cpp 5 | *.cpp text diff=cpp 6 | *.c++ text diff=cpp 7 | *.hpp text diff=cpp 8 | *.h text diff=cpp 9 | *.h++ text diff=cpp 10 | *.hh text diff=cpp 11 | 12 | # Compiled Object files 13 | *.slo binary 14 | *.lo binary 15 | *.o binary 16 | *.obj binary 17 | 18 | # Precompiled Headers 19 | *.gch binary 20 | *.pch binary 21 | -------------------------------------------------------------------------------- /DivaImGui/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by DivaImGui.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /DivaImGui/FileSystem/TextFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace DivaImGui::FileSystem 7 | { 8 | class TextFile 9 | { 10 | public: 11 | std::string FileName; 12 | 13 | TextFile(const std::string &path); 14 | TextFile(const std::string &directory, const std::string &file); 15 | ~TextFile(); 16 | 17 | bool OpenRead(); 18 | 19 | protected: 20 | virtual void Parse(std::ifstream &fileStream) = 0; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /DivaImGui/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 WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files 12 | #include 13 | 14 | 15 | 16 | // reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /DivaImGui/Utilities/Operations.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace DivaImGui::Utilities 8 | { 9 | std::vector Split(const std::string& str, const std::string& delim); 10 | 11 | void LeftTrim(std::string &s); 12 | void RightTrim(std::string &s); 13 | void Trim(std::string &s); 14 | 15 | std::string trim(const std::string& str, const std::string& whitespace = " \t"); 16 | } 17 | -------------------------------------------------------------------------------- /Release/graphics.ini: -------------------------------------------------------------------------------- 1 | # graphics.ini 2 | # do not enable features already implemented/enabled on tlac 3 | 4 | # game version 5 | version = 0.00 6 | 7 | # Disable if shaderpatch.dva exists! 8 | shaderpatch = 1 9 | 10 | # If using Intel and Sprites still doesn't work, enable this 11 | disableSprShaders = 0 12 | 13 | # disable when using ELAC Experimental! 14 | disableGui = 0 15 | 16 | # set the default fps limit 17 | fpsLimit = 60 18 | 19 | Vsync = 0 20 | glswapinterval = 1 21 | dbg = 0 22 | 23 | showFps = 1 -------------------------------------------------------------------------------- /DivaImGui/Utilities/Stopwatch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace chrono = std::chrono; 5 | 6 | typedef chrono::time_point steady_clock; 7 | typedef chrono::high_resolution_clock high_resolution_clock; 8 | 9 | namespace DivaImGui::Utilities 10 | { 11 | class Stopwatch 12 | { 13 | const float TIME_FACTOR = 1000.0f; 14 | 15 | public: 16 | Stopwatch(); 17 | ~Stopwatch(); 18 | 19 | void Start(); 20 | float Stop(); 21 | float Restart(); 22 | 23 | float GetElapsed(); 24 | 25 | private: 26 | steady_clock start; 27 | steady_clock end; 28 | }; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DivaImGui (x64) 2 | 3 | An in-game UI which can be used with [TLAC](https://github.com/samyuu/TotallyLegitArcadeController) or [PD-Loader](https://notabug.org/nastys/PD-Loader). 4 | 5 | # Download 6 | 7 | [Development Build](https://ci.appveyor.com/project/lybxlpsv/divaimgui/build/artifacts) (Use this when using latest development build of PD Loader) 8 | 9 | [Guide for Intel (u)HD users](https://github.com/lybxlpsv/DivaImGui/wiki/AMD-and-Intel-Guide) 10 | 11 | # Special Thanks 12 | 13 | [Samyuu](https://github.com/samyuu/) (for TLAC), [BesuBaru](https://github.com/BesuBaru), [somewhatlurker](https://github.com/somewhatlurker), [Raki Saionji](https://github.com/rakisaionji). 14 | -------------------------------------------------------------------------------- /DivaImGui/Utilities/Stopwatch.cpp: -------------------------------------------------------------------------------- 1 | #include "Stopwatch.h" 2 | 3 | namespace DivaImGui::Utilities 4 | { 5 | Stopwatch::Stopwatch() 6 | { 7 | } 8 | 9 | Stopwatch::~Stopwatch() 10 | { 11 | } 12 | 13 | void Stopwatch::Start() 14 | { 15 | start = high_resolution_clock::now(); 16 | } 17 | 18 | float Stopwatch::Stop() 19 | { 20 | end = high_resolution_clock::now(); 21 | return GetElapsed(); 22 | } 23 | 24 | float Stopwatch::Restart() 25 | { 26 | float elapsed = Stop(); 27 | Start(); 28 | 29 | return elapsed; 30 | } 31 | 32 | float Stopwatch::GetElapsed() 33 | { 34 | return (float)(chrono::duration_cast(end - start).count() / TIME_FACTOR); 35 | } 36 | } -------------------------------------------------------------------------------- /DivaImGui/FileSystem/ConfigFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TextFile.h" 4 | #include 5 | 6 | namespace DivaImGui::FileSystem 7 | { 8 | class ConfigFile : public TextFile 9 | { 10 | public: 11 | ConfigFile(const std::string &path); 12 | ConfigFile(const std::string &directory, const std::string &file); 13 | 14 | std::unordered_map ConfigMap; 15 | 16 | bool TryGetValue(const std::string &key, std::string **value); 17 | int GetIntegerValue(const std::string& key); 18 | bool GetBooleanValue(const std::string& key); 19 | float GetFloatValue(const std::string& key); 20 | 21 | protected: 22 | virtual void Parse(std::ifstream &fileStream) override; 23 | 24 | private: 25 | bool IsComment(const std::string &line); 26 | }; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /DivaImGui/DX11/inputclass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Filename: inputclass.h 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef _INPUTCLASS_H_ 5 | #define _INPUTCLASS_H_ 6 | 7 | 8 | //////////////////////////////////////////////////////////////////////////////// 9 | // Class name: InputClass 10 | //////////////////////////////////////////////////////////////////////////////// 11 | class InputClass 12 | { 13 | public: 14 | InputClass(); 15 | InputClass(const InputClass&); 16 | ~InputClass(); 17 | 18 | void Initialize(); 19 | 20 | void KeyDown(unsigned int); 21 | void KeyUp(unsigned int); 22 | 23 | bool IsKeyDown(unsigned int); 24 | 25 | private: 26 | bool m_keys[256]; 27 | }; 28 | 29 | #endif -------------------------------------------------------------------------------- /Depedencies/detours/detver.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Common version parameters. 4 | // 5 | // Microsoft Research Detours Package, Version 4.0.1 6 | // 7 | // Copyright (c) Microsoft Corporation. All rights reserved. 8 | // 9 | 10 | #define _USING_V110_SDK71_ 1 11 | #include "winver.h" 12 | #if 0 13 | #include 14 | #include 15 | #else 16 | #ifndef DETOURS_STRINGIFY 17 | #define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x) 18 | #define DETOURS_STRINGIFY_(x) #x 19 | #endif 20 | 21 | #define VER_FILEFLAGSMASK 0x3fL 22 | #define VER_FILEFLAGS 0x0L 23 | #define VER_FILEOS 0x00040004L 24 | #define VER_FILETYPE 0x00000002L 25 | #define VER_FILESUBTYPE 0x00000000L 26 | #endif 27 | #define VER_DETOURS_BITS DETOUR_STRINGIFY(DETOURS_BITS) 28 | -------------------------------------------------------------------------------- /DivaImGui/FileSystem/TextFile.cpp: -------------------------------------------------------------------------------- 1 | #include "TextFile.h" 2 | #include 3 | 4 | namespace fs = std::filesystem; 5 | 6 | namespace DivaImGui::FileSystem 7 | { 8 | TextFile::TextFile(const std::string &path) 9 | { 10 | FileName = path; 11 | } 12 | 13 | TextFile::TextFile(const std::string &directory, const std::string &file) 14 | { 15 | auto fullPath = directory + "/" + file; 16 | FileName = fullPath; 17 | } 18 | 19 | TextFile::~TextFile() 20 | { 21 | } 22 | 23 | bool TextFile::OpenRead() 24 | { 25 | fs::path configPath = fs::u8path(FileName); 26 | 27 | if (!fs::exists(configPath)) 28 | return false; 29 | 30 | std::ifstream fileStream(configPath.wstring().c_str()); 31 | 32 | if (!fileStream.is_open()) 33 | return false; 34 | 35 | Parse(fileStream); 36 | 37 | fileStream.close(); 38 | 39 | return true; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /DivaImGui/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | #include "windows.h" 4 | #include "MainModule.h" 5 | #include "GLComponent.h" 6 | 7 | 8 | 9 | void AttachImGui() 10 | { 11 | printf("[DivaImGui] Initializing hooks...\n"); 12 | DivaImGui::MainModule::initializeglcomp(); 13 | printf("[DivaImGui] Hooks initialized\n"); 14 | } 15 | 16 | BOOL APIENTRY DllMain( HMODULE hModule, 17 | DWORD ul_reason_for_call, 18 | LPVOID lpReserved 19 | ) 20 | { 21 | switch (ul_reason_for_call) 22 | { 23 | case DLL_PROCESS_ATTACH: 24 | 25 | 26 | DivaImGui::MainModule::Module = hModule; 27 | AttachImGui(); 28 | break; 29 | case DLL_THREAD_ATTACH: 30 | case DLL_THREAD_DETACH: 31 | case DLL_PROCESS_DETACH: 32 | break; 33 | } 34 | return TRUE; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /DivaImGui/DivaImGui.cpp: -------------------------------------------------------------------------------- 1 | // DivaImGui.cpp : Defines the exported functions for the DLL application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "MainModule.h" 6 | 7 | 8 | #define EXTERN_DLL_EXPORT extern "C" __declspec(dllexport) 9 | 10 | EXTERN_DLL_EXPORT LPCWSTR GetPluginName() { 11 | return L"DivaImGui"; 12 | } 13 | 14 | EXTERN_DLL_EXPORT LPCWSTR GetPluginDescription() { 15 | return L"DivaImGui Plugin by lybxlpsv\nDivaImGui adds an In-Game Interface."; 16 | } 17 | 18 | EXTERN_DLL_EXPORT int getVersion() { 19 | return 2; 20 | } 21 | 22 | EXTERN_DLL_EXPORT int getFrameRate() { 23 | return DivaImGui::MainModule::fpsLimitSet; 24 | } 25 | 26 | EXTERN_DLL_EXPORT void showUi() { 27 | DivaImGui::MainModule::showUi = true; 28 | return; 29 | } 30 | 31 | EXTERN_DLL_EXPORT void hideUi() { 32 | DivaImGui::MainModule::showUi = false; 33 | return; 34 | } 35 | 36 | EXTERN_DLL_EXPORT void toggleUi() { 37 | DivaImGui::MainModule::showUi = !DivaImGui::MainModule::showUi; 38 | return; 39 | } 40 | 41 | EXTERN_DLL_EXPORT bool getUiState() { 42 | return DivaImGui::MainModule::showUi; 43 | } -------------------------------------------------------------------------------- /DivaImGui/DX11/inputclass.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Filename: inputclass.cpp 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #include "inputclass.h" 5 | 6 | 7 | InputClass::InputClass() 8 | { 9 | } 10 | 11 | 12 | InputClass::InputClass(const InputClass& other) 13 | { 14 | } 15 | 16 | 17 | InputClass::~InputClass() 18 | { 19 | } 20 | 21 | 22 | void InputClass::Initialize() 23 | { 24 | int i; 25 | 26 | 27 | // Initialize all the keys to being released and not pressed. 28 | for(i=0; i<256; i++) 29 | { 30 | m_keys[i] = false; 31 | } 32 | 33 | return; 34 | } 35 | 36 | 37 | void InputClass::KeyDown(unsigned int input) 38 | { 39 | // If a key is pressed then save that state in the key array. 40 | m_keys[input] = true; 41 | return; 42 | } 43 | 44 | 45 | void InputClass::KeyUp(unsigned int input) 46 | { 47 | // If a key is released then clear that state in the key array. 48 | m_keys[input] = false; 49 | return; 50 | } 51 | 52 | 53 | bool InputClass::IsKeyDown(unsigned int key) 54 | { 55 | // Return what state the key is in (pressed/not pressed). 56 | return m_keys[key]; 57 | } -------------------------------------------------------------------------------- /DivaImGui/MainModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "GLComponent.h" 5 | #include "GLComponent101.h" 6 | #include "GLComponentLight.h" 7 | #include "GLComponentDummy.h" 8 | #include "GLComponentGCST.h" 9 | 10 | namespace DivaImGui 11 | { 12 | class MainModule 13 | { 14 | private: 15 | static std::string *moduleDirectory; 16 | 17 | public: 18 | static const wchar_t* DivaWindowName; 19 | static const wchar_t* ODivaWindowName; 20 | static const wchar_t* GlutDefaultName; 21 | static const wchar_t* freeGlutDefaultName; 22 | 23 | static HWND DivaWindowHandle; 24 | static HMODULE Module; 25 | 26 | static int fpsLimit; 27 | static int fpsLimitSet; 28 | static bool inputDisable; 29 | 30 | static DivaImGui::GLComponent glcomp; 31 | static DivaImGui::V101::GLComponent101 glcomp101; 32 | static DivaImGui::VLight::GLComponentLight glcomplight; 33 | static DivaImGui::VGCST::GLComponentLight glcompgcst; 34 | static DivaImGui::Vdummy::GLComponentDummy glcompdummy; 35 | 36 | static bool showUi; 37 | static std::string GetModuleDirectory(); 38 | static RECT GetWindowBounds(); 39 | 40 | static void initializeglcomp(); 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /DivaImGui/GLHook/GLHook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "GL/glew.h" 6 | #include "GL/gl.h" 7 | #include "GL/wglext.h" 8 | 9 | namespace DivaImGui::GLHook 10 | { 11 | struct ShaderPatchInfo { 12 | std::regex fileRegex; 13 | std::regex dataRegex; 14 | std::string dataReplace; 15 | std::vector archs; 16 | std::string cfg; 17 | }; 18 | 19 | struct SimpleReplace { 20 | std::string find; 21 | std::string replace; 22 | }; 23 | 24 | struct shaderNames { 25 | GLuint gluint; 26 | GLenum glenum; 27 | std::string filename; 28 | std::string file; 29 | }; 30 | 31 | enum iState { Busy, Idle }; 32 | 33 | class GLCtrl 34 | { 35 | 36 | public: 37 | static bool Enabled; 38 | static bool Initialized; 39 | static int gamever; 40 | static int refreshshd; 41 | static bool shaderaftmodified; 42 | static bool isAmd; 43 | static bool isIntel; 44 | static bool disableGpuDetect; 45 | static bool disableSprShader; 46 | static bool debug; 47 | static iState ShdState; 48 | static int ShaderPatchPos; 49 | static bool patchAsGameLoads; 50 | static void* fnuglswapbuffer; 51 | static void Update(HDC hdc); 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /DivaImGui/Keyboard/Keyboard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IInputDevice.h" 3 | #include "KeyboardState.h" 4 | #include "../Utilities/Stopwatch.h" 5 | 6 | using Stopwatch = DivaImGui::Utilities::Stopwatch; 7 | 8 | namespace DivaImGui::Input 9 | { 10 | constexpr float DOUBLE_TAP_THRESHOLD = 200.0f; 11 | constexpr float INTERVAL_TAP_DELAY_THRESHOLD = 500.0f; 12 | constexpr float INTERVAL_TAP_THRESHOLD = 75.0f; 13 | 14 | class Keyboard : public IInputDevice 15 | { 16 | public: 17 | static Keyboard* GetInstance(); 18 | 19 | bool PollInput() override; 20 | bool IsDown(BYTE keycode); 21 | bool IsUp(BYTE keycode); 22 | bool IsTapped(BYTE keycode); 23 | bool IsDoubleTapped(BYTE keycode); 24 | bool IsReleased(BYTE keycode); 25 | bool IsIntervalTapped(BYTE keycode); 26 | 27 | bool WasDown(BYTE keycode); 28 | bool WasUp(BYTE keycode); 29 | 30 | private: 31 | Keyboard(); 32 | KeyboardState lastState; 33 | KeyboardState currentState; 34 | 35 | Stopwatch keyIntervalWatch; 36 | 37 | BYTE keyDoubleTapStates[KEYBOARD_KEYS]; 38 | Stopwatch keyDoubleTapWatches[KEYBOARD_KEYS]; 39 | 40 | BOOL keyIntervalInitials[KEYBOARD_KEYS]; 41 | BYTE keyIntervalTapStates[KEYBOARD_KEYS]; 42 | FLOAT keyIntervalTapTimes[KEYBOARD_KEYS]; 43 | 44 | static Keyboard* instance; 45 | }; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Depedencies/imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core imgui) 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | 10 | #pragma once 11 | 12 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 13 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 14 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 15 | 16 | // Handler for Win32 messages, update mouse/keyboard data. 17 | // You may or not need this for your implementation, but it can serve as reference for handling inputs. 18 | // Intentionally commented out to avoid dragging dependencies on types. You can COPY this line into your .cpp code instead. 19 | /* 20 | IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 21 | */ 22 | -------------------------------------------------------------------------------- /DivaImGui/DX11/graphicsclass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Filename: graphicsclass.h 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef _GRAPHICSCLASS_H_ 5 | #define _GRAPHICSCLASS_H_ 6 | 7 | 8 | /////////////////////// 9 | // MY CLASS INCLUDES // 10 | /////////////////////// 11 | #include "d3dclass.h" 12 | #include 13 | #include 14 | 15 | ///////////// 16 | // GLOBALS // 17 | ///////////// 18 | const float SCREEN_DEPTH = 1000.0f; 19 | const float SCREEN_NEAR = 0.1f; 20 | 21 | 22 | //////////////////////////////////////////////////////////////////////////////// 23 | // Class name: GraphicsClass 24 | //////////////////////////////////////////////////////////////////////////////// 25 | class GraphicsClass 26 | { 27 | public: 28 | GraphicsClass(); 29 | GraphicsClass(const GraphicsClass&); 30 | ~GraphicsClass(); 31 | 32 | bool Initialize(int, int, HWND); 33 | void Shutdown(); 34 | bool Frame(); 35 | 36 | static bool FULL_SCREEN; 37 | static bool VSYNC_ENABLED; 38 | static int SWAPCHAIN_FORMAT; 39 | static int DISPLAY_FORMAT; 40 | static int DISPLAY_FORMAT2; 41 | static HDC currentHdc; 42 | static bool reinit; 43 | private: 44 | bool Render(); 45 | 46 | private: 47 | D3DClass* m_D3D; 48 | }; 49 | 50 | #endif -------------------------------------------------------------------------------- /DivaImGui/Utilities/Operations.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Operations.h" 3 | 4 | namespace DivaImGui::Utilities 5 | { 6 | std::vector Split(const std::string& str, const std::string& delim) 7 | { 8 | std::vector tokens; 9 | size_t prev = 0, pos = 0; 10 | do 11 | { 12 | pos = str.find(delim, prev); 13 | if (pos == std::string::npos) 14 | pos = str.length(); 15 | 16 | std::string token = str.substr(prev, pos - prev); 17 | 18 | if (!token.empty()) 19 | tokens.push_back(token); 20 | 21 | prev = pos + delim.length(); 22 | } while (pos < str.length() && prev < str.length()); 23 | 24 | return tokens; 25 | } 26 | 27 | void LeftTrim(std::string &s) 28 | { 29 | s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) 30 | { 31 | return !std::isspace(ch); 32 | })); 33 | } 34 | 35 | void RightTrim(std::string &s) 36 | { 37 | s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) 38 | { 39 | return !std::isspace(ch); 40 | }).base(), s.end()); 41 | } 42 | 43 | void Trim(std::string &s) 44 | { 45 | s = trim(s); 46 | } 47 | 48 | std::string trim(const std::string& str, const std::string& whitespace) 49 | { 50 | const size_t strBegin = str.find_first_not_of(whitespace); 51 | 52 | if (strBegin == std::string::npos) 53 | return ""; 54 | 55 | const size_t strEnd = str.find_last_not_of(whitespace); 56 | const size_t strRange = strEnd - strBegin + 1; 57 | 58 | return str.substr(strBegin, strRange); 59 | } 60 | } -------------------------------------------------------------------------------- /DivaImGui.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28803.452 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DivaImGui", "DivaImGui\DivaImGui.vcxproj", "{A275D083-3F99-4772-98F7-FDE089020F60}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A275D083-3F99-4772-98F7-FDE089020F60}.Debug|x64.ActiveCfg = Debug|x64 17 | {A275D083-3F99-4772-98F7-FDE089020F60}.Debug|x64.Build.0 = Debug|x64 18 | {A275D083-3F99-4772-98F7-FDE089020F60}.Debug|x86.ActiveCfg = Debug|Win32 19 | {A275D083-3F99-4772-98F7-FDE089020F60}.Debug|x86.Build.0 = Debug|Win32 20 | {A275D083-3F99-4772-98F7-FDE089020F60}.Release|x64.ActiveCfg = Release|x64 21 | {A275D083-3F99-4772-98F7-FDE089020F60}.Release|x64.Build.0 = Release|x64 22 | {A275D083-3F99-4772-98F7-FDE089020F60}.Release|x86.ActiveCfg = Release|Win32 23 | {A275D083-3F99-4772-98F7-FDE089020F60}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {41A2E0D2-365A-43B8-BA48-A9A9A4B78CFD} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /DivaImGui/DX11/d3dclass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Filename: d3dclass.h 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef _D3DCLASS_H_ 5 | #define _D3DCLASS_H_ 6 | 7 | 8 | ///////////// 9 | // LINKING // 10 | ///////////// 11 | #pragma comment(lib, "dxgi.lib") 12 | #pragma comment(lib, "d3d11.lib") 13 | 14 | 15 | ////////////// 16 | // INCLUDES // 17 | ////////////// 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | //////////////////////////////////////////////////////////////////////////////// 24 | // Class name: D3DClass 25 | //////////////////////////////////////////////////////////////////////////////// 26 | class D3DClass 27 | { 28 | public: 29 | D3DClass(); 30 | D3DClass(const D3DClass&); 31 | ~D3DClass(); 32 | 33 | bool Initialize(int, int, bool, HWND, bool, float, float); 34 | void Shutdown(); 35 | 36 | void BeginScene(float, float, float, float); 37 | void EndScene(); 38 | 39 | ID3D11Device* GetDevice(); 40 | ID3D11DeviceContext* GetDeviceContext(); 41 | 42 | void GetVideoCardInfo(char*, int&); 43 | 44 | private: 45 | bool m_vsync_enabled; 46 | int m_videoCardMemory; 47 | char m_videoCardDescription[128]; 48 | IDXGISwapChain* m_swapChain; 49 | ID3D11Device* m_device; 50 | ID3D11DeviceContext* m_deviceContext; 51 | ID3D11RenderTargetView* m_renderTargetView; 52 | ID3D11Texture2D* m_depthStencilBuffer; 53 | ID3D11DepthStencilState* m_depthStencilState; 54 | ID3D11DepthStencilView* m_depthStencilView; 55 | ID3D11RasterizerState* m_rasterState; 56 | }; 57 | 58 | #endif -------------------------------------------------------------------------------- /DivaImGui/DX11/systemclass.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Filename: systemclass.h 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef _SYSTEMCLASS_H_ 5 | #define _SYSTEMCLASS_H_ 6 | 7 | 8 | /////////////////////////////// 9 | // PRE-PROCESSING DIRECTIVES // 10 | /////////////////////////////// 11 | #define WIN32_LEAN_AND_MEAN 12 | 13 | 14 | ////////////// 15 | // INCLUDES // 16 | ////////////// 17 | #include 18 | 19 | 20 | /////////////////////// 21 | // MY CLASS INCLUDES // 22 | /////////////////////// 23 | #include "inputclass.h" 24 | #include "graphicsclass.h" 25 | 26 | 27 | //////////////////////////////////////////////////////////////////////////////// 28 | // Class name: SystemClass 29 | //////////////////////////////////////////////////////////////////////////////// 30 | class SystemClass 31 | { 32 | public: 33 | SystemClass(); 34 | SystemClass(const SystemClass&); 35 | ~SystemClass(); 36 | 37 | bool Initialize(); 38 | void Shutdown(); 39 | void Run(); 40 | 41 | LRESULT CALLBACK MessageHandler(HWND, UINT, WPARAM, LPARAM); 42 | void InitializeWindows(int&, int&); 43 | HWND m_hwnd; 44 | GraphicsClass* m_Graphics; 45 | private: 46 | bool Frame(); 47 | 48 | void ShutdownWindows(); 49 | 50 | private: 51 | LPCWSTR m_applicationName; 52 | HINSTANCE m_hinstance; 53 | 54 | 55 | InputClass* m_Input; 56 | 57 | }; 58 | 59 | 60 | ///////////////////////// 61 | // FUNCTION PROTOTYPES // 62 | ///////////////////////// 63 | static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 64 | 65 | 66 | ///////////// 67 | // GLOBALS // 68 | ///////////// 69 | static SystemClass* ApplicationHandle = 0; 70 | 71 | 72 | #endif -------------------------------------------------------------------------------- /Depedencies/imgui/imgui_impl_opengl2.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline) 2 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. 6 | 7 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 8 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 9 | // https://github.com/ocornut/imgui 10 | 11 | // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** 12 | // **Prefer using the code in imgui_impl_opengl3.cpp** 13 | // This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read. 14 | // If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more 15 | // complicated, will require your code to reset every single OpenGL attributes to their initial state, and might 16 | // confuse your GPU driver. 17 | // The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API. 18 | 19 | #pragma once 20 | 21 | IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init(); 22 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown(); 23 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_NewFrame(); 24 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data); 25 | 26 | // Called by Init/NewFrame/Shutdown 27 | IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateFontsTexture(); 28 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture(); 29 | IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects(); 30 | IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects(); 31 | -------------------------------------------------------------------------------- /DivaImGui/Utilities/HookHelper.h: -------------------------------------------------------------------------------- 1 | #define PRINT(value, ...) printf(value, __VA_ARGS__); 2 | 3 | #define PROC_ADDRESS(libraryName, procName) \ 4 | GetProcAddress(LoadLibrary(TEXT(libraryName)), procName) 5 | 6 | #define SAFE_RELEASE(object) if (object) { object->Release(); object = NULL; } 7 | 8 | #define VTABLE_HOOK(returnType, className, functionName, ...) \ 9 | typedef returnType functionName(className* This, __VA_ARGS__); \ 10 | functionName* original##functionName; \ 11 | returnType implOf##functionName(className* This, __VA_ARGS__) 12 | 13 | #define INSTALL_VTABLE_HOOK(object, functionName, functionIndex) \ 14 | { \ 15 | void** addr = &(*(void***)object)[functionIndex]; \ 16 | if (*addr != implOf##functionName) \ 17 | { \ 18 | PRINT("[DivaImGui] Installing %s hook...\n", #functionName); \ 19 | original##functionName = (functionName*)*addr; \ 20 | DWORD oldProtect; \ 21 | VirtualProtect(addr, sizeof(void*), PAGE_EXECUTE_READWRITE, &oldProtect); \ 22 | *addr = implOf##functionName; \ 23 | VirtualProtect(addr, sizeof(void*), oldProtect, NULL); \ 24 | } \ 25 | } 26 | 27 | #define HOOK(returnType, function, location, ...) \ 28 | typedef returnType function(__VA_ARGS__); \ 29 | function* original##function = (function*)location; \ 30 | returnType implOf##function(__VA_ARGS__) 31 | 32 | #define INSTALL_HOOK(functionName) \ 33 | { \ 34 | PRINT("[DivaImGui] Installing %s hook...\n", #functionName); \ 35 | DetourTransactionBegin(); \ 36 | DetourUpdateThread(GetCurrentThread()); \ 37 | DetourAttach((void**)&original##functionName, implOf##functionName); \ 38 | DetourTransactionCommit(); \ 39 | } 40 | 41 | #define ASSERT(function) \ 42 | if (FAILED(result = (function))) \ 43 | { \ 44 | PRINT("[DivaImGui] %s failed (error code: 0x%08x)\n", #function, (unsigned int)result); \ 45 | goto end; \ 46 | } /*\ 47 | else \ 48 | { \ 49 | PRINT("[DivaMovie] %s succeeded\n", #function); \ 50 | }*/ -------------------------------------------------------------------------------- /x64/Release/graphics.ini: -------------------------------------------------------------------------------- 1 | # graphics.ini 2 | # do not enable features already implemented/enabled on tlac 3 | 4 | # game version 5 | version = 7.10 6 | #version = 1.01 7 | 8 | # Disable GPU Detection, will always assume you are using NVIDIA 9 | disableGpuDetect = 0 10 | 11 | # Disable if shaderpatch.dva exists! 12 | shaderpatch = 0 13 | 14 | # Patch shaders after the game loads to reduce load time 15 | patchAsGameLoads = 0 16 | 17 | # If using Intel and Sprites still doesn't work, enable this 18 | disableSprShaders = 0 19 | 20 | # set the default fps limit 21 | fpsLimit = 60 22 | 23 | # framebuffer default width and height 24 | # do not exceed maxWidth and maxHeight 25 | #fbwidth = 1600 26 | #fbheight = 900 27 | 28 | # set render resolution to maxWidth and maxHeight 29 | # load dll before glut init when using this 30 | customRes = false 31 | maxWidth = 3840 32 | maxHeight = 2160 33 | 34 | # usual graphics option 35 | TAA = 0 36 | MLAA = 1 37 | disableDof = 0 38 | Vsync = 0 39 | glswapinterval = 1 40 | toonShaderWorkaround = 1 41 | forceToonShader = 0 42 | forceDisableOutline = 0 43 | 44 | # overlay options 45 | showFps = 1 46 | 47 | # reShade Standalone 48 | # no longer supported, use https://github.com/lybxlpsv/reshade/releases instead. 49 | depthCopy = 0 50 | 51 | # for DivaImGuiReShade.dva 52 | # 0 = behind sprites 53 | # 1 = in front of sprites 54 | ReShadeState = 0 55 | 56 | # lyb specific components 57 | 58 | # override switch when gpu detection is disabled 59 | # intel = 1 60 | # amd = 1 61 | 62 | # force Lightweight mode 63 | forceLightweight = 0 64 | 65 | # scale component 66 | scaling = 0 67 | 68 | # pv/aet framerate manager 69 | # if fpsLimit is 0, it will be set to the current monitor refresh rate 70 | frm = 0 71 | 72 | # others 73 | dbg = 0 74 | forcevsyncfpslimit = 0 75 | motifrm = 1500 76 | HOOK_TYPE = 1 77 | 78 | # Experimental DX11 (NVIDIA Only, Fullscreen Only) 79 | dxgi = 0 80 | # refer to DXGIFormats.h for the values 81 | SWAPCHAIN_FORMAT = 28 82 | DISPLAY_FORMAT = 28 83 | DISPLAY_FORMAT2 = 28 -------------------------------------------------------------------------------- /Depedencies/snappy/snappy-stubs-internal.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | #include "snappy-stubs-internal.h" 33 | 34 | namespace snappy { 35 | 36 | void Varint::Append32(std::string* s, uint32 value) { 37 | char buf[Varint::kMax32]; 38 | const char* p = Varint::Encode32(buf, value); 39 | s->append(buf, p - buf); 40 | } 41 | 42 | } // namespace snappy 43 | -------------------------------------------------------------------------------- /DivaImGui/DX11/graphicsclass.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Filename: graphicsclass.cpp 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #include "graphicsclass.h" 5 | 6 | int GraphicsClass::DISPLAY_FORMAT = 28; 7 | int GraphicsClass::SWAPCHAIN_FORMAT = 28; 8 | int GraphicsClass::DISPLAY_FORMAT2 = 28; 9 | bool GraphicsClass::FULL_SCREEN = true; 10 | bool GraphicsClass::VSYNC_ENABLED = false; 11 | HDC GraphicsClass::currentHdc = NULL; 12 | bool GraphicsClass::reinit = false; 13 | GraphicsClass::GraphicsClass() 14 | { 15 | m_D3D = 0; 16 | } 17 | 18 | 19 | GraphicsClass::GraphicsClass(const GraphicsClass& other) 20 | { 21 | } 22 | 23 | 24 | GraphicsClass::~GraphicsClass() 25 | { 26 | } 27 | 28 | 29 | bool GraphicsClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) 30 | { 31 | bool result; 32 | 33 | // Create the Direct3D object. 34 | m_D3D = new D3DClass; 35 | if(!m_D3D) 36 | { 37 | return false; 38 | } 39 | 40 | // Initialize the Direct3D object. 41 | result = m_D3D->Initialize(screenWidth, screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR); 42 | if(!result) 43 | { 44 | MessageBox(hwnd, L"Could not initialize Direct3D.", L"Error", MB_OK); 45 | return false; 46 | } 47 | 48 | return true; 49 | } 50 | 51 | 52 | void GraphicsClass::Shutdown() 53 | { 54 | // Release the D3D object. 55 | if(m_D3D) 56 | { 57 | m_D3D->Shutdown(); 58 | delete m_D3D; 59 | m_D3D = 0; 60 | } 61 | 62 | return; 63 | } 64 | 65 | 66 | bool GraphicsClass::Frame() 67 | { 68 | bool result; 69 | 70 | 71 | // Render the graphics scene. 72 | result = Render(); 73 | if(!result) 74 | { 75 | return false; 76 | } 77 | 78 | return true; 79 | } 80 | 81 | 82 | bool GraphicsClass::Render() 83 | { 84 | // Clear the buffers to begin the scene. 85 | m_D3D->BeginScene(0.5f, 0.5f, 0.5f, 1.0f); 86 | 87 | 88 | // Present the rendered scene to the screen. 89 | m_D3D->EndScene(); 90 | 91 | return true; 92 | } -------------------------------------------------------------------------------- /DivaImGui/FileSystem/ConfigFile.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ConfigFile.h" 3 | #include "../Utilities/Operations.h" 4 | 5 | namespace DivaImGui::FileSystem 6 | { 7 | ConfigFile::ConfigFile(const std::string &path) : TextFile(path) 8 | { 9 | return; 10 | } 11 | 12 | ConfigFile::ConfigFile(const std::string &directory, const std::string &file) : TextFile(directory, file) 13 | { 14 | return; 15 | } 16 | 17 | bool ConfigFile::TryGetValue(const std::string &key, std::string **value) 18 | { 19 | auto pair = ConfigMap.find(key); 20 | bool found = pair != ConfigMap.end(); 21 | 22 | *value = found ? new std::string(pair->second) : nullptr; 23 | return found; 24 | } 25 | 26 | int ConfigFile::GetIntegerValue(const std::string& key) 27 | { 28 | auto pair = ConfigMap.find(key); 29 | bool found = pair != ConfigMap.end(); 30 | 31 | return found ? atoi(pair->second.c_str()) : 0; 32 | } 33 | 34 | bool ConfigFile::GetBooleanValue(const std::string& key) 35 | { 36 | auto pair = ConfigMap.find(key); 37 | bool found = pair != ConfigMap.end(); 38 | 39 | return found ? pair->second == "true" : false; 40 | } 41 | 42 | float ConfigFile::GetFloatValue(const std::string & key) 43 | { 44 | auto pair = ConfigMap.find(key); 45 | bool found = pair != ConfigMap.end(); 46 | 47 | return found ? (float)atof(pair->second.c_str()) : 0.0f; 48 | } 49 | 50 | void ConfigFile::Parse(std::ifstream &fileStream) 51 | { 52 | std::string line; 53 | 54 | // check for BOM 55 | std::getline(fileStream, line); 56 | if (line.size() >= 3 && line.rfind("\xEF\xBB\xBF", 0) == 0) 57 | fileStream.seekg(3); 58 | else 59 | fileStream.seekg(0); 60 | 61 | while (std::getline(fileStream, line)) 62 | { 63 | if (IsComment(line)) 64 | continue; 65 | 66 | auto splitline = Utilities::Split(line, "="); 67 | if (splitline.size() < 2) 68 | continue; 69 | 70 | for (auto &line : splitline) 71 | Utilities::Trim(line); 72 | 73 | ConfigMap.insert(std::make_pair(splitline[0], splitline[1])); 74 | } 75 | } 76 | 77 | bool ConfigFile::IsComment(const std::string &line) 78 | { 79 | return line.size() <= 0 || line[0] == '#' || line[0] == '[' || (line.size() >= 2 && line.rfind("//", 0) == 0); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /DivaImGui/Keyboard/Keyboard.cpp: -------------------------------------------------------------------------------- 1 | #include "Keyboard.h" 2 | 3 | namespace DivaImGui::Input 4 | { 5 | Keyboard* Keyboard::instance; 6 | 7 | Keyboard::Keyboard() 8 | { 9 | } 10 | 11 | Keyboard* Keyboard::GetInstance() 12 | { 13 | if (instance == nullptr) 14 | instance = new Keyboard(); 15 | 16 | return instance; 17 | } 18 | 19 | bool Keyboard::PollInput() 20 | { 21 | lastState = currentState; 22 | 23 | float elapsed = keyIntervalWatch.Restart(); 24 | 25 | for (BYTE i = 0; i < KEYBOARD_KEYS; i++) 26 | { 27 | // DOWN 28 | bool isDown = GetAsyncKeyState(i) < 0; 29 | currentState.KeyStates[i] = isDown; 30 | 31 | // DOUBLE TAPPED 32 | bool isTapped = IsTapped(i); 33 | keyDoubleTapStates[i] = isTapped ? keyDoubleTapWatches[i].Restart() <= DOUBLE_TAP_THRESHOLD : false; 34 | 35 | // INTERVAL TAPPED 36 | keyIntervalTapStates[i] = isTapped; 37 | 38 | if (isTapped) 39 | { 40 | keyIntervalTapTimes[i] = 0; 41 | keyIntervalInitials[i] = true; 42 | } 43 | else if (isDown) 44 | { 45 | float threshold = keyIntervalInitials[i] ? INTERVAL_TAP_DELAY_THRESHOLD : INTERVAL_TAP_THRESHOLD; 46 | 47 | bool intervalTapped = (keyIntervalTapTimes[i] += elapsed) > threshold; 48 | keyIntervalTapStates[i] = intervalTapped; 49 | 50 | if (intervalTapped) 51 | { 52 | keyIntervalTapTimes[i] = 0; 53 | keyIntervalInitials[i] = false; 54 | } 55 | } 56 | } 57 | 58 | return true; 59 | } 60 | 61 | bool Keyboard::IsDown(BYTE keycode) 62 | { 63 | return currentState.IsDown(keycode); 64 | } 65 | 66 | bool Keyboard::IsUp(BYTE keycode) 67 | { 68 | return !IsDown(keycode); 69 | } 70 | 71 | bool Keyboard::IsTapped(BYTE keycode) 72 | { 73 | return IsDown(keycode) && WasUp(keycode); 74 | } 75 | 76 | bool Keyboard::IsDoubleTapped(BYTE keycode) 77 | { 78 | return keyDoubleTapStates[keycode]; 79 | } 80 | 81 | bool Keyboard::IsReleased(BYTE keycode) 82 | { 83 | return IsUp(keycode) && WasDown(keycode); 84 | } 85 | 86 | inline bool Keyboard::WasDown(BYTE keycode) 87 | { 88 | return lastState.IsDown(keycode); 89 | } 90 | 91 | inline bool Keyboard::WasUp(BYTE keycode) 92 | { 93 | return !WasDown(keycode); 94 | } 95 | 96 | bool Keyboard::IsIntervalTapped(BYTE keycode) 97 | { 98 | return keyIntervalTapStates[keycode]; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /DivaImGui/Constants101.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | constexpr uint8_t NOP_OPCODE = 0x90; 5 | constexpr uint8_t RET_OPCODE = 0xC3; 6 | constexpr uint8_t JMP_OPCODE = 0xE9; 7 | constexpr uint8_t JNE_OPCODE = 0x85; 8 | 9 | constexpr uint64_t ENGINE_UPDATE_HOOK_TARGET_ADDRESS = 0x000000014005D440; 10 | constexpr uint64_t ENGINE_UPDATE_INPUT_ADDRESS = 0x000000014005D3B0; 11 | 12 | constexpr uint64_t CURRENT_GAME_STATE_ADDRESS = 0x0000000140CEFAA0; 13 | constexpr uint64_t RESOLUTION_WIDTH_ADDRESS = 0x0000000140CEFB4C; 14 | constexpr uint64_t RESOLUTION_HEIGHT_ADDRESS = 0x0000000140CEFB50; 15 | 16 | constexpr uint64_t SYSTEM_WARNING_ELAPSED_ADDRESS = (0x0000000140E67D90 + 0x68); 17 | constexpr uint64_t DATA_INIT_STATE_ADDRESS = 0x0000000140CEFA58; 18 | 19 | constexpr uint64_t AET_FRAME_DURATION_ADDRESS = 0x0000000140842388; 20 | constexpr uint64_t PV_FRAME_RATE_ADDRESS = 0x0000000140CEFA7C; 21 | constexpr uint64_t FRAME_SPEED_ADDRESS = 0x0000000140CEFA48; 22 | constexpr uint64_t FRAME_RATE_ADDRESS = 0x0000000140CEF980; 23 | 24 | constexpr uint64_t DW_GUI_DISPLAY_INSTANCE_PTR_ADDRESS = 0x0000000140E53E88; 25 | constexpr uint64_t INPUT_STATE_PTR_ADDRESS = 0x0000000140CEF5E0; 26 | constexpr uint64_t SLIDER_CTRL_TASK_ADDRESS = 0x0000000140EB3940; 27 | constexpr uint64_t TASK_TOUCH_ADDRESS = 0x0000000140EF5200; 28 | constexpr uint64_t SEL_PV_TIME_ADDRESS = 0x0000000140EA6628; 29 | constexpr uint64_t PV_SEL_SLOTS_TO_SCROLL = 0x0000000140EA6604; 30 | 31 | constexpr uint64_t CAMERA_ADDRESS = 0x0000000140D9CD40; 32 | constexpr uint64_t CAMERA_POS_SETTER_ADDRESS = 0x00000001400D1110; 33 | constexpr uint64_t CAMERA_INTR_SETTER_ADDRESS = 0x00000001400D10B0; 34 | constexpr uint64_t CAMERA_ROT_SETTER_ADDRESS = 0x00000001400D1130; 35 | constexpr uint64_t CAMERA_PERS_SETTER_ADDRESS = 0x00000001400D10F0; 36 | 37 | constexpr uint64_t UPDATE_TASKS_ADDRESS = 0x000000014006C570; 38 | constexpr uint64_t GLUT_SET_CURSOR_ADDRESS = 0x000000014073261C; 39 | constexpr uint64_t CHANGE_MODE_ADDRESS = 0x0000000140065B30; 40 | constexpr uint64_t CHANGE_SUB_MODE_ADDRESS = 0x00000001400659C0; 41 | 42 | constexpr uint64_t FB1_WIDTH_ADDRESS = 0x0000000140E780F8; 43 | constexpr uint64_t FB1_HEIGHT_ADDRESS = 0x0000000140E780FC; 44 | 45 | constexpr uint64_t UI_WIDTH_ADDRESS = 0x0000000140EB73F4; 46 | constexpr uint64_t UI_HEIGHT_ADDRESS = 0x0000000140EB73F8; 47 | 48 | constexpr uint64_t FB_ASPECT_RATIO = 0x0000000140D9CD68; 49 | constexpr uint64_t UI_ASPECT_RATIO = 0x0000000140EB73E0; -------------------------------------------------------------------------------- /Depedencies/imgui/imgui_impl_opengl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline 2 | // - Desktop GL: 3.x 4.x 3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) 4 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) 5 | 6 | // Implemented features: 7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. 8 | 9 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 10 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 11 | // https://github.com/ocornut/imgui 12 | 13 | // About Desktop OpenGL function loaders: 14 | // Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers. 15 | // Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad). 16 | // You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own. 17 | 18 | // About GLSL version: 19 | // The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string. 20 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" 21 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. 22 | 23 | #pragma once 24 | 25 | // Specific OpenGL versions 26 | //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten 27 | //#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android 28 | 29 | // Set default OpenGL3 loader to be gl3w 30 | #if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \ 31 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \ 32 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \ 33 | && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) 34 | #define IMGUI_IMPL_OPENGL_LOADER_GL3W 35 | #endif 36 | 37 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); 38 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); 39 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); 40 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); 41 | 42 | // Called by Init/NewFrame/Shutdown 43 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); 44 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); 45 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); 46 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); 47 | -------------------------------------------------------------------------------- /Depedencies/snappy/snappy_uncompress_fuzzer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // libFuzzer harness for fuzzing snappy's decompression code. 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "snappy.h" 37 | 38 | // Entry point for LibFuzzer. 39 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 40 | std::string input(reinterpret_cast(data), size); 41 | 42 | // Avoid self-crafted decompression bombs. 43 | size_t uncompressed_size; 44 | constexpr size_t kMaxUncompressedSize = 1 << 20; 45 | bool get_uncompressed_length_succeeded = snappy::GetUncompressedLength( 46 | input.data(), input.size(), &uncompressed_size); 47 | if (!get_uncompressed_length_succeeded || 48 | (uncompressed_size > kMaxUncompressedSize)) { 49 | return 0; 50 | } 51 | 52 | std::string uncompressed; 53 | // The return value of snappy::Uncompress() is ignored because decompression 54 | // will fail on invalid inputs. 55 | snappy::Uncompress(input.data(), input.size(), &uncompressed); 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Depedencies/snappy/snappy_compress_fuzzer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // libFuzzer harness for fuzzing snappy compression code. 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "snappy.h" 37 | 38 | // Entry point for LibFuzzer. 39 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 40 | std::string input(reinterpret_cast(data), size); 41 | 42 | std::string compressed; 43 | size_t compressed_size = 44 | snappy::Compress(input.data(), input.size(), &compressed); 45 | 46 | (void)compressed_size; // Variable only used in debug builds. 47 | assert(compressed_size == compressed.size()); 48 | assert(compressed.size() <= snappy::MaxCompressedLength(input.size())); 49 | assert(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size())); 50 | 51 | std::string uncompressed_after_compress; 52 | bool uncompress_succeeded = snappy::Uncompress( 53 | compressed.data(), compressed.size(), &uncompressed_after_compress); 54 | 55 | (void)uncompress_succeeded; // Variable only used in debug builds. 56 | assert(uncompress_succeeded); 57 | assert(input == uncompressed_after_compress); 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /Depedencies/snappy/snappy-stubs-public.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // Various type stubs for the open-source version of Snappy. 30 | // 31 | // This file cannot include config.h, as it is included from snappy.h, 32 | // which is a public header. Instead, snappy-stubs-public.h is generated by 33 | // from snappy-stubs-public.h.in at configure time. 34 | 35 | #ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ 36 | #define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | #if ${HAVE_SYS_UIO_H_01} // HAVE_SYS_UIO_H 43 | #include 44 | #endif // HAVE_SYS_UIO_H 45 | 46 | #define SNAPPY_MAJOR ${PROJECT_VERSION_MAJOR} 47 | #define SNAPPY_MINOR ${PROJECT_VERSION_MINOR} 48 | #define SNAPPY_PATCHLEVEL ${PROJECT_VERSION_PATCH} 49 | #define SNAPPY_VERSION \ 50 | ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL) 51 | 52 | namespace snappy { 53 | 54 | using int8 = std::int8_t; 55 | using uint8 = std::uint8_t; 56 | using int16 = std::int16_t; 57 | using uint16 = std::uint16_t; 58 | using int32 = std::int32_t; 59 | using uint32 = std::uint32_t; 60 | using int64 = std::int64_t; 61 | using uint64 = std::uint64_t; 62 | 63 | #if !${HAVE_SYS_UIO_H_01} // !HAVE_SYS_UIO_H 64 | // Windows does not have an iovec type, yet the concept is universally useful. 65 | // It is simple to define it ourselves, so we put it inside our own namespace. 66 | struct iovec { 67 | void* iov_base; 68 | size_t iov_len; 69 | }; 70 | #endif // !HAVE_SYS_UIO_H 71 | 72 | } // namespace snappy 73 | 74 | #endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ 75 | -------------------------------------------------------------------------------- /DivaImGui/Constants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | constexpr uint8_t NOP_OPCODE = 0x90; 5 | constexpr uint8_t RET_OPCODE = 0xC3; 6 | constexpr uint8_t JMP_OPCODE = 0xE9; 7 | constexpr uint8_t JNE_OPCODE = 0x85; 8 | 9 | constexpr uint64_t ENGINE_UPDATE_HOOK_TARGET_ADDRESS = 0x000000014018CC40; 10 | constexpr uint64_t ENGINE_UPDATE_INPUT_ADDRESS = 0x000000014018CBB0; 11 | 12 | constexpr uint64_t CURRENT_GAME_STATE_ADDRESS = 0x0000000140EDA810; 13 | constexpr uint64_t RESOLUTION_WIDTH_ADDRESS = 0x0000000140EDA8BC; 14 | constexpr uint64_t RESOLUTION_HEIGHT_ADDRESS = 0x0000000140EDA8C0; 15 | 16 | constexpr uint64_t SYSTEM_WARNING_ELAPSED_ADDRESS = (0x00000001411A1430 + 0x68); 17 | constexpr uint64_t DATA_INIT_STATE_ADDRESS = 0x0000000140EDA7A8; 18 | 19 | constexpr uint64_t AET_FRAME_DURATION_ADDRESS = 0x00000001409A0A58; 20 | constexpr uint64_t PV_FRAME_RATE_ADDRESS = 0x0000000140EDA7CC; 21 | constexpr uint64_t FRAME_SPEED_ADDRESS = 0x0000000140EDA798; 22 | constexpr uint64_t FRAME_RATE_ADDRESS = 0x0000000140EDA6D0; 23 | 24 | constexpr uint64_t DW_GUI_DISPLAY_INSTANCE_PTR_ADDRESS = 0x0000000141190108; 25 | constexpr uint64_t INPUT_STATE_PTR_ADDRESS = 0x0000000140EDA330; 26 | constexpr uint64_t SLIDER_CTRL_TASK_ADDRESS = 0x000000014CC5DE40; 27 | constexpr uint64_t TASK_TOUCH_ADDRESS = 0x000000014CC9EC30; 28 | constexpr uint64_t SEL_PV_TIME_ADDRESS = 0x000000014CC12498; 29 | constexpr uint64_t PLAYER_DATA_ADDRESS = 0x00000001411A8850; 30 | constexpr uint64_t SET_DEFAULT_PLAYER_DATA_ADDRESS = 0x00000001404A7370; 31 | constexpr uint64_t PLAYS_PER_SESSION_GETTER_ADDRESS = 0x000000014038AEE0; 32 | constexpr uint64_t PV_SEL_SLOTS_TO_SCROLL = 0x000000014CC12470; 33 | 34 | constexpr uint64_t CAMERA_ADDRESS = 0x0000000140FBC2C0; 35 | constexpr uint64_t CAMERA_POS_SETTER_ADDRESS = 0x00000001401F9460; 36 | constexpr uint64_t CAMERA_INTR_SETTER_ADDRESS = 0x00000001401F93F0; 37 | constexpr uint64_t CAMERA_ROT_SETTER_ADDRESS = 0x00000001401F9480; 38 | constexpr uint64_t CAMERA_PERS_SETTER_ADDRESS = 0x00000001401F9430; 39 | 40 | constexpr uint64_t UPDATE_TASKS_ADDRESS = 0x000000014019B980; 41 | constexpr uint64_t GLUT_SET_CURSOR_ADDRESS = 0x00000001408B68E6; 42 | constexpr uint64_t CHANGE_MODE_ADDRESS = 0x00000001401953D0; 43 | constexpr uint64_t CHANGE_SUB_MODE_ADDRESS = 0x0000000140195260; 44 | 45 | constexpr uint64_t FB_WIDTH_ADDRESS = 0x00000001411ABCA8; 46 | constexpr uint64_t FB_HEIGHT_ADDRESS = 0x00000001411ABCAC; 47 | constexpr uint64_t FB1_WIDTH_ADDRESS = 0x00000001411AD5F8; 48 | constexpr uint64_t FB1_HEIGHT_ADDRESS = 0x00000001411AD5FC; 49 | constexpr uint64_t FB2_WIDTH_ADDRESS = 0x0000000140EDA8E4; 50 | constexpr uint64_t FB2_HEIGHT_ADDRESS = 0x0000000140EDA8E8; 51 | 52 | constexpr uint64_t FB_RESOLUTION_WIDTH_ADDRESS = 0x00000001411ABB50; 53 | constexpr uint64_t FB_RESOLUTION_HEIGHT_ADDRESS = 0x00000001411ABB54; 54 | 55 | constexpr uint64_t UI_WIDTH_ADDRESS = 0x000000014CC621E4; 56 | constexpr uint64_t UI_HEIGHT_ADDRESS = 0x000000014CC621E8; 57 | 58 | constexpr uint64_t FB_ASPECT_RATIO = 0x0000000140FBC2E8; 59 | constexpr uint64_t UI_ASPECT_RATIO = 0x000000014CC621D0; 60 | 61 | constexpr uint64_t MODSELECTOR_CHECK_FUNCTION_ERRRET_ADDRESS = 0x00000001405869AD; 62 | constexpr uint64_t MODSELECTOR_CLOSE_AFTER_MODULE = 0x0000000140583B45; 63 | constexpr uint64_t MODSELECTOR_CLOSE_AFTER_CUSTOMIZE = 0x0000000140583C8C; 64 | constexpr uint64_t MODULE_TABLE_START = PLAYER_DATA_ADDRESS + 0x140; 65 | constexpr uint64_t MODULE_TABLE_END = MODULE_TABLE_START + 127; 66 | constexpr uint64_t ITEM_TABLE_START = PLAYER_DATA_ADDRESS + 0x2B8; 67 | constexpr uint64_t ITEM_TABLE_END = ITEM_TABLE_START + 128; -------------------------------------------------------------------------------- /DivaImGui/DebugHook/DebugHook701.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "parser.hpp" 6 | #include "Utilities/HookHelper.h" 7 | #include "DebugHook701.h" 8 | 9 | namespace DebugHooks 10 | { 11 | //shd param 12 | HOOK(void*, sub_1405E52D0, 0x1405E52D0, unsigned int a1, __int64 a2, unsigned int a3) 13 | { 14 | printf("sub_1405E52D0 %d %d %d\n", a1, a2, a3); 15 | return originalsub_1405E52D0(a1, a2, a3); 16 | } 17 | 18 | HOOK(__int64*, sub_1405E5240, 0x1405E5240, unsigned int a1, __int64 a2, __int64 a3, unsigned int a4) 19 | { 20 | printf("sub_1405E5240 %d %d %d %d\n", a1, a2, a3, a4); 21 | return originalsub_1405E5240(a1, a2, a3, a4); 22 | } 23 | 24 | HOOK(signed __int64*, sub_1405E4B50, 0x1405E4B50, __int64 a1, __int64 a2) 25 | { 26 | //if (a1 == 1288011824) 27 | //if (a2 == 27) 28 | //if (_dbg_mmm_stuff1) 29 | { 30 | printf("sub_1405E4B50 %p\n", _ReturnAddress()); 31 | printf("sub_1405E4B50 %d %d\n", a1, a2); 32 | } 33 | 34 | auto result = originalsub_1405E4B50(a1, a2); 35 | 36 | auto v2 = *(signed int*)(a1 + 12); 37 | 38 | auto v3 = 0; 39 | auto v6 = *(DWORD**)(a1 + 16); 40 | auto v4 = 0; 41 | __int64 v5 = 0; 42 | while (*v6 != (DWORD)a2) 43 | { 44 | ++v5; 45 | ++v4; 46 | v6 += 12; 47 | if (v5 >= v2) 48 | return 0; 49 | } 50 | auto v8 = (UINT64*)(*(UINT64*)(a1 + 16) + 48 * v4); 51 | if (!v8) 52 | return 0; 53 | auto v9 = *(signed int*)(a1 + 24); 54 | auto v10 = 1; 55 | auto v11 = 0; 56 | auto v12 = 1; 57 | if (v9 > 0) 58 | { 59 | auto v13 = (signed int*)v8[1]; 60 | auto v14 = *(UINT64*)(a1 + 32) - (UINT64)v13; 61 | auto v15 = v8[2] - (UINT64)v13; 62 | do 63 | { 64 | auto v16 = *v13; 65 | a2 = *(unsigned int*)((char*)v13 + v15); 66 | auto v17 = *(DWORD*)0x14CC57AF0[(signed int*)((char*)v13 + v14)]; 67 | ++v13; 68 | auto v18 = v17; 69 | if (v17 > v16) 70 | v18 = v16; 71 | if (v17 > (signed int)a2) 72 | v17 = a2; 73 | v5 = (unsigned int)(v10 * v17); 74 | v11 += v12 * v18; 75 | v12 *= v16 + 1; 76 | v3 += v5; 77 | v10 *= (DWORD)a2 + 1; 78 | --v9; 79 | } while (v9); 80 | } 81 | auto v19 = *(DWORD*)(v8[4] + 4i64 * v11); 82 | auto v20 = *(DWORD*)(v8[5] + 4i64 * v3); 83 | 84 | //if (_dbg_mmm_stuff1) 85 | printf("v2=%d v6=%d v8[4]=%d v8[5]=%d v9=%d\n", v2, v6, v8[4], v8[5], v9); 86 | 87 | /*if (*(DWORD*)0x14CC587B0 != v19) 88 | { 89 | glBindProgramARB(34336i64, v19); 90 | *(DWORD*)0x14CC587B0 = v19; 91 | } 92 | if (*(DWORD*)0x14CC587B4 != v20) 93 | { 94 | glBindProgramARB(34820i64, v20); 95 | *(DWORD*)0x14CC587B0 = v20; 96 | } 97 | 98 | glEnable(GL_VERTEX_PROGRAM_ARB); 99 | glEnable(GL_FRAGMENT_PROGRAM_ARB);*/ 100 | return 0; 101 | } 102 | 103 | HOOK(__int64*, sub_1404444B0, 0x1404444B0, __int64 a1, char a2) 104 | { 105 | { 106 | printf("sub_1404444B0 %p\n", _ReturnAddress()); 107 | printf("sub_1404444B0 %d %d\n", a1, a2); 108 | } 109 | 110 | return originalsub_1404444B0(a1, a2); 111 | } 112 | 113 | HOOK(__int64*, sub_1404425B0, 0x1404425B0, __int64 a1) 114 | { 115 | { 116 | printf("sub_1404425B0 %p\n", _ReturnAddress()); 117 | printf("sub_1404425B0 %d\n", a1); 118 | } 119 | 120 | return originalsub_1404425B0(a1); 121 | } 122 | 123 | HOOK(__int64*, sub_140437820, 0x140437820, __int64 a1, __int64 a2, void(__fastcall* a3)(__int64), unsigned int a4) 124 | { 125 | { 126 | printf("sub_140437820 %p\n", _ReturnAddress()); 127 | printf("sub_140437820 %d %d %p %d\n", a1, a2, a3, a4); 128 | } 129 | return originalsub_140437820(a1, a2, a3, a4); 130 | } 131 | 132 | } 133 | 134 | -------------------------------------------------------------------------------- /Depedencies/snappy/snappy-sinksource.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | 31 | #include "snappy-sinksource.h" 32 | 33 | namespace snappy { 34 | 35 | Source::~Source() { } 36 | 37 | Sink::~Sink() { } 38 | 39 | char* Sink::GetAppendBuffer(size_t length, char* scratch) { 40 | return scratch; 41 | } 42 | 43 | char* Sink::GetAppendBufferVariable( 44 | size_t min_size, size_t desired_size_hint, char* scratch, 45 | size_t scratch_size, size_t* allocated_size) { 46 | *allocated_size = scratch_size; 47 | return scratch; 48 | } 49 | 50 | void Sink::AppendAndTakeOwnership( 51 | char* bytes, size_t n, 52 | void (*deleter)(void*, const char*, size_t), 53 | void *deleter_arg) { 54 | Append(bytes, n); 55 | (*deleter)(deleter_arg, bytes, n); 56 | } 57 | 58 | ByteArraySource::~ByteArraySource() { } 59 | 60 | size_t ByteArraySource::Available() const { return left_; } 61 | 62 | const char* ByteArraySource::Peek(size_t* len) { 63 | *len = left_; 64 | return ptr_; 65 | } 66 | 67 | void ByteArraySource::Skip(size_t n) { 68 | left_ -= n; 69 | ptr_ += n; 70 | } 71 | 72 | UncheckedByteArraySink::~UncheckedByteArraySink() { } 73 | 74 | void UncheckedByteArraySink::Append(const char* data, size_t n) { 75 | // Do no copying if the caller filled in the result of GetAppendBuffer() 76 | if (data != dest_) { 77 | memcpy(dest_, data, n); 78 | } 79 | dest_ += n; 80 | } 81 | 82 | char* UncheckedByteArraySink::GetAppendBuffer(size_t len, char* scratch) { 83 | return dest_; 84 | } 85 | 86 | void UncheckedByteArraySink::AppendAndTakeOwnership( 87 | char* data, size_t n, 88 | void (*deleter)(void*, const char*, size_t), 89 | void *deleter_arg) { 90 | if (data != dest_) { 91 | memcpy(dest_, data, n); 92 | (*deleter)(deleter_arg, data, n); 93 | } 94 | dest_ += n; 95 | } 96 | 97 | char* UncheckedByteArraySink::GetAppendBufferVariable( 98 | size_t min_size, size_t desired_size_hint, char* scratch, 99 | size_t scratch_size, size_t* allocated_size) { 100 | *allocated_size = desired_size_hint; 101 | return dest_; 102 | } 103 | 104 | } // namespace snappy 105 | -------------------------------------------------------------------------------- /Depedencies/detours/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | ## 3 | ## Makefile for Detours. 4 | ## 5 | ## Microsoft Research Detours Package, Version 4.0.1 6 | ## 7 | ## Copyright (c) Microsoft Corporation. All rights reserved. 8 | ## 9 | 10 | ROOT = .. 11 | !include "$(ROOT)\system.mak" 12 | 13 | !IF "$(DETOURS_SOURCE_BROWSING)" == "" 14 | DETOURS_SOURCE_BROWSING = 0 15 | !ENDIF 16 | 17 | #######################/####################################################### 18 | ## 19 | CFLAGS=/W4 /WX /Zi /MT /Gy /Gm- /Zl /Od 20 | 21 | !IF $(DETOURS_SOURCE_BROWSING)==1 22 | CFLAGS=$(CFLAGS) /FR 23 | !ELSE 24 | CFLAGS=$(CFLAGS) /DWIN32_LEAN_AND_MEAN /D_WIN32_WINNT=0x501 25 | !ENDIF 26 | 27 | !IF "$(DETOURS_TARGET_PROCESSOR)" == "IA64" 28 | CFLAGS=$(CFLAGS) /wd4163 # intrinsic rdtebex not available; using newer Windows headers with older compiler 29 | !ENDIF 30 | 31 | !if defined(DETOURS_WIN_7) && defined(DETOURS_CL_17_OR_NEWER) 32 | CFLAGS=$(CFLAGS) /D_USING_V110_SDK71_ 33 | !elseif defined(DETOURS_ANALYZE) 34 | CFLAGS=$(CFLAGS) /analyze 35 | !endif 36 | 37 | OBJS = \ 38 | $(OBJD)\detours.obj \ 39 | $(OBJD)\modules.obj \ 40 | $(OBJD)\disasm.obj \ 41 | $(OBJD)\image.obj \ 42 | $(OBJD)\creatwth.obj \ 43 | $(OBJD)\disolx86.obj \ 44 | $(OBJD)\disolx64.obj \ 45 | $(OBJD)\disolia64.obj \ 46 | $(OBJD)\disolarm.obj \ 47 | $(OBJD)\disolarm64.obj \ 48 | 49 | ############################################################################## 50 | ## 51 | .SUFFIXES: .cpp .h .obj 52 | 53 | !ifdef DETOURS_ANALYZE 54 | .cpp{$(OBJD)}.obj: 55 | $(CC) $(CFLAGS) /Fd$(LIBD)\detours.pdb /Fo$(OBJD)\ /c $< 56 | !else 57 | .cpp{$(OBJD)}.obj:: 58 | $(CC) $(CFLAGS) /Fd$(LIBD)\detours.pdb /Fo$(OBJD)\ /c $< 59 | !endif 60 | 61 | ############################################################################## 62 | 63 | all: dirs \ 64 | $(LIBD)\detours.lib \ 65 | $(INCD)\detours.h \ 66 | $(INCD)\detver.h \ 67 | !IF $(DETOURS_SOURCE_BROWSING)==1 68 | $(OBJD)\detours.bsc \ 69 | !endif 70 | 71 | ############################################################################## 72 | 73 | clean: 74 | -del *~ 2>nul 75 | -del $(LIBD)\detours.pdb $(LIBD)\detours.lib 2>nul 76 | -rmdir /q /s $(OBJD) 2>nul 77 | 78 | realclean: clean 79 | -rmdir /q /s $(OBJDS) 2>nul 80 | 81 | ############################################################################## 82 | 83 | dirs: 84 | @if not exist "$(INCD)" mkdir "$(INCD)" && echo. Created $(INCD) 85 | @if not exist "$(LIBD)" mkdir "$(LIBD)" && echo. Created $(LIBD) 86 | @if not exist "$(BIND)" mkdir "$(BIND)" && echo. Created $(BIND) 87 | @if not exist "$(OBJD)" mkdir "$(OBJD)" && echo. Created $(OBJD) 88 | 89 | $(OBJD)\detours.bsc : $(OBJS) 90 | bscmake /v /n /o $@ $(OBJS:.obj=.sbr) 91 | 92 | $(LIBD)\detours.lib : $(OBJS) 93 | link /lib /out:$@ $(OBJS) 94 | 95 | $(INCD)\detours.h : detours.h 96 | copy detours.h $@ 97 | 98 | $(INCD)\detver.h : detver.h 99 | copy detver.h $@ 100 | 101 | $(OBJD)\detours.obj : detours.cpp detours.h 102 | $(OBJD)\modules.obj : modules.cpp detours.h 103 | $(OBJD)\disasm.obj : disasm.cpp detours.h 104 | $(OBJD)\image.obj : image.cpp detours.h 105 | $(OBJD)\creatwth.obj : creatwth.cpp uimports.cpp detours.h 106 | $(OBJD)\disolx86.obj: disasm.cpp detours.h 107 | $(OBJD)\disolx64.obj: disasm.cpp detours.h 108 | $(OBJD)\disolia64.obj: disasm.cpp detours.h 109 | $(OBJD)\disolarm.obj: disasm.cpp detours.h 110 | $(OBJD)\disolarm64.obj: disasm.cpp detours.h 111 | 112 | test: all 113 | cd $(MAKEDIR)\..\samples\slept 114 | nmake /nologo test 115 | cd $(MAKEDIR) 116 | 117 | ################################################################# End of File. 118 | -------------------------------------------------------------------------------- /Release/ShaderPatch.ini: -------------------------------------------------------------------------------- 1 | [Config] 2 | # Patches to remove glitching with modern GPUs. 3 | # Appropriate patches will automatically be selected based on your GPU. 4 | Compat=1 5 | 6 | # Lyb's toon shader improvements (24 sept 2019) 7 | # Toon: Adjusts toon shader lighting 8 | Toon=0 9 | # Specular Multiplier 10 | Toon_Val1=0.9 11 | # Specular Offset 12 | Toon_Val2=-0.5 13 | 14 | # Lyb's toon shader improvements (24 sept 2019) 15 | # Toon_Eyes: Adjusts toon shader eyes 16 | Toon_Eyes=0 17 | 18 | # Lyb's toon shader improvements (24 sept 2019) 19 | # Toon_Hair: Adjusts toon shader hair 20 | Toon_Hair=0 21 | # Diffuse Brightness 22 | Toon_Hair_Val1=1.25 23 | 24 | # Lyb's toon shader improvements (24 sept 2019) 25 | # Toon_Lines: Adjusts toon shader outlines 26 | Toon_Lines=0 27 | # ??? 28 | Toon_Lines_Val1=0.75 29 | # Thickness Multiplier(?) 30 | Toon_Lines_Val2=0.75 31 | # Thickness Offset(?) 32 | Toon_Lines_Val3=0.75 33 | 34 | # Debug patches: 35 | # Nametags 36 | # Adds comments with the shader file name to the shader text. Useful for debugging issues. 37 | # `nametags_val1` and `nametags_val2` are a dirty hack to hide this in launcher (options ending in _val. must belong to a parent to be displayed) 38 | # `nametags_val2` is a bit faster, but the tags are placed at the end of the file and you may not like that 39 | Nametags_Val1=0 40 | Nametags_Val2=0 41 | 42 | [Patches] 43 | # Compatibility patches: 44 | # Star Story (and etc.) stage corruption (Maxwell+) 45 | blinn_per_vert\.0010010[23]00[01]\.fp=arch:GP,TU,GV,GM||cfg:compat||from:TEX tex_col, a_tex_color0, texture\[0\], 2D; ALIAS||to:TEX tex_col, a_tex_color0, texture[0], 2D; MUL tex_col, 1, tex_col; ALIAS 46 | # Turing shading lines 47 | esm_gauss\.0\.fp=arch:TU||cfg:compat||from:RCP sum.y, sum.y;(\r?\n) MUL||to:RCP sum.y, sum.y; ADD sum.x, sum.x, 0.000300;$1 MUL 48 | # Turing NPR cloth noise 49 | cloth_npr1.*=arch:TU||cfg:compat||from:SSG _tmp0.yw, ybr.xxzz;||to:TEMP _tmpForSSG; SGE _tmpForSSG.xz, ybr.xxzz, 0; SUB _tmpForSSG.xz, _tmpForSSG.xxzz, 1; SGT _tmpForSSG.yw, ybr.xxzz, 0; ADD _tmp0.yw, _tmpForSSG.xxzz, _tmpForSSG.yyww; 50 | 51 | # Lyb's toon shader improvements: 52 | cloth_npr1.*=cfg:toon||from:MAD tmp.y, lc.z, 1.2, -0.5;||to:MAD tmp.y, lc.z, , ; 53 | skin_default.*=cfg:toon||from:MAD diff.xyz, spec, spec_ratio, diff;||to: 54 | .*eye.*=cfg:toon_eyes||from:ADD o_color_f0.w, diff.x, diff.y;||to: 55 | hair_npr1.*=cfg:toon_hair||from:MUL spec.x, tmp.x, 0.7;||to:MUL spec.x, tmp.x, 0.7; MUL diff, diff, ; 56 | tone_map_npr1.*=cfg:toon_lines||from:MUL density.y, density.y, 0.25;||to:MUL density.y, density.y, ; 57 | tone_map_npr1.*=cfg:toon_lines||from:MAD density.w, density.x, 0.7, 0.25;||to:MAD density.w, density.x, , ; 58 | 59 | # Debug patches: 60 | # Nametags 61 | # Adds comments with the shader file name to the shader text. Useful for debugging issues 62 | # `nametags_val1` and `nametags_val2` are a dirty hack to hide this in launcher (options ending in _val. must belong to a parent to be displayed) 63 | # `nametags_val2` is a bit faster, but the tags are placed at the end of the file and you may not like that 64 | # Notes: 65 | # * `(\r?\n)` is used to capture the line ending type used and ensure we're at the start of a line 66 | # * `[^!]` ensures the comment is inserted after all start program lines (not sure if this even matters) 67 | # * `[\s\S]` matches all characters *including* new lines 68 | .*=cfg:nametags_val1||from:(\r?\n)([^!][\s\S]*)||to:$1#$1$2 69 | .*=cfg:nametags_val2||from:[\s\S]*?(\r?\n)[\s\S]*||to:$&$1# 70 | 71 | # DivaImGui related patches 72 | # Do not touch unless you know what you are doing. 73 | 74 | .*=cfg:intel||from:; ||to:;\n 75 | .*=cfg:intel||from:(?:RET|TXL|NRM|OPTION NV_fragment|PARAM p_charfragment.color|ATTRIB).*?||to:## 76 | .*=cfg:intel||from:(?:SHORT |LONG ).*?||to: 77 | .*=cfg:amd||from:PARAM p_charfragment.color||to:## 78 | .*=cfg:amd||from:!!NVfp4.0||to:!!ARBfp1.0 79 | .*=cfg:amd||from:POW||to:##POW -------------------------------------------------------------------------------- /Depedencies/snappy/snappy-c.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Martin Gieseking . 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include "snappy.h" 30 | #include "snappy-c.h" 31 | 32 | extern "C" { 33 | 34 | snappy_status snappy_compress(const char* input, 35 | size_t input_length, 36 | char* compressed, 37 | size_t *compressed_length) { 38 | if (*compressed_length < snappy_max_compressed_length(input_length)) { 39 | return SNAPPY_BUFFER_TOO_SMALL; 40 | } 41 | snappy::RawCompress(input, input_length, compressed, compressed_length); 42 | return SNAPPY_OK; 43 | } 44 | 45 | snappy_status snappy_uncompress(const char* compressed, 46 | size_t compressed_length, 47 | char* uncompressed, 48 | size_t* uncompressed_length) { 49 | size_t real_uncompressed_length; 50 | if (!snappy::GetUncompressedLength(compressed, 51 | compressed_length, 52 | &real_uncompressed_length)) { 53 | return SNAPPY_INVALID_INPUT; 54 | } 55 | if (*uncompressed_length < real_uncompressed_length) { 56 | return SNAPPY_BUFFER_TOO_SMALL; 57 | } 58 | if (!snappy::RawUncompress(compressed, compressed_length, uncompressed)) { 59 | return SNAPPY_INVALID_INPUT; 60 | } 61 | *uncompressed_length = real_uncompressed_length; 62 | return SNAPPY_OK; 63 | } 64 | 65 | size_t snappy_max_compressed_length(size_t source_length) { 66 | return snappy::MaxCompressedLength(source_length); 67 | } 68 | 69 | snappy_status snappy_uncompressed_length(const char *compressed, 70 | size_t compressed_length, 71 | size_t *result) { 72 | if (snappy::GetUncompressedLength(compressed, 73 | compressed_length, 74 | result)) { 75 | return SNAPPY_OK; 76 | } else { 77 | return SNAPPY_INVALID_INPUT; 78 | } 79 | } 80 | 81 | snappy_status snappy_validate_compressed_buffer(const char *compressed, 82 | size_t compressed_length) { 83 | if (snappy::IsValidCompressedBuffer(compressed, compressed_length)) { 84 | return SNAPPY_OK; 85 | } else { 86 | return SNAPPY_INVALID_INPUT; 87 | } 88 | } 89 | 90 | } // extern "C" 91 | -------------------------------------------------------------------------------- /Depedencies/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating imgui, or maintain a patch/branch with your modifications to imconfig.h) 7 | // B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h" 8 | // If you do so you need to make sure that configuration settings are defined consistently _everywhere_ dear imgui is used, which include 9 | // the imgui*.cpp files but also _any_ of your code that uses imgui. This is because some compile-time options have an affect on data structures. 10 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 11 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 12 | //----------------------------------------------------------------------------- 13 | 14 | #pragma once 15 | 16 | //---- Define assertion handler. Defaults to calling assert(). 17 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 18 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 19 | 20 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. 21 | //#define IMGUI_API __declspec( dllexport ) 22 | //#define IMGUI_API __declspec( dllimport ) 23 | 24 | //---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 25 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 26 | 27 | //---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty) 28 | //---- It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp. 29 | //#define IMGUI_DISABLE_DEMO_WINDOWS 30 | 31 | //---- Don't implement some functions to reduce linkage requirements. 32 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. 33 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. 34 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function. 35 | //#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf. 36 | //#define IMGUI_DISABLE_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h. 37 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 38 | 39 | //---- Include imgui_user.h at the end of imgui.h as a convenience 40 | //#define IMGUI_INCLUDE_IMGUI_USER_H 41 | 42 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 43 | //#define IMGUI_USE_BGRA_PACKED_COLOR 44 | 45 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 46 | // By default the embedded implementations are declared static and not available outside of imgui cpp files. 47 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 48 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 49 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 50 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 51 | 52 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 53 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 54 | /* 55 | #define IM_VEC2_CLASS_EXTRA \ 56 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 57 | operator MyVec2() const { return MyVec2(x,y); } 58 | 59 | #define IM_VEC4_CLASS_EXTRA \ 60 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 61 | operator MyVec4() const { return MyVec4(x,y,z,w); } 62 | */ 63 | 64 | //---- Use 32-bit vertex indices (default is 16-bit) to allow meshes with more than 64K vertices. Render function needs to support it. 65 | //#define ImDrawIdx unsigned int 66 | 67 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 68 | /* 69 | namespace ImGui 70 | { 71 | void MyFunction(const char* name, const MyMatrix44& v); 72 | } 73 | */ 74 | -------------------------------------------------------------------------------- /DivaImGui/MainModule.cpp: -------------------------------------------------------------------------------- 1 | #include "MainModule.h" 2 | #include 3 | #include "GLComponent.h" 4 | #include "GLComponent101.h" 5 | #include "GLComponentLight.h" 6 | #include "GLComponentDummy.h" 7 | #include "FileSystem/ConfigFile.h" 8 | #include "GLHook/GLHook.h" 9 | 10 | namespace DivaImGui 11 | { 12 | typedef std::filesystem::path fspath; 13 | 14 | std::string* MainModule::moduleDirectory; 15 | 16 | const wchar_t* MainModule::DivaWindowName = L"Hatsune Miku Project DIVA Arcade Future Tone"; 17 | const wchar_t* MainModule::ODivaWindowName = L"Project DIVA Arcade"; 18 | const wchar_t* MainModule::GlutDefaultName = L"GLUT"; 19 | const wchar_t* MainModule::freeGlutDefaultName = L"FREEGLUT"; 20 | 21 | HWND MainModule::DivaWindowHandle; 22 | HMODULE MainModule::Module; 23 | 24 | int MainModule::fpsLimit = 0; 25 | int MainModule::fpsLimitSet = 0; 26 | bool MainModule::inputDisable = false; 27 | DivaImGui::GLComponent MainModule::glcomp; 28 | DivaImGui::V101::GLComponent101 MainModule::glcomp101; 29 | DivaImGui::VLight::GLComponentLight MainModule::glcomplight; 30 | DivaImGui::VGCST::GLComponentLight MainModule::glcompgcst; 31 | DivaImGui::Vdummy::GLComponentDummy MainModule::glcompdummy; 32 | bool MainModule::showUi = false; 33 | 34 | void MainModule::initializeglcomp() 35 | { 36 | const std::string RESOLUTION_CONFIG_FILE_NAME = "graphics.ini"; 37 | 38 | DivaImGui::FileSystem::ConfigFile resolutionConfig(MainModule::GetModuleDirectory(), RESOLUTION_CONFIG_FILE_NAME.c_str()); 39 | bool success = resolutionConfig.OpenRead(); 40 | if (!success) 41 | { 42 | printf("[DivaImGui] Unable to parse %s\n", RESOLUTION_CONFIG_FILE_NAME.c_str()); 43 | } 44 | 45 | if (success) { 46 | std::string aftv101 = "1.01"; 47 | std::string aftv710 = "7.10"; 48 | std::string* value; 49 | bool forceLightweight = false; 50 | 51 | if (resolutionConfig.TryGetValue("shaderpatch", &value)) 52 | { 53 | if (*value == "1") 54 | GLHook::GLCtrl::Enabled = true; 55 | } 56 | 57 | if (resolutionConfig.TryGetValue("amd", &value)) 58 | { 59 | if (*value == "1") 60 | GLHook::GLCtrl::isAmd = true; 61 | } 62 | 63 | if (resolutionConfig.TryGetValue("intel", &value)) 64 | { 65 | if (*value == "1") 66 | GLHook::GLCtrl::isIntel = true; 67 | } 68 | 69 | if (resolutionConfig.TryGetValue("disableGpuDetect", &value)) 70 | { 71 | if (*value == "1") 72 | GLHook::GLCtrl::disableGpuDetect = true; 73 | } 74 | 75 | if (resolutionConfig.TryGetValue("patchAsGameLoads", &value)) 76 | { 77 | if (*value == "1") 78 | GLHook::GLCtrl::patchAsGameLoads = true; 79 | } 80 | 81 | if (resolutionConfig.TryGetValue("disableSprShaders", &value)) 82 | { 83 | if (*value == "1") 84 | GLHook::GLCtrl::disableSprShader = true; 85 | } 86 | 87 | if (resolutionConfig.TryGetValue("forceLightweight", &value)) 88 | { 89 | if (*value == "1") 90 | forceLightweight = true; 91 | } 92 | 93 | if (resolutionConfig.TryGetValue("lybdbg", &value)) 94 | { 95 | if (*value == "1") 96 | GLHook::GLCtrl::debug = true; 97 | } 98 | 99 | if (resolutionConfig.TryGetValue("shadernamed", &value)) 100 | { 101 | if (*value == "1") 102 | GLHook::GLCtrl::shaderaftmodified = true; 103 | } 104 | 105 | if (resolutionConfig.TryGetValue("gc", &value)) 106 | { 107 | glcompgcst.Initialize(); 108 | return; 109 | } 110 | 111 | if (forceLightweight) 112 | { 113 | if (resolutionConfig.TryGetValue("version", &value)) 114 | { 115 | double version = std::stod(*value); 116 | int iv = (version * 100); 117 | GLHook::GLCtrl::gamever = iv; 118 | } 119 | printf("[DivaImGui] Using Universal Mode!\n"); 120 | glcomplight.Initialize(); 121 | } 122 | else if (resolutionConfig.TryGetValue("version", &value)) 123 | { 124 | double version = std::stod(*value); 125 | int iv = (version * 100); 126 | GLHook::GLCtrl::gamever = iv; 127 | 128 | switch (iv) { 129 | #if _WIN64 130 | case 101: 131 | printf("[DivaImGui] AFT v1.01\n"); 132 | glcomp101.Initialize(); 133 | break; 134 | 135 | case 710: 136 | printf("[DivaImGui] AFT v7.10\n"); 137 | DWORD oldProtect, bck; 138 | VirtualProtect((BYTE*)0x0000000140626C29, 2, PAGE_EXECUTE_READWRITE, &oldProtect); 139 | *((BYTE*)0x0000000140626C29 + 0) = 0x48; 140 | *((BYTE*)0x0000000140626C29 + 1) = 0xE9; 141 | VirtualProtect((BYTE*)0x0000000140626C29, 2, oldProtect, &bck); 142 | glcomp.Initialize(); 143 | break; 144 | 145 | case 999: 146 | glcomp.Initialize(); 147 | break; 148 | #endif 149 | #if _WIN32 150 | 151 | #endif 152 | default: 153 | printf("[DivaImGui] Unknown Game Version! %d\n", iv); 154 | printf("[DivaImGui] Using Universal Mode!\n"); 155 | glcomplight.Initialize(); 156 | } 157 | } 158 | } 159 | } 160 | 161 | std::string MainModule::GetModuleDirectory() 162 | { 163 | if (moduleDirectory == nullptr) 164 | { 165 | WCHAR modulePathBuffer[MAX_PATH]; 166 | GetModuleFileNameW(MainModule::Module, modulePathBuffer, MAX_PATH); 167 | 168 | fspath configPath = fspath(modulePathBuffer).parent_path(); 169 | moduleDirectory = new std::string(configPath.u8string()); 170 | } 171 | 172 | return *moduleDirectory; 173 | } 174 | 175 | RECT MainModule::GetWindowBounds() 176 | { 177 | RECT windowRect; 178 | GetWindowRect(DivaWindowHandle, &windowRect); 179 | 180 | return windowRect; 181 | } 182 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 lybxlpsv 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | ------------------------------------------------------------------------------- 24 | MinHook - The Minimalistic API Hooking Library for x64/x86 25 | Copyright (C) 2009-2017 Tsuda Kageyu. 26 | All rights reserved. 27 | 28 | Redistribution and use in source and binary forms, with or without 29 | modification, are permitted provided that the following conditions 30 | are met: 31 | 32 | 1. Redistributions of source code must retain the above copyright 33 | notice, this list of conditions and the following disclaimer. 34 | 2. Redistributions in binary form must reproduce the above copyright 35 | notice, this list of conditions and the following disclaimer in the 36 | documentation and/or other materials provided with the distribution. 37 | 38 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 40 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 41 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 42 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 43 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 44 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 45 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 46 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 47 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 48 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | 50 | ================================================================================ 51 | Portions of this software are Copyright (c) 2008-2009, Vyacheslav Patkov. 52 | ================================================================================ 53 | Hacker Disassembler Engine 32 C 54 | Copyright (c) 2008-2009, Vyacheslav Patkov. 55 | All rights reserved. 56 | 57 | Redistribution and use in source and binary forms, with or without 58 | modification, are permitted provided that the following conditions 59 | are met: 60 | 61 | 1. Redistributions of source code must retain the above copyright 62 | notice, this list of conditions and the following disclaimer. 63 | 2. Redistributions in binary form must reproduce the above copyright 64 | notice, this list of conditions and the following disclaimer in the 65 | documentation and/or other materials provided with the distribution. 66 | 67 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 68 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 69 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 70 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 71 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 72 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 73 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 74 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 75 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 76 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 77 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 78 | 79 | ------------------------------------------------------------------------------- 80 | Hacker Disassembler Engine 64 C 81 | Copyright (c) 2008-2009, Vyacheslav Patkov. 82 | All rights reserved. 83 | 84 | Redistribution and use in source and binary forms, with or without 85 | modification, are permitted provided that the following conditions 86 | are met: 87 | 88 | 1. Redistributions of source code must retain the above copyright 89 | notice, this list of conditions and the following disclaimer. 90 | 2. Redistributions in binary form must reproduce the above copyright 91 | notice, this list of conditions and the following disclaimer in the 92 | documentation and/or other materials provided with the distribution. 93 | 94 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 95 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 96 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 97 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 98 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 99 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 100 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 101 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 102 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 103 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 104 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 105 | -------------------------------------------------------------------------------- /Depedencies/snappy/snappy-c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Martin Gieseking . 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * Plain C interface (a wrapper around the C++ implementation). 31 | */ 32 | 33 | #ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_ 34 | #define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #include 41 | 42 | /* 43 | * Return values; see the documentation for each function to know 44 | * what each can return. 45 | */ 46 | typedef enum { 47 | SNAPPY_OK = 0, 48 | SNAPPY_INVALID_INPUT = 1, 49 | SNAPPY_BUFFER_TOO_SMALL = 2 50 | } snappy_status; 51 | 52 | /* 53 | * Takes the data stored in "input[0..input_length-1]" and stores 54 | * it in the array pointed to by "compressed". 55 | * 56 | * signals the space available in "compressed". 57 | * If it is not at least equal to "snappy_max_compressed_length(input_length)", 58 | * SNAPPY_BUFFER_TOO_SMALL is returned. After successful compression, 59 | * contains the true length of the compressed output, 60 | * and SNAPPY_OK is returned. 61 | * 62 | * Example: 63 | * size_t output_length = snappy_max_compressed_length(input_length); 64 | * char* output = (char*)malloc(output_length); 65 | * if (snappy_compress(input, input_length, output, &output_length) 66 | * == SNAPPY_OK) { 67 | * ... Process(output, output_length) ... 68 | * } 69 | * free(output); 70 | */ 71 | snappy_status snappy_compress(const char* input, 72 | size_t input_length, 73 | char* compressed, 74 | size_t* compressed_length); 75 | 76 | /* 77 | * Given data in "compressed[0..compressed_length-1]" generated by 78 | * calling the snappy_compress routine, this routine stores 79 | * the uncompressed data to 80 | * uncompressed[0..uncompressed_length-1]. 81 | * Returns failure (a value not equal to SNAPPY_OK) if the message 82 | * is corrupted and could not be decrypted. 83 | * 84 | * signals the space available in "uncompressed". 85 | * If it is not at least equal to the value returned by 86 | * snappy_uncompressed_length for this stream, SNAPPY_BUFFER_TOO_SMALL 87 | * is returned. After successful decompression, 88 | * contains the true length of the decompressed output. 89 | * 90 | * Example: 91 | * size_t output_length; 92 | * if (snappy_uncompressed_length(input, input_length, &output_length) 93 | * != SNAPPY_OK) { 94 | * ... fail ... 95 | * } 96 | * char* output = (char*)malloc(output_length); 97 | * if (snappy_uncompress(input, input_length, output, &output_length) 98 | * == SNAPPY_OK) { 99 | * ... Process(output, output_length) ... 100 | * } 101 | * free(output); 102 | */ 103 | snappy_status snappy_uncompress(const char* compressed, 104 | size_t compressed_length, 105 | char* uncompressed, 106 | size_t* uncompressed_length); 107 | 108 | /* 109 | * Returns the maximal size of the compressed representation of 110 | * input data that is "source_length" bytes in length. 111 | */ 112 | size_t snappy_max_compressed_length(size_t source_length); 113 | 114 | /* 115 | * REQUIRES: "compressed[]" was produced by snappy_compress() 116 | * Returns SNAPPY_OK and stores the length of the uncompressed data in 117 | * *result normally. Returns SNAPPY_INVALID_INPUT on parsing error. 118 | * This operation takes O(1) time. 119 | */ 120 | snappy_status snappy_uncompressed_length(const char* compressed, 121 | size_t compressed_length, 122 | size_t* result); 123 | 124 | /* 125 | * Check if the contents of "compressed[]" can be uncompressed successfully. 126 | * Does not return the uncompressed data; if so, returns SNAPPY_OK, 127 | * or if not, returns SNAPPY_INVALID_INPUT. 128 | * Takes time proportional to compressed_length, but is usually at least a 129 | * factor of four faster than actual decompression. 130 | */ 131 | snappy_status snappy_validate_compressed_buffer(const char* compressed, 132 | size_t compressed_length); 133 | 134 | #ifdef __cplusplus 135 | } // extern "C" 136 | #endif 137 | 138 | #endif /* THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_ */ 139 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | bin/ 24 | bin-int/ 25 | [Bb]in/ 26 | [Oo]bj/ 27 | [Ll]og/ 28 | 29 | # Visual Studio 2015/2017 cache/options directory 30 | .vs/ 31 | # Uncomment if you have tasks that create the project's static files in wwwroot 32 | #wwwroot/ 33 | 34 | # Visual Studio 2017 auto generated files 35 | Generated\ Files/ 36 | 37 | # MSTest test Results 38 | [Tt]est[Rr]esult*/ 39 | [Bb]uild[Ll]og.* 40 | 41 | # NUNIT 42 | *.VisualState.xml 43 | TestResult.xml 44 | 45 | # Build Results of an ATL Project 46 | [Dd]ebugPS/ 47 | [Rr]eleasePS/ 48 | dlldata.c 49 | 50 | # Benchmark Results 51 | BenchmarkDotNet.Artifacts/ 52 | 53 | # .NET Core 54 | project.lock.json 55 | project.fragment.lock.json 56 | artifacts/ 57 | **/Properties/launchSettings.json 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_i.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *.log 83 | *.vspscc 84 | *.vssscc 85 | .builds 86 | *.pidb 87 | *.svclog 88 | *.scc 89 | 90 | # Chutzpah Test files 91 | _Chutzpah* 92 | 93 | # Visual C++ cache files 94 | ipch/ 95 | *.aps 96 | *.ncb 97 | *.opendb 98 | *.opensdf 99 | *.sdf 100 | *.cachefile 101 | *.VC.db 102 | *.VC.VC.opendb 103 | 104 | # Visual Studio profiler 105 | *.psess 106 | *.vsp 107 | *.vspx 108 | *.sap 109 | 110 | # Visual Studio Trace Files 111 | *.e2e 112 | 113 | # TFS 2012 Local Workspace 114 | $tf/ 115 | 116 | # Guidance Automation Toolkit 117 | *.gpState 118 | 119 | # ReSharper is a .NET coding add-in 120 | _ReSharper*/ 121 | *.[Rr]e[Ss]harper 122 | *.DotSettings.user 123 | 124 | # JustCode is a .NET coding add-in 125 | .JustCode 126 | 127 | # TeamCity is a build add-in 128 | _TeamCity* 129 | 130 | # DotCover is a Code Coverage Tool 131 | *.dotCover 132 | 133 | # AxoCover is a Code Coverage Tool 134 | .axoCover/* 135 | !.axoCover/settings.json 136 | 137 | # Visual Studio code coverage results 138 | *.coverage 139 | *.coveragexml 140 | 141 | # NCrunch 142 | _NCrunch_* 143 | .*crunch*.local.xml 144 | nCrunchTemp_* 145 | 146 | # MightyMoose 147 | *.mm.* 148 | AutoTest.Net/ 149 | 150 | # Web workbench (sass) 151 | .sass-cache/ 152 | 153 | # Installshield output folder 154 | [Ee]xpress/ 155 | 156 | # DocProject is a documentation generator add-in 157 | DocProject/buildhelp/ 158 | DocProject/Help/*.HxT 159 | DocProject/Help/*.HxC 160 | DocProject/Help/*.hhc 161 | DocProject/Help/*.hhk 162 | DocProject/Help/*.hhp 163 | DocProject/Help/Html2 164 | DocProject/Help/html 165 | 166 | # Click-Once directory 167 | publish/ 168 | 169 | # Publish Web Output 170 | *.[Pp]ublish.xml 171 | *.azurePubxml 172 | # Note: Comment the next line if you want to checkin your web deploy settings, 173 | # but database connection strings (with potential passwords) will be unencrypted 174 | *.pubxml 175 | *.publishproj 176 | 177 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 178 | # checkin your Azure Web App publish settings, but sensitive information contained 179 | # in these scripts will be unencrypted 180 | PublishScripts/ 181 | 182 | # NuGet Packages 183 | *.nupkg 184 | # The packages folder can be ignored because of Package Restore 185 | **/[Pp]ackages/* 186 | # except build/, which is used as an MSBuild target. 187 | !**/[Pp]ackages/build/ 188 | # Uncomment if necessary however generally it will be regenerated when needed 189 | #!**/[Pp]ackages/repositories.config 190 | # NuGet v3's project.json files produces more ignorable files 191 | *.nuget.props 192 | *.nuget.targets 193 | 194 | # Microsoft Azure Build Output 195 | csx/ 196 | *.build.csdef 197 | 198 | # Microsoft Azure Emulator 199 | ecf/ 200 | rcf/ 201 | 202 | # Windows Store app package directories and files 203 | AppPackages/ 204 | BundleArtifacts/ 205 | Package.StoreAssociation.xml 206 | _pkginfo.txt 207 | *.appx 208 | 209 | # Visual Studio cache files 210 | # files ending in .cache can be ignored 211 | *.[Cc]ache 212 | # but keep track of directories ending in .cache 213 | !*.[Cc]ache/ 214 | 215 | # Others 216 | ClientBin/ 217 | ~$* 218 | *~ 219 | *.dbmdl 220 | *.dbproj.schemaview 221 | *.jfm 222 | *.pfx 223 | *.publishsettings 224 | orleans.codegen.cs 225 | 226 | # Including strong name files can present a security risk 227 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 228 | #*.snk 229 | 230 | # Since there are multiple workflows, uncomment next line to ignore bower_components 231 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 232 | #bower_components/ 233 | 234 | # RIA/Silverlight projects 235 | Generated_Code/ 236 | 237 | # Backup & report files from converting an old project file 238 | # to a newer Visual Studio version. Backup files are not needed, 239 | # because we have git ;-) 240 | _UpgradeReport_Files/ 241 | Backup*/ 242 | UpgradeLog*.XML 243 | UpgradeLog*.htm 244 | ServiceFabricBackup/ 245 | *.rptproj.bak 246 | 247 | # SQL Server files 248 | *.mdf 249 | *.ldf 250 | *.ndf 251 | 252 | # Business Intelligence projects 253 | *.rdl.data 254 | *.bim.layout 255 | *.bim_*.settings 256 | *.rptproj.rsuser 257 | 258 | # Microsoft Fakes 259 | FakesAssemblies/ 260 | 261 | # GhostDoc plugin setting file 262 | *.GhostDoc.xml 263 | 264 | # Node.js Tools for Visual Studio 265 | .ntvs_analysis.dat 266 | node_modules/ 267 | 268 | # Visual Studio 6 build log 269 | *.plg 270 | 271 | # Visual Studio 6 workspace options file 272 | *.opt 273 | 274 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 275 | *.vbw 276 | 277 | # Visual Studio LightSwitch build output 278 | **/*.HTMLClient/GeneratedArtifacts 279 | **/*.DesktopClient/GeneratedArtifacts 280 | **/*.DesktopClient/ModelManifest.xml 281 | **/*.Server/GeneratedArtifacts 282 | **/*.Server/ModelManifest.xml 283 | _Pvt_Extensions 284 | 285 | # Paket dependency manager 286 | .paket/paket.exe 287 | paket-files/ 288 | 289 | # FAKE - F# Make 290 | .fake/ 291 | 292 | # JetBrains Rider 293 | .idea/ 294 | *.sln.iml 295 | 296 | # CodeRush 297 | .cr/ 298 | 299 | # Python Tools for Visual Studio (PTVS) 300 | __pycache__/ 301 | *.pyc 302 | 303 | # Cake - Uncomment if you are using it 304 | # tools/** 305 | # !tools/packages.config 306 | 307 | # Tabs Studio 308 | *.tss 309 | 310 | # Telerik's JustMock configuration file 311 | *.jmconfig 312 | 313 | # BizTalk build output 314 | *.btp.cs 315 | *.btm.cs 316 | *.odx.cs 317 | *.xsd.cs 318 | 319 | # OpenCover UI analysis results 320 | OpenCover/ 321 | 322 | # Azure Stream Analytics local run output 323 | ASALocalRun/ 324 | 325 | # MSBuild Binary and Structured Log 326 | *.binlog 327 | 328 | # NVidia Nsight GPU debugger configuration file 329 | *.nvuser 330 | 331 | # MFractors (Xamarin productivity tool) working folder 332 | .mfractor/ 333 | -------------------------------------------------------------------------------- /Depedencies/snappy/snappy-sinksource.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #ifndef THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_ 30 | #define THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_ 31 | 32 | #include 33 | 34 | namespace snappy { 35 | 36 | // A Sink is an interface that consumes a sequence of bytes. 37 | class Sink { 38 | public: 39 | Sink() { } 40 | virtual ~Sink(); 41 | 42 | // Append "bytes[0,n-1]" to this. 43 | virtual void Append(const char* bytes, size_t n) = 0; 44 | 45 | // Returns a writable buffer of the specified length for appending. 46 | // May return a pointer to the caller-owned scratch buffer which 47 | // must have at least the indicated length. The returned buffer is 48 | // only valid until the next operation on this Sink. 49 | // 50 | // After writing at most "length" bytes, call Append() with the 51 | // pointer returned from this function and the number of bytes 52 | // written. Many Append() implementations will avoid copying 53 | // bytes if this function returned an internal buffer. 54 | // 55 | // If a non-scratch buffer is returned, the caller may only pass a 56 | // prefix of it to Append(). That is, it is not correct to pass an 57 | // interior pointer of the returned array to Append(). 58 | // 59 | // The default implementation always returns the scratch buffer. 60 | virtual char* GetAppendBuffer(size_t length, char* scratch); 61 | 62 | // For higher performance, Sink implementations can provide custom 63 | // AppendAndTakeOwnership() and GetAppendBufferVariable() methods. 64 | // These methods can reduce the number of copies done during 65 | // compression/decompression. 66 | 67 | // Append "bytes[0,n-1] to the sink. Takes ownership of "bytes" 68 | // and calls the deleter function as (*deleter)(deleter_arg, bytes, n) 69 | // to free the buffer. deleter function must be non NULL. 70 | // 71 | // The default implementation just calls Append and frees "bytes". 72 | // Other implementations may avoid a copy while appending the buffer. 73 | virtual void AppendAndTakeOwnership( 74 | char* bytes, size_t n, void (*deleter)(void*, const char*, size_t), 75 | void *deleter_arg); 76 | 77 | // Returns a writable buffer for appending and writes the buffer's capacity to 78 | // *allocated_size. Guarantees *allocated_size >= min_size. 79 | // May return a pointer to the caller-owned scratch buffer which must have 80 | // scratch_size >= min_size. 81 | // 82 | // The returned buffer is only valid until the next operation 83 | // on this ByteSink. 84 | // 85 | // After writing at most *allocated_size bytes, call Append() with the 86 | // pointer returned from this function and the number of bytes written. 87 | // Many Append() implementations will avoid copying bytes if this function 88 | // returned an internal buffer. 89 | // 90 | // If the sink implementation allocates or reallocates an internal buffer, 91 | // it should use the desired_size_hint if appropriate. If a caller cannot 92 | // provide a reasonable guess at the desired capacity, it should set 93 | // desired_size_hint = 0. 94 | // 95 | // If a non-scratch buffer is returned, the caller may only pass 96 | // a prefix to it to Append(). That is, it is not correct to pass an 97 | // interior pointer to Append(). 98 | // 99 | // The default implementation always returns the scratch buffer. 100 | virtual char* GetAppendBufferVariable( 101 | size_t min_size, size_t desired_size_hint, char* scratch, 102 | size_t scratch_size, size_t* allocated_size); 103 | 104 | private: 105 | // No copying 106 | Sink(const Sink&); 107 | void operator=(const Sink&); 108 | }; 109 | 110 | // A Source is an interface that yields a sequence of bytes 111 | class Source { 112 | public: 113 | Source() { } 114 | virtual ~Source(); 115 | 116 | // Return the number of bytes left to read from the source 117 | virtual size_t Available() const = 0; 118 | 119 | // Peek at the next flat region of the source. Does not reposition 120 | // the source. The returned region is empty iff Available()==0. 121 | // 122 | // Returns a pointer to the beginning of the region and store its 123 | // length in *len. 124 | // 125 | // The returned region is valid until the next call to Skip() or 126 | // until this object is destroyed, whichever occurs first. 127 | // 128 | // The returned region may be larger than Available() (for example 129 | // if this ByteSource is a view on a substring of a larger source). 130 | // The caller is responsible for ensuring that it only reads the 131 | // Available() bytes. 132 | virtual const char* Peek(size_t* len) = 0; 133 | 134 | // Skip the next n bytes. Invalidates any buffer returned by 135 | // a previous call to Peek(). 136 | // REQUIRES: Available() >= n 137 | virtual void Skip(size_t n) = 0; 138 | 139 | private: 140 | // No copying 141 | Source(const Source&); 142 | void operator=(const Source&); 143 | }; 144 | 145 | // A Source implementation that yields the contents of a flat array 146 | class ByteArraySource : public Source { 147 | public: 148 | ByteArraySource(const char* p, size_t n) : ptr_(p), left_(n) { } 149 | virtual ~ByteArraySource(); 150 | virtual size_t Available() const; 151 | virtual const char* Peek(size_t* len); 152 | virtual void Skip(size_t n); 153 | private: 154 | const char* ptr_; 155 | size_t left_; 156 | }; 157 | 158 | // A Sink implementation that writes to a flat array without any bound checks. 159 | class UncheckedByteArraySink : public Sink { 160 | public: 161 | explicit UncheckedByteArraySink(char* dest) : dest_(dest) { } 162 | virtual ~UncheckedByteArraySink(); 163 | virtual void Append(const char* data, size_t n); 164 | virtual char* GetAppendBuffer(size_t len, char* scratch); 165 | virtual char* GetAppendBufferVariable( 166 | size_t min_size, size_t desired_size_hint, char* scratch, 167 | size_t scratch_size, size_t* allocated_size); 168 | virtual void AppendAndTakeOwnership( 169 | char* bytes, size_t n, void (*deleter)(void*, const char*, size_t), 170 | void *deleter_arg); 171 | 172 | // Return the current output pointer so that a caller can see how 173 | // many bytes were produced. 174 | // Note: this is not a Sink method. 175 | char* CurrentDestination() const { return dest_; } 176 | private: 177 | char* dest_; 178 | }; 179 | 180 | } // namespace snappy 181 | 182 | #endif // THIRD_PARTY_SNAPPY_SNAPPY_SINKSOURCE_H_ 183 | -------------------------------------------------------------------------------- /DivaImGui/DX11/systemclass.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Filename: systemclass.cpp 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #include "systemclass.h" 5 | #include 6 | #include 7 | 8 | SystemClass::SystemClass() 9 | { 10 | m_Input = 0; 11 | m_Graphics = 0; 12 | } 13 | 14 | 15 | SystemClass::SystemClass(const SystemClass& other) 16 | { 17 | } 18 | 19 | 20 | SystemClass::~SystemClass() 21 | { 22 | } 23 | 24 | 25 | bool SystemClass::Initialize() 26 | { 27 | int screenWidth, screenHeight; 28 | bool result; 29 | 30 | glewInit(); 31 | wglewInit(); 32 | 33 | // Initialize the width and height of the screen to zero before sending the variables into the function. 34 | screenWidth = 0; 35 | screenHeight = 0; 36 | 37 | // Initialize the windows api. 38 | InitializeWindows(screenWidth, screenHeight); 39 | 40 | // Create the input object. This object will be used to handle reading the keyboard input from the user. 41 | m_Input = new InputClass; 42 | if(!m_Input) 43 | { 44 | return false; 45 | } 46 | 47 | // Initialize the input object. 48 | m_Input->Initialize(); 49 | 50 | // Create the graphics object. This object will handle rendering all the graphics for this application. 51 | m_Graphics = new GraphicsClass; 52 | if(!m_Graphics) 53 | { 54 | return false; 55 | } 56 | 57 | // Initialize the graphics object. 58 | result = m_Graphics->Initialize(screenWidth, screenHeight, m_hwnd); 59 | if(!result) 60 | { 61 | return false; 62 | } 63 | 64 | return true; 65 | } 66 | 67 | 68 | void SystemClass::Shutdown() 69 | { 70 | // Release the graphics object. 71 | if(m_Graphics) 72 | { 73 | m_Graphics->Shutdown(); 74 | delete m_Graphics; 75 | m_Graphics = 0; 76 | } 77 | 78 | // Release the input object. 79 | if(m_Input) 80 | { 81 | delete m_Input; 82 | m_Input = 0; 83 | } 84 | 85 | // Shutdown the window. 86 | ShutdownWindows(); 87 | 88 | return; 89 | } 90 | 91 | bool isInit = false; 92 | 93 | void SystemClass::Run() 94 | { 95 | Frame(); 96 | return; 97 | } 98 | 99 | 100 | bool SystemClass::Frame() 101 | { 102 | bool result; 103 | 104 | 105 | // Check if the user pressed escape and wants to exit the application. 106 | if(m_Input->IsKeyDown(VK_ESCAPE)) 107 | { 108 | return false; 109 | } 110 | 111 | // Do the frame processing for the graphics object. 112 | result = m_Graphics->Frame(); 113 | if(!result) 114 | { 115 | return false; 116 | } 117 | 118 | return true; 119 | } 120 | 121 | 122 | LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam) 123 | { 124 | switch(umsg) 125 | { 126 | // Check if a key has been pressed on the keyboard. 127 | case WM_KEYDOWN: 128 | { 129 | // If a key is pressed send it to the input object so it can record that state. 130 | //m_Input->KeyDown((unsigned int)wparam); 131 | return 0; 132 | } 133 | 134 | // Check if a key has been released on the keyboard. 135 | case WM_KEYUP: 136 | { 137 | // If a key is released then send it to the input object so it can unset the state for that key. 138 | //m_Input->KeyUp((unsigned int)wparam); 139 | return 0; 140 | } 141 | 142 | // Any other messages send to the default message handler as our application won't make use of them. 143 | default: 144 | { 145 | return DefWindowProc(hwnd, umsg, wparam, lparam); 146 | } 147 | } 148 | } 149 | 150 | 151 | void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight) 152 | { 153 | WNDCLASSEX wc; 154 | DEVMODE dmScreenSettings; 155 | int posX, posY; 156 | 157 | 158 | // Get an external pointer to this object. 159 | ApplicationHandle = this; 160 | 161 | // Get the instance of this application. 162 | m_hinstance = GetModuleHandle(NULL); 163 | 164 | // Give the application a name. 165 | m_applicationName = L"DivaImGui DX11 Window"; 166 | 167 | // Setup the windows class with default settings. 168 | wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; 169 | wc.lpfnWndProc = WndProc; 170 | wc.cbClsExtra = 0; 171 | wc.cbWndExtra = 0; 172 | wc.hInstance = m_hinstance; 173 | wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); 174 | wc.hIconSm = wc.hIcon; 175 | wc.hCursor = LoadCursor(NULL, IDC_ARROW); 176 | wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); 177 | wc.lpszMenuName = NULL; 178 | wc.lpszClassName = m_applicationName; 179 | wc.cbSize = sizeof(WNDCLASSEX); 180 | 181 | // Register the window class. 182 | RegisterClassEx(&wc); 183 | 184 | // Determine the resolution of the clients desktop screen. 185 | screenWidth = GetSystemMetrics(SM_CXSCREEN); 186 | screenHeight = GetSystemMetrics(SM_CYSCREEN); 187 | 188 | // Setup the screen settings depending on whether it is running in full screen or in windowed mode. 189 | if(GraphicsClass::FULL_SCREEN) 190 | { 191 | // If full screen set the screen to maximum size of the users desktop and 32bit. 192 | memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); 193 | dmScreenSettings.dmSize = sizeof(dmScreenSettings); 194 | dmScreenSettings.dmPelsWidth = (unsigned long)screenWidth; 195 | dmScreenSettings.dmPelsHeight = (unsigned long)screenHeight; 196 | dmScreenSettings.dmBitsPerPel = 32; 197 | dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; 198 | 199 | // Change the display settings to full screen. 200 | ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN); 201 | 202 | // Set the position of the window to the top left corner. 203 | posX = posY = 0; 204 | } 205 | else 206 | { 207 | // If windowed then set it to 800x600 resolution. 208 | screenWidth = 1280; 209 | screenHeight = 720; 210 | 211 | // Place the window in the middle of the screen. 212 | posX = 0; 213 | posY = 0; 214 | } 215 | 216 | // Create the window with the screen settings and get the handle to it. 217 | if (GraphicsClass::FULL_SCREEN) 218 | { 219 | m_hwnd = CreateWindowEx(WS_EX_APPWINDOW, m_applicationName, m_applicationName, 220 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP, 221 | posX, posY, screenWidth, screenHeight, NULL, NULL, m_hinstance, NULL); 222 | } 223 | else { 224 | m_hwnd = CreateWindowEx(WS_EX_APPWINDOW, m_applicationName, m_applicationName, 225 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW, 226 | posX, posY, screenWidth, screenHeight, NULL, NULL, m_hinstance, NULL); 227 | } 228 | // Bring the window up on the screen and set it as main focus. 229 | ShowWindow(m_hwnd, SW_SHOW); 230 | SetForegroundWindow(m_hwnd); 231 | SetFocus(m_hwnd); 232 | 233 | // Hide the mouse cursor. 234 | ShowCursor(false); 235 | 236 | return; 237 | } 238 | 239 | 240 | void SystemClass::ShutdownWindows() 241 | { 242 | // Show the mouse cursor. 243 | ShowCursor(true); 244 | 245 | // Fix the display settings if leaving full screen mode. 246 | if(GraphicsClass::FULL_SCREEN) 247 | { 248 | ChangeDisplaySettings(NULL, 0); 249 | } 250 | 251 | // Remove the window. 252 | DestroyWindow(m_hwnd); 253 | m_hwnd = NULL; 254 | 255 | // Remove the application instance. 256 | UnregisterClass(m_applicationName, m_hinstance); 257 | m_hinstance = NULL; 258 | 259 | // Release the pointer to this class. 260 | ApplicationHandle = NULL; 261 | 262 | return; 263 | } 264 | 265 | 266 | LRESULT CALLBACK WndProc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam) 267 | { 268 | switch(umessage) 269 | { 270 | // Check if the window is being destroyed. 271 | case WM_DESTROY: 272 | { 273 | PostQuitMessage(0); 274 | return 0; 275 | } 276 | 277 | // Check if the window is being closed. 278 | case WM_CLOSE: 279 | { 280 | PostQuitMessage(0); 281 | return 0; 282 | } 283 | 284 | case WM_KILLFOCUS: 285 | { 286 | GraphicsClass::reinit = false; 287 | return 0; 288 | } 289 | 290 | case WM_SETFOCUS: 291 | { 292 | GraphicsClass::reinit = true; 293 | return 0; 294 | } 295 | 296 | // All other messages pass to the message handler in the system class. 297 | default: 298 | { 299 | return ApplicationHandle->MessageHandler(hwnd, umessage, wparam, lparam); 300 | } 301 | } 302 | } -------------------------------------------------------------------------------- /Depedencies/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 | -------------------------------------------------------------------------------- /DivaImGui/DivaImGui.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;hh;hpp;hxx;hm;inl;inc;ipp;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 | Header Files 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 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | Header Files 53 | 54 | 55 | Header Files 56 | 57 | 58 | Header Files 59 | 60 | 61 | Header Files 62 | 63 | 64 | Header Files 65 | 66 | 67 | Header Files 68 | 69 | 70 | Header Files 71 | 72 | 73 | Header Files 74 | 75 | 76 | Header Files 77 | 78 | 79 | Header Files 80 | 81 | 82 | Header Files 83 | 84 | 85 | Header Files 86 | 87 | 88 | Header Files 89 | 90 | 91 | Header Files 92 | 93 | 94 | Header Files 95 | 96 | 97 | Header Files 98 | 99 | 100 | Header Files 101 | 102 | 103 | Header Files 104 | 105 | 106 | Header Files 107 | 108 | 109 | Header Files 110 | 111 | 112 | Header Files 113 | 114 | 115 | Header Files 116 | 117 | 118 | Header Files 119 | 120 | 121 | Header Files 122 | 123 | 124 | Header Files 125 | 126 | 127 | Header Files 128 | 129 | 130 | Header Files 131 | 132 | 133 | Header Files 134 | 135 | 136 | 137 | 138 | Source Files 139 | 140 | 141 | Source Files 142 | 143 | 144 | Source Files 145 | 146 | 147 | Source Files 148 | 149 | 150 | Source Files 151 | 152 | 153 | Source Files 154 | 155 | 156 | Source Files 157 | 158 | 159 | Source Files 160 | 161 | 162 | Source Files 163 | 164 | 165 | Source Files 166 | 167 | 168 | Source Files 169 | 170 | 171 | Source Files 172 | 173 | 174 | Source Files 175 | 176 | 177 | Source Files 178 | 179 | 180 | Source Files 181 | 182 | 183 | Source Files 184 | 185 | 186 | Source Files 187 | 188 | 189 | Source Files 190 | 191 | 192 | Source Files 193 | 194 | 195 | Source Files 196 | 197 | 198 | Source Files 199 | 200 | 201 | Source Files 202 | 203 | 204 | Source Files 205 | 206 | 207 | Source Files 208 | 209 | 210 | Source Files 211 | 212 | 213 | Source Files 214 | 215 | 216 | Source Files 217 | 218 | 219 | Source Files 220 | 221 | 222 | Source Files 223 | 224 | 225 | Source Files 226 | 227 | 228 | Source Files 229 | 230 | 231 | Source Files 232 | 233 | 234 | Source Files 235 | 236 | 237 | Source Files 238 | 239 | 240 | Source Files 241 | 242 | 243 | Source Files 244 | 245 | 246 | Source Files 247 | 248 | 249 | 250 | 251 | Resource Files 252 | 253 | 254 | -------------------------------------------------------------------------------- /Depedencies/snappy/snappy.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005 and onwards Google Inc. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // A light-weight compression algorithm. It is designed for speed of 30 | // compression and decompression, rather than for the utmost in space 31 | // savings. 32 | // 33 | // For getting better compression ratios when you are compressing data 34 | // with long repeated sequences or compressing data that is similar to 35 | // other data, while still compressing fast, you might look at first 36 | // using BMDiff and then compressing the output of BMDiff with 37 | // Snappy. 38 | 39 | #ifndef THIRD_PARTY_SNAPPY_SNAPPY_H__ 40 | #define THIRD_PARTY_SNAPPY_SNAPPY_H__ 41 | 42 | #include 43 | #include 44 | 45 | #include "snappy-stubs-public.h" 46 | 47 | namespace snappy { 48 | class Source; 49 | class Sink; 50 | 51 | // ------------------------------------------------------------------------ 52 | // Generic compression/decompression routines. 53 | // ------------------------------------------------------------------------ 54 | 55 | // Compress the bytes read from "*source" and append to "*sink". Return the 56 | // number of bytes written. 57 | size_t Compress(Source* source, Sink* sink); 58 | 59 | // Find the uncompressed length of the given stream, as given by the header. 60 | // Note that the true length could deviate from this; the stream could e.g. 61 | // be truncated. 62 | // 63 | // Also note that this leaves "*source" in a state that is unsuitable for 64 | // further operations, such as RawUncompress(). You will need to rewind 65 | // or recreate the source yourself before attempting any further calls. 66 | bool GetUncompressedLength(Source* source, uint32* result); 67 | 68 | // ------------------------------------------------------------------------ 69 | // Higher-level string based routines (should be sufficient for most users) 70 | // ------------------------------------------------------------------------ 71 | 72 | // Sets "*compressed" to the compressed version of "input[0,input_length-1]". 73 | // Original contents of *compressed are lost. 74 | // 75 | // REQUIRES: "input[]" is not an alias of "*compressed". 76 | size_t Compress(const char* input, size_t input_length, 77 | std::string* compressed); 78 | 79 | // Decompresses "compressed[0,compressed_length-1]" to "*uncompressed". 80 | // Original contents of "*uncompressed" are lost. 81 | // 82 | // REQUIRES: "compressed[]" is not an alias of "*uncompressed". 83 | // 84 | // returns false if the message is corrupted and could not be decompressed 85 | bool Uncompress(const char* compressed, size_t compressed_length, 86 | std::string* uncompressed); 87 | 88 | // Decompresses "compressed" to "*uncompressed". 89 | // 90 | // returns false if the message is corrupted and could not be decompressed 91 | bool Uncompress(Source* compressed, Sink* uncompressed); 92 | 93 | // This routine uncompresses as much of the "compressed" as possible 94 | // into sink. It returns the number of valid bytes added to sink 95 | // (extra invalid bytes may have been added due to errors; the caller 96 | // should ignore those). The emitted data typically has length 97 | // GetUncompressedLength(), but may be shorter if an error is 98 | // encountered. 99 | size_t UncompressAsMuchAsPossible(Source* compressed, Sink* uncompressed); 100 | 101 | // ------------------------------------------------------------------------ 102 | // Lower-level character array based routines. May be useful for 103 | // efficiency reasons in certain circumstances. 104 | // ------------------------------------------------------------------------ 105 | 106 | // REQUIRES: "compressed" must point to an area of memory that is at 107 | // least "MaxCompressedLength(input_length)" bytes in length. 108 | // 109 | // Takes the data stored in "input[0..input_length]" and stores 110 | // it in the array pointed to by "compressed". 111 | // 112 | // "*compressed_length" is set to the length of the compressed output. 113 | // 114 | // Example: 115 | // char* output = new char[snappy::MaxCompressedLength(input_length)]; 116 | // size_t output_length; 117 | // RawCompress(input, input_length, output, &output_length); 118 | // ... Process(output, output_length) ... 119 | // delete [] output; 120 | void RawCompress(const char* input, 121 | size_t input_length, 122 | char* compressed, 123 | size_t* compressed_length); 124 | 125 | // Given data in "compressed[0..compressed_length-1]" generated by 126 | // calling the Snappy::Compress routine, this routine 127 | // stores the uncompressed data to 128 | // uncompressed[0..GetUncompressedLength(compressed)-1] 129 | // returns false if the message is corrupted and could not be decrypted 130 | bool RawUncompress(const char* compressed, size_t compressed_length, 131 | char* uncompressed); 132 | 133 | // Given data from the byte source 'compressed' generated by calling 134 | // the Snappy::Compress routine, this routine stores the uncompressed 135 | // data to 136 | // uncompressed[0..GetUncompressedLength(compressed,compressed_length)-1] 137 | // returns false if the message is corrupted and could not be decrypted 138 | bool RawUncompress(Source* compressed, char* uncompressed); 139 | 140 | // Given data in "compressed[0..compressed_length-1]" generated by 141 | // calling the Snappy::Compress routine, this routine 142 | // stores the uncompressed data to the iovec "iov". The number of physical 143 | // buffers in "iov" is given by iov_cnt and their cumulative size 144 | // must be at least GetUncompressedLength(compressed). The individual buffers 145 | // in "iov" must not overlap with each other. 146 | // 147 | // returns false if the message is corrupted and could not be decrypted 148 | bool RawUncompressToIOVec(const char* compressed, size_t compressed_length, 149 | const struct iovec* iov, size_t iov_cnt); 150 | 151 | // Given data from the byte source 'compressed' generated by calling 152 | // the Snappy::Compress routine, this routine stores the uncompressed 153 | // data to the iovec "iov". The number of physical 154 | // buffers in "iov" is given by iov_cnt and their cumulative size 155 | // must be at least GetUncompressedLength(compressed). The individual buffers 156 | // in "iov" must not overlap with each other. 157 | // 158 | // returns false if the message is corrupted and could not be decrypted 159 | bool RawUncompressToIOVec(Source* compressed, const struct iovec* iov, 160 | size_t iov_cnt); 161 | 162 | // Returns the maximal size of the compressed representation of 163 | // input data that is "source_bytes" bytes in length; 164 | size_t MaxCompressedLength(size_t source_bytes); 165 | 166 | // REQUIRES: "compressed[]" was produced by RawCompress() or Compress() 167 | // Returns true and stores the length of the uncompressed data in 168 | // *result normally. Returns false on parsing error. 169 | // This operation takes O(1) time. 170 | bool GetUncompressedLength(const char* compressed, size_t compressed_length, 171 | size_t* result); 172 | 173 | // Returns true iff the contents of "compressed[]" can be uncompressed 174 | // successfully. Does not return the uncompressed data. Takes 175 | // time proportional to compressed_length, but is usually at least 176 | // a factor of four faster than actual decompression. 177 | bool IsValidCompressedBuffer(const char* compressed, 178 | size_t compressed_length); 179 | 180 | // Returns true iff the contents of "compressed" can be uncompressed 181 | // successfully. Does not return the uncompressed data. Takes 182 | // time proportional to *compressed length, but is usually at least 183 | // a factor of four faster than actual decompression. 184 | // On success, consumes all of *compressed. On failure, consumes an 185 | // unspecified prefix of *compressed. 186 | bool IsValidCompressed(Source* compressed); 187 | 188 | // The size of a compression block. Note that many parts of the compression 189 | // code assumes that kBlockSize <= 65536; in particular, the hash table 190 | // can only store 16-bit offsets, and EmitCopy() also assumes the offset 191 | // is 65535 bytes or less. Note also that if you change this, it will 192 | // affect the framing format (see framing_format.txt). 193 | // 194 | // Note that there might be older data around that is compressed with larger 195 | // block sizes, so the decompression code should not rely on the 196 | // non-existence of long backreferences. 197 | static constexpr int kBlockLog = 16; 198 | static constexpr size_t kBlockSize = 1 << kBlockLog; 199 | 200 | static constexpr int kMinHashTableBits = 8; 201 | static constexpr size_t kMinHashTableSize = 1 << kMinHashTableBits; 202 | 203 | static constexpr int kMaxHashTableBits = 14; 204 | static constexpr size_t kMaxHashTableSize = 1 << kMaxHashTableBits; 205 | } // end namespace snappy 206 | 207 | #endif // THIRD_PARTY_SNAPPY_SNAPPY_H__ 208 | -------------------------------------------------------------------------------- /Depedencies/snappy/snappy-internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // Internals shared between the Snappy implementation and its unittest. 30 | 31 | #ifndef THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_ 32 | #define THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_ 33 | 34 | #include "snappy-stubs-internal.h" 35 | 36 | namespace snappy { 37 | namespace internal { 38 | 39 | // Working memory performs a single allocation to hold all scratch space 40 | // required for compression. 41 | class WorkingMemory { 42 | public: 43 | explicit WorkingMemory(size_t input_size); 44 | ~WorkingMemory(); 45 | 46 | // Allocates and clears a hash table using memory in "*this", 47 | // stores the number of buckets in "*table_size" and returns a pointer to 48 | // the base of the hash table. 49 | uint16* GetHashTable(size_t fragment_size, int* table_size) const; 50 | char* GetScratchInput() const { return input_; } 51 | char* GetScratchOutput() const { return output_; } 52 | 53 | private: 54 | char* mem_; // the allocated memory, never nullptr 55 | size_t size_; // the size of the allocated memory, never 0 56 | uint16* table_; // the pointer to the hashtable 57 | char* input_; // the pointer to the input scratch buffer 58 | char* output_; // the pointer to the output scratch buffer 59 | 60 | // No copying 61 | WorkingMemory(const WorkingMemory&); 62 | void operator=(const WorkingMemory&); 63 | }; 64 | 65 | // Flat array compression that does not emit the "uncompressed length" 66 | // prefix. Compresses "input" string to the "*op" buffer. 67 | // 68 | // REQUIRES: "input_length <= kBlockSize" 69 | // REQUIRES: "op" points to an array of memory that is at least 70 | // "MaxCompressedLength(input_length)" in size. 71 | // REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. 72 | // REQUIRES: "table_size" is a power of two 73 | // 74 | // Returns an "end" pointer into "op" buffer. 75 | // "end - op" is the compressed size of "input". 76 | char* CompressFragment(const char* input, 77 | size_t input_length, 78 | char* op, 79 | uint16* table, 80 | const int table_size); 81 | 82 | // Find the largest n such that 83 | // 84 | // s1[0,n-1] == s2[0,n-1] 85 | // and n <= (s2_limit - s2). 86 | // 87 | // Return make_pair(n, n < 8). 88 | // Does not read *s2_limit or beyond. 89 | // Does not read *(s1 + (s2_limit - s2)) or beyond. 90 | // Requires that s2_limit >= s2. 91 | // 92 | // Separate implementation for 64-bit, little-endian cpus. 93 | #if !defined(SNAPPY_IS_BIG_ENDIAN) && \ 94 | (defined(ARCH_K8) || defined(ARCH_PPC) || defined(ARCH_ARM)) 95 | static inline std::pair FindMatchLength(const char* s1, 96 | const char* s2, 97 | const char* s2_limit) { 98 | assert(s2_limit >= s2); 99 | size_t matched = 0; 100 | 101 | // This block isn't necessary for correctness; we could just start looping 102 | // immediately. As an optimization though, it is useful. It creates some not 103 | // uncommon code paths that determine, without extra effort, whether the match 104 | // length is less than 8. In short, we are hoping to avoid a conditional 105 | // branch, and perhaps get better code layout from the C++ compiler. 106 | if (SNAPPY_PREDICT_TRUE(s2 <= s2_limit - 8)) { 107 | uint64 a1 = UNALIGNED_LOAD64(s1); 108 | uint64 a2 = UNALIGNED_LOAD64(s2); 109 | if (a1 != a2) { 110 | return std::pair(Bits::FindLSBSetNonZero64(a1 ^ a2) >> 3, 111 | true); 112 | } else { 113 | matched = 8; 114 | s2 += 8; 115 | } 116 | } 117 | 118 | // Find out how long the match is. We loop over the data 64 bits at a 119 | // time until we find a 64-bit block that doesn't match; then we find 120 | // the first non-matching bit and use that to calculate the total 121 | // length of the match. 122 | while (SNAPPY_PREDICT_TRUE(s2 <= s2_limit - 8)) { 123 | if (UNALIGNED_LOAD64(s2) == UNALIGNED_LOAD64(s1 + matched)) { 124 | s2 += 8; 125 | matched += 8; 126 | } else { 127 | uint64 x = UNALIGNED_LOAD64(s2) ^ UNALIGNED_LOAD64(s1 + matched); 128 | int matching_bits = Bits::FindLSBSetNonZero64(x); 129 | matched += matching_bits >> 3; 130 | assert(matched >= 8); 131 | return std::pair(matched, false); 132 | } 133 | } 134 | while (SNAPPY_PREDICT_TRUE(s2 < s2_limit)) { 135 | if (s1[matched] == *s2) { 136 | ++s2; 137 | ++matched; 138 | } else { 139 | return std::pair(matched, matched < 8); 140 | } 141 | } 142 | return std::pair(matched, matched < 8); 143 | } 144 | #else 145 | static inline std::pair FindMatchLength(const char* s1, 146 | const char* s2, 147 | const char* s2_limit) { 148 | // Implementation based on the x86-64 version, above. 149 | assert(s2_limit >= s2); 150 | int matched = 0; 151 | 152 | while (s2 <= s2_limit - 4 && 153 | UNALIGNED_LOAD32(s2) == UNALIGNED_LOAD32(s1 + matched)) { 154 | s2 += 4; 155 | matched += 4; 156 | } 157 | if (LittleEndian::IsLittleEndian() && s2 <= s2_limit - 4) { 158 | uint32 x = UNALIGNED_LOAD32(s2) ^ UNALIGNED_LOAD32(s1 + matched); 159 | int matching_bits = Bits::FindLSBSetNonZero(x); 160 | matched += matching_bits >> 3; 161 | } else { 162 | while ((s2 < s2_limit) && (s1[matched] == *s2)) { 163 | ++s2; 164 | ++matched; 165 | } 166 | } 167 | return std::pair(matched, matched < 8); 168 | } 169 | #endif 170 | 171 | // Lookup tables for decompression code. Give --snappy_dump_decompression_table 172 | // to the unit test to recompute char_table. 173 | 174 | enum { 175 | LITERAL = 0, 176 | COPY_1_BYTE_OFFSET = 1, // 3 bit length + 3 bits of offset in opcode 177 | COPY_2_BYTE_OFFSET = 2, 178 | COPY_4_BYTE_OFFSET = 3 179 | }; 180 | static const int kMaximumTagLength = 5; // COPY_4_BYTE_OFFSET plus the actual offset. 181 | 182 | // Data stored per entry in lookup table: 183 | // Range Bits-used Description 184 | // ------------------------------------ 185 | // 1..64 0..7 Literal/copy length encoded in opcode byte 186 | // 0..7 8..10 Copy offset encoded in opcode byte / 256 187 | // 0..4 11..13 Extra bytes after opcode 188 | // 189 | // We use eight bits for the length even though 7 would have sufficed 190 | // because of efficiency reasons: 191 | // (1) Extracting a byte is faster than a bit-field 192 | // (2) It properly aligns copy offset so we do not need a <<8 193 | static const uint16 char_table[256] = { 194 | 0x0001, 0x0804, 0x1001, 0x2001, 0x0002, 0x0805, 0x1002, 0x2002, 195 | 0x0003, 0x0806, 0x1003, 0x2003, 0x0004, 0x0807, 0x1004, 0x2004, 196 | 0x0005, 0x0808, 0x1005, 0x2005, 0x0006, 0x0809, 0x1006, 0x2006, 197 | 0x0007, 0x080a, 0x1007, 0x2007, 0x0008, 0x080b, 0x1008, 0x2008, 198 | 0x0009, 0x0904, 0x1009, 0x2009, 0x000a, 0x0905, 0x100a, 0x200a, 199 | 0x000b, 0x0906, 0x100b, 0x200b, 0x000c, 0x0907, 0x100c, 0x200c, 200 | 0x000d, 0x0908, 0x100d, 0x200d, 0x000e, 0x0909, 0x100e, 0x200e, 201 | 0x000f, 0x090a, 0x100f, 0x200f, 0x0010, 0x090b, 0x1010, 0x2010, 202 | 0x0011, 0x0a04, 0x1011, 0x2011, 0x0012, 0x0a05, 0x1012, 0x2012, 203 | 0x0013, 0x0a06, 0x1013, 0x2013, 0x0014, 0x0a07, 0x1014, 0x2014, 204 | 0x0015, 0x0a08, 0x1015, 0x2015, 0x0016, 0x0a09, 0x1016, 0x2016, 205 | 0x0017, 0x0a0a, 0x1017, 0x2017, 0x0018, 0x0a0b, 0x1018, 0x2018, 206 | 0x0019, 0x0b04, 0x1019, 0x2019, 0x001a, 0x0b05, 0x101a, 0x201a, 207 | 0x001b, 0x0b06, 0x101b, 0x201b, 0x001c, 0x0b07, 0x101c, 0x201c, 208 | 0x001d, 0x0b08, 0x101d, 0x201d, 0x001e, 0x0b09, 0x101e, 0x201e, 209 | 0x001f, 0x0b0a, 0x101f, 0x201f, 0x0020, 0x0b0b, 0x1020, 0x2020, 210 | 0x0021, 0x0c04, 0x1021, 0x2021, 0x0022, 0x0c05, 0x1022, 0x2022, 211 | 0x0023, 0x0c06, 0x1023, 0x2023, 0x0024, 0x0c07, 0x1024, 0x2024, 212 | 0x0025, 0x0c08, 0x1025, 0x2025, 0x0026, 0x0c09, 0x1026, 0x2026, 213 | 0x0027, 0x0c0a, 0x1027, 0x2027, 0x0028, 0x0c0b, 0x1028, 0x2028, 214 | 0x0029, 0x0d04, 0x1029, 0x2029, 0x002a, 0x0d05, 0x102a, 0x202a, 215 | 0x002b, 0x0d06, 0x102b, 0x202b, 0x002c, 0x0d07, 0x102c, 0x202c, 216 | 0x002d, 0x0d08, 0x102d, 0x202d, 0x002e, 0x0d09, 0x102e, 0x202e, 217 | 0x002f, 0x0d0a, 0x102f, 0x202f, 0x0030, 0x0d0b, 0x1030, 0x2030, 218 | 0x0031, 0x0e04, 0x1031, 0x2031, 0x0032, 0x0e05, 0x1032, 0x2032, 219 | 0x0033, 0x0e06, 0x1033, 0x2033, 0x0034, 0x0e07, 0x1034, 0x2034, 220 | 0x0035, 0x0e08, 0x1035, 0x2035, 0x0036, 0x0e09, 0x1036, 0x2036, 221 | 0x0037, 0x0e0a, 0x1037, 0x2037, 0x0038, 0x0e0b, 0x1038, 0x2038, 222 | 0x0039, 0x0f04, 0x1039, 0x2039, 0x003a, 0x0f05, 0x103a, 0x203a, 223 | 0x003b, 0x0f06, 0x103b, 0x203b, 0x003c, 0x0f07, 0x103c, 0x203c, 224 | 0x0801, 0x0f08, 0x103d, 0x203d, 0x1001, 0x0f09, 0x103e, 0x203e, 225 | 0x1801, 0x0f0a, 0x103f, 0x203f, 0x2001, 0x0f0b, 0x1040, 0x2040 226 | }; 227 | 228 | } // end namespace internal 229 | } // end namespace snappy 230 | 231 | #endif // THIRD_PARTY_SNAPPY_SNAPPY_INTERNAL_H_ 232 | -------------------------------------------------------------------------------- /Depedencies/detours/uimports.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Add DLLs to a module import table (uimports.cpp of detours.lib) 4 | // 5 | // Microsoft Research Detours Package, Version 4.0.1 6 | // 7 | // Copyright (c) Microsoft Corporation. All rights reserved. 8 | // 9 | // Note that this file is included into creatwth.cpp one or more times 10 | // (once for each supported module format). 11 | // 12 | 13 | #if DETOURS_VERSION != 0x4c0c1 // 0xMAJORcMINORcPATCH 14 | #error detours.h version mismatch 15 | #endif 16 | 17 | // UpdateImports32 aka UpdateImports64 18 | static BOOL UPDATE_IMPORTS_XX(HANDLE hProcess, 19 | HMODULE hModule, 20 | __in_ecount(nDlls) LPCSTR *plpDlls, 21 | DWORD nDlls) 22 | { 23 | BOOL fSucceeded = FALSE; 24 | DWORD cbNew = 0; 25 | 26 | BYTE * pbNew = NULL; 27 | DWORD i; 28 | SIZE_T cbRead; 29 | DWORD n; 30 | 31 | PBYTE pbModule = (PBYTE)hModule; 32 | 33 | IMAGE_DOS_HEADER idh; 34 | ZeroMemory(&idh, sizeof(idh)); 35 | if (!ReadProcessMemory(hProcess, pbModule, &idh, sizeof(idh), &cbRead) 36 | || cbRead < sizeof(idh)) { 37 | 38 | DETOUR_TRACE(("ReadProcessMemory(idh@%p..%p) failed: %d\n", 39 | pbModule, pbModule + sizeof(idh), GetLastError())); 40 | 41 | finish: 42 | if (pbNew != NULL) { 43 | delete[] pbNew; 44 | pbNew = NULL; 45 | } 46 | return fSucceeded; 47 | } 48 | 49 | IMAGE_NT_HEADERS_XX inh; 50 | ZeroMemory(&inh, sizeof(inh)); 51 | 52 | if (!ReadProcessMemory(hProcess, pbModule + idh.e_lfanew, &inh, sizeof(inh), &cbRead) 53 | || cbRead < sizeof(inh)) { 54 | DETOUR_TRACE(("ReadProcessMemory(inh@%p..%p) failed: %d\n", 55 | pbModule + idh.e_lfanew, 56 | pbModule + idh.e_lfanew + sizeof(inh), 57 | GetLastError())); 58 | goto finish; 59 | } 60 | 61 | if (inh.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC_XX) { 62 | DETOUR_TRACE(("Wrong size image (%04x != %04x).\n", 63 | inh.OptionalHeader.Magic, IMAGE_NT_OPTIONAL_HDR_MAGIC_XX)); 64 | SetLastError(ERROR_INVALID_BLOCK); 65 | goto finish; 66 | } 67 | 68 | // Zero out the bound table so loader doesn't use it instead of our new table. 69 | inh.BOUND_DIRECTORY.VirtualAddress = 0; 70 | inh.BOUND_DIRECTORY.Size = 0; 71 | 72 | // Find the size of the mapped file. 73 | DWORD dwSec = idh.e_lfanew + 74 | FIELD_OFFSET(IMAGE_NT_HEADERS_XX, OptionalHeader) + 75 | inh.FileHeader.SizeOfOptionalHeader; 76 | 77 | for (i = 0; i < inh.FileHeader.NumberOfSections; i++) { 78 | IMAGE_SECTION_HEADER ish; 79 | ZeroMemory(&ish, sizeof(ish)); 80 | 81 | if (!ReadProcessMemory(hProcess, pbModule + dwSec + sizeof(ish) * i, &ish, 82 | sizeof(ish), &cbRead) 83 | || cbRead < sizeof(ish)) { 84 | 85 | DETOUR_TRACE(("ReadProcessMemory(ish@%p..%p) failed: %d\n", 86 | pbModule + dwSec + sizeof(ish) * i, 87 | pbModule + dwSec + sizeof(ish) * (i + 1), 88 | GetLastError())); 89 | goto finish; 90 | } 91 | 92 | DETOUR_TRACE(("ish[%d] : va=%08x sr=%d\n", i, ish.VirtualAddress, ish.SizeOfRawData)); 93 | 94 | // If the file didn't have an IAT_DIRECTORY, we assign it... 95 | if (inh.IAT_DIRECTORY.VirtualAddress == 0 && 96 | inh.IMPORT_DIRECTORY.VirtualAddress >= ish.VirtualAddress && 97 | inh.IMPORT_DIRECTORY.VirtualAddress < ish.VirtualAddress + ish.SizeOfRawData) { 98 | 99 | inh.IAT_DIRECTORY.VirtualAddress = ish.VirtualAddress; 100 | inh.IAT_DIRECTORY.Size = ish.SizeOfRawData; 101 | } 102 | } 103 | 104 | DETOUR_TRACE((" Imports: %p..%p\n", 105 | (DWORD_PTR)pbModule + inh.IMPORT_DIRECTORY.VirtualAddress, 106 | (DWORD_PTR)pbModule + inh.IMPORT_DIRECTORY.VirtualAddress + 107 | inh.IMPORT_DIRECTORY.Size)); 108 | 109 | DWORD nOldDlls = inh.IMPORT_DIRECTORY.Size / sizeof(IMAGE_IMPORT_DESCRIPTOR); 110 | DWORD obRem = sizeof(IMAGE_IMPORT_DESCRIPTOR) * nDlls; 111 | DWORD obOld = obRem + sizeof(IMAGE_IMPORT_DESCRIPTOR) * nOldDlls; 112 | DWORD obTab = PadToDwordPtr(obOld); 113 | DWORD obDll = obTab + sizeof(DWORD_XX) * 4 * nDlls; 114 | DWORD obStr = obDll; 115 | cbNew = obStr; 116 | for (n = 0; n < nDlls; n++) { 117 | cbNew += PadToDword((DWORD)strlen(plpDlls[n]) + 1); 118 | } 119 | 120 | _Analysis_assume_(cbNew > 121 | sizeof(IMAGE_IMPORT_DESCRIPTOR) * (nDlls + nOldDlls) 122 | + sizeof(DWORD_XX) * 4 * nDlls); 123 | pbNew = new BYTE [cbNew]; 124 | if (pbNew == NULL) { 125 | DETOUR_TRACE(("new BYTE [cbNew] failed.\n")); 126 | goto finish; 127 | } 128 | ZeroMemory(pbNew, cbNew); 129 | 130 | PBYTE pbBase = pbModule; 131 | PBYTE pbNext = pbBase 132 | + inh.OptionalHeader.BaseOfCode 133 | + inh.OptionalHeader.SizeOfCode 134 | + inh.OptionalHeader.SizeOfInitializedData 135 | + inh.OptionalHeader.SizeOfUninitializedData; 136 | if (pbBase < pbNext) { 137 | pbBase = pbNext; 138 | } 139 | DETOUR_TRACE(("pbBase = %p\n", pbBase)); 140 | 141 | PBYTE pbNewIid = FindAndAllocateNearBase(hProcess, pbModule, pbBase, cbNew); 142 | if (pbNewIid == NULL) { 143 | DETOUR_TRACE(("FindAndAllocateNearBase failed.\n")); 144 | goto finish; 145 | } 146 | 147 | PIMAGE_IMPORT_DESCRIPTOR piid = (PIMAGE_IMPORT_DESCRIPTOR)pbNew; 148 | DWORD_XX *pt; 149 | 150 | DWORD obBase = (DWORD)(pbNewIid - pbModule); 151 | DWORD dwProtect = 0; 152 | 153 | if (inh.IMPORT_DIRECTORY.VirtualAddress != 0) { 154 | // Read the old import directory if it exists. 155 | DETOUR_TRACE(("IMPORT_DIRECTORY perms=%x\n", dwProtect)); 156 | 157 | if (!ReadProcessMemory(hProcess, 158 | pbModule + inh.IMPORT_DIRECTORY.VirtualAddress, 159 | &piid[nDlls], 160 | nOldDlls * sizeof(IMAGE_IMPORT_DESCRIPTOR), &cbRead) 161 | || cbRead < nOldDlls * sizeof(IMAGE_IMPORT_DESCRIPTOR)) { 162 | 163 | DETOUR_TRACE(("ReadProcessMemory(imports) failed: %d\n", GetLastError())); 164 | goto finish; 165 | } 166 | } 167 | 168 | for (n = 0; n < nDlls; n++) { 169 | HRESULT hrRet = StringCchCopyA((char*)pbNew + obStr, cbNew - obStr, plpDlls[n]); 170 | if (FAILED(hrRet)) { 171 | DETOUR_TRACE(("StringCchCopyA failed: %d\n", GetLastError())); 172 | goto finish; 173 | } 174 | 175 | // After copying the string, we patch up the size "??" bits if any. 176 | hrRet = ReplaceOptionalSizeA((char*)pbNew + obStr, 177 | cbNew - obStr, 178 | DETOURS_STRINGIFY(DETOURS_BITS_XX)); 179 | if (FAILED(hrRet)) { 180 | DETOUR_TRACE(("ReplaceOptionalSizeA failed: %d\n", GetLastError())); 181 | goto finish; 182 | } 183 | 184 | DWORD nOffset = obTab + (sizeof(DWORD_XX) * (4 * n)); 185 | piid[n].OriginalFirstThunk = obBase + nOffset; 186 | pt = ((DWORD_XX*)(pbNew + nOffset)); 187 | pt[0] = IMAGE_ORDINAL_FLAG_XX + 1; 188 | pt[1] = 0; 189 | 190 | nOffset = obTab + (sizeof(DWORD_XX) * ((4 * n) + 2)); 191 | piid[n].FirstThunk = obBase + nOffset; 192 | pt = ((DWORD_XX*)(pbNew + nOffset)); 193 | pt[0] = IMAGE_ORDINAL_FLAG_XX + 1; 194 | pt[1] = 0; 195 | piid[n].TimeDateStamp = 0; 196 | piid[n].ForwarderChain = 0; 197 | piid[n].Name = obBase + obStr; 198 | 199 | obStr += PadToDword((DWORD)strlen(plpDlls[n]) + 1); 200 | } 201 | _Analysis_assume_(obStr <= cbNew); 202 | 203 | #if 0 204 | for (i = 0; i < nDlls + nOldDlls; i++) { 205 | DETOUR_TRACE(("%8d. Look=%08x Time=%08x Fore=%08x Name=%08x Addr=%08x\n", 206 | i, 207 | piid[i].OriginalFirstThunk, 208 | piid[i].TimeDateStamp, 209 | piid[i].ForwarderChain, 210 | piid[i].Name, 211 | piid[i].FirstThunk)); 212 | if (piid[i].OriginalFirstThunk == 0 && piid[i].FirstThunk == 0) { 213 | break; 214 | } 215 | } 216 | #endif 217 | 218 | if (!WriteProcessMemory(hProcess, pbNewIid, pbNew, obStr, NULL)) { 219 | DETOUR_TRACE(("WriteProcessMemory(iid) failed: %d\n", GetLastError())); 220 | goto finish; 221 | } 222 | 223 | DETOUR_TRACE(("obBaseBef = %08x..%08x\n", 224 | inh.IMPORT_DIRECTORY.VirtualAddress, 225 | inh.IMPORT_DIRECTORY.VirtualAddress + inh.IMPORT_DIRECTORY.Size)); 226 | DETOUR_TRACE(("obBaseAft = %08x..%08x\n", obBase, obBase + obStr)); 227 | 228 | // If the file doesn't have an IAT_DIRECTORY, we create it... 229 | if (inh.IAT_DIRECTORY.VirtualAddress == 0) { 230 | inh.IAT_DIRECTORY.VirtualAddress = obBase; 231 | inh.IAT_DIRECTORY.Size = cbNew; 232 | } 233 | 234 | inh.IMPORT_DIRECTORY.VirtualAddress = obBase; 235 | inh.IMPORT_DIRECTORY.Size = cbNew; 236 | 237 | /////////////////////// Update the NT header for the new import directory. 238 | // 239 | if (!DetourVirtualProtectSameExecuteEx(hProcess, pbModule, inh.OptionalHeader.SizeOfHeaders, 240 | PAGE_EXECUTE_READWRITE, &dwProtect)) { 241 | DETOUR_TRACE(("VirtualProtectEx(inh) write failed: %d\n", GetLastError())); 242 | goto finish; 243 | } 244 | 245 | inh.OptionalHeader.CheckSum = 0; 246 | 247 | if (!WriteProcessMemory(hProcess, pbModule, &idh, sizeof(idh), NULL)) { 248 | DETOUR_TRACE(("WriteProcessMemory(idh) failed: %d\n", GetLastError())); 249 | goto finish; 250 | } 251 | DETOUR_TRACE(("WriteProcessMemory(idh:%p..%p)\n", pbModule, pbModule + sizeof(idh))); 252 | 253 | if (!WriteProcessMemory(hProcess, pbModule + idh.e_lfanew, &inh, sizeof(inh), NULL)) { 254 | DETOUR_TRACE(("WriteProcessMemory(inh) failed: %d\n", GetLastError())); 255 | goto finish; 256 | } 257 | DETOUR_TRACE(("WriteProcessMemory(inh:%p..%p)\n", 258 | pbModule + idh.e_lfanew, 259 | pbModule + idh.e_lfanew + sizeof(inh))); 260 | 261 | if (!VirtualProtectEx(hProcess, pbModule, inh.OptionalHeader.SizeOfHeaders, 262 | dwProtect, &dwProtect)) { 263 | DETOUR_TRACE(("VirtualProtectEx(idh) restore failed: %d\n", GetLastError())); 264 | goto finish; 265 | } 266 | 267 | fSucceeded = TRUE; 268 | goto finish; 269 | } 270 | -------------------------------------------------------------------------------- /Depedencies/KHR/khrplatform.h: -------------------------------------------------------------------------------- 1 | #ifndef __khrplatform_h_ 2 | #define __khrplatform_h_ 3 | 4 | /* 5 | ** Copyright (c) 2008-2018 The Khronos Group Inc. 6 | ** 7 | ** Permission is hereby granted, free of charge, to any person obtaining a 8 | ** copy of this software and/or associated documentation files (the 9 | ** "Materials"), to deal in the Materials without restriction, including 10 | ** without limitation the rights to use, copy, modify, merge, publish, 11 | ** distribute, sublicense, and/or sell copies of the Materials, and to 12 | ** permit persons to whom the Materials are furnished to do so, subject to 13 | ** the following conditions: 14 | ** 15 | ** The above copyright notice and this permission notice shall be included 16 | ** in all copies or substantial portions of the Materials. 17 | ** 18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 | ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 25 | */ 26 | 27 | /* Khronos platform-specific types and definitions. 28 | * 29 | * The master copy of khrplatform.h is maintained in the Khronos EGL 30 | * Registry repository at https://github.com/KhronosGroup/EGL-Registry 31 | * The last semantic modification to khrplatform.h was at commit ID: 32 | * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 33 | * 34 | * Adopters may modify this file to suit their platform. Adopters are 35 | * encouraged to submit platform specific modifications to the Khronos 36 | * group so that they can be included in future versions of this file. 37 | * Please submit changes by filing pull requests or issues on 38 | * the EGL Registry repository linked above. 39 | * 40 | * 41 | * See the Implementer's Guidelines for information about where this file 42 | * should be located on your system and for more details of its use: 43 | * http://www.khronos.org/registry/implementers_guide.pdf 44 | * 45 | * This file should be included as 46 | * #include 47 | * by Khronos client API header files that use its types and defines. 48 | * 49 | * The types in khrplatform.h should only be used to define API-specific types. 50 | * 51 | * Types defined in khrplatform.h: 52 | * khronos_int8_t signed 8 bit 53 | * khronos_uint8_t unsigned 8 bit 54 | * khronos_int16_t signed 16 bit 55 | * khronos_uint16_t unsigned 16 bit 56 | * khronos_int32_t signed 32 bit 57 | * khronos_uint32_t unsigned 32 bit 58 | * khronos_int64_t signed 64 bit 59 | * khronos_uint64_t unsigned 64 bit 60 | * khronos_intptr_t signed same number of bits as a pointer 61 | * khronos_uintptr_t unsigned same number of bits as a pointer 62 | * khronos_ssize_t signed size 63 | * khronos_usize_t unsigned size 64 | * khronos_float_t signed 32 bit floating point 65 | * khronos_time_ns_t unsigned 64 bit time in nanoseconds 66 | * khronos_utime_nanoseconds_t unsigned time interval or absolute time in 67 | * nanoseconds 68 | * khronos_stime_nanoseconds_t signed time interval in nanoseconds 69 | * khronos_boolean_enum_t enumerated boolean type. This should 70 | * only be used as a base type when a client API's boolean type is 71 | * an enum. Client APIs which use an integer or other type for 72 | * booleans cannot use this as the base type for their boolean. 73 | * 74 | * Tokens defined in khrplatform.h: 75 | * 76 | * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. 77 | * 78 | * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. 79 | * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. 80 | * 81 | * Calling convention macros defined in this file: 82 | * KHRONOS_APICALL 83 | * KHRONOS_APIENTRY 84 | * KHRONOS_APIATTRIBUTES 85 | * 86 | * These may be used in function prototypes as: 87 | * 88 | * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( 89 | * int arg1, 90 | * int arg2) KHRONOS_APIATTRIBUTES; 91 | */ 92 | 93 | /*------------------------------------------------------------------------- 94 | * Definition of KHRONOS_APICALL 95 | *------------------------------------------------------------------------- 96 | * This precedes the return type of the function in the function prototype. 97 | */ 98 | #if defined(_WIN32) && !defined(__SCITECH_SNAP__) 99 | # define KHRONOS_APICALL __declspec(dllimport) 100 | #elif defined (__SYMBIAN32__) 101 | # define KHRONOS_APICALL IMPORT_C 102 | #elif defined(__ANDROID__) 103 | # define KHRONOS_APICALL __attribute__((visibility("default"))) 104 | #else 105 | # define KHRONOS_APICALL 106 | #endif 107 | 108 | /*------------------------------------------------------------------------- 109 | * Definition of KHRONOS_APIENTRY 110 | *------------------------------------------------------------------------- 111 | * This follows the return type of the function and precedes the function 112 | * name in the function prototype. 113 | */ 114 | #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) 115 | /* Win32 but not WinCE */ 116 | # define KHRONOS_APIENTRY __stdcall 117 | #else 118 | # define KHRONOS_APIENTRY 119 | #endif 120 | 121 | /*------------------------------------------------------------------------- 122 | * Definition of KHRONOS_APIATTRIBUTES 123 | *------------------------------------------------------------------------- 124 | * This follows the closing parenthesis of the function prototype arguments. 125 | */ 126 | #if defined (__ARMCC_2__) 127 | #define KHRONOS_APIATTRIBUTES __softfp 128 | #else 129 | #define KHRONOS_APIATTRIBUTES 130 | #endif 131 | 132 | /*------------------------------------------------------------------------- 133 | * basic type definitions 134 | *-----------------------------------------------------------------------*/ 135 | #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) 136 | 137 | 138 | /* 139 | * Using 140 | */ 141 | #include 142 | typedef int32_t khronos_int32_t; 143 | typedef uint32_t khronos_uint32_t; 144 | typedef int64_t khronos_int64_t; 145 | typedef uint64_t khronos_uint64_t; 146 | #define KHRONOS_SUPPORT_INT64 1 147 | #define KHRONOS_SUPPORT_FLOAT 1 148 | 149 | #elif defined(__VMS ) || defined(__sgi) 150 | 151 | /* 152 | * Using 153 | */ 154 | #include 155 | typedef int32_t khronos_int32_t; 156 | typedef uint32_t khronos_uint32_t; 157 | typedef int64_t khronos_int64_t; 158 | typedef uint64_t khronos_uint64_t; 159 | #define KHRONOS_SUPPORT_INT64 1 160 | #define KHRONOS_SUPPORT_FLOAT 1 161 | 162 | #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) 163 | 164 | /* 165 | * Win32 166 | */ 167 | typedef __int32 khronos_int32_t; 168 | typedef unsigned __int32 khronos_uint32_t; 169 | typedef __int64 khronos_int64_t; 170 | typedef unsigned __int64 khronos_uint64_t; 171 | #define KHRONOS_SUPPORT_INT64 1 172 | #define KHRONOS_SUPPORT_FLOAT 1 173 | 174 | #elif defined(__sun__) || defined(__digital__) 175 | 176 | /* 177 | * Sun or Digital 178 | */ 179 | typedef int khronos_int32_t; 180 | typedef unsigned int khronos_uint32_t; 181 | #if defined(__arch64__) || defined(_LP64) 182 | typedef long int khronos_int64_t; 183 | typedef unsigned long int khronos_uint64_t; 184 | #else 185 | typedef long long int khronos_int64_t; 186 | typedef unsigned long long int khronos_uint64_t; 187 | #endif /* __arch64__ */ 188 | #define KHRONOS_SUPPORT_INT64 1 189 | #define KHRONOS_SUPPORT_FLOAT 1 190 | 191 | #elif 0 192 | 193 | /* 194 | * Hypothetical platform with no float or int64 support 195 | */ 196 | typedef int khronos_int32_t; 197 | typedef unsigned int khronos_uint32_t; 198 | #define KHRONOS_SUPPORT_INT64 0 199 | #define KHRONOS_SUPPORT_FLOAT 0 200 | 201 | #else 202 | 203 | /* 204 | * Generic fallback 205 | */ 206 | #include 207 | typedef int32_t khronos_int32_t; 208 | typedef uint32_t khronos_uint32_t; 209 | typedef int64_t khronos_int64_t; 210 | typedef uint64_t khronos_uint64_t; 211 | #define KHRONOS_SUPPORT_INT64 1 212 | #define KHRONOS_SUPPORT_FLOAT 1 213 | 214 | #endif 215 | 216 | 217 | /* 218 | * Types that are (so far) the same on all platforms 219 | */ 220 | typedef signed char khronos_int8_t; 221 | typedef unsigned char khronos_uint8_t; 222 | typedef signed short int khronos_int16_t; 223 | typedef unsigned short int khronos_uint16_t; 224 | 225 | /* 226 | * Types that differ between LLP64 and LP64 architectures - in LLP64, 227 | * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears 228 | * to be the only LLP64 architecture in current use. 229 | */ 230 | #ifdef _WIN64 231 | typedef signed long long int khronos_intptr_t; 232 | typedef unsigned long long int khronos_uintptr_t; 233 | typedef signed long long int khronos_ssize_t; 234 | typedef unsigned long long int khronos_usize_t; 235 | #else 236 | typedef signed long int khronos_intptr_t; 237 | typedef unsigned long int khronos_uintptr_t; 238 | typedef signed long int khronos_ssize_t; 239 | typedef unsigned long int khronos_usize_t; 240 | #endif 241 | 242 | #if KHRONOS_SUPPORT_FLOAT 243 | /* 244 | * Float type 245 | */ 246 | typedef float khronos_float_t; 247 | #endif 248 | 249 | #if KHRONOS_SUPPORT_INT64 250 | /* Time types 251 | * 252 | * These types can be used to represent a time interval in nanoseconds or 253 | * an absolute Unadjusted System Time. Unadjusted System Time is the number 254 | * of nanoseconds since some arbitrary system event (e.g. since the last 255 | * time the system booted). The Unadjusted System Time is an unsigned 256 | * 64 bit value that wraps back to 0 every 584 years. Time intervals 257 | * may be either signed or unsigned. 258 | */ 259 | typedef khronos_uint64_t khronos_utime_nanoseconds_t; 260 | typedef khronos_int64_t khronos_stime_nanoseconds_t; 261 | #endif 262 | 263 | /* 264 | * Dummy value used to pad enum types to 32 bits. 265 | */ 266 | #ifndef KHRONOS_MAX_ENUM 267 | #define KHRONOS_MAX_ENUM 0x7FFFFFFF 268 | #endif 269 | 270 | /* 271 | * Enumerated boolean type 272 | * 273 | * Values other than zero should be considered to be true. Therefore 274 | * comparisons should not be made against KHRONOS_TRUE. 275 | */ 276 | typedef enum { 277 | KHRONOS_FALSE = 0, 278 | KHRONOS_TRUE = 1, 279 | KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM 280 | } khronos_boolean_enum_t; 281 | 282 | #endif /* __khrplatform_h_ */ 283 | -------------------------------------------------------------------------------- /Depedencies/parser.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ARIA_CSV_H 2 | #define ARIA_CSV_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace aria { 11 | namespace csv { 12 | enum class Term : char { CRLF = -2 }; 13 | enum class FieldType { DATA, ROW_END, CSV_END }; 14 | using CSV = std::vector>; 15 | 16 | // Checking for '\n', '\r', and '\r\n' by default 17 | inline bool operator==(const char c, const Term t) { 18 | switch (t) { 19 | case Term::CRLF: 20 | return c == '\r' || c == '\n'; 21 | default: 22 | return static_cast(t) == c; 23 | } 24 | } 25 | 26 | inline bool operator!=(const char c, const Term t) { 27 | return !(c == t); 28 | } 29 | 30 | // Wraps returned fields so we can also indicate 31 | // that we hit row endings or the end of the csv itself 32 | struct Field { 33 | explicit Field(FieldType t): type(t), data(nullptr) {} 34 | explicit Field(const std::string& str): type(FieldType::DATA), data(&str) {} 35 | 36 | FieldType type; 37 | const std::string *data; 38 | }; 39 | 40 | // Reads and parses lines from a csv file 41 | class CsvParser { 42 | private: 43 | // CSV state for state machine 44 | enum class State { 45 | START_OF_FIELD, 46 | IN_FIELD, 47 | IN_QUOTED_FIELD, 48 | IN_ESCAPED_QUOTE, 49 | END_OF_ROW, 50 | EMPTY 51 | }; 52 | State m_state = State::START_OF_FIELD; 53 | 54 | // Configurable attributes 55 | char m_quote = '"'; 56 | char m_delimiter = ','; 57 | Term m_terminator = Term::CRLF; 58 | std::istream& m_input; 59 | 60 | // Buffer capacities 61 | static constexpr int FIELDBUF_CAP = 1024; 62 | static constexpr int INPUTBUF_CAP = 1024 * 128; 63 | 64 | // Buffers 65 | std::string m_fieldbuf{}; 66 | char m_inputbuf[INPUTBUF_CAP]{}; 67 | 68 | // Misc 69 | bool m_eof = false; 70 | size_t m_cursor = INPUTBUF_CAP; 71 | size_t m_inputbuf_size = INPUTBUF_CAP; 72 | std::streamoff m_scanposition = -INPUTBUF_CAP; 73 | public: 74 | // Creates the CSV parser which by default, splits on commas, 75 | // uses quotes to escape, and handles CSV files that end in either 76 | // '\r', '\n', or '\r\n'. 77 | explicit CsvParser(std::istream& input): m_input(input) { 78 | // Reserve space upfront to improve performance 79 | m_fieldbuf.reserve(FIELDBUF_CAP); 80 | if (!m_input.good()) { 81 | throw std::runtime_error("Something is wrong with input stream"); 82 | } 83 | } 84 | 85 | // Change the quote character 86 | CsvParser& quote(char c) noexcept { 87 | m_quote = c; 88 | return *this; 89 | } 90 | 91 | // Change the delimiter character 92 | CsvParser& delimiter(char c) noexcept { 93 | m_delimiter = c; 94 | return *this; 95 | } 96 | 97 | // Change the terminator character 98 | CsvParser& terminator(char c) noexcept { 99 | m_terminator = static_cast(c); 100 | return *this; 101 | } 102 | 103 | // The parser is in the empty state when there are 104 | // no more tokens left to read from the input buffer 105 | bool empty() { 106 | return m_state == State::EMPTY; 107 | } 108 | 109 | // Not the actual position in the stream (its buffered) just the 110 | // position up to last availiable token 111 | std::streamoff position() const 112 | { 113 | return m_scanposition + static_cast(m_cursor); 114 | } 115 | 116 | // Reads a single field from the CSV 117 | Field next_field() { 118 | if (empty()) { 119 | return Field(FieldType::CSV_END); 120 | } 121 | m_fieldbuf.clear(); 122 | 123 | // This loop runs until either the parser has 124 | // read a full field or until there's no tokens left to read 125 | for (;;) { 126 | char *maybe_token = top_token(); 127 | 128 | // If we're out of tokens to read return whatever's left in the 129 | // field and row buffers. If there's nothing left, return null. 130 | if (!maybe_token) { 131 | m_state = State::EMPTY; 132 | return !m_fieldbuf.empty() ? Field(m_fieldbuf) : Field(FieldType::CSV_END); 133 | } 134 | 135 | // Parsing the CSV is done using a finite state machine 136 | char c = *maybe_token; 137 | switch (m_state) { 138 | case State::START_OF_FIELD: 139 | m_cursor++; 140 | if (c == m_terminator) { 141 | handle_crlf(c); 142 | return Field(FieldType::ROW_END); 143 | } 144 | 145 | if (c == m_quote) { 146 | m_state = State::IN_QUOTED_FIELD; 147 | } else if (c == m_delimiter) { 148 | return Field(m_fieldbuf); 149 | } else { 150 | m_state = State::IN_FIELD; 151 | m_fieldbuf += c; 152 | } 153 | 154 | break; 155 | 156 | case State::IN_FIELD: 157 | m_cursor++; 158 | if (c == m_terminator) { 159 | handle_crlf(c); 160 | m_state = State::END_OF_ROW; 161 | return Field(m_fieldbuf); 162 | } 163 | 164 | if (c == m_delimiter) { 165 | m_state = State::START_OF_FIELD; 166 | return Field(m_fieldbuf); 167 | } else { 168 | m_fieldbuf += c; 169 | } 170 | 171 | break; 172 | 173 | case State::IN_QUOTED_FIELD: 174 | m_cursor++; 175 | if (c == m_quote) { 176 | m_state = State::IN_ESCAPED_QUOTE; 177 | } else { 178 | m_fieldbuf += c; 179 | } 180 | 181 | break; 182 | 183 | case State::IN_ESCAPED_QUOTE: 184 | m_cursor++; 185 | if (c == m_terminator) { 186 | handle_crlf(c); 187 | m_state = State::END_OF_ROW; 188 | return Field(m_fieldbuf); 189 | } 190 | 191 | if (c == m_quote) { 192 | m_state = State::IN_QUOTED_FIELD; 193 | m_fieldbuf += c; 194 | } else if (c == m_delimiter) { 195 | m_state = State::START_OF_FIELD; 196 | return Field(m_fieldbuf); 197 | } else { 198 | m_state = State::IN_FIELD; 199 | m_fieldbuf += c; 200 | } 201 | 202 | break; 203 | 204 | case State::END_OF_ROW: 205 | m_state = State::START_OF_FIELD; 206 | return Field(FieldType::ROW_END); 207 | 208 | case State::EMPTY: 209 | throw std::logic_error("You goofed"); 210 | } 211 | } 212 | } 213 | private: 214 | // When the parser hits the end of a line it needs 215 | // to check the special case of '\r\n' as a terminator. 216 | // If it finds that the previous token was a '\r', and 217 | // the next token will be a '\n', it skips the '\n'. 218 | void handle_crlf(const char c) { 219 | if (m_terminator != Term::CRLF || c != '\r') { 220 | return; 221 | } 222 | 223 | char *token = top_token(); 224 | if (token && *token == '\n') { 225 | m_cursor++; 226 | } 227 | } 228 | 229 | // Pulls the next token from the input buffer, but does not move 230 | // the cursor forward. If the stream is empty and the input buffer 231 | // is also empty return a nullptr. 232 | char* top_token() { 233 | // Return null if there's nothing left to read 234 | if (m_eof && m_cursor == m_inputbuf_size) { 235 | return nullptr; 236 | } 237 | 238 | // Refill the input buffer if it's been fully read 239 | if (m_cursor == m_inputbuf_size) { 240 | m_scanposition += static_cast(m_cursor); 241 | m_cursor = 0; 242 | m_input.read(m_inputbuf, INPUTBUF_CAP); 243 | 244 | // Indicate we hit end of file, and resize 245 | // input buffer to show that it's not at full capacity 246 | if (m_input.eof()) { 247 | m_eof = true; 248 | m_inputbuf_size = m_input.gcount(); 249 | 250 | // Return null if there's nothing left to read 251 | if (m_inputbuf_size == 0) { 252 | return nullptr; 253 | } 254 | } 255 | } 256 | 257 | return &m_inputbuf[m_cursor]; 258 | } 259 | public: 260 | // Iterator implementation for the CSV parser, which reads 261 | // from the CSV row by row in the form of a vector of strings 262 | class iterator { 263 | public: 264 | using difference_type = std::ptrdiff_t; 265 | using value_type = std::vector; 266 | using pointer = const std::vector*; 267 | using reference = const std::vector&; 268 | using iterator_category = std::input_iterator_tag; 269 | 270 | explicit iterator(CsvParser *p, bool end = false): m_parser(p) { 271 | if (!end) { 272 | m_row.reserve(50); 273 | m_current_row = 0; 274 | next(); 275 | } 276 | } 277 | 278 | iterator& operator++() { 279 | next(); 280 | return *this; 281 | } 282 | 283 | iterator operator++(int) { 284 | iterator i = (*this); 285 | ++(*this); 286 | return i; 287 | } 288 | 289 | bool operator==(const iterator& other) const { 290 | return m_current_row == other.m_current_row 291 | && m_row.size() == other.m_row.size(); 292 | } 293 | 294 | bool operator!=(const iterator& other) const { 295 | return !(*this == other); 296 | } 297 | 298 | reference operator*() const { 299 | return m_row; 300 | } 301 | 302 | pointer operator->() const { 303 | return &m_row; 304 | } 305 | private: 306 | value_type m_row{}; 307 | CsvParser *m_parser; 308 | int m_current_row = -1; 309 | 310 | void next() { 311 | value_type::size_type num_fields = 0; 312 | for (;;) { 313 | auto field = m_parser->next_field(); 314 | switch (field.type) { 315 | case FieldType::CSV_END: 316 | if (num_fields < m_row.size()) { 317 | m_row.resize(num_fields); 318 | } 319 | m_current_row = -1; 320 | return; 321 | case FieldType::ROW_END: 322 | if (num_fields < m_row.size()) { 323 | m_row.resize(num_fields); 324 | } 325 | m_current_row++; 326 | return; 327 | case FieldType::DATA: 328 | if (num_fields < m_row.size()) { 329 | m_row[num_fields] = std::move(*field.data); 330 | } else { 331 | m_row.push_back(std::move(*field.data)); 332 | } 333 | num_fields++; 334 | } 335 | } 336 | } 337 | }; 338 | 339 | iterator begin() { return iterator(this); }; 340 | iterator end() { return iterator(this, true); }; 341 | }; 342 | } 343 | } 344 | #endif 345 | -------------------------------------------------------------------------------- /Depedencies/imgui/imgui_impl_opengl2.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline) 2 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. 6 | 7 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 8 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 9 | // https://github.com/ocornut/imgui 10 | 11 | // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** 12 | // **Prefer using the code in imgui_impl_opengl3.cpp** 13 | // This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read. 14 | // If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more 15 | // complicated, will require your code to reset every single OpenGL attributes to their initial state, and might 16 | // confuse your GPU driver. 17 | // The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API. 18 | 19 | // CHANGELOG 20 | // (minor and older changes stripped away, please see git history for details) 21 | // 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display. 22 | // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. 23 | // 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications. 24 | // 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples. 25 | // 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. 26 | // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplGlfwGL2_RenderDrawData() in the .h file so you can call it yourself. 27 | // 2017-09-01: OpenGL: Save and restore current polygon mode. 28 | // 2016-09-10: OpenGL: Uploading font texture as RGBA32 to increase compatibility with users shaders (not ideal). 29 | // 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle. 30 | 31 | #include "imgui.h" 32 | #include "imgui_impl_opengl2.h" 33 | #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier 34 | #include // intptr_t 35 | #else 36 | #include // intptr_t 37 | #endif 38 | 39 | // Include OpenGL header (without an OpenGL loader) requires a bit of fiddling 40 | #if defined(_WIN32) && !defined(APIENTRY) 41 | #define APIENTRY __stdcall // It is customary to use APIENTRY for OpenGL function pointer declarations on all platforms. Additionally, the Windows OpenGL header needs APIENTRY. 42 | #endif 43 | #if defined(_WIN32) && !defined(WINGDIAPI) 44 | #define WINGDIAPI __declspec(dllimport) // Some Windows OpenGL headers need this 45 | #endif 46 | #if defined(__APPLE__) 47 | #define GL_SILENCE_DEPRECATION 48 | #include 49 | #else 50 | #include 51 | #endif 52 | 53 | // OpenGL Data 54 | static GLuint g_FontTexture = 0; 55 | 56 | // Functions 57 | bool ImGui_ImplOpenGL2_Init() 58 | { 59 | ImGuiIO& io = ImGui::GetIO(); 60 | io.BackendRendererName = "imgui_impl_opengl2"; 61 | return true; 62 | } 63 | 64 | void ImGui_ImplOpenGL2_Shutdown() 65 | { 66 | ImGui_ImplOpenGL2_DestroyDeviceObjects(); 67 | } 68 | 69 | void ImGui_ImplOpenGL2_NewFrame() 70 | { 71 | if (!g_FontTexture) 72 | ImGui_ImplOpenGL2_CreateDeviceObjects(); 73 | } 74 | 75 | // OpenGL2 Render function. 76 | // (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) 77 | // Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so. 78 | void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data) 79 | { 80 | // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) 81 | int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x); 82 | int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y); 83 | if (fb_width == 0 || fb_height == 0) 84 | return; 85 | 86 | // We are using the OpenGL fixed pipeline to make the example code simpler to read! 87 | // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill. 88 | GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); 89 | GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); 90 | GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport); 91 | GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box); 92 | glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT); 93 | glEnable(GL_BLEND); 94 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 95 | glDisable(GL_CULL_FACE); 96 | glDisable(GL_DEPTH_TEST); 97 | glDisable(GL_LIGHTING); 98 | glDisable(GL_COLOR_MATERIAL); 99 | glEnable(GL_SCISSOR_TEST); 100 | glEnableClientState(GL_VERTEX_ARRAY); 101 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); 102 | glEnableClientState(GL_COLOR_ARRAY); 103 | glEnable(GL_TEXTURE_2D); 104 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 105 | 106 | // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!), 107 | // you may need to backup/reset/restore current shader using the lines below. DO NOT MODIFY THIS FILE! Add the code in your calling function: 108 | // GLint last_program; 109 | // glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); 110 | // glUseProgram(0); 111 | // ImGui_ImplOpenGL2_RenderDrawData(...); 112 | // glUseProgram(last_program) 113 | 114 | // Setup viewport, orthographic projection matrix 115 | // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. 116 | glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height); 117 | glMatrixMode(GL_PROJECTION); 118 | glPushMatrix(); 119 | glLoadIdentity(); 120 | glOrtho(draw_data->DisplayPos.x, draw_data->DisplayPos.x + draw_data->DisplaySize.x, draw_data->DisplayPos.y + draw_data->DisplaySize.y, draw_data->DisplayPos.y, -1.0f, +1.0f); 121 | glMatrixMode(GL_MODELVIEW); 122 | glPushMatrix(); 123 | glLoadIdentity(); 124 | 125 | // Will project scissor/clipping rectangles into framebuffer space 126 | ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports 127 | ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2) 128 | 129 | // Render command lists 130 | for (int n = 0; n < draw_data->CmdListsCount; n++) 131 | { 132 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 133 | const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; 134 | const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; 135 | glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos))); 136 | glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv))); 137 | glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col))); 138 | 139 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) 140 | { 141 | const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; 142 | if (pcmd->UserCallback) 143 | { 144 | // User callback (registered via ImDrawList::AddCallback) 145 | pcmd->UserCallback(cmd_list, pcmd); 146 | } 147 | else 148 | { 149 | // Project scissor/clipping rectangles into framebuffer space 150 | ImVec4 clip_rect; 151 | clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x; 152 | clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y; 153 | clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x; 154 | clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y; 155 | 156 | if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f) 157 | { 158 | // Apply scissor/clipping rectangle 159 | glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y)); 160 | 161 | // Bind texture, Draw 162 | glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId); 163 | glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer); 164 | } 165 | } 166 | idx_buffer += pcmd->ElemCount; 167 | } 168 | } 169 | 170 | // Restore modified state 171 | glDisableClientState(GL_COLOR_ARRAY); 172 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); 173 | glDisableClientState(GL_VERTEX_ARRAY); 174 | glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture); 175 | glMatrixMode(GL_MODELVIEW); 176 | glPopMatrix(); 177 | glMatrixMode(GL_PROJECTION); 178 | glPopMatrix(); 179 | glPopAttrib(); 180 | glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]); 181 | glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]); 182 | glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); 183 | } 184 | 185 | bool ImGui_ImplOpenGL2_CreateFontsTexture() 186 | { 187 | // Build texture atlas 188 | ImGuiIO& io = ImGui::GetIO(); 189 | unsigned char* pixels; 190 | int width, height; 191 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. 192 | 193 | // Upload texture to graphics system 194 | GLint last_texture; 195 | glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); 196 | glGenTextures(1, &g_FontTexture); 197 | glBindTexture(GL_TEXTURE_2D, g_FontTexture); 198 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 199 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 200 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 201 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 202 | 203 | // Store our identifier 204 | io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture; 205 | 206 | // Restore state 207 | glBindTexture(GL_TEXTURE_2D, last_texture); 208 | 209 | return true; 210 | } 211 | 212 | void ImGui_ImplOpenGL2_DestroyFontsTexture() 213 | { 214 | if (g_FontTexture) 215 | { 216 | ImGuiIO& io = ImGui::GetIO(); 217 | glDeleteTextures(1, &g_FontTexture); 218 | io.Fonts->TexID = 0; 219 | g_FontTexture = 0; 220 | } 221 | } 222 | 223 | bool ImGui_ImplOpenGL2_CreateDeviceObjects() 224 | { 225 | return ImGui_ImplOpenGL2_CreateFontsTexture(); 226 | } 227 | 228 | void ImGui_ImplOpenGL2_DestroyDeviceObjects() 229 | { 230 | ImGui_ImplOpenGL2_DestroyFontsTexture(); 231 | } 232 | --------------------------------------------------------------------------------