unmanaged-memory

Marshal.StructureToPtr without boxing

旧城冷巷雨未停 提交于 2019-12-09 19:27:41
问题 Is there a way to marshal a structure (possibly stored in a TypedReference ) to unmanaged memory without actually boxing it? The type of the structure isn't known at runtime, so I can't use the generic overload of StructureToPtr (.NET 4.5.1). I can get a MethodInfo of the StructureToPtr overload, but there doesn't seem to be a way to invoke it passing a generic reference or a TypedReference . Edit: The generic StructureToPtr still boxes the structure, so trying to invoke it is useless. 回答1: I

Trouble with passing handle to managed object using PInvoke

大城市里の小女人 提交于 2019-12-08 06:39:30
I'm quite confused about how to pass handle to my managed object from .Net to unmanaged code. Now I'm developing kind of "driver" for Oracle Siebel CRM using C#. And how i faced with problem about how to pass handle to Driver API have such method: ISCAPI ISC_RESULT CreateISCDriverInstance /* in */(const ISC_STRING mediaTypeStr, /* in */ const ISC_STRING languageCode, /* in */ const ISC_STRING connectString, /* in */ const struct ISC_KVParamList* datasetParams, /* out */ ISC_DRIVER_HANDLE* handle); And i have the problem with last parameter ISC_DRIVER_HANDLE* handle. I want to say that it may

Trouble with passing handle to managed object using PInvoke

假如想象 提交于 2019-12-08 04:52:43
问题 I'm quite confused about how to pass handle to my managed object from .Net to unmanaged code. Now I'm developing kind of "driver" for Oracle Siebel CRM using C#. And how i faced with problem about how to pass handle to Driver API have such method: ISCAPI ISC_RESULT CreateISCDriverInstance /* in */(const ISC_STRING mediaTypeStr, /* in */ const ISC_STRING languageCode, /* in */ const ISC_STRING connectString, /* in */ const struct ISC_KVParamList* datasetParams, /* out */ ISC_DRIVER_HANDLE*

Marshal.StructureToPtr without boxing

一个人想着一个人 提交于 2019-12-04 17:19:37
Is there a way to marshal a structure (possibly stored in a TypedReference ) to unmanaged memory without actually boxing it? The type of the structure isn't known at runtime, so I can't use the generic overload of StructureToPtr (.NET 4.5.1). I can get a MethodInfo of the StructureToPtr overload, but there doesn't seem to be a way to invoke it passing a generic reference or a TypedReference . Edit: The generic StructureToPtr still boxes the structure, so trying to invoke it is useless. I've finally found the answer, the SafeBuffer class. It contains exactly what I wanted - structure with

f# NativePtr.stackalloc in Struct Constructor

橙三吉。 提交于 2019-12-04 04:19:13
问题 I'm doing some F# performance testing and am trying to create an array on the stack rather then the heap (value vs reference type). I am using NativePtr.stackalloc to allocate memory on the stack. Getting an error in the first constructor below. type StackArray<'T when 'T : unmanaged> = struct val pointer: nativeptr<'T> new(x) = { pointer = NativePtr.stackalloc x} new(pointer) = { pointer = pointer} end // This give a System.TypeInitializationException with internal System

Read and write directly to Unlocked Bitmap unmanaged memory (Scan0)

女生的网名这么多〃 提交于 2019-11-30 20:39:09
Is that ok to Write and Read directly from a unlocked Bitmap unmanaged memory? Can I keep using the BitmapData after I UnlockBits of the Bitmap? I did a test app where I can read the pixel of the Bitmap of a PictureBox at mouse position while another thread is writing pixels to the same Bitmap. EDIT 1: As Boing have pointed out in his answer: "Scan0 does not point to the actual pixel data of the Bitmap object; rather, it points to a temporary buffer that represents a portion of the pixel data in the Bitmap object." from MSDN . But once I get the Scan0, I'm able to read/write to the Bitmap

Read and write directly to Unlocked Bitmap unmanaged memory (Scan0)

不打扰是莪最后的温柔 提交于 2019-11-30 04:56:32
问题 Is that ok to Write and Read directly from a unlocked Bitmap unmanaged memory? Can I keep using the BitmapData after I UnlockBits of the Bitmap? I did a test app where I can read the pixel of the Bitmap of a PictureBox at mouse position while another thread is writing pixels to the same Bitmap. EDIT 1: As Boing have pointed out in his answer: "Scan0 does not point to the actual pixel data of the Bitmap object; rather, it points to a temporary buffer that represents a portion of the pixel data