VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp@ 80484

Last change on this file since 80484 was 80033, checked in by vboxsync, 5 years ago

Runtime/r3/win/vcc100-kernel32-fakes.cpp: Include CreateIoCompletionPort, GetQueuedCompletionStatus and PostQueuedCompletionStatus for fileaio-win.cpp which got promoted to RuntimeR3 previously [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.1 KB
Line 
1/* $Id: vcc100-kernel32-fakes.cpp 80033 2019-07-28 22:16:32Z vboxsync $ */
2/** @file
3 * IPRT - Tricks to make the Visual C++ 2010 CRT work on NT4, W2K and XP.
4 */
5
6/*
7 * Copyright (C) 2012-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. 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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include <iprt/cdefs.h>
32#include <iprt/types.h>
33#include <iprt/asm.h>
34#include <iprt/assert.h>
35#include <iprt/string.h>
36#ifdef DEBUG
37# include <stdio.h> /* _snprintf */
38#endif
39
40#ifndef RT_ARCH_X86
41# error "This code is X86 only"
42#endif
43
44#include <iprt/nt/nt-and-windows.h>
45
46#include "vcc100-fakes.h"
47
48
49/*********************************************************************************************************************************
50* Defined Constants And Macros *
51*********************************************************************************************************************************/
52#ifndef HEAP_STANDARD
53# define HEAP_STANDARD 0
54#endif
55
56
57/** Declare a kernel32 API.
58 * @note We are not exporting them as that causes duplicate symbol troubles in
59 * the OpenGL bits. */
60#define DECL_KERNEL32(a_Type) extern "C" a_Type WINAPI
61
62
63
64/*********************************************************************************************************************************
65* Global Variables *
66*********************************************************************************************************************************/
67static volatile bool g_fInitialized = false;
68#define MAKE_IMPORT_ENTRY(a_uMajorVer, a_uMinorVer, a_Name, a_cb) DECLARE_FUNCTION_POINTER(a_Name, a_cb)
69#include "vcc100-kernel32-fakes.h"
70
71
72
73DECL_KERNEL32(PVOID) Fake_DecodePointer(PVOID pvEncoded)
74{
75 return pvEncoded;
76}
77
78
79DECL_KERNEL32(PVOID) Fake_EncodePointer(PVOID pvNative)
80{
81 return pvNative;
82}
83
84
85DECL_KERNEL32(BOOL) Fake_InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin)
86{
87 RT_NOREF(cSpin);
88 InitializeCriticalSection(pCritSect);
89 return TRUE;
90}
91
92
93DECL_KERNEL32(HANDLE) Fake_CreateIoCompletionPort(HANDLE hFile, HANDLE hExistingCompletionPort, ULONG_PTR uCompletionKey,
94 DWORD cConcurrentThreads)
95{
96 RT_NOREF(hFile, hExistingCompletionPort, uCompletionKey, cConcurrentThreads);
97 SetLastError(ERROR_NOT_SUPPORTED);
98 return NULL;
99}
100
101
102DECL_KERNEL32(BOOL) Fake_GetQueuedCompletionStatus(HANDLE hCompletionPort, PDWORD_PTR pcbTransfered, PULONG_PTR puCompletionKey,
103 LPOVERLAPPED *ppOverlapped, DWORD cMs)
104{
105 RT_NOREF(hCompletionPort, pcbTransfered, puCompletionKey, ppOverlapped, cMs);
106 SetLastError(ERROR_NOT_SUPPORTED);
107 return FALSE;
108}
109
110
111DECL_KERNEL32(BOOL) Fake_PostQueuedCompletionStatus(HANDLE hCompletionPort, DWORD cbTransfered, ULONG_PTR uCompletionKey,
112 LPOVERLAPPED pOverlapped)
113{
114 RT_NOREF(hCompletionPort, cbTransfered, uCompletionKey, pOverlapped);
115 SetLastError(ERROR_NOT_SUPPORTED);
116 return FALSE;
117}
118
119
120DECL_KERNEL32(BOOL) Fake_HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf)
121{
122 RT_NOREF(hHeap);
123 if (enmInfoClass == HeapCompatibilityInformation)
124 {
125 if ( cbBuf != sizeof(ULONG)
126 || !pvBuf
127 || *(PULONG)pvBuf == HEAP_STANDARD
128 )
129 {
130 SetLastError(ERROR_INVALID_PARAMETER);
131 return FALSE;
132 }
133 return TRUE;
134 }
135
136 SetLastError(ERROR_INVALID_PARAMETER);
137 return FALSE;
138}
139
140
141DECL_KERNEL32(BOOL) Fake_HeapQueryInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass,
142 PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet)
143{
144 RT_NOREF(hHeap);
145 if (enmInfoClass == HeapCompatibilityInformation)
146 {
147 *pcbRet = sizeof(ULONG);
148 if (cbBuf < sizeof(ULONG) || !pvBuf)
149 {
150 SetLastError(ERROR_INSUFFICIENT_BUFFER);
151 return FALSE;
152 }
153 *(PULONG)pvBuf = HEAP_STANDARD;
154 return TRUE;
155 }
156
157 SetLastError(ERROR_INVALID_PARAMETER);
158 return FALSE;
159}
160
161
162/* These are used by INTEL\mt_obj\Timer.obj: */
163
164DECL_KERNEL32(HANDLE) Fake_CreateTimerQueue(void)
165{
166 SetLastError(ERROR_NOT_SUPPORTED);
167 return NULL;
168}
169
170DECL_KERNEL32(BOOL) Fake_CreateTimerQueueTimer(PHANDLE phTimer, HANDLE hTimerQueue, WAITORTIMERCALLBACK pfnCallback, PVOID pvUser,
171 DWORD msDueTime, DWORD msPeriod, ULONG fFlags)
172{
173 NOREF(phTimer); NOREF(hTimerQueue); NOREF(pfnCallback); NOREF(pvUser); NOREF(msDueTime); NOREF(msPeriod); NOREF(fFlags);
174 SetLastError(ERROR_NOT_SUPPORTED);
175 return FALSE;
176}
177
178DECL_KERNEL32(BOOL) Fake_DeleteTimerQueueTimer(HANDLE hTimerQueue, HANDLE hTimer, HANDLE hEvtCompletion)
179{
180 NOREF(hTimerQueue); NOREF(hTimer); NOREF(hEvtCompletion);
181 SetLastError(ERROR_NOT_SUPPORTED);
182 return FALSE;
183}
184
185/* This is used by several APIs. */
186
187DECL_KERNEL32(VOID) Fake_InitializeSListHead(PSLIST_HEADER pHead)
188{
189 pHead->Alignment = 0;
190}
191
192
193DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedFlushSList(PSLIST_HEADER pHead)
194{
195 PSLIST_ENTRY pRet = NULL;
196 if (pHead->Next.Next)
197 {
198 for (;;)
199 {
200 SLIST_HEADER OldHead = *pHead;
201 SLIST_HEADER NewHead;
202 NewHead.Alignment = 0;
203 NewHead.Sequence = OldHead.Sequence + 1;
204 if (ASMAtomicCmpXchgU64(&pHead->Alignment, NewHead.Alignment, OldHead.Alignment))
205 {
206 pRet = OldHead.Next.Next;
207 break;
208 }
209 }
210 }
211 return pRet;
212}
213
214DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedPopEntrySList(PSLIST_HEADER pHead)
215{
216 PSLIST_ENTRY pRet = NULL;
217 for (;;)
218 {
219 SLIST_HEADER OldHead = *pHead;
220 pRet = OldHead.Next.Next;
221 if (pRet)
222 {
223 SLIST_HEADER NewHead;
224 __try
225 {
226 NewHead.Next.Next = pRet->Next;
227 }
228 __except(EXCEPTION_EXECUTE_HANDLER)
229 {
230 continue;
231 }
232 NewHead.Depth = OldHead.Depth - 1;
233 NewHead.Sequence = OldHead.Sequence + 1;
234 if (ASMAtomicCmpXchgU64(&pHead->Alignment, NewHead.Alignment, OldHead.Alignment))
235 break;
236 }
237 else
238 break;
239 }
240 return pRet;
241}
242
243DECL_KERNEL32(PSLIST_ENTRY) Fake_InterlockedPushEntrySList(PSLIST_HEADER pHead, PSLIST_ENTRY pEntry)
244{
245 PSLIST_ENTRY pRet = NULL;
246 for (;;)
247 {
248 SLIST_HEADER OldHead = *pHead;
249 pRet = OldHead.Next.Next;
250 pEntry->Next = pRet;
251 SLIST_HEADER NewHead;
252 NewHead.Next.Next = pEntry;
253 NewHead.Depth = OldHead.Depth + 1;
254 NewHead.Sequence = OldHead.Sequence + 1;
255 if (ASMAtomicCmpXchgU64(&pHead->Alignment, NewHead.Alignment, OldHead.Alignment))
256 break;
257 }
258 return pRet;
259}
260
261DECL_KERNEL32(WORD) Fake_QueryDepthSList(PSLIST_HEADER pHead)
262{
263 return pHead->Depth;
264}
265
266
267/* curl drags these in: */
268DECL_KERNEL32(BOOL) Fake_VerifyVersionInfoA(LPOSVERSIONINFOEXA pInfo, DWORD fTypeMask, DWORDLONG fConditionMask)
269{
270 OSVERSIONINFOEXA VerInfo;
271 RT_ZERO(VerInfo);
272 VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);
273 if (!GetVersionExA((OSVERSIONINFO *)&VerInfo))
274 {
275 RT_ZERO(VerInfo);
276 VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
277 BOOL fRet = GetVersionExA((OSVERSIONINFO *)&VerInfo);
278 if (fRet)
279 { /* likely */ }
280 else
281 {
282 MY_ASSERT(false, "VerifyVersionInfoA: #1");
283 return FALSE;
284 }
285 }
286
287 BOOL fRet = TRUE;
288 for (unsigned i = 0; i < 8 && fRet; i++)
289 if (fTypeMask & RT_BIT_32(i))
290 {
291 uint32_t uLeft, uRight;
292 switch (RT_BIT_32(i))
293 {
294#define MY_CASE(a_Num, a_Member) case a_Num: uLeft = VerInfo.a_Member; uRight = pInfo->a_Member; break
295 MY_CASE(VER_MINORVERSION, dwMinorVersion);
296 MY_CASE(VER_MAJORVERSION, dwMajorVersion);
297 MY_CASE(VER_BUILDNUMBER, dwBuildNumber);
298 MY_CASE(VER_PLATFORMID, dwPlatformId);
299 MY_CASE(VER_SERVICEPACKMINOR, wServicePackMinor);
300 MY_CASE(VER_SERVICEPACKMAJOR, wServicePackMinor);
301 MY_CASE(VER_SUITENAME, wSuiteMask);
302 MY_CASE(VER_PRODUCT_TYPE, wProductType);
303#undef MY_CASE
304 default: uLeft = uRight = 0; MY_ASSERT(false, "VerifyVersionInfoA: #2");
305 }
306 switch ((uint8_t)(fConditionMask >> (i*8)))
307 {
308 case VER_EQUAL: fRet = uLeft == uRight; break;
309 case VER_GREATER: fRet = uLeft > uRight; break;
310 case VER_GREATER_EQUAL: fRet = uLeft >= uRight; break;
311 case VER_LESS: fRet = uLeft < uRight; break;
312 case VER_LESS_EQUAL: fRet = uLeft <= uRight; break;
313 case VER_AND: fRet = (uLeft & uRight) == uRight; break;
314 case VER_OR: fRet = (uLeft & uRight) != 0; break;
315 default: fRet = FALSE; MY_ASSERT(false, "VerifyVersionInfoA: #3"); break;
316 }
317 }
318
319 return fRet;
320}
321
322
323DECL_KERNEL32(ULONGLONG) Fake_VerSetConditionMask(ULONGLONG fConditionMask, DWORD fTypeMask, BYTE bOperator)
324{
325 for (unsigned i = 0; i < 8; i++)
326 if (fTypeMask & RT_BIT_32(i))
327 {
328 uint64_t fMask = UINT64_C(0xff) << (i*8);
329 fConditionMask &= ~fMask;
330 fConditionMask |= (uint64_t)bOperator << (i*8);
331
332 }
333 return fConditionMask;
334}
335
336
337/*
338 * NT 3.51 stuff.
339 */
340
341DECL_KERNEL32(BOOL) Fake_IsProcessorFeaturePresent(DWORD enmProcessorFeature)
342{
343 /* Could make more of an effort here... */
344 RT_NOREF(enmProcessorFeature);
345 return FALSE;
346}
347
348
349DECL_KERNEL32(BOOL) Fake_CancelIo(HANDLE hHandle)
350{
351 /* All NT versions the NTDLL API this corresponds to. */
352 RESOLVE_NTDLL_API(NtCancelIoFile);
353 if (pfnNtCancelIoFile)
354 {
355 IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
356 NTSTATUS rcNt = pfnNtCancelIoFile(hHandle, &Ios);
357 if (RT_SUCCESS(rcNt))
358 return TRUE;
359 if (rcNt == STATUS_INVALID_HANDLE)
360 SetLastError(ERROR_INVALID_HANDLE);
361 else
362 SetLastError(ERROR_INVALID_FUNCTION);
363 }
364 else
365 SetLastError(ERROR_NOT_SUPPORTED);
366 return FALSE;
367}
368
369
370/*
371 * NT 3.50 stuff.
372 */
373
374DECL_KERNEL32(BOOL) Fake_IsDebuggerPresent(VOID)
375{
376 /* Fallback: */
377 return FALSE;
378}
379
380
381DECL_KERNEL32(VOID) Fake_GetSystemTimeAsFileTime(LPFILETIME pTime)
382{
383 DWORD dwVersion = GetVersion();
384 if ( (dwVersion & 0xff) > 3
385 || ( (dwVersion & 0xff) == 3
386 && ((dwVersion >> 8) & 0xff) >= 50) )
387 {
388 PKUSER_SHARED_DATA pUsd = (PKUSER_SHARED_DATA)MM_SHARED_USER_DATA_VA;
389
390 /* use interrupt time */
391 LARGE_INTEGER Time;
392 do
393 {
394 Time.HighPart = pUsd->SystemTime.High1Time;
395 Time.LowPart = pUsd->SystemTime.LowPart;
396 } while (pUsd->SystemTime.High2Time != Time.HighPart);
397
398 pTime->dwHighDateTime = Time.HighPart;
399 pTime->dwLowDateTime = Time.LowPart;
400 }
401 else
402 {
403 /* NT 3.1 didn't have a KUSER_SHARED_DATA nor a GetSystemTimeAsFileTime export. */
404 SYSTEMTIME SystemTime;
405 GetSystemTime(&SystemTime);
406 BOOL fRet = SystemTimeToFileTime(&SystemTime, pTime);
407 if (fRet)
408 { /* likely */ }
409 else
410 {
411 MY_ASSERT(false, "GetSystemTimeAsFileTime: #2");
412 pTime->dwHighDateTime = 0;
413 pTime->dwLowDateTime = 0;
414 }
415 }
416}
417
418
419/*
420 * NT 3.1 stuff.
421 */
422
423DECL_KERNEL32(BOOL) Fake_GetVersionExA(LPOSVERSIONINFOA pInfo)
424{
425 DWORD dwVersion = GetVersion();
426
427 /* Common fields: */
428 pInfo->dwMajorVersion = dwVersion & 0xff;
429 pInfo->dwMinorVersion = (dwVersion >> 8) & 0xff;
430 if (!(dwVersion & RT_BIT_32(31)))
431 pInfo->dwBuildNumber = dwVersion >> 16;
432 else
433 pInfo->dwBuildNumber = 511;
434 pInfo->dwPlatformId = VER_PLATFORM_WIN32_NT;
435/** @todo get CSD from registry. */
436 pInfo->szCSDVersion[0] = '\0';
437
438 /* OSVERSIONINFOEX fields: */
439 if (pInfo->dwOSVersionInfoSize > sizeof((*pInfo)))
440 {
441 LPOSVERSIONINFOEXA pInfoEx = (LPOSVERSIONINFOEXA)pInfo;
442 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXA, wServicePackMinor))
443 {
444 pInfoEx->wServicePackMajor = 0;
445 pInfoEx->wServicePackMinor = 0;
446 }
447 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXA, wSuiteMask))
448 pInfoEx->wSuiteMask = 0;
449 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXA, wProductType))
450 pInfoEx->wProductType = VER_NT_WORKSTATION;
451 if (pInfoEx->wReserved > RT_UOFFSETOF(OSVERSIONINFOEXA, wProductType))
452 pInfoEx->wReserved = 0;
453 }
454
455 return TRUE;
456}
457
458
459DECL_KERNEL32(BOOL) Fake_GetVersionExW(LPOSVERSIONINFOW pInfo)
460{
461 DWORD dwVersion = GetVersion();
462
463 /* Common fields: */
464 pInfo->dwMajorVersion = dwVersion & 0xff;
465 pInfo->dwMinorVersion = (dwVersion >> 8) & 0xff;
466 if (!(dwVersion & RT_BIT_32(31)))
467 pInfo->dwBuildNumber = dwVersion >> 16;
468 else
469 pInfo->dwBuildNumber = 511;
470 pInfo->dwPlatformId = VER_PLATFORM_WIN32_NT;
471/** @todo get CSD from registry. */
472 pInfo->szCSDVersion[0] = '\0';
473
474 /* OSVERSIONINFOEX fields: */
475 if (pInfo->dwOSVersionInfoSize > sizeof((*pInfo)))
476 {
477 LPOSVERSIONINFOEXW pInfoEx = (LPOSVERSIONINFOEXW)pInfo;
478 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXW, wServicePackMinor))
479 {
480 pInfoEx->wServicePackMajor = 0;
481 pInfoEx->wServicePackMinor = 0;
482 }
483 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXW, wSuiteMask))
484 pInfoEx->wSuiteMask = 0;
485 if (pInfoEx->dwOSVersionInfoSize > RT_UOFFSETOF(OSVERSIONINFOEXW, wProductType))
486 pInfoEx->wProductType = VER_NT_WORKSTATION;
487 if (pInfoEx->wReserved > RT_UOFFSETOF(OSVERSIONINFOEXW, wProductType))
488 pInfoEx->wReserved = 0;
489 }
490
491 return TRUE;
492}
493
494
495DECL_KERNEL32(LPWCH) Fake_GetEnvironmentStringsW(void)
496{
497 /*
498 * Environment is ANSI in NT 3.1. We should only be here for NT 3.1.
499 * For now, don't try do a perfect job converting it, just do it.
500 */
501 char *pszzEnv = (char *)RTNtCurrentPeb()->ProcessParameters->Environment;
502 size_t offEnv = 0;
503 while (pszzEnv[offEnv] != '\0')
504 {
505 size_t cchLen = strlen(&pszzEnv[offEnv]);
506 offEnv += cchLen + 1;
507 }
508 size_t const cchEnv = offEnv + 1;
509
510 PRTUTF16 pwszzEnv = (PRTUTF16)HeapAlloc(GetProcessHeap(), 0, cchEnv * sizeof(RTUTF16));
511 if (!pwszzEnv)
512 return NULL;
513 for (offEnv = 0; offEnv < cchEnv; offEnv++)
514 {
515 unsigned char ch = pwszzEnv[offEnv];
516 if (!(ch & 0x80))
517 pwszzEnv[offEnv] = ch;
518 else
519 pwszzEnv[offEnv] = '_';
520 }
521 return pwszzEnv;
522}
523
524
525DECL_KERNEL32(BOOL) Fake_FreeEnvironmentStringsW(LPWCH pwszzEnv)
526{
527 if (pwszzEnv)
528 HeapFree(GetProcessHeap(), 0, pwszzEnv);
529 return TRUE;
530}
531
532
533DECL_KERNEL32(int) Fake_GetLocaleInfoA(LCID idLocale, LCTYPE enmType, LPSTR pData, int cchData)
534{
535 NOREF(idLocale); NOREF(enmType); NOREF(pData); NOREF(cchData);
536 //MY_ASSERT(false, "GetLocaleInfoA: idLocale=%#x enmType=%#x cchData=%#x", idLocale, enmType, cchData);
537 MY_ASSERT(false, "GetLocaleInfoA");
538 SetLastError(ERROR_NOT_SUPPORTED);
539 return 0;
540}
541
542
543DECL_KERNEL32(BOOL) Fake_EnumSystemLocalesA(LOCALE_ENUMPROCA pfnCallback, DWORD fFlags)
544{
545 NOREF(pfnCallback); NOREF(fFlags);
546 //MY_ASSERT(false, "EnumSystemLocalesA: pfnCallback=%p fFlags=%#x", pfnCallback, fFlags);
547 MY_ASSERT(false, "EnumSystemLocalesA");
548 SetLastError(ERROR_NOT_SUPPORTED);
549 return FALSE;
550}
551
552
553DECL_KERNEL32(BOOL) Fake_IsValidLocale(LCID idLocale, DWORD fFlags)
554{
555 NOREF(idLocale); NOREF(fFlags);
556 //MY_ASSERT(false, "IsValidLocale: idLocale fFlags=%#x", idLocale, fFlags);
557 MY_ASSERT(false, "IsValidLocale");
558 SetLastError(ERROR_NOT_SUPPORTED);
559 return FALSE;
560}
561
562
563DECL_KERNEL32(DWORD_PTR) Fake_SetThreadAffinityMask(HANDLE hThread, DWORD_PTR fAffinityMask)
564{
565 SYSTEM_INFO SysInfo;
566 GetSystemInfo(&SysInfo);
567 //MY_ASSERT(false, "SetThreadAffinityMask: hThread=%p fAffinityMask=%p SysInfo.dwActiveProcessorMask=%p",
568 // hThread, fAffinityMask, SysInfo.dwActiveProcessorMask);
569 MY_ASSERT(false, "SetThreadAffinityMask");
570 if ( SysInfo.dwActiveProcessorMask == fAffinityMask
571 || fAffinityMask == ~(DWORD_PTR)0)
572 return fAffinityMask;
573
574 SetLastError(ERROR_NOT_SUPPORTED);
575 RT_NOREF(hThread);
576 return 0;
577}
578
579
580DECL_KERNEL32(BOOL) Fake_GetProcessAffinityMask(HANDLE hProcess, PDWORD_PTR pfProcessAffinityMask, PDWORD_PTR pfSystemAffinityMask)
581{
582 SYSTEM_INFO SysInfo;
583 GetSystemInfo(&SysInfo);
584 //MY_ASSERT(false, "GetProcessAffinityMask: SysInfo.dwActiveProcessorMask=%p", SysInfo.dwActiveProcessorMask);
585 MY_ASSERT(false, "GetProcessAffinityMask");
586 if (pfProcessAffinityMask)
587 *pfProcessAffinityMask = SysInfo.dwActiveProcessorMask;
588 if (pfSystemAffinityMask)
589 *pfSystemAffinityMask = SysInfo.dwActiveProcessorMask;
590 RT_NOREF(hProcess);
591 return TRUE;
592}
593
594
595DECL_KERNEL32(BOOL) Fake_GetHandleInformation(HANDLE hObject, DWORD *pfFlags)
596{
597 OBJECT_HANDLE_FLAG_INFORMATION Info = { 0, 0 };
598 DWORD cbRet = sizeof(Info);
599 NTSTATUS rcNt = NtQueryObject(hObject, ObjectHandleFlagInformation, &Info, sizeof(Info), &cbRet);
600 if (NT_SUCCESS(rcNt))
601 {
602 *pfFlags = (Info.Inherit ? HANDLE_FLAG_INHERIT : 0)
603 | (Info.ProtectFromClose ? HANDLE_FLAG_PROTECT_FROM_CLOSE : 0);
604 return TRUE;
605 }
606 *pfFlags = 0;
607 //MY_ASSERT(rcNt == STATUS_INVALID_HANDLE, "rcNt=%#x", rcNt);
608 MY_ASSERT(rcNt == STATUS_INVALID_HANDLE || rcNt == STATUS_INVALID_INFO_CLASS, "GetHandleInformation");
609 SetLastError(rcNt == STATUS_INVALID_HANDLE ? ERROR_INVALID_HANDLE : ERROR_INVALID_FUNCTION); /* see also process-win.cpp */
610 return FALSE;
611}
612
613
614DECL_KERNEL32(BOOL) Fake_SetHandleInformation(HANDLE hObject, DWORD fMask, DWORD fFlags)
615{
616 NOREF(hObject); NOREF(fMask); NOREF(fFlags);
617 SetLastError(ERROR_INVALID_FUNCTION);
618 return FALSE;
619}
620
621
622
623/**
624 * Resolves all the APIs ones and for all, updating the fake IAT entries.
625 */
626DECLASM(void) FakeResolve_kernel32(void)
627{
628 CURRENT_VERSION_VARIABLE();
629
630 HMODULE hmod = GetModuleHandleW(L"kernel32");
631 MY_ASSERT(hmod != NULL, "kernel32");
632
633#undef MAKE_IMPORT_ENTRY
634#define MAKE_IMPORT_ENTRY(a_uMajorVer, a_uMinorVer, a_Name, a_cb) RESOLVE_IMPORT(a_uMajorVer, a_uMinorVer, a_Name, a_cb)
635#include "vcc100-kernel32-fakes.h"
636
637 g_fInitialized = true;
638}
639
640
641/* Dummy to force dragging in this object in the link, so the linker
642 won't accidentally use the symbols from kernel32. */
643extern "C" int vcc100_kernel32_fakes_cpp(void)
644{
645 return 42;
646}
647
Note: See TracBrowser for help on using the repository browser.

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