Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yoann Laissus
wine
Commits
cd3afa89
Commit
cd3afa89
authored
23 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
LOAD_LIBRARY_AS_DATAFILE modules must be mapped like normal files, not
like PE images. Fixed resource loading to handle that.
parent
f94462fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
loader/module.c
+12
-1
12 additions, 1 deletion
loader/module.c
loader/pe_image.c
+0
-1
0 additions, 1 deletion
loader/pe_image.c
loader/pe_resource.c
+47
-3
47 additions, 3 deletions
loader/pe_resource.c
with
59 additions
and
5 deletions
loader/module.c
+
12
−
1
View file @
cd3afa89
...
...
@@ -1284,7 +1284,18 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
NULL
,
OPEN_EXISTING
,
0
,
0
);
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
{
hmod
=
PE_LoadImage
(
hFile
,
filename
,
flags
);
DWORD
type
;
MODULE_GetBinaryType
(
hFile
,
filename
,
&
type
);
if
(
type
==
SCS_32BIT_BINARY
)
{
HANDLE
mapping
=
CreateFileMappingA
(
hFile
,
NULL
,
PAGE_READONLY
,
0
,
0
,
NULL
);
if
(
mapping
)
{
hmod
=
(
HMODULE
)
MapViewOfFile
(
mapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
CloseHandle
(
mapping
);
}
}
CloseHandle
(
hFile
);
}
if
(
hmod
)
return
(
HMODULE
)((
ULONG_PTR
)
hmod
+
1
);
...
...
This diff is collapsed.
Click to expand it.
loader/pe_image.c
+
0
−
1
View file @
cd3afa89
...
...
@@ -477,7 +477,6 @@ HMODULE PE_LoadImage( HANDLE hFile, LPCSTR filename, DWORD flags )
if
(
!
base
)
return
0
;
hModule
=
(
HMODULE
)
base
;
if
(
flags
&
LOAD_LIBRARY_AS_DATAFILE
)
return
hModule
;
/* nothing else to do */
/* perform base relocation, if necessary */
...
...
This diff is collapsed.
Click to expand it.
loader/pe_resource.c
+
47
−
3
View file @
cd3afa89
...
...
@@ -46,6 +46,39 @@ static const void *get_module_base( HMODULE hmod )
}
/**********************************************************************
* is_data_file_module
*
* Check if a module handle is for a LOAD_LIBRARY_AS_DATAFILE module.
*/
inline
static
int
is_data_file_module
(
HMODULE
hmod
)
{
return
(
ULONG_PTR
)
hmod
&
1
;
}
/**********************************************************************
* get_data_file_ptr
*
* Get a pointer to a given offset in a file mapped as data file.
*/
static
const
void
*
get_data_file_ptr
(
const
void
*
base
,
DWORD
offset
)
{
const
IMAGE_NT_HEADERS
*
nt
=
PE_HEADER
(
base
);
const
IMAGE_SECTION_HEADER
*
sec
=
(
IMAGE_SECTION_HEADER
*
)((
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
int
i
;
/* find the section containing the virtual address */
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
,
sec
++
)
{
if
((
sec
->
VirtualAddress
<=
offset
)
&&
(
sec
->
VirtualAddress
+
sec
->
SizeOfRawData
>
offset
))
return
(
char
*
)
base
+
sec
->
PointerToRawData
+
(
offset
-
sec
->
VirtualAddress
);
}
return
NULL
;
}
/**********************************************************************
* get_resdir
*
...
...
@@ -61,7 +94,10 @@ static const IMAGE_RESOURCE_DIRECTORY* get_resdir( HMODULE hmod )
{
dir
=
&
PE_HEADER
(
base
)
->
OptionalHeader
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_RESOURCE
];
if
(
dir
->
Size
&&
dir
->
VirtualAddress
)
ret
=
(
IMAGE_RESOURCE_DIRECTORY
*
)((
char
*
)
base
+
dir
->
VirtualAddress
);
{
if
(
is_data_file_module
(
hmod
))
ret
=
get_data_file_ptr
(
base
,
dir
->
VirtualAddress
);
else
ret
=
(
IMAGE_RESOURCE_DIRECTORY
*
)((
char
*
)
base
+
dir
->
VirtualAddress
);
}
}
return
ret
;
}
...
...
@@ -274,9 +310,17 @@ HRSRC PE_FindResourceW( HMODULE hmod, LPCWSTR name, LPCWSTR type )
*/
HGLOBAL
PE_LoadResource
(
HMODULE
hmod
,
HRSRC
hRsrc
)
{
DWORD
offset
;
const
void
*
base
=
get_module_base
(
hmod
);
if
(
!
hRsrc
)
return
0
;
return
(
HANDLE
)((
char
*
)
base
+
((
PIMAGE_RESOURCE_DATA_ENTRY
)
hRsrc
)
->
OffsetToData
);
if
(
!
hRsrc
||
!
base
)
return
0
;
offset
=
((
PIMAGE_RESOURCE_DATA_ENTRY
)
hRsrc
)
->
OffsetToData
;
if
(
is_data_file_module
(
hmod
))
return
(
HANDLE
)
get_data_file_ptr
(
base
,
offset
);
else
return
(
HANDLE
)((
char
*
)
base
+
offset
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment