- Timestamp:
- Jan 28, 2010 2:32:05 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57043
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp ¶
r26083 r26085 82 82 default: 83 83 VBoxServiceError("Token class not implemented: %ld", tkClass); 84 rc = VERR_NOT_IMPLEMENTED; 84 85 break; 85 86 } … … 124 125 AssertPtr(pdwCount); 125 126 126 DWORD dw Size = 256; /* Number of processes our array can hold */127 DWORD *pdwProcIDs = (DWORD*)RTMemAlloc(dw Size* sizeof(DWORD));127 DWORD dwNumProcs = 128; /* Number of processes our array can hold */ 128 DWORD *pdwProcIDs = (DWORD*)RTMemAlloc(dwNumProcs * sizeof(DWORD)); 128 129 if (pdwProcIDs == NULL) 129 130 return VERR_NO_MEMORY; 130 131 131 132 int rc; 132 DWORD dwNeeded;133 DWORD cbRet; /* Returned size in bytes */ 133 134 do 134 135 { 135 if (FALSE == EnumProcesses(pdwProcIDs, dw Size * sizeof(DWORD), &dwNeeded))136 if (FALSE == EnumProcesses(pdwProcIDs, dwNumProcs * sizeof(DWORD), &cbRet)) 136 137 { 137 138 rc = RTErrConvertFromWin32(GetLastError()); … … 140 141 141 142 /* Was our array big enough? Or do we need more space? */ 142 if ( dwNeeded >= dwSize)143 if (cbRet >= dwNumProcs * sizeof(DWORD)) 143 144 { 144 145 /* Apparently not, so try next bigger size */ 145 dw Size += 256;146 pdwProcIDs = (DWORD*)RTMemRealloc(pdwProcIDs, dw Size* sizeof(DWORD));146 dwNumProcs += 128; 147 pdwProcIDs = (DWORD*)RTMemRealloc(pdwProcIDs, dwNumProcs * sizeof(DWORD)); 147 148 if (pdwProcIDs == NULL) 148 149 { … … 156 157 break; 157 158 } 158 } while( dwNeeded >= dwSize);159 } while(cbRet >= dwNumProcs * sizeof(DWORD)); 159 160 160 161 if (RT_SUCCESS(rc)) 161 162 { 162 163 /* Allocate our process structure */ 163 *ppProc = (PVBOXSERVICEVMINFOPROC)RTMemAlloc(dwN eeded* sizeof(VBOXSERVICEVMINFOPROC));164 *ppProc = (PVBOXSERVICEVMINFOPROC)RTMemAlloc(dwNumProcs * sizeof(VBOXSERVICEVMINFOPROC)); 164 165 if (ppProc == NULL) 165 166 rc = VERR_NO_MEMORY; … … 170 171 PVBOXSERVICEVMINFOPROC pCur = *ppProc; 171 172 DWORD *pCurProcID = pdwProcIDs; 172 for (DWORD i=0; i<dwN eeded; i++)173 for (DWORD i=0; i<dwNumProcs; i++) 173 174 { 174 175 RT_BZERO(pCur, sizeof(VBOXSERVICEVMINFOPROC)); … … 185 186 } 186 187 /* Save number of processes */ 187 *pdwCount = dwN eeded;188 *pdwCount = dwNumProcs; 188 189 } 189 190 } … … 227 228 { 228 229 /*VBoxServiceVerbose(3, "%ld:%ld <-> %ld:%ld\n", 229 pCur->luid.HighPart, pCur->luid.LowPart,230 pSessionData->LogonId.HighPart, pSessionData->LogonId.LowPart);*/230 pCur->luid.HighPart, pCur->luid.LowPart, 231 pSessionData->LogonId.HighPart, pSessionData->LogonId.LowPart);*/ 231 232 if ( pCur->luid.HighPart == pSessionData->LogonId.HighPart 232 233 && pCur->luid.LowPart == pSessionData->LogonId.LowPart) -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp ¶
r26083 r26085 225 225 rc = VBoxServiceVMInfoWinProcessesEnumerate(&pProcs, &dwNumProcs); 226 226 227 VBOXSERVICEVMINFOUSER userInfo;228 ZeroMemory (&userInfo, sizeof(VBOXSERVICEVMINFOUSER));229 230 227 for (ULONG i=0; i<ulCount; i++) 231 228 { 229 VBOXSERVICEVMINFOUSER userInfo; 230 ZeroMemory (&userInfo, sizeof(VBOXSERVICEVMINFOUSER)); 231 232 232 if ( VBoxServiceVMInfoWinIsLoggedIn(&userInfo, &pSessions[i]) 233 233 && VBoxServiceVMInfoWinSessionGetProcessCount(&pSessions[i], pProcs, dwNumProcs) > 0)
Note:
See TracChangeset
for help on using the changeset viewer.