Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.72 KB | None | 0 0
  1. #include "ProjectMain.h"
  2. #include "dirent.h"
  3. #include "CRC32.h"
  4. #include "DirFuncs.h"
  5. #include "DynamicWinapi.h"
  6. #include "Functions.h"
  7.  
  8. #include "Threads.h"
  9. #include "md5.h"
  10. #include <boost/algorithm/string/predicate.hpp>
  11. #include "CLog.h"
  12.  
  13.  
  14. CDirFunctions* LPDirFunctions;
  15. CDirFunctions::CDirFunctions()
  16. {
  17. }
  18.  
  19. CDirFunctions::~CDirFunctions()
  20. {
  21. }
  22.  
  23.  
  24. inline bool CDirFunctions::is_file_exist(const std::string& szName) {
  25. KARMA_MACRO_2;
  26. struct stat buffer;
  27. auto method1 = (stat(szName.c_str(), &buffer) == 0);
  28. if (!method1) {
  29. DWORD dwAttrib =BetaFunctionTable->GetFileAttributesA(szName.c_str());
  30. return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
  31. }
  32. return method1;
  33. }
  34.  
  35. std::string CDirFunctions::readFile(const std::string& filename) {
  36. KARMA_MACRO_2;
  37. ifstream in(filename.c_str(), ios_base::binary);
  38. in.exceptions(ios_base::badbit | ios_base::failbit | ios_base::eofbit);
  39. KARMA_MACRO_1;
  40. return std::string(istreambuf_iterator<char>(in), istreambuf_iterator<char>());
  41. }
  42.  
  43. void CDirFunctions::writeFile(char* filename, char* text){
  44. KARMA_MACRO_1;
  45. std::ofstream f(filename, std::ofstream::out | std::ofstream::app);
  46. f << text << std::endl;
  47. f.close();
  48. KARMA_MACRO_2;
  49. }
  50.  
  51. bool CDirFunctions::dirExist(const std::string& dirName_in)
  52. {
  53. KARMA_MACRO_1;
  54. DWORD ftyp = BetaFunctionTable->GetFileAttributesA(dirName_in.c_str());
  55. if (ftyp == INVALID_FILE_ATTRIBUTES)
  56. return false;
  57.  
  58. if (ftyp & FILE_ATTRIBUTE_DIRECTORY)
  59. return true;
  60.  
  61. return false;
  62. }
  63.  
  64. int CDirFunctions::DeleteDirectory(const std::string &refcstrRootDirectory, bool bDeleteSubdirectories)
  65. {
  66. KARMA_MACRO_1
  67. bool bSubdirectory = false; // Flag, indicating whether
  68. // subdirectories have been found
  69. HANDLE hFile; // Handle to directory
  70. std::string strFilePath; // Filepath
  71. std::string strPattern; // Pattern
  72. WIN32_FIND_DATA FileInformation; // File information
  73. KARMA_MACRO_2
  74.  
  75. strPattern = refcstrRootDirectory + "\\*.*"; // todo: array
  76. hFile = ::BetaFunctionTable->FindFirstFileA(strPattern.c_str(), &FileInformation);
  77. KARMA_MACRO_2
  78. if (hFile != INVALID_HANDLE_VALUE)
  79. {
  80. do
  81. {
  82. if (FileInformation.cFileName[0] != '.')
  83. {
  84. strFilePath.erase();
  85. strFilePath = refcstrRootDirectory + "\\" + FileInformation.cFileName; // todo: array
  86.  
  87. if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  88. {
  89. if (bDeleteSubdirectories)
  90. {
  91. // Delete subdirectory
  92. int iRC = DeleteDirectory(strFilePath, bDeleteSubdirectories);
  93. if (iRC)
  94. return iRC;
  95. }
  96. else
  97. bSubdirectory = true;
  98. }
  99. else
  100. {
  101. // Set file attributes
  102. if (::BetaFunctionTable->SetFileAttributesA(strFilePath.c_str(),
  103. FILE_ATTRIBUTE_NORMAL) == FALSE)
  104. return ::BetaFunctionTable->GetLastError();
  105.  
  106. // Delete file
  107. if (::BetaFunctionTable->DeleteFileA(strFilePath.c_str()) == FALSE)
  108. return ::BetaFunctionTable->GetLastError();
  109. }
  110. }
  111. } while (::BetaFunctionTable->FindNextFileA(hFile, &FileInformation) == TRUE);
  112.  
  113. // Close handle
  114. ::BetaFunctionTable->FindClose(hFile);
  115.  
  116. DWORD dwError = ::BetaFunctionTable->GetLastError();
  117. if (dwError != ERROR_NO_MORE_FILES)
  118. return dwError;
  119. else
  120. {
  121. if (!bSubdirectory)
  122. {
  123. // Set directory attributes
  124. if (::BetaFunctionTable->SetFileAttributesA(refcstrRootDirectory.c_str(),
  125. FILE_ATTRIBUTE_NORMAL) == FALSE)
  126. return ::BetaFunctionTable->GetLastError();
  127.  
  128. // Delete directory
  129. if (::BetaFunctionTable->RemoveDirectoryA(refcstrRootDirectory.c_str()) == FALSE)
  130. return ::BetaFunctionTable->GetLastError();
  131. }
  132. }
  133. }
  134. KARMA_MACRO_1
  135. return 0;
  136. }
  137.  
  138. HANDLE CDirFunctions::CreateTempFile(std::string * pszName)
  139. {
  140. TCHAR lpTempPathBuffer[MAX_PATH];
  141. DWORD dwRetVal = BetaFunctionTable->GetTempPathA(MAX_PATH, lpTempPathBuffer);
  142. if (dwRetVal > MAX_PATH || (dwRetVal == 0))
  143. return 0;
  144.  
  145. TCHAR szTempFileName[MAX_PATH];
  146. CHAR __bst[] = { 'b', 's', 't', 0x0 }; // bst
  147. UINT uRetVal = BetaFunctionTable->GetTempFileNameA(lpTempPathBuffer, __bst, 0, szTempFileName);
  148. if (uRetVal == 0)
  149. return 0;
  150.  
  151. HANDLE hTempFile = BetaFunctionTable->CreateFileA(szTempFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  152. if (hTempFile == INVALID_HANDLE_VALUE)
  153. return 0;
  154.  
  155. *pszName = szTempFileName;
  156. return hTempFile;
  157. }
  158.  
  159. std::string CDirFunctions::WinPath() {
  160. KARMA_MACRO_1;
  161. char buffer[MAX_PATH];
  162. BetaFunctionTable->GetWindowsDirectoryA(buffer, MAX_PATH);
  163. KARMA_MACRO_2;
  164. return buffer;
  165. }
  166.  
  167. std::string CDirFunctions::ExeName() {
  168. KARMA_MACRO_1;
  169. std::string szExeNameWithPath = ExeNameWithPath();
  170. std::string szExeNameWithoutPath = GetNameFromPath(szExeNameWithPath);
  171. KARMA_MACRO_2;
  172. return szExeNameWithoutPath;
  173. }
  174.  
  175. std::string CDirFunctions::ExePath() {
  176. KARMA_MACRO_2;
  177. char buffer[MAX_PATH];
  178. BetaFunctionTable->GetModuleFileNameA(NULL, buffer, MAX_PATH);
  179. std::string::size_type pos = std::string(buffer).find_last_of("\\/");// todo: array
  180. KARMA_MACRO_1;
  181. return std::string(buffer).substr(0, pos);
  182. }
  183.  
  184. std::string CDirFunctions::ExeNameWithPath(){
  185. KARMA_MACRO_1
  186. char buffer[MAX_PATH];
  187. BetaFunctionTable->GetModuleFileNameA(NULL, buffer, MAX_PATH);
  188. KARMA_MACRO_2
  189. return std::string(buffer);
  190. }
  191.  
  192. bool CDirFunctions::IsBetaBox(std::string szThis)
  193. {
  194. #ifdef _DEBUG
  195. LPLog->AddLog(0, "IsBetaBox started! Str: %s", szThis.empty() ? "NULL" : szThis.c_str());
  196. #endif
  197. if (szThis.empty())
  198. return false;
  199.  
  200. auto szLowerThis = LPFunctions->szLower(szThis);
  201. if (IsFromCurrentPath(szLowerThis) == true)
  202. {
  203. auto szExePath = ExePath();
  204. auto szLowerExePath = LPFunctions->szLower(ExePath());
  205.  
  206. //CHAR __p1[] = { '/', 'b', 'e', 't', 'a', 's', 'h', 'i', 'e', 'l', 'd', '/', 'b', 'e', 't', 'a', 'b', 'o', 'x', '.', 'e', 'x', 'e', 0x0 }; // /betashield/betabox.exe
  207. //auto szBox1 = szLowerExePath + __p1;
  208. //CHAR __p2[] = { '\\', 'b', 'e', 't', 'a', 's', 'h', 'i', 'e', 'l', 'd', '\\', 'b', 'e', 't', 'a', 'b', 'o', 'x', '.', 'e', 'x', 'e', 0x0 }; // \betashield\betabox.exe
  209. //auto szBox2 = szLowerExePath + __p2;
  210. CHAR __p3[] = { '\\', 'b', 'e', 't', 'a', 'b', 'o', 'x', '.', 'e', 'x', 'e', 0x0 }; // \betabox.exe
  211. auto szBox3 = szLowerExePath + __p3;
  212. CHAR __p4[] = { '/', 'b', 'e', 't', 'a', 'b', 'o', 'x', '.', 'e', 'x', 'e', 0x0 }; // /betabox.exe
  213. auto szBox4 = szLowerExePath + __p4;
  214.  
  215. //LPLog->AddLog(0, "P1: %s P2: %s P3: %s P4: %s Box: %s",
  216. // szBox1.c_str(), szBox2.c_str(), szBox3.c_str(), szBox4.c_str(), szLowerThis.c_str());
  217.  
  218. if ( /*szBox1 == szLowerThis || szBox2 == szLowerThis || */ szBox3 == szLowerThis || szBox4 == szLowerThis)
  219. return true;
  220. }
  221. return false;
  222. }
  223.  
  224. bool CDirFunctions::IsFromWindowsPath(std::string szPath)
  225. {
  226. std::string szLowerWinPath = WinPath();
  227. transform(szLowerWinPath.begin(), szLowerWinPath.end(), szLowerWinPath.begin(), tolower);
  228.  
  229. if (szPath.find(szLowerWinPath) != std::string::npos)
  230. return true;
  231. return false;
  232. }
  233.  
  234. bool CDirFunctions::IsFromWindowsPath(std::wstring wszPath)
  235. {
  236. CFunctions lpFuncs;
  237. std::string szPath = lpFuncs.WstringToUTF8(wszPath);
  238. return IsFromWindowsPath(szPath);
  239. }
  240.  
  241. bool CDirFunctions::IsFromWindowsPath(const char* c_szPath)
  242. {
  243. std::string szPath = c_szPath;
  244. return IsFromWindowsPath(szPath);
  245. }
  246.  
  247. bool CDirFunctions::IsFromWindowsPath(const wchar_t* c_wszPath)
  248. {
  249. std::wstring wszPath = c_wszPath;
  250. return IsFromWindowsPath(wszPath);
  251. }
  252.  
  253.  
  254. bool CDirFunctions::IsFromCurrentPath(std::string szPath)
  255. {
  256. std::string szLowerExePath = ExePath();
  257. transform(szLowerExePath.begin(), szLowerExePath.end(), szLowerExePath.begin(), tolower);
  258.  
  259. if (szPath.find(szLowerExePath) != std::string::npos)
  260. return true;
  261. return false;
  262. }
  263.  
  264. bool CDirFunctions::IsFromCurrentPath(std::wstring wszPath)
  265. {
  266. CFunctions lpFuncs;
  267. std::string szPath = lpFuncs.WstringToUTF8(wszPath);
  268. return IsFromCurrentPath(szPath);
  269. }
  270.  
  271. bool CDirFunctions::IsFromCurrentPath(const char* c_szPath)
  272. {
  273. std::string szPath = c_szPath;
  274. return IsFromCurrentPath(szPath);
  275. }
  276.  
  277. bool CDirFunctions::IsFromCurrentPath(const wchar_t* c_wszPath)
  278. {
  279. std::wstring wszPath = c_wszPath;
  280. return IsFromCurrentPath(wszPath);
  281. }
  282.  
  283. std::string CDirFunctions::GetNameFromPath(std::string __szFileName)
  284. {
  285. std::string szFileName = __szFileName;
  286. int iLastSlash = szFileName.find_last_of("\\/"); // TODO: Array
  287. szFileName = szFileName.substr(iLastSlash + 1, szFileName.length() - iLastSlash);
  288. return szFileName;
  289. }
  290.  
  291. std::wstring CDirFunctions::GetNameFromPath(std::wstring __wszFileName)
  292. {
  293. std::wstring wszFileName = __wszFileName;
  294. int iLastSlash = wszFileName.find_last_of(L"\\/"); // TODO: Array
  295. wszFileName = wszFileName.substr(iLastSlash + 1, wszFileName.length() - iLastSlash);
  296. return wszFileName;
  297. }
  298.  
  299.  
  300. __forceinline bool IsTrueExtensionForMiles(const char* c_szFileName) {
  301. CHAR __mss32[] = { 'm', 's', 's', '3', '2', '.', 'd', 'l', 'l', 0x0 }; //mss32.dll
  302. CHAR __mix[] = { '.', 'm', 'i', 'x', 0x0 }; //".mix"
  303. CHAR __asi[] = { '.', 'a', 's', 'i', 0x0 }; //".asi"
  304. CHAR __m3d[] = { '.', 'm', '3', 'd', 0x0 }; //".m3d"
  305. CHAR __flt[] = { '.', 'f', 'l', 't', 0x0 }; //".flt"
  306.  
  307. return strstr(c_szFileName, __mss32) || strstr(c_szFileName, __mix) || strstr(c_szFileName, __asi) || strstr(c_szFileName, __m3d) || strstr(c_szFileName, __flt);
  308. }
  309.  
  310. int CDirFunctions::GetDirFileCount(std::string szDir)
  311. {
  312. KARMA_MACRO_1;
  313. struct dirent *de;
  314. const char* my_Dir = szDir.c_str();
  315.  
  316. KARMA_MACRO_2;
  317. DIR *dir = opendir(my_Dir);
  318. if (!dir)
  319. return -1; // Probably dir is not exist
  320.  
  321. KARMA_MACRO_1;
  322. int count = 0;
  323. while (de = readdir(dir)) {
  324. if (IsTrueExtensionForMiles(de->d_name)) {
  325. ++count;
  326. }
  327. }
  328.  
  329. KARMA_MACRO_2;
  330. closedir(dir);
  331.  
  332. return count;
  333. }
  334.  
  335. void CDirFunctions::MilesCountCheck()
  336. {
  337. KARMA_MACRO_1
  338. CHAR __miles[] = { '\\', '\\', 'm', 'i', 'l', 'e', 's', '\\', '\\', 0x0 }; // "\\miles\\"
  339. int milessay = GetDirFileCount(ExePath() + __miles);
  340. if (milessay == -1)
  341. return;
  342.  
  343. KARMA_MACRO_2
  344. if (milessay != 10)
  345. {
  346. /*
  347. if (milessay < 10)
  348. {
  349. CHAR __Missingfile[] = { 'M', 'i', 's', 's', 'i', 'n', 'g', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', ' ', 'i', 'n', ' ', 'M', 'I', 'L', 'E', 'S', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ',', ' ', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'r', 'u', 'n', ' ', 'a', 'u', 't', 'o', 'p', 'a', 't', 'c', 'h', 'e', 'r', '.', 0x0 }; // Missing file detected in MILES folder, Please run autopatcher.
  350. LPFunctions->CloseProcess(__Missingfile, false, "");
  351. }
  352. */
  353. if (milessay > 10)
  354. {
  355. CHAR __Toomuchfile[] = { 'T', 'o', 'o', ' ', 'm', 'u', 'c', 'h', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', ' ', 'i', 'n', ' ', 'M', 'I', 'L', 'E', 'S', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ',', ' ', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'c', 'l', 'e', 'a', 'r', ' ', 'y', 'o', 'u', 'r', ' ', 'm', 'i', 'l', 'e', 's', ' ', 'f', 'o', 'l', 'd', 'e', 'r', '.', 0x0 }; // Too much file detected in MILES folder, Please clear your miles folder.
  356. LPFunctions->CloseProcess(__Toomuchfile, false, "");
  357. }
  358. }
  359. KARMA_MACRO_1
  360. }
  361.  
  362.  
  363. void CDirFunctions::CheckDirectory(string Directory)
  364. {
  365. CFunctions lpFuncs;
  366.  
  367. KARMA_MACRO_2;
  368. const string hedef = Directory;
  369. if (Directory.length() == 0)
  370. Directory = "*";
  371. else
  372. Directory = Directory + "\\*";
  373.  
  374. KARMA_MACRO_1;
  375.  
  376. WIN32_FIND_DATAA FindData;
  377. HANDLE Find = BetaFunctionTable->FindFirstFileA(Directory.c_str(), &FindData);
  378.  
  379. KARMA_MACRO_2;
  380.  
  381. int py = 0;
  382. int m3d = 0;
  383. int asi = 0;
  384. int flt = 0;
  385. int mix = 0;
  386.  
  387. KARMA_MACRO_1
  388.  
  389. // text list
  390. CHAR __miles[] = { 'm', 'i', 'l', 'e', 's', 0x0 }; //__miles
  391.  
  392. CHAR __logininfo[] = { 'l', 'o', 'g', 'i', 'n', 'i', 'n', 'f', 'o', '.', 'p', 'y', 0x0 }; //"logininfo.py"
  393. CHAR __mssa3d[] = { 'm', 's', 's', 'a', '3', 'd', '.', 'm', '3', 'd', 0x0 }; //"mssa3d.m3d"
  394. CHAR __mssds3d[] = { 'm', 's', 's', 'd', 's', '3', 'd', '.', 'm', '3', 'd', 0x0 }; //"mssds3d.m3d"
  395. CHAR __mssdx7[] = { 'm', 's', 's', 'd', 'x', '7', '.', 'm', '3', 'd', 0x0 }; //"mssdx7.m3d"
  396. CHAR __msseax[] = { 'm', 's', 's', 'e', 'a', 'x', '.', 'm', '3', 'd', 0x0 }; //"msseax.m3d"
  397. CHAR __mssrsx[] = { 'm', 's', 's', 'r', 's', 'x', '.', 'm', '3', 'd', 0x0 }; //"mssrsx.m3d"
  398. CHAR __msssoft[] = { 'm', 's', 's', 's', 'o', 'f', 't', '.', 'm', '3', 'd', 0x0 }; //"msssoft.m3d"
  399. CHAR __mssmp3[] = { 'm', 's', 's', 'm', 'p', '3', '.', 'a', 's', 'i', 0x0 }; //"mssmp3.asi"
  400. CHAR __mssvoice[] = { 'm', 's', 's', 'v', 'o', 'i', 'c', 'e', '.', 'a', 's', 'i', 0x0 }; //"mssvoice.asi"
  401. CHAR __mssdsp[] = { 'm', 's', 's', 'd', 's', 'p', '.', 'f', 'l', 't', 0x0 }; //"mssdsp.flt"
  402.  
  403. CHAR __py[] = { '.', 'p', 'y', 0x0 }; //".py"
  404. CHAR __mix[] = { '.', 'm', 'i', 'x', 0x0 }; //".mix"
  405. CHAR __asi[] = { '.', 'a', 's', 'i', 0x0 }; //".asi"
  406. CHAR __m3d[] = { '.', 'm', '3', 'd', 0x0 }; //".m3d"
  407. CHAR __flt[] = { '.', 'f', 'l', 't', 0x0 }; //".flt"
  408.  
  409. KARMA_MACRO_2
  410.  
  411. if (hedef == __miles) {
  412. while (BetaFunctionTable->FindNextFileA(Find, &FindData) != 0) {
  413. if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  414. if (lpFuncs.szLower(FindData.cFileName).compare(__logininfo) == 0) { py = 1; break; }
  415. if (lpFuncs.szLower(FindData.cFileName).compare(__mssa3d) != 0 && \
  416. lpFuncs.szLower(FindData.cFileName).compare(__mssds3d) != 0 && \
  417. lpFuncs.szLower(FindData.cFileName).compare(__mssdx7) != 0 && \
  418. lpFuncs.szLower(FindData.cFileName).compare(__msseax) != 0 && \
  419. lpFuncs.szLower(FindData.cFileName).compare(__mssrsx) != 0 && \
  420. lpFuncs.szLower(FindData.cFileName).compare(__msssoft) != 0) {
  421. if (lpFuncs.szLower(FindData.cFileName).find(__m3d) != string::npos) { m3d = 1; break; }
  422. }
  423. if (lpFuncs.szLower(FindData.cFileName).compare(__mssmp3) != 0 && \
  424. lpFuncs.szLower(FindData.cFileName).compare(__mssvoice)) {
  425. if (lpFuncs.szLower(FindData.cFileName).find(__asi) != string::npos) { asi = 1; break; }
  426. }
  427. if (lpFuncs.szLower(FindData.cFileName).compare(__mssdsp)) {
  428. if (lpFuncs.szLower(FindData.cFileName).find(__flt) != string::npos) { flt = 1; break; }
  429. }
  430. if (lpFuncs.szLower(FindData.cFileName).find(__mix) != string::npos) { mix = 1; break; }
  431. }
  432. }
  433. }
  434. else {
  435. while (BetaFunctionTable->FindNextFileA(Find, &FindData) != 0) {
  436. if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  437. if (lpFuncs.szLower(FindData.cFileName).find(__m3d) != string::npos) { m3d = 1; break; }
  438. if (lpFuncs.szLower(FindData.cFileName).find(__asi) != string::npos) { asi = 1; break; }
  439. if (lpFuncs.szLower(FindData.cFileName).find(__flt) != string::npos) { flt = 1; break; }
  440. if (lpFuncs.szLower(FindData.cFileName).find(__mix) != string::npos) { mix = 1; break; }
  441. if (lpFuncs.szLower(FindData.cFileName).find(__py) != string::npos) { py = 1; break; }
  442. }
  443. }
  444. }
  445.  
  446. KARMA_MACRO_1;
  447.  
  448. if (!(py == 0 && m3d == 0 && asi == 0 && flt == 0 && mix == 0)) {
  449. string is;
  450. if (py == 1) is = __py;
  451. if (m3d == 1) is = __m3d;
  452. if (asi == 1) is = __asi;
  453. if (flt == 1) is = __flt;
  454. if (mix == 1) is = __mix;
  455.  
  456. std::string szDetectedFile = Directory + is;
  457. CHAR __Badfiledetected[] = { 'B', 'a', 'd', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', ' ', 'i', 'n', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', '.', ' ', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'r', 'e', 'm', 'o', 'v', 'e', ':', ' ', '%', 's', 0x0 }; // Bad file detected in game folder. Please remove: %s
  458. char tmpBuf[500];
  459. sprintf(tmpBuf, __Badfiledetected, szDetectedFile.c_str());
  460.  
  461. lpFuncs.CloseProcess(tmpBuf, false, "");
  462. }
  463. KARMA_MACRO_2;
  464. }
  465.  
  466. void CDirFunctions::MainFolderCheck()
  467. {
  468. CFunctions lpFuncs;
  469. KARMA_MACRO_1
  470.  
  471. CHAR __logininfo1[] = { 'l', 'o', 'g', 'i', 'n', 'i', 'n', 'f', 'o', '.', 'p', 'y', 0x0 }; //"logininfo.py"
  472. CHAR __logininfo2[] = { 'l', 'o', 'g', 'i', 'n', 'I', 'n', 'f', 'o', '.', 'p', 'y', 0x0 }; //"loginInfo.py"
  473. KARMA_MACRO_2
  474. CHAR __d3d8thkdef[] = { 'd', '3', 'd', '8', 't', 'h', 'k', '.', 'd', 'e', 'f', 0x0 }; // d3d8thk.def
  475. CHAR __d3d8thk64def[] = { 'd', '3', 'd', '8', 't', 'h', 'k', '6', '4', '.', 'd', 'e', 'f', 0x0 }; // d3d8thk64.def
  476. KARMA_MACRO_2
  477.  
  478. if (is_file_exist(__logininfo1) || is_file_exist(__logininfo2)){
  479. CHAR __Logininfoinjection[] = { 'L', 'o', 'g', 'i', 'n', 'i', 'n', 'f', 'o', ' ', 'i', 'n', 'j', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // Logininfo injection detected.
  480. lpFuncs.CloseProcess(__Logininfoinjection, false, "");
  481. }
  482.  
  483. KARMA_MACRO_1
  484.  
  485. if (is_file_exist(__d3d8thkdef) || is_file_exist(__d3d8thk64def)) {
  486. CHAR __d3d8thkdefwarn[] = { 'U', 'n', 'a', 'l', 'l', 'o', 'w', 'e', 'd', ' ', 'f', 'i', 'l', 'e', ' ', 'd', '3', 'd', '8', 't', 'h', 'k', '.', 'd', 'e', 'f', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '!', 0x0 }; // Unallowed file d3d8thk.def detected!
  487. lpFuncs.CloseProcess(__d3d8thkdefwarn, false, "");
  488. }
  489.  
  490. KARMA_MACRO_1
  491. }
  492.  
  493. void CDirFunctions::PackCheck()
  494. {
  495. CFunctions lpFuncs;
  496. KARMA_MACRO_1;
  497.  
  498. CHAR __antiflydmg[] = { '\\', '\\', 'p', 'a', 'c', 'k', '\\', '\\', 'a', 'n', 't', 'i', 'f', 'l', 'y', 'd', 'm', 'g', '.', 'e', 'p', 'k', 0x0 }; // "\\pack\\antiflydmg.epk"
  499. CHAR __waitdmg[] = { '\\', '\\', 'p', 'a', 'c', 'k', '\\', '\\', 'w', 'a', 'i', 't', 'd', 'm', 'g', '.', 'e', 'p', 'k', 0x0 }; // "\\pack\\waitdmg.epk"
  500. CHAR __antifly[] = { '\\', '\\', 'p', 'a', 'c', 'k', '\\', '\\', 'a', 'n', 't', 'i', 'f', 'l', 'y', '.', 'e', 'p', 'k', 0x0 }; // "\\pack\\antifly.epk"
  501. CHAR __ymirpc[] = { 'd', ':', '\\', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', '\\', 'p', 'c', 0x0 }; // "d:\\ymir work\\pc"
  502. CHAR __ymirpc_2[] = { 'd', ':', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', 'p', 'c', 0x0 }; // "d:\\ymir work\\pc"
  503. CHAR __ymirpc2[] = { 'd', ':', '\\', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', '\\', 'p', 'c', '2', 0x0 }; // "d:\\ymir work\\pc2"
  504. CHAR __ymirpc2_2[] = { 'd', ':', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', 'p', 'c', '2', 0x0 }; // "d:\\ymir work\\pc2"
  505. CHAR __ymirpc3[] = { 'd', ':', '\\', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', '\\', 'p', 'c', '3', 0x0 }; // "d:\\ymir work\\pc3"
  506. CHAR __ymirpc3_2[] = { 'd', ':', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', 'p', 'c', '3', 0x0 }; // "d:\\ymir work\\pc3"
  507. CHAR __ymirmonster[] = { 'd', ':', '\\', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', '\\', 'm', 'o', 'n', 's', 't', 'e', 'r', 0x0 }; // d:/ymir work/monster
  508. CHAR __ymirmonster_2[] = { 'd', ':', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', 'm', 'o', 'n', 's', 't', 'e', 'r', 0x0 }; // d:/ymir work/monster
  509. CHAR __ymirmonster2[] = { 'd', ':', '\\', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', '\\', 'm', 'o', 'n', 's', 't', 'e', 'r', '2', 0x0 }; // d:/ymir work/monster2
  510. CHAR __ymirmonster2_2[] = { 'd', ':', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '\\', 'm', 'o', 'n', 's', 't', 'e', 'r', '2', 0x0 }; // d:/ymir work/monster2
  511. CHAR __ymir[] = { '\\', '\\', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', 0x0 }; // "\\ymir work"
  512. CHAR __pc[] = { '\\', '\\', 'p', 'c', 0x0 }; // "\\pc"
  513. CHAR __pc2[] = { '\\', '\\', 'p', 'c', '2', 0x0 }; // "\\pc2"
  514. CHAR __pc3[] = { '\\', '\\', 'p', 'c', '3', 0x0 }; // "\\pc3"
  515.  
  516. KARMA_MACRO_2
  517.  
  518. CHAR __Antiflydmg_warn[] = { 'A', 'n', 't', 'i', 'f', 'l', 'y', ' ', 'D', 'a', 'm', 'a', 'g', 'e', ' ', 'H', 'a', 'c', 'k', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // Antifly Damage Hack detected.
  519. CHAR __WaitDamage_warn[] = { 'W', 'a', 'i', 't', ' ', 'D', 'a', 'm', 'a', 'g', 'e', ' ', 'H', 'a', 'c', 'k', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // Wait Damage Hack detected.
  520. CHAR __Antifly_warn[] = { 'A', 'n', 't', 'i', 'f', 'l', 'y', ' ', 'H', 'a', 'c', 'k', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // Antifly Hack detected.
  521. CHAR __ymirworkpc_warn[] = { 'D', ':', '/', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '/', 'p', 'c', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // D:/ymir work/pc illegal folder detected.
  522. CHAR __ymirworkpc2_warn[] = { 'D', ':', '/', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '/', 'p', 'c', '2', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // D:/ymir work/pc2 illegal folder detected.
  523. CHAR __ymirworkpc3_warn[] = { 'D', ':', '/', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '/', 'p', 'c', '3', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // D:/ymir work/pc3 illegal folder detected.
  524. CHAR __ymirwork_warn[] = { 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', ' ', 'i', 'n', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // 'ymir work' illegal folder detected in game folder
  525. CHAR __pc_warn[] = { 'p', 'c', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', ' ', 'i', 'n', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // 'pc' illegal folder detected in game folder
  526. CHAR __pc2_warn[] = { 'p', 'c', '2', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', ' ', 'i', 'n', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // 'pc2' illegal folder detected in game folder
  527. CHAR __pc3_warn[] = { 'p', 'c', '3', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', ' ', 'i', 'n', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // 'pc3' illegal folder detected in game folder
  528. CHAR __ymirworkmonster_warn[] = { 'D', ':', '/', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '/', 'm', 'o', 'n', 's', 't', 'e', 'r', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // D:/ymir work/monster illegal folder detected.
  529. CHAR __ymirworkmonster2_warn[] = { 'D', ':', '/', 'y', 'm', 'i', 'r', ' ', 'w', 'o', 'r', 'k', '/', 'm', 'o', 'n', 's', 't', 'e', 'r', '2', ' ', 'i', 'l', 'l', 'e', 'g', 'a', 'l', ' ', 'f', 'o', 'l', 'd', 'e', 'r', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '.', 0x0 }; // D:/ymir work/monster2 illegal folder detected.
  530.  
  531. KARMA_MACRO_1;
  532. std::string packyediiks = ExePath() + __antiflydmg;
  533. if (is_file_exist(packyediiks)){
  534. lpFuncs.CloseProcess(__Antiflydmg_warn, false, "");
  535. }
  536.  
  537. KARMA_MACRO_2;
  538. std::string packyediiksiki = ExePath() + __waitdmg;
  539. if (is_file_exist(packyediiksiki)){
  540. lpFuncs.CloseProcess(__WaitDamage_warn, false, "");
  541. }
  542.  
  543. KARMA_MACRO_1;
  544. std::string packyediiksuc = ExePath() + __antifly;
  545. if (is_file_exist(packyediiksuc)){
  546. lpFuncs.CloseProcess(__Antifly_warn, false, "");
  547. }
  548. KARMA_MACRO_2;
  549. if (dirExist(__ymirpc) || dirExist(__ymirpc_2)) {
  550. lpFuncs.CloseProcess(__ymirworkpc_warn, false, "");
  551. }
  552. KARMA_MACRO_1;
  553. if (dirExist(__ymirpc2) || dirExist(__ymirpc2_2)) {
  554. lpFuncs.CloseProcess(__ymirworkpc2_warn, false, "");
  555. }
  556. KARMA_MACRO_1;
  557. if (dirExist(__ymirpc3) || dirExist(__ymirpc3_2)) {
  558. lpFuncs.CloseProcess(__ymirworkpc3_warn, false, "");
  559. }
  560. KARMA_MACRO_2;
  561. if (dirExist(__ymirmonster) || dirExist(__ymirmonster_2)) {
  562. lpFuncs.CloseProcess(__ymirworkmonster_warn, false, "");
  563. }
  564. KARMA_MACRO_1;
  565. if (dirExist(__ymirmonster2) || dirExist(__ymirmonster2_2)) {
  566. lpFuncs.CloseProcess(__ymirworkmonster2_warn, false, "");
  567. }
  568. KARMA_MACRO_2;
  569. std::string exedizin = ExePath() + __ymir;
  570. if (dirExist(exedizin.c_str())) {
  571. lpFuncs.CloseProcess(__ymirwork_warn, false, "");
  572. }
  573. KARMA_MACRO_1;
  574. std::string pcdizin = ExePath() + __pc;
  575. if (dirExist(pcdizin.c_str())) {
  576. lpFuncs.CloseProcess(__pc_warn, false, "");
  577. }
  578. KARMA_MACRO_2;
  579. std::string pc2dizin = ExePath() + __pc2;
  580. if (dirExist(pc2dizin.c_str())) {
  581. lpFuncs.CloseProcess(__pc2_warn, false, "");
  582. }
  583. KARMA_MACRO_2;
  584. std::string pc3dizin = ExePath() + __pc3;
  585. if (dirExist(pc3dizin.c_str())) {
  586. lpFuncs.CloseProcess(__pc3_warn, false, "");
  587. }
  588. KARMA_MACRO_1;
  589. }
  590.  
  591. int getdir(string dir, vector<string>& files)
  592. {
  593. KARMA_MACRO_2
  594. DIR *dp;
  595. struct dirent *dirp;
  596. if ((dp = opendir(dir.c_str())) == NULL) {
  597. return errno;
  598. }
  599.  
  600. while ((dirp = readdir(dp)) != NULL) {
  601. files.push_back(string(dirp->d_name));
  602. }
  603. closedir(dp);
  604. KARMA_MACRO_1
  605. return 0;
  606. }
  607.  
  608. bool CDirFunctions::AntiMssExploit() {
  609. CFunctions lpFuncs;
  610. KARMA_MACRO_1
  611.  
  612. string dir = string(".");
  613. vector<string> files = vector<string>();
  614.  
  615. CHAR __dot[] = { '.', 0x0 }; //"."
  616. CHAR __py[] = { 'p', 'y', 0x0 }; //.py"
  617. CHAR __mix[] = { 'm', 'i', 'x', 0x0 }; //"mix"
  618. CHAR __asi[] = { 'a', 's', 'i', 0x0 }; //"asi"
  619. CHAR __m3d[] = { 'm', '3', 'd', 0x0 }; //"m3d"
  620. CHAR __flt[] = { 'f', 'l', 't', 0x0 }; //"flt"
  621.  
  622. KARMA_MACRO_1
  623.  
  624. CHAR __Mixwarn[] = { 'M', 'i', 'x', ' ', 'i', 'n', 'j', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '\n', '\n', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'c', 'l', 'e', 'a', 'r', ' ', 'y', 'o', 'u', 'r', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // Mix injection detected Please clear your game folder
  625. CHAR __Fltwarn[] = { 'F', 'l', 't', ' ', 'i', 'n', 'j', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '\n', '\n', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'c', 'l', 'e', 'a', 'r', ' ', 'y', 'o', 'u', 'r', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // Flt injection detected Please clear your game folder
  626. CHAR __Asiwarn[] = { 'A', 's', 'i', ' ', 'i', 'n', 'j', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '\n', '\n', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'c', 'l', 'e', 'a', 'r', ' ', 'y', 'o', 'u', 'r', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // Asi injection detected Please clear your game folder
  627. CHAR __M3dwarn[] = { 'M', '3', 'd', ' ', 'i', 'n', 'j', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '\n', '\n', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'c', 'l', 'e', 'a', 'r', ' ', 'y', 'o', 'u', 'r', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // M3d injection detected Please clear your game folder
  628. CHAR __pywarn[] = { '.', 'p', 'y', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '\n', '\n', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'c', 'l', 'e', 'a', 'r', ' ', 'y', 'o', 'u', 'r', ' ', 'g', 'a', 'm', 'e', ' ', 'f', 'o', 'l', 'd', 'e', 'r', 0x0 }; // .py file detected Please clear your game folder
  629.  
  630. KARMA_MACRO_1
  631. getdir(dir, files);
  632. for (unsigned int i = 0; i < files.size(); i++) {
  633. string a = files[i];
  634. if (a.substr(a.find_last_of(__dot) + 1) == __mix) {
  635. const char* b = a.c_str();
  636.  
  637. lpFuncs.CloseProcess(__Mixwarn, false, "");
  638. }
  639. else if (a.substr(a.find_last_of(__dot) + 1) == __flt) {
  640. const char* b = a.c_str();
  641.  
  642. lpFuncs.CloseProcess(__Fltwarn, false, "");
  643. }
  644. else if (a.substr(a.find_last_of(__dot) + 1) == __m3d) {
  645. const char* b = a.c_str();
  646.  
  647. lpFuncs.CloseProcess(__Asiwarn, false, "");
  648. }
  649. else if (a.substr(a.find_last_of(__dot) + 1) == __asi){
  650. const char* b = a.c_str();
  651.  
  652. lpFuncs.CloseProcess(__M3dwarn, false, "");
  653. }
  654. }
  655.  
  656. KARMA_MACRO_2
  657. return false;
  658. }
  659.  
  660. DWORD CDirFunctions::GetFileSize(const char* c_szFileName) {
  661. HANDLE hFile = BetaFunctionTable->CreateFileA(c_szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  662. DWORD dwFileSize = hFile != INVALID_HANDLE_VALUE ? BetaFunctionTable->GetFileSize(hFile, NULL) : 0;
  663. return dwFileSize;
  664. }
  665. unsigned long CDirFunctions::GetFileCrc(const char* c_szFileName) {
  666. CCRC32 MyCRC32;
  667. MyCRC32.Initialize();
  668.  
  669. return MyCRC32.FileCRC(c_szFileName);
  670. }
  671. char* CDirFunctions::GetFileMd5(char* c_szFileName) {
  672. MD5 md5;
  673. return md5.digestFile(c_szFileName);
  674. }
  675.  
  676. void CDirFunctions::CheckFileSize(const char* c_szFileName, DWORD dwCorrectFileSize) {
  677. CFunctions lpFuncs;
  678. #ifdef _DEBUG
  679. LPLog->AddLog(0,"File size check has been started");
  680. #endif
  681.  
  682. KARMA_MACRO_1
  683.  
  684. HANDLE hFile = BetaFunctionTable->CreateFileA(c_szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  685. if (hFile == INVALID_HANDLE_VALUE)
  686. return; //TODO: Add force check option
  687. DWORD dwFileSize = BetaFunctionTable->GetFileSize(hFile, NULL);
  688.  
  689. #ifdef _DEBUG
  690. LPLog->AddLog(0,"File size check event. File: %s Correct size: %u Current Size: %u IsCorrect: %d",
  691. c_szFileName, dwCorrectFileSize, dwFileSize, (int)(dwCorrectFileSize == dwFileSize));
  692. #endif
  693.  
  694. if (dwFileSize != dwCorrectFileSize) {
  695. CHAR __warn[] = { '%', 's', ' ', 'F', 'i', 'l', 'e', ' ', 'm', 'o', 'd', 'i', 'f', 'i', 'c', 'a', 't', 'i', 'o', 'n', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '!', ' ', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'r', 'u', 'n', ' ', 'a', 'u', 't', 'o', 'p', 'a', 't', 'c', 'h', 'e', 'r', '.', '[', '0', 'x', '2', ']', 0x0 }; // %s File modification detected! Please run autopatcher.[0x2]
  696.  
  697. char cTmpStr[250];
  698. sprintf(cTmpStr, __warn, c_szFileName);
  699. lpFuncs.CloseProcess(cTmpStr, false, "");
  700. }
  701.  
  702. KARMA_MACRO_2
  703.  
  704. #ifdef _DEBUG
  705. LPLog->AddLog(0,"File size check completed");
  706. #endif
  707. }
  708.  
  709. void CDirFunctions::CheckFileCrc(const char* c_szFileName, unsigned long ulFileHash)
  710. {
  711. CFunctions lpFuncs;
  712. #ifdef _DEBUG
  713. LPLog->AddLog(0,"File crc check has been started");
  714. #endif
  715.  
  716. KARMA_MACRO_1
  717.  
  718. CCRC32 MyCRC32;
  719. MyCRC32.Initialize();
  720. unsigned long ulRightHash = MyCRC32.FileCRC(c_szFileName);
  721. #ifdef _DEBUG
  722. LPLog->AddLog(0,"File crc check event. File: %s Correct crc: %lu Current crc: %lu IsCorrect: %d",
  723. c_szFileName, ulRightHash, ulFileHash, (BOOL)(ulRightHash == ulFileHash));
  724. #endif
  725.  
  726. if (ulRightHash != ulFileHash) {
  727. CHAR __warn[] = { '%', 's', ' ', 'F', 'i', 'l', 'e', ' ', 'm', 'o', 'd', 'i', 'f', 'i', 'c', 'a', 't', 'i', 'o', 'n', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '!', ' ', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'r', 'u', 'n', ' ', 'a', 'u', 't', 'o', 'p', 'a', 't', 'c', 'h', 'e', 'r', '.', '[', '0', 'x', '1', ']', 0x0 }; // %s File modification detected! Please run autopatcher.[0x1]
  728.  
  729. char cTmpStr[250];
  730. sprintf(cTmpStr, __warn, c_szFileName);
  731. lpFuncs.CloseProcess(cTmpStr, false, "");
  732. }
  733.  
  734. KARMA_MACRO_2
  735.  
  736. #ifdef _DEBUG
  737. LPLog->AddLog(0,"File crc check completed");
  738. #endif
  739. }
  740.  
  741. void CDirFunctions::CheckFileMd5(char* c_szFileName, const char* c_szFileHash)
  742. {
  743. CFunctions lpFuncs;
  744. #ifdef _DEBUG
  745. LPLog->AddLog(0,"File md5 check has been started");
  746. #endif
  747.  
  748. KARMA_MACRO_1
  749.  
  750. MD5 md5;
  751. char* cRightHash = md5.digestFile(c_szFileName);
  752. bool bRet = boost::iequals(cRightHash, c_szFileHash);
  753. #ifdef _DEBUG
  754. LPLog->AddLog(0,"File md5 check event. File: %s Correct md5: %s Current md5: %s IsCorrect: %d",
  755. c_szFileName, cRightHash, c_szFileHash, bRet);
  756. #endif
  757.  
  758. if (bRet == false) {
  759. CHAR __warn[] = { '%', 's', ' ', 'F', 'i', 'l', 'e', ' ', 'm', 'o', 'd', 'i', 'f', 'i', 'c', 'a', 't', 'i', 'o', 'n', ' ', 'd', 'e', 't', 'e', 'c', 't', 'e', 'd', '!', ' ', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'r', 'u', 'n', ' ', 'a', 'u', 't', 'o', 'p', 'a', 't', 'c', 'h', 'e', 'r', '.', '[', '0', 'x', '3', ']', 0x0 }; // %s File modification detected! Please run autopatcher.[0x3]
  760.  
  761. char cTmpStr[250];
  762. sprintf(cTmpStr, __warn, c_szFileName);
  763. lpFuncs.CloseProcess(cTmpStr, false, "");
  764. }
  765.  
  766. KARMA_MACRO_2
  767.  
  768. #ifdef _DEBUG
  769. LPLog->AddLog(0,"File md5 check completed");
  770. #endif
  771. }
  772.  
  773. DWORD WINAPI InitializeFolderCheckEx(LPVOID)
  774. {
  775. #ifdef _DEBUG
  776. LPLog->AddLog(0, "Folder check event has been started");
  777. #endif
  778.  
  779. if (LPData->GetGameCode() == TEST_CONSOLE) {
  780. #ifdef _DEBUG
  781. LPLog->AddLog(0, "Folder check skipped on test console");
  782. #endif
  783. }
  784.  
  785. KARMA_MACRO_1
  786.  
  787. CHAR __miles[] = { 'm', 'i', 'l', 'e', 's', 0x0 }; //miles
  788. CHAR __mssa3d[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 'a', '3', 'd', '.', 'm', '3', 'd', 0x0 }; //"mssa3d.m3d"
  789. CHAR __mssds3d[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 'd', 's', '3', 'd', '.', 'm', '3', 'd', 0x0 }; //"mssds3d.m3d"
  790. CHAR __mssdx7[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 'd', 'x', '7', '.', 'm', '3', 'd', 0x0 }; //"mssdx7.m3d"
  791. CHAR __msseax[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 'e', 'a', 'x', '.', 'm', '3', 'd', 0x0 }; //"msseax.m3d"
  792. CHAR __mssrsx[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 'r', 's', 'x', '.', 'm', '3', 'd', 0x0 }; //"mssrsx.m3d"
  793. CHAR __msssoft[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 's', 'o', 'f', 't', '.', 'm', '3', 'd', 0x0 }; //"msssoft.m3d"
  794. CHAR __mssmp3[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 'm', 'p', '3', '.', 'a', 's', 'i', 0x0 }; //"mssmp3.asi"
  795. CHAR __mssvoice[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 'v', 'o', 'i', 'c', 'e', '.', 'a', 's', 'i', 0x0 }; //"mssvoice.asi"
  796. CHAR __mssdsp[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', 'd', 's', 'p', '.', 'f', 'l', 't', 0x0 }; //"mssdsp.flt"
  797. CHAR __miles_mss32[] = { 'm', 'i', 'l', 'e', 's', '/', '/', 'm', 's', 's', '3', '2', '.', 'd', 'l', 'l', 0x0 }; // miles//mss32.dll
  798. CHAR __mss32[] = { 'm', 's', 's', '3', '2', '.', 'd', 'l', 'l', 0x0 }; //mss32.dll
  799. CHAR __devildll[] = { 'd', 'e', 'v', 'i', 'l', '.', 'd', 'l', 'l', 0x0 }; // devil.dll
  800.  
  801. KARMA_MACRO_1
  802. if (LPData->GetGameCode() == METIN2_GAME)
  803. {
  804. LPDirFunctions->CheckFileCrc(__miles_mss32, 0x6c5812e3);
  805. LPDirFunctions->CheckFileCrc(__mssa3d, 0x6c0abc4c);
  806. LPDirFunctions->CheckFileCrc(__mssds3d, 0xa134de04);
  807. LPDirFunctions->CheckFileCrc(__mssdsp, 0xc88f11bb);
  808. LPDirFunctions->CheckFileCrc(__mssdx7, 0xe173609);
  809. LPDirFunctions->CheckFileCrc(__msseax, 0xbe7c43f7);
  810. LPDirFunctions->CheckFileCrc(__mssmp3, 0x48b4e4d5);
  811. LPDirFunctions->CheckFileCrc(__mssrsx, 0x20d6c7b7);
  812. LPDirFunctions->CheckFileCrc(__msssoft, 0xff5f14f8);
  813. LPDirFunctions->CheckFileCrc(__mssvoice, 0x53ebe0e8);
  814. LPDirFunctions->CheckFileCrc(__mss32, 0x6c5812e3);
  815.  
  816. auto dwDevilCrc = LPDirFunctions->GetFileCrc(__devildll);
  817. if (dwDevilCrc != 0x90f088b8 && dwDevilCrc != 0x68f0df33)
  818. LPDirFunctions->CheckFileCrc(__devildll, 0); // basic wrapper for close & warn
  819. }
  820.  
  821. #ifdef _DEBUG
  822. LPLog->AddLog(0,"Folder check event step1 completed");
  823. #endif
  824.  
  825. KARMA_MACRO_2
  826. LPDirFunctions->MilesCountCheck();
  827. #ifdef _DEBUG
  828. LPLog->AddLog(0,"Folder check event step2 completed");
  829. #endif
  830.  
  831. KARMA_MACRO_1
  832. LPDirFunctions->CheckDirectory("");
  833. #ifdef _DEBUG
  834. LPLog->AddLog(0,"Folder check event step3 completed");
  835. #endif
  836.  
  837. KARMA_MACRO_1
  838. LPDirFunctions->CheckDirectory(__miles);
  839. #ifdef _DEBUG
  840. LPLog->AddLog(0,"Folder check event step4 completed");
  841. #endif
  842.  
  843. KARMA_MACRO_2
  844. LPDirFunctions->MainFolderCheck();
  845. #ifdef _DEBUG
  846. LPLog->AddLog(0,"Folder check event step5 completed");
  847. #endif
  848.  
  849. KARMA_MACRO_1
  850. LPDirFunctions->PackCheck();
  851. #ifdef _DEBUG
  852. LPLog->AddLog(0,"Folder check event step6 completed");
  853. #endif
  854.  
  855. KARMA_MACRO_2
  856. LPDirFunctions->AntiMssExploit();
  857. #ifdef _DEBUG
  858. LPLog->AddLog(0,"Folder check event completed");
  859. #endif
  860.  
  861. KARMA_MACRO_1
  862.  
  863. return 0;
  864. }
  865.  
  866. HANDLE CDirFunctions::InitializeFolderCheck()
  867. {
  868. #ifdef _DEBUG
  869. LPLog->AddLog(0,"Folder check thread creation has been started!");
  870. #endif
  871.  
  872. KARMA_MACRO_1
  873.  
  874. HANDLE hThread = LPThreads->_CreateThread((LPTHREAD_START_ROUTINE)InitializeFolderCheckEx, 0, 3);
  875. if (!hThread) {
  876. CHAR __warn[] = { 'E', 'R', 'R', 'O', 'R', '!', ' ', 'T', 'h', 'r', 'e', 'a', 'd', ' ', 'c', 'r', 'e', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'a', 'i', 'l', 'e', 'd', ',', ' ', 'T', 'h', 'r', 'e', 'a', 'd', ' ', 'C', 'o', 'd', 'e', ' ', '0', 'x', '3', '!', 0x0 }; /* ERROR! Thread creation failed, Thread Code 0x3! */
  877. LPFunctions->CloseProcess(__warn, false, "");
  878. }
  879.  
  880. KARMA_MACRO_2
  881.  
  882. #ifdef _DEBUG
  883. LPLog->AddLog(0,"Folder check thread creation completed!");
  884. #endif
  885. return hThread;
  886. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement