-
Notifications
You must be signed in to change notification settings - Fork 149
/
PINCE.py
executable file
·5742 lines (5207 loc) · 273 KB
/
PINCE.py
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copyright (C) 2016-2017 Korcan Karaokçu <korcankaraokcu@gmail.com>
Copyright (C) 2016-2017 Çağrı Ulaş <cagriulas@gmail.com>
Copyright (C) 2016-2017 Jakob Kreuze <jakob@memeware.net>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import gi
# This fixes GTK version mismatch issues and crashes on gnome
# See #153 and #159 for more information
# This line can be deleted when GTK 4.0 properly runs on all supported systems
gi.require_version("Gtk", "3.0")
from PyQt6.QtGui import (
QIcon,
QMovie,
QPixmap,
QCursor,
QKeySequence,
QColor,
QContextMenuEvent,
QBrush,
QTextCursor,
QShortcut,
QColorConstants,
QStandardItemModel,
QStandardItem,
QCloseEvent,
QKeyEvent,
QMouseEvent,
QWheelEvent,
)
from PyQt6.QtWidgets import (
QApplication,
QMainWindow,
QTableWidgetItem,
QMessageBox,
QDialog,
QWidget,
QTabWidget,
QMenu,
QFileDialog,
QAbstractItemView,
QTreeWidgetItem,
QTreeWidgetItemIterator,
QCompleter,
QDialogButtonBox,
QCheckBox,
QHBoxLayout,
)
from PyQt6.QtCore import (
Qt,
QThread,
pyqtSignal,
QSize,
QByteArray,
QSettings,
QEvent,
QKeyCombination,
QTranslator,
QItemSelectionModel,
QTimer,
QStringListModel,
QLocale,
QSignalBlocker,
QItemSelection,
)
from time import sleep, time
import os, sys, traceback, signal, re, copy, io, collections, ast, json, select, importlib
from tr.tr import TranslationConstants as tr
from tr.tr import language_list, get_locale
from libpince import utils, debugcore, typedefs
from libpince.debugcore import scanmem, ptrscan
from GUI.States import states
from GUI.Settings import settings, themes
from GUI.Utils import guiutils, guitypedefs, utilwidgets
from GUI.MainWindow import Ui_MainWindow as MainWindow
from GUI.SelectProcess import Ui_MainWindow as ProcessWindow
from GUI.AddAddressManuallyDialog import Ui_Dialog as ManualAddressDialog
from GUI.EditTypeDialog import Ui_Dialog as EditTypeDialog
from GUI.TrackSelectorDialog import Ui_Dialog as TrackSelectorDialog
from GUI.LoadingDialog import Ui_Dialog as LoadingDialog
from GUI.TextEditDialog import Ui_Dialog as TextEditDialog
from GUI.SettingsDialog import Ui_Dialog as SettingsDialog
from GUI.HandleSignalsDialog import Ui_Dialog as HandleSignalsDialog
from GUI.ConsoleWidget import Ui_Form as ConsoleWidget
from GUI.AboutWidget import Ui_TabWidget as AboutWidget
# If you are going to change the name "Ui_MainWindow_MemoryView", review GUI/Labels/RegisterLabel.py as well
from GUI.MemoryViewerWindow import Ui_MainWindow_MemoryView as MemoryViewWindow
from GUI.Widgets.Bookmark.Bookmark import BookmarkWidget
from GUI.FloatRegisterWidget import Ui_TabWidget as FloatRegisterWidget
from GUI.StackTraceInfoWidget import Ui_Form as StackTraceInfoWidget
from GUI.BreakpointInfoWidget import Ui_TabWidget as BreakpointInfoWidget
from GUI.TrackWatchpointWidget import Ui_Form as TrackWatchpointWidget
from GUI.TrackBreakpointWidget import Ui_Form as TrackBreakpointWidget
from GUI.TraceInstructionsPromptDialog import Ui_Dialog as TraceInstructionsPromptDialog
from GUI.TraceInstructionsWaitWidget import Ui_Form as TraceInstructionsWaitWidget
from GUI.TraceInstructionsWindow import Ui_MainWindow as TraceInstructionsWindow
from GUI.FunctionsInfoWidget import Ui_Form as FunctionsInfoWidget
from GUI.HexEditDialog import Ui_Dialog as HexEditDialog
from GUI.EditInstructionDialog import Ui_Dialog as EditInstructionDialog
from GUI.LogFileWidget import Ui_Form as LogFileWidget
from GUI.SearchOpcodeWidget import Ui_Form as SearchOpcodeWidget
from GUI.MemoryRegionsWidget import Ui_Form as MemoryRegionsWidget
from GUI.DissectCodeDialog import Ui_Dialog as DissectCodeDialog
from GUI.ReferencedStringsWidget import Ui_Form as ReferencedStringsWidget
from GUI.ReferencedCallsWidget import Ui_Form as ReferencedCallsWidget
from GUI.ExamineReferrersWidget import Ui_Form as ExamineReferrersWidget
from GUI.Widgets.RestoreInstructions.RestoreInstructions import RestoreInstructionsWidget
from GUI.Widgets.PointerScanSearch.PointerScanSearch import PointerScanSearchDialog
from GUI.Widgets.PointerScan.PointerScan import PointerScanWindow
from GUI.Widgets.ManageScanRegions.ManageScanRegions import ManageScanRegionsDialog
from GUI.AbstractTableModels.HexModel import QHexModel
from GUI.AbstractTableModels.AsciiModel import QAsciiModel
from GUI.Validators.HexValidator import QHexValidator
from GUI.ManualAddressDialogUtils.PointerChainOffset import PointerChainOffset
from keyboard import KeyboardEvent, _pressed_events
from keyboard._nixkeyboard import to_name
if __name__ == "__main__":
app = QApplication([])
app.setOrganizationName("PINCE")
app.setOrganizationDomain("github.com/korcankaraokcu/PINCE")
app.setApplicationName("PINCE")
QSettings.setPath(
QSettings.Format.NativeFormat, QSettings.Scope.UserScope, utils.get_user_path(typedefs.USER_PATHS.CONFIG)
)
settings_instance = QSettings()
translator = QTranslator()
try:
locale = settings_instance.value("General/locale", type=str)
except SystemError:
# We're reading the settings for the first time here
# If there's an error due to python objects, clear settings
settings_instance.clear()
locale = None
if not locale:
locale = get_locale()
locale_file = utils.get_script_directory() + f"/i18n/qm/{locale}.qm"
translator.load(locale_file)
app.installTranslator(translator)
tr.translate()
# Reload states after QApplication instance to ensure that variables are correctly initiated
# Reloading states after translations also ensures that hotkeys are correctly translated
importlib.reload(states)
importlib.reload(themes) # Needed for correct translations, might not be needed after refactorization
# represents the index of columns in breakpoint table
BREAK_NUM_COL = 0
BREAK_TYPE_COL = 1
BREAK_DISP_COL = 2
BREAK_ENABLED_COL = 3
BREAK_ADDR_COL = 4
BREAK_SIZE_COL = 5
BREAK_ON_HIT_COL = 6
BREAK_HIT_COUNT_COL = 7
BREAK_COND_COL = 8
# row colors for disassemble qtablewidget
PC_COLOR = QColorConstants.Blue
BOOKMARK_COLOR = QColorConstants.Cyan
BREAKPOINT_COLOR = QColorConstants.Red
REF_COLOR = QColorConstants.LightGray
# represents the index of columns in address table
FROZEN_COL = 0 # Frozen
DESC_COL = 1 # Description
ADDR_COL = 2 # Address
TYPE_COL = 3 # Type
VALUE_COL = 4 # Value
# represents the index of columns in search results table
SEARCH_TABLE_ADDRESS_COL = 0
SEARCH_TABLE_VALUE_COL = 1
SEARCH_TABLE_PREVIOUS_COL = 2
# represents the index of columns in disassemble table
DISAS_ADDR_COL = 0
DISAS_BYTES_COL = 1
DISAS_OPCODES_COL = 2
DISAS_COMMENT_COL = 3
# represents the index of columns in floating point table
FLOAT_REGISTERS_NAME_COL = 0
FLOAT_REGISTERS_VALUE_COL = 1
# represents the index of columns in stacktrace table
STACKTRACE_RETURN_ADDRESS_COL = 0
STACKTRACE_FRAME_ADDRESS_COL = 1
# represents the index of columns in stack table
STACK_POINTER_ADDRESS_COL = 0
STACK_VALUE_COL = 1
STACK_POINTS_TO_COL = 2
# represents row and column counts of Hex table
HEX_VIEW_COL_COUNT = 16
HEX_VIEW_ROW_COUNT = 42 # J-JUST A COINCIDENCE, I SWEAR!
# represents the index of columns in track watchpoint table(what accesses this address thingy)
TRACK_WATCHPOINT_COUNT_COL = 0
TRACK_WATCHPOINT_ADDR_COL = 1
# represents the index of columns in track breakpoint table(which addresses this instruction accesses thingy)
TRACK_BREAKPOINT_COUNT_COL = 0
TRACK_BREAKPOINT_ADDR_COL = 1
TRACK_BREAKPOINT_VALUE_COL = 2
TRACK_BREAKPOINT_SOURCE_COL = 3
# represents the index of columns in function info table
FUNCTIONS_INFO_ADDR_COL = 0
FUNCTIONS_INFO_SYMBOL_COL = 1
# represents the index of columns in libpince reference resources table
LIBPINCE_REFERENCE_ITEM_COL = 0
LIBPINCE_REFERENCE_VALUE_COL = 1
# represents the index of columns in search opcode table
SEARCH_OPCODE_ADDR_COL = 0
SEARCH_OPCODE_OPCODES_COL = 1
# represents the index of columns in memory regions table
MEMORY_REGIONS_ADDR_COL = 0
MEMORY_REGIONS_PERM_COL = 1
MEMORY_REGIONS_OFFSET_COL = 2
MEMORY_REGIONS_PATH_COL = 3
# represents the index of columns in dissect code table
DISSECT_CODE_ADDR_COL = 0
DISSECT_CODE_PATH_COL = 1
# represents the index of columns in referenced strings table
REF_STR_ADDR_COL = 0
REF_STR_COUNT_COL = 1
REF_STR_VAL_COL = 2
# represents the index of columns in referenced calls table
REF_CALL_ADDR_COL = 0
REF_CALL_COUNT_COL = 1
def except_hook(exception_type, value, tb):
focused_widget = app.focusWidget()
if focused_widget and exception_type == typedefs.GDBInitializeException:
QMessageBox.information(focused_widget, tr.ERROR, tr.GDB_INIT)
traceback.print_exception(exception_type, value, tb)
# From version 5.5 and onwards, PyQT calls qFatal() when an exception has been encountered
# So, we must override sys.excepthook to avoid calling of qFatal()
sys.excepthook = except_hook
quit_prompt_active = False
def signal_handler(signal, frame):
global quit_prompt_active
with QSignalBlocker(app):
if debugcore.lock_send_command.locked():
print("\nCancelling the last GDB command")
debugcore.cancel_last_command()
else:
if quit_prompt_active:
print() # Prints a newline so the terminal looks nicer when we quit
debugcore.detach()
quit()
quit_prompt_active = True
print("\nNo GDB command to cancel, quit PINCE? (y/n)", end="", flush=True)
while True:
# Using select() instead of input() because it causes the bug below
# QBackingStore::endPaint() called with active painter
rlist, _, _ = select.select([sys.stdin], [], [], 0.1)
if rlist:
user_input = sys.stdin.readline().strip().lower()
break
if user_input.startswith("y"):
debugcore.detach()
quit()
else:
print("Quit aborted")
quit_prompt_active = False
signal.signal(signal.SIGINT, signal_handler)
class MainForm(QMainWindow, MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.deleted_regions: list[int] = []
hotkey_to_func = {
states.hotkeys.pause_hotkey: self.pause_hotkey_pressed,
states.hotkeys.break_hotkey: self.break_hotkey_pressed,
states.hotkeys.continue_hotkey: self.continue_hotkey_pressed,
states.hotkeys.toggle_attach_hotkey: self.toggle_attach_hotkey_pressed,
states.hotkeys.exact_scan_hotkey: lambda: self.nextscan_hotkey_pressed(typedefs.SCAN_TYPE.EXACT),
states.hotkeys.increased_scan_hotkey: lambda: self.nextscan_hotkey_pressed(typedefs.SCAN_TYPE.INCREASED),
states.hotkeys.decreased_scan_hotkey: lambda: self.nextscan_hotkey_pressed(typedefs.SCAN_TYPE.DECREASED),
states.hotkeys.changed_scan_hotkey: lambda: self.nextscan_hotkey_pressed(typedefs.SCAN_TYPE.CHANGED),
states.hotkeys.unchanged_scan_hotkey: lambda: self.nextscan_hotkey_pressed(typedefs.SCAN_TYPE.UNCHANGED),
}
for hotkey, func in hotkey_to_func.items():
hotkey.change_func(func)
self.treeWidget_AddressTable.setColumnWidth(FROZEN_COL, 50)
self.treeWidget_AddressTable.setColumnWidth(DESC_COL, 150)
self.treeWidget_AddressTable.setColumnWidth(ADDR_COL, 150)
self.treeWidget_AddressTable.setColumnWidth(TYPE_COL, 150)
self.tableWidget_valuesearchtable.setColumnWidth(SEARCH_TABLE_ADDRESS_COL, 120)
self.tableWidget_valuesearchtable.setColumnWidth(SEARCH_TABLE_VALUE_COL, 80)
self.tableWidget_valuesearchtable.horizontalHeader().setSortIndicatorClearable(True)
self.memory_view_window = MemoryViewWindowForm(self)
self.await_exit_thread = guitypedefs.AwaitProcessExit()
self.auto_attach_timer = QTimer(timeout=self.auto_attach_loop)
settings.init_settings()
self.settings_changed()
if os.environ.get("APPDIR"):
gdb_path = utils.get_default_gdb_path()
else:
gdb_path = states.gdb_path
if debugcore.init_gdb(gdb_path):
settings.apply_after_init()
else:
utilwidgets.InputDialog(self, tr.GDB_INIT_ERROR, cancel_button=False).exec()
self.await_exit_thread.process_exited.connect(self.on_inferior_exit)
self.await_exit_thread.start()
states.status_thread.process_stopped.connect(self.on_status_stopped)
states.status_thread.process_running.connect(self.on_status_running)
states.setting_signals.changed.connect(self.settings_changed)
self.address_table_timer = QTimer(timeout=self.address_table_loop, singleShot=True)
self.address_table_timer.start()
self.search_table_timer = QTimer(timeout=self.search_table_loop, singleShot=True)
self.search_table_timer.start()
self.freeze_timer = QTimer(timeout=self.freeze_loop, singleShot=True)
self.freeze_timer.start()
self.shortcut_open_file = QShortcut(QKeySequence("Ctrl+O"), self)
self.shortcut_open_file.activated.connect(self.pushButton_Open_clicked)
guiutils.append_shortcut_to_tooltip(self.pushButton_Open, self.shortcut_open_file)
self.shortcut_save_file = QShortcut(QKeySequence("Ctrl+S"), self)
self.shortcut_save_file.activated.connect(self.pushButton_Save_clicked)
guiutils.append_shortcut_to_tooltip(self.pushButton_Save, self.shortcut_save_file)
# Saving the original function because super() doesn't work when we override functions like this
self.treeWidget_AddressTable.mousePressEvent_original = self.treeWidget_AddressTable.mousePressEvent
self.treeWidget_AddressTable.mousePressEvent = self.treeWidget_AddressTable_mouse_press_event
self.treeWidget_AddressTable.mouseReleaseEvent_original = self.treeWidget_AddressTable.mouseReleaseEvent
self.treeWidget_AddressTable.mouseReleaseEvent = self.treeWidget_AddressTable_mouse_release_event
self.treeWidget_AddressTable.keyPressEvent_original = self.treeWidget_AddressTable.keyPressEvent
self.treeWidget_AddressTable.keyPressEvent = self.treeWidget_AddressTable_key_press_event
self.treeWidget_AddressTable.contextMenuEvent = self.treeWidget_AddressTable_context_menu_event
self.pushButton_AttachProcess.clicked.connect(self.pushButton_AttachProcess_clicked)
self.pushButton_Open.clicked.connect(self.pushButton_Open_clicked)
self.pushButton_Save.clicked.connect(self.pushButton_Save_clicked)
self.pushButton_NewFirstScan.clicked.connect(self.pushButton_NewFirstScan_clicked)
self.pushButton_UndoScan.clicked.connect(self.pushButton_UndoScan_clicked)
self.pushButton_NextScan.clicked.connect(self.pushButton_NextScan_clicked)
self.pushButton_ScanRegions.clicked.connect(self.pushButton_ScanRegions_clicked)
self.scan_mode = typedefs.SCAN_MODE.NEW
self.pushButton_NewFirstScan_clicked()
self.comboBox_ScanScope_init()
self.comboBox_ValueType_init()
guiutils.fill_endianness_combobox(self.comboBox_Endianness)
self.checkBox_Hex.stateChanged.connect(self.checkBox_Hex_stateChanged)
self.comboBox_ValueType.currentIndexChanged.connect(self.comboBox_ValueType_current_index_changed)
self.lineEdit_Scan.setValidator(guiutils.validator_map.get("int"))
self.lineEdit_Scan2.setValidator(guiutils.validator_map.get("int"))
self.lineEdit_Scan.keyPressEvent_original = self.lineEdit_Scan.keyPressEvent
self.lineEdit_Scan2.keyPressEvent_original = self.lineEdit_Scan2.keyPressEvent
self.lineEdit_Scan.keyPressEvent = self.lineEdit_Scan_on_key_press_event
self.lineEdit_Scan2.keyPressEvent = self.lineEdit_Scan2_on_key_press_event
self.comboBox_ScanType.currentIndexChanged.connect(self.comboBox_ScanType_current_index_changed)
self.comboBox_ScanType_current_index_changed()
self.pushButton_Settings.clicked.connect(self.pushButton_Settings_clicked)
self.pushButton_Console.clicked.connect(self.pushButton_Console_clicked)
self.pushButton_Wiki.clicked.connect(self.pushButton_Wiki_clicked)
self.pushButton_About.clicked.connect(self.pushButton_About_clicked)
self.pushButton_AddAddressManually.clicked.connect(self.pushButton_AddAddressManually_clicked)
self.pushButton_MemoryView.clicked.connect(self.pushButton_MemoryView_clicked)
self.pushButton_RefreshAdressTable.clicked.connect(self.pushButton_RefreshAdressTable_clicked)
self.pushButton_CopyToAddressTable.clicked.connect(self.copy_to_address_table)
self.pushButton_CleanAddressTable.clicked.connect(self.clear_address_table)
self.tableWidget_valuesearchtable.cellDoubleClicked.connect(
self.tableWidget_valuesearchtable_cell_double_clicked
)
self.tableWidget_valuesearchtable.keyPressEvent_original = self.tableWidget_valuesearchtable.keyPressEvent
self.tableWidget_valuesearchtable.keyPressEvent = self.tableWidget_valuesearchtable_key_press_event
self.tableWidget_valuesearchtable.contextMenuEvent = self.tableWidget_valuesearchtable_context_menu_event
self.treeWidget_AddressTable.itemDoubleClicked.connect(self.treeWidget_AddressTable_item_double_clicked)
self.treeWidget_AddressTable.expanded.connect(self.resize_address_table)
self.treeWidget_AddressTable.collapsed.connect(self.resize_address_table)
self.treeWidget_AddressTable.header().setSortIndicatorClearable(True)
self.treeWidget_AddressTable.header().setSortIndicator(-1, Qt.SortOrder.AscendingOrder) # Clear sort indicator
icons_directory = guiutils.get_icons_directory()
self.pushButton_AttachProcess.setIcon(QIcon(QPixmap(icons_directory + "/monitor.png")))
self.pushButton_Open.setIcon(QIcon(QPixmap(icons_directory + "/folder.png")))
self.pushButton_Save.setIcon(QIcon(QPixmap(icons_directory + "/disk.png")))
self.pushButton_Settings.setIcon(QIcon(QPixmap(icons_directory + "/wrench.png")))
self.pushButton_CopyToAddressTable.setIcon(QIcon(QPixmap(icons_directory + "/arrow_down.png")))
self.pushButton_CleanAddressTable.setIcon(QIcon(QPixmap(icons_directory + "/bin_closed.png")))
self.pushButton_RefreshAdressTable.setIcon(QIcon(QPixmap(icons_directory + "/table_refresh.png")))
self.pushButton_Console.setIcon(QIcon(QPixmap(icons_directory + "/application_xp_terminal.png")))
self.pushButton_Wiki.setIcon(QIcon(QPixmap(icons_directory + "/book_open.png")))
self.pushButton_About.setIcon(QIcon(QPixmap(icons_directory + "/information.png")))
self.pushButton_NextScan.setEnabled(False)
self.pushButton_UndoScan.setEnabled(False)
self.flashAttachButton = True
self.flashAttachButtonTimer = QTimer()
self.flashAttachButtonTimer.timeout.connect(self.flash_attach_button)
self.flashAttachButton_gradiantState = 0
self.flashAttachButtonTimer.start(100)
guiutils.center(self)
def settings_changed(self):
if states.auto_attach:
self.auto_attach_timer.start(100)
else:
self.auto_attach_timer.stop()
# Check if any process should be attached to automatically
# Patterns at former positions have higher priority if regex is off
def auto_attach_loop(self):
if debugcore.currentpid != -1:
return
if states.auto_attach_regex:
try:
compiled_re = re.compile(states.auto_attach)
except:
print(f"Auto-attach failed: {states.auto_attach} isn't a valid regex")
return
for pid, _, name in utils.get_process_list():
if compiled_re.search(name):
self.attach_to_pid(int(pid))
return
else:
for target in states.auto_attach.split(";"):
for pid, _, name in utils.get_process_list():
if name.find(target) != -1:
self.attach_to_pid(int(pid))
return
# Keyboard package has an issue with exceptions, any trigger function that throws an exception stops the event loop
# Writing a custom event loop instead of ignoring exceptions could work as well but honestly, this looks cleaner
# Keyboard package does not play well with Qt, do not use anything Qt related with hotkeys
# Instead of using Qt functions, try to use their signals to prevent crashes
@utils.ignore_exceptions
def pause_hotkey_pressed(self):
if not debugcore.active_trace:
debugcore.interrupt_inferior(typedefs.STOP_REASON.PAUSE)
@utils.ignore_exceptions
def break_hotkey_pressed(self):
if not debugcore.active_trace:
debugcore.interrupt_inferior()
@utils.ignore_exceptions
def continue_hotkey_pressed(self):
if not (
debugcore.currentpid == -1
or debugcore.inferior_status == typedefs.INFERIOR_STATUS.RUNNING
or debugcore.active_trace
):
debugcore.continue_inferior()
@utils.ignore_exceptions
def toggle_attach_hotkey_pressed(self):
result = debugcore.toggle_attach()
if not result:
print("Unable to toggle attach")
elif result == typedefs.TOGGLE_ATTACH.DETACHED:
self.on_status_detached()
else:
# Attaching back doesn't update the status if the process is already stopped before detachment
with debugcore.status_changed_condition:
debugcore.status_changed_condition.notify_all()
@utils.ignore_exceptions
def nextscan_hotkey_pressed(self, index):
if self.scan_mode == typedefs.SCAN_MODE.NEW:
return
self.comboBox_ScanType.setCurrentIndex(index)
self.pushButton_NextScan.clicked.emit()
def treeWidget_AddressTable_context_menu_event(self, event):
current_row = guiutils.get_current_item(self.treeWidget_AddressTable)
current_address = current_row.text(ADDR_COL) if current_row else None
header = self.treeWidget_AddressTable.headerItem()
menu = QMenu()
delete_record = menu.addAction(f"{tr.DELETE}[Del]")
edit_menu = menu.addMenu(tr.EDIT)
edit_desc = edit_menu.addAction(f"{header.text(DESC_COL)}[Ctrl+Enter]")
edit_address = edit_menu.addAction(f"{header.text(ADDR_COL)}[Ctrl+Alt+Enter]")
edit_type = edit_menu.addAction(f"{header.text(TYPE_COL)}[Alt+Enter]")
edit_value = edit_menu.addAction(f"{header.text(VALUE_COL)}[Enter]")
show_hex = menu.addAction(tr.SHOW_HEX)
show_dec = menu.addAction(tr.SHOW_DEC)
show_unsigned = menu.addAction(tr.SHOW_UNSIGNED)
show_signed = menu.addAction(tr.SHOW_SIGNED)
toggle_record = menu.addAction(f"{tr.TOGGLE}[Space]")
toggle_children = menu.addAction(f"{tr.TOGGLE_CHILDREN}[Ctrl+Space]")
freeze_menu = menu.addMenu(tr.FREEZE)
freeze_default = freeze_menu.addAction(tr.DEFAULT)
freeze_inc = freeze_menu.addAction(tr.INCREMENTAL)
freeze_dec = freeze_menu.addAction(tr.DECREMENTAL)
menu.addSeparator()
browse_region = menu.addAction(f"{tr.BROWSE_MEMORY_REGION}[Ctrl+B]")
disassemble = menu.addAction(f"{tr.DISASSEMBLE_ADDRESS}[Ctrl+D]")
menu.addSeparator()
pointer_scanner = menu.addAction(tr.POINTER_SCANNER)
pointer_scan = menu.addAction(tr.POINTER_SCAN)
menu.addSeparator()
what_writes = menu.addAction(tr.WHAT_WRITES)
what_reads = menu.addAction(tr.WHAT_READS)
what_accesses = menu.addAction(tr.WHAT_ACCESSES)
menu.addSeparator()
cut_record = menu.addAction(f"{tr.CUT}[Ctrl+X]")
copy_record = menu.addAction(f"{tr.COPY}[Ctrl+C]")
paste_record = menu.addAction(f"{tr.PASTE}[Ctrl+V]")
paste_inside = menu.addAction(f"{tr.PASTE_INSIDE}[V]")
menu.addSeparator()
add_group = menu.addAction(tr.ADD_GROUP)
create_group = menu.addAction(tr.CREATE_GROUP)
if current_row is None:
deletion_list = [
edit_menu.menuAction(),
show_hex,
show_dec,
show_unsigned,
show_signed,
toggle_record,
toggle_children,
freeze_menu.menuAction(),
browse_region,
disassemble,
pointer_scan,
what_writes,
what_reads,
what_accesses,
cut_record,
copy_record,
paste_inside,
delete_record,
add_group,
]
guiutils.delete_menu_entries(menu, deletion_list)
else:
value_type = current_row.data(TYPE_COL, Qt.ItemDataRole.UserRole)
if typedefs.VALUE_INDEX.is_integer(value_type.value_index):
if value_type.value_repr is typedefs.VALUE_REPR.HEX:
guiutils.delete_menu_entries(menu, [show_unsigned, show_signed, show_hex])
elif value_type.value_repr is typedefs.VALUE_REPR.UNSIGNED:
guiutils.delete_menu_entries(menu, [show_unsigned, show_dec])
elif value_type.value_repr is typedefs.VALUE_REPR.SIGNED:
guiutils.delete_menu_entries(menu, [show_signed, show_dec])
if current_row.checkState(FROZEN_COL) == Qt.CheckState.Unchecked:
guiutils.delete_menu_entries(menu, [freeze_menu.menuAction()])
else:
guiutils.delete_menu_entries(
menu, [show_hex, show_dec, show_unsigned, show_signed, freeze_menu.menuAction()]
)
if current_row.childCount() == 0:
guiutils.delete_menu_entries(menu, [toggle_children])
guiutils.delete_menu_entries(menu, [pointer_scanner])
if debugcore.currentpid == -1:
browse_region.setEnabled(False)
disassemble.setEnabled(False)
pointer_scan.setEnabled(False)
if not debugcore.is_attached():
what_writes.setEnabled(False)
what_reads.setEnabled(False)
what_accesses.setEnabled(False)
font_size = self.treeWidget_AddressTable.font().pointSize()
menu.setStyleSheet("font-size: " + str(font_size) + "pt;")
action = menu.exec(event.globalPos())
actions = {
delete_record: self.delete_records,
edit_desc: self.treeWidget_AddressTable_edit_desc,
edit_address: self.treeWidget_AddressTable_edit_address,
edit_type: self.treeWidget_AddressTable_edit_type,
edit_value: self.treeWidget_AddressTable_edit_value,
show_hex: lambda: self.treeWidget_AddressTable_change_repr(typedefs.VALUE_REPR.HEX),
show_dec: lambda: self.treeWidget_AddressTable_change_repr(typedefs.VALUE_REPR.UNSIGNED),
show_unsigned: lambda: self.treeWidget_AddressTable_change_repr(typedefs.VALUE_REPR.UNSIGNED),
show_signed: lambda: self.treeWidget_AddressTable_change_repr(typedefs.VALUE_REPR.SIGNED),
toggle_record: self.toggle_records,
toggle_children: lambda: self.toggle_records(True),
freeze_default: lambda: self.change_freeze_type(typedefs.FREEZE_TYPE.DEFAULT),
freeze_inc: lambda: self.change_freeze_type(typedefs.FREEZE_TYPE.INCREMENT),
freeze_dec: lambda: self.change_freeze_type(typedefs.FREEZE_TYPE.DECREMENT),
browse_region: lambda: self.browse_region_for_address(current_address),
disassemble: lambda: self.disassemble_for_address(current_address),
pointer_scanner: self.exec_pointer_scanner,
pointer_scan: self.exec_pointer_scan,
what_writes: lambda: self.exec_track_watchpoint_widget(typedefs.WATCHPOINT_TYPE.WRITE_ONLY),
what_reads: lambda: self.exec_track_watchpoint_widget(typedefs.WATCHPOINT_TYPE.READ_ONLY),
what_accesses: lambda: self.exec_track_watchpoint_widget(typedefs.WATCHPOINT_TYPE.BOTH),
cut_record: self.cut_records,
copy_record: self.copy_records,
paste_record: self.paste_records,
paste_inside: lambda: self.paste_records(True),
add_group: self.group_records,
create_group: self.create_group,
}
try:
actions[action]()
except KeyError:
pass
def exec_pointer_scanner(self):
pointer_window = PointerScanWindow(self)
pointer_window.show()
def exec_pointer_scan(self):
selected_row = guiutils.get_current_item(self.treeWidget_AddressTable)
if not selected_row:
return
address = selected_row.text(ADDR_COL).strip("P->")
pointer_window = PointerScanWindow(self)
pointer_window.show()
dialog = PointerScanSearchDialog(pointer_window, address)
dialog.exec()
def exec_track_watchpoint_widget(self, watchpoint_type):
selected_row = guiutils.get_current_item(self.treeWidget_AddressTable)
if not selected_row:
return
address = selected_row.text(ADDR_COL).strip("P->") # @todo Maybe rework address grabbing logic in the future
address_data = selected_row.data(ADDR_COL, Qt.ItemDataRole.UserRole)
if isinstance(address_data, typedefs.PointerChainRequest):
selection_dialog = TrackSelectorDialogForm(self)
selection_dialog.exec()
if not selection_dialog.selection:
return
if selection_dialog.selection == "pointer":
address = address_data.get_base_address_as_str()
value_type = selected_row.data(TYPE_COL, Qt.ItemDataRole.UserRole)
if typedefs.VALUE_INDEX.is_string(value_type.value_index):
value_text = selected_row.text(VALUE_COL)
encoding, option = typedefs.string_index_to_encoding_dict[value_type.value_index]
byte_len = len(value_text.encode(encoding, option))
elif value_type.value_index == typedefs.VALUE_INDEX.AOB:
byte_len = value_type.length
else:
byte_len = typedefs.index_to_valuetype_dict[value_type.value_index][0]
TrackWatchpointWidgetForm(self, address, byte_len, watchpoint_type)
def browse_region_for_address(self, address: str):
if address:
self.memory_view_window.hex_dump_address(int(address.strip("P->"), 16))
self.memory_view_window.show()
self.memory_view_window.activateWindow()
def disassemble_for_address(self, address: str):
if address and self.memory_view_window.disassemble_expression(address.strip("P->")):
self.memory_view_window.show()
self.memory_view_window.activateWindow()
def change_freeze_type(self, freeze_type: int | None = None, row: QTreeWidgetItem | None = None) -> None:
if freeze_type == None:
# No type has been specified, iterate through the freeze types
# This usually happens if user clicks the freeze type text instead of the checkbox
frozen: typedefs.Frozen = row.data(FROZEN_COL, Qt.ItemDataRole.UserRole)
if frozen.freeze_type == typedefs.FREEZE_TYPE.DECREMENT:
# Decrement is the last freeze type
freeze_type = typedefs.FREEZE_TYPE.DEFAULT
else:
freeze_type = frozen.freeze_type + 1
rows = [row] if row else self.treeWidget_AddressTable.selectedItems()
for row in rows:
frozen: typedefs.Frozen = row.data(FROZEN_COL, Qt.ItemDataRole.UserRole)
if row.checkState(FROZEN_COL) == Qt.CheckState.Checked:
frozen.freeze_type = freeze_type
if freeze_type == typedefs.FREEZE_TYPE.DEFAULT:
row.setText(FROZEN_COL, "")
row.setForeground(FROZEN_COL, QBrush())
elif freeze_type == typedefs.FREEZE_TYPE.INCREMENT:
row.setText(FROZEN_COL, "▲")
row.setForeground(FROZEN_COL, QBrush(QColor(0, 255, 0)))
elif freeze_type == typedefs.FREEZE_TYPE.DECREMENT:
row.setText(FROZEN_COL, "▼")
row.setForeground(FROZEN_COL, QBrush(QColor(255, 0, 0)))
else:
frozen.freeze_type = typedefs.FREEZE_TYPE.DEFAULT
row.setText(FROZEN_COL, "")
row.setForeground(FROZEN_COL, QBrush())
def toggle_records(self, toggle_children=False):
row = guiutils.get_current_item(self.treeWidget_AddressTable)
selected_items = self.treeWidget_AddressTable.selectedItems()
# If only one item is selected and then clicked while ctrl is being held
# There'll be no selected rows even with a current row present
if row and selected_items:
if not row.isSelected():
row = selected_items[0]
check_state = row.checkState(FROZEN_COL)
new_state = Qt.CheckState.Checked if check_state == Qt.CheckState.Unchecked else Qt.CheckState.Unchecked
for row in selected_items:
self.handle_freeze_change(row, new_state)
if toggle_children:
for index in range(row.childCount()):
child = row.child(index)
self.handle_freeze_change(child, new_state)
def cut_records(self):
self.copy_records()
self.delete_records()
def copy_records(self):
# Recursive copy
items = self.treeWidget_AddressTable.selectedItems()
def index_of(item):
"""Returns the index used to access the given QTreeWidgetItem
as a list of ints."""
result = []
while True:
parent = item.parent()
if parent:
result.append(parent.indexOfChild(item))
item = parent
else:
result.append(item.treeWidget().indexOfTopLevelItem(item))
return result[::-1]
# First, order the items by their indices in the tree widget.
# Store the indices for later usage.
index_items = [(index_of(item), item) for item in items]
index_items.sort(key=lambda x: x[0]) # sort by index
# Now filter any selected items that is a descendant of another selected items.
items = []
last_index = [-1] # any invalid list of indices are fine
for index, item in index_items:
if index[: len(last_index)] == last_index:
continue # this item is a descendant of the last item
items.append(item)
last_index = index
app.clipboard().setText(repr([self.read_address_table_recursively(item) for item in items]))
def insert_records(self, records, parent_row, insert_index):
# parent_row should be a QTreeWidgetItem in treeWidget_AddressTable
# records should be an iterable of valid output of read_address_table_recursively
assert isinstance(parent_row, QTreeWidgetItem)
rows = []
for rec in records:
row = QTreeWidgetItem()
row.setCheckState(FROZEN_COL, Qt.CheckState.Unchecked)
frozen = typedefs.Frozen("", typedefs.FREEZE_TYPE.DEFAULT)
row.setData(FROZEN_COL, Qt.ItemDataRole.UserRole, frozen)
# Deserialize the address_expr & value_type param
if type(rec[1]) in [list, tuple]:
address_expr = typedefs.PointerChainRequest(*rec[1])
else:
address_expr = rec[1]
value_type = typedefs.ValueType(*rec[2])
self.change_address_table_entries(row, rec[0], address_expr, value_type)
self.insert_records(rec[-1], row, 0)
rows.append(row)
parent_row.insertChildren(insert_index, rows)
parent_row.setExpanded(True)
def paste_records(self, insert_inside=False):
try:
records = ast.literal_eval(app.clipboard().text())
except (SyntaxError, ValueError):
QMessageBox.information(self, tr.ERROR, tr.INVALID_CLIPBOARD)
return
insert_row = guiutils.get_current_item(self.treeWidget_AddressTable)
root = self.treeWidget_AddressTable.invisibleRootItem()
if not insert_row: # this is common when the treeWidget_AddressTable is empty
self.insert_records(records, root, self.treeWidget_AddressTable.topLevelItemCount())
elif insert_inside:
self.insert_records(records, insert_row, 0)
else:
parent = insert_row.parent() or root
self.insert_records(records, parent, parent.indexOfChild(insert_row) + 1)
self.update_address_table()
def group_records(self):
selected_items = self.treeWidget_AddressTable.selectedItems()
if self.create_group():
item_count = self.treeWidget_AddressTable.topLevelItemCount()
last_item = self.treeWidget_AddressTable.topLevelItem(item_count - 1)
for item in selected_items:
parent = item.parent()
if parent:
parent.removeChild(item)
else:
index = self.treeWidget_AddressTable.indexOfTopLevelItem(item)
self.treeWidget_AddressTable.takeTopLevelItem(index)
last_item.addChild(item)
self.treeWidget_AddressTable.setCurrentItem(last_item)
last_item.setExpanded(True)
def create_group(self):
dialog = utilwidgets.InputDialog(self, [(tr.ENTER_DESCRIPTION, tr.GROUP)])
if dialog.exec():
desc = dialog.get_values()[0]
self.add_entry_to_addresstable(desc, "0x0")
return True
return False
def delete_records(self):
root = self.treeWidget_AddressTable.invisibleRootItem()
for item in self.treeWidget_AddressTable.selectedItems():
(item.parent() or root).removeChild(item)
def treeWidget_AddressTable_mouse_press_event(self, event: QMouseEvent) -> None:
self.treeWidget_AddressTable.mousePressEvent_original(event)
item = self.treeWidget_AddressTable.itemAt(event.pos())
column = self.treeWidget_AddressTable.columnAt(event.pos().x())
# Qt doesn't select rows when checkboxes are clicked
# Ensure that the row is selected when frozen col is clicked
if item and column == FROZEN_COL:
item.setSelected(True)
def treeWidget_AddressTable_mouse_release_event(self, event: QMouseEvent) -> None:
item = self.treeWidget_AddressTable.itemAt(event.pos())
column = self.treeWidget_AddressTable.columnAt(event.pos().x())
if item and column == FROZEN_COL:
old_state = item.checkState(FROZEN_COL)
self.treeWidget_AddressTable.mouseReleaseEvent_original(event)
new_state = item.checkState(FROZEN_COL)
item.setSelected(True)
box_clicked = old_state != new_state
current_item = self.treeWidget_AddressTable.currentItem()
if not box_clicked and new_state == Qt.CheckState.Checked:
self.change_freeze_type(row=current_item)
frozen: typedefs.Frozen = current_item.data(FROZEN_COL, Qt.ItemDataRole.UserRole)
freeze_type = frozen.freeze_type
for selected_item in self.treeWidget_AddressTable.selectedItems():
if box_clicked:
self.handle_freeze_change(selected_item, new_state)
elif new_state == Qt.CheckState.Checked:
self.change_freeze_type(freeze_type, selected_item)
else:
self.treeWidget_AddressTable.mouseReleaseEvent_original(event)
def treeWidget_AddressTable_key_press_event(self, event: QKeyEvent):
current_row = guiutils.get_current_item(self.treeWidget_AddressTable)
current_address = current_row.text(ADDR_COL) if current_row else None
actions = typedefs.KeyboardModifiersTupleDict(
[
(QKeyCombination(Qt.KeyboardModifier.NoModifier, Qt.Key.Key_Delete), self.delete_records),
(
QKeyCombination(Qt.KeyboardModifier.ControlModifier, Qt.Key.Key_B),
lambda: self.browse_region_for_address(current_address),
),
(
QKeyCombination(Qt.KeyboardModifier.ControlModifier, Qt.Key.Key_D),
lambda: self.disassemble_for_address(current_address),
),
(
QKeyCombination(Qt.KeyboardModifier.NoModifier, Qt.Key.Key_R),
self.pushButton_RefreshAdressTable_clicked,
),
(QKeyCombination(Qt.KeyboardModifier.NoModifier, Qt.Key.Key_Space), self.toggle_records),
(QKeyCombination(Qt.KeyboardModifier.ShiftModifier, Qt.Key.Key_Space), self.toggle_records),
(
QKeyCombination(Qt.KeyboardModifier.ControlModifier, Qt.Key.Key_Space),
lambda: self.toggle_records(True),
),
(QKeyCombination(Qt.KeyboardModifier.ControlModifier, Qt.Key.Key_X), self.cut_records),
(QKeyCombination(Qt.KeyboardModifier.ControlModifier, Qt.Key.Key_C), self.copy_records),
(QKeyCombination(Qt.KeyboardModifier.ControlModifier, Qt.Key.Key_V), self.paste_records),
(QKeyCombination(Qt.KeyboardModifier.NoModifier, Qt.Key.Key_V), lambda: self.paste_records(True)),
(
QKeyCombination(Qt.KeyboardModifier.NoModifier, Qt.Key.Key_Return),
self.treeWidget_AddressTable_edit_value,
),
(
QKeyCombination(Qt.KeyboardModifier.KeypadModifier, Qt.Key.Key_Enter),
self.treeWidget_AddressTable_edit_value,
),
(
QKeyCombination(Qt.KeyboardModifier.ControlModifier, Qt.Key.Key_Return),
self.treeWidget_AddressTable_edit_desc,
),
(
QKeyCombination(
Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier, Qt.Key.Key_Return
),
self.treeWidget_AddressTable_edit_address,
),
(
QKeyCombination(Qt.KeyboardModifier.AltModifier, Qt.Key.Key_Return),
self.treeWidget_AddressTable_edit_type,
),
]
)
try:
actions[QKeyCombination(event.modifiers(), Qt.Key(event.key()))]()
except KeyError:
self.treeWidget_AddressTable.keyPressEvent_original(event)
def update_address_table(self):
if debugcore.currentpid == -1 or self.treeWidget_AddressTable.topLevelItemCount() == 0:
return
it = QTreeWidgetItemIterator(self.treeWidget_AddressTable)
mem_handle = debugcore.memory_handle()
basic_math_exp = re.compile(r"^[0-9a-fA-F][/*+\-0-9a-fA-FxX]+$")
while True:
row = it.value()
if not row:
break
it += 1
address_data = row.data(ADDR_COL, Qt.ItemDataRole.UserRole)
if isinstance(address_data, typedefs.PointerChainRequest):
expression = address_data.base_address
else:
expression = address_data
parent = row.parent()
if parent and expression.startswith(("+", "-")):
expression = parent.data(ADDR_COL, Qt.ItemDataRole.UserRole + 1) + expression
if expression in states.exp_cache:
address = states.exp_cache[expression]
elif expression.startswith(("+", "-")): # If parent has an empty address
address = expression
elif basic_math_exp.match(expression.replace(" ", "")):
try:
address = hex(eval(expression))
except:
address = debugcore.examine_expression(expression).address
states.exp_cache[expression] = address
else:
address = debugcore.examine_expression(expression).address
states.exp_cache[expression] = address
vt = row.data(TYPE_COL, Qt.ItemDataRole.UserRole)
if isinstance(address_data, typedefs.PointerChainRequest):
# The original base could be a symbol so we have to save it
# This little hack avoids the unnecessary examine_expression call
# TODO: Consider implementing exp_cache inside libpince so we don't need this hack
pointer_chain_req = address_data
if address:
old_base = pointer_chain_req.base_address # save the old base
pointer_chain_req.base_address = address
pointer_chain_result = debugcore.read_pointer_chain(pointer_chain_req)
if pointer_chain_result and pointer_chain_result.get_final_address():
address = pointer_chain_result.get_final_address_as_hex()
else:
address = None
address_data.base_address = old_base # then set it back
if address:
row.setText(ADDR_COL, f"P->{address}")
else:
row.setText(ADDR_COL, "P->??")
else:
row.setText(ADDR_COL, "P->??")
else:
row.setText(ADDR_COL, address or address_data)
address = "" if not address else address
row.setData(ADDR_COL, Qt.ItemDataRole.UserRole + 1, address)
value = debugcore.read_memory(
address, vt.value_index, vt.length, vt.zero_terminate, vt.value_repr, vt.endian, mem_handle=mem_handle
)
value = "" if value is None else str(value)
row.setText(VALUE_COL, value)
def scan_values(self):
if debugcore.currentpid == -1:
return
search_for = self.validate_search(self.lineEdit_Scan.text(), self.lineEdit_Scan2.text())
self.QWidget_Toolbox.setEnabled(False)
self.progressBar.setValue(0)
self.progress_bar_timer = QTimer(timeout=self.update_progress_bar)
self.progress_bar_timer.start(100)
scan_thread = guitypedefs.Worker(scanmem.send_command, search_for)
scan_thread.signals.finished.connect(self.scan_callback)
states.threadpool.start(scan_thread)
def resize_address_table(self):
self.treeWidget_AddressTable.resizeColumnToContents(FROZEN_COL)
# gets the information from the dialog then adds it to addresstable
def pushButton_AddAddressManually_clicked(self):