Code:
Imports System.Runtime.InteropServices
Imports System.Text
REM Orignal written by: Deathader on hf
REM modded by hackerking @ fh
REM greetz to litlegangsta, sfx, sawyer (thepapst), handyripper, krusty, para, br00_pwn, j0hn^x3r
REM visit free-hack.com
Public Module ResourceManager
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Function UpdateResource(ByVal hUpdate As IntPtr, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As UShort, ByVal lpData As IntPtr, ByVal cbData As UInteger) As Boolean
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Function BeginUpdateResource(ByVal pFileName As String, <MarshalAs(UnmanagedType.Bool)> ByVal bDeleteExistingResources As Boolean) As IntPtr
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Function EndUpdateResource(ByVal hUpdate As IntPtr, ByVal fDiscard As Boolean) As Boolean
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Function FindResource(ByVal hModule As IntPtr, ByVal lpName As String, ByVal lpType As String) As IntPtr
End Function
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal moduleName As String) As IntPtr
Private Declare Function SizeofResource Lib "kernel32" (ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As Integer
Private Declare Function LoadResource Lib "kernel32" (ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
Public Function ReadResource(ByVal sFile As String, ByVal lpName As String, ByVal lpType As String) As Byte()
Dim hModule As IntPtr = GetModuleHandle(sFile)
Dim loc As IntPtr = FindResource(hModule, lpName, lpType) 'lpName = "0", lpType = "MyRes"
Dim x As IntPtr = LoadResource(hModule, loc)
Dim size = SizeofResource(hModule, loc)
Dim bPtr As Byte() = New Byte(size - 1) {}
Marshal.Copy(x, bPtr, 0, CInt(size))
Return bPtr
End Function
Private Function ToPtr(ByVal data As Object) As IntPtr
Dim gHandle As GCHandle = GCHandle.Alloc(data, GCHandleType.Pinned)
Dim ptr As IntPtr
Try
ptr = gHandle.AddrOfPinnedObject()
Finally
gHandle.Free()
End Try
Return ptr
End Function
Public Function WriteResource(ByVal sFile As String, ByVal bBytes As Byte(), ByVal lpType As String, ByVal lpName As String, _
Optional ByVal bDeleteExistingResources As Boolean = False) As Boolean
Try
Dim iHandle As IntPtr = BeginUpdateResource(sFile, bDeleteExistingResources)
Dim bPtr As IntPtr = ToPtr(bBytes)
Dim res As Boolean = UpdateResource(iHandle, lpType, lpName, 0, bPtr, Convert.ToUInt32(bBytes.Length)) 'lpName = "0", lpType = "MyRes"
EndUpdateResource(iHandle, False)
Catch ex As Exception
Return False
End Try
Return True
End Function
Public Function BytesToString(ByVal bBytes As Byte()) As String
Try
Return Encoding.Default.GetString(bBytes)
Catch
Return Nothing
End Try
End Function
Public Function StringToBytes(ByVal sString As String) As Byte()
Try
Return Encoding.Default.GetBytes(sString)
Catch
Return Nothing
End Try
End Function
End Module
Achja: