Rev 294 | Rev 314 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 294 | Rev 308 | ||
---|---|---|---|
Line 429... | Line 429... | ||
429 | /* Attention: The resource we have found using FindResource() might have a different |
429 | /* Attention: The resource we have found using FindResource() might have a different |
430 | language than the resource we are saving (Neutral), so we might end up having |
430 | language than the resource we are saving (Neutral), so we might end up having |
431 | multiple languages for the same resource. Therefore, the language "Neutral" was |
431 | multiple languages for the same resource. Therefore, the language "Neutral" was |
432 | set in the Scripting.rc file for the resource AETE and PIPL.rc for the resources PIPL. */ |
432 | set in the Scripting.rc file for the resource AETE and PIPL.rc for the resources PIPL. */ |
433 | 433 | ||
434 | if(_UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(50), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) |
434 | if(_UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(50), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin |
435 | && _UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) |
435 | && _UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin |
436 | && _UpdateResource(hupdate, RT_DIALOG, MAKEINTRESOURCE(ID_BUILDDLG), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NULL, 0) |
436 | && _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 |
- | 437 | && _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 |
|
- | 438 | && _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 |
|
- | 439 | && _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 |
|
- | 440 | && _UpdateResource(hupdate, RT_GROUP_CURSOR, MAKEINTRESOURCE(IDC_FF_HAND_QUESTION), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin |
|
- | 441 | && _UpdateResource(hupdate, RT_CURSOR, MAKEINTRESOURCE(6)/*QuestionHand*/, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) // clean up things we don't need in the standalone plugin |
|
437 | && _UpdateResource(hupdate,"PIPL" /* note: caps!! */,MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),newpipl,(DWORD)piplsize) |
442 | && _UpdateResource(hupdate, "PIPL" /* note: caps!! */,MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),newpipl,(DWORD)piplsize) |
438 | && _UpdateResource(hupdate, "AETE" /* note: caps!! */, MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newaete, (DWORD)aetesize) |
443 | && _UpdateResource(hupdate, "AETE" /* note: caps!! */, MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newaete, (DWORD)aetesize) |
439 | && _UpdateResource(hupdate, RT_MANIFEST, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newmanifest, (DWORD)manifestsize) |
444 | && _UpdateResource(hupdate, RT_MANIFEST, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newmanifest, (DWORD)manifestsize) |
440 | && _UpdateResource(hupdate,parm_type,MAKEINTRESOURCE(parm_id), MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),pparm,sizeof(PARM_T)) ) |
445 | && _UpdateResource(hupdate, parm_type,MAKEINTRESOURCE(parm_id), MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),pparm,sizeof(PARM_T)) ) |
441 | { |
446 | { |
Line 511... | Line 516... | ||
511 | DWORD dwAttrib = GetFileAttributes(szPath); |
516 | DWORD dwAttrib = GetFileAttributes(szPath); |
512 | return (dwAttrib != INVALID_FILE_ATTRIBUTES && |
517 | return (dwAttrib != INVALID_FILE_ATTRIBUTES && |
513 | !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); |
518 | !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); |
514 | } |
519 | } |
515 | 520 | ||
- | 521 | Boolean extractFile(LPCTSTR lpType, LPCTSTR lpName, const char* outName) { |
|
- | 522 | HGLOBAL datah; |
|
- | 523 | LPVOID datap; |
|
- | 524 | HRSRC datarsrc; |
|
- | 525 | size_t datalen; |
|
- | 526 | ||
- | 527 | if ((datarsrc = FindResource((HMODULE)hDllInstance, lpName, lpType)) |
|
- | 528 | && (datah = LoadResource((HMODULE)hDllInstance, datarsrc)) |
|
- | 529 | && (datalen = SizeofResource((HMODULE)hDllInstance, datarsrc)) |
|
- | 530 | && (datap = (Ptr)LockResource(datah))) { |
|
- | 531 | ||
- | 532 | FILE* fp = fopen(outName, "wb+"); |
|
- | 533 | if (fp == NULL) return false; |
|
- | 534 | if (fwrite(datap, 1, datalen, fp) != datalen) return false; |
|
- | 535 | if (fclose(fp)) return false; |
|
- | 536 | ||
- | 537 | return true; |
|
- | 538 | } |
|
- | 539 | else { |
|
- | 540 | return false; |
|
- | 541 | } |
|
- | 542 | } |
|
- | 543 | ||
516 | OSErr do_make_standalone(char* srcname, char* dstname, int bits) { |
544 | OSErr do_make_standalone(char* dstname, int bits) { |
517 | Boolean res; |
545 | Boolean res; |
518 | char err[MAX_PATH + 200]; |
546 | char err[MAX_PATH + 200]; |
519 | 547 | ||
520 | //DeleteFile(dstname); |
548 | //DeleteFile(dstname); |
521 | if (CopyFile(srcname, dstname, false)) { |
549 | if (extractFile("TPLT", MAKEINTRESOURCE(1000 + bits), dstname)) { |
522 | HMODULE hSrcmod; |
550 | HMODULE hSrcmod; |
523 | hSrcmod = LoadLibraryEx(srcname, NULL, LOAD_LIBRARY_AS_DATAFILE); |
551 | hSrcmod = LoadLibraryEx(dstname, NULL, LOAD_LIBRARY_AS_DATAFILE); |
524 | if (hSrcmod) { |
552 | if (hSrcmod) { |
525 | res = doresources(hSrcmod, dstname, bits); |
553 | res = doresources(hSrcmod, dstname, bits); |
- | 554 | FreeLibrary(hSrcmod); // do it now, otherwise DeleteFile() will not work |
|
526 | if (!res) { |
555 | if (!res) { |
527 | DeleteFile(dstname); |
556 | DeleteFile(dstname); |
528 | sprintf(err, "Could not create %d bit standalone plugin (doresources failed).", bits); |
557 | sprintf(err, "Could not create %d bit standalone plugin (doresources failed).", bits); |
529 | alertuser(_strdup(&err[0]), _strdup("")); |
558 | alertuser(_strdup(&err[0]), _strdup("")); |
530 | } |
559 | } |
531 | FreeLibrary(hSrcmod); |
- | |
532 | } |
560 | } |
533 | else { |
561 | else { |
534 | DWORD dwErr = GetLastError(); |
562 | DWORD dwErr = GetLastError(); |
535 | res = false; |
563 | res = false; |
536 | DeleteFile(dstname); |
564 | DeleteFile(dstname); |
Line 538... | Line 566... | ||
538 | sprintf(err, "Could not create %d bit standalone plugin (LoadLibraryEx failed, Win32 error %lu).", bits, dwErr); |
566 | sprintf(err, "Could not create %d bit standalone plugin (LoadLibraryEx failed, Win32 error %lu).", bits, dwErr); |
539 | alertuser(_strdup(&err[0]), _strdup("")); |
567 | alertuser(_strdup(&err[0]), _strdup("")); |
540 | } |
568 | } |
541 | } |
569 | } |
542 | else { |
570 | else { |
543 | DWORD dwErr = GetLastError(); |
571 | // If you see this error, please make sure that you have called foundry_3264_mixer to include the 32/64 plugins as resource! |
544 | res = false; |
572 | res = false; |
545 | //DeleteFile(dstname); |
573 | //DeleteFile(dstname); |
546 | // TODO: Also translate Win32 error to use readable text ( https://docs.microsoft.com/en-us/windows/win32/debug/retrieving-the-last-error-code ) |
- | |
547 | sprintf(err, "Could not create %d bit standalone plugin (CopyFile failed, Win32 error %lu).", bits, dwErr); |
574 | sprintf(err, "Could not create %d bit standalone plugin (File extraction failed).", bits); |
548 | alertuser(_strdup(&err[0]), _strdup("")); |
575 | alertuser(_strdup(&err[0]), _strdup("")); |
549 | } |
576 | } |
550 | 577 | ||
551 | return res ? noErr : ioErr; |
578 | return res ? noErr : ioErr; |
552 | } |
579 | } |
553 | 580 | ||
554 | OSErr make_standalone(StandardFileReply *sfr){ |
581 | OSErr make_standalone(StandardFileReply *sfr){ |
555 | OSErr tmpErr, outErr; |
582 | OSErr tmpErr, outErr; |
556 | char dstname[0x100],srcname[MAX_PATH+1]; |
583 | char dstname[MAX_PATH+1]; |
557 | 584 | ||
558 | if (!isWin32NT()) { |
585 | if (!isWin32NT()) { |
559 | HMODULE hLib; |
586 | HMODULE hLib; |
560 | 587 | ||
561 | hLib = LoadLibraryA("UNICOWS.DLL"); |
588 | hLib = LoadLibraryA("UNICOWS.DLL"); |
Line 576... | Line 603... | ||
576 | } |
603 | } |
577 | } |
604 | } |
578 | 605 | ||
579 | outErr = noErr; |
606 | outErr = noErr; |
580 | 607 | ||
581 | #ifdef _WIN64 |
- | |
582 | - | ||
583 | //64 bit DLL makes 64 bit: |
- | |
584 | // Source file = module filename |
- | |
585 | GetModuleFileName(hDllInstance, srcname, MAX_PATH); |
- | |
586 | // Destfile = no64_or_32(chosenname) + 64 |
- | |
587 | myp2cstrcpy(dstname, sfr->sfFile.name); |
- | |
588 | remove_64_filename_prefix(dstname); |
- | |
589 | add_64_filename_prefix(dstname); |
- | |
590 | tmpErr = do_make_standalone(&srcname[0], &dstname[0], 64); |
- | |
591 | if (tmpErr != noErr) |
- | |
592 | outErr = tmpErr; |
- | |
593 | else |
- | |
594 | showmessage(_strdup("64 bit standalone filter was successfully created")); |
- | |
595 | - | ||
596 | //64 bit DLL makes 32 bit: |
608 | // Make 32 bit: |
597 | // Source file = no32(modulefilename) |
- | |
598 | GetModuleFileName(hDllInstance, srcname, MAX_PATH); |
- | |
599 | if (!remove_64_filename_prefix(srcname)) { |
- | |
600 | char err[MAX_PATH + 200]; |
- | |
601 | sprintf(err, "Cannot create the %d bit version of this filter, because the 32-bit variant of this plugin could not be found", 32); |
- | |
602 | alertuser(_strdup(&err[0]), _strdup("")); |
- | |
603 | } |
- | |
604 | else if (!FileExists(srcname)) { |
- | |
605 | char err[MAX_PATH + 200]; |
- | |
606 | sprintf(err, "%s was not found. Therefore, the %d bit version of the standalone filter could not be created!", srcname, 32); |
- | |
607 | alertuser(_strdup(&err[0]), _strdup("")); |
- | |
608 | } |
- | |
609 | else { |
- | |
610 | // Destfile = no64_or_32(chosenname) |
609 | // Destfile = no64_or_32(chosenname) |
611 | myp2cstrcpy(dstname, sfr->sfFile.name); |
610 | myp2cstrcpy(dstname, sfr->sfFile.name); |
612 | remove_64_filename_prefix(dstname); |
611 | remove_64_filename_prefix(dstname); |
613 | tmpErr = do_make_standalone(&srcname[0], &dstname[0], 32); |
- | |
614 | if (tmpErr != noErr) |
- | |
615 | outErr = tmpErr; |
- | |
616 | else |
- | |
617 | showmessage(_strdup("32 bit standalone filter was successfully created")); |
- | |
618 | } |
- | |
619 | - | ||
620 | #else |
- | |
621 | - | ||
622 | //32 bit DLL makes 32 bit: |
- | |
623 | // Source file = module filename |
- | |
624 | GetModuleFileName(hDllInstance, srcname, MAX_PATH); |
- | |
625 | // Destfile = no64_or_32(chosenname) |
- | |
626 | myp2cstrcpy(dstname, sfr->sfFile.name); |
- | |
627 | remove_64_filename_prefix(dstname); |
- | |
628 | tmpErr = do_make_standalone(&srcname[0], &dstname[0], 32); |
612 | tmpErr = do_make_standalone(&dstname[0], 32); |
629 | if (tmpErr != noErr) |
613 | if (tmpErr != noErr) |
630 | outErr = tmpErr; |
614 | outErr = tmpErr; |
631 | else |
615 | else |
632 | showmessage(_strdup("32 bit standalone filter was successfully created")); |
616 | showmessage(_strdup("32 bit standalone filter was successfully created")); |
633 | 617 | ||
634 | if (isWin32NT()) { |
618 | if (isWin32NT()) { |
635 | //32 bit DLL makes 64 bit: |
619 | // Make 64 bit: |
636 | // Source file = module filename + 64 |
- | |
637 | GetModuleFileName(hDllInstance, srcname, MAX_PATH); |
- | |
638 | add_64_filename_prefix(srcname); |
- | |
639 | if (!FileExists(srcname)) { |
- | |
640 | char err[MAX_PATH + 200]; |
- | |
641 | sprintf(err, "%s was not found. Therefore, the %d bit version of the standalone filter could not be created!", srcname, 64); |
- | |
642 | alertuser(_strdup(&err[0]), _strdup("")); |
- | |
643 | } |
- | |
644 | else { |
- | |
645 | // Destfile = no64_or_32(chosenname) + 64 |
620 | // Destfile = no64_or_32(chosenname) + 64 |
646 | myp2cstrcpy(dstname, sfr->sfFile.name); |
621 | myp2cstrcpy(dstname, sfr->sfFile.name); |
647 | remove_64_filename_prefix(dstname); |
622 | remove_64_filename_prefix(dstname); |
648 | add_64_filename_prefix(dstname); |
623 | add_64_filename_prefix(dstname); |
649 | tmpErr = do_make_standalone(&srcname[0], &dstname[0], 64); |
624 | tmpErr = do_make_standalone(&dstname[0], 64); |
650 | if (tmpErr != noErr) |
625 | if (tmpErr != noErr) |
651 | outErr = tmpErr; |
626 | outErr = tmpErr; |
652 | else |
627 | else |
653 | showmessage(_strdup("64 bit standalone filter was successfully created")); |
628 | showmessage(_strdup("64 bit standalone filter was successfully created")); |
654 | } |
629 | } |
655 | } |
- | |
656 | else { |
630 | else { |
657 | // Unicows.dll cannot edit resources of 64 bit DLLs. |
631 | // Unicows.dll cannot edit resources of 64 bit DLLs. |
658 | // The normal Kernel function BeginUpdateResource can edit 64 bit DLLs, even in NT4.0 SP6 |
632 | // The normal Kernel function BeginUpdateResource can edit 64 bit DLLs, even in NT4.0 SP6 |
659 | simplealert(_strdup("Note: A 64 bit standalone filter cannot be created with your Windows version")); |
633 | simplealert(_strdup("Note: A 64 bit standalone filter cannot be created with your Windows version")); |
660 | } |
634 | } |
661 | #endif |
- | |
662 | 635 | ||
663 | return outErr; |
636 | return outErr; |
664 | } |
637 | } |
- | 638 |