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
4847c1d8
Commit
4847c1d8
authored
Oct 05, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server: Set the dynamically relocated flag when relocations are present.
parent
84418169
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
loader.c
dlls/kernel32/tests/loader.c
+8
-0
mapping.c
server/mapping.c
+18
-3
No files found.
dlls/kernel32/tests/loader.c
View file @
4847c1d8
...
@@ -2153,6 +2153,7 @@ static void test_import_resolution(void)
...
@@ -2153,6 +2153,7 @@ static void test_import_resolution(void)
}
data
,
*
ptr
;
}
data
,
*
ptr
;
IMAGE_NT_HEADERS
nt
,
*
pnt
;
IMAGE_NT_HEADERS
nt
,
*
pnt
;
IMAGE_SECTION_HEADER
section
;
IMAGE_SECTION_HEADER
section
;
SECTION_IMAGE_INFORMATION
image
;
int
test
,
tls_index_save
,
nb_rel
;
int
test
,
tls_index_save
,
nb_rel
;
#if defined(__i386__)
#if defined(__i386__)
static
const
UCHAR
tls_init_code
[]
=
{
static
const
UCHAR
tls_init_code
[]
=
{
...
@@ -2192,6 +2193,7 @@ static void test_import_resolution(void)
...
@@ -2192,6 +2193,7 @@ static void test_import_resolution(void)
#else
#else
#define ADD_RELOC(field) data.rel.type_off[nb_rel++] = (IMAGE_REL_BASED_HIGHLOW << 12) + offsetof( struct imports, field )
#define ADD_RELOC(field) data.rel.type_off[nb_rel++] = (IMAGE_REL_BASED_HIGHLOW << 12) + offsetof( struct imports, field )
#endif
#endif
winetest_push_context
(
"%u"
,
test
);
nt
=
nt_header_template
;
nt
=
nt_header_template
;
nt
.
FileHeader
.
NumberOfSections
=
1
;
nt
.
FileHeader
.
NumberOfSections
=
1
;
nt
.
FileHeader
.
SizeOfOptionalHeader
=
sizeof
(
IMAGE_OPTIONAL_HEADER
);
nt
.
FileHeader
.
SizeOfOptionalHeader
=
sizeof
(
IMAGE_OPTIONAL_HEADER
);
...
@@ -2363,6 +2365,11 @@ static void test_import_resolution(void)
...
@@ -2363,6 +2365,11 @@ static void test_import_resolution(void)
ok
(
GetLastError
()
==
ERROR_BAD_EXE_FORMAT
,
"wrong error %lu
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_BAD_EXE_FORMAT
,
"wrong error %lu
\n
"
,
GetLastError
()
);
break
;
break
;
}
}
status
=
pNtQuerySection
(
mapping
,
SectionImageInformation
,
&
image
,
sizeof
(
image
),
&
size
);
ok
(
!
status
,
"NtQuerySection failed %lx
\n
"
,
status
);
ok
(
test
==
6
?
!
image
.
ImageDynamicallyRelocated
:
image
.
ImageDynamicallyRelocated
,
"image flags %x
\n
"
,
image
.
ImageFlags
);
ok
(
!
image
.
ImageContainsCode
,
"contains code %x
\n
"
,
image
.
ImageContainsCode
);
ok
(
mapping
!=
0
,
"CreateFileMappingA failed err %lu
\n
"
,
GetLastError
()
);
ok
(
mapping
!=
0
,
"CreateFileMappingA failed err %lu
\n
"
,
GetLastError
()
);
/* make sure that the address is not available */
/* make sure that the address is not available */
tmp
=
VirtualAlloc
(
(
void
*
)
nt
.
OptionalHeader
.
ImageBase
,
0x10000
,
tmp
=
VirtualAlloc
(
(
void
*
)
nt
.
OptionalHeader
.
ImageBase
,
0x10000
,
...
@@ -2399,6 +2406,7 @@ static void test_import_resolution(void)
...
@@ -2399,6 +2406,7 @@ static void test_import_resolution(void)
break
;
break
;
}
}
DeleteFileA
(
dll_name
);
DeleteFileA
(
dll_name
);
winetest_pop_context
();
#undef DATA_RVA
#undef DATA_RVA
}
}
}
}
...
...
server/mapping.c
View file @
4847c1d8
...
@@ -695,7 +695,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
...
@@ -695,7 +695,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
}
opt
;
}
opt
;
}
nt
;
}
nt
;
off_t
pos
;
off_t
pos
;
int
size
;
int
size
,
has_relocs
;
size_t
mz_size
,
clr_va
=
0
,
clr_size
=
0
;
size_t
mz_size
,
clr_va
=
0
,
clr_size
=
0
;
unsigned
int
i
;
unsigned
int
i
;
...
@@ -757,10 +757,15 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
...
@@ -757,10 +757,15 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
mapping
->
image
.
header_size
=
nt
.
opt
.
hdr32
.
SizeOfHeaders
;
mapping
->
image
.
header_size
=
nt
.
opt
.
hdr32
.
SizeOfHeaders
;
mapping
->
image
.
checksum
=
nt
.
opt
.
hdr32
.
CheckSum
;
mapping
->
image
.
checksum
=
nt
.
opt
.
hdr32
.
CheckSum
;
mapping
->
image
.
image_flags
=
0
;
mapping
->
image
.
image_flags
=
0
;
has_relocs
=
(
nt
.
opt
.
hdr32
.
NumberOfRvaAndSizes
>
IMAGE_DIRECTORY_ENTRY_BASERELOC
&&
nt
.
opt
.
hdr32
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_BASERELOC
].
VirtualAddress
&&
nt
.
opt
.
hdr32
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_BASERELOC
].
Size
&&
!
(
nt
.
FileHeader
.
Characteristics
&
IMAGE_FILE_RELOCS_STRIPPED
));
if
(
nt
.
opt
.
hdr32
.
SectionAlignment
&
page_mask
)
if
(
nt
.
opt
.
hdr32
.
SectionAlignment
&
page_mask
)
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageMappedFlat
;
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageMappedFlat
;
else
if
((
nt
.
opt
.
hdr32
.
DllCharacteristics
&
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
)
&&
else
if
((
nt
.
opt
.
hdr32
.
DllCharacteristics
&
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
)
&&
mapping
->
image
.
contains_code
&&
!
(
clr_va
&&
clr_size
))
(
has_relocs
||
mapping
->
image
.
contains_code
)
&&
!
(
clr_va
&&
clr_size
))
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageDynamicallyRelocated
;
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageDynamicallyRelocated
;
break
;
break
;
...
@@ -800,10 +805,20 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
...
@@ -800,10 +805,20 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
mapping
->
image
.
header_size
=
nt
.
opt
.
hdr64
.
SizeOfHeaders
;
mapping
->
image
.
header_size
=
nt
.
opt
.
hdr64
.
SizeOfHeaders
;
mapping
->
image
.
checksum
=
nt
.
opt
.
hdr64
.
CheckSum
;
mapping
->
image
.
checksum
=
nt
.
opt
.
hdr64
.
CheckSum
;
mapping
->
image
.
image_flags
=
0
;
mapping
->
image
.
image_flags
=
0
;
has_relocs
=
(
nt
.
opt
.
hdr64
.
NumberOfRvaAndSizes
>
IMAGE_DIRECTORY_ENTRY_BASERELOC
&&
nt
.
opt
.
hdr64
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_BASERELOC
].
VirtualAddress
&&
nt
.
opt
.
hdr64
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_BASERELOC
].
Size
&&
!
(
nt
.
FileHeader
.
Characteristics
&
IMAGE_FILE_RELOCS_STRIPPED
));
if
(
nt
.
opt
.
hdr64
.
SectionAlignment
&
page_mask
)
if
(
nt
.
opt
.
hdr64
.
SectionAlignment
&
page_mask
)
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageMappedFlat
;
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageMappedFlat
;
else
if
(
nt
.
opt
.
hdr64
.
NumberOfRvaAndSizes
>
IMAGE_DIRECTORY_ENTRY_BASERELOC
&&
nt
.
opt
.
hdr64
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_BASERELOC
].
VirtualAddress
&&
nt
.
opt
.
hdr64
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_BASERELOC
].
Size
&&
!
(
nt
.
FileHeader
.
Characteristics
&
IMAGE_FILE_RELOCS_STRIPPED
))
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageDynamicallyRelocated
;
else
if
((
nt
.
opt
.
hdr64
.
DllCharacteristics
&
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
)
&&
else
if
((
nt
.
opt
.
hdr64
.
DllCharacteristics
&
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
)
&&
mapping
->
image
.
contains_code
&&
!
(
clr_va
&&
clr_size
))
(
has_relocs
||
mapping
->
image
.
contains_code
)
&&
!
(
clr_va
&&
clr_size
))
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageDynamicallyRelocated
;
mapping
->
image
.
image_flags
|=
IMAGE_FLAGS_ImageDynamicallyRelocated
;
break
;
break
;
...
...
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