Changeset 95868 in vbox
- Timestamp:
- Jul 27, 2022 1:28:13 AM (2 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
r95049 r95868 22 22 #define _WIN32_WINNT 0x0601 23 23 #include "VBoxTray.h" 24 25 #include <iprt/alloca.h> 26 #include <iprt/assert.h> 27 #include <iprt/errcore.h> 24 28 #include <iprt/log.h> 25 #include <iprt/errcore.h> 26 #include <iprt/assert.h> 29 #include <iprt/mem.h> 27 30 #include <iprt/system.h> 28 29 #include <malloc.h>30 31 31 32 … … 173 174 UINT32 cPathInfoArray = 0; 174 175 UINT32 cModeInfoArray = 0; 175 DISPLAYCONFIG_PATH_INFO *pPathInfoArray;176 DISPLAYCONFIG_MODE_INFO *pModeInfoArray;177 176 DWORD winEr = gCtx.pfnGetDisplayConfigBufferSizes(fFlags, &cPathInfoArray, &cModeInfoArray); 178 177 if (winEr != ERROR_SUCCESS) … … 182 181 } 183 182 184 pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)malloc(cPathInfoArray * sizeof(DISPLAYCONFIG_PATH_INFO)); 183 DISPLAYCONFIG_PATH_INFO *pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)RTMemAlloc( cPathInfoArray 184 * sizeof(DISPLAYCONFIG_PATH_INFO)); 185 185 if (!pPathInfoArray) 186 186 { 187 WARN(("VBoxTray: (WDDM) malloc failed!\n"));187 WARN(("VBoxTray: (WDDM) RTMemAlloc failed!\n")); 188 188 return ERROR_OUTOFMEMORY; 189 189 } 190 pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)malloc(cModeInfoArray * sizeof(DISPLAYCONFIG_MODE_INFO)); 190 DISPLAYCONFIG_MODE_INFO *pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)RTMemAlloc( cModeInfoArray 191 * sizeof(DISPLAYCONFIG_MODE_INFO)); 191 192 if (!pModeInfoArray) 192 193 { 193 WARN(("VBoxTray: (WDDM) malloc failed!\n"));194 free(pPathInfoArray);194 WARN(("VBoxTray: (WDDM) RTMemAlloc failed!\n")); 195 RTMemFree(pPathInfoArray); 195 196 return ERROR_OUTOFMEMORY; 196 197 } … … 200 201 { 201 202 WARN(("VBoxTray: (WDDM) Failed QueryDisplayConfig\n")); 202 free(pPathInfoArray);203 free(pModeInfoArray);203 RTMemFree(pPathInfoArray); 204 RTMemFree(pModeInfoArray); 204 205 return winEr; 205 206 } … … 218 219 if (pCfg->cPathInfoArray) 219 220 { 220 pCfgDst->pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *) malloc(pCfg->cPathInfoArray * sizeof (DISPLAYCONFIG_PATH_INFO));221 pCfgDst->pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)RTMemAlloc(pCfg->cPathInfoArray * sizeof (DISPLAYCONFIG_PATH_INFO)); 221 222 if (!pCfgDst->pPathInfoArray) 222 223 { 223 WARN(("VBoxTray: (WDDM) malloc failed!\n"));224 WARN(("VBoxTray: (WDDM) RTMemAlloc failed!\n")); 224 225 return ERROR_OUTOFMEMORY; 225 226 } … … 232 233 if (pCfg->cModeInfoArray) 233 234 { 234 pCfgDst->pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *) malloc(pCfg->cModeInfoArray * sizeof (DISPLAYCONFIG_MODE_INFO));235 pCfgDst->pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)RTMemAlloc(pCfg->cModeInfoArray * sizeof (DISPLAYCONFIG_MODE_INFO)); 235 236 if (!pCfgDst->pModeInfoArray) 236 237 { 237 WARN(("VBoxTray: (WDDM) malloc failed!\n"));238 WARN(("VBoxTray: (WDDM) RTMemAlloc failed!\n")); 238 239 if (pCfgDst->pPathInfoArray) 239 240 { 240 free(pCfgDst->pPathInfoArray);241 RTMemFree(pCfgDst->pPathInfoArray); 241 242 pCfgDst->pPathInfoArray = NULL; 242 243 } … … 256 257 { 257 258 if (pCfg->pPathInfoArray) 258 free(pCfg->pPathInfoArray);259 RTMemFree(pCfg->pPathInfoArray); 259 260 if (pCfg->pModeInfoArray) 260 free(pCfg->pModeInfoArray);261 RTMemFree(pCfg->pModeInfoArray); 261 262 /* sanity */ 262 263 memset(pCfg, 0, sizeof (*pCfg)); … … 351 352 if (pCfg->pModeInfoArray) 352 353 { 353 free(pCfg->pModeInfoArray);354 RTMemFree(pCfg->pModeInfoArray); 354 355 pCfg->pModeInfoArray = NULL; 355 356 } … … 360 361 { 361 362 UINT32 cModeInfoArray = pCfg->cModeInfoArray + 1; 362 DISPLAYCONFIG_MODE_INFO *pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)malloc(cModeInfoArray * sizeof (DISPLAYCONFIG_MODE_INFO)); 363 DISPLAYCONFIG_MODE_INFO *pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)RTMemAlloc( cModeInfoArray 364 * sizeof (DISPLAYCONFIG_MODE_INFO)); 363 365 if (!pModeInfoArray) 364 366 { 365 WARN(("VBoxTray: (WDDM) malloc failed!\n"));367 WARN(("VBoxTray: (WDDM) RTMemAlloc failed!\n")); 366 368 return ERROR_OUTOFMEMORY; 367 369 } … … 369 371 memcpy (pModeInfoArray, pCfg->pModeInfoArray, pCfg->cModeInfoArray * sizeof(DISPLAYCONFIG_MODE_INFO)); 370 372 memset(&pModeInfoArray[cModeInfoArray-1], 0, sizeof (pModeInfoArray[0])); 371 free(pCfg->pModeInfoArray);373 RTMemFree(pCfg->pModeInfoArray); 372 374 *pIdx = cModeInfoArray-1; 373 375 pCfg->pModeInfoArray = pModeInfoArray; … … 525 527 } 526 528 527 DISPLAYCONFIG_PATH_INFO *pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *) malloc(cDisplays * sizeof(DISPLAYCONFIG_PATH_INFO));529 DISPLAYCONFIG_PATH_INFO *pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)RTMemAlloc(cDisplays * sizeof(DISPLAYCONFIG_PATH_INFO)); 528 530 if (!pPathInfoArray) 529 531 { 530 WARN((" malloc failed\n"));532 WARN(("RTMemAlloc failed\n")); 531 533 return ERROR_OUTOFMEMORY; 532 534 } … … 554 556 { 555 557 WARN(("VBoxTray:(WDDM) vboxDispIfWddmDcCreate Failed winEr %d\n", winEr)); 556 free(pPathInfoArray);558 RTMemFree(pPathInfoArray); 557 559 return winEr; 558 560 } … … 621 623 } 622 624 623 free(pCfg->pPathInfoArray);625 RTMemFree(pCfg->pPathInfoArray); 624 626 pCfg->pPathInfoArray = pPathInfoArray; 625 627 pCfg->cPathInfoArray = cDisplays; … … 932 934 if (pMon->paDisplayDevices) 933 935 { 934 free(pMon->paDisplayDevices);936 RTMemFree(pMon->paDisplayDevices); 935 937 pMon->paDisplayDevices = NULL; 936 938 } … … 938 940 if (pMon->paDeviceModes) 939 941 { 940 free(pMon->paDeviceModes);942 RTMemFree(pMon->paDeviceModes); 941 943 pMon->paDeviceModes = NULL; 942 944 } … … 980 982 if (cDevModes) 981 983 { 982 pMon->paDisplayDevices = (DISPLAY_DEVICE*) malloc(sizeof (*paDisplayDevices) * cDevModes);984 pMon->paDisplayDevices = (DISPLAY_DEVICE*)RTMemAlloc(sizeof (*paDisplayDevices) * cDevModes); 983 985 Assert(pMon->paDisplayDevices); 984 986 if (!pMon->paDisplayDevices) 985 987 { 986 Log((" malloc failed!"));988 Log(("RTMemAlloc failed!")); 987 989 vboxRrRetryStopLocked(); 988 990 LeaveCriticalSection(&pMon->CritSect); … … 991 993 memcpy(pMon->paDisplayDevices, paDisplayDevices, sizeof (*paDisplayDevices) * cDevModes); 992 994 993 pMon->paDeviceModes = (DEVMODE*) malloc(sizeof (*paDeviceModes) * cDevModes);995 pMon->paDeviceModes = (DEVMODE*)RTMemAlloc(sizeof (*paDeviceModes) * cDevModes); 994 996 Assert(pMon->paDeviceModes); 995 997 if (!pMon->paDeviceModes) 996 998 { 997 Log((" malloc failed!"));999 Log(("RTMemAlloc failed!")); 998 1000 vboxRrRetryStopLocked(); 999 1001 LeaveCriticalSection(&pMon->CritSect); … … 1940 1942 { 1941 1943 /* No mode yet. Add the new mode to the ModeInfo array. */ 1942 DISPLAYCONFIG_MODE_INFO *paModeInfo = (DISPLAYCONFIG_MODE_INFO *)realloc(DispCfg.pModeInfoArray, (DispCfg.cModeInfoArray + 1) * sizeof(DISPLAYCONFIG_MODE_INFO)); 1944 DISPLAYCONFIG_MODE_INFO *paModeInfo = (DISPLAYCONFIG_MODE_INFO *)RTMemRealloc(DispCfg.pModeInfoArray, 1945 (DispCfg.cModeInfoArray + 1) 1946 * sizeof(paModeInfo[0])); 1943 1947 if (!paModeInfo) 1944 1948 { … … 2166 2170 else 2167 2171 { 2168 DISPLAYCONFIG_MODE_INFO *pModeInfo, *pModeInfoNew; 2169 2170 pModeInfo = (DISPLAYCONFIG_MODE_INFO *)realloc(DispCfg.pModeInfoArray, (DispCfg.cModeInfoArray + 2) * sizeof(DISPLAYCONFIG_MODE_INFO)); 2171 2172 DISPLAYCONFIG_MODE_INFO *pModeInfo = (DISPLAYCONFIG_MODE_INFO *)RTMemRealloc(DispCfg.pModeInfoArray, 2173 (DispCfg.cModeInfoArray + 2) 2174 * sizeof(pModeInfo[0])); 2172 2175 if (!pModeInfo) 2173 2176 { … … 2182 2185 pPathInfo->targetInfo.id = idx; 2183 2186 2184 pModeInfoNew = &pModeInfo[DispCfg.cModeInfoArray];2187 DISPLAYCONFIG_MODE_INFO *pModeInfoNew = &pModeInfo[DispCfg.cModeInfoArray]; 2185 2188 2186 2189 pModeInfoNew->infoType = DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE; -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp
r95733 r95868 16 16 */ 17 17 18 19 /********************************************************************************************************************************* 20 * Header Files * 21 *********************************************************************************************************************************/ 22 #define LOG_GROUP LOG_GROUP_DEFAULT 18 23 #define _WIN32_WINNT 0x0500 19 24 #include <iprt/win/windows.h> 20 25 26 #include <VBox/log.h> 27 21 28 #include <iprt/assert.h> 22 29 #include <iprt/ldr.h> 30 #include <iprt/mem.h> 23 31 #include <iprt/system.h> 24 32 25 #include <VBoxDisplay.h> 26 #include <VBoxHook.h> 27 28 #ifdef DEBUG 29 # define LOG_ENABLED 30 # define LOG_GROUP LOG_GROUP_DEFAULT 31 #endif 32 #include <VBox/log.h> 33 #include <VBoxDisplay.h> /** @todo r=bird: Presumably the ../include/VBoxDisplay.h file rather than ./VBoxDisplay.h. WTF??? */ 34 #include <VBoxHook.h> /* from ../include/ */ 33 35 34 36 #include "VBoxTray.h" … … 38 40 39 41 42 /********************************************************************************************************************************* 43 * Structures and Typedefs * 44 *********************************************************************************************************************************/ 40 45 typedef struct _VBOXSEAMLESSCONTEXT 41 46 { … … 56 61 } VBOX_ENUM_PARAM, *PVBOX_ENUM_PARAM; 57 62 63 64 /********************************************************************************************************************************* 65 * Global Variables * 66 *********************************************************************************************************************************/ 58 67 static VBOXSEAMLESSCONTEXT g_Ctx = { 0 }; 59 68 69 70 /********************************************************************************************************************************* 71 * Internal Functions * 72 *********************************************************************************************************************************/ 60 73 void VBoxLogString(HANDLE hDriver, char *pszStr); 74 75 61 76 62 77 static DECLCALLBACK(int) VBoxSeamlessInit(const PVBOXSERVICEENV pEnv, void **ppInstance) … … 162 177 if (pCtx->lpEscapeData) 163 178 { 164 free(pCtx->lpEscapeData);179 RTMemFree(pCtx->lpEscapeData); 165 180 pCtx->lpEscapeData = NULL; 166 181 } … … 318 333 if (param.hrgn) 319 334 { 320 DWORD cbSize; 321 322 cbSize = GetRegionData(param.hrgn, 0, NULL); 335 DWORD cbSize = GetRegionData(param.hrgn, 0, NULL); 323 336 if (cbSize) 324 337 { 325 PVBOXDISPIFESCAPE lpEscapeData = (PVBOXDISPIFESCAPE) malloc(VBOXDISPIFESCAPE_SIZE(cbSize));338 PVBOXDISPIFESCAPE lpEscapeData = (PVBOXDISPIFESCAPE)RTMemAllocZ(VBOXDISPIFESCAPE_SIZE(cbSize)); 326 339 if (lpEscapeData) 327 340 { … … 329 342 LPRGNDATA lpRgnData = VBOXDISPIFESCAPE_DATA(lpEscapeData, RGNDATA); 330 343 331 memset(lpRgnData, 0, cbSize);332 344 cbSize = GetRegionData(param.hrgn, cbSize, lpRgnData); 333 334 345 if (cbSize) 335 346 { … … 353 364 354 365 if (pCtx->lpEscapeData) 355 free(pCtx->lpEscapeData);366 RTMemFree(pCtx->lpEscapeData); 356 367 pCtx->lpEscapeData = lpEscapeData; 357 368 } … … 360 371 } 361 372 if (lpEscapeData != pCtx->lpEscapeData) 362 free(lpEscapeData);373 RTMemFree(lpEscapeData); 363 374 } 364 375 }
Note:
See TracChangeset
for help on using the changeset viewer.