1 /* $Id: pdata.h,v 1.4 2002/03/10 17:03:18 hyperion Exp $
6 * POSIX+ subsystem process environment data structure
8 * This file is part of the ReactOS Operating System.
11 * Created by KJK::Hyperion <noog@libero.it>
13 * THIS SOFTWARE IS NOT COPYRIGHTED
15 * This source code is offered for use in the public domain. You may
16 * use, modify or distribute it freely.
18 * This code is distributed in the hope that it will be useful but
19 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
20 * DISCLAMED. This includes but is not limited to warranties of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 #ifndef __PSX_PDATA_H_INCLUDED__
25 #define __PSX_PDATA_H_INCLUDED__
28 #include <ddk/ntddk.h>
29 #include <ntdll/rtl.h>
31 #include <psx/fdtable.h>
36 typedef struct __tagPDX_PDATA
38 BOOL Spawned
; /* TRUE if process has been created through __PdxSpawnPosixProcess() */
39 int ArgCount
; /* count of arguments passed to exec() */
40 char **ArgVect
; /* array of arguments passed to exec() */
41 char ***Environment
; /* pointer to user-provided environ variable */
42 UNICODE_STRING NativePathBuffer
; /* static buffer used by low-level calls for pathname conversions */
43 UNICODE_STRING CurDir
; /* current working directory */
44 UNICODE_STRING RootPath
; /* NT path to the process's root directory */
45 HANDLE RootHandle
; /* handle to the process's root directory */
46 __fdtable_t FdTable
; /* file descriptors table */
47 } __PDX_PDATA
, * __PPDX_PDATA
;
49 /* serialized process data block, used by __PdxSpawnPosixProcess() and __PdxExecThunk().
50 The layout of buffers inside the Buffer byte array is as following:
52 ArgVect[0] + null byte
53 ArgVect[1] + null byte
55 ArgVect[ArgCount - 1] + null byte
56 Environment[0] + null byte
57 Environment[1] + null byte
59 Environment[n - 1] + null byte (NOTE: the value of n is stored in ProcessData.Environment)
62 FdTable.Descriptors[0]
63 FdTable.Descriptors[1]
65 FdTable.Descriptors[FdTable.AllocatedDescriptors - 1]
66 FdTable.Descriptors[x].ExtraData
67 FdTable.Descriptors[y].ExtraData
69 padding for page boundary alignment
71 typedef struct __tagPDX_SERIALIZED_PDATA
73 __PDX_PDATA ProcessData
;
76 } __PDX_SERIALIZED_PDATA
, *__PPDX_SERIALIZED_PDATA
;
81 NTSTATUS STDCALL
__PdxSerializeProcessData(IN __PPDX_PDATA
, OUT __PPDX_SERIALIZED_PDATA
*);
82 NTSTATUS STDCALL
__PdxUnserializeProcessData(IN OUT __PPDX_SERIALIZED_PDATA
*, OUT __PPDX_PDATA
* OPTIONAL
);
85 #define __PdxAcquirePdataLock() (RtlAcquirePebLock())
86 #define __PdxReleasePdataLock() (RtlReleasePebLock())
88 #define __PdxSetProcessData(PPDATA) ((void)((NtCurrentPeb()->SubSystemData) = (PPDATA)))
89 #define __PdxGetProcessData() ((__PPDX_PDATA)(&(NtCurrentPeb()->SubSystemData)))
91 #define __PdxGetNativePathBuffer() ((PUNICODE_STRING)(&(__PdxGetProcessData()->NativePathBuffer)))
92 #define __PdxGetCurDir() ((PUNICODE_STRING)(&(__PdxGetProcessData()->CurDir)))
93 #define __PdxGetRootPath() ((PUNICODE_STRING)(&(__PdxGetProcessData()->RootPath)))
94 #define __PdxGetRootHandle() ((HANDLE)(__PdxGetProcessData()->RootHandle))
95 #define __PdxGetFdTable() ((__fdtable_t *)(__PdxGetProcessData()->FdTable))
97 #define __PdxSetNativePathBuffer(BUF) ((void)((__PdxGetProcessData()->NativePathBuffer) = (BUF)))
98 #define __PdxSetCurDir(CURDIR) ((void)((__PdxGetProcessData()->CurDir) = (CURDIR)))
99 #define __PdxSetRootPath(ROOTPATH) ((void)((__PdxGetProcessData()->RootPath) = (ROOTPATH)))
100 #define __PdxSetRootHandle(ROOTHANDLE) ((void)((__PdxGetProcessData()->RootHandle) = (ROOTHANDLE)))
101 #define __PdxSetFdTable(FDTABLE) ((void)((__PdxGetProcessData()->FdTable) = (FDTABLE)))
103 #endif /* __PSX_PDATA_H_INCLUDED__ */