mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-05 18:09:24 +00:00
DOS programs use handles 0-4 without opening/closing any of those
handles first. Split up Init from AllocDosHandle and call it from the DOSVM.
This commit is contained in:
parent
ab55442761
commit
b12e72d685
36
files/file.c
36
files/file.c
|
@ -975,6 +975,27 @@ HFILE32 WINAPI OpenFile32( LPCSTR name, OFSTRUCT *ofs, UINT32 mode )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* FILE_InitProcessDosHandles
|
||||
*
|
||||
* Allocates the default DOS handles for a process. Called either by
|
||||
* AllocDosHandle below or by the DOSVM stuff.
|
||||
*/
|
||||
BOOL32 FILE_InitProcessDosHandles( void ) {
|
||||
HANDLE32 *ptr;
|
||||
|
||||
if (!(ptr = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY,
|
||||
sizeof(*ptr) * DOS_TABLE_SIZE )))
|
||||
return FALSE;
|
||||
PROCESS_Current()->dos_handles = ptr;
|
||||
ptr[0] = GetStdHandle(STD_INPUT_HANDLE);
|
||||
ptr[1] = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
ptr[2] = GetStdHandle(STD_ERROR_HANDLE);
|
||||
ptr[3] = GetStdHandle(STD_ERROR_HANDLE);
|
||||
ptr[4] = GetStdHandle(STD_ERROR_HANDLE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* FILE_AllocDosHandle
|
||||
*
|
||||
|
@ -989,17 +1010,10 @@ HFILE16 FILE_AllocDosHandle( HANDLE32 handle )
|
|||
if (!handle || (handle == INVALID_HANDLE_VALUE32))
|
||||
return INVALID_HANDLE_VALUE16;
|
||||
|
||||
if (!ptr)
|
||||
{
|
||||
if (!(ptr = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY,
|
||||
sizeof(*ptr) * DOS_TABLE_SIZE )))
|
||||
goto error;
|
||||
PROCESS_Current()->dos_handles = ptr;
|
||||
ptr[0] = GetStdHandle(STD_INPUT_HANDLE);
|
||||
ptr[1] = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
ptr[2] = GetStdHandle(STD_ERROR_HANDLE);
|
||||
ptr[3] = GetStdHandle(STD_ERROR_HANDLE);
|
||||
ptr[4] = GetStdHandle(STD_ERROR_HANDLE);
|
||||
if (!ptr) {
|
||||
if (!FILE_InitProcessDosHandles())
|
||||
goto error;
|
||||
ptr = PROCESS_Current()->dos_handles;
|
||||
}
|
||||
|
||||
for (i = 0; i < DOS_TABLE_SIZE; i++, ptr++)
|
||||
|
|
|
@ -47,6 +47,7 @@ extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
|
|||
int prot, int flags );
|
||||
extern int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low );
|
||||
extern HFILE16 FILE_AllocDosHandle( HANDLE32 handle );
|
||||
extern BOOL32 FILE_InitProcessDosHandles( void );
|
||||
extern HANDLE32 FILE_GetHandle32( HFILE16 hfile );
|
||||
extern HFILE16 _lcreat16_uniq( LPCSTR path, INT32 attr );
|
||||
|
||||
|
|
|
@ -210,6 +210,9 @@ int DOSVM_Enter( PCONTEXT context )
|
|||
it will be killed automatically when the current task terminates */
|
||||
} else lpDosTask=pModule->lpDosTask;
|
||||
|
||||
/* allocate standard DOS handles */
|
||||
FILE_InitProcessDosHandles();
|
||||
|
||||
if (context) {
|
||||
#define CP(x,y) VM86.regs.x = y##_reg(context)
|
||||
CV;
|
||||
|
|
Loading…
Reference in a new issue