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 


Which programming language is the best for my case?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Game Development
View previous topic :: View next topic  
Author Message
hitmetwice
Advanced Cheater
Reputation: 0

Joined: 20 Nov 2012
Posts: 63

PostPosted: Tue Mar 19, 2013 1:11 pm    Post subject: Which programming language is the best for my case? Reply with quote

I'm thinking about writing a bot for one of my onlinegames. So I would search for some static pointers and good places to inject code. But what is the next step?
What programming language should I use? C#, C++, C, Java? Or AutoIt/Autohotkey/Python?

I have some basic knowledge with HTML/CSS/PHP/Javascript and some advanced knowledge about Lua and Autohotkey. But I since every millisecond counts, I'm thinking about something more professionell.
How would you rate C#, C++, C, Java? (speed, easy to learn, "neat" of the code, fast libs available .....)

I also wanna make a UI and I hate it when the UI is lagging while the program is working or when it looks crapy. I like Windows standard UI elements.

Hope you can help me. Smile
Back to top
View user's profile Send private message
hitmetwice
Advanced Cheater
Reputation: 0

Joined: 20 Nov 2012
Posts: 63

PostPosted: Wed Mar 20, 2013 8:08 am    Post subject: Reply with quote

I pretty much decided to use C#. Simply because most tutorials here are made for C# and because it seems to be relatively easy compared to C++. I don't really like the fact that a .Net framework is required, but okay... It's really way easier than I thought it would be. I found millions of Memory Read/Write classes/functions/libs/structs or however I have to call them. Some of them looked really simple and some of them where like "Dafuq, I don't understand anything".
I'm looking for a class with a good severty-performance ratio. I really don't wanna lose multiple milliseconds. But in my head it could be so easy:
Code:
OpenMemory();
playerHealthAddress = GetAddress('[[[[["Borderlands2.exe"+015B2260]+38]+2BC]+358]+1E4]+0');
float playerHealth = ReadMemory(playerHealthAddress);
CloseMemory();
System.Console.WriteLine(playerHealth);

:P
So, whose mem write/read class would you suggest me to use? :)
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Wed Mar 20, 2013 9:14 am    Post subject: Reply with quote

If you need to do any type of injection, I'd suggest using C/C++ for the language. UI wise I'd go with C# just to make it easier on yourself to pump out a UI with little effort.

If it comes to it, mix the two and inject a C/C++ DLL and use any form of IPC to communicate with your C# UI.

As for memory classes, write your own. Learn what you are doing as you go instead of just copy pasting others code.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
hitmetwice
Advanced Cheater
Reputation: 0

Joined: 20 Nov 2012
Posts: 63

PostPosted: Wed Mar 20, 2013 3:46 pm    Post subject: Reply with quote

I don't really want to understand how memory reading/writing works... I just want to wirite a basic bot as fast as possible. Right now I think it would take me about two weeks, but if I'd try to actually understand everything I would work on that for months... I know me. If something takes too long I'm definitely loseing the interest and I will start doing something else... : /

So actually I'd like to start with the lib that offers the best (easiest) api I can get. And once my bot is finished I'd like to understand everything and slowly upgreade to more efficient methods... Also I don't want to work with two programming languages. I kinda think that C# is the only way to go for me. C++ looks too difficult.
I hope you understand that. So what is the easiest Memory read/write class available for C#? : )
However, I should probably open a new thread for that. Rolling Eyes
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Wed Mar 20, 2013 8:29 pm    Post subject: Reply with quote

If you have no interest in actually learning what you are doing why bother with it to begin with?
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
hitmetwice
Advanced Cheater
Reputation: 0

Joined: 20 Nov 2012
Posts: 63

PostPosted: Thu Mar 21, 2013 9:25 am    Post subject: Reply with quote

I have right now no interesst in learning how the memory read/write part of the programs works...
You don't have to understand everything. I'm pretty sure you don't understand everything either. Do you want to know how exactly the binary code that is executed looks like or how exactly it works? Do you want to know how exactly your CPU-BUS-RAM system works with your code?
It's simply too much for me. I want to keep my interesst in this project. And the only way to ensure that is to finish a program as fast as possible... When I have my basic bot I will upgrade it and of course I will try to understand everything. :)
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Thu Mar 21, 2013 5:57 pm    Post subject: Reply with quote

hitmetwice wrote:
I have right now no interesst in learning how the memory read/write part of the programs works...
You don't have to understand everything. I'm pretty sure you don't understand everything either. Do you want to know how exactly the binary code that is executed looks like or how exactly it works? Do you want to know how exactly your CPU-BUS-RAM system works with your code?
It's simply too much for me. I want to keep my interesst in this project. And the only way to ensure that is to finish a program as fast as possible... When I have my basic bot I will upgrade it and of course I will try to understand everything. Smile


There is a different between understanding the hardware interpretation of binary and the actual code flow and usage of a higher level language. If you don't even understand the programming language, it's basic features, how to make simple API calls, etc. there is literally no reason to even bother learning.

All you are going to do is end up asking a million questions when things don't work because you didn't take the time to learn.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
SteveAndrew
Master Cheater
Reputation: 30

Joined: 02 Sep 2012
Posts: 323

PostPosted: Thu Mar 21, 2013 7:04 pm    Post subject: Reply with quote

lol Wiccaan can we just tell him to 'TICK ZF' ?!! LOLOLOLOL

Oh the days when we used to Tick ZF! I still do sometimes!! lol

No but seriously Wiccaan is right hitmetwice! Start from the bottom and work your way up!

I didn't even learn C++ until I was fluent in assembler! and all that assembler knowledge made C++ a nice cool breeze on a hot summer's day! We aren't talking about building a computer from your toaster and an old stereo, but just knowing how to make toast before you go and burn your hand! Very Happy

P.S. I still make pretty GUI's with little effort and I use C++ not C# Very Happy [Embarcadero RAD Studio XE 3 FTW Wink NO VCL /w FireMonkey instead xD]... build with no packages and Dynamic RTL set to false XD I still use MSVC++ for dll's though...

_________________
Back to top
View user's profile Send private message
hitmetwice
Advanced Cheater
Reputation: 0

Joined: 20 Nov 2012
Posts: 63

PostPosted: Fri Mar 22, 2013 6:28 am    Post subject: Reply with quote

@Wiccaan Maybe my example was bad, but I think you got my point. Smile
And, no. I'm definitely not going to ask questions about basic C# stuff. I just want a simple Memory read/write function. I couldn't really find anything that would answer my question by googleing, that's why I opened this thread.
I would never ask for help to understand the fucntions. I know how to use google. Smile
@SteveAndrew 'TICK ZF'? I don't get it.


I have no idea how I could explain that to you. I am pretty "unnormal" guy concerning this matter. Most people can't put theirselves in my shoes...
I could nerver just learn somthing like that the normal way, starting with hello world etc... I'm getting bored extremely fast.
If I wouldn't have started watching english movies and reading english stuff on the internet, I wouldn't even be able to build complete sentences.
Three years ago I started to learn "C", but after 3 weeks I was soo bored that I stoped. You know, I need something that motivates me. Simple popup windows that read what I want are not doing the job. I need a little bit more.
I think my way of learining things is somehow related to my attention deficit disorder. I really don't want to use you. This is just the only way for me to do it. It's okay if you don't want to help me. I don't want to force anyone to anything. Smile
Back to top
View user's profile Send private message
SteveAndrew
Master Cheater
Reputation: 30

Joined: 02 Sep 2012
Posts: 323

PostPosted: Fri Mar 22, 2013 12:46 pm    Post subject: Reply with quote

hitmetwice wrote:

@SteveAndrew 'TICK ZF'? I don't get it.


Okay well you know what a conditional jump is right? (an unconditional jump follows the jump no matter what, where as a conditional jump only follows the jump if certain 'conditions' are true)

Conditional jumps work by which flags are set, flags are set by certain instructions, the most obvious one's are CMP (compare) or TEST

Reference for conditional jumps:
http://faydoc.tripod.com/cpu/je.htm

The only conditional jumps that ONLY depend on the 'Zero Flag' being set or not set are JE/JZ or JNE/JNZ

JE(jump if equal) is really the same as JZ (jump if zero [jump if zero flag is set {see what I did there? Wink}])

where as JNE (jump if not equal) is reallly the same as JNZ (jump if not zero)

Following that reference you could know which flags to set/unset to achieve whether you want it to follow the jump or not follow it, but for a simple example lets just use JE or JNE as we only have to worry about the ZF (Zero Flag) in that case...

This Auto Assembler script can be injected into any game/application you have Cheat Engine attached to...

Code:

//ZF (Zero Flag) Test
[enable]
alloc(ZFTest,128)
label(ExitTheTestUponDisabling)
label(WillNeverNormallyMakeItHere)
label(MessageToYou)
label(MessageTitle)
label(ExitTheTest)
createthread(ZFTest)
registersymbol(ZFTest)
registersymbol(ExitTheTest)

ZFTest:
push 0a
call Sleep

xor eax,eax //eax == 0 after this line
inc eax     //eax == 1 after this line
test eax,eax//test if eax == 0
je WillNeverNormallyMakeItHere //if its equal to zero follow this jump (we know will always equal 1 here)
cmp [ExitTheTest],1
je ExitTheTestUponDisabling
jmp ZFTest

WillNeverNormallyMakeItHere:
push 0
push MessageTitle
push MessageToYou
push 0
call MessageBoxA

ExitTheTestUponDisabling:
ret

MessageToYou:
db 'Congrats you have either Ticked ZF [X] on first je or just reversed that jump (made it into jne)',0

MessageTitle:
db 'Zero Flag Test',0

ExitTheTest:
dd 0

[disable]

ExitTheTest:
dd 1

unregistersymbol(ZFTest)
unregistersymbol(ExitTheTest)



It creates a thread, and purposely creates a condition that will never be true... Only if you either alter the Zero Flag and force it to be set by right clicking the first conditional jump 'je' instruction or manually changing it to be a jne will a message box ever be shown... (disabling the script will exit the thread, but not show the message box)


These three lines here set up the condition and check if eax is zero
Code:

xor eax,eax //eax == 0 after this line
inc eax     //eax == 1 after this line
test eax,eax//test if eax == 0


Since eax is always going to be '1' since we have forced it to be so... eax will never equal zero (zero flag will never be set)! you could even swap out the je with jz and it would be the same...


After adding that test script to your CT and injecting it (by ticking the box to enable it) goto address 'ZFTest' in memory viewer... The first je instruction right click on it and choose 'Change register at this location' (it also lets you change flags) and tick the ZF box so it's checked, as shown in this image:


It will ask you if you want to attach the debugger if you haven't already for whatever game/app your attached to, choose yes...

If all goes well you should hear a sound, and if you click on the icon in the taskbar of whatever game/app it is, you'll see a message box Wink

You successfully forced the ZF flag to be set, in some cases you might want to force it to be unset, and so on and so forth...

P.S. I've noticed sometimes it doesn't apply the first time if you haven't attached the debugger yet, so if that's the case and you didnt get the message box, untoggle the breakpoint (F5 on the je instruction, or right click it) and apply it again, this time it will work for sure!

So now you know what the Zero Flag is! Very Happy

_________________
Back to top
View user's profile Send private message
hitmetwice
Advanced Cheater
Reputation: 0

Joined: 20 Nov 2012
Posts: 63

PostPosted: Fri Mar 22, 2013 3:16 pm    Post subject: Reply with quote

Ohhhkay. Surprised Very Happy

Well, back to topic. Very Happy
I started to write the function as I want to have it myself. I found a simple template:
forum.cheatengine.org/viewtopic.php?t=530207
Code:

        #region MemoryWrite
        public void MemoryWrite(int address, int[] offsets, int value)
        {
            int converted_address = Addr.ToDec(address.ToString());
            int bytesWritten;
            byte[] converted_value = BitConverter.GetBytes(value);
            string sWritten_Address = oMemory.PointerWrite((IntPtr)converted_address, converted_value, offsets, out bytesWritten);
            if (bytesWritten == converted_value.Length)
                MessageBox.Show("Wrote " + value.ToString() + " to " + sWritten_Address + "!");
            else
                MessageBox.Show("There was an error writing " + value.ToString() + " to " + sWritten_Address + ".");
        }
        #endregion

Now I can call my writing function like that:
Code:

MemoryWrite(00690320, new int[] { 0x464, 0xC4 }, 100);
//write 100 to the address of the pointer 00690320 with the offsets 0x464 and 0xC4


Pretty good for the second day, huh?
But however, I don't really know how to do it with the MemoryRead function.
Code:

public void MemoryRead(int address, int[] offsets)
{
// ?????????????
//I'm pretty sure I have to use PointerRead from the thread I mentioned in the beginning.
}

I want to automatically detect the length of the bytesToRead etc. But I have absolutely no idea how this works... I mean in the end I want to be able to call this function with only two parameters:
Code:

int pointerValue = MemoryRead(00690320, new int[] { 0x464, 0xC4 });
//first param: the address; second param: the offsets


Can you help me with that? Smile
Back to top
View user's profile Send private message
deviluc
Cheater
Reputation: 1

Joined: 02 Jun 2010
Posts: 28

PostPosted: Fri May 03, 2013 5:03 pm    Post subject: Reply with quote

The mentioned function:
Quote:
Pretty good for the second day, huh?
But however, I don't really know how to do it with the MemoryRead function.
Code:

public void MemoryRead(int address, int[] offsets)
{
// ?????????????
//I'm pretty sure I have to use PointerRead from the thread I mentioned in the beginning.
}

doesn't return any values, beacause it's void stands for nothing/null/nerda, to read memory you'll need to use that method:
Code:
public byte[] Read(IntPtr MemoryAddress, uint bytesToRead, out int bytesRead)

or:
Code:
public byte[] PointerRead(IntPtr MemoryAddress, uint bytesToRead, int[] Offset, out int bytesRead)


And to know the length of the bytes to read:
Code:

1-Byte Address: 00-FF (0-255)
2-Byte Address: 0000-FFFF (0-65535)
4-Byte Address: 00000000-FFFFFFFF (0-4294967295)
8-Byte Address: 0000000000000000-FFFFFFFFFFFFFFFF (0-enough ;)  )


P.S.: Floats stored as 4-Byte and Doubles as 8-Bytes
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Game Development 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