1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*++ |
6 | |
7 | |
8 | |
9 | Module Name: |
10 | |
11 | include/pal/procobj.hpp |
12 | |
13 | Abstract: |
14 | Header file for process structures |
15 | |
16 | |
17 | |
18 | --*/ |
19 | |
20 | #ifndef _PAL_PROCOBJ_HPP_ |
21 | #define _PAL_PROCOBJ_HPP_ |
22 | |
23 | #include "corunix.hpp" |
24 | |
25 | namespace CorUnix |
26 | { |
27 | extern CObjectType otProcess; |
28 | |
29 | typedef enum |
30 | { |
31 | PS_IDLE, |
32 | PS_STARTING, |
33 | PS_RUNNING, |
34 | PS_DONE |
35 | } PROCESS_STATE; |
36 | |
37 | // |
38 | // Struct for process module list (EnumProcessModules) |
39 | // |
40 | struct ProcessModules |
41 | { |
42 | ProcessModules *Next; |
43 | PVOID BaseAddress; |
44 | CHAR Name[0]; |
45 | }; |
46 | |
47 | // |
48 | // Ideally dwProcessId would be part of the process object's immutable |
49 | // data. Doing so, though, creates complications in CreateProcess. The |
50 | // contents of the immutable data for a new object must be set before |
51 | // that object is registered with the object manager (as the object |
52 | // manager may make a copy of the immutable data). The PID for a new |
53 | // process, though, is not known until after creation. Registering the |
54 | // process object after process creation creates an undesirable error path |
55 | // -- if we are not able to register the process object (say, because of |
56 | // a low resource condition) we would be forced to return an error to |
57 | // the caller of CreateProcess, even though the new process was actually |
58 | // created... |
59 | // |
60 | // Note: we could work around this by effectively always going down |
61 | // the create suspended path. That is, the new process would not exec until |
62 | // the parent process released it. It's unclear how much benefit this would |
63 | // provide us. |
64 | // |
65 | |
66 | class CProcProcessLocalData |
67 | { |
68 | public: |
69 | CProcProcessLocalData() |
70 | : |
71 | dwProcessId(0), |
72 | ps(PS_IDLE), |
73 | dwExitCode(0), |
74 | lAttachCount(0), |
75 | pProcessModules(NULL), |
76 | cProcessModules(0) |
77 | { |
78 | }; |
79 | |
80 | ~CProcProcessLocalData(); |
81 | |
82 | DWORD dwProcessId; |
83 | PROCESS_STATE ps; |
84 | DWORD dwExitCode; |
85 | LONG lAttachCount; |
86 | ProcessModules *pProcessModules; |
87 | DWORD cProcessModules; |
88 | }; |
89 | |
90 | PAL_ERROR |
91 | InternalCreateProcess( |
92 | CPalThread *pThread, |
93 | LPCWSTR lpApplicationName, |
94 | LPWSTR lpCommandLine, |
95 | LPSECURITY_ATTRIBUTES lpProcessAttributes, |
96 | LPSECURITY_ATTRIBUTES lpThreadAttributes, |
97 | BOOL bInheritHandles, |
98 | DWORD dwCreationFlags, |
99 | LPVOID lpEnvironment, |
100 | LPCWSTR lpCurrentDirectory, |
101 | LPSTARTUPINFOW lpStartupInfo, |
102 | LPPROCESS_INFORMATION lpProcessInformation |
103 | ); |
104 | |
105 | PAL_ERROR |
106 | InitializeProcessData( |
107 | void |
108 | ); |
109 | |
110 | PAL_ERROR |
111 | InitializeProcessCommandLine( |
112 | LPWSTR lpwstrCmdLine, |
113 | LPWSTR lpwstrFullPath |
114 | ); |
115 | |
116 | PAL_ERROR |
117 | CreateInitialProcessAndThreadObjects( |
118 | CPalThread *pThread |
119 | ); |
120 | |
121 | extern IPalObject *g_pobjProcess; |
122 | } |
123 | |
124 | #endif // _PAL_PROCOBJ_HPP_ |
125 | |
126 | |