VirtualBox

source: vbox/trunk/src/VBox/VMM/DBGFMem.cpp@ 5999

Last change on this file since 5999 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1/* $Id: DBGFMem.cpp 5999 2007-12-07 15:05:06Z vboxsync $ */
2/** @file
3 * VMM DBGF - Debugger Facility, Memory Methods.
4 */
5
6/*
7 * Copyright (C) 2007 innotek GmbH
8 *
9 * innotek GmbH confidential
10 * All rights reserved
11 */
12
13
14/*******************************************************************************
15* Header Files *
16*******************************************************************************/
17#define LOG_GROUP LOG_GROUP_DBGF
18#include <VBox/dbgf.h>
19#include <VBox/pgm.h>
20#include "DBGFInternal.h"
21#include <VBox/vm.h>
22#include <VBox/err.h>
23#include <VBox/log.h>
24
25
26
27/**
28 * Scan guest memory for an exact byte string.
29 *
30 * @returns VBox status code.
31 * @param pVM The VM handle.
32 * @param pAddress Where to store the mixed address.
33 * @param cbRange The number of bytes to scan.
34 * @param pabNeedle What to search for - exact search.
35 * @param cbNeedle Size of the search byte string.
36 * @param pHitAddress Where to put the address of the first hit.
37 */
38static DECLCALLBACK(int) dbgfR3MemScan(PVM pVM, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle,
39 PDBGFADDRESS pHitAddress)
40{
41 /*
42 * Validate the input we use, PGM does the rest.
43 */
44 if (!DBGFR3AddrIsValid(pVM, pAddress))
45 return VERR_INVALID_POINTER;
46 if (!VALID_PTR(pHitAddress))
47 return VERR_INVALID_POINTER;
48 if (DBGFADDRESS_IS_HMA(pAddress))
49 return VERR_INVALID_POINTER;
50
51 /*
52 * Select DBGF worker by addressing mode.
53 */
54 int rc;
55 PGMMODE enmMode = PGMGetGuestMode(pVM);
56 if ( enmMode == PGMMODE_REAL
57 || enmMode == PGMMODE_PROTECTED
58 || DBGFADDRESS_IS_PHYS(pAddress)
59 )
60 {
61 RTGCPHYS PhysHit;
62 rc = PGMR3DbgScanPhysical(pVM, pAddress->FlatPtr, cbRange, pabNeedle, cbNeedle, &PhysHit);
63 if (RT_SUCCESS(rc))
64 DBGFR3AddrFromPhys(pVM, pHitAddress, PhysHit);
65 }
66 else
67 {
68 RTGCUINTPTR GCPtrHit;
69 rc = PGMR3DbgScanVirtual(pVM, pAddress->FlatPtr, cbRange, pabNeedle, cbNeedle, &GCPtrHit);
70 if (RT_SUCCESS(rc))
71 DBGFR3AddrFromFlat(pVM, pHitAddress, GCPtrHit);
72 }
73
74 return rc;
75}
76
77
78/**
79 * Scan guest memory for an exact byte string.
80 *
81 * @returns VBox status codes:
82 * @retval VINF_SUCCESS and *pGCPtrHit on success.
83 * @retval VERR_DBGF_MEM_NOT_FOUND if not found.
84 * @retval VERR_INVALID_POINTER if any of the pointer arguments are invalid.
85 * @retval VERR_INVALID_ARGUMENT if any other arguments are invalid.
86 *
87 * @param pVM The VM handle.
88 * @param pAddress Where to store the mixed address.
89 * @param cbRange The number of bytes to scan.
90 * @param pabNeedle What to search for - exact search.
91 * @param cbNeedle Size of the search byte string.
92 * @param pHitAddress Where to put the address of the first hit.
93 *
94 * @thread Any thread.
95 */
96DBGFR3DECL(int) DBGFR3MemScan(PVM pVM, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress)
97{
98 PVMREQ pReq;
99 int rc = VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT, (PFNRT)dbgfR3MemScan, 6,
100 pVM, pAddress, cbRange, pabNeedle, cbNeedle, pHitAddress);
101 if (VBOX_SUCCESS(rc))
102 rc = pReq->iStatus;
103 VMR3ReqFree(pReq);
104
105 return rc;
106}
107
108
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette