Click here to Skip to main content
15,900,511 members

Comments by Pesmontis (Top 4 by date)

Pesmontis 2-Oct-10 6:16am View    
I've got it to work with the following changes:

#define FUNCDECL(ret, name, args) \
typedef ret (__cdecl *raw_##name) args; \
raw_##name* name = (raw_##name*)&_##name;

and:

FUNCDECL(unsigned int, GetUncompressedLength, (void*, unsigned int));

So this means I had to stop using standard calls, and I think that it is necessary to specify the exact function arguments (ie. without my own parameter names). Therefor I can now answer my own first question:

It is not necessary to create class prototypes in order to address the exports listed above (even / only for member functions from singleton classes).

The answer to the second question is: you can probably use a force cast as suggested by the codeguru article if you use a __cdecl convention. However, this is not necessary therefor I have not tested it.

The answer to the third question is: if you address the function(s) properly, using proper arguments, then the return value is indeed the function result. This will be a pointer if it is specified as a pointer. In the example I described above, the output was produced with improper function arguments. I should not have added argument names.
Pesmontis 26-Sep-10 16:48pm View    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
Pesmontis 22-Sep-10 15:43pm View    
I still get the Debug error: "The value of ESP was not properly saved across a function call"
Pesmontis 6-Sep-10 12:22pm View    
I wasn't too careful when typing my question, I should have typed "-- decorated name --" where it previously read "-- undecorated name --".

Before I posted this question I did test code like you (both) propose, but that way I never got a proper pointer to the function (always error 'access violation'). I read somewhere else that I should use the decorated function names, and this is working: the functions are present and accept input without raising further errors.

Note that my three questions are quite specific, so what I'm really interested in is (more) specific answers.