1
0
Fork 0
mirror of https://github.com/Detanup01/gbe_fork.git synced 2025-08-07 16:15:51 +02:00
gbe_fork/steamclient/steamclient.cpp

37 lines
879 B
C++

#define WIN32_LEAN_AND_MEAN
#include "Windows.h"
#ifdef _WIN64
#define DLL_NAME "steam_api64.dll"
#else
#define DLL_NAME "steam_api.dll"
#endif
extern "C" __declspec( dllexport ) void* __cdecl CreateInterface( const char *pName, int *pReturnCode )
{
using fn_create_interface_t = void* (__cdecl *)(const char *);
auto steam_api = LoadLibraryA(DLL_NAME);
if (!steam_api) {
if (pReturnCode) *pReturnCode = 0;
return nullptr;
}
auto create_interface = (fn_create_interface_t)GetProcAddress(steam_api, "SteamInternal_CreateInterface");
if (!create_interface) {
if (pReturnCode) *pReturnCode = 0;
return nullptr;
}
auto ptr = create_interface(pName);
if (pReturnCode) {
if (ptr) {
*pReturnCode = 1;
} else {
*pReturnCode = 0;
}
}
return ptr;
}