1- from .icicle import *
1+ from typing import List , Dict , Tuple
2+ from enum import Enum
3+
4+ class MemoryProtection (Enum ):
5+ NoAccess = ...
6+ ReadOnly = ...
7+ ReadWrite = ...
8+ ExecuteOnly = ...
9+ ExecuteRead = ...
10+ ExecuteReadWrite = ...
11+
12+ class MemoryExceptionCode (Enum ):
13+ Unallocated = ...
14+ Unmapped = ...
15+ UnmappedRegisters = ...
16+ Uninitialized = ...
17+ ReadViolation = ...
18+ WriteViolation = ...
19+ ExecViolation = ...
20+ ReadWatch = ...
21+ WriteWatch = ...
22+ Unaligned = ...
23+ OutOfMemory = ...
24+ SelfModifyingCode = ...
25+ AddressOverflow = ...
26+ Unknown = ...
27+
28+ class RunStatus (Enum ):
29+ Running = ...
30+ InstructionLimit = ...
31+ Breakpoint = ...
32+ Interrupted = ...
33+ Halt = ...
34+ Killed = ...
35+ Deadlock = ...
36+ OutOfMemory = ...
37+ Unimplemented = ...
38+ UnhandledException = ...
39+
40+ class ExceptionCode (Enum ):
41+ NoException = ...
42+ InstructionLimit = ...
43+ Halt = ...
44+ Sleep = ...
45+ Syscall = ...
46+ CpuStateChanged = ...
47+ DivisionException = ...
48+ ReadUnmapped = ...
49+ ReadPerm = ...
50+ ReadUnaligned = ...
51+ ReadWatch = ...
52+ ReadUninitialized = ...
53+ WriteUnmapped = ...
54+ WritePerm = ...
55+ WriteWatch = ...
56+ WriteUnaligned = ...
57+ ExecViolation = ...
58+ SelfModifyingCode = ...
59+ OutOfMemory = ...
60+ AddressOverflow = ...
61+ InvalidInstruction = ...
62+ UnknownInterrupt = ...
63+ UnknownCpuID = ...
64+ InvalidOpSize = ...
65+ InvalidFloatSize = ...
66+ CodeNotTranslated = ...
67+ ShadowStackOverflow = ...
68+ ShadowStackInvalid = ...
69+ InvalidTarget = ...
70+ UnimplementedOp = ...
71+ ExternalAddr = ...
72+ Environment = ...
73+ JitError = ...
74+ InternalError = ...
75+ UnmappedRegister = ...
76+ UnknownError = ...
77+
78+ class Icicle :
79+ def __init__ (self , architecture : str , * ,
80+ jit = True ,
81+ jit_mem = True ,
82+ shadow_stack = True ,
83+ recompilation = True ,
84+ track_uninitialized = False ,
85+ optimize_instructions = True ,
86+ optimize_block = True ,
87+ tracing = False ,
88+ ) -> None : ...
89+
90+ @property
91+ def exception_code (self ) -> ExceptionCode : ...
92+
93+ @property
94+ def exception_value (self ) -> int : ...
95+
96+ icount : int
97+
98+ icount_limit : int
99+
100+ # TODO: API to get memory information?
101+
102+ def mem_map (self , address : int , size : int , protection : MemoryProtection ): ...
103+
104+ def mem_unmap (self , address : int , size : int ): ...
105+
106+ def mem_protect (self , address : int , size : int , protection : MemoryProtection ): ...
107+
108+ def mem_read (self , address : int , size : int ) -> bytes : ...
109+
110+ def mem_write (self , address : int , data : bytes ) -> None : ...
111+
112+ def reg_list (self ) -> Dict [str , Tuple [int , int ]]: ...
113+
114+ def reg_offset (self , name : str ) -> int : ...
115+
116+ def reg_size (self , name : str ) -> int : ...
117+
118+ def reg_read (self , name : str ) -> int : ...
119+
120+ def reg_write (self , name : str , value : int ) -> None : ...
121+
122+ def reset (self ): ...
123+
124+ def run (self ) -> RunStatus : ...
125+
126+ def run_until (self , address : int ) -> RunStatus : ...
127+
128+ def step (self , count : int ) -> RunStatus : ...
129+
130+ def add_breakpoint (self , address : int ) -> bool : ...
131+
132+ def remove_breakpoint (self , address : int ) -> bool : ...
133+
134+ def architectures () -> List [str ]: ...
2135
3136class MemoryException (Exception ):
4137 def __init__ (self , message : str , code : MemoryExceptionCode ):
@@ -19,3 +152,6 @@ def __ghidra_init():
19152 raise FileNotFoundError ("Ghidra processor definitions not found" )
20153
21154__ghidra_init ()
155+
156+ # NOTE: This overrides the stubs at runtime with the actual implementation
157+ from .icicle import *
0 commit comments