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
61ca1128
Commit
61ca1128
authored
Apr 14, 2021
by
Paul Gofman
Committed by
Alexandre Julliard
Apr 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Implement VirtualAllocFromApp().
Signed-off-by:
Paul Gofman
<
pgofman@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
fd25cc3c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
3 deletions
+63
-3
api-ms-win-core-memory-l1-1-3.spec
...win-core-memory-l1-1-3/api-ms-win-core-memory-l1-1-3.spec
+1
-1
virtual.c
dlls/kernel32/tests/virtual.c
+38
-1
kernelbase.spec
dlls/kernelbase/kernelbase.spec
+1
-1
memory.c
dlls/kernelbase/memory.c
+22
-0
winbase.h
include/winbase.h
+1
-0
No files found.
dlls/api-ms-win-core-memory-l1-1-3/api-ms-win-core-memory-l1-1-3.spec
View file @
61ca1128
...
...
@@ -19,7 +19,7 @@
@ stdcall UnmapViewOfFile(ptr) kernel32.UnmapViewOfFile
@ stub UnmapViewOfFileEx
@ stdcall VirtualAlloc(ptr long long long) kernel32.VirtualAlloc
@ st
ub
VirtualAllocFromApp
@ st
dcall VirtualAllocFromApp(ptr long long long) kernelbase.
VirtualAllocFromApp
@ stdcall VirtualFree(ptr long long) kernel32.VirtualFree
@ stdcall VirtualFreeEx(long ptr long long) kernel32.VirtualFreeEx
@ stdcall VirtualLock(ptr long) kernel32.VirtualLock
...
...
dlls/kernel32/tests/virtual.c
View file @
61ca1128
...
...
@@ -35,7 +35,7 @@
#define NUM_THREADS 4
#define MAPPING_SIZE 0x100000
static
HINSTANCE
hkernel32
,
hntdll
;
static
HINSTANCE
hkernel32
,
h
kernelbase
,
h
ntdll
;
static
SYSTEM_INFO
si
;
static
UINT
(
WINAPI
*
pGetWriteWatch
)(
DWORD
,
LPVOID
,
SIZE_T
,
LPVOID
*
,
ULONG_PTR
*
,
ULONG
*
);
static
UINT
(
WINAPI
*
pResetWriteWatch
)(
LPVOID
,
SIZE_T
);
...
...
@@ -50,6 +50,7 @@ static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID);
static
BOOL
(
WINAPI
*
pGetProcessDEPPolicy
)(
HANDLE
,
LPDWORD
,
PBOOL
);
static
BOOL
(
WINAPI
*
pIsWow64Process
)(
HANDLE
,
PBOOL
);
static
NTSTATUS
(
WINAPI
*
pNtProtectVirtualMemory
)(
HANDLE
,
PVOID
*
,
SIZE_T
*
,
ULONG
,
ULONG
*
);
static
PVOID
(
WINAPI
*
pVirtualAllocFromApp
)(
PVOID
,
SIZE_T
,
DWORD
,
DWORD
);
/* ############################### */
...
...
@@ -443,6 +444,39 @@ static void test_VirtualAlloc(void)
ok
(
VirtualFree
(
addr1
,
0
,
MEM_RELEASE
),
"VirtualFree failed
\n
"
);
}
static
void
test_VirtualAllocFromApp
(
void
)
{
void
*
p
;
BOOL
ret
;
if
(
!
pVirtualAllocFromApp
)
{
win_skip
(
"VirtualAllocFromApp is not available.
\n
"
);
return
;
}
p
=
GetProcAddress
(
hkernel32
,
"VirtualAllocFromApp"
);
ok
(
!
p
,
"Found VirtualAllocFromApp in kernel32.dll.
\n
"
);
SetLastError
(
0xdeadbeef
);
p
=
pVirtualAllocFromApp
(
NULL
,
0x1000
,
MEM_RESERVE
,
PAGE_READWRITE
);
ok
(
p
&&
GetLastError
()
==
0xdeadbeef
,
"Got unexpected mem %p, GetLastError() %u.
\n
"
,
p
,
GetLastError
());
ret
=
VirtualFree
(
p
,
0
,
MEM_RELEASE
);
ok
(
ret
,
"Got unexpected ret %#x, GetLastError() %u.
\n
"
,
ret
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
p
=
pVirtualAllocFromApp
(
NULL
,
0x1000
,
MEM_RESERVE
,
PAGE_EXECUTE
);
ok
(
!
p
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Got unexpected mem %p, GetLastError() %u.
\n
"
,
p
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
p
=
pVirtualAllocFromApp
(
NULL
,
0x1000
,
MEM_RESERVE
,
PAGE_EXECUTE_READ
);
ok
(
!
p
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Got unexpected mem %p, GetLastError() %u.
\n
"
,
p
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
p
=
pVirtualAllocFromApp
(
NULL
,
0x1000
,
MEM_RESERVE
,
PAGE_EXECUTE_READWRITE
);
ok
(
!
p
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Got unexpected mem %p, GetLastError() %u.
\n
"
,
p
,
GetLastError
());
}
static
void
test_MapViewOfFile
(
void
)
{
static
const
char
testfile
[]
=
"testfile.xxx"
;
...
...
@@ -4238,6 +4272,7 @@ START_TEST(virtual)
}
hkernel32
=
GetModuleHandleA
(
"kernel32.dll"
);
hkernelbase
=
GetModuleHandleA
(
"kernelbase.dll"
);
hntdll
=
GetModuleHandleA
(
"ntdll.dll"
);
pGetWriteWatch
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"GetWriteWatch"
);
...
...
@@ -4252,6 +4287,7 @@ START_TEST(virtual)
pRtlAddVectoredExceptionHandler
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlAddVectoredExceptionHandler"
);
pRtlRemoveVectoredExceptionHandler
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlRemoveVectoredExceptionHandler"
);
pNtProtectVirtualMemory
=
(
void
*
)
GetProcAddress
(
hntdll
,
"NtProtectVirtualMemory"
);
pVirtualAllocFromApp
=
(
void
*
)
GetProcAddress
(
hkernelbase
,
"VirtualAllocFromApp"
);
GetSystemInfo
(
&
si
);
trace
(
"system page size %#x
\n
"
,
si
.
dwPageSize
);
...
...
@@ -4266,6 +4302,7 @@ START_TEST(virtual)
test_VirtualProtect
();
test_VirtualAllocEx
();
test_VirtualAlloc
();
test_VirtualAllocFromApp
();
test_MapViewOfFile
();
test_NtAreMappedFilesTheSame
();
test_CreateFileMapping
();
...
...
dlls/kernelbase/kernelbase.spec
View file @
61ca1128
...
...
@@ -1678,7 +1678,7 @@
@ stdcall VirtualAlloc(ptr long long long)
@ stdcall VirtualAllocEx(long ptr long long long)
@ stdcall VirtualAllocExNuma(long ptr long long long long)
# @ stub VirtualAllocFromApp
@ stdcall VirtualAllocFromApp(ptr long long long)
@ stdcall VirtualFree(ptr long long)
@ stdcall VirtualFreeEx(long ptr long long)
@ stdcall VirtualLock(ptr long)
...
...
dlls/kernelbase/memory.c
View file @
61ca1128
...
...
@@ -315,6 +315,28 @@ LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAlloc2( HANDLE process, void *addr, SIZE_
/***********************************************************************
* VirtualAllocFromApp (kernelbase.@)
*/
LPVOID
WINAPI
DECLSPEC_HOTPATCH
VirtualAllocFromApp
(
void
*
addr
,
SIZE_T
size
,
DWORD
type
,
DWORD
protect
)
{
LPVOID
ret
=
addr
;
TRACE_
(
virtual
)(
"addr %p, size %p, type %#x, protect %#x.
\n
"
,
addr
,
(
void
*
)
size
,
type
,
protect
);
if
(
protect
==
PAGE_EXECUTE
||
protect
==
PAGE_EXECUTE_READ
||
protect
==
PAGE_EXECUTE_READWRITE
||
protect
==
PAGE_EXECUTE_WRITECOPY
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
}
if
(
!
set_ntstatus
(
NtAllocateVirtualMemory
(
GetCurrentProcess
(),
&
ret
,
0
,
&
size
,
type
,
protect
)))
return
NULL
;
return
ret
;
}
/***********************************************************************
* VirtualFree (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
VirtualFree
(
void
*
addr
,
SIZE_T
size
,
DWORD
type
)
...
...
include/winbase.h
View file @
61ca1128
...
...
@@ -2748,6 +2748,7 @@ WINBASEAPI LPVOID WINAPI VirtualAlloc(LPVOID,SIZE_T,DWORD,DWORD);
WINBASEAPI
LPVOID
WINAPI
VirtualAlloc2
(
HANDLE
,
LPVOID
,
SIZE_T
,
DWORD
,
DWORD
,
MEM_EXTENDED_PARAMETER
*
,
ULONG
);
WINBASEAPI
LPVOID
WINAPI
VirtualAllocEx
(
HANDLE
,
LPVOID
,
SIZE_T
,
DWORD
,
DWORD
);
WINBASEAPI
LPVOID
WINAPI
VirtualAllocExNuma
(
HANDLE
,
void
*
,
SIZE_T
,
DWORD
,
DWORD
,
DWORD
);
WINBASEAPI
LPVOID
WINAPI
VirtualAllocFromApp
(
LPVOID
,
SIZE_T
,
DWORD
,
DWORD
);
WINBASEAPI
BOOL
WINAPI
VirtualFree
(
LPVOID
,
SIZE_T
,
DWORD
);
WINBASEAPI
BOOL
WINAPI
VirtualFreeEx
(
HANDLE
,
LPVOID
,
SIZE_T
,
DWORD
);
WINBASEAPI
BOOL
WINAPI
VirtualLock
(
LPVOID
,
SIZE_T
);
...
...
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