diff --git a/saco/game/address.h b/saco/game/address.h
index 9f35c63..0ab2ccf 100644
--- a/saco/game/address.h
+++ b/saco/game/address.h
@@ -4,3 +4,9 @@
#define ADDR_HWND 0xC97C1C
#define ADDR_KEYSTATES 0xB73458
+
+#define ADDR_GAME_STARTED 0xBA6831
+#define ADDR_ENTRY 0xC8D4C0
+
+#define ADDR_BYPASS_VIDS_USA10 0x747483
+#define ADDR_BYPASS_VIDS_EU10 0x7474D3
diff --git a/saco/game/game.cpp b/saco/game/game.cpp
index b1119d4..ca9d312 100644
--- a/saco/game/game.cpp
+++ b/saco/game/game.cpp
@@ -8,6 +8,8 @@ char *szGameTextMessage;
int unnamed_10150340[210];
+BOOL ApplyPreGamePatches();
+
CGame::CGame()
{
// TODO: CGame::CGame()
@@ -28,6 +30,8 @@ CGame::CGame()
field_5D = 90;
}
+//-----------------------------------------------------------
+
void CGame::InitGame()
{
// Create a buffer for game text.
@@ -41,5 +45,13 @@ void CGame::InitGame()
// Init radar colors
GameResetRadarColors();
+
+ if(!ApplyPreGamePatches()) {
+ MessageBox(0,
+ "I can't determine your GTA version.\r\nSA-MP only supports GTA:SA v1.0 USA/EU",
+ "Version Error",MB_OK | MB_ICONEXCLAMATION);
+ ExitProcess(1);
+ }
}
+//-----------------------------------------------------------
diff --git a/saco/game/patches.cpp b/saco/game/patches.cpp
new file mode 100644
index 0000000..b2eaea7
--- /dev/null
+++ b/saco/game/patches.cpp
@@ -0,0 +1,130 @@
+
+#include "../main.h"
+
+DWORD dwSystemMemory;
+DWORD dwStreamingMemory;
+
+extern int iGtaVersion;
+
+//----------------------------------------------------------
+
+void UnFuckAndCheck(DWORD addr, int size, BYTE byteCheck)
+{
+ DWORD d;
+ VirtualProtect((PVOID)addr,size,PAGE_EXECUTE_READWRITE,&d);
+
+ if(byteCheck != *(PBYTE)addr) {
+#ifdef _DEBUG
+ char s[256];
+ sprintf(s,"Failed Check At Addr: 0x%X",addr);
+ OutputDebugString(s);
+#endif
+ while(byteCheck != *(PBYTE)addr) Sleep(1);
+
+ VirtualProtect((PVOID)addr,size,PAGE_EXECUTE_READWRITE,&d);
+ }
+}
+
+//----------------------------------------------------------
+
+void UnFuck(DWORD addr, int size)
+{
+ DWORD d;
+ VirtualProtect((PVOID)addr,size,PAGE_EXECUTE_READWRITE,&d);
+}
+
+//----------------------------------------------------------
+
+BOOL ApplyPreGamePatches()
+{
+ BYTE * pbyteVersionDetermination = (PBYTE)ADDR_BYPASS_VIDS_USA10;
+ int iCounter=0;
+
+ // MAIN VERSION DETERMINING LOGIC
+ while( (*pbyteVersionDetermination != 0x89) &&
+ (*pbyteVersionDetermination != 0xC8) )
+ {
+ if (*(PBYTE)ADDR_GAME_STARTED == 1) {
+ return FALSE;
+ } else {
+ Sleep(10);
+ iCounter++;
+ if(iCounter>6000) { // 60 seconds have passed
+ return FALSE;
+ }
+ }
+ }
+
+ if(*pbyteVersionDetermination == 0x89) {
+ iGtaVersion = GTASA_VERSION_USA10;
+ }
+ else if(*pbyteVersionDetermination == 0xC8) {
+ iGtaVersion = GTASA_VERSION_EU10;
+ }
+
+ // (skip to starting screen)
+ if(iGtaVersion == GTASA_VERSION_USA10) {
+ UnFuck(ADDR_BYPASS_VIDS_USA10,6);
+ *(BYTE *)ADDR_ENTRY = 5;
+ memset((PVOID)ADDR_BYPASS_VIDS_USA10,0x90,6);
+ }
+ else if (iGtaVersion == GTASA_VERSION_EU10) {
+ UnFuck(ADDR_BYPASS_VIDS_EU10,6);
+ *(BYTE *)ADDR_ENTRY = 5;
+ memset((PVOID)ADDR_BYPASS_VIDS_EU10,0x90,6);
+ }
+
+ // Loading screens
+ UnFuck(0x866CD8,10);
+ UnFuck(0x866CCC,10);
+ strcpy((PCHAR)0x866CD8,"title");
+ strcpy((PCHAR)0x866CCC,"title");
+
+ UnFuck(0x745B87,68);
+ memset((PVOID)0x745B87,0x90,68);
+
+ UnFuck(0x7459E1,2);
+ memset((LPVOID)0x7459E1,0x90,2);
+
+ UnFuckAndCheck(0x561872,30,0x85);
+ *(PBYTE)0x561872 = 0x33;
+ *(PBYTE)0x561873 = 0xC0;
+ memset((LPVOID)0x561874,0x90,27);
+
+ MEMORYSTATUSEX statex;
+ statex.dwLength = sizeof(statex);
+ GlobalMemoryStatusEx(&statex);
+
+ dwSystemMemory = statex.ullTotalPhys / (1024 * 1024);
+
+ if(dwSystemMemory > 4000)
+ dwStreamingMemory = 0x40000000; // 1024MB
+ else if(dwSystemMemory > 2000)
+ dwStreamingMemory = 0x20000000; // 512MB
+ else if(dwSystemMemory > 1000)
+ dwStreamingMemory = 0x10000000; // 256MB
+ else if(dwSystemMemory > 500)
+ dwStreamingMemory = 0x08000000; // 128MB
+ else
+ dwStreamingMemory = 0x06000000; // 96MB
+
+ // Modify the streaming memory hardcoded values
+ UnFuck(0x5B8E6A,4);
+ *(DWORD *)0x5B8E6A = dwStreamingMemory;
+
+ UnFuckAndCheck(0x4083C0,1,0xB8);
+ *(PBYTE)0x4083C0 = 0xC3;
+
+ UnFuck(0x590099,5);
+ memset((LPVOID)0x590099,0x90,5);
+
+ UnFuck(0x53E94C,1);
+ *(PBYTE)0x53E94C = 2;
+
+ UnFuck(0x731F60,4);
+ *(PDWORD)0x731F60 = 20000;
+
+ return TRUE;
+}
+
+//----------------------------------------------------------
diff --git a/saco/main.cpp b/saco/main.cpp
index ccd8d4f..64ed710 100644
--- a/saco/main.cpp
+++ b/saco/main.cpp
@@ -1,6 +1,8 @@
#include "main.h"
+int iGtaVersion=0;
+
GAME_SETTINGS tSettings;
CConfig *pConfig=0;
CChatWindow *pChatWindow=0;
diff --git a/saco/main.h b/saco/main.h
index 0c2a44f..e52b42f 100644
--- a/saco/main.h
+++ b/saco/main.h
@@ -7,6 +7,10 @@
#define MAX_SETTINGS_STRING 256
+#define GTASA_VERSION_UNKNOWN 0
+#define GTASA_VERSION_USA10 1
+#define GTASA_VERSION_EU10 2
+
typedef struct _GAME_SETTINGS {
BOOL bDebug;
BOOL bPlayOnline;
diff --git a/saco/saco.vcproj b/saco/saco.vcproj
index 1f1d6d1..9cf813a 100644
--- a/saco/saco.vcproj
+++ b/saco/saco.vcproj
@@ -165,6 +165,9 @@
+
+