views:

699

answers:

2

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.

A: 

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:

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++.

cpeterso
I currently have one of my Java developers writing a Java "boot-strap" program that launches our AIR app as a child process and then uses Merapi to async message communicate to the AIR app over a loopback socket. The C program would still just use a Merapi-like approach to talk to the AIR app.
RogerV
But if the C program were to load the AIR runtime shared library in-process, that would make things a little tighter in terms of memory use, speed of app launching, etc. In general one could get rid of Java - in our case we need to run Oracle Forms Java applet. But Java JVM is easy to load in-proc.
RogerV
A: 

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.

RogerV

related questions