Beispiel #1
0
        public bool Start(IntPtr handle, bool bWrBd)
        {
            DEV_BROADCAST_DEVICEINTERFACE dbf = new DEV_BROADCAST_DEVICEINTERFACE();

            dbf.dbcc_size       = Marshal.SizeOf(dbf);
            dbf.dbcc_devicetype = Common.DBT_DEVTYP_DEVICEINTERFACE;
            dbf.dbcc_reserved   = 0;
            IntPtr hDevNotify1 = Common.RegisterDeviceNotification(handle, dbf, Common.DEVICE_NOTIFY_WINDOW_HANDLE | Common.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
            int    lt          = 0;

            if (bWrBd)
            {
                BYHXSoftLock.CheckDongle_WrBd();
            }
            else
            {
                BYHXSoftLock.CheckDongle();
            }
#if ADD_HARDKEY
            BYHX_SL_RetValue ret = BYHXSoftLock.CheckValidDate(ref lt);

            switch (ret)
            {
            case BYHX_SL_RetValue.EXPIRED:
                m_bOutdated = true;
                MessageBox.Show(ResString.GetResString("EncryptDog_Expired"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case BYHX_SL_RetValue.ILLEGALDOG:
                MessageBox.Show(ResString.GetResString("EncryptDog_Illegal"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);

            case BYHX_SL_RetValue.NOFOUNDDOG:
                MessageBox.Show(ResString.GetResString("EncryptDog_NoFound"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);

            case BYHX_SL_RetValue.WILLEXPIREDWORNING_100:
                MessageBox.Show(ResString.GetResString("EncryptDog_Warning"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tCheckDog.Interval = (lt - 1) * 60 * 1000 + 1;
                tCheckDog.Tick    += new EventHandler(tCheckDog_Tick);
                tCheckDog.Start();
                break;

            default:
                break;
            }
            if (lt > 60 * 100 && lt - 100 * 60 <= int.MaxValue / 1000 / 60)
            {
                tCloseTimer.Interval = (lt - 100 * 60) * 60 * 1000;
                tCloseTimer.Tick    += new EventHandler(tCloseTimer_Tick);
                tCloseTimer.Start();
            }
#endif
            return(true);
        }
Beispiel #2
0
        public static void CheckDongle_WrBd()
        {
            try
            {
                // 枚举插入的所有狗
                bool             bfirst      = true;
                int              index       = -1;
                int              leftt       = 0;
                SENSE4_CONTEXT[] jobInfoList = Common.EnumAllS4();
                if (jobInfoList != null & jobInfoList.Length > 0)
                {
                    // 遍历识别主锁
                    for (int i = 0; i < jobInfoList.Length; i++)
                    {
                        byte ret1 = BYHXSoftLock.RecognizeMasterKey(i, UserPin);
                        if (ret1 == 1)
                        {
                            byte[]           infos = new byte[19];
                            BYHX_SL_RetValue ret   = BYHXSoftLock.GetDongleInfo(ref infos, i);
                            if (ret != BYHX_SL_RetValue.SUCSESS)
                            {
                                continue;
                            }
                            else
                            {
                                if (0xff != (infos[16]))
                                {
                                    continue;
                                }
                            }

                            if (bfirst)
                            {
                                index  = i;
                                bfirst = false;
                            }
                            int lefttM = 0;
                            FIRST_S4_INDEX = i;
                            if (CheckValidDate(ref lefttM) == BYHX_SL_RetValue.SUCSESS && lefttM > leftt)
                            {
                                leftt = lefttM;
                                index = i;
                                //								break;
                            }
                        }
                    }
                    FIRST_S4_INDEX = index;
                }
            }
            catch
            {
                return;
            }
        }
Beispiel #3
0
        public bool LoadAndCheckDongleKey()
        {
            BYHXSoftLock.CheckDongle();
#if ADD_HARDKEY
            int lt = 0;
            BYHX_SL_RetValue ret = BYHXSoftLock.CheckValidDate(ref lt);
            m_bOutdated = false;
            switch (ret)
            {
            case BYHX_SL_RetValue.EXPIRED:
                m_bOutdated = true;
                break;

            case BYHX_SL_RetValue.ILLEGALDOG:
            case BYHX_SL_RetValue.NOFOUNDDOG:
                return(false);

            case BYHX_SL_RetValue.WILLEXPIREDWORNING_100:
                tCheckDog.Interval = (lt - 1) * 60 * 1000 + 1;
                tCheckDog.Tick    += new EventHandler(tCheckDog_Tick);
                tCheckDog.Start();
                break;

            default:
                break;
            }

            if (lt > 100 * 60 && lt - 100 * 60 <= int.MaxValue / 1000 / 60)
            {
                tCloseTimer.Interval = (lt - 100 * 60) * 60 * 1000;
                tCloseTimer.Tick    += new EventHandler(tCloseTimer_Tick);
                tCloseTimer.Start();
            }
            if (this.LoadAndCheckDongleKeyFinished != null)
            {
                this.LoadAndCheckDongleKeyFinished(null, new EventArgs());
            }
#endif
            return(true);
        }
Beispiel #4
0
        public void FirstReadyShakeHand()
        {
#if ADD_HARDKEY
            ushort Vid, Pid;
            Vid = Pid = 0;

            bool   result = true;
            byte[] infos  = new byte[19];
            if (CoreInterface.GetProductID(ref Vid, ref Pid) == 0)
            {
                result = false;
            }
            else
            {
                BYHX_SL_RetValue ret = BYHXSoftLock.GetDongleInfo(ref infos, BYHXSoftLock.FIRST_S4_INDEX);
                if (ret != BYHX_SL_RetValue.SUCSESS)
                {
                    result = false;
                }
                else
                {
                    ConvertAToB(infos);
                    ushort dogVid = BitConverter.ToUInt16(infos, 16);
                    //if ((Vid&0x7F) != (infos[16] & 0x7f))//模糊检查
                    //if (Vid != (infos[16] & 0x7f)) //BUG
                    if (Vid != dogVid) //严格检查
                    {
                        result = false;
#if LIYUUSB
                        if (infos[16] == 7 && Vid == (ushort)VenderID.LOTUS)
                        {
                            result = true;
                        }
#endif
                        if ((Vid & 0x807F) == (dogVid & 0x807f))
                        {
                            //if ((Vid & 0x7F) == (ushort)VenderID.GONGZENG)
                            result = true;
                        }
                    }
                }
            }
            if (result != bMatchVender)
            {
                bMatchVender = result;
//				m_IPrinterChange.OnPrinterStatusChanged(JetStatusEnum.PowerOff);
            }
            if (result == false)
            {
                MessageBox.Show(ResString.GetResString("EncryptDog_VidNotMatch"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

#if false
            //This is for Dog Check Board
            byte[] info = new byte[64];
            info[0] = (byte)(Vid & 0xff);
            info[1] = (byte)((Vid >> 8) & 0xff);
            info[2] = (byte)(Pid & 0xff);
            info[3] = (byte)((Pid >> 8) & 0xff);
            ret     = BYHXSoftLock.SetProductInfo(info, 32);
            if (ret != BYHX_SL_RetValue.SUCSESS)
            {
#if DEBUG
                //if (stDataPkgOut.tag != S4_API.S4_SUCCESS)
                {
                    MessageBox.Show("SetProductInfo Run failed!");
                }
#endif
            }
#endif
            //infos[16] = (byte)(Vid & 0xff);
            CoreInterface.SetDspPwmInfo(infos, infos.Length);
#endif
        }