| View previous topic :: View next topic |
| Author |
Message |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Tue Oct 21, 2008 5:31 pm Post subject: Can someone convert this from vb to delphi for me? |
|
|
| 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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Oct 21, 2008 6:10 pm Post subject: |
|
|
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 |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Tue Oct 21, 2008 6:24 pm Post subject: |
|
|
| 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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Oct 21, 2008 6:37 pm Post subject: |
|
|
Doesn't it have Inc?
_________________
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Tue Oct 21, 2008 7:11 pm Post subject: |
|
|
| dnsi0 wrote: | | I just tryed delphi and it doesn't have a step command which makes i increse by how ever much you want... |
to make it increase by 1.
Or:
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 |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Oct 22, 2008 4:47 pm Post subject: |
|
|
| Eh... Its every 2 chars converted into 1 byte?
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Wed Oct 22, 2008 5:35 pm Post subject: |
|
|
| dnsi0 wrote: | | Eh... Its every 2 chars converted into 1 byte? |
Why don't you test it..or learn more delphi.
|
|
| Back to top |
|
 |
|