VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxService/VBoxServicePageSharing.cpp@ 30030

Last change on this file since 30030 was 30030, checked in by vboxsync, 15 years ago

Include ntoskrnl.exe

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.6 KB
Line 
1/* $Id: VBoxServicePageSharing.cpp 30030 2010-06-04 11:47:58Z vboxsync $ */
2/** @file
3 * VBoxService - Guest page sharing.
4 */
5
6/*
7 * Copyright (C) 2006-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include <iprt/assert.h>
23#include <iprt/avl.h>
24#include <iprt/asm.h>
25#include <iprt/mem.h>
26#include <iprt/stream.h>
27#include <iprt/string.h>
28#include <iprt/semaphore.h>
29#include <iprt/system.h>
30#include <iprt/thread.h>
31#include <iprt/time.h>
32#include <VBox/VBoxGuestLib.h>
33#include "VBoxServiceInternal.h"
34#include "VBoxServiceUtils.h"
35
36
37/*******************************************************************************
38* Global Variables *
39*******************************************************************************/
40
41/** The semaphore we're blocking on. */
42static RTSEMEVENTMULTI g_PageSharingEvent = NIL_RTSEMEVENTMULTI;
43
44#if defined(RT_OS_WINDOWS) && !defined(TARGET_NT4)
45#include <tlhelp32.h>
46#include <psapi.h>
47#include <winternl.h>
48
49typedef struct
50{
51 AVLPVNODECORE Core;
52 HMODULE hModule;
53 char szFileVersion[16];
54 MODULEENTRY32 Info;
55} KNOWN_MODULE, *PKNOWN_MODULE;
56
57#define SystemModuleInformation 11
58
59typedef struct _RTL_PROCESS_MODULE_INFORMATION
60{
61 ULONG Section;
62 PVOID MappedBase;
63 PVOID ImageBase;
64 ULONG ImageSize;
65 ULONG Flags;
66 USHORT LoadOrderIndex;
67 USHORT InitOrderIndex;
68 USHORT LoadCount;
69 USHORT OffsetToFileName;
70 CHAR FullPathName[256];
71} RTL_PROCESS_MODULE_INFORMATION, *PRTL_PROCESS_MODULE_INFORMATION;
72
73typedef struct _RTL_PROCESS_MODULES
74{
75 ULONG NumberOfModules;
76 RTL_PROCESS_MODULE_INFORMATION Modules[1];
77} RTL_PROCESS_MODULES, *PRTL_PROCESS_MODULES;
78
79typedef NTSTATUS (WINAPI *PFNZWQUERYSYSTEMINFORMATION)(ULONG, PVOID, ULONG, PULONG);
80static PFNZWQUERYSYSTEMINFORMATION ZwQuerySystemInformation = NULL;
81static HMODULE hNtdll = 0;
82
83
84static DECLCALLBACK(int) VBoxServicePageSharingEmptyTreeCallback(PAVLPVNODECORE pNode, void *);
85
86static PAVLPVNODECORE pKnownModuleTree = NULL;
87
88/**
89 * Registers a new module with the VMM
90 * @param pModule Module ptr
91 * @param fValidateMemory Validate/touch memory pages or not
92 */
93void VBoxServicePageSharingRegisterModule(PKNOWN_MODULE pModule, bool fValidateMemory)
94{
95 VMMDEVSHAREDREGIONDESC aRegions[VMMDEVSHAREDREGIONDESC_MAX];
96 DWORD dwModuleSize = pModule->Info.modBaseSize;
97 BYTE *pBaseAddress = pModule->Info.modBaseAddr;
98 DWORD cbVersionSize, dummy;
99 BYTE *pVersionInfo;
100
101 VBoxServiceVerbose(3, "VBoxServicePageSharingRegisterModule\n");
102
103 cbVersionSize = GetFileVersionInfoSize(pModule->Info.szExePath, &dummy);
104 if (!cbVersionSize)
105 {
106 VBoxServiceVerbose(3, "VBoxServicePageSharingRegisterModule: GetFileVersionInfoSize failed with %d\n", GetLastError());
107 return;
108 }
109 pVersionInfo = (BYTE *)RTMemAlloc(cbVersionSize);
110 if (!pVersionInfo)
111 return;
112
113 if (!GetFileVersionInfo(pModule->Info.szExePath, 0, cbVersionSize, pVersionInfo))
114 {
115 VBoxServiceVerbose(3, "VBoxServicePageSharingRegisterModule: GetFileVersionInfo failed with %d\n", GetLastError());
116 goto end;
117 }
118
119 /* Fetch default code page. */
120 struct LANGANDCODEPAGE {
121 WORD wLanguage;
122 WORD wCodePage;
123 } *lpTranslate;
124
125 UINT cbTranslate;
126 BOOL ret = VerQueryValue(pVersionInfo, TEXT("\\VarFileInfo\\Translation"), (LPVOID *)&lpTranslate, &cbTranslate);
127 if ( !ret
128 || cbTranslate < 4)
129 {
130 VBoxServiceVerbose(3, "VBoxServicePageSharingRegisterModule: VerQueryValue failed with %d (cb=%d)\n", GetLastError(), cbTranslate);
131 goto end;
132 }
133
134 unsigned i;
135 UINT cbFileVersion;
136 char *lpszFileVersion;
137 unsigned cTranslationBlocks = cbTranslate/sizeof(struct LANGANDCODEPAGE);
138
139 for(i = 0; i < cTranslationBlocks; i++)
140 {
141 /* Fetch file version string. */
142 char szFileVersionLocation[256];
143
144 sprintf(szFileVersionLocation, TEXT("\\StringFileInfo\\%04x%04x\\FileVersion"), lpTranslate[i].wLanguage, lpTranslate[i].wCodePage);
145 ret = VerQueryValue(pVersionInfo, szFileVersionLocation, (LPVOID *)&lpszFileVersion, &cbFileVersion);
146 if (ret)
147 break;
148 }
149 if (i == cTranslationBlocks)
150 {
151 VBoxServiceVerbose(3, "VBoxServicePageSharingRegisterModule: no file version found!\n");
152 goto end;
153 }
154
155 _snprintf(pModule->szFileVersion, sizeof(pModule->szFileVersion), "%s", lpszFileVersion);
156 pModule->szFileVersion[RT_ELEMENTS(pModule->szFileVersion) - 1] = 0;
157
158 unsigned idxRegion = 0;
159
160 if (fValidateMemory)
161 {
162 do
163 {
164 MEMORY_BASIC_INFORMATION MemInfo;
165
166 SIZE_T ret = VirtualQuery(pBaseAddress, &MemInfo, sizeof(MemInfo));
167 Assert(ret);
168 if (!ret)
169 {
170 VBoxServiceVerbose(3, "VBoxServicePageSharingRegisterModule: VirtualQueryEx failed with %d\n", GetLastError());
171 break;
172 }
173
174 if ( MemInfo.State == MEM_COMMIT
175 && MemInfo.Type == MEM_IMAGE)
176 {
177 switch (MemInfo.Protect)
178 {
179 case PAGE_EXECUTE:
180 case PAGE_EXECUTE_READ:
181 case PAGE_READONLY:
182 {
183 char *pRegion = (char *)MemInfo.BaseAddress;
184
185 /* Skip the first region as it only contains the image file header. */
186 if (pRegion != (char *)pModule->Info.modBaseAddr)
187 {
188 /* Touch all pages. */
189 while (pRegion < (char *)MemInfo.BaseAddress + MemInfo.RegionSize)
190 {
191 /* Try to trick the optimizer to leave the page touching code in place. */
192 ASMProbeReadByte(pRegion);
193 pRegion += PAGE_SIZE;
194 }
195 }
196#ifdef RT_ARCH_X86
197 aRegions[idxRegion].GCRegionAddr = (RTGCPTR32)MemInfo.BaseAddress;
198#else
199 aRegions[idxRegion].GCRegionAddr = (RTGCPTR64)MemInfo.BaseAddress;
200#endif
201 aRegions[idxRegion].cbRegion = MemInfo.RegionSize;
202 idxRegion++;
203
204 break;
205 }
206
207 default:
208 break; /* ignore */
209 }
210 }
211
212 pBaseAddress = (BYTE *)MemInfo.BaseAddress + MemInfo.RegionSize;
213 if (dwModuleSize > MemInfo.RegionSize)
214 {
215 dwModuleSize -= MemInfo.RegionSize;
216 }
217 else
218 {
219 dwModuleSize = 0;
220 break;
221 }
222
223 if (idxRegion >= RT_ELEMENTS(aRegions))
224 break; /* out of room */
225 }
226 while (dwModuleSize);
227 }
228 else
229 {
230 /* We can't probe kernel memory ranges, so pretend it's one big region. */
231#ifdef RT_ARCH_X86
232 aRegions[idxRegion].GCRegionAddr = (RTGCPTR32)pBaseAddress;
233#else
234 aRegions[idxRegion].GCRegionAddr = (RTGCPTR64)pBaseAddress;
235#endif
236 aRegions[idxRegion].cbRegion = dwModuleSize;
237 idxRegion++;
238 }
239 VBoxServiceVerbose(3, "VbglR3RegisterSharedModule %s %s base=%p size=%x cregions=%d\n", pModule->Info.szModule, pModule->szFileVersion, pModule->Info.modBaseAddr, pModule->Info.modBaseSize, idxRegion);
240#ifdef RT_ARCH_X86
241 int rc = VbglR3RegisterSharedModule(pModule->Info.szModule, pModule->szFileVersion, (RTGCPTR32)pModule->Info.modBaseAddr,
242 pModule->Info.modBaseSize, idxRegion, aRegions);
243#else
244 int rc = VbglR3RegisterSharedModule(pModule->Info.szModule, pModule->szFileVersion, (RTGCPTR64)pModule->Info.modBaseAddr,
245 pModule->Info.modBaseSize, idxRegion, aRegions);
246#endif
247
248// AssertRC(rc);
249 if (RT_FAILURE(rc))
250 VBoxServiceVerbose(3, "VbglR3RegisterSharedModule failed with %d\n", rc);
251
252end:
253 RTMemFree(pVersionInfo);
254 return;
255}
256
257/**
258 * Inspect all loaded modules for the specified process
259 * @param dwProcessId Process id
260 */
261void VBoxServicePageSharingInspectModules(DWORD dwProcessId, PAVLPVNODECORE *ppNewTree)
262{
263 HANDLE hProcess, hSnapshot;
264
265 /* Get a list of all the modules in this process. */
266 hProcess = OpenProcess(PROCESS_QUERY_INFORMATION,
267 FALSE /* no child process handle inheritance */, dwProcessId);
268 if (hProcess == NULL)
269 {
270 VBoxServiceVerbose(3, "VBoxServicePageSharingInspectModules: OpenProcess %x failed with %d\n", dwProcessId, GetLastError());
271 return;
272 }
273
274 hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId);
275 if (hSnapshot == INVALID_HANDLE_VALUE)
276 {
277 VBoxServiceVerbose(3, "VBoxServicePageSharingInspectModules: CreateToolhelp32Snapshot failed with %d\n", GetLastError());
278 CloseHandle(hProcess);
279 return;
280 }
281
282 VBoxServiceVerbose(3, "VBoxServicePageSharingInspectModules\n");
283
284 MODULEENTRY32 ModuleInfo;
285 BOOL bRet;
286
287 ModuleInfo.dwSize = sizeof(ModuleInfo);
288 bRet = Module32First(hSnapshot, &ModuleInfo);
289 do
290 {
291 /** todo when changing this make sure VBoxService.exe is excluded! */
292 char *pszDot = strrchr(ModuleInfo.szModule, '.');
293 if ( pszDot
294 && (pszDot[1] == 'e' || pszDot[1] == 'E'))
295 continue; /* ignore executables for now. */
296
297 /* Found it before? */
298 PAVLPVNODECORE pRec = RTAvlPVGet(ppNewTree, ModuleInfo.modBaseAddr);
299 if (!pRec)
300 {
301 pRec = RTAvlPVRemove(&pKnownModuleTree, ModuleInfo.modBaseAddr);
302 if (!pRec)
303 {
304 /* New module; register it. */
305 PKNOWN_MODULE pModule = (PKNOWN_MODULE)RTMemAllocZ(sizeof(*pModule));
306 Assert(pModule);
307 if (!pModule)
308 break;
309
310 pModule->Info = ModuleInfo;
311 pModule->Core.Key = ModuleInfo.modBaseAddr;
312 pModule->hModule = LoadLibraryEx(ModuleInfo.szExePath, 0, DONT_RESOLVE_DLL_REFERENCES);
313 if (pModule->hModule)
314 VBoxServicePageSharingRegisterModule(pModule, true /* validate pages */);
315
316 VBoxServiceVerbose(3, "\n\n MODULE NAME: %s", ModuleInfo.szModule );
317 VBoxServiceVerbose(3, "\n executable = %s", ModuleInfo.szExePath );
318 VBoxServiceVerbose(3, "\n process ID = 0x%08X", ModuleInfo.th32ProcessID );
319 VBoxServiceVerbose(3, "\n base address = 0x%08X", (DWORD) ModuleInfo.modBaseAddr );
320 VBoxServiceVerbose(3, "\n base size = %d", ModuleInfo.modBaseSize );
321
322 pRec = &pModule->Core;
323 }
324 bool ret = RTAvlPVInsert(ppNewTree, pRec);
325 Assert(ret); NOREF(ret);
326 }
327 }
328 while (Module32Next(hSnapshot, &ModuleInfo));
329
330 CloseHandle(hSnapshot);
331 CloseHandle(hProcess);
332}
333
334/**
335 * Inspect all running processes for executables and dlls that might be worth sharing
336 * with other VMs.
337 *
338 */
339void VBoxServicePageSharingInspectGuest()
340{
341 HANDLE hSnapshot;
342 PAVLPVNODECORE pNewTree = NULL;
343 DWORD dwProcessId = GetCurrentProcessId();
344
345 VBoxServiceVerbose(3, "VBoxServicePageSharingInspectGuest\n");
346
347 hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
348 if (hSnapshot == INVALID_HANDLE_VALUE)
349 {
350 VBoxServiceVerbose(3, "CreateToolhelp32Snapshot failed with %d\n", GetLastError());
351 return;
352 }
353
354 /* Check loaded modules for all running processes. */
355 PROCESSENTRY32 ProcessInfo;
356
357 ProcessInfo.dwSize = sizeof(ProcessInfo);
358 Process32First(hSnapshot, &ProcessInfo);
359
360 do
361 {
362 /* Skip our own process. */
363 if (ProcessInfo.th32ProcessID != dwProcessId)
364 VBoxServicePageSharingInspectModules(ProcessInfo.th32ProcessID, &pNewTree);
365 }
366 while (Process32Next(hSnapshot, &ProcessInfo));
367
368 CloseHandle(hSnapshot);
369
370 /* Check all loaded kernel modules. */
371 if (ZwQuerySystemInformation)
372 {
373 ULONG cbBuffer = 0;
374 PVOID pBuffer = NULL;
375 PRTL_PROCESS_MODULES pSystemModules;
376
377 NTSTATUS ret = ZwQuerySystemInformation(SystemModuleInformation, (PVOID)&cbBuffer, 0, &cbBuffer);
378 if (!cbBuffer)
379 {
380 VBoxServiceVerbose(1, "ZwQuerySystemInformation returned length 0\n");
381 goto skipkernelmodules;
382 }
383
384 pBuffer = RTMemAllocZ(cbBuffer);
385 if (!pBuffer)
386 goto skipkernelmodules;
387
388 ret = ZwQuerySystemInformation(SystemModuleInformation, pBuffer, cbBuffer, &cbBuffer);
389 if (ret != STATUS_SUCCESS)
390 {
391 VBoxServiceVerbose(1, "ZwQuerySystemInformation returned %x (1)\n", ret);
392 goto skipkernelmodules;
393 }
394
395 pSystemModules = (PRTL_PROCESS_MODULES)pBuffer;
396 for (unsigned i = 0; i < pSystemModules->NumberOfModules; i++)
397 {
398 /* User-mode modules seem to have no flags set; skip them as we detected them above. */
399 if (pSystemModules->Modules[i].Flags == 0)
400 continue;
401
402 char *pszDot = strrchr(pSystemModules->Modules[i].FullPathName, '.');
403 if ( pszDot
404 && (pszDot[1] == 'e' || pszDot[1] == 'E')
405 && strcmp(&pSystemModules->Modules[i].FullPathName[pSystemModules->Modules[i].OffsetToFileName], "ntoskrnl.exe"))
406 continue; /* ignore executables for now. */
407
408 /* Found it before? */
409 PAVLPVNODECORE pRec = RTAvlPVGet(&pNewTree, pSystemModules->Modules[i].ImageBase);
410 if (!pRec)
411 {
412 pRec = RTAvlPVRemove(&pKnownModuleTree, pSystemModules->Modules[i].ImageBase);
413 if (!pRec)
414 {
415 /* New module; register it. */
416 char szFullFilePath[512];
417 PKNOWN_MODULE pModule = (PKNOWN_MODULE)RTMemAllocZ(sizeof(*pModule));
418 Assert(pModule);
419 if (!pModule)
420 break;
421
422 strcpy(pModule->Info.szModule, &pSystemModules->Modules[i].FullPathName[pSystemModules->Modules[i].OffsetToFileName]);
423 GetSystemDirectoryA(szFullFilePath, sizeof(szFullFilePath));
424
425 /* skip \Systemroot\system32 */
426 char *lpPath = strchr(&pSystemModules->Modules[i].FullPathName[1], '\\');
427 if (!lpPath)
428 {
429 VBoxServiceVerbose(1, "Unexpected kernel module name %s\n", pSystemModules->Modules[i].FullPathName);
430 RTMemFree(pModule);
431 break;
432 }
433
434 lpPath = strchr(lpPath+1, '\\');
435 if (!lpPath)
436 {
437 VBoxServiceVerbose(1, "Unexpected kernel module name %s\n", pSystemModules->Modules[i].FullPathName);
438 RTMemFree(pModule);
439 break;
440 }
441
442 strcat(szFullFilePath, lpPath);
443 strcpy(pModule->Info.szExePath, szFullFilePath);
444 pModule->Info.modBaseAddr = (BYTE *)pSystemModules->Modules[i].ImageBase;
445 pModule->Info.modBaseSize = pSystemModules->Modules[i].ImageSize;
446
447 pModule->Core.Key = pSystemModules->Modules[i].ImageBase;
448 VBoxServicePageSharingRegisterModule(pModule, false /* don't check memory pages */);
449
450 VBoxServiceVerbose(3, "\n\n KERNEL MODULE NAME: %s", pModule->Info.szModule );
451 VBoxServiceVerbose(3, "\n executable = %s", pModule->Info.szExePath );
452 VBoxServiceVerbose(3, "\n base address = 0x%08X", (DWORD) pModule->Info.modBaseAddr );
453 VBoxServiceVerbose(3, "\n flags = 0x%08X", pSystemModules->Modules[i].Flags);
454 VBoxServiceVerbose(3, "\n base size = %d", pModule->Info.modBaseSize );
455
456 pRec = &pModule->Core;
457 }
458 bool ret = RTAvlPVInsert(&pNewTree, pRec);
459 Assert(ret); NOREF(ret);
460 }
461 }
462skipkernelmodules:
463 if (pBuffer)
464 RTMemFree(pBuffer);
465 }
466
467 /* Delete leftover modules in the old tree. */
468 RTAvlPVDestroy(&pKnownModuleTree, VBoxServicePageSharingEmptyTreeCallback, NULL);
469
470 /* Check all registered modules. */
471 VbglR3CheckSharedModules();
472
473 /* Activate new module tree. */
474 pKnownModuleTree = pNewTree;
475}
476
477/**
478 * RTAvlPVDestroy callback.
479 */
480static DECLCALLBACK(int) VBoxServicePageSharingEmptyTreeCallback(PAVLPVNODECORE pNode, void *)
481{
482 PKNOWN_MODULE pModule = (PKNOWN_MODULE)pNode;
483
484 VBoxServiceVerbose(3, "VBoxServicePageSharingEmptyTreeCallback %s %s\n", pModule->Info.szModule, pModule->szFileVersion);
485
486 /* Defererence module in the hypervisor. */
487 int rc = VbglR3UnregisterSharedModule(pModule->Info.szModule, pModule->szFileVersion, (RTGCPTR64)pModule->Info.modBaseAddr, pModule->Info.modBaseSize);
488 AssertRC(rc);
489
490 if (pModule->hModule)
491 FreeLibrary(pModule->hModule);
492 RTMemFree(pNode);
493 return 0;
494}
495
496
497#elif TARGET_NT4
498void VBoxServicePageSharingInspectGuest()
499{
500 /* not implemented */
501}
502#else
503void VBoxServicePageSharingInspectGuest()
504{
505 /* @todo other platforms */
506}
507#endif
508
509/** @copydoc VBOXSERVICE::pfnPreInit */
510static DECLCALLBACK(int) VBoxServicePageSharingPreInit(void)
511{
512 return VINF_SUCCESS;
513}
514
515
516/** @copydoc VBOXSERVICE::pfnOption */
517static DECLCALLBACK(int) VBoxServicePageSharingOption(const char **ppszShort, int argc, char **argv, int *pi)
518{
519 NOREF(ppszShort);
520 NOREF(argc);
521 NOREF(argv);
522 NOREF(pi);
523 return VINF_SUCCESS;
524}
525
526
527/** @copydoc VBOXSERVICE::pfnInit */
528static DECLCALLBACK(int) VBoxServicePageSharingInit(void)
529{
530 VBoxServiceVerbose(3, "VBoxServicePageSharingInit\n");
531
532 int rc = RTSemEventMultiCreate(&g_PageSharingEvent);
533 AssertRCReturn(rc, rc);
534
535#if defined(RT_OS_WINDOWS) && !defined(TARGET_NT4)
536 hNtdll = LoadLibrary("ntdll.dll");
537
538 if (hNtdll)
539 ZwQuerySystemInformation = (PFNZWQUERYSYSTEMINFORMATION)GetProcAddress(hNtdll, "ZwQuerySystemInformation");
540#endif
541
542 /* @todo report system name and version */
543 /* Never fail here. */
544 return VINF_SUCCESS;
545}
546
547/** @copydoc VBOXSERVICE::pfnWorker */
548DECLCALLBACK(int) VBoxServicePageSharingWorker(bool volatile *pfShutdown)
549{
550 /*
551 * Tell the control thread that it can continue
552 * spawning services.
553 */
554 RTThreadUserSignal(RTThreadSelf());
555
556 /*
557 * Block here first for a minute as using DONT_RESOLVE_DLL_REFERENCES is kind of risky; other code that uses LoadLibrary on a dll loaded like this
558 * before will end up crashing the process as the dll's init routine was never called.
559 *
560 * We have to use this feature as we can't simply execute all init code in our service process.
561 *
562 */
563 int rc = RTSemEventMultiWait(g_PageSharingEvent, 60000);
564 if (*pfShutdown)
565 goto end;
566
567 if (rc != VERR_TIMEOUT && RT_FAILURE(rc))
568 {
569 VBoxServiceError("RTSemEventMultiWait failed; rc=%Rrc\n", rc);
570 goto end;
571 }
572
573 /*
574 * Now enter the loop retrieving runtime data continuously.
575 */
576 for (;;)
577 {
578 VBoxServiceVerbose(3, "VBoxServicePageSharingWorker: enabled=%d\n", VbglR3PageSharingIsEnabled());
579
580 if (VbglR3PageSharingIsEnabled())
581 VBoxServicePageSharingInspectGuest();
582
583 /*
584 * Block for a minute.
585 *
586 * The event semaphore takes care of ignoring interruptions and it
587 * allows us to implement service wakeup later.
588 */
589 if (*pfShutdown)
590 break;
591 rc = RTSemEventMultiWait(g_PageSharingEvent, 60000);
592 if (*pfShutdown)
593 break;
594 if (rc != VERR_TIMEOUT && RT_FAILURE(rc))
595 {
596 VBoxServiceError("RTSemEventMultiWait failed; rc=%Rrc\n", rc);
597 break;
598 }
599 }
600
601end:
602 RTSemEventMultiDestroy(g_PageSharingEvent);
603 g_PageSharingEvent = NIL_RTSEMEVENTMULTI;
604
605 VBoxServiceVerbose(3, "VBoxServicePageSharingWorker: finished thread\n");
606 return 0;
607}
608
609/** @copydoc VBOXSERVICE::pfnTerm */
610static DECLCALLBACK(void) VBoxServicePageSharingTerm(void)
611{
612 VBoxServiceVerbose(3, "VBoxServicePageSharingTerm\n");
613
614#if defined(RT_OS_WINDOWS) && !defined(TARGET_NT4)
615 if (hNtdll)
616 FreeLibrary(hNtdll);
617#endif
618 return;
619}
620
621
622/** @copydoc VBOXSERVICE::pfnStop */
623static DECLCALLBACK(void) VBoxServicePageSharingStop(void)
624{
625 RTSemEventMultiSignal(g_PageSharingEvent);
626}
627
628
629/**
630 * The 'pagesharing' service description.
631 */
632VBOXSERVICE g_PageSharing =
633{
634 /* pszName. */
635 "pagesharing",
636 /* pszDescription. */
637 "Page Sharing",
638 /* pszUsage. */
639 NULL,
640 /* pszOptions. */
641 NULL,
642 /* methods */
643 VBoxServicePageSharingPreInit,
644 VBoxServicePageSharingOption,
645 VBoxServicePageSharingInit,
646 VBoxServicePageSharingWorker,
647 VBoxServicePageSharingStop,
648 VBoxServicePageSharingTerm
649};
Note: See TracBrowser for help on using the repository browser.

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