| 392 | // Encrypting/Decrypting MPQ data block |
| 393 | |
| 394 | void EncryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey1) |
| 395 | { |
| 396 | LPDWORD DataBlock = (LPDWORD)pvDataBlock; |
| 397 | DWORD dwValue32; |
| 398 | DWORD dwKey2 = 0xEEEEEEEE; |
| 399 | |
| 400 | // Round to DWORDs |
| 401 | dwLength >>= 2; |
| 402 | |
| 403 | // Encrypt the data block at array of DWORDs |
| 404 | for(DWORD i = 0; i < dwLength; i++) |
| 405 | { |
| 406 | // Modify the second key |
| 407 | dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; |
| 408 | |
| 409 | dwValue32 = DataBlock[i]; |
| 410 | DataBlock[i] = DataBlock[i] ^ (dwKey1 + dwKey2); |
| 411 | |
| 412 | dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); |
| 413 | dwKey2 = dwValue32 + dwKey2 + (dwKey2 << 5) + 3; |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey1) |
| 418 | { |
no outgoing calls
no test coverage detected