Skip to content

Commit

Permalink
Fixed some issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rat43 committed Oct 10, 2019
1 parent 167bfad commit 4adc957
Show file tree
Hide file tree
Showing 32 changed files with 546 additions and 136 deletions.
4 changes: 2 additions & 2 deletions src/CSteamCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ namespace SteamCallback
{
auto iter = CallbacksBuffer.begin();

// Loop untill we find the asked callback to remove based on the ID.
// Loop untill we find the asked callback to remove based on the callback itself.
while (iter != CallbacksBuffer.end())
{
CCallbackBase* handleriter = *iter;
if (handleriter && handleriter->GetICallback() == callback)
if (handleriter && handleriter == handler)
{
CallbacksBuffer.erase(iter);
break;
Expand Down
9 changes: 6 additions & 3 deletions src/ColdManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ namespace ColdAPI_DLC
{
if (ColdDLC_Config::DLCsCount > 0)
{
*pAppID = ColdDLC_Config::DLCsAPPID.at(iDLC);
*pbAvailable = true;
if(pAppID != NULL && pAppID > NULL)
*pAppID = ColdDLC_Config::DLCsAPPID.at(iDLC);
if(pbAvailable != NULL && pbAvailable > NULL)
*pbAvailable = true;
std::string Name = ColdDLC_Config::DLCsNames.at(iDLC);
std::memcpy(pchName, Name.c_str(), cchNameBufferSize);
if(pchName != NULL && pchName > NULL && cchNameBufferSize >= NULL)
std::memcpy(pchName, Name.c_str(), cchNameBufferSize);
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/INI example/ColdAPI.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[SteamProfile]
Username = ColdAPI
Username = Rat431
LowViolence = 0
Language = english
;------------------------
Expand Down
21 changes: 14 additions & 7 deletions src/InterfacesEmulation/SteamAppTicket001.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@ class SteamAppTicketIn001 : public ISteamAppTicket001
SLength--;
FSize = sizeof(uint32_t) + sizeof(uint64_t) + SLength;
}
std::memcpy(pvSignedTicket, &Steam_Config::AppId, sizeof(uint32_t));
std::memcpy((void*)((ULONG_PTR)pvSignedTicket + sizeof(uint32_t)), &Steam_Config::UserID, sizeof(uint64_t));
std::memcpy((void*)((ULONG_PTR)pvSignedTicket + sizeof(uint32_t) + sizeof(uint64_t)), Signature, SLength);
*piAppId = 0;
*piSteamId = sizeof(uint32_t);
*piSignature = sizeof(uint32_t) + sizeof(uint64_t);
*pcbSignature = SLength;
if (pvSignedTicket != NULL && pvSignedTicket > NULL)
{
std::memcpy(pvSignedTicket, &Steam_Config::AppId, sizeof(uint32_t));
std::memcpy((void*)((ULONG_PTR)pvSignedTicket + sizeof(uint32_t)), &Steam_Config::UserID, sizeof(uint64_t));
std::memcpy((void*)((ULONG_PTR)pvSignedTicket + sizeof(uint32_t) + sizeof(uint64_t)), Signature, SLength);
}
if(piAppId != NULL && piAppId > NULL)
*piAppId = 0;
if(piSteamId != NULL && piSteamId > NULL)
*piSteamId = sizeof(uint32_t);
if(piSignature != NULL && piSignature > NULL)
*piSignature = sizeof(uint32_t) + sizeof(uint64_t);
if(pcbSignature != NULL && pcbSignature > NULL)
*pcbSignature = SLength;
return FSize;
}
return NULL;
Expand Down
7 changes: 5 additions & 2 deletions src/InterfacesEmulation/SteamApps005.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ class SteamAppsIn005 : public ISteamApps005

uint32 GetAppInstallDir(AppId_t appID, char* pchFolder, uint32 cchFolderBufferSize)
{
GetCurrentDirectoryA(cchFolderBufferSize, pchFolder);
return cchFolderBufferSize;
if (pchFolder != NULL && pchFolder > NULL && cchFolderBufferSize >= NULL) {
GetCurrentDirectoryA(cchFolderBufferSize, pchFolder);
return cchFolderBufferSize;
}
return NULL;
}
bool BIsAppInstalled(AppId_t appID)
{
Expand Down
7 changes: 5 additions & 2 deletions src/InterfacesEmulation/SteamApps006.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ class SteamAppsIn006 : public ISteamApps006

uint32 GetAppInstallDir(AppId_t appID, char* pchFolder, uint32 cchFolderBufferSize)
{
GetCurrentDirectoryA(cchFolderBufferSize, pchFolder);
return cchFolderBufferSize;
if (pchFolder != NULL && pchFolder > NULL && cchFolderBufferSize >= NULL) {
GetCurrentDirectoryA(cchFolderBufferSize, pchFolder);
return cchFolderBufferSize;
}
return NULL;
}
bool BIsAppInstalled(AppId_t appID)
{
Expand Down
7 changes: 5 additions & 2 deletions src/InterfacesEmulation/SteamApps007.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ class SteamAppsIn007 : public ISteamApps007

uint32 GetAppInstallDir(AppId_t appID, char* pchFolder, uint32 cchFolderBufferSize)
{
GetCurrentDirectoryA(cchFolderBufferSize, pchFolder);
return cchFolderBufferSize;
if (pchFolder != NULL && pchFolder > NULL && cchFolderBufferSize >= NULL) {
GetCurrentDirectoryA(cchFolderBufferSize, pchFolder);
return cchFolderBufferSize;
}
return NULL;
}
bool BIsAppInstalled(AppId_t appID)
{
Expand Down
7 changes: 5 additions & 2 deletions src/InterfacesEmulation/SteamApps008.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ class SteamAppsIn008 : public ISteamApps008

uint32 GetAppInstallDir(AppId_t appID, char* pchFolder, uint32 cchFolderBufferSize)
{
GetCurrentDirectoryA(cchFolderBufferSize, pchFolder);
return cchFolderBufferSize;
if (pchFolder != NULL && pchFolder > NULL && cchFolderBufferSize >= NULL) {
GetCurrentDirectoryA(cchFolderBufferSize, pchFolder);
return cchFolderBufferSize;
}
return NULL;
}
bool BIsAppInstalled(AppId_t appID)
{
Expand Down
14 changes: 12 additions & 2 deletions src/InterfacesEmulation/SteamRemoteStorage001.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SteamRemoteStorageIn001 : public ISteamRemoteStorage001
return true;
if (sizebytestowrite < NULL)
return false;
if(data == NULL)
if(data <= NULL)
return false;

// Let's use std as more faster.
Expand Down Expand Up @@ -48,6 +48,11 @@ class SteamRemoteStorageIn001 : public ISteamRemoteStorage001
{
if (!Steam_Config::RemoteStorage)
return false;
if(buffer <= NULL)
return false;
if(size < NULL)
return false;

// Let's use std as more faster.
std::FILE* File = std::fopen(ColdAPI_Storage::ConnectDirectoryToFile(filename), "rb");
if (File)
Expand Down Expand Up @@ -106,7 +111,8 @@ class SteamRemoteStorageIn001 : public ISteamRemoteStorage001
long FileSize = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::fclose(File);
*size = FileSize;
if(size != NULL && size > NULL)
*size = FileSize;
return FileName.c_str();
}
}
Expand All @@ -115,6 +121,10 @@ class SteamRemoteStorageIn001 : public ISteamRemoteStorage001

bool GetQuota(int* current, int* maximum)
{
if (current == NULL || current < NULL)
return false;
if (maximum == NULL || maximum < NULL)
return false;
*current = NULL;
*maximum = INT_MAX;
return true;
Expand Down
14 changes: 12 additions & 2 deletions src/InterfacesEmulation/SteamRemoteStorage002.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SteamRemoteStorageIn002 : public ISteamRemoteStorage002
return true;
if (cubData < NULL)
return false;
if (pvData == NULL)
if (pvData <= NULL)
return false;

// Let's use std as more faster.
Expand Down Expand Up @@ -46,6 +46,11 @@ class SteamRemoteStorageIn002 : public ISteamRemoteStorage002
{
if (!Steam_Config::RemoteStorage)
return NULL;
if (cubDataToRead < NULL)
return NULL;
if (pvData <= NULL)
return NULL;

// Let's use std as more faster.
std::FILE* File = std::fopen(ColdAPI_Storage::ConnectDirectoryToFile(pchFile), "rb");
if (File)
Expand Down Expand Up @@ -94,7 +99,8 @@ class SteamRemoteStorageIn002 : public ISteamRemoteStorage002
long FileSize = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::fclose(File);
*pnFileSizeInBytes = FileSize;
if(pnFileSizeInBytes != NULL && pnFileSizeInBytes > NULL)
*pnFileSizeInBytes = FileSize;
return FileName.c_str();
}
}
Expand All @@ -104,6 +110,10 @@ class SteamRemoteStorageIn002 : public ISteamRemoteStorage002

bool GetQuota(int32* pnTotalBytes, int32* puAvailableBytes)
{
if (pnTotalBytes == NULL || pnTotalBytes < NULL)
return false;
if (puAvailableBytes == NULL || puAvailableBytes < NULL)
return false;
*pnTotalBytes = NULL;
*puAvailableBytes = INT_MAX;
return true;
Expand Down
33 changes: 26 additions & 7 deletions src/InterfacesEmulation/SteamRemoteStorage003.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SteamRemoteStorageIn003 : public ISteamRemoteStorage003
return true;
if (cubData < NULL)
return false;
if (pvData == NULL)
if (pvData <= NULL)
return false;

// Let's use std as more faster.
Expand All @@ -29,6 +29,11 @@ class SteamRemoteStorageIn003 : public ISteamRemoteStorage003
{
if (!Steam_Config::RemoteStorage)
return NULL;
if (cubDataToRead < NULL)
return NULL;
if (pvData <= NULL)
return NULL;

// Let's use std as more faster.
std::FILE* File = std::fopen(ColdAPI_Storage::ConnectDirectoryToFile(pchFile), "rb");
if (File)
Expand Down Expand Up @@ -124,7 +129,8 @@ class SteamRemoteStorageIn003 : public ISteamRemoteStorage003
long FileSize = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::fclose(File);
*pnFileSizeInBytes = FileSize;
if(pnFileSizeInBytes != NULL || pnFileSizeInBytes > NULL)
*pnFileSizeInBytes = FileSize;
return FileName.c_str();
}
}
Expand All @@ -134,6 +140,10 @@ class SteamRemoteStorageIn003 : public ISteamRemoteStorage003

bool GetQuota(int32* pnTotalBytes, int32* puAvailableBytes)
{
if (pnTotalBytes == NULL || pnTotalBytes < NULL)
return false;
if (puAvailableBytes == NULL || puAvailableBytes < NULL)
return false;
*pnTotalBytes = NULL;
*puAvailableBytes = INT_MAX;
return true;
Expand Down Expand Up @@ -202,11 +212,16 @@ class SteamRemoteStorageIn003 : public ISteamRemoteStorage003
long FileSize = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::fclose(File);
*pnAppID = Steam_Config::AppId;
*ppchName = (char*)std::malloc(std::strlen(FileName.c_str()) + 10);
std::strcpy(*ppchName, FileName.c_str());
*pnFileSizeInBytes = FileSize;
*pSteamIDOwner = Steam_Config::UserID;
if(pnAppID != NULL && pnAppID > NULL)
*pnAppID = Steam_Config::AppId;
if (ppchName != NULL && ppchName > NULL) {
*ppchName = (char*)std::malloc(std::strlen(FileName.c_str()) + 10);
std::strcpy(*ppchName, FileName.c_str());
}
if(pnFileSizeInBytes != NULL && pnFileSizeInBytes > NULL)
*pnFileSizeInBytes = FileSize;
if(pSteamIDOwner != NULL && pSteamIDOwner > NULL)
*pSteamIDOwner = Steam_Config::UserID;
return true;
}
}
Expand All @@ -216,6 +231,10 @@ class SteamRemoteStorageIn003 : public ISteamRemoteStorage003
{
if (!Steam_Config::RemoteStorage)
return NULL;
if (cubDataToRead < NULL)
return NULL;
if (pvData <= NULL)
return NULL;

ColdAPI_Storage::FillFileStructure(ColdAPI_Storage::GetUGCDirectory());

Expand Down
33 changes: 26 additions & 7 deletions src/InterfacesEmulation/SteamRemoteStorage004.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SteamRemoteStorageIn004 : public ISteamRemoteStorage004
return true;
if (cubData < NULL)
return false;
if (pvData == NULL)
if (pvData <= NULL)
return false;

// Let's use std as more faster.
Expand All @@ -29,6 +29,11 @@ class SteamRemoteStorageIn004 : public ISteamRemoteStorage004
{
if (!Steam_Config::RemoteStorage)
return NULL;
if (cubDataToRead < NULL)
return NULL;
if (pvData <= NULL)
return NULL;

// Let's use std as more faster.
std::FILE* File = std::fopen(ColdAPI_Storage::ConnectDirectoryToFile(pchFile), "rb");
if (File)
Expand Down Expand Up @@ -131,7 +136,8 @@ class SteamRemoteStorageIn004 : public ISteamRemoteStorage004
long FileSize = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::fclose(File);
*pnFileSizeInBytes = FileSize;
if(pnFileSizeInBytes != NULL && pnFileSizeInBytes > NULL)
*pnFileSizeInBytes = FileSize;
return FileName.c_str();
}
}
Expand All @@ -140,6 +146,10 @@ class SteamRemoteStorageIn004 : public ISteamRemoteStorage004

bool GetQuota(int32* pnTotalBytes, int32* puAvailableBytes)
{
if (pnTotalBytes == NULL || pnTotalBytes < NULL)
return false;
if (puAvailableBytes == NULL || puAvailableBytes < NULL)
return false;
*pnTotalBytes = NULL;
*puAvailableBytes = INT_MAX;
return true;
Expand Down Expand Up @@ -208,11 +218,16 @@ class SteamRemoteStorageIn004 : public ISteamRemoteStorage004
long FileSize = std::ftell(File);
std::fseek(File, 0, SEEK_SET);
std::fclose(File);
*pnAppID = Steam_Config::AppId;
*ppchName = (char*)std::malloc(std::strlen(FileName.c_str()) + 10);
std::strcpy(*ppchName, FileName.c_str());
*pnFileSizeInBytes = FileSize;
*pSteamIDOwner = Steam_Config::UserID;
if (pnAppID != NULL && pnAppID > NULL)
* pnAppID = Steam_Config::AppId;
if (ppchName != NULL && ppchName > NULL) {
*ppchName = (char*)std::malloc(std::strlen(FileName.c_str()) + 10);
std::strcpy(*ppchName, FileName.c_str());
}
if (pnFileSizeInBytes != NULL && pnFileSizeInBytes > NULL)
*pnFileSizeInBytes = FileSize;
if (pSteamIDOwner != NULL && pSteamIDOwner > NULL)
*pSteamIDOwner = Steam_Config::UserID;
return true;
}
}
Expand All @@ -222,6 +237,10 @@ class SteamRemoteStorageIn004 : public ISteamRemoteStorage004
{
if (!Steam_Config::RemoteStorage)
return NULL;
if (cubDataToRead < NULL)
return NULL;
if (pvData <= NULL)
return NULL;

ColdAPI_Storage::FillFileStructure(ColdAPI_Storage::GetUGCDirectory());

Expand Down
Loading

0 comments on commit 4adc957

Please sign in to comment.