loadlibrary

LoadLibraryW() failing to load DLL in System32

≡放荡痞女 提交于 2019-12-10 20:26:22
问题 I'm trying to load a DLL that was installed with a printer driver in the C:\Windows\System32\ folder with the following code: LoadLibraryW(L"C:\\Windows\\System32\\MagAPI.dll"); GetLastError() is reporting that "The specified module could not be found". If I move the DLL outside of the System32 folder (C:\SomeFolder\MagAPI.dll for example) then it will load fine so it doesn't seem like it's a problem with the DLL itself. Is there some weird Windows security feature that might be blocking my

Address range of a dynamically loaded library under Windows

∥☆過路亽.° 提交于 2019-12-10 14:38:04
问题 I have a working program that loads plugins with LoadLibrary. New requirement: at some point in the code, I'm given a pointer, and I need to test whether this pointer points into the code or static data of a plugin. bool is_pointer_into_plugin(void *p, HMODULE h); Equivalently, I need to retrieve the plugin into which a pointer points, if any. I also need to know if the pointer points into the main program's code or static data (and ideally, distinguish between read-only and read-write areas)

Calling C++ DLL from C++ works, but not from C#

a 夏天 提交于 2019-12-10 12:47:48
问题 I have a DLL called tccdvc.dll which is part of an SDK available here: http://www.commell.com.tw/Download/Driver/Industrial%20Peripheral/Driver/MPX-885/MPX-885%20SDK%20(1.2)/SetupCOMMELL%20MPX-885_20100627.rar The DLL was written in C++ and examining the DLL shows it was linked with linker version 6.0, so I assume it was written with VC++ 6.0. The DLL does not come with source code, only a .lib file and a .h file. All exported functions are declared as extern "C" (so no C++ name mangling) and

Create a valid shared library in C

倖福魔咒の 提交于 2019-12-08 07:20:49
问题 I'm doing some test to learn how to create shared library. The template for shared libraries in Code::Blocks is this library.c // The functions contained in this file are pretty dummy // and are included only as a placeholder. Nevertheless, // they *will* get included in the shared library if you // don't remove them :) // // Obviously, you 'll have to write yourself the super-duper // functions to include in the resulting library... // Also, it's not necessary to write every function in this

LoadLibrary doesn't work when compiled to AnyCpu

和自甴很熟 提交于 2019-12-08 05:57:57
问题 I am developing a c# application that extract a cab file from a setup package. to do that I am using LoadLibrary. this is the pinvoke C# signature. [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)] internal static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)]string lpFileName); The above code works fine when compiling the project to x86, but if I compile it to anycpu it fails, and the last win32 error is: "%1 is not a valid Win32 application" I tried to use

Can .NET PInvoke dynamically load a native dll from a user specified directory?

爷,独闯天下 提交于 2019-12-08 03:00:32
问题 I have a .NET application and need to load a native library whose location is specified by the user. PInvoke looks like it'll only load from the global search paths (or a path specified at compile time?). Would the best method be to create a C++/CLI assembly which calls LoadLibrary at runtime? Would C++/CLI be simpler than C# PInvoking LoadLibrary? 回答1: If you already have a C#/VB.Net project it would be much simpler to just PInvoke LoadLibrary in order to get a DLL to load. It takes one

visual studio Dll and Matlab

北慕城南 提交于 2019-12-08 01:32:24
问题 I am trying to build a dll with visual studio so I can use it in matlab ... I tried thausand codes with no solution !!! I am working on matlab 2013(32and64) and VS2010 ! I tried for example to write the code this way ... //The header #ifndef SIMPLEH_H #define SIMPLEH_H #ifdef __cplusplus extern "C" { int sq(int x); #endif #ifdef __cplusplus } #endif #endif //the Func(example) #include "SimpleH.h" int sq(int x) { return (x*x); } visual studio Build it and make th dll file but matlab always

Unmanaged Exports with Arrays

為{幸葍}努か 提交于 2019-12-08 00:55:28
问题 I'm using RGiesecke DLLExport library to produce a C# DLL that can be dynamically loaded from Delphi. I have a method like: [DllExport("GetVals", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)] static void GetVals([In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] valueList, int len) { valueList = new int[3]; int[] arrList = new int[] { 1, 2, 3 }; int idx = 0; foreach (int s in arrList) { valueList[idx] = s; idx++; } } I want to be able to

Create a valid shared library in C

拈花ヽ惹草 提交于 2019-12-07 09:12:34
I'm doing some test to learn how to create shared library. The template for shared libraries in Code::Blocks is this library.c // The functions contained in this file are pretty dummy // and are included only as a placeholder. Nevertheless, // they *will* get included in the shared library if you // don't remove them :) // // Obviously, you 'll have to write yourself the super-duper // functions to include in the resulting library... // Also, it's not necessary to write every function in this file. // Feel free to add more files in this project. They will be // included in the resulting

C++/CLI Explicitly Load Managed DLL at runtime (the equivalent of LoadLibrary for Unmanaged)

只谈情不闲聊 提交于 2019-12-07 05:28:33
问题 Problem 1: Is there a way to explicitly load a library at runtime instead of at compile time in C++/CLI. Currently I am using the .NET "Add Reference" at compile time. I would like to explicitly load a managed dll. Is there the .NET equivalent of LoadLibrary? Update: Thanks to Randolpho Assembly::LoadFrom example from MSDN Assembly^ SampleAssembly; SampleAssembly = Assembly::LoadFrom( "c:\\Sample.Assembly.dll" ); // Obtain a reference to a method known to exist in assembly. MethodInfo^ Method