-
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 55caab9
Showing
6 changed files
with
202 additions
and
38 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,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,58 @@ | ||
#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); | ||
|
||
HANDLE file = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); | ||
if (file != INVALID_HANDLE_VALUE) | ||
{ | ||
HANDLE fileMapping = CreateFileMappingW(file, nullptr, PAGE_READONLY, 0, 0, nullptr); | ||
if (fileMapping != nullptr) | ||
{ | ||
void* view = MapViewOfFile(fileMapping, FILE_MAP_READ, 0, 0, 0); | ||
if (view != nullptr) | ||
{ | ||
DWORD_PTR instance = reinterpret_cast<DWORD_PTR>(view); | ||
const PIMAGE_NT_HEADERS ntHeader = reinterpret_cast<PIMAGE_NT_HEADERS>(instance + reinterpret_cast<PIMAGE_DOS_HEADER>(instance)->e_lfanew); | ||
if (ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress != 0) | ||
{ | ||
const PIMAGE_SECTION_HEADER textSection = IMAGE_FIRST_SECTION(ntHeader); | ||
auto RVAToAddress = [offset = instance - textSection->VirtualAddress + textSection->PointerToRawData](DWORD rva) | ||
{ | ||
return offset + rva; | ||
}; | ||
|
||
const PIMAGE_EXPORT_DIRECTORY exportDirectory = reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>(RVAToAddress(ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress)); | ||
const DWORD* functionNames = reinterpret_cast<DWORD*>(RVAToAddress(exportDirectory->AddressOfNames)); | ||
for (DWORD i = 0; i < exportDirectory->NumberOfNames; i++) | ||
{ | ||
const char* nameRva = reinterpret_cast<const char*>(RVAToAddress(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; | ||
} | ||
} | ||
} | ||
} | ||
|
||
UnmapViewOfFile(view); | ||
} | ||
CloseHandle(fileMapping); | ||
} | ||
CloseHandle(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); |