示例#1
0
 public unsafe CodeInfo(long codeOffset, byte[] rawCode, DecodeType dt, int features = 0)
 {
     _code = rawCode;
       _codePtr = null;
       _codeOffset = codeOffset;
       _decodeType = dt;
       _features = features;
 }
示例#2
0
 public unsafe CodeInfo(long codeOffset, byte[] rawCode, DecodeType dt, int features = 0)
 {
     _code       = rawCode;
     _codePtr    = null;
     _codeOffset = codeOffset;
     _decodeType = dt;
     _features   = features;
 }
示例#3
0
        public CodeInfo(long codeOffset, byte[] rawCode, DecodeType dt, int features)
        {
            _code = new byte[rawCode.Length];
            Array.Copy(rawCode, _code, _code.Length);

            _codeOffset = codeOffset;
            _decodeType = dt;
            _features   = features;
        }
示例#4
0
 public unsafe CodeInfo(long codeOffset, byte *code, int codeLength, DecodeType dt, int features = 0)
 {
     _code       = null;
     _codePtr    = code;
     _codeLength = codeLength;
     _codeOffset = codeOffset;
     _decodeType = dt;
     _features   = features;
 }
示例#5
0
    public CodeInfo(long codeOffset, byte[] rawCode, DecodeType dt, int features)
    {
      _code = new byte[rawCode.Length];
      Array.Copy(rawCode, _code, _code.Length);

      _codeOffset = codeOffset;
      _decodeType = dt;
      _features = features;
    }
示例#6
0
 public unsafe CodeInfo(long codeOffset, byte *code, int codeLength, DecodeType dt, int features = 0)
 {
     _code = null;
       _codePtr = code;
       _codeLength = codeLength;
       _codeOffset = codeOffset;
       _decodeType = dt;
       _features = features;
 }
 public IoRangeDescriptor(ResourceType resourceType, ulong minimum, ulong maximum,
                          ulong length, ulong alignment, ulong addressTranslationOffset,
                          bool minimumAddressIsFixed, bool maximumAddressIsFixed,
                          DecodeType decodeType, ConsumerProducer consumerProducer,
                          IoToMemoryTranslation ioToMemoryTranslation)
     : base(resourceType, minimum, maximum, length, alignment, addressTranslationOffset,
            minimumAddressIsFixed, maximumAddressIsFixed, decodeType, consumerProducer)
 {
     this.ioToMemoryTranslation = ioToMemoryTranslation;
 }
        public AddressSpaceDescriptor(ResourceType resourceType, ulong minimum, ulong maximum, ulong length, ulong alignment)
        {
            this.resourceType = resourceType;
            this.minimum      = minimum;
            this.maximum      = maximum;
            this.length       = length;
            this.alignment    = alignment;

            this.minimumAddressIsFixed    = false;
            this.maximumAddressIsFixed    = false;
            this.addressTranslationOffset = 0;
            this.decodeType       = DecodeType.BridgePositivelyDecodes;
            this.consumerProducer = ConsumerProducer.Consumes;
        }
 public MemoryRangeDescriptor(ResourceType resourceType, ulong minimum, ulong maximum,
                              ulong length, ulong alignment, ulong addressTranslationOffset,
                              bool minimumAddressIsFixed, bool maximumAddressIsFixed,
                              DecodeType decodeType, ConsumerProducer consumerProducer,
                              AcpiMemoryFlags acpiMemoryFlags, MemoryToIoTranslation memoryToIoTranslation,
                              AddressRangeAttribute addressRangeAttribute,
                              CacheableAttribute cacheableAttribute, WriteStatus writeStatus)
     : base(resourceType, minimum, maximum, length, alignment, addressTranslationOffset,
            minimumAddressIsFixed, maximumAddressIsFixed, decodeType, consumerProducer)
 {
     this.acpiMemoryFlags       = acpiMemoryFlags;
     this.memoryToIoTranslation = memoryToIoTranslation;
     this.addressRangeAttribute = addressRangeAttribute;
     this.cacheableAttribute    = cacheableAttribute;
     this.writeStatus           = writeStatus;
 }
示例#10
0
        /// <summary>
        /// 连接ftp服务器
        /// </summary>
        /// <param name="path"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool ConnnectServer(string path, string userName, string password, DecodeType decodeType = DecodeType.Default)
        {
            string strDecryptionPassW;

            if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                this._isConnection = false;
                return(false);
            }

            //如果密码加了密,则进行解密
            if (password.Length >= 3)
            {
                if (password.Substring(0, 1) + password.Substring(2, 1) + password.Substring(password.Length - 1, 1) == "★※★")
                {
                    strDecryptionPassW = password.Substring(1);
                    strDecryptionPassW = strDecryptionPassW.Substring(0, strDecryptionPassW.Length - 1);
                    strDecryptionPassW = strDecryptionPassW.Substring(0, 1) + strDecryptionPassW.Substring(2);
                    strDecryptionPassW = this.GetDecryptionPassW(strDecryptionPassW);

                    password = strDecryptionPassW;
                }
            }

            this._ftpServerIP = path;
            this._ftpUserName = userName;
            this._ftpPassword = password;
            this._decodeType  = decodeType;

            try
            {
                FtpWebRequest ftp = CreateFtpConnection("");

                ftp.Method = WebRequestMethods.Ftp.PrintWorkingDirectory;

                WebResponse response = ftp.GetResponse();
                response.Close();

                this._isConnection = true;
                return(true);
            }
            catch (Exception)
            {
                this._isConnection = false;
                return(false);
            }
        }
示例#11
0
        private void InitControl(DecodeType decodeType)
        {
            if (listingID != 0)
            {
                cbxMake.Visible   = false;
                cbxModel.Visible  = false;
                btnDecode.Visible = false;
            }
            else
            {
                DisableAllChildControls(pnDecode);
                switch (decodeType)
                {
                case DecodeType.VIN:
                    txtVin.Enabled          = true;
                    btnDecode.Enabled       = true;
                    cbxMake.Visible         = false;
                    cbxModel.Visible        = false;
                    pnLabel.Enabled         = true;
                    pnVinDecodeType.Enabled = true;
                    lblSalePrice.Enabled    = true;
                    lblDexcription.Enabled  = true;
                    rbnCertified.Enabled    = true;
                    txtVin.KeyDown         += new KeyEventHandler(txtVin_KeyDown);
                    break;

                case DecodeType.Manual:
                    txtYear.Enabled                = true;
                    txtYear.KeyDown               += new KeyEventHandler(txtYear_KeyDown);
                    btnDecode.Enabled              = true;
                    lblVin.Visible                 = false;
                    txtVin.Visible                 = false;
                    txtMake.Visible                = false;
                    txtModel.Visible               = false;
                    pnDecode.Enabled               = true;
                    pnLabel.Enabled                = true;
                    pnVinDecodeType.Enabled        = true;
                    lblSalePrice.Enabled           = true;
                    lblDexcription.Enabled         = true;
                    rbnCertified.Enabled           = true;
                    cbxMake.SelectedIndexChanged  += new EventHandler(cbxMake_SelectedIndexChanged);
                    cbxModel.SelectedIndexChanged += new EventHandler(cbxModel_SelectedIndexChanged);
                    break;
                }
            }
        }
示例#12
0
        public VinDecodeForm(DecodeType decodeType, MainForm frmMain)
        {
            _decodeType = decodeType;

            Load += VinDecodeForm_Load;
            InitializeComponent();

            if (decodeType.Equals(DecodeType.Manual))
            {
                rbVindecodeYear.Checked = true;
            }
            if (decodeType.Equals(DecodeType.VIN))
            {
                rbDecodeVin.Checked = true;
            }
            this._frmMain = frmMain;
        }
        private static DecodeDelegate GetDecodeDelegate32(PsdColorMode psdColorMode, ref DecodeType decoderType)
        {
            switch (psdColorMode)
            {
            case PsdColorMode.Grayscale:
                decoderType = DecodeType.Grayscale32;
                return(SetPDNRowGrayscale32);

            case PsdColorMode.RGB:
                decoderType = DecodeType.RGB32;
                return(SetPDNRowRgb32);

            default:
                throw new PsdInvalidException(
                          "32-bit HDR images must be either RGB or grayscale.");
            }
        }
        public AddressSpaceDescriptor(ResourceType resourceType, ulong minimum, ulong maximum,
                                      ulong length, ulong alignment, ulong addressTranslationOffset,
                                      bool minimumAddressIsFixed, bool maximumAddressIsFixed,
                                      DecodeType decodeType, ConsumerProducer consumerProducer)
        {
            this.resourceType = resourceType;
            this.minimum      = minimum;
            this.maximum      = maximum;
            this.length       = length;
            this.alignment    = alignment;

            this.minimumAddressIsFixed    = minimumAddressIsFixed;
            this.maximumAddressIsFixed    = maximumAddressIsFixed;
            this.addressTranslationOffset = addressTranslationOffset;
            this.decodeType       = decodeType;
            this.consumerProducer = consumerProducer;
        }
        ///////////////////////////////////////////////////////////////////////////
        /// SINGLE THREADED - KEPT FOR REFERENCE
        ///////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Decode image from Photoshop's channel-separated formats to BGRA.
        /// </summary>
        public static void DecodeImage(BitmapLayer pdnLayer, PhotoshopFile.Layer psdLayer)
        {
            UnityEngine.Profiling.Profiler.BeginSample("DecodeImage");
            var            decodeContext = new DecodeContext(psdLayer, pdnLayer.Bounds);
            DecodeDelegate decoder       = null;
            DecodeType     decoderType   = 0;

            if (decodeContext.ByteDepth == 4)
            {
                decoder = GetDecodeDelegate32(decodeContext.ColorMode, ref decoderType);
            }
            else
            {
                decoder = GetDecodeDelegate(decodeContext.ColorMode, ref decoderType);
            }

            DecodeImage(pdnLayer, decodeContext, decoder);
            decodeContext.Cleanup();
            UnityEngine.Profiling.Profiler.EndSample();
        }
        /// <summary>
        /// Decode image from Photoshop's channel-separated formats to BGRA.
        /// </summary>
        public static JobHandle DecodeImage(BitmapLayer pdnLayer, PhotoshopFile.Layer psdLayer, JobHandle inputDeps)
        {
            UnityEngine.Profiling.Profiler.BeginSample("DecodeImage");
            var            decodeContext = new DecodeContext(psdLayer, pdnLayer.Bounds);
            DecodeDelegate decoder       = null;
            DecodeType     decoderType   = 0;

            if (decodeContext.ByteDepth == 4)
            {
                decoder = GetDecodeDelegate32(decodeContext.ColorMode, ref decoderType);
            }
            else
            {
                decoder = GetDecodeDelegate(decodeContext.ColorMode, ref decoderType);
            }

            JobHandle jobHandle = DecodeImage(pdnLayer, decodeContext, decoderType, inputDeps);

            UnityEngine.Profiling.Profiler.EndSample();
            return(jobHandle);
        }
        private static DecodeDelegate GetDecodeDelegate(PsdColorMode psdColorMode, ref DecodeType decoderType)
        {
            switch (psdColorMode)
            {
            case PsdColorMode.Bitmap:
                decoderType = DecodeType.Bitmap;
                return(SetPDNRowBitmap);

            case PsdColorMode.Grayscale:
            case PsdColorMode.Duotone:
                decoderType = DecodeType.Grayscale;
                return(SetPDNRowGrayscale);

            case PsdColorMode.Indexed:
                decoderType = DecodeType.Indexed;
                return(SetPDNRowIndexed);

            case PsdColorMode.RGB:
                decoderType = DecodeType.RGB;
                return(SetPDNRowRgb);

            case PsdColorMode.CMYK:
                decoderType = DecodeType.CMYK;
                return(SetPDNRowCmyk);

            case PsdColorMode.Lab:
                decoderType = DecodeType.Lab;
                return(SetPDNRowLab);

            case PsdColorMode.Multichannel:
                throw new Exception("Cannot decode multichannel.");

            default:
                throw new Exception("Unknown color mode.");
            }
        }
示例#18
0
        /// <summary>
        /// A wrapper for distorm_decompose(), which only takes in the code to be decomposed.
        /// </summary>
        /// <param name="code">The code to be decomposed.</param>
        /// <param name="offset">The offset at which the code starts in the image being disassembled.</param>
        /// <param name="bitDepth">The target architecture type of the code being disassembled.</param>
        /// <param name="logFilename">
        /// The name of the file to use to log important updates about the decomposition process.
        /// </param>
        /// <returns>Returns the code to be decomposed on success or an empty array upon failure.</returns>
        /// <remarks>
        /// Usage of brainpower is required to recognize that decomposing a code array of size 0 will also result in
        /// an empty array.
        /// </remarks>
        public static DInst[] Decompose(
            byte[] code,
            ulong offset = 0,
            DecodeType bitDepth = DecodeType.Decode32Bits,
            string logFilename = "Distorm3cs.log")
        {
            GCHandle gch = GCHandle.Alloc(code, GCHandleType.Pinned);

            Distorm.CodeInfo ci = new Distorm.CodeInfo();
            ci.codeLen = code.Length;
            ci.code = gch.AddrOfPinnedObject();
            ci.codeOffset = offset;
            ci.dt = bitDepth;
            ci.features = Distorm.DecomposeFeatures.NONE;

            // Most likely a gross over-estimation of how large to make the array, but it should never fail.
            Distorm.DInst[] result = new Distorm.DInst[code.Length];
            uint usedInstructionsCount = 0;

            // Decompose the data.
            Distorm.DecodeResult r =
                Distorm.distorm_decompose(ref ci, result, (uint)result.Length, ref usedInstructionsCount);

            // Release the handle pinned to the code.
            gch.Free();

            // Return false if an error occured during decomposition.
            if (!r.Equals(Distorm.DecodeResult.SUCCESS))
            {
                Logger.Log(
                    "Error decomposing data. Result was: " + r.ToString(),
                    logFilename,
                    Logger.Type.CONSOLE | Logger.Type.FILE);
                return new Distorm.DInst[0];
            }

            // Resize the array to match the actual number of instructions decoded.
            Array.Resize(ref result, (int)usedInstructionsCount);

            // Return the result.
            return result;
        }
示例#19
0
 private static extern unsafe void distorm_decode64(IntPtr codeOffset, byte *code, int codeLen, DecodeType dt, void *result, uint maxInstructions, uint *usedInstructionsCount);
        /// <summary>
        /// Decode image from Photoshop's channel-separated formats to BGRA,
        /// using the specified decode delegate on each row.
        /// </summary>
        private static JobHandle DecodeImage(BitmapLayer pdnLayer, DecodeContext decodeContext, DecodeType decoderType, JobHandle inputDeps)
        {
            var psdLayer = decodeContext.Layer;
            var surface  = pdnLayer.Surface;
            var rect     = decodeContext.Rectangle;

            // Convert rows from the Photoshop representation, writing the
            // resulting ARGB values to to the Paint.NET Surface.

            int           jobCount   = Unity.Jobs.LowLevel.Unsafe.JobsUtility.JobWorkerMaximumCount;
            int           execCount  = (rect.Bottom - rect.Top);
            int           sliceCount = execCount / jobCount;
            PDNDecoderJob decoderJob = new PDNDecoderJob();

            decoderJob.Data.Rect             = rect;
            decoderJob.Data.LayerRect        = psdLayer.Rect;
            decoderJob.Data.ClippedRect      = rect;
            decoderJob.Data.SurfaceWidth     = surface.width;
            decoderJob.Data.SurfaceHeight    = surface.height;
            decoderJob.Data.SurfaceByteDepth = decodeContext.ByteDepth;
            decoderJob.Data.DecoderType      = decoderType;

            decoderJob.Data.ColorChannel0 = decodeContext.Channels[0].ImageData;
            decoderJob.Data.ColorChannel1 = decodeContext.Channels.Length > 1 ? decodeContext.Channels[1].ImageData : decodeContext.Channels[0].ImageData;
            decoderJob.Data.ColorChannel2 = decodeContext.Channels.Length > 2 ? decodeContext.Channels[2].ImageData : decodeContext.Channels[0].ImageData;
            decoderJob.Data.ColorChannel3 = decodeContext.Channels.Length > 3 ? decodeContext.Channels[3].ImageData : decodeContext.Channels[0].ImageData;
            decoderJob.Data.ColorModeData = decodeContext.ColorModeData;
            decoderJob.Data.DecodedImage  = surface.color;

            // Schedule the job, returns the JobHandle which can be waited upon later on
            JobHandle jobHandle = decoderJob.Schedule(execCount, sliceCount, inputDeps);

            // Mask and Alpha.
            int userMaskContextSize  = decodeContext.UserMaskContext != null ? decodeContext.Rectangle.Width : 1;
            int layerMaskContextSize = decodeContext.LayerMaskContext != null ? decodeContext.Rectangle.Width : 1;
            var userAlphaMask        = new NativeArray <byte>(userMaskContextSize, Allocator.TempJob);
            var layerAlphaMask       = new NativeArray <byte>(layerMaskContextSize, Allocator.TempJob);
            var userAlphaMaskEmpty   = new NativeArray <byte>(rect.Bottom, Allocator.TempJob);
            var layerAlphaMaskEmpty  = new NativeArray <byte>(rect.Bottom, Allocator.TempJob);

            PDNAlphaMaskJob alphaMaskJob = new PDNAlphaMaskJob();

            for (int y = rect.Top; y < rect.Bottom; ++y)
            {
                if (decodeContext.UserMaskContext != null)
                {
                    userAlphaMaskEmpty[y] = decodeContext.UserMaskContext.IsRowEmpty(y) ? (byte)1 : (byte)0;
                }
                if (decodeContext.LayerMaskContext != null)
                {
                    layerAlphaMaskEmpty[y] = decodeContext.LayerMaskContext.IsRowEmpty(y) ? (byte)1 : (byte)0;
                }
            }

            alphaMaskJob.Data.Rect             = rect;
            alphaMaskJob.Data.LayerRect        = psdLayer.Rect;
            alphaMaskJob.Data.ClippedRect      = rect;
            alphaMaskJob.Data.SurfaceWidth     = surface.width;
            alphaMaskJob.Data.SurfaceHeight    = surface.height;
            alphaMaskJob.Data.SurfaceByteDepth = decodeContext.ByteDepth;
            alphaMaskJob.Data.HasAlphaChannel  = decodeContext.HasAlphaChannel;

            alphaMaskJob.Data.HasUserAlphaMask       = decodeContext.UserMaskContext != null ? 1 : 0;
            alphaMaskJob.Data.UserMaskInvertOnBlend  = decodeContext.UserMaskContext != null ? (decodeContext.UserMaskContext.Mask.InvertOnBlend ? 1 : 0) : 0;
            alphaMaskJob.Data.UserMaskRect           = decodeContext.UserMaskContext != null ? decodeContext.UserMaskContext.Mask.Rect : rect;
            alphaMaskJob.Data.UserMaskContextRect    = decodeContext.UserMaskContext != null ? decodeContext.UserMaskContext.Rectangle : rect;
            alphaMaskJob.Data.HasLayerAlphaMask      = decodeContext.LayerMaskContext != null ? 1 : 0;
            alphaMaskJob.Data.LayerMaskInvertOnBlend = decodeContext.LayerMaskContext != null ? (decodeContext.LayerMaskContext.Mask.InvertOnBlend ? 1 : 0) : 0;
            alphaMaskJob.Data.LayerMaskRect          = decodeContext.LayerMaskContext != null ? decodeContext.LayerMaskContext.Mask.Rect : rect;
            alphaMaskJob.Data.LayerMaskContextRect   = decodeContext.LayerMaskContext != null ? decodeContext.LayerMaskContext.Rectangle : rect;

            alphaMaskJob.Data.AlphaChannel0            = decodeContext.AlphaChannel;
            alphaMaskJob.Data.UserMask                 = decodeContext.UserMaskContext != null ? decodeContext.UserMaskContext.Mask.ImageData : decodeContext.AlphaChannel;
            alphaMaskJob.Data.UserAlphaMask            = userAlphaMask;
            alphaMaskJob.Data.UserAlphaMaskEmpty       = userAlphaMaskEmpty;
            alphaMaskJob.Data.LayerMask                = decodeContext.LayerMaskContext != null ? decodeContext.LayerMaskContext.Mask.ImageData : decodeContext.AlphaChannel;
            alphaMaskJob.Data.LayerAlphaMask           = layerAlphaMask;
            alphaMaskJob.Data.LayerAlphaMaskEmpty      = layerAlphaMaskEmpty;
            alphaMaskJob.Data.DecodedImage             = surface.color;
            alphaMaskJob.Data.UserMaskBackgroundColor  = decodeContext.UserMaskContext != null ? decodeContext.UserMaskContext.Mask.BackgroundColor : (byte)0;
            alphaMaskJob.Data.LayerMaskBackgroundColor = decodeContext.LayerMaskContext != null ? decodeContext.LayerMaskContext.Mask.BackgroundColor : (byte)0;

            jobHandle = alphaMaskJob.Schedule(jobHandle);
            return(jobHandle);
        }
示例#21
0
        /// <summary>
        /// Translates opcodes into a list of strings, which each represent an instruction.
        /// </summary>
        /// <param name="code">The code to be disassembled.</param>
        /// <param name="offset">The offset at which the code starts in the image being disassembled.</param>
        /// <param name="bitDepth">The target architecture type of the code being disassembled.</param>
        /// <returns>Returns the disassembled instructions.</returns>
        public static List<string> Disassemble(
            byte[] code,
            ulong offset = 0,
            DecodeType bitDepth = DecodeType.Decode32Bits)
        {
            List<string> instructions = new List<string>();

            GCHandle gch = GCHandle.Alloc(code, GCHandleType.Pinned);

            // Prepare the CodeInfo structure for decomposition.
            Distorm.CodeInfo ci = new Distorm.CodeInfo();
            ci.codeLen = code.Length;
            ci.code = gch.AddrOfPinnedObject();
            ci.codeOffset = offset;
            ci.dt = bitDepth;
            ci.features = Distorm.DecomposeFeatures.NONE;

            // Prepare the result instruction buffer to receive the decomposition.
            Distorm.DInst[] result = new Distorm.DInst[code.Length];
            uint usedInstructionsCount = 0;

            // Perform the decomposition.
            Distorm.DecodeResult r =
                Distorm.distorm_decompose(ref ci, result, (uint)result.Length, ref usedInstructionsCount);

            // Release the handle pinned to the code.
            gch.Free();

            // Return an empty list if an error occured during decomposition.
            if (!r.Equals(Distorm.DecodeResult.SUCCESS))
            {
                return new List<string>();
            }

            // Prepare a DecodedInst structure for formatting the results.
            Distorm.DecodedInst inst = new Distorm.DecodedInst();

            for (uint i = 0; i < usedInstructionsCount; ++i)
            {
                // Format the results of the decomposition.
                Distorm.distorm_format(ref ci, ref result[i], ref inst);

                // Add it to the buffer to be verified.
                if (string.IsNullOrEmpty(inst.Operands))
                {
                    instructions.Add(inst.Mnemonic);
                }
                else
                {
                    instructions.Add(inst.Mnemonic + " " + inst.Operands);
                }
            }

            return instructions;
        }
示例#22
0
 public VinDecodeForm(DecodeType decodeType, int ListingID, MainForm frmMain)
     : this(decodeType, frmMain)
 {
     this._frmMain = frmMain;
     listingID     = ListingID;
 }
示例#23
0
 private static unsafe extern void distorm_decode64(IntPtr codeOffset, byte* code, int codeLen, DecodeType dt, void *result, uint maxInstructions, uint* usedInstructionsCount);