Virtual Mashine for DevXC - GameRecovery/GameModding (partially in MagicStudio)

DevXC language including syntax elements C#, c++, Ruby, Lua.

The code is compiled into bytes codes and executed on the DevXC-VM virtual machine

The version built into GameRecovery/GameModding includes the ability to use the functions of these products as well as complement their capabilities




Content:

 - GameRecovery function extantions
 - Language syntax: DevXC 

 

Function extantions:

Console message:

- void warning(string message) - from 9.05 version

- void error(string message) - from 9.05 version

 

Asset:

- PPtr FindPPtr(string assetName, long pathID)

- PPtr[] FindAssetsByNameAndType(string name, string assetType)  - from 9.02 version

 Example:

var v = FindAssetsByNameAndType("Girl", "Texture2D");

?"Count="+len(v)

dir=@"d:\11\";

foreach(p in v)
{
   file=dir+ GetName(p) + ".png";
   ?file
   SavePNG(file, p);
}


- string GetAssetType(PPtr)

- string GetName(object)

- Item FindItemByPPt(PPtr)

- IEnumerable<PPtr> EnumByAssetType(string class_name)

- object MakeAssetObject(PPtr)  - Make full asset info by PPtr or item

- PPtr ChangeToPPtr(object) - Change to PPtr link

- object GetAssetField(asset_object)

- void SetAssetField(asset_object, object)  - Set new value to asset field

- string GetAssetFieldsYamp(asset_object)

- void SelectItemOnTreeView(object item) - select treeview item by PPtr/Item/node  

- IEnumerable<PPtr> EnumAllAssets() - from 9.02 version

IEnumerable<PPtr> EnumAllAssetsFiltered() - Enum all assets by curret UI filter (treeView filter) (from 9.02 version)


Text tools:

bool BytesIsText(byte[] in_buffer) - is buffer text - return true
sting BytesToText(byte[] in_buffer) - if buffer is text return text
sting BytesToTextUNCODE(byte[] in_buffer) - convert to text as unicode
sting BytesToTextUtf8(byte[] in_buffer) - convert to text as utf8


UI input tools:

- string EditText(string caption, string text) - show edit text dialog (from 9.02 version)

string InputTextLine(string caption, string text) - show input text line dialog (from 9.02 version)

- void ShowStatus(string status) - set UI status (status bar) (from 9.02 version)



- object GetVariableStatic(string name) - for values stored by process run

- object SetVariableStatic(string name, object value) -for values stored by process run

- object GetSavedVariable(string name) - Save value for restore after close application

object SaveVariable(string name, object value) - Read saved value


Direcotry tools:

- string[] GetFiles(string directory_name) - Get files from directory

- string[] GetFiles(string directory_name, string filter) - Get files from directory by filter

- string[] GetFiles(string directory_name, string filter, bool allDirectories) - Get files from directory by filter recursive


Unpacker tools:

void ShowDebug()

void ClearDebug()

void Clear()

void OpenGameDir(string openPath, custom_file_list [])

void openAutoSelect(string file_name)

void openAPKFile(string file_name)

void openIPAFile(string file_name)

void openUnitypackageFile(string file_name)

void openWebGLFile(string file_name)

void openOsgJS(string file_name)

void MakeScriptsOfProject(string savePath)

void ExportToDir(string savePath,exp_items [])

void ExportForRepack(string savePath,exp_items [])

void ImportForRepack(string openPath)

void MakePrefabs(string savePath)

void MakeUnityUnitypackage(string savePath,assets [])

void ExportUassetsFromUnrealEnginePAK(string savePath, exp_items [])

void SaveSubContents(string savePath)

void SaveAPK(string out_dir, string APKSignParams)

void ExportConvertedContent(string savePath, PPtr)

- void SaveDUMP(string savePath, PPtr) - save asset dump in devxbxml format  (from 9.02 version)

- void SaveOBJ(string savePath, PPtr) - save model as obj format (from 9.02 version)

void SavePNG(string savePath, PPtr)

void SaveAsWAV(string savePath, PPtr)

void SaveSubContent(string savePath, PPtr)

void SaveAssetRawWithHeader(string savePath, PPtr)

- void MakeFBX(string savePath, exp_items=[])

void ReplaceImage(string sourceFile,PPtr)

void ReplaceText(string text,PPtr)

void ReplaceAudio(string text,PPtr)

void ReplaceTextByFile(string sourceFile,PPtr)


Compressors:

- byte[] GzipCompress(byte[] in_buffer);

- byte[] GzipDecompress(byte[] in_buffer);

// from 9.04
- byte[] BrotliDecompress(byte[] in_buffer);
- byte[] LZ4Decompress(byte[] in_buffer);
byte[] LZ4Decompress(byte[] in_buffer, int decompessed_size);
- byte[] LZMADecompress(byte[] in_buffer);





Language syntax: DevXC 

1) Constants

null nil

true

false

 

2) Keyword

if else elsif or and not for while do_while foreach goto break continue return this

null nil true false struct new end then var local mutable let do

def

3) Commentaries

// Comment 1

-- Comment 2

 

4) Stream initializing base types

(on declare value read from the binary stream):

 

TYPE @variable_name

 

Types:

string  - utf8 text (4 byte len and text bytes)

char[bytes_len] - utf8 string(fixed len)

char_unicode[bytes_len] - unicode string (fixed len)

string_null - utf8 text end with zero

int, int32, sint32

uint, uint32

unsigned int

int8, uint8, sint8, byte, sbyte

bool,

short, int16, sint16

ushort, uint16, unsigned short

long , int64, sint64

ulong, uint64, unsigned long

float

double

pptr

pptr8

vector2, vector3, vector4 - int vectors

vector2f, vector3f, vector4f - floaf vectors

Hash128

GUID

TypelessData - byte massive (4 byte len and bytes)

byte[bytes_len] - byte massive (fixed len)

colorrgb

colorrgba

varint

varuint

 

Examples:

int val;// read from binary stream int value and set to val

float f;// read from binary stream float value and set to f

byte[4] b;// read from binary stream 4 bytes and set to b

 

 

5) Stream initializing Massives: type - any base type or structure

 

type[] @name  - massiv (4 byte count and data count*sizeof(type) ), where type is structure or base type

type @name[]

 

type[count] @name - fixed massive (data count*sizeof(type) ), where type is structure or base type

 

type @name[count]

 

6) Local/Global variables


TYPE val = extention  - where TYPE is base type

value_name=extention

var val = extention

local val = extention

mutable val = extention

let val = extention

 

Ruby style:

_value_name - local value

value_name - class instance value (for class declaration)

@@value_name - static class value (visible for all class instance)

$value_name - global value

 

 

Examples:

v=34

empty_val=null

var v2=45.5; // auto type

local v3=55; // auto type

 

int i=10; // set with int type

string s=”ddd”;

@global1=”global string” // global value - auto string type

 

 

7) Local massive

a) value = [val1, val2, .. ,valN];

b) value = new type[size];

c) value = type[size];

d) type[size] value_name;

e) type value_name[size];


type - element type
size - massive type

Example:

v=[1,2,3,”56”]; // object massive

val1 = new int[5]; // int massive 
val2 = string[10]; // string massive

bool[10] bool_massive;
short short_mass[20];

 

 

8) Dictionary

value = {val1, val2, .. ,valN};

Example:

v={1,2,3,”56”};

 

9) Structures:


struct
struct_name

{

// fields

// functions

// constructor

// commands

}

class struct_name

{

// fields

// functions

// constructor

// commands

}

 

Create instance:

struct_name struct_val; //without init class variables

v = new class_name

v = new class_name(v1,v2)

v = class_name.new

v = class_name.new(v1,v2)

 

v=new struct_test;

v2=test_class.new

v3=new test_class()

 

struct struct_test

{

 function struct_test()

 {

 }

 

 int value1;

 

sub_struct_name struct_val;

struct sub_struct_name

{

       string value_str;

       int val=10;

}

}

class test_class

{

}

 

 

 

 

10) Function call

 

print(“123”);

print 1,3,5 // as print(1,3,5)

pow 5,2  // as pow(5,2)

 

11) Function declaration:

 

Javascript style

function function_name(type1 parametr1, type2 parametr2, ...)

{

return (...);

}

 

Lua style

function function_name(type1 parametr1, type2 parametr2, ...)

return (...);

end

 

Ruby style

def function_name

// code

end

 

C# style

return_type Func1(type1 parametr1, type2 parametr2, ...)

{

return v1+1;

}

 

 

Example:

 

//-----------

fun1();

fun_lua_style();

Test t=new Test();

t.fun2();

//-----------

 

function fun1()

{

    print(“execute fun1”);

     return “test 1”;

}

 

function fun_lua_style()

    print(“execute fun_lua_style”);

   return “test 2”;

end

 

struct Test

{

function Test()

{

print(“execute Test constructor”);

}

function fun2()

{

print(“execute Test.fun2”);

return (1,2,”test”);

}

void fun4()

{

print(“execute Test.fun4”);

}

 

}

 

 

 

12) Special function START END


BEGIN

{

// Sets the code that will be executed before the program starts.

}

END

{

// Similar to BEGIN, but executed at the end of the program execution, for example:

}

 

 

13) Math operations:  = . +  -  /  *  %   +=   -=   *=   /=   >>=  <<=  ++  --  **


v1**v2 - is as Pow(v1,v2)

 

val1 = 10

val1 = val2 * 3 + val3 + 1 + ( val4 * 10 )

v = v1 / 5

v = v1 % 10

v++

--v

 

14) Bit operations: & | ^ >> << &= |= ^= ~

 

val1 = val2 & 3

v = v1 | 1

v = v ^ 127

v &= 1

 

15) Logic operations: && || == != ~= (not equal) > < >= <= !  and or not

 

res = b2 == 5

res = b1 != b2

if(v>0) { }

v=!res

 

16) Get/Set massive values

v=[1,2,3]

i=0

print(v[i])

v[0]=55;

print(v[0])

 

17) Logic:

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

if (criteria_expression)

{ }

else

{ }

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

 

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

if criteria_expression [then]

..

else

..

end

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

 

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

if criteria_expression [then]

..

elsif criteria_expression2 [then]

..

elsif criteria_expression3

..

else

..

end

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

 

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

-- Run the code if the condition is true.

code if criteria_expression    


Example:

v=1

puts "v equal 1" if v==1

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

 

 

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

while(criteria_expression) {  }

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

do

{

}

while(criteria_expression)

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

 

 

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

while criteria_expression [do]

..

end

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

 

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

do

   ..

while criteria_expression

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

 

 

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

do_while(criteria_expression) {  }

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

 

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

for(init_block; criteria_blocl; math_bloc) {  }

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

 

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

foreach(val_name in enum_expression) {  }

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

 

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

goto point_label

point_label:

...

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

 

Example:

 

v=1

goto point_label;

v=5

point_label:

print(v); // show 1

 

for(int i=0; i<10; i++) { print(i); }

 

v={1,2,3,"fff"}

foreach(int c in v)

{

  ?c // print massive element

  break;

}

v=10

 

while v>0

    ?v--

end

 

18) Input binary stream functions:

long offset([stream]) - show relative offset (from last call offset())

offset([stream,] int) - set relative offset (from current position)

long offset_struct() - show relative offset (in structure start)

offset_struct(int) - set relative offset (from structure start)

position([stream,] int) - set global offset (input binary stream)

long position([stream]) - show global offset (input binary stream)

long lenght([stream]) - lenght of binary stream

 

align([stream]) - align by 4 bytes

align([stream,] int)

skip([stream,] int) - skip bytes

 

byte[] bytes([stream]) - read from stream bytes count and read bytes buffer

byte[] bytes([stream,] int len) - read from stream len bytes

type_name read([stream,] type_name) - read from stream value by type_name

object[] read([stream,] type1,type2,type3,...) - read from stream values by types

 

 

stream create(string file_name) - Create file for binary output

stream openWrite(string file_name) - Open file for binary output (append)

void close([stream]) - Close file for binary output

void write([stream,] val1,val2, ...) - Write variable to output binary stream

void writeText([stream,] val1,val2, ...) - Write variable to output binary stream as text

void writeLine([stream,] val1,val2, ...) - Write variable to output binary stream as text - end with new line

void writeBytes([stream,] val1,val2, ...) - Write variable bytes to default output binary stream

void writeStringNull([stream,] val1,val2, ...) - Write variable string with null end to output binary stream

void writeStringBytes([stream,] val1,val2, ...) - Write variable string bytes to output binary stream

byte[] readAllBytes(string file_name) - Read all bytes from local file

void writeAllBytes(string file_name, byte[] buff) - Write all bytes to local file

 

bool echo(bool) - on/off auto show read from stream value

echoOff() - off auto show read from stream value

echoOn() - on auto show read from stream value (default on)

 

19) Common functions:

 

print(expression) - show expression result

print(22+45);

print(val);

puts(expression) - show expression result

?expression - show expression result

WriteLine(expression) - as print

 

LITTLE_ENDIAN() - set LITTLE ENDIAN read

BIG_ENDIAN() - set BIG ENDIAN read

end() - finish current structure

string typeof(variable_name) - value type name

string type(variable_name) - value type name

string ToString(variable_name) - value to string

byte[] ToBytes(variable_name) - value to bytes

 

 

int len(variable_name) - massive, dictionary or string - length

double pow(x, y) - Math Pow

double sin(v) - Math Sin

double cos(v) - Math Cos

double tan(v) - Math Tan

double asin(v) - Math Asin

double acos(v) - Math Acos

double atan(v) - Math Atan

double abs(v) - Math Abs

double pi() - Math PI value

object min(v1,v2,v3 ...) - Minimum (param: values or array)

object max(v1,v2,v3 ...) - Maximum (param: values or array)

 

 

20) Network functions

 

string DownloadString(string url) - download string by url (GET)

string UploadValues(string url, object structure) - upload structure as parameters (POST)

string UploadBytes(string url, byte[] buff) - upload buffer (POST)

 

 

21) Runtime functions

 

object RunScriptCode(string code_text) -  Execute DevC code by source text

object RunScriptBinary(byte[] code_binary) -  Execute DevXC compiled code

 

22) Common variables function

String functions (String.Name(params)):

int IndexOf(string s)

int IndexOf(string s, int begin)

int IndexOfWord(string s)

int IndexOfWord(string s, int begin)

bool Contains(string s)

bool ContainsOfWord(string s)

bool ContainsOfWord(string s, int begin)

 

int LastIndexOf(string s)

int LastIndexOf(string s, int begin)

string Substring(int begin)

string Substring(int begin, int len)

string Remove(int begin)

string Remove(int begin, int len)

string Replace(string s_from, string s_to)

string Split(string chars)

string Trim()

string Trim(string chars)

string TrimStart()

string TrimEnd(string chars)

string Trim()

string Trim(string chars)

string ToLower()

string ToUpper()

int Length()

 

Example:

v= "1234567890";

?"Index: " + v.IndexOf("90")

?"Substring: " +v.Substring(0,3)

// Index: 8

// Substring: 123

 

 

 

 

 

23) Examples:

 

// Calculate PI value

 

// PI pi_struct;

var pi_struct = new PI();

pi_struct.CalcPi();

pi_struct.Show();

 

pi= pi_struct.m_pi;

 

Console.WriteLine("Result: "+pi);

if (pi=="3.14159265358979" || pi=="3.1415926535897878143417581995")

{

    Console.WriteLine("Test - OK");

}

else

{

    Console.WriteLine("Test - FAILED!!!");

}

 

//=======================

struct PI

{

  decimal m_pi=0;

  int step_count=10;

  function PI(int count)

  {

 if (count>0)

{

     step_count=count;

}

  }

  

  function CalcPi()

  {

if (step_count==0)

{

  step_count=10;

}

for (decimal i=0; i < step_count; i++)

{

      m_pi = m_pi + CalcPiStep(i);

}

 return m_pi;

  }

 

  decimal CalcPiStep(decimal i)

  {

       v= (1 / (pow(16, i))) * (4 / ((8 * i) + 1) - 2 / ((8 * i) + 4) - 1 / ((8 * i) + 5) - 1 / ((8 * i) + 6));

        return v;

  }

  

  void Show()

  {

        ?"PI: "+m_pi;

  }

}

 

 

//=======================

// Result: 3.1415926535897911463887768051