Signed-off-by: Andrew Wesie awesie@gmail.com --- dlls/ntdll/nt.c | 61 +++++++++++++++++++++++++++++++++++++++++++--- include/winternl.h | 9 +++++++ 2 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index 6c95517e79..174543bb89 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -2546,6 +2546,16 @@ BOOLEAN WINAPI RtlIsProcessorFeaturePresent( UINT feature ) return feature < PROCESSOR_FEATURE_MAX && user_shared_data->ProcessorFeatures[feature]; }
+static void fake_ntoskrnl_system_module( SYSTEM_MODULE* sm ) +{ + static char ntoskrnl_path[] = "\SystemRoot\system32\ntoskrnl.exe"; + char *sep; + memset(sm, 0, sizeof(*sm)); /* FIXME */ + strcpy((char *)sm->Name, ntoskrnl_path); + sep = strrchr((char *)sm->Name, '\'); + sm->NameOffset = sep == NULL ? 0 : sep - (char *)sm->Name + 1; +} + /****************************************************************************** * NtQuerySystemInformation [NTDLL.@] * ZwQuerySystemInformation [NTDLL.@] @@ -2869,9 +2879,54 @@ NTSTATUS WINAPI NtQuerySystemInformation( } break; case SystemModuleInformation: - /* FIXME: should be system-wide */ - if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION; - else ret = LdrQueryProcessModuleInformation( SystemInformation, Length, &len ); + /* Whether this returns user modules depends on the Windows version. */ + len = FIELD_OFFSET( SYSTEM_MODULE_INFORMATION, Modules[1] ); + if (Length < len) + { + ret = STATUS_INFO_LENGTH_MISMATCH; + } + else if (!SystemInformation) + { + ret = STATUS_ACCESS_VIOLATION; + } + else + { + SYSTEM_MODULE_INFORMATION *smi = SystemInformation; + FIXME("info_class SystemModuleInformation stub!\n"); + + smi->ModulesCount = 1; + fake_ntoskrnl_system_module(&smi->Modules[0]); + ret = STATUS_SUCCESS; + } + break; + case SystemModuleInformationEx: + /* Whether this returns user modules depends on the Windows version. */ + /* Length is sizeof(SYSTEM_MODULE_INFORMATION_EX) * (1 + number modules) */ + len = sizeof(SYSTEM_MODULE_INFORMATION_EX) * 2; + if (Length < len) + { + ret = STATUS_INFO_LENGTH_MISMATCH; + } + else if (!SystemInformation) + { + ret = STATUS_ACCESS_VIOLATION; + } + else + { + SYSTEM_MODULE_INFORMATION_EX *p = SystemInformation; + FIXME("info_class SystemModuleInformationEx stub!\n"); + + p->NextOffset = sizeof(*p); + fake_ntoskrnl_system_module(&p->BaseInfo); + p->ImageCheckSum = 0; /* FIXME */ + p->TimeDateStamp = 0; + p->DefaultBase = NULL; + p++; + + /* Terminating entry has NextOffset == 0 */ + memset(p, 0, sizeof(*p)); + ret = STATUS_SUCCESS; + } break; case SystemHandleInformation: { diff --git a/include/winternl.h b/include/winternl.h index f36419da78..8740d532b3 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2418,6 +2418,15 @@ typedef struct _SYSTEM_MODULE_INFORMATION SYSTEM_MODULE Modules[1]; /* FIXME: should be Modules[0] */ } SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION;
+typedef struct _SYSTEM_MODULE_INFORMATION_EX +{ + USHORT NextOffset; + SYSTEM_MODULE BaseInfo; + ULONG ImageCheckSum; + ULONG TimeDateStamp; + void *DefaultBase; +} SYSTEM_MODULE_INFORMATION_EX, *PSYSTEM_MODULE_INFORMATION_EX; + #define THREAD_CREATE_FLAGS_CREATE_SUSPENDED 0x00000001 #define THREAD_CREATE_FLAGS_SKIP_THREAD_ATTACH 0x00000002 #define THREAD_CREATE_FLAGS_HIDE_FROM_DEBUGGER 0x00000004
Signed-off-by: Andrew Wesie awesie@gmail.com --- dlls/ntdll/tests/info.c | 69 +++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 20 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 8dc8bad645..d950c224c4 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -492,39 +492,68 @@ static void test_query_procperf(void) HeapFree( GetProcessHeap(), 0, sppi); }
+static void check_system_module(ULONG i, SYSTEM_MODULE* sm) +{ + if (i == 0) + { + ok( strcasecmp((char *)sm->Name + sm->NameOffset, "ntoskrnl.exe") == 0, + "Expected ntoskrnl.exe as first module, got %s\n", sm->Name + sm->NameOffset); + } + ok( i == sm->LoadOrderIndex, "LoadOrderIndex (%d) should have matched %u\n", sm->LoadOrderIndex, i); + todo_wine ok( sm->ImageSize != 0, "ImageSize should not be 0\n"); + todo_wine ok( sm->LoadCount != 0, "LoadCount should not be 0\n"); + ok( strlen((char*)sm->Name) != 0, "Name should not be empty\n"); +} + static void test_query_module(void) { NTSTATUS status; - ULONG ReturnLength; - ULONG ModuleCount, i; + ULONG i, ReturnLength; + SYSTEM_MODULE_INFORMATION* smi = HeapAlloc(GetProcessHeap(), 0, sizeof(SYSTEM_MODULE_INFORMATION)); + SYSTEM_MODULE_INFORMATION_EX* smi_ex, *p;
- ULONG SystemInformationLength = sizeof(SYSTEM_MODULE_INFORMATION); - SYSTEM_MODULE_INFORMATION* smi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength); - SYSTEM_MODULE* sm; - - /* Request the needed length */ + /* SystemModuleInformation */ status = pNtQuerySystemInformation(SystemModuleInformation, smi, 0, &ReturnLength); ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); ok( ReturnLength > 0, "Expected a ReturnLength to show the needed length\n");
- SystemInformationLength = ReturnLength; - smi = HeapReAlloc(GetProcessHeap(), 0, smi , SystemInformationLength); - status = pNtQuerySystemInformation(SystemModuleInformation, smi, SystemInformationLength, &ReturnLength); + status = pNtQuerySystemInformation(SystemModuleInformation, NULL, 0, &ReturnLength); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); + ok( ReturnLength > 0, "Expected a ReturnLength to show the needed length\n"); + + smi = HeapReAlloc(GetProcessHeap(), 0, smi, ReturnLength); + status = pNtQuerySystemInformation(SystemModuleInformation, smi, ReturnLength, &ReturnLength); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
- ModuleCount = smi->ModulesCount; - sm = &smi->Modules[0]; - /* our implementation is a stub for now */ - ok( ModuleCount > 0, "Expected some modules to be loaded\n"); + ok( smi->ModulesCount > 0, "Expected some modules to be loaded\n");
- /* Loop through all the modules/drivers, Wine doesn't get here (yet) */ - for (i = 0; i < ModuleCount ; i++) - { - ok( i == sm->LoadOrderIndex, "LoadOrderIndex (%d) should have matched %u\n", sm->LoadOrderIndex, i); - sm++; - } + /* Loop through all the modules/drivers */ + for (i = 0; i < smi->ModulesCount ; i++) + check_system_module(i, &smi->Modules[i]); + + ok( (UINT_PTR)&smi->Modules[smi->ModulesCount] <= (UINT_PTR)smi + ReturnLength, "Read %d bytes, expected %d bytes\n", + (UINT_PTR)&smi->Modules[smi->ModulesCount] - (UINT_PTR)smi, ReturnLength); + + /* SystemModuleInformationEx */ + status = pNtQuerySystemInformation(SystemModuleInformationEx, NULL, 0, &ReturnLength); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); + ok( ReturnLength > 0, "Expected a ReturnLength to show the needed length\n"); + + smi_ex = HeapAlloc(GetProcessHeap(), 0, ReturnLength); + status = pNtQuerySystemInformation(SystemModuleInformationEx, smi_ex, ReturnLength, &ReturnLength); + ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + + ok( smi_ex->NextOffset != 0, "Expected some modules to be loaded\n"); + + /* Loop through all the modules/drivers */ + for (p = smi_ex, i = 0; p->NextOffset != 0; p = (SYSTEM_MODULE_INFORMATION_EX*)((UINT_PTR)p + p->NextOffset), i++) + check_system_module(i, &p->BaseInfo); + + ok( (UINT_PTR)p < (UINT_PTR)smi_ex + ReturnLength, "Read %d bytes, expected %d bytes\n", + (UINT_PTR)p - (UINT_PTR)smi_ex, ReturnLength);
HeapFree( GetProcessHeap(), 0, smi); + HeapFree( GetProcessHeap(), 0, smi_ex); }
static void test_query_handle(void)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=70448
Your paranoid android.
=== wxppro (32 bit report) ===
ntdll: info.c:539: Test failed: Expected STATUS_INFO_LENGTH_MISMATCH, got c0000003 info.c:540: Test failed: Expected a ReturnLength to show the needed length info.c:544: Test failed: Expected STATUS_SUCCESS, got c0000003 info.c:499: Test failed: Expected ntoskrnl.exe as first module, got ±»®Õ info.c:504: Test failed: LoadCount should not be 0 info.c:502: Test failed: LoadOrderIndex (0) should have matched 1 info.c:503: Test failed: ImageSize should not be 0 info.c:504: Test failed: LoadCount should not be 0 info.c:505: Test failed: Name should not be empty info.c:502: Test failed: LoadOrderIndex (0) should have matched 2 info.c:503: Test failed: ImageSize should not be 0 info.c:504: Test failed: LoadCount should not be 0 info.c:552: Test failed: Read 386 bytes, expected 0 bytes
=== debiant (build log) ===
The task timed out
=== debiant (build log) ===
The task timed out
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=70447
Your paranoid android.
=== debiant (build log) ===
The task timed out
=== debiant (build log) ===
The task timed out