Eexpression

int Eexpression(t_result *result,wchar_t *expl,uchar *cexpr,int index,uchar *data,ulong base,ulong size,ulong threadid,ulong a,ulong b,ulong mode);

Evaluates precompiled expression or subexpression to numerical and/or text value.


Parameters:

result
(out) Structure of type t_result that receives results of the evaluation
expl
(out) Pointer to the UNICODE buffer that receives the explanation, or NULL if explanation is not necessary. Explanations are allowed only if expression was compiled with flag EMOD_MULTI. The syntax of  expressions is described here; its most general form is "<explanation0>=<subexpression0>, <explanation1>=<subexpression1>, ..."
cexpr
(in) Precompiled expression produced by the preceding call to Cexpression()
index
(in) Index of subexpression if expression was compiled with flag EMOD_MULTI, otherwise ignored. To find the number of subexpressions in the precompiled expression, use Exprcount()
data
(in) Pointer to the optional copy of memory contents. If data is NULL, flag EMOD_NOMEMORY is not set and expression includes contents of memory, Eexpression() reads memory of debugged process. If data is not NULL and expression accesses memory in the range [base..base+size-1], contents of memory is taken from the data. In all other cases attempt to access memory will result in the failure
base
(in) Base address of the supplied data block, ignored if data is NULL
size
(in) Size of the supplied data block, ignored if data is NULL
threadid
(in) Identifier of the thread containing CPU registers used in the evaluation of the expression. If expression specifies register and threadid is 0, Eexpression() will fail
a
(in) First parameter, determines value of the pseudovariable %A in original expression
b
(in) Second parameter, determines value of the pseudovariable %B in original expression
mode
(in) Evaluation mode, combination of zero or more of the following flags:
EMOD_NOVALUE - requests not to convert the binary value of the expression (result->data) to text (result->value)
EMOD_NOMEMORY - forbids reading of the Debuggee's memory. If expression includes contents of memory and data is not supplied, evaluation will fail


Return values:

If evaluation was successful, returns 0. If evaluation failed, writes error message to result.value and returns -1.


Example:

This is the slightly modified code of Expression(). It compiles the supplied expression and immeadiately estimates its value.

int Expression(t_result *result,wchar_t *expression,uchar *data,
  ulong base,ulong size,ulong threadid,ulong a,ulong b,ulong mode) {
  int n;
  uchar cexpr[TEXTLEN];
  if (result==NULL)
    return 0;                          // Error in input parameters
  memset(result,0,sizeof(t_result));
  if (expression==NULL || expression[0]==L'\0') {
    StrcopyW(result->value,TEXTLEN,L"No expression");
    result->lvaltype=result->datatype=EXPR_INVALID;
    return 0; };
  if (mode & EMOD_MULTI) {
    StrcopyW(result->value,TEXTLEN,L"Multiple expressions are not allowed");
    result->lvaltype=result->datatype=EXPR_INVALID;
    return 0; };
  // Compile and estimate expression.
  n=Cexpression(expression,cexpr,TEXTLEN,NULL,result->value,mode);
  if (result->value[0]!=0)
    result->lvaltype=result->datatype=EXPR_INVALID;
  else
    Eexpression(result,NULL,cexpr,0,data,base,size,threadid,a,b,mode);
  return n;
}; 



See also:
Expressions, t_result, t_watch, Cexpression(), Expression(), Exprcount(), Fastexpression()