I created this class to facilitate some routine tasks when modding or hooking software. If you dont know what hooking is or how to use .dll’s it is of no use to your. It also bridges the gap between oop and asm a little, I try to give you the best of asm in a oop format.
Features
In a Nutshell
This class does all the work for you, just create the project and pass a function into the constructor and it will take care of the threading. The function you pass to it is the main function of the thread that is started, in this function you can handle key input or whatever manipulations you wish.
How to use
This is for use with Visual Studio, as I use masm syntax in the inline asm. Basically you make a VS c++ project of “.dll” type, then you include modtoolz.h class. If you dont know how to do that, just stop now. If you want a in depth “noob” tutorial, I wrote one here.
add these to your stdafx.h
#include <stdio.h>
#include <iostream>
#include <io.h>
#include <stdio.h>
#include <fstream>
using namespace std;
Everything happens when you call the constructor (as it should with oop). So in your main.cpp you could call the constructor like this
#include ModTools.h
// other stuff
// modtools constructor one
ModTools mt("window name", &myEngine);
If you did it like that you would have to have a function “myFunction” that you could handle events and keys. The function you pass into it with this constructor gets started in the thread, so when that function terminates, so does the thread. You need a while loop and some stuff like so
1 2 3 4 5 6 7 8 9 10 | long WINAPI myEngine(long lparam) { while(1){ // this goes forever, so your thread stays alive Sleep(10); // ~10 millisecond delay so it dont lag // if they hit f12 turn on the console if(GetAsyncKeyState(VK_F12) == -32767) { mt.Console(); } }// end the while loop |
that function would toggle the console on/off with the press of F12. Of course you could make it do any action based on any keys, for instance call a function inside the program, or change a memory value inside the program. Since you are inside the program in your .dll you can change anything or call the programs functions.
The above method is easy and does work fine; however, there is another constructor that you can also use which is more efficent. The second constructor (that you can use) hooks directly into the window, this allows you to handle key input better.
You can use the second constructor like so
1 2 3 | #include ModTools.h // second constructor ModTools mt("brood war", &KeyHandler); |
In this case you can only pass it a keyhandler, anything that takes time to process that is in this “keyhandler” function will lag the target application instantly. If you wish to do heavy processing and queues and such either make a new thread or jmpPatch to another function in your code.
Anyway this is what a keyhandler function looks like
1 2 3 4 5 6 7 8 9 | bool KeyHandler(int keyCode) { // Is key ~ pressed? if (keyCode == VK_OEM_3) { // DO SOMETHING } return FALSE; } |
This second constructor is more advanced and I do not recommend you use it unless you know what you are doing. That said, the second constructor is the way to go if you want to make really good applications.
If you are still confused I made a tutorial on another site that is pretty informational. You can acess that here. In that tut I show how to use the modtools.h class to do stuff with the game starcraft.
You can download modtools.h here modtools-v02
I created this class to facilitate some routine tasks when modding or hooking software. If you dont know what hooking is or how to use .dll’s it is of no use to your. It also bridges the gap between oop and asm a little, I try to give you the best of asm in a oop format.
Features
In a Nutshell
This class does all the work for you, just create the project and pass a function into the constructor and it will take care of the threading. The function you pass to it is the main function of the thread that is started, in this function you can handle key input or whatever manipulations you wish.
How to use
This is for use with Visual Studio, as I use masm syntax in the inline asm. Basically you make a VS c++ project of “.dll” type, then you include modtoolz.h class. If you dont know how to do that, just stop now. If you want a in depth “noob” tutorial, I wrote one here.
add these to your stdafx.h
#include <stdio.h>
#include <iostream>
#include <io.h>
#include <stdio.h>
#include <fstream>
using namespace std;
Everything happens when you call the constructor (as it should with oop). So in your main.cpp you could call the constructor like this
#include ModTools.h
// other stuff
// modtools constructor one
ModTools mt("window name", &myEngine);
If you did it like that you would have to have a function “myFunction” that you could handle events and keys. The function you pass into it with this constructor gets started in the thread, so when that function terminates, so does the thread. You need a while loop and some stuff like so
1 2 3 4 5 6 7 8 9 10 | long WINAPI myEngine(long lparam) { while(1){ // this goes forever, so your thread stays alive Sleep(10); // ~10 millisecond delay so it dont lag // if they hit f12 turn on the console if(GetAsyncKeyState(VK_F12) == -32767) { mt.Console(); } }// end the while loop |
that function would toggle the console on/off with the press of F12. Of course you could make it do any action based on any keys, for instance call a function inside the program, or change a memory value inside the program. Since you are inside the program in your .dll you can change anything or call the programs functions.
The above method is easy and does work fine; however, there is another constructor that you can also use which is more efficent. The second constructor (that you can use) hooks directly into the window, this allows you to handle key input better.
You can use the second constructor like so
1 2 3 | #include ModTools.h // second constructor ModTools mt("brood war", &KeyHandler); |
In this case you can only pass it a keyhandler, anything that takes time to process that is in this “keyhandler” function will lag the target application instantly. If you wish to do heavy processing and queues and such either make a new thread or jmpPatch to another function in your code.
Anyway this is what a keyhandler function looks like
1 2 3 4 5 6 7 8 9 | bool KeyHandler(int keyCode) { // Is key ~ pressed? if (keyCode == VK_OEM_3) { // DO SOMETHING } return FALSE; } |
This second constructor is more advanced and I do not recommend you use it unless you know what you are doing. That said, the second constructor is the way to go if you want to make really good applications.
If you are still confused I made a tutorial on another site that is pretty informational. You can acess that here. In that tut I show how to use the modtools.h class to do stuff with the game starcraft.
You can download modtools.h here modtools-v02

Categories
Tag Cloud
Blog RSS
Comments RSS

Void « Default
Life
Earth
Wind
Water
Fire
Light 