Handle #DBs and #BPs for kernel debugger. 
  446{
  448    ULONG                               ExitInstructionLength   = 0;
 
  449    UINT32                              SizeOfSafeBufferToRead  = 0;
 
  450    RFLAGS                              Rflags                  = {0};
  454 
  455    
  456    
  457    
  458    
  460    {
  462    }
  463 
  464    
  465    
  466    
  468 
  469    if (!ProcessDebuggingDetails)
  470    {
  471        
  472        
  473        
  475    }
  476 
  477    
  478    
  479    
  481 
  482    if (!ThreadDebuggingDetails)
  483    {
  484        
  485        
  486        
  488    }
  489 
  490    
  491    
  492    
  494 
  495    
  496    
  497    
  499 
  500    
  501    
  502    
  503 
  505 
  506    
  507    
  508    
  510 
  511    
  512    
  513    
  517 
  518    
  519    
  520    
  521    PausePacket.
Rip     = LastVmexitRip;
 
  523 
  524    
  525    
  526    
  528    PausePacket.
Rflags = Rflags.AsUInt;
 
  529 
  530    
  531    
  532    
  533    if (EventDetails != NULL)
  534    {
  537    }
  538 
  539    
  540    
  541    
  543    {
  545    }
  546    else
  547    {
  548        
  549        
  550        
  551        
  552 
  553        
  554        
  555        
  556        SizeOfSafeBufferToRead = (
UINT32)(LastVmexitRip & 0xfff);
 
  558 
  560        {
  561            SizeOfSafeBufferToRead = SizeOfSafeBufferToRead - 
PAGE_SIZE;
 
  563        }
  564        else
  565        {
  567        }
  568 
  569        
  570        
  571        
  572        ExitInstructionLength = SizeOfSafeBufferToRead;
  573    }
  574 
  575    
  576    
  577    
  579 
  580    
  581    
  582    
  585                                              ExitInstructionLength);
  586 
  587    
  588    
  589    
  591 
  592    
  593    
  594    
  595    
  597                          &PausePacket,
  600 
  601    
  602    
  603    
  605 
  606    
  607    
  608    
  610}
PUSERMODE_DEBUGGING_PROCESS_DETAILS AttachingFindProcessDebuggingDetailsByProcessId(UINT32 ProcessId)
Find user-mode debugging details for threads by process Id.
Definition Attaching.c:187
unsigned short UINT16
Definition BasicTypes.h:47
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned int UINT32
Definition BasicTypes.h:48
unsigned long ULONG
Definition BasicTypes.h:37
BOOLEAN LogCallbackSendBuffer(_In_ UINT32 OperationCode, _In_reads_bytes_(BufferLength) PVOID Buffer, _In_ UINT32 BufferLength, _In_ BOOLEAN Priority)
routines callback for sending buffer
Definition Callback.c:123
#define OPERATION_NOTIFICATION_FROM_USER_DEBUGGER_PAUSE
Definition Constants.h:387
#define MAXIMUM_INSTR_SIZE
maximum instruction size in Intel
Definition Constants.h:468
UINT64 VmFuncGetRflags()
Read guest's RFLAGS.
Definition Export.c:352
BOOLEAN VmFuncVmxGetCurrentExecutionMode()
Get the current VMX operation state.
Definition Export.c:552
UINT64 VmFuncGetLastVmexitRip(UINT32 CoreId)
get the last vm-exit RIP
Definition Export.c:318
BOOLEAN KdIsGuestOnUsermode32Bit()
determines if the guest was in 32-bit user-mode or 64-bit (long mode)
Definition Kd.c:3107
_Use_decl_annotations_ BOOLEAN MemoryMapperReadMemorySafeOnTargetProcess(UINT64 VaAddressToRead, PVOID BufferToSaveMemory, SIZE_T SizeToRead)
Read memory safely by mapping the buffer on the target process memory (It's a wrapper)
Definition MemoryMapper.c:1120
PUSERMODE_DEBUGGING_THREAD_DETAILS ThreadHolderFindOrCreateThreadDebuggingDetail(UINT32 ThreadId, PUSERMODE_DEBUGGING_PROCESS_DETAILS ProcessDebuggingDetail)
Find or create user-mode debugging details for threads.
Definition ThreadHolder.c:257
VOID UdSpinThreadOnNop(PUSERMODE_DEBUGGING_THREAD_DETAILS ThreadDebuggingDetails, PUSERMODE_DEBUGGING_PROCESS_DETAILS ProcessDebuggingDetails)
Spin on nop sled in user-mode to halt the debuggee.
Definition Ud.c:379
VOID UdPrePausingReasons(PROCESSOR_DEBUGGING_STATE *DbgState, PUSERMODE_DEBUGGING_THREAD_DETAILS ThreadDebuggingDetails, DEBUGGEE_PAUSING_REASON Reason, PDEBUGGER_TRIGGERED_EVENT_DETAILS EventDetails)
Handle special reasons pre-pausings.
Definition Ud.c:409
NULL()
Definition test-case-generator.py:530
The structure of pausing packet in uHyperDbg.
Definition DataTypes.h:229
GUEST_REGS GuestRegs
Definition DataTypes.h:241
DEBUGGEE_PAUSING_REASON PausingReason
Definition DataTypes.h:233
UINT16 ReadInstructionLen
Definition DataTypes.h:240
UINT64 Rip
Definition DataTypes.h:230
VMM_CALLBACK_EVENT_CALLING_STAGE_TYPE EventCallingStage
Definition DataTypes.h:238
BOOLEAN Is32Bit
Definition DataTypes.h:232
UINT64 ProcessDebuggingToken
Definition DataTypes.h:231
UINT64 EventTag
Definition DataTypes.h:237
UINT64 Rflags
Definition DataTypes.h:236
UINT32 ThreadId
Definition DataTypes.h:235
UINT32 ProcessId
Definition DataTypes.h:234
BYTE InstructionBytesOnRip[MAXIMUM_INSTR_SIZE]
Definition DataTypes.h:239
UINT64 Tag
Definition DataTypes.h:193
VMM_CALLBACK_EVENT_CALLING_STAGE_TYPE Stage
Definition DataTypes.h:195
GUEST_REGS * Regs
Definition State.h:168
UINT32 CoreId
Definition State.h:169
UINT16 InstructionLengthHint
Definition State.h:182
Description of each active thread in user-mode attaching mechanism.
Definition Attaching.h:49
UINT64 Token
Definition Attaching.h:50
UINT32 ActiveThreadId
Definition Attaching.h:53
Details of each thread in process.
Definition ThreadHolder.h:33
UINT32 ThreadId
Definition ThreadHolder.h:34
Definition BasicTypes.h:70