/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel IRC Team *
+ * Copyright (C) 2005-09 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
EnumModulesContext(HANDLE hProcess, QTextStream &stream) : hProcess(hProcess), stream(stream) {}
};
-#if _MSC_VER >= 1500
-BOOL CALLBACK EnumModulesCB(PCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) {
-#else
-BOOL CALLBACK EnumModulesCB(PSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) {
-#endif
+BOOL CALLBACK EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) {
IMAGEHLP_MODULE64 mod;
EnumModulesContext *context = (EnumModulesContext *)UserContext;
mod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
return TRUE;
}
-#ifdef _M_IX86
+
+
+#if defined( _M_IX86 ) && defined(Q_CC_MSVC)
// Disable global optimization and ignore /GS waning caused by
// inline assembly.
+ // not needed with mingw cause we can tell mingw which registers we use
#pragma optimize("g", off)
#pragma warning(push)
#pragma warning(disable : 4748)
#ifdef _M_IX86
ZeroMemory(&Context, sizeof(CONTEXT));
Context.ContextFlags = CONTEXT_CONTROL;
- __asm {
+
+
+#ifdef __MINGW32__
+ asm("Label:\n\t"
+ "movl %%ebp,%0;\n\t"
+ "movl %%esp,%1;\n\t"
+ "movl $Label,%%eax;\n\t"
+ "movl %%eax,%2;\n\t"
+ :"=r"(Context.Ebp),"=r"(Context.Esp),"=r"(Context.Eip)
+ ://no input
+ :"eax");
+#else
+ _asm {
Label:
mov [Context.Ebp], ebp;
mov [Context.Esp], esp;
mov eax, [Label];
mov [Context.Eip], eax;
}
+#endif
#else
RtlCaptureContext(&Context);
#endif
logFile.close();
}
-#ifdef _M_IX86
+#if defined(_M_IX86) && defined(Q_CC_MSVC)
#pragma warning(pop)
#pragma optimize("g", on)
#endif