Release 990226.
[wine/gsoc-2012-control.git] / include / process.h
blobbf3def877612b008d8ebbe58d5a2b0ac3d6d621e
1 /*
2 * Process definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_PROCESS_H
8 #define __WINE_PROCESS_H
10 #include "wintypes.h"
11 #include "module.h"
12 #include "k32obj.h"
14 struct _NE_MODULE;
15 struct _THREAD_ENTRY;
17 /* Process handle entry */
18 typedef struct
20 DWORD access; /* Access flags */
21 K32OBJ *ptr; /* Object ptr */
22 int server; /* Server handle (FIXME: tmp hack) */
23 } HANDLE_ENTRY;
25 /* Process handle table */
26 typedef struct
28 DWORD count;
29 HANDLE_ENTRY entries[1];
30 } HANDLE_TABLE;
32 /* Current Process pseudo-handle - Returned by GetCurrentProcess*/
33 #define CURRENT_PROCESS_PSEUDOHANDLE ((HANDLE)0x7fffffff)
35 /* Win32 process environment database */
36 typedef struct
38 LPSTR environ; /* 00 Process environment strings */
39 DWORD unknown1; /* 04 Unknown */
40 LPSTR cmd_line; /* 08 Command line */
41 LPSTR cur_dir; /* 0c Current directory */
42 STARTUPINFOA *startup_info; /* 10 Startup information */
43 HANDLE hStdin; /* 14 Handle for standard input */
44 HANDLE hStdout; /* 18 Handle for standard output */
45 HANDLE hStderr; /* 1c Handle for standard error */
46 DWORD unknown2; /* 20 Unknown */
47 DWORD inherit_console; /* 24 Inherit console flag */
48 DWORD break_type; /* 28 Console events flag */
49 K32OBJ *break_sem; /* 2c SetConsoleCtrlHandler semaphore */
50 K32OBJ *break_event; /* 30 SetConsoleCtrlHandler event */
51 K32OBJ *break_thread; /* 34 SetConsoleCtrlHandler thread */
52 void *break_handlers; /* 38 List of console handlers */
53 /* The following are Wine-specific fields */
54 CRITICAL_SECTION section; /* 3c Env DB critical section */
55 LPWSTR cmd_lineW; /* 40 Unicode command line */
56 WORD env_sel; /* 44 Environment strings selector */
57 } ENVDB;
59 /* Win32 process database */
60 typedef struct _PDB
62 K32OBJ header; /* 00 Kernel object header */
63 DWORD unknown1; /* 08 Unknown */
64 K32OBJ *event; /* 0c Pointer to an event object (unused) */
65 DWORD exit_code; /* 10 Process exit code */
66 DWORD unknown2; /* 14 Unknown */
67 HANDLE heap; /* 18 Default process heap */
68 HANDLE mem_context; /* 1c Process memory context */
69 DWORD flags; /* 20 Flags */
70 void *pdb16; /* 24 DOS PSP */
71 WORD PSP_sel; /* 28 Selector to DOS PSP */
72 WORD module; /* 2a IMTE for the process module */
73 WORD threads; /* 2c Number of threads */
74 WORD running_threads; /* 2e Number of running threads */
75 WORD unknown3; /* 30 Unknown */
76 WORD ring0_threads; /* 32 Number of ring 0 threads */
77 HANDLE system_heap; /* 34 System heap to allocate handles */
78 HTASK task; /* 38 Win16 task */
79 void *mem_map_files; /* 3c Pointer to mem-mapped files */
80 ENVDB *env_db; /* 40 Environment database */
81 HANDLE_TABLE *handle_table; /* 44 Handle table */
82 struct _PDB *parent; /* 48 Parent process */
83 WINE_MODREF *modref_list; /* 4c MODREF list */
84 void *thread_list; /* 50 List of threads */
85 void *debuggee_CB; /* 54 Debuggee context block */
86 void *local_heap_free; /* 58 Head of local heap free list */
87 DWORD unknown4; /* 5c Unknown */
88 CRITICAL_SECTION crit_section; /* 60 Critical section */
89 DWORD unknown5[3]; /* 78 Unknown */
90 K32OBJ *console; /* 84 Console */
91 DWORD tls_bits[2]; /* 88 TLS in-use bits */
92 DWORD process_dword; /* 90 Unknown */
93 struct _PDB *group; /* 94 Process group */
94 WINE_MODREF *exe_modref; /* 98 MODREF for the process EXE */
95 LPTOP_LEVEL_EXCEPTION_FILTER top_filter; /* 9c Top exception filter */
96 DWORD priority; /* a0 Priority level */
97 HANDLE heap_list; /* a4 Head of process heap list */
98 void *heap_handles; /* a8 Head of heap handles list */
99 DWORD unknown6; /* ac Unknown */
100 K32OBJ *console_provider; /* b0 Console provider (??) */
101 WORD env_selector; /* b4 Selector to process environment */
102 WORD error_mode; /* b6 Error mode */
103 HANDLE load_done_evt; /* b8 Event for process loading done */
104 DWORD unknown7; /* bc Unknown */
105 DWORD unknown8; /* c0 Unknown (NT) */
106 LCID locale; /* c4 Locale to be queried by GetThreadLocale (NT) */
107 /* The following are Wine-specific fields */
108 void *server_pid; /* Server id for this process */
109 HANDLE *dos_handles; /* Handles mapping DOS -> Win32 */
110 struct _PDB *list_next; /* List reference - list of PDB's */
111 struct _PDB *list_prev; /* List reference - list of PDB's */
112 } PDB;
114 /* Process flags */
115 #define PDB32_WIN16_PROC 0x0008 /* Win16 process */
116 #define PDB32_DOS_PROC 0x0010 /* Dos process */
117 #define PDB32_CONSOLE_PROC 0x0020 /* Console process */
118 #define PDB32_FILE_APIS_OEM 0x0040 /* File APIs are OEM */
119 #define PDB32_WIN32S_PROC 0x8000 /* Win32s process */
121 /* PDB <-> Process id conversion macros */
122 #define PROCESS_OBFUSCATOR ((DWORD)0xdeadbeef)
123 #define PROCESS_ID_TO_PDB(id) ((PDB *)((id) ^ PROCESS_OBFUSCATOR))
124 #define PDB_TO_PROCESS_ID(pdb) ((DWORD)(pdb) ^ PROCESS_OBFUSCATOR)
126 /* scheduler/environ.c */
127 extern BOOL ENV_BuildEnvironment( PDB *pdb );
128 extern BOOL ENV_InheritEnvironment( PDB *pdb, LPCSTR env );
129 extern void ENV_FreeEnvironment( PDB *pdb );
131 /* scheduler/handle.c */
132 extern BOOL HANDLE_CreateTable( PDB *pdb, BOOL inherit );
133 extern HANDLE HANDLE_Alloc( PDB *pdb, K32OBJ *ptr, DWORD access,
134 BOOL inherit, int server_handle );
135 extern int HANDLE_GetServerHandle( PDB *pdb, HANDLE handle,
136 K32OBJ_TYPE type, DWORD access );
137 extern void HANDLE_CloseAll( PDB *pdb, K32OBJ *ptr );
139 /* Global handle macros */
140 #define HANDLE_OBFUSCATOR ((DWORD)0x544a4def)
141 #define HANDLE_IS_GLOBAL(h) (((DWORD)(h) ^ HANDLE_OBFUSCATOR) < 0x10000)
142 #define HANDLE_LOCAL_TO_GLOBAL(h) ((HANDLE)((DWORD)(h) ^ HANDLE_OBFUSCATOR))
143 #define HANDLE_GLOBAL_TO_LOCAL(h) ((HANDLE)((DWORD)(h) ^ HANDLE_OBFUSCATOR))
146 /* scheduler/process.c */
147 extern BOOL PROCESS_Init( void );
148 extern PDB *PROCESS_Current(void);
149 extern BOOL PROCESS_IsCurrent( HANDLE handle );
150 extern PDB *PROCESS_Initial(void);
151 extern PDB *PROCESS_IdToPDB( DWORD id );
152 extern PDB *PROCESS_Create( struct _NE_MODULE *pModule, LPCSTR cmd_line,
153 LPCSTR env, HINSTANCE16 hInstance,
154 HINSTANCE16 hPrevInstance, BOOL inherit,
155 STARTUPINFOA *startup, PROCESS_INFORMATION *info );
156 extern void PROCESS_SuspendOtherThreads(void);
157 extern void PROCESS_ResumeOtherThreads(void);
158 extern int PROCESS_PDBList_Getsize (void);
159 extern PDB* PROCESS_PDBList_Getfirst (void);
160 extern PDB* PROCESS_PDBList_Getnext (PDB*);
162 #endif /* __WINE_PROCESS_H */