Start of unit tests for *Info* functions.
Check needed length regardless of given length. Return STATUS_INVALID_INFO_CLASS for non-implemented classes. Return STATUS_ACCESS_VIOLATION if no buffer given.
This commit is contained in:
parent
77103f8245
commit
a9cbabc03c
|
@ -574,21 +574,25 @@ NTSTATUS WINAPI NtQuerySystemInformation(
|
||||||
{
|
{
|
||||||
case SystemBasicInformation:
|
case SystemBasicInformation:
|
||||||
{
|
{
|
||||||
SYSTEM_BASIC_INFORMATION* sbi = (SYSTEM_BASIC_INFORMATION*)SystemInformation;
|
SYSTEM_BASIC_INFORMATION sbi;
|
||||||
if (Length >= sizeof(*sbi))
|
|
||||||
|
sbi.dwUnknown1 = 0;
|
||||||
|
sbi.uKeMaximumIncrement = 0;
|
||||||
|
sbi.uPageSize = 1024; /* FIXME */
|
||||||
|
sbi.uMmNumberOfPhysicalPages = 12345; /* FIXME */
|
||||||
|
sbi.uMmLowestPhysicalPage = 0; /* FIXME */
|
||||||
|
sbi.uMmHighestPhysicalPage = 12345; /* FIXME */
|
||||||
|
sbi.uAllocationGranularity = 65536; /* FIXME */
|
||||||
|
sbi.pLowestUserAddress = 0; /* FIXME */
|
||||||
|
sbi.pMmHighestUserAddress = (void*)~0; /* FIXME */
|
||||||
|
sbi.uKeActiveProcessors = 1; /* FIXME */
|
||||||
|
sbi.bKeNumberProcessors = 1; /* FIXME */
|
||||||
|
len = sizeof(sbi);
|
||||||
|
|
||||||
|
if ( Length >= len)
|
||||||
{
|
{
|
||||||
sbi->dwUnknown1 = 0;
|
if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;
|
||||||
sbi->uKeMaximumIncrement = 0;
|
else memcpy( SystemInformation, &sbi, len);
|
||||||
sbi->uPageSize = 1024; /* FIXME */
|
|
||||||
sbi->uMmNumberOfPhysicalPages = 12345; /* FIXME */
|
|
||||||
sbi->uMmLowestPhysicalPage = 0; /* FIXME */
|
|
||||||
sbi->uMmHighestPhysicalPage = 12345; /* FIXME */
|
|
||||||
sbi->uAllocationGranularity = 65536; /* FIXME */
|
|
||||||
sbi->pLowestUserAddress = 0; /* FIXME */
|
|
||||||
sbi->pMmHighestUserAddress = (void*)~0; /* FIXME */
|
|
||||||
sbi->uKeActiveProcessors = 1; /* FIXME */
|
|
||||||
sbi->bKeNumberProcessors = 1; /* FIXME */
|
|
||||||
len = sizeof(*sbi);
|
|
||||||
}
|
}
|
||||||
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
else ret = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
}
|
}
|
||||||
|
@ -808,8 +812,14 @@ NTSTATUS WINAPI NtQuerySystemInformation(
|
||||||
default:
|
default:
|
||||||
FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
|
FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
|
||||||
SystemInformationClass,SystemInformation,Length,ResultLength);
|
SystemInformationClass,SystemInformation,Length,ResultLength);
|
||||||
ret = STATUS_NOT_IMPLEMENTED;
|
|
||||||
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ResultLength) *ResultLength = len;
|
if (ResultLength) *ResultLength = len;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -2,6 +2,7 @@ Makefile
|
||||||
env.ok
|
env.ok
|
||||||
error.ok
|
error.ok
|
||||||
generated.ok
|
generated.ok
|
||||||
|
info.ok
|
||||||
large_int.ok
|
large_int.ok
|
||||||
path.ok
|
path.ok
|
||||||
reg.ok
|
reg.ok
|
||||||
|
|
|
@ -9,6 +9,7 @@ CTESTS = \
|
||||||
env.c \
|
env.c \
|
||||||
error.c \
|
error.c \
|
||||||
generated.c \
|
generated.c \
|
||||||
|
info.c \
|
||||||
large_int.c \
|
large_int.c \
|
||||||
path.c \
|
path.c \
|
||||||
reg.c \
|
reg.c \
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
/* Unit test suite for *Information* Registry API functions
|
||||||
|
*
|
||||||
|
* Copyright 2005 Paul Vriens
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ntdll_test.h"
|
||||||
|
|
||||||
|
static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
|
||||||
|
|
||||||
|
static HMODULE hntdll = 0;
|
||||||
|
|
||||||
|
#define NTDLL_GET_PROC(func) \
|
||||||
|
p ## func = (void*)GetProcAddress(hntdll, #func); \
|
||||||
|
if(!p ## func) { \
|
||||||
|
trace("GetProcAddress(%s) failed\n", #func); \
|
||||||
|
FreeLibrary(hntdll); \
|
||||||
|
return FALSE; \
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL InitFunctionPtrs(void)
|
||||||
|
{
|
||||||
|
hntdll = LoadLibraryA("ntdll.dll");
|
||||||
|
if(!hntdll) {
|
||||||
|
trace("Could not load ntdll.dll\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (hntdll)
|
||||||
|
{
|
||||||
|
NTDLL_GET_PROC(NtQuerySystemInformation)
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_basic()
|
||||||
|
{
|
||||||
|
DWORD status;
|
||||||
|
ULONG ReturnLength;
|
||||||
|
|
||||||
|
SYSTEM_BASIC_INFORMATION* sbi = HeapAlloc(GetProcessHeap(), 0, sizeof(*sbi));
|
||||||
|
|
||||||
|
/* This test also covers some basic parameter testing that should be the same for
|
||||||
|
* every information class
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Use a non existent info class */
|
||||||
|
trace("Check non existent info class\n");
|
||||||
|
status = pNtQuerySystemInformation(-1, NULL, 0, NULL);
|
||||||
|
ok( status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got %08lx\n", status);
|
||||||
|
|
||||||
|
/* Use an existent class but with a zero-length buffer */
|
||||||
|
trace("Check zero-length buffer\n");
|
||||||
|
status = pNtQuerySystemInformation(SystemBasicInformation, NULL, 0, NULL);
|
||||||
|
ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08lx\n", status);
|
||||||
|
|
||||||
|
/* Use an existent class, correct length but no SystemInformation buffer */
|
||||||
|
trace("Check no SystemInformation buffer\n");
|
||||||
|
status = pNtQuerySystemInformation(SystemBasicInformation, NULL, sizeof(*sbi), NULL);
|
||||||
|
ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
|
||||||
|
|
||||||
|
/* Use a existent class, correct length, a pointer to a buffer but no ReturnLength pointer */
|
||||||
|
trace("Check no ReturnLength pointer\n");
|
||||||
|
status = pNtQuerySystemInformation(SystemBasicInformation, sbi, sizeof(*sbi), NULL);
|
||||||
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
||||||
|
|
||||||
|
/* Finally some correct calls */
|
||||||
|
trace("Check with correct parameters\n");
|
||||||
|
status = pNtQuerySystemInformation(SystemBasicInformation, sbi, sizeof(*sbi), &ReturnLength);
|
||||||
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08lx\n", status);
|
||||||
|
ok( sizeof(*sbi) == ReturnLength, "Inconsistent length (%08x) <-> (%ld)\n", sizeof(*sbi), ReturnLength);
|
||||||
|
|
||||||
|
/* Check if we have some return values */
|
||||||
|
trace("Number of Processors : %d\n", sbi->NumberOfProcessors);
|
||||||
|
ok( sbi->NumberOfProcessors > 0, "Expected more than 0 processors, got %d\n", sbi->NumberOfProcessors);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, sbi);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(info)
|
||||||
|
{
|
||||||
|
if(!InitFunctionPtrs())
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* 0 SystemBasicInformation */
|
||||||
|
trace("Starting test_basic()\n");
|
||||||
|
test_basic();
|
||||||
|
|
||||||
|
FreeLibrary(hntdll);
|
||||||
|
}
|
Loading…
Reference in New Issue