- Timestamp:
- Jul 6, 1999, 10:50:12 AM (26 years ago)
- 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:37sandervl Exp $ */1 /* $Id: dialog.cpp,v 1.7 1999-07-06 08:50:11 sandervl Exp $ */ 2 2 3 3 /* … … 16 16 #define INCL_DOSPROCESS /* DOS Process values */ 17 17 #define INCL_DOSMISC /* DOS Miscellanous values */ 18 #define INCL_DOSNLS 18 19 #define INCL_WIN 19 20 #define INCL_WINMLE … … 40 41 static void ConvertCaption(ULONG style, char *caption); 41 42 static int ConvertFont(char *font, PRESPARAMS *dlgpparam, int fsize); 42 static void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size );43 static void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size, int cp); 43 44 44 45 //****************************************************************************** … … 48 49 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 49 50 //****************************************************************************** 50 void ShowDialog(int id, DialogBoxHeader *dhdr, int size )51 void ShowDialog(int id, DialogBoxHeader *dhdr, int size, int cp) 51 52 { 52 53 WINDLGTEMPLATEEX *windlgex = (WINDLGTEMPLATEEX *)dhdr; … … 63 64 ULONG ctrlflag, winclass; 64 65 BOOL fIconBmp; 66 ULONG ulCpSize, ulCP; 65 67 66 68 //First save original win32 resource … … 68 70 69 71 if(windlgex->wDlgVer == 1 && windlgex->wSignature == 0xFFFF) { 70 ShowDialogEx(id, windlgex, size );72 ShowDialogEx(id, windlgex, size, cp); 71 73 return; 72 74 } … … 79 81 dlgcurdata = dlgdata; 80 82 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 } 82 91 dlgt->offadlgti = 14; 83 92 dlgt->fsTemplateStatus = 1; … … 145 154 } 146 155 else { 147 cout << "Menu namestring : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd) ) << endl;156 cout << "Menu namestring : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd), cp) << endl; 148 157 ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR)); 149 158 } … … 159 168 } 160 169 else { 161 szClass = UnicodeToAscii((WCHAR *)ptrArray );170 szClass = UnicodeToAscii((WCHAR *)ptrArray, cp); 162 171 cout << "Class Name : " << szClass << endl; 163 172 … … 181 190 } 182 191 else { 183 ctrltext = UnicodeToAscii((WCHAR *)(ptrArray) );192 ctrltext = UnicodeToAscii((WCHAR *)(ptrArray), cp); 184 193 cout << "Title : " << ctrltext << endl; 185 194 ctrldata = (ControlData *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); … … 199 208 if(dhdr->lStyle & DS_SETFONT) { 200 209 fhdr = (FontHeader *)ctrldata; 201 font = UnicodeToAscii(fhdr->szFontName );210 font = UnicodeToAscii(fhdr->szFontName, cp); 202 211 cout << "Font Point Size : " << fhdr->wPointSize << endl; 203 212 cout << "Font Name : " << font << endl; … … 271 280 } 272 281 else { 273 szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId );282 szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId, cp); 274 283 cout << "Class Name : " << szClass << endl; 275 284 szCaption = (WCHAR *)((int)ctrldata + sizeof(ControlData) + strlen(szClass)*2); … … 289 298 } 290 299 else { //Handle Caption 291 ctrltext = UnicodeToAscii(szCaption );300 ctrltext = UnicodeToAscii(szCaption, cp); 292 301 //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes) 293 302 ConvertCaption(winclass, ctrltext); … … 312 321 } 313 322 } 314 cout << "Text : " << UnicodeToAscii(szCaption ) << endl;323 cout << "Text : " << UnicodeToAscii(szCaption, cp) << endl; 315 324 szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD)); 316 325 } … … 328 337 //****************************************************************************** 329 338 //****************************************************************************** 330 void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size )339 void ShowDialogEx(int id, WINDLGTEMPLATEEX *dhdr, int size, int cp) 331 340 { 332 341 DLGTEMPLATE *dlgt; … … 342 351 ULONG ctrlflag, winclass; 343 352 BOOL fIconBmp; 353 ULONG ulCpSize, ulCP; 344 354 345 355 //should be enough … … 350 360 dlgcurdata = dlgdata; 351 361 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 } 353 370 dlgt->offadlgti = 14; 354 371 dlgt->fsTemplateStatus = 1; … … 412 429 } 413 430 else { 414 cout << "Menu namestring : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd )) << endl;431 cout << "Menu namestring : " << UnicodeToAscii((WCHAR *)(&dhdr->fNameOrd, cp)) << endl; 415 432 ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR)); 416 433 } … … 448 465 } 449 466 else { 450 ctrltext = UnicodeToAscii((WCHAR *)(ptrArray) );467 ctrltext = UnicodeToAscii((WCHAR *)(ptrArray), cp); 451 468 cout << "Title : " << ctrltext << endl; 452 469 ctrldata = (WINDLGITEMTEMPLATEEX *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); … … 467 484 if(dhdr->lStyle & DS_SETFONT) { 468 485 fhdr = (FontHeaderEx *)ctrldata; 469 font = UnicodeToAscii(fhdr->szFontName );486 font = UnicodeToAscii(fhdr->szFontName, cp); 470 487 cout << "Font Point Size : " << fhdr->wPointSize << endl; 471 488 cout << "Font Name : " << font << endl; … … 536 553 } 537 554 else { 538 szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId );555 szClass = UnicodeToAscii((WCHAR *)&ctrldata->fClassId, cp); 539 556 cout << "Class Name : " << szClass << endl; 540 557 szCaption = (WCHAR *)((int)ctrldata + sizeof(WINDLGITEMTEMPLATEEX) + strlen(szClass)*2); … … 551 568 } 552 569 else { //Handle Caption 553 ctrltext = UnicodeToAscii(szCaption );570 ctrltext = UnicodeToAscii(szCaption, cp); 554 571 //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes) 555 572 ConvertCaption(winclass, ctrltext); … … 574 591 } 575 592 } 576 cout << "Text : " << UnicodeToAscii(szCaption ) << endl;593 cout << "Text : " << UnicodeToAscii(szCaption, cp) << endl; 577 594 szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD)); 578 595 } -
trunk/src/pe2lx/dialog.h
r97 r275 1 /* $Id: dialog.h,v 1. 3 1999-06-10 17:08:53 phallerExp $ */1 /* $Id: dialog.h,v 1.4 1999-07-06 08:50:11 sandervl Exp $ */ 2 2 3 3 /* … … 102 102 #pragma pack() 103 103 104 void ShowDialog(int id, DialogBoxHeader *dhdr, int size );104 void ShowDialog(int id, DialogBoxHeader *dhdr, int size, int cp=0); 105 105 106 106 -
trunk/src/pe2lx/menu.cpp
r97 r275 1 /* $Id: menu.cpp,v 1. 3 1999-06-10 17:08:54 phallerExp $ */1 /* $Id: menu.cpp,v 1.4 1999-07-06 08:50:11 sandervl Exp $ */ 2 2 3 3 /* … … 14 14 #define INCL_DOSPROCESS /* DOS Process values */ 15 15 #define INCL_DOSMISC /* DOS Miscellanous values */ 16 #define INCL_DOSNLS 16 17 #define INCL_WIN 17 18 #include <os2.h> … … 27 28 #include "misc.h" 28 29 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 );30 static int ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp); 31 static int ProcessMenuItem(NormalMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp); 31 32 static void menustrcpy(char *dest, char *src); 32 33 //****************************************************************************** 33 34 //****************************************************************************** 34 void ShowMenu(int id, MenuHeader *menu, int size )35 void ShowMenu(int id, MenuHeader *menu, int size, int cp) 35 36 { 36 37 PopupMenuItem *popupitem = (PopupMenuItem *)((char *)menu + sizeof(MenuHeader)); … … 39 40 MTI_OS2 *menuitem; 40 41 int newsize; 42 ULONG ulCpSize, ulCP; 41 43 42 44 //First save original win32 resource … … 45 47 os2menu = (MT_OS2 *)malloc(size*4); //should always be sufficient 46 48 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 } 48 56 os2menu->reserved = 4; 49 57 os2menu->cMti = 0; … … 53 61 if(popupitem->fItemFlags & POPUP) { 54 62 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); 58 66 59 67 if(popupitem->fItemFlags & ENDMENU) break; … … 70 78 //****************************************************************************** 71 79 //****************************************************************************** 72 static int ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size )80 static int ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp) 73 81 { 74 82 NormalMenuItem *normalitem; … … 119 127 else { 120 128 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)); 123 131 } 124 132 os2menu->len += sizeof(MTI_OS2); … … 144 152 if(normalitem->fItemFlags & POPUP) { 145 153 cout << "POPUP "; 146 newsize = ProcessSubMenu((PopupMenuItem *)normalitem, submenu, menuitem, size );154 newsize = ProcessSubMenu((PopupMenuItem *)normalitem, submenu, menuitem, size, cp); 147 155 } 148 else newsize = ProcessMenuItem(normalitem, submenu, menuitem, size );156 else newsize = ProcessMenuItem(normalitem, submenu, menuitem, size, cp); 149 157 150 158 menuitem = (MTI_OS2 *)((int)submenu + submenu->len); … … 161 169 //****************************************************************************** 162 170 //****************************************************************************** 163 static int ProcessMenuItem(NormalMenuItem *normalitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size )171 static int ProcessMenuItem(NormalMenuItem *normalitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp) 164 172 { 165 173 WCHAR *menustring; … … 226 234 } 227 235 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)); 230 238 } 231 239 } -
trunk/src/pe2lx/menu.h
r97 r275 1 /* $Id: menu.h,v 1. 3 1999-06-10 17:08:54 phallerExp $ */1 /* $Id: menu.h,v 1.4 1999-07-06 08:50:11 sandervl Exp $ */ 2 2 3 3 /* … … 47 47 #pragma pack() /*PLF Sat 97-06-21 22:17:31*/ 48 48 49 void ShowMenu(int id, MenuHeader *menu, int size );49 void ShowMenu(int id, MenuHeader *menu, int size, int cp = 0); 50 50 51 51 #endif -
trunk/src/pe2lx/misc.cpp
r272 r275 1 /* $Id: misc.cpp,v 1. 4 1999-07-05 12:36:12sandervl Exp $ */1 /* $Id: misc.cpp,v 1.5 1999-07-06 08:50:11 sandervl Exp $ */ 2 2 3 3 /* … … 183 183 } 184 184 } 185 else return FALSE; 186 185 187 return TRUE; 186 188 } … … 194 196 if(prepareCP(cp) == TRUE && CodePage > 0) 195 197 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 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: -
trunk/src/pe2lx/strings.cpp
r97 r275 1 /* $Id: strings.cpp,v 1. 3 1999-06-10 17:08:55 phallerExp $ */1 /* $Id: strings.cpp,v 1.4 1999-07-06 08:50:12 sandervl Exp $ */ 2 2 3 3 /* … … 14 14 #define INCL_DOSPROCESS /* DOS Process values */ 15 15 #define INCL_DOSMISC /* DOS Miscellanous values */ 16 #define INCL_DOSNLS 16 17 #define INCL_WIN 17 18 #include <os2.h> … … 32 33 //whereas windows strings can be up to 64k bytes long 33 34 //****************************************************************************** 34 void ShowStrings(int id, char *data, int size )35 void ShowStrings(int id, char *data, int size, int cp) 35 36 { 36 37 USHORT *len; -
trunk/src/pe2lx/strings.h
r97 r275 1 /* $Id: strings.h,v 1. 3 1999-06-10 17:08:55 phallerExp $ */1 /* $Id: strings.h,v 1.4 1999-07-06 08:50:12 sandervl Exp $ */ 2 2 3 3 /* … … 13 13 #define __STRING_H__ 14 14 15 void ShowStrings(int id, char *data, int size );15 void ShowStrings(int id, char *data, int size, int cp=0); 16 16 17 17 #endif
Note:
See TracChangeset
for help on using the changeset viewer.