Código:
Option Explicit
'--------------------------------------------------------------------------------------------
' Function : FiletoString
' Coder : The Swash
' References And Constans : API-Guide
' DateTime : 08/04/2010
'--------------------------------------------------------------------------------------------
'Shlwapi.dll
Private Declare Function PathFileExistsA Lib "shlwapi.dll" (ByVal pszPath As String) As Long
'Kernel32.dll
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
Private Declare Function CreateFileA Lib "kernel32" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
'Constants
Const FILE_SHARE_READ = &H1
Const OPEN_EXISTING = 3
Const GENERIC_READ = &H80000000
Const FILE_SHARE_WRITE = &H2
Public Function FiletoString(sFile As String) As String
Dim hFile As Long
Dim hFSize As Long
Dim bvBuff() As Byte
Dim hBytes As Long
Dim hRead As Long
If PathFileExistsA(sFile) > 0 Then
hFile = CreateFileA(sFile, GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
If hFile > 0 Then
hFSize = GetFileSize(hFile, 0)
ReDim bvBuff(1 To hFSize)
hRead = ReadFile(hFile, bvBuff(1), UBound(bvBuff), hBytes, 0&)
If hRead > 0 Then
FiletoString = StrConv(bvBuff, vbUnicode)
End If
End If
End If
Call CloseHandle(hFile)
End Function
Call:
Código:
Dim sFile As String
sFile = FiletoString(File path)
Disculpen por la descripcion xD, esta funcion permite obtener las strings de un ejecutable, usado mucho en el mundo del malware pero tambien se puede usar para muchas otras cosas