Subversion Repositories filter_foundry

Rev

Rev 402 | Rev 419 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 402 Rev 416
Line 100... Line 100...
100
        else {
100
        else {
101
                return sprintf(newmanifest, manifestp, (char*)name, "x86", VERSION_STR, (char*)description);
101
                return sprintf(newmanifest, manifestp, (char*)name, "x86", VERSION_STR, (char*)description);
102
        }
102
        }
103
}
103
}
104
 
104
 
105
void changeVersionInfo(char* dstname, PARM_T* pparm, HGLOBAL hupdate) {
105
ULONG changeVersionInfo(char* dstname, HANDLE hUpdate, PARM_T* pparm, int bits) {
106
        char* soleFilename;
106
        char* soleFilename;
107
        LPWSTR changeRequestStr, tmp;
107
        LPWSTR changeRequestStr, tmp;
-
 
108
        ULONG dwError = NOERROR;
-
 
109
        HRSRC hResInfo;
-
 
110
        HGLOBAL hg;
-
 
111
        ULONG size;
-
 
112
        PVOID pv;
-
 
113
        BOOL fDiscard = TRUE;
108
 
114
 
109
        if (soleFilename = strrchr(dstname, '\\')) {
115
        if (soleFilename = strrchr(dstname, '\\')) {
110
                ++soleFilename;
116
                ++soleFilename;
111
        }
117
        }
112
        else {
118
        else {
Line 166... Line 172...
166
        tmp += mbstowcs(tmp, "\b", 100); // \b = remove, since filter is standalone and might have its own license
172
        tmp += mbstowcs(tmp, "\b", 100); // \b = remove, since filter is standalone and might have its own license
167
        tmp++;
173
        tmp++;
168
 
174
 
169
        tmp += mbstowcs(tmp, "", 1);
175
        tmp += mbstowcs(tmp, "", 1);
170
 
176
 
-
 
177
        if (hResInfo = FindResourceEx(hDllInstance, "TPLT", MAKEINTRESOURCE(3000 + bits), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)))
-
 
178
        {
-
 
179
                if (hg = LoadResource(hDllInstance, hResInfo))
-
 
180
                {
-
 
181
                        if (size = SizeofResource(hDllInstance, hResInfo))
-
 
182
                        {
-
 
183
                                if (pv = LockResource(hg))
-
 
184
                                {
171
        if (UpdateVersionInfoWithHandle(dstname, hupdate, changeRequestStr) != NOERROR) {
185
                                        if (UpdateVersionRaw(pv, size, &pv, &size, changeRequestStr))
-
 
186
                                        {
172
                simplealert(_strdup("UpdateVersionInfoWithHandle failed"));
187
                                                if (_UpdateResource(hUpdate, RT_VERSION, MAKEINTRESOURCE(1), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), pv, size))
-
 
188
                                                {
-
 
189
                                                        fDiscard = FALSE;
-
 
190
                                                }
-
 
191
 
-
 
192
                                                LocalFree(pv);
-
 
193
                                        }
-
 
194
                                }
-
 
195
                        }
-
 
196
                }
173
        }
197
        }
174
 
198
 
175
        free(changeRequestStr);
199
        free(changeRequestStr);
-
 
200
 
-
 
201
        return dwError;
176
}
202
}
177
 
203
 
178
Boolean update_pe_timestamp(const char* filename, time_t timestamp) {
204
Boolean update_pe_timestamp(const char* filename, time_t timestamp) {
179
        size_t peoffset;
205
        size_t peoffset;
180
        FILE* fptr;
206
        FILE* fptr;
Line 434... Line 460...
434
                                        free(manifestp_copy);
460
                                        free(manifestp_copy);
435
                                }
461
                                }
436
 
462
 
437
                                // ====== Change version attributes
463
                                // ====== Change version attributes
438
 
464
 
439
                                changeVersionInfo(dstname, pparm, hupdate);
465
                                if (changeVersionInfo(dstname, hupdate, pparm, bits) != NOERROR) {
-
 
466
                                        simplealert(_strdup("changeVersionInfo failed"));
-
 
467
                                }
440
 
468
 
441
                                // ====== Obfuscate pparm!
469
                                // ====== Obfuscate pparm!
442
 
470
 
443
                                if (gdata->obfusc) {
471
                                if (gdata->obfusc) {
444
                                        parm_type = OBFUSCDATA_TYPE_NEW;
472
                                        parm_type = OBFUSCDATA_TYPE_NEW;
Line 456... Line 484...
456
                                /* Attention: The resource we have found using FindResource() might have a different
484
                                /* Attention: The resource we have found using FindResource() might have a different
457
                                   language than the resource we are saving (Neutral), so we might end up having
485
                                   language than the resource we are saving (Neutral), so we might end up having
458
                                   multiple languages for the same resource. Therefore, the language "Neutral" was
486
                                   multiple languages for the same resource. Therefore, the language "Neutral" was
459
                                   set in the Scripting.rc file for the resource AETE and PIPL.rc for the resources PIPL. */
487
                                   set in the Scripting.rc file for the resource AETE and PIPL.rc for the resources PIPL. */
460
 
488
 
461
                                if(_UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0)  // clean up things we don't need in the standalone plugin
-
 
462
                                        && _UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(16032), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin
-
 
463
                                        && _UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(16064), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin
-
 
-
 
489
                                if(
464
                                        && _UpdateResource(hupdate, RT_DIALOG, MAKEINTRESOURCE(ID_BUILDDLG), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NULL, 0) // clean up things we don't need in the standalone plugin
490
                                           _UpdateResource(hupdate, RT_DIALOG, MAKEINTRESOURCE(ID_BUILDDLG), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NULL, 0) // clean up things we don't need in the standalone plugin
465
                                        && _UpdateResource(hupdate, RT_DIALOG, MAKEINTRESOURCE(ID_MAINDLG), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NULL, 0) // clean up things we don't need in the standalone plugin
491
                                        && _UpdateResource(hupdate, RT_DIALOG, MAKEINTRESOURCE(ID_MAINDLG), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NULL, 0) // clean up things we don't need in the standalone plugin
466
                                        && _UpdateResource(hupdate, RT_GROUP_ICON, "CAUTION_ICO", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin
492
                                        && _UpdateResource(hupdate, RT_GROUP_ICON, "CAUTION_ICO", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin
467
//                                      && _UpdateResource(hupdate, RT_ICON, MAKEINTRESOURCE(1)/*Caution*/, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin
493
//                                      && _UpdateResource(hupdate, RT_ICON, MAKEINTRESOURCE(1)/*Caution*/, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin
468
                                        && _UpdateResource(hupdate, RT_GROUP_CURSOR, "HAND_QUESTION", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin
494
                                        && _UpdateResource(hupdate, RT_GROUP_CURSOR, "HAND_QUESTION", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin
469
                                        // TODO: Removing the single resources don't work correctly. Sometimes the cursors are numbered 4,5,6 and sometimes 1,2,3 . Probably conflicts with icons
495
                                        // TODO: Removing the single resources don't work correctly. Sometimes the cursors are numbered 4,5,6 and sometimes 1,2,3 . Probably conflicts with icons
Line 481... Line 507...
481
                                } else {
507
                                } else {
482
                                        dbglasterror(_strdup("UpdateResource"));
508
                                        dbglasterror(_strdup("UpdateResource"));
483
                                }
509
                                }
484
                        }
510
                        }
485
 
511
 
486
                }else dbglasterror(_strdup("Find-, Load- or LockResource"));
-
 
487
 
-
 
488
                // Here, the file will be saved
512
                        // Here, the file will be saved
489
                if (!_EndUpdateResource(hupdate, discard)) {
513
                        if (_EndUpdateResource(hupdate, discard)) {
490
                        dbglasterror(_strdup("EndUpdateResource"));
-
 
491
                }
-
 
492
                else {
-
 
493
 
-
 
494
                        if (gdata->obfusc) {
514
                                if (gdata->obfusc) {
495
                                // We modify the binary code to replace the deobfuscate-seed from <cObfuscSeed> to <obfuscseed>
515
                                        // We modify the binary code to replace the deobfuscate-seed from <cObfuscSeed> to <obfuscseed>
496
 
516
 
497
                                // First try with alignment "4" (this should be the usual case),
517
                                        // First try with alignment "4" (this should be the usual case),
498
                                // and if that failed, try without alignment ("1").
518
                                        // and if that failed, try without alignment ("1").
Line 507... Line 527...
507
                        }
527
                                }
508
 
528
 
509
                        update_pe_timestamp(dstname, time(0));
529
                                update_pe_timestamp(dstname, time(0));
510
 
530
 
511
                        repair_pe_checksum(dstname);
531
                                repair_pe_checksum(dstname);
-
 
532
                        }else dbglasterror(_strdup("EndUpdateResource"));
512
                }
533
 
-
 
534
                }else dbglasterror(_strdup("Find-, Load- or LockResource"));
513
 
535
 
514
                if(pparm) free(pparm);
536
                if(pparm) free(pparm);
515
                if(newpipl) free(newpipl);
537
                if(newpipl) free(newpipl);
516
                if(newaete) free(newaete);
538
                if(newaete) free(newaete);
517
        }else
539
        }else