Index: trunk/src/win32k/pe2lx/pe2lx.cpp
===================================================================
--- trunk/src/win32k/pe2lx/pe2lx.cpp	(revision 6850)
+++ trunk/src/win32k/pe2lx/pe2lx.cpp	(revision 6852)
@@ -1,3 +1,3 @@
-/* $Id: pe2lx.cpp,v 1.32 2001-08-08 17:24:45 bird Exp $
+/* $Id: pe2lx.cpp,v 1.33 2001-09-28 07:43:02 sandervl Exp $
  *
  * Pe2Lx class implementation. Ring 0 and Ring 3
@@ -94,4 +94,7 @@
 #include <stddef.h>                     /* C library stddef.h. */
 #include <stdarg.h>                     /* C library stdarg.h. */
+#ifndef RING0
+#include <stdio.h>
+#endif
 
 #include "vprintf.h"                    /* win32k printf and vprintf. Not C library! */
@@ -2780,4 +2783,8 @@
     BufferedRVARead            *pImpThunkReader;    /* Buffered reader for thunk reads; ie. reading from the OrgiginalFirstThunk array. */
     ULONG                       ulModuleOrdinal;    /* Module ordinal. Valid as long as fImport is set. */
+    #ifndef RING0
+    ULONG                       ulCustomModOrdinal; /* Module ordinal of custom Odin dll. Valid as long as fImport is set. */
+    char                        szModuleName[128];
+    #endif
     ULONG                       ulRVAFirstThunk;    /* Current first thunk array RVA. Points at current entry. */
     ULONG                       ulRVAOrgFirstThunk; /* Current original first thunk array RVA. Points at current entry. */
@@ -2831,5 +2838,7 @@
         (ulRVABaseReloc = pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress) > 0UL
         &&
-        ulRVABaseReloc < pNtHdrs->OptionalHeader.SizeOfImage;
+        ulRVABaseReloc < pNtHdrs->OptionalHeader.SizeOfImage
+        &&
+        areFixupsEnabled();
     #endif
     printInf(("\n"));
@@ -2885,6 +2894,16 @@
 
     /* Make sure kernel32 is the first imported module */
-    if (rc == NO_ERROR)
-        rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul));
+    if (rc == NO_ERROR) 
+    {
+        #ifndef RING0
+        if(hasCustomDll()) {
+            rc = addModule(options.pszCustomDll, (PULONG)SSToDS(&ul));
+            ulCustomModOrdinal = ul;
+            strcpy(szModuleName, "KERNEL32");
+        }
+        else
+        #endif
+            rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul));
+    }
 
     /* initiate the import variables */
@@ -2915,6 +2934,25 @@
                 rc = pImpNameReader->dupString(ulModuleOrdinal, (PSZ*)SSToDS(&psz));
                 if (rc == NO_ERROR)
-                    rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal));
-                free(psz);
+                {
+                    #ifndef RING0
+                    if(hasCustomDll()) {
+                        ulModuleOrdinal = ulCustomModOrdinal;
+                        strcpy(szModuleName, psz);
+                        char *tmp = szModuleName;
+                        while(*tmp != 0 && *tmp != '.')
+                        {
+                            if(*tmp >= 'a' && *tmp <= 'z') {
+                                *tmp += ('A' - 'a');
+                            }
+                            tmp++;
+                        }
+                        *tmp = 0;
+                    }
+                    else
+                    #endif
+                        rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal));
+
+                    free(psz);
+                }
             }
             else
@@ -2950,5 +2988,12 @@
             && ((paObjects[iObj].Misc.offTIBFix + paObjects[iObj].ulRVA) & ~(PAGESIZE-1UL)) == ulRVAPage)
         {
-            rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul));
+            #ifndef RING0
+            if(hasCustomDll()) {
+                rc = addModule(options.pszCustomDll, (PULONG)SSToDS(&ul));
+                ulCustomModOrdinal = ul;
+            }
+            else
+            #endif
+                rc = addModule("KERNEL32.DLL", (PULONG)SSToDS(&ul));
             if (rc == NO_ERROR)
             {
@@ -2957,5 +3002,9 @@
                                          ul,
                                          pNtHdrs->FileHeader.Characteristics & IMAGE_FILE_DLL ?
-                                            ORD_REGISTERPE2LXDLL : ORD_REGISTERPE2LXEXE);
+                                            ORD_REGISTERPE2LXDLL : ORD_REGISTERPE2LXEXE
+                #ifndef RING0
+                                         , "KERNEL32"
+                #endif
+                                         );
             }
             if (rc != NO_ERROR)
@@ -2977,5 +3026,9 @@
                     if (Thunk.u1.Ordinal & (ULONG)IMAGE_ORDINAL_FLAG)
                         rc = add32OrdImportFixup((WORD)(ulRVAFirstThunk & (PAGESIZE-1)),
-                                                 ulModuleOrdinal, Thunk.u1.Ordinal & 0xffff);
+                                                 ulModuleOrdinal, Thunk.u1.Ordinal & 0xffff
+                        #ifndef RING0
+                                                 , szModuleName
+                        #endif
+                                                 );
                     else if (Thunk.u1.Ordinal > 0UL && Thunk.u1.Ordinal < pNtHdrs->OptionalHeader.SizeOfImage)
                     {
@@ -2985,5 +3038,9 @@
                             break;
                         rc = add32NameImportFixup((WORD)(ulRVAFirstThunk & (PAGESIZE-1)),
-                                                  ulModuleOrdinal, psz);
+                                                  ulModuleOrdinal, psz
+                        #ifndef RING0
+                                                  , szModuleName
+                        #endif
+                                                 );
                         free(psz);
                     }
@@ -3028,5 +3085,20 @@
                             if (rc == NO_ERROR)
                             {
-                                rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal));
+                                #ifndef RING0
+                                if(hasCustomDll()) {
+                                    ulModuleOrdinal = ulCustomModOrdinal;
+                                    strcpy(szModuleName, psz);
+                                    char *tmp = szModuleName;
+                                    while(*tmp != 0 && *tmp != '.') {
+                                        if(*tmp >= 'a' && *tmp <= 'z') {
+                                            *tmp += ('A' - 'a');
+                                        }
+                                        tmp++;
+                                    }
+                                    *tmp = 0;
+                                }
+                                else
+                                #endif
+                                    rc = addModule(psz, (PULONG)SSToDS(&ulModuleOrdinal));
                                 free(psz);
                             }
@@ -3828,8 +3900,33 @@
  *
  */
+#ifndef RING0
+ULONG  Pe2Lx::add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal, PSZ pszModuleName)
+#else
 ULONG  Pe2Lx::add32OrdImportFixup(WORD offSource, ULONG ulModuleOrdinal, ULONG ulFunctionOrdinal)
+#endif
 {
     struct r32_rlc *prlc;
     ULONG           cbFixup;         /* size of the fixup record. */
+
+    #ifndef RING0
+    if(hasCustomDll() && pszModuleName)
+    {
+        char  searchstring[256];
+        char *found;
+
+        sprintf(searchstring, "%s.%d", pszModuleName, ulFunctionOrdinal);
+        found = strstr(options.pszCustomExports, searchstring);
+        if(found) {
+            while(*found != '@') {
+                found++;
+            }
+            ulFunctionOrdinal = atoi(++found);
+        }
+        else {
+            printf("Error: Export %s not found in table.\n\n", searchstring);
+            return ERROR_MOD_NOT_FOUND;
+        }
+    }
+    #endif
 
     /* enough memory? */
@@ -3953,5 +4050,9 @@
  *
  */
+#ifndef RING0
+ULONG  Pe2Lx::add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName, PSZ pszModuleName)
+#else
 ULONG  Pe2Lx::add32NameImportFixup(WORD offSource, ULONG ulModuleOrdinal, PCSZ pszFnName)
+#endif
 {
     APIRET          rc;
@@ -3959,4 +4060,27 @@
     ULONG           cbFixup;         /* size of the fixup record. */
     ULONG           offFnName;
+
+    #ifndef RING0
+    if(hasCustomDll())
+    {
+        char  searchstring[256];
+        char *found;
+        int   ordinal;
+
+        sprintf(searchstring, "%s.%s", pszModuleName, pszFnName);
+        found = strstr(options.pszCustomExports, searchstring);
+        if(found) {
+            while(*found != '@') {
+                found++;
+            }
+            ordinal = atoi(++found);
+            return add32OrdImportFixup(offSource, ulModuleOrdinal, ordinal, NULL);
+        }
+        else {
+            printf("Error: Export %s not found in table.\n\n", searchstring);
+            return ERROR_MOD_NOT_FOUND;
+        }
+    }
+    #endif
 
     /* enough memory? */
@@ -5009,4 +5133,9 @@
     int i = 0;
 
+    #ifndef RING0
+    if(hasCustomDll()) {
+        return pszWin32ModuleName;
+    }
+    #endif
     while (paLieList[i].pszWin32Name != NULL)
     {
Index: trunk/src/win32k/pe2lx/pe2lxmain.cpp
===================================================================
--- trunk/src/win32k/pe2lx/pe2lxmain.cpp	(revision 6850)
+++ trunk/src/win32k/pe2lx/pe2lxmain.cpp	(revision 6852)
@@ -1,3 +1,3 @@
-/* $Id: pe2lxmain.cpp,v 1.7 2001-02-10 11:11:48 bird Exp $
+/* $Id: pe2lxmain.cpp,v 1.8 2001-09-28 07:43:03 sandervl Exp $
  *
  * Pe2Lx main program. (Ring 3 only!)
@@ -32,4 +32,7 @@
 #include <string.h>
 #include <stdlib.h>
+#include <io.h>
+#include <fcntl.h>
+#include <sys/stat.h>
 #include "OS2Krnl.h"
 #include "modulebase.h"
@@ -125,4 +128,30 @@
                     }
                     break;
+
+                case 'f': //ignore internal fixups
+                case 'F':
+                    options.fSkipFixups = TRUE;
+                    break;
+
+                case 'c':
+                case 'C': //custom odin dll name
+                    if(!hasCustomExports()) {
+                        printf("Syntax error: export table file not specified (/O).\n\n");
+                        return 5;
+                    }
+                    options.pszCustomDll = &argv[argi][3];
+                    break;
+                case 'o':
+                case 'O':
+                {
+                    int fileIn = open(&argv[argi][3], O_RDONLY, S_IREAD);
+                    int sizein = (int)_filelength(fileIn);
+
+                    options.pszCustomExports = (PSZ)malloc(sizein+1);
+                    memset(options.pszCustomExports, 0, sizein+1);
+                    read(fileIn, options.pszCustomExports, sizein);
+                    close(fileIn);
+                    break;
+                }
 
                 default:
