From 60c6d1a632a3f61f3b14669e6815987da209c2c7 Mon Sep 17 00:00:00 2001 From: RD42 Date: Mon, 21 Apr 2025 06:47:22 -0700 Subject: [PATCH] [saco] Refactor --- saco/archive/ArchiveFS.cpp | 13 ++++++++++--- saco/archive/CryptoContext.cpp | 1 - saco/archive/CryptoFns.h | 13 ------------- saco/archive/Stream.h | 6 +++++- saco/archive/TinyEncrypt.cpp | 5 +++++ saco/game/address.h | 4 ++++ saco/game/common.h | 10 +++++++++- saco/httpclient.cpp | 3 ++- saco/runutil.cpp | 2 +- saco/runutil.h | 4 +++- 10 files changed, 39 insertions(+), 22 deletions(-) diff --git a/saco/archive/ArchiveFS.cpp b/saco/archive/ArchiveFS.cpp index 8067b37..885abde 100644 --- a/saco/archive/ArchiveFS.cpp +++ b/saco/archive/ArchiveFS.cpp @@ -8,6 +8,10 @@ #include "TinyEncrypt.h" #include "Obfuscator.h" +#ifndef ARCTOOL +#include "../outputdebugstring.h" +#endif + //------------------------------------ DWORD CArchiveFS::ms_dwHashInit = OBFUSCATE_DATA(0x9E3779B9); @@ -166,7 +170,7 @@ void CArchiveFS::LoadEntries() tinyEnc.SetKey((BYTE*)TEA_KEY, TEA_XOR_KEY); tinyEnc.DecryptData(sizeof(SAA_ENTRY)*m_dwNumEntries, reinterpret_cast(m_pEntries)); - // 5. Build a binary tree of the entries.. it makes searching for files faster (since we have a + // 5. Build a binary tree of the entries.. it makes searching for files faster (since we have a // huge index with fake entries) for(i=0; ipbData; - } } +//------------------------------------ + void CArchiveFS::UnloadData(DWORD dwFileIndex) { AFS_ENTRYBT_NODE* node = *(reinterpret_cast(&dwFileIndex)); @@ -375,3 +380,5 @@ void CArchiveFS::UnloadData(DWORD dwFileIndex) node->pbData = NULL; } } + +//------------------------------------ diff --git a/saco/archive/CryptoContext.cpp b/saco/archive/CryptoContext.cpp index 82a7038..a399e32 100644 --- a/saco/archive/CryptoContext.cpp +++ b/saco/archive/CryptoContext.cpp @@ -29,7 +29,6 @@ CCryptoContext::CCryptoContext(void) } ms_dwRefCount++; - } //------------------------------------ diff --git a/saco/archive/CryptoFns.h b/saco/archive/CryptoFns.h index 1a12439..a432d85 100644 --- a/saco/archive/CryptoFns.h +++ b/saco/archive/CryptoFns.h @@ -10,19 +10,6 @@ #ifndef ARCTOOL -/* -const CHAR* CRYPT_MODULE = "advapi32"; -const CHAR* CRYPT_FN_AcquireContext = "CryptAcquireContextA"; -const CHAR* CRYPT_FN_ReleaseContext = "CryptReleaseContext"; -const CHAR* CRYPT_FN_GenRandom = "CryptGenRandom"; -const CHAR* CRYPT_FN_CreateHash = "CryptCreateHash"; -const CHAR* CRYPT_FN_DestroyHash = "CryptDestroyHash"; -const CHAR* CRYPT_FN_HashData = "CryptHashData"; -const CHAR* CRYPT_FN_DestroyKey = "CryptDestroyKey"; -const CHAR* CRYPT_FN_ImportKey = "CryptImportKey"; -const CHAR* CRYPT_FN_VerifySignature = "CryptVerifySignatureA"; -*/ - const CHAR CRYPT_MODULE[] = "41#4% +#include class CAbstractStream { @@ -249,5 +254,4 @@ public: { return m_nOffset; } - }; diff --git a/saco/archive/TinyEncrypt.cpp b/saco/archive/TinyEncrypt.cpp index 0f4ed5d..0758c0a 100644 --- a/saco/archive/TinyEncrypt.cpp +++ b/saco/archive/TinyEncrypt.cpp @@ -1,4 +1,9 @@ +// +// This is a modified XTEA algorithm with a streaming +// mode of operation -- specifically CBC +// + #include "TinyEncrypt.h" #include "Obfuscator.h" #include diff --git a/saco/game/address.h b/saco/game/address.h index 8c5dfc2..9d3fdc4 100644 --- a/saco/game/address.h +++ b/saco/game/address.h @@ -1,6 +1,8 @@ #pragma once +//----------------------------------------------------------- + #define ADDR_HWND 0xC97C1C #define ADDR_ID3D9DEVICE 0xC97C28 @@ -30,3 +32,5 @@ #define ADDR_VEHICLE_TABLE 0xB74494 // Contains ptr to the vehicles table #define ADDR_CAMERA 0xB6F99C + +//----------------------------------------------------------- diff --git a/saco/game/common.h b/saco/game/common.h index 735a07e..6236eb4 100644 --- a/saco/game/common.h +++ b/saco/game/common.h @@ -3,6 +3,8 @@ #include +//----------------------------------------------------------- + #define MAX_PLAYERS 1004 #define MAX_ACTORS 1000 #define MAX_VEHICLES 2000 @@ -58,6 +60,7 @@ typedef struct _MATRIX4X4 { #define IN_VEHICLE(x) ((x->dwStateFlags & 256) >> 8) //----------------------------------------------------------- + typedef struct _WEAPON_SLOT_TYPE { DWORD dwType; @@ -71,6 +74,7 @@ typedef struct _WEAPON_SLOT_TYPE } WEAPON_SLOT_TYPE; // MUST BE EXACTLY ALIGNED TO 28 bytes //----------------------------------------------------------- + #pragma pack(1) typedef struct _PED_TASKS_TYPE { @@ -95,6 +99,7 @@ typedef struct _PED_TASKS_TYPE } PED_TASKS_TYPE; //----------------------------------------------------------- + #pragma pack(1) typedef struct _ENTITY_TYPE { @@ -127,10 +132,11 @@ typedef struct _ENTITY_TYPE } ENTITY_TYPE; //----------------------------------------------------------- + #pragma pack(1) typedef struct _PED_TYPE { - ENTITY_TYPE entity; + ENTITY_TYPE entity; // 0-184 char _gapB8[948]; @@ -193,6 +199,8 @@ typedef struct _PED_TYPE } PED_TYPE; //----------------------------------------------------------- + +#pragma pack(1) typedef struct _VEHICLE_TYPE { ENTITY_TYPE entity; // 0-184 diff --git a/saco/httpclient.cpp b/saco/httpclient.cpp index 3995a47..9b9fc33 100644 --- a/saco/httpclient.cpp +++ b/saco/httpclient.cpp @@ -61,7 +61,7 @@ CHttpClient::~CHttpClient() int CHttpClient::ProcessURL(int iType, char *szURL, char *szPostData, char *szReferer) { - printf("CHttpClient::ProcessURL %s\n", szURL); // Thanks Kalcor! + printf("CHttpClient::ProcessURL %s\n",szURL); InitRequest(iType,szURL,szPostData,szReferer); @@ -187,6 +187,7 @@ void CHttpClient::InitRequest(int iType, char *szURL, char *szPostData, char *sz // Copy hostname from URL slash_ptr = strchr(szUseURL,'/'); + if(!slash_ptr) { strcat(szUseURL,"/"); slash_ptr = strchr(szUseURL,'/'); diff --git a/saco/runutil.cpp b/saco/runutil.cpp index eb62cbf..ca6ed74 100644 --- a/saco/runutil.cpp +++ b/saco/runutil.cpp @@ -53,6 +53,7 @@ char *Util_stristr(const char *String, const char *Pattern) return (starti); } } + return(0); } @@ -119,7 +120,6 @@ int Util_wildcmp(char *wild, char *string) int Util_strnicmp(const char *s1, const char *s2, size_t n) { - if (n == 0) return 0; do diff --git a/saco/runutil.h b/saco/runutil.h index 1ca751b..a45158a 100644 --- a/saco/runutil.h +++ b/saco/runutil.h @@ -1,4 +1,6 @@ +//---------------------------------------------------- + void Util_UrlUnencode(char *enc); char Util_toupper(char c); char *Util_stristr(const char *String, const char *Pattern); @@ -12,4 +14,4 @@ void Util_Base64Encode( char *cpInput, char *cpOutput ); char * K_DecodeString(unsigned char *szInput); void K_EncodeString(char *szInput, char *szOutput); -//---------------------------------------------------- \ No newline at end of file +//----------------------------------------------------