1 | /*
|
---|
2 | * Process help functions
|
---|
3 | *
|
---|
4 | * Copyright (C) 1999 Sander van Leeuwen
|
---|
5 | *
|
---|
6 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
7 | *
|
---|
8 | */
|
---|
9 |
|
---|
10 | #ifndef _WPROCESS_H__
|
---|
11 | #define _WPROCESS_H__
|
---|
12 |
|
---|
13 | #define WIN32_TIBSEL
|
---|
14 |
|
---|
15 | #ifndef OS2_INCLUDED
|
---|
16 | #include <winprocess.h>
|
---|
17 | #else
|
---|
18 | #include <winconst.h>
|
---|
19 | typedef ULONG PDB;
|
---|
20 | #endif
|
---|
21 | #include <thread.h>
|
---|
22 | #include <FastInfoBlocks.h>
|
---|
23 |
|
---|
24 | #define SELECTOR_OS2_FS 0x150b
|
---|
25 |
|
---|
26 | #define MAKE_THREADID(processid, threadid) ((processid << 16) | threadid)
|
---|
27 | #define ODIN_TO_OS2_THREADID(threadid) (threadid & 0xFFFF)
|
---|
28 |
|
---|
29 | #define ODIN_GetCurrentThreadId() MAKE_THREADID(fibGetPid(), fibGetTid())
|
---|
30 | #define ODIN_GetCurrentProcessId() fibGetPid()
|
---|
31 |
|
---|
32 | TEB *WIN32API CreateTEB(HANDLE hThread, DWORD dwThreadId);
|
---|
33 | TEB *WIN32API InitializeMainThread();
|
---|
34 |
|
---|
35 | //******************************************************************************
|
---|
36 | // Set up the TEB structure of the CURRENT (!) thread
|
---|
37 | //******************************************************************************
|
---|
38 | BOOL WIN32API InitializeThread(TEB *teb, BOOL fMainThread = FALSE);
|
---|
39 |
|
---|
40 | void WIN32API DestroyTEB(TEB *teb);
|
---|
41 | ULONG WIN32API GetProcessTIBSel();
|
---|
42 |
|
---|
43 | #define TIB_SWITCH_DEFAULT 0 //executable type determines whether or not FS is changed
|
---|
44 | #define TIB_SWITCH_FORCE_WIN32 1 //always switch to win32 TIB (FS is changed)
|
---|
45 | //
|
---|
46 | //Switch to WIN32 TIB (FS selector)
|
---|
47 | //NOTE: This is not done for Odin32 applications (LX), unless
|
---|
48 | // fForceSwitch is TRUE)
|
---|
49 | USHORT WIN32API SetWin32TIB(BOOL fForceSwitch = TIB_SWITCH_DEFAULT);
|
---|
50 | void WIN32API RestoreOS2TIB();
|
---|
51 |
|
---|
52 | void SetPDBInstance(HINSTANCE hInstance);
|
---|
53 |
|
---|
54 | extern BOOL fExeStarted;
|
---|
55 | extern BOOL fFreeLibrary;
|
---|
56 | extern BOOL fIsOS2Image; //TRUE -> Odin32 OS/2 application (not converted!)
|
---|
57 | //FALSE -> otherwise
|
---|
58 | extern BOOL fSwitchTIBSel; // TRUE -> switch TIB selectors
|
---|
59 | // FALSE -> don't
|
---|
60 | extern BOOL fSEHEnabled; // TRUE -> SEH support enabled
|
---|
61 | // FALSE -> not enabled
|
---|
62 | extern BOOL fExitProcess;
|
---|
63 |
|
---|
64 | //Flat pointer to thread TIB structure
|
---|
65 | extern DWORD *TIBFlatPtr;
|
---|
66 |
|
---|
67 | extern PDB ProcessPDB;
|
---|
68 |
|
---|
69 | #define NtCurrentTeb GetThreadTEB
|
---|
70 | TEB *WIN32API GetThreadTEB(void);
|
---|
71 | TEB *WIN32API GetTEBFromThreadId(ULONG threadId);
|
---|
72 | TEB *WIN32API GetTEBFromThreadHandle(HANDLE hThread);
|
---|
73 |
|
---|
74 | #ifndef OS2_INCLUDED
|
---|
75 | inline PDB * PROCESS_Current(void)
|
---|
76 | {
|
---|
77 | return NtCurrentTeb()->process;
|
---|
78 | }
|
---|
79 | #endif
|
---|
80 |
|
---|
81 | ULONG InitCommandLine(const char *pszPeExe);
|
---|
82 | BOOL InitLoaders();
|
---|
83 |
|
---|
84 | UINT WIN32API GetProcModuleFileNameA(ULONG lpvAddress, LPSTR lpszFileName, UINT cchFileNameMax);
|
---|
85 |
|
---|
86 | #endif
|
---|