Sawyer
19.11.2008, 00:27
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Integer)
Function GetEOF(ByVal Path As String) As Long
Dim ByteArray() As Byte
Dim PE As Long, NumberOfSections As Integer
Dim BeginLastSection As Long
Dim RawSize As Long, RawOffset As Long
FileOpen(10, Path, OpenMode.Binary, OpenAccess.Default)
ReDim ByteArray(LOF(10) - 1)
FileGet(10, ByteArray)
FileClose(10)
Call CopyMemory(PE, ByteArray(&H3C), 4)
Call CopyMemory(NumberOfSections, ByteArray(PE + &H6), 2)
BeginLastSection = PE + &HF8 + ((NumberOfSections - 1) * &H28)
Call CopyMemory(RawSize, ByteArray(BeginLastSection + 16), 4)
Call CopyMemory(RawOffset, ByteArray(BeginLastSection + 20), 4)
GetEOF = RawSize + RawOffset
End Function
Function GetEOF(ByVal Path As String) As Long
Dim ByteArray() As Byte
Dim PE As Long, NumberOfSections As Integer
Dim BeginLastSection As Long
Dim RawSize As Long, RawOffset As Long
FileOpen(10, Path, OpenMode.Binary, OpenAccess.Default)
ReDim ByteArray(LOF(10) - 1)
FileGet(10, ByteArray)
FileClose(10)
Call CopyMemory(PE, ByteArray(&H3C), 4)
Call CopyMemory(NumberOfSections, ByteArray(PE + &H6), 2)
BeginLastSection = PE + &HF8 + ((NumberOfSections - 1) * &H28)
Call CopyMemory(RawSize, ByteArray(BeginLastSection + 16), 4)
Call CopyMemory(RawOffset, ByteArray(BeginLastSection + 20), 4)
GetEOF = RawSize + RawOffset
End Function