Skip to content

Commit

Permalink
Squashed 'ext/detours/' changes from 39aa864..36b69b9
Browse files Browse the repository at this point in the history
36b69b9 Make Detours MinGW Clang-compatible

git-subtree-dir: ext/detours
git-subtree-split: 36b69b971888b2ca0c5913563bae011efaa4a42e
  • Loading branch information
vosen committed Jan 3, 2021
1 parent dabc40c commit 4b96dbc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/creatwth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define DETOURS_INTERNAL
#include "detours.h"
#include <stddef.h>
#include <strsafe.h>

#if DETOURS_VERSION != 0x4c0c1 // 0xMAJORcMINORcPATCH
#error detours.h version mismatch
Expand Down
19 changes: 0 additions & 19 deletions src/detours.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@
//////////////////////////////////////////////////////////////////////////////
//

#if (_MSC_VER < 1299)
typedef LONG LONG_PTR;
typedef ULONG ULONG_PTR;
#endif

///////////////////////////////////////////////// SAL 2.0 Annotations w/o SAL.
//
// These definitions are include so that Detours will build even if the
Expand Down Expand Up @@ -846,24 +841,10 @@ VOID CALLBACK DetourFinishHelperProcess(_In_ HWND,

//////////////////////////////////////////////////////////////////////////////
//
#if (_MSC_VER < 1299)
#include <imagehlp.h>
typedef IMAGEHLP_MODULE IMAGEHLP_MODULE64;
typedef PIMAGEHLP_MODULE PIMAGEHLP_MODULE64;
typedef IMAGEHLP_SYMBOL SYMBOL_INFO;
typedef PIMAGEHLP_SYMBOL PSYMBOL_INFO;

static inline
LONG InterlockedCompareExchange(_Inout_ LONG *ptr, _In_ LONG nval, _In_ LONG oval)
{
return (LONG)::InterlockedCompareExchange((PVOID*)ptr, (PVOID)nval, (PVOID)oval);
}
#else
#pragma warning(push)
#pragma warning(disable:4091) // empty typedef
#include <dbghelp.h>
#pragma warning(pop)
#endif

#ifdef IMAGEAPI // defined by DBGHELP.H
typedef LPAPI_VERSION (NTAPI *PF_ImagehlpApiVersionEx)(_In_ LPAPI_VERSION AppVersion);
Expand Down
4 changes: 3 additions & 1 deletion src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class CImageData
DWORD m_cbAlloc;
};

class CImageImportName;

class CImageImportFile
{
friend class CImage;
Expand Down Expand Up @@ -1693,7 +1695,7 @@ BOOL CImage::Write(HANDLE hFile)
m_nNextFileAddr = Max(m_SectionHeaders[n].PointerToRawData +
m_SectionHeaders[n].SizeOfRawData,
m_nNextFileAddr);
// Old images have VirtualSize == 0 as a matter of course, e.g. NT 3.1.
// Old images have VirtualSize == 0 as a matter of course, e.g. NT 3.1.
// In which case, use SizeOfRawData instead.
m_nNextVirtAddr = Max(m_SectionHeaders[n].VirtualAddress +
(m_SectionHeaders[n].Misc.VirtualSize
Expand Down
4 changes: 3 additions & 1 deletion src/modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// #define DETOUR_DEBUG 1
#define DETOURS_INTERNAL
#include "detours.h"
#include <strsafe.h>
#include <libloaderapi.h>

#if DETOURS_VERSION != 0x4c0c1 // 0xMAJORcMINORcPATCH
#error detours.h version mismatch
Expand Down Expand Up @@ -340,7 +342,7 @@ PVOID WINAPI DetourGetEntryPoint(_In_opt_ HMODULE hModule)
}

SetLastError(NO_ERROR);
return GetProcAddress(hClr, "_CorExeMain");
return (PVOID)GetProcAddress(hClr, "_CorExeMain");
}

SetLastError(NO_ERROR);
Expand Down

0 comments on commit 4b96dbc

Please sign in to comment.