1 | /* $Id: VBoxGuestR3LibGR.cpp 6470 2008-01-24 07:09:56Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, GR.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 innotek GmbH
|
---|
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 |
|
---|
18 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | #include <iprt/mem.h>
|
---|
23 | #include <iprt/assert.h>
|
---|
24 | #include <iprt/string.h>
|
---|
25 | #include <iprt/err.h>
|
---|
26 | #include <VBox/VBoxGuest.h>
|
---|
27 | #include "VBGLR3Internal.h"
|
---|
28 |
|
---|
29 |
|
---|
30 | int vbglR3GRAlloc(VMMDevRequestHeader **ppReq, uint32_t cb, VMMDevRequestType enmReqType)
|
---|
31 | {
|
---|
32 | VMMDevRequestHeader *pReq;
|
---|
33 |
|
---|
34 | AssertPtrReturn(ppReq, VERR_INVALID_PARAMETER);
|
---|
35 | AssertMsgReturn(cb >= sizeof(VMMDevRequestHeader), ("%#x vs %#zx\n", cb, sizeof(VMMDevRequestHeader)),
|
---|
36 | VERR_INVALID_PARAMETER);
|
---|
37 |
|
---|
38 | pReq = (VMMDevRequestHeader *)RTMemTmpAlloc(cb);
|
---|
39 | if (RT_UNLIKELY(!pReq))
|
---|
40 | return VERR_NO_MEMORY;
|
---|
41 |
|
---|
42 | pReq->size = cb;
|
---|
43 | pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
|
---|
44 | pReq->requestType = enmReqType;
|
---|
45 | pReq->rc = VERR_GENERAL_FAILURE;
|
---|
46 | pReq->reserved1 = 0;
|
---|
47 | pReq->reserved2 = 0;
|
---|
48 |
|
---|
49 | *ppReq = pReq;
|
---|
50 |
|
---|
51 | return VINF_SUCCESS;
|
---|
52 | }
|
---|
53 |
|
---|
54 |
|
---|
55 | VBGLR3DECL(int) vbglR3GRPerform(VMMDevRequestHeader *pReq)
|
---|
56 | {
|
---|
57 | return vbglR3DoIOCtl(VBOXGUEST_IOCTL_VMMREQUEST(pReq->size), pReq, pReq->size);
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | void vbglR3GRFree(VMMDevRequestHeader *pReq)
|
---|
62 | {
|
---|
63 | RTMemTmpFree(pReq);
|
---|
64 | }
|
---|
65 |
|
---|