View previous topic :: View next topic |
Author |
Message |
tanjiajun_34 Grandmaster Cheater Reputation: 0
Joined: 16 Feb 2006 Posts: 786 Location: Singapore
|
Posted: Sun Oct 03, 2010 12:08 pm Post subject: C++ to Delphi Help |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Oct 03, 2010 2:58 pm Post subject: |
|
|
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 |
|
|
tanjiajun_34 Grandmaster Cheater Reputation: 0
Joined: 16 Feb 2006 Posts: 786 Location: Singapore
|
Posted: Mon Oct 04, 2010 6:45 am Post subject: |
|
|
Another question
How do I convert a pchar into a pointer?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Mon Oct 04, 2010 8:20 am Post subject: |
|
|
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 |
|
|
|