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

📄 htsearch.cc

📁 功能较全面的反汇编器:反汇编器ht-2.0.15.tar.gz
💻 CC
📖 第 1 页 / 共 3 页
字号:
bool search_bin_process(Object *context, ht_text *progress_indicator){	ht_search_bin_context *ctx = (ht_search_bin_context*)context;	if (ctx->bufptr - ctx->buf + ctx->patlen > ctx->c) {		if (ctx->file_end) {			*ctx->return_success = false;			return false;		}		ctx->file->seek(ctx->o);		ctx->c = ctx->file->read(ctx->buf, SEARCH_BUF_SIZE);		ctx->bufptr = ctx->buf;		ctx->file_end = (ctx->c != SEARCH_BUF_SIZE);		if (ctx->flags & SFBIN_CASEINSENSITIVE) bufdowncase(ctx->buf, ctx->c);	}	while (ctx->bufptr + ctx->patlen <= ctx->buf + ctx->c) {		if (memcmp(ctx->pat, ctx->bufptr, ctx->patlen) == 0) {			*ctx->return_success = true;			*ctx->return_ofs = ctx->o;			return false;		}		ctx->bufptr++;		ctx->o++;	}	ctx->o -= ctx->patlen-1;	int p = (int)(((double)(ctx->o - ctx->ofs))*100/ctx->len);	char status[64];	ht_snprintf(status, sizeof status, "%d %%", p);	progress_indicator->settext(status);	return true;}/* *	CLASS ht_hexascii_search_form */void ht_hexascii_search_form::init(Bounds *b, int options, List *history){	ht_group::init(b, VO_SELECTABLE, NULL);	VIEW_DEBUG_NAME("ht_hexascii_search_form");	Bounds c;	/* ascii string */	c.x=6;	c.y=0;	c.w=b->w-6;	c.h=1;	str=new ht_strinputfield();	str->init(&c, 64, history);	insert(str);	/* ascii string label */	c.x=0;	c.w=5;	c.h=1;	ht_label *strlabel=new ht_label();	strlabel->init(&c, "~ascii", str);	insert(strlabel);	/* hex string */	c.x=6;	c.y=2;	c.w=b->w-6;	c.h=1;	ht_hexinputfield *hex=new ht_hexinputfield();	hex->init(&c, 64);	hex->attach(str);	insert(hex);	/* hex string label */	c.x=0;	c.w=5;	c.h=1;	ht_label *hexlabel=new ht_label();	hexlabel->init(&c, "~hex", hex);	insert(hexlabel);	/* range start */	c.x=10;	c.y=4;	c.w=10;	c.h=1;	range_start=new ht_strinputfield();	range_start->init(&c, 10);	insert(range_start);	/* range start label */	c.x=0;	c.w=9;	c.h=1;	ht_label *rslabel=new ht_label();	rslabel->init(&c, "~from ofs", range_start);	insert(rslabel);	/* range end */	c.x=10;	c.y=6;	c.w=10;	c.h=1;	range_end=new ht_strinputfield();	range_end->init(&c, 10);	insert(range_end);	/* range end label */	c.x=0;	c.w=9;	c.h=1;	ht_label *relabel=new ht_label();	relabel->init(&c, "~to ofs", range_end);	insert(relabel);	/* options */	c.w=35;	c.y=8;	c.h=2;	ht_string_list *opts = new ht_string_list();	opts->init();	opts->insert_string("case ~insensitive");	option_boxes = new ht_checkboxes();	option_boxes->init(&c, opts);	ht_checkboxes_data d;	d.state = options;	option_boxes->databuf_set(&d, sizeof d);	insert(option_boxes);}/* *	CLASS ht_evalstr_search_form */void ht_evalstr_search_form::init(Bounds *b, int options, List *history){	ht_group::init(b, VO_SELECTABLE, NULL);	VIEW_DEBUG_NAME("ht_evalstr_search_form");	Bounds c;	/* string */	c.x=0;	c.y=1;	c.w=b->w;	c.h=1;	str=new ht_strinputfield();	str->init(&c, 64, history);	insert(str);	/* string label */	c.x=0;	c.y=0;	c.w=23;	c.h=1;	ht_label *strlabel=new ht_label();	strlabel->init(&c, "s~earch evaluated string", str);	insert(strlabel);	/* hint *//*	c.x=0;	c.y=2;	c.w=b->w-2;	c.h=1;	ht_statictext *hint=new ht_statictext();	hint->init(&c, "(example: \"hello\\n\\0\\077\\xd\" 'ho',011b,66o)", 0);	insert(hint);*/	/* range start */	c.x=10;	c.y=4;	c.w=10;	c.h=1;	range_start=new ht_strinputfield();	range_start->init(&c, 10);	insert(range_start);	/* range start label */	c.x=0;	c.w=9;	c.h=1;	ht_label *rslabel=new ht_label();	rslabel->init(&c, "~from ofs", range_start);	insert(rslabel);	/* range end */	c.x=10;	c.y=6;	c.w=10;	c.h=1;	range_end=new ht_strinputfield();	range_end->init(&c, 10);	insert(range_end);	/* range end label */	c.x=0;	c.w=9;	c.h=1;	ht_label *relabel=new ht_label();	relabel->init(&c, "~to ofs", range_end);	insert(relabel);	/* options */	c.w = 35;	c.y = 8;	c.h = 2;	ht_string_list *opts = new ht_string_list();	opts->init();	opts->insert_string("case ~insensitive");	option_boxes = new ht_checkboxes();	option_boxes->init(&c, opts);	ht_checkboxes_data d;	d.state = options;	option_boxes->databuf_set(&d, sizeof d);	insert(option_boxes);}/* *	CLASS ht_vregex_search_form */void ht_vregex_search_form::init(Bounds *b, int options, List *history){	ht_group::init(b, VO_SELECTABLE, NULL);	VIEW_DEBUG_NAME("ht_text_search_form");	Bounds c;	/* string */	c.x=0;	c.y=1;	c.w=b->w;	c.h=1;	str=new ht_strinputfield();	str->init(&c, 64, history);	insert(str);	/* string label */	c.x=0;	c.y=0;	c.w=12;	c.h=1;	ht_label *strlabel=new ht_label();	strlabel->init(&c, "s~earch regex", str);	insert(strlabel);	/* range start */	c.x=10;	c.y=4;	c.w=10;	c.h=1;	range_start=new ht_strinputfield();	range_start->init(&c, 10);	insert(range_start);	/* range start label */	c.x=0;	c.w=9;	c.h=1;	ht_label *rslabel=new ht_label();	rslabel->init(&c, "~from addr", range_start);	insert(rslabel);	/* range end */	c.x=10;	c.y=6;	c.w=10;	c.h=1;	range_end=new ht_strinputfield();	range_end->init(&c, 10);	insert(range_end);	/* range end label */	c.x=0;	c.w=9;	c.h=1;	ht_label *relabel=new ht_label();	relabel->init(&c, "~to addr", range_end);	insert(relabel);	/* options */	c.w = 35;	c.y = 8;	c.h = 2;	ht_string_list *opts = new ht_string_list();	opts->init();	opts->insert_string("case ~insensitive");	option_boxes = new ht_checkboxes();	option_boxes->init(&c, opts);	ht_checkboxes_data d;	d.state = options;	option_boxes->databuf_set(&d, sizeof d);	insert(option_boxes);}/* *	CLASS ht_expr_search_form */void	ht_expr_search_form::init(Bounds *b, int options, List *history){	ht_group::init(b, VO_SELECTABLE, NULL);	VIEW_DEBUG_NAME("ht_expr_search_form");	Bounds c;	/* string */	c.x=0;	c.y=1;	c.w=b->w;	c.h=1;	str=new ht_strinputfield();	str->init(&c, 256, history);	insert(str);	/* string label */	c.x=0;	c.y=0;	c.w=17;	c.h=1;	ht_label *strlabel=new ht_label();	strlabel->init(&c, "s~earch expression", str);	insert(strlabel);	/* hint */	c.x=0;	c.y=2;	c.w=b->w-2;	c.h=1;	ht_statictext *hint=new ht_statictext();	hint->init(&c, "stops if expression evaluates to non-zero", align_left);	insert(hint);	/* range start */	c.x=10;	c.y=4;	c.w=10;	c.h=1;	range_start=new ht_strinputfield();	range_start->init(&c, 10);	insert(range_start);	/* range start label */	c.x=0;	c.w=9;	c.h=1;	ht_label *rslabel=new ht_label();	rslabel->init(&c, "~from ofs", range_start);	insert(rslabel);	/* range end */	c.x=10;	c.y=6;	c.w=10;	c.h=1;	range_end=new ht_strinputfield();	range_end->init(&c, 10);	insert(range_end);	/* range end label */	c.x=0;	c.w=9;	c.h=1;	ht_label *relabel=new ht_label();	relabel->init(&c, "~to ofs", range_end);	insert(relabel);	/* options *//*	c.w=35;	c.y=8;	c.h=2;	ht_string_list *opts=new ht_string_list();	opts->init();	option_boxes=new ht_checkboxes();	option_boxes->init(&c, opts);	ht_checkboxes_data d;	d.state=options;	option_boxes->databuf_set(&d);	insert(option_boxes);*/}/* *	CLASS ht_replace_hexascii_search_form */ht_replace_bin_context::~ht_replace_bin_context(){	free(repl);}ht_view* create_form_replace_hexascii(Bounds *b, uint histid){	ht_replace_hexascii_search_form *form=new ht_replace_hexascii_search_form();	form->init(b, 0, (List*)getAtomValue(histid));	return form;}Object* create_replace_hexascii_context(File *file, FileOfs ofs, FileOfs len, ht_view *form, FileOfs *return_repllen){	ht_replace_hexascii_search_form_data d;	ViewDataBuf vdb(form, &d, sizeof d);		ht_replace_bin_context *ctx = (ht_replace_bin_context*)	create_replace_bin_context(file, ofs, len, d.str.text, d.str.textlen, return_repllen);	return ctx;}void ht_replace_hexascii_search_form::init(Bounds *b, int options, List *history){	ht_group::init(b, VO_SELECTABLE, NULL);	VIEW_DEBUG_NAME("ht_replace_hexascii_search_form");	Bounds c;	/* ascii string */	c.x=6;	c.y=0;	c.w=40;	c.h=1;	str=new ht_strinputfield();	str->init(&c, 64, history);	insert(str);	/* ascii string label */	c.x=0;	c.w=5;	c.h=1;	ht_label *strlabel=new ht_label();	strlabel->init(&c, "~ascii", str);	insert(strlabel);	/* hex string */	c.x=6;	c.y=2;	c.w=40;	c.h=1;	ht_hexinputfield *hex=new ht_hexinputfield();	hex->init(&c, 64);	hex->attach(str);	insert(hex);	/* hex string label */	c.x=0;	c.w=5;	c.h=1;	ht_label *hexlabel=new ht_label();	hexlabel->init(&c, "~hex", hex);	insert(hexlabel);}/* * */static ht_search_method search_methods[] ={	{ "bin: hex/ascii", SC_PHYSICAL, SEARCHMODE_BIN, HISTATOM_SEARCH_BIN,		create_form_hexascii, create_request_hexascii, create_desc_hexascii },	{ "bin: eval str", SC_PHYSICAL, SEARCHMODE_EVALSTR, HISTATOM_SEARCH_EVALSTR,		create_form_evalstr, create_request_evalstr, create_desc_evalstr },	{ "display: regex", SC_VISUAL, SEARCHMODE_VREGEX, HISTATOM_SEARCH_VREGEX,		create_form_vregex, create_request_vregex, create_desc_vregex },	{ "expr non-zero", SC_PHYSICAL, SEARCHMODE_EXPR, HISTATOM_SEARCH_EXPR,		create_form_expr, create_request_expr, create_desc_expr },	{ NULL }};ht_search_request *search_dialog(ht_format_viewer *format, uint searchmodes, viewer_pos *start, viewer_pos *end){	ht_search_request *result = NULL;	Bounds b;	b.w = 50;	b.h = 15;	b.x = (screen->w - b.w)/2;	b.y = (screen->h - b.h)/2;	ht_search_dialog *dialog = new ht_search_dialog();	dialog->init(&b, "search");	Bounds k;	dialog->search_mode_xgroup->getbounds(&k);	k.x = 0;	k.y = 0;	int modes = 0;	int i = 0;	ht_search_method *q = search_methods;	while (q->name) {		if (q->search_mode_mask & searchmodes) {			Bounds v = k;			ht_view *form = q->create_form(&v, q->histid);			dialog->insert_search_mode(i, q->name, form);			modes++;		}		q++;		i++;	}		dialog->select_search_mode(lastsearchmodeid);		if (dialog->run(false)) {		int modeid = dialog->get_search_modeid();		lastsearchmodeid = modeid;		ht_search_method *s = &search_methods[modeid];		ht_view *form = dialog->get_search_modeform();		search_pos sstart, send;		try {			/* create history entry */			if (s->create_desc) {				char hist_desc[1024];				s->create_desc(hist_desc, sizeof hist_desc, form);				insert_history_entry((List*)getAtomValue(s->histid), hist_desc, form);			}			/* create request */			switch (s->search_class) {			case SC_PHYSICAL:				if (!format->pos_to_offset(*start, &sstart.offset)) {					throw MsgfException("Internal error: can't convert viewer_pos to offset");				}				if (!format->pos_to_offset(*end, &send.offset)) {					send.offset = -1;				}				break;			case SC_VISUAL:				sstart.pos = *start;				send.pos = *end;				break;			}			result = s->create_request(&sstart, &send, form, format, s->search_class);			switch (s->search_class) {			case SC_PHYSICAL:				if (!format->offset_to_pos(sstart.offset, start)) {

⌨️ 快捷键说明

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