Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] My very useful HACKING HEADER!

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
educofu
Expert Cheater
Reputation: 3

Joined: 21 Aug 2009
Posts: 171
Location: Brazil,MG,OP

PostPosted: Fri Jan 21, 2011 12:17 pm    Post subject: [C++] My very useful HACKING HEADER! This post has 1 review(s) Reply with quote

hello guys,

i developed this to help me creating my C++ projects: a header!

this is my first one, and till now it works fine.

it already include <windows.h> , <iostream> and <psapi.h> (must to it works)

so u can create very tiny codes like this:
Code:


#include <hack.h>
using namespace std;

int main()
{
    int value;
    int address;
    while (AttachToProcess("MSACCESS.EXE"))
    {   
         cout << "Enter address to modify (decimal): ";
         cin >> address;
         cout << "Enter value: ";
         cin >> value;
         Write(address,value);
         system("PAUSE");
         }
    }


the header have the functions:

Code:

void   Clean                   () {system("CLS");}          // To clean the screen ^^
int    P                       (int address,int offset);    // For pointer addresses, using read(), eg.: P(P(pointer,offset1),offset2) = [[pointer]+offset1]+offeset2
bool   AttachToWindow          (char* name);                // Attach to the desired window name, return TRUE if sucess else FALSE
bool   AttachToPID             (int PIDtoLook);             // Attach to the desired PID, return TRUE if sucess else FALSE
bool   AttachToProcess         (char* pName);               // Attach to the desired process, return TRUE if sucess else FALSE
void   ShowProcessList         ();                          // Show a list of running processes
void   Write                   (int address,int value);     // Change the value in address to value
int    Read                    (int address,int size);      // Return the value in address; size = 1,2,4 bytes value
void   ReadString              (int address,int size);      // will store a string present in address to ReadStringValue
char   ReadStringValue[512];                                //
void   ExitProcess             ();                          // Exit the opened process


as u can see theres still allot of things to work on, thats why its on ALPHA version.

remember if u are using any IDE thats not MSVC: link libpsapi.a so it works fine.

as aways:
comments, suggestions, bugs, etc are welcome!

edit----

removed the search function, since it wasnt working as it should.
im studying caching to improve it.

THE HEADER : http://ifile.it/w7s8vxp

note: as the file was too small to upload i add a small useless file on it.

_________________
"I finally started thinking outside of the box, only to find myself in a larger box."


Last edited by educofu on Mon Mar 14, 2011 1:26 pm; edited 7 times in total
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Jan 21, 2011 1:01 pm    Post subject: Reply with quote

don't allocate such a giant chunk on the stack, you are cruising towards trouble:
Code:
int FoundAddress[1024];
char ReadStringValue[512];


allocate the memory yourself.

and what's the difference between the Read() and ReadString() functions? their prototype is the same. Why is it not just one function?
Back to top
View user's profile Send private message
educofu
Expert Cheater
Reputation: 3

Joined: 21 Aug 2009
Posts: 171
Location: Brazil,MG,OP

PostPosted: Fri Jan 21, 2011 1:30 pm    Post subject: Reply with quote

Read() returns an number of 1,2 or 4 bytes.
ReadString() saves the string of desired size on ReadStringValue

_________________
"I finally started thinking outside of the box, only to find myself in a larger box."
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Jan 21, 2011 1:52 pm    Post subject: Reply with quote

what if i want to read 60 bytes or write just as much?

like reading / writing a struct.
Back to top
View user's profile Send private message
educofu
Expert Cheater
Reputation: 3

Joined: 21 Aug 2009
Posts: 171
Location: Brazil,MG,OP

PostPosted: Sun Jan 23, 2011 10:22 pm    Post subject: Reply with quote

well, i gave the functions, i bet u can do what u want to using loops etc.

ofc it would be nice to implement a byte to byte writter/reader to/from an array.

ty for idea. going to release it in next ver.

more ideas are welcome^^

_________________
"I finally started thinking outside of the box, only to find myself in a larger box."
Back to top
View user's profile Send private message MSN Messenger
Eddie12390
Expert Cheater
Reputation: 0

Joined: 06 Oct 2007
Posts: 131
Location: Pittsburgh, PA

PostPosted: Wed Feb 02, 2011 7:24 pm    Post subject: Reply with quote

Just a few quick tips, both of the following are horrible programming practices. System() is "system specific" and therefore drops the portability of the program. There are better ways to do the same thing.

----------------------------------------------------

Code:
void   Clean                   () {system("CLS");}          // To clean the screen ^^


Replace that with something like this:

Code:
void Clean() {
for(int i = 0; i <= 50; i++) {
cout << "\n";
}
}


-------------------------------------------------------------

Code:
system("PAUSE");


and a replacement for this:

Code:
cout << "Press enter to continue";
cin.get();


--------------------------------------------------------------

All in all, use system(); as little as possible. Something that works well on Windows may not work elsewhere if you go that route. There are alternatives for what you want to do using system() and they are typically easy enough to do. The "cleaning" method will throw out a whole bunch of lines and push your text to the very bottom of the screen and get rid of all of the lines before it, the pause method will wait until the user presses enter and as soon as they do it will continue on.

TL;DR: Copy and paste the codes, they are better programming practice.

_________________
Back to top
View user's profile Send private message AIM Address
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8586
Location: 127.0.0.1

PostPosted: Thu Feb 03, 2011 1:32 pm    Post subject: Reply with quote

Spamming the console with \n to "clear" it isn't better practice lol..

On Windows users can use the standard API for consoles:
- GetStdHandle
- GetConsoleScreenBufferInfo
- FillConsoleOutputCharacter
- SetConsoleCursorPosition

Or using:
- std::system( "cls" );

(I recommend not using std::system at all on Windows, its bloated.)

On POSIX systems you can do things like:
- system( "clear" );
- cout << "\f";

Other methods:
printf("\033[2J\033[1;1H");

// all three lines
fputs("\033[A\033[2K\033[A\033[2K",stdout);
rewind(stdout);
ftruncate(1,0);

Credits:
http://stackoverflow.com/questions/228617/how-do-i-clear-the-console-in-both-windows-and-linux-using-c
http://stackoverflow.com/questions/1348563/clearing-output-of-a-terminal-program-linux-c-c

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
TrYk
How do I cheat?
Reputation: 0

Joined: 06 Feb 2011
Posts: 1

PostPosted: Sun Feb 06, 2011 10:05 am    Post subject: Reply with quote

I getting error on windows 7, microsoft visual studio ( C++ )

I create simple program like this:

Code:
#include <hack.h>
using namespace std;

int main()
{
    int value;
    while (AttachToProcess("Minesweeper.exe"))
    {   
         cout << "Enter value to search: ";
         cin >> value;
         Search(value, 4, 1, 0x10112600, 0x1013E800);
         system("PAUSE");
         }
    }


And getting errors:

Code:

1>------ Build started: Project: blablabla, Configuration: Debug Win32 ------
1>Build started 2011.02.06 07:48:38.
1>PrepareForBuild:
1>  Creating directory "c:\users\admin\documents\visual studio 2010\Projects\blablabla\Debug\".
1>InitializeBuildStatus:
1>  Creating "Debug\blablabla.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  asdasd.cpp
1>c:\program files\microsoft visual studio 10.0\vc\include\hack.h(44): warning C4101: 'doRescan' : unreferenced local variable
1>c:\program files\microsoft visual studio 10.0\vc\include\hack.h(155): error C2679: binary '==' : no operator found which takes a right-hand operand of type 'std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion)
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          could be 'built-in C++ operator==(char *, char *)'
1>          c:\program files\microsoft visual studio 10.0\vc\include\exception(470): or       'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)'
1>          c:\program files\microsoft visual studio 10.0\vc\include\exception(475): or       'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)'
1>          c:\program files\microsoft visual studio 10.0\vc\include\exception(481): or       'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)'
1>          c:\program files\microsoft visual studio 10.0\vc\include\system_error(408): or       'bool std::operator ==(const std::error_code &,const std::error_condition &)'
1>          c:\program files\microsoft visual studio 10.0\vc\include\system_error(416): or       'bool std::operator ==(const std::error_condition &,const std::error_code &)'
1>          c:\program files\microsoft sdks\windows\v7.0a\include\guiddef.h(192): or       'int operator ==(const GUID &,const GUID &)'
1>          while trying to match the argument list '(char *, std::basic_string<_Elem,_Traits,_Ax>)'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.46
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Back to top
View user's profile Send private message
educofu
Expert Cheater
Reputation: 3

Joined: 21 Aug 2009
Posts: 171
Location: Brazil,MG,OP

PostPosted: Fri Mar 11, 2011 12:19 pm    Post subject: Reply with quote

im going to remove the search function until i get it fully working. im studying caching for faster scans.
_________________
"I finally started thinking outside of the box, only to find myself in a larger box."
Back to top
View user's profile Send private message MSN Messenger
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 891

PostPosted: Mon Mar 14, 2011 8:13 am    Post subject: Reply with quote

Since you use common names for functions (read, write, search,etc), it would probably be a good idea to wrap your header in a namespace.

You can ignore the advice to avoid stack allocation. A few K on the stack is no big deal.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Mar 14, 2011 1:53 pm    Post subject: Reply with quote

justa_dude wrote:
Since you use common names for functions (read, write, search,etc), it would probably be a good idea to wrap your header in a namespace.

You can ignore the advice to avoid stack allocation. A few K on the stack is no big deal.

So exactly why do you think stack probes are necessary for stack allocations over the page size again ?
Back to top
View user's profile Send private message
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Mon Mar 14, 2011 2:20 pm    Post subject: Reply with quote

@educofu

File has expired from that link.

_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites