Git Product home page Git Product logo

gta-v-script-decompiler's Introduction

V/RDR Script-Decompiler

A command-line tool that will decompile the script resources (xsc,csc,ysc,osc) files from the X360, PS3, PS4 and PC versions of Grand Theft Auto V and Red Dead Redemption 2 (RDR3). You are not allowed to use this tool for the purpose of creating modification in GTA:Online/RDR:Online.

Sources

  1. GTA-V-Script-Decompiler
  2. gta5-nativedb-data: Native table used for V & V-Console decompilation. Dataset slightly modified to include cross-mapping. 32-bit console hashes use only the v323 Jenkins hashes.
  3. rdr3-nativedb-data: Native table used for RDR3 & RDR-Console decompilation. Dataset will require modification on version bump & hash changes.
  4. emcifuntik: 1737-to-1868 V Crossmap.

Dependencies

  1. Newtonsoft.Json 12.0.3
  2. CommandLineParser 2.6.0

Options

  --help             Display this help screen.
  --version          Display version information.
  -i, --in           Input Directory/File Path.
  -o, --out          Output Directory/File Path.
  -c, --opcode       Opcode Set (v|vconsole|rdr|rdrconsole) (Default: v)
  -n, --natives      native json file. On null use the use the defined opcode set to select a native resource.
  -f, --force        Allow output file overriding. (Default: false)
  -a, --aggregate    Compute aggregation statistics of bulk dataset. (Default: false)
  --minlines         Minimum function line count for aggregation (Default: -1)
  --minhits          Minimum number of occurrences for aggregation. (Default: -1)
  --gzin             Compressed Input (GZIP) (Default: false)
  --gzout            Compress Output (GZIP) (Default: false)

  --default          Use default configuration (Default: false)
  --uppercase        Use uppercase native names (Default: true)
  --namespace        Concatenate Namespace to Native definition (Default: true)
  --int              Integer Formatting Method (int, uint, hex) (Default: "int")
  --hash             Use hash (Entity.dat) lookup table when formatting integers (Default: true)
  --arraysize        Show array sizes in definitions (Default: true)
  --declare          Declare all variables at the beginning of function/script definitions (Default: true)
  --shift            Shift variable names, i.e., take into consideration the immediate size of stack values (Default: false)
  --mt               Multithreaded decompilation (Default: true)
  --position         Show function location in definition (Default: false)

Examples

# Decompile a single RDR Native Script
decompiler.exe --default --opcode=rdr -n "Root:\rdr3-nativedb-data\natives.json" -i "Root:\rdr\ysc\startup_mp.ysc.full" -o "../somerelativepath/startup_mp.ysc.c"

# Bulk decompile GTA Native Scripts with aggregation statistics
decompiler.exe --default --opcode=v -a -n "Root:\gta5-nativedb-data\natives.json" -i "Root:\gta\ysc" -o "Root:\gta-v-decompiled-scripts.1737"

# Bulk decompile compressed RDR3
decompiler.exe --default --opcode=rdr --gzin -n ./rdr3-nativedb-data/natives.json -i ./ysc/script_mp_rel -o ./rdr3-decompiled-scripts.1232/script_mp_rel

Aggregation

A ScriptFile decompiles each function in a way that removes all state data. These stateless-functions are then compared (via SHA256) against the stateless-functions to all other scripts to create a collection of shared (aggregated) functions. For example,

int af_intro_t_sandy.func_23(int iParam0)
{
	int iVar0;
	int iVar1;

	if (ENTITY::DOES_ENTITY_EXIST(iParam0))
	{
		iVar1 = ENTITY::GET_ENTITY_MODEL(iParam0);
		iVar0 = 0;
		while (iVar0 <= 2)
		{
			if (func_24(iVar0) == iVar1)
			{
				return iVar0;
			}
			iVar0++;
		}
	}
	return 145;
}

Stateless:

int func_(Param)
{
	int i;
	int i;

	if (ENTITY::DOES_ENTITY_EXIST(Param))
	{
		Var = ENTITY::GET_ENTITY_MODEL(Param);
		Var = 0;
		while (Var <= 2)
		{
			if (func_(Var) == Var)
			{
				return Var;
			}
			Var++;
		}
	}
	return 145;
}

Which exists in 615 other locations across the v1737 GTA V PC natives.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.