[124] | 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 |
|
---|
[130] | 13 | #define WIN32_TIBSEL
|
---|
[125] | 14 |
|
---|
[1067] | 15 | #ifndef OS2_INCLUDED
|
---|
[1887] | 16 | #include <winprocess.h>
|
---|
| 17 | #else
|
---|
[2086] | 18 | #include <winconst.h>
|
---|
[1887] | 19 | typedef ULONG PDB;
|
---|
[1067] | 20 | #endif
|
---|
[127] | 21 | #include <thread.h>
|
---|
[9909] | 22 | #include <FastInfoBlocks.h>
|
---|
[127] | 23 |
|
---|
[10279] | 24 | #define SELECTOR_OS2_FS 0x150b
|
---|
| 25 |
|
---|
[8017] | 26 | #define MAKE_THREADID(processid, threadid) ((processid << 16) | threadid)
|
---|
| 27 | #define ODIN_TO_OS2_THREADID(threadid) (threadid & 0xFFFF)
|
---|
| 28 |
|
---|
[9909] | 29 | #define ODIN_GetCurrentThreadId() MAKE_THREADID(fibGetPid(), fibGetTid())
|
---|
| 30 | #define ODIN_GetCurrentProcessId() fibGetPid()
|
---|
| 31 |
|
---|
[21916] | 32 | #ifdef __cplusplus
|
---|
| 33 | extern "C" {
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
[8645] | 36 | TEB *WIN32API CreateTEB(HANDLE hThread, DWORD dwThreadId);
|
---|
| 37 | TEB *WIN32API InitializeMainThread();
|
---|
| 38 |
|
---|
| 39 | //******************************************************************************
|
---|
| 40 | // Set up the TEB structure of the CURRENT (!) thread
|
---|
| 41 | //******************************************************************************
|
---|
[21941] | 42 | BOOL WIN32API InitializeThread(TEB *teb, BOOL fMainThread DEF_VAL(FALSE));
|
---|
[8645] | 43 |
|
---|
| 44 | void WIN32API DestroyTEB(TEB *teb);
|
---|
[5335] | 45 | ULONG WIN32API GetProcessTIBSel();
|
---|
[124] | 46 |
|
---|
[7829] | 47 | #define TIB_SWITCH_DEFAULT 0 //executable type determines whether or not FS is changed
|
---|
| 48 | #define TIB_SWITCH_FORCE_WIN32 1 //always switch to win32 TIB (FS is changed)
|
---|
[7810] | 49 | //
|
---|
| 50 | //Switch to WIN32 TIB (FS selector)
|
---|
| 51 | //NOTE: This is not done for Odin32 applications (LX), unless
|
---|
| 52 | // fForceSwitch is TRUE)
|
---|
[21941] | 53 | USHORT WIN32API SetWin32TIB(BOOL fForceSwitch DEF_VAL(TIB_SWITCH_DEFAULT));
|
---|
[281] | 54 | void WIN32API RestoreOS2TIB();
|
---|
[7810] | 55 |
|
---|
[1891] | 56 | void SetPDBInstance(HINSTANCE hInstance);
|
---|
[127] | 57 |
|
---|
| 58 | extern BOOL fExeStarted;
|
---|
[953] | 59 | extern BOOL fFreeLibrary;
|
---|
[9798] | 60 | extern BOOL fIsOS2Image; //TRUE -> Odin32 OS/2 application (not converted!)
|
---|
| 61 | //FALSE -> otherwise
|
---|
| 62 | extern BOOL fSwitchTIBSel; // TRUE -> switch TIB selectors
|
---|
| 63 | // FALSE -> don't
|
---|
[21999] | 64 | extern BOOL fForceWin32TIB;// TRUE -> SEH support enabled
|
---|
[21381] | 65 | // FALSE -> not enabled
|
---|
[4232] | 66 | extern BOOL fExitProcess;
|
---|
[127] | 67 |
|
---|
[281] | 68 | //Flat pointer to thread TIB structure
|
---|
| 69 | extern DWORD *TIBFlatPtr;
|
---|
| 70 |
|
---|
[1885] | 71 | extern PDB ProcessPDB;
|
---|
| 72 |
|
---|
| 73 | #define NtCurrentTeb GetThreadTEB
|
---|
[21352] | 74 | TEB *WIN32API GetThreadTEB(void);
|
---|
[4657] | 75 | TEB *WIN32API GetTEBFromThreadId(ULONG threadId);
|
---|
| 76 | TEB *WIN32API GetTEBFromThreadHandle(HANDLE hThread);
|
---|
[320] | 77 |
|
---|
[1887] | 78 | #ifndef OS2_INCLUDED
|
---|
| 79 | inline PDB * PROCESS_Current(void)
|
---|
[1885] | 80 | {
|
---|
| 81 | return NtCurrentTeb()->process;
|
---|
| 82 | }
|
---|
[1887] | 83 | #endif
|
---|
[1885] | 84 |
|
---|
[4234] | 85 | ULONG InitCommandLine(const char *pszPeExe);
|
---|
[9494] | 86 | BOOL InitLoaders();
|
---|
[4234] | 87 |
|
---|
[10294] | 88 | UINT WIN32API GetProcModuleFileNameA(ULONG lpvAddress, LPSTR lpszFileName, UINT cchFileNameMax);
|
---|
| 89 |
|
---|
[21916] | 90 | #ifdef __cplusplus
|
---|
| 91 | } // extern "C"
|
---|
| 92 | #endif
|
---|
| 93 |
|
---|
[21941] | 94 | #endif
|
---|