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

📄 htreg.cc

📁 功能较全面的反汇编器:反汇编器ht-2.0.15.tar.gz
💻 CC
📖 第 1 页 / 共 3 页
字号:
/* *	HT Editor *	htreg.cc * *	Copyright (C) 1999-2002 Stefan Weyergraf * *	This program is free software; you can redistribute it and/or modify *	it under the terms of the GNU General Public License version 2 as *	published by the Free Software Foundation. * *	This program is distributed in the hope that it will be useful, *	but WITHOUT ANY WARRANTY; without even the implied warranty of *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *	GNU General Public License for more details. * *	You should have received a copy of the GNU General Public License *	along with this program; if not, write to the Free Software *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#include <errno.h>#include <stdlib.h>#include <string.h>#include "defreg.h"#include "atom.h"#include "htctrl.h"#include "htdialog.h"#include "htiobox.h"#include "htreg.h"#include "log.h"#include "snprintf.h"#include "store.h"#include "tools.h"ht_registry *registry;#define ATOM_HT_REGISTRY		MAGIC32("REG\x00")#define ATOM_HT_REGISTRY_NODE		MAGIC32("REG\x01")#define ATOM_HT_REGISTRY_DATA_STREE	MAGIC32("REG\x02")#define ATOM_HT_REGISTRY_DATA_DWORD	MAGIC32("REG\x03")#define ATOM_HT_REGISTRY_DATA_RAW	MAGIC32("REG\x04")#define ATOM_HT_REGISTRY_DATA_STRING	MAGIC32("REG\x05")#define ATOM_HT_REGISTRY_NODE_TYPE_DESC	MAGIC32("REG\x10")#define ATOM_HT_CREATE_EMPTY_SUBDIR	MAGIC32("REG\x20")#define ATOM_HT_CREATE_EMPTY_SYMLINK	MAGIC32("REG\x21")#define ATOM_HT_CREATE_EMPTY_DWORD	MAGIC32("REG\x22")#define ATOM_HT_CREATE_EMPTY_STRING	MAGIC32("REG\x23")#define ATOM_HT_CREATE_EMPTY_RAW	MAGIC32("REG\x24")/* *	CLASS ht_registry_data */bool ht_registry_data::editdialog(const char *keyname){	return false;}void ht_registry_data::strvalue(char *buf32bytes){	strcpy(buf32bytes, "<unknown>");}/* *	CLASS ht_registry_data_stree */ht_registry_data_stree::ht_registry_data_stree(AVLTree *t){	tree = t;}ht_registry_data_stree::~ht_registry_data_stree(){	delete tree;}void ht_registry_data_stree::load(ObjectStream &f){	GET_OBJECT(f, tree);}ObjectID ht_registry_data_stree::getObjectID() const{	return ATOM_HT_REGISTRY_DATA_STREE;}void ht_registry_data_stree::store(ObjectStream &f) const{ 	PUT_OBJECT(f, tree);}void ht_registry_data_stree::strvalue(char *buf32bytes){	*buf32bytes = 0;}/* *	CLASS ht_registry_data_dword */ht_registry_data_dword::ht_registry_data_dword(uint32 v){	value = v;}bool ht_registry_data_dword::editdialog(const char *keyname){	// FIXME: use eval instead of strtol	char result[32];	ht_snprintf(result, sizeof result, "%d", value);	if (inputbox("edit dword", "number", result, sizeof result, 0)==button_ok) {		char *r;		int i = (int)strtol(result, &r, 10);		if (*r == 0) {			value = i;			return true;		}	}	return false;}void ht_registry_data_dword::load(ObjectStream &f){	GET_INT32X(f, value);}ObjectID ht_registry_data_dword::getObjectID() const{	return ATOM_HT_REGISTRY_DATA_DWORD;}void ht_registry_data_dword::store(ObjectStream &f) const{	PUT_INT32X(f, value);}void ht_registry_data_dword::strvalue(char *buf32bytes){	ht_snprintf(buf32bytes, 32, "%d", value);}/* *	CLASS ht_registry_data_raw */ht_registry_data_raw::ht_registry_data_raw(const void *v, uint s){	size = s;	if (size) {		value = malloc(s);		memcpy(value, v, s);	} else {		value = 0;	}}ht_registry_data_raw::~ht_registry_data_raw(){	free(value);}bool ht_registry_data_raw::editdialog(const char *keyname){	bool r = false;	Bounds b;	b.w = 50;	b.h = 15;	b.x = (screen->w-b.w)/2;	b.y = (screen->h-b.h)/2;		ht_dialog *d = new ht_dialog();	d->init(&b, "edit data_raw", FS_TITLE | FS_KILLER);		if (d->run(false)) {		r = true;	}		d->done();	delete d;	return r;}void ht_registry_data_raw::load(ObjectStream &f){	GET_INT32D(f, size);	GET_BINARY(f, value, size);}ObjectID ht_registry_data_raw::getObjectID() const{	return ATOM_HT_REGISTRY_DATA_RAW;}void ht_registry_data_raw::store(ObjectStream &f) const{	PUT_INT32D(f, size);	PUT_BINARY(f, value, size);}void ht_registry_data_raw::strvalue(char *buf32bytes){	strcpy(buf32bytes, "raw");}/* *	CLASS ht_registry_data_string */                                 ht_registry_data_string::ht_registry_data_string(const char *s){	value = ht_strdup(s);}ht_registry_data_string::~ht_registry_data_string(){	free(value);}bool ht_registry_data_string::editdialog(const char *keyname){	char res[256];	ht_strlcpy(res, value, sizeof res);	if (inputbox("edit string", "string", res, sizeof res, 0)) {		free(value);		value = strdup(res);		return true;	}	return false;}void ht_registry_data_string::load(ObjectStream &f){	GET_STRING(f, value);}ObjectID ht_registry_data_string::getObjectID() const{	return ATOM_HT_REGISTRY_DATA_STRING;}void ht_registry_data_string::store(ObjectStream &f) const{	PUT_STRING(f, value);}void ht_registry_data_string::strvalue(char *buf32bytes){	ht_strlcpy(buf32bytes, value, 32);}/* *	CLASS ht_registry_node */ht_registry_node::ht_registry_node(ht_registry_node_type aType, const char *aName, ht_registry_data *aData){	type = aType;	name = ht_strdup(aName);	data = aData;}ht_registry_node::~ht_registry_node(){	if (data) {		data->done();		delete data;	}	free(name);}int ht_registry_node::compareTo(const Object *o) const{	return strcmp(name, ((ht_registry_node*)o)->name);}void ht_registry_node::load(ObjectStream &f){	GET_INT32X(f, type);	GET_STRING(f, name);	GET_OBJECT(f, data);}void ht_registry_node::store(ObjectStream &f) const{	PUT_INT32X(f, type);	PUT_STRING(f, name);	PUT_OBJECT(f, data);}ObjectID ht_registry_node::getObjectID() const{	return ATOM_HT_REGISTRY_NODE;}/* *	create_empty_* */ht_registry_data *create_empty_symlink(){	return new ht_registry_data_string("");}ht_registry_data *create_empty_dword(){	return new ht_registry_data_dword(0);}ht_registry_data *create_empty_string(){	return new ht_registry_data_string("");}ht_registry_data *create_empty_raw(){	return new ht_registry_data_raw(NULL, 0);}/* *	CLASS ht_registry */ht_registry_node_type_desc::ht_registry_node_type_desc(ht_registry_node_type aType, 	const char *aName, create_empty_registry_data_func c){	type = aType;	name = ht_strdup(aName);	create_empty_registry_data = c;}ht_registry_node_type_desc::~ht_registry_node_type_desc(){	free(name);}int ht_registry_node_type_desc::compareTo(const Object *d) const{	return strcmp(name, ((ht_registry_node_type_desc*)d)->name);}void ht_registry_node_type_desc::load(ObjectStream &f){	GET_INT32D(f, type);	GET_STRING(f, name);	uint atom;	GET_INT32X(f, atom);	void *p = getAtomValue(atom);	create_empty_registry_data=(create_empty_registry_data_func)p;}ObjectID ht_registry_node_type_desc::getObjectID() const{	return ATOM_HT_REGISTRY_NODE_TYPE_DESC;}void ht_registry_node_type_desc::store(ObjectStream &f) const{	PUT_INT32D(f, type);	PUT_STRING(f, name);	uint atom = getAtomId((void*)create_empty_registry_data);	PUT_INT32X(f, atom);}ht_registry_data *create_empty_palette_entry();void ht_registry::init(){#if 0	// build registry root	AVLTree *s = new AVLTree(true);	root = new ht_registry_node(RNT_SUBDIR, "/", new ht_registry_data_stree(s));	AVLTree *config = new AVLTree(true);	AVLTree *palette = new AVLTree(true);	s->insert(new ht_registry_node(RNT_SUBDIR, "config", new ht_registry_data_stree(config)));	s->insert(new ht_registry_node(RNT_SUBDIR, "palette", new ht_registry_data_stree(palette)));	AVLTree *config_misc = new AVLTree(true);	AVLTree *config_editor = new AVLTree(true);	config->insert(new ht_registry_node(RNT_SUBDIR, "misc", new ht_registry_data_stree(config_misc)));	config_misc->insert(new ht_registry_node(RNT_DWORD, "config format", new ht_registry_data_dword(1)));	config_misc->insert(new ht_registry_node(RNT_STRING, "statusline", new ht_registry_data_string("%a %L %t %d")));	config_misc->insert(new ht_registry_node(RNT_STRING, "vfs display format", new ht_registry_data_string("type,name:20+,|,desc,|,bsize,|,perm,|,rmtime")));	config->insert(new ht_registry_node(RNT_SUBDIR, "editor", new ht_registry_data_stree(config_editor)));	config_editor->insert(new ht_registry_node(RNT_STRING, "EOF", new ht_registry_data_string("<EOF>")));	config_editor->insert(new ht_registry_node(RNT_STRING, "EOL", new ht_registry_data_string(".")));

⌨️ 快捷键说明

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