@@ -326,39 +326,46 @@ pub unsafe fn MapUserPhysicalPagesScatter(virtualaddresses: *const *const core::
326326 unsafe { MapUserPhysicalPagesScatter ( virtualaddresses, numberofpages, pagearray. unwrap_or ( core:: mem:: zeroed ( ) ) as _ ) . ok ( ) }
327327}
328328#[ inline]
329- pub unsafe fn MapViewOfFile ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize ) -> MEMORY_MAPPED_VIEW_ADDRESS {
329+ pub unsafe fn MapViewOfFile ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize ) -> windows_core :: Result < MEMORY_MAPPED_VIEW_ADDRESS > {
330330 windows_core:: link!( "kernel32.dll" "system" fn MapViewOfFile ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize ) -> MEMORY_MAPPED_VIEW_ADDRESS ) ;
331- unsafe { MapViewOfFile ( hfilemappingobject, dwdesiredaccess, dwfileoffsethigh, dwfileoffsetlow, dwnumberofbytestomap) }
331+ let result__ = unsafe { MapViewOfFile ( hfilemappingobject, dwdesiredaccess, dwfileoffsethigh, dwfileoffsetlow, dwnumberofbytestomap) } ;
332+ ( !result__. is_invalid ( ) ) . then_some ( result__) . ok_or_else ( windows_core:: Error :: from_thread)
332333}
333334#[ inline]
334- pub unsafe fn MapViewOfFile3 ( filemapping : super :: super :: Foundation :: HANDLE , process : Option < super :: super :: Foundation :: HANDLE > , baseaddress : Option < * const core:: ffi:: c_void > , offset : u64 , viewsize : usize , allocationtype : VIRTUAL_ALLOCATION_TYPE , pageprotection : u32 , extendedparameters : Option < & mut [ MEM_EXTENDED_PARAMETER ] > ) -> MEMORY_MAPPED_VIEW_ADDRESS {
335+ pub unsafe fn MapViewOfFile3 ( filemapping : super :: super :: Foundation :: HANDLE , process : Option < super :: super :: Foundation :: HANDLE > , baseaddress : Option < * const core:: ffi:: c_void > , offset : u64 , viewsize : usize , allocationtype : VIRTUAL_ALLOCATION_TYPE , pageprotection : u32 , extendedparameters : Option < & mut [ MEM_EXTENDED_PARAMETER ] > ) -> windows_core :: Result < MEMORY_MAPPED_VIEW_ADDRESS > {
335336 windows_core:: link!( "api-ms-win-core-memory-l1-1-6.dll" "system" fn MapViewOfFile3 ( filemapping : super :: super :: Foundation :: HANDLE , process : super :: super :: Foundation :: HANDLE , baseaddress : * const core:: ffi:: c_void, offset : u64 , viewsize : usize , allocationtype : VIRTUAL_ALLOCATION_TYPE , pageprotection : u32 , extendedparameters : * mut MEM_EXTENDED_PARAMETER , parametercount : u32 ) -> MEMORY_MAPPED_VIEW_ADDRESS ) ;
336- unsafe { MapViewOfFile3 ( filemapping, process. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , baseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , offset, viewsize, allocationtype, pageprotection, core:: mem:: transmute ( extendedparameters. as_deref ( ) . map_or ( core:: ptr:: null ( ) , |slice| slice. as_ptr ( ) ) ) , extendedparameters. as_deref ( ) . map_or ( 0 , |slice| slice. len ( ) . try_into ( ) . unwrap ( ) ) ) }
337+ let result__ = unsafe { MapViewOfFile3 ( filemapping, process. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , baseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , offset, viewsize, allocationtype, pageprotection, core:: mem:: transmute ( extendedparameters. as_deref ( ) . map_or ( core:: ptr:: null ( ) , |slice| slice. as_ptr ( ) ) ) , extendedparameters. as_deref ( ) . map_or ( 0 , |slice| slice. len ( ) . try_into ( ) . unwrap ( ) ) ) } ;
338+ ( !result__. is_invalid ( ) ) . then_some ( result__) . ok_or_else ( windows_core:: Error :: from_thread)
337339}
338340#[ inline]
339- pub unsafe fn MapViewOfFile3FromApp ( filemapping : super :: super :: Foundation :: HANDLE , process : Option < super :: super :: Foundation :: HANDLE > , baseaddress : Option < * const core:: ffi:: c_void > , offset : u64 , viewsize : usize , allocationtype : VIRTUAL_ALLOCATION_TYPE , pageprotection : u32 , extendedparameters : Option < & mut [ MEM_EXTENDED_PARAMETER ] > ) -> MEMORY_MAPPED_VIEW_ADDRESS {
341+ pub unsafe fn MapViewOfFile3FromApp ( filemapping : super :: super :: Foundation :: HANDLE , process : Option < super :: super :: Foundation :: HANDLE > , baseaddress : Option < * const core:: ffi:: c_void > , offset : u64 , viewsize : usize , allocationtype : VIRTUAL_ALLOCATION_TYPE , pageprotection : u32 , extendedparameters : Option < & mut [ MEM_EXTENDED_PARAMETER ] > ) -> windows_core :: Result < MEMORY_MAPPED_VIEW_ADDRESS > {
340342 windows_core:: link!( "api-ms-win-core-memory-l1-1-6.dll" "system" fn MapViewOfFile3FromApp ( filemapping : super :: super :: Foundation :: HANDLE , process : super :: super :: Foundation :: HANDLE , baseaddress : * const core:: ffi:: c_void, offset : u64 , viewsize : usize , allocationtype : VIRTUAL_ALLOCATION_TYPE , pageprotection : u32 , extendedparameters : * mut MEM_EXTENDED_PARAMETER , parametercount : u32 ) -> MEMORY_MAPPED_VIEW_ADDRESS ) ;
341- unsafe { MapViewOfFile3FromApp ( filemapping, process. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , baseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , offset, viewsize, allocationtype, pageprotection, core:: mem:: transmute ( extendedparameters. as_deref ( ) . map_or ( core:: ptr:: null ( ) , |slice| slice. as_ptr ( ) ) ) , extendedparameters. as_deref ( ) . map_or ( 0 , |slice| slice. len ( ) . try_into ( ) . unwrap ( ) ) ) }
343+ let result__ = unsafe { MapViewOfFile3FromApp ( filemapping, process. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , baseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , offset, viewsize, allocationtype, pageprotection, core:: mem:: transmute ( extendedparameters. as_deref ( ) . map_or ( core:: ptr:: null ( ) , |slice| slice. as_ptr ( ) ) ) , extendedparameters. as_deref ( ) . map_or ( 0 , |slice| slice. len ( ) . try_into ( ) . unwrap ( ) ) ) } ;
344+ ( !result__. is_invalid ( ) ) . then_some ( result__) . ok_or_else ( windows_core:: Error :: from_thread)
342345}
343346#[ inline]
344- pub unsafe fn MapViewOfFileEx ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize , lpbaseaddress : Option < * const core:: ffi:: c_void > ) -> MEMORY_MAPPED_VIEW_ADDRESS {
347+ pub unsafe fn MapViewOfFileEx ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize , lpbaseaddress : Option < * const core:: ffi:: c_void > ) -> windows_core :: Result < MEMORY_MAPPED_VIEW_ADDRESS > {
345348 windows_core:: link!( "kernel32.dll" "system" fn MapViewOfFileEx ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize , lpbaseaddress : * const core:: ffi:: c_void) -> MEMORY_MAPPED_VIEW_ADDRESS ) ;
346- unsafe { MapViewOfFileEx ( hfilemappingobject, dwdesiredaccess, dwfileoffsethigh, dwfileoffsetlow, dwnumberofbytestomap, lpbaseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ ) }
349+ let result__ = unsafe { MapViewOfFileEx ( hfilemappingobject, dwdesiredaccess, dwfileoffsethigh, dwfileoffsetlow, dwnumberofbytestomap, lpbaseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ ) } ;
350+ ( !result__. is_invalid ( ) ) . then_some ( result__) . ok_or_else ( windows_core:: Error :: from_thread)
347351}
348352#[ inline]
349- pub unsafe fn MapViewOfFileExNuma ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize , lpbaseaddress : Option < * const core:: ffi:: c_void > , nndpreferred : u32 ) -> MEMORY_MAPPED_VIEW_ADDRESS {
353+ pub unsafe fn MapViewOfFileExNuma ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize , lpbaseaddress : Option < * const core:: ffi:: c_void > , nndpreferred : u32 ) -> windows_core :: Result < MEMORY_MAPPED_VIEW_ADDRESS > {
350354 windows_core:: link!( "kernel32.dll" "system" fn MapViewOfFileExNuma ( hfilemappingobject : super :: super :: Foundation :: HANDLE , dwdesiredaccess : FILE_MAP , dwfileoffsethigh : u32 , dwfileoffsetlow : u32 , dwnumberofbytestomap : usize , lpbaseaddress : * const core:: ffi:: c_void, nndpreferred : u32 ) -> MEMORY_MAPPED_VIEW_ADDRESS ) ;
351- unsafe { MapViewOfFileExNuma ( hfilemappingobject, dwdesiredaccess, dwfileoffsethigh, dwfileoffsetlow, dwnumberofbytestomap, lpbaseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , nndpreferred) }
355+ let result__ = unsafe { MapViewOfFileExNuma ( hfilemappingobject, dwdesiredaccess, dwfileoffsethigh, dwfileoffsetlow, dwnumberofbytestomap, lpbaseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , nndpreferred) } ;
356+ ( !result__. is_invalid ( ) ) . then_some ( result__) . ok_or_else ( windows_core:: Error :: from_thread)
352357}
353358#[ inline]
354- pub unsafe fn MapViewOfFileFromApp ( hfilemappingobject : super :: super :: Foundation :: HANDLE , desiredaccess : FILE_MAP , fileoffset : u64 , numberofbytestomap : usize ) -> MEMORY_MAPPED_VIEW_ADDRESS {
359+ pub unsafe fn MapViewOfFileFromApp ( hfilemappingobject : super :: super :: Foundation :: HANDLE , desiredaccess : FILE_MAP , fileoffset : u64 , numberofbytestomap : usize ) -> windows_core :: Result < MEMORY_MAPPED_VIEW_ADDRESS > {
355360 windows_core:: link!( "kernel32.dll" "system" fn MapViewOfFileFromApp ( hfilemappingobject : super :: super :: Foundation :: HANDLE , desiredaccess : FILE_MAP , fileoffset : u64 , numberofbytestomap : usize ) -> MEMORY_MAPPED_VIEW_ADDRESS ) ;
356- unsafe { MapViewOfFileFromApp ( hfilemappingobject, desiredaccess, fileoffset, numberofbytestomap) }
361+ let result__ = unsafe { MapViewOfFileFromApp ( hfilemappingobject, desiredaccess, fileoffset, numberofbytestomap) } ;
362+ ( !result__. is_invalid ( ) ) . then_some ( result__) . ok_or_else ( windows_core:: Error :: from_thread)
357363}
358364#[ inline]
359- pub unsafe fn MapViewOfFileNuma2 ( filemappinghandle : super :: super :: Foundation :: HANDLE , processhandle : super :: super :: Foundation :: HANDLE , offset : u64 , baseaddress : Option < * const core:: ffi:: c_void > , viewsize : usize , allocationtype : u32 , pageprotection : u32 , preferrednode : u32 ) -> MEMORY_MAPPED_VIEW_ADDRESS {
365+ pub unsafe fn MapViewOfFileNuma2 ( filemappinghandle : super :: super :: Foundation :: HANDLE , processhandle : super :: super :: Foundation :: HANDLE , offset : u64 , baseaddress : Option < * const core:: ffi:: c_void > , viewsize : usize , allocationtype : u32 , pageprotection : u32 , preferrednode : u32 ) -> windows_core :: Result < MEMORY_MAPPED_VIEW_ADDRESS > {
360366 windows_core:: link!( "api-ms-win-core-memory-l1-1-5.dll" "system" fn MapViewOfFileNuma2 ( filemappinghandle : super :: super :: Foundation :: HANDLE , processhandle : super :: super :: Foundation :: HANDLE , offset : u64 , baseaddress : * const core:: ffi:: c_void, viewsize : usize , allocationtype : u32 , pageprotection : u32 , preferrednode : u32 ) -> MEMORY_MAPPED_VIEW_ADDRESS ) ;
361- unsafe { MapViewOfFileNuma2 ( filemappinghandle, processhandle, offset, baseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , viewsize, allocationtype, pageprotection, preferrednode) }
367+ let result__ = unsafe { MapViewOfFileNuma2 ( filemappinghandle, processhandle, offset, baseaddress. unwrap_or ( core:: mem:: zeroed ( ) ) as _ , viewsize, allocationtype, pageprotection, preferrednode) } ;
368+ ( !result__. is_invalid ( ) ) . then_some ( result__) . ok_or_else ( windows_core:: Error :: from_thread)
362369}
363370#[ inline]
364371pub unsafe fn OfferVirtualMemory ( virtualaddress : & mut [ u8 ] , priority : OFFER_PRIORITY ) -> u32 {
@@ -480,17 +487,17 @@ pub unsafe fn SetSystemFileCacheSize(minimumfilecachesize: usize, maximumfilecac
480487#[ inline]
481488pub unsafe fn UnmapViewOfFile ( lpbaseaddress : MEMORY_MAPPED_VIEW_ADDRESS ) -> windows_core:: Result < ( ) > {
482489 windows_core:: link!( "kernel32.dll" "system" fn UnmapViewOfFile ( lpbaseaddress : MEMORY_MAPPED_VIEW_ADDRESS ) -> windows_core:: BOOL ) ;
483- unsafe { UnmapViewOfFile ( core :: mem :: transmute ( lpbaseaddress) ) . ok ( ) }
490+ unsafe { UnmapViewOfFile ( lpbaseaddress) . ok ( ) }
484491}
485492#[ inline]
486493pub unsafe fn UnmapViewOfFile2 ( process : super :: super :: Foundation :: HANDLE , baseaddress : MEMORY_MAPPED_VIEW_ADDRESS , unmapflags : UNMAP_VIEW_OF_FILE_FLAGS ) -> windows_core:: Result < ( ) > {
487494 windows_core:: link!( "api-ms-win-core-memory-l1-1-5.dll" "system" fn UnmapViewOfFile2 ( process : super :: super :: Foundation :: HANDLE , baseaddress : MEMORY_MAPPED_VIEW_ADDRESS , unmapflags : UNMAP_VIEW_OF_FILE_FLAGS ) -> windows_core:: BOOL ) ;
488- unsafe { UnmapViewOfFile2 ( process, core :: mem :: transmute ( baseaddress) , unmapflags) . ok ( ) }
495+ unsafe { UnmapViewOfFile2 ( process, baseaddress, unmapflags) . ok ( ) }
489496}
490497#[ inline]
491498pub unsafe fn UnmapViewOfFileEx ( baseaddress : MEMORY_MAPPED_VIEW_ADDRESS , unmapflags : UNMAP_VIEW_OF_FILE_FLAGS ) -> windows_core:: Result < ( ) > {
492499 windows_core:: link!( "kernel32.dll" "system" fn UnmapViewOfFileEx ( baseaddress : MEMORY_MAPPED_VIEW_ADDRESS , unmapflags : UNMAP_VIEW_OF_FILE_FLAGS ) -> windows_core:: BOOL ) ;
493- unsafe { UnmapViewOfFileEx ( core :: mem :: transmute ( baseaddress) , unmapflags) . ok ( ) }
500+ unsafe { UnmapViewOfFileEx ( baseaddress, unmapflags) . ok ( ) }
494501}
495502#[ inline]
496503pub unsafe fn UnregisterBadMemoryNotification ( registrationhandle : * const core:: ffi:: c_void ) -> windows_core:: Result < ( ) > {
@@ -849,10 +856,13 @@ pub struct MEMORY_BASIC_INFORMATION64 {
849856 pub Type : PAGE_TYPE ,
850857 pub __alignment2 : u32 ,
851858}
852- #[ repr( C ) ]
853- #[ derive( Clone , Copy , Debug , PartialEq ) ]
854- pub struct MEMORY_MAPPED_VIEW_ADDRESS {
855- pub Value : * mut core:: ffi:: c_void ,
859+ #[ repr( transparent) ]
860+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
861+ pub struct MEMORY_MAPPED_VIEW_ADDRESS ( pub * mut core:: ffi:: c_void ) ;
862+ impl MEMORY_MAPPED_VIEW_ADDRESS {
863+ pub fn is_invalid ( & self ) -> bool {
864+ self . 0 . is_null ( )
865+ }
856866}
857867impl Default for MEMORY_MAPPED_VIEW_ADDRESS {
858868 fn default ( ) -> Self {
0 commit comments