コード例 #1
0
ファイル: FrmFrequency.cs プロジェクト: rebelbot/binvis
        // internal static void
        public void calcFrequency(int fileLength, ref int[] byteCount, ref byte[] fileBufferArray, ref float[] frequency, FrmMain frmMainHandle)
        {
            FrmProgressBar fpb = new FrmProgressBar("calculating byte frequency...");

            //Console.WriteLine(this.ParentForm.ToString());

            fpb.MdiParent = frmMainHandle;
            fpb.Start(0, fileLength);
            fpb.Show();

            for (int i = 0; i < fileLength; i++)
            {
                byteCount[fileBufferArray[i]]++;
                if (i % 10000 == 0)
                {
                    fpb.Update(i);
                    Application.DoEvents();
                }
            }
            for (int j = 0; j <= 255; j++)
            {
                frequency[j] = (float)byteCount[j] / fileLength;     //dividing int by int is integer division, must cast to float
                //Console.WriteLine(j + " " + byteCount[j]+ " " + fileLength + " " + frequency[j]);
            }
            fpb.Hide();
        }
コード例 #2
0
ファイル: FrmMain.cs プロジェクト: rebelbot/binvis
        //open file
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int BytesRead = 0;
            var ofd       = new OpenFileDialog();

            ofd.ShowDialog();

            if (ofd.FileName != "")
            {
                FileStream fs = File.OpenRead(ofd.FileName);
                var        br = new BinaryReader(fs);

                fileLength      = (int)fs.Length; // This limits the maximum file size to ~2GB due to maxint
                fileBufferArray = new byte[fileLength];
                var fpb = new FrmProgressBar("loading file...");
                fpb.MdiParent = this;
                fpb.Start(0, fileLength);
                fpb.Show();
                while (BytesRead < fileLength)
                {
                    fileBufferArray[BytesRead] = br.ReadByte();
                    if (BytesRead % 10000 == 0)
                    {
                        fpb.Update(BytesRead);
                        Application.DoEvents();
                    }
                    BytesRead++;
                }
                fpb.Close();
                br.Close();
                Text = "BinVis " + ofd.FileName;

                //FrmFrequency.calcFrequency(fileLength, ref byteCount, ref fileBufferArray, ref frequency);
                globalFrmFrequency.calcFrequency(fileLength, ref byteCount, ref fileBufferArray, ref frequency, this);
                processMemory.Process(fileLength, ref fileBufferArray);
                globalFrmNavigator.init(fileLength, ref fileBufferArray);
                globalFrmNavigator.MdiParent = this;
                globalFrmNavigator.Show();
            }
        }
コード例 #3
0
ファイル: FrmMain.cs プロジェクト: Evan-Sa/binvis
        //open file
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int BytesRead = 0;
            var ofd = new OpenFileDialog();
            ofd.ShowDialog();

            if (ofd.FileName != "")
            {
                FileStream fs = File.OpenRead(ofd.FileName);
                var br = new BinaryReader(fs);

                fileLength = (int) fs.Length; // This limits the maximum file size to ~2GB due to maxint
                fileBufferArray = new byte[fileLength];
                var fpb = new FrmProgressBar("loading file...");
                fpb.MdiParent = this;
                fpb.Start(0, fileLength);
                fpb.Show();
                while (BytesRead < fileLength)
                {
                    fileBufferArray[BytesRead] = br.ReadByte();
                    if (BytesRead%10000 == 0)
                    {
                        fpb.Update(BytesRead);
                        Application.DoEvents();
                    }
                    BytesRead++;
                }
                fpb.Close();
                br.Close();
                Text = "BinVis " + ofd.FileName;

                //FrmFrequency.calcFrequency(fileLength, ref byteCount, ref fileBufferArray, ref frequency);
                globalFrmFrequency.calcFrequency(fileLength, ref byteCount, ref fileBufferArray, ref frequency, this);
                processMemory.Process(fileLength, ref fileBufferArray);
                globalFrmNavigator.init(fileLength, ref fileBufferArray);
                globalFrmNavigator.MdiParent = this;
                globalFrmNavigator.Show();
            }
        }
コード例 #4
0
ファイル: FrmFrequency.cs プロジェクト: Evan-Sa/binvis
        // internal static void
        public void calcFrequency(int fileLength, ref int[] byteCount, ref byte[] fileBufferArray, ref float[] frequency, FrmMain frmMainHandle)
        {
            FrmProgressBar fpb = new FrmProgressBar("calculating byte frequency...");
            //Console.WriteLine(this.ParentForm.ToString());
            
            fpb.MdiParent = frmMainHandle;
            fpb.Start(0, fileLength);
            fpb.Show();

                for (int i = 0; i < fileLength; i++) {
                    byteCount[fileBufferArray[i]]++;
                    if (i % 10000 == 0)
                    {
                        fpb.Update(i);
                        Application.DoEvents();
                    }
                }
                for (int j = 0; j <= 255; j++) {
                    frequency[j] = (float)byteCount[j] / fileLength; //dividing int by int is integer division, must cast to float
                    //Console.WriteLine(j + " " + byteCount[j]+ " " + fileLength + " " + frequency[j]);
                }
            fpb.Hide();
        }