1 | /** @file
|
---|
2 | *
|
---|
3 | * tstSessionHack
|
---|
4 | *
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 | #define _WIN32_WINNT 0x0500
|
---|
23 | #include <windows.h>
|
---|
24 | #include <VBox/VBoxDev.h>
|
---|
25 | #include <VBox/VBoxGuest.h>
|
---|
26 | #include <VBoxGuestInternal.h>
|
---|
27 | #include <iprt/assert.h>
|
---|
28 | #include <stdio.h>
|
---|
29 |
|
---|
30 | void main(int argc, char *argv[])
|
---|
31 | {
|
---|
32 | DWORD cbReturned;
|
---|
33 | DWORD status = NO_ERROR;
|
---|
34 | HANDLE gVBoxDriver;
|
---|
35 |
|
---|
36 | /* open VBox guest driver */
|
---|
37 | gVBoxDriver = CreateFile(VBOXGUEST_DEVICE_NAME,
|
---|
38 | GENERIC_READ | GENERIC_WRITE,
|
---|
39 | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
---|
40 | NULL,
|
---|
41 | OPEN_EXISTING,
|
---|
42 | FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
|
---|
43 | NULL);
|
---|
44 | if (gVBoxDriver == INVALID_HANDLE_VALUE)
|
---|
45 | {
|
---|
46 | printf("Could not open VBox Guest Additions driver! rc = %d\n", GetLastError());
|
---|
47 | return;
|
---|
48 | }
|
---|
49 |
|
---|
50 | if (argc == 1)
|
---|
51 | printf("Installing session hack\n");
|
---|
52 | else
|
---|
53 | printf("Removing session hack\n");
|
---|
54 |
|
---|
55 | if (!DeviceIoControl (gVBoxDriver, (argc == 1) ? IOCTL_VBOXGUEST_ENABLE_VRDP_SESSION : IOCTL_VBOXGUEST_DISABLE_VRDP_SESSION, NULL, 0, NULL, 0, &cbReturned, NULL))
|
---|
56 | {
|
---|
57 | printf("VBoxRestoreThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n");
|
---|
58 | }
|
---|
59 | CloseHandle(gVBoxDriver);
|
---|
60 | }
|
---|
61 |
|
---|