File: VBoxWinDrvStore.h

package info (click to toggle)
virtualbox 7.2.6-dfsg-3
  • links: PTS, VCS
  • area: contrib
  • in suites: sid
  • size: 684,120 kB
  • sloc: ansic: 2,692,612; cpp: 2,685,536; asm: 402,532; python: 239,820; xml: 89,849; sh: 33,358; perl: 9,380; makefile: 8,889; java: 5,337; cs: 4,872; pascal: 1,785; javascript: 1,692; objc: 1,131; lex: 931; sed: 929; php: 906; yacc: 707
file content (206 lines) | stat: -rw-r--r-- 7,117 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/* $Id: VBoxWinDrvStore.h $ */
/** @file
 * VBoxWinDrvInst - Header for Windows driver store handling.
 */

/*
 * Copyright (C) 2024-2025 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
 * in the VirtualBox distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
 */

#ifndef VBOX_INCLUDED_GuestHost_VBoxWinDrvStore_h
#define VBOX_INCLUDED_GuestHost_VBoxWinDrvStore_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include <iprt/list.h>
#include <iprt/path.h>
#include <iprt/utf16.h>

#include <VBox/GuestHost/VBoxWinDrvDefs.h>


/** Maximum model PnP ID length (in characters). */
#define VBOXWINDRVSTORE_MAX_PNP_ID          255
/** Maximum model name length (in characters). */
#define VBOXWINDRVSTORE_MAX_MODEL_NAME      255
/** Maximum driver name length (in characters). */
#define VBOXWINDRVSTORE_MAX_DRIVER_NAME     255

/**
 * Structure for keeping a generic Windows driver store list.
 *
 * Used for VBOXWINDRVSTOREENTRY.
 */
typedef struct VBOXWINDRVSTORELIST
{
    /** List node. */
    RTLISTANCHOR List;
    /** Number of current entries of type VBOXWINDRVSTOREENTRY. */
    size_t       cEntries;
} VBOXWINDRVSTORELIST;
/** Pointer to a generic Windows driver store list. */
typedef VBOXWINDRVSTORELIST *PVBOXWINDRVSTORELIST;

/**
 * Structure for keeping a single generic Windows driver store file entry.
 */
typedef struct VBOXWINDRVSTOREFILEENTRY
{
    /** List node. */
    RTLISTNODE               Node;
    /** Full (absolute) path of the file. */
    RTUTF16                  wszFile[RTPATH_MAX];
} VBOXWINDRVSTOREFILEENTRY;
/** Pointer to a Windows driver store file entry. */
typedef VBOXWINDRVSTOREFILEENTRY *PVBOXWINDRVSTOREFILEENTRY;

/**
 * Structure for keeping a Windows driver store entry.
 */
typedef struct VBOXWINDRVSTOREENTRY
{
    RTLISTNODE Node;
    /** Version section information. */
    VBOXWINDRVINFSECVERSION   Ver;
    /** Full path to the oemXXX.inf file within the driver store. */
    RTUTF16                   wszInfFile[RTPATH_MAX];
    /** PnP ID of the driver.
     *  Only the first (valid) PnP ID is supported for now */
    RTUTF16                   wszPnpId[VBOXWINDRVSTORE_MAX_PNP_ID];
    /** Model name of the driver.
     *  Only the first (valid) model name is supported for now */
    RTUTF16                   wszModel[VBOXWINDRVSTORE_MAX_MODEL_NAME];
    /** Driver name (.sys).
     *  Only the first (valid) driver name is supported for now */
    RTUTF16                   wszDriverName[VBOXWINDRVSTORE_MAX_DRIVER_NAME];
    /** List of installed files onto the OS (e.g. in \%SystemRoot\%\\System32).
     *  Might be NULL if not being used. */
    PVBOXWINDRVINFLIST        pCopyFileList;
} VBOXWINDRVSTOREENTRY;
/** Pointer to a Windows driver store entry. */
typedef VBOXWINDRVSTOREENTRY *PVBOXWINDRVSTOREENTRY;

struct VBOXWINDRVSTORE;
/** Pointer to Windows driver store instance data. */
typedef struct VBOXWINDRVSTORE *PVBOXWINDRVSTORE;

/**
 * Interface for a Windows driver store implementation.
 */
typedef struct VBOXWINDRVSTOREIFACE
{
    /**
     * Adds a driver to the driver store.
     *
     * @returns VBox status code.
     * @param   pThis           Pointer to interface instance.
     * @param   pszInfFile      Path of INF file to add.
     *
     * Optional and can be NULL.
     */
    DECLCALLBACKMEMBER(int, pfnDriverAdd,(PVBOXWINDRVSTORE pThis, const char *pszInfFile));
    /**
     * Removes a driver from the driver store.
     *
     * @returns VBox status code.
     * @param   pThis           Pointer to interface instance.
     * @param   pszInfFile      Path of INF file to remove.
     *
     * Optional and can be NULL.
     */
    DECLCALLBACKMEMBER(int, pfnDriverRemove,(PVBOXWINDRVSTORE pThis, const char *pszInfFile, bool fForce));
    /**
     * Performs (re-)enumeration of the driver store entries.
     *
     * @returns VBox status code.
     * @param   pThis           Pointer to interface instance.
     */
    DECLCALLBACKMEMBER(int, pfnEnumerate,(PVBOXWINDRVSTORE pThis));
} VBOXWINDRVSTOREIFACE;
/** Pointer to a Windows driver store implementation. */
typedef VBOXWINDRVSTOREIFACE *PVBOXWINDRVSTOREIFACE;

/**
 * Enumeration for a driver store backend.
 */
typedef enum VBOXWINDRVSTOREBACKENDTYPE
{
    /** Invalid. */
    VBOXWINDRVSTOREBACKENDTYPE_INVALID = 0,
    /** Local file system. */
    VBOXWINDRVSTOREBACKENDTYPE_LOCAL_FS
} VBOXWINDRVSTOREBACKENDTYPE;

/**
 * Structure for keeping a Windows driver store backend.
 *
 * Currently only the (local) file system backend is supported.
 */
typedef struct VBOXWINDRVSTOREBACKEND
{
    VBOXWINDRVSTOREBACKENDTYPE enmType;
    /** The Windows driver store interface to use. */
    VBOXWINDRVSTOREIFACE       Iface;
    union
    {
        struct
        {
            char szPathAbs[RTPATH_MAX];
        } LocalFs;
    } u;
} VBOXWINDRVSTOREBACKEND;
/** Pointer to a Windows driver store backend. */
typedef VBOXWINDRVSTOREBACKEND *PVBOXWINDRVSTOREBACKEND;

/**
 * Structure for keeping Windows driver store instance data.
 */
typedef struct VBOXWINDRVSTORE
{
    /** The current list of drivers. */
    VBOXWINDRVSTORELIST    lstDrivers;
    /** The backend this driver store uses. */
    VBOXWINDRVSTOREBACKEND Backend;
} VBOXWINDRVSTORE;

int VBoxWinDrvStoreCreate(PVBOXWINDRVSTORE *ppDrvStore);
void VBoxWinDrvStoreDestroy(PVBOXWINDRVSTORE pDrvStore);
int VBoxWinDrvStoreQueryAny(PVBOXWINDRVSTORE pDrvStore, const char *pszPattern, PVBOXWINDRVSTORELIST *ppResults);
int VBoxWinDrvStoreQueryAll(PVBOXWINDRVSTORE pDrvStore, PVBOXWINDRVSTORELIST *ppResults);
int VBoxWinDrvStoreQueryByPnpId(PVBOXWINDRVSTORE pDrvStore, const char *pszPnpId, PVBOXWINDRVSTORELIST *ppResults);
int VBoxWinDrvStoreQueryByModelName(PVBOXWINDRVSTORE pDrvStore, const char *pszModelName, PVBOXWINDRVSTORELIST *ppResults);

const char *VBoxWinDrvStoreBackendGetLocation(PVBOXWINDRVSTORE pDrvStore);

void VBoxWinDrvStoreListFree(PVBOXWINDRVSTORELIST pList);

#endif /* !VBOX_INCLUDED_GuestHost_VBoxWinDrvStore_h */