1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Tutorial] Make a Trainer in C++ part 2

Discussion in 'Programming' started by DarkSpace, Aug 12, 2010.

  1. DarkSpace

    DarkSpace Well-Known Member Coder

    Dont forget to give me some Credit in your Trainer/bot for writing all of these tutorials and helping some of you individually in my own free time.

    This is the continue of part 1. we'll add a hack to our trainer and i'll explain how it works. and simple AA->ASM conversion

    Start Visual Studio, load up the form from the last tutorial and lets get to it.

    We'll Work from the top of the project solution again for the sake of simplicity. you can do this in any order you want.
    depending where you'r files are.

    Double Click on Form1.h to open up the form editer.
    Drag a Checkbox to your form so it looks something like this.
    https://imagizer.ImageShack is toxicus/v2/663x378q90/674/OLtUhi.png

    Double Click on CheckBox1.
    You should get something like this
    https://imagizer.ImageShack is toxicus/v2/830x246q90/906/Et8xXo.png
    We are going to Remove the body of that function event by removing the { and }
    and adding a semi colon at the end of the event. so it looks like this
    https://imagizer.ImageShack is toxicus/v2/813x192q90/539/Nk6Rkv.png
    Reason we did this was so that we can recreate the function in Form1.cpp which gives us more flexability
    and keeps our files nice and neat.

    lets move down the list now.

    We'll be adding our hack here. and the hack that we'll add is going to be Mob Speed Up. (version 63d)

    Code (Text):
    1. // Mob Speedup
    2. // Updated by SeNeco
    3. [ENABLE]
    4. 0091618F: //8D 48 24 E8 ?? ?? ?? ?? DD 5D F8 8D 4E 0C E8 ?? ?? ?? ?? DC 4F 08 83 7D 10
    5. db 8D 4E 0C
    7. [DISABLE]
    8. 0091618F:
    9. db 8D 48 24
    note* there are many different hacks. this is one of them
    we'll cover JMP scripts and codecaves later on.

    Ok now we know what we are going to add, lets start writing things out.

    if you look at the script it has 1 pointer. 0091618F
    we can write that as a DWORD

    so jump down to the end of your code in Form1.cpp and write
    Code (Text):
    2. DWORD MobSpeedPointer= 0x0091618F;
    next thing we will need are the bytes that make the hack happen.
    the enable bytes are db 8D 4E 0C

    and this is how its written in C++
    Code (Text):
    1. BYTE enableSpeedUp[] = {0x8D, 0x4E, 0x0C};
    everything after db are the bytes we need, so totally ignore db

    same thing with disable Bytes. if you look at the disable you'll see the bytes change a bit
    lets write them down in our form1.cpp also
    Code (Text):
    1. BYTE disableSpeedUp[] = {0x8D, 0x48, 0x24};
    now your Form1.cpp should look like this
    https://imagizer.ImageShack is toxicus/v2/487x284q90/913/zH3d1G.png

    Lets make the hack activate!

    under the code you just wrote. lets link the checkbox1 and our hack

    write this
    Code (Text):
    2. void Form1::checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
    3. {
    4.      if(this->checkBox1->Checked)
    5.         {
    6.                //here we enable the hack by changing the bytes of the pointer
    7.         memcpy((void*)MobSpeedPointer, enableSpeedUp, sizeof(enableSpeedUp));
    8.          }
    9.      else //if not checked
    10.         {
    11.                 //here we disable the hack by coping back the original bytes to the pointer
    12.         memcpy((void*)MobSpeedPointer, disableSpeedUp, sizeof(disableSpeedUp));
    13.          }
    14. }
    your form1.cpp should look like this now

    https://imagizer.ImageShack is toxicus/v2/679x513q90/540/cZITdl.png

    void Form1::checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) is the event that is called when checkBox1 is checked. we made this in form1.h by double clicking on the checkBox1.
    this is the reason we removed the body { and } from the function in form1.h so we could write it here instead.

    we check if checkbox1 is checked, if it is then we activate the hack
    if it isnt then we disable the hack

    memcpy(destination, source, size);
    memcpy does exactly what it says, copies memory from source to destination.
    so we are going to copy the bytes from enableSpeedUp to MobSPeedPointer and then when we disable it. we just put the original bytes back in place

    go to Build -> Build Solution (F7) and if you did everything right you should see
    Code (Text):
    2. 1>Tutorial - 0 error(s), 0 warning(s)
    3. ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    open winject, start maple. inject the dll. close winject and test it out!

    YOU DO NEED A BYPASS HOWEVER! (can be found in my siggy)
    Last edited: Aug 9, 2014
    • Like Like x 11
    • Made my day! Made my day! x 2
    • Heart-warming Heart-warming x 1
    • Thank You! Thank You! x 1
  2. Twister

    Twister Well-Known Member

    I, forreal, love, you, man.
    nohomo, but these tuts are awesome.
  3. Danny1994

    Danny1994 Likes to contribute Coder

    Yeah, these tuts ain't bad. :)
    But lets hope nibs don't spamm-release gay fag Trainers now :P
  4. King Virus

    King Virus Banned Banned

    Great tut once again. :)
  5. DarkSpace

    DarkSpace Well-Known Member Coder

    ghay f@g trainers are still better than "zomg mesos hax pl0x!"
    (not that we wont see those even with 100 tutorials)

    as long as people try to work things out them self, asking questions and what not about how to make something is never a bad thing =P.
    • Agree Agree x 1
  6. Twister

    Twister Well-Known Member

    Um, I get 2 errors after doing this, could be me but could you tell what Ive done wrong?

    Code (Text):
    1. #include "Form1.h"
    3. using namespace firstdll;
    5. void Main(void)
    6. {
    7.     Application::EnableVisualStyles();
    8.     Application::SetCompatibleTextRenderingDefault(false);
    9.     Application::Run(gcnew Form1); //change Form1 this to the name of your Form
    10.     Application::Exit();
    11. }
    13. DWORD MobSpeedPointer= 0x0091618F;
    14. BYTE enableSpeedUp[] = {0x8D, 0x4E, 0x0C};
    15. BYTE disableSpeedUp[] = {0x8D, 0x48, 0x24};
    18. void Form1::checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
    19. {
    20.      if(this->checkBox1->checked)
    21.         {
    22.                //here we enable the hack by changing the bytes of the pointer
    23.         memcpy((void*)MobSpeedPointer, enableSpeedUp, sizeof(enableSpeedUp));
    24.          }
    25.      else //if not checked
    26.         {
    27.                 //here we disable the hack by coping back the original bytes to the pointer
    28.         memcpy((void*)MobSpeedPointer, disableSpeedUp, sizeof(disableSpeedUp));
    29.          }
    30. }
    And these are my errors
    Code (Text):
    1.  1: Error   1   error C2084: function 'void firstdll::Form1::checkBox1_CheckedChanged(System::Object ^,System::EventArgs ^)' already has a body C:\Users\LazzDesktop\documents\visual studio 2010\Projects\firstdll\firstdll\Form1.cpp  19
    3. 2:Error 2   error C2039: 'checked' : is not a member of 'System::Windows::Forms::CheckBox'  C:\Users\LazzDesktop\documents\visual studio 2010\Projects\firstdll\firstdll\Form1.cpp  20
  7. Jakhals

    Jakhals New Member

    I'm gonna try this tomorrow, i hope it works ;D
  8. DarkSpace

    DarkSpace Well-Known Member Coder

    in form1.h you need to delete the body of the checkbox
    look at the tutorial where i say delete the body of the function event.

    error 2 says that checked isnt a member of checkbox object,
    you need to have Checked instead of checked
  9. Jakhals

    Jakhals New Member

    How do i get a check box?

    EDIT: i dont get the checkbox thing o.o, i found out how to get a check box and then?

    EDIT2: Can you make a better screenshot of wich we need to delete @ form1.h?
  10. Scum 72638

    Scum 72638 Go with the flow. Banned

    just look under toolbox HOLY CRAP!
  11. DarkSpace

    DarkSpace Well-Known Member Coder

    http://img189.ImageShack is toxicus/img189/9341/41980017.png

    http://img708.ImageShack is toxicus/img708/839/25252842.png

    only thing thats missing is the { and }
  12. Klaffen

    Klaffen ლ(ಠ益ಠლ) Donor

    tomorrow im gonna read trought these guides 2-3 more times, then im gonna try to make a bot :p(nothing big, just for testing purposes)
  13. Nebbis

    Nebbis Banned Banned

    nice tut btw
  14. DarkSpace

    DarkSpace Well-Known Member Coder

    depending what function it is.

    if a function is related to form1, within the function you can use this->
    if its a normal function you'll have to use Form1::label->text = readPointer();

    also you'd have to make your label public in form1.h else you wont be able to access it.
    security reasons... yea
  15. DarkSpace

    DarkSpace Well-Known Member Coder

    the error you are getting is because of the data missmatch.
    label->text accepts string^ only.
    and you are passing in a ulong ptr.

    one way around that is to say

    Code (Text):
    3. void Form1::button1_Click(System::Object^  sender, System::EventArgs^  e)
    4. {
    5.         int charInfo = (int) ReadPointer((ULONG_PTR*)CharInfoPointer, CharXOffset);
    6.     Form1::label9->Text = charInfo.ToString();
    7. }
    Reason is because int can be converted to a string easy. ^^
  16. DarkSpace

    DarkSpace Well-Known Member Coder

    yea 1st you'd need to make few global or external to the function variables and then a function to write to them
    a timer and form onLoad function

    for example. this is from the top of my head. so you'll need to change few things to make it work for you.
    but the code is correct.

    Code (Text):
    2. int charX;
    3. int charY;
    4. int mapID;
    6. void getCharInfos()
    7. {
    8.         for(;;) //infinate loop
    9.          {
    10.                 charX = (int)ReadPointer(charXpointer, charXoffset); //fill in the right info
    11.                 charY = (int)ReadPointer(charYpointer, charYofsset); //fill in info again.
    12.                 mapID = (int)ReadPoiner(mapPointer, mapOffset); //same as above
    13.                 Sleep(200) //how much to wait before it updates the values again.
    14.           }
    15. }
    17. void Form1::onForm_Load( blah blah blah)
    18. {
    19.      //here we create a new thread so our program doesnt lag
    20.      CreateThread(NULL, 0, (::LPTHREAD_START_ROUTINE)&getCharInfos, NULL, 0, NULL};
    21.      //then start the timer.
    22.       this->timer1->interval = 200; //this refering to Form1
    23.       this->timer1->enabled = true;
    24. }
    26. //timer event
    27. void Form1::onTimer_tick(syste, sender^)  //put the right things here. im too lazy to think
    28. {
    29.        this->label1->text = charX.ToString();
    30.        this->label2->text = charY.ToString();
    31.        this->label3->text = mapID.ToString();
    32. }
    34. //this should refresh your stats every 200ms
    35. //and timer is going to call the tick event every 200ms to write those values to your form.
  17. reppex

    reppex Banned Banned

    Nice tut :D i think that helps me alot
  18. Danny1994

    Danny1994 Likes to contribute Coder

    It's not like im pro or anything in C++ but i learned alot by reading many C++ sources and creating trainers.
  19. NonLeaf

    NonLeaf Well-Known Member

    Fixed, thanks danny1994 :).
  20. personal

    personal Well-Known Member

    i know all this kind of basic Stuff but thanks anyway

Share This Page