1
0
Fork 0
mirror of https://github.com/Detanup01/gbe_fork.git synced 2025-08-13 10:55:34 +02:00

Merge pull request #306 from otavepto/patch/client-stub

Update steamclient stub to set return code properly + enforce `cdecl` convention
This commit is contained in:
Detanup01 2025-07-27 21:28:23 +02:00 committed by GitHub
commit 1766112c56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,21 +1,37 @@
#define WIN32_LEAN_AND_MEAN
// #include "dll.h"
#define WIN32_LEAN_AND_MEAN
#include "Windows.h"
#ifdef _WIN64
#define DLL_NAME "steam_api64.dll"
#define DLL_NAME "steam_api64.dll"
#else
#define DLL_NAME "steam_api.dll"
#define DLL_NAME "steam_api.dll"
#endif
extern "C" __declspec(dllexport) void *CreateInterface(const char *pName, int *pReturnCode)
extern "C" __declspec( dllexport ) void* __cdecl CreateInterface( const char *pName, int *pReturnCode )
{
// PRINT_DEBUG("%s", pName);
using fn_create_interface_t = void* (__cdecl *)(const char *);
HMODULE steam_api = LoadLibraryA(DLL_NAME);
auto steam_api = LoadLibraryA(DLL_NAME);
if (!steam_api) {
if (pReturnCode) *pReturnCode = 0;
return nullptr;
}
void *(__stdcall * create_interface)(const char *) = reinterpret_cast<void *(__stdcall *)(const char *)>(GetProcAddress(steam_api, "SteamInternal_CreateInterface"));
auto create_interface = (fn_create_interface_t)GetProcAddress(steam_api, "SteamInternal_CreateInterface");
if (!create_interface) {
if (pReturnCode) *pReturnCode = 0;
return nullptr;
}
return create_interface(pName);
auto ptr = create_interface(pName);
if (pReturnCode) {
if (ptr) {
*pReturnCode = 1;
} else {
*pReturnCode = 0;
}
}
return ptr;
}