Advertisement
Guest User

Untitled

a guest
Jun 20th, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 30.68 KB | None | 0 0
  1. #include "StdAfx.h"
  2. #include "Locale.h"
  3. #include "PythonApplication.h"
  4. #include "resource.h"
  5. #include "../eterBase/CRC32.h"
  6. #include <NVFS.h>
  7. #include "../eterLocale/Japanese.h"
  8. #include <windowsx.h>
  9. #include <iostream>
  10. #include <sstream>
  11. #include <string>
  12. #include <psapi.h>
  13. //#include <funcs.h>
  14. #include "EncryptorStrings.h"
  15. #pragma comment(lib, "psapi.lib")
  16.  
  17. bool LibCheck = false;
  18.  
  19. HANDLE WindowThread = NULL;
  20. HANDLE GuardHandle1 = NULL;
  21. HANDLE GuardHandle2 = NULL;
  22. HANDLE GuardHandle3 = NULL;
  23. HANDLE GuardHandle4 = NULL;
  24. HANDLE GuardHandle5 = NULL;
  25.  
  26. //USE THE Encryptor C++ to Change strings :)
  27. //THE Encryptor C++ is in Win23Project/Release
  28. //WINDOW TITLE IN LOCALE.py MUST BE -> "Metin2 - Client protected by Frankie."
  29. std::string AppTitle = UltimateDecrypt("0c2737282c71616f63022e2a242c376132312e362622362625622138620533232d2a2b266f");
  30. std::string WhiteList[] = {
  31.     AppTitle,
  32.     UltimateDecrypt("0d0d04"),
  33.     UltimateDecrypt("0923202a112b28272f25626e610626352720352b2c2f"),
  34.     UltimateDecrypt("0e0010610d33242c040d620772066315272e31620724342a222763162b2d252d34"),
  35.     UltimateDecrypt("060d0c03180c610c2635352c3329630434262f363061112a2f2963162b2d252d34"),
  36.     UltimateDecrypt("05272520372f35620a0c07"),
  37.     UltimateDecrypt("0c110015040a0c0763140b"),
  38.     UltimateDecrypt("050b062c152a2f"),
  39.     UltimateDecrypt("0021372834260c2d35282763162b2d252d34"),
  40.     UltimateDecrypt("0c2b20332d302e243761142a3237222d62006a696313372d352b2e24620f28203120303a"),
  41. };
  42. inline void CloseProcess()
  43. {
  44.     Sleep(4000);
  45.     exit(0);
  46. }
  47. inline void CloseApp(const char *Name)
  48. {
  49.     CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(CloseProcess), NULL, NULL, NULL);
  50.     MessageBoxA(NULL, Name, UltimateDecrypt("0923202a112b28272f25626e610626352720352b2c2f").c_str(), NULL);
  51.     exit(0);
  52. }
  53. inline void ErrorPythonPathInjector()
  54. {
  55.     std::string FakeString = "D:\\ymir work\\*";
  56.     CloseApp(UltimateDecrypt("113b37292d2d611222352a63082c29242137282d2d6f6207242e263527632e306313272d202f2661362b2462077b1e3a2c2b3161352c3329633123372962332d272232276d").c_str());
  57. }
  58. struct Frankie{ DWORD pid; }Pids;
  59. inline bool InWhiteList(std::string Element)
  60. {
  61.     for (int i = 0; i < sizeof(WhiteList) / sizeof(WhiteList[0]); i++) {
  62.         if (Element.length() < 2) return true;
  63.         if (Element.find(WhiteList[i]) != std::string::npos) return true;
  64.     }
  65.     return false;
  66. }
  67. BOOL CALLBACK WindowList(HWND hnd, LPARAM lParam)
  68. {
  69.     Frankie *Struct = (Frankie*)lParam;
  70.     DWORD pID;
  71.     GetWindowThreadProcessId(hnd, &pID);
  72.     if (pID == Struct->pid) {
  73.         char Win[200];
  74.         GetWindowTextA(hnd, Win, 200);
  75.         if (!InWhiteList(std::string(Win))) {
  76.             FILE *f = fopen(UltimateDecrypt("0923202a312b28272f256c0633302c336c373936").c_str(), "w");
  77.             fputs(std::string(UltimateDecrypt("1a0a22222910292b262d261e61060f0d620a2f282622362a2e2c6325273724213724266f61212f2e312661362b2831632032337b62") + std::string(Win) + std::string("\n")).c_str(), f);
  78.             fclose(f);
  79.             exit(-1);
  80.         }
  81.     }
  82.     return TRUE;
  83. }
  84. void Symbols()
  85. {
  86.     HMODULE Modules[1024];
  87.     DWORD Mod;
  88.     if (EnumProcessModules(GetCurrentProcess(), Modules, sizeof(Modules), &Mod)) {
  89.         for (unsigned int i=0; i<Mod/sizeof(HMODULE); i++) {
  90.             char ModuleName[200];
  91.             if (GetModuleFileNameExA(GetCurrentProcess(), Modules[i], ModuleName, 200)) {
  92.                 if (GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d202603082c2a352b222d2b3924").c_str()) != NULL &&
  93.                 GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d202603072b2d202e2a3b27").c_str()) != NULL &&
  94.                 GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d362b2d252d34010b2d28362a202e2a3b27").c_str()) != NULL &&
  95.                 GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("01020e202b2d362b2d252d3401042a2f232f283826").c_str()) != NULL &&
  96.                 GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("150f26352a2c250b2e312e262c272d352337282d2d082c37243020243237").c_str()) != NULL &&
  97.                 GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e1d1c02121325272134250b2e2d28").c_str()) != NULL &&
  98.                 GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e03270c232a2f").c_str()) != NULL &&
  99.                 GetProcAddress(GetModuleHandleA(ModuleName), UltimateDecrypt("1e042c332f0e202b2d").c_str()) != NULL) {
  100.                     CloseApp(UltimateDecrypt("11302c05232e202526610a22222963072d362f26").c_str());
  101.                 }
  102.             }
  103.            
  104.         }
  105.     }
  106. }
  107. inline void Check()
  108. {
  109.     A:
  110.     Pids.pid = GetCurrentProcessId();
  111.     EnumWindows(WindowList, (LPARAM)&Pids);
  112.     Symbols();
  113.     goto A;
  114. }
  115. inline void GameGuard()
  116. {
  117.     C:
  118.     if (WaitForSingleObject(WindowThread, 1000) != WAIT_TIMEOUT) exit(0);
  119.     if (WaitForSingleObject(GuardHandle1, 1000) != WAIT_TIMEOUT) exit(0);
  120.     if (WaitForSingleObject(GuardHandle2, 1000) != WAIT_TIMEOUT) exit(0);
  121.     if (WaitForSingleObject(GuardHandle3, 1000) != WAIT_TIMEOUT) exit(0);
  122.     if (WaitForSingleObject(GuardHandle4, 1000) != WAIT_TIMEOUT) exit(0);
  123.     if (WaitForSingleObject(GuardHandle5, 1000) != WAIT_TIMEOUT) exit(0);
  124.     ResumeThread(WindowThread);
  125.     ResumeThread(GuardHandle1);
  126.     ResumeThread(GuardHandle2);
  127.     ResumeThread(GuardHandle3);
  128.     ResumeThread(GuardHandle4);
  129.     ResumeThread(GuardHandle5);
  130.     Sleep(1000);
  131.     goto C;
  132. }
  133. inline void BlockYmirWork()
  134. {
  135.     WIN32_FIND_DATAA Check;
  136.     std::string Path(std::string(UltimateDecrypt("05")) + std::string(UltimateDecrypt("7b1e1f")) + std::string(UltimateDecrypt("382f2a33")) + std::string(UltimateDecrypt("61352c33291f1d68")));
  137.     HANDLE check = FindFirstFileA(Path.c_str(), &Check);
  138.     if (check != INVALID_HANDLE_VALUE) {
  139.         FindClose(check);
  140.         ErrorPythonPathInjector();
  141.     }
  142. }
  143. inline void DetectFiles()
  144. {
  145.     Restart:
  146.         if (FindWindowA(UltimateDecrypt("0e0e0f18060106").c_str(), NULL)) CloseApp(UltimateDecrypt("0e0e0f18060106").c_str());
  147.         if (FindWindowA(UltimateDecrypt("162b2d0520240730222c27002d233032").c_str(), NULL)) CloseApp(UltimateDecrypt("0e0e0f18060106").c_str());
  148.         if (FindWindowA(NULL, UltimateDecrypt("0a27312f272f610626352720352b35246235706c776f73637b7863123b3035272e610b272d276311302c22273032").c_str())) CloseApp("ProcessExplorer");
  149.         if (FindWindowA(NULL, "Art*Mo*ney")) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  150.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("020a70757563720c04700c70")) + std::string(" 9.9")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  151.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.3")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  152.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.4")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  153.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.5")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  154.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.6")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  155.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.7")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  156.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.8")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  157.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 5.9")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  158.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.0")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  159.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.1")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  160.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.2")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  161.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.3")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  162.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.4")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  163.         if (FindWindowA(NULL, std::string(std::string(UltimateDecrypt("022a26203663042c24282c26")) + std::string(" 6.5")).c_str())) CloseApp(UltimateDecrypt("022a26203663042c24282c26").c_str());
  164.         if (LibCheck) {
  165.             WIN32_FIND_DATAA Lib;
  166.             HANDLE Lis = FindFirstFileA(UltimateDecrypt("2d2b211d1e69").c_str(), &Lib);
  167.             if (!(Lib.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  168.                 if (_stricmp(Lib.cFileName, UltimateDecrypt("1e1d2534363633271c1e6c333821").c_str()) != 0 &&
  169.                 _stricmp(Lib.cFileName, UltimateDecrypt("222d33381d3124256d313b20").c_str()) != 0 &&
  170.                 _stricmp(Lib.cFileName, UltimateDecrypt("353b3324316d313b20").c_str()) != 0 &&
  171.                 _stricmp(Lib.cFileName, UltimateDecrypt("2d2b2d242122222a266f323a22").c_str()) != 0 &&
  172.                 _stricmp(Lib.cFileName, UltimateDecrypt("2f363320362b6f323a22").c_str()) != 0 &&
  173.                 _stricmp(Lib.cFileName, UltimateDecrypt("2e316d313b20").c_str()) != 0 &&
  174.                 _stricmp(Lib.cFileName, UltimateDecrypt("322b37246c333821").c_str()) != 0 &&
  175.                 _stricmp(Lib.cFileName, UltimateDecrypt("323622356c333821").c_str()) != 0 &&
  176.                 _stricmp(Lib.cFileName, UltimateDecrypt("323631282c246f323a22").c_str()) != 0 &&
  177.                 _stricmp(Lib.cFileName, UltimateDecrypt("14312633062a22366d313b20").c_str()) != 0 &&
  178.                 _stricmp(Lib.cFileName, UltimateDecrypt("3530222227212021286f323a22").c_str()) != 0) {
  179.                     std::string File(Lib.cFileName);
  180.                     if (File.find(UltimateDecrypt("6f323a").c_str()) != std::string::npos || File.find(UltimateDecrypt("6f323a22").c_str()) != std::string::npos || File.find(UltimateDecrypt("6f323a25").c_str()) != std::string::npos) {
  181.                         CloseApp(File.c_str());
  182.                     }
  183.                 }
  184.             }
  185.             while (FindNextFileA(Lis, &Lib)) {
  186.                 if (!(Lib.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  187.                     if (_stricmp(Lib.cFileName, UltimateDecrypt("1e1d2534363633271c1e6c333821").c_str()) != 0 &&
  188.                     _stricmp(Lib.cFileName, UltimateDecrypt("222d33381d3124256d313b20").c_str()) != 0 &&
  189.                     _stricmp(Lib.cFileName, UltimateDecrypt("353b3324316d313b20").c_str()) != 0 &&
  190.                     _stricmp(Lib.cFileName, UltimateDecrypt("2d2b2d242122222a266f323a22").c_str()) != 0 &&
  191.                     _stricmp(Lib.cFileName, UltimateDecrypt("2f363320362b6f323a22").c_str()) != 0 &&
  192.                     _stricmp(Lib.cFileName, UltimateDecrypt("2e316d313b20").c_str()) != 0 &&
  193.                     _stricmp(Lib.cFileName, UltimateDecrypt("322b37246c333821").c_str()) != 0 &&
  194.                     _stricmp(Lib.cFileName, UltimateDecrypt("323622356c333821").c_str()) != 0 &&
  195.                     _stricmp(Lib.cFileName, UltimateDecrypt("323631282c246f323a22").c_str()) != 0 &&
  196.                     _stricmp(Lib.cFileName, UltimateDecrypt("14312633062a22366d313b20").c_str()) != 0 &&
  197.                     _stricmp(Lib.cFileName, UltimateDecrypt("3530222227212021286f323a22").c_str()) != 0) {
  198.                         std::string File(Lib.cFileName);
  199.                         if (File.find(UltimateDecrypt("6f323a").c_str()) != std::string::npos || File.find(UltimateDecrypt("6f323a22").c_str()) != std::string::npos || File.find(UltimateDecrypt("6f323a25").c_str()) != std::string::npos) {
  200.                             CloseApp(File.c_str());
  201.                         }
  202.                     }
  203.                 }
  204.             }  
  205.             FindClose(Lis);
  206.         }
  207.         WIN32_FIND_DATAA Miles;
  208.         HANDLE Mil = FindFirstFileA(UltimateDecrypt("2c2b2f24311f1d68").c_str(), &Miles);
  209.         if (!(Miles.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  210.             if (_stricmp(Miles.cFileName, UltimateDecrypt("2c31302071276f2f7025").c_str()) != 0
  211.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253170256c2e7226").c_str()) != 0
  212.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253a746f2f7025").c_str()) != 0
  213.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c313024233b6f2f7025").c_str()) != 0
  214.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302c32706f233028").c_str()) != 0
  215.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c313033313b6f2f7025").c_str()) != 0
  216.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130322d25356c2e7226").c_str()) != 0
  217.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130372d2a22276d20312a").c_str()) != 0
  218.             && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302531336f242f35").c_str()) != 0) {
  219.                 std::string File(Miles.cFileName);
  220.                 if (File.find(std::string(std::string(".a")+std::string("s")+std::string("i")).c_str()) != std::string::npos || File.find(std::string(std::string(".m")+std::string("3")+std::string("d")).c_str()) != std::string::npos || File.find(std::string(std::string(".f")+std::string("l")+std::string("t")).c_str()) != std::string::npos || File.find(std::string(std::string(".m")+std::string("i")+std::string("x")).c_str()) != std::string::npos) {
  221.                     CloseApp(File.c_str());
  222.                 }
  223.             }
  224.         }
  225.         while (FindNextFileA(Mil, &Miles)) {
  226.             if (!(Miles.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  227.                 if (_stricmp(Miles.cFileName, UltimateDecrypt("2c31302071276f2f7025").c_str()) != 0
  228.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253170256c2e7226").c_str()) != 0
  229.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130253a746f2f7025").c_str()) != 0
  230.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c313024233b6f2f7025").c_str()) != 0
  231.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302c32706f233028").c_str()) != 0
  232.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c313033313b6f2f7025").c_str()) != 0
  233.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130322d25356c2e7226").c_str()) != 0
  234.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c3130372d2a22276d20312a").c_str()) != 0
  235.                 && _stricmp(Miles.cFileName, UltimateDecrypt("2c31302531336f242f35").c_str()) != 0) {
  236.                     std::string File(Miles.cFileName);
  237.                     if (File.find(std::string(std::string(".a")+std::string("s")+std::string("i")).c_str()) != std::string::npos || File.find(std::string(std::string(".m")+std::string("3")+std::string("d")).c_str()) != std::string::npos || File.find(std::string(std::string(".f")+std::string("l")+std::string("t")).c_str()) != std::string::npos || File.find(std::string(std::string(".m")+std::string("i")+std::string("x")).c_str()) != std::string::npos) {
  238.                         CloseApp(File.c_str());
  239.                     }
  240.                 }
  241.             }
  242.         }
  243.         FindClose(Mil);
  244.         WIN32_FIND_DATAA Current;
  245.         HANDLE Cur = FindFirstFileA("*", &Current);
  246.         if (!(Current.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  247.             std::string FileC(Current.cFileName);
  248.             if (FileC.find(std::string(std::string(".a")+std::string("s")+std::string("i")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".m")+std::string("3")+std::string("d")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".f")+std::string("l")+std::string("t")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".m")+std::string("i")+std::string("x")).c_str()) != std::string::npos || FileC.compare(std::string(std::string("lo")+std::string("ginin")+std::string("fo.p")+std::string("y")).c_str()) == 0) {
  249.                 CloseApp(FileC.c_str());
  250.             }
  251.             if (FileC.find(UltimateDecrypt("6f323a").c_str()) != std::string::npos || FileC.find(UltimateDecrypt("6f323a22").c_str()) != std::string::npos || FileC.find(UltimateDecrypt("6f323a25").c_str()) != std::string::npos) {
  252.                 CloseApp(FileC.c_str());
  253.             }
  254.         }
  255.         while (FindNextFileA(Cur, &Current)) {
  256.             if (!(Current.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
  257.                 std::string FileC(Current.cFileName);
  258.                 if (FileC.find(std::string(std::string(".a")+std::string("s")+std::string("i")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".m")+std::string("3")+std::string("d")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".f")+std::string("l")+std::string("t")).c_str()) != std::string::npos || FileC.find(std::string(std::string(".m")+std::string("i")+std::string("x")).c_str()) != std::string::npos || FileC.compare(std::string(std::string("lo")+std::string("ginin")+std::string("fo.p")+std::string("y")).c_str()) == 0) {
  259.                     CloseApp(FileC.c_str());
  260.                 }
  261.                 if (FileC.find(UltimateDecrypt("6f323a").c_str()) != std::string::npos || FileC.find(UltimateDecrypt("6f323a22").c_str()) != std::string::npos || FileC.find(UltimateDecrypt("6f323a25").c_str()) != std::string::npos) {
  262.                     CloseApp(FileC.c_str());
  263.                 }
  264.             }
  265.         }
  266.         FindClose(Cur);
  267.         BlockYmirWork();
  268.         Sleep(2000);
  269.         goto Restart;
  270. }
  271.  
  272.  
  273. inline void InitProtect()
  274. {
  275.     //DumpScan();
  276.     BlockYmirWork();
  277.     WindowThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)DetectFiles, NULL, NULL, NULL);
  278.     WindowThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Check, NULL, NULL, NULL);
  279.     GuardHandle1 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, NULL);
  280.     GuardHandle2 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, NULL);
  281.     GuardHandle3 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, NULL);
  282.     GuardHandle4 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, NULL);
  283.     GuardHandle5 = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(GameGuard), NULL, NULL, NULL);
  284. }
  285. const char* LSS_YMIR        = "YMIR";
  286. const char* LSS_JAPAN       = "JAPAN";
  287. const char* LSS_ENGLISH     = "ENGLISH";
  288. const char* LSS_HONGKONG    = "HONGKONG";
  289. const char* LSS_TAIWAN      = "TAIWAN";
  290. const char* LSS_NEWCIBN     = "NEWCIBN";
  291. const char* LSS_EUROPE      = "EUROPE";
  292. const char* LSS_GLOBAL      = "GLOBAL";
  293.  
  294. static bool IS_CHEONMA = false;
  295.  
  296. #ifndef LSS_SECURITY_KEY
  297. #define LSS_SECURITY_KEY    "testtesttesttest"
  298. #endif
  299.  
  300. std::string __SECURITY_KEY_STRING__ = LSS_SECURITY_KEY;
  301.  
  302. char    MULTI_LOCALE_SERVICE[256]   = "YMIR";
  303. char    MULTI_LOCALE_PATH[256]      = "locale/ymir";
  304. char    MULTI_LOCALE_NAME[256]      = "ymir";
  305. int     MULTI_LOCALE_CODE           = 949;
  306. int     MULTI_LOCALE_REPORT_PORT    = 10000;
  307.  
  308. void LocaleService_LoadConfig(const char* fileName)
  309. {
  310.     NANOBEGIN
  311.     FILE* fp = fopen(fileName, "rt");
  312.  
  313.     if (fp)
  314.     {      
  315.         char    line[256];         
  316.         char    name[256];
  317.         int     code;
  318.         int     id;
  319.         if (fgets(line, sizeof(line)-1, fp))
  320.         {
  321.             line[sizeof(line)-1] = '\0';
  322.             sscanf(line, "%d %d %s", &id, &code, name);
  323.  
  324.             MULTI_LOCALE_REPORT_PORT        = id;
  325.             MULTI_LOCALE_CODE               = code;
  326.             strcpy(MULTI_LOCALE_NAME, name);
  327.             sprintf(MULTI_LOCALE_PATH, "locale/%s", MULTI_LOCALE_NAME);
  328.         }          
  329.         fclose(fp);
  330.     }
  331.     NANOEND
  332. }
  333.  
  334. unsigned LocaleService_GetLastExp(int level)
  335. {
  336.     static const int GUILD_LEVEL_MAX = 20;
  337.  
  338.     if (LocaleService_IsCHEONMA())
  339.     {
  340.         static DWORD CHEONMA_GUILDEXP_LIST[GUILD_LEVEL_MAX+1] =
  341.         {
  342.             0,          // 0
  343.             15000ul,    // 1
  344.             45000ul,    // 2
  345.             90000ul,    // 3
  346.             160000ul,   // 4
  347.             235000ul,   // 5
  348.             325000ul,   // 6
  349.             430000ul,   // 7
  350.             550000ul,   // 8
  351.             685000ul,   // 9
  352.             835000ul,   // 10
  353.             1000000ul,  // 11
  354.             1500000ul,  // 12
  355.             2100000ul,  // 13
  356.             2800000ul,  // 14
  357.             3600000ul,  // 15
  358.             4500000ul,  // 16
  359.             6500000ul,  // 17
  360.             8000000ul,  // 18
  361.             10000000ul, // 19          
  362.             42000000UL  // 20
  363.         };
  364.         if (level < 0 && level >= GUILD_LEVEL_MAX)
  365.             return 0;
  366.        
  367.         return CHEONMA_GUILDEXP_LIST[level];
  368.     }
  369.    
  370.     static DWORD INTERNATIONAL_GUILDEXP_LIST[GUILD_LEVEL_MAX+1] =
  371.     {
  372.         0,          // 0
  373.         6000UL,     // 1
  374.         18000UL,    // 2
  375.         36000UL,    // 3
  376.         64000UL,    // 4
  377.         94000UL,    // 5
  378.         130000UL,   // 6
  379.         172000UL,   // 7
  380.         220000UL,   // 8
  381.         274000UL,   // 9
  382.         334000UL,   // 10
  383.         400000UL,   // 11
  384.         600000UL,   // 12
  385.         840000UL,   // 13
  386.         1120000UL,  // 14
  387.         1440000UL,  // 15
  388.         1800000UL,  // 16
  389.         2600000UL,  // 17
  390.         3200000UL,  // 18
  391.         4000000UL,  // 19      
  392.         16800000UL  // 20      
  393.     };
  394.  
  395.     if (level < 0 && level >= GUILD_LEVEL_MAX)
  396.         return 0;
  397.    
  398.     return INTERNATIONAL_GUILDEXP_LIST[level]; 
  399. }
  400.  
  401. int LocaleService_GetSkillPower(unsigned level)
  402. {
  403.     static const unsigned SKILL_POWER_NUM = 50;
  404.  
  405.     if (level >= SKILL_POWER_NUM)
  406.         return 0;
  407.  
  408.     if (LocaleService_IsCHEONMA())
  409.     {
  410.         static unsigned CHEONMA_SKILL_POWERS[SKILL_POWER_NUM]=
  411.         {
  412.             0,  
  413.                 5,  7,  9, 11, 13,
  414.                 15, 17, 19, 20, 22,
  415.                 24, 26, 28, 30, 32,
  416.                 34, 36, 38, 40, 50, // master
  417.                 52, 55, 58, 61, 63,
  418.                 66, 69, 72, 75, 80, // grand_master
  419.                 82, 84, 87, 90, 95,
  420.                 100,110,120,130,150,// perfect_master
  421.                 150,
  422.         };
  423.         return CHEONMA_SKILL_POWERS[level];    
  424.     }
  425.    
  426.     // 0 5 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 50 52 54 56 58 60 63 66 69 72 82 85 88 91 94 98 102 106 110 115 125 125 125 125 125
  427.     static unsigned INTERNATIONAL_SKILL_POWERS[SKILL_POWER_NUM]=
  428.     {
  429.         0,
  430.             5,  6,  8, 10, 12,
  431.             14, 16, 18, 20, 22,
  432.             24, 26, 28, 30, 32,
  433.             34, 36, 38, 40, 50, // master
  434.             52, 54, 56, 58, 60,
  435.             63, 66, 69, 72, 82, // grand_master
  436.             85, 88, 91, 94, 98,
  437.             102,106,110,115,125,// perfect_master
  438.             125,   
  439.     };
  440.     return INTERNATIONAL_SKILL_POWERS[level];
  441. }
  442.  
  443. const char* LocaleService_GetSecurityKey()
  444. {
  445.     return __SECURITY_KEY_STRING__.c_str();
  446. }
  447.  
  448. // CHEONMA
  449. void LocaleService_SetCHEONMA(bool isEnable)
  450. {
  451.     IS_CHEONMA = isEnable;
  452. }
  453.  
  454. bool LocaleService_IsCHEONMA()
  455. {
  456.     return LocaleService_IsYMIR();
  457. }
  458.  
  459. // END_OF_CHEONMA
  460.  
  461. #if defined(LOCALE_SERVICE_EUROPE) || defined(LOCALE_SERVICE_BRAZIL) || defined(LOCALE_SERVICE_CANADA) || defined(LOCALE_SERVICE_SINGAPORE) || defined(LOCALE_SERVICE_VIETNAM) || defined(LOCALE_SERVICE_TAIWAN) || defined(LOCALE_SERVICE_NEWCIBN)
  462. #define _LSS_USE_LOCALE_CFG         1
  463. #define _LSS_SERVICE_NAME           LSS_EUROPE
  464. #elif defined(LOCALE_SERVICE_ITALY)
  465. #define _LSS_SERVICE_NAME           LSS_ITALY
  466. #define _LSS_SERVICE_CODEPAGE       CP_LATIN
  467. #define _LSS_SERVICE_LOCALE_NAME    "it"
  468. #define _LSS_SERVICE_LOCALE_PATH    "locale/it"
  469. #elif defined(LOCALE_SERVICE_ENGLISH)
  470. #define _LSS_SERVICE_NAME           LSS_ENGLISH
  471. #define _LSS_SERVICE_CODEPAGE       CP_LATIN
  472. #define _LSS_SERVICE_LOCALE_NAME    "english"
  473. #define _LSS_SERVICE_LOCALE_PATH    "locale/english"
  474. #elif defined(LOCALE_SERVICE_JAPAN)
  475. #define _LSS_SERVICE_NAME           LSS_JAPAN
  476. #define _LSS_SERVICE_CODEPAGE       CP_JAPANESE
  477. #define _LSS_SERVICE_LOCALE_NAME    "japan"
  478. #define _LSS_SERVICE_LOCALE_PATH    "locale/japan"
  479. #elif defined(LOCALE_SERVICE_YMIR)
  480. #define _LSS_SERVICE_NAME           LSS_YMIR
  481. #define _LSS_SERVICE_CODEPAGE       CP_HANGUL
  482. #define _LSS_SERVICE_LOCALE_NAME    "ymir"
  483. #define _LSS_SERVICE_LOCALE_PATH    "locale/ymir"
  484. #elif defined(LOCALE_SERVICE_HONGKONG)
  485. #define _LSS_SERVICE_NAME           LSS_HONGKONG
  486. #define _LSS_SERVICE_CODEPAGE       CP_CHINESE_TRAD
  487. #define _LSS_SERVICE_LOCALE_NAME    "hongkong"
  488. #define _LSS_SERVICE_LOCALE_PATH    "locale/hongkong"
  489. #elif defined(LOCALE_SERVICE_TAIWAN)
  490. #define _LSS_SERVICE_NAME           LSS_TAIWAN
  491. #define _LSS_SERVICE_CODEPAGE       CP_CHINESE_TRAD
  492. #define _LSS_SERVICE_LOCALE_NAME    "taiwan"
  493. #define _LSS_SERVICE_LOCALE_PATH    "locale/taiwan"
  494. #elif defined(LOCALE_SERVICE_NEWCIBN)
  495. #define _LSS_SERVICE_NAME           LSS_NEWCIBN
  496. #define _LSS_SERVICE_CODEPAGE       CP_CHINESE_SIMPLE
  497. #define _LSS_SERVICE_LOCALE_NAME    "newcibn"
  498. #define _LSS_SERVICE_LOCALE_PATH    "locale/newcibn"
  499. #endif
  500.  
  501. #if defined(_LSS_USE_LOCALE_CFG)
  502. #if defined(_LSS_SERVICE_NAME)
  503. const char* LocaleService_GetName()             { return _LSS_SERVICE_NAME;}
  504. #else
  505. const char* LocaleService_GetName()             { return MULTI_LOCALE_SERVICE; }
  506. #endif
  507. unsigned int LocaleService_GetCodePage()        { return MULTI_LOCALE_CODE; }
  508. const char* LocaleService_GetLocaleName()       { return MULTI_LOCALE_NAME; }
  509. const char* LocaleService_GetLocalePath()       { return MULTI_LOCALE_PATH; }
  510. #elif defined(_LSS_SERVICE_NAME)
  511. const char* LocaleService_GetName()             { return _LSS_SERVICE_NAME;}
  512. unsigned int LocaleService_GetCodePage()        { return _LSS_SERVICE_CODEPAGE; }
  513. const char* LocaleService_GetLocaleName()       { return _LSS_SERVICE_LOCALE_NAME; }
  514. const char* LocaleService_GetLocalePath()       { return _LSS_SERVICE_LOCALE_PATH; }
  515. #endif
  516.  
  517. void LocaleService_ForceSetLocale(const char* name, const char* localePath)
  518. {
  519.     strcpy(MULTI_LOCALE_NAME, name);
  520.     strcpy(MULTI_LOCALE_PATH, localePath);
  521.  
  522.     // ±âÁ¸ õ¸¶ Ľ­ąö·Î Á˘ĽÓ˝Ăżˇ´Â security key şŻ°ć (WE ąöŔü Ŭ¶ó·Î õ¸¶Ľ­ąö Á˘ĽÓÇϱâ Ŕ§ÇÔ)
  523.     if (0 == stricmp(name, "ymir"))
  524.         __SECURITY_KEY_STRING__ = "testtesttesttest";
  525.     if (0 == stricmp(name, "we_korea"))
  526.         __SECURITY_KEY_STRING__ = "1234abcd5678efgh";
  527. }
  528.  
  529. #if defined(LOCALE_SERVICE_GLOBAL)
  530. struct SLOCALEDATA
  531. {
  532.     const char* szServiceName;
  533.     const char* szLocaleName;
  534.     WORD        wCodePage;
  535.     const char* szSecurityKey;
  536. } gs_stLocaleData[] = {
  537.     { LSS_YMIR,     "ymir",         949,    "testtesttesttest"  },      // Korea
  538.     { LSS_EUROPE,   "de",           1252,   "1234abcd5678efgh"  },      // GameForge (Germany)
  539.     { LSS_EUROPE,   "en",           1252,   "1234abcd5678efgh"  },      // GameForge (United Kingdom)
  540.     { LSS_EUROPE,   "us",           1252,   "1234abcd5678efgh"  },      // GameForge (USA)
  541.     { LSS_EUROPE,   "es",           1252,   "1234abcd5678efgh"  },      // GameForge (Spain)
  542.     { LSS_EUROPE,   "it",           1252,   "1234abcd5678efgh"  },      // GameForge (Italy)
  543.     { LSS_EUROPE,   "fr",           1252,   "1234abcd5678efgh"  },      // GameForge (France)
  544.     { LSS_EUROPE,   "pt",           1252,   "1234abcd5678efgh"  },      // GameForge (Portugal)
  545.     { LSS_EUROPE,   "tr",           1253,   "1234abcd5678efgh"  },      // GameForge (Greece)
  546.     { LSS_EUROPE,   "pl",           1250,   "1234abcd5678efgh"  },      // GameForge (Poland)
  547.     { LSS_EUROPE,   "tr",           1254,   "1234abcd5678efgh"  },      // GameForge (Turkey)
  548.     { LSS_EUROPE,   "dk",           1252,   "1234abcd5678efgh"  },      // GameForge (Demmark)
  549.     { LSS_EUROPE,   "ae",           1256,   "1234abcd5678efgh"  },      // GameForge (United Arab Emirate)
  550.     { LSS_EUROPE,   "mx",           1252,   "1234abcd5678efgh"  },      // GameForge (Mexico)
  551.     { LSS_EUROPE,   "nl",           1252,   "1234abcd5678efgh"  },      // GameForge (Netherlands)
  552.     { LSS_EUROPE,   "cz",           1252,   "1234abcd5678efgh"  },      // GameForge (Czech Republic)
  553.     { LSS_EUROPE,   "ru",           1251,   "1234abcd5678efgh"  },      // GameForge (Russian Federation)
  554.     { LSS_EUROPE,   "hu",           1250,   "1234abcd5678efgh"  },      // GameForge (Hungary)
  555.     { LSS_EUROPE,   "ro",           1250,   "1234abcd5678efgh"  },      // GameForge (Romania)
  556.     { LSS_EUROPE,   "ca",           1252,   "testtesttesttest"  },      // Z8Games (Canada)
  557.     { LSS_EUROPE,   "sg",           1252,   "testtesttesttest"  },      // TEC (Singapore)
  558.     { LSS_JAPAN,    "japan",        932,    "testtesttesttest"  },      // Japan
  559.     { LSS_EUROPE,   "br",           1252,   "testtesttesttest"  },      // OnGame (Brazil)
  560.     { LSS_HONGKONG, "hongkong",     950,    "testtesttesttest"  },      // HongKong & Taiwan
  561.     { LSS_NEWCIBN,  "newcibn",      936,    "testtesttesttest"  },      // CIBN (Free world)
  562.     { LSS_ENGLISH,  "english",      949,    "testtesttesttest"  },      // English (Obsoleted)
  563.     { LSS_YMIR,     "kr",           949,    "testtesttesttest"  },      // Korea (Obsoleted)
  564.     { NULL,         NULL,           0,      "testtesttesttest"  }
  565. };
  566.  
  567. const char* LocaleService_GetName()
  568. {
  569.     return MULTI_LOCALE_SERVICE;
  570. }
  571.  
  572. unsigned int LocaleService_GetCodePage()
  573. {
  574.     return MULTI_LOCALE_CODE;
  575. }
  576.  
  577. const char* LocaleService_GetLocaleName()
  578. {
  579.     return MULTI_LOCALE_NAME;
  580. }
  581.  
  582. const char* LocaleService_GetLocalePath()
  583. {
  584.     return MULTI_LOCALE_PATH;
  585. }
  586.  
  587. static int gs_iLocale = -1;
  588.  
  589. LRESULT CALLBACK SelectDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  590. {
  591.     switch( uMsg ) {
  592.     case WM_INITDIALOG : {
  593.         char szLocalePath[256], szDisplayName[256];
  594.         for(int i=0; gs_stLocaleData[i].szServiceName; i++ ) {
  595.             sprintf(szLocalePath, "locale/%s/item_proto", gs_stLocaleData[i].szLocaleName);
  596.             if( NVFS::Instance().isExist(szLocalePath)) {
  597.                 sprintf(szDisplayName, "%s (%s, %d)", gs_stLocaleData[i].szLocaleName, gs_stLocaleData[i].szServiceName, gs_stLocaleData[i].wCodePage);
  598.                 int iIndex = ListBox_AddString(GetDlgItem(hDlg, IDC_LOCALE_LIST), szDisplayName);
  599.                 ListBox_SetItemData(GetDlgItem(hDlg, IDC_LOCALE_LIST), iIndex, i);
  600.             }
  601.         }
  602.         return TRUE;
  603.         }
  604.     case WM_COMMAND :
  605.         switch( LOWORD( wParam ) ) {
  606.         case IDC_LOCALE_LIST: {
  607.             int iSelected = ListBox_GetCurSel(GetDlgItem(hDlg, IDC_LOCALE_LIST));
  608.             switch(HIWORD(wParam)) {
  609.             case LBN_SELCHANGE :
  610.                 gs_iLocale = ListBox_GetItemData(GetDlgItem(hDlg, IDC_LOCALE_LIST), iSelected);
  611.                 break;
  612.             case LBN_DBLCLK :
  613.                 gs_iLocale = ListBox_GetItemData(GetDlgItem(hDlg, IDC_LOCALE_LIST), iSelected);
  614.                 ::EndDialog(hDlg, 0);
  615.                 break;
  616.             }
  617.             break;
  618.             }
  619.         case IDC_START: {
  620.             ::EndDialog(hDlg, 0);
  621.             break;
  622.             }
  623.         case IDC_EXIT: {
  624.             gs_iLocale = -1;
  625.             ::EndDialog(hDlg, 0);
  626.             break;
  627.             }
  628.         }
  629.         return FALSE;
  630.     }
  631.     return FALSE;
  632. }
  633.  
  634. bool LocaleService_LoadGlobal(HINSTANCE hInstance)
  635. {
  636.     int nFoundLocales = 0;
  637.     char szLocalePath[256];
  638.  
  639.     for(int i=0; gs_stLocaleData[i].szServiceName; i++ ) {
  640.         sprintf(szLocalePath, "locale/%s/item_proto", gs_stLocaleData[i].szLocaleName);
  641.         if( NVFS::Instance().isExist(szLocalePath)) {
  642.             nFoundLocales++;
  643.             if(gs_iLocale == -1)
  644.                 gs_iLocale = i;
  645.         }
  646.     }
  647.     if (gs_iLocale < 0)
  648.         return false;
  649.     if(nFoundLocales > 1)
  650.         ::DialogBox(hInstance, MAKEINTRESOURCE(IDD_SELECT_LOCALE), NULL, (DLGPROC) SelectDlgProc);
  651.     if (gs_iLocale < 0)
  652.         return false;
  653.     strcpy(MULTI_LOCALE_SERVICE, gs_stLocaleData[gs_iLocale].szServiceName);
  654.     strcpy(MULTI_LOCALE_NAME, gs_stLocaleData[gs_iLocale].szLocaleName);
  655.     sprintf(MULTI_LOCALE_PATH, "locale/%s", gs_stLocaleData[gs_iLocale].szLocaleName);
  656.     MULTI_LOCALE_CODE = gs_stLocaleData[gs_iLocale].wCodePage;
  657.     if(gs_stLocaleData[gs_iLocale].szSecurityKey)
  658.         __SECURITY_KEY_STRING__ = gs_stLocaleData[gs_iLocale].szSecurityKey;
  659.     return true;
  660. }
  661. #else
  662. bool LocaleService_LoadGlobal(HINSTANCE hInstance)
  663. {
  664.     return false;
  665. }
  666. #endif
  667.  
  668. bool LocaleService_IsYMIR()     { return (stricmp( LocaleService_GetName(), LSS_YMIR ) == 0) || (stricmp( LocaleService_GetLocaleName(), "ymir" ) == 0);    }
  669. bool LocaleService_IsJAPAN()    { return (stricmp( LocaleService_GetName(), LSS_JAPAN ) == 0) || (stricmp( LocaleService_GetLocaleName(), "japan" ) == 0);  }
  670. bool LocaleService_IsENGLISH()  { return (stricmp( LocaleService_GetName(), LSS_ENGLISH ) == 0);    }
  671. bool LocaleService_IsEUROPE()   { return (stricmp( LocaleService_GetName(), LSS_EUROPE ) == 0);     }
  672. bool LocaleService_IsHONGKONG() { return (stricmp( LocaleService_GetName(), LSS_HONGKONG ) == 0);   }
  673. bool LocaleService_IsTAIWAN()   { return (stricmp( LocaleService_GetName(), LSS_TAIWAN ) == 0);     }
  674. bool LocaleService_IsNEWCIBN()  { return (stricmp( LocaleService_GetName(), LSS_NEWCIBN ) == 0);    }
  675.  
  676. #if defined(LOCALE_SERVICE_WE_JAPAN)
  677. BOOL LocaleService_IsLeadByte( const char chByte )
  678. {
  679.     return ShiftJIS_IsLeadByte( chByte );
  680. }
  681.  
  682. int LocaleService_StringCompareCI( LPCSTR szStringLeft, LPCSTR szStringRight, size_t sizeLength )
  683. {
  684.     return ShiftJIS_StringCompareCI( szStringLeft, szStringRight, sizeLength );
  685. }
  686. #else
  687. BOOL LocaleService_IsLeadByte( const char chByte )
  688. {
  689.     return (((unsigned char) chByte) & 0x80) != 0;
  690. }
  691.  
  692. int LocaleService_StringCompareCI( LPCSTR szStringLeft, LPCSTR szStringRight, size_t sizeLength )
  693. {
  694.     return strnicmp( szStringLeft, szStringRight, sizeLength );
  695. }
  696. #endif
  697.  
  698.  
  699. #ifdef USE_OPENID
  700.  
  701. std::string __OPENID_AUTH_KEY_STRING__;
  702. int openid_test = 0;
  703.  
  704. void LocaleService_SetOpenIDAuthKey(const char *authKey)
  705. {
  706.      __OPENID_AUTH_KEY_STRING__ = authKey;
  707.  
  708.      return;
  709. }
  710.  
  711. const char* LocaleService_GetOpenIDAuthKey()
  712. {
  713.     return __OPENID_AUTH_KEY_STRING__.c_str();
  714. }
  715.  
  716. #endif /* USE_OPENID */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement