Esempio n. 1
0
 public static extern bool GetOverlappedResult(IntPtr hFile, ref Utilities.OVERLAPPED lpOverlapped, ref int lpNumberOfBytesTransferred, int bWait);
Esempio n. 2
0
 public static extern bool ReadFile(IntPtr hFile, byte[] Buffer, int NumberOfBytesToRead, ref int pNumberOfBytesRead, ref Utilities.OVERLAPPED pOverlapped);
Esempio n. 3
0
        public static bool Count_Num_Blocks(string p_file_name, ref int p_num_blocks, ref int p_err_code)
        {
            uint   num   = 0;
            uint   num2  = 0;
            uint   num3  = 0;
            uint   num4  = 0;
            bool   flag  = true;
            string str   = "";
            string str2  = "0x";
            string str3  = "0x";
            string str4  = "0x";
            string str5  = "0x";
            string str6  = "0x";
            int    num5  = 0;
            bool   flag2 = true;
            byte   num6  = 0;

            p_err_code = 0;
            if (File.Exists(p_file_name))
            {
                " ,\t".ToCharArray();
                try
                {
                    StreamReader reader = File.OpenText(p_file_name);
                    p_num_blocks = 0;
                    while (reader.Peek() >= 0)
                    {
                        str = reader.ReadLine();
                        if (str == ":00000001FF")
                        {
                            break;
                        }
                        if ((str != "") && (str[0] == ':'))
                        {
                            str2 = "0x";
                            str3 = "0x";
                            str4 = "0x";
                            str5 = "0x";
                            str6 = "0x";
                            num5 = Utilities.Convert_Value_To_Int(str2 + str[1] + str[2]);
                            str3 = (str3 + str[3] + str[4]) + str[5] + str[6];
                            str4 = str4 + str[7] + str[8];
                            num  = (uint)Utilities.Convert_Value_To_Int(str3);
                            num6 = (byte)Utilities.Convert_Value_To_Int(str4);
                            if (num6 == 4)
                            {
                                num4 = (uint)(Utilities.Convert_Value_To_Int((str5 + ((char)str[9]) + ((char)str[10])) + ((char)str[11]) + ((char)str[12])) << 0x10);
                            }
                            else
                            {
                                num += num4;
                                if ((((num / 2) > num3) || ((num / 2) < num2)) && !flag)
                                {
                                    flag = true;
                                }
                                if (flag)
                                {
                                    p_num_blocks++;
                                    flag = false;
                                    if (!Calculate_Device_Starting_Block_Addr(num, ref num2, ref num3))
                                    {
                                        reader.Close();
                                        p_err_code = 1;
                                        return(false);
                                    }
                                }
                                for (int i = 0; i < (2 * num5); i += 2)
                                {
                                    str6 = "0x";
                                    str6 = str6 + str[9 + i] + str[10 + i];
                                    if (num2 > (num / 2))
                                    {
                                        reader.Close();
                                        p_err_code = 1;
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    reader.Close();
                }
                catch (Exception)
                {
                    p_err_code = 2;
                    flag2      = false;
                }
                return(flag2);
            }
            flag2      = false;
            p_err_code = 2;
            return(flag2);
        }