VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/nt/memuserkernel-r0drv-nt.cpp@ 32736

Last change on this file since 32736 was 29705, checked in by vboxsync, 15 years ago

build fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1/* $Id: memuserkernel-r0drv-nt.cpp 29705 2010-05-20 15:58:39Z vboxsync $ */
2/** @file
3 * IPRT - User & Kernel Memory, Ring-0 Driver, NT.
4 */
5
6/*
7 * Copyright (C) 2009 Oracle Corporation
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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include "the-nt-kernel.h"
32
33#include <iprt/mem.h>
34#include <iprt/err.h>
35
36
37RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb)
38{
39 __try
40 {
41 ProbeForRead((PVOID)R3PtrSrc, cb, 1);
42 memcpy(pvDst, (void const *)R3PtrSrc, cb);
43 }
44 __except(EXCEPTION_EXECUTE_HANDLER)
45 {
46 return VERR_ACCESS_DENIED;
47 }
48 return VINF_SUCCESS;
49}
50
51
52RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb)
53{
54 __try
55 {
56 ProbeForWrite((PVOID)R3PtrDst, cb, 1);
57 memcpy((void *)R3PtrDst, pvSrc, cb);
58 }
59 __except(EXCEPTION_EXECUTE_HANDLER)
60 {
61 return VERR_ACCESS_DENIED;
62 }
63 return VINF_SUCCESS;
64}
65
66
67RTR0DECL(bool) RTR0MemUserIsValidAddr(RTR3PTR R3Ptr)
68{
69#ifdef IPRT_TARGET_NT4
70 /* Play safe+wrong... it used to be a constant, but in w2k+ is a variable. */
71 return R3Ptr < _2G;
72#else
73 return R3Ptr <= (uintptr_t)MM_HIGHEST_USER_ADDRESS;
74#endif
75}
76
77
78RTR0DECL(bool) RTR0MemKernelIsValidAddr(void *pv)
79{
80#ifdef IPRT_TARGET_NT4
81 /* Play safe+wrong... it used to be a constant, but in w2k+ is a variable. */
82 return (uintptr_t)pv >= _2G;
83#else
84 return (uintptr_t)pv >= (uintptr_t)MM_SYSTEM_RANGE_START;
85#endif
86}
87
88
89RTR0DECL(bool) RTR0MemAreKrnlAndUsrDifferent(void)
90{
91 return true;
92}
93
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