Click here to Skip to main content
16,011,475 members
Home / Discussions / C#
   

C#

 
GeneralRe: DES Crypto help Pin
Heath Stewart13-May-04 3:26
protectorHeath Stewart13-May-04 3:26 
GeneralInter Process Communication Pin
gek_at13-May-04 2:31
gek_at13-May-04 2:31 
GeneralRe: Inter Process Communication Pin
Heath Stewart13-May-04 3:45
protectorHeath Stewart13-May-04 3:45 
GeneralRe: Inter Process Communication Pin
gek_at13-May-04 8:18
gek_at13-May-04 8:18 
Questionhow do I marshal lpvoid pointer in a funcion? Pin
Paolo Ponzano13-May-04 2:24
Paolo Ponzano13-May-04 2:24 
AnswerRe: how do I marshal lpvoid pointer in a funcion? Pin
Heath Stewart13-May-04 3:29
protectorHeath Stewart13-May-04 3:29 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Paolo Ponzano13-May-04 4:40
Paolo Ponzano13-May-04 4:40 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Heath Stewart13-May-04 5:04
protectorHeath Stewart13-May-04 5:04 
You can't just cast a byte[] to IntPtr. You have to allocate the memory to pass to Toolhelp32ReadProcessMemory. Since Marshal.AllocHGlobal isn't available on the .NET CF, you have to do it like so:
// No need to allocate more bytes than you plan on reading
byte[] databuffer = new byte[100];
// Pin the object in memory so the GC doesn't move it
GCHandle handle = GCHandle.Alloc(databuffer);
// Get the pointer
IntPtr ptr = handle.AddrOfPinnedObject();
// Call your method
uint bytesread; // defaults to 0, and no need to cast like you did
Toolhelp32ReadProcessMemory(p.Handle, b.BaseAddress, ptr, 100, bytesread);
// Free the GCHandle and your databuffer now contains the data.
handle.Free();


 

Microsoft MVP, Visual C#
My Articles
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Paolo Ponzano13-May-04 5:27
Paolo Ponzano13-May-04 5:27 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Heath Stewart13-May-04 6:21
protectorHeath Stewart13-May-04 6:21 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Paolo Ponzano13-May-04 7:20
Paolo Ponzano13-May-04 7:20 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Heath Stewart13-May-04 9:37
protectorHeath Stewart13-May-04 9:37 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Paolo Ponzano13-May-04 11:43
Paolo Ponzano13-May-04 11:43 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Heath Stewart13-May-04 12:36
protectorHeath Stewart13-May-04 12:36 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Paolo Ponzano13-May-04 20:18
Paolo Ponzano13-May-04 20:18 
GeneralRe: how do I marshal lpvoid pointer in a funcion? Pin
Heath Stewart14-May-04 2:16
protectorHeath Stewart14-May-04 2:16 
GeneralUserControl and how to add controls to it Pin
Boaz V13-May-04 1:24
Boaz V13-May-04 1:24 
GeneralRe: UserControl and how to add controls to it Pin
Boaz V13-May-04 1:34
Boaz V13-May-04 1:34 
GeneralRe: UserControl and how to add controls to it Pin
Boaz V13-May-04 2:09
Boaz V13-May-04 2:09 
GeneralRe: UserControl and how to add controls to it Pin
sreejith ss nair13-May-04 2:50
sreejith ss nair13-May-04 2:50 
GeneralRe: UserControl and how to add controls to it Pin
Heath Stewart13-May-04 3:38
protectorHeath Stewart13-May-04 3:38 
GeneralRe: UserControl and how to add controls to it Pin
Boaz V13-May-04 3:48
Boaz V13-May-04 3:48 
GeneralCreating Installation Package for a C# Application with web reference Pin
koosala13-May-04 1:22
koosala13-May-04 1:22 
GeneralRe: Creating Installation Package for a C# Application with web reference Pin
Aryadip13-May-04 1:49
Aryadip13-May-04 1:49 
GeneralRe: Creating Installation Package for a C# Application with web reference Pin
koosala14-May-04 0:31
koosala14-May-04 0:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.