Sign in to follow this  
Followers 0
Jango

String to Hex conversion

8 posts in this topic

Hello,

I have the following code

$Adr    = 0x055CE390

...
$Handle = _MemoryOpen($PID)
                If @error = 0 Then
                        $Mem = _MemoryRead($Adr, $Handle)
...

MemoryRead require $Adr as hexadecimal value. But now i read the adress from a text file

$Adr = FileRead("adr.dat")

Then the $Adr variable is string ... how can i convert string to hex value accepted by _MemoryRead ?

I already extensively checked the help file but i'm a little bit confused...

Share this post


Link to post
Share on other sites



Hello.

Example from the help for the value you need to convert doesn't work for you?

$result = Hex(1033, 4)  ;returns "0409"

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Hello.

Example from the help for the value you need to convert doesn't work for you?

$result = Hex(1033, 4)  ;returns "0409"

Regards, Rudi.

I already tried that but it does'nt work

if i do

$Mem = _MemoryRead(0x400000, $Handle)

It works fine but here i read the adress from a file and it's like to have "400000" (string)

How to convert string "400000" to 0x400000 ?

Note: I also tried _StringToHex function but it does'nt work too and give me a strange result probably because it's the ascii code of my string converted in hex...

Share this post


Link to post
Share on other sites

I already tried that but it does'nt work

if i do

$Mem = _MemoryRead(0x400000, $Handle)

It works fine but here i read the adress from a file and it's like to have "400000" (string)

How to convert string "400000" to 0x400000 ?

Note: I also tried _StringToHex function but it does'nt work too and give me a strange result probably because it's the ascii code of my string converted in hex...

Have you tried something like Int("yourstring")? MsgBox(0,"",IsInt(Int("400000"))) returns 1, so that might work for you...?!

After that. a MsgBox(0,"",Hex("0x"&Int("400000"))) returns what you are looking for. I hope that helps.


You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/

Share this post


Link to post
Share on other sites

Have you tried something like Int("yourstring")? MsgBox(0,"",IsInt(Int("400000"))) returns 1, so that might work for you...?!

After that. a MsgBox(0,"",Hex("0x"&Int("400000"))) returns what you are looking for. I hope that helps.

I tried that but it does'nt work, in fact my string "400000" is an hexadecimel value. But i need to pass the type 0x... to my fucntion... arg :)

Share this post


Link to post
Share on other sites

I found the solution but i don't know why it works precisely...

$Adr = "400000"

$Mem = _MemoryRead(Dec($Adr), $Handle)

This works and give me the correct result, if someone know why plz tell me because i want to know

Share this post


Link to post
Share on other sites

I found the solution but i don't know why it works precisely...

$Adr = "400000"

$Mem = _MemoryRead(Dec($Adr), $Handle)

This works and give me the correct result, if someone know why plz tell me because i want to know

I think it works because the function behind _MemoryRead accept value in decimal as a memory address

Share this post


Link to post
Share on other sites

I found the solution but i don't know why it works precisely...

$Adr = "400000"

$Mem = _MemoryRead(Dec($Adr), $Handle)

This works and give me the correct result, if someone know why plz tell me because i want to know

I think it works because the function behind _MemoryRead accept value in decimal as a memory address

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0