Question

I've started C++ 1 week ago and learnt a lot of useful things. Now i'm coding a hack for an online game. i did it like that;

DWORD ENEMY = 0x01516370; //Base address
DWORD ENEMY_OFFSET = 0x4;

void Map1Function(bool fEnable)
{
 if(fEnable)
 {
WritePointer(ENEMY, ENEMY_OFFSET, textbox1->Text);
}
else
 { 
WritePointer(ENEMY, ENEMY_OFFSET, textbox1->Text);
 }
}

How can i get value from textbox ? Thanks.

My function :

#include <Windows.h>
bool WritePointer(unsigned long ulBase, int iOffset, int iValue)
{
  __try { *(int*)(*(unsigned long*)ulBase + iOffset) = iValue; return true; }
  __except (EXCEPTION_EXECUTE_HANDLER) { return false; }
}

But it gives that error when i do it like that ^ :

c:\users\*\documents\visual studio 2010\projects\tutorial\tutorial\Hacks.h(63): error         C2065: 'textbox1' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\tutorial\tutorial\Hacks.h(63): error  C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\tutorial\tutorial\Hacks.h(67): error C2065: 'textbox1' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\tutorial\tutorial\Hacks.h(67): error  C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''

Full src :

#pragma once

namespace Tutorial {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    /// <summary>
    /// Summary for Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
         // </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
    }
private: System::Windows::Forms::GroupBox^  groupBox1;
private: System::Windows::Forms::CheckBox^  checkBox5;
private: System::Windows::Forms::CheckBox^  checkBox4;
private: System::Windows::Forms::CheckBox^  checkBox3;
private: System::Windows::Forms::RadioButton^  radioButton3;
private: System::Windows::Forms::RadioButton^  radioButton2;
private: System::Windows::Forms::RadioButton^  radioButton1;
private: System::Windows::Forms::CheckBox^  checkBox2;
private: System::Windows::Forms::CheckBox^  checkBox1;
private: System::Windows::Forms::LinkLabel^  linkLabel1;
private: System::Windows::Forms::Label^  label1;
private: System::Windows::Forms::CheckBox^  checkBox8;
private: System::Windows::Forms::CheckBox^  checkBox7;
private: System::Windows::Forms::CheckBox^  checkBox6;
private: System::Windows::Forms::TextBox^  textBox1;



protected: 

protected: 

private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
        System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
        this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
        this->textBox1 = (gcnew System::Windows::Forms::TextBox());
        this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
        this->label1 = (gcnew System::Windows::Forms::Label());
        this->checkBox8 = (gcnew System::Windows::Forms::CheckBox());
        this->checkBox7 = (gcnew System::Windows::Forms::CheckBox());
        this->checkBox6 = (gcnew System::Windows::Forms::CheckBox());
        this->checkBox5 = (gcnew System::Windows::Forms::CheckBox());
        this->checkBox4 = (gcnew System::Windows::Forms::CheckBox());
        this->checkBox3 = (gcnew System::Windows::Forms::CheckBox());
        this->radioButton3 = (gcnew System::Windows::Forms::RadioButton());
        this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
        this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
        this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
        this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
        this->groupBox1->SuspendLayout();
        this->SuspendLayout();
        // 
        // groupBox1
        // 
        this->groupBox1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"groupBox1.BackgroundImage")));
        this->groupBox1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Zoom;
        this->groupBox1->Controls->Add(this->textBox1);
        this->groupBox1->Controls->Add(this->linkLabel1);
        this->groupBox1->Controls->Add(this->label1);
        this->groupBox1->Controls->Add(this->checkBox8);
        this->groupBox1->Controls->Add(this->checkBox7);
        this->groupBox1->Controls->Add(this->checkBox6);
        this->groupBox1->Controls->Add(this->checkBox5);
        this->groupBox1->Controls->Add(this->checkBox4);
        this->groupBox1->Controls->Add(this->checkBox3);
        this->groupBox1->Controls->Add(this->radioButton3);
        this->groupBox1->Controls->Add(this->radioButton2);
        this->groupBox1->Controls->Add(this->radioButton1);
        this->groupBox1->Controls->Add(this->checkBox2);
        this->groupBox1->Controls->Add(this->checkBox1);
        this->groupBox1->Location = System::Drawing::Point(0, 0);
        this->groupBox1->Name = L"groupBox1";
        this->groupBox1->Size = System::Drawing::Size(856, 799);
        this->groupBox1->TabIndex = 0;
        this->groupBox1->TabStop = false;
        this->groupBox1->Text = L"Functions";
        // 
        // textBox1
        // 
        this->textBox1->Location = System::Drawing::Point(115, 273);
        this->textBox1->Multiline = true;
        this->textBox1->Name = L"textBox1";
        this->textBox1->Size = System::Drawing::Size(54, 18);
        this->textBox1->TabIndex = 13;
        // 
        // linkLabel1
        // 
        this->linkLabel1->AutoSize = true;
        this->linkLabel1->Location = System::Drawing::Point(9, 309);
        this->linkLabel1->Name = L"linkLabel1";
        this->linkLabel1->Size = System::Drawing::Size(114, 15);
        this->linkLabel1->TabIndex = 12;
        this->linkLabel1->TabStop = true;
        this->linkLabel1->Text = L"www.elitepvpers.com";
        // 
        // label1
        // 
        this->label1->AutoSize = true;
        this->label1->Location = System::Drawing::Point(9, 294);
        this->label1->Name = L"label1";
        this->label1->Size = System::Drawing::Size(126, 15);
        this->label1->TabIndex = 11;
        this->label1->Text = L"Credits : SilverEmerald";
        // 
        // checkBox8
        // 
        this->checkBox8->AutoSize = true;
        this->checkBox8->Location = System::Drawing::Point(12, 272);
        this->checkBox8->Name = L"checkBox8";
        this->checkBox8->Size = System::Drawing::Size(103, 19);
        this->checkBox8->TabIndex = 10;
        this->checkBox8->Text = L"Room Password";
        this->checkBox8->UseVisualStyleBackColor = true;
        this->checkBox8->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox8_CheckedChanged);
        // 
        // checkBox7
        // 
        this->checkBox7->AutoSize = true;
        this->checkBox7->Location = System::Drawing::Point(12, 247);
        this->checkBox7->Name = L"checkBox7";
        this->checkBox7->Size = System::Drawing::Size(83, 19);
        this->checkBox7->TabIndex = 9;
        this->checkBox7->Text = L"No Gravity";
        this->checkBox7->UseVisualStyleBackColor = true;
        this->checkBox7->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox7_CheckedChanged);
        // 
        // checkBox6
        // 
        this->checkBox6->AutoSize = true;
        this->checkBox6->Location = System::Drawing::Point(12, 222);
        this->checkBox6->Name = L"checkBox6";
        this->checkBox6->Size = System::Drawing::Size(76, 19);
        this->checkBox6->TabIndex = 1;
        this->checkBox6->Text = L"Cam Hack";
        this->checkBox6->UseVisualStyleBackColor = true;
        this->checkBox6->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox6_CheckedChanged);
        // 
        // checkBox5
        // 
        this->checkBox5->AutoSize = true;
        this->checkBox5->Location = System::Drawing::Point(12, 197);
        this->checkBox5->Name = L"checkBox5";
        this->checkBox5->Size = System::Drawing::Size(85, 19);
        this->checkBox5->TabIndex = 8;
        this->checkBox5->Text = L"Infinite SP";
        this->checkBox5->UseVisualStyleBackColor = true;
        this->checkBox5->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox5_CheckedChanged);
        // 
        // checkBox4
        // 
        this->checkBox4->AutoSize = true;
        this->checkBox4->Location = System::Drawing::Point(12, 172);
        this->checkBox4->Name = L"checkBox4";
        this->checkBox4->Size = System::Drawing::Size(124, 19);
        this->checkBox4->TabIndex = 7;
        this->checkBox4->Text = L"HP Refill / Suicide";
        this->checkBox4->UseVisualStyleBackColor = true;
        this->checkBox4->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox4_CheckedChanged);
        // 
        // checkBox3
        // 
        this->checkBox3->AutoSize = true;
        this->checkBox3->Location = System::Drawing::Point(12, 147);
        this->checkBox3->Name = L"checkBox3";
        this->checkBox3->Size = System::Drawing::Size(163, 19);
        this->checkBox3->TabIndex = 6;
        this->checkBox3->Text = L"[Conquest] Frozen Enemies";
        this->checkBox3->UseVisualStyleBackColor = true;
        this->checkBox3->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox3_CheckedChanged);
        // 
        // radioButton3
        // 
        this->radioButton3->AutoSize = true;
        this->radioButton3->Location = System::Drawing::Point(12, 122);
        this->radioButton3->Name = L"radioButton3";
        this->radioButton3->Size = System::Drawing::Size(81, 19);
        this->radioButton3->TabIndex = 5;
        this->radioButton3->TabStop = true;
        this->radioButton3->Text = L"Deactivate";
        this->radioButton3->UseVisualStyleBackColor = true;
        this->radioButton3->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton3_CheckedChanged);
        // 
        // radioButton2
        // 
        this->radioButton2->AutoSize = true;
        this->radioButton2->Location = System::Drawing::Point(12, 97);
        this->radioButton2->Name = L"radioButton2";
        this->radioButton2->Size = System::Drawing::Size(72, 19);
        this->radioButton2->TabIndex = 4;
        this->radioButton2->TabStop = true;
        this->radioButton2->Text = L"HitRange";
        this->radioButton2->UseVisualStyleBackColor = true;
        this->radioButton2->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton2_CheckedChanged);
        // 
        // radioButton1
        // 
        this->radioButton1->AutoSize = true;
        this->radioButton1->Location = System::Drawing::Point(12, 72);
        this->radioButton1->Name = L"radioButton1";
        this->radioButton1->Size = System::Drawing::Size(79, 19);
        this->radioButton1->TabIndex = 3;
        this->radioButton1->TabStop = true;
        this->radioButton1->Text = L"WallShoot";
        this->radioButton1->UseVisualStyleBackColor = true;
        this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton1_CheckedChanged);
        // 
        // checkBox2
        // 
        this->checkBox2->AutoSize = true;
        this->checkBox2->Location = System::Drawing::Point(12, 47);
        this->checkBox2->Name = L"checkBox2";
        this->checkBox2->Size = System::Drawing::Size(106, 19);
        this->checkBox2->TabIndex = 2;
        this->checkBox2->Text = L"Design Changer";
        this->checkBox2->UseVisualStyleBackColor = true;
        this->checkBox2->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox2_CheckedChanged);
        // 
        // checkBox1
        // 
        this->checkBox1->AutoSize = true;
        this->checkBox1->Location = System::Drawing::Point(12, 22);
        this->checkBox1->Name = L"checkBox1";
        this->checkBox1->Size = System::Drawing::Size(69, 19);
        this->checkBox1->TabIndex = 1;
        this->checkBox1->Text = L"No Blast";
        this->checkBox1->UseVisualStyleBackColor = true;
        this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
        // 
        // Form1
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(7, 15);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(705, 344);
        this->Controls->Add(this->groupBox1);
        this->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
            static_cast<System::Byte>(162)));
        this->MaximizeBox = false;
        this->Name = L"Form1";
        this->Text = L"S4League EU In-Game Hack 23.03.14";
        this->groupBox1->ResumeLayout(false);
        this->groupBox1->PerformLayout();
        this->ResumeLayout(false);

    }
#pragma endregion
private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void checkBox2_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void checkBox8_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void radioButton3_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void checkBox3_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void checkBox4_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void checkBox5_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void checkBox6_CheckedChanged(System::Object^  sender, System::EventArgs^  e);
private: System::Void checkBox7_CheckedChanged(System::Object^  sender, System::EventArgs^  e);      
};
}
Was it helpful?

Solution

It's textBox1, not textbox1; variables are case sensitive.

Also, this won't work, you need to convert the string from the Text property to an int value. You will need this:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
{
    int value = Convert::ToInt32(textBox1->Text);
    WritePointer(ENEMY, ENEMY_OFFSET, value);
}

Notice how the textBox1 is used within the Form1 class. It is necessary because the textBox1 is private to the class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top