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 


String to Byte Array

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

Joined: 18 Feb 2011
Posts: 7

PostPosted: Tue Mar 01, 2011 5:21 pm    Post subject: String to Byte Array Reply with quote

Hello, looking for an example in vb.net or c# of how to convert the following string into a byte array to work in WriteProcessMemory. Thank you
Code:

 OPcode = "60"
        OPcode &= "A1" & MemFunctions._ResHex(&H9F3E6C)
        OPcode &= "68" & MemFunctions._ResHex(MonsterID)                         ' push mob-id
        OPcode &= "8B4820"                                                       ' mov ecx, [eax+0x20]
        OPcode &= "81C1" & MemFunctions._ResHex(&HEC)                            ' add ecx, 0xEC
        OPcode &= "E8" & MemFunctions._ResHex(&HE4F69CA7)                        ' Callstring
        OPcode &= "61"                                                           ' popad
        OPcode &= "C3"


Back to top
View user's profile Send private message
AhMunRa
Grandmaster Cheater Supreme
Reputation: 27

Joined: 06 Aug 2010
Posts: 1117

PostPosted: Tue Mar 01, 2011 10:21 pm    Post subject: Reply with quote

From http://www.chilkatsoft.com/faq/dotnetstrtobytes.html
Code:

public static byte[] StrToByteArray(string str)
{
    System.Text.UTF8Encoding  encoding=new System.Text.UTF8Encoding();
    return encoding.GetBytes(str);
}


Just change the encoding to suite your needs.

_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.>
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 204

Joined: 25 Jan 2006
Posts: 8580
Location: 127.0.0.1

PostPosted: Wed Mar 02, 2011 12:21 am    Post subject: Reply with quote

AhMunRa wrote:
From http://www.chilkatsoft.com/faq/dotnetstrtobytes.html
Code:

public static byte[] StrToByteArray(string str)
{
    System.Text.UTF8Encoding  encoding=new System.Text.UTF8Encoding();
    return encoding.GetBytes(str);
}


Just change the encoding to suite your needs.


Doing this will just convert the text to its Ascii format of a byte array.

Check out this example:
Code:

public static byte[] StringToByteArray(string hex) {
    return Enumerable.Range(0, hex.Length).
           Where(x => 0 == x % 2).
           Select(x => Convert.ToByte(hex.Substring(x, 2), 16)).
           ToArray();
}


Credits:
http://stackoverflow.com/questions/321370/convert-hex-string-to-byte-array

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Mar 02, 2011 5:50 am    Post subject: Reply with quote

You want to convert asm to opcode ?
Back to top
View user's profile Send private message
SlowPoke69
How do I cheat?
Reputation: 0

Joined: 18 Feb 2011
Posts: 7

PostPosted: Wed Mar 02, 2011 8:17 am    Post subject: Reply with quote

Thank you so much for the quick reply!. It works! Yay!
Very Happy
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Mar 02, 2011 1:11 pm    Post subject: Reply with quote

SlowPoke69 wrote:
Thank you so much for the quick reply!. It works! Yay!
Very Happy


you're welcome, CE Team. Smile
Back to top
View user's profile Send private message
Miaurice
Newbie cheater
Reputation: 0

Joined: 03 Jul 2009
Posts: 21
Location: Germany

PostPosted: Mon Mar 07, 2011 8:04 am    Post subject: Reply with quote

I am not able to PM yet, because I'm not a "trusted member", so I have to post it here.
I'm sorry, but this is important for me.

Hey SlowPoke69
I've seen that you posted in my topic, that you also looked for reading float values, and then I was interested in you, and looked through all your posts, and see, that you might need this for a "fog and zoom" hack, in Metin2?
Also you posted this: viewtopic.php?p=5205902
This looks like "Mob-Lock" for me.
Can you tell me, how you make the "Mob-Lock" in .NET ?
And can you tell me, how to reverze the metin2client.bin / metin2.bin to find these opcodes?

Thanks in advance Smile
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Tue Mar 08, 2011 12:49 am    Post subject: Reply with quote

Gabe Newell wrote:
You want to convert asm to opcode ?
You need to write an assembler or use an existing one.
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