-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathdebug.html
More file actions
1370 lines (1265 loc) · 118 KB
/
Copy pathdebug.html
File metadata and controls
1370 lines (1265 loc) · 118 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
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>9. windows.debug – Debugging — PythonForWindows 0.6 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/css/mbasic.css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="10. windows.com - Component Object Model" href="com.html" />
<link rel="prev" title="8. windows.wintrust – Checking signature" href="wintrust.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="com.html" title="10. windows.com - Component Object Model"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="wintrust.html" title="8. windows.wintrust – Checking signature"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">PythonForWindows 0.6 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-windows.debug">
<span id="windows-debug-debugging"></span><h1>9. <a class="reference internal" href="#module-windows.debug" title="windows.debug"><code class="xref py py-mod docutils literal notranslate"><span class="pre">windows.debug</span></code></a> – Debugging<a class="headerlink" href="#module-windows.debug" title="Permalink to this headline">¶</a></h1>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">See sample <a class="reference internal" href="sample.html#sample-debugger"><span class="std std-ref">Debugging</span></a></p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>If you are interrested by symbols (PDB) handling, go to subsection <a class="reference internal" href="#debug-symbols-module"><span class="std std-ref">windows.debug.symbols – Using symbols</span></a>.</p>
<p class="last">You can also look at the symbols-related samples: <a class="reference internal" href="sample.html#sample-symbols"><span class="std std-ref">Symbols</span></a></p>
</div>
<div class="section" id="debugger">
<h2>9.1. <a class="reference internal" href="#windows.debug.Debugger" title="windows.debug.Debugger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Debugger</span></code></a><a class="headerlink" href="#debugger" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#windows.debug.Debugger" title="windows.debug.Debugger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Debugger</span></code></a> is the base class to perform the debugging of a remote process.
The <a class="reference internal" href="#windows.debug.Debugger" title="windows.debug.Debugger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Debugger</span></code></a> have some functions called on given event that can be implemented by subclasses.</p>
<p>All Memory-breakpoint are disabled when callind a public callback or a breakpoint <code class="docutils literal notranslate"><span class="pre">trigger()</span></code> function.</p>
<p>This means that those methods see the original <code class="docutils literal notranslate"><span class="pre">current_process</span></code> memory access rights.</p>
<dl class="class">
<dt id="windows.debug.Debugger">
<em class="property">class </em><code class="descclassname">windows.debug.</code><code class="descname">Debugger</code><span class="sig-paren">(</span><em>target</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger" title="Permalink to this definition">¶</a></dt>
<dd><p>A debugger based on standard Win32 API. Handle :</p>
<ul class="simple">
<li>Standard BP (int3)</li>
<li>Hardware-Exec BP (DrX)</li>
<li>Memory BP (virtual_protect)</li>
</ul>
<dl class="method">
<dt id="windows.debug.Debugger.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>target</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">target</span></code> must be a debuggable <code class="xref py py-class docutils literal notranslate"><span class="pre">WinProcess</span></code>.</p>
</dd></dl>
<dl class="classmethod">
<dt id="windows.debug.Debugger.attach">
<em class="property">classmethod </em><code class="descname">attach</code><span class="sig-paren">(</span><em>target</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.attach"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.attach" title="Permalink to this definition">¶</a></dt>
<dd><p>attach to <code class="docutils literal notranslate"><span class="pre">target</span></code> (must be a <code class="xref py py-class docutils literal notranslate"><span class="pre">WinProcess</span></code>)</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#windows.debug.Debugger" title="windows.debug.Debugger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Debugger</span></code></a></td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">see <a class="reference internal" href="sample.html#sample-debugger-attach"><span class="std std-ref">Debugger.attach sample</span></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.detach">
<code class="descname">detach</code><span class="sig-paren">(</span><em>target=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.detach"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.detach" title="Permalink to this definition">¶</a></dt>
<dd><p>Detach from all debugged processes or process <code class="docutils literal notranslate"><span class="pre">target</span></code></p>
</dd></dl>
<dl class="classmethod">
<dt id="windows.debug.Debugger.debug">
<em class="property">classmethod </em><code class="descname">debug</code><span class="sig-paren">(</span><em>path</em>, <em>args=None</em>, <em>dwCreationFlags=0</em>, <em>show_windows=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.debug"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.debug" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a process and debug it.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#windows.debug.Debugger" title="windows.debug.Debugger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Debugger</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.loop">
<code class="descname">loop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.loop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.loop" title="Permalink to this definition">¶</a></dt>
<dd><p>Debugging loop: handle event / dispatch to breakpoint. Returns when all targets are dead/detached</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.add_bp">
<code class="descname">add_bp</code><span class="sig-paren">(</span><em>bp</em>, <em>addr=None</em>, <em>type=None</em>, <em>target=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.add_bp"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.add_bp" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a breakpoint, bp can be:</p>
<ul class="simple">
<li>a <a class="reference internal" href="#windows.debug.Breakpoint" title="windows.debug.Breakpoint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Breakpoint</span></code></a> (addr and type must be <code class="docutils literal notranslate"><span class="pre">None</span></code>)</li>
<li>any callable (addr and type must NOT be <code class="docutils literal notranslate"><span class="pre">None</span></code>) (NON-TESTED)</li>
</ul>
<p>If the <code class="docutils literal notranslate"><span class="pre">bp</span></code> type is <code class="docutils literal notranslate"><span class="pre">STANDARD_BP</span></code> or <code class="docutils literal notranslate"><span class="pre">MEMORY_BREAKPOINT</span></code>, target can be <code class="docutils literal notranslate"><span class="pre">None</span></code> (all targets) or a process.</p>
<p>If the <code class="docutils literal notranslate"><span class="pre">bp</span></code> type is <code class="docutils literal notranslate"><span class="pre">HARDWARE_EXEC_BP</span></code>, target can be <code class="docutils literal notranslate"><span class="pre">None</span></code> (all targets), a process or a thread.</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.del_bp">
<code class="descname">del_bp</code><span class="sig-paren">(</span><em>bp</em>, <em>targets=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.del_bp"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.del_bp" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete a breakpoint, if targets is <code class="docutils literal notranslate"><span class="pre">None</span></code>: delete it from all targets</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.single_step">
<code class="descname">single_step</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.single_step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.single_step" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the <code class="docutils literal notranslate"><span class="pre">current_thread</span></code> <code class="docutils literal notranslate"><span class="pre">single_step</span></code>. <code class="docutils literal notranslate"><span class="pre">Debugger.on_single_step</span></code> will be called after that</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.get_memory_breakpoint_at">
<code class="descname">get_memory_breakpoint_at</code><span class="sig-paren">(</span><em>addr</em>, <em>process=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.get_memory_breakpoint_at"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.get_memory_breakpoint_at" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the memory breakpoint that handle <code class="docutils literal notranslate"><span class="pre">addr</span></code></p>
<p>Return values are:</p>
<blockquote>
<div><ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">False</span></code> if the page has no memory breakpoint (real fault)</li>
<li><code class="docutils literal notranslate"><span class="pre">None</span></code> if the page as memBP but None handle <code class="docutils literal notranslate"><span class="pre">addr</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">bp</span></code> the MemBP that handle <code class="docutils literal notranslate"><span class="pre">addr</span></code></li>
</ul>
</div></blockquote>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.disable_all_memory_breakpoints">
<code class="descname">disable_all_memory_breakpoints</code><span class="sig-paren">(</span><em>target=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.disable_all_memory_breakpoints"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.disable_all_memory_breakpoints" title="Permalink to this definition">¶</a></dt>
<dd><p>Restore all pages to their original access rights.
If target is <code class="docutils literal notranslate"><span class="pre">None</span></code>, use <code class="docutils literal notranslate"><span class="pre">current_process</span></code></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">a mapping of all disabled breakpoints that must be passed to <a class="reference internal" href="#windows.debug.Debugger.restore_all_memory_breakpoints" title="windows.debug.Debugger.restore_all_memory_breakpoints"><code class="xref py py-func docutils literal notranslate"><span class="pre">restore_all_memory_breakpoints()</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.restore_all_memory_breakpoints">
<code class="descname">restore_all_memory_breakpoints</code><span class="sig-paren">(</span><em>data</em>, <em>target=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.restore_all_memory_breakpoints"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.restore_all_memory_breakpoints" title="Permalink to this definition">¶</a></dt>
<dd><p>Re-setup all memory breakpoints, affecting pages access rights.
If target is <code class="docutils literal notranslate"><span class="pre">None</span></code>, use <code class="docutils literal notranslate"><span class="pre">current_process</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">data</span></code> is the result of the corresponding call to <a class="reference internal" href="#windows.debug.Debugger.disable_all_memory_breakpoints" title="windows.debug.Debugger.disable_all_memory_breakpoints"><code class="xref py py-func docutils literal notranslate"><span class="pre">disable_all_memory_breakpoints()</span></code></a></p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.DisabledMemoryBreakpoint">
<code class="descname">DisabledMemoryBreakpoint</code><span class="sig-paren">(</span><em>**kwds</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.DisabledMemoryBreakpoint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.DisabledMemoryBreakpoint" title="Permalink to this definition">¶</a></dt>
<dd><p>A context-manager that disable all memory breakpoints and restore them on exit</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.get_exception_bitness">
<code class="descname">get_exception_bitness</code><span class="sig-paren">(</span><em>exc</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.get_exception_bitness"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.get_exception_bitness" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the bitness in which the exception occured.
Useful when debugingg a 32b process from a 64bits one</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/2.7/library/functions.html#int" title="(in Python v2.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a> – 32 or 64</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="staticmethod">
<dt id="windows.debug.Debugger.kill_on_exit">
<em class="property">static </em><code class="descname">kill_on_exit</code><span class="sig-paren">(</span><em>choice</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.kill_on_exit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.kill_on_exit" title="Permalink to this definition">¶</a></dt>
<dd><p>If set to True(default in Windows) will kill all attached process on thread exit.
Otherwise, the thread detaches from all processes being debugged on exit.</p>
<p>See: <a class="reference external" href="https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-debugsetprocesskillonexit">https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-debugsetprocesskillonexit</a></p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_setup">
<code class="descname">on_setup</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_setup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_setup" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on the first breakpoint event occuring in the debugger.
This callback allow to setup hook / interact with the debugee when ready:</p>
<ul class="simple">
<li>If <a class="reference internal" href="#windows.debug.Debugger.on_setup" title="windows.debug.Debugger.on_setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_setup()</span></code></a> is overriden by a subclass it will be called and <a class="reference internal" href="#windows.debug.Debugger.on_exception" title="windows.debug.Debugger.on_exception"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_exception()</span></code></a> will NOT be called for this event (first BP).</li>
<li>If <a class="reference internal" href="#windows.debug.Debugger.on_setup" title="windows.debug.Debugger.on_setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_setup()</span></code></a> is not defined the first BP will trigger an <a class="reference internal" href="#windows.debug.Debugger.on_exception" title="windows.debug.Debugger.on_exception"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_exception()</span></code></a>.</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">see sample <a class="reference internal" href="sample.html#sample-debugger-on-setup"><span class="std std-ref">on_setup</span></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_exception">
<code class="descname">on_exception</code><span class="sig-paren">(</span><em>exception</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_exception"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_exception" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on exception event other that known breakpoint or requested single step. <code class="docutils literal notranslate"><span class="pre">exception</span></code> is one of the following type:</p>
<blockquote>
<div><ul class="simple">
<li><a class="reference internal" href="exception.html#windows.winobject.exception.EEXCEPTION_DEBUG_INFO32" title="windows.winobject.exception.EEXCEPTION_DEBUG_INFO32"><code class="xref py py-class docutils literal notranslate"><span class="pre">windows.winobject.exception.EEXCEPTION_DEBUG_INFO32</span></code></a></li>
<li><a class="reference internal" href="exception.html#windows.winobject.exception.EEXCEPTION_DEBUG_INFO64" title="windows.winobject.exception.EEXCEPTION_DEBUG_INFO64"><code class="xref py py-class docutils literal notranslate"><span class="pre">windows.winobject.exception.EEXCEPTION_DEBUG_INFO64</span></code></a></li>
</ul>
</div></blockquote>
<p>The default behaviour is to return <code class="docutils literal notranslate"><span class="pre">DBG_CONTINUE</span></code> for the known exception code
and <code class="docutils literal notranslate"><span class="pre">DBG_EXCEPTION_NOT_HANDLED</span></code> else</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_single_step">
<code class="descname">on_single_step</code><span class="sig-paren">(</span><em>exception</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_single_step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_single_step" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on requested single step <code class="docutils literal notranslate"><span class="pre">exception</span></code> is one of the following type:</p>
<blockquote>
<div><ul class="simple">
<li><a class="reference internal" href="exception.html#windows.winobject.exception.EEXCEPTION_DEBUG_INFO32" title="windows.winobject.exception.EEXCEPTION_DEBUG_INFO32"><code class="xref py py-class docutils literal notranslate"><span class="pre">windows.winobject.exception.EEXCEPTION_DEBUG_INFO32</span></code></a></li>
<li><a class="reference internal" href="exception.html#windows.winobject.exception.EEXCEPTION_DEBUG_INFO64" title="windows.winobject.exception.EEXCEPTION_DEBUG_INFO64"><code class="xref py py-class docutils literal notranslate"><span class="pre">windows.winobject.exception.EEXCEPTION_DEBUG_INFO64</span></code></a></li>
</ul>
</div></blockquote>
<p>There is no default implementation, if you use <code class="docutils literal notranslate"><span class="pre">Debugger.single_step()</span></code> you should implement <code class="docutils literal notranslate"><span class="pre">on_single_step</span></code></p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_create_process">
<code class="descname">on_create_process</code><span class="sig-paren">(</span><em>create_process</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_create_process"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_create_process" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on create_process event</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>create_process</strong> (<a class="reference internal" href="winstructs_generated.html#windows.generated_def.winstructs.CREATE_PROCESS_DEBUG_INFO" title="windows.generated_def.winstructs.CREATE_PROCESS_DEBUG_INFO"><em>CREATE_PROCESS_DEBUG_INFO</em></a>) – </td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_exit_process">
<code class="descname">on_exit_process</code><span class="sig-paren">(</span><em>exit_process</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_exit_process"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_exit_process" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on exit_process event</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>exit_process</strong> (<a class="reference internal" href="winstructs_generated.html#windows.generated_def.winstructs.EXIT_PROCESS_DEBUG_INFO" title="windows.generated_def.winstructs.EXIT_PROCESS_DEBUG_INFO"><em>EXIT_PROCESS_DEBUG_INFO</em></a>) – </td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_create_thread">
<code class="descname">on_create_thread</code><span class="sig-paren">(</span><em>create_thread</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_create_thread"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_create_thread" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on create_thread event</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>create_thread</strong> (<a class="reference internal" href="winstructs_generated.html#windows.generated_def.winstructs.CREATE_THREAD_DEBUG_INFO" title="windows.generated_def.winstructs.CREATE_THREAD_DEBUG_INFO"><em>CREATE_THREAD_DEBUG_INFO</em></a>) – </td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_exit_thread">
<code class="descname">on_exit_thread</code><span class="sig-paren">(</span><em>exit_thread</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_exit_thread"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_exit_thread" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on exit_thread event</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>exit_thread</strong> (<a class="reference internal" href="winstructs_generated.html#windows.generated_def.winstructs.EXIT_THREAD_DEBUG_INFO" title="windows.generated_def.winstructs.EXIT_THREAD_DEBUG_INFO"><em>EXIT_THREAD_DEBUG_INFO</em></a>) – </td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_load_dll">
<code class="descname">on_load_dll</code><span class="sig-paren">(</span><em>load_dll</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_load_dll"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_load_dll" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on load_dll event</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>load_dll</strong> (<a class="reference internal" href="winstructs_generated.html#windows.generated_def.winstructs.LOAD_DLL_DEBUG_INFO" title="windows.generated_def.winstructs.LOAD_DLL_DEBUG_INFO"><em>LOAD_DLL_DEBUG_INFO</em></a>) – </td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_unload_dll">
<code class="descname">on_unload_dll</code><span class="sig-paren">(</span><em>unload_dll</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_unload_dll"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_unload_dll" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on unload_dll event</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>unload_dll</strong> (<a class="reference internal" href="winstructs_generated.html#windows.generated_def.winstructs.UNLOAD_DLL_DEBUG_INFO" title="windows.generated_def.winstructs.UNLOAD_DLL_DEBUG_INFO"><em>UNLOAD_DLL_DEBUG_INFO</em></a>) – </td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_output_debug_string">
<code class="descname">on_output_debug_string</code><span class="sig-paren">(</span><em>debug_string</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_output_debug_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_output_debug_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on debug_string event</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>debug_string</strong> (<a class="reference internal" href="winstructs_generated.html#windows.generated_def.winstructs.OUTPUT_DEBUG_STRING_INFO" title="windows.generated_def.winstructs.OUTPUT_DEBUG_STRING_INFO"><em>OUTPUT_DEBUG_STRING_INFO</em></a>) – </td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.Debugger.on_rip">
<code class="descname">on_rip</code><span class="sig-paren">(</span><em>rip_info</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/debugger.html#Debugger.on_rip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Debugger.on_rip" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on rip_info event</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>rip_info</strong> (<a class="reference internal" href="winstructs_generated.html#windows.generated_def.winstructs.RIP_INFO" title="windows.generated_def.winstructs.RIP_INFO"><em>RIP_INFO</em></a>) – </td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="symboldebugger">
<h2>9.2. <a class="reference internal" href="#windows.debug.SymbolDebugger" title="windows.debug.SymbolDebugger"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolDebugger</span></code></a><a class="headerlink" href="#symboldebugger" title="Permalink to this headline">¶</a></h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">See sample <a class="reference internal" href="sample.html#sample-symbol-debugger"><span class="std std-ref">SymbolDebugger</span></a></p>
</div>
<dl class="class">
<dt id="windows.debug.SymbolDebugger">
<em class="property">class </em><code class="descclassname">windows.debug.</code><code class="descname">SymbolDebugger</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/symboldbg.html#SymbolDebugger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.SymbolDebugger" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">windows.debug.debugger.Debugger</span></code></p>
<p>A debugger using the symbol API (hence PDB) for name resolution.
To use PDB, a correct version of dbghelp should be configured as well as <code class="docutils literal notranslate"><span class="pre">_NT_SYMBOL_PATH</span></code>.
(See <a class="reference internal" href="#debug-symbols-module"><span class="std std-ref">windows.debug.symbols – Using symbols</span></a>)</p>
<p>This debugger add a <code class="docutils literal notranslate"><span class="pre">current_resolver</span></code> variable (A <a class="reference internal" href="#windows.debug.symbols.ProcessSymbolHandler" title="windows.debug.symbols.ProcessSymbolHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">ProcessSymbolHandler</span></code></a>) for the <code class="docutils literal notranslate"><span class="pre">current_process</span></code>.</p>
</dd></dl>
</div>
<div class="section" id="localdebugger">
<h2>9.3. <a class="reference internal" href="#windows.debug.LocalDebugger" title="windows.debug.LocalDebugger"><code class="xref py py-class docutils literal notranslate"><span class="pre">LocalDebugger</span></code></a><a class="headerlink" href="#localdebugger" title="Permalink to this headline">¶</a></h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">See sample <a class="reference internal" href="sample.html#sample-local-debugger"><span class="std std-ref">LocalDebugger</span></a></p>
</div>
<p>The <a class="reference internal" href="#windows.debug.Debugger" title="windows.debug.Debugger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Debugger</span></code></a> is the base class to perform the debugging the current process.
It is based on <code class="xref py py-func docutils literal notranslate"><span class="pre">VectoredException()</span></code> (see <a class="reference internal" href="sample.html#sample-vectoredexception"><span class="std std-ref">VectoredException()</span></a>)</p>
<p>There is not much documentation for now as the code might change soon.</p>
<dl class="class">
<dt id="windows.debug.LocalDebugger">
<em class="property">class </em><code class="descclassname">windows.debug.</code><code class="descname">LocalDebugger</code><a class="reference internal" href="_modules/windows/debug/localdbg.html#LocalDebugger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.LocalDebugger" title="Permalink to this definition">¶</a></dt>
<dd><p>A debugger interface around <code class="xref py py-func docutils literal notranslate"><span class="pre">AddVectoredExceptionHandler()</span></code>.</p>
<p>Handle:</p>
<blockquote>
<div><ul class="simple">
<li>Standard BP (int3)</li>
<li>Hardware-Exec BP (DrX)</li>
</ul>
</div></blockquote>
<dl class="method">
<dt id="windows.debug.LocalDebugger.add_bp">
<code class="descname">add_bp</code><span class="sig-paren">(</span><em>bp</em>, <em>target=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/localdbg.html#LocalDebugger.add_bp"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.LocalDebugger.add_bp" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a breakpoint, bp is a “class:<cite>Breakpoint</cite></p>
<p>If the <code class="docutils literal notranslate"><span class="pre">bp</span></code> type is <code class="docutils literal notranslate"><span class="pre">STANDARD_BP</span></code>, target must be None.</p>
<p>If the <code class="docutils literal notranslate"><span class="pre">bp</span></code> type is <code class="docutils literal notranslate"><span class="pre">HARDWARE_EXEC_BP</span></code>, target can be None (all threads), or some threads of the process</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.LocalDebugger.del_bp">
<code class="descname">del_bp</code><span class="sig-paren">(</span><em>bp</em>, <em>targets=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/localdbg.html#LocalDebugger.del_bp"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.LocalDebugger.del_bp" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete a breakpoint</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.LocalDebugger.get_exception_code">
<code class="descname">get_exception_code</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/localdbg.html#LocalDebugger.get_exception_code"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.LocalDebugger.get_exception_code" title="Permalink to this definition">¶</a></dt>
<dd><p>Return ExceptionCode of current exception</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.LocalDebugger.get_exception_context">
<code class="descname">get_exception_context</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/localdbg.html#LocalDebugger.get_exception_context"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.LocalDebugger.get_exception_context" title="Permalink to this definition">¶</a></dt>
<dd><p>Return context of current exception</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.LocalDebugger.on_exception">
<code class="descname">on_exception</code><span class="sig-paren">(</span><em>exc</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/localdbg.html#LocalDebugger.on_exception"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.LocalDebugger.on_exception" title="Permalink to this definition">¶</a></dt>
<dd><p>Called on exception</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.LocalDebugger.single_step">
<code class="descname">single_step</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/localdbg.html#LocalDebugger.single_step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.LocalDebugger.single_step" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the current thread to single step</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="breakpoint">
<h2>9.4. <a class="reference internal" href="#windows.debug.Breakpoint" title="windows.debug.Breakpoint"><code class="xref py py-class docutils literal notranslate"><span class="pre">Breakpoint</span></code></a><a class="headerlink" href="#breakpoint" title="Permalink to this headline">¶</a></h2>
<p>Standard breakpoints types expect an address as argument.</p>
<p>An address can be:</p>
<blockquote>
<div><ul>
<li><p class="first">An <a class="reference external" href="https://docs.python.org/2.7/library/functions.html#int" title="(in Python v2.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a></p>
</li>
<li><p class="first">A <a class="reference external" href="https://docs.python.org/2.7/library/functions.html#str" title="(in Python v2.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> of form (breakpoint will be put when <code class="docutils literal notranslate"><span class="pre">DLL</span></code> is loaded):</p>
<blockquote>
<div><ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">"DLL!ApiName"</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">"DLL!Offset"</span></code> where offset is a int (“16”, “0x10”, ..)</li>
</ul>
</div></blockquote>
</li>
</ul>
</div></blockquote>
<p>When a breakpoint is hit, its <code class="docutils literal notranslate"><span class="pre">trigger</span></code> function is called with the debugger and a
<code class="docutils literal notranslate"><span class="pre">DEBUG_EXECEPTION_EVENT</span></code> structure as argument.</p>
<dl class="class">
<dt id="windows.debug.Breakpoint">
<em class="property">class </em><code class="descclassname">windows.debug.</code><code class="descname">Breakpoint</code><span class="sig-paren">(</span><em>addr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#Breakpoint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Breakpoint" title="Permalink to this definition">¶</a></dt>
<dd><p>An standard (Int3) breakpoint (type == <code class="docutils literal notranslate"><span class="pre">STANDARD_BP</span></code>)</p>
<dl class="method">
<dt id="windows.debug.Breakpoint.trigger">
<code class="descname">trigger</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#Breakpoint.trigger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.Breakpoint.trigger" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when breakpoint is hit</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="windows.debug.HXBreakpoint">
<em class="property">class </em><code class="descclassname">windows.debug.</code><code class="descname">HXBreakpoint</code><span class="sig-paren">(</span><em>addr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#HXBreakpoint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.HXBreakpoint" title="Permalink to this definition">¶</a></dt>
<dd><p>An hardware-execution breakpoint (type == <code class="docutils literal notranslate"><span class="pre">HARDWARE_EXEC_BP</span></code>)</p>
<dl class="method">
<dt id="windows.debug.HXBreakpoint.trigger">
<code class="descname">trigger</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.HXBreakpoint.trigger" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when breakpoint is hit</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="windows.debug.MemoryBreakpoint">
<em class="property">class </em><code class="descclassname">windows.debug.</code><code class="descname">MemoryBreakpoint</code><span class="sig-paren">(</span><em>addr</em>, <em>size=None</em>, <em>events=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#MemoryBreakpoint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.MemoryBreakpoint" title="Permalink to this definition">¶</a></dt>
<dd><p>A memory breakpoint (type == <code class="docutils literal notranslate"><span class="pre">MEMORY_BREAKPOINT</span></code>)</p>
<dl class="method">
<dt id="windows.debug.MemoryBreakpoint.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>addr</em>, <em>size=None</em>, <em>events=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#MemoryBreakpoint.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.MemoryBreakpoint.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">size</span></code>: the size of the memory breakpoint.</p>
<p><code class="docutils literal notranslate"><span class="pre">events</span></code>: a string representing the events that interest the BP (any of “RWX”)</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.MemoryBreakpoint.trigger">
<code class="descname">trigger</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#MemoryBreakpoint.trigger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.MemoryBreakpoint.trigger" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when breakpoint is hit</p>
</dd></dl>
</dd></dl>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>MemoryBreakpoint are triggered based on the fault address only (as I don’t know a way to get the size of the read/write causing the fault without embedding a disassembler).</p>
<p class="last">This means that a MEMBP at address <code class="docutils literal notranslate"><span class="pre">X</span></code> won’t be triggered by a write of size 4 at address <code class="docutils literal notranslate"><span class="pre">X</span> <span class="pre">-</span> <span class="pre">1</span></code>. it’s sad I know.</p>
</div>
<dl class="class">
<dt id="windows.debug.FunctionCallBP">
<em class="property">class </em><code class="descclassname">windows.debug.</code><code class="descname">FunctionCallBP</code><span class="sig-paren">(</span><em>addr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#FunctionCallBP"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.FunctionCallBP" title="Permalink to this definition">¶</a></dt>
<dd><p>A Breakpoint that allow to trigger at the return of a function</p>
<dl class="method">
<dt id="windows.debug.FunctionCallBP.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>addr</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionCallBP.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>x.__init__(…) initializes x; see help(type(x)) for signature</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionCallBP.break_on_ret">
<code class="descname">break_on_ret</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#FunctionCallBP.break_on_ret"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.FunctionCallBP.break_on_ret" title="Permalink to this definition">¶</a></dt>
<dd><p>Setup a breakpoint at the return address of the function, this breakpoint will call <a class="reference internal" href="#windows.debug.FunctionCallBP.ret_trigger" title="windows.debug.FunctionCallBP.ret_trigger"><code class="xref py py-func docutils literal notranslate"><span class="pre">ret_trigger()</span></code></a></p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionCallBP.get_ret_addr">
<code class="descname">get_ret_addr</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#FunctionCallBP.get_ret_addr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.FunctionCallBP.get_ret_addr" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the return address of the current target, only valid in the trigger() function.</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionCallBP.ret_trigger">
<code class="descname">ret_trigger</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#FunctionCallBP.ret_trigger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.FunctionCallBP.ret_trigger" title="Permalink to this definition">¶</a></dt>
<dd><p>Called at the return of the function if <a class="reference internal" href="#windows.debug.FunctionCallBP.break_on_ret" title="windows.debug.FunctionCallBP.break_on_ret"><code class="xref py py-func docutils literal notranslate"><span class="pre">break_on_ret()</span></code></a> was called</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionCallBP.trigger">
<code class="descname">trigger</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionCallBP.trigger" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when breakpoint is hit</p>
</dd></dl>
</dd></dl>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">See sample <a class="reference internal" href="sample.html#sample-debugger-bp-functioncallbp"><span class="std std-ref">windows.debug.FunctionCallBP</span></a></p>
</div>
<dl class="class">
<dt id="windows.debug.FunctionBP">
<em class="property">class </em><code class="descclassname">windows.debug.</code><code class="descname">FunctionBP</code><span class="sig-paren">(</span><em>addr=None</em>, <em>target=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/breakpoints.html#FunctionBP"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.FunctionBP" title="Permalink to this definition">¶</a></dt>
<dd><p>A breakpoint that accepts a function from <a class="reference internal" href="winproxy.html#module-windows.winproxy" title="windows.winproxy"><code class="xref py py-mod docutils literal notranslate"><span class="pre">windows.winproxy</span></code></a> and able to:</p>
<ul class="simple">
<li>Extract the arguments of the functions</li>
<li>Break at the return of the function</li>
</ul>
<dl class="method">
<dt id="windows.debug.FunctionBP.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>addr=None</em>, <em>target=None</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionBP.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>x.__init__(…) initializes x; see help(type(x)) for signature</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionBP.arguments">
<code class="descname">arguments</code><span class="sig-paren">(</span><em>dbg</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionBP.arguments" title="Permalink to this definition">¶</a></dt>
<dd><p>TEST PARAM DICT</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionBP.break_on_ret">
<code class="descname">break_on_ret</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionBP.break_on_ret" title="Permalink to this definition">¶</a></dt>
<dd><p>Setup a breakpoint at the return address of the function, this breakpoint will call <a class="reference internal" href="#windows.debug.FunctionBP.ret_trigger" title="windows.debug.FunctionBP.ret_trigger"><code class="xref py py-func docutils literal notranslate"><span class="pre">ret_trigger()</span></code></a></p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionBP.extract_arguments">
<code class="descname">extract_arguments</code><span class="sig-paren">(</span><em>cproc</em>, <em>cthread</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionBP.extract_arguments" title="Permalink to this definition">¶</a></dt>
<dd><p>Extracts the functions parameters in an <code class="xref py py-class docutils literal notranslate"><span class="pre">OrderedDict</span></code></p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionBP.get_ret_addr">
<code class="descname">get_ret_addr</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionBP.get_ret_addr" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the return address of the current target, only valid in the trigger() function.</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionBP.ret_trigger">
<code class="descname">ret_trigger</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionBP.ret_trigger" title="Permalink to this definition">¶</a></dt>
<dd><p>Called at the return of the function if <a class="reference internal" href="#windows.debug.FunctionBP.break_on_ret" title="windows.debug.FunctionBP.break_on_ret"><code class="xref py py-func docutils literal notranslate"><span class="pre">break_on_ret()</span></code></a> was called</p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.FunctionBP.trigger">
<code class="descname">trigger</code><span class="sig-paren">(</span><em>dbg</em>, <em>exception</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.FunctionBP.trigger" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when breakpoint is hit</p>
</dd></dl>
</dd></dl>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">See sample <a class="reference internal" href="sample.html#sample-debugger-bp-functionbp"><span class="std std-ref">windows.debug.FunctionBP</span></a></p>
</div>
</div>
<div class="section" id="module-windows.debug.symbols">
<span id="windows-debug-symbols-using-symbols"></span><span id="debug-symbols-module"></span><h2>9.5. <a class="reference internal" href="#module-windows.debug.symbols" title="windows.debug.symbols"><code class="xref py py-mod docutils literal notranslate"><span class="pre">windows.debug.symbols</span></code></a> – Using symbols<a class="headerlink" href="#module-windows.debug.symbols" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#module-windows.debug.symbols" title="windows.debug.symbols"><code class="xref py py-mod docutils literal notranslate"><span class="pre">windows.debug.symbols</span></code></a> module provide classes to load PDB and resolve name/address.
In its current state, this module does not handle types.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">See samples <a class="reference internal" href="sample.html#sample-symbols"><span class="std std-ref">Symbols</span></a></p>
</div>
<div class="section" id="configuration">
<h3>9.5.1. Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h3>
<p>In order to be able to automatically download PDB and parse remote <code class="docutils literal notranslate"><span class="pre">_NT_SYMBOL_PATH</span></code>, a debug version of the DLL <cite>dbghelp.dll</cite> must be used.
(See <a class="reference external" href="https://docs.microsoft.com/en-us/windows/win32/debug/dbghelp-versions">MSDN: DbgHelp Versions</a>)</p>
<p>As it is NOT recommended to replace <code class="docutils literal notranslate"><span class="pre">system32/dbghelp.dll</span></code>, its path must be provided to PythonForWindows.
This path must be provided before any call to the <code class="docutils literal notranslate"><span class="pre">dbghelp.dll</span></code> APIs.
Also, the <code class="docutils literal notranslate"><span class="pre">symsrv.dll</span></code> DLL should be present in the same directory as <code class="docutils literal notranslate"><span class="pre">dbghelp.dll</span></code> (See <a class="reference external" href="https://docs.microsoft.com/en-us/windows/win32/debug/using-symsrv#installation">SymSrv Installation</a>)</p>
<p>There is 2 ways to pass this information to <code class="docutils literal notranslate"><span class="pre">PythonForWindows</span></code>:</p>
<blockquote>
<div><ul class="simple">
<li>Using the function <a class="reference internal" href="#windows.debug.symbols.set_dbghelp_path" title="windows.debug.symbols.set_dbghelp_path"><code class="xref py py-func docutils literal notranslate"><span class="pre">set_dbghelp_path()</span></code></a></li>
<li><dl class="first docutils">
<dt>Using the environment variable <code class="docutils literal notranslate"><span class="pre">PFW_DBGHELP_PATH</span></code></dt>
<dd><ul class="first last">
<li>If this variable exists it will simply trigger a call to <code class="docutils literal notranslate"><span class="pre">set_dbghelp_path(PFW_DBGHELP_PATH)</span></code></li>
</ul>
</dd>
</dl>
</li>
</ul>
</div></blockquote>
<p>If the given path is a directory, the final path will be computer as <code class="docutils literal notranslate"><span class="pre">path\<current_process_bitness>\dbghelp.dll</span></code>.
This allow to use the same script (or environment variable) transparently in bot 32b & 64b python interpreters.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>For example, on my computer my setup is done through the environment variable: <code class="docutils literal notranslate"><span class="pre">PFW_DBGHELP_PATH=D:\pysym\bin</span></code></p>
<p>This directory have the following layout:</p>
<blockquote class="last">
<div><div class="line-block">
<div class="line">$ tree /A /F %PFW_DBGHELP_PATH%</div>
<div class="line-block">
<div class="line">D:\PYSYM\BIN</div>
<div class="line">| symsrv.yes</div>
<div class="line">|</div>
<div class="line">+---32</div>
<div class="line">| dbghelp.dll</div>
<div class="line">| symsrv.dll</div>
<div class="line">|</div>
<div class="line">\---64</div>
<div class="line-block">
<div class="line">dbghelp.dll</div>
<div class="line">symsrv.dll</div>
</div>
</div>
</div>
</div></blockquote>
</div>
</div>
<div class="section" id="helpers">
<h3>9.5.2. Helpers<a class="headerlink" href="#helpers" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="windows.debug.symbols.set_dbghelp_path">
<code class="descclassname">windows.debug.symbols.</code><code class="descname">set_dbghelp_path</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/symbols.html#set_dbghelp_path"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.symbols.set_dbghelp_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the path of the <code class="docutils literal notranslate"><span class="pre">dbghelp.dll</span></code> file to use. It allow to configure a different version of the DLL handling PDB downloading.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">path</span></code> is a directory, the final <code class="docutils literal notranslate"><span class="pre">dbghelp.dll</span></code> will be computed as
<code class="docutils literal notranslate"><span class="pre">path\<current_process_bitness>\dbghelp.dll</span></code>.</p>
<p>This allow to use the same script transparently in both 32b & 64b python interpreters.</p>
</dd></dl>
<dl class="class">
<dt id="windows.debug.symbols.SymbolEngine">
<em class="property">class </em><code class="descclassname">windows.debug.symbols.</code><code class="descname">SymbolEngine</code><a class="reference internal" href="_modules/windows/debug/symbols.html#SymbolEngine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.symbols.SymbolEngine" title="Permalink to this definition">¶</a></dt>
<dd><p>Represent the global symbol engine. Just a proxy to get/set global engine options</p>
<p>Its instance can be accessed using <code class="docutils literal notranslate"><span class="pre">windows.debug.symbols.engine</span></code></p>
<p>Exemple:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">windows</span><span class="o">.</span><span class="n">debug</span><span class="o">.</span><span class="n">symbols</span><span class="o">.</span><span class="n">engine</span><span class="o">.</span><span class="n">options</span>
<span class="go">6L</span>
<span class="gp">>>> </span><span class="n">windows</span><span class="o">.</span><span class="n">debug</span><span class="o">.</span><span class="n">symbols</span><span class="o">.</span><span class="n">engine</span><span class="o">.</span><span class="n">options</span> <span class="o">=</span> <span class="n">gdef</span><span class="o">.</span><span class="n">SYMOPT_UNDNAME</span>
<span class="gp">>>> </span><span class="n">windows</span><span class="o">.</span><span class="n">debug</span><span class="o">.</span><span class="n">symbols</span><span class="o">.</span><span class="n">engine</span><span class="o">.</span><span class="n">options</span>
<span class="go">2L</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="windows.debug.symbols.SymbolEngine.options">
<code class="descname">options</code><a class="headerlink" href="#windows.debug.symbols.SymbolEngine.options" title="Permalink to this definition">¶</a></dt>
<dd><p>The options of the Symbol engine
(<a class="reference external" href="https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetoptions#parameters">see options</a>)</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Default options are: <code class="docutils literal notranslate"><span class="pre">gdef.SYMOPT_DEFERRED_LOADS</span> <span class="pre">+</span> <span class="pre">gdef.SYMOPT_UNDNAME</span></code></p>
</div>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="virtualsymbolhandler">
<h3>9.5.3. <a class="reference internal" href="#windows.debug.symbols.VirtualSymbolHandler" title="windows.debug.symbols.VirtualSymbolHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">VirtualSymbolHandler</span></code></a><a class="headerlink" href="#virtualsymbolhandler" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="windows.debug.symbols.VirtualSymbolHandler">
<em class="property">class </em><code class="descclassname">windows.debug.symbols.</code><code class="descname">VirtualSymbolHandler</code><span class="sig-paren">(</span><em>search_path=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/symbols.html#VirtualSymbolHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">windows.debug.symbols.SymbolHandler</span></code></p>
<p>A SymbolHandler where its handle is not a valid process handle
Allow to create/resolve symbol in a ‘virtual’ process
But all API needing a real process handle will fail</p>
<dl class="method">
<dt id="windows.debug.symbols.VirtualSymbolHandler.__getitem__">
<code class="descname">__getitem__</code><span class="sig-paren">(</span><em>name_or_addr</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.__getitem__" title="Permalink to this definition">¶</a></dt>
<dd><p>Resolve <code class="docutils literal notranslate"><span class="pre">name_or_addr</span></code>.</p>
<p>If its an int -> Return the <a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a> at the address.
If its a string -> Return the <a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a> corresponding to the symbol name</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a></td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal notranslate"><span class="pre">__getitem__</span></code> is an alias for <code class="docutils literal notranslate"><span class="pre">resolve()</span></code></p>
</div>
<p>Exemple:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">sh</span> <span class="o">=</span> <span class="n">windows</span><span class="o">.</span><span class="n">debug</span><span class="o">.</span><span class="n">symbols</span><span class="o">.</span><span class="n">VirtualSymbolHandler</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">mod</span> <span class="o">=</span> <span class="n">sh</span><span class="o">.</span><span class="n">load_file</span><span class="p">(</span><span class="sa">r</span><span class="s2">"c:\windows\system32\kernelbase.dll"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">mod</span>
<span class="go"><SymbolModule name="kernelbase" type=SymPdb pdb="wkernelbase.pdb" addr=0x10000000></span>
<span class="gp">>>> </span><span class="n">sh</span><span class="o">.</span><span class="n">resolve</span><span class="p">(</span><span class="s2">"kernelbase!CreateFileInternal"</span><span class="p">)</span>
<span class="go"><SymbolInfoA name="CreateFileInternal" addr=0x100f2120 tag=SymTagFunction></span>
<span class="gp">>>> </span><span class="n">sh</span><span class="p">[</span><span class="mh">0x100f2042</span><span class="p">]</span>
<span class="go"><SymbolInfoA name="ReadFile" addr=0x100f1ee0 displacement=0x162 tag=SymTagFunction></span>
<span class="gp">>>> </span><span class="nb">str</span><span class="p">(</span><span class="n">sh</span><span class="p">[</span><span class="mh">0x100f2042</span><span class="p">])</span>
<span class="go">'kernelbase!ReadFile+0x162'</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.VirtualSymbolHandler.load">
<code class="descname">load</code><span class="sig-paren">(</span><em>path</em>, <em>name=None</em>, <em>addr=0</em>, <em>size=0</em>, <em>data=None</em>, <em>flags=0</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.load" title="Permalink to this definition">¶</a></dt>
<dd><p>An alias for <a class="reference internal" href="#windows.debug.symbols.VirtualSymbolHandler.load_file" title="windows.debug.symbols.VirtualSymbolHandler.load_file"><code class="xref py py-func docutils literal notranslate"><span class="pre">VirtualSymbolHandler.load_file()</span></code></a></p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.VirtualSymbolHandler.load_file">
<code class="descname">load_file</code><span class="sig-paren">(</span><em>path</em>, <em>name=None</em>, <em>addr=0</em>, <em>size=0</em>, <em>data=None</em>, <em>flags=0</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.load_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Load the module <code class="docutils literal notranslate"><span class="pre">path</span></code> at <code class="docutils literal notranslate"><span class="pre">addr</span></code></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#windows.debug.symbols.SymbolModule" title="windows.debug.symbols.SymbolModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolModule</span></code></a> – The loaded module</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.VirtualSymbolHandler.load_module">
<code class="descname">load_module</code><span class="sig-paren">(</span><em>file_handle=None</em>, <em>path=None</em>, <em>name=None</em>, <em>addr=0</em>, <em>size=0</em>, <em>data=None</em>, <em>flags=0</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.load_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Load a module at a given <code class="docutils literal notranslate"><span class="pre">addr</span></code>. The module to load can be pass via a <code class="docutils literal notranslate"><span class="pre">file_handle</span></code>
or the direct <code class="docutils literal notranslate"><span class="pre">path</span></code> of the file to load.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#windows.debug.symbols.SymbolModule" title="windows.debug.symbols.SymbolModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolModule</span></code></a> – The loaded module</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The logic of <code class="docutils literal notranslate"><span class="pre">SymLoadModuleEx</span></code> seems somewhat strange about the naming of the loaded module.
A custom module <code class="docutils literal notranslate"><span class="pre">name</span></code> is only taken into account if the file is passed via a File handle.
To make it more intuitive, if this function is call with a <code class="docutils literal notranslate"><span class="pre">path</span></code> and <code class="docutils literal notranslate"><span class="pre">name</span></code> and no <code class="docutils literal notranslate"><span class="pre">file_handle</span></code>,
it will open the path and directly call <code class="docutils literal notranslate"><span class="pre">SymLoadModuleEx</span></code> with a file handle and a name.</p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="windows.debug.symbols.VirtualSymbolHandler.modules">
<code class="descname">modules</code><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.modules" title="Permalink to this definition">¶</a></dt>
<dd><p>The list of loaded modules</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">[<a class="reference internal" href="#windows.debug.symbols.SymbolModule" title="windows.debug.symbols.SymbolModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolModule</span></code></a>] – A list of modules</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.VirtualSymbolHandler.refresh">
<code class="descname">refresh</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/symbols.html#VirtualSymbolHandler.refresh"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.refresh" title="Permalink to this definition">¶</a></dt>
<dd><p>Do nothing for a <a class="reference internal" href="#windows.debug.symbols.VirtualSymbolHandler" title="windows.debug.symbols.VirtualSymbolHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">VirtualSymbolHandler</span></code></a></p>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.VirtualSymbolHandler.resolve">
<code class="descname">resolve</code><span class="sig-paren">(</span><em>name_or_addr</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.resolve" title="Permalink to this definition">¶</a></dt>
<dd><p>Resolve <code class="docutils literal notranslate"><span class="pre">name_or_addr</span></code>.</p>
<p>If its an int -> Return the <a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a> at the address.
If its a string -> Return the <a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a> corresponding to the symbol name</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a></td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal notranslate"><span class="pre">__getitem__</span></code> is an alias for <code class="docutils literal notranslate"><span class="pre">resolve()</span></code></p>
</div>
<p>Exemple:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">sh</span> <span class="o">=</span> <span class="n">windows</span><span class="o">.</span><span class="n">debug</span><span class="o">.</span><span class="n">symbols</span><span class="o">.</span><span class="n">VirtualSymbolHandler</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">mod</span> <span class="o">=</span> <span class="n">sh</span><span class="o">.</span><span class="n">load_file</span><span class="p">(</span><span class="sa">r</span><span class="s2">"c:\windows\system32\kernelbase.dll"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">mod</span>
<span class="go"><SymbolModule name="kernelbase" type=SymPdb pdb="wkernelbase.pdb" addr=0x10000000></span>
<span class="gp">>>> </span><span class="n">sh</span><span class="o">.</span><span class="n">resolve</span><span class="p">(</span><span class="s2">"kernelbase!CreateFileInternal"</span><span class="p">)</span>
<span class="go"><SymbolInfoA name="CreateFileInternal" addr=0x100f2120 tag=SymTagFunction></span>
<span class="gp">>>> </span><span class="n">sh</span><span class="p">[</span><span class="mh">0x100f2042</span><span class="p">]</span>
<span class="go"><SymbolInfoA name="ReadFile" addr=0x100f1ee0 displacement=0x162 tag=SymTagFunction></span>
<span class="gp">>>> </span><span class="nb">str</span><span class="p">(</span><span class="n">sh</span><span class="p">[</span><span class="mh">0x100f2042</span><span class="p">])</span>
<span class="go">'kernelbase!ReadFile+0x162'</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.VirtualSymbolHandler.search">
<code class="descname">search</code><span class="sig-paren">(</span><em>mask</em>, <em>mod=0</em>, <em>tag=0</em>, <em>options=SYMSEARCH_ALLITEMS(0x8)</em>, <em>callback=None</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.search" title="Permalink to this definition">¶</a></dt>
<dd><p>Search the symbols matching <code class="docutils literal notranslate"><span class="pre">mask</span></code> (<code class="docutils literal notranslate"><span class="pre">Windbg</span></code> like).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">[<a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a>] – A list of <a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a></td>
</tr>
</tbody>
</table>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">sh</span> <span class="o">=</span> <span class="n">windows</span><span class="o">.</span><span class="n">debug</span><span class="o">.</span><span class="n">symbols</span><span class="o">.</span><span class="n">VirtualSymbolHandler</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">mod</span> <span class="o">=</span> <span class="n">sh</span><span class="o">.</span><span class="n">load_file</span><span class="p">(</span><span class="sa">r</span><span class="s2">"c:\windows\system32\kernelbase.dll"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">sh</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="s2">"kernelbase!CreateFile*"</span><span class="p">)</span>
<span class="go">[<SymbolInfoA name="CreateFileInternal" addr=0x100f2120 tag=SymTagFunction>,</span>
<span class="go"> <SymbolInfoA name="CreateFileMoniker" addr=0x10117d80 tag=SymTagFunction>,</span>
<span class="go"> <SymbolInfoA name="CreateFile2" addr=0x1011e690 tag=SymTagFunction>,</span>
<span class="go"> ...]</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.VirtualSymbolHandler.unload">
<code class="descname">unload</code><span class="sig-paren">(</span><em>addr</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.VirtualSymbolHandler.unload" title="Permalink to this definition">¶</a></dt>
<dd><p>Unload the module at <code class="docutils literal notranslate"><span class="pre">addr</span></code></p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="processsymbolhandler">
<h3>9.5.4. <a class="reference internal" href="#windows.debug.symbols.ProcessSymbolHandler" title="windows.debug.symbols.ProcessSymbolHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">ProcessSymbolHandler</span></code></a><a class="headerlink" href="#processsymbolhandler" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="windows.debug.symbols.ProcessSymbolHandler">
<em class="property">class </em><code class="descclassname">windows.debug.symbols.</code><code class="descname">ProcessSymbolHandler</code><span class="sig-paren">(</span><em>process</em>, <em>search_path=None</em>, <em>invade_process=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/symbols.html#ProcessSymbolHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.symbols.ProcessSymbolHandler" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">windows.debug.symbols.SymbolHandler</span></code></p>
<dl class="method">
<dt id="windows.debug.symbols.ProcessSymbolHandler.__getitem__">
<code class="descname">__getitem__</code><span class="sig-paren">(</span><em>name_or_addr</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.ProcessSymbolHandler.__getitem__" title="Permalink to this definition">¶</a></dt>
<dd><p>Resolve <code class="docutils literal notranslate"><span class="pre">name_or_addr</span></code>.</p>
<p>If its an int -> Return the <a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a> at the address.
If its a string -> Return the <a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a> corresponding to the symbol name</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#windows.debug.symbols.SymbolInfo" title="windows.debug.symbols.SymbolInfo"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolInfo</span></code></a></td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><code class="docutils literal notranslate"><span class="pre">__getitem__</span></code> is an alias for <code class="docutils literal notranslate"><span class="pre">resolve()</span></code></p>
</div>
<p>Exemple:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">sh</span> <span class="o">=</span> <span class="n">windows</span><span class="o">.</span><span class="n">debug</span><span class="o">.</span><span class="n">symbols</span><span class="o">.</span><span class="n">VirtualSymbolHandler</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">mod</span> <span class="o">=</span> <span class="n">sh</span><span class="o">.</span><span class="n">load_file</span><span class="p">(</span><span class="sa">r</span><span class="s2">"c:\windows\system32\kernelbase.dll"</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">mod</span>
<span class="go"><SymbolModule name="kernelbase" type=SymPdb pdb="wkernelbase.pdb" addr=0x10000000></span>
<span class="gp">>>> </span><span class="n">sh</span><span class="o">.</span><span class="n">resolve</span><span class="p">(</span><span class="s2">"kernelbase!CreateFileInternal"</span><span class="p">)</span>
<span class="go"><SymbolInfoA name="CreateFileInternal" addr=0x100f2120 tag=SymTagFunction></span>
<span class="gp">>>> </span><span class="n">sh</span><span class="p">[</span><span class="mh">0x100f2042</span><span class="p">]</span>
<span class="go"><SymbolInfoA name="ReadFile" addr=0x100f1ee0 displacement=0x162 tag=SymTagFunction></span>
<span class="gp">>>> </span><span class="nb">str</span><span class="p">(</span><span class="n">sh</span><span class="p">[</span><span class="mh">0x100f2042</span><span class="p">])</span>
<span class="go">'kernelbase!ReadFile+0x162'</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.ProcessSymbolHandler.load">
<code class="descname">load</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/symbols.html#ProcessSymbolHandler.load"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.symbols.ProcessSymbolHandler.load" title="Permalink to this definition">¶</a></dt>
<dd><p>Load the <a class="reference internal" href="#windows.debug.symbols.SymbolModule" title="windows.debug.symbols.SymbolModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolModule</span></code></a> associated with the loaded module <code class="docutils literal notranslate"><span class="pre">name</span></code> (as found in the PEB)</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#windows.debug.symbols.SymbolModule" title="windows.debug.symbols.SymbolModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolModule</span></code></a></td>
</tr>
</tbody>
</table>
<p>Exemple:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">sh</span> <span class="o">=</span> <span class="n">windows</span><span class="o">.</span><span class="n">debug</span><span class="o">.</span><span class="n">symbols</span><span class="o">.</span><span class="n">ProcessSymbolHandler</span><span class="p">(</span><span class="n">windows</span><span class="o">.</span><span class="n">test</span><span class="o">.</span><span class="n">pop_proc_64</span><span class="p">())</span>
<span class="go"><windows.debug.symbols.ProcessSymbolHandler object at 0x033A2C30></span>
<span class="gp">>>> </span><span class="n">sh</span>
<span class="go"><windows.debug.symbols.ProcessSymbolHandler object at 0x033A2C30></span>
<span class="gp">>>> </span><span class="n">sh</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s2">"kernelbase.dll"</span><span class="p">)</span>
<span class="go"><SymbolModule name="kernelbase" type=SymDeferred pdb="" addr=0x7ffb5b090000></span>
<span class="gp">>>> </span><span class="n">sh</span><span class="p">[</span><span class="s2">"kernelbase!CreateProcessA"</span><span class="p">]</span>
<span class="go"><SymbolInfoA name="CreateProcessA" start=0x7ffb5b2371f0 tag=SymTagPublicSymbol></span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.ProcessSymbolHandler.load_file">
<code class="descname">load_file</code><span class="sig-paren">(</span><em>path</em>, <em>name=None</em>, <em>addr=0</em>, <em>size=0</em>, <em>data=None</em>, <em>flags=0</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.ProcessSymbolHandler.load_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Load the module <code class="docutils literal notranslate"><span class="pre">path</span></code> at <code class="docutils literal notranslate"><span class="pre">addr</span></code></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#windows.debug.symbols.SymbolModule" title="windows.debug.symbols.SymbolModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolModule</span></code></a> – The loaded module</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.ProcessSymbolHandler.load_module">
<code class="descname">load_module</code><span class="sig-paren">(</span><em>file_handle=None</em>, <em>path=None</em>, <em>name=None</em>, <em>addr=0</em>, <em>size=0</em>, <em>data=None</em>, <em>flags=0</em><span class="sig-paren">)</span><a class="headerlink" href="#windows.debug.symbols.ProcessSymbolHandler.load_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Load a module at a given <code class="docutils literal notranslate"><span class="pre">addr</span></code>. The module to load can be pass via a <code class="docutils literal notranslate"><span class="pre">file_handle</span></code>
or the direct <code class="docutils literal notranslate"><span class="pre">path</span></code> of the file to load.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#windows.debug.symbols.SymbolModule" title="windows.debug.symbols.SymbolModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolModule</span></code></a> – The loaded module</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The logic of <code class="docutils literal notranslate"><span class="pre">SymLoadModuleEx</span></code> seems somewhat strange about the naming of the loaded module.
A custom module <code class="docutils literal notranslate"><span class="pre">name</span></code> is only taken into account if the file is passed via a File handle.
To make it more intuitive, if this function is call with a <code class="docutils literal notranslate"><span class="pre">path</span></code> and <code class="docutils literal notranslate"><span class="pre">name</span></code> and no <code class="docutils literal notranslate"><span class="pre">file_handle</span></code>,
it will open the path and directly call <code class="docutils literal notranslate"><span class="pre">SymLoadModuleEx</span></code> with a file handle and a name.</p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="windows.debug.symbols.ProcessSymbolHandler.modules">
<code class="descname">modules</code><a class="headerlink" href="#windows.debug.symbols.ProcessSymbolHandler.modules" title="Permalink to this definition">¶</a></dt>
<dd><p>The list of loaded modules</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">[<a class="reference internal" href="#windows.debug.symbols.SymbolModule" title="windows.debug.symbols.SymbolModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">SymbolModule</span></code></a>] – A list of modules</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="windows.debug.symbols.ProcessSymbolHandler.refresh">
<code class="descname">refresh</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/windows/debug/symbols.html#ProcessSymbolHandler.refresh"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#windows.debug.symbols.ProcessSymbolHandler.refresh" title="Permalink to this definition">¶</a></dt>
<dd><p>Update the list of loaded modules to match the modules present in the target process</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>This function only call <a class="reference external" href="https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symrefreshmodulelist">SymRefreshModuleList</a> for now.
It seems that this function do not handle refreshing a 64b target from a 32b python</p>
<p class="last">Also, on a 32b target from a 64b python it seems to only load symbols for the 64b modules (ntdll + syswow dll)</p>