unmanaged-memory

C# calling a DLL function that returns a pointer to pointer to an array of structures

陌路散爱 提交于 2021-01-28 03:30:56
问题 I have tried many different combinations of the various methods to marshal this call. This is a DLL that returns a pointer to a pointer to an array of structures. The types like debugPort are actually enums. /** * \struct debugConnectParameters * \brief Get device characterization and specify connection parameters through ST-LINK interface. */ typedef struct debugConnectParameters { debugPort dbgPort; /**< Select the type of debug interface #debugPort. */ int index; /**< Select one of the

C# calling a DLL function that returns a pointer to pointer to an array of structures

拈花ヽ惹草 提交于 2021-01-28 02:14:16
问题 I have tried many different combinations of the various methods to marshal this call. This is a DLL that returns a pointer to a pointer to an array of structures. The types like debugPort are actually enums. /** * \struct debugConnectParameters * \brief Get device characterization and specify connection parameters through ST-LINK interface. */ typedef struct debugConnectParameters { debugPort dbgPort; /**< Select the type of debug interface #debugPort. */ int index; /**< Select one of the

Unmanaged Memory Profiling for UWP applications?

大城市里の小女人 提交于 2020-08-10 20:11:05
问题 I have been on the search to find a tool or a technique or anything that could help me find which objects from my UWP application is allocating on unmanaged heap memory. I tried looking at WPR/WPA combination for tracing object. But, did not find anything useful there. (If you have any good links for UWP/WPF apps with this combo, please share) I installed Ant Memory profiler , but they do not seem to have any option for Windows Store apps anymore. I checked .NET memory profiler , when I try

How can I copy a array of strings into an unmanaged char double pointer?

↘锁芯ラ 提交于 2020-01-15 15:42:03
问题 I have a char** in a C struct which is allocated in the C code as a Nx128 matrix. In C# I have an array of strings and I want to copy this array to the char double pointer, without reallocating anything. I tried this: public void StringArrayToPtr(IntPtr ptr, string[] array) { for (int i = 0; i < array.Length; i++) { char[] chars = (array[i] + '\0').ToCharArray(); Marshal.Copy(chars, 0, IntPtr.Add(ptr, 128*i), chars.Length); } } But this doesn't work. Does somebody know how to perform such a

How can I copy a array of strings into an unmanaged char double pointer?

筅森魡賤 提交于 2020-01-15 15:39:38
问题 I have a char** in a C struct which is allocated in the C code as a Nx128 matrix. In C# I have an array of strings and I want to copy this array to the char double pointer, without reallocating anything. I tried this: public void StringArrayToPtr(IntPtr ptr, string[] array) { for (int i = 0; i < array.Length; i++) { char[] chars = (array[i] + '\0').ToCharArray(); Marshal.Copy(chars, 0, IntPtr.Add(ptr, 128*i), chars.Length); } } But this doesn't work. Does somebody know how to perform such a

Two Different GCHandle's refer to same array in memory

断了今生、忘了曾经 提交于 2019-12-25 12:45:28
问题 This is probably not a well-phrased question, because I am not sure what is happenning, so i don't know how to ask it pointedly. I am trying to learn, and i hope i can get some direction on this. Your patience with a neophyte is appreciated. I have a piece of code i am modifying. It displays an image. I want to modify the image, and display it in a different window. I copy the code that displays the image, do the modification, and it displays the modified image for both the original and

Passing objects between C# library and C++ (CLR)

对着背影说爱祢 提交于 2019-12-25 01:32:51
问题 How to pass objects from C# library to C++. I can call a function which returns void or int without any issue. Now consider the following function in C#, List<CSharpClass> CSharpFunction(string Input) where my C# class contains, public class CSharpClass { string mystring = string.Empty; byte[] bytearray = null; public byte[] bytearray { get { return bytearray ; } set { bytearray = value; } } public string mystring { get { return mystring ; } set { mystring = value; } } } Now, I want use this

WinDivert in C#

三世轮回 提交于 2019-12-23 03:31:17
问题 I want to call 5 WinDivert functions in a C# code, first reflex : PInvoke here are the signatures : internal enum WINDIVERT_LAYER { WINDIVERT_LAYER_NETWORK = 0, /* Network layer. */ WINDIVERT_LAYER_NETWORK_FORWARD = 1 /* Network layer (forwarded packets) */ } internal const UInt64 WINDIVERT_FLAG_SNIFF = 1; /* * typedef struct { UINT32 IfIdx; UINT32 SubIfIdx; UINT8 Direction; } WINDIVERT_ADDRESS, *PWINDIVERT_ADDRESS; * */ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] internal

Unmanaged memory in a .net 4 application pool

落爺英雄遲暮 提交于 2019-12-23 01:14:03
问题 I'm trying to track down the source of some unmanaged memory in a .net 4 application (this is curiosity...I don't have a major problem with it, I just want to know what it is) My application currently consists of 1 file: index.html - contains "hello world" From a memory profiler, I load up index.html and it's consuming very little (in fact, the profile hasn't kicked int) I then load up /fish (which doesn't exist) and now suddenly we're on a total of about 57MB usage, 54MB of which is

F# NativePtr.stackalloc Unexpected Stack Overflow

你离开我真会死。 提交于 2019-12-11 00:19:11
问题 Still doing my F# performance testing and trying to get stack based arrays working. For some more background see here: f# NativePtr.stackalloc in Struct Constructor. As I understand it, each function call should get its own frame in the stack. This memory is then freed upon return by moving the stack pointer back. However the below causes a stack overflow error - not sure why as the stackalloc is performed inside a function. Interestingly this only happens in Release mode, not Debug mode. I