Changeset 2898 for trunk/src


Ignore:
Timestamp:
Feb 25, 2000, 7:19:24 PM (26 years ago)
Author:
bird
Message:

Symbol Database is implemented.
No scanning of the os2krnl file, the loaded image is now scaned to determin
which build, debug/retail and smp/uni.
And yet some more enhanchments like 16-bit logging.

Location:
trunk/src/win32k
Files:
4 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/Makefile

    r2868 r2898  
    11################################################################################
    2 # $Id: Makefile,v 1.27 2000-02-23 09:02:19 bird Exp $
     2# $Id: Makefile,v 1.28 2000-02-25 18:15:01 bird Exp $
    33#
    44# Copyright 1998-1999 knut st. osmundsen
     
    3434LFLAGS      = /nologo /MAP /NOI /NOE /NOD /A:16 /MAP /O:$@
    3535CDEFINES    = -DWIN32K -DRING0 -D__WIN32OS2__ -D__WINE__
    36 CDEFINES16  =
     36CDEFINES16  = -DRING0
    3737ADEFINES    = -D:WIN32K
    3838
     
    5656CFLAGS16    = $(CFLAGS16)   -Zi -Od
    5757CPPFLAGS    = $(CPPFLAGS)   -O- -Ti+
    58 LFLAGS      = $(LFLAGS)     /NOEXEPACK /DEBUG /NODEBUG
     58LFLAGS      = $(LFLAGS)     /NOEXEPACK /DEBUG  /NODEB
    5959ASFLAGS     = $(ASFLAGS)    -Od+
    6060CDEFINES    = $(CDEFINES)   -DDEBUG
     
    6464
    6565!ifdef NODEBUGINFO
    66 LFLAGS      = $(LFLAGS)     /NODEB
     66LFLAGS      = $(LFLAGS)     /NODEB /EXEPACK:2 /PACKD /PACKC
     67CFLAGS16    = $(CFLAGS16)   -Owis
     68CFLAGS      = $(CFLAGS)     -O+ -Oi-
     69CPPFLAGS    = $(CPPFLAGS)   -O+ -Oi-
    6770!endif
    6871
     
    9598.SUFFIXES: .obj .cpp .c .asm
    9699
    97 {dev16}.c{object}.obj:
     100{dev16}.c{$(WIN32KOBJ)}.obj:
    98101    @$(ECHO) compiling 16bit: $<
    99102    @$(CC16) $(CFLAGS16) $(CDEFINES16) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES16) $<
    100103
    101 {dev32}.asm{object}.obj:
     104{dev32}.asm{$(WIN32KOBJ)}.obj:
    102105    @$(ECHO) assembling:      $<
    103106    @$(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
    104 {dev32}.c{object}.obj:
    105     @$(ECHO) compiling 32bit: $<
    106     @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    107 {dev32}.cpp{object}.obj:
    108     @$(ECHO) compiling 32bit: $<
    109     @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    110 
    111 {k32}.asm{object}.obj:
     107{dev32}.c{$(WIN32KOBJ)}.obj:
     108    @$(ECHO) compiling 32bit: $<
     109    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     110{dev32}.cpp{$(WIN32KOBJ)}.obj:
     111    @$(ECHO) compiling 32bit: $<
     112    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     113
     114{k32}.asm{$(WIN32KOBJ)}.obj:
    112115    @$(ECHO) assembling:      $<
    113116    @$(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
    114 {k32}.c{object}.obj:
    115     @$(ECHO) compiling 32bit: $<
    116     @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    117 {k32}.cpp{object}.obj:
    118     @$(ECHO) compiling 32bit: $<
    119     @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    120 
    121 {ldr}.asm{object}.obj:
     117{k32}.c{$(WIN32KOBJ)}.obj:
     118    @$(ECHO) compiling 32bit: $<
     119    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     120{k32}.cpp{$(WIN32KOBJ)}.obj:
     121    @$(ECHO) compiling 32bit: $<
     122    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     123
     124{ldr}.asm{$(WIN32KOBJ)}.obj:
    122125    @$(ECHO) assembling:      $<
    123126    @$(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
    124 {ldr}.c{object}.obj:
    125     @$(ECHO) compiling 32bit: $<
    126     @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    127 {ldr}.cpp{object}.obj:
    128     @$(ECHO) compiling 32bit: $<
    129     @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    130 
    131 {misc}.asm{object}.obj:
     127{ldr}.c{$(WIN32KOBJ)}.obj:
     128    @$(ECHO) compiling 32bit: $<
     129    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     130{ldr}.cpp{$(WIN32KOBJ)}.obj:
     131    @$(ECHO) compiling 32bit: $<
     132    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     133
     134{misc}.asm{$(WIN32KOBJ)}.obj:
    132135    @$(ECHO) assembling:      $<
    133136    $(AS) $(ASFLAGS) $(ADEFINES) $(AINCLUDES) $< -Fo:$@ -Fl:$(WIN32KLIST)\$(*B).lst
    134 {misc}.c{object}.obj:
    135     @$(ECHO) compiling 32bit: $<
    136     @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    137 {misc}.cpp{object}.obj:
    138     @$(ECHO) compiling 32bit: $<
    139     @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    140 
    141 {pe2lx}.c{object}.obj 32bit:
     137{misc}.c{$(WIN32KOBJ)}.obj:
     138    @$(ECHO) compiling 32bit: $<
     139    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     140{misc}.cpp{$(WIN32KOBJ)}.obj:
     141    @$(ECHO) compiling 32bit: $<
     142    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     143
     144{pe2lx}.c{$(WIN32KOBJ)}.obj 32bit:
    142145    @$(ECHO) compiling: $<
    143146    @$(CC) -c $(CFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
    144 {pe2lx}.cpp{object}.obj:
     147{pe2lx}.cpp{$(WIN32KOBJ)}.obj:
    145148    @$(ECHO) compiling 32bit: $<
    146149    @$(CC) -c $(CPPFLAGS) $(CDEFINES) -Fa$(WIN32KLIST)\$(*B).s -Fo$@ $(CINCLUDES) $<
     
    159162# OBJECTS and LIBRARIES - Don't mess with the order or objects and libraries!
    160163################################################################################
    161 OBJS  = object\devfirst.obj \
    162         object\d16strat.obj \
    163         object\d32hlp.obj \
    164         object\d32globals.obj \
    165         object\asmutils.obj \
    166         object\calltab.obj \
    167         object\malloc.obj \
    168         object\smalloc_avl.obj \
    169         object\avl.obj \
    170         object\rmalloc_avl.obj \
    171         object\new.obj \
    172         object\stricmp.obj \
    173         object\yield.obj \
    174         object\vsprintf.obj \
    175         object\vprintf.obj \
    176         object\ldr.obj \
    177         object\myldrClose.obj \
    178         object\myldrOpen.obj \
    179         object\myldrRead.obj \
    180         object\myLDRQAppType.obj \
    181         object\myldrEnum32bitRelRecs.obj \
    182         object\pe2lx.obj \
    183         object\ModuleBase.obj \
    184         object\d32ElfIOCtl.obj \
    185         object\d32Win32kIOCtl.obj \
    186         object\k32AllocMemEx.obj \
    187         object\buffer.obj \
    188         object\mytkExecPgm.obj
     164OBJS  = $(WIN32KOBJ)\devfirst.obj \
     165        $(WIN32KOBJ)\d16strat.obj \
     166        $(WIN32KOBJ)\d32hlp.obj \
     167        $(WIN32KOBJ)\d32globals.obj \
     168        $(WIN32KOBJ)\d16globl.obj \
     169        $(WIN32KOBJ)\asmutils.obj \
     170        $(WIN32KOBJ)\calltab.obj \
     171        $(WIN32KOBJ)\malloc.obj \
     172        $(WIN32KOBJ)\smalloc_avl.obj \
     173        $(WIN32KOBJ)\avl.obj \
     174        $(WIN32KOBJ)\rmalloc_avl.obj \
     175        $(WIN32KOBJ)\new.obj \
     176        $(WIN32KOBJ)\stricmp.obj \
     177        $(WIN32KOBJ)\yield.obj \
     178        $(WIN32KOBJ)\vsprintf.obj \
     179        $(WIN32KOBJ)\vprintf.obj \
     180        $(WIN32KOBJ)\ldr.obj \
     181        $(WIN32KOBJ)\myldrClose.obj \
     182        $(WIN32KOBJ)\myldrOpen.obj \
     183        $(WIN32KOBJ)\myldrRead.obj \
     184        $(WIN32KOBJ)\myLDRQAppType.obj \
     185        $(WIN32KOBJ)\myldrEnum32bitRelRecs.obj \
     186        $(WIN32KOBJ)\pe2lx.obj \
     187        $(WIN32KOBJ)\ModuleBase.obj \
     188        $(WIN32KOBJ)\d32ElfIOCtl.obj \
     189        $(WIN32KOBJ)\d32Win32kIOCtl.obj \
     190        $(WIN32KOBJ)\k32AllocMemEx.obj \
     191        $(WIN32KOBJ)\buffer.obj \
     192        $(WIN32KOBJ)\mytkExecPgm.obj
    189193
    190194
    191195OBJSINIT = \
    192         object\d16init.obj \
    193         object\d32init.obj \
    194         object\probkrnl.obj
     196        $(WIN32KOBJ)\d16init.obj \
     197        $(WIN32KOBJ)\d32init.obj \
     198        $(WIN32KOBJ)\ProbKrnl.obj \
     199        $(WIN32KOBJ)\SymDB.obj \
     200        $(WIN32KOBJ)\vprntf16.obj
    195201
    196202LIBS = \
     
    210216# SPECIAL RULES - Testing
    211217################################################################################
    212 ProbKrnl.exe: dev16\ProbKrnl.c $(WIN32KBASE)\include\sym.h \
     218ProbKrnl.exe: dev16\ProbKrnl.c dev16\symdb.c dev16\vprntf16.c \
     219              $(WIN32KBASE)\include\sym.h \
    213220              $(WIN32KBASE)\include\probKrnl.h
     221    $(CC16) -c -W4 -Asfw -G2s -Zp -Zl -nologo -Fa -Zi -Od -Lp \
     222        -DDEBUG -DDEBUGR3 -Fa$(WIN32KLIST)\$(*B).s     \
     223        -Fo$(WIN32KOBJ)\probkrnl_p.obj $(CINCLUDES16) dev16\probkrnl.c
     224    $(CC16) -c -W4 -Asfw -G2s -Zp -Zl -nologo -Fa -Zi -Od -Lp \
     225        -DDEBUG -DDEBUGR3 -Fa$(WIN32KLIST)\$(*B).s     \
     226        -Fo$(WIN32KOBJ)\symdb_p.obj $(CINCLUDES16) dev16\symdb.c
     227    $(CC16) -c -W4 -Asfw -G2s -Zp -Zl -nologo -Fa -Zi -Od -Lp \
     228        -DDEBUG -DDEBUGR3 -Fa$(WIN32KLIST)\$(*B).s     \
     229        -Fo$(WIN32KOBJ)\vprntf16_p.obj $(CINCLUDES16) dev16\vprntf16.c
     230    link /NOD /MAP:FULL /CO /pmtype:vio \
     231        $(WIN32KOBJ)\probkrnl_p.obj + $(WIN32KOBJ)\symdb_p.obj + $(WIN32KOBJ)\vprntf16_p.obj, \
     232        probkrnl.exe, probkrnl.map, $(TOOLKIT)\lib\os2286.lib + $(MSCPATH)\lib\clibcep.lib;
     233
     234extract.exe: dev16\ProbKrnl.c dev16\vprntf16.c \
     235             $(WIN32KBASE)\include\sym.h \
     236             $(WIN32KBASE)\include\probKrnl.h
    214237    $(CC16) -c -W4 -Asfw -G2s -Zp -Zl -nologo -Fo$@ -Fa -Zi -Od -Lp \
    215         $(CDEFINES16) -DDEBUGR3 -Fa$(WIN32KLIST)\$(*B).s     \
    216         -Foprobkrnl.obj $(CINCLUDES16) dev16\probkrnl.c
    217     link /NOD /MAP:FULL /CO /pmtype:vio probkrnl.obj, probkrnl.exe, probkrnl.map, $(TOOLKIT)\lib\os2286.lib + $(MSCPATH)\lib\clibcep.lib;
     238        -DDEBUG -DEXTRACT -Fa$(WIN32KLIST)\$(*B).s     \
     239        -Fo$(WIN32KOBJ)\probkrnl_e.obj $(CINCLUDES16) dev16\probkrnl.c
     240    $(CC16) -c -W4 -Asfw -G2s -Zp -Zl -nologo -Fo$@ -Fa -Zi -Od -Lp \
     241        -DDEBUG -DEXTRACT -Fa$(WIN32KLIST)\$(*B).s     \
     242        -Fo$(WIN32KOBJ)\vprntf16_e.obj $(CINCLUDES16) dev16\vprntf16.c
     243    link /NOD /MAP:FULL /CO /pmtype:vio \
     244        $(WIN32KOBJ)\probkrnl_e.obj + $(WIN32KOBJ)\vprntf16_e.obj, \
     245        $@, $(*B).map, $(TOOLKIT)\lib\os2286.lib + $(MSCPATH)\lib\clibcep.lib;
     246
     247d32init.exe: dev32\d32init.c
     248    icc -Ss /Gr+ $(CINCLUDES) -DRING3 -DDEBUGR3 -DDEBUG \
     249        -Fo$(WIN32KOBJ)\$(*B).r3obj -Fe$@ dev32\$(*B).c
    218250
    219251
     
    222254# Win32k.sys rule. Don't mess with the order or objects and libraries!
    223255################################################################################
    224 $(NAME).sys: $(OBJS) $(LIBS) last.lib $(OBJSINIT) $(LIBSINIT) $(NAME).def
     256$(NAME).sys: $(OBJS) $(LIBS) last.lib init.lib $(LIBSINIT) $(NAME).def
    225257    -@$(ECHO) linking: $@
    226258    $(LD) $(LFLAGS) @<<
    227 $(OBJS) $(LIBS) last.lib $(OBJSINIT) /IG $(LIBSINIT) $(NAME).def
     259$(OBJS) $(LIBS) last.lib init.lib /IG $(LIBSINIT) $(NAME).def
    228260<<
    229261    @mapsym $*.map > nul
     
    247279    $(ILIB) /nologo /nobackup /convformat $@;
    248280
    249 last.lib: object\devlast.obj
    250     -@del $@ > nul 2> nul
     281last.lib: $(WIN32KOBJ)\devlast.obj
     282    -@$(RM) $@ > nul 2> nul
    251283    $(ILIB) /nologo /nobackup $@ $**;
    252284
     285init.lib: $(OBJSINIT)
     286    -@$(RM) $@ > nul 2> nul
     287    $(ILIB) /nologo /nobackup $@ $**;
     288
    253289libconv.exe: libconv.c
    254     icc -Q+ libconv.c
     290    icc -Q+ -Fe$@ -Fo$(WIN32KOBJ)\$(*B).obj libconv.c
    255291
    256292
     
    291327################################################################################
    292328dep:
    293     $(PDWIN32_TOOLS)\fastdep -oObject $(CINCLUDES) misc\*.c* ldr\*.c* dev32\*.c* \
     329    $(PDWIN32_TOOLS)\fastdep -o$(WIN32KOBJ) $(CINCLUDES) misc\*.c* ldr\*.c* dev32\*.c* \
    294330        dev16\*.c* pe2lx\*.c* k32\*.c* lib\*.c include\*.h
    295     $(PDWIN32_TOOLS)\fastdep -a+ -oObject $(CINCLUDES16) dev16\*.c*
    296 
    297 
    298 object\asmutils.obj:            misc\asmutils.asm     include\devsegdf.inc
    299 object\buffer.obj:              misc\buffer.asm       include\devsegdf.inc
    300 object\calltab.obj:             ldr\calltab.asm       include\devsegdf.inc
    301 object\mytkExecPgm.obj:         ldr\mytkExecPgm.asm   include\devsegdf.inc
    302 object\d32hlp.obj:              dev32\d32hlp.asm      include\devsegdf.inc
    303 object\devfirst.obj:            dev32\devfirst.asm    include\devsegdf.inc
    304 object\devlast.obj:             dev32\devlast.asm     include\devsegdf.inc
     331    $(PDWIN32_TOOLS)\fastdep -a+ -o$(WIN32KOBJ) $(CINCLUDES16) dev16\*.c*
     332
     333
     334$(WIN32KOBJ)\asmutils.obj:      misc\asmutils.asm     include\devsegdf.inc
     335$(WIN32KOBJ)\buffer.obj:        misc\buffer.asm       include\devsegdf.inc
     336$(WIN32KOBJ)\calltab.obj:       ldr\calltab.asm       include\devsegdf.inc
     337$(WIN32KOBJ)\mytkExecPgm.obj:   ldr\mytkExecPgm.asm   include\devsegdf.inc
     338$(WIN32KOBJ)\d32hlp.obj:        dev32\d32hlp.asm      include\devsegdf.inc
     339$(WIN32KOBJ)\devfirst.obj:      dev32\devfirst.asm    include\devsegdf.inc
     340$(WIN32KOBJ)\devlast.obj:       dev32\devlast.asm     include\devsegdf.inc
    305341
    306342!ifndef NODEP
  • trunk/src/win32k/dev16/d16init.c

    r2836 r2898  
    1 /* $Id: d16init.c,v 1.5 2000-02-21 04:45:45 bird Exp $
     1/* $Id: d16init.c,v 1.6 2000-02-25 18:15:02 bird Exp $
    22 *
    33 * d16init - init routines for both drivers.
     
    2121#define INCL_DOSERRORS
    2222#define INCL_NOPMAPI
     23
    2324
    2425/*******************************************************************************
  • trunk/src/win32k/dev16/d16strat.c

    r2877 r2898  
    1 /* $Id: d16strat.c,v 1.7 2000-02-23 20:10:19 bird Exp $
     1/* $Id: d16strat.c,v 1.8 2000-02-25 18:15:02 bird Exp $
    22 *
    33 * d16strat.c - 16-bit strategy routine, device headers, device_helper (ptr)
     
    6464};
    6565
    66 /* Note: All global variables must be initialized!  *
    67  *       Uninitialized variables ends up in DATA32. */
    68 PFN     Device_Help = NULL;
    69 ULONG   TKSSBase16  = 0;
    70 USHORT  R0FlatCS16  = 0;
    71 USHORT  R0FlatDS16  = 0;
    72 BOOL    fInitTime   = TRUE;
    7366
    7467
     
    129122{
    130123    USHORT rc;
     124
    131125    if (pRp->Category == D16_IOCTL_CAT)
    132126    {
    133127        switch (pRp->Function)
    134128        {
     129            /*
     130             * This is the IOCtl which does the R0-initiation of the device driver.
     131             * Only available at init time...
     132             */
    135133            case D16_IOCTL_RING0INIT:
    136134                if (fInitTime)
     
    142140                break;
    143141
    144             case D16_IOCTL_GETKRNLOTES:
     142            /*
     143             * This is the IOCtl collects info of the running kernel.
     144             * Only available at init time.
     145             *
     146             * Since this IOCtl is issued before R0-Init is done, we'll have to
     147             * init TKSSBase for both 16-bit and 32-bit code and be a bit carefull.
     148             */
     149            case D16_IOCTL_GETKRNLINFO:
    145150                if (fInitTime)
    146151                {
     
    151156                                          &ulLin) != NO_ERROR)
    152157                        return STATUS_DONE | STERR | ERROR_I24_INVALID_PARAMETER;
    153                     return CallGetOTEs32(ulLin);
     158                    return CallGetKernelInfo32(ulLin);
    154159                }
    155160                break;
    156161
    157             case D16_IOCTL_VERIFYPROCTAB:
     162            /*
     163             * This is the IOCtl verifies the data in the ImportTab.
     164             * Only available at init time.
     165             *
     166             * Since this IOCtl is issued before R0-Init is done, we'll have to
     167             * init TKSSBase for both 16-bit and 32-bit code and be a bit carefull.
     168             */
     169            case D16_IOCTL_VERIFYIMPORTTAB:
    158170                if (fInitTime)
    159171                {
  • trunk/src/win32k/dev16/probkrnl.c

    r2848 r2898  
    1 /* $Id: probkrnl.c,v 1.15 2000-02-21 14:53:38 bird Exp $
     1/* $Id: probkrnl.c,v 1.16 2000-02-25 18:15:02 bird Exp $
    22 *
    33 * Description:   Autoprobes the os2krnl file and os2krnl[*].sym files.
     
    3030*   Defined Constants And Macros                                               *
    3131*******************************************************************************/
    32 #ifdef DEBUGR3
    33     #if 1
    34         int printf(const char *, ...);
    35         #define dprintf(a) printf a
    36     #else
    37         #define dprintf(a)
    38     #endif
    39 #else
    40     #define dprintf(a)
    41     #define static
     32/* Disable logging when doing extracts */
     33#if defined(EXTRACT) || defined(RING0)
     34    #define NOLOGGING 1
    4235#endif
    4336
     
    7265#include "dev16.h"
    7366#include "dev1632.h"
     67#include "vprntf16.h"
     68#include "log.h"
    7469
    7570
     
    111106};
    112107
    113 unsigned long int   ulBuild          = 0;
     108unsigned short int  usBuild          = 0;
    114109unsigned short      usVerMajor       = 0;
    115110unsigned short      usVerMinor       = 0;
     111unsigned char       fSMP             = FALSE;
     112unsigned char       fDebug           = FALSE;
    116113
    117114
     
    144141};
    145142
    146 static KRNLOBJTABLE KrnlOTEs = {0};
    147 
    148 /* messages */
    149 static char szBanner[]   = "Win32k - Odin32 support driver.";
    150 static char szMsg1[]     = "\n\r    Found kernel:     ";
    151 static char szMsg1a[]    = "\n\r    Build:            ";
    152 static char szMsg2[]     = "\n\r    Found symbolfile: ";
    153 static char szMsg4[]     = "\n\r    Failed to find symbolfile!\n\r";
    154 static char szMsgfailed[]= "failed!   ";
     143/* Result from GetKernelInfo/ReadOS2Krnl. */
     144static unsigned char  cObjects = 0;
     145static POTE           paKrnlOTEs = NULL;
     146
    155147
    156148
     
    172164static int      kstrnicmp(const char *psz1, const char *psz2, int cch);
    173165static int      kstrlen(const char *psz);
     166static char *   kstrcpy(char * pszTarget, const char * pszSource);
    174167static int      kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen);
    175168
    176169/* Workers */
     170static int      LookupKrnlEntry(unsigned uBuild, unsigned char chType,
     171                                unsigned char fSMP, unsigned char cObjects);
    177172static int      VerifyPrologs(void);
    178 static int      ProbeSymFile(char *pszFilename);
    179 static int      VerifyKernelVer(void);
    180 static int      ReadOS2Krnl(char *pszFilename);
    181 static int      ReadOS2Krnl2(HFILE hKrnl, unsigned long  cbKrnl);
    182 static int      GetKernelOTEs(void);
     173static int      ProbeSymFile(const char *pszFilename);
     174static int      GetKernelInfo(void);
    183175
    184176/* Ouput */
     
    186178static void     ShowHexNumber(unsigned long ul);
    187179static void     ShowResult(int rc, int iSym);
     180
     181/* Others used while debugging in R3. */
     182static int      VerifyKernelVer(void);
     183static int      ReadOS2Krnl(char *pszFilename);
     184static int      ReadOS2Krnl2(HFILE hKrnl, unsigned long  cbKrnl);
     185static int      processFile(const char *pszFilename);
    188186
    189187
     
    409407
    410408/**
     409 * String copy (strcpy).
     410 * @returns   Pointer to target string.
     411 * @param     pszTarget  Target string.
     412 * @param     pszSource  Source string.
     413 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     414 */
     415static char * kstrcpy(char * pszTarget, register const char * pszSource)
     416{
     417    register char *psz = pszTarget;
     418
     419    while (*pszSource != '\0')
     420        *psz++ = *pszSource++;
     421
     422    return pszTarget;
     423}
     424
     425
     426
     427
     428/**
    411429 * Copy an argument to a buffer. Ie. "-K[=|:]c:\os2krnl ....". Supports quotes
    412430 * @returns   Number of chars of pszArg that has been processed.
     
    465483*   Implementation Of The Important Functions                                  *
    466484*******************************************************************************/
     485#ifndef EXTRACT
     486/**
     487 * Checks if this kernel is within the kernel symbol database.
     488 * If an entry for the kernel is found, the data is copied from the
     489 * database entry to aImportTab.
     490 * @returns   NO_ERROR on succes (0)
     491 *            1 if not found.
     492 *            Error code on error.
     493 * @param     uBuild    Build level.
     494 * @param     chType    'A' all strict
     495 *                      'H' half strict
     496 *                      'R' retail
     497 * @param     fSMP      TRUE: SMP
     498 *                      FALSE: UNI
     499 * @param     cObjects  Count of object in the running kernel.
     500 * @sketch    Loop thru the table.
     501 * @status    completely implemented.
     502 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     503 */
     504static int LookupKrnlEntry(unsigned uBuild, unsigned char chType, unsigned char fSMP, unsigned char cObjects)
     505{
     506    int i;
     507
     508    /*
     509     * Loop tru the DB entries until a NULL pointer is found.
     510     */
     511    for (i = 0; aKrnlSymDB[i].usBuild != 0; i++)
     512    {
     513        if (aKrnlSymDB[i].usBuild      == uBuild
     514            && aKrnlSymDB[i].chType    == chType
     515            && aKrnlSymDB[i].fSMP      == fSMP
     516            && aKrnlSymDB[i].cObjects  == cObjects)
     517        {   /* found matching entry! */
     518            int j;
     519            int rc;
     520            register PKRNLDBENTRY pEntry = &aKrnlSymDB[i];
     521
     522            dprintf(("LookUpKrnlEntry - found entry for this kernel!\n"));
     523
     524            /*
     525             * Copy symbol data from the DB to aImportTab.
     526             */
     527            for (j = 0; j < NBR_OF_KRNLIMPORTS; j++)
     528            {
     529                aImportTab[j].offObject  = pEntry->aSyms[j].offObject;
     530                aImportTab[j].iObject    = pEntry->aSyms[j].iObject;
     531                aImportTab[j].ulAddress  = paKrnlOTEs[pEntry->aSyms[j].iObject].ote_base
     532                                           + pEntry->aSyms[j].offObject;
     533                aImportTab[j].usSel      = paKrnlOTEs[pEntry->aSyms[j].iObject].ote_sel;
     534                aImportTab[j].fFound     = TRUE;
     535                dprintf(("  %-3d addr=0x%08lx off=0x%08lx  %s\n",
     536                         j, aImportTab[j].ulAddress, aImportTab[j].offObject,
     537                         aImportTab[j].achName));
     538            }
     539
     540            /* Verify prologs*/
     541            rc = VerifyPrologs();
     542
     543            /* set sym name */
     544            if (rc == 0)
     545                kstrcpy(szUsrSym, "Win32k Symbol Database");
     546            return rc;
     547        }
     548    }
     549
     550    /* not found */
     551    return 1;
     552}
     553#endif /* !EXTRACT */
    467554
    468555/**
     
    473560static int VerifyPrologs(void)
    474561{
    475 #ifndef DEBUGR3
     562#if !defined(DEBUGR3) && !defined(EXTRACT)
    476563    APIRET          rc;
    477564    HFILE           hDev0 = 0;
     
    484571    if (rc == NO_ERROR)
    485572    {
    486         rc = DosDevIOCtl("", "", D16_IOCTL_VERIFYPROCTAB, D16_IOCTL_CAT, hDev0);
     573        rc = DosDevIOCtl("", "", D16_IOCTL_VERIFYIMPORTTAB, D16_IOCTL_CAT, hDev0);
    487574        DosClose(hDev0);
    488575    }
     
    502589 * @remark    Error codes starts at -50.
    503590 */
    504 static int ProbeSymFile(char * pszFilename)
     591static int ProbeSymFile(const char * pszFilename)
    505592{
    506593    HFILE          hSym;                /* Filehandle */
     
    565652     * Verify that the number of segments is equal to the number objects in OS2KRNL.
    566653     */
    567     if (MapDef.cSegs != KrnlOTEs.cObjects)
     654    #ifndef EXTRACT
     655    if (MapDef.cSegs != cObjects)
    568656    {   /* incorrect count of segments. */
    569657        dprintf(("Segment No. verify failed\n"));
     
    571659        return -52;
    572660    }
     661    #endif /* !EXTRACT */
    573662
    574663
     
    577666     */
    578667    for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
     668    {
    579669        aImportTab[i].fFound = 0;
     670        #ifdef DEBUG
     671        aImportTab[i].offObject = 0;
     672        aImportTab[i].ulAddress = 0;
     673        aImportTab[i].usSel = 0;
     674        #endif
     675    }
    580676
    581677
     
    697793                {   /* Symbol was found */
    698794                    aImportTab[i].offObject = (SegDef.bFlags & 0x01 ? SymDef32.wSymVal : SymDef16.wSymVal);
    699                     aImportTab[i].ulAddress = aImportTab[i].offObject + KrnlOTEs.aObjects[iSeg].ote_base;
     795                    aImportTab[i].ulAddress = aImportTab[i].offObject + paKrnlOTEs[iSeg].ote_base;
    700796                    aImportTab[i].iObject   = (unsigned char)iSeg;
    701                     aImportTab[i].usSel     = KrnlOTEs.aObjects[iSeg].ote_sel;
     797                    aImportTab[i].usSel     = paKrnlOTEs[iSeg].ote_sel;
     798                    dprintf(("debug: base=%lx, size=%lx iSeg=%d\n", paKrnlOTEs[iSeg].ote_base, paKrnlOTEs[iSeg].ote_size, iSeg));
    702799
    703800                    /* Paranoia test! */
    704                     if (aImportTab[i].offObject < KrnlOTEs.aObjects[iSeg].ote_size)
     801                    #ifndef EXTRACT
     802                    if (aImportTab[i].offObject < paKrnlOTEs[iSeg].ote_size)
    705803                    {
    706804                        aImportTab[i].fFound = TRUE;
     
    712810                    else/* test failed, continue on next symbol*/
    713811                        dprintf(("Error: Paranoia test failed for %s\n", aImportTab[i].achName));;
     812                    #else
     813                    aImportTab[i].fFound = TRUE;
     814                    cLeftToFind--;
     815                    #endif /* !EXTRACT */
    714816                    break;
    715817                }
     
    740842
    741843/**
    742  * Verifies that build no, matches kernel number.
    743  * @returns   0 on equal, !0 on error.
    744  */
    745 static int VerifyKernelVer(void)
    746 {
    747     int VerMinor, VerMajor;
    748 
    749     VerMajor = ulBuild < 20000 ? 20 : 30/*?*/;
    750     VerMinor = ulBuild < 6600 ? 10 :  ulBuild < 8000 ? 11 : ulBuild < 9000 ? 30 :
    751                ulBuild < 10000 ? 40 :  ulBuild < 15000 ? 45 : 50;
    752 
    753     return VerMajor - (int)usVerMajor | VerMinor - (int)usVerMinor;
    754 }
    755 
    756 
    757 /**
    758  * Reads and verifies OS/2 kernel.
    759  * @returns   0 on success, not 0 on failure.
    760  * @param     filename   Filename of the OS/2 kernel.
    761  * @result    ulBuild is set.
    762  * @remark    This step will be eliminated by searching thru the DOSGROUP datasegment
    763  *            in the kernel memory. This segment have a string "Internal revision 9.034[smp|uni]"
    764  *            This would be much faster than reading the kernel file. It will also give us a more precise
    765  *            answer to the question! This is currently a TODO issue. !FIXME!
    766  */
    767 static int ReadOS2Krnl(char * pszFilename)
    768 {
    769     HFILE          hKrnl;
    770     unsigned long  cbKrnl;
    771     int            rc;
    772 
    773     hKrnl = fopen(pszFilename, "rb");
    774     if (hKrnl != 0)
    775     {
    776         cbKrnl = fsize(hKrnl);
    777         if (!fseek(hKrnl, 0, SEEK_SET))
    778             rc = ReadOS2Krnl2(hKrnl, cbKrnl);
    779         else
    780             rc = -2;
    781         fclose(hKrnl);
    782     }
    783     else
    784     {
    785         dprintf(("Could not open file\n"));
    786         rc = -1;
    787     }
    788     return rc;
    789 }
    790 
    791 /**
    792  * Worker function for ReadOS2Krnl
    793  * @returns   0 on success.
    794  *            errorcodes on failure. (-1 >= rc >= -14)
    795  * @param     hKrnl   Handle to the kernel file.
    796  * @param     cbKrnl  Size of the kernel file.
    797  * @author    knut st. osmundsen
    798  */
    799 static int ReadOS2Krnl2(HFILE hKrnl, unsigned long  cbKrnl)
    800 {
    801     int            i, j;
    802     int            rc = 0;
    803     char           achBuffer[KERNEL_ID_STRING_LENGTH + KERNEL_READ_SIZE];
    804     unsigned long  offLXHdr;
    805     struct e32_exe *pLXHdr;
    806 
    807 
    808     /* find bldlevel string - "@#IBM:14.020#@  IBM OS/2 Kernel - 14.020F" */
    809     if (fseek(hKrnl, 0, SEEK_SET))
    810         return -2;
    811 
    812     if (!fread(&achBuffer[KERNEL_ID_STRING_LENGTH], 1, KERNEL_READ_SIZE, hKrnl))
    813         return -3;
    814 
    815     i = KERNEL_ID_STRING_LENGTH;
    816     while (cbKrnl > 0)
    817     {
    818         if (i == KERNEL_READ_SIZE)
    819         {
    820 
    821             kmemcpy(achBuffer, &achBuffer[KERNEL_READ_SIZE], KERNEL_ID_STRING_LENGTH);
    822             if (!fread(&achBuffer[KERNEL_ID_STRING_LENGTH], 1, cbKrnl > KERNEL_READ_SIZE ? KERNEL_READ_SIZE : (int)cbKrnl, hKrnl))
    823                 return -3;
    824 
    825             i = 0;
    826         }
    827 
    828         if (kstrncmp("@#IBM:", &achBuffer[i], 6) == 0)
    829             break;
    830 
    831         /* next */
    832         i++;
    833         cbKrnl--;
    834     }
    835 
    836     if (cbKrnl == 0)
    837     {
    838         fclose(hKrnl);
    839         return -4;
    840     }
    841 
    842     /* displacement */
    843     j = 0;
    844     while (j < 6 && achBuffer[i+10+j] != '#')
    845         j++;
    846 
    847     /* verify signature */
    848     if (kstrncmp(&achBuffer[i+10+j], "#@  IBM OS/2 Kernel", 19) != 0)
    849         return -5;
    850 
    851     /* read ulBuild */
    852     ulBuild  = (char)(achBuffer[i+6] - '0') * 1000;
    853     if (achBuffer[i+7] != '.')
    854     {
    855         /* this code is for Warp5 */
    856         ulBuild *= 10;
    857         ulBuild += (char)(achBuffer[i+7] - '0') * 1000;
    858         i++;
    859         j--;
    860         if (achBuffer[i+7] != '.')
    861         {
    862             ulBuild = ulBuild * 10;
    863             ulBuild = ulBuild + (unsigned long)(achBuffer[i+7] - '0') * 1000;
    864             i++;
    865             j--;
    866         }
    867     }
    868 
    869     if (j == 0)
    870     {
    871         ulBuild += (achBuffer[i+ 8] - '0') * 10;
    872         ulBuild += (achBuffer[i+ 9] - '0') * 1;
    873     } else
    874     {
    875         if (j == 3)
    876             return -9;
    877         ulBuild += (achBuffer[i+ 8] - '0') * 100;
    878         ulBuild += (achBuffer[i+ 9] - '0') * 10;
    879         ulBuild += (achBuffer[i+10] - '0');
    880     }
    881 
    882     if (VerifyKernelVer())
    883         return -9;
    884     dprintf(("ulBuild: %d\n",ulBuild));
    885 
    886     /* get segment number */
    887     /* read-MZheader */
    888     if (fseek(hKrnl,0,SEEK_SET))
    889         return -2;
    890 
    891     if (!fread(achBuffer, 1, 0x40, hKrnl))
    892         return -3;
    893 
    894     offLXHdr = *(unsigned long int *)&achBuffer[0x3c];
    895 
    896     if (offLXHdr > 0x2000 && offLXHdr < 0x80) /* just to detect garbage */
    897         return -6;
    898 
    899     if (fseek(hKrnl, offLXHdr, SEEK_SET))
    900         return -2;
    901 
    902     if (!fread(achBuffer, 1, sizeof(struct e32_exe), hKrnl))
    903         return -3;
    904 
    905     /* check LX-magic */
    906     if (achBuffer[0] != 'L' || achBuffer[1] != 'X')
    907         return -7;
    908 
    909 #ifndef DEBUGR3
    910     /* check object count - match it with what we got from the kernel. */
    911     pLXHdr = (struct e32_exe *)achBuffer;
    912     if ((UCHAR)pLXHdr->e32_objcnt != KrnlOTEs.cObjects)
    913         return -8;
    914 
    915     if (pLXHdr->e32_objcnt < 10)
    916         return -9;
    917 
    918     /* check objects (sizes and flags(?)) */
    919     if (!fseek(hKrnl, (LONG)offLXHdr + (LONG)pLXHdr->e32_objtab, SEEK_SET))
    920     {
    921         struct o32_obj *pObj = (struct o32_obj *)achBuffer;
    922         for (i = 0; i < (int)KrnlOTEs.cObjects; i++)
    923         {
    924             if (!fread(achBuffer, 1, sizeof(OTE), hKrnl))
    925                 return -11;
    926             if (pObj->o32_size < KrnlOTEs.aObjects[i].ote_size)
    927                 return -12;
    928 
    929             #if 0 /* don't work! */
    930             if ((pObj->o32_flags & 0xffffUL) != (KrnlOTEs.aObjects[i].ote_flags & 0xffffUL))
    931                 return -14;
    932             #endif
    933         }
    934     }
    935     else
    936         return -10;
    937 #else
    938     /* Since we can't get the OTEs from the kernel when debugging in RING-3,
    939      * we'll use what we find in the kernel.
    940      */
    941 
    942     /*  object count */
    943     pLXHdr = (struct e32_exe *)achBuffer;
    944     KrnlOTEs.cObjects = (UCHAR)pLXHdr->e32_objcnt;
    945 
    946     /* get OTEs */
    947     if (!fseek(hKrnl, (LONG)offLXHdr + (LONG)pLXHdr->e32_objtab, SEEK_SET))
    948     {
    949         struct o32_obj *pObj = (struct o32_obj *)achBuffer;
    950         for (i = 0; i < (int)KrnlOTEs.cObjects; i++)
    951             if (!fread(&KrnlOTEs.aObjects[i], 1, sizeof(struct o32_obj), hKrnl))
    952                 return -11;
    953     }
    954     else
    955         return -10;
    956 #endif
    957 
    958     return 0;
    959 }
    960 
    961 
    962 /**
    963844 * Gets the os/2 kernel OTE's (object table entries).
    964845 * @returns   0 on success. Not 0 on error.
    965846 */
    966 static int   GetKernelOTEs(void)
    967 {
    968 #ifndef DEBUGR3
     847static int   GetKernelInfo(void)
     848{
     849#if !defined(DEBUGR3) && !defined(EXTRACT) /* IOCtl not available after inittime! */
     850    static KRNLINFO KrnlInfo = {0};
    969851    APIRET          rc;
    970852    HFILE           hDev0 = 0;
     
    977859    if (rc == NO_ERROR)
    978860    {
    979         rc = DosDevIOCtl(&KrnlOTEs, "", D16_IOCTL_GETKRNLOTES, D16_IOCTL_CAT, hDev0);
     861        rc = DosDevIOCtl(&KrnlInfo, "", D16_IOCTL_GETKRNLINFO, D16_IOCTL_CAT, hDev0);
     862        if (rc == NO_ERROR)
     863        {
     864            int i;
     865
     866            /* Set the exported parameters */
     867            usBuild  = KrnlInfo.usBuild;
     868            fSMP     = KrnlInfo.fSMP;
     869            fDebug   = KrnlInfo.fDebug;
     870            cObjects = KrnlInfo.cObjects;
     871            paKrnlOTEs = &KrnlInfo.aObjects[0];
     872            #ifdef DEBUG
     873            for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
     874                dprintf(("debug: no.%2d base=%lx size=%lx sel=%x\n",
     875                         i,
     876                         paKrnlOTEs[i].ote_base,
     877                         paKrnlOTEs[i].ote_size,
     878                         paKrnlOTEs[i].ote_sel));
     879            #endif
     880
     881        }
    980882        DosClose(hDev0);
    981883    }
    982884
    983885    if (rc != NO_ERROR)
    984         puts("Failed to get kernel OTEs\r\n");
     886        printf16("Failed to get kernel OTEs\r\n");
    985887
    986888    return rc;
     889
    987890#else
    988     KrnlOTEs.cObjects = 23;
    989     return 0;
     891    #ifndef EXTRACT
     892        APIRET          rc;
     893
     894        /*--------------*/
     895        /* read kernel  */
     896        /*--------------*/
     897        if (szUsrOS2Krnl[0] != '\0')
     898        {
     899            rc = ReadOS2Krnl(szUsrOS2Krnl);
     900            if (rc != 0)
     901            {
     902                puts("Warning: Invalid kernel file specified. Tries defaults.\n\r");
     903                szUsrOS2Krnl[0] = '\0';
     904                rc = ReadOS2Krnl(szOS2Krnl);
     905            }
     906        }
     907        else
     908            rc = ReadOS2Krnl(szOS2Krnl);
     909        return rc;
     910    #else
     911        return 0;
     912    #endif
    990913#endif
    991914}
    992 
    993 
    994 /**
    995  * Displays an ULONG in decimal notation using DosPutMessage
    996  * @param     n   ULONG to show.
    997  */
    998 static void ShowDecNumber(unsigned long n)
    999 {
    1000     int f = 0;
    1001     unsigned long div;
    1002     char sif;
    1003 
    1004     for (div = 1000000; div > 0; div /= 10)
    1005     {
    1006         sif = (char)(n/div);
    1007         n %= div;
    1008         if (sif != 0 || f)
    1009         {
    1010             f = 1;
    1011             sif += '0';
    1012             DosPutMessage(0, 1, &sif);
    1013         }
    1014     }
    1015 }
    1016 
    1017 
    1018 /**
    1019  * Displays an ULONG in hexadecimal notation using DosPutMessage
    1020  * @param     n   ULONG to show.
    1021  */
    1022 static void ShowHexNumber(unsigned long int n)
    1023 {
    1024     signed int div;
    1025     char sif;
    1026     DosPutMessage(0, 2, "0x");
    1027     for (div = 28; div >= 0; div -= 4)
    1028     {
    1029         sif = (char)(n >> div) & (char)0xF;
    1030         sif += (sif < 10  ? '0' : 'a' - 10);
    1031         DosPutMessage(0, 1, &sif);
    1032     }
    1033 }
    1034 
    1035915
    1036916
     
    1040920 * @param     iSym        index of .sym-file into static struct.
    1041921 */
     922#ifndef EXTRACT
    1042923static void ShowResult(int rc, int iSym)
    1043924{
    1044     int i, j;
    1045 
    1046     /* complain even if quiet on error */
     925    int i;
     926
     927    /*
     928     * Complain even if quiet on error
     929     */
    1047930    if (!fQuiet || rc != 0)
    1048931    {
    1049         puts(szBanner);
    1050 
    1051         /* kernel stuff */
    1052         puts(szMsg1);
     932        printf16("Win32k - Odin32 support driver.\n");
     933
     934        /*
     935         * kernel stuff
     936         */
    1053937        if (rc <= -50 || rc == 0)
    1054938        {
    1055             puts(szOS2Krnl);
    1056             puts(szMsg1a);
    1057             ShowDecNumber(ulBuild);
    1058             puts(" - v");
    1059             ShowDecNumber(usVerMajor);
    1060             puts(".");
    1061             ShowDecNumber(usVerMinor);
     939            #ifdef DEBUGR3
     940            printf16("    Found kernel:     %s\n", szOS2Krnl);
     941            #endif
     942            printf16("    Build:            %d - v%d.%d\n",
     943                     usBuild, usVerMajor, usVerMinor);
    1062944        }
    1063945        else
    1064             puts(szMsgfailed);
    1065 
    1066         /* functions */
     946            printf16("    Kernel probing failed with rc=%d.\n", rc);
     947
     948        /*
     949         * symbol-file
     950         */
    1067951        if (rc == 0)
     952            printf16("    Found symbolfile: %s\n",
     953                     szUsrSym[0] == '\0' ? apszSym[iSym] : szUsrSym);
     954        else
     955            printf16("    Failed to find symbolfile! rc=%d\n", rc);
     956
     957        /*
     958         * function listing
     959         */
     960        for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
    1068961        {
    1069             puts(szMsg2);
    1070             if (szUsrSym[0] == '\0')
    1071                 puts(apszSym[iSym]);
     962            printf16("  %-20s at ",aImportTab[i].achName);
     963            if (aImportTab[i].fFound)
     964                printf16("0x%08lx%s", aImportTab[i].ulAddress, (i % 2) == 0 ? "" : "\n");
    1072965            else
    1073                 puts(szUsrSym);
    1074 
    1075             for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
    1076             {
    1077                 if ((i % 2) == 0)
    1078                     puts("\n\r    ");
    1079                 else
    1080                     puts("    ");
    1081                 puts(aImportTab[i].achName);
    1082                 for (j = aImportTab[i].cchName; j < 20; j++)
    1083                     puts(" ");
    1084 
    1085                 puts(" at ");
    1086                 if (aImportTab[i].fFound)
    1087                     ShowHexNumber(aImportTab[i].ulAddress);
    1088                 else
    1089                     puts(szMsgfailed);
    1090             }
     966                printf16("failed!%s", (i % 2) == 0 ? "" : "\n");
    1091967        }
    1092         else
    1093             puts(szMsg4);
    1094         puts("\n\r");
    1095     }
    1096 
    1097     /* if error: write rc */
    1098     if (rc != 0)
    1099     {
    1100         puts("rc = ");
    1101         ShowHexNumber((unsigned long)rc);
    1102         puts("\n\r");
    1103     }
    1104 }
    1105 
     968        if (i % 2) printf16("\n");
     969    }
     970}
    1106971
    1107972
     
    11871052
    11881053    /*-----------------*/
    1189     /* get kernel OTEs */
     1054    /* get kernel info */
    11901055    /*-----------------*/
    1191     rc = GetKernelOTEs();
     1056    rc = GetKernelInfo();
    11921057    if (rc != NO_ERROR)
    11931058        return rc;
    1194 
    1195     /*--------------*/
    1196     /* read kernel  */
    1197     /*--------------*/
    1198     if (szUsrOS2Krnl[0] != '\0')
    1199     {
    1200         rc = ReadOS2Krnl(szUsrOS2Krnl);
    1201         if (rc != 0)
    1202         {
    1203             puts("Warning: Invalid kernel file specified. Tries defaults.\n\r");
    1204             szUsrOS2Krnl[0] = '\0';
    1205             rc = ReadOS2Krnl(szOS2Krnl);
    1206         }
    1207     }
    1208     else
    1209         rc = ReadOS2Krnl(szOS2Krnl);
    12101059
    12111060    /*--------------*/
     
    12241073            }
    12251074        }
    1226         if (rc != 0) /* if user sym failed or don't exists */
     1075        if (rc != 0) /* if user sym failed or don't exists. */
    12271076        {
    1228             i = 0;
    1229             while (apszSym[i] != NULL && (rc = ProbeSymFile(apszSym[i])) != 0)
    1230                 i++;
     1077            /*
     1078             * Check database - only if not a debug kernel!
     1079             * You usually have a .sym-file when using a debug kernel.
     1080             * (Currently I am not able to distinguish between half and all strict kernels...)
     1081             */
     1082            if (fDebug ||
     1083                (rc = LookupKrnlEntry((unsigned short)usBuild, 'R', fSMP, cObjects)) != 0
     1084                )
     1085            {
     1086                /* search on disk */
     1087                i = 0;
     1088                while (apszSym[i] != NULL && (rc = ProbeSymFile(apszSym[i])) != 0)
     1089                    i++;
     1090            }
    12311091        }
    12321092    }
     
    12381098    return rc;
    12391099}
    1240 
     1100#endif
    12411101
    12421102
    12431103#ifdef DEBUGR3
     1104/**
     1105 * Verifies that build no, matches kernel number.
     1106 * @returns   0 on equal, !0 on error.
     1107 */
     1108static int VerifyKernelVer(void)
     1109{
     1110    int VerMinor, VerMajor;
     1111
     1112    VerMajor = usBuild < 20000 ? 20 : 30/*?*/;
     1113    VerMinor = usBuild <  6600 ? 10 :  usBuild <  8000 ? 11 : usBuild < 9000 ? 30 :
     1114               usBuild < 10000 ? 40 :  usBuild < 15000 ? 45 : 50;
     1115
     1116    return VerMajor - (int)usVerMajor | VerMinor - (int)usVerMinor;
     1117}
     1118
     1119
     1120/**
     1121 * Reads and verifies OS/2 kernel.
     1122 * @returns   0 on success, not 0 on failure.
     1123 * @param     filename   Filename of the OS/2 kernel.
     1124 * @result    usBuild is set.
     1125 * @remark    This step will be eliminated by searching thru the DOSGROUP datasegment
     1126 *            in the kernel memory. This segment have a string "Internal revision 9.034[smp|uni]"
     1127 *            This would be much faster than reading the kernel file. It will also give us a more precise
     1128 *            answer to the question! This is currently a TODO issue. !FIXME!
     1129 */
     1130static int ReadOS2Krnl(char * pszFilename)
     1131{
     1132    HFILE          hKrnl;
     1133    unsigned long  cbKrnl;
     1134    int            rc;
     1135
     1136    hKrnl = fopen(pszFilename, "rb");
     1137    if (hKrnl != 0)
     1138    {
     1139        cbKrnl = fsize(hKrnl);
     1140        if (!fseek(hKrnl, 0, SEEK_SET))
     1141            rc = ReadOS2Krnl2(hKrnl, cbKrnl);
     1142        else
     1143            rc = -2;
     1144        fclose(hKrnl);
     1145    }
     1146    else
     1147    {
     1148        dprintf(("Could not open file\n"));
     1149        rc = -1;
     1150    }
     1151    return rc;
     1152}
     1153
     1154
     1155/**
     1156 * Worker function for ReadOS2Krnl
     1157 * @returns   0 on success.
     1158 *            errorcodes on failure. (-1 >= rc >= -14)
     1159 * @param     hKrnl   Handle to the kernel file.
     1160 * @param     cbKrnl  Size of the kernel file.
     1161 * @author    knut st. osmundsen
     1162 */
     1163static int ReadOS2Krnl2(HFILE hKrnl, unsigned long  cbKrnl)
     1164{
     1165    #if defined(DEBUGR3) || !defined(EXTRACT)
     1166    static KRNLINFO KrnlInfo = {0};
     1167    #endif
     1168    int            i, j;
     1169    int            rc = 0;
     1170    char           achBuffer[KERNEL_ID_STRING_LENGTH + KERNEL_READ_SIZE];
     1171    unsigned long  offLXHdr;
     1172    struct e32_exe *pLXHdr;
     1173
     1174
     1175    /* find bldlevel string - "@#IBM:14.020#@  IBM OS/2 Kernel - 14.020F" */
     1176    if (fseek(hKrnl, 0, SEEK_SET))
     1177        return -2;
     1178
     1179    if (!fread(&achBuffer[KERNEL_ID_STRING_LENGTH], 1, KERNEL_READ_SIZE, hKrnl))
     1180        return -3;
     1181
     1182    i = KERNEL_ID_STRING_LENGTH;
     1183    while (cbKrnl > 0)
     1184    {
     1185        if (i == KERNEL_READ_SIZE)
     1186        {
     1187
     1188            kmemcpy(achBuffer, &achBuffer[KERNEL_READ_SIZE], KERNEL_ID_STRING_LENGTH);
     1189            if (!fread(&achBuffer[KERNEL_ID_STRING_LENGTH], 1, cbKrnl > KERNEL_READ_SIZE ? KERNEL_READ_SIZE : (int)cbKrnl, hKrnl))
     1190                return -3;
     1191
     1192            i = 0;
     1193        }
     1194
     1195        if (kstrncmp("@#IBM:", &achBuffer[i], 6) == 0)
     1196            break;
     1197
     1198        /* next */
     1199        i++;
     1200        cbKrnl--;
     1201    }
     1202
     1203    if (cbKrnl == 0)
     1204    {
     1205        fclose(hKrnl);
     1206        return -4;
     1207    }
     1208
     1209    /* displacement */
     1210    j = 0;
     1211    while (j < 6 && achBuffer[i+10+j] != '#')
     1212        j++;
     1213
     1214    /* verify signature */
     1215    if (kstrncmp(&achBuffer[i+10+j], "#@  IBM OS/2 Kernel", 19) != 0)
     1216        return -5;
     1217
     1218    /* read usBuild */
     1219    usBuild  = (char)(achBuffer[i+6] - '0') * 1000;
     1220    if (achBuffer[i+7] != '.')
     1221    {
     1222        /* this code is for Warp5 */
     1223        usBuild *= 10;
     1224        usBuild += (char)(achBuffer[i+7] - '0') * 1000;
     1225        i++;
     1226        j--;
     1227        if (achBuffer[i+7] != '.')
     1228        {
     1229            usBuild = usBuild * 10;
     1230            usBuild = usBuild + (unsigned short)(achBuffer[i+7] - '0') * 1000;
     1231            i++;
     1232            j--;
     1233        }
     1234    }
     1235
     1236    if (j == 0)
     1237    {
     1238        usBuild += (achBuffer[i+ 8] - '0') * 10;
     1239        usBuild += (achBuffer[i+ 9] - '0') * 1;
     1240    }
     1241    else
     1242    {
     1243        if (j == 3)
     1244            return -9;
     1245        usBuild += (achBuffer[i+ 8] - '0') * 100;
     1246        usBuild += (achBuffer[i+ 9] - '0') * 10;
     1247        usBuild += (achBuffer[i+10] - '0');
     1248    }
     1249
     1250    if (VerifyKernelVer())
     1251        return -9;
     1252    dprintf(("usBuild: %d\n", usBuild));
     1253
     1254    /* get segment number */
     1255    /* read-MZheader */
     1256    if (fseek(hKrnl,0,SEEK_SET))
     1257        return -2;
     1258
     1259    if (!fread(achBuffer, 1, 0x40, hKrnl))
     1260        return -3;
     1261
     1262    offLXHdr = *(unsigned long int *)&achBuffer[0x3c];
     1263
     1264    if (offLXHdr > 0x2000 && offLXHdr < 0x80) /* just to detect garbage */
     1265        return -6;
     1266
     1267    if (fseek(hKrnl, offLXHdr, SEEK_SET))
     1268        return -2;
     1269
     1270    if (!fread(achBuffer, 1, sizeof(struct e32_exe), hKrnl))
     1271        return -3;
     1272
     1273    /* check LX-magic */
     1274    if (achBuffer[0] != 'L' || achBuffer[1] != 'X')
     1275        return -7;
     1276
     1277#if !defined(DEBUGR3) && !defined(EXTRACT)
     1278    /* check object count - match it with what we got from the kernel. */
     1279    pLXHdr = (struct e32_exe *)achBuffer;
     1280    if ((UCHAR)pLXHdr->e32_objcnt != cObjects)
     1281        return -8;
     1282
     1283    if (pLXHdr->e32_objcnt < 10)
     1284        return -9;
     1285
     1286    /* check objects (sizes and flags(?)) */
     1287    if (!fseek(hKrnl, (LONG)offLXHdr + (LONG)pLXHdr->e32_objtab, SEEK_SET))
     1288    {
     1289        struct o32_obj *pObj = (struct o32_obj *)achBuffer;
     1290        for (i = 0; i < (int)cObjects; i++)
     1291        {
     1292            if (!fread(achBuffer, 1, sizeof(OTE), hKrnl))
     1293                return -11;
     1294            if (pObj->o32_size < paKrnlOTEs[i].ote_size)
     1295                return -12;
     1296
     1297            #if 0 /* don't work! */
     1298            if ((pObj->o32_flags & 0xffffUL) != (paKrnlOTEs[i].ote_flags & 0xffffUL))
     1299                return -14;
     1300            #endif
     1301        }
     1302    }
     1303    else
     1304        return -10;
     1305#else
     1306    /* Since we can't get the OTEs from the kernel when debugging in RING-3,
     1307     * we'll use what we find in the kernel.
     1308     */
     1309
     1310    /*  object count */
     1311    pLXHdr = (struct e32_exe *)achBuffer;
     1312    cObjects = (UCHAR)pLXHdr->e32_objcnt;
     1313    paKrnlOTEs = &KrnlInfo.aObjects[0];
     1314
     1315    /* get OTEs */
     1316    if (!fseek(hKrnl, (LONG)offLXHdr + (LONG)pLXHdr->e32_objtab, SEEK_SET))
     1317    {
     1318        struct o32_obj *pObj = (struct o32_obj *)achBuffer;
     1319        for (i = 0; i < (int)cObjects; i++)
     1320            if (!fread(&paKrnlOTEs[i], 1, sizeof(struct o32_obj), hKrnl))
     1321                return -11;
     1322    }
     1323    else
     1324        return -10;
     1325#endif
     1326
     1327    return 0;
     1328}
     1329
     1330
     1331
    12441332/**
    12451333 * Debug - Main procedure for standalone testing.
     
    12691357    ProbeKernel(&ReqPack);
    12701358}
    1271 
    12721359#endif
    12731360
     1361
     1362#ifdef EXTRACT
     1363/**
     1364 * Dumps writes a KRNLDBENTRY struct to stderr for the given .sym-file.
     1365 * The filesnames are on this format:
     1366 *    nnnn[n]tm.SYM
     1367 * Where: n - are the build number 4 or 5 digits.
     1368 *        t - kernel type. R = retail, H = half strict, A = all strict.
     1369 *        m - UNI or SMP.  U = UNI processor kernel. S = SMP processor kernel.
     1370 * @returns   NO_ERROR on success. Untracable error code on error.
     1371 * @param     pszFilename  Pointer to read only filename of the .sym-file.
     1372 * @status    completely implemented.
     1373 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     1374 * @remark    Currently only retail kernels are processed. See note below.
     1375 */
     1376static int processFile(const char *pszFilename)
     1377{
     1378    APIRET   rc;
     1379    int      cch = kstrlen(pszFilename);
     1380
     1381    /* Filename check */
     1382    if (cch < 10 || cch > 11
     1383        || !(pszFilename[0] >= '0' && pszFilename[0] <= '9')
     1384        || !(pszFilename[1] >= '0' && pszFilename[1] <= '9')
     1385        || !(pszFilename[2] >= '0' && pszFilename[2] <= '9')
     1386        || !(pszFilename[3] >= '0' && pszFilename[3] <= '9')
     1387        || !(pszFilename[cch-7] >= '0' && pszFilename[cch-7] <= '9')
     1388        || !(pszFilename[cch-6] == 'A' || pszFilename[cch-6] == 'H' || pszFilename[cch-6] == 'R')
     1389        || !(pszFilename[cch-5] == 'S' || pszFilename[cch-5] == 'U')
     1390        )
     1391    {
     1392        printf16("invalid filename: %s\n", pszFilename);
     1393        return 2;
     1394    }
     1395
     1396    /** @remark
     1397     * All a/h-strict files are currently ignored.
     1398     * When a debug kernel is used we'll have to use the
     1399     * .sym-file for it. This is so because I can't distinguish
     1400     * between a all-strick and a half-strick kernel (yet).
     1401     */
     1402    if (pszFilename[cch-6] != 'R')
     1403        return 0;
     1404
     1405    /*
     1406     * Probe kernelfile
     1407     */
     1408    rc = ProbeSymFile(pszFilename);
     1409
     1410
     1411    /*
     1412     * on success dump a struct for this kernel
     1413     */
     1414    if (rc == 0)
     1415    {
     1416        int i;
     1417
     1418        printf16("    { /* %s */\n"
     1419                 "        %.*s, \'%c\', %s, %d,\n"
     1420                 "        {\n",
     1421                 pszFilename,
     1422                 cch - 6, &pszFilename[0],                       /* build number */
     1423                 pszFilename[cch - 6],                           /* Type, A=astrict, H=halfstrict, R=Retail */
     1424                 pszFilename[cch - 5] == 'S' ? "TRUE" : "FALSE", /* UNI: TRUE  SMP: FALSE */
     1425                 aImportTab[0].iObject + 1); /* ASSUMES that DOSCODE32 is the last object. */
     1426
     1427        for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
     1428        {
     1429            char *psz = aImportTab[i].achName;
     1430            printf16("            {%2d, 0x%08lx}, /* %s */\n",
     1431                     aImportTab[i].iObject,
     1432                     aImportTab[i].offObject,
     1433                     (char *)&aImportTab[i].achName[0]
     1434                     );
     1435        }
     1436        printf16("        }\n"
     1437                 "    },\n");
     1438    }
     1439    else
     1440        printf16("ProbeSymFile failed with rc=%d\n", rc);
     1441
     1442    return rc;
     1443}
     1444
     1445
     1446/**
     1447 * Extract program.
     1448 *
     1449 * This is some initial trial-and-error for creating an "database" of
     1450 * kernel entrypoints.
     1451 *
     1452 * Output to stderr the structs generated for the passed in *.sym file.
     1453 *
     1454 */
     1455int main(int argc, char **argv)
     1456{
     1457    APIRET  rc;
     1458
     1459    if (argc > 1)
     1460    {
     1461        /*
     1462         * Arguments: extract.exe <symfiles...>
     1463         */
     1464        int i;
     1465        for (i = 0; i < argc; i++)
     1466        {
     1467            rc = processFile(argv[i]);
     1468            if (rc != NO_ERROR)
     1469            {
     1470                printf16("processFile failed with rc=%d for file %s\n",
     1471                          rc, argv[i]);
     1472                return rc;
     1473            }
     1474        }
     1475    }
     1476    else
     1477    {
     1478        /*
     1479         * Arguments: extract.exe
     1480         *
     1481         * Action:    Scan current directory for *.sym files.
     1482         *
     1483         */
     1484        USHORT      usSearch = 1;
     1485        HDIR        hDir = HDIR_CREATE;
     1486        FILEFINDBUF ffb;
     1487        int         i;
     1488
     1489        printf16("/* $Id: probkrnl.c,v 1.16 2000-02-25 18:15:02 bird Exp $\n"
     1490                 "*\n"
     1491                 "* Autogenerated kernel symbol database.\n"
     1492                 "*\n"
     1493                 "* Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)\n"
     1494                 "*\n"
     1495                 "* Project Odin Software License can be found in LICENSE.TXT\n"
     1496                 "*\n"
     1497                 "*/\n");
     1498
     1499        printf16("\n"
     1500                 "#include <os2.h>\n"
     1501                 "#include \"probkrnl.h\"\n"
     1502                 "\n");
     1503
     1504        printf16("KRNLDBENTRY aKrnlSymDB[] = \n"
     1505                 "{\n");
     1506
     1507        rc = DosFindFirst("*.sym", &hDir, FILE_NORMAL,
     1508                          &ffb, sizeof(ffb),
     1509                          &usSearch, 0UL);
     1510        while (rc == NO_ERROR & usSearch > 0)
     1511        {
     1512            rc = processFile(&ffb.achName[0]);
     1513            if (rc != NO_ERROR)
     1514            {
     1515                printf16("processFile failed with rc=%d for file %s\n",
     1516                         rc, &ffb.achName[0]);
     1517                return rc;
     1518            }
     1519
     1520            /* next file */
     1521            rc = DosFindNext(hDir, &ffb, sizeof(ffb), &usSearch);
     1522        }
     1523        DosFindClose(hDir);
     1524
     1525        printf16("    { /* Terminating entry */\n"
     1526                 "        0,0,0,0,\n"
     1527                 "        {\n");
     1528        for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
     1529            printf16("            {0,0},\n");
     1530        printf16("        }\n"
     1531                 "    }\n"
     1532                 "}; /* end of aKrnlSymDB[] */\n"
     1533                 );
     1534    }
     1535
     1536
     1537    return rc;
     1538}
     1539#endif /* EXTRACT */
     1540
  • trunk/src/win32k/dev32/d32globals.c

    r2849 r2898  
    1 /* $Id: d32globals.c,v 1.4 2000-02-21 15:59:20 bird Exp $
     1/* $Id: d32globals.c,v 1.5 2000-02-25 18:15:03 bird Exp $
    22 *
    33 * d32globals - global data (32-bit)
     
    1818*******************************************************************************/
    1919#include <os2.h>
    20 #include "options.h"
    2120
    2221/*******************************************************************************
     
    2423*******************************************************************************/
    2524PULONG          pulTKSSBase32;
    26 #ifdef DEBUG
    27 char szStartOfOptions[] = "START-OF-OPTIONS";
    28 #endif
    29 struct options  options = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
    30 #ifdef DEBUG
    31 char szEndOfOptions[] = "END-OF-OPTIONS";
    32 #endif
    3325
  • trunk/src/win32k/dev32/d32init.c

    r2878 r2898  
    1 /* $Id: d32init.c,v 1.15 2000-02-23 23:01:00 bird Exp $
     1/* $Id: d32init.c,v 1.16 2000-02-25 18:15:03 bird Exp $
    22 *
    33 * d32init.c - 32-bits init routines.
     
    1515                                        /* the one used in calltab.asm.       */
    1616#define static                          /* just to make all symbols visible in the kernel debugger.  */
     17#if  0                                  /* Enable this to have extra debug logging. */
     18    #define kprintf2(a) kprintf
     19#else
     20    #define kprintf2(a) (void)0
     21#endif
    1722
    1823
     
    4954static char * apszInfoLevel[] = {"INFOLEVEL_QUIET", "INFOLEVEL_ERROR", "INFOLEVEL_WARNING", "INFOLEVEL_INFO", "INFOLEVEL_INFOALL", "!invalid!"};
    5055#endif
     56static PMTE    pKrnlMTE = NULL;
     57static PSMTE   pKrnlSMTE = NULL;
     58static POTE    pKrnlOTE = NULL;
     59
    5160
    5261/*******************************************************************************
     
    7079/* extern(s) located in mytkExecPgm.asm  */
    7180extern char     mytkExecPgm;
    72 extern char     CODE32START;
    73 extern char     CODE32END;
    74 extern char     CONST32_ROEND;
    75 extern char     DATA16START;
    76 extern char     DATA16_CONSTEND;
    7781
    7882
     
    9498USHORT _loadds _Far32 _Pascal R0Init32(RP32INIT *pRpInit)
    9599{
    96     char   *pszTmp2;
    97     char   *pszTmp;
    98     ULONG   ul;
    99     APIRET  rc;
    100     LOCKHANDLE lhData16={0,0,0,0, 0,0,0,0, 0,0,0,0};
    101     LOCKHANDLE lhData = {0,0,0,0, 0,0,0,0, 0,0,0,0};
    102     LOCKHANDLE lhCode = {0,0,0,0, 0,0,0,0, 0,0,0,0};
     100    char *      pszTmp2;
     101    char *      pszTmp;
     102    ULONG       ul;
     103    APIRET      rc;
     104    LOCKHANDLE  lockhandle;
    103105
    104106    pulTKSSBase32 = (PULONG)_TKSSBase16;
    105 
    106     SET_OPTIONS_TO_DEFAULT(options);
    107107
    108108    /*---------------------*/
     
    273273
    274274    /* Transfer version and build number from 16-bit probkrnl.c */
    275     options.ulBuild    = _ulBuild;
     275    options.ulBuild    = _usBuild;
    276276    options.usVerMajor = _usVerMajor;
    277277    options.usVerMinor = _usVerMinor;
    278278
    279     /* log option summary - FIXME */
     279    /* Log option summary */
     280    #ifdef DEBUG
    280281    kprintf(("Options - Summary - Start\n"));
    281282    if (options.fQuiet)
     
    306307             options.cbSwpHeapInit, options.cbSwpHeapMax));
    307308    kprintf(("Options - Summary - End\n"));
     309    #endif /* debug */
    308310    /* end option summary */
    309311
     
    331333     */
    332334    /* 32-bit code segment */
     335    memset(SSToDS(&lockhandle), 0, sizeof(lockhandle));
    333336    rc = D32Hlp_VMLock2(&CODE32START,
    334337                        ((unsigned)&CODE32END & ~0xFFF) - (unsigned)&CODE32START, /* Round down so we don't overlap with the next request. */
    335338                        VMDHL_LONG,
    336                         SSToDS(&lhCode));
     339                        SSToDS(&lockhandle));
    337340    if (rc != NO_ERROR)
    338341        kprintf(("code segment lock failed with with rc=%d\n", rc));
    339342
    340343    /* 32-bit data segment */
     344    memset(SSToDS(&lockhandle), 0, sizeof(lockhandle));
    341345    rc = D32Hlp_VMLock2(callTab,
    342346                        &CONST32_ROEND - (char*)callTab,
    343347                        VMDHL_LONG | VMDHL_WRITE,
    344                         SSToDS(&lhData));
     348                        SSToDS(&lockhandle));
    345349    if (rc != NO_ERROR)
    346350        kprintf(("data segment lock failed with with rc=%d\n", rc));
    347351
    348     /* 16-bit data segment */
     352    /* 16-bit data segment - is this necessary? */
     353    memset(SSToDS(&lockhandle), 0, sizeof(lockhandle));
    349354    rc = D32Hlp_VMLock2(&DATA16START,
    350                         &DATA16_CONSTEND - &DATA16START,
     355                        &DATA16END - &DATA16START,
    351356                        VMDHL_LONG | VMDHL_WRITE,
    352                         SSToDS(&lhData16));
     357                        SSToDS(&lockhandle));
    353358    if (rc != NO_ERROR)
    354         kprintf(("data segment lock failed with with rc=%d\n", rc));
     359        kprintf(("16-bit data segment lock failed with with rc=%d\n", rc));
    355360
    356361    return STATUS_DONE;
     
    371376    int   i = 0;
    372377
     378    /* determin ulBase */
    373379    if (*pszNum == '0')
    374380        if (pszNum[1] == 'x' || pszNum[1] == 'X')
     
    403409/**
    404410 * Get kernel OTEs
     411 * This function set pKrnlMTE, pKrnlSMTE and pKrnlOTE.
    405412 * @returns   Strategy return code:
    406413 *            STATUS_DONE on success.
    407414 *            STATUS_DONE | STERR | errorcode on failure.
    408  * @param     pOTEBuf  Pointer to output buffer.
     415 * @param     pKrnlInfo  Pointer to output buffer.
     416 *                       If NULL only the three global variables are set.
    409417 * @status    completely implemented and tested.
    410418 * @author    knut st. osmundsen
    411419 * @remark    Called from IOCtl.
     420 *            WARNING! This function is called before the initroutine (R0INIT)!
    412421 */
    413 USHORT _loadds _Far32 _Pascal GetOTEs32(PKRNLOBJTABLE pOTEBuf)
     422USHORT _loadds _Far32 _Pascal GetKernelInfo32(PKRNLINFO pKrnlInfo)
    414423{
    415     PMTE    pMTE;
    416     PSMTE   pSMTE;
    417     POTE    pOTE;
    418424    int     i;
    419425    USHORT  usRc;
    420426
    421     pMTE = GetOS2KrnlMTE();
    422     if (pMTE != NULL)
     427    /* VerifyImporTab32 is called before the initroutine! */
     428    pulTKSSBase32 = (PULONG)_TKSSBase16;
     429
     430    /* Find the kernel OTE table */
     431    pKrnlMTE = GetOS2KrnlMTE();
     432    if (pKrnlMTE != NULL)
    423433    {
    424         pSMTE = pMTE->mte_swapmte;
    425         if (pSMTE != NULL)
     434        pKrnlSMTE = pKrnlMTE->mte_swapmte;
     435        if (pKrnlSMTE != NULL)
    426436        {
    427             pOTEBuf->cObjects = (unsigned char)pSMTE->smte_objcnt;
    428             if (pSMTE->smte_objcnt <= MAXKRNLOBJECTS)
     437            if (pKrnlSMTE->smte_objcnt <= MAXKRNLOBJECTS)
    429438            {
    430                 pOTE = pSMTE->smte_objtab;
    431                 if (pOTE != NULL)
     439                pKrnlOTE = pKrnlSMTE->smte_objtab;
     440                if (pKrnlOTE != NULL)
    432441                {
    433                     /* Copy OTEs */
    434                     for (i = 0; i < pOTEBuf->cObjects; i++)
    435                         memcpy((void*)&pOTEBuf->aObjects[i], &pOTE[i], sizeof(OTE));
     442                    /*
     443                     * Thats all?
     444                     */
     445                    if (pKrnlInfo == NULL)
     446                        return NO_ERROR;
     447
     448                    pKrnlInfo->cObjects = (unsigned char)pKrnlSMTE->smte_objcnt;
     449
     450                    /*
     451                     * Copy OTEs
     452                     */
     453                    for (i = 0; i < pKrnlInfo->cObjects; i++)
     454                    {
     455                        memcpy((void*)&pKrnlInfo->aObjects[i], &pKrnlOTE[i], sizeof(OTE));
     456                        kprintf2(("GetKernelInfo32: %d base=0x%08x size=0x%08x flags=0x%08x\n",
     457                                  i, pKrnlOTE[i].ote_base, pKrnlOTE[i].ote_size, pKrnlOTE[i].ote_flags));
     458                    }
    436459                    usRc = 0;
    437460
     
    439462                     * Search for internal revision stuff in the two first objects.
    440463                     */
    441                     #if 0
    442                     for (i = 0; i < 2; i++)
     464                    pKrnlInfo->usBuild = 0;
     465                    for (i = 0; i < 2 && pKrnlInfo->usBuild == 0; i++)
    443466                    {
    444                         const char *psz = (const char*)pOTE[i].ote_base;
    445                         const char *pszEnd = psz + pOTE[i].ote_size;
     467                        const char *psz = (const char*)pKrnlOTE[i].ote_base;
     468                        const char *pszEnd = psz + pKrnlOTE[i].ote_size;
    446469
    447470                        while (psz + 100 < pszEnd)
    448471                        {
    449                             strncmp(psz, "Internal revision");
     472                            if (strncmp(psz, "Internal revision ", 18) == 0 && (psz[18] >= '0' && psz[18] <= '9'))
     473                            {
     474                                int j;
     475                                kprintf2(("GetOTEs32: found internal revision: '%s'\n", psz));
     476
     477                                /* skip to end of "Internal revision " string. */
     478                                psz += 18;
     479
     480                                /* Read number*/
     481                                while ((*psz >= '0' && *psz <= '9') || *psz == '.')
     482                                {
     483                                    if (*psz != '.')
     484                                        pKrnlInfo->usBuild = (unsigned short)(pKrnlInfo->usBuild * 10 + (*psz - '0'));
     485                                    psz++;
     486                                }
     487
     488                                /* Check if build number seems valid. */
     489                                if (   !(pKrnlInfo->usBuild >=  8254 && pKrnlInfo->usBuild <  8383) /* Warp 3 fp 32 -> fp 60 */
     490                                    && !(pKrnlInfo->usBuild >=  9023 && pKrnlInfo->usBuild <  9063) /* Warp 4 GA -> fp 40 */
     491                                    && !(pKrnlInfo->usBuild >= 14039 && pKrnlInfo->usBuild < 14080) /* Warp 4.5 GA -> fp 40 */
     492                                      )
     493                                {
     494                                    kprintf(("GetOTEs32: info summary: Build %d is invalid - invalid fixpack?\n", pKrnlInfo->usBuild));
     495                                    usRc = 6;
     496                                    break;
     497                                }
     498
     499                                /* If this is an Aurora or Warp 3 kernel there is more info! */
     500                                pKrnlInfo->fSMP = (char)(*psz != ','
     501                                    && (   (psz[1] == '_' && (psz[2] == 'S' || psz[2] == 's'))  /* F_SMP */
     502                                        || (psz[2] == '_' && (psz[1] == 'S' || psz[1] == 's'))));/* _SMP  */
     503
     504                                /* Check if its a debug kernel (look for DEBUG at start of object 3-5) */
     505                                j = 3;
     506                                pKrnlInfo->fDebug = FALSE;
     507                                while (j < 5)
     508                                {
     509
     510                                    /* There should be no iopl object preceding the debugger data object. */
     511                                    if ((pKrnlOTE[j].ote_flags & OBJIOPL) != 0)
     512                                        break;
     513                                    /* Is this is? */
     514                                    if ((pKrnlOTE[j].ote_flags & OBJINVALID) == 0
     515                                        && (pKrnlOTE[j].ote_flags & (OBJREAD | OBJWRITE)) == (OBJREAD | OBJWRITE)
     516                                        && strncmp((char*)pKrnlOTE[j].ote_base, "DEBUG", 5) == 0)
     517                                    {
     518                                        pKrnlInfo->fDebug = TRUE;
     519                                        break;
     520                                    }
     521                                    j++;
     522                                }
     523
     524                                /* Display info */
     525                                kprintf(("GetOTEs32: info summary: Build %d, fSMP=%d, fDebug=%d\n",
     526                                         pKrnlInfo->usBuild, pKrnlInfo->fSMP, pKrnlInfo->fDebug));
     527
     528                                /* Break out */
     529                                break;
     530                            }
    450531
    451532                            /* next */
    452533                            psz++;
    453                         }
     534                        } /* while loop searching for "Internal revision " */
     535                    } /* for loop on objects 0-1. */
     536
     537                    /* Set error code if not found */
     538                    if (pKrnlInfo->usBuild == 0)
     539                    {
     540                        usRc = 5;
     541                        kprintf(("GetOTEs32: Internal revision was not found!\n"));
    454542                    }
    455                     #endif
    456543                }
    457544                else
     
    466553    else
    467554        usRc = 1;
     555
    468556
    469557    if (usRc != 0)
     
    515603    int cb = -3;
    516604
    517     kprintf(("interpretFunctionProlog32(0x%08x, %d):\n"
    518              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
    519              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
    520              pach, fOverload,
    521              pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
    522              pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
     605    kprintf2(("interpretFunctionProlog32(0x%08x, %d):\n"
     606              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
     607              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
     608              pach, fOverload,
     609              pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
     610              pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
    523611
    524612    /*
     
    699787    int cb = -7;
    700788
    701     kprintf(("interpretFunctionProlog16(0x%08x, %d):\n"
    702              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
    703              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
    704              pach, fOverload,
    705              pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
    706              pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
     789    kprintf2(("interpretFunctionProlog16(0x%08x, %d):\n"
     790              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
     791              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
     792              pach, fOverload,
     793              pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
     794              pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
    707795    /*
    708796     * Check for the well known prolog (the only that is supported now)
     
    817905 * @returns   0 if ok. !0 if not ok.
    818906 * @remark    Called from IOCtl.
    819  *            WARNING! VerifyImporTab32 is called before the initroutine!
     907 *            WARNING! This function is called before the initroutine (R0INIT)!
    820908 */
    821909USHORT _loadds _Far32 _Pascal VerifyImportTab32(void)
     
    828916    pulTKSSBase32 = (PULONG)_TKSSBase16;
    829917
    830     /* verify */
     918    /* Check that pKrnlOTE is set */
     919    if (GetKernelInfo32(NULL) != NO_ERROR)
     920        return STATUS_DONE | STERR | 1;
     921
     922    /*
     923     * Verify aImportTab.
     924     */
    831925    for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
    832926    {
    833         /* verify that it is found */
     927        /*
     928         * Debug info
     929         */
     930        kprintf2(("VerifyImportTab32: procedure no.%d is being checked: %s addr=0x%08x iObj=%d offObj=%d\n",
     931                  i, &_aImportTab[i].achName[0], _aImportTab[i].ulAddress,
     932                  _aImportTab[i].iObject, _aImportTab[i].offObject));
     933
     934        /* Verify that it is found */
    834935        if (!_aImportTab[i].fFound)
    835936        {
    836             kprintf(("VerifyImportTab32: procedure no.%d was not found!\n", i));
    837             return STATUS_DONE | STERR | 1;
     937            kprintf(("VerifyImportTab32: procedure no.%d was not fFound!\n", i));
     938            return STATUS_DONE | STERR | 2;
    838939        }
    839940
    840         /* verify read/writeable. - FIXME */
     941        /* Verify read/writeable. */
     942        if (_aImportTab[i].iObject >= pKrnlSMTE->smte_objcnt                                /* object index valid? */
     943            || _aImportTab[i].ulAddress < pKrnlOTE[_aImportTab[i].iObject].ote_base         /* address valid? */
     944            || _aImportTab[i].ulAddress + 16 > (pKrnlOTE[_aImportTab[i].iObject].ote_base +
     945                                                pKrnlOTE[_aImportTab[i].iObject].ote_size)  /* address valid? */
     946            || _aImportTab[i].ulAddress - _aImportTab[i].offObject
     947               != pKrnlOTE[_aImportTab[i].iObject].ote_base                                 /* offObject ok?  */
     948            )
     949        {
     950            kprintf(("VerifyImportTab32: procedure no.%d has an invalid address or object number.!\n"
     951                     "                   %s  addr=0x%08x iObj=%d offObj=%d\n",
     952                     i, &_aImportTab[i].achName[0], _aImportTab[i].ulAddress,
     953                     _aImportTab[i].iObject, _aImportTab[i].offObject));
     954            return STATUS_DONE | STERR | 3;
     955        }
     956
     957
     958
    841959        if (_aImportTab[i].ulAddress < 0xffe00000UL)
    842960        {
    843             kprintf(("VerifyImportTab32: procedure no.%d has an invlalid address, %#08x!\n",
     961            kprintf(("VerifyImportTab32: procedure no.%d has an invalid address, %#08x!\n",
    844962                     i, _aImportTab[i].ulAddress));
    845             return STATUS_DONE | STERR | 2;
     963            return STATUS_DONE | STERR | 4;
    846964        }
    847965
     
    855973                if (EPT32BitEntry(_aImportTab[i]))
    856974                {
    857                     cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC32);
     975                    cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress,
     976                                                   _aImportTab[i].fType == EPT_PROC32);
    858977                    cbmin = 5; /* Size of the jump instruction */
    859978                }
    860979                else
    861980                {
    862                     cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC16);
     981                    cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress,
     982                                                   _aImportTab[i].fType == EPT_PROC16);
    863983                    cbmin = 7; /* Size of the far jump instruction */
    864984                }
     
    870990                {   /* failed, too small or too large. */
    871991                    kprintf(("VerifyImportTab32: verify failed for procedure no.%d (cd=%d)\n", i, cb));
    872                     return STATUS_DONE | STERR | 3;
     992                    return STATUS_DONE | STERR | 5;
    873993                }
    874994                break;
     
    8811001                kprintf(("VerifyImportTab32: only EPT_PROC is implemented\n",i));
    8821002                Int3(); /* temporary fix! */
    883                 return STATUS_DONE | STERR | 4;
     1003                return STATUS_DONE | STERR | 6;
    8841004        }
    8851005    }
  • trunk/src/win32k/dev32/devfirst.asm

    r2836 r2898  
    1 ; $Id: devfirst.asm,v 1.4 2000-02-21 04:45:46 bird Exp $
     1; $Id: devfirst.asm,v 1.5 2000-02-25 18:15:03 bird Exp $
    22;
    33; DevFirst - entrypoint and segment definitions
     
    2828    public BSS32START
    2929    public CONST32_ROSTART
     30    public _VFTSTART
     31    public EH_DATASTART
     32
    3033
    3134    public _strategyAsm0
    3235    public _strategyAsm1
    33     public _CallGetOTEs32
     36    public _CallGetKernelInfo32
    3437    public _CallElfIOCtl
    3538    public _CallWin32kIOCtl
     
    4245;
    4346    extrn _TKSSBase16:dword
    44     extrn GETOTES32:FAR
     47    extrn GETKERNELINFO32:FAR
    4548    extrn ELFIOCTL:FAR
    4649    extrn WIN32KIOCTL:FAR
     
    8689;;
    8790; Thunk procedure for R0Init32.
    88 ; @cproto    USHORT NEAR CallGetOTEs32(ULONG addressOTEBuf);
    89 ; @returns   Same as GetOTEs32.
    90 ; @param     address of OTEBuf  32-bit pointer to request data.
    91 ; @status    completely implemented.
    92 ; @author    knut st. osmundsen
    93 _CallGetOTEs32 PROC NEAR
     91; @cproto    USHORT NEAR CallGetKernelInfo32(ULONG addressKrnlInfoBuf);
     92; @returns   Same as GetKernelInfo32.
     93; @param     addressKrnlInfoBuf  32-bit pointer to request data on stack.
     94; @status    completely implemented.
     95; @author    knut st. osmundsen
     96_CallGetKernelInfo32 PROC NEAR
    9497    ASSUME CS:CODE16
    9598    push    ds
    9699    push    word ptr [esp+6]            ; push high word.
    97100    push    word ptr [esp+6]            ; push low word.
    98     call    far ptr FLAT:GETOTES32
     101    call    far ptr FLAT:GETKERNELINFO32
    99102    pop     ds
    100103    retn
    101 _CallGetOTEs32 ENDP
     104_CallGetKernelInfo32 ENDP
    102105
    103106
  • trunk/src/win32k/dev32/devlast.asm

    r2836 r2898  
    1 ; $Id: devlast.asm,v 1.4 2000-02-21 04:45:46 bird Exp $
     1; $Id: devlast.asm,v 1.5 2000-02-25 18:15:03 bird Exp $
    22;
    33; DevLast - the object file termintating the resident part of the objects.
     
    3030    public BSS32END
    3131    public CONST32_ROEND
     32    public _VFTEND
     33    public EH_DATAEND
    3234    public _CallR0Init32
    3335    public _CallVerifyImportTab32
     
    9395
    9496CODE32 segment
    95 CODE32END db ?
     97CODE32END LABEL BYTE
    9698CODE32 ends
    9799
    98100DATA32 segment
    99 DATA32END  db ?
     101DATA32END  LABEL BYTE
    100102DATA32 ends
    101103
  • trunk/src/win32k/include/dev16.h

    r2836 r2898  
    1 /* $Id: dev16.h,v 1.7 2000-02-21 04:45:46 bird Exp $
     1/* $Id: dev16.h,v 1.8 2000-02-25 18:15:04 bird Exp $
    22 * dev16 - 16-bit specific. Should not be used in 32-bit C/C++.
    33 *
     
    1313typedef ULONG       LIN;
    1414typedef ULONG  FAR *PLIN;
     15#endif
     16#ifndef MAX_DISKDD_CMD   /* macro from reqpkt.h where these normally is declared. */
     17typedef void   FAR *PRPINITIN;
     18typedef void   FAR *PRPINITOUT;
     19typedef void   FAR *PRP_GENIOCTL;
     20typedef ULONG       DDHDR;
    1521#endif
    1622
     
    3642 * Get Kernel OTEs. No params. Data is KRNLOBJTABLE (dev1632.h).
    3743 */
    38 #define D16_IOCTL_GETKRNLOTES       0x41
     44#define D16_IOCTL_GETKRNLINFO       0x41
    3945
    4046
    4147/*
    42  * Get Kernel OTEs. No params. No data. aImportTab is used.
     48 * Verify aImportTab. No params. No data (aImportTab is used).
    4349 */
    44 #define D16_IOCTL_VERIFYPROCTAB     0x42
     50#define D16_IOCTL_VERIFYIMPORTTAB   0x42
     51
    4552
    4653/**
     
    112119 */
    113120USHORT NEAR CallR0Init32(LIN pRpInit);
    114 USHORT NEAR CallGetOTEs32(ULONG addressOTEBuf);
     121USHORT NEAR CallGetKernelInfo32(ULONG addressKrnlInfoBuf);
    115122USHORT NEAR CallVerifyImportTab32(void);
    116123USHORT NEAR CallElfIOCtl(LIN pRpIOCtl);
     
    132139extern USHORT   R0FlatCS16;
    133140extern USHORT   R0FlatDS16;
     141extern BOOL     fInitTime;
    134142
    135143
     
    155163extern char PASCAL BSS32START       ;
    156164extern char PASCAL CONST32_ROSTART  ;
     165extern char PASCAL _VFTSTART        ;
     166extern char PASCAL EH_DATASTART     ;
    157167
    158168extern char PASCAL CODE16END      ;
     
    166176extern char PASCAL BSS32END       ;
    167177extern char PASCAL CONST32_ROEND  ;
     178extern char PASCAL _VFTEND        ;
     179extern char PASCAL EH_DATAEND     ;
    168180
    169181
  • trunk/src/win32k/include/dev1632.h

    r2831 r2898  
    1 /* $Id: dev1632.h,v 1.3 2000-02-19 23:52:00 bird Exp $
     1/* $Id: dev1632.h,v 1.4 2000-02-25 18:15:04 bird Exp $
    22 * dev1632.h - Common header file for 16-bit and 32-bit C
    33 *
     
    4848
    4949#define MAXKRNLOBJECTS 24
    50 typedef struct _KRNLOBJTABLE
     50typedef struct _KRNLINFO
    5151{
    5252    unsigned char   cObjects;
     53    unsigned char   fDebug;
     54    unsigned char   fSMP;
     55    unsigned short  usBuild;
    5356    OTE             aObjects[MAXKRNLOBJECTS];
    54 } KRNLOBJTABLE, FAR * PKRNLOBJTABLE;
     57} KRNLINFO, FAR * PKRNLINFO;
    5558
    5659#else
    5760
    58 #define PKRNLOBJTABLE void *
     61#define PKRNLINFO void *
    5962
    6063#endif
  • trunk/src/win32k/include/dev32.h

    r2836 r2898  
    1 /* $Id: dev32.h,v 1.7 2000-02-21 04:45:46 bird Exp $
     1/* $Id: dev32.h,v 1.8 2000-02-25 18:15:04 bird Exp $
    22 *
    33 * dev32 - header file for 32-bit part of the driver.
     
    2323    #define RP32GENIOCTL    void
    2424    #define PRP32GENIOCTL   void *
    25     #define PKRNLOBJTABLE   void *
     25    #define PKRNLINFO       void *
    2626#endif
    2727
     
    5656#if !defined(__cplusplus) && defined(RING0)
    5757USHORT _loadds _Far32 _Pascal R0Init32(RP32INIT *pRpInit);
    58 USHORT _loadds _Far32 _Pascal GetOTEs32(PKRNLOBJTABLE pOTEBuf);
     58USHORT _loadds _Far32 _Pascal GetKernelInfo32(PKRNLINFO pKrnlInfo);
    5959USHORT _loadds _Far32 _Pascal VerifyImportTab32(void);
    6060USHORT _loadds _Far32 _Pascal ElfIOCtl(PRP32GENIOCTL pRpIOCtl);
     
    9696#endif
    9797
     98
     99/*
     100 * START and END labels. NOTE: these are not bytes only assembly labels.
     101 */
     102extern char CODE16START      ;
     103extern char DATA16START      ;
     104extern char DATA16START      ;
     105extern char DATA16_BSSSTART  ;
     106extern char DATA16_CONSTSTART;
     107extern char CODE16START      ;
     108extern char CODE32START      ;
     109extern char DATA32START      ;
     110extern char BSS32START       ;
     111extern char CONST32_ROSTART  ;
     112extern char _VFTSTART        ;
     113extern char EH_DATASTART     ;
     114
     115extern char CODE16END      ;
     116extern char DATA16END      ;
     117extern char DATA16END      ;
     118extern char DATA16_BSSEND  ;
     119extern char DATA16_CONSTEND;
     120extern char CODE16END      ;
     121extern char CODE32END      ;
     122extern char DATA32END      ;
     123extern char BSS32END       ;
     124extern char CONST32_ROEND  ;
     125extern char _VFTEND        ;
     126extern char EH_DATAEND     ;
     127
     128
     129
     130
    98131#endif
  • trunk/src/win32k/include/log.h

    r1467 r2898  
    1 /* $Id: log.h,v 1.3 1999-10-27 02:02:56 bird Exp $
     1/* $Id: log.h,v 1.4 2000-02-25 18:15:04 bird Exp $
    22 *
    33 * log - C-style logging - kprintf.
    44 * Dual mode, RING0 and RING3.
     5 * Dual 16 and 32 bit.
    56 *
    6  * Copyright (c) 1998-1999 knut st. osmundsen
     7 * Define NOLOGGING to disable logging for the given sourcefile or the entire system.
     8 *
     9 * Copyright (c) 1998-2000 knut st. osmundsen
    710 *
    811 * Project Odin Software License can be found in LICENSE.TXT
     
    2831 */
    2932#define dprintf kprintf
    30 #ifdef DEBUG
    31     #include <stdarg.h>
    32     #include "vprintf.h"
    33     #define kprintf(a)          printf a
     33#if defined(DEBUG) && !defined(NOLOGGING)
     34    #ifndef INCL_16
     35        /* 32-bit */
     36        #include <stdarg.h>
     37        #include "vprintf.h"
     38        #define kprintf(a)          printf a
     39    #else
     40        /* 16-bit */
     41        #include "vprntf16.h"
     42        #define kprintf(a)          printf16 a
     43    #endif
    3444#else
    35     #define kprintf(a)          (void)0
     45    #define kprintf(a)              (void)0
    3646#endif
    3747
  • trunk/src/win32k/include/options.h

    r2849 r2898  
    1 /* $Id: options.h,v 1.9 2000-02-21 15:59:21 bird Exp $
     1/* $Id: options.h,v 1.10 2000-02-25 18:15:06 bird Exp $
    22 *
    33 * Options.
     
    1616*******************************************************************************/
    1717/* fKernel */
    18 #define KF_UNI      0x00000000UL
    19 #define KF_SMP      0x00000001UL
     18#define KF_UNI              0x00000000UL
     19#define KF_SMP              0x00000001UL
    2020
    2121/* fPE */
     
    2626
    2727/* ulInfoLevel */
    28 #define INFOLEVEL_QUIET      0x00000000UL
    29 #define INFOLEVEL_ERROR      0x00000001UL
    30 #define INFOLEVEL_WARNING    0x00000002UL
    31 #define INFOLEVEL_INFO       0x00000003UL
    32 #define INFOLEVEL_INFOALL    0x00000004UL
     28#define INFOLEVEL_QUIET     0x00000000UL
     29#define INFOLEVEL_ERROR     0x00000001UL
     30#define INFOLEVEL_WARNING   0x00000002UL
     31#define INFOLEVEL_INFO      0x00000003UL
     32#define INFOLEVEL_INFOALL   0x00000004UL
    3333
    3434/* default heapsizes */
    35 #define CB_SWP_INIT         (1024*512)
    36 #define CB_SWP_MAX          (1024*1024*16)
    37 #define CB_RES_INIT         (1024*256)
    38 #define CB_RES_MAX          (1024*1024*10)
     35#define CB_SWP_INIT         (1024*512)      /* 512KB */
     36#define CB_SWP_MAX          (1024*1024*16)  /*  16MB  */
     37#define CB_RES_INIT         (1024*256)      /* 256KB */
     38#define CB_RES_MAX          (1024*1024*10)  /*  10MB  */
    3939
     40/* default assignments */
     41#define DEFAULT_OPTION_ASSIGMENTS                           \
     42            {FALSE,                 /* fQuiet        */     \
     43            OUTPUT_COM2,            /* usCom         */     \
     44            FALSE,                  /* fLogging      */     \
     45            KF_UNI,                 /* fKernel       */     \
     46            ~0UL,                   /* ulBuild       */     \
     47            (unsigned short)~0,     /* usVerMajor    */     \
     48            (unsigned short)~0,     /* usVerMinor    */     \
     49            FLAGS_PE_PE2LX,         /* fPE           */     \
     50            INFOLEVEL_QUIET,        /* ulInfoLevel   */     \
     51            FALSE,                  /* fElf          */     \
     52            TRUE,                   /* fScript       */     \
     53            FALSE,                  /* fNoLoader     */     \
     54            CB_SWP_INIT,            /* cbSwpHeapInit */     \
     55            CB_SWP_MAX,             /* cbSwpHeapMax  */     \
     56            CB_RES_INIT,            /* cbResHeapInit */     \
     57            CB_RES_MAX}             /* cbResHeapMax  */
    4058
    41 /* Set defaults. */
    42 #define SET_OPTIONS_TO_DEFAULT(o)                   \
    43             o.fQuiet        = FALSE;                \
    44             o.usCom         = OUTPUT_COM2;          \
    45             o.fLogging      = FALSE;                \
    46             o.fKernel       = KF_UNI;               \
    47             o.ulBuild       = ~0UL;                 \
    48             o.usVerMajor    = (unsigned short)~0;   \
    49             o.usVerMinor    = (unsigned short)~0;   \
    50             o.fPE           = FLAGS_PE_PE2LX;       \
    51             o.ulInfoLevel   = INFOLEVEL_QUIET;      \
    52             o.fElf          = FALSE;                \
    53             o.fScript       = TRUE;                 \
    54             o.fNoLoader     = FALSE;                \
    55             o.cbSwpHeapInit = CB_SWP_INIT;          \
    56             o.cbSwpHeapMax  = CB_SWP_MAX;           \
    57             o.cbResHeapInit = CB_RES_INIT;          \
    58             o.cbResHeapMax  = CB_RES_MAX;
    5959
    6060
     
    6363*******************************************************************************/
    6464/** Option struct */
     65#pragma pack(4)
    6566struct options
    6667{
    6768    /** @cat misc */
    68     BOOL        fQuiet;                 /* Quiet initialization. */
     69    ULONG       fQuiet;                 /* Quiet initialization. */
    6970
    7071    /** @cat logging options */
    7172    USHORT      usCom;                  /* Output port no. */
    72     BOOL        fLogging;               /* Logging. */
     73    ULONG       fLogging;               /* Logging. */
    7374
    7475    /** @cat kernel selection */
     
    7980
    8081    /** @cat Options affecting the generated LX executables */
    81     BOOL        fPE;                    /* Flags set the type of conversion. */
     82    ULONG       fPE;                    /* Flags set the type of conversion. */
    8283    ULONG       ulInfoLevel;            /* Pe2Lx InfoLevel. */
    8384
    8485    /** @cat Options affecting the generated ELF executables */
    85     BOOL        fElf;                   /* Elf flags. */
     86    ULONG       fElf;                   /* Elf flags. */
    8687
    8788    /** @cat Options affecting the script executables */
    88     BOOL        fScript;                /* Script flags. */
     89    ULONG       fScript;                /* Script flags. */
    8990
    9091    /** @cat Options affecting the script executables */
    91     BOOL        fNoLoader;              /* No loader stuff. */
     92    ULONG       fNoLoader;              /* No loader stuff. */
    9293
    9394    /** @cat Options affecting the heap. */
     
    9798    ULONG       cbResHeapMax;           /* Maxiumem residentheapsize. */
    9899};
     100#pragma pack()
     101
    99102
    100103/*******************************************************************************
    101104*   Global Variables                                                           *
    102105*******************************************************************************/
    103 extern struct options options;          /* defined in d32globals.c */
     106extern struct options options;      /* defined in d32globals.c */
     107#if defined(__IBMC__) || defined(__IBMCPP__)
     108    #pragma map( options , "_options"  )
     109#endif
    104110
    105111#endif
  • trunk/src/win32k/include/probkrnl.h

    r2838 r2898  
    1 /* $Id: probkrnl.h,v 1.10 2000-02-21 09:24:00 bird Exp $
     1/* $Id: probkrnl.h,v 1.11 2000-02-25 18:15:06 bird Exp $
    22 *
    33 * Include file for ProbKrnl.
     
    6161
    6262
     63/*
     64 * Database of kernel symbols.
     65 */
     66#pragma pack(1)
     67typedef struct
     68{
     69    unsigned short usBuild;             /* Build number */
     70    unsigned char  chType;              /* R, H, A */
     71    unsigned char  fSMP;                /* TRUE / FALSE */
     72    unsigned char  cObjects;            /* Count of objects */
     73    struct
     74    {
     75        unsigned char iObject;          /* Object number.  */
     76        unsigned long offObject;        /* offset into object of the symbol. */
     77    } aSyms[NBR_OF_KRNLIMPORTS];
     78
     79} KRNLDBENTRY, *PKRNLDBENTRY;
     80#pragma pack()
     81
     82
    6383
    6484/*******************************************************************************
     
    6787*******************************************************************************/
    6888extern IMPORTKRNLSYM _aImportTab[NBR_OF_KRNLIMPORTS]; /* 'aImportTab' in PrbKrnl.c */
    69 extern unsigned long int  _ulBuild;     /* 'ulBuild'         in PrbKrnl.c */
     89extern unsigned short int _usBuild;     /* 'ulBuild'         in PrbKrnl.c */
    7090extern unsigned short int _usVerMajor;  /* 'usVerMajor'      in PrbKrnl.c */
    7191extern unsigned short int _usVerMinor;  /* 'usVerMinor'      in PrbKrnl.c */
     92extern KRNLDBENTRY aKrnlSymDB[];        /* defined in symdb.c (for 16-bit usage) */
     93extern KRNLDBENTRY _aKrnlSymDB[];       /* defined in symdb.c (for 32-bit usage) */
    7294
    73 #ifdef INCL_16 /* 16-bit only */
     95
     96#if defined(INCL_16) && defined(MAX_DISKDD_CMD) /* 16-bit only */
    7497int ProbeKernel(PRPINITIN pReqPack);
    7598#endif
  • trunk/src/win32k/win32k.txt

    r1750 r2898  
    1 x.0 Win32k.sys - native OS/2 PE-"loader"
     12.3.0 Win32k.sys - native OS/2 PE-"loader"
    22----------------------------------------
    33
     
    55executables by implementing a Ring 0 on-the-fly converter. The converter is
    66Pe2Lx.exe. So, everything that works with Pe2Lx will probably work with
    7 win32k.sys. And vice versa, when Pe2lx don't make it, win32k.sys won't either.
     7win32k.sys. And vice versa, when Pe2lx can't handle it, win32k.sys won't either.
    88
    99You may wonder how you may run a Win32 program using a device driver. You
     
    2222
    2323
    24 x.1 WARNING
    25 -----------
     242.3.1 WARNING
     25-------------
    2626
    2727The Win32k.sys is quite alpha software and any bugs which haven't been found
     
    3737
    3838
    39 x.2 Requirements
    40 ----------------
     392.3.2 Requirements
     40------------------
    4141
    4242Win32k should work on any Warp 4 or Warp Server for e-business installations
    43 which Odin32 works on. It requires only one thing, a kernel symbol file. The
    44 kernel symbol is looked for in \OS2\PDPSI\PMDF\WARP4 and
    45 \OS2\PDPSI\PMDF\WARP45_U/S. All warp 4 and WE4eB installations should have
    46 those direcotries (we hope). It is updated when you install a new fixpack - so
    47 there is really nothing to worry about for the common user.
     43which Odin32 works on. It no longer requires a kernel file for non-debug
     44kernels. Win32k does now contain a "database" for the most recent retail
     45kernels. Currently this is:
     46    Warp 4 fp#5 -> fp#12
     47    Aurora GA
     48    Warp 3 fp#32-> fp#42
     49
     50If the running kernel is not found in the "database" or is a debug kernel
     51wink32.sys will look for symbolfiles as it allways has.
     52If you use the -s:<symfile> argument the given symbol file will be
     53investigated before the database is searched.
     54
     55NOTE! It hasn't been fully verified that all the different national fixpaks
     56have the same symbols as the us-english ones. Feedback on this issue is
     57appreciated.
    4858
    4959For those playing with debug-kernels, make sure that OS2KRNL.SYM is matching
    50 the running kernel, while this file too is investigated. (The complete list
    51 is found in src\Win32k\dev16\probkrnl.c,apszSym[] - odin32 source tree.)
     60the running kernel.
    5261
    5362
    54 x.2.1 Warp 3
    55 ------------
     632.3.2.1 Warp 3
     64--------------
    5665
    57 Win32k is not tested with Warp 3. It is supposed to work with Warp 3 provided
    58 that the os2krnl.sym file is present. Warp Server 4 have this, common Warp 3
    59 don't.
     66Win32k is not tested with Warp 3. It is _supposed_ to work with Warp 3
     67provided you are running fixpack 32 or later.
     68(Fixpack 32 + y2kclock.exe is required for Y2K readyness anyway so...)
    6069
    6170
    62 x.3 Installation
    63 ----------------
     712.3.3 Installation
     72------------------
    6473
    6574To use Win32k.sys you have to add the following line into your config.sys:
     
    6978directory.
    7079
    71 After doing this you'll have to reboot your machine to load the driver. During
     80After doing this, you'll have to reboot your machine to load the driver. During
    7281the boot process you will on a successful installation see some lines of
    7382technical info and finally a line saying:
    7483    'Win32k.sys succesfully initiated!'
    7584
    76 If you don't see the line above something is wrong!
     85If you don't see the line above something is wrong.
    7786
    7887
    79 x.4 Win32k parameters
    80 ---------------------
     882.3.4 Win32k parameters
     89-----------------------
     90
     91The Capitalized letters are the one which is tested for when identifying the
     92argument.
    8193
    8294There are some useful parameters for Win32k:
    83 -Q             Quiet driver initiation. (Default is verbose (-V) initiation.)
    84 -V             Verbose driver initiation. Default.
    85 -S:<filename>  Full path to the current OS/2 kernel symbole file.
    86 -K:<filename>  Full path to the running OS/2 kernel.
     95-Quited         Quiet driver initiation.
     96                Default: disabled (ie. -V)
     97
     98-Verbose        Verbose driver initiation.
     99                Default: enabled
     100
     101-S:<filename>   Full path to the current OS/2 kernel symbol file.
     102                When this is specified the given
     103                Default: symbol "database" and default locations are searched.
     104
     105Logging parameters:
     106-L<:E|:D>       Enables/Disables logging.
     107                Default: disabled.
     108
     109-C<1|2>         Which com-port to log to.
     110                Default: -C2
     111
     112-W<1|2|3|4>     Warning/info level for PE loader. (This is warnings and info
     113                which is published thru the com-port as logging information.)
     114                Default: -W0
     115
     116Heap parameters:
     117-HEAPMax:       Maximum swappable heap size in bytes.
     118                Default: 512KB
     119
     120-Heapinit:      Initial heapsize in bytes.
     121                Default: 16MB
     122
     123-RESHEAPMax:    Maximum resident heap size in bytes.
     124                Default: 256KB
     125
     126-Resheapinit:   Initial resident in bytes.
     127                Default: 16MB
     128
     129-SCript<:Y|:N>  Enable / disable UNIX script support.
     130                Default: Enabled.
     131
     132Obsolete:
     133-K:<filename> Ignored. Win32k scans the kernel image in memory!
    87134
    88135
    89 x.5 Rings - Ring 0 / Ring 3
    90 ---------------------------
     1362.3.5 Rings - Ring 0 / Ring 3
     137-----------------------------
    91138
    92139FYI. Ring 0 is the most priveleged level of execution in OS/2. The OS/2 kernel
    93 and device drivers execute at this level, while user applications executes in
     140and device drivers execute at this level, while user applications execute in
    94141Ring 3, the least priveleged executing level.
    95142
Note: See TracChangeset for help on using the changeset viewer.