|
19 | 19 |
|
20 | 20 | #include <stdlib.h> |
21 | 21 | #include <unistd.h> |
| 22 | +#include <errno.h> |
22 | 23 | #include <stdio.h> |
23 | 24 | #include <string.h> |
24 | 25 | #include <getopt.h> |
@@ -95,7 +96,7 @@ void printv(char * fmt, ...) { |
95 | 96 |
|
96 | 97 | #ifndef PS2_PACKER_LITE |
97 | 98 | typedef int (*pack_section_t)(const u8 * source, u8 ** dest, u32 source_size); |
98 | | -pack_section_t pack_section; |
| 99 | +pack_section_t ppack_section; |
99 | 100 | typedef u32 (*signature_t)(); |
100 | 101 | signature_t signature; |
101 | 102 | #endif |
@@ -563,7 +564,12 @@ void packing(FILE * out, FILE * in, u32 base, int use_asm_n2e) { |
563 | 564 | remove_section_zeroes(pdata, §ion_size, &psh.zeroByteSize); |
564 | 565 | printv("Loaded section: %08X bytes (with %08X zeroes) based at %08X\n", psh.originalSize, psh.zeroByteSize, psh.virtualAddr); |
565 | 566 |
|
566 | | - psh.compressedSize = packed_size = pack_section(pdata, &packed, section_size); |
| 567 | +#ifndef PS2_PACKER_LITE |
| 568 | + packed_size = ppack_section(pdata, &packed, section_size); |
| 569 | +#else |
| 570 | + packed_size = pack_section(pdata, &packed, section_size); |
| 571 | +#endif |
| 572 | + psh.compressedSize = packed_size; |
567 | 573 |
|
568 | 574 | printv("Section packed, from %u to %u bytes, ratio = %5.2f%%\n", section_size, packed_size, 100.0 * (section_size - packed_size) / section_size); |
569 | 575 |
|
@@ -705,16 +711,17 @@ int main(int argc, char ** argv) { |
705 | 711 | default: |
706 | 712 | printf("Unknown option %c\n\n", c); |
707 | 713 | show_usage(); |
708 | | - exit(-1); |
| 714 | + exit(EINVAL); |
709 | 715 | } |
710 | 716 | } |
711 | 717 |
|
712 | 718 | if (alternative) |
713 | 719 | printv("Using alternative packing method.\n"); |
714 | 720 |
|
715 | 721 | if ((argc - optind) != 2) { |
716 | | - printf("%i files specified, I need exactly 2.\n\n", argc - optind); |
| 722 | + printe("%i files specified, I need exactly 2.\n\n", argc - optind); |
717 | 723 | show_usage(); |
| 724 | + exit(EINVAL); |
718 | 725 | } |
719 | 726 |
|
720 | 727 | in_name = argv[optind++]; |
@@ -794,7 +801,7 @@ int main(int argc, char ** argv) { |
794 | 801 | #ifndef PS2_PACKER_LITE |
795 | 802 | printv("Opening packer %s.\n", packer_dll); |
796 | 803 | packer_module = open_module(packer_dll); |
797 | | - pack_section = get_symbol(packer_module, "pack_section"); |
| 804 | + ppack_section = get_symbol(packer_module, "pack_section"); |
798 | 805 | signature = get_symbol(packer_module, "signature"); |
799 | 806 | if (signature() != stub_signature) { |
800 | 807 | printe("Packer's signature and stub's signature are not matching.\n"); |
|
0 commit comments