clientbot/tools/CPersistentDataRecord.py

696 lines
33 KiB
Python
Raw Normal View History

2019-10-24 17:45:24 +00:00
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# module CPersistentDataRecord
#
# Copyright (C) 2019 AleaJactaEst
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import sys
from tools import Enum
from tools import CArg
from tools import TExtendType
from tools import CBNPCategorySet
from tools import CBNPFile
from tools import CBNPFileVersion
LOGGER='CPersistentDataRecord'
class CPersistentDataRecord:
def __init__(self):
self.TokenTable = []
self.ArgTable = []
self.StringTable = [ ]
self.ReadingStructStack = []
self.offsetToken = 0
self.ArgOffset = 0
self.version = 0
self.totalSize = 0
self.tokenCount = 0
self.argCount = 0
self.stringCount = 0
self.stringsSize = 0
self.CBNPFile = []
self.Categories = []
def show(self):
for x in self.CBNPFile:
logging.getLogger(LOGGER).debug("File:%s" % str(x))
for x in self.Categories:
logging.getLogger(LOGGER).debug("Categorie:%s" % str(x))
# ---------------- Manipulate Token ----------------
# +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
# +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
# | Token ID | Token Type |
# +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
def token2Type(self, token, extend): # persistent_data_inline.h:1102 CPersistentDataRecord::CArg::TType CPersistentDataRecord::CArg::token2Type(uint32 token,bool extend)
logging.getLogger(LOGGER).debug("token:%d, extend:%d" % (token, extend))
if token == Enum.Card.BEGIN_TOKEN:
return Enum.TType.STRUCT_BEGIN
elif token == Enum.Card.END_TOKEN:
return Enum.TType.STRUCT_END
elif token == Enum.Card.FLAG_TOKEN:
return Enum.TType.FLAG
elif token == Enum.Card.SINT_TOKEN:
if extend:
return Enum.TType.SINT64
else:
return Enum.TType.SINT32
elif token == Enum.Card.UINT_TOKEN:
if extend:
return Enum.TType.UINT64
else:
return Enum.TType.UINT32
elif token == Enum.Card.FLOAT_TOKEN:
if extend:
return Enum.TType.FLOAT64
else:
return Enum.TType.FLOAT32
elif token == Enum.Card.STRING_TOKEN:
if extend:
return Enum.TType.EXTEND_TYPE
else:
return Enum.TType.STRING
logging.getLogger(LOGGER).error('This should never happen!')
sys.exit(2)
def type2Token(self, type): # persistent_data_inline.h:1118 CPersistentDataRecord::TToken CPersistentDataRecord::CArg::type2Token(uint32 type)
logging.getLogger(LOGGER).debug("type: %d" %(type))
if type == Enum.TType.STRUCT_BEGIN:
return Enum.Card.BEGIN_TOKEN
elif type == Enum.TType.STRUCT_END:
return Enum.Card.END_TOKEN
elif type == Enum.TType.FLAG:
return Enum.Card.FLAG_TOKEN
elif type == Enum.TType.SINT32:
return Enum.Card.SINT_TOKEN
elif type == Enum.TType.UINT32:
return Enum.Card.UINT_TOKEN
elif type == Enum.TType.FLOAT32:
return Enum.Card.FLOAT_TOKEN
elif type == Enum.TType.STRING:
return Enum.Card.STRING_TOKEN
elif type == Enum.TType.SINT64:
return Enum.Card.SINT_TOKEN
elif type == Enum.TType.UINT64:
return Enum.Card.UINT_TOKEN
elif type == Enum.TType.FLOAT64:
return Enum.Card.FLOAT_TOKEN
elif type == Enum.TType.EXTEND_TYPE:
return Enum.Card.STRING_TOKEN
logging.getLogger(LOGGER).error('This should never happen!')
sys.exit(2)
def peekNextToken(self):
token = self.TokenTable[self.offsetToken]
logging.getLogger(LOGGER).debug("[%d] token:%d" %(self.offsetToken, token))
return token // 8 # persistent_data_inline.h:308 CPersistentDataRecord::TToken CPersistentDataRecord::peekNextToken() # _TokenTable[_TokenOffset]>>3;
def peekNextTokenType(self): # persistent_data_limit.h:308 CPersistentDataRecord::TToken CPersistentDataRecord::peekNextToken() const
logging.getLogger(LOGGER).debug("peekNextTokenType - old offset token:%d" % self.offsetToken)
if self.isEndOfData():
logging.getLogger(LOGGER).error('Attempt to read past end of input data')
sys.exit(2)
token = self.TokenTable[self.offsetToken]
tokenType = token & 7
if tokenType == Enum.Card.EXTEND_TOKEN:
if self.offsetToken + 1 > self.tokenCount:
logging.getLogger(LOGGER).error('Attempt to read past end of input data')
sys.exit(2)
tokenType = self.TokenTable[self.offsetToken+1]
logging.getLogger(LOGGER).debug("peekNextTokenType [%d] token:%d type:%d" %(self.offsetToken, token, tokenType))
return self.token2Type(tokenType, True)
logging.getLogger(LOGGER).debug("peekNextTokenType [%d] token:%d type:%d" %(self.offsetToken, token, tokenType))
return self.token2Type(tokenType, False)
def isEndOfData(self):
if self.offsetToken == self.tokenCount:
return True
return False
def isEndOfStruct(self):
if self.isEndOfData():
logging.getLogger(LOGGER).debug("isEndOfData")
return True
elif len(self.ReadingStructStack) == 0:
logging.getLogger(LOGGER).debug("ReadingStructStack")
return False
elif self.peekNextTokenType() != Enum.TType.STRUCT_END:
logging.getLogger(LOGGER).debug("peekNextTokenType != Enum.TType.STRUCT_END")
return False
elif self.ReadingStructStack[-1] != self.peekNextToken():
logging.getLogger(LOGGER).error("Opening and closing structure tokens don't match")
sys.exit(2)
logging.getLogger(LOGGER).debug("isEndOfStruct")
return True
def isStartOfStruct(self):
if self.peekNextTokenType() == Enum.TType.STRUCT_BEGIN:
return True
return False
def popStructBegin(self, token):
if self.peekNextToken() != token:
logging.getLogger(LOGGER).error('Attempting to enter a structure with the wrong delimiting token')
sys.exit(2)
if self.peekNextTokenType() != Enum.TType.STRUCT_BEGIN:
logging.getLogger(LOGGER).error('Attempting to leave a structure with the wrong delimiting token type')
sys.exit(2)
self.ReadingStructStack.append(token)
self.offsetToken += 1
def popStructEnd(self, token):
if len(self.ReadingStructStack) == 0:
logging.getLogger(LOGGER).error('Attempting to pop end of a structure with nothing left in the open structure stack')
sys.exit(2)
nextToken = self.peekNextToken()
topToken = self.ReadingStructStack[-1]
if topToken != token:
logging.getLogger(LOGGER).error('Attempting to pop end of a structure with the wrong delimiting token')
sys.exit(2)
if nextToken != token:
logging.getLogger(LOGGER).error('Attempting to pop end of a structure with the wrong delimiting token')
sys.exit(2)
if self.peekNextTokenType() != Enum.TType.STRUCT_END:
logging.getLogger(LOGGER).error('Attempting to leave a structure with the wrong delimiting token type')
sys.exit(2)
del self.ReadingStructStack[-1]
self.offsetToken += 1
# ---------------- Manipulate StringTable ----------------
def lookupString(self, idx):
if idx >= self.stringCount:
logging.getLogger(LOGGER).error("Attempting to access past end of string table")
sys.exit(2)
return self.StringTable[idx]
# ---------------- Manipulate Arg ----------------
def peekNextArg(self): # persistent_data_limit.h:339 CPersistentDataRecord::peekNextArg(CPersistentDataRecord::CArg& result) const
_type = self.peekNextTokenType()
result = CArg.CArg()
result.write_Type(_type)
result.write_Type64(False)
logging.getLogger(LOGGER).debug("peekNextArg - Type:%d ArgOffset:%d" % (_type, self.ArgOffset))
if result.isExtended():
logging.getLogger(LOGGER).debug("Extended")
result.write_i32_1(self.ArgTable[self.ArgOffset])
result.write_i32_2(self.ArgTable[self.ArgOffset+1])
if result.read_Type() == Enum.TType.EXTEND_TYPE and result.read_ExType() == TExtendType.TExtendType.ET_64_BIT_EXTENDED_TYPES:
result.write_ex32_2(self.ArgTable[self.ArgOffset+2]);
result.write_Type64(True)
elif not result.isFlag():
# result._Value.i32_1 = _ArgTable[_ArgOffset];
result.write_i32_1(self.ArgTable[self.ArgOffset])
logging.getLogger(LOGGER).debug("peekNextArg - id :%d" % result.read_i32_1())
if result.read_Type() == Enum.TType.STRING:
result.write_String(self.lookupString(result.read_i32_1()))
logging.getLogger(LOGGER).debug("peekNextArg - String:%s" % result.read_String())
return result
def popNextArg(self, token): # persistent_data_limit.h:414 CPersistentDataRecord::popNextArg(TToken token,CPersistentDataRecord::CArg& result)
result = self.peekNextArg()
if result.isFlag():
self.offsetToken += 1
elif result.isExtended():
self.ArgOffset += 2
self.offsetToken += 2
if result.read_Type() == Enum.TType.EXTEND_TYPE and result.read_ExType() == TExtendType.TExtendType.ET_64_BIT_EXTENDED_TYPES:
self.ArgOffset += 1
self.offsetToken += 1
else:
self.ArgOffset += 1
self.offsetToken += 1
logging.getLogger(LOGGER).debug("popNextArg - Arg:%d", result.read_i32_1())
return result
def popString(self, token):
TempArg = self.popNextArg(token)
return TempArg.asString()
def popUint32(self, token):
TempArg = self.popNextArg(token)
return TempArg.asUint()
def popBool(self, token):
TempArg = self.popNextArg(token)
return TempArg.asUint() != 0
# ---------------- Read Data ----------------
def readFromBinFile(self, filename): # persistent_data.cpp:835 # bool CPersistentDataRecord::fromBuffer(const char *src, uint32 bufferSize)
logging.getLogger(LOGGER).debug('Read Bin File %s' % filename)
with open(filename, "rb") as fp:
buffer = fp.read()
fp.close()
self.version = int.from_bytes(buffer[0:4], byteorder='little', signed=False)
self.totalSize = int.from_bytes(buffer[4:8], byteorder='little', signed=False)
self.tokenCount = int.from_bytes(buffer[8:12], byteorder='little', signed=False)
self.argCount = int.from_bytes(buffer[12:16], byteorder='little', signed=False)
self.stringCount = int.from_bytes(buffer[16:20], byteorder='little', signed=False)
self.stringsSize = int.from_bytes(buffer[20:24], byteorder='little', signed=False)
offset = 24
logging.getLogger(LOGGER).debug("version:%d, totalSize:%d, tokenCount:%d, argCount:%d, stringCount:%d, stringsSize:%d" % (self.version, self.totalSize, self.tokenCount, self.argCount, self.stringCount, self.stringsSize))
if len(buffer) != self.totalSize:
logging.getLogger(LOGGER).error("Failed to parse buffer due to invalid header (file:%s, size:%d, size define:%d)" % (filename, len(buffer), self.totalSize ))
sys.exit(2)
if self.version > 0:
logging.getLogger(LOGGER).error("PDR ERROR: Wrong file format version! (file:%s, version:%d)" % (filename, self.version))
sys.exit(2)
if (self.stringCount != 0 and self.stringsSize == 0) or (self.stringCount == 0 and self.stringsSize != 0):
logging.getLogger(LOGGER).error("PDR ERROR: Invalid string table parameters! (file:%s, stringCount:%d, stringsSize:%d)" % (filename, self.stringCount, self.stringsSize))
sys.exit(2)
# i = offset+tokenCount*sizeof(TToken)+argCount*sizeof(uint32)+stringsSize
i = offset + self.tokenCount * 2 + self.argCount * 4 + self.stringsSize;
if self.totalSize != i:
logging.getLogger(LOGGER).error("PDR ERROR: Invalid source data (file:%s, totalSize:%d != datasize:%s)" % (filename, self.totalSize, i))
sys.exit(2)
# READ the tokens
self.TokenTable = []
for i in range(0, self.tokenCount):
tmp = int.from_bytes(buffer[offset:offset+2], byteorder='little', signed=False)
logging.getLogger(LOGGER).debug("token %5d => %3d id:%3d type:%d" %(i, tmp, tmp // 8, tmp & 7))
self.TokenTable.append(tmp)
offset += 2
# READ the arguments
self.ArgTable = []
for i in range(0, self.argCount):
tmp = int.from_bytes(buffer[offset:offset+4], byteorder='little', signed=False)
self.ArgTable.append(tmp)
offset += 4
# READ the string table data
if self.stringsSize != 0:
chaine = ''
self.StringTable = [ ]
while offset < self.totalSize:
car = buffer[offset:offset+1].decode()
if car != '\0':
chaine += car
else:
self.StringTable.append(chaine)
chaine = ''
offset += 1
logging.getLogger(LOGGER).debug(self.StringTable)
if chaine != '':
logging.getLogger(LOGGER).error("PDR ERROR: Too few strings found in string table (file:%s)" % (filename))
sys.exit(2)
logging.getLogger(LOGGER).debug("Red %s" % filename)
def decrypt_token(self):
i = 0
lvl = 0
posArg = 0
extend = False
extend64 = False
result = CArg.CArg()
print("^ Position ^ Token ^")
for value in self.TokenTable:
print("| %5d | %3d |" %(i, value))
i += 1
i = 0
print("^ Position ^ Argument ^")
for value in self.ArgTable:
print("| %5d | %3d |" %(i, value))
i += 1
i = 0
print("^ Position ^ String ^")
for value in self.StringTable:
print("| %5d | %s |" %(i, value))
i += 1
i = 0
print("^ Position ^ Niveau ^ Token ^ Token ID ^^ Token Type (Card) ^^^ Result ^")
print("^ ^^ (entrée) ^ Valeur ^ Quoi ^ Valeur ^ Card ^ Type ^ ^")
for token in self.TokenTable:
tokenId = token // 8
tokenTypeValue = token & 7
result.write_String("-")
if tokenTypeValue == 0:
tokenCard = 'BEGIN_TOKEN'
tokenType = 'STRUCT_BEGIN'
result.write_Type(Enum.TType.STRUCT_BEGIN)
if lvl <= 1:
print("| |||||||")
lvl += 1
elif tokenTypeValue == 1:
tokenCard = 'END_TOKEN'
tokenType = 'STRUCT_END'
result.write_Type(Enum.TType.STRUCT_END)
extend = False
extend64 = False
elif tokenTypeValue == 2:
tokenCard = 'SINT_TOKEN'
if extend:
tokenType = 'SINT64'
result.write_Type(Enum.TType.SINT64)
result.write_i32_1(self.ArgTable[posArg])
result.write_i32_2(self.ArgTable[posArg+1])
if extend64:
result.write_ex32_2(self.ArgTable[posArg+2]);
posArg += 3
else:
posArg += 2
else:
tokenType = 'SINT32'
result.write_Type(Enum.TType.SINT32)
result.write_i32_1(self.ArgTable[posArg])
posArg += 1
extend = False
extend64 = False
elif tokenTypeValue == 3:
tokenCard = 'UINT_TOKEN'
if extend:
tokenType = 'UINT64'
result.write_Type(Enum.TType.UINT64)
result.write_i32_1(self.ArgTable[posArg])
result.write_i32_2(self.ArgTable[posArg+1])
if extend64:
result.write_ex32_2(self.ArgTable[posArg+2]);
posArg += 3
else:
posArg += 2
else:
tokenType = 'UINT32'
result.write_Type(Enum.TType.UINT32)
result.write_i32_1(self.ArgTable[posArg])
posArg += 1
extend = False
extend64 = False
elif tokenTypeValue == 4:
tokenCard = 'FLOAT_TOKEN'
if extend:
tokenType = 'FLOAT64'
result.write_Type(Enum.TType.FLOAT64)
result.write_i32_1(self.ArgTable[posArg])
result.write_i32_2(self.ArgTable[posArg+1])
if extend64:
result.write_ex32_2(self.ArgTable[posArg+2]);
posArg += 3
else:
posArg += 2
else:
tokenType = 'FLOAT32'
result.write_Type(Enum.TType.FLOAT32)
result.write_i32_1(self.ArgTable[posArg])
posArg += 1
extend = False
extend64 = False
elif tokenTypeValue == 5:
tokenCard = 'STRING_TOKEN'
if extend:
tokenType = 'EXTEND_TYPE'
result.write_Type(Enum.TType.EXTEND_TYPE)
result.write_i32_1(self.ArgTable[posArg])
result.write_i32_2(self.ArgTable[posArg+1])
if extend64:
result.write_ex32_2(self.ArgTable[posArg+2]);
posArg += 3
else:
posArg += 2
else:
tokenType = 'STRING'
result.write_Type(Enum.TType.STRING)
result.write_i32_1(self.ArgTable[posArg])
tmp = result.read_i32_1()
result.write_String(self.StringTable[tmp])
posArg += 1
extend = False
extend64 = False
elif tokenType == 6:
tokenCard = 'FLAG_TOKEN'
tokenType = 'FLAG'
result.write_Type(Enum.TType.FLAG)
extend = False
extend64 = False
elif tokenTypeValue == 7:
if extend:
extend64 = True
tokenCard = 'EXTEND_TOKEN'
result.write_Type(Enum.TType.EXTEND_TYPE)
tokenType = ''
extend = True
# print("token %5d => %3d id:%3d [%s] type:%d [%s]" %(i, token, tokenId, self.StringTable[tokenId], tokenType, tokenCard))
print("| %5d | %3d | %3d | %3d | %s | %d | %s | %s | %s |" %(i, lvl, token, tokenId, self.StringTable[tokenId], tokenTypeValue, tokenCard , tokenType, result))
if tokenTypeValue == 1:
lvl -= 1
i += 1
def addString(self, name): # persistent_data.cpp:100 uint16 CPersistentDataRecord::addString(const string& name)
for i in range(0, len(self.StringTable)):
if self.StringTable[i] == name:
return i
self.StringTable.append(name)
return len(self.StringTable) - 1
def CProductDescriptionForClient_apply(self): # persistent_data_template.h:459 # void PERSISTENT_CLASS::apply(CPersistentDataRecord &pdr _PERSISTENT_APPLY_ARGS)
__Tok__MapKey = self.addString("__Key__")
__Tok__MapVal = self.addString("__Val__")
__Tok_Files = self.addString("_Files")
__Tok_Categories = self.addString("_Categories")
logging.getLogger(LOGGER).debug("MapKey:%d, MapVal:%d, Files:%d, Categories:%d" %(__Tok__MapKey, __Tok__MapVal, __Tok_Files, __Tok_Categories))
while not self.isEndOfStruct():
nextToken = self.peekNextToken()
logging.getLogger(LOGGER).debug("nextToken:%d" % (nextToken))
if nextToken == __Tok_Files:
self.popStructBegin(__Tok_Files)
self.CBNPFileSet_apply()
self.popStructEnd(__Tok_Files)
continue
elif nextToken == __Tok_Categories:
self.popStructBegin(__Tok_Categories)
# (_Categories).apply(pdr);
self.CBNPCategorySet_apply()
self.popStructEnd(__Tok_Categories)
continue
logging.getLogger(LOGGER).error("TODO")
sys.exit(2)
def CBNPFileSet_apply(self):
__Tok__MapKey = self.addString("__Key__")
__Tok__MapVal = self.addString("__Val__")
__Tok_Files = self.addString("_Files")
logging.getLogger(LOGGER).debug("MapKey:%d, MapVal:%d, Files:%d" %(__Tok__MapKey, __Tok__MapVal, __Tok_Files))
while not self.isEndOfStruct():
nextToken = self.peekNextToken()
logging.getLogger(LOGGER).debug("nextToken:%d" % (nextToken))
if nextToken == __Tok_Files:
self.popStructBegin(__Tok_Files)
self.CBNPFile.append(CBNPFile.CBNPFile())
self.CBNPFile_apply(self.CBNPFile[-1])
self.popStructEnd(__Tok_Files)
continue
logging.getLogger(LOGGER).error("TODO")
sys.exit(2)
def CBNPFile_apply(self, _CBNPFile):
__Tok__MapKey = self.addString("__Key__")
__Tok__MapVal = self.addString("__Val__")
__Tok_FileName = self.addString("_FileName")
__Tok_Versions = self.addString("_Versions")
_FileName = None
logging.getLogger(LOGGER).debug("MapKey:%d, MapVal:%d, Filename:%d, Versions:%d" %(__Tok__MapKey, __Tok__MapVal, __Tok_FileName, __Tok_Versions))
while not self.isEndOfStruct():
nextToken = self.peekNextToken()
logging.getLogger(LOGGER).debug("nextToken:%d" % (nextToken))
if nextToken == __Tok_FileName:
_FileName = self.popString(nextToken)
_CBNPFile.FileName = _FileName
logging.getLogger(LOGGER).debug("filename: %s" % _FileName)
continue
if nextToken == __Tok_Versions:
self.popStructBegin(__Tok_Versions)
# vectAppend(_Versions).apply(pdr);
_CBNPFile.Versions.append(CBNPFileVersion.CBNPFileVersion())
self.CBNPFileVersion_apply(_CBNPFile.Versions[-1])
self.popStructEnd(__Tok_Versions)
continue
stack = []
while True:
if self.isStartOfStruct():
stack.append(self.peekNextToken())
self.popStructBegin(stack)
elif self.isEndOfStruct():
self.popStructEnd(stack[-1])
if len(stack) > 0:
del stack[-1]
else:
self.popNextArg(self.peekNextToken())
if self.isEndOfData() and len(stack) == 0:
break
logging.getLogger(LOGGER).debug("CBNPFile: %s" % _CBNPFile)
def CBNPFileVersion_apply(self, _CBNPFileVersion): # persistent_data_template.h:459 # void CBNPFileVersion::apply(CPersistentDataRecord &pdr )
__Tok__MapKey = self.addString("__Key__")
__Tok__MapVal = self.addString("__Val__")
__Tok_VersionNumber = self.addString("_VersionNumber")
__Tok_FileSize = self.addString("_FileSize")
__Tok_7ZFileSize = self.addString("_7ZFileSize")
__Tok_FileTime = self.addString("_FileTime")
__Tok_PatchSize = self.addString("_PatchSize")
__Tok_HashKey = self.addString("_HashKey")
logging.getLogger(LOGGER).debug("MapKey:%d, MapVal:%d, VersionNumber:%d, FileSize:%d, 7ZFileSize:%d, FileTime:%d, PatchSize:%d, HashKey:%d" %(__Tok__MapKey, __Tok__MapVal, __Tok_VersionNumber, __Tok_FileSize, __Tok_7ZFileSize, __Tok_FileTime, __Tok_PatchSize, __Tok_HashKey))
while not self.isEndOfStruct():
nextToken = self.peekNextToken()
logging.getLogger(LOGGER).debug("nextToken:%d" % (nextToken))
if nextToken == __Tok_VersionNumber:
logging.getLogger(LOGGER).debug("__Tok_VersionNumber")
_CBNPFileVersion.VersionNumber = self.popUint32(__Tok_VersionNumber)
logging.getLogger(LOGGER).debug("VersionNumber: %s" % _CBNPFileVersion.VersionNumber)
continue
elif nextToken == __Tok_FileSize:
logging.getLogger(LOGGER).debug("__Tok_FileSize")
_CBNPFileVersion.FileSize = self.popUint32(__Tok_FileSize)
logging.getLogger(LOGGER).debug("FileSize: %s" % _CBNPFileVersion.FileSize)
continue
elif nextToken == __Tok_7ZFileSize:
logging.getLogger(LOGGER).debug("__Tok_7ZFileSize")
_CBNPFileVersion.v7ZFileSize = self.popUint32(__Tok_7ZFileSize)
logging.getLogger(LOGGER).debug("7ZFileSize: %s" % _CBNPFileVersion.v7ZFileSize)
continue
elif nextToken == __Tok_FileTime:
logging.getLogger(LOGGER).debug("__Tok_FileTime")
_CBNPFileVersion.FileTime = self.popUint32(__Tok_FileTime)
logging.getLogger(LOGGER).debug("FileTime: %s" % _CBNPFileVersion.FileTime)
continue
elif nextToken == __Tok_PatchSize:
logging.getLogger(LOGGER).debug("__Tok_PatchSize")
_CBNPFileVersion.PatchSize = self.popUint32(__Tok_PatchSize)
logging.getLogger(LOGGER).debug("PatchSize: %s" % _CBNPFileVersion.PatchSize)
continue
elif nextToken == __Tok_HashKey:
logging.getLogger(LOGGER).debug("__Tok_HashKey")
_CBNPFileVersion.HashKey.append(self.popUint32(__Tok_HashKey))
logging.getLogger(LOGGER).debug("HashKey: %s" % _CBNPFileVersion.HashKey[-1])
continue
# Vidage des autres clefs (inconnues)
stack = []
while True:
if self.isStartOfStruct():
stack.append(self.peekNextToken())
self.popStructBegin(stack)
elif self.isEndOfStruct():
self.popStructEnd(stack[-1])
if len(stack) > 0:
del stack[-1]
else:
self.popNextArg(self.peekNextToken())
if self.isEndOfData() and len(stack) == 0:
break
def CBNPCategorySet_apply(self): # persistent_data_template.h:459 # void CBNPCategorySet::apply(CPersistentDataRecord &pdr )
#__Tok__MapKey = self.addString("__Key__")
#__Tok__MapVal = self.addString("__Val__")
__Tok_Category = self.addString("_Category")
while not self.isEndOfStruct():
nextToken = self.peekNextToken()
logging.getLogger(LOGGER).debug("nextToken:%d" % (nextToken))
if nextToken == __Tok_Category:
logging.getLogger(LOGGER).debug("__Tok_Category")
self.popStructBegin(__Tok_Category)
self.Categories.append(CBNPCategorySet.CBNPCategorySet())
self.CBNPCategory_apply(self.Categories[-1])
self.popStructEnd(__Tok_Category)
continue
# Vidage des autres clefs (inconnues)
stack = []
while True:
if self.isStartOfStruct():
stack.append(self.peekNextToken())
self.popStructBegin(stack)
elif self.isEndOfStruct():
self.popStructEnd(stack[-1])
if len(stack) > 0:
del stack[-1]
else:
self.popNextArg(self.peekNextToken())
if self.isEndOfData() and len(stack) == 0:
break
def CBNPCategory_apply(self, _CBNPCategory): # persistent_data_template.h:459 # void CBNPCategory::apply(CPersistentDataRecord &pdr )
__Tok__MapKey = self.addString("__Key__")
__Tok__MapVal = self.addString("__Val__")
__Tok_Name = self.addString("_Name")
__Tok_IsOptional = self.addString("_IsOptional")
__Tok_UnpackTo = self.addString("_UnpackTo")
__Tok_IsIncremental = self.addString("_IsIncremental")
__Tok_CatRequired = self.addString("_CatRequired")
__Tok_Hidden = self.addString("_Hidden")
__Tok_Files = self.addString("_Files")
logging.getLogger(LOGGER).debug("MapKey:%d, MapVal:%d, Name:%d, IsOptional:%d, UnpackTo:%d, IsIncremental:%d, CatRequired:%d, Hidden:%d, Files:%d" %(__Tok__MapKey, __Tok__MapVal, __Tok_Name, __Tok_IsOptional, __Tok_UnpackTo, __Tok_IsIncremental, __Tok_CatRequired, __Tok_Hidden, __Tok_Files))
while not self.isEndOfStruct():
nextToken = self.peekNextToken()
logging.getLogger(LOGGER).debug("nextToken:%d" % (nextToken))
if nextToken == __Tok_Name:
logging.getLogger(LOGGER).debug("__Tok_Name")
_CBNPCategory._Name = self.popString(nextToken)
logging.getLogger(LOGGER).debug("_Name: %s" % _CBNPCategory._Name)
continue
elif nextToken == __Tok_IsOptional:
logging.getLogger(LOGGER).debug("__Tok_IsOptional")
_CBNPCategory._IsOptional = self.popBool(nextToken)
logging.getLogger(LOGGER).debug("_IsOptional: %s" % str(_CBNPCategory._IsOptional))
continue
elif nextToken == __Tok_UnpackTo:
logging.getLogger(LOGGER).debug("__Tok_UnpackTo")
_CBNPCategory._UnpackTo = self.popString(nextToken)
logging.getLogger(LOGGER).debug("_UnpackTo: %s" % str(_CBNPCategory._UnpackTo))
continue
elif nextToken == __Tok_IsIncremental:
logging.getLogger(LOGGER).debug("__Tok_IsIncremental")
_CBNPCategory._IsIncremental = self.popBool(nextToken)
logging.getLogger(LOGGER).debug("_IsIncremental: %s" % str(_CBNPCategory._IsIncremental))
continue
elif nextToken == __Tok_CatRequired:
logging.getLogger(LOGGER).debug("__Tok_CatRequired")
_CBNPCategory._CatRequired = self.popString(nextToken)
logging.getLogger(LOGGER).debug("_CatRequired: %s" % str(_CBNPCategory._CatRequired))
continue
elif nextToken == __Tok_Hidden:
logging.getLogger(LOGGER).debug("__Tok_Hidden")
_CBNPCategory._Hidden = self.popBool(nextToken)
logging.getLogger(LOGGER).debug("_Hidden: %s" % str(_CBNPCategory._Hidden))
continue
elif nextToken == __Tok_Files:
logging.getLogger(LOGGER).debug("__Tok_Files")
_CBNPCategory._Files.append(self.popString(nextToken))
logging.getLogger(LOGGER).debug("_Files: %s" % str(_CBNPCategory._Files))
continue
# Vidage des autres clefs (inconnues)
stack = []
while True:
if self.isStartOfStruct():
stack.append(self.peekNextToken())
self.popStructBegin(stack)
elif self.isEndOfStruct():
self.popStructEnd(stack[-1])
if len(stack) > 0:
del stack[-1]
else:
self.popNextArg(self.peekNextToken())
if self.isEndOfData() and len(stack) == 0:
break