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 


Can someone convert this from vb to delphi for me?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Tue Oct 21, 2008 5:31 pm    Post subject: Can someone convert this from vb to delphi for me? Reply with quote

Code:
Public Function StringToArray(StrIn As String) As Byte()
Dim Result() As Byte
ReDim Result(Len(StrIn) / 2)
Dim NC As Integer

NC = 0
For i = 1 To Len(StrIn) Step 2
    Result(NC) = HextoDec(Mid(StrIn, i, 2))
   
    NC = NC + 1
Next i
StringToArray = Result
End Function


So what this does is that it converts string into a aob.

So Im trying to use this for dumping dlls instead of including them into the release.

So If My string was 0002030AFF then what comes out is a array of byte that contains

0=00
1=02
2=03
3=0A
4=FF
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Oct 21, 2008 6:10 pm    Post subject: Reply with quote

In C++:
Code:
BOOL StringToArray(__in_z LPCTSTR lpString, __out BYTE *Bytes)
{
   LPTSTR   lpSep = (LPTSTR)HeapAlloc(GetProcessHeap(), 0, sizeof(TCHAR)*3);

   if (lpSep != NULL)
   {
      for (int i = 0, Pos = 0; Pos < lstrlen(lpString); i++, Pos += 2)
      {
         lstrcpyn(lpSep, &lpString[Pos], 2);
         Bytes[i] = (BYTE)_tcstoul(lpSep, 0, 16);
      }
      HeapFree(GetProcessHeap(), 0, (LPVOID)lpSep);
      return TRUE;
   }
   return FALSE;
}


Haven't tested, just quickly coded it.

_________________
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Tue Oct 21, 2008 6:24 pm    Post subject: Reply with quote

I just tryed delphi and it doesn't have a step command which makes i increse by how ever much you want...
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Oct 21, 2008 6:37 pm    Post subject: Reply with quote

Doesn't it have Inc?
_________________
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Tue Oct 21, 2008 7:11 pm    Post subject: Reply with quote

dnsi0 wrote:
I just tryed delphi and it doesn't have a step command which makes i increse by how ever much you want...


Code:
Inc(i);


to make it increase by 1.

Or:

Code:
Inc(i;value);


to make it increase by value.


Harharhar

Code:
function ConvertToBytes(stringg: string): array of byte;
var i : integer;
begin
setlength(result,length(stringg));
for i:=0 to length(stringg)-1 do
result[j]:=ord(stringg[i+1])-48;
end;
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Wed Oct 22, 2008 4:47 pm    Post subject: Reply with quote

Eh... Its every 2 chars converted into 1 byte?
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Wed Oct 22, 2008 5:35 pm    Post subject: Reply with quote

dnsi0 wrote:
Eh... Its every 2 chars converted into 1 byte?


Why don't you test it..or learn more delphi.
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