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++ to Delphi Help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
tanjiajun_34
Grandmaster Cheater
Reputation: 0

Joined: 16 Feb 2006
Posts: 786
Location: Singapore

PostPosted: Sun Oct 03, 2010 12:08 pm    Post subject: C++ to Delphi Help Reply with quote

I need help in convert this 2 line to delphi. I don't know C++ and what is char*.

Code:
char* MP = (char*)malloc(100);


And
Code:
memcmp( (void*)(MP+c), (void*)varbytes, strlen( varbytes) )


"varbytes" and "MP" is a char*.
"c" is a unsigned long


Also, I have a question about delphi. How to I create a variable in the statement(between the begin and end;) instead of before the statement? I don't want to waste a lot unused array. I want the program to be able to change the no. of array during runtime.

Thank you for helping
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 373

Joined: 09 May 2003
Posts: 22009
Location: The netherlands

PostPosted: Sun Oct 03, 2010 2:58 pm    Post subject: This post has 1 review(s) Reply with quote

Code:

char* MP = (char*)malloc(100);

is
Code:

var MP: pchar;
...
getmem(mp,100);


Code:

memcmp( (void*)(MP+c), (void*)varbytes, strlen( varbytes) )

is
Code:

CompareMem(mp+c, varbytes, strlen(varbytes));

assuming varbytes is also a pchar

remember that strlen stops when a 0-terminator is encountered, so if this is for an aob scanner it's useless

Quote:
Also, I have a question about delphi. How to I create a variable in the statement(between the begin and end;) instead of before the statement? I don't want to waste a lot unused array. I want the program to be able to change the no. of array during runtime.

you don't create variables inside a statement, but you can allocate and resize a dynamic array using setlength

e.g:
Code:

var bla: array of byte;
begin
  setlength(bla,1)
  bla[0]:=$90;

  //then you find out you need more so:
  setlength(bla,3)
  bla[1]:=$90;
  bla[2]:=$90;

//the array bla is destroyed on function exit
end;

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
tanjiajun_34
Grandmaster Cheater
Reputation: 0

Joined: 16 Feb 2006
Posts: 786
Location: Singapore

PostPosted: Mon Oct 04, 2010 6:45 am    Post subject: Reply with quote

Another question
How do I convert a pchar into a pointer?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 373

Joined: 09 May 2003
Posts: 22009
Location: The netherlands

PostPosted: Mon Oct 04, 2010 8:20 am    Post subject: Reply with quote

not, it's already a pointer

but if you insist : pointer(pcharvar) but really, there is no need

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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