c# - How to know pointer to structure by it's array pointer? -


i have structure:

public struct mystruct {    public int a;    public int b;    public byte[] mass; }   

i need: pass poiner "mass" array c++ unmanaged function. , after done work return me pointer "mass".

so have list of mystruct. , need know mystruct in list contains returned "mass"(wich pointer have). if know pointer "mass" can reduce pointer 8 bytes , take pointer mystruct?

how :

1.get intptr "mass" array?

2.get intptr mystruct structure?

3.get mystruct intptr?

but, not using copy procedure, marshal.copy...

or there better way need ? can use pointers in c++ or intptr enought, , how can that?

assuming memory array allocated managed code:

when pass array unmanaged function via p/invoke, default array pinned in memory marshaller memory used array not have copied.

you should not need use intptr @ - need declare p/invoke accepting array parameter.

however, things different if unmanaged code allocating memory returned managed code; things more difficult.

assuming that's not case, if can show "c" function declaration might able come p/invoke declaration.

(i have feeling situation may bit more complicated though...)

some useful links you:

http://msdn.microsoft.com/en-us/library/z6cfh6e6%28v=vs.80%29.aspx

http://msdn.microsoft.com/en-us/library/zah6xy75.aspx

how can pass pointer array using p/invoke in c#?

and lower level information optimizations marshaller makes when calling unmanaged code , passing arrays. essentially, if can doesn't make copy of data @ all:

http://msdn.microsoft.com/en-us/library/23acw07k%28v=vs.80%29.aspx


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -