From 938e3a6a2548f0b8982107ada5726288d2cb0485 Mon Sep 17 00:00:00 2001 From: a Date: Sat, 26 Jul 2025 17:59:53 +0300 Subject: [PATCH] update steamclient stub to set return code properly --- steamclient/steamclient.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/steamclient/steamclient.cpp b/steamclient/steamclient.cpp index a185c616..4dbbce4a 100644 --- a/steamclient/steamclient.cpp +++ b/steamclient/steamclient.cpp @@ -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(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; }