-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The wrapper now checks for the existence of a "real" dplayx.dll circumventing the Windows missing dependencies prompt. If real dplayx.dll is found, it will pass through to that, so users who have DirectPlay installed can now play online without having to delete files from the game directory.
- Loading branch information
1 parent
f6e4e5c
commit ec3d660
Showing
7 changed files
with
188 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
defines { | ||
"rsc_FullName=\"DirectPlay Stub\"", | ||
"rsc_MinorVersion=0", | ||
"rsc_MinorVersion=1", | ||
"rsc_RevisionID=1", | ||
"rsc_BuildID=0", | ||
"rsc_Copyright=\"2023\"" | ||
"rsc_Copyright=\"2023-2024\"" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
LIBRARY DPLAYX | ||
EXPORTS | ||
DirectPlayCreate=DirectPlayCreate_Stub @1 | ||
DirectPlayEnumerateA=DirectPlayEnumerate_Stub @2 | ||
DirectPlayEnumerateW=DirectPlayEnumerate_Stub @3 | ||
DirectPlayLobbyCreateA=DirectPlayLobbyCreate_Stub @4 | ||
DirectPlayLobbyCreateW=DirectPlayLobbyCreate_Stub @5 | ||
DirectPlayEnumerate=DirectPlayEnumerate_Stub @9 | ||
DirectPlayCreate @1 | ||
DirectPlayEnumerateA @2 | ||
DirectPlayEnumerateW @3 | ||
DirectPlayLobbyCreateA @4 | ||
DirectPlayLobbyCreateW @5 | ||
DirectPlayEnumerate @9 | ||
gdwDPlaySPRefCount @11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "stubs.h" | ||
|
||
HRESULT WINAPI DirectPlayCreate_Stub(LPGUID lpGUID, LPVOID* lplpDP, IUnknown* lpUnk) | ||
{ | ||
if (lpUnk != nullptr) | ||
{ | ||
return CLASS_E_NOAGGREGATION; | ||
} | ||
if (lpGUID == nullptr || lplpDP == nullptr) | ||
{ | ||
return DPERR_INVALIDPARAM; | ||
} | ||
|
||
*lplpDP = nullptr; | ||
return DPERR_UNSUPPORTED; | ||
} | ||
|
||
HRESULT WINAPI DirectPlayEnumerate_Stub(LPVOID lpEnumCallback, LPVOID /*lpContext*/) | ||
{ | ||
if (lpEnumCallback == nullptr) | ||
{ | ||
return DPERR_INVALIDPARAM; | ||
} | ||
return DP_OK; | ||
} | ||
|
||
HRESULT WINAPI DirectPlayLobbyCreate_Stub(LPGUID lpGUIDDSP, LPVOID* lplpDPL, IUnknown* lpUnk, void* lpData, DWORD dwDataSize) | ||
{ | ||
if (lpGUIDDSP != nullptr && *lpGUIDDSP != GUID_NULL) | ||
{ | ||
return DPERR_INVALIDPARAM; | ||
} | ||
if (lpUnk != nullptr) | ||
{ | ||
return CLASS_E_NOAGGREGATION; | ||
} | ||
if (lpData != nullptr || dwDataSize != 0) | ||
{ | ||
return DPERR_INVALIDPARAM; | ||
} | ||
|
||
// lplpDPL is not checked for validity in the real DLL... | ||
*lplpDPL = nullptr; | ||
return DPERR_UNSUPPORTED; | ||
} | ||
|
||
DWORD gdwDPlaySPRefCount = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#define NOMINMAX | ||
|
||
#include <windows.h> | ||
#include <combaseapi.h> | ||
|
||
#include "../dplay-stub.h" | ||
|
||
HRESULT WINAPI DirectPlayCreate_Stub(LPGUID lpGUID, LPVOID* lplpDP, IUnknown* lpUnk); | ||
HRESULT WINAPI DirectPlayEnumerate_Stub(LPVOID lpEnumCallback, LPVOID /*lpContext*/); | ||
HRESULT WINAPI DirectPlayLobbyCreate_Stub(LPGUID lpGUIDDSP, LPVOID* lplpDPL, IUnknown* lpUnk, void* lpData, DWORD dwDataSize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "exportChecker.h" | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#define NOMINMAX | ||
|
||
#include <windows.h> | ||
|
||
#include <vector> | ||
|
||
bool CheckExports(const wchar_t* path, std::initializer_list<std::string_view> exports) | ||
{ | ||
std::vector<std::string_view> exportsToCheck(exports); | ||
|
||
HMODULE file = LoadLibraryExW(path, nullptr, LOAD_LIBRARY_AS_IMAGE_RESOURCE); | ||
if (file != nullptr) | ||
{ | ||
DWORD_PTR instance = reinterpret_cast<DWORD_PTR>(file) & ~3; | ||
const PIMAGE_NT_HEADERS ntHeader = reinterpret_cast<PIMAGE_NT_HEADERS>(instance + reinterpret_cast<PIMAGE_DOS_HEADER>(instance)->e_lfanew); | ||
const DWORD exportVA = ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; | ||
if (exportVA != 0) | ||
{ | ||
const PIMAGE_EXPORT_DIRECTORY exportDirectory = reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>(instance + exportVA); | ||
const DWORD* functionNames = reinterpret_cast<DWORD*>(instance + exportDirectory->AddressOfNames); | ||
for (DWORD i = 0; i < exportDirectory->NumberOfNames; i++) | ||
{ | ||
const char* nameRva = reinterpret_cast<const char*>(instance + functionNames[i]); | ||
auto it = std::find(exportsToCheck.begin(), exportsToCheck.end(), nameRva); | ||
if (it != exportsToCheck.end()) | ||
{ | ||
exportsToCheck.erase(it); | ||
if (exportsToCheck.empty()) | ||
{ | ||
// Early out if all required functions are found | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
FreeLibrary(file); | ||
} | ||
return exportsToCheck.empty(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
#include <initializer_list> | ||
#include <string_view> | ||
|
||
bool CheckExports(const wchar_t* path, std::initializer_list<std::string_view> exports); |