Is there an open source library for calling Windows Native API - dll

I have an application that needs to call that native API (Nt*/Zw* function calls in ntdll.dll). Is there an open source library that would provide me with the datatype definitions, function prototypes, maybe even a C++ wrapper for loading and unloading the dll dynamically?

There is an open source project called NativeTest from FSLogix that will do exactly what you are looking for. You can find the information here https://nativetest.codeplex.com/releases/view/107604

Related

How can I decompile and/or view the mshtml.dll file?

So far I have tried ISpy and received "This file does not contain a managed assembly." I also tried PEBrowse but couldn't even open it without getting an error
mshtml.dll is the rendering core of Internet Explorer. It is written in native code, not .NET so therefore it cannot be decompiled as "managed assembly". It is "unmanaged" code.
If you are reverse engineering some module, you may treat the call to MSHTML a native call.

Get FileVersionInfo interop wrapped COM dll - need full path

I need to present an "About" style dialog about a COM dll that my .NET application is calling via interop. I've seen solutions for using GetFileVersionInfo on a currently loaded assembly, and also pInvoke style GetModuleHandle then querying calls. But since I'm using interop, in my loaded modules list I don't see it directly, just my interop dll.
If I use FileVersionInfo(filename) and have the full path to the dll, I get exactly what I need - however as the user will have control over where they install this COM dll, I can only think of querying the registery to get this full path. Can anyone see a better solution? Previous version of this product was a native application and thus loaded the dll directly.
Any ideas or is querying the registry the best choice?

How can I use a native DLL from C#?

Given a native DLL, with no documentation or anything, and assuming it is not a COM component, is there any way to extract some sort of interface from that DLL so it can be called from C#?
I know about PInvoke, but that requires me to already know the method names and signatures. I don't have those.
Is it even possible?
You can use a PE reading tool to list the exported functions. For example Dependency Walker will do that for you.
There's not a right lot you can do with that information though. There's no metadata with a native DLL that tells you how to call those functions, what their signatures are. Or even what the parameters represent.
Something has gone wrong with this project. A DLL on its own is not enough. You need a header file and some documentation.

link dll functions at runtime

My program requires some function in a dll at runtime. How do I tell where the dll is? I can copy the dll into the program directory or system 32. Is there other neat way of doing this? Thank you. Also I am working in C++.
Are you using native code (C/C++/Delphi) or .NET? You should see my answer to Call Function from Dynamic Library for an example of how to do this with a native (not .NET) DLL.

C++/cli - Native error trap for "Framework not available" Errors?

When creating dlls (Add-ins) for a third party program that loads Native DLLs dynamically, is there a way, in a Mixed Mode DLL (C++/cli) to natively catch the fact that the .Net framework is not available. So that the Parent program that is dynamically trying to consume this DLL does not throw an error?
It might be possible to do something with a custom entry point in the dll, but I expect you are walking in 'undocumented' territory.
The only 'simple' way I can think to do this would be to create a native shim dll that performs the check and handles the condition in whatever way you see fit. If the framework is present it in turn loads the real plugin DLL and mirrors all calls through to it.
How easy this is will depend on the complexity of the plugin interface you are working with.