Changeset 1467 for trunk/src


Ignore:
Timestamp:
Oct 27, 1999, 4:03:01 AM (26 years ago)
Author:
bird
Message:

Corrections to make win32k work.
(And now it does work, at least at my test machine...)

Location:
trunk/src/win32k
Files:
3 added
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/Makefile

    r1332 r1467  
    11################################################################################
    2 # $Id: Makefile,v 1.9 1999-10-17 02:12:19 bird Exp $
     2# $Id: Makefile,v 1.10 1999-10-27 02:02:52 bird Exp $
    33#
    44# Copyright 1998-1999 knut st. osmundsen
     
    155155        object\asmutils.obj                 \
    156156        object\calltab.obj                  \
    157         object\cout.obj                     \
    158         object\log.obj                      \
    159157        object\malloc.obj                   \
    160158        object\new.obj                      \
     
    163161        object\vsprintf.obj                 \
    164162        object\vprintf.obj                  \
     163        object\avl.obj                      \
    165164        object\ldr.obj                      \
    166165        object\myldrClose.obj               \
     
    169168        object\myLDRQAppType.obj            \
    170169        object\pe2lx.obj
    171 #
    172 #        object\lxSuper.obj                  \
    173 #        object\lxFile.obj                   \
    174 #        object\accelerator.obj              \
    175 #        object\bitmap.obj                   \
    176 #        object\cursor.obj                   \
    177 #        object\cursorgrp.obj                \
    178 #        object\dialog.obj                   \
    179 #        object\icon.obj                     \
    180 #        object\icongrp.obj                  \
    181 #        object\menu.obj                     \
    182 #        object\misc.obj                     \
    183 #        object\pefile.obj                   \
    184 #        object\rcdata.obj                   \
    185 #        object\strings.obj                  \
    186 
     170
     171# not used
     172#         object\cout.obj
    187173
    188174OBJSINIT =                                  \
     
    226212    @mapsym $*.map > nul
    227213    $(CP) $@ $(PDWIN32_BIN)
     214    copy win32k.sym c:\temp
     215    copy win32k.sys c:\temp
    228216
    229217
  • trunk/src/win32k/dev16/d16init.c

    r847 r1467  
    1 /* $Id: d16init.c,v 1.1 1999-09-06 02:19:55 bird Exp $
     1/* $Id: d16init.c,v 1.2 1999-10-27 02:02:53 bird Exp $
    22 *
    33 * d16init - init routines for both drivers.
     
    3333#include <memory.h>
    3434
     35#include "probkrnl.h"
    3536#include "dev1632.h"
    3637#include "dev16.h"
    37 
    3838
    3939/**
     
    6161/**
    6262 * init function - device 1.
    63  * We will send an IOCtl request to the win32i$ (device 0) which will
     63 * We will send an IOCtl request to the elf$ (device 0) which will
    6464 * perform the Ring-0 initiation of the driver.
    6565 * @returns   Status word.
     
    7777    NPSZ            npszErrMsg = NULL;
    7878
    79     rc = DosOpen("\\dev\\win32i$", &hDev0, &usAction, 0UL, FILE_NORMAL,
    80                  OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
    81                  OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
    82                  0UL);
     79    rc = ProbeKernel(pRpIn);
    8380    if (rc == NO_ERROR)
    8481    {
    85         param.pRpInitIn = pRpIn;
    86         rc = DosDevIOCtl(&data, &param, D16_IOCTL_RING0INIT, D16_IOCTL_CAT, hDev0);
    87 /*        _asm int 3; */
     82        rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL,
     83                     OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
     84                     OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
     85                     0UL);
    8886        if (rc == NO_ERROR)
    8987        {
    90             if (data.Status != STATUS_DONE)
    91                 npszErrMsg = "Ring-0 initiation failed\n\r";
     88            param.pRpInitIn = pRpIn;
     89            rc = DosDevIOCtl(&data, &param, D16_IOCTL_RING0INIT, D16_IOCTL_CAT, hDev0);
     90            if (rc == NO_ERROR)
     91            {
     92                if (data.Status != STATUS_DONE)
     93                    npszErrMsg = "Ring-0 initiation failed\n\r";
     94                else
     95                {
     96                    register NPSZ npsz = "Win32k.sys succesfully initiated!\n\r";
     97                    DosPutMessage(1, strlen(npsz)+1, npsz);
     98                    pRpOut->Status = data.Status;
     99                }
     100            }
    92101            else
    93             {
    94                 register NPSZ npsz = "Test.sys succesfully initiated!\n\r";
    95                 DosPutMessage(1, strlen(npsz)+1, npsz);
    96                 pRpOut->Status = data.Status;
    97             }
     102                npszErrMsg = "DosDevIOCtl failed.\n\r";
     103            DosClose(hDev0);
    98104        }
    99105        else
    100             npszErrMsg = "DosDevIOCtl failed\n\r";
    101         DosClose(hDev0);
     106            npszErrMsg = "DosOpen failed.\n\r";
    102107    }
    103108    else
    104         npszErrMsg = "DosOpen failed\n\r";
    105 
     109        npszErrMsg = "ProbeKernel failed.\n\r";
    106110    pRpOut->BPBArray = NULL;
    107111    pRpOut->CodeEnd = (USHORT)&CODE16END;
     
    144148
    145149        pDT2 = (PDOSTABLE2)((char FAR *)pDT + pDT->cul*4 + 1);
    146         TKSSBase16 = pDT2->TKSSBase;
     150        TKSSBase16 = (ULONG)pDT2->pTKSSBase;
    147151        R0FlatCS16 = (USHORT)pDT2->R0FlatCS;
    148152        R0FlatDS16 = (USHORT)pDT2->R0FlatDS;
     
    169173                   )
    170174                {
    171                     /*_asm int 3;*/
    172175                    usRc = CallR0Init32(SSToDS_16(&rp32init));
    173                     /*_asm int 3;*/
    174176                }
    175177                else
    176178                    usRc |= ERROR_I24_INVALID_PARAMETER;
    177179
    178              ((PD16R0INITDATA)pRp->DataPacket)->Status = usRc;
     180                ((PD16R0INITDATA)pRp->DataPacket)->Status = usRc;
    179181
    180182                /* finished - unlock data and parm */
  • trunk/src/win32k/dev16/d16strat.c

    r847 r1467  
    1 /* $Id: d16strat.c,v 1.1 1999-09-06 02:19:55 bird Exp $
     1/* $Id: d16strat.c,v 1.2 1999-10-27 02:02:53 bird Exp $
    22 *
    33 * d16strat.c - 16-bit strategy routine, device headers, device_helper (ptr)
     
    3636{
    3737    {
    38         (unsigned long)(void _far *)(&aDevHdrs[1]),    /* NextHeader */
     38        (unsigned long)(void _far *)(&aDevHdrs[1]), /* NextHeader */
    3939        DEVLEV_3 | DEV_30 | DEV_CHAR_DEV,           /* SDevAtt */
    4040        (unsigned short)(void _near *)strategyAsm0, /* StrategyEP */
    4141        0,                                          /* InterruptEP */
    42         "win32i$ ", /* Later: elf ?*/               /* DevName */
     42        "elf$    ",                                 /* DevName */
    4343        0,                                          /* SDevProtCS */
    4444        0,                                          /* SDevProtDS */
     
    6767USHORT  R0FlatCS16  = 0;
    6868USHORT  R0FlatDS16  = 0;
     69BOOL    fInitTime   = TRUE;
    6970
    7071
     
    7980 * Strategy routine.
    8081 * @returns   Status word.
    81  * @param     pRpH   Pointer to request packed header.
     82 * @param     pRpH   Pointer to request packed header. (Do not change the pointer!)
    8283 * @parma     usDev  Device number.
    8384 * @remark    This function is called from the entrypoint in dev1st.asm
     
    8586USHORT NEAR strategy(PRPH pRpH, unsigned short usDev)
    8687{
     88
    8789    switch (pRpH->Cmd)
    8890    {
    8991        case CMDInit:                   /* INIT command */
    90             if (usDev == 0)
    91                 return dev0Init((PRPINITIN)pRpH, (PRPINITOUT)pRpH);
    92             else
    93                 return dev1Init((PRPINITIN)pRpH, (PRPINITOUT)pRpH);
     92            if (fInitTime)
     93            {
     94                if (usDev == 0)
     95                    return dev0Init((PRPINITIN)pRpH, (PRPINITOUT)pRpH);
     96                else
     97                    return dev1Init((PRPINITIN)pRpH, (PRPINITOUT)pRpH);
     98            }
     99            break;
    94100
    95101        case CMDGenIOCTL:               /* Generic IOCTL */
     
    104110        case CMDShutdown:
    105111            return STATUS_DONE;
     112    }
    106113
    107         default:
    108             return STATUS_DONE | STATUS_ERR_UNKCMD;
    109     }
     114    return STATUS_DONE | STATUS_ERR_UNKCMD;
    110115}
    111116
     
    121126USHORT dev0GenIOCtl(PRP_GENIOCTL pRp)
    122127{
    123 /*    _asm int 3;*/
    124     if (pRp->Category == D16_IOCTL_CAT && pRp->Function == D16_IOCTL_RING0INIT)
    125         return R0Init16(pRp);
     128    USHORT rc;
     129    if (pRp->Category == D16_IOCTL_CAT)
     130    {
     131        switch (pRp->Function)
     132        {
     133            case D16_IOCTL_RING0INIT:
     134                if (fInitTime)
     135                {
     136                    rc = R0Init16(pRp);
     137                    fInitTime = FALSE;
     138                    return rc;
     139                }
     140                break;
     141
     142            case D16_IOCTL_GETKRNLOTES:
     143            {
     144                ULONG ulLin;
     145                if (DevHelp_VirtToLin(SELECTOROF(pRp->DataPacket), OFFSETOF(pRp->DataPacket), &ulLin) != NO_ERROR)
     146                    return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
     147                return CallGetOTEs32(ulLin);
     148            }
     149
     150            case D16_IOCTL_VERIFYPROCTAB:
     151                if (fInitTime)
     152                    return CallVerifyProcTab32();
     153                break;
     154        }
     155    }
    126156
    127157    return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
  • trunk/src/win32k/dev16/probkrnl.c

    r847 r1467  
    1 /* $Id: probkrnl.c,v 1.1 1999-09-06 02:19:55 bird Exp $
     1/* $Id: probkrnl.c,v 1.2 1999-10-27 02:02:53 bird Exp $
    22 *
    33 * Description:   Autoprobes the os2krnl file and os2krnl[*].sym files.
     
    1313 *                How this works:
    1414 *                1. parses the device-line parameters and collects some "SysInfo".
    15  *                2. gets the kernel object table. (win32i$)
     15 *                2. gets the kernel object table. (elf$)
    1616 *                3. finds the kernel image and scans it for a build number.
    1717 *                4. locates and scans the symbol-file(s) for the entrypoints which are wanted.
    18  *                5. the entry points are verified. (win32i$)
     18 *                5. the entry points are verified. (elf$)
    1919 *                6. finished.
    2020 *
     
    2929#ifdef DEBUGR3
    3030    #if 1
     31        int printf(const char *, ...);
    3132        #define dprintf(a) printf a
    3233    #else
     
    3536#else
    3637    #define dprintf(a)
     38    #define static
    3739#endif
    3840
     
    125127static char szMsg1[]     = "\n\r\tFound kernel: ";
    126128static char szMsg1a[]    = "\n\r\tBuild: ";
    127 static char szMsg2[]     = "\n\r\n\r\tFound symbolfile: ";
     129static char szMsg2[]     = "\n\r\tFound symbolfile: ";
    128130static char szMsg4[]     = "\n\r\tFailed to find symbolfile!\n\r";
    129131static char szMsgfailed[]= "failed!";
     
    311313
    312314/**
    313  * kstrlen - String length
    314  * @returns   length of string
    315  * @param     p  Pointer to string
    316  */
    317 static int kstrlen(const char * p)
    318 {
    319     int len = 0;
    320     while ( p[len++] != '\0');
    321     return len-1;
     315 * kstrlen - String length.
     316 * @returns   Length of the string.
     317 * @param     psz  Pointer to string.
     318 * @status    completely implemented and tested.
     319 * @author    knut st. osmundsen
     320 */
     321static int kstrlen(const char * psz)
     322{
     323    int cch = 0;
     324    while (psz[cch] != '\0')
     325        cch++;
     326    return cch;
    322327}
    323328
     
    381386    USHORT          usAction = 0;
    382387
    383     rc = DosOpen("\\dev\\win32i$", &hDev0, &usAction, 0UL, FILE_NORMAL,
     388    rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL,
    384389                 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
    385390                 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
     
    430435    /* read header and display it */
    431436    rc = fread(&MapDef, sizeof(MAPDEF), 1, SymFile);
    432     if ( rc )
     437    if (rc)
    433438    {
    434439        Buffer[0] = MapDef.achModName[0];
     
    591596}
    592597
    593 /* Worker function for ReadOS2Krnl */
     598/**
     599 * Worker function for ReadOS2Krnl
     600 * @returns   0 on success.
     601 *            errorcodes on failure. (-1 >= rc >= -14)
     602 * @param
     603 * @equiv
     604 * @time
     605 * @sketch
     606 * @status
     607 * @author    knut st. osmundsen
     608 * @remark
     609 */
    594610static int ReadOS2Krnl2(HFILE krnl, unsigned long  cbKrnl)
    595611{
     
    722738            if (pObj->o32_size < KrnlOTEs.aObjects[i].ote_size)
    723739                return -12;
     740
     741            #if 0 /* don't work! */
    724742            if ((pObj->o32_flags & 0xffffUL) != (KrnlOTEs.aObjects[i].ote_flags & 0xffffUL))
    725743                return -14;
     744            #endif
    726745        }
    727746    }
     
    764783    USHORT          usAction = 0;
    765784
    766     rc = DosOpen("\\dev\\win32i$", &hDev0, &usAction, 0UL, FILE_NORMAL,
     785    rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL,
    767786                 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
    768787                 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
     
    779798    return rc;
    780799#else
     800    KrnlOTEs.cObjects = 23;
    781801    return 0;
    782802#endif
     
    857877
    858878        /* functions */
    859         if (rc > -50)
     879        if (rc == 0)
    860880        {
    861881            puts(szMsg2);
  • trunk/src/win32k/dev32/d32globals.c

    r847 r1467  
    1 /* $Id: d32globals.c,v 1.1 1999-09-06 02:19:56 bird Exp $
     1/* $Id: d32globals.c,v 1.2 1999-10-27 02:02:53 bird Exp $
    22 *
    33 * d32globals - global data (32-bit)
     
    2121*   Global Variables                                                           *
    2222*******************************************************************************/
    23 ULONG           TKSSBase32;
     23PULONG          pulTKSSBase32;
    2424struct options  options;
    2525
  • trunk/src/win32k/dev32/d32hlp.asm

    r847 r1467  
    1 ; $Id: d32hlp.asm,v 1.1 1999-09-06 02:19:56 bird Exp $
     1; $Id: d32hlp.asm,v 1.2 1999-10-27 02:02:54 bird Exp $
    22;
    33; d32hlp - 32-bit Device Driver Helper Function.
    44;
    55; Copyright (c) 1999 knut st. osmundsen
     6;
     7; Project Odin Software License can be found in LICENSE.TXT
    68;
    79    .386p
  • trunk/src/win32k/dev32/d32init.c

    r847 r1467  
    1 /* $Id: d32init.c,v 1.1 1999-09-06 02:19:56 bird Exp $
     1/* $Id: d32init.c,v 1.2 1999-10-27 02:02:54 bird Exp $
    22 *
    33 * d32init.c - 32-bits init routines.
     
    1212#define MAXSIZE_PROLOG 0x10             /* Note that this must be synced with */
    1313                                        /* the one used in calltab.asm.       */
     14#define static
    1415
    1516#define INCL_DOSERRORS
     
    3132#include "log.h"
    3233#include "asmutils.h"
    33 #include "cout.h"
    3434#include "malloc.h"
    3535#include "ldr.h"
     
    5858 * @returns   Status word.
    5959 * @param     pRpInit  Pointer init request packet.
     60 * @sketch    Set TKSSBase32.
     61 *            Set default parameters.
     62 *            Parse command line options.
     63 *            Show (kprint) configuration.
     64 *            Init heap.
     65 *            Init ldr.
     66 *            Init procs. (overloaded ldr procedures)
     67 * @status    completely implemented.
     68 * @author    knut st. osmundsen
    6069 */
    6170USHORT _loadds _Far32 _Pascal R0Init32(RP32INIT *pRpInit)
     
    6473    char *pszTmp;
    6574
    66     TKSSBase32 = _TKSSBase16;
     75    pulTKSSBase32 = (PULONG)_TKSSBase16;
    6776
    6877    SET_OPTIONS_TO_DEFAULT(options);
     
    8089        switch (*pszTmp)
    8190        {
    82             case 'C': /* -C[1|2] - com-port no */
     91            case 'C': /* -C[1|2] - com-port no, def:-C2 */
    8392                switch (pszTmp[1])
    8493                {
     
    8695                        options.usCom = OUTPUT_COM1;
    8796                        break;
     97
    8898                    case '2':
     99                    default:
    89100                        options.usCom = OUTPUT_COM2;
    90                         break;
    91101                }
    92102                break;
    93103
    94             case 'L': /*-L:[Y|N or ]*/
     104            case 'L': /* -L[..]<:|=| >[<Y..|E..| > | <N..|D..>] */
    95105                pszTmp2 = strpbrk(pszTmp, ":=/- ");
    96                 if (pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1 && (*pszTmp2 == '=' || *pszTmp2 == ':' || *pszTmp2 == ' ' && (pszTmp2[1] != '-' || pszTmp2[1] != '/')))
    97                 {
    98                     switch (pszTmp2[1])
    99                     {
    100                         case 'D': /*disable*/
    101                             options.fLogging = FALSE;
    102                             break;
    103                         case 'E': /*enable*/
    104                             options.fLogging = TRUE;
    105                             break;
    106                         case 'Y': /*yes*/
    107                             options.fLogging = TRUE;
    108                             break;
    109                         case 'N': /*no*/
    110                             options.fLogging = FALSE;
    111                             break;
    112                     }
    113                 }
     106                if (pszTmp2 != NULL && (int)(pszTmp2-pszTmp) < cch-1
     107                    && (pszTmp2[1] == 'N' ||pszTmp2[1] == 'n' || pszTmp2[1] == 'D' || pszTmp2[1] == 'd')
     108                    )
     109                    options.fLogging = FALSE;
    114110                else
    115111                    options.fLogging = TRUE;
     
    126122
    127123            case 'V': /* verbose initialization */
    128                 options.fQuiet = TRUE;
     124                options.fQuiet = FALSE;
    129125                break;
    130126
     
    164160     * init sub-parts
    165161     */
    166 
    167162    /* heap */
    168163    if (heapInit(HEAP_SIZE) != NO_ERROR)
    169164        return STATUS_DONE | STERR | ERROR_I24_QUIET_INIT_FAIL;
    170 
    171     /* cout init */
    172     coutInit(options.usCom);
    173165
    174166    /* loader */
     
    201193        {
    202194            kprintf(("VerifyProcTab32: procedure no.%d was not found!\n", i));
    203             return 1;
    204         }
    205 
    206         /* verify read/writeable. - NOT IMPLEMENTED (yet) */
     195            return STATUS_DONE | STERR | 1;
     196        }
     197
     198        /* verify read/writeable. - FIXME */
     199        if (_aProcTab[i].ulAddress < 0xffe00000UL)
     200        {
     201            kprintf(("VerifyProcTab32: procedure no.%d has an invlalid address, %#08x!\n",
     202                     i, _aProcTab[i].ulAddress));
     203            return STATUS_DONE | STERR | 2;
     204        }
    207205
    208206        /* verify known function prolog. (only EPT_PROC) */
     
    212210            {
    213211                kprintf(("VerifyProcTab32: verify failed for procedure no.%d\n",i));
    214                 return 2;
     212                return STATUS_DONE | STERR | 3;
    215213            }
    216214        }
     
    218216        {
    219217            kprintf(("VerifyProcTab32: only EPT_PROC is implemented\n",i));
    220             return 3;
    221         }
    222     }
    223 
    224     return 0;
     218            return STATUS_DONE | STERR | 4;
     219        }
     220    }
     221
     222    return STATUS_DONE;
    225223}
    226224
     
    228226/**
    229227 * Get kernel OTEs
    230  * @returns   0 if ok. !0 on failiure.
     228 * @returns   Strategy return code:
     229 *            STATUS_DONE on success.
     230 *            STATUS_DONE | STERR | errorcode on failure.
    231231 * @param     pOTEBuf  Pointer to output buffer.
     232 * @status    completely implemented and tested.
     233 * @author    knut st. osmundsen
    232234 * @remark    Called from IOCtl.
    233235 */
     
    271273        kprintf(("GetOTEs32: failed. usRc = %d\n", usRc));
    272274
    273     return usRc;
     275    return usRc | (usRc != 0 ? STATUS_DONE | STERR : STATUS_DONE);
    274276}
    275277
     
    292294     *     push ebp
    293295     *     mov ebp,esp
     296     *  or
     297     *     push ebp
     298     *     mov ecx, dword ptr [123407452]
    294299     */
    295300
    296     if (p[0] == 0x55 && p[1] == 0x8b && p[2] == 0xec)
    297     {
    298         rc = 3;
     301    if (p[0] == 0x55 && p[1] == 0x8b)
     302    {
     303        if (p[2] == 0xec)
     304            rc = 3;
     305        else
     306            rc = 1;
    299307        while (rc < 5)
    300308        {
     
    308316                case 0x33: /* xor (ldrClose, ldrOpen) */
    309317                    rc +=2;
     318                    break;
     319                case 0x8b:
     320                    if (p[rc+1] == 0x0d)
     321                        rc += 6;
     322                    else
     323                        rc += 2; /*????!*/
    310324                    break;
    311325                case 0x8d: /* lea (ldrRead) */
     
    341355    for (i = 0; i < NUMBER_OF_PROCS; i++)
    342356    {
    343         if ((cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress)) <= 0 && cb + 5 >= MAXSIZE_PROLOG)
    344         {
    345             kprintf(("rehookFunctions: verify failed for procedure no.%d\n", i));
     357        cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress);
     358        if (cb <= 0 || cb + 5 >= MAXSIZE_PROLOG)
     359        {
     360            kprintf(("rehookFunctions: verify failed for procedure no.%d, cb=%d\n", i, cb));
    346361            return 1;
    347362        }
     
    369384
    370385            /* copy function prolog */
    371             memcpy(callTab[i], (char*)_aProcTab[i].ulAddress, cb);
     386            memcpy(callTab[i], (void*)_aProcTab[i].ulAddress, (size_t)cb);
    372387
    373388            /* jump from calltab to original function */
     
    386401            return 1;
    387402        }
    388         i++;
    389403    }
    390404
  • trunk/src/win32k/dev32/devfirst.asm

    r847 r1467  
    1 ; $Id: devfirst.asm,v 1.1 1999-09-06 02:19:56 bird Exp $
     1; $Id: devfirst.asm,v 1.2 1999-10-27 02:02:54 bird Exp $
    22;
    33; DevFirst - entrypoint and segment definitions
     
    55; Copyright (c) 1999 knut st. osmundsen
    66;
     7; Project Odin Software License can be found in LICENSE.TXT
    78;
    89    .386p
     
    1213;
    1314    include devsegdf.inc
     15    include sas.inc
    1416
    1517;
     
    2931    public _strategyAsm0
    3032    public _strategyAsm1
     33    public _CallGetOTEs32
    3134    public _SSToDS_16a
     35    public GetOS2KrnlMTE
    3236
    3337
     
    3539; Externs
    3640;
     41    extrn _TKSSBase16:dword
     42    extrn GETOTES32:FAR
     43    .286p
    3744    extrn _strategy:near
    38     extrn CODE16END:byte
    39     extrn DATA16END:byte
    40     extrn _TKSSBase16:dword
    4145
    4246
     
    4650CODE16START label byte
    4751
     52    .286p
    4853;$win32ki entry point
    4954_strategyAsm0:
     
    5661    jmp     _strategyAsm
    5762
     63;;
     64; Stub which pushes parameters onto the stack and call the 16-bit C strategy routine.
     65; @returns   returns the return value of strategy(...)
     66; @author    knut st. osmundsen
    5867_strategyAsm proc far
    5968    push    es
     
    6675    mov     word ptr es:[bx+3], ax
    6776    add     sp, 2
    68 ;    int 3
    6977    retf
    7078_strategyAsm endp
    7179
    7280
    73 ;extern LIN   SSToDS_16a(void NEAR *pStackVar);
     81    .386p
     82;;
     83; Thunk procedure for R0Init32.
     84; @cproto    USHORT NEAR CallGetOTEs32(ULONG addressOTEBuf);
     85; @returns   Same as GetOTEs32.
     86; @param     addressOTEBuf  32-bit pointer to request data.
     87; @status    completely implemented.
     88; @author    knut st. osmundsen
     89_CallGetOTEs32 PROC NEAR
     90    ASSUME CS:CODE16
     91    push    ds
     92    push    word ptr [esp+6]            ; push high word.
     93    push    word ptr [esp+6]            ; push low word.
     94    call    far ptr FLAT:GETOTES32
     95    pop     ds
     96    retn
     97_CallGetOTEs32 ENDP
     98
     99
     100;;
     101; SSToDS - stack pointer to Flat pointer.
     102; @cproto    extern LIN   SSToDS_16a(void NEAR *pStackVar);
     103; @returns   ax:dx  makes up a 32-bit flat pointer to stack.
     104; @param     pStackVar  Stack pointer which is to be made a flat pointer.
     105; @equiv     SSToDS in 32-bit code.
     106; @sketch    Get Flat CS
     107;            Get TKSSBase address. (FLAT)
     108;            return *TKSSBase + pStackVar.
     109; @status    completely  implemented.
     110; @author    knut st. osmundsen
     111; @remark    es is cs, not ds!
    74112_SSToDS_16a proc near
    75113    assume CS:CODE16, DS:DATA16, ES:NOTHING
     114    mov     edx, ds:_TKSSBase16         ; get pointer held by _TKSSBase16 (pointer to stack base)
     115    call    far ptr FLAT:far_getCS      ; get flat selector.
    76116    push    es
    77     jmp far ptr FLAT:_SSToDS_16a_GetFLAT_32
    78 _SSToDS_16a_GetFLAT_16::
    79     mov     edx, ds:_TKSSBase16
    80     movzx   eax, word ptr ss:[esp + 4]
    81     add     eax, es:[edx]
     117    mov     es,  ax
     118    assume  es:FLAT
     119    mov     eax, es:[edx]               ; get pointer to stack base
     120    pop     es
     121    movzx   edx, word ptr ss:[esp + 2]  ; 16-bit stack pointer (parameter)
     122    add     eax, edx                    ; 32-bit stack pointer in eax
    82123    mov     edx, eax
    83     shr     edx, 16
    84     pop     es
     124    shr     edx, 16                     ; dx high 16-bit of 32-bit stack pointer.
    85125    ret
    86126_SSToDS_16a endp
     
    88128CODE16 ends
    89129
     130
     131;
     132; all segments have a <segmentname>START label at the start of the segment.
     133;
     134
    90135CODE32 segment
    91136CODE32START label byte
    92     ASSUME CS:CODE32
    93 _SSToDS_16a_GetFLAT_32:
    94     push    cs
    95     pop     es
    96     jmp far ptr CODE16:_SSToDS_16a_GetFLAT_16
     137
     138;;
     139; Gets the current cs.
     140; @cproto    none.
     141; @returns   CS
     142; @author    knut st. osmundsen
     143; @remark    internal method. called from 16-bit code...
     144far_getCS proc far
     145    ASSUME DS:nothing, ES:nothing
     146    mov     ax,  cs
     147    retf
     148far_getCS endp
     149
     150
     151
     152;;
     153; Gets the a 32-bit flat pointer to the OS/2 Kernel MTE.
     154; @cproto    extern PMTE _System GetOS2KrnlMTE(void);
     155; @returns   Pointer to kernel MTE.
     156; @status    completely implemented.
     157; @author    knut st. osmundsen
     158GetOS2KrnlMTE PROC NEAR
     159    push    es
     160
     161    mov     ax,  SAS_selector               ;70h - Read-only SAS selector.
     162    mov     es,  ax
     163    xor     ebx, ebx
     164    assume  ebx: PTR SAS
     165    mov     bx,  es:[ebx].SAS_vm_data       ;SAS_vm_data (0ch)
     166    assume  ebx: PTR SAS_vm_section
     167    mov     eax, es:[ebx].SAS_vm_krnl_mte   ;SAS_vm_krnl_mte (0ch)
     168
     169    pop     es
     170    ret
     171GetOS2KrnlMTE ENDP
    97172
    98173CODE32 ends
    99174
    100175
    101 ;
    102 ; all segments have a <segmentname>START label at the start of the segment.
    103 ;
    104176DATA16 segment
    105177DATA16START label byte
  • trunk/src/win32k/dev32/devlast.asm

    r847 r1467  
    1 ; $Id: devlast.asm,v 1.1 1999-09-06 02:19:56 bird Exp $
    2 ; DevLast - the last object file which is resident all the time.
    3 ; Object files which are linked in after this is discarded after init.
     1; $Id: devlast.asm,v 1.2 1999-10-27 02:02:54 bird Exp $
     2;
     3; DevLast - the object file termintating the resident part of the objects.
     4; Code after the ???END labes and object files and which are linked in
     5; after this file is discarded after init.
    46;
    57; Copyright (c) 1999 knut st. osmundsen
    68;
     9; Project Odin Software License can be found in LICENSE.TXT
    710;
    811       .model flat
     
    2831    public CONST32_ROEND
    2932    public _CallR0Init32
    30 
     33    public _CallVerifyProcTab32
    3134
    3235
     
    4952
    5053extrn R0INIT32:FAR
     54extrn VERIFYPROCTAB32:FAR
    5155
    5256CODE16 segment
    53     ASSUME CS:CODE16
    5457CODE16END db ?
    5558
    56 
     59;;
     60; Thunk procedure for R0Init32.
     61; @cproto    USHORT NEAR CallR0Init32(LIN pRpInit);
     62; @returns   Same as R0Init32.
     63; @param     pRpInit  32-bit pointer to request packet.
     64; @status    completely implemented.
     65; @author    knut st. osmundsen
    5766_CallR0Init32 PROC NEAR
     67    ASSUME CS:CODE16
    5868    push    ds
    59     push    word ptr [esp+4]
    60     push    word ptr [esp+8]
     69    push    word ptr [esp+6]            ; push high word.
     70    push    word ptr [esp+6]            ; push low word.
    6171    call    far ptr FLAT:R0INIT32
    6272    pop     ds
    6373    retn
    6474_CallR0Init32 ENDP
     75
     76
     77;;
     78; Thunk procedure for VerifyProcTab32.
     79; @cproto    USHORT NEAR CallVerifyProcTab32(void);
     80; @returns   Same as VerifyProcTab32.
     81; @status    completely implemented.
     82; @author    knut st. osmundsen
     83_CallVerifyProcTab32 PROC NEAR
     84    ASSUME CS:CODE16
     85    push    ds
     86    call    far ptr FLAT:VERIFYPROCTAB32
     87    pop     ds
     88    retn
     89_CallVerifyProcTab32 ENDP
     90
    6591CODE16 ends
     92
    6693
    6794CODE32 segment
  • trunk/src/win32k/include/OS2Krnl.h

    r847 r1467  
    1 /* $Id: OS2Krnl.h,v 1.1 1999-09-06 02:19:57 bird Exp $
     1/* $Id: OS2Krnl.h,v 1.2 1999-10-27 02:02:55 bird Exp $
    22 *
    33 * OS/2 kernel structures, typedefs and macros.
     
    1010#pragma pack(1)
    1111
    12 #ifndef RING0_DEBUG_IN_RING3
    13     typedef USHORT SFN,*PSFN;         /* system file number */
     12#ifdef RING0
     13    typedef USHORT SFN, *PSFN;         /* system file number */
    1414#else
    1515    #define SFN HFILE
  • trunk/src/win32k/include/asmutils.h

    r847 r1467  
    1 /* $Id: asmutils.h,v 1.1 1999-09-06 02:19:57 bird Exp $
     1/* $Id: asmutils.h,v 1.2 1999-10-27 02:02:55 bird Exp $
    22 *
    33 * Assembly utilities.
     
    2929extern void __stdcall memmov(void *p, signed int off, unsigned int len);
    3030
    31 #ifdef _OS2Krnl_h_
    32 extern PMTE _System GetOS2KrnlMTE(void);
    33 #endif
    34 
    3531#ifdef __cplusplus
    3632}
  • trunk/src/win32k/include/cout.h

    r847 r1467  
    1 /* $Id: cout.h,v 1.1 1999-09-06 02:19:57 bird Exp $
     1/* $Id: cout.h,v 1.2 1999-10-27 02:02:55 bird Exp $
    22 *
    33 * cout - cout replacement.
     
    66 *
    77 */
     8
     9#error("Not used! Use kprintf/dprintf!")
    810
    911#ifndef _cout_h_
  • trunk/src/win32k/include/dev16.h

    r847 r1467  
    1 /* $Id: dev16.h,v 1.1 1999-09-06 02:19:57 bird Exp $
     1/* $Id: dev16.h,v 1.2 1999-10-27 02:02:56 bird Exp $
    22 * dev16 - 16-bit specific. Should not be used in 32-bit C/C++.
    33 *
     
    4242#define D16_IOCTL_VERIFYPROCTAB     0x42
    4343
    44 
    4544/**
    46  * Regards goes to Matthieu Willm for this!
     45 * Regards goes to Matthieu Willm for (parts of) this!
    4746 */
     47#ifdef INCL_16
     48    typedef void FAR * FPVOID;
     49#else
     50    typedef ULONG FPVOID;
     51#endif
    4852typedef struct _DosTable /* dt */
    4953{
    5054    UCHAR  cul;             /* count of entries (dwords) in this table.*/
    51     ULONG  notinterestingAtAll;
     55    FPVOID fph_HardError;
     56    FPVOID fph_UCase;
     57    ULONG  UnknownOrReserved1;
     58    ULONG  UnknownOrReserved2;
     59    ULONG  UnknownOrReserved3;
     60    FPVOID fph_MemMapAlias;
     61    FPVOID fph_MemUnmapAlias;
     62    FPVOID fph_GoProtAll;
     63    FPVOID fph_GoRealAll;
     64    FPVOID fph_doshlp_RedirDev;
     65    ULONG  UnknownOrReserved4;
     66    ULONG  UnknownOrReserved5;
     67    FPVOID fph_SFFromSFN;
     68    FPVOID fph_SegGetInfo;
     69    FPVOID fph_AsgCheckDrive;
     70    ULONG  UnknownOrReserved6;
     71    ULONG  UnknownOrReserved7;
    5272} DOSTABLE, FAR *PDOSTABLE , NEAR *NPDOSTABLE;
    5373
     
    5575{
    5676    UCHAR  cul;             /* count of entries (dwords) in this table.*/
    57     ULONG  notinteresting0;
    58     ULONG  notinteresting1;
    59     ULONG  notinteresting2;
    60     ULONG  notinteresting3;
    61     ULONG  notinteresting4;
    62     ULONG  notinteresting5;
    63     ULONG  notinteresting6;
    64     ULONG  notinteresting7;
    65     ULONG  notinteresting8;
     77    FPVOID fpErrMap24;
     78    FPVOID fpErrMap24End;
     79    FPVOID fpErr_Table_24;
     80    FPVOID fpCDSAddr;
     81    FPVOID fpGDT_RDR1;
     82    FPVOID fpInterrupLevel;
     83    FPVOID fp_cInDos;
     84    ULONG  UnknownOrReserved1;
     85    ULONG  UnknownOrReserved2;
    6686    ULONG  R0FlatCS;
    6787    ULONG  R0FlatDS;
    68     ULONG  TKSSBase;
    69     ULONG  notinterestingC;
    70     ULONG  notinterestingD;
    71     ULONG  notinterestingE;
    72     ULONG  notinterestingF;
    73     ULONG  ReserveVM;
    74     ULONG  notinterestingH;
    75     ULONG  notinterestingI;
     88    LIN    pTKSSBase;
     89    LIN    pintSwitchStack;
     90    LIN    pprivatStack;
     91    FPVOID fpPhysDiskTablePtr;
     92    LIN    pforceEMHandler;
     93    LIN    pReserveVM;
     94    LIN    p_pgpPageDir;
     95    ULONG  UnknownOrReserved3;
    7696} DOSTABLE2, FAR *PDOSTABLE2 , NEAR *NPDOSTABLE2;
    7797
     
    89109 */
    90110USHORT NEAR CallR0Init32(LIN pRpInit);
    91 
     111USHORT NEAR CallGetOTEs32(ULONG addressOTEBuf);
     112USHORT NEAR CallVerifyProcTab32(void);
    92113
    93114/*
  • trunk/src/win32k/include/dev32.h

    r1269 r1467  
    1 /* $Id: dev32.h,v 1.2 1999-10-14 01:16:49 bird Exp $
     1/* $Id: dev32.h,v 1.3 1999-10-27 02:02:56 bird Exp $
    22 *
    33 * dev32 - header file for 32-bit part of the driver.
     
    4848 * Function prototypes.
    4949 */
    50 #ifndef __cplusplus
     50#if !defined(__cplusplus) && defined(RING0)
    5151USHORT _loadds _Far32 _Pascal R0Init32(RP32INIT *pRpInit);
    5252USHORT _loadds _Far32 _Pascal GetOTEs32(PKRNLOBJTABLE pOTEBuf);
    5353USHORT _loadds _Far32 _Pascal VerifyProcTab32(void);
    5454#endif
     55#ifdef _OS2Krnl_h_
     56PMTE _System GetOS2KrnlMTE(void); /* (devfirst.asm) */
     57#endif
     58
    5559
    5660/*
    5761 * Global variables
    5862 */
    59 extern ULONG TKSSBase32;
     63extern PULONG pulTKSSBase32;
    6064
    6165/*
    62  * Macros
     66 * SSToDS( stack pointer )
     67 *
     68 * In RING-0 this translates pointers to stack memory in the
     69 * Stack Segment (SS) to pointers to stack memory in the
     70 * Data Segment (DS). SS is 16-bit compatible, DS is 32-bit flat.
     71 * It is vitally important to use this macro whenever creating
     72 * a pointer to stack memory which don't implies that is a pointer
     73 * relative to SS. For example when passing the pointer to an stack
     74 * variable into an function call; like the addToModule calls.
     75 *
     76 * @returns    32-bit FLAT stack pointer.
    6377 */
    64 #define SSToDS(a)   ((PVOID)((ULONG)(a) + TKSSBase32))
     78#ifdef RING0
     79    #define SSToDS(a)   ((PVOID)((ULONG)(a) + *pulTKSSBase32))
     80#else
     81    #define SSToDS(a)   ((PVOID)(a))
     82#endif
    6583
    6684#ifdef __cplusplus
  • trunk/src/win32k/include/devSegDf.inc

    r847 r1467  
    1 ; $Id: devSegDf.inc,v 1.1 1999-09-06 02:19:58 bird Exp $
     1; $Id: devSegDf.inc,v 1.2 1999-10-27 02:02:56 bird Exp $
    22;
    33; Segment definitions for win32k.sys.
     
    2424CODE32 ends
    2525
    26 CALLTAB segment dword public 'CODE' use32
     26CALLTAB segment dword public 'DATA' use32
    2727CALLTAB ends
    2828
  • trunk/src/win32k/include/ldr.h

    r1269 r1467  
    1 /* $Id: ldr.h,v 1.2 1999-10-14 01:16:49 bird Exp $
     1/* $Id: ldr.h,v 1.3 1999-10-27 02:02:56 bird Exp $
    22 *
    33 * ldr - loader header file.
     
    1414        extern BOOL fQAppType;
    1515
    16         /***************************************************************/
    17         /* handle state - Array of handle states. Four state per byte! */
    18         /***************************************************************/
     16        /*
     17         * handle state - Array of handle states. Eight state per byte!
     18         */
    1919        #define MAX_FILE_HANDLES 0x10000
    2020
     
    3131
    3232
    33         /**************/
    34         /* PE handles */
    35         /**************/
    36         typedef struct _PENode
     33        /*
     34         * Module struct.
     35         */
     36        typedef struct _Module
    3737        {
    38             /* linking stuff */
    39             struct _PENode *left;
    40             struct _PENode *right;
     38            AVLNODECORE     coreKey;    /* Key is hFile. */
     39            AVLNODECORE     coreMTE;    /* Key is pMTE. */
    4140
    42             /* key */
    43             SFN hFile;                      /* system file number or file handle if you prefer that */
     41            SFN             hFile;      /* System file number or file handle if you prefer that. */
     42            PMTE            pMTE;       /* Pointer to MTE if we got one - NULL is allowed. */
    4443
    45             /* misc */
    46             PMTE pMTE;                      /* pointer to MTE if we got one - may be NULL */
     44            ULONG           fFlags;     /* Flags. Flags if coreMte is in use and what Data contains. */
     45            union
     46            {
     47                Pe2Lx *     pPe2Lx;     /* Pointer to a Pe2Lx object. (Win32 executables) */
     48                #if 0
     49                Elf2Lx *    pElf2Lx;    /* Pointer to a Elf2Lx object. (ELF executables) */
     50                Script *    pScript;    /* Pointer to a Script object. (Shell scripts) */
     51                Pe *        pPe;        /* Pointer to a Pe object. (Ring3 loader) */
     52                #endif
     53                void *      pv;
     54            } Data;                     /* Pointer to data. Currently it's allways a Pe2Lx object! */
     55        } MODULE, *PMODULE;
    4756
    48             /* Pe2Lx object */
    49             Pe2Lx *pPe2Lx;
    50         } PENODE, *PPENODE;
     57        #define MOD_FLAGS_IN_MTETREE    0x00000010 /* The node is present in the MTE-tree. */
     58        #define MOD_TYPE_MASK           0x0000000F /* Type mask. */
     59        #define MOD_TYPE_PE2LX          0x00000001 /* Pe2Lx module. */
     60        #define MOD_TYPE_ELF2LX         0x00000002 /* Elf2Lx module. */
     61        #define MOD_TYPE_SCRIPT         0x00000003 /* Script module. */
     62        #define MOD_TYPE_PE             0x00000004 /* Pe module. */
    5163
    52         #define SIZEOF_NODE (sizeof(NODE))
    5364
    54         ULONG       insertNode(PPENODE pNode);
    55         ULONG       deleteNode(SFN key);        /* removes from tree and freeNode */
    56         PPENODE     getNodePtr(SFN key);
    57         PPENODE     findNodePtr(const char *pszFilename);
    58         ULONG       depthPE(void);
    59         PPENODE     allocateNode(void);
    60         ULONG       freeNode(PPENODE pNode);    /* don't remove from tree! */
     65        /*
     66         * Modules operations.
     67         */
     68        PMODULE     getModuleBySFN(SFN hFile);
     69        PMODULE     getModuleByMTE(PMTE pMTE);
     70        PMODULE     getModuleByFilename(PCSZ pszFilename);
    6171
    62         /* if sequential insertion - this will give a lower tree. */
    63         /* testing shows that 3 gives best results for 27 to 134 nodes */
    64         #define ROTATION 3
    65         #define AdjustKey(a) ((USHORT)(a << 16-ROTATION) | (USHORT)(a >> ROTATION) )
    66         #define UnAdjustKey(a) ((USHORT)(a >> 16-ROTATION) | (USHORT)(a << ROTATION) )
     72        ULONG       addModule(SFN hFile, PMTE pMTE, ULONG fFlags, void *pData);
     73        ULONG       removeModule(SFN hFile);
    6774
    6875    #endif
     76
    6977    /*************/
    7078    /* functions */
  • trunk/src/win32k/include/log.h

    r1269 r1467  
    1 /* $Id: log.h,v 1.2 1999-10-14 01:16:50 bird Exp $
     1/* $Id: log.h,v 1.3 1999-10-27 02:02:56 bird Exp $
    22 *
    33 * log - C-style logging - kprintf.
     
    55 *
    66 * Copyright (c) 1998-1999 knut st. osmundsen
     7 *
     8 * Project Odin Software License can be found in LICENSE.TXT
    79 *
    810 */
     
    1517#endif
    1618
     19/*
     20 * COM-Port port numbers.
     21 */
    1722#define OUTPUT_COM1 0x3f8
    1823#define OUTPUT_COM2 0x2f8
     24
    1925
    2026/*
     
    2632    #include "vprintf.h"
    2733    #define kprintf(a)          printf a
    28     #define kernel_printf(a)    printf a, printf("\n") /* obsolete */
    2934#else
    3035    #define kprintf(a)          (void)0
    31     #define kernel_printf(a)    (void)0
    3236#endif
    3337
  • trunk/src/win32k/include/malloc.h

    r1269 r1467  
    1 /* $Id: malloc.h,v 1.2 1999-10-14 01:16:50 bird Exp $
     1/* $Id: malloc.h,v 1.3 1999-10-27 02:02:57 bird Exp $
    22 *
    33 * Heap.
     
    4646#define MAXPTR _uHeapMaxPtr
    4747
    48 #define HEAP_SIZE 0x00600000U /* 10MB of heap */
     48/*#define HEAP_SIZE 0x00600000U*/ /* 10MB of heap */
     49#define HEAP_SIZE 0x100000U /* 1MB of heap */
    4950
    5051/* HeapPointer assert - old ones... */
  • trunk/src/win32k/include/options.h

    r847 r1467  
    1 /* $Id: options.h,v 1.1 1999-09-06 02:19:59 bird Exp $
     1/* $Id: options.h,v 1.2 1999-10-27 02:02:57 bird Exp $
     2 *
    23 * Options.
    34 *
    45 * Copyright (c) 1998-1999 knut st. osmundsen
     6 *
     7 * Project Odin Software License can be found in LICENSE.TXT
    58 *
    69 */
     
    912#define _options_h_
    1013
     14/*******************************************************************************
     15*   Defined Constants And Macros                                               *
     16*******************************************************************************/
    1117/* fKernel */
    1218#define KF_UNI      0x00000000UL
    1319#define KF_SMP      0x00000001UL
    1420
     21/* Set defaults. */
     22#define SET_OPTIONS_TO_DEFAULT(o)            \
     23            o.fQuiet         = 0;            \
     24            o.usCom          = OUTPUT_COM2;  \
     25            o.fLogging       = 0;            \
     26            o.ulBuild        = ~0;           \
     27            o.fKernel        = KF_UNI;       \
     28            o.usVerMajor     = ~0;           \
     29            o.usVerMinor     = ~0;
    1530
     31
     32/*******************************************************************************
     33*   Structures and Typedefs                                                    *
     34*******************************************************************************/
    1635/** Option struct */
    1736struct options
     
    3958    /** @cat Options affecting the generated LX executable */
    4059    //******************************************************/
    41     int noExeTIBFix;        /* ask win32k for initstuff (win32k only) */
    42     int AlignSections;      /* don't align sections */
    43     //int TIBFixObject;       /* make a TIBFix object - AlignSections = 0 */
    44 
    45     int lxoffset;           /* if true use the fixed LXOFFSET if not ulPEOffset */
    46     int ourstub;            /* our DOS stub or the one from the PE-file */
     60    /* none yet... */
    4761};
    4862
    4963
    50 extern struct options options;
    51 
    52 #define SET_OPTIONS_TO_DEFAULT(o)            \
    53             o.fQuiet         = 0;            \
    54             o.usCom          = OUTPUT_COM2;  \
    55             o.fLogging       = 0;            \
    56             o.ulBuild        = 8259;         \
    57             o.fKernel        = KF_UNI;       \
    58             o.usVerMajor     = 20;           \
    59             o.usVerMinor     = 30;           \
    60             o.noExeTIBFix    = 0;            \
    61             o.AlignSections  = 1;            \
    62             o.lxoffset       = 0;            \
    63             o.ourstub        = 0
    64 
    65 
    66 #define SET_OPTIONS_WIN32K(o)                \
    67             SET_OPTIONS_TO_DEFAULT(o)
    68 
    69 #define SET_OPTIONS_WIN32K_SAFE(o)           \
    70             SET_OPTIONS_TO_DEFAULT(o);       \
    71             o.noExeTIBFix    = 0;            \
    72             o.AlignSections  = 1
    73 
    74 
    75 #define SET_OPTIONS_PE2LX(o)                 \
    76             SET_OPTIONS_TO_DEFAULT(o);       \
    77             o.fLogging       = 1;            \
    78             o.noExeTIBFix    = 0;            \
    79             o.AlignSections  = 1;            \
    80             o.lxoffset       = 0;            \
    81             o.ourstub        = 0
     64/*******************************************************************************
     65*   Global Variables                                                           *
     66*******************************************************************************/
     67extern struct options options; /* defined in d32globals.c */
    8268
    8369#endif
  • trunk/src/win32k/include/pe2lx.h

    r1270 r1467  
    1 /* $Id: pe2lx.h,v 1.4 1999-10-14 01:17:55 bird Exp $
     1/* $Id: pe2lx.h,v 1.5 1999-10-27 02:02:57 bird Exp $
    22 *
    33 * Pe2Lx class declarations. Ring 0 and Ring 3
     
    1717*   Defined Constants And Macros                                               *
    1818*******************************************************************************/
    19 /*
    20  * RING3 wrappings for RING0 constructs.
    21  */
    22 #ifdef RING3
    23     typedef HFILE SFN;      /* System File Number. (OS2Krnl.h) */
    24     typedef PVOID PMTE;     /* Pointer to Module Table Entry. (OS2Krnl.h) */
    25 #endif
    26 
    2719/*
    2820 * Misc
  • trunk/src/win32k/include/probkrnl.h

    r847 r1467  
    1 /* $Id: probkrnl.h,v 1.1 1999-09-06 02:19:59 bird Exp $
     1/* $Id: probkrnl.h,v 1.2 1999-10-27 02:02:57 bird Exp $
    22 *
    33 * Include file for ProbKrnl.
     
    5757extern unsigned long int _usVerMinor;       /* 'usVerMinor'      in PrbKrnl.c */
    5858
     59#ifdef INCL_16 /* 16-bit only */
     60int ProbeKernel(PRPINITIN pReqPack);
     61#endif
    5962
    6063#endif
  • trunk/src/win32k/ldr/calltab.asm

    r847 r1467  
    1 ; $Id: calltab.asm,v 1.1 1999-09-06 02:20:00 bird Exp $
     1; $Id: calltab.asm,v 1.2 1999-10-27 02:02:58 bird Exp $
    22;
    33; callTab - Call back again table - table with entry for each function which is overrided.
     
    66; Copyright (c) 1998-1999 knut st. osmundsen
    77;
     8; Project Odin Software License can be found in LICENSE.TXT
    89;
    910    .386p
     
    3334    assume cs:CALLTAB, ds:flat, ss:nothing
    3435
     36;
     37; must match with the aProcTab array in dev16\ProbKrnl.c
     38;
    3539callTab:
     40__ldrRead@24 PROC NEAR
     41    db MAXSIZE_PROLOG dup(0cch)
     42__ldrRead@24 ENDP
     43
     44__ldrOpen@12 PROC NEAR
     45    db MAXSIZE_PROLOG dup(0cch)
     46__ldrOpen@12 ENDP
     47
    3648__ldrClose@4 PROC NEAR
    37     dw MAXSIZE_PROLOG dup(0cch)
     49    db MAXSIZE_PROLOG dup(0cch)
    3850__ldrClose@4 ENDP
    3951
    40 __ldrOpen@12 PROC NEAR
    41     dw MAXSIZE_PROLOG dup(0cch)
    42 __ldrOpen@12 ENDP
    43 
    44 __ldrRead@24 PROC NEAR
    45     dw MAXSIZE_PROLOG dup(0cch)
    46 __ldrRead@24 ENDP
    47 
    4852__LDRQAppType@8 PROC NEAR
    49     dw MAXSIZE_PROLOG dup(0cch)
     53    db MAXSIZE_PROLOG dup(0cch)
    5054__LDRQAppType@8 ENDP
    5155
     
    5357    public __LDRLoadExe
    5458__LDRLoadExe PROC NEAR
    55     dw MAXSIZE_PROLOG dup(0cch)
     59    db MAXSIZE_PROLOG dup(0cch)
    5660__LDRLoadExe END
    5761
    5862    public __ldrGetResource
    5963__ldrGetResource PROC NEAR
    60     dw MAXSIZE_PROLOG dup(0cch)
     64    db MAXSIZE_PROLOG dup(0cch)
    6165__ldrGetResource ENDP
    6266
    6367    public __ldrOpenNewExe
    6468__ldrOpenNewExe PROC NEAR
    65     dw MAXSIZE_PROLOG dup(0cch)
     69    db MAXSIZE_PROLOG dup(0cch)
    6670__ldrOpenNewExe ENDP
    6771
    6872    public __ldrCreateMte
    6973__ldrCreateMte PROC NEAR
    70     dw MAXSIZE_PROLOG dup(0cch)
     74    db MAXSIZE_PROLOG dup(0cch)
    7175__ldrCreateMte ENDP
    7276
    7377    public __ldrGetMte
    7478__ldrGetMte PROC NEAR
    75     dw MAXSIZE_PROLOG dup(0cch)
     79    db MAXSIZE_PROLOG dup(0cch)
    7680__ldrGetMte ENDP
    7781
  • trunk/src/win32k/ldr/ldr.cpp

    r1273 r1467  
    1 /* $Id: ldr.cpp,v 1.2 1999-10-14 01:25:38 bird Exp $
     1/* $Id: ldr.cpp,v 1.3 1999-10-27 02:02:58 bird Exp $
    22 *
    3  * ldr.cpp - Loader helper functions a structures.
     3 * ldr.cpp - Loader helpers.
    44 *
    55 * Copyright (c)  1999 knut  St.  osmundsen
     
    2323#include <memory.h>
    2424#include <stdlib.h>
     25#include <stddef.h>
    2526
    2627#include "log.h"
     
    2930#include "OS2Krnl.h"
    3031#include "pe2lx.h"
     32#include "avl.h"
    3133#include "ldr.h"
     34
    3235
    3336
     
    3538*   Global Variables                                                           *
    3639*******************************************************************************/
    37 PPENODE         pPE;
     40PAVLNODECORE    pSFNRoot = NULL;
     41PAVLNODECORE    pMTERoot = NULL;
     42
    3843unsigned char   achHandleStates[MAX_FILE_HANDLES/8];
    3944
    4045
    41 /*******************************************************************************
    42 *   Internal Functions                                                         *
    43 *******************************************************************************/
    44 static PPENODE  findNodePtr2(PPENODE pRoot, const char *pszFilename);
    45 static ULONG    depth(PPENODE pNode);
    46 
    47 
    48 /**
    49  * Inserts a PENode into the pPE tree.
    50  * @returns    NO_ERROR on success. !0 on error.
    51  * @param      pNode  Pointer to node to insert.
    52  */
    53 ULONG insertNode(PPENODE pNode)
    54 {
    55     int level;
    56     PPENODE pPrev;
    57     PPENODE pTmp;
    58 
    59     if (pPE == NULL)
    60     {
    61         pPE = pNode;
    62         pNode->left = pNode->right = NULL;
     46/**
     47 * Gets a module by the give hFile.
     48 * @returns   Pointer to module node. If not found NULL.
     49 * @param     hFile  File handle of the module to be found.
     50 * @sketch    return a AVLGet on the pSFNRoot-tree.
     51 * @status    completely implemented.
     52 * @author    knut st. osmundsen
     53 */
     54PMODULE     getModuleBySFN(SFN hFile)
     55{
     56    return (PMODULE)AVLGet(&pSFNRoot, (AVLKEY)hFile);
     57}
     58
     59
     60/**
     61 * Gets a module by the MTE.
     62 * @returns   Pointer to module node. If not found NULL.
     63 * @param     pMTE  Pointer an Module Table Entry.
     64 * @sketch    Try find it in the MTE tree.
     65 *            IF not found THEN
     66 *            BEGIN
     67 *                DEBUG: validate pMTE pointer.
     68 *                Get the SFN from the MTE.
     69 *                IF found in the SFN-tree THEN
     70 *                BEGIN
     71 *                    Update the pMTE in the node.
     72 *                    Add the node to the MTE-tree.
     73 *                END
     74 *                ELSE return NULL
     75 *            END
     76 *            return pointer to module node.
     77 * @status    completely implemented.
     78 * @author    knut st. osmundsen
     79 */
     80PMODULE     getModuleByMTE(PMTE pMTE)
     81{
     82    PMODULE pMod = (PMODULE)AVLGet(&pMTERoot, (AVLKEY)pMTE);
     83    if (pMod == NULL)
     84    {
     85        #ifdef DEBUG
     86        if (pMTE <= (PMTE)0x10000)
     87        {
     88            kprintf(("getModuleByMTE: invalid pMTE pointer - %#8x\n", pMTE));
     89            return NULL;
     90        }
     91        #endif
     92        pMod = (PMODULE)AVLGet(&pSFNRoot, (AVLKEY)pMTE->mte_sfn);
     93        if (pMod != NULL)
     94        {
     95            pMod->coreMTE.Key = (AVLKEY)pMTE;
     96            pMod->fFlags |= MOD_FLAGS_IN_MTETREE;
     97            AVLInsert(&pMTERoot, (PAVLNODECORE)((unsigned)pMod + offsetof(MODULE, coreMTE)));
     98        }
    6399    }
    64100    else
    65     {
    66         level = 0;
    67         pPrev = NULL;
    68         pTmp = pPE;
    69         while (pTmp != NULL)
    70         {
    71             level = 0;
    72             pPrev = pTmp;
    73             pTmp = AdjustKey(pNode->hFile) < AdjustKey(pTmp->hFile) ? pTmp->left : pTmp->right;
    74         }
    75 
    76         if (pNode->hFile != pPrev->hFile)
    77         {
    78             if (AdjustKey(pNode->hFile) < AdjustKey(pPrev->hFile))
    79                 pPrev->left = pNode;
    80             else
    81                 pPrev->right = pNode;
    82             pNode->left = pNode->right = NULL;
    83         }
    84         else
    85             return -1;
     101        pMod = (PMODULE)((unsigned)pMod - offsetof(MODULE, coreMTE));
     102    return pMod;
     103}
     104
     105
     106/**
     107 * Get a module by filename.
     108 * @returns   Pointer to module node. If not found NULL.
     109 * @param     pszFilename  Pointer to the filename which we are search by.
     110 * @sketch    Not implemented.
     111 * @status    Stub.
     112 * @author    knut st. osmundsen
     113 */
     114PMODULE     getModuleByFilename(PCSZ pszFilename)
     115{
     116    pszFilename = pszFilename;
     117    return NULL;
     118}
     119
     120
     121/**
     122 * Adds a module to the SFN-tree, if pMTE is not NULL it is added to the MTE-tree too.
     123 * @returns   NO_ERROR on success. Appropriate errorcode on failiure.
     124 * @param     hFile   System file number for the module.
     125 * @param     pMTE    Pointer to MTE. NULL is valid.
     126 * @param     fFlags  Type flags for the fFlags field in the node.
     127 * @param     pvData  Pointer to data.
     128 * @sketch    DEBUG: check that the module doesn't exists and parameter check.
     129 *            (try) Allocate a new node. (return errorcode on failure)
     130 *            Fill in the node.
     131 *            Add the node to the SFN-tree.
     132 *            IF valid MTE pointer THEN add it to the MTE tree and set the in MTE-tree flag.
     133 *            return successfully.
     134 * @status    completely implemented.
     135 * @author    knut st. osmundsen
     136 */
     137ULONG       addModule(SFN hFile, PMTE pMTE, ULONG fFlags, void *pvData)
     138{
     139    PMODULE pMod;
     140    #ifdef DEBUG
     141        if (AVLGet(&pSFNRoot, (AVLKEY)hFile) != NULL)
     142            kprintf(("addModule: Module allready present in the SFN-tree!\n"));
     143        if (hFile == 0)
     144        {
     145            kprintf(("addModule: invalid parameter: hFile = 0\n"));
     146            return ERROR_INVALID_PARAMETER;
     147        }
     148        if ((fFlags & MOD_TYPE_MASK) == 0 || (fFlags  & ~MOD_TYPE_MASK) != 0)
     149        {
     150            kprintf(("addModule: invalid parameter: fFlags = 0x%#8x\n", fFlags));
     151            return ERROR_INVALID_PARAMETER;
     152        }
     153    #endif
     154
     155    /* try allocate memory for the node. */
     156    pMod = (PMODULE)malloc(sizeof(MODULE));
     157    if (pMod == NULL)
     158    {
     159        kprintf(("addModule: out of memory!\n"));
     160        return ERROR_NOT_ENOUGH_MEMORY;
     161    }
     162
     163    /* fill in the module node. */
     164    pMod->coreKey.Key = (AVLKEY)hFile;
     165    pMod->hFile = hFile;
     166    pMod->pMTE = pMTE;
     167    pMod->fFlags = fFlags;
     168    pMod->Data.pv = pvData;
     169
     170    /* insert the module node into the tree(s) */
     171    AVLInsert(&pSFNRoot, (PAVLNODECORE)pMod);
     172    if (pMTE != NULL)
     173    {
     174        pMod->coreMTE.Key = (AVLKEY)pMTE;
     175        pMod->fFlags |= MOD_FLAGS_IN_MTETREE;
     176        AVLInsert(&pMTERoot, (PAVLNODECORE)((unsigned)pMod + offsetof(MODULE, coreMTE)));
    86177    }
    87178
     
    91182
    92183/**
    93  * Deletes a node from the pPE tree.
    94  * @returns   NO_ERROR on success. !0 on error.
    95  * @param     key  Filehandle, which is the key.
    96  */
    97 ULONG deleteNode(SFN key)
    98 {
    99     int     level,level2;
    100     ULONG   rc;
    101     PPENODE pTmp,pTmp2;
    102     PPENODE pPrev,pPrev2;
    103     int     left;
    104 
    105     if (pPE != NULL)
    106     {
    107         /* find node to delete */
    108         level = 1;
    109         pPrev = NULL;
    110         pTmp = pPE;
    111         while (pTmp != NULL  &&  key != pTmp->hFile)
    112         {
    113             pPrev = pTmp;
    114             pTmp = (left = (AdjustKey(key) < AdjustKey(pTmp->hFile))) == TRUE ? pTmp->left : pTmp->right;
    115             level ++;
    116         }
    117 
    118         if (pTmp != NULL)
    119         {
    120             /*found it: pTmp -> node to delete  -  pPrev -> parent node*/
    121             level--;
    122             rc = -1;
    123             if (pTmp->left != NULL && pTmp->right != NULL)
    124             {
    125                 /* hard case - fetch the leftmost node in the right subtree */
    126                 level2 = level;
    127                 pPrev2 = pTmp;
    128                 pTmp2 = pTmp->right;
    129                 while (pTmp2->left != NULL)
    130                 {
    131                     pPrev2 = pTmp2;
    132                     pTmp2 = pTmp2->left;
    133                     level2++;
    134                 }
    135                 /* pTmp2 -> new root  -  pPrev2 -> parent node */
    136 
    137                 /* left child of pTmp2 */
    138                 pTmp2->left = pTmp->left;
    139 
    140                 /* parent of pTmp2 and pTmp2->right */
    141                 if (pPrev2 != pTmp)
    142                 {
    143                     pPrev2->left = pTmp2->right;
    144                     pTmp2->right = pTmp->right;
    145                 }
    146                 //else pTmp2->right = pTmp2->right;
    147 
    148                 /* link in pTmp2 */
    149                 if (pTmp != pPE)
    150                 {
    151                     if (left)
    152                         pPrev->left = pTmp2;
    153                     else
    154                         pPrev->right = pTmp2;
    155                 }
    156                 else
    157                     pPE = pTmp2;
    158                 rc = NO_ERROR;
    159             }
    160 
    161             /* leaf */
    162             if (rc!=0 && pTmp->left == NULL && pTmp->right == NULL)
    163             {
    164                 if (pTmp != pPE)
    165                 {
    166                     if (left)
    167                         pPrev->left = NULL;
    168                     else
    169                         pPrev->right = NULL;
    170                 }
    171                 else
    172                     pPE = NULL;
    173                 rc = NO_ERROR;
    174             }
    175 
    176             /* left is NULL */
    177             if (rc!=0 && pTmp->left == NULL && pTmp->right != NULL)
    178             {
    179                 /* move up right node */
    180                 if (pTmp != pPE)
    181                 {
    182                     if (left)
    183                         pPrev->left = pTmp->right;
    184                     else
    185                         pPrev->right = pTmp->right;
    186                 }
    187                 else
    188                     pPE = pTmp->right;
    189                 rc = NO_ERROR;
    190             }
    191 
    192             /* right is NULL */
    193             if (rc!=0 && pTmp->left != NULL && pTmp->right == NULL)
    194             {
    195                 /* move up left node */
    196                 if (pTmp != pPE)
    197                 {
    198                     if (left)
    199                         pPrev->left = pTmp->left;
    200                     else
    201                         pPrev->right = pTmp->left;
    202                 }
    203                 else
    204                     pPE = pTmp->left;
    205                 rc = NO_ERROR;
    206             }
    207 
    208             /* free node */
    209             if (rc == NO_ERROR)
    210                 rc = freeNode( pTmp );
    211         }
    212         else
    213             rc  = 1;      //not found
    214     }
    215     else
    216         rc  = 1; //not found
    217     return rc;
    218 }
    219 
    220 
    221 /**
    222  * Get the pointer to a node in the pPE tree.
    223  * @returns   Pointer to node on success. NULL if not found or error occured.
    224  * @param     key  Filehandle, which is the key for the pPE tree.
    225  */
    226 PPENODE getNodePtr(SFN key)
    227 {
    228     PPENODE pTmp = pPE;
    229     int level = 1;
    230     while (pTmp != NULL && pTmp->hFile != key)
    231     {
    232         pTmp = AdjustKey(key) < AdjustKey(pTmp->hFile) ? pTmp->left : pTmp->right;
    233         level++;
    234     }
    235     return pTmp;
    236 }
    237 
    238 
    239 /**
    240  * Find a PENode by filename in the node tree.
    241  * @returns   Pointer to PENode if found, NULL if not found.
    242  * @param     pszFilename  Pointer to filename.
    243  */
    244 PPENODE findNodePtr(const char *pszFilename)
    245 {
    246     /*depth first search thru the whole tree */
    247     return findNodePtr2(pPE, pszFilename);
    248 }
    249 
    250 
    251 /**
    252  * Find a PENode by filename in the given tree.
    253  * Depth first search thru the whole tree.
    254  * @returns   Pointer to matching PENode.
    255  * @param     pRoot        Tree root.
    256  * @param     pszFilename  Pointer to filename.
    257  * @remark    sub-function of findNodePtr.
    258  */
    259 static PPENODE findNodePtr2(PPENODE pRoot, const char *pszFilename)
    260 {
    261     PPENODE pNode = NULL;
    262 
    263     /*depth first search thru the whole tree */
    264     if (pRoot == NULL || pRoot->pPe2Lx->queryIsModuleName(pszFilename))
    265         return pRoot;
    266 
    267     //search subtrees
    268     if (pRoot->left != NULL)
    269         pNode = findNodePtr2(pRoot->left,pszFilename);
    270     if (pNode == NULL && pRoot->right != NULL)
    271         pNode = findNodePtr2(pRoot->right,pszFilename);
    272     return pNode;
    273 }
    274 
    275 
    276 /**
    277  * Allocate memory for a PENode.
    278  * @returns   Pointer to new PENode on success. NULL pointer on error.
    279  */
    280 PPENODE allocateNode(void)
    281 {
    282     PPENODE pNode;
    283 
    284     pNode = new PENODE;
    285     if (pNode == NULL)
    286         kprintf(("allocateNode: new returned a NULL-pointer\n"));
    287 
    288     return pNode;
    289 }
    290 
    291 
    292 /**
    293  * Frees node.
    294  * @returns   NO_ERROR on success.
    295  * @param     pNode  Pointer to node which is to be freed.
    296  */
    297 ULONG freeNode(PPENODE pNode)
    298 {
    299     if (pNode != NULL)
    300         delete pNode;
     184 * Removes and frees a module node (including the data pointer).
     185 * @returns   NO_ERROR on success. Appropriate error code on failure.
     186 * @param     hFile  System filehandle of the module.
     187 * @sketch    Remove the node from the SFN-tree.
     188 *            IF present in the MTE-tree THEN remove it from the tree.
     189 *            Delete the datapointer.
     190 *            Free the module node.
     191 *            return successfully.
     192 * @status    completely implemented.
     193 * @author    knut st. osmundsen
     194 */
     195ULONG      removeModule(SFN hFile)
     196{
     197    PMODULE pMod = (PMODULE)AVLRemove(&pSFNRoot, (AVLKEY)hFile);
     198    if (pMod == NULL)
     199    {
     200        kprintf(("removeModule: Module not found! hFile=%#4x\n", hFile));
     201        return ERROR_INVALID_PARAMETER;
     202    }
     203
     204    /* In MTE-tree too? */
     205    if (pMod->fFlags & MOD_FLAGS_IN_MTETREE)
     206    {
     207        if (AVLRemove(&pMTERoot, (AVLKEY)pMod->pMTE) == NULL)
     208        {
     209            kprintf(("removeModule: MOD_FLAGS_IN_MTETREE set but AVLRemove returns NULL\n"));
     210        }
     211    }
     212
     213    /* Delete the datapointer. */
     214    switch (pMod->fFlags & MOD_TYPE_MASK)
     215    {
     216        case MOD_TYPE_PE2LX:
     217            delete pMod->Data.pPe2Lx;
     218            break;
     219
     220        case MOD_TYPE_ELF2LX:
     221        case MOD_TYPE_SCRIPT:
     222        case MOD_TYPE_PE:
     223        default:
     224            kprintf(("removeModule: Unknown type, %#x\n", pMod->fFlags & MOD_TYPE_MASK));
     225    }
     226
     227    /* Free the module node. */
     228    free(pMod);
    301229
    302230    return NO_ERROR;
    303 }
    304 
    305 
    306 /**
    307  * Gets the depth of the pPE tree.
    308  * @returns   Number of levels in the the pPE tree.
    309  */
    310 ULONG depthPE(void)
    311 {
    312     return depth(pPE);
    313 }
    314 
    315 
    316 
    317 /**
    318  * Gets the depth of the pPE tree.
    319  * @returns   Number of levels in the the pPE tree.
    320  * @param     pNode  Node to start at. (root node...)
    321  */
    322 static ULONG depth(PPENODE pNode)
    323 {
    324     if (pNode != NULL)
    325     {
    326         int l, r;
    327         l = depth(pNode->left);
    328         r = depth(pNode->right);
    329         return 1 + (l > r ? l : r);
    330     }
    331     else
    332         return 0;
    333231}
    334232
     
    346244    memset(&achHandleStates[0], 0, sizeof(achHandleStates));
    347245
    348     /* init pPEFiles* */
    349     pPE = NULL;
     246    /* init the tree roots */
     247    pSFNRoot = NULL;
     248    pMTERoot = NULL;
    350249
    351250    return rc;
  • trunk/src/win32k/ldr/myldrClose.cpp

    r1273 r1467  
    1 /* $Id: myldrClose.cpp,v 1.2 1999-10-14 01:25:38 bird Exp $
     1/* $Id: myldrClose.cpp,v 1.3 1999-10-27 02:02:58 bird Exp $
    22 *
    33 * myldrClose - _ldrClose
     
    2626#include "OS2Krnl.h"
    2727#include "pe2lx.h"
     28#include "avl.h"
    2829#include "ldr.h"
    2930#include "ldrCalls.h"
     
    4445    if (GetState(hFile) == HSTATE_OUR)
    4546    {
    46         rc = deleteNode(hFile);
     47        rc = removeModule(hFile);
    4748        if (rc != NO_ERROR)
    48             kprintf(("Funny! deleteNode failed rc = %d\n", rc));
     49            kprintf(("_ldrClose: removeModule retured rc=%d\n", rc));
    4950
    5051        SetState(hFile, HSTATE_UNUSED);
  • trunk/src/win32k/ldr/myldrOpen.cpp

    r1273 r1467  
    1 /* $Id: myldrOpen.cpp,v 1.2 1999-10-14 01:25:38 bird Exp $
     1/* $Id: myldrOpen.cpp,v 1.3 1999-10-27 02:02:58 bird Exp $
    22 *
    33 * myldrOpen - _ldrOpen.
     
    2929#include "OS2Krnl.h"
    3030#include "pe2lx.h"
     31#include "elf.h"
     32#include "avl.h"
    3133#include "ldr.h"
    3234#include "ldrCalls.h"
    3335
    34 #include "elf.h"
    3536
    3637/**
     
    7172                if (rc == NO_ERROR && *(PULONG)pach == IMAGE_NT_SIGNATURE)
    7273                {   /* PE signature found */
    73                     PPENODE pNode;
     74                    PMODULE pMod;
    7475
    75                     kprintf(("_ldrOpen: PE executable!(?)\n"));
     76                    kprintf(("_ldrOpen: PE executable...\n"));
    7677                    #pragma info(none)
    7778                    if (/* invoke pe.exe or do conversion now? */ 1)
    7879                    {   /* pe2lx - win32k */
    7980                    #pragma info(restore)
    80                         pNode = allocateNode();
    81                         if (pNode != NULL)
     81                        Pe2Lx * pPe2Lx = new Pe2Lx(*phFile);
     82                        if (pPe2Lx != NULL)
    8283                        {
    83                             pNode->pPe2Lx = new Pe2Lx(*phFile);
    84                             if (pNode->pPe2Lx != NULL)
     84                            rc = pPe2Lx->init(pszFilename);
     85                            if (rc == NO_ERROR)
    8586                            {
    86                                 rc = pNode->pPe2Lx->init(pszFilename);
     87                                kprintf(("_ldrOpen: Successfully init of Pe2Lx object.\n"));
     88                                rc = addModule(*phFile, NULL, MOD_TYPE_PE2LX, pPe2Lx);
    8789                                if (rc == NO_ERROR)
    88                                 {
    89                                     kprintf(("_ldrOpen: Successfully init of Pe2Lx object.\n"));
    90                                     rc = insertNode(pNode);
    91                                     if (rc != NO_ERROR)
    92                                     {
    93                                         kprintf(("_ldrOpen: Failed to insert PeNode into tree. rc=%d\n"));
    94                                         delete pNode->pPe2Lx;
    95                                         pNode->pPe2Lx = NULL;
    96                                         freeNode(pNode);
    97                                         SetState(*phFile, HSTATE_OUR);
    98                                     }
    99                                 }
     90                                    SetState(*phFile, HSTATE_OUR);
    10091                                else
    101                                 {
    102                                     kprintf(("_ldrOpen: Failed to init Pe2Lx object. rc=%d\n"));
    103                                     delete pNode->pPe2Lx;
    104                                     pNode->pPe2Lx = NULL;
    105                                     freeNode(pNode);
    106                                 }
     92                                    kprintf(("_ldrOpen: Failed to add the module. rc=%d\n"));
    10793                            }
    10894                            else
    109                             {
    110                                 kprintf(("_ldrOpen: Failed to allocate Pe2Lx object.\n"));
    111                                 freeNode(pNode);
    112                             }
     95                                kprintf(("_ldrOpen: Failed to init Pe2Lx object. rc=%d\n"));
     96                            if (rc != NO_ERROR)
     97                                delete pPe2Lx;
    11398                        }
    11499                        else
    115                             kprintf(("_ldrOpen: Failed to allocate node.\n"));
     100                            kprintf(("_ldrOpen: Failed to allocate Pe2Lx object.\n"));
    116101                    }
    117102                    else
  • trunk/src/win32k/ldr/myldrRead.cpp

    r1276 r1467  
    1 /* $Id: myldrRead.cpp,v 1.3 1999-10-14 02:36:08 bird Exp $
     1/* $Id: myldrRead.cpp,v 1.4 1999-10-27 02:02:58 bird Exp $
    22 *
    33 * myldrRead - _ldrRead.
     
    2727#include "OS2Krnl.h"
    2828#include "pe2lx.h"
     29#include "avl.h"
    2930#include "ldrCalls.h"
    3031#include "ldr.h"
     
    4546    if (GetState(hFile) == HSTATE_OUR)
    4647    {
    47         PPENODE pNode;
     48        PMODULE pMod;
     49        kprintf(("_ldrRead+: hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x\n",hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE));
    4850
    49         pNode = getNodePtr(hFile);
    50         if (pNode != NULL)
     51        pMod = getModuleBySFN(hFile);
     52        if (pMod != NULL)
    5153        {
    5254            /* I would love to have a pointer to the MTE */
    53             if (pNode->pMTE == NULL && pMTE != NULL)
    54                 pNode->pMTE == pMTE;
     55            if (pMod->pMTE == NULL && pMTE != NULL)
     56                pMod->pMTE == pMTE;
    5557
    5658            /* debug */
     
    5860                kprintf(("_ldrRead: Warning ulFlags = 0x%x (!= 0)\n", ulFlags));
    5961
    60             rc = pNode->pPe2Lx->read(ulOffset, pBuffer, ulBytesToRead, ulFlags, pMTE);
     62            if ((pMod->fFlags & MOD_TYPE_MASK) == MOD_TYPE_PE2LX)
     63                rc = pMod->Data.pPe2Lx->read(ulOffset, pBuffer, ulBytesToRead, ulFlags, pMTE);
     64            else
     65            {
     66                kprintf(("_ldrRead: Invalid module type, %#x\n", pMod->fFlags & MOD_TYPE_MASK));
     67                rc = ERROR_READ_FAULT;
     68            }
    6169            return rc;
    6270        }
     
    6775    rc = _ldrRead(hFile, ulOffset, pBuffer, ulFlags, ulBytesToRead, pMTE);
    6876
    69 //  kprintf(("_ldrRead:  hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x rc=%d\n",hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE,rc));
     77    #if 0
     78    kprintf(("_ldrRead:  hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x rc=%d\n",
     79             hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE,rc));
     80    #endif
    7081
    7182    return rc;
  • trunk/src/win32k/misc/asmutils.asm

    r909 r1467  
    1 ; $Id: asmutils.asm,v 1.2 1999-09-12 00:26:27 bird Exp $
     1; $Id: asmutils.asm,v 1.3 1999-10-27 02:02:59 bird Exp $
    22;
    33; asmutils - assembly utility functions
     
    55; Copyright (c) 1998-1999 knut st. osmundsen
    66;
     7; Project Odin Software License can be found in LICENSE.TXT
    78;
    89    .386p
     
    1213;
    1314    include devsegdf.inc
    14     include sas.inc
    1515
    1616;
     
    2626    public _memrevmov@12
    2727    public _memmov@12
    28     public GetOS2KrnlMTE
    2928;    public DisableInterrupts
    3029;    public EnableInterrupts
     
    196195
    197196
    198 ; gets the FLAT pointer to the OS2 Kernel MTE.
    199 ; eax is flat pointer to OS2 Kernel MTE.
    200 GetOS2KrnlMTE PROC NEAR
    201     push    es
    202 
    203     mov     ax, SAS_selector            ;70h - Read-only SAS selector.
    204     mov     es, ax
    205     xor     ebx, ebx
    206     assume  ebx: PTR SAS
    207     mov     bx, [ebx].SAS_vm_data       ;SAS_vm_data (0ch)
    208     assume  ebx: PTR SAS_vm_section
    209     mov     eax,[ebx].SAS_vm_krnl_mte   ;SAS_vm_krnl_mte (0ch)
    210 
    211     pop     es
    212     ret
    213 GetOS2KrnlMTE ENDP
    214 
    215 
    216197CODE32 ends
    217198end
  • trunk/src/win32k/misc/cout.cpp

    r847 r1467  
    1 /* $Id: cout.cpp,v 1.1 1999-09-06 02:20:02 bird Exp $
     1/* $Id: cout.cpp,v 1.2 1999-10-27 02:02:59 bird Exp $
    22 *
    33 * cout - cout replacement.
    44 *
     5 * Note: use of cout is discurraged.
     6 *
    57 * Copyright (c) 1998-1999 knut st. osmundsen
     8 *
     9 * Project Odin Software License can be found in LICENSE.TXT
    610 *
    711 */
  • trunk/src/win32k/misc/malloc.c

    r1271 r1467  
    1 /* $Id: malloc.c,v 1.2 1999-10-14 01:19:21 bird Exp $
     1/* $Id: malloc.c,v 1.3 1999-10-27 02:03:00 bird Exp $
    22 *
    33 * Heap.
     
    1010 */
    1111
    12 
     12#define static
    1313/******************************************************************************
    1414*  Defined macros and constants
     
    289289
    290290    #ifdef RING0
    291         pFree = D32Hlp_VMAlloc(VMDHA_SWAP | VMDHA_USEHIGHMEM, cbSize, ~0UL);
     291        pFree = D32Hlp_VMAlloc(VMDHA_SWAP, cbSize, ~0UL);
    292292    #else
    293293        if (DosAllocMem((void*)&pFree, cbSize, PAG_COMMIT | PAG_READ | PAG_WRITE) != 0)
  • trunk/src/win32k/misc/vprintf.c

    r1271 r1467  
    1 /* $Id: vprintf.c,v 1.1 1999-10-14 01:19:22 bird Exp $
     1/* $Id: vprintf.c,v 1.2 1999-10-27 02:03:00 bird Exp $
    22 *
    33 * vprintf and printf
     
    3131#include <stdarg.h>
    3232
     33#include "dev32.h"
     34#include "vprintf.h"
    3335#ifdef RING0
    34     #include "dev32.h"
    35 #else
    36     #define SSToDS(a) (a)
     36    #include <builtin.h>
     37    #include "options.h"
    3738#endif
    38 #include "vprintf.h"
    39 
     39
     40
     41/*******************************************************************************
     42*   Global Variables                                                           *
     43*******************************************************************************/
     44static char chNewLine = '\n';
     45static char chReturn  = '\r';
    4046
    4147/*******************************************************************************
     
    4450static int       _atoi_skip(const char **ppsz);
    4551static unsigned  _strnlen(const char *psz, unsigned cchMax);
    46 _Inline void     chout(int ch);
     52static void      chout(int ch);
     53static char *    strout(char *psz, signed cchMax);
    4754
    4855
     
    162169    #if 0
    163170    else if (!(fFlags & NTSF_LEFT) && cchWidth > 0)
    164     {   /* not supported! */
     171    {   /* not yet supported! */
    165172        /*
    166173        for (j = i-1; j >= 0; j--)
     
    207214int vprintf(const char *pszFormat, va_list args)
    208215{
     216    #ifdef RING0
     217        if (options.fQuiet)
     218            return 0;
     219    #else
     220        int cch = 0;
     221    #endif
     222
    209223    while (*pszFormat != '\0')
    210224    {
    211225        if (*pszFormat == '%')
    212226        {
     227            #ifndef RING0
     228                if (cch > 0)
     229                {
     230                    strout((char*)(pszFormat - cch), cch);
     231                    cch = 0;
     232                }
     233            #endif
     234
    213235            pszFormat++;  /* skip '%' */
    214236            if (*pszFormat == '%')    /* '%%'-> '%' */
     
    306328                    case 's':   /* string */
    307329                    {
    308                         int   i;
    309330                        int   cchStr;
    310331                        char *pszStr = va_arg(args, char*);
     
    316337                            while (--cchWidth >= cchStr)
    317338                                 chout(' ');
    318                         for (i = cchStr; i > 0; i--)
    319                             chout(*pszStr++);
     339
     340                        pszStr = strout(pszStr, cchStr);
    320341
    321342                        while (--cchWidth >= cchStr)
     
    352373        }
    353374        else
    354             chout(*pszFormat++);
    355     }
     375        {
     376            #ifdef RING0
     377                chout(*pszFormat++);
     378            #else
     379                cch++;
     380                pszFormat++;
     381            #endif
     382        }
     383    }
     384
     385    #ifndef RING0
     386        if (cch > 0)
     387        {
     388            strout((char*)(pszFormat - cch), cch);
     389            cch = 0;
     390        }
     391    #endif
    356392
    357393    return 0UL;
     
    376412    va_list arguments;
    377413
     414    #ifdef RING0
     415        if (options.fQuiet)
     416            return 0;
     417    #endif
     418
    378419    va_start(arguments, pszFormat);
    379420    cch = vprintf(pszFormat, arguments);
     
    390431    va_list arguments;
    391432
     433    #ifdef RING0
     434        if (options.fQuiet)
     435            return 0;
     436    #endif
     437
    392438    va_start(arguments, pszFormat);
    393439    cch = vprintf(pszFormat, arguments);
     
    402448    int     cch;
    403449    va_list arguments;
     450
     451    #ifdef RING0
     452        if (options.fQuiet)
     453            return 0;
     454    #endif
    404455
    405456    va_start(arguments, pszFormat);
     
    419470 * @author    knut st. osmundsen
    420471 */
    421 _Inline void  chout(int ch)
    422 {
    423     #ifdef RING0
    424 
    425     #else
     472static void chout(int ch)
     473{
     474    #ifndef RING0
    426475        ULONG ulWrote;
    427476    #endif
     
    431480        if (ch == '\n')
    432481        {
    433             static char chReturn = '\r';
    434482            #ifdef RING0
    435 
     483                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     484                _outp(options.usCom, chReturn);             /* Put the char. */
    436485            #else
    437486                DosWrite(1, (void*)&chReturn, 1, &ulWrote);
     
    439488        }
    440489        #ifdef RING0
    441 
     490            while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     491            _outp(options.usCom, ch);                   /* Put the char. */
    442492        #else
    443493            DosWrite(1, (void*)&ch, 1, &ulWrote);
     
    446496}
    447497
     498
     499/**
     500 * Write a string to the output device.
     501 * @returns   pointer end of string.
     502 * @param     psz     Pointer to the string to write.
     503 * @param     cchMax  Max count of chars to write. (or until '\0')
     504 * @status    completely implemented.
     505 * @author    knut st. osmundsen
     506 */
     507static char *strout(char *psz, signed cchMax)
     508{
     509    while (cchMax > 0 && *psz != '\0')
     510    {
     511        ULONG cch = 0;
     512        ULONG ul;
     513
     514        while (cchMax - cch > 0 && psz[cch] != '\0' && psz[cch] != '\r' && psz[cch] != '\n')
     515            cch++;
     516
     517        /* write string part */
     518        #ifdef RING0
     519            for (ul = 0; ul < cch; ul++)
     520            {
     521                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     522                _outp(options.usCom, psz[ul]);              /* Put the char. */
     523            }
     524        #else
     525            DosWrite(1, (void*)psz, cch, &ul);
     526        #endif
     527
     528        /* cr and lf check + skip */
     529        if (psz[cch] == '\n' || psz[cch] == '\r')
     530        {
     531            if (psz[cch] == '\n')
     532            {
     533            #ifdef RING0
     534                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     535                _outp(options.usCom, chReturn);             /* Put the char. */
     536                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
     537                _outp(options.usCom, chNewLine);            /* Put the char. */
     538            #else
     539                DosWrite(1, (void*)&chReturn, 1, &ul);
     540                DosWrite(1, (void*)&chNewLine, 1, &ul);
     541            #endif
     542
     543            }
     544
     545            while (cchMax - cch > 0 && (psz[cch] == '\r' || psz[cch] == '\n'))
     546                cch++;
     547        }
     548
     549        /* next */
     550        psz += cch;
     551        cchMax -= cch;
     552    }
     553    return psz;
     554}
     555
  • trunk/src/win32k/misc/vsprintf.c

    r1271 r1467  
    1 /* $Id: vsprintf.c,v 1.2 1999-10-14 01:19:22 bird Exp $
     1/* $Id: vsprintf.c,v 1.3 1999-10-27 02:03:00 bird Exp $
    22 *
    33 * vsprintf and sprintf
     
    3131#include <stdarg.h>
    3232
    33 #ifdef RING0
    34     #include "dev32.h"
    35 #else
    36     #define SSToDS(a) (a)
    37 #endif
     33#include "dev32.h"
    3834#include "sprintf.h"
    3935
  • trunk/src/win32k/pe2lx/makefile

    r1289 r1467  
    11##############################################################################
    2 # $Id: makefile,v 1.4 1999-10-14 13:20:16 bird Exp $
     2# $Id: makefile,v 1.5 1999-10-27 02:03:01 bird Exp $
    33#
    44# PD-Win32 API
     
    112112    pe2lx.cpp \
    113113    $(WIN32K_INCLUDE)\pe2lx.h \
     114    $(WIN32K_INCLUDE)\OS2Krnl.h \
    114115    $(WIN32K_INCLUDE)\malloc.h \
    115116    $(WIN32K_INCLUDE)\new.h
     
    118119    pe2lxmain.cpp \
    119120    $(WIN32K_INCLUDE)\pe2lx.h \
     121    $(WIN32K_INCLUDE)\OS2Krnl.h
    120122
    121123$(PE2LXOBJ)\malloc.$(OBJEXT): \
  • trunk/src/win32k/pe2lx/pe2lx.cpp

    r1277 r1467  
    1 /* $Id: pe2lx.cpp,v 1.4 1999-10-14 02:36:51 bird Exp $
     1/* $Id: pe2lx.cpp,v 1.5 1999-10-27 02:03:01 bird Exp $
    22 *
    33 * Pe2Lx class implementation. Ring 0 and Ring 3
     
    4444                                            /* aligns something, a,  up to nearest alignment boundrary-
    4545                                             * Note: Aligment must be a 2**n number. */
    46 
    47 #ifndef RING0
    48     #define SSToDS(p)  (p)                  /* In RING-0 this translates pointers to stack memory in the
    49                                              * Stack Segment (SS) to pointers to stack memory in the
    50                                              * Data Segment (DS). SS is 16-bit compatible, DS is 32-bit flat.
    51                                              * It is vitally important to use this macro whenever creating
    52                                              * a pointer to stack memory which don't implies that is a pointer
    53                                              * relative to SS. For example when passing the pointer to an stack
    54                                              * variable into an function call; like the addToModule calls.
    55                                              */
    56 #endif
    57 
    5846
    5947/*
     
    131119
    132120#include "vprintf.h"                        /* win32k printf and vprintf. Not C library! */
    133 
     121#include "dev32.h"                          /* 32-Bit part of the device driver. (SSToDS) */
     122#include "OS2Krnl.h"                        /* kernel structs.  (SFN) */
    134123#ifdef RING0
    135     #include "dev32.h"                      /* 32-Bit part of the device driver. (SSToDS) */
    136     #include "OS2Krnl.h"                    /* kernel structs.  (SFN) */
    137124    #include "ldrCalls.h"                   /* _ldr* calls. (_ldrRead) */
    138125#endif
    139 
    140126#include "pe2lx.h"                          /* Pe2Lx class definitions, ++. */
    141127#include <versionos2.h>                     /* Pe2Lx version. */
  • trunk/src/win32k/pe2lx/pe2lxmain.cpp

    r1290 r1467  
    1 /* $Id: pe2lxmain.cpp,v 1.2 1999-10-14 13:27:02 bird Exp $
     1/* $Id: pe2lxmain.cpp,v 1.3 1999-10-27 02:03:01 bird Exp $
    22 *
    33 * Pe2Lx main program. (Ring 3 only!)
     
    2727#include <string.h>
    2828#include <stdlib.h>
     29#include "OS2Krnl.h"
    2930#include "pe2lx.h"
    3031#include <stdio.h>
  • trunk/src/win32k/win32k.def

    r886 r1467  
    44;******************************************************************************
    55PHYSICAL DEVICE WIN32K
    6 DESCRIPTION "$@#knut st. osmundsen:v0.5.0alpha#@Win32k - Odin32, Ring-0 part - Copyright (c) 1998-1998 knut st. osmundsen"
     6DESCRIPTION "$@#knut st. osmundsen:v0.5.0alpha#@Win32k - Odin32, Ring-0 part - Copyright (c) 1998-1999 knut st. osmundsen"
    77
    88CODE PRELOAD EXECUTEREAD
     
    1515    CODE16          class 'CODE'
    1616    CODE32          class 'CODE'
    17     CALLTAB         class 'CODE'
     17    CALLTAB         class 'DATA'
    1818    DATA32          class 'DATA'
    1919    c_common        class 'DATA'
Note: See TracChangeset for help on using the changeset viewer.