Beispiel #1
0
        public unsafe bool Check(byte[] fileimage)
        {
            if (this.TagName == "head")
                fixed(byte *img = &fileimage[0])
                {
                    // reset checkSumAdjustment
                    headTable *head = (headTable *)(img + (uint)this.offset);
                    ULONG      csa  = head->checkSumAdjustment;

                    head->checkSumAdjustment = (ULONG)0;

                    bool ret = this.CalculateTableSum(fileimage) == (uint)this.checkSum;

                    // Check checkSumAdjustment
                    OffsetTable *        offset = (OffsetTable *)img;
                    TableDirectoryEntry *entry  = (TableDirectoryEntry *)(offset + 1);
                    TableDirectoryEntry *end    = entry + (uint)offset->numTables;
                    uint sum = (uint)offset->Sum;

                    for (; entry < end; entry++)
                    {
                        sum += entry->Sum;
                        sum += (uint)entry->checkSum;
                    }

                    // restore checkSumAdjustment
                    head->checkSumAdjustment = csa;

                    return(ret);           //&&sum==0xB1B0AFBA-(uint)csa;
                }
            return(this.CalculateTableSum(fileimage) == (uint)this.checkSum);
        }
Beispiel #2
0
        public override unsafe System.Windows.Forms.Control GetControl()
        {
            UI.TreeNode.ShareLog.Clear();
            fixed(byte *pImg = &this.file.image[0])
            {
                headTable *table = (headTable *)(pImg + (uint)entry.offset);

                UI.TreeNode.ShareLog.WriteLine(
                    "《head table》\r\n表形式 {0}\r\nフォントのバージョン {1}\r\n毎 em {2} 単位\r\n作成 {3}\r\n更新 {4}\r\n矩形 ({5},{6}) - ({7},{8})"
                    , table->TableVersionNumber.Value
                    , table->fontRevision.Value
                    , (ushort)table->unitsPerEm
                    , (System.DateTime)table->created, (System.DateTime)table->modified
                    , (short)table->xMin, (short)table->yMin, (short)table->xMax, (short)table->yMax);
            }

            return(UI.TreeNode.ShareTxtBox);
        }
Beispiel #3
0
        public unsafe bool Check(byte[] fileimage)
        {
            if (this.TagName == "head")
                fixed(byte *img = &fileimage[0])
                {
                    // reset checkSumAdjustment
                    headTable *head = (headTable *)(img + (uint)this.offset);
                    ULONG      csa  = head->checkSumAdjustment;

                    head->checkSumAdjustment = (ULONG)0;
                    uint csaR = 0xB1B0AFBA - (uint)csa;

                    bool ret = this.CalculateTableSum(fileimage) == (uint)this.checkSum;

                    // Check checkSumAdjustment
                    OffsetTable *        offset = (OffsetTable *)img;
                    TableDirectoryEntry *entry  = (TableDirectoryEntry *)(offset + 1);
                    TableDirectoryEntry *end    = entry + (uint)offset->numTables;
                    uint sum = (uint)offset->Sum;

                    for (; entry < end; entry++)
                    {
                        sum += entry->Sum;
                        sum += (uint)entry->checkSum;
                    }

                    uint sum2 = this.SumEntireFont(fileimage);

                    // restore checkSumAdjustment
                    head->checkSumAdjustment = csa;

                    if (sum != sum2)
                    {
                        System.Console.WriteLine("checkSums of all the structures and the entire file are diffrent from each other.");
                        if (sum == csaR)
                        {
                            System.Console.WriteLine("checkSumAdjustment is calculated from all the structures.");
                        }
                        else if (sum2 == csaR)
                        {
                            System.Console.WriteLine("checkSumAdjustment is calculated from the entire file.");
                        }
                        else
                        {
                            System.Console.WriteLine("Neither structures nor entire file is used to calculate checkSumAdjustment: 0x{0:X8}", csaR);
                        }
                    }
                    else
                    {
                        if (sum != csaR)
                        {
                            System.Console.WriteLine("checkSumAdjustment is unexpected value: 0x{0:X8}", csaR);
                        }
                    }
                    System.Console.WriteLine("Σ1: 0x{0:X8}; checkSumAdjustment: 0x{1:X8}", sum, csaR);
                    System.Console.WriteLine("Σ2: 0x{0:X8}; checkSumAdjustment: 0x{1:X8}", sum2, csaR);
                    System.Console.WriteLine("Σ1 〜 checkSumAdjustment: 0x{0:X8} / 0x{1:X8}", csaR - sum, sum - csaR);
                    System.Console.WriteLine("Σ2 〜 checkSumAdjustment: 0x{0:X8} / 0x{1:X8}", csaR - sum2, sum2 - csaR);
                    return(ret);
                }
            return(this.CalculateTableSum(fileimage) == (uint)this.checkSum);
        }