Example of calldll tcc returning values

Doubts, help and support about QuickBMS and other game research tools
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Example of calldll tcc returning values

Post by aluigi »

In case someone is interested in a different example of calldll tcc (the embedded C code of quickbms), it includes:
- malloc and memset, don't worry about the implicit declaration "warning" messages at runtime
- returning a buffer as a variable
- returning an integer as a variable passed as argument
- print hexdump with size

Code: Select all

set MEMORY_FILE10 string "
unsigned char *func(
    int size,
    int *output_int
) {
    unsigned char   *data = malloc(size);
    memset(data, 'a', size);
    *output_int = 12345678;
    return data;
}
"

math RET2 = 0   # it must be declared first
math SIZE = 123

calldll MEMORY_FILE10 func tcc &RET SIZE &RET2

print "%RET2%"
print "%RET|hexdump SIZE%"

Not sure why RET2 must be declared first.