1 | /* $Id: VBoxWinDrvStore.h 106395 2024-10-16 16:27:03Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxWinDrvInst - Header for Windows driver store handling.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef VBOX_INCLUDED_GuestHost_VBoxWinDrvStore_h
|
---|
38 | #define VBOX_INCLUDED_GuestHost_VBoxWinDrvStore_h
|
---|
39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
40 | # pragma once
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #include <iprt/list.h>
|
---|
44 | #include <iprt/path.h>
|
---|
45 | #include <iprt/utf16.h>
|
---|
46 |
|
---|
47 | #include <VBox/GuestHost/VBoxWinDrvDefs.h>
|
---|
48 |
|
---|
49 | /** Maximum model PnP ID length (in characters). */
|
---|
50 | #define VBOXWINDRVSTORE_MAX_PNP_ID 255
|
---|
51 | /** Maximum model name length (in characters). */
|
---|
52 | #define VBOXWINDRVSTORE_MAX_MODEL_NAME 255
|
---|
53 | /** Maximum driver name length (in characters). */
|
---|
54 | #define VBOXWINDRVSTORE_MAX_DRIVER_NAME 255
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Structure for keeping a generic Windows driver store list.
|
---|
58 | */
|
---|
59 | typedef struct _VBOXWINDRVSTORELIST
|
---|
60 | {
|
---|
61 | /** List node. */
|
---|
62 | RTLISTANCHOR List;
|
---|
63 | /** Number of current entries of type VBOXWINDRVSTOREENTRY. */
|
---|
64 | size_t cEntries;
|
---|
65 | } VBOXWINDRVSTORELIST;
|
---|
66 | /** Pointer to a generic Windows driver store list. */
|
---|
67 | typedef VBOXWINDRVSTORELIST *PVBOXWINDRVSTORELIST;
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Structure for keeping a Windows driver store entry.
|
---|
71 | */
|
---|
72 | typedef struct _VBOXWINDRVSTOREENTRY
|
---|
73 | {
|
---|
74 | RTLISTNODE Node;
|
---|
75 | /** Version section information. */
|
---|
76 | VBOXWINDRVINFSEC_VERSION Ver;
|
---|
77 | /** Full path to the oemXXX.inf file within the driver store. */
|
---|
78 | RTUTF16 wszInfFile[RTPATH_MAX];
|
---|
79 | /** PnP ID of the driver.
|
---|
80 | * Only the first (valid) PnP ID is supported for now */
|
---|
81 | RTUTF16 wszPnpId[VBOXWINDRVSTORE_MAX_PNP_ID];
|
---|
82 | /** Model name of the driver.
|
---|
83 | * Only the first (valid) model name is supported for now */
|
---|
84 | RTUTF16 wszModel[VBOXWINDRVSTORE_MAX_MODEL_NAME];
|
---|
85 | /** Driver name (.sys).
|
---|
86 | * Only the first (valid) driver name is supported for now */
|
---|
87 | RTUTF16 wszDriverName[VBOXWINDRVSTORE_MAX_DRIVER_NAME];
|
---|
88 | } VBOXWINDRVSTOREENTRY;
|
---|
89 | /** Pointer to a Windows driver store entry. */
|
---|
90 | typedef VBOXWINDRVSTOREENTRY *PVBOXWINDRVSTOREENTRY;
|
---|
91 |
|
---|
92 | struct _VBOXWINDRVSTORE;
|
---|
93 | /** Pointer to Windows driver store instance data. */
|
---|
94 | typedef struct _VBOXWINDRVSTORE *PVBOXWINDRVSTORE;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Interface for a Windows driver store implementation.
|
---|
98 | */
|
---|
99 | typedef struct _VBOXWINDRVSTOREIFACE
|
---|
100 | {
|
---|
101 | /**
|
---|
102 | * Adds a driver to the driver store.
|
---|
103 | *
|
---|
104 | * @returns VBox status code.
|
---|
105 | * @param pThis Pointer to interface instance.
|
---|
106 | * @param pszInfFile Path of INF file to add.
|
---|
107 | *
|
---|
108 | * Optional and can be NULL.
|
---|
109 | */
|
---|
110 | DECLCALLBACKMEMBER(int, pfnDriverAdd,(PVBOXWINDRVSTORE pThis, const char *pszInfFile));
|
---|
111 | /**
|
---|
112 | * Removes a driver from the driver store.
|
---|
113 | *
|
---|
114 | * @returns VBox status code.
|
---|
115 | * @param pThis Pointer to interface instance.
|
---|
116 | * @param pszInfFile Path of INF file to remove.
|
---|
117 | *
|
---|
118 | * Optional and can be NULL.
|
---|
119 | */
|
---|
120 | DECLCALLBACKMEMBER(int, pfnDriverRemove,(PVBOXWINDRVSTORE pThis, const char *pszInfFile, bool fForce));
|
---|
121 | /**
|
---|
122 | * Performs (re-)enumeration of the driver store entries.
|
---|
123 | *
|
---|
124 | * @returns VBox status code.
|
---|
125 | * @param pThis Pointer to interface instance.
|
---|
126 | */
|
---|
127 | DECLCALLBACKMEMBER(int, pfnEnumerate,(PVBOXWINDRVSTORE pThis));
|
---|
128 | } VBOXWINDRVSTOREIFACE;
|
---|
129 | /** Pointer to a Windows driver store implementation. */
|
---|
130 | typedef VBOXWINDRVSTOREIFACE *PVBOXWINDRVSTOREIFACE;
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * Enumeration for a driver store backend.
|
---|
134 | */
|
---|
135 | typedef enum _VBOXWINDRVSTOREBACKENDTYPE
|
---|
136 | {
|
---|
137 | /** Invalid. */
|
---|
138 | VBOXWINDRVSTOREBACKENDTYPE_INVALID = 0,
|
---|
139 | /** Local file system. */
|
---|
140 | VBOXWINDRVSTOREBACKENDTYPE_LOCAL_FS
|
---|
141 | } VBOXWINDRVSTOREBACKENDTYPE;
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Structure for keeping a Windows driver store backend.
|
---|
145 | *
|
---|
146 | * Currently only the (local) file system backend is supported.
|
---|
147 | */
|
---|
148 | typedef struct _VBOXWINDRVSTOREBACKEND
|
---|
149 | {
|
---|
150 | VBOXWINDRVSTOREBACKENDTYPE enmType;
|
---|
151 | /** The Windows driver store interface to use. */
|
---|
152 | VBOXWINDRVSTOREIFACE Iface;
|
---|
153 | union
|
---|
154 | {
|
---|
155 | struct
|
---|
156 | {
|
---|
157 | char szPathAbs[RTPATH_MAX];
|
---|
158 | } LocalFs;
|
---|
159 | } u;
|
---|
160 | } VBOXWINDRVSTOREBACKEND;
|
---|
161 | /** Pointer to a Windows driver store backend. */
|
---|
162 | typedef VBOXWINDRVSTOREBACKEND *PVBOXWINDRVSTOREBACKEND;
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * Structure for keeping Windows driver store instance data.
|
---|
166 | */
|
---|
167 | typedef struct _VBOXWINDRVSTORE
|
---|
168 | {
|
---|
169 | /** The current list of drivers. */
|
---|
170 | VBOXWINDRVSTORELIST lstDrivers;
|
---|
171 | /** The backend this driver store uses. */
|
---|
172 | VBOXWINDRVSTOREBACKEND Backend;
|
---|
173 | } VBOXWINDRVSTORE;
|
---|
174 |
|
---|
175 | int VBoxWinDrvStoreCreate(PVBOXWINDRVSTORE *ppDrvStore);
|
---|
176 | void VBoxWinDrvStoreDestroy(PVBOXWINDRVSTORE pDrvStore);
|
---|
177 | int VBoxWinDrvStoreQueryAny(PVBOXWINDRVSTORE pDrvStore, const char *pszPattern, PVBOXWINDRVSTORELIST *ppResults);
|
---|
178 | int VBoxWinDrvStoreQueryAll(PVBOXWINDRVSTORE pDrvStore, PVBOXWINDRVSTORELIST *ppResults);
|
---|
179 | int VBoxWinDrvStoreQueryByPnpId(PVBOXWINDRVSTORE pDrvStore, const char *pszPnpId, PVBOXWINDRVSTORELIST *ppResults);
|
---|
180 | int VBoxWinDrvStoreQueryByModelName(PVBOXWINDRVSTORE pDrvStore, const char *pszModelName, PVBOXWINDRVSTORELIST *ppResults);
|
---|
181 |
|
---|
182 | const char *VBoxWinDrvStoreBackendGetLocation(PVBOXWINDRVSTORE pDrvStore);
|
---|
183 |
|
---|
184 | void VBoxWinDrvStoreListFree(PVBOXWINDRVSTORELIST pList);
|
---|
185 |
|
---|
186 | #endif /* !VBOX_INCLUDED_GuestHost_VBoxWinDrvStore_h */
|
---|
187 |
|
---|