| 415 | } |
| 416 | |
| 417 | void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey1) |
| 418 | { |
| 419 | LPDWORD DataBlock = (LPDWORD)pvDataBlock; |
| 420 | DWORD dwValue32; |
| 421 | DWORD dwKey2 = 0xEEEEEEEE; |
| 422 | |
| 423 | // Round to DWORDs |
| 424 | dwLength >>= 2; |
| 425 | |
| 426 | // Decrypt the data block at array of DWORDs |
| 427 | for(DWORD i = 0; i < dwLength; i++) |
| 428 | { |
| 429 | // Modify the second key |
| 430 | dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; |
| 431 | |
| 432 | DataBlock[i] = DataBlock[i] ^ (dwKey1 + dwKey2); |
| 433 | dwValue32 = DataBlock[i]; |
| 434 | |
| 435 | dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); |
| 436 | dwKey2 = dwValue32 + dwKey2 + (dwKey2 << 5) + 3; |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | /** |
| 441 | * Functions tries to get file decryption key. This comes from these facts |
no outgoing calls
no test coverage detected