Skip to content

Commit e64fe0f

Browse files
virtualdbgianfo
andauthored
Allow compilation with MinGW to succeed (microsoft#108)
- Tested with 7.3-win32 20180312 Co-authored-by: Brian Gianforcaro <[email protected]>
1 parent 39aa864 commit e64fe0f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/detours.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
#pragma warning(pop)
4949
#endif
5050

51+
// Allow Detours to cleanly compile with the MingW toolchain.
52+
//
53+
#ifdef __GNUC__
54+
#define __try
55+
#define __except(x) if (0)
56+
#include <strsafe.h>
57+
#endif
58+
5159
// From winerror.h, as this error isn't found in some SDKs:
5260
//
5361
// MessageId: ERROR_DYNAMIC_CODE_BLOCKED
@@ -846,7 +854,7 @@ VOID CALLBACK DetourFinishHelperProcess(_In_ HWND,
846854

847855
//////////////////////////////////////////////////////////////////////////////
848856
//
849-
#if (_MSC_VER < 1299)
857+
#if (_MSC_VER < 1299) && !defined(__GNUC__)
850858
#include <imagehlp.h>
851859
typedef IMAGEHLP_MODULE IMAGEHLP_MODULE64;
852860
typedef PIMAGEHLP_MODULE PIMAGEHLP_MODULE64;

src/image.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class CImageData
146146
DWORD m_cbAlloc;
147147
};
148148

149+
class CImageImportName;
150+
149151
class CImageImportFile
150152
{
151153
friend class CImage;

src/modules.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ PVOID WINAPI DetourGetEntryPoint(_In_opt_ HMODULE hModule)
340340
}
341341

342342
SetLastError(NO_ERROR);
343-
return GetProcAddress(hClr, "_CorExeMain");
343+
return (PVOID)GetProcAddress(hClr, "_CorExeMain");
344344
}
345345

346346
SetLastError(NO_ERROR);

0 commit comments

Comments
 (0)