先看效果:
压缩效果非常可观。
从零开始的使用步骤:
在upx的github上的release里下载对应版本,并解压到任意位置。
cmd窗口中先引用到解压后的文件路径,我的是E:\upx,故cmd中代码如下:
C:\Users\Xheng1934>e:
E:\>cd upx
E:\upx>
步骤直接全部给出:
upx D:\yourfile.exe
如果要压缩的文件路径中包含空格或特殊字符,需要将路径用引号括起来:
upx "D:\your folder\yourfile.exe"
举例:
C:\Users\Xheng1934>e:
E:\>cd upx
E:\upx>upx "C:\Users\Xheng1934\Desktop\FirstGame-flappy-Xheng1934.exe"
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2024
UPX 4.2.3 Markus Oberhumer, Laszlo Molnar & John Reiser Mar 27th 2024
File size Ratio Format Name
-------------------- ------ ----------- -----------
1428992 -> 560128 39.20% win64/pe FirstGame-flappy-Xheng1934.exe Packed 1 file.
E:\upx>upx "C:\Users\Xheng1934\Desktop\FirstGame-flappy-Xheng1934.exe"
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2024
UPX 4.2.3 Markus Oberhumer, Laszlo Molnar & John Reiser Mar 27th 2024
File size Ratio Format Name
-------------------- ------ ----------- -----------
upx: C:\Users\Xheng1934\Desktop\FirstGame-flappy-Xheng1934.exe: AlreadyPackedException: already packed by UPX
Packed 1 file: 0 ok, 1 error.
E:\upx>
E:\upx>upx -d "C:\Users\Xheng1934\Desktop\FirstGame-flappy-Xheng1934.exe"
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2024
UPX 4.2.3 Markus Oberhumer, Laszlo Molnar & John Reiser Mar 27th 2024
File size Ratio Format Name
-------------------- ------ ----------- -----------
1428992 <- 560128 39.20% win64/pe FirstGame-flappy-Xheng1934.exe
Unpacked 1 file.
E:\upx>
我先是压缩,再是二次压缩发现不行,因为UPX不支持对已经被UPX打包过的文件再次进行压缩。然后是解压缩。
解压缩代码:
upx -d "C:\Users\Xheng1934\Desktop\FirstGame-flappy-Xheng1934.exe"
注意:压缩后的exe文件运行时不需要解压缩就可直接运行。