-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
help wantedExtra attention is neededExtra attention is needed
Description
Not sure why this happens. I've noticed some weird behavior with D3D12 though. Here is an extremely simple example D3D12 proxy DLL which illustrates said weird behavior:
#include <Windows.h>
FARPROC p[3];
void* pp = &p[0];
extern "C" {
void RunAsm();
HMODULE originalDll = 0;
FARPROC funcAddr = NULL;
// This works. Using individual FARPROC variables also works.
void Proxy_D3D12CreateDevice() { funcAddr = *((FARPROC*)pp + 0); RunAsm(); }
void Proxy_D3D12GetDebugInterface() { funcAddr = *((FARPROC*)pp + 1); RunAsm(); }
void Proxy_D3D12SerializeRootSignature() { funcAddr = *((FARPROC*)pp + 2); RunAsm(); }
// Declaring the functions like this does not work and causes an instant crash, seems to be unique to proxying D3D12...
// No popups when crashing, crash cause is an access violation when checking with debugger
// Game in question only imports these 3 functions, proxying everything does not make a difference.
void Proxy_D3D12CreateDevice() { funcAddr = p[0]; RunAsm(); }
void Proxy_D3D12GetDebugInterface() { funcAddr = p[1]; RunAsm(); }
void Proxy_D3D12SerializeRootSignature() { funcAddr = p[2]; RunAsm(); }
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
originalDll = LoadLibraryEx(L".\\d3d12.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
p[0] = GetProcAddress(originalDll, "D3D12CreateDevice");
p[1] = GetProcAddress(originalDll, "D3D12GetDebugInterface");
p[2] = GetProcAddress(originalDll, "D3D12SerializeRootSignature");
}
return TRUE;
}
This weird behavior may or may not be related to the crashing.
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed