Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Main.h"
- #include "fConfigEditor.h" // Include the editor!
- #include "fItemBuilder.h" // Include the item builder!
- #include "fPWSnappy.h" // Include the PW Snappy
- #include "fAutoClicker.h" // Include Auto Clicker!
- #include "fMultiClient.h" // Include the MultiClient
- // Perl Stuff etc
- #include "PerlWrapper.h" // Allows full use of perl
- #include "XFuncs.h" // Some useful functions
- #include "XFuncsCPP.h" // Some useful functions
- #include <vector>
- // Variables
- const AnsiString GameCapX = "unset";
- const AnsiString GameClsX = "unset";
- //UnicodeString CGIURL = "http://d2realm.no-ip.org/Scripts/PWTool/PWTool.php";
- UnicodeString CGIURL = "https://d2realm.no-ip.org:8043/Scripts/PWTool/PWTool.php";
- UnicodeString CGIPOST = "?";
- int iInetCount = 0;
- UnicodeString sLastCommand = "";
- // This function is used to check if a function is on or off and put status into edit box accordingly
- void FuncOnOff(TEdit* eEditBX, AnsiString GameCls, AnsiString GameCap, AnsiString Address, AnsiString Checker){
- if(SameText(Checker, XFuncs::ReadMemory(GameCls, GameCap, Address, 1, "HEX"))){
- eEditBX->Text = "ON";
- }else{
- eEditBX->Text = "OFF";
- }
- }
- // This function pokes to memory the value from an editbox control
- void DoReadDec(TEdit* eEditBX, AnsiString GameCls, AnsiString GameCap, AnsiString Address, AnsiString ReadSize){
- int MaxVal;
- int MinVal;
- if(SameText(ReadSize, "DWORD")){
- MaxVal = 268435455;
- MinVal = 0;
- }else if(SameText(ReadSize, "WORD")){
- MaxVal = 65535;
- MinVal = 0;
- }else if(SameText(ReadSize, "BYTE")){
- MaxVal = 255;
- MinVal = 0;
- }else{
- MaxVal = 268435455;
- MinVal = 0;
- }
- XFuncs::PokeResolve(GameCls, GameCap, "Poke " + Address + " " + XFuncs::DecToPoke(XFuncs::CheckValidInt(eEditBX->Text.Trim(), MinVal, MaxVal), ReadSize));
- }
- // This function is used to check if a function is on or off and put status into edit box accordingly
- void ResolveOutput(TMemo* tmOutput, AnsiString sOutput){
- tmOutput->Lines->Clear();
- // Lets make a PERL array and cycle it
- PArray paOutputArray; // Define the array
- paOutputArray.InitArray("sOutputTxT");
- XFuncs::RegexSplit("sOutputTxT", sOutput, "<BR>");
- int ArraySize;
- paOutputArray.Size(ArraySize);
- AnsiString MyStr, TmpBuf;
- int loop;
- for(loop = 0; loop < ArraySize; loop++){
- if(paOutputArray.Get(loop, MyStr)){ // Make sure this element exists
- if(XFuncs::RegexMatch(MyStr, "^Login error!")){
- 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.");
- ConfigEdit->ShowModal();
- }else if(XFuncs::RegexMatchEx(MyStr, "^Func_WriteFileASCII\\(\"(.*)\",\"(.*)\"\\);$")){ // Write File ASCII Command
- AnsiString sFileName, sFileText;
- sFileName = XFuncs::RegexMatchGroup(1);
- sFileText = XFuncs::RegexMatchGroup(2);
- sFileText = XFuncs::Hex2Str(sFileText);
- sFileText = XFuncs::Trim(sFileText);
- XFuncs::WriteFileASCII(sFileName, sFileText);
- }else if(XFuncs::RegexMatchRet(TmpBuf, 1, MyStr, "^Func_EXEC\\(\"(.*)\"\\);$")){ // Execute system command
- if(FileExists(TmpBuf)){
- system(TmpBuf.c_str());
- }else{
- ShowMessage("File '" + MyStr + "' does not exist!");
- }
- }else if(XFuncs::RegexMatchRet(TmpBuf, 1, MyStr, "^Func_PEXEC\\(\"(.*)\"\\);$")){ // Execute perl command
- TmpBuf = XFuncs::Hex2Str(TmpBuf);
- CPerlWrap::doScript(TmpBuf);
- }else{
- tmOutput->Lines->Add(MyStr);
- }
- }
- }
- paOutputArray.Destroy(); // Remove the array
- }
- // This function is used to check the input for special modifiers
- AnsiString ResolveIntput(AnsiString sInput){
- AnsiString TmpBuf, RetVal, RetStr;
- int iFinished = 0;
- // Loop until all special funtions have been found!
- while(iFinished == 0){
- // Clear buffers first
- TmpBuf = "";
- RetVal = "";
- RetStr = "";
- if(XFuncs::RegexMatchRet(TmpBuf, 1, sInput, "!\"(.{1,})\"")){ // Check if we need to replace something with a file!
- if(FileExists(TmpBuf)){
- if(XFuncs::ReadFileASCII(RetVal, TmpBuf)){
- RetVal = XFuncs::Str2Hex(RetVal); // Convert it to hex!
- // Place it back into string
- if(XFuncs::RegexReplace(sInput, "\"" + RetVal + "\"", "!\"(.{1,})\"", RetStr)){
- return RetStr;
- }else{
- iFinished = 1; // Signal end of the loop
- ShowMessage("Failed to rebuild string for ASCII file get");
- }
- }else{
- iFinished = 1; // Signal end of the loop
- ShowMessage("Unable to get data from file '" + TmpBuf + "'");
- }
- }else{
- iFinished = 1; // Signal end of the loop
- ShowMessage("File '" + TmpBuf + "' does not exist!");
- }
- }else{
- iFinished = 1; // Signal end of the loop
- }
- }
- return sInput;
- }
- // TimerCode
- // FuncOnOff(eRevealMap, GameClsX, GameCapX, "4B1110", "E9");
- // FuncOnOff(eControl, GameClsX, GameCapX, "4B5B3E", "90");
- // FuncOnOff(eInfiniteRange, GameClsX, GameCapX, "49AEE0", "E9");
- // FuncOnOff(ePromotion, GameClsX, GameCapX, "49E425", "90");
- // FuncOnOff(eUltimateDiplomacy, GameClsX, GameCapX, "45E954", "E9");
- // FuncOnOff(eManpower, GameClsX, GameCapX, "43F381", "90");
- // FuncOnOff(eUnitBuild, GameClsX, GameCapX, "43EEEE", "90");
- // FuncOnOff(eInjection, GameClsX, GameCapX, "439E86", "E9");
- // FuncOnOff(eMegaResources, GameClsX, GameCapX, "42704B", "90");
- // FuncOnOff(eActiveBlueprint, GameClsX, GameCapX, "5461EF", "90");
- // eSlider->Text = XFuncs::ReadMemory(GameClsX, GameCapX, "40035D", 1, "DEC");
- // eTechID->Text = XFuncs::ReadMemory(GameClsX, GameCapX, "400600", 4, "DEC");
- // // Hotkeys (10 = Shift , 11 = Control)
- // if(GetKeyState(0x11) & 0x000000F0 && GetKeyState(0x10) & 0x000000F0 && GetKeyState(0x41) & 0x000000F0){
- // bInfiniteRangeClick(Sender);
- // }
- // Button code
- // if(SameText("E9", XFuncs::ReadMemory(GameClsX, GameCapX, "4B1110", 1, "HEX"))){
- // XFuncs::PokeResolve(GameClsX, GameCapX, "Poke 4B1110 A0 AC A6 2B 01");
- // }else{
- // XFuncs::PokeResolve(GameClsX, GameCapX, "Poke 4B1110 E9 6B F5 F4 FF\n"
- // "Poke 400680 C6 05 AC A6 2B 01 01 A0 AC A6 2B\n"
- // "Poke 40068B 01 E9 84 0A 0B 00"
- // );
- // }
- // EditBox change
- //DoReadDec(eSlider, GameClsX, GameCapX, "40035D", "BYTE");
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "SHDocVw_OCX"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- void __fastcall TForm1::SetCurrentLoginStatus(AnsiString sLoginX) {
- eLoginDetails->Text = "Current login: " + sLoginX;
- }
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- CPerlWrap::InitPerl(TRUE); // Required for use of all perl functions
- XFuncs::InitXFuncs(); // Required for many parts of XFuncs including read/write memory!
- // Load config file
- /* Open an instance */
- TCustomIniFile* SettingsFile = new TIniFile(ChangeFileExt("./Config.ini", ".ini"));;
- try {
- sLogin = SettingsFile->ReadString("General", "Login", "Unset");
- sPassword = SettingsFile->ReadString("General", "Password", "Unset");
- sPassword2 = SettingsFile->ReadString("General", "Password2", "Unset");
- SetCurrentLoginStatus(sLogin);
- }catch(Exception* e){
- }
- delete SettingsFile;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::mQuitClick(TObject *Sender)
- {
- int Result = MessageBox(0, "Are you sure you wish to quit?", "PW Tool", MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
- if(Result == IDYES){
- Application->Terminate();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::About1Click(TObject *Sender)
- {
- ShowMessage(
- "PW Tool created by Stacy"
- );
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::bQuitClick(TObject *Sender)
- {
- Application->Terminate();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::WMHotKey(TMessage &Message)
- {
- if(Message.WParam == 0x0000){ // Toggle Reveal Map
- // yay
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- // Setup Hotkeys!
- //RegisterHotKey( Form1->Handle, 0, MOD_CONTROL + MOD_SHIFT , 'F' );
- //RegisterHotKey( Form1->Handle, 1, MOD_CONTROL + MOD_SHIFT , 'C' );
- //RegisterHotKey( Form1->Handle, 2, MOD_CONTROL + MOD_SHIFT , 'R' );
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormDestroy(TObject *Sender)
- {
- // Free hotkeys
- //UnregisterHotKey( Form1->Handle, 0 );
- //UnregisterHotKey( Form1->Handle, 1 );
- //UnregisterHotKey( Form1->Handle, 2 );
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::DocComplete(TObject *Sender, LPDISPATCH pDisp, Variant *URL)
- {
- AnsiString sOutput = CppWebBrowser1->OleObject.OlePropertyGet("Document").OlePropertyGet("Body").OlePropertyGet("InnerHtml");
- ResolveOutput(mOutput, sOutput);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::sInputKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
- {
- if(Key == 13){ // Enter was pressed!
- //sInput->Enabled = FALSE;
- sLastCommand = sInput->Text.Trim();
- AnsiString sTemp = ResolveIntput(sLastCommand); // Special input resolver...
- sInput->Text = ""; // Clear text from input
- mOutput->Text = "Please wait... (If over a minute passes and nothing happens type your command again)"; // Clear text from output
- // Send to website
- iInetCount++;
- UnicodeString sURL;
- 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)));
- sURL.sprintf(L"%s%s%s%s", CGIURL, CGIPOST, L"&Counter=", UnicodeString(XFuncs::Str2Hex(iInetCount)));
- CppWebBrowser1->Navigate( sURL.w_str() );
- }else if(Key == 38){ // UP Arrow!
- sInput->Text = sLastCommand;
- sInput->SelStart = sInput->Text.Length();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::EditConfigini1Click(TObject *Sender)
- {
- ConfigEdit->ShowModal();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ItemBuilder1Click(TObject *Sender)
- {
- ItemBuild->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::PWSnappy1Click(TObject *Sender)
- {
- PWSnap->Show();
- Form1->Enabled = TRUE; // Allow control of main window after this is open
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::AutoClicker1Click(TObject *Sender)
- {
- AutoClicker->Show();
- Form1->Enabled = TRUE; // Allow control of main window after this is open
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::MultiClient1Click(TObject *Sender)
- {
- MultiClient->Show();
- Form1->Enabled = TRUE; // Allow control of main window after this is open
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement