unmanaged

Debugging MMC (Unmanaged c++)?

I work on a legacy MMC application and one thing I have noticed is that once in awhile when closing the MMC, an error will be reported. "MMC has detected an error in a snap-in. It is recommended that you shut down and restart MMC". How can I debug this? The error is not displayd until you close the console and if you try to attach a de...

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

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 ...

Debugger Visualizer for non-managed C++ code?

Hi - Does anyone know of a C++ IDE or debugger that's supports debugger visualizers for unmanaged C++ code? The problem is that Visual Studio's debugger visaulizer supports only managed C++. Thanks, Olumide PS: I'm still open to using VS if I can find a technique for making the visualizer work with unmanaged C++. ...

How to prevent access violation on unmanaged dll call?

We have inherited a legacy system for reading to and from meter guns. This system was originally build on XP with .Net 1.1 (VS2003?). Having recompiled it on VS2008 with .net 3.5 we get an access violation when calling the dll (dll not touched). The original program (using basically the same code) is running fine on our production machin...

How is a securestring marshalled to unmanaged code?

What prompted this question: I'm trying to change the account under which a windows service runs. I decided to use the win32 api rather than WMI and started looking at ChangeServiceConfig. I thought I could simply use the SecureString type in the unmanaged method signature and it would work fine. Hmmm, not quite. This made me wonder,...

Which managed classes in .NET Framework allocate (or use) unmanaged memory?

Is there a known (documented) set of .NET types that allocate memory in the unmanaged portion of the process' memory? For example, Microsoft documents that the WPF infrastructure allocated unmanaged memory for its retained rendering model in order to optimize performance. Are there other such portions of the .NET framework that utilize ...

Stackoverflow calling ManagementScope.Connect();

Error im getting: An unhandled exception of type 'System.StackOverflowException' occurred in System.Management.dll My callstack: [Managed to Native Transition] System.Management.dll!System.Management.ManagementScope.InitializeGuts(object o) + 0x1a3 bytes System.Management.dll!System.Management.ManagementScope.Initiali...

Avoid loading .Net Dlls in a C++/CLI project?

I have a project written in C++/CLI. Some of the types there are in managed code, and some are in completely native code. Let's say I have the produced DLL on a machine that dosen't have any version of the .Net framework installed, is there a way that another, native application will link with my "mixed-mode" Dll and use only the native ...

how to run some code in memory?

I have a compiler which compiles assembly language to machine language (in memory). My project is in c# .net. Is there any way to run the memory on a thread? How can DEP prevent it? byte[] a: 01010101 10111010 00111010 10101011 ... ...

Assembly Manifest loading error (.NET and C++ dlls)

My application (pure DotNET 2.0) is referencing another pure DotNET 2.0 dll which is PInvoking into an unmanaged (C++ 2005) dll. On some computers this works fine, on others there is a consistent error message: Could not load file or assembly 'C:\Program Files\Rhinoceros 4.0\Plug-ins\Grasshopper\rhcommon_c.dll' or one of its dependenci...

System Wide Shell Hook from .NET using Unmanaged DLL

Hello everyone, I have used the code supplied in the following CodeProject article in the past with success, but it only seems to partially work on Vista/7 (I'm guessing because of UAC). It works for the current thread, but it doesn't pick up system wide activity. I've tried adding requireAdministrator in the manifests and signing both ...

Reading from an unmanaged stream - unsafe code, IntPtr

The following is exposed in the Firefox (Gecko) 3.5 code: [Guid("fa9c7f6c-61b3-11d4-9877-00c04fa0cf4a"), ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface nsIInputStream { void Close(); int Available(); int Read(IntPtr aBuf, uint aCount); int ReadSegments(IntPtr aWriter, IntPtr aClosure, uint aCount); bool I...

How to advance the wallpaper slideshow on windows vista/7 programatically?

I readed on a forum that the "Next Desktop Background" command in Windows Aero Slideshow feature calls the stobject.dll file. So I runned the dumpbin to check wheter I could se an exported method to call: Microsoft Visual Studio 9.0\VC\bin\dumpbin.exe /EXPORTS Windows\System32\stobject.dll Microsoft (R) COFF/PE Dumper Version 9.00....

Need a good book(s) and information about working with unmanaged code and COM with .Net

I have been working with .Net since VS2002 and since then any time that I had to work with COM or unmanaged code has been a pain. I've succeeded doing what was expected but almost always doing a trial-error procedure. I've had enough of this and I want to know what's going on at the back room and understand how those things work. As us...

How to use managed code from unmanaged code?

How do I call a .NET code from native C++ (unmanaged code)? I want to expose .NET code to my unmanaged (C++) application and then use them. More specifically, I want to call C# from native C++ :). I know there are many ways but can you tell me the pros and cons of each? By the way, I don't want to use COM so what are the options now? I...

C# call to unmanaged C++ returning string of squares symbols

I have some C# code calling into an unmanaged C++ DLL. The method I am calling is intended to accept a string as a ref. To handle this I pass in a StringBuilder, otherwise there is a StackOverflowException. This is working fine, but on some calls the string that comes back from the unmanaged code is a jumbled string like this: øŸE˜.,Ê...

What is the difference between a delegate instance and a method pointer?

I thought that a delegate instance was interchangeable with a function instance. Take the following code: delegate int AddDelegate(int a, int b); AddDelegate DelegateInstance; public void DoStuff() { //I can call this without a delegate "instance": MethodThatTakesAdd(Add); //I can also call it WITH a delegate "instance" ...

Is Winforms accessible from unmanaged C++?

Some classic Windows/C++ applications can't easily be moved to managed C++.net, due to use of external libraries. Is it feasible to use newer GUI libraries like winforms (or even WPF) with such applications, 'dropping in' new controls to replace stale-looking MFC? Or is it not really worth it, and would take a lot of time? ...

Calling unmanaged function from C#: should I pass StringBuilder or use unsafe code?

I've got a C# program that needs to pass a char buffer to an unmanaged function. I've found two ways that seem to work reliably, but I'm not sure which I should choose. Here's the unmanaged function's signature. extern "C" __declspec(dllexport) int getNextResponse(char *buffer); The first option is to define the buffer as a StringBui...

Sending Byte[][] inbetween C++ unmanaged dll and C# managed dll.

I have an unmanaged C++ dll that exports the following methods: ERASURE_API void encode(unsigned char ** inp, unsigned char ** outp, unsigned int *block_nums, size_t num_block_nums, size_t sz); ERASURE_API void decode(unsigned char ** inp, unsigned char ** outp, unsigned int * index, size_t sz); Size of inp and outp can be...