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
30f1777e
Commit
30f1777e
authored
May 20, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase/tests: Add some VirtualAlloc2() tests.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
116c718a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
4 deletions
+84
-4
process.c
dlls/kernelbase/tests/process.c
+73
-0
winnt.h
include/winnt.h
+11
-4
No files found.
dlls/kernelbase/tests/process.c
View file @
30f1777e
...
...
@@ -33,6 +33,7 @@
static
BOOL
(
WINAPI
*
pCompareObjectHandles
)(
HANDLE
,
HANDLE
);
static
LPVOID
(
WINAPI
*
pMapViewOfFile3
)(
HANDLE
,
HANDLE
,
PVOID
,
ULONG64
offset
,
SIZE_T
size
,
ULONG
,
ULONG
,
MEM_EXTENDED_PARAMETER
*
,
ULONG
);
static
LPVOID
(
WINAPI
*
pVirtualAlloc2
)(
HANDLE
,
void
*
,
SIZE_T
,
DWORD
,
DWORD
,
MEM_EXTENDED_PARAMETER
*
,
ULONG
);
static
void
test_CompareObjectHandles
(
void
)
{
...
...
@@ -125,6 +126,76 @@ static void test_MapViewOfFile3(void)
ok
(
ret
,
"Failed to delete a test file.
\n
"
);
}
static
void
test_VirtualAlloc2
(
void
)
{
void
*
placeholder1
,
*
placeholder2
,
*
view1
,
*
view2
,
*
addr
;
MEMORY_BASIC_INFORMATION
info
;
HANDLE
section
;
SIZE_T
size
;
BOOL
ret
;
if
(
!
pVirtualAlloc2
)
{
win_skip
(
"VirtualAlloc2() is not supported.
\n
"
);
return
;
}
size
=
0x80000
;
addr
=
pVirtualAlloc2
(
NULL
,
NULL
,
size
,
MEM_COMMIT
,
PAGE_EXECUTE_READWRITE
,
NULL
,
0
);
todo_wine
ok
(
!!
addr
,
"Failed to allocate, error %lu.
\n
"
,
GetLastError
());
ret
=
VirtualFree
(
addr
,
0
,
MEM_RELEASE
);
todo_wine
ok
(
ret
,
"Unexpected return value %d, error %lu.
\n
"
,
ret
,
GetLastError
());
/* Placeholder splitting functionality */
placeholder1
=
pVirtualAlloc2
(
NULL
,
NULL
,
2
*
size
,
MEM_RESERVE_PLACEHOLDER
|
MEM_RESERVE
,
PAGE_NOACCESS
,
NULL
,
0
);
todo_wine
ok
(
!!
placeholder1
,
"Failed to create a placeholder range.
\n
"
);
if
(
!
placeholder1
)
return
;
memset
(
&
info
,
0
,
sizeof
(
info
));
VirtualQuery
(
placeholder1
,
&
info
,
sizeof
(
info
));
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
"Unexpected protection %#lx.
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_RESERVE
,
"Unexpected state %#lx.
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
MEM_PRIVATE
,
"Unexpected type %#lx.
\n
"
,
info
.
Type
);
ok
(
info
.
RegionSize
==
2
*
size
,
"Unexpected size.
\n
"
);
ret
=
VirtualFree
(
placeholder1
,
size
,
MEM_RELEASE
|
MEM_PRESERVE_PLACEHOLDER
);
ok
(
ret
,
"Failed to split placeholder.
\n
"
);
memset
(
&
info
,
0
,
sizeof
(
info
));
VirtualQuery
(
placeholder1
,
&
info
,
sizeof
(
info
));
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
"Unexpected protection %#lx.
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_RESERVE
,
"Unexpected state %#lx.
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
MEM_PRIVATE
,
"Unexpected type %#lx.
\n
"
,
info
.
Type
);
ok
(
info
.
RegionSize
==
size
,
"Unexpected size.
\n
"
);
placeholder2
=
(
void
*
)((
BYTE
*
)
placeholder1
+
size
);
memset
(
&
info
,
0
,
sizeof
(
info
));
VirtualQuery
(
placeholder2
,
&
info
,
sizeof
(
info
));
ok
(
info
.
AllocationProtect
==
PAGE_NOACCESS
,
"Unexpected protection %#lx.
\n
"
,
info
.
AllocationProtect
);
ok
(
info
.
State
==
MEM_RESERVE
,
"Unexpected state %#lx.
\n
"
,
info
.
State
);
ok
(
info
.
Type
==
MEM_PRIVATE
,
"Unexpected type %#lx.
\n
"
,
info
.
Type
);
ok
(
info
.
RegionSize
==
size
,
"Unexpected size.
\n
"
);
section
=
CreateFileMappingW
(
INVALID_HANDLE_VALUE
,
NULL
,
PAGE_READWRITE
,
0
,
size
,
NULL
);
ok
(
!!
section
,
"Failed to create a section.
\n
"
);
view1
=
pMapViewOfFile3
(
section
,
NULL
,
placeholder1
,
0
,
size
,
MEM_REPLACE_PLACEHOLDER
,
PAGE_READWRITE
,
NULL
,
0
);
ok
(
!!
view1
,
"Failed to map a section.
\n
"
);
view2
=
pMapViewOfFile3
(
section
,
NULL
,
placeholder2
,
0
,
size
,
MEM_REPLACE_PLACEHOLDER
,
PAGE_READWRITE
,
NULL
,
0
);
ok
(
!!
view2
,
"Failed to map a section.
\n
"
);
CloseHandle
(
section
);
UnmapViewOfFile
(
view1
);
UnmapViewOfFile
(
view2
);
VirtualFree
(
placeholder1
,
0
,
MEM_RELEASE
);
VirtualFree
(
placeholder2
,
0
,
MEM_RELEASE
);
}
START_TEST
(
process
)
{
HMODULE
hmod
;
...
...
@@ -136,7 +207,9 @@ START_TEST(process)
hmod
=
GetModuleHandleA
(
"kernelbase.dll"
);
pCompareObjectHandles
=
(
void
*
)
GetProcAddress
(
hmod
,
"CompareObjectHandles"
);
pMapViewOfFile3
=
(
void
*
)
GetProcAddress
(
hmod
,
"MapViewOfFile3"
);
pVirtualAlloc2
=
(
void
*
)
GetProcAddress
(
hmod
,
"VirtualAlloc2"
);
test_CompareObjectHandles
();
test_MapViewOfFile3
();
test_VirtualAlloc2
();
}
include/winnt.h
View file @
30f1777e
...
...
@@ -808,16 +808,23 @@ typedef struct _WIN32_MEMORY_RANGE_ENTRY
#define MEM_COMMIT 0x00001000
#define MEM_RESERVE 0x00002000
#define MEM_REPLACE_PLACEHOLDER 0x00004000
#define MEM_RESERVE_PLACEHOLDER 0x00040000
#define MEM_RESET 0x00080000
#define MEM_TOP_DOWN 0x00100000
#define MEM_PHYSICAL 0x00400000
#define MEM_RESET_UNDO 0x10000000
#define MEM_LARGE_PAGES 0x20000000
#define MEM_COALESCE_PLACEHOLDERS 0x00000001
#define MEM_PRESERVE_PLACEHOLDER 0x00000002
#define MEM_DECOMMIT 0x00004000
#define MEM_RELEASE 0x00008000
#define MEM_FREE 0x00010000
#define MEM_PRIVATE 0x00020000
#define MEM_MAPPED 0x00040000
#define MEM_RESET 0x00080000
#define MEM_TOP_DOWN 0x00100000
#define MEM_WRITE_WATCH 0x00200000
#define MEM_PHYSICAL 0x00400000
#define MEM_LARGE_PAGES 0x20000000
#define MEM_4MB_PAGES 0x80000000
#define SEC_FILE 0x00800000
...
...
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