Hi all,
some days ago i've posted a question for a win32 API stacktrace implementation with MSYS/Mingw: http://stackoverflow.com/questions/3318564/win32-api-stack-walk-with-mingw-msys
The hint with the explicit loading of the dll was the correct solution. So i've restart the try to implement a stacktrace using the win32 CaptureStackBackTrace API mechanism regarding this hint. The loading of the dll works fine:
// Load the RTLCapture context function:
HINSTANCE kernel32 = LoadLibrary("Kernel32.dll");
if(kernel32 != NULL){
std::cout << "Try to load method from kernel32.dll: CaptureStackBackTrace" << std::endl;
typedef USHORT (*CaptureStackBackTraceType)(ULONG FramesToSkip, ULONG FramesToCapture, void* BackTrace, ULONG* BackTraceHash);
CaptureStackBackTraceType func = (CaptureStackBackTraceType) GetProcAddress( kernel32, "RtlCaptureStackBackTrace" );
if(func==NULL){
std::cout << "Handle for CaptureStackBackTrace could't loded! Stop demo!."<< std::endl;
FreeLibrary(kernel32);
kernel32 = NULL;
func = NULL;
exit(1);
}
void *array[63];
int i,num = 0;
std::cout << "Try to call CaptureStackBackTrace..."<< std::endl;
num = CaptureStackBackTraceType( 1, 32, array, NULL );}
But i got trouble if i call the CaptureStackBackTraceType method and running in type convertion issues:
stacktrace.cpp:138: error: functional cast expression list treated as compound e
xpression
stacktrace.cpp:138: error: invalid conversion from USHORT (*)(ULONG, ULONG, voi
d*, ULONG*)' to
USHORT'
I think this issue may be due to type differences between MSYS/MinGW and the dll definitions. Defining the USHORT explicitly #define USHORT unsigned short has no effect.
Has anyone an idea how i could solve this issue? I would be deeply gratefull for any hint.
Best regards, Christian