Proper reference counting
Update to VS2019 Added IDirect3DVertexBuffer9 but not used (strange crash)
This commit is contained in:
parent
8088b424ef
commit
dbc6ff9390
|
@ -6,14 +6,16 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "NonCopyable.h"
|
|
||||||
#include "StringUtil.h"
|
#include "StringUtil.h"
|
||||||
#include "WinUtil.h"
|
#include "WinUtil.h"
|
||||||
|
|
||||||
#ifndef LOGGER_DISABLE
|
#ifndef LOGGER_DISABLE
|
||||||
class Logger : NonCopyable
|
class Logger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Logger(const Logger&) = delete;
|
||||||
|
const Logger& operator=(Logger& other) = delete;
|
||||||
|
|
||||||
Logger() : m_systime(), m_console(INVALID_HANDLE_VALUE), m_file(INVALID_HANDLE_VALUE) {}
|
Logger() : m_systime(), m_console(INVALID_HANDLE_VALUE), m_file(INVALID_HANDLE_VALUE) {}
|
||||||
|
|
||||||
Logger::~Logger()
|
Logger::~Logger()
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// An inheritable class to disallow the copy constructor and operator= functions
|
|
||||||
class NonCopyable
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
NonCopyable() {}
|
|
||||||
~NonCopyable() {}
|
|
||||||
private:
|
|
||||||
NonCopyable( const NonCopyable& );
|
|
||||||
const NonCopyable& operator=( NonCopyable& other );
|
|
||||||
};
|
|
|
@ -22,30 +22,30 @@
|
||||||
<ProjectGuid>{F142A341-5EE0-442D-A15F-98AE9B48DBAE}</ProjectGuid>
|
<ProjectGuid>{F142A341-5EE0-442D-A15F-98AE9B48DBAE}</ProjectGuid>
|
||||||
<RootNamespace>libMinHook</RootNamespace>
|
<RootNamespace>libMinHook</RootNamespace>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
@ -83,12 +83,8 @@
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<DebugInformationFormat>None</DebugInformationFormat>
|
<DebugInformationFormat>None</DebugInformationFormat>
|
||||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Lib />
|
<Lib />
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -122,6 +118,7 @@
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Lib />
|
<Lib />
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 15.0.27130.2036
|
VisualStudioVersion = 16.0.29215.179
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OneTweakNG", "d3d9ex\d3d9ex.vcxproj", "{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OneTweakNG", "d3d9ex\d3d9ex.vcxproj", "{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -9,7 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5DB3A8
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
Common\Defines.h = Common\Defines.h
|
Common\Defines.h = Common\Defines.h
|
||||||
Common\Logger.h = Common\Logger.h
|
Common\Logger.h = Common\Logger.h
|
||||||
Common\NonCopyable.h = Common\NonCopyable.h
|
|
||||||
Common\SimpleIni.h = Common\SimpleIni.h
|
Common\SimpleIni.h = Common\SimpleIni.h
|
||||||
Common\StringUtil.h = Common\StringUtil.h
|
Common\StringUtil.h = Common\StringUtil.h
|
||||||
Common\Timer.h = Common\Timer.h
|
Common\Timer.h = Common\Timer.h
|
||||||
|
@ -30,7 +29,8 @@ Global
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|Win32.ActiveCfg = Debug|Win32
|
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|Win32.Build.0 = Debug|Win32
|
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|x64.ActiveCfg = Debug|Win32
|
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Debug|x64.Build.0 = Debug|x64
|
||||||
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|Win32.ActiveCfg = Release|Win32
|
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|Win32.Build.0 = Release|Win32
|
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|Win32.Build.0 = Release|Win32
|
||||||
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|x64.ActiveCfg = Release|x64
|
{6C397640-B1A0-4DEF-8657-0EB21DC2FEA5}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "Context.h"
|
#include "Context.h"
|
||||||
|
#include "IDirect3DVertexBuffer9.h"
|
||||||
|
|
||||||
void MainContext::EnableAutoFix()
|
void MainContext::EnableAutoFix()
|
||||||
{
|
{
|
||||||
|
@ -65,15 +66,26 @@ bool MainContext::ApplyBehaviorFlagsFix(DWORD* flags)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainContext::ApplyVertexBufferFix(UINT& Length, DWORD& Usage, DWORD& FVF, D3DPOOL& Pool)
|
HRESULT APIENTRY MainContext::ApplyVertexBufferFix(IDirect3DDevice9 *pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle)
|
||||||
{
|
{
|
||||||
if (autofix == AutoFixes::NONE) return false;
|
if (autofix == AutoFixes::NONE) return pIDirect3DDevice9->CreateVertexBuffer(Length,Usage,FVF,Pool,ppVertexBuffer,pSharedHandle);
|
||||||
|
|
||||||
// Final Fantasy XIII
|
// Final Fantasy XIII
|
||||||
if (autofix == FINAL_FANTASY_XIII)
|
if (autofix == FINAL_FANTASY_XIII)
|
||||||
{
|
{
|
||||||
if (Length == 358400 && FVF == 0 && Pool == D3DPOOL_MANAGED) { Usage = D3DUSAGE_DYNAMIC; Pool = D3DPOOL_SYSTEMMEM; }
|
if (Length == 358400 && FVF == 0 && Pool == D3DPOOL_MANAGED) {
|
||||||
return true;
|
Usage = D3DUSAGE_DYNAMIC; Pool = D3DPOOL_SYSTEMMEM;
|
||||||
|
|
||||||
|
//IDirect3DVertexBuffer9* buffer = nullptr;
|
||||||
|
//HRESULT hr = pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, &buffer, NULL);
|
||||||
|
//if (FAILED(hr))
|
||||||
|
//{
|
||||||
|
// return pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if(ppVertexBuffer) *ppVertexBuffer = new hkIDirect3DVertexBuffer9(pIDirect3DDevice9, buffer);
|
||||||
|
//return hr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
|
||||||
}
|
}
|
|
@ -37,7 +37,7 @@ Config::Config()
|
||||||
#undef SETTING
|
#undef SETTING
|
||||||
}
|
}
|
||||||
|
|
||||||
MainContext::MainContext()
|
MainContext::MainContext() : oldWndProc(nullptr)
|
||||||
{
|
{
|
||||||
LogFile("OneTweakNG.log");
|
LogFile("OneTweakNG.log");
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ bool MainContext::CheckWindow(HWND hWnd)
|
||||||
|
|
||||||
void MainContext::ApplyWndProc(HWND hWnd)
|
void MainContext::ApplyWndProc(HWND hWnd)
|
||||||
{
|
{
|
||||||
if (config.GetAlwaysActive())
|
if (config.GetAlwaysActive() || config.GetHideCursor())
|
||||||
{
|
{
|
||||||
context.oldWndProc = (WNDPROC)context.TrueSetWindowLongA(hWnd, GWLP_WNDPROC, (LONG_PTR)context.WindowProc);
|
context.oldWndProc = (WNDPROC)context.TrueSetWindowLongA(hWnd, GWLP_WNDPROC, (LONG_PTR)context.WindowProc);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,8 @@ LRESULT CALLBACK MainContext::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
|
||||||
if (context.config.GetAlwaysActive())
|
if (context.config.GetAlwaysActive())
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
while (::ShowCursor(TRUE) < 0);
|
if (!context.config.GetForceHideCursor())
|
||||||
|
while (::ShowCursor(TRUE) < 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +228,10 @@ LRESULT CALLBACK MainContext::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.config.GetForceHideCursor())
|
||||||
|
while (::ShowCursor(FALSE) >= 0);
|
||||||
|
|
||||||
return CallWindowProc(context.oldWndProc, hWnd, uMsg, wParam, lParam);
|
return CallWindowProc(context.oldWndProc, hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,12 @@ struct hkIDirect3D9;
|
||||||
static const char* inifilename = "OneTweakNG.ini";
|
static const char* inifilename = "OneTweakNG.ini";
|
||||||
#define CONFIG_VERSION 3
|
#define CONFIG_VERSION 3
|
||||||
|
|
||||||
class Config : NonCopyable
|
class Config
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Config(const Config&) = delete;
|
||||||
|
const Config& operator=(Config& other) = delete;
|
||||||
|
|
||||||
Config();
|
Config();
|
||||||
|
|
||||||
#define SETTING(_type, _func, _var, _section, _defaultval) \
|
#define SETTING(_type, _func, _var, _section, _defaultval) \
|
||||||
|
@ -26,8 +29,11 @@ public:
|
||||||
public: type(callconv* True##name)(__VA_ARGS__); \
|
public: type(callconv* True##name)(__VA_ARGS__); \
|
||||||
private: static type callconv Hook##name(__VA_ARGS__);
|
private: static type callconv Hook##name(__VA_ARGS__);
|
||||||
|
|
||||||
class MainContext : NonCopyable
|
class MainContext
|
||||||
{
|
{
|
||||||
|
MainContext(const MainContext&) = delete;
|
||||||
|
const MainContext& operator=(MainContext& other) = delete;
|
||||||
|
|
||||||
DECLARE_HOOK(IDirect3D9*, WINAPI, Direct3DCreate9, UINT SDKVersion);
|
DECLARE_HOOK(IDirect3D9*, WINAPI, Direct3DCreate9, UINT SDKVersion);
|
||||||
DECLARE_HOOK(LONG, WINAPI, SetWindowLongA, HWND hWnd, int nIndex, LONG dwNewLong);
|
DECLARE_HOOK(LONG, WINAPI, SetWindowLongA, HWND hWnd, int nIndex, LONG dwNewLong);
|
||||||
DECLARE_HOOK(LONG, WINAPI, SetWindowLongW, HWND hWnd, int nIndex, LONG dwNewLong);
|
DECLARE_HOOK(LONG, WINAPI, SetWindowLongW, HWND hWnd, int nIndex, LONG dwNewLong);
|
||||||
|
@ -42,7 +48,7 @@ public:
|
||||||
|
|
||||||
bool ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentationParameters);
|
bool ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||||
bool ApplyBehaviorFlagsFix(DWORD* flags);
|
bool ApplyBehaviorFlagsFix(DWORD* flags);
|
||||||
bool ApplyVertexBufferFix(UINT& Length, DWORD& Usage, DWORD& FVF, D3DPOOL& Pool);
|
HRESULT APIENTRY ApplyVertexBufferFix(IDirect3DDevice9* pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle);
|
||||||
bool BehaviorFlagsToString(DWORD BehaviorFlags, std::string* BehaviorFlagsString);
|
bool BehaviorFlagsToString(DWORD BehaviorFlags, std::string* BehaviorFlagsString);
|
||||||
|
|
||||||
bool CheckWindow(HWND hWnd);
|
bool CheckWindow(HWND hWnd);
|
||||||
|
|
|
@ -9,31 +9,35 @@
|
||||||
|
|
||||||
#define IDirect3D9_PrintLog(format, ...) //PrintLog(format, __VA_ARGS__);
|
#define IDirect3D9_PrintLog(format, ...) //PrintLog(format, __VA_ARGS__);
|
||||||
|
|
||||||
hkIDirect3D9::hkIDirect3D9(IDirect3D9 *pIDirect3D9) {
|
|
||||||
PrintLog(__FUNCTION__);
|
|
||||||
m_pWrapped = pIDirect3D9;
|
|
||||||
}
|
|
||||||
|
|
||||||
hkIDirect3D9::~hkIDirect3D9()
|
|
||||||
{
|
|
||||||
PrintLog(__FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) {
|
HRESULT APIENTRY hkIDirect3D9::QueryInterface(REFIID riid, void** ppvObj) {
|
||||||
PrintLog(__FUNCTION__);
|
PrintLog(__FUNCTION__);
|
||||||
return m_pWrapped->QueryInterface(riid, ppvObj);
|
if (ppvObj == nullptr) return E_POINTER;
|
||||||
|
|
||||||
|
if (riid == __uuidof(IUnknown) ||
|
||||||
|
riid == __uuidof(IDirect3D9))
|
||||||
|
{
|
||||||
|
*ppvObj = static_cast<IDirect3D9*>(this);
|
||||||
|
AddRef();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppvObj = nullptr;
|
||||||
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG APIENTRY hkIDirect3D9::AddRef() {
|
ULONG APIENTRY hkIDirect3D9::AddRef() {
|
||||||
PrintLog(__FUNCTION__);
|
PrintLog(__FUNCTION__);
|
||||||
return m_pWrapped->AddRef();
|
return _InterlockedIncrement(&m_refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG APIENTRY hkIDirect3D9::Release() {
|
ULONG APIENTRY hkIDirect3D9::Release() {
|
||||||
ULONG ref_count = m_pWrapped->Release();
|
PrintLog(__FUNCTION__);
|
||||||
PrintLog(__FUNCTION__ " return = %lu", ref_count);
|
const LONG ref = _InterlockedDecrement(&m_refCount);
|
||||||
if (ref_count == 0) delete this;
|
if (ref == 0)
|
||||||
return ref_count;
|
{
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT APIENTRY hkIDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) {
|
HRESULT APIENTRY hkIDirect3D9::RegisterSoftwareDevice(void* pInitializeFunction) {
|
||||||
|
@ -131,18 +135,22 @@ HRESULT APIENTRY hkIDirect3D9::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType,
|
||||||
if (hFocusWindow == NULL) hFocusWindow = pPresentationParameters->hDeviceWindow;
|
if (hFocusWindow == NULL) hFocusWindow = pPresentationParameters->hDeviceWindow;
|
||||||
context.ApplyPresentationParameters(pPresentationParameters);
|
context.ApplyPresentationParameters(pPresentationParameters);
|
||||||
|
|
||||||
HRESULT hr = m_pWrapped->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
|
|
||||||
if (SUCCEEDED(hr) && ppReturnedDeviceInterface && *ppReturnedDeviceInterface)
|
|
||||||
{
|
|
||||||
hkIDirect3DDevice9* pIDirect3DDevice9 = new hkIDirect3DDevice9(*ppReturnedDeviceInterface);
|
|
||||||
*ppReturnedDeviceInterface = pIDirect3DDevice9;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OriginalBehaviorFlags != BehaviorFlags)
|
if (OriginalBehaviorFlags != BehaviorFlags)
|
||||||
{
|
{
|
||||||
std::string BehaviorFlagsString;
|
std::string BehaviorFlagsString;
|
||||||
context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString);
|
context.BehaviorFlagsToString(BehaviorFlags, &BehaviorFlagsString);
|
||||||
PrintLog("BehaviorFlags changed: %08X %s", BehaviorFlags, BehaviorFlagsString.c_str());
|
PrintLog("BehaviorFlags changed: %08X %s", BehaviorFlags, BehaviorFlagsString.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IDirect3DDevice9* device = nullptr;
|
||||||
|
HRESULT hr = m_pWrapped->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, &device);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
PrintLog("CreateDevice fail with HRESULT: %08X", hr);
|
||||||
|
*ppReturnedDeviceInterface = nullptr;
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppReturnedDeviceInterface = new hkIDirect3DDevice9(device);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,8 @@
|
||||||
#include "d3d9.h"
|
#include "d3d9.h"
|
||||||
#include "IDirect3DDevice9.h"
|
#include "IDirect3DDevice9.h"
|
||||||
|
|
||||||
interface hkIDirect3D9 : public IDirect3D9 {
|
interface hkIDirect3D9 final : public IDirect3D9 {
|
||||||
IDirect3D9* m_pWrapped;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hkIDirect3D9(IDirect3D9 *pIDirect3D9);
|
|
||||||
~hkIDirect3D9();
|
|
||||||
|
|
||||||
// original interface
|
// original interface
|
||||||
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj);
|
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj);
|
||||||
STDMETHOD_(ULONG, AddRef)();
|
STDMETHOD_(ULONG, AddRef)();
|
||||||
|
@ -29,5 +24,21 @@ public:
|
||||||
STDMETHOD(GetDeviceCaps)(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps);
|
STDMETHOD(GetDeviceCaps)(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps);
|
||||||
STDMETHOD_(HMONITOR, GetAdapterMonitor)(UINT Adapter);
|
STDMETHOD_(HMONITOR, GetAdapterMonitor)(UINT Adapter);
|
||||||
STDMETHOD(CreateDevice)(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface);
|
STDMETHOD(CreateDevice)(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface);
|
||||||
|
|
||||||
|
public:
|
||||||
|
hkIDirect3D9(IDirect3D9 *pIDirect3D9)
|
||||||
|
: m_pWrapped(pIDirect3D9)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
~hkIDirect3D9()
|
||||||
|
{
|
||||||
|
m_pWrapped->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG m_refCount = 1;
|
||||||
|
IDirect3D9 *m_pWrapped;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,31 +11,34 @@
|
||||||
|
|
||||||
#define IDirect3DDevice9_PrintLog(...) //PrintLog(format, __VA_ARGS__);
|
#define IDirect3DDevice9_PrintLog(...) //PrintLog(format, __VA_ARGS__);
|
||||||
|
|
||||||
hkIDirect3DDevice9::hkIDirect3DDevice9(IDirect3DDevice9 *pIDirect3DDevice9) {
|
|
||||||
PrintLog(__FUNCTION__);
|
|
||||||
m_pWrapped = pIDirect3DDevice9;
|
|
||||||
}
|
|
||||||
|
|
||||||
hkIDirect3DDevice9::~hkIDirect3DDevice9()
|
|
||||||
{
|
|
||||||
PrintLog(__FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT APIENTRY hkIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) {
|
HRESULT APIENTRY hkIDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) {
|
||||||
IDirect3DDevice9_PrintLog(__FUNCTION__);
|
IDirect3DDevice9_PrintLog(__FUNCTION__);
|
||||||
return m_pWrapped->QueryInterface(riid, ppvObj);
|
if (ppvObj == nullptr) return E_POINTER;
|
||||||
|
|
||||||
|
if (riid == __uuidof(IUnknown) ||
|
||||||
|
riid == __uuidof(IDirect3DDevice9))
|
||||||
|
{
|
||||||
|
*ppvObj = static_cast<IDirect3DDevice9*>(this);
|
||||||
|
AddRef();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppvObj = nullptr;
|
||||||
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG APIENTRY hkIDirect3DDevice9::AddRef() {
|
ULONG APIENTRY hkIDirect3DDevice9::AddRef() {
|
||||||
IDirect3DDevice9_PrintLog(__FUNCTION__);
|
IDirect3DDevice9_PrintLog(__FUNCTION__);
|
||||||
return m_pWrapped->AddRef();
|
return _InterlockedIncrement(&m_refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG APIENTRY hkIDirect3DDevice9::Release() {
|
ULONG APIENTRY hkIDirect3DDevice9::Release() {
|
||||||
ULONG ref_count = m_pWrapped->Release();
|
const LONG ref = _InterlockedDecrement(&m_refCount);
|
||||||
PrintLog(__FUNCTION__ " return = %lu", ref_count);
|
if (ref == 0)
|
||||||
if (ref_count == 0) delete this;
|
{
|
||||||
return ref_count;
|
delete this;
|
||||||
|
}
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT APIENTRY hkIDirect3DDevice9::TestCooperativeLevel() {
|
HRESULT APIENTRY hkIDirect3DDevice9::TestCooperativeLevel() {
|
||||||
|
@ -178,8 +181,7 @@ HRESULT APIENTRY hkIDirect3DDevice9::CreateCubeTexture(UINT EdgeLength, UINT Lev
|
||||||
|
|
||||||
HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
|
HRESULT APIENTRY hkIDirect3DDevice9::CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
|
||||||
//PrintLog("hkIDirect3DDevice9::CreateVertexBuffer %08u %x %x %x %p %p", Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
|
//PrintLog("hkIDirect3DDevice9::CreateVertexBuffer %08u %x %x %x %p %p", Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
|
||||||
context.ApplyVertexBufferFix(Length, Usage, FVF, Pool);
|
return context.ApplyVertexBufferFix(m_pWrapped, Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
|
||||||
return m_pWrapped->CreateVertexBuffer(Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT APIENTRY hkIDirect3DDevice9::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) {
|
HRESULT APIENTRY hkIDirect3DDevice9::CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) {
|
||||||
|
|
|
@ -4,13 +4,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "d3d9.h"
|
#include "d3d9.h"
|
||||||
|
|
||||||
interface hkIDirect3DDevice9 : public IDirect3DDevice9 {
|
interface hkIDirect3DDevice9 final : public IDirect3DDevice9 {
|
||||||
IDirect3DDevice9* m_pWrapped;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hkIDirect3DDevice9(IDirect3DDevice9 *pIDirect3DDevice9);
|
|
||||||
~hkIDirect3DDevice9();
|
|
||||||
|
|
||||||
// original interface
|
// original interface
|
||||||
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj);
|
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj);
|
||||||
STDMETHOD_(ULONG, AddRef)();
|
STDMETHOD_(ULONG, AddRef)();
|
||||||
|
@ -131,5 +126,20 @@ public:
|
||||||
STDMETHOD(DrawTriPatch)(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo);
|
STDMETHOD(DrawTriPatch)(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo);
|
||||||
STDMETHOD(DeletePatch)(UINT Handle);
|
STDMETHOD(DeletePatch)(UINT Handle);
|
||||||
STDMETHOD(CreateQuery)(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery);
|
STDMETHOD(CreateQuery)(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery);
|
||||||
|
|
||||||
|
public:
|
||||||
|
hkIDirect3DDevice9(IDirect3DDevice9 *pIDirect3DDevice9)
|
||||||
|
: m_pWrapped(pIDirect3DDevice9)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
~hkIDirect3DDevice9()
|
||||||
|
{
|
||||||
|
m_pWrapped->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG m_refCount = 1;
|
||||||
|
IDirect3DDevice9* m_pWrapped;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
102
d3d9ex/IDirect3DVertexBuffer9.cpp
Normal file
102
d3d9ex/IDirect3DVertexBuffer9.cpp
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
// wrapper for IDirect3DVertexBuffer9 in d3d9.h
|
||||||
|
// generated using wrapper_gen.rb
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "Context.h"
|
||||||
|
|
||||||
|
#include "IDirect3D9.h"
|
||||||
|
#include "IDirect3DDevice9.h"
|
||||||
|
#include "IDirect3DVertexBuffer9.h"
|
||||||
|
|
||||||
|
#define IDirect3DVertexBuffer9_PrintLog(format, ...) //PrintLog(format, __VA_ARGS__);
|
||||||
|
|
||||||
|
HRESULT APIENTRY hkIDirect3DVertexBuffer9::QueryInterface(REFIID riid, void** ppvObj) {
|
||||||
|
if (ppvObj == nullptr) return E_POINTER;
|
||||||
|
|
||||||
|
if (riid == __uuidof(IUnknown) ||
|
||||||
|
riid == __uuidof(IDirect3DResource9) ||
|
||||||
|
riid == __uuidof(IDirect3DVertexBuffer9))
|
||||||
|
{
|
||||||
|
*ppvObj = static_cast<IDirect3DVertexBuffer9*>(this);
|
||||||
|
AddRef();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppvObj = nullptr;
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG APIENTRY hkIDirect3DVertexBuffer9::AddRef() {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return _InterlockedIncrement(&m_refCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG APIENTRY hkIDirect3DVertexBuffer9::Release() {
|
||||||
|
const LONG ref = _InterlockedDecrement(&m_refCount);
|
||||||
|
if (ref == 0)
|
||||||
|
{
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetDevice(IDirect3DDevice9** ppDevice) {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
|
||||||
|
if (ppDevice == nullptr)
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
|
m_pIDirect3DDevice9->AddRef();
|
||||||
|
*ppDevice = m_pIDirect3DDevice9;
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT APIENTRY hkIDirect3DVertexBuffer9::SetPrivateData(REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->SetPrivateData(refguid, pData, SizeOfData, Flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetPrivateData(REFGUID refguid, void* pData, DWORD* pSizeOfData) {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->GetPrivateData(refguid, pData, pSizeOfData);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT APIENTRY hkIDirect3DVertexBuffer9::FreePrivateData(REFGUID refguid) {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->FreePrivateData(refguid);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD APIENTRY hkIDirect3DVertexBuffer9::SetPriority(DWORD PriorityNew) {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->SetPriority(PriorityNew);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD APIENTRY hkIDirect3DVertexBuffer9::GetPriority() {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->GetPriority();
|
||||||
|
}
|
||||||
|
|
||||||
|
void APIENTRY hkIDirect3DVertexBuffer9::PreLoad() {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->PreLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
D3DRESOURCETYPE APIENTRY hkIDirect3DVertexBuffer9::GetType() {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->GetType();
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT APIENTRY hkIDirect3DVertexBuffer9::Lock(UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->Lock(OffsetToLock, SizeToLock, ppbData, Flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT APIENTRY hkIDirect3DVertexBuffer9::Unlock() {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetDesc(D3DVERTEXBUFFER_DESC *pDesc) {
|
||||||
|
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||||
|
return m_pWrapped->GetDesc(pDesc);
|
||||||
|
}
|
40
d3d9ex/IDirect3DVertexBuffer9.h
Normal file
40
d3d9ex/IDirect3DVertexBuffer9.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// wrapper for IDirect3DVertexBuffer9 in d3d9.h
|
||||||
|
// generated using wrapper_gen.rb
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "d3d9.h"
|
||||||
|
|
||||||
|
interface hkIDirect3DVertexBuffer9 final : public IDirect3DVertexBuffer9 {
|
||||||
|
public:
|
||||||
|
// original interface
|
||||||
|
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj);
|
||||||
|
STDMETHOD_(ULONG, AddRef)();
|
||||||
|
STDMETHOD_(ULONG, Release)();
|
||||||
|
STDMETHOD(GetDevice)(IDirect3DDevice9** ppDevice);
|
||||||
|
STDMETHOD(SetPrivateData)(REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
|
||||||
|
STDMETHOD(GetPrivateData)(REFGUID refguid, void* pData, DWORD* pSizeOfData);
|
||||||
|
STDMETHOD(FreePrivateData)(REFGUID refguid);
|
||||||
|
STDMETHOD_(DWORD, SetPriority)(DWORD PriorityNew);
|
||||||
|
STDMETHOD_(DWORD, GetPriority)();
|
||||||
|
STDMETHOD_(void, PreLoad)();
|
||||||
|
STDMETHOD_(D3DRESOURCETYPE, GetType)();
|
||||||
|
STDMETHOD(Lock)(UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags);
|
||||||
|
STDMETHOD(Unlock)();
|
||||||
|
STDMETHOD(GetDesc)(D3DVERTEXBUFFER_DESC *pDesc);
|
||||||
|
|
||||||
|
public:
|
||||||
|
hkIDirect3DVertexBuffer9(IDirect3DDevice9* pIDirect3DDevice9, IDirect3DVertexBuffer9* pIDirect3DVertexBuffer9)
|
||||||
|
: m_pWrapped(pIDirect3DVertexBuffer9), m_pIDirect3DDevice9(pIDirect3DDevice9)
|
||||||
|
{}
|
||||||
|
|
||||||
|
private:
|
||||||
|
~hkIDirect3DVertexBuffer9()
|
||||||
|
{
|
||||||
|
m_pWrapped->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG m_refCount = 1;
|
||||||
|
IDirect3DVertexBuffer9 *m_pWrapped;
|
||||||
|
IDirect3DDevice9* m_pIDirect3DDevice9;
|
||||||
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@ SETTING(bool, BoolValue, AlwaysActive, Options, false);
|
||||||
SETTING(bool, BoolValue, AutoFix, Options, true);
|
SETTING(bool, BoolValue, AutoFix, Options, true);
|
||||||
SETTING(u32, LongValue, Multisample, Options, 0);
|
SETTING(u32, LongValue, Multisample, Options, 0);
|
||||||
SETTING(bool, BoolValue, HideCursor, Options, false);
|
SETTING(bool, BoolValue, HideCursor, Options, false);
|
||||||
|
SETTING(bool, BoolValue, ForceHideCursor, Options, false);
|
||||||
SETTING(u32, LongValue, BehaviorFlags, Options, 0);
|
SETTING(u32, LongValue, BehaviorFlags, Options, 0);
|
||||||
|
|
||||||
SETTING(bool, BoolValue, Adapter, Adapter, false);
|
SETTING(bool, BoolValue, Adapter, Adapter, false);
|
||||||
|
|
101
d3d9ex/Wrapper.h
101
d3d9ex/Wrapper.h
|
@ -4,12 +4,16 @@
|
||||||
|
|
||||||
#include "d3d9.h"
|
#include "d3d9.h"
|
||||||
#include "dinput.h"
|
#include "dinput.h"
|
||||||
|
#include "xinput.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class WrapperBase : NonCopyable
|
class WrapperBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WrapperBase() {}
|
WrapperBase(const WrapperBase&) = delete;
|
||||||
|
const WrapperBase& operator=(WrapperBase& other) = delete;
|
||||||
|
|
||||||
|
WrapperBase(): m_module(nullptr) {}
|
||||||
|
|
||||||
~WrapperBase()
|
~WrapperBase()
|
||||||
{
|
{
|
||||||
|
@ -161,3 +165,96 @@ extern "C"
|
||||||
return DINPUT8DLL::Get().DirectInput8Create(hinst, dwVersion, riidltf, ppvOut, punkOuter);
|
return DINPUT8DLL::Get().DirectInput8Create(hinst, dwVersion, riidltf, ppvOut, punkOuter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class XINPUTDLL : public WrapperBase<XINPUTDLL>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// XInput 1.3 and older functions
|
||||||
|
DWORD(WINAPI* XInputGetState)(DWORD dwUserIndex, XINPUT_STATE* pState);
|
||||||
|
DWORD(WINAPI* XInputSetState)(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration);
|
||||||
|
DWORD(WINAPI* XInputGetCapabilities)(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities);
|
||||||
|
VOID(WINAPI* XInputEnable)(BOOL enable);
|
||||||
|
DWORD(WINAPI* XInputGetDSoundAudioDeviceGuids)(DWORD dwUserIndex, GUID* pDSoundRenderGuid, GUID* pDSoundCaptureGuid);
|
||||||
|
DWORD(WINAPI* XInputGetBatteryInformation)(DWORD dwUserIndex, BYTE devType, XINPUT_BATTERY_INFORMATION* pBatteryInformation);
|
||||||
|
DWORD(WINAPI* XInputGetKeystroke)(DWORD dwUserIndex, DWORD dwReserved, PXINPUT_KEYSTROKE pKeystroke);
|
||||||
|
|
||||||
|
// XInput 1.3 undocumented functions
|
||||||
|
DWORD(WINAPI* XInputGetStateEx)(DWORD dwUserIndex, XINPUT_STATE *pState); // 100
|
||||||
|
DWORD(WINAPI* XInputWaitForGuideButton)(DWORD dwUserIndex, DWORD dwFlag, LPVOID pVoid); // 101
|
||||||
|
DWORD(WINAPI* XInputCancelGuideButtonWait)(DWORD dwUserIndex); // 102
|
||||||
|
DWORD(WINAPI* XInputPowerOffController)(DWORD dwUserIndex); // 103
|
||||||
|
|
||||||
|
// XInput 1.4 functions
|
||||||
|
DWORD(WINAPI* XInputGetAudioDeviceIds)(DWORD dwUserIndex, LPWSTR pRenderDeviceId, UINT* pRenderCount, LPWSTR pCaptureDeviceId, UINT* pCaptureCount);
|
||||||
|
|
||||||
|
// XInput 1.4 undocumented functionss
|
||||||
|
DWORD(WINAPI* XInputGetBaseBusInformation)(DWORD dwUserIndex, struct XINPUT_BUSINFO* pBusinfo); // 104
|
||||||
|
DWORD(WINAPI* XInputGetCapabilitiesEx)(DWORD unk1, DWORD dwUserIndex, DWORD dwFlags, struct XINPUT_CAPABILITIESEX* pCapabilitiesEx); // 108
|
||||||
|
|
||||||
|
XINPUTDLL()
|
||||||
|
{
|
||||||
|
WrapperLoad("xinput1_3.dll");
|
||||||
|
|
||||||
|
// XInput 1.3 and older functions
|
||||||
|
StoreAddress(&XInputGetState, "XInputGetState");
|
||||||
|
StoreAddress(&XInputSetState, "XInputSetState");
|
||||||
|
StoreAddress(&XInputGetCapabilities, "XInputGetCapabilities");
|
||||||
|
StoreAddress(&XInputEnable, "XInputEnable");
|
||||||
|
StoreAddress(&XInputGetDSoundAudioDeviceGuids, "XInputGetDSoundAudioDeviceGuids");
|
||||||
|
StoreAddress(&XInputGetBatteryInformation, "XInputGetBatteryInformation");
|
||||||
|
StoreAddress(&XInputGetKeystroke, "XInputGetKeystroke");
|
||||||
|
|
||||||
|
// XInput 1.3 undocumented functions
|
||||||
|
StoreAddress(&XInputGetStateEx, (const char*)100);
|
||||||
|
StoreAddress(&XInputWaitForGuideButton, (const char*)101);
|
||||||
|
StoreAddress(&XInputCancelGuideButtonWait, (const char*)102);
|
||||||
|
StoreAddress(&XInputPowerOffController, (const char*)103);
|
||||||
|
|
||||||
|
// XInput 1.4 functions
|
||||||
|
StoreAddress(&XInputGetAudioDeviceIds, "XInputGetAudioDeviceIds");
|
||||||
|
|
||||||
|
// XInput 1.4 undocumented functionss
|
||||||
|
StoreAddress(&XInputGetBaseBusInformation, (const char*)104);
|
||||||
|
StoreAddress(&XInputGetCapabilitiesEx, (const char*)108);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
// XInput 1.3 and older functions
|
||||||
|
DWORD WINAPI _XInputGetState(DWORD dwUserIndex, XINPUT_STATE* pState)
|
||||||
|
{
|
||||||
|
return XINPUTDLL::Get().XInputGetState(dwUserIndex, pState);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI _XInputSetState(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration)
|
||||||
|
{
|
||||||
|
return XINPUTDLL::Get().XInputSetState(dwUserIndex, pVibration);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI _XInputGetCapabilities(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities)
|
||||||
|
{
|
||||||
|
return XINPUTDLL::Get().XInputGetCapabilities(dwUserIndex, dwFlags, pCapabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID WINAPI _XInputEnable(BOOL enable)
|
||||||
|
{
|
||||||
|
return XINPUTDLL::Get().XInputEnable(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI _XInputGetDSoundAudioDeviceGuids(DWORD dwUserIndex, GUID* pDSoundRenderGuid, GUID* pDSoundCaptureGuid)
|
||||||
|
{
|
||||||
|
return XINPUTDLL::Get().XInputGetDSoundAudioDeviceGuids(dwUserIndex, pDSoundRenderGuid, pDSoundCaptureGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI _XInputGetBatteryInformation(DWORD dwUserIndex, BYTE devType, XINPUT_BATTERY_INFORMATION* pBatteryInformation)
|
||||||
|
{
|
||||||
|
return XINPUTDLL::Get().XInputGetBatteryInformation(dwUserIndex, devType, pBatteryInformation);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI _XInputGetKeystroke(DWORD dwUserIndex, DWORD dwReserved, PXINPUT_KEYSTROKE pKeystroke)
|
||||||
|
{
|
||||||
|
return XINPUTDLL::Get().XInputGetKeystroke(dwUserIndex, dwReserved, pKeystroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,19 +23,19 @@
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>d3d9ex</RootNamespace>
|
<RootNamespace>d3d9ex</RootNamespace>
|
||||||
<ProjectName>OneTweakNG</ProjectName>
|
<ProjectName>OneTweakNG</ProjectName>
|
||||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<InterproceduralOptimization>true</InterproceduralOptimization>
|
<InterproceduralOptimization>true</InterproceduralOptimization>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<InterproceduralOptimization>true</InterproceduralOptimization>
|
<InterproceduralOptimization>true</InterproceduralOptimization>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
@ -72,8 +72,8 @@
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<TargetName>d3d9</TargetName>
|
<TargetName>dinput8</TargetName>
|
||||||
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\MinHook\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\MinHook\include;$(DXSDK_DIR)\Include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
@ -83,12 +83,12 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetName>dinput8</TargetName>
|
<TargetName>dinput8</TargetName>
|
||||||
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\MinHook\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\MinHook\include;$(DXSDK_DIR)\Include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<TargetName>dinput8</TargetName>
|
<TargetName>dinput8</TargetName>
|
||||||
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\MinHook\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)\Common;$(SolutionDir)\MinHook\include;$(DXSDK_DIR)\Include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -129,6 +129,7 @@
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -163,6 +164,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Context.h" />
|
<ClInclude Include="Context.h" />
|
||||||
|
<ClInclude Include="IDirect3DVertexBuffer9.h" />
|
||||||
<ClInclude Include="Wrapper.h" />
|
<ClInclude Include="Wrapper.h" />
|
||||||
<ClInclude Include="IDirect3D9.h" />
|
<ClInclude Include="IDirect3D9.h" />
|
||||||
<ClInclude Include="IDirect3DDevice9.h" />
|
<ClInclude Include="IDirect3DDevice9.h" />
|
||||||
|
@ -189,6 +191,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="IDirect3D9.cpp" />
|
<ClCompile Include="IDirect3D9.cpp" />
|
||||||
<ClCompile Include="IDirect3DDevice9.cpp" />
|
<ClCompile Include="IDirect3DDevice9.cpp" />
|
||||||
|
<ClCompile Include="IDirect3DVertexBuffer9.cpp" />
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
<ClInclude Include="Wrapper.h">
|
<ClInclude Include="Wrapper.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="IDirect3DVertexBuffer9.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
@ -59,6 +62,9 @@
|
||||||
<ClCompile Include="Context.cpp">
|
<ClCompile Include="Context.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="IDirect3DVertexBuffer9.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="exports.def">
|
<None Include="exports.def">
|
||||||
|
|
|
@ -13,3 +13,10 @@ D3DPERF_SetRegion=_D3DPERF_SetRegion @26
|
||||||
|
|
||||||
DirectInput8Create=_DirectInput8Create
|
DirectInput8Create=_DirectInput8Create
|
||||||
|
|
||||||
|
XInputGetState=_XInputGetState @2
|
||||||
|
XInputSetState=_XInputSetState @3
|
||||||
|
XInputGetCapabilities=_XInputGetCapabilities @4
|
||||||
|
XInputEnable=_XInputEnable @5
|
||||||
|
XInputGetDSoundAudioDeviceGuids=_XInputGetDSoundAudioDeviceGuids @6
|
||||||
|
XInputGetBatteryInformation=_XInputGetBatteryInformation @7
|
||||||
|
XInputGetKeystroke=_XInputGetKeystroke @8
|
||||||
|
|
Loading…
Reference in a new issue