Loading SystemC modules dynamically at run-time - systemc

In my simulator framework, the HW/SW modules are implemented in SystemC and pre-built. The platform to be simulated is described in XML. The simulator core parses the XML, determines the modules used and corresponding libraries files (e.g. dlls in Windows), and loads these modules dynamically at run-time. But I found no sample code of SystemC loading modules dynamically.
How can I do this in SystemC?

Because you said the example in DLLs of Windows, I assume you are doing so in Windows platform. So I suggest you can read the article and example in MSDN http://msdn.microsoft.com/en-us/library/windows/desktop/ms686944(v=vs.85).aspx .
If you are using unix platform, you could use dlopen and dlsym to load the corresponding shared libraries and retrieve the function address to be called from your main program.

Related

Shared library update

I have my application splited into 4 main parts:
main application (acting like a glue for other parts - load plugins, has linked core and ui libraries)
core (shared library with classes etc., it will be even something like sdk, basically contains all except things related to Ui)
ui (shared library, that contains ui resources, types etc.)
other plugins (shared libraries, loaded by main application, which will use Plugin manager from core
The main reason for this is that i want to have possibility to replace all parts of application just by downloading plugins for my application (through plugin manager window in that application).
Let's say i want to redesign look of my app. In that case i should just release new version of ui shared library/plugin.
I am not sure if it will work, if that ui shared library is linked to my app by linker when application is compiled (core and ui are linked by linker, other shared libraries/plugins are loaded by plugin manager when app is starting).
Question:There will be probably saved some metadata about those libraries in final executable, for instance size?? So i probably can't just replace ui shared library, without need to compile and link my app again?
Generally speaking, you can replace a shared library with an other version of the shared library in distribution (without recompilation of the executable, etc.) in case the original library and the replaced library do have same ABI

Understanding bundles frameworks and libraries

I'm developing ios B2B app and I have several questions regarding app modularization.
Firstly i need to understand main difference between bundles and frameworks. When to use bundles and when frameworks.
Another question is. Is it possible for bundle to contain a .framework inside in it and vice versa.
Is it possible to create a plugins for ios app and load them dynamically, if yes then what it should be? bundle framework or library?
Is it possible for library to contain a resource files ?
Is it possible to create a resource bundle and dynamic library and then load them dynamically at runtime.
Is it possible to create a plugins for ios app and load them
dynamically, if yes then what it should be? bundle framework or
library?
No
Is it possible for library to contain a resource files ?
No
Is it possible to create a resource bundle and dynamic library and
then load them dynamically at runtime.
No
A Bundle is a type of Directory, a folder. A Framework is a bundle. So is an Application and so is a Plugin.
A Static Library is a single file code archive you can compile into your app at build time
A Dynamic Library is a single file code archive you can load at Runtime
A Framework is a Dynamic library in a Bundle with other things
A Plugin is a Dynamic library in a Bundle with other things
The Xcode build option 'Bundle' means 'Place the compiled Dynamic Library in a Bundle' - this is what you do when you want to create a Plugin.
Static libraries are the only option for modularising your code on iOS.
On the desktop..
Typically a Framework is for sharing code and resources between multiple apps. You want your app to behave as though the code was actually compiled into it. You want loading to happen transparently and you don't want to do anything special to use the methods, functions, etc. contained in it.
A Plugin (a Bundle containing compiled code and resources) is for optional, dynamically loaded code, e.g. a software extension that you can choose to load or not. You want to carefully architect your app so that it isn't dependent on the Plugin but acquires new behaviour if you manually locate and load it at Runtime.
A Framework and a Plugin are very similar, but a Framework has a strict file layout to facilitate locating and loading code and resources. With a plugin, these jobs are your responsibility so you can structure the Bundle contents however you want.
Because loading code is so easy in Cocoa on OSX (but not iOS) Frameworks can contain Plugins which contain Frameworks which contain more Frameworks, etc.
On iOS some people put Static Libraries in Bundles with resources and call them Frameworks. This has none of the benefits and all of the drawbacks of a real framework.

Plug-in architecture, access to code in application?

For a project I am doing, I want the Mac application to accept plug-ins. I like the whole idea of just adding Bundles to the application to extend it's functionality.
Only I came across a small question, where I can't find the answer to:
I need to include a JSON parser in my application, for some functionality. Is it possible for a plug-in Bundle to also use that same parser? Or does every plug-in that uses a JSON parser, need to include the parser themselves?
What is the best way to do this for separate Bundles?
On OS X there are two types of loadable things, a dylib and a plugin. (These two terms have specialized technical meaning in the context of mach-o, the binary format OS X uses.)
A loaded dylib can't refer to the libraries in the executable, while a loaded plugin can. As a side effect, a dylib can be loaded to any executable, but a plugin can only be loaded into the executable you specify when you make the plugin.
So you want to make a plugin. There is a template in the XCode to do that. Don't forget to specify the target executable in the linker flag, which can be set somewhere in the inspector.
For more, read Code Loading Programming Topics.

Calling dll from kernel mode c++ windows

How would I go about calling a dll from kernel mode?
I have tried making a custom lib file using multiple techniques but I cannot get anything to work. I have also researched on google but cannot seem to find anything. I was also curious if it was possible to create entries in the import address table from c++ or at link time?
The fundamental issue for a DLL in kernel mode is whether the DLL calls any user-mode code. If a DLL contains anything other than native kernel API calls, you'll get linker errors if you try to link your driver with it when you build (and the kernel wouldn't load it anyway)
check the following link
Calling a DLL in a Kernel-Mode Driver
Edit:
Another useful link
DLLs in Kernel Mode Tim Roberts

Problems using dynamic linked libraries (wxWidgets) from a DLL

We created a plugin; it is a DLL (Run-Time Dynamic Linking) which uses a 3rd party library (wxWidgets) and also links dynamically to that. The host software seems to scan our plugin, but exported functions are not called. We checked all dependencies with DependencyWalker.
We see in the debugger that the plugin is loaded, but the DllMain is not called, and the plugin is unloaded.
We tried loading our plugin from a simple test application using LoadLibrary and GetProcAddress which recognized and called the exported functions.
Having wxWidgets linked statically worked fine, though.
Does anyone have an idea why the exported function, respectively DllMain are not called, or can point out a tool which is capable to monitor the whole DLL loading process?
If wxWidgets is loaded already into the process address space before your plugin is loaded (the host app could do that, or there might be another plugin linking to wxWidgets which is loaded before yours), then there might be a chance that it is another version, missing some of the entry points that your plugin needs. Running the host app under DependencyWalker or WinDbg should show you which wxWidgets DLL is loaded, and you could try to load your plugin from your test app using exactly the same wxWidgets DLL. That should reveal whether there are missing dependencies.
Perhaps the host software does some funky things when loading the plugin and doesn't like wxWindows.
Anyways, try using the ProcessExplorer from the SysInternals suite to check what the process is doing.