| 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 |
|
|---|
| 23 | #define MAKE_THREADID(processid, threadid) ((processid << 16) | threadid)
|
|---|
| 24 | #define ODIN_TO_OS2_THREADID(threadid) (threadid & 0xFFFF)
|
|---|
| 25 |
|
|---|
| 26 | TEB * WIN32API InitializeTIB(BOOL fMainThread = FALSE);
|
|---|
| 27 | void WIN32API DestroyTIB();
|
|---|
| 28 | ULONG WIN32API GetProcessTIBSel();
|
|---|
| 29 |
|
|---|
| 30 | #define TIB_SWITCH_DEFAULT 0 //executable type determines whether or not FS is changed
|
|---|
| 31 | #define TIB_SWITCH_FORCE_WIN32 1 //always switch to win32 TIB (FS is changed)
|
|---|
| 32 | //
|
|---|
| 33 | //Switch to WIN32 TIB (FS selector)
|
|---|
| 34 | //NOTE: This is not done for Odin32 applications (LX), unless
|
|---|
| 35 | // fForceSwitch is TRUE)
|
|---|
| 36 | USHORT WIN32API SetWin32TIB(BOOL fForceSwitch = TIB_SWITCH_DEFAULT);
|
|---|
| 37 | void WIN32API RestoreOS2TIB();
|
|---|
| 38 |
|
|---|
| 39 | void SetPDBInstance(HINSTANCE hInstance);
|
|---|
| 40 |
|
|---|
| 41 | extern BOOL fExeStarted;
|
|---|
| 42 | extern BOOL fFreeLibrary;
|
|---|
| 43 | extern BOOL fIsOS2Image; //TRUE -> Odin32 OS/2 application (not converted!)
|
|---|
| 44 | //FALSE -> otherwise
|
|---|
| 45 | extern BOOL fExitProcess;
|
|---|
| 46 |
|
|---|
| 47 | //Flat pointer to thread TIB structure
|
|---|
| 48 | extern DWORD *TIBFlatPtr;
|
|---|
| 49 |
|
|---|
| 50 | extern PDB ProcessPDB;
|
|---|
| 51 |
|
|---|
| 52 | #define NtCurrentTeb GetThreadTEB
|
|---|
| 53 | TEB *WIN32API GetThreadTEB();
|
|---|
| 54 | TEB *WIN32API GetTEBFromThreadId(ULONG threadId);
|
|---|
| 55 | TEB *WIN32API GetTEBFromThreadHandle(HANDLE hThread);
|
|---|
| 56 |
|
|---|
| 57 | #ifndef OS2_INCLUDED
|
|---|
| 58 | inline PDB * PROCESS_Current(void)
|
|---|
| 59 | {
|
|---|
| 60 | return NtCurrentTeb()->process;
|
|---|
| 61 | }
|
|---|
| 62 | #endif
|
|---|
| 63 |
|
|---|
| 64 | ULONG InitCommandLine(const char *pszPeExe);
|
|---|
| 65 |
|
|---|
| 66 | #endif
|
|---|