Author: akhaldi
Date: Thu Aug 18 09:22:13 2016
New Revision: 72253
URL:
http://svn.reactos.org/svn/reactos?rev=72253&view=rev
Log:
[KERNEL32_WINETEST] Sync with Wine Staging 1.9.16. CORE-11866
Modified:
trunk/rostests/winetests/kernel32/debugger.c
trunk/rostests/winetests/kernel32/fiber.c
trunk/rostests/winetests/kernel32/loader.c
trunk/rostests/winetests/kernel32/process.c
trunk/rostests/winetests/kernel32/thread.c
trunk/rostests/winetests/kernel32/virtual.c
Modified: trunk/rostests/winetests/kernel32/debugger.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/kernel32/debugg…
==============================================================================
--- trunk/rostests/winetests/kernel32/debugger.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/kernel32/debugger.c [iso-8859-1] Thu Aug 18 09:22:13 2016
@@ -39,7 +39,6 @@
static BOOL (WINAPI *pDebugActiveProcessStop)(DWORD);
static BOOL (WINAPI *pDebugSetProcessKillOnExit)(BOOL);
static BOOL (WINAPI *pIsDebuggerPresent)(void);
-static struct _TEB * (WINAPI *pNtCurrentTeb)(void);
static LONG child_failures;
@@ -579,18 +578,15 @@
child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n",
GetLastError());
child_ok(debug, "Expected debug != 0, got %#x.\n", debug);
- if (pNtCurrentTeb)
- {
- pNtCurrentTeb()->Peb->BeingDebugged = FALSE;
-
- ret = pIsDebuggerPresent();
- child_ok(!ret, "Expected ret != 0, got %#x.\n", ret);
- ret = pCheckRemoteDebuggerPresent(GetCurrentProcess(), &debug);
- child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n",
GetLastError());
- child_ok(debug, "Expected debug != 0, got %#x.\n", debug);
-
- pNtCurrentTeb()->Peb->BeingDebugged = TRUE;
- }
+ NtCurrentTeb()->Peb->BeingDebugged = FALSE;
+
+ ret = pIsDebuggerPresent();
+ child_ok(!ret, "Expected ret != 0, got %#x.\n", ret);
+ ret = pCheckRemoteDebuggerPresent(GetCurrentProcess(), &debug);
+ child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n",
GetLastError());
+ child_ok(debug, "Expected debug != 0, got %#x.\n", debug);
+
+ NtCurrentTeb()->Peb->BeingDebugged = TRUE;
blackbox.failures = child_failures;
save_blackbox(blackbox_file, &blackbox, sizeof(blackbox));
@@ -815,8 +811,6 @@
pDebugActiveProcessStop=(void*)GetProcAddress(hdll,
"DebugActiveProcessStop");
pDebugSetProcessKillOnExit=(void*)GetProcAddress(hdll,
"DebugSetProcessKillOnExit");
pIsDebuggerPresent=(void*)GetProcAddress(hdll, "IsDebuggerPresent");
- hdll=GetModuleHandleA("ntdll.dll");
- if (hdll) pNtCurrentTeb = (void*)GetProcAddress(hdll, "NtCurrentTeb");
myARGC=winetest_get_mainargs(&myARGV);
if (myARGC >= 3 && strcmp(myARGV[2], "crash") == 0)
Modified: trunk/rostests/winetests/kernel32/fiber.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/kernel32/fiber.…
==============================================================================
--- trunk/rostests/winetests/kernel32/fiber.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/kernel32/fiber.c [iso-8859-1] Thu Aug 18 09:22:13 2016
@@ -33,9 +33,13 @@
static PVOID (WINAPI *pFlsGetValue)(DWORD);
static BOOL (WINAPI *pFlsSetValue)(DWORD,PVOID);
-static LPVOID fibers[2];
+static void *fibers[3];
static BYTE testparam = 185;
-static WORD cbCount;
+static DWORD fls_index_to_set = FLS_OUT_OF_INDEXES;
+static void* fls_value_to_set;
+
+static int fiberCount = 0;
+static int cbCount = 0;
static VOID init_funcs(void)
{
@@ -59,15 +63,35 @@
static VOID WINAPI FiberLocalStorageProc(PVOID lpFlsData)
{
+ ok(lpFlsData == fls_value_to_set,
+ "FlsData expected not to be changed, value is %p, expected %p\n",
+ lpFlsData, fls_value_to_set);
cbCount++;
- ok(lpFlsData == (PVOID) 1587, "FlsData expected not to be changed\n");
}
static VOID WINAPI FiberMainProc(LPVOID lpFiberParameter)
{
BYTE *tparam = (BYTE *)lpFiberParameter;
- cbCount++;
+ fiberCount++;
ok(*tparam == 185, "Parameterdata expected not to be changed\n");
+ if (fls_index_to_set != FLS_OUT_OF_INDEXES)
+ {
+ void* ret;
+ BOOL bret;
+
+ ret = pFlsGetValue(fls_index_to_set);
+ ok(ret == NULL, "FlsGetValue returned %p, expected NULL\n", ret);
+
+ /* Set the FLS value */
+ bret = pFlsSetValue(fls_index_to_set, fls_value_to_set);
+ ok(bret, "FlsSetValue failed with error %u\n", GetLastError());
+
+ /* Verify that FlsGetValue retrieves the value set by FlsSetValue */
+ SetLastError( 0xdeadbeef );
+ ret = pFlsGetValue(fls_index_to_set);
+ ok(ret == fls_value_to_set, "FlsGetValue returned %p, expected %p\n",
ret, fls_value_to_set);
+ ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue error %u\n",
GetLastError());
+ }
pSwitchToFiber(fibers[0]);
}
@@ -76,7 +100,7 @@
if (pConvertThreadToFiber)
{
fibers[0] = pConvertThreadToFiber(&testparam);
- ok(fibers[0] != 0, "ConvertThreadToFiber failed with error %d\n",
GetLastError());
+ ok(fibers[0] != NULL, "ConvertThreadToFiber failed with error %u\n",
GetLastError());
}
else
{
@@ -89,7 +113,7 @@
if (pConvertThreadToFiberEx)
{
fibers[0] = pConvertThreadToFiberEx(&testparam, 0);
- ok(fibers[0] != 0, "ConvertThreadToFiberEx failed with error %d\n",
GetLastError());
+ ok(fibers[0] != NULL, "ConvertThreadToFiberEx failed with error %u\n",
GetLastError());
}
else
{
@@ -102,7 +126,7 @@
if (pConvertFiberToThread)
{
BOOL ret = pConvertFiberToThread();
- ok(ret, "ConvertFiberToThread failed with error %d\n",
GetLastError());
+ ok(ret, "ConvertFiberToThread failed with error %u\n",
GetLastError());
}
else
{
@@ -112,9 +136,9 @@
static void test_FiberHandling(void)
{
- cbCount = 0;
+ fiberCount = 0;
fibers[0] = pCreateFiber(0,FiberMainProc,&testparam);
- ok(fibers[0] != 0, "CreateFiber failed with error %d\n", GetLastError());
+ ok(fibers[0] != NULL, "CreateFiber failed with error %u\n",
GetLastError());
pDeleteFiber(fibers[0]);
test_ConvertThreadToFiber();
@@ -124,12 +148,11 @@
else
test_ConvertThreadToFiber();
-
fibers[1] = pCreateFiber(0,FiberMainProc,&testparam);
- ok(fibers[1] != 0, "CreateFiber failed with error %d\n", GetLastError());
+ ok(fibers[1] != NULL, "CreateFiber failed with error %u\n",
GetLastError());
pSwitchToFiber(fibers[1]);
- ok(cbCount == 1, "Wrong callback count: %d\n", cbCount);
+ ok(fiberCount == 1, "Wrong fiber count: %d\n", fiberCount);
pDeleteFiber(fibers[1]);
if (!pCreateFiberEx)
@@ -138,12 +161,11 @@
return;
}
- SetLastError(0xdeadbeef);
fibers[1] = pCreateFiberEx(0,0,0,FiberMainProc,&testparam);
- ok(fibers[1] != 0, "CreateFiberEx failed with error %d\n",
GetLastError());
+ ok(fibers[1] != NULL, "CreateFiberEx failed with error %u\n",
GetLastError());
pSwitchToFiber(fibers[1]);
- ok(cbCount == 2, "Wrong callback count: %d\n", cbCount);
+ ok(fiberCount == 2, "Wrong fiber count: %d\n", fiberCount);
pDeleteFiber(fibers[1]);
if (!pIsThreadAFiber)
@@ -157,32 +179,62 @@
ok(!pIsThreadAFiber(), "IsThreadAFiber reported TRUE\n");
}
-static void test_FiberLocalStorage(PFLS_CALLBACK_FUNCTION cbfunc)
-{
- DWORD fls;
+static void test_FiberLocalStorage(void)
+{
+ DWORD fls, fls_2;
BOOL ret;
- PVOID val = (PVOID) 1587;
-
- if (!pFlsAlloc)
+ void* val;
+
+ if (!pFlsAlloc || !pFlsSetValue || !pFlsGetValue || !pFlsFree)
{
win_skip( "Fiber Local Storage not supported\n" );
return;
}
- cbCount = 0;
-
- fls = pFlsAlloc(cbfunc);
- ok(fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %d\n",
GetLastError());
-
- ret = pFlsSetValue(fls, val);
- ok(ret, "FlsSetValue failed\n");
- ok(val == pFlsGetValue(fls), "FlsGetValue failed\n");
-
- ret = pFlsFree(fls);
- ok(ret, "FlsFree failed\n");
- if (cbfunc)
- todo_wine ok(cbCount == 1, "Wrong callback count: %d\n", cbCount);
-
- /* test index 0 */
+
+ /* Test an unallocated index
+ * FlsFree should fail
+ * FlsGetValue and FlsSetValue should succeed
+ */
+ SetLastError( 0xdeadbeef );
+ ret = pFlsFree( 127 );
+ ok( !ret, "freeing fls index 127 (unallocated) succeeded\n" );
+ ok( GetLastError() == ERROR_INVALID_PARAMETER,
+ "freeing fls index 127 (unallocated) wrong error %u\n", GetLastError()
);
+
+ val = pFlsGetValue( 127 );
+ ok( val == NULL,
+ "getting fls index 127 (unallocated) failed with error %u\n",
GetLastError() );
+
+ ret = pFlsSetValue( 127, (void*) 0x217 );
+ ok( ret, "setting fls index 127 (unallocated) failed with error %u\n",
GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ val = pFlsGetValue( 127 );
+ ok( val == (void*) 0x217, "fls index 127 (unallocated) wrong value %p\n",
val );
+ ok( GetLastError() == ERROR_SUCCESS,
+ "getting fls index 127 (unallocated) failed with error %u\n",
GetLastError() );
+
+ /* FlsFree, FlsGetValue, and FlsSetValue out of bounds should return
+ * ERROR_INVALID_PARAMETER
+ */
+ SetLastError( 0xdeadbeef );
+ ret = pFlsFree( 128 );
+ ok( !ret, "freeing fls index 128 (out of bounds) succeeded\n" );
+ ok( GetLastError() == ERROR_INVALID_PARAMETER,
+ "freeing fls index 128 (out of bounds) wrong error %u\n",
GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ ret = pFlsSetValue( 128, (void*) 0x217 );
+ ok( !ret, "setting fls index 128 (out of bounds) succeeded\n" );
+ ok( GetLastError() == ERROR_INVALID_PARAMETER,
+ "setting fls index 128 (out of bounds) wrong error %u\n",
GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ val = pFlsGetValue( 128 );
+ ok( GetLastError() == ERROR_INVALID_PARAMETER,
+ "getting fls index 128 (out of bounds) wrong error %u\n",
GetLastError() );
+
+ /* Test index 0 */
SetLastError( 0xdeadbeef );
val = pFlsGetValue( 0 );
ok( !val, "fls index 0 set to %p\n", val );
@@ -196,6 +248,7 @@
ok( !val, "fls index 0 wrong value %p\n", val );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error
%u\n", GetLastError() );
+ /* Test creating an FLS index */
fls = pFlsAlloc( NULL );
ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed\n" );
ok( fls != 0, "fls index 0 allocated\n" );
@@ -203,13 +256,149 @@
ok( !val, "fls index %u wrong value %p\n", fls, val );
ret = pFlsSetValue( fls, (void *)0xdeadbeef );
ok( ret, "setting fls index %u failed\n", fls );
+ SetLastError( 0xdeadbeef );
val = pFlsGetValue( fls );
ok( val == (void *)0xdeadbeef, "fls index %u wrong value %p\n", fls, val
);
+ ok( GetLastError() == ERROR_SUCCESS,
+ "getting fls index %u failed with error %u\n", fls, GetLastError() );
pFlsFree( fls );
+
+ /* Undefined behavior: verify the value is NULL after it the slot is freed */
+ SetLastError( 0xdeadbeef );
+ val = pFlsGetValue( fls );
+ ok( val == NULL, "fls index %u wrong value %p\n", fls, val );
+ ok( GetLastError() == ERROR_SUCCESS,
+ "getting fls index %u failed with error %u\n", fls, GetLastError() );
+
+ /* Undefined behavior: verify the value is settable after the slot is freed */
ret = pFlsSetValue( fls, (void *)0xdeadbabe );
ok( ret, "setting fls index %u failed\n", fls );
val = pFlsGetValue( fls );
ok( val == (void *)0xdeadbabe, "fls index %u wrong value %p\n", fls, val
);
+
+ /* Try to create the same FLS index again, and verify that is initialized to NULL */
+ fls_2 = pFlsAlloc( NULL );
+ ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %u\n",
GetLastError() );
+ /* If this fails it is not an API error, but the test will be inconclusive */
+ ok( fls_2 == fls, "different FLS index allocated, was %u, now %u\n", fls,
fls_2 );
+
+ SetLastError( 0xdeadbeef );
+ val = pFlsGetValue( fls_2 );
+ ok( val == NULL, "fls index %u wrong value %p\n", fls, val );
+ ok( GetLastError() == ERROR_SUCCESS,
+ "getting fls index %u failed with error %u\n", fls_2, GetLastError()
);
+ pFlsFree( fls_2 );
+}
+
+static void test_FiberLocalStorageCallback(PFLS_CALLBACK_FUNCTION cbfunc)
+{
+ DWORD fls;
+ BOOL ret;
+ void* val, *val2;
+
+ if (!pFlsAlloc || !pFlsSetValue || !pFlsGetValue || !pFlsFree)
+ {
+ win_skip( "Fiber Local Storage not supported\n" );
+ return;
+ }
+
+ /* Test that the callback is executed */
+ cbCount = 0;
+ fls = pFlsAlloc( cbfunc );
+ ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %u\n",
GetLastError() );
+
+ val = (void*) 0x1587;
+ fls_value_to_set = val;
+ ret = pFlsSetValue( fls, val );
+ ok(ret, "FlsSetValue failed with error %u\n", GetLastError() );
+
+ val2 = pFlsGetValue( fls );
+ ok(val == val2, "FlsGetValue returned %p, expected %p\n", val2, val);
+
+ ret = pFlsFree( fls );
+ ok(ret, "FlsFree failed with error %u\n", GetLastError() );
+ todo_wine ok( cbCount == 1, "Wrong callback count: %d\n", cbCount );
+
+ /* Test that callback is not executed if value is NULL */
+ cbCount = 0;
+ fls = pFlsAlloc( cbfunc );
+ ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %u\n",
GetLastError() );
+
+ ret = pFlsSetValue( fls, NULL );
+ ok( ret, "FlsSetValue failed with error %u\n", GetLastError() );
+
+ pFlsFree( fls );
+ ok( ret, "FlsFree failed with error %u\n", GetLastError() );
+ ok( cbCount == 0, "Wrong callback count: %d\n", cbCount );
+}
+
+static void test_FiberLocalStorageWithFibers(PFLS_CALLBACK_FUNCTION cbfunc)
+{
+ void* val1 = (void*) 0x314;
+ void* val2 = (void*) 0x152;
+ BOOL ret;
+
+ if (!pFlsAlloc || !pFlsFree || !pFlsSetValue || !pFlsGetValue)
+ {
+ win_skip( "Fiber Local Storage not supported\n" );
+ return;
+ }
+
+ fls_index_to_set = pFlsAlloc(cbfunc);
+ ok(fls_index_to_set != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error
%u\n", GetLastError());
+
+ test_ConvertThreadToFiber();
+
+ fiberCount = 0;
+ cbCount = 0;
+ fibers[1] = pCreateFiber(0,FiberMainProc,&testparam);
+ fibers[2] = pCreateFiber(0,FiberMainProc,&testparam);
+ ok(fibers[1] != NULL, "CreateFiber failed with error %u\n",
GetLastError());
+ ok(fibers[2] != NULL, "CreateFiber failed with error %u\n",
GetLastError());
+ ok(fiberCount == 0, "Wrong fiber count: %d\n", fiberCount);
+ ok(cbCount == 0, "Wrong callback count: %d\n", cbCount);
+
+ fiberCount = 0;
+ cbCount = 0;
+ fls_value_to_set = val1;
+ pSwitchToFiber(fibers[1]);
+ ok(fiberCount == 1, "Wrong fiber count: %d\n", fiberCount);
+ ok(cbCount == 0, "Wrong callback count: %d\n", cbCount);
+
+ fiberCount = 0;
+ cbCount = 0;
+ fls_value_to_set = val2;
+ pSwitchToFiber(fibers[2]);
+ ok(fiberCount == 1, "Wrong fiber count: %d\n", fiberCount);
+ ok(cbCount == 0, "Wrong callback count: %d\n", cbCount);
+
+ fls_value_to_set = val2;
+ ret = pFlsSetValue(fls_index_to_set, fls_value_to_set);
+ ok(ret, "FlsSetValue failed\n");
+ ok(val2 == pFlsGetValue(fls_index_to_set), "FlsGetValue failed\n");
+
+ fiberCount = 0;
+ cbCount = 0;
+ fls_value_to_set = val1;
+ pDeleteFiber(fibers[1]);
+ ok(fiberCount == 0, "Wrong fiber count: %d\n", fiberCount);
+ todo_wine ok(cbCount == 1, "Wrong callback count: %d\n", cbCount);
+
+ fiberCount = 0;
+ cbCount = 0;
+ fls_value_to_set = val2;
+ pFlsFree(fls_index_to_set);
+ ok(fiberCount == 0, "Wrong fiber count: %d\n", fiberCount);
+ todo_wine ok(cbCount == 2, "Wrong callback count: %d\n", cbCount);
+
+ fiberCount = 0;
+ cbCount = 0;
+ fls_value_to_set = val1;
+ pDeleteFiber(fibers[2]);
+ ok(fiberCount == 0, "Wrong fiber count: %d\n", fiberCount);
+ ok(cbCount == 0, "Wrong callback count: %d\n", cbCount);
+
+ test_ConvertFiberToThread();
}
START_TEST(fiber)
@@ -223,6 +412,7 @@
}
test_FiberHandling();
- test_FiberLocalStorage(NULL);
- test_FiberLocalStorage(FiberLocalStorageProc);
-}
+ test_FiberLocalStorage();
+ test_FiberLocalStorageCallback(FiberLocalStorageProc);
+ test_FiberLocalStorageWithFibers(FiberLocalStorageProc);
+}
Modified: trunk/rostests/winetests/kernel32/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/kernel32/loader…
==============================================================================
--- trunk/rostests/winetests/kernel32/loader.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/kernel32/loader.c [iso-8859-1] Thu Aug 18 09:22:13 2016
@@ -52,6 +52,7 @@
static NTSTATUS (WINAPI *pNtCreateSection)(HANDLE *, ACCESS_MASK, const OBJECT_ATTRIBUTES
*,
const LARGE_INTEGER *, ULONG, ULONG, HANDLE
);
+static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, SECTION_INFORMATION_CLASS, void *,
ULONG, ULONG *);
static NTSTATUS (WINAPI *pNtMapViewOfSection)(HANDLE, HANDLE, PVOID *, ULONG, SIZE_T,
const LARGE_INTEGER *, SIZE_T *, ULONG, ULONG, ULONG);
static NTSTATUS (WINAPI *pNtUnmapViewOfSection)(HANDLE, PVOID);
static NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID,
ULONG, PULONG);
@@ -222,6 +223,115 @@
return size;
}
+static void query_image_section( int id, const char *dll_name, const IMAGE_NT_HEADERS
*nt_header )
+{
+ SECTION_BASIC_INFORMATION info;
+ SECTION_IMAGE_INFORMATION image;
+ ULONG info_size = 0xdeadbeef;
+ NTSTATUS status;
+ HANDLE file, mapping;
+ ULONG file_size;
+ LARGE_INTEGER map_size;
+ /* truncated header is not handled correctly in windows <= w2k3 */
+ BOOL truncated = nt_header->FileHeader.SizeOfOptionalHeader <
sizeof(nt_header->OptionalHeader);
+
+ file = CreateFileA( dll_name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE,
+ NULL, OPEN_EXISTING, 0, 0 );
+ ok( file != INVALID_HANDLE_VALUE, "%u: CreateFile error %d\n", id,
GetLastError() );
+ file_size = GetFileSize( file, NULL );
+
+ status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ
| SECTION_QUERY,
+ NULL, NULL, PAGE_READONLY, SEC_IMAGE, file );
+ ok( !status, "%u: NtCreateSection failed err %x\n", id, status );
+ if (status)
+ {
+ CloseHandle( file );
+ return;
+ }
+ status = pNtQuerySection( mapping, SectionImageInformation, &image,
sizeof(image), &info_size );
+ ok( !status, "%u: NtQuerySection failed err %x\n", id, status );
+ ok( info_size == sizeof(image), "%u: NtQuerySection wrong size %u\n", id,
info_size );
+ ok( (char *)image.TransferAddress == (char *)nt_header->OptionalHeader.ImageBase +
nt_header->OptionalHeader.AddressOfEntryPoint,
+ "%u: TransferAddress wrong %p / %p+%08x\n", id,
+ image.TransferAddress, (char *)nt_header->OptionalHeader.ImageBase,
+ nt_header->OptionalHeader.AddressOfEntryPoint );
+ ok( image.ZeroBits == 0, "%u: ZeroBits wrong %08x\n", id, image.ZeroBits
);
+ ok( image.MaximumStackSize == nt_header->OptionalHeader.SizeOfStackReserve ||
broken(truncated),
+ "%u: MaximumStackSize wrong %lx / %lx\n", id,
+ image.MaximumStackSize, (SIZE_T)nt_header->OptionalHeader.SizeOfStackReserve
);
+ ok( image.CommittedStackSize == nt_header->OptionalHeader.SizeOfStackCommit ||
broken(truncated),
+ "%u: CommittedStackSize wrong %lx / %lx\n", id,
+ image.CommittedStackSize, (SIZE_T)nt_header->OptionalHeader.SizeOfStackCommit
);
+ ok( image.SubSystemType == nt_header->OptionalHeader.Subsystem ||
broken(truncated),
+ "%u: SubSystemType wrong %08x / %08x\n", id,
+ image.SubSystemType, nt_header->OptionalHeader.Subsystem );
+ ok( image.SubsystemVersionLow == nt_header->OptionalHeader.MinorSubsystemVersion,
+ "%u: SubsystemVersionLow wrong %04x / %04x\n", id,
+ image.SubsystemVersionLow, nt_header->OptionalHeader.MinorSubsystemVersion );
+ ok( image.SubsystemVersionHigh ==
nt_header->OptionalHeader.MajorSubsystemVersion,
+ "%u: SubsystemVersionHigh wrong %04x / %04x\n", id,
+ image.SubsystemVersionHigh, nt_header->OptionalHeader.MajorSubsystemVersion
);
+ ok( image.ImageCharacteristics == nt_header->FileHeader.Characteristics,
+ "%u: ImageCharacteristics wrong %04x / %04x\n", id,
+ image.ImageCharacteristics, nt_header->FileHeader.Characteristics );
+ ok( image.DllCharacteristics == nt_header->OptionalHeader.DllCharacteristics ||
broken(truncated),
+ "%u: DllCharacteristics wrong %04x / %04x\n", id,
+ image.DllCharacteristics, nt_header->OptionalHeader.DllCharacteristics );
+ ok( image.Machine == nt_header->FileHeader.Machine, "%u: Machine wrong %04x /
%04x\n", id,
+ image.Machine, nt_header->FileHeader.Machine );
+ ok( image.LoaderFlags == nt_header->OptionalHeader.LoaderFlags,
+ "%u: LoaderFlags wrong %08x / %08x\n", id,
+ image.LoaderFlags, nt_header->OptionalHeader.LoaderFlags );
+ ok( image.ImageFileSize == file_size || broken(!image.ImageFileSize), /* winxpsp1 */
+ "%u: ImageFileSize wrong %08x / %08x\n", id, image.ImageFileSize,
file_size );
+ ok( image.CheckSum == nt_header->OptionalHeader.CheckSum, "%u: CheckSum wrong
%08x / %08x\n", id,
+ image.CheckSum, nt_header->OptionalHeader.CheckSum );
+ /* FIXME: needs more work: */
+ /* image.GpValue */
+ /* image.ImageFlags */
+ /* image.ImageContainsCode */
+
+ map_size.QuadPart = (nt_header->OptionalHeader.SizeOfImage + page_size - 1) &
~(page_size - 1);
+ status = pNtQuerySection( mapping, SectionBasicInformation, &info, sizeof(info),
NULL );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %x%08x /
%x%08x\n",
+ info.Size.u.HighPart, info.Size.u.LowPart, map_size.u.HighPart,
map_size.u.LowPart );
+ CloseHandle( mapping );
+
+ map_size.QuadPart = (nt_header->OptionalHeader.SizeOfImage + page_size - 1) &
~(page_size - 1);
+ status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ
| SECTION_QUERY,
+ NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file );
+ ok( !status, "%u: NtCreateSection failed err %x\n", id, status );
+ status = pNtQuerySection( mapping, SectionBasicInformation, &info, sizeof(info),
NULL );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %x%08x /
%x%08x\n",
+ info.Size.u.HighPart, info.Size.u.LowPart, map_size.u.HighPart,
map_size.u.LowPart );
+ CloseHandle( mapping );
+
+ map_size.QuadPart++;
+ status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ
| SECTION_QUERY,
+ NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file );
+ ok( status == STATUS_SECTION_TOO_BIG, "%u: NtCreateSection failed err
%x\n", id, status );
+
+ SetFilePointerEx( file, map_size, NULL, FILE_BEGIN );
+ SetEndOfFile( file );
+ status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ
| SECTION_QUERY,
+ NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file );
+ ok( status == STATUS_SECTION_TOO_BIG, "%u: NtCreateSection failed err
%x\n", id, status );
+
+ map_size.QuadPart = 1;
+ status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ
| SECTION_QUERY,
+ NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file );
+ ok( !status, "%u: NtCreateSection failed err %x\n", id, status );
+ status = pNtQuerySection( mapping, SectionBasicInformation, &info, sizeof(info),
NULL );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %x%08x /
%x%08x\n",
+ info.Size.u.HighPart, info.Size.u.LowPart, map_size.u.HighPart,
map_size.u.LowPart );
+ CloseHandle( mapping );
+
+ CloseHandle( file );
+}
+
/* helper to test image section mapping */
static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header )
{
@@ -230,19 +340,33 @@
LARGE_INTEGER size;
HANDLE file, map;
NTSTATUS status;
+ ULONG file_size;
GetTempPathA(MAX_PATH, temp_path);
GetTempFileNameA(temp_path, "ldr", 0, dll_name);
- size.u.LowPart = create_test_dll( &dos_header, sizeof(dos_header), nt_header,
dll_name );
- ok( size.u.LowPart, "could not create %s\n", dll_name);
- size.u.HighPart = 0;
+ file_size = create_test_dll( &dos_header, sizeof(dos_header), nt_header, dll_name
);
+ ok( file_size, "could not create %s\n", dll_name);
file = CreateFileA(dll_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0,
0);
ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
- status = pNtCreateSection(&map, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ,
NULL, &size,
- PAGE_READONLY, SEC_IMAGE, file );
+ size.QuadPart = file_size;
+ status = pNtCreateSection(&map, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ |
SECTION_QUERY,
+ NULL, &size, PAGE_READONLY, SEC_IMAGE, file );
+ if (!status)
+ {
+ SECTION_BASIC_INFORMATION info;
+ ULONG info_size = 0xdeadbeef;
+ NTSTATUS ret = pNtQuerySection( map, SectionBasicInformation, &info,
sizeof(info), &info_size );
+ ok( !ret, "NtQuerySection failed err %x\n", ret );
+ ok( info_size == sizeof(info), "NtQuerySection wrong size %u\n",
info_size );
+ ok( info.Attributes == (SEC_IMAGE | SEC_FILE), "NtQuerySection wrong attr
%x\n", info.Attributes );
+ ok( info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
info.BaseAddress );
+ ok( info.Size.QuadPart == file_size, "NtQuerySection wrong size %x%08x /
%08x\n",
+ info.Size.u.HighPart, info.Size.u.LowPart, file_size );
+ query_image_section( 1000, dll_name, nt_header );
+ }
if (map) CloseHandle( map );
CloseHandle( file );
DeleteFileA( dll_name );
@@ -574,6 +698,8 @@
SetLastError(0xdeadbeef);
ret = FreeLibrary(hlib_as_data_file);
ok(ret, "FreeLibrary error %d\n", GetLastError());
+
+ query_image_section( i, dll_name, &nt_header );
}
else
{
@@ -600,6 +726,8 @@
nt_header.FileHeader.SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER);
nt_header.OptionalHeader.SectionAlignment = page_size;
+ nt_header.OptionalHeader.AddressOfEntryPoint = 0x1234;
+ nt_header.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_NX_COMPAT;
nt_header.OptionalHeader.FileAlignment = page_size;
nt_header.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt_header) +
sizeof(IMAGE_SECTION_HEADER);
nt_header.OptionalHeader.SizeOfImage = sizeof(dos_header) + sizeof(nt_header) +
sizeof(IMAGE_SECTION_HEADER) + page_size;
@@ -1817,7 +1945,8 @@
memset(&pbi, 0, sizeof(pbi));
ret = pNtQueryInformationProcess(process, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
ok(!ret, "NtQueryInformationProcess error %#x\n", ret);
- ok(pbi.ExitStatus == STILL_ACTIVE, "expected STILL_ACTIVE, got %lu\n",
pbi.ExitStatus);
+ ok(pbi.ExitStatus == STILL_ACTIVE || pbi.ExitStatus == 195,
+ "expected STILL_ACTIVE, got %lu\n", pbi.ExitStatus);
affinity = 1;
ret = pNtSetInformationProcess(process, ProcessAffinityMask, &affinity,
sizeof(affinity));
ok(!ret, "NtSetInformationProcess error %#x\n", ret);
@@ -1852,7 +1981,8 @@
memset(&pbi, 0, sizeof(pbi));
ret = pNtQueryInformationProcess(process, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
ok(!ret, "NtQueryInformationProcess error %#x\n", ret);
- ok(pbi.ExitStatus == STILL_ACTIVE, "expected STILL_ACTIVE, got %lu\n",
pbi.ExitStatus);
+ ok(pbi.ExitStatus == STILL_ACTIVE || pbi.ExitStatus == 195,
+ "expected STILL_ACTIVE, got %lu\n", pbi.ExitStatus);
affinity = 1;
ret = pNtSetInformationProcess(process, ProcessAffinityMask, &affinity,
sizeof(affinity));
ok(!ret, "NtSetInformationProcess error %#x\n", ret);
@@ -2777,6 +2907,7 @@
ntdll = GetModuleHandleA("ntdll.dll");
pNtCreateSection = (void *)GetProcAddress(ntdll, "NtCreateSection");
+ pNtQuerySection = (void *)GetProcAddress(ntdll, "NtQuerySection");
pNtMapViewOfSection = (void *)GetProcAddress(ntdll, "NtMapViewOfSection");
pNtUnmapViewOfSection = (void *)GetProcAddress(ntdll,
"NtUnmapViewOfSection");
pNtTerminateProcess = (void *)GetProcAddress(ntdll, "NtTerminateProcess");
Modified: trunk/rostests/winetests/kernel32/process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/kernel32/proces…
==============================================================================
--- trunk/rostests/winetests/kernel32/process.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/kernel32/process.c [iso-8859-1] Thu Aug 18 09:22:13 2016
@@ -70,7 +70,6 @@
static BOOL (WINAPI *pQueryFullProcessImageNameA)(HANDLE hProcess, DWORD dwFlags, LPSTR
lpExeName, PDWORD lpdwSize);
static BOOL (WINAPI *pQueryFullProcessImageNameW)(HANDLE hProcess, DWORD dwFlags,
LPWSTR lpExeName, PDWORD lpdwSize);
static DWORD (WINAPI *pK32GetProcessImageFileNameA)(HANDLE,LPSTR,DWORD);
-static struct _TEB * (WINAPI *pNtCurrentTeb)(void);
static HANDLE (WINAPI *pCreateJobObjectW)(LPSECURITY_ATTRIBUTES sa, LPCWSTR name);
static BOOL (WINAPI *pAssignProcessToJobObject)(HANDLE job, HANDLE process);
static BOOL (WINAPI *pIsProcessInJob)(HANDLE process, HANDLE job, PBOOL result);
@@ -226,7 +225,6 @@
hkernel32 = GetModuleHandleA("kernel32");
hntdll = GetModuleHandleA("ntdll.dll");
- pNtCurrentTeb = (void *)GetProcAddress(hntdll, "NtCurrentTeb");
pNtQueryInformationProcess = (void *)GetProcAddress(hntdll,
"NtQueryInformationProcess");
pGetNativeSystemInfo = (void *) GetProcAddress(hkernel32,
"GetNativeSystemInfo");
@@ -297,6 +295,7 @@
*/
static void doChild(const char* file, const char* option)
{
+ RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters;
STARTUPINFOA siA;
STARTUPINFOW siW;
int i;
@@ -325,15 +324,10 @@
siA.dwFlags, siA.wShowWindow,
(DWORD_PTR)siA.hStdInput, (DWORD_PTR)siA.hStdOutput,
(DWORD_PTR)siA.hStdError);
- if (pNtCurrentTeb)
- {
- RTL_USER_PROCESS_PARAMETERS *params =
pNtCurrentTeb()->Peb->ProcessParameters;
-
- /* check the console handles in the TEB */
- childPrintf(hFile,
"[TEB]\nhStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
- (DWORD_PTR)params->hStdInput, (DWORD_PTR)params->hStdOutput,
- (DWORD_PTR)params->hStdError);
- }
+ /* check the console handles in the TEB */
+ childPrintf(hFile,
"[TEB]\nhStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
+ (DWORD_PTR)params->hStdInput, (DWORD_PTR)params->hStdOutput,
+ (DWORD_PTR)params->hStdError);
/* since GetStartupInfoW is only implemented in win2k,
* zero out before calling so we can notice the difference
@@ -2873,12 +2867,6 @@
char buffer[MAX_PATH];
STARTUPINFOA startup;
PROCESS_INFORMATION info;
-
- if (!pNtCurrentTeb)
- {
- win_skip( "NtCurrentTeb not supported\n" );
- return;
- }
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
Modified: trunk/rostests/winetests/kernel32/thread.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/kernel32/thread…
==============================================================================
--- trunk/rostests/winetests/kernel32/thread.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/kernel32/thread.c [iso-8859-1] Thu Aug 18 09:22:13 2016
@@ -1103,42 +1103,42 @@
static void test_GetThreadSelectorEntry(void)
{
- TEB *teb = NtCurrentTeb();
LDT_ENTRY entry;
CONTEXT ctx;
- TEB *teb_fs;
- DWORD ret;
+ DWORD limit;
+ void *base;
+ BOOL ret;
memset(&ctx, 0x11, sizeof(ctx));
ctx.ContextFlags = CONTEXT_SEGMENTS | CONTEXT_CONTROL;
ret = GetThreadContext(GetCurrentThread(), &ctx);
ok(ret, "GetThreadContext error %u\n", GetLastError());
- ok(!HIWORD(ctx.SegCs) && !HIWORD(ctx.SegDs) && !HIWORD(ctx.SegEs)
&& !HIWORD(ctx.SegFs) && !HIWORD(ctx.SegGs),
- "cs %08x, ds %08x, es %08x, fs %08x, gs %08x\n", ctx.SegCs, ctx.SegDs,
ctx.SegEs, ctx.SegFs, ctx.SegGs);
+ ok(!HIWORD(ctx.SegCs), "expected HIWORD(SegCs) == 0, got %u\n",
ctx.SegCs);
+ ok(!HIWORD(ctx.SegDs), "expected HIWORD(SegDs) == 0, got %u\n",
ctx.SegDs);
+ ok(!HIWORD(ctx.SegFs), "expected HIWORD(SegFs) == 0, got %u\n",
ctx.SegFs);
ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegCs, &entry);
ok(ret, "GetThreadSelectorEntry(SegCs) error %u\n", GetLastError());
-
ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegDs, &entry);
ok(ret, "GetThreadSelectorEntry(SegDs) error %u\n", GetLastError());
memset(&entry, 0x11, sizeof(entry));
ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegFs, &entry);
ok(ret, "GetThreadSelectorEntry(SegFs) error %u\n", GetLastError());
-
- teb_fs = (TEB *)((entry.HighWord.Bits.BaseHi << 24) |
(entry.HighWord.Bits.BaseMid << 16) | entry.BaseLow);
- ok(teb_fs == teb, "teb_fs %p != teb %p\n", teb_fs, teb);
-
- ret = (entry.HighWord.Bits.LimitHi << 16) | entry.LimitLow;
- ok(ret == 0x0fff || ret == 0x4000 /* testbot win7u */, "got %#x\n", ret);
-
- ok(entry.HighWord.Bits.Dpl == 3, "got %#x\n", entry.HighWord.Bits.Dpl);
- ok(entry.HighWord.Bits.Sys == 0, "got %#x\n", entry.HighWord.Bits.Sys);
- ok(entry.HighWord.Bits.Pres == 1, "got %#x\n", entry.HighWord.Bits.Pres);
- ok(entry.HighWord.Bits.Granularity == 0, "got %#x\n",
entry.HighWord.Bits.Granularity);
- ok(entry.HighWord.Bits.Default_Big == 1, "got %#x\n",
entry.HighWord.Bits.Default_Big);
- ok(entry.HighWord.Bits.Type == 0x13, "got %#x\n",
entry.HighWord.Bits.Type);
- ok(entry.HighWord.Bits.Reserved_0 == 0, "got %#x\n",
entry.HighWord.Bits.Reserved_0);
+ entry.HighWord.Bits.Type &= ~1; /* ignore accessed bit */
+
+ base = (void *)((entry.HighWord.Bits.BaseHi << 24) |
(entry.HighWord.Bits.BaseMid << 16) | entry.BaseLow);
+ limit = (entry.HighWord.Bits.LimitHi << 16) | entry.LimitLow;
+
+ ok(base == NtCurrentTeb(), "expected %p, got %p\n",
NtCurrentTeb(), base);
+ ok(limit == 0x0fff || limit == 0x4000, "expected 0x0fff or 0x4000, got
%#x\n", limit);
+ ok(entry.HighWord.Bits.Type == 0x12, "expected 0x12, got %#x\n",
entry.HighWord.Bits.Type);
+ ok(entry.HighWord.Bits.Dpl == 3, "expected 3, got %u\n",
entry.HighWord.Bits.Dpl);
+ ok(entry.HighWord.Bits.Pres == 1, "expected 1, got %u\n",
entry.HighWord.Bits.Pres);
+ ok(entry.HighWord.Bits.Sys == 0, "expected 0, got %u\n",
entry.HighWord.Bits.Sys);
+ ok(entry.HighWord.Bits.Reserved_0 == 0, "expected 0, got %u\n",
entry.HighWord.Bits.Reserved_0);
+ ok(entry.HighWord.Bits.Default_Big == 1, "expected 1, got %u\n",
entry.HighWord.Bits.Default_Big);
+ ok(entry.HighWord.Bits.Granularity == 0, "expected 0, got %u\n",
entry.HighWord.Bits.Granularity);
}
static void test_NtSetLdtEntries(void)
Modified: trunk/rostests/winetests/kernel32/virtual.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/kernel32/virtua…
==============================================================================
--- trunk/rostests/winetests/kernel32/virtual.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/kernel32/virtual.c [iso-8859-1] Thu Aug 18 09:22:13 2016
@@ -41,13 +41,15 @@
static UINT (WINAPI *pGetWriteWatch)(DWORD,LPVOID,SIZE_T,LPVOID*,ULONG_PTR*,ULONG*);
static UINT (WINAPI *pResetWriteWatch)(LPVOID,SIZE_T);
static NTSTATUS (WINAPI *pNtAreMappedFilesTheSame)(PVOID,PVOID);
+static NTSTATUS (WINAPI *pNtCreateSection)(HANDLE *, ACCESS_MASK, const OBJECT_ATTRIBUTES
*,
+ const LARGE_INTEGER *, ULONG, ULONG, HANDLE
);
static NTSTATUS (WINAPI *pNtMapViewOfSection)(HANDLE, HANDLE, PVOID *, ULONG, SIZE_T,
const LARGE_INTEGER *, SIZE_T *, ULONG, ULONG, ULONG);
static DWORD (WINAPI *pNtUnmapViewOfSection)(HANDLE, PVOID);
+static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, SECTION_INFORMATION_CLASS, void *,
ULONG, ULONG *);
static PVOID (WINAPI *pRtlAddVectoredExceptionHandler)(ULONG,
PVECTORED_EXCEPTION_HANDLER);
static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID);
static BOOL (WINAPI *pGetProcessDEPPolicy)(HANDLE, LPDWORD, PBOOL);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
-static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, int, PVOID, ULONG, PULONG);
static NTSTATUS (WINAPI *pNtProtectVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG, ULONG
*);
static NTSTATUS (WINAPI *pNtAllocateVirtualMemory)(HANDLE, PVOID *, ULONG, SIZE_T *,
ULONG, ULONG);
static NTSTATUS (WINAPI *pNtFreeVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG);
@@ -112,20 +114,13 @@
SetLastError(0xdeadbeef);
addr1 = pVirtualAllocEx(hProcess, NULL, alloc_size, MEM_COMMIT,
PAGE_EXECUTE_READWRITE);
- if (!addr1 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- { /* Win9x */
- win_skip("VirtualAllocEx not implemented\n");
- TerminateProcess(hProcess, 0);
- CloseHandle(hProcess);
- return;
- }
+ ok(addr1 != NULL, "VirtualAllocEx error %u\n", GetLastError());
src = VirtualAlloc( NULL, alloc_size, MEM_COMMIT, PAGE_READWRITE );
dst = VirtualAlloc( NULL, alloc_size, MEM_COMMIT, PAGE_READWRITE );
for (i = 0; i < alloc_size; i++)
src[i] = i & 0xff;
- ok(addr1 != NULL, "VirtualAllocEx error %u\n", GetLastError());
b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written);
ok(b && (bytes_written == alloc_size), "%lu bytes written\n",
bytes_written);
@@ -174,9 +169,8 @@
SetLastError(0xdeadbeef);
addr1 = pVirtualAllocEx(hProcess, 0, 0, MEM_RESERVE, PAGE_NOACCESS);
ok(addr1 == NULL, "VirtualAllocEx should fail on zero-sized
allocation\n");
- ok(GetLastError() == ERROR_INVALID_PARAMETER /* NT */ ||
- GetLastError() == ERROR_NOT_ENOUGH_MEMORY, /* Win9x */
- "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+ ok(GetLastError() == ERROR_INVALID_PARAMETER,
+ "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
addr1 = pVirtualAllocEx(hProcess, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
ok(addr1 != NULL, "VirtualAllocEx failed\n");
@@ -189,17 +183,13 @@
ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n",
info.AllocationProtect);
ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
- /* NT reports Protect == 0 for a not committed memory block */
- ok(info.Protect == 0 /* NT */ ||
- info.Protect == PAGE_NOACCESS, /* Win9x */
- "%x != PAGE_NOACCESS\n", info.Protect);
+ ok(info.Protect == 0, "%x != PAGE_NOACCESS\n", info.Protect);
ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
SetLastError(0xdeadbeef);
ok(!VirtualProtectEx(hProcess, addr1, 0xFFFC, PAGE_READONLY, &old_prot),
"VirtualProtectEx should fail on a not committed memory\n");
- ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
- GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
+ ok(GetLastError() == ERROR_INVALID_ADDRESS,
"got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
addr2 = pVirtualAllocEx(hProcess, addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
@@ -221,9 +211,8 @@
SetLastError(0xdeadbeef);
ok(!VirtualProtectEx(hProcess, addr1, 0xFFFC, PAGE_READONLY, &old_prot),
"VirtualProtectEx should fail on a not committed memory\n");
- ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
- GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
- "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
+ ok(GetLastError() == ERROR_INVALID_ADDRESS,
+ "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
old_prot = 0;
ok(VirtualProtectEx(hProcess, addr1, 0x1000, PAGE_READONLY, &old_prot),
"VirtualProtectEx failed\n");
@@ -263,8 +252,7 @@
SetLastError(0xdeadbeef);
addr1 = VirtualAlloc(0, 0, MEM_RESERVE, PAGE_NOACCESS);
ok(addr1 == NULL, "VirtualAlloc should fail on zero-sized allocation\n");
- ok(GetLastError() == ERROR_INVALID_PARAMETER /* NT */ ||
- GetLastError() == ERROR_NOT_ENOUGH_MEMORY, /* Win9x */
+ ok(GetLastError() == ERROR_INVALID_PARAMETER,
"got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
addr1 = VirtualAlloc(0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
@@ -278,17 +266,13 @@
ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n",
info.AllocationProtect);
ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
- /* NT reports Protect == 0 for a not committed memory block */
- ok(info.Protect == 0 /* NT */ ||
- info.Protect == PAGE_NOACCESS, /* Win9x */
- "%x != PAGE_NOACCESS\n", info.Protect);
+ ok(info.Protect == 0, "%x != PAGE_NOACCESS\n", info.Protect);
ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
SetLastError(0xdeadbeef);
ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
"VirtualProtect should fail on a not committed memory\n");
- ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
- GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
+ ok( GetLastError() == ERROR_INVALID_ADDRESS,
"got %d, expected ERROR_INVALID_ADDRESS\n", GetLastError());
addr2 = VirtualAlloc(addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
@@ -310,8 +294,7 @@
SetLastError(0xdeadbeef);
ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
"VirtualProtect should fail on a not committed memory\n");
- ok(GetLastError() == ERROR_INVALID_ADDRESS /* NT */ ||
- GetLastError() == ERROR_INVALID_PARAMETER, /* Win9x */
+ ok( GetLastError() == ERROR_INVALID_ADDRESS,
"got %d, expected ERROR_INVALID_ADDRESS\n", GetLastError());
ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtect
failed\n");
@@ -331,30 +314,26 @@
ok( *(DWORD *)addr1 == 0x55555555, "wrong data %x\n", *(DWORD *)addr1 );
addr2 = VirtualAlloc( addr1, 0x1000, MEM_RESET, PAGE_NOACCESS );
- ok( addr2 == addr1 || broken( !addr2 && GetLastError() ==
ERROR_INVALID_PARAMETER), /* win9x */
- "VirtualAlloc failed err %u\n", GetLastError() );
+ ok( addr2 == addr1, "VirtualAlloc failed err %u\n", GetLastError() );
ok( *(DWORD *)addr1 == 0x55555555 || *(DWORD *)addr1 == 0, "wrong data
%x\n", *(DWORD *)addr1 );
- if (addr2)
- {
- ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
- "VirtualQuery failed\n");
- ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
- ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
- ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n",
info.Protect);
-
- addr2 = VirtualAlloc( (char *)addr1 + 0x1000, 0x1000, MEM_RESET, PAGE_NOACCESS
);
- ok( (char *)addr2 == (char *)addr1 + 0x1000, "VirtualAlloc failed\n"
);
-
- ok(VirtualQuery(addr2, &info, sizeof(info)) == sizeof(info),
- "VirtualQuery failed\n");
- ok(info.RegionSize == 0xf000, "%lx != 0xf000\n", info.RegionSize);
- ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
- ok(info.Protect == 0, "%x != 0\n", info.Protect);
-
- addr2 = VirtualAlloc( (char *)addr1 + 0xf000, 0x2000, MEM_RESET, PAGE_NOACCESS
);
- ok( !addr2, "VirtualAlloc failed\n" );
- ok( GetLastError() == ERROR_INVALID_ADDRESS, "wrong error %u\n",
GetLastError() );
- }
+ ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
+ "VirtualQuery failed\n");
+ ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
+ ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
+ ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n",
info.Protect);
+
+ addr2 = VirtualAlloc( (char *)addr1 + 0x1000, 0x1000, MEM_RESET, PAGE_NOACCESS );
+ ok( (char *)addr2 == (char *)addr1 + 0x1000, "VirtualAlloc failed\n" );
+
+ ok(VirtualQuery(addr2, &info, sizeof(info)) == sizeof(info),
+ "VirtualQuery failed\n");
+ ok(info.RegionSize == 0xf000, "%lx != 0xf000\n", info.RegionSize);
+ ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
+ ok(info.Protect == 0, "%x != 0\n", info.Protect);
+
+ addr2 = VirtualAlloc( (char *)addr1 + 0xf000, 0x2000, MEM_RESET, PAGE_NOACCESS );
+ ok( !addr2, "VirtualAlloc failed\n" );
+ ok( GetLastError() == ERROR_INVALID_ADDRESS, "wrong error %u\n",
GetLastError() );
/* invalid protection values */
SetLastError(0xdeadbeef);
@@ -447,8 +426,14 @@
const char *name;
HANDLE file, mapping, map2;
void *ptr, *ptr2, *addr;
+ SECTION_BASIC_INFORMATION section_info;
+ SECTION_IMAGE_INFORMATION image_info;
MEMORY_BASIC_INFORMATION info;
BOOL ret;
+ SIZE_T size;
+ NTSTATUS status;
+ ULONG info_size;
+ LARGE_INTEGER map_size;
SetLastError(0xdeadbeef);
file = CreateFileA( testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0,
0 );
@@ -464,14 +449,13 @@
SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
- ok( ptr != NULL, "MapViewOfFile FILE_MAPE_READ error %u\n", GetLastError()
);
+ ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError()
);
UnmapViewOfFile( ptr );
- /* this fails on win9x but succeeds on NT */
SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
- if (ptr) UnmapViewOfFile( ptr );
- else ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n",
GetLastError() );
+ ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY error %u\n", GetLastError()
);
+ UnmapViewOfFile( ptr );
SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
@@ -496,24 +480,21 @@
ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
SetLastError(0xdeadbeef);
ptr = MapViewOfFile( map2, FILE_MAP_WRITE, 0, 0, 4096 );
- if (!ptr)
- {
- ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n",
GetLastError() );
- CloseHandle( map2 );
- ret = DuplicateHandle( GetCurrentProcess(), mapping, GetCurrentProcess(),
&map2, 0, FALSE, 0 );
- ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
- SetLastError(0xdeadbeef);
- ptr = MapViewOfFile( map2, 0, 0, 0, 4096 );
- ok( !ptr, "MapViewOfFile succeeded\n" );
- ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n",
GetLastError() );
- CloseHandle( map2 );
- ret = DuplicateHandle( GetCurrentProcess(), mapping, GetCurrentProcess(),
&map2,
- FILE_MAP_READ, FALSE, 0 );
- ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
- ptr = MapViewOfFile( map2, 0, 0, 0, 4096 );
- ok( ptr != NULL, "MapViewOfFile NO_ACCESS error %u\n", GetLastError()
);
- }
- else win_skip( "no access checks on win9x\n" );
+ ok( !ptr, "MapViewOfFile succeeded\n" );
+ ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n",
GetLastError() );
+ CloseHandle( map2 );
+ ret = DuplicateHandle( GetCurrentProcess(), mapping, GetCurrentProcess(), &map2,
0, FALSE, 0 );
+ ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
+ SetLastError(0xdeadbeef);
+ ptr = MapViewOfFile( map2, 0, 0, 0, 4096 );
+ ok( !ptr, "MapViewOfFile succeeded\n" );
+ ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n",
GetLastError() );
+ CloseHandle( map2 );
+ ret = DuplicateHandle( GetCurrentProcess(), mapping, GetCurrentProcess(), &map2,
+ FILE_MAP_READ, FALSE, 0 );
+ ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
+ ptr = MapViewOfFile( map2, 0, 0, 0, 4096 );
+ ok( ptr != NULL, "MapViewOfFile NO_ACCESS error %u\n", GetLastError() );
UnmapViewOfFile( ptr );
CloseHandle( map2 );
@@ -530,11 +511,10 @@
ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError()
);
UnmapViewOfFile( ptr );
- /* this fails on win9x but succeeds on NT */
SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
- if (ptr) UnmapViewOfFile( ptr );
- else ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n",
GetLastError() );
+ ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY error %u\n", GetLastError()
);
+ UnmapViewOfFile( ptr );
SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
@@ -580,33 +560,8 @@
SetLastError(0xdeadbeef);
mapping = CreateFileMappingA( file, NULL, PAGE_NOACCESS, 0, 4096, NULL );
- /* fails on NT but succeeds on win9x */
- if (!mapping) ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error
%d\n", GetLastError() );
- else
- {
- SetLastError(0xdeadbeef);
- ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
- ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n",
GetLastError() );
- UnmapViewOfFile( ptr );
-
- SetLastError(0xdeadbeef);
- ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
- ok( !ptr, "MapViewOfFile FILE_MAP_COPY succeeded\n" );
- ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n",
GetLastError() );
-
- SetLastError(0xdeadbeef);
- ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
- ok( ptr != NULL, "MapViewOfFile 0 error %u\n", GetLastError() );
- UnmapViewOfFile( ptr );
-
- SetLastError(0xdeadbeef);
- ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
- ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
- ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n",
GetLastError() );
-
- CloseHandle( mapping );
- }
-
+ ok( !mapping, "CreateFileMappingA succeeded\n" );
+ ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n",
GetLastError() );
CloseHandle( file );
/* now try read-only file */
@@ -661,12 +616,12 @@
SetLastError(0xdeadbeef);
name = "Local\\Foo";
- file = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, name
);
+ file = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4090, name
);
/* nt4 doesn't have Local\\ */
if (!file && GetLastError() == ERROR_PATH_NOT_FOUND)
{
name = "Foo";
- file = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096,
name );
+ file = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4090,
name );
}
ok( file != 0, "CreateFileMapping PAGE_READWRITE error %u\n",
GetLastError() );
@@ -675,26 +630,37 @@
ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %u\n",
GetLastError() );
SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
- if (!ptr)
- {
- SIZE_T size;
- ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n",
GetLastError() );
- SetLastError(0xdeadbeef);
- ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
- ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n",
GetLastError() );
- SetLastError(0xdeadbeef);
- size = VirtualQuery( ptr, &info, sizeof(info) );
- ok( size == sizeof(info),
- "VirtualQuery error %u\n", GetLastError() );
- ok( info.BaseAddress == ptr, "%p != %p\n", info.BaseAddress, ptr );
- ok( info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr
);
- ok( info.AllocationProtect == PAGE_READONLY, "%x != PAGE_READONLY\n",
info.AllocationProtect );
- ok( info.RegionSize == 4096, "%lx != 4096\n", info.RegionSize );
- ok( info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State );
- ok( info.Protect == PAGE_READONLY, "%x != PAGE_READONLY\n",
info.Protect );
- }
- else win_skip( "no access checks on win9x\n" );
+ ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
+ ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n",
GetLastError() );
+ SetLastError(0xdeadbeef);
+ ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
+ ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError()
);
+ SetLastError(0xdeadbeef);
+ size = VirtualQuery( ptr, &info, sizeof(info) );
+ ok( size == sizeof(info),
+ "VirtualQuery error %u\n", GetLastError() );
+ ok( info.BaseAddress == ptr, "%p != %p\n", info.BaseAddress, ptr );
+ ok( info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr );
+ ok( info.AllocationProtect == PAGE_READONLY, "%x != PAGE_READONLY\n",
info.AllocationProtect );
+ ok( info.RegionSize == 4096, "%lx != 4096\n", info.RegionSize );
+ ok( info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State );
+ ok( info.Protect == PAGE_READONLY, "%x != PAGE_READONLY\n", info.Protect
);
UnmapViewOfFile( ptr );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
+ sizeof(section_info), &info_size );
+ ok( status == STATUS_ACCESS_DENIED, "NtQuerySection failed err %x\n",
status );
+ CloseHandle( mapping );
+ mapping = OpenFileMappingA( FILE_MAP_READ | SECTION_QUERY, FALSE, name );
+ ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %u\n",
GetLastError() );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
+ sizeof(section_info), &info_size );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n",
info_size );
+ ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr
%08x\n",
+ section_info.Attributes );
+ ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
section_info.BaseAddress );
+ ok( section_info.Size.QuadPart == info.RegionSize, "NtQuerySection wrong size
%x%08x / %08lx\n",
+ section_info.Size.u.HighPart, section_info.Size.u.LowPart, info.RegionSize );
CloseHandle( mapping );
SetLastError(0xdeadbeef);
@@ -702,26 +668,38 @@
ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %u\n",
GetLastError() );
SetLastError(0xdeadbeef);
ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
- if (!ptr)
- {
- SIZE_T size;
- ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n",
GetLastError() );
- SetLastError(0xdeadbeef);
- ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
- ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %u\n",
GetLastError() );
- SetLastError(0xdeadbeef);
- size = VirtualQuery( ptr, &info, sizeof(info) );
- ok( size == sizeof(info),
- "VirtualQuery error %u\n", GetLastError() );
- ok( info.BaseAddress == ptr, "%p != %p\n", info.BaseAddress, ptr );
- ok( info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr
);
- ok( info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n",
info.AllocationProtect );
- ok( info.RegionSize == 4096, "%lx != 4096\n", info.RegionSize );
- ok( info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State );
- ok( info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n",
info.Protect );
- }
- else win_skip( "no access checks on win9x\n" );
+ ok( !ptr, "MapViewOfFile succeeded\n" );
+ ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n",
GetLastError() );
+ SetLastError(0xdeadbeef);
+ ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
+ ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %u\n", GetLastError()
);
+ SetLastError(0xdeadbeef);
+ size = VirtualQuery( ptr, &info, sizeof(info) );
+ ok( size == sizeof(info),
+ "VirtualQuery error %u\n", GetLastError() );
+ ok( info.BaseAddress == ptr, "%p != %p\n", info.BaseAddress, ptr );
+ ok( info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr );
+ ok( info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n",
info.AllocationProtect );
+ ok( info.RegionSize == 4096, "%lx != 4096\n", info.RegionSize );
+ ok( info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State );
+ ok( info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect
);
UnmapViewOfFile( ptr );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
+ sizeof(section_info), &info_size );
+ ok( status == STATUS_ACCESS_DENIED, "NtQuerySection failed err %x\n",
status );
+ CloseHandle( mapping );
+
+ mapping = OpenFileMappingA( FILE_MAP_WRITE | SECTION_QUERY, FALSE, name );
+ ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %u\n",
GetLastError() );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
+ sizeof(section_info), &info_size );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n",
info_size );
+ ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr
%08x\n",
+ section_info.Attributes );
+ ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
section_info.BaseAddress );
+ ok( section_info.Size.QuadPart == info.RegionSize, "NtQuerySection wrong size
%x%08x / %08lx\n",
+ section_info.Size.u.HighPart, section_info.Size.u.LowPart, info.RegionSize );
CloseHandle( mapping );
CloseHandle( file );
@@ -729,14 +707,21 @@
/* read/write mapping with SEC_RESERVE */
mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE |
SEC_RESERVE, 0, MAPPING_SIZE, NULL);
ok(mapping != INVALID_HANDLE_VALUE, "CreateFileMappingA failed with error
%d\n", GetLastError());
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
+ sizeof(section_info), NULL );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( section_info.Attributes == SEC_RESERVE, "NtQuerySection wrong attr
%08x\n",
+ section_info.Attributes );
+ ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
section_info.BaseAddress );
+ ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size
%x%08x / %08x\n",
+ section_info.Size.u.HighPart, section_info.Size.u.LowPart, MAPPING_SIZE );
ptr = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
ok(ptr != NULL, "MapViewOfFile failed with error %d\n", GetLastError());
ptr2 = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
- /* on NT ptr != ptr2 but on Win9x ptr == ptr2 */
- ok(ptr2 != NULL, "MapViewOfFile failed with error %d\n", GetLastError());
- trace("mapping same section resulted in views %p and %p\n", ptr, ptr2);
+ ok( ptr2 != NULL, "MapViewOfFile failed with error %d\n", GetLastError());
+ ok( ptr != ptr2, "MapViewOfFile returned same pointer\n" );
ret = VirtualQuery(ptr, &info, sizeof(info));
ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
@@ -744,40 +729,24 @@
ok(info.AllocationBase == ptr, "AllocationBase should have been %p but was %p
instead\n", ptr, info.AllocationBase);
ok(info.RegionSize == MAPPING_SIZE, "RegionSize should have been 0x%x but was
0x%lx\n", MAPPING_SIZE, info.RegionSize);
ok(info.State == MEM_RESERVE, "State should have been MEM_RESERVE instead of
0x%x\n", info.State);
- if (info.Type == MEM_PRIVATE) /* win9x is different for uncommitted mappings */
- {
- ok(info.AllocationProtect == PAGE_NOACCESS,
- "AllocationProtect should have been PAGE_NOACCESS but was 0x%x\n",
info.AllocationProtect);
- ok(info.Protect == PAGE_NOACCESS,
- "Protect should have been PAGE_NOACCESS instead of 0x%x\n",
info.Protect);
- }
- else
- {
- ok(info.AllocationProtect == PAGE_READWRITE,
- "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n",
info.AllocationProtect);
- ok(info.Protect == 0, "Protect should have been 0 instead of 0x%x\n",
info.Protect);
- ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of
0x%x\n", info.Type);
- }
-
- if (ptr != ptr2)
- {
- ret = VirtualQuery(ptr2, &info, sizeof(info));
- ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
- ok(info.BaseAddress == ptr2,
- "BaseAddress should have been %p but was %p instead\n", ptr2,
info.BaseAddress);
- ok(info.AllocationBase == ptr2,
- "AllocationBase should have been %p but was %p instead\n", ptr2,
info.AllocationBase);
- ok(info.AllocationProtect == PAGE_READWRITE,
- "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n",
info.AllocationProtect);
- ok(info.RegionSize == MAPPING_SIZE,
- "RegionSize should have been 0x%x but was 0x%lx\n", MAPPING_SIZE,
info.RegionSize);
- ok(info.State == MEM_RESERVE,
- "State should have been MEM_RESERVE instead of 0x%x\n",
info.State);
- ok(info.Protect == 0,
- "Protect should have been 0 instead of 0x%x\n", info.Protect);
- ok(info.Type == MEM_MAPPED,
- "Type should have been MEM_MAPPED instead of 0x%x\n", info.Type);
- }
+ ok(info.AllocationProtect == PAGE_READWRITE,
+ "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n",
info.AllocationProtect);
+ ok(info.Protect == 0, "Protect should have been 0 instead of 0x%x\n",
info.Protect);
+ ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of
0x%x\n", info.Type);
+
+ ret = VirtualQuery(ptr2, &info, sizeof(info));
+ ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+ ok(info.BaseAddress == ptr2,
+ "BaseAddress should have been %p but was %p instead\n", ptr2,
info.BaseAddress);
+ ok(info.AllocationBase == ptr2,
+ "AllocationBase should have been %p but was %p instead\n", ptr2,
info.AllocationBase);
+ ok(info.AllocationProtect == PAGE_READWRITE,
+ "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n",
info.AllocationProtect);
+ ok(info.RegionSize == MAPPING_SIZE,
+ "RegionSize should have been 0x%x but was 0x%lx\n", MAPPING_SIZE,
info.RegionSize);
+ ok(info.State == MEM_RESERVE, "State should have been MEM_RESERVE instead of
0x%x\n", info.State);
+ ok(info.Protect == 0, "Protect should have been 0 instead of 0x%x\n",
info.Protect);
+ ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of
0x%x\n", info.Type);
ptr = VirtualAlloc(ptr, 0x10000, MEM_COMMIT, PAGE_READONLY);
ok(ptr != NULL, "VirtualAlloc failed with error %d\n", GetLastError());
@@ -789,48 +758,35 @@
ok(info.RegionSize == 0x10000, "RegionSize should have been 0x10000 but was
0x%lx\n", info.RegionSize);
ok(info.State == MEM_COMMIT, "State should have been MEM_COMMIT instead of
0x%x\n", info.State);
ok(info.Protect == PAGE_READONLY, "Protect should have been PAGE_READONLY
instead of 0x%x\n", info.Protect);
- if (info.Type == MEM_PRIVATE) /* win9x is different for uncommitted mappings */
- {
- ok(info.AllocationProtect == PAGE_NOACCESS,
- "AllocationProtect should have been PAGE_NOACCESS but was 0x%x\n",
info.AllocationProtect);
- }
- else
- {
- ok(info.AllocationProtect == PAGE_READWRITE,
- "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n",
info.AllocationProtect);
- ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of
0x%x\n", info.Type);
- }
+ ok(info.AllocationProtect == PAGE_READWRITE,
+ "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n",
info.AllocationProtect);
+ ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of
0x%x\n", info.Type);
/* shows that the VirtualAlloc above affects the mapping, not just the
* virtual memory in this process - it also affects all other processes
* with a view of the mapping, but that isn't tested here */
- if (ptr != ptr2)
- {
- ret = VirtualQuery(ptr2, &info, sizeof(info));
- ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
- ok(info.BaseAddress == ptr2,
- "BaseAddress should have been %p but was %p instead\n", ptr2,
info.BaseAddress);
- ok(info.AllocationBase == ptr2,
- "AllocationBase should have been %p but was %p instead\n", ptr2,
info.AllocationBase);
- ok(info.AllocationProtect == PAGE_READWRITE,
- "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n",
info.AllocationProtect);
- ok(info.RegionSize == 0x10000,
- "RegionSize should have been 0x10000 but was 0x%lx\n",
info.RegionSize);
- ok(info.State == MEM_COMMIT,
- "State should have been MEM_COMMIT instead of 0x%x\n", info.State);
- ok(info.Protect == PAGE_READWRITE,
- "Protect should have been PAGE_READWRITE instead of 0x%x\n",
info.Protect);
- ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of
0x%x\n", info.Type);
- }
+ ret = VirtualQuery(ptr2, &info, sizeof(info));
+ ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+ ok(info.BaseAddress == ptr2,
+ "BaseAddress should have been %p but was %p instead\n", ptr2,
info.BaseAddress);
+ ok(info.AllocationBase == ptr2,
+ "AllocationBase should have been %p but was %p instead\n", ptr2,
info.AllocationBase);
+ ok(info.AllocationProtect == PAGE_READWRITE,
+ "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n",
info.AllocationProtect);
+ ok(info.RegionSize == 0x10000,
+ "RegionSize should have been 0x10000 but was 0x%lx\n",
info.RegionSize);
+ ok(info.State == MEM_COMMIT,
+ "State should have been MEM_COMMIT instead of 0x%x\n", info.State);
+ ok(info.Protect == PAGE_READWRITE,
+ "Protect should have been PAGE_READWRITE instead of 0x%x\n",
info.Protect);
+ ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of
0x%x\n", info.Type);
addr = VirtualAlloc( ptr, MAPPING_SIZE, MEM_RESET, PAGE_READONLY );
- ok( addr == ptr || broken(!addr && GetLastError() ==
ERROR_INVALID_PARAMETER), /* win9x */
- "VirtualAlloc failed with error %u\n", GetLastError() );
+ ok( addr == ptr, "VirtualAlloc failed with error %u\n", GetLastError() );
ret = VirtualFree( ptr, 0x10000, MEM_DECOMMIT );
- ok( !ret || broken(ret) /* win9x */, "VirtualFree succeeded\n" );
- if (!ret)
- ok( GetLastError() == ERROR_INVALID_PARAMETER, "VirtualFree failed with
%u\n", GetLastError() );
+ ok( !ret, "VirtualFree succeeded\n" );
+ ok( GetLastError() == ERROR_INVALID_PARAMETER, "VirtualFree failed with
%u\n", GetLastError() );
ret = UnmapViewOfFile(ptr2);
ok(ret, "UnmapViewOfFile failed with error %d\n", GetLastError());
@@ -950,6 +906,15 @@
SetLastError(0xdeadbeef);
ret = CloseHandle(map2);
ok(ret, "CloseHandle error %d\n", GetLastError());
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
+ sizeof(section_info), &info_size );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n",
info_size );
+ ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr
%08x\n",
+ section_info.Attributes );
+ ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
section_info.BaseAddress );
+ ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size
%x%08x\n",
+ section_info.Size.u.HighPart, section_info.Size.u.LowPart );
SetLastError(0xdeadbeef);
ret = CloseHandle(mapping);
ok(ret, "CloseHandle error %d\n", GetLastError());
@@ -1013,30 +978,117 @@
ok(info.Type == 0, "%#x != 0\n", info.Type);
mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 12288, NULL );
- ok( mapping != 0, "CreateFileMappingA failed with error %u\n",
GetLastError() );
+ ok( mapping != NULL, "CreateFileMappingA failed with error %u\n",
GetLastError() );
ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 12288 );
ok( ptr != NULL, "MapViewOfFile failed with error %u\n", GetLastError() );
ret = UnmapViewOfFile( (char *)ptr + 100 );
ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
- if (!ret) UnmapViewOfFile( ptr );
ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 12288 );
ok( ptr != NULL, "MapViewOfFile failed with error %u\n", GetLastError() );
ret = UnmapViewOfFile( (char *)ptr + 4096 );
ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
- if (!ret) UnmapViewOfFile( ptr );
ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 12288 );
ok( ptr != NULL, "MapViewOfFile failed with error %u\n", GetLastError() );
ret = UnmapViewOfFile( (char *)ptr + 4096 + 100 );
ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
- if (!ret) UnmapViewOfFile( ptr );
CloseHandle(mapping);
+
+ mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 36, NULL );
+ ok( mapping != NULL, "CreateFileMappingA failed with error %u\n",
GetLastError() );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
+ sizeof(section_info), &info_size );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n",
info_size );
+ ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr
%08x\n",
+ section_info.Attributes );
+ ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
section_info.BaseAddress );
+ ok( section_info.Size.QuadPart == 36, "NtQuerySection wrong size
%x%08x\n",
+ section_info.Size.u.HighPart, section_info.Size.u.LowPart );
+ CloseHandle(mapping);
+
+ SetFilePointer(file, 0x3456, NULL, FILE_BEGIN);
+ SetEndOfFile(file);
+ mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 0, NULL );
+ ok( mapping != NULL, "CreateFileMappingA failed with error %u\n",
GetLastError() );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
+ sizeof(section_info), &info_size );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n",
info_size );
+ ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr
%08x\n",
+ section_info.Attributes );
+ ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
section_info.BaseAddress );
+ ok( section_info.Size.QuadPart == 0x3456, "NtQuerySection wrong size
%x%08x\n",
+ section_info.Size.u.HighPart, section_info.Size.u.LowPart );
+ CloseHandle(mapping);
+
+ map_size.QuadPart = 0x3457;
+ status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
+ &map_size, PAGE_READONLY, SEC_COMMIT, file );
+ ok( status == STATUS_SECTION_TOO_BIG, "NtCreateSection failed %x\n", status
);
+ status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
+ &map_size, PAGE_READONLY, SEC_IMAGE, file );
+ ok( status == STATUS_INVALID_IMAGE_NOT_MZ, "NtCreateSection failed %x\n",
status );
+ if (!status) CloseHandle( mapping );
+ map_size.QuadPart = 0x3452;
+ status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
+ &map_size, PAGE_READONLY, SEC_COMMIT, file );
+ ok( !status, "NtCreateSection failed %x\n", status );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info), NULL );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr
%08x\n",
+ section_info.Attributes );
+ ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
section_info.BaseAddress );
+ ok( section_info.Size.QuadPart == 0x3452, "NtQuerySection wrong size
%x%08x\n",
+ section_info.Size.u.HighPart, section_info.Size.u.LowPart );
+ size = map_size.QuadPart;
+ status = pNtMapViewOfSection( mapping, GetCurrentProcess(), &ptr, 0, 0, NULL,
+ &size, ViewShare, 0, PAGE_READONLY );
+ ok( !status, "NtMapViewOfSection failed err %x\n", status );
+ pNtUnmapViewOfSection( GetCurrentProcess(), ptr );
+ size = map_size.QuadPart + 1;
+ status = pNtMapViewOfSection( mapping, GetCurrentProcess(), &ptr, 0, 0, NULL,
+ &size, ViewShare, 0, PAGE_READONLY );
+ ok( status == STATUS_INVALID_VIEW_SIZE, "NtMapViewOfSection failed err
%x\n", status );
+ CloseHandle(mapping);
+
+ status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
+ &map_size, PAGE_READONLY, SEC_COMMIT, 0 );
+ ok( !status, "NtCreateSection failed %x\n", status );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info), NULL );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr
%08x\n",
+ section_info.Attributes );
+ ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n",
section_info.BaseAddress );
+ ok( section_info.Size.QuadPart == 0x4000, "NtQuerySection wrong size
%x%08x\n",
+ section_info.Size.u.HighPart, section_info.Size.u.LowPart );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info)-1, NULL );
+ ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySection failed err
%x\n", status );
+ status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info)+1, NULL );
+ ok( !status, "NtQuerySection failed err %x\n", status );
+ status = pNtQuerySection( mapping, SectionImageInformation, &image_info,
sizeof(image_info)-1, NULL );
+ ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySection failed err
%x\n", status );
+ status = pNtQuerySection( mapping, SectionImageInformation, &image_info,
sizeof(image_info), NULL );
+ ok( status == STATUS_SECTION_NOT_IMAGE, "NtQuerySection failed err %x\n",
status );
+ status = pNtQuerySection( mapping, SectionImageInformation, &image_info,
sizeof(image_info)+1, NULL );
+ ok( status == STATUS_SECTION_NOT_IMAGE, "NtQuerySection failed err %x\n",
status );
+ CloseHandle(mapping);
+
+ SetFilePointer(file, 0, NULL, FILE_BEGIN);
+ SetEndOfFile(file);
+ status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
+ NULL, PAGE_READONLY, SEC_COMMIT, file );
+ ok( status == STATUS_MAPPED_FILE_SIZE_ZERO, "NtCreateSection failed %x\n",
status );
+ status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
+ NULL, PAGE_READONLY, SEC_IMAGE, file );
+ ok( status == STATUS_INVALID_FILE_FOR_SECTION, "NtCreateSection failed
%x\n", status );
+
CloseHandle(file);
DeleteFileA(testfile);
}
@@ -1413,8 +1465,7 @@
SetLastError(0xdeadbeef);
handle2 = OpenFileMappingA( FILE_MAP_ALL_ACCESS, FALSE, "WINE TEST
MAPPING");
ok( !handle2, "OpenFileMapping succeeded\n");
- ok( GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_INVALID_NAME /*
win9x */,
- "wrong error %u\n", GetLastError());
+ ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n",
GetLastError());
CloseHandle( handle );
}
@@ -3868,7 +3919,6 @@
ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
ok(ret == sizeof(info.basic), "wrong returned size %u\n", ret);
ok(info.basic.BaseAddress == NULL, "expected NULL, got %p\n",
info.basic.BaseAddress);
-todo_wine
ok(info.basic.Attributes == SEC_FILE, "expected SEC_FILE, got %#x\n",
info.basic.Attributes);
ok(info.basic.Size.QuadPart == fsize, "expected %#lx, got %#x/%08x\n",
fsize, info.basic.Size.HighPart, info.basic.Size.LowPart);
@@ -3884,6 +3934,87 @@
nt = image_nt_header(p);
image_size = ROUND_SIZE(p, nt->OptionalHeader.SizeOfImage);
+
+ memset(&info, 0x55, sizeof(info));
+ ret = 0xdeadbeef;
+ status = pNtQuerySection(mapping, SectionBasicInformation, &info, sizeof(info),
&ret);
+ ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
+ ok(ret == sizeof(info.basic), "wrong returned size %u\n", ret);
+ ok(info.basic.BaseAddress == NULL, "expected NULL, got %p\n",
info.basic.BaseAddress);
+ ok(info.basic.Attributes == SEC_FILE, "expected SEC_FILE, got %#x\n",
info.basic.Attributes);
+ ok(info.basic.Size.QuadPart == fsize, "expected %#lx, got %#x/%08x\n",
fsize, info.basic.Size.HighPart, info.basic.Size.LowPart);
+
+ UnmapViewOfFile(p);
+ CloseHandle(mapping);
+
+ SetLastError(0xdeadbef);
+ mapping = CreateFileMappingA(file, NULL, PAGE_EXECUTE_READ|SEC_IMAGE, 0, 0, NULL);
+ /* NT4 and win2k don't support EXEC on file mappings */
+ if (!mapping)
+ mapping = CreateFileMappingA(file, NULL, PAGE_READONLY|SEC_IMAGE, 0, 0, NULL);
+ ok(mapping != 0, "CreateFileMapping error %u\n", GetLastError());
+
+ memset(&info, 0x55, sizeof(info));
+ ret = 0xdeadbeef;
+ status = pNtQuerySection(mapping, SectionBasicInformation, &info, sizeof(info),
&ret);
+ ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
+ ok(ret == sizeof(info.basic), "wrong returned size %u\n", ret);
+ ok(info.basic.BaseAddress == NULL, "expected NULL, got %p\n",
info.basic.BaseAddress);
+ ok(info.basic.Attributes == (SEC_FILE|SEC_IMAGE), "expected SEC_FILE|SEC_IMAGE,
got %#x\n", info.basic.Attributes);
+ ok(info.basic.Size.QuadPart == image_size, "expected %#lx, got %#x/%08x\n",
image_size, info.basic.Size.HighPart, info.basic.Size.LowPart);
+
+ status = pNtQuerySection(mapping, SectionImageInformation, NULL, sizeof(info),
&ret);
+ ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got
%#x\n", status);
+
+ status = pNtQuerySection(mapping, SectionImageInformation, &info, 0, NULL);
+ ok(status == STATUS_INFO_LENGTH_MISMATCH, "expected STATUS_INFO_LENGTH_MISMATCH,
got %#x\n", status);
+
+ status = pNtQuerySection(mapping, SectionImageInformation, &info, 0, &ret);
+ ok(status == STATUS_INFO_LENGTH_MISMATCH, "expected STATUS_INFO_LENGTH_MISMATCH,
got %#x\n", status);
+
+ status = pNtQuerySection(mapping, SectionImageInformation, &info,
sizeof(info.basic), &ret);
+ ok(status == STATUS_INFO_LENGTH_MISMATCH, "expected STATUS_INFO_LENGTH_MISMATCH,
got %#x\n", status);
+
+ SetLastError(0xdeadbef);
+ p = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
+ ok(p != NULL, "MapViewOfFile error %u\n", GetLastError());
+
+ nt = image_nt_header(p);
+
+ memset(&info, 0x55, sizeof(info));
+ ret = 0xdeadbeef;
+ status = pNtQuerySection(mapping, SectionImageInformation, &info, sizeof(info),
&ret);
+ ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
+ ok(ret == sizeof(info.image), "wrong returned size %u\n", ret);
+ ok((ULONG_PTR)info.image.TransferAddress == nt->OptionalHeader.ImageBase +
nt->OptionalHeader.AddressOfEntryPoint,
+ "expected %#lx, got %p\n", (SIZE_T)(nt->OptionalHeader.ImageBase +
nt->OptionalHeader.AddressOfEntryPoint), info.image.TransferAddress);
+ ok(info.image.ZeroBits == 0, "expected 0, got %#x\n",
info.image.ZeroBits);
+ ok(info.image.MaximumStackSize == nt->OptionalHeader.SizeOfStackReserve,
"expected %#lx, got %#lx\n", (SIZE_T)nt->OptionalHeader.SizeOfStackReserve,
info.image.MaximumStackSize);
+ ok(info.image.CommittedStackSize == nt->OptionalHeader.SizeOfStackCommit,
"expected %#lx, got %#lx\n", (SIZE_T)nt->OptionalHeader.SizeOfStackCommit,
info.image.CommittedStackSize);
+ ok(info.image.SubSystemType == nt->OptionalHeader.Subsystem, "expected %#x,
got %#x\n", nt->OptionalHeader.Subsystem, info.image.SubSystemType);
+ ok(info.image.SubsystemVersionLow == nt->OptionalHeader.MinorSubsystemVersion,
"expected %#x, got %#x\n", nt->OptionalHeader.MinorSubsystemVersion,
info.image.SubsystemVersionLow);
+ ok(info.image.SubsystemVersionHigh == nt->OptionalHeader.MajorSubsystemVersion,
"expected %#x, got %#x\n", nt->OptionalHeader.MajorSubsystemVersion,
info.image.SubsystemVersionHigh);
+ ok(info.image.ImageCharacteristics == nt->FileHeader.Characteristics,
"expected %#x, got %#x\n", nt->FileHeader.Characteristics,
info.image.ImageCharacteristics);
+ ok(info.image.DllCharacteristics == nt->OptionalHeader.DllCharacteristics,
"expected %#x, got %#x\n", nt->OptionalHeader.DllCharacteristics,
info.image.DllCharacteristics);
+ ok(info.image.Machine == nt->FileHeader.Machine, "expected %#x, got
%#x\n", nt->FileHeader.Machine, info.image.Machine);
+todo_wine
+ ok(info.image.ImageContainsCode == TRUE, "expected 1, got %#x\n",
info.image.ImageContainsCode);
+
+ memset(&info, 0x55, sizeof(info));
+ ret = 0xdeadbeef;
+ status = pNtQuerySection(mapping, SectionBasicInformation, &info, sizeof(info),
&ret);
+ ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
+ ok(ret == sizeof(info.basic), "wrong returned size %u\n", ret);
+ ok(info.basic.BaseAddress == NULL, "expected NULL, got %p\n",
info.basic.BaseAddress);
+ ok(info.basic.Attributes == (SEC_FILE|SEC_IMAGE), "expected SEC_FILE|SEC_IMAGE,
got %#x\n", info.basic.Attributes);
+ ok(info.basic.Size.QuadPart == image_size, "expected %#lx, got %#x/%08x\n",
image_size, info.basic.Size.HighPart, info.basic.Size.LowPart);
+
+ UnmapViewOfFile(p);
+ CloseHandle(mapping);
+
+ SetLastError(0xdeadbef);
+ mapping = CreateFileMappingA(file, NULL, PAGE_READONLY|SEC_COMMIT|SEC_NOCACHE, 0, 0,
NULL);
+ ok(mapping != 0, "CreateFileMapping error %u\n", GetLastError());
memset(&info, 0x55, sizeof(info));
ret = 0xdeadbeef;
@@ -3895,14 +4026,10 @@
ok(info.basic.Attributes == SEC_FILE, "expected SEC_FILE, got %#x\n",
info.basic.Attributes);
ok(info.basic.Size.QuadPart == fsize, "expected %#lx, got %#x/%08x\n",
fsize, info.basic.Size.HighPart, info.basic.Size.LowPart);
- UnmapViewOfFile(p);
CloseHandle(mapping);
SetLastError(0xdeadbef);
- mapping = CreateFileMappingA(file, NULL, PAGE_EXECUTE_READ|SEC_IMAGE, 0, 0, NULL);
- /* NT4 and win2k don't support EXEC on file mappings */
- if (!mapping)
- mapping = CreateFileMappingA(file, NULL, PAGE_READONLY|SEC_IMAGE, 0, 0, NULL);
+ mapping = CreateFileMappingA(file, NULL, PAGE_READONLY|SEC_RESERVE, 0, 0, NULL);
ok(mapping != 0, "CreateFileMapping error %u\n", GetLastError());
memset(&info, 0x55, sizeof(info));
@@ -3911,88 +4038,6 @@
ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
ok(ret == sizeof(info.basic), "wrong returned size %u\n", ret);
ok(info.basic.BaseAddress == NULL, "expected NULL, got %p\n",
info.basic.BaseAddress);
-todo_wine
- ok(info.basic.Attributes == (SEC_FILE|SEC_IMAGE), "expected SEC_FILE|SEC_IMAGE,
got %#x\n", info.basic.Attributes);
- ok(info.basic.Size.QuadPart == image_size, "expected %#lx, got %#x/%08x\n",
image_size, info.basic.Size.HighPart, info.basic.Size.LowPart);
-
- status = pNtQuerySection(mapping, SectionImageInformation, NULL, sizeof(info),
&ret);
- ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got
%#x\n", status);
-
- status = pNtQuerySection(mapping, SectionImageInformation, &info, 0, NULL);
- ok(status == STATUS_INFO_LENGTH_MISMATCH, "expected STATUS_INFO_LENGTH_MISMATCH,
got %#x\n", status);
-
- status = pNtQuerySection(mapping, SectionImageInformation, &info, 0, &ret);
- ok(status == STATUS_INFO_LENGTH_MISMATCH, "expected STATUS_INFO_LENGTH_MISMATCH,
got %#x\n", status);
-
- status = pNtQuerySection(mapping, SectionImageInformation, &info,
sizeof(info.basic), &ret);
- ok(status == STATUS_INFO_LENGTH_MISMATCH, "expected STATUS_INFO_LENGTH_MISMATCH,
got %#x\n", status);
-
- SetLastError(0xdeadbef);
- p = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
- ok(p != NULL, "MapViewOfFile error %u\n", GetLastError());
-
- nt = image_nt_header(p);
-
- memset(&info, 0x55, sizeof(info));
- ret = 0xdeadbeef;
- status = pNtQuerySection(mapping, SectionImageInformation, &info, sizeof(info),
&ret);
- ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
- ok(ret == sizeof(info.image), "wrong returned size %u\n", ret);
- ok((ULONG_PTR)info.image.TransferAddress == nt->OptionalHeader.ImageBase +
nt->OptionalHeader.AddressOfEntryPoint,
- "expected %#lx, got %p\n", (SIZE_T)(nt->OptionalHeader.ImageBase +
nt->OptionalHeader.AddressOfEntryPoint), info.image.TransferAddress);
- ok(info.image.ZeroBits == 0, "expected 0, got %#x\n",
info.image.ZeroBits);
-todo_wine
- ok(info.image.MaximumStackSize == nt->OptionalHeader.SizeOfStackReserve,
"expected %#lx, got %#lx\n", (SIZE_T)nt->OptionalHeader.SizeOfStackReserve,
info.image.MaximumStackSize);
-todo_wine
- ok(info.image.CommittedStackSize == nt->OptionalHeader.SizeOfStackCommit,
"expected %#lx, got %#lx\n", (SIZE_T)nt->OptionalHeader.SizeOfStackCommit,
info.image.CommittedStackSize);
- ok(info.image.SubSystemType == nt->OptionalHeader.Subsystem, "expected %#x,
got %#x\n", nt->OptionalHeader.Subsystem, info.image.SubSystemType);
- ok(info.image.SubsystemVersionLow == nt->OptionalHeader.MinorSubsystemVersion,
"expected %#x, got %#x\n", nt->OptionalHeader.MinorSubsystemVersion,
info.image.SubsystemVersionLow);
- ok(info.image.SubsystemVersionHigh == nt->OptionalHeader.MajorSubsystemVersion,
"expected %#x, got %#x\n", nt->OptionalHeader.MajorSubsystemVersion,
info.image.SubsystemVersionHigh);
- ok(info.image.ImageCharacteristics == nt->FileHeader.Characteristics,
"expected %#x, got %#x\n", nt->FileHeader.Characteristics,
info.image.ImageCharacteristics);
- ok(info.image.DllCharacteristics == nt->OptionalHeader.DllCharacteristics,
"expected %#x, got %#x\n", nt->OptionalHeader.DllCharacteristics,
info.image.DllCharacteristics);
- ok(info.image.Machine == nt->FileHeader.Machine, "expected %#x, got
%#x\n", nt->FileHeader.Machine, info.image.Machine);
- ok(info.image.ImageContainsCode == TRUE, "expected 1, got %#x\n",
info.image.ImageContainsCode);
-
- memset(&info, 0x55, sizeof(info));
- ret = 0xdeadbeef;
- status = pNtQuerySection(mapping, SectionBasicInformation, &info, sizeof(info),
&ret);
- ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
- ok(ret == sizeof(info.basic), "wrong returned size %u\n", ret);
- ok(info.basic.BaseAddress == NULL, "expected NULL, got %p\n",
info.basic.BaseAddress);
-todo_wine
- ok(info.basic.Attributes == (SEC_FILE|SEC_IMAGE), "expected SEC_FILE|SEC_IMAGE,
got %#x\n", info.basic.Attributes);
- ok(info.basic.Size.QuadPart == image_size, "expected %#lx, got %#x/%08x\n",
image_size, info.basic.Size.HighPart, info.basic.Size.LowPart);
-
- UnmapViewOfFile(p);
- CloseHandle(mapping);
-
- SetLastError(0xdeadbef);
- mapping = CreateFileMappingA(file, NULL, PAGE_READONLY|SEC_COMMIT|SEC_NOCACHE, 0, 0,
NULL);
- ok(mapping != 0, "CreateFileMapping error %u\n", GetLastError());
-
- memset(&info, 0x55, sizeof(info));
- ret = 0xdeadbeef;
- status = pNtQuerySection(mapping, SectionBasicInformation, &info, sizeof(info),
&ret);
- ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
- ok(ret == sizeof(info.basic), "wrong returned size %u\n", ret);
- ok(info.basic.BaseAddress == NULL, "expected NULL, got %p\n",
info.basic.BaseAddress);
-todo_wine
- ok(info.basic.Attributes == SEC_FILE, "expected SEC_FILE, got %#x\n",
info.basic.Attributes);
- ok(info.basic.Size.QuadPart == fsize, "expected %#lx, got %#x/%08x\n",
fsize, info.basic.Size.HighPart, info.basic.Size.LowPart);
-
- CloseHandle(mapping);
-
- SetLastError(0xdeadbef);
- mapping = CreateFileMappingA(file, NULL, PAGE_READONLY|SEC_RESERVE, 0, 0, NULL);
- ok(mapping != 0, "CreateFileMapping error %u\n", GetLastError());
-
- memset(&info, 0x55, sizeof(info));
- ret = 0xdeadbeef;
- status = pNtQuerySection(mapping, SectionBasicInformation, &info, sizeof(info),
&ret);
- ok(status == STATUS_SUCCESS, "NtQuerySection error %#x\n", status);
- ok(ret == sizeof(info.basic), "wrong returned size %u\n", ret);
- ok(info.basic.BaseAddress == NULL, "expected NULL, got %p\n",
info.basic.BaseAddress);
-todo_wine
ok(info.basic.Attributes == SEC_FILE, "expected SEC_FILE, got %#x\n",
info.basic.Attributes);
ok(info.basic.Size.QuadPart == fsize, "expected %#lx, got %#x/%08x\n",
fsize, info.basic.Size.HighPart, info.basic.Size.LowPart);
@@ -4064,14 +4109,7 @@
}
if (!strcmp(argv[2], "sharedmemro"))
{
- if(!winetest_interactive)
- {
- skip("CORE-8541: Skipping test_shared_memory_ro(TRUE,
strtol(argv[3], NULL, 16))\n");
- }
- else
- {
- test_shared_memory_ro(TRUE, strtol(argv[3], NULL, 16));
- }
+ test_shared_memory_ro(TRUE, strtol(argv[3], NULL, 16));
return;
}
while (1)
@@ -4099,11 +4137,12 @@
pGetProcessDEPPolicy = (void *)GetProcAddress( hkernel32,
"GetProcessDEPPolicy" );
pIsWow64Process = (void *)GetProcAddress( hkernel32, "IsWow64Process" );
pNtAreMappedFilesTheSame = (void *)GetProcAddress( hntdll,
"NtAreMappedFilesTheSame" );
+ pNtCreateSection = (void *)GetProcAddress( hntdll, "NtCreateSection" );
pNtMapViewOfSection = (void *)GetProcAddress( hntdll, "NtMapViewOfSection"
);
pNtUnmapViewOfSection = (void *)GetProcAddress( hntdll,
"NtUnmapViewOfSection" );
+ pNtQuerySection = (void *)GetProcAddress( hntdll, "NtQuerySection" );
pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll,
"RtlAddVectoredExceptionHandler" );
pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll,
"RtlRemoveVectoredExceptionHandler" );
- pNtQuerySection = (void *)GetProcAddress( hntdll, "NtQuerySection" );
pNtProtectVirtualMemory = (void *)GetProcAddress( hntdll,
"NtProtectVirtualMemory" );
pNtAllocateVirtualMemory = (void *)GetProcAddress( hntdll,
"NtAllocateVirtualMemory" );
pNtFreeVirtualMemory = (void *)GetProcAddress( hntdll,
"NtFreeVirtualMemory" );