Welcome
Ladies and Gents:

These forums are now closed and registration disabled.

Please join us at our new forum on Proboards. Our hope is that these new forums are more stable, provide more and better features, and allow continuation of the project forums in a safer, more secure, long term environment.

me3explorer.proboards.com

--The ME3Explorer Team

Done Research: Script byte code

Technical research related to the structure of Mass Effect game files.

Done Research: Script byte code

Postby WarrantyVoider » 25 Aug 2012, 16:13

This will be my post for updating the process of reversing the script code. This is very important for doing any real mods.

PreInformation:
Spoiler:
ME3 is based on Unreal Engine 3, and as big companys as biowarEA can purchase the source code, they can also modify everything. For sure is another .upk .u ... fileformat, its called .pcc here. When a game should do something, f.e. like when pressing a button on a door, the developer of the game has to write a "script" for it. This is similar to C++ standarts and when the game is "cooked" (generated for release) this script will be saved as a stream of "tokens". For knowing how that works, you first have to know how a usual compiler/interpreter works:

1.step: generate Tokens from the code text (aka lexing/lexer)
==============================================
for this example I use this simple line of code:
a = b + c;

then token generated from these are a pair of two values, the text and its meaning, so this translates to:
Token(0): "a",variable
Token(1): "=",special_character
Token(2): "b",variable
Token(3): "+",special_character
Token(4): "c",variable

2.step: generate ABS (abstract syntax tree):
for the compiler or interpreter to know what these token means, they are picked up by algorithms and put in a treestructure, how is not important at this point. This looks then like this:
Image

3.step: compiling/interpreting the ABS
well this is actually easier than it sounds, then computer now just runs from top to bottom the tree along, and either runs the command (interpreting) or generates f.e. machinecode from it (compiling)

Well first the bad news:
If your code is in step 3 stage, you can never exactly get the original code, just low-level representation from it.

But the Good news:
Unreal Engine is an Interpreter, and in pccs are only the Tokens saved! Wohoo, thats means we can recreate the codetext from the developers and also change it! How? This is easy again, once you know the format(and it stays the same over pcc files) you just add the text from on token after another.

Now then again, the bad news:
this "almost standart" set of bytecode tokens seems to have changed, not completly but partly

Stuff you need to have to examine this:
Spoiler:
-obviously ME3 Explorer, especially PCCEditor2
-its sourcecode (see SVN link in knowledgebase)
-UnHood (which my current knowledge about this is mostly build upon)
http://unhood.googlecode.com/svn/trunk/
-this (seems old) http://www.scribd.com/doc/54572848/UT-P ... ile-Format

Ok the current known list of bytecodetokens(from UnHood):
Spoiler:
EX_LocalVariable=0x00;
EX_InstanceVariable=0x01;
EX_DefaultVariable=0x02;
EX_Return=0x04;
EX_Switch=0x05;
EX_Jump=0x06;
EX_JumpIfNot=0x07;
EX_Stop=0x08;
EX_Assert=0x09;
EX_Case=0x0A;
EX_Nothing=0x0B;
EX_LabelTable=0x0C;
EX_GotoLabel=0x0D;
EX_EatReturnValue=0x0E;
EX_Let=0x0F;
EX_DynArrayElement=0x10;
EX_New=0x11;
EX_ClassContext=0x12;
EX_Metacast=0x13;
EX_LetBool=0x14;
//EX_EndParmValue=0x15?
EX_EndFunctionParms=0x16;
EX_Self=0x17;
EX_Skip=0x18;
EX_Context=0x19;
EX_ArrayElement=0x1A;
EX_VirtualFunction=0x1B;
EX_FinalFunction=0x1C;
EX_IntConst=0x1D;
EX_FloatConst=0x1E;
EX_StringConst=0x1F;
EX_ObjectConst=0x20;
EX_NameConst=0x21;
EX_RotationConst=0x22;
EX_VectorConst=0x23;
EX_ByteConst=0x24;
EX_IntZero=0x25;
EX_IntOne=0x26;
EX_True=0x27;
EX_False=0x28;
EX_NativeParm=0x29;
EX_NoObject=0x2A;
EX_IntConstByte=0x2C;
EX_BoolVariable=0x2D;
EX_DynamicCast=0x2E;
EX_Iterator=0x2F;
EX_IteratorPop=0x30;
EX_IteratorNext=0x31;
EX_StructCmpEq=0x32;
EX_StructCmpNe=0x33;
EX_UnicodeStringConst=0x34;
EX_StructMember=0x35;
EX_DynArrayLength=0x36;
EX_GlobalFunction=0x37;
EX_PrimitiveCast=0x38;
EX_DynArrayInsert=0x39;
EX_ByteToInt=0x3A;//EX_ReturnNothing=0x3A
EX_EqualEqual_DelDel=0x3B;
EX_NotEqual_DelDel=0x3C;
EX_EqualEqual_DelFunc=0x3D;
EX_NotEqual_DelFunc=0x3E;
EX_EmptyDelegate=0x3F;
EX_DynArrayRemove=0x40;
EX_DebugInfo=0x41;
EX_DelegateFunction=0x42;
EX_DelegateProperty=0x43;
EX_LetDelegate=0x44;
EX_Conditional=0x45;
EX_DynArrayFind=0x46;
EX_DynArrayFindStruct=0x47;
EX_LocalOutVariable=0x48;
EX_DefaultParmValue=0x49;
EX_EmptyParmValue=0x4A;
EX_InstanceDelegate=0x4B;
EX_GoW_DefaultValue=0x50;
EX_InterfaceContext=0x51;
EX_InterfaceCast=0x52;
EX_EndOfScript=0x53;
EX_DynArrayAdd=0x54;
EX_DynArrayAddItem=0x55;
EX_DynArrayRemoveItem=0x56;
EX_DynArrayInsertItem=0x57;
EX_DynArrayIterator=0x58;

EX_ExtendedNative=0x60;
EX_FirstNative=0x70;

The current state of done functions:
Spoiler:
EX_LocalVariable:
Format:
[Tokenbyte][int32 index]
Text:
"LocVar(" + name[index] + ")"

EX_InstanceVariable:
Format:
[Tokenbyte][int32 index]
Text:
"InstVar(" + name[index] + ")"

EX_Return:
Format:
[Tokenbyte]
Text:
"Return();"

EX_NativeParm:
Format:
[Tokenbyte][int32 index]
Text:
"NatParam(" + name[index] + ")"

EX_Switch:
Format:
[Tokenbyte][TOKEN A]
Text:
"Switch(" + A.text + ")"

EX_Jump:
Format:
[Tokenbyte][int32 offset]
Text:
"Jump(" + offset + ")"

EX_JumpIfNot:
Format:
[Tokenbyte][int16 offset][TOKEN A]
Text:
"If(!(" + A.text + ")) jump(" + offset + ");"

EX_Nothing:
Format:
[Tokenbyte]
Text:

EX_LabelTable:
Format:
[Tokenbyte][int32 index]
Text:
name[index]

EX_Let:
Format:
[Tokenbyte][TOKEN A][TOKEN B]
Text:
"Let((" + A.text + ") = ( " + B.text + "))"

EX_EqualEqual_DelDel:
Format:
[Tokenbyte][TOKEN A][TOKEN B]
Text:
"(" + A.text + " == " + B.text + ")"

EX_EndOfScript:
[Tokenbyte]
Text:
"EndOfScript"

And last but not least an example:
Spoiler:
Image


so if you want faster results help me ^^ ;p

greetz WV
always backup your files!
mess with the best or die like the rest!
"I tried everything!" - "mkay, please list that..." ; please dont pm me for help, we have a help section

WarrantyVoider has been thanked by:
User avatar
WarrantyVoider
Emeritus
 
Posts: 2270
Joined: 22 Aug 2012, 11:33
Has thanked: 480 time
Have thanks: 626 time

Re: Current Research: Script byte code

Postby WarrantyVoider » 29 Aug 2012, 01:09

Found new more complete table
Spoiler:
enum Token
{
EX_LocalVariable = 0x00, // A local variable.
EX_InstanceVariable = 0x01, // An object variable.
EX_DefaultVariable = 0x02, // Default variable for a concrete object.
EX_Return = 0x04, // Return from function.
EX_Switch = 0x05, // Switch.
EX_Jump = 0x06, // Goto a local address in code.
EX_JumpIfNot = 0x07, // Goto if not expression.
EX_Stop = 0x08, // Stop executing state code.
EX_Assert = 0x09, // Assertion.
EX_Case = 0x0A, // Case.
EX_Nothing = 0x0B, // No operation.
EX_LabelTable = 0x0C, // Table of labels.
EX_GotoLabel = 0x0D, // Goto a label.
EX_EatString = 0x0E, // Ignore a dynamic string.
EX_Let = 0x0F, // Assign an arbitrary size value to a variable.
EX_DynArrayElement = 0x10, // Dynamic array element.!!
EX_New = 0x11, // New object allocation.
EX_ClassContext = 0x12, // Class default metaobject context.
EX_MetaCast = 0x13, // Metaclass cast.
EX_LetBool = 0x14, // Let boolean variable.
// EX_Unused = 0x15
EX_EndFunctionParms = 0x16, // End of function call parameters.
EX_Self = 0x17, // Self object.
EX_Skip = 0x18, // Skippable expression.
EX_Context = 0x19, // Call a function through an object context.
EX_ArrayElement = 0x1A, // Array element.
EX_VirtualFunction = 0x1B, // A function call with parameters.
EX_FinalFunction = 0x1C, // A prebound function call with parameters.
EX_IntConst = 0x1D, // Int constant.
EX_FloatConst = 0x1E, // Floating point constant.
EX_StringConst = 0x1F, // String constant.
EX_ObjectConst = 0x20, // An object constant.
EX_NameConst = 0x21, // A name constant.
EX_RotationConst = 0x22, // A rotation constant.
EX_VectorConst = 0x23, // A vector constant.
EX_ByteConst = 0x24, // A byte constant.
EX_IntZero = 0x25, // Zero.
EX_IntOne = 0x26, // One.
EX_True = 0x27, // Bool True.
EX_False = 0x28, // Bool False.
EX_NativeParm = 0x29, // Native function parameter offset.
EX_NoObject = 0x2A, // NoObject.
EX_IntConstByte = 0x2C, // Int constant that requires 1 byte.
EX_BoolVariable = 0x2D, // A bool variable which requires a bitmask.
EX_DynamicCast = 0x2E, // Safe dynamic class casting.
EX_Iterator = 0x2F, // Begin an iterator operation.
EX_IteratorPop = 0x30, // Pop an iterator level.
EX_IteratorNext = 0x31, // Go to next iteration.
EX_StructCmpEq = 0x32, // Struct binary compare-for-equal.
EX_StructCmpNe = 0x33, // Struct binary compare-for-unequal.
EX_UnicodeStringConst = 0x34, // Unicode string constant.
EX_StructMember = 0x35, // Struct member.
EX_DynArrayLength = 0x36, // A dynamic array length for setting/getting
EX_GlobalFunction = 0x37, // Call non-state version of a function.
EX_PrimitiveCast = 0x38, // A casting operator for primitives which reads the type as the subsequent byte
EX_DynArrayInsert = 0x39, // Inserts into a dynamic array
EX_DynArrayRemove = 0x40, // Removes from a dynamic array
EX_DebugInfo = 0x41, //DEBUGGER Debug information
EX_DelegateFunction = 0x42, // Call to a delegate function
EX_DelegateProperty = 0x43, // Delegate expression
EX_LetDelegate = 0x44, // Assignment to a delegate
EX_ExtendedNative = 0x60,
EX_FirstNative = 0x70,
EX_Max = 0x1000,
};

enum Casts
{
CST_RotatorToVector = 0x39,
CST_ByteToInt = 0x3A,
CST_ByteToBool = 0x3B,
CST_ByteToFloat = 0x3C,
CST_IntToByte = 0x3D,
CST_IntToBool = 0x3E,
CST_IntToFloat = 0x3F,
CST_BoolToByte = 0x40,
CST_BoolToInt = 0x41,
CST_BoolToFloat = 0x42,
CST_FloatToByte = 0x43,
CST_FloatToInt = 0x44,
CST_FloatToBool = 0x45,
CST_ObjectToBool = 0x47,
CST_NameToBool = 0x48,
CST_StringToByte = 0x49,
CST_StringToInt = 0x4A,
CST_StringToBool = 0x4B,
CST_StringToFloat = 0x4C,
CST_StringToVector = 0x4D,
CST_StringToRotator = 0x4E,
CST_VectorToBool = 0x4F,
CST_VectorToRotator = 0x50,
CST_RotatorToBool = 0x51,
CST_ByteToString = 0x52,
CST_IntToString = 0x53,
CST_BoolToString = 0x54,
CST_FloatToString = 0x55,
CST_ObjectToString = 0x56,
CST_NameToString = 0x57,
CST_VectorToString = 0x58,
CST_RotatorToString = 0x59,
CST_StringToName = 0x60,
CST_Max = 0xFF,
};
enum PollSFuncs
{
EPOLL_Sleep = 384,
EPOLL_FinishAnim = 385
};
always backup your files!
mess with the best or die like the rest!
"I tried everything!" - "mkay, please list that..." ; please dont pm me for help, we have a help section
User avatar
WarrantyVoider
Emeritus
 
Posts: 2270
Joined: 22 Aug 2012, 11:33
Has thanked: 480 time
Have thanks: 626 time

Re: Current Research: Script byte code

Postby WarrantyVoider » 30 Aug 2012, 20:45

new update, current state of done functions:
Spoiler:
caseEX_LocalVariable://0x00
caseEX_InstanceVariable://0x01
caseEX_Return://0x04
caseEX_Switch://0x05
caseEX_Jump://0x06
caseEX_JumpIfNot://0x07
caseEX_Nothing://0x0B
caseEX_LabelTable://0x0C
caseEX_Let://0x0F
caseEX_LetBool://0x14
caseEX_LetDelegate://0x44
caseEX_EndParmValue://0x15
caseEX_EndFunctionParms://0x16
caseEX_Self://0x17
caseEX_Context://0x19
caseEX_VirtualFunction://0x1B
caseEX_FinalFunction://0x1C
caseEX_FloatConst://0x1E
caseEX_ObjectConst://0x20
caseEX_NameConst://0x21
caseEX_IntZero://0x25
caseEX_True://0x27
caseEX_False://0x28
caseEX_NativeParm://0x29
caseEX_NoObject://0x2A
caseEX_ByteToInt://0x3A
caseEX_EqualEqual_DelDel://0x3B
caseEX_DefaultParmValue://0x49
caseEX_EndOfScript://0x53
caseEX_Unkn1://0x5E

30/83 Functions
always backup your files!
mess with the best or die like the rest!
"I tried everything!" - "mkay, please list that..." ; please dont pm me for help, we have a help section
User avatar
WarrantyVoider
Emeritus
 
Posts: 2270
Joined: 22 Aug 2012, 11:33
Has thanked: 480 time
Have thanks: 626 time

Re: Current Research: Script byte code

Postby WarrantyVoider » 01 Sep 2012, 22:05

I discovered another token list, which is actually defined in core.pcc but I can use a list. Its just that the time to finish this got at least twice as long. On the other hand I think this is it, so finish comes in view range:
Spoiler:
enum ENatives {
NATIVE_SaveConfig = 0x0218,
NATIVE_Disable = 0x0076,
NATIVE_Enable = 0x0075,
NATIVE_GetStateName = 0x011C,
NATIVE_IsInState = 0x0119,
NATIVE_GotoState = 0x0071,
NATIVE_WarnInternal = 0x00E8,
NATIVE_LogInternal = 0x00E7,
NATIVE_NotEqual_IntStringRef = 0x03ED,
NATIVE_NotEqual_StringRefInt = 0x03EC,
NATIVE_NotEqual_StringRefStringRef = 0x03EB,
NATIVE_EqualEqual_IntStringRef = 0x03EA,
NATIVE_EqualEqual_StringRefInt = 0x03E9,
NATIVE_EqualEqual_StringRefStringRef = 0x03E8,
NATIVE_Subtract_QuatQuat = 0x010F,
NATIVE_Add_QuatQuat = 0x010E,
NATIVE_NotEqual_NameName = 0x00FF,
NATIVE_EqualEqual_NameName = 0x00FE,
NATIVE_IsA = 0x00C5,
NATIVE_ClassIsChildOf = 0x0102,
NATIVE_NotEqual_ObjectObject = 0x0077,
NATIVE_EqualEqual_ObjectObject = 0x0072,
NATIVE_Repl = 0x00C9,
NATIVE_Asc = 0x00ED,
NATIVE_Chr = 0x00EC,
NATIVE_Locs = 0x00EE,
NATIVE_Caps = 0x00EB,
NATIVE_Right = 0x00EA,
NATIVE_Left = 0x0080,
NATIVE_Mid = 0x007F,
NATIVE_InStr = 0x007E,
NATIVE_Len = 0x007D,
NATIVE_SubtractEqual_StrStr = 0x0144,
NATIVE_AtEqual_StrStr = 0x0143,
NATIVE_ConcatEqual_StrStr = 0x0142,
NATIVE_ComplementEqual_StrStr = 0x007C,
NATIVE_NotEqual_StrStr = 0x007B,
NATIVE_EqualEqual_StrStr = 0x007A,
NATIVE_GreaterEqual_StrStr = 0x0079,
NATIVE_LessEqual_StrStr = 0x0078,
NATIVE_Greater_StrStr = 0x0074,
NATIVE_Less_StrStr = 0x0073,
NATIVE_At_StrStr = 0x00A8,
NATIVE_Concat_StrStr = 0x0070,
NATIVE_RotRand = 0x0140,
NATIVE_GetUnAxes = 0x00E6,
NATIVE_GetAxes = 0x00E5,
NATIVE_SubtractEqual_RotatorRotator = 0x013F,
NATIVE_AddEqual_RotatorRotator = 0x013E,
NATIVE_Subtract_RotatorRotator = 0x013D,
NATIVE_Add_RotatorRotator = 0x013C,
NATIVE_DivideEqual_RotatorFloat = 0x0123,
NATIVE_MultiplyEqual_RotatorFloat = 0x0122,
NATIVE_Divide_RotatorFloat = 0x0121,
NATIVE_Multiply_FloatRotator = 0x0120,
NATIVE_Multiply_RotatorFloat = 0x011F,
NATIVE_NotEqual_RotatorRotator = 0x00CB,
NATIVE_EqualEqual_RotatorRotator = 0x008E,
NATIVE_IsZero = 0x05DD,
NATIVE_ProjectOnTo = 0x05DC,
NATIVE_MirrorVectorByNormal = 0x012C,
NATIVE_VRand = 0x00FC,
NATIVE_Normal = 0x00E2,
NATIVE_VSize = 0x00E1,
NATIVE_SubtractEqual_VectorVector = 0x00E0,
NATIVE_AddEqual_VectorVector = 0x00DF,
NATIVE_DivideEqual_VectorFloat = 0x00DE,
NATIVE_MultiplyEqual_VectorVector = 0x0129,
NATIVE_MultiplyEqual_VectorFloat = 0x00DD,
NATIVE_Cross_VectorVector = 0x00DC,
NATIVE_Dot_VectorVector = 0x00DB,
NATIVE_NotEqual_VectorVector = 0x00DA,
NATIVE_EqualEqual_VectorVector = 0x00D9,
NATIVE_GreaterGreater_VectorRotator = 0x0114,
NATIVE_LessLess_VectorRotator = 0x0113,
NATIVE_Subtract_VectorVector = 0x00D8,
NATIVE_Add_VectorVector = 0x00D7,
NATIVE_Divide_VectorFloat = 0x00D6,
NATIVE_Multiply_VectorVector = 0x0128,
NATIVE_Multiply_FloatVector = 0x00D5,
NATIVE_Multiply_VectorFloat = 0x00D4,
NATIVE_Subtract_PreVector = 0x00D3,
NATIVE_Lerp = 0x00F7,
NATIVE_FClamp = 0x00F6,
NATIVE_FMax = 0x00F5,
NATIVE_FMin = 0x00F4,
NATIVE_FRand = 0x00C3,
NATIVE_Square = 0x00C2,
NATIVE_Sqrt = 0x00C1,
NATIVE_Loge = 0x00C0,
NATIVE_Exp = 0x00BF,
NATIVE_Atan = 0x00BE,
NATIVE_Tan = 0x00BD,
NATIVE_Cos = 0x00BC,
NATIVE_Sin = 0x00BB,
NATIVE_Abs = 0x00BA,
NATIVE_SubtractEqual_FloatFloat = 0x00B9,
NATIVE_AddEqual_FloatFloat = 0x00B8,
NATIVE_DivideEqual_FloatFloat = 0x00B7,
NATIVE_MultiplyEqual_FloatFloat = 0x00B6,
NATIVE_NotEqual_FloatFloat = 0x00B5,
NATIVE_ComplementEqual_FloatFloat = 0x00D2,
NATIVE_EqualEqual_FloatFloat = 0x00B4,
NATIVE_GreaterEqual_FloatFloat = 0x00B3,
NATIVE_LessEqual_FloatFloat = 0x00B2,
NATIVE_Greater_FloatFloat = 0x00B1,
NATIVE_Less_FloatFloat = 0x00B0,
NATIVE_Subtract_FloatFloat = 0x00AF,
NATIVE_Add_FloatFloat = 0x00AE,
NATIVE_Percent_FloatFloat = 0x00AD,
NATIVE_Divide_FloatFloat = 0x00AC,
NATIVE_Multiply_FloatFloat = 0x00AB,
NATIVE_MultiplyMultiply_FloatFloat = 0x00AA,
NATIVE_Subtract_PreFloat = 0x00A9,
NATIVE_Clamp = 0x00FB,
NATIVE_Max = 0x00FA,
NATIVE_Min = 0x00F9,
NATIVE_Rand = 0x00A7,
NATIVE_SubtractSubtract_Int = 0x00A6,
NATIVE_AddAdd_Int = 0x00A5,
NATIVE_SubtractSubtract_PreInt = 0x00A4,
NATIVE_AddAdd_PreInt = 0x00A3,
NATIVE_SubtractEqual_IntInt = 0x00A2,
NATIVE_AddEqual_IntInt = 0x00A1,
NATIVE_DivideEqual_IntFloat = 0x00A0,
NATIVE_MultiplyEqual_IntFloat = 0x009F,
NATIVE_Or_IntInt = 0x009E,
NATIVE_Xor_IntInt = 0x009D,
NATIVE_And_IntInt = 0x009C,
NATIVE_NotEqual_IntInt = 0x009B,
NATIVE_EqualEqual_IntInt = 0x009A,
NATIVE_GreaterEqual_IntInt = 0x0099,
NATIVE_LessEqual_IntInt = 0x0098,
NATIVE_Greater_IntInt = 0x0097,
NATIVE_Less_IntInt = 0x0096,
NATIVE_GreaterGreaterGreater_IntInt = 0x00C4,
NATIVE_GreaterGreater_IntInt = 0x0095,
NATIVE_LessLess_IntInt = 0x0094,
NATIVE_Subtract_IntInt = 0x0093,
NATIVE_Add_IntInt = 0x0092,
NATIVE_Divide_IntInt = 0x0091,
NATIVE_Multiply_IntInt = 0x0090,
NATIVE_Subtract_PreInt = 0x008F,
NATIVE_Complement_PreInt = 0x008D,
NATIVE_SubtractSubtract_Byte = 0x008C,
NATIVE_AddAdd_Byte = 0x008B,
NATIVE_SubtractSubtract_PreByte = 0x008A,
NATIVE_AddAdd_PreByte = 0x0089,
NATIVE_SubtractEqual_ByteByte = 0x0088,
NATIVE_AddEqual_ByteByte = 0x0087,
NATIVE_DivideEqual_ByteByte = 0x0086,
NATIVE_MultiplyEqual_ByteFloat = 0x00C6,
NATIVE_MultiplyEqual_ByteByte = 0x0085,
NATIVE_OrOr_BoolBool = 0x0084,
NATIVE_XorXor_BoolBool = 0x0083,
NATIVE_AndAnd_BoolBool = 0x0082,
NATIVE_NotEqual_BoolBool = 0x00F3,
NATIVE_EqualEqual_BoolBool = 0x00F2,
NATIVE_Not_PreBool = 0x0081,
NATIVE_CollidingActors = 0x0141,
NATIVE_VisibleCollidingActors = 0x0138,
NATIVE_VisibleActors = 0x0137,
NATIVE_TraceActors = 0x0135,
NATIVE_TouchingActors = 0x0133,
NATIVE_BasedActors = 0x0132,
NATIVE_ChildActors = 0x0131,
NATIVE_DynamicActors = 0x0139,
NATIVE_AllActors = 0x0130,
NATIVE_GetURLMap = 0x0223,
NATIVE_PlayerCanSeeMe = 0x0214,
NATIVE_MakeNoise = 0x0200,
NATIVE_SetTimer = 0x0118,
NATIVE_Destroy = 0x0117,
NATIVE_Spawn = 0x0116,
NATIVE_FastTrace = 0x0224,
NATIVE_Trace = 0x0115,
NATIVE_SetPhysics = 0x0F82,
NATIVE_SetOwner = 0x0110,
NATIVE_SetBase = 0x012A,
NATIVE_AutonomousPhysics = 0x0F83,
NATIVE_MoveSmooth = 0x0F81,
NATIVE_SetRotation = 0x012B,
NATIVE_SetLocation = 0x010B,
NATIVE_Move = 0x010A,
NATIVE_SetCollisionSize = 0x011B,
NATIVE_SetCollision = 0x0106,
NATIVE_FinishAnim = 0x0105,
NATIVE_Sleep = 0x0100,
NATIVE_WaitForLanding = 0x020F,
NATIVE_PickWallAdjust = 0x020E,
NATIVE_ActorReachable = 0x0208,
NATIVE_PointReachable = 0x0209,
NATIVE_FindRandomDest = 0x020D,
NATIVE_FindPathToward = 0x0205,
NATIVE_FindPathTo = 0x0206,
NATIVE_FinishRotation = 0x01FC,
NATIVE_MoveToward = 0x01F6,
NATIVE_MoveTo = 0x01F4,
NATIVE_PickTarget = 0x0213,
NATIVE_CanSeeByPoints = 0x0219,
NATIVE_CanSee = 0x0215,
NATIVE_LineOfSightTo = 0x0202,
NATIVE_FindStairRotation = 0x020C,
NATIVE_UpdateURL = 0x0222
};
also for unhood users, this will change in nativecallreader
private BytecodeToken ReadNativeCall(byte b)
{
int nativeIndex;
if ((b & 0xF0) == 0x70)
{
byte b2 = _reader.ReadByte();
nativeIndex = ((b - 0x70) << 8) + b2;
}
else
{
nativeIndex = b;
}
...
always backup your files!
mess with the best or die like the rest!
"I tried everything!" - "mkay, please list that..." ; please dont pm me for help, we have a help section
User avatar
WarrantyVoider
Emeritus
 
Posts: 2270
Joined: 22 Aug 2012, 11:33
Has thanked: 480 time
Have thanks: 626 time

Re: Current Research: Script byte code

Postby WarrantyVoider » 02 Sep 2012, 20:39

Thats how it looks when its working:(with debug infos) this is Object#535 in Engine.pcc called "PreBeginPlay":
Output:
Spoiler:
Childindex : 534
Unknown1 : -1
Unknown2 : 170
Script Size : 130
Flags ( Defined Event Public )
Native Index: 0
Script:
20 : If (!bGameRelevant && !bStatic && WorldInfo.NetMode != 3 && !WorldInfo.Game.CheckRelevance(this))
{
If(bNoDelete)
{
ShutDown()
}
else
{
Destroy()
}
}
9F : Return ();
A1 : \\End of Script

Debug print:

0 : Read token[0x7] at 0x20: "If (!bGameRelevant && !bStatic && WorldInfo.NetMode != 3 && !WorldInfo.Game.CheckRelevance(this))
{
If(bNoDelete)
{
ShutDown()
}
else
{
Destroy()
}
}" STOPTOKEN:False
1 : Read token[0x82] at 0x23: "!bGameRelevant && !bStatic && WorldInfo.NetMode != 3 && !WorldInfo.Game.CheckRelevance(this)" STOPTOKEN:False
2 : Read token[0x82] at 0x24: "!bGameRelevant && !bStatic && WorldInfo.NetMode != 3" STOPTOKEN:False
3 : Read token[0x82] at 0x25: "!bGameRelevant && !bStatic" STOPTOKEN:False
4 : Read token[0x81] at 0x26: "!bGameRelevant" STOPTOKEN:False
5 : Read token[0x2D] at 0x27: "bGameRelevant" STOPTOKEN:False
6 : Read token[0x1] at 0x28: "bGameRelevant" STOPTOKEN:False
7 : Read token[0x16] at 0x2D: "" STOPTOKEN:False
8 : Read token[0x18] at 0x2E: "!bStatic" STOPTOKEN:False
9 : Read token[0x81] at 0x31: "!bStatic" STOPTOKEN:False
10 : Read token[0x2D] at 0x32: "bStatic" STOPTOKEN:False
11 : Read token[0x1] at 0x33: "bStatic" STOPTOKEN:False
12 : Read token[0x16] at 0x38: "" STOPTOKEN:False
13 : Read token[0x16] at 0x39: "" STOPTOKEN:False
14 : Read token[0x18] at 0x3A: "WorldInfo.NetMode != 3" STOPTOKEN:False
15 : Read token[0x9B] at 0x3D: "WorldInfo.NetMode != 3" STOPTOKEN:False
16 : Read token[0x38] at 0x3E: "WorldInfo.NetMode" STOPTOKEN:False
17 : Read token[0x19] at 0x40: "WorldInfo.NetMode" STOPTOKEN:False
18 : Read token[0x62] at 0x41: "WorldInfo" STOPTOKEN:False
19 : Read token[0x61] at 0x4D: "NetMode" STOPTOKEN:False
20 : Read token[0x38] at 0x52: "3" STOPTOKEN:False
21 : Read token[0x24] at 0x54: "3" STOPTOKEN:False
22 : Read token[0x16] at 0x56: "" STOPTOKEN:False
23 : Read token[0x16] at 0x57: "" STOPTOKEN:False
24 : Read token[0x18] at 0x58: "!WorldInfo.Game.CheckRelevance(this)" STOPTOKEN:False
25 : Read token[0x81] at 0x5B: "!WorldInfo.Game.CheckRelevance(this)" STOPTOKEN:False
26 : Read token[0x19] at 0x5C: "WorldInfo.Game.CheckRelevance(this)" STOPTOKEN:False
27 : Read token[0x19] at 0x5D: "WorldInfo.Game" STOPTOKEN:False
28 : Read token[0x62] at 0x5E: "WorldInfo" STOPTOKEN:False
29 : Read token[0x62] at 0x6A: "Game" STOPTOKEN:False
30 : Read token[0x65] at 0x76: "CheckRelevance(this)" STOPTOKEN:False
31 : Read token[0x17] at 0x81: "this" STOPTOKEN:False
32 : Read token[0x16] at 0x82: "" STOPTOKEN:False
33 : Read token[0x16] at 0x83: "" STOPTOKEN:False
34 : Read token[0x16] at 0x84: "" STOPTOKEN:False
35 : Read token[0x64] at 0x85: "If(bNoDelete)
{
ShutDown()
}
else
{
Destroy()
}" STOPTOKEN:False
36 : Read token[0x65] at 0x8D: "ShutDown()" STOPTOKEN:False
37 : Read token[0x16] at 0x98: "" STOPTOKEN:False
38 : Read token[0x6] at 0x99: "Jump (0xFFFFA700)" STOPTOKEN:False
39 : Read token[0x71] at 0x9C: "Destroy()" STOPTOKEN:False
40 : Read token[0x16] at 0x9E: "" STOPTOKEN:False
41 : Read token[0x4] at 0x9F: "Return ();" STOPTOKEN:False
42 : Read token[0xB] at 0xA0: "" STOPTOKEN:False
43 : Read token[0x53] at 0xA1: "\\End of Script" STOPTOKEN:True

The Binary to that:
Spoiler:
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000 19 02 00 00 73 33 00 00 00 00 00 00 00 00 00 00 ....s3..........
00000010 17 02 00 00 00 00 00 00 AA 00 00 00 82 00 00 00 ........ª...‚...
00000020 07 A7 00 82 82 82 81 2D 01 3F 04 00 00 16 18 0D .§.‚‚‚.-.?......
00000030 00 81 2D 01 71 04 00 00 16 16 18 27 00 9B 38 3A ..-.q......'.›8:
00000040 19 62 82 04 00 00 09 00 77 22 00 00 00 61 77 22 .b‚.....w"...aw"
00000050 00 00 38 3A 24 03 16 16 18 3A 00 81 19 19 62 82 ..8:$....:....b‚
00000060 04 00 00 09 00 C0 22 00 00 00 62 C0 22 00 00 0D .....À"...bÀ"...
00000070 00 26 35 00 00 00 65 68 10 00 00 00 00 00 00 E4 .&5...eh.......ä
00000080 00 17 16 16 16 64 6F 04 00 00 01 A4 00 65 EB 44 .....do....¤.eëD
00000090 00 00 00 00 00 00 59 00 16 06 A7 00 71 17 16 04 ......Y...§.q...
000000A0 0B 53 00 00 02 08 02 00 .S......


And the original UT script for compare:
Spoiler:
//
// Called immediately before gameplay begins.
//
event PreBeginPlay()
{
// Handle autodestruction if desired.
if (!bGameRelevant && !bStatic && WorldInfo.NetMode != NM_Client && !WorldInfo.Game.CheckRelevance(self))
{
if (bNoDelete)
{
ShutDown();
}
else
{
Destroy();
}
}
}
always backup your files!
mess with the best or die like the rest!
"I tried everything!" - "mkay, please list that..." ; please dont pm me for help, we have a help section
User avatar
WarrantyVoider
Emeritus
 
Posts: 2270
Joined: 22 Aug 2012, 11:33
Has thanked: 480 time
Have thanks: 626 time

Re: Done Research: Script byte code

Postby FemShep » 16 Apr 2013, 19:21

Thanks for this WarrantyVoider. This is going to save me a lot of time from having to reverse engineer what each statement is by myself :)
Image
ME3Tweaks has modding guides, tools, forums for mods, a modding wiki, and ModMaker, an online mod creation tool.
ME3 Mod Manager, the civilized way of installing and managing ME3 mods.
ME3Tweaks Facebook Page
User avatar
FemShep
Modder
 
Posts: 1101
Joined: 18 Oct 2012, 20:48
Has thanked: 42 time
Have thanks: 76 time

Re: Done Research: Script byte code

Postby WarrantyVoider » 29 May 2013, 19:14

well im trying something new here. first off, I want to enter tokens as patterns, so no need for hardcoding, also this allowes me to *edit* (compile *hust*) stuff later (I hope so).... wish me luck^^

Image

incomplete opcodetable (try on core.pcc) here

now on SVN!

greetz WV
always backup your files!
mess with the best or die like the rest!
"I tried everything!" - "mkay, please list that..." ; please dont pm me for help, we have a help section
User avatar
WarrantyVoider
Emeritus
 
Posts: 2270
Joined: 22 Aug 2012, 11:33
Has thanked: 480 time
Have thanks: 626 time

Re: Done Research: Script byte code

Postby WarrantyVoider » 28 Sep 2014, 23:48

http://wiki.tesnexus.com/index.php/Hex_editing_UPK_files

this goes a bit into detail about the hex representation of unreal script tokens, probably useful if you wanna change only small things. remember that me3 has a custom format, but the unreal script decompiler helps on this

greetz WV
always backup your files!
mess with the best or die like the rest!
"I tried everything!" - "mkay, please list that..." ; please dont pm me for help, we have a help section
User avatar
WarrantyVoider
Emeritus
 
Posts: 2270
Joined: 22 Aug 2012, 11:33
Has thanked: 480 time
Have thanks: 626 time

Re: Done Research: Script byte code

Postby TankMaster » 30 Sep 2014, 04:24

Yeah, I stumbled onto that page last month as well. I knew a few things before that, but it certainly helped. I think I will toy with the PCC -> UPK converter and correct some issues so that they open properly in the UE Explorer. Right now the converted files open and everything shows correct in the tree view, just can't view the decompiled code due to it reaching end of stream or some other issues. The NTL generator in UE Explorer worked somewhat, as well, lol.
TankMaster
User
 
Posts: 173
Joined: 02 Nov 2012, 01:19
Location: Indiana
Has thanked: 6 time
Have thanks: 64 time

Re: Done Research: Script byte code

Postby wxadee » 19 Dec 2014, 09:50

This info and decoder on ME3 explorer came very helpful, thank you very much.
Also i want it in ME2 and ME1, is this rules valid for them?
wxadee
User
 
Posts: 6
Joined: 09 Dec 2014, 22:18
Has thanked: 0 time
Have thanks: 0 time

Next

Return to Technical Research

Who is online

Users browsing this forum: No registered users and 0 guests

cron
suspicion-preferred