private void ReadHeader() { var r = this.reader; RecordSize = r.ReadUInt16(); headerSize = r.ReadUInt16(); FileType = (ParadoxFileType)r.ReadByte(); maxTableSize = r.ReadByte(); RecordCount = r.ReadInt32(); nextBlock = r.ReadUInt16(); fileBlocks = r.ReadUInt16(); firstBlock = r.ReadUInt16(); lastBlock = r.ReadUInt16(); unknown12x13 = r.ReadUInt16(); modifiedFlags1 = r.ReadByte(); indexFieldNumber = r.ReadByte(); primaryIndexWorkspace = r.ReadInt32(); unknownPtr1A = r.ReadInt32(); pxRootBlockId = r.ReadUInt16(); pxLevelCount = r.ReadByte(); FieldCount = r.ReadInt16(); primaryKeyFields = r.ReadInt16(); encryption1 = r.ReadInt32(); sortOrder = r.ReadByte(); modifiedFlags2 = r.ReadByte(); unknown2Bx2C = r.ReadBytes(0x002C - 0x002B + 1); changeCount1 = r.ReadByte(); changeCount2 = r.ReadByte(); unknown2F = r.ReadByte(); tableNamePtrPtr = r.ReadInt32(); // ^pchar; fldInfoPtr = r.ReadInt32(); // PFldInfoRec; writeProtected = r.ReadByte(); fileVersionID = r.ReadByte(); maxBlocks = r.ReadUInt16(); unknown3C = r.ReadByte(); auxPasswords = r.ReadByte(); unknown3Ex3F = r.ReadBytes(0x003F - 0x003E + 1); cryptInfoStartPtr = r.ReadInt32(); // pointer; cryptInfoEndPtr = r.ReadInt32(); unknown48 = r.ReadByte(); autoIncVal = r.ReadInt32(); // longint; unknown4Dx4E = r.ReadBytes(0x004E - 0x004D + 1); indexUpdateRequired = r.ReadByte(); unknown50x54 = r.ReadBytes(0x0054 - 0x0050 + 1); refIntegrity = r.ReadByte(); unknown56x57 = r.ReadBytes(0x0057 - 0x0056 + 1); if ((this.FileType == ParadoxFileType.DbFileIndexed || this.FileType == ParadoxFileType.DbFileNotIndexed || this.FileType == ParadoxFileType.XnnFileInc || this.FileType == ParadoxFileType.XnnFileNonInc) && this.fileVersionID >= 5) { this.V4Header = new V4Hdr(r); } var buff = new List <FieldInfo>(); for (int i = 0; i < this.FieldCount; i++) { buff.Add(new FieldInfo(r)); } if (this.FileType == ParadoxFileType.PxFile) { this.FieldCount += 3; buff.Add(new FieldInfo(ParadoxFieldTypes.Short, sizeof(short))); buff.Add(new FieldInfo(ParadoxFieldTypes.Short, sizeof(short))); buff.Add(new FieldInfo(ParadoxFieldTypes.Short, sizeof(short))); } this.FieldTypes = buff.ToArray(); this.tableNamePtr = r.ReadInt32(); if (this.FileType == ParadoxFileType.DbFileIndexed || this.FileType == ParadoxFileType.DbFileNotIndexed) { fieldNamePtrArray = new int[this.FieldCount]; for (int i = 0; i < this.FieldCount; i++) { this.fieldNamePtrArray[i] = r.ReadInt32(); } } var tableNameBuff = r.ReadBytes(this.fileVersionID >= 0x0C ? 261 : 79); this.TableName = Encoding.ASCII.GetString(tableNameBuff, 0, Array.FindIndex(tableNameBuff, b => b == 0)); if (this.FileType == ParadoxFileType.DbFileIndexed || this.FileType == ParadoxFileType.DbFileNotIndexed) { FieldNames = new string[this.FieldCount]; for (int i = 0; i < this.FieldCount; i++) { var fldNameBuff = new StringBuilder(); char ch; while ((ch = r.ReadChar()) != '\x00') { fldNameBuff.Append(ch); } this.FieldNames[i] = fldNameBuff.ToString(); } } }
private void ReadHeader() { var r = this.reader; RecordSize = r.ReadUInt16(); headerSize = r.ReadUInt16(); FileType = (ParadoxFileType) r.ReadByte(); maxTableSize = r.ReadByte(); RecordCount = r.ReadInt32(); nextBlock = r.ReadUInt16(); fileBlocks = r.ReadUInt16(); firstBlock = r.ReadUInt16(); lastBlock = r.ReadUInt16(); unknown12x13 = r.ReadUInt16(); modifiedFlags1 = r.ReadByte(); indexFieldNumber = r.ReadByte(); primaryIndexWorkspace = r.ReadInt32(); unknownPtr1A = r.ReadInt32(); pxRootBlockId = r.ReadUInt16(); pxLevelCount = r.ReadByte(); FieldCount = r.ReadInt16(); primaryKeyFields = r.ReadInt16(); encryption1 = r.ReadInt32(); sortOrder = r.ReadByte(); modifiedFlags2 = r.ReadByte(); unknown2Bx2C = r.ReadBytes(0x002C - 0x002B + 1); changeCount1 = r.ReadByte(); changeCount2 = r.ReadByte(); unknown2F = r.ReadByte(); tableNamePtrPtr = r.ReadInt32(); // ^pchar; fldInfoPtr = r.ReadInt32(); // PFldInfoRec; writeProtected = r.ReadByte(); fileVersionID = r.ReadByte(); maxBlocks = r.ReadUInt16(); unknown3C = r.ReadByte(); auxPasswords = r.ReadByte(); unknown3Ex3F = r.ReadBytes(0x003F - 0x003E + 1); cryptInfoStartPtr = r.ReadInt32(); // pointer; cryptInfoEndPtr = r.ReadInt32(); unknown48 = r.ReadByte(); autoIncVal = r.ReadInt32(); // longint; unknown4Dx4E = r.ReadBytes(0x004E - 0x004D + 1); indexUpdateRequired = r.ReadByte(); unknown50x54 = r.ReadBytes(0x0054 - 0x0050 + 1); refIntegrity = r.ReadByte(); unknown56x57 = r.ReadBytes(0x0057 - 0x0056 + 1); if ((this.FileType == ParadoxFileType.DbFileIndexed || this.FileType == ParadoxFileType.DbFileNotIndexed || this.FileType == ParadoxFileType.XnnFileInc || this.FileType == ParadoxFileType.XnnFileNonInc) && this.fileVersionID >= 5) { this.V4Header = new V4Hdr(r); } var buff = new List<FieldInfo>(); for (int i = 0; i < this.FieldCount; i++) { buff.Add(new FieldInfo(r)); } if (this.FileType == ParadoxFileType.PxFile) { this.FieldCount += 3; buff.Add(new FieldInfo(ParadoxFieldTypes.Short, sizeof(short))); buff.Add(new FieldInfo(ParadoxFieldTypes.Short, sizeof(short))); buff.Add(new FieldInfo(ParadoxFieldTypes.Short, sizeof(short))); } this.FieldTypes = buff.ToArray(); this.tableNamePtr = r.ReadInt32(); if (this.FileType == ParadoxFileType.DbFileIndexed || this.FileType == ParadoxFileType.DbFileNotIndexed) { fieldNamePtrArray = new int[this.FieldCount]; for (int i = 0; i < this.FieldCount; i++) { this.fieldNamePtrArray[i] = r.ReadInt32(); } } var tableNameBuff = r.ReadBytes(this.fileVersionID >= 0x0C ? 261 : 79); this.TableName = Encoding.ASCII.GetString(tableNameBuff, 0, Array.FindIndex(tableNameBuff, b => b == 0)); if (this.FileType == ParadoxFileType.DbFileIndexed || this.FileType == ParadoxFileType.DbFileNotIndexed) { FieldNames = new string[this.FieldCount]; //for (int i = 0; i < this.FieldCount; i++) //{ // var fldNameBuff = new StringBuilder(); // char ch; // while ((ch = r.ReadChar()) != '\x00') fldNameBuff.Append(ch); // this.FieldNames[i] = fldNameBuff.ToString(); //} for (int i = 0; i < this.FieldCount; i++) { if (this.sortOrder == '\x4C') { var fldNameBuff = new StringBuilder(); char ch; while ((ch = r.ReadChar()) != '\x00') fldNameBuff.Append(ch); this.FieldNames[i] = fldNameBuff.ToString(); } else if (this.sortOrder == '\x03') { var fldNameBuff = new List<byte>(); byte by; while ((by = r.ReadByte()) != '\x00') fldNameBuff.Add(by); this.FieldNames[i] = Encoding.GetEncoding("gb2312").GetString(fldNameBuff.ToArray(), 0, fldNameBuff.Count); } } } }