Ignore:
Timestamp:
Oct 19, 2001, 2:07:30 AM (24 years ago)
Author:
bird
Message:

Upcase dhcalls.lib!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/kKrnlLib/tools/libconv.c

    r6628 r7117  
    1 /* $Id: libconv.c,v 1.1 2001-09-02 04:35:58 bird Exp $
     1/* $Id: libconv.c,v 1.2 2001-10-19 00:07:30 bird Exp $
    22 *
    33 * Very simple OMF/LIB dumper.
     
    99 */
    1010
     11/*******************************************************************************
     12*   Defined Constants And Macros                                               *
     13*******************************************************************************/
     14/**
     15 * Upcases a char.
     16 */
     17#define upcase(ch) ((ch) >= 'a' && (ch) <= 'z' ?  (char)((ch) - ('a' - 'A')) : (ch))
     18
     19
     20/**
     21 * Access macro for reading index value.
     22 * @return  index value. 0 - 32768.
     23 * @param   pch     Pointer to the first byte of the index.
     24 */
     25#define INDEX_VALUE(pch)    ( *(char*)(pch) & 0x80 \
     26                                ? (*(char *)(pch) & 0x7f) * 0x100 + *((char*)(pch)+1) \
     27                                : *((char*)(pch)) )
     28
     29/**
     30 * Access macro for determin the size of an index.
     31 * @return  index size in bytes. 1 or 2.
     32 * @param   pch     Pointer to the first byte of the index.
     33 */
     34#define INDEX_SIZE(pch)     ( *(char*)(pch) & 0x80 ? 2 : 1 )
     35
     36
     37/**
     38 * Get a byte at a given offset.
     39 * @return  byte at given offset.
     40 * @param   pch     Pointer to address relativ to.
     41 * @param   off     Byte offset from pch.
     42 */
     43#define OMF_BYTE(pch, off)  ( *((char*)(pch) + (int)(off)) )
     44
     45
     46/**
     47 * Get a word (unsigned short) at a given offset.
     48 * @return  word (unsigned short) at given offset.
     49 * @param   pch     Pointer to address relativ to.
     50 * @param   off     Byte offset from pch.
     51 */
     52#define OMF_WORD(pch, off)  ( *(unsigned short*)((char*)(pch) + (int)(off)) )
     53
     54
     55/**
     56 * Get a dword (unsigned long) at a given offset.
     57 * @return  dword (unsigned long) at given offset.
     58 * @param   pch     Pointer to address relativ to.
     59 * @param   off     Byte offset from pch.
     60 */
     61#define OMF_DWORD(pch, off)  ( *(unsigned long*)((char*)(pch) + (int)(off)) )
     62
    1163
    1264/*@Header***********************************************************************
     
    2072#include "include\omf.h"
    2173
    22 int fCodeToCode16 = 0;
     74int fUpcase = 0;
    2375int fRemoveExtra = 0;
    2476
     
    3688    int argi = 1;
    3789
    38     if (argc == 4)
     90    if (argc >= 4)
    3991    {
    4092        argi = 2;
     
    61113    psz = strrchr(pszFilename, '\\');
    62114    if (psz)
    63         fCodeToCode16 = stricmp(psz, "\\dhcalls.lib") == 0;
     115        fUpcase = stricmp(psz, "\\dhcalls.lib") == 0;
    64116
    65117    phFile = fopen(pszFilename, "rb");
     
    186238            cbRecord = *((unsigned short*)((int)pvRecord+1)) + 3;
    187239            *((char*)pvRecord + cbRecord - 1) = 0;
     240            if (fUpcase)
     241            {
     242                char *pch = (char*)pvRecord;
     243                char *pch1, *pch2, *pchEnd;
     244                pch1 = pch + 3 + INDEX_SIZE(pch + 3);
     245                pch2 = pch1 + INDEX_SIZE(pch1);
     246                if (!*pch1)
     247                    pch2 += 2;
     248
     249                for (pchEnd = pch + pch[1]; pch2 + 1 < pchEnd; )
     250                {
     251                    int i;
     252                    for (i = 1; i <= *pch2; i++)
     253                        pch2[i] = upcase(pch2[i]);
     254                    pch2 += *pch2 + 1 + (pch[0] & 0x1 ? 4 : 2);
     255                    pch2 += INDEX_SIZE(pch2);
     256                }
     257            }
    188258            break;
    189259        }
Note: See TracChangeset for help on using the changeset viewer.