Don't cache file handles for NE executable modules so that we don't

lock the CDROM.
oldstable
Mike McCormack 2002-08-27 02:05:21 +00:00 committed by Alexandre Julliard
parent 160ab19ace
commit f5d21eb2bf
3 changed files with 20 additions and 18 deletions

View File

@ -421,22 +421,18 @@ BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset )
*/
HANDLE NE_OpenFile( NE_MODULE *pModule )
{
HANDLE handle;
char *name;
static HANDLE cachedfd = INVALID_HANDLE_VALUE;
TRACE("(%p) cache: mod=%p fd=%d\n",
pModule, pCachedModule, cachedfd );
if (pCachedModule == pModule) return cachedfd;
CloseHandle( cachedfd );
pCachedModule = 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 ((cachedfd = CreateFileA( name, GENERIC_READ, FILE_SHARE_READ,
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 );
TRACE("opened '%s' -> %d\n",
name, cachedfd );
return cachedfd;
TRACE("opened '%s' -> %d\n", name, handle);
return handle;
}

View File

@ -246,6 +246,7 @@ HGLOBAL16 WINAPI NE_DefResourceHandler( HGLOBAL16 hMemObj, HMODULE16 hModule,
ReadFile( fd, GlobalLock16( handle ), (int)pNameInfo->length << sizeShift,
&res, NULL );
}
CloseHandle(fd);
return handle;
}
return (HGLOBAL16)0;

View File

@ -189,7 +189,7 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
if(buff == NULL) {
WARN_(dll)("Memory exausted!");
return FALSE;
goto fail;
}
ReadFile(hf, buff, size, &res, NULL);
@ -213,10 +213,10 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
NE_FixupSegmentPrologs( pModule, segnum );
if (!(pSeg->flags & NE_SEGFLAGS_RELOC_DATA))
return TRUE; /* No relocation data, we are done */
goto succeed; /* No relocation data, we are done */
ReadFile(hf, &count, sizeof(count), &res, NULL);
if (!count) return TRUE;
if (!count) goto succeed;
TRACE_(fixup)("Fixups for %.*s, segment %d, hSeg %04x\n",
*((BYTE *)pModule + pModule->name_table),
@ -230,13 +230,13 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
reloc_entries = (struct relocation_entry_s *)HeapAlloc(GetProcessHeap(), 0, count * sizeof(struct relocation_entry_s));
if(reloc_entries == NULL) {
WARN_(fixup)("Not enough memory for relocation entries!");
return FALSE;
goto fail;
}
if (!ReadFile( hf, reloc_entries, count * sizeof(struct relocation_entry_s), &res, NULL) ||
(res != count * sizeof(struct relocation_entry_s)))
{
WARN_(fixup)("Unable to read relocation information\n" );
return FALSE;
goto fail;
}
/*
@ -419,6 +419,9 @@ BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
}
HeapFree(GetProcessHeap(), 0, reloc_entries);
succeed:
CloseHandle(hf);
return TRUE;
unknown:
@ -427,6 +430,9 @@ unknown:
i + 1, rep->address_type, rep->relocation_type,
rep->offset, rep->target1, rep->target2);
HeapFree(GetProcessHeap(), 0, reloc_entries);
fail:
CloseHandle(hf);
return FALSE;
}
@ -464,8 +470,7 @@ BOOL NE_LoadAllSegments( NE_MODULE *pModule )
NtCurrentTeb()->cur_stack = MAKESEGPTR(pModule->self_loading_sel,
0xff00 - sizeof(STACK16FRAME) );
DuplicateHandle( GetCurrentProcess(), NE_OpenFile(pModule),
GetCurrentProcess(), &hf, 0, FALSE, DUPLICATE_SAME_ACCESS );
hf = NE_OpenFile(pModule);
hFile16 = Win32HandleToDosFileHandle( hf );
TRACE_(dll)("CallBootAppProc(hModule=0x%04x,hf=0x%04x)\n",
pModule->self,hFile16);