⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newcoff.h

📁 当前支持 16-bit, 32-bit and 64-bit 的二进制文件
💻 H
字号:
// newcoff.h
// Copyright (C) 2009 Willow Schlanger

#ifndef l_newcoff_h__included
#define l_newcoff_h__included

#include "x86s.h"
#include "util.h"
#include <string>
#include <map>
#include <set>
#include <vector>

namespace ceres
{

struct meta_t
{
	U1 length : 4;
	U1 branch : 1;		// =1 if a branch (not call) is here
	U1 target : 1;		// =1 if it's already in our list of targets (1st pass)
	U1 procedure : 1;	// =1 if this is a known procedure entrypoint (scan phase)
						// =1 if this byte should be shown when disassembling
						//    undecompilable instructions (after scan)
	U1 named : 1;		// =1 if target.names[offset] exists (and contains a
						// nonempty strings).
};

// we may want a separate arrays for icode, for the binary itself, and for meta-data.
// newcoff fills out the names[] map but not any metadata.

struct name_t
{
	std::string import_name;
	std::string export_name;
	std::string user_name;				// e.g. from debug symbols
};

class loaded_target_t
{
	public:

	U8 size;
	U8 base;
	U8 start;
	std::string module;					// e.g. MYDLL
	std::map<std::string, U8> exports;	// export name -> offset (no forwarders)
	std::set<std::string> imports;		// e.g. MYDLL.Name or MYDLL.#123 (only for root)
	std::map<U8, name_t> names;			// only used by root
	std::map<int, std::string> ordinals;	// full name, e.g. 3 -> XDLL.RealName
	std::map<std::string, std::string> forwarders;	// e.g. MyName -> XDLL.Alias (not for root)
	std::vector<U8> section_offset;		// for root only
	std::set<U8> relocations;			// for root only
	
	loaded_target_t()
	{
		clear();
	}
	
	~loaded_target_t()
	{
	}
	
	void clear()
	{
		size = 0;
		base = 0;
		start = 0;
		module.clear();
		exports.clear();
		imports.clear();
		names.clear();
	}
};

void load_coff(std::string path, std::string file, loaded_target_t &target, U1 **loaded, dll_finder_t &finder);
void load_coff(dll_finder_t &finder, std::string name, loaded_target_t &target, U1 **loaded);
void load_target(dll_finder_t &finder, std::string name, loaded_target_t &target, U1 **loaded, std::string dbgdir);

}	// namespace ceres

#endif	// l_newcoff_h__included

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -