-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A Steam offline emulator that allows you to play Steam games in SinglePlayer.
- Loading branch information
Rat43
committed
Oct 2, 2019
1 parent
570373e
commit 167bfad
Showing
477 changed files
with
69,524 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#pragma once | ||
#include <Windows.h> | ||
#include <iostream> | ||
#include <stdint.h> | ||
#include <cstdint> | ||
#include <ctime> | ||
#include <vector> | ||
#include <chrono> | ||
#include <fstream> | ||
#include <algorithm> | ||
#include "ColdManager.h" | ||
#include "CSteamCallbacks.h" | ||
#include <mutex> | ||
#define EXPORTMYFUNC extern "C" __declspec(dllexport) // Define structures and interface names : ) | ||
|
||
#define STEAMAPPID "steam_appid.txt" | ||
#define EMPTY "Nothing" | ||
#define STEAM_NOTINSTALLED "NoSteam" | ||
#define INI "ColdAPI.ini" | ||
#ifdef _WIN64 | ||
#define STEAMOVERLAY "gameoverlayrenderer64.dll" | ||
#define STEAMCLIENT "steamclient64.dll" | ||
#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 STEAMAPI "steam_api" | ||
#define Steamregistry "Software\\Valve\\Steam" | ||
#define ORGAPI "steam_api.org" | ||
#endif | ||
#define INTERFACE_NOT_FOUND 10 | ||
#define SUCCES_LOADED 1 | ||
|
||
|
||
enum CSteamInterface | ||
{ | ||
STEAM_APPLIST, | ||
STEAM_APPS, | ||
STEAM_APPTICKET, | ||
STEAM_CLIENT, | ||
STEAM_CONTENTSERVER, | ||
STEAM_CONTROLLER, | ||
STEAM_FRIENDS, | ||
STEAM_PARENTALSETTINGS, | ||
STEAM_GAMECOORDINATOR, | ||
STEAM_GAMESERVER, | ||
STEAM_GAMESERVERSTATS, | ||
STEAM_MATCHMAKING, | ||
STEAM_MATCHMAKINGSERVERS, | ||
STEAM_MUSIC, | ||
STEAM_NETWORKING, | ||
STEAM_REMOTESTORAGE, | ||
STEAM_USER, | ||
STEAM_USERSTATS, | ||
STEAM_UTILS, | ||
STEAM_BILLING, | ||
STEAM_GAMESERVERHTTP, | ||
STEAM_GAMESERVERINVENTORY, | ||
STEAM_GAMESERVERNETWORKING, | ||
STEAM_GAMESERVERUGC, | ||
STEAM_GAMESERVERUTILS, | ||
STEAM_HTMLSURFACE, | ||
STEAM_HTTP, | ||
STEAM_INVENTORY, | ||
STEAM_MUSICREMOTE, | ||
STEAM_SCREENSHOTS, | ||
STEAM_UNIFIEDMESSAGES, | ||
STEAM_UGC, | ||
STEAM_VIDEO, | ||
STEAM_MASTERSERVERUPDATER, | ||
STEAM_GAMESEARCH, | ||
STEAM_INPUT, | ||
STEAM_PARTIES, | ||
STEAM_REMOTEPLAY | ||
|
||
}; | ||
|
||
|
||
|
||
|
||
namespace Steam_Config // Steam configuration | ||
{ | ||
extern char Username[40]; | ||
extern uint32_t AppId; | ||
extern uint32_t AppBuildId; | ||
extern uint64_t UserID; | ||
|
||
extern char SaveDirectory[0x400]; | ||
extern char UGCDirectotry[0x400]; | ||
extern char Language[40]; | ||
|
||
extern bool OnlineMod; | ||
extern bool UnlockAllDLCS; | ||
extern bool LowViolence; | ||
extern bool RemoteStorage; | ||
extern bool LoadOverLay; | ||
extern bool StubBypass; | ||
} | ||
struct InterfaceInfo | ||
{ | ||
CSteamInterface SteamType; | ||
int Version; | ||
}; | ||
struct InterfaceData | ||
{ | ||
CSteamInterface SteamType; | ||
std::string key; | ||
std::string name; | ||
bool isstarted; | ||
int Version; | ||
InterfaceData(void* p = NULL, bool t = false) : datapointer(p), isstarted(t) {} | ||
void* datapointer; | ||
|
||
}; | ||
struct SteamContext | ||
{ | ||
FARPROC InitContext; | ||
ULONG_PTR Flag; | ||
ULONG_PTR Out; | ||
}; | ||
|
||
// public vars | ||
extern std::vector<std::string> FilesMatrix; | ||
extern HMODULE SteamApimod; | ||
extern char Steamapipath[MAX_PATH]; | ||
extern unsigned char TicketData[128]; | ||
// Crazy? ;P Change it if you don't like. :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#include "CSteamCallbacks.h" | ||
|
||
|
||
namespace SteamCallback | ||
{ | ||
std::unordered_map<uint64_t, bool> _Calls; // variables | ||
std::unordered_map<uint64_t, CCallbackBase*> ResultHandlersBuffers; | ||
std::vector<CSteamAPIResult_t> ResultsBuffer; | ||
std::vector<CCallbackBase*> CallbacksBuffer; | ||
int _CallID; | ||
std::mutex Thread; | ||
|
||
void RunCallbacks() | ||
{ | ||
// Lock | ||
Thread.lock(); | ||
|
||
// Loop to our stored callresults. | ||
auto criter = ResultsBuffer.begin(); | ||
while (criter != ResultsBuffer.end()) | ||
{ | ||
// Scan from the request callresult IDs and run its callback. | ||
auto ResultHws = ResultHandlersBuffers.find(criter->Call); | ||
if (ResultHws != ResultHandlersBuffers.end()) { | ||
// Run the callback if was marked active. | ||
if (_Calls[criter->Call] == true) | ||
ResultHandlersBuffers[criter->Call]->Run(criter->Data, false, criter->Call); | ||
} | ||
// Scan from the callback type. | ||
auto cbiter = CallbacksBuffer.begin(); | ||
while (cbiter != CallbacksBuffer.end()) | ||
{ | ||
CCallbackBase* CallBack = *cbiter; | ||
if (CallBack && CallBack->GetICallback() == criter->Type) | ||
if (_Calls[criter->Call] == true) | ||
CallBack->Run(criter->Data); | ||
++cbiter; | ||
} | ||
++criter; | ||
} | ||
ResultsBuffer.clear(); | ||
Thread.unlock(); | ||
} | ||
void RegisterCallback(CCallbackBase* handler, int callbackID) | ||
{ | ||
// Store the new callback ID. | ||
handler->SetICallback(callbackID); | ||
// Store in the vector | ||
CallbacksBuffer.push_back(handler); | ||
} | ||
void RegisterCallResult(CCallbackBase* result, uint64_t call) | ||
{ | ||
// Store the callresult from its ID. | ||
ResultHandlersBuffers[call] = result; | ||
} | ||
void UnregisterCallback(CCallbackBase* handler, int callback) | ||
{ | ||
auto iter = CallbacksBuffer.begin(); | ||
|
||
// Loop untill we find the asked callback to remove based on the ID. | ||
while (iter != CallbacksBuffer.end()) | ||
{ | ||
CCallbackBase* handleriter = *iter; | ||
if (handleriter && handleriter->GetICallback() == callback) | ||
{ | ||
CallbacksBuffer.erase(iter); | ||
break; | ||
} | ||
++iter; | ||
} | ||
} | ||
void UnregisterCallResult(CCallbackBase* result, uint64_t call) | ||
{ | ||
// Remove the callresult handler based on the ID. | ||
ResultHandlersBuffers.erase(call); | ||
} | ||
uint64_t RegisterCall(bool MarkActive) | ||
{ | ||
// Return a new callresult id and set the status. | ||
++_CallID; | ||
_Calls[_CallID] = MarkActive; | ||
return _CallID; | ||
} | ||
void CreateNewRequest(void* data, int size, int type, uint64_t call) | ||
{ | ||
Thread.lock(); | ||
// Create a new Callresult request with its callback stored. | ||
CSteamAPIResult_t cres; | ||
cres.Call = call; | ||
cres.Type = type; | ||
cres.Size = size; | ||
cres.Data = data; | ||
|
||
// Save our filled "buffer" in our public vector | ||
ResultsBuffer.push_back(cres); | ||
Thread.unlock(); | ||
} | ||
const char* GetCallbackName(int32_t ID) | ||
{ | ||
// You can add the names of the callbacks for debugging, but I believe is a bit redundant. | ||
return ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
#include "Bridge.h" | ||
|
||
class CCallbackBase | ||
{ | ||
public: | ||
CCallbackBase() { m_nCallbackFlags = 0; m_iCallback = 0; } | ||
// don't add a virtual destructor because we export this binary interface across dll's | ||
virtual void Run(void* pvParam) = 0; | ||
virtual void Run(void* pvParam, bool bIOFailure, unsigned long long hSteamAPICall) = 0; | ||
int GetICallback() { return m_iCallback; } | ||
// Change current callback ID. | ||
void SetICallback(int b) { m_iCallback = b; } | ||
virtual int GetCallbackSizeBytes() = 0; | ||
|
||
protected: | ||
enum { k_ECallbackFlagsRegistered = 0x01, k_ECallbackFlagsGameServer = 0x02 }; | ||
unsigned char m_nCallbackFlags; | ||
int m_iCallback; | ||
friend class CCallbackMgr; | ||
|
||
private: | ||
CCallbackBase(const CCallbackBase&); | ||
CCallbackBase& operator=(const CCallbackBase&); | ||
}; | ||
|
||
typedef struct | ||
{ | ||
void* Data; | ||
int32_t Size; | ||
int32_t Type; | ||
uint64_t Call; | ||
} CSteamAPIResult_t; | ||
|
||
namespace SteamCallback | ||
{ | ||
void RunCallbacks(); | ||
void RegisterCallback(CCallbackBase* handler, int callback); | ||
void RegisterCallResult(CCallbackBase* result, uint64_t call); | ||
void UnregisterCallback(CCallbackBase* handler, int callback); | ||
void UnregisterCallResult(CCallbackBase* result, uint64_t call); | ||
uint64_t RegisterCall(bool MarkActive); | ||
void CreateNewRequest(void* data, int size, int type, uint64_t call); | ||
const char* GetCallbackName(int ID); | ||
} |
Oops, something went wrong.