mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-02 13:16:12 +00:00
Use Win32 file handles instead of Unix ones.
This commit is contained in:
parent
f8e741bcbe
commit
1392658679
3 changed files with 22 additions and 17 deletions
|
@ -395,22 +395,25 @@ BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset )
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* NE_OpenFile
|
* NE_OpenFile
|
||||||
*/
|
*/
|
||||||
int NE_OpenFile( NE_MODULE *pModule )
|
HANDLE32 NE_OpenFile( NE_MODULE *pModule )
|
||||||
{
|
{
|
||||||
DOS_FULL_NAME full_name;
|
DOS_FULL_NAME full_name;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
static int cachedfd = -1;
|
static HANDLE32 cachedfd = -1;
|
||||||
|
|
||||||
TRACE( module, "(%p) cache: mod=%p fd=%d\n",
|
TRACE( module, "(%p) cache: mod=%p fd=%d\n",
|
||||||
pModule, pCachedModule, cachedfd );
|
pModule, pCachedModule, cachedfd );
|
||||||
if (pCachedModule == pModule) return cachedfd;
|
if (pCachedModule == pModule) return cachedfd;
|
||||||
close( cachedfd );
|
CloseHandle( cachedfd );
|
||||||
pCachedModule = pModule;
|
pCachedModule = pModule;
|
||||||
name = NE_MODULE_NAME( pModule );
|
name = NE_MODULE_NAME( pModule );
|
||||||
if (!DOSFS_GetFullName( name, TRUE, &full_name ) ||
|
if (!DOSFS_GetFullName( name, TRUE, &full_name ) ||
|
||||||
(cachedfd = open( full_name.long_name, O_RDONLY )) == -1)
|
(cachedfd = FILE_OpenUnixFile( full_name.long_name, O_RDONLY )) == -1)
|
||||||
MSG( "Can't open file '%s' for module %04x\n", name, pModule->self );
|
MSG( "Can't open file '%s' for module %04x\n", name, pModule->self );
|
||||||
|
else
|
||||||
|
/* FIXME: should not be necessary */
|
||||||
|
cachedfd = ConvertToGlobalHandle(cachedfd);
|
||||||
TRACE(module, "opened '%s' -> %d\n",
|
TRACE(module, "opened '%s' -> %d\n",
|
||||||
name, cachedfd );
|
name, cachedfd );
|
||||||
return cachedfd;
|
return cachedfd;
|
||||||
|
|
|
@ -182,7 +182,7 @@ static HRSRC16 NE_FindResourceFromType( NE_MODULE *pModule,
|
||||||
HGLOBAL16 WINAPI NE_DefResourceHandler( HGLOBAL16 hMemObj, HMODULE16 hModule,
|
HGLOBAL16 WINAPI NE_DefResourceHandler( HGLOBAL16 hMemObj, HMODULE16 hModule,
|
||||||
HRSRC16 hRsrc )
|
HRSRC16 hRsrc )
|
||||||
{
|
{
|
||||||
int fd;
|
HANDLE32 fd;
|
||||||
NE_MODULE* pModule = NE_GetPtr( hModule );
|
NE_MODULE* pModule = NE_GetPtr( hModule );
|
||||||
if (pModule && (fd = NE_OpenFile( pModule )) >= 0)
|
if (pModule && (fd = NE_OpenFile( pModule )) >= 0)
|
||||||
{
|
{
|
||||||
|
@ -200,8 +200,10 @@ HGLOBAL16 WINAPI NE_DefResourceHandler( HGLOBAL16 hMemObj, HMODULE16 hModule,
|
||||||
|
|
||||||
if( handle )
|
if( handle )
|
||||||
{
|
{
|
||||||
lseek( fd, (int)pNameInfo->offset << sizeShift, SEEK_SET );
|
DWORD res;
|
||||||
read( fd, GlobalLock16( handle ), (int)pNameInfo->length << sizeShift );
|
SetFilePointer( fd, (int)pNameInfo->offset << sizeShift, NULL, SEEK_SET );
|
||||||
|
ReadFile( fd, GlobalLock16( handle ), (int)pNameInfo->length << sizeShift,
|
||||||
|
&res, NULL );
|
||||||
}
|
}
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,8 @@ BOOL32 NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
|
||||||
WORD count, i, offset, next_offset;
|
WORD count, i, offset, next_offset;
|
||||||
HMODULE16 module;
|
HMODULE16 module;
|
||||||
FARPROC16 address = 0;
|
FARPROC16 address = 0;
|
||||||
int fd;
|
HFILE32 hf;
|
||||||
|
DWORD res;
|
||||||
struct relocation_entry_s *rep, *reloc_entries;
|
struct relocation_entry_s *rep, *reloc_entries;
|
||||||
BYTE *func_name;
|
BYTE *func_name;
|
||||||
int size;
|
int size;
|
||||||
|
@ -77,10 +78,10 @@ BOOL32 NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
|
||||||
|
|
||||||
pModuleTable = NE_MODULE_TABLE( pModule );
|
pModuleTable = NE_MODULE_TABLE( pModule );
|
||||||
|
|
||||||
fd = NE_OpenFile( pModule );
|
hf = NE_OpenFile( pModule );
|
||||||
TRACE(module, "Loading segment %d, hSeg=%04x, flags=%04x\n",
|
TRACE(module, "Loading segment %d, hSeg=%04x, flags=%04x\n",
|
||||||
segnum, pSeg->hSeg, pSeg->flags );
|
segnum, pSeg->hSeg, pSeg->flags );
|
||||||
lseek( fd, pSeg->filepos << pModule->alignment, SEEK_SET );
|
SetFilePointer( hf, pSeg->filepos << pModule->alignment, NULL, SEEK_SET );
|
||||||
if (pSeg->size) size = pSeg->size;
|
if (pSeg->size) size = pSeg->size;
|
||||||
else size = pSeg->minsize ? pSeg->minsize : 0x10000;
|
else size = pSeg->minsize ? pSeg->minsize : 0x10000;
|
||||||
mem = GlobalLock16(pSeg->hSeg);
|
mem = GlobalLock16(pSeg->hSeg);
|
||||||
|
@ -92,7 +93,6 @@ BOOL32 NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
|
||||||
DWORD oldstack;
|
DWORD oldstack;
|
||||||
WORD old_hSeg, new_hSeg;
|
WORD old_hSeg, new_hSeg;
|
||||||
THDB *thdb = THREAD_Current();
|
THDB *thdb = THREAD_Current();
|
||||||
HFILE32 hf = FILE_DupUnixHandle( fd );
|
|
||||||
|
|
||||||
selfloadheader = (SELFLOADHEADER *)
|
selfloadheader = (SELFLOADHEADER *)
|
||||||
PTR_SEG_OFF_TO_LIN(SEL(pSegTable->hSeg),0);
|
PTR_SEG_OFF_TO_LIN(SEL(pSegTable->hSeg),0);
|
||||||
|
@ -138,7 +138,7 @@ BOOL32 NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
|
||||||
thdb->cur_stack = oldstack;
|
thdb->cur_stack = oldstack;
|
||||||
}
|
}
|
||||||
else if (!(pSeg->flags & NE_SEGFLAGS_ITERATED))
|
else if (!(pSeg->flags & NE_SEGFLAGS_ITERATED))
|
||||||
read(fd, mem, size);
|
ReadFile(hf, mem, size, &res, NULL);
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
The following bit of code for "iterated segments" was written without
|
The following bit of code for "iterated segments" was written without
|
||||||
|
@ -148,7 +148,7 @@ BOOL32 NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
|
||||||
*/
|
*/
|
||||||
char* buff = xmalloc(size);
|
char* buff = xmalloc(size);
|
||||||
char* curr = buff;
|
char* curr = buff;
|
||||||
read(fd, buff, size);
|
ReadFile(hf, mem, size, &res, NULL);
|
||||||
while(curr < buff + size) {
|
while(curr < buff + size) {
|
||||||
unsigned int rept = *((short*) curr)++;
|
unsigned int rept = *((short*) curr)++;
|
||||||
unsigned int len = *((short*) curr)++;
|
unsigned int len = *((short*) curr)++;
|
||||||
|
@ -167,7 +167,7 @@ BOOL32 NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
|
||||||
if (!(pSeg->flags & NE_SEGFLAGS_RELOC_DATA))
|
if (!(pSeg->flags & NE_SEGFLAGS_RELOC_DATA))
|
||||||
return TRUE; /* No relocation data, we are done */
|
return TRUE; /* No relocation data, we are done */
|
||||||
|
|
||||||
read( fd, &count, sizeof(count) );
|
ReadFile(hf, &count, sizeof(count), &res, NULL);
|
||||||
if (!count) return TRUE;
|
if (!count) return TRUE;
|
||||||
|
|
||||||
TRACE(fixup, "Fixups for %.*s, segment %d, hSeg %04x\n",
|
TRACE(fixup, "Fixups for %.*s, segment %d, hSeg %04x\n",
|
||||||
|
@ -180,8 +180,8 @@ BOOL32 NE_LoadSegment( NE_MODULE *pModule, WORD segnum )
|
||||||
segnum, pSeg->hSeg );
|
segnum, pSeg->hSeg );
|
||||||
|
|
||||||
reloc_entries = (struct relocation_entry_s *)xmalloc(count * sizeof(struct relocation_entry_s));
|
reloc_entries = (struct relocation_entry_s *)xmalloc(count * sizeof(struct relocation_entry_s));
|
||||||
if (read( fd, reloc_entries, count * sizeof(struct relocation_entry_s)) !=
|
if (!ReadFile( hf, reloc_entries, count * sizeof(struct relocation_entry_s), &res, NULL) ||
|
||||||
count * sizeof(struct relocation_entry_s))
|
(res != count * sizeof(struct relocation_entry_s)))
|
||||||
{
|
{
|
||||||
WARN(fixup, "Unable to read relocation information\n" );
|
WARN(fixup, "Unable to read relocation information\n" );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -422,7 +422,7 @@ BOOL32 NE_LoadAllSegments( NE_MODULE *pModule )
|
||||||
stack16Top->ip = 0;
|
stack16Top->ip = 0;
|
||||||
stack16Top->cs = 0;
|
stack16Top->cs = 0;
|
||||||
|
|
||||||
hf = FILE_DupUnixHandle( NE_OpenFile( pModule ) );
|
hf = NE_OpenFile( pModule );
|
||||||
TRACE(dll,"CallBootAppProc(hModule=0x%04x,hf=0x%04x)\n",pModule->self,
|
TRACE(dll,"CallBootAppProc(hModule=0x%04x,hf=0x%04x)\n",pModule->self,
|
||||||
HFILE32_TO_HFILE16(hf));
|
HFILE32_TO_HFILE16(hf));
|
||||||
Callbacks->CallBootAppProc(selfloadheader->BootApp, pModule->self,
|
Callbacks->CallBootAppProc(selfloadheader->BootApp, pModule->self,
|
||||||
|
|
Loading…
Reference in a new issue