Commit eac5395f authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Move some misc functions to kernelbase.

parent ea43b87c
......@@ -150,16 +150,6 @@ VOID WINAPI GetNativeSystemInfo(
}
/***********************************************************************
* IsProcessorFeaturePresent [KERNEL32.@]
*
* Determine if the cpu supports a given feature.
*/
BOOL WINAPI IsProcessorFeaturePresent ( DWORD feature )
{
return RtlIsProcessorFeaturePresent( feature );
}
/***********************************************************************
* K32GetPerformanceInfo (KERNEL32.@)
*/
BOOL WINAPI K32GetPerformanceInfo(PPERFORMANCE_INFORMATION info, DWORD size)
......
......@@ -306,7 +306,7 @@
@ stdcall CreateNamedPipeA(str long long long long long long ptr)
@ stdcall -import CreateNamedPipeW(wstr long long long long long long ptr)
# @ stub CreateNlsSecurityDescriptor
@ stdcall CreatePipe(ptr ptr ptr long)
@ stdcall -import CreatePipe(ptr ptr ptr long)
# @ stub CreatePrivateNamespaceA
# @ stub CreatePrivateNamespaceW
@ stdcall CreateProcessA(str str ptr ptr long long ptr str ptr ptr)
......@@ -795,7 +795,7 @@
@ stdcall GetProcessVersion(long)
@ stdcall GetProcessWorkingSetSize(long ptr ptr)
@ stdcall -import GetProcessWorkingSetSizeEx(long ptr ptr ptr)
@ stdcall GetProductInfo(long long long long ptr)
@ stdcall -import GetProductInfo(long long long long ptr)
@ stub GetProductName
@ stdcall GetProfileIntA(str str long)
@ stdcall GetProfileIntW(wstr wstr long)
......@@ -981,8 +981,8 @@
@ stub -i386 IsLSCallback
# @ stub IsNLSDefinedString
@ stdcall IsNormalizedString(long wstr long)
@ stdcall IsProcessInJob(long long ptr)
@ stdcall IsProcessorFeaturePresent(long)
@ stdcall -import IsProcessInJob(long long ptr)
@ stdcall -import IsProcessorFeaturePresent(long)
@ stub -i386 IsSLCallback
@ stdcall IsSystemResumeAutomatic()
@ stdcall -import IsThreadAFiber()
......
......@@ -382,26 +382,6 @@ BOOL WINAPI AssignProcessToJobObject( HANDLE job, HANDLE process )
return !status;
}
/******************************************************************************
* IsProcessInJob (KERNEL32.@)
*/
BOOL WINAPI IsProcessInJob( HANDLE process, HANDLE job, PBOOL result )
{
NTSTATUS status = NtIsProcessInJob( process, job );
switch(status)
{
case STATUS_PROCESS_IN_JOB:
*result = TRUE;
return TRUE;
case STATUS_PROCESS_NOT_IN_JOB:
*result = FALSE;
return TRUE;
default:
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
}
/*
* Timers
......@@ -739,75 +719,6 @@ BOOL WINAPI CallNamedPipeA(
return ret;
}
/******************************************************************
* CreatePipe (KERNEL32.@)
*
*/
BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
LPSECURITY_ATTRIBUTES sa, DWORD size )
{
static unsigned index /* = 0 */;
WCHAR name[64];
HANDLE hr, hw;
unsigned in_index = index;
UNICODE_STRING nt_name;
OBJECT_ATTRIBUTES attr;
NTSTATUS status;
IO_STATUS_BLOCK iosb;
LARGE_INTEGER timeout;
*hReadPipe = *hWritePipe = INVALID_HANDLE_VALUE;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nt_name;
attr.Attributes = OBJ_CASE_INSENSITIVE |
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL;
if (!size) size = 4096;
timeout.QuadPart = (ULONGLONG)NMPWAIT_USE_DEFAULT_WAIT * -10000;
/* generate a unique pipe name (system wide) */
do
{
static const WCHAR nameFmt[] = { '\\','?','?','\\','p','i','p','e',
'\\','W','i','n','3','2','.','P','i','p','e','s','.','%','0','8','l',
'u','.','%','0','8','u','\0' };
snprintfW(name, ARRAY_SIZE(name), nameFmt, GetCurrentProcessId(), ++index);
RtlInitUnicodeString(&nt_name, name);
status = NtCreateNamedPipeFile(&hr, GENERIC_READ | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
&attr, &iosb, FILE_SHARE_WRITE, FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
FALSE, FALSE, FALSE,
1, size, size, &timeout);
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
hr = INVALID_HANDLE_VALUE;
}
} while (hr == INVALID_HANDLE_VALUE && index != in_index);
/* from completion sakeness, I think system resources might be exhausted before this happens !! */
if (hr == INVALID_HANDLE_VALUE) return FALSE;
status = NtOpenFile(&hw, GENERIC_WRITE | FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr, &iosb, 0,
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
NtClose(hr);
return FALSE;
}
*hReadPipe = hr;
*hWritePipe = hw;
return TRUE;
}
/******************************************************************************
* CreateMailslotA [KERNEL32.@]
*
......
......@@ -111,21 +111,6 @@ DWORD WINAPI SetTermsrvAppInstallMode(BOOL bInstallMode)
}
/***********************************************************************
* GetProductInfo (KERNEL32.@)
*
* Gives info about the current Windows product type, in a format compatible
* with the given Windows version
*
* Returns TRUE if the input is valid, FALSE otherwise
*/
BOOL WINAPI GetProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion,
DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType)
{
return RtlGetProductInfo(dwOSMajorVersion, dwOSMinorVersion,
dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType);
}
/***********************************************************************
* GetCurrentPackageId (KERNEL32.@)
*/
LONG WINAPI GetCurrentPackageId(UINT32 *len, BYTE *buffer)
......
......@@ -200,7 +200,7 @@
@ stdcall CreateMutexExW(ptr wstr long long)
@ stdcall CreateMutexW(ptr long wstr)
@ stdcall CreateNamedPipeW(wstr long long long long long long ptr)
@ stdcall CreatePipe(ptr ptr ptr long) kernel32.CreatePipe
@ stdcall CreatePipe(ptr ptr ptr long)
# @ stub CreatePrivateNamespaceW
@ stdcall CreatePrivateObjectSecurity(ptr ptr ptr long long ptr)
@ stdcall CreatePrivateObjectSecurityEx(ptr ptr ptr ptr long long long ptr)
......@@ -639,7 +639,7 @@
@ stdcall GetProcessVersion(long) kernel32.GetProcessVersion
@ stdcall GetProcessWorkingSetSizeEx(long ptr ptr ptr)
# @ stub GetProcessorSystemCycleTime
@ stdcall GetProductInfo(long long long long ptr) kernel32.GetProductInfo
@ stdcall GetProductInfo(long long long long ptr)
@ stub GetPtrCalData
@ stub GetPtrCalDataArray
# @ stub GetPublisherCacheFolder
......@@ -864,8 +864,8 @@
@ stub IsNLSDefinedString
@ stdcall IsNormalizedString(long wstr long) kernel32.IsNormalizedString
# @ stub IsProcessCritical
@ stdcall IsProcessInJob(long long ptr) kernel32.IsProcessInJob
@ stdcall IsProcessorFeaturePresent(long) kernel32.IsProcessorFeaturePresent
@ stdcall IsProcessInJob(long long ptr)
@ stdcall IsProcessorFeaturePresent(long)
# @ stub IsSideloadingEnabled
# @ stub IsSideloadingPolicyApplied
# @ stub IsSyncForegroundPolicyRefresh
......
......@@ -259,6 +259,36 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetProcessWorkingSetSizeEx( HANDLE process, SIZE_T
}
/******************************************************************************
* IsProcessInJob (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH IsProcessInJob( HANDLE process, HANDLE job, BOOL *result )
{
NTSTATUS status = NtIsProcessInJob( process, job );
switch (status)
{
case STATUS_PROCESS_IN_JOB:
*result = TRUE;
return TRUE;
case STATUS_PROCESS_NOT_IN_JOB:
*result = FALSE;
return TRUE;
default:
return set_ntstatus( status );
}
}
/***********************************************************************
* IsProcessorFeaturePresent (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH IsProcessorFeaturePresent ( DWORD feature )
{
return RtlIsProcessorFeaturePresent( feature );
}
/**********************************************************************
* IsWow64Process (kernelbase.@)
*/
......
......@@ -1172,6 +1172,56 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateNamedPipeW( LPCWSTR name, DWORD open_mode,
}
/******************************************************************
* CreatePipe (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH CreatePipe( HANDLE *read_pipe, HANDLE *write_pipe,
SECURITY_ATTRIBUTES *sa, DWORD size )
{
static unsigned int index;
WCHAR name[64];
UNICODE_STRING nt_name;
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK iosb;
LARGE_INTEGER timeout;
*read_pipe = *write_pipe = INVALID_HANDLE_VALUE;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nt_name;
attr.Attributes = OBJ_CASE_INSENSITIVE | ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL;
if (!size) size = 4096;
timeout.QuadPart = (ULONGLONG)NMPWAIT_USE_DEFAULT_WAIT * -10000;
/* generate a unique pipe name (system wide) */
for (;;)
{
static const WCHAR fmtW[] = { '\\','?','?','\\','p','i','p','e','\\',
'W','i','n','3','2','.','P','i','p','e','s','.','%','0','8','l','u','.','%','0','8','u','\0' };
swprintf( name, ARRAY_SIZE(name), fmtW, GetCurrentProcessId(), ++index );
RtlInitUnicodeString( &nt_name, name );
if (!NtCreateNamedPipeFile( read_pipe, GENERIC_READ | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
&attr, &iosb, FILE_SHARE_WRITE, FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
FALSE, FALSE, FALSE, 1, size, size, &timeout ))
break;
}
if (!set_ntstatus( NtOpenFile( write_pipe, GENERIC_WRITE | FILE_READ_ATTRIBUTES | SYNCHRONIZE, &attr,
&iosb, 0, FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE )))
{
NtClose( *read_pipe );
return FALSE;
}
return TRUE;
}
/***********************************************************************
* DisconnectNamedPipe (kernelbase.@)
*/
......
......@@ -1340,6 +1340,16 @@ DWORD WINAPI VerFindFileW( DWORD flags, LPCWSTR filename, LPCWSTR win_dir, LPCWS
/***********************************************************************
* GetProductInfo (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetProductInfo( DWORD os_major, DWORD os_minor,
DWORD sp_major, DWORD sp_minor, DWORD *type )
{
return RtlGetProductInfo( os_major, os_minor, sp_major, sp_minor, type );
}
/***********************************************************************
* GetVersion (kernelbase.@)
*/
DWORD WINAPI GetVersion(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment