Esempio n. 1
0
        private byte[] ReadConfiguration()
        {
            byte[] result = null;
            try
            {
                var config = new MFConfigHelper(_device);
                if (!config.IsValidConfig)
                {
                    throw new Exception("Invalid config");
                }
                if (config.IsFirmwareKeyLocked)
                {
                    throw new Exception("Firmware locked");
                }
                if (config.IsDeploymentKeyLocked)
                {
                    throw new Exception("Deployment locked");
                }

                var data = config.FindConfig("S4NCFG");
                //if (data.Length > 16)
                //{
                //    var temp = new byte[16];
                //    Array.Copy(data, data.Length - 16, temp, 0, 16);
                //    data = temp;
                //}
                if (data == null)
                {
                    result = null;
                }
                else
                {
                    //BUG: FindConfig returns a lot of garbage at the beginning of the config block
                    result = data; //TODO: copy only the config bytes
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Esempio n. 2
0
        private Guid GetDeviceId(MFDevice device)
        {
            var result = Guid.Empty;

            try
            {
                var config = new MFConfigHelper(device);
                if (!config.IsValidConfig)
                {
                    throw new Exception("Invalid config");
                }
                if (config.IsFirmwareKeyLocked)
                {
                    throw new Exception("Firmware locked");
                }
                if (config.IsDeploymentKeyLocked)
                {
                    throw new Exception("Deployment locked");
                }
                var data = config.FindConfig("S4NID");
                if (data.Length > 16)
                {
                    var temp = new byte[16];
                    Array.Copy(data, data.Length - 16, temp, 0, 16);
                    data = temp;
                }
                if (data == null)
                {
                    result = Guid.Empty;
                }
                else
                {
                    result = new Guid(data);
                }
            }
            catch
            {
                result = Guid.Empty;
            }
            return(result);
        }