Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

Fastman92LimitAdjusterDetector


goodidea82
 Share

Recommended Posts

It turns out that this post was "completely unnecessary". Keeping it only for historic reasons. See here: http://gtaforums.com/topic/733982-fastman92-limit-adjuster/?p=1069739918

 

Make your asi mods compatible with Fastman92LimitAdjuster (FLA) and with standard GTA SA without FLA.


Download

(The download does not exist anymore, but the source code is below)
https://github.com/goodidea82/Fastman92LimitAdjusterDetector

 

Source Code

cpp

 

#include "Fastman92LimitAdjusterDetector.h"

#include <fstream>

FLADetectorSA FLADetectorSAInstance;

//This is a subset of available version, those that I have on my computer.
unsigned int FLAsizeToVersion[][2] = {
//{Bytes, Version}
{ 546816, 109},
{ 797696, 201},
{ 1012224, 204},
{ 5510656, 345},
{ 5541888, 401},
{ 5574656, 402},
{ 5919744, 403}
};
int NUM_KNOWN_VERSIONS = 7;

/* goodidea82 */
int FLADetectorSA::detect() {
versionIsKnown = false;

//See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365740(v=vs.85).aspx
WIN32_FIND_DATA FindFileData;
HANDLE handle = FindFirstFile("$fastman92limitAdjuster.asi", &FindFileData);
int found = handle != INVALID_HANDLE_VALUE;
if (found)
{
FLAFileSize = FindFileData.nFileSizeLow;
for (int i = 0; i < NUM_KNOWN_VERSIONS; i++) {
if (FLAFileSize == FLAsizeToVersion[0]) {
FLAVersion = FLAsizeToVersion[1];
versionIsKnown = true;
}
}
if (!versionIsKnown) {
//try to estimate version;
for (int i = 0; i < NUM_KNOWN_VERSIONS; i++) {
if (FLAFileSize < FLAsizeToVersion[0]) {
FLAVersion = FLAsizeToVersion[1];
}
}
}
}
else {
FLAVersion = 0; //FLA does not exist
}
FindClose(handle);

initFields();
return 0;
}

//This function is called by detect() after the existence and version of FLA have been determined.
bool FLADetectorSA::initFields()
{
//To know the limit of SCM scripts, you should read WORD value from this pointer.
limit_of_SCM_scripts_ptr = (WORD*) 0x470917;


if (!FLAexist()) {
//Use default values. I think they are for GTA SA Hoodlum 1.0.
CStreaming__ms_modelInfoPtrs = (void*)0xA9B0C8;
CStreaming__ms_aInfoForModel = (void*)0x8E4CC0;
CAnimManager__ms_aAnimBlocks = (void*)0xB5D4A0;
CVehicleRecording__StreamingArray = (void*)0x97D880;
CTheScripts__StreamedScripts = (void*)0xA47B60;
TXD_base_idx_ptr = 0; //todo define addresses
COL_base_idx_ptr = 0;
IPL_base_idx_ptr = 0;
DAT_base_idx_ptr = 0;
IFP_base_idx_ptr = 0;
RRR_base_idx_ptr = 0;
SCM_base_idx_ptr = 0;
}
else {
CStreaming__ms_modelInfoPtrs = (void*)0x40122D;
CStreaming__ms_aInfoForModel = (void*)(0x408ADA + 3);
CAnimManager__ms_aAnimBlocks = (void*)(0x4C51CD + 1);
CVehicleRecording__StreamingArray = (void*)(0x1560EA1 + 1);
CTheScripts__StreamedScripts = (void*)(0x408AB9 + 1);
TXD_base_idx_ptr = (DWORD*)(0x407104 + 2);
COL_base_idx_ptr = (DWORD*)(0x410344 + 2);
IPL_base_idx_ptr = (DWORD*)(0x4044F4 + 2);
DAT_base_idx_ptr = (DWORD*)(0x44E4C4 + 1);
IFP_base_idx_ptr = (DWORD*)(0x40C1A4 + 1);
RRR_base_idx_ptr = (DWORD*)(0x4594A1 + 2);
SCM_base_idx_ptr = (DWORD*)(0x40C1C4 + 1);

if (FLAVersion >= 403) {
CStreaming__ms_modelInfoPtrs = (void*)(0x4C5538 + 3);
}

}

return true;
}


bool FLADetectorSA::FLAexist()
{
return FLAVersion > 0;
}

bool FLADetectorSA::FLAversionIsKnown()
{
return versionIsKnown;
}

void FLADetectorSA::createLogfile()
{
using namespace std;
ofstream myfile("FLADetector.log");
myfile << "Fastman92limitAdjusterDetector. Author: Goodidea82. Build: " << __DATE__ << " " << __TIME__ << endl;
myfile << "FLAVersion=" << FLAVersion;
if (FLAVersion == -1) myfile << " (not initialized)";
else if (FLAVersion == 0) myfile << " $Fastman92LimitAdjuster.asi NOT FOUND.";
myfile << endl;

myfile << "FLAFileSize=" << FLAFileSize << endl;

myfile << "\nUsing the following addresses:\n";
myfile << "CStreaming__ms_modelInfoPtrs=" << CStreaming__ms_modelInfoPtrs << endl;
myfile << "CStreaming__ms_aInfoForModel=" << CStreaming__ms_aInfoForModel << endl;
myfile << "CAnimManager__ms_aAnimBlocks=" << CAnimManager__ms_aAnimBlocks << endl;
myfile << "CVehicleRecording__StreamingArray=" << CVehicleRecording__StreamingArray << endl;
myfile << "CTheScripts__StreamedScripts=" << CTheScripts__StreamedScripts << endl;

myfile << "\nUsing the following indices:\n";
myfile << "getTXDbaseIdx()=" << getTXDbaseIdx() << endl;
myfile << "getCOLbaseIdx()=" << getCOLbaseIdx() << endl;
myfile << "getIPLbaseIdx()=" << getIPLbaseIdx() << endl;
myfile << "getDATbaseIdx()=" << getDATbaseIdx() << endl;
myfile << "getIFPbaseIdx()=" << getIFPbaseIdx() << endl;
myfile << "getRRRbaseIdx()=" << getRRRbaseIdx() << endl;
myfile << "getSCMbaseIdx()=" << getSCMbaseIdx() << endl;
}

DWORD FLADetectorSA::getTXDbaseIdx()
{
if (FLAexist())
return *TXD_base_idx_ptr;
else
return 20000;
}

DWORD FLADetectorSA::getCOLbaseIdx()
{
if (FLAexist())
return *COL_base_idx_ptr;
else
return 25000;
}

DWORD FLADetectorSA::getIPLbaseIdx()
{
if (FLAexist())
return *IPL_base_idx_ptr;
else
return 25255;
}

DWORD FLADetectorSA::getDATbaseIdx()
{
if (FLAexist())
return *DAT_base_idx_ptr;
else
return 25511;
}

DWORD FLADetectorSA::getIFPbaseIdx()
{
if (FLAexist())
return *IFP_base_idx_ptr;
else
return 25575;
}

DWORD FLADetectorSA::getRRRbaseIdx()
{
if (FLAexist())
return *RRR_base_idx_ptr;
else
return 25755;
}

DWORD FLADetectorSA::getSCMbaseIdx()
{
if (FLAexist())
return *SCM_base_idx_ptr;
else
return 26230;
}

 

 

header

 

#pragma once

#include <Windows.h> //Because the types WORD and DWORD are needed.

/* See: https://github.com/goodidea82/Fastman92LimitAdjusterDetector

Fastman92LimitAdjuster (short: FLA) modifies some addresses in Grand Theft Auto (GTA) games causing compatibility problems with mods.
This class detects if FLA is installed and initializes fields that hold
memory addresses and indices that are modified by FLA according to the description in
"source code\fastman92 limit adjuster\fastman92 limit adjuster\howToMakePluginsCompatible.txt"

If FLA is not installed, then the memory addresses are set to default values (GTA Hoodlum 1.0 I beliefe).
Hence, using this class mods can be built that work with FLA and without FLA!

This version of the detector is aware of FLAs up to version 4.3. The function detect() checks if the
file "$fastman92limitAdjuster.asi" is in the current folder and reads its filesize to detect
the FLA version and then sets the addresses in the class.
You can use the global extern variable FLADetectorSAInstance (defined below) in your program.
Hence the usage is:
FLADetectorSAInstance.detect(); //Now fields are initilized and can be used
FLADetectorSAInstance.createLogfile(); //If you want to see the result of detect().

Links and further information:
The FLA thread: http://gtaforums.com/topic/733982-fastman92-limit-adjuster/
Compatibility post: http://gtaforums.com/topic/733982-fastman92-limit-adjuster/?p=1066099922
Update to date information can be found in the following file that is part of FLA donwload:
source code\fastman92 limit adjuster\fastman92 limit adjuster\howToMakePluginsCompatible.txt

@author: goodidea82
*/
class FLADetectorSA {
public:
FLADetectorSA() {
FLAVersion = -1;
FLAFileSize = -1;
versionIsKnown = false;
CStreaming__ms_modelInfoPtrs = 0;
CStreaming__ms_aInfoForModel = 0;
CAnimManager__ms_aAnimBlocks = 0;
CVehicleRecording__StreamingArray = 0;
CTheScripts__StreamedScripts = 0;
}
int FLAVersion; //-1=Not initialized, 0=FLA not found, 107 = FLA 1.7,..., 400 = FLA 4.0,..., 403 = FLA 4.3
int FLAFileSize;

int detect();
bool FLAexist();
bool FLAversionIsKnown(); //If it is now known, then FLAVersion is an estimated version.
void createLogfile();

void* CStreaming__ms_modelInfoPtrs;
void* CStreaming__ms_aInfoForModel;
void* CAnimManager__ms_aAnimBlocks;
void* CVehicleRecording__StreamingArray;
void* CTheScripts__StreamedScripts;
WORD* limit_of_SCM_scripts_ptr; //To know the limit of SCM scripts, you should read WORD value from this pointer.

DWORD* TXD_base_idx_ptr;
DWORD* COL_base_idx_ptr;
DWORD* IPL_base_idx_ptr;
DWORD* DAT_base_idx_ptr;
DWORD* IFP_base_idx_ptr;
DWORD* RRR_base_idx_ptr;
DWORD* SCM_base_idx_ptr;

DWORD getTXDbaseIdx();
DWORD getCOLbaseIdx();
DWORD getIPLbaseIdx();
DWORD getDATbaseIdx();
DWORD getIFPbaseIdx();
DWORD getRRRbaseIdx();
DWORD getSCMbaseIdx();

protected:
bool versionIsKnown; //Use FLAversionIsKnown()
bool initFields(); //Called by detect to initialize the fields of this class
};


extern FLADetectorSA FLADetectorSAInstance;


/*
The information below is for FLA 4.0 and is not correct for FLA 4.3.
The correct information can be found here: source code\fastman92 limit adjuster\fastman92 limit adjuster\howToMakePluginsCompatible.txt

How to make plugin compatible with ID limit adjuster?

0x40122D - holds a pointer to CStreaming::ms_modelInfoPtrs array (0x0xA9B0C8 by default)
(0x408ADA + 3) - holds a pointer to CStreaming::ms_aInfoForModel array (0x8E4CC0 by default)

(0x4C51CD + 1) - holds a pointer to CAnimManager::ms_aAnimBlocks(0xB5D4A0 by default)
(0x1560EA1 + 1) - holds a pointer to CVehicleRecording::StreamingArray (0x97D880 by default)
(0x408AB9 + 1) - holds a pointer to CTheScripts::StreamedScripts (0xA47B60 by default)

Structure CStreamedScripts is modified.

Fields:
CStreamedScriptInfo[numberOfSCMscripts];
int largestExternalSize;
__int16 countOfScripts;
__int16 field_A46;


See this structure:
#pragma pack(push, 1)
struct CStreamedScripts_Footer
{
int largestExternalSize;
__int16 countOfScripts;
__int16 field_A46;
};
#pragma pack(pop)


If you want to access the last 3 members, you need to calculate address like this:

CStreamedScriptInfo* CTheScripts__StreamedScriptsArray = (CStreamedScriptInfo*)CTheScripts__StreamedScripts;
CStreamedScripts_Footer* CTheScripts__StreamedScriptsFooter = (CStreamedScripts_Footer*)(CTheScripts__StreamedScripts + numberOfSCMfiles * sizeof(CStreamedScriptInfo));

------------------------------------

Base ID indexes (DWORD values)
(0x407104 + 2) - holds TXD base index (20000 by default)
(0x410344 + 2) - holds COL base index (25000 by default)
(0x4044F4 + 2) - holds IPL base index (25255 by default)
(0x44E4C4 + 1) - holds DAT base index (25511 by default)
(0x40C1A4 + 1) - holds IFP base index (25575 by default)
(0x4594A1 + 2) - holds RRR base index (25755 by default)
(0x40C1C4 + 1) - holds SCM base index (26230 by default)

If you need to know the value of ID limits, you should perform subtraction.
numberOfTXDfiles = baseCOLindex - baseTXDindex;

To know the limit of SCM scripts, you should read WORD value from 0x470917

Author: fastman92
*/

 

Fastman92LimitAdjusterDetector
This is a C++ class which detects if Fastman92LimitAdjuster is installed and initialized memory addresses for compatibility.

Simply add this source code to your mod and use the provided memory addresses.

Description
Fastman92LimitAdjuster (short: FLA) modifies some addresses in Grand Theft Auto (GTA) games causing compatibility problems with mods.

This class detects if FLA is installed and initializes fields that hold
memory addresses and indices that are modified by FLA according to the description in
"source code\fastman92 limit adjuster\fastman92 limit adjuster\howToMakePluginsCompatible.txt"

If FLA is not installed, then the memory addresses are set to default values (GTA Hoodlum 1.0 I beliefe).
Hence, using this class mods can be built that work with FLA and without FLA!

This version of the detector is aware of FLAs up to version 4.3. The function detect() checks if the
file "$fastman92limitAdjuster.asi" is in the current folder and reads its filesize to detect
the FLA version and then sets the addresses in the class.
You can use the global extern variable FLADetectorSAInstance (defined below) in your program.
Hence the usage is:

FLADetectorSAInstance.detect(); //Now fields are initilized and can be usedFLADetectorSAInstance.createLogfile(); //If you want to see the result of detect().

Links and further information:
The FLA thread: http://gtaforums.com/topic/733982-fastman92-limit-adjuster/
Compatibility post: http://gtaforums.com/topic/733982-fastman92-limit-adjuster/?p=1066099922
Update to date information can be found in the following file that is part of FLA donwload:
http://source code\fastman92 limit adjuster\fastman92 limit adjuster\howToMakePluginsCompatible.txt


Example output: FLADetector.log

Fastman92limitAdjusterDetector. Author: Goodidea82. Build: Jul 24 2017 19:30:27FLAVersion=403FLAFileSize=5919744Using the following addresses:CStreaming__ms_modelInfoPtrs=004C553BCStreaming__ms_aInfoForModel=00408ADDCAnimManager__ms_aAnimBlocks=004C51CECVehicleRecording__StreamingArray=01560EA2CTheScripts__StreamedScripts=00408ABAUsing the following indices:getTXDbaseIdx()=26700getCOLbaseIdx()=33650getIPLbaseIdx()=33940getDATbaseIdx()=34240getIFPbaseIdx()=35264getRRRbaseIdx()=35453getSCMbaseIdx()=35953

 

 

Edited by goodidea82
  • Like 1
Link to comment
Share on other sites

This is completely unnecessary, anyone skilled enough who writes ASI plugins knows better way to make the plugins with/without the FLA.

Link to comment
Share on other sites

PlatinumSerb

Good work goodidea! Im sure many people will find this useful.

 

@Fastman: if you have better alternatives please share them. It will only help the community. :)

Edited by PlatinumSerb
Link to comment
Share on other sites

It would probably be better to check if fla ASI is loaded instead of mining for the file yourself.

Link to comment
Share on other sites

Good work goodidea! Im sure many people will find this useful.

 

@Fastman: if you have better alternatives please share them. It will only help the community. :)

Read the address directly in the project.

 

The FLA exports some functions, which can be used 32-bit file IDs, 32-bit difficult file IDs and other functions.

See ForOtherProjects directory in RAR.

 

At this point it could to be mentioned that the SilentPatch was the first plugin to implement the 32-bit DFF/TXD IDs. Well done, Silent!

Edited by fastman92
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.