在 Javascript 中获取外部接口定义

发布于 2024-08-17 10:38:03 字数 331 浏览 12 评论 0原文

有没有办法从 Flash 对象获取公开函数的列表?例如,您可以通过执行以下命令来获取对象中所有方法的列表:

for (var i in object) {
  if (typeof object[i] == "function") {
    console.log(i);
  }
}

唯一的问题是,这不会公开通过ExternalInterfaces API 注册的任何方法。我可以尝试查看该函数是否存在(object['method']),它告诉我它是一个函数,但我必须以这种方式猜测每个现有的方法。

注意:显然,我无权访问动作脚本。

Is there a way to get a list of the exposed functions from a Flash object? For example, you could get a list of all methods in an object by executing:

for (var i in object) {
  if (typeof object[i] == "function") {
    console.log(i);
  }
}

The only issue is that this won't expose any methods registered through the ExternalInterfaces API. I can try and see if the function exists (object['method']) and it tells me it is a function, but I would have to guess every existing method in this manner.

NOTE: Obviously, I don't have access to the actionscript.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

岁月打碎记忆 2024-08-24 10:38:03

只是提出这个问题,似乎有点晚了,但无论如何我都会发布答案;)
使用 IE10 (windows 7),我可以很好地列出我的所有方法,如下所示:

var obj = document.getElementById('flashObj');
for(var prop in obj){
  var fx = obj[prop];
  if(obj.hasOwnProperty(prop) && (typeof fx == 'function') && /eval\(instance/.test(fx)){
    console.log(prop)
  }
}

请注意,这在 Chrome 或 Firefox 中不起作用,只能使用精确的正则表达式,因为 IE10 不会像其他浏览器那样报告“本机代码” 。

Just hit this question, a tad to late it seems, but I'll post an answer anyways ;)
Using IE10 (windows 7) it worked perfectly fine for me to list all my methods like so:

var obj = document.getElementById('flashObj');
for(var prop in obj){
  var fx = obj[prop];
  if(obj.hasOwnProperty(prop) && (typeof fx == 'function') && /eval\(instance/.test(fx)){
    console.log(prop)
  }
}

Note that this did not work in Chrome or Firefox and only with the exact regexp since IE10 does not report "native code" as the other browsers do.

梦里寻她 2024-08-24 10:38:03

问题更糟:这些信息在 ActionScript 中均不可用。您将新函数注册为 ExternalInterface.addCallback('foo', foo) 并且无法列出已注册的回调。

The problem is even worse: the information is neither available in ActionScript. You register a new function as ExternalInterface.addCallback('foo', foo) and you can not list already registered callbacks.

萌吟 2024-08-24 10:38:03

只是猜测,但看看它是否有效。所有ExternalInterface函数都应该在全局命名空间中定义。尝试将 SWF 嵌入到 HTML 页面中,并在页面加载后获取为该页面定义的所有 Javascript 函数。 JavaScript 中的全局用户定义函数列表?

列表函数应该是在 SWF 文件中定义的函数。

Just a guess but see if it works. All the ExternalInterface functions should be defined in the global namespace. Try embedding the SWF in an HTML page and get all the Javascript functions defined for the page after the page has loaded. List of global user defined functions in JavaScript?

The list of functions should be those defined in the SWF file.

孤独岁月 2024-08-24 10:38:03

我想唯一的方法是解析 SWF 文件字节码并尝试收集对 ExternalInterface.addCallback 方法的调用。

http://www.google.com/search?q=parse+avm2

I guess the only way to go is to parse the SWF file bytecode and try to gather the calls to ExternalInterface.addCallback method.

http://www.google.com/search?q=parse+avm2

逆流 2024-08-24 10:38:03

我的直觉是否定的,ExternalInterface本质上是一个黑盒子,或者黑信箱,你把东西戳进去,有时东西又回来了,但你无法打开门看看里面有什么。

由于没有关于 SWF 中公开内容的文档,唯一的其他建议是反编译 swf 以查看源代码。

My instinct is no, ExternalInterface is essentially a black box, or black letter box, you poke things through and sometimes things come back, but you can't open the door to see what's inside.

Without documentation as to what's been exposed in the SWF, the only other suggestion is decompiling the swf to have a look at the source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文