Lua Files: Difference between revisions
Red-EyeX32 (talk | contribs) No edit summary |
Red-EyeX32 (talk | contribs) No edit summary |
||
| Line 15: | Line 15: | ||
The binary data is then passed to the Virtual Machine (VM) to be ran. Now for the header of the binary data. | The binary data is then passed to the Virtual Machine (VM) to be ran. Now for the header of the binary data. | ||
<source lang="cpp"> | <source lang="cpp"> | ||
#define LuaMagic = 0x1B4C7561 | |||
struct LuaHeader | struct LuaHeader | ||
{ | { | ||
Revision as of 04:09, 26 December 2014
The lua files were introduced in Call of Duty: Black Ops II and it has appeared on every Call of Duty since. It is only available as its own asset type on Ghosts and Advanced Warfare. On Black Ops 2, however, it is stored as a rawfile. This asset is used for the game menus.
struct LuaFile
{
const char *name;
int len;
char strippingType;
const char *buffer;
};The binary data is then passed to the Virtual Machine (VM) to be ran. Now for the header of the binary data.
#define LuaMagic = 0x1B4C7561
struct LuaHeader
{
char magic[8];
char version;
char swapEndian;
char sizeOfInt;
char sizeOfSize;
char sizeOfLuaN;
char sizeOfNumber;
char numberIntegralCode;
char bytecodeSharingMode;
};Opcodes
| Opcode | Number | Mode | A | B | C |
|---|---|---|---|---|---|
| HKS_OPCODE_GETFIELD | 0x0 | iABC | Used | Register | Constant |
| HKS_OPCODE_TEST | 0x1 | iABC | Used | Not Used | Used |
| HKS_OPCODE_CALL_I | 0x2 | iABC | Used | Used | Used |
| HKS_OPCODE_CALL_C | 0x3 | iABC | Used | Used | Used |
| HKS_OPCODE_EQ | 0x4 | iABC | Not Used | Register/Constant | Register |
| HKS_OPCODE_EQ_BK | 0x5 | iABC | Not Used | Register/Constant | Register |
| HKS_OPCODE_GETGLOBAL | 0x6 | iABx | Used | Constant | Used |
| HKS_OPCODE_MOVE | 0x7 | iABC | Used | Register | Not Used |
| HKS_OPCODE_SELF | 0x8 | iABC | Used | Register | Register |
| HKS_OPCODE_RETURN | 0x9 | iABC | Used | Used | Not Used |
| HKS_OPCODE_GETTABLE_S | 0xa | iABC | Used | Register | Register |
| HKS_OPCODE_GETTABLE_N | 0xb | iABC | Used | Register | Register |
| HKS_OPCODE_GETTABLE | 0xc | iABC | Used | Register | Register |
| HKS_OPCODE_LOADBOOL | 0xd | iABC | Used | Used | Used |
| HKS_OPCODE_TFORLOOP | 0xe | iABC | Used | Not Used | Used |
| HKS_OPCODE_SETFIELD | 0xf | iABC | Used | Constant | Register |
| HKS_OPCODE_SETTABLE_S | 0x10 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_SETTABLE_S_BK | 0x11 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_SETTABLE_N | 0x12 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_SETTABLE_N_BK | 0x13 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_SETTABLE | 0x14 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_SETTABLE_BK | 0x15 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_TAILCALL_I | 0x16 | iABC | Used | Used | Used |
| HKS_OPCODE_TAILCALL_C | 0x17 | iABC | Used | Used | Used |
| HKS_OPCODE_TAILCALL_M | 0x18 | iABC | Used | Used | Used |
| HKS_OPCODE_LOADK | 0x19 | iABx | Used | Constant | Not Used |
| HKS_OPCODE_LOADNIL | 0x1a | iABC | Used | Register | Not Used |
| HKS_OPCODE_SETGLOBAL | 0x1b | iABx | Used | Constant | Not Used |
| HKS_OPCODE_JMP | 0x1c | iAsBx | Not Used | Jump Offset | Not Used |
| HKS_OPCODE_CALL_M | 0x1d | iABC | Used | Used | Used |
| HKS_OPCODE_CALL | 0x1e | iABC | Used | Used | Used |
| HKS_OPCODE_INTRINSIC_INDEX | 0x1f | iABC | Used | Used | Used |
| HKS_OPCODE_INTRINSIC_NEWINDEX | 0x20 | iABC | Used | Used | Used |
| HKS_OPCODE_INTRINSIC_SELF | 0x21 | iABC | Used | Used | Used |
| HKS_OPCODE_INTRINSIC_INDEX_LITERAL | 0x22 | iABC | Used | Used | Used |
| HKS_OPCODE_INTRINSIC_NEWINDEX_LITERAL | 0x23 | iABC | Used | Used | Used |
| HKS_OPCODE_INTRINSIC_SELF_LITERAL | 0x24 | iABC | Used | Used | Used |
| HKS_OPCODE_TAILCALL | 0x25 | iABC | Used | Used | Used |
| HKS_OPCODE_GETUPVAL | 0x26 | iABC | Used | Used | Not Used |
| HKS_OPCODE_SETUPVAL | 0x27 | iABC | Used | Used | Not Used |
| HKS_OPCODE_ADD | 0x28 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_ADD_BK | 0x29 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_SUB | 0x2a | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_SUB_BK | 0x2b | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_MUL | 0x2c | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_MUL_BK | 0x2d | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_DIV | 0x2e | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_DIV_BK | 0x2f | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_MOD | 0x30 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_MOD_BK | 0x31 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_POW | 0x32 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_POW_BK | 0x33 | iABC | Used | Register/Constant | Register |
| HKS_OPCODE_NEWTABLE | 0x34 | iABC | Used | Used | Used |
| HKS_OPCODE_UNM | 0x35 | iABC | Used | Register | Not Used |
| HKS_OPCODE_NOT | 0x36 | iABC | Used | Register | Not Used |
| HKS_OPCODE_LEN | 0x37 | iABC | Used | Register | Not Used |
| HKS_OPCODE_LT | 0x38 | iABC | Not Used | Register/Constant | Register |
| HKS_OPCODE_LT_BK | 0x39 | iABC | Not Used | Register/Constant | Register |
| HKS_OPCODE_LE | 0x3a | iABC | Not Used | Register/Constant | Register |
| HKS_OPCODE_LE_BK | 0x3b | iABC | Not Used | Register/Constant | Register |
| HKS_OPCODE_CONCAT | 0x3c | iABC | Used | Used | Used |
| HKS_OPCODE_TESTSET | 0x3d | iABC | Used | Register | Used |
| HKS_OPCODE_FORPREP | 0x3e | iAsBx | Used | Jump Offset | Not Used |
| HKS_OPCODE_FORLOOP | 0x3f | iAsBx | Used | Jump Offset | Not Used |
| HKS_OPCODE_SETLIST | 0x40 | iABC | Used | Used | Jump Offset |
| HKS_OPCODE_CLOSE | 0x41 | iABC | Used | Not Used | Not Used |
| HKS_OPCODE_CLOSURE | 0x42 | iABx | Used | Used | Not Used |
| HKS_OPCODE_VARARG | 0x43 | iABC | Used | Used | Not Used |
| HKS_OPCODE_TAILCALL_I_R1 | 0x44 | iABC | Not Used | Used | Used |
| HKS_OPCODE_CALL_I_R1 | 0x45 | iABC | Not Used | Used | Used |
| HKS_OPCODE_SETUPVAL_R1 | 0x46 | iABC | Used | Used | Not Used |
| HKS_OPCODE_TEST_R1 | 0x47 | iABC | Used | Not Used | Used |
| HKS_OPCODE_NOT_R1 | 0x48 | iABC | Used | Register | Not Used |
| HKS_OPCODE_GETFIELD_R1 | 0x49 | iABC | Used | Register | Constant |
| HKS_OPCODE_SETFIELD_R1 | 0x4a | iABC | Used | Constant | Register |
| HKS_OPCODE_NEWSTRUCT | 0x4b | iABC | Used | Used | Used |
| HKS_OPCODE_DATA | 0x4c | iABx | Not Used | Jump Offset | Not Used |
| HKS_OPCODE_SETSLOTN | 0x4d | iABC | Used | Not Used | Used |
| HKS_OPCODE_SETSLOTI | 0x4e | iABC | Used | Used | Register |
| HKS_OPCODE_SETSLOT | 0x4f | iABC | Used | Used | Register |
| HKS_OPCODE_SETSLOTS | 0x50 | iABC | Used | Used | Register |
| HKS_OPCODE_SETSLOTMT | 0x51 | iABC | Used | Used | Register |
| HKS_OPCODE_CHECKTYPE | 0x52 | iABx | Used | Used | Not Used |
| HKS_OPCODE_CHECKTYPES | 0x53 | iABx | Used | Used | Not Used |
| HKS_OPCODE_GETSLOT | 0x54 | iABC | Used | Register | Used |
| HKS_OPCODE_GETSLOTMT | 0x55 | iABC | Used | Register | Used |
| HKS_OPCODE_SELFSLOT | 0x56 | iABC | Used | Register | Used |
| HKS_OPCODE_SELFSLOTMT | 0x57 | iABC | Used | Register | Used |
| HKS_OPCODE_GETFIELD_MM | 0x58 | iABC | Used | Register | Constant |
| HKS_OPCODE_CHECKTYPE_D | 0x59 | iABx | Used | Used | Not Used |
| HKS_OPCODE_GETSLOT_D | 0x5a | iABC | Used | Register | Used |
| HKS_OPCODE_GETGLOBAL_MEM | 0x5b | iABx | Used | Constant | Used |