Пример #1
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;
            }
        }
Пример #2
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
        }