for (i = 0; seg_names[i] != NULL; i++) {
- V3_Print(VM_NONE, VCORE_NONE, "\t%s: Sel=%x, base=%p, limit=%x (long_mode=%d, db=%d)\n", seg_names[i], seg_ptr[i].selector,
- (void *)(addr_t)seg_ptr[i].base, seg_ptr[i].limit,
- seg_ptr[i].long_mode, seg_ptr[i].db);
-
+ V3_Print(VM_NONE, VCORE_NONE, "\t%s: selector=0x%x, base=%p, limit=0x%x type=0x%x system=0x%x dpl=0x%x present=0x%x avail=0x%x long_mode=0x%x db=0x%x granularity=0x%x unusable=0x%x\n",
+ seg_names[i],
+ seg_ptr[i].selector,
+ (void *)(addr_t)seg_ptr[i].base,
+ seg_ptr[i].limit,
+ seg_ptr[i].type,
+ seg_ptr[i].system,
+ seg_ptr[i].dpl,
+ seg_ptr[i].present,
+ seg_ptr[i].avail,
+ seg_ptr[i].long_mode,
+ seg_ptr[i].db,
+ seg_ptr[i].granularity,
+ seg_ptr[i].unusable);
}
}
tmp_ptr += 3; // pass over symbol type
if (sym_offset > rip_val) {
- char * end_ptr = strchr(sym_ptr, '\n');
-
- if (end_ptr) {
- *end_ptr = 0; // null terminate symbol...
+ if (sym_ptr) {
+ char * end_ptr = strchr(sym_ptr, '\n');
+
+ if (end_ptr) {
+ *end_ptr = 0; // null terminate symbol...
+ }
+ sym_name = sym_ptr;
+ } else {
+ sym_name = NULL;
}
-
- sym_name = sym_ptr;
break;
}
sym_ptr = tmp_ptr;
+
{
char * end_ptr2 = strchr(tmp_ptr, '\n');
if (core->mem_mode == PHYSICAL_MEM) {
- v3_gpa_to_hva(core,
- get_addr_linear(core, idtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gpa_to_hva(core,
+ get_addr_linear(core, idtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
PrintError(core->vm_info, core, "Kind of weird that we got here.... physical mem?\n");
} else if (core->mem_mode == VIRTUAL_MEM) {
- v3_gva_to_hva(core,
- get_addr_linear(core, idtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gva_to_hva(core,
+ get_addr_linear(core, idtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
}
// SANITY CHECK
PrintError(core->vm_info, core, "idtr base address != linear translation, might be something funky with cs\n");
}
+ if (!base_hva) {
+ PrintError(core->vm_info, core "idtr address does not translate! skipping.\n");
+ return ;
+ }
+
int i;
char *types[16] = {" ILGL","aTSS16"," LDT","bTSS16","call16"," task","intr16","trap16",
" ILGL","aTSS32"," ILGL","bTSS32","call32"," ILGL","intr32","trap32"};
}
if (core->mem_mode == PHYSICAL_MEM) {
- v3_gpa_to_hva(core,
- get_addr_linear(core, gdtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gpa_to_hva(core,
+ get_addr_linear(core, gdtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
PrintError(core->vm_info, core, "Kind of weird that we got here.... physical mem?\n");
} else if (core->mem_mode == VIRTUAL_MEM) {
- v3_gva_to_hva(core,
- get_addr_linear(core, gdtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gva_to_hva(core,
+ get_addr_linear(core, gdtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
}
// SANITY CHECK
PrintError(core->vm_info, core, "gdtr base address != linear translation, might be something funky with cs\n");
}
+ if (!base_hva) {
+ PrintError(core->vm_info, core "gdtr address does not translate! skipping.\n");
+ return ;
+ }
+
int i;
char* cd[2] = {"data","code"};
- // TODO: handle possibility of gate/segment descriptor
+ char * sys_types[16] = {"rsvd",
+ "rsvd",
+ "64bit LDT",
+ "rsvd",
+ "rsvd",
+ "rsvd",
+ "rsvd",
+ "rsvd",
+ "rsvd",
+ "avail 64bit TSS",
+ "rsvd",
+ "busy 64bit TSS",
+ "64bit call gate",
+ "rsvd",
+ "64bit int gate",
+ "64bit trap gate"};
- struct code_desc_lgcy * entry;
+ struct code_desc_long * entry;
entry = (struct code_desc_long *)base_hva;
V3_Print(core->vm_info, core, "= GDT ========\n");
V3_Print(core->vm_info, core, " # | hex | limit | base | c/d | dpl | p\n");
- for (i = 0; i < NUM_GDT_ENTRIES; i++) {
- V3_Print(core->vm_info, core, "%3d | %3x | %x%04x | %02x%02x%04x | %s | %x | %x\n", i, i,
- entry->limit_hi, entry->limit_lo,
- entry->base_hi, entry->base_mid, entry->base_lo,
- cd[entry->one1], entry->dpl, entry->p);
- entry++;
+ for (i = 0; i < (core->segments.gdtr.limit+1)/8; i++) {
+ if (entry->one2 == 0) { // this is a system descriptor
+ struct system_desc_long* sys = (struct system_desc_long*)entry;
+ V3_Print(core->vm_info, core, "%3d | %3x | %x%04x | %08x%02x%02x%04x | %20s | %x | %x\n", i, i,
+ entry->limit_hi, entry->limit_lo,
+ sys->base_hi, entry->base_hi, entry->base_mid, entry->base_lo,
+ sys_types[sys->type], entry->dpl, entry->p);
+ entry += 2;
+ } else {
+ V3_Print(core->vm_info, core, "%3d | %3x | %x%04x | %08x%02x%02x%04x | %20s | %x | %x\n", i, i,
+ entry->limit_hi, entry->limit_lo,
+ 0, entry->base_hi, entry->base_mid, entry->base_lo,
+ cd[entry->one1], entry->dpl, entry->p);
+ entry++;
+ }
}
}
}
if (core->mem_mode == PHYSICAL_MEM) {
- v3_gpa_to_hva(core,
- get_addr_linear(core, idtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gpa_to_hva(core,
+ get_addr_linear(core, idtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
} else if (core->mem_mode == VIRTUAL_MEM) {
- v3_gva_to_hva(core,
- get_addr_linear(core, idtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gva_to_hva(core,
+ get_addr_linear(core, idtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
}
// SANITY CHECK
PrintError(core->vm_info, core, "idtr base address != linear translation, might be something funky with cs\n");
}
+ if (!base_hva) {
+ PrintError(core->vm_info, core, "idtr address does not translate! skipping.\n");
+ return ;
+ }
+
int i;
char *types[16] = {"ILGL","ILGL"," LDT","ILGL","ILGL","ILGL","ILGL","ILGL","ILGL",
"aTSS","ILGL","bTSS","call","ILGL","intr","trap"};
}
if (core->mem_mode == PHYSICAL_MEM) {
- v3_gpa_to_hva(core,
- get_addr_linear(core, gdtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gpa_to_hva(core,
+ get_addr_linear(core, gdtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
} else if (core->mem_mode == VIRTUAL_MEM) {
- v3_gva_to_hva(core,
- get_addr_linear(core, gdtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gva_to_hva(core,
+ get_addr_linear(core, gdtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
}
// SANITY CHECK
PrintError(core->vm_info, core, "gdtr base address != linear translation, might be something funky with cs\n");
}
+ if (!base_hva) {
+ PrintError(core->vm_info, core, "gdtr address does not translate! skipping.\n");
+ return ;
+ }
+
int i;
- char* cd[2] = {"data","code"};
+ char* cd[2] = {" data"," code"};
// TODO: handle possibility of gate/segment descriptor
+ char *types[16] = {" ILGL"," ILGL"," LDT64"," ILGL"," ILGL"," ILGL"," ILGL"," ILGL",
+ " ILGL","aTSS64"," ILGL","bTSS64","call64"," ILGL","intr64","trap64"};
struct code_desc_long * entry;
entry = (struct code_desc_long *)base_hva;
V3_Print(core->vm_info, core, "= GDT ========\n");
V3_Print(core->vm_info, core, " # | hex | limit | base | c/d | dpl | p\n");
- for (i = 0; i < NUM_GDT_ENTRIES; i++) {
- V3_Print(core->vm_info, core, "%3d | %3x | %x%04x | %02x%02x%04x | %s | %x | %x\n", i, i,
- entry->limit_hi, entry->limit_lo,
- entry->base_hi, entry->base_mid, entry->base_lo,
- cd[entry->one1], entry->dpl, entry->p);
- entry++;
+ for (i = 0; i < (core->segments.gdtr.limit+1)/8; i++) {
+ if (entry->one2 == 0 && *(uint64_t*)entry != 0) { // this is a system descriptor
+ struct system_desc_long* sys = (struct system_desc_long*)entry;
+ V3_Print(core->vm_info, core, "%3d | %3x | %x%04x | %08x%02x%02x%04x | %s | %x | %x\n", i, i,
+ entry->limit_hi, entry->limit_lo,
+ sys->base_hi, entry->base_hi, entry->base_mid, entry->base_lo,
+ types[sys->type], entry->dpl, entry->p);
+ entry += 2;
+ i++;
+ } else {
+ V3_Print(core->vm_info, core, "%3d | %3x | %x%04x | %08x%02x%02x%04x | %s | %x | %x\n", i, i,
+ entry->limit_hi, entry->limit_lo,
+ 0, entry->base_hi, entry->base_mid, entry->base_lo,
+ cd[entry->one1], entry->dpl, entry->p);
+ entry++;
+ }
}
}
}
if (core->mem_mode == PHYSICAL_MEM) {
- v3_gpa_to_hva(core,
- get_addr_linear(core, ldtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gpa_to_hva(core,
+ get_addr_linear(core, ldtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
} else if (core->mem_mode == VIRTUAL_MEM) {
- v3_gva_to_hva(core,
- get_addr_linear(core, ldtr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gva_to_hva(core,
+ get_addr_linear(core, ldtr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
}
// SANITY CHECK
PrintError(core->vm_info, core, "ldtr base address != linear translation, might be something funky with cs\n");
}
+ if (!base_hva) {
+ PrintError(core->vm_info, core, "ldtr address does not translate! skipping.\n");
+ return ;
+ }
+
int i;
char* cd[2] = {"data","code"};
// TODO: handle possibility of gate/segment descriptor
}
if (core->mem_mode == PHYSICAL_MEM) {
- v3_gpa_to_hva(core,
- get_addr_linear(core, tr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gpa_to_hva(core,
+ get_addr_linear(core, tr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
} else if (core->mem_mode == VIRTUAL_MEM) {
- v3_gva_to_hva(core,
- get_addr_linear(core, tr_base, &(core->segments.cs)),
- &base_hva);
+ if (v3_gva_to_hva(core,
+ get_addr_linear(core, tr_base, &(core->segments.cs)),
+ &base_hva)) {
+ PrintError(core->vm_info, core, "Cannot translate address\n");
+ return;
+ }
}
// SANITY CHECK
if (tr_base != get_addr_linear(core, tr_base, &(core->segments.cs))) {
PrintError(core->vm_info, core, "tr base address != linear translation, might be something funky with cs\n");
}
+
+ if (!base_hva) {
+ PrintError(core->vm_info, core, "tr address does not translate! skipping.\n");
+ return ;
+ }
+
t=(struct tss_long*)base_hva;
V3_Print(core->vm_info, core," res1 : 0x%llx\n", (uint64_t) t->res1);