Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
2ca5513a
Commit
2ca5513a
authored
Aug 23, 2010
by
Marcus Meissner
Committed by
Alexandre Julliard
Aug 24, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Set correct protection flags on sections in builtin DLLs.
parent
8c50936d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
16 deletions
+36
-16
loader.c
dlls/ntdll/loader.c
+2
-3
ntdll_misc.h
dlls/ntdll/ntdll_misc.h
+1
-1
info.c
dlls/ntdll/tests/info.c
+7
-7
virtual.c
dlls/ntdll/virtual.c
+26
-5
No files found.
dlls/ntdll/loader.c
View file @
2ca5513a
...
@@ -1404,9 +1404,8 @@ static void load_builtin_callback( void *module, const char *filename )
...
@@ -1404,9 +1404,8 @@ static void load_builtin_callback( void *module, const char *filename )
builtin_load_info
->
status
=
STATUS_INVALID_IMAGE_FORMAT
;
builtin_load_info
->
status
=
STATUS_INVALID_IMAGE_FORMAT
;
return
;
return
;
}
}
virtual_create_system_view
(
module
,
nt
->
OptionalHeader
.
SizeOfImage
,
VPROT_SYSTEM
|
VPROT_IMAGE
|
VPROT_COMMITTED
|
virtual_create_builtin_view
(
module
);
VPROT_READ
|
VPROT_WRITECOPY
|
VPROT_EXEC
);
/* create the MODREF */
/* create the MODREF */
...
...
dlls/ntdll/ntdll_misc.h
View file @
2ca5513a
...
@@ -155,7 +155,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S
...
@@ -155,7 +155,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S
/* virtual memory */
/* virtual memory */
extern
void
virtual_get_system_info
(
SYSTEM_BASIC_INFORMATION
*
info
);
extern
void
virtual_get_system_info
(
SYSTEM_BASIC_INFORMATION
*
info
);
extern
NTSTATUS
virtual_create_
system_view
(
void
*
base
,
SIZE_T
size
,
DWORD
vprot
);
extern
NTSTATUS
virtual_create_
builtin_view
(
void
*
base
);
extern
NTSTATUS
virtual_alloc_thread_stack
(
TEB
*
teb
,
SIZE_T
reserve_size
,
SIZE_T
commit_size
);
extern
NTSTATUS
virtual_alloc_thread_stack
(
TEB
*
teb
,
SIZE_T
reserve_size
,
SIZE_T
commit_size
);
extern
void
virtual_clear_thread_stack
(
void
);
extern
void
virtual_clear_thread_stack
(
void
);
extern
BOOL
virtual_handle_stack_fault
(
void
*
addr
);
extern
BOOL
virtual_handle_stack_fault
(
void
*
addr
);
...
...
dlls/ntdll/tests/info.c
View file @
2ca5513a
...
@@ -1077,15 +1077,15 @@ static void test_queryvirtualmemory(void)
...
@@ -1077,15 +1077,15 @@ static void test_queryvirtualmemory(void)
MEMORY_BASIC_INFORMATION
mbi
;
MEMORY_BASIC_INFORMATION
mbi
;
char
stackbuf
[
42
];
char
stackbuf
[
42
];
trace
(
"Check flags of a function entry in NTDLL.DLL
\n
"
);
trace
(
"Check flags of a function entry in NTDLL.DLL
at %p
\n
"
,
pNtQueryVirtualMemory
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
pNtQueryVirtualMemory
,
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
pNtQueryVirtualMemory
,
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
ok
(
mbi
.
AllocationProtect
==
PAGE_EXECUTE_WRITECOPY
,
"mbi.AllocationProtect is 0x%x, expected 0x%x
\n
"
,
mbi
.
AllocationProtect
,
PAGE_EXECUTE_WRITECOPY
);
ok
(
mbi
.
AllocationProtect
==
PAGE_EXECUTE_WRITECOPY
,
"mbi.AllocationProtect is 0x%x, expected 0x%x
\n
"
,
mbi
.
AllocationProtect
,
PAGE_EXECUTE_WRITECOPY
);
ok
(
mbi
.
State
==
MEM_COMMIT
,
"mbi.State is 0x%x, expected 0x%x
\n
"
,
mbi
.
State
,
MEM_COMMIT
);
ok
(
mbi
.
State
==
MEM_COMMIT
,
"mbi.State is 0x%x, expected 0x%x
\n
"
,
mbi
.
State
,
MEM_COMMIT
);
todo_wine
ok
(
mbi
.
Protect
==
PAGE_EXECUTE_READ
,
"mbi.Protect is 0x%x, expected 0x%x
\n
"
,
mbi
.
Protect
,
PAGE_EXECUTE_READ
);
ok
(
mbi
.
Protect
==
PAGE_EXECUTE_READ
,
"mbi.Protect is 0x%x, expected 0x%x
\n
"
,
mbi
.
Protect
,
PAGE_EXECUTE_READ
);
trace
(
"Check flags of heap
\n
"
);
trace
(
"Check flags of heap
at %p
\n
"
,
GetProcessHeap
()
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
GetProcessHeap
(),
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
GetProcessHeap
(),
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
...
@@ -1095,7 +1095,7 @@ static void test_queryvirtualmemory(void)
...
@@ -1095,7 +1095,7 @@ static void test_queryvirtualmemory(void)
ok
(
mbi
.
Protect
==
PAGE_READWRITE
||
mbi
.
Protect
==
PAGE_EXECUTE_READWRITE
,
ok
(
mbi
.
Protect
==
PAGE_READWRITE
||
mbi
.
Protect
==
PAGE_EXECUTE_READWRITE
,
"mbi.Protect is 0x%x
\n
"
,
mbi
.
Protect
);
"mbi.Protect is 0x%x
\n
"
,
mbi
.
Protect
);
trace
(
"Check flags of stack
\n
"
);
trace
(
"Check flags of stack
at %p
\n
"
,
stackbuf
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
stackbuf
,
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
stackbuf
,
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
...
@@ -1103,7 +1103,7 @@ static void test_queryvirtualmemory(void)
...
@@ -1103,7 +1103,7 @@ static void test_queryvirtualmemory(void)
ok
(
mbi
.
State
==
MEM_COMMIT
,
"mbi.State is 0x%x, expected 0x%x
\n
"
,
mbi
.
State
,
MEM_COMMIT
);
ok
(
mbi
.
State
==
MEM_COMMIT
,
"mbi.State is 0x%x, expected 0x%x
\n
"
,
mbi
.
State
,
MEM_COMMIT
);
ok
(
mbi
.
Protect
==
PAGE_READWRITE
,
"mbi.Protect is 0x%x, expected 0x%x
\n
"
,
mbi
.
Protect
,
PAGE_READWRITE
);
ok
(
mbi
.
Protect
==
PAGE_READWRITE
,
"mbi.Protect is 0x%x, expected 0x%x
\n
"
,
mbi
.
Protect
,
PAGE_READWRITE
);
trace
(
"Check flags of read-only data
\n
"
);
trace
(
"Check flags of read-only data
at %p
\n
"
,
teststring
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
teststring
,
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
teststring
,
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
...
@@ -1112,13 +1112,13 @@ static void test_queryvirtualmemory(void)
...
@@ -1112,13 +1112,13 @@ static void test_queryvirtualmemory(void)
if
(
mbi
.
Protect
!=
PAGE_READONLY
)
if
(
mbi
.
Protect
!=
PAGE_READONLY
)
todo_wine
ok
(
mbi
.
Protect
==
PAGE_READONLY
,
"mbi.Protect is 0x%x, expected 0x%X
\n
"
,
mbi
.
Protect
,
PAGE_READONLY
);
todo_wine
ok
(
mbi
.
Protect
==
PAGE_READONLY
,
"mbi.Protect is 0x%x, expected 0x%X
\n
"
,
mbi
.
Protect
,
PAGE_READONLY
);
trace
(
"Check flags of read-write global data (.bss)
\n
"
);
trace
(
"Check flags of read-write global data (.bss)
at %p
\n
"
,
rwtestbuf
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
rwtestbuf
,
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
status
=
pNtQueryVirtualMemory
(
NtCurrentProcess
(),
rwtestbuf
,
MemoryBasicInformation
,
&
mbi
,
sizeof
(
MEMORY_BASIC_INFORMATION
),
&
readcount
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
status
==
STATUS_SUCCESS
,
"Expected STATUS_SUCCESS, got %08x
\n
"
,
status
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
ok
(
readcount
==
sizeof
(
MEMORY_BASIC_INFORMATION
),
"Expected to read %d bytes, got %ld
\n
"
,(
int
)
sizeof
(
MEMORY_BASIC_INFORMATION
),
readcount
);
ok
(
mbi
.
AllocationProtect
==
PAGE_EXECUTE_WRITECOPY
,
"mbi.AllocationProtect is 0x%x, expected 0x%x
\n
"
,
mbi
.
AllocationProtect
,
PAGE_EXECUTE_WRITECOPY
);
ok
(
mbi
.
AllocationProtect
==
PAGE_EXECUTE_WRITECOPY
,
"mbi.AllocationProtect is 0x%x, expected 0x%x
\n
"
,
mbi
.
AllocationProtect
,
PAGE_EXECUTE_WRITECOPY
);
ok
(
mbi
.
State
==
MEM_COMMIT
,
"mbi.State is 0x%x, expected 0x%X
\n
"
,
mbi
.
State
,
MEM_COMMIT
);
ok
(
mbi
.
State
==
MEM_COMMIT
,
"mbi.State is 0x%x, expected 0x%X
\n
"
,
mbi
.
State
,
MEM_COMMIT
);
todo_wine
ok
(
mbi
.
Protect
==
PAGE_READWRITE
,
"mbi.Protect is 0x%x, expected 0x%X
\n
"
,
mbi
.
Protect
,
PAGE_READWRITE
);
ok
(
mbi
.
Protect
==
PAGE_READWRITE
,
"mbi.Protect is 0x%x, expected 0x%X
\n
"
,
mbi
.
Protect
,
PAGE_READWRITE
);
}
}
static
void
test_affinity
(
void
)
static
void
test_affinity
(
void
)
...
...
dlls/ntdll/virtual.c
View file @
2ca5513a
...
@@ -1396,18 +1396,39 @@ void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info )
...
@@ -1396,18 +1396,39 @@ void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info )
/***********************************************************************
/***********************************************************************
* virtual_create_system_view
* virtual_create_system_view
*/
*/
NTSTATUS
virtual_create_
system_view
(
void
*
base
,
SIZE_T
size
,
DWORD
vprot
)
NTSTATUS
virtual_create_
builtin_view
(
void
*
module
)
{
{
FILE_VIEW
*
view
;
NTSTATUS
status
;
NTSTATUS
status
;
sigset_t
sigset
;
sigset_t
sigset
;
IMAGE_NT_HEADERS
*
nt
=
RtlImageNtHeader
(
module
);
SIZE_T
size
=
nt
->
OptionalHeader
.
SizeOfImage
;
IMAGE_SECTION_HEADER
*
sec
;
FILE_VIEW
*
view
;
void
*
base
;
int
i
;
size
=
ROUND_SIZE
(
bas
e
,
size
);
size
=
ROUND_SIZE
(
modul
e
,
size
);
base
=
ROUND_ADDR
(
bas
e
,
page_mask
);
base
=
ROUND_ADDR
(
modul
e
,
page_mask
);
server_enter_uninterrupted_section
(
&
csVirtual
,
&
sigset
);
server_enter_uninterrupted_section
(
&
csVirtual
,
&
sigset
);
status
=
create_view
(
&
view
,
base
,
size
,
vprot
);
status
=
create_view
(
&
view
,
base
,
size
,
VPROT_SYSTEM
|
VPROT_IMAGE
|
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITECOPY
|
VPROT_EXEC
);
if
(
!
status
)
TRACE
(
"created %p-%p
\n
"
,
base
,
(
char
*
)
base
+
size
);
if
(
!
status
)
TRACE
(
"created %p-%p
\n
"
,
base
,
(
char
*
)
base
+
size
);
server_leave_uninterrupted_section
(
&
csVirtual
,
&
sigset
);
server_leave_uninterrupted_section
(
&
csVirtual
,
&
sigset
);
if
(
status
)
return
status
;
sec
=
(
IMAGE_SECTION_HEADER
*
)((
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
)
{
DWORD
flags
=
VPROT_SYSTEM
|
VPROT_IMAGE
|
VPROT_COMMITTED
;
if
(
sec
[
i
].
Characteristics
&
IMAGE_SCN_MEM_EXECUTE
)
flags
|=
VPROT_EXEC
;
if
(
sec
[
i
].
Characteristics
&
IMAGE_SCN_MEM_READ
)
flags
|=
VPROT_READ
;
if
(
sec
[
i
].
Characteristics
&
IMAGE_SCN_MEM_WRITE
)
flags
|=
VPROT_WRITE
;
memset
(
view
->
prot
+
(
sec
[
i
].
VirtualAddress
>>
page_shift
),
flags
,
ROUND_SIZE
(
sec
[
i
].
VirtualAddress
,
sec
[
i
].
Misc
.
VirtualSize
)
>>
page_shift
);
}
return
status
;
return
status
;
}
}
...
...
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