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
d4d39736
Commit
d4d39736
authored
Apr 17, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Apr 19, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Add more memory access checks.
parent
518e05cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
7 deletions
+89
-7
virtual.c
dlls/kernel32/tests/virtual.c
+89
-7
No files found.
dlls/kernel32/tests/virtual.c
View file @
d4d39736
...
...
@@ -792,8 +792,25 @@ static void test_MapViewOfFile(void)
SetLastError
(
0xdeadbeef
);
map2
=
OpenFileMappingA
(
FILE_MAP_READ
,
FALSE
,
name
);
ok
(
map2
!=
0
,
"OpenFileMappingA failed with error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
map2
);
CloseHandle
(
mapping
);
SetLastError
(
0xdeadbeef
);
ret
=
CloseHandle
(
map2
);
ok
(
ret
,
"CloseHandle error %d
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CloseHandle
(
mapping
);
ok
(
ret
,
"CloseHandle error %d
\n
"
,
GetLastError
());
ret
=
IsBadReadPtr
(
ptr
,
MAPPING_SIZE
);
ok
(
!
ret
,
"memory is not accessible
\n
"
);
ret
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"VirtualQuery error %d
\n
"
,
GetLastError
());
ok
(
info
.
BaseAddress
==
ptr
,
"got %p != expected %p
\n
"
,
info
.
BaseAddress
,
ptr
);
ok
(
info
.
RegionSize
==
MAPPING_SIZE
,
"got %#lx != expected %#x
\n
"
,
info
.
RegionSize
,
MAPPING_SIZE
);
ok
(
info
.
Protect
==
PAGE_READWRITE
,
"got %#x != expected PAGE_READWRITE
\n
"
,
info
.
Protect
);
ok
(
info
.
AllocationBase
==
ptr
,
"%p != %p
\n
"
,
info
.
AllocationBase
,
ptr
);
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
"%#x != PAGE_READWRITE
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_COMMIT
,
"%#x != MEM_COMMIT
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
MEM_MAPPED
,
"%#x != MEM_MAPPED
\n
"
,
info
.
Type
);
SetLastError
(
0xdeadbeef
);
map2
=
OpenFileMappingA
(
FILE_MAP_READ
,
FALSE
,
name
);
...
...
@@ -801,22 +818,46 @@ static void test_MapViewOfFile(void)
ok
(
map2
==
0
,
"OpenFileMappingA succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"OpenFileMappingA set error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
map2
);
if
(
map2
)
CloseHandle
(
map2
);
/* FIXME: remove once Wine is fixed */
SetLastError
(
0xdeadbeef
);
mapping
=
CreateFileMappingA
(
INVALID_HANDLE_VALUE
,
NULL
,
PAGE_READWRITE
,
0
,
MAPPING_SIZE
,
name
);
ok
(
mapping
!=
0
,
"CreateFileMappingA failed
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"CreateFileMappingA set error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
mapping
);
SetLastError
(
0xdeadbeef
);
ret
=
CloseHandle
(
mapping
);
ok
(
ret
,
"CloseHandle error %d
\n
"
,
GetLastError
());
ret
=
IsBadReadPtr
(
ptr
,
MAPPING_SIZE
);
ok
(
!
ret
,
"memory is not accessible
\n
"
);
ret
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"VirtualQuery error %d
\n
"
,
GetLastError
());
ok
(
info
.
BaseAddress
==
ptr
,
"got %p != expected %p
\n
"
,
info
.
BaseAddress
,
ptr
);
ok
(
info
.
RegionSize
==
MAPPING_SIZE
,
"got %#lx != expected %#x
\n
"
,
info
.
RegionSize
,
MAPPING_SIZE
);
ok
(
info
.
Protect
==
PAGE_READWRITE
,
"got %#x != expected PAGE_READWRITE
\n
"
,
info
.
Protect
);
ok
(
info
.
AllocationBase
==
ptr
,
"%p != %p
\n
"
,
info
.
AllocationBase
,
ptr
);
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
"%#x != PAGE_READWRITE
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_COMMIT
,
"%#x != MEM_COMMIT
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
MEM_MAPPED
,
"%#x != MEM_MAPPED
\n
"
,
info
.
Type
);
SetLastError
(
0xdeadbeef
);
ret
=
UnmapViewOfFile
(
ptr
);
ok
(
ret
,
"UnmapViewOfFile failed with error %d
\n
"
,
GetLastError
()
);
ret
=
IsBadReadPtr
(
ptr
,
MAPPING_SIZE
);
ok
(
ret
,
"memory is accessible
\n
"
);
ret
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"VirtualQuery error %d
\n
"
,
GetLastError
());
ok
(
info
.
BaseAddress
==
ptr
,
"got %p != expected %p
\n
"
,
info
.
BaseAddress
,
ptr
);
ok
(
info
.
RegionSize
!=
MAPPING_SIZE
,
"got size %#lx
\n
"
,
info
.
RegionSize
);
ok
(
info
.
Protect
==
PAGE_NOACCESS
,
"got %#x != expected PAGE_NOACCESS
\n
"
,
info
.
Protect
);
ok
(
info
.
AllocationBase
==
NULL
,
"%p != NULL
\n
"
,
info
.
AllocationBase
);
ok
(
info
.
AllocationProtect
==
0
,
"%#x != 0
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_FREE
,
"%#x != MEM_FREE
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
0
,
"%#x != 0
\n
"
,
info
.
Type
);
SetLastError
(
0xdeadbeef
);
file
=
CreateFileA
(
testfile
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
file
!=
INVALID_HANDLE_VALUE
,
"CreateFile error %u
\n
"
,
GetLastError
()
);
...
...
@@ -832,8 +873,25 @@ static void test_MapViewOfFile(void)
SetLastError
(
0xdeadbeef
);
map2
=
OpenFileMappingA
(
FILE_MAP_READ
,
FALSE
,
name
);
ok
(
map2
!=
0
,
"OpenFileMappingA failed with error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
map2
);
CloseHandle
(
mapping
);
SetLastError
(
0xdeadbeef
);
ret
=
CloseHandle
(
map2
);
ok
(
ret
,
"CloseHandle error %d
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CloseHandle
(
mapping
);
ok
(
ret
,
"CloseHandle error %d
\n
"
,
GetLastError
());
ret
=
IsBadReadPtr
(
ptr
,
MAPPING_SIZE
);
ok
(
!
ret
,
"memory is not accessible
\n
"
);
ret
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"VirtualQuery error %d
\n
"
,
GetLastError
());
ok
(
info
.
BaseAddress
==
ptr
,
"got %p != expected %p
\n
"
,
info
.
BaseAddress
,
ptr
);
ok
(
info
.
RegionSize
==
MAPPING_SIZE
,
"got %#lx != expected %#x
\n
"
,
info
.
RegionSize
,
MAPPING_SIZE
);
ok
(
info
.
Protect
==
PAGE_READWRITE
,
"got %#x != expected PAGE_READWRITE
\n
"
,
info
.
Protect
);
ok
(
info
.
AllocationBase
==
ptr
,
"%p != %p
\n
"
,
info
.
AllocationBase
,
ptr
);
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
"%#x != PAGE_READWRITE
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_COMMIT
,
"%#x != MEM_COMMIT
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
MEM_MAPPED
,
"%#x != MEM_MAPPED
\n
"
,
info
.
Type
);
SetLastError
(
0xdeadbeef
);
map2
=
OpenFileMappingA
(
FILE_MAP_READ
,
FALSE
,
name
);
...
...
@@ -847,16 +905,40 @@ static void test_MapViewOfFile(void)
ok
(
mapping
!=
0
,
"CreateFileMappingA failed
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"CreateFileMappingA set error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
mapping
);
SetLastError
(
0xdeadbeef
);
ret
=
CloseHandle
(
mapping
);
ok
(
ret
,
"CloseHandle error %d
\n
"
,
GetLastError
());
ret
=
IsBadReadPtr
(
ptr
,
MAPPING_SIZE
);
ok
(
!
ret
,
"memory is not accessible
\n
"
);
ret
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"VirtualQuery error %d
\n
"
,
GetLastError
());
ok
(
info
.
BaseAddress
==
ptr
,
"got %p != expected %p
\n
"
,
info
.
BaseAddress
,
ptr
);
ok
(
info
.
RegionSize
==
MAPPING_SIZE
,
"got %#lx != expected %#x
\n
"
,
info
.
RegionSize
,
MAPPING_SIZE
);
ok
(
info
.
Protect
==
PAGE_READWRITE
,
"got %#x != expected PAGE_READWRITE
\n
"
,
info
.
Protect
);
ok
(
info
.
AllocationBase
==
ptr
,
"%p != %p
\n
"
,
info
.
AllocationBase
,
ptr
);
ok
(
info
.
AllocationProtect
==
PAGE_READWRITE
,
"%#x != PAGE_READWRITE
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_COMMIT
,
"%#x != MEM_COMMIT
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
MEM_MAPPED
,
"%#x != MEM_MAPPED
\n
"
,
info
.
Type
);
SetLastError
(
0xdeadbeef
);
ret
=
UnmapViewOfFile
(
ptr
);
ok
(
ret
,
"UnmapViewOfFile failed with error %d
\n
"
,
GetLastError
()
);
ret
=
IsBadReadPtr
(
ptr
,
MAPPING_SIZE
);
ok
(
ret
,
"memory is accessible
\n
"
);
ret
=
VirtualQuery
(
ptr
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"VirtualQuery error %d
\n
"
,
GetLastError
());
ok
(
info
.
BaseAddress
==
ptr
,
"got %p != expected %p
\n
"
,
info
.
BaseAddress
,
ptr
);
ok
(
info
.
RegionSize
!=
MAPPING_SIZE
,
"got size %#lx
\n
"
,
info
.
RegionSize
);
ok
(
info
.
Protect
==
PAGE_NOACCESS
,
"got %#x != expected PAGE_NOACCESS
\n
"
,
info
.
Protect
);
ok
(
info
.
AllocationBase
==
NULL
,
"%p != NULL
\n
"
,
info
.
AllocationBase
);
ok
(
info
.
AllocationProtect
==
0
,
"%#x != 0
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_FREE
,
"%#x != MEM_FREE
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
0
,
"%#x != 0
\n
"
,
info
.
Type
);
CloseHandle
(
file
);
DeleteFileA
(
testfile
);
}
...
...
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