Changeset 86244 in vbox
- Timestamp:
- Sep 23, 2020 3:35:16 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCRemoteKd.cpp
r86235 r86244 51 51 /** NT status code - Success. */ 52 52 #define NTSTATUS_SUCCESS 0 53 /** NT status code - buffer overflow. */ 54 #define NTSTATUS_BUFFER_OVERFLOW UINT32_C(0x80000005) 53 55 /** NT status code - operation unsuccesful. */ 54 56 #define NTSTATUS_UNSUCCESSFUL UINT32_C(0xc0000001) 55 57 /** NT status code - operation not implemented. */ 56 58 #define NTSTATUS_NOT_IMPLEMENTED UINT32_C(0xc0000002) 59 /** NT status code - Object not found. */ 60 #define NTSTATUS_NOT_FOUND UINT32_C(0xc0000225) 57 61 58 62 /** Offset where the KD version block pointer is stored in the KPCR. … … 970 974 971 975 /** 976 * Search memory payload. 977 */ 978 typedef struct KDPACKETMANIPULATE_SEARCHMEMORY 979 { 980 /** The address to start searching at on input, found address on output. */ 981 uint64_t u64GCPtr; 982 /** Number of bytes to search. */ 983 uint64_t cbSearch; 984 /** Length of the pattern to search for following the payload. */ 985 uint32_t cbPattern; 986 /** Padding to the required size. */ 987 uint32_t au32Pad[5]; 988 } KDPACKETMANIPULATE_SEARCHMEMORY; 989 AssertCompileSize(KDPACKETMANIPULATE_SEARCHMEMORY, 40); 990 /** Pointer to a search memory properties payload. */ 991 typedef KDPACKETMANIPULATE_SEARCHMEMORY *PKDPACKETMANIPULATE_SEARCHMEMORY; 992 /** Pointer to a const search memory properties payload. */ 993 typedef const KDPACKETMANIPULATE_SEARCHMEMORY *PCKDPACKETMANIPULATE_SEARCHMEMORY; 994 995 996 /** 972 997 * Manipulate request packet header (Same for 32bit and 64bit). 973 998 */ … … 1022 1047 /** Query memory. */ 1023 1048 KDPACKETMANIPULATE_QUERYMEMORY QueryMemory; 1049 /** Search memory. */ 1050 KDPACKETMANIPULATE_SEARCHMEMORY SearchMemory; 1024 1051 } u; 1025 1052 } KDPACKETMANIPULATE64; … … 1087 1114 #define KD_PACKET_MANIPULATE_REQ_CAUSE_BUGCHECK UINT32_C(0x00003149) 1088 1115 /** @todo */ 1116 /** Search memory for a pattern request. */ 1117 #define KD_PACKET_MANIPULATE_REQ_SEARCH_MEMORY UINT32_C(0x00003156) 1118 /** @todo */ 1089 1119 /** Clear all internal breakpoints request. */ 1090 1120 #define KD_PACKET_MANIPULATE_REQ_CLEAR_ALL_INTERNAL_BKPT UINT32_C(0x0000315a) … … 1282 1312 case KD_PACKET_MANIPULATE_REQ_QUERY_MEMORY: return "QueryMemory"; 1283 1313 case KD_PACKET_MANIPULATE_REQ_CAUSE_BUGCHECK: return "CauseBugCheck"; 1314 case KD_PACKET_MANIPULATE_REQ_SEARCH_MEMORY: return "SearchMemory"; 1284 1315 default: break; 1285 1316 } … … 1417 1448 break; 1418 1449 } 1450 case KD_PACKET_MANIPULATE_REQ_SEARCH_MEMORY: 1451 { 1452 KDPACKETMANIPULATE_SEARCHMEMORY SearchMemory; 1453 cbCopied = RTSgBufCopyToBuf(pSgBuf, &SearchMemory, sizeof(SearchMemory)); 1454 if (cbCopied == sizeof(SearchMemory)) 1455 { 1456 Log3((" u64GCPtr: %RX64\n" 1457 " cbSearch: %RX64\n" 1458 " cbPattern: %RX32\n", 1459 SearchMemory.u64GCPtr, SearchMemory.cbSearch, SearchMemory.cbPattern)); 1460 } 1461 else 1462 Log3((" Payload to small, expected %u, got %zu\n", sizeof(SearchMemory), cbCopied)); 1463 break; 1464 } 1419 1465 default: 1420 1466 break; … … 3282 3328 3283 3329 /** 3330 * Processes a search memory 64 request. 3331 * 3332 * @returns VBox status code. 3333 * @param pThis The KD context. 3334 * @param pPktManip The manipulate packet request. 3335 */ 3336 static int dbgcKdCtxPktManipulate64SearchMemory(PKDCTX pThis, PCKDPACKETMANIPULATE64 pPktManip) 3337 { 3338 KDPACKETMANIPULATEHDR RespHdr; 3339 KDPACKETMANIPULATE_SEARCHMEMORY SearchMemory; 3340 RT_ZERO(RespHdr); RT_ZERO(SearchMemory); 3341 3342 RTSGSEG aRespSegs[2]; 3343 RespHdr.idReq = KD_PACKET_MANIPULATE_REQ_SEARCH_MEMORY; 3344 RespHdr.u16CpuLvl = pPktManip->Hdr.u16CpuLvl; 3345 RespHdr.idCpu = pPktManip->Hdr.idCpu; 3346 RespHdr.u32NtStatus = NTSTATUS_SUCCESS; 3347 3348 SearchMemory.u64GCPtr = pPktManip->u.SearchMemory.u64GCPtr; 3349 SearchMemory.cbSearch = pPktManip->u.SearchMemory.cbSearch; 3350 SearchMemory.cbPattern = pPktManip->u.SearchMemory.cbPattern; 3351 3352 /* Validate the pattern length and start searching. */ 3353 if (pPktManip->u.SearchMemory.cbPattern < sizeof(pThis->abBody) - sizeof(*pPktManip)) 3354 { 3355 DBGFADDRESS StartAddress; 3356 DBGFADDRESS HitAddress; 3357 VMCPUID idCpu = pPktManip->Hdr.idCpu; 3358 DBGFR3AddrFromFlat(pThis->Dbgc.pUVM, &StartAddress, pPktManip->u.SearchMemory.u64GCPtr); 3359 3360 /** @todo WindDbg sends CPU ID 32 sometimes, maybe that means continue search on last used CPU?. */ 3361 if (idCpu >= DBGFR3CpuGetCount(pThis->Dbgc.pUVM)) 3362 idCpu = pThis->Dbgc.idCpu; 3363 3364 int rc = DBGFR3MemScan(pThis->Dbgc.pUVM, idCpu, &StartAddress, pPktManip->u.SearchMemory.cbSearch, 1, 3365 &pThis->abBody[sizeof(*pPktManip)], pPktManip->u.SearchMemory.cbPattern, &HitAddress); 3366 if (RT_SUCCESS(rc)) 3367 SearchMemory.u64GCPtr = HitAddress.FlatPtr; 3368 else if (rc == VERR_DBGF_MEM_NOT_FOUND) 3369 RespHdr.u32NtStatus = NTSTATUS_NOT_FOUND; 3370 else 3371 RespHdr.u32NtStatus = NTSTATUS_UNSUCCESSFUL; 3372 } 3373 else 3374 RespHdr.u32NtStatus = NTSTATUS_BUFFER_OVERFLOW; 3375 3376 aRespSegs[0].pvSeg = &RespHdr; 3377 aRespSegs[0].cbSeg = sizeof(RespHdr); 3378 aRespSegs[1].pvSeg = &SearchMemory; 3379 aRespSegs[1].cbSeg = sizeof(SearchMemory); 3380 3381 return dbgcKdCtxPktSendSg(pThis, KD_PACKET_HDR_SIGNATURE_DATA, KD_PACKET_HDR_SUB_TYPE_STATE_MANIPULATE, 3382 &aRespSegs[0], RT_ELEMENTS(aRespSegs), true /*fAck*/); 3383 } 3384 3385 3386 /** 3284 3387 * Processes a cause bugcheck 64 request. 3285 3388 * … … 3376 3479 { 3377 3480 rc = dbgcKdCtxPktManipulate64QueryMemory(pThis, pPktManip); 3481 break; 3482 } 3483 case KD_PACKET_MANIPULATE_REQ_SEARCH_MEMORY: 3484 { 3485 rc = dbgcKdCtxPktManipulate64SearchMemory(pThis, pPktManip); 3378 3486 break; 3379 3487 }
Note:
See TracChangeset
for help on using the changeset viewer.