Exemplo n.º 1
0
        /// <summary>
        /// 默认发送获取加密盘的信息
        /// </summary>
        private void ShowBitLockerDiskThreadFun()
        {
            SetRichText("@:正在识别所有的BitLocker加密磁盘,请稍后......");
            VS_Msg msg = new VS_Msg();

            msg.type = MsgType.TYPE.GETALL;
            Program.viewcontrol.Send2Server(msg);
        }
Exemplo n.º 2
0
 public static void Send2S(VS_Msg msg)
 {
     while (isV2S)
     {
         Thread.Sleep(1);
     }
     V2S_Msg = msg;
     isV2S   = true;
 }
Exemplo n.º 3
0
 public static void Send2V(VS_Msg msg)
 {
     while (isS2V)
     {
         Thread.Sleep(1);
     }
     S2V_Msg = msg;
     isS2V   = true;
 }
Exemplo n.º 4
0
        private void ListenThreadFun()
        {
            while (isListenThreadRun)
            {
                if (VirtualPipe.isS2V)
                {
                    VS_Msg getmsg = VirtualPipe.GetS2VMessage();
                    switch (getmsg.type)
                    {
                    case MsgType.TYPE.SHOWLOG:
                    {
                        _mainwin.SetRichText(getmsg.content);
                    }
                    break;

                    case MsgType.TYPE.SETPROGRESS:
                    {
                        String[] getTemp = getmsg.content.Split(',');
                        if (getTemp.Length != 3)
                        {
                            break;
                        }

                        bool isAdd = false;
                        int  val   = 0;
                        int  max   = 100;
                        if (getTemp[0].Equals("true"))
                        {
                            isAdd = true;
                        }
                        bool flag  = int.TryParse(getTemp[1], out val);
                        bool flag_ = int.TryParse(getTemp[2], out max);
                        if (flag && flag_)
                        {
                            _mainwin.SetProgressBar(isAdd, val, max);
                        }
                        else
                        {
                            String err = "val invalid";
                        }
                    }
                    break;

                    case MsgType.TYPE.EnableLock:
                    {
                        _mainwin.SetBtnEnbale();
                    }
                    break;

                    default:
                        break;
                    }
                }

                Thread.Sleep(10);
            }
        }
Exemplo n.º 5
0
        private void ListenThreadFun()
        {
            while (isListenRun)
            {
                if (VirtualPipe.isV2S)
                {
                    VS_Msg getmsg = VirtualPipe.GetV2SMessage();
                    switch (getmsg.type)
                    {
                    case MsgType.TYPE.GETALL:
                    {
                        //启动磁盘信息服务,获取加密的磁盘
                        GetDiskServer getdiskServer = new GetDiskServer();
                        ArrayList     bitdisk       = getdiskServer.GetAllBitLockerDisk();
                        String        resultString  = "@加密磁盘列表:";
                        foreach (String name in bitdisk)
                        {
                            resultString += ("[" + name + "] ");
                        }

                        VS_Msg msg = new VS_Msg();
                        msg.type    = MsgType.TYPE.SHOWLOG;
                        msg.content = resultString;
                        Program.servercontrol.Send2View(msg);
                        msg      = new VS_Msg();
                        msg.type = MsgType.TYPE.EnableLock;
                        Program.servercontrol.Send2View(msg);
                        msg         = new VS_Msg();
                        msg.type    = MsgType.TYPE.SHOWLOG;
                        msg.content = "@:磁盘列表识别完毕,加锁操作执行完毕!";
                        Program.servercontrol.Send2View(msg);
                    }
                    break;

                    default:
                        break;
                    }
                }

                Thread.Sleep(10);
            }
        }
Exemplo n.º 6
0
 public void Send2Server(VS_Msg msg)
 {
     VirtualPipe.Send2S(msg);
 }
Exemplo n.º 7
0
        public ArrayList GetAllBitLockerDisk()
        {
            AllBitLockerInfo = new ArrayList();

            //获取所有磁盘
            ArrayList AllDiskInfo = new ArrayList();

            DriveInfo[] allDrives = DriveInfo.GetDrives();

            foreach (DriveInfo di in allDrives)
            {
                AllDiskInfo.Add(di.Name.Substring(0, di.Name.Length - 1));
            }


            //查询该磁盘是否为BitLocker加密盘
            foreach (String name in AllDiskInfo)
            {
                //通知当前界面信息和进度条
                VS_Msg showmsg = new VS_Msg();
                showmsg.type    = MsgType.TYPE.SHOWLOG;
                showmsg.content = "检测" + name + "盘...";
                Program.servercontrol.Send2View(showmsg);
                VS_Msg probarmsg = new VS_Msg();
                probarmsg.type    = MsgType.TYPE.SETPROGRESS;
                probarmsg.content = "true,0" + "," + AllDiskInfo.Count;
                Program.servercontrol.Send2View(probarmsg);

                //直接启动方式
                String result = ExcludeBitLockerCMD("manage-bde", " -status " + name, "");

                //处理日志
                result = result.Replace(" ", "");

                //判断类型
                if (!result.Contains("加密方法:无"))
                {
                    if (result.Contains("错误"))
                    {
                        continue;
                    }

                    VS_Msg showOkMsg = new VS_Msg();
                    showOkMsg.type    = MsgType.TYPE.SHOWLOG;
                    showOkMsg.content = name + "是BitLocker加密盘";
                    Program.servercontrol.Send2View(showOkMsg);

                    //debug
                    //if(name.ToLower().Contains("f"))
                    //{
                    //    showOkMsg = new VS_Msg();
                    //    showOkMsg.type = MsgType.TYPE.SHOWLOG;
                    //    showOkMsg.content = name + "暂不加锁";
                    //    Program.servercontrol.Send2View(showOkMsg);
                    //    continue;
                    //}

                    //判断当前盘是否已锁定
                    if (!result.Contains("锁定状态:已锁定"))
                    {
                        VS_Msg showOkMsg_ = new VS_Msg();
                        showOkMsg_.type    = MsgType.TYPE.SHOWLOG;
                        showOkMsg_.content = "开始对" + name + "进行加锁操作...";
                        Program.servercontrol.Send2View(showOkMsg_);

                        //当前盘没有被锁定,执行加锁
                        String result_ = ExcludeBitLockerCMD("manage-bde", " -lock " + name, "");
                        result_ = result_.Replace(" ", "");
                        if (result_.Contains("现在已锁定"))
                        {
                            showOkMsg_         = new VS_Msg();
                            showOkMsg_.type    = MsgType.TYPE.SHOWLOG;
                            showOkMsg_.content = "加锁成功";
                            Program.servercontrol.Send2View(showOkMsg_);
                        }
                        else
                        {
                            showOkMsg_         = new VS_Msg();
                            showOkMsg_.type    = MsgType.TYPE.SHOWLOG;
                            showOkMsg_.content = "加锁失败,错误:\r\n" + result_;
                            Program.servercontrol.Send2View(showOkMsg_);
                        }
                    }
                    else
                    {
                        showOkMsg         = new VS_Msg();
                        showOkMsg.type    = MsgType.TYPE.SHOWLOG;
                        showOkMsg.content = name + "磁盘已加锁";
                        Program.servercontrol.Send2View(showOkMsg);
                    }

                    AllBitLockerInfo.Add(name);
                }

                //创建脚本启动方式

                /*
                 * //创建执行脚本
                 * ArrayList setList = new ArrayList();
                 * setList.Add("manage-bde -status " + name);
                 * String filename = BatCreate.CreateBATFile(setList);
                 *
                 * //执行脚本
                 * ProcessStartInfo psi = new ProcessStartInfo();
                 * psi.FileName = filename;
                 * try
                 * {
                 *  Process.Start(psi);
                 * }
                 * catch(Exception)
                 * {
                 *
                 * }
                 *
                 * Thread.Sleep(1000);
                 * //解析日志文件
                 * String logname = filename.Substring(0, filename.Length - 4) + ".log";
                 * StreamReader sr = null;
                 * try
                 * {
                 *  sr = new StreamReader(logname, Encoding.Default);
                 *  String cLine = "";
                 *  String result = "";
                 *  while((cLine = sr.ReadLine()) != null)
                 *  {
                 *      result += cLine;
                 *  }
                 *  sr.Close();
                 *
                 *  //处理日志
                 *  result = result.Replace(" ", "");
                 *
                 *  //判断类型
                 *  if (!result.Contains("加密方法:无"))
                 *  {
                 *      if (result.Contains("错误: BitLocker 无法打开卷"))
                 *      {
                 *          continue;
                 *      }
                 *      AllBitLockerInfo.Add(name);
                 *  }
                 *
                 * }
                 * catch(Exception)
                 * {
                 *
                 * }
                 *
                 * //清理日志文件和脚本文件
                 * try
                 * {
                 *  File.Delete(filename);
                 *  File.Delete(logname);
                 * }
                 * catch(Exception){}
                 */
            }

            return(AllBitLockerInfo);
        }
Exemplo n.º 8
0
 public void Send2View(VS_Msg msg)
 {
     VirtualPipe.Send2V(msg);
 }