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)