Sunday, May 30, 2010

[VB.NET] EOF - End Of File


Hello everyone. This is little source of EOF i found on spam. The credits go to linky and it worked for me fine. Hope it will work for you good too, if you have problem i will try to help you to fix it.

Code:
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


P.S. Its useful if you making an crypter.... for more informations click following link.