Ignore:
Timestamp:
Feb 20, 2000, 5:27:24 AM (26 years ago)
Author:
bird
Message:

16-bit imports and import of global variables.
(But there are some problems left)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/dev16/probkrnl.c

    r2831 r2832  
    1 /* $Id: probkrnl.c,v 1.11 2000-02-19 23:51:59 bird Exp $
     1/* $Id: probkrnl.c,v 1.12 2000-02-20 04:27:23 bird Exp $
    22 *
    33 * Description:   Autoprobes the os2krnl file and os2krnl[*].sym files.
     
    8989 */
    9090IMPORTKRNLSYM aImportTab[NBR_OF_KRNLIMPORTS] =
    91 {/* iFound     cchName                  offObject    usSel        */
    92  /*      iObject      achName                 ulAddress  fType    */
    93     {FALSE, -1,  8, "_ldrRead",             -1,  -1, -1, EPT_PROC32},        /* 0 */
    94     {FALSE, -1,  8, "_ldrOpen",             -1,  -1, -1, EPT_PROC32},        /* 1 */
    95     {FALSE, -1,  9, "_ldrClose",            -1,  -1, -1, EPT_PROC32},        /* 2 */
    96     {FALSE, -1, 12, "_LDRQAppType",         -1,  -1, -1, EPT_PROCIMPORT32},  /* 3 */ /* to be removed? */
    97     {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1,  -1, -1, EPT_PROC32},        /* 4 */
    98     {FALSE, -1, 10, "_IOSftOpen",           -1,  -1, -1, EPT_PROCIMPORT32},  /* 5 */
    99     {FALSE, -1, 11, "_IOSftClose",          -1,  -1, -1, EPT_PROCIMPORT32},  /* 6 */
    100     {FALSE, -1, 15, "_IOSftTransPath",      -1,  -1, -1, EPT_PROCIMPORT32},  /* 7 */
    101     {FALSE, -1, 12, "_IOSftReadAt",         -1,  -1, -1, EPT_PROCIMPORT32},  /* 8 */
    102     {FALSE, -1, 13, "_IOSftWriteAt",        -1,  -1, -1, EPT_PROCIMPORT32},  /* 9 */
    103     {FALSE, -1, 12, "_SftFileSize",         -1,  -1, -1, EPT_PROCIMPORT32},  /* 10 */
    104     {FALSE, -1, 11, "_VMAllocMem",          -1,  -1, -1, EPT_PROCIMPORT32},  /* 11 */
    105     {FALSE, -1, 11, "_VMGetOwner",          -1,  -1, -1, EPT_PROCIMPORT32},  /* 12 */
    106     {FALSE, -1, 11, "g_tkExecPgm",          -1,  -1, -1, EPT_PROC32},        /* 13 */
    107     {FALSE, -1, 11, "f_FuStrLenZ",          -1,  -1, -1, EPT_PROCIMPORT16},  /* 14 */
    108     {FALSE, -1,  8, "f_FuBuff",             -1,  -1, -1, EPT_PROCIMPORT16}   /* 15 */
     91{/* iFound     cchName                  offObject    usSel     fType    */
     92 /*      iObject      achName                 ulAddress  cProlog        */
     93    {FALSE, -1,  8, "_ldrRead",             -1,  -1,  -1,  -1, EPT_PROC32},        /* 0 */
     94    {FALSE, -1,  8, "_ldrOpen",             -1,  -1,  -1,  -1, EPT_PROC32},        /* 1 */
     95    {FALSE, -1,  9, "_ldrClose",            -1,  -1,  -1,  -1, EPT_PROC32},        /* 2 */
     96    {FALSE, -1, 12, "_LDRQAppType",         -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 3 */ /* to be removed? */
     97    {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1,  -1,  -1,  -1, EPT_PROC32},        /* 4 */
     98    {FALSE, -1, 10, "_IOSftOpen",           -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 5 */
     99    {FALSE, -1, 11, "_IOSftClose",          -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 6 */
     100    {FALSE, -1, 15, "_IOSftTransPath",      -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 7 */
     101    {FALSE, -1, 12, "_IOSftReadAt",         -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 8 */
     102    {FALSE, -1, 13, "_IOSftWriteAt",        -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 9 */
     103    {FALSE, -1, 12, "_SftFileSize",         -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 10 */
     104    {FALSE, -1, 11, "_VMAllocMem",          -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 11 */
     105    {FALSE, -1, 11, "_VMGetOwner",          -1,  -1,  -1,  -1, EPT_PROCIMPORT32},  /* 12 */
     106    {FALSE, -1, 11, "g_tkExecPgm",          -1,  -1,  -1,  -1, EPT_PROC32},        /* 13 */
     107    {FALSE, -1, 11, "f_FuStrLenZ",          -1,  -1,  -1,  -1, EPT_PROCIMPORT16},  /* 14 */
     108    {FALSE, -1,  8, "f_FuBuff",             -1,  -1,  -1,  -1, EPT_PROCIMPORT16}   /* 15 */
    109109/*    {FALSE, -1, 11, "",          -1,  -1, -1, EPT_PROCIMPORT16} */ /* 16 */
    110110};
     
    157157*   Internal Functions                                                         *
    158158*******************************************************************************/
    159 static void  kmemcpy(char *p1, const char *p2, int len);
    160 static int   kstrcmp(const char *p1, const char *p2);
    161 static char *kstrstr(const char *psz1, const char *psz2);
    162 static int   kstrncmp(const char *p1, const char *p2, int len);
    163 static int   kstrlen(const char *p);
    164 static HFILE fopen(char * filename, char * ignored);
    165 static int   fread(void * pBuffer, USHORT i1, USHORT i2,  HFILE hfile);
    166 static int   fseek(HFILE hfile, signed long off, int org);
     159static HFILE    fopen(const char * pszFilename, const char * pszIgnored);
     160static int      fread(void * pvBuffer, USHORT cbBlock, USHORT cBlock,  HFILE hFile);
     161static int      fseek(HFILE hfile, signed long off, int iOrg);
    167162static unsigned long fsize(HFILE hFile);
    168 static void  puts(char *psz);
    169 static int   kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen);
    170 
    171 static int   VerifyPrologs(void);
    172 static int   ProbeSymFile(char *pszFilename);
    173 static int   VerifyKernelVer(void);
    174 static int   ReadOS2Krnl(char *filename);
    175 static int   ReadOS2Krnl2(HFILE krnl, unsigned long  cbKrnl);
    176 static int   GetKernelOTEs(void);
    177 
    178 static void  ShowDecNumber(unsigned long n);
    179 static void  ShowHexNumber(unsigned long int n);
    180 static void  ShowResult(int rc, int iSym);
     163static void     puts(char *psz);
     164
     165static void     kmemcpy(char *psz1, const char *psz2, int cch);
     166static char *   kstrstr(const char *psz1, const char *psz2);
     167static int      kstrcmp(const char *psz1, const char *psz2);
     168static int      kstrncmp(const char *psz1, const char *psz2, int cch);
     169static int      kstrlen(const char *psz);
     170static int      kargncpy(char *pszTarget, const char *pszArg, unsigned cchMaxlen);
     171
     172static int      VerifyPrologs(void);
     173static int      ProbeSymFile(char *pszFilename);
     174static int      VerifyKernelVer(void);
     175static int      ReadOS2Krnl(char *pszFilename);
     176static int      ReadOS2Krnl2(HFILE hKrnl, unsigned long  cbKrnl);
     177static int      GetKernelOTEs(void);
     178
     179static void     ShowDecNumber(unsigned long ul);
     180static void     ShowHexNumber(unsigned long ul);
     181static void     ShowResult(int rc, int iSym);
    181182
    182183
     
    189190/**
    190191 * Quick implementation of fopen.
    191  * @param    filename   name of file to open (sz)
    192  * @param    ignored    whatever - it is ignored
     192 * @param    pszFilename   name of file to open (sz)
     193 * @param    pszIgnored    whatever - it is ignored
    193194 * @return   Handle to file. (not pointer to a FILE stream as in C-library)
    194195 * @remark   binary and readonly is assumed!
    195196 */
    196 static HFILE fopen(char * filename, char * ignored)
     197static HFILE fopen(const char * pszFilename, const char * pszIgnored)
    197198{
    198199    HFILE   hFile = 0;
     
    201202
    202203    rc = DosOpen(
    203                 filename,
    204                 &hFile,
    205                 &Action,
    206                 0,
    207                 FILE_NORMAL,
    208                 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
    209                 OPEN_SHARE_DENYNONE + OPEN_ACCESS_READONLY,
    210                 NULL
    211                 );
    212 
    213     ignored = ignored;
     204        (char*)pszFilename,
     205        &hFile,
     206        &Action,
     207        0,
     208        FILE_NORMAL,
     209        OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
     210        OPEN_SHARE_DENYNONE + OPEN_ACCESS_READONLY,
     211        NULL);
     212
     213    pszIgnored = pszIgnored;
    214214    return hFile;
    215215}
     
    219219 * fread emulation
    220220 * @returns   Number of blocks read.
    221  * @param     pBuffer  Buffer to read into
    222  * @param     i1       blocksize
    223  * @param     i2       block count
    224  * @param     hFile    Handle to file (HFILE)
    225  */
    226 static int fread(void * pBuffer, USHORT cbBlock, USHORT cBlock,  HFILE hFile)
     221 * @param     pvBuffer  Buffer to read into
     222 * @param     cbBlock   Blocksize
     223 * @param     cBlock    Block count
     224 * @param     hFile     Handle to file (HFILE)
     225 */
     226static int fread(void * pvBuffer, USHORT cbBlock, USHORT cBlock,  HFILE hFile)
    227227{
    228228    USHORT  ulRead;
    229229    USHORT  rc;
    230230
    231     rc = DosRead(hFile, pBuffer, (USHORT)(cbBlock*cBlock), &ulRead);
     231    rc = DosRead(hFile, pvBuffer, (USHORT)(cbBlock*cBlock), &ulRead);
    232232    if (rc == 0)
    233233        rc = (USHORT)cBlock;
     
    246246 * @param     org     origin
    247247 */
    248 static int fseek(HFILE hFile, signed long off, int org)
    249 {
    250     USHORT rc;
    251     ULONG ole;
    252 
    253     rc = DosChgFilePtr(hFile, off, org, &ole);
    254 
    255     return rc;
     248static int fseek(HFILE hFile, signed long off, int iOrg)
     249{
     250    ULONG  ul;
     251    return  (int)DosChgFilePtr(hFile, off, iOrg, &ul);
    256252}
    257253
     
    285281/**
    286282 * kmemcpy - memory copy - slow!
    287  * @param     p1  target
    288  * @param     p2  source
    289  * @param     len length
    290  */
    291 static void kmemcpy(char * p1, const char * p2, int len)
    292 {
    293     while (len != 0)
    294     {
    295         *p1 = *p2;
    296         p1++;
    297         p2++;
    298         len--;
    299     }
    300 }
    301 
    302 #if 0 /* not in use */
    303 /**
    304  * kstrcmp - String compare
    305  * @returns   0 - equal else !0
    306  * @param     p1  String 1
    307  * @param     p2  String 2
    308  */
    309 static int kstrcmp(const char * p1, const char * p2)
    310 {
    311     while (*p1 == *p2 && *p1 != '\0' && *p2 != '\0')
    312     {
    313         p1++;
    314         p2++;
    315     }
    316     return *p1 - *p2;
    317 }
    318 #endif
    319 
     283 * @param     psz1  target
     284 * @param     psz2  source
     285 * @param     cch length
     286 */
     287static void     kmemcpy(char *psz1, const char *psz2, int cch)
     288{
     289    while (cch-- != 0)
     290        *psz1++ = *psz2++;
     291}
    320292
    321293
     
    347319
    348320
     321#if 0 /* not in use */
     322/**
     323 * kstrcmp - String compare
     324 * @returns   0 - equal else !0
     325 * @param     psz1  String 1
     326 * @param     psz2  String 2
     327 */
     328static int      kstrcmp(const char *psz1, const char *psz2);
     329{
     330    while (*psz1 == *psz2 && *psz1 != '\0' && *psz2 != '\0')
     331    {
     332        psz1++;
     333        psz2++;
     334    }
     335    return *psz1 - *psz2;
     336}
     337#endif
     338
     339
    349340
    350341/**
    351342 * kstrncmp - String 'n' compare.
    352  * @returns
    353343 * @returns   0 - equal else !0
    354344 * @param     p1  String 1
     
    356346 * @param     len length
    357347 */
    358 static int kstrncmp(const char * p1, const char * p2, int len)
     348static int      kstrncmp(register const char *psz1, register const char *psz2, int cch)
    359349{
    360350    int i = 0;
    361     while (i < len && *p1 == *p2 && *p1 != '\0' && *p2 != '\0')
    362     {
    363         p1++;
    364         p2++;
     351    while (i < cch && *psz1 == *psz2 && *psz1 != '\0' && *psz2 != '\0')
     352    {
     353        psz1++;
     354        psz2++;
    365355        i++;
    366356    }
    367357
    368     return i - len;
     358    return i - cch;
    369359}
    370360
     
    377367 * @author    knut st. osmundsen
    378368 */
    379 static int kstrlen(const char * psz)
    380 {
    381     int cch = 0;
    382     while (psz[cch] != '\0')
     369static int kstrlen(register const char * psz)
     370{
     371    register int cch = 0;
     372    while (*psz++ != '\0')
    383373        cch++;
    384374    return cch;
     
    508498        return -50;
    509499    }
     500    dprintf(("\nSuccessfully opened symbolfile: %s\n", pszFilename));
    510501
    511502
     
    525516    dprintf(("*Module name: %s\n", achBuffer));
    526517    dprintf(("*Segments: %d\n*MaxSymbolLength: %d\n", MapDef.cSegs, MapDef.cbMaxSym));
    527     dprintf(("*ppNextMap: 0x%x\n\n", MapDef.ppNextMap ));
     518    dprintf(("*ppNextMap: 0x%x\n", MapDef.ppNextMap ));
    528519
    529520
     
    765756 * @returns   0 on success.
    766757 *            errorcodes on failure. (-1 >= rc >= -14)
    767  * @param     hKrnl
    768  * @param
    769  * @equiv
    770  * @time
    771  * @sketch
    772  * @status
     758 * @param     hKrnl   Handle to the kernel file.
     759 * @param     cbKrnl  Size of the kernel file.
    773760 * @author    knut st. osmundsen
    774  * @remark
    775761 */
    776762static int ReadOS2Krnl2(HFILE hKrnl, unsigned long  cbKrnl)
     
    784770
    785771    /* find bldlevel string - "@#IBM:14.020#@  IBM OS/2 Kernel - 14.020F" */
    786     cbKrnl = fsize(hKrnl);
    787772    if (fseek(hKrnl, 0, SEEK_SET))
    788773        return -2;
Note: See TracChangeset for help on using the changeset viewer.