JAR 隐藏在 EXE 中? [英] JAR hidden inside EXE?

查看:26
本文介绍了JAR 隐藏在 EXE 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Minecraft 是一款 Java 游戏,本周末免费.Windows 版本下载为 exe 文件.我很好奇 EXE 文件在做什么以及它从哪里解压和运行实际游戏 JAR.所以使用命令,我找到了运行 javaw.exe 进程的命令行参数;奇怪的是,它是通过一个指向可执行文件的类路径启动的!(意思是,.exe 文件充当 jar).事实上,在将 Minecraft.exe 重命名为 Minecraft.jar 之后,我能够打开它并看到加载器类文件等,就好像它是一个普通的 JAR 文件而不是一个 EXE.

Minecraft, a Java game, is free this weekend. The Windows version downloads as an exe file. I was curious what the EXE file is doing and where it's unpacking and running the actual game JAR from. So using a command, I found the command-line arguments to the running javaw.exe process; and oddly enough, it was launched with a classpath pointing to the executable! (meaning, the .exe file was acting as a jar). Indeed, after renaming Minecraft.exe to Minecraft.jar, I was able to open it and see the loader class files and such, as if it were a normal JAR file and not an EXE at all.

这怎么可能?以及如何使用我自己的 JAR 文件来做到这一点?

How is this possible? And how can I do it with my own JAR files?

推荐答案

这在以前很常见 - 特别是在软盘时代,空间很宝贵,解压缩程序在不同的磁盘上很乏味比 zip 文件.

This used previously to be very common - especially in the days of floppy disks where space was precious and it was tedious for the unzip program to be on a different disk than the zip file.

之所以能做到,是因为zip-file的库存结构位于zip-file的end,而不是前面,所以一个zip文件可以包含大量的只要库存结构不指向它们(以及扩展 jar 文件),初始不相关字节.一个非常常见的用途是包含一个小型的仅解压缩程序,然后可以解压缩 zip 文件.

The reason why it can be done is because the zip-file inventory structure is located at the end of the zip-file, not the front, so a zip file can contain a large number of initial irrelevant bytes as long as the inventory structure does not point to them (and by extension jar-files too). A very frequent use for this has been to enclose a small unzip-only program which could then unpack the zip file.

在这样的程序之前添加一个实用程序是 unzipsfx.这是它的手册页:http://linuxcommand.org/man_pages/unzipsfx1.html

One utility to prepend such a program is the unzipsfx. Here is a manual page for it: http://linuxcommand.org/man_pages/unzipsfx1.html

Minecraft 似乎使用了另一个预先调用的程序,该程序在自身上调用了 Java.

It appears that Minecraft uses another prepended program which invokes Java on itself.

用十六进制编辑器查看内部.Minecraft.exe 被 Launch4j 包裹.

Looked inside with an hex editor. Minecraft.exe is wrapped with Launch4j.

这篇关于JAR 隐藏在 EXE 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆