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
db3af1b2
Commit
db3af1b2
authored
Sep 25, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Consistently use the IMAGE_FIRST_SECTION helper macro.
parent
af25f29c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
17 deletions
+12
-17
loader.c
dlls/ntdll/loader.c
+3
-6
virtual.c
dlls/ntdll/tests/virtual.c
+1
-2
loader.c
dlls/ntdll/unix/loader.c
+2
-2
virtual.c
dlls/ntdll/unix/virtual.c
+5
-5
winnt.h
include/winnt.h
+1
-2
No files found.
dlls/ntdll/loader.c
View file @
db3af1b2
...
...
@@ -2059,8 +2059,7 @@ static NTSTATUS perform_relocations( void *module, IMAGE_NT_HEADERS *nt, SIZE_T
if
(
nt
->
FileHeader
.
NumberOfSections
>
ARRAY_SIZE
(
protect_old
))
return
STATUS_INVALID_IMAGE_FORMAT
;
sec
=
(
const
IMAGE_SECTION_HEADER
*
)((
const
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
sec
=
IMAGE_FIRST_SECTION
(
nt
);
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
)
{
void
*
addr
=
get_rva
(
module
,
sec
[
i
].
VirtualAddress
);
...
...
@@ -2216,8 +2215,8 @@ static BOOL convert_to_pe64( HMODULE module, const SECTION_IMAGE_INFORMATION *in
IMAGE_OPTIONAL_HEADER32
hdr32
=
{
IMAGE_NT_OPTIONAL_HDR32_MAGIC
};
IMAGE_OPTIONAL_HEADER64
hdr64
=
{
IMAGE_NT_OPTIONAL_HDR64_MAGIC
};
IMAGE_NT_HEADERS
*
nt
=
RtlImageNtHeader
(
module
);
IMAGE_SECTION_HEADER
*
sec
=
IMAGE_FIRST_SECTION
(
nt
);
SIZE_T
hdr_size
=
min
(
sizeof
(
hdr32
),
nt
->
FileHeader
.
SizeOfOptionalHeader
);
IMAGE_SECTION_HEADER
*
sec
=
(
IMAGE_SECTION_HEADER
*
)((
char
*
)
&
nt
->
OptionalHeader
+
hdr_size
);
SIZE_T
size
=
min
(
nt
->
OptionalHeader
.
SizeOfHeaders
,
nt
->
OptionalHeader
.
SizeOfImage
);
void
*
addr
=
module
;
ULONG
i
,
old_prot
;
...
...
@@ -4361,10 +4360,8 @@ PIMAGE_SECTION_HEADER WINAPI RtlImageRvaToSection( const IMAGE_NT_HEADERS *nt,
HMODULE
module
,
DWORD
rva
)
{
int
i
;
const
IMAGE_SECTION_HEADER
*
sec
;
const
IMAGE_SECTION_HEADER
*
sec
=
IMAGE_FIRST_SECTION
(
nt
)
;
sec
=
(
const
IMAGE_SECTION_HEADER
*
)((
const
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
,
sec
++
)
{
if
((
sec
->
VirtualAddress
<=
rva
)
&&
(
sec
->
VirtualAddress
+
sec
->
SizeOfRawData
>
rva
))
...
...
dlls/ntdll/tests/virtual.c
View file @
db3af1b2
...
...
@@ -2053,8 +2053,7 @@ static void perform_relocations( void *module, INT_PTR delta )
nt
=
RtlImageNtHeader
(
module
);
relocs
=
&
nt
->
OptionalHeader
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_BASERELOC
];
if
(
!
relocs
->
VirtualAddress
||
!
relocs
->
Size
)
return
;
sec
=
(
const
IMAGE_SECTION_HEADER
*
)((
const
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
sec
=
IMAGE_FIRST_SECTION
(
nt
);
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
)
{
void
*
addr
=
(
char
*
)
module
+
sec
[
i
].
VirtualAddress
;
...
...
dlls/ntdll/unix/loader.c
View file @
db3af1b2
...
...
@@ -1125,7 +1125,7 @@ static void relocate_ntdll( void *module )
if
(
!
(
rel
=
get_module_data_dir
(
module
,
IMAGE_DIRECTORY_ENTRY_BASERELOC
,
&
size
)))
return
;
sec
=
(
IMAGE_SECTION_HEADER
*
)((
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
sec
=
IMAGE_FIRST_SECTION
(
nt
);
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
)
{
void
*
addr
=
get_rva
(
module
,
sec
[
i
].
VirtualAddress
);
...
...
@@ -1991,7 +1991,7 @@ static void load_apiset_dll(void)
if
(
!
status
)
{
nt
=
get_rva
(
ptr
,
((
IMAGE_DOS_HEADER
*
)
ptr
)
->
e_lfanew
);
sec
=
(
IMAGE_SECTION_HEADER
*
)((
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
sec
=
IMAGE_FIRST_SECTION
(
nt
);
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
,
sec
++
)
{
...
...
dlls/ntdll/unix/virtual.c
View file @
db3af1b2
...
...
@@ -2608,7 +2608,7 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena
int
i
;
off_t
pos
;
struct
stat
st
;
char
*
header_end
,
*
header_start
;
char
*
header_end
;
char
*
ptr
=
view
->
base
;
SIZE_T
header_size
,
total_size
=
view
->
size
;
...
...
@@ -2626,12 +2626,12 @@ static NTSTATUS map_image_into_view( struct file_view *view, const WCHAR *filena
header_end
=
ptr
+
ROUND_SIZE
(
0
,
header_size
);
memset
(
ptr
+
header_size
,
0
,
header_end
-
(
ptr
+
header_size
)
);
if
((
char
*
)(
nt
+
1
)
>
header_end
)
return
status
;
header_start
=
(
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
;
if
(
nt
->
FileHeader
.
NumberOfSections
>
ARRAY_SIZE
(
sections
))
return
status
;
if
(
header_start
+
sizeof
(
*
sections
)
*
nt
->
FileHeader
.
NumberOfSections
>
header_end
)
return
status
;
sec
=
IMAGE_FIRST_SECTION
(
nt
);
if
((
char
*
)(
sec
+
nt
->
FileHeader
.
NumberOfSections
)
>
header_end
)
return
status
;
/* Some applications (e.g. the Steam version of Borderlands) map over the top of the section headers,
* copying the headers into local memory is necessary to properly load such applications. */
memcpy
(
sections
,
header_start
,
sizeof
(
*
sections
)
*
nt
->
FileHeader
.
NumberOfSections
);
memcpy
(
sections
,
sec
,
sizeof
(
*
sections
)
*
nt
->
FileHeader
.
NumberOfSections
);
sec
=
sections
;
imports
=
nt
->
OptionalHeader
.
DataDirectory
+
IMAGE_DIRECTORY_ENTRY_IMPORT
;
...
...
@@ -3297,7 +3297,7 @@ NTSTATUS virtual_create_builtin_view( void *module, const UNICODE_STRING *nt_nam
/* The PE header is always read-only, no write, no execute. */
set_page_vprot
(
base
,
page_size
,
VPROT_COMMITTED
|
VPROT_READ
);
sec
=
(
IMAGE_SECTION_HEADER
*
)((
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
sec
=
IMAGE_FIRST_SECTION
(
nt
);
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
)
{
BYTE
flags
=
VPROT_COMMITTED
;
...
...
include/winnt.h
View file @
db3af1b2
...
...
@@ -2927,8 +2927,7 @@ typedef struct _IMAGE_SECTION_HEADER {
#define IMAGE_SIZEOF_SECTION_HEADER 40
#define IMAGE_FIRST_SECTION(ntheader) \
((PIMAGE_SECTION_HEADER)(ULONG_PTR)((const BYTE *)&((const IMAGE_NT_HEADERS *)(ntheader))->OptionalHeader + \
((const IMAGE_NT_HEADERS *)(ntheader))->FileHeader.SizeOfOptionalHeader))
((PIMAGE_SECTION_HEADER)((ULONG_PTR)&(ntheader)->OptionalHeader + (ntheader)->FileHeader.SizeOfOptionalHeader))
/* These defines are for the Characteristics bitfield. */
/* #define IMAGE_SCN_TYPE_REG 0x00000000 - Reserved */
...
...
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