This function applies commands from the debugger to the debuggee.
2259{
2297
2299 {
2302 UINT32 RecvBufferLength = 0;
2304
2305
2306
2307
2309
2310
2311
2312
2314 {
2315
2316
2317
2318 continue;
2319 }
2320
2322 {
2323
2324
2325
2327 RecvBufferLength -
sizeof(
BYTE)) != TheActualPacket->
Checksum)
2328 {
2329 LogError(
"Err, checksum is invalid");
2330 continue;
2331 }
2332
2333
2334
2335
2337 {
2338
2339
2340
2341
2342 LogError(
"Err, unknown packet received from the debugger\n");
2343 continue;
2344 }
2345
2346
2347
2348
2350 {
2352
2353
2354
2355
2357
2358
2359
2360
2361 EscapeFromTheLoop =
TRUE;
2362
2363 break;
2364
2366
2368
2370 {
2373
2374
2375
2376
2377
2378
2379
2380
2382
2383
2384
2385
2387
2389 {
2391 }
2392
2393
2394
2395
2396 EscapeFromTheLoop =
TRUE;
2397
2398 break;
2399
2403
2404
2405
2406
2411
2412
2413
2414
2416
2418 {
2420 }
2421
2422
2423
2424
2425 EscapeFromTheLoop =
TRUE;
2426
2427 break;
2428
2430
2431
2432
2433
2434
2435
2436
2437
2439
2440
2441
2442
2444
2445
2446
2447
2448 EscapeFromTheLoop =
TRUE;
2449
2450 break;
2451
2452 default:
2453 break;
2454 }
2455
2456 break;
2457
2459
2460
2461
2462
2464
2465
2466
2467
2469
2470
2471
2472
2473 EscapeFromTheLoop =
TRUE;
2474
2475 break;
2476
2478
2480
2481
2482
2483
2485 {
2486
2487
2488
2489 EscapeFromTheLoop =
TRUE;
2490
2491
2492
2493
2494 UnlockTheNewCore =
TRUE;
2495 }
2496
2497
2498
2499
2502 (
CHAR *)ChangeCorePacket,
2504
2505
2506
2507
2508 if (UnlockTheNewCore)
2509 {
2510 UnlockTheNewCore =
FALSE;
2512 }
2513
2514 break;
2515
2517
2519
2520
2521
2522
2524
2525
2526
2527
2530 (
CHAR *)FlushPacket,
2532
2533 break;
2534
2536
2538
2540
2541
2542
2543
2545 {
2547 }
2548
2549
2550
2551
2555 CallstackPacket->
Size,
2557 {
2559 }
2560 else
2561 {
2563 }
2564
2565
2566
2567
2570 (
CHAR *)CallstackPacket,
2571 (
UINT32)CallstackPacket->BufferSize);
2572
2573 break;
2574
2576
2578
2579
2580
2581
2583
2584
2585
2586
2589 (
CHAR *)TestQueryPacket,
2591
2592 break;
2593
2595
2597
2598
2599
2600
2602 {
2604 }
2605 else
2606 {
2608 }
2609
2611 {
2613 }
2614 else
2615 {
2617 }
2618
2619
2620
2623 (
CHAR *)ReadRegisterPacket,
2624 SizeToSend);
2625
2626 break;
2627
2629
2631
2632
2633
2634
2636 {
2638 }
2639 else
2640 {
2642 }
2643
2644
2645
2646
2649 (
CHAR *)WriteRegisterPacket,
2651
2652 break;
2653
2655
2657
2658
2659
2660
2663 &ReturnSize))
2664 {
2666 }
2667 else
2668 {
2670 }
2671
2673
2674
2675
2676
2679 (
CHAR *)ReadMemoryPacket,
2681
2682 break;
2683
2685
2687
2688
2689
2690
2692
2693
2694
2695
2698 (
CHAR *)EditMemoryPacket,
2700
2701 break;
2702
2704
2706
2707
2708
2709
2711
2712
2713
2714
2717 (
CHAR *)ChangeProcessPacket,
2719
2720 break;
2721
2723
2725
2726
2727
2728
2730
2731
2732
2733
2736 (
CHAR *)ChangeThreadPacket,
2738
2739 break;
2740
2742
2744
2745
2746
2747
2749 NULL,
2750 ScriptPacket,
2752 {
2753
2754
2755
2757 }
2758 else
2759 {
2760
2761
2762
2764 }
2765
2766
2767
2768
2771 (
CHAR *)ScriptPacket,
2773
2774 break;
2775
2777
2779
2780
2781
2782
2785
2786
2787
2788
2790 EscapeFromTheLoop =
TRUE;
2791
2792 break;
2793
2795
2797
2798
2799
2800
2801
2802
2804 SearchQueryPacket,
2809 {
2810
2811
2812
2814 }
2815 else
2816 {
2817
2818
2819
2821 }
2822
2823
2824
2825
2828 (
CHAR *)&SearchPacketResult,
2830
2831 break;
2832
2834
2836
2837
2838
2839
2841 {
2842
2843
2844
2846 EscapeFromTheLoop =
TRUE;
2847 }
2848 else
2849 {
2850
2851
2852
2855 (
CHAR *)&DebuggerEventAndActionResult,
2857 }
2858
2859 break;
2860
2862
2864
2865
2866
2867
2869 {
2870
2871
2872
2874 EscapeFromTheLoop =
TRUE;
2875 }
2876 else
2877 {
2878
2879
2880
2883 (
CHAR *)&DebuggerEventAndActionResult,
2885 }
2886
2887 break;
2888
2890
2892
2893
2894
2895
2897 {
2898
2899
2900
2902 EscapeFromTheLoop =
TRUE;
2903 }
2904 else
2905 {
2906
2907
2908
2911 (
CHAR *)QueryAndModifyEventPacket,
2913 }
2914
2915 break;
2916
2918
2920
2921
2922
2923
2925
2926
2927
2928
2931 (
CHAR *)ShortCircuitingEventPacket,
2933
2934 break;
2935
2937
2939
2940
2941
2942
2943
2944
2946
2947
2948
2949
2954
2955 break;
2956
2958
2960
2961
2962
2963
2965
2966
2967
2968
2973
2974 break;
2975
2977
2979
2980
2981
2982
2984
2985
2986
2987
2990 (
CHAR *)SmiOperationPacket,
2992
2993 break;
2994
2996
2998
2999
3000
3001
3003
3004
3005
3006
3009 (
CHAR *)HyperTraceLbrdumpPacket,
3011
3012 break;
3013
3015
3017
3018
3019
3020
3022
3023
3024
3025
3028 (
CHAR *)HyperTracePtOperationPacket,
3030
3031 break;
3032
3034
3036
3037
3038
3039
3041
3042
3043
3044
3048 SizeToSend);
3049
3050 break;
3051
3053
3055
3056
3057
3058
3060
3061
3062
3063
3066 (
CHAR *)IdtEntryPacket,
3068
3069 break;
3070
3072
3074
3075
3076
3077
3079
3080
3081
3082
3085 (
CHAR *)PageinPacket,
3087
3088 break;
3089
3091
3093
3094
3095
3096
3097
3099
3100
3101
3102
3105 (
CHAR *)Va2paPa2vaPacket,
3107
3108 break;
3109
3111
3113
3114
3115
3116
3117
3119
3120
3121
3122
3125 (
CHAR *)BpListOrModifyPacket,
3127
3128 break;
3129
3131
3133
3134
3135
3136
3138
3139
3140
3141
3143
3144
3145
3146
3147 EscapeFromTheLoop =
TRUE;
3148
3149 break;
3150
3152
3154
3155
3156
3157
3159
3160
3161
3162
3165 (
CHAR *)PcitreePacket,
3167
3168 break;
3169
3171
3173
3174
3175
3176
3178
3179
3180
3181
3184 (
CHAR *)PcidevinfoPacket,
3186
3187 break;
3188
3189 default:
3190 LogError(
"Err, unknown packet action received from the debugger\n");
3191 break;
3192 }
3193 }
3194 else
3195 {
3196
3197
3198
3199 LogError(
"Err, it's not a HyperDbg packet, the packet is probably deformed\n");
3200 continue;
3201 }
3202
3203
3204
3205
3206 if (EscapeFromTheLoop)
3207 {
3208 break;
3209 }
3210 }
3211}
BOOLEAN BreakpointAddNew(PDEBUGGEE_BP_PACKET BpDescriptorArg, BOOLEAN SwitchToTargetMemoryLayout)
Add new breakpoints.
Definition BreakpointCommands.c:950
BOOLEAN BreakpointListOrModify(PDEBUGGEE_BP_LIST_OR_MODIFY_PACKET ListOrModifyBreakpoints, BOOLEAN SwitchToTargetMemoryLayout)
List of modify breakpoints.
Definition BreakpointCommands.c:1196
BOOLEAN CallstackWalkthroughStack(PDEBUGGER_SINGLE_CALLSTACK_FRAME AddressToSaveFrames, UINT32 *FrameCount, UINT64 StackBaseAddress, UINT32 Size, BOOLEAN Is32Bit)
Walkthrough the stack.
Definition Callstack.c:26
BOOLEAN DebuggerPerformRunScript(PROCESSOR_DEBUGGING_STATE *DbgState, DEBUGGER_EVENT_ACTION *Action, DEBUGGEE_SCRIPT_PACKET *ScriptDetails, DEBUGGER_TRIGGERED_EVENT_DETAILS *EventTriggerDetail)
Managing run script action.
Definition Debugger.c:1662
BOOLEAN DebuggerCommandEditMemoryVmxRoot(PDEBUGGER_EDIT_MEMORY EditMemRequest)
Edit physical and virtual memory on vmxroot mode.
Definition DebuggerCommands.c:612
BOOLEAN DebuggerCommandReadRegisters(GUEST_REGS *Regs, PDEBUGGEE_REGISTER_READ_DESCRIPTION ReadRegisterRequest)
read registers
Definition DebuggerCommands.c:23
BOOLEAN DebuggerCommandReadMemoryVmxRoot(PDEBUGGER_READ_MEMORY ReadMemRequest, UCHAR *UserBuffer, UINT32 *ReturnSize)
Read memory for different commands from vmxroot mode.
Definition DebuggerCommands.c:186
BOOLEAN SearchAddressWrapper(PUINT64 AddressToSaveResults, PDEBUGGER_SEARCH_MEMORY SearchMemRequest, UINT64 StartAddress, UINT64 EndAddress, BOOLEAN IsDebuggeePaused, PUINT32 CountOfMatchedCases)
The wrapper to check for validity of addresses and call the search routines for both physical and vir...
Definition DebuggerCommands.c:1019
NTSTATUS DebuggerCommandFlush(PDEBUGGER_FLUSH_LOGGING_BUFFERS DebuggerFlushBuffersRequest)
Perform the flush requests to vmx-root and vmx non-root buffers.
Definition DebuggerCommands.c:1292
VOID ExtensionCommandPerformQueryIdtEntriesRequest(PINTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS IdtQueryRequest, BOOLEAN ReadFromVmxRoot)
Perform query for IDT entries.
Definition ExtensionCommands.c:92
VOID ExtensionCommandVa2paAndPa2va(PDEBUGGER_VA2PA_AND_PA2VA_COMMANDS AddressDetails, BOOLEAN OperateOnVmxRoot)
routines for !va2pa and !pa2va commands
Definition ExtensionCommands.c:114
VOID ExtensionCommandPcidevinfo(PDEBUGGEE_PCIDEVINFO_REQUEST_RESPONSE_PACKET PcidevinfoPacket, BOOLEAN OperateOnVmxRoot)
Request PCI device info.
Definition ExtensionCommands.c:760
UINT32 ExtensionCommandPerformActionsForApicRequests(PDEBUGGER_APIC_REQUEST ApicRequest)
Perform actions regarding APIC.
Definition ExtensionCommands.c:23
BOOLEAN ExtensionCommandPte(PDEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS PteDetails, BOOLEAN IsOperatingInVmxRoot)
routines for !pte command
Definition ExtensionCommands.c:261
VOID ExtensionCommandPcitree(PDEBUGGEE_PCITREE_REQUEST_RESPONSE_PACKET PcitreePacket, BOOLEAN OperateOnVmxRoot)
routines for PCIe tree
Definition ExtensionCommands.c:697
VOID KdRegularStepOver(UINT64 LastRip, BOOLEAN IsNextInstructionACall, UINT32 CallLength)
Regular step-over, step one instruction to the debuggee if there is a call then it jumps the call.
Definition Kd.c:433
VOID KdContinueDebuggeeJustCurrentCore(PROCESSOR_DEBUGGING_STATE *DbgState)
continue the debuggee, just the current operating core
Definition Kd.c:677
VOID KdPerformTheTestPacketOperation(PROCESSOR_DEBUGGING_STATE *DbgState, DEBUGGER_DEBUGGER_TEST_QUERY_BUFFER *TestQueryPacket)
Perform the test packet's operation.
Definition Kd.c:1853
_Use_decl_annotations_ VOID KdReloadSymbolDetailsInDebuggee(PDEBUGGEE_SYMBOL_REQUEST_PACKET SymPacket)
Notify user-mode to re-send (reload) the symbol packets.
Definition Kd.c:814
VOID KdNotifyDebuggeeForUserInput(DEBUGGEE_USER_INPUT_PACKET *Descriptor, UINT32 Len)
Notify user-mode to about new user-input buffer.
Definition Kd.c:839
BOOLEAN KdBringPagein(PROCESSOR_DEBUGGING_STATE *DbgState, PDEBUGGER_PAGE_IN_REQUEST PageinRequest)
routines to break page-in
Definition Kd.c:1805
VOID KdGuaranteedStepInstruction(PROCESSOR_DEBUGGING_STATE *DbgState)
apply a guaranteed step one instruction to the debuggee
Definition Kd.c:1440
BOOLEAN KdPerformEventQueryAndModification(PDEBUGGER_MODIFY_EVENTS ModifyAndQueryEvent)
Perform modify and query events.
Definition Kd.c:2050
_Use_decl_annotations_ VOID KdContinueDebuggee(PROCESSOR_DEBUGGING_STATE *DbgState, BOOLEAN PauseBreaksUntilSpecialMessageSent, DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION SpeialEventResponse)
continue the debuggee, this function guarantees that all other cores are continued (except current co...
Definition Kd.c:644
_Use_decl_annotations_ BYTE KdComputeDataChecksum(PVOID Buffer, UINT32 Length)
calculate the checksum of received buffer from debugger
Definition Kd.c:275
BOOLEAN KdPerformRegisterEvent(PDEBUGGEE_EVENT_AND_ACTION_HEADER_FOR_REMOTE_PACKET EventDetailHeader, DEBUGGER_EVENT_AND_ACTION_RESULT *DebuggerEventAndActionResult)
Send event registration buffer to user-mode to register the event.
Definition Kd.c:1550
VOID KdCloseConnectionAndUnloadDebuggee()
Notify user-mode to unload the debuggee and close the connections.
Definition Kd.c:790
BOOLEAN KdPerformAddActionToEvent(PDEBUGGEE_EVENT_AND_ACTION_HEADER_FOR_REMOTE_PACKET ActionDetailHeader, DEBUGGER_EVENT_AND_ACTION_RESULT *DebuggerEventAndActionResult)
Send action buffer to user-mode to be added to the event.
Definition Kd.c:1602
VOID KdPerformSettingTheStateOfShortCircuiting(PROCESSOR_DEBUGGING_STATE *DbgState, PDEBUGGER_SHORT_CIRCUITING_EVENT ShortCircuitingEvent)
Perform modify the state of short-circuiting.
Definition Kd.c:2023
BOOLEAN KdSwitchCore(PROCESSOR_DEBUGGING_STATE *DbgState, DEBUGGEE_CHANGE_CORE_PACKET *ChangeCorePacket)
change the current operating core to new core
Definition Kd.c:699
_Use_decl_annotations_ BOOLEAN KdResponsePacketToDebugger(DEBUGGER_REMOTE_PACKET_TYPE PacketType, DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION Response, CHAR *OptionalBuffer, UINT32 OptionalBufferLength)
Sends a HyperDbg response packet to the debugger.
Definition Kd.c:299
BOOLEAN ProcessInterpretProcess(PROCESSOR_DEBUGGING_STATE *DbgState, PDEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PACKET PidRequest)
change the current process @detail ONLY TO BE USED IN KD STUFFS
Definition Process.c:525
BOOLEAN SetRegValue(PGUEST_REGS GuestRegs, UINT32 RegisterId, UINT64 Value)
Set the register value.
Definition Regs.c:1003
BOOLEAN SerialConnectionRecvBuffer(CHAR *BufferToSave, UINT32 *LengthReceived)
Receive packet from the debugger.
Definition SerialConnection.c:99
BOOLEAN ThreadInterpretThread(PROCESSOR_DEBUGGING_STATE *DbgState, PDEBUGGEE_DETAILS_AND_SWITCH_THREAD_PACKET TidRequest)
change the current thread
Definition Thread.c:325
VOID TracingRegularStepInInstruction()
Regular step-in, step one instruction to the debuggee.
Definition Tracing.c:112
IMPORT_EXPORT_HYPERTRACE BOOLEAN HyperTracePtPerformOperation(HYPERTRACE_PT_OPERATION_PACKETS *PtOperationRequest)
Perform actions related to HyperTrace PT.
Definition PtApi.c:553
IMPORT_EXPORT_HYPERTRACE BOOLEAN HyperTraceLbrPerformDump(HYPERTRACE_LBR_DUMP_PACKETS *LbrDumpRequest)
Perform actions related to HyperTrace LBR dumping.
Definition LbrApi.c:457
IMPORT_EXPORT_VMM BOOLEAN VmFuncSmmPerformSmiOperation(SMI_OPERATION_PACKETS *SmiOperationRequest, BOOLEAN ApplyFromVmxRootMode)
Perform actions related to System Management Interrupts (SMIs).
Definition Export.c:1140
IMPORT_EXPORT_VMM UINT64 VmFuncGetLastVmexitRip(UINT32 CoreId)
get the last vm-exit RIP
Definition Export.c:363
UINT32 RegisterId
Definition RequestStructures.h:1617
UINT32 KernelStatus
Definition RequestStructures.h:1619
UINT64 Value
Definition RequestStructures.h:1632
UINT32 RegisterId
Definition RequestStructures.h:1631
UINT32 KernelStatus
Definition RequestStructures.h:1633
UINT32 CountOfResults
Definition RequestStructures.h:1604
UINT32 Result
Definition RequestStructures.h:1605
UINT32 Result
Definition RequestStructures.h:1588
BOOLEAN IsCurrentInstructionACall
Definition RequestStructures.h:1068
UINT32 CallLength
Definition RequestStructures.h:1069
DEBUGGER_REMOTE_STEPPING_REQUEST StepType
Definition RequestStructures.h:1062
UINT32 CommandLen
Definition DataTypes.h:174
UINT32 Size
Definition RequestStructures.h:847
UINT32 KernelStatus
Definition RequestStructures.h:845
UINT32 FrameCount
Definition RequestStructures.h:848
BOOLEAN Is32Bit
Definition RequestStructures.h:844
UINT64 BaseAddress
Definition RequestStructures.h:849
UINT32 KernelStatus
Definition RequestStructures.h:301
UINT32 ReturnLength
Definition RequestStructures.h:300
DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedActionOfThePacket
Definition Connection.h:201
DEBUGGER_REMOTE_PACKET_TYPE TypeOfThePacket
Definition Connection.h:200
BYTE Checksum
Definition Connection.h:198
UINT64 Indicator
Definition Connection.h:199
UINT64 Length
Definition RequestStructures.h:548
UINT64 Address
Definition RequestStructures.h:547
GUEST_REGS * Regs
Definition State.h:167
CHAR KdRecvBuffer[MaxSerialPacketSize]
Definition State.h:186
BOOLEAN IgnoreDisasmInNextPacket
Definition State.h:170
struct for extra registers
Definition BasicTypes.h:208
Definition BasicTypes.h:136
UINT64 rsp
Definition BasicTypes.h:145