VirtualBox

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

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

scm cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.5 KB
Line 
1/* $Id: VBoxServicePageSharing.cpp 30013 2010-06-03 14:40:59Z 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 continue; /* ignore executables for now. */
406
407 /* Found it before? */
408 PAVLPVNODECORE pRec = RTAvlPVGet(&pNewTree, pSystemModules->Modules[i].ImageBase);
409 if (!pRec)
410 {
411 pRec = RTAvlPVRemove(&pKnownModuleTree, pSystemModules->Modules[i].ImageBase);
412 if (!pRec)
413 {
414 /* New module; register it. */
415 char szFullFilePath[512];
416 PKNOWN_MODULE pModule = (PKNOWN_MODULE)RTMemAllocZ(sizeof(*pModule));
417 Assert(pModule);
418 if (!pModule)
419 break;
420
421 strcpy(pModule->Info.szModule, &pSystemModules->Modules[i].FullPathName[pSystemModules->Modules[i].OffsetToFileName]);
422 GetSystemDirectoryA(szFullFilePath, sizeof(szFullFilePath));
423
424 /* skip \Systemroot\system32 */
425 char *lpPath = strchr(&pSystemModules->Modules[i].FullPathName[1], '\\');
426 if (!lpPath)
427 {
428 VBoxServiceVerbose(1, "Unexpected kernel module name %s\n", pSystemModules->Modules[i].FullPathName);
429 RTMemFree(pModule);
430 break;
431 }
432
433 lpPath = strchr(lpPath+1, '\\');
434 if (!lpPath)
435 {
436 VBoxServiceVerbose(1, "Unexpected kernel module name %s\n", pSystemModules->Modules[i].FullPathName);
437 RTMemFree(pModule);
438 break;
439 }
440
441 strcat(szFullFilePath, lpPath);
442 strcpy(pModule->Info.szExePath, szFullFilePath);
443 pModule->Info.modBaseAddr = (BYTE *)pSystemModules->Modules[i].ImageBase;
444 pModule->Info.modBaseSize = pSystemModules->Modules[i].ImageSize;
445
446 pModule->Core.Key = pSystemModules->Modules[i].ImageBase;
447 VBoxServicePageSharingRegisterModule(pModule, false /* don't check memory pages */);
448
449 VBoxServiceVerbose(3, "\n\n KERNEL MODULE NAME: %s", pModule->Info.szModule );
450 VBoxServiceVerbose(3, "\n executable = %s", pModule->Info.szExePath );
451 VBoxServiceVerbose(3, "\n base address = 0x%08X", (DWORD) pModule->Info.modBaseAddr );
452 VBoxServiceVerbose(3, "\n flags = 0x%08X", pSystemModules->Modules[i].Flags);
453 VBoxServiceVerbose(3, "\n base size = %d", pModule->Info.modBaseSize );
454
455 pRec = &pModule->Core;
456 }
457 bool ret = RTAvlPVInsert(&pNewTree, pRec);
458 Assert(ret); NOREF(ret);
459 }
460 }
461skipkernelmodules:
462 if (pBuffer)
463 RTMemFree(pBuffer);
464 }
465
466 /* Delete leftover modules in the old tree. */
467 RTAvlPVDestroy(&pKnownModuleTree, VBoxServicePageSharingEmptyTreeCallback, NULL);
468
469 /* Check all registered modules. */
470 VbglR3CheckSharedModules();
471
472 /* Activate new module tree. */
473 pKnownModuleTree = pNewTree;
474}
475
476/**
477 * RTAvlPVDestroy callback.
478 */
479static DECLCALLBACK(int) VBoxServicePageSharingEmptyTreeCallback(PAVLPVNODECORE pNode, void *)
480{
481 PKNOWN_MODULE pModule = (PKNOWN_MODULE)pNode;
482
483 VBoxServiceVerbose(3, "VBoxServicePageSharingEmptyTreeCallback %s %s\n", pModule->Info.szModule, pModule->szFileVersion);
484
485 /* Defererence module in the hypervisor. */
486 int rc = VbglR3UnregisterSharedModule(pModule->Info.szModule, pModule->szFileVersion, (RTGCPTR64)pModule->Info.modBaseAddr, pModule->Info.modBaseSize);
487 AssertRC(rc);
488
489 if (pModule->hModule)
490 FreeLibrary(pModule->hModule);
491 RTMemFree(pNode);
492 return 0;
493}
494
495
496#elif TARGET_NT4
497void VBoxServicePageSharingInspectGuest()
498{
499 /* not implemented */
500}
501#else
502void VBoxServicePageSharingInspectGuest()
503{
504 /* @todo other platforms */
505}
506#endif
507
508/** @copydoc VBOXSERVICE::pfnPreInit */
509static DECLCALLBACK(int) VBoxServicePageSharingPreInit(void)
510{
511 return VINF_SUCCESS;
512}
513
514
515/** @copydoc VBOXSERVICE::pfnOption */
516static DECLCALLBACK(int) VBoxServicePageSharingOption(const char **ppszShort, int argc, char **argv, int *pi)
517{
518 NOREF(ppszShort);
519 NOREF(argc);
520 NOREF(argv);
521 NOREF(pi);
522 return VINF_SUCCESS;
523}
524
525
526/** @copydoc VBOXSERVICE::pfnInit */
527static DECLCALLBACK(int) VBoxServicePageSharingInit(void)
528{
529 VBoxServiceVerbose(3, "VBoxServicePageSharingInit\n");
530
531 int rc = RTSemEventMultiCreate(&g_PageSharingEvent);
532 AssertRCReturn(rc, rc);
533
534#if defined(RT_OS_WINDOWS) && !defined(TARGET_NT4)
535 hNtdll = LoadLibrary("ntdll.dll");
536
537 if (hNtdll)
538 ZwQuerySystemInformation = (PFNZWQUERYSYSTEMINFORMATION)GetProcAddress(hNtdll, "ZwQuerySystemInformation");
539#endif
540
541 /* @todo report system name and version */
542 /* Never fail here. */
543 return VINF_SUCCESS;
544}
545
546/** @copydoc VBOXSERVICE::pfnWorker */
547DECLCALLBACK(int) VBoxServicePageSharingWorker(bool volatile *pfShutdown)
548{
549 /*
550 * Tell the control thread that it can continue
551 * spawning services.
552 */
553 RTThreadUserSignal(RTThreadSelf());
554
555 /*
556 * 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
557 * before will end up crashing the process as the dll's init routine was never called.
558 *
559 * We have to use this feature as we can't simply execute all init code in our service process.
560 *
561 */
562 int rc = RTSemEventMultiWait(g_PageSharingEvent, 60000);
563 if (*pfShutdown)
564 goto end;
565
566 if (rc != VERR_TIMEOUT && RT_FAILURE(rc))
567 {
568 VBoxServiceError("RTSemEventMultiWait failed; rc=%Rrc\n", rc);
569 goto end;
570 }
571
572 /*
573 * Now enter the loop retrieving runtime data continuously.
574 */
575 for (;;)
576 {
577 VBoxServiceVerbose(3, "VBoxServicePageSharingWorker: enabled=%d\n", VbglR3PageSharingIsEnabled());
578
579 if (VbglR3PageSharingIsEnabled())
580 VBoxServicePageSharingInspectGuest();
581
582 /*
583 * Block for a minute.
584 *
585 * The event semaphore takes care of ignoring interruptions and it
586 * allows us to implement service wakeup later.
587 */
588 if (*pfShutdown)
589 break;
590 rc = RTSemEventMultiWait(g_PageSharingEvent, 60000);
591 if (*pfShutdown)
592 break;
593 if (rc != VERR_TIMEOUT && RT_FAILURE(rc))
594 {
595 VBoxServiceError("RTSemEventMultiWait failed; rc=%Rrc\n", rc);
596 break;
597 }
598 }
599
600end:
601 RTSemEventMultiDestroy(g_PageSharingEvent);
602 g_PageSharingEvent = NIL_RTSEMEVENTMULTI;
603
604 VBoxServiceVerbose(3, "VBoxServicePageSharingWorker: finished thread\n");
605 return 0;
606}
607
608/** @copydoc VBOXSERVICE::pfnTerm */
609static DECLCALLBACK(void) VBoxServicePageSharingTerm(void)
610{
611 VBoxServiceVerbose(3, "VBoxServicePageSharingTerm\n");
612
613#if defined(RT_OS_WINDOWS) && !defined(TARGET_NT4)
614 if (hNtdll)
615 FreeLibrary(hNtdll);
616#endif
617 return;
618}
619
620
621/** @copydoc VBOXSERVICE::pfnStop */
622static DECLCALLBACK(void) VBoxServicePageSharingStop(void)
623{
624 RTSemEventMultiSignal(g_PageSharingEvent);
625}
626
627
628/**
629 * The 'pagesharing' service description.
630 */
631VBOXSERVICE g_PageSharing =
632{
633 /* pszName. */
634 "pagesharing",
635 /* pszDescription. */
636 "Page Sharing",
637 /* pszUsage. */
638 NULL,
639 /* pszOptions. */
640 NULL,
641 /* methods */
642 VBoxServicePageSharingPreInit,
643 VBoxServicePageSharingOption,
644 VBoxServicePageSharingInit,
645 VBoxServicePageSharingWorker,
646 VBoxServicePageSharingStop,
647 VBoxServicePageSharingTerm
648};
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