Exemplo n.º 1
0
        // Token: 0x06000950 RID: 2384 RVA: 0x0004AF44 File Offset: 0x00049144
        public static void InjectIcon(string exeFileName, string iconFileName, uint iconGroupID, uint iconBaseID)
        {
            Gunakanicon.IconFile iconFile = Gunakanicon.IconFile.FromFile(iconFileName);
            IntPtr intPtr = Gunakanicon.NativeMethods.BeginUpdateResource(exeFileName, false);

            byte[] array    = iconFile.CreateIconGroupData(iconBaseID);
            IntPtr arg_3A_0 = intPtr;
            IntPtr intPtr2  = new IntPtr(14L);
            IntPtr arg_3A_1 = intPtr2;
            IntPtr intPtr3  = new IntPtr((long)((ulong)iconGroupID));

            Gunakanicon.NativeMethods.UpdateResource(arg_3A_0, arg_3A_1, intPtr3, 0, array, array.Length);
            int arg_4B_0 = 0;

            checked
            {
                int num  = iconFile.ImageCount - 1;
                int num2 = arg_4B_0;
                while (true)
                {
                    int arg_90_0 = num2;
                    int num3     = num;
                    if (arg_90_0 > num3)
                    {
                        break;
                    }
                    byte[] array2   = iconFile.get_ImageData(num2);
                    IntPtr arg_7F_0 = intPtr;
                    intPtr3 = new IntPtr(3L);
                    IntPtr arg_7F_1 = intPtr3;
                    intPtr2 = new IntPtr((long)(unchecked ((ulong)iconBaseID) + (ulong)(unchecked ((long)num2))));
                    Gunakanicon.NativeMethods.UpdateResource(arg_7F_0, arg_7F_1, intPtr2, 0, array2, array2.Length);
                    num2++;
                }
                Gunakanicon.NativeMethods.EndUpdateResource(intPtr, false);
            }
        }
Exemplo n.º 2
0
            // Token: 0x06000958 RID: 2392 RVA: 0x0004B020 File Offset: 0x00049220
            public static Gunakanicon.IconFile FromFile(string filename)
            {
                Gunakanicon.IconFile iconFile = new Gunakanicon.IconFile();
                byte[]   array    = File.ReadAllBytes(filename);
                GCHandle gCHandle = GCHandle.Alloc(array, GCHandleType.Pinned);

                iconFile.iconDir = (Gunakanicon.ICONDIR)Marshal.PtrToStructure(gCHandle.AddrOfPinnedObject(), typeof(Gunakanicon.ICONDIR));
                checked
                {
                    iconFile.iconEntry = new Gunakanicon.ICONDIRENTRY[(int)(iconFile.iconDir.Count - 1 + 1)];
                    iconFile.iconImage = new byte[(int)(iconFile.iconDir.Count - 1 + 1)][];
                    int  num            = Marshal.SizeOf(iconFile.iconDir);
                    Type typeFromHandle = typeof(Gunakanicon.ICONDIRENTRY);
                    int  num2           = Marshal.SizeOf(typeFromHandle);
                    int  arg_A5_0       = 0;
                    int  num3           = (int)(iconFile.iconDir.Count - 1);
                    int  num4           = arg_A5_0;
                    while (true)
                    {
                        int arg_13B_0 = num4;
                        int num5      = num3;
                        if (arg_13B_0 > num5)
                        {
                            break;
                        }
                        IntPtr ptr = new IntPtr(gCHandle.AddrOfPinnedObject().ToInt64() + unchecked ((long)num));
                        Gunakanicon.ICONDIRENTRY iCONDIRENTRY = (Gunakanicon.ICONDIRENTRY)Marshal.PtrToStructure(ptr, typeFromHandle);
                        iconFile.iconEntry[num4] = iCONDIRENTRY;
                        iconFile.iconImage[num4] = new byte[iCONDIRENTRY.BytesInRes - 1 + 1];
                        Buffer.BlockCopy(array, iCONDIRENTRY.ImageOffset, iconFile.iconImage[num4], 0, iCONDIRENTRY.BytesInRes);
                        num += num2;
                        num4++;
                    }
                    gCHandle.Free();
                    return(iconFile);
                }
            }