Straight question about WebRTC compilation on Windows (GN/Ninja): Is there a specific configuration in GN that tells ninja to build WebRTC into DLLs that can be consumed by a MSVC application? Currently I just build them statically, but this is not good because I am using a legacy application that should consume WebRTC in dynamic link only. Looking into WebRTC build list (in gn) it seems there is no such configuration. Is that statement correct? If not, what would be the option to be used?
New to Swift/Objective-c and coming from Java, C# and C++ background. My understanding is that a runtime is needed if the code is non-native as in case of Java or C# an intermediate code is generated which would at Runtime need an environment which translates code to the machine language and we call that a runtime environment (like JRE).
So having read some Q and As on stack overflow it is clear that Swift and Objective-C both are compiled as native binaries. But they need Objective-C runtime to execute them.
I don't know why a runtime is needed if code is already in machine language ?
Is it like a library linked to the program ?
Or Is this objective-C runtime a separate environment which hosts the objective-C/Swift program ? just like JRE ?
Can someone please shed some light on this ?
Thanks,
Ahmed
Many programming languages rely on runtime libraries, including C++. These consist of low-level routines to support the programming language's model on that of the hosting operating system. Objective-C's runtime library implements core features such as dynamic method lookup.
Java and C# require a virtual machine, these are much more involved than runtime libraries.
HTH
We (our team) saw that it's possible to include standalone app to a plugin. The app is used to modify Petrel's data in the specific way. See for example these plugins:
http://www.ocean.slb.com/Pages/Product.aspx?category=petrelgeophysics%28Petrel%29&cat=Petrel&pid=PCPT-B1%28Base%29&view=grid
http://www.ocean.slb.com/Pages/Product.aspx?category=petrelgeophysics%28Petrel%29&cat=Petrel&pid=PRPW-B1%28Base%29&view=grid
We want to do the same thing so there are questions:
How the plugin perform editing Petrel's data?
Does Petrel (Ocean) provide any mechanisms for IPC or should we develop our own architecture for communications between managed plugin code and native app process?
For most Petrel data, it is only safe to modify them inside the main thread of a Petrel plug-in.
If you already have a native process that does the number crunching, you will need to implement your own way to share the data between the plug-in and the native process. Eclipse does this by file sharing. If the overhead of IPC outweigh the actual computation, you may want to consider refactoring the native process to make it run inside the plug-in.
I'd like to build a special AIR launcher program in C along the lines of java.exe.
I've looked at running AIR programs with a process viewer and was able to locate the AIR runtime DLL that is being used. AIR programs are different than Java in that they are installed as platform-specific executables that bind the AIR runtime as an in-process shared library once they're launched (their icon is double-clicked by the user).
Well, I want to make an AIR launcher that is instead like the java.exe.
The java.exe is launched as a platform OS process that binds to the Java JVM runtime (JRE) as an in-process shared library. The java application that is to be executed is specified as a command-line argument to java.exe. Once java.exe is running and the JVM is fully functional, the specified java application class is loaded by the JVM class loader for execution. That specified Java application then takes over, in a sense "hijacking" the process of java.exe. Of course, the specified java application shows up in any process listing as the java.exe program that host it.
I want to make AIR app launching work like this. Why? So I can explore ways to hack AIR and perhaps overcome some of its many, many deficiencies. For instance, for starters I want to extend the AIR runtime experience with some new APIs that become available to the running AIR application.
My first order of business would be to:
Implement a binding interface of
ActionScript3 to C that is comparable
to .NET PInvoke
Add an API for process launching that
is comparable to the APIs found in
Java SE for doing this (Runtime.exec,
ProcessBuilder, Process)
Add support for an AIR application to
be able to interact with stdin,
stdout, stderr. Strangely, though
Adobe added support for local file
access in AIR, they have omitted
interaction with these standard file
pipes (yet they are found on any
OS platform that AIR supports).
Implement support of AMF over stdin,
stdout, stderr - so AIR (or Java or
any AMF capable language) apps can
interprocess communication via
exchanging AMF objects. This would add
a touch of Microsoft's PowerShell
to AIR.
Currently Merapi provides a AMF bridge with Java, so that demonstrates the efficacy of this. Alas, Merapi has to use a localhost port and socket for doing the interprocess communication - which is a clumsy way to go relative to using stdin/stdout/stderr interprocess pipes instead.
It sounds like you want to do some very hardcore AIR hacking. I don't think hosting the AIR runtime in your own process will be very easy. But you might consider embedding the Flash Player ActiveX Control. Since it is just a COM object, any COM application can CoCreateInstance() the Flash Player. The COM interface is not well documented, but here are some examples that might be helpful:
F-IN-BOX is a developer's library to enhance Macromedia Flash Player ActiveX features. It does not use its own engine to display movies but provide a wrapper around official swflash.ocx/flash.ocx code instead.
How to embed Flash Player ActiveX using BoxedApp SDK
If you want to get even lower level access, you could embed the open-source Tarmain AS3 VM. The code has an example command-line shell called "avmshell". If you build the Tamarin VM yourself, you can add new ActionScript classes implemented in native C++. Tamarin (and the Flash Player) implement many of their features using this "AVM Glue" between AS and C++.
What my question posed attempting to do turns out to be prohibited by Adobe (so far as any potential commercial use):
From the Adobe® AIR™ Runtime Distribution FAQ:
Distribute or use the Adobe AIR
runtime, installer files, or extracted
installer files in an undocumented
manner or purpose. For example, you
may not distribute, call directly, or
write wrappers for any of the Adobe
AIR libraries or runtime components
within your software application.
Runtime.dll, Runtime executables,
template.exe, and template.app are
examples of Runtime Components.
We need to interface to 3rd party app, but company behind the app doesn't disclose message protocol and provides only Windows DLL to interface to.
Our application is Linux-based so I cannot directly communicate with DLL. I couldn't find any existing solution so I'm considering writing socket-based bridge between Linux and Windows, however I'm sure it is not such a unique problem and somebody should have done it before.
Are you aware of any solution that allows to call Windows DDL functions from C app on Linux? It can use Wine or separate Windows PC - doesn't matter.
Many thanks in advance.
I wrote a small Python module for calling into Windows DLLs from Python on Linux. It is based on IPC between a regular Linux/Unix Python process and a Wine-based Python process. Because I have needed it in too many different use-cases / scenarios myself, I designed it as a "generic" ctypes module drop-in replacement, which does most of the required plumbing automatically in the background.
Example: Assume you're in Python on Linux, you have Wine installed, and you want to call into msvcrt.dll (the Microsoft C runtime library). You can do the following:
from zugbruecke import ctypes
dll_pow = ctypes.cdll.msvcrt.pow
dll_pow.argtypes = (ctypes.c_double, ctypes.c_double)
dll_pow.restype = ctypes.c_double
print('You should expect "1024.0" to show up here: "%.1f".' % dll_pow(2.0, 10.0))
Source code (LGPL), PyPI package & documentation.
It's still a bit rough around the edges (i.e. alpha and insecure), but it does handle most types of parameters (including pointers).
Any solution is going to need a TCP/IP-based "remoting" layer between the DLL which is running in a "windows-like" environment, and your linux app.
You'll need to write a simple PC app to expose the DLL functions, either using a homebrew protocol, or maybe XML-RPC, SOAP or JSON protocols. The RemObjects SDK might help you - but could be overkill.
I'd stick with a 'real' or virtualized PC. If you use Wine, the DLL developers are unlikely to offer any support.
MONO is also unlikely to be any help, because your DLL is probably NOT a .NET assembly.
This is a common problem. Fortunately, it now has a solution. Meet LoadLibrary, developed by Tavis Ormandy:
https://github.com/taviso/loadlibrary
I first stumbled across LoadLibrary in an article on Phoronix by Michael Larabel:
A Google researcher has been developing "LoadLibrary" as a means of
being able to load Windows Dynamic Link Libraries (DLLs) that in turn
can be used by native Linux code.
LoadLibrary isn't a replacement for Wine or the like but is intended
to allow Windows DLL libraries to be loaded that can then be accessed
by native Linux code, not trying to run Windows programs and the like
on Linux but simply loading the libraries.
This project is being developed by Tavis Ormandy, a well known Google
employee focused on vulnerability research. He worked on a custom
PE/COFF loader based on old ndiswrapper code, the project that was
about allowing Windows networking drivers to function on Linux.
LoadLibrary will handle relocations and imports and offers an API
inspired by dlopen. LoadLibrary at this stage appears to be working
well with self-contained Windows libraries and Tavis is using the
project in part for fuzzing Windows libraries on Linux.
Tavis noted, "Distributed, scalable fuzzing on Windows can be
challenging and inefficient. This is especially true for endpoint
security products, which use complex interconnected components that
span across kernel and user space. This often requires spinning up an
entire virtualized Windows environment to fuzz them or collect
coverage data. This is less of a problem on Linux, and I've found that
porting components of Windows Antivirus products to Linux is often
possible. This allows me to run the code I’m testing in minimal
containers with very little overhead, and easily scale up testing."
More details on LoadLibrary for loading Windows DLLs on Linux via
GitHub where he also demonstrated porting Windows Defender libraries
to Linux.
Sometimes it is better to pick a small vendor over a large vendor because the size of your business will give you more weight for them. We have certainly found this with AV engine vendors.
If you are sufficiently important to them, they should provide either a documented, supported protocol, a Linux build of the library, or the source code to the library.
Otherwise you'll have to run a Windows box in the loop using RPC as others have noted, which is likely to be very inconvenient, especially if the whole of the rest of your infrastructure runs Linux.
Will the vendor support the use of their library within a Windows VM? If performance is not critical, you might be able to do that.
Calling the DLL's functions themselves is of course only the tip of the iceberg. What if the DLL calls Win32, then you'd have a rather massive linking problem. I guess Wine could help you out there, not sure if they provide a solution.
IMO, the best bet is to use Sockets. I have done this previously and it works like a charm.
An alternate approach is to use objdump -d to disassemble the DLL, and then recompile/reassemble it. Don't expect to be able to recompile the code unedited. You might get pure, unadulterated rubbish, or code full of Windows calls, or both. Look for individual functions. Functions are often delimited by a series of push instructions and end with a ret instruction.