Skip to content

Commit

Permalink
Fixes #13 - Frame limiter off crashes
Browse files Browse the repository at this point in the history
Fixes #13 - turning frame limiter off would either cause a crash or
extremely fast gameplay
  • Loading branch information
Whitetigerswt committed Nov 23, 2014
1 parent aba4ecf commit 00d343f
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 42 deletions.
Binary file added crashes/Release/crashes-v2.3.1.exe
Binary file not shown.
Binary file removed crashes/Release/crashes-v2.3.exe
Binary file not shown.
Binary file added crashes/Release/crashes.asi
Binary file not shown.
2 changes: 1 addition & 1 deletion crashes/Release/crashes.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SetCompressor /SOLID lzma
;General

;Name and file
!define VERSION "v2.3"
!define VERSION "v2.3.1"
!define AUTHOR "Whitetiger"
Name "GTA:SA Crash Fix-${VERSION}"
OutFile "crashes-${VERSION}.exe"
Expand Down
Binary file modified crashes/Release/crashes.pdb
Binary file not shown.
Binary file removed crashes/crashes.sdf
Binary file not shown.
Binary file modified crashes/crashes.v12.suo
Binary file not shown.
3 changes: 2 additions & 1 deletion crashes/crashes/Addresses.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#define PLAYER_POINTER *(int*)0xB6F5F0
#define VAR_FRAME_LIMITER *(BYTE*)0xBA6794
#define VAR_FRAME_LIMITER *(BYTE*)0xBA6794
#define ADDRESS_LOADED *(int*)0xC8D4C0
3 changes: 2 additions & 1 deletion crashes/crashes/crashes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,8 @@ void InitHooks_SampCrashes()
{
SampPointerCheck1_Addr = FindPattern("\x74\x12\x8B\x50\x10\x8B\x02", "xxxxxxx");

if (SampPointerCheck1_Addr != 0) {
if (SampPointerCheck1_Addr != 0)
{
DWORD oldProt;
VirtualProtect((void*)SampPointerCheck1_Addr, 5, PAGE_EXECUTE_READWRITE, &oldProt);
HookInstall(SampPointerCheck1_Addr, (DWORD)HOOK_SampPointerCheck1, 5);
Expand Down
2 changes: 1 addition & 1 deletion crashes/crashes/main.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once

#define VERSION 2.3f
#define VERSION 2.31f

void DownloadUpdate(char* url);
93 changes: 55 additions & 38 deletions crashes/crashes/quickload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "Addresses.h"
#include "PatternScan.h"


void ShowRaster_Prox();
void StartGame_Prox();
void ChangeMenu_Prox();
Expand Down Expand Up @@ -44,54 +43,72 @@ void __declspec(naked) FPSStrafeHook() {

bool quickLoadPatches( )
{

unsigned long dwValue;

DWORD dwSAMPBase = GetModuleBaseAddress("samp.dll");
DWORD dwConnectDelay, dwFPSSleep[4];

if (*(int*)(dwSAMPBase + 0x77A3) == 3000) { // 0.3z-R2
dwConnectDelay = dwSAMPBase + 0x77A3;
} else if(*(int*)(dwSAMPBase + 0x2AE035) == 3000) { // 0.3z R1
dwConnectDelay = dwSAMPBase + 0x2AE035;
} else if(*(int*)(dwSAMPBase + 0x244A7E) == 3000) { // 0.3x-R2-pre-release 2
dwConnectDelay = dwSAMPBase + 0x244A7E;
} else if(*(int*)(dwSAMPBase + 0x295074) == 3000) { // 0.3x-R2-pre-release 1
dwConnectDelay = dwSAMPBase + 0x295074;
} else if(*(int*)(dwSAMPBase + 0x2CD600) == 3000) { // 0.3x-R1-2
dwConnectDelay = dwSAMPBase + 0x2CD600;
} else if(*(int*)(dwSAMPBase + 0x2607DC) == 3000) { // 0.3x
dwConnectDelay = dwSAMPBase + 0x2607DC;
}
DWORD dwSAMPBase = NULL;

dwFPSSleep[0] = FindPattern("\x57\x8B\xF9\xE8\xF6\x36\xFC\xFF\x8B\xF0\xA1", "xxxx????xxx") + 0x8;
dwFPSSleep[1] = FindPattern("\xBA\x0A\x00\x00\x00\x2B\xD6", "xxxxxxx") + 0x7;
dwFPSSleep[2] = FindPattern("\xA3\x5C\xCB\xB7\x00\xA3\x58\xCB\xB7\x00", "xxxxxxxxxx");
dwFPSSleep[3] = FindPattern("\xBA\x80\x1A\x56\x00\xFF\xE2", "xxxxxxx") - 0x7;
do
{
dwSAMPBase = GetModuleBaseAddress("samp.dll");
Sleep(10);
} while (dwSAMPBase == NULL && ADDRESS_LOADED < 6);

frame_limiter_off_addr = dwFPSSleep[2] - 0x5;
frame_limiter_on_addr = dwFPSSleep[2] + 0x27;
if (dwSAMPBase != NULL)
{

DWORD dwConnectDelay, dwFPSSleep[4];

DWORD oldProt;
if ( dwConnectDelay != NULL ) {
VirtualProtect((LPVOID)dwConnectDelay, 4, PAGE_EXECUTE_READWRITE, &oldProt);
MemPutFast < int > ( dwConnectDelay, 0 );
}
if (*(int*)(dwSAMPBase + 0x77A3) == 3000) { // 0.3z-R2
dwConnectDelay = dwSAMPBase + 0x77A3;
}
else if (*(int*)(dwSAMPBase + 0x2AE035) == 3000) { // 0.3z R1
dwConnectDelay = dwSAMPBase + 0x2AE035;
}
else if (*(int*)(dwSAMPBase + 0x244A7E) == 3000) { // 0.3x-R2-pre-release 2
dwConnectDelay = dwSAMPBase + 0x244A7E;
}
else if (*(int*)(dwSAMPBase + 0x295074) == 3000) { // 0.3x-R2-pre-release 1
dwConnectDelay = dwSAMPBase + 0x295074;
}
else if (*(int*)(dwSAMPBase + 0x2CD600) == 3000) { // 0.3x-R1-2
dwConnectDelay = dwSAMPBase + 0x2CD600;
}
else if (*(int*)(dwSAMPBase + 0x2607DC) == 3000) { // 0.3x
dwConnectDelay = dwSAMPBase + 0x2607DC;
}

if ( dwFPSSleep[1] != NULL ) {
// Disable the 100FPS Lock
VirtualProtect((LPVOID)dwFPSSleep[0], 7, PAGE_EXECUTE_READWRITE, &oldProt);
HookInstall(dwFPSSleep[0], (DWORD)FPSStrafeHook, 7);
dwFPSSleep[0] = FindPattern("\x57\x8B\xF9\xE8\xF6\x36\xFC\xFF\x8B\xF0\xA1", "xxxx????xxx") + 0xA;
dwFPSSleep[1] = FindPattern("\xBA\x0A\x00\x00\x00\x2B\xD6", "xxxxxxx") + 0x5;
dwFPSSleep[2] = FindPattern("\xB8\x00\x00\x80\x3F\xA3", "xxxxxx") + 0x5;
dwFPSSleep[3] = FindPattern("\xBA\x80\x1A\x56\x00\xFF\xE2", "xxxxxxx") - 0x7;

VirtualProtect((LPVOID)dwFPSSleep[1], 7, PAGE_EXECUTE_READWRITE, &oldProt);
memcpy((void*)dwFPSSleep[1], "\x90\x90\x90\x90\x90\x90\x90", 7);
frame_limiter_off_addr = dwFPSSleep[2] - 0x5;
frame_limiter_on_addr = dwFPSSleep[2] - 0x9;

DWORD oldProt;
if (dwConnectDelay != NULL) {
VirtualProtect((LPVOID)dwConnectDelay, 4, PAGE_EXECUTE_READWRITE, &oldProt);
MemPutFast < int >(dwConnectDelay, 0);
}

VirtualProtect((LPVOID)dwFPSSleep[2], 5, PAGE_EXECUTE_READWRITE, &oldProt);
memcpy((void*)dwFPSSleep[2], "\x90\x90\x90\x90\x90", 5);
if (dwFPSSleep[1] != NULL) {
// Disable the 100FPS Lock
VirtualProtect((LPVOID)dwFPSSleep[0], 7, PAGE_EXECUTE_READWRITE, &oldProt);
HookInstall(dwFPSSleep[0], (DWORD)FPSStrafeHook, 7);

VirtualProtect((LPVOID)dwFPSSleep[3], 1, PAGE_EXECUTE_READWRITE, &oldProt);
MemPut <BYTE> (dwFPSSleep[3], 0x0);
VirtualProtect((LPVOID)dwFPSSleep[1], 7, PAGE_EXECUTE_READWRITE, &oldProt);

MemPut <BYTE>(dwFPSSleep[1] + 0x2, 0x0);
MemPut <BYTE>(dwFPSSleep[1] + 0x4, 0x90);

VirtualProtect((LPVOID)dwFPSSleep[2], 5, PAGE_EXECUTE_READWRITE, &oldProt);
memcpy((void*)dwFPSSleep[2], "\x90\x90\x90\x90\x90", 5);

VirtualProtect((LPVOID)dwFPSSleep[3], 1, PAGE_EXECUTE_READWRITE, &oldProt);
MemPut <BYTE>(dwFPSSleep[3], 0x0);

}
}


Expand Down

0 comments on commit 00d343f

Please sign in to comment.