| 
129
 | 
     1 #include <stdint.h>
 | 
| 
 | 
     2 #include <stdio.h>
 | 
| 
 | 
     3 #include <stdlib.h>
 | 
| 
 | 
     4 #include <inttypes.h>
 | 
| 
 | 
     5 
 | 
| 
 | 
     6 static void decode_size(unsigned long x)
 | 
| 
 | 
     7 {
 | 
| 
 | 
     8     const char *lut[] = {"No", "One", "Two", "Four"};
 | 
| 
 | 
     9 
 | 
| 
 | 
    10     printf("k%sByteCode", lut[x & 3]);
 | 
| 
 | 
    11 }
 | 
| 
 | 
    12 
 | 
| 
 | 
    13 int main(int argc, char *argv[])
 | 
| 
 | 
    14 {
 | 
| 
 | 
    15     unsigned long x;
 | 
| 
 | 
    16 
 | 
| 
 | 
    17     if (argc < 2) {
 | 
| 
 | 
    18         fprintf(stderr, "usage: decrypt-mixed-call <param>\n");
 | 
| 
 | 
    19         return 1;
 | 
| 
 | 
    20     }
 | 
| 
 | 
    21 
 | 
| 
 | 
    22     x = strtoul(argv[1], NULL, 0);
 | 
| 
 | 
    23 
 | 
| 
 | 
    24     switch (x & 15) {
 | 
| 
 | 
    25     case 0:
 | 
| 
 | 
    26         printf("kPascalStackBased");
 | 
| 
 | 
    27         break;
 | 
| 
 | 
    28     case 1:
 | 
| 
 | 
    29         printf("kCStackBased");
 | 
| 
 | 
    30         break;
 | 
| 
 | 
    31     case 2:
 | 
| 
 | 
    32         printf("I'm too lazy for this!");
 | 
| 
 | 
    33         return 1;
 | 
| 
 | 
    34     case 5:
 | 
| 
 | 
    35         printf("kThinkCStackBased");
 | 
| 
 | 
    36         break;
 | 
| 
 | 
    37     case 8:
 | 
| 
 | 
    38         printf("kD0DispatchedPascalStackBased");
 | 
| 
 | 
    39         break;
 | 
| 
 | 
    40     case 9:
 | 
| 
 | 
    41         printf("kD0DispatchedCStackBased");
 | 
| 
 | 
    42         break;
 | 
| 
 | 
    43     case 12:
 | 
| 
 | 
    44         printf("kD1DispatchedPascalStackBased");
 | 
| 
 | 
    45         break;
 | 
| 
 | 
    46     case 14:
 | 
| 
 | 
    47         printf("kStackDispatchedPascalStackBased");
 | 
| 
 | 
    48         break;
 | 
| 
 | 
    49     default:
 | 
| 
 | 
    50         /* Invalid */
 | 
| 
 | 
    51         return 1;
 | 
| 
 | 
    52     }
 | 
| 
 | 
    53 
 | 
| 
 | 
    54     x >>= 4;
 | 
| 
 | 
    55 
 | 
| 
 | 
    56     printf(" | RESULT_SIZE(");
 | 
| 
 | 
    57     decode_size(x);
 | 
| 
 | 
    58     printf(")");
 | 
| 
 | 
    59 
 | 
| 
 | 
    60     /* trim the fat */
 | 
| 
 | 
    61     x >>= 2;
 | 
| 
 | 
    62 
 | 
| 
 | 
    63     /* hopefully we're using stack, since that's the ONLY thing i'm handling */
 | 
| 
 | 
    64     for (uint32_t i = 1; i < 13 && x; i++, x >>= 2) {
 | 
| 
 | 
    65         printf(" | STACK_ROUTINE_PARAMETER(%" PRIu32 ", ", i);
 | 
| 
 | 
    66         decode_size(x);
 | 
| 
 | 
    67         printf(")");
 | 
| 
 | 
    68     }
 | 
| 
 | 
    69 
 | 
| 
 | 
    70     puts("");
 | 
| 
 | 
    71 
 | 
| 
 | 
    72     return 0;
 | 
| 
 | 
    73 }
 |