unmanaged

How do I strongly name an Unmanaged C++ Dll?

梦想与她 提交于 2019-12-05 11:02:02
I'm working on a C# application which uses the EasyHook library for DLL Injection. EasyHook requires that any application using it be strongly named. In order to strongly name the application I need to make sure that all the libraries I use are strongly named as well. This is easy to do for all of my managed libraries, but I also have an unmanaged c++ library which I need to strongly name. After some searching I can't seem to find a way to sign my unmanaged dll, even with the source code. Can this be done, and if so what do I need to do? Thanks for any suggestions or assistance! I assume that

Create DLL from unmanaged C++

心不动则不痛 提交于 2019-12-05 10:31:55
I currently have a console application written in unmanaged C++, the source code consists of an entry-point main and some other functions. I need to create a DLL from this code so that I can use it from other projects, specifically from managed C++. (Another question: would I have to write a wrapper class for this purpose?) As I know next to nothing of managed/unmanaged C++ and creating DLLs, I followed this tutorial and managed to get a simple Hello World DLL up and running by using only VS2010 (no CMake). However, this project of mine has a lot of dependencies (e.g. Point Cloud Library ),

Unmanaged memory not showing up in task manager

和自甴很熟 提交于 2019-12-05 09:43:01
I wrote the following test (actually used in a wider context) IntPtr x = Marshal.AllocHGlobal(100000000); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); Marshal.FreeHGlobal(x); Console.ReadKey(true); Why doesn't the task manager show any sign of the allocated 100 megabytes before the first key press? If this is by design, how else can I test the consumption of unmanaged heap memory? You are getting some insight in how your operating system works. This behavior is not specific to Marshal.AllocHGlobal(), try this code for example: static void Main(string[] args) { var

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

人走茶凉 提交于 2019-12-05 08:04:09
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 StringBuilder, as follows. //at class level... [DllImport("mydll.dll")] static extern int getNextResponse(StringBuilder buffer); //in main method body... StringBuilder sb = new StringBuilder(" ", 65536); int rc = getNextResponse(sb); This is simple, and it works, and I

HOWTO: Call Managed C# Interface From Unmanaged C++ On WindowsCE Compact Framework

假如想象 提交于 2019-12-05 06:37:56
I have extensive unmanaged Windows CE 5 C++ code that provides a UI that I want to use in a new product by combining it with a large amount of newer business and communications logic written in managed C# on Windows CE 6 and the Compact Framework. The UI may know about the business logic, but I want the business logic ignorant of the UI such that I can later replace it with a managed version, or any other UI that I choose as a front-end. I found an article that describes how to use COM as the bridge in the Windows world, but I'm having difficulty applying it in the .NET CF under WinCE. In the

How do I combine an unmanaged dll and a managed assembly into one file?

戏子无情 提交于 2019-12-05 04:16:09
SQLite from PHX Software has combined a managed assembly (System.Data.SQLite) with an unmanaged dll (the SQLite 32- or 64-bit dll) into one file, and managed to link them together. How do I do this? Do I need to embed the managed assembly into the unmanaged dll, or vice versa? ie. my questions are: In which order do I need to do this? What tools or knowledge do I need in order to do this? How (if different) do I link to the exported functions from the unmanaged dll in my managed code? The reason I ask this is that I want to build a managed zLib wrapper. I know there is managed classes in .NET

Passing struct from unmanaged C++ to C#

时光总嘲笑我的痴心妄想 提交于 2019-12-05 03:49:46
Note: The final working solution is after the edit! I hope someone can help me with a problem I've been trying to solve for the last few days. I am trying to pass a struct from a unmanaged C++ DLL to a C# script. This is what I have so far: C++ EXPORT_API uchar *detectMarkers(...) { struct markerStruct { int id; } MarkerInfo; uchar *bytePtr = (uchar*) &MarkerInfo; ... MarkerInfo.id = 3; return bytePtr; } C# [DllImport ("UnmanagedDll")] public static extern byte[] detectMarkers(...); ... [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 1)] public struct markerStruct { [MarshalAs

Marshal.StructureToPtr fails in module ntdll.dll

。_饼干妹妹 提交于 2019-12-05 03:48:44
问题 I'll start with a bit of history : The issue I'm facing currently appeared suddenly without any changes to the code. Then disappeared in the same way after 3 days. Now it came back in a week and doesn't want to go away =). I have code that works with printer - settings it's printer preferences to print documents in the specified way. I use local printer which points to TCP address of the network printer (it is common approach for such tasks as I know). Here follows the code I use to load

What is an un/managed DLL? What is un/managed code? [duplicate]

我的未来我决定 提交于 2019-12-05 02:35:08
This question already has answers here : What is managed or unmanaged code in programming? (13 answers) Closed 6 years ago . Could someone please explain to me what an un/managed DLL is? And what is un/managed code? Sachin Shanbhag You will get a fair idea on managed and unmanaged code in following article - http://www.developer.com/net/cplus/article.php/2197621/Managed-Unmanaged-Native-What-Kind-of-Code-Is-This.htm Unmanged code will be compiled to machine language to run directly on the hardware. Managed code will be compiled to a virtual machine called CLR (Common Language Runtime), and

Call C++ functions from C#/.NET

爱⌒轻易说出口 提交于 2019-12-05 02:33:39
问题 I have a solution which has a C++ project and a C# project. The C++ project defines a class, which I want to instantiate in C# and call its member functions. So far I managed to instantiate the class: CFoo Bar = new CFoo(); But when I try to call a function on it, the compiler says, it is not available. Also, when I inspect the object in the debugger, no members are shown. What am I missing here? 回答1: You need to declare the class in C++/CLI as a ref class . (Note that we're talking about C++