-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherrorCodeInfo.py
More file actions
95 lines (88 loc) · 2.97 KB
/
errorCodeInfo.py
File metadata and controls
95 lines (88 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import sys
from enum import Enum
class ExceptionType(Enum):
PREFETCH = 0
DATA_ABORT = 1
UNDEFINED = 2
VFP = 3
@staticmethod
def getExceptionString(state: int):
stateStr = "unknown"
match state:
case ExceptionType.PREFETCH.value:
stateStr = "Prefetch abort"
case ExceptionType.DATA_ABORT.value:
stateStr = "Data abort"
case ExceptionType.UNDEFINED.value:
stateStr = "Undefined instruction"
case ExceptionType.VFP.value:
stateStr = "VFP (floating point) exception"
return stateStr
class CoreState(Enum):
INIT = 0
LOADING_RUNTIME = 1
LOADING_SCRIPTS = 2
LOADING_MODS = 3
EVENT = 4
EXECUTING_HOOK = 5
CREATING_HOOK = 6
@staticmethod
def getCoreStateString(state: int):
stateStr = "unknown"
match state:
case CoreState.INIT.value:
stateStr = "Core startup"
case CoreState.LOADING_RUNTIME.value:
stateStr = "Loading Lua runtime"
case CoreState.LOADING_SCRIPTS.value:
stateStr = "Loading scripts"
case CoreState.LOADING_MODS.value:
stateStr = "Loading mods"
case CoreState.EVENT.value:
stateStr = "Event triggered"
case CoreState.EXECUTING_HOOK.value:
stateStr = "Executing a hook in a game function"
case CoreState.CREATING_HOOK.value:
stateStr = "Setting up hooks"
return stateStr
def getGameStateString(state: int):
stateStr = "unknown"
match state:
case 0:
stateStr = "Loading"
case 1:
stateStr = "Menu"
case 2:
stateStr = "World"
return stateStr
def main(errorCode: int):
#u32 errorCode = (core_state << 28 | plg_state << 24 | game_state << 20 | possibleOOM << 19 | luaEnvBusy << 18)
excepType = (errorCode >> 30) & 0b11
core_state = (errorCode >> 27) & 0b111
game_state = (errorCode >> 25) & 0b11
possibleError = (errorCode >> 23) & 0b11
pluginFault = (errorCode >> 22) & 0b1
print("Exception:", ExceptionType.getExceptionString(excepType))
print("Last Core state:", CoreState.getCoreStateString(core_state))
print("Last Game state:", getGameStateString(game_state))
if possibleError == 1:
print("Error in plugin patch process")
if possibleError == 2:
print("The error was caused by the scripting runtime")
if possibleError == 3:
print("Lua out of memory")
pc = ((errorCode & 0b1111111111111111111111) << 2)
if (pluginFault == 1):
pc += 0x07000100
print(f"PC: {pc:08X}")
else:
pc += 0x00100000
print(f"PC: {pc:08X}")
if __name__ == "__main__":
code = 0
if len(sys.argv) == 1:
hexStr = input("Enter the error code: ")
code = int(hexStr, 16)
else:
code = int(sys.argv[1], 16)
main(code)