From e298cdee93ff9e87bbb904358409f433c747aeb7 Mon Sep 17 00:00:00 2001 From: mingkuang Date: Sun, 23 Jun 2019 13:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0QueryWorkingSetEx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReadMe.md | 4 +++- src/YY_Thunks.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index 367af17..443d8d8 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -126,6 +126,7 @@ YY-Thunks(鸭船),存在的目的就是抹平不同系统的差异,编 | *[GetNumaNodeProcessorMaskEx](https://msdn.microsoft.com/en-us/library/windows/desktop/dd405493.aspx) | 不存在时,调用GetNumaNodeProcessorMask。 | *[SetThreadGroupAffinity](https://msdn.microsoft.com/en-us/library/windows/desktop/dd405516.aspx) | 不存在时,调用SetThreadAffinityMask。 | *[CancelIoEx](https://docs.microsoft.com/en-us/windows/desktop/FileIO/cancelioex-func) | 不存在时,调用CancelIo(会把此句柄的所有IO操作取消掉!)。 +| *[QueryWorkingSetEx](https://docs.microsoft.com/en-us/windows/desktop/api/Psapi/nf-psapi-getwschangesex) | 不存在时,返回FALSE,并设置 LastError = ERROR_INVALID_FUNCTION。 ## Changes @@ -238,9 +239,10 @@ YY-Thunks(鸭船),存在的目的就是抹平不同系统的差异,编 * 添加TryAcquireSRWLockShared -### 1.0.1.8 - 优化实现(2019-06-18 16:00) +### 1.0.1.9 - 优化实现(2019-06-23 13:00) * 优化代码结构,减少不必要的全局对象引入。 * 内部函数采用__fastcall约定,减少栈操作。 * 增加YY-Thunks版本互斥。 * 改进与联想一键影音的兼容性,由于联想一键影音错会乱Hook,导致LoadLibraryExW行为异常。这样将导致YY-Thunks等在没有安装KB2533623的系统上无法正常使用问题。 * 改进Windows 7 RTM以及以下系统的兼容性,由于这些老版本系统由于在LoadLibraryExW期间不会恢复重定向,因此当目标线程关闭重定向时可能导致YY-Thunks无法正常工作。 +* 添加QueryWorkingSetEx diff --git a/src/YY_Thunks.cpp b/src/YY_Thunks.cpp index a205448..6f20524 100644 --- a/src/YY_Thunks.cpp +++ b/src/YY_Thunks.cpp @@ -85,6 +85,7 @@ _APPLY(TryAcquireSRWLockShared, kernel32 ) \ _APPLY(EnumProcessModulesEx, psapi ) \ _APPLY(GetWsChangesEx, psapi ) \ + _APPLY(QueryWorkingSetEx, psapi ) \ _APPLY(GetFileVersionInfoExW, version ) \ _APPLY(GetFileVersionInfoExA, version ) \ _APPLY(GetFileVersionInfoSizeExW, version ) \ @@ -4693,6 +4694,34 @@ _LCRT_DEFINE_IAT_SYMBOL(GetWsChangesEx, _12); #endif +#if (YY_Thunks_Support_Version < NTDDI_WS03SP1) +//Windows Vista, Windows XP Professional x64 Edition [desktop apps only] +//Windows Server 2008, Windows Server 2003 with SP1 [desktop apps only] + +EXTERN_C +BOOL +WINAPI +QueryWorkingSetEx( + _In_ HANDLE hProcess, + _Out_writes_bytes_(cb) PVOID pv, + _In_ DWORD cb + ) +{ + if (const auto pQueryWorkingSetEx = try_get_QueryWorkingSetEx()) + { + return pQueryWorkingSetEx(hProcess, pv, cb); + } + else + { + SetLastError(ERROR_INVALID_FUNCTION); + return FALSE; + } +} + +_LCRT_DEFINE_IAT_SYMBOL(QueryWorkingSetEx, _12); + +#endif + #if (YY_Thunks_Support_Version < NTDDI_WIN6) //Windows Vista [desktop apps only] //Windows Server 2008 [desktop apps only]