![]() |
|
[C] [C++] Hack Making (.DLL) - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] [C++] Hack Making (.DLL) (/showthread.php?tid=153424) |
[C++] Hack Making (.DLL) - The-One - Sep 23, 2009 Introduction to VC++ Here we will use Visual C++ 2008 Express, which is free an can be downloaded here: http://www.microsoft.com/express/download/ (Microsoft) Of course you can use another programm or another version, such as Visual C++ 2005 Express (if u use this u should take a look at the solved problems). I'll be using, as I said the 2008 version. Visual C++ is, roughly, an adaptation of c++ to microsoft's windows. I mean, it's not really that like, but is a little view of what it is xD (Note, we are going to programm with c++) C++ is "Case Sensitive", which mean that distinguish between Mayus. and Minus. After each C++ command you must end up with ; Getting Ready We start the VC++ and go to File->New->Project [Img 1] [img]http://i40.[censored].com/2urs3kx.jpg[/img] Here you will see another window [Img2]. There we click on Visual C++ (left menu) -> Win32 Console Application -> We give it a name -> And click OK. [img]http://i41.[censored].com/29li641.jpg[/img] There you will see the following [Img 3], click Next > [img]http://i39.[censored].com/2mzd445.jpg[/img] Then [Img 4]: Click on DLL Click on Empty Project (Proyecto Vacio) Click on Finish [img]http://i40.[censored].com/2djxi1d.jpg[/img] Here we have our first DLL, but don't try to compile, or it will give you errors. Now we need to create the files where the code will be written. Go to Project->Add New Item. There choose C++ File (.cpp) and write a name. I've written main, to be able to distinguish it better, but it doesn't matter. Basic Hack! This is the basic code of a DLL. (Note: Everything starting with // (and in the same line), means that it is a "Coment" and the compiler will ignore it, so, it's like it wasn't there. And it's the same as writting /* and then */. First we need to add a few references to some windows header files. This is ALWAYS done on the top of your file: Code #include <windows.h>Then, we need to also put the main code of the DLL Code BOOL WINAPI DllMain(HINSTANCE module, DWORD dwReason, LPVOID lpvReserved) /*Basic Function. */Then we write: Code void TheHacks() /* This is the "Thread" of the hacks, I'll explain it now */The while(1) does that everything which is inside gets repeated every 1 milisecond. Now we must initilize/create the thread, and it will be done only if dll has been atached, so, we will add it on the "DllMain", just below the DLL_PROCESS_ATTACH){ If you get lost, the full code is at the bottom Add the following: Code CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)TheHacks, NULL, NULL, NULL);Lets continue coding the hack. We will add a basic Stamina hack. Actually, there are many ways to do this, but I'll explain the faster and perhaps the easier to understand. (This method may not working on all games, depending if they protect or not memory) Inside or Thread (TheHacks): Note: This is not the code we will be using at all. The address areNO recent. Code DWORD dwPlayerPointer = *(DWORD*)0x002200;
Well, perhaps ur asking yourself: <<¿But, didn't we have to freeze the stamina?>>. Of course, but remember, our thread is being repeated every 1 milisecond! If I'm not wrong, u would like to be able to activated and deactivate the hack, so lets code it!: First, just below the #include(s) we add: Code bool stamina=false;
As you see we've written =false;. That means that the hack is deactivated by default. Change the false to true to enable it by default. And what is this useful for?, lets add and If statement and you will see: We want our hack to run if the variable value is true, so: Code /* Note: Delete the old code and put this. DON'T put both! */Ok, nice, but now we need something to toggle it, so, we are going to add hotkeys! On the Thread TheHacks(): Code if(GetAsyncKeyState(VK_F6) &1){ /* VK_F6 mean F6 Key*/ Lets analyse it: This <<stamina =>> should be clear. We are changing the stamina var value. The following: (!stamina): Take a look at the exclamation mark (!). This means the contrary of the var. I mean, If stamina was true, then we would be writing this: <<stamina = !true;>>, which is the same as <<stamina = false;>>. Ok, it works, BUT, this has a problem. We are checking up if a key is pressed every 1 MILISECOND, so, who is as fast as to press only during 1 ms a key? Noone. There are many ways to solve this, but I am not going to explain it now. Congrats! Lets click Buil->Build Solution. We will find our DLL on the Debug folder of our project folder. Here you have the code: Code #include <windows.h>It's ALL finished, but I'll explain something more. Apendix Creating hacks as Zoom (no DMA (offset) and no Freeze) It is really easy to do this: What we did later was edit the Address value whenever the var (stamina) was true, so, if we change it value to false, it won't be edited any more. Lets do it: Code //Below the other bool var.As you can see we've only written <<if(zoom){>>, and we have ommitted the <<==true>>, which would be <<if(zoom==true){>>. Ok, that's because when using a IF statement with a bool var, it's assummed that you are comparing it to true. optimizint the hack Have you ever though what would happen if you had like 20 address and warrock updated? Would you be searching for all of them in your code and changing them? NO, the answer it's NO! To not to do so, we will add a new file, (Project->Add new element). BUT this time it will be a Header File (.h). Give it a name (I use to write <<define>> as name, but as always, it's your choice). First we have to link the main.cpp file to this one, so, go to the first file (main.cpp) and below the others#include(s) write: Code #include "define.h"Now we are going to edit the new file (define.cpp). We will be following this pattern: #define "Hack_Name" 0x"ADDRESS" For example: Code #define zoom_address 0x000022And that's all? No,no... If you remember, we first used this code: Code DWORD dwPlayerPointer = *(DWORD*)0x000222;Code //On define.hNow, each time warrock updates, you just have to go to define.h and edit it ^^ Solved Problems Windows.h (No such file or directory) This problem is because VC++ 2005 doesn't include some files. Do the following:
Hack doesn't activate/deactivate (Hotkeys) It can be:
credits blipi * - tomcat09 - Oct 7, 2009 Nice Tutorial :) but I got some problem with some Adresses :( With many I needed it works but i need to write 0x90 to some adresses and every time try to write to this addresses the game crashes :( All I need ist to write 5 bytes to 5 addresses if I use other programm languadge with winapi WriteProcessMemory or memory editor it works but with the dll it crashes and only to this adresses :( Any Idea what this can be ? Here my last try Or can you show me how to use WriteProcessMemory in such an dll :) ? Code #include <windows.h>I hope you can help cause I just started to code in c++ some days ago ^^ * - n3xus - Oct 7, 2009 Thanks for the tut man, I've never tried making dlls before. I will +rep you as soon as the rep plugin is enabled again. * - tomcat09 - Oct 7, 2009 I got it, it was an protected memory region -.- * - MCM Domino - Oct 7, 2009 i don't think a noob like myself is going to fully understand why the code does what it does, it's a good post, just sayin ppl will just copy/paste and not learn anything not because they are lazy but because they don't know the technical names yet i reconize some of it, but i myself am still learning * - ByteReaper - Oct 8, 2009 Sweet, I've wanted to learn DLLs for ages. Thanks for the info 👍 * - Kingdutch - Oct 8, 2009 Nice tutorial, but if you'd want to edit this for other games. How'd you find out what the memory address is (for say stamina, or whatever you wish to edit) and if it's protected yes or no. Thanks for posting :D * - PoZHx - Oct 8, 2009 (Oct 7, 2009 01:32 PM)tomcat09 Wrote: I got it, it was an protected memory region -.-http://msdn.microsoft.com/en-us/library/aa366898%28VS.85%29.aspx Sorted. (Oct 8, 2009 06:26 AM)Kingdutch Wrote: Nice tutorial, but if you'd want to edit this for other games. How'd you find out what the memory address is (for say stamina, or whatever you wish to edit) and if it's protected yes or no. When you attempt to change the value of the address it wil fail Use CheatEngine to scan for addresses follow tutorial and get better understanding before you asked questions Work on none protected games such as minesweeper before you move onto actual games Check following websites out: www.gamehacking.com great website for new hackers https://forum.gamedeception.net great website for adv. hackers ( dont ask noob questions or you will be banned no questions asked) www.feagaming.info new gamehacking very little resources atm www.aimbots.net inbetween check out tutorials etc If you dont have good understanding of debugging / asm / coding language of your choice i recommend you go learn If you do really want to dedicate yourself to learning gamehacking send me via private msg your MSN.. But before you decide it wont be thing you can learn in few weeks * - TheHackingIdiot - Oct 8, 2009 In Soviet Russia, computers program YOU! * - Agelast - Oct 28, 2009 thats pretty good!... * - tomcat09 - Nov 22, 2009 Hi i tried this: DWORD *thefirst = (DWORD*)(*(DWORD*)0x0040014F + 0x1378); DWORD *thesecond = (DWORD*)(*(DWORD*)thefirst + 0x18); DWORD *thethird = (DWORD*)(*(DWORD*)thesecond + 0x974); DWORD *thefourth = (DWORD*)(*(DWORD*)thethird + 0x34); but now i have one problem. How can i prevent a crash when I try to read an adress that does not exists? I have 3th level Pointer and the last adress does only exist sometimes ^^ Can anyone help me with example how to solve this problem ? * - PoZHx - Nov 22, 2009 (Nov 22, 2009 05:01 PM)tomcat09 Wrote: Hi i tried this: You dont add offsets like that lol xd Use ReadProcessMemory() read 0x040014F then add offset to the buffer etc etc Also extra note: 0x0040014F must be invalid because an EP starts at 0x0400000 in typical x86 application |