Changeset 275 for trunk/src/pe2lx/pe.cpp


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

Edgar Buerkle's codepages changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.