diff --git a/src/Thunks/UIAutomationCore.hpp b/src/Thunks/UIAutomationCore.hpp index fc4e8b3..e3f0d23 100644 --- a/src/Thunks/UIAutomationCore.hpp +++ b/src/Thunks/UIAutomationCore.hpp @@ -125,4 +125,69 @@ namespace YY::Thunks return E_NOTIMPL; } #endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + + //UiaGetReservedMixedAttributeValue + __DEFINE_THUNK( + uiautomationcore, + 4, + HRESULT, + WINAPI, + UiaGetReservedMixedAttributeValue, + _Outptr_ IUnknown** punkMixedAttributeValue + ) + { + if (auto const pUiaGetReservedMixedAttributeValue = try_get_UiaGetReservedMixedAttributeValue()) + { + return pUiaGetReservedMixedAttributeValue(punkMixedAttributeValue); + } + + return E_NOTIMPL; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //UiaGetReservedNotSupportedValue + __DEFINE_THUNK( + uiautomationcore, + 4, + HRESULT, + WINAPI, + UiaGetReservedNotSupportedValue, + _Outptr_ IUnknown** punkNotSupportedValue + ) + { + if (auto const pUiaGetReservedNotSupportedValue = try_get_UiaGetReservedNotSupportedValue()) + { + return pUiaGetReservedNotSupportedValue(punkNotSupportedValue); + } + + return E_NOTIMPL; + } +#endif +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //UiaRaiseStructureChangedEvent + + __DEFINE_THUNK( + uiautomationcore, + 16, + HRESULT, + WINAPI, + UiaRaiseStructureChangedEvent, + IRawElementProviderSimple* pProvider, + enum StructureChangeType structureChangeType, + int* pRuntimeId, + int cRuntimeIdLen + ) + { + if (auto const pUiaRaiseStructureChangedEvent = try_get_UiaRaiseStructureChangedEvent()) + { + return pUiaRaiseStructureChangedEvent(pProvider, structureChangeType, pRuntimeId, cRuntimeIdLen); + } + + return E_NOTIMPL; + } +#endif } diff --git a/src/Thunks/YY_Thunks.cpp b/src/Thunks/YY_Thunks.cpp index 8618d6c..c1f8436 100644 --- a/src/Thunks/YY_Thunks.cpp +++ b/src/Thunks/YY_Thunks.cpp @@ -15,6 +15,11 @@ _APPLY(dxva2, "dxva2" , 0 ) \ _APPLY(uxtheme, "uxtheme" , 0 ) \ _APPLY(uiautomationcore, "uiautomationcore" , 0 ) \ + _APPLY(ncrypt, "ncrypt" , 0 ) \ + _APPLY(credui, "credui" , 0 ) \ + _APPLY(wevtapi, "wevtapi" , 0 ) \ + _APPLY(esent, "esent" , 0 ) \ + _APPLY(propsys, "propsys" , 0 ) \ _APPLY(psapi, "psapi" , 0 ) \ _APPLY(pdh, "pdh" , 0 ) \ _APPLY(version, "version" , 0 ) \ diff --git a/src/Thunks/credui.hpp b/src/Thunks/credui.hpp new file mode 100644 index 0000000..4dd2f83 --- /dev/null +++ b/src/Thunks/credui.hpp @@ -0,0 +1,46 @@ + +#include + +namespace YY +{ + namespace Thunks + { + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //CredUIPromptForWindowsCredentialsW + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + credui, + 36, + DWORD, + WINAPI, + CredUIPromptForWindowsCredentialsW, + _In_opt_ PCREDUI_INFOW pUiInfo, + _In_ DWORD dwAuthError, + _Inout_ ULONG* pulAuthPackage, + _In_reads_bytes_opt_(ulInAuthBufferSize) LPCVOID pvInAuthBuffer, + _In_ ULONG ulInAuthBufferSize, + _Outptr_result_bytebuffer_to_(*pulOutAuthBufferSize, *pulOutAuthBufferSize) LPVOID* ppvOutAuthBuffer, + _Out_ ULONG* pulOutAuthBufferSize, + _Inout_opt_ BOOL* pfSave, + _In_ DWORD dwFlags + ) + { + if (auto const pCredUIPromptForWindowsCredentialsW = try_get_CredUIPromptForWindowsCredentialsW()) + { + return pCredUIPromptForWindowsCredentialsW(pUiInfo, dwAuthError, pulAuthPackage, pvInAuthBuffer, ulInAuthBufferSize, ppvOutAuthBuffer, + pulOutAuthBufferSize, pfSave, dwFlags); + } + + return ERROR_CANCELLED; + } + +#endif + + + + + }//namespace Thunks + +} //namespace YY diff --git a/src/Thunks/dwmapi.hpp b/src/Thunks/dwmapi.hpp index 36b4855..b841b61 100644 --- a/src/Thunks/dwmapi.hpp +++ b/src/Thunks/dwmapi.hpp @@ -260,5 +260,28 @@ namespace YY return S_OK; } #endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + dwmapi, + 8, + HRESULT, + STDAPICALLTYPE, + DwmGetCompositionTimingInfo, + _In_ HWND hWnd, + _Out_ DWM_TIMING_INFO* pTimingInfo + ) + { + if (auto const pDwmGetCompositionTimingInfo = try_get_DwmGetCompositionTimingInfo()) + { + return pDwmGetCompositionTimingInfo(hWnd, pTimingInfo); + } + + return __HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); + } +#endif } // namespace Thunks } // namespace YY diff --git a/src/Thunks/dxgi.hpp b/src/Thunks/dxgi.hpp index 95802c6..5d60b80 100644 --- a/src/Thunks/dxgi.hpp +++ b/src/Thunks/dxgi.hpp @@ -24,4 +24,30 @@ namespace YY::Thunks return E_NOINTERFACE; } #endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN7) + + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + dxgi, + 8, + HRESULT, + STDAPICALLTYPE, + CreateDXGIFactory, + REFIID riid, + _COM_Outptr_ void** ppFactory + ) + { + if (auto const pCreateDXGIFactory = try_get_CreateDXGIFactory()) + { + return pCreateDXGIFactory(riid, ppFactory); + } + + return DXGI_ERROR_ACCESS_DENIED; + } +#endif + + + } diff --git a/src/Thunks/esent.hpp b/src/Thunks/esent.hpp new file mode 100644 index 0000000..460abf4 --- /dev/null +++ b/src/Thunks/esent.hpp @@ -0,0 +1,230 @@ + +#include + + +namespace YY +{ + namespace Thunks + { + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //JetAttachDatabase2W + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + esent, + 16, + JET_ERR, + JET_API, + JetAttachDatabase2W, + _In_ JET_SESID sesid, + _In_ JET_PCWSTR szFilename, + _In_ const unsigned long cpgDatabaseSizeMax, + _In_ JET_GRBIT grbit + ) + { + if (auto const pJetAttachDatabase2W = try_get_JetAttachDatabase2W()) + { + return pJetAttachDatabase2W(sesid, szFilename, cpgDatabaseSizeMax, grbit); + } + + return JET_errDatabaseNotFound; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //JetBeginSessionW + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + esent, + 16, + JET_ERR, + JET_API, + JetBeginSessionW, + _In_ JET_INSTANCE instance, + _Out_ JET_SESID* psesid, + _In_opt_ JET_PCWSTR szUserName, + _In_opt_ JET_PCWSTR szPassword + ) + { + if (auto const pJetBeginSessionW = try_get_JetBeginSessionW()) + { + return pJetBeginSessionW(instance, psesid, szUserName, szPassword); + } + + return JET_errInvalidParameter; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //JetCreateInstanceW + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + esent, + 8, + JET_ERR, + JET_API, + JetCreateInstanceW, + _Out_ JET_INSTANCE* pinstance, + _In_opt_ JET_PCWSTR szInstanceName + ) + { + if (auto const pJetCreateInstanceW = try_get_JetCreateInstanceW()) + { + return pJetCreateInstanceW(pinstance, szInstanceName); + } + + return JET_errInvalidParameter; + } + +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //JetGetTableColumnInfoW + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + esent, + 24, + JET_ERR, + JET_API, + JetGetTableColumnInfoW, + _In_ JET_SESID sesid, + _In_ JET_TABLEID tableid, + _In_opt_ JET_PCWSTR szColumnName, + _Out_writes_bytes_(cbMax) void* pvResult, + _In_ unsigned long cbMax, + _In_ unsigned long InfoLevel + ) + { + if (auto const pJetGetTableColumnInfoW = try_get_JetGetTableColumnInfoW()) + { + return pJetGetTableColumnInfoW(sesid, tableid, szColumnName, pvResult, cbMax, InfoLevel); + } + + return JET_errInvalidParameter; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //JetOpenDatabaseW + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + esent, + 20, + JET_ERR, + JET_API, + JetOpenDatabaseW, + _In_ JET_SESID sesid, + _In_ JET_PCWSTR szFilename, + _In_opt_ JET_PCWSTR szConnect, + _Out_ JET_DBID* pdbid, + _In_ JET_GRBIT grbit + ) + { + if (auto const pJetOpenDatabaseW = try_get_JetOpenDatabaseW()) + { + return pJetOpenDatabaseW(sesid, szFilename, szConnect, pdbid, grbit); + } + + return JET_errDatabaseInvalidPath; + } + +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //JetOpenTableW + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + esent, + 28, + JET_ERR, + JET_API, + JetOpenTableW, + _In_ JET_SESID sesid, + _In_ JET_DBID dbid, + _In_ JET_PCWSTR szTableName, + _In_reads_bytes_opt_(cbParameters) const void* pvParameters, + _In_ unsigned long cbParameters, + _In_ JET_GRBIT grbit, + _Out_ JET_TABLEID* ptableid + ) + { + if (auto const pJetOpenTableW = try_get_JetOpenTableW()) + { + return pJetOpenTableW(sesid, dbid, szTableName, pvParameters, cbParameters, grbit, ptableid); + } + + return JET_errInvalidName; + } + +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //JetSetSystemParameterW + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + esent, + 20, + JET_ERR, + JET_API, + JetSetSystemParameterW, + _Inout_opt_ JET_INSTANCE* pinstance, + _In_opt_ JET_SESID sesid, + _In_ unsigned long paramid, + _In_opt_ JET_API_PTR lParam, + _In_opt_ JET_PCWSTR szParam + ) + { + if (auto const pJetSetSystemParameterW = try_get_JetSetSystemParameterW()) + { + return pJetSetSystemParameterW(pinstance, sesid, paramid, lParam, szParam); + } + + return JET_errInstanceUnavailable; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //JetGetSystemParameterW + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + esent, + 24, + JET_ERR, + JET_API, + JetGetSystemParameterW, + _In_ JET_INSTANCE instance, + _In_opt_ JET_SESID sesid, + _In_ unsigned long paramid, + _Out_opt_ JET_API_PTR* plParam, + _Out_writes_bytes_opt_(cbMax) JET_PWSTR szParam, + _In_ unsigned long cbMax + ) + { + if (auto const pJetGetSystemParameterW = try_get_JetGetSystemParameterW()) + { + return pJetGetSystemParameterW(instance, sesid, paramid, plParam, szParam, cbMax); + } + + return JET_errInstanceUnavailable; + } + +#endif + + }//namespace Thunks + +} //namespace YY diff --git a/src/Thunks/kernel32.hpp b/src/Thunks/kernel32.hpp index 22b0683..46534f7 100644 --- a/src/Thunks/kernel32.hpp +++ b/src/Thunks/kernel32.hpp @@ -495,5 +495,82 @@ namespace YY return DEP_SYSTEM_POLICY_TYPE::DEPPolicyAlwaysOff; } #endif // (YY_Thunks_Support_Version < NTDDI_WIN6SP1) + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + + //Minimum supported client Windows Vista [desktop apps only] + //Minimum supported server Windows Server 2008 [desktop apps only] + __DEFINE_THUNK( + kernel32, + 8, + BOOL, + WINAPI, + Wow64GetThreadContext, + _In_ HANDLE hThread, + _Out_ PWOW64_CONTEXT lpContext + ) + { + if (const auto pWow64GetThreadContext = try_get_Wow64GetThreadContext()) + { + return pWow64GetThreadContext(hThread, lpContext); + } + + return FALSE; + } +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN7) + + //Minimum supported client Windows Vista [desktop apps only] + //Minimum supported server Windows Server 2008 [desktop apps only] + __DEFINE_THUNK( + kernel32, + 8, + HRESULT, + WINAPI, + WerRegisterRuntimeExceptionModule, + _In_ PCWSTR pwszOutOfProcessCallbackDll, + _In_ PVOID pContext + ) + { + if (const auto pWerRegisterRuntimeExceptionModule = try_get_WerRegisterRuntimeExceptionModule()) + { + return pWerRegisterRuntimeExceptionModule(pwszOutOfProcessCallbackDll, pContext); + } + + return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN7) + + //Minimum supported client Windows Vista [desktop apps only] + //Minimum supported server Windows Server 2008 [desktop apps only] + __DEFINE_THUNK( + kernel32, + 32, + HANDLE, + WINAPI, + CreateRemoteThreadEx, + _In_ HANDLE hProcess, + _In_ LPSECURITY_ATTRIBUTES lpThreadAttributes, + _In_ SIZE_T dwStackSize, + _In_ LPTHREAD_START_ROUTINE lpStartAddress, + _In_ LPVOID lpParameter, + _In_ DWORD dwCreationFlags, + _In_ LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, + _Out_ LPDWORD lpThreadId + ) + { + if (const auto pCreateRemoteThreadEx = try_get_CreateRemoteThreadEx()) + { + return pCreateRemoteThreadEx(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpAttributeList, lpThreadId); + } + + return CreateRemoteThread(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpThreadId); + } +#endif + } } diff --git a/src/Thunks/ncrypt.hpp b/src/Thunks/ncrypt.hpp new file mode 100644 index 0000000..8338b40 --- /dev/null +++ b/src/Thunks/ncrypt.hpp @@ -0,0 +1,263 @@ + +#include + +namespace YY +{ + namespace Thunks + { + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptSignHash + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 32, + SECURITY_STATUS, + NTAPI, + NCryptSignHash, + NCRYPT_KEY_HANDLE hKey, + VOID* pPaddingInfo, + PBYTE pbHashValue, + DWORD cbHashValue, + PBYTE pbSignature, + DWORD cbSignature, + DWORD* pcbResult, + DWORD dwFlags + ) + { + if (auto const pNCryptSignHash = try_get_NCryptSignHash()) + { + return pNCryptSignHash(hKey, pPaddingInfo, pbHashValue, cbHashValue, pbSignature, cbSignature, pcbResult, dwFlags); + } + + return NTE_BAD_FLAGS; + } + +#endif + + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptGetProperty + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 24, + SECURITY_STATUS, + NTAPI, + NCryptGetProperty, + NCRYPT_HANDLE hObject, + LPCWSTR pszProperty, + PBYTE pbOutput, + DWORD cbOutput, + DWORD* pcbResult, + DWORD dwFlags + ) + { + if (auto const pNCryptGetProperty = try_get_NCryptGetProperty()) + { + return pNCryptGetProperty(hObject, pszProperty, pbOutput, cbOutput, pcbResult, dwFlags); + } + + return NTE_BAD_FLAGS; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptFreeObject + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 4, + SECURITY_STATUS, + NTAPI, + NCryptFreeObject, + NCRYPT_HANDLE hObject + ) + { + if (auto const pNCryptFreeObject = try_get_NCryptFreeObject()) + { + return pNCryptFreeObject(hObject); + } + + return NTE_BAD_FLAGS; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptCreatePersistedKey + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 24, + SECURITY_STATUS, + NTAPI, + NCryptCreatePersistedKey, + _In_ NCRYPT_PROV_HANDLE hProvider, + _Out_ NCRYPT_KEY_HANDLE* phKey, + _In_ LPCWSTR pszAlgId, + _In_opt_ LPCWSTR pszKeyName, + _In_ DWORD dwLegacyKeySpec, + _In_ DWORD dwFlags + ) + { + if (auto const pNCryptCreatePersistedKey = try_get_NCryptCreatePersistedKey()) + { + return pNCryptCreatePersistedKey(hProvider, phKey, pszAlgId, pszKeyName, dwLegacyKeySpec, dwFlags); + } + + return NTE_BAD_FLAGS; + } + +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptExportKey + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 32, + SECURITY_STATUS, + NTAPI, + NCryptExportKey, + _In_ NCRYPT_KEY_HANDLE hKey, + _In_opt_ NCRYPT_KEY_HANDLE hExportKey, + _In_ LPCWSTR pszBlobType, + _In_opt_ NCryptBufferDesc* pParameterList, + _Out_writes_bytes_to_opt_(cbOutput, *pcbResult) PBYTE pbOutput, + _In_ DWORD cbOutput, + _Out_ DWORD* pcbResult, + _In_ DWORD dwFlags + ) + { + if (auto const pNCryptExportKey = try_get_NCryptExportKey()) + { + return pNCryptExportKey(hKey, hExportKey, pszBlobType, pParameterList, pbOutput, cbOutput, pcbResult, dwFlags); + } + + return NTE_BAD_FLAGS; + } + +#endif + + + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptFinalizeKey + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 8, + SECURITY_STATUS, + NTAPI, + NCryptFinalizeKey, + _In_ NCRYPT_KEY_HANDLE hKey, + _In_ DWORD dwFlags + ) + { + if (auto const pNCryptFinalizeKey = try_get_NCryptFinalizeKey()) + { + return pNCryptFinalizeKey(hKey, dwFlags); + } + + return NTE_BAD_FLAGS; + } + +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptImportKey + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 32, + SECURITY_STATUS, + NTAPI, + NCryptImportKey, + _In_ NCRYPT_PROV_HANDLE hProvider, + _In_opt_ NCRYPT_KEY_HANDLE hImportKey, + _In_ LPCWSTR pszBlobType, + _In_opt_ NCryptBufferDesc* pParameterList, + _Out_ NCRYPT_KEY_HANDLE* phKey, + _In_reads_bytes_(cbData) PBYTE pbData, + _In_ DWORD cbData, + _In_ DWORD dwFlags + ) + { + if (auto const pNCryptImportKey = try_get_NCryptImportKey()) + { + return pNCryptImportKey(hProvider, hImportKey, pszBlobType, pParameterList, phKey, pbData, cbData, dwFlags); + } + + return NTE_BAD_FLAGS; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptImportKey + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 12, + SECURITY_STATUS, + NTAPI, + NCryptIsAlgSupported, + _In_ NCRYPT_PROV_HANDLE hProvider, + _In_ LPCWSTR pszAlgId, + _In_ DWORD dwFlags + ) + { + if (auto const pNCryptIsAlgSupported = try_get_NCryptIsAlgSupported()) + { + return pNCryptIsAlgSupported(hProvider, pszAlgId, dwFlags); + } + + return NTE_BAD_FLAGS; + } + +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //NCryptImportKey + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + ncrypt, + 12, + SECURITY_STATUS, + NTAPI, + NCryptOpenStorageProvider, + _Out_ NCRYPT_PROV_HANDLE* phProvider, + _In_opt_ LPCWSTR pszProviderName, + _In_ DWORD dwFlags + ) + { + if (auto const pNCryptOpenStorageProvider = try_get_NCryptOpenStorageProvider()) + { + return pNCryptOpenStorageProvider(phProvider, pszProviderName, dwFlags); + } + + return NTE_BAD_FLAGS; + } + +#endif + + + }//namespace Thunks + +} //namespace YY diff --git a/src/Thunks/propsys.hpp b/src/Thunks/propsys.hpp new file mode 100644 index 0000000..e416075 --- /dev/null +++ b/src/Thunks/propsys.hpp @@ -0,0 +1,244 @@ + +#include +#include + + +namespace YY +{ + namespace Thunks + { +#ifdef YY_Thunks_Implemented + namespace internal + { +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + static __forceinline BOOL __fastcall myisemptyornull(const PROPVARIANT* propvar) + { + if (propvar->vt == VT_EMPTY || propvar->vt == VT_NULL) + return TRUE; + if ((propvar->vt & VT_ARRAY) == VT_ARRAY) + { + int i; + for (i = 0; i < propvar->parray->cDims; i++) + { + if (propvar->parray->rgsabound[i].cElements != 0) + break; + } + return i == propvar->parray->cDims; + } + if (propvar->vt == VT_CLSID) + return !propvar->puuid; + + if (propvar->vt & VT_VECTOR) + return !propvar->caub.cElems; + + /* FIXME: byrefs, errors? */ + return FALSE; + } + + static __forceinline INT __fastcall MyVariantCompareEx(const PROPVARIANT* propvar1, const PROPVARIANT* propvar2, PROPVAR_COMPARE_FLAGS flags) + { + const PROPVARIANT* propvar2_converted; + unsigned int count; + HRESULT hr; + INT res = -1; + + + if (myisemptyornull(propvar1)) + { + if (myisemptyornull(propvar2)) + return 0; + return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? 1 : -1; + } + + if (myisemptyornull(propvar2)) + return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? -1 : 1; + + if (propvar1->vt != propvar2->vt) + { + return -1; + } + + propvar2_converted = propvar2; + +#define CMP_NUM_VALUE(var) do { \ + if (propvar1->var > propvar2_converted->var) \ + res = 1; \ + else if (propvar1->var < propvar2_converted->var) \ + res = -1; \ + else \ + res = 0; \ + } while (0) + + switch (propvar1->vt) + { + case VT_I1: + CMP_NUM_VALUE(cVal); + break; + case VT_UI1: + CMP_NUM_VALUE(bVal); + break; + case VT_I2: + CMP_NUM_VALUE(iVal); + break; + case VT_UI2: + CMP_NUM_VALUE(uiVal); + break; + case VT_I4: + CMP_NUM_VALUE(lVal); + break; + case VT_UI4: + CMP_NUM_VALUE(ulVal); + break; + case VT_I8: + CMP_NUM_VALUE(hVal.QuadPart); + break; + case VT_UI8: + CMP_NUM_VALUE(uhVal.QuadPart); + break; + case VT_R4: + CMP_NUM_VALUE(fltVal); + break; + case VT_R8: + CMP_NUM_VALUE(dblVal); + break; + case VT_BSTR: + case VT_LPWSTR: + /* FIXME: Use other string flags. */ + if (flags & (PVCF_USESTRCMPI | PVCF_USESTRCMPIC)) + res = lstrcmpiW(propvar1->bstrVal, propvar2_converted->bstrVal); + else + res = lstrcmpW(propvar1->bstrVal, propvar2_converted->bstrVal); + break; + case VT_LPSTR: + /* FIXME: Use other string flags. */ + if (flags & (PVCF_USESTRCMPI | PVCF_USESTRCMPIC)) + res = lstrcmpiA(propvar1->pszVal, propvar2_converted->pszVal); + else + res = lstrcmpA(propvar1->pszVal, propvar2_converted->pszVal); + break; + case VT_CLSID: + res = memcmp(propvar1->puuid, propvar2->puuid, sizeof(*propvar1->puuid)); + if (res) res = res > 0 ? 1 : -1; + break; + case VT_VECTOR | VT_UI1: + count = min(propvar1->caub.cElems, propvar2->caub.cElems); + res = count ? memcmp(propvar1->caub.pElems, propvar2->caub.pElems, sizeof(*propvar1->caub.pElems) * count) : 0; + if (res) res = res > 0 ? 1 : -1; + if (!res && propvar1->caub.cElems != propvar2->caub.cElems) + res = propvar1->caub.cElems > propvar2->caub.cElems ? 1 : -1; + break; + default: + res = -1; + break; + } + + return res; + } + +#endif + } +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //InitPropVariantFromCLSID + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + propsys, + 8, + HRESULT, + WINAPI, + InitPropVariantFromCLSID, + _In_ REFCLSID clsid, + _Out_ PROPVARIANT* ppropvar + ) + { + if (auto const pInitPropVariantFromCLSID = try_get_InitPropVariantFromCLSID()) + { + return pInitPropVariantFromCLSID(clsid, ppropvar); + } + + return E_INVALIDARG; + } + +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //PSGetPropertyKeyFromName + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + propsys, + 8, + HRESULT, + WINAPI, + PSGetPropertyKeyFromName, + _In_ PCWSTR pszName, + _Out_ PROPERTYKEY* ppropkey + ) + { + if (auto const pPSGetPropertyKeyFromName = try_get_PSGetPropertyKeyFromName()) + { + return pPSGetPropertyKeyFromName(pszName, ppropkey); + } + + return E_INVALIDARG; + } + +#endif + + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //VariantCompare + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + propsys, + 8, + int, + WINAPI, + VariantCompare, + _In_ REFVARIANT var1, + _In_ REFVARIANT var2 + ) + { + if (auto const pVariantCompare = try_get_VariantCompare()) + { + return pVariantCompare(var1, var2); + } + + return -1; + } + +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //VariantCompare + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + propsys, + 8, + HRESULT, + WINAPI, + PSCreateMemoryPropertyStore, + _In_ REFIID riid, + _Outptr_ void** ppv + ) + { + if (auto const pPSCreateMemoryPropertyStore = try_get_PSCreateMemoryPropertyStore()) + { + return pPSCreateMemoryPropertyStore(riid, ppv); + } + + return E_INVALIDARG; + } + +#endif + + + }//namespace Thunks + +} //namespace YY diff --git a/src/Thunks/shell32.hpp b/src/Thunks/shell32.hpp index 0f12957..804d685 100644 --- a/src/Thunks/shell32.hpp +++ b/src/Thunks/shell32.hpp @@ -1124,4 +1124,80 @@ namespace YY::Thunks return _hr; } #endif + + + +#if (YY_Thunks_Support_Version < NTDDI_WIN7) + + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + shell32, + 12, + HRESULT, + STDAPICALLTYPE, + SHGetPropertyStoreForWindow, + _In_ HWND hwnd, + _In_ REFIID riid, + _Inout_ void** ppv + ) + { + if (auto const pSHGetPropertyStoreForWindow = try_get_SHGetPropertyStoreForWindow()) + { + return pSHGetPropertyStoreForWindow(hwnd, riid, ppv); + } + + return __HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); + } +#endif + + + +#if (YY_Thunks_Support_Version < NTDDI_WIN7) + + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + shell32, + 8, + HRESULT, + STDAPICALLTYPE, + SHOpenWithDialog, + _In_ HWND hwndParent, + _In_ const OPENASINFO* poainfo + ) + { + if (auto const pSHOpenWithDialog = try_get_SHOpenWithDialog()) + { + return pSHOpenWithDialog(hwndParent, poainfo); + } + + return __HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); + } +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN7) + + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + shell32, + 4, + HRESULT, + STDAPICALLTYPE, + SHQueryUserNotificationState, + _Out_ QUERY_USER_NOTIFICATION_STATE* pquns + + ) + { + if (auto const pSHQueryUserNotificationState = try_get_SHQueryUserNotificationState()) + { + return pSHQueryUserNotificationState(pquns); + } + + return __HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); + } +#endif + } //namespace YY diff --git a/src/Thunks/wevtapi.hpp b/src/Thunks/wevtapi.hpp new file mode 100644 index 0000000..6b464e3 --- /dev/null +++ b/src/Thunks/wevtapi.hpp @@ -0,0 +1,152 @@ + +#include + +namespace YY +{ + namespace Thunks + { + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //EvtClose + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + wevtapi, + 4, + BOOL, + WINAPI, + EvtClose, + _In_ _Post_invalid_ EVT_HANDLE Object + ) + { + if (auto const pEvtClose = try_get_EvtClose()) + { + return pEvtClose(Object); + } + + return TRUE; + } + +#endif + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //EvtCreateRenderContext + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + wevtapi, + 12, + EVT_HANDLE, + WINAPI, + EvtCreateRenderContext, + DWORD ValuePathsCount, + _In_reads_opt_(ValuePathsCount) LPCWSTR* ValuePaths, + DWORD Flags + ) + { + if (auto const pEvtCreateRenderContext = try_get_EvtCreateRenderContext()) + { + return pEvtCreateRenderContext(ValuePathsCount, ValuePaths, Flags); + } + + return NULL; + } + +#endif + + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //EvtNext + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + wevtapi, + 24, + BOOL, + WINAPI, + EvtNext, + _In_ EVT_HANDLE ResultSet, + DWORD EventsSize, + _Out_writes_to_(EventsSize, *Returned) PEVT_HANDLE Events, + DWORD Timeout, + DWORD Flags, + _Out_range_(0, EventsSize) PDWORD Returned + ) + { + if (auto const pEvtNext = try_get_EvtNext()) + { + return pEvtNext(ResultSet, EventsSize, Events, Timeout, Flags, Returned); + } + + return FALSE; + } + +#endif + + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //EvtQuery + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + wevtapi, + 16, + EVT_HANDLE, + WINAPI, + EvtQuery, + _In_opt_ EVT_HANDLE Session, + _In_opt_z_ LPCWSTR Path, + _In_opt_z_ LPCWSTR Query, + DWORD Flags + ) + { + if (auto const pEvtQuery = try_get_EvtQuery()) + { + return pEvtQuery(Session, Path, Query, Flags); + } + + return NULL; + } + +#endif + + + + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + //EvtRender + //Minimum supported client Windows Vista + //Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + wevtapi, + 28, + BOOL, + WINAPI, + EvtRender, + _In_opt_ EVT_HANDLE Context, + _In_ EVT_HANDLE Fragment, + DWORD Flags, + DWORD BufferSize, + _Out_writes_bytes_to_opt_(BufferSize, *BufferUsed) PVOID Buffer, + _Out_ PDWORD BufferUsed, + _Out_ PDWORD PropertyCount + ) + { + if (auto const pEvtRender = try_get_EvtRender()) + { + return pEvtRender(Context, Fragment, Flags, BufferSize, Buffer, BufferUsed, PropertyCount); + } + + return FALSE; + } + +#endif + + + + }//namespace Thunks + +} //namespace YY diff --git a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj index 0234357..19df143 100644 --- a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj +++ b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj @@ -222,6 +222,7 @@ + @@ -231,6 +232,7 @@ + @@ -239,14 +241,17 @@ + + + diff --git a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters index 05e8fe4..3a08698 100644 --- a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters +++ b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters @@ -314,6 +314,21 @@ Thunks + + Thunks + + + Thunks + + + Thunks + + + Thunks + + + Thunks +