| 1 | #pragma once
|
|---|
| 2 |
|
|---|
| 3 | #include <windows.h>
|
|---|
| 4 |
|
|---|
| 5 | #ifdef _MSC_VER
|
|---|
| 6 | #define HAVE_UXTHEME_H 1
|
|---|
| 7 | #define HAVE_DWMAPI_H 1
|
|---|
| 8 | #define HAVE_DBGHELP_H 1
|
|---|
| 9 | #define HAVE_HPAINTBUFFER 1
|
|---|
| 10 | #endif
|
|---|
| 11 |
|
|---|
| 12 | #ifdef __CYGWIN__
|
|---|
| 13 | #define _T(x) TEXT(x)
|
|---|
| 14 | #else
|
|---|
| 15 | #include <tchar.h>
|
|---|
| 16 | #endif
|
|---|
| 17 |
|
|---|
| 18 | #ifndef _ALLOCA_S_THRESHOLD
|
|---|
| 19 | #define _ALLOCA_S_THRESHOLD 1024
|
|---|
| 20 | #endif
|
|---|
| 21 |
|
|---|
| 22 | #ifndef MSFTEDIT_CLASS
|
|---|
| 23 | #define MSFTEDIT_CLASS TEXT("RichEdit50W")
|
|---|
| 24 | #endif
|
|---|
| 25 |
|
|---|
| 26 | #ifdef HAVE_UXTHEME_H
|
|---|
| 27 | # include <uxtheme.h>
|
|---|
| 28 | #else
|
|---|
| 29 | namespace windows_version_help {
|
|---|
| 30 | typedef HANDLE HTHEME;
|
|---|
| 31 | HRESULT WINAPI DrawThemeBackground(HTHEME,HDC,int,int,LPCRECT,LPCRECT);
|
|---|
| 32 | typedef struct _MARGINS {
|
|---|
| 33 | int cxLeftWidth; // width of left border that retains its size
|
|---|
| 34 | int cxRightWidth; // width of right border that retains its size
|
|---|
| 35 | int cyTopHeight; // height of top border that retains its size
|
|---|
| 36 | int cyBottomHeight; // height of bottom border that retains its size
|
|---|
| 37 | } MARGINS;
|
|---|
| 38 | typedef MARGINS* PMARGINS;
|
|---|
| 39 | }
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | #if !defined(HAVE_UXTHEME_H) || !defined(HAVE_HPAINTBUFFER)
|
|---|
| 43 | namespace windows_version_help {
|
|---|
| 44 | typedef struct _BP_PAINTPARAMS {
|
|---|
| 45 | DWORD cbSize;
|
|---|
| 46 | DWORD dwFlags;
|
|---|
| 47 | const RECT *prcExclude;
|
|---|
| 48 | const BLENDFUNCTION *pBlendFunction;
|
|---|
| 49 | } BP_PAINTPARAMS, *PBP_PAINTPARAMS;
|
|---|
| 50 | typedef HANDLE HPAINTBUFFER;
|
|---|
| 51 | typedef enum _BP_BUFFERFORMAT {
|
|---|
| 52 | BPBF_COMPATIBLEBITMAP,
|
|---|
| 53 | BPBF_DIB,
|
|---|
| 54 | BPBF_TOPDOWNDIB,
|
|---|
| 55 | BPBF_TOPDOWNMONODIB
|
|---|
| 56 | } BP_BUFFERFORMAT;
|
|---|
| 57 | }
|
|---|
| 58 | #define BPPF_ERASE 0x0001 // Empty the buffer during BeginBufferedPaint()
|
|---|
| 59 | #define BPPF_NOCLIP 0x0002 // Don't apply the target DC's clip region to the double buffer
|
|---|
| 60 | #define BPPF_NONCLIENT 0x0004 // Using a non-client DC
|
|---|
| 61 | #define ULW_EX_NORESIZE 0x00000008
|
|---|
| 62 | #endif
|
|---|
| 63 |
|
|---|
| 64 | #ifdef HAVE_DWMAPI_H
|
|---|
| 65 | # include <dwmapi.h>
|
|---|
| 66 | #else
|
|---|
| 67 | namespace windows_version_help {
|
|---|
| 68 | typedef enum _DWMWINDOWATTRIBUTE {
|
|---|
| 69 | DWMWA_NCRENDERING_ENABLED = 1,
|
|---|
| 70 | DWMWA_NCRENDERING_POLICY,
|
|---|
| 71 | DWMWA_TRANSITIONS_FORCEDISABLED,
|
|---|
| 72 | DWMWA_ALLOW_NCPAINT,
|
|---|
| 73 | DWMWA_CAPTION_BUTTON_BOUNDS,
|
|---|
| 74 | DWMWA_NONCLIENT_RTL_LAYOUT,
|
|---|
| 75 | DWMWA_FORCE_ICONIC_REPRESENTATION,
|
|---|
| 76 | DWMWA_FLIP3D_POLICY,
|
|---|
| 77 | DWMWA_EXTENDED_FRAME_BOUNDS,
|
|---|
| 78 | DWMWA_HAS_ICONIC_BITMAP,
|
|---|
| 79 | DWMWA_DISALLOW_PEEK,
|
|---|
| 80 | DWMWA_EXCLUDED_FROM_PEEK,
|
|---|
| 81 | DWMWA_LAST
|
|---|
| 82 | } DWMWINDOWATTRIBUTE;
|
|---|
| 83 | // Blur behind data structures
|
|---|
| 84 | #define DWM_BB_ENABLE 0x00000001 // fEnable has been specified
|
|---|
| 85 | #define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified
|
|---|
| 86 | #define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified
|
|---|
| 87 | typedef struct _DWM_BLURBEHIND {
|
|---|
| 88 | DWORD dwFlags;
|
|---|
| 89 | BOOL fEnable;
|
|---|
| 90 | HRGN hRgnBlur;
|
|---|
| 91 | BOOL fTransitionOnMaximized;
|
|---|
| 92 | } DWM_BLURBEHIND, *PDWM_BLURBEHIND;
|
|---|
| 93 | }
|
|---|
| 94 | #endif
|
|---|
| 95 |
|
|---|
| 96 | namespace windows_version_help {
|
|---|
| 97 |
|
|---|
| 98 | struct WindowsVersionHelpDLL {
|
|---|
| 99 | HRESULT (WINAPI *DwmExtendFrameIntoClientArea)(HWND, const MARGINS*);
|
|---|
| 100 | HRESULT (WINAPI *DwmIsCompositionEnabled)(BOOL*);
|
|---|
| 101 | HRESULT (WINAPI *DwmEnableBlurBehindWindow)(HWND, const DWM_BLURBEHIND*);
|
|---|
| 102 | HRESULT (WINAPI *DwmGetColorizationColor)(DWORD*, BOOL*);
|
|---|
| 103 | HRESULT (WINAPI *DwmGetWindowAttribute)(HWND, DWORD, void*,DWORD);
|
|---|
| 104 | HPAINTBUFFER (WINAPI *BeginBufferedPaint)(HDC, const RECT*, BP_BUFFERFORMAT, BP_PAINTPARAMS*, HDC*);
|
|---|
| 105 | HRESULT (WINAPI *BufferedPaintInit)(void);
|
|---|
| 106 | HRESULT (WINAPI *BufferedPaintUnInit)(void);
|
|---|
| 107 | HRESULT (WINAPI *EndBufferedPaint)(HPAINTBUFFER, BOOL);
|
|---|
| 108 | HRESULT (WINAPI *BufferedPaintSetAlpha)(HPAINTBUFFER, const RECT*, BYTE);
|
|---|
| 109 | PVOID (WINAPI *ImageDirectoryEntryToData)(PVOID, BOOLEAN, USHORT, PULONG);
|
|---|
| 110 |
|
|---|
| 111 | void init() {
|
|---|
| 112 |
|
|---|
| 113 | #define SET_DLL_ADDRESS(module, name) \
|
|---|
| 114 | { /* strict aliasing */ \
|
|---|
| 115 | void* pointer = (void*)&this->name; \
|
|---|
| 116 | void** pointer2 = (void**)pointer; \
|
|---|
| 117 | *pointer2 = (void*)GetProcAddress(module, #name); \
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | HMODULE dwmapi_dll = LoadLibrary(TEXT("dwmapi.dll"));
|
|---|
| 121 | if (dwmapi_dll) {
|
|---|
| 122 | SET_DLL_ADDRESS(dwmapi_dll, DwmExtendFrameIntoClientArea);
|
|---|
| 123 | SET_DLL_ADDRESS(dwmapi_dll, DwmIsCompositionEnabled);
|
|---|
| 124 | SET_DLL_ADDRESS(dwmapi_dll, DwmEnableBlurBehindWindow);
|
|---|
| 125 | SET_DLL_ADDRESS(dwmapi_dll, DwmGetColorizationColor);
|
|---|
| 126 | SET_DLL_ADDRESS(dwmapi_dll, DwmGetWindowAttribute);
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | HMODULE uxtheme_dll = LoadLibrary(TEXT("uxtheme.dll"));
|
|---|
| 130 | if (uxtheme_dll) {
|
|---|
| 131 | SET_DLL_ADDRESS(uxtheme_dll, BeginBufferedPaint);
|
|---|
| 132 | SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintInit);
|
|---|
| 133 | SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintUnInit);
|
|---|
| 134 | SET_DLL_ADDRESS(uxtheme_dll, EndBufferedPaint);
|
|---|
| 135 | SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintSetAlpha);
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | HMODULE dbghelp_dll = LoadLibrary(TEXT("dbghelp.dll"));
|
|---|
| 139 | if (dbghelp_dll) {
|
|---|
| 140 | SET_DLL_ADDRESS(dbghelp_dll, ImageDirectoryEntryToData);
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | #undef SET_DLL_ADDRESS
|
|---|
| 144 |
|
|---|
| 145 | }
|
|---|
| 146 | };
|
|---|
| 147 |
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | using namespace windows_version_help;
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|