Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
4832adf8
Commit
4832adf8
authored
Jul 25, 2016
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Remove some win9x compatibility cruft.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
fa42e3bb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
124 additions
and
215 deletions
+124
-215
virtual.c
dlls/kernel32/tests/virtual.c
+124
-215
No files found.
dlls/kernel32/tests/virtual.c
View file @
4832adf8
...
@@ -94,20 +94,13 @@ static void test_VirtualAllocEx(void)
...
@@ -94,20 +94,13 @@ static void test_VirtualAllocEx(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
addr1
=
pVirtualAllocEx
(
hProcess
,
NULL
,
alloc_size
,
MEM_COMMIT
,
addr1
=
pVirtualAllocEx
(
hProcess
,
NULL
,
alloc_size
,
MEM_COMMIT
,
PAGE_EXECUTE_READWRITE
);
PAGE_EXECUTE_READWRITE
);
if
(
!
addr1
&&
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
)
ok
(
addr1
!=
NULL
,
"VirtualAllocEx error %u
\n
"
,
GetLastError
());
{
/* Win9x */
win_skip
(
"VirtualAllocEx not implemented
\n
"
);
TerminateProcess
(
hProcess
,
0
);
CloseHandle
(
hProcess
);
return
;
}
src
=
VirtualAlloc
(
NULL
,
alloc_size
,
MEM_COMMIT
,
PAGE_READWRITE
);
src
=
VirtualAlloc
(
NULL
,
alloc_size
,
MEM_COMMIT
,
PAGE_READWRITE
);
dst
=
VirtualAlloc
(
NULL
,
alloc_size
,
MEM_COMMIT
,
PAGE_READWRITE
);
dst
=
VirtualAlloc
(
NULL
,
alloc_size
,
MEM_COMMIT
,
PAGE_READWRITE
);
for
(
i
=
0
;
i
<
alloc_size
;
i
++
)
for
(
i
=
0
;
i
<
alloc_size
;
i
++
)
src
[
i
]
=
i
&
0xff
;
src
[
i
]
=
i
&
0xff
;
ok
(
addr1
!=
NULL
,
"VirtualAllocEx error %u
\n
"
,
GetLastError
());
b
=
WriteProcessMemory
(
hProcess
,
addr1
,
src
,
alloc_size
,
&
bytes_written
);
b
=
WriteProcessMemory
(
hProcess
,
addr1
,
src
,
alloc_size
,
&
bytes_written
);
ok
(
b
&&
(
bytes_written
==
alloc_size
),
"%lu bytes written
\n
"
,
ok
(
b
&&
(
bytes_written
==
alloc_size
),
"%lu bytes written
\n
"
,
bytes_written
);
bytes_written
);
...
@@ -156,9 +149,8 @@ static void test_VirtualAllocEx(void)
...
@@ -156,9 +149,8 @@ static void test_VirtualAllocEx(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
addr1
=
pVirtualAllocEx
(
hProcess
,
0
,
0
,
MEM_RESERVE
,
PAGE_NOACCESS
);
addr1
=
pVirtualAllocEx
(
hProcess
,
0
,
0
,
MEM_RESERVE
,
PAGE_NOACCESS
);
ok
(
addr1
==
NULL
,
"VirtualAllocEx should fail on zero-sized allocation
\n
"
);
ok
(
addr1
==
NULL
,
"VirtualAllocEx should fail on zero-sized allocation
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
/* NT */
||
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
/* Win9x */
"got %u, expected ERROR_INVALID_PARAMETER
\n
"
,
GetLastError
());
"got %u, expected ERROR_INVALID_PARAMETER
\n
"
,
GetLastError
());
addr1
=
pVirtualAllocEx
(
hProcess
,
0
,
0xFFFC
,
MEM_RESERVE
,
PAGE_NOACCESS
);
addr1
=
pVirtualAllocEx
(
hProcess
,
0
,
0xFFFC
,
MEM_RESERVE
,
PAGE_NOACCESS
);
ok
(
addr1
!=
NULL
,
"VirtualAllocEx failed
\n
"
);
ok
(
addr1
!=
NULL
,
"VirtualAllocEx failed
\n
"
);
...
@@ -171,17 +163,13 @@ static void test_VirtualAllocEx(void)
...
@@ -171,17 +163,13 @@ static void test_VirtualAllocEx(void)
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
"%x != PAGE_NOACCESS
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
"%x != PAGE_NOACCESS
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
RegionSize
==
0x10000
,
"%lx != 0x10000
\n
"
,
info
.
RegionSize
);
ok
(
info
.
RegionSize
==
0x10000
,
"%lx != 0x10000
\n
"
,
info
.
RegionSize
);
ok
(
info
.
State
==
MEM_RESERVE
,
"%x != MEM_RESERVE
\n
"
,
info
.
State
);
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
,
"%x != PAGE_NOACCESS
\n
"
,
info
.
Protect
);
ok
(
info
.
Protect
==
0
/* NT */
||
info
.
Protect
==
PAGE_NOACCESS
,
/* Win9x */
"%x != PAGE_NOACCESS
\n
"
,
info
.
Protect
);
ok
(
info
.
Type
==
MEM_PRIVATE
,
"%x != MEM_PRIVATE
\n
"
,
info
.
Type
);
ok
(
info
.
Type
==
MEM_PRIVATE
,
"%x != MEM_PRIVATE
\n
"
,
info
.
Type
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ok
(
!
VirtualProtectEx
(
hProcess
,
addr1
,
0xFFFC
,
PAGE_READONLY
,
&
old_prot
),
ok
(
!
VirtualProtectEx
(
hProcess
,
addr1
,
0xFFFC
,
PAGE_READONLY
,
&
old_prot
),
"VirtualProtectEx should fail on a not committed memory
\n
"
);
"VirtualProtectEx should fail on a not committed memory
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
/* NT */
||
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
,
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
/* Win9x */
"got %u, expected ERROR_INVALID_ADDRESS
\n
"
,
GetLastError
());
"got %u, expected ERROR_INVALID_ADDRESS
\n
"
,
GetLastError
());
addr2
=
pVirtualAllocEx
(
hProcess
,
addr1
,
0x1000
,
MEM_COMMIT
,
PAGE_NOACCESS
);
addr2
=
pVirtualAllocEx
(
hProcess
,
addr1
,
0x1000
,
MEM_COMMIT
,
PAGE_NOACCESS
);
...
@@ -203,9 +191,8 @@ static void test_VirtualAllocEx(void)
...
@@ -203,9 +191,8 @@ static void test_VirtualAllocEx(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ok
(
!
VirtualProtectEx
(
hProcess
,
addr1
,
0xFFFC
,
PAGE_READONLY
,
&
old_prot
),
ok
(
!
VirtualProtectEx
(
hProcess
,
addr1
,
0xFFFC
,
PAGE_READONLY
,
&
old_prot
),
"VirtualProtectEx should fail on a not committed memory
\n
"
);
"VirtualProtectEx should fail on a not committed memory
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
/* NT */
||
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
,
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
/* Win9x */
"got %u, expected ERROR_INVALID_ADDRESS
\n
"
,
GetLastError
());
"got %u, expected ERROR_INVALID_ADDRESS
\n
"
,
GetLastError
());
old_prot
=
0
;
old_prot
=
0
;
ok
(
VirtualProtectEx
(
hProcess
,
addr1
,
0x1000
,
PAGE_READONLY
,
&
old_prot
),
"VirtualProtectEx failed
\n
"
);
ok
(
VirtualProtectEx
(
hProcess
,
addr1
,
0x1000
,
PAGE_READONLY
,
&
old_prot
),
"VirtualProtectEx failed
\n
"
);
...
@@ -245,8 +232,7 @@ static void test_VirtualAlloc(void)
...
@@ -245,8 +232,7 @@ static void test_VirtualAlloc(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
addr1
=
VirtualAlloc
(
0
,
0
,
MEM_RESERVE
,
PAGE_NOACCESS
);
addr1
=
VirtualAlloc
(
0
,
0
,
MEM_RESERVE
,
PAGE_NOACCESS
);
ok
(
addr1
==
NULL
,
"VirtualAlloc should fail on zero-sized allocation
\n
"
);
ok
(
addr1
==
NULL
,
"VirtualAlloc should fail on zero-sized allocation
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
/* NT */
||
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
GetLastError
()
==
ERROR_NOT_ENOUGH_MEMORY
,
/* Win9x */
"got %d, expected ERROR_INVALID_PARAMETER
\n
"
,
GetLastError
());
"got %d, expected ERROR_INVALID_PARAMETER
\n
"
,
GetLastError
());
addr1
=
VirtualAlloc
(
0
,
0xFFFC
,
MEM_RESERVE
,
PAGE_NOACCESS
);
addr1
=
VirtualAlloc
(
0
,
0xFFFC
,
MEM_RESERVE
,
PAGE_NOACCESS
);
...
@@ -260,17 +246,13 @@ static void test_VirtualAlloc(void)
...
@@ -260,17 +246,13 @@ static void test_VirtualAlloc(void)
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
"%x != PAGE_NOACCESS
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
"%x != PAGE_NOACCESS
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
RegionSize
==
0x10000
,
"%lx != 0x10000
\n
"
,
info
.
RegionSize
);
ok
(
info
.
RegionSize
==
0x10000
,
"%lx != 0x10000
\n
"
,
info
.
RegionSize
);
ok
(
info
.
State
==
MEM_RESERVE
,
"%x != MEM_RESERVE
\n
"
,
info
.
State
);
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
,
"%x != PAGE_NOACCESS
\n
"
,
info
.
Protect
);
ok
(
info
.
Protect
==
0
/* NT */
||
info
.
Protect
==
PAGE_NOACCESS
,
/* Win9x */
"%x != PAGE_NOACCESS
\n
"
,
info
.
Protect
);
ok
(
info
.
Type
==
MEM_PRIVATE
,
"%x != MEM_PRIVATE
\n
"
,
info
.
Type
);
ok
(
info
.
Type
==
MEM_PRIVATE
,
"%x != MEM_PRIVATE
\n
"
,
info
.
Type
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ok
(
!
VirtualProtect
(
addr1
,
0xFFFC
,
PAGE_READONLY
,
&
old_prot
),
ok
(
!
VirtualProtect
(
addr1
,
0xFFFC
,
PAGE_READONLY
,
&
old_prot
),
"VirtualProtect should fail on a not committed memory
\n
"
);
"VirtualProtect should fail on a not committed memory
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
/* NT */
||
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
,
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
/* Win9x */
"got %d, expected ERROR_INVALID_ADDRESS
\n
"
,
GetLastError
());
"got %d, expected ERROR_INVALID_ADDRESS
\n
"
,
GetLastError
());
addr2
=
VirtualAlloc
(
addr1
,
0x1000
,
MEM_COMMIT
,
PAGE_NOACCESS
);
addr2
=
VirtualAlloc
(
addr1
,
0x1000
,
MEM_COMMIT
,
PAGE_NOACCESS
);
...
@@ -292,8 +274,7 @@ static void test_VirtualAlloc(void)
...
@@ -292,8 +274,7 @@ static void test_VirtualAlloc(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ok
(
!
VirtualProtect
(
addr1
,
0xFFFC
,
PAGE_READONLY
,
&
old_prot
),
ok
(
!
VirtualProtect
(
addr1
,
0xFFFC
,
PAGE_READONLY
,
&
old_prot
),
"VirtualProtect should fail on a not committed memory
\n
"
);
"VirtualProtect should fail on a not committed memory
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
/* NT */
||
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
,
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
/* Win9x */
"got %d, expected ERROR_INVALID_ADDRESS
\n
"
,
GetLastError
());
"got %d, expected ERROR_INVALID_ADDRESS
\n
"
,
GetLastError
());
ok
(
VirtualProtect
(
addr1
,
0x1000
,
PAGE_READONLY
,
&
old_prot
),
"VirtualProtect failed
\n
"
);
ok
(
VirtualProtect
(
addr1
,
0x1000
,
PAGE_READONLY
,
&
old_prot
),
"VirtualProtect failed
\n
"
);
...
@@ -313,30 +294,26 @@ static void test_VirtualAlloc(void)
...
@@ -313,30 +294,26 @@ static void test_VirtualAlloc(void)
ok
(
*
(
DWORD
*
)
addr1
==
0x55555555
,
"wrong data %x
\n
"
,
*
(
DWORD
*
)
addr1
);
ok
(
*
(
DWORD
*
)
addr1
==
0x55555555
,
"wrong data %x
\n
"
,
*
(
DWORD
*
)
addr1
);
addr2
=
VirtualAlloc
(
addr1
,
0x1000
,
MEM_RESET
,
PAGE_NOACCESS
);
addr2
=
VirtualAlloc
(
addr1
,
0x1000
,
MEM_RESET
,
PAGE_NOACCESS
);
ok
(
addr2
==
addr1
||
broken
(
!
addr2
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
),
/* win9x */
ok
(
addr2
==
addr1
,
"VirtualAlloc failed err %u
\n
"
,
GetLastError
()
);
"VirtualAlloc failed err %u
\n
"
,
GetLastError
()
);
ok
(
*
(
DWORD
*
)
addr1
==
0x55555555
||
*
(
DWORD
*
)
addr1
==
0
,
"wrong data %x
\n
"
,
*
(
DWORD
*
)
addr1
);
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
(
VirtualQuery
(
addr1
,
&
info
,
sizeof
(
info
))
==
sizeof
(
info
),
ok
(
info
.
RegionSize
==
0x1000
,
"%lx != 0x1000
\n
"
,
info
.
RegionSize
);
"VirtualQuery failed
\n
"
);
ok
(
info
.
State
==
MEM_COMMIT
,
"%x != MEM_COMMIT
\n
"
,
info
.
State
);
ok
(
info
.
RegionSize
==
0x1000
,
"%lx != 0x1000
\n
"
,
info
.
RegionSize
);
ok
(
info
.
Protect
==
PAGE_READWRITE
,
"%x != PAGE_READWRITE
\n
"
,
info
.
Protect
);
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
"
);
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
(
VirtualQuery
(
addr2
,
&
info
,
sizeof
(
info
))
==
sizeof
(
info
),
ok
(
info
.
RegionSize
==
0xf000
,
"%lx != 0xf000
\n
"
,
info
.
RegionSize
);
"VirtualQuery failed
\n
"
);
ok
(
info
.
State
==
MEM_RESERVE
,
"%x != MEM_RESERVE
\n
"
,
info
.
State
);
ok
(
info
.
RegionSize
==
0xf000
,
"%lx != 0xf000
\n
"
,
info
.
RegionSize
);
ok
(
info
.
Protect
==
0
,
"%x != 0
\n
"
,
info
.
Protect
);
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
"
);
addr2
=
VirtualAlloc
(
(
char
*
)
addr1
+
0xf000
,
0x2000
,
MEM_RESET
,
PAGE_NOACCESS
);
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
,
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
!
addr2
,
"VirtualAlloc failed
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_ADDRESS
,
"wrong error %u
\n
"
,
GetLastError
()
);
}
/* invalid protection values */
/* invalid protection values */
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
...
@@ -431,6 +408,7 @@ static void test_MapViewOfFile(void)
...
@@ -431,6 +408,7 @@ static void test_MapViewOfFile(void)
void
*
ptr
,
*
ptr2
,
*
addr
;
void
*
ptr
,
*
ptr2
,
*
addr
;
MEMORY_BASIC_INFORMATION
info
;
MEMORY_BASIC_INFORMATION
info
;
BOOL
ret
;
BOOL
ret
;
SIZE_T
size
;
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
file
=
CreateFileA
(
testfile
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
file
=
CreateFileA
(
testfile
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
...
@@ -446,14 +424,13 @@ static void test_MapViewOfFile(void)
...
@@ -446,14 +424,13 @@ static void test_MapViewOfFile(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
4096
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
4096
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP
E
_READ error %u
\n
"
,
GetLastError
()
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_READ error %u
\n
"
,
GetLastError
()
);
UnmapViewOfFile
(
ptr
);
UnmapViewOfFile
(
ptr
);
/* this fails on win9x but succeeds on NT */
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_COPY
,
0
,
0
,
4096
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_COPY
,
0
,
0
,
4096
);
if
(
ptr
)
UnmapViewOfFile
(
ptr
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_COPY error %u
\n
"
,
GetLastError
()
);
else
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Wrong error %d
\n
"
,
GetLastError
()
);
UnmapViewOfFile
(
ptr
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
mapping
,
0
,
0
,
0
,
4096
);
ptr
=
MapViewOfFile
(
mapping
,
0
,
0
,
0
,
4096
);
...
@@ -478,24 +455,21 @@ static void test_MapViewOfFile(void)
...
@@ -478,24 +455,21 @@ static void test_MapViewOfFile(void)
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
map2
,
FILE_MAP_WRITE
,
0
,
0
,
4096
);
ptr
=
MapViewOfFile
(
map2
,
FILE_MAP_WRITE
,
0
,
0
,
4096
);
if
(
!
ptr
)
ok
(
!
ptr
,
"MapViewOfFile succeeded
\n
"
);
{
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
map2
);
CloseHandle
(
map2
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
mapping
,
GetCurrentProcess
(),
&
map2
,
0
,
FALSE
,
0
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
mapping
,
GetCurrentProcess
(),
&
map2
,
0
,
FALSE
,
0
);
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
map2
,
0
,
0
,
0
,
4096
);
ptr
=
MapViewOfFile
(
map2
,
0
,
0
,
0
,
4096
);
ok
(
!
ptr
,
"MapViewOfFile succeeded
\n
"
);
ok
(
!
ptr
,
"MapViewOfFile succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
map2
);
CloseHandle
(
map2
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
mapping
,
GetCurrentProcess
(),
&
map2
,
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
mapping
,
GetCurrentProcess
(),
&
map2
,
FILE_MAP_READ
,
FALSE
,
0
);
FILE_MAP_READ
,
FALSE
,
0
);
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
ptr
=
MapViewOfFile
(
map2
,
0
,
0
,
0
,
4096
);
ptr
=
MapViewOfFile
(
map2
,
0
,
0
,
0
,
4096
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile NO_ACCESS error %u
\n
"
,
GetLastError
()
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile NO_ACCESS error %u
\n
"
,
GetLastError
()
);
}
else
win_skip
(
"no access checks on win9x
\n
"
);
UnmapViewOfFile
(
ptr
);
UnmapViewOfFile
(
ptr
);
CloseHandle
(
map2
);
CloseHandle
(
map2
);
...
@@ -512,11 +486,10 @@ static void test_MapViewOfFile(void)
...
@@ -512,11 +486,10 @@ static void test_MapViewOfFile(void)
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_READ error %u
\n
"
,
GetLastError
()
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_READ error %u
\n
"
,
GetLastError
()
);
UnmapViewOfFile
(
ptr
);
UnmapViewOfFile
(
ptr
);
/* this fails on win9x but succeeds on NT */
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_COPY
,
0
,
0
,
4096
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_COPY
,
0
,
0
,
4096
);
if
(
ptr
)
UnmapViewOfFile
(
ptr
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_COPY error %u
\n
"
,
GetLastError
()
);
else
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Wrong error %d
\n
"
,
GetLastError
()
);
UnmapViewOfFile
(
ptr
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
mapping
,
0
,
0
,
0
,
4096
);
ptr
=
MapViewOfFile
(
mapping
,
0
,
0
,
0
,
4096
);
...
@@ -562,33 +535,8 @@ static void test_MapViewOfFile(void)
...
@@ -562,33 +535,8 @@ static void test_MapViewOfFile(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
mapping
=
CreateFileMappingA
(
file
,
NULL
,
PAGE_NOACCESS
,
0
,
4096
,
NULL
);
mapping
=
CreateFileMappingA
(
file
,
NULL
,
PAGE_NOACCESS
,
0
,
4096
,
NULL
);
/* fails on NT but succeeds on win9x */
ok
(
!
mapping
,
"CreateFileMappingA succeeded
\n
"
);
if
(
!
mapping
)
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Wrong error %d
\n
"
,
GetLastError
()
);
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
);
}
CloseHandle
(
file
);
CloseHandle
(
file
);
/* now try read-only file */
/* now try read-only file */
...
@@ -657,25 +605,21 @@ static void test_MapViewOfFile(void)
...
@@ -657,25 +605,21 @@ static void test_MapViewOfFile(void)
ok
(
mapping
!=
0
,
"OpenFileMapping FILE_MAP_READ error %u
\n
"
,
GetLastError
()
);
ok
(
mapping
!=
0
,
"OpenFileMapping FILE_MAP_READ error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_WRITE
,
0
,
0
,
0
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_WRITE
,
0
,
0
,
0
);
if
(
!
ptr
)
ok
(
!
ptr
,
"MapViewOfFile FILE_MAP_WRITE succeeded
\n
"
);
{
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
SIZE_T
size
;
SetLastError
(
0xdeadbeef
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
SetLastError
(
0xdeadbeef
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_READ error %u
\n
"
,
GetLastError
()
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
SetLastError
(
0xdeadbeef
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_READ error %u
\n
"
,
GetLastError
()
);
size
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
)
);
SetLastError
(
0xdeadbeef
);
ok
(
size
==
sizeof
(
info
),
size
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
)
);
"VirtualQuery error %u
\n
"
,
GetLastError
()
);
ok
(
size
==
sizeof
(
info
),
ok
(
info
.
BaseAddress
==
ptr
,
"%p != %p
\n
"
,
info
.
BaseAddress
,
ptr
);
"VirtualQuery error %u
\n
"
,
GetLastError
()
);
ok
(
info
.
AllocationBase
==
ptr
,
"%p != %p
\n
"
,
info
.
AllocationBase
,
ptr
);
ok
(
info
.
BaseAddress
==
ptr
,
"%p != %p
\n
"
,
info
.
BaseAddress
,
ptr
);
ok
(
info
.
AllocationProtect
==
PAGE_READONLY
,
"%x != PAGE_READONLY
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
AllocationBase
==
ptr
,
"%p != %p
\n
"
,
info
.
AllocationBase
,
ptr
);
ok
(
info
.
RegionSize
==
4096
,
"%lx != 4096
\n
"
,
info
.
RegionSize
);
ok
(
info
.
AllocationProtect
==
PAGE_READONLY
,
"%x != PAGE_READONLY
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_COMMIT
,
"%x != MEM_COMMIT
\n
"
,
info
.
State
);
ok
(
info
.
RegionSize
==
4096
,
"%lx != 4096
\n
"
,
info
.
RegionSize
);
ok
(
info
.
Protect
==
PAGE_READONLY
,
"%x != PAGE_READONLY
\n
"
,
info
.
Protect
);
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
"
);
UnmapViewOfFile
(
ptr
);
UnmapViewOfFile
(
ptr
);
CloseHandle
(
mapping
);
CloseHandle
(
mapping
);
...
@@ -684,25 +628,21 @@ static void test_MapViewOfFile(void)
...
@@ -684,25 +628,21 @@ static void test_MapViewOfFile(void)
ok
(
mapping
!=
0
,
"OpenFileMapping FILE_MAP_WRITE error %u
\n
"
,
GetLastError
()
);
ok
(
mapping
!=
0
,
"OpenFileMapping FILE_MAP_WRITE error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
if
(
!
ptr
)
ok
(
!
ptr
,
"MapViewOfFile succeeded
\n
"
);
{
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
SIZE_T
size
;
SetLastError
(
0xdeadbeef
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_WRITE
,
0
,
0
,
0
);
SetLastError
(
0xdeadbeef
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_WRITE error %u
\n
"
,
GetLastError
()
);
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_WRITE
,
0
,
0
,
0
);
SetLastError
(
0xdeadbeef
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_WRITE error %u
\n
"
,
GetLastError
()
);
size
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
)
);
SetLastError
(
0xdeadbeef
);
ok
(
size
==
sizeof
(
info
),
size
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
)
);
"VirtualQuery error %u
\n
"
,
GetLastError
()
);
ok
(
size
==
sizeof
(
info
),
ok
(
info
.
BaseAddress
==
ptr
,
"%p != %p
\n
"
,
info
.
BaseAddress
,
ptr
);
"VirtualQuery error %u
\n
"
,
GetLastError
()
);
ok
(
info
.
AllocationBase
==
ptr
,
"%p != %p
\n
"
,
info
.
AllocationBase
,
ptr
);
ok
(
info
.
BaseAddress
==
ptr
,
"%p != %p
\n
"
,
info
.
BaseAddress
,
ptr
);
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
"%x != PAGE_READWRITE
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
AllocationBase
==
ptr
,
"%p != %p
\n
"
,
info
.
AllocationBase
,
ptr
);
ok
(
info
.
RegionSize
==
4096
,
"%lx != 4096
\n
"
,
info
.
RegionSize
);
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
"%x != PAGE_READWRITE
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_COMMIT
,
"%x != MEM_COMMIT
\n
"
,
info
.
State
);
ok
(
info
.
RegionSize
==
4096
,
"%lx != 4096
\n
"
,
info
.
RegionSize
);
ok
(
info
.
Protect
==
PAGE_READWRITE
,
"%x != PAGE_READWRITE
\n
"
,
info
.
Protect
);
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
"
);
UnmapViewOfFile
(
ptr
);
UnmapViewOfFile
(
ptr
);
CloseHandle
(
mapping
);
CloseHandle
(
mapping
);
...
@@ -716,9 +656,8 @@ static void test_MapViewOfFile(void)
...
@@ -716,9 +656,8 @@ static void test_MapViewOfFile(void)
ok
(
ptr
!=
NULL
,
"MapViewOfFile failed with error %d
\n
"
,
GetLastError
());
ok
(
ptr
!=
NULL
,
"MapViewOfFile failed with error %d
\n
"
,
GetLastError
());
ptr2
=
MapViewOfFile
(
mapping
,
FILE_MAP_WRITE
,
0
,
0
,
0
);
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
());
ok
(
ptr2
!=
NULL
,
"MapViewOfFile failed with error %d
\n
"
,
GetLastError
());
ok
(
ptr
!=
ptr2
,
"MapViewOfFile returned same pointer
\n
"
);
trace
(
"mapping same section resulted in views %p and %p
\n
"
,
ptr
,
ptr2
);
ret
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
));
ret
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"VirtualQuery failed with error %d
\n
"
,
GetLastError
());
ok
(
ret
,
"VirtualQuery failed with error %d
\n
"
,
GetLastError
());
...
@@ -726,40 +665,24 @@ static void test_MapViewOfFile(void)
...
@@ -726,40 +665,24 @@ static void test_MapViewOfFile(void)
ok
(
info
.
AllocationBase
==
ptr
,
"AllocationBase should have been %p but was %p instead
\n
"
,
ptr
,
info
.
AllocationBase
);
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
.
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
.
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_READWRITE
,
{
"AllocationProtect should have been PAGE_READWRITE but was 0x%x
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
ok
(
info
.
Protect
==
0
,
"Protect should have been 0 instead of 0x%x
\n
"
,
info
.
Protect
);
"AllocationProtect should have been PAGE_NOACCESS 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
.
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
());
ret
=
VirtualQuery
(
ptr2
,
&
info
,
sizeof
(
info
));
ok
(
info
.
BaseAddress
==
ptr2
,
ok
(
ret
,
"VirtualQuery failed with error %d
\n
"
,
GetLastError
());
"BaseAddress should have been %p but was %p instead
\n
"
,
ptr2
,
info
.
BaseAddress
);
ok
(
info
.
BaseAddress
==
ptr2
,
ok
(
info
.
AllocationBase
==
ptr2
,
"BaseAddress should have been %p but was %p instead
\n
"
,
ptr2
,
info
.
BaseAddress
);
"AllocationBase should have been %p but was %p instead
\n
"
,
ptr2
,
info
.
AllocationBase
);
ok
(
info
.
AllocationBase
==
ptr2
,
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
"AllocationBase should have been %p but was %p instead
\n
"
,
ptr2
,
info
.
AllocationBase
);
"AllocationProtect should have been PAGE_READWRITE but was 0x%x
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
ok
(
info
.
RegionSize
==
MAPPING_SIZE
,
"AllocationProtect should have been PAGE_READWRITE but was 0x%x
\n
"
,
info
.
AllocationProtect
);
"RegionSize should have been 0x%x but was 0x%lx
\n
"
,
MAPPING_SIZE
,
info
.
RegionSize
);
ok
(
info
.
RegionSize
==
MAPPING_SIZE
,
ok
(
info
.
State
==
MEM_RESERVE
,
"State should have been MEM_RESERVE instead of 0x%x
\n
"
,
info
.
State
);
"RegionSize should have been 0x%x but was 0x%lx
\n
"
,
MAPPING_SIZE
,
info
.
RegionSize
);
ok
(
info
.
Protect
==
0
,
"Protect should have been 0 instead of 0x%x
\n
"
,
info
.
Protect
);
ok
(
info
.
State
==
MEM_RESERVE
,
ok
(
info
.
Type
==
MEM_MAPPED
,
"Type should have been MEM_MAPPED instead of 0x%x
\n
"
,
info
.
Type
);
"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
);
ptr
=
VirtualAlloc
(
ptr
,
0x10000
,
MEM_COMMIT
,
PAGE_READONLY
);
ok
(
ptr
!=
NULL
,
"VirtualAlloc failed with error %d
\n
"
,
GetLastError
());
ok
(
ptr
!=
NULL
,
"VirtualAlloc failed with error %d
\n
"
,
GetLastError
());
...
@@ -771,48 +694,35 @@ static void test_MapViewOfFile(void)
...
@@ -771,48 +694,35 @@ static void test_MapViewOfFile(void)
ok
(
info
.
RegionSize
==
0x10000
,
"RegionSize should have been 0x10000 but was 0x%lx
\n
"
,
info
.
RegionSize
);
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
.
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
);
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_READWRITE
,
{
"AllocationProtect should have been PAGE_READWRITE but was 0x%x
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
ok
(
info
.
Type
==
MEM_MAPPED
,
"Type should have been MEM_MAPPED instead of 0x%x
\n
"
,
info
.
Type
);
"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
);
}
/* shows that the VirtualAlloc above affects the mapping, not just the
/* shows that the VirtualAlloc above affects the mapping, not just the
* virtual memory in this process - it also affects all other processes
* virtual memory in this process - it also affects all other processes
* with a view of the mapping, but that isn't tested here */
* 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
());
ret
=
VirtualQuery
(
ptr2
,
&
info
,
sizeof
(
info
));
ok
(
info
.
BaseAddress
==
ptr2
,
ok
(
ret
,
"VirtualQuery failed with error %d
\n
"
,
GetLastError
());
"BaseAddress should have been %p but was %p instead
\n
"
,
ptr2
,
info
.
BaseAddress
);
ok
(
info
.
BaseAddress
==
ptr2
,
ok
(
info
.
AllocationBase
==
ptr2
,
"BaseAddress should have been %p but was %p instead
\n
"
,
ptr2
,
info
.
BaseAddress
);
"AllocationBase should have been %p but was %p instead
\n
"
,
ptr2
,
info
.
AllocationBase
);
ok
(
info
.
AllocationBase
==
ptr2
,
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
"AllocationBase should have been %p but was %p instead
\n
"
,
ptr2
,
info
.
AllocationBase
);
"AllocationProtect should have been PAGE_READWRITE but was 0x%x
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
ok
(
info
.
RegionSize
==
0x10000
,
"AllocationProtect should have been PAGE_READWRITE but was 0x%x
\n
"
,
info
.
AllocationProtect
);
"RegionSize should have been 0x10000 but was 0x%lx
\n
"
,
info
.
RegionSize
);
ok
(
info
.
RegionSize
==
0x10000
,
ok
(
info
.
State
==
MEM_COMMIT
,
"RegionSize should have been 0x10000 but was 0x%lx
\n
"
,
info
.
RegionSize
);
"State should have been MEM_COMMIT instead of 0x%x
\n
"
,
info
.
State
);
ok
(
info
.
State
==
MEM_COMMIT
,
ok
(
info
.
Protect
==
PAGE_READWRITE
,
"State should have been MEM_COMMIT instead of 0x%x
\n
"
,
info
.
State
);
"Protect should have been PAGE_READWRITE instead of 0x%x
\n
"
,
info
.
Protect
);
ok
(
info
.
Protect
==
PAGE_READWRITE
,
ok
(
info
.
Type
==
MEM_MAPPED
,
"Type should have been MEM_MAPPED instead of 0x%x
\n
"
,
info
.
Type
);
"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
);
addr
=
VirtualAlloc
(
ptr
,
MAPPING_SIZE
,
MEM_RESET
,
PAGE_READONLY
);
ok
(
addr
==
ptr
||
broken
(
!
addr
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
),
/* win9x */
ok
(
addr
==
ptr
,
"VirtualAlloc failed with error %u
\n
"
,
GetLastError
()
);
"VirtualAlloc failed with error %u
\n
"
,
GetLastError
()
);
ret
=
VirtualFree
(
ptr
,
0x10000
,
MEM_DECOMMIT
);
ret
=
VirtualFree
(
ptr
,
0x10000
,
MEM_DECOMMIT
);
ok
(
!
ret
||
broken
(
ret
)
/* win9x */
,
"VirtualFree succeeded
\n
"
);
ok
(
!
ret
,
"VirtualFree succeeded
\n
"
);
if
(
!
ret
)
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"VirtualFree failed with %u
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"VirtualFree failed with %u
\n
"
,
GetLastError
()
);
ret
=
UnmapViewOfFile
(
ptr2
);
ret
=
UnmapViewOfFile
(
ptr2
);
ok
(
ret
,
"UnmapViewOfFile failed with error %d
\n
"
,
GetLastError
());
ok
(
ret
,
"UnmapViewOfFile failed with error %d
\n
"
,
GetLastError
());
...
@@ -1392,8 +1302,7 @@ static void test_CreateFileMapping(void)
...
@@ -1392,8 +1302,7 @@ static void test_CreateFileMapping(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
handle2
=
OpenFileMappingA
(
FILE_MAP_ALL_ACCESS
,
FALSE
,
"WINE TEST MAPPING"
);
handle2
=
OpenFileMappingA
(
FILE_MAP_ALL_ACCESS
,
FALSE
,
"WINE TEST MAPPING"
);
ok
(
!
handle2
,
"OpenFileMapping succeeded
\n
"
);
ok
(
!
handle2
,
"OpenFileMapping succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
||
GetLastError
()
==
ERROR_INVALID_NAME
/* win9x */
,
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"wrong error %u
\n
"
,
GetLastError
());
"wrong error %u
\n
"
,
GetLastError
());
CloseHandle
(
handle
);
CloseHandle
(
handle
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment