Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 11.37 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Main.h"
  7. #include "fConfigEditor.h" // Include the editor!
  8. #include "fItemBuilder.h" // Include the item builder!
  9. #include "fPWSnappy.h" // Include the PW Snappy
  10. #include "fAutoClicker.h" // Include Auto Clicker!
  11. #include "fMultiClient.h" // Include the MultiClient
  12.  
  13. // Perl Stuff etc
  14. #include "PerlWrapper.h" // Allows full use of perl
  15. #include "XFuncs.h" // Some useful functions
  16. #include "XFuncsCPP.h" // Some useful functions
  17.  
  18. #include <vector>
  19.  
  20. // Variables
  21. const AnsiString GameCapX = "unset";
  22. const AnsiString GameClsX = "unset";
  23. //UnicodeString CGIURL = "http://d2realm.no-ip.org/Scripts/PWTool/PWTool.php";
  24. UnicodeString CGIURL = "https://d2realm.no-ip.org:8043/Scripts/PWTool/PWTool.php";
  25. UnicodeString CGIPOST = "?";
  26. int iInetCount = 0;
  27. UnicodeString sLastCommand = "";
  28.  
  29. // This function is used to check if a function is on or off and put status into edit box accordingly
  30. void FuncOnOff(TEdit* eEditBX, AnsiString GameCls, AnsiString GameCap, AnsiString Address, AnsiString Checker){
  31.     if(SameText(Checker, XFuncs::ReadMemory(GameCls, GameCap, Address, 1, "HEX"))){
  32.         eEditBX->Text = "ON";
  33.     }else{
  34.         eEditBX->Text = "OFF";
  35.     }
  36. }
  37.  
  38. // This function pokes to memory the value from an editbox control
  39. void DoReadDec(TEdit* eEditBX, AnsiString GameCls, AnsiString GameCap, AnsiString Address, AnsiString ReadSize){
  40.     int MaxVal;
  41.     int MinVal;
  42.     if(SameText(ReadSize, "DWORD")){
  43.         MaxVal = 268435455;
  44.         MinVal = 0;
  45.     }else if(SameText(ReadSize, "WORD")){
  46.         MaxVal = 65535;
  47.         MinVal = 0;
  48.     }else if(SameText(ReadSize, "BYTE")){
  49.         MaxVal = 255;
  50.         MinVal = 0;
  51.     }else{
  52.         MaxVal = 268435455;
  53.         MinVal = 0;
  54.     }
  55.     XFuncs::PokeResolve(GameCls, GameCap, "Poke " + Address + " " + XFuncs::DecToPoke(XFuncs::CheckValidInt(eEditBX->Text.Trim(), MinVal, MaxVal), ReadSize));
  56. }
  57.  
  58. // This function is used to check if a function is on or off and put status into edit box accordingly
  59. void ResolveOutput(TMemo* tmOutput, AnsiString sOutput){
  60.     tmOutput->Lines->Clear();
  61.     // Lets make a PERL array and cycle it
  62.     PArray paOutputArray; // Define the array
  63.     paOutputArray.InitArray("sOutputTxT");
  64.     XFuncs::RegexSplit("sOutputTxT", sOutput, "<BR>");
  65.     int ArraySize;
  66.     paOutputArray.Size(ArraySize);
  67.     AnsiString MyStr, TmpBuf;
  68.     int loop;
  69.     for(loop = 0; loop < ArraySize; loop++){
  70.         if(paOutputArray.Get(loop, MyStr)){ // Make sure this element exists
  71.             if(XFuncs::RegexMatch(MyStr, "^Login error!")){
  72.                 ShowMessage("It seems you have not logged in correctly.... You must edit the config file by selecting \"Edit Config File\" from File menu; The Editor will be opened now.");
  73.                 ConfigEdit->ShowModal();
  74.             }else if(XFuncs::RegexMatchEx(MyStr, "^Func_WriteFileASCII\\(\"(.*)\",\"(.*)\"\\);$")){ // Write File ASCII Command
  75.                 AnsiString sFileName, sFileText;
  76.                 sFileName = XFuncs::RegexMatchGroup(1);
  77.                 sFileText = XFuncs::RegexMatchGroup(2);
  78.                 sFileText = XFuncs::Hex2Str(sFileText);
  79.                 sFileText = XFuncs::Trim(sFileText);
  80.                 XFuncs::WriteFileASCII(sFileName, sFileText);
  81.             }else if(XFuncs::RegexMatchRet(TmpBuf, 1, MyStr, "^Func_EXEC\\(\"(.*)\"\\);$")){ // Execute system command
  82.                 if(FileExists(TmpBuf)){
  83.                     system(TmpBuf.c_str());
  84.                 }else{
  85.                     ShowMessage("File '" + MyStr + "' does not exist!");
  86.                 }
  87.             }else if(XFuncs::RegexMatchRet(TmpBuf, 1, MyStr, "^Func_PEXEC\\(\"(.*)\"\\);$")){ // Execute perl command
  88.                 TmpBuf = XFuncs::Hex2Str(TmpBuf);
  89.                 CPerlWrap::doScript(TmpBuf);
  90.             }else{
  91.                 tmOutput->Lines->Add(MyStr);
  92.             }
  93.         }
  94.     }
  95.     paOutputArray.Destroy(); // Remove the array
  96. }
  97.  
  98. // This function is used to check the input for special modifiers
  99. AnsiString ResolveIntput(AnsiString sInput){
  100.     AnsiString TmpBuf, RetVal, RetStr;
  101.     int iFinished = 0;
  102.     // Loop until all special funtions have been found!
  103.     while(iFinished == 0){
  104.         // Clear buffers first
  105.         TmpBuf = "";
  106.         RetVal = "";
  107.         RetStr = "";
  108.         if(XFuncs::RegexMatchRet(TmpBuf, 1, sInput, "!\"(.{1,})\"")){ // Check if we need to replace something with a file!
  109.             if(FileExists(TmpBuf)){
  110.                 if(XFuncs::ReadFileASCII(RetVal, TmpBuf)){
  111.                     RetVal = XFuncs::Str2Hex(RetVal); // Convert it to hex!
  112.                     // Place it back into string
  113.                     if(XFuncs::RegexReplace(sInput, "\"" + RetVal + "\"", "!\"(.{1,})\"", RetStr)){
  114.                         return RetStr;
  115.                     }else{
  116.                         iFinished = 1; // Signal end of the loop
  117.                         ShowMessage("Failed to rebuild string for ASCII file get");
  118.                     }
  119.                 }else{
  120.                 iFinished = 1; // Signal end of the loop
  121.                     ShowMessage("Unable to get data from file '" + TmpBuf + "'");
  122.                 }
  123.             }else{
  124.                 iFinished = 1; // Signal end of the loop
  125.                 ShowMessage("File '" + TmpBuf + "' does not exist!");
  126.             }
  127.         }else{
  128.             iFinished = 1; // Signal end of the loop
  129.         }
  130.     }
  131.     return sInput;
  132. }
  133.  
  134. // TimerCode
  135. //  FuncOnOff(eRevealMap, GameClsX, GameCapX, "4B1110", "E9");
  136. //  FuncOnOff(eControl, GameClsX, GameCapX, "4B5B3E", "90");
  137. //  FuncOnOff(eInfiniteRange, GameClsX, GameCapX, "49AEE0", "E9");
  138. //  FuncOnOff(ePromotion, GameClsX, GameCapX, "49E425", "90");
  139. //  FuncOnOff(eUltimateDiplomacy, GameClsX, GameCapX, "45E954", "E9");
  140. //  FuncOnOff(eManpower, GameClsX, GameCapX, "43F381", "90");
  141. //  FuncOnOff(eUnitBuild, GameClsX, GameCapX, "43EEEE", "90");
  142. //  FuncOnOff(eInjection, GameClsX, GameCapX, "439E86", "E9");
  143. //  FuncOnOff(eMegaResources, GameClsX, GameCapX, "42704B", "90");
  144. //  FuncOnOff(eActiveBlueprint, GameClsX, GameCapX, "5461EF", "90");
  145. //  eSlider->Text = XFuncs::ReadMemory(GameClsX, GameCapX, "40035D", 1, "DEC");
  146. //  eTechID->Text = XFuncs::ReadMemory(GameClsX, GameCapX, "400600", 4, "DEC");
  147. //  // Hotkeys (10 = Shift , 11 = Control)
  148. //  if(GetKeyState(0x11) & 0x000000F0 && GetKeyState(0x10) & 0x000000F0 && GetKeyState(0x41) & 0x000000F0){
  149. //      bInfiniteRangeClick(Sender);
  150. //  }
  151. // Button code
  152. //  if(SameText("E9", XFuncs::ReadMemory(GameClsX, GameCapX, "4B1110", 1, "HEX"))){
  153. //      XFuncs::PokeResolve(GameClsX, GameCapX, "Poke 4B1110 A0 AC A6 2B 01");
  154. //  }else{
  155. //      XFuncs::PokeResolve(GameClsX, GameCapX, "Poke 4B1110 E9 6B F5 F4 FF\n"
  156. //          "Poke 400680 C6 05 AC A6 2B 01 01 A0 AC A6 2B\n"
  157. //          "Poke 40068B 01 E9 84 0A 0B 00"
  158. //      );
  159. //  }
  160. // EditBox change
  161. //DoReadDec(eSlider, GameClsX, GameCapX, "40035D", "BYTE");
  162.  
  163. //---------------------------------------------------------------------------
  164. #pragma package(smart_init)
  165. #pragma link "SHDocVw_OCX"
  166. #pragma resource "*.dfm"
  167. TForm1 *Form1;
  168. //---------------------------------------------------------------------------
  169. void __fastcall TForm1::SetCurrentLoginStatus(AnsiString sLoginX) {
  170.     eLoginDetails->Text = "Current login: " + sLoginX;
  171. }
  172. //---------------------------------------------------------------------------
  173. __fastcall TForm1::TForm1(TComponent* Owner)
  174.     : TForm(Owner)
  175. {
  176.     CPerlWrap::InitPerl(TRUE); // Required for use of all perl functions
  177.     XFuncs::InitXFuncs(); // Required for many parts of XFuncs including read/write memory!
  178.  
  179.     // Load config file
  180.     /* Open an instance */
  181.     TCustomIniFile* SettingsFile = new TIniFile(ChangeFileExt("./Config.ini", ".ini"));;
  182.  
  183.     try {
  184.         sLogin = SettingsFile->ReadString("General", "Login", "Unset");
  185.         sPassword = SettingsFile->ReadString("General", "Password", "Unset");
  186.         sPassword2 = SettingsFile->ReadString("General", "Password2", "Unset");
  187.         SetCurrentLoginStatus(sLogin);
  188.     }catch(Exception* e){
  189.     }
  190.  
  191.     delete SettingsFile;
  192. }
  193. //---------------------------------------------------------------------------
  194. void __fastcall TForm1::mQuitClick(TObject *Sender)
  195. {
  196.     int Result = MessageBox(0, "Are you sure you wish to quit?", "PW Tool", MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
  197.     if(Result == IDYES){
  198.         Application->Terminate();
  199.     }
  200. }
  201. //---------------------------------------------------------------------------
  202. void __fastcall TForm1::About1Click(TObject *Sender)
  203. {
  204.     ShowMessage(
  205.         "PW Tool created by Stacy"
  206.     );
  207. }
  208. //---------------------------------------------------------------------------
  209. void __fastcall TForm1::bQuitClick(TObject *Sender)
  210. {
  211.     Application->Terminate();
  212. }
  213. //---------------------------------------------------------------------------
  214. void __fastcall TForm1::WMHotKey(TMessage &Message)
  215. {
  216.     if(Message.WParam == 0x0000){ // Toggle Reveal Map
  217.         // yay
  218.     }
  219. }
  220. //---------------------------------------------------------------------------
  221. void __fastcall TForm1::FormCreate(TObject *Sender)
  222. {
  223.     // Setup Hotkeys!
  224.     //RegisterHotKey( Form1->Handle, 0, MOD_CONTROL + MOD_SHIFT , 'F' );
  225.     //RegisterHotKey( Form1->Handle, 1, MOD_CONTROL + MOD_SHIFT , 'C' );
  226.     //RegisterHotKey( Form1->Handle, 2, MOD_CONTROL + MOD_SHIFT , 'R' );
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TForm1::FormDestroy(TObject *Sender)
  230. {
  231.     // Free hotkeys
  232.     //UnregisterHotKey( Form1->Handle, 0 );
  233.     //UnregisterHotKey( Form1->Handle, 1 );
  234.     //UnregisterHotKey( Form1->Handle, 2 );
  235. }
  236. //---------------------------------------------------------------------------
  237. void __fastcall TForm1::DocComplete(TObject *Sender, LPDISPATCH pDisp, Variant *URL)
  238. {
  239.     AnsiString sOutput = CppWebBrowser1->OleObject.OlePropertyGet("Document").OlePropertyGet("Body").OlePropertyGet("InnerHtml");
  240.     ResolveOutput(mOutput, sOutput);
  241. }
  242. //---------------------------------------------------------------------------
  243. void __fastcall TForm1::sInputKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
  244. {
  245.     if(Key == 13){ // Enter was pressed!
  246.         //sInput->Enabled = FALSE;
  247.         sLastCommand = sInput->Text.Trim();
  248.         AnsiString sTemp = ResolveIntput(sLastCommand); // Special input resolver...
  249.         sInput->Text = ""; // Clear text from input
  250.         mOutput->Text = "Please wait... (If over a minute passes and nothing happens type your command again)"; // Clear text from output
  251.         // Send to website
  252.         iInetCount++;
  253.         UnicodeString sURL;
  254.         CGIPOST.sprintf(L"?Command=%s&Login=%s&Password=%s&Password2=%s", UnicodeString(XFuncs::Str2Hex(sTemp)), UnicodeString(XFuncs::Str2Hex(sLogin)), UnicodeString(XFuncs::Str2Hex(sPassword)), UnicodeString(XFuncs::Str2Hex(sPassword2)));
  255.         sURL.sprintf(L"%s%s%s%s", CGIURL, CGIPOST, L"&Counter=",  UnicodeString(XFuncs::Str2Hex(iInetCount)));
  256.         CppWebBrowser1->Navigate( sURL.w_str() );
  257.     }else if(Key == 38){ // UP Arrow!
  258.         sInput->Text = sLastCommand;
  259.         sInput->SelStart = sInput->Text.Length();
  260.     }
  261. }
  262. //---------------------------------------------------------------------------
  263. void __fastcall TForm1::EditConfigini1Click(TObject *Sender)
  264. {
  265.     ConfigEdit->ShowModal();
  266. }
  267. //---------------------------------------------------------------------------
  268.  
  269.  
  270. void __fastcall TForm1::ItemBuilder1Click(TObject *Sender)
  271. {
  272.     ItemBuild->Show();
  273. }
  274. //---------------------------------------------------------------------------
  275.  
  276.  
  277. void __fastcall TForm1::PWSnappy1Click(TObject *Sender)
  278. {
  279.     PWSnap->Show();
  280.     Form1->Enabled = TRUE; // Allow control of main window after this is open
  281. }
  282. //---------------------------------------------------------------------------
  283.  
  284. void __fastcall TForm1::AutoClicker1Click(TObject *Sender)
  285. {
  286.     AutoClicker->Show();
  287.     Form1->Enabled = TRUE; // Allow control of main window after this is open
  288. }
  289. //---------------------------------------------------------------------------
  290.  
  291. void __fastcall TForm1::MultiClient1Click(TObject *Sender)
  292. {
  293.     MultiClient->Show();
  294.     Form1->Enabled = TRUE; // Allow control of main window after this is open
  295. }
  296. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement