예제 #1
0
	int ComHeaderDirectory::read(unsigned char* buffer, unsigned int buffersize)
	{
		if (buffersize < PELIB_IMAGE_COR20_HEADER::size())
		{
			return ERROR_INVALID_FILE;
		}
		
		std::vector<byte> vComDescDirectory(buffer, buffer + buffersize);
		
		InputBuffer ibBuffer(vComDescDirectory);
		read(ibBuffer);
		return NO_ERROR;
	}
예제 #2
0
	int DebugDirectory::read(unsigned char* buffer, unsigned int buffersize)
	{
		// XXX: Note, debug data is not read at all. This might or might not change
		//      in the future.
		
		std::vector<byte> vDebugDirectory(buffer, buffer + buffersize);
		
		InputBuffer ibBuffer(vDebugDirectory);
		
		std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo = read(ibBuffer, buffersize);
		
		std::swap(currDebugInfo, m_vDebugInfo);
		
		return NO_ERROR;
	}
예제 #3
0
	/**
	* @param strFilename Name of the file which will be read.
	* @param uiOffset File offset of the Debug directory.
	* @param uiSize Size of the Debug directory.
	**/
	int DebugDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
	{
		std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
		unsigned int ulFileSize = fileSize(ifFile);

		if (!ifFile)
		{
			return ERROR_OPENING_FILE;
		}
		
		if (ulFileSize < uiOffset + uiSize)
		{
			return ERROR_INVALID_FILE;
		}

		ifFile.seekg(uiOffset, std::ios::beg);

		std::vector<byte> vDebugDirectory(uiSize);
		ifFile.read(reinterpret_cast<char*>(&vDebugDirectory[0]), uiSize);
		
		InputBuffer ibBuffer(vDebugDirectory);
		
		std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo = read(ibBuffer, uiSize);
		
		for (unsigned int i=0;i<currDebugInfo.size();i++)
		{
			ifFile.seekg(currDebugInfo[i].idd.PointerToRawData, std::ios::beg);
			currDebugInfo[i].data.resize(currDebugInfo[i].idd.SizeOfData);
			ifFile.read(reinterpret_cast<char*>(&currDebugInfo[i].data[0]), currDebugInfo[i].idd.SizeOfData);
			if (!ifFile) return ERROR_INVALID_FILE;
		}
		
		std::swap(currDebugInfo, m_vDebugInfo);
		
		return NO_ERROR;
	}
예제 #4
0
	/**
	* Reads a file's COM+ descriptor.
	* @param strFilename Name of the file.
	* @param uiOffset File offset of the COM+ descriptor.
	* @param uiSize Size of the COM+ descriptor.
	**/
	int ComHeaderDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
	{
		std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
		unsigned int ulFileSize = fileSize(ifFile);

		if (!ifFile)
		{
			return ERROR_OPENING_FILE;
		}
		
		if (ulFileSize < uiOffset + uiSize)
		{
			return ERROR_INVALID_FILE;
		}

		ifFile.seekg(uiOffset, std::ios::beg);

		std::vector<byte> vComDescDirectory(uiSize);
		ifFile.read(reinterpret_cast<char*>(&vComDescDirectory[0]), uiSize);
		
		InputBuffer ibBuffer(vComDescDirectory);
		read(ibBuffer);
		return NO_ERROR;
	}