kernel32: Reimplement GetMaximumProcessorCount on top of GetLogicalProcessorInformati...
[wine.git] / dlls / kernel32 / process.c
blob6de094950e35d59421ce72b4ed688e5592c13040
1 /*
2 * Win32 processes
4 * Copyright 1996, 1998 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <assert.h>
22 #include <ctype.h>
23 #include <errno.h>
24 #include <signal.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <time.h>
29 #include "ntstatus.h"
30 #define WIN32_NO_STATUS
31 #include "winternl.h"
32 #include "winbase.h"
33 #include "winnls.h"
34 #include "wincon.h"
35 #include "kernel_private.h"
36 #include "psapi.h"
37 #include "ddk/wdm.h"
38 #include "wine/exception.h"
39 #include "wine/asm.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(process);
44 static const struct _KUSER_SHARED_DATA *user_shared_data = (struct _KUSER_SHARED_DATA *)0x7ffe0000;
46 typedef struct
48 LPSTR lpEnvAddress;
49 LPSTR lpCmdLine;
50 LPSTR lpCmdShow;
51 DWORD dwReserved;
52 } LOADPARMS32;
54 SYSTEM_BASIC_INFORMATION system_info = { 0 };
56 /* Process flags */
57 #define PDB32_DEBUGGED 0x0001 /* Process is being debugged */
58 #define PDB32_WIN16_PROC 0x0008 /* Win16 process */
59 #define PDB32_DOS_PROC 0x0010 /* Dos process */
60 #define PDB32_CONSOLE_PROC 0x0020 /* Console process */
61 #define PDB32_FILE_APIS_OEM 0x0040 /* File APIs are OEM */
62 #define PDB32_WIN32S_PROC 0x8000 /* Win32s process */
65 /***********************************************************************
66 * wait_input_idle
68 * Wrapper to call WaitForInputIdle USER function
70 typedef DWORD (WINAPI *WaitForInputIdle_ptr)( HANDLE hProcess, DWORD dwTimeOut );
72 static DWORD wait_input_idle( HANDLE process, DWORD timeout )
74 HMODULE mod = GetModuleHandleA( "user32.dll" );
75 if (mod)
77 WaitForInputIdle_ptr ptr = (WaitForInputIdle_ptr)GetProcAddress( mod, "WaitForInputIdle" );
78 if (ptr) return ptr( process, timeout );
80 return 0;
84 /***********************************************************************
85 * WinExec (KERNEL32.@)
87 UINT WINAPI DECLSPEC_HOTPATCH WinExec( LPCSTR lpCmdLine, UINT nCmdShow )
89 PROCESS_INFORMATION info;
90 STARTUPINFOA startup;
91 char *cmdline;
92 UINT ret;
94 memset( &startup, 0, sizeof(startup) );
95 startup.cb = sizeof(startup);
96 startup.dwFlags = STARTF_USESHOWWINDOW;
97 startup.wShowWindow = nCmdShow;
99 /* cmdline needs to be writable for CreateProcess */
100 if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(lpCmdLine)+1 ))) return 0;
101 strcpy( cmdline, lpCmdLine );
103 if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE,
104 0, NULL, NULL, &startup, &info ))
106 /* Give 30 seconds to the app to come up */
107 if (wait_input_idle( info.hProcess, 30000 ) == WAIT_FAILED)
108 WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
109 ret = 33;
110 /* Close off the handles */
111 CloseHandle( info.hThread );
112 CloseHandle( info.hProcess );
114 else if ((ret = GetLastError()) >= 32)
116 FIXME("Strange error set by CreateProcess: %d\n", ret );
117 ret = 11;
119 HeapFree( GetProcessHeap(), 0, cmdline );
120 return ret;
124 /**********************************************************************
125 * LoadModule (KERNEL32.@)
127 DWORD WINAPI LoadModule( LPCSTR name, LPVOID paramBlock )
129 LOADPARMS32 *params = paramBlock;
130 PROCESS_INFORMATION info;
131 STARTUPINFOA startup;
132 DWORD ret;
133 LPSTR cmdline, p;
134 char filename[MAX_PATH];
135 BYTE len;
137 if (!name) return ERROR_FILE_NOT_FOUND;
139 if (!SearchPathA( NULL, name, ".exe", sizeof(filename), filename, NULL ) &&
140 !SearchPathA( NULL, name, NULL, sizeof(filename), filename, NULL ))
141 return GetLastError();
143 len = (BYTE)params->lpCmdLine[0];
144 if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(filename) + len + 2 )))
145 return ERROR_NOT_ENOUGH_MEMORY;
147 strcpy( cmdline, filename );
148 p = cmdline + strlen(cmdline);
149 *p++ = ' ';
150 memcpy( p, params->lpCmdLine + 1, len );
151 p[len] = 0;
153 memset( &startup, 0, sizeof(startup) );
154 startup.cb = sizeof(startup);
155 if (params->lpCmdShow)
157 startup.dwFlags = STARTF_USESHOWWINDOW;
158 startup.wShowWindow = ((WORD *)params->lpCmdShow)[1];
161 if (CreateProcessA( filename, cmdline, NULL, NULL, FALSE, 0,
162 params->lpEnvAddress, NULL, &startup, &info ))
164 /* Give 30 seconds to the app to come up */
165 if (wait_input_idle( info.hProcess, 30000 ) == WAIT_FAILED)
166 WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
167 ret = 33;
168 /* Close off the handles */
169 CloseHandle( info.hThread );
170 CloseHandle( info.hProcess );
172 else if ((ret = GetLastError()) >= 32)
174 FIXME("Strange error set by CreateProcess: %u\n", ret );
175 ret = 11;
178 HeapFree( GetProcessHeap(), 0, cmdline );
179 return ret;
183 /***********************************************************************
184 * ExitProcess (KERNEL32.@)
186 * Exits the current process.
188 * PARAMS
189 * status [I] Status code to exit with.
191 * RETURNS
192 * Nothing.
194 #ifdef __i386__
195 __ASM_STDCALL_FUNC( ExitProcess, 4, /* Shrinker depend on this particular ExitProcess implementation */
196 "pushl %ebp\n\t"
197 ".byte 0x8B, 0xEC\n\t" /* movl %esp, %ebp */
198 ".byte 0x6A, 0x00\n\t" /* pushl $0 */
199 ".byte 0x68, 0x00, 0x00, 0x00, 0x00\n\t" /* pushl $0 - 4 bytes immediate */
200 "pushl 8(%ebp)\n\t"
201 "call " __ASM_STDCALL("RtlExitUserProcess",4) "\n\t"
202 "leave\n\t"
203 "ret $4" )
204 #else
206 void WINAPI ExitProcess( DWORD status )
208 RtlExitUserProcess( status );
211 #endif
213 /***********************************************************************
214 * GetExitCodeProcess [KERNEL32.@]
216 * Gets termination status of specified process.
218 * PARAMS
219 * hProcess [in] Handle to the process.
220 * lpExitCode [out] Address to receive termination status.
222 * RETURNS
223 * Success: TRUE
224 * Failure: FALSE
226 BOOL WINAPI GetExitCodeProcess( HANDLE hProcess, LPDWORD lpExitCode )
228 PROCESS_BASIC_INFORMATION pbi;
230 if (!set_ntstatus( NtQueryInformationProcess( hProcess, ProcessBasicInformation, &pbi, sizeof(pbi), NULL )))
231 return FALSE;
232 if (lpExitCode) *lpExitCode = pbi.ExitStatus;
233 return TRUE;
237 /**************************************************************************
238 * FatalExit (KERNEL32.@)
240 void WINAPI FatalExit( int code )
242 WARN( "FatalExit\n" );
243 ExitProcess( code );
247 /***********************************************************************
248 * GetProcessFlags (KERNEL32.@)
250 DWORD WINAPI GetProcessFlags( DWORD processid )
252 IMAGE_NT_HEADERS *nt;
253 DWORD flags = 0;
255 if (processid && processid != GetCurrentProcessId()) return 0;
257 if ((nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress )))
259 if (nt->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
260 flags |= PDB32_CONSOLE_PROC;
262 if (!AreFileApisANSI()) flags |= PDB32_FILE_APIS_OEM;
263 if (IsDebuggerPresent()) flags |= PDB32_DEBUGGED;
264 return flags;
268 /***********************************************************************
269 * ConvertToGlobalHandle (KERNEL32.@)
271 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
273 HANDLE ret = INVALID_HANDLE_VALUE;
274 DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
275 DUPLICATE_MAKE_GLOBAL | DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE );
276 return ret;
280 /***********************************************************************
281 * SetHandleContext (KERNEL32.@)
283 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context)
285 FIXME("(%p,%d), stub. In case this got called by WSOCK32/WS2_32: "
286 "the external WINSOCK DLLs won't work with WINE, don't use them.\n",hnd,context);
287 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
288 return FALSE;
292 /***********************************************************************
293 * GetHandleContext (KERNEL32.@)
295 DWORD WINAPI GetHandleContext(HANDLE hnd)
297 FIXME("(%p), stub. In case this got called by WSOCK32/WS2_32: "
298 "the external WINSOCK DLLs won't work with WINE, don't use them.\n",hnd);
299 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
300 return 0;
304 /***********************************************************************
305 * CreateSocketHandle (KERNEL32.@)
307 HANDLE WINAPI CreateSocketHandle(void)
309 FIXME("(), stub. In case this got called by WSOCK32/WS2_32: "
310 "the external WINSOCK DLLs won't work with WINE, don't use them.\n");
311 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
312 return INVALID_HANDLE_VALUE;
316 /***********************************************************************
317 * SetProcessAffinityMask (KERNEL32.@)
319 BOOL WINAPI SetProcessAffinityMask( HANDLE hProcess, DWORD_PTR affmask )
321 return set_ntstatus( NtSetInformationProcess( hProcess, ProcessAffinityMask,
322 &affmask, sizeof(DWORD_PTR) ));
326 /**********************************************************************
327 * GetProcessAffinityMask (KERNEL32.@)
329 BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess, PDWORD_PTR process_mask, PDWORD_PTR system_mask )
331 if (process_mask)
333 if (!set_ntstatus( NtQueryInformationProcess( hProcess, ProcessAffinityMask,
334 process_mask, sizeof(*process_mask), NULL )))
335 return FALSE;
337 if (system_mask)
339 SYSTEM_BASIC_INFORMATION info;
341 if (!set_ntstatus( NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )))
342 return FALSE;
343 *system_mask = info.ActiveProcessorsAffinityMask;
345 return TRUE;
349 /***********************************************************************
350 * SetProcessWorkingSetSize [KERNEL32.@]
351 * Sets the min/max working set sizes for a specified process.
353 * PARAMS
354 * process [I] Handle to the process of interest
355 * minset [I] Specifies minimum working set size
356 * maxset [I] Specifies maximum working set size
358 * RETURNS
359 * Success: TRUE
360 * Failure: FALSE
362 BOOL WINAPI SetProcessWorkingSetSize(HANDLE process, SIZE_T minset, SIZE_T maxset)
364 return SetProcessWorkingSetSizeEx(process, minset, maxset, 0);
367 /***********************************************************************
368 * GetProcessWorkingSetSize (KERNEL32.@)
370 BOOL WINAPI GetProcessWorkingSetSize(HANDLE process, SIZE_T *minset, SIZE_T *maxset)
372 return GetProcessWorkingSetSizeEx(process, minset, maxset, NULL);
376 /******************************************************************
377 * GetProcessIoCounters (KERNEL32.@)
379 BOOL WINAPI GetProcessIoCounters(HANDLE hProcess, PIO_COUNTERS ioc)
381 return set_ntstatus( NtQueryInformationProcess(hProcess, ProcessIoCounters, ioc, sizeof(*ioc), NULL ));
384 /***********************************************************************
385 * RegisterServiceProcess (KERNEL32.@)
387 * A service process calls this function to ensure that it continues to run
388 * even after a user logged off.
390 DWORD WINAPI RegisterServiceProcess(DWORD dwProcessId, DWORD dwType)
392 /* I don't think that Wine needs to do anything in this function */
393 return 1; /* success */
397 /***********************************************************************
398 * GetCurrentProcess (KERNEL32.@)
400 * Get a handle to the current process.
402 * PARAMS
403 * None.
405 * RETURNS
406 * A handle representing the current process.
408 HANDLE WINAPI KERNEL32_GetCurrentProcess(void)
410 return (HANDLE)~(ULONG_PTR)0;
414 /***********************************************************************
415 * CreateActCtxA (KERNEL32.@)
417 HANDLE WINAPI DECLSPEC_HOTPATCH CreateActCtxA( const ACTCTXA *actctx )
419 ACTCTXW actw;
420 SIZE_T len;
421 HANDLE ret = INVALID_HANDLE_VALUE;
422 LPWSTR src = NULL, assdir = NULL, resname = NULL, appname = NULL;
424 TRACE("%p %08x\n", actctx, actctx ? actctx->dwFlags : 0);
426 if (!actctx || actctx->cbSize != sizeof(*actctx))
428 SetLastError(ERROR_INVALID_PARAMETER);
429 return INVALID_HANDLE_VALUE;
432 actw.cbSize = sizeof(actw);
433 actw.dwFlags = actctx->dwFlags;
434 if (actctx->lpSource)
436 len = MultiByteToWideChar(CP_ACP, 0, actctx->lpSource, -1, NULL, 0);
437 src = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
438 if (!src) return INVALID_HANDLE_VALUE;
439 MultiByteToWideChar(CP_ACP, 0, actctx->lpSource, -1, src, len);
441 actw.lpSource = src;
443 if (actw.dwFlags & ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID)
444 actw.wProcessorArchitecture = actctx->wProcessorArchitecture;
445 if (actw.dwFlags & ACTCTX_FLAG_LANGID_VALID)
446 actw.wLangId = actctx->wLangId;
447 if (actw.dwFlags & ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID)
449 len = MultiByteToWideChar(CP_ACP, 0, actctx->lpAssemblyDirectory, -1, NULL, 0);
450 assdir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
451 if (!assdir) goto done;
452 MultiByteToWideChar(CP_ACP, 0, actctx->lpAssemblyDirectory, -1, assdir, len);
453 actw.lpAssemblyDirectory = assdir;
455 if (actw.dwFlags & ACTCTX_FLAG_RESOURCE_NAME_VALID)
457 if ((ULONG_PTR)actctx->lpResourceName >> 16)
459 len = MultiByteToWideChar(CP_ACP, 0, actctx->lpResourceName, -1, NULL, 0);
460 resname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
461 if (!resname) goto done;
462 MultiByteToWideChar(CP_ACP, 0, actctx->lpResourceName, -1, resname, len);
463 actw.lpResourceName = resname;
465 else actw.lpResourceName = (LPCWSTR)actctx->lpResourceName;
467 if (actw.dwFlags & ACTCTX_FLAG_APPLICATION_NAME_VALID)
469 len = MultiByteToWideChar(CP_ACP, 0, actctx->lpApplicationName, -1, NULL, 0);
470 appname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
471 if (!appname) goto done;
472 MultiByteToWideChar(CP_ACP, 0, actctx->lpApplicationName, -1, appname, len);
473 actw.lpApplicationName = appname;
475 if (actw.dwFlags & ACTCTX_FLAG_HMODULE_VALID)
476 actw.hModule = actctx->hModule;
478 ret = CreateActCtxW(&actw);
480 done:
481 HeapFree(GetProcessHeap(), 0, src);
482 HeapFree(GetProcessHeap(), 0, assdir);
483 HeapFree(GetProcessHeap(), 0, resname);
484 HeapFree(GetProcessHeap(), 0, appname);
485 return ret;
488 /***********************************************************************
489 * FindActCtxSectionStringA (KERNEL32.@)
491 BOOL WINAPI FindActCtxSectionStringA( DWORD flags, const GUID *guid, ULONG id, const char *search,
492 ACTCTX_SECTION_KEYED_DATA *info )
494 LPWSTR searchW;
495 DWORD len;
496 BOOL ret;
498 TRACE("%08x %s %u %s %p\n", flags, debugstr_guid(guid), id, debugstr_a(search), info);
500 if (!search || !info)
502 SetLastError(ERROR_INVALID_PARAMETER);
503 return FALSE;
505 len = MultiByteToWideChar(CP_ACP, 0, search, -1, NULL, 0);
506 searchW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
507 MultiByteToWideChar(CP_ACP, 0, search, -1, searchW, len);
508 ret = FindActCtxSectionStringW( flags, guid, id, searchW, info );
509 HeapFree(GetProcessHeap(), 0, searchW);
510 return ret;
514 /***********************************************************************
515 * CmdBatNotification (KERNEL32.@)
517 * Notifies the system that a batch file has started or finished.
519 * PARAMS
520 * bBatchRunning [I] TRUE if a batch file has started or
521 * FALSE if a batch file has finished executing.
523 * RETURNS
524 * Unknown.
526 BOOL WINAPI CmdBatNotification( BOOL bBatchRunning )
528 FIXME("%d\n", bBatchRunning);
529 return FALSE;
532 /***********************************************************************
533 * RegisterApplicationRestart (KERNEL32.@)
535 HRESULT WINAPI RegisterApplicationRestart(PCWSTR pwzCommandLine, DWORD dwFlags)
537 FIXME("(%s,%d)\n", debugstr_w(pwzCommandLine), dwFlags);
539 return S_OK;
542 /**********************************************************************
543 * WTSGetActiveConsoleSessionId (KERNEL32.@)
545 DWORD WINAPI WTSGetActiveConsoleSessionId(void)
547 static int once;
548 if (!once++) FIXME("stub\n");
549 /* Return current session id. */
550 return NtCurrentTeb()->Peb->SessionId;
553 /**********************************************************************
554 * GetSystemDEPPolicy (KERNEL32.@)
556 DEP_SYSTEM_POLICY_TYPE WINAPI GetSystemDEPPolicy(void)
558 return user_shared_data->NXSupportPolicy;
561 /**********************************************************************
562 * SetProcessDEPPolicy (KERNEL32.@)
564 BOOL WINAPI SetProcessDEPPolicy( DWORD flags )
566 ULONG dep_flags = 0;
568 TRACE("%#x\n", flags);
570 if (flags & PROCESS_DEP_ENABLE)
571 dep_flags |= MEM_EXECUTE_OPTION_DISABLE | MEM_EXECUTE_OPTION_PERMANENT;
572 if (flags & PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION)
573 dep_flags |= MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION;
575 return set_ntstatus( NtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags,
576 &dep_flags, sizeof(dep_flags) ) );
579 /**********************************************************************
580 * ApplicationRecoveryFinished (KERNEL32.@)
582 VOID WINAPI ApplicationRecoveryFinished(BOOL success)
584 FIXME(": stub\n");
585 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
588 /**********************************************************************
589 * ApplicationRecoveryInProgress (KERNEL32.@)
591 HRESULT WINAPI ApplicationRecoveryInProgress(PBOOL canceled)
593 FIXME(":%p stub\n", canceled);
594 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
595 return E_FAIL;
598 /**********************************************************************
599 * RegisterApplicationRecoveryCallback (KERNEL32.@)
601 HRESULT WINAPI RegisterApplicationRecoveryCallback(APPLICATION_RECOVERY_CALLBACK callback, PVOID param, DWORD pingint, DWORD flags)
603 FIXME("%p, %p, %d, %d: stub, faking success\n", callback, param, pingint, flags);
604 return S_OK;
607 /***********************************************************************
608 * GetActiveProcessorGroupCount (KERNEL32.@)
610 WORD WINAPI GetActiveProcessorGroupCount(void)
612 WORD groups;
613 DWORD size = 0;
614 SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info;
616 TRACE("()\n");
618 if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0;
619 if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0;
620 if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size))
622 HeapFree(GetProcessHeap(), 0, info);
623 return 0;
626 groups = info->Group.ActiveGroupCount;
628 HeapFree(GetProcessHeap(), 0, info);
629 return groups;
632 /***********************************************************************
633 * GetActiveProcessorCount (KERNEL32.@)
635 DWORD WINAPI GetActiveProcessorCount(WORD group)
637 DWORD cpus = 0;
638 DWORD size = 0;
639 SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info;
641 TRACE("(0x%x)\n", group);
643 if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0;
644 if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0;
645 if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size))
647 HeapFree(GetProcessHeap(), 0, info);
648 return 0;
651 if (group == ALL_PROCESSOR_GROUPS)
653 for (group = 0; group < info->Group.ActiveGroupCount; group++)
654 cpus += info->Group.GroupInfo[group].ActiveProcessorCount;
656 else
658 if (group < info->Group.ActiveGroupCount)
659 cpus = info->Group.GroupInfo[group].ActiveProcessorCount;
662 HeapFree(GetProcessHeap(), 0, info);
663 return cpus;
666 /***********************************************************************
667 * GetMaximumProcessorCount (KERNEL32.@)
669 DWORD WINAPI GetMaximumProcessorCount(WORD group)
671 DWORD cpus = 0;
672 DWORD size = 0;
673 SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info;
675 TRACE("(0x%x)\n", group);
677 if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0;
678 if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0;
679 if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size))
681 HeapFree(GetProcessHeap(), 0, info);
682 return 0;
685 if (group == ALL_PROCESSOR_GROUPS)
687 for (group = 0; group < info->Group.ActiveGroupCount; group++)
688 cpus += info->Group.GroupInfo[group].MaximumProcessorCount;
690 else
692 if (group < info->Group.ActiveGroupCount)
693 cpus = info->Group.GroupInfo[group].MaximumProcessorCount;
696 HeapFree(GetProcessHeap(), 0, info);
697 return cpus;
700 /***********************************************************************
701 * GetMaximumProcessorGroupCount (KERNEL32.@)
703 WORD WINAPI GetMaximumProcessorGroupCount(void)
705 FIXME("semi-stub, always returning 1\n");
706 return 1;
709 /***********************************************************************
710 * GetFirmwareEnvironmentVariableA (KERNEL32.@)
712 DWORD WINAPI GetFirmwareEnvironmentVariableA(LPCSTR name, LPCSTR guid, PVOID buffer, DWORD size)
714 FIXME("stub: %s %s %p %u\n", debugstr_a(name), debugstr_a(guid), buffer, size);
715 SetLastError(ERROR_INVALID_FUNCTION);
716 return 0;
719 /***********************************************************************
720 * GetFirmwareEnvironmentVariableW (KERNEL32.@)
722 DWORD WINAPI GetFirmwareEnvironmentVariableW(LPCWSTR name, LPCWSTR guid, PVOID buffer, DWORD size)
724 FIXME("stub: %s %s %p %u\n", debugstr_w(name), debugstr_w(guid), buffer, size);
725 SetLastError(ERROR_INVALID_FUNCTION);
726 return 0;
729 /***********************************************************************
730 * SetFirmwareEnvironmentVariableW (KERNEL32.@)
732 BOOL WINAPI SetFirmwareEnvironmentVariableW(const WCHAR *name, const WCHAR *guid, void *buffer, DWORD size)
734 FIXME("stub: %s %s %p %u\n", debugstr_w(name), debugstr_w(guid), buffer, size);
735 SetLastError(ERROR_INVALID_FUNCTION);
736 return FALSE;
739 /**********************************************************************
740 * GetNumaNodeProcessorMask (KERNEL32.@)
742 BOOL WINAPI GetNumaNodeProcessorMask(UCHAR node, PULONGLONG mask)
744 FIXME("(%c %p): stub\n", node, mask);
745 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
746 return FALSE;
749 /**********************************************************************
750 * GetNumaAvailableMemoryNode (KERNEL32.@)
752 BOOL WINAPI GetNumaAvailableMemoryNode(UCHAR node, PULONGLONG available_bytes)
754 FIXME("(%c %p): stub\n", node, available_bytes);
755 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
756 return FALSE;
759 /**********************************************************************
760 * GetNumaAvailableMemoryNodeEx (KERNEL32.@)
762 BOOL WINAPI GetNumaAvailableMemoryNodeEx(USHORT node, PULONGLONG available_bytes)
764 FIXME("(%hu %p): stub\n", node, available_bytes);
765 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
766 return FALSE;
769 /***********************************************************************
770 * GetNumaProcessorNode (KERNEL32.@)
772 BOOL WINAPI GetNumaProcessorNode(UCHAR processor, PUCHAR node)
774 TRACE("(%d, %p)\n", processor, node);
776 if (processor < system_info.NumberOfProcessors)
778 *node = 0;
779 return TRUE;
782 *node = 0xFF;
783 SetLastError(ERROR_INVALID_PARAMETER);
784 return FALSE;
787 /***********************************************************************
788 * GetNumaProcessorNodeEx (KERNEL32.@)
790 BOOL WINAPI GetNumaProcessorNodeEx(PPROCESSOR_NUMBER processor, PUSHORT node_number)
792 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
793 return FALSE;
796 /***********************************************************************
797 * GetNumaProximityNode (KERNEL32.@)
799 BOOL WINAPI GetNumaProximityNode(ULONG proximity_id, PUCHAR node_number)
801 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
802 return FALSE;
805 /**********************************************************************
806 * GetProcessDEPPolicy (KERNEL32.@)
808 BOOL WINAPI GetProcessDEPPolicy(HANDLE process, LPDWORD flags, PBOOL permanent)
810 ULONG dep_flags;
812 TRACE("(%p %p %p)\n", process, flags, permanent);
814 if (!set_ntstatus( NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags,
815 &dep_flags, sizeof(dep_flags), NULL )))
816 return FALSE;
818 if (flags)
820 *flags = 0;
821 if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
822 *flags |= PROCESS_DEP_ENABLE;
823 if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)
824 *flags |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION;
827 if (permanent) *permanent = (dep_flags & MEM_EXECUTE_OPTION_PERMANENT) != 0;
828 return TRUE;
831 /***********************************************************************
832 * UnregisterApplicationRestart (KERNEL32.@)
834 HRESULT WINAPI UnregisterApplicationRestart(void)
836 FIXME(": stub\n");
837 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
838 return S_OK;
841 /***********************************************************************
842 * CreateUmsCompletionList (KERNEL32.@)
844 BOOL WINAPI CreateUmsCompletionList(PUMS_COMPLETION_LIST *list)
846 FIXME( "%p: stub\n", list );
847 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
848 return FALSE;
851 /***********************************************************************
852 * CreateUmsThreadContext (KERNEL32.@)
854 BOOL WINAPI CreateUmsThreadContext(PUMS_CONTEXT *ctx)
856 FIXME( "%p: stub\n", ctx );
857 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
858 return FALSE;
861 /***********************************************************************
862 * DeleteUmsCompletionList (KERNEL32.@)
864 BOOL WINAPI DeleteUmsCompletionList(PUMS_COMPLETION_LIST list)
866 FIXME( "%p: stub\n", list );
867 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
868 return FALSE;
871 /***********************************************************************
872 * DeleteUmsThreadContext (KERNEL32.@)
874 BOOL WINAPI DeleteUmsThreadContext(PUMS_CONTEXT ctx)
876 FIXME( "%p: stub\n", ctx );
877 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
878 return FALSE;
881 /***********************************************************************
882 * DequeueUmsCompletionListItems (KERNEL32.@)
884 BOOL WINAPI DequeueUmsCompletionListItems(void *list, DWORD timeout, PUMS_CONTEXT *ctx)
886 FIXME( "%p,%08x,%p: stub\n", list, timeout, ctx );
887 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
888 return FALSE;
891 /***********************************************************************
892 * EnterUmsSchedulingMode (KERNEL32.@)
894 BOOL WINAPI EnterUmsSchedulingMode(UMS_SCHEDULER_STARTUP_INFO *info)
896 FIXME( "%p: stub\n", info );
897 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
898 return FALSE;
901 /***********************************************************************
902 * ExecuteUmsThread (KERNEL32.@)
904 BOOL WINAPI ExecuteUmsThread(PUMS_CONTEXT ctx)
906 FIXME( "%p: stub\n", ctx );
907 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
908 return FALSE;
911 /***********************************************************************
912 * GetCurrentUmsThread (KERNEL32.@)
914 PUMS_CONTEXT WINAPI GetCurrentUmsThread(void)
916 FIXME( "stub\n" );
917 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
918 return FALSE;
921 /***********************************************************************
922 * GetNextUmsListItem (KERNEL32.@)
924 PUMS_CONTEXT WINAPI GetNextUmsListItem(PUMS_CONTEXT ctx)
926 FIXME( "%p: stub\n", ctx );
927 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
928 return NULL;
931 /***********************************************************************
932 * GetUmsCompletionListEvent (KERNEL32.@)
934 BOOL WINAPI GetUmsCompletionListEvent(PUMS_COMPLETION_LIST list, HANDLE *event)
936 FIXME( "%p,%p: stub\n", list, event );
937 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
938 return FALSE;
941 /***********************************************************************
942 * QueryUmsThreadInformation (KERNEL32.@)
944 BOOL WINAPI QueryUmsThreadInformation(PUMS_CONTEXT ctx, UMS_THREAD_INFO_CLASS class,
945 void *buf, ULONG length, ULONG *ret_length)
947 FIXME( "%p,%08x,%p,%08x,%p: stub\n", ctx, class, buf, length, ret_length );
948 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
949 return FALSE;
952 /***********************************************************************
953 * SetUmsThreadInformation (KERNEL32.@)
955 BOOL WINAPI SetUmsThreadInformation(PUMS_CONTEXT ctx, UMS_THREAD_INFO_CLASS class,
956 void *buf, ULONG length)
958 FIXME( "%p,%08x,%p,%08x: stub\n", ctx, class, buf, length );
959 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
960 return FALSE;
963 /***********************************************************************
964 * UmsThreadYield (KERNEL32.@)
966 BOOL WINAPI UmsThreadYield(void *param)
968 FIXME( "%p: stub\n", param );
969 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
970 return FALSE;