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:
Marcus Meissner 1999-01-23 14:01:08 +00:00 committed by Alexandre Julliard
parent ab55442761
commit b12e72d685
3 changed files with 29 additions and 11 deletions

View file

@ -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 * FILE_AllocDosHandle
* *
@ -989,17 +1010,10 @@ HFILE16 FILE_AllocDosHandle( HANDLE32 handle )
if (!handle || (handle == INVALID_HANDLE_VALUE32)) if (!handle || (handle == INVALID_HANDLE_VALUE32))
return INVALID_HANDLE_VALUE16; return INVALID_HANDLE_VALUE16;
if (!ptr) if (!ptr) {
{ if (!FILE_InitProcessDosHandles())
if (!(ptr = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, goto error;
sizeof(*ptr) * DOS_TABLE_SIZE ))) ptr = PROCESS_Current()->dos_handles;
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);
} }
for (i = 0; i < DOS_TABLE_SIZE; i++, ptr++) for (i = 0; i < DOS_TABLE_SIZE; i++, ptr++)

View file

@ -47,6 +47,7 @@ extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
int prot, int flags ); int prot, int flags );
extern int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low ); extern int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low );
extern HFILE16 FILE_AllocDosHandle( HANDLE32 handle ); extern HFILE16 FILE_AllocDosHandle( HANDLE32 handle );
extern BOOL32 FILE_InitProcessDosHandles( void );
extern HANDLE32 FILE_GetHandle32( HFILE16 hfile ); extern HANDLE32 FILE_GetHandle32( HFILE16 hfile );
extern HFILE16 _lcreat16_uniq( LPCSTR path, INT32 attr ); extern HFILE16 _lcreat16_uniq( LPCSTR path, INT32 attr );

View file

@ -210,6 +210,9 @@ int DOSVM_Enter( PCONTEXT context )
it will be killed automatically when the current task terminates */ it will be killed automatically when the current task terminates */
} else lpDosTask=pModule->lpDosTask; } else lpDosTask=pModule->lpDosTask;
/* allocate standard DOS handles */
FILE_InitProcessDosHandles();
if (context) { if (context) {
#define CP(x,y) VM86.regs.x = y##_reg(context) #define CP(x,y) VM86.regs.x = y##_reg(context)
CV; CV;