1 | /* $Id: svchlp.h 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Declaration of SVC Helper Process control routines.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 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 | #ifndef MAIN_INCLUDED_SRC_src_server_win_svchlp_h
|
---|
19 | #define MAIN_INCLUDED_SRC_src_server_win_svchlp_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "VBox/com/string.h"
|
---|
25 | #include "VBox/com/guid.h"
|
---|
26 |
|
---|
27 | #include <VBox/err.h>
|
---|
28 |
|
---|
29 | #include <iprt/win/windows.h>
|
---|
30 |
|
---|
31 | struct SVCHlpMsg
|
---|
32 | {
|
---|
33 | enum Code
|
---|
34 | {
|
---|
35 | Null = 0, /* no parameters */
|
---|
36 | OK, /* no parameters */
|
---|
37 | Error, /* Utf8Str string (may be null but must present) */
|
---|
38 |
|
---|
39 | CreateHostOnlyNetworkInterface = 100, /* see usage in code */
|
---|
40 | CreateHostOnlyNetworkInterface_OK, /* see usage in code */
|
---|
41 | RemoveHostOnlyNetworkInterface, /* see usage in code */
|
---|
42 | EnableDynamicIpConfig, /* see usage in code */
|
---|
43 | EnableStaticIpConfig, /* see usage in code */
|
---|
44 | EnableStaticIpConfigV6, /* see usage in code */
|
---|
45 | DhcpRediscover, /* see usage in code */
|
---|
46 | };
|
---|
47 | };
|
---|
48 |
|
---|
49 | class SVCHlpClient
|
---|
50 | {
|
---|
51 | public:
|
---|
52 |
|
---|
53 | SVCHlpClient();
|
---|
54 | virtual ~SVCHlpClient();
|
---|
55 |
|
---|
56 | int create (const char *aName);
|
---|
57 | int connect();
|
---|
58 | int open (const char *aName);
|
---|
59 | int close();
|
---|
60 |
|
---|
61 | bool isOpen() const { return mIsOpen; }
|
---|
62 | bool isServer() const { return mIsServer; }
|
---|
63 | const com::Utf8Str &name() const { return mName; }
|
---|
64 |
|
---|
65 | int write (const void *aVal, size_t aLen);
|
---|
66 | template <typename Scalar>
|
---|
67 | int write (Scalar aVal) { return write (&aVal, sizeof (aVal)); }
|
---|
68 | int write (const com::Utf8Str &aVal);
|
---|
69 | int write (const com::Guid &aGuid);
|
---|
70 |
|
---|
71 | int read (void *aVal, size_t aLen);
|
---|
72 | template <typename Scalar>
|
---|
73 | int read (Scalar &aVal) { return read (&aVal, sizeof (aVal)); }
|
---|
74 | int read (com::Utf8Str &aVal);
|
---|
75 | int read (com::Guid &aGuid);
|
---|
76 |
|
---|
77 | private:
|
---|
78 |
|
---|
79 | bool mIsOpen : 1;
|
---|
80 | bool mIsServer : 1;
|
---|
81 |
|
---|
82 | HANDLE mReadEnd;
|
---|
83 | HANDLE mWriteEnd;
|
---|
84 | com::Utf8Str mName;
|
---|
85 | };
|
---|
86 |
|
---|
87 | class SVCHlpServer : public SVCHlpClient
|
---|
88 | {
|
---|
89 | public:
|
---|
90 |
|
---|
91 | SVCHlpServer();
|
---|
92 |
|
---|
93 | int run();
|
---|
94 | };
|
---|
95 |
|
---|
96 | #endif /* !MAIN_INCLUDED_SRC_src_server_win_svchlp_h */
|
---|
97 |
|
---|