1 | /* $Id: dllmain.cpp 48944 2013-10-07 21:32:37Z 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 "stdafx.h"
|
---|
19 | #include "tsmfhook.h"
|
---|
20 | #include "logging.h"
|
---|
21 |
|
---|
22 | #include <Winternl.h>
|
---|
23 | #include <iprt/initterm.h>
|
---|
24 | #include <VBox/VBoxGuestLib.h>
|
---|
25 |
|
---|
26 | bool isWMP = false;
|
---|
27 |
|
---|
28 | BOOL APIENTRY DllMain( HMODULE hModule,
|
---|
29 | DWORD ul_reason_for_call,
|
---|
30 | LPVOID lpReserved
|
---|
31 | )
|
---|
32 | {
|
---|
33 | switch (ul_reason_for_call)
|
---|
34 | {
|
---|
35 | case DLL_PROCESS_ATTACH:
|
---|
36 |
|
---|
37 | DisableThreadLibraryCalls(hModule);
|
---|
38 |
|
---|
39 | {
|
---|
40 | CHAR buffer[MAX_PATH];
|
---|
41 | GetModuleFileNameA(NULL, buffer, sizeof(buffer));
|
---|
42 | const PCHAR pc = strrchr(buffer, '\\');
|
---|
43 | isWMP = (0 == strcmp(pc + 1, "wmplayer.exe"));
|
---|
44 |
|
---|
45 | if (isWMP)
|
---|
46 | {
|
---|
47 | RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
|
---|
48 | VbglR3Init();
|
---|
49 | VBoxMMRHookLog("VBoxMMR: Hooking wmplayer process\n");
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | case DLL_THREAD_ATTACH:
|
---|
54 | case DLL_THREAD_DETACH:
|
---|
55 | break;
|
---|
56 | case DLL_PROCESS_DETACH:
|
---|
57 | Shutdown();
|
---|
58 | if (isWMP)
|
---|
59 | {
|
---|
60 | VBoxMMRHookLog("VBoxMMR: Unhooking wmplayer process\n");
|
---|
61 | VbglR3Term();
|
---|
62 | }
|
---|
63 | break;
|
---|
64 | }
|
---|
65 | return TRUE;
|
---|
66 | }
|
---|