unmanaged

Passing c# string to unmanaged c++ DLL

て烟熏妆下的殇ゞ 提交于 2019-12-05 00:49:19
问题 I have a simple application that loads an unmanaged dll and passes a few string values to it from C#. But in the C++ dll application, I receive an exception :: Tried to access a read/write protected memory. My DLL Import looks like this: [DllImport("X.dll", CallingConvention = CallingConvention.Cdecl) ] public static extern int DumpToDBLogFile([MarshalAs(UnmanagedType.I4)]int loggingLevel, [MarshalAs(UnmanagedType.I4)]int jobId, int threadId, [MarshalAs(UnmanagedType.LPStr)]string procName,

What are the implications of using unsafe code

ぃ、小莉子 提交于 2019-12-04 23:51:36
Aside from the fact that the code itself can access memory directly. What are the other implications of using the "/unsafe" compiler flag and the "fixed" keyword? Are there any knock on effects related to code signing and deployment of my .exe (my app is desktop only)? (This isn't about whether or not I should be doing this, the why is covered in my question here ) Unsafe code is not verifiable, so you have to be aware of that. In a Full Trust environment, that's not a big deal, but if you have other environments which have a more restricted permission set, then this might impact you there.

how to track dlls being loaded into a process?

荒凉一梦 提交于 2019-12-04 21:57:10
I am looking for a tool to trace the dlls being loaded into a process on windows. The app i have is loading managed and unmanaged dlls, but not sure if the managed ones are loading the unmaanged ones. Process Explorer and File Explorer doesn't seem to help much. Any thoughts?? thanks!! Procmon is the best tool I know of, though its level of detail can be overwhelming. As of version 2.0, Dependency Walker can do dynamic application profiling . This allows you to see what modules a running application is loading, as opposed to just seeing what is in the static import tables. 来源: https:/

Reference an unmanaged C++ DLL from Managed C++

霸气de小男生 提交于 2019-12-04 17:18:03
This question follows from my previous question: Create DLL from unmanaged C++ , but you would not have to read it to understand this new question. I now have a DLL that contains unmanaged C++ code consisting of a few functions, of which I only export one for outside use. Next, I need to use this DLL in a Managed C++ project (built with Common Language Runtime support). So far, I have added a reference to the existing unmanaged project's header file by setting the Additional Include Directories in Visual Studio 2010. If I now try to add a reference to the DLL file: MyManagedProject >

mono and unmanaged code in ubuntu

大憨熊 提交于 2019-12-04 13:11:07
I'm using Mono 2.10 running on Ubuntu 12 x64. Now I need to know how to use unmanaged code. [DllImport("libc.so")] public static extern int getpid (); And, in the next step I have: getpid(); and I recieve this errorL $ MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono libc_test.exe Mono: DllImport attempting to load: 'libc.so'. Mono: DllImport loading library: '/home/ibaranov/Documents/MONO/libc_test/libc_test/bin/Debug/libc.so'. Mono: DllImport error loading library '/home/ibaranov/Documents/MONO/libc_test/libc_test/bin/Debug/libc.so: cannot open shared object file: No such file or directory'.

calling unmanaged function char returns char *

守給你的承諾、 提交于 2019-12-04 13:03:24
I have a function in unmanaged C/C++ code (dll) that returns a structure containing a char array. I created C# struct to receive this return value uppon calling the function. And uppon calling this function i get 'System.Runtime.InteropServices.MarshalDirectiveException' This is C declaration: typedef struct T_SAMPLE_STRUCT { int num; char text[20]; } SAMPLE_STRUCT; SAMPLE_STRUCT sampleFunction( SAMPLE_STRUCT ss ); This is C# declaration: struct SAMPLE_STRUCT { public int num; public string text; } class Dllwrapper { [DllImport("samplecdll.dll")] public static extern SAMPLE_STRUCT

Best method of calling managed code(c#) from unmanaged C++

佐手、 提交于 2019-12-04 11:01:21
We have developed a s/w architecture consisting of set of objects developed in C#. They make extensive use of events to notify the client of changes in status, etc. The intention originally was to allow legacy code to use these managed objects through COM interop services. That was easy to write in the design specification but, I'm seeing that actually implementing it is more problematic. I've searched for many hours looking for a good sample of event handling using this method. Before we march down that path, I want to make sure that COM interop is the best way to allow legacy code to call

Performance of Managed C++ Vs UnManaged/native C++

﹥>﹥吖頭↗ 提交于 2019-12-04 09:25:30
问题 I am writing a very high performance application that handles and processes hundreds of events every millisecond. Is Unmanaged C++ faster than managed c++? and why? Managed C++ deals with CLR instead of OS and CLR takes care of memory management, which simplifies the code and is probably also more efficient than code written by "a programmer" in unmanaged C++? or there is some other reason? When using managed, how can one then avoid dynamic memory allocation, which causes a performance hit,

Passing Unmanaged pointers in C++/CLI

陌路散爱 提交于 2019-12-04 08:30:25
I'm creating a C++/CLI wrapper DLL that depends on numerous C++ static libraries. Some of the function calls expect unmanaged pointers to be passed in. How do i pass them properly? Also, other functions expect a "this pointer" to be passed in as a void*. What's the right way to pass "this"? Here's my class definition... public ref class RTPClient { public: RTPClient(); ~RTPClient(); bool Connect(); void Disconnect(); private: CIsmaClient* mClient; }; Here's my usage where the pointers in question are used... RTPClient::RTPClient(): mClient(NULL) { CIsmaClient::Create(&mClient, NULL,

Implement a C# DLL COM File In Unmanaged C++ Program

柔情痞子 提交于 2019-12-04 05:12:07
问题 Here is my other question that led into this one as reference also: How to call managed C++ methods from Un-managed C++ I have successfully created a C# COM File. Now I need a simple explanation on how to implement it in unmanaged C++. I am following this example but the c++ part is weak. http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C Here is my COM file using System; using System.Runtime.InteropServices; using System.Collections.Generic; using System.Linq; using System