Index: trunk/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp
===================================================================
--- trunk/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp	(revision 107060)
+++ trunk/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp	(revision 107061)
@@ -59,4 +59,5 @@
 
 #include "VBoxWinDrvCommon.h"
+#include "VBoxWinDrvInstInternal.h"
 
 
@@ -139,55 +140,4 @@
 DECL_HIDDEN_DATA(PFNSETUPUNINSTALLOEMINFW)               g_pfnSetupUninstallOEMInfW               = NULL; /* For XP+.  */
 DECL_HIDDEN_DATA(PFNSETUPSETNONINTERACTIVEMODE)          g_pfnSetupSetNonInteractiveMode          = NULL; /* For W2K+. */
-
-
-/**
- * Enumeration specifying the driver (un)installation mode.
- */
-typedef enum VBOXWINDRVINSTMODE
-{
-    /** Invalid mode; do not use. */
-    VBOXWINDRVINSTMODE_INVALID = 0,
-    /** Install a driver. */
-    VBOXWINDRVINSTMODE_INSTALL,
-    /** Install by executing an INF section. */
-    VBOXWINDRVINSTMODE_INSTALL_INFSECTION,
-    /** Uninstall a driver. */
-    VBOXWINDRVINSTMODE_UNINSTALL,
-    /** Uninstall by executing an INF section. */
-    VBOXWINDRVINSTMODE_UNINSTALL_INFSECTION
-} VBOXWINDRVINSTMODE;
-
-/**
- * Structure for keeping driver (un)installation parameters.
- */
-typedef struct VBOXWINDRVINSTPARMS
-{
-    /** Installation mode. */
-    VBOXWINDRVINSTMODE enmMode;
-    /** Installation flags of type VBOX_WIN_DRIVERINSTALL_F_XXX. */
-    uint32_t           fFlags;
-    /** INF file to use for (un)installation. */
-    PRTUTF16           pwszInfFile;
-    /** Union keeping specific parameters, depending on \a enmMode. */
-    union
-    {
-        struct
-        {
-            /** Model including decoration (e.g. "VBoxUSB.NTAMD64"); optional and might be NULL. */
-            PRTUTF16   pwszModel;
-            /** Hardware (Pnp) ID; optional and might be NULL. */
-            PRTUTF16   pwszPnpId;
-            /** Name of section to install. */
-            PRTUTF16   pwszSection;
-        } UnInstall;
-        struct
-        {
-            /** Section within in the INF file to execute. */
-            PRTUTF16   pwszSection;
-        } ExecuteInf;
-    } u;
-} VBOXWINDRVINSTPARMS;
-/** Pointer to driver installation parameters. */
-typedef VBOXWINDRVINSTPARMS *PVBOXWINDRVINSTPARMS;
 
 /**
@@ -1813,5 +1763,6 @@
     }
 
-    vboxWinDrvInstParmsDestroy(&pCtx->Parms);
+    if (!(fFlags & VBOX_WIN_DRIVERINSTALL_F_NO_DESTROY))
+        vboxWinDrvInstParmsDestroy(&pCtx->Parms);
 
     if (RT_FAILURE(rc))
@@ -1882,5 +1833,6 @@
         rc = vboxWinDrvInstMain(pCtx, &pCtx->Parms);
 
-    vboxWinDrvInstParmsDestroy(&pCtx->Parms);
+    if (!(fFlags & VBOX_WIN_DRIVERINSTALL_F_NO_DESTROY))
+        vboxWinDrvInstParmsDestroy(&pCtx->Parms);
 
     if (RT_FAILURE(rc))
@@ -1919,5 +1871,6 @@
     rc = vboxWinDrvInstMain(pCtx, &pCtx->Parms);
 
-    vboxWinDrvInstParmsDestroy(&pCtx->Parms);
+    if (!(fFlags & VBOX_WIN_DRIVERINSTALL_F_NO_DESTROY))
+        vboxWinDrvInstParmsDestroy(&pCtx->Parms);
 
     return rc;
@@ -1952,2 +1905,28 @@
 }
 
+#ifdef TESTCASE
+/**
+ * Returns the internal parameters of an (un)installation.
+ *
+ * @returns Internal parameters of an (un)installation.
+ * @param   hDrvInst            Windows driver installer handle to use.
+ */
+PVBOXWINDRVINSTPARMS VBoxWinDrvInstTestGetParms(VBOXWINDRVINST hDrvInst)
+{
+    PVBOXWINDRVINSTINTERNAL pCtx = hDrvInst;
+    VBOXWINDRVINST_VALID_RETURN_RC((hDrvInst), NULL);
+
+    return &pCtx->Parms;
+}
+
+/**
+ * Detroys internal parameters of an (un)installation.
+ *
+ * @param   pParms              Internal parameters of an (un)installation to destroy.
+ */
+void VBoxWinDrvInstTestParmsDestroy(PVBOXWINDRVINSTPARMS pParms)
+{
+    vboxWinDrvInstParmsDestroy(pParms);
+}
+#endif /* TESTCASE */
+
Index: trunk/src/VBox/GuestHost/installation/VBoxWinDrvInstInternal.h
===================================================================
--- trunk/src/VBox/GuestHost/installation/VBoxWinDrvInstInternal.h	(revision 107061)
+++ trunk/src/VBox/GuestHost/installation/VBoxWinDrvInstInternal.h	(revision 107061)
@@ -0,0 +1,91 @@
+/* $Id$ */
+/** @file
+ * VBoxWinDrvInstInternal.h - Internal header for VBoxWinDrvInst.cpp.
+ *
+ * Required for exposing internal stuff to the testcase(s).
+ */
+
+/*
+ * Copyright (C) 2024 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>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+#ifndef VBOX_INCLUDED_SRC_installation_VBoxWinDrvInstInternal_h
+#define VBOX_INCLUDED_SRC_installation_VBoxWinDrvInstInternal_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+/**
+ * Enumeration specifying the driver (un)installation mode.
+ */
+typedef enum VBOXWINDRVINSTMODE
+{
+    /** Invalid mode; do not use. */
+    VBOXWINDRVINSTMODE_INVALID = 0,
+    /** Install a driver. */
+    VBOXWINDRVINSTMODE_INSTALL,
+    /** Install by executing an INF section. */
+    VBOXWINDRVINSTMODE_INSTALL_INFSECTION,
+    /** Uninstall a driver. */
+    VBOXWINDRVINSTMODE_UNINSTALL,
+    /** Uninstall by executing an INF section. */
+    VBOXWINDRVINSTMODE_UNINSTALL_INFSECTION
+} VBOXWINDRVINSTMODE;
+
+/**
+ * Structure for keeping driver (un)installation parameters.
+ */
+typedef struct VBOXWINDRVINSTPARMS
+{
+    /** Installation mode. */
+    VBOXWINDRVINSTMODE enmMode;
+    /** Installation flags of type VBOX_WIN_DRIVERINSTALL_F_XXX. */
+    uint32_t           fFlags;
+    /** INF file to use for (un)installation. */
+    PRTUTF16           pwszInfFile;
+    /** Union keeping specific parameters, depending on \a enmMode. */
+    union
+    {
+        struct
+        {
+            /** Model including decoration (e.g. "VBoxUSB.NTAMD64"); optional and might be NULL. */
+            PRTUTF16   pwszModel;
+            /** Hardware (Pnp) ID; optional and might be NULL. */
+            PRTUTF16   pwszPnpId;
+            /** Name of section to install. */
+            PRTUTF16   pwszSection;
+        } UnInstall;
+        struct
+        {
+            /** Section within in the INF file to execute. */
+            PRTUTF16   pwszSection;
+        } ExecuteInf;
+    } u;
+} VBOXWINDRVINSTPARMS;
+/** Pointer to driver installation parameters. */
+typedef VBOXWINDRVINSTPARMS *PVBOXWINDRVINSTPARMS;
+
+#ifdef TESTCASE
+PVBOXWINDRVINSTPARMS VBoxWinDrvInstTestGetParms(VBOXWINDRVINST hDrvInst);
+void VBoxWinDrvInstTestParmsDestroy(PVBOXWINDRVINSTPARMS);
+#endif
+
+#endif /* !VBOX_INCLUDED_SRC_installation_VBoxWinDrvInstInternal_h */
