forked from Detanup01/gbe_fork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsteamclient.cpp
More file actions
38 lines (31 loc) · 1.05 KB
/
steamclient.cpp
File metadata and controls
38 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#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 = 1; // IFACE_FAILED
return nullptr;
}
auto create_interface = (fn_create_interface_t)GetProcAddress(steam_api, "SteamInternal_CreateInterface");
// https://github.com/ValveSoftware/source-sdk-2013/blob/57a8b644af418c691f1fba45791019cf2367dedd/src/public/tier1/interface.h#L156-L160
if (!create_interface) {
if (pReturnCode) *pReturnCode = 1; // IFACE_FAILED
return nullptr;
}
auto ptr = create_interface(pName);
if (pReturnCode) {
if (ptr) {
*pReturnCode = 0; // IFACE_OK
} else {
*pReturnCode = 1; // IFACE_FAILED
}
}
return ptr;
}