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
8ca3ca5a
Commit
8ca3ca5a
authored
Dec 01, 2006
by
Eric Pouech
Committed by
Alexandre Julliard
Dec 04, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imagehlp: MapAndLoad should do some useful stuff now.
parent
3b87fe97
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
56 deletions
+38
-56
access.c
dlls/imagehlp/access.c
+38
-56
No files found.
dlls/imagehlp/access.c
View file @
8ca3ca5a
...
...
@@ -145,95 +145,75 @@ BOOL WINAPI ImageUnload(PLOADED_IMAGE pLoadedImage)
/***********************************************************************
* MapAndLoad (IMAGEHLP.@)
*/
BOOL
WINAPI
MapAndLoad
(
LPSTR
pszImageName
,
LPSTR
pszDllPath
,
PLOADED_IMAGE
pLoadedImage
,
BOOL
WINAPI
MapAndLoad
(
LPSTR
pszImageName
,
LPSTR
pszDllPath
,
PLOADED_IMAGE
pLoadedImage
,
BOOL
bDotDll
,
BOOL
bReadOnly
)
{
CHAR
szFileName
[
MAX_PATH
];
HANDLE
hFile
=
NULL
;
HANDLE
hFile
=
INVALID_HANDLE_VALUE
;
HANDLE
hFileMapping
=
NULL
;
HMODULE
hModule
=
NULL
;
PVOID
mapping
=
NULL
;
PIMAGE_NT_HEADERS
pNtHeader
=
NULL
;
TRACE
(
"(%s, %s, %p, %d, %d)
\n
"
,
pszImageName
,
pszDllPath
,
pLoadedImage
,
bDotDll
,
bReadOnly
);
TRACE
(
"(%s, %s, %p, %d, %d)
\n
"
,
pszImageName
,
pszDllPath
,
pLoadedImage
,
bDotDll
,
bReadOnly
);
/* PathCombine(&szFileName, pszDllPath, pszImageName); */
/* PathRenameExtension(&szFileName, bDotDll?:"dll":"exe"); */
/* FIXME: Check if the file already loaded (use IMAGEHLP_pFirstLoadedImage) */
if
(
!
(
hFile
=
CreateFileA
(
szFileName
,
GENERIC_READ
,
1
,
/* FIXME: FILE_SHARE_READ not defined */
NULL
,
OPEN_EXISTING
,
0
,
NULL
)))
if
(
!
SearchPathA
(
pszDllPath
,
pszImageName
,
bDotDll
?
".DLL"
:
".EXE"
,
sizeof
(
szFileName
),
szFileName
,
NULL
))
{
SetLastError
(
ERROR_FILE_NOT_FOUND
);
goto
Error
;
}
if
(
!
(
hFileMapping
=
CreateFileMappingA
(
hFile
,
NULL
,
PAGE_READONLY
|
SEC_COMMIT
,
0
,
0
,
NULL
)))
hFile
=
CreateFileA
(
szFileName
,
GENERIC_READ
,
1
,
/* FIXME: FILE_SHARE_READ not defined */
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
if
(
hFile
==
INVALID_HANDLE_VALUE
)
{
DWORD
dwLastError
=
GetLastError
();
WARN
(
"CreateFileMapping: Error = %d
\n
"
,
dwLastError
);
SetLastError
(
dwLastError
);
WARN
(
"CreateFile: Error = %d
\n
"
,
GetLastError
());
goto
Error
;
}
CloseHandle
(
hFile
);
hFile
=
NULL
;
if
(
!
(
hModule
=
(
HMODULE
)
MapViewOfFile
(
hFileMapping
,
FILE_MAP_READ
,
0
,
0
,
0
))
)
hFileMapping
=
CreateFileMappingA
(
hFile
,
NULL
,
PAGE_READONLY
|
SEC_COMMIT
,
0
,
0
,
NULL
);
if
(
!
hFileMapping
)
{
DWORD
dwLastError
=
GetLastError
();
WARN
(
"MapViewOfFile: Error = %d
\n
"
,
dwLastError
);
SetLastError
(
dwLastError
);
WARN
(
"CreateFileMapping: Error = %d
\n
"
,
GetLastError
());
goto
Error
;
}
mapping
=
MapViewOfFile
(
hFileMapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
CloseHandle
(
hFileMapping
);
hFileMapping
=
NULL
;
pLoadedImage
=
HeapAlloc
(
IMAGEHLP_hHeap
,
0
,
sizeof
(
LOADED_IMAGE
));
if
(
!
mapping
)
{
WARN
(
"MapViewOfFile: Error = %d
\n
"
,
GetLastError
());
goto
Error
;
}
pNtHeader
=
RtlImageNtHeader
(
hModule
);
pNtHeader
=
RtlImageNtHeader
(
mapping
);
pLoadedImage
->
ModuleName
=
HeapAlloc
(
IMAGEHLP_hHeap
,
0
,
strlen
(
pszDllPath
)
+
1
);
/* FIXME: Correct? */
strcpy
(
pLoadedImage
->
ModuleName
,
pszDllPath
);
pLoadedImage
->
ModuleName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
szFileName
)
+
1
);
if
(
pLoadedImage
->
ModuleName
)
strcpy
(
pLoadedImage
->
ModuleName
,
szFileName
);
pLoadedImage
->
hFile
=
hFile
;
pLoadedImage
->
MappedAddress
=
(
PUCHAR
)
hModule
;
pLoadedImage
->
MappedAddress
=
mapping
;
pLoadedImage
->
FileHeader
=
pNtHeader
;
pLoadedImage
->
Sections
=
(
PIMAGE_SECTION_HEADER
)
((
LPBYTE
)
&
pNtHeader
->
OptionalHeader
+
pNtHeader
->
FileHeader
.
SizeOfOptionalHeader
);
pLoadedImage
->
NumberOfSections
=
pNtHeader
->
FileHeader
.
NumberOfSections
;
pLoadedImage
->
SizeOfImage
=
pNtHeader
->
OptionalHeader
.
SizeOfImage
;
pLoadedImage
->
Characteristics
=
pNtHeader
->
FileHeader
.
Characteristics
;
pLoadedImage
->
NumberOfSections
=
pNtHeader
->
FileHeader
.
NumberOfSections
;
pLoadedImage
->
SizeOfImage
=
pNtHeader
->
OptionalHeader
.
SizeOfImage
;
pLoadedImage
->
Characteristics
=
pNtHeader
->
FileHeader
.
Characteristics
;
pLoadedImage
->
LastRvaSection
=
pLoadedImage
->
Sections
;
pLoadedImage
->
fSystemImage
=
FALSE
;
/* FIXME */
pLoadedImage
->
fDOSImage
=
FALSE
;
/* FIXME */
/* FIXME: Make thread safe */
pLoadedImage
->
Links
.
Flink
=
NULL
;
pLoadedImage
->
Links
.
Blink
=
&
IMAGEHLP_pLastLoadedImage
->
Links
;
if
(
IMAGEHLP_pLastLoadedImage
)
IMAGEHLP_pLastLoadedImage
->
Links
.
Flink
=
&
pLoadedImage
->
Links
;
IMAGEHLP_pLastLoadedImage
=
pLoadedImage
;
if
(
!
IMAGEHLP_pFirstLoadedImage
)
IMAGEHLP_pFirstLoadedImage
=
pLoadedImage
;
pLoadedImage
->
Links
.
Flink
=
&
pLoadedImage
->
Links
;
pLoadedImage
->
Links
.
Blink
=
&
pLoadedImage
->
Links
;
return
TRUE
;
Error:
if
(
hModule
)
UnmapViewOfFile
((
PVOID
)
hModule
);
if
(
hFileMapping
)
CloseHandle
(
hFileMapping
);
if
(
hFile
)
CloseHandle
(
hFile
);
if
(
mapping
)
UnmapViewOfFile
(
mapping
);
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
hFile
);
return
FALSE
;
}
...
...
@@ -254,9 +234,11 @@ BOOL WINAPI SetImageConfigInformation(
/***********************************************************************
* UnMapAndLoad (IMAGEHLP.@)
*/
BOOL
WINAPI
UnMapAndLoad
(
PLOADED_IMAGE
LoadedImage
)
BOOL
WINAPI
UnMapAndLoad
(
PLOADED_IMAGE
p
LoadedImage
)
{
FIXME
(
"(%p): stub
\n
"
,
LoadedImage
);
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
return
FALSE
;
HeapFree
(
GetProcessHeap
(),
0
,
pLoadedImage
->
ModuleName
);
/* FIXME: MSDN states that a new checksum is computed and stored into the file */
if
(
pLoadedImage
->
MappedAddress
)
UnmapViewOfFile
(
pLoadedImage
->
MappedAddress
);
if
(
pLoadedImage
->
hFile
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
pLoadedImage
->
hFile
);
return
TRUE
;
}
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