[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 |
|
---|
[8017] | 24 | #define MAKE_THREADID(processid, threadid) ((processid << 16) | threadid)
|
---|
| 25 | #define ODIN_TO_OS2_THREADID(threadid) (threadid & 0xFFFF)
|
---|
| 26 |
|
---|
[9909] | 27 | #define ODIN_GetCurrentThreadId() MAKE_THREADID(fibGetPid(), fibGetTid())
|
---|
| 28 | #define ODIN_GetCurrentProcessId() fibGetPid()
|
---|
| 29 |
|
---|
[8645] | 30 | TEB *WIN32API CreateTEB(HANDLE hThread, DWORD dwThreadId);
|
---|
| 31 | TEB *WIN32API InitializeMainThread();
|
---|
| 32 |
|
---|
| 33 | //******************************************************************************
|
---|
| 34 | // Set up the TEB structure of the CURRENT (!) thread
|
---|
| 35 | //******************************************************************************
|
---|
| 36 | BOOL WIN32API InitializeThread(TEB *teb, BOOL fMainThread = FALSE);
|
---|
| 37 |
|
---|
| 38 | void WIN32API DestroyTEB(TEB *teb);
|
---|
[5335] | 39 | ULONG WIN32API GetProcessTIBSel();
|
---|
[124] | 40 |
|
---|
[7829] | 41 | #define TIB_SWITCH_DEFAULT 0 //executable type determines whether or not FS is changed
|
---|
| 42 | #define TIB_SWITCH_FORCE_WIN32 1 //always switch to win32 TIB (FS is changed)
|
---|
[7810] | 43 | //
|
---|
| 44 | //Switch to WIN32 TIB (FS selector)
|
---|
| 45 | //NOTE: This is not done for Odin32 applications (LX), unless
|
---|
| 46 | // fForceSwitch is TRUE)
|
---|
| 47 | USHORT WIN32API SetWin32TIB(BOOL fForceSwitch = TIB_SWITCH_DEFAULT);
|
---|
[281] | 48 | void WIN32API RestoreOS2TIB();
|
---|
[7810] | 49 |
|
---|
[1891] | 50 | void SetPDBInstance(HINSTANCE hInstance);
|
---|
[127] | 51 |
|
---|
| 52 | extern BOOL fExeStarted;
|
---|
[953] | 53 | extern BOOL fFreeLibrary;
|
---|
[9798] | 54 | extern BOOL fIsOS2Image; //TRUE -> Odin32 OS/2 application (not converted!)
|
---|
| 55 | //FALSE -> otherwise
|
---|
| 56 | extern BOOL fSwitchTIBSel; // TRUE -> switch TIB selectors
|
---|
| 57 | // FALSE -> don't
|
---|
[4232] | 58 | extern BOOL fExitProcess;
|
---|
[127] | 59 |
|
---|
[281] | 60 | //Flat pointer to thread TIB structure
|
---|
| 61 | extern DWORD *TIBFlatPtr;
|
---|
| 62 |
|
---|
[1885] | 63 | extern PDB ProcessPDB;
|
---|
| 64 |
|
---|
| 65 | #define NtCurrentTeb GetThreadTEB
|
---|
[320] | 66 | TEB *WIN32API GetThreadTEB();
|
---|
[4657] | 67 | TEB *WIN32API GetTEBFromThreadId(ULONG threadId);
|
---|
| 68 | TEB *WIN32API GetTEBFromThreadHandle(HANDLE hThread);
|
---|
[320] | 69 |
|
---|
[1887] | 70 | #ifndef OS2_INCLUDED
|
---|
| 71 | inline PDB * PROCESS_Current(void)
|
---|
[1885] | 72 | {
|
---|
| 73 | return NtCurrentTeb()->process;
|
---|
| 74 | }
|
---|
[1887] | 75 | #endif
|
---|
[1885] | 76 |
|
---|
[4234] | 77 | ULONG InitCommandLine(const char *pszPeExe);
|
---|
[9494] | 78 | BOOL InitLoaders();
|
---|
[4234] | 79 |
|
---|
| 80 | #endif
|
---|