fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <vector>
  4. #include <sstream>
  5. #include <fstream>
  6.  
  7. #ifdef _WIN32 || _WIN64
  8. #include <windows.h>
  9. #include <conio.h>
  10. #define mkfolder(dirname) CreateDirectoryA(dirname, NULL)
  11. #else
  12. #ifdef __linux__ //untested
  13. #include <sys/types.h>
  14. #include <sys/stat.h>
  15.  
  16. #include <termios.h>
  17. #include <unistd.h>
  18.  
  19. #define mkfolder(dirname) mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
  20.  
  21. int getch(void)
  22. {
  23. struct termios oldt,
  24. newt;
  25. int ch;
  26. tcgetattr( STDIN_FILENO, &oldt );
  27. newt = oldt;
  28. newt.c_lflag &= ~( ICANON | ECHO );
  29. tcsetattr( STDIN_FILENO, TCSANOW, &newt );
  30. ch = getchar();
  31. tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
  32. return ch;
  33. }
  34. #else
  35. #error "THIS OS NOT SUPPORTED YET!"
  36. #endif
  37. #endif
  38.  
  39. #define FourCC 0x5A4F434D
  40. #define ItemFourCC 0x5850494D
  41. #define MobFourCC 0x5450494D
  42. #define IndexHeader 0x444B5045
  43. #define IndexVersion 2
  44. #define IndexBlockSize 0xC0
  45. #define delta -1640531527 //-0x61C88647
  46. #define LZO_E_OK 1
  47. #define LZO_E_INPUT_OVERRUN (-1)
  48. #define LZO_E_EOF_NOT_FOUND (-2)
  49. #define LZO_E_INPUT_NOT_CONSUMED (-3)
  50. #define IndexName ".eix"
  51. #define DataName ".epk"
  52. int crashi = 0;
  53.  
  54. unsigned char IndexXTEA[] = {0xB9, 0x9E, 0xB0, 0x02, 0x6F, 0x69, 0x81, 0x05, 0x63, 0x98, 0x9B, 0x28, 0x79, 0x18, 0x1A, 0x00,};
  55.  
  56. unsigned char DataXTEA[] = {0x22, 0xB8, 0xB4, 0x04, 0x64, 0xB2, 0x6E, 0x1F, 0xAE, 0xEA, 0x18, 0x00, 0xA6, 0xF6, 0xFB, 0x1C,};
  57.  
  58. int XteaEncrypt(unsigned long* output, unsigned long* input, unsigned char* XTEA, int size)
  59. {
  60. int round_count = 32;
  61. int rounds = 0;
  62. if (size & 7) size = (size & 0xFFFFFFF8) + 8;
  63. if(size) {
  64. do {
  65. output[0] = input[0];
  66. output[1] = input[1];
  67. unsigned int sum = 0;
  68. for (int i=0; i < round_count; i++) {
  69. output[0] += (((output[1] << 4) ^ (output[1] >> 5)) + output[1]) ^ (sum + *(unsigned long*)(XTEA + 4 * (sum & 3)));
  70. sum += delta;
  71. output[1] += (((output[0] << 4) ^ (output[0] >> 5)) + output[0]) ^ (sum + *(unsigned long*)(XTEA + 4 * ((sum >> 11) & 3)));
  72. }
  73. input += 2;
  74. output += 2;
  75. ++rounds;
  76. } while ( size/8 > rounds );
  77. }
  78. return size;
  79. }
  80.  
  81. int XteaDecrypt(unsigned long* output, unsigned long* input, unsigned char* XTEA, int size)
  82. {
  83. int round_count = 32;
  84. int rounds = 0;
  85. if (size & 7) size = (size & 0xFFFFFFF8) + 8;
  86. if(size) {
  87. do {
  88. output[0] = input[0];
  89. output[1] = input[1];
  90. unsigned int sum = delta * round_count;
  91. for (int i=0; i < round_count; i++) {
  92. output[1] -= (((output[0] << 4) ^ (output[0] >> 5)) + output[0]) ^ (sum + *(unsigned long*)(XTEA + 4 * ((sum >> 11) & 3)));
  93. sum -= delta;
  94. output[0] -= (((output[1] << 4) ^ (output[1] >> 5)) + output[1]) ^ (sum + *(unsigned long*)(XTEA + 4 * (sum & 3)));
  95. }
  96. input += 2;
  97. output += 2;
  98. ++rounds;
  99. } while ( size/8 > rounds );
  100. }
  101. return size;
  102. }
  103.  
  104. static unsigned long lzo_docompress(const unsigned char* in , unsigned long in_len, unsigned char* out, unsigned long* out_len, unsigned long ti, void* wrkmem)
  105. {
  106. register const unsigned char* ip;
  107. unsigned char* op;
  108. const unsigned char* const in_end = in + in_len;
  109. const unsigned char* const ip_end = in + in_len - 20;
  110. const unsigned char* ii;
  111. unsigned short* const dict = (unsigned short*)wrkmem;
  112.  
  113. op = out;
  114. ip = in;
  115. ii = ip;
  116.  
  117. ip += ti < 4 ? 4 - ti : 0;
  118. for (;;)
  119. {
  120. const unsigned char* m_pos;
  121. unsigned long m_off;
  122. unsigned long m_len;
  123. {
  124. int dv;
  125. unsigned long dindex;
  126. literal:
  127. ip += 1 + ((ip - ii) >> 5);
  128. next:
  129. if (ip >= ip_end)
  130. break;
  131. dv = (* (volatile const int*) (volatile const void*) (ip));
  132. dindex = ((unsigned long) (((((((unsigned long) ((0x1824429d) * (dv)))) >> (32-14))) & ( ((1u << 14) - 1) >> (0))) << (0)));
  133. m_pos = in+dict[dindex];
  134. dict[dindex] = ((unsigned short) ((unsigned long) ((ip)-(in))));
  135. if (dv != (* (volatile const int*) (volatile const void*) (m_pos)))
  136. goto literal;
  137. }
  138.  
  139. ii -= ti; ti = 0;
  140. {
  141. register unsigned long t = (unsigned long) ((ip)-(ii));
  142. if (t != 0)
  143. {
  144. if (t <= 3)
  145. {
  146. op[-2] |= (unsigned char)(t);
  147. ((* (volatile int*) (volatile void*) (op)) = (int) ((* (volatile const int*) (volatile const void*) (ii))));
  148. op += t;
  149. }
  150. else if (t <= 16)
  151. {
  152. *op++ = (unsigned char)(t - 3);
  153. ((* (volatile int*) (volatile void*) (op)) = (int) ((* (volatile const int*) (volatile const void*) (ii))));
  154. ((* (volatile int*) (volatile void*) (op+4)) = (int) ((* (volatile const int*) (volatile const void*) (ii+4))));
  155. ((* (volatile int*) (volatile void*) (op+8)) = (int) ((* (volatile const int*) (volatile const void*) (ii+8))));
  156. ((* (volatile int*) (volatile void*) (op+12)) = (int) ((* (volatile const int*) (volatile const void*) (ii+12))));
  157. op += t;
  158. }
  159. else
  160. {
  161. if (t <= 18)
  162. *op++ = (unsigned char)(t - 3);
  163. else
  164. {
  165. register unsigned long tt = t - 18;
  166. *op++ = 0;
  167. while (tt > 255)
  168. {
  169. tt -= 255;
  170. * (volatile unsigned char *) op++ = 0;
  171. }
  172. *op++ = (unsigned char)(tt);
  173. }
  174. do {
  175. ((* (volatile int*) (volatile void*) (op)) = (int) ((* (volatile const int*) (volatile const void*) (ii))));
  176. ((* (volatile int*) (volatile void*) (op+4)) = (int) ((* (volatile const int*) (volatile const void*) (ii+4))));
  177. ((* (volatile int*) (volatile void*) (op+8)) = (int) ((* (volatile const int*) (volatile const void*) (ii+8))));
  178. ((* (volatile int*) (volatile void*) (op+12)) = (int) ((* (volatile const int*) (volatile const void*) (ii+12))));
  179. op += 16; ii += 16; t -= 16;
  180. } while (t >= 16); if (t > 0)
  181. { do *op++ = *ii++; while (--t > 0); }
  182. }
  183. }
  184. }
  185. m_len = 4;
  186. {
  187. int v;
  188. v = (* (volatile const int*) (volatile const void*) (ip + m_len)) ^ (* (volatile const int*) (volatile const void*) (m_pos + m_len));
  189. if (v == 0) {
  190. do {
  191. m_len += 4;
  192. v = (* (volatile const int*) (volatile const void*) (ip + m_len)) ^ (* (volatile const int*) (volatile const void*) (m_pos + m_len));
  193. if (ip + m_len >= ip_end)
  194. goto m_len_done;
  195. } while (v == 0);
  196. }
  197. unsigned long res;
  198. m_len += res / 8;
  199. }
  200. m_len_done:
  201. m_off = (unsigned long) ((ip)-(m_pos));
  202. ip += m_len;
  203. ii = ip;
  204. if (m_len <= 8 && m_off <= 0x0800)
  205. {
  206. m_off -= 1;
  207. *op++ = (unsigned char)(((m_len - 1) << 5) | ((m_off & 7) << 2));
  208. *op++ = (unsigned char)(m_off >> 3);
  209. }
  210. else if (m_off <= 0x4000)
  211. {
  212. m_off -= 1;
  213. if (m_len <= 33)
  214. *op++ = (unsigned char)(32 | (m_len - 2));
  215. else
  216. {
  217. m_len -= 33;
  218. *op++ = 32 | 0;
  219. while (m_len > 255)
  220. {
  221. m_len -= 255;
  222. * (volatile unsigned char *) op++ = 0;
  223. }
  224. *op++ = (unsigned char)(m_len);
  225. }
  226. *op++ = (unsigned char)(m_off << 2);
  227. *op++ = (unsigned char)(m_off >> 6);
  228. }
  229. else
  230. {
  231. m_off -= 0x4000;
  232. if (m_len <= 9)
  233. *op++ = (unsigned char)(16 | ((m_off >> 11) & 8) | (m_len - 2));
  234. else
  235. {
  236. m_len -= 9;
  237. *op++ = (unsigned char)(16 | ((m_off >> 11) & 8));
  238. while (m_len > 255)
  239. {
  240. m_len -= 255;
  241. * (volatile unsigned char *) op++ = 0;
  242. }
  243. *op++ = (unsigned char)(m_len);
  244. }
  245. *op++ = (unsigned char)(m_off << 2);
  246. *op++ = (unsigned char)(m_off >> 6);
  247. }
  248. goto next;
  249. }
  250.  
  251. *out_len = (unsigned long) ((op)-(out));
  252. return (unsigned long) ((in_end)-(ii-ti));
  253. }
  254.  
  255. int lzo_compress(const unsigned char* in , unsigned long in_len, unsigned char* out, unsigned long* out_len)
  256. {
  257. const unsigned char* ip = in;
  258. unsigned char* op = out;
  259. unsigned long l = in_len;
  260. unsigned long t = 0;
  261. void* wrkmem = new void*[16384];
  262.  
  263. while (l > 20)
  264. {
  265. unsigned long ll = l;
  266. size_t ll_end;
  267. ll = ((ll) <= (49152) ? (ll) : (49152));
  268. ll_end = (size_t)ip + ll;
  269. if ((ll_end + ((t + ll) >> 5)) <= ll_end || (const unsigned char*)(ll_end + ((t + ll) >> 5)) <= ip + ll) break;
  270. memset(wrkmem, 0, ((unsigned long)1 << 14) * sizeof(unsigned short));
  271. t = lzo_docompress(ip,ll,op,out_len,t,wrkmem);
  272. ip += ll;
  273. op += *out_len;
  274. l -= ll;
  275. }
  276. t += l;
  277.  
  278. if (t > 0)
  279. {
  280. const unsigned char* ii = in + in_len - t;
  281.  
  282. if (op == out && t <= 238)
  283. *op++ = (unsigned char)(17 + t);
  284. else if (t <= 3)
  285. op[-2] |= (unsigned char)(t);
  286. else if (t <= 18)
  287. *op++ = (unsigned char)(t - 3);
  288. else
  289. {
  290. unsigned long tt = t - 18;
  291.  
  292. *op++ = 0;
  293. while (tt > 255)
  294. {
  295. tt -= 255;
  296.  
  297. * (volatile unsigned char *) op++ = 0;
  298. }
  299. *op++ = (unsigned char)(tt);
  300. }
  301. do *op++ = *ii++; while (--t > 0);
  302. }
  303.  
  304. *op++ = 16 | 1;
  305. *op++ = 0;
  306. *op++ = 0;
  307.  
  308. *out_len = (unsigned long) ((op)-(out));
  309. return LZO_E_OK;
  310. }
  311.  
  312. int lzo_decompress( const unsigned char* in , unsigned long in_len, unsigned char* out, unsigned long* out_len)
  313. {
  314. register unsigned char* op;
  315. register const unsigned char* ip;
  316. register unsigned long t;
  317. register const unsigned char* m_pos;
  318.  
  319. const unsigned char* const ip_end = in + in_len;
  320. unsigned char* const op_end = out + *out_len;
  321.  
  322. *out_len = 0;
  323.  
  324. op = out;
  325. ip = in;
  326.  
  327. if (*ip > 17)
  328. {
  329. t = *ip++ - 17;
  330. if (t < 4) goto match_next;
  331. do *op++ = *ip++; while (--t > 0);
  332. goto first_literal_run;
  333. }
  334.  
  335. while (ip < ip_end)
  336. {
  337. t = *ip++;
  338. if (t >= 16)
  339. goto match;
  340. if (t == 0)
  341. {
  342. while (*ip == 0)
  343. {
  344. t += 255;
  345. ip++;
  346. }
  347. t += 15 + *ip++;
  348. }
  349. ((* (volatile unsigned int*) (volatile void*) (op)) = (unsigned long) (* (volatile const unsigned int*) (volatile const void*) (ip)));
  350. op += 4; ip += 4;
  351. if (--t > 0)
  352. {
  353. if (t >= 4)
  354. {
  355. do {
  356. ((* (volatile unsigned int*) (volatile void*) (op)) = (unsigned long) (* (volatile const unsigned int*) (volatile const void*) (ip)));
  357. op += 4; ip += 4; t -= 4;
  358. } while (t >= 4);
  359. if (t > 0) do *op++ = *ip++; while (--t > 0);
  360. }
  361. else
  362. do *op++ = *ip++; while (--t > 0);
  363. }
  364.  
  365. first_literal_run:
  366.  
  367. t = *ip++;
  368. if (t >= 16) goto match;
  369. m_pos = op - (1 + 0x0800);
  370. m_pos -= t >> 2;
  371. m_pos -= *ip++ << 2;
  372. *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
  373. goto match_done;
  374.  
  375. do {
  376. match:
  377. if (t >= 64)
  378. {
  379. m_pos = op - 1;
  380. m_pos -= (t >> 2) & 7;
  381. m_pos -= *ip++ << 3;
  382. t = (t >> 5) - 1;
  383. goto copy_match;
  384. }
  385. else if (t >= 32)
  386. {
  387. t &= 31;
  388. if (t == 0)
  389. {
  390. while (*ip == 0)
  391. {
  392. t += 255;
  393. ip++;
  394. }
  395. t += 31 + *ip++;
  396. }
  397. m_pos = op - 1;
  398. m_pos -= (* (volatile const unsigned short*) (volatile const void*) (ip)) >> 2;
  399. ip += 2;
  400. }
  401. else if (t >= 16)
  402. {
  403. m_pos = op;
  404. m_pos -= (t & 8) << 11;
  405. t &= 7;
  406. if (t == 0)
  407. {
  408. while (*ip == 0)
  409. {
  410. t += 255;
  411. ip++;
  412. }
  413. t += 7 + *ip++;
  414. }
  415. m_pos -= (* (volatile const unsigned short*) (volatile const void*) (ip)) >> 2;
  416. ip += 2;
  417. if (m_pos == op)
  418. goto eof_found;
  419. m_pos -= 0x4000;
  420. }
  421. else
  422. {
  423. m_pos = op - 1;
  424. m_pos -= t >> 2;
  425. m_pos -= *ip++ << 2;
  426. *op++ = *m_pos++; *op++ = *m_pos;
  427. goto match_done;
  428. }
  429.  
  430. if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
  431. {
  432. ((* (volatile unsigned int*) (volatile void*) (op)) = (unsigned long) (* (volatile const unsigned int*) (volatile const void*) (m_pos)));
  433. op += 4; m_pos += 4; t -= 4 - (3 - 1);
  434. do {
  435. ((* (volatile unsigned int*) (volatile void*) (op)) = (unsigned long) (* (volatile const unsigned int*) (volatile const void*) (m_pos)));
  436. op += 4; m_pos += 4; t -= 4;
  437. } while (t >= 4);
  438. if (t > 0) do *op++ = *m_pos++; while (--t > 0);
  439. }
  440. else
  441. {
  442. copy_match:
  443. *op++ = *m_pos++; *op++ = *m_pos++;
  444. do *op++ = *m_pos++; while (--t > 0);
  445. }
  446.  
  447.  
  448. match_done:
  449. t = ip[-2] & 3;
  450. if (t == 0)
  451. break;
  452.  
  453. match_next:
  454. *op++ = *ip++;
  455. if (t > 1) {
  456. *op++ = *ip++;
  457. if (t > 2)
  458. {
  459. *op++ = *ip++;
  460. }
  461. }
  462. t = *ip++;
  463. } while (ip < ip_end);
  464. }
  465. *out_len = ((unsigned long) ((op)-(out)));
  466. return LZO_E_EOF_NOT_FOUND;
  467.  
  468. eof_found:
  469. *out_len = ((unsigned long) ((op)-(out)));
  470. return (ip == ip_end ? LZO_E_OK :
  471. (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
  472. }
  473.  
  474. static const int crctable[] = {
  475. 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
  476. 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
  477. 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
  478. 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
  479. 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
  480. 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
  481. 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
  482. 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
  483. 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
  484. 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
  485. 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
  486. 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
  487. 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
  488. 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
  489. 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
  490. 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
  491. 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
  492. 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
  493. 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
  494. 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
  495. 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
  496. 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
  497. 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
  498. 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
  499. 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
  500. 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
  501. 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
  502. 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
  503. 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
  504. 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
  505. 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
  506. 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
  507. 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
  508. 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
  509. 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
  510. 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
  511. 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
  512. 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
  513. 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
  514. 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
  515. 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
  516. 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
  517. 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
  518. 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
  519. 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
  520. 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
  521. 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
  522. 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
  523. 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
  524. 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
  525. 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
  526. 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
  527. 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
  528. 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
  529. 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
  530. 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
  531. 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
  532. 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
  533. 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
  534. 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
  535. 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
  536. 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
  537. 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
  538. 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
  539. };
  540.  
  541. unsigned long CRC32(unsigned char* buffer, int size) {
  542. unsigned long crc = 0xffffffff;
  543. for (int i = 0; i < size; i++) crc = (crc >> 8) ^ crctable[buffer[i] ^ crc & 0x000000FF];
  544. return ~crc;
  545. }
  546.  
  547. void pause()
  548. {
  549. printf("Press a key to continue...\n");
  550. getch();
  551. }
  552.  
  553. int main(int argc, char * argv[])
  554. {
  555. printf("Metin2 File Tool By balika011\nVersion: 1.1\n\nThanks to:\n Memory leak fix, r26+ type2 --> tim66613\n Used sources --> pushedx, wikipedia, Markus F.X.J. Oberhumer\n\n");
  556.  
  557. if(argc != 2)
  558. {
  559. std::string exename = argv[0];
  560. exename = exename.substr(exename.find_last_of("\\") + 1, exename.find_last_of(".") - exename.find_last_of("\\") - 1);
  561. printf("Usage: %s <.dat file>\n\nunpack:\n unpack|pack_name|out_folder|out_dat_name\npack:\n pack|pack_name\n\tfile_name|file_path|file_type\ncomment:\n start line whit \"--\"\n", exename.c_str());
  562. pause();
  563. return -1;
  564. }
  565.  
  566. std::ifstream myfile(argv[1]);
  567. if (myfile.is_open())
  568. {
  569. while(1)
  570. {
  571. std::string line;
  572. std::getline(myfile,line);
  573. LAB1:
  574. if(strlen(line.c_str()) == 0 || line.substr(0, 2) == "--") if(!myfile.good()) break; else continue;
  575. if(line.substr(0, 4) == "pack")
  576. {
  577. if(strlen(line.c_str())-5 < 1) continue;
  578. std::string outfile = line.substr(5, strlen(line.c_str())-5);
  579. bool agin = 0;
  580. std::string file[9999];
  581. std::string path[9999];
  582. int type[9999];
  583. int filecount = 0;
  584. while(1)
  585. {
  586. std::getline(myfile,line);
  587. if(strlen(line.c_str()) == 0 || line.substr(0, 2) == "--") if(!myfile.good()) break; else continue;
  588. if(line.substr(0, 1) != "\t")
  589. {
  590. agin = 1;
  591. break;
  592. }
  593. if(strlen(line.c_str())-1 < 1 || line.substr(2, 3) == "--") if(!myfile.good()) break; else continue;
  594. std::string filename = line.substr(1, strlen(line.c_str())-1);
  595. file[filecount] = strtok((char*)(filename.c_str()),"|");
  596. path[filecount] = strtok(NULL, "|");
  597. type[filecount] = atoi(strtok(NULL, "|"));
  598. ++filecount;
  599. if(!myfile.good()) break;
  600. }
  601. unsigned char* eixdecompressedBuffer = new unsigned char[0x0C + filecount * IndexBlockSize];
  602. memset(eixdecompressedBuffer, 0, 0x0C + filecount * IndexBlockSize);
  603.  
  604. eixdecompressedBuffer += 0x0C;
  605.  
  606. unsigned char* epkBuffer = new unsigned char[536870911]; //512MB
  607.  
  608. int lastoffset = 0;
  609. int donefiles = 0;
  610. for(int i=0; i < filecount; ++i) {
  611. unsigned char* Buffer;
  612. unsigned long Size;
  613.  
  614. FILE* File = fopen(path[i].c_str() , "rb" );
  615. if (File == NULL) {
  616. printf("Could not open %s file.\n", path[i].c_str());
  617. if(agin) goto LAB1; else return 0;
  618. }
  619. fseek(File , 0 , SEEK_END);
  620. Size = ftell(File);
  621. rewind(File);
  622. Buffer = new unsigned char[Size];
  623. if (Buffer == NULL) {
  624. printf("Memory error when make buffer for %s file.\n", path[i].c_str());
  625. if(agin) goto LAB1; else return 0;
  626. }
  627. if (fread(Buffer,1,Size,File) != Size) {
  628. printf("Could not read %s file.\n", path[i].c_str());
  629. if(agin) goto LAB1; else return 0;
  630. }
  631. fclose(File);
  632.  
  633. *(unsigned long*)eixdecompressedBuffer = i;
  634. memcpy(eixdecompressedBuffer + 4, file[i].c_str(), strlen(file[i].c_str()));
  635. *(unsigned long*)(eixdecompressedBuffer + 168) = CRC32((unsigned char*)file[i].c_str(),strlen(file[i].c_str()));
  636. *(unsigned long*)(eixdecompressedBuffer + 184) = lastoffset;
  637. *(unsigned char*)(eixdecompressedBuffer + 188) = type[i];
  638.  
  639. if(type[i] == 0){
  640. *(unsigned long*)(eixdecompressedBuffer + 172) = Size;
  641. *(unsigned long*)(eixdecompressedBuffer + 176) = Size;
  642. *(unsigned long*)(eixdecompressedBuffer + 180) = CRC32(Buffer, Size);
  643. memset(epkBuffer + lastoffset, 0, Size);
  644. memcpy(epkBuffer + lastoffset, Buffer, Size);
  645. lastoffset += Size;
  646. }
  647. else if(type[i] == 1){
  648. unsigned char* compressedBuffer = new unsigned char[Size + (Size / 16) + 64 + 3 + 20];
  649. memset(compressedBuffer, 0, Size + (Size / 16) + 64 + 3 + 20);
  650.  
  651. unsigned long compSize = 0;
  652. if(lzo_compress(Buffer, Size, compressedBuffer + 20, &compSize) != LZO_E_OK)
  653. {
  654. printf("Error when compressing %s.\n", file[i].c_str());
  655. delete [] compressedBuffer;
  656. pause();
  657. if(agin) goto LAB1; else return 0;
  658. }
  659.  
  660. *(unsigned long*)compressedBuffer = FourCC;
  661. *(unsigned long*)(compressedBuffer + 8) = compSize;
  662. *(unsigned long*)(compressedBuffer + 12) = Size;
  663. *(unsigned long*)(compressedBuffer + 16) = FourCC;
  664.  
  665. memset(epkBuffer + lastoffset, 0, compSize + 20);
  666. memcpy(epkBuffer + lastoffset, compressedBuffer, compSize + 20);
  667.  
  668. *(unsigned long*)(eixdecompressedBuffer + 172) = Size;
  669. *(unsigned long*)(eixdecompressedBuffer + 176) = compSize + 4;
  670. *(unsigned long*)(eixdecompressedBuffer + 180) = CRC32(Buffer, Size);
  671. lastoffset += compSize + 20;
  672. delete[] compressedBuffer;
  673. }
  674. else if(type[i] == 2)
  675. {
  676. unsigned char* compressedBuffer = new unsigned char[Size + (Size / 16) + 64 + 3 + 4];
  677. memset(compressedBuffer, 0, Size + (Size / 16) + 64 + 3 + 4);
  678.  
  679. unsigned long compSize = 0;
  680. if(lzo_compress(Buffer, Size, compressedBuffer + 4, &compSize) != LZO_E_OK)
  681. {
  682. printf("Error when compressing %s.\n", file[i].c_str());
  683. delete [] compressedBuffer;
  684. pause();
  685. if(agin) goto LAB1; else return 0;
  686. }
  687. *(unsigned long*)compressedBuffer = FourCC;
  688.  
  689. unsigned char* encryptedBuffer = new unsigned char[compSize + 4 + 7];
  690. memset(encryptedBuffer, 0, compSize + 4 + 7);
  691.  
  692. unsigned long cryptSize = XteaEncrypt((unsigned long*)encryptedBuffer, (unsigned long*)compressedBuffer, DataXTEA, compSize + 4);
  693.  
  694. memset(epkBuffer + lastoffset, 0, cryptSize + 16);
  695. *(unsigned long*)(epkBuffer + lastoffset) = FourCC;
  696. *(unsigned long*)(epkBuffer + lastoffset + 4) = cryptSize;
  697. *(unsigned long*)(epkBuffer + lastoffset + 8) = compSize;
  698. *(unsigned long*)(epkBuffer + lastoffset + 12) = Size;
  699. memcpy(epkBuffer + lastoffset + 16, encryptedBuffer, cryptSize);
  700.  
  701.  
  702. *(unsigned long*)(eixdecompressedBuffer + 172) = 512 + (512 / (cryptSize + 16));
  703. *(unsigned long*)(eixdecompressedBuffer + 176) = cryptSize;
  704. *(unsigned long*)(eixdecompressedBuffer + 180) = CRC32(epkBuffer + lastoffset, cryptSize);
  705. lastoffset += cryptSize + 16;
  706. delete[] compressedBuffer;
  707. delete[] encryptedBuffer;
  708. }
  709. else
  710. {
  711. printf("type %i is unsupported\n", type[i]);
  712. delete [] Buffer;
  713. continue;
  714. }
  715. eixdecompressedBuffer += IndexBlockSize;
  716. ++donefiles;
  717. delete [] Buffer;
  718. }
  719.  
  720. unsigned long eixdecompressedSize = 0x0C + donefiles * IndexBlockSize;
  721. eixdecompressedBuffer -= eixdecompressedSize;
  722.  
  723. *(unsigned long*)eixdecompressedBuffer = IndexHeader;
  724. *(unsigned long*)(eixdecompressedBuffer + 4) = IndexVersion;
  725. *(unsigned long*)(eixdecompressedBuffer + 8) = donefiles;
  726.  
  727. unsigned char* compressedBuffer = new unsigned char[eixdecompressedSize + (eixdecompressedSize / 16) + 64 + 3 + 4];
  728. memset(compressedBuffer, 0, eixdecompressedSize + (eixdecompressedSize / 16) + 64 + 3 + 4);
  729.  
  730. unsigned long compSize = 0;
  731. if(lzo_compress(eixdecompressedBuffer, eixdecompressedSize, compressedBuffer + 4, &compSize) != LZO_E_OK)
  732. {
  733. printf("Error when compressing index.\n");
  734. delete [] compressedBuffer;
  735. pause();
  736. if(agin) goto LAB1; else return 0;
  737. }
  738. *(unsigned long*)compressedBuffer = FourCC;
  739.  
  740. unsigned char* encryptedBuffer = new unsigned char[compSize + 4];
  741. memset(encryptedBuffer, 0, compSize + 4);
  742.  
  743. unsigned long cryptSize = XteaEncrypt((unsigned long*)encryptedBuffer, (unsigned long*)compressedBuffer, IndexXTEA, compSize + 4);
  744.  
  745. unsigned char* DoneBuffer = new unsigned char[cryptSize + 16];
  746. memset(DoneBuffer, 0, cryptSize + 16);
  747. *(unsigned long*)DoneBuffer = FourCC;
  748. *(unsigned long*)(DoneBuffer + 4) = cryptSize;
  749. *(unsigned long*)(DoneBuffer + 8) = compSize;
  750. *(unsigned long*)(DoneBuffer + 12) = eixdecompressedSize;
  751. memcpy(DoneBuffer + 16, encryptedBuffer, cryptSize);
  752.  
  753. FILE * indexof = fopen((outfile + IndexName).c_str(), "wb");
  754. if(indexof)
  755. {
  756. fwrite(DoneBuffer, 1, cryptSize + 16, indexof);
  757. fclose(indexof);
  758. }
  759.  
  760. FILE * dataof = fopen((outfile + DataName).c_str(), "wb");
  761. if(dataof)
  762. {
  763. fwrite(epkBuffer, 1, lastoffset + 16, dataof);
  764. fclose(dataof);
  765. }
  766.  
  767. printf("Done!\n");
  768. if(agin) goto LAB1;
  769. }
  770. else if(line.substr(0, 6) == "unpack")
  771. {
  772. if(strlen(line.c_str())-7 < 1) continue;
  773. std::string in = line.substr(7, strlen(line.c_str())-7);
  774. char* infile = strtok((char*)(in.c_str()),"|");
  775. std::string outfolder = strtok(NULL, "|");
  776. char* outfile = strtok(NULL, "|");
  777.  
  778. std::string eixName_ = (std::string)infile + IndexName;
  779. std::string epkName_ = (std::string)infile + DataName;
  780. const char * eixName = eixName_.c_str();
  781. const char * epkName = epkName_.c_str();
  782.  
  783. unsigned char* eixBuffer;
  784. unsigned long eixSize;
  785.  
  786. FILE* eixFile = fopen(eixName , "rb" );
  787. if (eixFile == NULL) {
  788. printf("Could not open %s file.\n", eixName);
  789. if(!myfile.good()) {pause(); return 0;} else goto LAB1;
  790. }
  791. fseek(eixFile , 0 , SEEK_END);
  792. eixSize = ftell(eixFile);
  793. rewind(eixFile);
  794. eixBuffer = new unsigned char[eixSize];
  795. if (eixBuffer == NULL) {
  796. printf("Memory error when make buffer for %s file.\n", eixName);
  797. if(!myfile.good()) {pause(); return 0;} else goto LAB1;
  798. }
  799. if (fread(eixBuffer,1,eixSize,eixFile) != eixSize) {
  800. printf("Could not read %s file.\n", eixName);
  801. if(!myfile.good()) {pause(); return 0;} else goto LAB1;
  802. }
  803. fclose(eixFile);
  804.  
  805. unsigned char* epkBuffer;
  806. unsigned long epkSize;
  807.  
  808. FILE* epkFile = fopen(epkName , "rb" );
  809. if (epkFile == NULL) {
  810. printf("Could not open %s file.\n", epkName);
  811. if(!myfile.good()) {pause(); return 0;} else goto LAB1;
  812. }
  813. fseek(epkFile , 0 , SEEK_END);
  814. epkSize = ftell(epkFile);
  815. rewind(epkFile);
  816. epkBuffer = new unsigned char[epkSize];
  817. if (epkBuffer == NULL) {
  818. printf("Memory error when make buffer for %s file.\n", epkName);
  819. if(!myfile.good()) {pause(); return 0;} else goto LAB1;
  820. }
  821. if (fread(epkBuffer,1,epkSize,epkFile) != epkSize) {
  822. printf("Could not read %s file.\n", epkName);
  823. if(!myfile.good()) {pause(); return 0;} else goto LAB1;
  824. }
  825. fclose(epkFile);
  826.  
  827. if(eixSize < 0x0C)
  828. {
  829. printf("The file size for the %s file is too small. The program will now exit.\n", eixName);
  830. pause();
  831. if(!myfile.good()) {pause(); return 0;} else goto LAB1;
  832. }
  833.  
  834. unsigned char* eixdecompressedBuffer;
  835. unsigned long eixdecompressedSize;
  836.  
  837. if (*(unsigned long*)eixBuffer != IndexHeader)
  838. {
  839. unsigned long eixheader = *(unsigned long*)eixBuffer;
  840. unsigned long eixcryptedSize = *(unsigned long*)(eixBuffer + 4);
  841. unsigned long eixcompressedSize = *(unsigned long*)(eixBuffer + 8);
  842. eixdecompressedSize = *(unsigned long*)(eixBuffer + 12);
  843.  
  844. if (eixheader != FourCC)
  845. {
  846. printf("The FourCC of %s is incorrect.\n", eixName);
  847. pause();
  848. if(!myfile.good()) return 0; else goto LAB1;
  849. }
  850.  
  851. if(eixcryptedSize == 0)
  852. {
  853. printf("[TODO] -- Index of %s is not encrypted!\n", eixName);
  854. pause();
  855. if(!myfile.good()) return 0; else goto LAB1;
  856. }
  857.  
  858. unsigned char* eixcompressedBuffer = new unsigned char[eixcryptedSize];
  859. memset(eixcompressedBuffer, 0, eixcryptedSize);
  860.  
  861. XteaDecrypt((unsigned long*)eixcompressedBuffer, (unsigned long*)(eixBuffer + 0x10), IndexXTEA, eixcryptedSize);
  862. if(*(unsigned long*)eixcompressedBuffer != FourCC)
  863. {
  864. delete [] eixcompressedBuffer;
  865. printf("The XTEA Key of %s is incorrect.\n", eixName);
  866. pause();
  867. if(!myfile.good()) return 0; else goto LAB1;
  868. }
  869.  
  870. eixdecompressedBuffer = new unsigned char[eixdecompressedSize];
  871. memset(eixdecompressedBuffer, 0, eixdecompressedSize);
  872.  
  873. unsigned long finalSize = 0;
  874. if(lzo_decompress(eixcompressedBuffer + 4, eixcompressedSize, eixdecompressedBuffer, &finalSize) != LZO_E_OK || finalSize != eixdecompressedSize)
  875. {
  876. delete [] eixdecompressedBuffer;
  877. delete [] eixcompressedBuffer;
  878. printf("There was an error when decompressing %s.\n", eixName);
  879. if(!myfile.good()) return 0; else goto LAB1;
  880. }
  881. delete [] eixcompressedBuffer;
  882. }
  883. else
  884. {
  885. eixdecompressedBuffer = eixBuffer + 4;
  886. eixdecompressedSize = eixSize - 4;
  887. }
  888.  
  889. unsigned long eixheader2 = *(unsigned long*)eixdecompressedBuffer;
  890. unsigned long eixversion = *(unsigned long*)(eixdecompressedBuffer + 4);
  891. unsigned long eixfileCount = *(unsigned long*)(eixdecompressedBuffer + 8);
  892.  
  893. if(eixversion != IndexVersion)
  894. {
  895. delete [] eixdecompressedBuffer;
  896. printf("The version of %s file is incorrect. Found: %i Supported: %i).\n", eixName, eixversion, IndexVersion);
  897. pause();
  898. if(!myfile.good()) return 0; else goto LAB1;
  899. }
  900.  
  901. std::string filename = ((std::string)infile).substr(1 + ((std::string)infile).find_last_of("\\/"));
  902.  
  903. eixdecompressedBuffer += 0x0C;
  904.  
  905. FILE * of = fopen(outfile, "w");
  906. if(!of)
  907. {
  908. printf("There was an error creating %s file.\n", "name");
  909. pause();
  910. if(!myfile.good()) return 0; else goto LAB1;
  911. }
  912. if(of) fprintf(of, "pack|%s\n", infile);
  913.  
  914. for(unsigned long x = 0; x < eixfileCount; ++x)
  915. {
  916. unsigned long index = *(unsigned long*)eixdecompressedBuffer;
  917. char filename[160];
  918. memcpy(filename,eixdecompressedBuffer + 4,160);
  919. unsigned long filenameCRC = *(unsigned long*)(eixdecompressedBuffer + 168);
  920. unsigned long dw3 = *(unsigned long*)(eixdecompressedBuffer + 172);
  921. unsigned long dwSrcSize = *(unsigned long*)(eixdecompressedBuffer + 176);
  922. unsigned long unpackedCRC = *(unsigned long*)(eixdecompressedBuffer + 180);
  923. unsigned long dwFileOffset = *(unsigned long*)(eixdecompressedBuffer + 184);
  924. unsigned char packedType = *(unsigned char*)(eixdecompressedBuffer + 188);
  925. eixdecompressedBuffer += IndexBlockSize;
  926. std::string outfilename;
  927. if(packedType == 0)
  928. {
  929. std::stringstream dirPath;
  930. std::vector<std::string> pathTokens;
  931. size_t p0 = 0, p1 = std::string::npos;
  932. while(p0 != std::string::npos)
  933. {
  934. p1 = ((const std::string&)filename).find_first_of("\\/", p0);
  935. if(p1 != p0)
  936. {
  937. std::string token = ((const std::string&)filename).substr(p0, p1 - p0);
  938. pathTokens.push_back(token);
  939. }
  940. p0 = ((const std::string&)filename).find_first_not_of("\\/", p1);
  941. }
  942. dirPath << outfolder;
  943. mkfolder(dirPath.str().c_str());
  944. dirPath << "\\";
  945. size_t index = 0;
  946. for(index = 0; index < pathTokens.size() - 1; ++index)
  947. {
  948. if(pathTokens[index].find_first_of(":") != std::string::npos)
  949. continue;
  950. dirPath << pathTokens[index];
  951. mkfolder(dirPath.str().c_str());
  952. dirPath << "\\";
  953. }
  954. dirPath << pathTokens[index];
  955. outfilename = dirPath.str();
  956. FILE * of = fopen(outfilename.c_str(), "wb");
  957. if(!of)
  958. {
  959. std::string buff = outfolder + "\\crashfile" + (char)crashi;
  960. ++crashi;
  961. of = fopen(buff.c_str(), "wb");
  962. printf("Crash file %s saved as: %s\n", outfilename.c_str(), buff.c_str());
  963. outfilename = buff;
  964. }
  965. if(of)
  966. {
  967. fwrite(epkBuffer + dwFileOffset, 1, dwSrcSize, of);
  968. fclose(of);
  969. }
  970. else
  971. {
  972. printf("Could not save the file %s\n", outfilename.c_str());
  973. }
  974. }
  975. else if(packedType == 1)
  976. {
  977. unsigned long dataheader = *(unsigned long*)(epkBuffer + dwFileOffset);
  978. unsigned long datacryptedSize = *(unsigned long*)(epkBuffer + dwFileOffset + 4);
  979. unsigned long datacompressedSize = *(unsigned long*)(epkBuffer + dwFileOffset + 8);
  980. unsigned long datadecompressedSize = *(unsigned long*)(epkBuffer + dwFileOffset + 12);
  981.  
  982. if(dataheader != FourCC)
  983. {
  984. printf("The FourCC is incorrect of %s.\n", filename);
  985. continue;
  986. }
  987.  
  988. unsigned char* datauncompressedBuffer = new unsigned char[datadecompressedSize];
  989. memset(datauncompressedBuffer, 0, datadecompressedSize);
  990.  
  991. unsigned long finalSize = 0;
  992. if(lzo_decompress(epkBuffer + dwFileOffset + 16 + 4, datacompressedSize, datauncompressedBuffer, &finalSize) == LZO_E_OK && finalSize == datadecompressedSize)
  993. {
  994. std::stringstream dirPath;
  995. std::vector<std::string> pathTokens;
  996. size_t p0 = 0, p1 = std::string::npos;
  997. while(p0 != std::string::npos)
  998. {
  999. p1 = ((const std::string&)filename).find_first_of("\\/", p0);
  1000. if(p1 != p0)
  1001. {
  1002. std::string token = ((const std::string&)filename).substr(p0, p1 - p0);
  1003. pathTokens.push_back(token);
  1004. }
  1005. p0 = ((const std::string&)filename).find_first_not_of("\\/", p1);
  1006. }
  1007. dirPath << outfolder;
  1008. mkfolder(dirPath.str().c_str());
  1009. dirPath << "\\";
  1010. size_t index = 0;
  1011. for(index = 0; index < pathTokens.size() - 1; ++index)
  1012. {
  1013. if(pathTokens[index].find_first_of(":") != std::string::npos)
  1014. continue;
  1015. dirPath << pathTokens[index];
  1016. mkfolder(dirPath.str().c_str());
  1017. dirPath << "\\";
  1018. }
  1019. dirPath << pathTokens[index];
  1020. outfilename = dirPath.str();
  1021. FILE * of = fopen(outfilename.c_str(), "wb");
  1022. if(!of)
  1023. {
  1024. std::string buff = outfolder + "\\crashfile" + (char)crashi;
  1025. ++crashi;
  1026. of = fopen(buff.c_str(), "wb");
  1027. printf("Crash file %s saved as: %s\n", outfilename.c_str(), buff.c_str());
  1028. outfilename = buff;
  1029. }
  1030. if(of)
  1031. {
  1032. fwrite(datauncompressedBuffer, 1, datadecompressedSize, of);
  1033. fclose(of);
  1034. }
  1035. else
  1036. {
  1037. printf("Could not save the file %s\n", outfilename.c_str());
  1038. }
  1039. }
  1040. else
  1041. {
  1042. printf("There was an error when decompressing %s file.\n", filename);
  1043. }
  1044.  
  1045. delete [] datauncompressedBuffer;
  1046. }
  1047. else if(packedType == 2)
  1048. {
  1049. unsigned long dataheader = *(unsigned long*)(epkBuffer + dwFileOffset);
  1050. unsigned long datacryptedSize = *(unsigned long*)(epkBuffer + dwFileOffset + 4);
  1051. unsigned long datacompressedSize = *(unsigned long*)(epkBuffer + dwFileOffset + 8);
  1052. unsigned long datadecompressedSize = *(unsigned long*)(epkBuffer + dwFileOffset + 12);
  1053.  
  1054. if(dataheader != FourCC)
  1055. {
  1056. printf("The FourCC is incorrect of %s.\n", filename);
  1057. continue;
  1058. }
  1059.  
  1060. unsigned char* datadecryptedBuffer = new unsigned char[datacryptedSize];
  1061. memset(datadecryptedBuffer, 0, datacryptedSize);
  1062.  
  1063. XteaDecrypt((unsigned long*)datadecryptedBuffer, (unsigned long*)(epkBuffer + dwFileOffset + 16), DataXTEA, datacryptedSize);
  1064. if(*(unsigned long*)datadecryptedBuffer != FourCC)
  1065. {
  1066. printf("There was an error decrypting the data for the %s file. It will be skipped.\n", filename);
  1067. delete [] datadecryptedBuffer;
  1068. continue;
  1069. }
  1070.  
  1071. unsigned char* datauncompressedBuffer = new unsigned char[datadecompressedSize];
  1072. memset(datauncompressedBuffer, 0, datadecompressedSize);
  1073.  
  1074. unsigned long finalSize = 0;
  1075. if(lzo_decompress(datadecryptedBuffer + 4, datacompressedSize, datauncompressedBuffer, &finalSize) == LZO_E_OK && finalSize == datadecompressedSize)
  1076. {
  1077. std::stringstream dirPath;
  1078. std::vector<std::string> pathTokens;
  1079. size_t p0 = 0, p1 = std::string::npos;
  1080. while(p0 != std::string::npos)
  1081. {
  1082. p1 = ((const std::string&)filename).find_first_of("\\/", p0);
  1083. if(p1 != p0)
  1084. {
  1085. std::string token = ((const std::string&)filename).substr(p0, p1 - p0);
  1086. pathTokens.push_back(token);
  1087. }
  1088. p0 = ((const std::string&)filename).find_first_not_of("\\/", p1);
  1089. }
  1090. dirPath << outfolder;
  1091. mkfolder(dirPath.str().c_str());
  1092. dirPath << "\\";
  1093. size_t index = 0;
  1094. for(index = 0; index < pathTokens.size() - 1; ++index)
  1095. {
  1096. if(pathTokens[index].find_first_of(":") != std::string::npos)
  1097. continue;
  1098. dirPath << pathTokens[index];
  1099. mkfolder(dirPath.str().c_str());
  1100. dirPath << "\\";
  1101. }
  1102. dirPath << pathTokens[index];
  1103. outfilename = dirPath.str();
  1104. FILE * of = fopen(outfilename.c_str(), "wb");
  1105. if(!of)
  1106. {
  1107. std::string buff = outfolder + "\\crashfile" + (char)crashi;
  1108. ++crashi;
  1109. of = fopen(buff.c_str(), "wb");
  1110. printf("Crash file %s saved as: %s\n", outfilename.c_str(), buff.c_str());
  1111. outfilename = buff;
  1112. }
  1113. if(of)
  1114. {
  1115. fwrite(datauncompressedBuffer, 1, datadecompressedSize, of);
  1116. fclose(of);
  1117. }
  1118. else
  1119. {
  1120. printf("Could not save the file %s\n", outfilename.c_str());
  1121. }
  1122. }
  1123. else
  1124. {
  1125. printf("There was an error when decompressing %s file.\n", filename);
  1126. }
  1127.  
  1128. delete [] datadecryptedBuffer;
  1129. delete [] datauncompressedBuffer;
  1130. }
  1131. else
  1132. {
  1133. printf("Unsupported type: %i (%s).\n", packedType, filename);
  1134. continue;
  1135. }
  1136. fprintf(of, "\t%s|%s|%i\n", filename, outfilename.c_str(), packedType);
  1137. }
  1138. fclose(of);
  1139. printf("Done!\n");
  1140. }
  1141. else printf("dat file error!\n");
  1142. if(!myfile.good()) break;
  1143. }
  1144. printf("All done!\n");
  1145. myfile.close();
  1146. }
  1147. else printf("%s file not found!\n", argv[1]);
  1148.  
  1149. pause();
  1150. return 0;
  1151. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:7:15: warning: extra tokens at end of #ifdef directive [enabled by default]
 #ifdef _WIN32 || _WIN64
               ^
prog.cpp: In function ‘int lzo_compress(const unsigned char*, long unsigned int, unsigned char*, long unsigned int*)’:
prog.cpp:270:76: error: ‘memset’ was not declared in this scope
         memset(wrkmem, 0, ((unsigned long)1 << 14) * sizeof(unsigned short));
                                                                            ^
prog.cpp: In function ‘int lzo_decompress(const unsigned char*, long unsigned int, unsigned char*, long unsigned int*)’:
prog.cpp:320:26: warning: unused variable ‘op_end’ [-Wunused-variable]
     unsigned char* const op_end = out + *out_len;
                          ^
prog.cpp: At global scope:
prog.cpp:539:1: warning: narrowing conversion of ‘3993919788u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
 };
 ^
prog.cpp:539:1: warning: narrowing conversion of ‘2567524794u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3915621685u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2657392035u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3772115230u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2547177864u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3887607047u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2428444049u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4089016648u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2227061214u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4107580753u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2211677639u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4251122042u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2321926636u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4195302755u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2366115317u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3579855332u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2724688242u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3524101629u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2768942443u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3686517206u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2898065728u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3705015759u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2882616665u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3369554304u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3218104598u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3485111705u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3099436303u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3322730930u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2970347812u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3244367275u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3060149565u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2563907772u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4023717930u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2680153253u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3904427059u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2517215374u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3775830040u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2439277719u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3865271297u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2238001368u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4066508878u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2181625025u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4111451223u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2344532202u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4240017532u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2362670323u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4224994405u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2747007092u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3569037538u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2765210733u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3554079995u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2909243462u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3663771856u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2852801631u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3708648649u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3188396048u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3373015174u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3110523913u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3462522015u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2966460450u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3352799412u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3082640443u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3233442989u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3988292384u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2596254646u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3939845945u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2647816111u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3814918930u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2489596804u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3826175755u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2466906013u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4027552580u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2265490386u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4150417245u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2154129355u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4275313526u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2312317920u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4189708143u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2394877945u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3604390888u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2714866558u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3518719985u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2797360999u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3624741850u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2936675148u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3747672003u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2825379669u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3412177804u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3160834842u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3423369109u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3138078467u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3317316542u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2998733608u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3268935591u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3050360625u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2607071920u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3965973030u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2617837225u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3943577151u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2512341634u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3803740692u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2463272603u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3855990285u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2262029012u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4057260610u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2176718541u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4139329115u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2282248934u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4279200368u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2405801727u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘4167216745u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2685067896u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3608007406u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2808555105u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3495958263u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2932959818u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3654703836u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘2847714899u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3736837829u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3183342108u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3401237130u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3134207493u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3453421203u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3009837614u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3294710456u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3020668471u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp:539:1: warning: narrowing conversion of ‘3272380065u’ from ‘unsigned int’ to ‘const int’ inside { } is ill-formed in C++11 [-Wnarrowing]
prog.cpp: In function ‘long unsigned int CRC32(unsigned char*, int)’:
prog.cpp:543:80: warning: suggest parentheses around arithmetic in operand of ‘^’ [-Wparentheses]
     for (int i = 0; i < size; i++) crc = (crc >> 8) ^ crctable[buffer[i] ^ crc & 0x000000FF];
                                                                                ^
prog.cpp: In function ‘void pause()’:
prog.cpp:547:12: error: new declaration ‘void pause()’
 void pause()
            ^
In file included from prog.cpp:17:0:
/usr/include/unistd.h:469:12: error: ambiguates old declaration ‘int pause()’
 extern int pause (void);
            ^
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:574:35: error: ‘strlen’ was not declared in this scope
             if(strlen(line.c_str()) == 0 || line.substr(0, 2) == "--") if(!myfile.good()) break; else continue;
                                   ^
prog.cpp:574:15: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
             if(strlen(line.c_str()) == 0 || line.substr(0, 2) == "--") if(!myfile.good()) break; else continue;
               ^
prog.cpp:577:39: error: ‘strlen’ was not declared in this scope
                 if(strlen(line.c_str())-5 < 1) continue;
                                       ^
prog.cpp:578:73: error: ‘strlen’ was not declared in this scope
                 std::string outfile = line.substr(5, strlen(line.c_str())-5);
                                                                         ^
prog.cpp:587:23: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
                     if(strlen(line.c_str()) == 0 || line.substr(0, 2) == "--") if(!myfile.good()) break; else continue;
                       ^
prog.cpp:593:23: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
                     if(strlen(line.c_str())-1 < 1 || line.substr(2, 3) == "--") if(!myfile.good()) break; else continue;
                       ^
prog.cpp:595:75: error: ‘strtok’ was not declared in this scope
                     file[filecount] = strtok((char*)(filename.c_str()),"|");
                                                                           ^
prog.cpp:597:61: error: ‘atoi’ was not declared in this scope
                     type[filecount] = atoi(strtok(NULL, "|"));
                                                             ^
prog.cpp:602:83: error: ‘memset’ was not declared in this scope
                 memset(eixdecompressedBuffer, 0, 0x0C + filecount * IndexBlockSize);
                                                                                   ^
prog.cpp:634:95: error: ‘memcpy’ was not declared in this scope
                     memcpy(eixdecompressedBuffer + 4, file[i].c_str(), strlen(file[i].c_str()));
                                                                                               ^
prog.cpp:751:67: error: ‘memcpy’ was not declared in this scope
                 memcpy(DoneBuffer + 16, encryptedBuffer, cryptSize);
                                                                   ^
prog.cpp:772:39: error: ‘strlen’ was not declared in this scope
                 if(strlen(line.c_str())-7 < 1) continue;
                                       ^
prog.cpp:773:68: error: ‘strlen’ was not declared in this scope
                 std::string in = line.substr(7, strlen(line.c_str())-7);
                                                                    ^
prog.cpp:774:62: error: ‘strtok’ was not declared in this scope
                 char* infile = strtok((char*)(in.c_str()),"|");
                                                              ^
prog.cpp:859:66: error: ‘memset’ was not declared in this scope
                     memset(eixcompressedBuffer, 0, eixcryptedSize);
                                                                  ^
prog.cpp:896:129: warning: format ‘%i’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
                     printf("The version of %s file is incorrect. Found: %i Supported: %i).\n", eixName, eixversion, IndexVersion);
                                                                                                                                 ^
prog.cpp:918:66: error: ‘memcpy’ was not declared in this scope
                     memcpy(filename,eixdecompressedBuffer + 4,160);
                                                                  ^
prog.cpp:989:79: error: ‘memset’ was not declared in this scope
                         memset(datauncompressedBuffer, 0, datadecompressedSize);
                                                                               ^
prog.cpp:978:39: warning: unused variable ‘datacryptedSize’ [-Wunused-variable]
                         unsigned long datacryptedSize = *(unsigned long*)(epkBuffer + dwFileOffset + 4);
                                       ^
prog.cpp:1061:71: error: ‘memset’ was not declared in this scope
                         memset(datadecryptedBuffer, 0, datacryptedSize);
                                                                       ^
prog.cpp:916:35: warning: unused variable ‘index’ [-Wunused-variable]
                     unsigned long index = *(unsigned long*)eixdecompressedBuffer;
                                   ^
prog.cpp:919:35: warning: unused variable ‘filenameCRC’ [-Wunused-variable]
                     unsigned long filenameCRC = *(unsigned long*)(eixdecompressedBuffer + 168);
                                   ^
prog.cpp:920:35: warning: unused variable ‘dw3’ [-Wunused-variable]
                     unsigned long dw3 = *(unsigned long*)(eixdecompressedBuffer + 172);
                                   ^
prog.cpp:922:35: warning: unused variable ‘unpackedCRC’ [-Wunused-variable]
                     unsigned long unpackedCRC = *(unsigned long*)(eixdecompressedBuffer + 180);
                                   ^
prog.cpp:889:31: warning: unused variable ‘eixheader2’ [-Wunused-variable]
                 unsigned long eixheader2 = *(unsigned long*)eixdecompressedBuffer;
                               ^
stdout
Standard output is empty