created datatype for the denormalized process data block
[reactos.git] / posix / include / psx / pdata.h
1 /* $Id: pdata.h,v 1.3 2002/03/07 05:48:35 hyperion Exp $
2 */
3 /*
4 * psx/pdata.h
5 *
6 * POSIX+ subsystem process environment data structure
7 *
8 * This file is part of the ReactOS Operating System.
9 *
10 * Contributors:
11 * Created by KJK::Hyperion <noog@libero.it>
12 *
13 * THIS SOFTWARE IS NOT COPYRIGHTED
14 *
15 * This source code is offered for use in the public domain. You may
16 * use, modify or distribute it freely.
17 *
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.
22 *
23 */
24 #ifndef __PSX_PDATA_H_INCLUDED__
25 #define __PSX_PDATA_H_INCLUDED__
26
27 /* INCLUDES */
28 #include <ddk/ntddk.h>
29 #include <ntdll/rtl.h>
30 #include <limits.h>
31 #include <psx/fdtable.h>
32
33 /* OBJECTS */
34
35 /* TYPES */
36 typedef struct __tagPDX_PDATA
37 {
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 exesc() */
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;
48
49 /* serialized process data block, used by __PdxSpawnPosixProcess() and __PdxExecThunk().
50 The layout of buffers inside the Buffer byte array is as following:
51
52 ArgVect[0] + null byte
53 ArgVect[1] + null byte
54 ...
55 ArgVect[ArgCount - 1] + null byte
56 Environment[0] + null byte
57 Environment[1] + null byte
58 ...
59 Environment[n - 1] + null byte (NOTE: the value of n is stored in ProcessData.Environment)
60 CurDir.Buffer
61 RootPath.Buffer
62 FdTable.Descriptors[0]
63 FdTable.Descriptors[1]
64 ...
65 FdTable.Descriptors[FdTable.AllocatedDescriptors - 1]
66 FdTable.Descriptors[x].ExtraData
67 FdTable.Descriptors[y].ExtraData
68 ...
69 padding for page boundary alignment
70 */
71 typedef struct __tagPDX_SERIALIZED_PDATA
72 {
73 __PDX_PDATA ProcessData;
74 ULONG AllocSize;
75 BYTE Buffer[1];
76 } __PDX_SERIALIZED_PDATA, *__PPDX_SERIALIZED_PDATA;
77
78 /* CONSTANTS */
79
80 /* PROTOTYPES */
81
82 /* MACROS */
83 #define __PdxAcquirePdataLock() (RtlAcquirePebLock())
84 #define __PdxReleasePdataLock() (RtlReleasePebLock())
85
86 #define __PdxSetProcessData()(PPDATA) ((void)((NtCurrentPeb()->SubSystemData) = (PPDATA)))
87 #define __PdxGetProcessData() ((__PPDX_PDATA)(&(NtCurrentPeb()->SubSystemData)))
88
89 #define __PdxGetNativePathBuffer() ((PUNICODE_STRING)(&(__PdxGetProcessData()->NativePathBuffer)))
90 #define __PdxGetCurDir() ((PUNICODE_STRING)(&(__PdxGetProcessData()->CurDir)))
91 #define __PdxGetRootPath() ((PUNICODE_STRING)(&(__PdxGetProcessData()->RootPath)))
92 #define __PdxGetRootHandle() ((HANDLE)(__PdxGetProcessData()->RootHandle))
93 #define __PdxGetFdTable() ((__fdtable_t *)(__PdxGetProcessData()->FdTable))
94
95 #define __PdxSetNativePathBuffer(BUF) ((void)((__PdxGetProcessData()->NativePathBuffer) = (BUF)))
96 #define __PdxSetCurDir(CURDIR) ((void)((__PdxGetProcessData()->CurDir) = (CURDIR)))
97 #define __PdxSetRootPath(ROOTPATH) ((void)((__PdxGetProcessData()->RootPath) = (ROOTPATH)))
98 #define __PdxSetRootHandle(ROOTHANDLE) ((void)((__PdxGetProcessData()->RootHandle) = (ROOTHANDLE)))
99 #define __PdxSetFdTable(FDTABLE) ((void)((__PdxGetProcessData()->FdTable) = (FDTABLE)))
100
101 #endif /* __PSX_PDATA_H_INCLUDED__ */
102
103 /* EOF */
104