From 864165a44c441c853316e44b182236a4b2338fd5 Mon Sep 17 00:00:00 2001 From: "gergely.erdelyi" Date: Mon, 27 Apr 2009 17:38:17 +0000 Subject: [PATCH] Added support for retrieving large local types --- python/idc.py | 6 +++++- swig/typeinf.i | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/python/idc.py b/python/idc.py index 94d5189..ac63413 100644 --- a/python/idc.py +++ b/python/idc.py @@ -6089,8 +6089,12 @@ def GetLocalType(ordinal, flags): @param flags: any of PRTYPE_* constants @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_MULTI = 0x0001 # print to many lines diff --git a/swig/typeinf.i b/swig/typeinf.i index 9591853..9353064 100644 --- a/swig/typeinf.i +++ b/swig/typeinf.i @@ -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 %{ /* Parse types from a string or file. See ParseTypes() in idc.py */ 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; } -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 p_list *fields; if (!get_numbered_type(idati, ordinal, &type, &fields)) - return false; + { + buf[0] = 0; + return false; + } qstring res; 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) - return false; + { + buf[0] = 0; + return false; + } - qstrncpy(buf, res.c_str(), bufsize); + qstrncpy(buf, res.c_str(), maxsize); return true; }