1998-11-01 15:00:21 +01:00
|
|
|
/*
|
|
|
|
* NT basis DLL
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1998-11-01 15:00:21 +01:00
|
|
|
* This file contains the Nt* API functions of NTDLL.DLL.
|
2000-12-13 22:28:15 +01:00
|
|
|
* In the original ntdll.dll they all seem to just call int 0x2e (down to the NTOSKRNL)
|
1998-11-01 15:00:21 +01:00
|
|
|
*
|
|
|
|
* Copyright 1996-1998 Marcus Meissner
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
|
|
|
|
2009-09-15 21:38:07 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
# include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SYSCTL_H
|
|
|
|
# include <sys/sysctl.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MACHINE_CPU_H
|
|
|
|
# include <machine/cpu.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MACH_MACHINE_H
|
|
|
|
# include <mach/machine.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-06-12 16:55:11 +02:00
|
|
|
#include <stdio.h>
|
1998-11-01 15:00:21 +01:00
|
|
|
#include <stdlib.h>
|
2009-09-15 21:38:07 +02:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
1998-11-01 15:00:21 +01:00
|
|
|
#include <time.h>
|
2005-11-28 17:32:54 +01:00
|
|
|
|
2007-09-18 00:39:43 +02:00
|
|
|
#define NONAMELESSUNION
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2005-06-16 11:44:39 +02:00
|
|
|
#include "wine/unicode.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
#include "ntdll_misc.h"
|
2001-07-19 02:39:09 +02:00
|
|
|
#include "wine/server.h"
|
2009-09-15 21:38:07 +02:00
|
|
|
#include "ddk/wdm.h"
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2008-10-17 22:25:30 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <mach/mach_init.h>
|
|
|
|
#include <mach/mach_host.h>
|
|
|
|
#include <mach/vm_map.h>
|
|
|
|
#endif
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2018-07-12 00:57:51 +02:00
|
|
|
#include "pshpack1.h"
|
|
|
|
|
|
|
|
struct smbios_prologue {
|
|
|
|
BYTE calling_method;
|
|
|
|
BYTE major_version;
|
|
|
|
BYTE minor_version;
|
|
|
|
BYTE revision;
|
|
|
|
DWORD length;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct smbios_bios {
|
|
|
|
BYTE type;
|
|
|
|
BYTE length;
|
|
|
|
WORD handle;
|
|
|
|
BYTE vendor;
|
|
|
|
BYTE version;
|
|
|
|
WORD start;
|
|
|
|
BYTE date;
|
|
|
|
BYTE size;
|
|
|
|
UINT64 characteristics;
|
|
|
|
};
|
|
|
|
|
2018-07-12 00:57:53 +02:00
|
|
|
struct smbios_system {
|
|
|
|
BYTE type;
|
|
|
|
BYTE length;
|
|
|
|
WORD handle;
|
|
|
|
BYTE vendor;
|
|
|
|
BYTE product;
|
|
|
|
BYTE version;
|
|
|
|
BYTE serial;
|
|
|
|
};
|
|
|
|
|
2018-07-12 00:57:54 +02:00
|
|
|
struct smbios_board {
|
|
|
|
BYTE type;
|
|
|
|
BYTE length;
|
|
|
|
WORD handle;
|
|
|
|
BYTE vendor;
|
|
|
|
BYTE product;
|
|
|
|
BYTE version;
|
|
|
|
BYTE serial;
|
|
|
|
};
|
|
|
|
|
2018-07-12 00:57:55 +02:00
|
|
|
struct smbios_chassis {
|
|
|
|
BYTE type;
|
|
|
|
BYTE length;
|
|
|
|
WORD handle;
|
|
|
|
BYTE vendor;
|
|
|
|
BYTE shape;
|
|
|
|
BYTE version;
|
|
|
|
BYTE serial;
|
|
|
|
BYTE asset_tag;
|
|
|
|
};
|
|
|
|
|
2018-07-12 00:57:51 +02:00
|
|
|
#include "poppack.h"
|
|
|
|
|
|
|
|
/* Firmware table providers */
|
|
|
|
#define ACPI 0x41435049
|
|
|
|
#define FIRM 0x4649524D
|
|
|
|
#define RSMB 0x52534D42
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* Token
|
|
|
|
*/
|
|
|
|
|
1998-11-01 15:00:21 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtDuplicateToken [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwDuplicateToken [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
1999-03-09 18:47:51 +01:00
|
|
|
NTSTATUS WINAPI NtDuplicateToken(
|
|
|
|
IN HANDLE ExistingToken,
|
|
|
|
IN ACCESS_MASK DesiredAccess,
|
|
|
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
|
|
|
IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
|
|
|
|
IN TOKEN_TYPE TokenType,
|
|
|
|
OUT PHANDLE NewToken)
|
1999-02-13 08:35:31 +01:00
|
|
|
{
|
2005-02-11 12:52:06 +01:00
|
|
|
NTSTATUS status;
|
2017-06-14 20:20:43 +02:00
|
|
|
data_size_t len;
|
|
|
|
struct object_attributes *objattr;
|
2005-02-11 12:52:06 +01:00
|
|
|
|
2009-02-16 11:46:44 +01:00
|
|
|
TRACE("(%p,0x%08x,%s,0x%08x,0x%08x,%p)\n",
|
|
|
|
ExistingToken, DesiredAccess, debugstr_ObjectAttributes(ObjectAttributes),
|
|
|
|
ImpersonationLevel, TokenType, NewToken);
|
2005-02-11 12:52:06 +01:00
|
|
|
|
2017-06-14 20:20:43 +02:00
|
|
|
if ((status = alloc_object_attributes( ObjectAttributes, &objattr, &len ))) return status;
|
|
|
|
|
2007-07-12 16:32:00 +02:00
|
|
|
if (ObjectAttributes && ObjectAttributes->SecurityQualityOfService)
|
|
|
|
{
|
|
|
|
SECURITY_QUALITY_OF_SERVICE *SecurityQOS = ObjectAttributes->SecurityQualityOfService;
|
|
|
|
TRACE("ObjectAttributes->SecurityQualityOfService = {%d, %d, %d, %s}\n",
|
|
|
|
SecurityQOS->Length, SecurityQOS->ImpersonationLevel,
|
|
|
|
SecurityQOS->ContextTrackingMode,
|
|
|
|
SecurityQOS->EffectiveOnly ? "TRUE" : "FALSE");
|
|
|
|
ImpersonationLevel = SecurityQOS->ImpersonationLevel;
|
|
|
|
}
|
|
|
|
|
2005-02-11 12:52:06 +01:00
|
|
|
SERVER_START_REQ( duplicate_token )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( ExistingToken );
|
2005-12-09 12:17:19 +01:00
|
|
|
req->access = DesiredAccess;
|
|
|
|
req->primary = (TokenType == TokenPrimary);
|
2005-02-11 12:52:06 +01:00
|
|
|
req->impersonation_level = ImpersonationLevel;
|
2017-06-14 20:20:43 +02:00
|
|
|
wine_server_add_data( req, objattr, len );
|
2005-02-11 12:52:06 +01:00
|
|
|
status = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!status) *NewToken = wine_server_ptr_handle( reply->new_handle );
|
2005-02-11 12:52:06 +01:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2017-06-14 20:20:43 +02:00
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, objattr );
|
2005-02-11 12:52:06 +01:00
|
|
|
return status;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtOpenProcessToken [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwOpenProcessToken [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
1999-03-09 18:47:51 +01:00
|
|
|
NTSTATUS WINAPI NtOpenProcessToken(
|
|
|
|
HANDLE ProcessHandle,
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD DesiredAccess,
|
|
|
|
HANDLE *TokenHandle)
|
2008-09-04 21:57:13 +02:00
|
|
|
{
|
|
|
|
return NtOpenProcessTokenEx( ProcessHandle, DesiredAccess, 0, TokenHandle );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtOpenProcessTokenEx [NTDLL.@]
|
|
|
|
* ZwOpenProcessTokenEx [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenProcessTokenEx( HANDLE process, DWORD access, DWORD attributes,
|
|
|
|
HANDLE *handle )
|
1999-02-13 08:35:31 +01:00
|
|
|
{
|
2003-07-24 02:07:00 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2008-09-04 21:57:13 +02:00
|
|
|
TRACE("(%p,0x%08x,0x%08x,%p)\n", process, access, attributes, handle);
|
2003-07-24 02:07:00 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( open_token )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( process );
|
2008-09-04 21:57:13 +02:00
|
|
|
req->access = access;
|
|
|
|
req->attributes = attributes;
|
2005-12-09 12:17:19 +01:00
|
|
|
req->flags = 0;
|
2003-07-24 02:07:00 +02:00
|
|
|
ret = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!ret) *handle = wine_server_ptr_handle( reply->token );
|
2003-07-24 02:07:00 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtOpenThreadToken [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwOpenThreadToken [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
1999-03-09 18:47:51 +01:00
|
|
|
NTSTATUS WINAPI NtOpenThreadToken(
|
|
|
|
HANDLE ThreadHandle,
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD DesiredAccess,
|
1999-03-09 18:47:51 +01:00
|
|
|
BOOLEAN OpenAsSelf,
|
2002-06-01 01:06:46 +02:00
|
|
|
HANDLE *TokenHandle)
|
2008-09-04 21:57:13 +02:00
|
|
|
{
|
|
|
|
return NtOpenThreadTokenEx( ThreadHandle, DesiredAccess, OpenAsSelf, 0, TokenHandle );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtOpenThreadTokenEx [NTDLL.@]
|
|
|
|
* ZwOpenThreadTokenEx [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtOpenThreadTokenEx( HANDLE thread, DWORD access, BOOLEAN as_self, DWORD attributes,
|
|
|
|
HANDLE *handle )
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2003-07-24 02:07:00 +02:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2008-09-04 21:57:13 +02:00
|
|
|
TRACE("(%p,0x%08x,%u,0x%08x,%p)\n", thread, access, as_self, attributes, handle );
|
2003-07-24 02:07:00 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( open_token )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( thread );
|
2008-09-04 21:57:13 +02:00
|
|
|
req->access = access;
|
|
|
|
req->attributes = attributes;
|
2005-12-09 12:17:19 +01:00
|
|
|
req->flags = OPEN_TOKEN_THREAD;
|
2008-09-04 21:57:13 +02:00
|
|
|
if (as_self) req->flags |= OPEN_TOKEN_AS_SELF;
|
2003-07-24 02:07:00 +02:00
|
|
|
ret = wine_server_call( req );
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!ret) *handle = wine_server_ptr_handle( reply->token );
|
2003-07-24 02:07:00 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
return ret;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtAdjustPrivilegesToken [NTDLL.@]
|
2004-08-30 20:36:24 +02:00
|
|
|
* ZwAdjustPrivilegesToken [NTDLL.@]
|
1999-02-13 08:35:31 +01:00
|
|
|
*
|
|
|
|
* FIXME: parameters unsafe
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtAdjustPrivilegesToken(
|
1999-02-26 12:11:13 +01:00
|
|
|
IN HANDLE TokenHandle,
|
1999-02-19 17:29:05 +01:00
|
|
|
IN BOOLEAN DisableAllPrivileges,
|
1999-02-13 08:35:31 +01:00
|
|
|
IN PTOKEN_PRIVILEGES NewState,
|
|
|
|
IN DWORD BufferLength,
|
|
|
|
OUT PTOKEN_PRIVILEGES PreviousState,
|
|
|
|
OUT PDWORD ReturnLength)
|
|
|
|
{
|
2005-02-11 12:52:06 +01:00
|
|
|
NTSTATUS ret;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,0x%08x,%p,0x%08x,%p,%p)\n",
|
2005-02-11 12:52:06 +01:00
|
|
|
TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
|
|
|
|
|
|
|
|
SERVER_START_REQ( adjust_token_privileges )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( TokenHandle );
|
2005-02-11 12:52:06 +01:00
|
|
|
req->disable_all = DisableAllPrivileges;
|
|
|
|
req->get_modified_state = (PreviousState != NULL);
|
|
|
|
if (!DisableAllPrivileges)
|
|
|
|
{
|
2008-07-11 11:41:42 +02:00
|
|
|
wine_server_add_data( req, NewState->Privileges,
|
2005-02-11 12:52:06 +01:00
|
|
|
NewState->PrivilegeCount * sizeof(NewState->Privileges[0]) );
|
|
|
|
}
|
|
|
|
if (PreviousState && BufferLength >= FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
|
2008-07-11 11:41:42 +02:00
|
|
|
wine_server_set_reply( req, PreviousState->Privileges,
|
2005-02-11 12:52:06 +01:00
|
|
|
BufferLength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
if (PreviousState)
|
|
|
|
{
|
2013-12-02 06:38:09 +01:00
|
|
|
if (ReturnLength) *ReturnLength = reply->len + FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges );
|
2005-02-11 12:52:06 +01:00
|
|
|
PreviousState->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
return ret;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtQueryInformationToken [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwQueryInformationToken [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
* NOTES
|
|
|
|
* Buffer for TokenUser:
|
|
|
|
* 0x00 TOKEN_USER the PSID field points to the SID
|
|
|
|
* 0x08 SID
|
|
|
|
*
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQueryInformationToken(
|
|
|
|
HANDLE token,
|
2006-01-12 13:32:09 +01:00
|
|
|
TOKEN_INFORMATION_CLASS tokeninfoclass,
|
|
|
|
PVOID tokeninfo,
|
|
|
|
ULONG tokeninfolength,
|
|
|
|
PULONG retlen )
|
1999-02-13 08:35:31 +01:00
|
|
|
{
|
2010-08-22 11:32:46 +02:00
|
|
|
static const ULONG info_len [] =
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
0, /* TokenUser */
|
|
|
|
0, /* TokenGroups */
|
|
|
|
0, /* TokenPrivileges */
|
|
|
|
0, /* TokenOwner */
|
|
|
|
0, /* TokenPrimaryGroup */
|
|
|
|
0, /* TokenDefaultDacl */
|
|
|
|
sizeof(TOKEN_SOURCE), /* TokenSource */
|
|
|
|
sizeof(TOKEN_TYPE), /* TokenType */
|
|
|
|
sizeof(SECURITY_IMPERSONATION_LEVEL), /* TokenImpersonationLevel */
|
|
|
|
sizeof(TOKEN_STATISTICS), /* TokenStatistics */
|
|
|
|
0, /* TokenRestrictedSids */
|
2011-08-08 23:27:22 +02:00
|
|
|
sizeof(DWORD), /* TokenSessionId */
|
2010-08-22 11:32:46 +02:00
|
|
|
0, /* TokenGroupsAndPrivileges */
|
|
|
|
0, /* TokenSessionReference */
|
|
|
|
0, /* TokenSandBoxInert */
|
|
|
|
0, /* TokenAuditPolicy */
|
|
|
|
0, /* TokenOrigin */
|
2010-11-14 19:04:55 +01:00
|
|
|
sizeof(TOKEN_ELEVATION_TYPE), /* TokenElevationType */
|
2010-08-22 11:32:46 +02:00
|
|
|
0, /* TokenLinkedToken */
|
|
|
|
sizeof(TOKEN_ELEVATION), /* TokenElevation */
|
|
|
|
0, /* TokenHasRestrictions */
|
|
|
|
0, /* TokenAccessInformation */
|
|
|
|
0, /* TokenVirtualizationAllowed */
|
2018-10-29 04:59:29 +01:00
|
|
|
sizeof(DWORD), /* TokenVirtualizationEnabled */
|
2012-07-30 18:08:34 +02:00
|
|
|
sizeof(TOKEN_MANDATORY_LABEL) + sizeof(SID), /* TokenIntegrityLevel [sizeof(SID) includes one SubAuthority] */
|
2010-08-22 11:32:46 +02:00
|
|
|
0, /* TokenUIAccess */
|
|
|
|
0, /* TokenMandatoryPolicy */
|
2014-05-31 02:08:45 +02:00
|
|
|
0, /* TokenLogonSid */
|
2016-11-15 21:21:35 +01:00
|
|
|
sizeof(DWORD), /* TokenIsAppContainer */
|
2014-05-31 02:08:45 +02:00
|
|
|
0, /* TokenCapabilities */
|
|
|
|
sizeof(TOKEN_APPCONTAINER_INFORMATION) + sizeof(SID), /* TokenAppContainerSid */
|
|
|
|
0, /* TokenAppContainerNumber */
|
|
|
|
0, /* TokenUserClaimAttributes*/
|
|
|
|
0, /* TokenDeviceClaimAttributes */
|
|
|
|
0, /* TokenRestrictedUserClaimAttributes */
|
|
|
|
0, /* TokenRestrictedDeviceClaimAttributes */
|
|
|
|
0, /* TokenDeviceGroups */
|
|
|
|
0, /* TokenRestrictedDeviceGroups */
|
|
|
|
0, /* TokenSecurityAttributes */
|
|
|
|
0, /* TokenIsRestricted */
|
|
|
|
0 /* TokenProcessTrustLevel */
|
2010-08-22 11:32:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
ULONG len = 0;
|
2005-02-11 12:52:06 +01:00
|
|
|
NTSTATUS status = STATUS_SUCCESS;
|
2000-11-01 22:38:09 +01:00
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%p,%d,%p,%d,%p)\n",
|
2000-11-01 22:38:09 +01:00
|
|
|
token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
|
|
|
|
|
2010-08-22 11:32:46 +02:00
|
|
|
if (tokeninfoclass < MaxTokenInfoClass)
|
|
|
|
len = info_len[tokeninfoclass];
|
1998-11-01 15:00:21 +01:00
|
|
|
|
2006-01-12 13:32:09 +01:00
|
|
|
if (retlen) *retlen = len;
|
2000-11-01 22:38:09 +01:00
|
|
|
|
|
|
|
if (tokeninfolength < len)
|
2003-10-06 23:04:06 +02:00
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
2000-11-01 22:38:09 +01:00
|
|
|
|
|
|
|
switch (tokeninfoclass)
|
|
|
|
{
|
|
|
|
case TokenUser:
|
2009-11-16 21:11:06 +01:00
|
|
|
SERVER_START_REQ( get_token_sid )
|
2000-11-01 22:38:09 +01:00
|
|
|
{
|
|
|
|
TOKEN_USER * tuser = tokeninfo;
|
2009-03-17 00:12:11 +01:00
|
|
|
PSID sid = tuser + 1;
|
2005-07-18 15:22:55 +02:00
|
|
|
DWORD sid_len = tokeninfolength < sizeof(TOKEN_USER) ? 0 : tokeninfolength - sizeof(TOKEN_USER);
|
|
|
|
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( token );
|
2009-11-16 21:11:06 +01:00
|
|
|
req->which_sid = tokeninfoclass;
|
2005-07-18 15:22:55 +02:00
|
|
|
wine_server_set_reply( req, sid, sid_len );
|
|
|
|
status = wine_server_call( req );
|
2009-11-16 21:11:06 +01:00
|
|
|
if (retlen) *retlen = reply->sid_len + sizeof(TOKEN_USER);
|
2005-07-18 15:22:55 +02:00
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
tuser->User.Sid = sid;
|
|
|
|
tuser->User.Attributes = 0;
|
|
|
|
}
|
2000-11-01 22:38:09 +01:00
|
|
|
}
|
2005-07-18 15:22:55 +02:00
|
|
|
SERVER_END_REQ;
|
2000-11-01 22:38:09 +01:00
|
|
|
break;
|
|
|
|
case TokenGroups:
|
2006-05-13 17:58:19 +02:00
|
|
|
{
|
2011-08-23 09:16:27 +02:00
|
|
|
void *buffer;
|
|
|
|
|
|
|
|
/* reply buffer is always shorter than output one */
|
|
|
|
buffer = tokeninfolength ? RtlAllocateHeap(GetProcessHeap(), 0, tokeninfolength) : NULL;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_token_groups )
|
2000-11-01 22:38:09 +01:00
|
|
|
{
|
2011-08-23 09:16:27 +02:00
|
|
|
TOKEN_GROUPS *groups = tokeninfo;
|
2009-02-12 09:09:17 +01:00
|
|
|
|
2011-08-23 09:16:27 +02:00
|
|
|
req->handle = wine_server_obj_handle( token );
|
|
|
|
wine_server_set_reply( req, buffer, tokeninfolength );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (status == STATUS_BUFFER_TOO_SMALL)
|
2006-05-13 17:58:19 +02:00
|
|
|
{
|
2011-08-23 09:16:27 +02:00
|
|
|
if (retlen) *retlen = reply->user_len;
|
|
|
|
}
|
|
|
|
else if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
struct token_groups *tg = buffer;
|
|
|
|
unsigned int *attr = (unsigned int *)(tg + 1);
|
|
|
|
ULONG i;
|
|
|
|
const int non_sid_portion = (sizeof(struct token_groups) + tg->count * sizeof(unsigned int));
|
|
|
|
SID *sids = (SID *)((char *)tokeninfo + FIELD_OFFSET( TOKEN_GROUPS, Groups[tg->count] ));
|
2000-11-01 22:38:09 +01:00
|
|
|
|
2011-08-23 09:16:27 +02:00
|
|
|
if (retlen) *retlen = reply->user_len;
|
|
|
|
|
|
|
|
groups->GroupCount = tg->count;
|
|
|
|
memcpy( sids, (char *)buffer + non_sid_portion,
|
2011-10-10 19:07:30 +02:00
|
|
|
reply->user_len - FIELD_OFFSET( TOKEN_GROUPS, Groups[tg->count] ));
|
2011-08-23 09:16:27 +02:00
|
|
|
|
|
|
|
for (i = 0; i < tg->count; i++)
|
2006-05-13 17:58:19 +02:00
|
|
|
{
|
2011-08-23 09:16:27 +02:00
|
|
|
groups->Groups[i].Attributes = attr[i];
|
|
|
|
groups->Groups[i].Sid = sids;
|
|
|
|
sids = (SID *)((char *)sids + RtlLengthSid(sids));
|
2006-05-13 17:58:19 +02:00
|
|
|
}
|
2011-08-23 09:16:27 +02:00
|
|
|
}
|
|
|
|
else if (retlen) *retlen = 0;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
RtlFreeHeap(GetProcessHeap(), 0, buffer);
|
2000-11-01 22:38:09 +01:00
|
|
|
break;
|
2006-05-13 17:58:19 +02:00
|
|
|
}
|
2004-08-18 00:28:13 +02:00
|
|
|
case TokenPrimaryGroup:
|
2009-11-16 21:11:06 +01:00
|
|
|
SERVER_START_REQ( get_token_sid )
|
2004-08-18 00:28:13 +02:00
|
|
|
{
|
|
|
|
TOKEN_PRIMARY_GROUP *tgroup = tokeninfo;
|
2009-11-16 21:11:06 +01:00
|
|
|
PSID sid = tgroup + 1;
|
|
|
|
DWORD sid_len = tokeninfolength < sizeof(TOKEN_PRIMARY_GROUP) ? 0 : tokeninfolength - sizeof(TOKEN_PRIMARY_GROUP);
|
|
|
|
|
|
|
|
req->handle = wine_server_obj_handle( token );
|
|
|
|
req->which_sid = tokeninfoclass;
|
|
|
|
wine_server_set_reply( req, sid, sid_len );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (retlen) *retlen = reply->sid_len + sizeof(TOKEN_PRIMARY_GROUP);
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
tgroup->PrimaryGroup = sid;
|
2004-08-18 00:28:13 +02:00
|
|
|
}
|
2009-11-16 21:11:06 +01:00
|
|
|
SERVER_END_REQ;
|
2004-08-18 00:28:13 +02:00
|
|
|
break;
|
2000-11-01 22:38:09 +01:00
|
|
|
case TokenPrivileges:
|
2005-02-11 12:52:06 +01:00
|
|
|
SERVER_START_REQ( get_token_privileges )
|
2000-11-01 22:38:09 +01:00
|
|
|
{
|
|
|
|
TOKEN_PRIVILEGES *tpriv = tokeninfo;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( token );
|
2005-02-11 12:52:06 +01:00
|
|
|
if (tpriv && tokeninfolength > FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ))
|
2008-07-11 11:41:42 +02:00
|
|
|
wine_server_set_reply( req, tpriv->Privileges, tokeninfolength - FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) );
|
2005-02-11 12:52:06 +01:00
|
|
|
status = wine_server_call( req );
|
2006-01-12 13:32:09 +01:00
|
|
|
if (retlen) *retlen = FIELD_OFFSET( TOKEN_PRIVILEGES, Privileges ) + reply->len;
|
2005-02-11 12:52:06 +01:00
|
|
|
if (tpriv) tpriv->PrivilegeCount = reply->len / sizeof(LUID_AND_ATTRIBUTES);
|
2000-11-01 22:38:09 +01:00
|
|
|
}
|
2005-02-11 12:52:06 +01:00
|
|
|
SERVER_END_REQ;
|
2000-11-01 22:38:09 +01:00
|
|
|
break;
|
2003-12-30 20:17:05 +01:00
|
|
|
case TokenOwner:
|
2009-11-16 21:11:06 +01:00
|
|
|
SERVER_START_REQ( get_token_sid )
|
2003-12-30 20:17:05 +01:00
|
|
|
{
|
2009-11-16 21:11:06 +01:00
|
|
|
TOKEN_OWNER *towner = tokeninfo;
|
|
|
|
PSID sid = towner + 1;
|
|
|
|
DWORD sid_len = tokeninfolength < sizeof(TOKEN_OWNER) ? 0 : tokeninfolength - sizeof(TOKEN_OWNER);
|
|
|
|
|
|
|
|
req->handle = wine_server_obj_handle( token );
|
|
|
|
req->which_sid = tokeninfoclass;
|
|
|
|
wine_server_set_reply( req, sid, sid_len );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (retlen) *retlen = reply->sid_len + sizeof(TOKEN_OWNER);
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
towner->Owner = sid;
|
2003-12-30 20:17:05 +01:00
|
|
|
}
|
2009-11-16 21:11:06 +01:00
|
|
|
SERVER_END_REQ;
|
2003-12-30 20:17:05 +01:00
|
|
|
break;
|
2007-02-21 18:10:45 +01:00
|
|
|
case TokenImpersonationLevel:
|
|
|
|
SERVER_START_REQ( get_token_impersonation_level )
|
|
|
|
{
|
|
|
|
SECURITY_IMPERSONATION_LEVEL *impersonation_level = tokeninfo;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( token );
|
2007-02-21 18:10:45 +01:00
|
|
|
status = wine_server_call( req );
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
*impersonation_level = reply->impersonation_level;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
break;
|
2007-09-13 17:47:56 +02:00
|
|
|
case TokenStatistics:
|
|
|
|
SERVER_START_REQ( get_token_statistics )
|
|
|
|
{
|
|
|
|
TOKEN_STATISTICS *statistics = tokeninfo;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( token );
|
2007-09-13 17:47:56 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
statistics->TokenId.LowPart = reply->token_id.low_part;
|
|
|
|
statistics->TokenId.HighPart = reply->token_id.high_part;
|
|
|
|
statistics->AuthenticationId.LowPart = 0; /* FIXME */
|
|
|
|
statistics->AuthenticationId.HighPart = 0; /* FIXME */
|
2007-09-18 00:39:43 +02:00
|
|
|
statistics->ExpirationTime.u.HighPart = 0x7fffffff;
|
|
|
|
statistics->ExpirationTime.u.LowPart = 0xffffffff;
|
2007-09-13 17:47:56 +02:00
|
|
|
statistics->TokenType = reply->primary ? TokenPrimary : TokenImpersonation;
|
|
|
|
statistics->ImpersonationLevel = reply->impersonation_level;
|
|
|
|
|
|
|
|
/* kernel information not relevant to us */
|
|
|
|
statistics->DynamicCharged = 0;
|
|
|
|
statistics->DynamicAvailable = 0;
|
|
|
|
|
|
|
|
statistics->GroupCount = reply->group_count;
|
|
|
|
statistics->PrivilegeCount = reply->privilege_count;
|
|
|
|
statistics->ModifiedId.LowPart = reply->modified_id.low_part;
|
|
|
|
statistics->ModifiedId.HighPart = reply->modified_id.high_part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
break;
|
|
|
|
case TokenType:
|
|
|
|
SERVER_START_REQ( get_token_statistics )
|
|
|
|
{
|
|
|
|
TOKEN_TYPE *token_type = tokeninfo;
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( token );
|
2007-09-13 17:47:56 +02:00
|
|
|
status = wine_server_call( req );
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
*token_type = reply->primary ? TokenPrimary : TokenImpersonation;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
break;
|
2009-04-21 09:53:49 +02:00
|
|
|
case TokenDefaultDacl:
|
|
|
|
SERVER_START_REQ( get_token_default_dacl )
|
|
|
|
{
|
|
|
|
TOKEN_DEFAULT_DACL *default_dacl = tokeninfo;
|
|
|
|
ACL *acl = (ACL *)(default_dacl + 1);
|
|
|
|
DWORD acl_len;
|
|
|
|
|
|
|
|
if (tokeninfolength < sizeof(TOKEN_DEFAULT_DACL)) acl_len = 0;
|
|
|
|
else acl_len = tokeninfolength - sizeof(TOKEN_DEFAULT_DACL);
|
|
|
|
|
|
|
|
req->handle = wine_server_obj_handle( token );
|
|
|
|
wine_server_set_reply( req, acl, acl_len );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
|
|
|
|
if (retlen) *retlen = reply->acl_len + sizeof(TOKEN_DEFAULT_DACL);
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
if (reply->acl_len)
|
|
|
|
default_dacl->DefaultDacl = acl;
|
|
|
|
else
|
|
|
|
default_dacl->DefaultDacl = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
break;
|
2010-11-14 19:04:55 +01:00
|
|
|
case TokenElevationType:
|
|
|
|
{
|
|
|
|
TOKEN_ELEVATION_TYPE *elevation_type = tokeninfo;
|
|
|
|
FIXME("QueryInformationToken( ..., TokenElevationType, ...) semi-stub\n");
|
|
|
|
*elevation_type = TokenElevationTypeFull;
|
|
|
|
}
|
|
|
|
break;
|
2010-08-22 11:32:46 +02:00
|
|
|
case TokenElevation:
|
|
|
|
{
|
|
|
|
TOKEN_ELEVATION *elevation = tokeninfo;
|
|
|
|
FIXME("QueryInformationToken( ..., TokenElevation, ...) semi-stub\n");
|
|
|
|
elevation->TokenIsElevated = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2011-08-08 23:27:22 +02:00
|
|
|
case TokenSessionId:
|
|
|
|
{
|
|
|
|
*((DWORD*)tokeninfo) = 0;
|
|
|
|
FIXME("QueryInformationToken( ..., TokenSessionId, ...) semi-stub\n");
|
|
|
|
}
|
|
|
|
break;
|
2018-10-29 04:59:29 +01:00
|
|
|
case TokenVirtualizationEnabled:
|
|
|
|
{
|
|
|
|
*(DWORD *)tokeninfo = 0;
|
|
|
|
TRACE("QueryInformationToken( ..., TokenVirtualizationEnabled, ...) semi-stub\n");
|
|
|
|
}
|
|
|
|
break;
|
2012-07-30 18:08:34 +02:00
|
|
|
case TokenIntegrityLevel:
|
|
|
|
{
|
|
|
|
/* report always "S-1-16-12288" (high mandatory level) for now */
|
|
|
|
static const SID high_level = {SID_REVISION, 1, {SECURITY_MANDATORY_LABEL_AUTHORITY},
|
|
|
|
{SECURITY_MANDATORY_HIGH_RID}};
|
|
|
|
|
|
|
|
TOKEN_MANDATORY_LABEL *tml = tokeninfo;
|
|
|
|
PSID psid = tml + 1;
|
|
|
|
|
|
|
|
tml->Label.Sid = psid;
|
|
|
|
tml->Label.Attributes = SE_GROUP_INTEGRITY | SE_GROUP_INTEGRITY_ENABLED;
|
|
|
|
memcpy(psid, &high_level, sizeof(SID));
|
|
|
|
}
|
|
|
|
break;
|
2014-05-31 02:08:45 +02:00
|
|
|
case TokenAppContainerSid:
|
|
|
|
{
|
|
|
|
TOKEN_APPCONTAINER_INFORMATION *container = tokeninfo;
|
|
|
|
FIXME("QueryInformationToken( ..., TokenAppContainerSid, ...) semi-stub\n");
|
|
|
|
container->TokenAppContainer = NULL;
|
|
|
|
}
|
|
|
|
break;
|
2016-11-15 21:21:35 +01:00
|
|
|
case TokenIsAppContainer:
|
|
|
|
{
|
|
|
|
TRACE("TokenIsAppContainer semi-stub\n");
|
|
|
|
*(DWORD*)tokeninfo = 0;
|
|
|
|
break;
|
|
|
|
}
|
2018-02-06 05:19:37 +01:00
|
|
|
case TokenLogonSid:
|
|
|
|
SERVER_START_REQ( get_token_sid )
|
|
|
|
{
|
|
|
|
TOKEN_GROUPS * groups = tokeninfo;
|
|
|
|
PSID sid = groups + 1;
|
|
|
|
DWORD sid_len = tokeninfolength < sizeof(TOKEN_GROUPS) ? 0 : tokeninfolength - sizeof(TOKEN_GROUPS);
|
|
|
|
|
|
|
|
req->handle = wine_server_obj_handle( token );
|
|
|
|
req->which_sid = tokeninfoclass;
|
|
|
|
wine_server_set_reply( req, sid, sid_len );
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (retlen) *retlen = reply->sid_len + sizeof(TOKEN_GROUPS);
|
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
groups->GroupCount = 1;
|
|
|
|
groups->Groups[0].Sid = sid;
|
|
|
|
groups->Groups[0].Attributes = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
break;
|
2004-07-06 21:42:30 +02:00
|
|
|
default:
|
|
|
|
{
|
2006-01-12 13:32:09 +01:00
|
|
|
ERR("Unhandled Token Information class %d!\n", tokeninfoclass);
|
2004-07-06 21:42:30 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2000-11-01 22:38:09 +01:00
|
|
|
}
|
2005-02-11 12:52:06 +01:00
|
|
|
return status;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
2004-08-18 00:09:55 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtSetInformationToken [NTDLL.@]
|
|
|
|
* ZwSetInformationToken [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetInformationToken(
|
|
|
|
HANDLE TokenHandle,
|
|
|
|
TOKEN_INFORMATION_CLASS TokenInformationClass,
|
|
|
|
PVOID TokenInformation,
|
|
|
|
ULONG TokenInformationLength)
|
|
|
|
{
|
2009-04-21 09:53:49 +02:00
|
|
|
NTSTATUS ret = STATUS_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
TRACE("%p %d %p %u\n", TokenHandle, TokenInformationClass,
|
|
|
|
TokenInformation, TokenInformationLength);
|
|
|
|
|
|
|
|
switch (TokenInformationClass)
|
|
|
|
{
|
|
|
|
case TokenDefaultDacl:
|
|
|
|
if (TokenInformationLength < sizeof(TOKEN_DEFAULT_DACL))
|
|
|
|
{
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!TokenInformation)
|
|
|
|
{
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SERVER_START_REQ( set_token_default_dacl )
|
|
|
|
{
|
|
|
|
ACL *acl = ((TOKEN_DEFAULT_DACL *)TokenInformation)->DefaultDacl;
|
|
|
|
WORD size;
|
|
|
|
|
|
|
|
if (acl) size = acl->AclSize;
|
|
|
|
else size = 0;
|
|
|
|
|
|
|
|
req->handle = wine_server_obj_handle( TokenHandle );
|
|
|
|
wine_server_add_data( req, acl, size );
|
|
|
|
ret = wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
break;
|
2018-05-18 06:51:00 +02:00
|
|
|
case TokenSessionId:
|
|
|
|
if (TokenInformationLength < sizeof(DWORD))
|
|
|
|
{
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!TokenInformation)
|
|
|
|
{
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
FIXME("TokenSessionId stub!\n");
|
2018-05-18 06:51:01 +02:00
|
|
|
ret = STATUS_SUCCESS;
|
|
|
|
break;
|
|
|
|
case TokenIntegrityLevel:
|
|
|
|
FIXME("TokenIntegrityLevel stub!\n");
|
2018-05-18 06:51:00 +02:00
|
|
|
ret = STATUS_SUCCESS;
|
|
|
|
break;
|
2009-04-21 09:53:49 +02:00
|
|
|
default:
|
|
|
|
FIXME("unimplemented class %u\n", TokenInformationClass);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2004-08-18 00:09:55 +02:00
|
|
|
}
|
|
|
|
|
2004-08-30 20:36:24 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtAdjustGroupsToken [NTDLL.@]
|
|
|
|
* ZwAdjustGroupsToken [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtAdjustGroupsToken(
|
|
|
|
HANDLE TokenHandle,
|
|
|
|
BOOLEAN ResetToDefault,
|
|
|
|
PTOKEN_GROUPS NewState,
|
|
|
|
ULONG BufferLength,
|
|
|
|
PTOKEN_GROUPS PreviousState,
|
|
|
|
PULONG ReturnLength)
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("%p %d %p %u %p %p\n", TokenHandle, ResetToDefault,
|
2004-08-30 20:36:24 +02:00
|
|
|
NewState, BufferLength, PreviousState, ReturnLength);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-04-22 23:17:15 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtPrivilegeCheck [NTDLL.@]
|
|
|
|
* ZwPrivilegeCheck [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtPrivilegeCheck(
|
|
|
|
HANDLE ClientToken,
|
|
|
|
PPRIVILEGE_SET RequiredPrivileges,
|
|
|
|
PBOOLEAN Result)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
SERVER_START_REQ( check_token_privileges )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( ClientToken );
|
2012-08-09 09:32:54 +02:00
|
|
|
req->all_required = (RequiredPrivileges->Control & PRIVILEGE_SET_ALL_NECESSARY) != 0;
|
2008-07-11 11:41:42 +02:00
|
|
|
wine_server_add_data( req, RequiredPrivileges->Privilege,
|
2005-04-22 23:17:15 +02:00
|
|
|
RequiredPrivileges->PrivilegeCount * sizeof(RequiredPrivileges->Privilege[0]) );
|
2008-07-11 11:41:42 +02:00
|
|
|
wine_server_set_reply( req, RequiredPrivileges->Privilege,
|
2005-04-22 23:17:15 +02:00
|
|
|
RequiredPrivileges->PrivilegeCount * sizeof(RequiredPrivileges->Privilege[0]) );
|
|
|
|
|
|
|
|
status = wine_server_call( req );
|
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
2012-08-09 09:32:54 +02:00
|
|
|
*Result = reply->has_privileges != 0;
|
2005-04-22 23:17:15 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* ports
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtCreatePort [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwCreatePort [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
2002-12-10 21:04:40 +01:00
|
|
|
NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
|
2005-06-13 12:03:18 +02:00
|
|
|
ULONG MaxConnectInfoLength,ULONG MaxDataLength,PULONG reserved)
|
1999-02-13 08:35:31 +01:00
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%p,%p,%u,%u,%p),stub!\n",PortHandle,ObjectAttributes,
|
2005-06-13 12:03:18 +02:00
|
|
|
MaxConnectInfoLength,MaxDataLength,reserved);
|
2006-05-10 04:18:07 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtConnectPort [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwConnectPort [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
2005-06-14 13:43:20 +02:00
|
|
|
NTSTATUS WINAPI NtConnectPort(
|
|
|
|
PHANDLE PortHandle,
|
|
|
|
PUNICODE_STRING PortName,
|
|
|
|
PSECURITY_QUALITY_OF_SERVICE SecurityQos,
|
|
|
|
PLPC_SECTION_WRITE WriteSection,
|
|
|
|
PLPC_SECTION_READ ReadSection,
|
|
|
|
PULONG MaximumMessageLength,
|
|
|
|
PVOID ConnectInfo,
|
|
|
|
PULONG pConnectInfoLength)
|
1999-02-13 08:35:31 +01:00
|
|
|
{
|
2005-06-14 13:43:20 +02:00
|
|
|
FIXME("(%p,%s,%p,%p,%p,%p,%p,%p),stub!\n",
|
|
|
|
PortHandle,debugstr_w(PortName->Buffer),SecurityQos,
|
|
|
|
WriteSection,ReadSection,MaximumMessageLength,ConnectInfo,
|
|
|
|
pConnectInfoLength);
|
|
|
|
if (ConnectInfo && pConnectInfoLength)
|
|
|
|
TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength));
|
2006-05-10 04:18:07 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
2009-06-01 09:40:37 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtSecureConnectPort (NTDLL.@)
|
|
|
|
* ZwSecureConnectPort (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSecureConnectPort(
|
|
|
|
PHANDLE PortHandle,
|
|
|
|
PUNICODE_STRING PortName,
|
|
|
|
PSECURITY_QUALITY_OF_SERVICE SecurityQos,
|
|
|
|
PLPC_SECTION_WRITE WriteSection,
|
|
|
|
PSID pSid,
|
|
|
|
PLPC_SECTION_READ ReadSection,
|
|
|
|
PULONG MaximumMessageLength,
|
|
|
|
PVOID ConnectInfo,
|
|
|
|
PULONG pConnectInfoLength)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%s,%p,%p,%p,%p,%p,%p,%p),stub!\n",
|
|
|
|
PortHandle,debugstr_w(PortName->Buffer),SecurityQos,
|
|
|
|
WriteSection,pSid,ReadSection,MaximumMessageLength,ConnectInfo,
|
|
|
|
pConnectInfoLength);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1998-11-01 15:00:21 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtListenPort [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwListenPort [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
2005-06-14 13:43:20 +02:00
|
|
|
NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPC_MESSAGE pLpcMessage)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2002-12-10 21:04:40 +01:00
|
|
|
FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
|
2006-05-10 04:18:07 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtAcceptConnectPort [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwAcceptConnectPort [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
2005-06-14 13:43:20 +02:00
|
|
|
NTSTATUS WINAPI NtAcceptConnectPort(
|
|
|
|
PHANDLE PortHandle,
|
|
|
|
ULONG PortIdentifier,
|
|
|
|
PLPC_MESSAGE pLpcMessage,
|
|
|
|
BOOLEAN Accept,
|
|
|
|
PLPC_SECTION_WRITE WriteSection,
|
|
|
|
PLPC_SECTION_READ ReadSection)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%p,%u,%p,%d,%p,%p),stub!\n",
|
2005-06-14 13:43:20 +02:00
|
|
|
PortHandle,PortIdentifier,pLpcMessage,Accept,WriteSection,ReadSection);
|
2006-05-10 04:18:07 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtCompleteConnectPort [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwCompleteConnectPort [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
2002-12-10 21:04:40 +01:00
|
|
|
NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2002-12-10 21:04:40 +01:00
|
|
|
FIXME("(%p),stub!\n",PortHandle);
|
2006-05-10 04:18:07 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtRegisterThreadTerminatePort [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwRegisterThreadTerminatePort [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
2002-12-10 21:04:40 +01:00
|
|
|
NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2002-12-10 21:04:40 +01:00
|
|
|
FIXME("(%p),stub!\n",PortHandle);
|
2006-05-10 04:18:07 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtRequestWaitReplyPort [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwRequestWaitReplyPort [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
2005-06-14 13:43:20 +02:00
|
|
|
NTSTATUS WINAPI NtRequestWaitReplyPort(
|
|
|
|
HANDLE PortHandle,
|
|
|
|
PLPC_MESSAGE pLpcMessageIn,
|
|
|
|
PLPC_MESSAGE pLpcMessageOut)
|
1999-02-13 08:35:31 +01:00
|
|
|
{
|
2002-12-10 21:04:40 +01:00
|
|
|
FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
|
|
|
|
if(pLpcMessageIn)
|
|
|
|
{
|
|
|
|
TRACE("Message to send:\n");
|
2005-06-14 13:43:20 +02:00
|
|
|
TRACE("\tDataSize = %u\n",pLpcMessageIn->DataSize);
|
|
|
|
TRACE("\tMessageSize = %u\n",pLpcMessageIn->MessageSize);
|
|
|
|
TRACE("\tMessageType = %u\n",pLpcMessageIn->MessageType);
|
|
|
|
TRACE("\tVirtualRangesOffset = %u\n",pLpcMessageIn->VirtualRangesOffset);
|
|
|
|
TRACE("\tClientId.UniqueProcess = %p\n",pLpcMessageIn->ClientId.UniqueProcess);
|
|
|
|
TRACE("\tClientId.UniqueThread = %p\n",pLpcMessageIn->ClientId.UniqueThread);
|
2009-05-07 13:42:39 +02:00
|
|
|
TRACE("\tMessageId = %lu\n",pLpcMessageIn->MessageId);
|
|
|
|
TRACE("\tSectionSize = %lu\n",pLpcMessageIn->SectionSize);
|
2005-06-14 13:43:20 +02:00
|
|
|
TRACE("\tData = %s\n",
|
2005-09-02 16:47:36 +02:00
|
|
|
debugstr_an((const char*)pLpcMessageIn->Data,pLpcMessageIn->DataSize));
|
2002-12-10 21:04:40 +01:00
|
|
|
}
|
2006-05-10 04:18:07 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtReplyWaitReceivePort [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwReplyWaitReceivePort [NTDLL.@]
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
2005-06-14 13:43:20 +02:00
|
|
|
NTSTATUS WINAPI NtReplyWaitReceivePort(
|
|
|
|
HANDLE PortHandle,
|
|
|
|
PULONG PortIdentifier,
|
|
|
|
PLPC_MESSAGE ReplyMessage,
|
|
|
|
PLPC_MESSAGE Message)
|
1999-03-09 18:47:51 +01:00
|
|
|
{
|
2005-06-14 13:43:20 +02:00
|
|
|
FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,PortIdentifier,ReplyMessage,Message);
|
2006-05-10 04:18:07 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
|
|
|
|
1999-03-09 18:47:51 +01:00
|
|
|
/*
|
|
|
|
* Misc
|
1998-11-01 15:00:21 +01:00
|
|
|
*/
|
1999-03-09 18:47:51 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtSetIntervalProfile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwSetIntervalProfile [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*/
|
2005-06-16 12:46:11 +02:00
|
|
|
NTSTATUS WINAPI NtSetIntervalProfile(
|
|
|
|
ULONG Interval,
|
|
|
|
KPROFILE_SOURCE Source)
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("%u,%d\n", Interval, Source);
|
2005-06-16 12:46:11 +02:00
|
|
|
return STATUS_SUCCESS;
|
1998-11-01 15:00:21 +01:00
|
|
|
}
|
1999-03-09 18:47:51 +01:00
|
|
|
|
2019-02-14 19:41:34 +01:00
|
|
|
SYSTEM_CPU_INFORMATION cpu_info = { 0 };
|
2009-09-15 21:38:07 +02:00
|
|
|
|
2012-10-22 23:22:51 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Architecture specific feature detection for CPUs
|
|
|
|
*
|
|
|
|
* This a set of mutually exclusive #if define()s each providing its own get_cpuinfo() to be called
|
|
|
|
* from fill_cpu_info();
|
|
|
|
*/
|
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
|
2009-09-15 21:38:07 +02:00
|
|
|
#define AUTH 0x68747541 /* "Auth" */
|
|
|
|
#define ENTI 0x69746e65 /* "enti" */
|
|
|
|
#define CAMD 0x444d4163 /* "cAMD" */
|
|
|
|
|
2012-10-21 02:40:44 +02:00
|
|
|
#define GENU 0x756e6547 /* "Genu" */
|
|
|
|
#define INEI 0x49656e69 /* "ineI" */
|
|
|
|
#define NTEL 0x6c65746e /* "ntel" */
|
|
|
|
|
2018-11-26 17:00:05 +01:00
|
|
|
extern void do_cpuid(unsigned int ax, unsigned int *p);
|
|
|
|
|
2009-09-15 21:38:07 +02:00
|
|
|
#ifdef __i386__
|
2018-11-26 17:00:05 +01:00
|
|
|
__ASM_GLOBAL_FUNC( do_cpuid,
|
|
|
|
"pushl %esi\n\t"
|
|
|
|
"pushl %ebx\n\t"
|
|
|
|
"movl 12(%esp),%eax\n\t"
|
|
|
|
"movl 16(%esp),%esi\n\t"
|
|
|
|
"cpuid\n\t"
|
|
|
|
"movl %eax,(%esi)\n\t"
|
|
|
|
"movl %ebx,4(%esi)\n\t"
|
|
|
|
"movl %ecx,8(%esi)\n\t"
|
|
|
|
"movl %edx,12(%esi)\n\t"
|
|
|
|
"popl %ebx\n\t"
|
|
|
|
"popl %esi\n\t"
|
|
|
|
"ret" )
|
|
|
|
#else
|
|
|
|
__ASM_GLOBAL_FUNC( do_cpuid,
|
|
|
|
"pushq %rbx\n\t"
|
|
|
|
"movl %edi,%eax\n\t"
|
|
|
|
"cpuid\n\t"
|
|
|
|
"movl %eax,(%rsi)\n\t"
|
|
|
|
"movl %ebx,4(%rsi)\n\t"
|
|
|
|
"movl %ecx,8(%rsi)\n\t"
|
|
|
|
"movl %edx,12(%rsi)\n\t"
|
|
|
|
"popq %rbx\n\t"
|
|
|
|
"ret" )
|
2009-09-15 21:38:07 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __i386__
|
2018-11-26 17:00:06 +01:00
|
|
|
extern int have_cpuid(void);
|
|
|
|
__ASM_GLOBAL_FUNC( have_cpuid,
|
|
|
|
"pushfl\n\t"
|
|
|
|
"pushfl\n\t"
|
|
|
|
"movl (%esp),%ecx\n\t"
|
|
|
|
"xorl $0x00200000,(%esp)\n\t"
|
|
|
|
"popfl\n\t"
|
|
|
|
"pushfl\n\t"
|
|
|
|
"popl %eax\n\t"
|
|
|
|
"popfl\n\t"
|
|
|
|
"xorl %ecx,%eax\n\t"
|
|
|
|
"andl $0x00200000,%eax\n\t"
|
|
|
|
"ret" )
|
2009-09-15 21:38:07 +02:00
|
|
|
#else
|
2018-11-26 17:00:06 +01:00
|
|
|
static int have_cpuid(void)
|
|
|
|
{
|
|
|
|
return 1;
|
2009-09-15 21:38:07 +02:00
|
|
|
}
|
2018-11-26 17:00:06 +01:00
|
|
|
#endif
|
2009-09-15 21:38:07 +02:00
|
|
|
|
2012-10-21 02:40:47 +02:00
|
|
|
/* Detect if a SSE2 processor is capable of Denormals Are Zero (DAZ) mode.
|
|
|
|
*
|
|
|
|
* This function assumes you have already checked for SSE2/FXSAVE support. */
|
2013-11-02 14:34:13 +01:00
|
|
|
static inline BOOL have_sse_daz_mode(void)
|
2012-10-21 02:40:47 +02:00
|
|
|
{
|
|
|
|
#ifdef __i386__
|
|
|
|
typedef struct DECLSPEC_ALIGN(16) _M128A {
|
|
|
|
ULONGLONG Low;
|
|
|
|
LONGLONG High;
|
|
|
|
} M128A;
|
|
|
|
|
|
|
|
typedef struct _XMM_SAVE_AREA32 {
|
|
|
|
WORD ControlWord;
|
|
|
|
WORD StatusWord;
|
|
|
|
BYTE TagWord;
|
|
|
|
BYTE Reserved1;
|
|
|
|
WORD ErrorOpcode;
|
|
|
|
DWORD ErrorOffset;
|
|
|
|
WORD ErrorSelector;
|
|
|
|
WORD Reserved2;
|
|
|
|
DWORD DataOffset;
|
|
|
|
WORD DataSelector;
|
|
|
|
WORD Reserved3;
|
|
|
|
DWORD MxCsr;
|
|
|
|
DWORD MxCsr_Mask;
|
|
|
|
M128A FloatRegisters[8];
|
|
|
|
M128A XmmRegisters[16];
|
|
|
|
BYTE Reserved4[96];
|
|
|
|
} XMM_SAVE_AREA32;
|
|
|
|
|
|
|
|
/* Intel says we need a zeroed 16-byte aligned buffer */
|
|
|
|
char buffer[512 + 16];
|
|
|
|
XMM_SAVE_AREA32 *state = (XMM_SAVE_AREA32 *)(((ULONG_PTR)buffer + 15) & ~15);
|
|
|
|
memset(buffer, 0, sizeof(buffer));
|
|
|
|
|
|
|
|
__asm__ __volatile__( "fxsave %0" : "=m" (*state) : "m" (*state) );
|
|
|
|
|
|
|
|
return (state->MxCsr_Mask & (1 << 6)) >> 6;
|
|
|
|
#else /* all x86_64 processors include SSE2 with DAZ mode */
|
2013-11-02 14:34:13 +01:00
|
|
|
return TRUE;
|
2012-10-21 02:40:47 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-09-15 21:38:07 +02:00
|
|
|
static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
|
|
|
|
{
|
|
|
|
unsigned int regs[4], regs2[4];
|
|
|
|
|
2012-10-22 23:22:51 +02:00
|
|
|
#if defined(__i386__)
|
|
|
|
info->Architecture = PROCESSOR_ARCHITECTURE_INTEL;
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
info->Architecture = PROCESSOR_ARCHITECTURE_AMD64;
|
|
|
|
#endif
|
|
|
|
|
2012-10-21 02:40:44 +02:00
|
|
|
/* We're at least a 386 */
|
|
|
|
info->FeatureSet = CPU_FEATURE_VME | CPU_FEATURE_X86 | CPU_FEATURE_PGE;
|
|
|
|
info->Level = 3;
|
|
|
|
|
2009-09-15 21:38:07 +02:00
|
|
|
if (!have_cpuid()) return;
|
|
|
|
|
|
|
|
do_cpuid(0x00000000, regs); /* get standard cpuid level and vendor name */
|
|
|
|
if (regs[0]>=0x00000001) /* Check for supported cpuid version */
|
|
|
|
{
|
|
|
|
do_cpuid(0x00000001, regs2); /* get cpu features */
|
2012-10-21 02:40:44 +02:00
|
|
|
|
|
|
|
if(regs2[3] & (1 << 3 )) info->FeatureSet |= CPU_FEATURE_PSE;
|
|
|
|
if(regs2[3] & (1 << 4 )) info->FeatureSet |= CPU_FEATURE_TSC;
|
|
|
|
if(regs2[3] & (1 << 8 )) info->FeatureSet |= CPU_FEATURE_CX8;
|
|
|
|
if(regs2[3] & (1 << 11)) info->FeatureSet |= CPU_FEATURE_SEP;
|
|
|
|
if(regs2[3] & (1 << 12)) info->FeatureSet |= CPU_FEATURE_MTRR;
|
|
|
|
if(regs2[3] & (1 << 15)) info->FeatureSet |= CPU_FEATURE_CMOV;
|
|
|
|
if(regs2[3] & (1 << 16)) info->FeatureSet |= CPU_FEATURE_PAT;
|
|
|
|
if(regs2[3] & (1 << 23)) info->FeatureSet |= CPU_FEATURE_MMX;
|
|
|
|
if(regs2[3] & (1 << 24)) info->FeatureSet |= CPU_FEATURE_FXSR;
|
|
|
|
if(regs2[3] & (1 << 25)) info->FeatureSet |= CPU_FEATURE_SSE;
|
|
|
|
if(regs2[3] & (1 << 26)) info->FeatureSet |= CPU_FEATURE_SSE2;
|
|
|
|
|
2010-01-23 11:09:28 +01:00
|
|
|
user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = !(regs2[3] & 1);
|
2015-10-26 09:57:50 +01:00
|
|
|
user_shared_data->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = (regs2[3] >> 4) & 1;
|
|
|
|
user_shared_data->ProcessorFeatures[PF_PAE_ENABLED] = (regs2[3] >> 6) & 1;
|
|
|
|
user_shared_data->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = (regs2[3] >> 8) & 1;
|
|
|
|
user_shared_data->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = (regs2[3] >> 23) & 1;
|
|
|
|
user_shared_data->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = (regs2[3] >> 25) & 1;
|
|
|
|
user_shared_data->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = (regs2[3] >> 26) & 1;
|
2012-10-21 02:40:44 +02:00
|
|
|
user_shared_data->ProcessorFeatures[PF_SSE3_INSTRUCTIONS_AVAILABLE] = regs2[2] & 1;
|
2015-10-26 09:57:50 +01:00
|
|
|
user_shared_data->ProcessorFeatures[PF_XSAVE_ENABLED] = (regs2[2] >> 27) & 1;
|
|
|
|
user_shared_data->ProcessorFeatures[PF_COMPARE_EXCHANGE128] = (regs2[2] >> 13) & 1;
|
2009-09-15 21:38:07 +02:00
|
|
|
|
2012-10-21 02:40:47 +02:00
|
|
|
if((regs2[3] & (1 << 26)) && (regs2[3] & (1 << 24))) /* has SSE2 and FXSAVE/FXRSTOR */
|
|
|
|
user_shared_data->ProcessorFeatures[PF_SSE_DAZ_MODE_AVAILABLE] = have_sse_daz_mode();
|
|
|
|
|
2009-09-15 21:38:07 +02:00
|
|
|
if (regs[1] == AUTH && regs[3] == ENTI && regs[2] == CAMD)
|
|
|
|
{
|
2012-10-21 02:40:45 +02:00
|
|
|
info->Level = (regs2[0] >> 8) & 0xf; /* family */
|
|
|
|
if (info->Level == 0xf) /* AMD says to add the extended family to the family if family is 0xf */
|
|
|
|
info->Level += (regs2[0] >> 20) & 0xff;
|
|
|
|
|
2012-10-21 02:40:46 +02:00
|
|
|
/* repack model and stepping to make a "revision" */
|
|
|
|
info->Revision = ((regs2[0] >> 16) & 0xf) << 12; /* extended model */
|
|
|
|
info->Revision |= ((regs2[0] >> 4 ) & 0xf) << 8; /* model */
|
|
|
|
info->Revision |= regs2[0] & 0xf; /* stepping */
|
|
|
|
|
2009-09-15 21:38:07 +02:00
|
|
|
do_cpuid(0x80000000, regs); /* get vendor cpuid level */
|
|
|
|
if (regs[0] >= 0x80000001)
|
|
|
|
{
|
|
|
|
do_cpuid(0x80000001, regs2); /* get vendor features */
|
2015-10-26 09:57:50 +01:00
|
|
|
user_shared_data->ProcessorFeatures[PF_VIRT_FIRMWARE_ENABLED] = (regs2[2] >> 2) & 1;
|
|
|
|
user_shared_data->ProcessorFeatures[PF_NX_ENABLED] = (regs2[3] >> 20) & 1;
|
|
|
|
user_shared_data->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] >> 31) & 1;
|
2015-10-26 23:00:14 +01:00
|
|
|
if (regs2[3] >> 31) info->FeatureSet |= CPU_FEATURE_3DNOW;
|
2012-10-21 02:40:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (regs[1] == GENU && regs[3] == INEI && regs[2] == NTEL)
|
|
|
|
{
|
2012-10-21 02:40:45 +02:00
|
|
|
info->Level = ((regs2[0] >> 8) & 0xf) + ((regs2[0] >> 20) & 0xff); /* family + extended family */
|
|
|
|
if(info->Level == 15) info->Level = 6;
|
|
|
|
|
2012-10-21 02:40:46 +02:00
|
|
|
/* repack model and stepping to make a "revision" */
|
|
|
|
info->Revision = ((regs2[0] >> 16) & 0xf) << 12; /* extended model */
|
|
|
|
info->Revision |= ((regs2[0] >> 4 ) & 0xf) << 8; /* model */
|
|
|
|
info->Revision |= regs2[0] & 0xf; /* stepping */
|
|
|
|
|
2012-10-21 02:40:44 +02:00
|
|
|
if(regs2[3] & (1 << 21)) info->FeatureSet |= CPU_FEATURE_DS;
|
2015-10-26 09:57:50 +01:00
|
|
|
user_shared_data->ProcessorFeatures[PF_VIRT_FIRMWARE_ENABLED] = (regs2[2] >> 5) & 1;
|
2012-10-21 02:40:44 +02:00
|
|
|
|
|
|
|
do_cpuid(0x80000000, regs); /* get vendor cpuid level */
|
|
|
|
if (regs[0] >= 0x80000001)
|
|
|
|
{
|
|
|
|
do_cpuid(0x80000001, regs2); /* get vendor features */
|
2015-10-26 09:57:50 +01:00
|
|
|
user_shared_data->ProcessorFeatures[PF_NX_ENABLED] = (regs2[3] >> 20) & 1;
|
2009-09-15 21:38:07 +02:00
|
|
|
}
|
|
|
|
}
|
2012-10-21 02:40:45 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
info->Level = (regs2[0] >> 8) & 0xf; /* family */
|
2012-10-21 02:40:46 +02:00
|
|
|
|
|
|
|
/* repack model and stepping to make a "revision" */
|
|
|
|
info->Revision = ((regs2[0] >> 4 ) & 0xf) << 8; /* model */
|
|
|
|
info->Revision |= regs2[0] & 0xf; /* stepping */
|
2012-10-21 02:40:45 +02:00
|
|
|
}
|
2009-09-15 21:38:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-22 23:22:51 +02:00
|
|
|
#elif defined(__powerpc__) || defined(__ppc__)
|
|
|
|
|
|
|
|
static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
|
2009-09-15 21:38:07 +02:00
|
|
|
{
|
2012-10-22 23:22:51 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
size_t valSize;
|
|
|
|
int value;
|
2012-10-22 23:22:50 +02:00
|
|
|
|
2012-10-22 23:22:51 +02:00
|
|
|
valSize = sizeof(value);
|
|
|
|
if (sysctlbyname("hw.optional.floatingpoint", &value, &valSize, NULL, 0) == 0)
|
|
|
|
user_shared_data->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = !value;
|
|
|
|
|
|
|
|
valSize = sizeof(value);
|
|
|
|
if (sysctlbyname("hw.cpusubtype", &value, &valSize, NULL, 0) == 0)
|
2012-10-22 23:22:50 +02:00
|
|
|
{
|
2012-10-22 23:22:51 +02:00
|
|
|
switch (value)
|
|
|
|
{
|
|
|
|
case CPU_SUBTYPE_POWERPC_601:
|
|
|
|
case CPU_SUBTYPE_POWERPC_602: info->Level = 1; break;
|
|
|
|
case CPU_SUBTYPE_POWERPC_603: info->Level = 3; break;
|
|
|
|
case CPU_SUBTYPE_POWERPC_603e:
|
|
|
|
case CPU_SUBTYPE_POWERPC_603ev: info->Level = 6; break;
|
|
|
|
case CPU_SUBTYPE_POWERPC_604: info->Level = 4; break;
|
|
|
|
case CPU_SUBTYPE_POWERPC_604e: info->Level = 9; break;
|
|
|
|
case CPU_SUBTYPE_POWERPC_620: info->Level = 20; break;
|
|
|
|
case CPU_SUBTYPE_POWERPC_750: /* G3/G4 derive from 603 so ... */
|
|
|
|
case CPU_SUBTYPE_POWERPC_7400:
|
|
|
|
case CPU_SUBTYPE_POWERPC_7450: info->Level = 6; break;
|
|
|
|
case CPU_SUBTYPE_POWERPC_970: info->Level = 9;
|
|
|
|
/* :o) user_shared_data->ProcessorFeatures[PF_ALTIVEC_INSTRUCTIONS_AVAILABLE] ;-) */
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2012-10-22 23:22:50 +02:00
|
|
|
}
|
|
|
|
#else
|
2012-10-22 23:22:51 +02:00
|
|
|
FIXME("CPU Feature detection not implemented.\n");
|
2012-10-22 23:22:50 +02:00
|
|
|
#endif
|
2012-10-22 23:22:51 +02:00
|
|
|
info->Architecture = PROCESSOR_ARCHITECTURE_PPC;
|
|
|
|
}
|
2012-10-22 23:22:50 +02:00
|
|
|
|
2010-09-18 18:02:12 +02:00
|
|
|
#elif defined(__arm__)
|
2009-09-15 21:38:07 +02:00
|
|
|
|
2012-10-22 23:22:51 +02:00
|
|
|
static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
|
|
|
|
{
|
2009-09-15 21:38:07 +02:00
|
|
|
#ifdef linux
|
2012-10-22 23:22:51 +02:00
|
|
|
char line[512];
|
|
|
|
char *s, *value;
|
|
|
|
FILE *f = fopen("/proc/cpuinfo", "r");
|
|
|
|
if (f)
|
2009-09-15 21:38:07 +02:00
|
|
|
{
|
2012-10-22 23:22:51 +02:00
|
|
|
while (fgets(line, sizeof(line), f) != NULL)
|
2009-09-15 21:38:07 +02:00
|
|
|
{
|
|
|
|
/* NOTE: the ':' is the only character we can rely on */
|
|
|
|
if (!(value = strchr(line,':')))
|
|
|
|
continue;
|
|
|
|
/* terminate the valuename */
|
|
|
|
s = value - 1;
|
2012-10-22 23:22:51 +02:00
|
|
|
while ((s >= line) && isspace(*s)) s--;
|
2009-09-15 21:38:07 +02:00
|
|
|
*(s + 1) = '\0';
|
|
|
|
/* and strip leading spaces from value */
|
|
|
|
value += 1;
|
2012-10-22 23:22:51 +02:00
|
|
|
while (isspace(*value)) value++;
|
2009-09-15 21:38:07 +02:00
|
|
|
if ((s = strchr(value,'\n')))
|
|
|
|
*s='\0';
|
2019-03-26 10:26:43 +01:00
|
|
|
if (!_stricmp(line, "CPU architecture"))
|
2009-09-15 21:38:07 +02:00
|
|
|
{
|
|
|
|
if (isdigit(value[0]))
|
2015-03-26 23:17:14 +01:00
|
|
|
info->Level = atoi(value);
|
2013-11-10 22:40:23 +01:00
|
|
|
continue;
|
|
|
|
}
|
2019-03-26 10:26:43 +01:00
|
|
|
if (!_stricmp(line, "CPU revision"))
|
2013-11-10 22:40:23 +01:00
|
|
|
{
|
|
|
|
if (isdigit(value[0]))
|
|
|
|
info->Revision = atoi(value);
|
2009-09-15 21:38:07 +02:00
|
|
|
continue;
|
|
|
|
}
|
2019-03-26 10:26:43 +01:00
|
|
|
if (!_stricmp(line, "features"))
|
2009-09-15 21:38:07 +02:00
|
|
|
{
|
2012-10-22 23:22:51 +02:00
|
|
|
if (strstr(value, "vfpv3"))
|
|
|
|
user_shared_data->ProcessorFeatures[PF_ARM_VFP_32_REGISTERS_AVAILABLE] = TRUE;
|
|
|
|
if (strstr(value, "neon"))
|
|
|
|
user_shared_data->ProcessorFeatures[PF_ARM_NEON_INSTRUCTIONS_AVAILABLE] = TRUE;
|
2009-09-15 21:38:07 +02:00
|
|
|
continue;
|
|
|
|
}
|
2012-10-22 23:22:51 +02:00
|
|
|
}
|
|
|
|
fclose(f);
|
2009-09-15 21:38:07 +02:00
|
|
|
}
|
2015-03-26 23:17:53 +01:00
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
size_t valsize;
|
|
|
|
char buf[8];
|
|
|
|
int value;
|
|
|
|
|
|
|
|
valsize = sizeof(buf);
|
|
|
|
if (!sysctlbyname("hw.machine_arch", &buf, &valsize, NULL, 0) &&
|
|
|
|
sscanf(buf, "armv%i", &value) == 1)
|
|
|
|
info->Level = value;
|
|
|
|
|
|
|
|
valsize = sizeof(value);
|
|
|
|
if (!sysctlbyname("hw.floatingpoint", &value, &valsize, NULL, 0))
|
|
|
|
user_shared_data->ProcessorFeatures[PF_ARM_VFP_32_REGISTERS_AVAILABLE] = value;
|
2012-10-22 23:22:51 +02:00
|
|
|
#else
|
|
|
|
FIXME("CPU Feature detection not implemented.\n");
|
2009-09-15 21:38:07 +02:00
|
|
|
#endif
|
2015-05-21 16:16:52 +02:00
|
|
|
if (info->Level >= 8)
|
|
|
|
user_shared_data->ProcessorFeatures[PF_ARM_V8_INSTRUCTIONS_AVAILABLE] = TRUE;
|
2012-10-22 23:22:51 +02:00
|
|
|
info->Architecture = PROCESSOR_ARCHITECTURE_ARM;
|
|
|
|
}
|
2009-09-15 21:38:07 +02:00
|
|
|
|
2013-01-16 00:52:23 +01:00
|
|
|
#elif defined(__aarch64__)
|
|
|
|
|
|
|
|
static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
|
|
|
|
{
|
2015-05-21 16:13:35 +02:00
|
|
|
#ifdef linux
|
|
|
|
char line[512];
|
|
|
|
char *s, *value;
|
|
|
|
FILE *f = fopen("/proc/cpuinfo", "r");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
while (fgets(line, sizeof(line), f) != NULL)
|
|
|
|
{
|
|
|
|
/* NOTE: the ':' is the only character we can rely on */
|
|
|
|
if (!(value = strchr(line,':')))
|
|
|
|
continue;
|
|
|
|
/* terminate the valuename */
|
|
|
|
s = value - 1;
|
|
|
|
while ((s >= line) && isspace(*s)) s--;
|
|
|
|
*(s + 1) = '\0';
|
|
|
|
/* and strip leading spaces from value */
|
|
|
|
value += 1;
|
|
|
|
while (isspace(*value)) value++;
|
|
|
|
if ((s = strchr(value,'\n')))
|
|
|
|
*s='\0';
|
2019-03-26 10:26:43 +01:00
|
|
|
if (!_stricmp(line, "CPU architecture"))
|
2015-05-21 16:13:35 +02:00
|
|
|
{
|
|
|
|
if (isdigit(value[0]))
|
|
|
|
info->Level = atoi(value);
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-26 10:26:43 +01:00
|
|
|
if (!_stricmp(line, "CPU revision"))
|
2015-05-21 16:13:35 +02:00
|
|
|
{
|
|
|
|
if (isdigit(value[0]))
|
|
|
|
info->Revision = atoi(value);
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-26 10:26:43 +01:00
|
|
|
if (!_stricmp(line, "Features"))
|
2015-05-21 16:13:35 +02:00
|
|
|
{
|
|
|
|
if (strstr(value, "crc32"))
|
|
|
|
user_shared_data->ProcessorFeatures[PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE] = TRUE;
|
|
|
|
if (strstr(value, "aes"))
|
|
|
|
user_shared_data->ProcessorFeatures[PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE] = TRUE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
FIXME("CPU Feature detection not implemented.\n");
|
|
|
|
#endif
|
|
|
|
info->Level = max(info->Level, 8);
|
|
|
|
user_shared_data->ProcessorFeatures[PF_ARM_V8_INSTRUCTIONS_AVAILABLE] = TRUE;
|
2015-05-20 14:43:09 +02:00
|
|
|
info->Architecture = PROCESSOR_ARCHITECTURE_ARM64;
|
2013-01-16 00:52:23 +01:00
|
|
|
}
|
|
|
|
|
2012-10-22 23:22:51 +02:00
|
|
|
#endif /* End architecture specific feature detection for CPUs */
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* fill_cpu_info
|
|
|
|
*
|
|
|
|
* inits a couple of places with CPU related information:
|
2019-02-14 19:41:34 +01:00
|
|
|
* - cpu_info in this file
|
2012-10-22 23:22:51 +02:00
|
|
|
* - Peb->NumberOfProcessors
|
|
|
|
* - SharedUserData->ProcessFeatures[] array
|
|
|
|
*/
|
|
|
|
void fill_cpu_info(void)
|
|
|
|
{
|
|
|
|
long num;
|
|
|
|
|
|
|
|
#ifdef _SC_NPROCESSORS_ONLN
|
|
|
|
num = sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|
if (num < 1)
|
2009-09-15 21:38:07 +02:00
|
|
|
{
|
2012-10-22 23:22:51 +02:00
|
|
|
num = 1;
|
|
|
|
WARN("Failed to detect the number of processors.\n");
|
2010-02-28 05:07:10 +01:00
|
|
|
}
|
2012-10-22 23:22:51 +02:00
|
|
|
#elif defined(CTL_HW) && defined(HW_NCPU)
|
|
|
|
int mib[2];
|
|
|
|
size_t len = sizeof(num);
|
|
|
|
mib[0] = CTL_HW;
|
|
|
|
mib[1] = HW_NCPU;
|
|
|
|
if (sysctl(mib, 2, &num, &len, NULL, 0) != 0)
|
2009-09-15 21:38:07 +02:00
|
|
|
{
|
2012-10-22 23:22:51 +02:00
|
|
|
num = 1;
|
|
|
|
WARN("Failed to detect the number of processors.\n");
|
2009-09-15 21:38:07 +02:00
|
|
|
}
|
|
|
|
#else
|
2012-10-22 23:22:51 +02:00
|
|
|
num = 1;
|
2012-11-04 11:06:58 +01:00
|
|
|
FIXME("Detecting the number of processors is not supported.\n");
|
2009-09-15 21:38:07 +02:00
|
|
|
#endif
|
2012-10-22 23:22:51 +02:00
|
|
|
NtCurrentTeb()->Peb->NumberOfProcessors = num;
|
|
|
|
|
2019-02-14 19:41:34 +01:00
|
|
|
get_cpuinfo(&cpu_info);
|
2012-10-22 23:22:51 +02:00
|
|
|
|
2009-09-15 21:38:07 +02:00
|
|
|
TRACE("<- CPU arch %d, level %d, rev %d, features 0x%x\n",
|
2019-02-14 19:41:34 +01:00
|
|
|
cpu_info.Architecture, cpu_info.Level, cpu_info.Revision, cpu_info.FeatureSet);
|
2009-09-15 21:38:07 +02:00
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
static BOOL grow_logical_proc_buf(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **pdata,
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **pdataex, DWORD *max_len)
|
2012-09-04 13:37:59 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
if (pdata)
|
|
|
|
{
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION *new_data;
|
2012-09-04 13:37:59 +02:00
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
*max_len *= 2;
|
|
|
|
new_data = RtlReAllocateHeap(GetProcessHeap(), 0, *pdata, *max_len*sizeof(*new_data));
|
|
|
|
if (!new_data)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*pdata = new_data;
|
|
|
|
}
|
|
|
|
else
|
2012-09-04 13:37:59 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *new_dataex;
|
2012-09-04 13:37:59 +02:00
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
*max_len *= 2;
|
|
|
|
new_dataex = RtlReAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, *pdataex, *max_len*sizeof(*new_dataex));
|
|
|
|
if (!new_dataex)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*pdataex = new_dataex;
|
2012-09-04 13:37:59 +02:00
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD log_proc_ex_size_plus(DWORD size)
|
|
|
|
{
|
|
|
|
/* add SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX.Relationship and .Size */
|
|
|
|
return sizeof(LOGICAL_PROCESSOR_RELATIONSHIP) + sizeof(DWORD) + size;
|
|
|
|
}
|
|
|
|
|
2018-06-21 07:29:42 +02:00
|
|
|
static DWORD count_bits(ULONG_PTR mask)
|
|
|
|
{
|
|
|
|
DWORD count = 0;
|
|
|
|
while (mask > 0)
|
|
|
|
{
|
|
|
|
mask >>= 1;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store package and core information for a logical processor. Parsing of processor
|
|
|
|
* data may happen in multiple passes; the 'id' parameter is then used to locate
|
|
|
|
* previously stored data. The type of data stored in 'id' depends on 'rel':
|
|
|
|
* - RelationProcessorPackage: package id ('CPU socket').
|
|
|
|
* - RelationProcessorCore: physical core number.
|
|
|
|
*/
|
2016-01-25 15:47:10 +01:00
|
|
|
static inline BOOL logical_proc_info_add_by_id(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **pdata,
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **pdataex, DWORD *len, DWORD *pmax_len,
|
|
|
|
LOGICAL_PROCESSOR_RELATIONSHIP rel, DWORD id, ULONG_PTR mask)
|
|
|
|
{
|
|
|
|
if (pdata) {
|
|
|
|
DWORD i;
|
|
|
|
|
2018-06-21 07:29:44 +02:00
|
|
|
for (i=0; i<*len; i++)
|
|
|
|
{
|
|
|
|
if (rel == RelationProcessorPackage && (*pdata)[i].Relationship == rel && (*pdata)[i].u.Reserved[1] == id)
|
2016-01-25 15:47:10 +01:00
|
|
|
{
|
|
|
|
(*pdata)[i].ProcessorMask |= mask;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2018-06-21 07:29:44 +02:00
|
|
|
else if (rel == RelationProcessorCore && (*pdata)[i].Relationship == rel && (*pdata)[i].u.Reserved[1] == id)
|
|
|
|
return TRUE;
|
|
|
|
}
|
2016-01-25 15:47:10 +01:00
|
|
|
|
|
|
|
while(*len == *pmax_len)
|
|
|
|
{
|
|
|
|
if (!grow_logical_proc_buf(pdata, NULL, pmax_len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*pdata)[i].Relationship = rel;
|
|
|
|
(*pdata)[i].ProcessorMask = mask;
|
2018-06-21 07:29:46 +02:00
|
|
|
if (rel == RelationProcessorCore)
|
|
|
|
(*pdata)[i].u.ProcessorCore.Flags = count_bits(mask) > 1 ? LTP_PC_SMT : 0;
|
2016-01-25 15:47:10 +01:00
|
|
|
(*pdata)[i].u.Reserved[0] = 0;
|
|
|
|
(*pdata)[i].u.Reserved[1] = id;
|
|
|
|
*len = i+1;
|
|
|
|
}else{
|
2017-01-30 23:11:05 +01:00
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *dataex;
|
2016-01-25 15:47:10 +01:00
|
|
|
DWORD ofs = 0;
|
|
|
|
|
|
|
|
while(ofs < *len)
|
|
|
|
{
|
|
|
|
dataex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(((char *)*pdataex) + ofs);
|
|
|
|
if (rel == RelationProcessorPackage && dataex->Relationship == rel && dataex->u.Processor.Reserved[1] == id)
|
|
|
|
{
|
|
|
|
dataex->u.Processor.GroupMask[0].Mask |= mask;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2018-06-21 07:29:44 +02:00
|
|
|
else if (rel == RelationProcessorCore && dataex->Relationship == rel && dataex->u.Processor.Reserved[1] == id)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2016-01-25 15:47:10 +01:00
|
|
|
ofs += dataex->Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: For now, just one group. If more than 64 processors, then we
|
|
|
|
* need another group. */
|
|
|
|
|
|
|
|
while (ofs + log_proc_ex_size_plus(sizeof(PROCESSOR_RELATIONSHIP)) > *pmax_len)
|
|
|
|
{
|
|
|
|
if (!grow_logical_proc_buf(NULL, pdataex, pmax_len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dataex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(((char *)*pdataex) + ofs);
|
|
|
|
|
|
|
|
dataex->Relationship = rel;
|
|
|
|
dataex->Size = log_proc_ex_size_plus(sizeof(PROCESSOR_RELATIONSHIP));
|
2018-06-21 07:29:45 +02:00
|
|
|
if (rel == RelationProcessorCore)
|
|
|
|
dataex->u.Processor.Flags = count_bits(mask) > 1 ? LTP_PC_SMT : 0;
|
|
|
|
else
|
|
|
|
dataex->u.Processor.Flags = 0;
|
2016-01-25 15:47:10 +01:00
|
|
|
dataex->u.Processor.EfficiencyClass = 0;
|
|
|
|
dataex->u.Processor.GroupCount = 1;
|
|
|
|
dataex->u.Processor.GroupMask[0].Mask = mask;
|
|
|
|
dataex->u.Processor.GroupMask[0].Group = 0;
|
|
|
|
/* mark for future lookup */
|
|
|
|
dataex->u.Processor.Reserved[0] = 0;
|
|
|
|
dataex->u.Processor.Reserved[1] = id;
|
|
|
|
|
|
|
|
*len += dataex->Size;
|
|
|
|
}
|
2012-09-04 13:37:59 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
static inline BOOL logical_proc_info_add_cache(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **pdata,
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **pdataex, DWORD *len,
|
|
|
|
DWORD *pmax_len, ULONG_PTR mask, CACHE_DESCRIPTOR *cache)
|
2012-09-04 13:38:17 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
if (pdata)
|
|
|
|
{
|
|
|
|
DWORD i;
|
2012-09-04 13:38:17 +02:00
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
for (i=0; i<*len; i++)
|
|
|
|
{
|
|
|
|
if ((*pdata)[i].Relationship==RelationCache && (*pdata)[i].ProcessorMask==mask
|
|
|
|
&& (*pdata)[i].u.Cache.Level==cache->Level && (*pdata)[i].u.Cache.Type==cache->Type)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*len == *pmax_len)
|
|
|
|
if (!grow_logical_proc_buf(pdata, NULL, pmax_len))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
(*pdata)[i].Relationship = RelationCache;
|
|
|
|
(*pdata)[i].ProcessorMask = mask;
|
|
|
|
(*pdata)[i].u.Cache = *cache;
|
|
|
|
*len = i+1;
|
|
|
|
}
|
|
|
|
else
|
2012-09-04 13:38:17 +02:00
|
|
|
{
|
2017-01-30 23:11:05 +01:00
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *dataex;
|
2016-01-25 15:47:10 +01:00
|
|
|
DWORD ofs;
|
|
|
|
|
|
|
|
for (ofs = 0; ofs < *len; )
|
|
|
|
{
|
|
|
|
dataex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(((char *)*pdataex) + ofs);
|
|
|
|
if (dataex->Relationship == RelationCache && dataex->u.Cache.GroupMask.Mask == mask &&
|
|
|
|
dataex->u.Cache.Level == cache->Level && dataex->u.Cache.Type == cache->Type)
|
|
|
|
return TRUE;
|
|
|
|
ofs += dataex->Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (ofs + log_proc_ex_size_plus(sizeof(CACHE_RELATIONSHIP)) > *pmax_len)
|
|
|
|
{
|
|
|
|
if (!grow_logical_proc_buf(NULL, pdataex, pmax_len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dataex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(((char *)*pdataex) + ofs);
|
|
|
|
|
|
|
|
dataex->Relationship = RelationCache;
|
|
|
|
dataex->Size = log_proc_ex_size_plus(sizeof(CACHE_RELATIONSHIP));
|
|
|
|
dataex->u.Cache.Level = cache->Level;
|
|
|
|
dataex->u.Cache.Associativity = cache->Associativity;
|
|
|
|
dataex->u.Cache.LineSize = cache->LineSize;
|
|
|
|
dataex->u.Cache.CacheSize = cache->Size;
|
|
|
|
dataex->u.Cache.Type = cache->Type;
|
|
|
|
dataex->u.Cache.GroupMask.Mask = mask;
|
|
|
|
dataex->u.Cache.GroupMask.Group = 0;
|
|
|
|
|
|
|
|
*len += dataex->Size;
|
2012-09-04 13:38:17 +02:00
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL logical_proc_info_add_numa_node(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **pdata,
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **pdataex, DWORD *len, DWORD *pmax_len, ULONG_PTR mask,
|
|
|
|
DWORD node_id)
|
|
|
|
{
|
|
|
|
if (pdata)
|
|
|
|
{
|
|
|
|
while (*len == *pmax_len)
|
|
|
|
if (!grow_logical_proc_buf(pdata, NULL, pmax_len))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
(*pdata)[*len].Relationship = RelationNumaNode;
|
|
|
|
(*pdata)[*len].ProcessorMask = mask;
|
|
|
|
(*pdata)[*len].u.NumaNode.NodeNumber = node_id;
|
|
|
|
(*len)++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *dataex;
|
|
|
|
|
|
|
|
while (*len + log_proc_ex_size_plus(sizeof(NUMA_NODE_RELATIONSHIP)) > *pmax_len)
|
|
|
|
{
|
|
|
|
if (!grow_logical_proc_buf(NULL, pdataex, pmax_len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dataex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(((char *)*pdataex) + *len);
|
|
|
|
|
|
|
|
dataex->Relationship = RelationNumaNode;
|
|
|
|
dataex->Size = log_proc_ex_size_plus(sizeof(NUMA_NODE_RELATIONSHIP));
|
|
|
|
dataex->u.NumaNode.NodeNumber = node_id;
|
|
|
|
dataex->u.NumaNode.GroupMask.Mask = mask;
|
|
|
|
dataex->u.NumaNode.GroupMask.Group = 0;
|
|
|
|
|
|
|
|
*len += dataex->Size;
|
|
|
|
}
|
2012-09-04 13:38:17 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
static inline BOOL logical_proc_info_add_group(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **pdataex,
|
|
|
|
DWORD *len, DWORD *pmax_len, DWORD num_cpus, ULONG_PTR mask)
|
2012-09-04 13:38:36 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *dataex;
|
|
|
|
|
|
|
|
while (*len + log_proc_ex_size_plus(sizeof(GROUP_RELATIONSHIP)) > *pmax_len)
|
|
|
|
{
|
|
|
|
if (!grow_logical_proc_buf(NULL, pdataex, pmax_len))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dataex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(((char *)*pdataex) + *len);
|
|
|
|
|
|
|
|
dataex->Relationship = RelationGroup;
|
|
|
|
dataex->Size = log_proc_ex_size_plus(sizeof(GROUP_RELATIONSHIP));
|
|
|
|
dataex->u.Group.MaximumGroupCount = 1;
|
|
|
|
dataex->u.Group.ActiveGroupCount = 1;
|
|
|
|
dataex->u.Group.GroupInfo[0].MaximumProcessorCount = num_cpus;
|
|
|
|
dataex->u.Group.GroupInfo[0].ActiveProcessorCount = num_cpus;
|
|
|
|
dataex->u.Group.GroupInfo[0].ActiveProcessorMask = mask;
|
|
|
|
|
|
|
|
*len += dataex->Size;
|
2012-09-04 13:38:36 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
#ifdef linux
|
2018-12-03 07:53:15 +01:00
|
|
|
/* Helper function for counting bitmap values as commonly used by the Linux kernel
|
|
|
|
* for storing CPU masks in sysfs. The format is comma separated lists of hex values
|
|
|
|
* each max 32-bit e.g. "00ff" or even "00,00000000,0000ffff".
|
|
|
|
*
|
|
|
|
* Example files include:
|
|
|
|
* - /sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_map
|
|
|
|
* - /sys/devices/system/cpu/cpu0/topology/thread_siblings
|
|
|
|
*/
|
|
|
|
static BOOL sysfs_parse_bitmap(const char *filename, ULONG_PTR * const mask)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
DWORD r;
|
|
|
|
|
|
|
|
f = fopen(filename, "r");
|
|
|
|
if (!f)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
while (!feof(f))
|
|
|
|
{
|
|
|
|
char op;
|
|
|
|
if (!fscanf(f, "%x%c ", &r, &op))
|
|
|
|
break;
|
|
|
|
|
|
|
|
*mask = (sizeof(ULONG_PTR)>sizeof(int) ? *mask<<(8*sizeof(DWORD)) : 0) + r;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-03 07:53:17 +01:00
|
|
|
/* Helper function for counting number of elements in interval lists as used by
|
|
|
|
* the Linux kernel. The format is comma separated list of intervals of which
|
|
|
|
* each interval has the format of "begin-end" where begin and end are decimal
|
|
|
|
* numbers. E.g. "0-7", "0-7,16-23"
|
|
|
|
*
|
|
|
|
* Example files include:
|
|
|
|
* - /sys/devices/system/cpu/online
|
|
|
|
* - /sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_list
|
|
|
|
* - /sys/devices/system/cpu/cpu0/topology/thread_siblings_list.
|
|
|
|
*/
|
|
|
|
static BOOL sysfs_count_list_elements(const char *filename, DWORD *result)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
f = fopen(filename, "r");
|
|
|
|
if (!f)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
while (!feof(f))
|
|
|
|
{
|
|
|
|
char op;
|
|
|
|
DWORD beg, end;
|
|
|
|
|
|
|
|
if (!fscanf(f, "%u%c ", &beg, &op))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(op == '-')
|
|
|
|
fscanf(f, "%u%c ", &end, &op);
|
|
|
|
else
|
|
|
|
end = beg;
|
|
|
|
|
|
|
|
*result += end - beg + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
/* for 'data', max_len is the array count. for 'dataex', max_len is in bytes */
|
|
|
|
static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **data,
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **dataex, DWORD *max_len)
|
2012-09-04 13:37:59 +02:00
|
|
|
{
|
2018-04-19 07:30:27 +02:00
|
|
|
static const char core_info[] = "/sys/devices/system/cpu/cpu%u/topology/%s";
|
2015-10-28 19:36:15 +01:00
|
|
|
static const char cache_info[] = "/sys/devices/system/cpu/cpu%u/cache/index%u/%s";
|
|
|
|
static const char numa_info[] = "/sys/devices/system/node/node%u/cpumap";
|
2012-09-04 13:37:59 +02:00
|
|
|
|
2012-09-04 13:38:36 +02:00
|
|
|
FILE *fcpu_list, *fnuma_list, *f;
|
2018-12-03 07:53:17 +01:00
|
|
|
DWORD len = 0, beg, end, i, j, r, num_cpus = 0, max_cpus = 0;
|
2012-09-04 13:37:59 +02:00
|
|
|
char op, name[MAX_PATH];
|
2016-01-25 15:47:10 +01:00
|
|
|
ULONG_PTR all_cpus_mask = 0;
|
2012-09-04 13:37:59 +02:00
|
|
|
|
2018-12-03 07:53:17 +01:00
|
|
|
/* On systems with a large number of CPU cores (32 or 64 depending on 32-bit or 64-bit),
|
|
|
|
* we have issues parsing processor information:
|
|
|
|
* - ULONG_PTR masks as used in data structures can't hold all cores. Requires splitting
|
|
|
|
* data appropriately into "processor groups". We are hard coding 1.
|
|
|
|
* - Thread affinity code in wineserver and our CPU parsing code here work independently.
|
|
|
|
* So far the Windows mask applied directly to Linux, but process groups break that.
|
|
|
|
* (NUMA systems you may have multiple non-full groups.)
|
|
|
|
*/
|
|
|
|
if(sysfs_count_list_elements("/sys/devices/system/cpu/present", &max_cpus) && max_cpus > MAXIMUM_PROCESSORS)
|
|
|
|
{
|
|
|
|
FIXME("Improve CPU info reporting: system supports %u logical cores, but only %u supported!\n",
|
|
|
|
max_cpus, MAXIMUM_PROCESSORS);
|
|
|
|
}
|
|
|
|
|
2012-09-04 13:37:59 +02:00
|
|
|
fcpu_list = fopen("/sys/devices/system/cpu/online", "r");
|
|
|
|
if(!fcpu_list)
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
while(!feof(fcpu_list))
|
|
|
|
{
|
|
|
|
if(!fscanf(fcpu_list, "%u%c ", &beg, &op))
|
|
|
|
break;
|
|
|
|
if(op == '-') fscanf(fcpu_list, "%u%c ", &end, &op);
|
|
|
|
else end = beg;
|
|
|
|
|
|
|
|
for(i=beg; i<=end; i++)
|
|
|
|
{
|
2018-06-21 07:29:44 +02:00
|
|
|
DWORD phys_core = 0;
|
|
|
|
ULONG_PTR thread_mask = 0;
|
|
|
|
|
2012-09-04 13:37:59 +02:00
|
|
|
if(i > 8*sizeof(ULONG_PTR))
|
|
|
|
{
|
|
|
|
FIXME("skipping logical processor %d\n", i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
sprintf(name, core_info, i, "physical_package_id");
|
2012-09-04 13:37:59 +02:00
|
|
|
f = fopen(name, "r");
|
|
|
|
if(f)
|
|
|
|
{
|
|
|
|
fscanf(f, "%u", &r);
|
|
|
|
fclose(f);
|
|
|
|
}
|
2016-01-25 15:47:10 +01:00
|
|
|
else r = 0;
|
2016-02-06 15:30:59 +01:00
|
|
|
if(!logical_proc_info_add_by_id(data, dataex, &len, max_len, RelationProcessorPackage, r, (ULONG_PTR)1 << i))
|
2012-09-04 13:37:59 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
fclose(fcpu_list);
|
|
|
|
return STATUS_NO_MEMORY;
|
2012-09-04 13:37:59 +02:00
|
|
|
}
|
|
|
|
|
2018-06-21 07:29:44 +02:00
|
|
|
/* Sysfs enumerates logical cores (and not physical cores), but Windows enumerates
|
|
|
|
* by physical core. Upon enumerating a logical core in sysfs, we register a physical
|
|
|
|
* core and all its logical cores. In order to not report physical cores multiple
|
|
|
|
* times, we pass a unique physical core ID to logical_proc_info_add_by_id and let
|
|
|
|
* that call figure out any duplication.
|
|
|
|
* Obtain a unique physical core ID from the first element of thread_siblings_list.
|
|
|
|
* This list provides logical cores sharing the same physical core. The IDs are based
|
|
|
|
* on kernel cpu core numbering as opposed to a hardware core ID like provided through
|
|
|
|
* 'core_id', so are suitable as a unique ID.
|
|
|
|
*/
|
|
|
|
sprintf(name, core_info, i, "thread_siblings_list");
|
2012-09-04 13:37:59 +02:00
|
|
|
f = fopen(name, "r");
|
|
|
|
if(f)
|
|
|
|
{
|
2018-06-21 07:29:44 +02:00
|
|
|
fscanf(f, "%d%c", &phys_core, &op);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
else phys_core = i;
|
|
|
|
|
|
|
|
/* Mask of logical threads sharing same physical core in kernel core numbering. */
|
|
|
|
sprintf(name, core_info, i, "thread_siblings");
|
2018-12-03 07:53:16 +01:00
|
|
|
if(!sysfs_parse_bitmap(name, &thread_mask))
|
|
|
|
thread_mask = 1<<i;
|
2018-06-21 07:29:44 +02:00
|
|
|
if(!logical_proc_info_add_by_id(data, dataex, &len, max_len, RelationProcessorCore, phys_core, thread_mask))
|
2012-09-04 13:37:59 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
fclose(fcpu_list);
|
|
|
|
return STATUS_NO_MEMORY;
|
2012-09-04 13:37:59 +02:00
|
|
|
}
|
2012-09-04 13:38:17 +02:00
|
|
|
|
|
|
|
for(j=0; j<4; j++)
|
|
|
|
{
|
|
|
|
CACHE_DESCRIPTOR cache;
|
|
|
|
ULONG_PTR mask = 0;
|
|
|
|
|
|
|
|
sprintf(name, cache_info, i, j, "shared_cpu_map");
|
2018-12-03 07:53:15 +01:00
|
|
|
if(!sysfs_parse_bitmap(name, &mask)) continue;
|
2012-09-04 13:38:17 +02:00
|
|
|
|
|
|
|
sprintf(name, cache_info, i, j, "level");
|
|
|
|
f = fopen(name, "r");
|
|
|
|
if(!f) continue;
|
|
|
|
fscanf(f, "%u", &r);
|
|
|
|
fclose(f);
|
|
|
|
cache.Level = r;
|
|
|
|
|
|
|
|
sprintf(name, cache_info, i, j, "ways_of_associativity");
|
|
|
|
f = fopen(name, "r");
|
|
|
|
if(!f) continue;
|
|
|
|
fscanf(f, "%u", &r);
|
|
|
|
fclose(f);
|
|
|
|
cache.Associativity = r;
|
|
|
|
|
|
|
|
sprintf(name, cache_info, i, j, "coherency_line_size");
|
|
|
|
f = fopen(name, "r");
|
|
|
|
if(!f) continue;
|
|
|
|
fscanf(f, "%u", &r);
|
|
|
|
fclose(f);
|
|
|
|
cache.LineSize = r;
|
|
|
|
|
|
|
|
sprintf(name, cache_info, i, j, "size");
|
|
|
|
f = fopen(name, "r");
|
|
|
|
if(!f) continue;
|
|
|
|
fscanf(f, "%u%c", &r, &op);
|
|
|
|
fclose(f);
|
|
|
|
if(op != 'K')
|
|
|
|
WARN("unknown cache size %u%c\n", r, op);
|
|
|
|
cache.Size = (op=='K' ? r*1024 : r);
|
|
|
|
|
|
|
|
sprintf(name, cache_info, i, j, "type");
|
|
|
|
f = fopen(name, "r");
|
|
|
|
if(!f) continue;
|
|
|
|
fscanf(f, "%s", name);
|
|
|
|
fclose(f);
|
|
|
|
if(!memcmp(name, "Data", 5))
|
|
|
|
cache.Type = CacheData;
|
|
|
|
else if(!memcmp(name, "Instruction", 11))
|
|
|
|
cache.Type = CacheInstruction;
|
|
|
|
else
|
|
|
|
cache.Type = CacheUnified;
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
if(!logical_proc_info_add_cache(data, dataex, &len, max_len, mask, &cache))
|
2012-09-04 13:38:17 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
fclose(fcpu_list);
|
|
|
|
return STATUS_NO_MEMORY;
|
2012-09-04 13:38:17 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-04 13:37:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fcpu_list);
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
if(data){
|
|
|
|
for(i=0; i<len; i++){
|
|
|
|
if((*data)[i].Relationship == RelationProcessorCore){
|
|
|
|
all_cpus_mask |= (*data)[i].ProcessorMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
for(i = 0; i < len; ){
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *infoex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(((char *)*dataex) + i);
|
|
|
|
if(infoex->Relationship == RelationProcessorCore){
|
|
|
|
all_cpus_mask |= infoex->u.Processor.GroupMask[0].Mask;
|
|
|
|
}
|
|
|
|
i += infoex->Size;
|
|
|
|
}
|
|
|
|
}
|
2018-06-21 07:29:42 +02:00
|
|
|
num_cpus = count_bits(all_cpus_mask);
|
2016-01-25 15:47:10 +01:00
|
|
|
|
2012-09-04 13:38:36 +02:00
|
|
|
fnuma_list = fopen("/sys/devices/system/node/online", "r");
|
|
|
|
if(!fnuma_list)
|
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
if(!logical_proc_info_add_numa_node(data, dataex, &len, max_len, all_cpus_mask, 0))
|
|
|
|
return STATUS_NO_MEMORY;
|
2012-09-04 13:38:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while(!feof(fnuma_list))
|
|
|
|
{
|
|
|
|
if(!fscanf(fnuma_list, "%u%c ", &beg, &op))
|
|
|
|
break;
|
|
|
|
if(op == '-') fscanf(fnuma_list, "%u%c ", &end, &op);
|
|
|
|
else end = beg;
|
|
|
|
|
|
|
|
for(i=beg; i<=end; i++)
|
|
|
|
{
|
|
|
|
ULONG_PTR mask = 0;
|
|
|
|
|
|
|
|
sprintf(name, numa_info, i);
|
|
|
|
f = fopen(name, "r");
|
|
|
|
if(!f) continue;
|
|
|
|
while(!feof(f))
|
|
|
|
{
|
|
|
|
if(!fscanf(f, "%x%c ", &r, &op))
|
|
|
|
break;
|
|
|
|
mask = (sizeof(ULONG_PTR)>sizeof(int) ? mask<<(8*sizeof(DWORD)) : 0) + r;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
if(!logical_proc_info_add_numa_node(data, dataex, &len, max_len, mask, i))
|
2012-09-04 13:38:36 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
fclose(fnuma_list);
|
|
|
|
return STATUS_NO_MEMORY;
|
2012-09-04 13:38:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fnuma_list);
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
if(dataex)
|
|
|
|
logical_proc_info_add_group(dataex, &len, max_len, num_cpus, all_cpus_mask);
|
|
|
|
|
|
|
|
if(data)
|
|
|
|
*max_len = len * sizeof(**data);
|
|
|
|
else
|
|
|
|
*max_len = len;
|
|
|
|
|
2012-09-04 13:37:59 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2012-09-05 12:00:55 +02:00
|
|
|
#elif defined(__APPLE__)
|
2016-01-25 15:47:10 +01:00
|
|
|
/* for 'data', max_len is the array count. for 'dataex', max_len is in bytes */
|
|
|
|
static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **data,
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **dataex, DWORD *max_len)
|
2012-09-05 12:00:55 +02:00
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
DWORD pkgs_no, cores_no, lcpu_no, lcpu_per_core, cores_per_package, assoc, len = 0;
|
|
|
|
DWORD cache_ctrs[10] = {0};
|
|
|
|
ULONG_PTR all_cpus_mask = 0;
|
|
|
|
CACHE_DESCRIPTOR cache[10];
|
2012-09-05 12:01:28 +02:00
|
|
|
LONGLONG cache_size, cache_line_size, cache_sharing[10];
|
2016-01-25 15:47:10 +01:00
|
|
|
size_t size;
|
|
|
|
DWORD p,i,j,k;
|
2012-09-05 12:00:55 +02:00
|
|
|
|
|
|
|
lcpu_no = NtCurrentTeb()->Peb->NumberOfProcessors;
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
size = sizeof(pkgs_no);
|
|
|
|
if(sysctlbyname("hw.packages", &pkgs_no, &size, NULL, 0))
|
|
|
|
pkgs_no = 1;
|
|
|
|
|
2012-09-05 12:00:55 +02:00
|
|
|
size = sizeof(cores_no);
|
2016-01-25 15:47:10 +01:00
|
|
|
if(sysctlbyname("hw.physicalcpu", &cores_no, &size, NULL, 0))
|
2012-09-05 12:00:55 +02:00
|
|
|
cores_no = lcpu_no;
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
TRACE("%u logical CPUs from %u physical cores across %u packages\n",
|
|
|
|
lcpu_no, cores_no, pkgs_no);
|
2012-09-05 12:00:55 +02:00
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
lcpu_per_core = lcpu_no / cores_no;
|
|
|
|
cores_per_package = cores_no / pkgs_no;
|
2012-09-05 12:00:55 +02:00
|
|
|
|
2012-09-05 12:01:28 +02:00
|
|
|
memset(cache, 0, sizeof(cache));
|
|
|
|
cache[1].Level = 1;
|
2016-01-25 15:47:10 +01:00
|
|
|
cache[1].Type = CacheInstruction;
|
|
|
|
cache[1].Associativity = 8; /* reasonable default */
|
|
|
|
cache[1].LineSize = 0x40; /* reasonable default */
|
|
|
|
cache[2].Level = 1;
|
|
|
|
cache[2].Type = CacheData;
|
|
|
|
cache[2].Associativity = 8;
|
|
|
|
cache[2].LineSize = 0x40;
|
|
|
|
cache[3].Level = 2;
|
2012-09-05 12:01:28 +02:00
|
|
|
cache[3].Type = CacheUnified;
|
2016-01-25 15:47:10 +01:00
|
|
|
cache[3].Associativity = 8;
|
|
|
|
cache[3].LineSize = 0x40;
|
|
|
|
cache[4].Level = 3;
|
|
|
|
cache[4].Type = CacheUnified;
|
|
|
|
cache[4].Associativity = 12;
|
|
|
|
cache[4].LineSize = 0x40;
|
2012-09-05 12:01:28 +02:00
|
|
|
|
|
|
|
size = sizeof(cache_line_size);
|
|
|
|
if(!sysctlbyname("hw.cachelinesize", &cache_line_size, &size, NULL, 0))
|
|
|
|
{
|
2016-01-25 15:47:10 +01:00
|
|
|
for(i=1; i<5; i++)
|
2012-09-05 12:01:28 +02:00
|
|
|
cache[i].LineSize = cache_line_size;
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
/* TODO: set actual associativity for all caches */
|
2012-09-05 12:01:28 +02:00
|
|
|
size = sizeof(assoc);
|
|
|
|
if(!sysctlbyname("machdep.cpu.cache.L2_associativity", &assoc, &size, NULL, 0))
|
2016-01-25 15:47:10 +01:00
|
|
|
cache[3].Associativity = assoc;
|
2012-09-05 12:01:28 +02:00
|
|
|
|
|
|
|
size = sizeof(cache_size);
|
|
|
|
if(!sysctlbyname("hw.l1icachesize", &cache_size, &size, NULL, 0))
|
2016-01-25 15:47:10 +01:00
|
|
|
cache[1].Size = cache_size;
|
2012-09-05 12:01:28 +02:00
|
|
|
size = sizeof(cache_size);
|
|
|
|
if(!sysctlbyname("hw.l1dcachesize", &cache_size, &size, NULL, 0))
|
2016-01-25 15:47:10 +01:00
|
|
|
cache[2].Size = cache_size;
|
2012-09-05 12:01:28 +02:00
|
|
|
size = sizeof(cache_size);
|
|
|
|
if(!sysctlbyname("hw.l2cachesize", &cache_size, &size, NULL, 0))
|
2016-01-25 15:47:10 +01:00
|
|
|
cache[3].Size = cache_size;
|
2012-09-05 12:01:28 +02:00
|
|
|
size = sizeof(cache_size);
|
|
|
|
if(!sysctlbyname("hw.l3cachesize", &cache_size, &size, NULL, 0))
|
2016-01-25 15:47:10 +01:00
|
|
|
cache[4].Size = cache_size;
|
2012-09-05 12:01:28 +02:00
|
|
|
|
|
|
|
size = sizeof(cache_sharing);
|
2016-01-25 15:47:10 +01:00
|
|
|
if(sysctlbyname("hw.cacheconfig", cache_sharing, &size, NULL, 0) < 0){
|
|
|
|
cache_sharing[1] = lcpu_per_core;
|
|
|
|
cache_sharing[2] = lcpu_per_core;
|
|
|
|
cache_sharing[3] = lcpu_per_core;
|
|
|
|
cache_sharing[4] = lcpu_no;
|
|
|
|
}else{
|
|
|
|
/* in cache[], indexes 1 and 2 are l1 caches */
|
|
|
|
cache_sharing[4] = cache_sharing[3];
|
|
|
|
cache_sharing[3] = cache_sharing[2];
|
|
|
|
cache_sharing[2] = cache_sharing[1];
|
|
|
|
}
|
2012-09-05 12:01:28 +02:00
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
for(p = 0; p < pkgs_no; ++p){
|
|
|
|
for(j = 0; j < cores_per_package && p * cores_per_package + j < cores_no; ++j){
|
|
|
|
ULONG_PTR mask = 0;
|
2018-06-21 07:29:43 +02:00
|
|
|
DWORD phys_core;
|
2012-09-05 12:01:28 +02:00
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
for(k = 0; k < lcpu_per_core; ++k)
|
|
|
|
mask |= (ULONG_PTR)1 << (j * lcpu_per_core + k);
|
|
|
|
|
|
|
|
all_cpus_mask |= mask;
|
|
|
|
|
|
|
|
/* add to package */
|
|
|
|
if(!logical_proc_info_add_by_id(data, dataex, &len, max_len, RelationProcessorPackage, p, mask))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
/* add new core */
|
2018-06-21 07:29:43 +02:00
|
|
|
phys_core = p * cores_per_package + j;
|
|
|
|
if(!logical_proc_info_add_by_id(data, dataex, &len, max_len, RelationProcessorCore, phys_core, mask))
|
2016-01-25 15:47:10 +01:00
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
for(i = 1; i < 5; ++i){
|
|
|
|
if(cache_ctrs[i] == 0 && cache[i].Size > 0){
|
|
|
|
mask = 0;
|
|
|
|
for(k = 0; k < cache_sharing[i]; ++k)
|
|
|
|
mask |= (ULONG_PTR)1 << (j * lcpu_per_core + k);
|
|
|
|
|
|
|
|
if(!logical_proc_info_add_cache(data, dataex, &len, max_len, mask, &cache[i]))
|
|
|
|
return STATUS_NO_MEMORY;
|
2012-09-05 12:01:28 +02:00
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
cache_ctrs[i] += lcpu_per_core;
|
|
|
|
|
|
|
|
if(cache_ctrs[i] == cache_sharing[i])
|
|
|
|
cache_ctrs[i] = 0;
|
2012-09-05 12:01:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
/* OSX doesn't support NUMA, so just make one NUMA node for all CPUs */
|
|
|
|
if(!logical_proc_info_add_numa_node(data, dataex, &len, max_len, all_cpus_mask, 0))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
if(dataex)
|
|
|
|
logical_proc_info_add_group(dataex, &len, max_len, lcpu_no, all_cpus_mask);
|
|
|
|
|
|
|
|
if(data)
|
|
|
|
*max_len = len * sizeof(**data);
|
|
|
|
else
|
|
|
|
*max_len = len;
|
2012-09-05 12:01:15 +02:00
|
|
|
|
2012-09-05 12:00:55 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2012-09-04 13:37:59 +02:00
|
|
|
#else
|
2016-01-25 15:47:10 +01:00
|
|
|
static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **data,
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX **dataex, DWORD *max_len)
|
2012-09-04 13:37:59 +02:00
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-07-12 00:57:51 +02:00
|
|
|
#ifdef linux
|
|
|
|
|
|
|
|
static inline void copy_smbios_string(char **buffer, char *s, size_t len)
|
|
|
|
{
|
|
|
|
if (!len) return;
|
|
|
|
memcpy(*buffer, s, len + 1);
|
|
|
|
*buffer += len + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t get_smbios_string(const char *path, char *str, size_t size)
|
|
|
|
{
|
|
|
|
FILE *file;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if (!(file = fopen(path, "r")))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
len = fread(str, 1, size - 1, file);
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
if (len >= 1 && str[len - 1] == '\n')
|
|
|
|
len--;
|
|
|
|
|
|
|
|
str[len] = 0;
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti, ULONG available_len, ULONG *required_len)
|
|
|
|
{
|
|
|
|
switch (sfti->ProviderSignature)
|
|
|
|
{
|
|
|
|
case RSMB:
|
|
|
|
{
|
|
|
|
char bios_vendor[128], bios_version[128], bios_date[128];
|
|
|
|
size_t bios_vendor_len, bios_version_len, bios_date_len;
|
2018-07-12 00:57:53 +02:00
|
|
|
char system_vendor[128], system_product[128], system_version[128], system_serial[128];
|
|
|
|
size_t system_vendor_len, system_product_len, system_version_len, system_serial_len;
|
2018-07-12 00:57:54 +02:00
|
|
|
char board_vendor[128], board_product[128], board_version[128], board_serial[128];
|
|
|
|
size_t board_vendor_len, board_product_len, board_version_len, board_serial_len;
|
2018-07-12 00:57:55 +02:00
|
|
|
char chassis_vendor[128], chassis_version[128], chassis_serial[128], chassis_asset_tag[128];
|
|
|
|
size_t chassis_vendor_len, chassis_version_len, chassis_serial_len, chassis_asset_tag_len;
|
2018-07-12 00:57:51 +02:00
|
|
|
char *buffer = (char*)sfti->TableBuffer;
|
|
|
|
BYTE string_count;
|
|
|
|
struct smbios_prologue *prologue;
|
|
|
|
struct smbios_bios *bios;
|
2018-07-12 00:57:53 +02:00
|
|
|
struct smbios_system *system;
|
2018-07-12 00:57:54 +02:00
|
|
|
struct smbios_board *board;
|
2018-07-12 00:57:55 +02:00
|
|
|
struct smbios_chassis *chassis;
|
2018-07-12 00:57:51 +02:00
|
|
|
|
|
|
|
#define S(s) s, sizeof(s)
|
|
|
|
bios_vendor_len = get_smbios_string("/sys/class/dmi/id/bios_vendor", S(bios_vendor));
|
|
|
|
bios_version_len = get_smbios_string("/sys/class/dmi/id/bios_version", S(bios_version));
|
|
|
|
bios_date_len = get_smbios_string("/sys/class/dmi/id/bios_date", S(bios_date));
|
2018-07-12 00:57:53 +02:00
|
|
|
system_vendor_len = get_smbios_string("/sys/class/dmi/id/sys_vendor", S(system_vendor));
|
|
|
|
system_product_len = get_smbios_string("/sys/class/dmi/id/product", S(system_product));
|
|
|
|
system_version_len = get_smbios_string("/sys/class/dmi/id/product_version", S(system_version));
|
|
|
|
system_serial_len = get_smbios_string("/sys/class/dmi/id/product_serial", S(system_serial));
|
2018-07-12 00:57:54 +02:00
|
|
|
board_vendor_len = get_smbios_string("/sys/class/dmi/id/board_vendor", S(board_vendor));
|
|
|
|
board_product_len = get_smbios_string("/sys/class/dmi/id/board_name", S(board_product));
|
|
|
|
board_version_len = get_smbios_string("/sys/class/dmi/id/board_version", S(board_version));
|
|
|
|
board_serial_len = get_smbios_string("/sys/class/dmi/id/board_serial", S(board_serial));
|
2018-07-12 00:57:55 +02:00
|
|
|
chassis_vendor_len = get_smbios_string("/sys/class/dmi/id/chassis_vendor", S(chassis_vendor));
|
|
|
|
chassis_version_len = get_smbios_string("/sys/class/dmi/id/chassis_version", S(chassis_version));
|
|
|
|
chassis_serial_len = get_smbios_string("/sys/class/dmi/id/chassis_serial", S(chassis_serial));
|
|
|
|
chassis_asset_tag_len = get_smbios_string("/sys/class/dmi/id/chassis_tag", S(chassis_asset_tag));
|
2018-07-12 00:57:51 +02:00
|
|
|
#undef S
|
|
|
|
|
|
|
|
*required_len = sizeof(struct smbios_prologue);
|
|
|
|
|
|
|
|
*required_len += sizeof(struct smbios_bios);
|
|
|
|
*required_len += max(bios_vendor_len + bios_version_len + bios_date_len + 4, 2);
|
|
|
|
|
2018-07-12 00:57:53 +02:00
|
|
|
*required_len += sizeof(struct smbios_system);
|
|
|
|
*required_len += max(system_vendor_len + system_product_len + system_version_len +
|
|
|
|
system_serial_len + 5, 2);
|
|
|
|
|
2018-07-12 00:57:54 +02:00
|
|
|
*required_len += sizeof(struct smbios_board);
|
|
|
|
*required_len += max(board_vendor_len + board_product_len + board_version_len + board_serial_len + 5, 2);
|
|
|
|
|
2018-07-12 00:57:55 +02:00
|
|
|
*required_len += sizeof(struct smbios_chassis);
|
|
|
|
*required_len += max(chassis_vendor_len + chassis_version_len + chassis_serial_len +
|
|
|
|
chassis_asset_tag_len + 5, 2);
|
|
|
|
|
2018-07-12 00:57:51 +02:00
|
|
|
sfti->TableBufferLength = *required_len;
|
|
|
|
|
|
|
|
*required_len += FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
|
|
|
|
|
|
|
|
if (available_len < *required_len)
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
|
|
|
|
prologue = (struct smbios_prologue*)buffer;
|
|
|
|
prologue->calling_method = 0;
|
|
|
|
prologue->major_version = 2;
|
|
|
|
prologue->minor_version = 0;
|
|
|
|
prologue->revision = 0;
|
|
|
|
prologue->length = sfti->TableBufferLength - sizeof(struct smbios_prologue);
|
|
|
|
buffer += sizeof(struct smbios_prologue);
|
|
|
|
|
|
|
|
string_count = 0;
|
|
|
|
bios = (struct smbios_bios*)buffer;
|
|
|
|
bios->type = 0;
|
|
|
|
bios->length = sizeof(struct smbios_bios);
|
|
|
|
bios->handle = 0;
|
|
|
|
bios->vendor = bios_vendor_len ? ++string_count : 0;
|
|
|
|
bios->version = bios_version_len ? ++string_count : 0;
|
|
|
|
bios->start = 0;
|
|
|
|
bios->date = bios_date_len ? ++string_count : 0;
|
|
|
|
bios->size = 0;
|
|
|
|
bios->characteristics = 0x4; /* not supported */
|
|
|
|
buffer += sizeof(struct smbios_bios);
|
|
|
|
|
|
|
|
copy_smbios_string(&buffer, bios_vendor, bios_vendor_len);
|
|
|
|
copy_smbios_string(&buffer, bios_version, bios_version_len);
|
|
|
|
copy_smbios_string(&buffer, bios_date, bios_date_len);
|
|
|
|
if (!string_count) *buffer++ = 0;
|
|
|
|
*buffer++ = 0;
|
|
|
|
|
2018-07-12 00:57:53 +02:00
|
|
|
string_count = 0;
|
|
|
|
system = (struct smbios_system*)buffer;
|
|
|
|
system->type = 1;
|
|
|
|
system->length = sizeof(struct smbios_system);
|
|
|
|
system->handle = 0;
|
|
|
|
system->vendor = system_vendor_len ? ++string_count : 0;
|
|
|
|
system->product = system_product_len ? ++string_count : 0;
|
|
|
|
system->version = system_version_len ? ++string_count : 0;
|
|
|
|
system->serial = system_serial_len ? ++string_count : 0;
|
|
|
|
buffer += sizeof(struct smbios_system);
|
|
|
|
|
|
|
|
copy_smbios_string(&buffer, system_vendor, system_vendor_len);
|
|
|
|
copy_smbios_string(&buffer, system_product, system_product_len);
|
|
|
|
copy_smbios_string(&buffer, system_version, system_version_len);
|
|
|
|
copy_smbios_string(&buffer, system_serial, system_serial_len);
|
|
|
|
if (!string_count) *buffer++ = 0;
|
|
|
|
*buffer++ = 0;
|
|
|
|
|
2018-07-12 00:57:54 +02:00
|
|
|
string_count = 0;
|
|
|
|
board = (struct smbios_board*)buffer;
|
|
|
|
board->type = 2;
|
|
|
|
board->length = sizeof(struct smbios_board);
|
|
|
|
board->handle = 0;
|
|
|
|
board->vendor = board_vendor_len ? ++string_count : 0;
|
|
|
|
board->product = board_product_len ? ++string_count : 0;
|
|
|
|
board->version = board_version_len ? ++string_count : 0;
|
|
|
|
board->serial = board_serial_len ? ++string_count : 0;
|
|
|
|
buffer += sizeof(struct smbios_board);
|
|
|
|
|
|
|
|
copy_smbios_string(&buffer, board_vendor, board_vendor_len);
|
|
|
|
copy_smbios_string(&buffer, board_product, board_product_len);
|
|
|
|
copy_smbios_string(&buffer, board_version, board_version_len);
|
|
|
|
copy_smbios_string(&buffer, board_serial, board_serial_len);
|
|
|
|
if (!string_count) *buffer++ = 0;
|
|
|
|
*buffer++ = 0;
|
|
|
|
|
2018-07-12 00:57:55 +02:00
|
|
|
string_count = 0;
|
|
|
|
chassis = (struct smbios_chassis*)buffer;
|
|
|
|
chassis->type = 3;
|
|
|
|
chassis->length = sizeof(struct smbios_chassis);
|
|
|
|
chassis->handle = 0;
|
|
|
|
chassis->vendor = chassis_vendor_len ? ++string_count : 0;
|
|
|
|
chassis->shape = 0x2; /* unknown */
|
|
|
|
chassis->version = chassis_version_len ? ++string_count : 0;
|
|
|
|
chassis->serial = chassis_serial_len ? ++string_count : 0;
|
|
|
|
chassis->asset_tag = chassis_asset_tag_len ? ++string_count : 0;
|
|
|
|
buffer += sizeof(struct smbios_chassis);
|
|
|
|
|
|
|
|
copy_smbios_string(&buffer, chassis_vendor, chassis_vendor_len);
|
|
|
|
copy_smbios_string(&buffer, chassis_version, chassis_version_len);
|
|
|
|
copy_smbios_string(&buffer, chassis_serial, chassis_serial_len);
|
|
|
|
copy_smbios_string(&buffer, chassis_asset_tag, chassis_asset_tag_len);
|
|
|
|
if (!string_count) *buffer++ = 0;
|
|
|
|
*buffer++ = 0;
|
|
|
|
|
2018-07-12 00:57:51 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
FIXME("info_class SYSTEM_FIRMWARE_TABLE_INFORMATION provider %08x\n", sfti->ProviderSignature);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti, ULONG available_len, ULONG *required_len)
|
|
|
|
{
|
|
|
|
FIXME("info_class SYSTEM_FIRMWARE_TABLE_INFORMATION\n");
|
|
|
|
sfti->TableBufferLength = 0;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-01-24 17:33:16 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RtlIsProcessorFeaturePresent [NTDLL.@]
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlIsProcessorFeaturePresent( UINT feature )
|
|
|
|
{
|
|
|
|
return feature < PROCESSOR_FEATURE_MAX && user_shared_data->ProcessorFeatures[feature];
|
|
|
|
}
|
|
|
|
|
1998-12-24 15:34:55 +01:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtQuerySystemInformation [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwQuerySystemInformation [NTDLL.@]
|
1999-03-09 18:47:51 +01:00
|
|
|
*
|
|
|
|
* ARGUMENTS:
|
|
|
|
* SystemInformationClass Index to a certain information structure
|
|
|
|
* SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
|
|
|
|
* SystemCacheInformation SYSTEM_CACHE_INFORMATION
|
|
|
|
* SystemConfigurationInformation CONFIGURATION_INFORMATION
|
2002-06-01 01:06:46 +02:00
|
|
|
* observed (class/len):
|
1999-03-09 18:47:51 +01:00
|
|
|
* 0x0/0x2c
|
|
|
|
* 0x12/0x18
|
|
|
|
* 0x2/0x138
|
|
|
|
* 0x8/0x600
|
2000-12-06 20:45:07 +01:00
|
|
|
* 0x25/0xc
|
1999-03-09 18:47:51 +01:00
|
|
|
* SystemInformation caller supplies storage for the information structure
|
|
|
|
* Length size of the structure
|
|
|
|
* ResultLength Data written
|
1999-02-13 08:35:31 +01:00
|
|
|
*/
|
1999-03-09 18:47:51 +01:00
|
|
|
NTSTATUS WINAPI NtQuerySystemInformation(
|
|
|
|
IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
|
|
|
|
OUT PVOID SystemInformation,
|
|
|
|
IN ULONG Length,
|
|
|
|
OUT PULONG ResultLength)
|
1999-02-13 08:35:31 +01:00
|
|
|
{
|
2003-09-16 03:07:21 +02:00
|
|
|
NTSTATUS ret = STATUS_SUCCESS;
|
|
|
|
ULONG len = 0;
|
|
|
|
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(0x%08x,%p,0x%08x,%p)\n",
|
2003-09-16 03:07:21 +02:00
|
|
|
SystemInformationClass,SystemInformation,Length,ResultLength);
|
|
|
|
|
|
|
|
switch (SystemInformationClass)
|
2000-12-06 20:45:07 +01:00
|
|
|
{
|
2003-09-16 03:07:21 +02:00
|
|
|
case SystemBasicInformation:
|
|
|
|
{
|
2005-04-15 16:12:54 +02:00
|
|
|
SYSTEM_BASIC_INFORMATION sbi;
|
|
|
|
|
2008-11-03 13:23:48 +01:00
|
|
|
virtual_get_system_info( &sbi );
|
2005-04-15 16:12:54 +02:00
|
|
|
len = sizeof(sbi);
|
|
|
|
|
2005-06-15 12:19:34 +02:00
|
|
|
if ( Length == len)
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
2005-04-15 16:12:54 +02:00
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else memcpy( SystemInformation, &sbi, len);
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
|
|
|
break;
|
2005-01-28 13:34:20 +01:00
|
|
|
case SystemCpuInformation:
|
2019-02-14 19:41:34 +01:00
|
|
|
if (Length >= (len = sizeof(cpu_info)))
|
2005-01-28 13:34:20 +01:00
|
|
|
{
|
2009-09-15 21:38:07 +02:00
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
2019-02-14 19:41:34 +01:00
|
|
|
else memcpy(SystemInformation, &cpu_info, len);
|
2005-01-28 13:34:20 +01:00
|
|
|
}
|
2009-09-15 21:38:07 +02:00
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
2005-01-28 13:34:20 +01:00
|
|
|
break;
|
2003-09-16 03:07:21 +02:00
|
|
|
case SystemPerformanceInformation:
|
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
SYSTEM_PERFORMANCE_INFORMATION spi;
|
2008-11-28 15:33:34 +01:00
|
|
|
static BOOL fixme_written = FALSE;
|
2010-11-19 18:57:08 +01:00
|
|
|
FILE *fp;
|
2005-07-05 13:46:37 +02:00
|
|
|
|
|
|
|
memset(&spi, 0 , sizeof(spi));
|
|
|
|
len = sizeof(spi);
|
|
|
|
|
2010-03-29 13:31:07 +02:00
|
|
|
spi.Reserved3 = 0x7fffffff; /* Available paged pool memory? */
|
|
|
|
|
2010-11-19 18:57:08 +01:00
|
|
|
if ((fp = fopen("/proc/uptime", "r")))
|
|
|
|
{
|
|
|
|
double uptime, idle_time;
|
|
|
|
|
|
|
|
fscanf(fp, "%lf %lf", &uptime, &idle_time);
|
|
|
|
fclose(fp);
|
|
|
|
spi.IdleTime.QuadPart = 10000000 * idle_time;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
static ULONGLONG idle;
|
|
|
|
/* many programs expect IdleTime to change so fake change */
|
|
|
|
spi.IdleTime.QuadPart = ++idle;
|
|
|
|
}
|
|
|
|
|
2019-04-16 11:27:16 +02:00
|
|
|
if ((fp = fopen("/proc/meminfo", "r")))
|
|
|
|
{
|
2019-04-23 17:10:47 +02:00
|
|
|
unsigned long long totalram, freeram, totalswap, freeswap;
|
2019-04-16 11:27:16 +02:00
|
|
|
char line[64];
|
|
|
|
while (fgets(line, sizeof(line), fp))
|
|
|
|
{
|
|
|
|
if(sscanf(line, "MemTotal: %llu kB", &totalram) == 1)
|
|
|
|
{
|
|
|
|
totalram *= 1024;
|
|
|
|
}
|
|
|
|
else if(sscanf(line, "MemFree: %llu kB", &freeram) == 1)
|
|
|
|
{
|
|
|
|
freeram *= 1024;
|
|
|
|
}
|
|
|
|
else if(sscanf(line, "SwapTotal: %llu kB", &totalswap) == 1)
|
|
|
|
{
|
|
|
|
totalswap *= 1024;
|
|
|
|
}
|
|
|
|
else if(sscanf(line, "SwapFree: %llu kB", &freeswap) == 1)
|
|
|
|
{
|
|
|
|
freeswap *= 1024;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
spi.AvailablePages = freeram / page_size;
|
|
|
|
spi.TotalCommittedPages = (totalram + totalswap - freeram - freeswap) / page_size;
|
|
|
|
spi.TotalCommitLimit = (totalram + totalswap) / page_size;
|
|
|
|
}
|
|
|
|
|
2005-07-05 13:46:37 +02:00
|
|
|
if (Length >= len)
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else memcpy( SystemInformation, &spi, len);
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
2008-11-28 15:33:34 +01:00
|
|
|
if(!fixme_written) {
|
|
|
|
FIXME("info_class SYSTEM_PERFORMANCE_INFORMATION\n");
|
|
|
|
fixme_written = TRUE;
|
|
|
|
}
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SystemTimeOfDayInformation:
|
|
|
|
{
|
2005-06-13 13:34:56 +02:00
|
|
|
SYSTEM_TIMEOFDAY_INFORMATION sti;
|
|
|
|
|
|
|
|
memset(&sti, 0 , sizeof(sti));
|
|
|
|
|
|
|
|
/* liKeSystemTime, liExpTimeZoneBias, uCurrentTimeZoneId */
|
2007-04-17 20:08:59 +02:00
|
|
|
sti.liKeBootTime.QuadPart = server_start_time;
|
2005-06-13 13:34:56 +02:00
|
|
|
|
|
|
|
if (Length <= sizeof(sti))
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
2005-06-13 13:34:56 +02:00
|
|
|
len = Length;
|
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else memcpy( SystemInformation, &sti, Length);
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SystemProcessInformation:
|
|
|
|
{
|
2009-03-17 00:12:11 +01:00
|
|
|
SYSTEM_PROCESS_INFORMATION* spi = SystemInformation;
|
2003-09-16 03:07:21 +02:00
|
|
|
SYSTEM_PROCESS_INFORMATION* last = NULL;
|
|
|
|
HANDLE hSnap = 0;
|
2003-09-30 03:04:19 +02:00
|
|
|
WCHAR procname[1024];
|
2005-06-16 11:44:39 +02:00
|
|
|
WCHAR* exename;
|
2003-09-30 03:04:19 +02:00
|
|
|
DWORD wlen = 0;
|
2005-06-09 22:33:45 +02:00
|
|
|
DWORD procstructlen = 0;
|
2003-09-16 03:07:21 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( create_snapshot )
|
|
|
|
{
|
2005-12-09 12:09:44 +01:00
|
|
|
req->flags = SNAP_PROCESS | SNAP_THREAD;
|
|
|
|
req->attributes = 0;
|
2008-12-08 16:05:17 +01:00
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
hSnap = wine_server_ptr_handle( reply->handle );
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
len = 0;
|
|
|
|
while (ret == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( next_process )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( hSnap );
|
2003-09-16 03:07:21 +02:00
|
|
|
req->reset = (len == 0);
|
2005-06-16 11:44:39 +02:00
|
|
|
wine_server_set_reply( req, procname, sizeof(procname)-sizeof(WCHAR) );
|
2003-09-16 03:07:21 +02:00
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
{
|
2005-06-16 11:44:39 +02:00
|
|
|
/* Make sure procname is 0 terminated */
|
|
|
|
procname[wine_server_reply_size(reply) / sizeof(WCHAR)] = 0;
|
|
|
|
|
|
|
|
/* Get only the executable name, not the path */
|
|
|
|
if ((exename = strrchrW(procname, '\\')) != NULL) exename++;
|
|
|
|
else exename = procname;
|
|
|
|
|
|
|
|
wlen = (strlenW(exename) + 1) * sizeof(WCHAR);
|
|
|
|
|
2005-06-09 22:33:45 +02:00
|
|
|
procstructlen = sizeof(*spi) + wlen + ((reply->threads - 1) * sizeof(SYSTEM_THREAD_INFORMATION));
|
2005-06-16 11:44:39 +02:00
|
|
|
|
2005-06-09 22:33:45 +02:00
|
|
|
if (Length >= len + procstructlen)
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
2005-06-07 22:01:48 +02:00
|
|
|
/* ftCreationTime, ftUserTime, ftKernelTime;
|
2005-06-03 13:24:43 +02:00
|
|
|
* vmCounters, ioCounters
|
|
|
|
*/
|
|
|
|
|
2003-09-16 03:07:21 +02:00
|
|
|
memset(spi, 0, sizeof(*spi));
|
2005-06-03 13:24:43 +02:00
|
|
|
|
2009-01-03 14:54:11 +01:00
|
|
|
spi->NextEntryOffset = procstructlen - wlen;
|
2003-09-16 03:07:21 +02:00
|
|
|
spi->dwThreadCount = reply->threads;
|
2005-06-03 13:24:43 +02:00
|
|
|
|
2003-09-16 03:07:21 +02:00
|
|
|
/* spi->pszProcessName will be set later on */
|
2005-06-03 13:24:43 +02:00
|
|
|
|
2003-09-16 03:07:21 +02:00
|
|
|
spi->dwBasePriority = reply->priority;
|
2009-01-03 14:54:11 +01:00
|
|
|
spi->UniqueProcessId = UlongToHandle(reply->pid);
|
|
|
|
spi->ParentProcessId = UlongToHandle(reply->ppid);
|
|
|
|
spi->HandleCount = reply->handles;
|
2005-06-03 13:24:43 +02:00
|
|
|
|
2003-09-16 03:07:21 +02:00
|
|
|
/* spi->ti will be set later on */
|
2005-06-03 13:24:43 +02:00
|
|
|
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
2012-10-23 16:52:35 +02:00
|
|
|
len += procstructlen;
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2005-06-09 22:33:45 +02:00
|
|
|
|
2003-09-16 03:07:21 +02:00
|
|
|
if (ret != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
|
|
|
|
break;
|
|
|
|
}
|
2012-10-23 16:52:35 +02:00
|
|
|
|
|
|
|
if (Length >= len)
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
/* set thread info */
|
|
|
|
i = j = 0;
|
|
|
|
while (ret == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
SERVER_START_REQ( next_thread )
|
|
|
|
{
|
2008-12-08 16:05:17 +01:00
|
|
|
req->handle = wine_server_obj_handle( hSnap );
|
2003-09-16 03:07:21 +02:00
|
|
|
req->reset = (j == 0);
|
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
j++;
|
2009-01-03 14:54:11 +01:00
|
|
|
if (UlongToHandle(reply->pid) == spi->UniqueProcessId)
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
|
|
|
/* ftKernelTime, ftUserTime, ftCreateTime;
|
|
|
|
* dwTickCount, dwStartAddress
|
|
|
|
*/
|
2005-06-07 22:01:48 +02:00
|
|
|
|
|
|
|
memset(&spi->ti[i], 0, sizeof(spi->ti));
|
|
|
|
|
2009-01-03 14:54:11 +01:00
|
|
|
spi->ti[i].CreateTime.QuadPart = 0xdeadbeef;
|
|
|
|
spi->ti[i].ClientId.UniqueProcess = UlongToHandle(reply->pid);
|
|
|
|
spi->ti[i].ClientId.UniqueThread = UlongToHandle(reply->tid);
|
2003-09-16 03:07:21 +02:00
|
|
|
spi->ti[i].dwCurrentPriority = reply->base_pri + reply->delta_pri;
|
|
|
|
spi->ti[i].dwBasePriority = reply->base_pri;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
|
|
|
if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
/* now append process name */
|
2009-01-03 14:54:11 +01:00
|
|
|
spi->ProcessName.Buffer = (WCHAR*)((char*)spi + spi->NextEntryOffset);
|
2005-06-06 17:42:08 +02:00
|
|
|
spi->ProcessName.Length = wlen - sizeof(WCHAR);
|
|
|
|
spi->ProcessName.MaximumLength = wlen;
|
2005-06-16 11:44:39 +02:00
|
|
|
memcpy( spi->ProcessName.Buffer, exename, wlen );
|
2009-01-03 14:54:11 +01:00
|
|
|
spi->NextEntryOffset += wlen;
|
2003-09-16 03:07:21 +02:00
|
|
|
|
|
|
|
last = spi;
|
2009-01-03 14:54:11 +01:00
|
|
|
spi = (SYSTEM_PROCESS_INFORMATION*)((char*)spi + spi->NextEntryOffset);
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
}
|
2009-01-03 14:54:11 +01:00
|
|
|
if (ret == STATUS_SUCCESS && last) last->NextEntryOffset = 0;
|
2012-10-23 16:52:35 +02:00
|
|
|
if (len > Length) ret = STATUS_INFO_LENGTH_MISMATCH;
|
2003-09-16 03:07:21 +02:00
|
|
|
if (hSnap) NtClose(hSnap);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SystemProcessorPerformanceInformation:
|
|
|
|
{
|
2008-10-17 22:25:30 +02:00
|
|
|
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION *sppi = NULL;
|
|
|
|
unsigned int cpus = 0;
|
|
|
|
int out_cpus = Length / sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
|
|
|
|
|
|
|
|
if (out_cpus == 0)
|
|
|
|
{
|
|
|
|
len = 0;
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#ifdef __APPLE__
|
|
|
|
{
|
|
|
|
processor_cpu_load_info_data_t *pinfo;
|
|
|
|
mach_msg_type_number_t info_count;
|
|
|
|
|
|
|
|
if (host_processor_info (mach_host_self (),
|
|
|
|
PROCESSOR_CPU_LOAD_INFO,
|
|
|
|
&cpus,
|
|
|
|
(processor_info_array_t*)&pinfo,
|
|
|
|
&info_count) == 0)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
cpus = min(cpus,out_cpus);
|
|
|
|
len = sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * cpus;
|
2016-10-24 15:11:55 +02:00
|
|
|
sppi = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
2008-10-17 22:25:30 +02:00
|
|
|
for (i = 0; i < cpus; i++)
|
|
|
|
{
|
2009-08-28 21:15:22 +02:00
|
|
|
sppi[i].IdleTime.QuadPart = pinfo[i].cpu_ticks[CPU_STATE_IDLE];
|
|
|
|
sppi[i].KernelTime.QuadPart = pinfo[i].cpu_ticks[CPU_STATE_SYSTEM];
|
|
|
|
sppi[i].UserTime.QuadPart = pinfo[i].cpu_ticks[CPU_STATE_USER];
|
2008-10-17 22:25:30 +02:00
|
|
|
}
|
2008-10-31 21:17:17 +01:00
|
|
|
vm_deallocate (mach_task_self (), (vm_address_t) pinfo, info_count * sizeof(natural_t));
|
2008-10-17 22:25:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
{
|
2009-09-15 21:38:07 +02:00
|
|
|
FILE *cpuinfo = fopen("/proc/stat", "r");
|
2008-10-17 22:25:30 +02:00
|
|
|
if (cpuinfo)
|
|
|
|
{
|
2011-04-15 10:54:28 +02:00
|
|
|
unsigned long clk_tck = sysconf(_SC_CLK_TCK);
|
2011-02-23 14:12:22 +01:00
|
|
|
unsigned long usr,nice,sys,idle,remainder[8];
|
2011-04-15 10:54:28 +02:00
|
|
|
int i, count;
|
|
|
|
char name[32];
|
2008-10-31 21:17:17 +01:00
|
|
|
char line[255];
|
2008-10-17 22:25:30 +02:00
|
|
|
|
|
|
|
/* first line is combined usage */
|
2011-04-15 10:54:28 +02:00
|
|
|
while (fgets(line,255,cpuinfo))
|
2008-10-17 22:25:30 +02:00
|
|
|
{
|
2011-04-15 10:54:28 +02:00
|
|
|
count = sscanf(line, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
|
|
|
|
name, &usr, &nice, &sys, &idle,
|
|
|
|
&remainder[0], &remainder[1], &remainder[2], &remainder[3],
|
|
|
|
&remainder[4], &remainder[5], &remainder[6], &remainder[7]);
|
|
|
|
|
|
|
|
if (count < 5 || strncmp( name, "cpu", 3 )) break;
|
|
|
|
for (i = 0; i + 5 < count; ++i) sys += remainder[i];
|
|
|
|
sys += idle;
|
2011-02-23 14:12:22 +01:00
|
|
|
usr += nice;
|
2011-04-15 10:54:28 +02:00
|
|
|
cpus = atoi( name + 3 ) + 1;
|
|
|
|
if (cpus > out_cpus) break;
|
|
|
|
len = sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * cpus;
|
|
|
|
if (sppi)
|
|
|
|
sppi = RtlReAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, sppi, len );
|
2008-10-31 21:17:17 +01:00
|
|
|
else
|
2011-04-15 10:54:28 +02:00
|
|
|
sppi = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
|
|
|
|
|
|
|
|
sppi[cpus-1].IdleTime.QuadPart = (ULONGLONG)idle * 10000000 / clk_tck;
|
|
|
|
sppi[cpus-1].KernelTime.QuadPart = (ULONGLONG)sys * 10000000 / clk_tck;
|
|
|
|
sppi[cpus-1].UserTime.QuadPart = (ULONGLONG)usr * 10000000 / clk_tck;
|
|
|
|
}
|
2008-10-17 22:25:30 +02:00
|
|
|
fclose(cpuinfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (cpus == 0)
|
|
|
|
{
|
|
|
|
static int i = 1;
|
2013-02-20 22:25:56 +01:00
|
|
|
unsigned int n;
|
2011-01-03 20:27:00 +01:00
|
|
|
cpus = min(NtCurrentTeb()->Peb->NumberOfProcessors, out_cpus);
|
|
|
|
len = sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * cpus;
|
2016-10-24 15:11:55 +02:00
|
|
|
sppi = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
2008-10-17 22:25:30 +02:00
|
|
|
FIXME("stub info_class SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION\n");
|
|
|
|
/* many programs expect these values to change so fake change */
|
2011-01-03 20:27:00 +01:00
|
|
|
for (n = 0; n < cpus; n++)
|
|
|
|
{
|
|
|
|
sppi[n].KernelTime.QuadPart = 1 * i;
|
|
|
|
sppi[n].UserTime.QuadPart = 2 * i;
|
|
|
|
sppi[n].IdleTime.QuadPart = 3 * i;
|
|
|
|
}
|
2008-10-17 22:25:30 +02:00
|
|
|
i++;
|
|
|
|
}
|
2005-07-05 13:46:37 +02:00
|
|
|
|
|
|
|
if (Length >= len)
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
2008-10-17 22:25:30 +02:00
|
|
|
else memcpy( SystemInformation, sppi, len);
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
2008-10-17 22:25:30 +02:00
|
|
|
|
|
|
|
RtlFreeHeap(GetProcessHeap(),0,sppi);
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
break;
|
2005-05-20 11:40:59 +02:00
|
|
|
case SystemModuleInformation:
|
2007-06-19 16:58:42 +02:00
|
|
|
/* FIXME: should be system-wide */
|
2007-07-04 12:07:22 +02:00
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else ret = LdrQueryProcessModuleInformation( SystemInformation, Length, &len );
|
2005-05-13 15:55:51 +02:00
|
|
|
break;
|
2005-05-10 15:15:58 +02:00
|
|
|
case SystemHandleInformation:
|
|
|
|
{
|
2015-12-24 13:08:50 +01:00
|
|
|
struct handle_info *info;
|
|
|
|
DWORD i, num_handles;
|
2005-05-10 15:15:58 +02:00
|
|
|
|
2015-12-24 13:08:50 +01:00
|
|
|
if (Length < sizeof(SYSTEM_HANDLE_INFORMATION))
|
|
|
|
{
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
break;
|
|
|
|
}
|
2003-09-16 03:07:21 +02:00
|
|
|
|
2015-12-24 13:08:50 +01:00
|
|
|
if (!SystemInformation)
|
2005-05-10 15:15:58 +02:00
|
|
|
{
|
2015-12-24 13:08:50 +01:00
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
break;
|
2005-05-10 15:15:58 +02:00
|
|
|
}
|
2015-12-24 13:08:50 +01:00
|
|
|
|
|
|
|
num_handles = (Length - FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION, Handle )) / sizeof(SYSTEM_HANDLE_ENTRY);
|
|
|
|
if (!(info = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*info) * num_handles )))
|
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_system_handles )
|
|
|
|
{
|
|
|
|
wine_server_set_reply( req, info, sizeof(*info) * num_handles );
|
|
|
|
if (!(ret = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
SYSTEM_HANDLE_INFORMATION *shi = SystemInformation;
|
|
|
|
shi->Count = wine_server_reply_size( req ) / sizeof(*info);
|
|
|
|
len = FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION, Handle[shi->Count] );
|
|
|
|
for (i = 0; i < shi->Count; i++)
|
|
|
|
{
|
|
|
|
memset( &shi->Handle[i], 0, sizeof(shi->Handle[i]) );
|
|
|
|
shi->Handle[i].OwnerPid = info[i].owner;
|
|
|
|
shi->Handle[i].HandleValue = info[i].handle;
|
|
|
|
shi->Handle[i].AccessMask = info[i].access;
|
|
|
|
/* FIXME: Fill out ObjectType, HandleFlags, ObjectPointer */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ret == STATUS_BUFFER_TOO_SMALL)
|
|
|
|
{
|
|
|
|
len = FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION, Handle[reply->count] );
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, info );
|
2005-05-10 15:15:58 +02:00
|
|
|
}
|
|
|
|
break;
|
2003-09-16 03:07:21 +02:00
|
|
|
case SystemCacheInformation:
|
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
SYSTEM_CACHE_INFORMATION sci;
|
|
|
|
|
|
|
|
memset(&sci, 0, sizeof(sci)); /* FIXME */
|
|
|
|
len = sizeof(sci);
|
|
|
|
|
|
|
|
if ( Length >= len)
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else memcpy( SystemInformation, &sci, len);
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
2007-10-28 00:02:41 +02:00
|
|
|
FIXME("info_class SYSTEM_CACHE_INFORMATION\n");
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
break;
|
2005-05-13 15:55:51 +02:00
|
|
|
case SystemInterruptInformation:
|
|
|
|
{
|
|
|
|
SYSTEM_INTERRUPT_INFORMATION sii;
|
|
|
|
|
|
|
|
memset(&sii, 0, sizeof(sii));
|
|
|
|
len = sizeof(sii);
|
|
|
|
|
|
|
|
if ( Length >= len)
|
|
|
|
{
|
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else memcpy( SystemInformation, &sii, len);
|
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
2007-10-28 00:02:41 +02:00
|
|
|
FIXME("info_class SYSTEM_INTERRUPT_INFORMATION\n");
|
2005-05-13 15:55:51 +02:00
|
|
|
}
|
|
|
|
break;
|
2005-05-10 15:15:58 +02:00
|
|
|
case SystemKernelDebuggerInformation:
|
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi;
|
|
|
|
|
|
|
|
skdi.DebuggerEnabled = FALSE;
|
|
|
|
skdi.DebuggerNotPresent = TRUE;
|
|
|
|
len = sizeof(skdi);
|
|
|
|
|
|
|
|
if ( Length >= len)
|
2005-05-10 15:15:58 +02:00
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else memcpy( SystemInformation, &skdi, len);
|
2005-05-10 15:15:58 +02:00
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
|
|
|
break;
|
2003-09-16 03:07:21 +02:00
|
|
|
case SystemRegistryQuotaInformation:
|
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
/* Something to do with the size of the registry *
|
|
|
|
* Since we don't have a size limitation, fake it *
|
|
|
|
* This is almost certainly wrong. *
|
|
|
|
* This sets each of the three words in the struct to 32 MB, *
|
|
|
|
* which is enough to make the IE 5 installer happy. */
|
|
|
|
SYSTEM_REGISTRY_QUOTA_INFORMATION srqi;
|
|
|
|
|
|
|
|
srqi.RegistryQuotaAllowed = 0x2000000;
|
|
|
|
srqi.RegistryQuotaUsed = 0x200000;
|
|
|
|
srqi.Reserved1 = (void*)0x200000;
|
|
|
|
len = sizeof(srqi);
|
|
|
|
|
|
|
|
if ( Length >= len)
|
2003-09-16 03:07:21 +02:00
|
|
|
{
|
2005-07-05 13:46:37 +02:00
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("SystemRegistryQuotaInformation: faking max registry size of 32 MB\n");
|
|
|
|
memcpy( SystemInformation, &srqi, len);
|
|
|
|
}
|
2003-09-16 03:07:21 +02:00
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
2000-12-06 20:45:07 +01:00
|
|
|
break;
|
2012-09-04 13:37:59 +02:00
|
|
|
case SystemLogicalProcessorInformation:
|
|
|
|
{
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION *buf;
|
|
|
|
|
|
|
|
/* Each logical processor may use up to 7 entries in returned table:
|
|
|
|
* core, numa node, package, L1i, L1d, L2, L3 */
|
|
|
|
len = 7 * NtCurrentTeb()->Peb->NumberOfProcessors;
|
|
|
|
buf = RtlAllocateHeap(GetProcessHeap(), 0, len * sizeof(*buf));
|
|
|
|
if(!buf)
|
|
|
|
{
|
|
|
|
ret = STATUS_NO_MEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-01-25 15:47:10 +01:00
|
|
|
ret = create_logical_proc_info(&buf, NULL, &len);
|
2012-09-04 13:37:59 +02:00
|
|
|
if( ret != STATUS_SUCCESS )
|
|
|
|
{
|
|
|
|
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Length >= len)
|
|
|
|
{
|
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else memcpy( SystemInformation, buf, len);
|
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
|
|
|
}
|
|
|
|
break;
|
2016-02-12 08:37:32 +01:00
|
|
|
case SystemRecommendedSharedDataAlignment:
|
|
|
|
{
|
|
|
|
len = sizeof(DWORD);
|
|
|
|
if (Length >= len)
|
|
|
|
{
|
|
|
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else *((DWORD *)SystemInformation) = 64;
|
|
|
|
}
|
|
|
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
}
|
|
|
|
break;
|
2018-07-12 00:57:51 +02:00
|
|
|
case SystemFirmwareTableInformation:
|
|
|
|
{
|
|
|
|
SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti = (SYSTEM_FIRMWARE_TABLE_INFORMATION*)SystemInformation;
|
|
|
|
len = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
|
|
|
|
if (Length < len)
|
|
|
|
{
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (sfti->Action)
|
|
|
|
{
|
|
|
|
case SystemFirmwareTable_Get:
|
|
|
|
ret = get_firmware_info(sfti, Length, &len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
len = 0;
|
|
|
|
ret = STATUS_NOT_IMPLEMENTED;
|
|
|
|
FIXME("info_class SYSTEM_FIRMWARE_TABLE_INFORMATION action %d\n", sfti->Action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2000-12-06 20:45:07 +01:00
|
|
|
default:
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(0x%08x,%p,0x%08x,%p) stub\n",
|
2000-12-06 20:45:07 +01:00
|
|
|
SystemInformationClass,SystemInformation,Length,ResultLength);
|
2005-04-15 16:12:54 +02:00
|
|
|
|
|
|
|
/* Several Information Classes are not implemented on Windows and return 2 different values
|
|
|
|
* STATUS_NOT_IMPLEMENTED or STATUS_INVALID_INFO_CLASS
|
|
|
|
* in 95% of the cases it's STATUS_INVALID_INFO_CLASS, so use this as the default
|
|
|
|
*/
|
|
|
|
ret = STATUS_INVALID_INFO_CLASS;
|
2000-12-06 20:45:07 +01:00
|
|
|
}
|
2005-04-15 16:12:54 +02:00
|
|
|
|
2003-09-16 03:07:21 +02:00
|
|
|
if (ResultLength) *ResultLength = len;
|
2000-12-06 20:45:07 +01:00
|
|
|
|
2003-09-16 03:07:21 +02:00
|
|
|
return ret;
|
1998-12-24 15:34:55 +01:00
|
|
|
}
|
|
|
|
|
2016-01-03 23:56:47 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* NtQuerySystemInformationEx [NTDLL.@]
|
|
|
|
* ZwQuerySystemInformationEx [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtQuerySystemInformationEx(SYSTEM_INFORMATION_CLASS SystemInformationClass,
|
|
|
|
void *Query, ULONG QueryLength, void *SystemInformation, ULONG Length, ULONG *ResultLength)
|
|
|
|
{
|
2016-02-10 19:53:42 +01:00
|
|
|
ULONG len = 0;
|
2016-01-25 15:47:10 +01:00
|
|
|
NTSTATUS ret = STATUS_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
TRACE("(0x%08x,%p,%u,%p,%u,%p) stub\n", SystemInformationClass, Query, QueryLength, SystemInformation,
|
2016-01-03 23:56:47 +01:00
|
|
|
Length, ResultLength);
|
2016-01-25 15:47:10 +01:00
|
|
|
|
|
|
|
switch (SystemInformationClass) {
|
|
|
|
case SystemLogicalProcessorInformationEx:
|
|
|
|
{
|
|
|
|
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buf;
|
|
|
|
|
|
|
|
if (!Query || QueryLength < sizeof(DWORD))
|
|
|
|
{
|
|
|
|
ret = STATUS_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*(DWORD*)Query != RelationAll)
|
|
|
|
FIXME("Relationship filtering not implemented: 0x%x\n", *(DWORD*)Query);
|
|
|
|
|
|
|
|
len = 3 * sizeof(*buf);
|
|
|
|
buf = RtlAllocateHeap(GetProcessHeap(), 0, len);
|
|
|
|
if (!buf)
|
|
|
|
{
|
|
|
|
ret = STATUS_NO_MEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = create_logical_proc_info(NULL, &buf, &len);
|
|
|
|
if (ret != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Length >= len)
|
|
|
|
{
|
|
|
|
if (!SystemInformation)
|
|
|
|
ret = STATUS_ACCESS_VIOLATION;
|
|
|
|
else
|
|
|
|
memcpy( SystemInformation, buf, len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
|
|
|
|
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
FIXME("(0x%08x,%p,%u,%p,%u,%p) stub\n", SystemInformationClass, Query, QueryLength, SystemInformation,
|
|
|
|
Length, ResultLength);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ResultLength)
|
|
|
|
*ResultLength = len;
|
|
|
|
|
|
|
|
return ret;
|
2016-01-03 23:56:47 +01:00
|
|
|
}
|
|
|
|
|
2006-01-20 19:41:04 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* NtSetSystemInformation [NTDLL.@]
|
|
|
|
* ZwSetSystemInformation [NTDLL.@]
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetSystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG Length)
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(0x%08x,%p,0x%08x) stub\n",SystemInformationClass,SystemInformation,Length);
|
2006-01-20 19:41:04 +01:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
1998-11-01 15:00:21 +01:00
|
|
|
|
1999-02-13 08:35:31 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtCreatePagingFile [NTDLL.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* ZwCreatePagingFile [NTDLL.@]
|
1999-02-13 08:35:31 +01:00
|
|
|
*/
|
1999-03-09 18:47:51 +01:00
|
|
|
NTSTATUS WINAPI NtCreatePagingFile(
|
2005-06-16 12:46:11 +02:00
|
|
|
PUNICODE_STRING PageFileName,
|
2005-10-03 20:44:52 +02:00
|
|
|
PLARGE_INTEGER MinimumSize,
|
|
|
|
PLARGE_INTEGER MaximumSize,
|
2005-06-16 12:46:11 +02:00
|
|
|
PLARGE_INTEGER ActualSize)
|
1999-02-13 08:35:31 +01:00
|
|
|
{
|
2005-10-03 20:44:52 +02:00
|
|
|
FIXME("(%p %p %p %p) stub\n", PageFileName, MinimumSize, MaximumSize, ActualSize);
|
2005-06-16 12:46:11 +02:00
|
|
|
return STATUS_SUCCESS;
|
1999-02-13 08:35:31 +01:00
|
|
|
}
|
|
|
|
|
1999-04-11 16:53:24 +02:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtDisplayString [NTDLL.@]
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1999-04-11 16:53:24 +02:00
|
|
|
* writes a string to the nt-textmode screen eg. during startup
|
|
|
|
*/
|
2000-09-29 02:31:57 +02:00
|
|
|
NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
|
1999-04-11 16:53:24 +02:00
|
|
|
{
|
2000-09-29 02:31:57 +02:00
|
|
|
STRING stringA;
|
|
|
|
NTSTATUS ret;
|
|
|
|
|
|
|
|
if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
|
|
|
|
{
|
|
|
|
MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
|
|
|
|
RtlFreeAnsiString( &stringA );
|
|
|
|
}
|
|
|
|
return ret;
|
1999-04-11 16:53:24 +02:00
|
|
|
}
|
1999-12-10 04:27:15 +01:00
|
|
|
|
2005-04-16 12:45:51 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtInitiatePowerAction [NTDLL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtInitiatePowerAction(
|
|
|
|
IN POWER_ACTION SystemAction,
|
|
|
|
IN SYSTEM_POWER_STATE MinSystemState,
|
|
|
|
IN ULONG Flags,
|
|
|
|
IN BOOLEAN Asynchronous)
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%d,%d,0x%08x,%d),stub\n",
|
2005-04-16 12:45:51 +02:00
|
|
|
SystemAction,MinSystemState,Flags,Asynchronous);
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2012-09-13 23:12:15 +02:00
|
|
|
|
|
|
|
#ifdef linux
|
|
|
|
/* Fallback using /proc/cpuinfo for Linux systems without cpufreq. For
|
|
|
|
* most distributions on recent enough hardware, this is only likely to
|
|
|
|
* happen while running in virtualized environments such as QEMU. */
|
|
|
|
static ULONG mhz_from_cpuinfo(void)
|
|
|
|
{
|
|
|
|
char line[512];
|
|
|
|
char *s, *value;
|
|
|
|
double cmz = 0;
|
|
|
|
FILE* f = fopen("/proc/cpuinfo", "r");
|
|
|
|
if(f) {
|
|
|
|
while (fgets(line, sizeof(line), f) != NULL) {
|
|
|
|
if (!(value = strchr(line,':')))
|
|
|
|
continue;
|
|
|
|
s = value - 1;
|
|
|
|
while ((s >= line) && isspace(*s)) s--;
|
|
|
|
*(s + 1) = '\0';
|
|
|
|
value++;
|
2019-03-26 10:26:43 +01:00
|
|
|
if (!_stricmp(line, "cpu MHz")) {
|
2012-09-13 23:12:15 +02:00
|
|
|
sscanf(value, " %lf", &cmz);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
return cmz;
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-16 12:45:51 +02:00
|
|
|
|
1999-12-10 04:27:15 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* NtPowerInformation [NTDLL.@]
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1999-12-10 04:27:15 +01:00
|
|
|
*/
|
2005-04-16 12:45:51 +02:00
|
|
|
NTSTATUS WINAPI NtPowerInformation(
|
|
|
|
IN POWER_INFORMATION_LEVEL InformationLevel,
|
|
|
|
IN PVOID lpInputBuffer,
|
|
|
|
IN ULONG nInputBufferSize,
|
|
|
|
IN PVOID lpOutputBuffer,
|
|
|
|
IN ULONG nOutputBufferSize)
|
1999-12-10 04:27:15 +01:00
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
TRACE("(%d,%p,%d,%p,%d)\n",
|
2005-04-16 12:45:51 +02:00
|
|
|
InformationLevel,lpInputBuffer,nInputBufferSize,lpOutputBuffer,nOutputBufferSize);
|
2005-04-18 11:52:32 +02:00
|
|
|
switch(InformationLevel) {
|
|
|
|
case SystemPowerCapabilities: {
|
2009-03-17 00:12:11 +01:00
|
|
|
PSYSTEM_POWER_CAPABILITIES PowerCaps = lpOutputBuffer;
|
2005-04-18 11:52:32 +02:00
|
|
|
FIXME("semi-stub: SystemPowerCapabilities\n");
|
|
|
|
if (nOutputBufferSize < sizeof(SYSTEM_POWER_CAPABILITIES))
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
/* FIXME: These values are based off a native XP desktop, should probably use APM/ACPI to get the 'real' values */
|
|
|
|
PowerCaps->PowerButtonPresent = TRUE;
|
|
|
|
PowerCaps->SleepButtonPresent = FALSE;
|
|
|
|
PowerCaps->LidPresent = FALSE;
|
|
|
|
PowerCaps->SystemS1 = TRUE;
|
|
|
|
PowerCaps->SystemS2 = FALSE;
|
|
|
|
PowerCaps->SystemS3 = FALSE;
|
|
|
|
PowerCaps->SystemS4 = TRUE;
|
|
|
|
PowerCaps->SystemS5 = TRUE;
|
|
|
|
PowerCaps->HiberFilePresent = TRUE;
|
|
|
|
PowerCaps->FullWake = TRUE;
|
|
|
|
PowerCaps->VideoDimPresent = FALSE;
|
|
|
|
PowerCaps->ApmPresent = FALSE;
|
|
|
|
PowerCaps->UpsPresent = FALSE;
|
|
|
|
PowerCaps->ThermalControl = FALSE;
|
|
|
|
PowerCaps->ProcessorThrottle = FALSE;
|
|
|
|
PowerCaps->ProcessorMinThrottle = 100;
|
|
|
|
PowerCaps->ProcessorMaxThrottle = 100;
|
|
|
|
PowerCaps->DiskSpinDown = TRUE;
|
|
|
|
PowerCaps->SystemBatteriesPresent = FALSE;
|
|
|
|
PowerCaps->BatteriesAreShortTerm = FALSE;
|
|
|
|
PowerCaps->BatteryScale[0].Granularity = 0;
|
|
|
|
PowerCaps->BatteryScale[0].Capacity = 0;
|
|
|
|
PowerCaps->BatteryScale[1].Granularity = 0;
|
|
|
|
PowerCaps->BatteryScale[1].Capacity = 0;
|
|
|
|
PowerCaps->BatteryScale[2].Granularity = 0;
|
|
|
|
PowerCaps->BatteryScale[2].Capacity = 0;
|
|
|
|
PowerCaps->AcOnLineWake = PowerSystemUnspecified;
|
|
|
|
PowerCaps->SoftLidWake = PowerSystemUnspecified;
|
|
|
|
PowerCaps->RtcWake = PowerSystemSleeping1;
|
|
|
|
PowerCaps->MinDeviceWakeState = PowerSystemUnspecified;
|
|
|
|
PowerCaps->DefaultLowLatencyWake = PowerSystemUnspecified;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2009-07-14 18:02:59 +02:00
|
|
|
case SystemExecutionState: {
|
|
|
|
PULONG ExecutionState = lpOutputBuffer;
|
2009-08-09 00:17:15 +02:00
|
|
|
WARN("semi-stub: SystemExecutionState\n"); /* Needed for .NET Framework, but using a FIXME is really noisy. */
|
2009-07-14 18:02:59 +02:00
|
|
|
if (lpInputBuffer != NULL)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
/* FIXME: The actual state should be the value set by SetThreadExecutionState which is not currently implemented. */
|
|
|
|
*ExecutionState = ES_USER_PRESENT;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2012-09-12 21:14:27 +02:00
|
|
|
case ProcessorInformation: {
|
2012-09-13 23:12:15 +02:00
|
|
|
const int cannedMHz = 1000; /* We fake a 1GHz processor if we can't conjure up real values */
|
2012-09-12 21:14:27 +02:00
|
|
|
PROCESSOR_POWER_INFORMATION* cpu_power = lpOutputBuffer;
|
2012-09-13 23:12:15 +02:00
|
|
|
int i, out_cpus;
|
2012-09-12 21:14:27 +02:00
|
|
|
|
|
|
|
if ((lpOutputBuffer == NULL) || (nOutputBufferSize == 0))
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
2012-09-13 23:12:15 +02:00
|
|
|
out_cpus = NtCurrentTeb()->Peb->NumberOfProcessors;
|
|
|
|
if ((nOutputBufferSize / sizeof(PROCESSOR_POWER_INFORMATION)) < out_cpus)
|
2009-09-15 21:38:15 +02:00
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
2012-09-13 23:12:15 +02:00
|
|
|
#if defined(linux)
|
|
|
|
{
|
|
|
|
char filename[128];
|
|
|
|
FILE* f;
|
|
|
|
|
|
|
|
for(i = 0; i < out_cpus; i++) {
|
|
|
|
sprintf(filename, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", i);
|
|
|
|
f = fopen(filename, "r");
|
|
|
|
if (f && (fscanf(f, "%d", &cpu_power[i].CurrentMhz) == 1)) {
|
|
|
|
cpu_power[i].CurrentMhz /= 1000;
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(i == 0) {
|
|
|
|
cpu_power[0].CurrentMhz = mhz_from_cpuinfo();
|
|
|
|
if(cpu_power[0].CurrentMhz == 0)
|
|
|
|
cpu_power[0].CurrentMhz = cannedMHz;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cpu_power[i].CurrentMhz = cpu_power[0].CurrentMhz;
|
|
|
|
if(f) fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(filename, "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", i);
|
|
|
|
f = fopen(filename, "r");
|
|
|
|
if (f && (fscanf(f, "%d", &cpu_power[i].MaxMhz) == 1)) {
|
|
|
|
cpu_power[i].MaxMhz /= 1000;
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cpu_power[i].MaxMhz = cpu_power[i].CurrentMhz;
|
|
|
|
if(f) fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(filename, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", i);
|
|
|
|
f = fopen(filename, "r");
|
|
|
|
if(f && (fscanf(f, "%d", &cpu_power[i].MhzLimit) == 1)) {
|
|
|
|
cpu_power[i].MhzLimit /= 1000;
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cpu_power[i].MhzLimit = cpu_power[i].MaxMhz;
|
|
|
|
if(f) fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
cpu_power[i].Number = i;
|
|
|
|
cpu_power[i].MaxIdleState = 0; /* FIXME */
|
|
|
|
cpu_power[i].CurrentIdleState = 0; /* FIXME */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined(__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__DragonFly__)
|
|
|
|
{
|
|
|
|
int num;
|
|
|
|
size_t valSize = sizeof(num);
|
|
|
|
if (sysctlbyname("hw.clockrate", &num, &valSize, NULL, 0))
|
|
|
|
num = cannedMHz;
|
|
|
|
for(i = 0; i < out_cpus; i++) {
|
|
|
|
cpu_power[i].CurrentMhz = num;
|
|
|
|
cpu_power[i].MaxMhz = num;
|
|
|
|
cpu_power[i].MhzLimit = num;
|
|
|
|
cpu_power[i].Number = i;
|
|
|
|
cpu_power[i].MaxIdleState = 0; /* FIXME */
|
|
|
|
cpu_power[i].CurrentIdleState = 0; /* FIXME */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined (__APPLE__)
|
|
|
|
{
|
|
|
|
size_t valSize;
|
|
|
|
unsigned long long currentMhz;
|
|
|
|
unsigned long long maxMhz;
|
|
|
|
|
|
|
|
valSize = sizeof(currentMhz);
|
|
|
|
if (!sysctlbyname("hw.cpufrequency", ¤tMhz, &valSize, NULL, 0))
|
|
|
|
currentMhz /= 1000000;
|
|
|
|
else
|
|
|
|
currentMhz = cannedMHz;
|
|
|
|
|
|
|
|
valSize = sizeof(maxMhz);
|
|
|
|
if (!sysctlbyname("hw.cpufrequency_max", &maxMhz, &valSize, NULL, 0))
|
|
|
|
maxMhz /= 1000000;
|
|
|
|
else
|
|
|
|
maxMhz = currentMhz;
|
|
|
|
|
|
|
|
for(i = 0; i < out_cpus; i++) {
|
|
|
|
cpu_power[i].CurrentMhz = currentMhz;
|
|
|
|
cpu_power[i].MaxMhz = maxMhz;
|
|
|
|
cpu_power[i].MhzLimit = maxMhz;
|
|
|
|
cpu_power[i].Number = i;
|
|
|
|
cpu_power[i].MaxIdleState = 0; /* FIXME */
|
|
|
|
cpu_power[i].CurrentIdleState = 0; /* FIXME */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
for(i = 0; i < out_cpus; i++) {
|
|
|
|
cpu_power[i].CurrentMhz = cannedMHz;
|
|
|
|
cpu_power[i].MaxMhz = cannedMHz;
|
|
|
|
cpu_power[i].MhzLimit = cannedMHz;
|
2012-09-12 21:14:27 +02:00
|
|
|
cpu_power[i].Number = i;
|
|
|
|
cpu_power[i].MaxIdleState = 0; /* FIXME */
|
|
|
|
cpu_power[i].CurrentIdleState = 0; /* FIXME */
|
|
|
|
}
|
2012-09-13 23:12:15 +02:00
|
|
|
WARN("Unable to detect CPU MHz for this platform. Reporting %d MHz.\n", cannedMHz);
|
|
|
|
#endif
|
|
|
|
for(i = 0; i < out_cpus; i++) {
|
|
|
|
TRACE("cpu_power[%d] = %u %u %u %u %u %u\n", i, cpu_power[i].Number,
|
|
|
|
cpu_power[i].MaxMhz, cpu_power[i].CurrentMhz, cpu_power[i].MhzLimit,
|
|
|
|
cpu_power[i].MaxIdleState, cpu_power[i].CurrentIdleState);
|
|
|
|
}
|
2012-09-12 21:14:27 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2005-04-18 11:52:32 +02:00
|
|
|
default:
|
2009-05-21 22:07:02 +02:00
|
|
|
/* FIXME: Needed by .NET Framework */
|
|
|
|
WARN("Unimplemented NtPowerInformation action: %d\n", InformationLevel);
|
2005-04-18 11:52:32 +02:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
1999-12-10 04:27:15 +01:00
|
|
|
}
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2004-09-14 21:30:36 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* NtShutdownSystem [NTDLL.@]
|
|
|
|
*
|
|
|
|
*/
|
2005-06-16 12:46:11 +02:00
|
|
|
NTSTATUS WINAPI NtShutdownSystem(SHUTDOWN_ACTION Action)
|
2004-09-14 21:30:36 +02:00
|
|
|
{
|
2005-06-16 12:46:11 +02:00
|
|
|
FIXME("%d\n",Action);
|
|
|
|
return STATUS_SUCCESS;
|
2004-09-14 21:30:36 +02:00
|
|
|
}
|
|
|
|
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
/******************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* NtAllocateLocallyUniqueId (NTDLL.@)
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
|
|
|
|
{
|
2007-03-07 01:33:26 +01:00
|
|
|
NTSTATUS status;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2007-03-07 01:33:26 +01:00
|
|
|
TRACE("%p\n", Luid);
|
2004-11-04 05:52:17 +01:00
|
|
|
|
|
|
|
if (!Luid)
|
|
|
|
return STATUS_ACCESS_VIOLATION;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
|
2007-03-07 01:33:26 +01:00
|
|
|
SERVER_START_REQ( allocate_locally_unique_id )
|
|
|
|
{
|
|
|
|
status = wine_server_call( req );
|
|
|
|
if (!status)
|
|
|
|
{
|
|
|
|
Luid->LowPart = reply->luid.low_part;
|
|
|
|
Luid->HighPart = reply->luid.high_part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
2001-11-20 19:52:20 +01:00
|
|
|
|
2007-03-07 01:33:26 +01:00
|
|
|
return status;
|
- implementation of RtlReg* (read access), RtlEvent*, RtlSemaphore*,
NtAllocateLocallyUniqueId
- implementation or stubs for NtAccessCheck, NtSetSecurityObject,
RtlClearBits, RtlEqualPrefixSid, RtlFindClearBits,
RtlFormatCurrentUserKeyPath, RtlGetControlSecurityDescriptor,
RtlIdentifierAuthoritySid, RtlImpersonateSelf, RtlInitializeBitMap,
RtlInitializeGenericTable, RtlMakeSelfRelativeSD,
RtlPrefixUnicodeString, RtlSetBits, RtlUnicodeToMultiByteN,
RtlUpcaseUnicodeStringToOemString, RtlUpcaseUnicodeToOemN,
RtlValidSid, RtlxUnicodeStringToOemSize
- corrected most RtlString* functions, added documentation
- more fixes and partial implementations
2000-01-23 23:35:33 +01:00
|
|
|
}
|
2002-05-09 22:30:52 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* VerSetConditionMask (NTDLL.@)
|
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
|
|
|
|
BYTE dwConditionMask)
|
|
|
|
{
|
2002-05-20 00:20:09 +02:00
|
|
|
if(dwTypeBitMask == 0)
|
|
|
|
return dwlConditionMask;
|
|
|
|
dwConditionMask &= 0x07;
|
|
|
|
if(dwConditionMask == 0)
|
|
|
|
return dwlConditionMask;
|
|
|
|
|
|
|
|
if(dwTypeBitMask & VER_PRODUCT_TYPE)
|
|
|
|
dwlConditionMask |= dwConditionMask << 7*3;
|
|
|
|
else if (dwTypeBitMask & VER_SUITENAME)
|
|
|
|
dwlConditionMask |= dwConditionMask << 6*3;
|
|
|
|
else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
|
|
|
|
dwlConditionMask |= dwConditionMask << 5*3;
|
|
|
|
else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
|
|
|
|
dwlConditionMask |= dwConditionMask << 4*3;
|
|
|
|
else if (dwTypeBitMask & VER_PLATFORMID)
|
|
|
|
dwlConditionMask |= dwConditionMask << 3*3;
|
|
|
|
else if (dwTypeBitMask & VER_BUILDNUMBER)
|
|
|
|
dwlConditionMask |= dwConditionMask << 2*3;
|
|
|
|
else if (dwTypeBitMask & VER_MAJORVERSION)
|
|
|
|
dwlConditionMask |= dwConditionMask << 1*3;
|
|
|
|
else if (dwTypeBitMask & VER_MINORVERSION)
|
|
|
|
dwlConditionMask |= dwConditionMask << 0*3;
|
2002-05-09 22:30:52 +02:00
|
|
|
return dwlConditionMask;
|
|
|
|
}
|
2005-10-27 12:25:41 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtAccessCheckAndAuditAlarm (NTDLL.@)
|
|
|
|
* ZwAccessCheckAndAuditAlarm (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtAccessCheckAndAuditAlarm(PUNICODE_STRING SubsystemName, HANDLE HandleId, PUNICODE_STRING ObjectTypeName,
|
|
|
|
PUNICODE_STRING ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
|
|
ACCESS_MASK DesiredAccess, PGENERIC_MAPPING GenericMapping, BOOLEAN ObjectCreation,
|
|
|
|
PACCESS_MASK GrantedAccess, PBOOLEAN AccessStatus, PBOOLEAN GenerateOnClose)
|
|
|
|
{
|
2006-10-16 13:49:06 +02:00
|
|
|
FIXME("(%s, %p, %s, %p, 0x%08x, %p, %d, %p, %p, %p), stub\n", debugstr_us(SubsystemName), HandleId,
|
2005-10-27 12:25:41 +02:00
|
|
|
debugstr_us(ObjectTypeName), SecurityDescriptor, DesiredAccess, GenericMapping, ObjectCreation,
|
|
|
|
GrantedAccess, AccessStatus, GenerateOnClose);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2010-06-29 04:27:11 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtSystemDebugControl (NTDLL.@)
|
|
|
|
* ZwSystemDebugControl (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSystemDebugControl(SYSDBG_COMMAND command, PVOID inbuffer, ULONG inbuflength, PVOID outbuffer,
|
|
|
|
ULONG outbuflength, PULONG retlength)
|
|
|
|
{
|
|
|
|
FIXME("(%d, %p, %d, %p, %d, %p), stub\n", command, inbuffer, inbuflength, outbuffer, outbuflength, retlength);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
2016-04-30 02:57:00 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* NtSetLdtEntries (NTDLL.@)
|
|
|
|
* ZwSetLdtEntries (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI NtSetLdtEntries(ULONG selector1, ULONG entry1_low, ULONG entry1_high,
|
|
|
|
ULONG selector2, ULONG entry2_low, ULONG entry2_high)
|
|
|
|
{
|
|
|
|
FIXME("(%u, %u, %u, %u, %u, %u): stub\n", selector1, entry1_low, entry1_high, selector2, entry2_low, entry2_high);
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|