amstream: Implement AMAudioStream::NewSegment.
[wine/zf.git] / dlls / kernel32 / process.c
blob8f506fcf13205f728728c725f4f312217cc9c39e
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 "config.h"
22 #include "wine/port.h"
24 #include <assert.h>
25 #include <ctype.h>
26 #include <errno.h>
27 #include <signal.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <time.h>
31 #ifdef HAVE_SYS_TIME_H
32 # include <sys/time.h>
33 #endif
34 #ifdef HAVE_SYS_IOCTL_H
35 #include <sys/ioctl.h>
36 #endif
37 #ifdef HAVE_SYS_SOCKET_H
38 #include <sys/socket.h>
39 #endif
40 #include <sys/types.h>
41 #ifdef HAVE_SYS_WAIT_H
42 # include <sys/wait.h>
43 #endif
44 #ifdef HAVE_UNISTD_H
45 # include <unistd.h>
46 #endif
48 #include "ntstatus.h"
49 #define WIN32_NO_STATUS
50 #include "winternl.h"
51 #include "winbase.h"
52 #include "wincon.h"
53 #include "kernel_private.h"
54 #include "psapi.h"
55 #include "wine/exception.h"
56 #include "wine/server.h"
57 #include "wine/unicode.h"
58 #include "wine/asm.h"
59 #include "wine/debug.h"
61 WINE_DEFAULT_DEBUG_CHANNEL(process);
62 WINE_DECLARE_DEBUG_CHANNEL(relay);
64 typedef struct
66 LPSTR lpEnvAddress;
67 LPSTR lpCmdLine;
68 LPSTR lpCmdShow;
69 DWORD dwReserved;
70 } LOADPARMS32;
72 HMODULE kernel32_handle = 0;
73 SYSTEM_BASIC_INFORMATION system_info = { 0 };
75 const WCHAR DIR_Windows[] = {'C',':','\\','w','i','n','d','o','w','s',0};
76 const WCHAR DIR_System[] = {'C',':','\\','w','i','n','d','o','w','s',
77 '\\','s','y','s','t','e','m','3','2',0};
79 /* Process flags */
80 #define PDB32_DEBUGGED 0x0001 /* Process is being debugged */
81 #define PDB32_WIN16_PROC 0x0008 /* Win16 process */
82 #define PDB32_DOS_PROC 0x0010 /* Dos process */
83 #define PDB32_CONSOLE_PROC 0x0020 /* Console process */
84 #define PDB32_FILE_APIS_OEM 0x0040 /* File APIs are OEM */
85 #define PDB32_WIN32S_PROC 0x8000 /* Win32s process */
88 #ifdef __i386__
89 extern DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry );
90 __ASM_GLOBAL_FUNC( call_process_entry,
91 "pushl %ebp\n\t"
92 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
93 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
94 "movl %esp,%ebp\n\t"
95 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
96 "pushl %ebx\n\t"
97 __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
98 "movl 8(%ebp),%ebx\n\t"
99 /* deliberately mis-align the stack by 8, Doom 3 needs this */
100 "pushl 4(%ebp)\n\t" /* Driller expects readable address at this offset */
101 "pushl 4(%ebp)\n\t"
102 "pushl %ebx\n\t"
103 "call *12(%ebp)\n\t"
104 "leal -4(%ebp),%esp\n\t"
105 "popl %ebx\n\t"
106 __ASM_CFI(".cfi_same_value %ebx\n\t")
107 "popl %ebp\n\t"
108 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
109 __ASM_CFI(".cfi_same_value %ebp\n\t")
110 "ret" )
112 __ASM_GLOBAL_FUNC( __wine_start_process,
113 "pushl %ebp\n\t"
114 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
115 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
116 "movl %esp,%ebp\n\t"
117 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
118 "pushl %ebx\n\t" /* arg */
119 "pushl %eax\n\t" /* entry */
120 "call " __ASM_NAME("start_process") )
121 #else
122 static inline DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry )
124 return entry( peb );
126 #endif
128 /***********************************************************************
129 * __wine_start_process
131 * Startup routine of a new process. Runs on the new process stack.
133 #ifdef __i386__
134 void CDECL start_process( LPTHREAD_START_ROUTINE entry, PEB *peb )
135 #else
136 void CDECL __wine_start_process( LPTHREAD_START_ROUTINE entry, PEB *peb )
137 #endif
139 BOOL being_debugged;
141 if (!entry)
143 ERR( "%s doesn't have an entry point, it cannot be executed\n",
144 debugstr_w(peb->ProcessParameters->ImagePathName.Buffer) );
145 ExitThread( 1 );
148 TRACE_(relay)( "\1Starting process %s (entryproc=%p)\n",
149 debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), entry );
151 __TRY
153 if (!CheckRemoteDebuggerPresent( GetCurrentProcess(), &being_debugged ))
154 being_debugged = FALSE;
156 SetLastError( 0 ); /* clear error code */
157 if (being_debugged) DbgBreakPoint();
158 ExitThread( call_process_entry( peb, entry ));
160 __EXCEPT(UnhandledExceptionFilter)
162 TerminateProcess( GetCurrentProcess(), GetExceptionCode() );
164 __ENDTRY
165 abort(); /* should not be reached */
169 /***********************************************************************
170 * wait_input_idle
172 * Wrapper to call WaitForInputIdle USER function
174 typedef DWORD (WINAPI *WaitForInputIdle_ptr)( HANDLE hProcess, DWORD dwTimeOut );
176 static DWORD wait_input_idle( HANDLE process, DWORD timeout )
178 HMODULE mod = GetModuleHandleA( "user32.dll" );
179 if (mod)
181 WaitForInputIdle_ptr ptr = (WaitForInputIdle_ptr)GetProcAddress( mod, "WaitForInputIdle" );
182 if (ptr) return ptr( process, timeout );
184 return 0;
188 /***********************************************************************
189 * WinExec (KERNEL32.@)
191 UINT WINAPI DECLSPEC_HOTPATCH WinExec( LPCSTR lpCmdLine, UINT nCmdShow )
193 PROCESS_INFORMATION info;
194 STARTUPINFOA startup;
195 char *cmdline;
196 UINT ret;
198 memset( &startup, 0, sizeof(startup) );
199 startup.cb = sizeof(startup);
200 startup.dwFlags = STARTF_USESHOWWINDOW;
201 startup.wShowWindow = nCmdShow;
203 /* cmdline needs to be writable for CreateProcess */
204 if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(lpCmdLine)+1 ))) return 0;
205 strcpy( cmdline, lpCmdLine );
207 if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE,
208 0, NULL, NULL, &startup, &info ))
210 /* Give 30 seconds to the app to come up */
211 if (wait_input_idle( info.hProcess, 30000 ) == WAIT_FAILED)
212 WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
213 ret = 33;
214 /* Close off the handles */
215 CloseHandle( info.hThread );
216 CloseHandle( info.hProcess );
218 else if ((ret = GetLastError()) >= 32)
220 FIXME("Strange error set by CreateProcess: %d\n", ret );
221 ret = 11;
223 HeapFree( GetProcessHeap(), 0, cmdline );
224 return ret;
228 /**********************************************************************
229 * LoadModule (KERNEL32.@)
231 DWORD WINAPI LoadModule( LPCSTR name, LPVOID paramBlock )
233 LOADPARMS32 *params = paramBlock;
234 PROCESS_INFORMATION info;
235 STARTUPINFOA startup;
236 DWORD ret;
237 LPSTR cmdline, p;
238 char filename[MAX_PATH];
239 BYTE len;
241 if (!name) return ERROR_FILE_NOT_FOUND;
243 if (!SearchPathA( NULL, name, ".exe", sizeof(filename), filename, NULL ) &&
244 !SearchPathA( NULL, name, NULL, sizeof(filename), filename, NULL ))
245 return GetLastError();
247 len = (BYTE)params->lpCmdLine[0];
248 if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen(filename) + len + 2 )))
249 return ERROR_NOT_ENOUGH_MEMORY;
251 strcpy( cmdline, filename );
252 p = cmdline + strlen(cmdline);
253 *p++ = ' ';
254 memcpy( p, params->lpCmdLine + 1, len );
255 p[len] = 0;
257 memset( &startup, 0, sizeof(startup) );
258 startup.cb = sizeof(startup);
259 if (params->lpCmdShow)
261 startup.dwFlags = STARTF_USESHOWWINDOW;
262 startup.wShowWindow = ((WORD *)params->lpCmdShow)[1];
265 if (CreateProcessA( filename, cmdline, NULL, NULL, FALSE, 0,
266 params->lpEnvAddress, NULL, &startup, &info ))
268 /* Give 30 seconds to the app to come up */
269 if (wait_input_idle( info.hProcess, 30000 ) == WAIT_FAILED)
270 WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
271 ret = 33;
272 /* Close off the handles */
273 CloseHandle( info.hThread );
274 CloseHandle( info.hProcess );
276 else if ((ret = GetLastError()) >= 32)
278 FIXME("Strange error set by CreateProcess: %u\n", ret );
279 ret = 11;
282 HeapFree( GetProcessHeap(), 0, cmdline );
283 return ret;
287 /***********************************************************************
288 * ExitProcess (KERNEL32.@)
290 * Exits the current process.
292 * PARAMS
293 * status [I] Status code to exit with.
295 * RETURNS
296 * Nothing.
298 #ifdef __i386__
299 __ASM_STDCALL_FUNC( ExitProcess, 4, /* Shrinker depend on this particular ExitProcess implementation */
300 "pushl %ebp\n\t"
301 ".byte 0x8B, 0xEC\n\t" /* movl %esp, %ebp */
302 ".byte 0x6A, 0x00\n\t" /* pushl $0 */
303 ".byte 0x68, 0x00, 0x00, 0x00, 0x00\n\t" /* pushl $0 - 4 bytes immediate */
304 "pushl 8(%ebp)\n\t"
305 "call " __ASM_STDCALL("RtlExitUserProcess",4) "\n\t"
306 "leave\n\t"
307 "ret $4" )
308 #else
310 void WINAPI ExitProcess( DWORD status )
312 RtlExitUserProcess( status );
315 #endif
317 /***********************************************************************
318 * GetExitCodeProcess [KERNEL32.@]
320 * Gets termination status of specified process.
322 * PARAMS
323 * hProcess [in] Handle to the process.
324 * lpExitCode [out] Address to receive termination status.
326 * RETURNS
327 * Success: TRUE
328 * Failure: FALSE
330 BOOL WINAPI GetExitCodeProcess( HANDLE hProcess, LPDWORD lpExitCode )
332 PROCESS_BASIC_INFORMATION pbi;
334 if (!set_ntstatus( NtQueryInformationProcess( hProcess, ProcessBasicInformation, &pbi, sizeof(pbi), NULL )))
335 return FALSE;
336 if (lpExitCode) *lpExitCode = pbi.ExitStatus;
337 return TRUE;
341 /**************************************************************************
342 * FatalExit (KERNEL32.@)
344 void WINAPI FatalExit( int code )
346 WARN( "FatalExit\n" );
347 ExitProcess( code );
351 /***********************************************************************
352 * GetProcessFlags (KERNEL32.@)
354 DWORD WINAPI GetProcessFlags( DWORD processid )
356 IMAGE_NT_HEADERS *nt;
357 DWORD flags = 0;
359 if (processid && processid != GetCurrentProcessId()) return 0;
361 if ((nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress )))
363 if (nt->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
364 flags |= PDB32_CONSOLE_PROC;
366 if (!AreFileApisANSI()) flags |= PDB32_FILE_APIS_OEM;
367 if (IsDebuggerPresent()) flags |= PDB32_DEBUGGED;
368 return flags;
372 /***********************************************************************
373 * ConvertToGlobalHandle (KERNEL32.@)
375 HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
377 HANDLE ret = INVALID_HANDLE_VALUE;
378 DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
379 DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
380 return ret;
384 /***********************************************************************
385 * SetHandleContext (KERNEL32.@)
387 BOOL WINAPI SetHandleContext(HANDLE hnd,DWORD context)
389 FIXME("(%p,%d), stub. In case this got called by WSOCK32/WS2_32: "
390 "the external WINSOCK DLLs won't work with WINE, don't use them.\n",hnd,context);
391 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
392 return FALSE;
396 /***********************************************************************
397 * GetHandleContext (KERNEL32.@)
399 DWORD WINAPI GetHandleContext(HANDLE hnd)
401 FIXME("(%p), stub. In case this got called by WSOCK32/WS2_32: "
402 "the external WINSOCK DLLs won't work with WINE, don't use them.\n",hnd);
403 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
404 return 0;
408 /***********************************************************************
409 * CreateSocketHandle (KERNEL32.@)
411 HANDLE WINAPI CreateSocketHandle(void)
413 FIXME("(), stub. In case this got called by WSOCK32/WS2_32: "
414 "the external WINSOCK DLLs won't work with WINE, don't use them.\n");
415 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
416 return INVALID_HANDLE_VALUE;
420 /***********************************************************************
421 * SetProcessAffinityMask (KERNEL32.@)
423 BOOL WINAPI SetProcessAffinityMask( HANDLE hProcess, DWORD_PTR affmask )
425 return set_ntstatus( NtSetInformationProcess( hProcess, ProcessAffinityMask,
426 &affmask, sizeof(DWORD_PTR) ));
430 /**********************************************************************
431 * GetProcessAffinityMask (KERNEL32.@)
433 BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess, PDWORD_PTR process_mask, PDWORD_PTR system_mask )
435 if (process_mask)
437 if (!set_ntstatus( NtQueryInformationProcess( hProcess, ProcessAffinityMask,
438 process_mask, sizeof(*process_mask), NULL )))
439 return FALSE;
441 if (system_mask)
443 SYSTEM_BASIC_INFORMATION info;
445 if (!set_ntstatus( NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )))
446 return FALSE;
447 *system_mask = info.ActiveProcessorsAffinityMask;
449 return TRUE;
453 /***********************************************************************
454 * SetProcessWorkingSetSize [KERNEL32.@]
455 * Sets the min/max working set sizes for a specified process.
457 * PARAMS
458 * process [I] Handle to the process of interest
459 * minset [I] Specifies minimum working set size
460 * maxset [I] Specifies maximum working set size
462 * RETURNS
463 * Success: TRUE
464 * Failure: FALSE
466 BOOL WINAPI SetProcessWorkingSetSize(HANDLE process, SIZE_T minset, SIZE_T maxset)
468 return SetProcessWorkingSetSizeEx(process, minset, maxset, 0);
471 /***********************************************************************
472 * GetProcessWorkingSetSize (KERNEL32.@)
474 BOOL WINAPI GetProcessWorkingSetSize(HANDLE process, SIZE_T *minset, SIZE_T *maxset)
476 return GetProcessWorkingSetSizeEx(process, minset, maxset, NULL);
480 /******************************************************************
481 * GetProcessIoCounters (KERNEL32.@)
483 BOOL WINAPI GetProcessIoCounters(HANDLE hProcess, PIO_COUNTERS ioc)
485 return set_ntstatus( NtQueryInformationProcess(hProcess, ProcessIoCounters, ioc, sizeof(*ioc), NULL ));
488 /***********************************************************************
489 * RegisterServiceProcess (KERNEL32.@)
491 * A service process calls this function to ensure that it continues to run
492 * even after a user logged off.
494 DWORD WINAPI RegisterServiceProcess(DWORD dwProcessId, DWORD dwType)
496 /* I don't think that Wine needs to do anything in this function */
497 return 1; /* success */
501 /***********************************************************************
502 * GetCurrentProcess (KERNEL32.@)
504 * Get a handle to the current process.
506 * PARAMS
507 * None.
509 * RETURNS
510 * A handle representing the current process.
512 HANDLE WINAPI KERNEL32_GetCurrentProcess(void)
514 return (HANDLE)~(ULONG_PTR)0;
518 /***********************************************************************
519 * CreateActCtxA (KERNEL32.@)
521 HANDLE WINAPI DECLSPEC_HOTPATCH CreateActCtxA( const ACTCTXA *actctx )
523 ACTCTXW actw;
524 SIZE_T len;
525 HANDLE ret = INVALID_HANDLE_VALUE;
526 LPWSTR src = NULL, assdir = NULL, resname = NULL, appname = NULL;
528 TRACE("%p %08x\n", actctx, actctx ? actctx->dwFlags : 0);
530 if (!actctx || actctx->cbSize != sizeof(*actctx))
532 SetLastError(ERROR_INVALID_PARAMETER);
533 return INVALID_HANDLE_VALUE;
536 actw.cbSize = sizeof(actw);
537 actw.dwFlags = actctx->dwFlags;
538 if (actctx->lpSource)
540 len = MultiByteToWideChar(CP_ACP, 0, actctx->lpSource, -1, NULL, 0);
541 src = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
542 if (!src) return INVALID_HANDLE_VALUE;
543 MultiByteToWideChar(CP_ACP, 0, actctx->lpSource, -1, src, len);
545 actw.lpSource = src;
547 if (actw.dwFlags & ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID)
548 actw.wProcessorArchitecture = actctx->wProcessorArchitecture;
549 if (actw.dwFlags & ACTCTX_FLAG_LANGID_VALID)
550 actw.wLangId = actctx->wLangId;
551 if (actw.dwFlags & ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID)
553 len = MultiByteToWideChar(CP_ACP, 0, actctx->lpAssemblyDirectory, -1, NULL, 0);
554 assdir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
555 if (!assdir) goto done;
556 MultiByteToWideChar(CP_ACP, 0, actctx->lpAssemblyDirectory, -1, assdir, len);
557 actw.lpAssemblyDirectory = assdir;
559 if (actw.dwFlags & ACTCTX_FLAG_RESOURCE_NAME_VALID)
561 if ((ULONG_PTR)actctx->lpResourceName >> 16)
563 len = MultiByteToWideChar(CP_ACP, 0, actctx->lpResourceName, -1, NULL, 0);
564 resname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
565 if (!resname) goto done;
566 MultiByteToWideChar(CP_ACP, 0, actctx->lpResourceName, -1, resname, len);
567 actw.lpResourceName = resname;
569 else actw.lpResourceName = (LPCWSTR)actctx->lpResourceName;
571 if (actw.dwFlags & ACTCTX_FLAG_APPLICATION_NAME_VALID)
573 len = MultiByteToWideChar(CP_ACP, 0, actctx->lpApplicationName, -1, NULL, 0);
574 appname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
575 if (!appname) goto done;
576 MultiByteToWideChar(CP_ACP, 0, actctx->lpApplicationName, -1, appname, len);
577 actw.lpApplicationName = appname;
579 if (actw.dwFlags & ACTCTX_FLAG_HMODULE_VALID)
580 actw.hModule = actctx->hModule;
582 ret = CreateActCtxW(&actw);
584 done:
585 HeapFree(GetProcessHeap(), 0, src);
586 HeapFree(GetProcessHeap(), 0, assdir);
587 HeapFree(GetProcessHeap(), 0, resname);
588 HeapFree(GetProcessHeap(), 0, appname);
589 return ret;
592 /***********************************************************************
593 * FindActCtxSectionStringA (KERNEL32.@)
595 BOOL WINAPI FindActCtxSectionStringA( DWORD flags, const GUID *guid, ULONG id, const char *search,
596 ACTCTX_SECTION_KEYED_DATA *info )
598 LPWSTR searchW;
599 DWORD len;
600 BOOL ret;
602 TRACE("%08x %s %u %s %p\n", flags, debugstr_guid(guid), id, debugstr_a(search), info);
604 if (!search || !info)
606 SetLastError(ERROR_INVALID_PARAMETER);
607 return FALSE;
609 len = MultiByteToWideChar(CP_ACP, 0, search, -1, NULL, 0);
610 searchW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
611 MultiByteToWideChar(CP_ACP, 0, search, -1, searchW, len);
612 ret = FindActCtxSectionStringW( flags, guid, id, searchW, info );
613 HeapFree(GetProcessHeap(), 0, searchW);
614 return ret;
618 /***********************************************************************
619 * CmdBatNotification (KERNEL32.@)
621 * Notifies the system that a batch file has started or finished.
623 * PARAMS
624 * bBatchRunning [I] TRUE if a batch file has started or
625 * FALSE if a batch file has finished executing.
627 * RETURNS
628 * Unknown.
630 BOOL WINAPI CmdBatNotification( BOOL bBatchRunning )
632 FIXME("%d\n", bBatchRunning);
633 return FALSE;
636 /***********************************************************************
637 * RegisterApplicationRestart (KERNEL32.@)
639 HRESULT WINAPI RegisterApplicationRestart(PCWSTR pwzCommandLine, DWORD dwFlags)
641 FIXME("(%s,%d)\n", debugstr_w(pwzCommandLine), dwFlags);
643 return S_OK;
646 /**********************************************************************
647 * WTSGetActiveConsoleSessionId (KERNEL32.@)
649 DWORD WINAPI WTSGetActiveConsoleSessionId(void)
651 static int once;
652 if (!once++) FIXME("stub\n");
653 /* Return current session id. */
654 return NtCurrentTeb()->Peb->SessionId;
657 /**********************************************************************
658 * GetSystemDEPPolicy (KERNEL32.@)
660 DEP_SYSTEM_POLICY_TYPE WINAPI GetSystemDEPPolicy(void)
662 FIXME("stub\n");
663 return OptIn;
666 /**********************************************************************
667 * SetProcessDEPPolicy (KERNEL32.@)
669 BOOL WINAPI SetProcessDEPPolicy(DWORD newDEP)
671 FIXME("(%d): stub\n", newDEP);
672 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
673 return FALSE;
676 /**********************************************************************
677 * ApplicationRecoveryFinished (KERNEL32.@)
679 VOID WINAPI ApplicationRecoveryFinished(BOOL success)
681 FIXME(": stub\n");
682 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
685 /**********************************************************************
686 * ApplicationRecoveryInProgress (KERNEL32.@)
688 HRESULT WINAPI ApplicationRecoveryInProgress(PBOOL canceled)
690 FIXME(":%p stub\n", canceled);
691 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
692 return E_FAIL;
695 /**********************************************************************
696 * RegisterApplicationRecoveryCallback (KERNEL32.@)
698 HRESULT WINAPI RegisterApplicationRecoveryCallback(APPLICATION_RECOVERY_CALLBACK callback, PVOID param, DWORD pingint, DWORD flags)
700 FIXME("%p, %p, %d, %d: stub, faking success\n", callback, param, pingint, flags);
701 return S_OK;
704 /***********************************************************************
705 * GetActiveProcessorGroupCount (KERNEL32.@)
707 WORD WINAPI GetActiveProcessorGroupCount(void)
709 FIXME("semi-stub, always returning 1\n");
710 return 1;
713 /***********************************************************************
714 * GetActiveProcessorCount (KERNEL32.@)
716 DWORD WINAPI GetActiveProcessorCount(WORD group)
718 DWORD cpus = system_info.NumberOfProcessors;
720 FIXME("semi-stub, returning %u\n", cpus);
721 return cpus;
724 /***********************************************************************
725 * GetMaximumProcessorCount (KERNEL32.@)
727 DWORD WINAPI GetMaximumProcessorCount(WORD group)
729 DWORD cpus = system_info.NumberOfProcessors;
731 FIXME("semi-stub, returning %u\n", cpus);
732 return cpus;
735 /***********************************************************************
736 * GetEnabledXStateFeatures (KERNEL32.@)
738 DWORD64 WINAPI GetEnabledXStateFeatures(void)
740 FIXME("\n");
741 return 0;
744 /***********************************************************************
745 * GetFirmwareEnvironmentVariableA (KERNEL32.@)
747 DWORD WINAPI GetFirmwareEnvironmentVariableA(LPCSTR name, LPCSTR guid, PVOID buffer, DWORD size)
749 FIXME("stub: %s %s %p %u\n", debugstr_a(name), debugstr_a(guid), buffer, size);
750 SetLastError(ERROR_INVALID_FUNCTION);
751 return 0;
754 /***********************************************************************
755 * GetFirmwareEnvironmentVariableW (KERNEL32.@)
757 DWORD WINAPI GetFirmwareEnvironmentVariableW(LPCWSTR name, LPCWSTR guid, PVOID buffer, DWORD size)
759 FIXME("stub: %s %s %p %u\n", debugstr_w(name), debugstr_w(guid), buffer, size);
760 SetLastError(ERROR_INVALID_FUNCTION);
761 return 0;
764 /**********************************************************************
765 * GetNumaNodeProcessorMask (KERNEL32.@)
767 BOOL WINAPI GetNumaNodeProcessorMask(UCHAR node, PULONGLONG mask)
769 FIXME("(%c %p): stub\n", node, mask);
770 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
771 return FALSE;
774 /**********************************************************************
775 * GetNumaAvailableMemoryNode (KERNEL32.@)
777 BOOL WINAPI GetNumaAvailableMemoryNode(UCHAR node, PULONGLONG available_bytes)
779 FIXME("(%c %p): stub\n", node, available_bytes);
780 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
781 return FALSE;
784 /**********************************************************************
785 * GetNumaAvailableMemoryNodeEx (KERNEL32.@)
787 BOOL WINAPI GetNumaAvailableMemoryNodeEx(USHORT node, PULONGLONG available_bytes)
789 FIXME("(%hu %p): stub\n", node, available_bytes);
790 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
791 return FALSE;
794 /***********************************************************************
795 * GetNumaProcessorNode (KERNEL32.@)
797 BOOL WINAPI GetNumaProcessorNode(UCHAR processor, PUCHAR node)
799 TRACE("(%d, %p)\n", processor, node);
801 if (processor < system_info.NumberOfProcessors)
803 *node = 0;
804 return TRUE;
807 *node = 0xFF;
808 SetLastError(ERROR_INVALID_PARAMETER);
809 return FALSE;
812 /***********************************************************************
813 * GetNumaProcessorNodeEx (KERNEL32.@)
815 BOOL WINAPI GetNumaProcessorNodeEx(PPROCESSOR_NUMBER processor, PUSHORT node_number)
817 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
818 return FALSE;
821 /***********************************************************************
822 * GetNumaProximityNode (KERNEL32.@)
824 BOOL WINAPI GetNumaProximityNode(ULONG proximity_id, PUCHAR node_number)
826 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
827 return FALSE;
830 /**********************************************************************
831 * GetProcessDEPPolicy (KERNEL32.@)
833 BOOL WINAPI GetProcessDEPPolicy(HANDLE process, LPDWORD flags, PBOOL permanent)
835 ULONG dep_flags;
837 TRACE("(%p %p %p)\n", process, flags, permanent);
839 if (!set_ntstatus( NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags,
840 &dep_flags, sizeof(dep_flags), NULL )))
841 return FALSE;
843 if (flags)
845 *flags = 0;
846 if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
847 *flags |= PROCESS_DEP_ENABLE;
848 if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)
849 *flags |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION;
852 if (permanent) *permanent = (dep_flags & MEM_EXECUTE_OPTION_PERMANENT) != 0;
853 return TRUE;
856 /***********************************************************************
857 * UnregisterApplicationRestart (KERNEL32.@)
859 HRESULT WINAPI UnregisterApplicationRestart(void)
861 FIXME(": stub\n");
862 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
863 return S_OK;
866 /***********************************************************************
867 * CreateUmsCompletionList (KERNEL32.@)
869 BOOL WINAPI CreateUmsCompletionList(PUMS_COMPLETION_LIST *list)
871 FIXME( "%p: stub\n", list );
872 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
873 return FALSE;
876 /***********************************************************************
877 * CreateUmsThreadContext (KERNEL32.@)
879 BOOL WINAPI CreateUmsThreadContext(PUMS_CONTEXT *ctx)
881 FIXME( "%p: stub\n", ctx );
882 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
883 return FALSE;
886 /***********************************************************************
887 * DeleteUmsCompletionList (KERNEL32.@)
889 BOOL WINAPI DeleteUmsCompletionList(PUMS_COMPLETION_LIST list)
891 FIXME( "%p: stub\n", list );
892 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
893 return FALSE;
896 /***********************************************************************
897 * DeleteUmsThreadContext (KERNEL32.@)
899 BOOL WINAPI DeleteUmsThreadContext(PUMS_CONTEXT ctx)
901 FIXME( "%p: stub\n", ctx );
902 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
903 return FALSE;
906 /***********************************************************************
907 * DequeueUmsCompletionListItems (KERNEL32.@)
909 BOOL WINAPI DequeueUmsCompletionListItems(void *list, DWORD timeout, PUMS_CONTEXT *ctx)
911 FIXME( "%p,%08x,%p: stub\n", list, timeout, ctx );
912 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
913 return FALSE;
916 /***********************************************************************
917 * EnterUmsSchedulingMode (KERNEL32.@)
919 BOOL WINAPI EnterUmsSchedulingMode(UMS_SCHEDULER_STARTUP_INFO *info)
921 FIXME( "%p: stub\n", info );
922 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
923 return FALSE;
926 /***********************************************************************
927 * ExecuteUmsThread (KERNEL32.@)
929 BOOL WINAPI ExecuteUmsThread(PUMS_CONTEXT ctx)
931 FIXME( "%p: stub\n", ctx );
932 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
933 return FALSE;
936 /***********************************************************************
937 * GetCurrentUmsThread (KERNEL32.@)
939 PUMS_CONTEXT WINAPI GetCurrentUmsThread(void)
941 FIXME( "stub\n" );
942 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
943 return FALSE;
946 /***********************************************************************
947 * GetNextUmsListItem (KERNEL32.@)
949 PUMS_CONTEXT WINAPI GetNextUmsListItem(PUMS_CONTEXT ctx)
951 FIXME( "%p: stub\n", ctx );
952 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
953 return NULL;
956 /***********************************************************************
957 * GetUmsCompletionListEvent (KERNEL32.@)
959 BOOL WINAPI GetUmsCompletionListEvent(PUMS_COMPLETION_LIST list, HANDLE *event)
961 FIXME( "%p,%p: stub\n", list, event );
962 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
963 return FALSE;
966 /***********************************************************************
967 * QueryUmsThreadInformation (KERNEL32.@)
969 BOOL WINAPI QueryUmsThreadInformation(PUMS_CONTEXT ctx, UMS_THREAD_INFO_CLASS class,
970 void *buf, ULONG length, ULONG *ret_length)
972 FIXME( "%p,%08x,%p,%08x,%p: stub\n", ctx, class, buf, length, ret_length );
973 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
974 return FALSE;
977 /***********************************************************************
978 * SetUmsThreadInformation (KERNEL32.@)
980 BOOL WINAPI SetUmsThreadInformation(PUMS_CONTEXT ctx, UMS_THREAD_INFO_CLASS class,
981 void *buf, ULONG length)
983 FIXME( "%p,%08x,%p,%08x: stub\n", ctx, class, buf, length );
984 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
985 return FALSE;
988 /***********************************************************************
989 * UmsThreadYield (KERNEL32.@)
991 BOOL WINAPI UmsThreadYield(void *param)
993 FIXME( "%p: stub\n", param );
994 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
995 return FALSE;