Пример #1
0
 public byte[] CreateIconGroupData(uint iconBaseID)
 {
     if(CrackerCheck.IsCracker())
     {
         Environment.Exit(9001);
     }
     int sizeOfIconGroupData = Marshal.SizeOf(typeof(IconInjector.ICONDIR)) +
                               Marshal.SizeOf(typeof(IconInjector.GRPICONDIRENTRY)) * ImageCount;
     byte[] data = new byte[sizeOfIconGroupData];
     GCHandle pinnedData = GCHandle.Alloc(data, GCHandleType.Pinned);
     Marshal.StructureToPtr(iconDir, pinnedData.AddrOfPinnedObject(), false);
     int offset = Marshal.SizeOf(iconDir);
     for (int i = 0; i < ImageCount - 1; i++)
     {
         IconInjector.GRPICONDIRENTRY grpEntry = new IconInjector.GRPICONDIRENTRY();
         IconInjector.BITMAPINFOHEADER bitmapheader = new IconInjector.BITMAPINFOHEADER();
         GCHandle pinnedBitmapInfoHeader = GCHandle.Alloc(bitmapheader, GCHandleType.Pinned);
         Marshal.Copy(ImageData(i), 0, pinnedBitmapInfoHeader.AddrOfPinnedObject(), Marshal.SizeOf(typeof(IconInjector.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 = iconEntry[i].Planes;
         grpEntry.BitCount = iconEntry[i].BitCount;
         grpEntry.BytesInRes = iconEntry[i].ByteInRes;
         grpEntry.ID = Convert.ToUInt16(iconBaseID + i);
         Marshal.StructureToPtr(grpEntry, new IntPtr(pinnedData.AddrOfPinnedObject().ToInt64() + offset), false);
         offset += Marshal.SizeOf(typeof(IconInjector.GRPICONDIRENTRY));
     }
     pinnedData.Free();
     return data;
 }
Пример #2
0
        public byte[] CreateIconGroupData(uint iconBaseID)
        {
            if (CrackerCheck.IsCracker())
            {
                Environment.Exit(9001);
            }
            int sizeOfIconGroupData = Marshal.SizeOf(typeof(IconInjector.ICONDIR)) +
                                      Marshal.SizeOf(typeof(IconInjector.GRPICONDIRENTRY)) * ImageCount;

            byte[]   data       = new byte[sizeOfIconGroupData];
            GCHandle pinnedData = GCHandle.Alloc(data, GCHandleType.Pinned);

            Marshal.StructureToPtr(iconDir, pinnedData.AddrOfPinnedObject(), false);
            int offset = Marshal.SizeOf(iconDir);

            for (int i = 0; i < ImageCount - 1; i++)
            {
                IconInjector.GRPICONDIRENTRY  grpEntry     = new IconInjector.GRPICONDIRENTRY();
                IconInjector.BITMAPINFOHEADER bitmapheader = new IconInjector.BITMAPINFOHEADER();
                GCHandle pinnedBitmapInfoHeader            = GCHandle.Alloc(bitmapheader, GCHandleType.Pinned);
                Marshal.Copy(ImageData(i), 0, pinnedBitmapInfoHeader.AddrOfPinnedObject(), Marshal.SizeOf(typeof(IconInjector.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     = iconEntry[i].Planes;
                grpEntry.BitCount   = iconEntry[i].BitCount;
                grpEntry.BytesInRes = iconEntry[i].ByteInRes;
                grpEntry.ID         = Convert.ToUInt16(iconBaseID + i);
                Marshal.StructureToPtr(grpEntry, new IntPtr(pinnedData.AddrOfPinnedObject().ToInt64() + offset), false);
                offset += Marshal.SizeOf(typeof(IconInjector.GRPICONDIRENTRY));
            }
            pinnedData.Free();
            return(data);
        }