HyperDbg Debugger
Loading...
Searching...
No Matches
Regs.c File Reference

Script engine registers implementations. More...

#include "pch.h"

Functions

UINT64 GetRegValue (PGUEST_REGS GuestRegs, REGS_ENUM RegId)
 Get the register value.
 
BOOLEAN SetRegValue (PGUEST_REGS GuestRegs, UINT32 RegisterId, UINT64 Value)
 Set the register value.
 
BOOLEAN SetRegValueUsingSymbol (PGUEST_REGS GuestRegs, PSYMBOL Symbol, UINT64 Value)
 Set the register value.
 

Detailed Description

Script engine registers implementations.

Author
Alee Amini (alee@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.2
Date
2022-06-29

Function Documentation

◆ GetRegValue()

UINT64 GetRegValue ( PGUEST_REGS GuestRegs,
REGS_ENUM RegId )

Get the register value.

Parameters
GuestRegs
RegId
Returns
UINT64
24{
25 switch (RegId)
26 {
27 case REGISTER_RAX:
28 return GuestRegs->rax;
29
30 break;
31
32 case REGISTER_EAX:
33 return (GuestRegs->rax & LOWER_32_BITS);
34
35 break;
36
37 case REGISTER_AX:
38 return (GuestRegs->rax & LOWER_16_BITS);
39
40 break;
41
42 case REGISTER_AH:
43 return (GuestRegs->rax & SECOND_LOWER_8_BITS) >> 8;
44
45 break;
46
47 case REGISTER_AL:
48 return (GuestRegs->rax & LOWER_8_BITS);
49
50 break;
51
52 case REGISTER_RCX:
53 return GuestRegs->rcx;
54
55 break;
56
57 case REGISTER_ECX:
58 return (GuestRegs->rcx & LOWER_32_BITS);
59
60 break;
61
62 case REGISTER_CX:
63 return (GuestRegs->rcx & LOWER_16_BITS);
64
65 break;
66
67 case REGISTER_CH:
68 return (GuestRegs->rcx & SECOND_LOWER_8_BITS) >> 8;
69
70 break;
71
72 case REGISTER_CL:
73 return (GuestRegs->rcx & LOWER_8_BITS);
74
75 break;
76
77 case REGISTER_RDX:
78 return GuestRegs->rdx;
79
80 break;
81
82 case REGISTER_EDX:
83 return (GuestRegs->rdx & LOWER_32_BITS);
84
85 break;
86
87 case REGISTER_DX:
88 return (GuestRegs->rdx & LOWER_16_BITS);
89
90 break;
91
92 case REGISTER_DH:
93 return (GuestRegs->rdx & SECOND_LOWER_8_BITS) >> 8;
94
95 break;
96
97 case REGISTER_DL:
98 return (GuestRegs->rdx & LOWER_8_BITS);
99
100 break;
101
102 case REGISTER_RBX:
103 return GuestRegs->rbx;
104
105 break;
106
107 case REGISTER_EBX:
108 return (GuestRegs->rbx & LOWER_32_BITS);
109
110 break;
111
112 case REGISTER_BX:
113 return (GuestRegs->rbx & LOWER_16_BITS);
114
115 break;
116
117 case REGISTER_BH:
118 return (GuestRegs->rbx & SECOND_LOWER_8_BITS) >> 8;
119
120 break;
121
122 case REGISTER_BL:
123 return (GuestRegs->rbx & LOWER_8_BITS);
124
125 break;
126
127 case REGISTER_RSP:
128 return GuestRegs->rsp;
129
130 break;
131
132 case REGISTER_ESP:
133 return (GuestRegs->rsp & LOWER_32_BITS);
134
135 break;
136
137 case REGISTER_SP:
138 return (GuestRegs->rsp & LOWER_16_BITS);
139
140 break;
141
142 case REGISTER_SPL:
143 return (GuestRegs->rsp & LOWER_8_BITS);
144
145 break;
146
147 case REGISTER_RBP:
148 return GuestRegs->rbp;
149
150 break;
151
152 case REGISTER_EBP:
153 return (GuestRegs->rbp & LOWER_32_BITS);
154
155 break;
156
157 case REGISTER_BP:
158 return (GuestRegs->rbp & LOWER_16_BITS);
159
160 break;
161 case REGISTER_BPL:
162 return (GuestRegs->rbp & LOWER_8_BITS);
163
164 break;
165
166 case REGISTER_RSI:
167 return GuestRegs->rsi;
168
169 break;
170
171 case REGISTER_ESI:
172 return (GuestRegs->rsi & LOWER_32_BITS);
173
174 break;
175
176 case REGISTER_SI:
177 return (GuestRegs->rsi & LOWER_16_BITS);
178
179 break;
180
181 case REGISTER_SIL:
182 return (GuestRegs->rsi & LOWER_8_BITS);
183
184 break;
185
186 case REGISTER_RDI:
187 return GuestRegs->rdi;
188
189 break;
190
191 case REGISTER_EDI:
192 return (GuestRegs->rdi & LOWER_32_BITS);
193
194 break;
195
196 case REGISTER_DI:
197 return (GuestRegs->rdi & LOWER_16_BITS);
198
199 break;
200
201 case REGISTER_DIL:
202 return (GuestRegs->rdi & LOWER_8_BITS);
203
204 break;
205
206 case REGISTER_R8:
207 return GuestRegs->r8;
208
209 break;
210
211 case REGISTER_R8D:
212 return (GuestRegs->r8 & LOWER_32_BITS);
213
214 break;
215
216 case REGISTER_R8W:
217 return (GuestRegs->r8 & LOWER_16_BITS);
218
219 break;
220
221 case REGISTER_R8H:
222 return (GuestRegs->r8 & SECOND_LOWER_8_BITS) >> 8;
223
224 break;
225
226 case REGISTER_R8L:
227 return (GuestRegs->r8 & LOWER_8_BITS);
228
229 break;
230 case REGISTER_R9:
231 return GuestRegs->r9;
232
233 break;
234
235 case REGISTER_R9D:
236 return (GuestRegs->r9 & LOWER_32_BITS);
237
238 break;
239
240 case REGISTER_R9W:
241 return (GuestRegs->r9 & LOWER_16_BITS);
242
243 break;
244
245 case REGISTER_R9H:
246 return (GuestRegs->r9 & SECOND_LOWER_8_BITS) >> 8;
247
248 break;
249
250 case REGISTER_R9L:
251 return (GuestRegs->r9 & LOWER_8_BITS);
252
253 break;
254
255 case REGISTER_R10:
256 return GuestRegs->r10;
257
258 break;
259
260 case REGISTER_R10D:
261 return (GuestRegs->r10 & LOWER_32_BITS);
262
263 break;
264
265 case REGISTER_R10W:
266 return (GuestRegs->r10 & LOWER_16_BITS);
267
268 break;
269
270 case REGISTER_R10H:
271 return (GuestRegs->r10 & SECOND_LOWER_8_BITS) >> 8;
272
273 break;
274
275 case REGISTER_R10L:
276 return (GuestRegs->r10 & LOWER_8_BITS);
277
278 break;
279
280 case REGISTER_R11:
281 return GuestRegs->r11;
282
283 break;
284
285 case REGISTER_R11D:
286 return (GuestRegs->r11 & LOWER_32_BITS);
287
288 break;
289
290 case REGISTER_R11W:
291 return (GuestRegs->r11 & LOWER_16_BITS);
292
293 break;
294
295 case REGISTER_R11H:
296 return (GuestRegs->r11 & SECOND_LOWER_8_BITS) >> 8;
297
298 break;
299
300 case REGISTER_R11L:
301 return (GuestRegs->r11 & LOWER_8_BITS);
302
303 break;
304
305 case REGISTER_R12:
306 return GuestRegs->r12;
307
308 break;
309
310 case REGISTER_R12D:
311 return (GuestRegs->r12 & LOWER_32_BITS);
312
313 break;
314
315 case REGISTER_R12W:
316 return (GuestRegs->r12 & LOWER_16_BITS);
317
318 break;
319
320 case REGISTER_R12H:
321 return (GuestRegs->r12 & SECOND_LOWER_8_BITS) >> 8;
322
323 break;
324
325 case REGISTER_R12L:
326 return (GuestRegs->r12 & LOWER_8_BITS);
327
328 break;
329
330 case REGISTER_R13:
331 return GuestRegs->r13;
332
333 break;
334
335 case REGISTER_R13D:
336 return (GuestRegs->r13 & LOWER_32_BITS);
337
338 break;
339
340 case REGISTER_R13W:
341 return (GuestRegs->r13 & LOWER_16_BITS);
342
343 break;
344
345 case REGISTER_R13H:
346 return (GuestRegs->r13 & SECOND_LOWER_8_BITS) >> 8;
347
348 break;
349
350 case REGISTER_R13L:
351 return (GuestRegs->r13 & LOWER_8_BITS);
352
353 break;
354
355 case REGISTER_R14:
356 return GuestRegs->r14;
357
358 break;
359
360 case REGISTER_R14D:
361 return (GuestRegs->r14 & LOWER_32_BITS);
362
363 break;
364
365 case REGISTER_R14W:
366 return (GuestRegs->r14 & LOWER_16_BITS);
367
368 break;
369
370 case REGISTER_R14H:
371 return (GuestRegs->r14 & SECOND_LOWER_8_BITS) >> 8;
372
373 break;
374
375 case REGISTER_R14L:
376 return (GuestRegs->r14 & LOWER_8_BITS);
377
378 break;
379
380 case REGISTER_R15:
381 return GuestRegs->r15;
382
383 break;
384
385 case REGISTER_R15D:
386 return (GuestRegs->r15 & LOWER_32_BITS);
387
388 break;
389
390 case REGISTER_R15W:
391 return (GuestRegs->r15 & LOWER_16_BITS);
392
393 break;
394
395 case REGISTER_R15H:
396 return (GuestRegs->r15 & SECOND_LOWER_8_BITS) >> 8;
397
398 break;
399
400 case REGISTER_R15L:
401 return (GuestRegs->r15 & LOWER_8_BITS);
402
403 break;
404
405 case REGISTER_DS:
406
407#ifdef SCRIPT_ENGINE_USER_MODE
408 return NULL;
409#endif // SCRIPT_ENGINE_USER_MODE
410
411#ifdef SCRIPT_ENGINE_KERNEL_MODE
412 return GetGuestDs().Selector;
413#endif // SCRIPT_ENGINE_KERNEL_MODE
414
415 break;
416
417 case REGISTER_ES:
418
419#ifdef SCRIPT_ENGINE_USER_MODE
420 return NULL;
421#endif // SCRIPT_ENGINE_USER_MODE
422
423#ifdef SCRIPT_ENGINE_KERNEL_MODE
424 return GetGuestEs().Selector;
425#endif // SCRIPT_ENGINE_KERNEL_MODE
426
427 break;
428
429 case REGISTER_FS:
430
431#ifdef SCRIPT_ENGINE_USER_MODE
432 return NULL;
433#endif // SCRIPT_ENGINE_USER_MODE
434
435#ifdef SCRIPT_ENGINE_KERNEL_MODE
436 return GetGuestFs().Selector;
437#endif // SCRIPT_ENGINE_KERNEL_MODE
438
439 break;
440
441 case REGISTER_GS:
442
443#ifdef SCRIPT_ENGINE_USER_MODE
444 return NULL;
445#endif // SCRIPT_ENGINE_USER_MODE
446
447#ifdef SCRIPT_ENGINE_KERNEL_MODE
448 return GetGuestGs().Selector;
449#endif // SCRIPT_ENGINE_KERNEL_MODE
450
451 break;
452
453 case REGISTER_CS:
454
455#ifdef SCRIPT_ENGINE_USER_MODE
456 return NULL;
457#endif // SCRIPT_ENGINE_USER_MODE
458
459#ifdef SCRIPT_ENGINE_KERNEL_MODE
460 return GetGuestCs().Selector;
461#endif // SCRIPT_ENGINE_KERNEL_MODE
462
463 break;
464
465 case REGISTER_SS:
466
467#ifdef SCRIPT_ENGINE_USER_MODE
468 return NULL;
469#endif // SCRIPT_ENGINE_USER_MODE
470
471#ifdef SCRIPT_ENGINE_KERNEL_MODE
472 return GetGuestSs().Selector;
473#endif // SCRIPT_ENGINE_KERNEL_MODE
474
475 break;
476
477 case REGISTER_RFLAGS:
478
479#ifdef SCRIPT_ENGINE_USER_MODE
480 return NULL;
481#endif // SCRIPT_ENGINE_USER_MODE
482
483#ifdef SCRIPT_ENGINE_KERNEL_MODE
484 return GetGuestRFlags();
485#endif // SCRIPT_ENGINE_KERNEL_MODE
486
487 break;
488
489 case REGISTER_EFLAGS:
490
491#ifdef SCRIPT_ENGINE_USER_MODE
492 return NULL;
493#endif // SCRIPT_ENGINE_USER_MODE
494
495#ifdef SCRIPT_ENGINE_KERNEL_MODE
496 return (GetGuestRFlags() & LOWER_32_BITS);
497#endif // SCRIPT_ENGINE_KERNEL_MODE
498
499 break;
500
501 case REGISTER_FLAGS:
502
503#ifdef SCRIPT_ENGINE_USER_MODE
504 return NULL;
505#endif // SCRIPT_ENGINE_USER_MODE
506
507#ifdef SCRIPT_ENGINE_KERNEL_MODE
508 return (GetGuestRFlags() & LOWER_16_BITS);
509#endif // SCRIPT_ENGINE_KERNEL_MODE
510
511 break;
512
513 case REGISTER_CF:
514
515#ifdef SCRIPT_ENGINE_USER_MODE
516 return NULL;
517#endif // SCRIPT_ENGINE_USER_MODE
518
519#ifdef SCRIPT_ENGINE_KERNEL_MODE
520 return (GetGuestRFlags() & X86_FLAGS_CF) != (UINT64)NULL ? TRUE : FALSE;
521#endif // SCRIPT_ENGINE_KERNEL_MODE
522
523 break;
524
525 case REGISTER_PF:
526
527#ifdef SCRIPT_ENGINE_USER_MODE
528 return NULL;
529#endif // SCRIPT_ENGINE_USER_MODE
530
531#ifdef SCRIPT_ENGINE_KERNEL_MODE
532 return (GetGuestRFlags() & (X86_FLAGS_PF)) != (UINT64)NULL ? TRUE : FALSE;
533#endif // SCRIPT_ENGINE_KERNEL_MODE
534
535 break;
536
537 case REGISTER_AF:
538
539#ifdef SCRIPT_ENGINE_USER_MODE
540 return NULL;
541#endif // SCRIPT_ENGINE_USER_MODE
542
543#ifdef SCRIPT_ENGINE_KERNEL_MODE
544 return (GetGuestRFlags() & (X86_FLAGS_AF)) != (UINT64)NULL ? TRUE : FALSE;
545#endif // SCRIPT_ENGINE_KERNEL_MODE
546
547 break;
548
549 case REGISTER_ZF:
550
551#ifdef SCRIPT_ENGINE_USER_MODE
552 return NULL;
553#endif // SCRIPT_ENGINE_USER_MODE
554
555#ifdef SCRIPT_ENGINE_KERNEL_MODE
556 return (GetGuestRFlags() & (X86_FLAGS_ZF)) != (UINT64)NULL ? TRUE : FALSE;
557#endif // SCRIPT_ENGINE_KERNEL_MODE
558
559 break;
560
561 case REGISTER_SF:
562
563#ifdef SCRIPT_ENGINE_USER_MODE
564 return NULL;
565#endif // SCRIPT_ENGINE_USER_MODE
566
567#ifdef SCRIPT_ENGINE_KERNEL_MODE
568 return (GetGuestRFlags() & (X86_FLAGS_SF)) != (UINT64)NULL ? TRUE : FALSE;
569#endif // SCRIPT_ENGINE_KERNEL_MODE
570
571 break;
572
573 case REGISTER_TF:
574
575#ifdef SCRIPT_ENGINE_USER_MODE
576 return NULL;
577#endif // SCRIPT_ENGINE_USER_MODE
578
579#ifdef SCRIPT_ENGINE_KERNEL_MODE
580 return (GetGuestRFlags() & (X86_FLAGS_TF)) != (UINT64)NULL ? TRUE : FALSE;
581#endif // SCRIPT_ENGINE_KERNEL_MODE
582
583 break;
584
585 case REGISTER_IF:
586
587#ifdef SCRIPT_ENGINE_USER_MODE
588 return NULL;
589#endif // SCRIPT_ENGINE_USER_MODE
590
591#ifdef SCRIPT_ENGINE_KERNEL_MODE
592 return (GetGuestRFlags() & (X86_FLAGS_IF)) != (UINT64)NULL ? TRUE : FALSE;
593#endif // SCRIPT_ENGINE_KERNEL_MODE
594
595 break;
596
597 case REGISTER_DF:
598
599#ifdef SCRIPT_ENGINE_USER_MODE
600 return NULL;
601#endif // SCRIPT_ENGINE_USER_MODE
602
603#ifdef SCRIPT_ENGINE_KERNEL_MODE
604 return (GetGuestRFlags() & (X86_FLAGS_DF)) != (UINT64)NULL ? TRUE : FALSE;
605#endif // SCRIPT_ENGINE_KERNEL_MODE
606
607 break;
608
609 case REGISTER_OF:
610
611#ifdef SCRIPT_ENGINE_USER_MODE
612 return NULL;
613#endif // SCRIPT_ENGINE_USER_MODE
614
615#ifdef SCRIPT_ENGINE_KERNEL_MODE
616 return (GetGuestRFlags() & (X86_FLAGS_OF)) != (UINT64)NULL ? TRUE : FALSE;
617#endif // SCRIPT_ENGINE_KERNEL_MODE
618
619 break;
620
621 case REGISTER_IOPL:
622
623#ifdef SCRIPT_ENGINE_USER_MODE
624 return NULL;
625#endif // SCRIPT_ENGINE_USER_MODE
626
627#ifdef SCRIPT_ENGINE_KERNEL_MODE
628 return ((GetGuestRFlags() & (0b11 << X86_FLAGS_IOPL_SHIFT)) >> 12);
629#endif // SCRIPT_ENGINE_KERNEL_MODE
630
631 break;
632
633 case REGISTER_NT:
634
635#ifdef SCRIPT_ENGINE_USER_MODE
636 return NULL;
637#endif // SCRIPT_ENGINE_USER_MODE
638
639#ifdef SCRIPT_ENGINE_KERNEL_MODE
640 return (GetGuestRFlags() & (X86_FLAGS_NT)) != (UINT64)NULL ? TRUE : FALSE;
641#endif // SCRIPT_ENGINE_KERNEL_MODE
642
643 break;
644
645 case REGISTER_RF:
646
647#ifdef SCRIPT_ENGINE_USER_MODE
648 return NULL;
649#endif // SCRIPT_ENGINE_USER_MODE
650
651#ifdef SCRIPT_ENGINE_KERNEL_MODE
652 return (GetGuestRFlags() & (X86_FLAGS_RF)) != (UINT64)NULL ? TRUE : FALSE;
653#endif // SCRIPT_ENGINE_KERNEL_MODE
654
655 break;
656
657 case REGISTER_VM:
658
659#ifdef SCRIPT_ENGINE_USER_MODE
660 return NULL;
661#endif // SCRIPT_ENGINE_USER_MODE
662
663#ifdef SCRIPT_ENGINE_KERNEL_MODE
664 return (GetGuestRFlags() & (X86_FLAGS_VM)) != (UINT64)NULL ? TRUE : FALSE;
665#endif // SCRIPT_ENGINE_KERNEL_MODE
666
667 break;
668
669 case REGISTER_AC:
670
671#ifdef SCRIPT_ENGINE_USER_MODE
672 return NULL;
673#endif // SCRIPT_ENGINE_USER_MODE
674
675#ifdef SCRIPT_ENGINE_KERNEL_MODE
676 return (GetGuestRFlags() & (X86_FLAGS_AC)) != (UINT64)NULL ? TRUE : FALSE;
677#endif // SCRIPT_ENGINE_KERNEL_MODE
678
679 break;
680
681 case REGISTER_VIF:
682
683#ifdef SCRIPT_ENGINE_USER_MODE
684 return NULL;
685#endif // SCRIPT_ENGINE_USER_MODE
686
687#ifdef SCRIPT_ENGINE_KERNEL_MODE
688 return (GetGuestRFlags() & (X86_FLAGS_VIF)) != (UINT64)NULL ? TRUE : FALSE;
689#endif // SCRIPT_ENGINE_KERNEL_MODE
690
691 break;
692
693 case REGISTER_VIP:
694
695#ifdef SCRIPT_ENGINE_USER_MODE
696 return NULL;
697#endif // SCRIPT_ENGINE_USER_MODE
698
699#ifdef SCRIPT_ENGINE_KERNEL_MODE
700 return (GetGuestRFlags() & (X86_FLAGS_VIP)) != (UINT64)NULL ? TRUE : FALSE;
701#endif // SCRIPT_ENGINE_KERNEL_MODE
702
703 break;
704
705 case REGISTER_ID:
706
707#ifdef SCRIPT_ENGINE_USER_MODE
708 return NULL;
709#endif // SCRIPT_ENGINE_USER_MODE
710
711#ifdef SCRIPT_ENGINE_KERNEL_MODE
712 return (GetGuestRFlags() & (X86_FLAGS_ID)) != (UINT64)NULL ? TRUE : FALSE;
713#endif // SCRIPT_ENGINE_KERNEL_MODE
714
715 break;
716
717 case REGISTER_RIP:
718
719#ifdef SCRIPT_ENGINE_USER_MODE
720 return NULL;
721#endif // SCRIPT_ENGINE_USER_MODE
722
723#ifdef SCRIPT_ENGINE_KERNEL_MODE
724 return GetGuestRIP();
725#endif // SCRIPT_ENGINE_KERNEL_MODE
726
727 break;
728
729 case REGISTER_EIP:
730
731#ifdef SCRIPT_ENGINE_USER_MODE
732 return NULL;
733#endif // SCRIPT_ENGINE_USER_MODE
734
735#ifdef SCRIPT_ENGINE_KERNEL_MODE
736 return (GetGuestRIP() & LOWER_32_BITS);
737#endif // SCRIPT_ENGINE_KERNEL_MODE
738
739 break;
740
741 case REGISTER_IP:
742
743#ifdef SCRIPT_ENGINE_USER_MODE
744 return NULL;
745#endif // SCRIPT_ENGINE_USER_MODE
746
747#ifdef SCRIPT_ENGINE_KERNEL_MODE
748 return (GetGuestRIP() & LOWER_16_BITS);
749#endif // SCRIPT_ENGINE_KERNEL_MODE
750
751 break;
752
753 case REGISTER_IDTR:
754
755#ifdef SCRIPT_ENGINE_USER_MODE
756 return NULL;
757#endif // SCRIPT_ENGINE_USER_MODE
758
759#ifdef SCRIPT_ENGINE_KERNEL_MODE
760
761 return GetGuestIdtr();
762#endif // SCRIPT_ENGINE_KERNEL_MODE
763
764 break;
765
766 case REGISTER_LDTR:
767
768#ifdef SCRIPT_ENGINE_USER_MODE
769 return NULL;
770#endif // SCRIPT_ENGINE_USER_MODE
771
772#ifdef SCRIPT_ENGINE_KERNEL_MODE
773
774 return GetGuestLdtr();
775#endif // SCRIPT_ENGINE_KERNEL_MODE
776
777 break;
778
779 case REGISTER_TR:
780
781#ifdef SCRIPT_ENGINE_USER_MODE
782 return NULL;
783#endif // SCRIPT_ENGINE_USER_MODE
784
785#ifdef SCRIPT_ENGINE_KERNEL_MODE
786
787 return GetGuestTr();
788#endif // SCRIPT_ENGINE_KERNEL_MODE
789
790 break;
791
792 case REGISTER_GDTR:
793
794#ifdef SCRIPT_ENGINE_USER_MODE
795 return NULL;
796#endif // SCRIPT_ENGINE_USER_MODE
797
798#ifdef SCRIPT_ENGINE_KERNEL_MODE
799 return GetGuestGdtr();
800
801#endif // SCRIPT_ENGINE_KERNEL_MODE
802
803 break;
804
805 case REGISTER_CR0:
806
807#ifdef SCRIPT_ENGINE_USER_MODE
808 return NULL;
809#endif // SCRIPT_ENGINE_USER_MODE
810
811#ifdef SCRIPT_ENGINE_KERNEL_MODE
812 return GetGuestCr0();
813#endif // SCRIPT_ENGINE_KERNEL_MODE
814
815 break;
816
817 case REGISTER_CR2:
818
819#ifdef SCRIPT_ENGINE_USER_MODE
820 return NULL;
821#endif // SCRIPT_ENGINE_USER_MODE
822
823#ifdef SCRIPT_ENGINE_KERNEL_MODE
824 return GetGuestCr2();
825#endif // SCRIPT_ENGINE_KERNEL_MODE
826
827 break;
828
829 case REGISTER_CR3:
830
831#ifdef SCRIPT_ENGINE_USER_MODE
832 return NULL;
833#endif // SCRIPT_ENGINE_USER_MODE
834
835#ifdef SCRIPT_ENGINE_KERNEL_MODE
836 return GetGuestCr3();
837#endif // SCRIPT_ENGINE_KERNEL_MODE
838
839 break;
840
841 case REGISTER_CR4:
842
843#ifdef SCRIPT_ENGINE_USER_MODE
844 return NULL;
845#endif // SCRIPT_ENGINE_USER_MODE
846
847#ifdef SCRIPT_ENGINE_KERNEL_MODE
848 return GetGuestCr4();
849#endif // SCRIPT_ENGINE_KERNEL_MODE
850
851 break;
852
853 case REGISTER_CR8:
854
855#ifdef SCRIPT_ENGINE_USER_MODE
856 return NULL;
857#endif // SCRIPT_ENGINE_USER_MODE
858
859#ifdef SCRIPT_ENGINE_KERNEL_MODE
860 return GetGuestCr8();
861#endif // SCRIPT_ENGINE_KERNEL_MODE
862
863 break;
864
865 case REGISTER_DR0:
866
867#ifdef SCRIPT_ENGINE_USER_MODE
868 return NULL;
869#endif // SCRIPT_ENGINE_USER_MODE
870
871#ifdef SCRIPT_ENGINE_KERNEL_MODE
872 return GetGuestDr0();
873#endif // SCRIPT_ENGINE_KERNEL_MODE
874
875 break;
876
877 case REGISTER_DR1:
878
879#ifdef SCRIPT_ENGINE_USER_MODE
880 return NULL;
881#endif // SCRIPT_ENGINE_USER_MODE
882
883#ifdef SCRIPT_ENGINE_KERNEL_MODE
884 return GetGuestDr1();
885#endif // SCRIPT_ENGINE_KERNEL_MODE
886
887 break;
888
889 case REGISTER_DR2:
890
891#ifdef SCRIPT_ENGINE_USER_MODE
892 return NULL;
893#endif // SCRIPT_ENGINE_USER_MODE
894
895#ifdef SCRIPT_ENGINE_KERNEL_MODE
896 return GetGuestDr2();
897#endif // SCRIPT_ENGINE_KERNEL_MODE
898
899 break;
900
901 case REGISTER_DR3:
902
903#ifdef SCRIPT_ENGINE_USER_MODE
904 return NULL;
905#endif // SCRIPT_ENGINE_USER_MODE
906
907#ifdef SCRIPT_ENGINE_KERNEL_MODE
908 return GetGuestDr3();
909#endif // SCRIPT_ENGINE_KERNEL_MODE
910
911 break;
912
913 case REGISTER_DR6:
914
915#ifdef SCRIPT_ENGINE_USER_MODE
916 return NULL;
917#endif // SCRIPT_ENGINE_USER_MODE
918
919#ifdef SCRIPT_ENGINE_KERNEL_MODE
920 return GetGuestDr6();
921#endif // SCRIPT_ENGINE_KERNEL_MODE
922
923 break;
924
925 case REGISTER_DR7:
926
927#ifdef SCRIPT_ENGINE_USER_MODE
928 return NULL;
929#endif // SCRIPT_ENGINE_USER_MODE
930
931#ifdef SCRIPT_ENGINE_KERNEL_MODE
932 return GetGuestDr7();
933#endif // SCRIPT_ENGINE_KERNEL_MODE
934
935 break;
936
937 default:
938
939#ifdef SCRIPT_ENGINE_USER_MODE
940 ShowMessages("error in reading register");
941#endif // SCRIPT_ENGINE_USER_MODE
942
943#ifdef SCRIPT_ENGINE_KERNEL_MODE
944 LogInfo("Error in reading register");
945#endif // SCRIPT_ENGINE_KERNEL_MODE
946
947 return INVALID;
948
949 break;
950 }
951}
#define LOWER_32_BITS
Definition BasicTypes.h:60
#define LOWER_16_BITS
Definition BasicTypes.h:61
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned __int64 UINT64
Definition BasicTypes.h:21
#define SECOND_LOWER_8_BITS
Definition BasicTypes.h:63
#define LOWER_8_BITS
Definition BasicTypes.h:62
#define LogInfo(format,...)
Define log variables.
Definition HyperDbgHyperLogIntrinsics.h:71
VMX_SEGMENT_SELECTOR GetGuestDs()
Get the Guest Ds Selector.
Definition ManageRegs.c:139
VMX_SEGMENT_SELECTOR GetGuestSs()
Get the Guest Ss Selector.
Definition ManageRegs.c:94
UINT64 GetGuestTr()
Get the Guest Tr.
Definition ManageRegs.c:383
UINT64 GetGuestCr2()
Get the Guest Cr2 value.
Definition ManageRegs.c:474
UINT64 GetGuestIdtr()
Get the Guest Idtr.
Definition ManageRegs.c:304
VMX_SEGMENT_SELECTOR GetGuestFs()
Get the Guest Fs Selector.
Definition ManageRegs.c:184
UINT64 GetGuestCr8()
Get the Guest Cr8 value.
Definition ManageRegs.c:516
VMX_SEGMENT_SELECTOR GetGuestCs()
Get the Guest Cs Selector.
Definition ManageRegs.c:49
VMX_SEGMENT_SELECTOR GetGuestGs()
Get the Guest Gs Selector.
Definition ManageRegs.c:229
UINT64 GetGuestDr1()
Get the Guest Dr1 value.
Definition ManageRegs.c:675
UINT64 GetGuestDr7()
Get the Guest Dr7 (breakpoint trigger) value.
Definition ManageRegs.c:727
UINT64 GetGuestDr0()
Get the Guest Dr0 value.
Definition ManageRegs.c:662
UINT64 GetGuestCr4()
Get the Guest Cr4 value.
Definition ManageRegs.c:502
UINT64 GetGuestCr3()
Get the Guest Cr3 value.
Definition ManageRegs.c:488
UINT64 GetGuestRFlags()
Get the Guest Rflags value.
Definition ManageRegs.c:409
UINT64 GetGuestCr0()
Get the Guest Cr0 value.
Definition ManageRegs.c:460
UINT64 GetGuestDr3()
Get the Guest Dr3 value.
Definition ManageRegs.c:701
UINT64 GetGuestDr6()
Get the Guest Dr6 (breakpoint status) value.
Definition ManageRegs.c:714
UINT64 GetGuestRIP()
Get the Guest RIP value.
Definition ManageRegs.c:446
UINT64 GetGuestLdtr()
Get the Guest Ldtr.
Definition ManageRegs.c:331
VMX_SEGMENT_SELECTOR GetGuestEs()
Get the Guest Es Selector.
Definition ManageRegs.c:274
UINT64 GetGuestDr2()
Get the Guest Dr2 value.
Definition ManageRegs.c:688
UINT64 GetGuestGdtr()
Get the Guest Gdtr.
Definition ManageRegs.c:358
@ REGISTER_DIL
Definition ScriptEngineCommonDefinitions.h:349
@ REGISTER_DR1
Definition ScriptEngineCommonDefinitions.h:429
@ REGISTER_R12W
Definition ScriptEngineCommonDefinitions.h:372
@ REGISTER_EDI
Definition ScriptEngineCommonDefinitions.h:347
@ REGISTER_R14W
Definition ScriptEngineCommonDefinitions.h:382
@ REGISTER_BPL
Definition ScriptEngineCommonDefinitions.h:341
@ REGISTER_CF
Definition ScriptEngineCommonDefinitions.h:399
@ REGISTER_R8D
Definition ScriptEngineCommonDefinitions.h:351
@ REGISTER_DI
Definition ScriptEngineCommonDefinitions.h:348
@ REGISTER_R14L
Definition ScriptEngineCommonDefinitions.h:384
@ REGISTER_RDX
Definition ScriptEngineCommonDefinitions.h:324
@ REGISTER_R10H
Definition ScriptEngineCommonDefinitions.h:363
@ REGISTER_BH
Definition ScriptEngineCommonDefinitions.h:332
@ REGISTER_R12D
Definition ScriptEngineCommonDefinitions.h:371
@ REGISTER_GDTR
Definition ScriptEngineCommonDefinitions.h:421
@ REGISTER_R10
Definition ScriptEngineCommonDefinitions.h:360
@ REGISTER_DR3
Definition ScriptEngineCommonDefinitions.h:431
@ REGISTER_CR4
Definition ScriptEngineCommonDefinitions.h:426
@ REGISTER_CS
Definition ScriptEngineCommonDefinitions.h:394
@ REGISTER_BL
Definition ScriptEngineCommonDefinitions.h:333
@ REGISTER_AL
Definition ScriptEngineCommonDefinitions.h:318
@ REGISTER_IOPL
Definition ScriptEngineCommonDefinitions.h:408
@ REGISTER_CH
Definition ScriptEngineCommonDefinitions.h:322
@ REGISTER_RF
Definition ScriptEngineCommonDefinitions.h:410
@ REGISTER_DR6
Definition ScriptEngineCommonDefinitions.h:432
@ REGISTER_R12
Definition ScriptEngineCommonDefinitions.h:370
@ REGISTER_CL
Definition ScriptEngineCommonDefinitions.h:323
@ REGISTER_RBX
Definition ScriptEngineCommonDefinitions.h:329
@ REGISTER_TR
Definition ScriptEngineCommonDefinitions.h:422
@ REGISTER_PF
Definition ScriptEngineCommonDefinitions.h:400
@ REGISTER_ZF
Definition ScriptEngineCommonDefinitions.h:402
@ REGISTER_R14H
Definition ScriptEngineCommonDefinitions.h:383
@ REGISTER_EIP
Definition ScriptEngineCommonDefinitions.h:417
@ REGISTER_R9
Definition ScriptEngineCommonDefinitions.h:355
@ REGISTER_R12H
Definition ScriptEngineCommonDefinitions.h:373
@ REGISTER_R14D
Definition ScriptEngineCommonDefinitions.h:381
@ REGISTER_ESP
Definition ScriptEngineCommonDefinitions.h:335
@ REGISTER_IDTR
Definition ScriptEngineCommonDefinitions.h:419
@ REGISTER_RIP
Definition ScriptEngineCommonDefinitions.h:416
@ REGISTER_DL
Definition ScriptEngineCommonDefinitions.h:328
@ REGISTER_R11
Definition ScriptEngineCommonDefinitions.h:365
@ REGISTER_NT
Definition ScriptEngineCommonDefinitions.h:409
@ REGISTER_FS
Definition ScriptEngineCommonDefinitions.h:392
@ REGISTER_SPL
Definition ScriptEngineCommonDefinitions.h:337
@ REGISTER_OF
Definition ScriptEngineCommonDefinitions.h:407
@ REGISTER_DH
Definition ScriptEngineCommonDefinitions.h:327
@ REGISTER_R15
Definition ScriptEngineCommonDefinitions.h:385
@ REGISTER_LDTR
Definition ScriptEngineCommonDefinitions.h:420
@ REGISTER_AF
Definition ScriptEngineCommonDefinitions.h:401
@ REGISTER_CR8
Definition ScriptEngineCommonDefinitions.h:427
@ REGISTER_IP
Definition ScriptEngineCommonDefinitions.h:418
@ REGISTER_R8
Definition ScriptEngineCommonDefinitions.h:350
@ REGISTER_SS
Definition ScriptEngineCommonDefinitions.h:395
@ REGISTER_DR2
Definition ScriptEngineCommonDefinitions.h:430
@ REGISTER_R8L
Definition ScriptEngineCommonDefinitions.h:354
@ REGISTER_RAX
Definition ScriptEngineCommonDefinitions.h:314
@ REGISTER_R13
Definition ScriptEngineCommonDefinitions.h:375
@ REGISTER_R11D
Definition ScriptEngineCommonDefinitions.h:366
@ REGISTER_R13H
Definition ScriptEngineCommonDefinitions.h:378
@ REGISTER_EBX
Definition ScriptEngineCommonDefinitions.h:330
@ REGISTER_GS
Definition ScriptEngineCommonDefinitions.h:393
@ REGISTER_DR0
Definition ScriptEngineCommonDefinitions.h:428
@ REGISTER_R9L
Definition ScriptEngineCommonDefinitions.h:359
@ REGISTER_R15D
Definition ScriptEngineCommonDefinitions.h:386
@ REGISTER_CR2
Definition ScriptEngineCommonDefinitions.h:424
@ REGISTER_SF
Definition ScriptEngineCommonDefinitions.h:403
@ REGISTER_DX
Definition ScriptEngineCommonDefinitions.h:326
@ REGISTER_TF
Definition ScriptEngineCommonDefinitions.h:404
@ REGISTER_R9D
Definition ScriptEngineCommonDefinitions.h:356
@ REGISTER_ESI
Definition ScriptEngineCommonDefinitions.h:343
@ REGISTER_R15H
Definition ScriptEngineCommonDefinitions.h:388
@ REGISTER_RSI
Definition ScriptEngineCommonDefinitions.h:342
@ REGISTER_SIL
Definition ScriptEngineCommonDefinitions.h:345
@ REGISTER_BP
Definition ScriptEngineCommonDefinitions.h:340
@ REGISTER_AC
Definition ScriptEngineCommonDefinitions.h:412
@ REGISTER_R10L
Definition ScriptEngineCommonDefinitions.h:364
@ REGISTER_R13D
Definition ScriptEngineCommonDefinitions.h:376
@ REGISTER_R10D
Definition ScriptEngineCommonDefinitions.h:361
@ REGISTER_EFLAGS
Definition ScriptEngineCommonDefinitions.h:397
@ REGISTER_CR0
Definition ScriptEngineCommonDefinitions.h:423
@ REGISTER_DF
Definition ScriptEngineCommonDefinitions.h:406
@ REGISTER_R11H
Definition ScriptEngineCommonDefinitions.h:368
@ REGISTER_VM
Definition ScriptEngineCommonDefinitions.h:411
@ REGISTER_R15L
Definition ScriptEngineCommonDefinitions.h:389
@ REGISTER_R9H
Definition ScriptEngineCommonDefinitions.h:358
@ REGISTER_VIP
Definition ScriptEngineCommonDefinitions.h:414
@ REGISTER_SI
Definition ScriptEngineCommonDefinitions.h:344
@ REGISTER_R10W
Definition ScriptEngineCommonDefinitions.h:362
@ REGISTER_EAX
Definition ScriptEngineCommonDefinitions.h:315
@ REGISTER_CX
Definition ScriptEngineCommonDefinitions.h:321
@ REGISTER_BX
Definition ScriptEngineCommonDefinitions.h:331
@ REGISTER_IF
Definition ScriptEngineCommonDefinitions.h:405
@ REGISTER_R13L
Definition ScriptEngineCommonDefinitions.h:379
@ REGISTER_ES
Definition ScriptEngineCommonDefinitions.h:391
@ REGISTER_AX
Definition ScriptEngineCommonDefinitions.h:316
@ REGISTER_R12L
Definition ScriptEngineCommonDefinitions.h:374
@ REGISTER_RCX
Definition ScriptEngineCommonDefinitions.h:319
@ REGISTER_R8W
Definition ScriptEngineCommonDefinitions.h:352
@ REGISTER_R8H
Definition ScriptEngineCommonDefinitions.h:353
@ REGISTER_ID
Definition ScriptEngineCommonDefinitions.h:415
@ REGISTER_EDX
Definition ScriptEngineCommonDefinitions.h:325
@ REGISTER_RFLAGS
Definition ScriptEngineCommonDefinitions.h:396
@ REGISTER_VIF
Definition ScriptEngineCommonDefinitions.h:413
@ REGISTER_R11L
Definition ScriptEngineCommonDefinitions.h:369
@ REGISTER_R14
Definition ScriptEngineCommonDefinitions.h:380
@ REGISTER_R15W
Definition ScriptEngineCommonDefinitions.h:387
@ REGISTER_CR3
Definition ScriptEngineCommonDefinitions.h:425
@ REGISTER_SP
Definition ScriptEngineCommonDefinitions.h:336
@ REGISTER_DR7
Definition ScriptEngineCommonDefinitions.h:433
@ REGISTER_FLAGS
Definition ScriptEngineCommonDefinitions.h:398
@ REGISTER_RDI
Definition ScriptEngineCommonDefinitions.h:346
@ REGISTER_ECX
Definition ScriptEngineCommonDefinitions.h:320
@ REGISTER_R13W
Definition ScriptEngineCommonDefinitions.h:377
@ REGISTER_R11W
Definition ScriptEngineCommonDefinitions.h:367
@ REGISTER_DS
Definition ScriptEngineCommonDefinitions.h:390
@ REGISTER_RSP
Definition ScriptEngineCommonDefinitions.h:334
@ REGISTER_EBP
Definition ScriptEngineCommonDefinitions.h:339
@ REGISTER_AH
Definition ScriptEngineCommonDefinitions.h:317
@ REGISTER_RBP
Definition ScriptEngineCommonDefinitions.h:338
@ REGISTER_R9W
Definition ScriptEngineCommonDefinitions.h:357
#define INVALID
Definition ScriptEngineCommonDefinitions.h:96
#define X86_FLAGS_VM
Definition Common.h:104
#define X86_FLAGS_RF
Definition Common.h:103
#define X86_FLAGS_TF
Definition Common.h:94
#define X86_FLAGS_VIP
Definition Common.h:107
#define X86_FLAGS_ZF
Definition Common.h:92
#define X86_FLAGS_OF
Definition Common.h:97
#define X86_FLAGS_AF
Definition Common.h:91
#define X86_FLAGS_CF
EFLAGS/RFLAGS.
Definition Common.h:89
#define X86_FLAGS_DF
Definition Common.h:96
#define X86_FLAGS_IF
Definition Common.h:95
#define X86_FLAGS_SF
Definition Common.h:93
#define X86_FLAGS_AC
Definition Common.h:105
#define X86_FLAGS_ID
Definition Common.h:108
#define X86_FLAGS_VIF
Definition Common.h:106
#define X86_FLAGS_NT
Definition Common.h:102
#define X86_FLAGS_IOPL_SHIFT
Definition Common.h:100
#define X86_FLAGS_PF
Definition Common.h:90
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
NULL()
Definition test-case-generator.py:530
UINT16 Selector
Definition DataTypes.h:437
UINT64 rsp
Definition BasicTypes.h:79
UINT64 r14
Definition BasicTypes.h:89
UINT64 r15
Definition BasicTypes.h:90
UINT64 rdi
Definition BasicTypes.h:82
UINT64 rax
Definition BasicTypes.h:75
UINT64 r12
Definition BasicTypes.h:87
UINT64 r13
Definition BasicTypes.h:88
UINT64 r9
Definition BasicTypes.h:84
UINT64 r8
Definition BasicTypes.h:83
UINT64 rbp
Definition BasicTypes.h:80
UINT64 rbx
Definition BasicTypes.h:78
UINT64 r10
Definition BasicTypes.h:85
UINT64 rcx
Definition BasicTypes.h:76
UINT64 rsi
Definition BasicTypes.h:81
UINT64 r11
Definition BasicTypes.h:86
UINT64 rdx
Definition BasicTypes.h:77

◆ SetRegValue()

BOOLEAN SetRegValue ( PGUEST_REGS GuestRegs,
UINT32 RegisterId,
UINT64 Value )

Set the register value.

Parameters
GuestRegs
RegisterId
Value
Returns
BOOLEAN
964{
965 BOOLEAN Result = TRUE;
966
967 switch (RegisterId)
968 {
969 case REGISTER_RAX:
970 GuestRegs->rax = Value;
971
972 break;
973
974 case REGISTER_EAX:
975 GuestRegs->rax = (GuestRegs->rax & UPPER_32_BITS) | (Value & LOWER_32_BITS);
976
977 break;
978
979 case REGISTER_AX:
980 GuestRegs->rax = (GuestRegs->rax & UPPER_48_BITS) | (Value & LOWER_16_BITS);
981
982 break;
983
984 case REGISTER_AH:
985 GuestRegs->rax = (GuestRegs->rax & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
986
987 break;
988
989 case REGISTER_AL:
990 GuestRegs->rax = (GuestRegs->rax & UPPER_56_BITS) | (Value & LOWER_8_BITS);
991
992 break;
993
994 case REGISTER_RCX:
995 GuestRegs->rcx = Value;
996
997 break;
998 case REGISTER_ECX:
999 GuestRegs->rcx = (GuestRegs->rcx & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1000
1001 break;
1002
1003 case REGISTER_CX:
1004 GuestRegs->rcx = (GuestRegs->rcx & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1005
1006 break;
1007
1008 case REGISTER_CH:
1009 GuestRegs->rcx = (GuestRegs->rcx & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1010
1011 break;
1012
1013 case REGISTER_CL:
1014 GuestRegs->rcx = (GuestRegs->rcx & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1015
1016 break;
1017 case REGISTER_RDX:
1018 GuestRegs->rdx = Value;
1019
1020 break;
1021 case REGISTER_EDX:
1022 GuestRegs->rdx = (GuestRegs->rdx & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1023
1024 break;
1025
1026 case REGISTER_DX:
1027 GuestRegs->rdx = (GuestRegs->rdx & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1028
1029 break;
1030
1031 case REGISTER_DH:
1032 GuestRegs->rdx = (GuestRegs->rdx & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1033
1034 break;
1035
1036 case REGISTER_DL:
1037 GuestRegs->rdx = (GuestRegs->rdx & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1038
1039 break;
1040 case REGISTER_RBX:
1041 GuestRegs->rbx = Value;
1042
1043 break;
1044 case REGISTER_EBX:
1045 GuestRegs->rbx = (GuestRegs->rbx & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1046
1047 break;
1048
1049 case REGISTER_BX:
1050 GuestRegs->rbx = (GuestRegs->rbx & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1051
1052 break;
1053
1054 case REGISTER_BH:
1055 GuestRegs->rbx = (GuestRegs->rbx & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1056
1057 break;
1058
1059 case REGISTER_BL:
1060 GuestRegs->rbx = (GuestRegs->rbx & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1061
1062 break;
1063 case REGISTER_RSP:
1064
1065#ifdef SCRIPT_ENGINE_USER_MODE
1066 GuestRegs->rsp = Value;
1067#endif // SCRIPT_ENGINE_USER_MODE
1068
1069#ifdef SCRIPT_ENGINE_KERNEL_MODE
1070 GuestRegs->rsp = Value;
1072#endif // SCRIPT_ENGINE_KERNEL_MODE
1073
1074 break;
1075
1076 case REGISTER_ESP:
1077
1078#ifdef SCRIPT_ENGINE_USER_MODE
1079 GuestRegs->rsp = Value;
1080#endif // SCRIPT_ENGINE_USER_MODE
1081
1082#ifdef SCRIPT_ENGINE_KERNEL_MODE
1083 GuestRegs->rsp = (GuestRegs->rsp & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1084 SetGuestRSP(GuestRegs->rsp);
1085#endif // SCRIPT_ENGINE_KERNEL_MODE
1086
1087 break;
1088
1089 case REGISTER_SP:
1090
1091#ifdef SCRIPT_ENGINE_USER_MODE
1092 GuestRegs->rsp = Value;
1093#endif // SCRIPT_ENGINE_USER_MODE
1094
1095#ifdef SCRIPT_ENGINE_KERNEL_MODE
1096 GuestRegs->rsp = (GuestRegs->rsp & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1097 SetGuestRSP(GuestRegs->rsp);
1098#endif // SCRIPT_ENGINE_KERNEL_MODE
1099
1100 break;
1101
1102 case REGISTER_SPL:
1103
1104#ifdef SCRIPT_ENGINE_USER_MODE
1105 GuestRegs->rsp = Value;
1106#endif // SCRIPT_ENGINE_USER_MODE
1107
1108#ifdef SCRIPT_ENGINE_KERNEL_MODE
1109 GuestRegs->rsp = (GuestRegs->rsp & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1110 SetGuestRSP(GuestRegs->rsp);
1111#endif // SCRIPT_ENGINE_KERNEL_MODE
1112
1113 break;
1114
1115 case REGISTER_RBP:
1116 GuestRegs->rbp = Value;
1117
1118 break;
1119 case REGISTER_EBP:
1120 GuestRegs->rbp = (GuestRegs->rbp & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1121
1122 break;
1123
1124 case REGISTER_BP:
1125 GuestRegs->rbp = (GuestRegs->rbp & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1126
1127 break;
1128
1129 case REGISTER_BPL:
1130 GuestRegs->rbp = (GuestRegs->rbp & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1131
1132 break;
1133 case REGISTER_RSI:
1134 GuestRegs->rsi = Value;
1135
1136 break;
1137 case REGISTER_ESI:
1138 GuestRegs->rsi = (GuestRegs->rsi & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1139
1140 break;
1141
1142 case REGISTER_SI:
1143 GuestRegs->rsi = (GuestRegs->rsi & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1144
1145 break;
1146
1147 case REGISTER_SIL:
1148 GuestRegs->rsi = (GuestRegs->rsi & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1149
1150 break;
1151 case REGISTER_RDI:
1152 GuestRegs->rdi = Value;
1153
1154 break;
1155 case REGISTER_EDI:
1156 GuestRegs->rdi = (GuestRegs->rdi & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1157
1158 break;
1159
1160 case REGISTER_DI:
1161 GuestRegs->rdi = (GuestRegs->rdi & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1162
1163 break;
1164
1165 case REGISTER_DIL:
1166 GuestRegs->rdi = (GuestRegs->rdi & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1167
1168 break;
1169 case REGISTER_R8:
1170 GuestRegs->r8 = Value;
1171
1172 break;
1173 case REGISTER_R8D:
1174 GuestRegs->r8 = (GuestRegs->r8 & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1175
1176 break;
1177
1178 case REGISTER_R8W:
1179 GuestRegs->r8 = (GuestRegs->r8 & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1180
1181 break;
1182
1183 case REGISTER_R8H:
1184 GuestRegs->r8 = (GuestRegs->r8 & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1185
1186 break;
1187
1188 case REGISTER_R8L:
1189 GuestRegs->r8 = (GuestRegs->r8 & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1190
1191 break;
1192 case REGISTER_R9:
1193 GuestRegs->r9 = Value;
1194
1195 break;
1196 case REGISTER_R9D:
1197 GuestRegs->r9 = (GuestRegs->r9 & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1198
1199 break;
1200
1201 case REGISTER_R9W:
1202 GuestRegs->r9 = (GuestRegs->r9 & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1203
1204 break;
1205
1206 case REGISTER_R9H:
1207 GuestRegs->r9 = (GuestRegs->r9 & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1208
1209 break;
1210
1211 case REGISTER_R9L:
1212 GuestRegs->r9 = (GuestRegs->r9 & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1213
1214 break;
1215 case REGISTER_R10:
1216 GuestRegs->r10 = Value;
1217
1218 break;
1219 case REGISTER_R10D:
1220 GuestRegs->r10 = (GuestRegs->r10 & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1221
1222 break;
1223
1224 case REGISTER_R10W:
1225 GuestRegs->r10 = (GuestRegs->r10 & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1226
1227 break;
1228
1229 case REGISTER_R10H:
1230 GuestRegs->r10 = (GuestRegs->r10 & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1231
1232 break;
1233
1234 case REGISTER_R10L:
1235 GuestRegs->r10 = (GuestRegs->r10 & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1236
1237 break;
1238 case REGISTER_R11:
1239 GuestRegs->r11 = Value;
1240
1241 break;
1242 case REGISTER_R11D:
1243 GuestRegs->r11 = (GuestRegs->r11 & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1244
1245 break;
1246
1247 case REGISTER_R11W:
1248 GuestRegs->r11 = (GuestRegs->r11 & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1249
1250 break;
1251
1252 case REGISTER_R11H:
1253 GuestRegs->r11 = (GuestRegs->r11 & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1254
1255 break;
1256
1257 case REGISTER_R11L:
1258 GuestRegs->r11 = (GuestRegs->r11 & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1259
1260 break;
1261 case REGISTER_R12:
1262 GuestRegs->r12 = Value;
1263
1264 break;
1265 case REGISTER_R12D:
1266 GuestRegs->r12 = (GuestRegs->r12 & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1267
1268 break;
1269
1270 case REGISTER_R12W:
1271 GuestRegs->r12 = (GuestRegs->r12 & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1272
1273 break;
1274
1275 case REGISTER_R12H:
1276 GuestRegs->r12 = (GuestRegs->r12 & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1277
1278 break;
1279
1280 case REGISTER_R12L:
1281 GuestRegs->r12 = (GuestRegs->r12 & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1282
1283 break;
1284 case REGISTER_R13:
1285 GuestRegs->r13 = Value;
1286
1287 break;
1288 case REGISTER_R13D:
1289 GuestRegs->r13 = (GuestRegs->r13 & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1290
1291 break;
1292
1293 case REGISTER_R13W:
1294 GuestRegs->r13 = (GuestRegs->r13 & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1295
1296 break;
1297
1298 case REGISTER_R13H:
1299 GuestRegs->r13 = (GuestRegs->r13 & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1300
1301 break;
1302
1303 case REGISTER_R13L:
1304 GuestRegs->r13 = (GuestRegs->r13 & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1305
1306 break;
1307 case REGISTER_R14:
1308 GuestRegs->r14 = Value;
1309
1310 break;
1311 case REGISTER_R14D:
1312 GuestRegs->r14 = (GuestRegs->r14 & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1313
1314 break;
1315
1316 case REGISTER_R14W:
1317 GuestRegs->r14 = (GuestRegs->r14 & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1318
1319 break;
1320
1321 case REGISTER_R14H:
1322 GuestRegs->r14 = (GuestRegs->r14 & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1323
1324 break;
1325
1326 case REGISTER_R14L:
1327 GuestRegs->r14 = (GuestRegs->r14 & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1328
1329 break;
1330 case REGISTER_R15:
1331 GuestRegs->r15 = Value;
1332
1333 break;
1334 case REGISTER_R15D:
1335 GuestRegs->r15 = (GuestRegs->r15 & UPPER_32_BITS) | (Value & LOWER_32_BITS);
1336
1337 break;
1338
1339 case REGISTER_R15W:
1340 GuestRegs->r15 = (GuestRegs->r15 & UPPER_48_BITS) | (Value & LOWER_16_BITS);
1341
1342 break;
1343
1344 case REGISTER_R15H:
1345 GuestRegs->r15 = (GuestRegs->r15 & UPPER_48_BITS_AND_LOWER_8_BITS) | ((Value << 8) & SECOND_LOWER_8_BITS);
1346
1347 break;
1348
1349 case REGISTER_R15L:
1350 GuestRegs->r15 = (GuestRegs->r15 & UPPER_56_BITS) | (Value & LOWER_8_BITS);
1351
1352 break;
1353 case REGISTER_DS:
1354
1355#ifdef SCRIPT_ENGINE_USER_MODE
1356 //
1357 // Nothing to do
1358 //
1359#endif // SCRIPT_ENGINE_USER_MODE
1360
1361#ifdef SCRIPT_ENGINE_KERNEL_MODE
1364#endif // SCRIPT_ENGINE_KERNEL_MODE
1365
1366 break;
1367
1368 case REGISTER_ES:
1369
1370#ifdef SCRIPT_ENGINE_USER_MODE
1371 //
1372 // Nothing to do
1373 //
1374#endif // SCRIPT_ENGINE_USER_MODE
1375
1376#ifdef SCRIPT_ENGINE_KERNEL_MODE
1379#endif // SCRIPT_ENGINE_KERNEL_MODE
1380
1381 break;
1382
1383 case REGISTER_FS:
1384
1385#ifdef SCRIPT_ENGINE_USER_MODE
1386 //
1387 // Nothing to do
1388 //
1389#endif // SCRIPT_ENGINE_USER_MODE
1390
1391#ifdef SCRIPT_ENGINE_KERNEL_MODE
1394#endif // SCRIPT_ENGINE_KERNEL_MODE
1395
1396 break;
1397
1398 case REGISTER_GS:
1399
1400#ifdef SCRIPT_ENGINE_USER_MODE
1401 //
1402 // Nothing to do
1403 //
1404#endif // SCRIPT_ENGINE_USER_MODE
1405
1406#ifdef SCRIPT_ENGINE_KERNEL_MODE
1409#endif // SCRIPT_ENGINE_KERNEL_MODE
1410
1411 break;
1412
1413 case REGISTER_CS:
1414
1415#ifdef SCRIPT_ENGINE_USER_MODE
1416 //
1417 // Nothing to do
1418 //
1419#endif // SCRIPT_ENGINE_USER_MODE
1420
1421#ifdef SCRIPT_ENGINE_KERNEL_MODE
1424#endif // SCRIPT_ENGINE_KERNEL_MODE
1425
1426 break;
1427
1428 case REGISTER_SS:
1429
1430#ifdef SCRIPT_ENGINE_USER_MODE
1431 //
1432 // Nothing to do
1433 //
1434#endif // SCRIPT_ENGINE_USER_MODE
1435
1436#ifdef SCRIPT_ENGINE_KERNEL_MODE
1439#endif // SCRIPT_ENGINE_KERNEL_MODE
1440
1441 break;
1442
1443 case REGISTER_RFLAGS:
1444
1445#ifdef SCRIPT_ENGINE_USER_MODE
1446 //
1447 // Nothing to do
1448 //
1449#endif // SCRIPT_ENGINE_USER_MODE
1450
1451#ifdef SCRIPT_ENGINE_KERNEL_MODE
1453#endif // SCRIPT_ENGINE_KERNEL_MODE
1454
1455 break;
1456
1457 case REGISTER_EFLAGS:
1458
1459#ifdef SCRIPT_ENGINE_USER_MODE
1460 //
1461 // Nothing to do
1462 //
1463#endif // SCRIPT_ENGINE_USER_MODE
1464
1465#ifdef SCRIPT_ENGINE_KERNEL_MODE
1467#endif // SCRIPT_ENGINE_KERNEL_MODE
1468
1469 break;
1470
1471 case REGISTER_FLAGS:
1472
1473#ifdef SCRIPT_ENGINE_USER_MODE
1474 //
1475 // Nothing to do
1476 //
1477#endif // SCRIPT_ENGINE_USER_MODE
1478
1479#ifdef SCRIPT_ENGINE_KERNEL_MODE
1481#endif // SCRIPT_ENGINE_KERNEL_MODE
1482
1483 break;
1484
1485 case REGISTER_CF:
1486
1487#ifdef SCRIPT_ENGINE_USER_MODE
1488 //
1489 // Nothing to do
1490 //
1491#endif // SCRIPT_ENGINE_USER_MODE
1492
1493#ifdef SCRIPT_ENGINE_KERNEL_MODE
1495#endif // SCRIPT_ENGINE_KERNEL_MODE
1496
1497 break;
1498
1499 case REGISTER_PF:
1500
1501#ifdef SCRIPT_ENGINE_USER_MODE
1502 //
1503 // Nothing to do
1504 //
1505#endif // SCRIPT_ENGINE_USER_MODE
1506
1507#ifdef SCRIPT_ENGINE_KERNEL_MODE
1509#endif // SCRIPT_ENGINE_KERNEL_MODE
1510
1511 break;
1512
1513 case REGISTER_AF:
1514
1515#ifdef SCRIPT_ENGINE_USER_MODE
1516 //
1517 // Nothing to do
1518 //
1519#endif // SCRIPT_ENGINE_USER_MODE
1520
1521#ifdef SCRIPT_ENGINE_KERNEL_MODE
1523#endif // SCRIPT_ENGINE_KERNEL_MODE
1524
1525 break;
1526
1527 case REGISTER_ZF:
1528
1529#ifdef SCRIPT_ENGINE_USER_MODE
1530 //
1531 // Nothing to do
1532 //
1533#endif // SCRIPT_ENGINE_USER_MODE
1534
1535#ifdef SCRIPT_ENGINE_KERNEL_MODE
1537#endif // SCRIPT_ENGINE_KERNEL_MODE
1538
1539 break;
1540
1541 case REGISTER_SF:
1542
1543#ifdef SCRIPT_ENGINE_USER_MODE
1544 //
1545 // Nothing to do
1546 //
1547#endif // SCRIPT_ENGINE_USER_MODE
1548
1549#ifdef SCRIPT_ENGINE_KERNEL_MODE
1551#endif // SCRIPT_ENGINE_KERNEL_MODE
1552
1553 break;
1554
1555 case REGISTER_TF:
1556
1557#ifdef SCRIPT_ENGINE_USER_MODE
1558 //
1559 // Nothing to do
1560 //
1561#endif // SCRIPT_ENGINE_USER_MODE
1562
1563#ifdef SCRIPT_ENGINE_KERNEL_MODE
1565#endif // SCRIPT_ENGINE_KERNEL_MODE
1566
1567 break;
1568
1569 case REGISTER_IF:
1570
1571#ifdef SCRIPT_ENGINE_USER_MODE
1572 //
1573 // Nothing to do
1574 //
1575#endif // SCRIPT_ENGINE_USER_MODE
1576
1577#ifdef SCRIPT_ENGINE_KERNEL_MODE
1579#endif // SCRIPT_ENGINE_KERNEL_MODE
1580
1581 break;
1582
1583 case REGISTER_DF:
1584
1585#ifdef SCRIPT_ENGINE_USER_MODE
1586 //
1587 // Nothing to do
1588 //
1589#endif // SCRIPT_ENGINE_USER_MODE
1590
1591#ifdef SCRIPT_ENGINE_KERNEL_MODE
1593#endif // SCRIPT_ENGINE_KERNEL_MODE
1594
1595 break;
1596
1597 case REGISTER_OF:
1598
1599#ifdef SCRIPT_ENGINE_USER_MODE
1600 //
1601 // Nothing to do
1602 //
1603#endif // SCRIPT_ENGINE_USER_MODE
1604
1605#ifdef SCRIPT_ENGINE_KERNEL_MODE
1607#endif // SCRIPT_ENGINE_KERNEL_MODE
1608
1609 break;
1610
1611 case REGISTER_IOPL:
1612
1613#ifdef SCRIPT_ENGINE_USER_MODE
1614 //
1615 // Nothing to do
1616 //
1617#endif // SCRIPT_ENGINE_USER_MODE
1618
1619#ifdef SCRIPT_ENGINE_KERNEL_MODE
1621 Value = (Value >> 4) & 1;
1623#endif // SCRIPT_ENGINE_KERNEL_MODE
1624
1625 break;
1626
1627 case REGISTER_NT:
1628
1629#ifdef SCRIPT_ENGINE_USER_MODE
1630 //
1631 // Nothing to do
1632 //
1633#endif // SCRIPT_ENGINE_USER_MODE
1634
1635#ifdef SCRIPT_ENGINE_KERNEL_MODE
1637#endif // SCRIPT_ENGINE_KERNEL_MODE
1638
1639 break;
1640
1641 case REGISTER_RF:
1642
1643#ifdef SCRIPT_ENGINE_USER_MODE
1644 //
1645 // Nothing to do
1646 //
1647#endif // SCRIPT_ENGINE_USER_MODE
1648
1649#ifdef SCRIPT_ENGINE_KERNEL_MODE
1651#endif // SCRIPT_ENGINE_KERNEL_MODE
1652
1653 break;
1654
1655 case REGISTER_VM:
1656
1657#ifdef SCRIPT_ENGINE_USER_MODE
1658 //
1659 // Nothing to do
1660 //
1661#endif // SCRIPT_ENGINE_USER_MODE
1662
1663#ifdef SCRIPT_ENGINE_KERNEL_MODE
1665#endif // SCRIPT_ENGINE_KERNEL_MODE
1666
1667 break;
1668
1669 case REGISTER_AC:
1670
1671#ifdef SCRIPT_ENGINE_USER_MODE
1672 //
1673 // Nothing to do
1674 //
1675#endif // SCRIPT_ENGINE_USER_MODE
1676
1677#ifdef SCRIPT_ENGINE_KERNEL_MODE
1679#endif // SCRIPT_ENGINE_KERNEL_MODE
1680
1681 break;
1682
1683 case REGISTER_VIF:
1684
1685#ifdef SCRIPT_ENGINE_USER_MODE
1686 //
1687 // Nothing to do
1688 //
1689#endif // SCRIPT_ENGINE_USER_MODE
1690
1691#ifdef SCRIPT_ENGINE_KERNEL_MODE
1693#endif // SCRIPT_ENGINE_KERNEL_MODE
1694
1695 break;
1696
1697 case REGISTER_VIP:
1698
1699#ifdef SCRIPT_ENGINE_USER_MODE
1700 //
1701 // Nothing to do
1702 //
1703#endif // SCRIPT_ENGINE_USER_MODE
1704
1705#ifdef SCRIPT_ENGINE_KERNEL_MODE
1707#endif // SCRIPT_ENGINE_KERNEL_MODE
1708
1709 break;
1710
1711 case REGISTER_ID:
1712
1713#ifdef SCRIPT_ENGINE_USER_MODE
1714 //
1715 // Nothing to do
1716 //
1717#endif // SCRIPT_ENGINE_USER_MODE
1718
1719#ifdef SCRIPT_ENGINE_KERNEL_MODE
1721#endif // SCRIPT_ENGINE_KERNEL_MODE
1722
1723 break;
1724
1725 case REGISTER_RIP:
1726
1727#ifdef SCRIPT_ENGINE_USER_MODE
1728 //
1729 // Nothing to do
1730 //
1731#endif // SCRIPT_ENGINE_USER_MODE
1732
1733#ifdef SCRIPT_ENGINE_KERNEL_MODE
1735#endif // SCRIPT_ENGINE_KERNEL_MODE
1736
1737 break;
1738
1739 case REGISTER_EIP:
1740
1741#ifdef SCRIPT_ENGINE_USER_MODE
1742 //
1743 // Nothing to do
1744 //
1745#endif // SCRIPT_ENGINE_USER_MODE
1746
1747#ifdef SCRIPT_ENGINE_KERNEL_MODE
1749#endif // SCRIPT_ENGINE_KERNEL_MODE
1750
1751 break;
1752
1753 case REGISTER_IP:
1754
1755#ifdef SCRIPT_ENGINE_USER_MODE
1756 //
1757 // Nothing to do
1758 //
1759#endif // SCRIPT_ENGINE_USER_MODE
1760
1761#ifdef SCRIPT_ENGINE_KERNEL_MODE
1763#endif // SCRIPT_ENGINE_KERNEL_MODE
1764
1765 break;
1766
1767 case REGISTER_IDTR:
1768
1769#ifdef SCRIPT_ENGINE_USER_MODE
1770 //
1771 // Nothing to do
1772 //
1773#endif // SCRIPT_ENGINE_USER_MODE
1774
1775#ifdef SCRIPT_ENGINE_KERNEL_MODE
1777#endif // SCRIPT_ENGINE_KERNEL_MODE
1778
1779 break;
1780
1781 case REGISTER_LDTR:
1782
1783#ifdef SCRIPT_ENGINE_USER_MODE
1784 //
1785 // Nothing to do
1786 //
1787#endif // SCRIPT_ENGINE_USER_MODE
1788
1789#ifdef SCRIPT_ENGINE_KERNEL_MODE
1791#endif // SCRIPT_ENGINE_KERNEL_MODE
1792
1793 break;
1794
1795 case REGISTER_GDTR:
1796
1797#ifdef SCRIPT_ENGINE_USER_MODE
1798 //
1799 // Nothing to do
1800 //
1801#endif // SCRIPT_ENGINE_USER_MODE
1802
1803#ifdef SCRIPT_ENGINE_KERNEL_MODE
1805#endif // SCRIPT_ENGINE_KERNEL_MODE
1806
1807 break;
1808
1809 case REGISTER_TR:
1810
1811#ifdef SCRIPT_ENGINE_USER_MODE
1812 //
1813 // Nothing to do
1814 //
1815#endif // SCRIPT_ENGINE_USER_MODE
1816
1817#ifdef SCRIPT_ENGINE_KERNEL_MODE
1819#endif // SCRIPT_ENGINE_KERNEL_MODE
1820
1821 break;
1822
1823 case REGISTER_CR0:
1824
1825#ifdef SCRIPT_ENGINE_USER_MODE
1826 //
1827 // Nothing to do
1828 //
1829#endif // SCRIPT_ENGINE_USER_MODE
1830
1831#ifdef SCRIPT_ENGINE_KERNEL_MODE
1833#endif // SCRIPT_ENGINE_KERNEL_MODE
1834
1835 break;
1836
1837 case REGISTER_CR2:
1838
1839#ifdef SCRIPT_ENGINE_USER_MODE
1840 //
1841 // Nothing to do
1842 //
1843#endif // SCRIPT_ENGINE_USER_MODE
1844
1845#ifdef SCRIPT_ENGINE_KERNEL_MODE
1847#endif // SCRIPT_ENGINE_KERNEL_MODE
1848
1849 break;
1850
1851 case REGISTER_CR3:
1852
1853#ifdef SCRIPT_ENGINE_USER_MODE
1854 //
1855 // Nothing to do
1856 //
1857#endif // SCRIPT_ENGINE_USER_MODE
1858
1859#ifdef SCRIPT_ENGINE_KERNEL_MODE
1861#endif // SCRIPT_ENGINE_KERNEL_MODE
1862
1863 break;
1864
1865 case REGISTER_CR4:
1866
1867#ifdef SCRIPT_ENGINE_USER_MODE
1868 //
1869 // Nothing to do
1870 //
1871#endif // SCRIPT_ENGINE_USER_MODE
1872
1873#ifdef SCRIPT_ENGINE_KERNEL_MODE
1875#endif // SCRIPT_ENGINE_KERNEL_MODE
1876
1877 break;
1878
1879 case REGISTER_CR8:
1880
1881#ifdef SCRIPT_ENGINE_USER_MODE
1882 //
1883 // Nothing to do
1884 //
1885#endif // SCRIPT_ENGINE_USER_MODE
1886
1887#ifdef SCRIPT_ENGINE_KERNEL_MODE
1889#endif // SCRIPT_ENGINE_KERNEL_MODE
1890
1891 break;
1892
1893 case REGISTER_DR0:
1894
1895#ifdef SCRIPT_ENGINE_USER_MODE
1896 //
1897 // Nothing to do
1898 //
1899#endif // SCRIPT_ENGINE_USER_MODE
1900
1901#ifdef SCRIPT_ENGINE_KERNEL_MODE
1903#endif // SCRIPT_ENGINE_KERNEL_MODE
1904
1905 break;
1906
1907 case REGISTER_DR1:
1908
1909#ifdef SCRIPT_ENGINE_USER_MODE
1910 //
1911 // Nothing to do
1912 //
1913#endif // SCRIPT_ENGINE_USER_MODE
1914
1915#ifdef SCRIPT_ENGINE_KERNEL_MODE
1917#endif // SCRIPT_ENGINE_KERNEL_MODE
1918
1919 break;
1920
1921 case REGISTER_DR2:
1922
1923#ifdef SCRIPT_ENGINE_USER_MODE
1924 //
1925 // Nothing to do
1926 //
1927#endif // SCRIPT_ENGINE_USER_MODE
1928
1929#ifdef SCRIPT_ENGINE_KERNEL_MODE
1931#endif // SCRIPT_ENGINE_KERNEL_MODE
1932
1933 break;
1934
1935 case REGISTER_DR3:
1936
1937#ifdef SCRIPT_ENGINE_USER_MODE
1938 //
1939 // Nothing to do
1940 //
1941#endif // SCRIPT_ENGINE_USER_MODE
1942
1943#ifdef SCRIPT_ENGINE_KERNEL_MODE
1945#endif // SCRIPT_ENGINE_KERNEL_MODE
1946
1947 break;
1948
1949 case REGISTER_DR6:
1950
1951#ifdef SCRIPT_ENGINE_USER_MODE
1952 //
1953 // Nothing to do
1954 //
1955#endif // SCRIPT_ENGINE_USER_MODE
1956
1957#ifdef SCRIPT_ENGINE_KERNEL_MODE
1959#endif // SCRIPT_ENGINE_KERNEL_MODE
1960
1961 break;
1962
1963 case REGISTER_DR7:
1964
1965#ifdef SCRIPT_ENGINE_USER_MODE
1966 //
1967 // Nothing to do
1968 //
1969#endif // SCRIPT_ENGINE_USER_MODE
1970
1971#ifdef SCRIPT_ENGINE_KERNEL_MODE
1973#endif // SCRIPT_ENGINE_KERNEL_MODE
1974
1975 break;
1976 default:
1977 Result = FALSE;
1978 break;
1979 }
1980
1981 return Result;
1982}
#define UPPER_56_BITS
Definition BasicTypes.h:57
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define UPPER_48_BITS_AND_LOWER_8_BITS
Definition BasicTypes.h:64
#define UPPER_32_BITS
Definition BasicTypes.h:59
#define UPPER_48_BITS
Definition BasicTypes.h:58
VOID SetGuestCr3(UINT64 Cr3)
Set the Guest Cr3 Register.
Definition ManageRegs.c:555
VOID SetGuestCr0(UINT64 Cr0)
Set the Guest Cr0 Register.
Definition ManageRegs.c:531
VOID SetGuestDr7(UINT64 value)
Set the Guest Dr7 Register.
Definition ManageRegs.c:651
VOID SetGuestCr2(UINT64 Cr2)
Set the Guest Cr2 Register.
Definition ManageRegs.c:543
VOID SetGuestEsSel(PVMX_SEGMENT_SELECTOR Es)
Set just the Guest Es selector.
Definition ManageRegs.c:248
VOID SetGuestDr1(UINT64 value)
Set the Guest Dr1 Register.
Definition ManageRegs.c:603
VOID SetGuestRSP(UINT64 RSP)
Set the Guest RSP Register.
Definition ManageRegs.c:435
VOID SetGuestGsSel(PVMX_SEGMENT_SELECTOR Gs)
Set just the Guest Gs selector.
Definition ManageRegs.c:203
VOID SetGuestRFlags(UINT64 RFlags)
Set the Guest RFLAGS Register.
Definition ManageRegs.c:398
VOID SetGuestDr3(UINT64 value)
Set the Guest Dr3 Register.
Definition ManageRegs.c:627
VOID SetGuestDr2(UINT64 value)
Set the Guest Dr2 Register.
Definition ManageRegs.c:615
VOID SetGuestCr8(UINT64 Cr8)
Set the Guest Cr8 Register.
Definition ManageRegs.c:579
VOID SetGuestTr(UINT64 Tr)
Definition ManageRegs.c:372
VOID SetGuestIdtr(UINT64 Idtr)
Set the Guest Idtr.
Definition ManageRegs.c:293
VOID SetGuestLdtr(UINT64 Ldtr)
Set the Guest Ldtr.
Definition ManageRegs.c:320
VOID SetGuestDr6(UINT64 value)
Set the Guest Dr6 Register.
Definition ManageRegs.c:639
VOID SetGuestDsSel(PVMX_SEGMENT_SELECTOR Ds)
Set just the Guest Ds selector.
Definition ManageRegs.c:113
VOID SetGuestSsSel(PVMX_SEGMENT_SELECTOR Ss)
Set just the Guest Ss selector.
Definition ManageRegs.c:68
VOID SetGuestDr0(UINT64 value)
Set the Guest Dr0 Register.
Definition ManageRegs.c:591
VOID SetGuestCsSel(PVMX_SEGMENT_SELECTOR Cs)
Set just the Guest Cs selector.
Definition ManageRegs.c:22
VOID SetGuestCr4(UINT64 Cr4)
Set the Guest Cr4 Register.
Definition ManageRegs.c:567
VOID SetGuestGdtr(UINT64 Gdtr)
Set the Guest Gdtr.
Definition ManageRegs.c:347
VOID SetGuestRIP(UINT64 RIP)
Set the Guest RIP Register.
Definition ManageRegs.c:423
VOID SetGuestFsSel(PVMX_SEGMENT_SELECTOR Fs)
Set just the Guest Fs selector.
Definition ManageRegs.c:158
#define X86_FLAGS_IOPL_SHIFT_2ND_BIT
Definition Common.h:101
RequestedActionOfThePacket Value(0x1) 00000000
Segment selector.
Definition DataTypes.h:436

◆ SetRegValueUsingSymbol()

BOOLEAN SetRegValueUsingSymbol ( PGUEST_REGS GuestRegs,
PSYMBOL Symbol,
UINT64 Value )

Set the register value.

Parameters
GuestRegs
Symbol
Value
Returns
BOOLEAN
1994{
1995 return SetRegValue(GuestRegs, (UINT32)Symbol->Value, Value);
1996}
unsigned int UINT32
Definition BasicTypes.h:48
BOOLEAN SetRegValue(PGUEST_REGS GuestRegs, UINT32 RegisterId, UINT64 Value)
Set the register value.
Definition Regs.c:963
long long unsigned Value
Definition ScriptEngineCommonDefinitions.h:10