Some improvements

This commit is contained in:
RamiLego4Game
2018-05-10 21:35:27 +03:00
parent 0f1735669e
commit 98bdc16d18

View File

@@ -4,9 +4,14 @@
local iconChanger = require("icon-changer") local iconChanger = require("icon-changer")
local icodata = iconChanger.extractIcon(exeFile) local icodata = iconChanger.extractIcon(exeFile)
- Reference:
Version File Resource: https://msdn.microsoft.com/en-us/library/ms647001(v=vs.85).aspx
]] ]]
local bit = require("bit") local bit = require("bit")
local utf8 = require("utf8")
local bor,band,lshift,rshift,tohex = bit.bor,bit.band,bit.lshift,bit.rshift,bit.tohex local bor,band,lshift,rshift,tohex = bit.bor,bit.band,bit.lshift,bit.rshift,bit.tohex
@@ -26,7 +31,9 @@ local resourcesTypes = {
"13", "13",
"Group Icons", "Group Icons",
"15", "15",
"Version Information" "Version Information",
"17","18","19","20","21","22","23",
"Manifests"
} }
--==Internal Functions==-- --==Internal Functions==--
@@ -47,8 +54,16 @@ local function decodeNumber(str,bigEndian)
end end
local function convertUTF16(str16) local function convertUTF16(str16)
return str16--return str16:gsub("..","%1") --return str16--return str16:gsub("..","%1")
local newstr = {}
for chars in string.gmatch(str16,"..") do
local unicode = decodeNumber(chars,true)
newstr[#newstr+1] = utf8.char(unicode)
end end
return table.concat(newstr)
end
convertUTF16 = function(...) return ... end
local function convertRVA2Offset(RVA,Sections) local function convertRVA2Offset(RVA,Sections)
for id, Section in ipairs(Sections) do for id, Section in ipairs(Sections) do
@@ -134,7 +149,7 @@ local function readResourceDirectoryTable(exeFile,Sections,RootOffset,Level)
if ok then if ok then
print("RVA OK") print("RVA OK")
exeFile:seek(DataOffset) exeFile:seek(DataOffset)
Tree[Name.."_P_"..tohex(DataCodepage)] = convertUTF16(exeFile:read(DataSize)) Tree[Name] = convertUTF16(exeFile:read(DataSize))
else else
print("RVA Failed",DataOffset) print("RVA Failed",DataOffset)
Tree[Name] = "" Tree[Name] = ""