From 100f13016e36aa02aada446d17de1f2106701bd8 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Fri, 2 May 2003 10:54:31 +0000 Subject: [PATCH] added support for the don't inheritance flag and changed the psp routines to use this flag Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@980 --- include/dos_inc.h | 5 +++-- include/dos_system.h | 4 ++-- src/dos/dos.cpp | 2 +- src/dos/dos_classes.cpp | 18 ++++++++++++++++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/dos_inc.h b/include/dos_inc.h index 1b91e545..8bee9a96 100644 --- a/include/dos_inc.h +++ b/include/dos_inc.h @@ -125,6 +125,7 @@ void DOS_SetupDevices(void); /* Execute and new process creation */ bool DOS_NewPSP(Bit16u pspseg,Bit16u size); +bool DOS_ChildPSP(Bit16u pspseg,Bit16u size); bool DOS_Execute(char * name,PhysPt block,Bit8u flags); bool DOS_Terminate(bool tsr); @@ -237,7 +238,7 @@ class DOS_PSP :public MemStruct { public: DOS_PSP (Bit16u segment) { SetPt(segment);seg=segment;psp=(sPSP *)HostMake(segment,0);}; void MakeNew (Bit16u memSize); - void CopyFileTable (DOS_PSP* srcpsp); + void CopyFileTable (DOS_PSP* srcpsp,bool createchildpsp); Bit16u FindFreeFileEntry (void); void CloseFiles (void); @@ -263,7 +264,7 @@ public: void SetCommandTail (RealPt src); bool SetNumFiles (Bit16u fileNum); Bit16u FindEntryByHandle (Bit8u handle); - + private: #ifdef _MSC_VER #pragma pack(1) diff --git a/include/dos_system.h b/include/dos_system.h index f0878ac2..1a333eaf 100644 --- a/include/dos_system.h +++ b/include/dos_system.h @@ -51,7 +51,7 @@ class DOS_DTA; class DOS_File { public: - DOS_File() { name=0; }; + DOS_File():flags(0) { name=0; }; virtual ~DOS_File(){}; virtual bool Read(Bit8u * data,Bit16u * size)=0; virtual bool Write(Bit8u * data,Bit16u * size)=0; @@ -220,7 +220,7 @@ public: DOS_Drive_Cache dirCache; }; -enum { OPEN_READ=0,OPEN_WRITE=1,OPEN_READWRITE=2 }; +enum { OPEN_READ=0,OPEN_WRITE=1,OPEN_READWRITE=2, DOS_NOT_INHERIT=128}; enum { DOS_SEEK_SET=0,DOS_SEEK_CUR=1,DOS_SEEK_END=2}; diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index b351b32c..f05a7f9b 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -666,7 +666,7 @@ static Bitu DOS_21Handler(void) { reg_al=dos.verify?1:0; break; case 0x55: /* Create Child PSP*/ - DOS_NewPSP(reg_dx,reg_si); + DOS_ChildPSP(reg_dx,reg_si); dos.psp = reg_dx; break; case 0x56: /* RENAME Rename file */ diff --git a/src/dos/dos_classes.cpp b/src/dos/dos_classes.cpp index 815d2ca7..dce39fbe 100644 --- a/src/dos/dos_classes.cpp +++ b/src/dos/dos_classes.cpp @@ -156,12 +156,26 @@ Bit16u DOS_PSP::FindEntryByHandle(Bit8u handle) return 0xFF; }; -void DOS_PSP::CopyFileTable(DOS_PSP* srcpsp) +void DOS_PSP::CopyFileTable(DOS_PSP* srcpsp,bool createchildpsp) { /* Copy file table from calling process */ for (Bit16u i=0;i<20;i++) { Bit8u handle = srcpsp->GetFileHandle(i); - SetFileHandle(i,handle); + if(createchildpsp) + { //copy obeying not inherit flag. + if(Files[handle] && !(Files[handle]->flags & DOS_NOT_INHERIT)) + { + SetFileHandle(i,handle); + } + else + { + SetFileHandle(i,0xff); + } + } + else + { //normal copy so don't mind the inheritance + SetFileHandle(i,handle); + } } };