Added support for retrieving large local types

This commit is contained in:
gergely.erdelyi 2009-04-27 17:38:17 +00:00
parent 5e1871f485
commit 864165a44c
2 changed files with 17 additions and 5 deletions

View File

@ -6089,8 +6089,12 @@ def GetLocalType(ordinal, flags):
@param flags: any of PRTYPE_* constants @param flags: any of PRTYPE_* constants
@return: local type as a C declaration or "" @return: local type as a C declaration or ""
@note: This function can return types strings up to 64KiB. Use idaapi.idc_get_local_type()
for larger types.
""" """
return idaapi.idc_get_local_type(ordinal, flags) res,str = idaapi.idc_get_local_type(ordinal, flags, 2**16)
return str
PRTYPE_1LINE = 0x0000 # print to one line PRTYPE_1LINE = 0x0000 # print to one line
PRTYPE_MULTI = 0x0001 # print to many lines PRTYPE_MULTI = 0x0001 # print to many lines

View File

@ -176,6 +176,8 @@ til_t * load_til_header_wrap(const char *tildir, const char *name)
} }
%} %}
%cstring_output_maxsize(char *buf, size_t maxsize);
%inline %{ %inline %{
/* Parse types from a string or file. See ParseTypes() in idc.py */ /* Parse types from a string or file. See ParseTypes() in idc.py */
int idc_parse_types(const char *input, int flags) int idc_parse_types(const char *input, int flags)
@ -255,21 +257,27 @@ int idc_set_local_type(int ordinal, const char *dcl, int flags)
return ordinal; return ordinal;
} }
char idc_get_local_type(int ordinal, int flags, char *buf, size_t bufsize) int idc_get_local_type(int ordinal, int flags, char *buf, size_t maxsize)
{ {
const type_t *type; const type_t *type;
const p_list *fields; const p_list *fields;
if (!get_numbered_type(idati, ordinal, &type, &fields)) if (!get_numbered_type(idati, ordinal, &type, &fields))
return false; {
buf[0] = 0;
return false;
}
qstring res; qstring res;
const char *name = get_numbered_type_name(idati, ordinal); const char *name = get_numbered_type_name(idati, ordinal);
if (print_type_to_qstring(&res, NULL, 2, 40, flags, idati, type, name, NULL, fields) <= 0) if (print_type_to_qstring(&res, NULL, 2, 40, flags, idati, type, name, NULL, fields) <= 0)
return false; {
buf[0] = 0;
return false;
}
qstrncpy(buf, res.c_str(), bufsize); qstrncpy(buf, res.c_str(), maxsize);
return true; return true;
} }