[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 |
|
---|
[8645] | 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);
|
---|
[5335] | 41 | ULONG WIN32API GetProcessTIBSel();
|
---|
[124] | 42 |
|
---|
[7829] | 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)
|
---|
[7810] | 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);
|
---|
[281] | 50 | void WIN32API RestoreOS2TIB();
|
---|
[7810] | 51 |
|
---|
[1891] | 52 | void SetPDBInstance(HINSTANCE hInstance);
|
---|
[127] | 53 |
|
---|
| 54 | extern BOOL fExeStarted;
|
---|
[953] | 55 | extern BOOL fFreeLibrary;
|
---|
[9798] | 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
|
---|
[4232] | 60 | extern BOOL fExitProcess;
|
---|
[127] | 61 |
|
---|
[281] | 62 | //Flat pointer to thread TIB structure
|
---|
| 63 | extern DWORD *TIBFlatPtr;
|
---|
| 64 |
|
---|
[1885] | 65 | extern PDB ProcessPDB;
|
---|
| 66 |
|
---|
| 67 | #define NtCurrentTeb GetThreadTEB
|
---|
[320] | 68 | TEB *WIN32API GetThreadTEB();
|
---|
[4657] | 69 | TEB *WIN32API GetTEBFromThreadId(ULONG threadId);
|
---|
| 70 | TEB *WIN32API GetTEBFromThreadHandle(HANDLE hThread);
|
---|
[320] | 71 |
|
---|
[1887] | 72 | #ifndef OS2_INCLUDED
|
---|
| 73 | inline PDB * PROCESS_Current(void)
|
---|
[1885] | 74 | {
|
---|
| 75 | return NtCurrentTeb()->process;
|
---|
| 76 | }
|
---|
[1887] | 77 | #endif
|
---|
[1885] | 78 |
|
---|
[4234] | 79 | ULONG InitCommandLine(const char *pszPeExe);
|
---|
[9494] | 80 | BOOL InitLoaders();
|
---|
[4234] | 81 |
|
---|
| 82 | #endif
|
---|