Rev 85 | Rev 107 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 85 | Rev 106 | ||
---|---|---|---|
Line 165... | Line 165... | ||
165 | 165 | ||
166 | void obfusc(unsigned char *pparm,size_t size){ |
166 | void obfusc(unsigned char *pparm,size_t size){ |
167 | int i; |
167 | int i; |
168 | unsigned char *p; |
168 | unsigned char *p; |
169 | 169 | ||
- | 170 | /* Do a small self-test to test if the stdlib implementation works as expected, i.e. that it only |
|
- | 171 | * depends on the seed set by srand() and on nothing else. |
|
- | 172 | */ |
|
- | 173 | srand(0xdc43df3c); |
|
- | 174 | int selftest1 = rand(); |
|
- | 175 | int selftest2 = rand(); |
|
- | 176 | int selftest3 = rand(); |
|
- | 177 | ||
- | 178 | srand(0xdc43df3c); |
|
- | 179 | if ((rand() != selftest1) || (rand() != selftest2) || (rand() != selftest3)) { |
|
- | 180 | // This should never happen |
|
- | 181 | simplealert("Stdcall rand() implementation does not work as expected. Obfuscation operation will be cancelled."); |
|
- | 182 | return; // apply no obfuscation |
|
- | 183 | } |
|
- | 184 | ||
170 | /* Very simplistic. meant to hide from casual observation/loading only. |
185 | /* Very simplistic. meant to hide from casual observation/loading only. |
171 | * Results are platform dependent, but this should not matter. */ |
186 | * Results are platform dependent, but this should not matter. */ |
172 | srand(0xdc43df3c); |
187 | srand(0xdc43df3c); |
173 | for(i = size, p = pparm; i--;) |
188 | for(i = size, p = pparm; i--;) |
174 | *p++ ^= rand(); |
189 | *p++ ^= rand(); |