Index: trunk/src/win32k/kKrnlLib/src/Dev16.mak
===================================================================
--- trunk/src/win32k/kKrnlLib/src/Dev16.mak	(revision 9510)
+++ trunk/src/win32k/kKrnlLib/src/Dev16.mak	(revision 9511)
@@ -1,3 +1,3 @@
-# $Id: Dev16.mak,v 1.9 2002-08-24 22:07:40 bird Exp $
+# $Id: Dev16.mak,v 1.10 2002-12-16 01:52:23 bird Exp $
 
 #
@@ -35,7 +35,8 @@
 $(PATH_TARGET)\d16Init.$(EXT_OBJ)\
 $(PATH_TARGET)\d16Globl.$(EXT_OBJ)\
-$(PATH_TARGET)\d16crt.$(EXT_OBJ)\
+$(PATH_TARGET)\devErrors.$(EXT_OBJ)\
+# $(PATH_TARGET)\d16crt.$(EXT_OBJ)\
 $(PATH_TARGET)\d16vprintf.$(EXT_OBJ)\
-$(PATH_TARGET)\d16ProbeKrnl.$(EXT_OBJ)\
+# $(PATH_TARGET)\d16ProbeKrnl.$(EXT_OBJ)\
 $(PATH_TARGET)\krnlImportTable.$(EXT_OBJ)\
 
Index: trunk/src/win32k/kKrnlLib/src/d16Init.c
===================================================================
--- trunk/src/win32k/kKrnlLib/src/d16Init.c	(revision 9510)
+++ trunk/src/win32k/kKrnlLib/src/d16Init.c	(revision 9511)
@@ -1,14 +1,27 @@
-/* $Id: d16Init.c,v 1.2 2002-03-31 19:01:13 bird Exp $
+/* $Id: d16Init.c,v 1.3 2002-12-16 01:53:25 bird Exp $
  *
  * d16init - init routines for both drivers.
  *
- * IMPORTANT! Code and data defined here will be discarded after init is
- *            completed. CodeEnd and DataEnd should not be set here.?
- *
- * Copyright (c) 1999-2001 knut st. osmundsen (kosmunds@csc.com)
- *
- * Project Odin Software License can be found in LICENSE.TXT
- *
- */
+ * Copyright (c) 1999-2002 knut st. osmundsen <bird@anduin.net>
+ *
+ *
+ * This file is part of kKrnlLib.
+ *
+ * kKrnlLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * kKrnlLib 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kKrnlLib; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
 
 /*******************************************************************************
@@ -36,11 +49,6 @@
 #include <memory.h>
 
-#include "devSegDf.h"
-#undef  DATA16_INIT
-#define DATA16_INIT
-#undef  CODE16_INIT
-#define CODE16_INIT
 #include "kKLInitHlp.h"
-#include "probkrnl.h"
+#include "devErrors.h"
 #include "dev1632.h"
 #include "dev16.h"
@@ -48,5 +56,52 @@
 #include "kKLlog.h"
 #include "options.h"
-#include "ProbKrnlErrors.h"
+
+
+
+/*******************************************************************************
+*   Internal Functions                                                         *
+*******************************************************************************/
+int             DoDevIOCtl(KKLR0INITPARAM  *pParam, KKLR0INITDATA *pData);
+
+
+/**
+ * Does the dev ioctl call to the helper driver for calling
+ * a 32-bit Ring-0 worker.
+ * @returns error code from DosOpen or DosDevIOCtl.
+ * @param   pParam  Pointer to parameter buffer.
+ * @param   pData   Pointer to data buffer.
+ * @author  knut st. osmundsen (kosmunds@csc.com)
+ */
+int             DoDevIOCtl(KKLR0INITPARAM  *pParam, KKLR0INITDATA *pData)
+{
+    APIRET          rc;
+    HFILE           hDev0 = 0;
+    USHORT          usAction = 0;
+
+    /* Open the kKrnlHlp device driver. */
+    rc = DosOpen(KKL_DEVICE_NAME, &hDev0, &usAction, 0UL, FILE_NORMAL,
+                 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
+                 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
+                 0UL);
+    if (rc == NO_ERROR)
+    {
+        pData->ulRc = 0;
+        rc = DosDevIOCtl(pData, pParam, KKL_IOCTL_RING0INIT, KKL_IOCTL_CAT, hDev0);
+        DosClose(hDev0);
+        if (rc != NO_ERROR)
+        {
+            dprintf(("DosDevIOCtl failed with rc=%d\n", rc));
+            rc = ERROR_D16_IOCTL_FAILED;
+        }
+    }
+    else
+    {
+        dprintf(("DosOpen Failed with rc=%d\n", rc));
+        rc = ERROR_D16_OPEN_DEV_FAILED;
+    }
+
+    return rc;
+}
+
 
 
@@ -74,6 +129,6 @@
 
     pRpOut->BPBArray = NULL;
-    pRpOut->CodeEnd = (USHORT)&CODE16_INITSTART;
-    pRpOut->DataEnd = (USHORT)&DATA16_INITSTART;
+    pRpOut->CodeEnd = (USHORT)&CODE16END;
+    pRpOut->DataEnd = (USHORT)&DATA16_ENDEND;
     pRpOut->Unit     = 0;
     pRpOut->rph.Status = STATUS_DONE;
@@ -96,41 +151,31 @@
     KKLR0INITPARAM  param;
     KKLR0INITDATA   data = {0UL};
-    HFILE           hDev0 = 0;
-    USHORT          usAction = 0;
-
-
-    /*
-     * Probe kernel data.
-     */
-    rc = ProbeKernel(pRpIn);
-    if (rc == NO_ERROR)
-    {
-        /*
-         * Create new 32-bit init packet - Parameter pointer is thunked.
-         */
-        RP32INIT        rp32init;
-        RP32INIT FAR *  fprp32init = &rp32init;
-
-        _fmemcpy(fprp32init, pRpIn, sizeof(RPINITIN));
-        if ((   pRpIn->InitArgs == NULL
-             || !(rc = DevHelp_VirtToLin(SELECTOROF(rp32init.InitArgs), OFFSETOF(rp32init.InitArgs), (PLIN)&rp32init.InitArgs))
-             )
-            &&  !(rc = DevHelp_VirtToLin(SELECTOROF(fprp32init), OFFSETOF(fprp32init), (PLIN)&param.ulParam))
-           )
-        {   /* call 32-bit init routine and set 32 bit rc. */
-            param.pfn = GetR0InitPtr();
-            rc = DoDevIOCtl(&param, &data);
-            if (rc == NO_ERROR)
-                rc = (USHORT)data.ulRc;
-        }
-        else
-            rc = ERROR_D16_THUNKING_FAILED;
-    }
+    RP32INIT        rp32init;
+    RP32INIT FAR *  fprp32init = &rp32init;
+
+    /*
+     * Create new 32-bit init packet - Parameter pointer is thunked.
+     */
+    _fmemcpy(fprp32init, pRpIn, sizeof(RPINITIN));
+    if ((   pRpIn->InitArgs == NULL
+         || !(rc = DevHelp_VirtToLin(SELECTOROF(rp32init.InitArgs), OFFSETOF(rp32init.InitArgs), (PLIN)&rp32init.InitArgs))
+         )
+        &&  !(rc = DevHelp_VirtToLin(SELECTOROF(fprp32init), OFFSETOF(fprp32init), (PLIN)&param.ulParam))
+       )
+    {   /* call 32-bit init routine and set 32 bit rc. */
+        param.pfn = GetR0InitPtr();
+        rc = DoDevIOCtl(&param, &data);
+        if (rc == NO_ERROR)
+            rc = (USHORT)data.ulRc;
+    }
+    else
+        rc = ERROR_D16_THUNKING_FAILED;
+
 
     /*
      * Fill return data.
      */
-    pRpOut->CodeEnd = (USHORT)&CODE16_INITSTART;
-    pRpOut->DataEnd = (USHORT)&DATA16_INITSTART;
+    pRpOut->CodeEnd = (USHORT)&CODE16_ENDEND;
+    pRpOut->DataEnd = (USHORT)&DATA16_ENDEND;
     pRpOut->BPBArray= NULL;
     pRpOut->Unit    = 0;
@@ -148,5 +193,5 @@
     else
     {
-        char *psz = GetErrorMsg(rc);
+        char *psz = devGetErrorMsg(rc);
         printf16("kKrnlLib.sys init failed with rc=0x%x (%d)\n", rc, rc);
         if (psz)
@@ -169,12 +214,9 @@
 /**
  * Gets the data we need from the DosTables.
- * This data is TKSSBase16, R0FlatCS16 and R0FlatDS16.
+ * (pulTKSSBase32, R0FlatCS16 and R0FlatDS16)
+ *
  * @returns   Same as DevHelp_GetDosVar.
  * @status    completely implemented.
  * @author    knut st. osmundsen (knut.stange.osmundsen@mynd.no)
- * @remark    If you are not sure if TKSSBase16 is set or not, call this.
- *            After R0Init16 is called TKSSBase16 _is_ set.
- *            IMPORTANT! This function must _not_ be called after the initiation of the second device driver!!!
- *                       (Since this is init code not present after init...)
  */
 USHORT NEAR  initGetDosTableData(void)
@@ -184,5 +226,5 @@
     PDOSTABLE2 pDT2;
 
-    if (TKSSBase16 != 0)
+    if (pulTKSSBase32 != 0)
         return NO_ERROR;
     /*
@@ -197,5 +239,5 @@
     {
         pDT2 = (PDOSTABLE2)((char FAR *)pDT + pDT->cul*4 + 1);
-        TKSSBase16 = (ULONG)pDT2->pTKSSBase;
+        pulTKSSBase32 = (ULONG)pDT2->pTKSSBase;
         R0FlatCS16 = (USHORT)pDT2->R0FlatCS;
         R0FlatDS16 = (USHORT)pDT2->R0FlatDS;
Index: trunk/src/win32k/kKrnlLib/src/devErrors.c
===================================================================
--- trunk/src/win32k/kKrnlLib/src/devErrors.c	(revision 9510)
+++ trunk/src/win32k/kKrnlLib/src/devErrors.c	(revision 9511)
@@ -1,7 +1,7 @@
-/* $Id: devErrors.c,v 1.1 2002-12-16 01:50:51 bird Exp $
+/* $Id: devErrors.c,v 1.2 2002-12-16 01:53:55 bird Exp $
  *
  * Error message from rc.
  *
- * Copyright (c) 2002 knut st. osmundsen <bird@anduin.net>
+ * Copyright (c) 2000-2002 knut st. osmundsen <bird@anduin.net>
  *
  *
@@ -105,5 +105,4 @@
  * @param   sErr  Error code id.
  * @status  completely implemented.
- * @author  knut st. osmundsen (kosmunds@csc.com)
  */
 const char *devGetErrorMsg(int sErr)
