-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_attaching_8c.html
2387 lines (2334 loc) · 310 KB
/
_attaching_8c.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/code/debugger/user-level/Attaching.c 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_8c.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="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">Attaching.c File Reference</div></div>
</div><!--header-->
<div class="contents">
<p>Attaching and detaching for debugging user-mode processes.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include "pch.h"</code><br />
</div><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:a593f7e7ea84362b61dad501869a7b998" id="r_a593f7e7ea84362b61dad501869a7b998"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#a593f7e7ea84362b61dad501869a7b998">AttachingCreateProcessDebuggingDetails</a> (<a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> ProcessId, <a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> Enabled, <a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> Is32Bit, <a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> CheckCallbackAtFirstInstruction, PEPROCESS Eprocess, <a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> PebAddressToMonitor, <a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> UsermodeReservedBuffer)</td></tr>
<tr class="memdesc:a593f7e7ea84362b61dad501869a7b998"><td class="mdescLeft"> </td><td class="mdescRight">Create user-mode debugging details for threads. <br /></td></tr>
<tr class="separator:a593f7e7ea84362b61dad501869a7b998"><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="_attaching_8h.html#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="_attaching_8h.html#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:a0890d6e4aaf7fd8bdb1663697ed6b717" id="r_a0890d6e4aaf7fd8bdb1663697ed6b717"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_attaching_8h.html#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#a0890d6e4aaf7fd8bdb1663697ed6b717">AttachingFindProcessDebuggingDetailsInStartingPhase</a> ()</td></tr>
<tr class="memdesc:a0890d6e4aaf7fd8bdb1663697ed6b717"><td class="mdescLeft"> </td><td class="mdescRight">Find user-mode debugging details for threads that is in the start-up phase. <br /></td></tr>
<tr class="separator:a0890d6e4aaf7fd8bdb1663697ed6b717"><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:aaadea1225d670dcdb595dafb4f8e6022" id="r_aaadea1225d670dcdb595dafb4f8e6022"><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="#aaadea1225d670dcdb595dafb4f8e6022">AttachingRemoveProcessDebuggingDetailsByToken</a> (<a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> Token)</td></tr>
<tr class="memdesc:aaadea1225d670dcdb595dafb4f8e6022"><td class="mdescLeft"> </td><td class="mdescRight">Remove user-mode debugging details for threads by its token. <br /></td></tr>
<tr class="separator:aaadea1225d670dcdb595dafb4f8e6022"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a3d3e20ec99d70f3b498c332625729a3d" id="r_a3d3e20ec99d70f3b498c332625729a3d"><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="#a3d3e20ec99d70f3b498c332625729a3d">AttachingSetStartingPhaseOfProcessDebuggingDetailsByToken</a> (<a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> Set, <a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> Token)</td></tr>
<tr class="memdesc:a3d3e20ec99d70f3b498c332625729a3d"><td class="mdescLeft"> </td><td class="mdescRight">Set the start up phase of a debugging thread buffer by its token. <br /></td></tr>
<tr class="separator:a3d3e20ec99d70f3b498c332625729a3d"><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="_attaching_8h.html#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>
<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:a5d48d4a604f0d7effefad660da3aaf4a" id="r_a5d48d4a604f0d7effefad660da3aaf4a"><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="#a5d48d4a604f0d7effefad660da3aaf4a">AttachingAdjustNopSledBuffer</a> (<a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> ReservedBuffAddress, <a class="el" href="_basic_types_8h.html#ae1e6edbbc26d6fbc71a90190d0266018">UINT32</a> ProcessId)</td></tr>
<tr class="memdesc:a5d48d4a604f0d7effefad660da3aaf4a"><td class="mdescLeft"> </td><td class="mdescRight">Allocate a nop-sled buffer. <br /></td></tr>
<tr class="separator:a5d48d4a604f0d7effefad660da3aaf4a"><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:a96029792901bb04ae2baa8acfacdd5a7" id="r_a96029792901bb04ae2baa8acfacdd5a7"><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="#a96029792901bb04ae2baa8acfacdd5a7">AttachingCheckForSafeCallbackRequestedInitializations</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> AttachRequest, <a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> ProcessDebuggingToken)</td></tr>
<tr class="memdesc:a96029792901bb04ae2baa8acfacdd5a7"><td class="mdescLeft"> </td><td class="mdescRight">This function checks whether any special initialization is needed while attaching to a process that requests a callback. <br /></td></tr>
<tr class="separator:a96029792901bb04ae2baa8acfacdd5a7"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aa2294a8797b41cc7787eeb68672689b9" id="r_aa2294a8797b41cc7787eeb68672689b9"><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="#aa2294a8797b41cc7787eeb68672689b9">AttachingPerformAttachToProcess</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> AttachRequest, <a class="el" href="_basic_types_8h.html#a1cb18096b299d23458d3c7b85fd86555">BOOLEAN</a> IsAttachingToEntrypoint)</td></tr>
<tr class="memdesc:aa2294a8797b41cc7787eeb68672689b9"><td class="mdescLeft"> </td><td class="mdescRight">Attach to the target process. <br /></td></tr>
<tr class="separator:aa2294a8797b41cc7787eeb68672689b9"><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: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:aba0a55c32fa1b903bbb0b4408b238f62" id="r_aba0a55c32fa1b903bbb0b4408b238f62"><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="#aba0a55c32fa1b903bbb0b4408b238f62">AttachingRemoveHooks</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> AttachRequest)</td></tr>
<tr class="memdesc:aba0a55c32fa1b903bbb0b4408b238f62"><td class="mdescLeft"> </td><td class="mdescRight">Clearing hooks after resuming the process. <br /></td></tr>
<tr class="separator:aba0a55c32fa1b903bbb0b4408b238f62"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aa9fb4120d9e11c187b7a722ba6c7818c" id="r_aa9fb4120d9e11c187b7a722ba6c7818c"><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="#aa9fb4120d9e11c187b7a722ba6c7818c">AttachingPauseProcess</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> PauseRequest)</td></tr>
<tr class="memdesc:aa9fb4120d9e11c187b7a722ba6c7818c"><td class="mdescLeft"> </td><td class="mdescRight">Pauses the target process. <br /></td></tr>
<tr class="separator:aa9fb4120d9e11c187b7a722ba6c7818c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae631c2803c19685c4517a36470b7f169" id="r_ae631c2803c19685c4517a36470b7f169"><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="#ae631c2803c19685c4517a36470b7f169">AttachingKillProcess</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> KillRequest)</td></tr>
<tr class="memdesc:ae631c2803c19685c4517a36470b7f169"><td class="mdescLeft"> </td><td class="mdescRight">Kill the target process from kernel-mode. <br /></td></tr>
<tr class="separator:ae631c2803c19685c4517a36470b7f169"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8f5b7ae763989ea4c219eada9c8889c6" id="r_a8f5b7ae763989ea4c219eada9c8889c6"><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="#a8f5b7ae763989ea4c219eada9c8889c6">AttachingPerformDetach</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> DetachRequest)</td></tr>
<tr class="memdesc:a8f5b7ae763989ea4c219eada9c8889c6"><td class="mdescLeft"> </td><td class="mdescRight">Clearing hooks after resuming the process. <br /></td></tr>
<tr class="separator:a8f5b7ae763989ea4c219eada9c8889c6"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7275aab09d377c86c14c6a7613897597" id="r_a7275aab09d377c86c14c6a7613897597"><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="#a7275aab09d377c86c14c6a7613897597">AttachingSwitchProcess</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> SwitchRequest)</td></tr>
<tr class="memdesc:a7275aab09d377c86c14c6a7613897597"><td class="mdescLeft"> </td><td class="mdescRight">Switch to the target thread. <br /></td></tr>
<tr class="separator:a7275aab09d377c86c14c6a7613897597"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aab87bdbf88894b1c9986c88a16298e38" id="r_aab87bdbf88894b1c9986c88a16298e38"><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="#aab87bdbf88894b1c9986c88a16298e38">AttachingQueryCountOfActiveDebuggingThreadsAndProcesses</a> (<a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a> QueryCountOfDebugThreadsRequest)</td></tr>
<tr class="memdesc:aab87bdbf88894b1c9986c88a16298e38"><td class="mdescLeft"> </td><td class="mdescRight">Query count of active debugging threads. <br /></td></tr>
<tr class="separator:aab87bdbf88894b1c9986c88a16298e38"><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: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>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>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">Function Documentation</h2>
<a id="a5d48d4a604f0d7effefad660da3aaf4a" name="a5d48d4a604f0d7effefad660da3aaf4a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5d48d4a604f0d7effefad660da3aaf4a">◆ </a></span>AttachingAdjustNopSledBuffer()</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> AttachingAdjustNopSledBuffer </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>ReservedBuffAddress</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>ProcessId</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Allocate a nop-sled buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ReservedBuffAddress</td><td></td></tr>
<tr><td class="paramname">ProcessId</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"> 558</span>{</div>
<div class="line"><span class="lineno"> 559</span> PEPROCESS SourceProcess;</div>
<div class="line"><span class="lineno"> 560</span> KAPC_STATE State = {0};</div>
<div class="line"><span class="lineno"> 561</span> </div>
<div class="line"><span class="lineno"> 562</span> <span class="keywordflow">if</span> (PsLookupProcessByProcessId((HANDLE)ProcessId, &SourceProcess) != STATUS_SUCCESS)</div>
<div class="line"><span class="lineno"> 563</span> {</div>
<div class="line"><span class="lineno"> 564</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 565</span> <span class="comment">// if the process not found</span></div>
<div class="line"><span class="lineno"> 566</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 567</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"> 568</span> }</div>
<div class="line"><span class="lineno"> 569</span> </div>
<div class="line"><span class="lineno"> 570</span> __try</div>
<div class="line"><span class="lineno"> 571</span> {</div>
<div class="line"><span class="lineno"> 572</span> KeStackAttachProcess(SourceProcess, &State);</div>
<div class="line"><span class="lineno"> 573</span> </div>
<div class="line"><span class="lineno"> 574</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 575</span> <span class="comment">// Fill the memory with nops</span></div>
<div class="line"><span class="lineno"> 576</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 577</span> memset((<span class="keywordtype">void</span> *)ReservedBuffAddress, 0x90, <a class="code hl_define" href="libhyperdbg_2header_2_common_8h.html#a7d467c1d283fdfa1f2081ba1e0d01b6e">PAGE_SIZE</a>);</div>
<div class="line"><span class="lineno"> 578</span> </div>
<div class="line"><span class="lineno"> 579</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 580</span> <span class="comment">// Set jmps to form a loop (little endians)</span></div>
<div class="line"><span class="lineno"> 581</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 582</span> <span class="comment">// Disassembly of section .text:</span></div>
<div class="line"><span class="lineno"> 583</span> <span class="comment">// 0000000000000000 <NopLoop>:</span></div>
<div class="line"><span class="lineno"> 584</span> <span class="comment">// 0: 90 nop</span></div>
<div class="line"><span class="lineno"> 585</span> <span class="comment">// 1: 90 nop</span></div>
<div class="line"><span class="lineno"> 586</span> <span class="comment">// 2: 90 nop</span></div>
<div class="line"><span class="lineno"> 587</span> <span class="comment">// 3: 90 nop</span></div>
<div class="line"><span class="lineno"> 588</span> <span class="comment">// 4: 90 nop</span></div>
<div class="line"><span class="lineno"> 589</span> <span class="comment">// 5: 90 nop</span></div>
<div class="line"><span class="lineno"> 590</span> <span class="comment">// 6: 90 nop</span></div>
<div class="line"><span class="lineno"> 591</span> <span class="comment">// 7: 90 nop</span></div>
<div class="line"><span class="lineno"> 592</span> <span class="comment">// 8: 0f a2 cpuid</span></div>
<div class="line"><span class="lineno"> 593</span> <span class="comment">// a: eb f4 jmp 0 <NopLoop></span></div>
<div class="line"><span class="lineno"> 594</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 595</span> *(<a class="code hl_typedef" href="_basic_types_8h.html#a09f1a1fb2293e33483cc8d44aefb1eb1">UINT16</a> *)(ReservedBuffAddress + <a class="code hl_define" href="libhyperdbg_2header_2_common_8h.html#a7d467c1d283fdfa1f2081ba1e0d01b6e">PAGE_SIZE</a> - 4) = 0xa20f;</div>
<div class="line"><span class="lineno"> 596</span> *(<a class="code hl_typedef" href="_basic_types_8h.html#a09f1a1fb2293e33483cc8d44aefb1eb1">UINT16</a> *)(ReservedBuffAddress + <a class="code hl_define" href="libhyperdbg_2header_2_common_8h.html#a7d467c1d283fdfa1f2081ba1e0d01b6e">PAGE_SIZE</a> - 2) = 0xf4eb;</div>
<div class="line"><span class="lineno"> 597</span> </div>
<div class="line"><span class="lineno"> 598</span> KeUnstackDetachProcess(&State);</div>
<div class="line"><span class="lineno"> 599</span> </div>
<div class="line"><span class="lineno"> 600</span> ObDereferenceObject(SourceProcess);</div>
<div class="line"><span class="lineno"> 601</span> }</div>
<div class="line"><span class="lineno"> 602</span> __except (EXCEPTION_EXECUTE_HANDLER)</div>
<div class="line"><span class="lineno"> 603</span> {</div>
<div class="line"><span class="lineno"> 604</span> KeUnstackDetachProcess(&State);</div>
<div class="line"><span class="lineno"> 605</span> </div>
<div class="line"><span class="lineno"> 606</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"> 607</span> }</div>
<div class="line"><span class="lineno"> 608</span> </div>
<div class="line"><span class="lineno"> 609</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"> 610</span>}</div>
<div class="ttc" id="a_basic_types_8h_html_a09f1a1fb2293e33483cc8d44aefb1eb1"><div class="ttname"><a href="_basic_types_8h.html#a09f1a1fb2293e33483cc8d44aefb1eb1">UINT16</a></div><div class="ttdeci">unsigned short UINT16</div><div class="ttdef"><b>Definition</b> BasicTypes.h:47</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="alibhyperdbg_2header_2_common_8h_html_a7d467c1d283fdfa1f2081ba1e0d01b6e"><div class="ttname"><a href="libhyperdbg_2header_2_common_8h.html#a7d467c1d283fdfa1f2081ba1e0d01b6e">PAGE_SIZE</a></div><div class="ttdeci">#define PAGE_SIZE</div><div class="ttdoc">Size of each page (4096 bytes)</div><div class="ttdef"><b>Definition</b> common.h:69</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a96029792901bb04ae2baa8acfacdd5a7" name="a96029792901bb04ae2baa8acfacdd5a7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a96029792901bb04ae2baa8acfacdd5a7">◆ </a></span>AttachingCheckForSafeCallbackRequestedInitializations()</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> AttachingCheckForSafeCallbackRequestedInitializations </td>
<td>(</td>
<td class="paramtype"><a class="el" href="_request_structures_8h.html#afd35adb8eff27c6c99326eb010e53b77">PDEBUGGER_ATTACH_DETACH_USER_MODE_PROCESS</a></td> <td class="paramname"><span class="paramname"><em>AttachRequest</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>ProcessDebuggingToken</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>This function checks whether any special initialization is needed while attaching to a process that requests a callback. </p>
<p>this function should not be called in vmx-root</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">AttachRequest</td><td></td></tr>
<tr><td class="paramname">ProcessDebuggingToken</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"> 787</span>{</div>
<div class="line"><span class="lineno"> 788</span> UNREFERENCED_PARAMETER(AttachRequest);</div>
<div class="line"><span class="lineno"> 789</span> UNREFERENCED_PARAMETER(ProcessDebuggingToken);</div>
<div class="line"><span class="lineno"> 790</span> </div>
<div class="line"><span class="lineno"> 791</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 792</span> <span class="comment">// Enable the memory access logging</span></div>
<div class="line"><span class="lineno"> 793</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 794</span> <a class="code hl_function" href="_configuration_8c.html#a1b26f0e861226a28347668799ce3f45e">ConfigureInitializeExecTrapOnAllProcessors</a>();</div>
<div class="line"><span class="lineno"> 795</span> </div>
<div class="line"><span class="lineno"> 796</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"> 797</span>}</div>
<div class="ttc" id="a_configuration_8c_html_a1b26f0e861226a28347668799ce3f45e"><div class="ttname"><a href="_configuration_8c.html#a1b26f0e861226a28347668799ce3f45e">ConfigureInitializeExecTrapOnAllProcessors</a></div><div class="ttdeci">BOOLEAN ConfigureInitializeExecTrapOnAllProcessors()</div><div class="ttdoc">routines for initializing user-mode, kernel-mode exec trap</div><div class="ttdef"><b>Definition</b> Configuration.c:37</div></div>
</div><!-- fragment -->
</div>
</div>
<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="#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="#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_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="#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="_attaching_8h.html#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="#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="_attaching_8h.html#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="a593f7e7ea84362b61dad501869a7b998" name="a593f7e7ea84362b61dad501869a7b998"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a593f7e7ea84362b61dad501869a7b998">◆ </a></span>AttachingCreateProcessDebuggingDetails()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a> AttachingCreateProcessDebuggingDetails </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>
</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>Enabled</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>Is32Bit</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>CheckCallbackAtFirstInstruction</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">PEPROCESS</td> <td class="paramname"><span class="paramname"><em>Eprocess</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>PebAddressToMonitor</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>UsermodeReservedBuffer</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Create user-mode debugging details for threads. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ProcessId</td><td></td></tr>
<tr><td class="paramname">Is32Bit</td><td></td></tr>
<tr><td class="paramname">Eprocess</td><td></td></tr>
<tr><td class="paramname">PebAddressToMonitor</td><td></td></tr>
<tr><td class="paramname">UsermodeReservedBuffer</td><td></td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>UINT64 returns the unique token </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 107</span>{</div>
<div class="line"><span class="lineno"> 108</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"> 109</span> </div>
<div class="line"><span class="lineno"> 110</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 111</span> <span class="comment">// Allocate the buffer</span></div>
<div class="line"><span class="lineno"> 112</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 113</span> ProcessDebuggingDetail = (<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> *)</div>
<div class="line"><span class="lineno"> 114</span> <a class="code hl_function" href="_mem_8c.html#a9bd46383a9f12e1a8a1b59c1658d1bc8">PlatformMemAllocateZeroedNonPagedPool</a>(<span class="keyword">sizeof</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">USERMODE_DEBUGGING_PROCESS_DETAILS</a>));</div>
<div class="line"><span class="lineno"> 115</span> </div>
<div class="line"><span class="lineno"> 116</span> <span class="keywordflow">if</span> (!ProcessDebuggingDetail)</div>
<div class="line"><span class="lineno"> 117</span> {</div>
<div class="line"><span class="lineno"> 118</span> <span class="keywordflow">return</span> (<a class="code hl_typedef" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a>)<a class="code hl_function" href="namespacetest-case-generator.html#a9a4eff80432bb93d2796381610dd86c3">NULL</a>;</div>
<div class="line"><span class="lineno"> 119</span> }</div>
<div class="line"><span class="lineno"> 120</span> </div>
<div class="line"><span class="lineno"> 121</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 122</span> <span class="comment">// Set the unique tag and increment it</span></div>
<div class="line"><span class="lineno"> 123</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 124</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#aac3f928359d06bdd7572a4bd67c86429">Token</a> = <a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#a6cc09230cf7303d0513330bed82491b0">g_SeedOfUserDebuggingDetails</a>++;</div>
<div class="line"><span class="lineno"> 125</span> </div>
<div class="line"><span class="lineno"> 126</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 127</span> <span class="comment">// Set the details of the created buffer</span></div>
<div class="line"><span class="lineno"> 128</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 129</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#ace267a6473505408e798a827e1b244f0">ProcessId</a> = ProcessId;</div>
<div class="line"><span class="lineno"> 130</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#acaf7519d69de4a28112b82f39d438ae0">Enabled</a> = Enabled;</div>
<div class="line"><span class="lineno"> 131</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#ac1a80680491ceb043b754ab5e9a7eec8">Is32Bit</a> = Is32Bit;</div>
<div class="line"><span class="lineno"> 132</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#ab748a7db00ec4b671fa65ef900986080">CheckCallBackForInterceptingFirstInstruction</a> = CheckCallbackAtFirstInstruction;</div>
<div class="line"><span class="lineno"> 133</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#af3376ddf4a0eed532aa22d4be1747764">Eprocess</a> = Eprocess;</div>
<div class="line"><span class="lineno"> 134</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#aefb16ed28844461dfa42f40f062015b0">PebAddressToMonitor</a> = (PVOID)PebAddressToMonitor;</div>
<div class="line"><span class="lineno"> 135</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#ac2d3522e9585dce69980ff651c53cb1d">UsermodeReservedBuffer</a> = UsermodeReservedBuffer;</div>
<div class="line"><span class="lineno"> 136</span> </div>
<div class="line"><span class="lineno"> 137</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 138</span> <span class="comment">// Allocate a thread holder buffer for this process</span></div>
<div class="line"><span class="lineno"> 139</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 140</span> <span class="keywordflow">if</span> (!<a class="code hl_function" href="_thread_holder_8c.html#a2d845e6ff080bbb13aa08176a8c81fa7">ThreadHolderAssignThreadHolderToProcessDebuggingDetails</a>(ProcessDebuggingDetail))</div>
<div class="line"><span class="lineno"> 141</span> {</div>
<div class="line"><span class="lineno"> 142</span> <a class="code hl_function" href="_mem_8c.html#a8ad365cfb6c54c3d6fdd745e6b4666f1">PlatformMemFreePool</a>(ProcessDebuggingDetail);</div>
<div class="line"><span class="lineno"> 143</span> <span class="keywordflow">return</span> (<a class="code hl_typedef" href="_basic_types_8h.html#aae17ebb9ef7279d026817fb22f8aebe9">UINT64</a>)<a class="code hl_function" href="namespacetest-case-generator.html#a9a4eff80432bb93d2796381610dd86c3">NULL</a>;</div>
<div class="line"><span class="lineno"> 144</span> }</div>
<div class="line"><span class="lineno"> 145</span> </div>
<div class="line"><span class="lineno"> 146</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 147</span> <span class="comment">// Attach it to the list of active thread (LIST_ENTRY)</span></div>
<div class="line"><span class="lineno"> 148</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 149</span> <a class="code hl_function" href="_windows_8h.html#ad311db6648e5e4e2860aab6164cdb6c1">InsertHeadList</a>(&<a class="code hl_variable" href="hyperkd_2header_2globals_2_global_8h.html#a3a003d2c59562062fe921cd2754440f7">g_ProcessDebuggingDetailsListHead</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#af9cc943c4e24dbad2df94819db2c2c72">AttachedProcessList</a>));</div>
<div class="line"><span class="lineno"> 150</span> </div>
<div class="line"><span class="lineno"> 151</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 152</span> <span class="comment">// return the token</span></div>
<div class="line"><span class="lineno"> 153</span> <span class="comment">//</span></div>
<div class="line"><span class="lineno"> 154</span> <span class="keywordflow">return</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#aac3f928359d06bdd7572a4bd67c86429">Token</a>;</div>
<div class="line"><span class="lineno"> 155</span>}</div>
<div class="ttc" id="a_mem_8c_html_a8ad365cfb6c54c3d6fdd745e6b4666f1"><div class="ttname"><a href="_mem_8c.html#a8ad365cfb6c54c3d6fdd745e6b4666f1">PlatformMemFreePool</a></div><div class="ttdeci">VOID PlatformMemFreePool(PVOID BufferAddress)</div><div class="ttdoc">Free (dellocate) a non-paged buffer.</div><div class="ttdef"><b>Definition</b> Mem.c:86</div></div>
<div class="ttc" id="a_mem_8c_html_a9bd46383a9f12e1a8a1b59c1658d1bc8"><div class="ttname"><a href="_mem_8c.html#a9bd46383a9f12e1a8a1b59c1658d1bc8">PlatformMemAllocateZeroedNonPagedPool</a></div><div class="ttdeci">PVOID PlatformMemAllocateZeroedNonPagedPool(SIZE_T NumberOfBytes)</div><div class="ttdoc">Allocate a non-paged buffer (zeroed)</div><div class="ttdef"><b>Definition</b> Mem.c:69</div></div>
<div class="ttc" id="a_thread_holder_8c_html_a2d845e6ff080bbb13aa08176a8c81fa7"><div class="ttname"><a href="_thread_holder_8c.html#a2d845e6ff080bbb13aa08176a8c81fa7">ThreadHolderAssignThreadHolderToProcessDebuggingDetails</a></div><div class="ttdeci">BOOLEAN ThreadHolderAssignThreadHolderToProcessDebuggingDetails(PUSERMODE_DEBUGGING_PROCESS_DETAILS ProcessDebuggingDetail)</div><div class="ttdoc">Assign a thread holder to process debugging details.</div><div class="ttdef"><b>Definition</b> ThreadHolder.c:42</div></div>
<div class="ttc" id="a_windows_8h_html_ad311db6648e5e4e2860aab6164cdb6c1"><div class="ttname"><a href="_windows_8h.html#ad311db6648e5e4e2860aab6164cdb6c1">InsertHeadList</a></div><div class="ttdeci">FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ PLIST_ENTRY Entry)</div><div class="ttdef"><b>Definition</b> Windows.h:115</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="ahyperkd_2header_2globals_2_global_8h_html_a6cc09230cf7303d0513330bed82491b0"><div class="ttname"><a href="hyperkd_2header_2globals_2_global_8h.html#a6cc09230cf7303d0513330bed82491b0">g_SeedOfUserDebuggingDetails</a></div><div class="ttdeci">UINT64 g_SeedOfUserDebuggingDetails</div><div class="ttdoc">Seed for tokens of unique details buffer for threads.</div><div class="ttdef"><b>Definition</b> Global.h:139</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 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_aac3f928359d06bdd7572a4bd67c86429"><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#aac3f928359d06bdd7572a4bd67c86429">_USERMODE_DEBUGGING_PROCESS_DETAILS::Token</a></div><div class="ttdeci">UINT64 Token</div><div class="ttdef"><b>Definition</b> Attaching.h:50</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_ab748a7db00ec4b671fa65ef900986080"><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#ab748a7db00ec4b671fa65ef900986080">_USERMODE_DEBUGGING_PROCESS_DETAILS::CheckCallBackForInterceptingFirstInstruction</a></div><div class="ttdeci">BOOLEAN CheckCallBackForInterceptingFirstInstruction</div><div class="ttdef"><b>Definition</b> Attaching.h:65</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_ac1a80680491ceb043b754ab5e9a7eec8"><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#ac1a80680491ceb043b754ab5e9a7eec8">_USERMODE_DEBUGGING_PROCESS_DETAILS::Is32Bit</a></div><div class="ttdeci">BOOLEAN Is32Bit</div><div class="ttdef"><b>Definition</b> Attaching.h:62</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_ac2d3522e9585dce69980ff651c53cb1d"><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#ac2d3522e9585dce69980ff651c53cb1d">_USERMODE_DEBUGGING_PROCESS_DETAILS::UsermodeReservedBuffer</a></div><div class="ttdeci">UINT64 UsermodeReservedBuffer</div><div class="ttdef"><b>Definition</b> Attaching.h:57</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_acaf7519d69de4a28112b82f39d438ae0"><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#acaf7519d69de4a28112b82f39d438ae0">_USERMODE_DEBUGGING_PROCESS_DETAILS::Enabled</a></div><div class="ttdeci">BOOLEAN Enabled</div><div class="ttdef"><b>Definition</b> Attaching.h:51</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_ace267a6473505408e798a827e1b244f0"><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#ace267a6473505408e798a827e1b244f0">_USERMODE_DEBUGGING_PROCESS_DETAILS::ProcessId</a></div><div class="ttdeci">UINT32 ProcessId</div><div class="ttdef"><b>Definition</b> Attaching.h:61</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_aefb16ed28844461dfa42f40f062015b0"><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#aefb16ed28844461dfa42f40f062015b0">_USERMODE_DEBUGGING_PROCESS_DETAILS::PebAddressToMonitor</a></div><div class="ttdeci">PVOID PebAddressToMonitor</div><div class="ttdef"><b>Definition</b> Attaching.h:52</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_af3376ddf4a0eed532aa22d4be1747764"><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#af3376ddf4a0eed532aa22d4be1747764">_USERMODE_DEBUGGING_PROCESS_DETAILS::Eprocess</a></div><div class="ttdeci">PEPROCESS Eprocess</div><div class="ttdef"><b>Definition</b> Attaching.h:60</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_af9cc943c4e24dbad2df94819db2c2c72"><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#af9cc943c4e24dbad2df94819db2c2c72">_USERMODE_DEBUGGING_PROCESS_DETAILS::AttachedProcessList</a></div><div class="ttdeci">LIST_ENTRY AttachedProcessList</div><div class="ttdef"><b>Definition</b> Attaching.h:56</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="_attaching_8h.html#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><!-- 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="_attaching_8h.html#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="a0890d6e4aaf7fd8bdb1663697ed6b717" name="a0890d6e4aaf7fd8bdb1663697ed6b717"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0890d6e4aaf7fd8bdb1663697ed6b717">◆ </a></span>AttachingFindProcessDebuggingDetailsInStartingPhase()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="_attaching_8h.html#ac289d6b25a670c70d1f6a5105788fb04">PUSERMODE_DEBUGGING_PROCESS_DETAILS</a> AttachingFindProcessDebuggingDetailsInStartingPhase </td>
<td>(</td>
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Find user-mode debugging details for threads that is in the start-up phase. </p>
<dl class="section return"><dt>Returns</dt><dd>PUSERMODE_DEBUGGING_PROCESS_DETAILS </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 211</span>{</div>
<div class="line"><span class="lineno"> 212</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"> 213</span> {</div>
<div class="line"><span class="lineno"> 214</span> <span class="keywordflow">if</span> (ProcessDebuggingDetails->IsOnTheStartingPhase)</div>
<div class="line"><span class="lineno"> 215</span> {</div>
<div class="line"><span class="lineno"> 216</span> <span class="keywordflow">return</span> ProcessDebuggingDetails;</div>
<div class="line"><span class="lineno"> 217</span> }</div>
<div class="line"><span class="lineno"> 218</span> }</div>
<div class="line"><span class="lineno"> 219</span> </div>
<div class="line"><span class="lineno"> 220</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"> 221</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="#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="_attaching_8h.html#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="#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>