Rev 528 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 528 | Rev 532 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | // 2. Since the code segment is closer to the 8BF file start, the search+replace of the key is faster |
31 | // 2. Since the code segment is closer to the 8BF file start, the search+replace of the key is faster |
32 | // Please also note: |
32 | // Please also note: |
33 | // The 8BF file *MUST* only contain the seed A SINGLE TIME |
33 | // The 8BF file *MUST* only contain the seed A SINGLE TIME |
34 | // (In the Non-Standalone filter actually 3 times, because we have 2 resourced containing the 32/64 template DLLs) |
34 | // (In the Non-Standalone filter actually 3 times, because we have 2 resourced containing the 32/64 template DLLs) |
35 | #if defined(__WATCOMC__) |
35 | #if defined(__WATCOMC__) |
36 | uint64_t GetObfuscSeed() { |
36 | uint64_t GetObfuscSeed(void) { |
37 | // Due to "volatile", this value will only exist a single time in the binary file. |
37 | // Due to "volatile", this value will only exist a single time in the binary file. |
38 | // This char array will result in contiguous chars in OpenWatcom. |
38 | // This char array will result in contiguous chars in OpenWatcom. |
39 | // In MSVC++, the array will be built using several "mov ..." OP codes. |
39 | // In MSVC++, the array will be built using several "mov ..." OP codes. |
40 | volatile char seed[8] = { '\x17', '\x05', '\x83', '\x52', '\x2a', '\x97', '\x16', '\x74' }; |
40 | volatile char seed[8] = { '\x17', '\x05', '\x83', '\x52', '\x2a', '\x97', '\x16', '\x74' }; |
41 | return *((uint64_t*)&seed[0]); |
41 | return *((uint64_t*)&seed[0]); |
Line 43... | Line 43... | ||
43 | } |
43 | } |
44 | #elif defined(_MSC_VER) |
44 | #elif defined(_MSC_VER) |
45 | #ifdef _WIN64 |
45 | #ifdef _WIN64 |
46 | // Note: For MSVCC 64-bit, neither making the method volatile, nor including a volatile variable did avoid inlining. |
46 | // Note: For MSVCC 64-bit, neither making the method volatile, nor including a volatile variable did avoid inlining. |
47 | // so we use __declspec(noinline) |
47 | // so we use __declspec(noinline) |
48 | __declspec(noinline) uint64_t GetObfuscSeed() { |
48 | __declspec(noinline) uint64_t GetObfuscSeed(void) { |
49 | // TODO: Not 4-byte aligned! (both variants) |
49 | // TODO: Not 4-byte aligned! (both variants) |
50 | //volatile uint64_t seed = 0x7416972a52830517ull; |
50 | //volatile uint64_t seed = 0x7416972a52830517ull; |
51 | //return seed; |
51 | //return seed; |
52 | return 0x7416972a52830517ull; |
52 | return 0x7416972a52830517ull; |
53 | } |
53 | } |
54 | #else |
54 | #else |
55 | __declspec(noinline) uint64_t GetObfuscSeed() { |
55 | __declspec(noinline) uint64_t GetObfuscSeed(void) { |
56 | //volatile int test = 0; |
56 | //volatile int test = 0; |
57 | uint64_t* addr = NULL; |
57 | uint64_t* addr = NULL; |
58 | __asm { |
58 | __asm { |
59 | mov eax, seed // Doesn't work in OpenWatcom |
59 | mov eax, seed // Doesn't work in OpenWatcom |
60 | mov addr, eax |
60 | mov addr, eax |
Line 83... | Line 83... | ||
83 | #else |
83 | #else |
84 | // Unfortunately, with this compiler, we don't know how to force the seed into the .code segment. |
84 | // Unfortunately, with this compiler, we don't know how to force the seed into the .code segment. |
85 | // So, we put it in the .data segment. |
85 | // So, we put it in the .data segment. |
86 | // Note: Due to "const volatile", this value will only exist a single time in the binary file. |
86 | // Note: Due to "const volatile", this value will only exist a single time in the binary file. |
87 | const volatile uint64_t obfusc_seed = 0x7416972a52830517ull; |
87 | const volatile uint64_t obfusc_seed = 0x7416972a52830517ull; |
88 | uint64_t GetObfuscSeed() { |
88 | uint64_t GetObfuscSeed(void) { |
89 | return obfusc_seed; |
89 | return obfusc_seed; |
90 | } |
90 | } |
91 | #endif |
91 | #endif |
92 | 92 | ||
93 | // Random seed #2 for obfuscation "86 21 1f 3e f1 a2 87 ef" |
93 | // Random seed #2 for obfuscation "86 21 1f 3e f1 a2 87 ef" |
94 | // Lies in the data segment. Same rules like for the random seed #1. |
94 | // Lies in the data segment. Same rules like for the random seed #1. |
95 | const volatile uint64_t obfusc_seed2 = 0xef87a2f13e1f2186ull; |
95 | const volatile uint64_t obfusc_seed2 = 0xef87a2f13e1f2186ull; |
96 | #ifdef _MSC_VER |
96 | #ifdef _MSC_VER |
97 | __declspec(noinline) |
97 | __declspec(noinline) |
98 | #endif |
98 | #endif |
99 | uint64_t GetObfuscSeed2() { |
99 | uint64_t GetObfuscSeed2(void) { |
100 | // Additional seed for Obfusc V7. It is always in the data segment, |
100 | // Additional seed for Obfusc V7. It is always in the data segment, |
101 | // while obfusc seed 1 is in the code segment (if the compiler allows it) |
101 | // while obfusc seed 1 is in the code segment (if the compiler allows it) |
102 | return obfusc_seed2; |
102 | return obfusc_seed2; |
103 | } |
103 | } |
104 | 104 |