shaderPack = r'C:\ShaderData.dat'
from struct import unpack
import os
shaderdataFloder = r'ShaderData'
os.makedirs(shaderdataFloder,exist_ok=True)
def dint(b):
return unpack("i",b)[0]
def decodeData(data,factor):
factor = factor & 0xff
result = b''
for v3 in range(len(data)):
v4 = data[v3]
eax = v3 + v4
result += bytes([factor ^ v4])
factor = eax & 0xff
return result
shaders = {}
with open(shaderPack,'rb') as fp:
shaderNum = dint(fp.read(4))
for v6 in range(shaderNum):
nameLength = dint(fp.read(4))
cryptedName = fp.read(nameLength)
name = decodeData(cryptedName,v6)
size = dint(decodeData(fp.read(4),v6))
offset = dint(decodeData(fp.read(4),v6))
shaders[name.decode()] = {
"offset":offset,
"size":size,
"factor":v6
}
for filename in shaders:
shader = shaders[filename]
fp.seek(shader["offset"])
data = fp.read(shader["size"])
with open(os.path.join(shaderdataFloder,filename),"wb") as wfp:
wfp.write(decodeData(data,shader["factor"]))