int Decodeargument(t_module *pmod,wchar_t *prtype,void *data,int ndata,wchar_t *text,int ntext,int *nontriv);
Decodes data of size ndata as element of prefixed type prtype to the UNICODE string text at least ntext wide characters long. Optionally sets nontriv to zero if decoding is trivial (i.e. invalid or contains only hexadecimal or decimal numbers) and to 1 otherwise.
Note that this routine ignores ARG_OUT. The burden of proof whether pointer points to the valid data is on the calling routine.
Parameters:
pmod
(in) Optional ointer to the module descriptor (structure of type t_module), necessary to decode module-dependent items, like resource strings or .NET-specific data
prtype
(in) Pointer to the UNICODE string, prefixed type of the information in data
data
(in) Pointer to the argument, ndata bytes long, that will be decoded to the text
ndata
(in) Length of the data, bytes
text
(out) UNICODE buffer, at least ntext wide characters long, that receives decoding. The produced string is always null-terminated
ntext
(in) Length of the text buffer, wide characters
nontriv
(out)
Optional pointer to the variable that will be set to 0 if decoding is
trivial (contains only hexadecimal or decimal number) or not possible
due to the error, and 1 otherwise
Return values:
Returns length of the decoded text, in wide characters, not including the terminal zero, or 0 on any error.
Example:
Suppose we are going to decode parameter Msg of DefWindowProc(). The corresponding call may be like this:
int msg;
wchar_t text[TEXTLEN],prefixedtype[SHORTNAME];
// Get value of the argument.
msg=32;
// Prepare prefixed type. Internal type of Msg in the database is
// WM_XA (ASCII) or WM_XW (UNICODE). Names of the constants are the
// same in both cases.
prefixedtype[0]=(wchar_t)(ARG_VALID|ARG_TYPE);
wcscpy(prefixedtype+1,L"WM_XA");
// Decoding of Msg is module-independent, I set pmod to NULL.
Decodeargument(NULL,prefixedtype,&msg,sizeof(msg),text,TEXTLEN,NULL);
On return, text will contain "WM_SETCURSOR", which is the name of the message with code 32 (0x20).
int msg;
wchar_t text[TEXTLEN],prefixedtype[SHORTNAME];
// Get value of the argument.
msg=32;
// Prepare prefixed type. Internal type of Msg in the database is
// WM_XA (ASCII) or WM_XW (UNICODE). Names of the constants are the
// same in both cases.
prefixedtype[0]=(wchar_t)(ARG_VALID|ARG_TYPE);
wcscpy(prefixedtype+1,L"WM_XA");
// Decoding of Msg is module-independent, I set pmod to NULL.
Decodeargument(NULL,prefixedtype,&msg,sizeof(msg),text,TEXTLEN,NULL);
On return, text will contain "WM_SETCURSOR", which is the name of the message with code 32 (0x20).
See also:
Analysis, arguments, known functions, Decodeknownbyaddr(), Decodeknownbyname(), Decodetype(), Decodestructure()