diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bace4cb0..5f9ae839d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,8 +94,12 @@ target_link_libraries( PUBLIC binary_io::binary_io spdlog::spdlog - Version.lib + Advapi32.lib + D3D11.lib Dbghelp.lib + DXGI.lib + Ole32.lib + Version.lib ) target_precompile_headers( diff --git a/cmake/sourcelist.cmake b/cmake/sourcelist.cmake index 297ce72d1..516b10289 100644 --- a/cmake/sourcelist.cmake +++ b/cmake/sourcelist.cmake @@ -1620,16 +1620,40 @@ set(SOURCES include/REL/REL.h include/REL/Relocation.h include/REL/Version.h + include/REX/PS4.h + include/REX/PS4/SCEPAD.h + include/REX/W32.h + include/REX/W32/ADVAPI32.h + include/REX/W32/BASE.h + include/REX/W32/COM.h + include/REX/W32/COMPTR.h + include/REX/W32/D3D.h + include/REX/W32/D3D11.h + include/REX/W32/D3D11_1.h + include/REX/W32/D3D11_2.h + include/REX/W32/D3D11_3.h + include/REX/W32/D3D11_4.h + include/REX/W32/D3DCOMPILER.h + include/REX/W32/DBGHELP.h + include/REX/W32/DINPUT.h + include/REX/W32/DXGI.h + include/REX/W32/DXGI_2.h + include/REX/W32/DXGI_3.h + include/REX/W32/DXGI_4.h + include/REX/W32/DXGI_5.h + include/REX/W32/DXGI_6.h + include/REX/W32/KERNEL32.h + include/REX/W32/OLE32.h + include/REX/W32/SHELL32.h + include/REX/W32/USER32.h + include/REX/W32/VERSION.h + include/REX/W32/XINPUT.h include/SKSE/API.h include/SKSE/Events.h include/SKSE/IAT.h - include/SKSE/Impl/DInputAPI.h include/SKSE/Impl/PCH.h include/SKSE/Impl/RegistrationTraits.h - include/SKSE/Impl/ScePadAPI.h include/SKSE/Impl/Stubs.h - include/SKSE/Impl/WinAPI.h - include/SKSE/Impl/XInputAPI.h include/SKSE/InputMap.h include/SKSE/Interfaces.h include/SKSE/Logger.h @@ -1965,10 +1989,19 @@ set(SOURCES src/RE/Z/ZeroFunctionArguments.cpp src/REL/ID.cpp src/REL/Module.cpp + src/REX/W32/ADVAPI32.cpp + src/REX/W32/D3D11.cpp + src/REX/W32/D3DCOMPILER.cpp + src/REX/W32/DBGHELP.cpp + src/REX/W32/DXGI.cpp + src/REX/W32/KERNEL32.cpp + src/REX/W32/OLE32.cpp + src/REX/W32/SHELL32.cpp + src/REX/W32/USER32.cpp + src/REX/W32/VERSION.cpp src/SKSE/API.cpp src/SKSE/IAT.cpp src/SKSE/Impl/PCH.cpp - src/SKSE/Impl/WinAPI.cpp src/SKSE/InputMap.cpp src/SKSE/Interfaces.cpp src/SKSE/Logger.cpp diff --git a/include/RE/A/Actor.h b/include/RE/A/Actor.h index cbf210e86..13dd763ae 100644 --- a/include/RE/A/Actor.h +++ b/include/RE/A/Actor.h @@ -24,6 +24,8 @@ #include "RE/T/TESNPC.h" #include "RE/T/TESObjectREFR.h" +#include "REX/W32/BASE.h" + namespace RE { class ActorMagicCaster; @@ -688,7 +690,7 @@ namespace RE std::uint32_t unk274; // 274 std::uint64_t unk278; // 278 std::uint64_t unk280; // 280 - WinAPI::CRITICAL_SECTION unk288; // 288 - havok related + REX::W32::CRITICAL_SECTION unk288; // 288 - havok related private: void CalculateCurrentVendorFaction() const; diff --git a/include/RE/B/BSAtomic.h b/include/RE/B/BSAtomic.h index a804fe4be..037376f49 100644 --- a/include/RE/B/BSAtomic.h +++ b/include/RE/B/BSAtomic.h @@ -1,12 +1,14 @@ #pragma once +#include "REX/W32/BASE.h" + namespace RE { class BSCriticalSection { public: // members - WinAPI::CRITICAL_SECTION criticalSection; // 00 + REX::W32::CRITICAL_SECTION criticalSection; // 00 }; static_assert(sizeof(BSCriticalSection) == 0x28); diff --git a/include/RE/B/BSDirectInputManager.h b/include/RE/B/BSDirectInputManager.h index 53db931c1..b0631a59f 100644 --- a/include/RE/B/BSDirectInputManager.h +++ b/include/RE/B/BSDirectInputManager.h @@ -2,6 +2,15 @@ #include "RE/B/BSTSingleton.h" +#include "REX/W32/BASE.h" + +namespace REX::W32 +{ + struct DIDEVICEOBJECTDATA; + struct IDirectInput8A; + struct IDirectInputDevice8A; +} + namespace RE { class BSDirectInputManager : public BSTSingletonSDM @@ -9,14 +18,14 @@ namespace RE public: static BSDirectInputManager* GetSingleton(); - DirectInput8::IDirectInputDevice8A* CreateDeviceWithGUID(WinAPI::GUID* a_guid); - void GetDeviceState(DirectInput8::IDirectInputDevice8A* a_device, std::uint32_t a_size, void* a_outData); - void GetDeviceData(DirectInput8::IDirectInputDevice8A* a_device, std::uint32_t* a_dataSize, DirectInput8::DIDEVICEOBJECTDATA** a_outData); - void ReleaseDevice(DirectInput8::IDirectInputDevice8A* a_device); + REX::W32::IDirectInputDevice8A* CreateDeviceWithGUID(REX::W32::GUID* a_guid); + void GetDeviceState(REX::W32::IDirectInputDevice8A* a_device, std::uint32_t a_size, void* a_outData); + void GetDeviceData(REX::W32::IDirectInputDevice8A* a_device, std::uint32_t* a_dataSize, REX::W32::DIDEVICEOBJECTDATA** a_outData); + void ReleaseDevice(REX::W32::IDirectInputDevice8A* a_device); // members - std::uint32_t pad00; // 00 - DirectInput8::IDirectInput8A* diInterface; // 08 + std::uint32_t pad00; // 00 + REX::W32::IDirectInput8A* diInterface; // 08 }; static_assert(sizeof(BSDirectInputManager) == 0x10); } diff --git a/include/RE/B/BSFile.h b/include/RE/B/BSFile.h index 239add3a7..ce2883010 100644 --- a/include/RE/B/BSFile.h +++ b/include/RE/B/BSFile.h @@ -2,6 +2,8 @@ #include "RE/N/NiFile.h" +#include "REX/W32/BASE.h" + namespace RE { class BSFile : public NiFile @@ -31,22 +33,22 @@ namespace RE virtual void Unk_12(void); // 12 // members - bool useAuxBuffer; // 048 - std::uint8_t pad049; // 049 - std::uint16_t pad04A; // 04A - std::uint32_t pad04C; // 04C - char* auxBuffer; // 050 - std::int32_t auxTrueFilePos; // 058 - std::uint32_t auxBufferMinIndex; // 05C - std::uint32_t auxBufferMaxIndex; // 060 - char fileName[WinAPI::MAX_PATH]; // 064 - std::uint32_t result; // 168 - std::uint32_t ioSize; // 16C - std::uint32_t trueFilePos; // 170 - std::uint32_t fileSize; // 174 - bool virtualAlloc; // 178 - std::uint8_t unk179; // 179 - std::uint16_t unk17A; // 17A + bool useAuxBuffer; // 048 + std::uint8_t pad049; // 049 + std::uint16_t pad04A; // 04A + std::uint32_t pad04C; // 04C + char* auxBuffer; // 050 + std::int32_t auxTrueFilePos; // 058 + std::uint32_t auxBufferMinIndex; // 05C + std::uint32_t auxBufferMaxIndex; // 060 + char fileName[REX::W32::MAX_PATH]; // 064 + std::uint32_t result; // 168 + std::uint32_t ioSize; // 16C + std::uint32_t trueFilePos; // 170 + std::uint32_t fileSize; // 174 + bool virtualAlloc; // 178 + std::uint8_t unk179; // 179 + std::uint16_t unk17A; // 17A }; static_assert(sizeof(BSFile) == 0x180); } diff --git a/include/RE/B/BSMultiIndexTriShape.h b/include/RE/B/BSMultiIndexTriShape.h index 31f5ab53a..fcc7a1dd1 100644 --- a/include/RE/B/BSMultiIndexTriShape.h +++ b/include/RE/B/BSMultiIndexTriShape.h @@ -4,6 +4,8 @@ #include "RE/N/NiColor.h" #include "RE/N/NiSmartPointer.h" +#include "REX/W32/D3D.h" + namespace RE { namespace BSGraphics @@ -29,7 +31,7 @@ namespace RE // members BSGraphics::IndexBuffer* altIndexBuffer; // 160 std::uint32_t altPrimCount; // 168 - DirectX::XMFLOAT4X4 materialProjection; // 16C + REX::W32::XMFLOAT4X4 materialProjection; // 16C std::uint32_t pad1AC; // 1AC NiPointer additionalShaderProperty; // 1B0 std::uint8_t useAdditionalTriList; // 1B8 diff --git a/include/RE/B/BSPCOrbisGamepadDevice.h b/include/RE/B/BSPCOrbisGamepadDevice.h index c3a85046d..b5e0a4be0 100644 --- a/include/RE/B/BSPCOrbisGamepadDevice.h +++ b/include/RE/B/BSPCOrbisGamepadDevice.h @@ -2,6 +2,8 @@ #include "RE/B/BSPCGamepadDeviceDelegate.h" +#include "REX/PS4/SCEPAD.h" + namespace RE { // PS4 controller used via HID polling @@ -17,26 +19,26 @@ namespace RE { // Masks for buttonState // Key hardware value - kUp = ScePad::ScePadButton::SCE_PAD_BUTTON_UP, - kDown = ScePad::ScePadButton::SCE_PAD_BUTTON_DOWN, - kLeft = ScePad::ScePadButton::SCE_PAD_BUTTON_LEFT, - kRight = ScePad::ScePadButton::SCE_PAD_BUTTON_RIGHT, - kPS3_Start = ScePad::ScePadButton::SCE_PAD_BUTTON_OPTIONS, - kPS3_Back = ScePad::ScePadButton::SCE_PAD_BUTTON_TOUCH_PAD, // This is mapped to the touchpad on the PS4 controller - kPS3_L3 = ScePad::ScePadButton::SCE_PAD_BUTTON_L3, - kPS3_R3 = ScePad::ScePadButton::SCE_PAD_BUTTON_R3, - kPS3_LB = ScePad::ScePadButton::SCE_PAD_BUTTON_L1, - kPS3_RB = ScePad::ScePadButton::SCE_PAD_BUTTON_R1, - kPS3_A = ScePad::ScePadButton::SCE_PAD_BUTTON_CROSS, - kPS3_B = ScePad::ScePadButton::SCE_PAD_BUTTON_CIRCLE, - kPS3_X = ScePad::ScePadButton::SCE_PAD_BUTTON_SQUARE, - kPS3_Y = ScePad::ScePadButton::SCE_PAD_BUTTON_TRIANGLE, + kUp = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_UP, + kDown = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_DOWN, + kLeft = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_LEFT, + kRight = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_RIGHT, + kPS3_Start = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_OPTIONS, + kPS3_Back = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_TOUCH_PAD, // This is mapped to the touchpad on the PS4 controller + kPS3_L3 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_L3, + kPS3_R3 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_R3, + kPS3_LB = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_L1, + kPS3_RB = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_R1, + kPS3_A = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_CROSS, + kPS3_B = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_CIRCLE, + kPS3_X = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_SQUARE, + kPS3_Y = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_TRIANGLE, // Unused by Skyrim - kPS4_Share = ScePad::ScePadButton::SCE_PAD_BUTTON_SHARE, // Skyrim uses the touchpad for Back and leaves the Share button unused - kPS4_L2 = ScePad::ScePadButton::SCE_PAD_BUTTON_L2, // Skyrim uses trigger axis read instead of button press - kPS4_R2 = ScePad::ScePadButton::SCE_PAD_BUTTON_R2, // Skyrim uses trigger axis read instead of button press - kPS4_PSBtn = ScePad::ScePadButton::SCE_PAD_BUTTON_PLAYSTATION, // Playstation button + kPS4_Share = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_SHARE, // Skyrim uses the touchpad for Back and leaves the Share button unused + kPS4_L2 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_L2, // Skyrim uses trigger axis read instead of button press + kPS4_R2 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_R2, // Skyrim uses trigger axis read instead of button press + kPS4_PSBtn = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_PLAYSTATION, // Playstation button // arbitrary values // IDs meant to be used with ButtonEvent diff --git a/include/RE/B/BSParticleShaderCubeEmitter.h b/include/RE/B/BSParticleShaderCubeEmitter.h index e1a9dc615..c0d72e331 100644 --- a/include/RE/B/BSParticleShaderCubeEmitter.h +++ b/include/RE/B/BSParticleShaderCubeEmitter.h @@ -3,6 +3,8 @@ #include "RE/B/BSParticleShaderEmitter.h" #include "RE/N/NiPoint3.h" +#include "REX/W32/D3D.h" + namespace RE { class BSParticleShaderCubeEmitter : public BSParticleShaderEmitter @@ -16,18 +18,18 @@ namespace RE bool Generate(bool a_arg1, NiPoint3& a_arg2, NiPoint3& a_arg3) override; // 03 - { return false; } // members - alignas(0x10) DirectX::XMFLOAT4X4 occlusionProjection; // ED0 - NiPoint3 cameraOffsetVector; // F10 - NiPoint3 offsetVector; // F1C - NiPoint3 compositeOffsetVector; // F28 - NiPoint3 frameVelocityVector; // F34 - NiPoint3 windVelocity; // F40 - NiPoint3 gravityVelocity; // F4C - float rotation; // F58 - float rotationVelocity; // F5C - float cubeSize; // F60 - float density; // F64 - NiPoint3 instanceOffsets[10]; // F68 + alignas(0x10) REX::W32::XMFLOAT4X4 occlusionProjection; // ED0 + NiPoint3 cameraOffsetVector; // F10 + NiPoint3 offsetVector; // F1C + NiPoint3 compositeOffsetVector; // F28 + NiPoint3 frameVelocityVector; // F34 + NiPoint3 windVelocity; // F40 + NiPoint3 gravityVelocity; // F4C + float rotation; // F58 + float rotationVelocity; // F5C + float cubeSize; // F60 + float density; // F64 + NiPoint3 instanceOffsets[10]; // F68 }; static_assert(sizeof(BSParticleShaderCubeEmitter) == 0xFE0); } diff --git a/include/RE/B/BSSystemFile.h b/include/RE/B/BSSystemFile.h index 3a2209141..2045ec08f 100644 --- a/include/RE/B/BSSystemFile.h +++ b/include/RE/B/BSSystemFile.h @@ -1,5 +1,7 @@ #pragma once +#include "REX/W32/BASE.h" + namespace RE { namespace BSResource @@ -9,21 +11,20 @@ namespace RE public: struct Info { - public: // members - WinAPI::FILETIME accessTime; // 00 - WinAPI::FILETIME modifyTime; // 08 - WinAPI::FILETIME createTime; // 10 - std::uint64_t fileSize; // 18 + REX::W32::FILETIME accessTime; // 00 + REX::W32::FILETIME modifyTime; // 08 + REX::W32::FILETIME createTime; // 10 + std::uint64_t fileSize; // 18 }; static_assert(sizeof(Info) == 0x20); BSSystemFile(); // members - std::uint32_t flags{ 1 }; // 00 - std::uint32_t pad04{ 0 }; // 04 - void* file{ WinAPI::INVALID_HANDLE_VALUE }; // 08 + std::uint32_t flags{ 1 }; // 00 + std::uint32_t pad04{ 0 }; // 04 + void* file{ REX::W32::INVALID_HANDLE_VALUE }; // 08 }; static_assert(sizeof(BSSystemFile) == 0x10); } diff --git a/include/RE/B/BSThread.h b/include/RE/B/BSThread.h index 7f6ae9036..cc8aa0b78 100644 --- a/include/RE/B/BSThread.h +++ b/include/RE/B/BSThread.h @@ -1,5 +1,7 @@ #pragma once +#include "REX/W32/BASE.h" + namespace RE { class BSThread @@ -14,15 +16,15 @@ namespace RE virtual void Unk_02(void); // 02 - { return; } // members - WinAPI::CRITICAL_SECTION lock; // 08 - void* thread; // 30 - void* ownerThread; // 38 - std::uint32_t threadID; // 40 - std::uint32_t ownerThreadID; // 44 - bool initialized; // 48 - std::uint8_t pad49; // 49 - std::uint16_t pad4A; // 4A - std::uint32_t pad4C; // 4C + REX::W32::CRITICAL_SECTION lock; // 08 + void* thread; // 30 + void* ownerThread; // 38 + std::uint32_t threadID; // 40 + std::uint32_t ownerThreadID; // 44 + bool initialized; // 48 + std::uint8_t pad49; // 49 + std::uint16_t pad4A; // 4A + std::uint32_t pad4C; // 4C }; static_assert(sizeof(BSThread) == 0x50); } diff --git a/include/RE/B/BSWin32GamepadDevice.h b/include/RE/B/BSWin32GamepadDevice.h index 08d433c9b..9952bf19f 100644 --- a/include/RE/B/BSWin32GamepadDevice.h +++ b/include/RE/B/BSWin32GamepadDevice.h @@ -2,6 +2,8 @@ #include "RE/B/BSPCGamepadDeviceDelegate.h" +#include "REX/W32/XINPUT.h" + namespace RE { class BSWin32GamepadDevice : public BSPCGamepadDeviceDelegate @@ -15,20 +17,20 @@ namespace RE enum Key : std::uint32_t { // button masks for wButtons - kUp = XInput::XInputButton::XINPUT_GAMEPAD_DPAD_UP, // 0x0001 - kDown = XInput::XInputButton::XINPUT_GAMEPAD_DPAD_DOWN, // 0x0002 - kLeft = XInput::XInputButton::XINPUT_GAMEPAD_DPAD_LEFT, // 0x0004 - kRight = XInput::XInputButton::XINPUT_GAMEPAD_DPAD_RIGHT, // 0x0008 - kStart = XInput::XInputButton::XINPUT_GAMEPAD_START, // 0x0010 - kBack = XInput::XInputButton::XINPUT_GAMEPAD_BACK, // 0x0020 - kLeftThumb = XInput::XInputButton::XINPUT_GAMEPAD_LEFT_THUMB, // 0x0040 - kRightThumb = XInput::XInputButton::XINPUT_GAMEPAD_RIGHT_THUMB, // 0x0080 - kLeftShoulder = XInput::XInputButton::XINPUT_GAMEPAD_LEFT_SHOULDER, // 0x0100 - kRightShoulder = XInput::XInputButton::XINPUT_GAMEPAD_RIGHT_SHOULDER, // 0x0200 - kA = XInput::XInputButton::XINPUT_GAMEPAD_A, // 0x1000 - kB = XInput::XInputButton::XINPUT_GAMEPAD_B, // 0x2000 - kX = XInput::XInputButton::XINPUT_GAMEPAD_X, // 0x4000 - kY = XInput::XInputButton::XINPUT_GAMEPAD_Y, // 0x8000 + kUp = REX::W32::XINPUT_GAMEPAD_DPAD_UP, // 0x0001 + kDown = REX::W32::XINPUT_GAMEPAD_DPAD_DOWN, // 0x0002 + kLeft = REX::W32::XINPUT_GAMEPAD_DPAD_LEFT, // 0x0004 + kRight = REX::W32::XINPUT_GAMEPAD_DPAD_RIGHT, // 0x0008 + kStart = REX::W32::XINPUT_GAMEPAD_START, // 0x0010 + kBack = REX::W32::XINPUT_GAMEPAD_BACK, // 0x0020 + kLeftThumb = REX::W32::XINPUT_GAMEPAD_LEFT_THUMB, // 0x0040 + kRightThumb = REX::W32::XINPUT_GAMEPAD_RIGHT_THUMB, // 0x0080 + kLeftShoulder = REX::W32::XINPUT_GAMEPAD_LEFT_SHOULDER, // 0x0100 + kRightShoulder = REX::W32::XINPUT_GAMEPAD_RIGHT_SHOULDER, // 0x0200 + kA = REX::W32::XINPUT_GAMEPAD_A, // 0x1000 + kB = REX::W32::XINPUT_GAMEPAD_B, // 0x2000 + kX = REX::W32::XINPUT_GAMEPAD_X, // 0x4000 + kY = REX::W32::XINPUT_GAMEPAD_Y, // 0x8000 // arbitrary values // IDs meant to be used with ButtonEvent @@ -71,30 +73,30 @@ namespace RE // Returns the previous ButtonState of the gamepad ButtonState GetPreviousButtonState() const { - return stl::unrestricted_cast(previousState.Gamepad.wButtons & XInput::XINPUT_BUTTON_MASK); + return stl::unrestricted_cast(previousState.gamepad.buttons & REX::W32::XINPUT_GAMEPAD_BUTTON_MASK); } // Returns the current ButtonState of the gamepad ButtonState GetCurrentButtonState() const { - return stl::unrestricted_cast(currentState.Gamepad.wButtons & XInput::XINPUT_BUTTON_MASK); + return stl::unrestricted_cast(currentState.gamepad.buttons & REX::W32::XINPUT_GAMEPAD_BUTTON_MASK); } // members - XInput::XINPUT_STATE previousState; // 0D8 - float previousLT; // 0E8 - float previousRT; // 0EC - float previousLX; // 0F0 - float previousLY; // 0F4 - float previousRX; // 0F8 - float previousRY; // 0FC - XInput::XINPUT_STATE currentState; // 100 - float currentLT; // 110 - float currentRT; // 114 - float currentLX; // 118 - float currentLY; // 11C - float currentRX; // 120 - float currentRY; // 124 + REX::W32::XINPUT_STATE previousState; // 0D8 + float previousLT; // 0E8 + float previousRT; // 0EC + float previousLX; // 0F0 + float previousLY; // 0F4 + float previousRX; // 0F8 + float previousRY; // 0FC + REX::W32::XINPUT_STATE currentState; // 100 + float currentLT; // 110 + float currentRT; // 114 + float currentLX; // 118 + float currentLY; // 11C + float currentRX; // 120 + float currentRY; // 124 protected: friend class BSGamepadDeviceHandler; diff --git a/include/RE/B/BSWin32KeyboardDevice.h b/include/RE/B/BSWin32KeyboardDevice.h index f4690e892..54abacaa8 100644 --- a/include/RE/B/BSWin32KeyboardDevice.h +++ b/include/RE/B/BSWin32KeyboardDevice.h @@ -2,6 +2,8 @@ #include "RE/B/BSKeyboardDevice.h" +#include "REX/W32/DINPUT.h" + namespace RE { class BSWin32KeyboardDevice : public BSKeyboardDevice @@ -21,14 +23,14 @@ namespace RE void Unk_0A(void) override; // 0A - { return; } [[nodiscard]] bool IsPressed(std::uint32_t a_keyCode) const; - [[nodiscard]] Key RemapNumpadKey(DirectInput8::DIKey a_key); + [[nodiscard]] Key RemapNumpadKey(REX::W32::DIK a_key); // members - DirectInput8::IDirectInput8A* dInputDevice; // 070 - DirectInput8::DIDEVICEOBJECTDATA diObjData[10]; // 078 - std::uint8_t prevState[0x100]; // 168 - std::uint8_t curState[0x100]; // 268 - bool capsLockOn; // 368 + REX::W32::IDirectInput8A* dInputDevice; // 070 + REX::W32::DIDEVICEOBJECTDATA diObjData[10]; // 078 + std::uint8_t prevState[0x100]; // 168 + std::uint8_t curState[0x100]; // 268 + bool capsLockOn; // 368 protected: BSWin32KeyboardDevice(); diff --git a/include/RE/B/BSWin32MouseDevice.h b/include/RE/B/BSWin32MouseDevice.h index d771c6a6c..609ed4cc8 100644 --- a/include/RE/B/BSWin32MouseDevice.h +++ b/include/RE/B/BSWin32MouseDevice.h @@ -3,6 +3,8 @@ #include "RE/B/BSAtomic.h" #include "RE/B/BSMouseDevice.h" +#include "REX/W32/DINPUT.h" + namespace RE { class BSWin32MouseDevice : public BSMouseDevice @@ -39,11 +41,11 @@ namespace RE void Reinitialize(void) override; // 09 // members - DirectInput8::IDirectInputDevice8A* dInputDevice; // 78 - DirectInput8::DIMOUSESTATE2 dInputPrevState{}; // 80 - DirectInput8::DIMOUSESTATE2 dInputNextState{}; // 94 - bool notInitialized; // A8 - mutable BSSpinLock reinitializeLock; // AC + REX::W32::IDirectInputDevice8A* dInputDevice; // 78 + REX::W32::DIMOUSESTATE2 dInputPrevState{}; // 80 + REX::W32::DIMOUSESTATE2 dInputNextState{}; // 94 + bool notInitialized; // A8 + mutable BSSpinLock reinitializeLock; // AC protected: BSWin32MouseDevice(); diff --git a/include/RE/G/GAtomic.h b/include/RE/G/GAtomic.h index b276ce09c..80a1cb521 100644 --- a/include/RE/G/GAtomic.h +++ b/include/RE/G/GAtomic.h @@ -1,5 +1,7 @@ #pragma once +#include "REX/W32/BASE.h" + namespace RE { class GLock @@ -25,7 +27,7 @@ namespace RE void Unlock(); // members - WinAPI::CRITICAL_SECTION cs; // 00 + REX::W32::CRITICAL_SECTION cs; // 00 }; static_assert(sizeof(GLock) == 0x28); diff --git a/include/RE/I/Info.h b/include/RE/I/Info.h index c923666a9..dbcddd809 100644 --- a/include/RE/I/Info.h +++ b/include/RE/I/Info.h @@ -1,5 +1,7 @@ #pragma once +#include "REX/W32/BASE.h" + namespace RE { namespace BSResource @@ -8,9 +10,9 @@ namespace RE { public: // members - WinAPI::FILETIME modifyTime; // 00 - WinAPI::FILETIME createTime; // 08 - std::uint64_t fileSize; // 10 + REX::W32::FILETIME modifyTime; // 00 + REX::W32::FILETIME createTime; // 08 + std::uint64_t fileSize; // 10 }; static_assert(sizeof(Info) == 0x18); } diff --git a/include/RE/L/LooseFileLocation.h b/include/RE/L/LooseFileLocation.h index 794707e9b..5785f50f6 100644 --- a/include/RE/L/LooseFileLocation.h +++ b/include/RE/L/LooseFileLocation.h @@ -3,6 +3,8 @@ #include "RE/B/BSFixedString.h" #include "RE/L/Location.h" +#include "REX/W32/KERNEL32.h" + namespace RE { namespace BSResource @@ -11,11 +13,11 @@ namespace RE { public: // members - void* handle; // 000 - WinAPI::WIN32_FIND_DATAA findData; // 008 - char dirPath[WinAPI::MAX_PATH]; // 148 - ErrorCode lastError; // 24C - std::uint64_t entryPos; // 250 + void* handle; // 000 + REX::W32::WIN32_FIND_DATAA findData; // 008 + char dirPath[REX::W32::MAX_PATH]; // 148 + ErrorCode lastError; // 24C + std::uint64_t entryPos; // 250 }; static_assert(sizeof(BSSystemDir) == 0x258); diff --git a/include/RE/M/Main.h b/include/RE/M/Main.h index e5b6f5f54..872fc8218 100644 --- a/include/RE/M/Main.h +++ b/include/RE/M/Main.h @@ -4,6 +4,8 @@ #include "RE/B/BSTMessageQueue.h" #include "RE/S/ScrapHeap.h" +#include "REX/W32/BASE.h" + namespace RE { class NiNode; @@ -80,8 +82,8 @@ namespace RE bool reloadContent; // 015 bool freezeTime; // 016 bool freezeNextFrame; // 017 - WinAPI::HWND wnd; // 018 - WinAPI::HINSTANCE instance; // 020 + REX::W32::HWND wnd; // 018 + REX::W32::HINSTANCE instance; // 020 std::uint32_t threadID; // 028 std::uint32_t unk02C; // 02C std::uint64_t unk030; // 030 diff --git a/include/RE/M/MenuTopicManager.h b/include/RE/M/MenuTopicManager.h index 3365b7650..8ce2fd92e 100644 --- a/include/RE/M/MenuTopicManager.h +++ b/include/RE/M/MenuTopicManager.h @@ -7,6 +7,8 @@ #include "RE/B/BSTList.h" #include "RE/B/BSTSingleton.h" +#include "REX/W32/BASE.h" + namespace RE { class BGSDialogueBranch; @@ -68,7 +70,7 @@ namespace RE std::uint64_t unk28; // 28 TESTopicInfo* rootTopicInfo; // 30 Dialogue* lastSelectedDialogue; // 38 - WinAPI::CRITICAL_SECTION criticalSection; // 40 + REX::W32::CRITICAL_SECTION criticalSection; // 40 ObjectRefHandle speaker; // 68 ObjectRefHandle lastSpeaker; // 6C - used if the dialogue menu was closed but the NPC is still talking TESTopicInfo* currentTopicInfo; // 70 - only valid when the NPC is talking diff --git a/include/RE/N/NiSkinInstance.h b/include/RE/N/NiSkinInstance.h index ef70c76f0..70495ea15 100644 --- a/include/RE/N/NiSkinInstance.h +++ b/include/RE/N/NiSkinInstance.h @@ -3,6 +3,8 @@ #include "RE/N/NiObject.h" #include "RE/N/NiSmartPointer.h" +#include "REX/W32/BASE.h" + namespace RE { class NiAVObject; @@ -46,7 +48,7 @@ namespace RE void* boneMatrices; // 48 void* prevBoneMatrices; // 50 void* skinToWorldWorldToSkinMatrix; // 58 - WinAPI::CRITICAL_SECTION lock; // 60 + REX::W32::CRITICAL_SECTION lock; // 60 }; static_assert(sizeof(NiSkinInstance) == 0x88); } diff --git a/include/RE/N/NiStream.h b/include/RE/N/NiStream.h index 8e47fc7fb..d97e8e3f3 100644 --- a/include/RE/N/NiStream.h +++ b/include/RE/N/NiStream.h @@ -6,6 +6,8 @@ #include "RE/N/NiTArray.h" #include "RE/N/NiTPointerMap.h" +#include "REX/W32/BASE.h" + namespace RE { class NiBinaryStream; @@ -57,40 +59,40 @@ namespace RE virtual bool LoadObjectSizeTable(); // 17 // members - BSStreamHeader header; // 008 - BSTSmallArray groups; // 0D0 - std::uint32_t nifMaxVersion; // 100 - std::uint32_t nifMaxUserDefinedVersion; // 104 - char inputFilePath[WinAPI::MAX_PATH]; // 108 - std::uint16_t unk20C; // 20C - std::uint16_t unk20E; // 20E - std::uint64_t unk210; // 210 - NiTLargeObjectArray> objects; // 218 - NiTLargePrimitiveArray objectSizes; // 238 - NiTLargeObjectArray> topObjects; // 258 - NiTLargeObjectArray fixedStrings; // 278 - NiBinaryStream* iStr; // 298 - NiBinaryStream* oStr; // 2A0 - std::uint32_t linkIndex; // 2A8 - std::uint32_t linkBlockIndex; // 2AC - NiTPointerMap registerMap; // 2B0 - std::uint16_t niAVObjectFlags; // 2D0 - std::uint16_t niTimeControllerFlags; // 2D2 - std::uint16_t niPropertyFlags; // 2D4 - std::uint32_t unk2D8; // 2D8 - bool unk2DC; // 2DC - std::uint32_t load; // 2E0 - std::uint32_t link; // 2E4 - std::uint32_t postLink; // 2E8 - std::uint64_t unk2F0; // 2F0 - std::uint64_t unk2F8; // 2F8 - std::uint32_t unk300; // 300 - std::uint32_t unk304; // 304 - std::int32_t unk308; // 308 - char lastLoadedRTTI[WinAPI::MAX_PATH]; // 30C - std::uint32_t lastError; // 410 - char lastErrorMessage[WinAPI::MAX_PATH]; // 414 - char filePath[WinAPI::MAX_PATH]; // 518 + BSStreamHeader header; // 008 + BSTSmallArray groups; // 0D0 + std::uint32_t nifMaxVersion; // 100 + std::uint32_t nifMaxUserDefinedVersion; // 104 + char inputFilePath[REX::W32::MAX_PATH]; // 108 + std::uint16_t unk20C; // 20C + std::uint16_t unk20E; // 20E + std::uint64_t unk210; // 210 + NiTLargeObjectArray> objects; // 218 + NiTLargePrimitiveArray objectSizes; // 238 + NiTLargeObjectArray> topObjects; // 258 + NiTLargeObjectArray fixedStrings; // 278 + NiBinaryStream* iStr; // 298 + NiBinaryStream* oStr; // 2A0 + std::uint32_t linkIndex; // 2A8 + std::uint32_t linkBlockIndex; // 2AC + NiTPointerMap registerMap; // 2B0 + std::uint16_t niAVObjectFlags; // 2D0 + std::uint16_t niTimeControllerFlags; // 2D2 + std::uint16_t niPropertyFlags; // 2D4 + std::uint32_t unk2D8; // 2D8 + bool unk2DC; // 2DC + std::uint32_t load; // 2E0 + std::uint32_t link; // 2E4 + std::uint32_t postLink; // 2E8 + std::uint64_t unk2F0; // 2F0 + std::uint64_t unk2F8; // 2F8 + std::uint32_t unk300; // 300 + std::uint32_t unk304; // 304 + std::int32_t unk308; // 308 + char lastLoadedRTTI[REX::W32::MAX_PATH]; // 30C + std::uint32_t lastError; // 410 + char lastErrorMessage[REX::W32::MAX_PATH]; // 414 + char filePath[REX::W32::MAX_PATH]; // 518 }; static_assert(sizeof(NiStream) == 0x620); } diff --git a/include/RE/P/Precipitation.h b/include/RE/P/Precipitation.h index 99de06463..9b2555d7f 100644 --- a/include/RE/P/Precipitation.h +++ b/include/RE/P/Precipitation.h @@ -3,6 +3,8 @@ #include "RE/N/NiPoint3.h" #include "RE/N/NiSmartPointer.h" +#include "REX/W32/D3D.h" + namespace RE { class BSCullingProcess; @@ -19,11 +21,11 @@ namespace RE { public: // members - alignas(0x10) DirectX::XMFLOAT4X4 projection; // 00 - NiPointer camera; // 40 - NiPointer accumulator; // 48 - BSCullingProcess* cullingProcess; // 50 - std::uint64_t pad58; // 58 + alignas(0x10) REX::W32::XMFLOAT4X4 projection; // 00 + NiPointer camera; // 40 + NiPointer accumulator; // 48 + BSCullingProcess* cullingProcess; // 50 + std::uint64_t pad58; // 58 }; static_assert(sizeof(OcclusionMapData) == 0x60); diff --git a/include/RE/R/Renderer.h b/include/RE/R/Renderer.h index 0f4eec671..cdf42d58f 100644 --- a/include/RE/R/Renderer.h +++ b/include/RE/R/Renderer.h @@ -5,11 +5,8 @@ #include "RE/R/RenderTargetData.h" #include "RE/T/TextureFileFormat.h" -struct ID3D11Device; -struct ID3D11DeviceContext; -struct IDXGISwapChain; -struct ID3D11RenderTargetView1; -struct ID3D11ShaderResourceView1; +#include "REX/W32/D3D11_3.h" +#include "REX/W32/USER32.h" namespace RE { @@ -17,66 +14,62 @@ namespace RE { struct RendererWindow { - public: - // members - SKSE::WinAPI::HWND hWnd; // 00 - std::int32_t windowX; // 08 - std::int32_t windowY; // 0C - std::int32_t windowWidth; // 10 - std::int32_t windowHeight; // 14 - IDXGISwapChain* swapChain; // 18 - RENDER_TARGET swapChainRenderTarget; // 20 - std::uint32_t unk24; // 24 - std::uint64_t unk28; // 28 - ID3D11RenderTargetView1* renderView; // 30 - ID3D11ShaderResourceView1* resourceView; // 38 - std::uint64_t unk40; // 40 - std::uint64_t unk48; // 48 + REX::W32::HWND hWnd; // 00 + std::int32_t windowX; // 08 + std::int32_t windowY; // 0C + std::int32_t windowWidth; // 10 + std::int32_t windowHeight; // 14 + REX::W32::IDXGISwapChain* swapChain; // 18 + RENDER_TARGET swapChainRenderTarget; // 20 + std::uint32_t unk24; // 24 + std::uint64_t unk28; // 28 + REX::W32::ID3D11RenderTargetView1* renderView; // 30 + REX::W32::ID3D11ShaderResourceView1* resourceView; // 38 + std::uint64_t unk40; // 40 + std::uint64_t unk48; // 48 }; static_assert(sizeof(RendererWindow) == 0x50); struct RendererData { - public: - // members - std::uint32_t adapter; // 0000 - DirectX::DXGI_RATIONAL desiredRefreshRate; // 0004 - DirectX::DXGI_RATIONAL actualRefreshRate; // 000C - DirectX::DXGI_MODE_SCALING scaleMode; // 0014 - DirectX::DXGI_MODE_SCANLINE_ORDER scanlineOrdering; // 0018 - std::uint32_t isNotWindowed; // 001C - bool fullScreen; // 0020 - bool borderlessDisplay; // 0021 - bool readOnlyDepth; // 0022 - bool instantiated; // 0023 - bool requestedWindowSizeChange; // 0024 - std::uint32_t newWidth; // 0028 - std::uint32_t newHeight; // 002C - std::uint32_t presentInterval; // 0030 - ID3D11Device* forwarder; // 0038 - ID3D11DeviceContext* context; // 0040 - RendererWindow renderWindows[32]; // 0048 - RenderTargetData renderTargets[RENDER_TARGET::kTOTAL]; // 0A48 - DepthStencilData depthStencils[RENDER_TARGET_DEPTHSTENCIL::kTOTAL]; // 1FA8 - CubemapRenderTargetData cubemapRenderTargets[RENDER_TARGET_CUBEMAP::kTOTAL]; // 26C8 - Texture3DTargetData texture3DRenderTargets[RENDER_TARGET_3D::kTOTAL]; // 2708 - float clearColor[4]; // 2768 - std::uint8_t clearStencil; // 2778 - SKSE::WinAPI::CRITICAL_SECTION lock; // 2780 - const char* className; // 27A8 - SKSE::WinAPI::HINSTANCE hInstance; // 27B0 + std::uint32_t adapter; // 0000 + REX::W32::DXGI_RATIONAL desiredRefreshRate; // 0004 + REX::W32::DXGI_RATIONAL actualRefreshRate; // 000C + REX::W32::DXGI_MODE_SCALING scaleMode; // 0014 + REX::W32::DXGI_MODE_SCANLINE_ORDER scanlineOrdering; // 0018 + std::uint32_t isNotWindowed; // 001C + bool fullScreen; // 0020 + bool borderlessDisplay; // 0021 + bool readOnlyDepth; // 0022 + bool instantiated; // 0023 + bool requestedWindowSizeChange; // 0024 + std::uint32_t newWidth; // 0028 + std::uint32_t newHeight; // 002C + std::uint32_t presentInterval; // 0030 + REX::W32::ID3D11Device* forwarder; // 0038 + REX::W32::ID3D11DeviceContext* context; // 0040 + RendererWindow renderWindows[32]; // 0048 + RenderTargetData renderTargets[RENDER_TARGET::kTOTAL]; // 0A48 + DepthStencilData depthStencils[RENDER_TARGET_DEPTHSTENCIL::kTOTAL]; // 1FA8 + CubemapRenderTargetData cubemapRenderTargets[RENDER_TARGET_CUBEMAP::kTOTAL]; // 26C8 + Texture3DTargetData texture3DRenderTargets[RENDER_TARGET_3D::kTOTAL]; // 2708 + float clearColor[4]; // 2768 + std::uint8_t clearStencil; // 2778 + REX::W32::CRITICAL_SECTION lock; // 2780 + const char* className; // 27A8 + REX::W32::HINSTANCE hInstance; // 27B0 }; static_assert(offsetof(RendererData, lock) == 0x2780); struct RendererInitOSData { - WinAPI::HWND hwnd; // 00 - WinAPI::HINSTANCE instance; // 08 - WinAPI::WNDPROC windowProcFunction; // 10 - WinAPI::HICON icon; // 18 - const char* className; // 20 - uint32_t adapter; // 28 - uint32_t unk2C; // 2C + REX::W32::HWND hwnd; // 00 + REX::W32::HINSTANCE instance; // 08 + REX::W32::WNDPROC windowProcFunction; // 10 + REX::W32::HICON icon; // 18 + const char* className; // 20 + std::uint32_t adapter; // 28 + std::uint32_t unk2C; // 2C }; static_assert(sizeof(RendererInitOSData) == 0x30); @@ -105,29 +98,29 @@ namespace RE public: [[nodiscard]] static Renderer* GetSingleton() noexcept; - void CreateSwapChain(WinAPI::HWND* window, bool setCurrent); - void KillWindow(std::uint32_t windowID); + void CreateSwapChain(REX::W32::HWND* a_window, bool a_setCurrent); + void KillWindow(std::uint32_t a_windowID); void Lock(); void Unlock(); - void ResizeWindow(std::uint32_t windowID, std::uint32_t width, std::uint32_t height, bool fullscreen, bool borderless); - void RequestWindowResize(std::uint32_t width, std::uint32_t height); - void SetWindowPosition(std::uint32_t windowID, std::int32_t x, std::int32_t y); - void SetWindowActiveState(bool show); - void WindowSizeChanged(std::uint32_t windowID); - void ResetWindow(std::uint32_t windowID); - void UpdateViewPort(std::uint32_t a_unk, std::uint32_t b_unk, bool c_unk); + void ResizeWindow(std::uint32_t a_windowID, std::uint32_t a_width, std::uint32_t a_height, bool a_fullscreen, bool a_borderless); + void RequestWindowResize(std::uint32_t a_width, std::uint32_t a_height); + void SetWindowPosition(std::uint32_t a_windowID, std::int32_t a_x, std::int32_t a_y); + void SetWindowActiveState(bool a_show); + void WindowSizeChanged(std::uint32_t a_windowID); + void ResetWindow(std::uint32_t a_windowID); + void UpdateViewPort(std::uint32_t a_unk1, std::uint32_t a_unk2, bool a_unk3); [[nodiscard]] NiTexture::RendererData* CreateRenderTexture(std::uint32_t a_width, std::uint32_t a_height); void SaveRenderTargetToFile(RENDER_TARGET a_renderTarget, const char* a_filePath, TextureFileFormat a_textureFileFormat); - [[nodiscard]] static RendererData* GetRendererData(); - [[nodiscard]] static ScreenSize GetScreenSize(); - [[nodiscard]] static ID3D11Device* GetDevice(); - [[nodiscard]] static RendererWindow* GetCurrentRenderWindow(); + [[nodiscard]] static RendererData* GetRendererData(); + [[nodiscard]] static ScreenSize GetScreenSize(); + [[nodiscard]] static REX::W32::ID3D11Device* GetDevice(); + [[nodiscard]] static RendererWindow* GetCurrentRenderWindow(); private: void Begin(std::uint32_t windowID); - void Init(RendererInitOSData* a_data, ApplicationWindowProperties* windowProps, WinAPI::HWND window); + void Init(RendererInitOSData* a_data, ApplicationWindowProperties* a_windowProps, REX::W32::HWND a_window); void End(); void Shutdown(); diff --git a/include/RE/S/ScrapHeap.h b/include/RE/S/ScrapHeap.h index ad6b5be18..27fd6c7a7 100644 --- a/include/RE/S/ScrapHeap.h +++ b/include/RE/S/ScrapHeap.h @@ -2,6 +2,8 @@ #include "RE/I/IMemoryStore.h" +#include "REX/W32/KERNEL32.h" + namespace RE { class ScrapHeap : public IMemoryStore @@ -38,7 +40,7 @@ namespace RE }; static_assert(sizeof(FreeTreeNode) == 0x30); - ~ScrapHeap() override { WinAPI::VirtualFree(baseAddress, 0, WinAPI::MEM_RELEASE); } // 00 + ~ScrapHeap() override { REX::W32::VirtualFree(baseAddress, 0, REX::W32::MEM_RELEASE); } // 00 // override (IMemoryStore) std::size_t Size(void const* a_mem) const override { return *static_cast(a_mem) & ~(std::size_t{ 3 } << 62); } // 01 diff --git a/include/RE/T/TESFile.h b/include/RE/T/TESFile.h index 3548af341..353b80f55 100644 --- a/include/RE/T/TESFile.h +++ b/include/RE/T/TESFile.h @@ -6,6 +6,8 @@ #include "RE/F/FormTypes.h" #include "RE/N/NiFile.h" +#include "REX/W32/KERNEL32.h" + namespace RE { class BSFile; @@ -82,8 +84,8 @@ namespace RE TESBitArrayFile* formUserDataBitArray; // 040 TESBitArrayFile* formVersionBitArray; // 048 TESBitArrayFile* formIDBitArray; // 050 - char fileName[WinAPI::MAX_PATH]; // 058 - char path[WinAPI::MAX_PATH]; // 15C + char fileName[REX::W32::MAX_PATH]; // 058 + char path[REX::W32::MAX_PATH]; // 15C char* buffer; // 260 std::uint32_t bufferAllocSize; // 268 std::uint32_t firstCellOffset; // 26C @@ -107,7 +109,7 @@ namespace RE bool isBigEndian; // 2E9 std::uint8_t unk2EA; // 2EA std::uint8_t pad2EB; // 2EB - WinAPI::WIN32_FIND_DATAA fileData; // 2EC + REX::W32::WIN32_FIND_DATAA fileData; // 2EC float unk42C; // 42C std::uint32_t unk430; // 430 std::uint32_t flags; // 434 @@ -118,7 +120,7 @@ namespace RE std::uint32_t masterCount; // 460 std::uint32_t pad464; // 464 TESFile** masterPtrs; // 468 - WinAPI::FILETIME deletedFormTime; // 470 + REX::W32::FILETIME deletedFormTime; // 470 std::uint8_t compileIndex; // 478 std::uint8_t pad479; // 479 std::uint16_t smallFileCompileIndex; // 47A diff --git a/include/REL/Module.h b/include/REL/Module.h index 07f465e40..52b220b3a 100644 --- a/include/REL/Module.h +++ b/include/REL/Module.h @@ -2,6 +2,8 @@ #include "REL/Version.h" +#include "REX/W32/KERNEL32.h" + namespace REL { class Segment @@ -61,7 +63,7 @@ namespace REL [[nodiscard]] Segment segment(Segment::Name a_segment) const noexcept { return _segments[a_segment]; } - [[nodiscard]] void* pointer() const noexcept { return reinterpret_cast(base()); } + [[nodiscard]] REX::W32::HMODULE pointer() const noexcept { return reinterpret_cast(base()); } template [[nodiscard]] T* pointer() const noexcept @@ -73,7 +75,7 @@ namespace REL Module() { const auto getFilename = [&]() { - return WinAPI::GetEnvironmentVariable( + return REX::W32::GetEnvironmentVariableW( ENVIRONMENT.data(), _filename.data(), static_cast(_filename.size())); @@ -99,7 +101,7 @@ namespace REL void load() { - auto handle = WinAPI::GetModuleHandle(_filename.c_str()); + auto handle = REX::W32::GetModuleHandleW(_filename.c_str()); if (handle == nullptr) { stl::report_and_fail( std::format( @@ -131,13 +133,13 @@ namespace REL } static constexpr std::array SEGMENTS{ - std::make_pair(".text"sv, WinAPI::IMAGE_SCN_MEM_EXECUTE), + std::make_pair(".text"sv, REX::W32::IMAGE_SCN_MEM_EXECUTE), std::make_pair(".idata"sv, 0u), std::make_pair(".rdata"sv, 0u), std::make_pair(".data"sv, 0u), std::make_pair(".pdata"sv, 0u), std::make_pair(".tls"sv, 0u), - std::make_pair(".text"sv, WinAPI::IMAGE_SCN_MEM_WRITE), + std::make_pair(".text"sv, REX::W32::IMAGE_SCN_MEM_WRITE), std::make_pair(".gfids"sv, 0u) }; diff --git a/include/REL/Relocation.h b/include/REL/Relocation.h index b8edfe732..93e27e53d 100644 --- a/include/REL/Relocation.h +++ b/include/REL/Relocation.h @@ -1,5 +1,7 @@ #pragma once +#include "REX/W32/KERNEL32.h" + #define REL_MAKE_MEMBER_FUNCTION_POD_TYPE_HELPER_IMPL(a_nopropQual, a_propQual, ...) \ template < \ class R, \ @@ -188,23 +190,15 @@ namespace REL inline void safe_write(std::uintptr_t a_dst, const void* a_src, std::size_t a_count) { std::uint32_t old{ 0 }; - auto success = - WinAPI::VirtualProtect( - reinterpret_cast(a_dst), - a_count, - (WinAPI::PAGE_EXECUTE_READWRITE), - std::addressof(old)); - if (success != 0) { + bool success = REX::W32::VirtualProtect( + reinterpret_cast(a_dst), a_count, REX::W32::PAGE_EXECUTE_READWRITE, std::addressof(old)); + if (success) { std::memcpy(reinterpret_cast(a_dst), a_src, a_count); - success = - WinAPI::VirtualProtect( - reinterpret_cast(a_dst), - a_count, - old, - std::addressof(old)); + success = REX::W32::VirtualProtect( + reinterpret_cast(a_dst), a_count, old, std::addressof(old)); } - assert(success != 0); + assert(success); } template @@ -222,23 +216,15 @@ namespace REL inline void safe_fill(std::uintptr_t a_dst, std::uint8_t a_value, std::size_t a_count) { std::uint32_t old{ 0 }; - auto success = - WinAPI::VirtualProtect( - reinterpret_cast(a_dst), - a_count, - (WinAPI::PAGE_EXECUTE_READWRITE), - std::addressof(old)); - if (success != 0) { + bool success = REX::W32::VirtualProtect( + reinterpret_cast(a_dst), a_count, REX::W32::PAGE_EXECUTE_READWRITE, std::addressof(old)); + if (success) { std::fill_n(reinterpret_cast(a_dst), a_count, a_value); - success = - WinAPI::VirtualProtect( - reinterpret_cast(a_dst), - a_count, - old, - std::addressof(old)); + success = REX::W32::VirtualProtect( + reinterpret_cast(a_dst), a_count, old, std::addressof(old)); } - assert(success != 0); + assert(success); } template diff --git a/include/REL/Version.h b/include/REL/Version.h index b6f4ddd91..f72ebeb62 100644 --- a/include/REL/Version.h +++ b/include/REL/Version.h @@ -1,5 +1,7 @@ #pragma once +#include "REX/W32/VERSION.h" + namespace REL { class Version @@ -78,18 +80,18 @@ namespace REL [[nodiscard]] inline std::optional get_file_version(stl::zwstring a_filename) { std::uint32_t dummy; - std::vector buf(WinAPI::GetFileVersionInfoSize(a_filename.data(), std::addressof(dummy))); + std::vector buf(REX::W32::GetFileVersionInfoSizeW(a_filename.data(), std::addressof(dummy))); if (buf.empty()) { return std::nullopt; } - if (!WinAPI::GetFileVersionInfo(a_filename.data(), 0, static_cast(buf.size()), buf.data())) { + if (!REX::W32::GetFileVersionInfoW(a_filename.data(), 0, static_cast(buf.size()), buf.data())) { return std::nullopt; } void* verBuf{ nullptr }; std::uint32_t verLen{ 0 }; - if (!WinAPI::VerQueryValue(buf.data(), L"\\StringFileInfo\\040904B0\\ProductVersion", std::addressof(verBuf), std::addressof(verLen))) { + if (!REX::W32::VerQueryValueW(buf.data(), L"\\StringFileInfo\\040904B0\\ProductVersion", std::addressof(verBuf), std::addressof(verLen))) { return std::nullopt; } diff --git a/include/REX/PS4.h b/include/REX/PS4.h new file mode 100644 index 000000000..8d7b0f3f5 --- /dev/null +++ b/include/REX/PS4.h @@ -0,0 +1,3 @@ +#pragma once + +#include "REX/PS4/SCEPAD.h" diff --git a/include/REX/PS4/SCEPAD.h b/include/REX/PS4/SCEPAD.h new file mode 100644 index 000000000..dd8c8ea88 --- /dev/null +++ b/include/REX/PS4/SCEPAD.h @@ -0,0 +1,27 @@ +#pragma once + +namespace REX::PS4 +{ + enum SCE_PAD_BUTTON : std::uint32_t + { + SCE_PAD_BUTTON_SHARE = 0x00000001, + SCE_PAD_BUTTON_L3 = 0x00000002, + SCE_PAD_BUTTON_R3 = 0x00000004, + SCE_PAD_BUTTON_OPTIONS = 0x00000008, + SCE_PAD_BUTTON_UP = 0x00000010, + SCE_PAD_BUTTON_RIGHT = 0x00000020, + SCE_PAD_BUTTON_DOWN = 0x00000040, + SCE_PAD_BUTTON_LEFT = 0x00000080, + SCE_PAD_BUTTON_L2 = 0x00000100, + SCE_PAD_BUTTON_R2 = 0x00000200, + SCE_PAD_BUTTON_L1 = 0x00000400, + SCE_PAD_BUTTON_R1 = 0x00000800, + SCE_PAD_BUTTON_TRIANGLE = 0x00001000, + SCE_PAD_BUTTON_CIRCLE = 0x00002000, + SCE_PAD_BUTTON_CROSS = 0x00004000, + SCE_PAD_BUTTON_SQUARE = 0x00008000, + SCE_PAD_BUTTON_PLAYSTATION = 0x00010000, + SCE_PAD_BUTTON_TOUCH_PAD = 0x00100000, + SCE_PAD_BUTTON_INTERCEPTED = 0x80000000, + }; +} diff --git a/include/REX/W32.h b/include/REX/W32.h new file mode 100644 index 000000000..6deadaa11 --- /dev/null +++ b/include/REX/W32.h @@ -0,0 +1,27 @@ +#pragma once + +#include "REX/W32/BASE.h" + +#include "REX/W32/ADVAPI32.h" +#include "REX/W32/COM.h" +#include "REX/W32/COMPTR.h" +#include "REX/W32/D3D.h" +#include "REX/W32/D3D11.h" +#include "REX/W32/D3D11_1.h" +#include "REX/W32/D3D11_2.h" +#include "REX/W32/D3D11_3.h" +#include "REX/W32/D3D11_4.h" +#include "REX/W32/D3DCOMPILER.h" +#include "REX/W32/DBGHELP.h" +#include "REX/W32/DINPUT.h" +#include "REX/W32/DXGI.h" +#include "REX/W32/DXGI_2.h" +#include "REX/W32/DXGI_3.h" +#include "REX/W32/DXGI_4.h" +#include "REX/W32/DXGI_5.h" +#include "REX/W32/DXGI_6.h" +#include "REX/W32/KERNEL32.h" +#include "REX/W32/OLE32.h" +#include "REX/W32/USER32.h" +#include "REX/W32/VERSION.h" +#include "REX/W32/XINPUT.h" diff --git a/include/REX/W32/ADVAPI32.h b/include/REX/W32/ADVAPI32.h new file mode 100644 index 000000000..cde432247 --- /dev/null +++ b/include/REX/W32/ADVAPI32.h @@ -0,0 +1,16 @@ +#pragma once + +#include "REX/W32/BASE.h" + +namespace REX::W32 +{ + inline auto HKEY_CLASSES_ROOT{ reinterpret_cast(0x80000000ull) }; + inline auto HKEY_CURRENT_USER{ reinterpret_cast(0x80000001ull) }; + inline auto HKEY_LOCAL_MACHINE{ reinterpret_cast(0x80000002ull) }; +} + +namespace REX::W32 +{ + std::int32_t RegGetValueA(HKEY a_key, const char* a_subKey, const char* a_value, std::uint32_t a_flags, std::uint32_t* a_type, void* a_data, std::uint32_t* a_dataLen); + std::int32_t RegGetValueW(HKEY a_key, const wchar_t* a_subKey, const wchar_t* a_value, std::uint32_t a_flags, std::uint32_t* a_type, void* a_data, std::uint32_t* a_dataLen); +} diff --git a/include/REX/W32/BASE.h b/include/REX/W32/BASE.h new file mode 100644 index 000000000..1da8accaf --- /dev/null +++ b/include/REX/W32/BASE.h @@ -0,0 +1,188 @@ +#pragma once + +#ifdef _INC_WINAPIFAMILY +#error Windows API detected. Please move any Windows API includes after CommonLib, or remove them. +#endif + +#define REX_W32_IMPORT(a_ret, a_name, ...)\ + extern "C" __declspec(dllimport) a_ret __stdcall W32_IMPL_##a_name(...) noexcept;\ + __pragma(comment(linker, "/alternatename:__imp_W32_IMPL_" #a_name "=__imp_" #a_name)) + +namespace REX::W32 +{ + using BOOL = std::int32_t; + using HANDLE = void*; + using HBITMAP = struct HBITMAP__*; + using HBRUSH = struct HBRUSH__*; + using HCURSOR = struct HCURSOR__*; + using HDC = struct HDC__*; + using HFONT = struct HFONT__*; + using HICON = struct HICON__*; + using HINSTANCE = struct HINSTANCE__*; + using HKEY = struct HKEY__*; + using HMENU = struct HMENU__*; + using HMODULE = HINSTANCE; + using HMONITOR = struct HMONITOR__*; + using HPALETTE = struct HPALETTE__*; + using HPEN = struct HPEN__*; + using HSTRING = struct HSTRING__*; + using HWND = struct HWND__*; + + // general constants + inline const auto INVALID_HANDLE_VALUE{ reinterpret_cast(static_cast(-1)) }; + inline constexpr auto MAX_PATH{ 260u }; +} + +namespace REX::W32 +{ + struct FILETIME + { + constexpr FILETIME() noexcept = default; + + constexpr FILETIME(std::uint64_t a_value) noexcept + { + *this = std::bit_cast(a_value); + } + + constexpr operator std::uint64_t() const noexcept + { + return std::bit_cast(*this); + } + + std::uint32_t lo; // 00 + std::uint32_t hi; // 04 + }; + static_assert(sizeof(FILETIME) == 0x8); +} + +namespace REX::W32 +{ + struct GUID + { + constexpr GUID() noexcept = default; + + constexpr GUID(const std::uint32_t a_data1, std::uint16_t const a_data2, const std::uint16_t a_data3, const std::array& a_data4) noexcept : + data1(a_data1), data2(a_data2), data3(a_data3), data4{ a_data4[0], a_data4[1], a_data4[2], a_data4[3], a_data4[4], a_data4[5], a_data4[6], a_data4[7] } + {} + + friend bool operator==(const GUID& a_lhs, const GUID& a_rhs) noexcept + { + return std::memcmp(&a_lhs, &a_rhs, sizeof(a_lhs)) == 0; + } + + friend bool operator!=(const GUID& a_lhs, const GUID& a_rhs) noexcept + { + return !(a_lhs == a_rhs); + } + + std::uint32_t data1; // 00 + std::uint16_t data2; // 04 + std::uint16_t data3; // 08 + std::uint8_t data4[8]; // 10 + }; + static_assert(sizeof(GUID) == 0x10); + + using UUID = GUID; + using IID = GUID; +} + +namespace REX::W32 +{ + struct HRESULT + { + constexpr HRESULT() noexcept = default; + + constexpr HRESULT(const std::int32_t a_hr) noexcept : + value(a_hr) + {} + + constexpr operator bool() const noexcept + { + return value >= 0; + } + + constexpr operator std::int32_t() const noexcept + { + return value; + } + + std::int32_t value; + }; + static_assert(sizeof(HRESULT) == 0x4); +} + +namespace REX::W32 +{ + struct POINT + { + constexpr POINT() noexcept = default; + + constexpr POINT(std::int32_t a_x, std::int32_t a_y) noexcept : + x(a_x), y(a_y) + {} + + std::int32_t x; // 00 + std::int32_t y; // 04 + }; + static_assert(sizeof(POINT) == 0x8); +} + +namespace REX::W32 +{ + struct RECT + { + constexpr RECT() noexcept = default; + + constexpr RECT(const std::int32_t a_x1, const std::int32_t a_y1, const std::int32_t a_x2, const std::int32_t a_y2) noexcept : + x1(a_x1), y1(a_y1), x2(a_x2), y2(a_y2) + {} + + std::int32_t x1; // 00 + std::int32_t y1; // 04 + std::int32_t x2; // 08 + std::int32_t y2; // 10 + }; + static_assert(sizeof(RECT) == 0x10); +} + +namespace REX::W32 +{ + struct SIZE + { + std::int32_t x; // 00 + std::int32_t y; // 04 + }; + static_assert(sizeof(SIZE) == 0x8); +} + +namespace REX::W32 +{ + struct CRITICAL_SECTION + { + void* debugInfo; // 00 + std::int32_t lockCount; // 08 + std::int32_t recursionCount; // 0C + HANDLE owningThread; // 10 + HANDLE lockSemaphore; // 18 + std::uintptr_t spinCount; // 20 + }; + static_assert(sizeof(CRITICAL_SECTION) == 0x28); + + struct SECURITY_ATTRIBUTES + { + std::uint32_t length; // 00 + void* securityDescriptor; // 04 + BOOL inheritHandle; // 0C + }; + static_assert(sizeof(SECURITY_ATTRIBUTES) == 0x18); + + union ULARGE_INTEGER + { + struct + { + std::uint32_t lo; + std::uint32_t hi; + }; + std::uint64_t value; + }; +} diff --git a/include/REX/W32/COM.h b/include/REX/W32/COM.h new file mode 100644 index 000000000..414801252 --- /dev/null +++ b/include/REX/W32/COM.h @@ -0,0 +1,25 @@ +#pragma once + +#include "BASE.h" + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("00000000-0000-0000-c000-000000000046")) + IUnknown + { + virtual HRESULT QueryInterface(const IID& a_iid, void** a_object) = 0; + virtual std::uint32_t AddRef() = 0; + virtual std::uint32_t Release() = 0; + + template + HRESULT QueryInterface(T** a_object) + { + return QueryInterface(__uuidof(T), static_cast(a_object)); + } + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_IUnknown{ 0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }; +} diff --git a/include/REX/W32/COMPTR.h b/include/REX/W32/COMPTR.h new file mode 100644 index 000000000..b80769fa1 --- /dev/null +++ b/include/REX/W32/COMPTR.h @@ -0,0 +1,196 @@ +#pragma once + +#include "BASE.h" + +namespace REX::W32 +{ + // based on Microsoft::WRL::ComPtr + template + struct ComPtr + { + constexpr ComPtr() noexcept = default; + constexpr ComPtr(std::nullptr_t) noexcept {} + + ComPtr(const ComPtr& a_other) noexcept : + _ptr(a_other._ptr) + { + TryAddRef(); + } + + template + ComPtr(U* a_other) noexcept : + _ptr(a_other) + { + TryAddRef(); + } + + ~ComPtr() noexcept + { + TryRelease(); + } + + ComPtr& operator=(std::nullptr_t) noexcept + { + TryRelease(); + return *this; + } + + ComPtr& operator=(T* a_other) noexcept + { + if (_ptr != a_other) + ComPtr(a_other).Swap(*this); + + return *this; + } + + template + ComPtr& operator=(U* a_other) noexcept + { + ComPtr(a_other).Swap(*this); + return *this; + } + + ComPtr& operator=(const ComPtr& a_other) noexcept + { + if (_ptr != a_other._ptr) + ComPtr(a_other).Swap(*this); + + return *this; + } + + template + ComPtr& operator=(const ComPtr& a_other) noexcept + { + ComPtr(a_other).Swap(*this); + return *this; + } + + ComPtr& operator=(ComPtr&& a_other) noexcept + { + ComPtr(static_cast(a_other)).Swap(*this); + return *this; + } + + template + ComPtr& operator=(ComPtr&& a_other) noexcept + { + ComPtr(static_cast&&>(a_other)).Swap(*this); + return *this; + } + + T* operator->() const noexcept + { + return _ptr; + } + + void Attach(T* a_other) noexcept + { + if (_ptr != nullptr) { + [[maybe_unused]] auto ref = _ptr->Release(); + assert((ref != 0) || (_ptr != a_other)); + } + + _ptr = a_other; + } + + T* Detach() noexcept + { + T* ptr = _ptr; + _ptr = nullptr; + return ptr; + } + + T* Get() const noexcept + { + return _ptr; + } + + T** GetAddressOf() noexcept + { + return &_ptr; + } + + T* const* GetAddressOf() const noexcept + { + return &_ptr; + } + + T** ReleaseAndGetAddressOf() noexcept + { + TryRelease(); + return &_ptr; + } + + std::uint32_t Reset() noexcept + { + return TryRelease(); + } + + void Swap(ComPtr& a_other) noexcept + { + T* ptr = _ptr; + _ptr = a_other._ptr; + a_other._ptr = ptr; + } + + void Swap(ComPtr&& a_other) noexcept + { + T* ptr = _ptr; + _ptr = a_other._ptr; + a_other._ptr = ptr; + } + + template + HRESULT As(ComPtr* a_ptr) const noexcept + { + return _ptr->QueryInterface(__uuidof(U), reinterpret_cast(a_ptr->ReleaseAndGetAddressOf())); + } + + template + HRESULT AsIID(const IID& a_iid, ComPtr* a_ptr) const noexcept + { + return _ptr->QueryInterface(a_iid, reinterpret_cast(a_ptr->ReleaseAndGetAddressOf())); + } + + HRESULT CopyTo(const IID& a_iid, void** a_ptr) const noexcept + { + return _ptr->QueryInterface(a_iid, a_ptr); + } + + HRESULT CopyTo(T** a_ptr) const noexcept + { + TryAddRef(); + *a_ptr = _ptr; + return 0; + } + + template + HRESULT CopyTo(U** a_ptr) const noexcept + { + return _ptr->QueryInterface(__uuidof(U), reinterpret_cast(a_ptr)); + } + + protected: + template + friend struct ComPtr; + + void TryAddRef() const noexcept + { + if (_ptr) + _ptr->AddRef(); + } + + std::uint32_t TryRelease() noexcept + { + T* ptr = _ptr; + if (ptr) { + _ptr = nullptr; + return ptr->Release(); + } + + return 0; + } + + T* _ptr{ nullptr }; + }; +} diff --git a/include/REX/W32/D3D.h b/include/REX/W32/D3D.h new file mode 100644 index 000000000..9c60bcad6 --- /dev/null +++ b/include/REX/W32/D3D.h @@ -0,0 +1,736 @@ +#pragma once + +#include "DXGI.h" + +namespace REX::W32 +{ + struct ID3DBlob; + struct ID3DDestructionNotifier; + struct ID3DInclude; +} + +namespace REX::W32 +{ + enum D3D_CBUFFER_TYPE + { + D3D_CT_CBUFFER = 0, + D3D_CT_TBUFFER = (D3D_CT_CBUFFER + 1), + D3D_CT_INTERFACE_POINTERS = (D3D_CT_TBUFFER + 1), + D3D_CT_RESOURCE_BIND_INFO = (D3D_CT_INTERFACE_POINTERS + 1), + D3D10_CT_CBUFFER = D3D_CT_CBUFFER, + D3D10_CT_TBUFFER = D3D_CT_TBUFFER, + D3D11_CT_CBUFFER = D3D_CT_CBUFFER, + D3D11_CT_TBUFFER = D3D_CT_TBUFFER, + D3D11_CT_INTERFACE_POINTERS = D3D_CT_INTERFACE_POINTERS, + D3D11_CT_RESOURCE_BIND_INFO = D3D_CT_RESOURCE_BIND_INFO, + }; + + enum D3D_DRIVER_TYPE + { + D3D_DRIVER_TYPE_UNKNOWN = 0, + D3D_DRIVER_TYPE_HARDWARE = (D3D_DRIVER_TYPE_UNKNOWN + 1), + D3D_DRIVER_TYPE_REFERENCE = (D3D_DRIVER_TYPE_HARDWARE + 1), + D3D_DRIVER_TYPE_NULL = (D3D_DRIVER_TYPE_REFERENCE + 1), + D3D_DRIVER_TYPE_SOFTWARE = (D3D_DRIVER_TYPE_NULL + 1), + D3D_DRIVER_TYPE_WARP = (D3D_DRIVER_TYPE_SOFTWARE + 1), + }; + + enum D3D_FEATURE_LEVEL + { + D3D_FEATURE_LEVEL_1_0_CORE = 0x1000, + D3D_FEATURE_LEVEL_9_1 = 0x9100, + D3D_FEATURE_LEVEL_9_2 = 0x9200, + D3D_FEATURE_LEVEL_9_3 = 0x9300, + D3D_FEATURE_LEVEL_10_0 = 0xA000, + D3D_FEATURE_LEVEL_10_1 = 0xA100, + D3D_FEATURE_LEVEL_11_0 = 0xB000, + D3D_FEATURE_LEVEL_11_1 = 0xB100, + D3D_FEATURE_LEVEL_12_0 = 0xC000, + D3D_FEATURE_LEVEL_12_1 = 0xC100, + D3D_FEATURE_LEVEL_12_2 = 0xC200, + }; + + enum D3D_INCLUDE_TYPE + { + D3D_INCLUDE_LOCAL = 0, + D3D_INCLUDE_SYSTEM = (D3D_INCLUDE_LOCAL + 1), + D3D10_INCLUDE_LOCAL = D3D_INCLUDE_LOCAL, + D3D10_INCLUDE_SYSTEM = D3D_INCLUDE_SYSTEM, + D3D_INCLUDE_FORCE_DWORD = 0x7FFFFFFF, + }; + + enum D3D_INTERPOLATION_MODE + { + D3D_INTERPOLATION_UNDEFINED = 0, + D3D_INTERPOLATION_CONSTANT = 1, + D3D_INTERPOLATION_LINEAR = 2, + D3D_INTERPOLATION_LINEAR_CENTROID = 3, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE = 4, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE_CENTROID = 5, + D3D_INTERPOLATION_LINEAR_SAMPLE = 6, + D3D_INTERPOLATION_LINEAR_NOPERSPECTIVE_SAMPLE = 7, + }; + + enum D3D_MIN_PRECISION + { + D3D_MIN_PRECISION_DEFAULT = 0, + D3D_MIN_PRECISION_FLOAT_16 = 1, + D3D_MIN_PRECISION_FLOAT_2_8 = 2, + D3D_MIN_PRECISION_RESERVED = 3, + D3D_MIN_PRECISION_SINT_16 = 4, + D3D_MIN_PRECISION_UINT_16 = 5, + D3D_MIN_PRECISION_ANY_16 = 0xF0, + D3D_MIN_PRECISION_ANY_10 = 0xF1, + }; + + enum D3D_NAME + { + D3D_NAME_UNDEFINED = 0, + D3D_NAME_POSITION = 1, + D3D_NAME_CLIP_DISTANCE = 2, + D3D_NAME_CULL_DISTANCE = 3, + D3D_NAME_RENDER_TARGET_ARRAY_INDEX = 4, + D3D_NAME_VIEWPORT_ARRAY_INDEX = 5, + D3D_NAME_VERTEX_ID = 6, + D3D_NAME_PRIMITIVE_ID = 7, + D3D_NAME_INSTANCE_ID = 8, + D3D_NAME_IS_FRONT_FACE = 9, + D3D_NAME_SAMPLE_INDEX = 10, + D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR = 11, + D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR = 12, + D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR = 13, + D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR = 14, + D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR = 15, + D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR = 16, + D3D_NAME_BARYCENTRICS = 23, + D3D_NAME_SHADINGRATE = 24, + D3D_NAME_CULLPRIMITIVE = 25, + D3D_NAME_TARGET = 64, + D3D_NAME_DEPTH = 65, + D3D_NAME_COVERAGE = 66, + D3D_NAME_DEPTH_GREATER_EQUAL = 67, + D3D_NAME_DEPTH_LESS_EQUAL = 68, + D3D_NAME_STENCIL_REF = 69, + D3D_NAME_INNER_COVERAGE = 70, + D3D10_NAME_UNDEFINED = D3D_NAME_UNDEFINED, + D3D10_NAME_POSITION = D3D_NAME_POSITION, + D3D10_NAME_CLIP_DISTANCE = D3D_NAME_CLIP_DISTANCE, + D3D10_NAME_CULL_DISTANCE = D3D_NAME_CULL_DISTANCE, + D3D10_NAME_RENDER_TARGET_ARRAY_INDEX = D3D_NAME_RENDER_TARGET_ARRAY_INDEX, + D3D10_NAME_VIEWPORT_ARRAY_INDEX = D3D_NAME_VIEWPORT_ARRAY_INDEX, + D3D10_NAME_VERTEX_ID = D3D_NAME_VERTEX_ID, + D3D10_NAME_PRIMITIVE_ID = D3D_NAME_PRIMITIVE_ID, + D3D10_NAME_INSTANCE_ID = D3D_NAME_INSTANCE_ID, + D3D10_NAME_IS_FRONT_FACE = D3D_NAME_IS_FRONT_FACE, + D3D10_NAME_SAMPLE_INDEX = D3D_NAME_SAMPLE_INDEX, + D3D10_NAME_TARGET = D3D_NAME_TARGET, + D3D10_NAME_DEPTH = D3D_NAME_DEPTH, + D3D10_NAME_COVERAGE = D3D_NAME_COVERAGE, + D3D11_NAME_FINAL_QUAD_EDGE_TESSFACTOR = D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, + D3D11_NAME_FINAL_QUAD_INSIDE_TESSFACTOR = D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR, + D3D11_NAME_FINAL_TRI_EDGE_TESSFACTOR = D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR, + D3D11_NAME_FINAL_TRI_INSIDE_TESSFACTOR = D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR, + D3D11_NAME_FINAL_LINE_DETAIL_TESSFACTOR = D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR, + D3D11_NAME_FINAL_LINE_DENSITY_TESSFACTOR = D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR, + D3D11_NAME_DEPTH_GREATER_EQUAL = D3D_NAME_DEPTH_GREATER_EQUAL, + D3D11_NAME_DEPTH_LESS_EQUAL = D3D_NAME_DEPTH_LESS_EQUAL, + D3D11_NAME_STENCIL_REF = D3D_NAME_STENCIL_REF, + D3D11_NAME_INNER_COVERAGE = D3D_NAME_INNER_COVERAGE, + D3D12_NAME_BARYCENTRICS = D3D_NAME_BARYCENTRICS, + D3D12_NAME_SHADINGRATE = D3D_NAME_SHADINGRATE, + D3D12_NAME_CULLPRIMITIVE = D3D_NAME_CULLPRIMITIVE, + }; + + enum D3D_PARAMETER_FLAGS + { + D3D_PF_NONE = 0, + D3D_PF_IN = 0x1, + D3D_PF_OUT = 0x2, + D3D_PF_FORCE_DWORD = 0x7FFFFFFF, + }; + + enum D3D_PRIMITIVE + { + D3D_PRIMITIVE_UNDEFINED = 0, + D3D_PRIMITIVE_POINT = 1, + D3D_PRIMITIVE_LINE = 2, + D3D_PRIMITIVE_TRIANGLE = 3, + D3D_PRIMITIVE_LINE_ADJ = 6, + D3D_PRIMITIVE_TRIANGLE_ADJ = 7, + D3D_PRIMITIVE_1_CONTROL_POINT_PATCH = 8, + D3D_PRIMITIVE_2_CONTROL_POINT_PATCH = 9, + D3D_PRIMITIVE_3_CONTROL_POINT_PATCH = 10, + D3D_PRIMITIVE_4_CONTROL_POINT_PATCH = 11, + D3D_PRIMITIVE_5_CONTROL_POINT_PATCH = 12, + D3D_PRIMITIVE_6_CONTROL_POINT_PATCH = 13, + D3D_PRIMITIVE_7_CONTROL_POINT_PATCH = 14, + D3D_PRIMITIVE_8_CONTROL_POINT_PATCH = 15, + D3D_PRIMITIVE_9_CONTROL_POINT_PATCH = 16, + D3D_PRIMITIVE_10_CONTROL_POINT_PATCH = 17, + D3D_PRIMITIVE_11_CONTROL_POINT_PATCH = 18, + D3D_PRIMITIVE_12_CONTROL_POINT_PATCH = 19, + D3D_PRIMITIVE_13_CONTROL_POINT_PATCH = 20, + D3D_PRIMITIVE_14_CONTROL_POINT_PATCH = 21, + D3D_PRIMITIVE_15_CONTROL_POINT_PATCH = 22, + D3D_PRIMITIVE_16_CONTROL_POINT_PATCH = 23, + D3D_PRIMITIVE_17_CONTROL_POINT_PATCH = 24, + D3D_PRIMITIVE_18_CONTROL_POINT_PATCH = 25, + D3D_PRIMITIVE_19_CONTROL_POINT_PATCH = 26, + D3D_PRIMITIVE_20_CONTROL_POINT_PATCH = 27, + D3D_PRIMITIVE_21_CONTROL_POINT_PATCH = 28, + D3D_PRIMITIVE_22_CONTROL_POINT_PATCH = 29, + D3D_PRIMITIVE_23_CONTROL_POINT_PATCH = 30, + D3D_PRIMITIVE_24_CONTROL_POINT_PATCH = 31, + D3D_PRIMITIVE_25_CONTROL_POINT_PATCH = 32, + D3D_PRIMITIVE_26_CONTROL_POINT_PATCH = 33, + D3D_PRIMITIVE_27_CONTROL_POINT_PATCH = 34, + D3D_PRIMITIVE_28_CONTROL_POINT_PATCH = 35, + D3D_PRIMITIVE_29_CONTROL_POINT_PATCH = 36, + D3D_PRIMITIVE_30_CONTROL_POINT_PATCH = 37, + D3D_PRIMITIVE_31_CONTROL_POINT_PATCH = 38, + D3D_PRIMITIVE_32_CONTROL_POINT_PATCH = 39, + D3D10_PRIMITIVE_UNDEFINED = D3D_PRIMITIVE_UNDEFINED, + D3D10_PRIMITIVE_POINT = D3D_PRIMITIVE_POINT, + D3D10_PRIMITIVE_LINE = D3D_PRIMITIVE_LINE, + D3D10_PRIMITIVE_TRIANGLE = D3D_PRIMITIVE_TRIANGLE, + D3D10_PRIMITIVE_LINE_ADJ = D3D_PRIMITIVE_LINE_ADJ, + D3D10_PRIMITIVE_TRIANGLE_ADJ = D3D_PRIMITIVE_TRIANGLE_ADJ, + D3D11_PRIMITIVE_UNDEFINED = D3D_PRIMITIVE_UNDEFINED, + D3D11_PRIMITIVE_POINT = D3D_PRIMITIVE_POINT, + D3D11_PRIMITIVE_LINE = D3D_PRIMITIVE_LINE, + D3D11_PRIMITIVE_TRIANGLE = D3D_PRIMITIVE_TRIANGLE, + D3D11_PRIMITIVE_LINE_ADJ = D3D_PRIMITIVE_LINE_ADJ, + D3D11_PRIMITIVE_TRIANGLE_ADJ = D3D_PRIMITIVE_TRIANGLE_ADJ, + D3D11_PRIMITIVE_1_CONTROL_POINT_PATCH = D3D_PRIMITIVE_1_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_2_CONTROL_POINT_PATCH = D3D_PRIMITIVE_2_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_3_CONTROL_POINT_PATCH = D3D_PRIMITIVE_3_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_4_CONTROL_POINT_PATCH = D3D_PRIMITIVE_4_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_5_CONTROL_POINT_PATCH = D3D_PRIMITIVE_5_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_6_CONTROL_POINT_PATCH = D3D_PRIMITIVE_6_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_7_CONTROL_POINT_PATCH = D3D_PRIMITIVE_7_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_8_CONTROL_POINT_PATCH = D3D_PRIMITIVE_8_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_9_CONTROL_POINT_PATCH = D3D_PRIMITIVE_9_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_10_CONTROL_POINT_PATCH = D3D_PRIMITIVE_10_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_11_CONTROL_POINT_PATCH = D3D_PRIMITIVE_11_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_12_CONTROL_POINT_PATCH = D3D_PRIMITIVE_12_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_13_CONTROL_POINT_PATCH = D3D_PRIMITIVE_13_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_14_CONTROL_POINT_PATCH = D3D_PRIMITIVE_14_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_15_CONTROL_POINT_PATCH = D3D_PRIMITIVE_15_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_16_CONTROL_POINT_PATCH = D3D_PRIMITIVE_16_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_17_CONTROL_POINT_PATCH = D3D_PRIMITIVE_17_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_18_CONTROL_POINT_PATCH = D3D_PRIMITIVE_18_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_19_CONTROL_POINT_PATCH = D3D_PRIMITIVE_19_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_20_CONTROL_POINT_PATCH = D3D_PRIMITIVE_20_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_21_CONTROL_POINT_PATCH = D3D_PRIMITIVE_21_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_22_CONTROL_POINT_PATCH = D3D_PRIMITIVE_22_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_23_CONTROL_POINT_PATCH = D3D_PRIMITIVE_23_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_24_CONTROL_POINT_PATCH = D3D_PRIMITIVE_24_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_25_CONTROL_POINT_PATCH = D3D_PRIMITIVE_25_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_26_CONTROL_POINT_PATCH = D3D_PRIMITIVE_26_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_27_CONTROL_POINT_PATCH = D3D_PRIMITIVE_27_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_28_CONTROL_POINT_PATCH = D3D_PRIMITIVE_28_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_29_CONTROL_POINT_PATCH = D3D_PRIMITIVE_29_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_30_CONTROL_POINT_PATCH = D3D_PRIMITIVE_30_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_31_CONTROL_POINT_PATCH = D3D_PRIMITIVE_31_CONTROL_POINT_PATCH, + D3D11_PRIMITIVE_32_CONTROL_POINT_PATCH = D3D_PRIMITIVE_32_CONTROL_POINT_PATCH, + }; + + enum D3D_PRIMITIVE_TOPOLOGY + { + D3D_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D_PRIMITIVE_TOPOLOGY_POINTLIST = 1, + D3D_PRIMITIVE_TOPOLOGY_LINELIST = 2, + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, + D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = 11, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = 12, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = 13, + D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST = 33, + D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST = 34, + D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST = 35, + D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST = 36, + D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST = 37, + D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST = 38, + D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST = 39, + D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST = 40, + D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST = 41, + D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST = 42, + D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST = 43, + D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST = 44, + D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST = 45, + D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST = 46, + D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST = 47, + D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST = 48, + D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST = 49, + D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST = 50, + D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST = 51, + D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST = 52, + D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST = 53, + D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST = 54, + D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST = 55, + D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST = 56, + D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST = 57, + D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST = 58, + D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST = 59, + D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST = 60, + D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST = 61, + D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST = 62, + D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST = 63, + D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST = 64, + D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED, + D3D10_PRIMITIVE_TOPOLOGY_POINTLIST = D3D_PRIMITIVE_TOPOLOGY_POINTLIST, + D3D10_PRIMITIVE_TOPOLOGY_LINELIST = D3D_PRIMITIVE_TOPOLOGY_LINELIST, + D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, + D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ, + D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ, + D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ, + D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED, + D3D11_PRIMITIVE_TOPOLOGY_POINTLIST = D3D_PRIMITIVE_TOPOLOGY_POINTLIST, + D3D11_PRIMITIVE_TOPOLOGY_LINELIST = D3D_PRIMITIVE_TOPOLOGY_LINELIST, + D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, + D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ, + D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ, + D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ, + D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST, + D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST = D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST, + }; + + enum D3D_REGISTER_COMPONENT_TYPE + { + D3D_REGISTER_COMPONENT_UNKNOWN = 0, + D3D_REGISTER_COMPONENT_UINT32 = 1, + D3D_REGISTER_COMPONENT_SINT32 = 2, + D3D_REGISTER_COMPONENT_FLOAT32 = 3, + D3D10_REGISTER_COMPONENT_UNKNOWN = D3D_REGISTER_COMPONENT_UNKNOWN, + D3D10_REGISTER_COMPONENT_UINT32 = D3D_REGISTER_COMPONENT_UINT32, + D3D10_REGISTER_COMPONENT_SINT32 = D3D_REGISTER_COMPONENT_SINT32, + D3D10_REGISTER_COMPONENT_FLOAT32 = D3D_REGISTER_COMPONENT_FLOAT32, + }; + + enum D3D_RESOURCE_RETURN_TYPE + { + D3D_RETURN_TYPE_UNORM = 1, + D3D_RETURN_TYPE_SNORM = 2, + D3D_RETURN_TYPE_SINT = 3, + D3D_RETURN_TYPE_UINT = 4, + D3D_RETURN_TYPE_FLOAT = 5, + D3D_RETURN_TYPE_MIXED = 6, + D3D_RETURN_TYPE_DOUBLE = 7, + D3D_RETURN_TYPE_CONTINUED = 8, + D3D10_RETURN_TYPE_UNORM = D3D_RETURN_TYPE_UNORM, + D3D10_RETURN_TYPE_SNORM = D3D_RETURN_TYPE_SNORM, + D3D10_RETURN_TYPE_SINT = D3D_RETURN_TYPE_SINT, + D3D10_RETURN_TYPE_UINT = D3D_RETURN_TYPE_UINT, + D3D10_RETURN_TYPE_FLOAT = D3D_RETURN_TYPE_FLOAT, + D3D10_RETURN_TYPE_MIXED = D3D_RETURN_TYPE_MIXED, + D3D11_RETURN_TYPE_UNORM = D3D_RETURN_TYPE_UNORM, + D3D11_RETURN_TYPE_SNORM = D3D_RETURN_TYPE_SNORM, + D3D11_RETURN_TYPE_SINT = D3D_RETURN_TYPE_SINT, + D3D11_RETURN_TYPE_UINT = D3D_RETURN_TYPE_UINT, + D3D11_RETURN_TYPE_FLOAT = D3D_RETURN_TYPE_FLOAT, + D3D11_RETURN_TYPE_MIXED = D3D_RETURN_TYPE_MIXED, + D3D11_RETURN_TYPE_DOUBLE = D3D_RETURN_TYPE_DOUBLE, + D3D11_RETURN_TYPE_CONTINUED = D3D_RETURN_TYPE_CONTINUED, + }; + + enum D3D_SHADER_CBUFFER_FLAGS + { + D3D_CBF_USERPACKED = 1, + D3D10_CBF_USERPACKED = D3D_CBF_USERPACKED, + D3D_CBF_FORCE_DWORD = 0x7FFFFFFF, + }; + + enum D3D_SHADER_INPUT_FLAGS + { + D3D_SIF_USERPACKED = 0x1, + D3D_SIF_COMPARISON_SAMPLER = 0x2, + D3D_SIF_TEXTURE_COMPONENT_0 = 0x4, + D3D_SIF_TEXTURE_COMPONENT_1 = 0x8, + D3D_SIF_TEXTURE_COMPONENTS = 0xc, + D3D_SIF_UNUSED = 0x10, + D3D10_SIF_USERPACKED = D3D_SIF_USERPACKED, + D3D10_SIF_COMPARISON_SAMPLER = D3D_SIF_COMPARISON_SAMPLER, + D3D10_SIF_TEXTURE_COMPONENT_0 = D3D_SIF_TEXTURE_COMPONENT_0, + D3D10_SIF_TEXTURE_COMPONENT_1 = D3D_SIF_TEXTURE_COMPONENT_1, + D3D10_SIF_TEXTURE_COMPONENTS = D3D_SIF_TEXTURE_COMPONENTS, + D3D_SIF_FORCE_DWORD = 0x7FFFFFFF, + }; + + enum D3D_SHADER_INPUT_TYPE + { + D3D_SIT_CBUFFER = 0, + D3D_SIT_TBUFFER = (D3D_SIT_CBUFFER + 1), + D3D_SIT_TEXTURE = (D3D_SIT_TBUFFER + 1), + D3D_SIT_SAMPLER = (D3D_SIT_TEXTURE + 1), + D3D_SIT_UAV_RWTYPED = (D3D_SIT_SAMPLER + 1), + D3D_SIT_STRUCTURED = (D3D_SIT_UAV_RWTYPED + 1), + D3D_SIT_UAV_RWSTRUCTURED = (D3D_SIT_STRUCTURED + 1), + D3D_SIT_BYTEADDRESS = (D3D_SIT_UAV_RWSTRUCTURED + 1), + D3D_SIT_UAV_RWBYTEADDRESS = (D3D_SIT_BYTEADDRESS + 1), + D3D_SIT_UAV_APPEND_STRUCTURED = (D3D_SIT_UAV_RWBYTEADDRESS + 1), + D3D_SIT_UAV_CONSUME_STRUCTURED = (D3D_SIT_UAV_APPEND_STRUCTURED + 1), + D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER = (D3D_SIT_UAV_CONSUME_STRUCTURED + 1), + D3D_SIT_RTACCELERATIONSTRUCTURE = (D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER + 1), + D3D_SIT_UAV_FEEDBACKTEXTURE = (D3D_SIT_RTACCELERATIONSTRUCTURE + 1), + D3D10_SIT_CBUFFER = D3D_SIT_CBUFFER, + D3D10_SIT_TBUFFER = D3D_SIT_TBUFFER, + D3D10_SIT_TEXTURE = D3D_SIT_TEXTURE, + D3D10_SIT_SAMPLER = D3D_SIT_SAMPLER, + D3D11_SIT_UAV_RWTYPED = D3D_SIT_UAV_RWTYPED, + D3D11_SIT_STRUCTURED = D3D_SIT_STRUCTURED, + D3D11_SIT_UAV_RWSTRUCTURED = D3D_SIT_UAV_RWSTRUCTURED, + D3D11_SIT_BYTEADDRESS = D3D_SIT_BYTEADDRESS, + D3D11_SIT_UAV_RWBYTEADDRESS = D3D_SIT_UAV_RWBYTEADDRESS, + D3D11_SIT_UAV_APPEND_STRUCTURED = D3D_SIT_UAV_APPEND_STRUCTURED, + D3D11_SIT_UAV_CONSUME_STRUCTURED = D3D_SIT_UAV_CONSUME_STRUCTURED, + D3D11_SIT_UAV_RWSTRUCTURED_WITH_COUNTER = D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER, + }; + + enum D3D_SHADER_VARIABLE_CLASS + { + D3D_SVC_SCALAR = 0, + D3D_SVC_VECTOR = (D3D_SVC_SCALAR + 1), + D3D_SVC_MATRIX_ROWS = (D3D_SVC_VECTOR + 1), + D3D_SVC_MATRIX_COLUMNS = (D3D_SVC_MATRIX_ROWS + 1), + D3D_SVC_OBJECT = (D3D_SVC_MATRIX_COLUMNS + 1), + D3D_SVC_STRUCT = (D3D_SVC_OBJECT + 1), + D3D_SVC_INTERFACE_CLASS = (D3D_SVC_STRUCT + 1), + D3D_SVC_INTERFACE_POINTER = (D3D_SVC_INTERFACE_CLASS + 1), + D3D10_SVC_SCALAR = D3D_SVC_SCALAR, + D3D10_SVC_VECTOR = D3D_SVC_VECTOR, + D3D10_SVC_MATRIX_ROWS = D3D_SVC_MATRIX_ROWS, + D3D10_SVC_MATRIX_COLUMNS = D3D_SVC_MATRIX_COLUMNS, + D3D10_SVC_OBJECT = D3D_SVC_OBJECT, + D3D10_SVC_STRUCT = D3D_SVC_STRUCT, + D3D11_SVC_INTERFACE_CLASS = D3D_SVC_INTERFACE_CLASS, + D3D11_SVC_INTERFACE_POINTER = D3D_SVC_INTERFACE_POINTER, + D3D_SVC_FORCE_DWORD = 0x7FFFFFFF, + }; + + enum D3D_SHADER_VARIABLE_FLAGS + { + D3D_SVF_USERPACKED = 1, + D3D_SVF_USED = 2, + D3D_SVF_INTERFACE_POINTER = 4, + D3D_SVF_INTERFACE_PARAMETER = 8, + D3D10_SVF_USERPACKED = D3D_SVF_USERPACKED, + D3D10_SVF_USED = D3D_SVF_USED, + D3D11_SVF_INTERFACE_POINTER = D3D_SVF_INTERFACE_POINTER, + D3D11_SVF_INTERFACE_PARAMETER = D3D_SVF_INTERFACE_PARAMETER, + D3D_SVF_FORCE_DWORD = 0x7FFFFFFF, + }; + + enum D3D_SHADER_VARIABLE_TYPE + { + D3D_SVT_VOID = 0, + D3D_SVT_BOOL = 1, + D3D_SVT_INT = 2, + D3D_SVT_FLOAT = 3, + D3D_SVT_STRING = 4, + D3D_SVT_TEXTURE = 5, + D3D_SVT_TEXTURE1D = 6, + D3D_SVT_TEXTURE2D = 7, + D3D_SVT_TEXTURE3D = 8, + D3D_SVT_TEXTURECUBE = 9, + D3D_SVT_SAMPLER = 10, + D3D_SVT_SAMPLER1D = 11, + D3D_SVT_SAMPLER2D = 12, + D3D_SVT_SAMPLER3D = 13, + D3D_SVT_SAMPLERCUBE = 14, + D3D_SVT_PIXELSHADER = 15, + D3D_SVT_VERTEXSHADER = 16, + D3D_SVT_PIXELFRAGMENT = 17, + D3D_SVT_VERTEXFRAGMENT = 18, + D3D_SVT_UINT = 19, + D3D_SVT_UINT8 = 20, + D3D_SVT_GEOMETRYSHADER = 21, + D3D_SVT_RASTERIZER = 22, + D3D_SVT_DEPTHSTENCIL = 23, + D3D_SVT_BLEND = 24, + D3D_SVT_BUFFER = 25, + D3D_SVT_CBUFFER = 26, + D3D_SVT_TBUFFER = 27, + D3D_SVT_TEXTURE1DARRAY = 28, + D3D_SVT_TEXTURE2DARRAY = 29, + D3D_SVT_RENDERTARGETVIEW = 30, + D3D_SVT_DEPTHSTENCILVIEW = 31, + D3D_SVT_TEXTURE2DMS = 32, + D3D_SVT_TEXTURE2DMSARRAY = 33, + D3D_SVT_TEXTURECUBEARRAY = 34, + D3D_SVT_HULLSHADER = 35, + D3D_SVT_DOMAINSHADER = 36, + D3D_SVT_INTERFACE_POINTER = 37, + D3D_SVT_COMPUTESHADER = 38, + D3D_SVT_DOUBLE = 39, + D3D_SVT_RWTEXTURE1D = 40, + D3D_SVT_RWTEXTURE1DARRAY = 41, + D3D_SVT_RWTEXTURE2D = 42, + D3D_SVT_RWTEXTURE2DARRAY = 43, + D3D_SVT_RWTEXTURE3D = 44, + D3D_SVT_RWBUFFER = 45, + D3D_SVT_BYTEADDRESS_BUFFER = 46, + D3D_SVT_RWBYTEADDRESS_BUFFER = 47, + D3D_SVT_STRUCTURED_BUFFER = 48, + D3D_SVT_RWSTRUCTURED_BUFFER = 49, + D3D_SVT_APPEND_STRUCTURED_BUFFER = 50, + D3D_SVT_CONSUME_STRUCTURED_BUFFER = 51, + D3D_SVT_MIN8FLOAT = 52, + D3D_SVT_MIN10FLOAT = 53, + D3D_SVT_MIN16FLOAT = 54, + D3D_SVT_MIN12INT = 55, + D3D_SVT_MIN16INT = 56, + D3D_SVT_MIN16UINT = 57, + D3D_SVT_INT16 = 58, + D3D_SVT_UINT16 = 59, + D3D_SVT_FLOAT16 = 60, + D3D_SVT_INT64 = 61, + D3D_SVT_UINT64 = 62, + D3D10_SVT_VOID = D3D_SVT_VOID, + D3D10_SVT_BOOL = D3D_SVT_BOOL, + D3D10_SVT_INT = D3D_SVT_INT, + D3D10_SVT_FLOAT = D3D_SVT_FLOAT, + D3D10_SVT_STRING = D3D_SVT_STRING, + D3D10_SVT_TEXTURE = D3D_SVT_TEXTURE, + D3D10_SVT_TEXTURE1D = D3D_SVT_TEXTURE1D, + D3D10_SVT_TEXTURE2D = D3D_SVT_TEXTURE2D, + D3D10_SVT_TEXTURE3D = D3D_SVT_TEXTURE3D, + D3D10_SVT_TEXTURECUBE = D3D_SVT_TEXTURECUBE, + D3D10_SVT_SAMPLER = D3D_SVT_SAMPLER, + D3D10_SVT_SAMPLER1D = D3D_SVT_SAMPLER1D, + D3D10_SVT_SAMPLER2D = D3D_SVT_SAMPLER2D, + D3D10_SVT_SAMPLER3D = D3D_SVT_SAMPLER3D, + D3D10_SVT_SAMPLERCUBE = D3D_SVT_SAMPLERCUBE, + D3D10_SVT_PIXELSHADER = D3D_SVT_PIXELSHADER, + D3D10_SVT_VERTEXSHADER = D3D_SVT_VERTEXSHADER, + D3D10_SVT_PIXELFRAGMENT = D3D_SVT_PIXELFRAGMENT, + D3D10_SVT_VERTEXFRAGMENT = D3D_SVT_VERTEXFRAGMENT, + D3D10_SVT_UINT = D3D_SVT_UINT, + D3D10_SVT_UINT8 = D3D_SVT_UINT8, + D3D10_SVT_GEOMETRYSHADER = D3D_SVT_GEOMETRYSHADER, + D3D10_SVT_RASTERIZER = D3D_SVT_RASTERIZER, + D3D10_SVT_DEPTHSTENCIL = D3D_SVT_DEPTHSTENCIL, + D3D10_SVT_BLEND = D3D_SVT_BLEND, + D3D10_SVT_BUFFER = D3D_SVT_BUFFER, + D3D10_SVT_CBUFFER = D3D_SVT_CBUFFER, + D3D10_SVT_TBUFFER = D3D_SVT_TBUFFER, + D3D10_SVT_TEXTURE1DARRAY = D3D_SVT_TEXTURE1DARRAY, + D3D10_SVT_TEXTURE2DARRAY = D3D_SVT_TEXTURE2DARRAY, + D3D10_SVT_RENDERTARGETVIEW = D3D_SVT_RENDERTARGETVIEW, + D3D10_SVT_DEPTHSTENCILVIEW = D3D_SVT_DEPTHSTENCILVIEW, + D3D10_SVT_TEXTURE2DMS = D3D_SVT_TEXTURE2DMS, + D3D10_SVT_TEXTURE2DMSARRAY = D3D_SVT_TEXTURE2DMSARRAY, + D3D10_SVT_TEXTURECUBEARRAY = D3D_SVT_TEXTURECUBEARRAY, + D3D11_SVT_HULLSHADER = D3D_SVT_HULLSHADER, + D3D11_SVT_DOMAINSHADER = D3D_SVT_DOMAINSHADER, + D3D11_SVT_INTERFACE_POINTER = D3D_SVT_INTERFACE_POINTER, + D3D11_SVT_COMPUTESHADER = D3D_SVT_COMPUTESHADER, + D3D11_SVT_DOUBLE = D3D_SVT_DOUBLE, + D3D11_SVT_RWTEXTURE1D = D3D_SVT_RWTEXTURE1D, + D3D11_SVT_RWTEXTURE1DARRAY = D3D_SVT_RWTEXTURE1DARRAY, + D3D11_SVT_RWTEXTURE2D = D3D_SVT_RWTEXTURE2D, + D3D11_SVT_RWTEXTURE2DARRAY = D3D_SVT_RWTEXTURE2DARRAY, + D3D11_SVT_RWTEXTURE3D = D3D_SVT_RWTEXTURE3D, + D3D11_SVT_RWBUFFER = D3D_SVT_RWBUFFER, + D3D11_SVT_BYTEADDRESS_BUFFER = D3D_SVT_BYTEADDRESS_BUFFER, + D3D11_SVT_RWBYTEADDRESS_BUFFER = D3D_SVT_RWBYTEADDRESS_BUFFER, + D3D11_SVT_STRUCTURED_BUFFER = D3D_SVT_STRUCTURED_BUFFER, + D3D11_SVT_RWSTRUCTURED_BUFFER = D3D_SVT_RWSTRUCTURED_BUFFER, + D3D11_SVT_APPEND_STRUCTURED_BUFFER = D3D_SVT_APPEND_STRUCTURED_BUFFER, + D3D11_SVT_CONSUME_STRUCTURED_BUFFER = D3D_SVT_CONSUME_STRUCTURED_BUFFER, + D3D_SVT_FORCE_DWORD = 0x7FFFFFFF, + }; + + enum D3D_SRV_DIMENSION + { + D3D_SRV_DIMENSION_UNKNOWN = 0, + D3D_SRV_DIMENSION_BUFFER = 1, + D3D_SRV_DIMENSION_TEXTURE1D = 2, + D3D_SRV_DIMENSION_TEXTURE1DARRAY = 3, + D3D_SRV_DIMENSION_TEXTURE2D = 4, + D3D_SRV_DIMENSION_TEXTURE2DARRAY = 5, + D3D_SRV_DIMENSION_TEXTURE2DMS = 6, + D3D_SRV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D_SRV_DIMENSION_TEXTURE3D = 8, + D3D_SRV_DIMENSION_TEXTURECUBE = 9, + D3D_SRV_DIMENSION_TEXTURECUBEARRAY = 10, + D3D_SRV_DIMENSION_BUFFEREX = 11, + D3D10_SRV_DIMENSION_UNKNOWN = D3D_SRV_DIMENSION_UNKNOWN, + D3D10_SRV_DIMENSION_BUFFER = D3D_SRV_DIMENSION_BUFFER, + D3D10_SRV_DIMENSION_TEXTURE1D = D3D_SRV_DIMENSION_TEXTURE1D, + D3D10_SRV_DIMENSION_TEXTURE1DARRAY = D3D_SRV_DIMENSION_TEXTURE1DARRAY, + D3D10_SRV_DIMENSION_TEXTURE2D = D3D_SRV_DIMENSION_TEXTURE2D, + D3D10_SRV_DIMENSION_TEXTURE2DARRAY = D3D_SRV_DIMENSION_TEXTURE2DARRAY, + D3D10_SRV_DIMENSION_TEXTURE2DMS = D3D_SRV_DIMENSION_TEXTURE2DMS, + D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY = D3D_SRV_DIMENSION_TEXTURE2DMSARRAY, + D3D10_SRV_DIMENSION_TEXTURE3D = D3D_SRV_DIMENSION_TEXTURE3D, + D3D10_SRV_DIMENSION_TEXTURECUBE = D3D_SRV_DIMENSION_TEXTURECUBE, + D3D10_1_SRV_DIMENSION_UNKNOWN = D3D_SRV_DIMENSION_UNKNOWN, + D3D10_1_SRV_DIMENSION_BUFFER = D3D_SRV_DIMENSION_BUFFER, + D3D10_1_SRV_DIMENSION_TEXTURE1D = D3D_SRV_DIMENSION_TEXTURE1D, + D3D10_1_SRV_DIMENSION_TEXTURE1DARRAY = D3D_SRV_DIMENSION_TEXTURE1DARRAY, + D3D10_1_SRV_DIMENSION_TEXTURE2D = D3D_SRV_DIMENSION_TEXTURE2D, + D3D10_1_SRV_DIMENSION_TEXTURE2DARRAY = D3D_SRV_DIMENSION_TEXTURE2DARRAY, + D3D10_1_SRV_DIMENSION_TEXTURE2DMS = D3D_SRV_DIMENSION_TEXTURE2DMS, + D3D10_1_SRV_DIMENSION_TEXTURE2DMSARRAY = D3D_SRV_DIMENSION_TEXTURE2DMSARRAY, + D3D10_1_SRV_DIMENSION_TEXTURE3D = D3D_SRV_DIMENSION_TEXTURE3D, + D3D10_1_SRV_DIMENSION_TEXTURECUBE = D3D_SRV_DIMENSION_TEXTURECUBE, + D3D10_1_SRV_DIMENSION_TEXTURECUBEARRAY = D3D_SRV_DIMENSION_TEXTURECUBEARRAY, + D3D11_SRV_DIMENSION_UNKNOWN = D3D_SRV_DIMENSION_UNKNOWN, + D3D11_SRV_DIMENSION_BUFFER = D3D_SRV_DIMENSION_BUFFER, + D3D11_SRV_DIMENSION_TEXTURE1D = D3D_SRV_DIMENSION_TEXTURE1D, + D3D11_SRV_DIMENSION_TEXTURE1DARRAY = D3D_SRV_DIMENSION_TEXTURE1DARRAY, + D3D11_SRV_DIMENSION_TEXTURE2D = D3D_SRV_DIMENSION_TEXTURE2D, + D3D11_SRV_DIMENSION_TEXTURE2DARRAY = D3D_SRV_DIMENSION_TEXTURE2DARRAY, + D3D11_SRV_DIMENSION_TEXTURE2DMS = D3D_SRV_DIMENSION_TEXTURE2DMS, + D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY = D3D_SRV_DIMENSION_TEXTURE2DMSARRAY, + D3D11_SRV_DIMENSION_TEXTURE3D = D3D_SRV_DIMENSION_TEXTURE3D, + D3D11_SRV_DIMENSION_TEXTURECUBE = D3D_SRV_DIMENSION_TEXTURECUBE, + D3D11_SRV_DIMENSION_TEXTURECUBEARRAY = D3D_SRV_DIMENSION_TEXTURECUBEARRAY, + D3D11_SRV_DIMENSION_BUFFEREX = D3D_SRV_DIMENSION_BUFFEREX, + }; + + enum D3D_TESSELLATOR_DOMAIN + { + D3D_TESSELLATOR_DOMAIN_UNDEFINED = 0, + D3D_TESSELLATOR_DOMAIN_ISOLINE = 1, + D3D_TESSELLATOR_DOMAIN_TRI = 2, + D3D_TESSELLATOR_DOMAIN_QUAD = 3, + D3D11_TESSELLATOR_DOMAIN_UNDEFINED = D3D_TESSELLATOR_DOMAIN_UNDEFINED, + D3D11_TESSELLATOR_DOMAIN_ISOLINE = D3D_TESSELLATOR_DOMAIN_ISOLINE, + D3D11_TESSELLATOR_DOMAIN_TRI = D3D_TESSELLATOR_DOMAIN_TRI, + D3D11_TESSELLATOR_DOMAIN_QUAD = D3D_TESSELLATOR_DOMAIN_QUAD, + }; + + enum D3D_TESSELLATOR_OUTPUT_PRIMITIVE + { + D3D_TESSELLATOR_OUTPUT_UNDEFINED = 0, + D3D_TESSELLATOR_OUTPUT_POINT = 1, + D3D_TESSELLATOR_OUTPUT_LINE = 2, + D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3, + D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4, + D3D11_TESSELLATOR_OUTPUT_UNDEFINED = D3D_TESSELLATOR_OUTPUT_UNDEFINED, + D3D11_TESSELLATOR_OUTPUT_POINT = D3D_TESSELLATOR_OUTPUT_POINT, + D3D11_TESSELLATOR_OUTPUT_LINE = D3D_TESSELLATOR_OUTPUT_LINE, + D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CW = D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW, + D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CCW = D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW, + }; + + enum D3D_TESSELLATOR_PARTITIONING + { + D3D_TESSELLATOR_PARTITIONING_UNDEFINED = 0, + D3D_TESSELLATOR_PARTITIONING_INTEGER = 1, + D3D_TESSELLATOR_PARTITIONING_POW2 = 2, + D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3, + D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4, + D3D11_TESSELLATOR_PARTITIONING_UNDEFINED = D3D_TESSELLATOR_PARTITIONING_UNDEFINED, + D3D11_TESSELLATOR_PARTITIONING_INTEGER = D3D_TESSELLATOR_PARTITIONING_INTEGER, + D3D11_TESSELLATOR_PARTITIONING_POW2 = D3D_TESSELLATOR_PARTITIONING_POW2, + D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD, + D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN, + }; +} + +namespace REX::W32 +{ + using D3DCOLOR = std::uint32_t; + + struct D3DRECT + { + std::int32_t x1; + std::int32_t y1; + std::int32_t x2; + std::int32_t y2; + }; + + struct D3DVECTOR + { + float x; + float y; + float z; + }; + + struct D3D_SHADER_MACRO + { + const char* name; + const char* definition; + }; + + struct XMFLOAT4X4 + { + float m[4][4]; + }; + static_assert(sizeof(XMFLOAT4X4) == 0x40); +} + +namespace REX::W32 +{ + using PFN_DESTRUCTION_CALLBACK = void(__stdcall*)(void* a_data); +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("8BA5FB08-5195-40e2-AC58-0D989C3A0102")) + ID3DBlob : public IUnknown + { + virtual void* GetBufferPointer(void) = 0; + virtual std::size_t GetBufferSize(void) = 0; + }; + + struct __declspec(novtable, uuid("A06EB39A-50DA-425B-8C31-4EECD6C270F3")) + ID3DDestructionNotifier : public IUnknown + { + virtual HRESULT RegisterDestructionCallback(PFN_DESTRUCTION_CALLBACK a_callbackFn, void* a_data, std::uint32_t* a_callbackID) = 0; + virtual HRESULT UnregisterDestructionCallback(std::uint32_t a_callbackID) = 0; + }; + + struct __declspec(novtable) // uuid(?) + ID3DInclude : public IUnknown + { + virtual HRESULT Open(D3D_INCLUDE_TYPE a_includeType, const char* a_fileName, const void* a_parentData, const void** a_data, std::uint32_t* a_bytes) = 0; + virtual HRESULT Close(const void* a_data) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_ID3DBlob{ 0xA06EB39A, 0x50DA, 0x425B, { 0x8C, 0x31, 0x4E, 0xEC, 0xD6, 0xC2, 0x70, 0xF3 } }; + inline constexpr IID IID_ID3DDestructionNotifier{ 0xA06EB39A, 0x50DA, 0x425B, { 0x8C, 0x31, 0x4E, 0xEC, 0xD6, 0xC2, 0x70, 0xF3 } }; +} diff --git a/include/REX/W32/D3D11.h b/include/REX/W32/D3D11.h new file mode 100644 index 000000000..2a5aaab56 --- /dev/null +++ b/include/REX/W32/D3D11.h @@ -0,0 +1,2043 @@ +#pragma once + +#include "D3D.h" + +namespace REX::W32 +{ + struct ID3D11Asynchronous; + struct ID3D11AuthenticatedChannel; + struct ID3D11BlendState; + struct ID3D11Buffer; + struct ID3D11ClassInstance; + struct ID3D11ClassLinkage; + struct ID3D11CommandList; + struct ID3D11ComputeShader; + struct ID3D11Counter; + struct ID3D11CryptoSession; + struct ID3D11Device; + struct ID3D11DeviceChild; + struct ID3D11DeviceContext; + struct ID3D11DepthStencilState; + struct ID3D11DepthStencilView; + struct ID3D11DomainShader; + struct ID3D11GeometryShader; + struct ID3D11HullShader; + struct ID3D11InputLayout; + struct ID3D11PixelShader; + struct ID3D11Predicate; + struct ID3D11Query; + struct ID3D11RasterizerState; + struct ID3D11RenderTargetView; + struct ID3D11Resource; + struct ID3D11SamplerState; + struct ID3D11ShaderResourceView; + struct ID3D11Texture1D; + struct ID3D11Texture2D; + struct ID3D11Texture3D; + struct ID3D11UnorderedAccessView; + struct ID3D11VertexShader; + struct ID3D11VideoContext; + struct ID3D11VideoDecoder; + struct ID3D11VideoDecoderOutputView; + struct ID3D11VideoDevice; + struct ID3D11VideoProcessor; + struct ID3D11VideoProcessorEnumerator; + struct ID3D11VideoProcessorInputView; + struct ID3D11VideoProcessorOutputView; + struct ID3D11View; +} + +namespace REX::W32 +{ + enum D3D11_ASYNC_GETDATA_FLAG + { + D3D11_ASYNC_GETDATA_DONOTFLUSH = 0x1, + }; + + enum D3D11_AUTHENTICATED_CHANNEL_TYPE + { + D3D11_AUTHENTICATED_CHANNEL_D3D11 = 1, + D3D11_AUTHENTICATED_CHANNEL_DRIVER_SOFTWARE = 2, + D3D11_AUTHENTICATED_CHANNEL_DRIVER_HARDWARE = 3, + }; + + enum D3D11_BIND_FLAG + { + D3D11_BIND_VERTEX_BUFFER = 0x1L, + D3D11_BIND_INDEX_BUFFER = 0x2L, + D3D11_BIND_CONSTANT_BUFFER = 0x4L, + D3D11_BIND_SHADER_RESOURCE = 0x8L, + D3D11_BIND_STREAM_OUTPUT = 0x10L, + D3D11_BIND_RENDER_TARGET = 0x20L, + D3D11_BIND_DEPTH_STENCIL = 0x40L, + D3D11_BIND_UNORDERED_ACCESS = 0x80L, + D3D11_BIND_DECODER = 0x200L, + D3D11_BIND_VIDEO_ENCODER = 0x400L, + }; + + enum D3D11_BLEND + { + D3D11_BLEND_ZERO = 1, + D3D11_BLEND_ONE = 2, + D3D11_BLEND_SRC_COLOR = 3, + D3D11_BLEND_INV_SRC_COLOR = 4, + D3D11_BLEND_SRC_ALPHA = 5, + D3D11_BLEND_INV_SRC_ALPHA = 6, + D3D11_BLEND_DEST_ALPHA = 7, + D3D11_BLEND_INV_DEST_ALPHA = 8, + D3D11_BLEND_DEST_COLOR = 9, + D3D11_BLEND_INV_DEST_COLOR = 10, + D3D11_BLEND_SRC_ALPHA_SAT = 11, + D3D11_BLEND_BLEND_FACTOR = 14, + D3D11_BLEND_INV_BLEND_FACTOR = 15, + D3D11_BLEND_SRC1_COLOR = 16, + D3D11_BLEND_INV_SRC1_COLOR = 17, + D3D11_BLEND_SRC1_ALPHA = 18, + D3D11_BLEND_INV_SRC1_ALPHA = 19, + }; + + enum D3D11_BLEND_OP + { + D3D11_BLEND_OP_ADD = 1, + D3D11_BLEND_OP_SUBTRACT = 2, + D3D11_BLEND_OP_REV_SUBTRACT = 3, + D3D11_BLEND_OP_MIN = 4, + D3D11_BLEND_OP_MAX = 5, + }; + + enum D3D11_BUFFER_UAV_FLAG + { + D3D11_BUFFER_UAV_FLAG_RAW = 0x1, + D3D11_BUFFER_UAV_FLAG_APPEND = 0x2, + D3D11_BUFFER_UAV_FLAG_COUNTER = 0x4, + }; + + enum D3D11_BUFFEREX_SRV_FLAG + { + D3D11_BUFFEREX_SRV_FLAG_RAW = 0x1, + }; + + enum D3D11_CLEAR_FLAG + { + D3D11_CLEAR_DEPTH = 0x1L, + D3D11_CLEAR_STENCIL = 0x2L, + }; + + enum D3D11_COLOR_WRITE_ENABLE + { + D3D11_COLOR_WRITE_ENABLE_RED = 1, + D3D11_COLOR_WRITE_ENABLE_GREEN = 2, + D3D11_COLOR_WRITE_ENABLE_BLUE = 4, + D3D11_COLOR_WRITE_ENABLE_ALPHA = 8, + D3D11_COLOR_WRITE_ENABLE_ALL = (((D3D11_COLOR_WRITE_ENABLE_RED | D3D11_COLOR_WRITE_ENABLE_GREEN) | D3D11_COLOR_WRITE_ENABLE_BLUE) | D3D11_COLOR_WRITE_ENABLE_ALPHA), + }; + + enum D3D11_COMPARISON_FUNC + { + D3D11_COMPARISON_NEVER = 1, + D3D11_COMPARISON_LESS = 2, + D3D11_COMPARISON_EQUAL = 3, + D3D11_COMPARISON_LESS_EQUAL = 4, + D3D11_COMPARISON_GREATER = 5, + D3D11_COMPARISON_NOT_EQUAL = 6, + D3D11_COMPARISON_GREATER_EQUAL = 7, + D3D11_COMPARISON_ALWAYS = 8, + }; + + enum D3D11_CONTENT_PROTECTION_CAPS + { + D3D11_CONTENT_PROTECTION_CAPS_SOFTWARE = 0x1, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE = 0x2, + D3D11_CONTENT_PROTECTION_CAPS_PROTECTION_ALWAYS_ON = 0x4, + D3D11_CONTENT_PROTECTION_CAPS_PARTIAL_DECRYPTION = 0x8, + D3D11_CONTENT_PROTECTION_CAPS_CONTENT_KEY = 0x10, + D3D11_CONTENT_PROTECTION_CAPS_FRESHEN_SESSION_KEY = 0x20, + D3D11_CONTENT_PROTECTION_CAPS_ENCRYPTED_READ_BACK = 0x40, + D3D11_CONTENT_PROTECTION_CAPS_ENCRYPTED_READ_BACK_KEY = 0x80, + D3D11_CONTENT_PROTECTION_CAPS_SEQUENTIAL_CTR_IV = 0x100, + D3D11_CONTENT_PROTECTION_CAPS_ENCRYPT_SLICEDATA_ONLY = 0x200, + D3D11_CONTENT_PROTECTION_CAPS_DECRYPTION_BLT = 0x400, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_PROTECT_UNCOMPRESSED = 0x800, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_PROTECTED_MEMORY_PAGEABLE = 0x1000, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_TEARDOWN = 0x2000, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_DRM_COMMUNICATION = 0x4000, + D3D11_CONTENT_PROTECTION_CAPS_HARDWARE_DRM_COMMUNICATION_MULTI_THREADED = 0x8000, + }; + + enum D3D11_COUNTER + { + D3D11_COUNTER_DEVICE_DEPENDENT_0 = 0x40000000 + }; + + enum D3D11_COUNTER_TYPE + { + D3D11_COUNTER_TYPE_FLOAT32 = 0, + D3D11_COUNTER_TYPE_UINT16 = (D3D11_COUNTER_TYPE_FLOAT32 + 1), + D3D11_COUNTER_TYPE_UINT32 = (D3D11_COUNTER_TYPE_UINT16 + 1), + D3D11_COUNTER_TYPE_UINT64 = (D3D11_COUNTER_TYPE_UINT32 + 1), + }; + + enum D3D11_CPU_ACCESS_FLAG + { + D3D11_CPU_ACCESS_WRITE = 0x10000L, + D3D11_CPU_ACCESS_READ = 0x20000L, + }; + + enum D3D11_CREATE_DEVICE_FLAG + { + D3D11_CREATE_DEVICE_SINGLETHREADED = 0x1, + D3D11_CREATE_DEVICE_DEBUG = 0x2, + D3D11_CREATE_DEVICE_SWITCH_TO_REF = 0x4, + D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS = 0x8, + D3D11_CREATE_DEVICE_BGRA_SUPPORT = 0x20, + D3D11_CREATE_DEVICE_DEBUGGABLE = 0x40, + D3D11_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY = 0x80, + D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT = 0x100, + D3D11_CREATE_DEVICE_VIDEO_SUPPORT = 0x800, + }; + + enum D3D11_CULL_MODE + { + D3D11_CULL_NONE = 1, + D3D11_CULL_FRONT = 2, + D3D11_CULL_BACK = 3, + }; + + enum D3D11_DEPTH_WRITE_MASK + { + D3D11_DEPTH_WRITE_MASK_ZERO = 0, + D3D11_DEPTH_WRITE_MASK_ALL = 1, + }; + + enum D3D11_DEVICE_CONTEXT_TYPE + { + D3D11_DEVICE_CONTEXT_IMMEDIATE = 0, + D3D11_DEVICE_CONTEXT_DEFERRED = (D3D11_DEVICE_CONTEXT_IMMEDIATE + 1), + }; + + enum D3D11_DSV_DIMENSION + { + D3D11_DSV_DIMENSION_UNKNOWN = 0, + D3D11_DSV_DIMENSION_TEXTURE1D = 1, + D3D11_DSV_DIMENSION_TEXTURE1DARRAY = 2, + D3D11_DSV_DIMENSION_TEXTURE2D = 3, + D3D11_DSV_DIMENSION_TEXTURE2DARRAY = 4, + D3D11_DSV_DIMENSION_TEXTURE2DMS = 5, + D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY = 6, + }; + + enum D3D11_DSV_FLAG + { + D3D11_DSV_READ_ONLY_DEPTH = 0x1L, + D3D11_DSV_READ_ONLY_STENCIL = 0x2L, + }; + + enum D3D11_FEATURE + { + D3D11_FEATURE_THREADING = 0, + D3D11_FEATURE_DOUBLES = (D3D11_FEATURE_THREADING + 1), + D3D11_FEATURE_FORMAT_SUPPORT = (D3D11_FEATURE_DOUBLES + 1), + D3D11_FEATURE_FORMAT_SUPPORT2 = (D3D11_FEATURE_FORMAT_SUPPORT + 1), + D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS = (D3D11_FEATURE_FORMAT_SUPPORT2 + 1), + D3D11_FEATURE_D3D11_OPTIONS = (D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS + 1), + D3D11_FEATURE_ARCHITECTURE_INFO = (D3D11_FEATURE_D3D11_OPTIONS + 1), + D3D11_FEATURE_D3D9_OPTIONS = (D3D11_FEATURE_ARCHITECTURE_INFO + 1), + D3D11_FEATURE_SHADER_MIN_PRECISION_SUPPORT = (D3D11_FEATURE_D3D9_OPTIONS + 1), + D3D11_FEATURE_D3D9_SHADOW_SUPPORT = (D3D11_FEATURE_SHADER_MIN_PRECISION_SUPPORT + 1), + D3D11_FEATURE_D3D11_OPTIONS1 = (D3D11_FEATURE_D3D9_SHADOW_SUPPORT + 1), + D3D11_FEATURE_D3D9_SIMPLE_INSTANCING_SUPPORT = (D3D11_FEATURE_D3D11_OPTIONS1 + 1), + D3D11_FEATURE_MARKER_SUPPORT = (D3D11_FEATURE_D3D9_SIMPLE_INSTANCING_SUPPORT + 1), + D3D11_FEATURE_D3D9_OPTIONS1 = (D3D11_FEATURE_MARKER_SUPPORT + 1), + D3D11_FEATURE_D3D11_OPTIONS2 = (D3D11_FEATURE_D3D9_OPTIONS1 + 1), + D3D11_FEATURE_D3D11_OPTIONS3 = (D3D11_FEATURE_D3D11_OPTIONS2 + 1), + D3D11_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT = (D3D11_FEATURE_D3D11_OPTIONS3 + 1), + D3D11_FEATURE_D3D11_OPTIONS4 = (D3D11_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT + 1), + D3D11_FEATURE_SHADER_CACHE = (D3D11_FEATURE_D3D11_OPTIONS4 + 1), + D3D11_FEATURE_D3D11_OPTIONS5 = (D3D11_FEATURE_SHADER_CACHE + 1), + D3D11_FEATURE_DISPLAYABLE = (D3D11_FEATURE_D3D11_OPTIONS5 + 1), + }; + + enum D3D11_FILL_MODE + { + D3D11_FILL_WIREFRAME = 2, + D3D11_FILL_SOLID = 3, + }; + + enum D3D11_FILTER + { + D3D11_FILTER_MIN_MAG_MIP_POINT = 0, + D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, + D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, + D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, + D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + D3D11_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + D3D11_FILTER_ANISOTROPIC = 0x55, + D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, + D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, + D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, + D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, + D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, + D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, + D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, + D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, + D3D11_FILTER_COMPARISON_ANISOTROPIC = 0xd5, + D3D11_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100, + D3D11_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101, + D3D11_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104, + D3D11_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105, + D3D11_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110, + D3D11_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111, + D3D11_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114, + D3D11_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 0x115, + D3D11_FILTER_MINIMUM_ANISOTROPIC = 0x155, + D3D11_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 0x180, + D3D11_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181, + D3D11_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184, + D3D11_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185, + D3D11_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190, + D3D11_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191, + D3D11_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194, + D3D11_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195, + D3D11_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5, + }; + + enum D3D11_FILTER_TYPE + { + D3D11_FILTER_TYPE_POINT = 0, + D3D11_FILTER_TYPE_LINEAR = 1, + }; + + enum D3D11_FILTER_REDUCTION_TYPE + { + D3D11_FILTER_REDUCTION_TYPE_STANDARD = 0, + D3D11_FILTER_REDUCTION_TYPE_COMPARISON = 1, + D3D11_FILTER_REDUCTION_TYPE_MINIMUM = 2, + D3D11_FILTER_REDUCTION_TYPE_MAXIMUM = 3, + }; + + enum D3D11_FORMAT_SUPPORT + { + D3D11_FORMAT_SUPPORT_BUFFER = 0x1, + D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER = 0x2, + D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER = 0x4, + D3D11_FORMAT_SUPPORT_SO_BUFFER = 0x8, + D3D11_FORMAT_SUPPORT_TEXTURE1D = 0x10, + D3D11_FORMAT_SUPPORT_TEXTURE2D = 0x20, + D3D11_FORMAT_SUPPORT_TEXTURE3D = 0x40, + D3D11_FORMAT_SUPPORT_TEXTURECUBE = 0x80, + D3D11_FORMAT_SUPPORT_SHADER_LOAD = 0x100, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE = 0x200, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON = 0x400, + D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT = 0x800, + D3D11_FORMAT_SUPPORT_MIP = 0x1000, + D3D11_FORMAT_SUPPORT_MIP_AUTOGEN = 0x2000, + D3D11_FORMAT_SUPPORT_RENDER_TARGET = 0x4000, + D3D11_FORMAT_SUPPORT_BLENDABLE = 0x8000, + D3D11_FORMAT_SUPPORT_DEPTH_STENCIL = 0x10000, + D3D11_FORMAT_SUPPORT_CPU_LOCKABLE = 0x20000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE = 0x40000, + D3D11_FORMAT_SUPPORT_DISPLAY = 0x80000, + D3D11_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT = 0x100000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET = 0x200000, + D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD = 0x400000, + D3D11_FORMAT_SUPPORT_SHADER_GATHER = 0x800000, + D3D11_FORMAT_SUPPORT_BACK_BUFFER_CAST = 0x1000000, + D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW = 0x2000000, + D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON = 0x4000000, + D3D11_FORMAT_SUPPORT_DECODER_OUTPUT = 0x8000000, + D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_OUTPUT = 0x10000000, + D3D11_FORMAT_SUPPORT_VIDEO_PROCESSOR_INPUT = 0x20000000, + D3D11_FORMAT_SUPPORT_VIDEO_ENCODER = 0x40000000, + }; + + enum D3D11_FORMAT_SUPPORT2 + { + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_ADD = 0x1, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS = 0x2, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 0x4, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE = 0x8, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX = 0x10, + D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 0x20, + D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD = 0x40, + D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE = 0x80, + D3D11_FORMAT_SUPPORT2_OUTPUT_MERGER_LOGIC_OP = 0x100, + D3D11_FORMAT_SUPPORT2_TILED = 0x200, + D3D11_FORMAT_SUPPORT2_SHAREABLE = 0x400, + D3D11_FORMAT_SUPPORT2_MULTIPLANE_OVERLAY = 0x4000, + D3D11_FORMAT_SUPPORT2_DISPLAYABLE = 0x10000, + }; + + enum D3D11_INPUT_CLASSIFICATION + { + D3D11_INPUT_PER_VERTEX_DATA = 0, + D3D11_INPUT_PER_INSTANCE_DATA = 1, + }; + + enum D3D11_MAP + { + D3D11_MAP_READ = 1, + D3D11_MAP_WRITE = 2, + D3D11_MAP_READ_WRITE = 3, + D3D11_MAP_WRITE_DISCARD = 4, + D3D11_MAP_WRITE_NO_OVERWRITE = 5, + }; + + enum D3D11_MAP_FLAG + { + D3D11_MAP_FLAG_DO_NOT_WAIT = 0x100000L, + }; + + using D3D11_PRIMITIVE = D3D_PRIMITIVE; + using D3D11_PRIMITIVE_TOPOLOGY = D3D_PRIMITIVE_TOPOLOGY; + + enum D3D11_QUERY + { + D3D11_QUERY_EVENT = 0, + D3D11_QUERY_OCCLUSION = (D3D11_QUERY_EVENT + 1), + D3D11_QUERY_TIMESTAMP = (D3D11_QUERY_OCCLUSION + 1), + D3D11_QUERY_TIMESTAMP_DISJOINT = (D3D11_QUERY_TIMESTAMP + 1), + D3D11_QUERY_PIPELINE_STATISTICS = (D3D11_QUERY_TIMESTAMP_DISJOINT + 1), + D3D11_QUERY_OCCLUSION_PREDICATE = (D3D11_QUERY_PIPELINE_STATISTICS + 1), + D3D11_QUERY_SO_STATISTICS = (D3D11_QUERY_OCCLUSION_PREDICATE + 1), + D3D11_QUERY_SO_OVERFLOW_PREDICATE = (D3D11_QUERY_SO_STATISTICS + 1), + D3D11_QUERY_SO_STATISTICS_STREAM0 = (D3D11_QUERY_SO_OVERFLOW_PREDICATE + 1), + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0 = (D3D11_QUERY_SO_STATISTICS_STREAM0 + 1), + D3D11_QUERY_SO_STATISTICS_STREAM1 = (D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0 + 1), + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1 = (D3D11_QUERY_SO_STATISTICS_STREAM1 + 1), + D3D11_QUERY_SO_STATISTICS_STREAM2 = (D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1 + 1), + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2 = (D3D11_QUERY_SO_STATISTICS_STREAM2 + 1), + D3D11_QUERY_SO_STATISTICS_STREAM3 = (D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2 + 1), + D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3 = (D3D11_QUERY_SO_STATISTICS_STREAM3 + 1), + }; + + enum D3D11_QUERY_MISC_FLAG + { + D3D11_QUERY_MISC_PREDICATEHINT = 0x1, + }; + + enum D3D11_RAISE_FLAG + { + D3D11_RAISE_FLAG_DRIVER_INTERNAL_ERROR = 0x1L, + }; + + enum D3D11_RESOURCE_DIMENSION + { + D3D11_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D11_RESOURCE_DIMENSION_BUFFER = 1, + D3D11_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D11_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D11_RESOURCE_DIMENSION_TEXTURE3D = 4, + }; + + enum D3D11_RESOURCE_MISC_FLAG + { + D3D11_RESOURCE_MISC_GENERATE_MIPS = 0x1L, + D3D11_RESOURCE_MISC_SHARED = 0x2L, + D3D11_RESOURCE_MISC_TEXTURECUBE = 0x4L, + D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS = 0x10L, + D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS = 0x20L, + D3D11_RESOURCE_MISC_BUFFER_STRUCTURED = 0x40L, + D3D11_RESOURCE_MISC_RESOURCE_CLAMP = 0x80L, + D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x100L, + D3D11_RESOURCE_MISC_GDI_COMPATIBLE = 0x200L, + D3D11_RESOURCE_MISC_SHARED_NTHANDLE = 0x800L, + D3D11_RESOURCE_MISC_RESTRICTED_CONTENT = 0x1000L, + D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE = 0x2000L, + D3D11_RESOURCE_MISC_RESTRICT_SHARED_RESOURCE_DRIVER = 0x4000L, + D3D11_RESOURCE_MISC_GUARDED = 0x8000L, + D3D11_RESOURCE_MISC_TILE_POOL = 0x20000L, + D3D11_RESOURCE_MISC_TILED = 0x40000L, + D3D11_RESOURCE_MISC_HW_PROTECTED = 0x80000L, + D3D11_RESOURCE_MISC_SHARED_DISPLAYABLE = 0x100000L, + D3D11_RESOURCE_MISC_SHARED_EXCLUSIVE_WRITER = 0x200000L, + }; + + enum D3D11_RTV_DIMENSION + { + D3D11_RTV_DIMENSION_UNKNOWN = 0, + D3D11_RTV_DIMENSION_BUFFER = 1, + D3D11_RTV_DIMENSION_TEXTURE1D = 2, + D3D11_RTV_DIMENSION_TEXTURE1DARRAY = 3, + D3D11_RTV_DIMENSION_TEXTURE2D = 4, + D3D11_RTV_DIMENSION_TEXTURE2DARRAY = 5, + D3D11_RTV_DIMENSION_TEXTURE2DMS = 6, + D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D11_RTV_DIMENSION_TEXTURE3D = 8, + }; + + using D3D11_SRV_DIMENSION = D3D_SRV_DIMENSION; + + enum D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS + { + D3D11_STANDARD_MULTISAMPLE_PATTERN = 0xFFFFFFFF, + D3D11_CENTER_MULTISAMPLE_PATTERN = 0xFFFFFFFE, + }; + + enum D3D11_STENCIL_OP + { + D3D11_STENCIL_OP_KEEP = 1, + D3D11_STENCIL_OP_ZERO = 2, + D3D11_STENCIL_OP_REPLACE = 3, + D3D11_STENCIL_OP_INCR_SAT = 4, + D3D11_STENCIL_OP_DECR_SAT = 5, + D3D11_STENCIL_OP_INVERT = 6, + D3D11_STENCIL_OP_INCR = 7, + D3D11_STENCIL_OP_DECR = 8, + }; + + enum D3D11_TEXTURE_ADDRESS_MODE + { + D3D11_TEXTURE_ADDRESS_WRAP = 1, + D3D11_TEXTURE_ADDRESS_MIRROR = 2, + D3D11_TEXTURE_ADDRESS_CLAMP = 3, + D3D11_TEXTURE_ADDRESS_BORDER = 4, + D3D11_TEXTURE_ADDRESS_MIRROR_ONCE = 5, + }; + + enum D3D11_TEXTURECUBE_FACE + { + D3D11_TEXTURECUBE_FACE_POSITIVE_X = 0, + D3D11_TEXTURECUBE_FACE_NEGATIVE_X = 1, + D3D11_TEXTURECUBE_FACE_POSITIVE_Y = 2, + D3D11_TEXTURECUBE_FACE_NEGATIVE_Y = 3, + D3D11_TEXTURECUBE_FACE_POSITIVE_Z = 4, + D3D11_TEXTURECUBE_FACE_NEGATIVE_Z = 5, + }; + + enum D3D11_UAV_DIMENSION + { + D3D11_UAV_DIMENSION_UNKNOWN = 0, + D3D11_UAV_DIMENSION_BUFFER = 1, + D3D11_UAV_DIMENSION_TEXTURE1D = 2, + D3D11_UAV_DIMENSION_TEXTURE1DARRAY = 3, + D3D11_UAV_DIMENSION_TEXTURE2D = 4, + D3D11_UAV_DIMENSION_TEXTURE2DARRAY = 5, + D3D11_UAV_DIMENSION_TEXTURE3D = 8, + }; + + enum D3D11_USAGE + { + D3D11_USAGE_DEFAULT = 0, + D3D11_USAGE_IMMUTABLE = 1, + D3D11_USAGE_DYNAMIC = 2, + D3D11_USAGE_STAGING = 3, + }; + + enum D3D11_VDOV_DIMENSION + { + D3D11_VDOV_DIMENSION_UNKNOWN = 0, + D3D11_VDOV_DIMENSION_TEXTURE2D = 1, + }; + + enum D3D11_VPIV_DIMENSION + { + D3D11_VPIV_DIMENSION_UNKNOWN = 0, + D3D11_VPIV_DIMENSION_TEXTURE2D = 1, + }; + + enum D3D11_VPOV_DIMENSION + { + D3D11_VPOV_DIMENSION_UNKNOWN = 0, + D3D11_VPOV_DIMENSION_TEXTURE2D = 1, + D3D11_VPOV_DIMENSION_TEXTURE2DARRAY = 2, + }; + + enum D3D11_VIDEO_DECODER_BUFFER_TYPE + { + D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS = 0, + D3D11_VIDEO_DECODER_BUFFER_MACROBLOCK_CONTROL = 1, + D3D11_VIDEO_DECODER_BUFFER_RESIDUAL_DIFFERENCE = 2, + D3D11_VIDEO_DECODER_BUFFER_DEBLOCKING_CONTROL = 3, + D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX = 4, + D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL = 5, + D3D11_VIDEO_DECODER_BUFFER_BITSTREAM = 6, + D3D11_VIDEO_DECODER_BUFFER_MOTION_VECTOR = 7, + D3D11_VIDEO_DECODER_BUFFER_FILM_GRAIN = 8, + }; + + enum D3D11_VIDEO_FRAME_FORMAT + { + D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE = 0, + D3D11_VIDEO_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST = 1, + D3D11_VIDEO_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST = 2, + }; + + enum D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE + { + D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_OPAQUE = 0, + D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_BACKGROUND = 1, + D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_DESTINATION = 2, + D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE_SOURCE_STREAM = 3, + }; + + enum D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS + { + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_DENOISE = 0x1, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_DERINGING = 0x2, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_EDGE_ENHANCEMENT = 0x4, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_COLOR_CORRECTION = 0x8, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_FLESH_TONE_MAPPING = 0x10, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_IMAGE_STABILIZATION = 0x20, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_SUPER_RESOLUTION = 0x40, + D3D11_VIDEO_PROCESSOR_AUTO_STREAM_CAPS_ANAMORPHIC_SCALING = 0x80, + }; + + enum D3D11_VIDEO_PROCESSOR_DEVICE_CAPS + { + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_LINEAR_SPACE = 0x1, + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_xvYCC = 0x2, + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_RGB_RANGE_CONVERSION = 0x4, + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_YCbCr_MATRIX_CONVERSION = 0x8, + D3D11_VIDEO_PROCESSOR_DEVICE_CAPS_NOMINAL_RANGE = 0x10, + }; + + enum D3D11_VIDEO_PROCESSOR_FEATURE_CAPS + { + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_FILL = 0x1, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_CONSTRICTION = 0x2, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_LUMA_KEY = 0x4, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_PALETTE = 0x8, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_LEGACY = 0x10, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_STEREO = 0x20, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ROTATION = 0x40, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_STREAM = 0x80, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_PIXEL_ASPECT_RATIO = 0x100, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_MIRROR = 0x200, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_SHADER_USAGE = 0x400, + D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_METADATA_HDR10 = 0x800, + }; + + enum D3D11_VIDEO_PROCESSOR_FILTER + { + D3D11_VIDEO_PROCESSOR_FILTER_BRIGHTNESS = 0, + D3D11_VIDEO_PROCESSOR_FILTER_CONTRAST = 1, + D3D11_VIDEO_PROCESSOR_FILTER_HUE = 2, + D3D11_VIDEO_PROCESSOR_FILTER_SATURATION = 3, + D3D11_VIDEO_PROCESSOR_FILTER_NOISE_REDUCTION = 4, + D3D11_VIDEO_PROCESSOR_FILTER_EDGE_ENHANCEMENT = 5, + D3D11_VIDEO_PROCESSOR_FILTER_ANAMORPHIC_SCALING = 6, + D3D11_VIDEO_PROCESSOR_FILTER_STEREO_ADJUSTMENT = 7, + }; + + enum D3D11_VIDEO_PROCESSOR_FILTER_CAPS + { + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_BRIGHTNESS = 0x1, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_CONTRAST = 0x2, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_HUE = 0x4, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_SATURATION = 0x8, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_NOISE_REDUCTION = 0x10, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_EDGE_ENHANCEMENT = 0x20, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_ANAMORPHIC_SCALING = 0x40, + D3D11_VIDEO_PROCESSOR_FILTER_CAPS_STEREO_ADJUSTMENT = 0x80, + }; + + enum D3D11_VIDEO_PROCESSOR_FORMAT_CAPS + { + D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_INTERLACED = 0x1, + D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_PROCAMP = 0x2, + D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_RGB_LUMA_KEY = 0x4, + D3D11_VIDEO_PROCESSOR_FORMAT_CAPS_PALETTE_INTERLACED = 0x8, + }; + + enum D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT + { + D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT_INPUT = 0x1, + D3D11_VIDEO_PROCESSOR_FORMAT_SUPPORT_OUTPUT = 0x2, + }; + + enum D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS + { + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_32 = 0x1, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_22 = 0x2, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_2224 = 0x4, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_2332 = 0x8, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_32322 = 0x10, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_55 = 0x20, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_64 = 0x40, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_87 = 0x80, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_222222222223 = 0x100, + D3D11_VIDEO_PROCESSOR_ITELECINE_CAPS_OTHER = 0x80000000, + }; + + enum D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE + { + D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_UNDEFINED = 0, + D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_16_235 = 1, + D3D11_VIDEO_PROCESSOR_NOMINAL_RANGE_0_255 = 2, + }; + + enum D3D11_VIDEO_PROCESSOR_OUTPUT_RATE + { + D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_NORMAL = 0, + D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_HALF = 1, + D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_CUSTOM = 2, + }; + + enum D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS + { + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BLEND = 0x1, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BOB = 0x2, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_ADAPTIVE = 0x4, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_MOTION_COMPENSATION = 0x8, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_INVERSE_TELECINE = 0x10, + D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_FRAME_RATE_CONVERSION = 0x20, + }; + + enum D3D11_VIDEO_PROCESSOR_ROTATION + { + D3D11_VIDEO_PROCESSOR_ROTATION_IDENTITY = 0, + D3D11_VIDEO_PROCESSOR_ROTATION_90 = 1, + D3D11_VIDEO_PROCESSOR_ROTATION_180 = 2, + D3D11_VIDEO_PROCESSOR_ROTATION_270 = 3, + }; + + enum D3D11_VIDEO_PROCESSOR_STEREO_CAPS + { + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_MONO_OFFSET = 0x1, + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_ROW_INTERLEAVED = 0x2, + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_COLUMN_INTERLEAVED = 0x4, + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_CHECKERBOARD = 0x8, + D3D11_VIDEO_PROCESSOR_STEREO_CAPS_FLIP_MODE = 0x10, + }; + + enum D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE + { + D3D11_VIDEO_PROCESSOR_STEREO_FLIP_NONE = 0, + D3D11_VIDEO_PROCESSOR_STEREO_FLIP_FRAME0 = 1, + D3D11_VIDEO_PROCESSOR_STEREO_FLIP_FRAME1 = 2, + }; + + enum D3D11_VIDEO_PROCESSOR_STEREO_FORMAT + { + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_MONO = 0, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_HORIZONTAL = 1, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_VERTICAL = 2, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_SEPARATE = 3, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_MONO_OFFSET = 4, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_ROW_INTERLEAVED = 5, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_COLUMN_INTERLEAVED = 6, + D3D11_VIDEO_PROCESSOR_STEREO_FORMAT_CHECKERBOARD = 7, + }; + + enum D3D11_VIDEO_USAGE + { + D3D11_VIDEO_USAGE_PLAYBACK_NORMAL = 0, + D3D11_VIDEO_USAGE_OPTIMAL_SPEED = 1, + D3D11_VIDEO_USAGE_OPTIMAL_QUALITY = 2, + }; +} + +namespace REX::W32 +{ + using D3D11_RECT = RECT; + + struct D3D11_AES_CTR_IV + { + std::uint64_t iv; + std::uint64_t count; + }; + + struct D3D11_BOX + { + std::uint32_t left; + std::uint32_t top; + std::uint32_t front; + std::uint32_t right; + std::uint32_t bottom; + std::uint32_t back; + }; + + struct D3D11_BUFFER_DESC + { + std::uint32_t byteWidth; + D3D11_USAGE usage; + std::uint32_t bindFlags; + std::uint32_t cpuAccessFlags; + std::uint32_t miscFlags; + std::uint32_t structureByteStride; + }; + + struct D3D11_BUFFER_RTV + { + union + { + std::uint32_t firstElement; + std::uint32_t elementOffset; + }; + union + { + std::uint32_t numElements; + std::uint32_t elementWidth; + }; + }; + + struct D3D11_BUFFER_SRV + { + union + { + std::uint32_t firstElement; + std::uint32_t elementOffset; + }; + union + { + std::uint32_t numElements; + std::uint32_t elementWidth; + }; + }; + + struct D3D11_BUFFER_UAV + { + std::uint32_t firstElement; + std::uint32_t numElements; + std::uint32_t flags; + }; + + struct D3D11_BUFFEREX_SRV + { + std::uint32_t firstElement; + std::uint32_t numElements; + std::uint32_t flags; + }; + + struct D3D11_CLASS_INSTANCE_DESC + { + std::uint32_t instanceId; + std::uint32_t instanceIndex; + std::uint32_t typeId; + std::uint32_t constantBuffer; + std::uint32_t baseConstantBufferOffset; + std::uint32_t baseTexture; + std::uint32_t baseSampler; + BOOL created; + }; + + struct D3D11_COUNTER_DESC + { + D3D11_COUNTER counter; + std::uint32_t miscFlags; + }; + + struct D3D11_COUNTER_INFO + { + D3D11_COUNTER lastDeviceDependentCounter; + std::uint32_t numSimultaneousCounters; + std::uint8_t numDetectableParallelUnits; + }; + + struct D3D11_DRAW_INSTANCED_INDIRECT_ARGS + { + std::uint32_t vertexCountPerInstance; + std::uint32_t instanceCount; + std::uint32_t startVertexLocation; + std::uint32_t startInstanceLocation; + }; + + struct D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS + { + std::uint32_t indexCountPerInstance; + std::uint32_t instanceCount; + std::uint32_t startIndexLocation; + std::int32_t baseVertexLocation; + std::uint32_t startInstanceLocation; + }; + + struct D3D11_ENCRYPTED_BLOCK_INFO + { + std::uint32_t numEncryptedBytesAtBeginning; + std::uint32_t numBytesInSkipPattern; + std::uint32_t numBytesInEncryptPattern; + }; + + struct D3D11_INPUT_ELEMENT_DESC + { + const char* semanticName; + std::uint32_t semanticIndex; + DXGI_FORMAT format; + std::uint32_t inputSlot; + std::uint32_t alignedByteOffset; + D3D11_INPUT_CLASSIFICATION inputSlotClass; + std::uint32_t instanceDataStepRate; + }; + + struct D3D11_MAPPED_SUBRESOURCE + { + void* data; + std::uint32_t rowPitch; + std::uint32_t depthPitch; + }; + + struct D3D11_QUERY_DATA_PIPELINE_STATISTICS + { + std::uint64_t iaVertices; + std::uint64_t iaPrimitives; + std::uint64_t vsInvocations; + std::uint64_t gsInvocations; + std::uint64_t gsPrimitives; + std::uint64_t cInvocations; + std::uint64_t cPrimitives; + std::uint64_t psInvocations; + std::uint64_t hsInvocations; + std::uint64_t dsInvocations; + std::uint64_t csInvocations; + }; + + struct D3D11_QUERY_DATA_SO_STATISTICS + { + std::uint64_t numPrimitivesWritten; + std::uint64_t primitivesStorageNeeded; + }; + + struct D3D11_QUERY_DATA_TIMESTAMP_DISJOINT + { + std::uint64_t frequency; + BOOL disjoint; + }; + + struct D3D11_QUERY_DESC + { + D3D11_QUERY query; + std::uint32_t miscFlags; + }; + + struct D3D11_RASTERIZER_DESC + { + D3D11_FILL_MODE fillMode; + D3D11_CULL_MODE cullMode; + BOOL frontCounterClockwise; + std::int32_t depthBias; + float depthBiasClamp; + float slopeScaledDepthBias; + BOOL depthClipEnable; + BOOL scissorEnable; + BOOL multisampleEnable; + BOOL antialiasedLineEnable; + }; + + struct D3D11_RENDER_TARGET_BLEND_DESC + { + BOOL blendEnable; + D3D11_BLEND srcBlend; + D3D11_BLEND destBlend; + D3D11_BLEND_OP blendOp; + D3D11_BLEND srcBlendAlpha; + D3D11_BLEND destBlendAlpha; + D3D11_BLEND_OP blendOpAlpha; + std::uint8_t renderTargetWriteMask; + }; + + struct D3D11_BLEND_DESC + { + BOOL alphaToCoverageEnable; + BOOL independentBlendEnable; + D3D11_RENDER_TARGET_BLEND_DESC renderTarget[8]; + }; + + struct D3D11_SO_DECLARATION_ENTRY + { + std::uint32_t stream; + const char* semanticName; + std::uint32_t semanticIndex; + std::uint8_t startComponent; + std::uint8_t componentCount; + std::uint8_t outputSlot; + }; + + struct D3D11_SAMPLER_DESC + { + D3D11_FILTER filter; + D3D11_TEXTURE_ADDRESS_MODE addressU; + D3D11_TEXTURE_ADDRESS_MODE addressV; + D3D11_TEXTURE_ADDRESS_MODE addressW; + float mipLODBias; + std::uint32_t maxAnisotropy; + D3D11_COMPARISON_FUNC comparisonFunc; + float borderColor[4]; + float minLOD; + float maxLOD; + }; + + struct D3D11_SUBRESOURCE_DATA + { + const void* sysMem; + std::uint32_t sysMemPitch; + std::uint32_t sysMemSlicePitch; + }; + + struct D3D11_TEX1D_DSV + { + std::uint32_t mipSlice; + }; + + struct D3D11_TEX1D_RTV + { + std::uint32_t mipSlice; + }; + + struct D3D11_TEX1D_SRV + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + }; + + struct D3D11_TEX1D_UAV + { + std::uint32_t mipSlice; + }; + + struct D3D11_TEX1D_ARRAY_DSV + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX1D_ARRAY_RTV + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX1D_ARRAY_SRV + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX1D_ARRAY_UAV + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX2D_DSV + { + std::uint32_t mipSlice; + }; + + struct D3D11_TEX2D_RTV + { + std::uint32_t mipSlice; + }; + + struct D3D11_TEX2D_SRV + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + }; + + struct D3D11_TEX2D_UAV + { + std::uint32_t mipSlice; + }; + + struct D3D11_TEX2D_VDOV + { + std::uint32_t arraySlice; + }; + + struct D3D11_TEX2D_VPIV + { + std::uint32_t mipSlice; + std::uint32_t arraySlice; + }; + + struct D3D11_TEX2D_VPOV + { + std::uint32_t mipSlice; + }; + + struct D3D11_TEX2D_ARRAY_DSV + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX2D_ARRAY_RTV + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX2D_ARRAY_SRV + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX2D_ARRAY_UAV + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX2D_ARRAY_VPOV + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX2DMS_DSV + { + std::uint32_t _unusedField_NothingToDefine; + }; + + struct D3D11_TEX2DMS_RTV + { + std::uint32_t _unusedField_NothingToDefine; + }; + + struct D3D11_TEX2DMS_SRV + { + std::uint32_t _unusedField_NothingToDefine; + }; + + struct D3D11_TEX2DMS_ARRAY_DSV + { + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX2DMS_ARRAY_RTV + { + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX2DMS_ARRAY_SRV + { + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + }; + + struct D3D11_TEX3D_RTV + { + std::uint32_t mipSlice; + std::uint32_t firstWSlice; + std::uint32_t wSize; + }; + + struct D3D11_TEX3D_SRV + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + }; + + struct D3D11_TEX3D_UAV + { + std::uint32_t mipSlice; + std::uint32_t firstWSlice; + std::uint32_t wSize; + }; + + struct D3D11_TEXCUBE_SRV + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + }; + + struct D3D11_TEXCUBE_ARRAY_SRV + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + std::uint32_t first2DArrayFace; + std::uint32_t numCubes; + }; + + struct D3D11_DEPTH_STENCILOP_DESC + { + D3D11_STENCIL_OP stencilFailOp; + D3D11_STENCIL_OP stencilDepthFailOp; + D3D11_STENCIL_OP stencilPassOp; + D3D11_COMPARISON_FUNC stencilFunc; + }; + + struct D3D11_DEPTH_STENCIL_DESC + { + BOOL depthEnable; + D3D11_DEPTH_WRITE_MASK depthWriteMask; + D3D11_COMPARISON_FUNC depthFunc; + BOOL stencilEnable; + std::uint8_t stencilReadMask; + std::uint8_t stencilWriteMask; + D3D11_DEPTH_STENCILOP_DESC frontFace; + D3D11_DEPTH_STENCILOP_DESC backFace; + }; + + struct D3D11_DEPTH_STENCIL_VIEW_DESC + { + DXGI_FORMAT format; + D3D11_DSV_DIMENSION viewDimension; + std::uint32_t flags; + union + { + D3D11_TEX1D_DSV texture1D; + D3D11_TEX1D_ARRAY_DSV texture1DArray; + D3D11_TEX2D_DSV texture2D; + D3D11_TEX2D_ARRAY_DSV texture2DArray; + D3D11_TEX2DMS_DSV texture2DMS; + D3D11_TEX2DMS_ARRAY_DSV texture2DMSArray; + }; + }; + + struct D3D11_OMAC + { + std::uint8_t omac[16]; + }; + + struct D3D11_AUTHENTICATED_CONFIGURE_OUTPUT + { + D3D11_OMAC omac; + GUID configureType; + HANDLE channel; + std::uint32_t sequenceNumber; + HRESULT returnCode; + }; + + struct D3D11_RENDER_TARGET_VIEW_DESC + { + DXGI_FORMAT format; + D3D11_RTV_DIMENSION viewDimension; + union + { + D3D11_BUFFER_RTV buffer; + D3D11_TEX1D_RTV texture1D; + D3D11_TEX1D_ARRAY_RTV texture1DArray; + D3D11_TEX2D_RTV texture2D; + D3D11_TEX2D_ARRAY_RTV texture2DArray; + D3D11_TEX2DMS_RTV texture2DMS; + D3D11_TEX2DMS_ARRAY_RTV texture2DMSArray; + D3D11_TEX3D_RTV texture3D; + }; + }; + + struct D3D11_SHADER_RESOURCE_VIEW_DESC + { + DXGI_FORMAT format; + D3D11_SRV_DIMENSION viewDimension; + union + { + D3D11_BUFFER_SRV buffer; + D3D11_TEX1D_SRV texture1D; + D3D11_TEX1D_ARRAY_SRV texture1DArray; + D3D11_TEX2D_SRV texture2D; + D3D11_TEX2D_ARRAY_SRV texture2DArray; + D3D11_TEX2DMS_SRV texture2DMS; + D3D11_TEX2DMS_ARRAY_SRV texture2DMSArray; + D3D11_TEX3D_SRV texture3D; + D3D11_TEXCUBE_SRV textureCube; + D3D11_TEXCUBE_ARRAY_SRV textureCubeArray; + D3D11_BUFFEREX_SRV bufferEx; + }; + }; + + struct D3D11_TEXTURE1D_DESC + { + std::uint32_t width; + std::uint32_t mipLevels; + std::uint32_t arraySize; + DXGI_FORMAT format; + D3D11_USAGE usage; + std::uint32_t bindFlags; + std::uint32_t cpuAccessFlags; + std::uint32_t miscFlags; + }; + + struct D3D11_TEXTURE2D_DESC + { + std::uint32_t width; + std::uint32_t height; + std::uint32_t mipLevels; + std::uint32_t arraySize; + DXGI_FORMAT format; + DXGI_SAMPLE_DESC sampleDesc; + D3D11_USAGE usage; + std::uint32_t bindFlags; + std::uint32_t cpuAccessFlags; + std::uint32_t miscFlags; + }; + + struct D3D11_TEXTURE3D_DESC + { + std::uint32_t width; + std::uint32_t height; + std::uint32_t depth; + std::uint32_t mipLevels; + DXGI_FORMAT format; + D3D11_USAGE usage; + std::uint32_t bindFlags; + std::uint32_t cpuAccessFlags; + std::uint32_t miscFlags; + }; + + struct D3D11_UNORDERED_ACCESS_VIEW_DESC + { + DXGI_FORMAT format; + D3D11_UAV_DIMENSION viewDimension; + union + { + D3D11_BUFFER_UAV buffer; + D3D11_TEX1D_UAV texture1D; + D3D11_TEX1D_ARRAY_UAV texture1DArray; + D3D11_TEX2D_UAV texture2D; + D3D11_TEX2D_ARRAY_UAV texture2DArray; + D3D11_TEX3D_UAV texture3D; + }; + }; + + struct D3D11_VIDEO_COLOR_RGBA + { + float r; + float g; + float b; + float a; + }; + + struct D3D11_VIDEO_COLOR_YCbCrA + { + float y; + float cb; + float cr; + float a; + }; + + struct D3D11_VIDEO_COLOR + { + union + { + D3D11_VIDEO_COLOR_YCbCrA ycbcr; + D3D11_VIDEO_COLOR_RGBA rgba; + }; + }; + + struct D3D11_VIDEO_CONTENT_PROTECTION_CAPS + { + std::uint32_t caps; + std::uint32_t keyExchangeTypeCount; + std::uint32_t blockAlignmentSize; + std::uint64_t protectedMemorySize; + }; + + struct D3D11_VIDEO_DECODER_BUFFER_DESC + { + D3D11_VIDEO_DECODER_BUFFER_TYPE bufferType; + std::uint32_t bufferIndex; + std::uint32_t dataOffset; + std::uint32_t dataSize; + std::uint32_t firstMBAddress; + std::uint32_t numMBsInBuffer; + std::uint32_t width; + std::uint32_t height; + std::uint32_t stride; + std::uint32_t reservedBits; + void* iv; + std::uint32_t ivSize; + BOOL partialEncryption; + D3D11_ENCRYPTED_BLOCK_INFO encryptedBlockInfo; + }; + + struct D3D11_VIDEO_DECODER_CONFIG + { + GUID guidConfigBitstreamEncryption; + GUID guidConfigMBControlEncryption; + GUID guidConfigResidDiffEncryption; + std::uint32_t configBitstreamRaw; + std::uint32_t configMBControlRasterOrder; + std::uint32_t configResidDiffHost; + std::uint32_t configSpatialResid8; + std::uint32_t configResid8Subtraction; + std::uint32_t configSpatialHost8or9Clipping; + std::uint32_t configSpatialResidInterleaved; + std::uint32_t configIntraResidUnsigned; + std::uint32_t configResidDiffAccelerator; + std::uint32_t configHostInverseScan; + std::uint32_t configSpecificIDCT; + std::uint32_t config4GroupedCoefs; + std::uint16_t configMinRenderTargetBuffCount; + std::uint16_t configDecoderSpecific; + }; + + struct D3D11_VIDEO_DECODER_DESC + { + GUID guid; + std::uint32_t sampleWidth; + std::uint32_t sampleHeight; + DXGI_FORMAT outputFormat; + }; + + struct D3D11_VIDEO_DECODER_EXTENSION + { + std::uint32_t function; + void* privateInputData; + std::uint32_t privateInputDataSize; + void* privateOutputData; + std::uint32_t privateOutputDataSize; + std::uint32_t resourceCount; + ID3D11Resource** resourceList; + }; + + struct D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC + { + GUID decodeProfile; + D3D11_VDOV_DIMENSION viewDimension; + union + { + D3D11_TEX2D_VDOV texture2D; + }; + }; + + struct D3D11_VIDEO_PROCESSOR_CAPS + { + std::uint32_t aeviceCaps; + std::uint32_t featureCaps; + std::uint32_t filterCaps; + std::uint32_t inputFormatCaps; + std::uint32_t autoStreamCaps; + std::uint32_t stereoCaps; + std::uint32_t rateConversionCapsCount; + std::uint32_t maxInputStreams; + std::uint32_t maxStreamStates; + }; + + struct D3D11_VIDEO_PROCESSOR_COLOR_SPACE + { + std::uint32_t usage : 1; + std::uint32_t rgb_Range : 1; + std::uint32_t yCbCr_Matrix : 1; + std::uint32_t yCbCr_xvYCC : 1; + std::uint32_t nominal_Range : 2; + std::uint32_t reserved : 26; + }; + + struct D3D11_VIDEO_PROCESSOR_CONTENT_DESC + { + D3D11_VIDEO_FRAME_FORMAT inputFrameFormat; + DXGI_RATIONAL inputFrameRate; + std::uint32_t inputWidth; + std::uint32_t inputHeight; + DXGI_RATIONAL outputFrameRate; + std::uint32_t outputWidth; + std::uint32_t outputHeight; + D3D11_VIDEO_USAGE usage; + }; + + struct D3D11_VIDEO_PROCESSOR_CUSTOM_RATE + { + DXGI_RATIONAL customRate; + std::uint32_t outputFrames; + BOOL inputInterlaced; + std::uint32_t inputFramesOrFields; + }; + + struct D3D11_VIDEO_PROCESSOR_FILTER_RANGE + { + std::int32_t min; + std::int32_t max; + std::int32_t def; + float mult; + }; + + struct D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC + { + std::uint32_t fourCC; + D3D11_VPIV_DIMENSION viewDimension; + union + { + D3D11_TEX2D_VPIV texture2D; + }; + }; + + struct D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC + { + D3D11_VPOV_DIMENSION viewDimension; + union + { + D3D11_TEX2D_VPOV texture2D; + D3D11_TEX2D_ARRAY_VPOV texture2DArray; + }; + }; + + struct D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS + { + std::uint32_t pastFrames; + std::uint32_t futureFrames; + std::uint32_t processorCaps; + std::uint32_t iTelecineCaps; + std::uint32_t customRateCount; + }; + + struct D3D11_VIDEO_PROCESSOR_STREAM + { + BOOL enable; + std::uint32_t outputIndex; + std::uint32_t inputFrameOrField; + std::uint32_t pastFrames; + std::uint32_t futureFrames; + ID3D11VideoProcessorInputView** pastSurfaces; + ID3D11VideoProcessorInputView* inputSurface; + ID3D11VideoProcessorInputView** futureSurfaces; + ID3D11VideoProcessorInputView** pastSurfacesRight; + ID3D11VideoProcessorInputView* inputSurfaceRight; + ID3D11VideoProcessorInputView** futureSurfacesRight; + }; + + struct D3D11_VIEWPORT + { + float topLeftX; + float topLeftY; + float width; + float height; + float minDepth; + float maxDepth; + + friend bool operator==(const D3D11_VIEWPORT& a_lhs, const D3D11_VIEWPORT& a_rhs) + { + return a_lhs.topLeftX == a_rhs.topLeftX && a_lhs.topLeftY == a_rhs.topLeftY && a_lhs.width == a_rhs.width && + a_lhs.height == a_rhs.height && a_lhs.minDepth == a_rhs.minDepth && a_lhs.maxDepth == a_rhs.maxDepth; + } + + friend bool operator!=(const D3D11_VIEWPORT& a_lhs, const D3D11_VIEWPORT& a_rhs) + { + return !(a_lhs == a_rhs); + } + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("db6f6ddb-ac77-4e88-8253-819df9bbf140")) + ID3D11Device : public IUnknown + { + virtual HRESULT CreateBuffer(const D3D11_BUFFER_DESC* a_desc, const D3D11_SUBRESOURCE_DATA* a_initialData, ID3D11Buffer** a_buffer) = 0; + virtual HRESULT CreateTexture1D(const D3D11_TEXTURE1D_DESC* a_desc, const D3D11_SUBRESOURCE_DATA* a_initialData, ID3D11Texture1D** a_texture1D) = 0; + virtual HRESULT CreateTexture2D(const D3D11_TEXTURE2D_DESC* a_desc, const D3D11_SUBRESOURCE_DATA* a_initialData, ID3D11Texture2D** a_texture2D) = 0; + virtual HRESULT CreateTexture3D(const D3D11_TEXTURE3D_DESC* a_desc, const D3D11_SUBRESOURCE_DATA* a_initialData, ID3D11Texture3D** a_texture3D) = 0; + virtual HRESULT CreateShaderResourceView(ID3D11Resource* a_resource, const D3D11_SHADER_RESOURCE_VIEW_DESC* a_desc, ID3D11ShaderResourceView** a_srView) = 0; + virtual HRESULT CreateUnorderedAccessView(ID3D11Resource* a_resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC* a_desc, ID3D11UnorderedAccessView** a_uaView) = 0; + virtual HRESULT CreateRenderTargetView(ID3D11Resource* a_resource, const D3D11_RENDER_TARGET_VIEW_DESC* a_desc, ID3D11RenderTargetView** a_rtView) = 0; + virtual HRESULT CreateDepthStencilView(ID3D11Resource* a_resource, const D3D11_DEPTH_STENCIL_VIEW_DESC* a_desc, ID3D11DepthStencilView** a_dsView) = 0; + virtual HRESULT CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC* a_desc, std::uint32_t a_numElements, const void* a_shaderBytecodeWithInputSignature, std::size_t a_bytecodeLength, ID3D11InputLayout** a_inputLayout) = 0; + virtual HRESULT CreateVertexShader(const void* a_shaderBytecode, std::size_t a_bytecodeLength, ID3D11ClassLinkage* a_classLinkage, ID3D11VertexShader** a_vertexShader) = 0; + virtual HRESULT CreateGeometryShader(const void* a_shaderBytecode, std::size_t a_bytecodeLength, ID3D11ClassLinkage* a_classLinkage, ID3D11GeometryShader** a_geometryShader) = 0; + virtual HRESULT CreateGeometryShaderWithStreamOutput(const void* a_shaderBytecode, std::size_t a_bytecodeLength, const D3D11_SO_DECLARATION_ENTRY* a_soDeclaration, std::uint32_t a_numEntries, const std::uint32_t* a_bufferStrides, std::uint32_t a_numStrides, std::uint32_t a_rasterizedStream, ID3D11ClassLinkage* a_classLinkage, ID3D11GeometryShader** a_geometryShader) = 0; + virtual HRESULT CreatePixelShader(const void* a_shaderBytecode, std::size_t a_bytecodeLength, ID3D11ClassLinkage* a_classLinkage, ID3D11PixelShader** a_pixelShader) = 0; + virtual HRESULT CreateHullShader(const void* a_shaderBytecode, std::size_t a_bytecodeLength, ID3D11ClassLinkage* a_classLinkage, ID3D11HullShader** a_hullShader) = 0; + virtual HRESULT CreateDomainShader(const void* a_shaderBytecode, std::size_t a_bytecodeLength, ID3D11ClassLinkage* a_classLinkage, ID3D11DomainShader** a_domainShader) = 0; + virtual HRESULT CreateComputeShader(const void* a_shaderBytecode, std::size_t a_bytecodeLength, ID3D11ClassLinkage* a_classLinkage, ID3D11ComputeShader** a_computeShader) = 0; + virtual HRESULT CreateClassLinkage(ID3D11ClassLinkage** a_classLinkage) = 0; + virtual HRESULT CreateBlendState(const D3D11_BLEND_DESC* a_blendStateDesc, ID3D11BlendState** a_blendState) = 0; + virtual HRESULT CreateDepthStencilState(const D3D11_DEPTH_STENCIL_DESC* a_depthStencilDesc, ID3D11DepthStencilState** a_depthStencilState) = 0; + virtual HRESULT CreateRasterizerState(const D3D11_RASTERIZER_DESC* a_rasterizerDesc, ID3D11RasterizerState** a_rasterizerState) = 0; + virtual HRESULT CreateSamplerState(const D3D11_SAMPLER_DESC* a_samplerDesc, ID3D11SamplerState** a_samplerState) = 0; + virtual HRESULT CreateQuery(const D3D11_QUERY_DESC* a_queryDesc, ID3D11Query** a_query) = 0; + virtual HRESULT CreatePredicate(const D3D11_QUERY_DESC* a_predicateDesc, ID3D11Predicate** a_predicate) = 0; + virtual HRESULT CreateCounter(const D3D11_COUNTER_DESC* a_counterDesc, ID3D11Counter** a_counter) = 0; + virtual HRESULT CreateDeferredContext(std::uint32_t a_contextFlags, ID3D11DeviceContext** a_deferredContext) = 0; + virtual HRESULT OpenSharedResource(HANDLE a_resourceHandle, const IID& a_returnedInterface, void** a_resource) = 0; + virtual HRESULT CheckFormatSupport(DXGI_FORMAT a_format, std::uint32_t* a_formatSupport) = 0; + virtual HRESULT CheckMultisampleQualityLevels(DXGI_FORMAT a_format, std::uint32_t a_sampleCount, std::uint32_t* a_numQualityLevels) = 0; + virtual void CheckCounterInfo(D3D11_COUNTER_INFO* a_counterInfo) = 0; + virtual HRESULT CheckCounter(const D3D11_COUNTER_DESC* a_desc, D3D11_COUNTER_TYPE* a_type, std::uint32_t* a_activeCounters, char* a_name, std::uint32_t* a_nameLength, char* a_units, std::uint32_t* a_unitsLength, char* a_description, std::uint32_t* a_descriptionLength) = 0; + virtual HRESULT CheckFeatureSupport(D3D11_FEATURE a_feature, void* a_featureSupportData, std::uint32_t a_featureSupportDataSize) = 0; + virtual HRESULT GetPrivateData(const GUID& a_guid, std::uint32_t* a_dataSize, void* a_data) = 0; + virtual HRESULT SetPrivateData(const GUID& a_guid, std::uint32_t a_dataSize, const void* a_data) = 0; + virtual HRESULT SetPrivateDataInterface(const GUID& a_guid, const IUnknown* a_data) = 0; + virtual D3D_FEATURE_LEVEL GetFeatureLevel(void) = 0; + virtual std::uint32_t GetCreationFlags(void) = 0; + virtual HRESULT GetDeviceRemovedReason(void) = 0; + virtual void GetImmediateContext(ID3D11DeviceContext** a_immediateContext) = 0; + virtual HRESULT SetExceptionMode(std::uint32_t a_raiseFlags) = 0; + virtual std::uint32_t GetExceptionMode(void) = 0; + }; + + struct __declspec(novtable, uuid("1841e5c8-16b0-489b-bcc8-44cfb0d5deae")) + ID3D11DeviceChild : public IUnknown + { + virtual void GetDevice(ID3D11Device** a_device) = 0; + virtual HRESULT GetPrivateData(const GUID& a_guid, std::uint32_t* a_dataSize, void* a_data) = 0; + virtual HRESULT SetPrivateData(const GUID& a_guid, std::uint32_t a_dataSize, const void* a_data) = 0; + virtual HRESULT SetPrivateDataInterface(const GUID& a_guid, const IUnknown* a_data) = 0; + }; + + struct __declspec(novtable, uuid("c0bfa96c-e089-44fb-8eaf-26f8796190da")) + ID3D11DeviceContext : public ID3D11DeviceChild + { + virtual void VSSetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers) = 0; + virtual void PSSetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView* const* a_shaderResourceViews) = 0; + virtual void PSSetShader(ID3D11PixelShader* a_pixelShader, ID3D11ClassInstance* const* a_classInstances, std::uint32_t a_numClassInstances) = 0; + virtual void PSSetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState* const* a_samplers) = 0; + virtual void VSSetShader(ID3D11VertexShader* a_vertexShader, ID3D11ClassInstance* const* a_classInstances, std::uint32_t a_numClassInstances) = 0; + virtual void DrawIndexed(std::uint32_t IndexCount, std::uint32_t a_startIndexLocation, std::int32_t a_baseVertexLocation) = 0; + virtual void Draw(std::uint32_t a_vertexCount, std::uint32_t a_startVertexLocation) = 0; + virtual HRESULT Map(ID3D11Resource* a_resource, std::uint32_t a_subResource, D3D11_MAP a_mapType, std::uint32_t a_mapFlags, D3D11_MAPPED_SUBRESOURCE* a_mappedResource) = 0; + virtual void Unmap(ID3D11Resource* a_resource, std::uint32_t a_subResource) = 0; + virtual void PSSetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers) = 0; + virtual void IASetInputLayout(ID3D11InputLayout* a_inputLayout) = 0; + virtual void IASetVertexBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_vertexBuffers, const std::uint32_t* a_strides, const std::uint32_t* a_offsets) = 0; + virtual void IASetIndexBuffer(ID3D11Buffer* a_indexBuffer, DXGI_FORMAT a_format, std::uint32_t a_offset) = 0; + virtual void DrawIndexedInstanced(std::uint32_t a_indexCountPerInstance, std::uint32_t a_instanceCount, std::uint32_t a_startIndexLocation, std::int32_t a_baseVertexLocation, std::uint32_t a_startInstanceLocation) = 0; + virtual void DrawInstanced(std::uint32_t a_vertexCountPerInstance, std::uint32_t a_instanceCount, std::uint32_t a_startVertexLocation, std::uint32_t a_startInstanceLocation) = 0; + virtual void GSSetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers) = 0; + virtual void GSSetShader(ID3D11GeometryShader* a_shader, ID3D11ClassInstance* const* a_classInstances, std::uint32_t a_numClassInstances) = 0; + virtual void IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY a_topology) = 0; + virtual void VSSetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView* const* a_shaderResourceViews) = 0; + virtual void VSSetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState* const* a_samplers) = 0; + virtual void Begin(ID3D11Asynchronous* a_async) = 0; + virtual void End(ID3D11Asynchronous* a_async) = 0; + virtual HRESULT GetData(ID3D11Asynchronous* a_async, void* a_data, std::uint32_t a_dataSize, std::uint32_t a_getDataFlags) = 0; + virtual void SetPredication(ID3D11Predicate* a_predicate, BOOL a_predicateValue) = 0; + virtual void GSSetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView* const* a_shaderResourceViews) = 0; + virtual void GSSetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState* const* a_samplers) = 0; + virtual void OMSetRenderTargets(std::uint32_t a_numViews, ID3D11RenderTargetView* const* a_renderTargetViews, ID3D11DepthStencilView* a_depthStencilView) = 0; + virtual void OMSetRenderTargetsAndUnorderedAccessViews(std::uint32_t a_numRTVs, ID3D11RenderTargetView* const* a_renderTargetViews, ID3D11DepthStencilView* a_depthStencilView, std::uint32_t a_uavStartSlot, std::uint32_t a_numUAVs, ID3D11UnorderedAccessView* const* a_unorderedAccessViews, const std::uint32_t* a_uavInitialCounts) = 0; + virtual void OMSetBlendState(ID3D11BlendState* a_blendState, const float a_blendFactor[4], std::uint32_t a_sampleMask) = 0; + virtual void OMSetDepthStencilState(ID3D11DepthStencilState* a_depthStencilState, std::uint32_t a_stencilRef) = 0; + virtual void SOSetTargets(std::uint32_t a_numBuffers, ID3D11Buffer* const* a_soTargets, const std::uint32_t* a_offsets) = 0; + virtual void DrawAuto(void) = 0; + virtual void DrawIndexedInstancedIndirect(ID3D11Buffer* a_bufferForArgs, std::uint32_t a_alignedByteOffsetForArgs) = 0; + virtual void DrawInstancedIndirect(ID3D11Buffer* a_bufferForArgs, std::uint32_t a_alignedByteOffsetForArgs) = 0; + virtual void Dispatch(std::uint32_t a_threadGroupCountX, std::uint32_t a_threadGroupCountY, std::uint32_t a_threadGroupCountZ) = 0; + virtual void DispatchIndirect(ID3D11Buffer* a_bufferForArgs, std::uint32_t a_alignedByteOffsetForArgs) = 0; + virtual void RSSetState(ID3D11RasterizerState* a_rasterizerState) = 0; + virtual void RSSetViewports(std::uint32_t a_numViewports, const D3D11_VIEWPORT* a_viewports) = 0; + virtual void RSSetScissorRects(std::uint32_t a_numRects, const D3D11_RECT* a_rects) = 0; + virtual void CopySubresourceRegion(ID3D11Resource* a_dstResource, std::uint32_t a_dstSubresource, std::uint32_t a_dstX, std::uint32_t a_dstY, std::uint32_t a_dstZ, ID3D11Resource* a_srcResource, std::uint32_t a_srcSubresource, const D3D11_BOX* a_srcBox) = 0; + virtual void CopyResource(ID3D11Resource* a_dstResource, ID3D11Resource* a_srcResource) = 0; + virtual void UpdateSubresource(ID3D11Resource* a_dstResource, std::uint32_t a_dstSubresource, const D3D11_BOX* a_dstBox, const void* a_srcData, std::uint32_t a_srcRowPitch, std::uint32_t a_srcDepthPitch) = 0; + virtual void CopyStructureCount(ID3D11Buffer* a_dstBuffer, std::uint32_t a_dstAlignedByteOffset, ID3D11UnorderedAccessView* a_srcView) = 0; + virtual void ClearRenderTargetView(ID3D11RenderTargetView* a_renderTargetView, const float a_colorRGBA[4]) = 0; + virtual void ClearUnorderedAccessViewUint(ID3D11UnorderedAccessView* a_unorderedAccessView, const std::uint32_t a_values[4]) = 0; + virtual void ClearUnorderedAccessViewFloat(ID3D11UnorderedAccessView* a_unorderedAccessView, const float a_values[4]) = 0; + virtual void ClearDepthStencilView(ID3D11DepthStencilView* a_depthStencilView, std::uint32_t a_clearFlags, float a_depth, std::uint8_t a_stencil) = 0; + virtual void GenerateMips(ID3D11ShaderResourceView* a_shaderResourceView) = 0; + virtual void SetResourceMinLOD(ID3D11Resource* a_resource, float a_minLOD) = 0; + virtual float GetResourceMinLOD(ID3D11Resource* a_resource) = 0; + virtual void ResolveSubresource(ID3D11Resource* a_dstResource, std::uint32_t a_dstSubresource, ID3D11Resource* a_srcResource, std::uint32_t a_srcSubresource, DXGI_FORMAT a_format) = 0; + virtual void ExecuteCommandList(ID3D11CommandList* a_commandList, BOOL a_restoreContextState) = 0; + virtual void HSSetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView* const* a_shaderResourceViews) = 0; + virtual void HSSetShader(ID3D11HullShader* a_hullShader, ID3D11ClassInstance* const* a_classInstances, std::uint32_t a_numClassInstances) = 0; + virtual void HSSetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState* const* a_samplers) = 0; + virtual void HSSetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers) = 0; + virtual void DSSetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView* const* a_shaderResourceViews) = 0; + virtual void DSSetShader(ID3D11DomainShader* a_domainShader, ID3D11ClassInstance* const* a_classInstances, std::uint32_t a_numClassInstances) = 0; + virtual void DSSetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState* const* a_samplers) = 0; + virtual void DSSetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers) = 0; + virtual void CSSetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView* const* a_shaderResourceViews) = 0; + virtual void CSSetUnorderedAccessViews(std::uint32_t a_startSlot, std::uint32_t a_numUAVs, ID3D11UnorderedAccessView* const* a_unorderedAccessViews, const std::uint32_t* a_uavInitialCounts) = 0; + virtual void CSSetShader(ID3D11ComputeShader* a_computeShader, ID3D11ClassInstance* const* a_classInstances, std::uint32_t a_numClassInstances) = 0; + virtual void CSSetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState* const* a_samplers) = 0; + virtual void CSSetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers) = 0; + virtual void VSGetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers) = 0; + virtual void PSGetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView** a_shaderResourceViews) = 0; + virtual void PSGetShader(ID3D11PixelShader** a_pixelShader, ID3D11ClassInstance** a_classInstances, std::uint32_t* a_numClassInstances) = 0; + virtual void PSGetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState** a_samplers) = 0; + virtual void VSGetShader(ID3D11VertexShader** a_vertexShader, ID3D11ClassInstance** a_classInstances, std::uint32_t* a_numClassInstances) = 0; + virtual void PSGetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers) = 0; + virtual void IAGetInputLayout(ID3D11InputLayout** a_inputLayout) = 0; + virtual void IAGetVertexBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_vertexBuffers, std::uint32_t* a_strides, std::uint32_t* a_offsets) = 0; + virtual void IAGetIndexBuffer(ID3D11Buffer** a_indexBuffer, DXGI_FORMAT* a_format, std::uint32_t* a_offset) = 0; + virtual void GSGetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers) = 0; + virtual void GSGetShader(ID3D11GeometryShader** a_geometryShader, ID3D11ClassInstance** a_classInstances, std::uint32_t* a_numClassInstances) = 0; + virtual void IAGetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY* a_topology) = 0; + virtual void VSGetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView** a_shaderResourceViews) = 0; + virtual void VSGetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState** a_samplers) = 0; + virtual void GetPredication(ID3D11Predicate** a_predicate, BOOL* a_predicateValue) = 0; + virtual void GSGetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView** a_shaderResourceViews) = 0; + virtual void GSGetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState** a_samplers) = 0; + virtual void OMGetRenderTargets(std::uint32_t a_numViews, ID3D11RenderTargetView** a_renderTargetViews, ID3D11DepthStencilView** a_depthStencilView) = 0; + virtual void OMGetRenderTargetsAndUnorderedAccessViews(std::uint32_t a_numRTVs, ID3D11RenderTargetView** a_renderTargetViews, ID3D11DepthStencilView** a_depthStencilView, std::uint32_t a_uavStartSlot, std::uint32_t a_numUAVs, ID3D11UnorderedAccessView** a_unorderedAccessViews) = 0; + virtual void OMGetBlendState(ID3D11BlendState** a_blendState, float a_blendFactor[4], std::uint32_t* a_sampleMask) = 0; + virtual void OMGetDepthStencilState(ID3D11DepthStencilState** a_depthStencilState, std::uint32_t* a_stencilRef) = 0; + virtual void SOGetTargets(std::uint32_t a_numBuffers, ID3D11Buffer** a_soTargets) = 0; + virtual void RSGetState(ID3D11RasterizerState** a_rasterizerState) = 0; + virtual void RSGetViewports(std::uint32_t* a_numViewports, D3D11_VIEWPORT* a_viewports) = 0; + virtual void RSGetScissorRects(std::uint32_t* a_numRects, D3D11_RECT* a_rects) = 0; + virtual void HSGetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView** a_shaderResourceViews) = 0; + virtual void HSGetShader(ID3D11HullShader** a_hullShader, ID3D11ClassInstance** a_classInstances, std::uint32_t* a_numClassInstances) = 0; + virtual void HSGetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState** a_samplers) = 0; + virtual void HSGetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers) = 0; + virtual void DSGetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView** a_shaderResourceViews) = 0; + virtual void DSGetShader(ID3D11DomainShader** a_domainShader, ID3D11ClassInstance** a_classInstances, std::uint32_t* a_numClassInstances) = 0; + virtual void DSGetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState** a_samplers) = 0; + virtual void DSGetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers) = 0; + virtual void CSGetShaderResources(std::uint32_t a_startSlot, std::uint32_t a_numViews, ID3D11ShaderResourceView** a_shaderResourceViews) = 0; + virtual void CSGetUnorderedAccessViews(std::uint32_t a_startSlot, std::uint32_t a_numUAVs, ID3D11UnorderedAccessView** a_unorderedAccessViews) = 0; + virtual void CSGetShader(ID3D11ComputeShader** a_computeShader, ID3D11ClassInstance** a_classInstances, std::uint32_t* a_numClassInstances) = 0; + virtual void CSGetSamplers(std::uint32_t a_startSlot, std::uint32_t a_numSamplers, ID3D11SamplerState** a_samplers) = 0; + virtual void CSGetConstantBuffers(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers) = 0; + virtual void ClearState(void) = 0; + virtual void Flush(void) = 0; + virtual D3D11_DEVICE_CONTEXT_TYPE GetType(void) = 0; + virtual std::uint32_t GetContextFlags(void) = 0; + virtual HRESULT FinishCommandList(BOOL a_restoreDeferredContextState, ID3D11CommandList** a_commandList) = 0; + }; + + struct __declspec(novtable, uuid("4b35d0cd-1e15-4258-9c98-1b1333f6dd3b")) + ID3D11Asynchronous : public ID3D11DeviceChild + { + virtual std::uint32_t GetDataSize(void) = 0; + }; + + struct __declspec(novtable, uuid("3015A308-DCBD-47aa-A747-192486D14D4A")) + ID3D11AuthenticatedChannel : public ID3D11DeviceChild + { + virtual HRESULT GetCertificateSize(std::uint32_t* a_certificateSize) = 0; + virtual HRESULT GetCertificate(std::uint32_t a_certificateSize, std::uint8_t* a_certificate) = 0; + virtual void GetChannelHandle(HANDLE* a_channelHandle) = 0; + }; + + struct __declspec(novtable, uuid("75b68faa-347d-4159-8f45-a0640f01cd9a")) + ID3D11BlendState : public ID3D11DeviceChild + { + virtual void GetDesc(D3D11_BLEND_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("a6cd7faa-b0b7-4a2f-9436-8662a65797cb")) + ID3D11ClassInstance : public ID3D11DeviceChild + { + virtual void GetClassLinkage(ID3D11ClassLinkage** a_linkage) = 0; + virtual void GetDesc(D3D11_CLASS_INSTANCE_DESC* a_desc) = 0; + virtual void GetInstanceName(char* a_instanceName, std::size_t* a_bufferLength) = 0; + virtual void GetTypeName(char* a_typeName, std::size_t* a_bufferLength) = 0; + }; + + struct __declspec(novtable, uuid("ddf57cba-9543-46e4-a12b-f207a0fe7fed")) + ID3D11ClassLinkage : public ID3D11DeviceChild + { + virtual HRESULT GetClassInstance(const char* a_classInstanceName, std::uint32_t a_instanceIndex, ID3D11ClassInstance** a_instance) = 0; + virtual HRESULT CreateClassInstance(const char* a_classTypeName, std::uint32_t a_constantBufferOffset, std::uint32_t a_constantVectorOffset, std::uint32_t a_textureOffset, std::uint32_t a_samplerOffset, ID3D11ClassInstance** a_instance) = 0; + }; + + struct __declspec(novtable, uuid("a24bc4d1-769e-43f7-8013-98ff566c18e2")) + ID3D11CommandList : public ID3D11DeviceChild + { + virtual std::uint32_t GetContextFlags(void) = 0; + }; + + struct __declspec(novtable, uuid("4f5b196e-c2bd-495e-bd01-1fded38e4969")) + ID3D11ComputeShader : public ID3D11DeviceChild + {}; + + struct __declspec(novtable, uuid("6e8c49fb-a371-4770-b440-29086022b741")) + ID3D11Counter : public ID3D11Asynchronous + { + virtual void GetDesc(D3D11_COUNTER_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("9B32F9AD-BDCC-40a6-A39D-D5C865845720")) + ID3D11CryptoSession : public ID3D11DeviceChild + { + virtual void GetCryptoType(GUID* a_cryptoType) = 0; + virtual void GetDecoderProfile(GUID* a_decoderProfile) = 0; + virtual HRESULT GetCertificateSize(std::uint32_t* a_certificateSize) = 0; + virtual HRESULT GetCertificate(std::uint32_t a_certificateSize, std::uint8_t* a_certificate) = 0; + virtual void GetCryptoSessionHandle(HANDLE* a_cryptoSessionHandle) = 0; + }; + + struct __declspec(novtable, uuid("03823efb-8d8f-4e1c-9aa2-f64bb2cbfdf1")) + ID3D11DepthStencilState : public ID3D11DeviceChild + { + virtual void GetDesc(D3D11_DEPTH_STENCIL_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("f582c508-0f36-490c-9977-31eece268cfa")) + ID3D11DomainShader : public ID3D11DeviceChild + {}; + + struct __declspec(novtable, uuid("38325b96-effb-4022-ba02-2e795b70275c")) + ID3D11GeometryShader : public ID3D11DeviceChild + {}; + + struct __declspec(novtable, uuid("8e5c6061-628a-4c8e-8264-bbe45cb3d5dd")) + ID3D11HullShader : public ID3D11DeviceChild + {}; + + struct __declspec(novtable, uuid("e4819ddc-4cf0-4025-bd26-5de82a3e07b7")) + ID3D11InputLayout : public ID3D11DeviceChild + {}; + + struct __declspec(novtable, uuid("ea82e40d-51dc-4f33-93d4-db7c9125ae8c")) + ID3D11PixelShader : public ID3D11DeviceChild + {}; + + struct __declspec(novtable, uuid("9bb4ab81-ab1a-4d8f-b506-fc04200b6ee7")) + ID3D11RasterizerState : public ID3D11DeviceChild + { + virtual void GetDesc(D3D11_RASTERIZER_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("dc8e63f3-d12b-4952-b47b-5e45026a862d")) + ID3D11Resource : public ID3D11DeviceChild + { + virtual void GetType(D3D11_RESOURCE_DIMENSION* a_resourceDimension) = 0; + virtual void SetEvictionPriority(std::uint32_t a_evictionPriority) = 0; + virtual std::uint32_t GetEvictionPriority(void) = 0; + }; + + struct __declspec(novtable, uuid("da6fea51-564c-4487-9810-f0d0f9b4e3a5")) + ID3D11SamplerState : public ID3D11DeviceChild + { + virtual void GetDesc(D3D11_SAMPLER_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("3b301d64-d678-4289-8897-22f8928b72f3")) + ID3D11VertexShader : public ID3D11DeviceChild + {}; + + struct __declspec(novtable, uuid("839d1216-bb2e-412b-b7f4-a9dbebe08ed1")) + ID3D11View : public ID3D11DeviceChild + { + virtual void GetResource(ID3D11Resource** a_resource) = 0; + }; + + struct __declspec(novtable, uuid("48570b85-d1ee-4fcd-a250-eb350722b037")) + ID3D11Buffer : public ID3D11Resource + { + virtual void GetDesc(D3D11_BUFFER_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("9fdac92a-1876-48c3-afad-25b94f84a9b6")) + ID3D11DepthStencilView : public ID3D11View + { + virtual void GetDesc(D3D11_DEPTH_STENCIL_VIEW_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("d6c00747-87b7-425e-b84d-44d108560afd")) + ID3D11Query : public ID3D11Asynchronous + { + virtual void GetDesc(D3D11_QUERY_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("9eb576dd-9f77-4d86-81aa-8bab5fe490e2")) + ID3D11Predicate : public ID3D11Query + {}; + + struct __declspec(novtable, uuid("f8fb5c27-c6b3-4f75-a4c8-439af2ef564c")) + ID3D11Texture1D : public ID3D11Resource + { + virtual void GetDesc(D3D11_TEXTURE1D_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("6f15aaf2-d208-4e89-9ab4-489535d34f9c")) + ID3D11Texture2D : public ID3D11Resource + { + virtual void GetDesc(D3D11_TEXTURE2D_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("037e866e-f56d-4357-a8af-9dabbe6e250e")) + ID3D11Texture3D : public ID3D11Resource + { + virtual void GetDesc(D3D11_TEXTURE3D_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("dfdba067-0b8d-4865-875b-d7b4516cc164")) + ID3D11RenderTargetView : public ID3D11View + { + virtual void GetDesc(D3D11_RENDER_TARGET_VIEW_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("b0e06fe0-8192-4e1a-b1ca-36d7414710b2")) + ID3D11ShaderResourceView : public ID3D11View + { + virtual void GetDesc(D3D11_SHADER_RESOURCE_VIEW_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("28acf509-7f5c-48f6-8611-f316010a6380")) + ID3D11UnorderedAccessView : public ID3D11View + { + virtual void GetDesc(D3D11_UNORDERED_ACCESS_VIEW_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("61F21C45-3C0E-4a74-9CEA-67100D9AD5E4")) + ID3D11VideoContext : public ID3D11DeviceChild + { + virtual HRESULT GetDecoderBuffer(ID3D11VideoDecoder* a_decoder, D3D11_VIDEO_DECODER_BUFFER_TYPE a_type, std::uint32_t* a_bufferSize, void** a_buffer) = 0; + virtual HRESULT ReleaseDecoderBuffer(ID3D11VideoDecoder* a_decoder, D3D11_VIDEO_DECODER_BUFFER_TYPE a_type) = 0; + virtual HRESULT DecoderBeginFrame(ID3D11VideoDecoder* a_decoder, ID3D11VideoDecoderOutputView* a_view, std::uint32_t a_contentKeySize, const void* a_contentKey) = 0; + virtual HRESULT DecoderEndFrame(ID3D11VideoDecoder* a_decoder) = 0; + virtual HRESULT SubmitDecoderBuffers(ID3D11VideoDecoder* a_decoder, std::uint32_t a_numBuffers, const D3D11_VIDEO_DECODER_BUFFER_DESC* a_bufferDesc) = 0; + virtual HRESULT DecoderExtension(ID3D11VideoDecoder* a_decoder, const D3D11_VIDEO_DECODER_EXTENSION* a_extensionData) = 0; + virtual void VideoProcessorSetOutputTargetRect(ID3D11VideoProcessor* a_videoProcessor, BOOL a_enable, const RECT* a_rect) = 0; + virtual void VideoProcessorSetOutputBackgroundColor(ID3D11VideoProcessor* a_videoProcessor, BOOL a_bYCbCr, const D3D11_VIDEO_COLOR* a_color) = 0; + virtual void VideoProcessorSetOutputColorSpace(ID3D11VideoProcessor* a_videoProcessor, const D3D11_VIDEO_PROCESSOR_COLOR_SPACE* a_colorSpace) = 0; + virtual void VideoProcessorSetOutputAlphaFillMode(ID3D11VideoProcessor* a_videoProcessor, D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE a_alphaFillMode, std::uint32_t a_streamIndex) = 0; + virtual void VideoProcessorSetOutputConstriction(ID3D11VideoProcessor* a_videoProcessor, BOOL a_enable, SIZE a_size) = 0; + virtual void VideoProcessorSetOutputStereoMode(ID3D11VideoProcessor* a_videoProcessor, BOOL a_enable) = 0; + virtual HRESULT VideoProcessorSetOutputExtension(ID3D11VideoProcessor* a_videoProcessor, const GUID* a_extensionGuid, std::uint32_t a_dataSize, void* a_data) = 0; + virtual void VideoProcessorGetOutputTargetRect(ID3D11VideoProcessor* a_videoProcessor, BOOL* a_enabled, RECT* a_rect) = 0; + virtual void VideoProcessorGetOutputBackgroundColor(ID3D11VideoProcessor* a_videoProcessor, BOOL* a_bYCbCr, D3D11_VIDEO_COLOR* a_color) = 0; + virtual void VideoProcessorGetOutputColorSpace(ID3D11VideoProcessor* a_videoProcessor, D3D11_VIDEO_PROCESSOR_COLOR_SPACE* a_colorSpace) = 0; + virtual void VideoProcessorGetOutputAlphaFillMode(ID3D11VideoProcessor* a_videoProcessor, D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE* a_alphaFillMode, std::uint32_t* a_streamIndex) = 0; + virtual void VideoProcessorGetOutputConstriction(ID3D11VideoProcessor* a_videoProcessor, BOOL* a_enabled, SIZE* a_size) = 0; + virtual void VideoProcessorGetOutputStereoMode(ID3D11VideoProcessor* a_videoProcessor, BOOL* a_enabled) = 0; + virtual HRESULT VideoProcessorGetOutputExtension(ID3D11VideoProcessor* a_videoProcessor, const GUID* a_extensionGuid, std::uint32_t a_dataSize, void* a_data) = 0; + virtual void VideoProcessorSetStreamFrameFormat(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, D3D11_VIDEO_FRAME_FORMAT a_frameFormat) = 0; + virtual void VideoProcessorSetStreamColorSpace(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, const D3D11_VIDEO_PROCESSOR_COLOR_SPACE* a_colorSpace) = 0; + virtual void VideoProcessorSetStreamOutputRate(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, D3D11_VIDEO_PROCESSOR_OUTPUT_RATE a_outputRate, BOOL a_repeatFrame, const DXGI_RATIONAL* a_customRate) = 0; + virtual void VideoProcessorSetStreamSourceRect(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL a_enable, const RECT* a_rect) = 0; + virtual void VideoProcessorSetStreamDestRect(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL a_enable, const RECT* a_rect) = 0; + virtual void VideoProcessorSetStreamAlpha(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL a_enable, float a_alpha) = 0; + virtual void VideoProcessorSetStreamPalette(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, std::uint32_t a_count, const std::uint32_t* a_entries) = 0; + virtual void VideoProcessorSetStreamPixelAspectRatio(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL a_enable, const DXGI_RATIONAL* a_sourceAspectRatio, const DXGI_RATIONAL* a_destinationAspectRatio) = 0; + virtual void VideoProcessorSetStreamLumaKey(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t StreamIndex, BOOL a_enable, float a_lower, float a_upper) = 0; + virtual void VideoProcessorSetStreamStereoFormat(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL a_enable, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT a_format, BOOL a_leftViewFrame0, BOOL a_baseViewFrame0, D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE a_flipMode, std::int32_t a_monoOffset) = 0; + virtual void VideoProcessorSetStreamAutoProcessingMode(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL a_enable) = 0; + virtual void VideoProcessorSetStreamFilter(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, D3D11_VIDEO_PROCESSOR_FILTER a_filter, BOOL a_enable, std::int32_t a_level) = 0; + virtual HRESULT VideoProcessorSetStreamExtension(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, const GUID* a_extensionGuid, std::uint32_t a_dataSize, void* a_data) = 0; + virtual void VideoProcessorGetStreamFrameFormat(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, D3D11_VIDEO_FRAME_FORMAT* a_frameFormat) = 0; + virtual void VideoProcessorGetStreamColorSpace(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, D3D11_VIDEO_PROCESSOR_COLOR_SPACE* a_colorSpace) = 0; + virtual void VideoProcessorGetStreamOutputRate(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, D3D11_VIDEO_PROCESSOR_OUTPUT_RATE* a_outputRate, BOOL* a_repeatFrame, DXGI_RATIONAL* a_customRate) = 0; + virtual void VideoProcessorGetStreamSourceRect(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enabled, RECT* a_rect) = 0; + virtual void VideoProcessorGetStreamDestRect(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enabled, RECT* a_rect) = 0; + virtual void VideoProcessorGetStreamAlpha(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enabled, float* a_alpha) = 0; + virtual void VideoProcessorGetStreamPalette(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, std::uint32_t a_count, std::uint32_t* a_entries) = 0; + virtual void VideoProcessorGetStreamPixelAspectRatio(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enabled, DXGI_RATIONAL* a_sourceAspectRatio, DXGI_RATIONAL* a_destinationAspectRatio) = 0; + virtual void VideoProcessorGetStreamLumaKey(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enabled, float* a_lower, float* a_upper) = 0; + virtual void VideoProcessorGetStreamStereoFormat(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enable, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT* a_format, BOOL* a_leftViewFrame0, BOOL* a_baseViewFrame0, D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE* a_flipMode, std::int32_t* a_monoOffset) = 0; + virtual void VideoProcessorGetStreamAutoProcessingMode(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enabled) = 0; + virtual void VideoProcessorGetStreamFilter(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, D3D11_VIDEO_PROCESSOR_FILTER a_filter, BOOL* a_enabled, std::int32_t* a_level) = 0; + virtual HRESULT VideoProcessorGetStreamExtension(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, const GUID* a_extensionGuid, std::uint32_t a_dataSize, void* a_data) = 0; + virtual HRESULT VideoProcessorBlt(ID3D11VideoProcessor* a_videoProcessor, ID3D11VideoProcessorOutputView* a_view, std::uint32_t a_outputFrame, std::uint32_t a_streamCount, const D3D11_VIDEO_PROCESSOR_STREAM* a_streams) = 0; + virtual HRESULT NegotiateCryptoSessionKeyExchange(ID3D11CryptoSession* a_cryptoSession, std::uint32_t a_dataSize, void* a_data) = 0; + virtual void EncryptionBlt(ID3D11CryptoSession* a_cryptoSession, ID3D11Texture2D* a_srcSurface, ID3D11Texture2D* a_dstSurface, std::uint32_t a_ivSize, void* a_iv) = 0; + virtual void DecryptionBlt(ID3D11CryptoSession* a_cryptoSession, ID3D11Texture2D* a_srcSurface, ID3D11Texture2D* a_dstSurface, D3D11_ENCRYPTED_BLOCK_INFO* a_encryptedBlockInfo, std::uint32_t a_contentKeySize, const void* a_contentKey, std::uint32_t a_ivSize, void* a_iv) = 0; + virtual void StartSessionKeyRefresh(ID3D11CryptoSession* a_cryptoSession, std::uint32_t a_randomNumberSize, void* a_randomNumber) = 0; + virtual void FinishSessionKeyRefresh(ID3D11CryptoSession* a_cryptoSession) = 0; + virtual HRESULT GetEncryptionBltKey(ID3D11CryptoSession* a_cryptoSession, std::uint32_t a_keySize, void* a_readbackKey) = 0; + virtual HRESULT NegotiateAuthenticatedChannelKeyExchange(ID3D11AuthenticatedChannel* a_channel, std::uint32_t a_dataSize, void* a_data) = 0; + virtual HRESULT QueryAuthenticatedChannel(ID3D11AuthenticatedChannel* a_channel, std::uint32_t a_inputSize, const void* a_input, std::uint32_t a_outputSize, void* a_output) = 0; + virtual HRESULT ConfigureAuthenticatedChannel(ID3D11AuthenticatedChannel* a_channel, std::uint32_t a_inputSize, const void* a_input, D3D11_AUTHENTICATED_CONFIGURE_OUTPUT* a_output) = 0; + virtual void VideoProcessorSetStreamRotation(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL a_enable, D3D11_VIDEO_PROCESSOR_ROTATION a_rotation) = 0; + virtual void VideoProcessorGetStreamRotation(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enable, D3D11_VIDEO_PROCESSOR_ROTATION* a_rotation) = 0; + }; + + struct __declspec(novtable, uuid("3C9C5B51-995D-48d1-9B8D-FA5CAEDED65C")) + ID3D11VideoDecoder : public ID3D11DeviceChild + { + virtual HRESULT GetCreationParameters(D3D11_VIDEO_DECODER_DESC* a_videoDesc, D3D11_VIDEO_DECODER_CONFIG* a_config) = 0; + virtual HRESULT GetDriverHandle(HANDLE* a_driverHandle) = 0; + }; + + struct __declspec(novtable, uuid("C2931AEA-2A85-4f20-860F-FBA1FD256E18")) + ID3D11VideoDecoderOutputView : public ID3D11View + { + virtual void GetDesc(D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("10EC4D5B-975A-4689-B9E4-D0AAC30FE333")) + ID3D11VideoDevice : public IUnknown + { + virtual HRESULT CreateVideoDecoder(const D3D11_VIDEO_DECODER_DESC* a_videoDesc, const D3D11_VIDEO_DECODER_CONFIG* a_config, ID3D11VideoDecoder** a_decoder) = 0; + virtual HRESULT CreateVideoProcessor(ID3D11VideoProcessorEnumerator* a_enum, std::uint32_t a_rateConversionIndex, ID3D11VideoProcessor** a_videoProcessor) = 0; + virtual HRESULT CreateAuthenticatedChannel(D3D11_AUTHENTICATED_CHANNEL_TYPE a_channelType, ID3D11AuthenticatedChannel** a_authenticatedChannel) = 0; + virtual HRESULT CreateCryptoSession(const GUID* a_cryptoType, const GUID* a_decoderProfile, const GUID* a_keyExchangeType, ID3D11CryptoSession** a_cryptoSession) = 0; + virtual HRESULT CreateVideoDecoderOutputView(ID3D11Resource* a_resource, const D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC* a_desc, ID3D11VideoDecoderOutputView** a_dvovView) = 0; + virtual HRESULT CreateVideoProcessorInputView(ID3D11Resource* a_resource, ID3D11VideoProcessorEnumerator* a_enum, const D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC* a_desc, ID3D11VideoProcessorInputView** a_vpiView) = 0; + virtual HRESULT CreateVideoProcessorOutputView(ID3D11Resource* a_resource, ID3D11VideoProcessorEnumerator* a_enum, const D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC* a_desc, ID3D11VideoProcessorOutputView** a_vpoView) = 0; + virtual HRESULT CreateVideoProcessorEnumerator(const D3D11_VIDEO_PROCESSOR_CONTENT_DESC* a_desc, ID3D11VideoProcessorEnumerator** a_enum) = 0; + virtual std::uint32_t GetVideoDecoderProfileCount(void) = 0; + virtual HRESULT GetVideoDecoderProfile(std::uint32_t a_index, GUID* a_decoderProfile) = 0; + virtual HRESULT CheckVideoDecoderFormat(const GUID* a_decoderProfile, DXGI_FORMAT a_format, BOOL* a_supported) = 0; + virtual HRESULT GetVideoDecoderConfigCount(const D3D11_VIDEO_DECODER_DESC* a_desc, std::uint32_t* a_count) = 0; + virtual HRESULT GetVideoDecoderConfig(const D3D11_VIDEO_DECODER_DESC* a_desc, std::uint32_t a_index, D3D11_VIDEO_DECODER_CONFIG* a_config) = 0; + virtual HRESULT GetContentProtectionCaps(const GUID* a_cryptoType, const GUID* a_decoderProfile, D3D11_VIDEO_CONTENT_PROTECTION_CAPS* a_caps) = 0; + virtual HRESULT CheckCryptoKeyExchange(const GUID* a_cryptoType, const GUID* a_decoderProfile, std::uint32_t a_index, GUID* a_keyExchangeType) = 0; + virtual HRESULT SetPrivateData(const GUID& a_guid, std::uint32_t a_dataSize, const void* a_data) = 0; + virtual HRESULT SetPrivateDataInterface(const GUID& a_guid, const IUnknown* a_data) = 0; + }; + + struct __declspec(novtable, uuid("1D7B0652-185F-41c6-85CE-0C5BE3D4AE6C")) + ID3D11VideoProcessor : public ID3D11DeviceChild + { + virtual void GetContentDesc(D3D11_VIDEO_PROCESSOR_CONTENT_DESC* a_desc) = 0; + virtual void GetRateConversionCaps(D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS* a_caps) = 0; + }; + + struct __declspec(novtable, uuid("31627037-53AB-4200-9061-05FAA9AB45F9")) + ID3D11VideoProcessorEnumerator : public ID3D11DeviceChild + { + virtual HRESULT GetVideoProcessorContentDesc(D3D11_VIDEO_PROCESSOR_CONTENT_DESC* a_contentDesc) = 0; + virtual HRESULT CheckVideoProcessorFormat(DXGI_FORMAT a_format, std::uint32_t* a_flags) = 0; + virtual HRESULT GetVideoProcessorCaps(D3D11_VIDEO_PROCESSOR_CAPS* a_caps) = 0; + virtual HRESULT GetVideoProcessorRateConversionCaps(std::uint32_t a_typeIndex, D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS* a_caps) = 0; + virtual HRESULT GetVideoProcessorCustomRate(std::uint32_t a_typeIndex, std::uint32_t a_customRateIndex, D3D11_VIDEO_PROCESSOR_CUSTOM_RATE* a_rate) = 0; + virtual HRESULT GetVideoProcessorFilterRange(D3D11_VIDEO_PROCESSOR_FILTER a_filter, D3D11_VIDEO_PROCESSOR_FILTER_RANGE* a_range) = 0; + }; + + struct __declspec(novtable, uuid("11EC5A5F-51DC-4945-AB34-6E8C21300EA5")) + ID3D11VideoProcessorInputView : public ID3D11View + { + virtual void GetDesc(D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("A048285E-25A9-4527-BD93-D68B68C44254")) + ID3D11VideoProcessorOutputView : public ID3D11View + { + virtual void GetDesc(D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC* a_desc) = 0; + }; +} + +namespace REX::W32 +{ + using PFN_D3D11_CREATE_DEVICE = HRESULT(__stdcall*)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, std::uint32_t, const D3D_FEATURE_LEVEL*, std::uint32_t, std::uint32_t, ID3D11Device**, D3D_FEATURE_LEVEL*, ID3D11DeviceContext**); + using PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN = HRESULT(__stdcall*)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, std::uint32_t, const D3D_FEATURE_LEVEL*, std::uint32_t, std::uint32_t, const DXGI_SWAP_CHAIN_DESC*, IDXGISwapChain**, ID3D11Device**, D3D_FEATURE_LEVEL*, ID3D11DeviceContext**); + + HRESULT D3D11CreateDevice(IDXGIAdapter* a_adapter, D3D_DRIVER_TYPE a_driverType, HMODULE a_software, std::uint32_t a_flags, const D3D_FEATURE_LEVEL* a_pFeatureLevels, std::uint32_t a_featureLevels, std::uint32_t a_sdkVersion, ID3D11Device** a_device, D3D_FEATURE_LEVEL* a_pFeatureLevel, ID3D11DeviceContext** a_immediateContext) noexcept; + HRESULT D3D11CreateDeviceAndSwapChain(IDXGIAdapter* a_adapter, D3D_DRIVER_TYPE a_driverType, HMODULE a_software, std::uint32_t a_flags, const D3D_FEATURE_LEVEL* a_pFeatureLevels, std::uint32_t a_featureLevels, std::uint32_t a_sdkVersion, const DXGI_SWAP_CHAIN_DESC* a_swapChainDesc, IDXGISwapChain** a_swapChain, ID3D11Device** a_device, D3D_FEATURE_LEVEL* a_pFeatureLevel, ID3D11DeviceContext** a_immediateContext) noexcept; +} + +namespace REX::W32 +{ + inline constexpr IID IID_ID3D11Asynchronous{ 0x4B35D0CD, 0x1E15, 0x4258, { 0x9C, 0x98, 0x1B, 0x13, 0x33, 0xF6, 0xDD, 0x3B } }; + inline constexpr IID IID_ID3D11AuthenticatedChannel{ 0x3015A308, 0xDCBD, 0x47AA, { 0xA7, 0x47, 0x19, 0x24, 0x86, 0xD1, 0x4D, 0x4A } }; + inline constexpr IID IID_ID3D11BlendState{ 0x75B68FAA, 0x347D, 0x4159, { 0x8F, 0x45, 0xA0, 0x64, 0x0F, 0x01, 0xCD, 0x9A } }; + inline constexpr IID IID_ID3D11Buffer{ 0x48570B85, 0xD1EE, 0x4FCD, { 0xA2, 0x50, 0xEB, 0x35, 0x07, 0x22, 0xB0, 0x37 } }; + inline constexpr IID IID_ID3D11ClassInstance{ 0xA6CD7FAA, 0xB0B7, 0x4A2F, { 0x94, 0x36, 0x86, 0x62, 0xA6, 0x57, 0x97, 0xCB } }; + inline constexpr IID IID_ID3D11ClassLinkage{ 0xDDF57CBA, 0x9543, 0x46E4, { 0xA1, 0x2B, 0xF2, 0x07, 0xA0, 0xFE, 0x7F, 0xED } }; + inline constexpr IID IID_ID3D11CommandList{ 0xA24BC4D1, 0x769E, 0x43F7, { 0x80, 0x13, 0x98, 0xFF, 0x56, 0x6C, 0x18, 0xE2 } }; + inline constexpr IID IID_ID3D11ComputeShader{ 0x4F5B196E, 0xC2BD, 0x495E, { 0xBD, 0x01, 0x1F, 0xDE, 0xD3, 0x8E, 0x49, 0x69 } }; + inline constexpr IID IID_ID3D11Counter{ 0x6E8C49FB, 0xA371, 0x4770, { 0xB4, 0x40, 0x29, 0x08, 0x60, 0x22, 0xB7, 0x41 } }; + inline constexpr IID IID_ID3D11CryptoSession{ 0x9B32F9AD, 0xBDCC, 0x40A6, { 0xA3, 0x9D, 0xD5, 0xC8, 0x65, 0x84, 0x57, 0x20 } }; + inline constexpr IID IID_ID3D11Device{ 0xDB6F6DDB, 0xAC77, 0x4E88, { 0x82, 0x53, 0x81, 0x9D, 0xF9, 0xBB, 0xF1, 0x40 } }; + inline constexpr IID IID_ID3D11DeviceChild{ 0x1841E5C8, 0x16B0, 0x489B, { 0xBC, 0xC8, 0x44, 0xCF, 0xB0, 0xD5, 0xDE, 0xAE } }; + inline constexpr IID IID_ID3D11DeviceContext{ 0xC0BFA96C, 0xE089, 0x44FB, { 0x8E, 0xAF, 0x26, 0xF8, 0x79, 0x61, 0x90, 0xDA } }; + inline constexpr IID IID_ID3D11DepthStencilState{ 0x03823EFB, 0x8D8F, 0x4E1C, { 0x9A, 0xA2, 0xF6, 0x4B, 0xB2, 0xCB, 0xFD, 0xF1 } }; + inline constexpr IID IID_ID3D11DepthStencilView{ 0x9FDAC92A, 0x1876, 0x48C3, { 0xAF, 0xAD, 0x25, 0xB9, 0x4F, 0x84, 0xA9, 0xB6 } }; + inline constexpr IID IID_ID3D11DomainShader{ 0xF582C508, 0x0F36, 0x490C, { 0x99, 0x77, 0x31, 0xEE, 0xCE, 0x26, 0x8C, 0xFA } }; + inline constexpr IID IID_ID3D11GeometryShader{ 0x38325B96, 0xEFFB, 0x4022, { 0xBA, 0x02, 0x2E, 0x79, 0x5B, 0x70, 0x27, 0x5C } }; + inline constexpr IID IID_ID3D11HullShader{ 0x8E5C6061, 0x628A, 0x4C8E, { 0x82, 0x64, 0xBB, 0xE4, 0x5C, 0xB3, 0xD5, 0xDD } }; + inline constexpr IID IID_ID3D11InputLayout{ 0xE4819DDC, 0x4CF0, 0x4025, { 0xBD, 0x26, 0x5D, 0xE8, 0x2A, 0x3E, 0x07, 0xB7 } }; + inline constexpr IID IID_ID3D11PixelShader{ 0xEA82E40D, 0x51DC, 0x4F33, { 0x93, 0xD4, 0xDB, 0x7C, 0x91, 0x25, 0xAE, 0x8C } }; + inline constexpr IID IID_ID3D11Predicate{ 0x9EB576DD, 0x9F77, 0x4D86, { 0x81, 0xAA, 0x8B, 0xAB, 0x5F, 0xE4, 0x90, 0xE2 } }; + inline constexpr IID IID_ID3D11Query{ 0xD6C00747, 0x87B7, 0x425E, { 0xB8, 0x4D, 0x44, 0xD1, 0x08, 0x56, 0x0A, 0xFD } }; + inline constexpr IID IID_ID3D11RasterizerState{ 0x9BB4AB81, 0xAB1A, 0x4D8F, { 0xB5, 0x06, 0xFC, 0x04, 0x20, 0x0B, 0x6E, 0xE7 } }; + inline constexpr IID IID_ID3D11RenderTargetView{ 0xDFDBA067, 0x0B8D, 0x4865, { 0x87, 0x5B, 0xD7, 0xB4, 0x51, 0x6C, 0xC1, 0x64 } }; + inline constexpr IID IID_ID3D11Resource{ 0xDC8E63F3, 0xD12B, 0x4952, { 0xB4, 0x7B, 0x5E, 0x45, 0x02, 0x6A, 0x86, 0x2D } }; + inline constexpr IID IID_ID3D11SamplerState{ 0xDA6FEA51, 0x564C, 0x4487, { 0x98, 0x10, 0xF0, 0xD0, 0xF9, 0xB4, 0xE3, 0xA5 } }; + inline constexpr IID IID_ID3D11ShaderResourceView{ 0xB0E06FE0, 0x8192, 0x4E1A, { 0xB1, 0xCA, 0x36, 0xD7, 0x41, 0x47, 0x10, 0xB2 } }; + inline constexpr IID IID_ID3D11Texture1D{ 0xF8FB5C27, 0xC6B3, 0x4F75, { 0xA4, 0xC8, 0x43, 0x9A, 0xF2, 0xEF, 0x56, 0x4C } }; + inline constexpr IID IID_ID3D11Texture2D{ 0x6F15AAF2, 0xD208, 0x4E89, { 0x9A, 0xB4, 0x48, 0x95, 0x35, 0xD3, 0x4F, 0x9C } }; + inline constexpr IID IID_ID3D11Texture3D{ 0x037E866E, 0xF56D, 0x4357, { 0xA8, 0xAF, 0x9D, 0xAB, 0xBE, 0x6E, 0x25, 0x0E } }; + inline constexpr IID IID_ID3D11UnorderedAccessView{ 0x28ACF509, 0x7F5C, 0x48F6, { 0x86, 0x11, 0xF3, 0x16, 0x01, 0x0A, 0x63, 0x80 } }; + inline constexpr IID IID_ID3D11VertexShader{ 0x3B301D64, 0xD678, 0x4289, { 0x88, 0x97, 0x22, 0xF8, 0x92, 0x8B, 0x72, 0xF3 } }; + inline constexpr IID IID_ID3D11VideoContext{ 0x61F21C45, 0x3C0E, 0x4A74, { 0x9C, 0xEA, 0x67, 0x10, 0x0D, 0x9A, 0xD5, 0xE4 } }; + inline constexpr IID IID_ID3D11VideoDecoder{ 0x3C9C5B51, 0x995D, 0x48D1, { 0x9B, 0x8D, 0xFA, 0x5C, 0xAE, 0xDE, 0xD6, 0x5C } }; + inline constexpr IID IID_ID3D11VideoDecoderOutputView{ 0xC2931AEA, 0x2A85, 0x4F20, { 0x86, 0x0F, 0xFB, 0xA1, 0xFD, 0x25, 0x6E, 0x18 } }; + inline constexpr IID IID_ID3D11VideoDevice{ 0x10EC4D5B, 0x975A, 0x4689, { 0xB9, 0xE4, 0xD0, 0xAA, 0xC3, 0x0F, 0xE3, 0x33 } }; + inline constexpr IID IID_ID3D11VideoProcessor{ 0x1D7B0652, 0x185F, 0x41C6, { 0x85, 0xCE, 0x0C, 0x5B, 0xE3, 0xD4, 0xAE, 0x6C } }; + inline constexpr IID IID_ID3D11VideoProcessorEnumerator{ 0x31627037, 0x53AB, 0x4200, { 0x90, 0x61, 0x05, 0xFA, 0xA9, 0xAB, 0x45, 0xF9 } }; + inline constexpr IID IID_ID3D11VideoProcessorInputView{ 0x11EC5A5F, 0x51DC, 0x4945, { 0xAB, 0x34, 0x6E, 0x8C, 0x21, 0x30, 0x0E, 0xA5 } }; + inline constexpr IID IID_ID3D11VideoProcessorOutputView{ 0xA048285E, 0x25A9, 0x4527, { 0xBD, 0x93, 0xD6, 0x8B, 0x68, 0xC4, 0x42, 0x54 } }; + inline constexpr IID IID_ID3D11View{ 0x839D1216, 0xBB2E, 0x412B, { 0xB7, 0xF4, 0xA9, 0xDB, 0xEB, 0xE0, 0x8E, 0xD1 } }; +} diff --git a/include/REX/W32/D3D11_1.h b/include/REX/W32/D3D11_1.h new file mode 100644 index 000000000..b8b1de79e --- /dev/null +++ b/include/REX/W32/D3D11_1.h @@ -0,0 +1,296 @@ +#pragma once + +#include "D3D11.h" + +namespace REX::W32 +{ + struct ID3DDeviceContextState; + struct ID3DUserDefinedAnnotation; + struct ID3D11BlendState1; + struct ID3D11Device1; + struct ID3D11DeviceContext1; + struct ID3D11RasterizerState1; + struct ID3D11VideoContext1; + struct ID3D11VideoDevice1; + struct ID3D11VideoProcessorEnumerator1; +} + +namespace REX::W32 +{ + enum D3D11_1_CREATE_DEVICE_CONTEXT_STATE_FLAG + { + D3D11_1_CREATE_DEVICE_CONTEXT_STATE_SINGLETHREADED = 0x1, + }; + + enum D3D11_COPY_FLAGS + { + D3D11_COPY_NO_OVERWRITE = 0x1, + D3D11_COPY_DISCARD = 0x2, + }; + + enum D3D11_CRYPTO_SESSION_STATUS + { + D3D11_CRYPTO_SESSION_STATUS_OK = 0, + D3D11_CRYPTO_SESSION_STATUS_KEY_LOST = 1, + D3D11_CRYPTO_SESSION_STATUS_KEY_AND_CONTENT_LOST = 2, + }; + + enum D3D11_LOGIC_OP + { + D3D11_LOGIC_OP_CLEAR = 0, + D3D11_LOGIC_OP_SET = (D3D11_LOGIC_OP_CLEAR + 1), + D3D11_LOGIC_OP_COPY = (D3D11_LOGIC_OP_SET + 1), + D3D11_LOGIC_OP_COPY_INVERTED = (D3D11_LOGIC_OP_COPY + 1), + D3D11_LOGIC_OP_NOOP = (D3D11_LOGIC_OP_COPY_INVERTED + 1), + D3D11_LOGIC_OP_INVERT = (D3D11_LOGIC_OP_NOOP + 1), + D3D11_LOGIC_OP_AND = (D3D11_LOGIC_OP_INVERT + 1), + D3D11_LOGIC_OP_NAND = (D3D11_LOGIC_OP_AND + 1), + D3D11_LOGIC_OP_OR = (D3D11_LOGIC_OP_NAND + 1), + D3D11_LOGIC_OP_NOR = (D3D11_LOGIC_OP_OR + 1), + D3D11_LOGIC_OP_XOR = (D3D11_LOGIC_OP_NOR + 1), + D3D11_LOGIC_OP_EQUIV = (D3D11_LOGIC_OP_XOR + 1), + D3D11_LOGIC_OP_AND_REVERSE = (D3D11_LOGIC_OP_EQUIV + 1), + D3D11_LOGIC_OP_AND_INVERTED = (D3D11_LOGIC_OP_AND_REVERSE + 1), + D3D11_LOGIC_OP_OR_REVERSE = (D3D11_LOGIC_OP_AND_INVERTED + 1), + D3D11_LOGIC_OP_OR_INVERTED = (D3D11_LOGIC_OP_OR_REVERSE + 1), + }; + + enum D3D11_VIDEO_DECODER_CAPS + { + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE = 0x1, + D3D11_VIDEO_DECODER_CAPS_NON_REAL_TIME = 0x2, + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE_DYNAMIC = 0x4, + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE_REQUIRED = 0x8, + D3D11_VIDEO_DECODER_CAPS_UNSUPPORTED = 0x10, + }; + + enum D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINTS + { + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_ROTATION = 0x1, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_RESIZE = 0x2, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_COLOR_SPACE_CONVERSION = 0x4, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_TRIPLE_BUFFER_OUTPUT = 0x8, + }; +} + +namespace REX::W32 +{ + struct D3D11_KEY_EXCHANGE_HW_PROTECTION_INPUT_DATA; + struct D3D11_KEY_EXCHANGE_HW_PROTECTION_OUTPUT_DATA; + struct D3D11_VIDEO_DECODER_SUB_SAMPLE_MAPPING_BLOCK; + + struct D3D11_KEY_EXCHANGE_HW_PROTECTION_DATA + { + std::uint32_t hwProtectionFunctionID; + D3D11_KEY_EXCHANGE_HW_PROTECTION_INPUT_DATA* inputData; + D3D11_KEY_EXCHANGE_HW_PROTECTION_OUTPUT_DATA* outputData; + HRESULT status; + }; + + struct D3D11_KEY_EXCHANGE_HW_PROTECTION_INPUT_DATA + { + std::uint32_t privateDataSize; + std::uint32_t hwProtectionDataSize; + std::uint8_t input[4]; + }; + + struct D3D11_KEY_EXCHANGE_HW_PROTECTION_OUTPUT_DATA + { + std::uint32_t privateDataSize; + std::uint32_t maxHWProtectionDataSize; + std::uint32_t hwProtectionDataSize; + std::uint64_t transportTime; + std::uint64_t executionTime; + std::uint8_t output[4]; + }; + + struct D3D11_RASTERIZER_DESC1 + { + D3D11_FILL_MODE fillMode; + D3D11_CULL_MODE cullMode; + BOOL frontCounterClockwise; + std::int32_t depthBias; + float depthBiasClamp; + float slopeScaledDepthBias; + BOOL depthClipEnable; + BOOL scissorEnable; + BOOL multisampleEnable; + BOOL antialiasedLineEnable; + std::uint32_t forcedSampleCount; + }; + + struct D3D11_RENDER_TARGET_BLEND_DESC1 + { + BOOL blendEnable; + BOOL logicOpEnable; + D3D11_BLEND srcBlend; + D3D11_BLEND destBlend; + D3D11_BLEND_OP blendOp; + D3D11_BLEND srcBlendAlpha; + D3D11_BLEND destBlendAlpha; + D3D11_BLEND_OP blendOpAlpha; + D3D11_LOGIC_OP logicOp; + std::uint8_t renderTargetWriteMask; + }; + + struct D3D11_VIDEO_DECODER_BEGIN_FRAME_CRYPTO_SESSION + { + ID3D11CryptoSession* cryptoSession; + std::uint32_t blobSize; + void* blob; + GUID* keyInfoId; + std::uint32_t privateDataSize; + void* privateData; + }; + + struct D3D11_VIDEO_DECODER_BUFFER_DESC1 + { + D3D11_VIDEO_DECODER_BUFFER_TYPE bufferType; + std::uint32_t dataOffset; + std::uint32_t dataSize; + void* iv; + std::uint32_t ivSize; + D3D11_VIDEO_DECODER_SUB_SAMPLE_MAPPING_BLOCK* subSampleMappingBlock; + std::uint32_t subSampleMappingCount; + }; + + struct D3D11_VIDEO_DECODER_SUB_SAMPLE_MAPPING_BLOCK + { + std::uint32_t clearSize; + std::uint32_t encryptedSize; + }; + + struct D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT + { + BOOL enable; + std::uint32_t width; + std::uint32_t height; + DXGI_FORMAT format; + }; + + struct D3D11_VIDEO_SAMPLE_DESC + { + std::uint32_t width; + std::uint32_t height; + DXGI_FORMAT format; + DXGI_COLOR_SPACE_TYPE colorSpace; + }; + + struct D3D11_BLEND_DESC1 + { + BOOL alphaToCoverageEnable; + BOOL independentBlendEnable; + D3D11_RENDER_TARGET_BLEND_DESC1 renderTarget[8]; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("5c1e0d8a-7c23-48f9-8c59-a92958ceff11")) + ID3DDeviceContextState : public ID3D11DeviceChild + {}; + + struct __declspec(novtable, uuid("b2daad8b-03d4-4dbf-95eb-32ab4b63d0ab")) + ID3DUserDefinedAnnotation : public IUnknown + { + virtual std::int32_t BeginEvent(const wchar_t* a_name) = 0; + virtual std::int32_t EndEvent(void) = 0; + virtual void SetMarker(const wchar_t* a_name) = 0; + virtual BOOL GetStatus(void) = 0; + }; + + struct __declspec(novtable, uuid("cc86fabe-da55-401d-85e7-e3c9de2877e9")) + ID3D11BlendState1 : public ID3D11BlendState + { + virtual void GetDesc1(D3D11_BLEND_DESC1* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("a04bfb29-08ef-43d6-a49c-a9bdbdcbe686")) + ID3D11Device1 : public ID3D11Device + { + virtual void GetImmediateContext1(ID3D11DeviceContext1** a_immediateContext) = 0; + virtual HRESULT CreateDeferredContext1(std::uint32_t a_contextFlags, ID3D11DeviceContext1** a_deferredContext) = 0; + virtual HRESULT CreateBlendState1(const D3D11_BLEND_DESC1* a_blendStateDesc, ID3D11BlendState1** a_blendState) = 0; + virtual HRESULT CreateRasterizerState1(const D3D11_RASTERIZER_DESC1* a_rasterizerDesc, ID3D11RasterizerState1** a_rasterizerState) = 0; + virtual HRESULT CreateDeviceContextState(std::uint32_t a_flags, const D3D_FEATURE_LEVEL* a_pFeatureLevels, std::uint32_t a_featureLevels, std::uint32_t a_sdkVersion, const IID& a_emulatedInterface, D3D_FEATURE_LEVEL* a_pFeatureLevel, ID3DDeviceContextState** a_contextState) = 0; + virtual HRESULT OpenSharedResource1(HANDLE a_resourceHandle, const IID& a_returnedInterface, void** a_resource) = 0; + virtual HRESULT OpenSharedResourceByName(const wchar_t* a_name, std::uint32_t a_desiredAccess, const IID& a_returnedInterface, void** a_resource) = 0; + }; + + struct __declspec(novtable, uuid("bb2c6faa-b5fb-4082-8e6b-388b8cfa90e1")) + ID3D11DeviceContext1 : public ID3D11DeviceContext + { + virtual void CopySubresourceRegion1(ID3D11Resource* a_dstResource, std::uint32_t a_dstSubresource, std::uint32_t a_dstX, std::uint32_t a_dstY, std::uint32_t a_dstZ, ID3D11Resource* a_srcResource, std::uint32_t a_srcSubresource, const D3D11_BOX* a_srcBox, std::uint32_t a_copyFlags) = 0; + virtual void UpdateSubresource1(ID3D11Resource* a_dstResource, std::uint32_t a_dstSubresource, const D3D11_BOX* a_dstBox, const void* a_srcData, std::uint32_t a_srcRowPitch, std::uint32_t a_srcDepthPitch, std::uint32_t a_copyFlags) = 0; + virtual void DiscardResource(ID3D11Resource* a_resource) = 0; + virtual void DiscardView(ID3D11View* a_resourceView) = 0; + virtual void VSSetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers, const std::uint32_t* a_firstConstant, const std::uint32_t* a_numConstants) = 0; + virtual void HSSetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers, const std::uint32_t* a_firstConstant, const std::uint32_t* a_numConstants) = 0; + virtual void DSSetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers, const std::uint32_t* a_firstConstant, const std::uint32_t* a_numConstants) = 0; + virtual void GSSetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers, const std::uint32_t* a_firstConstant, const std::uint32_t* a_numConstants) = 0; + virtual void PSSetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers, const std::uint32_t* a_firstConstant, const std::uint32_t* a_numConstants) = 0; + virtual void CSSetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer* const* a_constantBuffers, const std::uint32_t* a_firstConstant, const std::uint32_t* a_numConstants) = 0; + virtual void VSGetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers, std::uint32_t* a_firstConstant, std::uint32_t* a_numConstants) = 0; + virtual void HSGetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers, std::uint32_t* a_firstConstant, std::uint32_t* a_numConstants) = 0; + virtual void DSGetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers, std::uint32_t* a_firstConstant, std::uint32_t* a_numConstants) = 0; + virtual void GSGetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers, std::uint32_t* a_firstConstant, std::uint32_t* a_numConstants) = 0; + virtual void PSGetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers, std::uint32_t* a_firstConstant, std::uint32_t* a_numConstants) = 0; + virtual void CSGetConstantBuffers1(std::uint32_t a_startSlot, std::uint32_t a_numBuffers, ID3D11Buffer** a_constantBuffers, std::uint32_t* a_firstConstant, std::uint32_t* a_numConstants) = 0; + virtual void SwapDeviceContextState(ID3DDeviceContextState* a_state, ID3DDeviceContextState** a_previousState) = 0; + virtual void ClearView(ID3D11View* a_view, const float a_color[4], const D3D11_RECT* a_rect, std::uint32_t a_numRects) = 0; + virtual void DiscardView1(ID3D11View* a_resourceView, const D3D11_RECT* a_rects, std::uint32_t a_numRects) = 0; + }; + + struct __declspec(novtable, uuid("1217d7a6-5039-418c-b042-9cbe256afd6e")) + ID3D11RasterizerState1 : public ID3D11RasterizerState + { + virtual void GetDesc1(D3D11_RASTERIZER_DESC1* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("A7F026DA-A5F8-4487-A564-15E34357651E")) + ID3D11VideoContext1 : public ID3D11VideoContext + { + virtual HRESULT SubmitDecoderBuffers1(ID3D11VideoDecoder* a_decoder, std::uint32_t a_numBuffers, const D3D11_VIDEO_DECODER_BUFFER_DESC1* a_bufferDesc) = 0; + virtual HRESULT GetDataForNewHardwareKey(ID3D11CryptoSession* a_cryptoSession, std::uint32_t a_privateInputSize, const void* a_privateInputData, std::uint64_t* a_privateOutputData) = 0; + virtual HRESULT CheckCryptoSessionStatus(ID3D11CryptoSession* a_cryptoSession, D3D11_CRYPTO_SESSION_STATUS* a_status) = 0; + virtual HRESULT DecoderEnableDownsampling(ID3D11VideoDecoder* a_decoder, DXGI_COLOR_SPACE_TYPE a_inputColorSpace, const D3D11_VIDEO_SAMPLE_DESC* a_outputDesc, std::uint32_t a_referenceFrameCount) = 0; + virtual HRESULT DecoderUpdateDownsampling(ID3D11VideoDecoder* a_decoder, const D3D11_VIDEO_SAMPLE_DESC* a_outputDesc) = 0; + virtual void VideoProcessorSetOutputColorSpace1(ID3D11VideoProcessor* a_videoProcessor, DXGI_COLOR_SPACE_TYPE a_colorSpace) = 0; + virtual void VideoProcessorSetOutputShaderUsage(ID3D11VideoProcessor* a_videoProcessor, BOOL a_shaderUsage) = 0; + virtual void VideoProcessorGetOutputColorSpace1(ID3D11VideoProcessor* a_videoProcessor, DXGI_COLOR_SPACE_TYPE* a_colorSpace) = 0; + virtual void VideoProcessorGetOutputShaderUsage(ID3D11VideoProcessor* a_videoProcessor, BOOL* a_shaderUsage) = 0; + virtual void VideoProcessorSetStreamColorSpace1(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, DXGI_COLOR_SPACE_TYPE a_colorSpace) = 0; + virtual void VideoProcessorSetStreamMirror(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL a_enable, BOOL a_flipHorizontal, BOOL a_flipVertical) = 0; + virtual void VideoProcessorGetStreamColorSpace1(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, DXGI_COLOR_SPACE_TYPE* a_colorSpace) = 0; + virtual void VideoProcessorGetStreamMirror(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, BOOL* a_enable, BOOL* a_flipHorizontal, BOOL* a_flipVertical) = 0; + virtual HRESULT VideoProcessorGetBehaviorHints(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_outputWidth, std::uint32_t a_outputHeight, DXGI_FORMAT a_outputFormat, std::uint32_t a_streamCount, const D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT* a_streams, std::uint32_t* a_behaviorHints) = 0; + }; + + struct __declspec(novtable, uuid("29DA1D51-1321-4454-804B-F5FC9F861F0F")) + ID3D11VideoDevice1 : public ID3D11VideoDevice + { + virtual HRESULT GetCryptoSessionPrivateDataSize(const GUID* a_cryptoType, const GUID* a_decoderProfile, const GUID* a_keyExchangeType, std::uint32_t* a_privateInputSize, std::uint32_t* a_privateOutputSize) = 0; + virtual HRESULT GetVideoDecoderCaps(const GUID* a_decoderProfile, std::uint32_t a_sampleWidth, std::uint32_t a_sampleHeight, const DXGI_RATIONAL* a_frameRate, std::uint32_t a_bitRate, const GUID* a_cryptoType, std::uint32_t* a_decoderCaps) = 0; + virtual HRESULT CheckVideoDecoderDownsampling(const D3D11_VIDEO_DECODER_DESC* a_inputDesc, DXGI_COLOR_SPACE_TYPE a_inputColorSpace, const D3D11_VIDEO_DECODER_CONFIG* a_inputConfig, const DXGI_RATIONAL* a_frameRate, const D3D11_VIDEO_SAMPLE_DESC* a_outputDesc, BOOL* a_supported, BOOL* a_realTimeHint) = 0; + virtual HRESULT RecommendVideoDecoderDownsampleParameters(const D3D11_VIDEO_DECODER_DESC* a_inputDesc, DXGI_COLOR_SPACE_TYPE a_inputColorSpace, const D3D11_VIDEO_DECODER_CONFIG* a_inputConfig, const DXGI_RATIONAL* a_frameRate, D3D11_VIDEO_SAMPLE_DESC* a_recommendedOutputDesc) = 0; + }; + + struct __declspec(novtable, uuid("465217F2-5568-43CF-B5B9-F61D54531CA1")) + ID3D11VideoProcessorEnumerator1 : public ID3D11VideoProcessorEnumerator + { + virtual HRESULT CheckVideoProcessorFormatConversion(DXGI_FORMAT a_inputFormat, DXGI_COLOR_SPACE_TYPE a_inputColorSpace, DXGI_FORMAT a_outputFormat, DXGI_COLOR_SPACE_TYPE a_outputColorSpace, BOOL* a_supported) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_ID3DDeviceContextState{ 0x5C1E0D8A, 0x7C23, 0x48F9, { 0x8C, 0x59, 0xA9, 0x29, 0x58, 0xCE, 0xFF, 0x11 } }; + inline constexpr IID IID_ID3DUserDefinedAnnotation{ 0xB2DAAD8B, 0x03D4, 0x4DBF, { 0x95, 0xEB, 0x32, 0xAB, 0x4B, 0x63, 0xD0, 0xAB } }; + inline constexpr IID IID_ID3D11BlendState1{ 0xCC86FABE, 0xDA55, 0x401D, { 0x85, 0xE7, 0xE3, 0xC9, 0xDE, 0x28, 0x77, 0xE9 } }; + inline constexpr IID IID_ID3D11Device1{ 0xA04BFB29, 0x08EF, 0x43D6, { 0xA4, 0x9C, 0xA9, 0xBD, 0xBD, 0xCB, 0xE6, 0x86 } }; + inline constexpr IID IID_ID3D11DeviceContext1{ 0xBB2C6FAA, 0xB5FB, 0x4082, { 0x8E, 0x6B, 0x38, 0x8B, 0x8C, 0xFA, 0x90, 0xE1 } }; + inline constexpr IID IID_ID3D11RasterizerState1{ 0x1217D7A6, 0x5039, 0x418C, { 0xB0, 0x42, 0x9C, 0xBE, 0x25, 0x6A, 0xFD, 0x6E } }; + inline constexpr IID IID_ID3D11VideoContext1{ 0xA7F026DA, 0xA5F8, 0x4487, { 0xA5, 0x64, 0x15, 0xE3, 0x43, 0x57, 0x65, 0x1E } }; + inline constexpr IID IID_ID3D11VideoDevice1{ 0x29DA1D51, 0x1321, 0x4454, { 0x80, 0x4B, 0xF5, 0xFC, 0x9F, 0x86, 0x1F, 0x0F } }; + inline constexpr IID IID_ID3D11VideoProcessorEnumerator1{ 0x465217F2, 0x5568, 0x43CF, { 0xB5, 0xB9, 0xF6, 0x1D, 0x54, 0x53, 0x1C, 0xA1 } }; +} diff --git a/include/REX/W32/D3D11_2.h b/include/REX/W32/D3D11_2.h new file mode 100644 index 000000000..b8809920c --- /dev/null +++ b/include/REX/W32/D3D11_2.h @@ -0,0 +1,112 @@ +#pragma once + +#include "D3D11_1.h" + +namespace REX::W32 +{ + struct ID3D11Device2; + struct ID3D11DeviceContext2; +} + +namespace REX::W32 +{ + enum D3D11_CHECK_MULTISAMPLE_QUALITY_LEVELS_FLAG + { + D3D11_CHECK_MULTISAMPLE_QUALITY_LEVELS_TILED_RESOURCE = 0x1, + }; + + enum D3D11_TILE_COPY_FLAG + { + D3D11_TILE_COPY_NO_OVERWRITE = 0x1, + D3D11_TILE_COPY_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x2, + D3D11_TILE_COPY_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x4, + }; + + enum D3D11_TILE_MAPPING_FLAG + { + D3D11_TILE_MAPPING_NO_OVERWRITE = 0x1, + }; + + enum D3D11_TILE_RANGE_FLAG + { + D3D11_TILE_RANGE_NULL = 0x1, + D3D11_TILE_RANGE_SKIP = 0x2, + D3D11_TILE_RANGE_REUSE_SINGLE_TILE = 0x4, + }; +} + +namespace REX::W32 +{ + struct D3D11_PACKED_MIP_DESC + { + std::uint8_t numStandardMips; + std::uint8_t numPackedMips; + std::uint32_t numTilesForPackedMips; + std::uint32_t startTileIndexInOverallResource; + }; + + struct D3D11_SUBRESOURCE_TILING + { + std::uint32_t widthInTiles; + std::uint16_t heightInTiles; + std::uint16_t depthInTiles; + std::uint32_t startTileIndexInOverallResource; + }; + + struct D3D11_TILED_RESOURCE_COORDINATE + { + std::uint32_t x; + std::uint32_t y; + std::uint32_t z; + std::uint32_t subResource; + }; + + struct D3D11_TILE_REGION_SIZE + { + std::uint32_t numTiles; + BOOL bUseBox; + std::uint32_t width; + std::uint16_t height; + std::uint16_t depth; + }; + + struct D3D11_TILE_SHAPE + { + std::uint32_t widthInTexels; + std::uint32_t heightInTexels; + std::uint32_t depthInTexels; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("9d06dffa-d1e5-4d07-83a8-1bb123f2f841")) + ID3D11Device2 : public ID3D11Device1 + { + virtual void GetImmediateContext2(ID3D11DeviceContext2** a_immediateContext) = 0; + virtual HRESULT CreateDeferredContext2(std::uint32_t a_contextFlags, ID3D11DeviceContext2** a_deferredContext) = 0; + virtual void GetResourceTiling(ID3D11Resource* a_tiledResource, std::uint32_t* a_numTilesForEntireResource, D3D11_PACKED_MIP_DESC* a_packedMipDesc, D3D11_TILE_SHAPE* a_standardTileShapeForNonPackedMips, std::uint32_t* a_numSubresourceTilings, std::uint32_t a_firstSubResourceTilingToGet, D3D11_SUBRESOURCE_TILING* a_subResourceTilingsForNonPackedMips) = 0; + virtual HRESULT CheckMultisampleQualityLevels1(DXGI_FORMAT a_format, std::uint32_t a_sampleCount, std::uint32_t a_flags, std::uint32_t* a_numQualityLevels) = 0; + }; + + struct __declspec(novtable, uuid("420d5b32-b90c-4da4-bef0-359f6a24a83a")) + ID3D11DeviceContext2 : public ID3D11DeviceContext1 + { + virtual HRESULT UpdateTileMappings(ID3D11Resource* a_tiledResource, std::uint32_t numTiledResourceRegions, const D3D11_TILED_RESOURCE_COORDINATE* a_tiledResourceRegionStartCoordinates, const D3D11_TILE_REGION_SIZE* a_tiledResourceRegionSizes, ID3D11Buffer* a_tilePool, std::uint32_t a_numRanges, const std::uint32_t* a_rangeFlags, const std::uint32_t* a_tilePoolStartOffsets, const std::uint32_t* a_rangeTileCounts, std::uint32_t a_flags) = 0; + virtual HRESULT CopyTileMappings(ID3D11Resource* a_destTiledResource, const D3D11_TILED_RESOURCE_COORDINATE* a_destRegionStartCoordinate, ID3D11Resource* a_sourceTiledResource, const D3D11_TILED_RESOURCE_COORDINATE* a_sourceRegionStartCoordinate, const D3D11_TILE_REGION_SIZE* a_tileRegionSize, std::uint32_t a_flags) = 0; + virtual void CopyTiles(ID3D11Resource* a_tiledResource, const D3D11_TILED_RESOURCE_COORDINATE* a_tileRegionStartCoordinate, const D3D11_TILE_REGION_SIZE* a_tileRegionSize, ID3D11Buffer* a_buffer, std::uint64_t a_bufferStartOffsetInBytes, std::uint32_t a_flags) = 0; + virtual void UpdateTiles(ID3D11Resource* a_destTiledResource, const D3D11_TILED_RESOURCE_COORDINATE* a_destTileRegionStartCoordinate, const D3D11_TILE_REGION_SIZE* a_destTileRegionSize, const void* a_sourceTileData, std::uint32_t a_flags) = 0; + virtual HRESULT ResizeTilePool(ID3D11Buffer* a_tilePool, std::uint64_t a_newSizeInBytes) = 0; + virtual void TiledResourceBarrier(ID3D11DeviceChild* a_tiledResourceOrViewAccessBeforeBarrier, ID3D11DeviceChild* a_tiledResourceOrViewAccessAfterBarrier) = 0; + virtual BOOL IsAnnotationEnabled(void) = 0; + virtual void SetMarkerInt(const wchar_t* a_label, std::int32_t a_data) = 0; + virtual void BeginEventInt(const wchar_t* a_label, std::int32_t a_data) = 0; + virtual void EndEvent(void) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_ID3D11Device2{ 0x9D06DFFA, 0xD1E5, 0x4D07, { 0x83, 0xA8, 0x1B, 0xB1, 0x23, 0xF2, 0xF8, 0x41 } }; + inline constexpr IID IID_ID3D11DeviceContext2{ 0x420D5B32, 0xB90C, 0x4DA4, { 0xBE, 0xF0, 0x35, 0x9F, 0x6A, 0x24, 0xA8, 0x3A } }; +} diff --git a/include/REX/W32/D3D11_3.h b/include/REX/W32/D3D11_3.h new file mode 100644 index 000000000..1c6222873 --- /dev/null +++ b/include/REX/W32/D3D11_3.h @@ -0,0 +1,301 @@ +#pragma once + +#include "D3D11_2.h" + +namespace REX::W32 +{ + struct ID3D11Device3; + struct ID3D11DeviceContext3; + struct ID3D11DeviceContext4; + struct ID3D11Fence; + struct ID3D11Query1; + struct ID3D11RasterizerState2; + struct ID3D11RenderTargetView1; + struct ID3D11ShaderResourceView1; + struct ID3D11Texture2D1; + struct ID3D11Texture3D1; + struct ID3D11UnorderedAccessView1; +} + +namespace REX::W32 +{ + enum D3D11_CONSERVATIVE_RASTERIZATION_MODE + { + D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF = 0, + D3D11_CONSERVATIVE_RASTERIZATION_MODE_ON = 1, + }; + + enum D3D11_CONTEXT_TYPE + { + D3D11_CONTEXT_TYPE_ALL = 0, + D3D11_CONTEXT_TYPE_3D = 1, + D3D11_CONTEXT_TYPE_COMPUTE = 2, + D3D11_CONTEXT_TYPE_COPY = 3, + D3D11_CONTEXT_TYPE_VIDEO = 4, + }; + + enum D3D11_FENCE_FLAG + { + D3D11_FENCE_FLAG_NONE = 0, + D3D11_FENCE_FLAG_SHARED = 0x2, + D3D11_FENCE_FLAG_SHARED_CROSS_ADAPTER = 0x4, + D3D11_FENCE_FLAG_NON_MONITORED = 0x8, + }; + + enum D3D11_TEXTURE_LAYOUT + { + D3D11_TEXTURE_LAYOUT_UNDEFINED = 0, + D3D11_TEXTURE_LAYOUT_ROW_MAJOR = 1, + D3D11_TEXTURE_LAYOUT_64K_STANDARD_SWIZZLE = 2, + }; +} + +namespace REX::W32 +{ + struct D3D11_TEX2D_ARRAY_RTV1 + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + std::uint32_t planeSlice; + }; + + struct D3D11_TEX2D_ARRAY_SRV1 + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + std::uint32_t planeSlice; + }; + + struct D3D11_TEX2D_ARRAY_UAV1 + { + std::uint32_t mipSlice; + std::uint32_t firstArraySlice; + std::uint32_t arraySize; + std::uint32_t planeSlice; + }; + + struct D3D11_TEX2D_RTV1 + { + std::uint32_t mipSlice; + std::uint32_t planeSlice; + }; + + struct D3D11_TEX2D_SRV1 + { + std::uint32_t mostDetailedMip; + std::uint32_t mipLevels; + std::uint32_t planeSlice; + }; + + struct D3D11_TEX2D_UAV1 + { + std::uint32_t mipSlice; + std::uint32_t planeSlice; + }; + + struct D3D11_QUERY_DESC1 + { + D3D11_QUERY query; + std::uint32_t miscFlags; + D3D11_CONTEXT_TYPE contextType; + }; + + struct D3D11_RASTERIZER_DESC2 + { + D3D11_FILL_MODE fillMode; + D3D11_CULL_MODE cullMode; + BOOL frontCounterClockwise; + std::int32_t depthBias; + float depthBiasClamp; + float slopeScaledDepthBias; + BOOL depthClipEnable; + BOOL scissorEnable; + BOOL multisampleEnable; + BOOL antialiasedLineEnable; + std::uint32_t forcedSampleCount; + D3D11_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster; + }; + + struct D3D11_RENDER_TARGET_VIEW_DESC1 + { + DXGI_FORMAT format; + D3D11_RTV_DIMENSION viewDimension; + union + { + D3D11_BUFFER_RTV buffer; + D3D11_TEX1D_RTV texture1D; + D3D11_TEX1D_ARRAY_RTV texture1DArray; + D3D11_TEX2D_RTV1 texture2D; + D3D11_TEX2D_ARRAY_RTV1 texture2DArray; + D3D11_TEX2DMS_RTV texture2DMS; + D3D11_TEX2DMS_ARRAY_RTV texture2DMSArray; + D3D11_TEX3D_RTV texture3D; + }; + }; + + struct D3D11_TEXTURE2D_DESC1 + { + std::uint32_t width; + std::uint32_t height; + std::uint32_t mipLevels; + std::uint32_t arraySize; + DXGI_FORMAT format; + DXGI_SAMPLE_DESC sampleDesc; + D3D11_USAGE usage; + std::uint32_t bindFlags; + std::uint32_t cpuAccessFlags; + std::uint32_t miscFlags; + D3D11_TEXTURE_LAYOUT textureLayout; + }; + + struct D3D11_TEXTURE3D_DESC1 + { + std::uint32_t width; + std::uint32_t height; + std::uint32_t depth; + std::uint32_t mipLevels; + DXGI_FORMAT format; + D3D11_USAGE usage; + std::uint32_t bindFlags; + std::uint32_t cpuAccessFlags; + std::uint32_t miscFlags; + D3D11_TEXTURE_LAYOUT textureLayout; + }; + + struct D3D11_SHADER_RESOURCE_VIEW_DESC1 + { + DXGI_FORMAT format; + D3D11_SRV_DIMENSION viewDimension; + union + { + D3D11_BUFFER_SRV buffer; + D3D11_TEX1D_SRV texture1D; + D3D11_TEX1D_ARRAY_SRV texture1DArray; + D3D11_TEX2D_SRV1 texture2D; + D3D11_TEX2D_ARRAY_SRV1 texture2DArray; + D3D11_TEX2DMS_SRV texture2DMS; + D3D11_TEX2DMS_ARRAY_SRV texture2DMSArray; + D3D11_TEX3D_SRV texture3D; + D3D11_TEXCUBE_SRV textureCube; + D3D11_TEXCUBE_ARRAY_SRV textureCubeArray; + D3D11_BUFFEREX_SRV bufferEx; + }; + }; + + struct D3D11_UNORDERED_ACCESS_VIEW_DESC1 + { + DXGI_FORMAT format; + D3D11_UAV_DIMENSION viewDimension; + union + { + D3D11_BUFFER_UAV buffer; + D3D11_TEX1D_UAV texture1D; + D3D11_TEX1D_ARRAY_UAV texture1DArray; + D3D11_TEX2D_UAV1 texture2D; + D3D11_TEX2D_ARRAY_UAV1 texture2DArray; + D3D11_TEX3D_UAV texture3D; + }; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("A05C8C37-D2C6-4732-B3A0-9CE0B0DC9AE6")) + ID3D11Device3 : public ID3D11Device2 + { + virtual HRESULT CreateTexture2D1(const D3D11_TEXTURE2D_DESC1* a_desc1, const D3D11_SUBRESOURCE_DATA* a_initialData, ID3D11Texture2D1** a_texture2D) = 0; + virtual HRESULT CreateTexture3D1(const D3D11_TEXTURE3D_DESC1* a_desc1, const D3D11_SUBRESOURCE_DATA* a_initialData, ID3D11Texture3D1** a_texture3D) = 0; + virtual HRESULT CreateRasterizerState2(const D3D11_RASTERIZER_DESC2* a_rasterizerDesc, ID3D11RasterizerState2** a_rasterizerState) = 0; + virtual HRESULT CreateShaderResourceView1(ID3D11Resource* a_resource, const D3D11_SHADER_RESOURCE_VIEW_DESC1* a_desc1, ID3D11ShaderResourceView1** a_srView1) = 0; + virtual HRESULT CreateUnorderedAccessView1(ID3D11Resource* a_resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC1* a_desc1, ID3D11UnorderedAccessView1** a_uaView1) = 0; + virtual HRESULT CreateRenderTargetView1(ID3D11Resource* a_resource, const D3D11_RENDER_TARGET_VIEW_DESC1* a_desc1, ID3D11RenderTargetView1** a_rtView1) = 0; + virtual HRESULT CreateQuery1(const D3D11_QUERY_DESC1* a_queryDesc1, ID3D11Query1** a_query1) = 0; + virtual void GetImmediateContext3(ID3D11DeviceContext3** a_immediateContext) = 0; + virtual HRESULT CreateDeferredContext3(std::uint32_t a_contextFlags, ID3D11DeviceContext3** a_deferredContext) = 0; + virtual void WriteToSubresource(ID3D11Resource* a_dstResource, std::uint32_t a_dstSubresource, const D3D11_BOX* a_dstBox, const void* a_srcData, std::uint32_t a_srcRowPitch, std::uint32_t a_srcDepthPitch) = 0; + virtual void ReadFromSubresource(void* a_dstData, std::uint32_t a_dstRowPitch, std::uint32_t a_dstDepthPitch, ID3D11Resource* a_srcResource, std::uint32_t a_srcSubresource, const D3D11_BOX* a_srcBox) = 0; + }; + + struct __declspec(novtable, uuid("b4e3c01d-e79e-4637-91b2-510e9f4c9b8f")) + ID3D11DeviceContext3 : public ID3D11DeviceContext2 + { + virtual void Flush1(D3D11_CONTEXT_TYPE a_contextType, HANDLE a_event) = 0; + virtual void SetHardwareProtectionState(BOOL a_hwProtectionEnable) = 0; + virtual void GetHardwareProtectionState(BOOL* a_hwProtectionEnable) = 0; + }; + + struct __declspec(novtable, uuid("917600da-f58c-4c33-98d8-3e15b390fa24")) + ID3D11DeviceContext4 : public ID3D11DeviceContext3 + { + virtual HRESULT Signal(ID3D11Fence* a_fence, std::uint64_t a_value) = 0; + virtual HRESULT Wait(ID3D11Fence* a_fence, std::uint64_t a_value) = 0; + }; + + struct __declspec(novtable, uuid("affde9d1-1df7-4bb7-8a34-0f46251dab80")) + ID3D11Fence : public ID3D11DeviceChild + { + virtual HRESULT CreateSharedHandle(const SECURITY_ATTRIBUTES* a_attributes, std::uint32_t a_access, const wchar_t* a_name, HANDLE* a_handle) = 0; + virtual std::uint64_t GetCompletedValue(void) = 0; + virtual HRESULT SetEventOnCompletion(std::uint64_t a_value, HANDLE a_event) = 0; + }; + + struct __declspec(novtable, uuid("631b4766-36dc-461d-8db6-c47e13e60916")) + ID3D11Query1 : public ID3D11Query + { + virtual void GetDesc1(D3D11_QUERY_DESC1* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("6fbd02fb-209f-46c4-b059-2ed15586a6ac")) + ID3D11RasterizerState2 : public ID3D11RasterizerState1 + { + virtual void GetDesc2(D3D11_RASTERIZER_DESC2* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("ffbe2e23-f011-418a-ac56-5ceed7c5b94b")) + ID3D11RenderTargetView1 : public ID3D11RenderTargetView + { + virtual void GetDesc1(D3D11_RENDER_TARGET_VIEW_DESC1* a_desc1) = 0; + }; + + struct __declspec(novtable, uuid("91308b87-9040-411d-8c67-c39253ce3802")) + ID3D11ShaderResourceView1 : public ID3D11ShaderResourceView + { + virtual void GetDesc1(D3D11_SHADER_RESOURCE_VIEW_DESC1* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("51218251-1E33-4617-9CCB-4D3A4367E7BB")) + ID3D11Texture2D1 : public ID3D11Texture2D + { + virtual void GetDesc1(D3D11_TEXTURE2D_DESC1* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("0C711683-2853-4846-9BB0-F3E60639E46A")) + ID3D11Texture3D1 : public ID3D11Texture3D + { + virtual void GetDesc1(D3D11_TEXTURE3D_DESC1* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("7b3b6153-a886-4544-ab37-6537c8500403")) + ID3D11UnorderedAccessView1 : public ID3D11UnorderedAccessView + { + virtual void GetDesc1(D3D11_UNORDERED_ACCESS_VIEW_DESC1* a_desc) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_ID3D11Device3{ 0xA05C8C37, 0xD2C6, 0x4732, { 0xB3, 0xA0, 0x9C, 0xE0, 0xB0, 0xDC, 0x9A, 0xE6 } }; + inline constexpr IID IID_ID3D11DeviceContext3{ 0xB4E3C01D, 0xE79E, 0x4637, { 0x91, 0xB2, 0x51, 0x0E, 0x9F, 0x4C, 0x9B, 0x8F } }; + inline constexpr IID IID_ID3D11DeviceContext4{ 0x917600DA, 0xF58C, 0x4C33, { 0x98, 0xD8, 0x3E, 0x15, 0xB3, 0x90, 0xFA, 0x24 } }; + inline constexpr IID IID_ID3D11Fence{ 0xAFFDE9D1, 0x1DF7, 0x4BB7, { 0x8A, 0x34, 0x0F, 0x46, 0x25, 0x1D, 0xAB, 0x80 } }; + inline constexpr IID IID_ID3D11Query1{ 0x631B4766, 0x36DC, 0x461D, { 0x8D, 0xB6, 0xC4, 0x7E, 0x13, 0xE6, 0x09, 0x16 } }; + inline constexpr IID IID_ID3D11RasterizerState2{ 0x6FBD02FB, 0x209F, 0x46C4, { 0xb0, 0x59, 0x2E, 0xD1, 0x55, 0x86, 0xA6, 0xAC } }; + inline constexpr IID IID_ID3D11RenderTargetView1{ 0xFFBE2E23, 0xF011, 0x418A, { 0xAC, 0x56, 0x5C, 0xEE, 0xD7, 0xC5, 0xB9, 0x4B } }; + inline constexpr IID IID_ID3D11ShaderResourceView1{ 0x91308B87, 0x9040, 0x411D, { 0x8C, 0x67, 0xC3, 0x92, 0x53, 0xCE, 0x38, 0x02 } }; + inline constexpr IID IID_ID3D11Texture2D1{ 0x51218251, 0x1E33, 0x4617, { 0x9C, 0xCB, 0x4D, 0x3A, 0x43, 0x67, 0xE7, 0xBB } }; + inline constexpr IID IID_ID3D11Texture3D1{ 0x0C711683, 0x2853, 0x4846, { 0x9B, 0xB0, 0xF3, 0xE6, 0x06, 0x39, 0xE4, 0x6A } }; + inline constexpr IID IID_ID3D11UnorderedAccessView1{ 0x7B3B6153, 0xA886, 0x4544, { 0xAB, 0x37, 0x65, 0x37, 0xC8, 0x50, 0x04, 0x03 } }; +} diff --git a/include/REX/W32/D3D11_4.h b/include/REX/W32/D3D11_4.h new file mode 100644 index 000000000..8b0b5b8af --- /dev/null +++ b/include/REX/W32/D3D11_4.h @@ -0,0 +1,138 @@ +#pragma once + +#include "D3D11_3.h" +#include "DXGI_5.h" + +namespace REX::W32 +{ + struct ID3D11Device4; + struct ID3D11Device5; + struct ID3D11Multithread; + struct ID3D11VideoContext2; + struct ID3D11VideoContext3; + struct ID3D11VideoDevice2; +} + +namespace REX::W32 +{ + enum D3D11_CRYPTO_SESSION_KEY_EXCHANGE_FLAGS + { + D3D11_CRYPTO_SESSION_KEY_EXCHANGE_FLAG_NONE = 0, + }; + + enum D3D11_FEATURE_VIDEO + { + D3D11_FEATURE_VIDEO_DECODER_HISTOGRAM = 0, + }; + + enum D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT + { + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_Y = 0, + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_U = 1, + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_V = 2, + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_R = 0, + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_G = 1, + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_B = 2, + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_A = 3, + }; + + enum D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAGS + { + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAG_NONE = 0, + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAG_Y = (1 << D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_Y), + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAG_U = (1 << D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_U), + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAG_V = (1 << D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_V), + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAG_R = (1 << D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_R), + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAG_G = (1 << D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_G), + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAG_B = (1 << D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_B), + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAG_A = (1 << D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_A), + }; +} + +namespace REX::W32 +{ + struct D3D11_FEATURE_DATA_D3D11_OPTIONS4 + { + BOOL extendedNV12SharedTextureSupported; + }; + + struct D3D11_FEATURE_DATA_VIDEO_DECODER_HISTOGRAM + { + D3D11_VIDEO_DECODER_DESC decoderDesc; + D3D11_VIDEO_DECODER_HISTOGRAM_COMPONENT_FLAGS components; + std::uint32_t binCount; + std::uint32_t counterBitDepth; + }; + + struct D3D11_VIDEO_DECODER_BUFFER_DESC2 + { + D3D11_VIDEO_DECODER_BUFFER_TYPE bufferType; + std::uint32_t dataOffset; + std::uint32_t dataSize; + void* iv; + std::uint32_t ivSize; + D3D11_VIDEO_DECODER_SUB_SAMPLE_MAPPING_BLOCK* subSampleMappingBlock; + std::uint32_t subSampleMappingCount; + std::uint32_t cBlocksStripeEncrypted; + std::uint32_t cBlocksStripeClear; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("8992ab71-02e6-4b8d-ba48-b056dcda42c4")) + ID3D11Device4 : public ID3D11Device3 + { + virtual HRESULT RegisterDeviceRemovedEvent(HANDLE a_event, std::uint32_t* a_cookie) = 0; + virtual void UnregisterDeviceRemoved(std::uint32_t a_cookie) = 0; + }; + + struct __declspec(novtable, uuid("8ffde202-a0e7-45df-9e01-e837801b5ea0")) + ID3D11Device5 : public ID3D11Device4 + { + virtual HRESULT OpenSharedFence(HANDLE a_fenceHandle, const IID& a_returnedInterface, void** a_fence) = 0; + virtual HRESULT CreateFence(std::uint64_t a_initialValue, D3D11_FENCE_FLAG a_flags, const IID& a_returnedInterface, void** a_fence) = 0; + }; + + struct __declspec(novtable, uuid("9B7E4E00-342C-4106-A19F-4F2704F689F0")) + ID3D11Multithread : public IUnknown + { + virtual void Enter(void) = 0; + virtual void Leave(void) = 0; + virtual BOOL SetMultithreadProtected(BOOL a_mtProtect) = 0; + virtual BOOL GetMultithreadProtected(void) = 0; + }; + + struct __declspec(novtable, uuid("C4E7374C-6243-4D1B-AE87-52B4F740E261")) + ID3D11VideoContext2 : public ID3D11VideoContext1 + { + virtual void VideoProcessorSetOutputHDRMetaData(ID3D11VideoProcessor* a_videoProcessor, DXGI_HDR_METADATA_TYPE a_type, std::uint32_t a_size, const void* a_hdrMetaData) = 0; + virtual void VideoProcessorGetOutputHDRMetaData(ID3D11VideoProcessor* a_videoProcessor, DXGI_HDR_METADATA_TYPE* a_type, std::uint32_t a_size, void* a_hdrMetaData) = 0; + virtual void VideoProcessorSetStreamHDRMetaData(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, DXGI_HDR_METADATA_TYPE a_type, std::uint32_t a_size, const void* a_hdrMetaData) = 0; + virtual void VideoProcessorGetStreamHDRMetaData(ID3D11VideoProcessor* a_videoProcessor, std::uint32_t a_streamIndex, DXGI_HDR_METADATA_TYPE* a_type, std::uint32_t a_size, void* a_hdrMetaData) = 0; + }; + + struct __declspec(novtable, uuid("A9E2FAA0-CB39-418F-A0B7-D8AAD4DE672E")) + ID3D11VideoContext3 : public ID3D11VideoContext2 + { + virtual HRESULT DecoderBeginFrame1(ID3D11VideoDecoder* a_decoder, ID3D11VideoDecoderOutputView* a_view, std::uint32_t a_contentKeySize, const void* a_contentKey, std::uint32_t a_numComponentHistograms, const std::uint32_t* a_histogramOffsets, ID3D11Buffer* const* a_histogramBuffers) = 0; + virtual HRESULT SubmitDecoderBuffers2(ID3D11VideoDecoder* a_decoder, std::uint32_t a_numBuffers, const D3D11_VIDEO_DECODER_BUFFER_DESC2* a_bufferDesc) = 0; + }; + + struct __declspec(novtable, uuid("59C0CB01-35F0-4A70-8F67-87905C906A53")) + ID3D11VideoDevice2 : public ID3D11VideoDevice1 + { + virtual HRESULT CheckFeatureSupport(D3D11_FEATURE_VIDEO a_feature, void* a_featureSupportData, std::uint32_t a_featureSupportDataSize) = 0; + virtual HRESULT NegotiateCryptoSessionKeyExchangeMT(ID3D11CryptoSession* a_cryptoSession, D3D11_CRYPTO_SESSION_KEY_EXCHANGE_FLAGS a_flags, std::uint32_t a_dataSize, void* a_data) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_ID3D11Device4{ 0x8992AB71, 0x02E6, 0x4B8D, { 0xBA, 0x48, 0xB0, 0x56, 0xDC, 0xDA, 0x42, 0xC4 } }; + inline constexpr IID IID_ID3D11Device5{ 0x8FFDE202, 0xA0E7, 0x45DF, { 0x9E, 0x01, 0xE8, 0x37, 0x80, 0x1B, 0x5E, 0xA0 } }; + inline constexpr IID IID_ID3D11Multithread{ 0x9B7E4E00, 0x342C, 0x4106, { 0xA1, 0x9F, 0x4F, 0x27, 0x04, 0xF6, 0x89, 0xF0 } }; + inline constexpr IID IID_ID3D11VideoContext2{ 0xC4E7374C, 0x6243, 0x4D1B, { 0xAE, 0x87, 0x52, 0xB4, 0xF7, 0x40, 0xE2, 0x61 } }; + inline constexpr IID IID_ID3D11VideoContext3{ 0xA9E2FAA0, 0xCB39, 0x418F, { 0xA0, 0xB7, 0xD8, 0xAA, 0xD4, 0xDE, 0x67, 0x2E } }; + inline constexpr IID IID_ID3D11VideoDevice2{ 0x59C0CB01, 0x35F0, 0x4A70, { 0x8F, 0x67, 0x87, 0x90, 0x5C, 0x90, 0x6A, 0x53 } }; +} diff --git a/include/REX/W32/D3DCOMPILER.h b/include/REX/W32/D3DCOMPILER.h new file mode 100644 index 000000000..edef47126 --- /dev/null +++ b/include/REX/W32/D3DCOMPILER.h @@ -0,0 +1,154 @@ +#pragma once + +#include "D3D.h" + +namespace REX::W32 +{ + struct ID3DBlob; + struct ID3DInclude; + struct ID3D10Effect; + struct ID3D11FunctionLinkingGraph; + struct ID3D11Linker; + struct ID3D11Module; +} + +namespace REX::W32 +{ + enum D3D_BLOB_PART + { + D3D_BLOB_INPUT_SIGNATURE_BLOB, + D3D_BLOB_OUTPUT_SIGNATURE_BLOB, + D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, + D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, + D3D_BLOB_ALL_SIGNATURE_BLOB, + D3D_BLOB_DEBUG_INFO, + D3D_BLOB_LEGACY_SHADER, + D3D_BLOB_XNA_PREPASS_SHADER, + D3D_BLOB_XNA_SHADER, + D3D_BLOB_PDB, + D3D_BLOB_PRIVATE_DATA, + D3D_BLOB_ROOT_SIGNATURE, + D3D_BLOB_DEBUG_NAME, + D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000, + D3D_BLOB_TEST_COMPILE_DETAILS, + D3D_BLOB_TEST_COMPILE_PERF, + D3D_BLOB_TEST_COMPILE_REPORT, + }; + + enum D3D_DISASM_FLAGS + { + D3D_DISASM_ENABLE_COLOR_CODE = 0x00000001, + D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS = 0x00000002, + D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING = 0x00000004, + D3D_DISASM_ENABLE_INSTRUCTION_CYCLE = 0x00000008, + D3D_DISASM_DISABLE_DEBUG_INFO = 0x00000010, + D3D_DISASM_ENABLE_INSTRUCTION_OFFSET = 0x00000020, + D3D_DISASM_INSTRUCTION_ONLY = 0x00000040, + D3D_DISASM_PRINT_HEX_LITERALS = 0x00000080, + }; + + enum D3DCOMPILE_EFFECT + { + D3DCOMPILE_EFFECT_CHILD_EFFECT = (1 << 0), + D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS = (1 << 1), + }; + + enum D3DCOMPILE_FLAGS + { + D3DCOMPILE_DEBUG = (1 << 0), + D3DCOMPILE_SKIP_VALIDATION = (1 << 1), + D3DCOMPILE_SKIP_OPTIMIZATION = (1 << 2), + D3DCOMPILE_PACK_MATRIX_ROW_MAJOR = (1 << 3), + D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR = (1 << 4), + D3DCOMPILE_PARTIAL_PRECISION = (1 << 5), + D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT = (1 << 6), + D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT = (1 << 7), + D3DCOMPILE_NO_PRESHADER = (1 << 8), + D3DCOMPILE_AVOID_FLOW_CONTROL = (1 << 9), + D3DCOMPILE_PREFER_FLOW_CONTROL = (1 << 10), + D3DCOMPILE_ENABLE_STRICTNESS = (1 << 11), + D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY = (1 << 12), + D3DCOMPILE_IEEE_STRICTNESS = (1 << 13), + D3DCOMPILE_OPTIMIZATION_LEVEL0 = (1 << 14), + D3DCOMPILE_OPTIMIZATION_LEVEL1 = 0, + D3DCOMPILE_OPTIMIZATION_LEVEL2 = ((1 << 14) | (1 << 15)), + D3DCOMPILE_OPTIMIZATION_LEVEL3 = (1 << 15), + D3DCOMPILE_RESERVED16 = (1 << 16), + D3DCOMPILE_RESERVED17 = (1 << 17), + D3DCOMPILE_WARNINGS_ARE_ERRORS = (1 << 18), + D3DCOMPILE_RESOURCES_MAY_ALIAS = (1 << 19), + D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES = (1 << 20), + D3DCOMPILE_ALL_RESOURCES_BOUND = (1 << 21), + D3DCOMPILE_DEBUG_NAME_FOR_SOURCE = (1 << 22), + D3DCOMPILE_DEBUG_NAME_FOR_BINARY = (1 << 23), + }; + + enum D3DCOMPILE_FLAGS2 + { + D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST = 0, + D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_0 = (1 << 4), + D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_1 = (1 << 5), + }; + + enum D3DCOMPILE_SECDATA_FLAGS + { + D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS = 0x00000001, + D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS = 0x00000002, + D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH = 0x00000004, + }; + + enum D3DCOMPILER_STRIP_FLAGS + { + D3DCOMPILER_STRIP_REFLECTION_DATA = 0x00000001, + D3DCOMPILER_STRIP_DEBUG_INFO = 0x00000002, + D3DCOMPILER_STRIP_TEST_BLOBS = 0x00000004, + D3DCOMPILER_STRIP_PRIVATE_DATA = 0x00000008, + D3DCOMPILER_STRIP_ROOT_SIGNATURE = 0x00000010, + D3DCOMPILER_STRIP_FORCE_DWORD = 0x7FFFFFFF, + }; +} + +namespace REX::W32 +{ + struct D3D_SHADER_DATA + { + const void* bytecode; + std::size_t bytecodeLength; + }; +} + +namespace REX::W32 +{ + inline const auto D3D_COMPILE_STANDARD_FILE_INCLUDE{ reinterpret_cast(static_cast(1)) }; + inline constexpr auto D3D_COMPRESS_SHADER_KEEP_ALL_PARTS{ 0x00000001u }; + inline constexpr auto D3D_GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE{ 0x00000001u }; +} + +namespace REX::W32 +{ + HRESULT D3DCompile(const void* a_srcData, std::size_t a_srcDataSize, const char* a_sourceName, const D3D_SHADER_MACRO* a_defines, ID3DInclude* a_include, const char* a_entrypoint, const char* a_target, std::uint32_t a_flags1, std::uint32_t a_flags2, ID3DBlob** a_code, ID3DBlob** a_errorMsgs); + HRESULT D3DCompile2(const void* a_srcData, std::size_t a_srcDataSize, const char* a_sourceName, const D3D_SHADER_MACRO* a_defines, ID3DInclude* a_include, const char* a_entrypoint, const char* a_target, std::uint32_t a_flags1, std::uint32_t a_flags2, std::uint32_t a_secondaryDataFlags, const void* a_secondaryData, std::size_t a_secondaryDataSize, ID3DBlob** a_code, ID3DBlob** a_errorMsgs); + HRESULT D3DCompileFromFile(const wchar_t* a_fileName, const D3D_SHADER_MACRO* a_defines, ID3DInclude* a_include, const char* a_entrypoint, const char* a_target, std::uint32_t a_flags1, std::uint32_t a_flags2, ID3DBlob** a_code, ID3DBlob** a_errorMsgs); + HRESULT D3DCompressShaders(std::uint32_t a_numShaders, D3D_SHADER_DATA* a_shaderData, std::uint32_t a_flags, ID3DBlob** a_compressedData); + HRESULT D3DCreateBlob(std::size_t a_size, ID3DBlob** a_blob); + HRESULT D3DCreateFunctionLinkingGraph(std::uint32_t a_flags, ID3D11FunctionLinkingGraph** a_functionLinkingGraph); + HRESULT D3DCreateLinker(ID3D11Linker** a_linker); + HRESULT D3DDecompressShaders(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_numShaders, std::uint32_t a_startIndex, std::uint32_t* a_indices, std::uint32_t a_flags, ID3DBlob** a_shaders, std::uint32_t* a_totalShaders); + HRESULT D3DDisassemble(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_flags, const char* a_comments, ID3DBlob** a_disassembly); + HRESULT D3DDisassemble10Effect(ID3D10Effect* a_effect, std::uint32_t a_flags, ID3DBlob** a_disassembly); + HRESULT D3DDisassembleRegion(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_flags, const char* a_comments, std::size_t a_startByteOffset, std::size_t a_numInsts, std::size_t* a_finishByteOffset, ID3DBlob** a_disassembly); + HRESULT D3DGetBlobPart(const void* a_srcData, std::size_t a_srcDataSize, D3D_BLOB_PART a_partType, std::uint32_t a_flags, ID3DBlob** a_part); + HRESULT D3DGetDebugInfo(const void* a_srcData, std::size_t a_srcDataSize, ID3DBlob** a_debugInfo); + HRESULT D3DGetInputSignatureBlob(const void* a_srcData, std::size_t a_srcDataSize, ID3DBlob** a_signatureBlob); + HRESULT D3DGetInputAndOutputSignatureBlob(const void* a_srcData, std::size_t a_srcDataSize, ID3DBlob** a_signatureBlob); + HRESULT D3DGetOutputSignatureBlob(const void* a_srcData, std::size_t a_srcDataSize, ID3DBlob** a_signatureBlob); + HRESULT D3DGetTraceInstructionOffsets(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_flags, std::size_t a_startInstIndex, std::size_t a_numInsts, std::size_t* a_offsets, std::size_t* a_totalInsts); + HRESULT D3DLoadModule(const void* a_srcData, std::size_t a_srcDataSize, ID3D11Module** a_module); + HRESULT D3DPreprocess(const void* a_srcData, std::size_t a_srcDataSize, const char* a_sourceName, const D3D_SHADER_MACRO* a_defines, ID3DInclude* a_include, ID3DBlob** a_codeText, ID3DBlob** a_errorMsgs); + HRESULT D3DReadFileToBlob(const wchar_t* a_fileName, ID3DBlob** a_contents); + HRESULT D3DReflect(const void* a_srcData, std::size_t a_srcDataSize, const IID& a_iid, void** a_reflector); + HRESULT D3DReflectLibrary(const void* a_srcData, std::size_t a_srcDataSize, const IID& a_iid, void** a_reflector); + HRESULT D3DSetBlobPart(const void* a_srcData, std::size_t a_srcDataSize, D3D_BLOB_PART a_partType, std::uint32_t a_flags, const void* a_part, std::size_t a_partSize, ID3DBlob** a_newShader); + HRESULT D3DStripShader(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_stripFlags, ID3DBlob** a_strippedBlob); + HRESULT D3DWriteBlobToFile(ID3DBlob* a_blob, const wchar_t* a_fileName, bool a_overwrite); +} diff --git a/include/REX/W32/DBGHELP.h b/include/REX/W32/DBGHELP.h new file mode 100644 index 000000000..350b3ebb6 --- /dev/null +++ b/include/REX/W32/DBGHELP.h @@ -0,0 +1,22 @@ +#pragma once + +namespace REX::W32 +{ + // symbol name undecoration flags + inline constexpr auto UNDNAME_NO_MS_KEYWORDS{ 0x00000002u }; + inline constexpr auto UNDNAME_NO_FUNCTION_RETURNS{ 0x00000004u }; + inline constexpr auto UNDNAME_NO_ALLOCATION_MODEL{ 0x00000008u }; + inline constexpr auto UNDNAME_NO_ALLOCATION_LANGUAGE{ 0x00000010u }; + inline constexpr auto UNDNAME_NO_THISTYPE{ 0x00000060u }; + inline constexpr auto UNDNAME_NO_ACCESS_SPECIFIERS{ 0x00000080u }; + inline constexpr auto UNDNAME_NO_THROW_SIGNATURES{ 0x00000100u }; + inline constexpr auto UNDNAME_NO_RETURN_UDT_MODEL{ 0x00000400u }; + inline constexpr auto UNDNAME_NAME_ONLY{ 0x00001000u }; + inline constexpr auto UNDNAME_NO_ARGUMENTS{ 0x00002000u }; +} + +namespace REX::W32 +{ + std::uint32_t UnDecorateSymbolName(const char* a_name, char* a_buf, std::uint32_t a_bufLen, std::uint32_t a_flags) noexcept; + std::uint32_t UnDecorateSymbolNameW(const wchar_t* a_name, wchar_t* a_buf, std::uint32_t a_bufLen, std::uint32_t a_flags) noexcept; +} diff --git a/include/REX/W32/DINPUT.h b/include/REX/W32/DINPUT.h new file mode 100644 index 000000000..b56b923c1 --- /dev/null +++ b/include/REX/W32/DINPUT.h @@ -0,0 +1,499 @@ +#pragma once + +#include "COM.h" +#include "D3D.h" + +namespace REX::W32 +{ + struct IDirectInput8A; + struct IDirectInputDevice8A; + struct IDirectInputEffect; +} + +namespace REX::W32 +{ + enum DIK : std::uint32_t + { + DIK_ESCAPE = 0x1, + DIK_1 = 0x2, + DIK_2 = 0x3, + DIK_3 = 0x4, + DIK_4 = 0x5, + DIK_5 = 0x6, + DIK_6 = 0x7, + DIK_7 = 0x8, + DIK_8 = 0x9, + DIK_9 = 0xA, + DIK_0 = 0xB, + DIK_MINUS = 0xC, + DIK_EQUALS = 0xD, + DIK_BACK = 0xE, + DIK_TAB = 0xF, + DIK_Q = 0x10, + DIK_W = 0x11, + DIK_E = 0x12, + DIK_R = 0x13, + DIK_T = 0x14, + DIK_Y = 0x15, + DIK_U = 0x16, + DIK_I = 0x17, + DIK_O = 0x18, + DIK_P = 0x19, + DIK_LBRACKET = 0x1A, + DIK_RBRACKET = 0x1B, + DIK_RETURN = 0x1C, + DIK_LCONTROL = 0x1D, + DIK_A = 0x1E, + DIK_S = 0x1F, + DIK_D = 0x20, + DIK_F = 0x21, + DIK_G = 0x22, + DIK_H = 0x23, + DIK_J = 0x24, + DIK_K = 0x25, + DIK_L = 0x26, + DIK_SEMICOLON = 0x27, + DIK_APOSTROPHE = 0x28, + DIK_GRAVE = 0x29, + DIK_LSHIFT = 0x2A, + DIK_BACKSLASH = 0x2B, + DIK_Z = 0x2C, + DIK_X = 0x2D, + DIK_C = 0x2E, + DIK_V = 0x2F, + DIK_B = 0x30, + DIK_N = 0x31, + DIK_M = 0x32, + DIK_COMMA = 0x33, + DIK_PERIOD = 0x34, + DIK_SLASH = 0x35, + DIK_RSHIFT = 0x36, + DIK_MULTIPLY = 0x37, + DIK_LMENU = 0x38, + DIK_SPACE = 0x39, + DIK_CAPITAL = 0x3A, + DIK_F1 = 0x3B, + DIK_F2 = 0x3C, + DIK_F3 = 0x3D, + DIK_F4 = 0x3E, + DIK_F5 = 0x3F, + DIK_F6 = 0x40, + DIK_F7 = 0x41, + DIK_F8 = 0x42, + DIK_F9 = 0x43, + DIK_F10 = 0x44, + DIK_NUMLOCK = 0x45, + DIK_SCROLL = 0x46, + DIK_NUMPAD7 = 0x47, + DIK_NUMPAD8 = 0x48, + DIK_NUMPAD9 = 0x49, + DIK_SUBTRACT = 0x4A, + DIK_NUMPAD4 = 0x4B, + DIK_NUMPAD5 = 0x4C, + DIK_NUMPAD6 = 0x4D, + DIK_ADD = 0x4E, + DIK_NUMPAD1 = 0x4F, + DIK_NUMPAD2 = 0x50, + DIK_NUMPAD3 = 0x51, + DIK_NUMPAD0 = 0x52, + DIK_DECIMAL = 0x53, + DIK_OEM_102 = 0x56, + DIK_F11 = 0x57, + DIK_F12 = 0x58, + DIK_F13 = 0x64, + DIK_F14 = 0x65, + DIK_F15 = 0x66, + DIK_KANA = 0x70, + DIK_ABNT_C1 = 0x73, + DIK_CONVERT = 0x79, + DIK_NOCONVERT = 0x7B, + DIK_YEN = 0x7D, + DIK_ABNT_C2 = 0x7E, + DIK_NUMPADEQUALS = 0x8D, + DIK_PREVTRACK = 0x90, + DIK_AT = 0x91, + DIK_COLON = 0x92, + DIK_UNDERLINE = 0x93, + DIK_KANJI = 0x94, + DIK_STOP = 0x95, + DIK_AX = 0x96, + DIK_UNLABELED = 0x97, + DIK_NEXTTRACK = 0x99, + DIK_NUMPADENTER = 0x9C, + DIK_RCONTROL = 0x9D, + DIK_MUTE = 0xA0, + DIK_CALCULATOR = 0xA1, + DIK_PLAYPAUSE = 0xA2, + DIK_MEDIASTOP = 0xA4, + DIK_VOLUMEDOWN = 0xAE, + DIK_VOLUMEUP = 0xB0, + DIK_WEBHOME = 0xB2, + DIK_NUMPADCOMMA = 0xB3, + DIK_DIVIDE = 0xB5, + DIK_SYSRQ = 0xB7, + DIK_RMENU = 0xB8, + DIK_PAUSE = 0xC5, + DIK_HOME = 0xC7, + DIK_UP = 0xC8, + DIK_PRIOR = 0xC9, + DIK_LEFT = 0xCB, + DIK_RIGHT = 0xCD, + DIK_END = 0xCF, + DIK_DOWN = 0xD0, + DIK_NEXT = 0xD1, + DIK_INSERT = 0xD2, + DIK_DELETE = 0xD3, + DIK_LWIN = 0xDB, + DIK_RWIN = 0xDC, + DIK_APPS = 0xDD, + DIK_POWER = 0xDE, + DIK_SLEEP = 0xDF, + DIK_WAKE = 0xE3, + DIK_WEBSEARCH = 0xE5, + DIK_WEBFAVORITES = 0xE6, + DIK_WEBREFRESH = 0xE7, + DIK_WEBSTOP = 0xE8, + DIK_WEBFORWARD = 0xE9, + DIK_WEBBACK = 0xEA, + DIK_MYCOMPUTER = 0xEB, + DIK_MAIL = 0xEC, + DIK_MEDIASELECT = 0xED, + DIK_BACKSPACE = DIK_BACK, + DIK_NUMPADSTAR = DIK_MULTIPLY, + DIK_LALT = DIK_LMENU, + DIK_CAPSLOCK = DIK_CAPITAL, + DIK_NUMPADMINUS = DIK_SUBTRACT, + DIK_NUMPADPLUS = DIK_ADD, + DIK_NUMPADPERIOD = DIK_DECIMAL, + DIK_NUMPADSLASH = DIK_DIVIDE, + DIK_RALT = DIK_RMENU, + DIK_UPARROW = DIK_UP, + DIK_PGUP = DIK_PRIOR, + DIK_LEFTARROW = DIK_LEFT, + DIK_RIGHTARROW = DIK_RIGHT, + DIK_DOWNARROW = DIK_DOWN, + DIK_PGDN = DIK_NEXT + }; +} + +namespace REX::W32 +{ + struct DIENVELOPE; + struct DIOBJECTDATAFORMAT; + + struct DIACTIONA + { + std::uintptr_t appData; + std::uint32_t semantic; + std::uint32_t flags; + union + { + const char* actionName; + std::uint32_t resIdString; + }; + GUID guidInstance; + std::uint32_t objID; + std::uint32_t how; + }; + + struct DIACTIONFORMATA + { + std::uint32_t size; + std::uint32_t actionSize; + std::uint32_t dataSize; + std::uint32_t numActions; + DIACTIONA* action; + GUID guidActionMap; + std::uint32_t genre; + std::uint32_t bufferSize; + std::int32_t axisMin; + std::int32_t axisMax; + HINSTANCE instString; + FILETIME timeStamp; + std::uint32_t crc; + char actionMap[MAX_PATH]; + }; + + struct DICOLORSET + { + std::uint32_t size; + D3DCOLOR textFore; + D3DCOLOR textHighlight; + D3DCOLOR calloutLine; + D3DCOLOR calloutHighlight; + D3DCOLOR border; + D3DCOLOR controlFill; + D3DCOLOR highlightFill; + D3DCOLOR areaFill; + }; + + struct DICONFIGUREDEVICESPARAMSA + { + std::uint32_t size; + std::uint32_t users; + char* userNames; + std::uint32_t formatsSize; + DIACTIONFORMATA* formats; + HWND hwnd; + DICOLORSET dics; + IUnknown* unkDDSTarget; + }; + + struct DIDATAFORMAT + { + std::uint32_t size; + std::uint32_t objSize; + std::uint32_t flags; + std::uint32_t dataSize; + std::uint32_t numObjs; + DIOBJECTDATAFORMAT* odf; + }; + + struct DIDEVCAPS + { + std::uint32_t size; + std::uint32_t flags; + std::uint32_t devType; + std::uint32_t axes; + std::uint32_t buttons; + std::uint32_t povs; + std::uint32_t ffSamplePeriod; + std::uint32_t ffMinTimeResolution; + std::uint32_t firmwareRevision; + std::uint32_t hardwareRevision; + std::uint32_t ffDriverVersion; + }; + + struct DIDEVICEIMAGEINFOA + { + char imagePath[MAX_PATH]; + std::uint32_t flags; + std::uint32_t viewID; + RECT overlay; + std::uint32_t objID; + std::uint32_t validPts; + POINT calloutLine[5]; + RECT calloutRect; + std::uint32_t textAlign; + }; + + struct DIDEVICEIMAGEINFOHEADERA + { + std::uint32_t size; + std::uint32_t sizeImageInfo; + std::uint32_t views; + std::uint32_t buttons; + std::uint32_t axes; + std::uint32_t povs; + std::uint32_t bufferSize; + std::uint32_t bufferUsed; + DIDEVICEIMAGEINFOA* imageInfoArray; + }; + + struct DIDEVICEINSTANCEA + { + std::uint32_t size; + GUID guidInstance; + GUID guidProduct; + std::uint32_t devType; + char instanceName[MAX_PATH]; + char productName[MAX_PATH]; + GUID guidFFDriver; + + // DIRECTINPUT_VERSION >= 0x0500 + std::uint16_t usagePage; + std::uint16_t usage; + }; + + struct DIDEVICEOBJECTDATA + { + std::uint32_t ofs; + std::uint32_t data; + std::uint32_t timeStamp; + std::uint32_t sequence; + std::uintptr_t appData; + }; + + struct DIDEVICEOBJECTINSTANCEA + { + std::uint32_t size; + GUID guidType; + std::uint32_t ofs; + std::uint32_t type; + std::uint32_t flags; + char name[MAX_PATH]; + + // DIRECTINPUT_VERSION >= 0x0500 + std::uint32_t ffMaxForce; + std::uint32_t ffForceResolution; + std::uint16_t collectionNumber; + std::uint16_t designatorIndex; + std::uint16_t usagePage; + std::uint16_t usage; + std::uint32_t dimension; + std::uint16_t exponent; + std::uint16_t reportId; + }; + + struct DIEFFECT + { + std::uint32_t size; + std::uint32_t flags; + std::uint32_t duration; + std::uint32_t samplePeriod; + std::uint32_t gain; + std::uint32_t triggerButton; + std::uint32_t triggerRepeatInterval; + std::uint32_t axesSize; + std::uint32_t* axes; + std::int32_t* direction; + DIENVELOPE* envelope; + std::uint32_t typeSpecificParamsSize; + void* typeSpecificParams; + std::uint32_t startDelay; + }; + + struct DIENVELOPE + { + std::uint32_t size; + std::uint32_t attackLevel; + std::uint32_t attackTime; + std::uint32_t fadeLevel; + std::uint32_t fadeTime; + }; + + struct DIEFFECTINFOA + { + std::uint32_t size; + GUID guid; + std::uint32_t effectType; + std::uint32_t staticParams; + std::uint32_t dynamicParams; + char name[MAX_PATH]; + }; + + struct DIEFFESCAPE + { + std::uint32_t size; + std::uint32_t command; + void* inBuffer; + std::uint32_t inBufferSize; + void* outBuffer; + std::uint32_t outBufferSize; + }; + + struct DIFILEEFFECT + { + std::uint32_t size; + GUID guidEffect; + const DIEFFECT* effect; + char friendlyName[MAX_PATH]; + }; + + struct DIMOUSESTATE2 + { + std::int32_t x; + std::int32_t y; + std::int32_t z; + std::uint8_t rgbButtons[8]; + }; + + struct DIOBJECTDATAFORMAT + { + const GUID* guid; + std::uint32_t ofs; + std::uint32_t type; + std::uint32_t flags; + }; + + struct DIPROPHEADER + { + std::uint32_t size; + std::uint32_t headerSize; + std::uint32_t obj; + std::uint32_t how; + }; +} + +namespace REX::W32 +{ + using LPDICONFIGUREDEVICESCALLBACK = BOOL(__stdcall*)(IUnknown*, void*); + using LPDIENUMCREATEDEFFECTOBJECTSCALLBACK = BOOL(__stdcall*)(IDirectInputEffect*, void*); + using LPDIENUMDEVICESBYSEMANTICSCBA = BOOL(__stdcall*)(const DIDEVICEINSTANCEA*, IDirectInputDevice8A*, std::uint32_t, std::uint32_t, void*); + using LPDIENUMDEVICESCALLBACKA = BOOL(__stdcall*)(const DIDEVICEINSTANCEA*, void*); + using LPDIENUMDEVICEOBJECTSCALLBACKA = BOOL(__stdcall*)(const DIDEVICEOBJECTINSTANCEA*, void*); + using LPDIENUMEFFECTSCALLBACKA = BOOL(__stdcall*)(const DIEFFECTINFOA*, void*); + using LPDIENUMEFFECTSINFILECALLBACK = BOOL(__stdcall*)(const DIFILEEFFECT*, void*); +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("BF798030-483A-4DA2-AA99-5D64ED369700")) + IDirectInput8A : public IUnknown + { + virtual HRESULT CreateDevice(const GUID&, IDirectInputDevice8A**, IUnknown*) noexcept = 0; + virtual HRESULT EnumDevices(std::uint32_t, LPDIENUMDEVICESCALLBACKA, void*, std::uint32_t) noexcept = 0; + virtual HRESULT GetDeviceStatus(const GUID&) noexcept = 0; + virtual HRESULT RunControlPanel(HWND, std::uint32_t) noexcept = 0; + virtual HRESULT Initialize(HINSTANCE, std::uint32_t) noexcept = 0; + virtual HRESULT FindDevice(const GUID&, const char*, GUID*) noexcept = 0; + virtual HRESULT EnumDevicesBySemantics(const char*, DIACTIONFORMATA*, LPDIENUMDEVICESBYSEMANTICSCBA, void*, std::uint32_t) noexcept = 0; + virtual HRESULT ConfigureDevices(LPDICONFIGUREDEVICESCALLBACK, DICONFIGUREDEVICESPARAMSA*, std::uint32_t, void*) noexcept = 0; + }; + + struct __declspec(novtable, uuid("54D41080-DC15-4833-A41B-748F73A38179")) + IDirectInputDevice8A : public IUnknown + { + virtual HRESULT GetCapabilities(DIDEVCAPS*) noexcept = 0; + virtual HRESULT EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKA, void*, std::uint32_t) noexcept = 0; + virtual HRESULT GetProperty(const GUID&, DIPROPHEADER*) noexcept = 0; + virtual HRESULT SetProperty(const GUID&, const DIPROPHEADER*) noexcept = 0; + virtual HRESULT Acquire() noexcept = 0; + virtual HRESULT Unacquire() noexcept = 0; + virtual HRESULT GetDeviceState(std::uint32_t, void*) noexcept = 0; + virtual HRESULT GetDeviceData(std::uint32_t, DIDEVICEOBJECTDATA*, std::uint32_t*, std::uint32_t) noexcept = 0; + virtual HRESULT SetDataFormat(const DIDATAFORMAT*) noexcept = 0; + virtual HRESULT SetEventNotification(HANDLE) noexcept = 0; + virtual HRESULT SetCooperativeLevel(HWND, std::uint32_t) noexcept = 0; + virtual HRESULT GetObjectInfo(DIDEVICEOBJECTINSTANCEA*, std::uint32_t, std::uint32_t) noexcept = 0; + virtual HRESULT GetDeviceInfo(DIDEVICEINSTANCEA*) noexcept = 0; + virtual HRESULT RunControlPanel(HWND, std::uint32_t) noexcept = 0; + virtual HRESULT Initialize(HINSTANCE, std::uint32_t, const GUID&) noexcept = 0; + virtual HRESULT CreateEffect(const GUID&, const DIEFFECT*, IDirectInputEffect*, IUnknown*) noexcept = 0; + virtual HRESULT EnumEffects(LPDIENUMEFFECTSCALLBACKA, void*, std::uint32_t) noexcept = 0; + virtual HRESULT GetEffectInfo(DIEFFECTINFOA*, const GUID&) noexcept = 0; + virtual HRESULT GetForceFeedbackState(std::uint32_t*) noexcept = 0; + virtual HRESULT SendForceFeedbackCommand(std::uint32_t) noexcept = 0; + virtual HRESULT EnumCreatedEffectObjects(LPDIENUMCREATEDEFFECTOBJECTSCALLBACK, void*, std::uint32_t) noexcept = 0; + virtual HRESULT Escape(DIEFFESCAPE*) noexcept = 0; + virtual HRESULT Poll() noexcept = 0; + virtual HRESULT SendDeviceData(std::uint32_t, const DIDEVICEOBJECTDATA*, std::uint32_t*, std::uint32_t) noexcept = 0; + virtual HRESULT EnumEffectsInFile(const char*, LPDIENUMEFFECTSINFILECALLBACK, void*, std::uint32_t) noexcept = 0; + virtual HRESULT WriteEffectToFile(const char*, std::uint32_t, DIFILEEFFECT*, std::uint32_t) noexcept = 0; + virtual HRESULT BuildActionMap(DIACTIONFORMATA*, const char*, std::uint32_t) noexcept = 0; + virtual HRESULT SetActionMap(DIACTIONFORMATA*, const char*, std::uint32_t) noexcept = 0; + virtual HRESULT GetImageInfo(DIDEVICEIMAGEINFOHEADERA*) noexcept = 0; + }; + + struct __declspec(novtable, uuid("E7E1F7C0-88D2-11D0-9AD0-00A0C9A06E35")) + IDirectInputEffect : public IUnknown + { + virtual HRESULT Initialize(HINSTANCE, std::uint32_t, const GUID&) noexcept = 0; + virtual HRESULT GetEffectGuid(GUID*) noexcept = 0; + virtual HRESULT GetParameters(DIEFFECT*, std::uint32_t) noexcept = 0; + virtual HRESULT SetParameters(const DIEFFECT*, std::uint32_t) noexcept = 0; + virtual HRESULT Start(std::uint32_t, std::uint32_t) noexcept = 0; + virtual HRESULT Stop() noexcept = 0; + virtual HRESULT GetEffectStatus(std::uint32_t*) noexcept = 0; + virtual HRESULT Download() noexcept = 0; + virtual HRESULT Unload() noexcept = 0; + virtual HRESULT Escape(DIEFFESCAPE*) noexcept = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_IDirectInput8A{ 0xBF798030, 0x483A, 0x4DA2, { 0xAA, 0x99, 0x5D, 0x64, 0xED, 0x36, 0x97, 0x00 } }; + inline constexpr IID IID_IDirectInputDevice8A{ 0x54D41080, 0xDC15, 0x4833, { 0xA4, 0x1B, 0x74, 0x8F, 0x73, 0xA3, 0x81, 0x79 } }; + inline constexpr IID IID_IDirectInputEffect{ 0xE7E1F7C0, 0x88D2, 0x11D0, { 0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35 } }; +} diff --git a/include/REX/W32/DXGI.h b/include/REX/W32/DXGI.h new file mode 100644 index 000000000..9c3325cc8 --- /dev/null +++ b/include/REX/W32/DXGI.h @@ -0,0 +1,549 @@ +#pragma once + +#include "COM.h" + +namespace REX::W32 +{ + struct IDXGIAdapter; + struct IDXGIAdapter1; + struct IDXGIDevice; + struct IDXGIDevice1; + struct IDXGIDeviceSubObject; + struct IDXGIFactory1; + struct IDXGIKeyedMutex; + struct IDXGIObject; + struct IDXGIOutput; + struct IDXGIResource; + struct IDXGISurface; + struct IDXGISurface1; + struct IDXGISwapChain; +} + +namespace REX::W32 +{ + enum DXGI_ADAPTER_FLAG + { + DXGI_ADAPTER_FLAG_NONE = 0, + DXGI_ADAPTER_FLAG_REMOTE = 1, + DXGI_ADAPTER_FLAG_SOFTWARE = 2, + DXGI_ADAPTER_FLAG_FORCE_DWORD = 0xFFFFFFFF, + }; + + enum DXGI_COLOR_SPACE_TYPE + { + DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 = 0, + DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 = 1, + DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709 = 2, + DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020 = 3, + DXGI_COLOR_SPACE_RESERVED = 4, + DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 = 5, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 = 6, + DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601 = 7, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 = 8, + DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709 = 9, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 = 10, + DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 = 11, + DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 = 12, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020 = 13, + DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020 = 14, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020 = 15, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020 = 16, + DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020 = 17, + DXGI_COLOR_SPACE_YCBCR_STUDIO_GHLG_TOPLEFT_P2020 = 18, + DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020 = 19, + DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P709 = 20, + DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P2020 = 21, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P709 = 22, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P2020 = 23, + DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_TOPLEFT_P2020 = 24, + DXGI_COLOR_SPACE_CUSTOM = 0xFFFFFFFF, + }; + + enum DXGI_FORMAT + { + DXGI_FORMAT_UNKNOWN = 0, + DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, + DXGI_FORMAT_R32G32B32A32_FLOAT = 2, + DXGI_FORMAT_R32G32B32A32_UINT = 3, + DXGI_FORMAT_R32G32B32A32_SINT = 4, + DXGI_FORMAT_R32G32B32_TYPELESS = 5, + DXGI_FORMAT_R32G32B32_FLOAT = 6, + DXGI_FORMAT_R32G32B32_UINT = 7, + DXGI_FORMAT_R32G32B32_SINT = 8, + DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, + DXGI_FORMAT_R16G16B16A16_FLOAT = 10, + DXGI_FORMAT_R16G16B16A16_UNORM = 11, + DXGI_FORMAT_R16G16B16A16_UINT = 12, + DXGI_FORMAT_R16G16B16A16_SNORM = 13, + DXGI_FORMAT_R16G16B16A16_SINT = 14, + DXGI_FORMAT_R32G32_TYPELESS = 15, + DXGI_FORMAT_R32G32_FLOAT = 16, + DXGI_FORMAT_R32G32_UINT = 17, + DXGI_FORMAT_R32G32_SINT = 18, + DXGI_FORMAT_R32G8X24_TYPELESS = 19, + DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, + DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, + DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, + DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, + DXGI_FORMAT_R10G10B10A2_UNORM = 24, + DXGI_FORMAT_R10G10B10A2_UINT = 25, + DXGI_FORMAT_R11G11B10_FLOAT = 26, + DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, + DXGI_FORMAT_R8G8B8A8_UNORM = 28, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, + DXGI_FORMAT_R8G8B8A8_UINT = 30, + DXGI_FORMAT_R8G8B8A8_SNORM = 31, + DXGI_FORMAT_R8G8B8A8_SINT = 32, + DXGI_FORMAT_R16G16_TYPELESS = 33, + DXGI_FORMAT_R16G16_FLOAT = 34, + DXGI_FORMAT_R16G16_UNORM = 35, + DXGI_FORMAT_R16G16_UINT = 36, + DXGI_FORMAT_R16G16_SNORM = 37, + DXGI_FORMAT_R16G16_SINT = 38, + DXGI_FORMAT_R32_TYPELESS = 39, + DXGI_FORMAT_D32_FLOAT = 40, + DXGI_FORMAT_R32_FLOAT = 41, + DXGI_FORMAT_R32_UINT = 42, + DXGI_FORMAT_R32_SINT = 43, + DXGI_FORMAT_R24G8_TYPELESS = 44, + DXGI_FORMAT_D24_UNORM_S8_UINT = 45, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, + DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, + DXGI_FORMAT_R8G8_TYPELESS = 48, + DXGI_FORMAT_R8G8_UNORM = 49, + DXGI_FORMAT_R8G8_UINT = 50, + DXGI_FORMAT_R8G8_SNORM = 51, + DXGI_FORMAT_R8G8_SINT = 52, + DXGI_FORMAT_R16_TYPELESS = 53, + DXGI_FORMAT_R16_FLOAT = 54, + DXGI_FORMAT_D16_UNORM = 55, + DXGI_FORMAT_R16_UNORM = 56, + DXGI_FORMAT_R16_UINT = 57, + DXGI_FORMAT_R16_SNORM = 58, + DXGI_FORMAT_R16_SINT = 59, + DXGI_FORMAT_R8_TYPELESS = 60, + DXGI_FORMAT_R8_UNORM = 61, + DXGI_FORMAT_R8_UINT = 62, + DXGI_FORMAT_R8_SNORM = 63, + DXGI_FORMAT_R8_SINT = 64, + DXGI_FORMAT_A8_UNORM = 65, + DXGI_FORMAT_R1_UNORM = 66, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, + DXGI_FORMAT_R8G8_B8G8_UNORM = 68, + DXGI_FORMAT_G8R8_G8B8_UNORM = 69, + DXGI_FORMAT_BC1_TYPELESS = 70, + DXGI_FORMAT_BC1_UNORM = 71, + DXGI_FORMAT_BC1_UNORM_SRGB = 72, + DXGI_FORMAT_BC2_TYPELESS = 73, + DXGI_FORMAT_BC2_UNORM = 74, + DXGI_FORMAT_BC2_UNORM_SRGB = 75, + DXGI_FORMAT_BC3_TYPELESS = 76, + DXGI_FORMAT_BC3_UNORM = 77, + DXGI_FORMAT_BC3_UNORM_SRGB = 78, + DXGI_FORMAT_BC4_TYPELESS = 79, + DXGI_FORMAT_BC4_UNORM = 80, + DXGI_FORMAT_BC4_SNORM = 81, + DXGI_FORMAT_BC5_TYPELESS = 82, + DXGI_FORMAT_BC5_UNORM = 83, + DXGI_FORMAT_BC5_SNORM = 84, + DXGI_FORMAT_B5G6R5_UNORM = 85, + DXGI_FORMAT_B5G5R5A1_UNORM = 86, + DXGI_FORMAT_B8G8R8A8_UNORM = 87, + DXGI_FORMAT_B8G8R8X8_UNORM = 88, + DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89, + DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, + DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, + DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, + DXGI_FORMAT_BC6H_TYPELESS = 94, + DXGI_FORMAT_BC6H_UF16 = 95, + DXGI_FORMAT_BC6H_SF16 = 96, + DXGI_FORMAT_BC7_TYPELESS = 97, + DXGI_FORMAT_BC7_UNORM = 98, + DXGI_FORMAT_BC7_UNORM_SRGB = 99, + DXGI_FORMAT_AYUV = 100, + DXGI_FORMAT_Y410 = 101, + DXGI_FORMAT_Y416 = 102, + DXGI_FORMAT_NV12 = 103, + DXGI_FORMAT_P010 = 104, + DXGI_FORMAT_P016 = 105, + DXGI_FORMAT_420_OPAQUE = 106, + DXGI_FORMAT_YUY2 = 107, + DXGI_FORMAT_Y210 = 108, + DXGI_FORMAT_Y216 = 109, + DXGI_FORMAT_NV11 = 110, + DXGI_FORMAT_AI44 = 111, + DXGI_FORMAT_IA44 = 112, + DXGI_FORMAT_P8 = 113, + DXGI_FORMAT_A8P8 = 114, + DXGI_FORMAT_B4G4R4A4_UNORM = 115, + + DXGI_FORMAT_P208 = 130, + DXGI_FORMAT_V208 = 131, + DXGI_FORMAT_V408 = 132, + + DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 189, + DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 190, + + DXGI_FORMAT_FORCE_UINT = 0xFFFFFFFF, + }; + + enum DXGI_MODE_ROTATION + { + DXGI_MODE_ROTATION_UNSPECIFIED = 0, + DXGI_MODE_ROTATION_IDENTITY = 1, + DXGI_MODE_ROTATION_ROTATE90 = 2, + DXGI_MODE_ROTATION_ROTATE180 = 3, + DXGI_MODE_ROTATION_ROTATE270 = 4, + }; + + enum DXGI_MODE_SCALING + { + DXGI_MODE_SCALING_UNSPECIFIED = 0, + DXGI_MODE_SCALING_CENTERED = 1, + DXGI_MODE_SCALING_STRETCHED = 2, + }; + + enum DXGI_MODE_SCANLINE_ORDER + { + DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0, + DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1, + DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2, + DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3, + }; + + enum DXGI_RESIDENCY + { + DXGI_RESIDENCY_FULLY_RESIDENT = 1, + DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2, + DXGI_RESIDENCY_EVICTED_TO_DISK = 3, + }; + + enum DXGI_SWAP_EFFECT + { + DXGI_SWAP_EFFECT_DISCARD = 0, + DXGI_SWAP_EFFECT_SEQUENTIAL = 1, + DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3, + DXGI_SWAP_EFFECT_FLIP_DISCARD = 4, + }; + + enum DXGI_SWAP_CHAIN_FLAG + { + DXGI_SWAP_CHAIN_FLAG_NONPREROTATED = 1, + DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH = 2, + DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE = 4, + DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT = 8, + DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER = 16, + DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY = 32, + DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT = 64, + DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 128, + DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 256, + DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 512, + DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 1024, + DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING = 2048, + DXGI_SWAP_CHAIN_FLAG_RESTRICTED_TO_ALL_HOLOGRAPHIC_DISPLAYS = 4096, + }; +} + +namespace REX::W32 +{ + struct D3DCOLORVALUE + { + float r; + float g; + float b; + float a; + }; + + using DXGI_RGBA = D3DCOLORVALUE; + using DXGI_USAGE = std::uint32_t; + + struct LUID + { + std::uint32_t lo; + std::int32_t hi; + }; +} + +namespace REX::W32 +{ + struct DXGI_ADAPTER_DESC + { + wchar_t description[128]; + std::uint32_t vendorId; + std::uint32_t deviceId; + std::uint32_t subSysId; + std::uint32_t revision; + std::size_t dedicatedVideoMemory; + std::size_t dedicatedSystemMemory; + std::size_t sharedSystemMemory; + LUID adapterLuid; + }; + + struct DXGI_ADAPTER_DESC1 + { + wchar_t description[128]; + std::uint32_t vendorId; + std::uint32_t deviceId; + std::uint32_t subSysId; + std::uint32_t revision; + std::size_t dedicatedVideoMemory; + std::size_t dedicatedSystemMemory; + std::size_t sharedSystemMemory; + LUID adapterLuid; + std::uint32_t flags; + }; + + struct DXGI_DISPLAY_COLOR_SPACE + { + float primaryCoordinates[8][2]; + float whitePoints[16][2]; + }; + + struct DXGI_FRAME_STATISTICS + { + std::uint32_t presentCount; + std::uint32_t presentRefreshCount; + std::uint32_t syncRefreshCount; + std::int64_t syncQPCTime; + std::int64_t syncGPUTime; + }; + + struct DXGI_RGB + { + float red; + float green; + float blue; + }; + + struct DXGI_GAMMA_CONTROL + { + DXGI_RGB scale; + DXGI_RGB offset; + DXGI_RGB gammaCurve[1025]; + }; + + struct DXGI_GAMMA_CONTROL_CAPABILITIES + { + BOOL scaleAndOffsetSupported; + float maxConvertedValue; + float minConvertedValue; + std::uint32_t numGammaControlPoints; + float controlPointPositions[1025]; + }; + + struct DXGI_MAPPED_RECT + { + std::int32_t pitch; + std::uint8_t* bits; + }; + + struct DXGI_RATIONAL + { + std::uint32_t numerator; + std::uint32_t denominator; + }; + + struct DXGI_MODE_DESC + { + std::uint32_t width; + std::uint32_t height; + DXGI_RATIONAL refreshRate; + DXGI_FORMAT format; + DXGI_MODE_SCANLINE_ORDER scanlineOrdering; + DXGI_MODE_SCALING scaling; + }; + + struct DXGI_OUTPUT_DESC + { + wchar_t deviceName[32]; + RECT desktopCoordinates; + BOOL attachedToDesktop; + DXGI_MODE_ROTATION rotation; + HMONITOR monitor; + }; + + struct DXGI_SAMPLE_DESC + { + std::uint32_t count; + std::uint32_t quality; + }; + + struct DXGI_SHARED_RESOURCE + { + HANDLE handle; + }; + + struct DXGI_SURFACE_DESC + { + std::uint32_t width; + std::uint32_t height; + DXGI_FORMAT format; + DXGI_SAMPLE_DESC sampleDesc; + }; + + struct DXGI_SWAP_CHAIN_DESC + { + DXGI_MODE_DESC bufferDesc; + DXGI_SAMPLE_DESC sampleDesc; + DXGI_USAGE bufferUsage; + std::uint32_t bufferCount; + HWND outputWindow; + BOOL windowed; + DXGI_SWAP_EFFECT swapEffect; + std::uint32_t flags; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("aec22fb8-76f3-4639-9be0-28eb43a67a2e")) + IDXGIObject : public IUnknown + { + virtual HRESULT SetPrivateData(const GUID& a_iid, std::uint32_t a_dataSize, const void* a_data) = 0; + virtual HRESULT SetPrivateDataInterface(const GUID& a_iid, const IUnknown* a_unknown) = 0; + virtual HRESULT GetPrivateData(const GUID& a_iid, std::uint32_t* a_dataSize, void* a_data) = 0; + virtual HRESULT GetParent(const GUID& a_iid, void** a_parent) = 0; + }; + + struct __declspec(novtable, uuid("3d3e0379-f9de-4d58-bb6c-18d62992f1a6")) + IDXGIDeviceSubObject : public IDXGIObject + { + virtual HRESULT GetDevice(const GUID& a_iid, void** a_device) = 0; + }; + + struct __declspec(novtable, uuid("035f3ab4-482e-4e50-b41f-8a7f8bd8960b")) + IDXGIResource : public IDXGIDeviceSubObject + { + virtual HRESULT GetSharedHandle(HANDLE* a_sharedHandle) = 0; + virtual HRESULT GetUsage(DXGI_USAGE* a_usage) = 0; + virtual HRESULT SetEvictionPriority(std::uint32_t a_evictionPriority) = 0; + virtual HRESULT GetEvictionPriority(std::uint32_t* a_evictionPriority) = 0; + }; + + struct __declspec(novtable, uuid("9d8e1289-d7b3-465f-8126-250e349af85d")) + IDXGIKeyedMutex : public IDXGIDeviceSubObject + { + virtual HRESULT AcquireSync(std::uint64_t a_key, std::uint32_t a_milliseconds) = 0; + virtual HRESULT ReleaseSync(std::uint64_t a_key) = 0; + }; + + struct __declspec(novtable, uuid("cafcb56c-6ac3-4889-bf47-9e23bbd260ec")) + IDXGISurface : public IDXGIDeviceSubObject + { + virtual HRESULT GetDesc(DXGI_SURFACE_DESC* a_desc) = 0; + virtual HRESULT Map(DXGI_MAPPED_RECT* a_lockedRect, std::uint32_t a_mapFlags) = 0; + virtual HRESULT Unmap(void) = 0; + }; + + struct __declspec(novtable, uuid("4AE63092-6327-4c1b-80AE-BFE12EA32B86")) + IDXGISurface1 : public IDXGISurface + { + virtual HRESULT GetDC(BOOL a_discard, HDC* a_hdc) = 0; + virtual HRESULT ReleaseDC(RECT* a_dirtyRect) = 0; + }; + + struct __declspec(novtable, uuid("2411e7e1-12ac-4ccf-bd14-9798e8534dc0")) + IDXGIAdapter : public IDXGIObject + { + virtual HRESULT EnumOutputs(std::uint32_t a_outputSize, IDXGIOutput** a_output) = 0; + virtual HRESULT GetDesc(DXGI_ADAPTER_DESC* a_desc) = 0; + virtual HRESULT CheckInterfaceSupport(const GUID& a_iid, std::int64_t* a_umdVersion) = 0; + }; + + struct __declspec(novtable, uuid("29038f61-3839-4626-91fd-086879011a05")) + IDXGIAdapter1 : public IDXGIAdapter + { + virtual HRESULT GetDesc1(DXGI_ADAPTER_DESC1* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("ae02eedb-c735-4690-8d52-5a8dc20213aa")) + IDXGIOutput : public IDXGIObject + { + virtual HRESULT GetDesc(DXGI_OUTPUT_DESC* a_desc) = 0; + virtual HRESULT GetDisplayModeList(DXGI_FORMAT a_enumFormat, std::uint32_t a_flags, std::uint32_t* a_numModes, DXGI_MODE_DESC* a_desc) = 0; + virtual HRESULT FindClosestMatchingMode(const DXGI_MODE_DESC* a_modeToMatch, DXGI_MODE_DESC* a_closestMatch, IUnknown* a_concernedDevice) = 0; + virtual HRESULT WaitForVBlank(void) = 0; + virtual HRESULT TakeOwnership(IUnknown* a_device, BOOL a_exclusive) = 0; + virtual void ReleaseOwnership(void) = 0; + virtual HRESULT GetGammaControlCapabilities(DXGI_GAMMA_CONTROL_CAPABILITIES* a_gammaCaps) = 0; + virtual HRESULT SetGammaControl(const DXGI_GAMMA_CONTROL* a_array) = 0; + virtual HRESULT GetGammaControl(DXGI_GAMMA_CONTROL* a_array) = 0; + virtual HRESULT SetDisplaySurface(IDXGISurface* a_scanoutSurface) = 0; + virtual HRESULT GetDisplaySurfaceData(IDXGISurface* a_destination) = 0; + virtual HRESULT GetFrameStatistics(DXGI_FRAME_STATISTICS* a_stats) = 0; + }; + + struct __declspec(novtable, uuid("310d36a0-d2e7-4c0a-aa04-6a9d23b8886a")) + IDXGISwapChain : public IDXGIDeviceSubObject + { + virtual HRESULT Present(std::uint32_t a_syncInterval, std::uint32_t a_flags) = 0; + virtual HRESULT GetBuffer(std::uint32_t a_buffer, const GUID& a_iid, void** a_surface) = 0; + virtual HRESULT SetFullscreenState(BOOL a_fullscreen, IDXGIOutput* a_target) = 0; + virtual HRESULT GetFullscreenState(BOOL* a_fullscreen, IDXGIOutput** a_target) = 0; + virtual HRESULT GetDesc(DXGI_SWAP_CHAIN_DESC* a_desc) = 0; + virtual HRESULT ResizeBuffers(std::uint32_t a_bufferCount, std::uint32_t a_width, std::uint32_t a_height, DXGI_FORMAT a_newFormat, std::uint32_t a_swapChainFlags) = 0; + virtual HRESULT ResizeTarget(const DXGI_MODE_DESC* a_newTargetParameters) = 0; + virtual HRESULT GetContainingOutput(IDXGIOutput** a_output) = 0; + virtual HRESULT GetFrameStatistics(DXGI_FRAME_STATISTICS* a_stats) = 0; + virtual HRESULT GetLastPresentCount(std::uint32_t* a_lastPresentCount) = 0; + }; + + struct __declspec(novtable, uuid("7b7166ec-21c7-44ae-b21a-c9ae321ae369")) + IDXGIFactory : public IDXGIObject + { + virtual HRESULT EnumAdapters(std::uint32_t a_adapterSize, IDXGIAdapter** a_adapter) = 0; + virtual HRESULT MakeWindowAssociation(HWND a_windowHandle, std::uint32_t a_flags) = 0; + virtual HRESULT GetWindowAssociation(HWND* a_windowHandle) = 0; + virtual HRESULT CreateSwapChain(IUnknown* a_device, DXGI_SWAP_CHAIN_DESC* a_desc, IDXGISwapChain** a_swapChain) = 0; + virtual HRESULT CreateSoftwareAdapter(HMODULE a_module, IDXGIAdapter** a_adapter) = 0; + }; + + struct __declspec(novtable, uuid("770aae78-f26f-4dba-a829-253c83d1b387")) + IDXGIFactory1 : public IDXGIFactory + { + virtual HRESULT EnumAdapters1(std::uint32_t a_adapterSize, IDXGIAdapter1** a_adapter) = 0; + virtual BOOL IsCurrent(void) = 0; + }; + + struct __declspec(novtable, uuid("54ec77fa-1377-44e6-8c32-88fd5f44c84c")) + IDXGIDevice : public IDXGIObject + { + virtual HRESULT GetAdapter(IDXGIAdapter** a_adapter) = 0; + virtual HRESULT CreateSurface(const DXGI_SURFACE_DESC* a_desc, std::uint32_t a_numSurfaces, DXGI_USAGE a_usage, const DXGI_SHARED_RESOURCE* a_sharedResource, IDXGISurface** a_surface) = 0; + virtual HRESULT QueryResourceResidency(IUnknown* const* a_resources, DXGI_RESIDENCY* a_residencyStatus, std::uint32_t a_numResources) = 0; + virtual HRESULT SetGPUThreadPriority(std::int32_t a_priority) = 0; + virtual HRESULT GetGPUThreadPriority(std::int32_t* a_priority) = 0; + }; + + struct __declspec(novtable, uuid("77db970f-6276-48ba-ba28-070143b4392c")) + IDXGIDevice1 : public IDXGIDevice + { + virtual HRESULT SetMaximumFrameLatency(std::uint32_t a_maxLatency) = 0; + virtual HRESULT GetMaximumFrameLatency(std::uint32_t* a_maxLatency) = 0; + }; +} + +namespace REX::W32 +{ + HRESULT CreateDXGIFactory(const IID& a_iid, void** a_factory) noexcept; + HRESULT CreateDXGIFactory1(const IID& a_iid, void** a_factory) noexcept; +} + +namespace REX::W32 +{ + inline constexpr IID IID_IDXGIAdapter{ 0x2411E7E1, 0x12AC, 0x4CCF, { 0xBD, 0x14, 0x97, 0x98, 0xE8, 0x53, 0x4D, 0xC0 } }; + inline constexpr IID IID_IDXGIAdapter1{ 0x29038F61, 0x3839, 0x4626, { 0x91, 0xFD, 0x08, 0x68, 0x79, 0x01, 0x1A, 0x05 } }; + inline constexpr IID IID_IDXGIObject{ 0xAEC22Fb8, 0x76F3, 0x4639, { 0x9B, 0xE0, 0x28, 0xEB, 0x43, 0xA6, 0x7A, 0x2E } }; + inline constexpr IID IID_IDXGIDevice{ 0x54EC77FA, 0x1377, 0x44E6, { 0x8C, 0x32, 0x88, 0xFD, 0x5F, 0x44, 0xC8, 0x4C } }; + inline constexpr IID IID_IDXGIDevice1{ 0x77DB970F, 0x6276, 0x48BA, { 0xBA, 0x28, 0x07, 0x01, 0x43, 0xB4, 0x39, 0x2C } }; + inline constexpr IID IID_IDXGIDeviceSubObject{ 0x3D3E0379, 0xF9DE, 0x4D58, { 0xBB, 0x6C, 0x18, 0xD6, 0x29, 0x92, 0xF1, 0xA6 } }; + inline constexpr IID IID_IDXGIFactory{ 0x7B7166EC, 0x21C7, 0x44AE, { 0xB2, 0x1A, 0xC9, 0xAE, 0x32, 0x1A, 0xE3, 0x69 } }; + inline constexpr IID IID_IDXGIFactory1{ 0x770AAE78, 0xF26F, 0x4DBA, { 0xA8, 0x29, 0x25, 0x3C, 0x83, 0xD1, 0xB3, 0x87 } }; + inline constexpr IID IID_IDXGIKeyedMutex{ 0x9D8E1289, 0xD7B3, 0x465F, { 0x81, 0x26, 0x25, 0x0E, 0x34, 0x9A, 0xF8, 0x5D } }; + inline constexpr IID IID_IDXGIOutput{ 0xAE02EEDB, 0xC735, 0x4690, { 0x8D, 0x52, 0x5A, 0x8D, 0xC2, 0x02, 0x13, 0xAA } }; + inline constexpr IID IID_IDXGIResource{ 0x035F3AB4, 0x482E, 0x4E50, { 0xB4, 0x1F, 0x8A, 0x7F, 0x8B, 0xD8, 0x96, 0x0B } }; + inline constexpr IID IID_IDXGISurface{ 0xCAFCB56C, 0x6AC3, 0x4889, { 0xBF, 0x47, 0x9E, 0x23, 0xBB, 0xD2, 0x60, 0xEC } }; + inline constexpr IID IID_IDXGISurface1{ 0x4AE63092, 0x6327, 0x4C1B, { 0x80, 0xAE, 0xBF, 0xE1, 0x2E, 0xA3, 0x2B, 0x86 } }; + inline constexpr IID IID_IDXGISwapChain{ 0x310D36A0, 0xD2E7, 0x4C0A, { 0xAA, 0x04, 0x6A, 0x9D, 0x23, 0xB8, 0x88, 0x6A } }; +} diff --git a/include/REX/W32/DXGI_2.h b/include/REX/W32/DXGI_2.h new file mode 100644 index 000000000..a1b98cbe6 --- /dev/null +++ b/include/REX/W32/DXGI_2.h @@ -0,0 +1,272 @@ +#pragma once + +#include "DXGI.h" + +namespace REX::W32 +{ + struct IDXGIAdapter2; + struct IDXGIDevice2; + struct IDXGIDisplayControl; + struct IDXGIFactory2; + struct IDXGIOutput1; + struct IDXGIOutputDuplication; + struct IDXGIResource1; + struct IDXGISurface2; + struct IDXGISwapChain1; +} + +namespace REX::W32 +{ + enum DXGI_ALPHA_MODE + { + DXGI_ALPHA_MODE_UNSPECIFIED = 0, + DXGI_ALPHA_MODE_PREMULTIPLIED = 1, + DXGI_ALPHA_MODE_STRAIGHT = 2, + DXGI_ALPHA_MODE_IGNORE = 3, + DXGI_ALPHA_MODE_FORCE_DWORD = 0xFFFFFFFF, + }; + + enum DXGI_COMPUTE_PREEMPTION_GRANULARITY + { + DXGI_COMPUTE_PREEMPTION_DMA_BUFFER_BOUNDARY = 0, + DXGI_COMPUTE_PREEMPTION_DISPATCH_BOUNDARY = 1, + DXGI_COMPUTE_PREEMPTION_THREAD_GROUP_BOUNDARY = 2, + DXGI_COMPUTE_PREEMPTION_THREAD_BOUNDARY = 3, + DXGI_COMPUTE_PREEMPTION_INSTRUCTION_BOUNDARY = 4, + }; + + enum DXGI_GRAPHICS_PREEMPTION_GRANULARITY + { + DXGI_GRAPHICS_PREEMPTION_DMA_BUFFER_BOUNDARY = 0, + DXGI_GRAPHICS_PREEMPTION_PRIMITIVE_BOUNDARY = 1, + DXGI_GRAPHICS_PREEMPTION_TRIANGLE_BOUNDARY = 2, + DXGI_GRAPHICS_PREEMPTION_PIXEL_BOUNDARY = 3, + DXGI_GRAPHICS_PREEMPTION_INSTRUCTION_BOUNDARY = 4, + }; + + enum DXGI_OFFER_RESOURCE_PRIORITY + { + DXGI_OFFER_RESOURCE_PRIORITY_LOW = 1, + DXGI_OFFER_RESOURCE_PRIORITY_NORMAL = (DXGI_OFFER_RESOURCE_PRIORITY_LOW + 1), + DXGI_OFFER_RESOURCE_PRIORITY_HIGH = (DXGI_OFFER_RESOURCE_PRIORITY_NORMAL + 1) + }; + + enum DXGI_OUTDUPL_POINTER_SHAPE_TYPE + { + DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME = 0x1, + DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR = 0x2, + DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR = 0x4, + }; + + enum DXGI_SCALING + { + DXGI_SCALING_STRETCH = 0, + DXGI_SCALING_NONE = 1, + DXGI_SCALING_ASPECT_RATIO_STRETCH = 2, + }; +} + +namespace REX::W32 +{ + struct DXGI_ADAPTER_DESC2 + { + wchar_t description[128]; + std::uint32_t vendorID; + std::uint32_t deviceID; + std::uint32_t subSysID; + std::uint32_t revision; + std::size_t dedicatedVideoMemory; + std::size_t dedicatedSystemMemory; + std::size_t sharedSystemMemory; + LUID adapterLUID; + std::uint32_t flags; + DXGI_GRAPHICS_PREEMPTION_GRANULARITY graphicsPreemptionGranularity; + DXGI_COMPUTE_PREEMPTION_GRANULARITY computePreemptionGranularity; + }; + + struct DXGI_MODE_DESC1 + { + std::uint32_t width; + std::uint32_t height; + DXGI_RATIONAL refreshRate; + DXGI_FORMAT format; + DXGI_MODE_SCANLINE_ORDER scanlineOrdering; + DXGI_MODE_SCALING scaling; + BOOL stereo; + }; + + struct DXGI_OUTDUPL_DESC + { + DXGI_MODE_DESC modeDesc; + DXGI_MODE_ROTATION rotation; + BOOL desktopImageInSystemMemory; + }; + + struct DXGI_OUTDUPL_POINTER_POSITION + { + POINT position; + BOOL visible; + }; + + struct DXGI_OUTDUPL_FRAME_INFO + { + std::int64_t lastPresentTime; + std::int64_t lastMouseUpdateTime; + std::uint32_t accumulatedFrames; + BOOL rectsCoalesced; + BOOL protectedContentMaskedOut; + DXGI_OUTDUPL_POINTER_POSITION pointerPosition; + std::uint32_t totalMetadataBufferSize; + std::uint32_t pointerShapeBufferSize; + }; + + struct DXGI_OUTDUPL_MOVE_RECT + { + POINT sourcePoint; + RECT destinationRect; + }; + + struct DXGI_OUTDUPL_POINTER_SHAPE_INFO + { + std::uint32_t type; + std::uint32_t width; + std::uint32_t height; + std::uint32_t pitch; + POINT hotSpot; + }; + + struct DXGI_PRESENT_PARAMETERS + { + std::uint32_t dirtyRectsCount; + RECT* dirtyRects; + RECT* scrollRect; + POINT* scrollOffset; + }; + + struct DXGI_SWAP_CHAIN_DESC1 + { + std::uint32_t width; + std::uint32_t height; + DXGI_FORMAT format; + BOOL stereo; + DXGI_SAMPLE_DESC sampleDesc; + DXGI_USAGE bufferUsage; + std::uint32_t bufferCount; + DXGI_SCALING scaling; + DXGI_SWAP_EFFECT swapEffect; + DXGI_ALPHA_MODE alphaMode; + std::uint32_t flags; + }; + + struct DXGI_SWAP_CHAIN_FULLSCREEN_DESC + { + DXGI_RATIONAL refreshRate; + DXGI_MODE_SCANLINE_ORDER scanlineOrdering; + DXGI_MODE_SCALING scaling; + BOOL windowed; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("0AA1AE0A-FA0E-4B84-8644-E05FF8E5ACB5")) + IDXGIAdapter2 : public IDXGIAdapter1 + { + virtual HRESULT GetDesc2(DXGI_ADAPTER_DESC2* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("05008617-FBFD-4051-A790-144884B4F6A9")) + IDXGIDevice2 : public IDXGIDevice1 + { + virtual HRESULT OfferResources(std::uint32_t a_numResources, IDXGIResource* const* a_resources, DXGI_OFFER_RESOURCE_PRIORITY a_priority) = 0; + virtual HRESULT ReclaimResources(std::uint32_t a_numResources, IDXGIResource* const* a_resources, BOOL* a_discarded) = 0; + virtual HRESULT EnqueueSetEvent(HANDLE a_event) = 0; + }; + + struct __declspec(novtable, uuid("EA9DBF1A-C88E-4486-854A-98AA0138F30C")) + IDXGIDisplayControl : public IUnknown + { + virtual BOOL IsStereoEnabled(void) = 0; + virtual void SetStereoEnabled(BOOL a_enabled) = 0; + }; + + struct __declspec(novtable, uuid("50C83A1C-E072-4C48-87B0-3630FA36A6D0")) + IDXGIFactory2 : public IDXGIFactory1 + { + virtual BOOL IsWindowedStereoEnabled(void) = 0; + virtual HRESULT CreateSwapChainForHwnd(IUnknown* a_device, HWND a_wnd, const DXGI_SWAP_CHAIN_DESC1* a_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* a_fullscreenDesc, IDXGIOutput* a_restrictToOutput, IDXGISwapChain1** a_swapChain) = 0; + virtual HRESULT CreateSwapChainForCoreWindow(IUnknown* a_device, IUnknown* a_window, const DXGI_SWAP_CHAIN_DESC1* a_desc, IDXGIOutput* a_restrictToOutput, IDXGISwapChain1** a_swapChain) = 0; + virtual HRESULT GetSharedResourceAdapterLuid(HANDLE a_resource, LUID* a_luid) = 0; + virtual HRESULT RegisterStereoStatusWindow(HWND a_wnd, std::uint32_t a_msg, std::uint32_t* a_cookie) = 0; + virtual HRESULT RegisterStereoStatusEvent(HANDLE a_event, std::uint32_t* a_cookie) = 0; + virtual void UnregisterStereoStatus(std::uint32_t a_cookie) = 0; + virtual HRESULT RegisterOcclusionStatusWindow(HWND a_wnd, std::uint32_t a_msg, std::uint32_t* a_cookie) = 0; + virtual HRESULT RegisterOcclusionStatusEvent(HANDLE a_event, std::uint32_t* a_cookie) = 0; + virtual void UnregisterOcclusionStatus(std::uint32_t dwCookie) = 0; + virtual HRESULT CreateSwapChainForComposition(IUnknown* a_device, const DXGI_SWAP_CHAIN_DESC1* a_desc, IDXGIOutput* a_restrictToOutput, IDXGISwapChain1** a_swapChain) = 0; + }; + + struct __declspec(novtable, uuid("00CDDEA8-939B-4B83-A340-A685226666CC")) + IDXGIOutput1 : public IDXGIOutput + { + virtual HRESULT GetDisplayModeList1(DXGI_FORMAT a_enumFormat, std::uint32_t a_flags, std::uint32_t* a_numModes, DXGI_MODE_DESC1* a_desc) = 0; + virtual HRESULT FindClosestMatchingMode1(const DXGI_MODE_DESC1* a_modeToMatch, DXGI_MODE_DESC1* a_closestMatch, IUnknown* a_concernedDevice) = 0; + virtual HRESULT GetDisplaySurfaceData1(IDXGIResource* a_destination) = 0; + virtual HRESULT DuplicateOutput(IUnknown* a_device, IDXGIOutputDuplication** a_outputDuplication) = 0; + }; + + struct __declspec(novtable, uuid("191CFAC3-A341-470D-B26E-A864F428319C")) + IDXGIOutputDuplication : public IDXGIObject + { + virtual void GetDesc(DXGI_OUTDUPL_DESC* a_desc) = 0; + virtual HRESULT AcquireNextFrame(std::uint32_t a_timeoutInMilliseconds, DXGI_OUTDUPL_FRAME_INFO* a_frameInfo, IDXGIResource** a_desktopResource) = 0; + virtual HRESULT GetFrameDirtyRects(std::uint32_t a_dirtyRectsBufferSize, RECT* a_dirtyRectsBuffer, std::uint32_t* a_dirtyRectsBufferSizeRequired) = 0; + virtual HRESULT GetFrameMoveRects(std::uint32_t a_moveRectsBufferSize, DXGI_OUTDUPL_MOVE_RECT* a_moveRectBuffer, std::uint32_t* a_moveRectsBufferSizeRequired) = 0; + virtual HRESULT GetFramePointerShape(std::uint32_t a_pointerShapeBufferSize, void* a_pointerShapeBuffer, std::uint32_t* a_pointerShapeBufferSizeRequired, DXGI_OUTDUPL_POINTER_SHAPE_INFO* a_pointerShapeInfo) = 0; + virtual HRESULT MapDesktopSurface(DXGI_MAPPED_RECT* a_lockedRect) = 0; + virtual HRESULT UnMapDesktopSurface(void) = 0; + virtual HRESULT ReleaseFrame(void) = 0; + }; + + struct __declspec(novtable, uuid("30961379-4609-4A41-998E-54FE567EE0C1")) + IDXGIResource1 : public IDXGIResource + { + virtual HRESULT CreateSubresourceSurface(std::uint32_t a_index, IDXGISurface2** a_surface) = 0; + virtual HRESULT CreateSharedHandle(const SECURITY_ATTRIBUTES* a_attributes, std::uint32_t a_access, const wchar_t* a_name, HANDLE* a_handle) = 0; + }; + + struct __declspec(novtable, uuid("ABA496DD-B617-4CB8-A866-BC44D7EB1FA2")) + IDXGISurface2 : public IDXGISurface1 + { + virtual HRESULT GetResource(const IID& a_iid, void** a_parentResource, std::uint32_t* a_subresourceIndex) = 0; + }; + + struct __declspec(novtable, uuid("790A45F7-0D42-4876-983A-0A55CFE6F4AA")) + IDXGISwapChain1 : public IDXGISwapChain + { + virtual HRESULT GetDesc1(DXGI_SWAP_CHAIN_DESC1* a_desc) = 0; + virtual HRESULT GetFullscreenDesc(DXGI_SWAP_CHAIN_FULLSCREEN_DESC* a_desc) = 0; + virtual HRESULT GetHwnd(HWND* a_wnd) = 0; + virtual HRESULT GetCoreWindow(const IID& a_iid, void** a_unk) = 0; + virtual HRESULT Present1(std::uint32_t a_syncInterval, std::uint32_t a_presentFlags, const DXGI_PRESENT_PARAMETERS* a_presentParameters) = 0; + virtual BOOL IsTemporaryMonoSupported(void) = 0; + virtual HRESULT GetRestrictToOutput(IDXGIOutput** a_restrictToOutput) = 0; + virtual HRESULT SetBackgroundColor(const DXGI_RGBA* a_color) = 0; + virtual HRESULT GetBackgroundColor(DXGI_RGBA* a_color) = 0; + virtual HRESULT SetRotation(DXGI_MODE_ROTATION a_rotation) = 0; + virtual HRESULT GetRotation(DXGI_MODE_ROTATION* a_rotation) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_IDXGIAdapter2{ 0x0AA1AE0A, 0xFA0E, 0x4B84, { 0x86, 0x44, 0xE0, 0x5F, 0xF8, 0xE5, 0xAC, 0xB5 } }; + inline constexpr IID IID_IDXGIDevice2{ 0x05008617, 0xFBFD, 0x4051, { 0xA7, 0x90, 0x14, 0x48, 0x84, 0xB4, 0xF6, 0xA9 } }; + inline constexpr IID IID_IDXGIDisplayControl{ 0xEA9DBF1A, 0xC88E, 0x4486, { 0x85, 0x4A, 0x98, 0xAA, 0x01, 0x38, 0xF3, 0x0C } }; + inline constexpr IID IID_IDXGIFactory2{ 0x50C83A1C, 0xE072, 0x4C48, { 0x87, 0xB0, 0x36, 0x30, 0xFA, 0x36, 0xA6, 0xD0 } }; + inline constexpr IID IID_IDXGIOutput1{ 0x00CDDEA8, 0x939B, 0x4B83, { 0xA3, 0x40, 0xA6, 0x85, 0x22, 0x66, 0x66, 0xCC } }; + inline constexpr IID IID_IDXGIOutputDuplication{ 0x191CFAC3, 0xA341, 0x470D, { 0xB2, 0x6E, 0xA8, 0x64, 0xF4, 0x28, 0x31, 0x9C } }; + inline constexpr IID IID_IDXGIResource1{ 0x30961379, 0x4609, 0x4A41, { 0x99, 0x8E, 0x54, 0xFE, 0x56, 0x7E, 0xE0, 0xC1 } }; + inline constexpr IID IID_IDXGISurface2{ 0xABA496DD, 0xB617, 0x4CB8, { 0xA8, 0x66, 0xBC, 0x44, 0xD7, 0xEB, 0x1F, 0xA2 } }; + inline constexpr IID IID_IDXGISwapChain1{ 0x790A45F7, 0x0D42, 0x4876, { 0x98, 0x3A, 0x0A, 0x55, 0xCF, 0xE6, 0xF4, 0xAA } }; +} diff --git a/include/REX/W32/DXGI_3.h b/include/REX/W32/DXGI_3.h new file mode 100644 index 000000000..3dc7040cd --- /dev/null +++ b/include/REX/W32/DXGI_3.h @@ -0,0 +1,148 @@ +#pragma once + +#include "DXGI_2.h" + +namespace REX::W32 +{ + struct IDXGIDecodeSwapChain; + struct IDXGIDevice3; + struct IDXGIFactory3; + struct IDXGIFactoryMedia; + struct IDXGIOutput2; + struct IDXGIOutput3; + struct IDXGISwapChain2; + struct IDXGISwapChainMedia; +} + +namespace REX::W32 +{ + enum DXGI_FRAME_PRESENTATION_MODE + { + DXGI_FRAME_PRESENTATION_MODE_COMPOSED = 0, + DXGI_FRAME_PRESENTATION_MODE_OVERLAY = 1, + DXGI_FRAME_PRESENTATION_MODE_NONE = 2, + DXGI_FRAME_PRESENTATION_MODE_COMPOSITION_FAILURE = 3, + }; + + enum DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS + { + DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_NOMINAL_RANGE = 0x1, + DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_BT709 = 0x2, + DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_xvYCC = 0x4, + }; + + enum DXGI_OVERLAY_SUPPORT_FLAG + { + DXGI_OVERLAY_SUPPORT_FLAG_DIRECT = 0x1, + DXGI_OVERLAY_SUPPORT_FLAG_SCALING = 0x2, + }; +} + +namespace REX::W32 +{ + struct DXGI_DECODE_SWAP_CHAIN_DESC + { + std::uint32_t flags; + }; + + struct DXGI_FRAME_STATISTICS_MEDIA + { + std::uint32_t presentCount; + std::uint32_t presentRefreshCount; + std::uint32_t syncRefreshCount; + std::int64_t syncQPCTime; + std::int64_t syncGPUTime; + DXGI_FRAME_PRESENTATION_MODE compositionMode; + std::uint32_t approvedPresentDuration; + }; + + struct DXGI_MATRIX_3X2_F + { + float _11; + float _12; + float _21; + float _22; + float _31; + float _32; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("2633066B-4514-4C7A-8FD8-12EA98059D18")) + IDXGIDecodeSwapChain : public IUnknown + { + virtual HRESULT PresentBuffer(std::uint32_t a_bufferToPresent, std::uint32_t a_syncInterval, std::uint32_t a_flags) = 0; + virtual HRESULT SetSourceRect(const RECT* a_rect) = 0; + virtual HRESULT SetTargetRect(const RECT* a_rect) = 0; + virtual HRESULT SetDestSize(std::uint32_t a_width, std::uint32_t a_height) = 0; + virtual HRESULT GetSourceRect(RECT* a_rect) = 0; + virtual HRESULT GetTargetRect(RECT* a_rect) = 0; + virtual HRESULT GetDestSize(std::uint32_t* a_width, std::uint32_t* a_height) = 0; + virtual HRESULT SetColorSpace(DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS a_colorSpace) = 0; + virtual DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS GetColorSpace(void) = 0; + }; + + struct __declspec(novtable, uuid("6007896C-3244-4AFD-BF18-A6D3BEDA5023")) + IDXGIDevice3 : public IDXGIDevice2 + { + virtual void Trim(void) = 0; + }; + + struct __declspec(novtable, uuid("25483823-CD46-4C7D-86CA-47AA95B837BD")) + IDXGIFactory3 : public IDXGIFactory2 + { + virtual std::uint32_t GetCreationFlags(void) = 0; + }; + + struct __declspec(novtable, uuid("41E7D1F2-A591-4F7B-A2E5-FA9C843E1C12")) + IDXGIFactoryMedia : public IUnknown + { + virtual HRESULT CreateSwapChainForCompositionSurfaceHandle(IUnknown* a_device, HANDLE a_surface, const DXGI_SWAP_CHAIN_DESC1* a_desc, IDXGIOutput* a_restrictToOutput, IDXGISwapChain1** a_swapChain) = 0; + virtual HRESULT CreateDecodeSwapChainForCompositionSurfaceHandle(IUnknown* a_device, HANDLE a_surface, DXGI_DECODE_SWAP_CHAIN_DESC* a_desc, IDXGIResource* a_yuvDecodeBuffers, IDXGIOutput* a_restrictToOutput, IDXGIDecodeSwapChain** a_swapChain) = 0; + }; + + struct __declspec(novtable, uuid("595E39D1-2724-4663-99B1-DA969DE28364")) + IDXGIOutput2 : public IDXGIOutput1 + { + virtual BOOL SupportsOverlays(void) = 0; + }; + + struct __declspec(novtable, uuid("8A6BB301-7E7E-41F4-A8E0-5B32F7F99B18")) + IDXGIOutput3 : public IDXGIOutput2 + { + virtual HRESULT CheckOverlaySupport(DXGI_FORMAT a_enumFormat, IUnknown* a_concernedDevice, std::uint32_t* a_flags) = 0; + }; + + struct __declspec(novtable, uuid("A8BE2AC4-199F-4946-B331-79599FB98DE7")) + IDXGISwapChain2 : public IDXGISwapChain1 + { + virtual HRESULT SetSourceSize(std::uint32_t a_width, std::uint32_t a_height) = 0; + virtual HRESULT GetSourceSize(std::uint32_t* a_width, std::uint32_t* a_height) = 0; + virtual HRESULT SetMaximumFrameLatency(std::uint32_t a_maxLatency) = 0; + virtual HRESULT GetMaximumFrameLatency(std::uint32_t* a_maxLatency) = 0; + virtual HANDLE GetFrameLatencyWaitableObject(void) = 0; + virtual HRESULT SetMatrixTransform(const DXGI_MATRIX_3X2_F* a_matrix) = 0; + virtual HRESULT GetMatrixTransform(DXGI_MATRIX_3X2_F* a_matrix) = 0; + }; + + struct __declspec(novtable, uuid("DD95B90B-F05F-4F6A-BD65-25BFB264BD84")) + IDXGISwapChainMedia : public IUnknown + { + virtual HRESULT GetFrameStatisticsMedia(DXGI_FRAME_STATISTICS_MEDIA* a_stats) = 0; + virtual HRESULT SetPresentDuration(std::uint32_t a_duration) = 0; + virtual HRESULT CheckPresentDurationSupport(std::uint32_t a_desiredPresentDuration, std::uint32_t* a_closestSmallerPresentDuration, std::uint32_t* a_closestLargerPresentDuration) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_IDXGIDecodeSwapChain{ 0x2633066B, 0x4514, 0x4C7A, { 0x8F, 0xD8, 0x12, 0xEA, 0x98, 0x05, 0x9D, 0x18 } }; + inline constexpr IID IID_IDXGIDevice3{ 0x6007896C, 0x3244, 0x4AFD, { 0xBF, 0x18, 0xA6, 0xD3, 0xBE, 0xDA, 0x50, 0x23 } }; + inline constexpr IID IID_IDXGIFactory3{ 0x25483823, 0xCD46, 0x4C7D, { 0x86, 0xCA, 0x47, 0xAA, 0x95, 0xB8, 0x37, 0xBD } }; + inline constexpr IID IID_IDXGIFactoryMedia{ 0x41E7D1F2, 0xA591, 0x4F7B, { 0xA2, 0xE5, 0xFA, 0x9C, 0x84, 0x3E, 0x1C, 0x12 } }; + inline constexpr IID IID_IDXGIOutput2{ 0x595E39D1, 0x2724, 0x4663, { 0x99, 0xB1, 0xDA, 0x96, 0x9D, 0xE2, 0x83, 0x64 } }; + inline constexpr IID IID_IDXGIOutput3{ 0x8A6BB301, 0x7E7E, 0x41F4, { 0xA8, 0xE0, 0x5B, 0x32, 0xF7, 0xF9, 0x9B, 0x18 } }; + inline constexpr IID IID_IDXGISwapChain2{ 0xA8BE2AC4, 0x199F, 0x4946, { 0xB3, 0x31, 0x79, 0x59, 0x9F, 0xB9, 0x8D, 0xE7 } }; + inline constexpr IID IID_IDXGISwapChainMedia{ 0xDD95B90B, 0xF05F, 0x4F6A, { 0xBD, 0x65, 0x25, 0xBF, 0xB2, 0x64, 0xBD, 0x84 } }; +} diff --git a/include/REX/W32/DXGI_4.h b/include/REX/W32/DXGI_4.h new file mode 100644 index 000000000..82522a1f9 --- /dev/null +++ b/include/REX/W32/DXGI_4.h @@ -0,0 +1,86 @@ +#pragma once + +#include "DXGI_3.h" + +namespace REX::W32 +{ + struct IDXGIAdapter3; + struct IDXGIFactory4; + struct IDXGIOutput4; + struct IDXGISwapChain3; +} + +namespace REX::W32 +{ + enum DXGI_MEMORY_SEGMENT_GROUP + { + DXGI_MEMORY_SEGMENT_GROUP_LOCAL = 0, + DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL = 1, + }; + + enum DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG + { + DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG_PRESENT = 0x1, + }; + + enum DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG + { + DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT = 0x1, + DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_OVERLAY_PRESENT = 0x2, + }; +} + +namespace REX::W32 +{ + struct DXGI_QUERY_VIDEO_MEMORY_INFO + { + std::uint64_t budget; + std::uint64_t currentUsage; + std::uint64_t availableForReservation; + std::uint64_t currentReservation; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("645967A4-1392-4310-A798-8053CE3E93FD")) + IDXGIAdapter3 : public IDXGIAdapter2 + { + virtual HRESULT RegisterHardwareContentProtectionTeardownStatusEvent(HANDLE a_event, std::uint32_t* a_cookie) = 0; + virtual void UnregisterHardwareContentProtectionTeardownStatus(std::uint32_t a_cookie) = 0; + virtual HRESULT QueryVideoMemoryInfo(std::uint32_t a_nodeIndex, DXGI_MEMORY_SEGMENT_GROUP a_memorySegmentGroup, DXGI_QUERY_VIDEO_MEMORY_INFO* a_videoMemoryInfo) = 0; + virtual HRESULT SetVideoMemoryReservation(std::uint32_t a_nodeIndex, DXGI_MEMORY_SEGMENT_GROUP a_memorySegmentGroup, std::uint64_t a_reservation) = 0; + virtual HRESULT RegisterVideoMemoryBudgetChangeNotificationEvent(HANDLE a_event, std::uint32_t* a_cookie) = 0; + virtual void UnregisterVideoMemoryBudgetChangeNotification(std::uint32_t a_cookie) = 0; + }; + + struct __declspec(novtable, uuid("1BC6EA02-EF36-464F-BF0C-21CA39E5168A")) + IDXGIFactory4 : public IDXGIFactory3 + { + virtual HRESULT EnumAdapterByLuid(LUID a_luid, const IID& a_iid, void** a_adapter) = 0; + virtual HRESULT EnumWarpAdapter(const IID& a_iid, void** a_adapter) = 0; + }; + + struct __declspec(novtable, uuid("DC7DCA35-2196-414D-9F53-617884032A60")) + IDXGIOutput4 : public IDXGIOutput3 + { + virtual HRESULT CheckOverlayColorSpaceSupport(DXGI_FORMAT a_format, DXGI_COLOR_SPACE_TYPE a_colorSpace, IUnknown* a_concernedDevice, std::uint32_t* a_flags) = 0; + }; + + struct __declspec(novtable, uuid("94D99BDB-F1F8-4AB0-B236-7DA0170EDAB1")) + IDXGISwapChain3 : public IDXGISwapChain2 + { + virtual std::uint32_t GetCurrentBackBufferIndex(void) = 0; + virtual HRESULT CheckColorSpaceSupport(DXGI_COLOR_SPACE_TYPE a_colorSpace, std::uint32_t* a_colorSpaceSupport) = 0; + virtual HRESULT SetColorSpace1(DXGI_COLOR_SPACE_TYPE a_colorSpace) = 0; + virtual HRESULT ResizeBuffers1(std::uint32_t a_bufferCount, std::uint32_t a_width, std::uint32_t a_height, DXGI_FORMAT a_format, std::uint32_t a_swapChainFlags, const std::uint32_t* a_creationNodeMask, IUnknown* const* a_presentQueue) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_IDXGIAdapter3{ 0x645967A4, 0x1392, 0x4310, { 0xA7, 0x98, 0x80, 0x53, 0xCE, 0x3E, 0x93, 0xFD } }; + inline constexpr IID IID_IDXGIFactory4{ 0x1BC6EA02, 0xEF36, 0x464F, { 0xBF, 0x0C, 0x21, 0xCA, 0x39, 0xE5, 0x16, 0x8A } }; + inline constexpr IID IID_IDXGIOutput4{ 0xDC7DCA35, 0x2196, 0x414D, { 0x9F, 0x53, 0x61, 0x78, 0x84, 0x03, 0x2A, 0x60 } }; + inline constexpr IID IID_IDXGISwapChain3{ 0x94D99BDB, 0xF1F8, 0x4AB0, { 0xB2, 0x36, 0x7D, 0xA0, 0x17, 0x0E, 0xDA, 0xB1 } }; +} diff --git a/include/REX/W32/DXGI_5.h b/include/REX/W32/DXGI_5.h new file mode 100644 index 000000000..80ead088c --- /dev/null +++ b/include/REX/W32/DXGI_5.h @@ -0,0 +1,94 @@ +#pragma once + +#include "DXGI_4.h" + +namespace REX::W32 +{ + struct IDXGIDevice4; + struct IDXGIFactory5; + struct IDXGIOutput5; + struct IDXGISwapChain4; +} + +namespace REX::W32 +{ + enum DXGI_FEATURE + { + DXGI_FEATURE_PRESENT_ALLOW_TEARING = 0, + }; + + enum DXGI_HDR_METADATA_TYPE + { + DXGI_HDR_METADATA_TYPE_NONE = 0, + DXGI_HDR_METADATA_TYPE_HDR10 = 1, + DXGI_HDR_METADATA_TYPE_HDR10PLUS = 2, + }; + + enum DXGI_OFFER_RESOURCE_FLAGS + { + DXGI_OFFER_RESOURCE_FLAG_ALLOW_DECOMMIT = 0x1, + }; + + enum DXGI_RECLAIM_RESOURCE_RESULTS + { + DXGI_RECLAIM_RESOURCE_RESULT_OK = 0, + DXGI_RECLAIM_RESOURCE_RESULT_DISCARDED = 1, + DXGI_RECLAIM_RESOURCE_RESULT_NOT_COMMITTED = 2, + }; +} + +namespace REX::W32 +{ + struct DXGI_HDR_METADATA_HDR10 + { + std::uint16_t redPrimary[2]; + std::uint16_t GreenPrimary[2]; + std::uint16_t bluePrimary[2]; + std::uint16_t whitePoint[2]; + std::uint32_t maxMasteringLuminance; + std::uint32_t minMasteringLuminance; + std::uint16_t maxContentLightLevel; + std::uint16_t maxFrameAverageLightLevel; + }; + + struct DXGI_HDR_METADATA_HDR10PLUS + { + std::uint8_t data[72]; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("95B4F95F-D8DA-4CA4-9EE6-3B76D5968A10")) + IDXGIDevice4 : public IDXGIDevice3 + { + virtual HRESULT OfferResources1(std::uint32_t a_numResources, IDXGIResource* const* a_resources, DXGI_OFFER_RESOURCE_PRIORITY a_priority, std::uint32_t a_flags) = 0; + virtual HRESULT ReclaimResources1(std::uint32_t a_numResources, IDXGIResource* const* a_resources, DXGI_RECLAIM_RESOURCE_RESULTS* a_results) = 0; + }; + + struct __declspec(novtable, uuid("7632E1F5-EE65-4DCA-87FD-84CD75F8838D")) + IDXGIFactory5 : public IDXGIFactory4 + { + virtual HRESULT CheckFeatureSupport(DXGI_FEATURE a_feature, void* a_featureSupportData, std::uint32_t a_featureSupportDataSize) = 0; + }; + + struct __declspec(novtable, uuid("80A07424-AB52-42EB-833C-0C42FD282D98")) + IDXGIOutput5 : public IDXGIOutput4 + { + virtual HRESULT DuplicateOutput1(IUnknown* a_device, std::uint32_t a_flags, std::uint32_t a_supportedFormatsCount, const DXGI_FORMAT* a_supportedFormats, IDXGIOutputDuplication** a_outputDuplication) = 0; + }; + + struct __declspec(novtable, uuid("3D585D5A-BD4A-489E-B1F4-3DBCB6452FFB")) + IDXGISwapChain4 : public IDXGISwapChain3 + { + virtual HRESULT SetHDRMetaData(DXGI_HDR_METADATA_TYPE a_type, std::uint32_t a_size, void* a_metaData) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_IDXGIDevice4{ 0x95B4F95F, 0xD8DA, 0x4CA4, { 0x9E, 0xE6, 0x3B, 0x76, 0xD5, 0x96, 0x8A, 0x10 } }; + inline constexpr IID IID_IDXGIFactory5{ 0x7632E1F5, 0xEE65, 0x4DCA, { 0x87, 0xFD, 0x84, 0xCD, 0x75, 0xF8, 0x83, 0x8D } }; + inline constexpr IID IID_IDXGIOutput5{ 0x80A07424, 0xAB52, 0x42EB, { 0x83, 0x3C, 0x0C, 0x42, 0xFD, 0x28, 0x2D, 0x98 } }; + inline constexpr IID IID_IDXGISwapChain4{ 0x3D585D5A, 0xBD4A, 0x489E, { 0xB1, 0xF4, 0x3D, 0xBC, 0xB6, 0x45, 0x2F, 0xFB } }; +} diff --git a/include/REX/W32/DXGI_6.h b/include/REX/W32/DXGI_6.h new file mode 100644 index 000000000..59ae84df9 --- /dev/null +++ b/include/REX/W32/DXGI_6.h @@ -0,0 +1,114 @@ +#pragma once + +#include "DXGI_5.h" + +namespace REX::W32 +{ + struct IDXGIAdapter4; + struct IDXGIFactory6; + struct IDXGIFactory7; + struct IDXGIOutput6; +} + +namespace REX::W32 +{ + enum DXGI_ADAPTER_FLAG3 + { + DXGI_ADAPTER_FLAG3_NONE = 0, + DXGI_ADAPTER_FLAG3_REMOTE = 1, + DXGI_ADAPTER_FLAG3_SOFTWARE = 2, + DXGI_ADAPTER_FLAG3_ACG_COMPATIBLE = 4, + DXGI_ADAPTER_FLAG3_SUPPORT_MONITORED_FENCES = 8, + DXGI_ADAPTER_FLAG3_SUPPORT_NON_MONITORED_FENCES = 0x10, + DXGI_ADAPTER_FLAG3_KEYED_MUTEX_CONFORMANCE = 0x20, + DXGI_ADAPTER_FLAG3_FORCE_DWORD = 0xFFFFFFFF, + }; + + enum DXGI_GPU_PREFERENCE + { + DXGI_GPU_PREFERENCE_UNSPECIFIED = 0, + DXGI_GPU_PREFERENCE_MINIMUM_POWER = (DXGI_GPU_PREFERENCE_UNSPECIFIED + 1), + DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE = (DXGI_GPU_PREFERENCE_MINIMUM_POWER + 1), + }; + + enum DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAGS + { + DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_FULLSCREEN = 1, + DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_WINDOWED = 2, + DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_CURSOR_STRETCHED = 4, + }; +} + +namespace REX::W32 +{ + struct DXGI_ADAPTER_DESC3 + { + wchar_t description[128]; + std::uint32_t vendorID; + std::uint32_t deviceID; + std::uint32_t subSysID; + std::uint32_t revision; + std::size_t dedicatedVideoMemory; + std::size_t dedicatedSystemMemory; + std::size_t sharedSystemMemory; + LUID adapterLUID; + DXGI_ADAPTER_FLAG3 flags; + DXGI_GRAPHICS_PREEMPTION_GRANULARITY graphicsPreemptionGranularity; + DXGI_COMPUTE_PREEMPTION_GRANULARITY computePreemptionGranularity; + }; + + struct DXGI_OUTPUT_DESC1 + { + wchar_t deviceName[32]; + RECT desktopCoordinates; + BOOL attachedToDesktop; + DXGI_MODE_ROTATION rotation; + HMONITOR monitor; + std::uint32_t bitsPerColor; + DXGI_COLOR_SPACE_TYPE colorSpace; + float redPrimary[2]; + float greenPrimary[2]; + float bluePrimary[2]; + float whitePoint[2]; + float minLuminance; + float maxLuminance; + float maxFullFrameLuminance; + }; +} + +namespace REX::W32 +{ + struct __declspec(novtable, uuid("3C8D99D1-4FBF-4181-A82C-AF66BF7BD24E")) + IDXGIAdapter4 : public IDXGIAdapter3 + { + virtual HRESULT GetDesc3(DXGI_ADAPTER_DESC3* a_desc) = 0; + }; + + struct __declspec(novtable, uuid("C1B6694F-FF09-44A9-B03C-77900A0A1D17")) + IDXGIFactory6 : public IDXGIFactory5 + { + virtual HRESULT EnumAdapterByGpuPreference(std::uint32_t a_adapterFlags, DXGI_GPU_PREFERENCE a_gpuPreference, const IID& a_iid, void** a_adapter) = 0; + }; + + struct __declspec(novtable, uuid("A4966EED-76DB-44DA-84C1-EE9A7AFB20A8")) + IDXGIFactory7 : public IDXGIFactory6 + { + virtual HRESULT RegisterAdaptersChangedEvent(HANDLE a_event, std::uint32_t* a_cookie) = 0; + virtual HRESULT UnregisterAdaptersChangedEvent(std::uint32_t a_cookie) = 0; + }; + + struct __declspec(novtable, uuid("068346E8-AAEC-4B84-ADD7-137F513F77A1")) + IDXGIOutput6 : public IDXGIOutput5 + { + virtual HRESULT GetDesc1(DXGI_OUTPUT_DESC1* a_desc) = 0; + virtual HRESULT CheckHardwareCompositionSupport(std::uint32_t* a_flags) = 0; + }; +} + +namespace REX::W32 +{ + inline constexpr IID IID_IDXGIAdapter4{ 0x3C8D99D1, 0x4FBF, 0x4181, { 0xA8, 0x2C, 0xAF, 0x66, 0xBF, 0x7B, 0xD2, 0x4E } }; + inline constexpr IID IID_IDXGIFactory6{ 0xC1B6694F, 0xFF09, 0x44A9, { 0xB0, 0x3C, 0x77, 0x90, 0x0A, 0x0A, 0x1D, 0x17 } }; + inline constexpr IID IID_IDXGIFactory7{ 0xA4966EED, 0x76DB, 0x44DA, { 0x84, 0xC1, 0xEE, 0x9A, 0x7A, 0xFB, 0x20, 0xA8 } }; + inline constexpr IID IID_IDXGIOutput6{ 0x068346E8, 0xAAEC, 0x4B84, { 0xAD, 0xD7, 0x13, 0x7F, 0x51, 0x3F, 0x77, 0xA1 } }; +} diff --git a/include/REX/W32/KERNEL32.h b/include/REX/W32/KERNEL32.h new file mode 100644 index 000000000..38a3d3938 --- /dev/null +++ b/include/REX/W32/KERNEL32.h @@ -0,0 +1,506 @@ +#pragma once + +#include "REX/W32/BASE.h" + +namespace REX::W32 +{ + // standard access + inline constexpr auto STANDARD_RIGHTS_REQUIRED{ 0x000F0000 }; + inline constexpr auto STANDARD_RIGHTS_ALL{ 0x001F0000 }; + + // code page identifiers + inline constexpr auto CP_UTF8{ 65001u }; + + // memory allocation types + inline constexpr auto MEM_COMMIT{ 0x00001000u }; + inline constexpr auto MEM_RESERVE{ 0x00002000u }; + inline constexpr auto MEM_DECOMMIT{ 0x00004000u }; + inline constexpr auto MEM_RELEASE{ 0x00008000u }; + inline constexpr auto MEM_FREE{ 0x00010000u }; + inline constexpr auto MEM_RESET{ 0x00080000u }; + inline constexpr auto MEM_RESET_UNDO{ 0x01000000u }; + + // memory page protection attributes + inline constexpr auto PAGE_NOACCESS{ 0x00000001u }; + inline constexpr auto PAGE_READONLY{ 0x00000002u }; + inline constexpr auto PAGE_READWRITE{ 0x00000004u }; + inline constexpr auto PAGE_WRITECOPY{ 0x00000008u }; + inline constexpr auto PAGE_EXECUTE{ 0x00000010u }; + inline constexpr auto PAGE_EXECUTE_READ{ 0x00000020u }; + inline constexpr auto PAGE_EXECUTE_READWRITE{ 0x00000040u }; + + // memory section + inline constexpr auto SECTION_QUERY{ 0x00000001 }; + inline constexpr auto SECTION_MAP_WRITE{ 0x00000002 }; + inline constexpr auto SECTION_MAP_READ{ 0x00000004 }; + inline constexpr auto SECTION_MAP_EXECUTE{ 0x00000008 }; + inline constexpr auto SECTION_EXTEND_SIZE{ 0x00000010 }; + inline constexpr auto SECTION_MAP_EXECUTE_EXPLICIT{ 0x00000020 }; + inline constexpr auto SECTION_ALL_ACCESS{ + STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE + }; + + // file attributes + inline constexpr auto FILE_ATTRIBUTE_READONLY{ 0x00000001u }; + inline constexpr auto FILE_ATTRIBUTE_HIDDEN{ 0x00000002u }; + inline constexpr auto FILE_ATTRIBUTE_SYSTEM{ 0x00000004u }; + inline constexpr auto FILE_ATTRIBUTE_DIRECTORY{ 0x00000010u }; + inline constexpr auto FILE_ATTRIBUTE_ARCHIVE{ 0x00000020u }; + + // file mapping flags + inline constexpr auto FILE_MAP_ALL_ACCESS{ SECTION_ALL_ACCESS }; + inline constexpr auto FILE_MAP_COPY{ 0x00000001u }; + inline constexpr auto FILE_MAP_WRITE{ 0x00000002u }; + inline constexpr auto FILE_MAP_READ{ 0x00000004u }; + inline constexpr auto FILE_MAP_EXECUTE{ 0x00000020u }; + inline constexpr auto FILE_MAP_LARGE_PAGES{ 0x20000000u }; + inline constexpr auto FILE_MAP_TARGETS_INVALID{ 0x40000000u }; + inline constexpr auto FILE_MAP_RESERVE{ 0x80000000u }; + + // file open mode flags + inline constexpr auto GENERIC_READ{ 0x80000000L }; + inline constexpr auto GENERIC_WRITE{ 0x40000000L }; + inline constexpr auto GENERIC_EXECUTE{ 0x20000000L }; + inline constexpr auto GENERIC_ALL{ 0x10000000L }; + + // pe image header + inline constexpr auto IMAGE_DOS_SIGNATURE{ 0x5A4Du }; + inline constexpr auto IMAGE_NT_SIGNATURE{ 0x00004550u }; + inline constexpr auto IMAGE_NT_OPTIONAL_HDR32_MAGIC{ 0x10Bu }; + inline constexpr auto IMAGE_NT_OPTIONAL_HDR64_MAGIC{ 0x20Bu }; + + // pe image directory entries + inline constexpr auto IMAGE_DIRECTORY_ENTRY_EXPORT{ 0u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_IMPORT{ 1u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_RESOURCE{ 2u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_EXCEPTION{ 3u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_SECURITY{ 4u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_BASERELOC{ 5u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_DEBUG{ 6u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_ARCHITECTURE{ 7u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_GLOBALPTR{ 8u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_TLS{ 9u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG{ 10u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT{ 11u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_IAT{ 12u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT{ 13u }; + inline constexpr auto IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR{ 14u }; + inline constexpr auto IMAGE_NUMBEROF_DIRECTORY_ENTRIES{ 16u }; + + // pe image ordinal + inline constexpr auto IMAGE_ORDINAL_FLAG32{ 0x80000000u }; + inline constexpr auto IMAGE_ORDINAL_FLAG64{ 0x8000000000000000ull }; + + // pe image section header characteristics + inline constexpr auto IMAGE_SCN_MEM_SHARED{ 0x10000000u }; + inline constexpr auto IMAGE_SCN_MEM_EXECUTE{ 0x20000000u }; + inline constexpr auto IMAGE_SCN_MEM_READ{ 0x40000000u }; + inline constexpr auto IMAGE_SCN_MEM_WRITE{ 0x80000000u }; + inline constexpr auto IMAGE_SIZEOF_SECTION_HEADER{ 40u }; + inline constexpr auto IMAGE_SIZEOF_SHORT_NAME{ 8u }; + + // process creation flags + inline constexpr auto DEBUG_PROCESS{ 0x00000001u }; + inline constexpr auto DEBUG_ONLY_THIS_PROCESS{ 0x00000002u }; + inline constexpr auto CREATE_SUSPENDED{ 0x00000004u }; + inline constexpr auto DETACHED_PROCESS{ 0x00000008u }; + inline constexpr auto CREATE_NEW_CONSOLE{ 0x00000010u }; + inline constexpr auto NORMAL_PRIORITY_CLASS{ 0x00000020u }; + inline constexpr auto IDLE_PRIORITY_CLASS{ 0x00000040u }; + inline constexpr auto HIGH_PRIORITY_CLASS{ 0x00000080u }; + inline constexpr auto REALTIME_PRIORITY_CLASS{ 0x00000100u }; + inline constexpr auto CREATE_NEW_PROCESS_GROUP{ 0x00000200u }; + inline constexpr auto CREATE_UNICODE_ENVIRONMENT{ 0x00000400u }; + inline constexpr auto CREATE_FORCEDOS{ 0x00002000u }; + inline constexpr auto BELOW_NORMAL_PRIORITY_CLASS{ 0x00004000u }; + inline constexpr auto ABOVE_NORMAL_PRIORITY_CLASS{ 0x00008000u }; + inline constexpr auto INHERIT_PARENT_AFFINITY{ 0x00010000u }; + inline constexpr auto CREATE_PROTECTED_PROCESS{ 0x00040000u }; + inline constexpr auto EXTENDED_STARTUPINFO_PRESENT{ 0x00080000u }; + inline constexpr auto PROCESS_MODE_BACKGROUND_BEGIN{ 0x00100000u }; + inline constexpr auto PROCESS_MODE_BACKGROUND_END{ 0x00200000u }; + inline constexpr auto CREATE_SECURE_PROCESS{ 0x00400000 }; + inline constexpr auto CREATE_BREAKAWAY_FROM_JOB{ 0x01000000u }; + inline constexpr auto CREATE_PRESERVE_CODE_AUTHZ_LEVEL{ 0x02000000u }; + inline constexpr auto CREATE_DEFAULT_ERROR_MODE{ 0x04000000u }; + inline constexpr auto CREATE_NO_WINDOW{ 0x08000000u }; + + // locale map flags + inline constexpr auto LCMAP_LOWERCASE{ 0x00000100u }; + inline constexpr auto LCMAP_UPPERCASE{ 0x00000200u }; + inline constexpr auto LCMAP_TITLECASE{ 0x00000300u }; + inline constexpr auto LCMAP_SORTKEY{ 0x00000400u }; + inline constexpr auto LCMAP_BYTEREV{ 0x00000800u }; + inline constexpr auto LCMAP_HIRAGANA{ 0x00100000u }; + inline constexpr auto LCMAP_KATAKANA{ 0x00200000u }; + inline constexpr auto LCMAP_HALFWIDTH{ 0x00400000u }; + inline constexpr auto LCMAP_FULLWIDTH{ 0x00800000u }; + inline constexpr auto LCMAP_LINGUISTIC_CASING{ 0x01000000u }; + inline constexpr auto LCMAP_SIMPLIFIED_CHINESE{ 0x02000000u }; + inline constexpr auto LCMAP_TRADITIONAL_CHINESE{ 0x04000000u }; + + // locale names + inline constexpr auto LOCALE_NAME_USER_DEFAULT{ nullptr }; + inline constexpr auto LOCALE_NAME_INVARIANT{ L"" }; + inline constexpr auto LOCALE_NAME_SYSTEM_DEFAULT{ L"!x-sys-default-locale" }; +} + +namespace REX::W32 +{ + struct IMAGE_DATA_DIRECTORY + { + std::uint32_t virtualAddress; + std::uint32_t size; + }; + static_assert(sizeof(IMAGE_DATA_DIRECTORY) == 0x8); + + struct IMAGE_DOS_HEADER + { + std::uint16_t magic; + std::uint16_t cblp; + std::uint16_t cp; + std::uint16_t crlc; + std::uint16_t cparhdr; + std::uint16_t minalloc; + std::uint16_t maxalloc; + std::uint16_t ss; + std::uint16_t sp; + std::uint16_t csum; + std::uint16_t ip; + std::uint16_t cs; + std::uint16_t lfarlc; + std::uint16_t ovno; + std::uint16_t res[4]; + std::uint16_t oemid; + std::uint16_t oeminfo; + std::uint16_t res2[10]; + std::int32_t lfanew; + }; + static_assert(sizeof(IMAGE_DOS_HEADER) == 0x40); + + struct IMAGE_FILE_HEADER + { + std::uint16_t machine; + std::uint16_t sectionCount; + std::uint32_t timeDateStamp; + std::uint32_t symbolTablePtr; + std::uint32_t symbolCount; + std::uint16_t optionalHeaderSize; + std::uint16_t characteristics; + }; + static_assert(sizeof(IMAGE_FILE_HEADER) == 0x14); + + struct IMAGE_IMPORT_BY_NAME + { + std::uint16_t hint; + char name[1]; + }; + static_assert(sizeof(IMAGE_IMPORT_BY_NAME) == 0x4); + + struct IMAGE_IMPORT_DESCRIPTOR + { + union + { + std::uint32_t characteristics; + std::uint32_t firstThunkOriginal; + }; + + std::uint32_t timeDateStamp; + std::uint32_t forwarderChain; + std::uint32_t name; + std::uint32_t firstThunk; + }; + static_assert(sizeof(IMAGE_IMPORT_DESCRIPTOR) == 0x14); + + struct IMAGE_OPTIONAL_HEADER64 + { + std::uint16_t magic; + std::uint8_t linkerVersionMajor; + std::uint8_t linkerVersionMinor; + std::uint32_t codeSize; + std::uint32_t initializedDataSize; + std::uint32_t uninitializedDataSize; + std::uint32_t entryPointAddress; + std::uint32_t codeBase; + std::uint64_t imageBase; + std::uint32_t sectionAlignment; + std::uint32_t fileAlignment; + std::uint16_t osVersionMajor; + std::uint16_t osVersionMinor; + std::uint16_t imageVersionMajor; + std::uint16_t imageVersionMinor; + std::uint16_t subsystemVersionMajor; + std::uint16_t subsystemVersionMinor; + std::uint32_t win32Version; + std::uint32_t imageSize; + std::uint32_t headersSize; + std::uint32_t checksum; + std::uint16_t subsystem; + std::uint16_t dllCharacteristics; + std::uint64_t stackReserveSize; + std::uint64_t stackCommitSize; + std::uint64_t heapReserveSize; + std::uint64_t heapCommitSize; + std::uint32_t loaderFlags; + std::uint32_t rvaAndSizesCount; + IMAGE_DATA_DIRECTORY dataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; + }; + static_assert(sizeof(IMAGE_OPTIONAL_HEADER64) == 0xF0); + + struct IMAGE_NT_HEADERS64 + { + std::uint32_t signature; + IMAGE_FILE_HEADER fileHeader; + IMAGE_OPTIONAL_HEADER64 optionalHeader; + }; + static_assert(sizeof(IMAGE_NT_HEADERS64) == 0x108); + + struct IMAGE_SECTION_HEADER + { + std::uint8_t name[IMAGE_SIZEOF_SHORT_NAME]; + union + { + std::uint32_t physicalAddress; + std::uint32_t virtualSize; + }; + std::uint32_t virtualAddress; + std::uint32_t rawDataSize; + std::uint32_t rawDataPtr; + std::uint32_t relocationsPtr; + std::uint32_t lineNumbersPtr; + std::uint16_t relocationsCount; + std::uint16_t lineNumbersCount; + std::uint32_t characteristics; + }; + static_assert(sizeof(IMAGE_SECTION_HEADER) == 0x28); + + struct IMAGE_THUNK_DATA64 + { + union + { + std::uint64_t forwarderString; + std::uint64_t function; + std::uint64_t ordinal; + std::uint64_t address; + }; + }; + static_assert(sizeof(IMAGE_THUNK_DATA64) == 0x8); + + struct MEMORY_BASIC_INFORMATION + { + void* baseAddress; + void* allocationBase; + std::uint32_t allocationProtect; + std::uint16_t partitionID; + std::size_t regionSize; + std::uint32_t state; + std::uint32_t protect; + std::uint32_t type; + }; + static_assert(sizeof(MEMORY_BASIC_INFORMATION) == 0x30); + + struct NLSVERSIONINFO + { + std::uint32_t nlsVersionInfoSize; + std::uint32_t nlsVersion; + std::uint32_t definedVersion; + std::uint32_t effectiveID; + GUID guidCustomVersion; + }; + static_assert(sizeof(NLSVERSIONINFO) == 0x20); + + struct PROCESS_INFORMATION + { + void* process; + void* thread; + std::uint32_t processID; + std::uint32_t threadID; + }; + static_assert(sizeof(PROCESS_INFORMATION) == 0x18); + + struct STARTUPINFOA + { + std::uint32_t size; + char* reserved0; + char* desktop; + char* title; + std::uint32_t x; + std::uint32_t y; + std::uint32_t xSize; + std::uint32_t ySize; + std::uint32_t xCountChars; + std::uint32_t yCountChars; + std::uint32_t fillAttribute; + std::uint32_t flags; + std::uint16_t showWindow; + std::uint16_t reserved1; + std::uint8_t* reserved2; + void* stdIn; + void* stdOut; + void* stdErr; + }; + static_assert(sizeof(STARTUPINFOA) == 0x68); + + struct STARTUPINFOW + { + std::uint32_t size; + wchar_t* reserved0; + wchar_t* desktop; + wchar_t* title; + std::uint32_t x; + std::uint32_t y; + std::uint32_t xSize; + std::uint32_t ySize; + std::uint32_t xCountChars; + std::uint32_t yCountChars; + std::uint32_t fillAttribute; + std::uint32_t flags; + std::uint16_t showWindow; + std::uint16_t reserved1; + std::uint8_t* reserved2; + void* stdIn; + void* stdOut; + void* stdErr; + }; + static_assert(sizeof(STARTUPINFOW) == 0x68); + + struct SYSTEM_INFO + { + union + { + std::uint32_t oemID; + struct + { + std::uint16_t processorArch; + std::uint16_t reserved; + }; + }; + std::uint32_t pageSize; + void* appAddressMin; + void* appAddressMax; + std::uintptr_t processorActiveMask; + std::uint32_t processorCount; + std::uint32_t processorType; + std::uint32_t allocationGranularity; + std::uint16_t processorLevel; + std::uint16_t processorRevision; + }; + static_assert(sizeof(SYSTEM_INFO) == 0x30); + + struct WIN32_FIND_DATAA + { + std::uint32_t fileAttributes; + FILETIME creationTime; + FILETIME lastAccessTime; + FILETIME lastWriteTime; + std::uint32_t fileSizeHi; + std::uint32_t fileSizeLo; + std::uint32_t reserved0; + std::uint32_t reserved1; + char fileName[MAX_PATH]; + char fileNameAlt[14]; + }; + static_assert(sizeof(WIN32_FIND_DATAA) == 0x140); + + struct WIN32_FIND_DATAW + { + std::uint32_t fileAttributes; + FILETIME creationTime; + FILETIME lastAccessTime; + FILETIME lastWriteTime; + std::uint32_t fileSizeHi; + std::uint32_t fileSizeLo; + std::uint32_t reserved0; + std::uint32_t reserved1; + wchar_t fileName[MAX_PATH]; + wchar_t fileNameAlt[14]; + }; + static_assert(sizeof(WIN32_FIND_DATAW) == 0x250); +} + +namespace REX::W32 +{ + using THREAD_START_ROUTINE = std::uint32_t(void* a_param); +} + +namespace REX::W32 +{ + bool CloseHandle(HANDLE a_handle) noexcept; + HANDLE CreateFileMappingA(HANDLE a_file, SECURITY_ATTRIBUTES* a_attributes, std::uint32_t a_protect, std::uint32_t a_maxSizeHigh, std::uint32_t a_maxSizeLow, const char* a_name) noexcept; + HANDLE CreateFileMappingW(HANDLE a_file, SECURITY_ATTRIBUTES* a_attributes, std::uint32_t a_protect, std::uint32_t a_maxSizeHigh, std::uint32_t a_maxSizeLow, const wchar_t* a_name) noexcept; + bool CreateProcessA(const char* a_name, char* a_cmd, SECURITY_ATTRIBUTES* a_procAttr, SECURITY_ATTRIBUTES* a_threadAttr, bool a_inheritHandles, std::uint32_t a_flags, void* a_env, const char* a_curDir, STARTUPINFOA* a_startInfo, PROCESS_INFORMATION* a_procInfo) noexcept; + bool CreateProcessW(const wchar_t* a_name, wchar_t* a_cmd, SECURITY_ATTRIBUTES* a_procAttr, SECURITY_ATTRIBUTES* a_threadAttr, bool a_inheritHandles, std::uint32_t a_flags, void* a_env, const wchar_t* a_curDir, STARTUPINFOW* a_startInfo, PROCESS_INFORMATION* a_procInfo) noexcept; + HANDLE CreateRemoteThread(HANDLE a_process, SECURITY_ATTRIBUTES* a_threadAttr, std::size_t a_stackSize, THREAD_START_ROUTINE* a_startAddr, void* a_param, std::uint32_t a_flags, std::uint32_t* a_threadID) noexcept; + HANDLE CreateSemaphoreA(SECURITY_ATTRIBUTES* a_semaphoreAttr, std::int32_t a_initCount, std::int32_t a_maxCount, const char* a_name); + HANDLE CreateThread(SECURITY_ATTRIBUTES* a_threadAttr, std::size_t a_stackSize, THREAD_START_ROUTINE* a_startAddr, void* a_param, std::uint32_t a_flags, std::uint32_t* a_threadID) noexcept; + void DeleteCriticalSection(CRITICAL_SECTION* a_criticalSection); + void EnterCriticalSection(CRITICAL_SECTION* a_criticalSection); + std::uint32_t ExpandEnvironmentStrings(const char* a_src, char* a_dst, std::uint32_t a_dstLen) noexcept; + std::uint32_t ExpandEnvironmentStrings(const wchar_t* a_src, wchar_t* a_dst, std::uint32_t a_dstLen) noexcept; + bool FindClose(HANDLE a_file) noexcept; + HANDLE FindFirstFileA(const char* a_name, WIN32_FIND_DATAA* a_data) noexcept; + HANDLE FindFirstFileW(const wchar_t* a_name, WIN32_FIND_DATAW* a_data) noexcept; + bool FindNextFileA(HANDLE a_file, WIN32_FIND_DATAA* a_data) noexcept; + bool FindNextFileW(HANDLE a_file, WIN32_FIND_DATAW* a_data) noexcept; + bool FlushInstructionCache(HANDLE a_process, const void* a_baseAddr, std::size_t a_size) noexcept; + bool FreeLibrary(HMODULE a_module) noexcept; + HMODULE GetCurrentModule() noexcept; + HANDLE GetCurrentProcess() noexcept; + std::uint32_t GetCurrentThreadId() noexcept; + std::uint32_t GetEnvironmentVariableA(const char* a_name, char* a_buf, std::uint32_t a_bufLen) noexcept; + std::uint32_t GetEnvironmentVariableW(const wchar_t* a_name, wchar_t* a_buf, std::uint32_t a_bufLen) noexcept; + std::uint32_t GetLastError() noexcept; + std::uint32_t GetModuleFileNameA(HMODULE a_module, char* a_name, std::uint32_t a_nameLen) noexcept; + std::uint32_t GetModuleFileNameW(HMODULE a_module, wchar_t* a_name, std::uint32_t a_nameLen) noexcept; + HMODULE GetModuleHandleA(const char* a_name) noexcept; + HMODULE GetModuleHandleW(const wchar_t* a_name) noexcept; + std::uint32_t GetPrivateProfileStringA(const char* a_app, const char* a_key, const char* a_default, char* a_buf, std::uint32_t a_bufLen, const char* a_name) noexcept; + std::uint32_t GetPrivateProfileStringW(const wchar_t* a_app, const wchar_t* a_key, const wchar_t* a_default, wchar_t* a_buf, std::uint32_t a_bufLen, const wchar_t* a_name) noexcept; + void* GetProcAddress(HMODULE a_module, const char* a_name) noexcept; + void GetSystemInfo(SYSTEM_INFO* a_info) noexcept; + bool IMAGE_SNAP_BY_ORDINAL64(std::uint64_t a_ordinal) noexcept; + IMAGE_SECTION_HEADER* IMAGE_FIRST_SECTION(const IMAGE_NT_HEADERS64* a_header) noexcept; + bool InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION* a_criticalSection, std::uint32_t a_spinCount); + std::uint32_t InterlockedCompareExchange(volatile std::uint32_t* a_target, std::uint32_t a_value, std::uint32_t a_compare) noexcept; + std::uint64_t InterlockedCompareExchange64(volatile std::uint64_t* a_target, std::uint64_t a_value, std::uint64_t a_compare) noexcept; + std::uint32_t InterlockedDecrement(volatile std::uint32_t* a_target) noexcept; + std::uint64_t InterlockedDecrement64(volatile std::uint64_t* a_target) noexcept; + std::uint32_t InterlockedExchange(volatile std::uint32_t* a_target, std::uint32_t a_value) noexcept; + std::uint64_t InterlockedExchange64(volatile std::uint64_t* a_target, std::uint64_t a_value) noexcept; + std::uint32_t InterlockedIncrement(volatile std::uint32_t* a_target) noexcept; + std::uint64_t InterlockedIncrement64(volatile std::uint64_t* a_target) noexcept; + bool IsDebuggerPresent() noexcept; + std::int32_t LCMapStringEx(const wchar_t* a_locale, std::uint32_t a_flags, const wchar_t* a_src, std::int32_t a_srcLen, wchar_t* a_dst, std::int32_t a_dstLen, NLSVERSIONINFO* a_info, void* a_reserved, std::intptr_t a_sortHandle) noexcept; + void LeaveCriticalSection(CRITICAL_SECTION* a_criticalSection); + HMODULE LoadLibraryA(const char* a_name) noexcept; + HMODULE LoadLibraryW(const wchar_t* a_name) noexcept; + void* MapViewOfFile(HANDLE a_object, std::uint32_t a_desiredAccess, std::uint32_t a_fileOffsetHi, std::uint32_t a_fileOffsetLo, std::size_t a_numBytes) noexcept; + void* MapViewOfFileEx(HANDLE a_object, std::uint32_t a_desiredAccess, std::uint32_t a_fileOffsetHi, std::uint32_t a_fileOffsetLo, std::size_t a_numBytes, void* a_baseAddr) noexcept; + std::int32_t MultiByteToWideChar(std::uint32_t a_codePage, std::uint32_t a_flags, const char* a_src, std::int32_t a_srcLen, wchar_t* a_dst, std::int32_t a_dstLen) noexcept; + HANDLE OpenFileMappingA(std::uint32_t a_desiredAccess, bool a_inheritHandle, const char* a_name) noexcept; + HANDLE OpenFileMappingW(std::uint32_t a_desiredAccess, bool a_inheritHandle, const wchar_t* a_name) noexcept; + void OutputDebugStringA(const char* a_str) noexcept; + void OutputDebugStringW(const wchar_t* a_str) noexcept; + bool QueryPerformanceCounter(std::int64_t* a_counter) noexcept; + bool QueryPerformanceFrequency(std::int64_t* a_frequency) noexcept; + std::uint32_t ResumeThread(HANDLE a_handle) noexcept; + bool SetEnvironmentVariableA(const char* a_name, const char* a_value) noexcept; + bool SetEnvironmentVariableW(const wchar_t* a_name, const wchar_t* a_value) noexcept; + void Sleep(std::uint32_t a_milliseconds) noexcept; + bool TerminateProcess(HANDLE a_process, std::uint32_t a_exitCode) noexcept; + void* TlsGetValue(std::uint32_t a_index) noexcept; + bool TlsSetValue(std::uint32_t a_index, void* a_value) noexcept; + bool UnmapViewOfFile(const void* a_baseAddress) noexcept; + void* VirtualAlloc(void* a_address, std::size_t a_size, std::uint32_t a_type, std::uint32_t a_protect) noexcept; + void* VirtualAllocEx(HANDLE a_process, void* a_address, std::size_t a_size, std::uint32_t a_type, std::uint32_t a_protect) noexcept; + bool VirtualFree(void* a_address, std::size_t a_size, std::uint32_t a_type) noexcept; + bool VirtualFreeEx(HANDLE a_process, void* a_address, std::size_t a_size, std::uint32_t a_type) noexcept; + bool VirtualProtect(void* a_address, std::size_t a_size, std::uint32_t a_newProtect, std::uint32_t* a_oldProtect) noexcept; + bool VirtualProtectEx(HANDLE a_process, void* a_address, std::size_t a_size, std::uint32_t a_newProtect, std::uint32_t* a_oldProtect) noexcept; + std::size_t VirtualQuery(const void* a_address, MEMORY_BASIC_INFORMATION* a_buf, std::size_t a_bufLen) noexcept; + std::size_t VirtualQueryEx(HANDLE a_process, const void* a_address, MEMORY_BASIC_INFORMATION* a_buf, std::size_t a_bufLen) noexcept; + std::uint32_t WaitForSingleObject(HANDLE a_handle, std::uint32_t a_milliseconds) noexcept; + std::uint32_t WaitForSingleObjectEx(HANDLE a_handle, std::uint32_t a_milliseconds, bool a_alertable) noexcept; + std::int32_t WideCharToMultiByte(std::uint32_t a_codePage, std::uint32_t a_flags, const wchar_t* a_src, std::int32_t a_srcLen, char* a_dst, std::int32_t a_dstLen, const char* a_default, std::int32_t* a_defaultLen); + bool WriteProcessMemory(HANDLE a_process, void* a_address, const void* a_buf, std::size_t a_bufLen, std::size_t* a_bufWritten) noexcept; +} diff --git a/include/REX/W32/OLE32.h b/include/REX/W32/OLE32.h new file mode 100644 index 000000000..517861ec4 --- /dev/null +++ b/include/REX/W32/OLE32.h @@ -0,0 +1,8 @@ +#pragma once + +#include "REX/W32/BASE.h" + +namespace REX::W32 +{ + void CoTaskMemFree(void* a_block) noexcept; +} diff --git a/include/REX/W32/SHELL32.h b/include/REX/W32/SHELL32.h new file mode 100644 index 000000000..85b3d95c0 --- /dev/null +++ b/include/REX/W32/SHELL32.h @@ -0,0 +1,34 @@ +#pragma once + +#include "REX/W32/BASE.h" + +namespace REX::W32 +{ + // known folder ids + inline constexpr GUID FOLDERID_Documents{ 0xFDD39AD0u, 0x238Fu, 0x46AFu, { 0xADu, 0xB4u, 0x6Cu, 0x85u, 0x48u, 0x03u, 0x69u, 0xC7u } }; + inline constexpr GUID FOLDERID_Pictures{ 0x33E28130u, 0x4E1Eu, 0x4676u, { 0x83u, 0x5Au, 0x98u, 0x39u, 0x5Cu, 0x3Bu, 0xC3u, 0xBBu } }; + inline constexpr GUID FOLDERID_ProgramData{ 0x62AB5D82u, 0xFDC1u, 0x4DC3u, { 0xA9u, 0xDDu, 0x07u, 0x0Du, 0x1Du, 0x49u, 0x5Du, 0x97u } }; + + // known folder flags + inline constexpr auto KF_FLAG_DEFAULT{ 0x00000000u }; + inline constexpr auto KF_FLAG_FORCE_APP_DATA_REDIRECTION{ 0x00080000u }; + inline constexpr auto KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET{ 0x00040000u }; + inline constexpr auto KF_FLAG_FORCE_PACKAGE_REDIRECTION{ 0x00020000u }; + inline constexpr auto KF_FLAG_NO_PACKAGE_REDIRECTION{ 0x00010000u }; + inline constexpr auto KF_FLAG_FORCE_APPCONTAINER_REDIRECTION{ 0x00020000u }; + inline constexpr auto KF_FLAG_NO_APPCONTAINER_REDIRECTION{ 0x00010000u }; + inline constexpr auto KF_FLAG_CREATE{ 0x00008000u }; + inline constexpr auto KF_FLAG_DONT_VERIFY{ 0x00004000u }; + inline constexpr auto KF_FLAG_DONT_UNEXPAND{ 0x00002000u }; + inline constexpr auto KF_FLAG_NO_ALIAS{ 0x00001000u }; + inline constexpr auto KF_FLAG_INIT{ 0x00000800u }; + inline constexpr auto KF_FLAG_DEFAULT_PATH{ 0x00000400u }; + inline constexpr auto KF_FLAG_NOT_PARENT_RELATIVE{ 0x00000200u }; + inline constexpr auto KF_FLAG_SIMPLE_IDLIST{ 0x00000100u }; + inline constexpr auto KF_FLAG_ALIAS_ONLY{ 0x80000000u }; +} + +namespace REX::W32 +{ + std::int32_t SHGetKnownFolderPath(const GUID& a_id, std::uint32_t a_flags, void* a_token, wchar_t** a_path) noexcept; +} diff --git a/include/REX/W32/USER32.h b/include/REX/W32/USER32.h new file mode 100644 index 000000000..eab565dc5 --- /dev/null +++ b/include/REX/W32/USER32.h @@ -0,0 +1,293 @@ +#pragma once + +#include "REX/W32/BASE.h" + +namespace REX::W32 +{ + enum GWLP : std::int32_t + { + GWLP_USERDATA = -21, + GWLP_ID = -12, + GWLP_HWNDPARENT = -8, + GWLP_HINSTANCE = -6, + GWLP_WNDPROC = -4, + }; + + enum WM : std::uint32_t + { + WM_NULL = 0x0000u, + WM_CREATE = 0x0001u, + WM_DESTROY = 0x0002u, + WM_MOVE = 0x0003u, + WM_SIZE = 0x0005u, + WM_ACTIVATE = 0x0006u, + WM_SETFOCUS = 0x0007u, + WM_KILLFOCUS = 0x0008u, + WM_ENABLE = 0x000Au, + WM_SETREDRAW = 0x000Bu, + WM_SETTEXT = 0x000Cu, + WM_GETTEXT = 0x000Du, + WM_GETTEXTLENGTH = 0x000Eu, + WM_PAINT = 0x000Fu, + WM_CLOSE = 0x0010u, + WM_QUIT = 0x0012u, + WM_ERASEBKGND = 0x0014u, + WM_SHOWWINDOW = 0x0018u, + WM_ACTIVATEAPP = 0x001Cu, + WM_FONTCHANGE = 0x001Du, + WM_TIMECHANGE = 0x001Eu, + WM_CANCELMODE = 0x001Fu, + WM_SETCURSOR = 0x0020u, + WM_MOUSEACTIVATE = 0x0021u, + WM_CHILDACTIVATE = 0x0022u, + }; + + enum VK : std::uint32_t + { + VK_LBUTTON = 0x1, + VK_RBUTTON = 0x2, + VK_CANCEL = 0x3, + VK_MBUTTON = 0x4, + VK_XBUTTON1 = 0x5, + VK_XBUTTON2 = 0x6, + VK_BACK = 0x8, + VK_TAB = 0x9, + VK_RESERVED_0A = 0xA, + VK_RESERVED_0B = 0xB, + VK_CLEAR = 0xC, + VK_RETURN = 0xD, + VK_SHIFT = 0x10, + VK_CONTROL = 0x11, + VK_MENU = 0x12, + VK_PAUSE = 0x13, + VK_CAPITAL = 0x14, + VK_KANA = 0x15, + VK_HANGUEL = 0x15, + VK_HANGUL = 0x15, + VK_IME_ON = 0x16, + VK_JUNJA = 0x17, + VK_FINAL = 0x18, + VK_HANJA = 0x19, + VK_KANJI = VK_HANJA, + VK_IME_OFF = 0x1A, + VK_ESCAPE = 0x1B, + VK_CONVERT = 0x1C, + VK_NONCONVERT = 0x1D, + VK_ACCEPT = 0x1E, + VK_MODECHANGE = 0x1F, + VK_SPACE = 0x20, + VK_PRIOR = 0x21, + VK_NEXT = 0x22, + VK_END = 0x23, + VK_HOME = 0x24, + VK_LEFT = 0x25, + VK_UP = 0x26, + VK_RIGHT = 0x27, + VK_DOWN = 0x28, + VK_SELECT = 0x29, + VK_PRINT = 0x2A, + VK_EXECUTE = 0x2B, + VK_SNAPSHOT = 0x2C, + VK_INSERT = 0x2D, + VK_DELETE = 0x2E, + VK_HELP = 0x2F, + VK_0 = 0x30, + VK_1 = 0x31, + VK_2 = 0x32, + VK_3 = 0x33, + VK_4 = 0x34, + VK_5 = 0x35, + VK_6 = 0x36, + VK_7 = 0x37, + VK_8 = 0x38, + VK_9 = 0x39, + VK_A = 0x41, + VK_B = 0x42, + VK_C = 0x43, + VK_D = 0x44, + VK_E = 0x45, + VK_F = 0x46, + VK_G = 0x47, + VK_H = 0x48, + VK_I = 0x49, + VK_J = 0x4A, + VK_K = 0x4B, + VK_L = 0x4C, + VK_M = 0x4D, + VK_N = 0x4E, + VK_O = 0x4F, + VK_P = 0x50, + VK_Q = 0x51, + VK_R = 0x52, + VK_S = 0x53, + VK_T = 0x54, + VK_U = 0x55, + VK_V = 0x56, + VK_W = 0x57, + VK_X = 0x58, + VK_Y = 0x59, + VK_Z = 0x5A, + VK_LWIN = 0x5B, + VK_RWIN = 0x5C, + VK_APPS = 0x5D, + VK_RESERVED_5E = 0x5E, + VK_SLEEP = 0x5F, + VK_NUMPAD0 = 0x60, + VK_NUMPAD1 = 0x61, + VK_NUMPAD2 = 0x62, + VK_NUMPAD3 = 0x63, + VK_NUMPAD4 = 0x64, + VK_NUMPAD5 = 0x65, + VK_NUMPAD6 = 0x66, + VK_NUMPAD7 = 0x67, + VK_NUMPAD8 = 0x68, + VK_NUMPAD9 = 0x69, + VK_MULTIPLY = 0x6A, + VK_ADD = 0x6B, + VK_SEPARATOR = 0x6C, + VK_SUBTRACT = 0x6D, + VK_DECIMAL = 0x6E, + VK_DIVIDE = 0x6F, + VK_F1 = 0x70, + VK_F2 = 0x71, + VK_F3 = 0x72, + VK_F4 = 0x73, + VK_F5 = 0x74, + VK_F6 = 0x75, + VK_F7 = 0x76, + VK_F8 = 0x77, + VK_F9 = 0x78, + VK_F10 = 0x79, + VK_F11 = 0x7A, + VK_F12 = 0x7B, + VK_F13 = 0x7C, + VK_F14 = 0x7D, + VK_F15 = 0x7E, + VK_F16 = 0x7F, + VK_F17 = 0x80, + VK_F18 = 0x81, + VK_F19 = 0x82, + VK_F20 = 0x83, + VK_F21 = 0x84, + VK_F22 = 0x85, + VK_F23 = 0x86, + VK_F24 = 0x87, + VK_NUMLOCK = 0x90, + VK_SCROLL = 0x91, + VK_OEMSPECIFIC_92 = 0x92, + VK_OEMSPECIFIC_93 = 0x93, + VK_OEMSPECIFIC_94 = 0x94, + VK_OEMSPECIFIC_95 = 0x95, + VK_OEMSPECIFIC_96 = 0x96, + VK_LSHIFT = 0xA0, + VK_RSHIFT = 0xA1, + VK_LCONTROL = 0xA2, + VK_RCONTROL = 0xA3, + VK_LMENU = 0xA4, + VK_RMENU = 0xA5, + VK_BROWSER_BACK = 0xA6, + VK_BROWSER_FORWARD = 0xA7, + VK_BROWSER_REFRESH = 0xA8, + VK_BROWSER_STOP = 0xA9, + VK_BROWSER_SEARCH = 0xAA, + VK_BROWSER_FAVORITES = 0xAB, + VK_BROWSER_HOME = 0xAC, + VK_VOLUME_MUTE = 0xAD, + VK_VOLUME_DOWN = 0xAE, + VK_VOLUME_UP = 0xAF, + VK_MEDIA_NEXT_TRACK = 0xB0, + VK_MEDIA_PREV_TRACK = 0xB1, + VK_MEDIA_STOP = 0xB2, + VK_MEDIA_PLAY_PAUSE = 0xB3, + VK_LAUNCH_MAIL = 0xB4, + VK_LAUNCH_MEDIA_SELECT = 0xB5, + VK_LAUNCH_APP1 = 0xB6, + VK_LAUNCH_APP2 = 0xB7, + VK_RESERVED_B8 = 0xB8, + VK_RESERVED_B9 = 0xB9, + VK_OEM_1 = 0xBA, + VK_OEM_PLUS = 0xBB, + VK_OEM_COMMA = 0xBC, + VK_OEM_MINUS = 0xBD, + VK_OEM_PERIOD = 0xBE, + VK_OEM_2 = 0xBF, + VK_OEM_3 = 0xC0, + VK_RESERVED_C1 = 0xC1, + VK_RESERVED_C2 = 0xC2, + VK_RESERVED_C3 = 0xC3, + VK_RESERVED_C4 = 0xC4, + VK_RESERVED_C5 = 0xC5, + VK_RESERVED_C6 = 0xC6, + VK_RESERVED_C7 = 0xC7, + VK_RESERVED_C8 = 0xC8, + VK_RESERVED_C9 = 0xC9, + VK_RESERVED_CA = 0xCA, + VK_RESERVED_CB = 0xCB, + VK_RESERVED_CC = 0xCC, + VK_RESERVED_CD = 0xCD, + VK_RESERVED_CE = 0xCE, + VK_RESERVED_CF = 0xCF, + VK_RESERVED_D0 = 0xD0, + VK_RESERVED_D1 = 0xD1, + VK_RESERVED_D2 = 0xD2, + VK_RESERVED_D3 = 0xD3, + VK_RESERVED_D4 = 0xD4, + VK_RESERVED_D5 = 0xD5, + VK_RESERVED_D6 = 0xD6, + VK_RESERVED_D7 = 0xD7, + VK_OEM_4 = 0xDB, + VK_OEM_5 = 0xDC, + VK_OEM_6 = 0xDD, + VK_OEM_7 = 0xDE, + VK_OEM_8 = 0xDF, + VK_RESERVED_E0 = 0xE0, + VK_OEMSPECIFIC_E1 = 0xE1, + VK_OEM_102 = 0xE2, + VK_OEMSPECIFIC_E3 = 0xE3, + VK_OEMSPECIFIC_E4 = 0xE4, + VK_PROCESSKEY = 0xE5, + VK_OEMSPECIFIC_E6 = 0xE6, + VK_PACKET = 0xE7, + VK_OEMSPECIFIC_E9 = 0xE9, + VK_OEMSPECIFIC_EA = 0xEA, + VK_OEMSPECIFIC_EB = 0xEB, + VK_OEMSPECIFIC_EC = 0xEC, + VK_OEMSPECIFIC_ED = 0xED, + VK_OEMSPECIFIC_EE = 0xEE, + VK_OEMSPECIFIC_EF = 0xEF, + VK_OEMSPECIFIC_F0 = 0xF0, + VK_OEMSPECIFIC_F1 = 0xF1, + VK_OEMSPECIFIC_F2 = 0xF2, + VK_OEMSPECIFIC_F3 = 0xF3, + VK_OEMSPECIFIC_F4 = 0xF4, + VK_OEMSPECIFIC_F5 = 0xF5, + VK_ATTN = 0xF6, + VK_CRSEL = 0xF7, + VK_EXSEL = 0xF8, + VK_EREOF = 0xF9, + VK_PLAY = 0xFA, + VK_ZOOM = 0xFB, + VK_NONAME = 0xFC, + VK_PA1 = 0xFD, + VK_OEM_CLEAR = 0xFE, + VK_RESERVED_FF = 0xFF, + }; +} + +namespace REX::W32 +{ + using WNDPROC = std::intptr_t(*)(HWND, std::uint32_t, std::uintptr_t, std::intptr_t); +} + +namespace REX::W32 +{ + bool GetClientRect(HWND a_wnd, RECT* a_rect) noexcept; + std::int32_t GetKeyNameTextA(std::int32_t a_param, char* a_buf, std::int32_t a_bufLen) noexcept; + std::int32_t GetKeyNameTextW(std::int32_t a_param, wchar_t* a_buf, std::int32_t a_bufLen) noexcept; + std::int16_t GetKeyState(std::int32_t a_key) noexcept; + bool GetWindowRect(HWND a_wnd, RECT* a_rect) noexcept; + std::int32_t MessageBoxA(HWND a_wnd, const char* a_text, const char* a_caption, std::uint32_t a_type) noexcept; + std::int32_t MessageBoxW(HWND a_wnd, const wchar_t* a_text, const wchar_t* a_caption, std::uint32_t a_type) noexcept; + std::intptr_t SetWindowLongPtrA(HWND a_wnd, std::int32_t a_index, std::intptr_t a_newPtr) noexcept; + std::int32_t ShowCursor(bool a_show) noexcept; +} diff --git a/include/REX/W32/VERSION.h b/include/REX/W32/VERSION.h new file mode 100644 index 000000000..ae626a6e7 --- /dev/null +++ b/include/REX/W32/VERSION.h @@ -0,0 +1,13 @@ +#pragma once + +namespace REX::W32 +{ + bool GetFileVersionInfoA(const char* a_name, std::uint32_t a_handle, std::uint32_t a_dataLen, void* a_data) noexcept; + std::uint32_t GetFileVersionInfoSizeA(const char* a_name, std::uint32_t* a_handle) noexcept; + //std::uint32_t GetFileVersionInfoSizeExA(std::uint32_t a_flags, const char* a_name, std::uint32_t* a_handle) noexcept; + std::uint32_t GetFileVersionInfoSizeExW(std::uint32_t a_flags, const wchar_t* a_name, std::uint32_t* a_handle) noexcept; + std::uint32_t GetFileVersionInfoSizeW(const wchar_t* a_name, std::uint32_t* a_handle) noexcept; + bool GetFileVersionInfoW(const wchar_t* a_name, std::uint32_t a_handle, std::uint32_t a_dataLen, void* a_data) noexcept; + bool VerQueryValueA(const void* a_block, const char* a_subBlock, void** a_buf, std::uint32_t* a_bufLen) noexcept; + bool VerQueryValueW(const void* a_block, const wchar_t* a_subBlock, void** a_buf, std::uint32_t* a_bufLen) noexcept; +} diff --git a/include/REX/W32/XINPUT.h b/include/REX/W32/XINPUT.h new file mode 100644 index 000000000..a55060baa --- /dev/null +++ b/include/REX/W32/XINPUT.h @@ -0,0 +1,80 @@ +#pragma once + +namespace REX::W32 +{ + inline constexpr std::uint16_t XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE{ 7849 }; + inline constexpr std::uint16_t XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE{ 8689 }; + inline constexpr std::uint8_t XINPUT_GAMEPAD_TRIGGER_THRESHOLD{ 30 }; +} + +namespace REX::W32 +{ + enum XINPUT_GAMEPAD_BUTTON : std::uint16_t + { + XINPUT_GAMEPAD_DPAD_UP = 0x0001, + XINPUT_GAMEPAD_DPAD_DOWN = 0x0002, + XINPUT_GAMEPAD_DPAD_LEFT = 0x0004, + XINPUT_GAMEPAD_DPAD_RIGHT = 0x0008, + XINPUT_GAMEPAD_START = 0x0010, + XINPUT_GAMEPAD_BACK = 0x0020, + XINPUT_GAMEPAD_LEFT_THUMB = 0x0040, + XINPUT_GAMEPAD_RIGHT_THUMB = 0x0080, + XINPUT_GAMEPAD_LEFT_SHOULDER = 0x0100, + XINPUT_GAMEPAD_RIGHT_SHOULDER = 0x0200, + XINPUT_GAMEPAD_A = 0x1000, + XINPUT_GAMEPAD_B = 0x2000, + XINPUT_GAMEPAD_X = 0x4000, + XINPUT_GAMEPAD_Y = 0x8000, + XINPUT_GAMEPAD_BUTTON_MASK = XINPUT_GAMEPAD_DPAD_UP | XINPUT_GAMEPAD_DPAD_DOWN | XINPUT_GAMEPAD_DPAD_LEFT | XINPUT_GAMEPAD_DPAD_RIGHT | XINPUT_GAMEPAD_START | XINPUT_GAMEPAD_BACK | XINPUT_GAMEPAD_LEFT_THUMB | XINPUT_GAMEPAD_RIGHT_THUMB | XINPUT_GAMEPAD_LEFT_SHOULDER | XINPUT_GAMEPAD_RIGHT_SHOULDER | XINPUT_GAMEPAD_A | XINPUT_GAMEPAD_B | XINPUT_GAMEPAD_X | XINPUT_GAMEPAD_Y, + }; +} + +namespace REX::W32 +{ + struct XINPUT_BATTERY_INFORMATION + { + std::uint8_t batteryType; + std::uint8_t batteryLevel; + }; + + struct XINPUT_GAMEPAD + { + std::uint16_t buttons; + std::uint8_t leftTrigger; + std::uint8_t rightTrigger; + std::int16_t thumbLX; + std::int16_t thumbLY; + std::int16_t thumbRX; + std::int16_t thumbRY; + }; + + struct XINPUT_KEYSTROKE + { + std::uint16_t virtualKey; + std::uint16_t unicode; + std::uint16_t flags; + std::uint8_t userIndex; + std::uint8_t hidCode; + }; + + struct XINPUT_STATE + { + std::uint32_t packetNumber; + XINPUT_GAMEPAD gamepad; + }; + + struct XINPUT_VIBRATION + { + std::uint16_t leftMotorSpeed; + std::uint16_t rightMotorSpeed; + }; + + struct XINPUT_CAPABILITIES + { + std::uint8_t type; + std::uint8_t subType; + std::uint16_t flags; + XINPUT_GAMEPAD gamepad; + XINPUT_VIBRATION vibration; + }; +} diff --git a/include/SKSE/IAT.h b/include/SKSE/IAT.h index 27a89e8a1..57fa55a2d 100644 --- a/include/SKSE/IAT.h +++ b/include/SKSE/IAT.h @@ -3,7 +3,7 @@ namespace SKSE { [[nodiscard]] std::uintptr_t GetIATAddr(std::string_view a_dll, std::string_view a_function); - [[nodiscard]] std::uintptr_t GetIATAddr(void* a_module, std::string_view a_dll, std::string_view a_function); + [[nodiscard]] std::uintptr_t GetIATAddr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function); [[nodiscard]] void* GetIATPtr(std::string_view a_dll, std::string_view a_function); @@ -13,10 +13,10 @@ namespace SKSE return static_cast(GetIATPtr(std::move(a_dll), std::move(a_function))); } - [[nodiscard]] void* GetIATPtr(void* a_module, std::string_view a_dll, std::string_view a_function); + [[nodiscard]] void* GetIATPtr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function); template - [[nodiscard]] inline T* GetIATPtr(void* a_module, std::string_view a_dll, std::string_view a_function) + [[nodiscard]] inline T* GetIATPtr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function) { return static_cast(GetIATPtr(a_module, std::move(a_dll), std::move(a_function))); } diff --git a/include/SKSE/Impl/DInputAPI.h b/include/SKSE/Impl/DInputAPI.h deleted file mode 100644 index 6e818957e..000000000 --- a/include/SKSE/Impl/DInputAPI.h +++ /dev/null @@ -1,572 +0,0 @@ -#pragma once - -#include "WinAPI.h" - -// TODO: This should probably be behind some sort of pragma that allows linking with dinput and dinput8 -namespace RE::DirectInput8 -{ - using DWORD = std::uint32_t; - using LONG = std::int32_t; - using WORD = std::uint16_t; - using BYTE = std::uint8_t; - using UINT = std::uint32_t; - using CHAR = char; - - using LPSTR = char*; - using LPCSTR = const char*; - - using UINT_PTR = std::uintptr_t; - using HANDLE = void*; - using LPDWORD = DWORD*; - using LPVOID = void*; - using LPLONG = LONG*; - using LPWORD = WORD*; - - using GUID = SKSE::WinAPI::GUID; - using LPGUID = GUID*; - using REFGUID = const GUID&; - using FILETIME = SKSE::WinAPI::FILETIME; - using RECT = SKSE::WinAPI::RECT; - using POINT = SKSE::WinAPI::POINT; - - using IID = GUID; - using REFIID = const IID&; - using LPIID = IID*; - using D3DCOLOR = std::uint32_t; - - using HRESULT = SKSE::WinAPI::HRESULT; - using HWND = SKSE::WinAPI::HWND; - using HINSTANCE = SKSE::WinAPI::HINSTANCE; - - inline static constexpr std::uint32_t MAX_PATH = 260; - - enum DIKey : std::uint32_t - { - DIK_ESCAPE = 0x1, - DIK_1 = 0x2, - DIK_2 = 0x3, - DIK_3 = 0x4, - DIK_4 = 0x5, - DIK_5 = 0x6, - DIK_6 = 0x7, - DIK_7 = 0x8, - DIK_8 = 0x9, - DIK_9 = 0xA, - DIK_0 = 0xB, - DIK_MINUS = 0xC, - DIK_EQUALS = 0xD, - DIK_BACK = 0xE, - DIK_TAB = 0xF, - DIK_Q = 0x10, - DIK_W = 0x11, - DIK_E = 0x12, - DIK_R = 0x13, - DIK_T = 0x14, - DIK_Y = 0x15, - DIK_U = 0x16, - DIK_I = 0x17, - DIK_O = 0x18, - DIK_P = 0x19, - DIK_LBRACKET = 0x1A, - DIK_RBRACKET = 0x1B, - DIK_RETURN = 0x1C, - DIK_LCONTROL = 0x1D, - DIK_A = 0x1E, - DIK_S = 0x1F, - DIK_D = 0x20, - DIK_F = 0x21, - DIK_G = 0x22, - DIK_H = 0x23, - DIK_J = 0x24, - DIK_K = 0x25, - DIK_L = 0x26, - DIK_SEMICOLON = 0x27, - DIK_APOSTROPHE = 0x28, - DIK_GRAVE = 0x29, - DIK_LSHIFT = 0x2A, - DIK_BACKSLASH = 0x2B, - DIK_Z = 0x2C, - DIK_X = 0x2D, - DIK_C = 0x2E, - DIK_V = 0x2F, - DIK_B = 0x30, - DIK_N = 0x31, - DIK_M = 0x32, - DIK_COMMA = 0x33, - DIK_PERIOD = 0x34, - DIK_SLASH = 0x35, - DIK_RSHIFT = 0x36, - DIK_MULTIPLY = 0x37, - DIK_LMENU = 0x38, - DIK_SPACE = 0x39, - DIK_CAPITAL = 0x3A, - DIK_F1 = 0x3B, - DIK_F2 = 0x3C, - DIK_F3 = 0x3D, - DIK_F4 = 0x3E, - DIK_F5 = 0x3F, - DIK_F6 = 0x40, - DIK_F7 = 0x41, - DIK_F8 = 0x42, - DIK_F9 = 0x43, - DIK_F10 = 0x44, - DIK_NUMLOCK = 0x45, - DIK_SCROLL = 0x46, - DIK_NUMPAD7 = 0x47, - DIK_NUMPAD8 = 0x48, - DIK_NUMPAD9 = 0x49, - DIK_SUBTRACT = 0x4A, - DIK_NUMPAD4 = 0x4B, - DIK_NUMPAD5 = 0x4C, - DIK_NUMPAD6 = 0x4D, - DIK_ADD = 0x4E, - DIK_NUMPAD1 = 0x4F, - DIK_NUMPAD2 = 0x50, - DIK_NUMPAD3 = 0x51, - DIK_NUMPAD0 = 0x52, - DIK_DECIMAL = 0x53, - DIK_OEM_102 = 0x56, - DIK_F11 = 0x57, - DIK_F12 = 0x58, - DIK_F13 = 0x64, - DIK_F14 = 0x65, - DIK_F15 = 0x66, - DIK_KANA = 0x70, - DIK_ABNT_C1 = 0x73, - DIK_CONVERT = 0x79, - DIK_NOCONVERT = 0x7B, - DIK_YEN = 0x7D, - DIK_ABNT_C2 = 0x7E, - DIK_NUMPADEQUALS = 0x8D, - DIK_PREVTRACK = 0x90, - DIK_AT = 0x91, - DIK_COLON = 0x92, - DIK_UNDERLINE = 0x93, - DIK_KANJI = 0x94, - DIK_STOP = 0x95, - DIK_AX = 0x96, - DIK_UNLABELED = 0x97, - DIK_NEXTTRACK = 0x99, - DIK_NUMPADENTER = 0x9C, - DIK_RCONTROL = 0x9D, - DIK_MUTE = 0xA0, - DIK_CALCULATOR = 0xA1, - DIK_PLAYPAUSE = 0xA2, - DIK_MEDIASTOP = 0xA4, - DIK_VOLUMEDOWN = 0xAE, - DIK_VOLUMEUP = 0xB0, - DIK_WEBHOME = 0xB2, - DIK_NUMPADCOMMA = 0xB3, - DIK_DIVIDE = 0xB5, - DIK_SYSRQ = 0xB7, - DIK_RMENU = 0xB8, - DIK_PAUSE = 0xC5, - DIK_HOME = 0xC7, - DIK_UP = 0xC8, - DIK_PRIOR = 0xC9, - DIK_LEFT = 0xCB, - DIK_RIGHT = 0xCD, - DIK_END = 0xCF, - DIK_DOWN = 0xD0, - DIK_NEXT = 0xD1, - DIK_INSERT = 0xD2, - DIK_DELETE = 0xD3, - DIK_LWIN = 0xDB, - DIK_RWIN = 0xDC, - DIK_APPS = 0xDD, - DIK_POWER = 0xDE, - DIK_SLEEP = 0xDF, - DIK_WAKE = 0xE3, - DIK_WEBSEARCH = 0xE5, - DIK_WEBFAVORITES = 0xE6, - DIK_WEBREFRESH = 0xE7, - DIK_WEBSTOP = 0xE8, - DIK_WEBFORWARD = 0xE9, - DIK_WEBBACK = 0xEA, - DIK_MYCOMPUTER = 0xEB, - DIK_MAIL = 0xEC, - DIK_MEDIASELECT = 0xED, - DIK_BACKSPACE = DIK_BACK, - DIK_NUMPADSTAR = DIK_MULTIPLY, - DIK_LALT = DIK_LMENU, - DIK_CAPSLOCK = DIK_CAPITAL, - DIK_NUMPADMINUS = DIK_SUBTRACT, - DIK_NUMPADPLUS = DIK_ADD, - DIK_NUMPADPERIOD = DIK_DECIMAL, - DIK_NUMPADSLASH = DIK_DIVIDE, - DIK_RALT = DIK_RMENU, - DIK_UPARROW = DIK_UP, - DIK_PGUP = DIK_PRIOR, - DIK_LEFTARROW = DIK_LEFT, - DIK_RIGHTARROW = DIK_RIGHT, - DIK_DOWNARROW = DIK_DOWN, - DIK_PGDN = DIK_NEXT - }; - - struct DIMOUSESTATE2__ - { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[8]; - }; - static_assert(sizeof(DIMOUSESTATE2__) == 0x14); - using DIMOUSESTATE2 = DIMOUSESTATE2__; - using LPDIMOUSESTATE2 = DIMOUSESTATE2*; - - struct DIDEVICEOBJECTDATA__ - { - DWORD dwOfs; // 00 - DWORD dwData; // 04 - DWORD dwTimeStamp; // 08 - DWORD dwSequence; // 0C - UINT_PTR uAppData; // 10 - }; - static_assert(sizeof(DIDEVICEOBJECTDATA__) == 0x18); - using DIDEVICEOBJECTDATA = DIDEVICEOBJECTDATA__; - using LPDIDEVICEOBJECTDATA = DIDEVICEOBJECTDATA*; - using LPCDIDEVICEOBJECTDATA = const DIDEVICEOBJECTDATA*; - - struct DIDEVICEINSTANCEA__ - { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; - GUID guidFFDriver; // DIRECTINPUT_VERSION >= 0x0500 - WORD wUsagePage; - WORD wUsage; - }; - using DIDEVICEINSTANCEA = DIDEVICEINSTANCEA__; - using LPDIDEVICEINSTANCEA = DIDEVICEINSTANCEA*; - using LPCDIDEVICEINSTANCEA = const DIDEVICEINSTANCEA*; - - struct DIDEVICEOBJECTINSTANCEA__ - { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; - //#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReportId; - //#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - }; - using DIDEVICEOBJECTINSTANCEA = DIDEVICEOBJECTINSTANCEA__; - using LPDIDEVICEOBJECTINSTANCEA = DIDEVICEOBJECTINSTANCEA*; - using LPCDIDEVICEOBJECTINSTANCEA = const DIDEVICEOBJECTINSTANCEA*; - - using LPDIENUMDEVICEOBJECTSCALLBACKA = bool(__stdcall*)(LPCDIDEVICEOBJECTINSTANCEA, LPVOID); - - struct DIPROPHEADER__ - { - DWORD dwSize; - DWORD dwHeaderSize; - DWORD dwObj; - DWORD dwHow; - }; - - using DIPROPHEADER = DIPROPHEADER__; - using LPDIPROPHEADER = DIPROPHEADER*; - using LPCDIPROPHEADER = const DIPROPHEADER*; - - struct DIDEVCAPS__ - { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; - DWORD dwFFSamplePeriod; // -- fields here are Dinput >= 0x0500 - DWORD dwFFMinTimeResolution; - DWORD dwFirmwareRevision; - DWORD dwHardwareRevision; - DWORD dwFFDriverVersion; - }; - static_assert(sizeof(DIDEVCAPS__) == 0x2C); - using DIDEVCAPS = DIDEVCAPS__; - using LPDIDEVCAPS = DIDEVCAPS*; - using LPCDIDEVCAPS = const DIDEVCAPS*; - struct _DIDEVICEIMAGEINFOA - { - CHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; - }; - using DIDEVICEIMAGEINFOA = _DIDEVICEIMAGEINFOA; - using LPDIDEVICEIMAGEINFOA = DIDEVICEIMAGEINFOA*; - using LPCDIDEVICEIMAGEINFOA = const DIDEVICEIMAGEINFOA*; - - struct _DIOBJECTDATAFORMAT - { - const GUID* pguid; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - }; - using DIOBJECTDATAFORMAT = _DIOBJECTDATAFORMAT; - using LPDIOBJECTDATAFORMAT = DIOBJECTDATAFORMAT*; - using LPCDIOBJECTDATAFORMAT = const DIOBJECTDATAFORMAT*; - - struct _DIDATAFORMAT - { - DWORD dwSize; - DWORD dwObjSize; - DWORD dwFlags; - DWORD dwDataSize; - DWORD dwNumObjs; - LPDIOBJECTDATAFORMAT rgodf; - }; - using DIDATAFORMAT = _DIDATAFORMAT; - using LPDIDATAFORMAT = DIDATAFORMAT*; - using LPCDIDATAFORMAT = const DIDATAFORMAT*; - - struct DIENVELOPE__ - { - DWORD dwSize; /* sizeof(DIENVELOPE) */ - DWORD dwAttackLevel; - DWORD dwAttackTime; /* Microseconds */ - DWORD dwFadeLevel; - DWORD dwFadeTime; /* Microseconds */ - }; - using DIENVELOPE = DIENVELOPE__; - using LPDIENVELOPE = DIENVELOPE*; - using LPCDIENVELOPE = const DIENVELOPE*; - - struct DIEFFECTINFOA__ - { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - CHAR tszName[MAX_PATH]; - }; - using DIEFFECTINFOA = DIEFFECTINFOA__; - using LPDIEFFECTINFOA = DIEFFECTINFOA*; - using LPCDIEFFECTINFOA = const DIEFFECTINFOA*; - - using LPDIENUMEFFECTSCALLBACKA = bool(__stdcall*)(LPCDIEFFECTINFOA, LPVOID); - - struct DIEFFECT__ - { - DWORD dwSize; /* sizeof(DIEFFECT) */ - DWORD dwFlags; /* DIEFF_* */ - DWORD dwDuration; /* Microseconds */ - DWORD dwSamplePeriod; /* Microseconds */ - DWORD dwGain; - DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ - DWORD dwTriggerRepeatInterval; /* Microseconds */ - DWORD cAxes; /* Number of axes */ - LPDWORD rgdwAxes; /* Array of axes */ - LPLONG rglDirection; /* Array of directions */ - LPDIENVELOPE lpEnvelope; /* Optional */ - DWORD cbTypeSpecificParams; /* Size of params */ - LPVOID lpvTypeSpecificParams; /* Pointer to params */ - DWORD dwStartDelay; /* Microseconds */ // -- fields here are Dinput >= 0x0600 - }; - using DIEFFECT = DIEFFECT__; - using LPDIEFFECT = DIEFFECT*; - using LPCDIEFFECT = const DIEFFECT*; - - struct DIEFFESCAPE__ - { - DWORD dwSize; - DWORD dwCommand; - LPVOID lpvInBuffer; - DWORD cbInBuffer; - LPVOID lpvOutBuffer; - DWORD cbOutBuffer; - }; - using DIEFFESCAPE = DIEFFESCAPE__; - using LPDIEFFESCAPE = DIEFFESCAPE*; - using LPCDIEFFESCAPE = const DIEFFESCAPE*; - struct DIFILEEFFECT__ - { - DWORD dwSize; - GUID GuidEffect; - LPCDIEFFECT lpDiEffect; - CHAR szFriendlyName[MAX_PATH]; - }; - using DIFILEEFFECT = DIFILEEFFECT__; - using LPDIFILEEFFECT = DIFILEEFFECT*; - using LPCDIFILEEFFECT = const DIFILEEFFECT*; - struct _DIACTIONA - { - UINT_PTR uAppData; - DWORD dwSemantic; - DWORD dwFlags; - union - { - LPCSTR lptszActionName; - UINT uResIdString; - }; - GUID guidInstance; - DWORD dwObjID; - DWORD dwHow; - }; - using DIACTIONA = _DIACTIONA; - using LPDIACTIONA = DIACTIONA*; - - struct _DIACTIONFORMATA - { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONA rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - LONG lAxisMin; - LONG lAxisMax; - HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - CHAR tszActionMap[MAX_PATH]; - }; - using DIACTIONFORMATA = _DIACTIONFORMATA; - using LPDIACTIONFORMATA = DIACTIONFORMATA*; - using LPCDIACTIONFORMATA = const DIACTIONFORMATA*; - struct _DIDEVICEIMAGEINFOHEADERA - { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOA lprgImageInfoArray; - }; - using DIDEVICEIMAGEINFOHEADERA = _DIDEVICEIMAGEINFOHEADERA; - using LPDIDEVICEIMAGEINFOHEADERA = DIDEVICEIMAGEINFOHEADERA*; - using LPCDIDEVICEIMAGEINFOHEADERA = const DIDEVICEIMAGEINFOHEADERA*; - - struct _DICOLORSET - { - DWORD dwSize; - D3DCOLOR cTextFore; - D3DCOLOR cTextHighlight; - D3DCOLOR cCalloutLine; - D3DCOLOR cCalloutHighlight; - D3DCOLOR cBorder; - D3DCOLOR cControlFill; - D3DCOLOR cHighlightFill; - D3DCOLOR cAreaFill; - }; - using DICOLORSET = _DICOLORSET; - - struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) - IUnknown - { - virtual HRESULT QueryInterface(const GUID&, void**) noexcept = 0; - virtual std::uint32_t AddRef() noexcept = 0; - virtual std::uint32_t Release() noexcept = 0; - }; - using LPUNKNOWN = IUnknown*; - - struct _DICONFIGUREDEVICESPARAMSA - { - DWORD dwSize; - DWORD dwcUsers; - LPSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATA lprgFormats; - HWND hwnd; - DICOLORSET dics; - IUnknown* lpUnkDDSTarget; - }; - using DICONFIGUREDEVICESPARAMSA = _DICONFIGUREDEVICESPARAMSA; - - struct __declspec(novtable) IDirectInputEffect : public IUnknown - { - virtual HRESULT Initialize(HINSTANCE, DWORD, REFGUID) noexcept = 0; - virtual HRESULT GetEffectGuid(LPGUID) noexcept = 0; - virtual HRESULT GetParameters(LPDIEFFECT, DWORD) noexcept = 0; - virtual HRESULT SetParameters(LPCDIEFFECT, DWORD) noexcept = 0; - virtual HRESULT Start(std::uint32_t, std::uint32_t) noexcept = 0; - virtual HRESULT Stop() noexcept = 0; - virtual HRESULT GetEffectStatus(std::uint32_t*) noexcept = 0; - virtual HRESULT Download() noexcept = 0; - virtual HRESULT Unload() noexcept = 0; - virtual HRESULT Escape(LPDIEFFESCAPE) noexcept = 0; - }; - using LPDIRECTINPUTEFFECT = IDirectInputEffect*; - using LPCDIRECTINPUTEFFECT = const IDirectInputEffect*; - - using LPDIENUMCREATEDEFFECTOBJECTSCALLBACK = bool(__stdcall*)(LPDIRECTINPUTEFFECT, void*); - using LPDICONFIGUREDEVICESCALLBACK = bool(__stdcall*)(IUnknown*, void*); - using LPDIENUMDEVICESCALLBACKA = bool(__stdcall*)(const DIDEVICEINSTANCEA*, void*); - - using LPDIENUMEFFECTSCALLBACKA = bool(__stdcall*)(const DIEFFECTINFOA*, void*); - - using LPDIENUMEFFECTSINFILECALLBACK = bool(__stdcall*)(const DIFILEEFFECT*, void*); - - struct __declspec(novtable) IDirectInputDevice8A : public IUnknown - { - virtual HRESULT GetCapabilities(DIDEVCAPS*) noexcept = 0; - virtual HRESULT EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKA, void*, std::uint32_t) noexcept = 0; - virtual HRESULT GetProperty(std::uint32_t, DIPROPHEADER*) noexcept = 0; - virtual HRESULT SetProperty(std::uint32_t, const DIPROPHEADER*) noexcept = 0; - virtual HRESULT Acquire() noexcept = 0; - virtual HRESULT Unacquire() noexcept = 0; - virtual HRESULT GetDeviceState(std::uint32_t, void*) noexcept = 0; - virtual HRESULT GetDeviceData(std::uint32_t, DIDEVICEOBJECTDATA*, std::uint32_t*, std::uint32_t) noexcept = 0; - virtual HRESULT SetDataFormat(const DIDATAFORMAT*) noexcept = 0; - virtual HRESULT SetEventNotification(HANDLE) noexcept = 0; - virtual HRESULT SetCooperativeLevel(HWND, std::uint32_t) noexcept = 0; - virtual HRESULT GetObjectInfo(DIDEVICEOBJECTINSTANCEA*, std::uint32_t, std::uint32_t) noexcept = 0; - virtual HRESULT GetDeviceInfo(DIDEVICEINSTANCEA*) noexcept = 0; - virtual HRESULT RunControlPanel(HWND, std::uint32_t) noexcept = 0; - virtual HRESULT Initialize(HINSTANCE, std::uint32_t, const GUID&) noexcept = 0; - virtual HRESULT CreateEffect(const GUID&, const DIEFFECT*, IDirectInputEffect*, IUnknown*) noexcept = 0; - virtual HRESULT EnumEffects(LPDIENUMEFFECTSCALLBACKA, void*, std::uint32_t) noexcept = 0; - virtual HRESULT GetEffectInfo(DIEFFECTINFOA*, const GUID&) noexcept = 0; - virtual HRESULT GetForceFeedbackState(std::uint32_t*) noexcept = 0; - virtual HRESULT SendForceFeedbackCommand(std::uint32_t) noexcept = 0; - virtual HRESULT EnumCreatedEffectObjects(LPDIENUMCREATEDEFFECTOBJECTSCALLBACK, void*, std::uint32_t) noexcept = 0; - virtual HRESULT Escape(DIEFFESCAPE*) noexcept = 0; - virtual HRESULT Poll() noexcept = 0; - virtual HRESULT SendDeviceData(std::uint32_t, const DIDEVICEOBJECTDATA*, std::uint32_t*, std::uint32_t) noexcept = 0; - virtual HRESULT EnumEffectsInFile(const char*, LPDIENUMEFFECTSINFILECALLBACK, void*, std::uint32_t) noexcept = 0; - virtual HRESULT WriteEffectToFile(const char*, std::uint32_t, DIFILEEFFECT*, std::uint32_t) noexcept = 0; - virtual HRESULT BuildActionMap(DIACTIONFORMATA*, const char*, std::uint32_t) noexcept = 0; - virtual HRESULT SetActionMap(DIACTIONFORMATA*, const char*, std::uint32_t) noexcept = 0; - virtual HRESULT GetImageInfo(DIDEVICEIMAGEINFOHEADERA*) noexcept = 0; - }; - - using LPDIENUMDEVICESBYSEMANTICSCBA = bool(__stdcall*)(const DIDEVICEINSTANCEA*, IDirectInputDevice8A*, DWORD, DWORD, LPVOID); - - struct __declspec(novtable) IDirectInput8A : public IUnknown - { - virtual HRESULT CreateDevice(const GUID&, IDirectInputDevice8A**, IUnknown*) noexcept = 0; - virtual HRESULT EnumDevices(std::uint32_t, LPDIENUMDEVICESCALLBACKA, void*, std::uint32_t) noexcept = 0; - virtual HRESULT GetDeviceStatus(const GUID&) noexcept = 0; - virtual HRESULT RunControlPanel(HWND, std::uint32_t) noexcept = 0; - virtual HRESULT Initialize(HINSTANCE, std::uint32_t) noexcept = 0; - virtual HRESULT FindDevice(const GUID&, const char*, GUID*) noexcept = 0; - virtual HRESULT EnumDevicesBySemantics(const char*, LPDIACTIONFORMATA, LPDIENUMDEVICESBYSEMANTICSCBA, void*, std::uint32_t) noexcept = 0; - virtual HRESULT ConfigureDevices(LPDICONFIGUREDEVICESCALLBACK, DICONFIGUREDEVICESPARAMSA*, std::uint32_t, void*) noexcept = 0; - }; - -} diff --git a/include/SKSE/Impl/PCH.h b/include/SKSE/Impl/PCH.h index e76a73124..e82ba3469 100644 --- a/include/SKSE/Impl/PCH.h +++ b/include/SKSE/Impl/PCH.h @@ -63,10 +63,8 @@ static_assert( #include #pragma warning(pop) -#include "SKSE/Impl/DInputAPI.h" -#include "SKSE/Impl/ScePadAPI.h" -#include "SKSE/Impl/WinAPI.h" -#include "SKSE/Impl/XInputAPI.h" +#include "REX/W32/KERNEL32.h" +#include "REX/W32/USER32.h" namespace SKSE { @@ -536,8 +534,8 @@ namespace SKSE -> std::optional { const auto cvt = [&](wchar_t* a_dst, std::size_t a_length) { - return WinAPI::MultiByteToWideChar( - WinAPI::CP_UTF8, + return REX::W32::MultiByteToWideChar( + REX::W32::CP_UTF8, 0, a_in.data(), static_cast(a_in.length()), @@ -562,8 +560,8 @@ namespace SKSE -> std::optional { const auto cvt = [&](char* a_dst, std::size_t a_length) { - return WinAPI::WideCharToMultiByte( - WinAPI::CP_UTF8, + return REX::W32::WideCharToMultiByte( + REX::W32::CP_UTF8, 0, a_in.data(), static_cast(a_in.length()), @@ -608,15 +606,14 @@ namespace SKSE }(); const auto caption = []() { - const auto maxPath = WinAPI::GetMaxPath(); std::vector buf; - buf.reserve(maxPath); - buf.resize(maxPath / 2); + buf.reserve(REX::W32::MAX_PATH); + buf.resize(REX::W32::MAX_PATH / 2); std::uint32_t result = 0; do { buf.resize(buf.size() * 2); - result = WinAPI::GetModuleFileName( - WinAPI::GetCurrentModule(), + result = REX::W32::GetModuleFileNameW( + REX::W32::GetCurrentModule(), buf.data(), static_cast(buf.size())); } while (result && result == buf.size() && buf.size() <= std::numeric_limits::max()); @@ -636,8 +633,8 @@ namespace SKSE a_loc.function_name() }, spdlog::level::critical, a_msg); - WinAPI::MessageBox(nullptr, body.c_str(), (caption.empty() ? nullptr : caption.c_str()), 0); - WinAPI::TerminateProcess(WinAPI::GetCurrentProcess(), EXIT_FAILURE); + REX::W32::MessageBoxW(nullptr, body.c_str(), (caption.empty() ? nullptr : caption.c_str()), 0); + REX::W32::TerminateProcess(REX::W32::GetCurrentProcess(), EXIT_FAILURE); } template @@ -697,14 +694,12 @@ namespace RE { using namespace std::literals; namespace stl = SKSE::stl; - namespace WinAPI = SKSE::WinAPI; } namespace REL { using namespace std::literals; namespace stl = SKSE::stl; - namespace WinAPI = SKSE::WinAPI; } #ifdef SKYRIM_SUPPORT_AE diff --git a/include/SKSE/Impl/ScePadAPI.h b/include/SKSE/Impl/ScePadAPI.h deleted file mode 100644 index a1d8df583..000000000 --- a/include/SKSE/Impl/ScePadAPI.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -namespace RE::ScePad -{ - enum ScePadButton : std::uint32_t - { - SCE_PAD_BUTTON_SHARE = 0x00000001, - SCE_PAD_BUTTON_L3 = 0x00000002, - SCE_PAD_BUTTON_R3 = 0x00000004, - SCE_PAD_BUTTON_OPTIONS = 0x00000008, - SCE_PAD_BUTTON_UP = 0x00000010, - SCE_PAD_BUTTON_RIGHT = 0x00000020, - SCE_PAD_BUTTON_DOWN = 0x00000040, - SCE_PAD_BUTTON_LEFT = 0x00000080, - SCE_PAD_BUTTON_L2 = 0x00000100, - SCE_PAD_BUTTON_R2 = 0x00000200, - SCE_PAD_BUTTON_L1 = 0x00000400, - SCE_PAD_BUTTON_R1 = 0x00000800, - SCE_PAD_BUTTON_TRIANGLE = 0x00001000, - SCE_PAD_BUTTON_CIRCLE = 0x00002000, - SCE_PAD_BUTTON_CROSS = 0x00004000, - SCE_PAD_BUTTON_SQUARE = 0x00008000, - SCE_PAD_BUTTON_PLAYSTATION = 0x0010000, - SCE_PAD_BUTTON_TOUCH_PAD = 0x00100000, - SCE_PAD_BUTTON_INTERCEPTED = 0x80000000, - }; -} diff --git a/include/SKSE/Impl/WinAPI.h b/include/SKSE/Impl/WinAPI.h deleted file mode 100644 index 3b65100aa..000000000 --- a/include/SKSE/Impl/WinAPI.h +++ /dev/null @@ -1,1238 +0,0 @@ -#pragma once - -#ifdef _INC_WINAPIFAMILY -# error Windows API detected. Please move any Windows API includes after CommonLibSSE, or remove them. -#else - -namespace SKSE::WinAPI -{ - // general constants - inline const auto INVALID_HANDLE_VALUE{ reinterpret_cast(static_cast(-1)) }; - inline constexpr auto MAX_PATH{ 260u }; - - // standard access - inline constexpr auto STANDARD_RIGHTS_REQUIRED{ 0x000F0000 }; - inline constexpr auto STANDARD_RIGHTS_ALL{ 0x001F0000 }; - - // code page identifiers - inline constexpr auto CP_UTF8{ 65001u }; - - // pe image header - inline constexpr auto IMAGE_DOS_SIGNATURE{ 0x5A4Du }; - inline constexpr auto IMAGE_NT_SIGNATURE{ 0x00004550u }; - inline constexpr auto IMAGE_NT_OPTIONAL_HDR32_MAGIC{ 0x10Bu }; - inline constexpr auto IMAGE_NT_OPTIONAL_HDR64_MAGIC{ 0x20Bu }; - - // pe image directory entries - inline constexpr auto IMAGE_DIRECTORY_ENTRY_EXPORT{ 0u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_IMPORT{ 1u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_RESOURCE{ 2u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_EXCEPTION{ 3u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_SECURITY{ 4u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_BASERELOC{ 5u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_DEBUG{ 6u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_ARCHITECTURE{ 7u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_GLOBALPTR{ 8u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_TLS{ 9u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG{ 10u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT{ 11u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_IAT{ 12u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT{ 13u }; - inline constexpr auto IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR{ 14u }; - inline constexpr auto IMAGE_NUMBEROF_DIRECTORY_ENTRIES{ 16u }; - - // pe image ordinal - inline constexpr auto IMAGE_ORDINAL_FLAG32{ 0x80000000u }; - inline constexpr auto IMAGE_ORDINAL_FLAG64{ 0x8000000000000000ull }; - - // pe image section header characteristics - inline constexpr auto IMAGE_SCN_MEM_SHARED{ 0x10000000u }; - inline constexpr auto IMAGE_SCN_MEM_EXECUTE{ 0x20000000u }; - inline constexpr auto IMAGE_SCN_MEM_READ{ 0x40000000u }; - inline constexpr auto IMAGE_SCN_MEM_WRITE{ 0x80000000u }; - inline constexpr auto IMAGE_SIZEOF_SECTION_HEADER{ 40u }; - inline constexpr auto IMAGE_SIZEOF_SHORT_NAME{ 8u }; - - // memory allocation types - inline constexpr auto MEM_COMMIT{ 0x00001000u }; - inline constexpr auto MEM_RESERVE{ 0x00002000u }; - inline constexpr auto MEM_DECOMMIT{ 0x00004000u }; - inline constexpr auto MEM_RELEASE{ 0x00008000u }; - inline constexpr auto MEM_FREE{ 0x00010000u }; - inline constexpr auto MEM_RESET{ 0x00080000u }; - inline constexpr auto MEM_RESET_UNDO{ 0x01000000u }; - - // memory page protection attributes - inline constexpr auto PAGE_NOACCESS{ 0x00000001u }; - inline constexpr auto PAGE_READONLY{ 0x00000002u }; - inline constexpr auto PAGE_READWRITE{ 0x00000004u }; - inline constexpr auto PAGE_WRITECOPY{ 0x00000008u }; - inline constexpr auto PAGE_EXECUTE{ 0x00000010u }; - inline constexpr auto PAGE_EXECUTE_READ{ 0x00000020u }; - inline constexpr auto PAGE_EXECUTE_READWRITE{ 0x00000040u }; - - // memory section - inline constexpr auto SECTION_QUERY{ 0x00000001 }; - inline constexpr auto SECTION_MAP_WRITE{ 0x00000002 }; - inline constexpr auto SECTION_MAP_READ{ 0x00000004 }; - inline constexpr auto SECTION_MAP_EXECUTE{ 0x00000008 }; - inline constexpr auto SECTION_EXTEND_SIZE{ 0x00000010 }; - inline constexpr auto SECTION_MAP_EXECUTE_EXPLICIT{ 0x00000020 }; - inline constexpr auto SECTION_ALL_ACCESS{ - STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE - }; - - // file attributes - inline constexpr auto FILE_ATTRIBUTE_READONLY{ 0x00000001u }; - inline constexpr auto FILE_ATTRIBUTE_HIDDEN{ 0x00000002u }; - inline constexpr auto FILE_ATTRIBUTE_SYSTEM{ 0x00000004u }; - inline constexpr auto FILE_ATTRIBUTE_DIRECTORY{ 0x00000010u }; - inline constexpr auto FILE_ATTRIBUTE_ARCHIVE{ 0x00000020u }; - - // file mapping flags - inline constexpr auto FILE_MAP_ALL_ACCESS{ SECTION_ALL_ACCESS }; - inline constexpr auto FILE_MAP_COPY{ 0x00000001u }; - inline constexpr auto FILE_MAP_WRITE{ 0x00000002u }; - inline constexpr auto FILE_MAP_READ{ 0x00000004u }; - inline constexpr auto FILE_MAP_EXECUTE{ 0x00000020u }; - inline constexpr auto FILE_MAP_LARGE_PAGES{ 0x20000000u }; - inline constexpr auto FILE_MAP_TARGETS_INVALID{ 0x40000000u }; - inline constexpr auto FILE_MAP_RESERVE{ 0x80000000u }; - - // file open mode flags - inline constexpr auto GENERIC_READ{ 0x80000000L }; - inline constexpr auto GENERIC_WRITE{ 0x40000000L }; - inline constexpr auto GENERIC_EXECUTE{ 0x20000000L }; - inline constexpr auto GENERIC_ALL{ 0x10000000L }; - - // known folder flags - inline constexpr auto KF_FLAG_DEFAULT{ 0x00000000u }; - inline constexpr auto KF_FLAG_FORCE_APP_DATA_REDIRECTION{ 0x00080000u }; - inline constexpr auto KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET{ 0x00040000u }; - inline constexpr auto KF_FLAG_FORCE_PACKAGE_REDIRECTION{ 0x00020000u }; - inline constexpr auto KF_FLAG_NO_PACKAGE_REDIRECTION{ 0x00010000u }; - inline constexpr auto KF_FLAG_FORCE_APPCONTAINER_REDIRECTION{ 0x00020000u }; - inline constexpr auto KF_FLAG_NO_APPCONTAINER_REDIRECTION{ 0x00010000u }; - inline constexpr auto KF_FLAG_CREATE{ 0x00008000u }; - inline constexpr auto KF_FLAG_DONT_VERIFY{ 0x00004000u }; - inline constexpr auto KF_FLAG_DONT_UNEXPAND{ 0x00002000u }; - inline constexpr auto KF_FLAG_NO_ALIAS{ 0x00001000u }; - inline constexpr auto KF_FLAG_INIT{ 0x00000800u }; - inline constexpr auto KF_FLAG_DEFAULT_PATH{ 0x00000400u }; - inline constexpr auto KF_FLAG_NOT_PARENT_RELATIVE{ 0x00000200u }; - inline constexpr auto KF_FLAG_SIMPLE_IDLIST{ 0x00000100u }; - inline constexpr auto KF_FLAG_ALIAS_ONLY{ 0x80000000u }; - - // string normalization forms - inline constexpr auto NORM_FORM_OTHER{ 0x0 }; - inline constexpr auto NORM_FORM_C{ 0x1 }; - inline constexpr auto NORM_FORM_D{ 0x2 }; - inline constexpr auto NORM_FORM_KC{ 0x5 }; - inline constexpr auto NORM_FORM_KD{ 0x6 }; - - // locale map flags - inline constexpr auto LCMAP_LOWERCASE{ 0x00000100u }; - inline constexpr auto LCMAP_UPPERCASE{ 0x00000200u }; - inline constexpr auto LCMAP_TITLECASE{ 0x00000300u }; - inline constexpr auto LCMAP_SORTKEY{ 0x00000400u }; - inline constexpr auto LCMAP_BYTEREV{ 0x00000800u }; - inline constexpr auto LCMAP_HIRAGANA{ 0x00100000u }; - inline constexpr auto LCMAP_KATAKANA{ 0x00200000u }; - inline constexpr auto LCMAP_HALFWIDTH{ 0x00400000u }; - inline constexpr auto LCMAP_FULLWIDTH{ 0x00800000u }; - inline constexpr auto LCMAP_LINGUISTIC_CASING{ 0x01000000u }; - inline constexpr auto LCMAP_SIMPLIFIED_CHINESE{ 0x02000000u }; - inline constexpr auto LCMAP_TRADITIONAL_CHINESE{ 0x04000000u }; - - // locale names - inline constexpr auto LOCALE_NAME_USER_DEFAULT{ nullptr }; - inline constexpr auto LOCALE_NAME_INVARIANT{ L"" }; - inline constexpr auto LOCALE_NAME_SYSTEM_DEFAULT{ L"!x-sys-default-locale" }; - - // process creation flags - inline constexpr auto DEBUG_PROCESS{ 0x00000001u }; - inline constexpr auto DEBUG_ONLY_THIS_PROCESS{ 0x00000002u }; - inline constexpr auto CREATE_SUSPENDED{ 0x00000004u }; - inline constexpr auto DETACHED_PROCESS{ 0x00000008u }; - inline constexpr auto CREATE_NEW_CONSOLE{ 0x00000010u }; - inline constexpr auto NORMAL_PRIORITY_CLASS{ 0x00000020u }; - inline constexpr auto IDLE_PRIORITY_CLASS{ 0x00000040u }; - inline constexpr auto HIGH_PRIORITY_CLASS{ 0x00000080u }; - inline constexpr auto REALTIME_PRIORITY_CLASS{ 0x00000100u }; - inline constexpr auto CREATE_NEW_PROCESS_GROUP{ 0x00000200u }; - inline constexpr auto CREATE_UNICODE_ENVIRONMENT{ 0x00000400u }; - inline constexpr auto CREATE_FORCEDOS{ 0x00002000u }; - inline constexpr auto BELOW_NORMAL_PRIORITY_CLASS{ 0x00004000u }; - inline constexpr auto ABOVE_NORMAL_PRIORITY_CLASS{ 0x00008000u }; - inline constexpr auto INHERIT_PARENT_AFFINITY{ 0x00010000u }; - inline constexpr auto CREATE_PROTECTED_PROCESS{ 0x00040000u }; - inline constexpr auto EXTENDED_STARTUPINFO_PRESENT{ 0x00080000u }; - inline constexpr auto PROCESS_MODE_BACKGROUND_BEGIN{ 0x00100000u }; - inline constexpr auto PROCESS_MODE_BACKGROUND_END{ 0x00200000u }; - inline constexpr auto CREATE_SECURE_PROCESS{ 0x00400000 }; - inline constexpr auto CREATE_BREAKAWAY_FROM_JOB{ 0x01000000u }; - inline constexpr auto CREATE_PRESERVE_CODE_AUTHZ_LEVEL{ 0x02000000u }; - inline constexpr auto CREATE_DEFAULT_ERROR_MODE{ 0x04000000u }; - inline constexpr auto CREATE_NO_WINDOW{ 0x08000000u }; - - // symbol name undecoration flags - inline constexpr auto UNDNAME_NO_MS_KEYWORDS{ 0x00000002u }; - inline constexpr auto UNDNAME_NO_FUNCTION_RETURNS{ 0x00000004u }; - inline constexpr auto UNDNAME_NO_ALLOCATION_MODEL{ 0x00000008u }; - inline constexpr auto UNDNAME_NO_ALLOCATION_LANGUAGE{ 0x00000010u }; - inline constexpr auto UNDNAME_NO_THISTYPE{ 0x00000060u }; - inline constexpr auto UNDNAME_NO_ACCESS_SPECIFIERS{ 0x00000080u }; - inline constexpr auto UNDNAME_NO_THROW_SIGNATURES{ 0x00000100u }; - inline constexpr auto UNDNAME_NO_RETURN_UDT_MODEL{ 0x00000400u }; - inline constexpr auto UNDNAME_NAME_ONLY{ 0x00001000u }; - inline constexpr auto UNDNAME_NO_ARGUMENTS{ 0x00002000u }; - - using THREAD_START_ROUTINE = std::uint32_t(void* a_param); - - struct CRITICAL_SECTION - { - public: - void* debugInfo; // 00 - std::int32_t lockCount; // 08 - std::int32_t recursionCount; // 0C - void* owningThread; // 10 - void* lockSemaphore; // 18 - std::uint64_t* spinCount; // 20 - }; - static_assert(sizeof(CRITICAL_SECTION) == 0x28); - - struct FILETIME - { - std::uint32_t lo; // 00 - std::uint32_t hi; // 04 - }; - static_assert(sizeof(FILETIME) == 0x8); - - struct GUID - { - std::uint32_t data1; - std::uint16_t data2; - std::uint16_t data3; - std::uint8_t data4[8]; - }; - static_assert(sizeof(GUID) == 0x10); - - // known folder ids - inline constexpr GUID FOLDERID_DOCUMENTS{ 0xFDD39AD0u, 0x238Fu, 0x46AFu, 0xADu, 0xB4u, 0x6Cu, 0x85u, 0x48u, 0x03u, 0x69u, 0xC7u }; - inline constexpr GUID FOLDERID_PICTURES{ 0x33E28130u, 0x4E1Eu, 0x4676u, 0x83u, 0x5Au, 0x98u, 0x39u, 0x5Cu, 0x3Bu, 0xC3u, 0xBBu }; - inline constexpr GUID FOLDERID_PROGRAMDATA{ 0x62AB5D82u, 0xFDC1u, 0x4DC3u, 0xA9u, 0xDDu, 0x07u, 0x0Du, 0x1Du, 0x49u, 0x5Du, 0x97u }; - - using HRESULT = std::uint32_t; - - struct HWND__; - using HWND = HWND__*; - - using WNDPROC = std::int32_t(__stdcall*)(HWND, std::uint32_t, std::uint64_t, std::int64_t); - - struct HICON__; - using HICON = HICON__*; - - struct HINSTANCE__; - using HINSTANCE = HINSTANCE__*; - using HMODULE = HINSTANCE; - - struct HKEY__; - using HKEY = HKEY__*; - - inline auto HKEY_CLASSES_ROOT{ reinterpret_cast(0x80000000ull) }; - inline auto HKEY_CURRENT_USER{ reinterpret_cast(0x80000001ull) }; - inline auto HKEY_LOCAL_MACHINE{ reinterpret_cast(0x80000002ull) }; - - struct IMAGE_DATA_DIRECTORY - { - std::uint32_t virtualAddress; - std::uint32_t size; - }; - static_assert(sizeof(IMAGE_DATA_DIRECTORY) == 0x8); - - struct IMAGE_DOS_HEADER - { - std::uint16_t magic; - std::uint16_t cblp; - std::uint16_t cp; - std::uint16_t crlc; - std::uint16_t cparhdr; - std::uint16_t minalloc; - std::uint16_t maxalloc; - std::uint16_t ss; - std::uint16_t sp; - std::uint16_t csum; - std::uint16_t ip; - std::uint16_t cs; - std::uint16_t lfarlc; - std::uint16_t ovno; - std::uint16_t res[4]; - std::uint16_t oemid; - std::uint16_t oeminfo; - std::uint16_t res2[10]; - std::int32_t lfanew; - }; - static_assert(sizeof(IMAGE_DOS_HEADER) == 0x40); - - struct IMAGE_FILE_HEADER - { - std::uint16_t machine; - std::uint16_t sectionCount; - std::uint32_t timeDateStamp; - std::uint32_t symbolTablePtr; - std::uint32_t symbolCount; - std::uint16_t optionalHeaderSize; - std::uint16_t characteristics; - }; - static_assert(sizeof(IMAGE_FILE_HEADER) == 0x14); - - struct IMAGE_IMPORT_BY_NAME - { - std::uint16_t hint; - char name[1]; - }; - static_assert(sizeof(IMAGE_IMPORT_BY_NAME) == 0x4); - - struct IMAGE_IMPORT_DESCRIPTOR - { - union - { - std::uint32_t characteristics; - std::uint32_t firstThunkOriginal; - }; - - std::uint32_t timeDateStamp; - std::uint32_t forwarderChain; - std::uint32_t name; - std::uint32_t firstThunk; - }; - static_assert(sizeof(IMAGE_IMPORT_DESCRIPTOR) == 0x14); - - struct IMAGE_OPTIONAL_HEADER64 - { - std::uint16_t magic; - std::uint8_t linkerVersionMajor; - std::uint8_t linkerVersionMinor; - std::uint32_t codeSize; - std::uint32_t initializedDataSize; - std::uint32_t uninitializedDataSize; - std::uint32_t entryPointAddress; - std::uint32_t codeBase; - std::uint64_t imageBase; - std::uint32_t sectionAlignment; - std::uint32_t fileAlignment; - std::uint16_t osVersionMajor; - std::uint16_t osVersionMinor; - std::uint16_t imageVersionMajor; - std::uint16_t imageVersionMinor; - std::uint16_t subsystemVersionMajor; - std::uint16_t subsystemVersionMinor; - std::uint32_t win32Version; - std::uint32_t imageSize; - std::uint32_t headersSize; - std::uint32_t checksum; - std::uint16_t subsystem; - std::uint16_t dllCharacteristics; - std::uint64_t stackReserveSize; - std::uint64_t stackCommitSize; - std::uint64_t heapReserveSize; - std::uint64_t heapCommitSize; - std::uint32_t loaderFlags; - std::uint32_t rvaAndSizesCount; - IMAGE_DATA_DIRECTORY dataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; - }; - static_assert(sizeof(IMAGE_OPTIONAL_HEADER64) == 0xF0); - - struct IMAGE_NT_HEADERS64 - { - std::uint32_t signature; - IMAGE_FILE_HEADER fileHeader; - IMAGE_OPTIONAL_HEADER64 optionalHeader; - }; - static_assert(sizeof(IMAGE_NT_HEADERS64) == 0x108); - - struct IMAGE_SECTION_HEADER - { - std::uint8_t name[IMAGE_SIZEOF_SHORT_NAME]; - union - { - std::uint32_t physicalAddress; - std::uint32_t virtualSize; - }; - std::uint32_t virtualAddress; - std::uint32_t rawDataSize; - std::uint32_t rawDataPtr; - std::uint32_t relocationsPtr; - std::uint32_t lineNumbersPtr; - std::uint16_t relocationsCount; - std::uint16_t lineNumbersCount; - std::uint32_t characteristics; - }; - static_assert(sizeof(IMAGE_SECTION_HEADER) == 0x28); - - struct IMAGE_THUNK_DATA64 - { - union - { - std::uint64_t forwarderString; // PBYTE - std::uint64_t function; // PDWORD - std::uint64_t ordinal; - std::uint64_t address; // PIMAGE_IMPORT_BY_NAME - }; - }; - static_assert(sizeof(IMAGE_THUNK_DATA64) == 0x8); - - struct MEMORY_BASIC_INFORMATION - { - void* baseAddress; - void* allocationBase; - std::uint32_t allocationProtect; - std::uint16_t partitionID; - std::size_t regionSize; - std::uint32_t state; - std::uint32_t protect; - std::uint32_t type; - }; - static_assert(sizeof(MEMORY_BASIC_INFORMATION) == 0x30); - - struct NLSVERSIONINFO; - - struct POINT - { - std::int32_t x; - std::int32_t y; - }; - - struct PROCESS_INFORMATION - { - void* process; - void* thread; - std::uint32_t processID; - std::uint32_t threadID; - }; - static_assert(sizeof(PROCESS_INFORMATION) == 0x18); - - struct RECT - { - std::int32_t left; - std::int32_t top; - std::int32_t right; - std::int32_t bottom; - }; - - struct SECURITY_ATTRIBUTES - { - std::uint32_t length; - void* securityDescriptor; - bool inheritHandle; - }; - static_assert(sizeof(SECURITY_ATTRIBUTES) == 0x18); - - struct STARTUPINFOA - { - std::uint32_t size; - char* reserved0; - char* desktop; - char* title; - std::uint32_t x; - std::uint32_t y; - std::uint32_t xSize; - std::uint32_t ySize; - std::uint32_t xCountChars; - std::uint32_t yCountChars; - std::uint32_t fillAttribute; - std::uint32_t flags; - std::uint16_t showWindow; - std::uint16_t reserved1; - std::uint8_t* reserved2; - void* stdIn; - void* stdOut; - void* stdErr; - }; - static_assert(sizeof(STARTUPINFOA) == 0x68); - - struct STARTUPINFOW - { - std::uint32_t size; - wchar_t* reserved0; - wchar_t* desktop; - wchar_t* title; - std::uint32_t x; - std::uint32_t y; - std::uint32_t xSize; - std::uint32_t ySize; - std::uint32_t xCountChars; - std::uint32_t yCountChars; - std::uint32_t fillAttribute; - std::uint32_t flags; - std::uint16_t showWindow; - std::uint16_t reserved1; - std::uint8_t* reserved2; - void* stdIn; - void* stdOut; - void* stdErr; - }; - static_assert(sizeof(STARTUPINFOW) == 0x68); - - struct SYSTEM_INFO - { - union - { - std::uint32_t oemID; - struct - { - std::uint16_t processorArch; - std::uint16_t reserved; - }; - }; - std::uint32_t pageSize; - void* appAddressMin; - void* appAddressMax; - std::uintptr_t processorActiveMask; - std::uint32_t processorCount; - std::uint32_t processorType; - std::uint32_t allocationGranularity; - std::uint16_t processorLevel; - std::uint16_t processorRevision; - }; - static_assert(sizeof(SYSTEM_INFO) == 0x30); - - union ULARGE_INTEGER - { - struct - { - std::uint32_t lo; - std::uint32_t hi; - }; - std::uint64_t value; - }; - - struct WIN32_FIND_DATAA - { - // members - std::uint32_t fileAttributes; - FILETIME creationTime; - FILETIME lastAccessTime; - FILETIME lastWriteTime; - std::uint32_t fileSizeHi; - std::uint32_t fileSizeLo; - std::uint32_t reserved0; - std::uint32_t reserved1; - char fileName[MAX_PATH]; - char fileNameAlt[14]; - }; - static_assert(sizeof(WIN32_FIND_DATAA) == 0x140); - - struct WIN32_FIND_DATAW - { - // members - std::uint32_t fileAttributes; - FILETIME creationTime; - FILETIME lastAccessTime; - FILETIME lastWriteTime; - std::uint32_t fileSizeHi; - std::uint32_t fileSizeLo; - std::uint32_t reserved0; - std::uint32_t reserved1; - wchar_t fileName[MAX_PATH]; - wchar_t fileNameAlt[14]; - }; - static_assert(sizeof(WIN32_FIND_DATAW) == 0x250); - - enum VKEnum : std::uint32_t - { - VK_LBUTTON = 0x1, - VK_RBUTTON = 0x2, - VK_CANCEL = 0x3, - VK_MBUTTON = 0x4, - VK_XBUTTON1 = 0x5, - VK_XBUTTON2 = 0x6, - VK_BACK = 0x8, - VK_TAB = 0x9, - VK_RESERVED_0A = 0xA, - VK_RESERVED_0B = 0xB, - VK_CLEAR = 0xC, - VK_RETURN = 0xD, - VK_SHIFT = 0x10, - VK_CONTROL = 0x11, - VK_MENU = 0x12, - VK_PAUSE = 0x13, - VK_CAPITAL = 0x14, - VK_KANA = 0x15, - VK_HANGUEL = 0x15, - VK_HANGUL = 0x15, - VK_IME_ON = 0x16, - VK_JUNJA = 0x17, - VK_FINAL = 0x18, - VK_HANJA = 0x19, - VK_KANJI = VK_HANJA, - VK_IME_OFF = 0x1A, - VK_ESCAPE = 0x1B, - VK_CONVERT = 0x1C, - VK_NONCONVERT = 0x1D, - VK_ACCEPT = 0x1E, - VK_MODECHANGE = 0x1F, - VK_SPACE = 0x20, - VK_PRIOR = 0x21, - VK_NEXT = 0x22, - VK_END = 0x23, - VK_HOME = 0x24, - VK_LEFT = 0x25, - VK_UP = 0x26, - VK_RIGHT = 0x27, - VK_DOWN = 0x28, - VK_SELECT = 0x29, - VK_PRINT = 0x2A, - VK_EXECUTE = 0x2B, - VK_SNAPSHOT = 0x2C, - VK_INSERT = 0x2D, - VK_DELETE = 0x2E, - VK_HELP = 0x2F, - VK_0 = 0x30, - VK_1 = 0x31, - VK_2 = 0x32, - VK_3 = 0x33, - VK_4 = 0x34, - VK_5 = 0x35, - VK_6 = 0x36, - VK_7 = 0x37, - VK_8 = 0x38, - VK_9 = 0x39, - VK_A = 0x41, - VK_B = 0x42, - VK_C = 0x43, - VK_D = 0x44, - VK_E = 0x45, - VK_F = 0x46, - VK_G = 0x47, - VK_H = 0x48, - VK_I = 0x49, - VK_J = 0x4A, - VK_K = 0x4B, - VK_L = 0x4C, - VK_M = 0x4D, - VK_N = 0x4E, - VK_O = 0x4F, - VK_P = 0x50, - VK_Q = 0x51, - VK_R = 0x52, - VK_S = 0x53, - VK_T = 0x54, - VK_U = 0x55, - VK_V = 0x56, - VK_W = 0x57, - VK_X = 0x58, - VK_Y = 0x59, - VK_Z = 0x5A, - VK_LWIN = 0x5B, - VK_RWIN = 0x5C, - VK_APPS = 0x5D, - VK_RESERVED_5E = 0x5E, - VK_SLEEP = 0x5F, - VK_NUMPAD0 = 0x60, - VK_NUMPAD1 = 0x61, - VK_NUMPAD2 = 0x62, - VK_NUMPAD3 = 0x63, - VK_NUMPAD4 = 0x64, - VK_NUMPAD5 = 0x65, - VK_NUMPAD6 = 0x66, - VK_NUMPAD7 = 0x67, - VK_NUMPAD8 = 0x68, - VK_NUMPAD9 = 0x69, - VK_MULTIPLY = 0x6A, - VK_ADD = 0x6B, - VK_SEPARATOR = 0x6C, - VK_SUBTRACT = 0x6D, - VK_DECIMAL = 0x6E, - VK_DIVIDE = 0x6F, - VK_F1 = 0x70, - VK_F2 = 0x71, - VK_F3 = 0x72, - VK_F4 = 0x73, - VK_F5 = 0x74, - VK_F6 = 0x75, - VK_F7 = 0x76, - VK_F8 = 0x77, - VK_F9 = 0x78, - VK_F10 = 0x79, - VK_F11 = 0x7A, - VK_F12 = 0x7B, - VK_F13 = 0x7C, - VK_F14 = 0x7D, - VK_F15 = 0x7E, - VK_F16 = 0x7F, - VK_F17 = 0x80, - VK_F18 = 0x81, - VK_F19 = 0x82, - VK_F20 = 0x83, - VK_F21 = 0x84, - VK_F22 = 0x85, - VK_F23 = 0x86, - VK_F24 = 0x87, - VK_NUMLOCK = 0x90, - VK_SCROLL = 0x91, - VK_OEMSPECIFIC_92 = 0x92, - VK_OEMSPECIFIC_93 = 0x93, - VK_OEMSPECIFIC_94 = 0x94, - VK_OEMSPECIFIC_95 = 0x95, - VK_OEMSPECIFIC_96 = 0x96, - VK_LSHIFT = 0xA0, - VK_RSHIFT = 0xA1, - VK_LCONTROL = 0xA2, - VK_RCONTROL = 0xA3, - VK_LMENU = 0xA4, - VK_RMENU = 0xA5, - VK_BROWSER_BACK = 0xA6, - VK_BROWSER_FORWARD = 0xA7, - VK_BROWSER_REFRESH = 0xA8, - VK_BROWSER_STOP = 0xA9, - VK_BROWSER_SEARCH = 0xAA, - VK_BROWSER_FAVORITES = 0xAB, - VK_BROWSER_HOME = 0xAC, - VK_VOLUME_MUTE = 0xAD, - VK_VOLUME_DOWN = 0xAE, - VK_VOLUME_UP = 0xAF, - VK_MEDIA_NEXT_TRACK = 0xB0, - VK_MEDIA_PREV_TRACK = 0xB1, - VK_MEDIA_STOP = 0xB2, - VK_MEDIA_PLAY_PAUSE = 0xB3, - VK_LAUNCH_MAIL = 0xB4, - VK_LAUNCH_MEDIA_SELECT = 0xB5, - VK_LAUNCH_APP1 = 0xB6, - VK_LAUNCH_APP2 = 0xB7, - VK_RESERVED_B8 = 0xB8, - VK_RESERVED_B9 = 0xB9, - VK_OEM_1 = 0xBA, - VK_OEM_PLUS = 0xBB, - VK_OEM_COMMA = 0xBC, - VK_OEM_MINUS = 0xBD, - VK_OEM_PERIOD = 0xBE, - VK_OEM_2 = 0xBF, - VK_OEM_3 = 0xC0, - VK_RESERVED_C1 = 0xC1, - VK_RESERVED_C2 = 0xC2, - VK_RESERVED_C3 = 0xC3, - VK_RESERVED_C4 = 0xC4, - VK_RESERVED_C5 = 0xC5, - VK_RESERVED_C6 = 0xC6, - VK_RESERVED_C7 = 0xC7, - VK_RESERVED_C8 = 0xC8, - VK_RESERVED_C9 = 0xC9, - VK_RESERVED_CA = 0xCA, - VK_RESERVED_CB = 0xCB, - VK_RESERVED_CC = 0xCC, - VK_RESERVED_CD = 0xCD, - VK_RESERVED_CE = 0xCE, - VK_RESERVED_CF = 0xCF, - VK_RESERVED_D0 = 0xD0, - VK_RESERVED_D1 = 0xD1, - VK_RESERVED_D2 = 0xD2, - VK_RESERVED_D3 = 0xD3, - VK_RESERVED_D4 = 0xD4, - VK_RESERVED_D5 = 0xD5, - VK_RESERVED_D6 = 0xD6, - VK_RESERVED_D7 = 0xD7, - VK_OEM_4 = 0xDB, - VK_OEM_5 = 0xDC, - VK_OEM_6 = 0xDD, - VK_OEM_7 = 0xDE, - VK_OEM_8 = 0xDF, - VK_RESERVED_E0 = 0xE0, - VK_OEMSPECIFIC_E1 = 0xE1, - VK_OEM_102 = 0xE2, - VK_OEMSPECIFIC_E3 = 0xE3, - VK_OEMSPECIFIC_E4 = 0xE4, - VK_PROCESSKEY = 0xE5, - VK_OEMSPECIFIC_E6 = 0xE6, - VK_PACKET = 0xE7, - VK_OEMSPECIFIC_E9 = 0xE9, - VK_OEMSPECIFIC_EA = 0xEA, - VK_OEMSPECIFIC_EB = 0xEB, - VK_OEMSPECIFIC_EC = 0xEC, - VK_OEMSPECIFIC_ED = 0xED, - VK_OEMSPECIFIC_EE = 0xEE, - VK_OEMSPECIFIC_EF = 0xEF, - VK_OEMSPECIFIC_F0 = 0xF0, - VK_OEMSPECIFIC_F1 = 0xF1, - VK_OEMSPECIFIC_F2 = 0xF2, - VK_OEMSPECIFIC_F3 = 0xF3, - VK_OEMSPECIFIC_F4 = 0xF4, - VK_OEMSPECIFIC_F5 = 0xF5, - VK_ATTN = 0xF6, - VK_CRSEL = 0xF7, - VK_EXSEL = 0xF8, - VK_EREOF = 0xF9, - VK_PLAY = 0xFA, - VK_ZOOM = 0xFB, - VK_NONAME = 0xFC, - VK_PA1 = 0xFD, - VK_OEM_CLEAR = 0xFE, - VK_RESERVED_FF = 0xFF - }; - - bool CloseHandle( - void* a_handle) noexcept; - - void CoTaskMemFree( - void* a_block) noexcept; - - void* CreateFileMapping( - void* a_file, - SECURITY_ATTRIBUTES* a_attributes, - std::uint32_t a_protect, - std::uint32_t a_maxSizeHigh, - std::uint32_t a_maxSizeLow, - const char* a_name) noexcept; - - void* CreateFileMapping( - void* a_file, - SECURITY_ATTRIBUTES* a_attributes, - std::uint32_t a_protect, - std::uint32_t a_maxSizeHigh, - std::uint32_t a_maxSizeLow, - const wchar_t* a_name) noexcept; - - bool CreateProcess( - const char* a_name, - char* a_cmd, - SECURITY_ATTRIBUTES* a_procAttr, - SECURITY_ATTRIBUTES* a_threadAttr, - bool a_inherit, - std::uint32_t a_flags, - void* a_env, - const char* a_curDir, - STARTUPINFOA* a_startInfo, - PROCESS_INFORMATION* a_procInfo) noexcept; - - bool CreateProcess( - const wchar_t* a_name, - wchar_t* a_cmd, - SECURITY_ATTRIBUTES* a_procAttr, - SECURITY_ATTRIBUTES* a_threadAttr, - bool a_inherit, - std::uint32_t a_flags, - void* a_env, - const wchar_t* a_curDir, - STARTUPINFOW* a_startInfo, - PROCESS_INFORMATION* a_procInfo) noexcept; - - void* CreateRemoteThread( - void* a_process, - SECURITY_ATTRIBUTES* a_threadAttr, - std::size_t a_stackSize, - THREAD_START_ROUTINE* a_startAddr, - void* a_param, - std::uint32_t a_flags, - std::uint32_t* a_threadID) noexcept; - - void* CreateThread( - SECURITY_ATTRIBUTES* a_threadAttr, - std::size_t a_stackSize, - THREAD_START_ROUTINE* a_startAddr, - void* a_param, - std::uint32_t a_flags, - std::uint32_t* a_threadID) noexcept; - - std::uint32_t ExpandEnvironmentStrings( - const char* a_src, - char* a_dst, - std::uint32_t a_dstLen) noexcept; - - std::uint32_t ExpandEnvironmentStrings( - const wchar_t* a_src, - wchar_t* a_dst, - std::uint32_t a_dstLen) noexcept; - - [[nodiscard]] bool FindClose( - void* a_file) noexcept; - - [[nodiscard]] void* FindFirstFile( - const char* a_name, - WIN32_FIND_DATAA* a_data) noexcept; - - [[nodiscard]] void* FindFirstFile( - const wchar_t* a_name, - WIN32_FIND_DATAW* a_data) noexcept; - - [[nodiscard]] bool FindNextFile( - void* a_file, - WIN32_FIND_DATAA* a_data) noexcept; - - [[nodiscard]] bool FindNextFile( - void* a_file, - WIN32_FIND_DATAW* a_data) noexcept; - - bool FlushInstructionCache( - void* a_process, - const void* a_baseAddr, - std::size_t a_size) noexcept; - - bool FreeLibrary( - HMODULE a_module) noexcept; - - [[nodiscard]] void* GetCurrentModule() noexcept; - - [[nodiscard]] void* GetCurrentProcess() noexcept; - - [[nodiscard]] std::uint32_t GetCurrentThreadID() noexcept; - - [[nodiscard]] std::uint32_t GetEnvironmentVariable( - const char* a_name, - char* a_buffer, - std::uint32_t a_size) noexcept; - - [[nodiscard]] std::uint32_t GetEnvironmentVariable( - const wchar_t* a_name, - wchar_t* a_buffer, - std::uint32_t a_size) noexcept; - - [[nodiscard]] bool GetFileVersionInfo( - const char* a_name, - std::uint32_t a_handle, - std::uint32_t a_dataLen, - void* a_data) noexcept; - - [[nodiscard]] bool GetFileVersionInfo( - const wchar_t* a_name, - std::uint32_t a_handle, - std::uint32_t a_dataLen, - void* a_data) noexcept; - - [[nodiscard]] std::uint32_t GetFileVersionInfoSize( - const char* a_name, - std::uint32_t* a_handle) noexcept; - - [[nodiscard]] std::uint32_t GetFileVersionInfoSize( - const wchar_t* a_name, - std::uint32_t* a_handle) noexcept; - - [[nodiscard]] std::int32_t GetKeyNameText( - std::int32_t a_param, - char* a_buffer, - std::int32_t a_bufferLen) noexcept; - - [[nodiscard]] std::int32_t GetKeyNameText( - std::int32_t a_param, - wchar_t* a_buffer, - std::int32_t a_bufferLen) noexcept; - - [[nodiscard]] std::int16_t GetKeyState( - std::int32_t a_key) noexcept; - - [[nodiscard]] std::uint32_t GetLastError() noexcept; - - [[nodiscard]] std::size_t GetMaxPath() noexcept; - - [[nodiscard]] std::uint32_t GetModuleFileName( - void* a_module, - char* a_name, - std::uint32_t a_nameLen) noexcept; - - [[nodiscard]] std::uint32_t GetModuleFileName( - void* a_module, - wchar_t* a_name, - std::uint32_t a_nameLen) noexcept; - - [[nodiscard]] HMODULE GetModuleHandle( - const char* a_name) noexcept; - - [[nodiscard]] HMODULE GetModuleHandle( - const wchar_t* a_name) noexcept; - - [[nodiscard]] std::uint32_t GetPrivateProfileString( - const char* a_app, - const char* a_key, - const char* a_default, - char* a_out, - std::uint32_t a_outLen, - const char* a_name) noexcept; - - [[nodiscard]] std::uint32_t GetPrivateProfileString( - const wchar_t* a_app, - const wchar_t* a_key, - const wchar_t* a_default, - wchar_t* a_out, - std::uint32_t a_outLen, - const wchar_t* a_name) noexcept; - - [[nodiscard]] void* GetProcAddress( - void* a_module, - const char* a_name) noexcept; - - [[nodiscard]] std::string_view GetProcPath( - HMODULE a_handle) noexcept; - - void GetSystemInfo( - SYSTEM_INFO* a_info) noexcept; - - [[nodiscard]] bool IMAGE_SNAP_BY_ORDINAL64( - std::uint64_t a_ordinal) noexcept; - - [[nodiscard]] IMAGE_SECTION_HEADER* IMAGE_FIRST_SECTION( - const IMAGE_NT_HEADERS64* a_header) noexcept; - - [[nodiscard]] bool IsDebuggerPresent() noexcept; - - std::int32_t LCMapStringEx( - const wchar_t* a_locale, - std::uint32_t a_flags, - const wchar_t* a_src, - std::int32_t a_srcLen, - wchar_t* a_dest, - std::int32_t a_destLen, - NLSVERSIONINFO* a_info, - void* a_reserved, - std::intptr_t a_sortHandle) noexcept; - - [[nodiscard]] HMODULE LoadLibrary( - const char* a_name) noexcept; - - [[nodiscard]] HMODULE LoadLibrary( - const wchar_t* a_name) noexcept; - - [[nodiscard]] void* MapViewOfFile( - void* a_object, - std::uint32_t a_desiredAccess, - std::uint32_t a_fileOffsetHigh, - std::uint32_t a_fileOffsetLow, - std::size_t a_numBytesToMap) noexcept; - - [[nodiscard]] void* MapViewOfFileEx( - void* a_object, - std::uint32_t a_desiredAccess, - std::uint32_t a_fileOffsetHigh, - std::uint32_t a_fileOffsetLow, - std::size_t a_numBytesToMap, - void* a_baseAddress) noexcept; - - std::int32_t MessageBox( - void* a_wnd, - const char* a_text, - const char* a_caption, - std::uint32_t a_type) noexcept; - - std::int32_t MessageBox( - void* a_wnd, - const wchar_t* a_text, - const wchar_t* a_caption, - std::uint32_t a_type) noexcept; - - [[nodiscard]] std::int32_t MultiByteToWideChar( - std::uint32_t a_codePage, - std::uint32_t a_flags, - const char* a_str, - std::int32_t a_strLen, - wchar_t* a_wstr, - std::int32_t a_wstrLen); - - [[nodiscard]] std::int32_t NormalizeString( - std::int32_t a_normForm, - const wchar_t* a_src, - std::int32_t a_srcLen, - wchar_t* a_dest, - std::int32_t a_destLen); - - [[nodiscard]] void* OpenFileMapping( - std::uint32_t a_desiredAccess, - bool a_inheritHandle, - const char* a_name) noexcept; - - [[nodiscard]] void* OpenFileMapping( - std::uint32_t a_desiredAccess, - bool a_inheritHandle, - const wchar_t* a_name) noexcept; - - void OutputDebugString( - const char* a_outStr) noexcept; - - void OutputDebugString( - const wchar_t* a_outStr) noexcept; - - std::int32_t RegGetValue( - HKEY a_key, - const char* a_subKey, - const char* a_value, - std::uint32_t a_flags, - std::uint32_t* a_type, - void* a_data, - std::uint32_t* a_dataLen); - - std::int32_t RegGetValue( - HKEY a_key, - const wchar_t* a_subKey, - const wchar_t* a_value, - std::uint32_t a_flags, - std::uint32_t* a_type, - void* a_data, - std::uint32_t* a_dataLen); - - std::uint32_t ResumeThread( - void* a_handle) noexcept; - - bool SetEnvironmentVariable( - const char* a_name, - const char* a_value) noexcept; - - bool SetEnvironmentVariable( - const wchar_t* a_name, - const wchar_t* a_value) noexcept; - - [[nodiscard]] std::int32_t SHGetKnownFolderPath( - const GUID& a_id, - std::uint32_t a_flags, - void* a_token, - wchar_t** a_path) noexcept; - - [[nodiscard]] std::int32_t ShowCursor( - bool a_show) noexcept; - - void Sleep( - std::uint32_t a_milliseconds) noexcept; - - bool TerminateProcess( - void* a_process, - std::uint32_t a_exitCode) noexcept; - - [[nodiscard]] void* TlsGetValue( - std::uint32_t a_index) noexcept; - - bool TlsSetValue( - std::uint32_t a_index, - void* a_value) noexcept; - - [[nodiscard]] std::uint32_t UnDecorateSymbolName( - const char* a_name, - char* a_out, - std::uint32_t a_outLenMax, - std::uint32_t a_flags) noexcept; - - [[nodiscard]] std::uint32_t UnDecorateSymbolName( - const wchar_t* a_name, - wchar_t* a_out, - std::uint32_t a_outLenMax, - std::uint32_t a_flags) noexcept; - - bool UnmapViewOfFile( - const void* a_baseAddress) noexcept; - - bool VerQueryValue( - const void* a_block, - const char* a_subBlock, - void** a_buffer, - std::uint32_t* a_bufferLen) noexcept; - - bool VerQueryValue( - const void* a_block, - const wchar_t* a_subBlock, - void** a_buffer, - std::uint32_t* a_bufferLen) noexcept; - - void* VirtualAlloc( - void* a_address, - std::size_t a_size, - std::uint32_t a_type, - std::uint32_t a_protect) noexcept; - - void* VirtualAllocEx( - void* a_process, - void* a_address, - std::size_t a_size, - std::uint32_t a_type, - std::uint32_t a_protect) noexcept; - - bool VirtualFree( - void* a_address, - std::size_t a_size, - std::uint32_t a_type) noexcept; - - bool VirtualFreeEx( - void* a_process, - void* a_address, - std::size_t a_size, - std::uint32_t a_type) noexcept; - - bool VirtualProtect( - void* a_address, - std::size_t a_size, - std::uint32_t a_newProtect, - std::uint32_t* a_oldProtect) noexcept; - - bool VirtualProtectEx( - void* a_process, - void* a_address, - std::size_t a_size, - std::uint32_t a_newProtect, - std::uint32_t* a_oldProtect) noexcept; - - [[nodiscard]] std::size_t VirtualQuery( - const void* a_address, - MEMORY_BASIC_INFORMATION* a_buffer, - std::size_t a_bufferLen) noexcept; - - [[nodiscard]] std::size_t VirtualQueryEx( - void* a_process, - const void* a_address, - MEMORY_BASIC_INFORMATION* a_buffer, - std::size_t a_bufferLen) noexcept; - - [[nodiscard]] std::uint32_t WaitForSingleObject( - void* a_handle, - std::uint32_t a_milliseconds) noexcept; - - [[nodiscard]] std::uint32_t WaitForSingleObjectEx( - void* a_handle, - std::uint32_t a_milliseconds, - bool a_alertable) noexcept; - - [[nodiscard]] std::int32_t WideCharToMultiByte( - std::uint32_t a_codePage, - std::uint32_t a_flags, - const wchar_t* a_wstr, - std::int32_t a_wstrLen, - char* a_str, - std::int32_t a_strLen, - const char* a_default, - std::int32_t* a_defaultLen); - - bool WriteProcessMemory( - void* a_process, - void* a_address, - const void* a_buffer, - std::size_t a_bufferLen, - std::size_t* a_bufferWritten) noexcept; -} - -#endif // _INC_WINAPIFAMILY - -namespace RE::DirectX -{ - struct XMFLOAT4X4 - { - // members - float m[4][4]; - }; - static_assert(sizeof(XMFLOAT4X4) == 0x40); - - struct DXGI_RATIONAL - { - // members - std::uint32_t numerator; // 00 - std::uint32_t denominator; // 04 - }; - static_assert(sizeof(DXGI_RATIONAL) == 0x08); - - enum DXGI_MODE_SCALING : std::uint32_t - { - DXGI_MODE_SCALING_UNSPECIFIED = 0, - DXGI_MODE_SCALING_CENTERED = 1, - DXGI_MODE_SCALING_STRETCHED = 2 - }; - - enum DXGI_MODE_SCANLINE_ORDER : std::uint32_t - { - DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0, - DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1, - DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2, - DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3 - }; -} diff --git a/include/SKSE/Impl/XInputAPI.h b/include/SKSE/Impl/XInputAPI.h deleted file mode 100644 index 42280876a..000000000 --- a/include/SKSE/Impl/XInputAPI.h +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once - -// TODO: This should probably be behind some sort of pragma that allows linking with xinput -namespace RE::XInput -{ - struct __XINPUT_GAMEPAD - { - std::uint16_t wButtons; - std::byte bLeftTrigger; - std::byte bRightTrigger; - std::int16_t sThumbLX; - std::int16_t sThumbLY; - std::int16_t sThumbRX; - std::int16_t sThumbRY; - }; - using XINPUT_GAMEPAD = __XINPUT_GAMEPAD; - struct __XINPUT_STATE - { - std::uint32_t dwPacketNumber; - __XINPUT_GAMEPAD Gamepad; - }; - using XINPUT_STATE = __XINPUT_STATE; - struct __XINPUT_KEYSTROKE - { - std::uint16_t VirtualKey; - std::uint16_t Unicode; - std::uint16_t Flags; - std::uint8_t UserIndex; - std::uint8_t HidCode; - }; - using XINPUT_KEYSTROKE = __XINPUT_KEYSTROKE; - struct __XINPUT_VIBRATION - { - std::uint16_t wLeftMotorSpeed; - std::uint16_t wRightMotorSpeed; - }; - using XINPUT_VIBRATION = __XINPUT_VIBRATION; - - struct __XINPUT_CAPABILITIES - { - std::uint8_t Type; - std::uint8_t SubType; - std::uint16_t Flags; - XINPUT_GAMEPAD Gamepad; - XINPUT_VIBRATION Vibration; - }; - using XINPUT_CAPABILITIES = __XINPUT_CAPABILITIES; - - enum XInputButton : std::uint16_t - { - XINPUT_GAMEPAD_DPAD_UP = 0x0001, - XINPUT_GAMEPAD_DPAD_DOWN = 0x0002, - XINPUT_GAMEPAD_DPAD_LEFT = 0x0004, - XINPUT_GAMEPAD_DPAD_RIGHT = 0x0008, - XINPUT_GAMEPAD_START = 0x0010, - XINPUT_GAMEPAD_BACK = 0x0020, - XINPUT_GAMEPAD_LEFT_THUMB = 0x0040, - XINPUT_GAMEPAD_RIGHT_THUMB = 0x0080, - XINPUT_GAMEPAD_LEFT_SHOULDER = 0x0100, - XINPUT_GAMEPAD_RIGHT_SHOULDER = 0x0200, - XINPUT_GAMEPAD_A = 0x1000, - XINPUT_GAMEPAD_B = 0x2000, - XINPUT_GAMEPAD_X = 0x4000, - XINPUT_GAMEPAD_Y = 0x8000 - }; - static constexpr std::uint16_t XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE = 7849; - static constexpr std::uint16_t XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE = 8689; - static constexpr std::uint8_t XINPUT_GAMEPAD_TRIGGER_THRESHOLD = 30; - - static constexpr std::uint16_t XINPUT_BUTTON_MASK = XINPUT_GAMEPAD_DPAD_UP | - XINPUT_GAMEPAD_DPAD_DOWN | - XINPUT_GAMEPAD_DPAD_LEFT | - XINPUT_GAMEPAD_DPAD_RIGHT | - XINPUT_GAMEPAD_START | - XINPUT_GAMEPAD_BACK | - XINPUT_GAMEPAD_LEFT_THUMB | - XINPUT_GAMEPAD_RIGHT_THUMB | - XINPUT_GAMEPAD_LEFT_SHOULDER | - XINPUT_GAMEPAD_RIGHT_SHOULDER | - XINPUT_GAMEPAD_A | - XINPUT_GAMEPAD_B | - XINPUT_GAMEPAD_X | - XINPUT_GAMEPAD_Y; -} diff --git a/include/SKSE/Trampoline.h b/include/SKSE/Trampoline.h index dc2703757..3285b9a68 100644 --- a/include/SKSE/Trampoline.h +++ b/include/SKSE/Trampoline.h @@ -1,5 +1,7 @@ #pragma once +#include "REX/W32/KERNEL32.h" + #if defined(SKSE_SUPPORT_XBYAK) namespace Xbyak { @@ -80,10 +82,9 @@ namespace SKSE stl::report_and_fail("failed to create trampoline"sv); } - set_trampoline(mem, a_size, - [](void* a_mem, std::size_t) { - WinAPI::VirtualFree(a_mem, 0, WinAPI::MEM_RELEASE); - }); + set_trampoline(mem, a_size, [](void* a_mem, std::size_t) { + REX::W32::VirtualFree(a_mem, 0, REX::W32::MEM_RELEASE); + }); } void set_trampoline(void* a_trampoline, std::size_t a_size) { set_trampoline(a_trampoline, a_size, {}); } diff --git a/src/RE/A/Actor.cpp b/src/RE/A/Actor.cpp index 3ef846858..d4c77ca0a 100644 --- a/src/RE/A/Actor.cpp +++ b/src/RE/A/Actor.cpp @@ -1172,7 +1172,7 @@ namespace RE kTotal }; - char addonString[WinAPI::MAX_PATH]{ '\0' }; + char addonString[REX::W32::MAX_PATH]{ '\0' }; a_arma->GetNodeName(addonString, this, a_armor, -1); std::array skeletonRoot = { Get3D(k3rd), Get3D(k1st) }; if (skeletonRoot[k1st] == skeletonRoot[k3rd]) { diff --git a/src/RE/B/BSAtomic.cpp b/src/RE/B/BSAtomic.cpp index 1be15fa3d..a9f9cfcae 100644 --- a/src/RE/B/BSAtomic.cpp +++ b/src/RE/B/BSAtomic.cpp @@ -1,48 +1,6 @@ #include "RE/B/BSAtomic.h" -#define WIN32_LEAN_AND_MEAN - -#define NOGDICAPMASKS -#define NOVIRTUALKEYCODES -//#define NOWINMESSAGES -#define NOWINSTYLES -#define NOSYSMETRICS -#define NOMENUS -#define NOICONS -#define NOKEYSTATES -#define NOSYSCOMMANDS -#define NORASTEROPS -#define NOSHOWWINDOW -#define OEMRESOURCE -#define NOATOM -#define NOCLIPBOARD -#define NOCOLOR -//#define NOCTLMGR -#define NODRAWTEXT -#define NOGDI -#define NOKERNEL -//#define NOUSER -#define NONLS -//#define NOMB -#define NOMEMMGR -#define NOMETAFILE -#define NOMINMAX -//#define NOMSG -#define NOOPENFILE -#define NOSCROLL -#define NOSERVICE -#define NOSOUND -#define NOTEXTMETRIC -#define NOWH -#define NOWINOFFSETS -#define NOCOMM -#define NOKANJI -#define NOHELP -#define NOPROFILER -#define NODEFERWINDOWPOS -#define NOMCX - -#include +#include "REX/W32/KERNEL32.h" namespace RE { @@ -50,12 +8,12 @@ namespace RE semaphore() { stl::memzero(&semaphore); - semaphore = ::CreateSemaphoreA(nullptr, 0, 40, nullptr); + semaphore = REX::W32::CreateSemaphoreA(nullptr, 0, 40, nullptr); } BSSemaphoreBase::~BSSemaphoreBase() { - ::CloseHandle(semaphore); + REX::W32::CloseHandle(semaphore); stl::memzero(&semaphore); } @@ -66,25 +24,25 @@ namespace RE void BSSpinLock::Lock(std::uint32_t a_pauseAttempts) { - std::uint32_t myThreadID = ::GetCurrentThreadId(); + std::uint32_t myThreadID = REX::W32::GetCurrentThreadId(); _mm_lfence(); if (_owningThread == myThreadID) { - ::_InterlockedIncrement(&_lockCount); + REX::W32::InterlockedIncrement(&_lockCount); } else { std::uint32_t attempts = 0; - if (::_InterlockedCompareExchange(&_lockCount, 1, 0)) { + if (REX::W32::InterlockedCompareExchange(&_lockCount, 1, 0)) { do { ++attempts; _mm_pause(); if (attempts >= a_pauseAttempts) { std::uint32_t spinCount = 0; - while (::_InterlockedCompareExchange(&_lockCount, 1, 0)) { - Sleep(++spinCount < kFastSpinThreshold ? 0 : 1); + while (REX::W32::InterlockedCompareExchange(&_lockCount, 1, 0)) { + REX::W32::Sleep(++spinCount < kFastSpinThreshold ? 0 : 1); } break; } - } while (::_InterlockedCompareExchange(&_lockCount, 1, 0)); + } while (REX::W32::InterlockedCompareExchange(&_lockCount, 1, 0)); _mm_lfence(); } @@ -95,16 +53,16 @@ namespace RE void BSSpinLock::Unlock() { - std::uint32_t myThreadID = GetCurrentThreadId(); + std::uint32_t myThreadID = REX::W32::GetCurrentThreadId(); _mm_lfence(); if (_owningThread == myThreadID) { if (_lockCount == 1) { _owningThread = 0; _mm_mfence(); - ::_InterlockedCompareExchange(&_lockCount, 0, 1); + REX::W32::InterlockedCompareExchange(&_lockCount, 0, 1); } else { - ::_InterlockedDecrement(&_lockCount); + REX::W32::InterlockedDecrement(&_lockCount); } } } diff --git a/src/RE/B/BSDirectInputManager.cpp b/src/RE/B/BSDirectInputManager.cpp index dc5fd250f..ce9fcd0e7 100644 --- a/src/RE/B/BSDirectInputManager.cpp +++ b/src/RE/B/BSDirectInputManager.cpp @@ -8,28 +8,28 @@ namespace RE return *singleton; } - DirectInput8::IDirectInputDevice8A* BSDirectInputManager::CreateDeviceWithGUID(WinAPI::GUID* a_guid) + REX::W32::IDirectInputDevice8A* BSDirectInputManager::CreateDeviceWithGUID(REX::W32::GUID* a_guid) { using func_t = decltype(&BSDirectInputManager::CreateDeviceWithGUID); REL::Relocation func{ RELOCATION_ID(67373, 68675) }; return func(this, a_guid); } - void BSDirectInputManager::GetDeviceState(DirectInput8::IDirectInputDevice8A* a_device, std::uint32_t a_size, void* a_outData) + void BSDirectInputManager::GetDeviceState(REX::W32::IDirectInputDevice8A* a_device, std::uint32_t a_size, void* a_outData) { using func_t = decltype(&BSDirectInputManager::GetDeviceState); REL::Relocation func{ RELOCATION_ID(67375, 68677) }; return func(this, a_device, a_size, a_outData); } - void BSDirectInputManager::GetDeviceData(DirectInput8::IDirectInputDevice8A* a_device, std::uint32_t* a_dataSize, DirectInput8::DIDEVICEOBJECTDATA** a_outData) + void BSDirectInputManager::GetDeviceData(REX::W32::IDirectInputDevice8A* a_device, std::uint32_t* a_dataSize, REX::W32::DIDEVICEOBJECTDATA** a_outData) { using func_t = decltype(&BSDirectInputManager::GetDeviceData); REL::Relocation func{ RELOCATION_ID(67376, 68678) }; return func(this, a_device, a_dataSize, a_outData); } - void BSDirectInputManager::ReleaseDevice(DirectInput8::IDirectInputDevice8A* a_device) + void BSDirectInputManager::ReleaseDevice(REX::W32::IDirectInputDevice8A* a_device) { using func_t = decltype(&BSDirectInputManager::ReleaseDevice); REL::Relocation func{ RELOCATION_ID(67374, 68676) }; diff --git a/src/RE/B/BSWin32KeyboardDevice.cpp b/src/RE/B/BSWin32KeyboardDevice.cpp index ca63326f6..e0f0abe73 100644 --- a/src/RE/B/BSWin32KeyboardDevice.cpp +++ b/src/RE/B/BSWin32KeyboardDevice.cpp @@ -7,35 +7,35 @@ namespace RE return (a_keyCode < sizeof(curState)) && ((curState[a_keyCode] & 0x80) != 0); } - BSKeyboardDevice::Key BSWin32KeyboardDevice::RemapNumpadKey(DirectInput8::DIKey a_key) + BSKeyboardDevice::Key BSWin32KeyboardDevice::RemapNumpadKey(REX::W32::DIK a_key) { - if (WinAPI::GetKeyState(WinAPI::VKEnum::VK_NUMLOCK) != 1) { + if (REX::W32::GetKeyState(REX::W32::VK::VK_NUMLOCK) != 1) { return Key::kNone; } switch (a_key) { - case DirectInput8::DIKey::DIK_NUMPAD7: + case REX::W32::DIK::DIK_NUMPAD7: return Key::kKP_Multiply; - case DirectInput8::DIKey::DIK_NUMPAD8: + case REX::W32::DIK::DIK_NUMPAD8: return Key::kLeftAlt; - case DirectInput8::DIKey::DIK_NUMPAD9: + case REX::W32::DIK::DIK_NUMPAD9: return Key::kSpacebar; - case DirectInput8::DIKey::DIK_NUMPAD4: + case REX::W32::DIK::DIK_NUMPAD4: return Key::kPeriod; - case DirectInput8::DIKey::DIK_NUMPAD5: + case REX::W32::DIK::DIK_NUMPAD5: return Key::kSlash; - case DirectInput8::DIKey::DIK_NUMPAD6: + case REX::W32::DIK::DIK_NUMPAD6: return Key::kRightShift; - case DirectInput8::DIKey::DIK_NUMPAD1: + case REX::W32::DIK::DIK_NUMPAD1: return Key::kN; - case DirectInput8::DIKey::DIK_NUMPAD2: + case REX::W32::DIK::DIK_NUMPAD2: return Key::kM; - case DirectInput8::DIKey::DIK_NUMPAD3: + case REX::W32::DIK::DIK_NUMPAD3: return Key::kComma; - case DirectInput8::DIKey::DIK_NUMPAD0: + case REX::W32::DIK::DIK_NUMPAD0: return Key::kB; - case DirectInput8::DIKey::DIK_DECIMAL: + case REX::W32::DIK::DIK_DECIMAL: return Key::kC; - case DirectInput8::DIKey::DIK_DIVIDE: + case REX::W32::DIK::DIK_DIVIDE: return Key::kV; default: break; diff --git a/src/RE/G/GAtomic.cpp b/src/RE/G/GAtomic.cpp index e933c1096..b8db39aec 100644 --- a/src/RE/G/GAtomic.cpp +++ b/src/RE/G/GAtomic.cpp @@ -1,48 +1,6 @@ #include "RE/G/GAtomic.h" -#define WIN32_LEAN_AND_MEAN - -#define NOGDICAPMASKS -#define NOVIRTUALKEYCODES -//#define NOWINMESSAGES -#define NOWINSTYLES -#define NOSYSMETRICS -#define NOMENUS -#define NOICONS -#define NOKEYSTATES -#define NOSYSCOMMANDS -#define NORASTEROPS -#define NOSHOWWINDOW -#define OEMRESOURCE -#define NOATOM -#define NOCLIPBOARD -#define NOCOLOR -//#define NOCTLMGR -#define NODRAWTEXT -#define NOGDI -#define NOKERNEL -//#define NOUSER -#define NONLS -//#define NOMB -#define NOMEMMGR -#define NOMETAFILE -#define NOMINMAX -//#define NOMSG -#define NOOPENFILE -#define NOSCROLL -#define NOSERVICE -#define NOSOUND -#define NOTEXTMETRIC -#define NOWH -#define NOWINOFFSETS -#define NOCOMM -#define NOKANJI -#define NOHELP -#define NOPROFILER -#define NODEFERWINDOWPOS -#define NOMCX - -#include +#include "REX/W32/KERNEL32.h" namespace RE { @@ -59,23 +17,21 @@ namespace RE GLock::GLock(std::uint32_t a_spinCount) { - ::InitializeCriticalSectionAndSpinCount( - reinterpret_cast<::LPCRITICAL_SECTION>(&cs), - a_spinCount); + REX::W32::InitializeCriticalSectionAndSpinCount(&cs, a_spinCount); } GLock::~GLock() { - ::DeleteCriticalSection(reinterpret_cast<::LPCRITICAL_SECTION>(&cs)); + REX::W32::DeleteCriticalSection(&cs); } void GLock::Lock() { - ::EnterCriticalSection(reinterpret_cast<::LPCRITICAL_SECTION>(&cs)); + REX::W32::EnterCriticalSection(&cs); } void GLock::Unlock() { - ::LeaveCriticalSection(reinterpret_cast<::LPCRITICAL_SECTION>(&cs)); + REX::W32::LeaveCriticalSection(&cs); } } diff --git a/src/RE/G/GFxLog.cpp b/src/RE/G/GFxLog.cpp index 75b2530cc..ab4f64be7 100644 --- a/src/RE/G/GFxLog.cpp +++ b/src/RE/G/GFxLog.cpp @@ -1,5 +1,7 @@ #include "RE/G/GFxLog.h" +#include "REX/W32/KERNEL32.h" + namespace RE { GFxLog::GFxLog() : @@ -13,7 +15,7 @@ namespace RE std::vector buf(std::vsnprintf(nullptr, 0, a_fmt, a_argList) + 1); std::vsnprintf(buf.data(), buf.size(), a_fmt, args); va_end(args); - WinAPI::OutputDebugString(buf.data()); + REX::W32::OutputDebugStringA(buf.data()); } void GFxLog::LogMessageByType(LogMessageType a_messageType, const char* a_fmt, ...) diff --git a/src/RE/G/GMemoryHeap.cpp b/src/RE/G/GMemoryHeap.cpp index f98553d5d..56eff8fe4 100644 --- a/src/RE/G/GMemoryHeap.cpp +++ b/src/RE/G/GMemoryHeap.cpp @@ -1,4 +1,5 @@ #include "RE/G/GMemoryHeap.h" +#include "REX/W32/KERNEL32.h" namespace RE { @@ -102,8 +103,8 @@ namespace RE void GMemoryHeap::AssignToCurrentThread() { - assert(_ownerThreadID == 0 || _ownerThreadID == WinAPI::GetCurrentThreadID()); - _ownerThreadID = WinAPI::GetCurrentThreadID(); + assert(_ownerThreadID == 0 || _ownerThreadID == REX::W32::GetCurrentThreadId()); + _ownerThreadID = REX::W32::GetCurrentThreadId(); } bool GMemoryHeap::DumpMemoryLeaks() diff --git a/src/RE/M/MenuCursor.cpp b/src/RE/M/MenuCursor.cpp index 09287e3b3..72b8b5125 100644 --- a/src/RE/M/MenuCursor.cpp +++ b/src/RE/M/MenuCursor.cpp @@ -1,4 +1,5 @@ #include "RE/M/MenuCursor.h" +#include "REX/W32/USER32.h" namespace RE { @@ -12,11 +13,11 @@ namespace RE { if (a_visible && showCursorCount < 0) { do { - showCursorCount = WinAPI::ShowCursor(true); + showCursorCount = REX::W32::ShowCursor(true); } while (showCursorCount < 0); } else if (!a_visible && showCursorCount >= 0) { do { - showCursorCount = WinAPI::ShowCursor(false); + showCursorCount = REX::W32::ShowCursor(false); } while (showCursorCount >= 0); } } diff --git a/src/RE/R/Renderer.cpp b/src/RE/R/Renderer.cpp index a0c836949..1c7336337 100644 --- a/src/RE/R/Renderer.cpp +++ b/src/RE/R/Renderer.cpp @@ -24,90 +24,104 @@ namespace RE return func(this, a_renderTarget, a_filePath, a_textureFileFormat); } - void Renderer::Init(RendererInitOSData* a_data, ApplicationWindowProperties* windowProps, WinAPI::HWND window) + void Renderer::Init(RendererInitOSData* a_data, ApplicationWindowProperties* a_windowProps, REX::W32::HWND a_window) { using func_t = decltype(&Renderer::Init); REL::Relocation func{ RELOCATION_ID(75445, 77226) }; - return func(this, a_data, windowProps, window); + return func(this, a_data, a_windowProps, a_window); } - void Renderer::Begin(std::uint32_t windowID) + + void Renderer::Begin(std::uint32_t a_windowID) { using func_t = decltype(&Renderer::Begin); REL::Relocation func{ RELOCATION_ID(75460, 77245) }; - return func(this, windowID); + return func(this, a_windowID); } - void Renderer::CreateSwapChain(WinAPI::HWND* window, bool setCurrent) + + void Renderer::CreateSwapChain(REX::W32::HWND* a_window, bool a_setCurrent) { using func_t = decltype(&Renderer::CreateSwapChain); REL::Relocation func{ RELOCATION_ID(75457, 77242) }; - return func(this, window, setCurrent); + return func(this, a_window, a_setCurrent); } + void Renderer::End() { using func_t = decltype(&Renderer::End); REL::Relocation func{ RELOCATION_ID(75461, 77246) }; return func(this); } - void Renderer::KillWindow(std::uint32_t windowID) + + void Renderer::KillWindow(std::uint32_t a_windowID) { using func_t = decltype(&Renderer::KillWindow); REL::Relocation func{ RELOCATION_ID(75452, 77237) }; - return func(this, windowID); + return func(this, a_windowID); } + void Renderer::Lock() { using func_t = decltype(&Renderer::Lock); REL::Relocation func{ RELOCATION_ID(75458, 77243) }; return func(this); } + void Renderer::Unlock() { using func_t = decltype(&Renderer::Unlock); REL::Relocation func{ RELOCATION_ID(75459, 77244) }; return func(this); } - void Renderer::ResizeWindow(std::uint32_t windowID, std::uint32_t width, std::uint32_t height, bool fullscreen, bool borderless) + + void Renderer::ResizeWindow(std::uint32_t a_windowID, std::uint32_t a_width, std::uint32_t a_height, bool a_fullscreen, bool a_borderless) { using func_t = decltype(&Renderer::ResizeWindow); REL::Relocation func{ RELOCATION_ID(75454, 77239) }; - return func(this, windowID, width, height, fullscreen, borderless); + return func(this, a_windowID, a_width, a_height, a_fullscreen, a_borderless); } - void Renderer::RequestWindowResize(std::uint32_t width, std::uint32_t height) + + void Renderer::RequestWindowResize(std::uint32_t a_width, std::uint32_t a_height) { using func_t = decltype(&Renderer::RequestWindowResize); REL::Relocation func{ RELOCATION_ID(75450, 77235) }; - return func(this, width, height); + return func(this, a_width, a_height); } - void Renderer::SetWindowPosition(std::uint32_t windowID, std::int32_t x, std::int32_t y) + + void Renderer::SetWindowPosition(std::uint32_t a_windowID, std::int32_t a_x, std::int32_t a_y) { using func_t = decltype(&Renderer::SetWindowPosition); REL::Relocation func{ RELOCATION_ID(75448, 77233) }; - return func(this, windowID, x, y); + return func(this, a_windowID, a_x, a_y); } - void Renderer::SetWindowActiveState(bool show) + + void Renderer::SetWindowActiveState(bool a_show) { using func_t = decltype(&Renderer::SetWindowActiveState); REL::Relocation func{ RELOCATION_ID(75451, 77236) }; - return func(this, show); + return func(this, a_show); } - void Renderer::WindowSizeChanged(std::uint32_t windowID) + + void Renderer::WindowSizeChanged(std::uint32_t a_windowID) { using func_t = decltype(&Renderer::WindowSizeChanged); REL::Relocation func{ RELOCATION_ID(75453, 77238) }; - return func(this, windowID); + return func(this, a_windowID); } - void Renderer::ResetWindow(std::uint32_t windowID) + + void Renderer::ResetWindow(std::uint32_t a_windowID) { using func_t = decltype(&Renderer::ResetWindow); REL::Relocation func{ RELOCATION_ID(75454, 77239) }; - return func(this, windowID); + return func(this, a_windowID); } - void Renderer::UpdateViewPort(std::uint32_t a_unk, std::uint32_t b_unk, bool c_unk) + + void Renderer::UpdateViewPort(std::uint32_t a_unk1, std::uint32_t a_unk2, bool a_unk3) { using func_t = decltype(&Renderer::UpdateViewPort); REL::Relocation func{ RELOCATION_ID(75455, 77240) }; - return func(this, a_unk, b_unk, c_unk); + return func(this, a_unk1, a_unk2, a_unk3); } + void Renderer::Shutdown() { using func_t = decltype(&Renderer::Shutdown); @@ -128,10 +142,10 @@ namespace RE REL::Relocation singleton{ RELOCATION_ID(525002, 411483) }; return *singleton; } - [[nodiscard]] ID3D11Device* Renderer::GetDevice() + [[nodiscard]] REX::W32::ID3D11Device* Renderer::GetDevice() { // Location is a global pointer to the device in the Renderer Data - REL::Relocation device{ RELOCATION_ID(524729, 411348) }; + REL::Relocation device{ RELOCATION_ID(524729, 411348) }; return *device; } [[nodiscard]] RendererWindow* Renderer::GetCurrentRenderWindow() diff --git a/src/RE/T/TESObjectARMA.cpp b/src/RE/T/TESObjectARMA.cpp index 4cc238f24..2cc83163c 100644 --- a/src/RE/T/TESObjectARMA.cpp +++ b/src/RE/T/TESObjectARMA.cpp @@ -6,6 +6,8 @@ #include "RE/T/TESObjectREFR.h" #include "RE/T/TESRace.h" +#include "REX/W32/BASE.h" + namespace RE { bool HasArmorRace(const TESRace* a_sourceRace, const TESRace* a_targetRace) @@ -63,6 +65,6 @@ namespace RE } std::uint32_t sex = npc ? static_cast(npc->GetSex()) : 0; - sprintf_s(a_dstBuff, WinAPI::MAX_PATH, " (%08X)[%d]/ (%08X) [%2.0f%%]", GetFormID(), sex, a_armor->GetFormID(), weight); + sprintf_s(a_dstBuff, REX::W32::MAX_PATH, " (%08X)[%d]/ (%08X) [%2.0f%%]", GetFormID(), sex, a_armor->GetFormID(), weight); } } diff --git a/src/RE/T/TESObjectWEAP.cpp b/src/RE/T/TESObjectWEAP.cpp index ab9000b05..feadd9cc6 100644 --- a/src/RE/T/TESObjectWEAP.cpp +++ b/src/RE/T/TESObjectWEAP.cpp @@ -1,5 +1,7 @@ #include "RE/T/TESObjectWEAP.h" +#include "REX/W32/BASE.h" + namespace RE { float TESObjectWEAP::GetSpeed() const @@ -41,7 +43,7 @@ namespace RE void TESObjectWEAP::GetNodeName(char* a_dstBuff) const { - sprintf_s(a_dstBuff, WinAPI::MAX_PATH, "%s (%08X)", "Weapon", formID); + sprintf_s(a_dstBuff, REX::W32::MAX_PATH, "%s (%08X)", "Weapon", formID); } WEAPON_TYPE TESObjectWEAP::GetWeaponType() const diff --git a/src/REL/ID.cpp b/src/REL/ID.cpp index 86926e12a..e6c0f63bf 100644 --- a/src/REL/ID.cpp +++ b/src/REL/ID.cpp @@ -1,5 +1,7 @@ #include "REL/ID.h" +#include "REX/W32/KERNEL32.h" + namespace REL { namespace detail @@ -8,11 +10,11 @@ namespace REL { close(); - WinAPI::ULARGE_INTEGER bytes; + REX::W32::ULARGE_INTEGER bytes; bytes.value = a_size; - _mapping = WinAPI::OpenFileMapping( - WinAPI::FILE_MAP_READ | WinAPI::FILE_MAP_WRITE, + _mapping = REX::W32::OpenFileMappingW( + REX::W32::FILE_MAP_READ | REX::W32::FILE_MAP_WRITE, false, a_name.data()); if (!_mapping) { @@ -20,9 +22,9 @@ namespace REL return false; } - _view = WinAPI::MapViewOfFile( + _view = REX::W32::MapViewOfFile( _mapping, - WinAPI::FILE_MAP_READ | WinAPI::FILE_MAP_WRITE, + REX::W32::FILE_MAP_READ | REX::W32::FILE_MAP_WRITE, 0, 0, bytes.value); @@ -38,18 +40,18 @@ namespace REL { close(); - WinAPI::ULARGE_INTEGER bytes; + REX::W32::ULARGE_INTEGER bytes; bytes.value = a_size; - _mapping = WinAPI::OpenFileMapping( - WinAPI::FILE_MAP_READ | WinAPI::FILE_MAP_WRITE, + _mapping = REX::W32::OpenFileMappingW( + REX::W32::FILE_MAP_READ | REX::W32::FILE_MAP_WRITE, false, a_name.data()); if (!_mapping) { - _mapping = WinAPI::CreateFileMapping( - WinAPI::INVALID_HANDLE_VALUE, + _mapping = REX::W32::CreateFileMappingW( + REX::W32::INVALID_HANDLE_VALUE, nullptr, - WinAPI::PAGE_READWRITE, + REX::W32::PAGE_READWRITE, bytes.hi, bytes.lo, a_name.data()); @@ -58,9 +60,9 @@ namespace REL } } - _view = WinAPI::MapViewOfFile( + _view = REX::W32::MapViewOfFile( _mapping, - WinAPI::FILE_MAP_READ | WinAPI::FILE_MAP_WRITE, + REX::W32::FILE_MAP_READ | REX::W32::FILE_MAP_WRITE, 0, 0, bytes.value); @@ -74,12 +76,12 @@ namespace REL void memory_map::close() { if (_view) { - WinAPI::UnmapViewOfFile(static_cast(_view)); + REX::W32::UnmapViewOfFile(static_cast(_view)); _view = nullptr; } if (_mapping) { - WinAPI::CloseHandle(_mapping); + REX::W32::CloseHandle(_mapping); _mapping = nullptr; } } diff --git a/src/REL/Module.cpp b/src/REL/Module.cpp index 3a590cf74..846df2bf3 100644 --- a/src/REL/Module.cpp +++ b/src/REL/Module.cpp @@ -1,12 +1,14 @@ #include "REL/Module.h" +#include "REX/W32/KERNEL32.h" + namespace REL { void Module::load_segments() { - const auto dosHeader = reinterpret_cast(_base); - const auto ntHeader = stl::adjust_pointer(dosHeader, dosHeader->lfanew); - const auto sections = WinAPI::IMAGE_FIRST_SECTION(ntHeader); + const auto dosHeader = reinterpret_cast(_base); + const auto ntHeader = stl::adjust_pointer(dosHeader, dosHeader->lfanew); + const auto sections = REX::W32::IMAGE_FIRST_SECTION(ntHeader); const auto size = std::min(ntHeader->fileHeader.sectionCount, _segments.size()); for (std::size_t i = 0; i < size; ++i) { const auto& section = sections[i]; diff --git a/src/REX/W32/ADVAPI32.cpp b/src/REX/W32/ADVAPI32.cpp new file mode 100644 index 000000000..a84eb0b01 --- /dev/null +++ b/src/REX/W32/ADVAPI32.cpp @@ -0,0 +1,17 @@ +#include "REX/W32/ADVAPI32.h" + +REX_W32_IMPORT(std::int32_t, RegGetValueA, REX::W32::HKEY, const char*, const char*, std::uint32_t, std::uint32_t*, void*, std::uint32_t*); +REX_W32_IMPORT(std::int32_t, RegGetValueW, REX::W32::HKEY, const wchar_t*, const wchar_t*, std::uint32_t, std::uint32_t*, void*, std::uint32_t*); + +namespace REX::W32 +{ + std::int32_t RegGetValueA(HKEY a_key, const char* a_subKey, const char* a_value, std::uint32_t a_flags, std::uint32_t* a_type, void* a_data, std::uint32_t* a_dataLen) + { + return ::W32_IMPL_RegGetValueA(a_key, a_subKey, a_value, a_flags, a_type, a_data, a_dataLen); + } + + std::int32_t RegGetValueW(HKEY a_key, const wchar_t* a_subKey, const wchar_t* a_value, std::uint32_t a_flags, std::uint32_t* a_type, void* a_data, std::uint32_t* a_dataLen) + { + return ::W32_IMPL_RegGetValueW(a_key, a_subKey, a_value, a_flags, a_type, a_data, a_dataLen); + } +} diff --git a/src/REX/W32/D3D11.cpp b/src/REX/W32/D3D11.cpp new file mode 100644 index 000000000..536f6f42d --- /dev/null +++ b/src/REX/W32/D3D11.cpp @@ -0,0 +1,17 @@ +#include "D3D11.h" + +REX_W32_IMPORT(std::int32_t, D3D11CreateDevice, REX::W32::IDXGIAdapter*, REX::W32::D3D_DRIVER_TYPE, REX::W32::HMODULE, std::uint32_t, const REX::W32::D3D_FEATURE_LEVEL*, std::uint32_t, std::uint32_t, REX::W32::ID3D11Device**, REX::W32::D3D_FEATURE_LEVEL*, REX::W32::ID3D11DeviceContext**); +REX_W32_IMPORT(std::int32_t, D3D11CreateDeviceAndSwapChain, REX::W32::IDXGIAdapter*, REX::W32::D3D_DRIVER_TYPE, REX::W32::HMODULE, std::uint32_t, const REX::W32::D3D_FEATURE_LEVEL*, std::uint32_t, std::uint32_t, const REX::W32::DXGI_SWAP_CHAIN_DESC*, REX::W32::IDXGISwapChain**, REX::W32::ID3D11Device**, REX::W32::D3D_FEATURE_LEVEL*, REX::W32::ID3D11DeviceContext**); + +namespace REX::W32 +{ + HRESULT D3D11CreateDevice(IDXGIAdapter* a_adapter, D3D_DRIVER_TYPE a_driverType, HMODULE a_software, std::uint32_t a_flags, const D3D_FEATURE_LEVEL* a_pFeatureLevels, std::uint32_t a_featureLevels, std::uint32_t a_sdkVersion, ID3D11Device** a_device, D3D_FEATURE_LEVEL* a_pFeatureLevel, ID3D11DeviceContext** a_immediateContext) noexcept + { + return ::W32_IMPL_D3D11CreateDevice(a_adapter, a_driverType, a_software, a_flags, a_pFeatureLevels, a_featureLevels, a_sdkVersion, a_device, a_pFeatureLevel, a_immediateContext); + } + + HRESULT D3D11CreateDeviceAndSwapChain(IDXGIAdapter* a_adapter, D3D_DRIVER_TYPE a_driverType, HMODULE a_software, std::uint32_t a_flags, const D3D_FEATURE_LEVEL* a_pFeatureLevels, std::uint32_t a_featureLevels, std::uint32_t a_sdkVersion, const DXGI_SWAP_CHAIN_DESC* a_swapChainDesc, IDXGISwapChain** a_swapChain, ID3D11Device** a_device, D3D_FEATURE_LEVEL* a_pFeatureLevel, ID3D11DeviceContext** a_immediateContext) noexcept + { + return ::W32_IMPL_D3D11CreateDeviceAndSwapChain(a_adapter, a_driverType, a_software, a_flags, a_pFeatureLevels, a_featureLevels, a_sdkVersion, a_swapChainDesc, a_swapChain, a_device, a_pFeatureLevel, a_immediateContext); + } +} diff --git a/src/REX/W32/D3DCOMPILER.cpp b/src/REX/W32/D3DCOMPILER.cpp new file mode 100644 index 000000000..d13e89e91 --- /dev/null +++ b/src/REX/W32/D3DCOMPILER.cpp @@ -0,0 +1,155 @@ +#include "D3DCOMPILER.h" + +REX_W32_IMPORT(std::int32_t, D3DCompile, const void*, std::size_t, const char*, const REX::W32::D3D_SHADER_MACRO*, REX::W32::ID3DInclude*, const char*, const char*, std::uint32_t, std::uint32_t, REX::W32::ID3DBlob**, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DCompile2, const void*, std::size_t, const char*, const REX::W32::D3D_SHADER_MACRO*, REX::W32::ID3DInclude*, const char*, const char*, std::uint32_t, std::uint32_t, std::uint32_t, const void*, std::size_t, REX::W32::ID3DBlob**, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DCompileFromFile, const wchar_t*, const REX::W32::D3D_SHADER_MACRO*, REX::W32::ID3DInclude*, const char*, const char*, std::uint32_t, std::uint32_t, REX::W32::ID3DBlob**, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DCompressShaders, std::uint32_t, REX::W32::D3D_SHADER_DATA*, std::uint32_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DCreateBlob, std::size_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DCreateFunctionLinkingGraph, std::uint32_t, REX::W32::ID3D11FunctionLinkingGraph**); +REX_W32_IMPORT(std::int32_t, D3DCreateLinker, REX::W32::ID3D11Linker**); +REX_W32_IMPORT(std::int32_t, D3DDecompressShaders, const void*, std::size_t, std::uint32_t, std::uint32_t, std::uint32_t*, std::uint32_t, REX::W32::ID3DBlob**, std::uint32_t*); +REX_W32_IMPORT(std::int32_t, D3DDisassemble, const void*, std::size_t, std::uint32_t, const char*, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DDisassemble10Effect, REX::W32::ID3D10Effect*, std::uint32_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DDisassembleRegion, const void*, std::size_t, std::uint32_t, const char*, std::size_t, std::size_t, std::size_t*, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DGetBlobPart, const void*, std::size_t, REX::W32::D3D_BLOB_PART, std::uint32_t a_flags, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DGetDebugInfo, const void*, std::size_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DGetInputSignatureBlob, const void*, std::size_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DGetInputAndOutputSignatureBlob, const void*, std::size_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DGetOutputSignatureBlob, const void*, std::size_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DGetTraceInstructionOffsets, const void*, std::size_t, std::uint32_t, std::size_t, std::size_t, std::size_t*, std::size_t*); +REX_W32_IMPORT(std::int32_t, D3DLoadModule, const void*, std::size_t, REX::W32::ID3D11Module**); +REX_W32_IMPORT(std::int32_t, D3DPreprocess, const void*, std::size_t, const char*, const REX::W32::D3D_SHADER_MACRO*, REX::W32::ID3DInclude*, REX::W32::ID3DBlob**, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DReadFileToBlob, const wchar_t*, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DReflect, const void*, std::size_t, const REX::W32::IID&, void**); +REX_W32_IMPORT(std::int32_t, D3DReflectLibrary, const void*, std::size_t, const REX::W32::IID&, void**); +REX_W32_IMPORT(std::int32_t, D3DSetBlobPart, const void*, std::size_t, REX::W32::D3D_BLOB_PART, std::uint32_t, const void*, std::size_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DStripShader, const void*, std::size_t, std::uint32_t, REX::W32::ID3DBlob**); +REX_W32_IMPORT(std::int32_t, D3DWriteBlobToFile, REX::W32::ID3DBlob*, const wchar_t*, REX::W32::BOOL); + +namespace REX::W32 +{ + HRESULT D3DCompile(const void* a_srcData, std::size_t a_srcDataSize, const char* a_sourceName, const D3D_SHADER_MACRO* a_defines, ID3DInclude* a_include, const char* a_entrypoint, const char* a_target, std::uint32_t a_flags1, std::uint32_t a_flags2, ID3DBlob** a_code, ID3DBlob** a_errorMsgs) + { + return ::W32_IMPL_D3DCompile(a_srcData, a_srcDataSize, a_sourceName, a_defines, a_include, a_entrypoint, a_target, a_flags1, a_flags2, a_code, a_errorMsgs); + } + + HRESULT D3DCompile2(const void* a_srcData, std::size_t a_srcDataSize, const char* a_sourceName, const D3D_SHADER_MACRO* a_defines, ID3DInclude* a_include, const char* a_entrypoint, const char* a_target, std::uint32_t a_flags1, std::uint32_t a_flags2, std::uint32_t a_secondaryDataFlags, const void* a_secondaryData, std::size_t a_secondaryDataSize, ID3DBlob** a_code, ID3DBlob** a_errorMsgs) + { + return ::W32_IMPL_D3DCompile2(a_srcData, a_srcDataSize, a_sourceName, a_defines, a_include, a_entrypoint, a_target, a_flags1, a_flags2, a_secondaryDataFlags, a_secondaryData, a_secondaryDataSize, a_code, a_errorMsgs); + } + + HRESULT D3DCompileFromFile(const wchar_t* a_fileName, const D3D_SHADER_MACRO* a_defines, ID3DInclude* a_include, const char* a_entrypoint, const char* a_target, std::uint32_t a_flags1, std::uint32_t a_flags2, ID3DBlob** a_code, ID3DBlob** a_errorMsgs) + { + return ::W32_IMPL_D3DCompileFromFile(a_fileName, a_defines, a_include, a_entrypoint, a_target, a_flags1, a_flags2, a_code, a_errorMsgs); + } + + HRESULT D3DCompressShaders(std::uint32_t a_numShaders, D3D_SHADER_DATA* a_shaderData, std::uint32_t a_flags, ID3DBlob** a_compressedData) + { + return ::W32_IMPL_D3DCompressShaders(a_numShaders, a_shaderData, a_flags, a_compressedData); + } + + HRESULT D3DCreateBlob(std::size_t a_size, ID3DBlob** a_blob) + { + return ::W32_IMPL_D3DCreateBlob(a_size, a_blob); + } + + HRESULT D3DCreateFunctionLinkingGraph(std::uint32_t a_flags, ID3D11FunctionLinkingGraph** a_functionLinkingGraph) + { + return ::W32_IMPL_D3DCreateFunctionLinkingGraph(a_flags, a_functionLinkingGraph); + } + + HRESULT D3DCreateLinker(ID3D11Linker** a_linker) + { + return ::W32_IMPL_D3DCreateLinker(a_linker); + } + + HRESULT D3DDecompressShaders(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_numShaders, std::uint32_t a_startIndex, std::uint32_t* a_indices, std::uint32_t a_flags, ID3DBlob** a_shaders, std::uint32_t* a_totalShaders) + { + return ::W32_IMPL_D3DDecompressShaders(a_srcData, a_srcDataSize, a_numShaders, a_startIndex, a_indices, a_flags, a_shaders, a_totalShaders); + } + + HRESULT D3DDisassemble(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_flags, const char* a_comments, ID3DBlob** a_disassembly) + { + return ::W32_IMPL_D3DDisassemble(a_srcData, a_srcDataSize, a_flags, a_comments, a_disassembly); + } + + HRESULT D3DDisassemble10Effect(ID3D10Effect* a_effect, std::uint32_t a_flags, ID3DBlob** a_disassembly) + { + return ::W32_IMPL_D3DDisassemble10Effect(a_effect, a_flags, a_disassembly); + } + + HRESULT D3DDisassembleRegion(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_flags, const char* a_comments, std::size_t a_startByteOffset, std::size_t a_numInsts, std::size_t* a_finishByteOffset, ID3DBlob** a_disassembly) + { + return ::W32_IMPL_D3DDisassembleRegion(a_srcData, a_srcDataSize, a_flags, a_comments, a_startByteOffset, a_numInsts, a_finishByteOffset, a_disassembly); + } + + HRESULT D3DGetBlobPart(const void* a_srcData, std::size_t a_srcDataSize, D3D_BLOB_PART a_partType, std::uint32_t a_flags, ID3DBlob** a_part) + { + return ::W32_IMPL_D3DGetBlobPart(a_srcData, a_srcDataSize, a_partType, a_flags, a_part); + } + + HRESULT D3DGetDebugInfo(const void* a_srcData, std::size_t a_srcDataSize, ID3DBlob** a_debugInfo) + { + return ::W32_IMPL_D3DGetDebugInfo(a_srcData, a_srcDataSize, a_debugInfo); + } + + HRESULT D3DGetInputSignatureBlob(const void* a_srcData, std::size_t a_srcDataSize, ID3DBlob** a_signatureBlob) + { + return ::W32_IMPL_D3DGetInputSignatureBlob(a_srcData, a_srcDataSize, a_signatureBlob); + } + + HRESULT D3DGetInputAndOutputSignatureBlob(const void* a_srcData, std::size_t a_srcDataSize, ID3DBlob** a_signatureBlob) + { + return ::W32_IMPL_D3DGetInputAndOutputSignatureBlob(a_srcData, a_srcDataSize, a_signatureBlob); + } + + HRESULT D3DGetOutputSignatureBlob(const void* a_srcData, std::size_t a_srcDataSize, ID3DBlob** a_signatureBlob) + { + return ::W32_IMPL_D3DGetOutputSignatureBlob(a_srcData, a_srcDataSize, a_signatureBlob); + } + + HRESULT D3DGetTraceInstructionOffsets(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_flags, std::size_t a_startInstIndex, std::size_t a_numInsts, std::size_t* a_offsets, std::size_t* a_totalInsts) + { + return ::W32_IMPL_D3DGetTraceInstructionOffsets(a_srcData, a_srcDataSize, a_flags, a_startInstIndex, a_numInsts, a_offsets, a_totalInsts); + } + + HRESULT D3DLoadModule(const void* a_srcData, std::size_t a_srcDataSize, ID3D11Module** a_module) + { + return ::W32_IMPL_D3DLoadModule(a_srcData, a_srcDataSize, a_module); + } + + HRESULT D3DPreprocess(const void* a_srcData, std::size_t a_srcDataSize, const char* a_sourceName, const D3D_SHADER_MACRO* a_defines, ID3DInclude* a_include, ID3DBlob** a_codeText, ID3DBlob** a_errorMsgs) + { + return ::W32_IMPL_D3DPreprocess(a_srcData, a_srcDataSize, a_sourceName, a_defines, a_include, a_codeText, a_errorMsgs); + } + + HRESULT D3DReadFileToBlob(const wchar_t* a_fileName, ID3DBlob** a_contents) + { + return ::W32_IMPL_D3DReadFileToBlob(a_fileName, a_contents); + } + + HRESULT D3DReflect(const void* a_srcData, std::size_t a_srcDataSize, const IID& a_iid, void** a_reflector) + { + return ::W32_IMPL_D3DReflect(a_srcData, a_srcDataSize, a_iid, a_reflector); + } + + HRESULT D3DReflectLibrary(const void* a_srcData, std::size_t a_srcDataSize, const IID& a_iid, void** a_reflector) + { + return ::W32_IMPL_D3DReflectLibrary(a_srcData, a_srcDataSize, a_iid, a_reflector); + } + + HRESULT D3DSetBlobPart(const void* a_srcData, std::size_t a_srcDataSize, D3D_BLOB_PART a_partType, std::uint32_t a_flags, const void* a_part, std::size_t a_partSize, ID3DBlob** a_newShader) + { + return ::W32_IMPL_D3DSetBlobPart(a_srcData, a_srcDataSize, a_partType, a_flags, a_part, a_partSize, a_newShader); + } + + HRESULT D3DStripShader(const void* a_srcData, std::size_t a_srcDataSize, std::uint32_t a_stripFlags, ID3DBlob** a_strippedBlob) + { + return ::W32_IMPL_D3DStripShader(a_srcData, a_srcDataSize, a_stripFlags, a_strippedBlob); + } + + HRESULT D3DWriteBlobToFile(ID3DBlob* a_blob, const wchar_t* a_fileName, bool a_overwrite) + { + return ::W32_IMPL_D3DWriteBlobToFile(a_blob, a_fileName, static_cast(a_overwrite)); + } +} diff --git a/src/REX/W32/DBGHELP.cpp b/src/REX/W32/DBGHELP.cpp new file mode 100644 index 000000000..dc532bc39 --- /dev/null +++ b/src/REX/W32/DBGHELP.cpp @@ -0,0 +1,17 @@ +#include "REX/W32/DBGHELP.h" + +REX_W32_IMPORT(std::uint32_t, UnDecorateSymbolName, const char*, char*, std::uint32_t, std::uint32_t); +REX_W32_IMPORT(std::uint32_t, UnDecorateSymbolNameW, const wchar_t*, wchar_t*, std::uint32_t, std::uint32_t); + +namespace REX::W32 +{ + std::uint32_t UnDecorateSymbolName(const char* a_name, char* a_buf, std::uint32_t a_bufLen, std::uint32_t a_flags) noexcept + { + return ::W32_IMPL_UnDecorateSymbolName(a_name, a_buf, a_bufLen, a_flags); + } + + std::uint32_t UnDecorateSymbolNameW(const wchar_t* a_name, wchar_t* a_buf, std::uint32_t a_bufLen, std::uint32_t a_flags) noexcept + { + return ::W32_IMPL_UnDecorateSymbolNameW(a_name, a_buf, a_bufLen, a_flags); + } +} diff --git a/src/REX/W32/DXGI.cpp b/src/REX/W32/DXGI.cpp new file mode 100644 index 000000000..101933a12 --- /dev/null +++ b/src/REX/W32/DXGI.cpp @@ -0,0 +1,17 @@ +#include "DXGI.h" + +REX_W32_IMPORT(std::int32_t, CreateDXGIFactory, const IID&, void**); +REX_W32_IMPORT(std::int32_t, CreateDXGIFactory1, const IID&, void**); + +namespace REX::W32 +{ + HRESULT CreateDXGIFactory(const IID& a_iid, void** a_factory) noexcept + { + return ::W32_IMPL_CreateDXGIFactory(a_iid, a_factory); + } + + HRESULT CreateDXGIFactory1(const IID& a_iid, void** a_factory) noexcept + { + return ::W32_IMPL_CreateDXGIFactory1(a_iid, a_factory); + } +} diff --git a/src/REX/W32/KERNEL32.cpp b/src/REX/W32/KERNEL32.cpp new file mode 100644 index 000000000..69c11ca27 --- /dev/null +++ b/src/REX/W32/KERNEL32.cpp @@ -0,0 +1,467 @@ +#include "REX/W32/KERNEL32.h" + +REX_W32_IMPORT(REX::W32::BOOL, CloseHandle, REX::W32::HANDLE); +REX_W32_IMPORT(REX::W32::HANDLE, CreateFileMappingA, REX::W32::HANDLE, REX::W32::SECURITY_ATTRIBUTES*, std::uint32_t, std::uint32_t, std::uint32_t, const char*); +REX_W32_IMPORT(REX::W32::HANDLE, CreateFileMappingW, REX::W32::HANDLE, REX::W32::SECURITY_ATTRIBUTES*, std::uint32_t, std::uint32_t, std::uint32_t, const wchar_t*); +REX_W32_IMPORT(REX::W32::BOOL, CreateProcessA, const char*, char*, REX::W32::SECURITY_ATTRIBUTES*, REX::W32::SECURITY_ATTRIBUTES*, REX::W32::BOOL, std::uint32_t, void*, const char*, REX::W32::STARTUPINFOA*, REX::W32::PROCESS_INFORMATION*); +REX_W32_IMPORT(REX::W32::BOOL, CreateProcessW, const wchar_t*, wchar_t*, REX::W32::SECURITY_ATTRIBUTES*, REX::W32::SECURITY_ATTRIBUTES*, REX::W32::BOOL, std::uint32_t, void*, const wchar_t*, REX::W32::STARTUPINFOW*, REX::W32::PROCESS_INFORMATION*); +REX_W32_IMPORT(REX::W32::HANDLE, CreateRemoteThread, REX::W32::HANDLE, REX::W32::SECURITY_ATTRIBUTES*, std::size_t, REX::W32::THREAD_START_ROUTINE*, void*, std::uint32_t, std::uint32_t*); +REX_W32_IMPORT(REX::W32::HANDLE, CreateSemaphoreA, REX::W32::SECURITY_ATTRIBUTES*, std::int32_t, std::int32_t, const char*); +REX_W32_IMPORT(REX::W32::HANDLE, CreateThread, REX::W32::SECURITY_ATTRIBUTES*, std::size_t, REX::W32::THREAD_START_ROUTINE*, void*, std::uint32_t, std::uint32_t*); +REX_W32_IMPORT(void, DeleteCriticalSection, REX::W32::CRITICAL_SECTION*); +REX_W32_IMPORT(void, EnterCriticalSection, REX::W32::CRITICAL_SECTION*); +REX_W32_IMPORT(std::uint32_t, ExpandEnvironmentStringsA, const char*, char*, std::uint32_t); +REX_W32_IMPORT(std::uint32_t, ExpandEnvironmentStringsW, const wchar_t*, wchar_t*, std::uint32_t); +REX_W32_IMPORT(REX::W32::BOOL, FindClose, REX::W32::HANDLE); +REX_W32_IMPORT(REX::W32::HANDLE, FindFirstFileA, const char*, REX::W32::WIN32_FIND_DATAA*); +REX_W32_IMPORT(REX::W32::HANDLE, FindFirstFileW, const wchar_t*, REX::W32::WIN32_FIND_DATAW*); +REX_W32_IMPORT(REX::W32::BOOL, FindNextFileA, REX::W32::HANDLE, REX::W32::WIN32_FIND_DATAA*); +REX_W32_IMPORT(REX::W32::BOOL, FindNextFileW, REX::W32::HANDLE, REX::W32::WIN32_FIND_DATAW*); +REX_W32_IMPORT(REX::W32::BOOL, FlushInstructionCache, REX::W32::HANDLE, const void*, std::size_t); +REX_W32_IMPORT(REX::W32::BOOL, FreeLibrary, REX::W32::HMODULE); +REX_W32_IMPORT(REX::W32::HANDLE, GetCurrentProcess); +REX_W32_IMPORT(std::uint32_t, GetCurrentThreadId); +REX_W32_IMPORT(std::uint32_t, GetEnvironmentVariableA, const char*, char*, std::uint32_t); +REX_W32_IMPORT(std::uint32_t, GetEnvironmentVariableW, const wchar_t*, wchar_t*, std::uint32_t); +REX_W32_IMPORT(std::uint32_t, GetLastError); +REX_W32_IMPORT(std::uint32_t, GetModuleFileNameA, REX::W32::HMODULE, char*, std::uint32_t); +REX_W32_IMPORT(std::uint32_t, GetModuleFileNameW, REX::W32::HMODULE, wchar_t*, std::uint32_t); +REX_W32_IMPORT(REX::W32::HMODULE, GetModuleHandleA, const char*); +REX_W32_IMPORT(REX::W32::HMODULE, GetModuleHandleW, const wchar_t*); +REX_W32_IMPORT(std::uint32_t, GetPrivateProfileStringA, const char*, const char*, const char*, char*, std::uint32_t, const char*); +REX_W32_IMPORT(std::uint32_t, GetPrivateProfileStringW, const wchar_t*, const wchar_t*, const wchar_t*, wchar_t*, std::uint32_t, const wchar_t*); +REX_W32_IMPORT(void*, GetProcAddress, REX::W32::HMODULE, const char*); +REX_W32_IMPORT(void, GetSystemInfo, REX::W32::SYSTEM_INFO*); +REX_W32_IMPORT(REX::W32::BOOL, InitializeCriticalSectionAndSpinCount, REX::W32::CRITICAL_SECTION*, std::uint32_t); +REX_W32_IMPORT(REX::W32::BOOL, IsDebuggerPresent); +REX_W32_IMPORT(std::int32_t, LCMapStringEx, const wchar_t*, std::uint32_t, const wchar_t*, std::int32_t, wchar_t*, std::int32_t, REX::W32::NLSVERSIONINFO*, void*, std::intptr_t); +REX_W32_IMPORT(void, LeaveCriticalSection, REX::W32::CRITICAL_SECTION*); +REX_W32_IMPORT(REX::W32::HMODULE, LoadLibraryA, const char*); +REX_W32_IMPORT(REX::W32::HMODULE, LoadLibraryW, const wchar_t*); +REX_W32_IMPORT(void*, MapViewOfFile, REX::W32::HANDLE, std::uint32_t, std::uint32_t, std::uint32_t, std::size_t); +REX_W32_IMPORT(void*, MapViewOfFileEx, REX::W32::HANDLE, std::uint32_t, std::uint32_t, std::uint32_t, std::size_t, void*); +REX_W32_IMPORT(std::int32_t, MultiByteToWideChar, std::uint32_t, std::uint32_t, const char*, std::int32_t, wchar_t*, std::int32_t); +REX_W32_IMPORT(REX::W32::HANDLE, OpenFileMappingA, std::uint32_t, REX::W32::BOOL, const char*); +REX_W32_IMPORT(REX::W32::HANDLE, OpenFileMappingW, std::uint32_t, REX::W32::BOOL, const wchar_t*); +REX_W32_IMPORT(void, OutputDebugStringA, const char*); +REX_W32_IMPORT(void, OutputDebugStringW, const wchar_t*); +REX_W32_IMPORT(REX::W32::BOOL, QueryPerformanceCounter, std::int64_t*); +REX_W32_IMPORT(REX::W32::BOOL, QueryPerformanceFrequency, std::int64_t*); +REX_W32_IMPORT(std::uint32_t, ResumeThread, REX::W32::HANDLE); +REX_W32_IMPORT(REX::W32::BOOL, SetEnvironmentVariableA, const char*, const char*); +REX_W32_IMPORT(REX::W32::BOOL, SetEnvironmentVariableW, const wchar_t*, const wchar_t*); +REX_W32_IMPORT(void, Sleep, std::uint32_t); +REX_W32_IMPORT(REX::W32::BOOL, TerminateProcess, REX::W32::HANDLE, std::uint32_t); +REX_W32_IMPORT(void*, TlsGetValue, std::uint32_t); +REX_W32_IMPORT(REX::W32::BOOL, TlsSetValue, std::uint32_t, void*); +REX_W32_IMPORT(REX::W32::BOOL, UnmapViewOfFile, const void*); +REX_W32_IMPORT(void*, VirtualAlloc, void*, std::size_t, std::uint32_t, std::uint32_t); +REX_W32_IMPORT(void*, VirtualAllocEx, REX::W32::HANDLE, void*, std::size_t, std::uint32_t, std::uint32_t); +REX_W32_IMPORT(REX::W32::BOOL, VirtualFree, void*, std::size_t, std::uint32_t); +REX_W32_IMPORT(REX::W32::BOOL, VirtualFreeEx, REX::W32::HANDLE, void*, std::size_t, std::uint32_t); +REX_W32_IMPORT(REX::W32::BOOL, VirtualProtect, void*, std::size_t, std::uint32_t, std::uint32_t*); +REX_W32_IMPORT(REX::W32::BOOL, VirtualProtectEx, REX::W32::HANDLE, void*, std::size_t, std::uint32_t, std::uint32_t*); +REX_W32_IMPORT(std::size_t, VirtualQuery, const void*, MEMORY_BASIC_INFORMATION*, std::size_t); +REX_W32_IMPORT(std::size_t, VirtualQueryEx, REX::W32::HANDLE, const void*, MEMORY_BASIC_INFORMATION*, std::size_t); +REX_W32_IMPORT(std::uint32_t, WaitForSingleObject, REX::W32::HANDLE, std::uint32_t); +REX_W32_IMPORT(std::uint32_t, WaitForSingleObjectEx, REX::W32::HANDLE, std::uint32_t, REX::W32::BOOL); +REX_W32_IMPORT(std::int32_t, WideCharToMultiByte, std::uint32_t, std::uint32_t, const wchar_t*, std::int32_t, char*, std::int32_t, const char*, std::int32_t*); +REX_W32_IMPORT(REX::W32::BOOL, WriteProcessMemory, REX::W32::HANDLE, void*, const void*, std::size_t, std::size_t*); + +extern "C" REX::W32::IMAGE_DOS_HEADER __ImageBase; + +namespace REX::W32 +{ + bool CloseHandle(HANDLE a_handle) noexcept + { + return ::W32_IMPL_CloseHandle(a_handle); + } + + HANDLE CreateFileMappingA(HANDLE a_file, SECURITY_ATTRIBUTES* a_attributes, std::uint32_t a_protect, std::uint32_t a_maxSizeHigh, std::uint32_t a_maxSizeLow, const char* a_name) noexcept + { + return ::W32_IMPL_CreateFileMappingA(a_file, a_attributes, a_protect, a_maxSizeHigh, a_maxSizeLow, a_name); + } + + HANDLE CreateFileMappingW(HANDLE a_file, SECURITY_ATTRIBUTES* a_attributes, std::uint32_t a_protect, std::uint32_t a_maxSizeHigh, std::uint32_t a_maxSizeLow, const wchar_t* a_name) noexcept + { + return ::W32_IMPL_CreateFileMappingW(a_file, a_attributes, a_protect, a_maxSizeHigh, a_maxSizeLow, a_name); + } + + bool CreateProcessA(const char* a_name, char* a_cmd, SECURITY_ATTRIBUTES* a_procAttr, SECURITY_ATTRIBUTES* a_threadAttr, bool a_inheritHandles, std::uint32_t a_flags, void* a_env, const char* a_curDir, STARTUPINFOA* a_startInfo, PROCESS_INFORMATION* a_procInfo) noexcept + { + return ::W32_IMPL_CreateProcessA(a_name, a_cmd, a_procAttr, a_threadAttr, a_inheritHandles, a_flags, a_env, a_curDir, a_startInfo, a_procInfo); + } + + bool CreateProcessW(const wchar_t* a_name, wchar_t* a_cmd, SECURITY_ATTRIBUTES* a_procAttr, SECURITY_ATTRIBUTES* a_threadAttr, bool a_inheritHandles, std::uint32_t a_flags, void* a_env, const wchar_t* a_curDir, STARTUPINFOW* a_startInfo, PROCESS_INFORMATION* a_procInfo) noexcept + { + return ::W32_IMPL_CreateProcessW(a_name, a_cmd, a_procAttr, a_threadAttr, a_inheritHandles, a_flags, a_env, a_curDir, a_startInfo, a_procInfo); + } + + HANDLE CreateRemoteThread(HANDLE a_process, SECURITY_ATTRIBUTES* a_threadAttr, std::size_t a_stackSize, THREAD_START_ROUTINE* a_startAddr, void* a_param, std::uint32_t a_flags, std::uint32_t* a_threadID) noexcept + { + return ::W32_IMPL_CreateRemoteThread(a_process, a_threadAttr, a_stackSize, a_startAddr, a_param, a_flags, a_threadID); + } + + HANDLE CreateSemaphoreA(SECURITY_ATTRIBUTES* a_semaphoreAttr, std::int32_t a_initCount, std::int32_t a_maxCount, const char* a_name) + { + return ::W32_IMPL_CreateSemaphoreA(a_semaphoreAttr, a_initCount, a_maxCount, a_name); + } + + HANDLE CreateThread(SECURITY_ATTRIBUTES* a_threadAttr, std::size_t a_stackSize, THREAD_START_ROUTINE* a_startAddr, void* a_param, std::uint32_t a_flags, std::uint32_t* a_threadID) noexcept + { + return ::W32_IMPL_CreateThread(a_threadAttr, a_stackSize, a_startAddr, a_param, a_flags, a_threadID); + } + + void DeleteCriticalSection(CRITICAL_SECTION* a_criticalSection) + { + ::W32_IMPL_DeleteCriticalSection(a_criticalSection); + } + + void EnterCriticalSection(CRITICAL_SECTION* a_criticalSection) + { + ::W32_IMPL_EnterCriticalSection(a_criticalSection); + } + + std::uint32_t ExpandEnvironmentStringsA(const char* a_src, char* a_dst, std::uint32_t a_dstLen) noexcept + { + return ::W32_IMPL_ExpandEnvironmentStringsA(a_src, a_dst, a_dstLen); + } + + std::uint32_t ExpandEnvironmentStringsW(const wchar_t* a_src, wchar_t* a_dst, std::uint32_t a_dstLen) noexcept + { + return ::W32_IMPL_ExpandEnvironmentStringsW(a_src, a_dst, a_dstLen); + } + + bool FindClose(HANDLE a_file) noexcept + { + return ::W32_IMPL_FindClose(a_file); + } + + HANDLE FindFirstFileA(const char* a_name, WIN32_FIND_DATAA* a_data) noexcept + { + return ::W32_IMPL_FindFirstFileA(a_name, a_data); + } + + HANDLE FindFirstFileW(const wchar_t* a_name, WIN32_FIND_DATAW* a_data) noexcept + { + return ::W32_IMPL_FindFirstFileW(a_name, a_data); + } + + bool FindNextFileA(HANDLE a_file, WIN32_FIND_DATAA* a_data) noexcept + { + return ::W32_IMPL_FindNextFileA(a_file, a_data); + } + + bool FindNextFileW(HANDLE a_file, WIN32_FIND_DATAW* a_data) noexcept + { + return ::W32_IMPL_FindNextFileW(a_file, a_data); + } + + bool FlushInstructionCache(HANDLE a_process, const void* a_baseAddr, std::size_t a_size) noexcept + { + return ::W32_IMPL_FlushInstructionCache(a_process, a_baseAddr, a_size); + } + + bool FreeLibrary(HMODULE a_module) noexcept + { + return ::W32_IMPL_FreeLibrary(a_module); + } + + HMODULE GetCurrentModule() noexcept + { + return reinterpret_cast(std::addressof(__ImageBase)); + } + + HANDLE GetCurrentProcess() noexcept + { + return ::W32_IMPL_GetCurrentProcess(); + } + + std::uint32_t GetCurrentThreadId() noexcept + { + return ::W32_IMPL_GetCurrentThreadId(); + } + + std::uint32_t GetEnvironmentVariableA(const char* a_name, char* a_buf, std::uint32_t a_bufLen) noexcept + { + return ::W32_IMPL_GetEnvironmentVariableA(a_name, a_buf, a_bufLen); + } + + std::uint32_t GetEnvironmentVariableW(const wchar_t* a_name, wchar_t* a_buf, std::uint32_t a_bufLen) noexcept + { + return ::W32_IMPL_GetEnvironmentVariableW(a_name, a_buf, a_bufLen); + } + + std::uint32_t GetLastError() noexcept + { + return ::W32_IMPL_GetLastError(); + } + + std::uint32_t GetModuleFileNameA(HMODULE a_module, char* a_name, std::uint32_t a_nameLen) noexcept + { + return ::W32_IMPL_GetModuleFileNameA(a_module, a_name, a_nameLen); + } + + std::uint32_t GetModuleFileNameW(HMODULE a_module, wchar_t* a_name, std::uint32_t a_nameLen) noexcept + { + return ::W32_IMPL_GetModuleFileNameW(a_module, a_name, a_nameLen); + } + + HMODULE GetModuleHandleA(const char* a_name) noexcept + { + return ::W32_IMPL_GetModuleHandleA(a_name); + } + + HMODULE GetModuleHandleW(const wchar_t* a_name) noexcept + { + return ::W32_IMPL_GetModuleHandleW(a_name); + } + + std::uint32_t GetPrivateProfileStringA(const char* a_app, const char* a_key, const char* a_default, char* a_buf, std::uint32_t a_bufLen, const char* a_name) noexcept + { + return ::W32_IMPL_GetPrivateProfileStringA(a_app, a_key, a_default, a_buf, a_bufLen, a_name); + } + + std::uint32_t GetPrivateProfileStringW(const wchar_t* a_app, const wchar_t* a_key, const wchar_t* a_default, wchar_t* a_buf, std::uint32_t a_bufLen, const wchar_t* a_name) noexcept + { + return ::W32_IMPL_GetPrivateProfileStringW(a_app, a_key, a_default, a_buf, a_bufLen, a_name); + } + + void* GetProcAddress(HMODULE a_module, const char* a_name) noexcept + { + return ::W32_IMPL_GetProcAddress(a_module, a_name); + } + + void GetSystemInfo(SYSTEM_INFO* a_info) noexcept + { + return ::W32_IMPL_GetSystemInfo(a_info); + } + + bool IMAGE_SNAP_BY_ORDINAL64(std::uint64_t a_ordinal) noexcept + { + return (a_ordinal & IMAGE_ORDINAL_FLAG64) != 0; + } + + IMAGE_SECTION_HEADER* IMAGE_FIRST_SECTION(const IMAGE_NT_HEADERS64* a_header) noexcept + { + constexpr auto opt = __builtin_offsetof(IMAGE_NT_HEADERS64, optionalHeader); + const auto optSize = a_header->fileHeader.optionalHeaderSize; + const auto section = reinterpret_cast(a_header) + opt + optSize; + return reinterpret_cast(section); + } + + bool InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION* a_criticalSection, std::uint32_t a_spinCount) + { + return ::W32_IMPL_InitializeCriticalSectionAndSpinCount(a_criticalSection, a_spinCount); + } + + std::uint32_t InterlockedCompareExchange(volatile std::uint32_t* a_target, std::uint32_t a_value, std::uint32_t a_compare) noexcept + { + return _InterlockedCompareExchange((volatile long*)a_target, a_value, a_compare); + } + + std::uint64_t InterlockedCompareExchange64(volatile std::uint64_t* a_target, std::uint64_t a_value, std::uint64_t a_compare) noexcept + { + return _InterlockedCompareExchange64((volatile long long*)a_target, a_value, a_compare); + } + + std::uint32_t InterlockedDecrement(volatile std::uint32_t* a_target) noexcept + { + return _InterlockedDecrement((volatile long*)a_target); + } + + std::uint64_t InterlockedDecrement64(volatile std::uint64_t* a_target) noexcept + { + return _InterlockedDecrement64((volatile long long*)a_target); + } + + std::uint32_t InterlockedExchange(volatile std::uint32_t* a_target, std::uint32_t a_value) noexcept + { + return _InterlockedExchange((volatile long*)a_target, a_value); + } + + std::uint64_t InterlockedExchange64(volatile std::uint64_t* a_target, std::uint64_t a_value) noexcept + { + return _InterlockedExchange64((volatile long long*)a_target, a_value); + } + + std::uint32_t InterlockedIncrement(volatile std::uint32_t* a_target) noexcept + { + return _InterlockedIncrement((volatile long*)a_target); + } + + std::uint64_t InterlockedIncrement64(volatile std::uint64_t* a_target) noexcept + { + return _InterlockedIncrement64((volatile long long*)a_target); + } + + bool IsDebuggerPresent() noexcept + { + return ::W32_IMPL_IsDebuggerPresent(); + } + + std::int32_t LCMapStringEx(const wchar_t* a_locale, std::uint32_t a_flags, const wchar_t* a_src, std::int32_t a_srcLen, wchar_t* a_dst, std::int32_t a_dstLen, NLSVERSIONINFO* a_info, void* a_reserved, std::intptr_t a_sortHandle) noexcept + { + return ::W32_IMPL_LCMapStringEx(a_locale, a_flags, a_src, a_srcLen, a_dst, a_dstLen, a_info, a_reserved, a_sortHandle); + } + + void LeaveCriticalSection(CRITICAL_SECTION* a_criticalSection) + { + ::W32_IMPL_LeaveCriticalSection(a_criticalSection); + } + + HMODULE LoadLibraryA(const char* a_name) noexcept + { + return ::W32_IMPL_LoadLibraryA(a_name); + } + + HMODULE LoadLibraryW(const wchar_t* a_name) noexcept + { + return ::W32_IMPL_LoadLibraryW(a_name); + } + + void* MapViewOfFile(HANDLE a_object, std::uint32_t a_desiredAccess, std::uint32_t a_fileOffsetHi, std::uint32_t a_fileOffsetLo, std::size_t a_numBytes) noexcept + { + return ::W32_IMPL_MapViewOfFile(a_object, a_desiredAccess, a_fileOffsetHi, a_fileOffsetLo, a_numBytes); + } + + void* MapViewOfFileEx(HANDLE a_object, std::uint32_t a_desiredAccess, std::uint32_t a_fileOffsetHi, std::uint32_t a_fileOffsetLo, std::size_t a_numBytes, void* a_baseAddr) noexcept + { + return ::W32_IMPL_MapViewOfFileEx(a_object, a_desiredAccess, a_fileOffsetHi, a_fileOffsetLo, a_numBytes, a_baseAddr); + } + + std::int32_t MultiByteToWideChar(std::uint32_t a_codePage, std::uint32_t a_flags, const char* a_src, std::int32_t a_srcLen, wchar_t* a_dst, std::int32_t a_dstLen) noexcept + { + return ::W32_IMPL_MultiByteToWideChar(a_codePage, a_flags, a_src, a_srcLen, a_dst, a_dstLen); + } + + HANDLE OpenFileMappingA(std::uint32_t a_desiredAccess, bool a_inheritHandle, const char* a_name) noexcept + { + return ::W32_IMPL_OpenFileMappingA(a_desiredAccess, a_inheritHandle, a_name); + } + + HANDLE OpenFileMappingW(std::uint32_t a_desiredAccess, bool a_inheritHandle, const wchar_t* a_name) noexcept + { + return ::W32_IMPL_OpenFileMappingW(a_desiredAccess, a_inheritHandle, a_name); + } + + void OutputDebugStringA(const char* a_str) noexcept + { + ::W32_IMPL_OutputDebugStringA(a_str); + } + + void OutputDebugStringW(const wchar_t* a_str) noexcept + { + ::W32_IMPL_OutputDebugStringW(a_str); + } + + bool QueryPerformanceCounter(std::int64_t* a_counter) noexcept + { + return ::W32_IMPL_QueryPerformanceCounter(a_counter); + } + + bool QueryPerformanceFrequency(std::int64_t* a_frequency) noexcept + { + return ::W32_IMPL_QueryPerformanceFrequency(a_frequency); + } + + std::uint32_t ResumeThread(HANDLE a_handle) noexcept + { + return ::W32_IMPL_ResumeThread(a_handle); + } + + bool SetEnvironmentVariableA(const char* a_name, const char* a_value) noexcept + { + return ::W32_IMPL_SetEnvironmentVariableA(a_name, a_value); + } + + bool SetEnvironmentVariableW(const wchar_t* a_name, const wchar_t* a_value) noexcept + { + return ::W32_IMPL_SetEnvironmentVariableW(a_name, a_value); + } + + void Sleep(std::uint32_t a_milliseconds) noexcept + { + ::W32_IMPL_Sleep(a_milliseconds); + } + + bool TerminateProcess(HANDLE a_process, std::uint32_t a_exitCode) noexcept + { + return ::W32_IMPL_TerminateProcess(a_process, a_exitCode); + } + + void* TlsGetValue(std::uint32_t a_index) noexcept + { + return ::W32_IMPL_TlsGetValue(a_index); + } + + bool TlsSetValue(std::uint32_t a_index, void* a_value) noexcept + { + return ::W32_IMPL_TlsSetValue(a_index, a_value); + } + + bool UnmapViewOfFile(const void* a_baseAddress) noexcept + { + return ::W32_IMPL_UnmapViewOfFile(a_baseAddress); + } + + void* VirtualAlloc(void* a_address, std::size_t a_size, std::uint32_t a_type, std::uint32_t a_protect) noexcept + { + return ::W32_IMPL_VirtualAlloc(a_address, a_size, a_type, a_protect); + } + + void* VirtualAllocEx(HANDLE a_process, void* a_address, std::size_t a_size, std::uint32_t a_type, std::uint32_t a_protect) noexcept + { + return ::W32_IMPL_VirtualAllocEx(a_process, a_address, a_size, a_type, a_protect); + } + + bool VirtualFree(void* a_address, std::size_t a_size, std::uint32_t a_type) noexcept + { + return ::W32_IMPL_VirtualFree(a_address, a_size, a_type); + } + + bool VirtualFreeEx(HANDLE a_process, void* a_address, std::size_t a_size, std::uint32_t a_type) noexcept + { + return ::W32_IMPL_VirtualFreeEx(a_process, a_address, a_size, a_type); + } + + bool VirtualProtect(void* a_address, std::size_t a_size, std::uint32_t a_newProtect, std::uint32_t* a_oldProtect) noexcept + { + return ::W32_IMPL_VirtualProtect(a_address, a_size, a_newProtect, a_oldProtect); + } + + bool VirtualProtectEx(HANDLE a_process, void* a_address, std::size_t a_size, std::uint32_t a_newProtect, std::uint32_t* a_oldProtect) noexcept + { + return ::W32_IMPL_VirtualProtectEx(a_process, a_address, a_size, a_newProtect, a_oldProtect); + } + + std::size_t VirtualQuery(const void* a_address, MEMORY_BASIC_INFORMATION* a_buf, std::size_t a_bufLen) noexcept + { + return ::W32_IMPL_VirtualQuery(a_address, a_buf, a_bufLen); + } + + std::size_t VirtualQueryEx(HANDLE a_process, const void* a_address, MEMORY_BASIC_INFORMATION* a_buf, std::size_t a_bufLen) noexcept + { + return ::W32_IMPL_VirtualQueryEx(a_process, a_address, a_buf, a_bufLen); + } + + std::uint32_t WaitForSingleObject(HANDLE a_handle, std::uint32_t a_milliseconds) noexcept + { + return ::W32_IMPL_WaitForSingleObject(a_handle, a_milliseconds); + } + + std::uint32_t WaitForSingleObjectEx(HANDLE a_handle, std::uint32_t a_milliseconds, bool a_alertable) noexcept + { + return ::W32_IMPL_WaitForSingleObjectEx(a_handle, a_milliseconds, a_alertable); + } + + std::int32_t WideCharToMultiByte(std::uint32_t a_codePage, std::uint32_t a_flags, const wchar_t* a_src, std::int32_t a_srcLen, char* a_dst, std::int32_t a_dstLen, const char* a_default, std::int32_t* a_defaultLen) + { + return ::W32_IMPL_WideCharToMultiByte(a_codePage, a_flags, a_src, a_srcLen, a_dst, a_dstLen, a_default, a_defaultLen); + } + + bool WriteProcessMemory(HANDLE a_process, void* a_address, const void* a_buf, std::size_t a_bufLen, std::size_t* a_bufWritten) noexcept + { + return ::W32_IMPL_WriteProcessMemory(a_process, a_address, a_buf, a_bufLen, a_bufWritten); + } +} diff --git a/src/REX/W32/OLE32.cpp b/src/REX/W32/OLE32.cpp new file mode 100644 index 000000000..2e20d0b7f --- /dev/null +++ b/src/REX/W32/OLE32.cpp @@ -0,0 +1,11 @@ +#include "REX/W32/OLE32.h" + +REX_W32_IMPORT(void, CoTaskMemFree, void*); + +namespace REX::W32 +{ + void CoTaskMemFree(void* a_block) noexcept + { + ::W32_IMPL_CoTaskMemFree(a_block); + } +} diff --git a/src/REX/W32/SHELL32.cpp b/src/REX/W32/SHELL32.cpp new file mode 100644 index 000000000..fd52204e4 --- /dev/null +++ b/src/REX/W32/SHELL32.cpp @@ -0,0 +1,11 @@ +#include "REX/W32/SHELL32.h" + +REX_W32_IMPORT(std::int32_t, SHGetKnownFolderPath, const REX::W32::GUID&, std::uint32_t, void*, wchar_t**); + +namespace REX::W32 +{ + std::int32_t SHGetKnownFolderPath(const GUID& a_id, std::uint32_t a_flags, void* a_token, wchar_t** a_path) noexcept + { + return ::W32_IMPL_SHGetKnownFolderPath(a_id, a_flags, a_token, a_path); + } +} diff --git a/src/REX/W32/USER32.cpp b/src/REX/W32/USER32.cpp new file mode 100644 index 000000000..aac4229d2 --- /dev/null +++ b/src/REX/W32/USER32.cpp @@ -0,0 +1,59 @@ +#include "REX/W32/KERNEL32.h" + +REX_W32_IMPORT(REX::W32::BOOL, GetClientRect, REX::W32::HWND, REX::W32::RECT*); +REX_W32_IMPORT(std::int32_t, GetKeyNameTextA, std::int32_t, char*, std::int32_t); +REX_W32_IMPORT(std::int32_t, GetKeyNameTextW, std::int32_t, wchar_t*, std::int32_t); +REX_W32_IMPORT(std::int16_t, GetKeyState, std::int32_t); +REX_W32_IMPORT(REX::W32::BOOL, GetWindowRect, REX::W32::HWND, REX::W32::RECT*); +REX_W32_IMPORT(std::int32_t, MessageBoxA, REX::W32::HWND, const char*, const char*, std::uint32_t); +REX_W32_IMPORT(std::int32_t, MessageBoxW, REX::W32::HWND, const wchar_t*, const wchar_t*, std::uint32_t); +REX_W32_IMPORT(std::intptr_t, SetWindowLongPtrA, REX::W32::HWND, std::int32_t, std::intptr_t); +REX_W32_IMPORT(std::int32_t, ShowCursor, REX::W32::BOOL); + +namespace REX::W32 +{ + bool GetClientRect(HWND a_wnd, RECT* a_rect) noexcept + { + return ::W32_IMPL_GetClientRect(a_wnd, a_rect); + } + + std::int32_t GetKeyNameTextA(std::int32_t a_param, char* a_buf, std::int32_t a_bufLen) noexcept + { + return ::W32_IMPL_GetKeyNameTextA(a_param, a_buf, a_bufLen); + } + + std::int32_t GetKeyNameTextW(std::int32_t a_param, wchar_t* a_buf, std::int32_t a_bufLen) noexcept + { + return ::W32_IMPL_GetKeyNameTextW(a_param, a_buf, a_bufLen); + } + + std::int16_t GetKeyState(std::int32_t a_key) noexcept + { + return ::W32_IMPL_GetKeyState(a_key); + } + + bool GetWindowRect(HWND a_wnd, RECT* a_rect) noexcept + { + return ::W32_IMPL_GetWindowRect(a_wnd, a_rect); + } + + std::int32_t MessageBoxA(HWND a_wnd, const char* a_text, const char* a_caption, std::uint32_t a_type) noexcept + { + return ::W32_IMPL_MessageBoxA(a_wnd, a_text, a_caption, a_type); + } + + std::int32_t MessageBoxW(HWND a_wnd, const wchar_t* a_text, const wchar_t* a_caption, std::uint32_t a_type) noexcept + { + return ::W32_IMPL_MessageBoxW(a_wnd, a_text, a_caption, a_type); + } + + std::intptr_t SetWindowLongPtrA(HWND a_wnd, std::int32_t a_index, std::intptr_t a_newPtr) noexcept + { + return ::W32_IMPL_SetWindowLongPtrA(a_wnd, a_index, a_newPtr); + } + + std::int32_t ShowCursor(bool a_show) noexcept + { + return ::W32_IMPL_ShowCursor(a_show); + } +} diff --git a/src/REX/W32/VERSION.cpp b/src/REX/W32/VERSION.cpp new file mode 100644 index 000000000..ce249a491 --- /dev/null +++ b/src/REX/W32/VERSION.cpp @@ -0,0 +1,53 @@ +#include "REX/W32/VERSION.h" + +REX_W32_IMPORT(REX::W32::BOOL, GetFileVersionInfoA, const char*, std::uint32_t, std::uint32_t, void*); +REX_W32_IMPORT(REX::W32::BOOL, GetFileVersionInfoW, const wchar_t*, std::uint32_t, std::uint32_t, void*); +REX_W32_IMPORT(std::uint32_t, GetFileVersionInfoSizeA, const char*, std::uint32_t*); +//REX_W32_IMPORT(std::uint32_t, GetFileVersionInfoSizeExA, std::uint32_t, const char*, std::uint32_t*); +REX_W32_IMPORT(std::uint32_t, GetFileVersionInfoSizeExW, std::uint32_t, const wchar_t*, std::uint32_t*); +REX_W32_IMPORT(std::uint32_t, GetFileVersionInfoSizeW, const wchar_t*, std::uint32_t*); +REX_W32_IMPORT(REX::W32::BOOL, VerQueryValueA, const void*, const char*, void**, std::uint32_t*); +REX_W32_IMPORT(REX::W32::BOOL, VerQueryValueW, const void*, const wchar_t*, void**, std::uint32_t*); + +namespace REX::W32 +{ + bool GetFileVersionInfoA(const char* a_name, std::uint32_t a_handle, std::uint32_t a_dataLen, void* a_data) noexcept + { + return ::W32_IMPL_GetFileVersionInfoA(a_name, a_handle, a_dataLen, a_data); + } + + std::uint32_t GetFileVersionInfoSizeA(const char* a_name, std::uint32_t* a_handle) noexcept + { + return ::W32_IMPL_GetFileVersionInfoSizeA(a_name, a_handle); + } + + //std::uint32_t GetFileVersionInfoSizeExA(std::uint32_t a_flags, const char* a_name, std::uint32_t* a_handle) noexcept + //{ + // return ::W32_IMPL_GetFileVersionInfoSizeExA(a_flags, a_name, a_handle); + //} + + std::uint32_t GetFileVersionInfoSizeExW(std::uint32_t a_flags, const wchar_t* a_name, std::uint32_t* a_handle) noexcept + { + return ::W32_IMPL_GetFileVersionInfoSizeExW(a_flags, a_name, a_handle); + } + + std::uint32_t GetFileVersionInfoSizeW(const wchar_t* a_name, std::uint32_t* a_handle) noexcept + { + return ::W32_IMPL_GetFileVersionInfoSizeW(a_name, a_handle); + } + + bool GetFileVersionInfoW(const wchar_t* a_name, std::uint32_t a_handle, std::uint32_t a_dataLen, void* a_data) noexcept + { + return ::W32_IMPL_GetFileVersionInfoW(a_name, a_handle, a_dataLen, a_data); + } + + bool VerQueryValueA(const void* a_block, const char* a_subBlock, void** a_buf, std::uint32_t* a_bufLen) noexcept + { + return ::W32_IMPL_VerQueryValueA(a_block, a_subBlock, a_buf, a_bufLen); + } + + bool VerQueryValueW(const void* a_block, const wchar_t* a_subBlock, void** a_buf, std::uint32_t* a_bufLen) noexcept + { + return ::W32_IMPL_VerQueryValueW(a_block, a_subBlock, a_buf, a_bufLen); + } +} diff --git a/src/SKSE/IAT.cpp b/src/SKSE/IAT.cpp index ba879b123..9039bc5d6 100644 --- a/src/SKSE/IAT.cpp +++ b/src/SKSE/IAT.cpp @@ -2,49 +2,7 @@ #include "SKSE/Logger.h" -#define WIN32_LEAN_AND_MEAN - -#define NOGDICAPMASKS -#define NOVIRTUALKEYCODES -//#define NOWINMESSAGES -#define NOWINSTYLES -#define NOSYSMETRICS -#define NOMENUS -#define NOICONS -#define NOKEYSTATES -#define NOSYSCOMMANDS -#define NORASTEROPS -#define NOSHOWWINDOW -#define OEMRESOURCE -#define NOATOM -#define NOCLIPBOARD -#define NOCOLOR -//#define NOCTLMGR -#define NODRAWTEXT -#define NOGDI -#define NOKERNEL -//#define NOUSER -#define NONLS -//#define NOMB -#define NOMEMMGR -#define NOMETAFILE -#define NOMINMAX -//#define NOMSG -#define NOOPENFILE -#define NOSCROLL -#define NOSERVICE -#define NOSOUND -#define NOTEXTMETRIC -#define NOWH -#define NOWINOFFSETS -#define NOCOMM -#define NOKANJI -#define NOHELP -#define NOPROFILER -#define NODEFERWINDOWPOS -#define NOMCX - -#include +#include "REX/W32/KERNEL32.h" namespace SKSE { @@ -53,7 +11,7 @@ namespace SKSE return reinterpret_cast(GetIATPtr(std::move(a_dll), std::move(a_function))); } - std::uintptr_t GetIATAddr(void* a_module, std::string_view a_dll, std::string_view a_function) + std::uintptr_t GetIATAddr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function) { return reinterpret_cast(GetIATPtr(a_module, std::move(a_dll), std::move(a_function))); } @@ -64,36 +22,35 @@ namespace SKSE } // https://guidedhacking.com/attachments/pe_imptbl_headers-jpg.2241/ - void* GetIATPtr(void* a_module, std::string_view a_dll, std::string_view a_function) + void* GetIATPtr(REX::W32::HMODULE a_module, std::string_view a_dll, std::string_view a_function) { assert(a_module); - auto dosHeader = static_cast<::IMAGE_DOS_HEADER*>(a_module); - if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE) { + const auto dosHeader = reinterpret_cast(a_module); + if (dosHeader->magic != REX::W32::IMAGE_DOS_SIGNATURE) { log::error("Invalid DOS header"); return nullptr; } - auto ntHeader = stl::adjust_pointer<::IMAGE_NT_HEADERS>(dosHeader, dosHeader->e_lfanew); - auto& dataDir = ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; - auto importDesc = stl::adjust_pointer<::IMAGE_IMPORT_DESCRIPTOR>(dosHeader, dataDir.VirtualAddress); + const auto ntHeader = stl::adjust_pointer(dosHeader, dosHeader->lfanew); + const auto& dataDir = ntHeader->optionalHeader.dataDirectory[REX::W32::IMAGE_DIRECTORY_ENTRY_IMPORT]; + const auto importDesc = stl::adjust_pointer(dosHeader, dataDir.virtualAddress); - for (auto import = importDesc; import->Characteristics != 0; ++import) { - auto name = stl::adjust_pointer(dosHeader, import->Name); - if (a_dll.size() == strlen(name) && - _strnicmp(a_dll.data(), name, a_dll.size()) != 0) { + for (auto import = importDesc; import->characteristics != 0; ++import) { + auto name = stl::adjust_pointer(dosHeader, import->name); + if (a_dll.size() == strlen(name) && _strnicmp(a_dll.data(), name, a_dll.size()) != 0) { continue; } - auto thunk = stl::adjust_pointer<::IMAGE_THUNK_DATA>(dosHeader, import->OriginalFirstThunk); - for (std::size_t i = 0; thunk[i].u1.Ordinal; ++i) { - if (IMAGE_SNAP_BY_ORDINAL(thunk[i].u1.Ordinal)) { + const auto thunk = stl::adjust_pointer(dosHeader, import->firstThunkOriginal); + for (std::size_t i = 0; thunk[i].ordinal; ++i) { + if (REX::W32::IMAGE_SNAP_BY_ORDINAL64(thunk[i].ordinal)) { continue; } - auto importByName = stl::adjust_pointer(dosHeader, thunk[i].u1.AddressOfData); - if (a_function.size() == strlen(importByName->Name) && - _strnicmp(a_function.data(), importByName->Name, a_function.size()) == 0) { - return stl::adjust_pointer<::IMAGE_THUNK_DATA>(dosHeader, import->FirstThunk) + i; + const auto importByName = stl::adjust_pointer(dosHeader, thunk[i].address); + if (a_function.size() == strlen(importByName->name) && + _strnicmp(a_function.data(), importByName->name, a_function.size()) == 0) { + return stl::adjust_pointer(dosHeader, import->firstThunk) + i; } } } @@ -106,7 +63,7 @@ namespace SKSE { std::uintptr_t origAddr = 0; - auto oldFunc = GetIATAddr(a_dll, a_function); + const auto oldFunc = GetIATAddr(a_dll, a_function); if (oldFunc) { origAddr = *reinterpret_cast(oldFunc); REL::safe_write(oldFunc, a_newFunc); diff --git a/src/SKSE/Impl/WinAPI.cpp b/src/SKSE/Impl/WinAPI.cpp deleted file mode 100644 index 3a28645eb..000000000 --- a/src/SKSE/Impl/WinAPI.cpp +++ /dev/null @@ -1,1032 +0,0 @@ -#include "SKSE/Impl/WinAPI.h" - -#define WIN32_LEAN_AND_MEAN - -// clang-format off -#include -#include -#include -#include -// clang-format on - -#undef CreateFileMapping -#undef CreateProcess -#undef ExpandEnvironmentStrings -#undef FindFirstFile -#undef FindNextFile -#undef GetEnvironmentVariable -#undef GetFileVersionInfo -#undef GetFileVersionInfoSize -#undef GetKeyNameText -#undef GetModuleFileName -#undef GetModuleHandle -#undef GetPrivateProfileString -#undef IMAGE_FIRST_SECTION -#undef IMAGE_SNAP_BY_ORDINAL64 -#undef LoadLibrary -#undef MessageBox -#undef OpenFileMapping -#undef OutputDebugString -#undef RegGetValue -#undef RegQueryValueEx -#undef SetEnvironmentVariable -#undef VerQueryValue - -extern "C" IMAGE_DOS_HEADER __ImageBase; - -namespace SKSE::WinAPI -{ - bool CloseHandle( - void* a_handle) noexcept - { - return static_cast( - ::CloseHandle( - a_handle)); - } - - void CoTaskMemFree( - void* a_block) noexcept - { - ::CoTaskMemFree( - a_block); - } - - void* CreateFileMapping( - void* a_file, - SECURITY_ATTRIBUTES* a_attributes, - std::uint32_t a_protect, - std::uint32_t a_maxSizeHigh, - std::uint32_t a_maxSizeLow, - const char* a_name) noexcept - { - return CreateFileMappingA( - a_file, - reinterpret_cast(a_attributes), - a_protect, - a_maxSizeHigh, - a_maxSizeLow, - a_name); - } - - void* CreateFileMapping( - void* a_file, - SECURITY_ATTRIBUTES* a_attributes, - std::uint32_t a_protect, - std::uint32_t a_maxSizeHigh, - std::uint32_t a_maxSizeLow, - const wchar_t* a_name) noexcept - { - return CreateFileMappingW( - a_file, - reinterpret_cast(a_attributes), - a_protect, - a_maxSizeHigh, - a_maxSizeLow, - a_name); - } - - bool CreateProcess( - const char* a_name, - char* a_cmd, - SECURITY_ATTRIBUTES* a_procAttr, - SECURITY_ATTRIBUTES* a_threadAttr, - bool a_inherit, - std::uint32_t a_flags, - void* a_env, - const char* a_curDir, - STARTUPINFOA* a_startInfo, - PROCESS_INFORMATION* a_procInfo) noexcept - { - return static_cast( - CreateProcessA( - a_name, - a_cmd, - reinterpret_cast(a_procAttr), - reinterpret_cast(a_threadAttr), - a_inherit, - a_flags, - a_env, - a_curDir, - reinterpret_cast(a_startInfo), - reinterpret_cast(a_procInfo))); - } - - bool CreateProcess( - const wchar_t* a_name, - wchar_t* a_cmd, - SECURITY_ATTRIBUTES* a_procAttr, - SECURITY_ATTRIBUTES* a_threadAttr, - bool a_inherit, - std::uint32_t a_flags, - void* a_env, - const wchar_t* a_curDir, - STARTUPINFOW* a_startInfo, - PROCESS_INFORMATION* a_procInfo) noexcept - { - return static_cast( - CreateProcessW( - a_name, - a_cmd, - reinterpret_cast(a_procAttr), - reinterpret_cast(a_threadAttr), - a_inherit, - a_flags, - a_env, - a_curDir, - reinterpret_cast(a_startInfo), - reinterpret_cast(a_procInfo))); - } - - void* CreateRemoteThread( - void* a_process, - SECURITY_ATTRIBUTES* a_threadAttr, - std::size_t a_stackSize, - THREAD_START_ROUTINE* a_startAddr, - void* a_param, - std::uint32_t a_flags, - std::uint32_t* a_threadID) noexcept - { - return ::CreateRemoteThread( - a_process, - reinterpret_cast(a_threadAttr), - a_stackSize, - reinterpret_cast(a_startAddr), - a_param, - a_flags, - reinterpret_cast(a_threadID)); - } - - void* CreateThread( - SECURITY_ATTRIBUTES* a_threadAttr, - std::size_t a_stackSize, - THREAD_START_ROUTINE* a_startAddr, - void* a_param, - std::uint32_t a_flags, - std::uint32_t* a_threadID) noexcept - { - return ::CreateThread( - reinterpret_cast(a_threadAttr), - a_stackSize, - reinterpret_cast(a_startAddr), - a_param, - a_flags, - reinterpret_cast(a_threadID)); - } - - std::uint32_t ExpandEnvironmentStrings( - const char* a_src, - char* a_dst, - std::uint32_t a_dstLen) noexcept - { - return static_cast( - ExpandEnvironmentStringsA( - a_src, - a_dst, - a_dstLen)); - } - - std::uint32_t ExpandEnvironmentStrings( - const wchar_t* a_src, - wchar_t* a_dst, - std::uint32_t a_dstLen) noexcept - { - return static_cast( - ExpandEnvironmentStringsW( - a_src, - a_dst, - a_dstLen)); - } - - bool FindClose( - void* a_file) noexcept - { - return static_cast( - ::FindClose( - a_file)); - } - - void* FindFirstFile( - const char* a_name, - WIN32_FIND_DATAA* a_data) noexcept - { - return FindFirstFileA( - a_name, - reinterpret_cast(a_data)); - } - - void* FindFirstFile( - const wchar_t* a_name, - WIN32_FIND_DATAW* a_data) noexcept - { - return FindFirstFileW( - a_name, - reinterpret_cast(a_data)); - } - - bool FindNextFile( - void* a_file, - WIN32_FIND_DATAA* a_data) noexcept - { - return static_cast( - FindNextFileA( - a_file, - reinterpret_cast(a_data))); - } - - bool FindNextFile( - void* a_file, - WIN32_FIND_DATAW* a_data) noexcept - { - return static_cast( - FindNextFileW( - a_file, - reinterpret_cast(a_data))); - } - - bool FlushInstructionCache( - void* a_process, - const void* a_baseAddr, - std::size_t a_size) noexcept - { - return static_cast( - ::FlushInstructionCache( - a_process, - a_baseAddr, - a_size)); - } - - bool FreeLibrary( - HMODULE a_module) noexcept - { - return static_cast( - ::FreeLibrary( - reinterpret_cast<::HMODULE>(a_module))); - } - - void* GetCurrentModule() noexcept - { - return std::addressof(__ImageBase); - } - - void* GetCurrentProcess() noexcept - { - return ::GetCurrentProcess(); - } - - std::uint32_t GetCurrentThreadID() noexcept - { - return static_cast( - GetCurrentThreadId()); - } - - std::uint32_t GetEnvironmentVariable( - const char* a_name, - char* a_buffer, - std::uint32_t a_bufferLen) noexcept - { - return static_cast( - GetEnvironmentVariableA( - a_name, - a_buffer, - a_bufferLen)); - } - - std::uint32_t GetEnvironmentVariable( - const wchar_t* a_name, - wchar_t* a_buffer, - std::uint32_t a_bufferLen) noexcept - { - return static_cast( - GetEnvironmentVariableW( - a_name, - a_buffer, - a_bufferLen)); - } - - bool GetFileVersionInfo( - const char* a_name, - std::uint32_t a_handle, - std::uint32_t a_dataLen, - void* a_data) noexcept - { - return static_cast( - GetFileVersionInfoA( - a_name, - a_handle, - a_dataLen, - a_data)); - } - - bool GetFileVersionInfo( - const wchar_t* a_name, - std::uint32_t a_handle, - std::uint32_t a_dataLen, - void* a_data) noexcept - { - return static_cast( - GetFileVersionInfoW( - a_name, - a_handle, - a_dataLen, - a_data)); - } - - std::uint32_t GetFileVersionInfoSize( - const char* a_name, - std::uint32_t* a_handle) noexcept - { - return static_cast( - GetFileVersionInfoSizeA( - a_name, - reinterpret_cast(a_handle))); - } - - std::uint32_t GetFileVersionInfoSize( - const wchar_t* a_name, - std::uint32_t* a_handle) noexcept - { - return static_cast( - GetFileVersionInfoSizeW( - a_name, - reinterpret_cast(a_handle))); - } - - std::int32_t GetKeyNameText( - std::int32_t a_param, - wchar_t* a_buffer, - std::int32_t a_bufferLen) noexcept - { - return GetKeyNameTextW( - a_param, - a_buffer, - a_bufferLen); - } - - std::int32_t GetKeyNameText( - std::int32_t a_param, - char* a_buffer, - std::int32_t a_bufferLen) noexcept - { - return GetKeyNameTextA( - a_param, - a_buffer, - a_bufferLen); - } - - std::int16_t GetKeyState( - std::int32_t a_key) noexcept - { - return ::GetKeyState(a_key); - } - - std::uint32_t GetLastError() noexcept - { - return static_cast( - ::GetLastError()); - } - - std::size_t GetMaxPath() noexcept - { - return MAX_PATH; - } - - std::uint32_t GetModuleFileName( - void* a_module, - char* a_name, - std::uint32_t a_nameLen) noexcept - { - return static_cast( - GetModuleFileNameA( - static_cast<::HMODULE>(a_module), - a_name, - a_nameLen)); - } - - std::uint32_t GetModuleFileName( - void* a_module, - wchar_t* a_name, - std::uint32_t a_nameLen) noexcept - { - return static_cast( - GetModuleFileNameW( - static_cast<::HMODULE>(a_module), - a_name, - a_nameLen)); - } - - HMODULE GetModuleHandle( - const char* a_name) noexcept - { - return reinterpret_cast( - GetModuleHandleA( - a_name)); - } - - HMODULE GetModuleHandle( - const wchar_t* a_name) noexcept - { - return reinterpret_cast( - GetModuleHandleW(a_name)); - } - - std::uint32_t GetPrivateProfileString( - const char* a_app, - const char* a_key, - const char* a_default, - char* a_out, - std::uint32_t a_outLen, - const char* a_name) noexcept - { - return static_cast( - GetPrivateProfileStringA( - a_app, - a_key, - a_default, - a_out, - a_outLen, - a_name)); - } - - std::uint32_t GetPrivateProfileString( - const wchar_t* a_app, - const wchar_t* a_key, - const wchar_t* a_default, - wchar_t* a_out, - std::uint32_t a_outLen, - const wchar_t* a_name) noexcept - { - return static_cast( - GetPrivateProfileStringW( - a_app, - a_key, - a_default, - a_out, - a_outLen, - a_name)); - } - - void* GetProcAddress( - void* a_module, - const char* a_name) noexcept - { - return reinterpret_cast( - ::GetProcAddress( - static_cast<::HMODULE>(a_module), - a_name)); - } - - std::string_view GetProcPath( - HMODULE a_handle) noexcept - { - static std::string fileName(MAX_PATH + 1, ' '); - auto res = GetModuleFileName(a_handle, fileName.data(), MAX_PATH + 1); - if (res == 0) { - fileName = "[ProcessHost]"; - res = 13; - } - - return { fileName.c_str(), res }; - } - - void GetSystemInfo( - SYSTEM_INFO* a_info) noexcept - { - ::GetSystemInfo( - reinterpret_cast(a_info)); - } - - bool IMAGE_SNAP_BY_ORDINAL64( - std::uint64_t a_ordinal) noexcept - { - return (a_ordinal & IMAGE_ORDINAL_FLAG64) != 0; - } - - IMAGE_SECTION_HEADER* IMAGE_FIRST_SECTION( - const IMAGE_NT_HEADERS64* a_header) noexcept - { - constexpr auto opt = __builtin_offsetof(IMAGE_NT_HEADERS64, optionalHeader); - const auto optSize = a_header->fileHeader.optionalHeaderSize; - const auto section = reinterpret_cast(a_header) + opt + optSize; - return reinterpret_cast(section); - } - - bool IsDebuggerPresent() noexcept - { - return static_cast( - ::IsDebuggerPresent()); - } - - std::int32_t LCMapStringEx( - const wchar_t* a_locale, - std::uint32_t a_flags, - const wchar_t* a_src, - std::int32_t a_srcLen, - wchar_t* a_dest, - std::int32_t a_destLen, - NLSVERSIONINFO* a_info, - void* a_reserved, - std::intptr_t a_sortHandle) noexcept - { - return ::LCMapStringEx( - a_locale, - a_flags, - a_src, - a_srcLen, - a_dest, - a_destLen, - reinterpret_cast(a_info), - a_reserved, - a_sortHandle); - } - - HMODULE LoadLibrary( - const char* a_name) noexcept - { - return reinterpret_cast( - LoadLibraryA( - a_name)); - } - - HMODULE LoadLibrary( - const wchar_t* a_name) noexcept - { - return reinterpret_cast( - LoadLibraryW(a_name)); - } - - void* MapViewOfFile( - void* a_object, - std::uint32_t a_desiredAccess, - std::uint32_t a_fileOffsetHigh, - std::uint32_t a_fileOffsetLow, - std::size_t a_numBytesToMap) noexcept - { - return ::MapViewOfFile( - a_object, - a_desiredAccess, - a_fileOffsetHigh, - a_fileOffsetLow, - a_numBytesToMap); - } - - void* MapViewOfFileEx( - void* a_object, - std::uint32_t a_desiredAccess, - std::uint32_t a_fileOffsetHigh, - std::uint32_t a_fileOffsetLow, - std::size_t a_numBytesToMap, - void* a_baseAddress) noexcept - { - return ::MapViewOfFileEx( - a_object, - a_desiredAccess, - a_fileOffsetHigh, - a_fileOffsetLow, - a_numBytesToMap, - a_baseAddress); - } - - std::int32_t MessageBox( - void* a_wnd, - const char* a_text, - const char* a_caption, - std::uint32_t a_type) noexcept - { - return MessageBoxA( - static_cast<::HWND>(a_wnd), - a_text, - a_caption, - a_type); - } - - std::int32_t MessageBox( - void* a_wnd, - const wchar_t* a_text, - const wchar_t* a_caption, - std::uint32_t a_type) noexcept - { - return MessageBoxW( - static_cast<::HWND>(a_wnd), - a_text, - a_caption, - a_type); - } - - std::int32_t MultiByteToWideChar( - std::uint32_t a_codePage, - std::uint32_t a_flags, - const char* a_str, - std::int32_t a_strLen, - wchar_t* a_wstr, - std::int32_t a_wstrLen) - { - return ::MultiByteToWideChar( - a_codePage, - a_flags, - a_str, - a_strLen, - a_wstr, - a_wstrLen); - } - - std::int32_t NormalizeString( - std::int32_t a_normForm, - const wchar_t* a_src, - std::int32_t a_srcLen, - wchar_t* a_dest, - std::int32_t a_destLen) - { - return ::NormalizeString( - static_cast(a_normForm), - a_src, - a_srcLen, - a_dest, - a_destLen); - } - - void* OpenFileMapping( - std::uint32_t a_desiredAccess, - bool a_inheritHandle, - const char* a_name) noexcept - { - return OpenFileMappingA( - a_desiredAccess, - a_inheritHandle, - a_name); - } - - void* OpenFileMapping( - std::uint32_t a_desiredAccess, - bool a_inheritHandle, - const wchar_t* a_name) noexcept - { - return OpenFileMappingW( - a_desiredAccess, - a_inheritHandle, - a_name); - } - - void OutputDebugString( - const char* a_out) noexcept - { - OutputDebugStringA( - a_out); - } - - void OutputDebugString( - const wchar_t* a_out) noexcept - { - OutputDebugStringW( - a_out); - } - - std::int32_t RegGetValue( - HKEY a_key, - const char* a_subKey, - const char* a_value, - std::uint32_t a_flags, - std::uint32_t* a_type, - void* a_data, - std::uint32_t* a_dataLen) - { - return RegGetValueA( - reinterpret_cast<::HKEY>(a_key), - a_subKey, - a_value, - a_flags, - reinterpret_cast(a_type), - a_data, - reinterpret_cast(a_dataLen)); - } - - std::int32_t RegGetValue( - HKEY a_key, - const wchar_t* a_subKey, - const wchar_t* a_value, - std::uint32_t a_flags, - std::uint32_t* a_type, - void* a_data, - std::uint32_t* a_dataLen) - { - return RegGetValueW( - reinterpret_cast<::HKEY>(a_key), - a_subKey, - a_value, - a_flags, - reinterpret_cast(a_type), - a_data, - reinterpret_cast(a_dataLen)); - } - - std::uint32_t ResumeThread( - void* a_handle) noexcept - { - return static_cast( - ::ResumeThread( - a_handle)); - } - - bool SetEnvironmentVariable( - const char* a_name, - const char* a_value) noexcept - { - return static_cast( - SetEnvironmentVariableA( - a_name, - a_value)); - } - - bool SetEnvironmentVariable( - const wchar_t* a_name, - const wchar_t* a_value) noexcept - { - return static_cast( - SetEnvironmentVariableW( - a_name, - a_value)); - } - - std::int32_t SHGetKnownFolderPath( - const GUID& a_id, - std::uint32_t a_flags, - void* a_token, - wchar_t** a_path) noexcept - { - return static_cast( - ::SHGetKnownFolderPath( - reinterpret_cast(a_id), - a_flags, - a_token, - a_path)); - } - - std::int32_t ShowCursor( - bool a_show) noexcept - { - return ::ShowCursor( - a_show); - } - - void Sleep( - std::uint32_t a_milliseconds) noexcept - { - ::Sleep(a_milliseconds); - } - - bool TerminateProcess( - void* a_process, - std::uint32_t a_exitCode) noexcept - { - return static_cast( - ::TerminateProcess( - a_process, - a_exitCode)); - } - - void* TlsGetValue( - std::uint32_t a_index) noexcept - { - return ::TlsGetValue( - a_index); - } - - bool TlsSetValue( - std::uint32_t a_index, - void* a_value) noexcept - { - return static_cast( - ::TlsSetValue( - a_index, - a_value)); - } - - std::uint32_t UnDecorateSymbolName( - const char* a_name, - char* a_out, - std::uint32_t a_outLenMax, - std::uint32_t a_flags) noexcept - { - return static_cast( - ::UnDecorateSymbolName( - a_name, - a_out, - a_outLenMax, - a_flags)); - } - - std::uint32_t UnDecorateSymbolName( - const wchar_t* a_name, - wchar_t* a_out, - std::uint32_t a_outLenMax, - std::uint32_t a_flags) noexcept - { - return static_cast( - UnDecorateSymbolNameW( - a_name, - a_out, - a_outLenMax, - a_flags)); - } - - bool UnmapViewOfFile( - const void* a_baseAddress) noexcept - { - return static_cast( - ::UnmapViewOfFile( - a_baseAddress)); - } - - bool VerQueryValue( - const void* a_block, - const char* a_subBlock, - void** a_buffer, - std::uint32_t* a_bufferLen) noexcept - { - return static_cast( - VerQueryValueA(a_block, - a_subBlock, - a_buffer, - a_bufferLen)); - } - - bool VerQueryValue( - const void* a_block, - const wchar_t* a_subBlock, - void** a_buffer, - std::uint32_t* a_bufferLen) noexcept - { - return static_cast( - VerQueryValueW( - a_block, - a_subBlock, - a_buffer, - a_bufferLen)); - } - - void* VirtualAlloc( - void* a_address, - std::size_t a_size, - std::uint32_t a_type, - std::uint32_t a_protect) noexcept - { - return ::VirtualAlloc( - a_address, - a_size, - a_type, - a_protect); - } - - void* VirtualAllocEx( - void* a_process, - void* a_address, - std::size_t a_size, - std::uint32_t a_type, - std::uint32_t a_protect) noexcept - { - return ::VirtualAllocEx( - a_process, - a_address, - a_size, - a_type, - a_protect); - } - - bool VirtualFree( - void* a_address, - std::size_t a_size, - std::uint32_t a_type) noexcept - { - return static_cast( - ::VirtualFree( - a_address, - a_size, - a_type)); - } - - bool VirtualFreeEx( - void* a_process, - void* a_address, - std::size_t a_size, - std::uint32_t a_type) noexcept - { - return static_cast( - ::VirtualFreeEx( - a_process, - a_address, - a_size, - a_type)); - } - - bool VirtualProtect( - void* a_address, - std::size_t a_size, - std::uint32_t a_newProtect, - std::uint32_t* a_oldProtect) noexcept - { - return static_cast( - ::VirtualProtect( - a_address, - a_size, - a_newProtect, - reinterpret_cast(a_oldProtect))); - } - - bool VirtualProtectEx( - void* a_process, - void* a_address, - std::size_t a_size, - std::uint32_t a_newProtect, - std::uint32_t* a_oldProtect) noexcept - { - return static_cast( - ::VirtualProtectEx( - a_process, - a_address, - a_size, - a_newProtect, - reinterpret_cast(a_oldProtect))); - } - - std::size_t VirtualQuery( - const void* a_address, - MEMORY_BASIC_INFORMATION* a_buffer, - std::size_t a_bufferLen) noexcept - { - return ::VirtualQuery( - a_address, - reinterpret_cast(a_buffer), - a_bufferLen); - } - - std::size_t VirtualQueryEx( - void* a_process, - const void* a_address, - MEMORY_BASIC_INFORMATION* a_buffer, - std::size_t a_bufferLen) noexcept - { - return ::VirtualQueryEx( - a_process, - a_address, - reinterpret_cast(a_buffer), - a_bufferLen); - } - - std::uint32_t WaitForSingleObject( - void* a_handle, - std::uint32_t a_milliseconds) noexcept - { - return static_cast( - ::WaitForSingleObject( - a_handle, - a_milliseconds)); - } - - std::uint32_t WaitForSingleObjectEx( - void* a_handle, - std::uint32_t a_milliseconds, - bool a_alertable) noexcept - { - return static_cast( - ::WaitForSingleObjectEx( - a_handle, - a_milliseconds, - a_alertable)); - } - - std::int32_t WideCharToMultiByte( - std::uint32_t a_codePage, - std::uint32_t a_flags, - const wchar_t* a_wstr, - std::int32_t a_wstrLen, - char* a_str, - std::int32_t a_strLen, - const char* a_default, - std::int32_t* a_defaultLen) - { - return ::WideCharToMultiByte( - a_codePage, - a_flags, - a_wstr, - a_wstrLen, - a_str, - a_strLen, - a_default, - a_defaultLen); - } - - bool WriteProcessMemory( - void* a_process, - void* a_address, - const void* a_buffer, - std::size_t a_bufferLen, - std::size_t* a_bufferWritten) noexcept - { - return static_cast( - ::WriteProcessMemory( - a_process, - a_address, - a_buffer, - a_bufferLen, - a_bufferWritten)); - } -} diff --git a/src/SKSE/InputMap.cpp b/src/SKSE/InputMap.cpp index 02c223715..0ce8af9f7 100644 --- a/src/SKSE/InputMap.cpp +++ b/src/SKSE/InputMap.cpp @@ -1,45 +1,45 @@ #include "SKSE/InputMap.h" #include "RE/C/ControlMap.h" -#include "SKSE/Impl/ScePadAPI.h" -#include "SKSE/Impl/XInputAPI.h" + +#include "REX/PS4/SCEPAD.h" +#include "REX/W32/DINPUT.h" +#include "REX/W32/USER32.h" +#include "REX/W32/XINPUT.h" namespace SKSE { - using XInputButton = RE::XInput::XInputButton; - using ScePadButton = RE::ScePad::ScePadButton; - std::uint32_t InputMap::XInputToScePadOffset(std::uint32_t keyMask) { switch (keyMask) { - case XInputButton::XINPUT_GAMEPAD_DPAD_UP: - return ScePadButton::SCE_PAD_BUTTON_UP; - case XInputButton::XINPUT_GAMEPAD_DPAD_DOWN: - return ScePadButton::SCE_PAD_BUTTON_DOWN; - case XInputButton::XINPUT_GAMEPAD_DPAD_LEFT: - return ScePadButton::SCE_PAD_BUTTON_LEFT; - case XInputButton::XINPUT_GAMEPAD_DPAD_RIGHT: - return ScePadButton::SCE_PAD_BUTTON_RIGHT; - case XInputButton::XINPUT_GAMEPAD_START: - return ScePadButton::SCE_PAD_BUTTON_OPTIONS; - case XInputButton::XINPUT_GAMEPAD_BACK: - return ScePadButton::SCE_PAD_BUTTON_TOUCH_PAD; - case XInputButton::XINPUT_GAMEPAD_LEFT_THUMB: - return ScePadButton::SCE_PAD_BUTTON_L3; - case XInputButton::XINPUT_GAMEPAD_RIGHT_THUMB: - return ScePadButton::SCE_PAD_BUTTON_R3; - case XInputButton::XINPUT_GAMEPAD_LEFT_SHOULDER: - return ScePadButton::SCE_PAD_BUTTON_L1; - case XInputButton::XINPUT_GAMEPAD_RIGHT_SHOULDER: - return ScePadButton::SCE_PAD_BUTTON_R1; - case XInputButton::XINPUT_GAMEPAD_A: - return ScePadButton::SCE_PAD_BUTTON_CROSS; - case XInputButton::XINPUT_GAMEPAD_B: - return ScePadButton::SCE_PAD_BUTTON_CIRCLE; - case XInputButton::XINPUT_GAMEPAD_X: - return ScePadButton::SCE_PAD_BUTTON_SQUARE; - case XInputButton::XINPUT_GAMEPAD_Y: - return ScePadButton::SCE_PAD_BUTTON_TRIANGLE; + case REX::W32::XINPUT_GAMEPAD_DPAD_UP: + return REX::PS4::SCE_PAD_BUTTON_UP; + case REX::W32::XINPUT_GAMEPAD_DPAD_DOWN: + return REX::PS4::SCE_PAD_BUTTON_DOWN; + case REX::W32::XINPUT_GAMEPAD_DPAD_LEFT: + return REX::PS4::SCE_PAD_BUTTON_LEFT; + case REX::W32::XINPUT_GAMEPAD_DPAD_RIGHT: + return REX::PS4::SCE_PAD_BUTTON_RIGHT; + case REX::W32::XINPUT_GAMEPAD_START: + return REX::PS4::SCE_PAD_BUTTON_OPTIONS; + case REX::W32::XINPUT_GAMEPAD_BACK: + return REX::PS4::SCE_PAD_BUTTON_TOUCH_PAD; + case REX::W32::XINPUT_GAMEPAD_LEFT_THUMB: + return REX::PS4::SCE_PAD_BUTTON_L3; + case REX::W32::XINPUT_GAMEPAD_RIGHT_THUMB: + return REX::PS4::SCE_PAD_BUTTON_R3; + case REX::W32::XINPUT_GAMEPAD_LEFT_SHOULDER: + return REX::PS4::SCE_PAD_BUTTON_L1; + case REX::W32::XINPUT_GAMEPAD_RIGHT_SHOULDER: + return REX::PS4::SCE_PAD_BUTTON_R1; + case REX::W32::XINPUT_GAMEPAD_A: + return REX::PS4::SCE_PAD_BUTTON_CROSS; + case REX::W32::XINPUT_GAMEPAD_B: + return REX::PS4::SCE_PAD_BUTTON_CIRCLE; + case REX::W32::XINPUT_GAMEPAD_X: + return REX::PS4::SCE_PAD_BUTTON_SQUARE; + case REX::W32::XINPUT_GAMEPAD_Y: + return REX::PS4::SCE_PAD_BUTTON_TRIANGLE; default: return keyMask; } @@ -48,34 +48,34 @@ namespace SKSE std::uint32_t InputMap::ScePadOffsetToXInput(std::uint32_t keyMask) { switch (keyMask) { - case ScePadButton::SCE_PAD_BUTTON_UP: - return XInputButton::XINPUT_GAMEPAD_DPAD_UP; - case ScePadButton::SCE_PAD_BUTTON_DOWN: - return XInputButton::XINPUT_GAMEPAD_DPAD_DOWN; - case ScePadButton::SCE_PAD_BUTTON_LEFT: - return XInputButton::XINPUT_GAMEPAD_DPAD_LEFT; - case ScePadButton::SCE_PAD_BUTTON_RIGHT: - return XInputButton::XINPUT_GAMEPAD_DPAD_RIGHT; - case ScePadButton::SCE_PAD_BUTTON_OPTIONS: - return XInputButton::XINPUT_GAMEPAD_START; - case ScePadButton::SCE_PAD_BUTTON_TOUCH_PAD: - return XInputButton::XINPUT_GAMEPAD_BACK; - case ScePadButton::SCE_PAD_BUTTON_L3: - return XInputButton::XINPUT_GAMEPAD_LEFT_THUMB; - case ScePadButton::SCE_PAD_BUTTON_R3: - return XInputButton::XINPUT_GAMEPAD_RIGHT_THUMB; - case ScePadButton::SCE_PAD_BUTTON_L1: - return XInputButton::XINPUT_GAMEPAD_LEFT_SHOULDER; - case ScePadButton::SCE_PAD_BUTTON_R1: - return XInputButton::XINPUT_GAMEPAD_RIGHT_SHOULDER; - case ScePadButton::SCE_PAD_BUTTON_CROSS: - return XInputButton::XINPUT_GAMEPAD_A; - case ScePadButton::SCE_PAD_BUTTON_CIRCLE: - return XInputButton::XINPUT_GAMEPAD_B; - case ScePadButton::SCE_PAD_BUTTON_SQUARE: - return XInputButton::XINPUT_GAMEPAD_X; - case ScePadButton::SCE_PAD_BUTTON_TRIANGLE: - return XInputButton::XINPUT_GAMEPAD_Y; + case REX::PS4::SCE_PAD_BUTTON_UP: + return REX::W32::XINPUT_GAMEPAD_DPAD_UP; + case REX::PS4::SCE_PAD_BUTTON_DOWN: + return REX::W32::XINPUT_GAMEPAD_DPAD_DOWN; + case REX::PS4::SCE_PAD_BUTTON_LEFT: + return REX::W32::XINPUT_GAMEPAD_DPAD_LEFT; + case REX::PS4::SCE_PAD_BUTTON_RIGHT: + return REX::W32::XINPUT_GAMEPAD_DPAD_RIGHT; + case REX::PS4::SCE_PAD_BUTTON_OPTIONS: + return REX::W32::XINPUT_GAMEPAD_START; + case REX::PS4::SCE_PAD_BUTTON_TOUCH_PAD: + return REX::W32::XINPUT_GAMEPAD_BACK; + case REX::PS4::SCE_PAD_BUTTON_L3: + return REX::W32::XINPUT_GAMEPAD_LEFT_THUMB; + case REX::PS4::SCE_PAD_BUTTON_R3: + return REX::W32::XINPUT_GAMEPAD_RIGHT_THUMB; + case REX::PS4::SCE_PAD_BUTTON_L1: + return REX::W32::XINPUT_GAMEPAD_LEFT_SHOULDER; + case REX::PS4::SCE_PAD_BUTTON_R1: + return REX::W32::XINPUT_GAMEPAD_RIGHT_SHOULDER; + case REX::PS4::SCE_PAD_BUTTON_CROSS: + return REX::W32::XINPUT_GAMEPAD_A; + case REX::PS4::SCE_PAD_BUTTON_CIRCLE: + return REX::W32::XINPUT_GAMEPAD_B; + case REX::PS4::SCE_PAD_BUTTON_SQUARE: + return REX::W32::XINPUT_GAMEPAD_X; + case REX::PS4::SCE_PAD_BUTTON_TRIANGLE: + return REX::W32::XINPUT_GAMEPAD_Y; default: return keyMask; } @@ -88,33 +88,33 @@ namespace SKSE } switch (keyMask) { - case XInputButton::XINPUT_GAMEPAD_DPAD_UP: + case REX::W32::XINPUT_GAMEPAD_DPAD_UP: return kGamepadButtonOffset_DPAD_UP; - case XInputButton::XINPUT_GAMEPAD_DPAD_DOWN: + case REX::W32::XINPUT_GAMEPAD_DPAD_DOWN: return kGamepadButtonOffset_DPAD_DOWN; - case XInputButton::XINPUT_GAMEPAD_DPAD_LEFT: + case REX::W32::XINPUT_GAMEPAD_DPAD_LEFT: return kGamepadButtonOffset_DPAD_LEFT; - case XInputButton::XINPUT_GAMEPAD_DPAD_RIGHT: + case REX::W32::XINPUT_GAMEPAD_DPAD_RIGHT: return kGamepadButtonOffset_DPAD_RIGHT; - case XInputButton::XINPUT_GAMEPAD_START: + case REX::W32::XINPUT_GAMEPAD_START: return kGamepadButtonOffset_START; - case XInputButton::XINPUT_GAMEPAD_BACK: + case REX::W32::XINPUT_GAMEPAD_BACK: return kGamepadButtonOffset_BACK; - case XInputButton::XINPUT_GAMEPAD_LEFT_THUMB: + case REX::W32::XINPUT_GAMEPAD_LEFT_THUMB: return kGamepadButtonOffset_LEFT_THUMB; - case XInputButton::XINPUT_GAMEPAD_RIGHT_THUMB: + case REX::W32::XINPUT_GAMEPAD_RIGHT_THUMB: return kGamepadButtonOffset_RIGHT_THUMB; - case XInputButton::XINPUT_GAMEPAD_LEFT_SHOULDER: + case REX::W32::XINPUT_GAMEPAD_LEFT_SHOULDER: return kGamepadButtonOffset_LEFT_SHOULDER; - case XInputButton::XINPUT_GAMEPAD_RIGHT_SHOULDER: + case REX::W32::XINPUT_GAMEPAD_RIGHT_SHOULDER: return kGamepadButtonOffset_RIGHT_SHOULDER; - case XInputButton::XINPUT_GAMEPAD_A: + case REX::W32::XINPUT_GAMEPAD_A: return kGamepadButtonOffset_A; - case XInputButton::XINPUT_GAMEPAD_B: + case REX::W32::XINPUT_GAMEPAD_B: return kGamepadButtonOffset_B; - case XInputButton::XINPUT_GAMEPAD_X: + case REX::W32::XINPUT_GAMEPAD_X: return kGamepadButtonOffset_X; - case XInputButton::XINPUT_GAMEPAD_Y: + case REX::W32::XINPUT_GAMEPAD_Y: return kGamepadButtonOffset_Y; case 0x9: // Left Trigger game-defined ID return kGamepadButtonOffset_LT; @@ -131,46 +131,46 @@ namespace SKSE switch (keyCode) { case kGamepadButtonOffset_DPAD_UP: - keyMask = XInputButton::XINPUT_GAMEPAD_DPAD_UP; + keyMask = REX::W32::XINPUT_GAMEPAD_DPAD_UP; break; case kGamepadButtonOffset_DPAD_DOWN: - keyMask = XInputButton::XINPUT_GAMEPAD_DPAD_DOWN; + keyMask = REX::W32::XINPUT_GAMEPAD_DPAD_DOWN; break; case kGamepadButtonOffset_DPAD_LEFT: - keyMask = XInputButton::XINPUT_GAMEPAD_DPAD_LEFT; + keyMask = REX::W32::XINPUT_GAMEPAD_DPAD_LEFT; break; case kGamepadButtonOffset_DPAD_RIGHT: - keyMask = XInputButton::XINPUT_GAMEPAD_DPAD_RIGHT; + keyMask = REX::W32::XINPUT_GAMEPAD_DPAD_RIGHT; break; case kGamepadButtonOffset_START: - keyMask = XInputButton::XINPUT_GAMEPAD_START; + keyMask = REX::W32::XINPUT_GAMEPAD_START; break; case kGamepadButtonOffset_BACK: - keyMask = XInputButton::XINPUT_GAMEPAD_BACK; + keyMask = REX::W32::XINPUT_GAMEPAD_BACK; break; case kGamepadButtonOffset_LEFT_THUMB: - keyMask = XInputButton::XINPUT_GAMEPAD_LEFT_THUMB; + keyMask = REX::W32::XINPUT_GAMEPAD_LEFT_THUMB; break; case kGamepadButtonOffset_RIGHT_THUMB: - keyMask = XInputButton::XINPUT_GAMEPAD_RIGHT_THUMB; + keyMask = REX::W32::XINPUT_GAMEPAD_RIGHT_THUMB; break; case kGamepadButtonOffset_LEFT_SHOULDER: - keyMask = XInputButton::XINPUT_GAMEPAD_LEFT_SHOULDER; + keyMask = REX::W32::XINPUT_GAMEPAD_LEFT_SHOULDER; break; case kGamepadButtonOffset_RIGHT_SHOULDER: - keyMask = XInputButton::XINPUT_GAMEPAD_RIGHT_SHOULDER; + keyMask = REX::W32::XINPUT_GAMEPAD_RIGHT_SHOULDER; break; case kGamepadButtonOffset_A: - keyMask = XInputButton::XINPUT_GAMEPAD_A; + keyMask = REX::W32::XINPUT_GAMEPAD_A; break; case kGamepadButtonOffset_B: - keyMask = XInputButton::XINPUT_GAMEPAD_B; + keyMask = REX::W32::XINPUT_GAMEPAD_B; break; case kGamepadButtonOffset_X: - keyMask = XInputButton::XINPUT_GAMEPAD_X; + keyMask = REX::W32::XINPUT_GAMEPAD_X; break; case kGamepadButtonOffset_Y: - keyMask = XInputButton::XINPUT_GAMEPAD_Y; + keyMask = REX::W32::XINPUT_GAMEPAD_Y; break; case kGamepadButtonOffset_LT: keyMask = 0x9; // Left Trigger game-defined ID @@ -205,49 +205,47 @@ namespace SKSE { std::int32_t scancode = static_cast(a_keyCode & 0xFF); - using DIKey = RE::DirectInput8::DIKey; - switch (scancode) { - case DIKey::DIK_NUMPADENTER: // Numpad Enter + case REX::W32::DIK_NUMPADENTER: // Numpad Enter scancode = 0x11C; break; - case DIKey::DIK_RCONTROL: // Right Control + case REX::W32::DIK_RCONTROL: // Right Control scancode = 0x11D; break; - case DIKey::DIK_DIVIDE: // Numpad / + case REX::W32::DIK_DIVIDE: // Numpad / scancode = 0x135; break; - case DIKey::DIK_RALT: // Right Alt + case REX::W32::DIK_RALT: // Right Alt scancode = 0x138; break; - case DIKey::DIK_HOME: // Home + case REX::W32::DIK_HOME: // Home scancode = 0x147; break; - case DIKey::DIK_UPARROW: // Up Arrow + case REX::W32::DIK_UPARROW: // Up Arrow scancode = 0x148; break; - case DIKey::DIK_PGUP: // Page Up + case REX::W32::DIK_PGUP: // Page Up scancode = 0x149; break; - case DIKey::DIK_LEFTARROW: // Left Arrow + case REX::W32::DIK_LEFTARROW: // Left Arrow scancode = 0x14B; break; - case DIKey::DIK_RIGHTARROW: // Right Arrow + case REX::W32::DIK_RIGHTARROW: // Right Arrow scancode = 0x14D; break; - case DIKey::DIK_END: // End + case REX::W32::DIK_END: // End scancode = 0x14F; break; - case DIKey::DIK_DOWNARROW: // Down Arrow + case REX::W32::DIK_DOWNARROW: // Down Arrow scancode = 0x150; break; - case DIKey::DIK_PGDN: // Page Down + case REX::W32::DIK_PGDN: // Page Down scancode = 0x151; break; - case DIKey::DIK_INSERT: // Insert + case REX::W32::DIK_INSERT: // Insert scancode = 0x152; break; - case DIKey::DIK_DELETE: // Delete + case REX::W32::DIK_DELETE: // Delete scancode = 0x153; break; } @@ -258,8 +256,8 @@ namespace SKSE lParam |= (0x1 << 24); } - wchar_t buffer[WinAPI::MAX_PATH]; - auto length = WinAPI::GetKeyNameText(lParam, buffer, WinAPI::MAX_PATH); + wchar_t buffer[REX::W32::MAX_PATH]; + auto length = REX::W32::GetKeyNameTextW(lParam, buffer, REX::W32::MAX_PATH); std::wstring keyNameW{ buffer, static_cast(length) }; return stl::utf16_to_utf8(keyNameW).value_or(""s); diff --git a/src/SKSE/Logger.cpp b/src/SKSE/Logger.cpp index c212b95d6..0da3d86b9 100644 --- a/src/SKSE/Logger.cpp +++ b/src/SKSE/Logger.cpp @@ -1,9 +1,11 @@ #include "SKSE/Logger.h" #include "RE/V/VirtualMachine.h" + #include "SKSE/API.h" -#include +#include "REX/W32/OLE32.h" +#include "REX/W32/SHELL32.h" namespace SKSE { @@ -63,10 +65,10 @@ namespace SKSE { std::optional log_directory() { - wchar_t* buffer{ nullptr }; - const auto result = ::SHGetKnownFolderPath(::FOLDERID_Documents, ::KNOWN_FOLDER_FLAG::KF_FLAG_DEFAULT, nullptr, std::addressof(buffer)); - std::unique_ptr knownPath(buffer, ::CoTaskMemFree); - if (!knownPath || result != S_OK) { + wchar_t* buffer{ nullptr }; + const auto result = REX::W32::SHGetKnownFolderPath(REX::W32::FOLDERID_Documents, REX::W32::KF_FLAG_DEFAULT, nullptr, std::addressof(buffer)); + std::unique_ptr knownPath(buffer, REX::W32::CoTaskMemFree); + if (!knownPath || result != 0) { error("failed to get known folder path"sv); return std::nullopt; } diff --git a/src/SKSE/Trampoline.cpp b/src/SKSE/Trampoline.cpp index 1de3f6be0..f310d3c26 100644 --- a/src/SKSE/Trampoline.cpp +++ b/src/SKSE/Trampoline.cpp @@ -2,52 +2,16 @@ #include "SKSE/Logger.h" -#define WIN32_LEAN_AND_MEAN - -#define NOGDICAPMASKS -#define NOVIRTUALKEYCODES -//#define NOWINMESSAGES -#define NOWINSTYLES -#define NOSYSMETRICS -#define NOMENUS -#define NOICONS -#define NOKEYSTATES -#define NOSYSCOMMANDS -#define NORASTEROPS -#define NOSHOWWINDOW -#define OEMRESOURCE -#define NOATOM -#define NOCLIPBOARD -#define NOCOLOR -//#define NOCTLMGR -#define NODRAWTEXT -#define NOGDI -#define NOKERNEL -//#define NOUSER -#define NONLS -//#define NOMB -#define NOMEMMGR -#define NOMETAFILE -#define NOMINMAX -//#define NOMSG -#define NOOPENFILE -#define NOSCROLL -#define NOSERVICE -#define NOSOUND -#define NOTEXTMETRIC -#define NOWH -#define NOWINOFFSETS -#define NOCOMM -#define NOKANJI -#define NOHELP -#define NOPROFILER -#define NODEFERWINDOWPOS -#define NOMCX - -#include +#include "REX/W32/KERNEL32.h" +// xbyak brings in #ifdef SKSE_SUPPORT_XBYAK # include +# undef max +# undef MEM_COMMIT +# undef MEM_FREE +# undef MEM_RESERVE +# undef PAGE_EXECUTE_READWRITE #endif namespace SKSE @@ -69,36 +33,34 @@ namespace SKSE constexpr std::size_t minRange = gigabyte * 2; constexpr std::uintptr_t maxAddr = std::numeric_limits::max(); - ::DWORD granularity; - ::SYSTEM_INFO si; - ::GetSystemInfo(&si); - granularity = si.dwAllocationGranularity; + REX::W32::SYSTEM_INFO si; + REX::W32::GetSystemInfo(&si); + const std::uint32_t granularity = si.allocationGranularity; std::uintptr_t min = a_address >= minRange ? detail::roundup(a_address - minRange, granularity) : 0; const std::uintptr_t max = a_address < (maxAddr - minRange) ? detail::rounddown(a_address + minRange, granularity) : maxAddr; - std::uintptr_t addr; - ::MEMORY_BASIC_INFORMATION mbi; + REX::W32::MEMORY_BASIC_INFORMATION mbi; do { - if (!::VirtualQuery(reinterpret_cast(min), std::addressof(mbi), sizeof(mbi))) { - log::error("VirtualQuery failed with code: 0x{:08X}"sv, ::GetLastError()); + if (!REX::W32::VirtualQuery(reinterpret_cast(min), std::addressof(mbi), sizeof(mbi))) { + log::error("VirtualQuery failed with code: 0x{:08X}"sv, REX::W32::GetLastError()); return nullptr; } - auto baseAddr = reinterpret_cast(mbi.BaseAddress); - min = baseAddr + mbi.RegionSize; + const auto baseAddr = reinterpret_cast(mbi.baseAddress); + min = baseAddr + mbi.regionSize; - if (mbi.State == MEM_FREE) { - addr = detail::roundup(baseAddr, granularity); + if (mbi.state == REX::W32::MEM_FREE) { + const std::uintptr_t addr = detail::roundup(baseAddr, granularity); // if rounding didn't advance us into the next region and the region is the required size if (addr < min && (min - addr) >= a_size) { - auto mem = ::VirtualAlloc(reinterpret_cast(addr), a_size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); + const auto mem = REX::W32::VirtualAlloc( + reinterpret_cast(addr), a_size,REX::W32::MEM_COMMIT | REX::W32::MEM_RESERVE, REX::W32::PAGE_EXECUTE_READWRITE); if (mem) { return mem; - } else { - log::warn("VirtualAlloc failed with code: 0x{:08X}"sv, ::GetLastError()); } + log::warn("VirtualAlloc failed with code: 0x{:08X}"sv, REX::W32::GetLastError()); } } } while (min < max); @@ -108,9 +70,7 @@ namespace SKSE void Trampoline::log_stats() const { - auto pct = (static_cast(_size) / - static_cast(_capacity)) * - 100.0; + const auto pct = (static_cast(_size) / static_cast(_capacity)) * 100.0; log::debug("{} => {}B / {}B ({:05.2f}%)"sv, _name, _size, _capacity, pct); } }