mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
safer resource management
This commit is contained in:
parent
f39c7c8d2c
commit
98055b9f3f
1 changed files with 3 additions and 8 deletions
|
@ -720,16 +720,13 @@ void DrawMoonWithPhases(int moonColor, float* screenPos, float sizeX, float size
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Load from memory
|
// Load from memory
|
||||||
|
|
||||||
HMODULE thisModule;
|
HMODULE thisModule;
|
||||||
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)DrawMoonWithPhases, &thisModule);
|
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)DrawMoonWithPhases, &thisModule);
|
||||||
|
|
||||||
HRSRC resource = FindResourceW(thisModule, MAKEINTRESOURCE(IDR_LUNAR64), RT_RCDATA);
|
HRSRC resource = FindResourceW(thisModule, MAKEINTRESOURCE(IDR_LUNAR64), RT_RCDATA);
|
||||||
void* pMoonMask = static_cast<void*>(LoadResource(thisModule, resource));
|
void* pMoonMask = LockResource( LoadResource(thisModule, resource) );
|
||||||
|
|
||||||
gpMoonMask = CPNGFile::ReadFromMemory(pMoonMask, SizeofResource(thisModule, resource));
|
gpMoonMask = CPNGFile::ReadFromMemory(pMoonMask, SizeofResource(thisModule, resource));
|
||||||
|
|
||||||
FreeResource(pMoonMask);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//D3DPERF_BeginEvent(D3DCOLOR_ARGB(0,0,0,0), L"render moon");
|
//D3DPERF_BeginEvent(D3DCOLOR_ARGB(0,0,0,0), L"render moon");
|
||||||
|
@ -1135,13 +1132,11 @@ bool ShaderAttach()
|
||||||
HMODULE thisModule;
|
HMODULE thisModule;
|
||||||
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)ShaderAttach, &thisModule);
|
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)ShaderAttach, &thisModule);
|
||||||
|
|
||||||
HRSRC resource = FindResource(thisModule, MAKEINTRESOURCE(IDR_NVCSHADER), RT_RCDATA);
|
HRSRC resource = FindResourceW(thisModule, MAKEINTRESOURCE(IDR_NVCSHADER), RT_RCDATA);
|
||||||
RwUInt32* shader = static_cast<RwUInt32*>(LoadResource(thisModule, resource));
|
RwUInt32* shader = static_cast<RwUInt32*>(LockResource( LoadResource(thisModule, resource) ));
|
||||||
|
|
||||||
RwD3D9CreateVertexShader(shader, reinterpret_cast<void**>(&pNVCShader));
|
RwD3D9CreateVertexShader(shader, reinterpret_cast<void**>(&pNVCShader));
|
||||||
|
|
||||||
FreeResource(shader);
|
|
||||||
|
|
||||||
bXMSupported = XMVerifyCPUSupport() != FALSE;
|
bXMSupported = XMVerifyCPUSupport() != FALSE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue