HandleError HandleSystem::CloneHandle(Handle_t handle, Handle_t *newhandle, IdentityToken_t *newOwner, const HandleSecurity *pSecurity) { HandleError err; QHandle *pHandle; unsigned int index; IdentityToken_t *ident = pSecurity ? pSecurity->pIdentity : NULL; if ((err=GetHandle(handle, ident, &pHandle, &index)) != HandleError_None) { return err; } /* Identities cannot be cloned */ if (pHandle->set == HandleSet_Identity) { return HandleError_Identity; } /* Check if the handle can be cloned */ if (!CheckAccess(pHandle, HandleAccess_Clone, pSecurity)) { return HandleError_Access; } /* Make sure we're not cloning a clone */ if (pHandle->clone) { QHandle *pParent = &m_Handles[pHandle->clone]; return CloneHandle(pParent, pHandle->clone, newhandle, newOwner); } return CloneHandle(pHandle, index, newhandle, newOwner); }
Handle_t HandleSystem::FastCloneHandle(QHandle *pHandle, unsigned int index) { if (pHandle->clone) return FastCloneHandle(&m_Handles[pHandle->clone], pHandle->clone); Handle_t hndl; if (CloneHandle(pHandle, index, &hndl, g_pCoreIdent) != HandleError_None) return BAD_HANDLE; return hndl; }
/* The following code is 8086 dependant */ VOID new_psp(psp FAR * p, int psize) { REG COUNT i; psp FAR *q = MK_FP(cu_psp, 0); /* Clear out new psp first */ fmemset(p, 0, sizeof(psp)); /* initialize all entries and exits */ /* CP/M-like exit point */ p->ps_exit = 0x20cd; /* CP/M-like entry point - jump to special entry */ p->ps_farcall = 0xea; p->ps_reentry = (VOID(FAR *) ())cpm_entry; /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ p->ps_unix[0] = 0xcd; p->ps_unix[1] = 0x21; p->ps_unix[2] = 0xcb; /* Now for parent-child relationships */ /* parent psp segment */ p->ps_parent = cu_psp; /* previous psp pointer */ p->ps_prevpsp = q; /* Environment and memory useage parameters */ /* memory size in paragraphs */ p->ps_size = psize; /* environment paragraph */ p->ps_environ = 0; /* process dta */ p->ps_dta = (BYTE FAR *) (&p->ps_cmd_count); /* terminate address */ p->ps_isv22 = (VOID(INRPT FAR *) (void))getvec(0x22); /* break address */ p->ps_isv23 = (VOID(INRPT FAR *) (void))getvec(0x23); /* critical error address */ p->ps_isv24 = (VOID(INRPT FAR *) (void))getvec(0x24); /* File System parameters */ /* user stack pointer - int 21 */ p->ps_stack = q->ps_stack; /* file table - 0xff is unused */ for (i = 0; i < 20; i++) p->ps_files[i] = 0xff; /* maximum open files */ p->ps_maxfiles = 20; /* open file table pointer */ p->ps_filetab = p->ps_files; /* clone the file table */ if (p!=q) { REG COUNT i; for (i = 0; i < 20; i++) { if (q->ps_filetab[i] != 0xff && CloneHandle(i) >= 0) p->ps_filetab[i] = q->ps_filetab[i]; else p->ps_filetab[i] = 0xff; } } /* first command line argument */ p->ps_fcb1.fcb_drive = 0; /* second command line argument */ p->ps_fcb2.fcb_drive = 0; /* local command line */ p->ps_cmd_count = 0; /* command tail */ p->ps_cmd[0] = 0; /* command tail */ if (RootPsp == (seg) ~ 0) RootPsp = FP_SEG(p); }