Type BinaryOperation(string name, BinaryTypes types)
        {
            var rightType = _valueTypeStack.Pop();
            var leftType  = _valueTypeStack.Pop();

            var resultType = types[leftType, rightType];

            if (IgnoreValidationFlag == false)
            {
                Trace.Assert(resultType != null, "{0}({1}, {2}) is invalid IL", name, leftType, rightType);
            }
            _valueTypeStack.Push(resultType);
            return(resultType);
        }
Example #2
0
        public Patcher(string file)
        {
            Initialized = false;
            success     = false;

            using (var stream = new MemoryStream(File.ReadAllBytes(file)))
            {
                Binary = file;
                binary = stream.ToArray();

                if (binary != null)
                {
                    Type = Helper.GetBinaryType(binary);

                    Initialized = true;
                }
            }
        }
Example #3
0
        public Patcher(string file)
        {
            Initialized = false;
            success = false;

            using (var stream = new MemoryStream(File.ReadAllBytes(file)))
            {
                Binary = file;
                binary = stream.ToArray();

                if (binary != null)
                {
                    Type = Helper.GetBinaryType(binary);

                    Initialized = true;
                }
            }
        }
Example #4
0
        public static BinaryTypes GetBinaryType(byte[] data)
        {
            BinaryTypes type = 0u;

            using (var reader = new BinaryReader(new MemoryStream(data)))
            {
                var magic = (uint)reader.ReadUInt16();

                // Check MS-DOS magic
                if (magic == 0x5A4D)
                {
                    reader.BaseStream.Seek(0x3C, SeekOrigin.Begin);

                    // Read PE start offset
                    var peOffset = reader.ReadUInt32();

                    reader.BaseStream.Seek(peOffset, SeekOrigin.Begin);

                    var peMagic = reader.ReadUInt32();

                    // Check PE magic
                    if (peMagic != 0x4550)
                    {
                        throw new NotSupportedException("Not a PE file!");
                    }

                    type = (BinaryTypes)reader.ReadUInt16();
                }
                else
                {
                    reader.BaseStream.Seek(0, SeekOrigin.Begin);

                    type = (BinaryTypes)reader.ReadUInt32();
                }
            }

            return(type);
        }
Example #5
0
        public static BinaryTypes GetBinaryType(byte[] p_Data)
        {
            BinaryTypes l_Type = 0u;

            using (var l_Reader = new BinaryReader(new MemoryStream(p_Data)))
            {
                var l_Magic = (uint)l_Reader.ReadUInt16();

                // Check MS-DOS magic
                if (l_Magic == 0x5A4D)
                {
                    l_Reader.BaseStream.Seek(0x3C, SeekOrigin.Begin);

                    var l_PEOffset = l_Reader.ReadUInt32();

                    l_Reader.BaseStream.Seek(l_PEOffset, SeekOrigin.Begin);

                    var l_PEMagic = l_Reader.ReadUInt32();

                    if (l_PEMagic != 0x4550)
                    {
                        throw new NotSupportedException("Not a PE file!");
                    }

                    l_Type = (BinaryTypes)l_Reader.ReadUInt16();
                }
                else
                {
                    l_Reader.BaseStream.Seek(0, SeekOrigin.Begin);

                    l_Type = (BinaryTypes)l_Reader.ReadUInt32();
                }
            }

            return(l_Type);
        }
Example #6
0
        /// <summary>
        /// returns URLs of the binaries related to the object
        /// </summary>
        public async Task <APIResponse <List <string> > > GetBinariesForObject(string objectId, BinaryTypes type)
        {
            //are we in?
            if (!string.IsNullOrEmpty(CurrenMobileServicetUser.UserId))
            {
                return(new APIResponse <List <string> >(new List <string>(),
                                                        new UnauthorizedAccessException("User is unauthenticated")));
            }

            var parameters = new Dictionary <string, string> {
                { "objectId", objectId }, { "type", type.ToString() }
            };

            try
            {
                return
                    (new APIResponse <List <string> >(
                         await serviceClient.InvokeApiAsync <List <string> >("BinaryItem", HttpMethod.Get, parameters),
                         null));
            }
            catch (Exception ex)
            {
                return(new APIResponse <List <string> >(new List <string>(), ex));
            }
        }
Example #7
0
 public async Task <APIResponse <bool> > UploadBinaryAsync(string objectId, BinaryTypes objectType, byte[] data)
 {
     return(await UploadBinaryAsync(objectId, objectType, DataConverter.GetStringFromData(data)));
 }
Example #8
0
        //Methods in this region is to post/get binary data related to any object like beer or review,
        //where we may have several images

        /// <summary>
        /// Uploads binary data to database
        /// </summary>
        /// <param name="objectId">I believe it should be BreweryDBId for beer and review id for reviews</param>
        /// <param name="objectType"></param>
        /// <param name="binaryData"></param>
        /// <returns></returns>
        public async Task <APIResponse <bool> > UploadBinaryAsync(string objectId, BinaryTypes objectType, string binaryData)
        {
            return(null);
        }