Rev 456 | Rev 492 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 456 | Rev 482 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | IMAGE_OPTIONAL_HEADER32 optHeader; // Standard COFF fields, Windows Specific Fields, Data Directories |
36 | IMAGE_OPTIONAL_HEADER32 optHeader; // Standard COFF fields, Windows Specific Fields, Data Directories |
37 | } PE32; |
37 | } PE32; |
38 | 38 | ||
39 | Boolean doresources(FSSpec* dst, int bits); |
39 | Boolean doresources(FSSpec* dst, int bits); |
40 | 40 | ||
41 | void dbglasterror(TCHAR *func){ |
41 | void showLastError(TCHAR *func){ |
42 | TCHAR s[0x300] = {0}; |
42 | TCHAR s[0x300] = {0}; |
43 | 43 | ||
44 | xstrcpy(&s[0],func); |
44 | xstrcpy(&s[0],func); |
45 | xstrcat(&s[0],TEXT(" failed: ")); |
45 | xstrcat(&s[0],TEXT(" failed: ")); |
46 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + xstrlen(s), 0x300 - (DWORD)xstrlen(s), NULL); |
46 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + xstrlen(s), 0x300 - (DWORD)xstrlen(s), NULL); |
47 | dbg(&s[0]); |
47 | simplealert(&s[0]); |
48 | } |
48 | } |
49 | 49 | ||
50 | /* |
50 | /* |
51 | BOOL CALLBACK enumfunc(HMODULE hModule,LPCTSTR lpszType,LPCTSTR lpszName,WORD wIDLanguage,LONG lParam){ |
51 | BOOL CALLBACK enumfunc(HMODULE hModule,LPCTSTR lpszType,LPCTSTR lpszName,WORD wIDLanguage,LONG lParam){ |
- | 52 | #ifdef DEBUG |
|
52 | char s[0x100]; |
53 | char s[0x100]; |
53 | sprintf(s,"EnumResourceLanguages callback: module=%#x type=%s name=%s lang=%d", |
54 | sprintf(s,"EnumResourceLanguages callback: module=%#x type=%s name=%s lang=%d", |
54 | hModule,lpszType,lpszName,wIDLanguage); |
55 | hModule,lpszType,lpszName,wIDLanguage); |
55 | dbg(s); |
56 | dbg(s); |
- | 57 | #endif |
|
56 | return TRUE; |
58 | return TRUE; |
57 | } |
59 | } |
58 | */ |
60 | */ |
59 | 61 | ||
60 | int domanifest(char *newmanifest, char *manifestp, PARM_T* pparm, int bits) { |
62 | int domanifest(char *newmanifest, char *manifestp, PARM_T* pparm, int bits) { |
Line 398... | Line 400... | ||
398 | memset(&dummy_oper, 0, sizeof(operdef_t)); |
400 | memset(&dummy_oper, 0, sizeof(operdef_t)); |
399 | memset(&dummy_func, 0, sizeof(funcdef_t)); |
401 | memset(&dummy_func, 0, sizeof(funcdef_t)); |
400 | memset(&dummy_symn, 0, sizeof(symndef_t)); |
402 | memset(&dummy_symn, 0, sizeof(symndef_t)); |
401 | 403 | ||
402 | if( (hupdate = _BeginUpdateResource(&dst->szName[0],false)) ){ |
404 | if( (hupdate = _BeginUpdateResource(&dst->szName[0],false)) ){ |
403 | DBG("BeginUpdateResource OK"); |
- | |
404 | if( (datarsrc = FindResource(hDllInstance,MAKEINTRESOURCE(16000 + bits), TEXT("TPLT"))) |
405 | if( (datarsrc = FindResource(hDllInstance,MAKEINTRESOURCE(16000 + bits), TEXT("TPLT"))) |
405 | && (datah = LoadResource(hDllInstance,datarsrc)) |
406 | && (datah = LoadResource(hDllInstance,datarsrc)) |
406 | && (datap = (Ptr)LockResource(datah)) |
407 | && (datap = (Ptr)LockResource(datah)) |
407 | && (aetersrc = FindResource(hDllInstance, MAKEINTRESOURCE(16000), TEXT("AETE"))) |
408 | && (aetersrc = FindResource(hDllInstance, MAKEINTRESOURCE(16000), TEXT("AETE"))) |
408 | && (aeteh = LoadResource(hDllInstance, aetersrc)) |
409 | && (aeteh = LoadResource(hDllInstance, aetersrc)) |
Line 414... | Line 415... | ||
414 | char* newmanifest; |
415 | char* newmanifest; |
415 | int manifestsize = SizeofResource(hDllInstance, manifestsrc); |
416 | int manifestsize = SizeofResource(hDllInstance, manifestsrc); |
416 | 417 | ||
417 | newmanifest = (char*)malloc((size_t)manifestsize + 4096/*+4KiB for name,description,etc.*/); |
418 | newmanifest = (char*)malloc((size_t)manifestsize + 4096/*+4KiB for name,description,etc.*/); |
418 | 419 | ||
419 | DBG("loaded DATA, PiPL"); |
- | |
420 | - | ||
421 | strcpy(title,gdata->parm.szTitle); |
420 | strcpy(title,gdata->parm.szTitle); |
422 | if(gdata->parm.popDialog) |
421 | if(gdata->parm.popDialog) |
423 | strcat(title,"..."); |
422 | strcat(title,"..."); |
424 | 423 | ||
425 | origsize = SizeofResource(hDllInstance,datarsrc); |
424 | origsize = SizeofResource(hDllInstance,datarsrc); |
Line 495... | Line 494... | ||
495 | && _UpdateResource(hupdate, RT_MANIFEST, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newmanifest, (DWORD)manifestsize) |
494 | && _UpdateResource(hupdate, RT_MANIFEST, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newmanifest, (DWORD)manifestsize) |
496 | && _UpdateResource(hupdate, parm_type,parm_id, MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),pparm,sizeof(PARM_T)) ) |
495 | && _UpdateResource(hupdate, parm_type,parm_id, MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),pparm,sizeof(PARM_T)) ) |
497 | { |
496 | { |
498 | discard = false; |
497 | discard = false; |
499 | } else { |
498 | } else { |
500 | dbglasterror((TCHAR*)TEXT("UpdateResource")); |
499 | showLastError((TCHAR*)TEXT("UpdateResource")); |
501 | } |
500 | } |
502 | } |
501 | } |
503 | 502 | ||
504 | free(newmanifest); |
503 | free(newmanifest); |
505 | 504 | ||
Line 513... | Line 512... | ||
513 | // We only need to set maxamount to "1", because "const volatile" makes sure that |
512 | // We only need to set maxamount to "1", because "const volatile" makes sure that |
514 | // the compiler won't place (inline) it at several locations in the code. |
513 | // the compiler won't place (inline) it at several locations in the code. |
515 | if ((binary_replace_file(dst, cObfuscSeed, obfuscseed, /*align to 4*/1, /*maxamount=*/1) == 0) && |
514 | if ((binary_replace_file(dst, cObfuscSeed, obfuscseed, /*align to 4*/1, /*maxamount=*/1) == 0) && |
516 | (binary_replace_file(dst, cObfuscSeed, obfuscseed, /*align to 1*/0, /*maxamount=*/1) == 0)) |
515 | (binary_replace_file(dst, cObfuscSeed, obfuscseed, /*align to 1*/0, /*maxamount=*/1) == 0)) |
517 | { |
516 | { |
518 | dbg((TCHAR*)TEXT("binary_replace_file failed")); |
517 | simplewarning((TCHAR*)TEXT("binary_replace_file failed")); |
519 | discard = true; |
518 | discard = true; |
520 | } |
519 | } |
521 | } |
520 | } |
522 | 521 | ||
523 | if (!update_pe_timestamp(dst, (__time32_t)time(0))) { |
522 | if (!update_pe_timestamp(dst, (__time32_t)time(0))) { |
Line 525... | Line 524... | ||
525 | } |
524 | } |
526 | 525 | ||
527 | if (!repair_pe_checksum(dst)) { |
526 | if (!repair_pe_checksum(dst)) { |
528 | simplewarning((TCHAR*)TEXT("repair_pe_checksum failed")); |
527 | simplewarning((TCHAR*)TEXT("repair_pe_checksum failed")); |
529 | } |
528 | } |
530 | }else dbglasterror((TCHAR*)TEXT("EndUpdateResource")); |
529 | }else showLastError((TCHAR*)TEXT("EndUpdateResource")); |
531 | 530 | ||
532 | }else dbglasterror((TCHAR*)TEXT("Find-, Load- or LockResource")); |
531 | }else showLastError((TCHAR*)TEXT("Find-, Load- or LockResource")); |
533 | 532 | ||
534 | if(pparm) free(pparm); |
533 | if(pparm) free(pparm); |
535 | if(newpipl) free(newpipl); |
534 | if(newpipl) free(newpipl); |
536 | if(newaete) free(newaete); |
535 | if(newaete) free(newaete); |
537 | }else |
536 | }else |
538 | dbglasterror((TCHAR*)TEXT("BeginUpdateResource")); |
537 | showLastError((TCHAR*)TEXT("BeginUpdateResource")); |
539 | return !discard; |
538 | return !discard; |
540 | } |
539 | } |
541 | 540 | ||
542 | Boolean remove_64_filename_prefix(LPTSTR dstname) { |
541 | Boolean remove_64_filename_prefix(LPTSTR dstname) { |
543 | // foobar.8bf => foobar.8bf |
542 | // foobar.8bf => foobar.8bf |