Changeset 275 for trunk/src


Ignore:
Timestamp:
Jul 6, 1999, 10:50:12 AM (26 years ago)
Author:
sandervl
Message:

Edgar Buerkle's codepages changes

Location:
trunk/src/pe2lx
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/pe2lx/dialog.cpp

    r265 r275  
    1 /* $Id: dialog.cpp,v 1.6 1999-07-04 19:02:37 sandervl Exp $ */
     1/* $Id: dialog.cpp,v 1.7 1999-07-06 08:50:11 sandervl Exp $ */
    22
    33/*
     
    1616#define INCL_DOSPROCESS          /* DOS Process values       */
    1717#define INCL_DOSMISC             /* DOS Miscellanous values  */
     18#define INCL_DOSNLS
    1819#define INCL_WIN
    1920#define INCL_WINMLE
     
    4041static void ConvertCaption(ULONG style, char *caption);
    4142static int  ConvertFont(char *font, PRESPARAMS *dlgpparam, int fsize);
    42 static void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size);
     43static void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size, int cp);
    4344
    4445//******************************************************************************
     
    4849//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    4950//******************************************************************************
    50 void ShowDialog(int id, DialogBoxHeader *dhdr, int size)
     51void ShowDialog(int id, DialogBoxHeader *dhdr, int size, int cp)
    5152{
    5253 WINDLGTEMPLATEEX *windlgex = (WINDLGTEMPLATEEX *)dhdr;
     
    6364 ULONG        ctrlflag, winclass;
    6465 BOOL         fIconBmp;
     66 ULONG        ulCpSize, ulCP;
    6567
    6668  //First save original win32 resource
     
    6870
    6971  if(windlgex->wDlgVer == 1 && windlgex->wSignature == 0xFFFF) {
    70         ShowDialogEx(id, windlgex, size);
     72        ShowDialogEx(id, windlgex, size, cp);
    7173        return;
    7274  }
     
    7981  dlgcurdata = dlgdata;
    8082
    81   dlgt->codepage         = 437;
     83  if(cp == 0) {
     84        dlgt->codepage         = 437;
     85  }
     86  else
     87  {
     88        DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize);
     89        dlgt->codepage = ulCP;
     90  }
    8291  dlgt->offadlgti        = 14;
    8392  dlgt->fsTemplateStatus = 1;
     
    145154        }
    146155        else {
    147                 cout << "Menu namestring    : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd)) << endl;
     156                cout << "Menu namestring    : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd), cp) << endl;
    148157                ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR));
    149158        }
     
    159168        }
    160169        else {
    161                 szClass = UnicodeToAscii((WCHAR *)ptrArray);
     170                szClass = UnicodeToAscii((WCHAR *)ptrArray, cp);
    162171                cout << "Class Name            : " << szClass << endl;
    163172
     
    181190  }
    182191  else {
    183         ctrltext = UnicodeToAscii((WCHAR *)(ptrArray));
     192        ctrltext = UnicodeToAscii((WCHAR *)(ptrArray), cp);
    184193        cout << "Title                : " << ctrltext << endl;
    185194        ctrldata = (ControlData *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD));
     
    199208  if(dhdr->lStyle & DS_SETFONT) {
    200209        fhdr = (FontHeader *)ctrldata;
    201         font = UnicodeToAscii(fhdr->szFontName);
     210        font = UnicodeToAscii(fhdr->szFontName, cp);
    202211        cout << "Font Point Size      : " << fhdr->wPointSize << endl;
    203212        cout << "Font Name            : " << font << endl;
     
    271280        }
    272281        else {
    273                 szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId);
     282                szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId, cp);
    274283                cout << "Class Name            : " << szClass << endl;
    275284                szCaption = (WCHAR *)((int)ctrldata + sizeof(ControlData) + strlen(szClass)*2);
     
    289298        }
    290299        else {  //Handle Caption
    291                 ctrltext = UnicodeToAscii(szCaption);
     300                ctrltext = UnicodeToAscii(szCaption, cp);
    292301                //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes)
    293302                ConvertCaption(winclass, ctrltext);
     
    312321                        }
    313322                }
    314                 cout << "Text                  : " << UnicodeToAscii(szCaption) << endl;
     323                cout << "Text                  : " << UnicodeToAscii(szCaption, cp) << endl;
    315324                szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD));
    316325        }
     
    328337//******************************************************************************
    329338//******************************************************************************
    330 void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size)
     339void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size, int cp)
    331340{
    332341 DLGTEMPLATE *dlgt;
     
    342351 ULONG        ctrlflag, winclass;
    343352 BOOL         fIconBmp;
     353 ULONG        ulCpSize, ulCP;
    344354
    345355  //should be enough
     
    350360  dlgcurdata = dlgdata;
    351361
    352   dlgt->codepage         = 437;
     362  if(cp == 0) {
     363        dlgt->codepage         = 437;
     364  }
     365  else
     366  {
     367        DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize);
     368        dlgt->codepage = ulCP;
     369  }
    353370  dlgt->offadlgti        = 14;
    354371  dlgt->fsTemplateStatus = 1;
     
    412429        }
    413430        else {
    414                 cout << "Menu namestring    : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd)) << endl;
     431                cout << "Menu namestring    : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd, cp)) << endl;
    415432                ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR));
    416433        }
     
    448465  }
    449466  else {
    450         ctrltext = UnicodeToAscii((WCHAR *)(ptrArray));
     467        ctrltext = UnicodeToAscii((WCHAR *)(ptrArray), cp);
    451468        cout << "Title                : " << ctrltext << endl;
    452469        ctrldata = (WINDLGITEMTEMPLATEEX *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD));
     
    467484  if(dhdr->lStyle & DS_SETFONT) {
    468485        fhdr = (FontHeaderEx *)ctrldata;
    469         font = UnicodeToAscii(fhdr->szFontName);
     486        font = UnicodeToAscii(fhdr->szFontName, cp);
    470487        cout << "Font Point Size      : " << fhdr->wPointSize << endl;
    471488        cout << "Font Name            : " << font << endl;
     
    536553        }
    537554        else {
    538                 szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId);
     555                szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId, cp);
    539556                cout << "Class Name            : " << szClass << endl;
    540557                szCaption = (WCHAR *)((int)ctrldata + sizeof(WINDLGITEMTEMPLATEEX) + strlen(szClass)*2);
     
    551568        }
    552569        else {  //Handle Caption
    553                 ctrltext = UnicodeToAscii(szCaption);
     570                ctrltext = UnicodeToAscii(szCaption, cp);
    554571                //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes)
    555572                ConvertCaption(winclass, ctrltext);
     
    574591                        }
    575592                }
    576                 cout << "Text                  : " << UnicodeToAscii(szCaption) << endl;
     593                cout << "Text                  : " << UnicodeToAscii(szCaption, cp) << endl;
    577594                szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD));
    578595        }
  • trunk/src/pe2lx/dialog.h

    r97 r275  
    1 /* $Id: dialog.h,v 1.3 1999-06-10 17:08:53 phaller Exp $ */
     1/* $Id: dialog.h,v 1.4 1999-07-06 08:50:11 sandervl Exp $ */
    22
    33/*
     
    102102#pragma pack()
    103103
    104 void ShowDialog(int id, DialogBoxHeader *dhdr, int size);
     104void ShowDialog(int id, DialogBoxHeader *dhdr, int size, int cp=0);
    105105
    106106
  • trunk/src/pe2lx/menu.cpp

    r97 r275  
    1 /* $Id: menu.cpp,v 1.3 1999-06-10 17:08:54 phaller Exp $ */
     1/* $Id: menu.cpp,v 1.4 1999-07-06 08:50:11 sandervl Exp $ */
    22
    33/*
     
    1414#define INCL_DOSPROCESS          /* DOS Process values       */
    1515#define INCL_DOSMISC             /* DOS Miscellanous values  */
     16#define INCL_DOSNLS
    1617#define INCL_WIN
    1718#include <os2.h>
     
    2728#include "misc.h"
    2829
    29 static int  ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size);
    30 static int  ProcessMenuItem(NormalMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size);
     30static int  ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp);
     31static int  ProcessMenuItem(NormalMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp);
    3132static void menustrcpy(char *dest, char *src);
    3233//******************************************************************************
    3334//******************************************************************************
    34 void ShowMenu(int id, MenuHeader *menu, int size)
     35void ShowMenu(int id, MenuHeader *menu, int size, int cp)
    3536{
    3637  PopupMenuItem  *popupitem = (PopupMenuItem *)((char *)menu + sizeof(MenuHeader));
     
    3940  MTI_OS2 *menuitem;
    4041  int newsize;
     42  ULONG   ulCpSize, ulCP;
    4143
    4244  //First save original win32 resource
     
    4547  os2menu           = (MT_OS2 *)malloc(size*4); //should always be sufficient
    4648  os2menu->len      = sizeof(MT_OS2) - sizeof(MTI_OS2);
    47   os2menu->codepage = 437;
     49  if(cp == 0)
     50    os2menu->codepage         = 437;
     51  else
     52  {
     53    DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize);
     54    os2menu->codepage = ulCP;
     55  }
    4856  os2menu->reserved = 4;
    4957  os2menu->cMti     = 0;
     
    5361    if(popupitem->fItemFlags & POPUP) {
    5462        cout << "POPUP ";
    55         newsize = ProcessSubMenu(popupitem, os2menu, menuitem, size);
    56     }
    57     else    newsize = ProcessMenuItem(normalitem, os2menu, menuitem, size);
     63        newsize = ProcessSubMenu(popupitem, os2menu, menuitem, size, cp);
     64    }
     65    else    newsize = ProcessMenuItem(normalitem, os2menu, menuitem, size, cp);
    5866
    5967    if(popupitem->fItemFlags & ENDMENU) break;
     
    7078//******************************************************************************
    7179//******************************************************************************
    72 static int ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size)
     80static int ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp)
    7381{
    7482NormalMenuItem *normalitem;
     
    119127  else {
    120128    len = (UniStrlen(popupitem->szItemText)+1)*2;
    121     cout << UnicodeToAscii(popupitem->szItemText) << endl;
    122     menustrcpy(menuitem->c, UnicodeToAscii(popupitem->szItemText));
     129    cout << UnicodeToAscii(popupitem->szItemText, cp) << endl;
     130    menustrcpy(menuitem->c, UnicodeToAscii(popupitem->szItemText, cp));
    123131  }
    124132  os2menu->len += sizeof(MTI_OS2);
     
    144152        if(normalitem->fItemFlags & POPUP) {
    145153            cout << "POPUP ";
    146             newsize = ProcessSubMenu((PopupMenuItem *)normalitem, submenu, menuitem, size);
     154            newsize = ProcessSubMenu((PopupMenuItem *)normalitem, submenu, menuitem, size, cp);
    147155        }
    148         else    newsize = ProcessMenuItem(normalitem, submenu, menuitem, size);
     156        else    newsize = ProcessMenuItem(normalitem, submenu, menuitem, size, cp);
    149157
    150158                menuitem = (MTI_OS2 *)((int)submenu + submenu->len);
     
    161169//******************************************************************************
    162170//******************************************************************************
    163 static int ProcessMenuItem(NormalMenuItem *normalitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size)
     171static int ProcessMenuItem(NormalMenuItem *normalitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp)
    164172{
    165173WCHAR          *menustring;
     
    226234    }
    227235    else {
    228         cout << UnicodeToAscii(normalitem->szItemText) << endl;
    229         menustrcpy(menuitem->c, UnicodeToAscii(normalitem->szItemText));
     236        cout << UnicodeToAscii(normalitem->szItemText, cp) << endl;
     237        menustrcpy(menuitem->c, UnicodeToAscii(normalitem->szItemText, cp));
    230238    }
    231239  }
  • trunk/src/pe2lx/menu.h

    r97 r275  
    1 /* $Id: menu.h,v 1.3 1999-06-10 17:08:54 phaller Exp $ */
     1/* $Id: menu.h,v 1.4 1999-07-06 08:50:11 sandervl Exp $ */
    22
    33/*
     
    4747#pragma pack() /*PLF Sat  97-06-21 22:17:31*/
    4848
    49 void ShowMenu(int id, MenuHeader *menu, int size);
     49void ShowMenu(int id, MenuHeader *menu, int size, int cp = 0);
    5050
    5151#endif
  • trunk/src/pe2lx/misc.cpp

    r272 r275  
    1 /* $Id: misc.cpp,v 1.4 1999-07-05 12:36:12 sandervl Exp $ */
     1/* $Id: misc.cpp,v 1.5 1999-07-06 08:50:11 sandervl Exp $ */
    22
    33/*
     
    183183    }
    184184  }
     185  else  return FALSE;
     186
    185187  return TRUE;
    186188}
     
    194196  if(prepareCP(cp) == TRUE && CodePage > 0)
    195197    while(*str != 0)
    196       *str++ = transCP[*str];
    197 }
    198 //******************************************************************************
    199 //******************************************************************************
     198    {
     199      *str = transCP[*str];
     200      str++;
     201    }
     202}
     203//******************************************************************************
     204//******************************************************************************
  • trunk/src/pe2lx/pe.cpp

    r141 r275  
    1 /* $Id: pe.cpp,v 1.4 1999-06-21 01:15:40 buerkle Exp $ */
     1/* $Id: pe.cpp,v 1.5 1999-07-06 08:50:11 sandervl Exp $ */
    22
    33/*
     
    5858/**/
    5959
    60 
     60BOOL fUseCodePage = FALSE;
     61int  WinCodePage;
     62 
    6163char INFO_BANNER[] =
    62 "Usage: PE2LX winfile \n\
    63        OR\n\
    64        PE2LX winfile os2file\n";
     64"Usage: PE2LX winfile [os2file] [-cp]\n\
     65        OR\n\
     66        PE2LX winfile os2file [-cp]\n";
    6567
    6668char *ResTypes[MAX_RES] =
     
    9597PIMAGE_SECTION_HEADER    psh;
    9698int  nSections;
    97 
    98   if(argc != 2 && argc != 3) {
     99char *winfile=NULL, *os2file=NULL;
     100
     101  if(argc < 2 || argc > 4) {
    99102        cout << "pe2lx v0.0." << PE2LX_VERSION << "alpha"<< endl;
    100103        cout << INFO_BANNER << endl;
    101104        return(0);
    102105  }
    103 
    104   rc = DosOpen(argv[1],                        /* File path name */
     106  for(i=1;i<argc;i++)
     107  {
     108      if(!stricmp(argv[i], "/CP") || !stricmp(argv[i], "-CP"))
     109        fUseCodePage = TRUE;
     110      else if(winfile == NULL)
     111        winfile = argv[i];
     112      else if(os2file == NULL)
     113        os2file = argv[i];
     114  }
     115
     116  rc = DosOpen(winfile,                        /* File path name */
    105117               &win32handle,                   /* File handle */
    106118               &ulAction,                      /* Action taken */
     
    163175        return(1);
    164176  }
    165   if(argc == 2) {
     177  if(os2file == NULL) {
    166178        //ok, it's a PE file, so we can safely make a backup copy
    167         char *newfile = (char *)malloc(strlen(argv[1])+1);
    168         strcpy(newfile, argv[1]);
     179        char *newfile = (char *)malloc(strlen(winfile)+1);
     180        strcpy(newfile, winfile);
    169181        newfile[strlen(newfile)-1]++;
    170182        //save copy of win32 exe/dll (exe->exf, dll->dlk)
    171         rc = DosMove(argv[1], newfile);
     183        rc = DosMove(winfile, newfile);
    172184        if(rc) {
    173185                cout << "Unable to save original win32 file to " << newfile << "(" << rc << ")" << endl;
     
    214226  ////  OS2Exe.SetStackSize(oh.SizeOfStackCommit);
    215227  OS2Exe.SetStackSize(max(oh.SizeOfStackCommit, oh.SizeOfStackReserve));
    216   if(argc == 2)
    217         OS2Exe.SetModuleName(argv[1]);
    218   else  OS2Exe.SetModuleName(argv[2]);
     228  if(os2file == NULL)
     229        OS2Exe.SetModuleName(winfile);
     230  else  OS2Exe.SetModuleName(os2file);
    219231
    220232  nSections = NR_SECTIONS(win32file);
     
    557569  }
    558570  OS2Exe.SaveConvertedNames();
    559   if(argc == 2)
    560         OS2Exe.SaveNewExeFile(argv[1]);
    561   else  OS2Exe.SaveNewExeFile(argv[2]);
     571  if(os2file == NULL)
     572        OS2Exe.SaveNewExeFile(winfile);
     573  else  OS2Exe.SaveNewExeFile(os2file);
    562574
    563575  return(0);
     
    617629                cout << "Resource Data RVA " << hex(pData->OffsetToData) << endl;
    618630                cout << "Resource Data VA  " << hex(VirtualAddress) << endl;
    619                 cout << "Resource Codepage " << pData->CodePage << endl;
     631                if(fUseCodePage == TRUE)
     632                        WinCodePage = pData->CodePage;
     633                else    WinCodePage = 0;
     634 
    620635                if(pData->Size) {//winamp17 winzip archive has resource with size 0
    621636                 switch(type) {
    622637                        case NTRT_MENU:
    623                                 ShowMenu(id, (MenuHeader *)((char *)prdRoot + pData->OffsetToData - VirtualAddress), pData->Size);
     638                                ShowMenu(id, (MenuHeader *)((char *)prdRoot + pData->OffsetToData - VirtualAddress), pData->Size, WinCodePage);
    624639                                break;
    625640                        case NTRT_ICON:
     
    640655                                break;
    641656                        case NTRT_DIALOG:
    642                                 ShowDialog(id, (DialogBoxHeader *)((char *)prdRoot + pData->OffsetToData - VirtualAddress), pData->Size);
     657                                ShowDialog(id, (DialogBoxHeader *)((char *)prdRoot + pData->OffsetToData - VirtualAddress), pData->Size, WinCodePage);
    643658                                break;
    644659                        case NTRT_VERSION:
     
    655670//lower 4 bits are an index into the string table
    656671//Best solution is to split the strings up and store them as RCDATA
    657                                 ShowStrings(id, (char *)((char *)prdRoot + pData->OffsetToData - VirtualAddress), pData->Size);
     672                                ShowStrings(id, (char *)((char *)prdRoot + pData->OffsetToData - VirtualAddress), pData->Size, WinCodePage);
    658673                                break;
    659674                        case NTRT_ACCELERATORS:
  • trunk/src/pe2lx/strings.cpp

    r97 r275  
    1 /* $Id: strings.cpp,v 1.3 1999-06-10 17:08:55 phaller Exp $ */
     1/* $Id: strings.cpp,v 1.4 1999-07-06 08:50:12 sandervl Exp $ */
    22
    33/*
     
    1414#define INCL_DOSPROCESS          /* DOS Process values       */
    1515#define INCL_DOSMISC             /* DOS Miscellanous values  */
     16#define INCL_DOSNLS
    1617#define INCL_WIN
    1718#include <os2.h>
     
    3233//whereas windows strings can be up to 64k bytes long
    3334//******************************************************************************
    34 void ShowStrings(int id, char *data, int size)
     35void ShowStrings(int id, char *data, int size, int cp)
    3536{
    3637USHORT *len;
  • trunk/src/pe2lx/strings.h

    r97 r275  
    1 /* $Id: strings.h,v 1.3 1999-06-10 17:08:55 phaller Exp $ */
     1/* $Id: strings.h,v 1.4 1999-07-06 08:50:12 sandervl Exp $ */
    22
    33/*
     
    1313#define __STRING_H__
    1414
    15 void ShowStrings(int id, char *data, int size);
     15void ShowStrings(int id, char *data, int size, int cp=0);
    1616
    1717#endif
Note: See TracChangeset for help on using the changeset viewer.