VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxMMR.cpp@ 42295

Last change on this file since 42295 was 42295, checked in by vboxsync, 12 years ago

two missing files in OSE.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/* $Id: VBoxMMR.cpp 42295 2012-07-21 00:19:53Z vboxsync $ */
2/** @file
3 * VBoxMMR - Multimedia Redirection
4 */
5
6/*
7 * Copyright (C) 2012 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
18#include "VBoxTray.h"
19#include "VBoxMMR.h"
20
21struct VBOXMMRCONTEXT
22{
23 HINSTANCE hMod;
24 HHOOK hHook;
25};
26
27static VBOXMMRCONTEXT gCtx = {0};
28
29static const char *g_pszMMRDLL = "VBoxMMRHook";
30static const char *g_pszMMRPROC = "CBTProc";
31
32void VBoxMMRCleanup(VBOXMMRCONTEXT *pCtx)
33{
34 if (NULL != pCtx->hHook)
35 {
36 UnhookWindowsHookEx(pCtx->hHook);
37 }
38
39 if (pCtx->hMod)
40 {
41 FreeLibrary(pCtx->hMod);
42 }
43
44 return;
45}
46
47int VBoxMMRInit(
48 const VBOXSERVICEENV *pEnv,
49 void **ppInstance,
50 bool *pfStartThread)
51{
52 HOOKPROC pHook = NULL;
53
54 LogRel2(("VBoxMMR: Initializing\n"));
55
56 gCtx.hMod = LoadLibraryA(g_pszMMRDLL);
57 if (NULL == gCtx.hMod)
58 {
59 LogRel2(("VBoxMMR: Hooking library not found\n"));
60 VBoxMMRCleanup(&gCtx);
61 return VERR_NOT_FOUND;
62 }
63
64 pHook = (HOOKPROC) GetProcAddress(gCtx.hMod, g_pszMMRPROC);
65 if (NULL == pHook)
66 {
67 LogRel2(("VBoxMMR: Hooking proc not found\n"));
68 VBoxMMRCleanup(&gCtx);
69 return VERR_NOT_FOUND;
70 }
71
72 gCtx.hHook = SetWindowsHookEx(WH_CBT, pHook, gCtx.hMod, 0);
73 if (NULL == gCtx.hHook)
74 {
75 int rc = RTErrConvertFromWin32(GetLastError());
76 LogRel2(("VBoxMMR: Error installing hooking proc: %d\n", rc));
77 VBoxMMRCleanup(&gCtx);
78 return rc;
79 }
80
81 *ppInstance = &gCtx;
82
83 return VINF_SUCCESS;
84}
85
86void VBoxMMRDestroy(const VBOXSERVICEENV *pEnv, void *pInstance)
87{
88 VBOXMMRCONTEXT *pCtx = (VBOXMMRCONTEXT *) pInstance;
89
90 VBoxMMRCleanup(pCtx);
91}
92
93unsigned __stdcall VBoxMMRThread(void *pInstance)
94{
95 return 0;
96}
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