当前位置: 首页>>代码示例>>C++>>正文


C++ BigEndianView::read方法代码示例

本文整理汇总了C++中BigEndianView::read方法的典型用法代码示例。如果您正苦于以下问题:C++ BigEndianView::read方法的具体用法?C++ BigEndianView::read怎么用?C++ BigEndianView::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigEndianView的用法示例。


在下文中一共展示了BigEndianView::read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

bool
readRelocationAddend(BigEndianView &in, Rela &rela)
{
   in.read(rela.offset);
   in.read(rela.info);
   in.read(rela.addend);
   return true;
}
开发者ID:aspico,项目名称:wiiu-emu,代码行数:8,代码来源:elf.cpp

示例2: readSectionHeader

bool
readSections(BigEndianView &in, Header &header, std::vector<Section> &sections)
{
   sections.resize(header.shnum);

   for (auto i = 0u; i < sections.size(); ++i) {
      auto &section = sections[i];

      // Read section header
      in.seek(header.shoff + header.shentsize * i);
      readSectionHeader(in, section.header);

      if ((section.header.type == SHT_NOBITS) || !section.header.size) {
         continue;
      }

      // Read section data
      if (section.header.flags & SHF_DEFLATED) {
         auto stream = z_stream {};
         auto ret = Z_OK;

         // Read the original size
         in.seek(section.header.offset);
         section.data.resize(in.read<uint32_t>());

         // Inflate
         memset(&stream, 0, sizeof(stream));
         stream.zalloc = Z_NULL;
         stream.zfree = Z_NULL;
         stream.opaque = Z_NULL;

         ret = inflateInit(&stream);

         if (ret != Z_OK) {
            gLog->error("Couldn't decompress .rpx section because inflateInit returned {}", ret);
            section.data.clear();
         } else {
            stream.avail_in = section.header.size;
            stream.next_in = in.readRaw<Bytef>(section.header.size);
            stream.avail_out = static_cast<uInt>(section.data.size());
            stream.next_out = reinterpret_cast<Bytef*>(section.data.data());

            ret = inflate(&stream, Z_FINISH);

            if (ret != Z_OK && ret != Z_STREAM_END) {
               gLog->error("Couldn't decompress .rpx section because inflate returned {}", ret);
               section.data.clear();
            }

            inflateEnd(&stream);
         }
      } else {
         section.data.resize(section.header.size);
         in.seek(section.header.offset);
         in.read(section.data.data(), section.header.size);
      }
   }

   return true;
}
开发者ID:aspico,项目名称:wiiu-emu,代码行数:60,代码来源:elf.cpp

示例3: memset

bool
readSectionData(BigEndianView &in, const SectionHeader& header, std::vector<uint8_t> &data)
{
   if (header.type == SHT_NOBITS || header.size == 0) {
      data.clear();
      return true;
   }

   if (header.flags & SHF_DEFLATED) {
      auto stream = z_stream{};
      auto ret = Z_OK;

      // Read the original size
      in.seek(header.offset);
      data.resize(in.read<uint32_t>());

      // Inflate
      memset(&stream, 0, sizeof(stream));
      stream.zalloc = Z_NULL;
      stream.zfree = Z_NULL;
      stream.opaque = Z_NULL;

      ret = inflateInit(&stream);

      if (ret != Z_OK) {
         gLog->error("Couldn't decompress .rpx section because inflateInit returned {}", ret);
         data.clear();
      } else {
         stream.avail_in = header.size;
         stream.next_in = const_cast<Bytef*>(in.readRaw<Bytef>(header.size));
         stream.avail_out = static_cast<uInt>(data.size());
         stream.next_out = reinterpret_cast<Bytef*>(data.data());

         ret = inflate(&stream, Z_FINISH);

         if (ret != Z_OK && ret != Z_STREAM_END) {
            gLog->error("Couldn't decompress .rpx section because inflate returned {}", ret);
            data.clear();
         }

         inflateEnd(&stream);
      }
   } else {
      data.resize(header.size);
      in.seek(header.offset);
      in.read(data.data(), header.size);
   }

   return data.size() > 0;
}
开发者ID:ZilverXZX,项目名称:wiiu-emu,代码行数:50,代码来源:elf.cpp

示例4: assert

bool
readHeader(BigEndianView &in, Header &header)
{
   in.read(header.magic);
   in.read(header.fileClass);
   in.read(header.encoding);
   in.read(header.elfVersion);
   in.read(header.abi);
   in.read(header.pad);
   in.read(header.type);
   in.read(header.machine);
   in.read(header.version);
   in.read(header.entry);
   in.read(header.phoff);
   in.read(header.shoff);
   in.read(header.flags);
   in.read(header.ehsize);
   in.read(header.phentsize);
   in.read(header.phnum);
   in.read(header.shentsize);
   in.read(header.shnum);
   in.read(header.shstrndx);

   if (header.magic != Header::Magic) {
      gLog->error("Unexpected elf magic, found {:08x} expected {:08x}", header.magic, Header::Magic);
      return false;
   }

   if (header.fileClass != ELFCLASS32) {
      gLog->error("Unexpected elf file class, found {:02x} expected {:02x}", header.fileClass, ELFCLASS32);
      return false;
   }

   if (header.encoding != ELFDATA2MSB) {
      gLog->error("Unexpected elf encoding, found {:02x} expected {:02x}", header.encoding, ELFDATA2MSB);
      return false;
   }

   if (header.machine != EM_PPC) {
      gLog->error("Unexpected elf machine, found {:04x} expected {:04x}", header.machine, EM_PPC);
      return false;
   }

   if (header.elfVersion != EV_CURRENT) {
      gLog->error("Unexpected elf version, found {:02x} expected {:02x}", header.elfVersion, EV_CURRENT);
      return false;
   }

   assert(header.shentsize == sizeof(SectionHeader));
   return true;
}
开发者ID:aspico,项目名称:wiiu-emu,代码行数:51,代码来源:elf.cpp

示例5: parseGSH

bool parseGSH(BigEndianView &fh)
{
   gsh::Header header;
   fh.read(header.magic);

   if (header.magic != gsh::Header::Magic) {
      std::cout << "Unexpected gsh magic " << header.magic << std::endl;
      return false;
   }

   fh.read(header.unk1);
   fh.read(header.unk2);
   fh.read(header.unk3);
   fh.read(header.unk4);
   fh.read(header.unk5);
   fh.read(header.unk6);
   fh.read(header.unk7);

   while (!fh.eof()) {
      gsh::Block block;
      fh.read(block.magic);

      if (block.magic != gsh::Block::Magic) {
         std::cout << "Unexpected block magic " << header.magic << std::endl;
         return false;
      }

      fh.read(block.unk1);
      fh.read(block.unk2);
      fh.read(block.unk3);
      fh.read(block.type);
      fh.read(block.dataLength);
      fh.read(block.unk4);
      fh.read(block.unk5);

      block.data.resize(block.dataLength);
      fh.read<uint8_t>(block.data);

      if (block.type == gsh::Block::VertexShader || block.type == gsh::Block::PixelShader) {
         std::string out;
         latte::disassemble(out, block.data);
         std::cout << "----------------------------------------------" << std::endl;
         std::cout << "                  Disassembly                 " << std::endl;
         std::cout << "----------------------------------------------" << std::endl;
         std::cout << out << std::endl;
         std::cout << std::endl;

         latte::Shader shader;
         latte::decode(shader, block.data);
         std::cout << "----------------------------------------------" << std::endl;
         std::cout << "                    Blocks                    " << std::endl;
         std::cout << "----------------------------------------------" << std::endl;
         latte::blockify(shader);
         std::cout << std::endl;

         std::string hlsl;
         latte::generateHLSL(shader, hlsl);
         std::cout << "----------------------------------------------" << std::endl;
         std::cout << "                     HLSL                     " << std::endl;
         std::cout << "----------------------------------------------" << std::endl;
         std::cout << hlsl << std::endl;
         std::cout << std::endl;
      }
   }

   return true;
}
开发者ID:7heaven,项目名称:wiiu-emu,代码行数:67,代码来源:gsh-disassemble.cpp


注:本文中的BigEndianView::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。