Advertisement
Guest User

Untitled

a guest
Jun 20th, 2012
3,246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 28.33 KB | None | 0 0
  1.  
  2. /*********************************************************************
  3.  * Structures and definitions undocumented or included in the NTDDK. *
  4.  *********************************************************************/
  5.  
  6. #ifndef __STRUCT_H__
  7. #define __STRUCT_H__
  8.  
  9. #include <winternl.h>
  10. #include <tlhelp32.h>
  11. #include <cstdlib>
  12. #include <windows.h>
  13.  
  14. ///////////////// Windows NT ///////////////
  15.  
  16. typedef unsigned long ULONG_PTR, *PULONG_PTR;
  17. typedef LONG NTSTATUS, *PNTSTATUS;
  18. typedef ULONG KAFFINITY, *PKAFFINITY;
  19. typedef LONG KPRIORITY;
  20.  
  21. #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
  22.  
  23. typedef void (CALLBACK *PKNORMAL_ROUTINE)(PVOID, PVOID, PVOID);
  24.  
  25. typedef struct _CLIENT_ID {
  26.    HANDLE UniqueProcess;
  27.    HANDLE UniqueThread;
  28. } CLIENT_ID, *PCLIENT_ID;
  29.  
  30. #define InitializeObjectAttributes( p, n, a, r, s ) { \
  31.     (p)->Length = sizeof( OBJECT_ATTRIBUTES );        \
  32.     (p)->RootDirectory = r;                           \
  33.     (p)->Attributes = a;                              \
  34.     (p)->ObjectName = n;                              \
  35.     (p)->SecurityDescriptor = s;                      \
  36.     (p)->SecurityQualityOfService = NULL;             \
  37.     }
  38.  
  39. #define OBJ_INHERIT             0x00000002L
  40. #define OBJ_PERMANENT           0x00000010L
  41. #define OBJ_EXCLUSIVE           0x00000020L
  42. #define OBJ_CASE_INSENSITIVE    0x00000040L
  43. #define OBJ_OPENIF              0x00000080L
  44. #define OBJ_OPENLINK            0x00000100L
  45. #define OBJ_KERNEL_HANDLE       0x00000200L
  46.  
  47. typedef struct RTL_DRIVE_LETTER_CURDIR {        // Size = 0x10
  48.     USHORT          Flags;
  49.     USHORT          Length;
  50.     ULONG           TimeStamp;
  51.     UNICODE_STRING  DosPath;
  52. } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
  53.  
  54. typedef struct _RTL_USER_PROCESS_PARAMETERS {   // Size = 0x290
  55.     ULONG           AllocationSize;
  56.     ULONG           Size;
  57.     ULONG           Flags;
  58.     ULONG           DebugFlags;
  59.     HANDLE          hConsole;
  60.     ULONG           ProcessGroup;
  61.     HANDLE          hStdInput;
  62.     HANDLE          hStdOutput;
  63.     HANDLE          hStdError;
  64.     UNICODE_STRING  CurrentDirectoryName;
  65.     HANDLE          CurrentDirectoryHandle;
  66.     UNICODE_STRING  DllPath;
  67.     UNICODE_STRING  ImagePathName;
  68.     UNICODE_STRING  CommandLine;
  69.     PWSTR           Environment;
  70.     ULONG           StartingPositionLeft;
  71.     ULONG           StartingPositionTop;
  72.     ULONG           Width;
  73.     ULONG           Height;
  74.     ULONG           CharWidth;
  75.     ULONG           CharHeight;
  76.     ULONG           ConsoleTextAttributes;
  77.     ULONG           WindowFlags;
  78.     ULONG           ShowWindowFlags;
  79.     UNICODE_STRING  WindowTitle;
  80.     UNICODE_STRING  DesktopName;
  81.     UNICODE_STRING  ShellInfo;
  82.     UNICODE_STRING  RuntimeInfo;
  83.     RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
  84. } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
  85.  
  86. typedef struct _LDR_MODULE {
  87.         LIST_ENTRY     InLoadOrderModuleList;
  88.         LIST_ENTRY     InMemoryOrderModuleList;
  89.         LIST_ENTRY     InInitializationOrderModuleList;
  90.         PVOID          BaseAddress;
  91.         PVOID          EntryPoint;
  92.         ULONG          SizeOfImage;
  93.         UNICODE_STRING FullDllName;
  94.         UNICODE_STRING BaseDllName;
  95.         ULONG          Flags;
  96.         SHORT          LoadCount;
  97.         SHORT          TlsIndex;
  98.         LIST_ENTRY     HashTableEntry;
  99.         ULONG          TimeDateStamp;
  100. } LDR_MODULE, *PLDR_MODULE;
  101.  
  102. typedef struct _PEB_LDR_DATA {                          // Size = 0x24
  103.     ULONG           Length;                             // 00
  104.     BOOLEAN         Initialized;                        // 04
  105.     PVOID           SsHandle;                           // 08
  106.     LIST_ENTRY      InLoadOrderModuleList;              // 0C
  107.     LIST_ENTRY      InMemoryOrderModuleList;            // 14
  108.     LIST_ENTRY      InInitializationOrderModuleList;    // 1C
  109. //  void *          EntryInProgress;                    // 24
  110. } PEB_LDR_DATA, *PPEB_LDR_DATA;
  111.  
  112. typedef struct _PEB_FREE_BLOCK {  // Size = 8
  113. struct _PEB_FREE_BLOCK *Next;
  114. ULONG Size;
  115. } PEB_FREE_BLOCK, *PPEB_FREE_BLOCK;
  116.  
  117. // Structured Exception Handler
  118. typedef struct _SEH {
  119.     struct _SEH *pNext;
  120.     FARPROC     pfnHandler;
  121. } SEH, *PSEH;
  122.  
  123. #pragma pack(1)
  124.  
  125. // Thread Information Block (FS:[0])
  126. typedef struct _TIB_NT {
  127.     PSEH       pvExcept;             // 00 Head of exception record list
  128.     PVOID      pvStackBase;          // 04
  129.     PVOID      pvStackLimit;         // 08
  130.     PVOID      SubSystemTib;         // 0C
  131.     union {
  132.         PVOID FiberData;             // 10
  133.         DWORD Version;
  134.     };
  135.     PVOID      pvArbitrary;          // 14 Available for application use
  136.     struct _TIB_NT *pTIBSelf;        // 18 Linear address of TIB structure
  137. } TIB_NT, *PTIB_NT;
  138.  
  139. typedef void (*PPEBLOCKROUTINE)(PVOID);
  140.  
  141. // PEB (Process Environment Block) data structure (FS:[0x30])
  142. // Located at addr. 0x7FFDF000
  143. typedef struct _PEB_NT {                                        // Size = 0x1E8
  144.   BOOLEAN                      InheritedAddressSpace;           //000
  145.   BOOLEAN                      ReadImageFileExecOptions;        //001
  146.   BOOLEAN                      BeingDebugged;                   //002
  147.   BOOLEAN                      SpareBool;                       //003 Allocation size
  148.   HANDLE                       Mutant;                          //004
  149.   HINSTANCE                    ImageBaseAddress;                //008 Instance
  150.   PPEB_LDR_DATA                LdrData;                         //00C
  151.   PRTL_USER_PROCESS_PARAMETERS ProcessParameters;               //010
  152.   ULONG                        SubSystemData;                   //014
  153.   HANDLE                       ProcessHeap;                     //018
  154.   KSPIN_LOCK                   FastPebLock;                     //01C
  155.   PPEBLOCKROUTINE              FastPebLockRoutine;              //020
  156.   PPEBLOCKROUTINE              FastPebUnlockRoutine;            //024
  157.   ULONG                        EnvironmentUpdateCount;          //028
  158.   PVOID *                      KernelCallbackTable;             //02C
  159.   PVOID                        EventLogSection;                 //030
  160.   PVOID                        EventLog;                        //034
  161.   PPEB_FREE_BLOCK              FreeList;                        //038
  162.   ULONG                        TlsExpansionCounter;             //03C
  163.   ULONG                        TlsBitmap;                       //040
  164.   LARGE_INTEGER                TlsBitmapBits;                   //044
  165.   PVOID                        ReadOnlySharedMemoryBase;        //04C
  166.   PVOID                        ReadOnlySharedMemoryHeap;        //050
  167.   PVOID *                      ReadOnlyStaticServerData;        //054
  168.   PVOID                        AnsiCodePageData;                //058
  169.   PVOID                        OemCodePageData;                 //05C
  170.   PVOID                        UnicodeCaseTableData;            //060
  171.   ULONG                        NumberOfProcessors;              //064
  172.   LARGE_INTEGER                NtGlobalFlag;                    //068 Address of a local copy
  173.   LARGE_INTEGER                CriticalSectionTimeout;          //070
  174.   ULONG                        HeapSegmentReserve;              //078
  175.   ULONG                        HeapSegmentCommit;               //07C
  176.   ULONG                        HeapDeCommitTotalFreeThreshold;  //080
  177.   ULONG                        HeapDeCommitFreeBlockThreshold;  //084
  178.   ULONG                        NumberOfHeaps;                   //088
  179.   ULONG                        MaximumNumberOfHeaps;            //08C
  180.   PVOID **                     ProcessHeaps;                    //090
  181.   PVOID                        GdiSharedHandleTable;            //094
  182.   PVOID                        ProcessStarterHelper;            //098
  183.   PVOID                        GdiDCAttributeList;              //09C
  184.   KSPIN_LOCK                   LoaderLock;                      //0A0
  185.   ULONG                        OSMajorVersion;                  //0A4
  186.   ULONG                        OSMinorVersion;                  //0A8
  187.   USHORT                       OSBuildNumber;                   //0AC
  188.   USHORT                       OSCSDVersion;                    //0AE
  189.   ULONG                        OSPlatformId;                    //0B0
  190.   ULONG                        ImageSubsystem;                  //0B4
  191.   ULONG                        ImageSubsystemMajorVersion;      //0B8
  192.   ULONG                        ImageSubsystemMinorVersion;      //0BC
  193.   ULONG                        ImageProcessAffinityMask;        //0C0
  194.   ULONG                        GdiHandleBuffer[0x22];           //0C4
  195.   ULONG                        PostProcessInitRoutine;          //14C
  196.   ULONG                        TlsExpansionBitmap;              //150
  197.   UCHAR                        TlsExpansionBitmapBits[0x80];    //154
  198.   ULONG                        SessionId;                       //1D4
  199.   void *                       AppCompatInfo;                   //1D8
  200.   UNICODE_STRING               CSDVersion;                      //1DC
  201. } PEB_NT, *PPEB_NT;
  202.  
  203. // TEB (Thread Environment Block) data structure (FS:[0x18])
  204. // Located at 0x7FFDE000, 0x7FFDD000, ...
  205. typedef struct _TEB_NT {                        // Size = 0xF88
  206.   NT_TIB        Tib;                            //000
  207.   PVOID         EnvironmentPointer;             //01C
  208.   CLIENT_ID     ClientId;                       //020
  209.   HANDLE        ActiveRpcHandle;                //028
  210.   PVOID         ThreadLocalStoragePointer;      //02C
  211.   PPEB_NT       ProcessEnvironmentBlock;        //030 PEB
  212.   ULONG         LastErrorValue;                 //034
  213.   ULONG         CountOfOwnedCriticalSections;   //038
  214.   ULONG         CsrClientThread;                //03C
  215.   ULONG         Win32ThreadInfo;                //040
  216.   UCHAR         Win32ClientInfo[0x7C];          //044
  217.   ULONG         WOW32Reserved;                  //0C0
  218.   ULONG         CurrentLocale;                  //0C4
  219.   ULONG         FpSoftwareStatusRegister;       //0C8
  220.   UCHAR         SystemReserved1[0xD8];          //0CC
  221.   ULONG         Spare1;                         //1A4
  222.   ULONG         ExceptionCode;                  //1A8
  223.   UCHAR         SpareBytes1[0x28];              //1AC
  224.   UCHAR         SystemReserved2[0x28];          //1D4
  225.   UCHAR         GdiTebBatch[0x4E0];             //1FC
  226.   ULONG         GdiRgn;                         //6DC
  227.   ULONG         GdiPen;                         //6E0
  228.   ULONG         GdiBrush;                       //6E4
  229.   CLIENT_ID     RealClientId;                   //6E8
  230.   ULONG         GdiCachedProcessHandle;         //6F0
  231.   ULONG         GdiClientPID;                   //6F4
  232.   ULONG         GdiClientTID;                   //6F8
  233.   ULONG         GdiThreadLocalInfo;             //6FC
  234.   UCHAR         UserReserved[0x14];             //700
  235.   UCHAR         glDispatchTable[0x460];         //714
  236.   UCHAR         glReserved1[0x68];              //B74
  237.   ULONG         glReserved2;                    //BDC
  238.   ULONG         glSectionInfo;                  //BE0
  239.   ULONG         glSection;                      //BE4
  240.   ULONG         glTable;                        //BE8
  241.   ULONG         glCurrentRC;                    //BEC
  242.   ULONG         glContext;                      //BF0
  243.   ULONG         LastStatusValue;                //BF4
  244.   LARGE_INTEGER StaticUnicodeString;            //BF8
  245.   UCHAR         StaticUnicodeBuffer[0x20C];     //C00
  246.   ULONG         DeallocationStack;              //E0C
  247.   UCHAR         TlsSlots[0x100];                //E10
  248.   LARGE_INTEGER TlsLinks;                       //F10
  249.   ULONG         Vdm;                            //F18
  250.   ULONG         ReservedForNtRpc;               //F1C
  251.   LARGE_INTEGER DbgSsReserved;                  //F20
  252.   ULONG         HardErrorsAreDisabled;          //F28
  253.   UCHAR         Instrumentation[0x40];          //F2C
  254.   ULONG         WinSockData;                    //F6C
  255.   ULONG         GdiBatchCount;                  //F70
  256.   ULONG         Spare2;                         //F74
  257.   ULONG         Spare3;                         //F78
  258.   ULONG         Spare4;                         //F7C
  259.   ULONG         ReservedForOle;                 //F80
  260.   ULONG         WaitingOnLoaderLock;            //F84
  261. //  PVOID         StackCommit;
  262. //  PVOID         StackCommitMax;
  263. //  PVOID         StackReserved;
  264. //  PVOID         MessageQueue;
  265. } TEB_NT, *PTEB_NT;
  266.  
  267. #pragma pack()
  268.  
  269. typedef struct _THREAD_BASIC_INFORMATION {
  270.      NTSTATUS  ExitStatus;
  271.      PTIB_NT   TebBaseAddress;
  272.      CLIENT_ID ClientId;
  273.      KAFFINITY AffinityMask;
  274.      KPRIORITY Priority;
  275.      KPRIORITY BasePriority;
  276. } THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
  277.  
  278. #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
  279. #define SystemProcessesAndThreadsInformation    5
  280.  
  281. typedef struct _VM_COUNTERS {
  282.     SIZE_T          PeakVirtualSize;
  283.     SIZE_T          VirtualSize;
  284.     ULONG           PageFaultCount;
  285.     SIZE_T          PeakWorkingSetSize;
  286.     SIZE_T          WorkingSetSize;
  287.     SIZE_T          QuotaPeakPagedPoolUsage;
  288.     SIZE_T          QuotaPagedPoolUsage;
  289.     SIZE_T          QuotaPeakNonPagedPoolUsage;
  290.     SIZE_T          QuotaNonPagedPoolUsage;
  291.     SIZE_T          PagefileUsage;
  292.     SIZE_T          PeakPagefileUsage;
  293. } VM_COUNTERS;
  294.  
  295. typedef struct _SYSTEM_THREAD_INFORMATION {
  296.     LARGE_INTEGER   KernelTime;
  297.     LARGE_INTEGER   UserTime;
  298.     LARGE_INTEGER   CreateTime;
  299.     ULONG                 WaitTime;
  300.     PVOID                 StartAddress;
  301.     CLIENT_ID     ClientId;
  302.     KPRIORITY     Priority;
  303.     KPRIORITY     BasePriority;
  304.     ULONG                 ContextSwitchCount;
  305.     LONG                  State;
  306.     LONG                  WaitReason;
  307. } SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
  308.  
  309. // The size of the SYSTEM_PROCESS_INFORMATION structure is
  310. // different on NT 4 and Win2K.
  311.  
  312. typedef struct _SYSTEM_PROCESS_INFORMATION_NT4 {
  313.     ULONG                 NextEntryDelta;
  314.     ULONG                 ThreadCount;
  315.     ULONG                 Reserved1[6];
  316.     LARGE_INTEGER   CreateTime;
  317.     LARGE_INTEGER   UserTime;
  318.     LARGE_INTEGER   KernelTime;
  319.     UNICODE_STRING  ProcessName;
  320.     KPRIORITY     BasePriority;
  321.     ULONG                 ProcessId;
  322.     ULONG                 InheritedFromProcessId;
  323.     ULONG                 HandleCount;
  324.     ULONG                 Reserved2[2];
  325.     VM_COUNTERS   VmCounters;
  326.     SYSTEM_THREAD_INFORMATION  Threads[1];
  327. } SYSTEM_PROCESS_INFORMATION_NT4, *PSYSTEM_PROCESS_INFORMATION_NT4;
  328.  
  329. /////////////////////// Windows 95 /////////////////////////
  330.  
  331. #pragma pack(1)
  332.  
  333. #define VA_SHARED 0x8000000             // Undocumented flag to allocate shared memory in Win9x
  334.  
  335. // Kernel32 objects (WIN95)
  336. #define WIN95_K32OBJ_SEMAPHORE            0x1
  337. #define WIN95_K32OBJ_EVENT                0x2
  338. #define WIN95_K32OBJ_MUTEX                0x3
  339. #define WIN95_K32OBJ_CRITICAL_SECTION     0x4
  340. #define WIN95_K32OBJ_PROCESS              0x5
  341. #define WIN95_K32OBJ_THREAD               0x6
  342. #define WIN95_K32OBJ_FILE                 0x7
  343. #define WIN95_K32OBJ_CHANGE               0x8
  344. #define WIN95_K32OBJ_CONSOLE              0x9
  345. #define WIN95_K32OBJ_SCREEN_BUFFER        0xA
  346. #define WIN95_K32OBJ_MEM_MAPPED_FILE      0xB
  347. #define WIN95_K32OBJ_SERIAL               0xC
  348. #define WIN95_K32OBJ_DEVICE_IOCTL         0xD
  349. #define WIN95_K32OBJ_PIPE                 0xE
  350. #define WIN95_K32OBJ_MAILSLOT             0xF
  351. #define WIN95_K32OBJ_TOOLHELP_SNAPSHOT    0x10
  352. #define WIN95_K32OBJ_SOCKET               0x11
  353.  
  354. // TIB flags
  355. #define TIBF_WIN32                    0x00000001
  356. #define TIBF_TRAP                     0x00000002
  357.  
  358. // Process Database flags (WIN95)
  359. #define fDebugSingle                  0x00000001  // Set if process is being debugged
  360. #define fCreateProcessEvent           0x00000002  // Set in debugged process after starting
  361. #define fExitProcessEvent             0x00000004  // Might be set in debugged process at exit time
  362. #define fWin16Process                 0x00000008  // 16-bit process
  363. #define fDosProcess                   0x00000010  // DOS process
  364. #define fConsoleProcess               0x00000020  // 32-bit console process
  365. #define fFileApisAreOem               0x00000040  // SetFileAPIsToOEM
  366. #define fNukeProcess                  0x00000080
  367. #define fServiceProcess               0x00000100  // RegisterServiceProcess
  368. #define fLoginScriptHack              0x00000800  // Might be a Novell network login process
  369. #define fSendDllNotifications         0x00200000
  370. #define fDebugEventPending            0x00400000  // e.g. stopped in debugger
  371. #define fNearlyTerminating            0x00800000
  372. #define fFaulted                      0x08000000
  373. #define fTerminating                  0x10000000
  374. #define fTerminated                   0x20000000
  375. #define fInitError                    0x40000000
  376. #define fSignaled                     0x80000000
  377.  
  378. // Thread Database flags (WIN95)
  379. #define fCreateThreadEvent            0x00000001   // Set if thread is being debugged
  380. #define fCancelExceptionAbort         0x00000002
  381. #define fOnTempStack                  0x00000004
  382. #define fGrowableStack                0x00000008
  383. #define fDelaySingleStep              0x00000010
  384. #define fOpenExeAsImmovableFile       0x00000020
  385. #define fCreateSuspended              0x00000040   // CREATE_SUSPENDED flag to CreateProcess()
  386. #define fStackOverflow                0x00000080
  387. #define fNestedCleanAPCs              0x00000100
  388. #define fWasOemNowAnsi                0x00000200   // ANSI/OEM file function
  389. #define fOKToSetThreadOem             0x00000400   // ANSI/OEM file function
  390.  
  391. // TDBX flags (WIN95)
  392. #define WAITEXBIT                     0x00000001
  393. #define WAITACKBIT                    0x00000002
  394. #define SUSPEND_APC_PENDING           0x00000004
  395. #define SUSPEND_TERMINATED            0x00000008
  396. #define BLOCKED_FOR_TERMINATION       0x00000010
  397. #define EMULATE_NPX                   0x00000020
  398. #define WIN32_NPX                     0x00000040
  399. #define EXTENDED_HANDLES              0x00000080
  400. #define FROZEN                        0x00000100
  401. #define DONT_FREEZE                   0x00000200
  402. #define DONT_UNFREEZE                 0x00000400
  403. #define DONT_TRACE                    0x00000800
  404. #define STOP_TRACING                  0x00001000
  405. #define WAITING_FOR_CRST_SAFE         0x00002000
  406. #define CRST_SAFE                     0x00004000
  407. #define BLOCK_TERMINATE_APC           0x00040000
  408.  
  409. // Environment Database
  410. typedef struct _ENVIRONMENT_DATABASE {
  411.     PSTR    pszEnvironment;             //00 Pointer to Process Environment
  412.     DWORD   un1;                        //04 (always 0)
  413.     PSTR    pszCmdLine;                 //08 Pointer to command line
  414.     PSTR    pszCurrDirectory;           //0C Pointer to current directory
  415.     LPSTARTUPINFOA pStartupInfo;        //10 Pointer to STARTUPINFOA struct
  416.     HANDLE  hStdIn;                     //14 Standard Input handle
  417.     HANDLE  hStdOut;                    //18 Standard Output handle
  418.     HANDLE  hStdErr;                    //1C Standard Error handle
  419.     DWORD   un2;                        //20 (always 1)
  420.     DWORD   InheritConsole;             //24 Inherit console from parent
  421.     DWORD   BreakType;                  //28 Handle console events (like CTRL+C)
  422.     DWORD   BreakSem;                   //2C Pointer to K32OBJ_SEMAPHORE
  423.     DWORD   BreakEvent;                 //30 Pointer to K32OBJ_EVENT
  424.     DWORD   BreakThreadID;              //34 Pointer to K32OBJ_THREAD
  425.     DWORD   BreakHandlers;              //38 Pointer to list of installed console control handlers
  426. } EDB, *PEDB;
  427.  
  428. // Handle Table Entry
  429. typedef struct _HANDLE_TABLE_ENTRY {
  430.     DWORD  flags;                   // Valid flags depend on what type of object this is
  431.     PVOID  pObject;                 // Pointer to the object that the handle refers to
  432. } HANDLE_TABLE_ENTRY, *PHANDLE_TABLE_ENTRY;
  433.  
  434. // Handle Table
  435. typedef struct _HANDLE_TABLE {
  436.     DWORD cEntries;                 // Max number of handles in table
  437.     HANDLE_TABLE_ENTRY array[1];    // An array (number is given by cEntries)
  438. } HANDLE_TABLE, *PHANDLE_TABLE;
  439.  
  440.  
  441. typedef struct _IMTE
  442. {
  443.     DWORD           un1;            // 00h
  444.     PIMAGE_NT_HEADERS   pNTHdr;     // 04h
  445.     DWORD           un2;            // 08h
  446.     PSTR            pszFileName;    // 0Ch
  447.     PSTR            pszModName;     // 10h
  448.     WORD            cbFileName;     // 14h
  449.     WORD            cbModName;      // 16h
  450.     DWORD           un3;            // 18h
  451.     DWORD           cSections;      // 1Ch
  452.     DWORD           un5;            // 20h
  453.     DWORD           baseAddress;    // 24h
  454.     WORD            hModule16;      // 28h
  455.     WORD            cUsage;         // 2Ah
  456.     DWORD           un7;            // 2Ch
  457.     PSTR            pszFileName2;   // 30h
  458.     WORD            cbFileName2;    // 34h
  459.     PSTR            pszModName2;    // 36h
  460.     WORD            cbModName2;     // 3Ah
  461. } IMTE, *PIMTE;
  462.  
  463. // Thread Information Block (FS:[0x18])
  464. typedef struct _TIB95 {         // Size = 0x34
  465.     PSEH    pvExcept;           // 00 Pointer to head of structured exception handling chain
  466.     PVOID   pvStackUserTop;     // 04 Max. address for stack
  467.     PVOID   pvStackUserBase;    // 08 Lowest page aligned addr. of stack
  468.     WORD    pvTDB;              // 0C Ptr to win-16 task database
  469.     WORD    pvThunksSS;         // 0E SS selector used for thunking to 16 bits
  470.     DWORD   SelmanList;         // 10 Pointer to selector manager list
  471.     PVOID   pvArbitrary;        // 14 Available for application use
  472.     struct _TIB95 *pTIBSelf;    // 18 Linear address of TIB structure
  473.     WORD    TIBFlags;           // 1C TIBF_WIN32 = 1, TIBF_TRAP = 2
  474.     WORD    Win16MutexCount;    // 1E Win16Lock
  475.     DWORD   DebugContext;       // 20 Pointer to debug context structure
  476.     DWORD   pCurrentPriority;   // 24 Pointer to DWORD containing current priority level
  477.     DWORD   pvQueue;            // 28 Message Queue selector
  478.     PVOID*  pvTLSArray;         // 2C Thread Local Storage (TLS) array
  479.     PVOID*  pProcess;           // 30 Pointer to owning process database (PDB)
  480. } TIB95, *PTIB95;
  481.  
  482. // Thread Database Extension
  483. typedef struct _TDBX95 {
  484.     DWORD  ptdb;              // 00 TDB
  485.     DWORD  ppdb;              // 04 PDB
  486.     DWORD  ContextHandle;     // 08 R0 memory context
  487.     DWORD  un1;               // 0C
  488.     DWORD  TimeOutHandle;     // 10
  489.     DWORD  WakeParam;         // 14
  490.     DWORD  BlockHandle;       // 18 R0 semaphore on which thread will wait inside VWIN32
  491.     DWORD  BlockState;        // 1C
  492.     DWORD  SuspendCount;      // 20 Number of times SuspendThread() was called
  493.     DWORD  SuspendHandle;     // 24
  494.     DWORD  MustCompleteCount; // 28 Count of EnterMustComplete's minus LeaveMustComplete's
  495.     DWORD  WaitExFlags;       // 2C Flags
  496.     DWORD  SyncWaitCount;     // 30
  497.     DWORD  QueuedSyncFuncs;   // 34
  498.     DWORD  UserAPCList;       // 38
  499.     DWORD  KernAPCList;       // 3C
  500.     DWORD  pPMPSPSelector;    // 40 Pointer to protected mode PSP selector
  501.     DWORD  BlockedOnID;       // 44
  502.     DWORD  un2[7];            // 48
  503.     DWORD  TraceRefData;      // 64
  504.     DWORD  TraceCallBack;     // 68
  505.     DWORD  TraceEventHandle;  // 6C
  506.     WORD   TraceOutLastCS;    // 70
  507.     WORD   K16TDB;            // 72 Win16 TDB selector
  508.     WORD   K16PDB;            // 74 Win16 PSP selector
  509.     WORD   DosPDBSeg;         // 76 Real mode segment value of PSP
  510.     WORD   ExceptionCount;    // 78
  511. } TDBX95, *PTDBX95;
  512.  
  513. // Kernel32 objects (WIN98)
  514. #define WIN98_K32OBJ_SEMAPHORE            0x1
  515. #define WIN98_K32OBJ_EVENT                0x2
  516. #define WIN98_K32OBJ_MUTEX                0x3
  517. #define WIN98_K32OBJ_CRITICAL_SECTION     0x4
  518. #define WIN98_K32OBJ_CHANGE               0x5
  519. #define WIN98_K32OBJ_PROCESS              0x6
  520. #define WIN98_K32OBJ_THREAD               0x7
  521. #define WIN98_K32OBJ_FILE                 0x8
  522. #define WIN98_K32OBJ_CONSOLE              0x9
  523. #define WIN98_K32OBJ_SCREEN_BUFFER        0xA
  524. #define WIN98_K32OBJ_MAILSLOT             0xB
  525. #define WIN98_K32OBJ_SERIAL               0xC
  526. #define WIN98_K32OBJ_MEM_MAPPED_FILE      0xD
  527. #define WIN98_K32OBJ_PIPE                 0xE
  528. #define WIN98_K32OBJ_DEVICE_IOCTL         0xF
  529. #define WIN98_K32OBJ_TOOLHELP_SNAPSHOT    0x10
  530. #define WIN98_K32OBJ_SOCKET               0x11
  531.  
  532. typedef struct _TDBX98 TDBX98;
  533. typedef struct _PDB98  PDB98;
  534.  
  535. // Thread Information Block (FS:[0x18])
  536. typedef struct _TIB98 {        // Size = 0x38
  537.     PSEH    pvExcept;          // 00 Head of exception record list
  538.     PVOID   pvStackUserTop;    // 04 Top of user stack
  539.     PVOID   pvStackUserBase;   // 08 Base of user stack
  540.     WORD    pvTDB;             // 0C Ptr to win-16 task database
  541.     WORD    pvThunksSS;        // 0E SS selector used for thunking to 16 bits
  542.     DWORD   SelmanList;        // 10 Pointer to selector manager list
  543.     PVOID   pvArbitrary;       // 14 Available for application use
  544.     struct _TIB98 *pTIBSelf;   // 18 Linear address of TIB structure
  545.     WORD    TIBFlags;          // 1C TIBF_WIN32 = 1, TIBF_TRAP = 2
  546.     WORD    Win16MutexCount;   // 1E Win16Lock
  547.     DWORD   DebugContext;      // 20 Pointer to debug context structure
  548.     DWORD   pCurrentPriority;  // 24 Pointer to DWORD containing current priority level
  549.     DWORD   pvQueue;           // 28 Message Queue selector
  550.     PVOID   *pvTLSArray;       // 2C Thread Local Storage (TLS) array
  551.     PVOID   *pProcess;         // 30 Pointer to owning process database (PDB)
  552.     DWORD   Unknown;           // 34 Pointer to ???
  553. } TIB98, *PTIB98;
  554.  
  555. // Thread database (FS:[0x18] - 0x8)
  556. typedef struct _TDB98 {        // Size = 0x228 (from Kernel32)
  557.     WORD    Type;              // 00 K32 object type
  558.     WORD    cReference;        // 02 Reference count
  559.     DWORD   pSomeEvent;        // 04 K32 event object used when someone waits on the thread object
  560.     TIB98   tib;               // 08 Thread information block (TIB)
  561.     DWORD   Unknown;           // 40
  562.     DWORD   Flags;             // 44 Flags
  563.     DWORD   TerminationStatus; // 48 Exit code
  564.     WORD    TIBSelector;       // 4C Selector used in FS to point to TIB
  565.     WORD    EmulatorSelector;  // 4E Memory block for saving x87 state
  566.     DWORD   cHandles;          // 50 Handle count
  567.     DWORD   Ring0Thread;       // 54 R0 thread control block (TCB)
  568.     TDBX98  *pTDBX;            // 58 R0 thread database extension (TDBX)
  569.     DWORD   un1[109];          // 5C
  570.     DWORD   APISuspendCount;   // 210 Count of SuspendThread's minus ResumeThread's
  571. } TDB98, *PTDB98;
  572.  
  573. // Thread database extension
  574. typedef struct _TDBX98 {
  575.     DWORD  un0;                // 00
  576.     TDB98  *ptdb;              // 04 R3 thread database
  577.     PDB98  *ppdb;              // 08 R3 process database
  578.     DWORD  ContextHandle;      // 0C R0 memory context
  579.     DWORD  Ring0Thread;        // 10 R0 thread control block [TCB *]
  580.     DWORD  WaitNodeList;       // 14 Anchor of things we're waiting on  [WAITNODE *]
  581.     DWORD  WaitFlags;          // 18 Blocking flags
  582.     DWORD  un1;                // 1C
  583.     DWORD  TimeOutHandle;      // 20
  584.     DWORD  WakeParam;          // 24
  585.     DWORD  BlockHandle;        // 28 R0 semaphore on which thread will wait inside VWIN32
  586.     DWORD  BlockState;         // 2C
  587.     DWORD  SuspendCount;       // 30
  588.     DWORD  SuspendHandle;      // 34
  589.     DWORD  MustCompleteCount;  // 38 Count of EnterMustComplete's minus LeaveMustComplete's
  590.     DWORD  WaitExFlags;        // 3C Flags
  591.     DWORD  SyncWaitCount;      // 40
  592.     DWORD  QueuedSyncFuncs;    // 44
  593.     DWORD  UserAPCList;        // 48
  594.     DWORD  KernAPCList;        // 4C
  595.     DWORD  pPMPSPSelector;     // 50
  596.     DWORD  BlockedOnID;        // 54
  597. } TDBX98, *PTDBX98;
  598.  
  599. /////////////////////// Windows Me /////////////////////////
  600.  
  601. typedef TIB98   TIBME;
  602. typedef TIBME   *PTIBME;
  603.  
  604. typedef struct _TDBME {        // Size = 0x228 (from Kernel32)
  605.     WORD    Type;              // 00 K32 object type
  606.     WORD    cReference;        // 02 Reference count
  607.     DWORD   pSomeEvent;        // 04 K32 event object used when someone waits on the thread object
  608.     TIB98   tib;               // 08 Thread information block (TIB)
  609.     DWORD   Unknown;           // 40
  610.     DWORD   Unknown2;          // 44
  611.     WORD    TIBSelector;       // 46 Selector used in FS to point to TIB
  612.     DWORD   TerminationStatus; // 48 Exit code
  613.     DWORD   Flags;             // 4C Flags
  614.     DWORD   cHandles;          // 50 Handle count
  615.     DWORD   Ring0Thread;       // 54 R0 thread control block (TCB)
  616.     DWORD   Unknown3;          // 58 Selector for ???
  617.     DWORD   un1[109];          // 5C
  618.     DWORD   APISuspendCount;   // 210 Count of SuspendThread's minus ResumeThread's
  619. } TDBME, *PTDBME;
  620.  
  621. #pragma pack()
  622.  
  623. #endif // __STRUCT_H__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement