예제 #1
0
파일: FileIO.cpp 프로젝트: galek/RathEngine
	void FileContainer::read(std::string& str)
	{
		UINT size = 0;
		sgetn((char*)&size, sizeof(size));
		str.resize(size);
		sgetn(&str[0], size);
	}
예제 #2
0
파일: FileIO.cpp 프로젝트: galek/RathEngine
	void FileContainer::readCompressed(void* ptr, unsigned int size)
	{
		uLongf CompressedSpace = 0;
		sgetn((char*)&CompressedSpace, sizeof(CompressedSpace));
		Bytef* CompressedSpaceBuffer = (Bytef*)malloc(CompressedSpace);
		sgetn((char*)CompressedSpaceBuffer, CompressedSpace);
		uLongf UncompressedSize = size;
		uncompress((Bytef*)ptr, &UncompressedSize, CompressedSpaceBuffer, CompressedSpace);
		free(CompressedSpaceBuffer);
	}
예제 #3
0
void
no_copy_membuf::read (char *data, std::streamsize size) {

    // std::streambuf read methodology.
    sgetn((char *)data, size);
    m_current_pos += size;
}
예제 #4
0
void LoaderPacker::ProcessExecutable(
  std::vector<uint8_t>& outFileBuffer,
  const AdditionalDataBlocksType& additionalDataBlocks)
{
  auto loaderBlock = utils::GetSingleAdditionalBlock(additionalDataBlocks, PackerType::kLoaderPacker);

  // get type of source executable
  PlatformType platformType;
  auto sourcePEbits = srcPEFile_->getBits();
  switch (sourcePEbits)
  {
  case 32:
    platformType = PlatformType::x86;
    break;
  case 64:
    platformType = PlatformType::x64;
    break;
  default:
    break;
  }

  auto loaderInfo = std::find_if(gloadersNames.begin(), gloadersNames.end(), [&platformType](LoaderInfo& loaderInfo)->bool
  {
    return loaderInfo.platformType == platformType;
  });

  if (loaderInfo == gloadersNames.end())
  {
    throw std::runtime_error("error finding loader");
  }

  // load loader data
  boost::filesystem::path loaderFullPath = loadersStoragePath_;
  loaderFullPath /= loaderInfo->loaderName;

  boost::filesystem::ifstream loaderFile;
  loaderFile.open(loaderFullPath, std::ios::in || std::ifstream::binary);

  auto pbuf = loaderFile.rdbuf();
  // get file size
  size_t size = static_cast<size_t>(pbuf->pubseekoff(0, loaderFile.end, loaderFile.in));
  pbuf->pubseekpos(0, loaderFile.in);

  std::vector<PeLib::byte> loaderData(size);

  // get file data
  pbuf->sgetn(reinterpret_cast<char*>(loaderData.data()), size);

  loaderFile.close();

  // get stub data offset to update loader code with pointer to stub data ( link stubData to loader )
  ModifyLoaderWithStubDataInfo(loaderData, additionalDataBlocks);

  utils::ReplaceContainerData(outFileBuffer, loaderBlock.rawOffset, loaderData);
}
예제 #5
0
int tfont_width(char const *code)
{
	if(code == NULL) {
		return 0;
	}
	while(*code)
	{
		char c = sgetc(&code);
		switch(c)
		{
			case 0:
			case -1:
				return 0;
			case 'a':
				return scalex(sgetn(&code));
		}
	}
	return 0;
}
예제 #6
0
파일: FileIO.cpp 프로젝트: galek/RathEngine
	void FileContainer::read(void* ptr, unsigned int size)
	{
		sgetn((char*)ptr, size);
	}
예제 #7
0
int tfont_render_glyph(int tx, int ty, char const *code)
{
	if(code == NULL) {
		return 0;
	}
	int advance = 0;
	int x = 0;
	int y = 0;
	int px = 0;
	int py = 0;
	while(*code)
	{
		char c = sgetc(&code);
		switch(c)
		{
			case 0:
			case -1:
				return scale(advance);
			case 'a':
				advance = sgetn(&code);
				break;
			case 'M':
				x = sgetn(&code);
				y = sgetn(&code);
				break;
			case 'm':
				x += sgetn(&code);
				y += sgetn(&code);
				break;
			case 'P':
				x = sgetn(&code);
				y = sgetn(&code);
				line(
					tx + scalex(px), 
					ty - scaley(py), 
					tx + scalex(x), 
					ty - scaley(y));
				break;
			case 'p':
				x += sgetn(&code);
				y += sgetn(&code);
				line(
					tx + scalex(px),
					ty - scaley(py), 
					tx + scalex(x), 
					ty - scaley(y));
				break;
			case 'd':
				dot(
					tx + scalex(x),
					ty - scaley(y));
				break;
			default:
#if TFONT_DEBUG
				printf("Unknown command: %c(%d)?\n", c, c);
#endif
				break;
		}
		px = x;
		py = y;
	}
	return scalex(advance);
}