Skip to content

Commit

Permalink
added /NODEFAULTLIB
Browse files Browse the repository at this point in the history
  • Loading branch information
maltsevda committed May 18, 2019
1 parent b18607d commit 9d14b19
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions d3d9.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,18 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<ExceptionHandling>false</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>d3d9.def</ModuleDefinitionFile>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>DllMain</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -124,6 +130,9 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;D3D9_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<ExceptionHandling>false</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -132,6 +141,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>d3d9.def</ModuleDefinitionFile>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>DllMain</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand Down
27 changes: 26 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ extern "C" IDirect3D9* WINAPI Fake_Direct3DCreate9(UINT SDKVersion)
return new FakeDirect3D9(pRealDirect3D9);
}

// error LNK2019: unresolved external symbol _memcpy referenced in function _DllMain@12
void MyCopyMemory(void* pDst, const void* pSrc, size_t uiSize)
{
BYTE* pDstB = (BYTE*)pDst;
const BYTE* pSrcB = (const BYTE*)pSrc;
for (UINT i = 0; i < uiSize; ++i)
pDstB[i] = pSrcB[i];
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
Expand All @@ -54,7 +63,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
WCHAR path[MAX_PATH];
UINT length = GetSystemDirectoryW(path, MAX_PATH - 10);
CopyMemory(path + length, L"\\d3d9.dll", sizeof(WCHAR) * 11);
MyCopyMemory(path + length, L"\\d3d9.dll", sizeof(WCHAR) * 10);
d3d9dll.hDll = LoadLibraryW(path);
if (!d3d9dll.hDll)
{
Expand Down Expand Up @@ -84,3 +93,19 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
}
return TRUE;
}

// error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
void* __cdecl operator new(unsigned int size)
{
return HeapAlloc(GetProcessHeap(), 0, size);
}

// error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z)
void __cdecl operator delete(void* ptr, unsigned int)
{
HeapFree(GetProcessHeap(), 0, ptr);
}

// error LNK2001: unresolved external symbol __fltused
// it should be a single underscore since the double one is the mangled name
extern "C" int _fltused = 0;

0 comments on commit 9d14b19

Please sign in to comment.