ghidraxdbg 12.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ghidraxdbg/schema.xml ADDED
@@ -0,0 +1,317 @@
1
+ <context>
2
+ <schema name="X64DbgRoot" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
3
+ <interface name="EventScope" />
4
+ <attribute name="Sessions" schema="SessionContainer" required="yes" fixed="yes" />
5
+ <attribute name="Settings" schema="ANY" />
6
+ <attribute name="State" schema="State" />
7
+ <attribute-alias from="_state" to="State" />
8
+ <attribute name="Utility" schema="ANY" />
9
+ <attribute name="_display" schema="STRING" hidden="yes" />
10
+ <attribute name="_order" schema="INT" hidden="yes" />
11
+ <attribute schema="ANY"/>
12
+ </schema>
13
+ <schema name="SessionContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
14
+ <element schema="Session" />
15
+ <attribute name="_order" schema="INT" hidden="yes" />
16
+ <attribute schema="ANY"/>
17
+ </schema>
18
+ <schema name="Session" elementResync="NEVER" attributeResync="NEVER">
19
+ <interface name="Activatable" />
20
+ <interface name="FocusScope" />
21
+ <interface name="Aggregate" />
22
+ <interface name="ExecutionStateful" />
23
+ <element schema="VOID" />
24
+ <attribute name="Processes" schema="ProcessContainer" required="yes" fixed="yes" />
25
+ <attribute name="Available" schema="AvailableContainer" required="yes" fixed="yes" />
26
+ <attribute name="_event_thread" schema="OBJECT" hidden="yes" />
27
+ <attribute name="_focus" schema="Selectable" required="yes" hidden="yes" />
28
+ <attribute name="_display" schema="STRING" hidden="yes" />
29
+ <attribute name="_order" schema="INT" hidden="yes" />
30
+ <attribute schema="ANY"/>
31
+ </schema>
32
+ <schema name="State" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
33
+ <element schema="VOID" />
34
+ <attribute name="_order" schema="INT" hidden="yes" />
35
+ <attribute schema="ANY"/>
36
+ </schema>
37
+ <schema name="Selectable" elementResync="NEVER" attributeResync="NEVER">
38
+ <element schema="OBJECT" />
39
+ <attribute name="_order" schema="INT" hidden="yes" />
40
+ <attribute schema="VOID" />
41
+ </schema>
42
+ <schema name="DebugBreakpointContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
43
+ <interface name="Aggregate" />
44
+ <element schema="VOID" />
45
+ <attribute name="Software Breakpoints" schema="BreakpointContainer" required="yes" />
46
+ <attribute name="Hardware Breakpoints" schema="BreakpointContainer" required="yes" />
47
+ <attribute name="Memory Breakpoints" schema="BreakpointContainer" required="yes" />
48
+ <attribute name="Events" schema="EventContainer" required="yes" />
49
+ <attribute name="Exceptions" schema="ExceptionContainer" required="yes" />
50
+ <attribute name="_order" schema="INT" hidden="yes" />
51
+ <attribute schema="VOID" />
52
+ </schema>
53
+ <schema name="BreakpointContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
54
+ <element schema="BreakpointSpec" />
55
+ <attribute name="_order" schema="INT" hidden="yes" />
56
+ <attribute schema="ANY" />
57
+ </schema>
58
+ <schema name="EventContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
59
+ <element schema="Event" />
60
+ <attribute name="_order" schema="INT" hidden="yes" />
61
+ <attribute schema="ANY" />
62
+ </schema>
63
+ <schema name="Event" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
64
+ <element schema="ANY" />
65
+ <attribute name="Cont" schema="ContinueOption" />
66
+ <attribute name="Exec" schema="ExecutionOption" />
67
+ <attribute name="_order" schema="INT" hidden="yes" />
68
+ <attribute schema="ANY" />
69
+ </schema>
70
+ <schema name="ExceptionContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
71
+ <element schema="Exception" />
72
+ <attribute name="_order" schema="INT" hidden="yes" />
73
+ <attribute schema="ANY" />
74
+ </schema>
75
+ <schema name="Exception" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
76
+ <element schema="ANY" />
77
+ <attribute name="Cont" schema="ContinueOption" />
78
+ <attribute name="Exec" schema="ExecutionOption" />
79
+ <attribute name="_order" schema="INT" hidden="yes" />
80
+ <attribute schema="ANY" />
81
+ </schema>
82
+ <schema name="ContinueOption" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
83
+ <interface name="Togglable" />
84
+ <element schema="VOID" />
85
+ <attribute name="_order" schema="INT" hidden="yes" />
86
+ <attribute schema="ANY" />
87
+ </schema>
88
+ <schema name="ExecutionOption" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
89
+ <interface name="Togglable" />
90
+ <element schema="VOID" />
91
+ <attribute name="_order" schema="INT" hidden="yes" />
92
+ <attribute schema="ANY" />
93
+ </schema>
94
+ <schema name="AvailableContainer" canonical="yes" elementResync="ALWAYS" attributeResync="NEVER">
95
+ <element schema="Attachable" />
96
+ <attribute name="_order" schema="INT" hidden="yes" />
97
+ <attribute schema="VOID" />
98
+ </schema>
99
+ <schema name="ProcessContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
100
+ <element schema="Process" />
101
+ <attribute name="_order" schema="INT" hidden="yes" />
102
+ <attribute schema="ANY" />
103
+ </schema>
104
+ <schema name="BreakpointSpec" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
105
+ <interface name="BreakpointSpec" />
106
+ <interface name="BreakpointLocation" />
107
+ <interface name="Togglable" />
108
+ <element schema="VOID" />
109
+ <attribute name="Name" schema="STRING" hidden="yes" />
110
+ <attribute-alias from="_name" to="Name" />
111
+ <attribute name="Kinds" schema="STRING" hidden="yes" />
112
+ <attribute-alias from="_kinds" to="Kinds" />
113
+ <attribute name="_order" schema="INT" hidden="yes" />
114
+ <attribute name="Range" schema="RANGE" />
115
+ <attribute-alias from="_range" to="Range" />
116
+ <attribute name="Enabled" schema="BOOL" required="yes" />
117
+ <attribute-alias from="_enabled" to="Enabled" />
118
+ <attribute name="Commands" schema="STRING" />
119
+ <attribute name="Condition" schema="STRING" />
120
+ <attribute name="Hit Count" schema="INT" />
121
+ <attribute name="Ignore Count" schema="INT" />
122
+ <attribute name="Pending" schema="BOOL" />
123
+ <attribute name="Silent" schema="BOOL" />
124
+ <attribute name="Temporary" schema="BOOL" />
125
+ <attribute schema="VOID" />
126
+ </schema>
127
+ <schema name="Attachable" elementResync="NEVER" attributeResync="NEVER">
128
+ <element schema="VOID" />
129
+ <attribute name="PID" schema="LONG" />
130
+ <attribute-alias from="_pid" to="PID" />
131
+ <attribute name="_display" schema="STRING" hidden="yes" />
132
+ <attribute name="_order" schema="INT" hidden="yes" />
133
+ <attribute schema="VOID" />
134
+ </schema>
135
+ <schema name="Process" elementResync="NEVER" attributeResync="NEVER">
136
+ <interface name="Activatable" />
137
+ <interface name="Process" />
138
+ <interface name="Aggregate" />
139
+ <interface name="ExecutionStateful" />
140
+ <element schema="VOID" />
141
+ <attribute name="Threads" schema="ThreadContainer" required="yes" fixed="yes" />
142
+ <attribute name="Debug" schema="DebugBreakpointContainer" required="yes" fixed="yes" />
143
+ <attribute name="Exit Code" schema="LONG" />
144
+ <attribute-alias from="_exit_code" to="Exit Code" />
145
+ <attribute name="Environment" schema="Environment" required="yes" fixed="yes" />
146
+ <attribute name="Memory" schema="Memory" required="yes" fixed="yes" />
147
+ <attribute name="Modules" schema="ModuleContainer" required="yes" fixed="yes" />
148
+ <attribute name="Handle" schema="STRING" fixed="yes" />
149
+ <attribute name="Id" schema="STRING" fixed="yes" />
150
+ <attribute name="PID" schema="LONG" hidden="yes" />
151
+ <attribute-alias from="_pid" to="PID" />
152
+ <attribute name="State" schema="EXECUTION_STATE" required="yes" hidden="yes" />
153
+ <attribute-alias from="_state" to="State" />
154
+ <attribute name="_display" schema="STRING" hidden="yes" />
155
+ <attribute name="_short_display" schema="STRING" hidden="yes" />
156
+ <attribute name="_order" schema="INT" hidden="yes" />
157
+ <attribute schema="ANY" />
158
+ </schema>
159
+ <schema name="Environment" elementResync="NEVER" attributeResync="NEVER">
160
+ <interface name="Environment" />
161
+ <element schema="VOID" />
162
+ <attribute name="OS" schema="STRING" />
163
+ <attribute name="Arch" schema="STRING" />
164
+ <attribute name="Endian" schema="STRING" />
165
+ <attribute name="Debugger" schema="STRING" />
166
+ <attribute-alias from="_os" to="OS" />
167
+ <attribute-alias from="_arch" to="Arch" />
168
+ <attribute-alias from="_endian" to="Endian" />
169
+ <attribute-alias from="_debugger" to="Debugger" />
170
+ <attribute name="_order" schema="INT" hidden="yes" />
171
+ <attribute schema="VOID" />
172
+ </schema>
173
+ <schema name="ModuleContainer" canonical="yes" elementResync="ONCE" attributeResync="NEVER">
174
+ <element schema="Module" />
175
+ <attribute name="_order" schema="INT" hidden="yes" />
176
+ <attribute schema="ANY" />
177
+ </schema>
178
+ <schema name="Memory" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
179
+ <interface name="Memory" />
180
+ <element schema="MemoryRegion" />
181
+ <attribute name="_order" schema="INT" hidden="yes" />
182
+ <attribute schema="VOID" />
183
+ </schema>
184
+ <schema name="ThreadContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
185
+ <element schema="Thread" />
186
+ <attribute name="_order" schema="INT" hidden="yes" />
187
+ <attribute schema="ANY" />
188
+ </schema>
189
+ <schema name="Method" elementResync="NEVER" attributeResync="NEVER">
190
+ <interface name="Method" />
191
+ <element schema="VOID" />
192
+ <attribute name="_display" schema="STRING" required="yes" fixed="yes" hidden="yes" />
193
+ <attribute name="_return_type" schema="TYPE" required="yes" fixed="yes" hidden="yes" />
194
+ <attribute name="_parameters" schema="MAP_PARAMETERS" required="yes" fixed="yes" hidden="yes" />
195
+ <attribute schema="VOID" fixed="yes" hidden="yes" />
196
+ </schema>
197
+ <schema name="Thread" elementResync="NEVER" attributeResync="NEVER">
198
+ <interface name="Activatable" />
199
+ <interface name="Thread" />
200
+ <interface name="ExecutionStateful" />
201
+ <interface name="Aggregate" />
202
+ <element schema="VOID" />
203
+ <attribute name="Stack" schema="StackFramesContainer" required="yes" fixed="yes" />
204
+ <attribute name="Registers" schema="RegisterValueContainer" required="yes" fixed="yes" />
205
+ <attribute name="Environment" schema="ANY" fixed="yes" />
206
+ <attribute name="Id" schema="STRING" fixed="yes" />
207
+ <attribute name="TID" schema="LONG" />
208
+ <attribute-alias from="_tid" to="TID" />
209
+ <attribute name="State" schema="EXECUTION_STATE" required="yes" hidden="yes" />
210
+ <attribute-alias from="_state" to="State" />
211
+ <attribute name="_display" schema="STRING" hidden="yes" />
212
+ <attribute name="_short_display" schema="STRING" hidden="yes" />
213
+ <attribute name="_order" schema="INT" hidden="yes" />
214
+ <attribute name="Advance" schema="Method" required="yes" fixed="yes" hidden="yes" />
215
+ <attribute schema="ANY" />
216
+ </schema>
217
+ <schema name="Module" elementResync="NEVER" attributeResync="NEVER">
218
+ <interface name="Module" />
219
+ <element schema="VOID" />
220
+ <attribute name="Sections" schema="SectionContainer" required="yes" fixed="yes" />
221
+ <attribute name="Symbols" schema="SymbolContainer" required="yes" fixed="yes" />
222
+ <attribute name="Range" schema="RANGE" />
223
+ <attribute name="Name" schema="STRING" />
224
+ <attribute-alias from="_module_name" to="Name" />
225
+ <attribute-alias from="_range" to="Range" />
226
+ <attribute name="_display" schema="STRING" hidden="yes" />
227
+ <attribute name="_order" schema="INT" hidden="yes" />
228
+ <attribute name="ToDisplayString" schema="BOOL" hidden="yes" />
229
+ <attribute schema="VOID" />
230
+ </schema>
231
+ <schema name="MemoryRegion" elementResync="NEVER" attributeResync="NEVER">
232
+ <interface name="MemoryRegion" />
233
+ <element schema="VOID" />
234
+ <attribute name="Base" schema="LONG" required="yes" fixed="yes" />
235
+ <attribute name="Object File" schema="STRING" fixed="yes" />
236
+ <attribute name="_readable" schema="BOOL" required="yes" hidden="yes" />
237
+ <attribute name="_writable" schema="BOOL" required="yes" hidden="yes" />
238
+ <attribute name="_executable" schema="BOOL" required="yes" hidden="yes" />
239
+ <attribute name="Range" schema="RANGE" required="yes" hidden="yes" />
240
+ <attribute-alias from="_range" to="Range" />
241
+ <attribute name="_display" schema="STRING" hidden="yes" />
242
+ <attribute name="_order" schema="INT" hidden="yes" />
243
+ <attribute schema="VOID" />
244
+ </schema>
245
+ <schema name="SectionContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
246
+ <element schema="Section" />
247
+ <attribute name="_order" schema="INT" hidden="yes" />
248
+ <attribute schema="VOID" />
249
+ </schema>
250
+ <schema name="StackFramesContainer" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
251
+ <interface name="Aggregate" />
252
+ <element schema="VOID" />
253
+ <attribute name="Frames" schema="Stack" required="yes" />
254
+ <attribute name="_order" schema="INT" hidden="yes" />
255
+ <attribute schema="VOID" />
256
+ </schema>
257
+ <schema name="Stack" canonical="yes" elementResync="NEVER" attributeResync="NEVER">
258
+ <interface name="Stack" />
259
+ <element schema="StackFrame" />
260
+ <attribute name="_display" schema="STRING" hidden="yes" />
261
+ <attribute name="_order" schema="INT" hidden="yes" />
262
+ <attribute schema="ANY" />
263
+ </schema>
264
+ <schema name="SymbolContainer" canonical="yes" elementResync="ONCE" attributeResync="NEVER">
265
+ <element schema="Symbol" />
266
+ <attribute name="_order" schema="INT" hidden="yes" />
267
+ <attribute schema="VOID" />
268
+ </schema>
269
+ <schema name="Symbol" elementResync="NEVER" attributeResync="NEVER">
270
+ <element schema="VOID" />
271
+ <attribute name="_display" schema="STRING" hidden="yes" />
272
+ <attribute name="_order" schema="INT" hidden="yes" />
273
+ <attribute schema="VOID" />
274
+ </schema>
275
+ <schema name="StackFrame" elementResync="NEVER" attributeResync="NEVER">
276
+ <interface name="Activatable" />
277
+ <interface name="StackFrame" />
278
+ <interface name="Aggregate" />
279
+ <element schema="VOID" />
280
+ <attribute name="Function" schema="STRING" hidden="yes" />
281
+ <attribute-alias from="_function" to="Function" />
282
+ <attribute name="Instruction Offset" schema="ADDRESS" required="yes" />
283
+ <attribute-alias from="_pc" to="Instruction Offset" />
284
+ <attribute name="Stack Offset" schema="ADDRESS" />
285
+ <attribute name="Return Offset" schema="ADDRESS" />
286
+ <attribute name="Frame Offset" schema="ADDRESS" />
287
+ <attribute name="_display" schema="STRING" hidden="yes" />
288
+ <attribute name="_order" schema="INT" hidden="yes" />
289
+ <attribute schema="ANY" />
290
+ </schema>
291
+ <schema name="Section" elementResync="NEVER" attributeResync="NEVER">
292
+ <interface name="Section" />
293
+ <element schema="VOID" />
294
+ <attribute name="Range" schema="RANGE" />
295
+ <attribute-alias from="_range" to="Range" />
296
+ <attribute name="Offset" schema="STRING" fixed="yes" />
297
+ <attribute name="_display" schema="STRING" hidden="yes" />
298
+ <attribute name="_order" schema="INT" hidden="yes" />
299
+ <attribute schema="VOID" />
300
+ </schema>
301
+ <schema name="RegisterValueContainer" attributeResync="ONCE">
302
+ <interface name="RegisterContainer" />
303
+ <attribute name="General Purpose Registers" schema="RegisterBank" />
304
+ <attribute name="Floating Point Registers" schema="RegisterBank" />
305
+ <attribute name="Advanced Vector Extensions" schema="RegisterBank" />
306
+ <attribute name="Memory Protection Extensions" schema="RegisterBank" />
307
+ <attribute name="FloatingPoint" schema="RegisterBank" />
308
+ <attribute name="SIMD" schema="RegisterBank" />
309
+ <attribute name="User" schema="RegisterBank" />
310
+ <attribute name="_order" schema="INT" hidden="yes" />
311
+ <attribute schema="VOID" />
312
+ </schema>
313
+ <schema name="RegisterBank" canonical="yes" elementResync="ONCE" attributeResync="NEVER">
314
+ <attribute name="_order" schema="INT" hidden="yes" />
315
+ <attribute schema="VOID" />
316
+ </schema>
317
+ </context>
ghidraxdbg/util.py ADDED
@@ -0,0 +1,297 @@
1
+ ## ###
2
+ # IP: GHIDRA
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ ##
16
+
17
+ from ghidratrace.client import Schedule
18
+ from collections import namedtuple
19
+ from ctypes import POINTER, byref, c_ulong, c_ulonglong, create_string_buffer
20
+ import functools
21
+ import io
22
+ import os
23
+ import queue
24
+ import psutil
25
+ import re
26
+ import sys
27
+ import threading
28
+ import traceback
29
+ from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, TypeVar, Union, cast
30
+
31
+ from x64dbg_automate import X64DbgClient
32
+ from x64dbg_automate.events import CreateThreadEventData
33
+ from x64dbg_automate.models import Context32, Context64, Instruction, MemPage, RegDump
34
+
35
+ DbgVersion = namedtuple('DbgVersion', ['full', 'name', 'dotted', 'arch'])
36
+ conv_map: Dict[str, str] = {}
37
+ threads: Dict[int, CreateThreadEventData] = {}
38
+
39
+ class DebuggeeRunningException(BaseException):
40
+ pass
41
+
42
+ class GhidraDbg(object):
43
+
44
+ def __init__(self) -> None:
45
+ self._new_base()
46
+ client = self._client
47
+ client.start_session()
48
+
49
+ def _new_base(self) -> None:
50
+ executable = os.getenv('OPT_X64DBG_EXE')
51
+ if executable is None:
52
+ return
53
+ self._client = X64DbgClient(executable)
54
+
55
+ @property
56
+ def client(self) -> X64DbgClient:
57
+ return self._client
58
+
59
+ def cmd(self, cmdline: str, quiet: bool = True) -> str:
60
+ # Here, we let it print without capture if quiet is False
61
+ if quiet:
62
+ buffer = io.StringIO()
63
+ #self.client.callbacks.stdout = buffer
64
+ self.client.cmd_sync(cmdline)
65
+ return "completed"
66
+ else:
67
+ self.client.cmd_sync(cmdline)
68
+ return ""
69
+
70
+ def wait(self) -> None:
71
+ self._client.wait_until_stopped()
72
+
73
+ def interrupt(self) -> None:
74
+ self._client.pause()
75
+
76
+ def eval(self, input: str) -> Optional[list[int]]:
77
+ try:
78
+ return self._client.eval_sync(input)
79
+ except:
80
+ return None
81
+
82
+ def get_actual_processor_type(self) -> int:
83
+ return self.client.debugee_bitness()
84
+
85
+ @property
86
+ def pid(self) -> Optional[int]:
87
+ try:
88
+ return self.client.get_debugger_pid()
89
+ except:
90
+ # There is no process
91
+ return None
92
+
93
+
94
+ dbg = GhidraDbg()
95
+
96
+
97
+ def compute_dbg_ver() -> DbgVersion:
98
+ ver = dbg.client.get_debugger_version()
99
+ executable = os.getenv('OPT_X64DBG_EXE')
100
+ bitness = dbg.client.debugee_bitness()
101
+ return DbgVersion('Unknown', 'Unknown', ver, 'x{}'.format(bitness))
102
+
103
+
104
+ DBG_VERSION = compute_dbg_ver()
105
+ last_process = None
106
+
107
+
108
+ def get_target():
109
+ return 0 #dbg.get_current_system_id()
110
+
111
+
112
+ def disassemble1(addr: int) -> Instruction | None:
113
+ return dbg.client.disassemble_at(addr)
114
+
115
+
116
+ def get_inst(addr: int) -> Instruction | None:
117
+ return disassemble1(addr)
118
+
119
+
120
+ def get_inst_sz(addr: int) -> int:
121
+ inst = disassemble1(addr)
122
+ if inst is None:
123
+ return 0
124
+ return int(inst.instr_size)
125
+
126
+
127
+ def selected_process() -> int:
128
+ global last_process
129
+ try:
130
+ pid = dbg.client.debugee_pid()
131
+ if pid is not None:
132
+ last_process = pid
133
+ return pid
134
+ except:
135
+ return None
136
+
137
+
138
+ def selected_process_space() -> int:
139
+ try:
140
+ return selected_process()
141
+ except:
142
+ # NB: we're intentionally returning 0 instead of None
143
+ return 0
144
+
145
+
146
+ def selected_thread() -> Optional[int]:
147
+ try:
148
+ ev = dbg.eval('tid()')
149
+ if ev is None:
150
+ return None
151
+ return ev[0]
152
+ except:
153
+ return None
154
+
155
+
156
+ def selected_frame() -> Optional[int]:
157
+ try:
158
+ line = dbg.cmd('.frame').strip()
159
+ if not line:
160
+ return None
161
+ num_str = line.split(sep=None, maxsplit=1)[0]
162
+ return int(num_str, 16)
163
+ except OSError:
164
+ return None
165
+ except ValueError:
166
+ return None
167
+
168
+
169
+ def select_thread(id: int) -> bool:
170
+ return dbg.client.switch_thread(id)
171
+
172
+
173
+ def select_frame(id: int) -> str:
174
+ return dbg.cmd('.frame /c {}'.format(id))
175
+
176
+
177
+ def reset_frames() -> str:
178
+ return dbg.cmd('.cxr')
179
+
180
+
181
+ def parse_and_eval(expr: Union[str, int],
182
+ type: Optional[int] = None) -> Union[int, float, bytes]:
183
+ if isinstance(expr, int):
184
+ return expr
185
+ return int(expr, 16)
186
+
187
+
188
+ def get_pc() -> int:
189
+ ctxt = dbg.client.get_regs().context
190
+ if hasattr(ctxt, 'rip'):
191
+ return ctxt.rip
192
+ else:
193
+ return ctxt.eip
194
+
195
+
196
+ def get_sp() -> int:
197
+ ctxt = dbg.client.get_regs().context
198
+ if hasattr(ctxt, 'rsp'):
199
+ return ctxt.rsp
200
+ else:
201
+ return ctxt.esp
202
+
203
+
204
+ def process_list0(running: bool = False) -> Union[
205
+ Iterable[Tuple[int, str, int]], Iterable[Tuple[int]]]:
206
+ """Get the list of all processes."""
207
+ nproc = selected_process()
208
+ sysids = []
209
+ names = []
210
+ if nproc is None:
211
+ return zip(sysids)
212
+
213
+ try:
214
+ proc = psutil.Process(nproc)
215
+ sysids.append(nproc)
216
+ names.append(proc.name())
217
+ return zip(sysids, names)
218
+ except Exception:
219
+ return zip(sysids)
220
+
221
+
222
+ def process_list(running: bool = False) -> Union[
223
+ Iterable[Tuple[int, str, int]], Iterable[Tuple[int]]]:
224
+ """Get the list of all processes."""
225
+ sysids = []
226
+ names = []
227
+
228
+ try:
229
+ for pid in psutil.pids():
230
+ sysids.append(pid)
231
+ proc = psutil.Process(pid)
232
+ names.append(proc.name())
233
+ return zip(sysids, names)
234
+ except Exception:
235
+ return zip(sysids)
236
+
237
+
238
+ def thread_list(running: bool = False) -> Union[
239
+ Iterable[Tuple[int, int, str]], Iterable[Tuple[int]]]:
240
+ """Get the list of all threads."""
241
+ nproc = selected_process()
242
+ proc = psutil.Process(nproc)
243
+ sysids = []
244
+
245
+ try:
246
+ for t in proc.threads():
247
+ sysids.append(t.id)
248
+ return zip(sysids)
249
+ except Exception:
250
+ return zip(sysids)
251
+
252
+
253
+ def full_mem() -> List[MemPage]:
254
+ return []
255
+
256
+
257
+ def split_path(pathString: str) -> List[str]:
258
+ list = []
259
+ segs = pathString.split(".")
260
+ for s in segs:
261
+ if s.endswith("]"):
262
+ if "[" not in s:
263
+ print(f"Missing terminator: {s}")
264
+ index = s.index("[")
265
+ list.append(s[:index])
266
+ list.append(s[index:])
267
+ else:
268
+ list.append(s)
269
+ return list
270
+
271
+
272
+ def get_kind(obj) -> Optional[int]:
273
+ """Get the kind."""
274
+ if obj is None:
275
+ return None
276
+ kind = obj.GetKind()
277
+ if kind is None:
278
+ return None
279
+ return obj.GetKind().value
280
+
281
+
282
+ def terminate_session() -> None:
283
+ dbg.client.terminate_session()
284
+
285
+
286
+ def get_convenience_variable(id: str) -> Any:
287
+ if id not in conv_map:
288
+ return "auto"
289
+ val = conv_map[id]
290
+ if val is None:
291
+ return "auto"
292
+ return val
293
+
294
+
295
+ def set_convenience_variable(id: str, value: Any) -> None:
296
+ conv_map[id] = value
297
+
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: ghidraxdbg
3
+ Version: 12.0
4
+ Summary: Ghidra's Plugin for x64dbg
5
+ Author: Ghidra Development Team
6
+ Project-URL: Homepage, https://github.com/NationalSecurityAgency/ghidra
7
+ Project-URL: Bug Tracker, https://github.com/NationalSecurityAgency/ghidra/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: ghidratrace==12.0
15
+ Requires-Dist: x64dbg_automate>=0.5.0
16
+ Dynamic: license-file
17
+
18
+ # Ghidra Trace RMI
19
+
20
+ Package for connecting x64dbg to Ghidra via Trace RMI.
@@ -0,0 +1,13 @@
1
+ ghidraxdbg/__init__.py,sha256=mHeO63cetdttEAMQUt_f94NWEy0DRA1gCJUjfXo4L-I,616
2
+ ghidraxdbg/arch.py,sha256=w8kkOdSnyoNm0hOOFxLHDDQRyK41K5NKbT3DiaYpdB0,7014
3
+ ghidraxdbg/commands.py,sha256=sJcq3r3OVKNJP3mqVFzkMOlBUkj0WWMvi4x_MnBi_Lg,45537
4
+ ghidraxdbg/hooks.py,sha256=dOq1nnKxorDCWjScwX-Cr-rw-Xt78kSNzVrgOlkbNUA,13355
5
+ ghidraxdbg/methods.py,sha256=EVr8ie6hAU5sN1qUeUTw-2_n_o9_cJ1OT6bGPj3q2Rc,22427
6
+ ghidraxdbg/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ ghidraxdbg/schema.xml,sha256=UVk8eXQaUolCPZ2PvjY5ct6KplqJliwSExNiCSqa13U,15237
8
+ ghidraxdbg/util.py,sha256=ZOksyCt-kSCe6fFqvJbfT29TEJ_M-zAr-YfksrFlKnQ,7223
9
+ ghidraxdbg-12.0.dist-info/licenses/LICENSE,sha256=SlHPf3JPUb7bX6T5WDonYvHbjQXkOld-JIfHqrL9zhg,525
10
+ ghidraxdbg-12.0.dist-info/METADATA,sha256=BIT0zBQ4MSYBi4uMLICGYqvW8sIMKoMR-pYhyI-2O3c,688
11
+ ghidraxdbg-12.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ ghidraxdbg-12.0.dist-info/top_level.txt,sha256=AFpNw4R7HkgUMXaTyQYNSPI-xzo6bZIwDa8nd1NWSFk,11
13
+ ghidraxdbg-12.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
@@ -0,0 +1 @@
1
+ ghidraxdbg