📄 msc.c
字号:
else
{
if (mod_typeno - FIRST_DEFINABLE_TYPE < mod->num_defined_types)
symt = mod->defined_types[mod_typeno - FIRST_DEFINABLE_TYPE];
}
}
if (!allow_special && symt && symt->tag == SymTagCVBitField)
FIXME("bitfields are only handled for UDTs\n");
if (!symt && typeno) FIXME("Returning NULL symt for type-id %x\n", typeno);
return symt;
}
static int codeview_add_type(unsigned int typeno, struct symt* dt)
{
if (typeno < FIRST_DEFINABLE_TYPE)
FIXME("What the heck\n");
if (!cv_current_module)
{
FIXME("Adding %x to non allowed module\n", typeno);
return FALSE;
}
if ((typeno >> 24) != 0)
FIXME("No module index while inserting type-id assumption is wrong %x\n",
typeno);
while (typeno - FIRST_DEFINABLE_TYPE >= cv_current_module->num_defined_types)
{
cv_current_module->num_defined_types += 0x100;
if (cv_current_module->defined_types)
cv_current_module->defined_types = (struct symt**)
HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
cv_current_module->defined_types,
cv_current_module->num_defined_types * sizeof(struct symt*));
else
cv_current_module->defined_types = (struct symt**)
HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
cv_current_module->num_defined_types * sizeof(struct symt*));
if (cv_current_module->defined_types == NULL) return FALSE;
}
cv_current_module->defined_types[typeno - FIRST_DEFINABLE_TYPE] = dt;
return TRUE;
}
static void codeview_clear_type_table(void)
{
int i;
for (i = 0; i < CV_MAX_MODULES; i++)
{
if (cv_zmodules[i].allowed && cv_zmodules[i].defined_types)
HeapFree(GetProcessHeap(), 0, cv_zmodules[i].defined_types);
cv_zmodules[i].allowed = FALSE;
cv_zmodules[i].defined_types = NULL;
cv_zmodules[i].num_defined_types = 0;
if (cv_zmodules[i].bitfields)
HeapFree(GetProcessHeap(), 0, cv_zmodules[i].bitfields);
cv_zmodules[i].bitfields = NULL;
cv_zmodules[i].num_bitfields = cv_zmodules[i].used_bitfields = 0;
}
cv_current_module = NULL;
}
static int codeview_add_type_pointer(struct module* module, unsigned int typeno,
unsigned int datatype)
{
struct symt* symt = &symt_new_pointer(module,
codeview_get_type(datatype, FALSE))->symt;
return codeview_add_type(typeno, symt);
}
static int codeview_add_type_array(struct module* module,
unsigned int typeno, const char* name,
unsigned int elemtype, unsigned int arr_len)
{
struct symt* symt;
struct symt* elem = codeview_get_type(elemtype, FALSE);
DWORD arr_max = 0;
if (elem)
{
DWORD elem_size;
symt_get_info(elem, TI_GET_LENGTH, &elem_size);
if (elem_size) arr_max = arr_len / elem_size;
}
symt = &symt_new_array(module, 0, arr_max, elem)->symt;
return codeview_add_type(typeno, symt);
}
static int codeview_add_type_bitfield(unsigned int typeno, unsigned int bitoff,
unsigned int nbits, unsigned int basetype)
{
if (cv_current_module->used_bitfields >= cv_current_module->num_bitfields)
{
if (cv_current_module->bitfields)
{
cv_current_module->num_bitfields *= 2;
cv_current_module->bitfields =
HeapReAlloc(GetProcessHeap(), 0,
cv_current_module->bitfields,
cv_current_module->num_bitfields * sizeof(struct codeview_bitfield));
}
else
{
cv_current_module->num_bitfields = 64;
cv_current_module->bitfields =
HeapAlloc(GetProcessHeap(), 0,
cv_current_module->num_bitfields * sizeof(struct codeview_bitfield));
}
if (!cv_current_module->bitfields) return 0;
}
cv_current_module->bitfields[cv_current_module->used_bitfields].symt.tag = SymTagCVBitField;
cv_current_module->bitfields[cv_current_module->used_bitfields].subtype = basetype;
cv_current_module->bitfields[cv_current_module->used_bitfields].bitposition = bitoff;
cv_current_module->bitfields[cv_current_module->used_bitfields].bitlength = nbits;
return codeview_add_type(typeno, &cv_current_module->bitfields[cv_current_module->used_bitfields++].symt);
}
static int codeview_add_type_enum_field_list(struct module* module,
unsigned int typeno,
const unsigned char* list, int len)
{
struct symt_enum* symt;
const unsigned char* ptr = list;
symt = symt_new_enum(module, NULL);
while (ptr - list < len)
{
const union codeview_fieldtype* type = (const union codeview_fieldtype*)ptr;
if (*ptr >= 0xf0) /* LF_PAD... */
{
ptr += *ptr & 0x0f;
continue;
}
switch (type->generic.id)
{
case LF_ENUMERATE_V1:
{
int value, vlen = numeric_leaf(&value, &type->enumerate_v1.value);
const struct p_string* p_name = (const struct p_string*)((const unsigned char*)&type->enumerate_v1.value + vlen);
symt_add_enum_element(module, symt, terminate_string(p_name), value);
ptr += 2 + 2 + vlen + (1 + p_name->namelen);
break;
}
case LF_ENUMERATE_V3:
{
int value, vlen = numeric_leaf(&value, &type->enumerate_v3.value);
const char* name = (const char*)&type->enumerate_v3.value + vlen;
symt_add_enum_element(module, symt, name, value);
ptr += 2 + 2 + vlen + (1 + strlen(name));
break;
}
default:
FIXME("Unsupported type %04x in ENUM field list\n", type->generic.id);
return FALSE;
}
}
return codeview_add_type(typeno, &symt->symt);
}
static int codeview_add_type_struct_field_list(struct module* module,
unsigned int typeno,
const unsigned char* list, int len)
{
struct symt_udt* symt;
const unsigned char* ptr = list;
int value, leaf_len, vpoff, vplen;
const struct p_string* p_name;
const char* c_name;
struct symt* subtype;
const unsigned short int* p_vboff;
symt = symt_new_udt(module, NULL, 0, UdtStruct /* don't care */);
while (ptr - list < len)
{
const union codeview_fieldtype* type = (const union codeview_fieldtype*)ptr;
if (*ptr >= 0xf0) /* LF_PAD... */
{
ptr +=* ptr & 0x0f;
continue;
}
switch (type->generic.id)
{
case LF_BCLASS_V1:
leaf_len = numeric_leaf(&value, &type->bclass_v1.offset);
/* FIXME: ignored for now */
ptr += 2 + 2 + 2 + leaf_len;
break;
case LF_BCLASS_V2:
leaf_len = numeric_leaf(&value, &type->bclass_v2.offset);
/* FIXME: ignored for now */
ptr += 2 + 2 + 4 + leaf_len;
break;
case LF_VBCLASS_V1:
case LF_IVBCLASS_V1:
{
leaf_len = numeric_leaf(&value, &type->vbclass_v1.vbpoff);
p_vboff = (const unsigned short int*)((const char*)&type->vbclass_v1.vbpoff + leaf_len);
vplen = numeric_leaf(&vpoff, p_vboff);
/* FIXME: ignored for now */
ptr += 2 + 2 + 2 + 2 + leaf_len + vplen;
}
break;
case LF_VBCLASS_V2:
case LF_IVBCLASS_V2:
{
leaf_len = numeric_leaf(&value, &type->vbclass_v2.vbpoff);
p_vboff = (const unsigned short int*)((const char*)&type->vbclass_v2.vbpoff + leaf_len);
vplen = numeric_leaf(&vpoff, p_vboff);
/* FIXME: ignored for now */
ptr += 2 + 2 + 4 + 4 + leaf_len + vplen;
}
break;
case LF_MEMBER_V1:
leaf_len = numeric_leaf(&value, &type->member_v1.offset);
p_name = (const struct p_string*)((const char*)&type->member_v1.offset + leaf_len);
subtype = codeview_get_type(type->member_v1.type, TRUE);
if (!subtype || subtype->tag != SymTagCVBitField)
{
DWORD elem_size = 0;
if (subtype) symt_get_info(subtype, TI_GET_LENGTH, &elem_size);
symt_add_udt_element(module, symt, terminate_string(p_name),
codeview_get_type(type->member_v1.type, TRUE),
value << 3, elem_size << 3);
}
else
{
struct codeview_bitfield* cvbf = (struct codeview_bitfield*)subtype;
symt_add_udt_element(module, symt, terminate_string(p_name),
codeview_get_type(cvbf->subtype, FALSE),
cvbf->bitposition, cvbf->bitlength);
}
ptr += 2 + 2 + 2 + leaf_len + (1 + p_name->namelen);
break;
case LF_MEMBER_V2:
leaf_len = numeric_leaf(&value, &type->member_v2.offset);
p_name = (const struct p_string*)((const unsigned char*)&type->member_v2.offset + leaf_len);
subtype = codeview_get_type(type->member_v2.type, TRUE);
if (!subtype || subtype->tag != SymTagCVBitField)
{
DWORD elem_size = 0;
if (subtype) symt_get_info(subtype, TI_GET_LENGTH, &elem_size);
symt_add_udt_element(module, symt, terminate_string(p_name),
subtype, value << 3, elem_size << 3);
}
else
{
struct codeview_bitfield* cvbf = (struct codeview_bitfield*)subtype;
symt_add_udt_element(module, symt, terminate_string(p_name),
codeview_get_type(cvbf->subtype, FALSE),
cvbf->bitposition, cvbf->bitlength);
}
ptr += 2 + 2 + 4 + leaf_len + (1 + p_name->namelen);
break;
case LF_MEMBER_V3:
leaf_len = numeric_leaf(&value, &type->member_v3.offset);
c_name = (const char*)&type->member_v3.offset + leaf_len;
subtype = codeview_get_type(type->member_v3.type, TRUE);
if (!subtype || subtype->tag != SymTagCVBitField)
{
DWORD elem_size = 0;
if (subtype) symt_get_info(subtype, TI_GET_LENGTH, &elem_size);
symt_add_udt_element(module, symt, c_name,
subtype, value << 3, elem_size << 3);
}
else
{
struct codeview_bitfield* cvbf = (struct codeview_bitfield*)subtype;
symt_add_udt_element(module, symt, c_name,
codeview_get_type(cvbf->subtype, FALSE),
cvbf->bitposition, cvbf->bitlength);
}
ptr += 2 + 2 + 4 + leaf_len + (strlen(c_name) + 1);
break;
case LF_STMEMBER_V1:
/* FIXME: ignored for now */
ptr += 2 + 2 + 2 + (1 + type->stmember_v1.p_name.namelen);
break;
case LF_STMEMBER_V2:
/* FIXME: ignored for now */
ptr += 2 + 4 + 2 + (1 + type->stmember_v2.p_name.namelen);
break;
case LF_METHOD_V1:
/* FIXME: ignored for now */
ptr += 2 + 2 + 2 + (1 + type->method_v1.p_name.namelen);
break;
case LF_METHOD_V2:
/* FIXME: ignored for now */
ptr += 2 + 2 + 4 + (1 + type->method_v2.p_name.namelen);
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -