Commit d6a7b356 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Sort the info classes by numeric value in NtQuerySystemInformation().

parent 8b79c8d4
......@@ -2161,7 +2161,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
switch (class)
{
case SystemBasicInformation:
case SystemBasicInformation: /* 0 */
{
SYSTEM_BASIC_INFORMATION sbi;
......@@ -2176,7 +2176,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemCpuInformation:
case SystemCpuInformation: /* 1 */
if (size >= (len = sizeof(cpu_info)))
{
if (!info) ret = STATUS_ACCESS_VIOLATION;
......@@ -2185,7 +2185,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
else ret = STATUS_INFO_LENGTH_MISMATCH;
break;
case SystemPerformanceInformation:
case SystemPerformanceInformation: /* 2 */
{
SYSTEM_PERFORMANCE_INFORMATION spi;
static BOOL fixme_written = FALSE;
......@@ -2205,7 +2205,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemTimeOfDayInformation:
case SystemTimeOfDayInformation: /* 3 */
{
struct tm *tm;
time_t now;
......@@ -2230,7 +2230,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemProcessInformation:
case SystemProcessInformation: /* 5 */
{
unsigned int process_count, i, j;
char *buffer = NULL;
......@@ -2333,7 +2333,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemProcessorPerformanceInformation:
case SystemProcessorPerformanceInformation: /* 8 */
{
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION *sppi = NULL;
unsigned int cpus = 0;
......@@ -2435,7 +2435,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemModuleInformation:
case SystemModuleInformation: /* 11 */
{
/* FIXME: return some fake info for now */
static const char *fake_modules[] =
......@@ -2469,42 +2469,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemModuleInformationEx:
{
/* FIXME: return some fake info for now */
static const char *fake_modules[] =
{
"\\SystemRoot\\system32\\ntoskrnl.exe",
"\\SystemRoot\\system32\\hal.dll",
"\\SystemRoot\\system32\\drivers\\mountmgr.sys"
};
ULONG i;
RTL_PROCESS_MODULE_INFORMATION_EX *module_info = info;
len = sizeof(*module_info) * ARRAY_SIZE(fake_modules) + sizeof(module_info->NextOffset);
if (len <= size)
{
memset( info, 0, len );
for (i = 0; i < ARRAY_SIZE(fake_modules); i++)
{
SYSTEM_MODULE *sm = &module_info[i].BaseInfo;
sm->ImageBaseAddress = (char *)0x10000000 + 0x200000 * i;
sm->ImageSize = 0x200000;
sm->LoadOrderIndex = i;
sm->LoadCount = 1;
strcpy( (char *)sm->Name, fake_modules[i] );
sm->NameOffset = strrchr( fake_modules[i], '\\' ) - fake_modules[i] + 1;
module_info[i].NextOffset = sizeof(*module_info);
}
module_info[ARRAY_SIZE(fake_modules)].NextOffset = 0;
}
else ret = STATUS_INFO_LENGTH_MISMATCH;
break;
}
case SystemHandleInformation:
case SystemHandleInformation: /* 16 */
{
struct handle_info *handle_info;
DWORD i, num_handles;
......@@ -2555,59 +2520,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemExtendedHandleInformation:
{
struct handle_info *handle_info;
DWORD i, num_handles;
if (size < sizeof(SYSTEM_HANDLE_INFORMATION_EX))
{
ret = STATUS_INFO_LENGTH_MISMATCH;
break;
}
if (!info)
{
ret = STATUS_ACCESS_VIOLATION;
break;
}
num_handles = (size - FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION_EX, Handles ))
/ sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX);
if (!(handle_info = malloc( sizeof(*handle_info) * num_handles ))) return STATUS_NO_MEMORY;
SERVER_START_REQ( get_system_handles )
{
wine_server_set_reply( req, handle_info, sizeof(*handle_info) * num_handles );
if (!(ret = wine_server_call( req )))
{
SYSTEM_HANDLE_INFORMATION_EX *shi = info;
shi->NumberOfHandles = wine_server_reply_size( req ) / sizeof(*handle_info);
len = FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION_EX, Handles[shi->NumberOfHandles] );
for (i = 0; i < shi->NumberOfHandles; i++)
{
memset( &shi->Handles[i], 0, sizeof(shi->Handles[i]) );
shi->Handles[i].UniqueProcessId = handle_info[i].owner;
shi->Handles[i].HandleValue = handle_info[i].handle;
shi->Handles[i].GrantedAccess = handle_info[i].access;
shi->Handles[i].HandleAttributes = handle_info[i].attributes;
shi->Handles[i].ObjectTypeIndex = handle_info[i].type;
/* FIXME: Fill out Object */
}
}
else if (ret == STATUS_BUFFER_TOO_SMALL)
{
len = FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION_EX, Handles[reply->count] );
ret = STATUS_INFO_LENGTH_MISMATCH;
}
}
SERVER_END_REQ;
free( handle_info );
break;
}
case SystemFileCacheInformation:
case SystemFileCacheInformation: /* 21 */
{
SYSTEM_CACHE_INFORMATION sci = { 0 };
......@@ -2622,7 +2535,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemInterruptInformation:
case SystemInterruptInformation: /* 23 */
{
len = NtCurrentTeb()->Peb->NumberOfProcessors * sizeof(SYSTEM_INTERRUPT_INFORMATION);
if (size >= len)
......@@ -2648,7 +2561,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemTimeAdjustmentInformation:
case SystemTimeAdjustmentInformation: /* 28 */
{
SYSTEM_TIME_ADJUSTMENT_QUERY query = { 156250, 156250, TRUE };
......@@ -2662,7 +2575,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemKernelDebuggerInformation:
case SystemKernelDebuggerInformation: /* 35 */
{
SYSTEM_KERNEL_DEBUGGER_INFORMATION skdi;
......@@ -2678,7 +2591,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemRegistryQuotaInformation:
case SystemRegistryQuotaInformation: /* 37 */
{
/* Something to do with the size of the registry *
* Since we don't have a size limitation, fake it *
......@@ -2705,7 +2618,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemCurrentTimeZoneInformation:
case SystemCurrentTimeZoneInformation: /* 44 */
{
RTL_DYNAMIC_TIME_ZONE_INFORMATION tz;
......@@ -2720,7 +2633,84 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemLogicalProcessorInformation:
case SystemExtendedProcessInformation: /* 57 */
FIXME("SystemExtendedProcessInformation, size %u, info %p, stub!\n", size, info);
memset( info, 0, size );
ret = STATUS_SUCCESS;
break;
case SystemRecommendedSharedDataAlignment: /* 58 */
{
len = sizeof(DWORD);
if (size >= len)
{
if (!info) ret = STATUS_ACCESS_VIOLATION;
else
{
#ifdef __arm__
*((DWORD *)info) = 32;
#else
*((DWORD *)info) = 64;
#endif
}
}
else ret = STATUS_INFO_LENGTH_MISMATCH;
break;
}
case SystemExtendedHandleInformation: /* 64 */
{
struct handle_info *handle_info;
DWORD i, num_handles;
if (size < sizeof(SYSTEM_HANDLE_INFORMATION_EX))
{
ret = STATUS_INFO_LENGTH_MISMATCH;
break;
}
if (!info)
{
ret = STATUS_ACCESS_VIOLATION;
break;
}
num_handles = (size - FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION_EX, Handles ))
/ sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX);
if (!(handle_info = malloc( sizeof(*handle_info) * num_handles ))) return STATUS_NO_MEMORY;
SERVER_START_REQ( get_system_handles )
{
wine_server_set_reply( req, handle_info, sizeof(*handle_info) * num_handles );
if (!(ret = wine_server_call( req )))
{
SYSTEM_HANDLE_INFORMATION_EX *shi = info;
shi->NumberOfHandles = wine_server_reply_size( req ) / sizeof(*handle_info);
len = FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION_EX, Handles[shi->NumberOfHandles] );
for (i = 0; i < shi->NumberOfHandles; i++)
{
memset( &shi->Handles[i], 0, sizeof(shi->Handles[i]) );
shi->Handles[i].UniqueProcessId = handle_info[i].owner;
shi->Handles[i].HandleValue = handle_info[i].handle;
shi->Handles[i].GrantedAccess = handle_info[i].access;
shi->Handles[i].HandleAttributes = handle_info[i].attributes;
shi->Handles[i].ObjectTypeIndex = handle_info[i].type;
/* FIXME: Fill out Object */
}
}
else if (ret == STATUS_BUFFER_TOO_SMALL)
{
len = FIELD_OFFSET( SYSTEM_HANDLE_INFORMATION_EX, Handles[reply->count] );
ret = STATUS_INFO_LENGTH_MISMATCH;
}
}
SERVER_END_REQ;
free( handle_info );
break;
}
case SystemLogicalProcessorInformation: /* 73 */
{
SYSTEM_LOGICAL_PROCESSOR_INFORMATION *buf;
......@@ -2747,29 +2737,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemCpuSetInformation:
return NtQuerySystemInformationEx(class, NULL, 0, info, size, ret_size);
case SystemRecommendedSharedDataAlignment:
{
len = sizeof(DWORD);
if (size >= len)
{
if (!info) ret = STATUS_ACCESS_VIOLATION;
else
{
#ifdef __arm__
*((DWORD *)info) = 32;
#else
*((DWORD *)info) = 64;
#endif
}
}
else ret = STATUS_INFO_LENGTH_MISMATCH;
break;
}
case SystemFirmwareTableInformation:
case SystemFirmwareTableInformation: /* 76 */
{
SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti = info;
len = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
......@@ -2792,7 +2760,42 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemDynamicTimeZoneInformation:
case SystemModuleInformationEx: /* 77 */
{
/* FIXME: return some fake info for now */
static const char *fake_modules[] =
{
"\\SystemRoot\\system32\\ntoskrnl.exe",
"\\SystemRoot\\system32\\hal.dll",
"\\SystemRoot\\system32\\drivers\\mountmgr.sys"
};
ULONG i;
RTL_PROCESS_MODULE_INFORMATION_EX *module_info = info;
len = sizeof(*module_info) * ARRAY_SIZE(fake_modules) + sizeof(module_info->NextOffset);
if (len <= size)
{
memset( info, 0, len );
for (i = 0; i < ARRAY_SIZE(fake_modules); i++)
{
SYSTEM_MODULE *sm = &module_info[i].BaseInfo;
sm->ImageBaseAddress = (char *)0x10000000 + 0x200000 * i;
sm->ImageSize = 0x200000;
sm->LoadOrderIndex = i;
sm->LoadCount = 1;
strcpy( (char *)sm->Name, fake_modules[i] );
sm->NameOffset = strrchr( fake_modules[i], '\\' ) - fake_modules[i] + 1;
module_info[i].NextOffset = sizeof(*module_info);
}
module_info[ARRAY_SIZE(fake_modules)].NextOffset = 0;
}
else ret = STATUS_INFO_LENGTH_MISMATCH;
break;
}
case SystemDynamicTimeZoneInformation: /* 102 */
{
RTL_DYNAMIC_TIME_ZONE_INFORMATION tz;
......@@ -2807,15 +2810,27 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemExtendedProcessInformation:
FIXME("SystemExtendedProcessInformation, size %u, info %p, stub!\n", size, info);
memset( info, 0, size );
ret = STATUS_SUCCESS;
case SystemCodeIntegrityInformation: /* 103 */
{
SYSTEM_CODEINTEGRITY_INFORMATION *integrity_info = info;
FIXME("SystemCodeIntegrityInformation, size %u, info %p, stub!\n", size, info);
len = sizeof(SYSTEM_CODEINTEGRITY_INFORMATION);
if (size < len)
integrity_info->CodeIntegrityOptions = CODEINTEGRITY_OPTION_ENABLED;
else
ret = STATUS_INFO_LENGTH_MISMATCH;
break;
}
case SystemCpuSetInformation: /* 175 */
return NtQuerySystemInformationEx(class, NULL, 0, info, size, ret_size);
/* Wine extensions */
case SystemWineVersionInformation:
case SystemWineVersionInformation: /* 1000 */
{
static const char version[] = PACKAGE_VERSION;
extern const char wine_build[];
......@@ -2828,21 +2843,6 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
break;
}
case SystemCodeIntegrityInformation:
{
SYSTEM_CODEINTEGRITY_INFORMATION *integrity_info = info;
FIXME("SystemCodeIntegrityInformation, size %u, info %p, stub!\n", size, info);
len = sizeof(SYSTEM_CODEINTEGRITY_INFORMATION);
if (size < len)
integrity_info->CodeIntegrityOptions = CODEINTEGRITY_OPTION_ENABLED;
else
ret = STATUS_INFO_LENGTH_MISMATCH;
break;
}
default:
FIXME( "(0x%08x,%p,0x%08x,%p) stub\n", class, info, size, ret_size );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment