KaFu Posted January 31, 2012 Share Posted January 31, 2012 Yashieds most excellent WinAPIEx UDF is required for this example. expandcollapse popup#include <APIConstants.au3> #include <WinAPIEx.au3> #cs http://www.catch22.net/tuts/memory-techniques-part-1 CreateFileMapping function http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537(v=vs.85).aspx MapViewOfFile function http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761(v=vs.85).aspx File Mapping http://msdn.microsoft.com/en-us/library/windows/desktop/aa366556(v=vs.85).aspx #ce Global $nBytes $sFile = @SystemDir & "shell32.dll" $iBytesToRead = 32 $iOffset = 235222 #region - Read file by _WinAPI_CreateFileEx() - Start $tBuffer = DllStructCreate("byte[" & $iBytesToRead & "]") $hFile = _WinAPI_CreateFileEx($sFile, 3, 0x80000000, 7, 0x08000000) _WinAPI_SetFilePointerEx($hFile, $iOffset) ; use for files > 2 GB !!! _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $iBytesToRead, $nBytes) _WinAPI_CloseHandle($hFile) ConsoleWrite(DllStructGetData($tBuffer, 1) & @CRLF) #region - Read file by _WinAPI_CreateFileEx() - End $tBuffer = 0 ConsoleWrite(@CRLF & "**********************" & @CRLF & @CRLF) #region - Read file by _WinAPI_CreateFileMapping - Start #cs The combination of the high and low offsets must specify an offset within the file mapping. They must also match the memory allocation granularity of the system. That is, the offset must be a multiple of the allocation granularity. To obtain the memory allocation granularity of the system, use the GetSystemInfo function, which fills in the members of a SYSTEM_INFO structure. #ce $a_GetSystemInfo = _WinAPI_GetSystemInfo() $i_Global_MemoryAllocationGranularity = $a_GetSystemInfo[7] $iOffset_Slice = Round(Floor($iOffset / $i_Global_MemoryAllocationGranularity)) * $i_Global_MemoryAllocationGranularity ConsoleWrite("$iOffset_Slice " & @TAB & @TAB & $iOffset_Slice & @CRLF) $iOffset_Slice_Size = $iOffset - $iOffset_Slice ConsoleWrite("$iOffset_Slice_Size " & @TAB & $iOffset_Slice_Size & @CRLF) $hFile = _WinAPI_CreateFileEx($sFile, 3, 0x80000000, 7, 0x08000000) $hMapping = _WinAPI_CreateFileMapping($hFile, 0, '', $PAGE_READONLY) $pAddress = _WinAPI_MapViewOfFile($hMapping, $iOffset_Slice, $iOffset_Slice_Size + $iBytesToRead, $FILE_MAP_READ) $tBuffer = DllStructCreate('byte[' & $iBytesToRead & ']', $pAddress + $iOffset_Slice_Size) ConsoleWrite(DllStructGetData($tBuffer, 1) & @CRLF) _WinAPI_UnmapViewOfFile($pAddress) _WinAPI_CloseHandle($hMapping) _WinAPI_CloseHandle($hFile) #region - Read file by _WinAPI_CreateFileMapping - End OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now