Some minor changes and refactoring
This commit is contained in:
parent
dbc6ff9390
commit
b129645128
|
@ -80,7 +80,7 @@ inline void StringPathAppend(std::wstring* path, const std::wstring& more)
|
|||
inline bool FileExists(const std::string& path)
|
||||
{
|
||||
FILE* filep;
|
||||
if (fopen_s(&filep, path.c_str(), "rb") == 0)
|
||||
if (fopen_s(&filep, path.c_str(), "rb") == 0 && filep != 0)
|
||||
{
|
||||
fclose(filep);
|
||||
return true;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<SpectreMitigation>false</SpectreMitigation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
|
|
|
@ -30,7 +30,7 @@ void MainContext::EnableAutoFix()
|
|||
const std::map<const MainContext::AutoFixes, const uint32_t> MainContext::behaviorflags_fixes =
|
||||
{
|
||||
{ RESIDENT_EVIL_4, D3DCREATE_SOFTWARE_VERTEXPROCESSING },
|
||||
{ KINGS_BOUNTY_LEGEND, D3DCREATE_MIXED_VERTEXPROCESSING },
|
||||
{ KINGS_BOUNTY_LEGEND, D3DCREATE_MIXED_VERTEXPROCESSING }
|
||||
};
|
||||
|
||||
void MainContext::FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out)
|
||||
|
@ -73,8 +73,9 @@ HRESULT APIENTRY MainContext::ApplyVertexBufferFix(IDirect3DDevice9 *pIDirect3DD
|
|||
// 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 && Pool == D3DPOOL_MANAGED) {
|
||||
Usage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY;
|
||||
Pool = D3DPOOL_SYSTEMMEM;
|
||||
|
||||
//IDirect3DVertexBuffer9* buffer = nullptr;
|
||||
//HRESULT hr = pIDirect3DDevice9->CreateVertexBuffer(Length, Usage, FVF, Pool, &buffer, NULL);
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
};
|
||||
|
||||
#define DECLARE_HOOK(type, callconv, name, ...) \
|
||||
public: type(callconv* True##name)(__VA_ARGS__); \
|
||||
public: type(callconv* True##name)(__VA_ARGS__) = name; \
|
||||
private: static type callconv Hook##name(__VA_ARGS__);
|
||||
|
||||
class MainContext
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
#include "IDirect3DDevice9.h"
|
||||
#include "IDirect3DVertexBuffer9.h"
|
||||
|
||||
#define IDirect3DVertexBuffer9_PrintLog(format, ...) //PrintLog(format, __VA_ARGS__);
|
||||
#define IDirect3DVertexBuffer9_PrintLog(format, ...) PrintLog(format, __VA_ARGS__);
|
||||
|
||||
HRESULT APIENTRY hkIDirect3DVertexBuffer9::QueryInterface(REFIID riid, void** ppvObj) {
|
||||
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||
if (ppvObj == nullptr) return E_POINTER;
|
||||
|
||||
if (riid == __uuidof(IUnknown) ||
|
||||
|
@ -32,6 +33,7 @@ ULONG APIENTRY hkIDirect3DVertexBuffer9::AddRef() {
|
|||
}
|
||||
|
||||
ULONG APIENTRY hkIDirect3DVertexBuffer9::Release() {
|
||||
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||
const LONG ref = _InterlockedDecrement(&m_refCount);
|
||||
if (ref == 0)
|
||||
{
|
||||
|
@ -52,12 +54,12 @@ HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetDevice(IDirect3DDevice9** ppDevice
|
|||
}
|
||||
|
||||
HRESULT APIENTRY hkIDirect3DVertexBuffer9::SetPrivateData(REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
||||
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__ " %s", GUIDtoStringA(refguid));
|
||||
return m_pWrapped->SetPrivateData(refguid, pData, SizeOfData, Flags);
|
||||
}
|
||||
|
||||
HRESULT APIENTRY hkIDirect3DVertexBuffer9::GetPrivateData(REFGUID refguid, void* pData, DWORD* pSizeOfData) {
|
||||
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__);
|
||||
IDirect3DVertexBuffer9_PrintLog(__FUNCTION__ " %s", GUIDtoStringA(refguid));
|
||||
return m_pWrapped->GetPrivateData(refguid, pData, pSizeOfData);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,21 +6,23 @@
|
|||
|
||||
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);
|
||||
/*** IUnknown methods ***/
|
||||
STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj);
|
||||
STDMETHOD_(ULONG, AddRef)(THIS);
|
||||
STDMETHOD_(ULONG, Release)(THIS);
|
||||
|
||||
/*** IDirect3DResource9 methods ***/
|
||||
STDMETHOD(GetDevice)(THIS_ IDirect3DDevice9** ppDevice);
|
||||
STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
|
||||
STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void* pData, DWORD* pSizeOfData);
|
||||
STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid);
|
||||
STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew);
|
||||
STDMETHOD_(DWORD, GetPriority)(THIS);
|
||||
STDMETHOD_(void, PreLoad)(THIS);
|
||||
STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS);
|
||||
STDMETHOD(Lock)(THIS_ UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags);
|
||||
STDMETHOD(Unlock)(THIS);
|
||||
STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC* pDesc);
|
||||
|
||||
public:
|
||||
hkIDirect3DVertexBuffer9(IDirect3DDevice9* pIDirect3DDevice9, IDirect3DVertexBuffer9* pIDirect3DVertexBuffer9)
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<InterproceduralOptimization>true</InterproceduralOptimization>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<SpectreMitigation>false</SpectreMitigation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
|
|
Loading…
Reference in New Issue