public static function parse(BinaryStreamParser $parser) { $data = new UserData(); $data->size = $parser->readUInt32(); $data->headerOffset = $parser->readUInt32(); $data->header = $parser->readUInt32(); $data->rawContent = $parser->readBytes($data->size - 12); return $data; }
public static function parse(BinaryStreamParser $parser) { $block = new Block(); $block->filePos = $parser->readUInt32(); $block->compressedSize = $parser->readUInt32(); $block->size = $parser->readUInt32(); $block->flags = $parser->readUInt32(); return $block; }
public function __construct(Stream $stream) { $stream = new BinaryStreamParser($stream); $this->source = $stream->readByte(); $this->namespace = $stream->readUInt32(); $count = $stream->readUInt32(); for ($i = 0; $i < $count; $i++) { $namespace = $stream->readUInt32(); $attrid = $stream->readUInt32(); $scope = $stream->readByte(); $value = trim(strrev($stream->readBytes(4))); if (!isset($this->attributes[$scope])) { $this->attributes[$scope] = array(); } $this->attributes[$scope][$attrid] = new Attribute($attrid, $namespace, $scope, $value); } }
public static function parse(BinaryStreamParser $parser) { $hash = new Hash(); $hash->name1 = $parser->readUInt32(); $hash->name2 = $parser->readUInt32(); $hash->locale = $parser->readUInt16(); $hash->platform = $parser->readUInt16(); $hash->blockIndex = $parser->readUInt32(); return $hash; }
/** * BinaryStreamParser constructor. * @param BitStream $stream */ public function __construct(BitStream $stream) { parent::__construct($stream); $this->stream = $stream; }
public function openStream($fileName) { $block = $this->getFileBlock($fileName); if ($block == NULL) { return NULL; } $stream = clone $this->stream; $stream->seek($this->getUserDataOffset() + $block->getFilePos()); $parser = new BinaryStreamParser($stream); $sectors = array(); if ($block->isChecksumed() || !$block->isSingleUnit()) { $blockSize = 512 * (1 << $this->getHeader()->getBlockSize()); $fileSize = $block->getSize(); for ($i = $fileSize; $i > 0; $i -= $blockSize) { $sectors[] = $parser->readUInt32(); $blockSize -= 4; } $sectors[] = $parser->readUInt32(); } else { $sectors = array(0, $block->getCompressedSize()); } return new BlockStream($this, $stream, $block, $sectors); }
public function __construct(BinaryStreamParser $parser) { $magic = $parser->readBytes(4); if ($magic !== 'IpaM') { throw new MapException('Invalid MapInfo magic header'); } $this->version = $parser->readUInt32(); if ($this->version >= 0x18) { $this->unknown1 = $parser->readUInt32(); $this->unknown2 = $parser->readUInt32(); } $this->width = $parser->readUInt32(); $this->height = $parser->readUInt32(); $this->smallPreviewType = $parser->readUInt32(); if ($this->smallPreviewType == 2) { $this->smallPreviewPath = $parser->readCString(); } $this->largePreviewType = $parser->readUInt32(); if ($this->largePreviewType == 2) { $this->largePreviewPath = $parser->readCString(); } if ($this->version >= 0x1f) { $this->unknown3 = $parser->readCString(); } if ($this->version >= 0x26) { $this->unknown4 = $parser->readCString(); } if ($this->version >= 0x1f) { $this->unknown5 = $parser->readUInt32(); } $this->unknown6 = $parser->readUInt32(); $this->fogType = $parser->readCString(); $this->tileSet = $parser->readCString(); $this->cameraLeft = $parser->readUInt32(); $this->cameraBottom = $parser->readUInt32(); $this->cameraRight = $parser->readUInt32(); $this->cameraTop = $parser->readUInt32(); $this->baseHeight = $parser->readUInt32() / 4096; // ------------------------------------------------------------------------------------------------------------- $this->loadScreenType = $parser->readUInt32(); $this->loadScreenPath = $parser->readCString(); $this->unknown7 = $parser->readBytes($parser->readUInt16()); $this->loadScreenScaling = $parser->readUInt32(); $this->textPosition = $parser->readUInt32(); $this->textPositionOffsetX = $parser->readUInt32(); $this->textPositionOffsetY = $parser->readUInt32(); $this->textPositionSizeX = $parser->readUInt32(); $this->textPositionSizeY = $parser->readUInt32(); $this->dataFlags = $parser->readUInt32(); $this->unknown8 = $parser->readUInt32(); if ($this->version >= 0x19) { $this->unknown9 = $parser->readBytes(8); } if ($this->version >= 0x1f) { $this->unknown10 = $parser->readBytes(9); } if ($this->version >= 0x20) { $this->unknown11 = $parser->readBytes(4); } // there are more fields, but the implementation of them have been ommited }
public static function parse(BinaryStreamParser $parser) { $header = new Header(); $header->size = $parser->readUInt32(); $header->archiveSize = $parser->readUInt32(); $header->formatVersion = $parser->readUInt16(); $header->blockSize = $parser->readUInt16(); $header->hashTablePos = $parser->readUInt32(); $header->blockTablePos = $parser->readUInt32(); $header->hashTableSize = $parser->readUInt32(); $header->blockTableSize = $parser->readUInt32(); if ($header->formatVersion >= self::ARCHIVE_FORMAT_2) { $parser->skip(8); //FIXME HiBlockTablePos64 $header->hashTablePosHi = $parser->readUInt16(); $header->blockTablePosHi = $parser->readUInt16(); } // TODO implement other formats return $header; }
private function createCompressedStream(Sector $sector) { $stream = $this->stream; if ($this->block->isCompressed() && $this->block->getSize() > $this->block->getCompressedSize()) { $parser = new BinaryStreamParser($this->stream); $compressionType = $parser->readByte(); switch ($compressionType) { case 0x0: return $stream; case 0x2: $len = $parser->readUInt16(); $blockData = $stream->readBytes($len); return new MemoryStream(gzinflate($blockData)); // case 0x02: return new CompressedStream($stream, new DeflateCompression()); // case 0x02: return new CompressedStream($stream, new DeflateCompression()); case 0x10: return new CompressedStream($stream, new BZIPCompression()); default: throw new CompressionException(sprintf('Invalid compression format: %s', $compressionType)); } } return $stream; }
public function __construct(BinaryStreamParser $parser) { $parser->readBytes(44); $numDeps = $parser->readByte(); $parser->readBytes(3); while ($numDeps > 0) { while ($parser->readByte() !== 0) { } $numDeps--; } $numAttribs = $parser->readUInt32(); $attribs = array(); while ($numAttribs > 0) { $keyLen = $parser->readUInt16(); $key = $parser->readBytes($keyLen); $locale = hex2bin(dechex($parser->readUInt32())); $valueLen = $parser->readUInt16(); $value = $parser->readBytes($valueLen); $attribs[$key][$locale] = $value; $numAttribs--; } if (isset($attribs['DocInfo/Name'])) { $this->name = $attribs['DocInfo/Name']; } if (isset($attribs['DocInfo/DescShort'])) { $this->shortDescription = $attribs['DocInfo/DescShort']; } if (isset($attribs['DocInfo/DescLong'])) { $this->longDescription = $attribs['DocInfo/DescLong']; } }