1 | /* $Id: VBoxWinDrvStore.h 106321 2024-10-15 13:06:30Z 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/utf16.h>
|
---|
45 |
|
---|
46 | /** Maximum model PnP ID length (in characters). */
|
---|
47 | #define VBOXWINDRVSTORE_MAX_PNP_ID 255
|
---|
48 | /** Maximum model name length (in characters). */
|
---|
49 | #define VBOXWINDRVSTORE_MAX_MODEL_NAME 255
|
---|
50 | /** Maximum driver name length (in characters). */
|
---|
51 | #define VBOXWINDRVSTORE_MAX_DRIVER_NAME 255
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Structure for keeping a generic Windows driver store list.
|
---|
55 | */
|
---|
56 | typedef struct _VBOXWINDRVSTORELIST
|
---|
57 | {
|
---|
58 | /** List node. */
|
---|
59 | RTLISTANCHOR List;
|
---|
60 | /** Number of current entries of type VBOXWINDRVSTOREENTRY. */
|
---|
61 | size_t cEntries;
|
---|
62 | } VBOXWINDRVSTORELIST;
|
---|
63 | /** Pointer to a generic Windows driver store list. */
|
---|
64 | typedef VBOXWINDRVSTORELIST *PVBOXWINDRVSTORELIST;
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Structure for keeping a Windows driver store entry.
|
---|
68 | */
|
---|
69 | typedef struct _VBOXWINDRVSTOREENTRY
|
---|
70 | {
|
---|
71 | RTLISTNODE Node;
|
---|
72 | /** Full path to the oemXXX.inf file within the driver store. */
|
---|
73 | RTUTF16 wszInfFile[RTPATH_MAX];
|
---|
74 | /** PnP ID of the driver.
|
---|
75 | * Only the first (valid) PnP ID is supported for now */
|
---|
76 | RTUTF16 wszPnpId[VBOXWINDRVSTORE_MAX_PNP_ID];
|
---|
77 | /** Model name of the driver.
|
---|
78 | * Only the first (valid) model name is supported for now */
|
---|
79 | RTUTF16 wszModel[VBOXWINDRVSTORE_MAX_MODEL_NAME];
|
---|
80 | /** Driver name (.sys).
|
---|
81 | * Only the first (valid) driver name is supported for now */
|
---|
82 | RTUTF16 wszDriverName[VBOXWINDRVSTORE_MAX_DRIVER_NAME];
|
---|
83 | } VBOXWINDRVSTOREENTRY;
|
---|
84 | /** Pointer to a Windows driver store entry. */
|
---|
85 | typedef VBOXWINDRVSTOREENTRY *PVBOXWINDRVSTOREENTRY;
|
---|
86 |
|
---|
87 | struct _VBOXWINDRVSTORE;
|
---|
88 | typedef struct _VBOXWINDRVSTORE *PVBOXWINDRVSTORE;
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Interface for a Windows driver store implementation.
|
---|
92 | */
|
---|
93 | typedef struct _VBOXWINDRVSTOREIFACE
|
---|
94 | {
|
---|
95 | /**
|
---|
96 | * Adds a driver to the driver store.
|
---|
97 | *
|
---|
98 | * @returns VBox status code.
|
---|
99 | * @param pThis Pointer to interface instance.
|
---|
100 | * @param pszInfFile Path of INF file to add.
|
---|
101 | *
|
---|
102 | * Optional and can be NULL.
|
---|
103 | */
|
---|
104 | DECLCALLBACKMEMBER(int, pfnDriverAdd,(PVBOXWINDRVSTORE pThis, const char *pszInfFile));
|
---|
105 | /**
|
---|
106 | * Removes a driver from the driver store.
|
---|
107 | *
|
---|
108 | * @returns VBox status code.
|
---|
109 | * @param pThis Pointer to interface instance.
|
---|
110 | * @param pszInfFile Path of INF file to remove.
|
---|
111 | *
|
---|
112 | * Optional and can be NULL.
|
---|
113 | */
|
---|
114 | DECLCALLBACKMEMBER(int, pfnDriverRemove,(PVBOXWINDRVSTORE pThis, const char *pszInfFile, bool fForce));
|
---|
115 | /**
|
---|
116 | * Performs (re-)enumeration of the driver store entries.
|
---|
117 | *
|
---|
118 | * @returns VBox status code.
|
---|
119 | * @param pThis Pointer to interface instance.
|
---|
120 | */
|
---|
121 | DECLCALLBACKMEMBER(int, pfnEnumerate,(PVBOXWINDRVSTORE pThis));
|
---|
122 | } VBOXWINDRVSTOREIFACE;
|
---|
123 | /** Pointer to a Windows driver store implementation. */
|
---|
124 | typedef VBOXWINDRVSTOREIFACE *PVBOXWINDRVSTOREIFACE;
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * Enumeration for a driver store backend.
|
---|
128 | */
|
---|
129 | typedef enum _VBOXWINDRVSTOREBACKENDTYPE
|
---|
130 | {
|
---|
131 | /** Invalid. */
|
---|
132 | VBOXWINDRVSTOREBACKENDTYPE_INVALID = 0,
|
---|
133 | /** Local file system. */
|
---|
134 | VBOXWINDRVSTOREBACKENDTYPE_LOCAL_FS
|
---|
135 | } VBOXWINDRVSTOREBACKENDTYPE;
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * Structure for keeping a Windows driver store backend.
|
---|
139 | *
|
---|
140 | * Currently only the (local) file system backend is supported.
|
---|
141 | */
|
---|
142 | typedef struct _VBOXWINDRVSTOREBACKEND
|
---|
143 | {
|
---|
144 | VBOXWINDRVSTOREBACKENDTYPE enmType;
|
---|
145 | /** The Windows driver store interface to use. */
|
---|
146 | VBOXWINDRVSTOREIFACE Iface;
|
---|
147 | union
|
---|
148 | {
|
---|
149 | struct
|
---|
150 | {
|
---|
151 | char szPathAbs[RTPATH_MAX];
|
---|
152 | } LocalFs;
|
---|
153 | } u;
|
---|
154 | } VBOXWINDRVSTOREBACKEND;
|
---|
155 | /** Pointer to a Windows driver store backend. */
|
---|
156 | typedef VBOXWINDRVSTOREBACKEND *PVBOXWINDRVSTOREBACKEND;
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Structure for keeping Windows driver store instance data.
|
---|
160 | */
|
---|
161 | typedef struct _VBOXWINDRVSTORE
|
---|
162 | {
|
---|
163 | /** The current list of drivers. */
|
---|
164 | VBOXWINDRVSTORELIST lstDrivers;
|
---|
165 | /** The backend this driver store uses. */
|
---|
166 | VBOXWINDRVSTOREBACKEND Backend;
|
---|
167 | } VBOXWINDRVSTORE;
|
---|
168 | /** Pointer to Windows driver store instance data. */
|
---|
169 | typedef VBOXWINDRVSTORE *PVBOXWINDRVSTORE;
|
---|
170 |
|
---|
171 | int VBoxWinDrvStoreCreate(PVBOXWINDRVSTORE *ppDrvStore);
|
---|
172 | void VBoxWinDrvStoreDestroy(PVBOXWINDRVSTORE pDrvStore);
|
---|
173 | int VBoxWinDrvStoreQueryAny(PVBOXWINDRVSTORE pDrvStore, const char *pszPattern, PVBOXWINDRVSTORELIST *ppResults);
|
---|
174 | int VBoxWinDrvStoreQueryAll(PVBOXWINDRVSTORE pDrvStore, PVBOXWINDRVSTORELIST *ppResults);
|
---|
175 | int VBoxWinDrvStoreQueryByPnpId(PVBOXWINDRVSTORE pDrvStore, const char *pszPnpId, PVBOXWINDRVSTORELIST *ppResults);
|
---|
176 | int VBoxWinDrvStoreQueryByModelName(PVBOXWINDRVSTORE pDrvStore, const char *pszModelName, PVBOXWINDRVSTORELIST *ppResults);
|
---|
177 |
|
---|
178 | const char *VBoxWinDrvStoreBackendGetLocation(PVBOXWINDRVSTORE pDrvStore);
|
---|
179 |
|
---|
180 | void VBoxWinDrvStoreListFree(PVBOXWINDRVSTORELIST pList);
|
---|
181 |
|
---|
182 | #endif /* !VBOX_INCLUDED_GuestHost_VBoxWinDrvStore_h */
|
---|
183 |
|
---|