Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Commit

Permalink
Add necessary exports for Sonic Generations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajidur78 committed Jan 10, 2020
1 parent c279347 commit 93ca8f0
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/LostCodeLoader/Direct3DHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma warning(disable:6387)

void* DirectXFuncs[6];
void* DirectXFuncs[8];
HMODULE hD3D;

void HookDirectX()
Expand All @@ -19,8 +19,10 @@ void HookDirectX()
DirectXFuncs[1] = GetProcAddress(hD3D, "D3DPERF_GetStatus");
DirectXFuncs[2] = GetProcAddress(hD3D, "D3DPERF_BeginEvent");
DirectXFuncs[3] = GetProcAddress(hD3D, "D3DPERF_EndEvent");
DirectXFuncs[4] = GetProcAddress(hD3D, "Direct3DCreate9");
DirectXFuncs[5] = GetProcAddress(hD3D, "Direct3DCreate9Ex");
DirectXFuncs[4] = GetProcAddress(hD3D, "D3DPERF_QueryRepeatFrame");
DirectXFuncs[5] = GetProcAddress(hD3D, "D3DPERF_SetOptions");
DirectXFuncs[6] = GetProcAddress(hD3D, "Direct3DCreate9");
DirectXFuncs[7] = GetProcAddress(hD3D, "Direct3DCreate9Ex");
}

extern "C"
Expand All @@ -45,13 +47,23 @@ extern "C"
__asm jmp dword ptr[DirectXFuncs + 12]
}

void __declspec(naked) __declspec(dllexport) Direct3DCreate9()
void __declspec(naked) __declspec(dllexport) D3DPERF_QueryRepeatFrame()
{
__asm jmp dword ptr[DirectXFuncs + 16]
}

HRESULT __declspec(naked) __declspec(dllexport) Direct3DCreate9Ex()
void __declspec(naked) __declspec(dllexport) D3DPERF_SetOptions()
{
__asm jmp dword ptr[DirectXFuncs + 20]
}

void __declspec(naked) __declspec(dllexport) Direct3DCreate9()
{
__asm jmp dword ptr[DirectXFuncs + 24]
}

HRESULT __declspec(naked) __declspec(dllexport) Direct3DCreate9Ex()
{
__asm jmp dword ptr[DirectXFuncs + 28]
}
}
100 changes: 100 additions & 0 deletions src/LostCodeLoader/LostCodeLoader.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,0,0
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "NeverFinishAnything"
VALUE "FileDescription", "Code loader for Sonic Lost World"
VALUE "FileVersion", "1.1.0.0"
VALUE "InternalName", "LostCodeLoader.dll"
VALUE "LegalCopyright", "Copyright (C) 2020"
VALUE "OriginalFilename", "LostCodeLoader.dll"
VALUE "ProductName", "Lost Code Loader"
VALUE "ProductVersion", "1.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

4 changes: 4 additions & 0 deletions src/LostCodeLoader/LostCodeLoader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
<ClInclude Include="helpers.h" />
<ClInclude Include="LostCodeLoader.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="configuration.cpp" />
Expand All @@ -187,6 +188,9 @@
<Project>{ec0293f5-4bcf-46b2-8133-18caea141c5b}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LostCodeLoader.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
8 changes: 8 additions & 0 deletions src/LostCodeLoader/LostCodeLoader.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<ClInclude Include="helpers.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
Expand All @@ -57,4 +60,9 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LostCodeLoader.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/LostCodeLoader/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void InitLoader()
INSTALL_HOOK(SteamAPI_IsSteamRunning);
HookDirectX();

// Create a Direct3D device and hook it's vtable
IDirect3D9Ex* d3d;
Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d);
INSTALL_VTABLE_HOOK(d3d, CreateDeviceEx, 20);
Expand Down Expand Up @@ -94,6 +95,7 @@ void InitLoader()
mod->Path = path.c_str();
ModsInfo->CurrentMod = mod;
ModsInfo->ModList->push_back(mod);

if (ConfigurationFile::open(path, &modConfig))
{
string dllName = modConfig.getString("Main", "DLLFile");
Expand Down
14 changes: 14 additions & 0 deletions src/LostCodeLoader/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by LostCodeLoader.rc

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

0 comments on commit 93ca8f0

Please sign in to comment.