File size: 685 Bytes
6af5421
 
 
 
 
 
 
 
 
686266c
 
387663b
 
686266c
 
6af5421
686266c
 
4b07098
686266c
 
 
6af5421
686266c
6af5421
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "ice.h"
#include <string.h> // memcpy

#ifdef _WIN32
#define ICE_API __declspec(dllexport)
#else
#define ICE_API
#endif

extern "C" ICE_API void decrypt_inplace(unsigned char *text, size_t length) {
  auto key = (const unsigned char
                  *)"\x51\xF3\x0F\x11\x04\x24\x6A\x00"; // this is the game's
                                                        // encryption key.
  auto ice = ice_key_create(0);
  ice_key_set(ice, key);

  // decrypt in 8-byte blocks
  unsigned char buffer[8];
  for (size_t i = 0; (i + 8) <= length; i += 8) {
    ice_key_decrypt(ice, (unsigned char *)text + i, buffer);
    memcpy(text + i, buffer, 8);
  }

  ice_key_destroy(ice);
}