Changeset 4524 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Sep 5, 2007 8:34:25 AM (17 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp
r4301 r4524 428 428 } 429 429 430 static NTSTATUS VBoxGuestQueryMemoryBalloon(PVBOXGUESTDEVEXT pDevExt) 431 { 432 /* just perform the request */ 433 VMMDevGetMemBalloonChangeRequest *req = NULL; 434 435 Log(("VBoxGuestQueryMemoryBalloon\n")); 436 437 int rc = VbglGRAlloc((VMMDevRequestHeader **)&req, sizeof(VMMDevGetMemBalloonChangeRequest), VMMDevReq_GetMemBalloonChangeRequest); 438 vmmdevInitRequest(&req->header, VMMDevReq_GetMemBalloonChangeRequest); 439 req->eventAck = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST; 440 441 if (VBOX_SUCCESS(rc)) 442 { 443 rc = VbglGRPerform(&req->header); 444 445 if (VBOX_FAILURE(rc) || VBOX_FAILURE(req->header.rc)) 446 { 447 dprintf(("VBoxGuest::VBoxGuestDeviceControl IOCTL_VBOXGUEST_CTL_CHECK_BALLOON: error issuing request to VMMDev!" 448 "rc = %d, VMMDev rc = %Vrc\n", rc, req->header.rc)); 449 Status = STATUS_UNSUCCESSFUL; 450 } 451 else 452 { 453 454 } 455 456 VbglGRFree(&req->header); 457 } 458 else 459 { 460 Status = STATUS_UNSUCCESSFUL; 461 } 462 } 463 464 430 465 /** 431 466 * Device I/O Control entry point. … … 770 805 pDevExt->ulOldActiveConsoleId = 0; 771 806 } 807 break; 808 } 809 #endif 810 811 #ifdef VBOX_WITH_MANAGEMENT 812 case IOCTL_VBOXGUEST_CTL_CHECK_BALLOON: 813 { 814 Status = VBoxGuestQueryMemoryBalloon(pDevExt); 772 815 break; 773 816 } -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxGuest.cpp
r4516 r4524 25 25 #include <iprt/assert.h> 26 26 #include "helpers.h" 27 #include <winternl.h> 27 28 28 29 typedef struct _VBOXGUESTCONTEXT 29 30 { 30 31 const VBOXSERVICEENV *pEnv; 32 uint32_t uStatInterval; 33 34 NTSTATUS (WINAPI *pfnNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength); 31 35 } VBOXGUESTCONTEXT; 32 36 … … 37 41 int VBoxGuestInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread) 38 42 { 43 HANDLE gVBoxDriver = pEnv->hDriver; 44 DWORD cbReturned; 45 39 46 dprintf(("VBoxGuestInit\n")); 40 47 41 gCtx.pEnv = pEnv; 48 gCtx.pEnv = pEnv; 49 gCtx.uStatInterval = 0; /* default */ 50 51 VMMDevGetStatisticsChangeRequest req; 52 vmmdevInitRequest(&req.header, VMMDevReq_GetStatisticsChangeRequest); 53 req.eventAck = 0; 54 55 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &req, req.header.size, &req, req.header.size, &cbReturned, NULL)) 56 { 57 dprintf(("VBoxGuestThread: new statistics interval %d seconds\n", req.u32StatInterval)); 58 gCtx.uStatInterval = req.u32StatInterval * 1000; 59 } 60 else 61 dprintf(("VBoxGuestThread: DeviceIoControl failed with %d\n", GetLastError())); 62 63 HMODULE hMod = LoadLibrary("NTDLL.DLL"); 64 if (hMod) 65 { 66 *(uintptr_t *)&gCtx.pfnNtQuerySystemInformation = (uintptr_t)GetProcAddress(hMod, "NtQuerySystemInformation"); 67 if (gCtx.pfnNtQuerySystemInformation) 68 dprintf(("gCtx.pfnNtQuerySystemInformation = %x\n", gCtx.pfnNtQuerySystemInformation)); 69 else 70 dprintf(("NTDLL.NtQuerySystemInformation not found!!\n")); 71 } 42 72 43 73 *pfStartThread = true; … … 81 111 /* wait for a seamless change event */ 82 112 VBoxGuestWaitEventInfo waitEvent; 83 waitEvent.u32TimeoutIn = 1000;84 waitEvent.u32EventMaskIn = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST ;113 waitEvent.u32TimeoutIn = (pCtx->uStatInterval) ? pCtx->uStatInterval : 1000; 114 waitEvent.u32EventMaskIn = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST | VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST; 85 115 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL)) 86 116 { … … 98 128 DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_CTL_CHECK_BALLOON, NULL, 0, NULL, 0, NULL, NULL); 99 129 } 130 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST) 131 { 132 VMMDevGetStatisticsChangeRequest req; 133 vmmdevInitRequest(&req.header, VMMDevReq_GetStatisticsChangeRequest); 134 req.eventAck = VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST; 135 136 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &req, req.header.size, &req, req.header.size, &cbReturned, NULL)) 137 { 138 dprintf(("VBoxGuestThread: new statistics interval %d seconds\n", req.u32StatInterval)); 139 pCtx->uStatInterval = req.u32StatInterval * 1000; 140 } 141 else 142 dprintf(("VBoxGuestThread: DeviceIoControl failed with %d\n", GetLastError())); 143 144 } 100 145 } 101 146 else … … 110 155 } 111 156 } 157 if ( gCtx.uStatInterval 158 && gCtx.pfnNtQuerySystemInformation) 159 { 160 SYSTEM_INFO systemInfo; 161 162 /* Query and report guest statistics */ 163 GetSystemInfo(&systemInfo); 164 165 //gCtx.pfnNtQuerySystemInformation( 166 } 112 167 } 113 168 while (!fTerminate); 114 169 115 170 maskInfo.u32OrMask = 0; 116 maskInfo.u32NotMask = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST ;171 maskInfo.u32NotMask = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST | VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST; 117 172 if (DeviceIoControl (gVBoxDriver, IOCTL_VBOXGUEST_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL)) 118 173 {
Note:
See TracChangeset
for help on using the changeset viewer.