Results 1 to 5 of 5
  1. #1
    Intellectual's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    GDI
    Posts
    5,389
    Reputation
    785
    Thanks
    16,091
    My Mood
    Yeehaw

    Executable Icon Changer

    Hey guys on this tutorial you will learn to create an executable icon changer(the name says everything ) so lets start our tutorial by launching visual basics
    • 1 The tools we need:
      - 3 Buttons
      - 2 TextBoxs
      - 1 PictureBox


    • 2 Changing text:
      We should change texts of the following:
      - Button1 = Browse Executable
      - Button2 = Browse Icon
      - Button3 = Change Executable Icon
      It should look like this



    • 3 Coding:(double click on buttons then paste the codes)
      Browse Executable Button
      Code:
          Dim ofd As New OpenFileDialog 'Here we're making a manual openfiledialog
              With ofd 'Calling ofd
                  .InitialDirectory = Application.StartupPath
                  .Filter = "*.EXE|*.exe"  'Works with executables only
                  .DefaultExt = "*.EXE|*.exe"
              End With
              If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
                  TextBox1.Text = ofd.FileName
              End If

      Browse Icon Button
      Code:
      Dim ofd As New OpenFileDialog
              With ofd
                  .InitialDirectory = Application.StartupPath
                  .Filter = "*.ICO|*.ico" 'Works for icons only
                  .DefaultExt = "*.ICO|*.ico"
              End With
              If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
                  TextBox2.Text = ofd.FileName
                  PictureBox1.Image = System.Drawing.Image.FromFile(ofd.FileName)
              End If

      Browse Executable Button
      Code:
       If TextBox1.Text <> Nothing = False Then
                  MsgBox("Select an executable file first", MsgBoxStyle.Critical, "Error") ' When textbox1 is empty
                  Exit Sub
              End If
              If TextBox2.Text <> Nothing = False Then
                  MsgBox("Select an icon first", MsgBoxStyle.Critical, "Error") ' When textbox2 is empty
                  Exit Sub
              End If
              Dim OriginalExecutableData As Byte() = IO.File.ReadAllBytes(TextBox1.Text)
              Dim sfd As New SaveFileDialog ' Creating a manual savedialog
              With sfd
                  .InitialDirectory = Application.StartupPath
                  .Filter = "*.EXE|*.exe"
                  .DefaultExt = "*.EXE|*.exe"
                  .AddExtension = True
                  .SupportMultiDottedExtensions = True
              End With
              If sfd.ShowDialog() = Windows.Forms.DialogResult.OK Then
              End If
              Try
                  IO.File.WriteAllBytes(sfd.FileName, OriginalExecutableData)
                  IC.InjectIcon(sfd.FileName, TextBox2.Text)
                  MsgBox("File Icon has been successfully changed!", MsgBoxStyle.Information, "Sucess")
              Catch ex As Exception
                  MessageBox.Show(ex.Message)
              End Try



    • 4 How to fix errors that will pop up?
      - 1 error should pop up:

      To fix the error create a new class (Project=>Add Class) call it IC then paste the following code
      Code:
      'The following source code wasn't made by me, credits goes to the original creator
      
      Option Strict On
      Option Explicit On
      Option Infer On
      Imports System.Runtime.InteropServices
      Imports System.Security
      Public Class IC
          <SuppressUnmanagedCodeSecurity()> _
          Private Class NativeMethods
              <DllImport("kernel32")> _
              Public Shared Function BeginUpdateResource( _
                  ByVal fileName As String, _
                  <MarshalAs(UnmanagedType.Bool)> ByVal deleteExistingResources As Boolean) As IntPtr
              End Function
              <DllImport("kernel32")> _
              Public Shared Function UpdateResource( _
                  ByVal hUpdate As IntPtr, _
                  ByVal type As IntPtr, _
                  ByVal name As IntPtr, _
                  ByVal language As Short, _
                  <MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=5)> _
                  ByVal data() As Byte, _
                  ByVal dataSize As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
              End Function
              <DllImport("kernel32")> _
              Public Shared Function EndUpdateResource( _
                  ByVal hUpdate As IntPtr, _
                  <MarshalAs(UnmanagedType.Bool)> ByVal discard As Boolean) As <MarshalAs(UnmanagedType.Bool)> Boolean
              End Function
          End Class
          <StructLayout(LayoutKind.Sequential)> _
          Private Structure ICONDIR
              Public Reserved As UShort
              Public Type As UShort
              Public Count As UShort
          End Structure
          <StructLayout(LayoutKind.Sequential)> _
          Private Structure ICONDIRENTRY
              Public Width As Byte
              Public Height As Byte
              Public ColorCount As Byte
              Public Reserved As Byte
              Public Planes As UShort
              Public BitCount As UShort
              Public BytesInRes As Integer
              Public ImageOffset As Integer
          End Structure
          <StructLayout(LayoutKind.Sequential)> _
          Private Structure BITMAPINFOHEADER
              Public Size As UInteger
              Public Width As Integer
              Public Height As Integer
              Public Planes As UShort
              Public BitCount As UShort
              Public Compression As UInteger
              Public SizeImage As UInteger
              Public XPelsPerMeter As Integer
              Public YPelsPerMeter As Integer
              Public ClrUsed As UInteger
              Public ClrImportant As UInteger
          End Structure
          <StructLayout(LayoutKind.Sequential, Pack:=2)> _
          Private Structure GRPICONDIRENTRY
              Public Width As Byte
              Public Height As Byte
              Public ColorCount As Byte
              Public Reserved As Byte
              Public Planes As UShort
              Public BitCount As UShort
              Public BytesInRes As Integer
              Public ID As UShort
          End Structure
          Public Shared Sub InjectIcon(ByVal exeFileName As String, ByVal iconFileName As String)
              InjectIcon(exeFileName, iconFileName, 1, 1)
          End Sub
          Public Shared Sub InjectIcon(ByVal exeFileName As String, ByVal iconFileName As String, ByVal iconGroupID As UInteger, ByVal iconBaseID As UInteger)
              Const RT_ICON As UInteger = 3UI
              Const RT_GROUP_ICON As UInteger = 14UI
              Dim iconFile As IconFile = iconFile.FromFile(iconFileName)
              Dim hUpdate = NativeMethods.BeginUpdateResource(exeFileName, False)
              Dim data = iconFile.CreateIconGroupData(iconBaseID)
              NativeMethods.UpdateResource(hUpdate, New IntPtr(RT_GROUP_ICON), New IntPtr(iconGroupID), 0, data, data.Length)
              For i = 0 To iconFile.ImageCount - 1
                  Dim image = iconFile.ImageData(i)
                  NativeMethods.UpdateResource(hUpdate, New IntPtr(RT_ICON), New IntPtr(iconBaseID + i), 0, image, image.Length)
              Next
              NativeMethods.EndUpdateResource(hUpdate, False)
          End Sub
          Private Class IconFile
              Private iconDir As New ICONDIR
              Private iconEntry() As ICONDIRENTRY
              Private iconImage()() As Byte
              Public ReadOnly Property ImageCount() As Integer
                  Get
                      Return iconDir.Count
                  End Get
              End Property
              Public ReadOnly Property ImageData(ByVal index As Integer) As Byte()
                  Get
                      Return iconImage(index)
                  End Get
              End Property
              Private Sub New()
              End Sub
              Public Shared Function FromFile(ByVal filename As String) As IconFile
                  Dim instance As New IconFile
                  Dim fileBytes() As Byte = IO.File.ReadAllBytes(filename)
                  Dim pinnedBytes = GCHandle.Alloc(fileBytes, GCHandleType.Pinned)
                  instance.iconDir = DirectCast(Marshal.PtrToStructure(pinnedBytes.AddrOfPinnedObject, GetType(ICONDIR)), ICONDIR)
                  instance.iconEntry = New ICONDIRENTRY(instance.iconDir.Count - 1) {}
                  instance.iconImage = New Byte(instance.iconDir.Count - 1)() {}
                  Dim offset = Marshal.SizeOf(instance.iconDir)
                  Dim iconDirEntryType = GetType(ICONDIRENTRY)
                  Dim size = Marshal.SizeOf(iconDirEntryType)
                  For i = 0 To instance.iconDir.Count - 1
                      Dim entry = DirectCast(Marshal.PtrToStructure(New IntPtr(pinnedBytes.AddrOfPinnedObject.ToInt64 + offset), iconDirEntryType), ICONDIRENTRY)
                      instance.iconEntry(i) = entry
                      instance.iconImage(i) = New Byte(entry.BytesInRes - 1) {}
                      Buffer.BlockCopy(fileBytes, entry.ImageOffset, instance.iconImage(i), 0, entry.BytesInRes)
                      offset += size
                  Next
                  pinnedBytes.Free()
                  Return instance
              End Function
              Public Function CreateIconGroupData(ByVal iconBaseID As UInteger) As Byte()
                  Dim sizeOfIconGroupData As Integer = Marshal.SizeOf(GetType(ICONDIR)) + Marshal.SizeOf(GetType(GRPICONDIRENTRY)) * ImageCount
                  Dim data(sizeOfIconGroupData - 1) As Byte
                  Dim pinnedData = GCHandle.Alloc(data, GCHandleType.Pinned)
                  Marshal.StructureToPtr(iconDir, pinnedData.AddrOfPinnedObject, False)
                  Dim offset = Marshal.SizeOf(iconDir)
                  For i = 0 To ImageCount - 1
                      Dim grpEntry As New GRPICONDIRENTRY
                      Dim bitmapheader As New BITMAPINFOHEADER
                      Dim pinnedBitmapInfoHeader = GCHandle.Alloc(bitmapheader, GCHandleType.Pinned)
                      Marshal.Copy(ImageData(i), 0, pinnedBitmapInfoHeader.AddrOfPinnedObject, Marshal.SizeOf(GetType(BITMAPINFOHEADER)))
                      pinnedBitmapInfoHeader.Free()
                      grpEntry.Width = iconEntry(i).Width
                      grpEntry.Height = iconEntry(i).Height
                      grpEntry.ColorCount = iconEntry(i).ColorCount
                      grpEntry.Reserved = iconEntry(i).Reserved
                      grpEntry.Planes = bitmapheader.Planes
                      grpEntry.BitCount = bitmapheader.BitCount
                      grpEntry.BytesInRes = iconEntry(i).BytesInRes
                      grpEntry.ID = CType(iconBaseID + i, UShort)
                      Marshal.StructureToPtr(grpEntry, New IntPtr(pinnedData.AddrOfPinnedObject.ToInt64 + offset), False)
                      offset += Marshal.SizeOf(GetType(GRPICONDIRENTRY))
                  Next
                  pinnedData.Free()
                  Return data
              End Function
          End Class
      End Class

    Last edited by Intellectual; 05-19-2013 at 03:51 PM.

  2. The Following 2 Users Say Thank You to Intellectual For This Useful Post:

    By_Hummet (01-31-2014),e-skillz (06-29-2014)

  3. #2
    viHackz's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    47
    Reputation
    10
    Thanks
    78
    Thanks for this tut sir ^^

  4. #3
    Intellectual's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    GDI
    Posts
    5,389
    Reputation
    785
    Thanks
    16,091
    My Mood
    Yeehaw
    You're welcome.

  5. #4
    iSmexy's Avatar
    Join Date
    Dec 2011
    Gender
    female
    Posts
    16,204
    Reputation
    1355
    Thanks
    3,734
    this is pretty use full thanks

    List of Middleman Impersonations
    Current MPGH Staff
    Report a Scammer here


    Member Since: 5 Dec 2011
    Crossfire Minion Since: 19 Feb 2013 - 24 Oct 2014
    Minecraft Minion Since: 4 Feb 2014 - 24 Oct 2014
    BattleOn Minion Since: 26 Aug 2014 - 24 Oct 2014
    Donator Since: Mar 12 2014


     

    x x

  6. #5
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    awsome! Thanks!

Similar Threads

  1. [Release] xChanger(Icon Changer-Icon Extractor)
    By ANDREAS789 in forum CrossFire Spammers, Injectors and Multi Tools
    Replies: 10
    Last Post: 12-28-2010, 05:38 AM
  2. sadam execution
    By masoudmasoud in forum Islam vs Western World
    Replies: 47
    Last Post: 02-09-2007, 10:21 PM
  3. Saddam execution video
    By AN1MAL in forum General
    Replies: 10
    Last Post: 02-03-2007, 10:43 PM
  4. [Release] Nickname changer
    By hjerherjdsd in forum WarRock - International Hacks
    Replies: 42
    Last Post: 12-16-2006, 04:24 PM