Changeset 13416


Ignore:
Timestamp:
Feb 21, 2000, 5:45:47 AM (25 years ago)
Author:
bird
Message:

ProbKrnl and code for importing krnl symbols has been enhanched.
Now we'll lock 32-bit segments into memory too.
And some other fixes...

Location:
tags/trunk/src/win32k
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/win32k/dev16/d16init.c

    r12264 r13416  
    1 /* $Id: d16init.c,v 1.4 1999-11-10 01:45:30 bird Exp $
     1/* $Id: d16init.c,v 1.5 2000-02-21 04:45:45 bird Exp $
    22 *
    33 * d16init - init routines for both drivers.
     
    4848 * @remark    pRpIn and pRpOut points to the same memory.
    4949 */
    50 USHORT _near dev0Init(PRPINITIN pRpIn, PRPINITOUT pRpOut)
     50USHORT NEAR dev0Init(PRPINITIN pRpIn, PRPINITOUT pRpOut)
    5151{
    5252    Device_Help = pRpIn->DevHlpEP;
     
    7070 * @remark    pRpIn and pRpOut points to the same memory.
    7171 */
    72 USHORT _near dev1Init(PRPINITIN pRpIn, PRPINITOUT pRpOut)
     72USHORT NEAR dev1Init(PRPINITIN pRpIn, PRPINITOUT pRpOut)
    7373{
    7474    APIRET          rc;
     
    103103            }
    104104            else
    105                 npszErrMsg = "DosDevIOCtl failed.\n\r";
     105            {
     106                APIRET rc2 = rc;
     107                NPSZ   npsz;
     108                            /*0123456789012345678901234567890 1*/
     109                npszErrMsg = "DosDevIOCtl failed. rc=       \n\r";
     110
     111                npsz  = &npszErrMsg[29];
     112                do
     113                {
     114                    *npsz-- = (char)((rc2 % 10) + '0');
     115                    rc2 = rc2/10;
     116                } while (rc2 > 0);
     117            }
     118
    106119            DosClose(hDev0);
    107120        }
     
    133146 * @param     pRp  Generic IO Control request packet.
    134147 */
    135 USHORT R0Init16(PRP_GENIOCTL pRp)
     148USHORT NEAR R0Init16(PRP_GENIOCTL pRp)
    136149{
    137150    USHORT usRc = STATUS_DONE;
    138151    APIRET rc;
    139     PDOSTABLE  pDT;
    140     PDOSTABLE2 pDT2;
    141152
    142153    /* First we're to get the DosTable2 stuff. */
    143     rc = DevHelp_GetDOSVar(9, 0, &pDT);
     154    rc = initGetDosTableData();
    144155    if (rc == NO_ERROR)
    145156    {
     
    150161        ULONG ulLinData;
    151162
    152         pDT2 = (PDOSTABLE2)((char FAR *)pDT + pDT->cul*4 + 1);
    153         TKSSBase16 = (ULONG)pDT2->pTKSSBase;
    154         R0FlatCS16 = (USHORT)pDT2->R0FlatCS;
    155         R0FlatDS16 = (USHORT)pDT2->R0FlatDS;
    156163        if (!DevHelp_VirtToLin(SELECTOROF(pRp->ParmPacket), OFFSETOF(pRp->ParmPacket), &ulLinParm)
    157164            &&
     
    159166            )
    160167        {
    161             if (!(rc = DevHelp_VMLock(VMDHL_LONG | VMDHL_WRITE | VMDHL_VERIFY,
     168            if (!(rc = DevHelp_VMLock(VMDHL_LONG | VMDHL_WRITE,
    162169                                ulLinParm, sizeof(D16R0INITPARAM),
    163170                                (LIN)~0UL, SSToDS_16(&hLockParm[0]), &cPages))
    164171                &&
    165                 !DevHelp_VMLock(VMDHL_LONG | VMDHL_WRITE | VMDHL_VERIFY,
     172                !DevHelp_VMLock(VMDHL_LONG | VMDHL_WRITE,
    166173                                ulLinData, sizeof(D16R0INITDATA),
    167174                                (LIN)~0UL, SSToDS_16(&hLockData[0]), &cPages)
     
    215222    return usRc;
    216223}
     224
     225
     226
     227/**
     228 * Gets the data we need from the DosTables.
     229 * This data is TKSSBase16, R0FlatCS16 and R0FlatDS16.
     230 * @returns   Same as DevHelp_GetDosVar.
     231 * @status    completely implemented.
     232 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     233 * @remark    If you are not sure if TKSSBase16 is set or not, call this.
     234 *            After R0Init16 is called TKSSBase16 _is_ set.
     235 *            IMPORTANT! This function must _not_ be called after the initiation of the second device driver!!!
     236 */
     237USHORT NEAR initGetDosTableData(void)
     238{
     239    APIRET     rc;
     240    PDOSTABLE  pDT;
     241    PDOSTABLE2 pDT2;
     242
     243    if (TKSSBase16 != 0)
     244        return NO_ERROR;
     245
     246    /* First we're to get the DosTable2 stuff. */
     247    rc = DevHelp_GetDOSVar(9, 0, &pDT);
     248    if (rc == NO_ERROR)
     249    {
     250        pDT2 = (PDOSTABLE2)((char FAR *)pDT + pDT->cul*4 + 1);
     251        TKSSBase16 = (ULONG)pDT2->pTKSSBase;
     252        R0FlatCS16 = (USHORT)pDT2->R0FlatCS;
     253        R0FlatDS16 = (USHORT)pDT2->R0FlatDS;
     254    }
     255    return rc;
     256}
  • TabularUnified tags/trunk/src/win32k/dev16/d16strat.c

    r13412 r13416  
    1 /* $Id: d16strat.c,v 1.5 2000-02-20 04:27:22 bird Exp $
     1/* $Id: d16strat.c,v 1.6 2000-02-21 04:45:45 bird Exp $
    22 *
    33 * d16strat.c - 16-bit strategy routine, device headers, device_helper (ptr)
     
    145145            {
    146146                ULONG ulLin;
     147                if (fInitTime && TKSSBase16 == 0)
     148                    initGetDosTableData();
    147149                if (DevHelp_VirtToLin(SELECTOROF(pRp->DataPacket), OFFSETOF(pRp->DataPacket),
    148150                                      &ulLin) != NO_ERROR)
     
    153155            case D16_IOCTL_VERIFYPROCTAB:
    154156                if (fInitTime)
     157                {
     158                    if (TKSSBase16 == 0)
     159                        initGetDosTableData();
    155160                    return CallVerifyImportTab32();
     161                }
    156162                break;
    157163        }
  • TabularUnified tags/trunk/src/win32k/dev16/probkrnl.c

    r13412 r13416  
    1 /* $Id: probkrnl.c,v 1.12 2000-02-20 04:27:23 bird Exp $
     1/* $Id: probkrnl.c,v 1.13 2000-02-21 04:45:45 bird Exp $
    22 *
    33 * Description:   Autoprobes the os2krnl file and os2krnl[*].sym files.
     
    157157*   Internal Functions                                                         *
    158158*******************************************************************************/
     159/* File an output replacements */
    159160static HFILE    fopen(const char * pszFilename, const char * pszIgnored);
    160161static int      fread(void * pvBuffer, USHORT cbBlock, USHORT cBlock,  HFILE hFile);
     
    163164static void     puts(char *psz);
    164165
     166/* C-library replacements. */
    165167static void     kmemcpy(char *psz1, const char *psz2, int cch);
    166168static char *   kstrstr(const char *psz1, const char *psz2);
    167169static int      kstrcmp(const char *psz1, const char *psz2);
    168170static int      kstrncmp(const char *psz1, const char *psz2, int cch);
     171static int      kstrnicmp(const char *psz1, const char *psz2, int cch);
    169172static int      kstrlen(const char *psz);
    170173static int      kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen);
    171174
     175/* Workers */
    172176static int      VerifyPrologs(void);
    173177static int      ProbeSymFile(char *pszFilename);
     
    177181static int      GetKernelOTEs(void);
    178182
     183/* Ouput */
    179184static void     ShowDecNumber(unsigned long ul);
    180185static void     ShowHexNumber(unsigned long ul);
     
    338343
    339344
    340 
    341345/**
    342346 * kstrncmp - String 'n' compare.
     
    360364
    361365
     366#if 0 /* not in use */
     367/**
     368 * kstrnicmp - String 'n' compare, case-insensitive.
     369 * @returns   0 - equal else !0
     370 * @param     p1  String 1
     371 * @param     p2  String 2
     372 * @param     len length
     373 */
     374static int      kstrnicmp(const char *psz1, const char *psz2, int cch)
     375{
     376    register char ch1, ch2;
     377
     378    do
     379    {
     380        ch1 = *psz1++;
     381        if (ch1 >= 'A' && ch1 <= 'Z')
     382            ch1 += 'a' - 'A';           /* to lower case */
     383        ch2 = *psz2++;
     384        if (ch2 >= 'A' && ch2 <= 'Z')
     385            ch2 += 'a' - 'A';           /* to lower case */
     386    } while (--cch > 0 && ch1 == ch2 && ch1 != '\0' && ch2 != '\0');
     387
     388    return ch1 - ch2;
     389}
     390#endif
     391
     392
    362393/**
    363394 * kstrlen - String length.
     
    431462
    432463/*******************************************************************************
    433 *   Implementation Of The Important Function                                   *
     464*   Implementation Of The Important Functions                                  *
    434465*******************************************************************************/
    435466
     
    727758 * @param     filename   Filename of the OS/2 kernel.
    728759 * @result    ulBuild is set.
     760 * @remark    This step will be eliminated by searching thru the DOSGROUP datasegment
     761 *            in the kernel memory. This segment have a string "Internal revision 9.034[smp|uni]"
     762 *            This would be much faster than reading the kernel file. It will also give us a more precise
     763 *            answer to the question! This is currently a TODO issue. !FIXME!
    729764 */
    730765static int ReadOS2Krnl(char * pszFilename)
     
    11171152                    case 'S': /* Symbol file */
    11181153                        i++;
    1119                         i += kargncpy(szUsrSym, &pReqPack->InitArgs[i], sizeof(szUsrSym));
     1154                        if (pReqPack->InitArgs[i] == 'Y' || pReqPack->InitArgs[i] == 'y')
     1155                            i += kargncpy(szUsrSym, &pReqPack->InitArgs[i], sizeof(szUsrSym));
    11201156                        break;
    11211157
  • TabularUnified tags/trunk/src/win32k/dev32/d32init.c

    r13412 r13416  
    1 /* $Id: d32init.c,v 1.12 2000-02-20 04:27:23 bird Exp $
     1/* $Id: d32init.c,v 1.13 2000-02-21 04:45:46 bird Exp $
    22 *
    33 * d32init.c - 32-bits init routines.
     
    1212*   Defined Constants                                                          *
    1313*******************************************************************************/
    14 #define MAXSIZE_PROLOG 0x10             /* Note that this must be synced with */
     14#define MAXSIZE_PROLOG 0x18             /* Note that this must be synced with */
    1515                                        /* the one used in calltab.asm.       */
    1616#define static                          /* just to make all symbols visible in the kernel debugger.  */
     
    3232#include "dev1632.h"
    3333#include "dev32.h"
     34#include "dev32hlp.h"
    3435#include "probkrnl.h"
    3536#include "log.h"
     
    3839#include "ldr.h"
    3940#include "ldrCalls.h"
    40 
     41#include "macros.h"
     42
     43/*******************************************************************************
     44*   Global Variables                                                           *
     45*******************************************************************************/
     46#ifdef DEBUG
     47static char * apszPE[] = {"FLAGS_PE_NOT", "FLAGS_PE_PE2LX", "FLAGS_PE_PE", "FLAGS_PE_MIXED", "!invalid!"};
     48static char * apszInfoLevel[] = {"INFOLEVEL_QUIET", "INFOLEVEL_ERROR", "INFOLEVEL_WARNING", "INFOLEVEL_INFO", "INFOLEVEL_INFOALL", "!invalid!"};
     49#endif
    4150
    4251/*******************************************************************************
    4352*   Internal Functions                                                         *
    4453*******************************************************************************/
    45 static ULONG    readnum(const char *pszNum);
    46 static signed char interpretFunctionProlog32(char *pach, BOOL fOverload);
    47 static signed char interpretFunctionProlog16(char *pach, BOOL fOverload);
    48 static int      ImportTabInit(void);
     54static ULONG        readnum(const char *pszNum);
     55_Inline int         ModR_M_32bit(char bModRM);
     56static int          interpretFunctionProlog32(char *pach, BOOL fOverload);
     57static int          interpretFunctionProlog16(char *pach, BOOL fOverload);
     58static int          ImportTabInit(void);
    4959
    5060
     
    5969/* extern(s) located in mytkExecPgm.asm  */
    6070extern char     mytkExecPgm;
    61 
     71extern char     CODE32START;
     72extern char     CODE32END;
     73extern char     CONST32_ROEND;
     74extern char     DATA16START;
     75extern char     DATA16_CONSTEND;
    6276
    6377
     
    8195    char   *pszTmp;
    8296    ULONG   ul;
     97    APIRET  rc;
     98    LOCKHANDLE lhData16={0,0,0,0, 0,0,0,0, 0,0,0,0};
     99    LOCKHANDLE lhData = {0,0,0,0, 0,0,0,0, 0,0,0,0};
     100    LOCKHANDLE lhCode = {0,0,0,0, 0,0,0,0, 0,0,0,0};
    83101
    84102    pulTKSSBase32 = (PULONG)_TKSSBase16;
     
    258276
    259277    /* log option summary - FIXME */
    260     kprintf(("Options - Summary\n"));
     278    kprintf(("Options - Summary - Start\n"));
     279    if (options.fQuiet)
     280        kprintf(("\tQuiet init\n"));
     281    else
     282        kprintf(("\tVerbose init\n"));
     283
     284    if (options.fLogging)
     285        kprintf(("\tlogging enabled\n"));
     286    else
     287        kprintf(("\tlogging disabled\n"));
     288    kprintf(("\tCom port no.%d\n", options.usCom));
     289
    261290    kprintf(("\tKernel: ver%d.%d  build %d  type %s\n",
    262291                options.usVerMajor,
     
    265294                (options.fKernel & KF_SMP) ? "SMP" : "UNI"
    266295              ));
    267     kprintf(("\tCom port no.%d\n", options.usCom));
    268     if (options.fQuiet)
    269         kprintf(("\tQuiet init\n"));
    270     else
    271         kprintf(("\tVerbose init\n"));
    272     if (options.fLogging)
    273         kprintf(("\tlogging enabled\n"));
    274     else
    275         kprintf(("\tlogging disabled\n"));
     296    kprintf(("\tfPE=%d (%s)\n", options.fPE, apszPE[MIN(options.fPE, 5)]));
     297    kprintf(("\tulInfoLevel=%d (%s)\n", options.ulInfoLevel, apszInfoLevel[MIN(options.ulInfoLevel, 5)]));
     298    kprintf(("\tfElf=%d\n", options.fElf));
     299    kprintf(("\tfScript=%d\n", options.fScript));
     300    kprintf(("\tfNoLoader=%d\n", options.fNoLoader));
     301    kprintf(("\tcbSwpHeapInit=0x%08x  cbSwpHeapMax=0x%08x\n",
     302             options.cbSwpHeapInit, options.cbSwpHeapMax));
     303    kprintf(("\tcbResHeapInit=0x%08x  cbResHeapMax=0x%08x\n",
     304             options.cbSwpHeapInit, options.cbSwpHeapMax));
     305    kprintf(("Options - Summary - End\n"));
    276306    /* end option summary */
    277307
     
    294324        if (ImportTabInit() != NO_ERROR)
    295325            return STATUS_DONE | STERR | ERROR_I24_QUIET_INIT_FAIL;
     326
     327    /*
     328     * Lock the 32-bit objects/segments and 16-bit datasegment in memory
     329     */
     330    /* 32-bit code segment */
     331    rc = D32Hlp_VMLock2(&CODE32START,
     332                        ((unsigned)&CODE32END & ~0xFFF) - (unsigned)&CODE32START, /* Round down so we don't overlap with the next request. */
     333                        VMDHL_LONG,
     334                        SSToDS(&lhCode));
     335    if (rc != NO_ERROR)
     336        kprintf(("code segment lock failed with with rc=%d\n", rc));
     337
     338    /* 32-bit data segment */
     339    rc = D32Hlp_VMLock2(callTab,
     340                        &CONST32_ROEND - (char*)callTab,
     341                        VMDHL_LONG | VMDHL_WRITE,
     342                        SSToDS(&lhData));
     343    if (rc != NO_ERROR)
     344        kprintf(("data segment lock failed with with rc=%d\n", rc));
     345
     346    /* 16-bit data segment */
     347    rc = D32Hlp_VMLock2(&DATA16START,
     348                        &DATA16_CONSTEND - &DATA16START,
     349                        VMDHL_LONG | VMDHL_WRITE,
     350                        SSToDS(&lhData16));
     351    if (rc != NO_ERROR)
     352        kprintf(("data segment lock failed with with rc=%d\n", rc));
    296353
    297354    return STATUS_DONE;
     
    395452
    396453
     454
     455/**
     456 * Functions which cacluates the instructionsize given a ModR/M byte.
     457 * @returns   Number of bytes to add to cb and pach.
     458 * @param     bModRM  ModR/M byte.
     459 * @status    completely implemented.
     460 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     461 */
     462_Inline int ModR_M_32bit(char bModRM)
     463{
     464    if ((bModRM & 0xc0) == 0x80  /* ex. mov ax,[ebp+11145543h] */
     465        || ((bModRM & 0xc0) == 0 && (bModRM & 0x07) == 5)) /* ex. mov ebp,[0ff231234h] */
     466    {   /* 32-bit displacement */
     467        return 5;
     468    }
     469    else if ((bModRM & 0xc0) == 0x40) /* ex. mov ecx,[esi]+4fh */
     470    {   /* 8-bit displacement */
     471        return 2;
     472    }
     473    /* no displacement (only /r byte) */
     474    return 1;
     475}
     476
     477
     478
     479
     480
    397481/**
    398482 * 32-bit! Interpret function prolog to find where to jmp back.
     
    404488 *                       FALSE: Function is to be imported.
    405489 */
    406 static signed char interpretFunctionProlog32(char *pach, BOOL fOverload)
     490static int interpretFunctionProlog32(char *pach, BOOL fOverload)
    407491{
    408     int cb;
     492    int cb = -3;
     493
     494    kprintf(("interpretFunctionProlog32(0x%08x, %d):\n"
     495             "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
     496             "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
     497             pach, fOverload,
     498             pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
     499             pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
    409500
    410501    /*
     
    416507     *     push ebp
    417508     *     mov ecx, dword ptr [xxxxxxxx]
     509     *
     510     * These are allowed when not overloading:
     511     *     mov eax, imm32
     512     *     jmp short
     513     *  or
     514     *     mov eax, imm32
     515     *     push ebp
    418516     */
    419 
    420     if (pach[0] == 0x55 && pach[1] == 0x8b)
     517    if ((pach[0] == 0x55 && (pach[1] == 0x8b || pach[1] == 0xa1)) /* two first prologs */
     518        ||
     519        (pach[0] == 0xB8 && (pach[5] == 0xEB || pach[5] == 0x55) && !fOverload) /* two last prologs */
     520        )
    421521    {
    422         if (pach[2] == 0xec)
    423             cb = 3;
    424         else
    425             cb = 1;
    426         while (cb < 5)
    427         {
    428             /*
    429              * This is not at all very stable or correct - but it works
    430              * for the current functions.
    431              * There will never be any doubt when something goes wrong!
    432              */
    433             switch(pach[cb])
     522        BOOL fForce;
     523        cb = 0;
     524        while (cb < 5 || fForce)                  /* 5 is the size of a jump instruction. */
     525        {
     526            int cb2;
     527            fForce = FALSE;
     528            switch (*pach)
    434529            {
    435                 case 0x33: /* xor (ldrClose, ldrOpen) */
    436                     cb +=2;
    437                     break;
    438                 case 0x8b:
    439                     if (pach[cb+1] == 0x0d)
    440                         cb += 6;
     530                /* simple one byte prefixes */
     531                case 0x2e:              /* cs segment override */
     532                case 0x36:              /* ss segment override */
     533                case 0x3e:              /* ds segment override */
     534                case 0x26:              /* es segment override */
     535                case 0x64:              /* fs segment override */
     536                case 0x65:              /* gs segment override */
     537                    fForce = TRUE;
     538                    break;
     539
     540                /* simple one byte instructions */
     541                case 0x50:              /* push ax */
     542                case 0x51:              /* push cx */
     543                case 0x52:              /* push dx */
     544                case 0x53:              /* push bx */
     545                case 0x54:              /* push sp */
     546                case 0x55:              /* push bp */
     547                case 0x56:              /* push si */
     548                case 0x57:              /* push di */
     549                    break;
     550
     551                /* simple two byte instructions */
     552                case 0xb0:              /* mov al, imm8 */
     553                case 0xb1:              /* mov cl, imm8 */
     554                case 0xb2:              /* mov dl, imm8 */
     555                case 0xb3:              /* mov bl, imm8 */
     556                case 0xb4:              /* mov ah, imm8 */
     557                case 0xb5:              /* mov ch, imm8 */
     558                case 0xb6:              /* mov dh, imm8 */
     559                case 0xb7:              /* mov bh, imm8 */
     560                case 0x2c:              /* sub al, imm8 */
     561                case 0x34:              /* xor al, imm8 */
     562                case 0x3c:              /* cmp al, imm8 */
     563                case 0x6a:              /* push <byte> */
     564                    pach++;
     565                    cb++;
     566                    break;
     567
     568                /* simple five byte instructions */
     569                case 0xb8:              /* mov eax, imm32 */
     570                case 0xb9:              /* mov ecx, imm32 */
     571                case 0xba:              /* mov edx, imm32 */
     572                case 0xbb:              /* mov ebx, imm32 */
     573                case 0xbc:              /* mov esx, imm32 */
     574                case 0xbd:              /* mov ebx, imm32 */
     575                case 0xbe:              /* mov esi, imm32 */
     576                case 0xbf:              /* mov edi, imm32 */
     577                case 0x2d:              /* sub eax, imm32 */
     578                case 0x35:              /* xor eax, imm32 */
     579                case 0x3d:              /* cmp eax, imm32 */
     580                case 0x68:              /* push <dword> */
     581                    pach += 4;
     582                    cb += 4;
     583                    break;
     584
     585                /* complex sized instructions -  "/r" */
     586                case 0x30:              /* xor r/m8,  r8 */
     587                case 0x31:              /* xor r/m32, r32 */
     588                case 0x32:              /* xor r8,  r/m8 */
     589                case 0x33:              /* xor r32, r/m32 */
     590                case 0x38:              /* cmp r/m8, r8 */
     591                case 0x39:              /* cmp r/m32, r32 */
     592                case 0x3a:              /* cmp r8, r/m8 */
     593                case 0x3b:              /* cmp r32, r/m32 */
     594                case 0x28:              /* sub r/m8, r8 */
     595                case 0x29:              /* sub r/m32, r32 */
     596                case 0x2a:              /* sub r8, r/m8 */
     597                case 0x2b:              /* sub r32, r/m32 */
     598                case 0x8b:              /* mov /r */
     599                case 0x8d:              /* lea /r */
     600                    if ((pach[1] & 0x7) == 4 && (pach[1] & 0xc0) != 0xc0) /* invalid instruction!?! */
     601                        return -1;
     602                    cb += cb2 = ModR_M_32bit(pach[1]);
     603                    pach += cb2;
     604                    break;
     605
     606                /* complex sized instruction - "/5 ib" */
     607                case 0x80:              /* 5: sub r/m8, imm8  7: cmp r/m8, imm8 */
     608                case 0x83:              /* 5: sub r/m32, imm8 7: cmp r/m32, imm8 */
     609                    if ((pach[1] & 0x38) == (5<<3)
     610                        || (pach[1] & 0x38) == (7<<3)
     611                        )
     612                    {
     613                        cb += cb2 = 1 + ModR_M_32bit(pach[1]); /* 1 is the size of the imm8 */
     614                        pach += cb2;
     615                    }
    441616                    else
    442                         cb += 2; /*????!*/
    443                     break;
    444                 case 0x8d: /* lea (ldrRead) */
    445                     cb += 3;
    446                     break;
    447                 case 0x83: /* sub (LDRQAppType) */
    448                     cb += 3;
    449                     break;
     617                    {
     618                        kprintf(("interpretFunctionProlog32: unknown instruction (-3) 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
     619                        return -3;
     620                    }
     621                    break;
     622
     623                /* complex sized instruction - "/digit id" */
     624                case 0x81:              /* sub r/m32, imm32 + more instructions! */
     625                    if ((pach[1] & 0x38) == (5<<3)       /* sub r/m32, imm32  */
     626                        || (pach[1] & 0x38) == (7<<3)    /* cmp r/m32, imm32  */
     627                        )
     628                    {
     629                        cb += cb2 = 4 + ModR_M_32bit(pach[1]); /* 4 is the size of the imm32 */
     630                        pach += cb2;
     631                    }
     632                    else
     633                    {
     634                        kprintf(("interpretFunctionProlog32: unknown instruction (-2) 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
     635                        return -2;
     636                    }
     637                    break;
     638
    450639                default:
    451                     kprintf(("interpretFunctionProlog: unknown instruction 0x%x\n", pach[cb]));
     640                    kprintf(("interpretFunctionProlog32: unknown instruction 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
    452641                    return 0;
    453642            }
    454         }
    455     }
    456     else if (pach[0] == 0x55 && pach[1] == 0xa1) /* ldrEnum32bitRelRecs on WS4eB */
    457     {
    458         cb = 1 + 5;
     643            pach++;
     644            cb++;
     645        }
    459646    }
    460647    else
    461648    {
    462         /* special case for IOSftReadAt and IOSftWriteAt */
    463         if (fOverload == FALSE && pach[0] == 0xB8 && (pach[5] == 0xEB || pach[5] == 0x55))
    464             cb = 5;
    465         else
    466             cb = 0;
     649        kprintf(("interpretFunctionProlog32: unknown prolog start. 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
     650        cb = 0;
    467651    }
    468 
    469     return (signed char)cb;
     652    return cb;
    470653}
    471654
     
    480663 *                       FALSE: Function is to be imported.
    481664 */
    482 static signed char interpretFunctionProlog16(char *pach, BOOL fOverload)
     665static int interpretFunctionProlog16(char *pach, BOOL fOverload)
    483666{
    484     int cb;
    485 
     667    int cb = -7;
     668
     669    kprintf(("interpretFunctionProlog16(0x%08x, %d):\n"
     670             "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
     671             "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
     672             pach, fOverload,
     673             pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
     674             pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
    486675    /*
    487676     * Check for the well known prolog (the only that is supported now)
     
    493682        BOOL fForce;
    494683        cb = 0;
    495         while (cb < 8 || fForce)
     684        while (cb < 8 || fForce)        /* 8 is the size of a 66h prefixed far jump instruction. */
    496685        {
    497686            fForce = FALSE;
     
    528717
    529718                case 0x8b:              /* mov /r */
    530                     if ((pach[1] & 0xc0) == 10  /* ex. mov ax,bp+1114h */
    531                         || ((pach[1] & 0xc0) == 0 && (pach[1] & 0xc0) == 6)) /* ex. mov bp,0ff23h */
     719                    if ((pach[1] & 0xc0) == 0x80  /* ex. mov ax,bp+1114h */
     720                        || ((pach[1] & 0xc0) == 0 && (pach[1] & 0x7) == 6)) /* ex. mov bp,0ff23h */
    532721                    {   /* 16-bit displacement */
    533722                        pach += 3;
     
    548737
    549738                default:
    550                     kprintf(("interpretFunctionProlog: unknown instruction 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
     739                    kprintf(("interpretFunctionProlog16: unknown instruction 0x%x 0x%x 0x%x\n", pach[0], pach[1], pach[2]));
    551740                    return 0;
    552741            }
     
    557746
    558747    fOverload = fOverload;
    559     return (signed char)cb;
     748    return cb;
    560749}
     750
    561751
    562752
     
    601791                 * Verify known function prolog.
    602792                 */
    603                 if (_aImportTab[i].fType & EPT_32BIT)
     793                if (EPT32BitEntry(_aImportTab[i]))
    604794                {
    605795                    cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC32);
    606                     cbmin = 5;
     796                    cbmin = 5; /* Size of the jump instruction */
    607797                }
    608798                else
    609799                {
    610800                    cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC16);
    611                     cbmin = 8;
     801                    cbmin = 7; /* Size of the far jump instruction */
    612802                }
    613803
     
    628818            default:
    629819                kprintf(("VerifyImportTab32: only EPT_PROC is implemented\n",i));
     820                Int3(); /* temporary fix! */
    630821                return STATUS_DONE | STERR | 4;
    631822        }
     
    665856    int i;
    666857    int cb;
    667 
     858    int cbmin;
    668859
    669860    /*
     
    676867            continue;
    677868
    678         if (_aImportTab[i].fType & EPT_32BIT)
     869        if (EPT32BitEntry(_aImportTab[i]))
     870        {
    679871            cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC32);
     872            cbmin = 5; /* Size of the jump instruction */
     873        }
    680874        else
     875        {
    681876            cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC16);
    682         if (cb <= 0 || cb + 5 >= MAXSIZE_PROLOG)
    683         {
    684             kprintf(("ImportTabInit: verify failed for procedure no.%d, cb=%d\n", i, cb));
     877            cbmin = 7; /* Size of the far jump instruction */
     878        }
     879        if (cb <= 0 || cb + cbmin >= MAXSIZE_PROLOG)
     880        {
     881            kprintf(("ImportTabInit: Verify failed for procedure no.%d, cb=%d\n", i, cb));
    685882            return 1;
    686883        }
     
    702899            case EPT_PROC32:
    703900            {
    704                 cb = _aImportTab[i].cbProlog = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, TRUE);
    705                 if (cb > 0 && cb + 5 < MAXSIZE_PROLOG)
    706                 {
     901                cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, TRUE);
     902                _aImportTab[i].cbProlog = (char)cb;
     903                if (cb >= 5 && cb + 5 < MAXSIZE_PROLOG) /* 5(1st): size of jump instruction in the function prolog which jumps to my overloading function */
     904                {                                       /* 5(2nd): size of jump instruction which jumps back to the original function after executing the prolog copied to the callTab entry for this function. */
    707905                    /*
    708906                     * Copy function prolog which will be overwritten by the jmp to calltabl.
     
    743941                Int3();
    744942
    745                 cb = _aImportTab[i].cbProlog = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, TRUE);
    746                 if (cb > 0 && cb + 8 < MAXSIZE_PROLOG) /* a 16:32 jump must be prefixed with 66h in a 16-bit segment */
    747                 {
     943                cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, TRUE);
     944                _aImportTab[i].cbProlog = (char)cb;
     945                if (cb >= 8 && cb + 7 < MAXSIZE_PROLOG) /* 8: size of a 16:32 jump which jumps to my overloading function (prefixed with 66h in a 16-bit segment) */
     946                {                                       /* 7: size of a 16:32 jump which is added to the call tab */
    748947                    /*
    749948                     * Copy function prolog which is to be overwritten.
     
    784983            case EPT_PROCIMPORT32:
    785984            {
    786                 cb = _aImportTab[i].cbProlog = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, FALSE);
    787                 if (cb > 0 && cb + 5 < MAXSIZE_PROLOG)
     985                cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, FALSE);
     986                _aImportTab[i].cbProlog = (char)cb;
     987                if (cb > 0) /* Since no prolog part is copied to the function table, it's ok as long as the prolog has been recognzied. */
    788988                {
    789989                    /*
     
    8111011            case EPT_PROCIMPORT16:
    8121012            {
    813                 cb = _aImportTab[i].cbProlog = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, FALSE);
    814                 if (cb > 0 && cb + 8 < MAXSIZE_PROLOG)
     1013                cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, FALSE);
     1014                _aImportTab[i].cbProlog = (char)cb;
     1015                if (cb > 0) /* Since no prolog part is copied to the function table, it's ok as long as the prolog has been recognzied. */
    8151016                {
    8161017                    /*
     
    8421043            case EPT_VARIMPORT32:
    8431044            case EPT_VARIMPORT16:
     1045                _aImportTab[i].cbProlog = (char)0;
    8441046                *(unsigned long*)(void*)&callTab[i][0] = _aImportTab[i].ulAddress;
    8451047                *(unsigned long*)(void*)&callTab[i][4] = _aImportTab[i].offObject;
  • TabularUnified tags/trunk/src/win32k/dev32/devfirst.asm

    r13379 r13416  
    1 ; $Id: devfirst.asm,v 1.3 2000-02-15 23:39:19 bird Exp $
     1; $Id: devfirst.asm,v 1.4 2000-02-21 04:45:46 bird Exp $
    22;
    33; DevFirst - entrypoint and segment definitions
     
    239239CONST32_ROSTART label byte
    240240CONST32_RO ends
     241
     242_VFT segment
     243_VFTSTART LABEL BYTE
     244_VFT ends
     245
     246EH_DATA segment
     247EH_DATASTART LABEL BYTE
     248EH_DATA ends
     249
    241250END
    242251
  • TabularUnified tags/trunk/src/win32k/dev32/devlast.asm

    r13412 r13416  
    1 ; $Id: devlast.asm,v 1.3 2000-02-20 04:27:23 bird Exp $
     1; $Id: devlast.asm,v 1.4 2000-02-21 04:45:46 bird Exp $
    22;
    33; DevLast - the object file termintating the resident part of the objects.
     
    105105
    106106CONST32_RO segment
    107 CONST32_ROEND db ?
     107CONST32_ROEND LABEL BYTE
    108108CONST32_RO ends
     109
     110_VFT segment
     111_VFTEND LABEL BYTE
     112_VFT ends
     113
     114EH_DATA segment
     115EH_DATAEND LABEL BYTE
     116EH_DATA ends
     117
    109118END
    110119
  • TabularUnified tags/trunk/src/win32k/include/dev16.h

    r13412 r13416  
    1 /* $Id: dev16.h,v 1.6 2000-02-20 04:27:23 bird Exp $
     1/* $Id: dev16.h,v 1.7 2000-02-21 04:45:46 bird Exp $
    22 * dev16 - 16-bit specific. Should not be used in 32-bit C/C++.
    33 *
     
    105105USHORT NEAR dev1Init(PRPINITIN pRpIn, PRPINITOUT pRpOut);
    106106USHORT NEAR R0Init16(PRP_GENIOCTL pRp);
     107USHORT NEAR initGetDosTableData(void);
    107108
    108109
  • TabularUnified tags/trunk/src/win32k/include/dev32.h

    r13412 r13416  
    1 /* $Id: dev32.h,v 1.6 2000-02-20 04:27:23 bird Exp $
     1/* $Id: dev32.h,v 1.7 2000-02-21 04:45:46 bird Exp $
    22 *
    33 * dev32 - header file for 32-bit part of the driver.
     
    8282 * variable into an function call; like the addToModule calls.
    8383 *
    84  * @returns    32-bit FLAT stack pointer.
     84 * Warning - At init-time you have ot make sure that the pulTKSSBase32 pointer is set!
     85 *
     86 * @returns    32-bit FLAT pointer.
    8587 */
    8688#ifdef RING0
  • TabularUnified tags/trunk/src/win32k/include/devSegDf.inc

    r12264 r13416  
    1 ; $Id: devSegDf.inc,v 1.3 1999-11-10 01:45:32 bird Exp $
     1; $Id: devSegDf.inc,v 1.4 2000-02-21 04:45:46 bird Exp $
    22;
    33; Segment definitions for win32k.sys.
     
    2020DATA16_GROUP    group DATA16, DATA16_CONST, DATA16_BSS
    2121
     22
    2223CODE16 segment word public 'CODE' use16
    2324CODE16 ends
     25
    2426
    2527CODE32 segment dword public 'CODE' use32
    2628CODE32 ends
    2729
     30EH_CODE segment dword public 'CODE' use32
     31EH_CODE ends
     32
    2833CALLTAB segment dword public 'DATA' use32
    2934CALLTAB ends
    3035
    31 DGROUP group BSS32, DATA32
     36
     37;DGROUP group BSS32, DATA32
     38DGROUP group BSS32, DATA32, CONST32_RO, _VFT, EH_DATA, CALLTAB
    3239
    3340DATA32  segment dword public 'DATA' use32
     
    4047BSS32 ends
    4148
     49
     50;CONSTGROUP group CONST32_RO, _VFT, EH_DATA
     51
    4252CONST32_RO segment dword public 'CONST' use32
    4353CONST32_RO ends
    4454
     55_VFT segment dword public 'CONST' use32
     56_VFT ends
     57
     58EH_DATA segment byte public 'CONST' use32
     59EH_DATA ends
     60
  • TabularUnified tags/trunk/src/win32k/include/options.h

    r13092 r13416  
    1 /* $Id: options.h,v 1.6 2000-01-24 18:18:59 bird Exp $
     1/* $Id: options.h,v 1.7 2000-02-21 04:45:47 bird Exp $
    22 *
    33 * Options.
     
    4444            o.usCom         = OUTPUT_COM2;          \
    4545            o.fLogging      = FALSE;                \
     46//            o.fLogging      = TRUE;                 \
    4647            o.fKernel       = KF_UNI;               \
    4748            o.ulBuild       = ~0UL;                 \
  • TabularUnified tags/trunk/src/win32k/ldr/calltab.asm

    r13412 r13416  
    1 ; $Id: calltab.asm,v 1.8 2000-02-20 04:27:24 bird Exp $
     1; $Id: calltab.asm,v 1.9 2000-02-21 04:45:47 bird Exp $
    22;
    33; callTab - Call back again table - table with entry for each function which is overrided.
     
    4242; Constants
    4343;
    44 MAXSIZE_PROLOG EQU 10h
     44MAXSIZE_PROLOG EQU 18h
    4545
    4646
  • TabularUnified tags/trunk/src/win32k/ldr/myldrOpen.cpp

    r13407 r13416  
    1 /* $Id: myldrOpen.cpp,v 1.7 2000-02-19 08:40:30 bird Exp $
     1/* $Id: myldrOpen.cpp,v 1.8 2000-02-21 04:45:47 bird Exp $
    22 *
    33 * myldrOpen - ldrOpen.
     
    130130                if (options.fPE == FLAGS_PE_NOT)
    131131                {
    132                     free(pszBuffer);
     132                    rfree(pszBuffer);
    133133                    return NO_ERROR;
    134134                }
     
    208208                            rc = ldrOpen(phFile, "pe.exe", param3);  /* path....! problems! */
    209209                            kprintf(("ldrOpen: pe.exe - open returned with rc = %d\n", rc));
    210                             free(pszBuffer);
     210                            rfree(pszBuffer);
    211211                            return rc;
    212212                        }
    213213                    }
    214214                }
    215                 free(pszBuffer);
     215                rfree(pszBuffer);
    216216                return NO_ERROR;
    217217            }
     
    231231                     * Do nothing more yet. NEED AN ELF LOADER!!!
    232232                     */
    233                     free(pszBuffer);
     233                    rfree(pszBuffer);
    234234                    return NO_ERROR;
    235235                }
     
    273273                {
    274274                    char *pszStart = pach+2;
     275                    kprintf(("ldrOpen: scrtip debug 1\n"));
    275276
    276277                    /* Make sure we don't read to much... */
     
    283284                    while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t'))
    284285                        pszStart++;
     286                    kprintf(("ldrOpen: scrtip debug 2\n"));
    285287
    286288                    /* anything left on the line? */
     
    295297                         */
    296298                        pszEnd = pszStart;
     299                        kprintf(("ldrOpen: scrtip debug 3\n"));
    297300                        //pszFirstArg = NULL;
    298301                        while (*pszEnd != '\0' && *pszEnd != '\r' && *pszEnd != '\n')
     
    314317                        }
    315318                        *pszEnd = '\0';
     319                        kprintf(("ldrOpen: scrtip debug 4\n"));
    316320
    317321                        /*
     
    319323                         */
    320324                        pBuffer = QueryBufferPointerFromFilename(pszFilename);
     325                        kprintf(("ldrOpen: scrtip debug 5\n"));
    321326                        if (pBuffer != NULL)
    322327                        {
    323328                            unsigned cchArguments = getArgsLength(pBuffer->achArgs);
    324329                            kprintf(("ldrOpen: debug1\n"));
     330
     331                            kprintf(("ldrOpen: scrtip debug 6\n"));
    325332
    326333                            /*
     
    329336                            if (cchArguments + cchToAdd < sizeof(pBuffer->achArgs))
    330337                            {
    331                                 kprintf(("ldrOpen: debug2\n"));
     338                                kprintf(("ldrOpen: scrtip debug 7\n"));
    332339                                /*
    333340                                 * Open the interpreter.
     
    337344                                if (rc == NO_ERROR)
    338345                                {
    339                                     kprintf(("ldrOpen: debug3\n"));
     346                                    kprintf(("ldrOpen: scritp debug 8\n"));
    340347                                    /* Make space for the addition arguments. */
    341348                                    memmove(&pBuffer->achArgs[cchToAdd], &pBuffer->achArgs[0], cchArguments);
    342349                                    memcpy(&pBuffer->achArgs[0], pszBuffer, cchToAdd);
    343                                     kprintf(("ldrOpen: debug4\n"));
     350                                    kprintf(("ldrOpen: scrtip debug 9\n"));
    344351                                }
    345352                                else
     
    375382            rc = NO_ERROR;
    376383        }
    377         free(pszBuffer);
     384        rfree(pszBuffer);
    378385    }
    379386    return rc;
  • TabularUnified tags/trunk/src/win32k/win32k.def

    r13407 r13416  
    11;******************************************************************************
    2 ; Copyright 1998 knut st. osmundsen
     2; Copyright 1998-2000 knut st. osmundsen
    33; Definition file for Win32k
    44; Project Odin Software License can be found in LICENSE.TXT
    55;******************************************************************************
    6 PHYSICAL DEVICE WIN32K
    7 DESCRIPTION "$@#knut st. osmundsen:v0.5.0alpha#@Win32k - Odin32, Ring-0 part - Copyright (c) 1998-1999 knut st. osmundsen"
     6PHYSICAL DEVICE Grace
     7DESCRIPTION "$@#knut st. osmundsen:v0.5.0alpha#@Grace - Odin32 and OS2NIX Ring-0 part - Copyright (c) 1998-2000 knut st. osmundsen"
    88
    99CODE PRELOAD EXECUTEREAD
     
    1717    CODE32          class 'CODE'
    1818    CALLTAB         class 'DATA'
    19 ;    CALLTAB         class 'CODE' WRITABLE
    2019    DATA32          class 'DATA'
    2120    c_common        class 'DATA'
    2221    BSS32           class 'BSS'
     22    _VFT            class 'CONST'
    2323    CONST32_RO      class 'CONST'
    2424
    25 
Note: See TracChangeset for help on using the changeset viewer.