Simon Soka
Simon Soka

Reputation: 79

Converting string address to int address

So i couldn't find anything at google, believe in you guys.

I'm converting address from string which I read using StreamReader. Simply need advice how to convert it to actually be able to use readprocessmemory, I want to read address from .txt file.

Address looks like this: 0x003D6ED4 .

just simple int addr for rpm but can't somehow make it working so far.

PS: no, int.parse and convert.toint32 doesnt work. thanks

Upvotes: 2

Views: 661

Answers (2)

Backs
Backs

Reputation: 24903

It seems, you need HexNumber parsing:

var addr = int.Parse("0x003D6ED4".Substring(2), System.Globalization.NumberStyles.HexNumber);

Substring(2) - to skip 0x at the begining

Upvotes: 1

IglooGreg
IglooGreg

Reputation: 147

You can also do int addr = Convert.ToInt32("0x003D6ED4".Substring(2), 16);

Upvotes: 1

Related Questions