Changeset 2501 for trunk/src


Ignore:
Timestamp:
Jan 22, 2000, 7:21:03 PM (26 years ago)
Author:
bird
Message:

Temporary backup checkin.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/Makefile

    r1682 r2501  
    11################################################################################
    2 # $Id: Makefile,v 1.13 1999-11-10 02:51:43 bird Exp $
     2# $Id: Makefile,v 1.14 2000-01-22 18:20:55 bird Exp $
    33#
    44# Copyright 1998-1999 knut st. osmundsen
     
    2929
    3030
    31 CFLAGS      = -q -Ge -Gs- -Gr+ -Rn -Ss+ -Mp
     31CFLAGS      = -q -Ge -Gs- -Gr+ -Rn -Ss+ -Mp -Wall+ppt-ppc-inl-cnv-gnr-vft-gen-uni-ext-
    3232CFLAGS16    = -c -W4 -Asfw /NTCODE16 /NDDATA16 -G2s -Zp -Zl -nologo -Fo$@ -Fa
    33 CPPFLAGS    = -q -Ge -Gs- -Gr+ -Rn -Ss+ -Mp -Gx
     33CPPFLAGS    = -q -Ge -Gs- -Gr+ -Rn -Ss+ -Mp -Gx -Wall+ppt-ppc-inl-cnv-gnr-vft-
    3434ASFLAGS     = -Sv:ALP -Mb -Li
    3535LFLAGS      = /nologo /MAP /NOI /NOE /NOD /A:16 /MAP /O:$@
     
    9494
    9595{dev16}.c{object}.obj:
    96     @$(ECHO) compiling: $<
     96    @$(ECHO) compiling 16bit: $<
    9797    @$(CC16) $(CFLAGS16) $(CDEFINES16) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES16) $<
    9898
    9999{dev32}.asm{object}.obj:
    100     @$(ECHO) assembling: $<
     100    @$(ECHO) assembling:      $<
    101101    @$(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
    102102{dev32}.c{object}.obj:
    103     @$(ECHO) compiling: $<
     103    @$(ECHO) compiling 32bit: $<
    104104    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    105105{dev32}.cpp{object}.obj:
    106     @$(ECHO) compiling: $<
     106    @$(ECHO) compiling 32bit: $<
    107107    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    108108
    109109{ldr}.asm{object}.obj:
    110     @$(ECHO) assembling: $<
     110    @$(ECHO) assembling:      $<
    111111    @$(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
    112112{ldr}.c{object}.obj:
    113     @$(ECHO) compiling: $<
     113    @$(ECHO) compiling 32bit: $<
    114114    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    115115{ldr}.cpp{object}.obj:
    116     @$(ECHO) compiling: $<
     116    @$(ECHO) compiling 32bit: $<
    117117    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    118118
    119119{misc}.asm{object}.obj:
    120     @$(ECHO) assembling: $<
     120    @$(ECHO) assembling:      $<
    121121    @$(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
    122122{misc}.c{object}.obj:
     123    @$(ECHO) compiling 32bit: $<
     124    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     125{misc}.cpp{object}.obj:
     126    @$(ECHO) compiling 32bit: $<
     127    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     128
     129{pe2lx}.c{object}.obj 32bit:
    123130    @$(ECHO) compiling: $<
    124131    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    125 {misc}.cpp{object}.obj:
    126     @$(ECHO) compiling: $<
    127     @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    128 
    129 {pe2lx}.c{object}.obj:
    130     @$(ECHO) compiling: $<
    131     @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    132132{pe2lx}.cpp{object}.obj:
    133     @$(ECHO) compiling: $<
    134     @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    135 
    136 {devhlpadd}.asm{object}.obj:
    137     @$(ECHO) assembling: $<
    138     @$(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
     133    @$(ECHO) compiling 32bit: $<
     134    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    139135
    140136
     
    169165        object\myldrRead.obj \
    170166        object\myLDRQAppType.obj \
     167        object\myldrEnum32bitRelRecs.obj \
    171168        object\pe2lx.obj \
    172169        object\ModuleBase.obj
     
    226223    libconv $(DDKPATH)\lib\dhcalls.lib $@
    227224    $(ILIB) /nologo /nobackup /convformat $@;
    228 #   ilib /nologo /nobackup /convformat $@;
    229225
    230226clib.lib: $(MSCPATH)\lib\clibcep.lib libconv.exe
    231227    libconv $(MSCPATH)\lib\clibcep.lib $@ > nul
    232228    $(ILIB) /nologo /nobackup /convformat $@;
    233 #   ilib /nologo /nobackup /convformat $@;
    234229
    235230last.lib: object\devlast.obj
    236231    -@del $@ > nul 2> nul
    237232    $(ILIB) /nologo /nobackup $@ $**;
    238 #   ilib /nologo /nobackup $@ $**;
    239233
    240234libconv.exe: libconv.c
  • trunk/src/win32k/dev16/probkrnl.c

    r1989 r2501  
    1 /* $Id: probkrnl.c,v 1.5 1999-12-06 16:18:25 bird Exp $
     1/* $Id: probkrnl.c,v 1.6 2000-01-22 18:20:56 bird Exp $
    22 *
    33 * Description:   Autoprobes the os2krnl file and os2krnl[*].sym files.
     
    2020 *                6. finished.
    2121 *
    22  * Copyright (c) 1998-1999 knut st. osmundsen
     22 * Copyright (c) 1998-2000 knut st. osmundsen
    2323 *
    2424 * Project Odin Software License can be found in LICENSE.TXT
     
    8080 * kernel data - !only valid during init!
    8181 */
     82
     83/*
     84 * aProcTab defines the imported and overloaded OS/2 kernel functions.
     85 * IMPORTANT: aProcTab has a sibling array in d32init.c, aulProc, which must
     86 *            match entry by entry. Adding/removing/shuffling aProcTab, aulProc
     87 *            has to be updated immediately!
     88 */
    8289PROCS aProcTab[NUMBER_OF_PROCS] =
    83 {/* iFound     cchName          offObject     fType */
    84  /*      iObject      achName         ulAddress     */
    85     {FALSE, -1,  8, "_ldrRead",     -1,  -1, EPT_PROC},
    86     {FALSE, -1,  8, "_ldrOpen",     -1,  -1, EPT_PROC},
    87     {FALSE, -1,  9, "_ldrClose",    -1,  -1, EPT_PROC},
    88     {FALSE, -1, 12, "_LDRQAppType", -1,  -1, EPT_PROC},
     90{/* iFound     cchName                  offObject     fType */
     91 /*      iObject      achName                 ulAddress     */
     92    {FALSE, -1,  8, "_ldrRead",             -1,  -1, EPT_PROC},        /* 0 */
     93    {FALSE, -1,  8, "_ldrOpen",             -1,  -1, EPT_PROC},        /* 1 */
     94    {FALSE, -1,  9, "_ldrClose",            -1,  -1, EPT_PROC},        /* 2 */
     95    {FALSE, -1, 12, "_LDRQAppType",         -1,  -1, EPT_PROC},        /* 3 */
     96    {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1,  -1, EPT_PROC},        /* 4 */
     97
     98    {FALSE, -1, 10, "_IOSftOpen",           -1,  -1, EPT_PROCIMPORT},  /* 5 */
     99    {FALSE, -1, 11, "_IOSftClose",          -1,  -1, EPT_PROCIMPORT},  /* 6 */
     100    {FALSE, -1, 15, "_IOSftTransPath",      -1,  -1, EPT_PROCIMPORT},  /* 7 */
     101    {FALSE, -1, 12, "_IOSftReadAt",         -1,  -1, EPT_PROCIMPORT},  /* 8 */
     102    {FALSE, -1, 13, "_IOSftWriteAt",        -1,  -1, EPT_PROCIMPORT}   /* 9 */
    89103};
    90104
    91 unsigned long int   ulBuild      = 0;
    92 unsigned short      usVerMajor   = 0;
    93 unsigned short      usVerMinor   = 0;
     105unsigned long int   ulBuild          = 0;
     106unsigned short      usVerMajor       = 0;
     107unsigned short      usVerMinor       = 0;
    94108
    95109
     
    97111 * privat data
    98112 */
    99 static int      fQuiet = 0;
    100 static char     szUsrOS2Krnl[50] = {0};
    101 static char     szOS2Krnl[]      = {"c:\\os2krnl"};
    102 
    103 static char     szUsrSym[50]     = {0};
    104 static char    *apszSym[]        =
     113static int          fQuiet          = 0;
     114static char         szUsrOS2Krnl[50] = {0};
     115static char         szOS2Krnl[]      = {"c:\\os2krnl"};
     116
     117static char         szUsrSym[50]     = {0};
     118static char *       apszSym[]        =
    105119{
    106120    {"c:\\os2krnl.sym"},                              /* usual for debugkernel */
  • trunk/src/win32k/dev32/d32init.c

    r1678 r2501  
    1 /* $Id: d32init.c,v 1.4 1999-11-10 01:45:30 bird Exp $
     1/* $Id: d32init.c,v 1.5 2000-01-22 18:20:57 bird Exp $
    22 *
    33 * d32init.c - 32-bits init routines.
     
    1919#define INCL_NOPMAPI
    2020#define LDR_INCL_INITONLY
     21
    2122
    2223/*******************************************************************************
     
    4344*******************************************************************************/
    4445static ULONG    readnum(const char *pszNum);
    45 static int      interpretFunctionProlog(char *p);
     46static int      interpretFunctionProlog(char *p, BOOL fOverload);
    4647static int      procInit(void);
    4748
    4849
    4950/* externs located in 16-bit data segement */
    50 extern ULONG  _TKSSBase16;
    51 extern USHORT _R0FlatCS16;
    52 extern USHORT _R0FlatDS16;
     51extern ULONG    _TKSSBase16;
     52extern USHORT   _R0FlatCS16;
     53extern USHORT   _R0FlatDS16;
    5354
    5455
    5556/* extern(s) located in calltab.asm */
    56 extern char callTab[NUMBER_OF_PROCS][MAXSIZE_PROLOG];
     57extern char     callTab[NUMBER_OF_PROCS][MAXSIZE_PROLOG];
    5758
    5859
     
    8889    while (pszTmp != NULL)
    8990    {
    90         char cch;
     91        int cch;
    9192        pszTmp++; //skip [-/]
    9293        cch = strlen(pszTmp);
     
    309310        if (pszNum[1] == 'x' || pszNum[1] == 'X')
    310311        {
    311             ulBase == 16;
     312            ulBase = 16;
    312313            pszNum += 2;
    313314        }
    314315        else
    315316        {
    316             ulBase == 8;
     317            ulBase = 8;
    317318            i = 1;
    318319        }
     
    364365        }
    365366
    366         /* verify known function prolog. (only EPT_PROC) */
    367         if (_aProcTab[i].fType == EPT_PROC)
    368         {
    369             if ((cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress)) <= 0 && cb + 5 >= MAXSIZE_PROLOG)
    370             {
    371                 kprintf(("VerifyProcTab32: verify failed for procedure no.%d\n",i));
    372                 return STATUS_DONE | STERR | 3;
    373             }
    374         }
    375         else
    376         {
    377             kprintf(("VerifyProcTab32: only EPT_PROC is implemented\n",i));
    378             return STATUS_DONE | STERR | 4;
     367        switch (_aProcTab[i].fType)
     368        {
     369            case EPT_PROC:
     370            case EPT_PROCIMPORT:
     371                /* verify known function prolog. */
     372                if ((cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress, _aProcTab[i].fType == EPT_PROC))
     373                    <= 0 && cb + 5 >= MAXSIZE_PROLOG)
     374                {
     375                    kprintf(("VerifyProcTab32: verify failed for procedure no.%d\n",i));
     376                    return STATUS_DONE | STERR | 3;
     377                }
     378                break;
     379
     380            default:
     381                kprintf(("VerifyProcTab32: only EPT_PROC is implemented\n",i));
     382                return STATUS_DONE | STERR | 4;
    379383        }
    380384    }
     
    408412        if (pSMTE != NULL)
    409413        {
    410             pOTEBuf->cObjects = pSMTE->smte_objcnt;
     414            pOTEBuf->cObjects = (unsigned char)pSMTE->smte_objcnt;
    411415            if (pSMTE->smte_objcnt <= MAXKRNLOBJECTS)
    412416            {
     
    433437        kprintf(("GetOTEs32: failed. usRc = %d\n", usRc));
    434438
    435     return usRc | (usRc != 0 ? STATUS_DONE | STERR : STATUS_DONE);
     439    return (USHORT)(usRc | (usRc != NO_ERROR ? STATUS_DONE | STERR : STATUS_DONE));
    436440}
    437441
     
    442446 *            where the jmp instr should be placed.
    443447 *            On error it returns 0.
    444  * @param     p  Pointer to prolog.
     448 * @param     pach       Pointer to prolog.
     449 * @param     fOverload  TRUE:  Function is to be overloaded.
     450 *                       FALSE: Function is to be imported.
    445451 */
    446 static int interpretFunctionProlog(char *p)
     452static int interpretFunctionProlog(char *pach, BOOL fOverload)
    447453{
    448     int length;
    449454    int rc;
    450455
     
    459464     */
    460465
    461     if (p[0] == 0x55 && p[1] == 0x8b)
    462     {
    463         if (p[2] == 0xec)
     466    if (pach[0] == 0x55 && pach[1] == 0x8b)
     467    {
     468        if (pach[2] == 0xec)
    464469            rc = 3;
    465470        else
     
    472477             * There will never be any doubt when something goes wrong!
    473478             */
    474             switch(p[rc])
     479            switch(pach[rc])
    475480            {
    476481                case 0x33: /* xor (ldrClose, ldrOpen) */
     
    478483                    break;
    479484                case 0x8b:
    480                     if (p[rc+1] == 0x0d)
     485                    if (pach[rc+1] == 0x0d)
    481486                        rc += 6;
    482487                    else
     
    490495                    break;
    491496                default:
    492                     kprintf(("interpretFunctionProlog: unknown instruction 0x%x \n", p[rc]));
     497                    kprintf(("interpretFunctionProlog: unknown instruction 0x%x\n", pach[rc]));
    493498                    return 0;
    494499            }
     
    496501    }
    497502    else
    498         rc = 0;
     503    {
     504        /* special case for IOSftReadAt and IOSftWriteAt */
     505        if (fOverload == FALSE && pach[0] == 0xB8 && (pach[5] == 0xEB || pach[5] == 0x55))
     506            rc = 5;
     507        else
     508            rc = 0;
     509    }
    499510
    500511    return rc;
     
    512523    int cb;
    513524
    514     /* verify */
     525    /*
     526     * verify proctable
     527     */
    515528    for (i = 0; i < NUMBER_OF_PROCS; i++)
    516529    {
    517         cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress);
     530        if (_aProcTab[i].fType != EPT_PROC && _aProcTab[i].fType != EPT_PROCIMPORT)
     531        {
     532            kprintf(("procInit: EPT_VAR is not supported. (procedure no.%d, cb=%d)\n", i, cb));
     533            return 1;
     534        }
     535        cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress, _aProcTab[i].fType == EPT_PROC);
    518536        if (cb <= 0 || cb + 5 >= MAXSIZE_PROLOG)
    519537        {
    520             kprintf(("rehookFunctions: verify failed for procedure no.%d, cb=%d\n", i, cb));
     538            kprintf(("procInit: verify failed for procedure no.%d, cb=%d\n", i, cb));
    521539            return 1;
    522540        }
    523541    }
    524542
    525     /* rehook */
     543    /*
     544     * rehook / import
     545     */
    526546    for (i = 0; i < NUMBER_OF_PROCS; i++)
    527547    {
    528         cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress);
    529         if (cb > 0 && cb + 5 < MAXSIZE_PROLOG)
    530         {
    531             char *pMy;
    532             switch (i)
     548        switch (_aProcTab[i].fType)
     549        {
     550            case EPT_PROC:
    533551            {
    534                 case iLDRREAD:          pMy = (char*)myldrRead; break;
    535                 case iLDROPEN:          pMy = (char*)myldrOpen; break;
    536                 case iLDRCLOSE:         pMy = (char*)myldrClose; break;
    537                 case iLDRQAPPTYPE:      pMy = (char*)myLDRQAppType; break;
    538 
    539                 default:
    540                     kprintf(("rehookFunctions: Someone has added function without updating the switch! i=%d\n", i));
    541                     Int3();
    542                     return 2;
     552                cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress, TRUE);
     553                if (cb > 0 && cb + 5 < MAXSIZE_PROLOG)
     554                {
     555                    static unsigned auFuncs[NUMBER_OF_PROCS] = /* This table must be updated with the overloading functions. */
     556                    {
     557                        (unsigned)myldrRead,
     558                        (unsigned)myldrOpen,
     559                        (unsigned)myldrClose,
     560                        (unsigned)myLDRQAppType,
     561                        (unsigned)myldrEnum32bitRelRecs,
     562                        0,
     563                        0,
     564                        0,
     565                        0,
     566                        0,
     567                    };
     568
     569                    /* copy function prolog */
     570                    memcpy(callTab[i], (void*)_aProcTab[i].ulAddress, (size_t)cb);
     571
     572                    /* jump from calltab to original function */
     573                    callTab[i][cb] = 0xE9; /* jmp */
     574                    *(unsigned*)(void*)&callTab[i][cb+1] = _aProcTab[i].ulAddress + cb - (unsigned)&callTab[i][cb+5];
     575
     576
     577                    /* jump from original function to my function - an cli(?) could be needed here */
     578                    *(char*)_aProcTab[i].ulAddress = 0xE9; /* jmp */
     579                    *(unsigned*)(_aProcTab[i].ulAddress + 1) = auFuncs[i] - (_aProcTab[i].ulAddress + 5);
     580                }
     581                else
     582                {   /* !fatal! - this could never happen really... */
     583                    kprintf(("procInit: FATAL verify failed for procedure no.%d when rehooking it!\n",i));
     584                    Int3(); /* ipe - later! */
     585                    return 1;
     586                }
     587                break;
    543588            }
    544589
    545             /* copy function prolog */
    546             memcpy(callTab[i], (void*)_aProcTab[i].ulAddress, (size_t)cb);
    547 
    548             /* jump from calltab to original function */
    549             callTab[i][cb] = 0xE9; /* jmp */
    550             *(unsigned*)&callTab[i][cb+1] = _aProcTab[i].ulAddress + cb - (unsigned)&callTab[i][cb+5];
    551 
    552             /* jump from original function to my function - an cli could be needed here */
    553             *(char*)_aProcTab[i].ulAddress = 0xE9; /* jmp */
    554             *(unsigned*)(_aProcTab[i].ulAddress + 1) = (unsigned)pMy - (_aProcTab[i].ulAddress + 5);
    555         }
    556         else
    557         {
    558             /* !fatal! - this could never happen really... */
    559             kprintf(("rehookFunctions: FATAL verify failed for procedure no.%d when rehooking it!\n",i));
    560             Int3(); /* ipe - later! */
    561             return 1;
    562         }
    563     }
     590            case EPT_PROCIMPORT:
     591            {
     592                cb = interpretFunctionProlog((char*)_aProcTab[i].ulAddress, FALSE);
     593                if (cb > 0 && cb + 5 < MAXSIZE_PROLOG)
     594                {
     595                    /* jump from calltab to original function */
     596                    callTab[i][0] = 0xE9; /* jmp */
     597                    *(unsigned*)(void*)&callTab[i][1] = _aProcTab[i].ulAddress - (unsigned)&callTab[i][cb+5];
     598                }
     599                else
     600                {   /* !fatal! - this could never happen really... */
     601                    kprintf(("procInit: FATAL verify failed for procedure no.%d when importing it!\n",i));
     602                    Int3(); /* ipe - later! */
     603                    return 1;
     604                }
     605                break;
     606            }
     607
     608            default:
     609                kprintf(("procInit: EPT_VAR is not supported. (procedure no.%d, cb=%d)\n", i, cb));
     610                Int3(); /* ipe - later! */
     611                return 1;
     612        } /* switch - type */
     613    }   /* for */
    564614
    565615    return NO_ERROR;
  • trunk/src/win32k/fastdep.c

    r1678 r2501  
    1 /* $Id: fastdep.c,v 1.6 1999-11-10 01:45:29 bird Exp $
     1/* $Id: fastdep.c,v 1.7 2000-01-22 18:20:54 bird Exp $
    22 *
    33 * Fast dependants. (Fast = Quick and Dirty!)
     
    9797        TRUE             /* fSrcWhenObj */
    9898    };
     99
     100    if (argc == 1)
     101    {
     102        syntax();
     103        return -87;
     104    }
    99105
    100106    /* look for depend filename option "-d <filename>" */
  • trunk/src/win32k/include/LdrCalls.h

    r1678 r2501  
    1 /* $Id: LdrCalls.h,v 1.2 1999-11-10 01:45:32 bird Exp $
     1/* $Id: LdrCalls.h,v 1.3 2000-01-22 18:21:00 bird Exp $
    22 *
    33 * Prototypes for the loader overrided function.
     
    2424 * _ldrClose
    2525 */
    26 extern ULONG LDRCALL _ldrClose( /* retd  0x04 */
     26extern ULONG LDRCALL ldrClose( /* retd  0x04 */
    2727    SFN p1                      /* ebp + 0x08 */
    2828    );
     
    3434 * _ldrOpen
    3535 */
    36 extern ULONG LDRCALL _ldrOpen(  /* retd  0x0c */
     36extern ULONG LDRCALL ldrOpen(   /* retd  0x0c */
    3737    PSFN p1,                    /* ebp + 0x08 */
    3838    PCHAR p2,                   /* ebp + 0x0c */
     
    4646 * _ldrRead
    4747 */
    48 extern ULONG LDRCALL _ldrRead(  /* retd  0x18 */
     48extern ULONG LDRCALL ldrRead(   /* retd  0x18 */
    4949    SFN p1,                     /* ebp + 0x08 */
    5050    ULONG p2,                   /* ebp + 0x0c */
     
    6969 * _LDRQAppType
    7070 */
    71 extern ULONG LDRCALL _LDRQAppType(  /* retd  0x08 */
     71extern ULONG LDRCALL LDRQAppType(   /* retd  0x08 */
    7272    ULONG p1,                       /* ebp + 0x08 */
    7373    ULONG p2                        /* ebp + 0x0c */
     
    7676ULONG LDRCALL myLDRQAppType(ULONG,ULONG);
    7777
     78
     79/**
     80 * ldrEnum32bitRelRecs
     81 * @param  pMTE           Pointer to MTE for this module.
     82 * @param  iObject        Object index. 0-based!
     83 * @param  iPageTabl      Page index. 0-based!
     84 * @param  pvPage         Pointer to page buffer.
     85 * @param  ulPageAddress  Note! Page is not present.
     86 * @param  pPTDA
     87 *
     88 */
     89extern ULONG LDRCALL ldrEnum32bitRelRecs( /* retd 0x20 */
     90    PMTE pMTE,                      /* ebp + 0x08 */
     91    ULONG iObject,                  /* ebp + 0x0c */
     92    ULONG iPageTable,               /* ebp + 0x10 */
     93    PVOID pvPage,                   /* ebp + 0x14 */
     94    ULONG ulPageAddress,            /* ebp + 0x18 */
     95    PVOID pvPTDA                    /* ebp + 0x1c */
     96    );
     97
     98ULONG LDRCALL myldrEnum32bitRelRecs(PMTE, ULONG, ULONG, PVOID, ULONG, PVOID);
    7899
    79100
  • trunk/src/win32k/include/ModuleBase.h

    r1678 r2501  
    1 /* $Id: ModuleBase.h,v 1.1 1999-11-10 01:45:31 bird Exp $
     1/* $Id: ModuleBase.h,v 1.2 2000-01-22 18:20:58 bird Exp $
    22 *
    33 * ModuleBase - Declaration of the Basic module class.
     
    2222#define ERROR_INTERNAL_PROCESSING_ERROR     0x42000002UL
    2323
     24
     25/*
     26 * Some useful macros.
     27 */
     28#define NOREF(a) (a=a)                      /* Not referenced parameter warning fix. */
     29#define ALIGN(a, alignment) (((a) + (alignment - 1UL)) & ~(alignment - 1UL))
     30                                            /* aligns something, a,  up to nearest alignment boundrary-
     31                                             * Note: Aligment must be a 2**n number. */
    2432
    2533/*
     
    7482    virtual ULONG  init(PCSZ pszFilename);
    7583    virtual ULONG  read(ULONG offLXFile, PVOID pvBuffer, ULONG cbToRead, ULONG flFlags, PMTE pMTE) = 0;
     84    virtual ULONG  applyFixups(PMTE pMTE, ULONG iObject, ULONG iPageTable, PVOID pvPage,
     85                               ULONG ulPageAddress, PVOID pvPTDA); /*(ldrEnum32bitRelRecs)*/
    7686    #ifndef RING0
    7787    virtual ULONG  writeFile(PCSZ pszLXFilename);
  • trunk/src/win32k/include/OS2KIO.h

    r2461 r2501  
    1 /* $Id: OS2KIO.h,v 1.2 2000-01-17 16:52:25 bird Exp $
     1/* $Id: OS2KIO.h,v 1.3 2000-01-22 18:20:58 bird Exp $
    22 *
    3  * OS/2 kernel IO, typedefs and macros.
     3 * OS/2 kernel IO: prototypes, typedefs and macros.
    44 *
    55 * Project Odin Software License can be found in LICENSE.TXT
     
    1010#define _OS2KIO_h_
    1111
    12 APIRET KRNLCALL IOSftOpen(PSZ pszFilename,
    13                           ULONG flOpenFlags,  /* probably similar to DosOpen */
    14                           ULONG fsOpenMode,   /* probably similar to DosOpen */
    15                           PSFN phFile,
    16                           PULONG pulsomething); /* EA? */
    17 APIRET KRNLCALL IOSftClose(SFN hFile);
    18 APIRET KRNLCALL IOSftTransPath(PSZ pszPath /* IN and OUT? */);
    19 APIRET KRNLCALL IOSftReadAt(SFN hFile,
    20                             PULONG pulActual,
    21                             PVOID pvBuffer,
    22                             ULONG flFlags,
    23                             ULONG cbBuffer);
    24 APIRET KRNLCALL IOSftWriteAt(SFN hFile,
    25                             PULONG pulActual,
    26                             PVOID pvBuffer,
    27                             ULONG flFlags,
    28                             ULONG cbBuffer);
    29 /* APIRET KRNLCALL IOSft(1,2,3,4,5); */
     12
     13/**
     14 * Opens a given file.
     15 * @returns  NO_ERROR on success. other on error.
     16 * @param    pszFilename   Pointer to filename.
     17 * @param    flOpenFlags   Open flags. (similar to DosOpen)
     18 * @param    fsOpenMode    Open mode flags. (similar to DosOpen)
     19 * @param    phFile        Pointer to filehandle.
     20 * @param    pulsomething  16-bit near (?) pointer to a variable - unknown. NULL is allowed. EA?
     21 */
     22APIRET KRNLCALL IOSftOpen(
     23    PSZ pszFilename,
     24    ULONG flOpenFlags,
     25    ULONG fsOpenMode,
     26    PSFN phFile,
     27    PULONG pulsomething
     28    );
     29
     30
     31/**
     32 * Closes the specified file.
     33 * @returns  NO_ERROR on success. other on error.
     34 * @param    hFile      File handle - System File Number.
     35 */
     36APIRET KRNLCALL IOSftClose(
     37    SFN hFile
     38    );
     39
     40
     41/**
     42 * Probably this function will expand a relative path to a full path.
     43 * @returns  NO_ERROR on success. other on error. (?)
     44 * @param    pszPath  Pointer to path to expand. Contains the full path upon return. (?)
     45 *                    This buffer should probably be of CCHMAXPATH length.
     46 */
     47APIRET KRNLCALL IOSftTransPath(
     48    PSZ pszPath
     49    );
     50
     51
     52/**
     53 * Read at a given offset in the a file.
     54 * @returns  NO_ERROR on success. other on error.
     55 * @param    hFile      File handle - System File Number.
     56 * @param    pcbActual  Pointer to variable which upon input holds the number
     57 *                      of bytes to read, on output the actual number of bytes read.
     58 * @param    pvBuffer   Pointer to the read buffer.
     59 * @param    flFlags    Read flags?
     60 * @param    ulOffset   File offset to read from. (0=start of file)
     61 */
     62APIRET KRNLCALL IOSftReadAt(
     63    SFN hFile,
     64    PULONG pcbActual,
     65    PVOID pvBuffer,
     66    ULONG flFlags,
     67    ULONG ulOffset
     68    );
     69
     70
     71/**
     72 * Write at a given offset in the a file.
     73 * @returns  NO_ERROR on success. other on error.
     74 * @param    hFile      File handle - System File Number.
     75 * @param    pcbActual  Pointer to variable which upon input holds the number
     76 *                      of bytes to write, on output the actual number of bytes write.
     77 * @param    pvBuffer   Pointer to the write buffer.
     78 * @param    flFlags    Read flags?
     79 * @param    ulOffset   File offset to write from. (0=start of file)
     80 */
     81APIRET KRNLCALL IOSftWriteAt(
     82    SFN hFile,
     83    PULONG pcbActual,
     84    PVOID pvBuffer,
     85    ULONG flFlags,
     86    ULONG ulOffset
     87    );
    3088
    3189#endif
  • trunk/src/win32k/include/avl.h

    r1467 r2501  
    1 /* $Id: avl.h,v 1.1 1999-10-27 02:02:55 bird Exp $
     1/* $Id: avl.h,v 1.2 2000-01-22 18:20:59 bird Exp $
    22 *
    33 * AVL-Tree (lookalike) declaration.
     
    1515#endif
    1616
     17/*
     18 * AVL configuration. PRIVATE!
     19 */
     20#define AVL_MAX_HEIGHT      19          /* Up to 2^16 nodes. */
     21
    1722/**
    1823 * AVL key type
     
    2530typedef struct _AVLNodeCore
    2631{
    27     unsigned char           uchHeight; /* Height of this tree: max(heigth(left), heigth(right)) + 1 */
     32    AVLKEY                  Key;       /* Key value. */
    2833    struct  _AVLNodeCore *  pLeft;     /* Pointer to left leaf node. */
    2934    struct  _AVLNodeCore *  pRight;    /* Pointer to right leaf node. */
    30     AVLKEY                  Key;       /* Key value. */
     35    unsigned char           uchHeight; /* Height of this tree: max(heigth(left), heigth(right)) + 1 */
    3136} AVLNODECORE, *PAVLNODECORE, **PPAVLNODECORE;
    3237
     38/**
     39 * AVL Enum data - All members are PRIVATE! Don't touch!
     40 */
     41typedef struct _AVLEnumData
     42{
     43    char         fFromLeft;
     44    char         cEntries;
     45    char         achFlags[AVL_MAX_HEIGHT];
     46    PAVLNODECORE aEntries[AVL_MAX_HEIGHT];
     47} AVLENUMDATA, *PAVLENUMDATA;
    3348
    34 void AVLInsert(PPAVLNODECORE ppTree, PAVLNODECORE pNode);
    35 PAVLNODECORE AVLRemove(PPAVLNODECORE ppTree, AVLKEY Key);
    36 PAVLNODECORE AVLGet(PPAVLNODECORE ppTree, AVLKEY Key);
    37 PAVLNODECORE AVLGetWithAdjecentNodes(PPAVLNODECORE ppTree, AVLKEY Key, PPAVLNODECORE ppLeft, PPAVLNODECORE ppRight);
     49
     50/*
     51 * callback type
     52 */
     53typedef unsigned ( _PAVLCALLBACK)(PAVLNODECORE, void*);
     54typedef _PAVLCALLBACK *PAVLCALLBACK;
     55
     56
     57void            AVLInsert(PPAVLNODECORE ppTree, PAVLNODECORE pNode);
     58PAVLNODECORE    AVLRemove(PPAVLNODECORE ppTree, AVLKEY Key);
     59PAVLNODECORE    AVLGet(PPAVLNODECORE ppTree, AVLKEY Key);
     60PAVLNODECORE    AVLGetWithParent(PPAVLNODECORE ppTree, PPAVLNODECORE ppParent, AVLKEY Key);
     61PAVLNODECORE    AVLGetWithAdjecentNodes(PPAVLNODECORE ppTree, AVLKEY Key, PPAVLNODECORE ppLeft, PPAVLNODECORE ppRight);
     62unsigned        AVLDoWithAll(PPAVLNODECORE ppTree, int fFromLeft, PAVLCALLBACK pfnCallBack, void *pvParam);
     63PAVLNODECORE    AVLBeginEnumTree(PPAVLNODECORE ppTree, PAVLENUMDATA pEnumData, int fFromLeft);
     64PAVLNODECORE    AVLGetNextNode(PAVLENUMDATA pEnumData);
     65PAVLNODECORE    AVLGetBestFit(PPAVLNODECORE ppTree, AVLKEY Key, int fAbove);
     66
    3867
    3968
  • trunk/src/win32k/include/ldr.h

    r1678 r2501  
    1 /* $Id: ldr.h,v 1.4 1999-11-10 01:45:32 bird Exp $
     1/* $Id: ldr.h,v 1.5 2000-01-22 18:20:59 bird Exp $
    22 *
    33 * ldr - loader header file.
     
    6363        } MODULE, *PMODULE;
    6464
    65         #define MOD_FLAGS_IN_MTETREE    0x00000010 /* The node is present in the MTE-tree. */
    66         #define MOD_TYPE_MASK           0x0000000F /* Type mask. */
    67         #define MOD_TYPE_PE2LX          0x00000001 /* Pe2Lx module. */
    68         #define MOD_TYPE_ELF2LX         0x00000002 /* Elf2Lx module. */
    69         #define MOD_TYPE_SCRIPT         0x00000003 /* Script module. */
    70         #define MOD_TYPE_PE             0x00000004 /* Pe module. */
     65        #define MOD_FLAGS_IN_MTETREE    0x00000010UL /* The node is present in the MTE-tree. */
     66        #define MOD_TYPE_MASK           0x0000000FUL /* Type mask. */
     67        #define MOD_TYPE_PE2LX          0x00000001UL /* Pe2Lx module. */
     68        #define MOD_TYPE_ELF2LX         0x00000002UL /* Elf2Lx module. */
     69        #define MOD_TYPE_SCRIPT         0x00000003UL /* Script module. */
     70        #define MOD_TYPE_PE             0x00000004UL /* Pe module. */
    7171
    7272
  • trunk/src/win32k/include/options.h

    r1678 r2501  
    1 /* $Id: options.h,v 1.4 1999-11-10 01:45:33 bird Exp $
     1/* $Id: options.h,v 1.5 2000-01-22 18:21:01 bird Exp $
    22 *
    33 * Options.
     
    3333
    3434/* Set defaults. */
    35 #define SET_OPTIONS_TO_DEFAULT(o)           \
    36             o.fQuiet      = FALSE;          \
    37             o.usCom       = OUTPUT_COM2;    \
    38             o.fLogging    = FALSE;          \
    39             o.fKernel     = KF_UNI;         \
    40             o.ulBuild     = ~0UL;           \
    41             o.usVerMajor  = ~0;             \
    42             o.usVerMinor  = ~0;             \
    43             o.fPE         = FLAGS_PE_PE2LX; \
    44             o.ulInfoLevel = INFOLEVEL_QUIET;\
    45             o.fElf        = FALSE;          \
    46             o.fScript     = FALSE;          \
    47             o.fNoLoader   = FALSE;          \
    48             o.cbHeap      = 0x100000; /* 1MB */ \
    49             o.cbHeapMax   = 0x100000; /* 1MB */ \
    50             o.cbHeapResident    = 0x10000; /* 64KB */ \
    51             o.cbHeapMaxResident = 0x1000;  /* 4KB */ \
     35#define SET_OPTIONS_TO_DEFAULT(o)                       \
     36            o.fQuiet      = FALSE;                      \
     37            o.usCom       = OUTPUT_COM2;                \
     38            o.fLogging    = FALSE;                      \
     39            o.fKernel     = KF_UNI;                     \
     40            o.ulBuild     = ~0UL;                       \
     41            o.usVerMajor  = (unsigned short)~0;         \
     42            o.usVerMinor  = (unsigned short)~0;         \
     43            o.fPE         = FLAGS_PE_PE2LX;             \
     44            o.ulInfoLevel = INFOLEVEL_QUIET;            \
     45            o.fElf        = FALSE;                      \
     46            o.fScript     = FALSE;                      \
     47            o.fNoLoader   = FALSE;                      \
     48            o.cbHeap      = 0x100000; /* 1MB */         \
     49            o.cbHeapMax   = 0x100000; /* 1MB */         \
     50            o.cbHeapResident    = 0x10000; /* 64KB */   \
     51            o.cbHeapMaxResident = 0x1000;  /* 4KB */    \
    5252
    5353
  • trunk/src/win32k/include/pe2lx.h

    r1678 r2501  
    1 /* $Id: pe2lx.h,v 1.6 1999-11-10 01:45:33 bird Exp $
     1/* $Id: pe2lx.h,v 1.7 2000-01-22 18:21:01 bird Exp $
    22 *
    33 * Pe2Lx class declarations. Ring 0 and Ring 3
     
    6666    ULONG  init(PCSZ pszFilename);
    6767    ULONG  read(ULONG offLXFile, PVOID pvBuffer, ULONG cbToRead, ULONG flFlags, PMTE pMTE);
     68    ULONG  applyFixups(PMTE pMTE, ULONG iObject, ULONG iPageTable, PVOID pvPage,
     69                       ULONG ulPageAddress, PVOID pvPTDA); /*(ldrEnum32bitRelRecs)*/
     70
    6871    #ifndef RING0
    6972    ULONG  writeLxFile(PCSZ pszLXFilename);
  • trunk/src/win32k/include/probkrnl.h

    r1678 r2501  
    1 /* $Id: probkrnl.h,v 1.3 1999-11-10 01:45:33 bird Exp $
     1/* $Id: probkrnl.h,v 1.4 2000-01-22 18:21:01 bird Exp $
    22 *
    33 * Include file for ProbKrnl.
    44 *
    5  * Copyright (c) 1998-1999 knut st. osmundsen
     5 * Copyright (c) 1998-2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
    66 *
    77 * Project Odin Software License can be found in LICENSE.TXT
     
    1616*   Defined Constants And Macros                                               *
    1717*******************************************************************************/
    18 #define NUMBER_OF_PROCS 4   /* remeber to sync this with ldr_functions.h and dev32_start.asm */
    19 
    20 /* indexes into the _ProcTab/ProcTab table */
    21 #define iLDRREAD              0
    22 #define iLDROPEN              1
    23 #define iLDRCLOSE             2
    24 #define iLDRQAPPTYPE          3
    25 
     18#define NUMBER_OF_PROCS      10
    2619#define MAX_LENGTH_NAME      32
    2720
    2821/* entry-point type flag */
    29 #define EPT_PROC              0 /* procedure */
    30 #define EPT_VAR               1 /* variable/non-procedure */
     22#define EPT_PROC              0 /* procedure - overload procedure*/
     23#define EPT_PROCIMPORT        1 /* procedure - import only */
     24#define EPT_VAR               2 /* variable/non-procedure - not implemented yet */
    3125
    3226
     
    5448*******************************************************************************/
    5549extern PROCS _aProcTab[NUMBER_OF_PROCS];    /* 'aProcTab'        in PrbKrnl.c */
    56 extern unsigned long int _ulBuild;          /* 'ulBuild'         in PrbKrnl.c */
    57 extern unsigned long int _fInitSuccess;     /* 'fInitSuccess'    in PrbKrnl.c */
    58 extern unsigned long int _usVerMajor;       /* 'usVerMajor'      in PrbKrnl.c */
    59 extern unsigned long int _usVerMinor;       /* 'usVerMinor'      in PrbKrnl.c */
     50extern unsigned long int  _ulBuild;         /* 'ulBuild'         in PrbKrnl.c */
     51extern unsigned short int _usVerMajor;      /* 'usVerMajor'      in PrbKrnl.c */
     52extern unsigned short int _usVerMinor;      /* 'usVerMinor'      in PrbKrnl.c */
    6053
    6154#ifdef INCL_16 /* 16-bit only */
  • trunk/src/win32k/ldr/ModuleBase.cpp

    r1678 r2501  
    1 /* $Id: ModuleBase.cpp,v 1.1 1999-11-10 01:45:35 bird Exp $
     1/* $Id: ModuleBase.cpp,v 1.2 2000-01-22 18:21:01 bird Exp $
    22 *
    33 * ModuleBase - Implementetation.
     
    132132    return NO_ERROR;
    133133}
     134
     135
     136
     137/**
     138 * Applies relocation fixups to a page which is being loaded.
     139 * @returns    NO_ERROR on success?
     140 *             error code on error?
     141 * @param      pMTE           Pointer Module Table Entry.
     142 * @param      iObject        Index into the object table. (0-based)
     143 * @param      iPageTable     Index into the page table. (0-based)
     144 * @param      pvPage         Pointer to the page which is being loaded.
     145 * @param      ulPageAddress  Address of page.
     146 * @param      pvPTDA         Pointer to Per Task Data Aera
     147 * @remark     Stub.
     148 */
     149ULONG  ModuleBase::applyFixups(PMTE pMTE, ULONG iObject, ULONG iPageTable, PVOID pvPage,
     150                               ULONG ulPageAddress, PVOID pvPTDA)
     151{
     152    NOREF(pMTE);
     153    NOREF(iObject);
     154    NOREF(iPageTable);
     155    NOREF(pvPage);
     156    NOREF(ulPageAddress);
     157    NOREF(pvPTDA);
     158    return NO_ERROR;
     159}
     160
    134161
    135162
  • trunk/src/win32k/ldr/calltab.asm

    r1467 r2501  
    1 ; $Id: calltab.asm,v 1.2 1999-10-27 02:02:58 bird Exp $
     1; $Id: calltab.asm,v 1.3 2000-01-22 18:21:01 bird Exp $
    22;
    33; callTab - Call back again table - table with entry for each function which is overrided.
     
    1919;
    2020    public callTab
    21     public __ldrClose@4
    22     public __ldrOpen@12
    23     public __ldrRead@24
    24     public __LDRQAppType@8
    25 
     21    public _ldrClose@4
     22    public _ldrOpen@12
     23    public _ldrRead@24
     24    public _LDRQAppType@8
     25    public _ldrEnum32bitRelRecs@24
     26    public _IOSftOpen@20
     27    public _IOSftClose@4
     28    public _IOSftTransPath@4
     29    public _IOSftReadAt@20
     30    public _IOSftWriteAt@20
    2631
    2732;
     
    3136
    3237
     38
    3339CALLTAB segment
    3440    assume cs:CALLTAB, ds:flat, ss:nothing
    35 
    3641;
    37 ; must match with the aProcTab array in dev16\ProbKrnl.c
     42; callTab is an array of evt. function prologs with a jump to the real function.
     43; Imported and Overrided OS/2 kernel functions are called tru this table.
     44;
     45; This array of near procedures are parallel to the aProcTab array in dev16\ProbKrnl.c.
     46; Remember to update both!.
    3847;
    3948callTab:
    40 __ldrRead@24 PROC NEAR
     49_ldrRead@24 PROC NEAR
    4150    db MAXSIZE_PROLOG dup(0cch)
    42 __ldrRead@24 ENDP
     51_ldrRead@24 ENDP
    4352
    44 __ldrOpen@12 PROC NEAR
     53_ldrOpen@12 PROC NEAR
    4554    db MAXSIZE_PROLOG dup(0cch)
    46 __ldrOpen@12 ENDP
     55_ldrOpen@12 ENDP
    4756
    48 __ldrClose@4 PROC NEAR
     57_ldrClose@4 PROC NEAR
    4958    db MAXSIZE_PROLOG dup(0cch)
    50 __ldrClose@4 ENDP
     59_ldrClose@4 ENDP
    5160
    52 __LDRQAppType@8 PROC NEAR
     61_LDRQAppType@8 PROC NEAR
    5362    db MAXSIZE_PROLOG dup(0cch)
    54 __LDRQAppType@8 ENDP
     63_LDRQAppType@8 ENDP
    5564
    56 if 0
    57     public __LDRLoadExe
    58 __LDRLoadExe PROC NEAR
     65_ldrEnum32bitRelRecs@24 PROC NEAR
    5966    db MAXSIZE_PROLOG dup(0cch)
    60 __LDRLoadExe END
     67_ldrEnum32bitRelRecs@24 ENDP
    6168
    62     public __ldrGetResource
    63 __ldrGetResource PROC NEAR
     69
     70_IOSftOpen@20 PROC NEAR
    6471    db MAXSIZE_PROLOG dup(0cch)
    65 __ldrGetResource ENDP
     72_IOSftOpen@20 ENDP
    6673
    67     public __ldrOpenNewExe
    68 __ldrOpenNewExe PROC NEAR
     74_IOSftClose@4 PROC NEAR
    6975    db MAXSIZE_PROLOG dup(0cch)
    70 __ldrOpenNewExe ENDP
     76_IOSftClose@4 ENDP
    7177
    72     public __ldrCreateMte
    73 __ldrCreateMte PROC NEAR
     78_IOSftTransPath@4 PROC NEAR
    7479    db MAXSIZE_PROLOG dup(0cch)
    75 __ldrCreateMte ENDP
     80_IOSftTransPath@4 ENDP
    7681
    77     public __ldrGetMte
    78 __ldrGetMte PROC NEAR
     82_IOSftReadAt@20 PROC NEAR
    7983    db MAXSIZE_PROLOG dup(0cch)
    80 __ldrGetMte ENDP
     84_IOSftReadAt@20 ENDP
    8185
    82 endif
     86_IOSftWriteAt@20 PROC NEAR
     87    db MAXSIZE_PROLOG dup(0cch)
     88_IOSftWriteAt@20 ENDP
     89
    8390
    8491CALLTAB ENDS
  • trunk/src/win32k/ldr/ldr.cpp

    r1678 r2501  
    1 /* $Id: ldr.cpp,v 1.6 1999-11-10 01:45:36 bird Exp $
     1/* $Id: ldr.cpp,v 1.7 2000-01-22 18:21:01 bird Exp $
    22 *
    33 * ldr.cpp - Loader helpers.
     
    8383PMODULE     getModuleByMTE(PMTE pMTE)
    8484{
    85     PMODULE pMod = (PMODULE)AVLGet(&pMTERoot, (AVLKEY)pMTE);
    86     if (pMod == NULL)
    87     {
     85    #if 0
     86        /* Not 100% sure that this will work correctly! */
     87        PMODULE pMod = (PMODULE)AVLGet(&pMTERoot, (AVLKEY)pMTE);
     88        if (pMod == NULL)
     89        {
     90            #ifdef DEBUG
     91                if (pMTE <= (PMTE)0x10000)
     92                {
     93                    kprintf(("getModuleByMTE: invalid pMTE pointer - %#8x\n", pMTE));
     94                    return NULL;
     95                }
     96            #endif
     97            pMod = (PMODULE)AVLGet(&pSFNRoot, (AVLKEY)pMTE->mte_sfn);
     98            if (pMod != NULL)
     99            {
     100                pMod->coreMTE.Key = (AVLKEY)pMTE;
     101                pMod->fFlags |= MOD_FLAGS_IN_MTETREE;
     102                AVLInsert(&pMTERoot, (PAVLNODECORE)((unsigned)pMod + offsetof(MODULE, coreMTE)));
     103            }
     104        }
     105        else
     106            pMod = (PMODULE)((unsigned)pMod - offsetof(MODULE, coreMTE));
     107        return pMod;
     108    #else
     109        /* Use this for the time being. */
    88110        #ifdef DEBUG
    89         if (pMTE <= (PMTE)0x10000)
    90         {
    91             kprintf(("getModuleByMTE: invalid pMTE pointer - %#8x\n", pMTE));
    92             return NULL;
    93         }
     111            if (pMTE <= (PMTE)0x10000)
     112            {
     113                kprintf(("getModuleByMTE: invalid pMTE pointer - %#8x\n", pMTE));
     114                return NULL;
     115            }
    94116        #endif
    95         pMod = (PMODULE)AVLGet(&pSFNRoot, (AVLKEY)pMTE->mte_sfn);
    96         if (pMod != NULL)
    97         {
    98             pMod->coreMTE.Key = (AVLKEY)pMTE;
    99             pMod->fFlags |= MOD_FLAGS_IN_MTETREE;
    100             AVLInsert(&pMTERoot, (PAVLNODECORE)((unsigned)pMod + offsetof(MODULE, coreMTE)));
    101         }
    102     }
    103     else
    104         pMod = (PMODULE)((unsigned)pMod - offsetof(MODULE, coreMTE));
    105     return pMod;
     117        if (GetState(pMTE->mte_sfn) == HSTATE_OUR)
     118            return (PMODULE)AVLGet(&pSFNRoot, (AVLKEY)pMTE->mte_sfn);
     119
     120        return NULL;
     121    #endif
    106122}
    107123
     
    149165            return ERROR_INVALID_PARAMETER;
    150166        }
    151         if ((fFlags & MOD_TYPE_MASK) == 0 || (fFlags  & ~MOD_TYPE_MASK) != 0)
     167        if ((fFlags & MOD_TYPE_MASK) == 0 || (fFlags  & ~MOD_TYPE_MASK) != 0UL)
    152168        {
    153169            kprintf(("addModule: invalid parameter: fFlags = 0x%#8x\n", fFlags));
     
    242258{
    243259    int rc = NO_ERROR;
    244     int i;
    245260
    246261    /* init state table */
  • trunk/src/win32k/ldr/myLDRQAppType.cpp

    r1678 r2501  
    1 /* $Id: myLDRQAppType.cpp,v 1.2 1999-11-10 01:45:36 bird Exp $
     1/* $Id: myLDRQAppType.cpp,v 1.3 2000-01-22 18:21:02 bird Exp $
    22 *
    33 * _myLDRQAppType - _LDRQAppType overload.
     
    3636ULONG LDRCALL myLDRQAppType(ULONG p1, ULONG p2)
    3737{
    38     int rc;
     38    APIRET rc;
    3939
    4040    kprintf(("_LDRQAppType: entry\n"));
    4141    fQAppType = 1;
    4242
    43     rc = _LDRQAppType(p1, p2);
     43    rc = LDRQAppType(p1, p2);
    4444
    4545    fQAppType = 0;
  • trunk/src/win32k/ldr/myldrClose.cpp

    r1678 r2501  
    1 /* $Id: myldrClose.cpp,v 1.4 1999-11-10 01:45:36 bird Exp $
     1/* $Id: myldrClose.cpp,v 1.5 2000-01-22 18:21:02 bird Exp $
    22 *
    3  * myldrClose - _ldrClose
     3 * myldrClose - ldrClose
    44 *
    55 * Copyright (c) 1998-1999 knut st. osmundsen
     
    4141ULONG LDRCALL myldrClose(SFN hFile)
    4242{
    43     int rc;
    44 
    4543    /* closes handle */
    46     kprintf(("_ldrClose: hFile = %.4x\n", hFile));
     44    kprintf(("ldrClose: hFile = %.4x\n", hFile));
    4745    if (GetState(hFile) == HSTATE_OUR)
    4846    {
     47        APIRET rc;
     48
    4949        #ifdef DEBUG
    5050        PMODULE pMod = getModuleBySFN(hFile);
     
    5252            pMod->Data.pModule->dumpVirtualLxFile();
    5353        else
    54             kprintf(("_ldrClose: getModuleBySFN failed!!!"));
     54            kprintf(("ldrClose: getModuleBySFN failed!!!"));
    5555        #endif
    5656
    5757        rc = removeModule(hFile);
    5858        if (rc != NO_ERROR)
    59             kprintf(("_ldrClose: removeModule retured rc=%d\n", rc));
     59            kprintf(("ldrClose: removeModule retured rc=%d\n", rc));
    6060
     61        #pragma info(notrd)
    6162        SetState(hFile, HSTATE_UNUSED);
     63        #pragma info(restore)
    6264    }
    6365
    64     return _ldrClose(hFile);
     66    return ldrClose(hFile);
    6567}
  • trunk/src/win32k/ldr/myldrOpen.cpp

    r1678 r2501  
    1 /* $Id: myldrOpen.cpp,v 1.5 1999-11-10 01:45:36 bird Exp $
     1/* $Id: myldrOpen.cpp,v 1.6 2000-01-22 18:21:02 bird Exp $
    22 *
    3  * myldrOpen - _ldrOpen.
     3 * myldrOpen - ldrOpen.
    44 *
    55 * Copyright (c) 1998-1999 knut st. osmundsen
     
    3939
    4040/**
    41  * _ldrOpen override.
     41 * ldrOpen override.
    4242 * @returns   Return code.
    4343 * @param     phFile       Pointer to file handler. Holds filehandle on output.
     
    4848{
    4949    ULONG rc;
    50     int i;
    5150
    52     rc = _ldrOpen(phFile, pszFilename, param3);
     51    rc = ldrOpen(phFile, pszFilename, param3);
    5352
    5453    if (rc == NO_ERROR)
    55         kprintf(("_ldrOpen:  phFile=%#.4x, flags=%#.8x, pszFn=%s\n", *phFile, param3, pszFilename));
     54        kprintf(("ldrOpen:  phFile=%#.4x, flags=%#.8x, pszFn=%s\n", *phFile, param3, pszFilename));
    5655
    5756    if (rc == NO_ERROR && (options.fElf || options.fPE != FLAGS_PE_NOT || options.fScript))
     
    6665         * This costs up to two disk reads!
    6766         */
    68         rc = _ldrRead(*phFile, 0UL, pMzHdr, 0UL, sizeof(IMAGE_DOS_HEADER), NULL);
     67        rc = ldrRead(*phFile, 0UL, pMzHdr, 0UL, sizeof(IMAGE_DOS_HEADER), NULL);
    6968        if (rc == NO_ERROR)
    7069        {
     
    7776
    7877                if (*(PULONG)pach != IMAGE_NT_SIGNATURE)
    79                     rc = _ldrRead(*phFile, pMzHdr->e_lfanew, pach, 0UL, sizeof(achBuffer), NULL);
     78                    rc = ldrRead(*phFile, pMzHdr->e_lfanew, pach, 0UL, sizeof(achBuffer), NULL);
    8079
    8180                if (rc == NO_ERROR && *(PULONG)pach == IMAGE_NT_SIGNATURE)
    8281                {   /* PE signature found */
    83                     kprintf(("_ldrOpen: PE executable...\n"));
     82                    kprintf(("ldrOpen: PE executable...\n"));
    8483                    if (options.fPE == FLAGS_PE_PE2LX
    8584                        || (options.fPE == FLAGS_PE_MIXED
     
    9695                            if (rc == NO_ERROR)
    9796                            {
    98                                 kprintf(("_ldrOpen: Successfully init of Pe2Lx object.\n"));
     97                                kprintf(("ldrOpen: Successfully init of Pe2Lx object.\n"));
    9998                                rc = addModule(*phFile, NULL, MOD_TYPE_PE2LX, pPe2Lx);
    10099                                if (rc == NO_ERROR)
     100                                    #pragma info(notrd)
    101101                                    SetState(*phFile, HSTATE_OUR);
     102                                    #pragma info(restore)
    102103                                else
    103                                     kprintf(("_ldrOpen: Failed to add the module. rc=%d\n"));
     104                                    kprintf(("ldrOpen: Failed to add the module. rc=%d\n"));
    104105                            }
    105106                            else
    106                                 kprintf(("_ldrOpen: Failed to init Pe2Lx object. rc=%d\n"));
     107                                kprintf(("ldrOpen: Failed to init Pe2Lx object. rc=%d\n"));
    107108                            if (rc != NO_ERROR)
    108109                                delete pPe2Lx;
    109110                        }
    110111                        else
    111                             kprintf(("_ldrOpen: Failed to allocate Pe2Lx object.\n"));
     112                            kprintf(("ldrOpen: Failed to allocate Pe2Lx object.\n"));
    112113                    }
    113114                    else
    114115                        if (options.fPE == FLAGS_PE_PE || options.fPE == FLAGS_PE_MIXED)
    115116                        {   /* pe.exe */
    116                             kprintf(("_ldrOpen: pe.exe - opening\n"));
    117                             _ldrClose(*phFile);
    118                             rc = _ldrOpen(phFile, "pe.exe", param3);  /* path....! problems! */
    119                             kprintf(("_ldrOpen: pe.exe - open returned with rc = %d\n", rc));
     117                            kprintf(("ldrOpen: pe.exe - opening\n"));
     118                            ldrClose(*phFile);
     119                            rc = ldrOpen(phFile, "pe.exe", param3);  /* path....! problems! */
     120                            kprintf(("ldrOpen: pe.exe - open returned with rc = %d\n", rc));
    120121                            return rc;
    121122                        }
     
    128129                {
    129130                    /* ELF signature found */
    130                     kprintf(("_ldrOpen: ELF executable! - not implemented yet!\n"));
     131                    kprintf(("ldrOpen: ELF executable! - not implemented yet!\n"));
    131132                }
    132133                else
     
    136137                        char *pszStart = pach+2;
    137138                        char *pszEnd;
    138                         kprintf(("_ldrOpen: unix script?\n"));
     139                        kprintf(("ldrOpen: unix script?\n"));
    139140
    140141                        achBuffer[sizeof(achBuffer)-1] = '\0'; /* just to make sure we don't read to much... */
     
    152153                            {
    153154                                *pszEnd = '\0';
    154                                 kprintf(("_ldrOpen: unix script - opening %s\n", pszStart));
    155                                 _ldrClose(*phFile);
    156                                 rc = _ldrOpen(phFile, pszStart, param3);
    157                                 kprintf(("_ldrOpen: unix script - open returned with rc = %d\n", rc));
     155                                kprintf(("ldrOpen: unix script - opening %s\n", pszStart));
     156                                ldrClose(*phFile);
     157                                rc = ldrOpen(phFile, pszStart, param3);
     158                                kprintf(("ldrOpen: unix script - open returned with rc = %d\n", rc));
    158159                            }
    159160                        }
    160161                        else
    161                             kprintf(("_ldrOpen: unix script - unexpected end of line/file. (line: %.10s\n", pach));
     162                            kprintf(("ldrOpen: unix script - unexpected end of line/file. (line: %.10s\n", pach));
    162163                    }
    163164            }
     
    165166        else
    166167        {
    167             kprintf(("_ldrOpen: _ldrRead failed with rc=%d when reading DosHdr.\n", rc));
     168            kprintf(("ldrOpen: ldrRead failed with rc=%d when reading DosHdr.\n", rc));
    168169            rc = NO_ERROR;
    169170        }
  • trunk/src/win32k/ldr/myldrRead.cpp

    r1678 r2501  
    1 /* $Id: myldrRead.cpp,v 1.5 1999-11-10 01:45:36 bird Exp $
     1/* $Id: myldrRead.cpp,v 1.6 2000-01-22 18:21:02 bird Exp $
    22 *
    3  * myldrRead - _ldrRead.
     3 * myldrRead - ldrRead.
    44 *
    55 * Copyright (c) 1998-1999 knut st. osmundsen
     
    5050    {
    5151        PMODULE pMod;
    52         kprintf(("_ldrRead+: hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x\n",hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE));
     52        kprintf(("ldrRead+: hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x\n",hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE));
    5353
    5454        pMod = getModuleBySFN(hFile);
     
    5757            /* I would love to have a pointer to the MTE */
    5858            if (pMod->pMTE == NULL && pMTE != NULL)
    59                 pMod->pMTE == pMTE;
     59                pMod->pMTE = pMTE;
    6060
    6161            /* debug */
    6262            if (ulFlags != 0)
    63                 kprintf(("_ldrRead: Warning ulFlags = 0x%x (!= 0)\n", ulFlags));
     63                kprintf(("ldrRead: Warning ulFlags = 0x%x (!= 0)\n", ulFlags));
    6464
    6565            if ((pMod->fFlags & MOD_TYPE_MASK) == MOD_TYPE_PE2LX)
     
    6767            else
    6868            {
    69                 kprintf(("_ldrRead: Invalid module type, %#x\n", pMod->fFlags & MOD_TYPE_MASK));
     69                kprintf(("ldrRead: Invalid module type, %#x\n", pMod->fFlags & MOD_TYPE_MASK));
    7070                rc = ERROR_READ_FAULT;
    7171            }
     
    7373        }
    7474        else
    75             kprintf(("_ldrRead:  DON'T PANIC! - but I can't get Node ptr! - This is really an IPE!\n"));
     75            kprintf(("ldrRead:  DON'T PANIC! - but I can't get Node ptr! - This is really an IPE!\n"));
    7676    }
    7777
    78     rc = _ldrRead(hFile, ulOffset, pBuffer, ulFlags, ulBytesToRead, pMTE);
     78    rc = ldrRead(hFile, ulOffset, pBuffer, ulFlags, ulBytesToRead, pMTE);
    7979
    8080    #if 0
    81     kprintf(("_ldrRead:  hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x rc=%d\n",
     81    kprintf(("ldrRead:  hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x rc=%d\n",
    8282             hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE,rc));
    8383    #endif
  • trunk/src/win32k/misc/avl.c

    r1467 r2501  
    1 /* $Id: avl.c,v 1.1 1999-10-27 02:02:59 bird Exp $
     1/* $Id: avl.c,v 1.2 2000-01-22 18:21:02 bird Exp $
    22 *
    33 * AVL-Tree (lookalike) implementation.
     
    1414
    1515/*
    16  * AVL configuration.
    17  */
    18 #define AVL_MAX_HEIGHT      19          /* Up to 2^16 nodes. */
    19 #define assert
    20 
    21 /*
    2216 * AVL helper macros.
    2317 */
    24 #define AVL_HEIGHTOF(pNode) ((pNode) != NULL ? pNode->uchHeight : 0UL)
     18#define AVL_HEIGHTOF(pNode) ((unsigned char)((pNode) != NULL ? pNode->uchHeight : 0))
    2519#define max(a,b) (((a) > (b)) ? (a) : (b))
    2620
     
    3327#include "dev32.h"
    3428
     29#include <builtin.h>
     30#define assert(a) ((a) ? (void)0 : __interrupt(3))
     31
    3532
    3633/*******************************************************************************
     
    4542    PPAVLNODECORE aEntries[AVL_MAX_HEIGHT];
    4643} AVLSTACK, *PAVLSTACK;
     44typedef struct _AVLStack2
     45{
     46    unsigned     cEntries;
     47    PAVLNODECORE aEntries[AVL_MAX_HEIGHT];
     48    char         achFlags[AVL_MAX_HEIGHT];
     49} AVLSTACK2, *PAVLSTACK2;
    4750
    4851
     
    200203
    201204/**
    202  * Gets node from the tree (does not remove it!)
     205 * Gets a node from the tree (does not remove it!)
    203206 * @returns   Pointer to the node holding the given key.
    204207 * @param     ppTree  Pointer to the AVL-tree root node pointer.
     
    222225    return pNode;
    223226}
     227
     228
     229
     230/**
     231 * Gets a node from the tree and its parent node (if any) (does not remove any nodes!)
     232 * @returns   Pointer to the node holding the given key.
     233 * @param     ppTree    Pointer to the AVL-tree root node pointer.
     234 * @param     ppParent  Pointer to a variable which will hold the pointer to the partent node on
     235 *                      return. When no node is found, this will hold the last searched node.
     236 * @param     Key       Key value of the node which is to be found.
     237 * @sketch
     238 * @status    completely implemented.
     239 * @author    knut st. osmundsen
     240 */
     241PAVLNODECORE    AVLGetWithParent(PPAVLNODECORE ppTree, PPAVLNODECORE ppParent, AVLKEY Key)
     242{
     243    register PAVLNODECORE  pNode = *ppTree;
     244    register PAVLNODECORE  pParent = NULL;
     245
     246    while (pNode != NULL && pNode->Key != Key)
     247    {
     248        pParent = pNode;
     249        if (pNode->Key > Key)
     250            pNode = pNode->pLeft;
     251        else
     252            pNode = pNode->pRight;
     253    }
     254
     255    *ppParent = pParent;
     256    return pNode;
     257}
     258
    224259
    225260
     
    292327
    293328    return pNode;
     329}
     330
     331
     332/**
     333 * Iterates tru all nodes in the given tree.
     334 * @returns   0 on success. Return from callback on failiure.
     335 * @param     ppTree   Pointer to the AVL-tree root node pointer.
     336 * @param     fFromLeft    TRUE:  Left to right.
     337 *                         FALSE: Right to left.
     338 * @param     pfnCallBack  Pointer to callback function.
     339 * @param     pvParam      Userparameter passed on to the callback function.
     340 * @status    completely implemented.
     341 * @author    knut st. osmundsen
     342 */
     343unsigned AVLDoWithAll(PPAVLNODECORE ppTree, int fFromLeft, PAVLCALLBACK pfnCallBack, void *pvParam)
     344{
     345    AVLSTACK2       AVLStack;
     346    PAVLNODECORE    pNode;
     347    unsigned        rc;
     348
     349    if (*ppTree == NULL)
     350        return 0;
     351
     352    AVLStack.cEntries = 1;
     353    AVLStack.achFlags[0] = 0;
     354    AVLStack.aEntries[0] = *ppTree;
     355
     356    if (fFromLeft)
     357    {   /* from left */
     358        while (AVLStack.cEntries > 0)
     359        {
     360            pNode = AVLStack.aEntries[AVLStack.cEntries - 1];
     361
     362            /* left */
     363            if (!AVLStack.achFlags[AVLStack.cEntries - 1]++)
     364            {
     365                if (pNode->pLeft != NULL)
     366                {
     367                    AVLStack.achFlags[AVLStack.cEntries] = 0; /* 0 first, 1 last */
     368                    AVLStack.aEntries[AVLStack.cEntries++] = pNode->pLeft;
     369                    continue;
     370                }
     371            }
     372
     373            /* center */
     374            rc = pfnCallBack(pNode, pvParam);
     375            if (rc != 0)
     376                return rc;
     377
     378            /* right */
     379            AVLStack.cEntries--;
     380            if (pNode->pRight != NULL)
     381            {
     382                AVLStack.achFlags[AVLStack.cEntries] = 0;
     383                AVLStack.aEntries[AVLStack.cEntries++] = pNode->pRight;
     384            }
     385        } /* while */
     386    }
     387    else
     388    {   /* from right */
     389        while (AVLStack.cEntries > 0)
     390        {
     391            pNode = AVLStack.aEntries[AVLStack.cEntries - 1];
     392
     393
     394            /* right */
     395            if (!AVLStack.achFlags[AVLStack.cEntries - 1]++)
     396            {
     397                if (pNode->pRight != NULL)
     398                {
     399                    AVLStack.achFlags[AVLStack.cEntries] = 0;  /* 0 first, 1 last */
     400                    AVLStack.aEntries[AVLStack.cEntries++] = pNode->pRight;
     401                    continue;
     402                }
     403            }
     404
     405            /* center */
     406            rc = pfnCallBack(pNode, pvParam);
     407            if (rc != 0)
     408                return rc;
     409
     410            /* left */
     411            AVLStack.cEntries--;
     412            if (pNode->pLeft != NULL)
     413            {
     414                AVLStack.achFlags[AVLStack.cEntries] = 0;
     415                AVLStack.aEntries[AVLStack.cEntries++] = pNode->pLeft;
     416            }
     417        } /* while */
     418    }
     419
     420    return 0;
     421}
     422
     423
     424/**
     425 * Starts an enumeration of all nodes in the given AVL tree.
     426 * @returns   Pointer to the first node in the tree.
     427 * @param     ppTree     Pointer to the AVL-tree root node pointer.
     428 * @param     pEnumData  Pointer to enumeration control data.
     429 * @param     fFromLeft  TRUE:  Left to right.
     430 *                       FALSE: Right to left.
     431 * @status    completely implemented.
     432 * @author    knut st. osmundsen
     433 */
     434PAVLNODECORE AVLBeginEnumTree(PPAVLNODECORE ppTree, PAVLENUMDATA pEnumData, int fFromLeft)
     435{
     436    if (*ppTree != NULL)
     437    {
     438        pEnumData->fFromLeft = fFromLeft;
     439        pEnumData->cEntries = 1;
     440        pEnumData->aEntries[0] = *ppTree;
     441        pEnumData->achFlags[0] = 0;
     442    }
     443    else
     444        pEnumData->cEntries = 0;
     445
     446    return AVLGetNextNode(pEnumData);
     447}
     448
     449
     450/**
     451 * Get the next node in the tree enumeration.
     452 * @returns   Pointer to the first node in the tree.
     453 * @param     pEnumData  Pointer to enumeration control data.
     454 * @status    completely implemented.
     455 * @author    knut st. osmundsen
     456 */
     457PAVLNODECORE AVLGetNextNode(PAVLENUMDATA pEnumData)
     458{
     459    PAVLNODECORE    pNode;
     460
     461    if (pEnumData->fFromLeft)
     462    {   /* from left */
     463        while (pEnumData->cEntries > 0)
     464        {
     465            pNode = pEnumData->aEntries[pEnumData->cEntries - 1];
     466
     467            /* left */
     468            if (pEnumData->achFlags[pEnumData->cEntries - 1] == 0)
     469            {
     470                pEnumData->achFlags[pEnumData->cEntries - 1]++;
     471                if (pNode->pLeft != NULL)
     472                {
     473                    pEnumData->achFlags[pEnumData->cEntries] = 0; /* 0 left, 1 center, 2 right */
     474                    pEnumData->aEntries[pEnumData->cEntries++] = pNode->pLeft;
     475                    continue;
     476                }
     477            }
     478
     479            /* center */
     480            if (pEnumData->achFlags[pEnumData->cEntries - 1] == 1)
     481            {
     482                pEnumData->achFlags[pEnumData->cEntries - 1]++;
     483                return pNode;
     484            }
     485
     486            /* right */
     487            pEnumData->cEntries--;
     488            if (pNode->pRight != NULL)
     489            {
     490                pEnumData->achFlags[pEnumData->cEntries] = 0;
     491                pEnumData->aEntries[pEnumData->cEntries++] = pNode->pRight;
     492            }
     493        } /* while */
     494    }
     495    else
     496    {   /* from right */
     497        while (pEnumData->cEntries > 0)
     498        {
     499            pNode = pEnumData->aEntries[pEnumData->cEntries - 1];
     500
     501
     502            /* right */
     503            if (pEnumData->achFlags[pEnumData->cEntries - 1] == 0)
     504            {
     505                pEnumData->achFlags[pEnumData->cEntries - 1]++;
     506                if (pNode->pRight != NULL)
     507                {
     508                    pEnumData->achFlags[pEnumData->cEntries] = 0;  /* 0 right, 1 center, 2 left */
     509                    pEnumData->aEntries[pEnumData->cEntries++] = pNode->pRight;
     510                    continue;
     511                }
     512            }
     513
     514            /* center */
     515            if (pEnumData->achFlags[pEnumData->cEntries - 1] == 1)
     516            {
     517                pEnumData->achFlags[pEnumData->cEntries - 1]++;
     518                return pNode;
     519            }
     520
     521            /* left */
     522            pEnumData->cEntries--;
     523            if (pNode->pLeft != NULL)
     524            {
     525                pEnumData->achFlags[pEnumData->cEntries] = 0;
     526                pEnumData->aEntries[pEnumData->cEntries++] = pNode->pLeft;
     527            }
     528        } /* while */
     529    }
     530
     531    return NULL;
     532
     533}
     534
     535
     536
     537
     538/**
     539 * Finds the best fitting node in the tree for the given Key value.
     540 * @returns   Pointer to the best fitting node found.
     541 * @param     ppTree  Pointer to Pointer to the tree root node.
     542 * @param     Key     The Key of which is to be found a best fitting match for..
     543 * @param     fAbove  TRUE:  Returned node is have the closest key to Key from above.
     544 *                    FALSE: Returned node is have the closest key to Key from below.
     545 * @status    completely implemented.
     546 * @sketch    The best fitting node is always located in the searchpath above you.
     547 *            >= (above): The node where you last turned left.
     548 *            <= (below): the node where you last turned right.
     549 * @author    knut st. osmundsen
     550 */
     551PAVLNODECORE    AVLGetBestFit(PPAVLNODECORE ppTree, AVLKEY Key, int fAbove)
     552{
     553    register PAVLNODECORE   pNode = *ppTree;
     554    PAVLNODECORE            pNodeLast = NULL;
     555
     556    if (fAbove)
     557    {   /* pNode->Key >= Key */
     558        while (pNode != NULL && pNode->Key != Key)
     559        {
     560            if (pNode->Key > Key)
     561            {
     562                pNodeLast = pNode;
     563                pNode = pNode->pLeft;
     564            }
     565            else
     566                pNode = pNode->pRight;
     567        }
     568    }
     569    else
     570    {   /* pNode->Key <= Key */
     571        while (pNode != NULL && pNode->Key != Key)
     572        {
     573            if (pNode->Key < Key)
     574            {
     575                pNodeLast = pNode;
     576                pNode = pNode->pRight;
     577            }
     578            else
     579                pNode = pNode->pLeft;
     580        }
     581    }
     582
     583    return pNode == NULL ? pNodeLast /* best fit */ : pNode /* perfect match */;
    294584}
    295585
     
    354644        PAVLNODECORE    pNode = *ppNode;
    355645        PAVLNODECORE    pLeftNode = pNode->pLeft;
    356         unsigned        uLeftHeight = AVL_HEIGHTOF(pLeftNode);
     646        unsigned char   uchLeftHeight = AVL_HEIGHTOF(pLeftNode);
    357647        PAVLNODECORE    pRightNode = pNode->pRight;
    358         unsigned        uRightHeight = AVL_HEIGHTOF(pRightNode);
    359 
    360         if (uRightHeight + 1 < uLeftHeight)
     648        unsigned char   uchRightHeight = AVL_HEIGHTOF(pRightNode);
     649
     650        if (uchRightHeight + 1 < uchLeftHeight)
    361651        {
    362652            PAVLNODECORE    pLeftLeftNode = pLeftNode->pLeft;
    363653            PAVLNODECORE    pLeftRightNode = pLeftNode->pRight;
    364             unsigned        uLeftRightHeight = AVL_HEIGHTOF(pLeftRightNode);
    365 
    366             if (AVL_HEIGHTOF(pLeftLeftNode) >= uLeftRightHeight)
     654            unsigned char   uchLeftRightHeight = AVL_HEIGHTOF(pLeftRightNode);
     655
     656            if (AVL_HEIGHTOF(pLeftLeftNode) >= uchLeftRightHeight)
    367657            {
    368658                pNode->pLeft = pLeftRightNode;
    369659                pLeftNode->pRight = pNode;
    370                 pLeftNode->uchHeight = 1 + (pNode->uchHeight = 1 + uLeftRightHeight);
     660                pLeftNode->uchHeight = (unsigned char)(1 + (pNode->uchHeight = (unsigned char)(1 + uchLeftRightHeight)));
    371661                *ppNode = pLeftNode;
    372662            }
     
    377667                pLeftRightNode->pLeft = pLeftNode;
    378668                pLeftRightNode->pRight = pNode;
    379                 pLeftNode->uchHeight = pNode->uchHeight = uLeftRightHeight;
    380                 pLeftRightNode->uchHeight = uLeftHeight;
     669                pLeftNode->uchHeight = pNode->uchHeight = uchLeftRightHeight;
     670                pLeftRightNode->uchHeight = uchLeftHeight;
    381671                *ppNode = pLeftRightNode;
    382672            }
    383673        }
    384         else if (uLeftHeight + 1 < uRightHeight)
     674        else if (uchLeftHeight + 1 < uchRightHeight)
    385675        {
    386676            PAVLNODECORE    pRightLeftNode = pRightNode->pLeft;
    387             unsigned        uRightLeftHeight = AVL_HEIGHTOF(pRightLeftNode);
     677            unsigned char   uchRightLeftHeight = AVL_HEIGHTOF(pRightLeftNode);
    388678            PAVLNODECORE    pRightRightNode = pRightNode->pRight;
    389679
    390             if (AVL_HEIGHTOF(pRightRightNode) >= uRightLeftHeight)
     680            if (AVL_HEIGHTOF(pRightRightNode) >= uchRightLeftHeight)
    391681            {
    392682                pNode->pRight = pRightLeftNode;
    393683                pRightNode->pLeft = pNode;
    394                 pRightNode->uchHeight = 1 + (pNode->uchHeight = 1 + uRightLeftHeight);
     684                pRightNode->uchHeight = (unsigned char)(1 + (pNode->uchHeight = (unsigned char)(1 + uchRightLeftHeight)));
    395685                *ppNode = pRightNode;
    396686            }
     
    401691                pRightLeftNode->pRight = pRightNode;
    402692                pRightLeftNode->pLeft = pNode;
    403                 pRightNode->uchHeight = pNode->uchHeight = uRightLeftHeight;
    404                 pRightLeftNode->uchHeight = uRightHeight;
     693                pRightNode->uchHeight = pNode->uchHeight = uchRightLeftHeight;
     694                pRightLeftNode->uchHeight = uchRightHeight;
    405695                *ppNode = pRightLeftNode;
    406696            }
     
    408698        else
    409699        {
    410             register unsigned uHeight = max(uLeftHeight, uRightHeight) + 1;
    411             if (uHeight == pNode->uchHeight)
     700            register unsigned char uchHeight = (unsigned char)(max(uchLeftHeight, uchRightHeight) + 1);
     701            if (uchHeight == pNode->uchHeight)
    412702                break;
    413             pNode->uchHeight = uHeight;
     703            pNode->uchHeight = uchHeight;
    414704        }
    415705    }
  • trunk/src/win32k/misc/vprintf.c

    r1683 r2501  
    1 /* $Id: vprintf.c,v 1.6 1999-11-10 09:11:28 bird Exp $
     1/* $Id: vprintf.c,v 1.7 2000-01-22 18:21:03 bird Exp $
    22 *
    33 * vprintf and printf
     
    488488        {
    489489            #ifdef RING0
     490                #pragma info(noeff)
    490491                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
    491492                _outp(options.usCom, chReturn);             /* Put the char. */
     493                #pragma info(restore)
    492494            #else
    493495                DosWrite(1, (void*)&chReturn, 1, &ulWrote);
     
    495497        }
    496498        #ifdef RING0
     499            #pragma info(noeff)
    497500            while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
    498501            _outp(options.usCom, ch);                   /* Put the char. */
     502            #pragma info(restore)
    499503            Yield();
    500504        #else
     
    528532            for (ul = 0; ul < cch; ul++)
    529533            {
     534                #pragma info(noeff)
    530535                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
    531536                _outp(options.usCom, psz[ul]);              /* Put the char. */
     537                #pragma info(restore)
    532538            }
    533539        #else
     
    541547            {
    542548            #ifdef RING0
     549                #pragma info(noeff)
    543550                while (!(_inp(options.usCom + 5) & 0x20));  /* Waits for the port to be ready. */
    544551                _outp(options.usCom, chReturn);             /* Put the char. */
     
    546553                _outp(options.usCom, chNewLine);            /* Put the char. */
    547554                cchYield ++;
     555                #pragma info(restore)
    548556            #else
    549557                DosWrite(1, (void*)&chReturn, 1, &ul);
  • trunk/src/win32k/pe2lx/pe2lx.cpp

    r2005 r2501  
    1 /* $Id: pe2lx.cpp,v 1.14 1999-12-07 08:28:42 bird Exp $
     1/* $Id: pe2lx.cpp,v 1.15 2000-01-22 18:21:03 bird Exp $
    22 *
    33 * Pe2Lx class implementation. Ring 0 and Ring 3
     
    3737#define CB2PAGES_SHIFT              12      /* count of bytes to count of pages. shift right value. Note. ALIGN!*/
    3838
    39 
    40 /*
    41  * useful macros.
    42  */
    43 #define NOREF(a) (a=a)                      /* Not referenced parameter warning fix. */
    44 #define ALIGN(a, alignment) (((a) + (alignment - 1UL)) & ~(alignment - 1UL))
    45                                             /* aligns something, a,  up to nearest alignment boundrary-
    46                                              * Note: Aligment must be a 2**n number. */
    4739
    4840/*
     
    8577 *  ReadAt:  Reads from a file, hFile, at a given offset, ulOffset, into a buffer, pvBuffer,
    8678 *           an amount of bytes, cbToRead.
    87  *           RING0: Map this to _ldrRead with 0UL as flFlags.
     79 *           RING0: Map this to ldrRead with 0UL as flFlags.
    8880 *           RING3: Implementes this function as a static function, ReadAt.
    8981 *  ReadAtF: Same as ReadAt but two extra parameters; an additional flag and a pointer to an MTE.
    9082 *           Used in the read method.
    91  *           RING0: Map directly to _ldrRead.
     83 *           RING0: Map directly to ldrRead.
    9284 *           RING3: Map to ReadAt, ignoring the two extra parameters.
    9385 */
    9486#ifdef RING0
    9587    #define ReadAt(hFile, ulOffset, pvBuffer, cbToRead) \
    96         _ldrRead(hFile, ulOffset, pvBuffer, 0UL, cbToRead, NULL)
     88        ldrRead(hFile, ulOffset, pvBuffer, 0UL, cbToRead, NULL)
    9789    #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \
    98         _ldrRead(hFile, ulOffset, pvBuffer, flFlags, cbToRead, pMTE)
     90        ldrRead(hFile, ulOffset, pvBuffer, flFlags, cbToRead, pMTE)
    9991#else
    10092    #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \
     
    123115#include "OS2Krnl.h"                        /* kernel structs.  (SFN) */
    124116#ifdef RING0
    125     #include "ldrCalls.h"                   /* _ldr* calls. (_ldrRead) */
     117    #include "ldrCalls.h"                   /* ldr* calls. (ldrRead) */
    126118#endif
    127119#include "modulebase.h"                     /* ModuleBase class definitions, ++. */
     
    723715 * @param     pvBuffer   Pointer to buffer where data is to be put.
    724716 * @param     cbToRead   Bytes to be read.
    725  * @param     flFlag     Flags which was spesified to the _ldrRead call.
    726  * @parma     pMTE       Pointer to MTE which was specified to the _ldrRead call.
     717 * @param     flFlag     Flags which was spesified to the ldrRead call.
     718 * @parma     pMTE       Pointer to MTE which was specified to the ldrRead call.
    727719 * @return    NO_ERROR if successful something else if not.
    728720 * @status    completely implmented; tested.
     
    10181010
    10191011
     1012/**
     1013 * Applies relocation fixups to a page which is being loaded.
     1014 * @returns    NO_ERROR on success?
     1015 *             error code on error?
     1016 * @param      pMTE           Pointer Module Table Entry.
     1017 * @param      iObject        Index into the object table. (0-based)
     1018 * @param      iPageTable     Index into the page table. (0-based)
     1019 * @param      pvPage         Pointer to the page which is being loaded.
     1020 * @param      ulPageAddress  Address of page.
     1021 * @param      pvPTDA         Pointer to Per Task Data Aera
     1022 *
     1023 * @sketch     Find RVA.
     1024 */
     1025ULONG  Pe2Lx::applyFixups(PMTE pMTE, ULONG iObject, ULONG iPageTable, PVOID pvPage,
     1026                          ULONG ulPageAddress, PVOID pvPTDA)
     1027{
     1028    ULONG ulRVA;
     1029
     1030    NOREF(ulRVA);
     1031
     1032    NOREF(pMTE);
     1033    NOREF(iObject);
     1034    NOREF(iPageTable);
     1035    NOREF(pvPage);
     1036    NOREF(ulPageAddress);
     1037    NOREF(pvPTDA);
     1038
     1039    return NO_ERROR;
     1040}
     1041
     1042
     1043
    10201044#ifndef RING0
    10211045/**
Note: See TracChangeset for help on using the changeset viewer.