Skip to content

Commit

Permalink
Added steamclient emulation and improved the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rat43 committed Oct 28, 2019
1 parent 0c10947 commit b88e24e
Show file tree
Hide file tree
Showing 509 changed files with 16,484 additions and 472 deletions.
11 changes: 11 additions & 0 deletions src/Bridge.h → src/ColdAPI_Steam/Bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ColdManager.h"
#include "CSteamCallbacks.h"
#include <mutex>
#include <map>
#include <stdio.h>
#include <wchar.h>

#define EXPORTMYFUNC extern "C" __declspec(dllexport) // Define structures and interface names : )

#define STEAMAPPID "steam_appid.txt"
Expand All @@ -20,12 +24,14 @@
#ifdef _WIN64
#define STEAMOVERLAY "gameoverlayrenderer64.dll"
#define STEAMCLIENT "steamclient64.dll"
#define STEAMCLIENTREG "SteamClientDll64"
#define STEAMAPI "steam_api64"
#define Steamregistry "Software\\Wow6432Node\\Valve\\Steam"
#define ORGAPI "steam_api64.org"
#else
#define STEAMOVERLAY "gameoverlayrenderer.dll"
#define STEAMCLIENT "steamclient.dll"
#define STEAMCLIENTREG "SteamClientDll"
#define STEAMAPI "steam_api"
#define Steamregistry "Software\\Valve\\Steam"
#define ORGAPI "steam_api.org"
Expand Down Expand Up @@ -97,6 +103,10 @@ namespace Steam_Config // Steam configuration
extern bool RemoteStorage;
extern bool LoadOverLay;
extern bool StubBypass;
extern bool InterfaceNFound;

extern bool ClientEmulation;
extern bool HookForInjection;
}
struct InterfaceInfo
{
Expand Down Expand Up @@ -125,5 +135,6 @@ struct SteamContext
extern std::vector<std::string> FilesMatrix;
extern HMODULE SteamApimod;
extern char Steamapipath[MAX_PATH];
extern char SteamModule[MAX_PATH];
extern unsigned char TicketData[128];
// Crazy? ;P Change it if you don't like. :)
67 changes: 67 additions & 0 deletions src/CSteamCallbacks.cpp → src/ColdAPI_Steam/CSteamCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace SteamCallback
std::vector<CCallbackBase*> CallbacksBuffer;
int _CallID;
std::mutex Thread;
void* Buffer = nullptr;
std::vector<CSteamAPIResult_t>::iterator CurrentCB;

void RunCallbacks()
{
Expand Down Expand Up @@ -100,4 +102,69 @@ namespace SteamCallback
// You can add the names of the callbacks for debugging, but I believe is a bit redundant.
return "";
}

bool CCGetCallBack(void* pCallbackMsg)
{
// Assuming we want to Run only callresults as we're returning its callresult ID by the interfaces functions.
if (pCallbackMsg > NULL)
{
CurrentCB = ResultsBuffer.begin();

if (CurrentCB != ResultsBuffer.end() && !ResultsBuffer.empty())
{
CCallbackMsg_t* CBM = (CCallbackMsg_t*)pCallbackMsg;
if (Buffer == nullptr)
Buffer = std::malloc(sizeof(CCSteamAPICallCompleted_t));
// We return a random item from our callresult vector to run
int randomCB = std::rand() % ResultsBuffer.size();
std::advance(CurrentCB, randomCB);

if (CurrentCB != ResultsBuffer.end() && randomCB <= ResultsBuffer.size())
{
CSteamAPIResult_t cresC = *CurrentCB;
CBM->m_iCallback = 703;
CBM->m_cubParam = cresC.Size;
CBM->m_hSteamUser = 1;

if (Buffer > nullptr) {
CCSteamAPICallCompleted_t* cst = (CCSteamAPICallCompleted_t*)Buffer;
cst->m_cubParam = cresC.Size;
cst->m_hAsyncCall = cresC.Call;
cst->m_iCallback = cresC.Type;
return true;
}
}
}
}
return false;
}
bool CCGetAPICallResult(uint64_t hSteamAPICall, void* pCallback, int cubCallback, int iCallbackExpected, bool* pbFailed)
{
if (hSteamAPICall && pCallback > NULL)
{
// Loop to our stored callresults.
auto criter = ResultsBuffer.begin();
while (criter != ResultsBuffer.end())
{
CSteamAPIResult_t cresC = *criter;
if (cresC.Call == hSteamAPICall && cresC.Type == iCallbackExpected && cresC.Size == cubCallback)
{
// Copy our callback data in the requested buffer
std::memcpy(pCallback, cresC.Data, cresC.Size);
if(pbFailed > NULL)
*pbFailed = false;
return true;
}
++criter;
}
}
if (pbFailed > NULL)
*pbFailed = true;
return false;
}
void FreeCB()
{
if(!ResultsBuffer.empty())
ResultsBuffer.erase(CurrentCB);
}
}
18 changes: 18 additions & 0 deletions src/CSteamCallbacks.h → src/ColdAPI_Steam/CSteamCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ typedef struct
int32_t Type;
uint64_t Call;
} CSteamAPIResult_t;
struct CCallbackMsg_t
{
int32_t m_hSteamUser;
int m_iCallback;
unsigned char* m_pubParam;
int m_cubParam;
};
struct CCSteamAPICallCompleted_t
{
enum { k_iCallback = 700 + 3 };
uint64_t m_hAsyncCall;
int m_iCallback;
uint32_t m_cubParam;
};

namespace SteamCallback
{
Expand All @@ -42,4 +56,8 @@ namespace SteamCallback
uint64_t RegisterCall(bool MarkActive);
void CreateNewRequest(void* data, int size, int type, uint64_t call);
const char* GetCallbackName(int ID);

bool CCGetCallBack(void* pCallbackMsg);
bool CCGetAPICallResult(uint64_t hSteamAPICall, void* pCallback, int cubCallback, int iCallbackExpected, bool* pbFailed);
void FreeCB();
}
Loading

0 comments on commit b88e24e

Please sign in to comment.