VirtualBox

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

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

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1/* $Id: DBGFMem.cpp 8155 2008-04-18 15:16:47Z vboxsync $ */
2/** @file
3 * VMM DBGF - Debugger Facility, Memory Methods.
4 */
5
6/*
7 * Copyright (C) 2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#define LOG_GROUP LOG_GROUP_DBGF
27#include <VBox/dbgf.h>
28#include <VBox/pgm.h>
29#include "DBGFInternal.h"
30#include <VBox/vm.h>
31#include <VBox/err.h>
32#include <VBox/log.h>
33
34
35
36/**
37 * Scan guest memory for an exact byte string.
38 *
39 * @returns VBox status code.
40 * @param pVM The VM handle.
41 * @param pAddress Where to store the mixed address.
42 * @param cbRange The number of bytes to scan.
43 * @param pabNeedle What to search for - exact search.
44 * @param cbNeedle Size of the search byte string.
45 * @param pHitAddress Where to put the address of the first hit.
46 */
47static DECLCALLBACK(int) dbgfR3MemScan(PVM pVM, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle,
48 PDBGFADDRESS pHitAddress)
49{
50 /*
51 * Validate the input we use, PGM does the rest.
52 */
53 if (!DBGFR3AddrIsValid(pVM, pAddress))
54 return VERR_INVALID_POINTER;
55 if (!VALID_PTR(pHitAddress))
56 return VERR_INVALID_POINTER;
57 if (DBGFADDRESS_IS_HMA(pAddress))
58 return VERR_INVALID_POINTER;
59
60 /*
61 * Select DBGF worker by addressing mode.
62 */
63 int rc;
64 PGMMODE enmMode = PGMGetGuestMode(pVM);
65 if ( enmMode == PGMMODE_REAL
66 || enmMode == PGMMODE_PROTECTED
67 || DBGFADDRESS_IS_PHYS(pAddress)
68 )
69 {
70 RTGCPHYS PhysHit;
71 rc = PGMR3DbgScanPhysical(pVM, pAddress->FlatPtr, cbRange, pabNeedle, cbNeedle, &PhysHit);
72 if (RT_SUCCESS(rc))
73 DBGFR3AddrFromPhys(pVM, pHitAddress, PhysHit);
74 }
75 else
76 {
77 RTGCUINTPTR GCPtrHit;
78 rc = PGMR3DbgScanVirtual(pVM, pAddress->FlatPtr, cbRange, pabNeedle, cbNeedle, &GCPtrHit);
79 if (RT_SUCCESS(rc))
80 DBGFR3AddrFromFlat(pVM, pHitAddress, GCPtrHit);
81 }
82
83 return rc;
84}
85
86
87/**
88 * Scan guest memory for an exact byte string.
89 *
90 * @returns VBox status codes:
91 * @retval VINF_SUCCESS and *pGCPtrHit on success.
92 * @retval VERR_DBGF_MEM_NOT_FOUND if not found.
93 * @retval VERR_INVALID_POINTER if any of the pointer arguments are invalid.
94 * @retval VERR_INVALID_ARGUMENT if any other arguments are invalid.
95 *
96 * @param pVM The VM handle.
97 * @param pAddress Where to store the mixed address.
98 * @param cbRange The number of bytes to scan.
99 * @param pabNeedle What to search for - exact search.
100 * @param cbNeedle Size of the search byte string.
101 * @param pHitAddress Where to put the address of the first hit.
102 *
103 * @thread Any thread.
104 */
105DBGFR3DECL(int) DBGFR3MemScan(PVM pVM, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress)
106{
107 PVMREQ pReq;
108 int rc = VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT, (PFNRT)dbgfR3MemScan, 6,
109 pVM, pAddress, cbRange, pabNeedle, cbNeedle, pHitAddress);
110 if (VBOX_SUCCESS(rc))
111 rc = pReq->iStatus;
112 VMR3ReqFree(pReq);
113
114 return rc;
115}
116
117
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