Changeset 79408 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB
- Timestamp:
- Jun 28, 2019 11:28:24 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131649
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/win/Install/USBInstall.cpp
r76553 r79408 35 35 #include <iprt/errcore.h> 36 36 #include <iprt/initterm.h> 37 #include <iprt/message.h> 37 38 #include <iprt/param.h> 38 39 #include <iprt/path.h> 40 #include <iprt/process.h> 39 41 #include <iprt/stream.h> 40 42 #include <iprt/string.h> 41 #include <iprt/errcore.h> 42 #include <stdio.h> 43 #include <iprt/utf16.h> 43 44 44 45 #include <VBox/VBoxDrvCfg-win.h> 46 47 48 /********************************************************************************************************************************* 49 * Defined Constants And Macros * 50 *********************************************************************************************************************************/ 51 /** The support service name. */ 52 #define SERVICE_NAME "VBoxUSBMon" 53 /** Win32 Device name. */ 54 #define DEVICE_NAME "\\\\.\\VBoxUSBMon" 55 /** NT Device name. */ 56 #define DEVICE_NAME_NT L"\\Device\\VBoxUSBMon" 57 /** Win32 Symlink name. */ 58 #define DEVICE_NAME_DOS L"\\DosDevices\\VBoxUSBMon" 59 60 61 /********************************************************************************************************************************* 62 * Internal Functions * 63 *********************************************************************************************************************************/ 64 int usblibOsCreateService(void); 65 45 66 46 67 static DECLCALLBACK(void) vboxUsbLog(VBOXDRVCFG_LOG_SEVERITY enmSeverity, char *pszMsg, void *pvContext) … … 68 89 } 69 90 70 int usblibOsCreateService(void);71 91 72 92 int __cdecl main(int argc, char **argv) 73 93 { 74 if (RTR3InitExe(argc, &argv, 0) != VINF_SUCCESS) 75 { 76 printf("Could not init IPRT!\n"); 77 return 1; 78 } 94 int rc = RTR3InitExe(argc, &argv, 0); 95 if (RT_FAILURE(rc)) 96 return RTMsgInitFailure(rc); 79 97 80 98 VBoxDrvCfgLoggerSet(vboxUsbLog, NULL); … … 83 101 RTPrintf("USB installation\n"); 84 102 85 int rc = usblibOsCreateService(); 86 103 rc = usblibOsCreateService(); 87 104 if (RT_SUCCESS(rc)) 88 105 { 89 LPWSTR lpszFilePart; 90 WCHAR szFullPath[MAX_PATH]; 91 DWORD len; 92 93 len = GetFullPathNameW(L".\\VBoxUSB.inf", RT_ELEMENTS(szFullPath), szFullPath, &lpszFilePart); 94 Assert(len); 95 96 HRESULT hr = VBoxDrvCfgInfInstall(szFullPath); 97 if (hr == S_OK) 98 { 99 RTPrintf("Installation successful.\n"); 106 /* Build the path to the INF file: */ 107 char szInfFile[RTPATH_MAX]; 108 rc = RTProcGetExecutablePath(szInfFile, sizeof(szInfFile)) ? VINF_SUCCESS : VERR_BUFFER_OVERFLOW; 109 if (RT_SUCCESS(rc)) 110 { 111 RTPathStripFilename(szInfFile); 112 rc = RTPathAppend(szInfFile, sizeof(szInfFile), "VBoxUSB.inf"); 113 } 114 PRTUTF16 pwszInfFile = NULL; 115 if (RT_SUCCESS(rc)) 116 rc = RTStrToUtf16(szInfFile, &pwszInfFile); 117 if (RT_SUCCESS(rc)) 118 { 119 /* Install the INF file: */ 120 HRESULT hr = VBoxDrvCfgInfInstall(pwszInfFile); 121 if (hr == S_OK) 122 RTPrintf("Installation successful.\n"); 123 else 124 rc = -1; 125 126 RTUtf16Free(pwszInfFile); 100 127 } 101 128 else 102 { 103 rc = -1; 104 } 105 } 106 107 if (RT_SUCCESS(rc)) 108 rc = 0; 109 110 /** @todo RTR3Term(); */ 111 return rc; 112 } 113 114 /** The support service name. */ 115 #define SERVICE_NAME "VBoxUSBMon" 116 /** Win32 Device name. */ 117 #define DEVICE_NAME "\\\\.\\VBoxUSBMon" 118 /** NT Device name. */ 119 #define DEVICE_NAME_NT L"\\Device\\VBoxUSBMon" 120 /** Win32 Symlink name. */ 121 #define DEVICE_NAME_DOS L"\\DosDevices\\VBoxUSBMon" 129 RTMsgError("Failed to construct INF path: %Rrc", rc); 130 } 131 132 return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 133 } 122 134 123 135
Note:
See TracChangeset
for help on using the changeset viewer.