如何从AIR程序加载AIR运行时作为进程内共享库

时间:2022-01-02 22:57:08

I'd like to build a special AIR launcher program in C along the lines of java.exe.

我想在C语言中沿着java.exe构建一个特殊的AIR启动程序。

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

我已经研究了使用进程查看器运行AIR程序,并且能够找到正在使用的AIR运行时DLL。 AIR程序与Java不同之处在于它们作为特定于平台的可执行文件安装,这些可执行文件在启动时将AIR运行时绑定为进程内共享库(用户双击它们的图标)。

Well, I want to make an AIR launcher that is instead like the java.exe.

好吧,我想制作一个类似java.exe的AIR启动器。

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.

java.exe作为平台OS进程启动,该进程将Java JVM运行时(JRE)绑定为进程内共享库。要执行的java应用程序被指定为java.exe的命令行参数。一旦java.exe运行并且JVM完全正常运行,JVM类加载器就会加载指定的java应用程序类以供执行。然后,指定的Java应用程序接管,从某种意义上说“劫持”java.exe的进程。当然,指定的java应用程序在任何进程列表中显示为托管它的java.exe程序。

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.

我想让AIR应用程序启动这样的工作。为什么?因此,我可以探索破解AIR的方法,并可能克服其中的许多不足之处。例如,对于初学者,我想使用一些可供运行的AIR应用程序使用的新API来扩展AIR运行时体验。

My first order of business would be to:

我的第一笔业务是:

  • Implement a binding interface of ActionScript3 to C that is comparable to .NET PInvoke
  • 实现ActionScript3到C的绑定接口,与.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)
  • 添加用于流程启动的API,与用于执行此操作的Java SE中的API相当(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).
  • 添加对AIR应用程序的支持,以便能够与stdin,stdout,stderr进行交互。奇怪的是,尽管Adobe在AIR中添加了对本地文件访问的支持,但他们忽略了与这些标准文件管道的交互(但它们可以在AIR支持的任何OS平台上找到)。

  • 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.
  • 通过stdin,stdout,stderr实现对AMF的支持 - 因此AIR(或Java或任何支持AMF的语言)应用程序可以通过交换AMF对象来进行通信间处理。这将为AIR添加一点微软的PowerShell。

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.

目前Merapi提供了一个带Java的AMF桥,因此证明了这一点的功效。唉,Merapi必须使用localhost端口和套接字来进行进程间通信 - 相对于使用stdin / stdout / stderr进程间管道而言,这是一种笨拙的方式。

2 个解决方案

#1


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:

听起来你想要做一些非常铁杆的AIR黑客攻击。我不认为在您自己的进程中托管AIR运行时将非常容易。但您可以考虑嵌入Flash Player ActiveX控件。由于它只是一个COM对象,因此任何COM应用程序都可以使用CoCreateInstance()Flash Player。 COM接口没有很好的文档记录,但这里有一些可能有用的示例:

  • 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.
  • F-IN-BOX是一个用于增强Macromedia Flash Player ActiveX功能的开发人员库。它不使用自己的引擎来显示电影,而是提供官方swflash.ocx / flash.ocx代码的包装。

  • How to embed Flash Player ActiveX using BoxedApp SDK
  • 如何使用BoxedApp SDK嵌入Flash Player ActiveX

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

如果您希望获得更低级别的访问权限,则可以嵌入开源的Tarmain AS3 VM。该代码有一个名为“avmshell”的命令行shell示例。如果您自己构建Tamarin VM,则可以添加在本机C ++中实现的新ActionScript类。 Tamarin(和Flash Player)使用AS和C ++之间的“AVM Glue”实现了许多功能。

#2


What my question posed attempting to do turns out to be prohibited by Adobe (so far as any potential commercial use):

我的问题试图做的事实证明是Adobe禁止的(只要有任何潜在的商业用途):

From the Adobe® AIR™ Runtime Distribution FAQ:

从Adobe®AIR™运行时分发常见问题解答:

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.

以未记录的方式或目的分发或使用Adobe AIR运行时,安装程​​序文件或解压缩的安装程序文件。例如,您不得为软件应用程序中的任何Adobe AIR库或运行时组件分发,直接调用或编写包装器。 Runtime.dll,Runtime可执行文件,template.exe和template.app是运行时组件的示例。

#1


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:

听起来你想要做一些非常铁杆的AIR黑客攻击。我不认为在您自己的进程中托管AIR运行时将非常容易。但您可以考虑嵌入Flash Player ActiveX控件。由于它只是一个COM对象,因此任何COM应用程序都可以使用CoCreateInstance()Flash Player。 COM接口没有很好的文档记录,但这里有一些可能有用的示例:

  • 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.
  • F-IN-BOX是一个用于增强Macromedia Flash Player ActiveX功能的开发人员库。它不使用自己的引擎来显示电影,而是提供官方swflash.ocx / flash.ocx代码的包装。

  • How to embed Flash Player ActiveX using BoxedApp SDK
  • 如何使用BoxedApp SDK嵌入Flash Player ActiveX

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

如果您希望获得更低级别的访问权限,则可以嵌入开源的Tarmain AS3 VM。该代码有一个名为“avmshell”的命令行shell示例。如果您自己构建Tamarin VM,则可以添加在本机C ++中实现的新ActionScript类。 Tamarin(和Flash Player)使用AS和C ++之间的“AVM Glue”实现了许多功能。

#2


What my question posed attempting to do turns out to be prohibited by Adobe (so far as any potential commercial use):

我的问题试图做的事实证明是Adobe禁止的(只要有任何潜在的商业用途):

From the Adobe® AIR™ Runtime Distribution FAQ:

从Adobe®AIR™运行时分发常见问题解答:

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.

以未记录的方式或目的分发或使用Adobe AIR运行时,安装程​​序文件或解压缩的安装程序文件。例如,您不得为软件应用程序中的任何Adobe AIR库或运行时组件分发,直接调用或编写包装器。 Runtime.dll,Runtime可执行文件,template.exe和template.app是运行时组件的示例。