Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Problem using strings instead of LÖVE files #1

Open
25A0 opened this issue May 6, 2019 · 1 comment
Open

Problem using strings instead of LÖVE files #1

25A0 opened this issue May 6, 2019 · 1 comment

Comments

@25A0
Copy link

25A0 commented May 6, 2019

Thanks a lot for this little tool!

In the Readme you show that it's possible to use strings instead of LÖVE files:

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

--[[ Arguments:
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.]]

However, when I try to do this, the output file is corrupted. It is just 214KB big, instead of the original exe which is about 4MB. After a bit of investigation, I suspect that there is something wrong with the function newStringFile(). In particular, I think this line needs to be removed:

   function file:write(d,s)
     if s then d = d:sub(1,s) end
>    if pos+#d > #str then d = d:sub(1,#str-pos) end
     
     str = str:sub(1,pos)..d..str:sub(pos+#d+1,-1)
     
     pos = pos + #d
    
     return #d
   end

Once that line is removed, I was able to produce a correctly patched exe.

@Rami-Sabbagh
Copy link
Owner

Yes, I remember l encountered the same problem when using the library in another project myself.
I've fixed it but didn't update the library in this repository.
I'll upload the fix once l finish studying at 1/7/2019
Thanks for reminding me about this.

@Rami-Sabbagh Rami-Sabbagh pinned this issue May 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants