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++ dll edit array of bytes

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Kukudum
How do I cheat?
Reputation: 0

Joined: 07 Mar 2009
Posts: 3

PostPosted: Sun Mar 22, 2009 10:52 am    Post subject: c++ dll edit array of bytes Reply with quote

I've been searching for a way to edit an array of bytes (96 bytes total) in a target process - a game called Rakion (the game is protected by GameGuard).
Since there was an undetected injector released I figured I'll just make a dll.

I found a tutorial on how to make the dll (or rather the source of the dll) but it's written in the Delphi language. I don't know much about Delphi but I understand what's going on.
Here's what i do in cheat engine


There should have been urls to screenshots here but it doesn't let me
Just remove the space between the "h" and "ttp"
h ttp://img220.imageshack.us/my.php?image=15003268.jpg
h ttp://img106.imageshack.us/my.php?image=46321771.jpg

Here is the source of the dll - Delphi
He uses a different address and value (edits another thing but that doesn't matter)
Code:

library Nak2Dragon;

uses
  Windows;

const
   N:dword=$353E49C8;

 CellArray:Array[0..95] of Byte = ($04, $00, $40, $35, $00, $00, $00, $00, $08, $00, $40, $35, $00, $00, $00, $00, $20, $36, $3E, $35, $01, $00, $00, $00, $28, $00, $40, $35, $01, $00, $00, $00, $8C, $7B, $31, $35, $58, $73, $2F, $35, $63, $04, $00, $00, $60, $39, $3E, $35, $80, $67, $10, $35, $A0, $64, $10, $35, $B0, $64, $10, $35, $C0, $64, $10, $35, $E0, $64, $10, $35, $F0, $64, $10, $35, $00, $65, $10, $35, $D0, $64, $10, $35, $01, $00, $00, $00, $FF, $FF, $FF, $FF, $C0, $69, $10, $35, $58, $73, $2F, $35);
Procedure celladdress2cellarray;
var
  j:Integer;
begin
  VirtualProtectEx(GetCurrentProcess,ptr(N),96,PAGE_EXECUTE_READWRITE,nil);


  while(true) do
    for j := 0 To Length(CellArray) do
      PByte(N + j)^:=CellArray[j];


end;

var
  x:cardinal;

Begin
   CreateThread(nil,0,@celladdress2cellarray,nil,0,x);
  if x=0 then
    MessageBox(0, 'Cannot Inject.', 'Failed!', MB_OK or MB_ICONERROR) else
    MessageBox(0, 'Nak -> Dragon Created By Andre', 'gamersNeeds.net', MB_OK);

end.


So I do the same thing (or that's what I think atleast) in a C++ project
I create a thread named blabla and do my stuff there. The problem is that I crash.. the game works fine until I summon (it accesses that address).. I must be doing something waaayy off but since I'm new to this I don't really get what's wrong.

Code:

BYTE newdata[96]={0x4C, 0xDF, 0x40, 0x35, 0x00, 0x00, 0x00, 0x00, 0x50, 0xDF, 0x40, 0x35, 0x00, 0x00, 0x00, 0x00, 0x70, 0x12, 0x3F, 0x35, 0x06, 0x00, 0x00, 0x00, 0x70, 0xDF, 0x40, 0x35, 0x02, 0x00, 0x00, 0x00, 0xC8, 0xB2, 0x32, 0x35, 0x68, 0xB3, 0x30, 0x35, 0x77, 0x04, 0x00, 0x00, 0xD0, 0x15, 0x3F, 0x35, 0x40, 0x2B, 0x10, 0x35, 0x60, 0x26, 0x10, 0x35, 0x70, 0x26, 0x10, 0x35, 0x80, 0x26, 0x10, 0x35, 0xA0, 0x26, 0x10, 0x35, 0xB0, 0x26, 0x10, 0x35, 0xC0, 0x26, 0x10, 0x35, 0x90, 0x26, 0x10, 0x35, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x36, 0x10, 0x35, 0x68, 0xB3, 0x30, 0x35};
         
VirtualProtectEx(GetCurrentProcess, (LPVOID)0x353F1220, 96, PAGE_EXECUTE_READWRITE, NULL);

for (int nInc=0; nInc < 95; nInc++)
  {

      *(BYTE*)(0x353F1220 + nInc) = newdata[nInc]; //crash :S

  }


The full source of my dll is in the attachment
P.S: please excuse my english as it is not my native language Embarassed
and thank you for reading this looong post Wink



The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.

Back to top
View user's profile Send private message
AlbanainRetard
Master Cheater
Reputation: 0

Joined: 02 Nov 2008
Posts: 494
Location: Canada eh?

PostPosted: Sun Mar 22, 2009 11:22 am    Post subject: Reply with quote

Look into Kitterz, Elayos ('s) source they are made in C++. Also I made a simplistic refrence somewhere in the first 1-6 pages in GP look there.

If you look at hacks.cpp you should see how he edits his, altough AoB are used to find addresses so use FindPattern?

_________________
Back to top
View user's profile Send private message Send e-mail
Kukudum
How do I cheat?
Reputation: 0

Joined: 07 Mar 2009
Posts: 3

PostPosted: Sun Mar 22, 2009 11:30 am    Post subject: Reply with quote

AlbanainRetard wrote:
AoB are used to find addresses so use FindPattern?

I don't need to find the address. I already have it and it won't change (unless a MAJOR update). Either way I'll have a look at the source you pointed me to

Edit: Did you mean this-> h-ttp://forum.cheatengine.org/viewtopic.php?p=3289166 (Kitterz Trainer)? From what I gather it's a MapleStory trainer (never played the game).

Also I took a look at the hacks.cpp. I basically do the same thing

Code:

*(BYTE*)(BlinkAddy + 9) = 0x90;               //should be the same as
*(BYTE*)(0x353F29C8 + nInc) = newdata[nInc];  //this one
                                              //for example if nInc were 1 (since it is a loop it will change):
*(BYTE*)(0x353F29C8 + 1) = newdata[1];        //2nd byte of newdata (newdata[0] being the 1st byte)

Maybe I'm missing something (logical)
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Mar 22, 2009 4:39 pm    Post subject: Reply with quote

it would be more efficient if you get the length first. then write as big blocks as possible. eg. keep writing dwords till there is 3 or less left. then words if there are 2/3 bytes left and so on..
Back to top
View user's profile Send private message
Kukudum
How do I cheat?
Reputation: 0

Joined: 07 Mar 2009
Posts: 3

PostPosted: Sun Mar 22, 2009 5:35 pm    Post subject: Reply with quote

I thought about that but since it crashes me already I'm trying to figure out why Sad . Otherwise i have to write 96 bytes - 24 DWORDs if I'm not mistaken. I only do this function once so I guess it doesn't slow me that bad (I'm gonna change it once I figure out what's wrong)

The thing is I have no idea why I crash (it compiles fine).

Edit: Please when you see array of bytes in the title don't assume I'm trying to do something very complex Very Happy. I just want to write the bytes to that address Wink . myaddress+1 = 0xmybyte ; myaddress+2 = 0xmybyte2 etc..
It's just that the program crashes when it reads the addresses I modified Crying or Very sad
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