Changeset 275 for trunk/src/pe2lx/pe.cpp
- Timestamp:
- Jul 6, 1999, 10:50:12 AM (26 years ago)
- 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 buerkleExp $ */1 /* $Id: pe.cpp,v 1.5 1999-07-06 08:50:11 sandervl Exp $ */ 2 2 3 3 /* … … 58 58 /**/ 59 59 60 60 BOOL fUseCodePage = FALSE; 61 int WinCodePage; 62 61 63 char 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"; 65 67 66 68 char *ResTypes[MAX_RES] = … … 95 97 PIMAGE_SECTION_HEADER psh; 96 98 int nSections; 97 98 if(argc != 2 && argc != 3) { 99 char *winfile=NULL, *os2file=NULL; 100 101 if(argc < 2 || argc > 4) { 99 102 cout << "pe2lx v0.0." << PE2LX_VERSION << "alpha"<< endl; 100 103 cout << INFO_BANNER << endl; 101 104 return(0); 102 105 } 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 */ 105 117 &win32handle, /* File handle */ 106 118 &ulAction, /* Action taken */ … … 163 175 return(1); 164 176 } 165 if( argc == 2) {177 if(os2file == NULL) { 166 178 //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); 169 181 newfile[strlen(newfile)-1]++; 170 182 //save copy of win32 exe/dll (exe->exf, dll->dlk) 171 rc = DosMove( argv[1], newfile);183 rc = DosMove(winfile, newfile); 172 184 if(rc) { 173 185 cout << "Unable to save original win32 file to " << newfile << "(" << rc << ")" << endl; … … 214 226 //// OS2Exe.SetStackSize(oh.SizeOfStackCommit); 215 227 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); 219 231 220 232 nSections = NR_SECTIONS(win32file); … … 557 569 } 558 570 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); 562 574 563 575 return(0); … … 617 629 cout << "Resource Data RVA " << hex(pData->OffsetToData) << endl; 618 630 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 620 635 if(pData->Size) {//winamp17 winzip archive has resource with size 0 621 636 switch(type) { 622 637 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); 624 639 break; 625 640 case NTRT_ICON: … … 640 655 break; 641 656 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); 643 658 break; 644 659 case NTRT_VERSION: … … 655 670 //lower 4 bits are an index into the string table 656 671 //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); 658 673 break; 659 674 case NTRT_ACCELERATORS:
Note:
See TracChangeset
for help on using the changeset viewer.