Esempio n. 1
0
bool GBACheatAddLine(struct GBACheatSet* cheats, const char* line) {
	uint32_t op1;
	uint16_t op2;
	uint16_t op3;
	line = hex32(line, &op1);
	if (!line) {
		return false;
	}
	while (isspace((int) line[0])) {
		++line;
	}
	line = hex16(line, &op2);
	if (!line) {
		return false;
	}
	if (!line[0] || isspace((int) line[0])) {
		return GBACheatAddCodeBreaker(cheats, op1, op2);
	}
	line = hex16(line, &op3);
	if (!line) {
		return false;
	}
	uint32_t realOp2 = op2;
	realOp2 <<= 16;
	realOp2 |= op3;
	return GBACheatAddAutodetect(cheats, op1, realOp2);
}
Esempio n. 2
0
static void
dump_section_table (MonoSectionTable *st)
{
	guint32 flags = st->st_flags;
		
	printf ("\n\tName: %s\n", st->st_name);
	hex32 ("   Virtual Size", st->st_virtual_size);
	hex32 ("Virtual Address", st->st_virtual_address);
	hex32 ("  Raw Data Size", st->st_raw_data_size);
	hex32 ("   Raw Data Ptr", st->st_raw_data_ptr);
	hex32 ("      Reloc Ptr", st->st_reloc_ptr);
	hex32 ("     LineNo Ptr", st->st_lineno_ptr);
	hex16 ("    Reloc Count", st->st_reloc_count);
	hex16 ("     Line Count", st->st_line_count);

	printf ("\tFlags: %s%s%s%s%s%s%s%s%s%s\n",
		(flags & SECT_FLAGS_HAS_CODE) ? "code, " : "",
		(flags & SECT_FLAGS_HAS_INITIALIZED_DATA) ? "data, " : "",
		(flags & SECT_FLAGS_HAS_UNINITIALIZED_DATA) ? "bss, " : "",
		(flags & SECT_FLAGS_MEM_DISCARDABLE) ? "discard, " : "",
		(flags & SECT_FLAGS_MEM_NOT_CACHED) ? "nocache, " : "",
		(flags & SECT_FLAGS_MEM_NOT_PAGED) ? "nopage, " : "",
		(flags & SECT_FLAGS_MEM_SHARED) ? "shared, " : "",
		(flags & SECT_FLAGS_MEM_EXECUTE) ? "exec, " : "",
		(flags & SECT_FLAGS_MEM_READ) ? "read, " : "",
		(flags & SECT_FLAGS_MEM_WRITE) ? "write" : "");
}
Esempio n. 3
0
static void
dump_coff_header (MonoCOFFHeader *coff)
{
	printf ("\nCOFF Header:\n");
	hex16 ("                Machine", coff->coff_machine);
	hex16 ("               Sections", coff->coff_sections);
	hex32 ("             Time stamp", coff->coff_time);
	hex32 ("Pointer to Symbol Table", coff->coff_symptr);
	hex32 ("   	   Symbol Count", coff->coff_symcount);
	hex16 ("   Optional Header Size", coff->coff_opt_header_size);
	hex16 ("   	Characteristics", coff->coff_attributes);

}
Esempio n. 4
0
static void
dump_nt_header (MonoPEHeaderNT *nt)
{
	printf ("\nNT Header:\n");

	hex32 ("   Image Base (0x400000)", nt->pe_image_base);
	hex32 ("Section Alignment (8192)", nt->pe_section_align);
	hex32 ("   File Align (512/4096)", nt->pe_file_alignment);
	hex16 ("            OS Major (4)", nt->pe_os_major);
	hex16 ("            OS Minor (0)", nt->pe_os_minor);
	hex16 ("  	  User Major (0)", nt->pe_user_major);
	hex16 ("  	  User Minor (0)", nt->pe_user_minor);
	hex16 ("  	Subsys major (4)", nt->pe_subsys_major);
	hex16 ("  	Subsys minor (0)", nt->pe_subsys_minor);
	hex32 (" 	       Reserverd", nt->pe_reserved_1);
	hex32 (" 	      Image Size", nt->pe_image_size);
	hex32 (" 	     Header Size", nt->pe_header_size);
	hex32 ("            Checksum (0)", nt->pe_checksum);
	hex16 ("               Subsystem", nt->pe_subsys_required);
	hex16 ("           DLL Flags (0)", nt->pe_dll_flags);
	hex32 (" Stack Reserve Size (1M)", nt->pe_stack_reserve);
	hex32 ("Stack commit Size (4096)", nt->pe_stack_commit);
	hex32 ("  Heap Reserve Size (1M)", nt->pe_heap_reserve);
	hex32 (" Heap Commit Size (4096)", nt->pe_heap_commit);
	hex32 ("      Loader flags (0x1)", nt->pe_loader_flags);
	hex32 ("   Data Directories (16)", nt->pe_data_dir_count);
}
int VnetId_aton(const char *s, VnetId *vnet){
    int err = -EINVAL;
    const char *p, *q;
    uint16_t v;
    char buf[5];
    int buf_n = sizeof(buf) - 1;
    int i, n;
    const int elts_n = VNETID_SIZE16;

    q = s;
    p = strchr(q, ':');
    i = (p ? 0 : elts_n - 1);
    do {
        if(!p){
            if(i < elts_n - 1) goto exit;
            p = s + strlen(s);
        }
        n = p - q;
        if(n > buf_n) goto exit;
        memcpy(buf, q, n);
        buf[n] = '\0';
        err = hex16(buf, &v);
        if(err) goto exit;
        vnet->u.vnet16[i] = htons(v);
        q = p+1;
        p = strchr(q, ':');
        i++;
    } while(i < elts_n);
    err = 0;
  exit:
    if(err){
        *vnet = (VnetId){};
    }
    return err;
}
Esempio n. 6
0
bool GBACheatAddLine(struct mCheatSet* set, const char* line, int type) {
	struct GBACheatSet* cheats = (struct GBACheatSet*) set;
	switch (type) {
	case GBA_CHEAT_AUTODETECT:
		break;
	case GBA_CHEAT_CODEBREAKER:
		return GBACheatAddCodeBreakerLine(cheats, line);
	case GBA_CHEAT_GAMESHARK:
		return GBACheatAddGameSharkLine(cheats, line);
	case GBA_CHEAT_PRO_ACTION_REPLAY:
		return GBACheatAddProActionReplayLine(cheats, line);
	case GBA_CHEAT_VBA:
		return GBACheatAddVBALine(cheats, line);
	default:
		return false;
	}

	uint32_t op1;
	uint16_t op2;
	uint16_t op3;
	const char* lineNext = hex32(line, &op1);
	if (!lineNext) {
		return false;
	}
	if (lineNext[0] == ':') {
		return GBACheatAddVBALine(cheats, line);
	}
	while (isspace((int) lineNext[0])) {
		++lineNext;
	}
	lineNext = hex16(lineNext, &op2);
	if (!lineNext) {
		return false;
	}
	if (!lineNext[0] || isspace((int) lineNext[0])) {
		return GBACheatAddCodeBreaker(cheats, op1, op2);
	}
	lineNext = hex16(lineNext, &op3);
	if (!lineNext) {
		return false;
	}
	uint32_t realOp2 = op2;
	realOp2 <<= 16;
	realOp2 |= op3;
	return GBACheatAddAutodetect(cheats, op1, realOp2);
}
Esempio n. 7
0
static void
dump_pe_header (MonoPEHeader *pe)
{
	printf ("\nPE Header:\n");
	hex16 ("         Magic (0x010b)", pe->pe_magic);
	hex8  ("             LMajor (6)", pe->pe_major);
	hex8  ("             LMinor (0)", pe->pe_minor);
	hex32 ("              Code Size", pe->pe_code_size);
	hex32 ("  Initialized Data Size", pe->pe_data_size);
	hex32 ("Uninitialized Data Size", pe->pe_uninit_data_size);
	hex32 ("        Entry Point RVA", pe->pe_rva_entry_point);
	hex32 (" 	  Code Base RVA", pe->pe_rva_code_base);
	hex32 ("	  Data Base RVA", pe->pe_rva_data_base);
	printf ("\n");
}
Esempio n. 8
0
static int pkconv(char *pd)
{
	char *buf, *p;
	int i;

	if((buf = malloc(INBUFSIZ)) == NULL) {
		error("Memory allocation error");
	}
	p = pd;
	for(i = 0;*p != '\0';++i) {
		if(p[0] == '%' && isxdigit(p[1]) && isxdigit(p[2])) {
			buf[i] = (16 * hex16(p[1])) + hex16(p[2]);
			p = &p[3];
		}
		else if(p[0] == '+') {
			buf[i] = ' ';
			++p;
		}
		else buf[i] = *p++;
	}
	buf[i] = '\0';
	cnvbuff(buf);
	strcpy(pd, buf);
}
Esempio n. 9
0
bool GBACheatAddCodeBreakerLine(struct GBACheatSet* cheats, const char* line) {
	uint32_t op1;
	uint16_t op2;
	line = hex32(line, &op1);
	if (!line) {
		return false;
	}
	while (*line == ' ') {
		++line;
	}
	line = hex16(line, &op2);
	if (!line) {
		return false;
	}
	return GBACheatAddCodeBreaker(cheats, op1, op2);
}
Esempio n. 10
0
static inline int __init parse_eth0_hwaddr(const char *buf, u8 *out)
{
	int i, t;
	u8 addr[6];

	for (i = 0; i < 6; i++) {
		t = hex16(buf);
		if (t == -1)
			return -1;
		addr[i] = t;
		buf += 3;
	}
	memcpy(out, addr, 6);

	return 0;
}
Esempio n. 11
0
uint16_t ihx_record_address(char line[]) {
  return hex16(&line[3]);
}