PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : [VB.NET] ResourceManager



hackerking
14.08.2010, 14:57
jo hey leute, habe nen code auf hf geshen, und bissel abgeändert.
is ne funktion drin um ressourcen zu schreiben (WriteResource) und eine um zu lesen (ReadResource). dadurch kriegt ihr keine lästige Dropper Meldung von Avira mehr. Macht damit was ihr wollt, ein kleine Info, das der Code von mir stammt wäre nett, genau so wie ein danke ;)


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 ModuleAchja:
Die ReadResource Funktion liefert ein Byte zurück, welches ihr mit BytesToString einfach konvertieren könnt. Genau dasselbe geht auch umgekehrt mit StringToBytes, da WriteResource auch ein Byte Array fordert.

lol der 900ste post ohne die offtopic posts zu zählen :D :D :D

Malw0rm
14.08.2010, 16:15
Danke schonmal dafür! :D
Wenn ich jetzt ne Stealer Source hätte...

zin
16.08.2010, 00:11
habe nen code auf hf geshen

ein kleine Info, das der Code von mir stammt wäre nett, genau so wie ein danke

Der Code stammt nicht von dir. Ist genauso, wie wenn ich auf ein da Vinci-Bild draufkleckse und sage, ich hätte es gemalt.

K-Gee
16.08.2010, 18:43
Malworm, fail.
Builder & Stub Examples/Tut o.ä gibts für VB.Net überall.
Mach dich mal auf die Suche hier im Board

Grüße, K-Gee

hackerking
16.08.2010, 18:45
@zin Wann sagte ich dass ihr keine Credits an den User auf HF geben sollt ;)

IRET
16.08.2010, 18:47
Wenn ich jetzt ne Stealer Source hätte...
SOurceripper mag niemand.
Außerdem gibts sogar 2 Beispiele in vb.net hier (einer mit den Nirsofttools und einer der nur Keys stealt).

B2T:
Nett dass du das tust.