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
8db8368e
Commit
8db8368e
authored
Sep 18, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep the file handle of 16-bit modules open while the module is
loaded. This makes it possible to remove the InstallShield hack in OpenFile16. Moved LoadLibrary32_16 to kernel.
parent
5d249cb2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
55 deletions
+55
-55
ne_module.c
dlls/kernel/ne_module.c
+49
-18
file.c
files/file.c
+5
-22
module.h
include/module.h
+1
-0
module.c
loader/module.c
+0
-15
No files found.
dlls/kernel/ne_module.c
View file @
8db8368e
...
...
@@ -77,8 +77,6 @@ struct ne_segment_table_entry_s
#define hFirstModule (pThhook->hExeHead)
static
NE_MODULE
*
pCachedModule
=
0
;
/* Module cached by NE_OpenFile */
typedef
struct
{
void
*
module_start
;
/* 32-bit address of the module data */
...
...
@@ -563,15 +561,24 @@ BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset )
HANDLE
NE_OpenFile
(
NE_MODULE
*
pModule
)
{
HANDLE
handle
;
char
*
name
;
char
*
name
=
NE_MODULE_NAME
(
pModule
)
;
TRACE
(
"(%p)
\n
"
,
pModule
);
/* mjm - removed module caching because it keeps open file handles
thus preventing CDROMs from being ejected */
name
=
NE_MODULE_NAME
(
pModule
);
if
((
handle
=
CreateFileA
(
name
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
))
==
INVALID_HANDLE_VALUE
)
MESSAGE
(
"Can't open file '%s' for module %04x
\n
"
,
name
,
pModule
->
self
);
if
(
pModule
->
fd
)
{
if
(
!
DuplicateHandle
(
GetCurrentProcess
(),
pModule
->
fd
,
GetCurrentProcess
(),
&
handle
,
0
,
FALSE
,
DUPLICATE_SAME_ACCESS
))
handle
=
INVALID_HANDLE_VALUE
;
}
else
{
handle
=
CreateFileA
(
name
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
}
if
(
handle
==
INVALID_HANDLE_VALUE
)
ERR
(
"Can't open file '%s' for module %04x
\n
"
,
name
,
pModule
->
self
);
TRACE
(
"opened '%s' -> %p
\n
"
,
name
,
handle
);
return
handle
;
}
...
...
@@ -1027,17 +1034,29 @@ static HINSTANCE16 NE_LoadModule( LPCSTR name, BOOL lib_only )
HINSTANCE16
hInstance
;
HFILE16
hFile
;
OFSTRUCT
ofs
;
UINT
drive_type
;
/* Open file */
if
((
hFile
=
OpenFile16
(
name
,
&
ofs
,
OF_READ
))
==
HFILE_ERROR16
)
if
((
hFile
=
OpenFile16
(
name
,
&
ofs
,
OF_READ
|
OF_SHARE_DENY_WRITE
))
==
HFILE_ERROR16
)
return
(
HMODULE16
)
2
;
/* File not found */
hModule
=
NE_LoadExeHeader
(
DosFileHandleToWin32Handle
(
hFile
),
ofs
.
szPathName
);
_lclose16
(
hFile
);
if
(
hModule
<
32
)
return
hModule
;
if
(
hModule
<
32
)
{
_lclose16
(
hFile
);
return
hModule
;
}
pModule
=
NE_GetPtr
(
hModule
);
if
(
!
pModule
)
return
hModule
;
drive_type
=
GetDriveTypeA
(
ofs
.
szPathName
);
if
(
drive_type
!=
DRIVE_REMOVABLE
&&
drive_type
!=
DRIVE_CDROM
)
{
/* keep the file handle open if not on a removable media */
DuplicateHandle
(
GetCurrentProcess
(),
DosFileHandleToWin32Handle
(
hFile
),
GetCurrentProcess
(),
&
pModule
->
fd
,
0
,
FALSE
,
DUPLICATE_SAME_ACCESS
);
}
_lclose16
(
hFile
);
if
(
!
lib_only
&&
!
(
pModule
->
flags
&
NE_FFLAGS_LIBMODULE
)
)
return
hModule
;
...
...
@@ -1521,6 +1540,7 @@ static BOOL16 NE_FreeModule( HMODULE16 hModule, BOOL call_wep )
/* Clear magic number just in case */
pModule
->
magic
=
pModule
->
self
=
0
;
if
(
pModule
->
fd
)
CloseHandle
(
pModule
->
fd
);
/* Remove it from the linked list */
...
...
@@ -1542,10 +1562,6 @@ static BOOL16 NE_FreeModule( HMODULE16 hModule, BOOL call_wep )
/* Free the module storage */
GlobalFreeAll16
(
hModule
);
/* Remove module from cache */
if
(
pCachedModule
==
pModule
)
pCachedModule
=
NULL
;
return
TRUE
;
}
...
...
@@ -2080,6 +2096,21 @@ void WINAPI PrivateFreeLibrary(HINSTANCE16 handle)
FreeLibrary16
(
handle
);
}
/***********************************************************************
* LoadLibrary32 (KERNEL.452)
* LoadSystemLibrary32 (KERNEL.482)
*/
HMODULE
WINAPI
LoadLibrary32_16
(
LPCSTR
libname
)
{
HMODULE
hModule
;
DWORD
count
;
ReleaseThunkLock
(
&
count
);
hModule
=
LoadLibraryA
(
libname
);
RestoreThunkLock
(
count
);
return
hModule
;
}
/***************************************************************************
* MapHModuleLS (KERNEL32.@)
*/
...
...
files/file.c
View file @
8db8368e
...
...
@@ -1221,30 +1221,13 @@ found:
WideCharToMultiByte
(
CP_ACP
,
0
,
full_name
.
short_name
,
-
1
,
ofs
->
szPathName
,
sizeof
(
ofs
->
szPathName
),
NULL
,
NULL
);
if
(
mode
&
OF_SHARE_EXCLUSIVE
)
/* Some InstallShield version uses OF_SHARE_EXCLUSIVE
on the file <tempdir>/_ins0432._mp to determine how
far installation has proceeded.
_ins0432._mp is an executable and while running the
application expects the open with OF_SHARE_ to fail*/
/* Probable FIXME:
As our loader closes the files after loading the executable,
we can't find the running executable with FILE_InUse.
The loader should keep the file open, as Windows does that, too.
*/
{
char
*
last
=
strrchr
(
full_name
.
long_name
,
'/'
);
if
(
!
last
)
last
=
full_name
.
long_name
-
1
;
if
(
GetModuleHandle16
(
last
+
1
))
{
TRACE
(
"Denying shared open for %s
\n
"
,
full_name
.
long_name
);
return
HFILE_ERROR
;
}
}
if
(
mode
&
OF_DELETE
)
{
handle
=
FILE_CreateFile
(
full_name
.
long_name
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
,
TRUE
,
GetDriveTypeW
(
full_name
.
short_name
)
);
if
(
!
handle
)
goto
error
;
CloseHandle
(
handle
);
if
(
unlink
(
full_name
.
long_name
)
==
-
1
)
goto
not_found
;
TRACE
(
"(%s): OF_DELETE return = OK
\n
"
,
name
);
return
1
;
...
...
include/module.h
View file @
8db8368e
...
...
@@ -69,6 +69,7 @@ typedef struct _NE_MODULE
HMODULE16
self
;
/* 44 Handle for this module */
WORD
self_loading_sel
;
/* 46 Selector used for self-loading apps. */
LPVOID
hRsrcMap
;
/* HRSRC 16->32 map (for 32-bit modules) */
HANDLE
fd
;
/* handle to the binary file */
}
NE_MODULE
;
...
...
loader/module.c
View file @
8db8368e
...
...
@@ -618,21 +618,6 @@ HMODULE WINAPI LoadLibraryW(LPCWSTR libnameW)
}
/***********************************************************************
* LoadLibrary32 (KERNEL.452)
* LoadSystemLibrary32 (KERNEL.482)
*/
HMODULE
WINAPI
LoadLibrary32_16
(
LPCSTR
libname
)
{
HMODULE
hModule
;
DWORD
count
;
ReleaseThunkLock
(
&
count
);
hModule
=
LoadLibraryA
(
libname
);
RestoreThunkLock
(
count
);
return
hModule
;
}
/***********************************************************************
* FreeLibrary (KERNEL32.@)
* FreeLibrary32 (KERNEL.486)
*/
...
...
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