Basic offline steamhttp emulation.
parent
120aa968b2
commit
f147638f99
|
@ -109,6 +109,13 @@ Build id:
|
||||||
Add a steam_settings\build_id.txt with the build id if the game doesn't show the correct build id and you want the emu to give it the correct one.
|
Add a steam_settings\build_id.txt with the build id if the game doesn't show the correct build id and you want the emu to give it the correct one.
|
||||||
An example can be found in steam_settings.EXAMPLE
|
An example can be found in steam_settings.EXAMPLE
|
||||||
|
|
||||||
|
SteamHTTP:
|
||||||
|
Add a steam_settings\http folder. The folder should contain the domain name and path to the files that will be returned by steamHTTP like so:
|
||||||
|
For example this url: https://en.wikipedia.org/wiki/Main_Page
|
||||||
|
Would be: steam_settings\http\en.wikipedia.org\wiki\Main_Page
|
||||||
|
The Main_Page file would contain the data returned by the steamHTTP api when it tries to access: https://en.wikipedia.org/wiki/Main_Page
|
||||||
|
An example that was made for payday 2 can be found in steam_settings.EXAMPLE
|
||||||
|
|
||||||
|
|
||||||
Support for CPY steam_api(64).dll cracks: See the build in the experimental folder.
|
Support for CPY steam_api(64).dll cracks: See the build in the experimental folder.
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,32 @@ Steam_Http_Request *Steam_HTTP::get_request(HTTPRequestHandle hRequest)
|
||||||
HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod, const char *pchAbsoluteURL )
|
HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod, const char *pchAbsoluteURL )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("CreateHTTPRequest %i %s\n", eHTTPRequestMethod, pchAbsoluteURL);
|
PRINT_DEBUG("CreateHTTPRequest %i %s\n", eHTTPRequestMethod, pchAbsoluteURL);
|
||||||
|
if (!pchAbsoluteURL) return INVALID_HTTPREQUEST_HANDLE;
|
||||||
|
std::string url = pchAbsoluteURL;
|
||||||
|
unsigned url_index = 0;
|
||||||
|
if (url.rfind("https://", 0) == 0) {
|
||||||
|
url_index = sizeof("https://") - 1;
|
||||||
|
} else if (url.rfind("http://", 0) == 0) {
|
||||||
|
url_index = sizeof("http://") - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Steam_Http_Request request;
|
||||||
|
if (url_index) {
|
||||||
|
if (url[url.size() - 1] == '/') url += "index.html";
|
||||||
|
std::string file_path = Local_Storage::get_game_settings_path() + "http/" + url.substr(url_index);
|
||||||
|
unsigned long long file_size = file_size_(file_path);
|
||||||
|
if (file_size) {
|
||||||
|
request.response.resize(file_size);
|
||||||
|
long long read = Local_Storage::get_file_data(file_path, (char *)request.response.data(), file_size, 0);
|
||||||
|
if (read < 0) read = 0;
|
||||||
|
if (read != file_size) request.response.resize(read);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
static HTTPRequestHandle h;
|
static HTTPRequestHandle h;
|
||||||
++h;
|
++h;
|
||||||
struct Steam_Http_Request request;
|
|
||||||
request.handle = h;
|
request.handle = h;
|
||||||
request.context_value = 0;
|
request.context_value = 0;
|
||||||
|
|
||||||
|
@ -84,7 +107,7 @@ bool Steam_HTTP::SetHTTPRequestNetworkActivityTimeout( HTTPRequestHandle hReques
|
||||||
// return false if the handle is invalid or the request is already sent.
|
// return false if the handle is invalid or the request is already sent.
|
||||||
bool Steam_HTTP::SetHTTPRequestHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, const char *pchHeaderValue )
|
bool Steam_HTTP::SetHTTPRequestHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, const char *pchHeaderValue )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("SetHTTPRequestHeaderValue\n");
|
PRINT_DEBUG("SetHTTPRequestHeaderValue %s %s\n", pchHeaderName, pchHeaderValue);
|
||||||
Steam_Http_Request *request = get_request(hRequest);
|
Steam_Http_Request *request = get_request(hRequest);
|
||||||
if (!request) {
|
if (!request) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -122,12 +145,18 @@ bool Steam_HTTP::SendHTTPRequest( HTTPRequestHandle hRequest, SteamAPICall_t *pC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct HTTPRequestCompleted_t data;
|
struct HTTPRequestCompleted_t data = {};
|
||||||
data.m_hRequest = request->handle;
|
data.m_hRequest = request->handle;
|
||||||
data.m_ulContextValue = request->context_value;
|
data.m_ulContextValue = request->context_value;
|
||||||
data.m_bRequestSuccessful = false;
|
if (request->response.size() == 0) {
|
||||||
data.m_eStatusCode = k_EHTTPStatusCode404NotFound;
|
data.m_bRequestSuccessful = false;
|
||||||
data.m_unBodySize = request->response.size();
|
data.m_eStatusCode = k_EHTTPStatusCode404NotFound;
|
||||||
|
data.m_unBodySize = request->response.size();
|
||||||
|
} else {
|
||||||
|
data.m_bRequestSuccessful = true;
|
||||||
|
data.m_eStatusCode = k_EHTTPStatusCode200OK;
|
||||||
|
data.m_unBodySize = request->response.size();
|
||||||
|
}
|
||||||
|
|
||||||
if (pCallHandle) {
|
if (pCallHandle) {
|
||||||
*pCallHandle = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1);
|
*pCallHandle = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1);
|
||||||
|
@ -245,6 +274,7 @@ bool Steam_HTTP::GetHTTPStreamingResponseBodyData( HTTPRequestHandle hRequest, u
|
||||||
bool Steam_HTTP::ReleaseHTTPRequest( HTTPRequestHandle hRequest )
|
bool Steam_HTTP::ReleaseHTTPRequest( HTTPRequestHandle hRequest )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("ReleaseHTTPRequest\n");
|
PRINT_DEBUG("ReleaseHTTPRequest\n");
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
|
|
||||||
auto c = std::begin(requests);
|
auto c = std::begin(requests);
|
||||||
while (c != std::end(requests)) {
|
while (c != std::end(requests)) {
|
||||||
|
@ -275,7 +305,7 @@ bool Steam_HTTP::GetHTTPDownloadProgressPct( HTTPRequestHandle hRequest, float *
|
||||||
// parameter will set the content-type header for the request so the server may know how to interpret the body.
|
// parameter will set the content-type header for the request so the server may know how to interpret the body.
|
||||||
bool Steam_HTTP::SetHTTPRequestRawPostBody( HTTPRequestHandle hRequest, const char *pchContentType, uint8 *pubBody, uint32 unBodyLen )
|
bool Steam_HTTP::SetHTTPRequestRawPostBody( HTTPRequestHandle hRequest, const char *pchContentType, uint8 *pubBody, uint32 unBodyLen )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("SetHTTPRequestRawPostBody\n");
|
PRINT_DEBUG("SetHTTPRequestRawPostBody %s\n", pchContentType);
|
||||||
Steam_Http_Request *request = get_request(hRequest);
|
Steam_Http_Request *request = get_request(hRequest);
|
||||||
if (!request) {
|
if (!request) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{"access_token":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","bans":null,"display_name":"","expires_in":3600,"is_comply":true,"jflgs":0,"namespace":"PD2","namespace_roles":null,"permissions":[],"platform_id":"","platform_user_id":"","roles":null,"scope":"account commerce social publishing analytics","token_type":"Bearer","user_id":"","xuid":""}
|
Loading…
Reference in New Issue