[V0.3] love-pe - A 100% lua library for manipulating windows PE files (exe/dll)

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
RamiLego4Game
Citizen
Posts: 73
Joined: Tue Jun 10, 2014 7:41 pm

[V0.3] love-pe - A 100% lua library for manipulating windows PE files (exe/dll)

Post by RamiLego4Game »

Hello everyone :awesome: ,

I've been working on a library for manipulating PE files (.exe/.dll) using only Lua and LÖVE, it mainly focuses on hacking the resources.

The main goal of creating this library is to make it possible to change love.exe icon using LÖVE itself, The library is currently not complete and it's like 10% only of my plans.

Image

IconPatcher Usage:
  • Install LÖVE 11.1.
  • Download IconPatcher-V0.3.love (From github releases, link at the end of the post).
  • Download LÖVE for Windows (32-bit or 64-bit, both supported), from https://love2d.org.
  • Create a new icon using your favorite image editor.
  • Run the downloaded .love using LÖVE.
  • Drop the .exe and .ico files
  • A folder with open with the patched .exe in.
  • Enjoy.
Note:
This version (v0.3) replaces the icon by patching the executable, instead of rebuilding it, so it has much more stability, it could only break the checksum which is 0 for more executables.

The resulting executable will have the exact size of the old one.

The new icon should contain the same image sizes of the exe one, otherwise the non-matching images won't be updated.

And because .ico uses bmp format, then as long as the .ico has the same images sizes and bpp then they will have the same file size.

When reporting a non working '.exe', please upload the '.exe' and '.ico' and create a github issue: https://github.com/RamiLego4Game/love-pe/issues

lovePE API:
Copy the love-pe.lua file from this repo into your own project, and here's the API documentation (It's available at the top of the script):

Code: Select all

local lovePE = require("love-pe")

local icodata = lovePE.extractIcon(exeFile)
local success = lovePE.replaceIcon(exeFile,icoFile,newFile)
local success = lovePE.patchIcon(exeFile,icoFile,newFile)

local icodata = lovePE.extractIcon(exeString)
local success, newString = lovePE.replaceIcon(exeString,icoString)
local success, newString = lovePE.patchIcon(exeString,icoString)

--Arguments:
--[[
exeFile -> A LÖVE File object open in read mode and seaked at 0, The source exe file.
icoFile -> A LÖVE File object open in read mode and seaked at 0, The new ico file.
newFile -> A LÖVE File object open in write mode and seaked at 0, The new patched exe file.

exeString -> The source exe data as a string.
icoString -> The new ico data as a string.
newString -> The new patched exe data as a string.
]]
Github: https://github.com/RamiLego4Game/love-pe/
Releases: https://github.com/RamiLego4Game/love-pe/releases

Tell me what you think !
Last edited by RamiLego4Game on Wed May 16, 2018 7:38 pm, edited 5 times in total.
User avatar
Guard13007
Party member
Posts: 132
Joined: Sat Oct 25, 2014 3:42 am
Location: Internet, USA
Contact:

Re: [V0.1] love-pe - A 100% lua library for manipulating windows PE files (exe/dll)

Post by Guard13007 »

This is awesome. I can't wait to see it finished. :D
User avatar
RamiLego4Game
Citizen
Posts: 73
Joined: Tue Jun 10, 2014 7:41 pm

Re: [V0.2] love-pe - A 100% lua library for manipulating windows PE files (exe/dll)

Post by RamiLego4Game »

New update (V0.2) !

Uploaded the icon patcher, check the first post :)
User avatar
RamiLego4Game
Citizen
Posts: 73
Joined: Tue Jun 10, 2014 7:41 pm

Re: [V0.3] love-pe - A 100% lua library for manipulating windows PE files (exe/dll)

Post by RamiLego4Game »

New update (V0.3) !

This new version replaces the icon by patching the executable, instead of rebuilding it, so it has much more stability, it could only break the checksum which is 0 for more executables.

The resulting executable will have the exact size of the old one.

The new icon should contain the same image sizes of the exe one, otherwise the non-matching images won't be updated.

And because .ico uses bmp format, then as long as the .ico has the same images sizes and bpp then they will have the same file size.
User avatar
Rucikir
Party member
Posts: 129
Joined: Tue Nov 05, 2013 6:33 pm

Re: [V0.3] love-pe - A 100% lua library for manipulating windows PE files (exe/dll)

Post by Rucikir »

Out of curiosity, where did you get the documentation on the PE format ?
User avatar
RamiLego4Game
Citizen
Posts: 73
Joined: Tue Jun 10, 2014 7:41 pm

Re: [V0.3] love-pe - A 100% lua library for manipulating windows PE files (exe/dll)

Post by RamiLego4Game »

Rucikir wrote: Sun Jun 10, 2018 9:52 pm Out of curiosity, where did you get the documentation on the PE format ?
They could be found on google easily,

PE Format:
https://en.wikibooks.org/wiki/X86_Disas ... able_Files
https://github.com/deptofdefense/SalSA/ ... ile-Format
https://msdn.microsoft.com/library/wind ... s.85).aspx

Icons:
https://en.wikipedia.org/wiki/ICO_(file_format)
https://msdn.microsoft.com/en-us/library/ms997538.aspx

Note that icon format in PE files is quite different
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 24 guests