Index: trunk/src/win32k/Makefile
===================================================================
--- trunk/src/win32k/Makefile	(revision 2820)
+++ trunk/src/win32k/Makefile	(revision 2823)
@@ -1,4 +1,4 @@
 ################################################################################
-# $Id: Makefile,v 1.23 2000-02-15 23:39:18 bird Exp $
+# $Id: Makefile,v 1.24 2000-02-18 19:27:28 bird Exp $
 #
 # Copyright 1998-1999 knut st. osmundsen
@@ -131,5 +131,5 @@
 {misc}.asm{object}.obj:
     @$(ECHO) assembling:      $<
-    @$(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
+    $(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
 {misc}.c{object}.obj:
     @$(ECHO) compiling 32bit: $<
@@ -184,5 +184,7 @@
         object\d32ElfIOCtl.obj \
         object\d32Win32kIOCtl.obj \
-        object\k32AllocMemEx.obj
+        object\k32AllocMemEx.obj \
+        object\buffer.obj \
+        object\mytkExecPgm.obj
 
 
Index: trunk/src/win32k/dev16/probkrnl.c
===================================================================
--- trunk/src/win32k/dev16/probkrnl.c	(revision 2820)
+++ trunk/src/win32k/dev16/probkrnl.c	(revision 2823)
@@ -1,3 +1,3 @@
-/* $Id: probkrnl.c,v 1.8 2000-02-08 12:38:38 bird Exp $
+/* $Id: probkrnl.c,v 1.9 2000-02-18 19:27:29 bird Exp $
  *
  * Description:   Autoprobes the os2krnl file and os2krnl[*].sym files.
@@ -95,13 +95,13 @@
     {FALSE, -1,  9, "_ldrClose",            -1,  -1, EPT_PROC},        /* 2 */
     {FALSE, -1, 12, "_LDRQAppType",         -1,  -1, EPT_PROC},        /* 3 */
-    {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1,  -1, EPT_PROC}         /* 4 */
-#if 0 /* Currently problems with with WS4eB */
-    ,
+    {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1,  -1, EPT_PROC},        /* 4 */
     {FALSE, -1, 10, "_IOSftOpen",           -1,  -1, EPT_PROCIMPORT},  /* 5 */
     {FALSE, -1, 11, "_IOSftClose",          -1,  -1, EPT_PROCIMPORT},  /* 6 */
     {FALSE, -1, 15, "_IOSftTransPath",      -1,  -1, EPT_PROCIMPORT},  /* 7 */
     {FALSE, -1, 12, "_IOSftReadAt",         -1,  -1, EPT_PROCIMPORT},  /* 8 */
-    {FALSE, -1, 13, "_IOSftWriteAt",        -1,  -1, EPT_PROCIMPORT}   /* 9 */
-#endif
+    {FALSE, -1, 13, "_IOSftWriteAt",        -1,  -1, EPT_PROCIMPORT},  /* 9 */
+    {FALSE, -1, 11, "_VMAllocMem",          -1,  -1, EPT_PROCIMPORT},  /* 10 */
+    {FALSE, -1, 11, "_VMGetOwner",          -1,  -1, EPT_PROCIMPORT},  /* 11 */
+    {FALSE, -1, 11, "g_tkExecPgm",          -1,  -1, EPT_PROC}         /* 12 */
 };
 
Index: trunk/src/win32k/dev32/d32init.c
===================================================================
--- trunk/src/win32k/dev32/d32init.c	(revision 2820)
+++ trunk/src/win32k/dev32/d32init.c	(revision 2823)
@@ -1,3 +1,3 @@
-/* $Id: d32init.c,v 1.8 2000-02-08 12:54:25 bird Exp $
+/* $Id: d32init.c,v 1.9 2000-02-18 19:27:29 bird Exp $
  *
  * d32init.c - 32-bits init routines.
@@ -48,12 +48,15 @@
 
 
-/* externs located in 16-bit data segement */
+/* externs located in 16-bit data segement in ProbKrnl.c */
 extern ULONG    _TKSSBase16;
 extern USHORT   _R0FlatCS16;
 extern USHORT   _R0FlatDS16;
 
-
 /* extern(s) located in calltab.asm */
 extern char     callTab[NUMBER_OF_PROCS][MAXSIZE_PROLOG];
+
+/* extern(s) located in mytkExecPgm.asm  */
+extern char     mytkExecPgm;
+
 
 
@@ -564,13 +567,13 @@
                         (unsigned)myldrClose,
                         (unsigned)myLDRQAppType,
-                        (unsigned)myldrEnum32bitRelRecs
-                        #if 0 /* Currently problems with with WS4eB */
-                        ,
+                        (unsigned)myldrEnum32bitRelRecs,
                         0,
                         0,
                         0,
                         0,
-                        0
-                        #endif
+                        0,
+                        0,
+                        0,
+                        (unsigned)&mytkExecPgm
                     };
 
Index: trunk/src/win32k/include/OS2KVM.h
===================================================================
--- trunk/src/win32k/include/OS2KVM.h	(revision 2820)
+++ trunk/src/win32k/include/OS2KVM.h	(revision 2823)
@@ -1,3 +1,3 @@
-/* $Id: OS2KVM.h,v 1.2 2000-02-15 23:39:19 bird Exp $
+/* $Id: OS2KVM.h,v 1.3 2000-02-18 19:27:29 bird Exp $
  *
  * OS/2 kernel VM functions.
@@ -19,22 +19,48 @@
  * VMAlloc flFlag1 guessings
  */
-#define VMA_CONTIG          0x00000001 /* VMDHA_CONTIG */
-#define VMA_WRITE           0x00000002 /* PAG_WRITE and OB_WRITE */
-#define VMA_USER            0x00000004 /* OB_USER */
-#define VMA_EXECUTE         0x00000008 /* PAG_EXECUTE and OB_READ !! */
-#define VMA_READ            0x00000010 /* PAG_READ and OB_EXEC !! */
-#define VMA_LOWMEM          0x00000020 /* OB_LOWMEM */
-#define VMA_GUARD           0x00000040 /* PAG_GUARD and VMDHA_16M and OB_GUARD */
-#define VMA_RESIDENT        0x00000080 /* OB_RESIDENT */
-#define VMA_ZEROINIT        0x00000100 /* OB_ZEROINIT */
-#define VMA_PHYS            0x00000200 /* VMDHA_PHYS */
-#define VMA_FIXED           0x00000400 /* VMDHA_FIXED and OB_SHARED */
-#define VMA_SHARE           0x00001000 /* OBJSHARE and OBJEXEC (which implies shared) */
-#define VMA_PROTECTED       0x00004000 /* PAG_PROTECTED */
-#define VMA_LOWMEM2         0x00010000 /* OB_LOWMEM */
-#define VMA_DECOMMIT        0x00080000 /* PAG_DECOMMIT */
-#define VMA_TILE            0x00400000 /* OBJ_TILE */
-#define VMA_SHRINKABLE      0x00800000 /* OB_SHRINKABLE */
-#define VMA_HUGH            0x01000000 /* OB_HUGH */
+#define VMA_CONTIG          0x00000001  /* VMDHA_CONTIG */
+#define VMA_WRITE           0x00000002  /* PAG_WRITE and OB_WRITE */
+#define VMA_USER            0x00000004  /* OB_USER */
+#define VMA_EXECUTE         0x00000008  /* PAG_EXECUTE and OB_READ !! */
+#define VMA_READ            0x00000010  /* PAG_READ and OB_EXEC !! */
+#define VMA_LOWMEM          0x00000020  /* OB_LOWMEM < 1MB physical */
+#define VMA_GUARD           0x00000040  /* PAG_GUARD and VMDHA_16M and OB_GUARD */
+#if 0
+#define VMA_RESIDENT        0x00000080  /* OB_RESIDENT */
+#define VMA_ZEROINIT        0x00000100  /* OB_ZEROINIT */
+#define VMA_PHYS            0x00000200  /* VMDHA_PHYS */
+#define VMA_FIXED           0x00000400  /* VMDHA_FIXED and OB_SHARED */
+#else
+#define VMA_ZEROFILL        0x00000080
+#define VMA_SWAPONWRITE     0x00000100
+#define VMA_UVIRT           0x00000200  /* VMDHA_PHYS */
+#define VMA_RESIDENT        0x00000400  /* VMDHA_FIXED and OB_SHARED */
+#endif
+#define VMA_DISCARDABLE     0x00000800  /* discarable object */
+#define VMA_SHARE           0x00001000  /* OBJSHARE and OBJEXEC (which implies shared) */
+#define VMA_PROTECTED       0x00004000  /* PAG_PROTECTED */
+#define VMA_LOWMEM2         0x00010000  /* OB_LOWMEM */
+#define VMA_VDM             0x00040000  /* VDM */
+#define VMA_DECOMMIT        0x00080000  /* PAG_DECOMMIT */
+#define VMA_TILE            0x00400000  /* OBJ_TILE */
+#define VMA_SELALLOC        0x00400000  /* Allocates selector */
+#define VMA_SHRINKABLE      0x00800000  /* OB_SHRINKABLE */
+#define VMA_HUGH            0x01000000  /* OB_HUGH */
+
+#define VMA_ARENASHARED     0x04000000  /* Shared Arena */
+#define VMA_ARENASYSTEM     0x00000000  /* System Arena */
+#define VMA_ARENAPRIVATE    0x02000000  /* Private Arena */
+#define VMA_ARENAHEAP       0x06000000  /* Heap Arena */
+#define VMA_ARENAHIGHA      0x00008000  /* High shared arena (Warp >= fp13) */
+#define VMA_ARENAHIGH   (options.ulBuild >= MERLINFP13 ? VMA_ARENAHIGHA : 0UL)
+#define VMA_ARENAMASKW      0x06000000  /* Warp < fp13 Arena Mask */
+#define VMA_ARENAMASKA      0x06008000  /* Aurora Arena Mask */
+#define VMA_ARENAMASK   (options.ulBuild >= MERLINFP13 ? VMA_ARENAMASKA : VMA_ARENAMASKW)
+
+#define VMA_LOCMASK         0xC0000000  /* Location mask */
+#define VMA_LOCSPECIFIC     0x80000000  /* Specific location */
+#define VMA_LOCABOVE        0x40000000  /* Above or equal to specified location */
+#define VMA_LOCANY          0x00000000  /* Anywhere */
+
 
 
@@ -56,15 +82,21 @@
 
 
+typedef USHORT HMTE, *PHMTE;
+typedef USHORT HPTDA, *PHPTDA;
 
 /*******************************************************************************
 *   Exported Functions                                                         *
 *******************************************************************************/
+HMTE KRNLCALL VMGetOwner(
+    ULONG ulCS,
+    ULONG ulEIP);
+
 APIRET KRNLCALL VMAllocMem(
     ULONG   cbSize,
-    ULONG   SomeArg1,
+    ULONG   cbCommit,
     ULONG   flFlags1,
-    USHORT  hPTDA,
+    HPTDA   hPTDA,
     USHORT  usVMOwnerId,
-    USHORT  hMTE,
+    HMTE    hMTE,
     ULONG   flFlags2,
     ULONG   SomeArg2,
Index: trunk/src/win32k/include/probkrnl.h
===================================================================
--- trunk/src/win32k/include/probkrnl.h	(revision 2820)
+++ trunk/src/win32k/include/probkrnl.h	(revision 2823)
@@ -1,3 +1,3 @@
-/* $Id: probkrnl.h,v 1.5 2000-02-08 12:38:39 bird Exp $
+/* $Id: probkrnl.h,v 1.6 2000-02-18 19:27:29 bird Exp $
  *
  * Include file for ProbKrnl.
@@ -16,5 +16,5 @@
 *   Defined Constants And Macros                                               *
 *******************************************************************************/
-#define NUMBER_OF_PROCS       5
+#define NUMBER_OF_PROCS      13
 #define MAX_LENGTH_NAME      32
 
Index: trunk/src/win32k/include/win32k.h
===================================================================
--- trunk/src/win32k/include/win32k.h	(revision 2820)
+++ trunk/src/win32k/include/win32k.h	(revision 2823)
@@ -1,3 +1,3 @@
-/* $Id: win32k.h,v 1.2 2000-02-15 23:39:19 bird Exp $
+/* $Id: win32k.h,v 1.3 2000-02-18 19:27:29 bird Exp $
  *
  * Top level make file for the Win32k library.
@@ -58,5 +58,8 @@
 *   External Functions                                                         *
 *******************************************************************************/
+APIRET APIENTRY  libWin32kInit(void);
+APIRET APIENTRY  libWin32kTerm(void);
 APIRET APIENTRY  DosAllocMemEx(PPVOID ppv, ULONG cb, ULONG flag);
+
 
 #endif
Index: trunk/src/win32k/k32/k32AllocMemEx.cpp
===================================================================
--- trunk/src/win32k/k32/k32AllocMemEx.cpp	(revision 2820)
+++ trunk/src/win32k/k32/k32AllocMemEx.cpp	(revision 2823)
@@ -1,3 +1,3 @@
-/* $Id: k32AllocMemEx.cpp,v 1.1 2000-02-15 23:39:58 bird Exp $
+/* $Id: k32AllocMemEx.cpp,v 1.2 2000-02-18 19:27:30 bird Exp $
  *
  * k32AllocMemEx - Equivalent to DosAllocMem, but this one
@@ -18,4 +18,8 @@
 #define INCL_OS2KRNL_VM
 
+#ifndef OBJ_SELMAPALL
+#define OBJ_SELMAPALL   0x00000800UL
+#endif
+
 
 /*******************************************************************************
@@ -30,4 +34,46 @@
 
 
+/* nasty! These should be imported from the kernel later! */
+
+ULONG vmApiF0[] =
+{
+    0,
+    VMA_READ,
+    VMA_WRITE | VMA_READ,
+    VMA_WRITE | VMA_READ,
+    VMA_EXECUTE,
+    VMA_EXECUTE | VMA_READ,
+    VMA_WRITE | VMA_EXECUTE | VMA_READ,
+    VMA_WRITE | VMA_EXECUTE | VMA_READ,
+    VMA_GUARD,
+    VMA_READ | VMA_GUARD,
+    VMA_WRITE | VMA_READ | VMA_GUARD,
+    VMA_WRITE | VMA_READ | VMA_GUARD,
+    VMA_EXECUTE | VMA_GUARD,
+    VMA_EXECUTE | VMA_READ | VMA_GUARD,
+    VMA_WRITE | VMA_EXECUTE | VMA_READ | VMA_GUARD,
+    VMA_WRITE | VMA_EXECUTE | VMA_READ | VMA_GUARD
+};
+
+
+ULONG vmApiF1[] =
+{
+    0,
+    0,
+    VMA_DECOMMIT,
+    VMA_DECOMMIT,
+    VMA_TILE,
+    VMA_TILE,
+    VMA_DECOMMIT | VMA_TILE,
+    VMA_DECOMMIT | VMA_TILE,
+    VMA_PROTECTED,
+    VMA_PROTECTED,
+    VMA_PROTECTED | VMA_DECOMMIT,
+    VMA_PROTECTED | VMA_DECOMMIT,
+    VMA_PROTECTED | VMA_TILE,
+    VMA_PROTECTED | VMA_TILE,
+    VMA_PROTECTED | VMA_DECOMMIT | VMA_TILE,
+    VMA_PROTECTED | VMA_DECOMMIT | VMA_TILE
+};
 
 
@@ -49,12 +95,42 @@
 APIRET k32AllocMemEx(PPVOID ppv, ULONG cb, ULONG flag, ULONG ulCS, ULONG ulEIP)
 {
+    APIRET  rc;
+    ULONG   flFlags2;
+    VMAC    vmac = {0};
+    ULONG   cbCommit;
+    HMTE    hMTE;
 
-    ppv = ppv;
-    cb = cb;
-    flag = flag;
-    ulCS = ulCS;
-    ulEIP = ulEIP;
+    if ((flag & ~(PAG_READ | PAG_WRITE | PAG_EXECUTE | PAG_GUARD | PAG_COMMIT
+                 | OBJ_TILE | OBJ_SELMAPALL))
+        || (flag & (PAG_READ | PAG_WRITE | PAG_EXECUTE)) == 0UL
+        || cb == 0
+        || ulCS == 0
+        || ulEIP == 0
+        )
+        return ERROR_INVALID_PARAMETER;
+    if (cb > 0xC0000000UL)
+        return ERROR_NOT_ENOUGH_MEMORY;
 
-    return ERROR_NOT_SUPPORTED;
+    vmac.ac_va = (ULONG)*ppv;
+    cb = (cb + 0xFFFUL) & ~0xFFFUL;
+    if (flag & PAG_COMMIT)
+        cbCommit = cb;
+    flag = vmApiF0[flag & (PAG_READ | PAG_WRITE | PAG_EXECUTE | PAG_GUARD)]
+           | vmApiF1[(flag & (PAG_COMMIT | PAG_DECOMMIT | OBJ_TILE | OBJ_PROTECTED)) >> 2]
+           | VMA_USER | VMA_RESIDENT | VMA_LOWMEM2 | VMA_TILE | 0x12000000;
+    flFlags2 = (flag & VMA_WRITE ? VMAF2_WRITE : 0) | 0x460;
+
+    hMTE = VMGetOwner(ulCS, ulEIP);
+    rc = VMAllocMem(cb,
+                    cbCommit,
+                    flag,
+                    0,
+                    0,
+                    hMTE,
+                    flFlags2,
+                    0,
+                    (PVMAC)SSToDS(&vmac));
+
+    return rc;
 }
 
Index: trunk/src/win32k/ldr/calltab.asm
===================================================================
--- trunk/src/win32k/ldr/calltab.asm	(revision 2820)
+++ trunk/src/win32k/ldr/calltab.asm	(revision 2823)
@@ -1,3 +1,3 @@
-; $Id: calltab.asm,v 1.4 2000-02-08 12:38:39 bird Exp $
+; $Id: calltab.asm,v 1.5 2000-02-18 19:27:30 bird Exp $
 ;
 ; callTab - Call back again table - table with entry for each function which is overrided.
@@ -24,5 +24,5 @@
     public _LDRQAppType@8
     public _ldrEnum32bitRelRecs@24
-if 0    ; /* Currently problems with with WS4eB */
+
     public _IOSftOpen@20
     public _IOSftClose@4
@@ -30,5 +30,9 @@
     public _IOSftReadAt@20
     public _IOSftWriteAt@20
-endif
+
+    public _VMAllocMem@36
+    public _VMGetOwner@8
+    public g_tkExecPgm
+
 
 ;
@@ -91,4 +95,16 @@
 
 
+_VMAllocMem@36 PROC NEAR
+    db MAXSIZE_PROLOG dup(0cch)
+_VMAllocMem@36 ENDP
+
+_VMGetOwner@8 PROC NEAR
+    db MAXSIZE_PROLOG dup(0cch)
+_VMGetOwner@8 ENDP
+
+g_tkExecPgm PROC NEAR
+    db MAXSIZE_PROLOG dup(0cch)
+g_tkExecPgm ENDP
+
 CALLTAB ENDS
 
Index: trunk/src/win32k/lib/libDosAllocMemEx.c
===================================================================
--- trunk/src/win32k/lib/libDosAllocMemEx.c	(revision 2823)
+++ trunk/src/win32k/lib/libDosAllocMemEx.c	(revision 2823)
@@ -0,0 +1,69 @@
+/* $Id: libDosAllocMemEx.c,v 1.1 2000-02-18 19:27:31 bird Exp $
+ *
+ * DosAllocMemEx - Extened Edition of DosAllocMem.
+ *                 Allows you to suggest an address of the memory.
+ *
+ * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#define INCL_DOSERROR
+#define INCL_DOSFILEMGR
+#define INCL_DOSDEVICES
+#define INCL_WIN32K_LIB
+
+
+/*******************************************************************************
+*   Internal Functions                                                         *
+*******************************************************************************/
+#include <os2.h>
+#include <win32k.h>
+
+
+/*******************************************************************************
+*   Global Variables                                                           *
+*******************************************************************************/
+static BOOL fInited = FALSE;
+HFILE       hWin32k = NULLHANDLE;
+
+
+
+
+APIRET APIENTRY  DosAllocMemEx(PPVOID ppv, ULONG cb, ULONG flag)
+{
+    APIRET rc;
+
+    if (fInited)
+    {
+        K32ALLOCMEMEX Param;
+        Param.pv = *ppv;
+        Param.cb = cb;
+        Param.flFlags = flag;
+        Param.rc = 0;
+        Param.ulCS = ;
+        Param.ulEIP = ;
+
+        param.pRpInitIn = pRpIn;
+        rc = DosDevIOCtl(hWin32k,
+                         IOCTL_W32K_K32,
+                         K32_ALLOCMEMEX,
+                         &Param, sizeof(Param), &cbParam,
+                         "", 1, &cbData);
+        if (rc == NO_ERROR)
+        {
+            ppv = Param.pv;
+            rc = Param.rc;
+        }
+    }
+    else
+        rc = ERROR_INIT_ROUTINE_FAILED;
+
+    return rc;
+}
+
Index: trunk/src/win32k/lib/libInit.c
===================================================================
--- trunk/src/win32k/lib/libInit.c	(revision 2823)
+++ trunk/src/win32k/lib/libInit.c	(revision 2823)
@@ -0,0 +1,64 @@
+/* $Id: libInit.c,v 1.1 2000-02-18 19:27:31 bird Exp $
+ *
+ * Inits the Win32k library functions.
+ *
+ * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#define INCL_DOSERROR
+#define INCL_DOSFILEMGR
+#define INCL_DOSDEVICES
+
+
+/*******************************************************************************
+*   Internal Functions                                                         *
+*******************************************************************************/
+#include <os2.h>
+
+
+/*******************************************************************************
+*   Global Variables                                                           *
+*******************************************************************************/
+static BOOL fInited = FALSE;
+HFILE       hWin32k = NULLHANDLE;
+
+
+/**
+ * Initiates the library.
+ * @returns   OS/2 return code.
+ * @status
+ * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
+ * @remark
+ */
+APIRET APIENTRY  libWin32kInit(void)
+{
+    APIRET rc;
+
+    if (!fInited)
+    {
+        ULONG ulAction = 0UL;
+
+        rc = DosOpen("\\dev\\win32k$",
+                     &hWin32k,
+                     &ulAction,
+                     0UL,
+                     FILE_NORMAL,
+                     OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
+                     OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
+                     NULL);
+
+        fInited = rc == NO_ERROR;
+    }
+    else
+        rc = NO_ERROR;
+
+    return rc;
+}
+
Index: trunk/src/win32k/misc/buffer.asm
===================================================================
--- trunk/src/win32k/misc/buffer.asm	(revision 2820)
+++ trunk/src/win32k/misc/buffer.asm	(revision 2823)
@@ -1,3 +1,3 @@
-; $Id: buffer.asm,v 1.1 2000-02-18 14:55:08 bird Exp $
+; $Id: buffer.asm,v 1.2 2000-02-18 19:27:31 bird Exp $
 ;
 ; Simple resident buffer for use when overloading tkExecPgm.
@@ -19,5 +19,6 @@
     public AcquireBuffer
     public ReleaseBuffer
-    public cbBuffer
+    public QueryBufferSegmentOffset
+;    public cbBuffer
 
 
@@ -25,9 +26,14 @@
 ;   Global Variables
 ;
-DATA32 segment
+DATA16 SEGMENT
+;DATA32 SEGMENT
+achBuffer   db 4096 dup(?)
+DATA16 ENDS
+;DATA32 ENDS
+
+;DATA16 SEGMENT
+DATA32 SEGMENT
 fBuffer     db 0            ;Access "semaphore"
-cbBuffer    db 4096
-achBuffer   db 4096 dup(?)
-DATA32 ends
+DATA32 ENDS
 
 
@@ -53,6 +59,8 @@
 AcquireBuffer PROC NEAR
     push    ds
-    mov     ax, FLAT
-    mov     ds, ax
+    ;mov     ax,
+;    push    FLAT
+    pop     ds
+    ;mov     ds, ax
     ASSUME  DS:FLAT
     mov     al, 0
@@ -89,6 +97,8 @@
     ASSUME  DS:NOTHING
     push    ds
-    mov     ax, FLAT
-    mov     ds, ax
+;    mov     ax, DATA16
+;    mov     ds, ax
+;    push    FLAT
+    pop     ds
     ASSUME  DS:FLAT
     cmp     eax, offset achBuffer
@@ -122,6 +132,8 @@
     ASSUME  DS:NOTHING
     push    ds
-    mov     ax, FLAT
-    mov     ds, ax
+;    mov     ax, DATA16
+;    mov     ds, ax
+;    push    FLAT
+    pop     ds
     ASSUME  DS:FLAT
     cmp     eax, offset achBuffer
@@ -152,5 +164,5 @@
 ; Jumps back to GetBufferOffset32
 GetBufferSegmentOffset16:
-    ASSUME CS:CODE16, DS:FLAT
+    ASSUME CS:CODE16, DS:NOTHING
     mov     ax, seg achBuffer
     mov     es, ax
