VirtualBox

Ignore:
Timestamp:
Sep 1, 2022 8:36:22 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153448
Message:

HostDrives,Installer/win: Reworked the windows installer related code for no-CRT mode, where applicable, and changed the XxxxInstall.exe/XxxxUninstall.exe utilities to link against VBoxRT.dll instead of being statically linked. Lot's of cleanup. The change is uncomfortably large, but difficult to detangle these things. bugref:10261

Location:
trunk/src/VBox/HostDrivers/VBoxUSB/win
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/Install/USBInstall.cpp

    r96407 r96572  
    7575
    7676
    77 static DECLCALLBACK(void) vboxUsbLog(VBOXDRVCFG_LOG_SEVERITY enmSeverity, char *pszMsg, void *pvContext)
     77static DECLCALLBACK(void) vboxUsbLog(VBOXDRVCFG_LOG_SEVERITY_T enmSeverity, char *pszMsg, void *pvContext)
    7878{
    7979    RT_NOREF1(pvContext);
     
    8484            break;
    8585        case VBOXDRVCFG_LOG_SEVERITY_REL:
    86             RTPrintf("%s", pszMsg);
     86            RTMsgInfo("%s", pszMsg);
    8787            break;
    8888        default:
     
    106106        return RTMsgInitFailure(rc);
    107107
     108    RTMsgInfo("USB installation");
     109
    108110    VBoxDrvCfgLoggerSet(vboxUsbLog, NULL);
    109111    VBoxDrvCfgPanicSet(vboxUsbPanic, NULL);
    110 
    111     RTPrintf("USB installation\n");
    112112
    113113    rc = usblibOsCreateService();
     
    130130            HRESULT hr = VBoxDrvCfgInfInstall(pwszInfFile);
    131131            if (hr == S_OK)
    132                 RTPrintf("Installation successful.\n");
     132                RTMsgInfo("Installation successful!");
    133133            else
    134                 rc = -1;
     134            {
     135                RTMsgError("Installation failed: %Rhrc", hr);
     136                rc = VERR_GENERAL_FAILURE;
     137            }
    135138
    136139            RTUtf16Free(pwszInfFile);
     
    139142            RTMsgError("Failed to construct INF path: %Rrc", rc);
    140143    }
     144    else
     145        RTMsgError("Service creation failed: %Rrc", rc);
    141146
    142147    return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/Install/USBUninstall.cpp

    r96407 r96572  
    4545#include <iprt/assert.h>
    4646#include <iprt/errcore.h>
     47#include <iprt/initterm.h>
     48#include <iprt/message.h>
    4749#include <iprt/param.h>
    4850#include <iprt/path.h>
    4951#include <iprt/string.h>
    50 #include <iprt/errcore.h>
    5152#include <VBox/VBoxDrvCfg-win.h>
    52 #include <stdio.h>
    53 
    54 
    55 int usblibOsStopService(void);
    56 int usblibOsDeleteService(void);
    57 
    58 static DECLCALLBACK(void) vboxUsbLog(VBOXDRVCFG_LOG_SEVERITY enmSeverity, char *pszMsg, void *pvContext)
    59 {
    60     RT_NOREF1(pvContext);
    61     switch (enmSeverity)
    62     {
    63         case VBOXDRVCFG_LOG_SEVERITY_FLOW:
    64         case VBOXDRVCFG_LOG_SEVERITY_REGULAR:
    65             break;
    66         case VBOXDRVCFG_LOG_SEVERITY_REL:
    67             printf("%s", pszMsg);
    68             break;
    69         default:
    70             break;
    71     }
    72 }
    73 
    74 static DECLCALLBACK(void) vboxUsbPanic(void *pvPanic)
    75 {
    76     RT_NOREF1(pvPanic);
    77 #ifndef DEBUG_bird
    78     AssertFailed();
    79 #endif
    80 }
    81 
    82 
    83 int __cdecl main(int argc, char **argv)
    84 {
    85     RT_NOREF2(argc, argv);
    86     printf("USB uninstallation\n");
    87 
    88     VBoxDrvCfgLoggerSet(vboxUsbLog, NULL);
    89     VBoxDrvCfgPanicSet(vboxUsbPanic, NULL);
    90 
    91     usblibOsStopService();
    92     usblibOsDeleteService();
    93 
    94     HRESULT hr = VBoxDrvCfgInfUninstallAllF(L"USB", L"USB\\VID_80EE&PID_CAFE", SUOI_FORCEDELETE);
    95     if (hr != S_OK)
    96     {
    97         printf("SetupUninstallOEMInf failed with hr=0x%lx\n", hr);
    98         return 1;
    99     }
    100 
    101     printf("USB uninstallation succeeded!\n");
    102 
    103     return 0;
    104 }
    105 
     53
     54
     55/*********************************************************************************************************************************
     56*   Defined Constants And Macros                                                                                                 *
     57*********************************************************************************************************************************/
    10658/** The support service name. */
    10759#define SERVICE_NAME    "VBoxUSBMon"
     
    11365#define DEVICE_NAME_DOS  L"\\DosDevices\\VBoxUSBMon"
    11466
     67
     68/*********************************************************************************************************************************
     69*   Internal Functions                                                                                                           *
     70*********************************************************************************************************************************/
     71static int usblibOsStopService(void);
     72static int usblibOsDeleteService(void);
     73
     74
     75static DECLCALLBACK(void) vboxUsbLog(VBOXDRVCFG_LOG_SEVERITY_T enmSeverity, char *pszMsg, void *pvContext)
     76{
     77    RT_NOREF1(pvContext);
     78    switch (enmSeverity)
     79    {
     80        case VBOXDRVCFG_LOG_SEVERITY_FLOW:
     81        case VBOXDRVCFG_LOG_SEVERITY_REGULAR:
     82            break;
     83        case VBOXDRVCFG_LOG_SEVERITY_REL:
     84            RTMsgInfo("%s", pszMsg);
     85            break;
     86        default:
     87            break;
     88    }
     89}
     90
     91static DECLCALLBACK(void) vboxUsbPanic(void *pvPanic)
     92{
     93    RT_NOREF1(pvPanic);
     94#ifndef DEBUG_bird
     95    AssertFailed();
     96#endif
     97}
     98
     99
     100int __cdecl main(int argc, char **argv)
     101{
     102    RTR3InitExeNoArguments(0);
     103    if (argc != 1)
     104        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "This utility takes no arguments\n");
     105    NOREF(argv);
     106    RTMsgInfo("USB uninstallation\n");
     107
     108    VBoxDrvCfgLoggerSet(vboxUsbLog, NULL);
     109    VBoxDrvCfgPanicSet(vboxUsbPanic, NULL);
     110
     111    usblibOsStopService();
     112    usblibOsDeleteService();
     113
     114    HRESULT hr = VBoxDrvCfgInfUninstallAllF(L"USB", L"USB\\VID_80EE&PID_CAFE", SUOI_FORCEDELETE);
     115    if (hr != S_OK)
     116        return RTMsgErrorExitFailure("SetupUninstallOEMInf failed: %Rhrc\n", hr);
     117
     118    RTMsgInfo("USB uninstallation succeeded!");
     119    return 0;
     120}
     121
     122
    115123/**
    116124 * Stops a possibly running service.
     
    119127 * @returns -1 on failure.
    120128 */
    121 int usblibOsStopService(void)
     129static int usblibOsStopService(void)
    122130{
    123131    /*
     
    176184 * @returns -1 on failure.
    177185 */
    178 int usblibOsDeleteService(void)
     186static int usblibOsDeleteService(void)
    179187{
    180188    /*
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/Makefile.kmk

    r96407 r96572  
    122122#
    123123TEMPLATE_VBoxUsbR3 = Template for USBInstalls, USBUninstall and USBTest
    124 TEMPLATE_VBoxUsbR3_EXTENDS  = VBoxR3Static
    125 TEMPLATE_VBoxUsbR3_SDKS     = $(TEMPLATE_VBoxR3Static_SDKS) ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK) VBOX_WIN_NEWDEV
    126 TEMPLATE_VBoxUsbR3_CXXFLAGS = $(TEMPLATE_VBoxR3Static_CXXFLAGS) -Gz
    127 TEMPLATE_VBoxUsbR3_CFLAGS   = $(TEMPLATE_VBoxR3Static_CFLAGS) -Gz
    128 TEMPLATE_VBoxUsbR3_LIBS     = $(TEMPLATE_VBoxR3Static_LIBS) \
    129         $(PATH_STAGE_LIB)/VBoxDrvCfg$(VBOX_SUFF_LIB)
     124TEMPLATE_VBoxUsbR3_EXTENDS  = VBOXR3EXE
     125TEMPLATE_VBoxUsbR3_SDKS     = $(TEMPLATE_VBOXR3EXE_SDKS) ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK) VBOX_WIN_NEWDEV
     126TEMPLATE_VBoxUsbR3_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -Gz
     127TEMPLATE_VBoxUsbR3_CFLAGS   = $(TEMPLATE_VBOXR3EXE_CFLAGS) -Gz
     128TEMPLATE_VBoxUsbR3_LIBS     = $(TEMPLATE_VBOXR3EXE_LIBS) \
     129        $(PATH_STAGE_LIB)/VBoxDrvCfgExe$(VBOX_SUFF_LIB) \
     130       $(LIB_RUNTIME)
    130131
    131132#
  • trunk/src/VBox/HostDrivers/VBoxUSB/win/testcase/USBTest.cpp

    r96407 r96572  
    4242#include <iprt/win/setupapi.h>
    4343#include <newdev.h>
     44
    4445#include <iprt/assert.h>
    45 #include <iprt/err.h>
     46#include <VBox/err.h>
    4647#include <iprt/param.h>
    4748#include <iprt/path.h>
     49#include <iprt/stream.h>
    4850#include <iprt/string.h>
    49 #include <VBox/err.h>
    50 #include <stdio.h>
    5151#include <VBox/usblib.h>
    5252#include <VBox/VBoxDrvCfg-win.h>
    5353
     54
     55/*********************************************************************************************************************************
     56*   Global Variables                                                                                                             *
     57*********************************************************************************************************************************/
    5458/** Handle to the open device. */
    5559static HANDLE   g_hUSBMonitor = INVALID_HANDLE_VALUE;
     
    5761static bool     g_fStartedService = false;
    5862
     63
    5964/**
    6065 * Attempts to start the service, creating it if necessary.
     
    8388int usbMonStopService(void)
    8489{
    85     printf("usbMonStopService\n");
     90    RTPrintf("usbMonStopService\n");
     91
    8692    /*
    8793     * Assume it didn't exist, so we'll create the service.
     
    141147    DWORD          cbReturned = 0;
    142148
    143     printf("usbLibReleaseDevice %x %x %x\n", usVendorId, usProductId, usRevision);
     149    RTPrintf("usbLibReleaseDevice %x %x %x\n", usVendorId, usProductId, usRevision);
    144150
    145151    release.usVendorId  = usVendorId;
     
    174180    Assert(g_hUSBMonitor);
    175181
    176     printf("usblibInsertFilter %04X %04X %04X\n", usVendorId, usProductId, usRevision);
     182    RTPrintf("usblibInsertFilter %04X %04X %04X\n", usVendorId, usProductId, usRevision);
    177183
    178184    USBFilterInit(&filter, USBFILTERTYPE_CAPTURE);
     
    222228    Assert(g_hUSBMonitor);
    223229
    224     printf("usblibRemoveFilter %p\n", aID);
     230    RTPrintf("usblibRemoveFilter %p\n", aID);
    225231
    226232    uId = (uintptr_t)aID;
     
    244250    DWORD          cbReturned;
    245251
    246     printf("usbproxy: usbLibInit\n");
     252    RTPrintf("usbproxy: usbLibInit\n");
    247253
    248254    g_hUSBMonitor = CreateFile (USBMON_DEVICE_NAME,
     
    269275        {
    270276            /* AssertFailed(); */
    271             printf("usbproxy: Unable to open filter driver!! (rc=%lu)\n", GetLastError());
     277            RTPrintf("usbproxy: Unable to open filter driver!! (rc=%lu)\n", GetLastError());
    272278            rc = VERR_FILE_NOT_FOUND;
    273279            goto failure;
     
    281287    if (!DeviceIoControl(g_hUSBMonitor, SUPUSBFLT_IOCTL_GET_VERSION, NULL, 0,&version, sizeof(version),  &cbReturned, NULL))
    282288    {
    283         printf("usbproxy: Unable to query filter version!! (rc=%lu)\n", GetLastError());
     289        RTPrintf("usbproxy: Unable to query filter version!! (rc=%lu)\n", GetLastError());
    284290        rc = VERR_VERSION_MISMATCH;
    285291        goto failure;
     
    292298        )
    293299    {
    294         printf("usbproxy: Filter driver version mismatch!!\n");
     300        RTPrintf("usbproxy: Filter driver version mismatch!!\n");
    295301        rc = VERR_VERSION_MISMATCH;
    296302        goto failure;
     
    344350    RT_NOREF2(argc, argv);
    345351
    346     printf("USB test\n");
     352    RTPrintf("USB test\n");
    347353
    348354    rc = usbMonitorInit();
     
    355361    usbMonInsertFilter(0x80EE, 0x0030, 0x0110, &pId3);
    356362
    357     printf("Waiting to capture devices... enter 'r' to run filters\n");
    358     c = getchar();
     363    RTPrintf("Waiting to capture devices... enter 'r' to run filters\n");
     364    c = RTStrmGetCh(g_pStdIn);
    359365    if (c == 'r')
    360366    {
    361367        usbMonRunFilters();
    362         printf("Waiting to capture devices...\n");
    363         getchar();  /* eat the '\n' */
    364         getchar();  /* wait for more input */
    365     }
    366 
    367     printf("Releasing device\n");
     368        RTPrintf("Waiting to capture devices...\n");
     369        RTStrmGetCh(g_pStdIn);  /* eat the '\n' */
     370        RTStrmGetCh(g_pStdIn);  /* wait for more input */
     371    }
     372
     373    RTPrintf("Releasing device\n");
    368374    usbMonReleaseDevice(0xA16, 0x2499, 0x100);
    369375
     
    376382    return 0;
    377383}
     384
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette