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:
commit
1766112c56
1 changed files with 25 additions and 9 deletions
|
@ -1,21 +1,37 @@
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
// #include "dll.h"
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include "Windows.h"
|
#include "Windows.h"
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
#define DLL_NAME "steam_api64.dll"
|
#define DLL_NAME "steam_api64.dll"
|
||||||
#else
|
#else
|
||||||
#define DLL_NAME "steam_api.dll"
|
#define DLL_NAME "steam_api.dll"
|
||||||
#endif
|
#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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue