tags:

views:

55

answers:

2

I'm using lpBaseAddress : IntPtr

but ... I need to enter hex value :-/ like a normal offset

like on VB that could be something like :

offset = CLng("&H" + text)

So I need to take a value from textbox and make same magic on C# (or Nemerle ^_)

+1  A: 
offset = System.Convert.ToInt64(this.yourTextBox.Text, 16);

Are you sure you need an Int64 (Long) and not just an Int32 (Int)? If you're a VB6 coder, Int32 (Int) is what you're looking for, not Long.

Bobby
Im not vb coder :) and I don't know VB
nCdy
@nCdy: My bad, sorry. I just asked because I associate offsets with Ints, and VB6 developers tend to use Longs even within .NET, because they never really look at the new framework.
Bobby
+1  A: 

If you just want to parse hex:

string hex = "0a12cc";
long ptr = Convert.ToInt64(hex, 16);
IntPtr newPtr = new IntPtr(ptr);

I've used long here for illustration, as IntPtr could be 32/64.

Marc Gravell
I think I need intptr ....
nCdy
@nCdy - it shows `IntPtr`...?
Marc Gravell
what shows ? :S[DllImport("kernel32.dll",SetLastError = true)]static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte [] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);Pinvoke tells it must be intptr :-S
nCdy