[PATCH] ntoskrnl: Have MmIsAddressValid use IsBadReadPtr.

Zhiyi Zhang yi.gd.cn at gmail.com
Tue Jun 5 21:36:47 CDT 2018


Hi Derek,

I don't think MSDN incorrectly documents this function.
The function is meant to be used in nt kernel space, however wineserver is
in user space as far as I know. So we would need different implementation.

May be we could do something like return !IsBadWritePtr(VirtualAddress, 1) || !IsBadReadPtr(VirtualAddress, 1).
And write a test to verify such behavior.

Regards,
Zhiyi

On Tue 6 5 23:35, Derek Lesho wrote:
> Side note, while this change does not follow the MSDN, it appears that the
> MSDN incorrectly documents the function.
> 
> This blog post from 2006 explains more:
> https://blogs.msdn.microsoft.com/doronh/2006/03/09/beware-the-shiny-light-that-is-mmisaddressvalid/
> 
> On Tue, Jun 5, 2018 at 11:14 AM, Derek Lesho <dereklesho52 at gmail.com> wrote:
> 
>> Fixes an error inside EasyAntiCheat.sys, which uses MmIsAddressValid on
>> ntoskrnl.exe, to find its base address.  Wine will always return FALSE,
>> because it checks for write access to ntoskrnl, when all the driver
>> needs is read access
>>
>> Tested on Arch Linux
>>
>> Signed-off-by: Derek Lesho <dereklesho52 at Gmail.com>
>> ---
>>  dlls/ntoskrnl.exe/ntoskrnl.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
>> index 55027c5..e4c1c35 100644
>> --- a/dlls/ntoskrnl.exe/ntoskrnl.c
>> +++ b/dlls/ntoskrnl.exe/ntoskrnl.c
>> @@ -2164,7 +2164,7 @@ void WINAPI MmFreeNonCachedMemory( void *addr,
>> SIZE_T size )
>>  BOOLEAN WINAPI MmIsAddressValid(PVOID VirtualAddress)
>>  {
>>      TRACE("(%p)\n", VirtualAddress);
>> -    return !IsBadWritePtr(VirtualAddress, 1);
>> +    return !IsBadReadPtr(VirtualAddress, 1);
>>  }
>>
>>  /***********************************************************************
>> --
>> 2.7.4
>>
>>
> 
> 
> 
> 



More information about the wine-devel mailing list