From 436eda30711adf4b13a7c056bb55d99a2304aeae Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Tue, 25 Nov 2003 00:42:26 +0000
Subject: [PATCH] Removed task.h.

---
 dlls/kernel/kernel_main.c |   1 -
 dlls/kernel/ne_module.c   |   1 -
 dlls/kernel/ne_segment.c  |   1 -
 dlls/kernel/resource16.c  |   1 -
 dlls/kernel/task.c        |  29 +++++--
 dlls/kernel/thunk.c       |   1 -
 dlls/kernel/wowthunk.c    |   2 +-
 dlls/user/user16.c        |   1 -
 dlls/winedos/int21.c      |   1 -
 dlls/winedos/int31.c      |   1 -
 dlls/winedos/interrupts.c |   1 -
 dlls/winedos/module.c     |   1 -
 dlls/winedos/vxd.c        |   1 -
 files/drive.c             |   1 -
 include/module.h          |  36 +++++++-
 include/task.h            | 170 --------------------------------------
 include/wine/winbase16.h  |  88 ++++++++++++++++++++
 17 files changed, 144 insertions(+), 193 deletions(-)
 delete mode 100644 include/task.h

diff --git a/dlls/kernel/kernel_main.c b/dlls/kernel/kernel_main.c
index 78717c042f4..ed384b208b3 100644
--- a/dlls/kernel/kernel_main.c
+++ b/dlls/kernel/kernel_main.c
@@ -40,7 +40,6 @@
 #include "global.h"
 #include "miscemu.h"
 #include "module.h"
-#include "task.h"
 #include "thread.h"
 #include "stackframe.h"
 #include "wincon.h"
diff --git a/dlls/kernel/ne_module.c b/dlls/kernel/ne_module.c
index b71e72d0e9f..85634e9e18e 100644
--- a/dlls/kernel/ne_module.c
+++ b/dlls/kernel/ne_module.c
@@ -43,7 +43,6 @@
 #include "toolhelp.h"
 #include "global.h"
 #include "file.h"
-#include "task.h"
 #include "builtin16.h"
 #include "stackframe.h"
 #include "excpt.h"
diff --git a/dlls/kernel/ne_segment.c b/dlls/kernel/ne_segment.c
index 2633300af1b..2e3a5827959 100644
--- a/dlls/kernel/ne_segment.c
+++ b/dlls/kernel/ne_segment.c
@@ -37,7 +37,6 @@
 #include "wownt32.h"
 #include "wine/library.h"
 #include "global.h"
-#include "task.h"
 #include "file.h"
 #include "module.h"
 #include "stackframe.h"
diff --git a/dlls/kernel/resource16.c b/dlls/kernel/resource16.c
index 85455881ef9..0052bd40cbd 100644
--- a/dlls/kernel/resource16.c
+++ b/dlls/kernel/resource16.c
@@ -36,7 +36,6 @@
 #include "wine/winuser16.h"
 #include "wine/unicode.h"
 #include "module.h"
-#include "task.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(resource);
diff --git a/dlls/kernel/task.c b/dlls/kernel/task.c
index c373aebf090..2616ec00f27 100644
--- a/dlls/kernel/task.c
+++ b/dlls/kernel/task.c
@@ -44,7 +44,6 @@
 #include "winternl.h"
 #include "wine/server.h"
 #include "stackframe.h"
-#include "task.h"
 #include "thread.h"
 #include "toolhelp.h"
 #include "kernel_private.h"
@@ -55,9 +54,27 @@ WINE_DEFAULT_DEBUG_CHANNEL(task);
 WINE_DECLARE_DEBUG_CHANNEL(relay);
 WINE_DECLARE_DEBUG_CHANNEL(toolhelp);
 
+#include <pshpack1.h>
+
+/* Segment containing MakeProcInstance() thunks */
+typedef struct
+{
+    WORD  next;       /* Selector of next segment */
+    WORD  magic;      /* Thunks signature */
+    WORD  unused;
+    WORD  free;       /* Head of the free list */
+    WORD  thunks[4];  /* Each thunk is 4 words long */
+} THUNKS;
+
+#include <poppack.h>
+
+#define THUNK_MAGIC  ('P' | ('T' << 8))
+
   /* Min. number of thunks allocated when creating a new segment */
 #define MIN_THUNKS  32
 
+#define TDB_MAGIC    ('T' | ('D' << 8))
+
 static THHOOK DefaultThhook;
 THHOOK *pThhook = &DefaultThhook;
 
@@ -183,8 +200,8 @@ static SEGPTR TASK_AllocThunk(void)
 
     if (!(pTask = TASK_GetCurrent())) return 0;
     sel = pTask->hCSAlias;
-    pThunk = &pTask->thunks;
-    base = (int)pThunk - (int)pTask;
+    pThunk = (THUNKS *)&pTask->thunks;
+    base = (char *)pThunk - (char *)pTask;
     while (!pThunk->free)
     {
         sel = pThunk->next;
@@ -218,8 +235,8 @@ static BOOL TASK_FreeThunk( SEGPTR thunk )
 
     if (!(pTask = TASK_GetCurrent())) return 0;
     sel = pTask->hCSAlias;
-    pThunk = &pTask->thunks;
-    base = (int)pThunk - (int)pTask;
+    pThunk = (THUNKS *)&pTask->thunks;
+    base = (char *)pThunk - (char *)pTask;
     while (sel && (sel != HIWORD(thunk)))
     {
         sel = pThunk->next;
@@ -282,7 +299,7 @@ static TDB *TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cm
 
       /* Create the thunks block */
 
-    TASK_CreateThunks( hTask, (int)&pTask->thunks - (int)pTask, 7 );
+    TASK_CreateThunks( hTask, (char *)&pTask->thunks - (char *)pTask, 7 );
 
       /* Copy the module name */
 
diff --git a/dlls/kernel/thunk.c b/dlls/kernel/thunk.c
index 816be2ebcc0..be128711587 100644
--- a/dlls/kernel/thunk.c
+++ b/dlls/kernel/thunk.c
@@ -43,7 +43,6 @@
 #include "flatthunk.h"
 #include "module.h"
 #include "stackframe.h"
-#include "task.h"
 #include "kernel_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(thunk);
diff --git a/dlls/kernel/wowthunk.c b/dlls/kernel/wowthunk.c
index 64e479f0ce8..d5fedb602ba 100644
--- a/dlls/kernel/wowthunk.c
+++ b/dlls/kernel/wowthunk.c
@@ -33,8 +33,8 @@
 #include "winreg.h"
 #include "winternl.h"
 #include "file.h"
-#include "task.h"
 #include "miscemu.h"
+#include "module.h"
 #include "stackframe.h"
 #include "kernel_private.h"
 #include "wine/exception.h"
diff --git a/dlls/user/user16.c b/dlls/user/user16.c
index 5adcb06e1a4..ba017201751 100644
--- a/dlls/user/user16.c
+++ b/dlls/user/user16.c
@@ -24,7 +24,6 @@
 #include "windef.h"
 #include "winbase.h"
 #include "wownt32.h"
-#include "task.h"
 #include "user.h"
 #include "win.h"
 #include "winproc.h"
diff --git a/dlls/winedos/int21.c b/dlls/winedos/int21.c
index 899cad487da..488bad8ad7c 100644
--- a/dlls/winedos/int21.c
+++ b/dlls/winedos/int21.c
@@ -38,7 +38,6 @@
 #include "wine/winbase16.h"
 #include "dosexe.h"
 #include "file.h"
-#include "task.h"
 #include "winerror.h"
 #include "winuser.h"
 #include "wine/unicode.h"
diff --git a/dlls/winedos/int31.c b/dlls/winedos/int31.c
index 70602bda4dd..36f99994ae5 100644
--- a/dlls/winedos/int31.c
+++ b/dlls/winedos/int31.c
@@ -27,7 +27,6 @@
 #include "winbase.h"
 #include "wine/winbase16.h"
 #include "wownt32.h"
-#include "task.h"
 #include "dosexe.h"
 
 #include "excpt.h"
diff --git a/dlls/winedos/interrupts.c b/dlls/winedos/interrupts.c
index bddbeda7d78..c4271e69c43 100644
--- a/dlls/winedos/interrupts.c
+++ b/dlls/winedos/interrupts.c
@@ -25,7 +25,6 @@
 #include "wine/winbase16.h"
 
 #include "thread.h"
-#include "task.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(int);
 WINE_DECLARE_DEBUG_CHANNEL(relay);
diff --git a/dlls/winedos/module.c b/dlls/winedos/module.c
index 7d91bf79891..0326082150b 100644
--- a/dlls/winedos/module.c
+++ b/dlls/winedos/module.c
@@ -43,7 +43,6 @@
 #include "wingdi.h"
 #include "winuser.h"
 #include "winerror.h"
-#include "task.h"
 #include "wine/debug.h"
 #include "dosexe.h"
 #include "dosvm.h"
diff --git a/dlls/winedos/vxd.c b/dlls/winedos/vxd.c
index 614517a440b..005f6d7e2da 100644
--- a/dlls/winedos/vxd.c
+++ b/dlls/winedos/vxd.c
@@ -42,7 +42,6 @@
 #include "wine/winbase16.h"
 #include "wine/winuser16.h"
 #include "dosexe.h"
-#include "task.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(vxd);
diff --git a/files/drive.c b/files/drive.c
index 2a549dab8ad..8ffbb37e60b 100644
--- a/files/drive.c
+++ b/files/drive.c
@@ -69,7 +69,6 @@
 #include "ntddcdrm.h"
 #include "drive.h"
 #include "file.h"
-#include "task.h"
 #include "wine/unicode.h"
 #include "wine/library.h"
 #include "wine/server.h"
diff --git a/include/module.h b/include/module.h
index d6af15ab27d..520b695582b 100644
--- a/include/module.h
+++ b/include/module.h
@@ -98,6 +98,25 @@ typedef struct
                          /* of segment in memory */
 } SEGTABLEENTRY;
 
+
+  /* THHOOK Kernel Data Structure */
+typedef struct _THHOOK
+{
+    HANDLE16   hGlobalHeap;         /* 00 (handle BURGERMASTER) */
+    WORD       pGlobalHeap;         /* 02 (selector BURGERMASTER) */
+    HMODULE16  hExeHead;            /* 04 hFirstModule */
+    HMODULE16  hExeSweep;           /* 06 (unused) */
+    HANDLE16   TopPDB;              /* 08 (handle of KERNEL PDB) */
+    HANDLE16   HeadPDB;             /* 0A (first PDB in list) */
+    HANDLE16   TopSizePDB;          /* 0C (unused) */
+    HTASK16    HeadTDB;             /* 0E hFirstTask */
+    HTASK16    CurTDB;              /* 10 hCurrentTask */
+    HTASK16    LoadTDB;             /* 12 (unused) */
+    HTASK16    LockTDB;             /* 14 hLockedTask */
+} THHOOK;
+
+extern THHOOK *pThhook;
+
 /* Resource types */
 
 #define NE_SEG_TABLE(pModule) \
@@ -132,7 +151,7 @@ enum binary_type
 extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
 extern enum binary_type MODULE_GetBinaryType( HANDLE hfile );
 
-/* loader/ne/module.c */
+/* ne_module.c */
 extern NE_MODULE *NE_GetPtr( HMODULE16 hModule );
 extern WORD NE_GetOrdinal( HMODULE16 hModule, const char *name );
 extern FARPROC16 WINAPI NE_GetEntryPoint( HMODULE16 hModule, WORD ordinal );
@@ -141,10 +160,10 @@ extern BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset );
 extern HANDLE NE_OpenFile( NE_MODULE *pModule );
 extern DWORD NE_StartTask(void);
 
-/* loader/ne/resource.c */
+/* resource16.c */
 extern HGLOBAL16 WINAPI NE_DefResourceHandler(HGLOBAL16,HMODULE16,HRSRC16);
 
-/* loader/ne/segment.c */
+/* ne_segment.c */
 extern BOOL NE_LoadSegment( NE_MODULE *pModule, WORD segnum );
 extern BOOL NE_LoadAllSegments( NE_MODULE *pModule );
 extern BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum );
@@ -154,7 +173,16 @@ extern void NE_InitializeDLLs( HMODULE16 hModule );
 extern void NE_DllProcessAttach( HMODULE16 hModule );
 extern void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code );
 
-/* loader/loadorder.c */
+/* task.c */
+extern void TASK_CreateMainTask(void);
+extern HTASK16 TASK_SpawnTask( NE_MODULE *pModule, WORD cmdShow,
+                               LPCSTR cmdline, BYTE len, HANDLE *hThread );
+extern void TASK_ExitTask(void);
+extern HTASK16 TASK_GetTaskFromThread( DWORD thread );
+extern TDB *TASK_GetCurrent(void);
+extern void TASK_InstallTHHook( THHOOK *pNewThook );
+
+/* loadorder.c */
 extern void MODULE_GetLoadOrderW( enum loadorder_type plo[], const WCHAR *app_name,
                                   const WCHAR *path, BOOL win32 );
 extern void MODULE_GetLoadOrderA( enum loadorder_type plo[], const WCHAR *app_name,
diff --git a/include/task.h b/include/task.h
deleted file mode 100644
index 3003d867a91..00000000000
--- a/include/task.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Task definitions
- *
- * Copyright 1995 Alexandre Julliard
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __WINE_TASK_H
-#define __WINE_TASK_H
-
-#include <windef.h>
-#include <wine/windef16.h>
-
-#include <pshpack1.h>
-
-  /* Process database (i.e. a normal DOS PSP) */
-
-typedef struct
-{
-    WORD      int20;                   /* 00 int 20h instruction */
-    WORD      nextParagraph;           /* 02 Segment of next paragraph */
-    BYTE      reserved1;
-    BYTE      dispatcher[5];           /* 05 Long call to DOS */
-    FARPROC16 savedint22 WINE_PACKED;  /* 0a Saved int 22h handler */
-    FARPROC16 savedint23 WINE_PACKED;  /* 0e Saved int 23h handler */
-    FARPROC16 savedint24 WINE_PACKED;  /* 12 Saved int 24h handler */
-    WORD      parentPSP;               /* 16 Selector of parent PSP */
-    BYTE      fileHandles[20];         /* 18 Open file handles */
-    HANDLE16  environment;             /* 2c Selector of environment */
-    DWORD     saveStack;               /* 2e SS:SP on last int21 call */
-    WORD      nbFiles;                 /* 32 Number of file handles */
-    SEGPTR    fileHandlesPtr;          /* 34 Pointer to file handle table */
-    HANDLE16  hFileHandles;            /* 38 Handle to fileHandlesPtr */
-    WORD      reserved3[17];
-    BYTE      fcb1[16];                /* 5c First FCB */
-    BYTE      fcb2[20];                /* 6c Second FCB */
-    BYTE      cmdLine[128];            /* 80 Command-line (first byte is len)*/
-    BYTE      padding[16];             /* Some apps access beyond the end of the cmd line */
-} PDB16;
-
-
-  /* Segment containing MakeProcInstance() thunks */
-typedef struct
-{
-    WORD  next;       /* Selector of next segment */
-    WORD  magic;      /* Thunks signature */
-    WORD  unused;
-    WORD  free;       /* Head of the free list */
-    WORD  thunks[4];  /* Each thunk is 4 words long */
-} THUNKS;
-
-#define THUNK_MAGIC  ('P' | ('T' << 8))
-
-struct _TEB;
-struct _WSINFO;
-struct _NE_MODULE;
-
-  /* signal proc typedef */
-typedef void (CALLBACK *USERSIGNALPROC)(HANDLE16, UINT16, UINT16,
-                                        HINSTANCE16, HQUEUE16);
-
-  /* Task database. See 'Windows Internals' p. 226.
-   * Note that 16-bit OLE 2 libs like to read it directly
-   * so we have to keep entry offsets as they are.
-   */
-typedef struct _TDB
-{
-    HTASK16   hNext;                      /* 00 Selector of next TDB */
-    DWORD     ss_sp WINE_PACKED;          /* 02 Stack pointer of task */
-    WORD      nEvents;                    /* 06 Events for this task */
-    INT16     priority;                   /* 08 Task priority, -32..15 */
-    WORD      unused1;                    /* 0a */
-    HTASK16   hSelf;                      /* 0c Selector of this TDB */
-    HANDLE16  hPrevInstance;              /* 0e Previous instance of module */
-    DWORD     unused2;                    /* 10 */
-    WORD      ctrlword8087;               /* 14 80x87 control word */
-    WORD      flags;                      /* 16 Task flags */
-    UINT16    error_mode;                 /* 18 Error mode (see SetErrorMode)*/
-    WORD      version;                    /* 1a Expected Windows version */
-    HANDLE16  hInstance;                  /* 1c Instance handle for task */
-    HMODULE16 hModule;                    /* 1e Module handle */
-    HQUEUE16  hQueue;                     /* 20 Selector of task queue */
-    HTASK16   hParent;                    /* 22 Selector of TDB of parent */
-    WORD      signal_flags;               /* 24 Flags for signal handler */
-    FARPROC16 sighandler WINE_PACKED;     /* 26 Signal handler */
-    FARPROC16 userhandler WINE_PACKED;    /* 2a USER signal handler */
-    FARPROC16 discardhandler WINE_PACKED; /* 2e Handler for GlobalNotify() */
-    FARPROC16 int0 WINE_PACKED;           /* 32 int 0 (divide by 0) handler */
-    FARPROC16 int2 WINE_PACKED;           /* 36 int 2 (NMI) handler */
-    FARPROC16 int4 WINE_PACKED;           /* 3a int 4 (INTO) handler */
-    FARPROC16 int6 WINE_PACKED;           /* 3e int 6 (invalid opc) handler */
-    FARPROC16 int7 WINE_PACKED;           /* 42 int 7 (coprocessor) handler */
-    FARPROC16 int3e WINE_PACKED;          /* 46 int 3e (80x87 emu) handler */
-    FARPROC16 int75 WINE_PACKED;          /* 4a int 75 (80x87 error) handler */
-    DWORD     compat_flags WINE_PACKED;   /* 4e Compatibility flags */
-    BYTE      unused4[2];                 /* 52 */
-    struct _TEB *teb;                     /* 54 Pointer to thread database */
-    BYTE      unused5[8];                 /* 58 */
-    HANDLE16  hPDB;                       /* 60 Selector of PDB (i.e. PSP) */
-    SEGPTR    dta WINE_PACKED;            /* 62 Current DTA */
-    BYTE      curdrive;                   /* 66 Current drive */
-    BYTE      curdir[65];                 /* 67 Current directory */
-    WORD      nCmdShow;                   /* a8 cmdShow parameter to WinMain */
-    HTASK16   hYieldTo;                   /* aa Next task to schedule */
-    DWORD     dlls_to_init;               /* ac Ptr to DLLs to initialize */
-    HANDLE16  hCSAlias;                   /* b0 Code segment for this TDB */
-    THUNKS    thunks WINE_PACKED;         /* b2 Make proc instance thunks */
-    WORD      more_thunks[6*4];           /* c2 Space for 6 more thunks */
-    BYTE      module_name[8];             /* f2 Module name for task */
-    WORD      magic;                      /* fa TDB signature */
-    HANDLE    hEvent;                     /* fc scheduler event handle */
-    PDB16     pdb;                        /* 100 PDB for this task */
-} TDB;
-
-#define TDB_MAGIC    ('T' | ('D' << 8))
-
-  /* TDB flags */
-#define TDBF_WINOLDAP   0x0001
-#define TDBF_OS2APP     0x0008
-#define TDBF_WIN32      0x0010
-
-  /* Windows 3.1 USER signals */
-#define USIG16_TERMINATION	0x0020
-#define USIG16_DLL_LOAD		0x0040
-#define USIG16_DLL_UNLOAD	0x0080
-#define USIG16_GPF		0x0666
-
-
-  /* THHOOK Kernel Data Structure */
-typedef struct _THHOOK
-{
-    HANDLE16   hGlobalHeap;         /* 00 (handle BURGERMASTER) */
-    WORD       pGlobalHeap;         /* 02 (selector BURGERMASTER) */
-    HMODULE16  hExeHead;            /* 04 hFirstModule */
-    HMODULE16  hExeSweep;           /* 06 (unused) */
-    HANDLE16   TopPDB;              /* 08 (handle of KERNEL PDB) */
-    HANDLE16   HeadPDB;             /* 0A (first PDB in list) */
-    HANDLE16   TopSizePDB;          /* 0C (unused) */
-    HTASK16    HeadTDB;             /* 0E hFirstTask */
-    HTASK16    CurTDB;              /* 10 hCurrentTask */
-    HTASK16    LoadTDB;             /* 12 (unused) */
-    HTASK16    LockTDB;             /* 14 hLockedTask */
-} THHOOK;
-
-#include <poppack.h>
-
-extern THHOOK *pThhook;
-
-extern void TASK_CreateMainTask(void);
-extern HTASK16 TASK_SpawnTask( struct _NE_MODULE *pModule, WORD cmdShow,
-                               LPCSTR cmdline, BYTE len, HANDLE *hThread );
-extern void TASK_ExitTask(void);
-extern HTASK16 TASK_GetTaskFromThread( DWORD thread );
-extern TDB *TASK_GetCurrent(void);
-extern void TASK_InstallTHHook( THHOOK *pNewThook );
-
-#endif /* __WINE_TASK_H */
diff --git a/include/wine/winbase16.h b/include/wine/winbase16.h
index 6ec65ce7262..213fa41f1a9 100644
--- a/include/wine/winbase16.h
+++ b/include/wine/winbase16.h
@@ -27,6 +27,94 @@
 #include <wine/library.h>
 
 #include <pshpack1.h>
+
+/* Process database (i.e. a normal DOS PSP) */
+typedef struct
+{
+    WORD      int20;            /* 00 int 20h instruction */
+    WORD      nextParagraph;    /* 02 Segment of next paragraph */
+    BYTE      reserved1;
+    BYTE      dispatcher[5];    /* 05 Long call to DOS */
+    FARPROC16 savedint22;       /* 0a Saved int 22h handler */
+    FARPROC16 savedint23;       /* 0e Saved int 23h handler */
+    FARPROC16 savedint24;       /* 12 Saved int 24h handler */
+    WORD      parentPSP;        /* 16 Selector of parent PSP */
+    BYTE      fileHandles[20];  /* 18 Open file handles */
+    HANDLE16  environment;      /* 2c Selector of environment */
+    DWORD     saveStack;        /* 2e SS:SP on last int21 call */
+    WORD      nbFiles;          /* 32 Number of file handles */
+    SEGPTR    fileHandlesPtr;   /* 34 Pointer to file handle table */
+    HANDLE16  hFileHandles;     /* 38 Handle to fileHandlesPtr */
+    WORD      reserved3[17];
+    BYTE      fcb1[16];         /* 5c First FCB */
+    BYTE      fcb2[20];         /* 6c Second FCB */
+    BYTE      cmdLine[128];     /* 80 Command-line (first byte is len)*/
+    BYTE      padding[16];      /* Some apps access beyond the end of the cmd line */
+} PDB16;
+
+/* Task database. See 'Windows Internals' p. 226.
+ * Note that 16-bit OLE 2 libs like to read it directly
+ * so we have to keep entry offsets as they are.
+ */
+typedef struct _TDB
+{
+    HTASK16   hNext;              /* 00 Selector of next TDB */
+    DWORD     ss_sp;              /* 02 Stack pointer of task */
+    WORD      nEvents;            /* 06 Events for this task */
+    INT16     priority;           /* 08 Task priority, -32..15 */
+    WORD      unused1;            /* 0a */
+    HTASK16   hSelf;              /* 0c Selector of this TDB */
+    HANDLE16  hPrevInstance;      /* 0e Previous instance of module */
+    DWORD     unused2;            /* 10 */
+    WORD      ctrlword8087;       /* 14 80x87 control word */
+    WORD      flags;              /* 16 Task flags */
+    UINT16    error_mode;         /* 18 Error mode (see SetErrorMode)*/
+    WORD      version;            /* 1a Expected Windows version */
+    HANDLE16  hInstance;          /* 1c Instance handle for task */
+    HMODULE16 hModule;            /* 1e Module handle */
+    HQUEUE16  hQueue;             /* 20 Selector of task queue */
+    HTASK16   hParent;            /* 22 Selector of TDB of parent */
+    WORD      signal_flags;       /* 24 Flags for signal handler */
+    FARPROC16 sighandler;         /* 26 Signal handler */
+    FARPROC16 userhandler;        /* 2a USER signal handler */
+    FARPROC16 discardhandler;     /* 2e Handler for GlobalNotify() */
+    FARPROC16 int0;               /* 32 int 0 (divide by 0) handler */
+    FARPROC16 int2;               /* 36 int 2 (NMI) handler */
+    FARPROC16 int4;               /* 3a int 4 (INTO) handler */
+    FARPROC16 int6;               /* 3e int 6 (invalid opc) handler */
+    FARPROC16 int7;               /* 42 int 7 (coprocessor) handler */
+    FARPROC16 int3e;              /* 46 int 3e (80x87 emu) handler */
+    FARPROC16 int75;              /* 4a int 75 (80x87 error) handler */
+    DWORD     compat_flags;       /* 4e Compatibility flags */
+    BYTE      unused4[2];         /* 52 */
+    struct _TEB *teb;             /* 54 Pointer to thread database */
+    BYTE      unused5[8];         /* 58 */
+    HANDLE16  hPDB;               /* 60 Selector of PDB (i.e. PSP) */
+    SEGPTR    dta;                /* 62 Current DTA */
+    BYTE      curdrive;           /* 66 Current drive */
+    BYTE      curdir[65];         /* 67 Current directory */
+    WORD      nCmdShow;           /* a8 cmdShow parameter to WinMain */
+    HTASK16   hYieldTo;           /* aa Next task to schedule */
+    DWORD     dlls_to_init;       /* ac Ptr to DLLs to initialize */
+    HANDLE16  hCSAlias;           /* b0 Code segment for this TDB */
+    WORD      thunks[8*4];        /* b2 Make proc instance thunks */
+    BYTE      module_name[8];     /* f2 Module name for task */
+    WORD      magic;              /* fa TDB signature */
+    HANDLE    hEvent;             /* fc scheduler event handle */
+    PDB16     pdb;                /* 100 PDB for this task */
+} TDB;
+
+/* TDB flags */
+#define TDBF_WINOLDAP   0x0001
+#define TDBF_OS2APP     0x0008
+#define TDBF_WIN32      0x0010
+
+/* Windows 3.1 USER signals */
+#define USIG16_TERMINATION      0x0020
+#define USIG16_DLL_LOAD         0x0040
+#define USIG16_DLL_UNLOAD       0x0080
+#define USIG16_GPF              0x0666
+
 typedef struct _SEGINFO {
     UINT16    offSegment;
     UINT16    cbSegment;
-- 
GitLab