unmanaged

Using WinDbg/SOS to debug managed->native callstack. I get “Failed to request ThreadStore”

对着背影说爱祢 提交于 2019-12-18 09:23:34
问题 MyManagedFunc in managed.exe calls into MyUnmanagedFunc() in unmanaged.dll. I produce a minidump in unmanaged.dll using Win32. SetUnhandledExceptionFilter. I can see MyUnmanagedFunc in the callstack, but nothing usefull in the managed side. I'm supposed to be able to use WinDbg and SOS.dll to see the managed calls, right? Below is my WinDbg session. What am I doing wrong? Executable search path is: Windows XP Version 2600 (Service Pack 3) MP (4 procs) Free x86 compatible Product: WinNt, suite

How do I import and call unmanaged C dll with ANSI C string “char *” pointer string from VB.NET?

不打扰是莪最后的温柔 提交于 2019-12-18 09:08:48
问题 I have written my own function, which in C would be declared like this, using standard Win32 calling conventions: int Thing( char * command, char * buffer, int * BufSize); I have the following amount of Visual Basic code figured out, which should import the DLL file and call this function, wrapping it up to make it easy to call Thing("CommandHere",GetDataBackHere). UPDATE: This code is now a working solution, as shown here: Imports Microsoft.VisualBasic Imports System.Runtime.InteropServices

Pass a function pointer from C++ to be called by C# - Arguments of functions include a wide char string (LPCWSTR)

和自甴很熟 提交于 2019-12-18 06:58:02
问题 I am writing a C# library to be used by native C++ application. I am using C++/CLI as the Interoperability mechanisim. I require to pass a callback function from C++ to C# (using C++/CLI as the intermediate layer). C# library needs to call the C++ function with a zero terminated string of wide characters; i.e. the prototype of the callback function is Func(LPCWSTR pszString); There are other parameters but they are immaterial for this discussion. I searched net and found Marshal

Read cell Items from data grid in SysListView32 of another application using C#

孤街醉人 提交于 2019-12-18 05:18:05
问题 I am trying to read data grid items in SysListView32 of another process using C# .net ui-automation and winapi C# code using ui-automation http://pastebin.com/6x7rXMiW C# code using winapi http://pastebin.com/61RjXZuK using this code you just have to place your Mouse pointer on SysListView32 on screen and press Enter. now both code returns empty on the cell item which have following properties pastebin.com/Rw9FGkYC but both code works on following properties pastebin.com/L51T4PLu the only

How can I send a managed object to native function to use it?

馋奶兔 提交于 2019-12-18 04:23:34
问题 How can I send a managed object to native function to use it? void managed_function() { Object^ obj = gcnew Object(); void* ptr = obj ??? // How to convert Managed object to void*? unmanaged_function(ptr); } // The parameter type should be void* and I can not change the type. // This function is native but it uses managed object. Because type of ptr could not be // Object^ I called it "Unmanaged Function". void unmanaged_function(void* ptr) { Object^ obj = ptr ??? // How to convert void* to

Unmanaged Exports: Cannot compile assembly

こ雲淡風輕ζ 提交于 2019-12-18 03:44:38
问题 I want to create a .NET assembly that can be accessed from unmanaged code (Delphi 5). I have found Unmanaged Exports and followed the steps there but I am unable to successfuly compile even the basic example: using RGiesecke.DllExport; namespace DelphiNET { public class Class1 { [DllExport("add")] public static int Add(int left, int right) { return left + right; } } } DelphiNET.csproj project file: ... <ItemGroup> <Compile Include="Class1.cs" /> <Compile Include="DllExport\DllExportAttribute

Unmanaged Exports: Cannot compile assembly

Deadly 提交于 2019-12-18 03:44:21
问题 I want to create a .NET assembly that can be accessed from unmanaged code (Delphi 5). I have found Unmanaged Exports and followed the steps there but I am unable to successfuly compile even the basic example: using RGiesecke.DllExport; namespace DelphiNET { public class Class1 { [DllExport("add")] public static int Add(int left, int right) { return left + right; } } } DelphiNET.csproj project file: ... <ItemGroup> <Compile Include="Class1.cs" /> <Compile Include="DllExport\DllExportAttribute

Marshal.AllocHGlobal VS Marshal.AllocCoTaskMem, Marshal.SizeOf VS sizeof()

馋奶兔 提交于 2019-12-17 23:10:36
问题 I have the following struct: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct WAVEHDR { internal IntPtr lpData; // pointer to locked data buffer internal uint dwBufferLength; // length of data buffer internal uint dwBytesRecorded; // used for input only internal IntPtr dwUser; // for client's use internal uint dwFlags; // assorted flags (see defines) internal uint dwLoops; // loop control counter internal IntPtr lpNext; // reserved for driver internal IntPtr

Managed C++ to form a bridge between c# and C++

不打扰是莪最后的温柔 提交于 2019-12-17 22:34:41
问题 I'm a bit rusty, actually really rusty with my C++. Haven't touched it since Freshman year of college so it's been a while. Anyway, I'm doing the reverse of what most people do. Calling C# code from C++. I've done some research online and it seems like I need to create some managed C++ to form a bridge. Use __declspec(dllexport) and then create a dll from that and use the whole thing as a wrapper. But my problem is - I'm really having a hard time finding examples. I found some basic stuff

Detecting memory leak in mixed environment(Managed-Unmanaged)

百般思念 提交于 2019-12-17 21:14:47
问题 I've an application written in VC++ MFC 6.0. Recently got upgraded to .NET 3.5 by compiling in vs2008 and added some WPF applications to it by using managed and unmanaged environment. Basically hosting WPF on win32 window. If I just open a WPF app window, memory keeps going up like 1KB/10 secs. I've tried using .NET Memory profiler & Ants memory profiler. But both are not helping me in detecting the leaks!! I've removed all the WPF controls from the hosted WPF application. It just contains a