kernel32: Move some process functions to kernelbase.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-08-09 13:37:26 +02:00
parent f2e7e1658b
commit 09f588ee69
8 changed files with 393 additions and 425 deletions

View File

@ -252,14 +252,6 @@ BOOL WINAPI HeapUnlock(
}
/***********************************************************************
* GetProcessHeaps (KERNEL32.@)
*/
DWORD WINAPI GetProcessHeaps( DWORD count, HANDLE *heaps )
{
return RtlGetProcessHeaps( count, heaps );
}
/* These are needed so that we can call the functions from inside kernel itself */

View File

@ -517,7 +517,7 @@
@ stdcall -import FlsSetValue(long ptr)
@ stdcall FlushConsoleInputBuffer(long)
@ stdcall FlushFileBuffers(long)
@ stdcall FlushInstructionCache(long long long)
@ stdcall -import FlushInstructionCache(long long long)
@ stdcall FlushProcessWriteBuffers()
@ stdcall FlushViewOfFile(ptr long)
@ stdcall FoldStringA(long str long ptr long)
@ -664,7 +664,7 @@
@ stdcall GetEnvironmentVariableA(str ptr long)
@ stdcall GetEnvironmentVariableW(wstr ptr long)
# @ stub GetEraNameCountedString
@ stdcall GetErrorMode()
@ stdcall -import GetErrorMode()
@ stdcall GetExitCodeProcess(long ptr)
@ stdcall -import GetExitCodeThread(long ptr)
@ stdcall GetExpandedNameA(str ptr)
@ -763,7 +763,7 @@
@ stdcall GetUserPreferredUILanguages(long ptr ptr ptr)
@ stdcall GetPackageFullName(long ptr ptr)
@ stdcall GetPhysicallyInstalledSystemMemory(ptr)
@ stdcall GetPriorityClass(long)
@ stdcall -import GetPriorityClass(long)
@ stdcall GetPrivateProfileIntA(str str long str)
@ stdcall GetPrivateProfileIntW(wstr wstr long wstr)
@ stdcall GetPrivateProfileSectionA(str ptr long str)
@ -779,22 +779,22 @@
@ stdcall GetProcessDEPPolicy(long ptr ptr)
@ stdcall GetProcessFlags(long)
# @ stub GetProcessGroupAffinity
@ stdcall GetProcessHandleCount(long ptr)
@ stdcall -norelay GetProcessHeap() KERNEL32_GetProcessHeap
@ stdcall GetProcessHeaps(long ptr)
@ stdcall GetProcessId(long)
@ stdcall -import GetProcessHandleCount(long ptr)
@ stdcall -import GetProcessHeap()
@ stdcall -import GetProcessHeaps(long ptr) RtlGetProcessHeaps
@ stdcall -import GetProcessId(long)
@ stdcall -import GetProcessIdOfThread(long)
@ stdcall GetProcessIoCounters(long ptr)
@ stdcall GetProcessMitigationPolicy(long long ptr long)
@ stdcall -import GetProcessMitigationPolicy(long long ptr long)
@ stdcall GetProcessPreferredUILanguages(long ptr ptr ptr)
@ stdcall GetProcessPriorityBoost(long ptr)
@ stdcall GetProcessShutdownParameters(ptr ptr)
@ stdcall -import GetProcessPriorityBoost(long ptr)
@ stdcall -import GetProcessShutdownParameters(ptr ptr)
# @ stub GetProcessorSystemCycleTime
@ stdcall GetProcessTimes(long ptr ptr ptr ptr)
# @ stub GetProcessUserModeExceptionPolicy
@ stdcall GetProcessVersion(long)
@ stdcall GetProcessWorkingSetSize(long ptr ptr)
@ stdcall GetProcessWorkingSetSizeEx(long ptr ptr ptr)
@ stdcall -import GetProcessWorkingSetSizeEx(long ptr ptr ptr)
@ stdcall GetProductInfo(long long long long ptr)
@ stub GetProductName
@ stdcall GetProfileIntA(str str long)
@ -994,7 +994,7 @@
@ stdcall IsValidLocale(long long)
@ stdcall IsValidLocaleName(wstr)
# @ stub IsValidUILanguage
@ stdcall IsWow64Process(ptr ptr)
@ stdcall -import IsWow64Process(ptr ptr)
@ stdcall K32EmptyWorkingSet(long)
@ stdcall K32EnumDeviceDrivers(ptr long ptr)
@ stdcall K32EnumPageFilesA(ptr ptr)
@ -1124,7 +1124,7 @@
@ stdcall -import OpenMutexW(long long wstr)
# @ stub OpenPrivateNamespaceA
# @ stub OpenPrivateNamespaceW
@ stdcall OpenProcess(long long long)
@ stdcall -import OpenProcess(long long long)
# @ stub OpenProcessToken
@ stdcall OpenProfileUserMapping()
@ stdcall OpenSemaphoreA(long long str)
@ -1388,7 +1388,7 @@
# @ stub SetEnvironmentStringsW
@ stdcall SetEnvironmentVariableA(str str)
@ stdcall SetEnvironmentVariableW(wstr wstr)
@ stdcall SetErrorMode(long)
@ stdcall -import SetErrorMode(long)
@ stdcall -import SetEvent(long)
@ stdcall SetEventWhenCallbackReturns(ptr long) ntdll.TpCallbackSetEventOnCompletion
@ stdcall SetFileApisToANSI()
@ -1424,17 +1424,17 @@
@ stub SetMessageWaitingIndicator
# @ stub SetNamedPipeAttribute
@ stdcall -import SetNamedPipeHandleState(long ptr ptr ptr)
@ stdcall SetPriorityClass(long long)
@ stdcall -import SetPriorityClass(long long)
@ stdcall SetProcessAffinityMask(long long)
@ stdcall SetProcessAffinityUpdateMode(long long)
@ stdcall -import SetProcessAffinityUpdateMode(long long)
@ stdcall SetProcessDEPPolicy(long)
@ stdcall SetProcessMitigationPolicy(long ptr long)
@ stdcall -import SetProcessMitigationPolicy(long ptr long)
@ stdcall SetProcessPreferredUILanguages(long ptr ptr)
@ stdcall SetProcessPriorityBoost(long long)
@ stdcall SetProcessShutdownParameters(long long)
@ stdcall -import SetProcessPriorityBoost(long long)
@ stdcall -import SetProcessShutdownParameters(long long)
# @ stub SetProcessUserModeExceptionPolicy
@ stdcall SetProcessWorkingSetSize(long long long)
@ stdcall SetProcessWorkingSetSizeEx(long long long long)
@ stdcall -import SetProcessWorkingSetSizeEx(long long long long)
@ stdcall SetSearchPathMode(long)
@ stdcall SetStdHandle(long long)
# @ stub SetStdHandleEx
@ -1496,7 +1496,7 @@
@ stdcall SystemTimeToTzSpecificLocalTime (ptr ptr ptr)
# @ stub SystemTimeToTzSpecificLocalTimeEx
@ stdcall TerminateJobObject(long long)
@ stdcall TerminateProcess(long long)
@ stdcall -import TerminateProcess(long long)
@ stdcall -import TerminateThread(long long)
@ stdcall TermsrvAppInstallMode()
@ stdcall Thread32First(long ptr)

View File

@ -84,8 +84,6 @@ typedef struct
DWORD dwReserved;
} LOADPARMS32;
static DWORD shutdown_flags = 0;
static DWORD shutdown_priority = 0x280;
static BOOL is_wow64;
static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
@ -118,8 +116,6 @@ static const char * const cpu_names[] = { "x86", "x86_64", "PowerPC", "ARM", "AR
static void exec_process( LPCWSTR name );
extern void SHELL_LoadRegistry(void);
/* return values for get_binary_info */
enum binary_type
{
@ -3115,34 +3111,6 @@ DWORD WINAPI LoadModule( LPCSTR name, LPVOID paramBlock )
}
/******************************************************************************
* TerminateProcess (KERNEL32.@)
*
* Terminates a process.
*
* PARAMS
* handle [I] Process to terminate.
* exit_code [I] Exit code.
*
* RETURNS
* Success: TRUE.
* Failure: FALSE, check GetLastError().
*/
BOOL WINAPI TerminateProcess( HANDLE handle, DWORD exit_code )
{
NTSTATUS status;
if (!handle)
{
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
status = NtTerminateProcess( handle, exit_code );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
/***********************************************************************
* ExitProcess (KERNEL32.@)
*
@ -3203,32 +3171,6 @@ BOOL WINAPI GetExitCodeProcess( HANDLE hProcess, LPDWORD lpExitCode )
}
/***********************************************************************
* SetErrorMode (KERNEL32.@)
*/
UINT WINAPI SetErrorMode( UINT mode )
{
UINT old;
NtQueryInformationProcess( GetCurrentProcess(), ProcessDefaultHardErrorMode,
&old, sizeof(old), NULL );
NtSetInformationProcess( GetCurrentProcess(), ProcessDefaultHardErrorMode,
&mode, sizeof(mode) );
return old;
}
/***********************************************************************
* GetErrorMode (KERNEL32.@)
*/
UINT WINAPI GetErrorMode( void )
{
UINT mode;
NtQueryInformationProcess( GetCurrentProcess(), ProcessDefaultHardErrorMode,
&mode, sizeof(mode), NULL );
return mode;
}
/***********************************************************************
* GetProcessFlags (KERNEL32.@)
*/
@ -3250,79 +3192,6 @@ DWORD WINAPI GetProcessFlags( DWORD processid )
}
/*********************************************************************
* OpenProcess (KERNEL32.@)
*
* Opens a handle to a process.
*
* PARAMS
* access [I] Desired access rights assigned to the returned handle.
* inherit [I] Determines whether or not child processes will inherit the handle.
* id [I] Process identifier of the process to get a handle to.
*
* RETURNS
* Success: Valid handle to the specified process.
* Failure: NULL, check GetLastError().
*/
HANDLE WINAPI OpenProcess( DWORD access, BOOL inherit, DWORD id )
{
NTSTATUS status;
HANDLE handle;
OBJECT_ATTRIBUTES attr;
CLIENT_ID cid;
cid.UniqueProcess = ULongToHandle(id);
cid.UniqueThread = 0; /* FIXME ? */
attr.Length = sizeof(OBJECT_ATTRIBUTES);
attr.RootDirectory = NULL;
attr.Attributes = inherit ? OBJ_INHERIT : 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
attr.ObjectName = NULL;
if (GetVersion() & 0x80000000) access = PROCESS_ALL_ACCESS;
status = NtOpenProcess(&handle, access, &attr, &cid);
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return NULL;
}
return handle;
}
/*********************************************************************
* GetProcessId (KERNEL32.@)
*
* Gets the a unique identifier of a process.
*
* PARAMS
* hProcess [I] Handle to the process.
*
* RETURNS
* Success: TRUE.
* Failure: FALSE, check GetLastError().
*
* NOTES
*
* The identifier is unique only on the machine and only until the process
* exits (including system shutdown).
*/
DWORD WINAPI GetProcessId( HANDLE hProcess )
{
NTSTATUS status;
PROCESS_BASIC_INFORMATION pbi;
status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
if (status == STATUS_SUCCESS) return pbi.UniqueProcessId;
SetLastError( RtlNtStatusToDosError(status) );
return 0;
}
/*********************************************************************
* CloseHandle (KERNEL32.@)
*
@ -3480,75 +3349,6 @@ HANDLE WINAPI CreateSocketHandle(void)
}
/***********************************************************************
* SetPriorityClass (KERNEL32.@)
*/
BOOL WINAPI SetPriorityClass( HANDLE hprocess, DWORD priorityclass )
{
NTSTATUS status;
PROCESS_PRIORITY_CLASS ppc;
ppc.Foreground = FALSE;
switch (priorityclass)
{
case IDLE_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_IDLE; break;
case BELOW_NORMAL_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_BELOW_NORMAL; break;
case NORMAL_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_NORMAL; break;
case ABOVE_NORMAL_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_ABOVE_NORMAL; break;
case HIGH_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_HIGH; break;
case REALTIME_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_REALTIME; break;
default:
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
status = NtSetInformationProcess(hprocess, ProcessPriorityClass,
&ppc, sizeof(ppc));
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
return TRUE;
}
/***********************************************************************
* GetPriorityClass (KERNEL32.@)
*/
DWORD WINAPI GetPriorityClass(HANDLE hProcess)
{
NTSTATUS status;
PROCESS_BASIC_INFORMATION pbi;
status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return 0;
}
switch (pbi.BasePriority)
{
case PROCESS_PRIOCLASS_IDLE: return IDLE_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_BELOW_NORMAL: return BELOW_NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_NORMAL: return NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_ABOVE_NORMAL: return ABOVE_NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_HIGH: return HIGH_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_REALTIME: return REALTIME_PRIORITY_CLASS;
}
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
/***********************************************************************
* SetProcessAffinityMask (KERNEL32.@)
*/
@ -3593,17 +3393,6 @@ BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess, PDWORD_PTR process_mask, PD
}
/***********************************************************************
* SetProcessAffinityUpdateMode (KERNEL32.@)
*/
BOOL WINAPI SetProcessAffinityUpdateMode( HANDLE process, DWORD flags )
{
FIXME("(%p,0x%08x): stub\n", process, flags);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/***********************************************************************
* GetProcessVersion (KERNEL32.@)
*/
@ -3659,30 +3448,6 @@ err:
}
/***********************************************************************
* SetProcessWorkingSetSizeEx [KERNEL32.@]
* Sets the min/max working set sizes for a specified process.
*
* PARAMS
* process [I] Handle to the process of interest
* minset [I] Specifies minimum working set size
* maxset [I] Specifies maximum working set size
* flags [I] Flags to enforce working set sizes
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL WINAPI SetProcessWorkingSetSizeEx(HANDLE process, SIZE_T minset, SIZE_T maxset, DWORD flags)
{
WARN("(%p,%ld,%ld,%x): stub - harmless\n", process, minset, maxset, flags);
if(( minset == (SIZE_T)-1) && (maxset == (SIZE_T)-1)) {
/* Trim the working set to zero */
/* Swap the process out of physical RAM */
}
return TRUE;
}
/***********************************************************************
* SetProcessWorkingSetSize [KERNEL32.@]
* Sets the min/max working set sizes for a specified process.
@ -3710,22 +3475,6 @@ BOOL WINAPI K32EmptyWorkingSet(HANDLE hProcess)
}
/***********************************************************************
* GetProcessWorkingSetSizeEx (KERNEL32.@)
*/
BOOL WINAPI GetProcessWorkingSetSizeEx(HANDLE process, SIZE_T *minset,
SIZE_T *maxset, DWORD *flags)
{
FIXME("(%p,%p,%p,%p): stub\n", process, minset, maxset, flags);
/* 32 MB working set size */
if (minset) *minset = 32*1024*1024;
if (maxset) *maxset = 32*1024*1024;
if (flags) *flags = QUOTA_LIMITS_HARDWS_MIN_DISABLE |
QUOTA_LIMITS_HARDWS_MAX_DISABLE;
return TRUE;
}
/***********************************************************************
* GetProcessWorkingSetSize (KERNEL32.@)
*/
@ -3735,54 +3484,6 @@ BOOL WINAPI GetProcessWorkingSetSize(HANDLE process, SIZE_T *minset, SIZE_T *max
}
/***********************************************************************
* SetProcessShutdownParameters (KERNEL32.@)
*/
BOOL WINAPI SetProcessShutdownParameters(DWORD level, DWORD flags)
{
FIXME("(%08x, %08x): partial stub.\n", level, flags);
shutdown_flags = flags;
shutdown_priority = level;
return TRUE;
}
/***********************************************************************
* GetProcessShutdownParameters (KERNEL32.@)
*
*/
BOOL WINAPI GetProcessShutdownParameters( LPDWORD lpdwLevel, LPDWORD lpdwFlags )
{
*lpdwLevel = shutdown_priority;
*lpdwFlags = shutdown_flags;
return TRUE;
}
/***********************************************************************
* GetProcessPriorityBoost (KERNEL32.@)
*/
BOOL WINAPI GetProcessPriorityBoost(HANDLE hprocess,PBOOL pDisablePriorityBoost)
{
FIXME("(%p,%p): semi-stub\n", hprocess, pDisablePriorityBoost);
/* Report that no boost is present.. */
*pDisablePriorityBoost = FALSE;
return TRUE;
}
/***********************************************************************
* SetProcessPriorityBoost (KERNEL32.@)
*/
BOOL WINAPI SetProcessPriorityBoost(HANDLE hprocess,BOOL disableboost)
{
FIXME("(%p,%d): stub\n",hprocess,disableboost);
/* Say we can do it. I doubt the program will notice that we don't. */
return TRUE;
}
/***********************************************************************
* ReadProcessMemory (KERNEL32.@)
*/
@ -3807,18 +3508,6 @@ BOOL WINAPI WriteProcessMemory( HANDLE process, LPVOID addr, LPCVOID buffer, SIZ
}
/****************************************************************************
* FlushInstructionCache (KERNEL32.@)
*/
BOOL WINAPI FlushInstructionCache(HANDLE hProcess, LPCVOID lpBaseAddress, SIZE_T dwSize)
{
NTSTATUS status;
status = NtFlushInstructionCache( hProcess, lpBaseAddress, dwSize );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
/******************************************************************
* GetProcessIoCounters (KERNEL32.@)
*/
@ -3832,19 +3521,6 @@ BOOL WINAPI GetProcessIoCounters(HANDLE hProcess, PIO_COUNTERS ioc)
return !status;
}
/******************************************************************
* GetProcessHandleCount (KERNEL32.@)
*/
BOOL WINAPI GetProcessHandleCount(HANDLE hProcess, DWORD *cnt)
{
NTSTATUS status;
status = NtQueryInformationProcess(hProcess, ProcessHandleCount,
cnt, sizeof(*cnt), NULL);
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
/******************************************************************
* QueryFullProcessImageNameA (KERNEL32.@)
*/
@ -4114,26 +3790,6 @@ DWORD WINAPI RegisterServiceProcess(DWORD dwProcessId, DWORD dwType)
}
/**********************************************************************
* IsWow64Process (KERNEL32.@)
*/
BOOL WINAPI IsWow64Process(HANDLE hProcess, PBOOL Wow64Process)
{
ULONG_PTR pbi;
NTSTATUS status;
status = NtQueryInformationProcess( hProcess, ProcessWow64Information, &pbi, sizeof(pbi), NULL );
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError( status ) );
return FALSE;
}
*Wow64Process = (pbi != 0);
return TRUE;
}
/***********************************************************************
* GetCurrentProcess (KERNEL32.@)
*
@ -4735,23 +4391,3 @@ BOOL WINAPI BaseFlushAppcompatCache(void)
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/**********************************************************************
* SetProcessMitigationPolicy (KERNEL32.@)
*/
BOOL WINAPI SetProcessMitigationPolicy(PROCESS_MITIGATION_POLICY policy, void *buffer, SIZE_T length)
{
FIXME("(%d, %p, %lu): stub\n", policy, buffer, length);
return TRUE;
}
/**********************************************************************
* GetProcessMitigationPolicy (KERNEL32.@)
*/
BOOL WINAPI GetProcessMitigationPolicy(HANDLE hProcess, PROCESS_MITIGATION_POLICY policy, void *buffer, SIZE_T length)
{
FIXME("(%p, %u, %p, %lu): stub\n", hProcess, policy, buffer, length);
return TRUE;
}

View File

@ -160,11 +160,3 @@ DWORD WINAPI KERNEL32_GetCurrentThreadId(void)
{
return HandleToULong(NtCurrentTeb()->ClientId.UniqueThread);
}
/***********************************************************************
* GetProcessHeap (KERNEL32.@)
*/
HANDLE WINAPI KERNEL32_GetProcessHeap(void)
{
return NtCurrentTeb()->Peb->ProcessHeap;
}

View File

@ -7,6 +7,7 @@ C_SRCS = \
loader.c \
main.c \
path.c \
process.c \
registry.c \
security.c \
string.c \

View File

@ -381,7 +381,7 @@
@ stdcall FlsSetValue(long ptr)
@ stdcall FlushConsoleInputBuffer(long) kernel32.FlushConsoleInputBuffer
@ stdcall FlushFileBuffers(long) kernel32.FlushFileBuffers
@ stdcall FlushInstructionCache(long long long) kernel32.FlushInstructionCache
@ stdcall FlushInstructionCache(long long long)
@ stdcall FlushProcessWriteBuffers() kernel32.FlushProcessWriteBuffers
@ stdcall FlushViewOfFile(ptr long) kernel32.FlushViewOfFile
@ stdcall FoldStringW(long wstr long ptr long) kernel32.FoldStringW
@ -464,8 +464,8 @@
# @ stub GetCurrentPackagePath
# @ stub GetCurrentPackageResourcesContext
# @ stub GetCurrentPackageSecurityContext
@ stdcall -norelay GetCurrentProcess() kernel32.GetCurrentProcess
@ stdcall -norelay GetCurrentProcessId() kernel32.GetCurrentProcessId
@ stdcall -norelay GetCurrentProcess() kernelbase_GetCurrentProcess
@ stdcall -norelay GetCurrentProcessId() kernelbase_GetCurrentProcessId
@ stdcall GetCurrentProcessorNumber() ntdll.NtGetCurrentProcessorNumber
@ stdcall GetCurrentProcessorNumberEx(ptr) ntdll.RtlGetCurrentProcessorNumberEx
# @ stub GetCurrentTargetPlatformContext
@ -498,8 +498,8 @@
@ stdcall GetEnvironmentVariableA(str ptr long) kernel32.GetEnvironmentVariableA
@ stdcall GetEnvironmentVariableW(wstr ptr long) kernel32.GetEnvironmentVariableW
@ stub GetEraNameCountedString
@ stdcall GetErrorMode() kernel32.GetErrorMode
@ stdcall GetExitCodeProcess(long ptr) kernel32.GetExitCodeProcess
@ stdcall GetErrorMode()
@ stdcall GetExitCodeProcess(long ptr)
@ stdcall GetExitCodeThread(long ptr)
@ stub GetFallbackDisplayName
@ stdcall GetFileAttributesA(str) kernel32.GetFileAttributesA
@ -617,28 +617,28 @@
# @ stub GetPerformanceInfo
@ stdcall GetPhysicallyInstalledSystemMemory(ptr) kernel32.GetPhysicallyInstalledSystemMemory
# @ stub GetPreviousFgPolicyRefreshInfoInternal
@ stdcall GetPriorityClass(long) kernel32.GetPriorityClass
@ stdcall GetPriorityClass(long)
@ stdcall GetPrivateObjectSecurity(ptr long ptr long ptr)
@ stdcall GetProcAddress(long str) kernel32.GetProcAddress
# @ stub GetProcAddressForCaller
# @ stub GetProcessDefaultCpuSets
# @ stub GetProcessGroupAffinity
@ stdcall GetProcessHandleCount(long ptr) kernel32.GetProcessHandleCount
@ stdcall -norelay GetProcessHeap() kernel32.GetProcessHeap
@ stdcall GetProcessHeaps(long ptr) kernel32.GetProcessHeaps
@ stdcall GetProcessId(long) kernel32.GetProcessId
@ stdcall GetProcessHandleCount(long ptr)
@ stdcall -norelay GetProcessHeap() kernelbase_GetProcessHeap
@ stdcall -import GetProcessHeaps(long ptr) RtlGetProcessHeaps
@ stdcall GetProcessId(long)
@ stdcall GetProcessIdOfThread(long)
# @ stub GetProcessImageFileNameA
# @ stub GetProcessImageFileNameW
# @ stub GetProcessInformation
# @ stub GetProcessMemoryInfo
@ stdcall GetProcessMitigationPolicy(long long ptr long) kernel32.GetProcessMitigationPolicy
@ stdcall GetProcessMitigationPolicy(long long ptr long)
@ stdcall GetProcessPreferredUILanguages(long ptr ptr ptr) kernel32.GetProcessPreferredUILanguages
@ stdcall GetProcessPriorityBoost(long ptr) kernel32.GetProcessPriorityBoost
@ stdcall GetProcessShutdownParameters(ptr ptr) kernel32.GetProcessShutdownParameters
@ stdcall GetProcessPriorityBoost(long ptr)
@ stdcall GetProcessShutdownParameters(ptr ptr)
@ stdcall GetProcessTimes(long ptr ptr ptr ptr) kernel32.GetProcessTimes
@ stdcall GetProcessVersion(long) kernel32.GetProcessVersion
@ stdcall GetProcessWorkingSetSizeEx(long ptr ptr ptr) kernel32.GetProcessWorkingSetSizeEx
@ stdcall GetProcessWorkingSetSizeEx(long ptr ptr ptr)
# @ stub GetProcessorSystemCycleTime
@ stdcall GetProductInfo(long long long long ptr) kernel32.GetProductInfo
@ stub GetPtrCalData
@ -884,7 +884,7 @@
@ stdcall IsValidSecurityDescriptor(ptr)
@ stdcall IsValidSid(ptr)
@ stdcall IsWellKnownSid(ptr long)
@ stdcall IsWow64Process(ptr ptr) kernel32.IsWow64Process
@ stdcall IsWow64Process(ptr ptr)
# @ stub IsWow64Process2
@ stdcall K32EmptyWorkingSet(long) kernel32.K32EmptyWorkingSet
@ stdcall K32EnumDeviceDrivers(ptr long ptr) kernel32.K32EnumDeviceDrivers
@ -991,7 +991,7 @@
# @ stub OpenPackageInfoByFullName
# @ stub OpenPackageInfoByFullNameForUser
# @ stub OpenPrivateNamespaceW
@ stdcall OpenProcess(long long long) kernel32.OpenProcess
@ stdcall OpenProcess(long long long)
@ stdcall OpenProcessToken(long long ptr)
@ stub OpenRegKey
@ stdcall OpenSemaphoreW(long long wstr)
@ -1426,7 +1426,7 @@
@ stub SetEnvironmentStringsW
@ stdcall SetEnvironmentVariableA(str str) kernel32.SetEnvironmentVariableA
@ stdcall SetEnvironmentVariableW(wstr wstr) kernel32.SetEnvironmentVariableW
@ stdcall SetErrorMode(long) kernel32.SetErrorMode
@ stdcall SetErrorMode(long)
@ stdcall SetEvent(long)
@ stdcall SetEventWhenCallbackReturns(ptr long) ntdll.TpCallbackSetEventOnCompletion
@ stdcall SetFileApisToANSI() kernel32.SetFileApisToANSI
@ -1450,19 +1450,19 @@
@ stdcall SetLocalTime(ptr) kernel32.SetLocalTime
@ stdcall SetLocaleInfoW(long long wstr) kernel32.SetLocaleInfoW
@ stdcall SetNamedPipeHandleState(long ptr ptr ptr)
@ stdcall SetPriorityClass(long long) kernel32.SetPriorityClass
@ stdcall SetPriorityClass(long long)
@ stdcall SetPrivateObjectSecurity(long ptr ptr ptr long)
@ stub SetPrivateObjectSecurityEx
@ stdcall SetProcessAffinityUpdateMode(long long) kernel32.SetProcessAffinityUpdateMode
@ stdcall SetProcessAffinityUpdateMode(long long)
# @ stub SetProcessDefaultCpuSets
# @ stub SetProcessGroupAffinity
# @ stub SetProcessInformation
@ stdcall SetProcessMitigationPolicy(long ptr long) kernel32.SetProcessMitigationPolicy
@ stdcall SetProcessMitigationPolicy(long ptr long)
@ stdcall SetProcessPreferredUILanguages(long ptr ptr) kernel32.SetProcessPreferredUILanguages
@ stdcall SetProcessPriorityBoost(long long) kernel32.SetProcessPriorityBoost
@ stdcall SetProcessShutdownParameters(long long) kernel32.SetProcessShutdownParameters
@ stdcall SetProcessPriorityBoost(long long)
@ stdcall SetProcessShutdownParameters(long long)
# @ stub SetProcessValidCallTargets
@ stdcall SetProcessWorkingSetSizeEx(long long long long) kernel32.SetProcessWorkingSetSizeEx
@ stdcall SetProcessWorkingSetSizeEx(long long long long)
# @ stub SetProtectedPolicy
# @ stub SetRoamingLastObservedChangeTime
@ stub SetSecurityAccessMask
@ -1594,7 +1594,7 @@
@ stdcall SystemTimeToFileTime(ptr ptr) kernel32.SystemTimeToFileTime
@ stdcall SystemTimeToTzSpecificLocalTime(ptr ptr ptr) kernel32.SystemTimeToTzSpecificLocalTime
@ stub SystemTimeToTzSpecificLocalTimeEx
@ stdcall TerminateProcess(long long) kernel32.TerminateProcess
@ stdcall TerminateProcess(long long)
# @ stub TerminateProcessOnMemoryExhaustion
@ stdcall TerminateThread(long long)
@ stdcall TlsAlloc()

346
dlls/kernelbase/process.c Normal file
View File

@ -0,0 +1,346 @@
/*
* Win32 processes
*
* Copyright 1996, 1998 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <string.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "kernelbase.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(process);
static DWORD shutdown_flags = 0;
static DWORD shutdown_priority = 0x280;
/***********************************************************************
* Processes
***********************************************************************/
/****************************************************************************
* FlushInstructionCache (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH FlushInstructionCache( HANDLE process, LPCVOID addr, SIZE_T size )
{
return set_ntstatus( NtFlushInstructionCache( process, addr, size ));
}
/***********************************************************************
* GetCurrentProcess (kernelbase.@)
*/
HANDLE WINAPI kernelbase_GetCurrentProcess(void)
{
return (HANDLE)~(ULONG_PTR)0;
}
/***********************************************************************
* GetCurrentProcessId (kernelbase.@)
*/
DWORD WINAPI kernelbase_GetCurrentProcessId(void)
{
return HandleToULong( NtCurrentTeb()->ClientId.UniqueProcess );
}
/***********************************************************************
* GetErrorMode (kernelbase.@)
*/
UINT WINAPI DECLSPEC_HOTPATCH GetErrorMode(void)
{
UINT mode;
NtQueryInformationProcess( GetCurrentProcess(), ProcessDefaultHardErrorMode,
&mode, sizeof(mode), NULL );
return mode;
}
/***********************************************************************
* GetExitCodeProcess (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetExitCodeProcess( HANDLE process, LPDWORD exit_code )
{
NTSTATUS status;
PROCESS_BASIC_INFORMATION pbi;
status = NtQueryInformationProcess( process, ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
if (status && exit_code) *exit_code = pbi.ExitStatus;
return set_ntstatus( status );
}
/***********************************************************************
* GetPriorityClass (kernelbase.@)
*/
DWORD WINAPI DECLSPEC_HOTPATCH GetPriorityClass( HANDLE process )
{
PROCESS_BASIC_INFORMATION pbi;
if (!set_ntstatus( NtQueryInformationProcess( process, ProcessBasicInformation,
&pbi, sizeof(pbi), NULL )))
return 0;
switch (pbi.BasePriority)
{
case PROCESS_PRIOCLASS_IDLE: return IDLE_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_BELOW_NORMAL: return BELOW_NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_NORMAL: return NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_ABOVE_NORMAL: return ABOVE_NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_HIGH: return HIGH_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_REALTIME: return REALTIME_PRIORITY_CLASS;
default: return 0;
}
}
/******************************************************************
* GetProcessHandleCount (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessHandleCount( HANDLE process, DWORD *count )
{
return set_ntstatus( NtQueryInformationProcess( process, ProcessHandleCount,
count, sizeof(*count), NULL ));
}
/***********************************************************************
* GetProcessHeap (kernelbase.@)
*/
HANDLE WINAPI kernelbase_GetProcessHeap(void)
{
return NtCurrentTeb()->Peb->ProcessHeap;
}
/*********************************************************************
* GetProcessId (kernelbase.@)
*/
DWORD WINAPI DECLSPEC_HOTPATCH GetProcessId( HANDLE process )
{
PROCESS_BASIC_INFORMATION pbi;
if (!set_ntstatus( NtQueryInformationProcess( process, ProcessBasicInformation,
&pbi, sizeof(pbi), NULL )))
return 0;
return pbi.UniqueProcessId;
}
/**********************************************************************
* GetProcessMitigationPolicy (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessMitigationPolicy( HANDLE process, PROCESS_MITIGATION_POLICY policy,
void *buffer, SIZE_T length )
{
FIXME( "(%p, %u, %p, %lu): stub\n", process, policy, buffer, length );
return TRUE;
}
/***********************************************************************
* GetProcessPriorityBoost (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessPriorityBoost( HANDLE process, PBOOL disable )
{
FIXME( "(%p,%p): semi-stub\n", process, disable );
*disable = FALSE; /* report that no boost is present */
return TRUE;
}
/***********************************************************************
* GetProcessShutdownParameters (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessShutdownParameters( LPDWORD level, LPDWORD flags )
{
*level = shutdown_priority;
*flags = shutdown_flags;
return TRUE;
}
/***********************************************************************
* GetProcessWorkingSetSizeEx (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetProcessWorkingSetSizeEx( HANDLE process, SIZE_T *minset,
SIZE_T *maxset, DWORD *flags)
{
FIXME( "(%p,%p,%p,%p): stub\n", process, minset, maxset, flags );
/* 32 MB working set size */
if (minset) *minset = 32*1024*1024;
if (maxset) *maxset = 32*1024*1024;
if (flags) *flags = QUOTA_LIMITS_HARDWS_MIN_DISABLE | QUOTA_LIMITS_HARDWS_MAX_DISABLE;
return TRUE;
}
/**********************************************************************
* IsWow64Process (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH IsWow64Process( HANDLE process, PBOOL wow64 )
{
ULONG_PTR pbi;
NTSTATUS status;
status = NtQueryInformationProcess( process, ProcessWow64Information, &pbi, sizeof(pbi), NULL );
if (!status) *wow64 = !!pbi;
return set_ntstatus( status );
}
/*********************************************************************
* OpenProcess (kernelbase.@)
*/
HANDLE WINAPI DECLSPEC_HOTPATCH OpenProcess( DWORD access, BOOL inherit, DWORD id )
{
HANDLE handle;
OBJECT_ATTRIBUTES attr;
CLIENT_ID cid;
if (GetVersion() & 0x80000000) access = PROCESS_ALL_ACCESS;
attr.Length = sizeof(OBJECT_ATTRIBUTES);
attr.RootDirectory = 0;
attr.Attributes = inherit ? OBJ_INHERIT : 0;
attr.ObjectName = NULL;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
cid.UniqueProcess = ULongToHandle(id);
cid.UniqueThread = 0;
if (!set_ntstatus( NtOpenProcess( &handle, access, &attr, &cid ))) return NULL;
return handle;
}
/***********************************************************************
* SetErrorMode (kernelbase.@)
*/
UINT WINAPI DECLSPEC_HOTPATCH SetErrorMode( UINT mode )
{
UINT old = GetErrorMode();
NtSetInformationProcess( GetCurrentProcess(), ProcessDefaultHardErrorMode,
&mode, sizeof(mode) );
return old;
}
/***********************************************************************
* SetPriorityClass (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetPriorityClass( HANDLE process, DWORD class )
{
PROCESS_PRIORITY_CLASS ppc;
ppc.Foreground = FALSE;
switch (class)
{
case IDLE_PRIORITY_CLASS: ppc.PriorityClass = PROCESS_PRIOCLASS_IDLE; break;
case BELOW_NORMAL_PRIORITY_CLASS: ppc.PriorityClass = PROCESS_PRIOCLASS_BELOW_NORMAL; break;
case NORMAL_PRIORITY_CLASS: ppc.PriorityClass = PROCESS_PRIOCLASS_NORMAL; break;
case ABOVE_NORMAL_PRIORITY_CLASS: ppc.PriorityClass = PROCESS_PRIOCLASS_ABOVE_NORMAL; break;
case HIGH_PRIORITY_CLASS: ppc.PriorityClass = PROCESS_PRIOCLASS_HIGH; break;
case REALTIME_PRIORITY_CLASS: ppc.PriorityClass = PROCESS_PRIOCLASS_REALTIME; break;
default:
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
return set_ntstatus( NtSetInformationProcess( process, ProcessPriorityClass, &ppc, sizeof(ppc) ));
}
/***********************************************************************
* SetProcessAffinityUpdateMode (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessAffinityUpdateMode( HANDLE process, DWORD flags )
{
FIXME( "(%p,0x%08x): stub\n", process, flags );
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE;
}
/**********************************************************************
* SetProcessMitigationPolicy (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessMitigationPolicy( PROCESS_MITIGATION_POLICY policy,
void *buffer, SIZE_T length )
{
FIXME( "(%d, %p, %lu): stub\n", policy, buffer, length );
return TRUE;
}
/***********************************************************************
* SetProcessPriorityBoost (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessPriorityBoost( HANDLE process, BOOL disable )
{
FIXME( "(%p,%d): stub\n", process, disable );
return TRUE;
}
/***********************************************************************
* SetProcessShutdownParameters (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessShutdownParameters( DWORD level, DWORD flags )
{
FIXME( "(%08x, %08x): partial stub.\n", level, flags );
shutdown_flags = flags;
shutdown_priority = level;
return TRUE;
}
/***********************************************************************
* SetProcessWorkingSetSizeEx (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetProcessWorkingSetSizeEx( HANDLE process, SIZE_T minset,
SIZE_T maxset, DWORD flags )
{
WARN( "(%p,%ld,%ld,%x): stub - harmless\n", process, minset, maxset, flags );
return TRUE;
}
/******************************************************************************
* TerminateProcess (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH TerminateProcess( HANDLE handle, DWORD exit_code )
{
if (!handle)
{
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
return set_ntstatus( NtTerminateProcess( handle, exit_code ));
}

View File

@ -2236,6 +2236,7 @@ WINBASEAPI BOOL WINAPI GetProcessShutdownParameters(LPDWORD,LPDWORD);
WINBASEAPI BOOL WINAPI GetProcessTimes(HANDLE,LPFILETIME,LPFILETIME,LPFILETIME,LPFILETIME);
WINBASEAPI DWORD WINAPI GetProcessVersion(DWORD);
WINBASEAPI BOOL WINAPI GetProcessWorkingSetSize(HANDLE,PSIZE_T,PSIZE_T);
WINBASEAPI BOOL WINAPI GetProcessWorkingSetSizeEx(HANDLE,SIZE_T*,SIZE_T*,DWORD*);
WINBASEAPI BOOL WINAPI GetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
WINBASEAPI UINT WINAPI GetProfileIntA(LPCSTR,LPCSTR,INT);
WINBASEAPI UINT WINAPI GetProfileIntW(LPCWSTR,LPCWSTR,INT);