c# - Pinning an updateble struct before passing to unmanaged code? -


I am using some older APIs and need to pass an ectopic driven code to an indicator of a structure.

In other words, when I give the structure indicator for unmanaged code, the unmanaged code gives copies to the indicator and gives it back immediately. Unmanaged code can use that structure in the background, in the second thread. I have no control over the unmanaged code that runs in another thread and neither threads.

The specified {} statement can not be used for pinning because it is not designed for async unmanaged pinning.

GCendal can only reference the reference, so the structure must be boxed to use GCindal. I tried it and it works. The main problem with this is that you can not update the Managed Code structure to update any structure, first we need to unbox it, then update, again box , But ... oh ... the box again?!? This means that the previous indicator in memory still indicates the old non-up-to-date strat, and is another indicator of the new structure, and that means I have to pass new pointers in unmanaged code ... my Disable case in

How can I pin a strip in memory without any definite {} statement, and so that I can update it with managed code without any changes Can i

Thank you.

Edit:

Just thought ... There is a structure in which there is a way to pin the original object, and then get the < Strong> struct

Unsecured code is an option?

// Assign to the missed memory Foo * foo = (Foo *) Marshall. AllocHGlobal (sizeof (Foo)); // start foo-> Bar = 0; // Unmoded function, which is the Foo Unespanable Modes. Remembers Bir (AF); Console.WriteLine (foo- & gt; Bar); // Update format foo- & gt; Bar = 10; UnsafeNativeMethods.Qux () uses the missed foo / / unmanaged function which invokes; Console.WriteLine (foo- & gt; Bar); // free unmanaged memory Marshal.FreeHGlobal ((IntPtr) foo);

It compiles and throws an exception, but I do not have an unmanaged function in my hand to test.

From:

When LocalAlloc calls AllocHGlobal, it passes an LMEM_FIXED flag, allocated memory is locked. Also, the allocated memory is not zero-loaded.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -