Skip to content

Commit b7e7d54

Browse files
committed
Initial implementation of function B() that will handle parsing VS_VERSION_INFO struct in PE95TIME.LUA.
1 parent f30500a commit b7e7d54

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

demo/xtra/PE95TIME.LUA

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
#!/usr/bin/env lua
22

33
--Set PE timestamps to a constant so builds are repeatable
4-
C,E,F,S,V="cur","Unexpected EOF","<I4","set",809222400
4+
C,E,F,S,V="cur","!EOF","<I4","set",809222400
55
function R(f,l)local b=f:read(l)if b and#b>=l then return string.unpack(l==2 and"<I2"or F,b)end error(E)end
66
function W(f,p,v)f:seek(S,p)f:write(string.pack(F,v))end
77
function P(f)f:seek(S,0)local mz=f:read(2)f:seek(S,0x3C)if mz=="MZ"then return R(f,4)end error("!MZ")end
88
function O(f,p)
99
f:seek(S,p)local s,n,h,m=f:read(4)if s~="PE\0\0"then error("!PE")end f:seek(C,2)
1010
n=R(f,2)f:seek(C,12)s=R(f,2)f:seek(C,2)h,m=f:seek(),R(f,2)
11-
if m~=0x10b and m~=0x20b then error("!Magic")end f:seek(S,h+s)
12-
for _=1,n do
13-
local u,o,q=f:seek(),f:read(8):gsub("\0.*","")f:seek(C,12)q=R(f,4)f:seek(S,u+40)
14-
if o==".rsrc"then return q end
15-
end return nil end
16-
function A(f,b,o,l)
11+
if m~=0x10b then error("!10")end f:seek(S,h+s)
12+
for _=1,n do local u,o,q=f:seek(),f:read(8):gsub("\0.*","")f:seek(C,12)q=R(f,4)f:seek(S,u+40) if o==".rsrc"then return q end end end
13+
function B(f,o)
14+
local r,s=R(f,4),R(f,4)
15+
print("TODO: handle VS_VERSION_INFO @" .. r .. " (size " .. s .. ")")
16+
end
17+
function A(f,b,o,l,v)
1718
local d,n,i,t,e=b+o+4 W(f,d,V)f:seek(C,4)n,i=R(f,2),R(f,2)t,e=n+i,d+12
18-
for j=0,t-1 do f:seek(S,e+(j*8))i,d=R(f,4),R(f,4)if(d&0x80000000)~=0 then A(f,b,d&0x7FFFFFFF,l+1)end end
19-
--TODO: if l==1 and i==16 then parse_VS_VERSION_INFO() end
19+
for j=0,t-1 do f:seek(S,e+(j*8))i,d=R(f,4),R(f,4)
20+
if(d&0x80000000)~=0 then A(f,b,d&0x7FFFFFFF,l+1,v or(l==1 and i==16))
21+
elseif v and l==3 then B(f,b+d)end
22+
end
2023
end
2124
if #arg<1 then os.exit(1)end
2225
local f,p,r=assert(io.open(arg[1],"r+b"))p=P(f)W(f,p+8,V)r=O(f,p)

0 commit comments

Comments
 (0)