-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_attaching_8h.html
1292 lines (1250 loc) · 155 KB
/
_attaching_8h.html
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" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.11.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>HyperDbg Debugger: hyperdbg/hyperkd/header/debugger/user-level/Attaching.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">HyperDbg Debugger
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.11.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function(){initNavTree('_attaching_8h.html',''); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Classes</a> |
<a href="#define-members">Macros</a> |
<a href="#typedef-members">Typedefs</a> |
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">Attaching.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<p>Header for attaching and detaching for debugging user-mode processes.
<a href="#details">More...</a></p>
<p><a href="_attaching_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">_USERMODE_DEBUGGING_PROCESS_DETAILS</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Description of each active thread in user-mode attaching mechanism. <a href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a71a7b969b4769247f9e1c54276f6514f" id="r_a71a7b969b4769247f9e1c54276f6514f"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="#a71a7b969b4769247f9e1c54276f6514f">MAX_USER_ACTIONS_FOR_THREADS</a>   3</td></tr>
<tr class="memdesc:a71a7b969b4769247f9e1c54276f6514f"><td class="mdescLeft"> </td><td class="mdescRight">Maximum actions in paused threads storage. <br /></td></tr>
<tr class="separator:a71a7b969b4769247f9e1c54276f6514f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0c6e13c5d1c8b877d7e31b6f5065b1e3" id="r_a0c6e13c5d1c8b877d7e31b6f5065b1e3"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="#a0c6e13c5d1c8b877d7e31b6f5065b1e3">MAX_THREADS_IN_A_PROCESS_HOLDER</a>   100</td></tr>
<tr class="memdesc:a0c6e13c5d1c8b877d7e31b6f5065b1e3"><td class="mdescLeft"> </td><td class="mdescRight">Maximum threads that a process thread holder might have. <br /></td></tr>
<tr class="separator:a0c6e13c5d1c8b877d7e31b6f5065b1e3"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a829d27c9709ca2e1f18c2b8661652b41" id="r_a829d27c9709ca2e1f18c2b8661652b41"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="#a829d27c9709ca2e1f18c2b8661652b41">MAX_CR3_IN_A_PROCESS</a>   4</td></tr>
<tr class="memdesc:a829d27c9709ca2e1f18c2b8661652b41"><td class="mdescLeft"> </td><td class="mdescRight">Maximum number of CR3 registers that a process can have. <br /></td></tr>
<tr class="separator:a829d27c9709ca2e1f18c2b8661652b41"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ae69b85159349c201bde2de678d985193" id="r_ae69b85159349c201bde2de678d985193"><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">_USERMODE_DEBUGGING_PROCESS_DETAILS</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#ae69b85159349c201bde2de678d985193">USERMODE_DEBUGGING_PROCESS_DETAILS</a></td></tr>
<tr class="memdesc:ae69b85159349c201bde2de678d985193"><td class="mdescLeft"> </td><td class="mdescRight">Description of each active thread in user-mode attaching mechanism. <br /></td></tr>
<tr class="separator:ae69b85159349c201bde2de678d985193"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac289d6b25a670c70d1f6a5105788fb04" id="r_ac289d6b25a670c70d1f6a5105788fb04"><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">_USERMODE_DEBUGGING_PROCESS_DETAILS</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a></td></tr>
<tr class="separator:ac289d6b25a670c70d1f6a5105788fb04"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ac973601a8671bd7f982fb9f7fd13ccc4" id="r_ac973601a8671bd7f982fb9f7fd13ccc4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#ac973601a8671bd7f982fb9f7fd13ccc4">AttachingInitialize</a> ()</td></tr>
<tr class="memdesc:ac973601a8671bd7f982fb9f7fd13ccc4"><td class="mdescLeft"> </td><td class="mdescRight">Initialize the attaching mechanism. <br /></td></tr>
<tr class="separator:ac973601a8671bd7f982fb9f7fd13ccc4"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:af709328759d9b5fb6d0213ee458723dd" id="r_af709328759d9b5fb6d0213ee458723dd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#af709328759d9b5fb6d0213ee458723dd">AttachingCheckPageFaultsWithUserDebugger</a> (<a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> CoreId, <a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> <a class="el" href="_hyper_dbg_script_imports_8h.html#a3f7c5b71d899e923be0a80d4ac7902fe">Address</a>, <a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> PageFaultErrorCode)</td></tr>
<tr class="memdesc:af709328759d9b5fb6d0213ee458723dd"><td class="mdescLeft"> </td><td class="mdescRight">Check page-faults with user-debugger. <br /></td></tr>
<tr class="separator:af709328759d9b5fb6d0213ee458723dd"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7f67611f7474cb9199c0b941fcf82a85" id="r_a7f67611f7474cb9199c0b941fcf82a85"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#a7f67611f7474cb9199c0b941fcf82a85">AttachingConfigureInterceptingThreads</a> (<a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> ProcessDebuggingToken, <a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> Enable)</td></tr>
<tr class="memdesc:a7f67611f7474cb9199c0b941fcf82a85"><td class="mdescLeft"> </td><td class="mdescRight">Enable or disable the thread intercepting phase. <br /></td></tr>
<tr class="separator:a7f67611f7474cb9199c0b941fcf82a85"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a2a634f245bfc5d1ce07e9df31f37f26a" id="r_a2a634f245bfc5d1ce07e9df31f37f26a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#a2a634f245bfc5d1ce07e9df31f37f26a">AttachingHandleCr3VmexitsForThreadInterception</a> (<a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> CoreId, <a class="el" href="_basic_types_8h.html#aaeec30724d8f0c9d2acd894f41ee06fe">CR3_TYPE</a> NewCr3)</td></tr>
<tr class="memdesc:a2a634f245bfc5d1ce07e9df31f37f26a"><td class="mdescLeft"> </td><td class="mdescRight">Handle the cr3 vm-exits for thread interception. <br /></td></tr>
<tr class="separator:a2a634f245bfc5d1ce07e9df31f37f26a"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a6fba37d8db6966c26c921887bcf11656" id="r_a6fba37d8db6966c26c921887bcf11656"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a7f319bfc2492a2136964194204e7a8cf">VOID</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#a6fba37d8db6966c26c921887bcf11656">AttachingTargetProcess</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> Request)</td></tr>
<tr class="memdesc:a6fba37d8db6966c26c921887bcf11656"><td class="mdescLeft"> </td><td class="mdescRight">Dispatch and perform attaching tasks. <br /></td></tr>
<tr class="separator:a6fba37d8db6966c26c921887bcf11656"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:adadde19c6465b57b781fff52e7f8db85" id="r_adadde19c6465b57b781fff52e7f8db85"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a7f319bfc2492a2136964194204e7a8cf">VOID</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#adadde19c6465b57b781fff52e7f8db85">AttachingHandleEntrypointInterception</a> (<a class="el" href="hyperkd_2header_2debugger_2core_2_state_8h.html#aa35afece6adc9a29a7bf7a2e76476037">PROCESSOR_DEBUGGING_STATE</a> *DbgState)</td></tr>
<tr class="memdesc:adadde19c6465b57b781fff52e7f8db85"><td class="mdescLeft"> </td><td class="mdescRight">Handle the interception of finding the entrypoint on attaching to user-mode process. <br /></td></tr>
<tr class="separator:adadde19c6465b57b781fff52e7f8db85"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ad16b106f9f7b6a857bafc12252bcfadd" id="r_ad16b106f9f7b6a857bafc12252bcfadd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a7f319bfc2492a2136964194204e7a8cf">VOID</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#ad16b106f9f7b6a857bafc12252bcfadd">AttachingRemoveAndFreeAllProcessDebuggingDetails</a> ()</td></tr>
<tr class="memdesc:ad16b106f9f7b6a857bafc12252bcfadd"><td class="mdescLeft"> </td><td class="mdescRight">Remove and deallocate all thread debuggig details. <br /></td></tr>
<tr class="separator:ad16b106f9f7b6a857bafc12252bcfadd"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab826f65586e0a294b97e505c6affe8b5" id="r_ab826f65586e0a294b97e505c6affe8b5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#ab826f65586e0a294b97e505c6affe8b5">AttachingFindProcessDebuggingDetailsByToken</a> (<a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> Token)</td></tr>
<tr class="memdesc:ab826f65586e0a294b97e505c6affe8b5"><td class="mdescLeft"> </td><td class="mdescRight">Find user-mode debugging details for threads by token. <br /></td></tr>
<tr class="separator:ab826f65586e0a294b97e505c6affe8b5"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a733d0f343ddcccaeec221bbbb20483c7" id="r_a733d0f343ddcccaeec221bbbb20483c7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#a733d0f343ddcccaeec221bbbb20483c7">AttachingFindProcessDebuggingDetailsByProcessId</a> (<a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> ProcessId)</td></tr>
<tr class="memdesc:a733d0f343ddcccaeec221bbbb20483c7"><td class="mdescLeft"> </td><td class="mdescRight">Find user-mode debugging details for threads by process Id. <br /></td></tr>
<tr class="separator:a733d0f343ddcccaeec221bbbb20483c7"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a640e936614ebe9a68cf54e78f7d8f323" id="r_a640e936614ebe9a68cf54e78f7d8f323"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#a640e936614ebe9a68cf54e78f7d8f323">AttachingQueryDetailsOfActiveDebuggingThreadsAndProcesses</a> (PVOID BufferToStoreDetails, <a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> BufferSize)</td></tr>
<tr class="memdesc:a640e936614ebe9a68cf54e78f7d8f323"><td class="mdescLeft"> </td><td class="mdescRight">Query details of active debugging threads. <br /></td></tr>
<tr class="separator:a640e936614ebe9a68cf54e78f7d8f323"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:af92565f7d626021eb2e7312480126fa5" id="r_af92565f7d626021eb2e7312480126fa5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#af92565f7d626021eb2e7312480126fa5">AttachingCheckUnhandledEptViolation</a> (<a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> CoreId, <a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> ViolationQualification, <a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> GuestPhysicalAddr)</td></tr>
<tr class="memdesc:af92565f7d626021eb2e7312480126fa5"><td class="mdescLeft"> </td><td class="mdescRight">handling unhandled EPT violations <br /></td></tr>
<tr class="separator:af92565f7d626021eb2e7312480126fa5"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:afb4b04c662929a9dc3b74b45b634aff4" id="r_afb4b04c662929a9dc3b74b45b634aff4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#afb4b04c662929a9dc3b74b45b634aff4">AttachingReachedToValidLoadedModule</a> (<a class="el" href="hyperkd_2header_2debugger_2core_2_state_8h.html#aa35afece6adc9a29a7bf7a2e76476037">PROCESSOR_DEBUGGING_STATE</a> *DbgState, <a class="el" href="#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> ProcessDebuggingDetail)</td></tr>
<tr class="memdesc:afb4b04c662929a9dc3b74b45b634aff4"><td class="mdescLeft"> </td><td class="mdescRight">Handle cases where we reached to the valid loaded module The main module should be loaded once we reach to this function. <br /></td></tr>
<tr class="separator:afb4b04c662929a9dc3b74b45b634aff4"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Header for attaching and detaching for debugging user-mode processes. </p>
<dl class="section author"><dt>Author</dt><dd>Sina Karvandi (<a href="#" onclick="location.href='mai'+'lto:'+'sin'+'a@'+'hyp'+'er'+'dbg'+'.o'+'rg'; return false;">sina@<span class="obfuscator">.nosp@m.</span>hype<span class="obfuscator">.nosp@m.</span>rdbg.<span class="obfuscator">.nosp@m.</span>org</a>)</dd></dl>
<dl class="section version"><dt>Version</dt><dd>0.1 </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2021-12-28</dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>This project is released under the GNU Public License v3. </dd></dl>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a829d27c9709ca2e1f18c2b8661652b41" name="a829d27c9709ca2e1f18c2b8661652b41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a829d27c9709ca2e1f18c2b8661652b41">◆ </a></span>MAX_CR3_IN_A_PROCESS</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MAX_CR3_IN_A_PROCESS   4</td>
</tr>
</table>
</div><div class="memdoc">
<p>Maximum number of CR3 registers that a process can have. </p>
<p>Generally, a process has one cr3 but after meltdown KPTI another Cr3 is added and separated the kernel and user CR3s, recently I've noticed from a tweet from Petr Benes that there might be other cr3s <a href="https://twitter.com/PetrBenes/status/1310642455352672257?s=20">https://twitter.com/PetrBenes/status/1310642455352672257?s=20</a> So, I assume two extra cr3 for each process </p>
</div>
</div>
<a id="a0c6e13c5d1c8b877d7e31b6f5065b1e3" name="a0c6e13c5d1c8b877d7e31b6f5065b1e3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0c6e13c5d1c8b877d7e31b6f5065b1e3">◆ </a></span>MAX_THREADS_IN_A_PROCESS_HOLDER</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MAX_THREADS_IN_A_PROCESS_HOLDER   100</td>
</tr>
</table>
</div><div class="memdoc">
<p>Maximum threads that a process thread holder might have. </p>
</div>
</div>
<a id="a71a7b969b4769247f9e1c54276f6514f" name="a71a7b969b4769247f9e1c54276f6514f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a71a7b969b4769247f9e1c54276f6514f">◆ </a></span>MAX_USER_ACTIONS_FOR_THREADS</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MAX_USER_ACTIONS_FOR_THREADS   3</td>
</tr>
</table>
</div><div class="memdoc">
<p>Maximum actions in paused threads storage. </p>
</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="ac289d6b25a670c70d1f6a5105788fb04" name="ac289d6b25a670c70d1f6a5105788fb04"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac289d6b25a670c70d1f6a5105788fb04">◆ </a></span>PUSERMODE_DEBUGGING_PROCESS_DETAILS</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef struct <a class="el" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">_USERMODE_DEBUGGING_PROCESS_DETAILS</a> * <a class="el" href="#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="ae69b85159349c201bde2de678d985193" name="ae69b85159349c201bde2de678d985193"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae69b85159349c201bde2de678d985193">◆ </a></span>USERMODE_DEBUGGING_PROCESS_DETAILS</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef struct <a class="el" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">_USERMODE_DEBUGGING_PROCESS_DETAILS</a> <a class="el" href="#ae69b85159349c201bde2de678d985193">USERMODE_DEBUGGING_PROCESS_DETAILS</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>Description of each active thread in user-mode attaching mechanism. </p>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="af709328759d9b5fb6d0213ee458723dd" name="af709328759d9b5fb6d0213ee458723dd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af709328759d9b5fb6d0213ee458723dd">◆ </a></span>AttachingCheckPageFaultsWithUserDebugger()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> AttachingCheckPageFaultsWithUserDebugger </td>
<td>(</td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a></td> <td class="paramname"><span class="paramname"><em>CoreId</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a></td> <td class="paramname"><span class="paramname"><em>Address</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a></td> <td class="paramname"><span class="paramname"><em>PageFaultErrorCode</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Check page-faults with user-debugger. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">CoreId</td><td></td></tr>
<tr><td class="paramname">Address</td><td></td></tr>
<tr><td class="paramname">PageFaultErrorCode</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>BOOLEAN if TRUE show that the page-fault injection should be ignored </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 624</span>{</div>
<div class="line"><span class="lineno"> 625</span> UNREFERENCED_PARAMETER(<a class="code hl_variable" href="_hyper_dbg_script_imports_8h.html#a3f7c5b71d899e923be0a80d4ac7902fe">Address</a>);</div>
<div class="line"><span class="lineno"> 626</span> UNREFERENCED_PARAMETER(PageFaultErrorCode);</div>
<div class="line"><span class="lineno"> 627</span> </div>
<div class="line"><span class="lineno"> 628</span> <a class="code hl_struct" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> ProcessDebuggingDetail;</div>
<div class="line"><span class="lineno"> 629</span> <a class="code hl_struct" href="struct___p_r_o_c_e_s_s_o_r___d_e_b_u_g_g_i_n_g___s_t_a_t_e.html">PROCESSOR_DEBUGGING_STATE</a> * DbgState = &<a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#a349ee1adc363d2e4323a35a68fae5646">g_DbgState</a>[CoreId];</div>
<div class="line"><span class="lineno"> 630</span> </div>
<div class="line"><span class="lineno"> 631</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 632</span> <span class="comment">// Check whether user-debugger is initialized or not</span></div>
<div class="line"><span class="lineno"> 633</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 634</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#ae304ded1a8cbb4e772d97aec7510c9d2">g_UserDebuggerState</a> == <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>)</div>
<div class="line"><span class="lineno"> 635</span> {</div>
<div class="line"><span class="lineno"> 636</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 637</span> }</div>
<div class="line"><span class="lineno"> 638</span> </div>
<div class="line"><span class="lineno"> 639</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 640</span> <span class="comment">// Check if thread is in user-mode</span></div>
<div class="line"><span class="lineno"> 641</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 642</span> <span class="keywordflow">if</span> (<a class="code hl_function" href="_export_8c.html#ab49740d6ce5d1c5f90828b66496dcb4c">VmFuncGetLastVmexitRip</a>(CoreId) & 0xf000000000000000)</div>
<div class="line"><span class="lineno"> 643</span> {</div>
<div class="line"><span class="lineno"> 644</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 645</span> <span class="comment">// We won't intercept threads in kernel-mode</span></div>
<div class="line"><span class="lineno"> 646</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 647</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 648</span> }</div>
<div class="line"><span class="lineno"> 649</span> </div>
<div class="line"><span class="lineno"> 650</span> ProcessDebuggingDetail = <a class="code hl_function" href="_attaching_8c.html#a733d0f343ddcccaeec221bbbb20483c7">AttachingFindProcessDebuggingDetailsByProcessId</a>(<a class="code hl_define" href="_meta_macros_8h.html#ad790279846c85a5a453f2e7a4e02abad">HANDLE_TO_UINT32</a>(PsGetCurrentProcessId()));</div>
<div class="line"><span class="lineno"> 651</span> </div>
<div class="line"><span class="lineno"> 652</span> <span class="keywordflow">if</span> (!ProcessDebuggingDetail)</div>
<div class="line"><span class="lineno"> 653</span> {</div>
<div class="line"><span class="lineno"> 654</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 655</span> <span class="comment">// not related to user debugger</span></div>
<div class="line"><span class="lineno"> 656</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 657</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 658</span> }</div>
<div class="line"><span class="lineno"> 659</span> </div>
<div class="line"><span class="lineno"> 660</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 661</span> <span class="comment">// Check if thread is in intercepting phase</span></div>
<div class="line"><span class="lineno"> 662</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 663</span> <span class="keywordflow">if</span> (ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#ad3d6574cef84c00d549493d88c62e68f">IsOnThreadInterceptingPhase</a>)</div>
<div class="line"><span class="lineno"> 664</span> {</div>
<div class="line"><span class="lineno"> 665</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 666</span> <span class="comment">// Handling state through the user-mode debugger</span></div>
<div class="line"><span class="lineno"> 667</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 668</span> <a class="code hl_function" href="_ud_8c.html#a5ebe34618715108270c71344983e4af3">UdCheckAndHandleBreakpointsAndDebugBreaks</a>(DbgState,</div>
<div class="line"><span class="lineno"> 669</span> <a class="code hl_enumvalue" href="_connection_8h.html#a6e2be89205e735ebae644cf4850ac21ba1d3a5d418b8e74a9d4fae15b9db0f9cd">DEBUGGEE_PAUSING_REASON_DEBUGGEE_GENERAL_THREAD_INTERCEPTED</a>,</div>
<div class="line"><span class="lineno"> 670</span> NULL);</div>
<div class="line"><span class="lineno"> 671</span> </div>
<div class="line"><span class="lineno"> 672</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 673</span> <span class="comment">// related to user debugger</span></div>
<div class="line"><span class="lineno"> 674</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 675</span> <a class="code hl_function" href="_export_8c.html#ad357512be8732352fac0e4a03676e458">VmFuncSuppressRipIncrement</a>(CoreId);</div>
<div class="line"><span class="lineno"> 676</span> </div>
<div class="line"><span class="lineno"> 677</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;</div>
<div class="line"><span class="lineno"> 678</span> }</div>
<div class="line"><span class="lineno"> 679</span> </div>
<div class="line"><span class="lineno"> 680</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 681</span> <span class="comment">// this thread is not in intercepting phase</span></div>
<div class="line"><span class="lineno"> 682</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 683</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 684</span>}</div>
<div class="ttc" id="a_attaching_8c_html_a733d0f343ddcccaeec221bbbb20483c7"><div class="ttname"><a href="_attaching_8c.html#a733d0f343ddcccaeec221bbbb20483c7">AttachingFindProcessDebuggingDetailsByProcessId</a></div><div class="ttdeci">PUSERMODE_DEBUGGING_PROCESS_DETAILS AttachingFindProcessDebuggingDetailsByProcessId(UINT32 ProcessId)</div><div class="ttdoc">Find user-mode debugging details for threads by process Id.</div><div class="ttdef"><b>Definition</b> Attaching.c:187</div></div>
<div class="ttc" id="a_basic_types_8h_html_aa8cecfc5c5c054d2875c03e77b7be15d"><div class="ttname"><a href="_basic_types_8h.html#aa8cecfc5c5c054d2875c03e77b7be15d">TRUE</a></div><div class="ttdeci">#define TRUE</div><div class="ttdef"><b>Definition</b> BasicTypes.h:55</div></div>
<div class="ttc" id="a_basic_types_8h_html_aa93f0eb578d23995850d61f7d61c55c1"><div class="ttname"><a href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a></div><div class="ttdeci">#define FALSE</div><div class="ttdef"><b>Definition</b> BasicTypes.h:54</div></div>
<div class="ttc" id="a_connection_8h_html_a6e2be89205e735ebae644cf4850ac21ba1d3a5d418b8e74a9d4fae15b9db0f9cd"><div class="ttname"><a href="_connection_8h.html#a6e2be89205e735ebae644cf4850ac21ba1d3a5d418b8e74a9d4fae15b9db0f9cd">DEBUGGEE_PAUSING_REASON_DEBUGGEE_GENERAL_THREAD_INTERCEPTED</a></div><div class="ttdeci">@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_GENERAL_THREAD_INTERCEPTED</div><div class="ttdef"><b>Definition</b> Connection.h:42</div></div>
<div class="ttc" id="a_export_8c_html_ab49740d6ce5d1c5f90828b66496dcb4c"><div class="ttname"><a href="_export_8c.html#ab49740d6ce5d1c5f90828b66496dcb4c">VmFuncGetLastVmexitRip</a></div><div class="ttdeci">UINT64 VmFuncGetLastVmexitRip(UINT32 CoreId)</div><div class="ttdoc">get the last vm-exit RIP</div><div class="ttdef"><b>Definition</b> Export.c:318</div></div>
<div class="ttc" id="a_export_8c_html_ad357512be8732352fac0e4a03676e458"><div class="ttname"><a href="_export_8c.html#ad357512be8732352fac0e4a03676e458">VmFuncSuppressRipIncrement</a></div><div class="ttdeci">VOID VmFuncSuppressRipIncrement(UINT32 CoreId)</div><div class="ttdoc">Suppress the incrementation of RIP.</div><div class="ttdef"><b>Definition</b> Export.c:34</div></div>
<div class="ttc" id="a_hyper_dbg_script_imports_8h_html_a3f7c5b71d899e923be0a80d4ac7902fe"><div class="ttname"><a href="_hyper_dbg_script_imports_8h.html#a3f7c5b71d899e923be0a80d4ac7902fe">Address</a></div><div class="ttdeci">UINT64 Address</div><div class="ttdef"><b>Definition</b> HyperDbgScriptImports.h:67</div></div>
<div class="ttc" id="a_meta_macros_8h_html_ad790279846c85a5a453f2e7a4e02abad"><div class="ttname"><a href="_meta_macros_8h.html#ad790279846c85a5a453f2e7a4e02abad">HANDLE_TO_UINT32</a></div><div class="ttdeci">#define HANDLE_TO_UINT32(_var)</div><div class="ttdef"><b>Definition</b> MetaMacros.h:39</div></div>
<div class="ttc" id="a_ud_8c_html_a5ebe34618715108270c71344983e4af3"><div class="ttname"><a href="_ud_8c.html#a5ebe34618715108270c71344983e4af3">UdCheckAndHandleBreakpointsAndDebugBreaks</a></div><div class="ttdeci">BOOLEAN UdCheckAndHandleBreakpointsAndDebugBreaks(PROCESSOR_DEBUGGING_STATE *DbgState, DEBUGGEE_PAUSING_REASON Reason, PDEBUGGER_TRIGGERED_EVENT_DETAILS EventDetails)</div><div class="ttdoc">Handle #DBs and #BPs for kernel debugger.</div><div class="ttdef"><b>Definition</b> Ud.c:443</div></div>
<div class="ttc" id="ahyperkd_2header_2globals_2_global_8h_html_a349ee1adc363d2e4323a35a68fae5646"><div class="ttname"><a href="hyperkd_2header_2globals_2_global_8h.html#a349ee1adc363d2e4323a35a68fae5646">g_DbgState</a></div><div class="ttdeci">PROCESSOR_DEBUGGING_STATE * g_DbgState</div><div class="ttdoc">Save the state and variables related to debugging on each to logical core.</div><div class="ttdef"><b>Definition</b> Global.h:17</div></div>
<div class="ttc" id="ahyperkd_2header_2globals_2_global_8h_html_ae304ded1a8cbb4e772d97aec7510c9d2"><div class="ttname"><a href="hyperkd_2header_2globals_2_global_8h.html#ae304ded1a8cbb4e772d97aec7510c9d2">g_UserDebuggerState</a></div><div class="ttdeci">BOOLEAN g_UserDebuggerState</div><div class="ttdoc">shows whether the user debugger is enabled or disabled</div><div class="ttdef"><b>Definition</b> Global.h:109</div></div>
<div class="ttc" id="astruct___p_r_o_c_e_s_s_o_r___d_e_b_u_g_g_i_n_g___s_t_a_t_e_html"><div class="ttname"><a href="struct___p_r_o_c_e_s_s_o_r___d_e_b_u_g_g_i_n_g___s_t_a_t_e.html">_PROCESSOR_DEBUGGING_STATE</a></div><div class="ttdoc">Saves the debugger state.</div><div class="ttdef"><b>Definition</b> State.h:165</div></div>
<div class="ttc" id="astruct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s_html"><div class="ttname"><a href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">_USERMODE_DEBUGGING_PROCESS_DETAILS</a></div><div class="ttdoc">Description of each active thread in user-mode attaching mechanism.</div><div class="ttdef"><b>Definition</b> Attaching.h:49</div></div>
<div class="ttc" id="astruct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s_html_ad3d6574cef84c00d549493d88c62e68f"><div class="ttname"><a href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#ad3d6574cef84c00d549493d88c62e68f">_USERMODE_DEBUGGING_PROCESS_DETAILS::IsOnThreadInterceptingPhase</a></div><div class="ttdeci">BOOLEAN IsOnThreadInterceptingPhase</div><div class="ttdef"><b>Definition</b> Attaching.h:64</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="af92565f7d626021eb2e7312480126fa5" name="af92565f7d626021eb2e7312480126fa5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af92565f7d626021eb2e7312480126fa5">◆ </a></span>AttachingCheckUnhandledEptViolation()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> AttachingCheckUnhandledEptViolation </td>
<td>(</td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a></td> <td class="paramname"><span class="paramname"><em>CoreId</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a></td> <td class="paramname"><span class="paramname"><em>ViolationQualification</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a></td> <td class="paramname"><span class="paramname"><em>GuestPhysicalAddr</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>handling unhandled EPT violations </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">CoreId</td><td></td></tr>
<tr><td class="paramname">ViolationQualification</td><td></td></tr>
<tr><td class="paramname">GuestPhysicalAddr</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>BOOLEAN </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 1105</span>{</div>
<div class="line"><span class="lineno"> 1106</span> UNREFERENCED_PARAMETER(CoreId);</div>
<div class="line"><span class="lineno"> 1107</span> UNREFERENCED_PARAMETER(ViolationQualification);</div>
<div class="line"><span class="lineno"> 1108</span> UNREFERENCED_PARAMETER(GuestPhysicalAddr);</div>
<div class="line"><span class="lineno"> 1109</span> </div>
<div class="line"><span class="lineno"> 1110</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1111</span> <span class="comment">// Not handled here</span></div>
<div class="line"><span class="lineno"> 1112</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1113</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 1114</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a7f67611f7474cb9199c0b941fcf82a85" name="a7f67611f7474cb9199c0b941fcf82a85"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7f67611f7474cb9199c0b941fcf82a85">◆ </a></span>AttachingConfigureInterceptingThreads()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> AttachingConfigureInterceptingThreads </td>
<td>(</td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a></td> <td class="paramname"><span class="paramname"><em>ProcessDebuggingToken</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a></td> <td class="paramname"><span class="paramname"><em>Enable</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Enable or disable the thread intercepting phase. </p>
<p>this function should be called in vmx non-root</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ProcessDebuggingToken</td><td></td></tr>
<tr><td class="paramname">Enable</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>BOOLEAN </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 696</span>{</div>
<div class="line"><span class="lineno"> 697</span> <a class="code hl_struct" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> ProcessDebuggingDetail;</div>
<div class="line"><span class="lineno"> 698</span> </div>
<div class="line"><span class="lineno"> 699</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 700</span> <span class="comment">// Get the current process debugging detail</span></div>
<div class="line"><span class="lineno"> 701</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 702</span> ProcessDebuggingDetail = <a class="code hl_function" href="_attaching_8c.html#ab826f65586e0a294b97e505c6affe8b5">AttachingFindProcessDebuggingDetailsByToken</a>(ProcessDebuggingToken);</div>
<div class="line"><span class="lineno"> 703</span> </div>
<div class="line"><span class="lineno"> 704</span> <span class="keywordflow">if</span> (!ProcessDebuggingDetail)</div>
<div class="line"><span class="lineno"> 705</span> {</div>
<div class="line"><span class="lineno"> 706</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 707</span> }</div>
<div class="line"><span class="lineno"> 708</span> </div>
<div class="line"><span class="lineno"> 709</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 710</span> <span class="comment">// If the thread is already in intercepting phase, we should return,</span></div>
<div class="line"><span class="lineno"> 711</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 712</span> <span class="keywordflow">if</span> (Enable && ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#ad3d6574cef84c00d549493d88c62e68f">IsOnThreadInterceptingPhase</a>)</div>
<div class="line"><span class="lineno"> 713</span> {</div>
<div class="line"><span class="lineno"> 714</span> <a class="code hl_define" href="_hyper_dbg_hyper_log_intrinsics_8h.html#a459b19922fecfbb9438dd56b66930d16">LogError</a>(<span class="stringliteral">"Err, thread is already in intercepting phase"</span>);</div>
<div class="line"><span class="lineno"> 715</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 716</span> }</div>
<div class="line"><span class="lineno"> 717</span> </div>
<div class="line"><span class="lineno"> 718</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 719</span> <span class="comment">// if the user want to disable the intercepting phase, we just ignore the</span></div>
<div class="line"><span class="lineno"> 720</span> <span class="comment">// request without a message</span></div>
<div class="line"><span class="lineno"> 721</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 722</span> <span class="keywordflow">if</span> (!Enable && !ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#ad3d6574cef84c00d549493d88c62e68f">IsOnThreadInterceptingPhase</a>)</div>
<div class="line"><span class="lineno"> 723</span> {</div>
<div class="line"><span class="lineno"> 724</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 725</span> }</div>
<div class="line"><span class="lineno"> 726</span> </div>
<div class="line"><span class="lineno"> 727</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 728</span> <span class="comment">// We're or we're not in thread intercepting phase now</span></div>
<div class="line"><span class="lineno"> 729</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 730</span> ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#ad3d6574cef84c00d549493d88c62e68f">IsOnThreadInterceptingPhase</a> = Enable;</div>
<div class="line"><span class="lineno"> 731</span> </div>
<div class="line"><span class="lineno"> 732</span> <span class="keywordflow">if</span> (Enable)</div>
<div class="line"><span class="lineno"> 733</span> {</div>
<div class="line"><span class="lineno"> 734</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 735</span> <span class="comment">// Intercept all mov 2 cr3s</span></div>
<div class="line"><span class="lineno"> 736</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 737</span> <a class="code hl_function" href="_debugger_events_8c.html#a9fc0885a9799673255c0e61a4bf34a59">DebuggerEventEnableMovToCr3ExitingOnAllProcessors</a>();</div>
<div class="line"><span class="lineno"> 738</span> }</div>
<div class="line"><span class="lineno"> 739</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 740</span> {</div>
<div class="line"><span class="lineno"> 741</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 742</span> <span class="comment">// Removing the mov to cr3 vm-exits</span></div>
<div class="line"><span class="lineno"> 743</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 744</span> <a class="code hl_function" href="_debugger_events_8c.html#a29eb984baceb23c7c2a01cc947d4fe09">DebuggerEventDisableMovToCr3ExitingOnAllProcessors</a>();</div>
<div class="line"><span class="lineno"> 745</span> }</div>
<div class="line"><span class="lineno"> 746</span> </div>
<div class="line"><span class="lineno"> 747</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 748</span> <span class="comment">// Set the supervisor bit to 1 when we want to continue all the threads</span></div>
<div class="line"><span class="lineno"> 749</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 750</span> <span class="keywordflow">if</span> (!Enable)</div>
<div class="line"><span class="lineno"> 751</span> {</div>
<div class="line"><span class="lineno"> 752</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < <a class="code hl_define" href="#a829d27c9709ca2e1f18c2b8661652b41">MAX_CR3_IN_A_PROCESS</a>; i++)</div>
<div class="line"><span class="lineno"> 753</span> {</div>
<div class="line"><span class="lineno"> 754</span> <span class="keywordflow">if</span> (ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#a03824d851e6ed19772d65969892f267e">InterceptedCr3</a>[i].<a class="code hl_variable" href="struct___c_r3___t_y_p_e.html#a04eb96cc99b0458be739bcc9c640e08b">Flags</a> != (<a class="code hl_typedef" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a>)NULL)</div>
<div class="line"><span class="lineno"> 755</span> {</div>
<div class="line"><span class="lineno"> 756</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 757</span> <span class="comment">// This cr3 should not be intercepted on threads' user mode execution</span></div>
<div class="line"><span class="lineno"> 758</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 759</span> <span class="keywordflow">if</span> (!<a class="code hl_function" href="_memory_mapper_8c.html#ae48f36c16e0f72dfb25560c01b19423d">MemoryMapperSetSupervisorBitWithoutSwitchingByCr3</a>(NULL,</div>
<div class="line"><span class="lineno"> 760</span> <a class="code hl_define" href="_basic_types_8h.html#aa8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>,</div>
<div class="line"><span class="lineno"> 761</span> <a class="code hl_enumvalue" href="_data_types_8h.html#a0e279f80607c232e77080fd6ab7efb90a9f4053f14ec81e29707f1ec4cec0659e">PagingLevelPageMapLevel4</a>,</div>
<div class="line"><span class="lineno"> 762</span> ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#a03824d851e6ed19772d65969892f267e">InterceptedCr3</a>[i]))</div>
<div class="line"><span class="lineno"> 763</span> {</div>
<div class="line"><span class="lineno"> 764</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 765</span> }</div>
<div class="line"><span class="lineno"> 766</span> }</div>
<div class="line"><span class="lineno"> 767</span> }</div>
<div class="line"><span class="lineno"> 768</span> }</div>
<div class="line"><span class="lineno"> 769</span> </div>
<div class="line"><span class="lineno"> 770</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;</div>
<div class="line"><span class="lineno"> 771</span>}</div>
<div class="ttc" id="a_attaching_8c_html_ab826f65586e0a294b97e505c6affe8b5"><div class="ttname"><a href="_attaching_8c.html#ab826f65586e0a294b97e505c6affe8b5">AttachingFindProcessDebuggingDetailsByToken</a></div><div class="ttdeci">PUSERMODE_DEBUGGING_PROCESS_DETAILS AttachingFindProcessDebuggingDetailsByToken(UINT64 Token)</div><div class="ttdoc">Find user-mode debugging details for threads by token.</div><div class="ttdef"><b>Definition</b> Attaching.c:164</div></div>
<div class="ttc" id="a_attaching_8h_html_a829d27c9709ca2e1f18c2b8661652b41"><div class="ttname"><a href="#a829d27c9709ca2e1f18c2b8661652b41">MAX_CR3_IN_A_PROCESS</a></div><div class="ttdeci">#define MAX_CR3_IN_A_PROCESS</div><div class="ttdoc">Maximum number of CR3 registers that a process can have.</div><div class="ttdef"><b>Definition</b> Attaching.h:37</div></div>
<div class="ttc" id="a_basic_types_8h_html_aae17ebb9ef7279d026817fb22f8aebe9"><div class="ttname"><a href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a></div><div class="ttdeci">unsigned __int64 UINT64</div><div class="ttdef"><b>Definition</b> BasicTypes.h:21</div></div>
<div class="ttc" id="a_data_types_8h_html_a0e279f80607c232e77080fd6ab7efb90a9f4053f14ec81e29707f1ec4cec0659e"><div class="ttname"><a href="_data_types_8h.html#a0e279f80607c232e77080fd6ab7efb90a9f4053f14ec81e29707f1ec4cec0659e">PagingLevelPageMapLevel4</a></div><div class="ttdeci">@ PagingLevelPageMapLevel4</div><div class="ttdef"><b>Definition</b> DataTypes.h:28</div></div>
<div class="ttc" id="a_debugger_events_8c_html_a29eb984baceb23c7c2a01cc947d4fe09"><div class="ttname"><a href="_debugger_events_8c.html#a29eb984baceb23c7c2a01cc947d4fe09">DebuggerEventDisableMovToCr3ExitingOnAllProcessors</a></div><div class="ttdeci">VOID DebuggerEventDisableMovToCr3ExitingOnAllProcessors()</div><div class="ttdoc">routines for debugging threads (disable mov-to-cr3 exiting)</div><div class="ttdef"><b>Definition</b> DebuggerEvents.c:53</div></div>
<div class="ttc" id="a_debugger_events_8c_html_a9fc0885a9799673255c0e61a4bf34a59"><div class="ttname"><a href="_debugger_events_8c.html#a9fc0885a9799673255c0e61a4bf34a59">DebuggerEventEnableMovToCr3ExitingOnAllProcessors</a></div><div class="ttdeci">VOID DebuggerEventEnableMovToCr3ExitingOnAllProcessors()</div><div class="ttdoc">routines for debugging threads (enable mov-to-cr3 exiting)</div><div class="ttdef"><b>Definition</b> DebuggerEvents.c:42</div></div>
<div class="ttc" id="a_hyper_dbg_hyper_log_intrinsics_8h_html_a459b19922fecfbb9438dd56b66930d16"><div class="ttname"><a href="_hyper_dbg_hyper_log_intrinsics_8h.html#a459b19922fecfbb9438dd56b66930d16">LogError</a></div><div class="ttdeci">#define LogError(format,...)</div><div class="ttdoc">Log in the case of error.</div><div class="ttdef"><b>Definition</b> HyperDbgHyperLogIntrinsics.h:113</div></div>
<div class="ttc" id="a_memory_mapper_8c_html_ae48f36c16e0f72dfb25560c01b19423d"><div class="ttname"><a href="_memory_mapper_8c.html#ae48f36c16e0f72dfb25560c01b19423d">MemoryMapperSetSupervisorBitWithoutSwitchingByCr3</a></div><div class="ttdeci">_Use_decl_annotations_ BOOLEAN MemoryMapperSetSupervisorBitWithoutSwitchingByCr3(PVOID Va, BOOLEAN Set, PAGING_LEVEL Level, CR3_TYPE TargetCr3)</div><div class="ttdoc">This function the Supervisor bit of the target PTE based on the specific cr3.</div><div class="ttdef"><b>Definition</b> MemoryMapper.c:1697</div></div>
<div class="ttc" id="astruct___c_r3___t_y_p_e_html_a04eb96cc99b0458be739bcc9c640e08b"><div class="ttname"><a href="struct___c_r3___t_y_p_e.html#a04eb96cc99b0458be739bcc9c640e08b">_CR3_TYPE::Flags</a></div><div class="ttdeci">UINT64 Flags</div><div class="ttdef"><b>Definition</b> BasicTypes.h:133</div></div>
<div class="ttc" id="astruct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s_html_a03824d851e6ed19772d65969892f267e"><div class="ttname"><a href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#a03824d851e6ed19772d65969892f267e">_USERMODE_DEBUGGING_PROCESS_DETAILS::InterceptedCr3</a></div><div class="ttdeci">CR3_TYPE InterceptedCr3[MAX_CR3_IN_A_PROCESS]</div><div class="ttdef"><b>Definition</b> Attaching.h:66</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a733d0f343ddcccaeec221bbbb20483c7" name="a733d0f343ddcccaeec221bbbb20483c7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a733d0f343ddcccaeec221bbbb20483c7">◆ </a></span>AttachingFindProcessDebuggingDetailsByProcessId()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> AttachingFindProcessDebuggingDetailsByProcessId </td>
<td>(</td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a></td> <td class="paramname"><span class="paramname"><em>ProcessId</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Find user-mode debugging details for threads by process Id. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ProcessId</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>PUSERMODE_DEBUGGING_PROCESS_DETAILS </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 188</span>{</div>
<div class="line"><span class="lineno"> 189</span> <a class="code hl_define" href="_meta_macros_8h.html#ae6305b9ffbb1d946674b7b98431a67e9">LIST_FOR_EACH_LINK</a>(<a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#a3a003d2c59562062fe921cd2754440f7">g_ProcessDebuggingDetailsListHead</a>, <a class="code hl_struct" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">USERMODE_DEBUGGING_PROCESS_DETAILS</a>, AttachedProcessList, ProcessDebuggingDetails)</div>
<div class="line"><span class="lineno"> 190</span> {</div>
<div class="line"><span class="lineno"> 191</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 192</span> <span class="comment">// Check if we found the target thread and if it's enabled</span></div>
<div class="line"><span class="lineno"> 193</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 194</span> <span class="keywordflow">if</span> (ProcessDebuggingDetails->ProcessId == ProcessId && ProcessDebuggingDetails->Enabled)</div>
<div class="line"><span class="lineno"> 195</span> {</div>
<div class="line"><span class="lineno"> 196</span> <span class="keywordflow">return</span> ProcessDebuggingDetails;</div>
<div class="line"><span class="lineno"> 197</span> }</div>
<div class="line"><span class="lineno"> 198</span> }</div>
<div class="line"><span class="lineno"> 199</span> </div>
<div class="line"><span class="lineno"> 200</span> <span class="keywordflow">return</span> <a class="code hl_function" href="namespacetest-case-generator.html#a9a4eff80432bb93d2796381610dd86c3">NULL</a>;</div>
<div class="line"><span class="lineno"> 201</span>}</div>
<div class="ttc" id="a_meta_macros_8h_html_ae6305b9ffbb1d946674b7b98431a67e9"><div class="ttname"><a href="_meta_macros_8h.html#ae6305b9ffbb1d946674b7b98431a67e9">LIST_FOR_EACH_LINK</a></div><div class="ttdeci">#define LIST_FOR_EACH_LINK(_head, _struct_type, _member, _var)</div><div class="ttdef"><b>Definition</b> MetaMacros.h:34</div></div>
<div class="ttc" id="ahyperkd_2header_2globals_2_global_8h_html_a3a003d2c59562062fe921cd2754440f7"><div class="ttname"><a href="hyperkd_2header_2globals_2_global_8h.html#a3a003d2c59562062fe921cd2754440f7">g_ProcessDebuggingDetailsListHead</a></div><div class="ttdeci">LIST_ENTRY g_ProcessDebuggingDetailsListHead</div><div class="ttdoc">List header of thread debugging details.</div><div class="ttdef"><b>Definition</b> Global.h:152</div></div>
<div class="ttc" id="anamespacetest-case-generator_html_a9a4eff80432bb93d2796381610dd86c3"><div class="ttname"><a href="namespacetest-case-generator.html#a9a4eff80432bb93d2796381610dd86c3">test-case-generator.NULL</a></div><div class="ttdeci">NULL()</div><div class="ttdef"><b>Definition</b> test-case-generator.py:530</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="ab826f65586e0a294b97e505c6affe8b5" name="ab826f65586e0a294b97e505c6affe8b5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab826f65586e0a294b97e505c6affe8b5">◆ </a></span>AttachingFindProcessDebuggingDetailsByToken()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> AttachingFindProcessDebuggingDetailsByToken </td>
<td>(</td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a></td> <td class="paramname"><span class="paramname"><em>Token</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Find user-mode debugging details for threads by token. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">Token</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>PUSERMODE_DEBUGGING_PROCESS_DETAILS </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 165</span>{</div>
<div class="line"><span class="lineno"> 166</span> <a class="code hl_define" href="_meta_macros_8h.html#ae6305b9ffbb1d946674b7b98431a67e9">LIST_FOR_EACH_LINK</a>(<a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#a3a003d2c59562062fe921cd2754440f7">g_ProcessDebuggingDetailsListHead</a>, <a class="code hl_struct" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">USERMODE_DEBUGGING_PROCESS_DETAILS</a>, AttachedProcessList, ProcessDebuggingDetails)</div>
<div class="line"><span class="lineno"> 167</span> {</div>
<div class="line"><span class="lineno"> 168</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 169</span> <span class="comment">// Check if we found the target thread and if it's enabled</span></div>
<div class="line"><span class="lineno"> 170</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 171</span> <span class="keywordflow">if</span> (ProcessDebuggingDetails->Token == Token && ProcessDebuggingDetails->Enabled)</div>
<div class="line"><span class="lineno"> 172</span> {</div>
<div class="line"><span class="lineno"> 173</span> <span class="keywordflow">return</span> ProcessDebuggingDetails;</div>
<div class="line"><span class="lineno"> 174</span> }</div>
<div class="line"><span class="lineno"> 175</span> }</div>
<div class="line"><span class="lineno"> 176</span> </div>
<div class="line"><span class="lineno"> 177</span> <span class="keywordflow">return</span> <a class="code hl_function" href="namespacetest-case-generator.html#a9a4eff80432bb93d2796381610dd86c3">NULL</a>;</div>
<div class="line"><span class="lineno"> 178</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a2a634f245bfc5d1ce07e9df31f37f26a" name="a2a634f245bfc5d1ce07e9df31f37f26a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2a634f245bfc5d1ce07e9df31f37f26a">◆ </a></span>AttachingHandleCr3VmexitsForThreadInterception()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> AttachingHandleCr3VmexitsForThreadInterception </td>
<td>(</td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a></td> <td class="paramname"><span class="paramname"><em>CoreId</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#aaeec30724d8f0c9d2acd894f41ee06fe">CR3_TYPE</a></td> <td class="paramname"><span class="paramname"><em>NewCr3</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Handle the cr3 vm-exits for thread interception. </p>
<p>this function should be called in vmx-root</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">CoreId</td><td></td></tr>
<tr><td class="paramname">NewCr3</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>BOOLEAN </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 1037</span>{</div>
<div class="line"><span class="lineno"> 1038</span> <a class="code hl_struct" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> ProcessDebuggingDetail;</div>
<div class="line"><span class="lineno"> 1039</span> </div>
<div class="line"><span class="lineno"> 1040</span> ProcessDebuggingDetail = <a class="code hl_function" href="_attaching_8c.html#a733d0f343ddcccaeec221bbbb20483c7">AttachingFindProcessDebuggingDetailsByProcessId</a>(<a class="code hl_define" href="_meta_macros_8h.html#ad790279846c85a5a453f2e7a4e02abad">HANDLE_TO_UINT32</a>(PsGetCurrentProcessId()));</div>
<div class="line"><span class="lineno"> 1041</span> </div>
<div class="line"><span class="lineno"> 1042</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1043</span> <span class="comment">// Check if process is valid or if thread is in intercepting phase</span></div>
<div class="line"><span class="lineno"> 1044</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1045</span> <span class="keywordflow">if</span> (!ProcessDebuggingDetail || !ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#ad3d6574cef84c00d549493d88c62e68f">IsOnThreadInterceptingPhase</a>)</div>
<div class="line"><span class="lineno"> 1046</span> {</div>
<div class="line"><span class="lineno"> 1047</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1048</span> <span class="comment">// not related to user debugger</span></div>
<div class="line"><span class="lineno"> 1049</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1050</span> <a class="code hl_function" href="_export_8c.html#acabb4a88d5b23a655b48c81114c6779e">VmFuncUnsetExceptionBitmap</a>(CoreId, <a class="code hl_enumvalue" href="include_2_s_d_k_2_headers_2_events_8h.html#af9640e4f7e36f7a6bf7c56e30a860349a6a2e04f0e1552752bd9419a4019638a2">EXCEPTION_VECTOR_PAGE_FAULT</a>);</div>
<div class="line"><span class="lineno"> 1051</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 1052</span> }</div>
<div class="line"><span class="lineno"> 1053</span> </div>
<div class="line"><span class="lineno"> 1054</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1055</span> <span class="comment">// Save the cr3 for future continuing the thread</span></div>
<div class="line"><span class="lineno"> 1056</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1057</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < <a class="code hl_define" href="#a829d27c9709ca2e1f18c2b8661652b41">MAX_CR3_IN_A_PROCESS</a>; i++)</div>
<div class="line"><span class="lineno"> 1058</span> {</div>
<div class="line"><span class="lineno"> 1059</span> <span class="keywordflow">if</span> (ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#a03824d851e6ed19772d65969892f267e">InterceptedCr3</a>[i].<a class="code hl_variable" href="struct___c_r3___t_y_p_e.html#a04eb96cc99b0458be739bcc9c640e08b">Flags</a> == NewCr3.<a class="code hl_variable" href="struct___c_r3___t_y_p_e.html#a04eb96cc99b0458be739bcc9c640e08b">Flags</a>)</div>
<div class="line"><span class="lineno"> 1060</span> {</div>
<div class="line"><span class="lineno"> 1061</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1062</span> <span class="comment">// We found it saved previously, no need any further action</span></div>
<div class="line"><span class="lineno"> 1063</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1064</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 1065</span> }</div>
<div class="line"><span class="lineno"> 1066</span> </div>
<div class="line"><span class="lineno"> 1067</span> <span class="keywordflow">if</span> (ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#a03824d851e6ed19772d65969892f267e">InterceptedCr3</a>[i].<a class="code hl_variable" href="struct___c_r3___t_y_p_e.html#a04eb96cc99b0458be739bcc9c640e08b">Flags</a> == (<a class="code hl_typedef" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a>)NULL)</div>
<div class="line"><span class="lineno"> 1068</span> {</div>
<div class="line"><span class="lineno"> 1069</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1070</span> <span class="comment">// Save the cr3</span></div>
<div class="line"><span class="lineno"> 1071</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1072</span> ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#a03824d851e6ed19772d65969892f267e">InterceptedCr3</a>[i].<a class="code hl_variable" href="struct___c_r3___t_y_p_e.html#a04eb96cc99b0458be739bcc9c640e08b">Flags</a> = NewCr3.<a class="code hl_variable" href="struct___c_r3___t_y_p_e.html#a04eb96cc99b0458be739bcc9c640e08b">Flags</a>;</div>
<div class="line"><span class="lineno"> 1073</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 1074</span> }</div>
<div class="line"><span class="lineno"> 1075</span> }</div>
<div class="line"><span class="lineno"> 1076</span> </div>
<div class="line"><span class="lineno"> 1077</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1078</span> <span class="comment">// This thread should be intercepted</span></div>
<div class="line"><span class="lineno"> 1079</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1080</span> <span class="keywordflow">if</span> (!<a class="code hl_function" href="_memory_mapper_8c.html#ae48f36c16e0f72dfb25560c01b19423d">MemoryMapperSetSupervisorBitWithoutSwitchingByCr3</a>(NULL, <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>, <a class="code hl_enumvalue" href="_data_types_8h.html#a0e279f80607c232e77080fd6ab7efb90a9f4053f14ec81e29707f1ec4cec0659e">PagingLevelPageMapLevel4</a>, NewCr3))</div>
<div class="line"><span class="lineno"> 1081</span> {</div>
<div class="line"><span class="lineno"> 1082</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 1083</span> }</div>
<div class="line"><span class="lineno"> 1084</span> </div>
<div class="line"><span class="lineno"> 1085</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1086</span> <span class="comment">// Intercept #PFs</span></div>
<div class="line"><span class="lineno"> 1087</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1088</span> <a class="code hl_function" href="_export_8c.html#a837024687fafd5d17e1020eb6157923f">VmFuncSetExceptionBitmap</a>(CoreId, <a class="code hl_enumvalue" href="include_2_s_d_k_2_headers_2_events_8h.html#af9640e4f7e36f7a6bf7c56e30a860349a6a2e04f0e1552752bd9419a4019638a2">EXCEPTION_VECTOR_PAGE_FAULT</a>);</div>
<div class="line"><span class="lineno"> 1089</span> </div>
<div class="line"><span class="lineno"> 1090</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;</div>
<div class="line"><span class="lineno"> 1091</span>}</div>
<div class="ttc" id="a_export_8c_html_a837024687fafd5d17e1020eb6157923f"><div class="ttname"><a href="_export_8c.html#a837024687fafd5d17e1020eb6157923f">VmFuncSetExceptionBitmap</a></div><div class="ttdeci">VOID VmFuncSetExceptionBitmap(UINT32 CoreId, UINT32 IdtIndex)</div><div class="ttdoc">Set exception bitmap in VMCS.</div><div class="ttdef"><b>Definition</b> Export.c:253</div></div>
<div class="ttc" id="a_export_8c_html_acabb4a88d5b23a655b48c81114c6779e"><div class="ttname"><a href="_export_8c.html#acabb4a88d5b23a655b48c81114c6779e">VmFuncUnsetExceptionBitmap</a></div><div class="ttdeci">VOID VmFuncUnsetExceptionBitmap(UINT32 CoreId, UINT32 IdtIndex)</div><div class="ttdoc">Unset exception bitmap in VMCS.</div><div class="ttdef"><b>Definition</b> Export.c:267</div></div>
<div class="ttc" id="ainclude_2_s_d_k_2_headers_2_events_8h_html_af9640e4f7e36f7a6bf7c56e30a860349a6a2e04f0e1552752bd9419a4019638a2"><div class="ttname"><a href="include_2_s_d_k_2_headers_2_events_8h.html#af9640e4f7e36f7a6bf7c56e30a860349a6a2e04f0e1552752bd9419a4019638a2">EXCEPTION_VECTOR_PAGE_FAULT</a></div><div class="ttdeci">@ EXCEPTION_VECTOR_PAGE_FAULT</div><div class="ttdef"><b>Definition</b> Events.h:38</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="adadde19c6465b57b781fff52e7f8db85" name="adadde19c6465b57b781fff52e7f8db85"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adadde19c6465b57b781fff52e7f8db85">◆ </a></span>AttachingHandleEntrypointInterception()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_basic_types_8h.html#a7f319bfc2492a2136964194204e7a8cf">VOID</a> AttachingHandleEntrypointInterception </td>
<td>(</td>
<td class="paramtype"><a class="el" href="hyperkd_2header_2debugger_2core_2_state_8h.html#aa35afece6adc9a29a7bf7a2e76476037">PROCESSOR_DEBUGGING_STATE</a> *</td> <td class="paramname"><span class="paramname"><em>DbgState</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Handle the interception of finding the entrypoint on attaching to user-mode process. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">DbgState</td><td>The state of the debugger on the current core </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>VOID </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 437</span>{</div>
<div class="line"><span class="lineno"> 438</span> <a class="code hl_struct" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> ProcessDebuggingDetail = <a class="code hl_function" href="namespacetest-case-generator.html#a9a4eff80432bb93d2796381610dd86c3">NULL</a>;</div>
<div class="line"><span class="lineno"> 439</span> PAGE_FAULT_EXCEPTION PageFaultErrorCode = {0};</div>
<div class="line"><span class="lineno"> 440</span> </div>
<div class="line"><span class="lineno"> 441</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 442</span> <span class="comment">// Not increment the RIP register as no instruction is intended to go</span></div>
<div class="line"><span class="lineno"> 443</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 444</span> <a class="code hl_function" href="_export_8c.html#ad357512be8732352fac0e4a03676e458">VmFuncSuppressRipIncrement</a>(DbgState-><a class="code hl_variable" href="struct___p_r_o_c_e_s_s_o_r___d_e_b_u_g_g_i_n_g___s_t_a_t_e.html#a090832a74d330cde891a17bdd5b236e3">CoreId</a>);</div>
<div class="line"><span class="lineno"> 445</span> </div>
<div class="line"><span class="lineno"> 446</span> ProcessDebuggingDetail = <a class="code hl_function" href="_attaching_8c.html#a733d0f343ddcccaeec221bbbb20483c7">AttachingFindProcessDebuggingDetailsByProcessId</a>(<a class="code hl_define" href="_meta_macros_8h.html#ad790279846c85a5a453f2e7a4e02abad">HANDLE_TO_UINT32</a>(PsGetCurrentProcessId()));</div>
<div class="line"><span class="lineno"> 447</span> </div>
<div class="line"><span class="lineno"> 448</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 449</span> <span class="comment">// Check to only break on the target process id and thread id and when</span></div>
<div class="line"><span class="lineno"> 450</span> <span class="comment">// the entrypoint is not called, if the thread debugging detail is found</span></div>
<div class="line"><span class="lineno"> 451</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 452</span> <span class="keywordflow">if</span> (ProcessDebuggingDetail != NULL)</div>
<div class="line"><span class="lineno"> 453</span> {</div>
<div class="line"><span class="lineno"> 454</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#ae4b7e6d3d73fbc5e36dab0e432cfda0e">g_IsWaitingForUserModeProcessEntryToBeCalled</a>)</div>
<div class="line"><span class="lineno"> 455</span> {</div>
<div class="line"><span class="lineno"> 456</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 457</span> <span class="comment">// Show a message that we reached to the entrypoint</span></div>
<div class="line"><span class="lineno"> 458</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 459</span> <span class="comment">// Log("Reached to the main module entrypoint (%016llx)\n", VmFuncGetLastVmexitRip(DbgState->CoreId));</span></div>
<div class="line"><span class="lineno"> 460</span> </div>
<div class="line"><span class="lineno"> 461</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 462</span> <span class="comment">// Not waiting for these event anymore</span></div>
<div class="line"><span class="lineno"> 463</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 464</span> <a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#ae4b7e6d3d73fbc5e36dab0e432cfda0e">g_IsWaitingForUserModeProcessEntryToBeCalled</a> = <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 465</span> </div>
<div class="line"><span class="lineno"> 466</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 467</span> <span class="comment">// Whenever Windows calls the start entrypoint of the target PE, initially,</span></div>
<div class="line"><span class="lineno"> 468</span> <span class="comment">// the module is not loaded in the memory, thus a page-fault will happen and</span></div>
<div class="line"><span class="lineno"> 469</span> <span class="comment">// the page-fault handler will bring the module content to the memory and after</span></div>
<div class="line"><span class="lineno"> 470</span> <span class="comment">// that, the start entrypoint of PE is called again</span></div>
<div class="line"><span class="lineno"> 471</span> <span class="comment">// It's not possible for us to handle everything here without checking for the</span></div>
<div class="line"><span class="lineno"> 472</span> <span class="comment">// possible page-fault, it is because the first instruction is not available to be</span></div>
<div class="line"><span class="lineno"> 473</span> <span class="comment">// read from the memory, thus, it shows a wrong instruction and the user might not</span></div>
<div class="line"><span class="lineno"> 474</span> <span class="comment">// use the instrumentation step-in from the start up of the entrypoint.</span></div>
<div class="line"><span class="lineno"> 475</span> <span class="comment">// Because if the user uses the instrumentation step-in command then it should go</span></div>
<div class="line"><span class="lineno"> 476</span> <span class="comment">// the page-fault handler routine in the kernel and it's not what the user expects</span></div>
<div class="line"><span class="lineno"> 477</span> <span class="comment">// we inject a #PF here and let the Windows handle the page-fault. Meanwhile, we</span></div>
<div class="line"><span class="lineno"> 478</span> <span class="comment">// set the hardware debug breakpoint again at the start of the entrypoint, so, the</span></div>
<div class="line"><span class="lineno"> 479</span> <span class="comment">// next time that the instruction is about to be fetched, a vm-exit happens as a</span></div>
<div class="line"><span class="lineno"> 480</span> <span class="comment">// result of intercepting #DBs</span></div>
<div class="line"><span class="lineno"> 481</span> <span class="comment">// In some cases, there is no need to inject #PF to the guest. One example is when</span></div>
<div class="line"><span class="lineno"> 482</span> <span class="comment">// the target page is already available in the memory like the same process is also</span></div>
<div class="line"><span class="lineno"> 483</span> <span class="comment">// open in the debuggee. In these cases, we handle the break directly without injecting</span></div>
<div class="line"><span class="lineno"> 484</span> <span class="comment">// any page-fault</span></div>
<div class="line"><span class="lineno"> 485</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 486</span> </div>
<div class="line"><span class="lineno"> 487</span> <span class="keywordflow">if</span> (!<a class="code hl_function" href="_address_check_8c.html#aec71cec56c29db61a23b2997ee8e2059">CheckAccessValidityAndSafety</a>(ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#adb588665a0fa72d6307d6f8577f2f946">EntrypointOfMainModule</a>, <span class="keyword">sizeof</span>(<a class="code hl_typedef" href="_basic_types_8h.html#aebb9e13210d88d43e32e735ada43a425">CHAR</a>)))</div>
<div class="line"><span class="lineno"> 488</span> {</div>
<div class="line"><span class="lineno"> 489</span> <span class="comment">// LogInfo("Injecting #PF for entrypoint at : %llx", ProcessDebuggingDetail->EntrypointOfMainModule);</span></div>
<div class="line"><span class="lineno"> 490</span> </div>
<div class="line"><span class="lineno"> 491</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 492</span> <span class="comment">// We're waiting for this pointer to be called again after handling page-fault</span></div>
<div class="line"><span class="lineno"> 493</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 494</span> <a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#a0b03446aa090036e1c29277857de9596">g_IsWaitingForReturnAndRunFromPageFault</a> = <a class="code hl_define" href="_basic_types_8h.html#aa8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;</div>
<div class="line"><span class="lineno"> 495</span> </div>
<div class="line"><span class="lineno"> 496</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 497</span> <span class="comment">// Create page-fault error code (user, fetch #PF)</span></div>
<div class="line"><span class="lineno"> 498</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 499</span> PageFaultErrorCode.AsUInt = 0x14;</div>
<div class="line"><span class="lineno"> 500</span> </div>
<div class="line"><span class="lineno"> 501</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 502</span> <span class="comment">// Inject the page-fault</span></div>
<div class="line"><span class="lineno"> 503</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 504</span> <a class="code hl_function" href="_export_8c.html#ad4cb8e5eaaa79a648e0b82a1a7af295f">VmFuncEventInjectPageFaultWithCr2</a>(DbgState-><a class="code hl_variable" href="struct___p_r_o_c_e_s_s_o_r___d_e_b_u_g_g_i_n_g___s_t_a_t_e.html#a090832a74d330cde891a17bdd5b236e3">CoreId</a>,</div>
<div class="line"><span class="lineno"> 505</span> ProcessDebuggingDetail-><a class="code hl_variable" href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#adb588665a0fa72d6307d6f8577f2f946">EntrypointOfMainModule</a>,</div>
<div class="line"><span class="lineno"> 506</span> PageFaultErrorCode.AsUInt);</div>
<div class="line"><span class="lineno"> 507</span> </div>
<div class="line"><span class="lineno"> 508</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 509</span> <span class="comment">// Also, set the RFLAGS.TF to intercept the process (thread) again after inject #PF</span></div>
<div class="line"><span class="lineno"> 510</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 511</span> <a class="code hl_function" href="_export_8c.html#a8f68fa306b093e98466bd4f16cd16035">VmFuncSetRflagTrapFlag</a>(<a class="code hl_define" href="_basic_types_8h.html#aa8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>);</div>
<div class="line"><span class="lineno"> 512</span> </div>
<div class="line"><span class="lineno"> 513</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 514</span> <span class="comment">// Indicate that we should set the trap flag to the FALSE next time on</span></div>
<div class="line"><span class="lineno"> 515</span> <span class="comment">// the same process/thread</span></div>
<div class="line"><span class="lineno"> 516</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 517</span> <span class="keywordflow">if</span> (!<a class="code hl_function" href="_breakpoint_commands_8c.html#ac0e535f6d443deb15a20ffbf8e2252c6">BreakpointRestoreTheTrapFlagOnceTriggered</a>(<a class="code hl_define" href="_meta_macros_8h.html#ad790279846c85a5a453f2e7a4e02abad">HANDLE_TO_UINT32</a>(PsGetCurrentProcessId()), <a class="code hl_define" href="_meta_macros_8h.html#ad790279846c85a5a453f2e7a4e02abad">HANDLE_TO_UINT32</a>(PsGetCurrentThreadId())))</div>
<div class="line"><span class="lineno"> 518</span> {</div>
<div class="line"><span class="lineno"> 519</span> <a class="code hl_define" href="_hyper_dbg_hyper_log_intrinsics_8h.html#abf506c814a6f717a87b5d808b828ef56">LogWarning</a>(<span class="stringliteral">"Warning, it is currently not possible to add the current process/thread to the list of processes "</span></div>
<div class="line"><span class="lineno"> 520</span> <span class="stringliteral">"where the trap flag should be masked. Please ensure that you manually unset the trap flag"</span>);</div>
<div class="line"><span class="lineno"> 521</span> }</div>
<div class="line"><span class="lineno"> 522</span> }</div>
<div class="line"><span class="lineno"> 523</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 524</span> {</div>
<div class="line"><span class="lineno"> 525</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 526</span> <span class="comment">// Address is valid, probably the module is previously loaded</span></div>
<div class="line"><span class="lineno"> 527</span> <span class="comment">// or another process with same image is currently running</span></div>
<div class="line"><span class="lineno"> 528</span> <span class="comment">// Thus, there is no need to inject #PF, we'll handle it in debugger</span></div>
<div class="line"><span class="lineno"> 529</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 530</span> <a class="code hl_function" href="_attaching_8c.html#afb4b04c662929a9dc3b74b45b634aff4">AttachingReachedToValidLoadedModule</a>(DbgState, ProcessDebuggingDetail);</div>
<div class="line"><span class="lineno"> 531</span> }</div>
<div class="line"><span class="lineno"> 532</span> }</div>
<div class="line"><span class="lineno"> 533</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#a0b03446aa090036e1c29277857de9596">g_IsWaitingForReturnAndRunFromPageFault</a>)</div>
<div class="line"><span class="lineno"> 534</span> {</div>
<div class="line"><span class="lineno"> 535</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 536</span> <span class="comment">// not waiting for a break after the page-fault anymore</span></div>
<div class="line"><span class="lineno"> 537</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 538</span> <a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#a0b03446aa090036e1c29277857de9596">g_IsWaitingForReturnAndRunFromPageFault</a> = <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 539</span> </div>
<div class="line"><span class="lineno"> 540</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 541</span> <span class="comment">// We reached here as a result of setting the trap flag after</span></div>
<div class="line"><span class="lineno"> 542</span> <span class="comment">// injecting a page-fault</span></div>
<div class="line"><span class="lineno"> 543</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 544</span> <a class="code hl_function" href="_attaching_8c.html#afb4b04c662929a9dc3b74b45b634aff4">AttachingReachedToValidLoadedModule</a>(DbgState, ProcessDebuggingDetail);</div>
<div class="line"><span class="lineno"> 545</span> }</div>
<div class="line"><span class="lineno"> 546</span> }</div>
<div class="line"><span class="lineno"> 547</span>}</div>
<div class="ttc" id="a_address_check_8c_html_aec71cec56c29db61a23b2997ee8e2059"><div class="ttname"><a href="_address_check_8c.html#aec71cec56c29db61a23b2997ee8e2059">CheckAccessValidityAndSafety</a></div><div class="ttdeci">BOOLEAN CheckAccessValidityAndSafety(UINT64 TargetAddress, UINT32 Size)</div><div class="ttdoc">Check the safety to access the memory.</div><div class="ttdef"><b>Definition</b> AddressCheck.c:156</div></div>
<div class="ttc" id="a_attaching_8c_html_afb4b04c662929a9dc3b74b45b634aff4"><div class="ttname"><a href="_attaching_8c.html#afb4b04c662929a9dc3b74b45b634aff4">AttachingReachedToValidLoadedModule</a></div><div class="ttdeci">BOOLEAN AttachingReachedToValidLoadedModule(PROCESSOR_DEBUGGING_STATE *DbgState, PUSERMODE_DEBUGGING_PROCESS_DETAILS ProcessDebuggingDetail)</div><div class="ttdoc">Handle cases where we reached to the valid loaded module The main module should be loaded once we rea...</div><div class="ttdef"><b>Definition</b> Attaching.c:348</div></div>
<div class="ttc" id="a_basic_types_8h_html_aebb9e13210d88d43e32e735ada43a425"><div class="ttname"><a href="_basic_types_8h.html#aebb9e13210d88d43e32e735ada43a425">CHAR</a></div><div class="ttdeci">char CHAR</div><div class="ttdef"><b>Definition</b> BasicTypes.h:31</div></div>
<div class="ttc" id="a_breakpoint_commands_8c_html_ac0e535f6d443deb15a20ffbf8e2252c6"><div class="ttname"><a href="_breakpoint_commands_8c.html#ac0e535f6d443deb15a20ffbf8e2252c6">BreakpointRestoreTheTrapFlagOnceTriggered</a></div><div class="ttdeci">BOOLEAN BreakpointRestoreTheTrapFlagOnceTriggered(UINT32 ProcessId, UINT32 ThreadId)</div><div class="ttdoc">This function makes sure to unset the RFLAGS.TF on next trigger of #DB on the target process/thread.</div><div class="ttdef"><b>Definition</b> BreakpointCommands.c:174</div></div>
<div class="ttc" id="a_export_8c_html_a8f68fa306b093e98466bd4f16cd16035"><div class="ttname"><a href="_export_8c.html#a8f68fa306b093e98466bd4f16cd16035">VmFuncSetRflagTrapFlag</a></div><div class="ttdeci">VOID VmFuncSetRflagTrapFlag(BOOLEAN Set)</div><div class="ttdoc">Set Rflag's trap flag.</div><div class="ttdef"><b>Definition</b> Export.c:110</div></div>
<div class="ttc" id="a_export_8c_html_ad4cb8e5eaaa79a648e0b82a1a7af295f"><div class="ttname"><a href="_export_8c.html#ad4cb8e5eaaa79a648e0b82a1a7af295f">VmFuncEventInjectPageFaultWithCr2</a></div><div class="ttdeci">VOID VmFuncEventInjectPageFaultWithCr2(UINT32 CoreId, UINT64 Address, UINT32 PageFaultCode)</div><div class="ttdoc">Inject #PF and configure CR2 register.</div><div class="ttdef"><b>Definition</b> Export.c:626</div></div>
<div class="ttc" id="a_hyper_dbg_hyper_log_intrinsics_8h_html_abf506c814a6f717a87b5d808b828ef56"><div class="ttname"><a href="_hyper_dbg_hyper_log_intrinsics_8h.html#abf506c814a6f717a87b5d808b828ef56">LogWarning</a></div><div class="ttdeci">#define LogWarning(format,...)</div><div class="ttdoc">Log in the case of warning.</div><div class="ttdef"><b>Definition</b> HyperDbgHyperLogIntrinsics.h:99</div></div>
<div class="ttc" id="ahyperkd_2header_2globals_2_global_8h_html_a0b03446aa090036e1c29277857de9596"><div class="ttname"><a href="hyperkd_2header_2globals_2_global_8h.html#a0b03446aa090036e1c29277857de9596">g_IsWaitingForReturnAndRunFromPageFault</a></div><div class="ttdeci">BOOLEAN g_IsWaitingForReturnAndRunFromPageFault</div><div class="ttdoc">Whether the thread attaching mechanism is waiting for a page-fault finish or not.</div><div class="ttdef"><b>Definition</b> Global.h:146</div></div>
<div class="ttc" id="ahyperkd_2header_2globals_2_global_8h_html_ae4b7e6d3d73fbc5e36dab0e432cfda0e"><div class="ttname"><a href="hyperkd_2header_2globals_2_global_8h.html#ae4b7e6d3d73fbc5e36dab0e432cfda0e">g_IsWaitingForUserModeProcessEntryToBeCalled</a></div><div class="ttdeci">BOOLEAN g_IsWaitingForUserModeProcessEntryToBeCalled</div><div class="ttdoc">Whether the thread attaching mechanism is waiting for #DB or not.</div><div class="ttdef"><b>Definition</b> Global.h:158</div></div>
<div class="ttc" id="astruct___p_r_o_c_e_s_s_o_r___d_e_b_u_g_g_i_n_g___s_t_a_t_e_html_a090832a74d330cde891a17bdd5b236e3"><div class="ttname"><a href="struct___p_r_o_c_e_s_s_o_r___d_e_b_u_g_g_i_n_g___s_t_a_t_e.html#a090832a74d330cde891a17bdd5b236e3">_PROCESSOR_DEBUGGING_STATE::CoreId</a></div><div class="ttdeci">UINT32 CoreId</div><div class="ttdef"><b>Definition</b> State.h:169</div></div>
<div class="ttc" id="astruct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s_html_adb588665a0fa72d6307d6f8577f2f946"><div class="ttname"><a href="struct___u_s_e_r_m_o_d_e___d_e_b_u_g_g_i_n_g___p_r_o_c_e_s_s___d_e_t_a_i_l_s.html#adb588665a0fa72d6307d6f8577f2f946">_USERMODE_DEBUGGING_PROCESS_DETAILS::EntrypointOfMainModule</a></div><div class="ttdeci">UINT64 EntrypointOfMainModule</div><div class="ttdef"><b>Definition</b> Attaching.h:58</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="ac973601a8671bd7f982fb9f7fd13ccc4" name="ac973601a8671bd7f982fb9f7fd13ccc4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac973601a8671bd7f982fb9f7fd13ccc4">◆ </a></span>AttachingInitialize()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> AttachingInitialize </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize the attaching mechanism. </p>
<p>as we use the functionalities for these functions, we initialize them from the debugger at start up of debugger (not initialization of user-debugger) </p><dl class="section return"><dt>Returns</dt><dd>BOOLEAN </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 23</span>{</div>
<div class="line"><span class="lineno"> 24</span> <a class="code hl_struct" href="struct___u_n_i_c_o_d_e___s_t_r_i_n_g.html">UNICODE_STRING</a> FunctionName;</div>
<div class="line"><span class="lineno"> 25</span> </div>
<div class="line"><span class="lineno"> 26</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 27</span> <span class="comment">// Find address of PsGetProcessPeb</span></div>
<div class="line"><span class="lineno"> 28</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 29</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="_user_access_8h.html#a2e58e91ee1d41c311736e026efcfe134">g_PsGetProcessPeb</a> == NULL)</div>
<div class="line"><span class="lineno"> 30</span> {</div>
<div class="line"><span class="lineno"> 31</span> RtlInitUnicodeString(&FunctionName, L<span class="stringliteral">"PsGetProcessPeb"</span>);</div>
<div class="line"><span class="lineno"> 32</span> <a class="code hl_variable" href="_user_access_8h.html#a2e58e91ee1d41c311736e026efcfe134">g_PsGetProcessPeb</a> = (<a class="code hl_typedef" href="_user_access_8h.html#aeea4e249b597d96d35bd6b3d310f940b">PsGetProcessPeb</a>)MmGetSystemRoutineAddress(&FunctionName);</div>
<div class="line"><span class="lineno"> 33</span> </div>
<div class="line"><span class="lineno"> 34</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="_user_access_8h.html#a2e58e91ee1d41c311736e026efcfe134">g_PsGetProcessPeb</a> == NULL)</div>
<div class="line"><span class="lineno"> 35</span> {</div>
<div class="line"><span class="lineno"> 36</span> <a class="code hl_define" href="_hyper_dbg_hyper_log_intrinsics_8h.html#a459b19922fecfbb9438dd56b66930d16">LogError</a>(<span class="stringliteral">"Err, cannot resolve PsGetProcessPeb"</span>);</div>
<div class="line"><span class="lineno"> 37</span> </div>
<div class="line"><span class="lineno"> 38</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 39</span> <span class="comment">// Won't fail the entire debugger for not finding this</span></div>
<div class="line"><span class="lineno"> 40</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 41</span> <span class="comment">// return FALSE;</span></div>
<div class="line"><span class="lineno"> 42</span> }</div>
<div class="line"><span class="lineno"> 43</span> }</div>
<div class="line"><span class="lineno"> 44</span> </div>
<div class="line"><span class="lineno"> 45</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 46</span> <span class="comment">// Find address of PsGetProcessWow64Process</span></div>
<div class="line"><span class="lineno"> 47</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 48</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="_user_access_8h.html#a7e5eee7c3615d4c3a4b2e080eebf3046">g_PsGetProcessWow64Process</a> == NULL)</div>
<div class="line"><span class="lineno"> 49</span> {</div>
<div class="line"><span class="lineno"> 50</span> RtlInitUnicodeString(&FunctionName, L<span class="stringliteral">"PsGetProcessWow64Process"</span>);</div>
<div class="line"><span class="lineno"> 51</span> <a class="code hl_variable" href="_user_access_8h.html#a7e5eee7c3615d4c3a4b2e080eebf3046">g_PsGetProcessWow64Process</a> = (<a class="code hl_typedef" href="_user_access_8h.html#a586171a43627dbaf3dd3a68eef7d2954">PsGetProcessWow64Process</a>)MmGetSystemRoutineAddress(&FunctionName);</div>
<div class="line"><span class="lineno"> 52</span> </div>
<div class="line"><span class="lineno"> 53</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="_user_access_8h.html#a7e5eee7c3615d4c3a4b2e080eebf3046">g_PsGetProcessWow64Process</a> == NULL)</div>
<div class="line"><span class="lineno"> 54</span> {</div>
<div class="line"><span class="lineno"> 55</span> <a class="code hl_define" href="_hyper_dbg_hyper_log_intrinsics_8h.html#a459b19922fecfbb9438dd56b66930d16">LogError</a>(<span class="stringliteral">"Err, cannot resolve PsGetProcessPeb"</span>);</div>
<div class="line"><span class="lineno"> 56</span> </div>
<div class="line"><span class="lineno"> 57</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 58</span> <span class="comment">// Won't fail the entire debugger for not finding this</span></div>
<div class="line"><span class="lineno"> 59</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 60</span> <span class="comment">// return FALSE;</span></div>
<div class="line"><span class="lineno"> 61</span> }</div>
<div class="line"><span class="lineno"> 62</span> }</div>
<div class="line"><span class="lineno"> 63</span> </div>
<div class="line"><span class="lineno"> 64</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 65</span> <span class="comment">// Find address of ZwQueryInformationProcess</span></div>
<div class="line"><span class="lineno"> 66</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 67</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="_user_access_8h.html#a114772f502575fa8e6ff36c9fab0bf3e">g_ZwQueryInformationProcess</a> == NULL)</div>
<div class="line"><span class="lineno"> 68</span> {</div>
<div class="line"><span class="lineno"> 69</span> <a class="code hl_struct" href="struct___u_n_i_c_o_d_e___s_t_r_i_n_g.html">UNICODE_STRING</a> RoutineName;</div>
<div class="line"><span class="lineno"> 70</span> </div>
<div class="line"><span class="lineno"> 71</span> RtlInitUnicodeString(&RoutineName, L<span class="stringliteral">"ZwQueryInformationProcess"</span>);</div>
<div class="line"><span class="lineno"> 72</span> </div>
<div class="line"><span class="lineno"> 73</span> <a class="code hl_variable" href="_user_access_8h.html#a114772f502575fa8e6ff36c9fab0bf3e">g_ZwQueryInformationProcess</a> = (<a class="code hl_typedef" href="_user_access_8h.html#aeb00925a7719b80558821f57265bf112">ZwQueryInformationProcess</a>)MmGetSystemRoutineAddress(&RoutineName);</div>
<div class="line"><span class="lineno"> 74</span> </div>
<div class="line"><span class="lineno"> 75</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="_user_access_8h.html#a114772f502575fa8e6ff36c9fab0bf3e">g_ZwQueryInformationProcess</a> == NULL)</div>
<div class="line"><span class="lineno"> 76</span> {</div>
<div class="line"><span class="lineno"> 77</span> <a class="code hl_define" href="_hyper_dbg_hyper_log_intrinsics_8h.html#a459b19922fecfbb9438dd56b66930d16">LogError</a>(<span class="stringliteral">"Err, cannot resolve ZwQueryInformationProcess"</span>);</div>
<div class="line"><span class="lineno"> 78</span> </div>
<div class="line"><span class="lineno"> 79</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 80</span> <span class="comment">// Won't fail the entire debugger for not finding this</span></div>
<div class="line"><span class="lineno"> 81</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 82</span> <span class="comment">// return FALSE;</span></div>
<div class="line"><span class="lineno"> 83</span> }</div>
<div class="line"><span class="lineno"> 84</span> }</div>
<div class="line"><span class="lineno"> 85</span> </div>
<div class="line"><span class="lineno"> 86</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;</div>
<div class="line"><span class="lineno"> 87</span>}</div>
<div class="ttc" id="a_user_access_8h_html_a114772f502575fa8e6ff36c9fab0bf3e"><div class="ttname"><a href="_user_access_8h.html#a114772f502575fa8e6ff36c9fab0bf3e">g_ZwQueryInformationProcess</a></div><div class="ttdeci">ZwQueryInformationProcess g_ZwQueryInformationProcess</div><div class="ttdoc">Address of ZwQueryInformationProcess.</div><div class="ttdef"><b>Definition</b> UserAccess.h:187</div></div>
<div class="ttc" id="a_user_access_8h_html_a2e58e91ee1d41c311736e026efcfe134"><div class="ttname"><a href="_user_access_8h.html#a2e58e91ee1d41c311736e026efcfe134">g_PsGetProcessPeb</a></div><div class="ttdeci">PsGetProcessPeb g_PsGetProcessPeb</div><div class="ttdoc">Address of PsGetProcessPeb.</div><div class="ttdef"><b>Definition</b> UserAccess.h:193</div></div>
<div class="ttc" id="a_user_access_8h_html_a586171a43627dbaf3dd3a68eef7d2954"><div class="ttname"><a href="_user_access_8h.html#a586171a43627dbaf3dd3a68eef7d2954">PsGetProcessWow64Process</a></div><div class="ttdeci">PPEB32(NTAPI * PsGetProcessWow64Process)(PEPROCESS Process)</div><div class="ttdef"><b>Definition</b> UserAccess.h:177</div></div>
<div class="ttc" id="a_user_access_8h_html_a7e5eee7c3615d4c3a4b2e080eebf3046"><div class="ttname"><a href="_user_access_8h.html#a7e5eee7c3615d4c3a4b2e080eebf3046">g_PsGetProcessWow64Process</a></div><div class="ttdeci">PsGetProcessWow64Process g_PsGetProcessWow64Process</div><div class="ttdoc">Address of PsGetProcessWow64Process.</div><div class="ttdef"><b>Definition</b> UserAccess.h:199</div></div>
<div class="ttc" id="a_user_access_8h_html_aeb00925a7719b80558821f57265bf112"><div class="ttname"><a href="_user_access_8h.html#aeb00925a7719b80558821f57265bf112">ZwQueryInformationProcess</a></div><div class="ttdeci">NTSTATUS(* ZwQueryInformationProcess)(__in HANDLE ProcessHandle, __in PROCESSINFOCLASS ProcessInformationClass, __out_bcount(ProcessInformationLength) PVOID ProcessInformation, __in ULONG ProcessInformationLength, __out_opt PULONG ReturnLength)</div><div class="ttdef"><b>Definition</b> UserAccess.h:168</div></div>
<div class="ttc" id="a_user_access_8h_html_aeea4e249b597d96d35bd6b3d310f940b"><div class="ttname"><a href="_user_access_8h.html#aeea4e249b597d96d35bd6b3d310f940b">PsGetProcessPeb</a></div><div class="ttdeci">PPEB(NTAPI * PsGetProcessPeb)(PEPROCESS Process)</div><div class="ttdef"><b>Definition</b> UserAccess.h:175</div></div>
<div class="ttc" id="astruct___u_n_i_c_o_d_e___s_t_r_i_n_g_html"><div class="ttname"><a href="struct___u_n_i_c_o_d_e___s_t_r_i_n_g.html">_UNICODE_STRING</a></div><div class="ttdef"><b>Definition</b> casting.cpp:25</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a640e936614ebe9a68cf54e78f7d8f323" name="a640e936614ebe9a68cf54e78f7d8f323"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a640e936614ebe9a68cf54e78f7d8f323">◆ </a></span>AttachingQueryDetailsOfActiveDebuggingThreadsAndProcesses()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> AttachingQueryDetailsOfActiveDebuggingThreadsAndProcesses </td>
<td>(</td>
<td class="paramtype">PVOID</td> <td class="paramname"><span class="paramname"><em>BufferToStoreDetails</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a></td> <td class="paramname"><span class="paramname"><em>BufferSize</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Query details of active debugging threads. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">BufferToStoreDetails</td><td></td></tr>
<tr><td class="paramname">BufferSize</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>BOOLEAN </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 1477</span>{</div>
<div class="line"><span class="lineno"> 1478</span> <a class="code hl_typedef" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> CountOfProcessesAndThreadsToStore;</div>
<div class="line"><span class="lineno"> 1479</span> </div>
<div class="line"><span class="lineno"> 1480</span> CountOfProcessesAndThreadsToStore = BufferSize / <a class="code hl_define" href="_request_structures_8h.html#a09aea4145f7df682c4513602c5b2a9c6">SIZEOF_USERMODE_DEBUGGING_THREAD_OR_PROCESS_STATE_DETAILS</a>;</div>
<div class="line"><span class="lineno"> 1481</span> </div>
<div class="line"><span class="lineno"> 1482</span> <span class="keywordflow">if</span> (CountOfProcessesAndThreadsToStore == 0)</div>
<div class="line"><span class="lineno"> 1483</span> {</div>
<div class="line"><span class="lineno"> 1484</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1485</span> <span class="comment">// No active thread or process</span></div>
<div class="line"><span class="lineno"> 1486</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1487</span> <span class="keywordflow">return</span> <a class="code hl_define" href="_basic_types_8h.html#aa93f0eb578d23995850d61f7d61c55c1">FALSE</a>;</div>
<div class="line"><span class="lineno"> 1488</span> }</div>
<div class="line"><span class="lineno"> 1489</span> </div>
<div class="line"><span class="lineno"> 1490</span> <span class="comment">// LogInfo("Count of active process and threads : %x", CountOfProcessesAndThreadsToStore);</span></div>
<div class="line"><span class="lineno"> 1491</span> </div>
<div class="line"><span class="lineno"> 1492</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 1493</span> <span class="comment">// Get the results</span></div>