상속: MonoBehaviour
예제 #1
0
파일: CallInfo.cs 프로젝트: DatZach/Xi
 public CallInfo(Module vmModule, Method method, int instructionPointer)
 {
     Module = vmModule;
     Class = null;
     Method = method;
     InstructionPointer = instructionPointer;
 }
예제 #2
0
        public static void Log(Module module, string message, Exception ex)
        {

#if APPVERSE_EMULATOR
            Trace.WriteLine(module + ": " + message);
			if (ex!=null) {
                Trace.WriteLine(module + ": Exception=[" + ex.Message + "] Source=[" + ex.Source + "]");
                Trace.WriteLine(module + ": Stacktrace ---------------------");
                Trace.WriteLine(module + ": " + ex.StackTrace);
			}	
#endif


#if DEBUG   && !WP8
			Console.WriteLine(module+": "+message);
			if (ex!=null) {
				Console.WriteLine(module+": Exception=["+ex.Message+"] Source=["+ex.Source+"]");
				Console.WriteLine(module+": Stacktrace ---------------------");
				Console.WriteLine(module+": "+ex.StackTrace);
			}	
#endif
#if DEBUG && WP8
            Debug.WriteLine(module + ": " + message);
            if (ex == null) return;
            Debug.WriteLine(module + ": Exception=[" + ex.Message + "] Source=[" + ex.Source + "]");
            Debug.WriteLine(module + ": Stacktrace ---------------------");
            Debug.WriteLine(module + ": " + ex.StackTrace);
#endif
        }
			public ModuleMetadataInfo(Module module, Mono.Cecil.ModuleDefinition cecilModule)
			{
				this.Module = module;
				this.CecilModule = cecilModule;
				typeRefLoader = new CecilLoader();
				typeRefLoader.SetCurrentModule(cecilModule);
			}
예제 #4
0
        public void Execute(IContext context)
        {
            Module module = ModuleUtilities.LoadModule(this.modname, context);

            IValues values = context;
            int nname = 0;

            foreach (var name in this.names)
            {
                string normname = name.Trim();

                if (nname == this.names.Length - 1)
                    values.SetValue(normname, module);
                else if (!values.HasValue(normname))
                {
                    var mod = new Module(context.GlobalContext);
                    values.SetValue(normname, mod);
                    values = mod;
                }
                else
                    values = (IValues)values.GetValue(normname);

                nname++;
            }
        }
예제 #5
0
        public void FillMessageMergeVars(MandrillMessage message, Module.Models.LinkOrderCampaignProductRecord record)
        {
            var products = new Dictionary<string, object>
                    {
                        {"quantity", record.Count},
                        {"name",  record.CampaignProductRecord.ProductRecord.Name},
                        {"description",  record.CampaignProductRecord.ProductRecord.Details},
                        {"price",  record.CampaignProductRecord.Price},
                        {"total_price", record.OrderRecord.TotalPrice}
                    };

            message.AddRcptMergeVars(record.OrderRecord.Email, "FNAME", record.OrderRecord.FirstName);
            message.AddRcptMergeVars(record.OrderRecord.Email, "LNAME", record.OrderRecord.LastName);
            message.AddRcptMergeVars(record.OrderRecord.Email, "CITY", record.OrderRecord.City);
            message.AddRcptMergeVars(record.OrderRecord.Email, "STATE", record.OrderRecord.State);
            message.AddRcptMergeVars(record.OrderRecord.Email, "COUNTRY", record.OrderRecord.Country);
            if (record.OrderRecord.TotalPriceWithPromo > 0.0)
            {
                message.AddRcptMergeVars(record.OrderRecord.Email, "TOTALPRICE", record.OrderRecord.TotalPriceWithPromo.ToString());
            }
            else
            {
                message.AddRcptMergeVars(record.OrderRecord.Email, "TOTALPRICE", record.OrderRecord.TotalPrice.ToString());
            }
            message.AddRcptMergeVars(record.OrderRecord.Email, "PRODUCTS", products);
        }
예제 #6
0
 public ControlLine(Module module, byte address, byte modes, ControlLineMode mode)
 {
     Module = module;
     Address = address;
     Modes = modes;
     Mode = mode;
 }
        /// <summary>
        /// Performs the actual code mutations, returning each with
        /// <c>yield</c> for the calling code to use.
        /// </summary>
        /// <remarks>
        /// Implementing classes should yield the result obtained by calling
        /// the <see mref="DoYield" /> method.
        /// </remarks>
        /// <param name="method">
        ///     A <see cref="MethodDefinition" /> for the method on which mutation
        ///     testing is to be carried out.
        /// </param>
        /// <param name="module">
        ///     A <see cref="Module" /> representing the main module of the
        ///     containing assembly.
        /// </param>
        /// <param name="originalOffsets"></param>
        /// <returns>
        /// An <see cref="IEnumerable{T}" /> of
        /// <see cref="MutantMetaData" /> structures.
        /// </returns>
        protected override IEnumerable<MutantMetaData> CreateMutant(MethodDefinition method, Module module, int[] originalOffsets)
        {
            for (int index = 0; index < method.Body.Instructions.Count; index++)
            {
                var instruction = method.Body.Instructions[index];
                if (instruction.OpCode == OpCodes.Clt
                    || instruction.OpCode == OpCodes.Cgt)
                {
                    var originalCode = instruction.OpCode.Code;

                    var loadZero = method.Body.GetILProcessor().Create(OpCodes.Ldc_I4_0);
                    var compareEqual = method.Body.GetILProcessor().Create(OpCodes.Ceq);

                    method.Body.Instructions.Insert(index + 1, compareEqual);
                    method.Body.Instructions.Insert(index + 1, loadZero);

                    instruction.OpCode = instruction.OpCode == OpCodes.Clt ? OpCodes.Cgt : OpCodes.Clt;

                    var description = string.Format("{0:x4}: {1} => not {2}", originalOffsets[index], originalCode, instruction.OpCode.Code);
                    yield return DoYield(method, module, description, index);

                    instruction.OpCode = instruction.OpCode == OpCodes.Clt ? OpCodes.Cgt : OpCodes.Clt;

                    method.Body.Instructions.Remove(compareEqual);
                    method.Body.Instructions.Remove(loadZero);
                }
            }
        }
예제 #8
0
 public RenderPtxContext(Module module)
     : base(module)
 {
     Buf = new StringBuilder();
     Delayed = Buf.Delayed();
     Writer = Delayed.Indented();
 }
예제 #9
0
        internal void RegisterModule(Module module)
        {
            if (module == null) 
                throw new ArgumentNullException("module");

            RegistredModulesCollection.Add(module);
        }
예제 #10
0
        public void RenderScripts_for_single_module_when_not_using_modules_returns_script_element_for_each_source_script()
        {
            var referenceBuilder = new FakeReferenceBuilder();
            var module = new Module(
                "lib",
                new[]
                {
                    new Resource("lib/test-1.js", new byte[] { 1,2,3 }, new string[0]),
                    new Resource("lib/test-2.js", new byte[] { 4,5,6 }, new string[0]),
                },
                new string[0],
                null
            );
            referenceBuilder.GetRequiredModules = () => new[] { module };

            var useModules = false;

            var pageHelper = new PageHelper(useModules, false, referenceBuilder, new FakeReferenceBuilder(), VirtualPathToAbsolute);
            var html = pageHelper.RenderScripts(null);

            Regex.IsMatch(
                html.ToHtmlString(),
                @"<script src=""/lib/test-1\.js\?[a-z0-9]+"" type=""text/javascript""></script>\r\n"+
                @"<script src=""/lib/test-2\.js\?[a-z0-9]+"" type=""text/javascript""></script>"
            ).ShouldBeTrue();
        }
예제 #11
0
        public void PopulatePermissions(IEnumerable<ModuleDto> moduleDtos)
        {
            foreach (ModuleDto moduleDto in moduleDtos)
            {
                Module module = new Module
                                    {
                                        Enabled = moduleDto.Enabled,
                                        Name = moduleDto.Name
                                    };
                foreach (ViewDto viewDto in moduleDto.Views)
                {
                    View view = new View
                    {
                        Enabled = viewDto.Enabled,
                        Name = viewDto.Name
                    };

                    foreach (ControlDto controlDto in viewDto.Controls)
                    {
                        Control control=new Control
                        {
                            Property = controlDto.Property,
                            Value = controlDto.Value,
                            Name = controlDto.Name
                        };
                        view.Controls.Add(control);
                    }
                    module.Views.Add(view);
                }
                _permissionsService.Permissions.Add(module);
            }
        }
예제 #12
0
 public ModuleModel(Module module)
 {
     Id = module.Id;
     Name = module.Name;
     Description = module.Description;
     AccessTypeId = module.AccessTypeId;
 }
예제 #13
0
 protected override IHeader Build(Module module, params Value[] parameterArray)
 {
     var ipHeader = CreateHeader<IPHeader>(parameterArray);
     ipHeader.SourceAddress = (IPAddress)parameterArray.First(p => p.Scope.Equals("IPHeader") && p.Name.Equals("SourceAddress")).AsObject;
     ipHeader.VersionIHL = 4;
     return ipHeader;
 }
예제 #14
0
        public void GivenModuleHasUrlReference_ThenCreateModuleContainersGeneratesExternalModuleForTheUrl()
        {
            var module = new Module("~/test");
            module.AddReferences(new[] { "http://test.com/api.js" });

            var externalModule = new Module("http://test.com/api.js");
            var moduleFactory = new Mock<IModuleFactory<Module>>();
            moduleFactory.Setup(f => f.CreateExternalModule("http://test.com/api.js"))
                .Returns(externalModule);
            var moduleFactories = new Dictionary<Type, object>
            {
                { typeof(Module), moduleFactory.Object }
            };
            var moduleSource = new Mock<IModuleSource<Module>>();
            moduleSource
                .Setup(s => s.GetModules(It.IsAny<IModuleFactory<Module>>(), It.IsAny<ICassetteApplication>()))
                .Returns(new[] { module });

            var config = new ModuleConfiguration(
                Mock.Of<ICassetteApplication>(),
                Mock.Of<IDirectory>(),
                Mock.Of<IDirectory>(),
                moduleFactories,
                ""
            );
            config.Add(moduleSource.Object);

            var containers = config.CreateModuleContainers(false, "");
            var generatedModule = containers[typeof(Module)].FindModuleContainingPath("http://test.com/api.js");
            generatedModule.ShouldBeSameAs(externalModule);
        }
예제 #15
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string loginID = "1";
        try
        {
            if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); }
            loginID = ((Login)Session["Login"]).LoginID.ToString();
        }
        catch (Exception ex)
        { }

        Module module = new Module();
        module = ModuleManager.GetModuleByID(Int32.Parse(hfModuleID.Value));
        Module tempModule = new Module();
        tempModule.ModuleID = module.ModuleID;

        tempModule.ModuleName = txtModuleName.Text;
        tempModule.FolderName = txtFolderName.Text;
        tempModule.DefaultURL = txtDefaultURL.Text;
        tempModule.MenuOrder = decimal.Parse(txtMenuOrder.Text);
        tempModule.AddedBy = loginID;
        tempModule.AddedDate = DateTime.Now;
        tempModule.UpdatedBy = loginID;
        tempModule.UpdatedDate = DateTime.Now;
        tempModule.RowStatusID = Int32.Parse(ddlRowStatus.SelectedValue);
        bool result = ModuleManager.UpdateModule(tempModule);
        showModuleGrid();
        btnClear_Click(this, new EventArgs());
    }
예제 #16
0
        public ActionResult Create(PDCPMS.Modules.Authority.Model.BlockAddModel model)
        {
            if (model == null || model.block == null)
            {
                TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "操作失败,系统发生了一个错误" };
                return RedirectToAction("Add");
            }

            Module domainmodel = new Module(model.block.Name, model.block.AddDate, model.block.Description, model.block.Status);

            ReadOnlyCollection<BrokenRule> brokenRules = domainmodel.GetBrokenRules();

            if (brokenRules.Count != 0)
            {
                TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,模块添加失败" };
                TempData["BrokenRules"] = brokenRules;
                TempData["InvalidModel"] = model;
            }

            repository.Add(domainmodel);

            unitOfWork.Commit();

            TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("模块({0})添加成功", model.block.Name) };

            return RedirectToAction("Index");
        }
예제 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlContentService" /> class.
 /// </summary>
 /// <param name="repository">The repository.</param>
 /// <param name="unitOfWork">The unit of work.</param>
 /// <param name="contentService">The content service.</param>
 /// <param name="securityService">The security service.</param>
 public HtmlContentService(IRepository repository, IUnitOfWork unitOfWork, Module.Root.Services.IContentService contentService, ISecurityService securityService)
 {
     this.repository = repository;
     this.unitOfWork = unitOfWork;
     this.contentService = contentService;
     this.securityService = securityService;
 }
예제 #18
0
 public static void SetUp(Module module, Grammar grammar)
 {
     if (pattern == null)
     {
         BlockCommentPrototype.pattern
             = new AbstractPattern(null, "BlockCommentPrototype");    
         
         BlockCommentPrototype.pattern.SetType(typeof(BlockCommentPrototype));
         grammar.PatternDefined(BlockCommentPrototype.pattern);
         
         string expression = "s('/*' *(s(!('*/') a(0 any))) '*/')";
         ParseGraphNode parseGraph = BootstrapParser.Parse(expression,
             new Pattern[]{BlockCommentPrototype.pattern});
     
         pattern = new ConcretePattern(null, "BlockComment",
             parseGraph);
         
         pattern.SetType(typeof(BlockComment));
         
         BlockCommentPrototype.pattern.AddAltPattern(pattern);
     }
     
     module.SetName("BlockComment", typeof(BlockComment));
     grammar.PatternDefined(pattern);
 }
예제 #19
0
        public Module BuildModule(Module module, Context context)
        {
            module.Context = context;
            module.Response = this.responseFormatterFactory.Create(context);

            return module;
        }
예제 #20
0
 public Label(Module parent, string text, Point position)
     : base(parent)
 {
     var stringSize = GameManager.Instance.MenuFont.MeasureString(text);
     Bounds = new Rectangle(position.X, position.Y, (int)stringSize.X, (int)stringSize.Y);
     Text = text;
 }
예제 #21
0
        public Module this[object key]
        {
            get
            {
                if (this.Modules == null || this.Modules.Count <= 0)
                    return null;

                if (ReferenceEquals(key, null))
                    return null;

                int intKey = -1;

                if (!int.TryParse(key.ToString(), out intKey) || intKey < 0 || intKey >= this.Modules.Count)
                    return null;

                //return this.Modules[intKey];

                Module module = new Module();

                foreach (var model in Modules)
                {
                    if (model.Key.Equals(intKey))
                    {
                        module = model;
                    }
                }

                return module;
            }
        }
    public override void Read(Module[] modules)
    {
        StringReader sr = new StringReader (csv);

        int idx = 0;
        string line = null;
        while ((line = sr.ReadLine()) != null) {
            int c = 0;
            string[] ss = line.Split (',');

            if (idx >= modules.Length)
                continue;

            Module m = modules [idx];
            m.moduleName = ss [c++];

            int num = (ss.Length - 1) / 4;
            m.partials = new Module.Partial[num];

            for (int i=0; i<num; i++) {
                Module.Partial p = new Module.Partial ();
                p.start = int.Parse (ss [c++]);

                p.sColor = ToColor (int.Parse (ss [c++]));
                p.end = int.Parse (ss [c++]);
                p.eColor = ToColor (int.Parse (ss [c++]));
                m.partials [i] = p;
            }

            idx++;
        }
    }
예제 #23
0
        public DefaultBuildEnvironment(IPlan plan, ITargetDescription description, TaskMap<ModuleName, ITarget> taskMap, CancellationToken token)
        {
            if (taskMap == null)
                throw new System.ArgumentNullException("taskMap");
            if (description == null)
                throw new System.ArgumentNullException("description");
            if ((object) plan == null)
                throw new System.ArgumentNullException("plan");

            _token = token;
            _plan = plan;
            _taskMap = taskMap;
            _description = description;
            var externals = new List<SymbolInfo>();
            foreach (var name in description.Dependencies)
            {
                var d = taskMap[name].Value.Result;
                if (d.Symbols == null) continue;
                var origin = new SymbolOrigin.ModuleTopLevel(name, NoSourcePosition.Instance);
                externals.AddRange(from decl in d.Symbols
                                   select new SymbolInfo(decl.Value, origin, decl.Key));
            }
            _externalSymbols = SymbolStore.Create(conflictUnionSource: externals);
            _compilationEngine = new Engine();
            _module = Module.Create(description.Name);
        }
		protected MetadataRW(Module module, bool bigStrings, bool bigGuids, bool bigBlobs)
		{
			this.bigStrings = bigStrings;
			this.bigGuids = bigGuids;
			this.bigBlobs = bigBlobs;
			this.bigField = module.Field.IsBig;
			this.bigMethodDef = module.MethodDef.IsBig;
			this.bigParam = module.Param.IsBig;
			this.bigTypeDef = module.TypeDef.IsBig;
			this.bigProperty = module.Property.IsBig;
			this.bigEvent = module.Event.IsBig;
			this.bigGenericParam = module.GenericParam.IsBig;
			this.bigModuleRef = module.ModuleRef.IsBig;
			this.bigResolutionScope = IsBig(2, module.ModuleTable, module.ModuleRef, module.AssemblyRef, module.TypeRef);
			this.bigTypeDefOrRef = IsBig(2, module.TypeDef, module.TypeRef, module.TypeSpec);
			this.bigMemberRefParent = IsBig(3, module.TypeDef, module.TypeRef, module.ModuleRef, module.MethodDef, module.TypeSpec);
			this.bigMethodDefOrRef = IsBig(1, module.MethodDef, module.MemberRef);
			this.bigHasCustomAttribute = IsBig(5, module.MethodDef, module.Field, module.TypeRef, module.TypeDef, module.Param, module.InterfaceImpl, module.MemberRef,
				module.ModuleTable, /*module.Permission,*/ module.Property, module.Event, module.StandAloneSig, module.ModuleRef, module.TypeSpec, module.AssemblyTable,
				module.AssemblyRef, module.File, module.ExportedType, module.ManifestResource);
			this.bigCustomAttributeType = IsBig(3, module.MethodDef, module.MemberRef);
			this.bigHasConstant = IsBig(2, module.Field, module.Param, module.Property);
			this.bigHasSemantics = IsBig(1, module.Event, module.Property);
			this.bigHasFieldMarshal = IsBig(1, module.Field, module.Param);
			this.bigHasDeclSecurity = IsBig(2, module.TypeDef, module.MethodDef, module.AssemblyTable);
			this.bigTypeOrMethodDef = IsBig(1, module.TypeDef, module.MethodDef);
			this.bigMemberForwarded = IsBig(1, module.Field, module.MethodDef);
			this.bigImplementation = IsBig(2, module.File, module.AssemblyRef, module.ExportedType);
		}
예제 #25
0
 public TranslatePoint(Module connectedModule, double xTranslation, double yTranslation, double zTranslation)
 {
     ConnectedModule = connectedModule;
     XTranslation = xTranslation;
     YTranslation = yTranslation;
     ZTranslation = zTranslation;
 }
예제 #26
0
        /// <summary>
        /// Builds the module for Serenity.
        /// </summary>
        /// <returns></returns>
        public override Module CreateModule()
        {
            Module m = new Module("serenity");

            m.Resources.AddRange(this.BuildResourceTree(ResourceNamespace));
            return m;
        }
예제 #27
0
		public void Initialize(Module aModule)
		{
			Module = aModule;
			theWinFormThread = new Thread(WinFormThread);
			theWinFormThread.SetApartmentState(ApartmentState.STA);
			theWinFormThread.Start();
		}
예제 #28
0
 protected override IHeader Build(Module module, params Value[] parameterArray)
 {
     var udpHeader = CreateHeader<UdpHeader>(parameterArray);
     udpHeader.PseudoDestinationPort1 = (IPAddress)parameterArray.First(p => p.Scope.Equals("IPHeader") && p.Name.Equals("DestinationAddress")).AsObject;
     udpHeader.PseudoSourcePort = (IPAddress)parameterArray.First(p => p.Scope.Equals("IPHeader") && p.Name.Equals("SourceAddress")).AsObject;
     return udpHeader;
 }
예제 #29
0
 public TranslatePoint(Module connectedModule)
 {
     ConnectedModule = connectedModule;
     XTranslation = DefaultTranslatePointX;
     YTranslation = DefaultTranslatePointY;
     ZTranslation = DefaultTranslatePointZ;
 }
예제 #30
0
 public Displace(Module sourceModule, Module displaceModuleX, Module displaceModuleY, Module displaceModuleZ)
 {
     SourceModule = sourceModule;
     DisplaceModuleX = displaceModuleX;
     DisplaceModuleY = displaceModuleY;
     DisplaceModuleZ = displaceModuleZ;
 }
예제 #31
0
        private static void FindAllTypes(List <Type> newlyFoundObjects, Assembly assembly, Module module)
        {
            Type[] types;

            using (Logger.SuppressFirstChanceExceptionLogMessages())
            {
                try
                {
                    types = module.GetTypes();
                }
                catch (ReflectionTypeLoadException ex)
                {
                    //Since its possible that during enumeration, the GetTypes method can error, this will allow us
                    //to enumerate the types that did not error.
                    Log.Publish(MessageLevel.Error, "Reflection Load Error Occurred", assembly.GetName().Name, $"{ex}{Environment.NewLine}{string.Join(Environment.NewLine, ex.LoaderExceptions.Select(x => x.ToString()))}", ex);
                    types = ex.Types;
                }
            }

            foreach (Type assemblyType in types)
            {
                try
                {
                    if (!(assemblyType is null))
                    {
                        newlyFoundObjects.Add(assemblyType);
                    }
                }
                catch (Exception ex)
                {
                    Log.Publish(MessageLevel.Critical, MessageFlags.BugReport, "Static Constructor Error", null, null, ex);
                }
            }
        }
예제 #32
0
 public ResourceRenamer(Module module)
 {
     this.module = module;
 }
예제 #33
0
 public ModulesLecturesViewModel(int subjectId, Module module) : base(subjectId, module)
 {
     LecturesData =
         SubjectManagementService.GetSubject(subjectId).Lectures.Select(e => new LecturesDataViewModel(e)).ToList();
 }
예제 #34
0
        private static void webkitTests(string folderPath = "tests\\webkit\\")
        {
            bool showAll    = false;
            bool refresh    = true;
            int  lastUpdate = Environment.TickCount;

            Action <string> _      = Console.WriteLine;
            var             sw     = new Stopwatch();
            int             passed = 0;
            int             failed = 0;
            string          code;
            string          preCode  = "";
            string          postCode = "";
            Module          s        = null;

            _("webkit testing begun...");
            _("Load standalone-pre.js...");
            using (var staFile = new FileStream(folderPath + "resources\\standalone-pre.js", FileMode.Open, FileAccess.Read))
                preCode = new StreamReader(staFile).ReadToEnd();
            _("Load standalone-post.js...");
            using (var staFile = new FileStream(folderPath + "resources\\standalone-post.js", FileMode.Open, FileAccess.Read))
                postCode = new StreamReader(staFile).ReadToEnd();
            _("Directory: \"" + Directory.GetParent(folderPath) + "\"");

            _("Scaning directory...");
            var fls = Directory.EnumerateFiles(folderPath, "*.js", SearchOption.AllDirectories).ToArray();

            _("Found " + (fls.Length - 2) + " js-files");
            bool skipedShowed = false;

            sw.Start();
            for (int i = 0; i < fls.Length; i++)
            {
                if (i != 0 && !skipedShowed)
                {
                    _("Skiped: " + i);
                }
                skipedShowed = true;
                try
                {
                    if (fls[i].EndsWith("standalone-pre.js") ||
                        fls[i].EndsWith("standalone-post.js"))
                    {
                        continue;
                    }
                    if (showAll)
                    {
                        Console.Write("Processing file \"" + fls[i] + "\" ");
                    }
                    var f  = new FileStream(fls[i], FileMode.Open, FileAccess.Read);
                    var sr = new StreamReader(f, true);
                    code = sr.ReadToEnd();
                    sr.Dispose();
                    f.Dispose();
                    Context econtext = null;
                    if (refresh || s == null)
                    {
                        Context.ResetGlobalContext();
                        s = new Module(preCode);
                        s.Run();
                        econtext = s.Context;
                        s.Context.DefineVariable("print").Assign(new ExternalFunction((t, e) =>
                        {
                            bool fail = code.Length == 0; // она всегда не равна нулю,
                            // но таким образом мы можем прочитать код без гуляния по стеку
                            string text;
                            for (var ti = 0; e != null && ti < e.Length; ti++)
                            {
                                text = e[ti].ToString();
                                if (ti == 0 && text == "FAIL")
                                {
                                    fail = true;
                                }
                                if (ti > 0)
                                {
                                    System.Console.Write(' ');
                                }
                                System.Console.Write(text);
                            }
                            if (fail)
                            {
                                failed++;
                                Debugger.Break();
                            }
                            else
                            {
                                passed++;
                            }
                            System.Console.WriteLine();
                            return(JSValue.Undefined);
                        }));
                    }
                    else
                    {
                        econtext = new Context(s.Context);
                    }
                    try
                    {
                        econtext.Eval(code, true);
                    }
                    finally
                    {
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debugger.Break();
                    Console.WriteLine(e);
                }
                if (Environment.TickCount - lastUpdate > 100)
                {
                    Console.Title = "passed: " + passed + ". failed: " + failed;
                    lastUpdate    = Environment.TickCount;
                }
            }
            sw.Stop();
            _("time: " + sw.Elapsed);
            _("webkit test complite");
        }
예제 #35
0
 public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
 {
     throw new NotImplementedException();
 }
예제 #36
0
		public abstract void Found(Module mod);
예제 #37
0
 private void AddRemoteClick(object sender, EventArgs e)
 {
     UICommands.StartRemotesDialog();
     _NO_TRANSLATE_Remotes.DataSource = Module.GetRemoteNames();
 }
예제 #38
0
 /// <summary>
 /// Reads the function name and displacement.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="address">The address.</param>
 public Tuple <string, ulong> ReadFunctionNameAndDisplacement(Module module, ulong address)
 {
     return(ReadFunctionNameAndDisplacement(module, ClrStackFrame.Method, address));
 }
예제 #39
0
 /// <summary>
 /// Reads the name of the source file, line and displacement.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="address">The address.</param>
 public Tuple <string, uint, ulong> ReadSourceFileNameAndLine(Module module, ulong address)
 {
     return(ReadSourceFileNameAndLine((ClrMdModule)Module, ClrStackFrame.Method, address));
 }
예제 #40
0
 public void Store(Module module)
 {
     DocumentSession.Store(module);
 }
예제 #41
0
 public virtual void VisitModule(Module module)
 {
     VisitPackage(module.Package);
     VisitItemArray(module.Items);
 }
예제 #42
0
        public virtual void VisitItem(Object item)
        {
            if (item == null)
            {
                return;
            }

            Module module = item as Module;

            if (module != null)
            {
                VisitModule(module);
                return;
            }
            Product product = item as Product;

            if (product != null)
            {
                VisitProduct(product);
                return;
            }
            Feature feature = item as Feature;

            if (feature != null)
            {
                VisitFeature(feature);
                return;
            }
            AdvtExecuteSequence advtExecuteSequence = item as AdvtExecuteSequence;

            if (advtExecuteSequence != null)
            {
                VisitAdvtExecuteSequence(advtExecuteSequence);
                return;
            }
            InstallUISequence installUISequence = item as InstallUISequence;

            if (installUISequence != null)
            {
                VisitInstallUISequence(installUISequence);
                return;
            }
            User user = item as User;

            if (user != null)
            {
                VisitUser(user);
                return;
            }
            Upgrade upgrade = item as Upgrade;

            if (upgrade != null)
            {
                VisitUpgrade(upgrade);
                return;
            }
            Directory directory = item as Directory;

            if (directory != null)
            {
                VisitDirectory(directory);
                return;
            }
            PropertyRef propertyRef = item as PropertyRef;

            if (propertyRef != null)
            {
                VisitPropertyRef(propertyRef);
                return;
            }
            WebSite webSite = item as WebSite;

            if (webSite != null)
            {
                VisitWebSite(webSite);
                return;
            }
            AdminUISequence adminUISequence = item as AdminUISequence;

            if (adminUISequence != null)
            {
                VisitAdminUISequence(adminUISequence);
                return;
            }
            CustomAction customAction = item as CustomAction;

            if (customAction != null)
            {
                VisitCustomAction(customAction);
                return;
            }
            DirectoryRef directoryRef = item as DirectoryRef;

            if (directoryRef != null)
            {
                VisitDirectoryRef(directoryRef);
                return;
            }
            AppId appId = item as AppId;

            if (appId != null)
            {
                VisitAppId(appId);
                return;
            }
            Media media = item as Media;

            if (media != null)
            {
                VisitMedia(media);
                return;
            }
            CustomTable customTable = item as CustomTable;

            if (customTable != null)
            {
                VisitCustomTable(customTable);
                return;
            }
            Condition condition = item as Condition;

            if (condition != null)
            {
                VisitCondition(condition);
                return;
            }
            SFPCatalog sFPCatalog = item as SFPCatalog;

            if (sFPCatalog != null)
            {
                VisitSFPCatalog(sFPCatalog);
                return;
            }
            UI ui = item as UI;

            if (ui != null)
            {
                VisitUI(ui);
                return;
            }
            FragmentRef fragmentRef = item as FragmentRef;

            if (fragmentRef != null)
            {
                VisitFragmentRef(fragmentRef);
                return;
            }
            Icon icon = item as Icon;

            if (icon != null)
            {
                VisitIcon(icon);
                return;
            }
            Property property = item as Property;

            if (property != null)
            {
                VisitProperty(property);
                return;
            }
            FeatureRef featureRef = item as FeatureRef;

            if (featureRef != null)
            {
                VisitFeatureRef(featureRef);
                return;
            }
            WebDirProperties webDirProperties = item as WebDirProperties;

            if (webDirProperties != null)
            {
                VisitWebDirProperties(webDirProperties);
                return;
            }
            ComplianceCheck complianceCheck = item as ComplianceCheck;

            if (complianceCheck != null)
            {
                VisitComplianceCheck(complianceCheck);
                return;
            }
            InstallExecuteSequence installExecuteSequence = item as InstallExecuteSequence;

            if (installExecuteSequence != null)
            {
                VisitInstallExecuteSequence(installExecuteSequence);
                return;
            }
            AdminExecuteSequence adminExecuteSequence = item as AdminExecuteSequence;

            if (adminExecuteSequence != null)
            {
                VisitAdminExecuteSequence(adminExecuteSequence);
                return;
            }
            Binary binary = item as Binary;

            if (binary != null)
            {
                VisitBinary(binary);
                return;
            }
            Group group = item as Group;

            if (group != null)
            {
                VisitGroup(group);
                return;
            }
            WebApplication webApplication = item as WebApplication;

            if (webApplication != null)
            {
                VisitWebApplication(webApplication);
                return;
            }
            ActionSequenceType actionSequenceType = item as ActionSequenceType;

            if (actionSequenceType != null)
            {
                VisitActionSequenceType(actionSequenceType);
                return;
            }
            ActionModuleSequenceType actionModuleSequenceType = item as ActionModuleSequenceType;

            if (actionModuleSequenceType != null)
            {
                VisitActionModuleSequenceType(actionModuleSequenceType);
                return;
            }
            BillboardAction billboardAction = item as BillboardAction;

            if (billboardAction != null)
            {
                VisitBillboardAction(billboardAction);
                return;
            }
            Error error = item as Error;

            if (error != null)
            {
                VisitError(error);
                return;
            }
            Dialog dialog = item as Dialog;

            if (dialog != null)
            {
                VisitDialog(dialog);
                return;
            }
            ProgressText progressText = item as ProgressText;

            if (progressText != null)
            {
                VisitProgressText(progressText);
                return;
            }
            TextStyle textStyle = item as TextStyle;

            if (textStyle != null)
            {
                VisitTextStyle(textStyle);
                return;
            }
            ListBox listBox = item as ListBox;

            if (listBox != null)
            {
                VisitListBox(listBox);
                return;
            }
            ListView listView = item as ListView;

            if (listView != null)
            {
                VisitListView(listView);
                return;
            }
            ComboBox comboBox = item as ComboBox;

            if (comboBox != null)
            {
                VisitComboBox(comboBox);
                return;
            }
            UIText uIText = item as UIText;

            if (uIText != null)
            {
                VisitUIText(uIText);
                return;
            }
            RadioGroup radioGroup = item as RadioGroup;

            if (radioGroup != null)
            {
                VisitRadioGroup(radioGroup);
                return;
            }
            IniFileSearch iniFileSearch = item as IniFileSearch;

            if (iniFileSearch != null)
            {
                VisitIniFileSearch(iniFileSearch);
                return;
            }
            RegistrySearch registrySearch = item as RegistrySearch;

            if (registrySearch != null)
            {
                VisitRegistrySearch(registrySearch);
                return;
            }
            ComponentSearch componentSearch = item as ComponentSearch;

            if (componentSearch != null)
            {
                VisitComponentSearch(componentSearch);
                return;
            }
            FileSearch fileSearch = item as FileSearch;

            if (fileSearch != null)
            {
                VisitFileSearch(fileSearch);
                return;
            }
            DirectorySearch directorySearch = item as DirectorySearch;

            if (directorySearch != null)
            {
                VisitDirectorySearch(directorySearch);
                return;
            }
            File file = item as File;

            if (file != null)
            {
                VisitFile(file);
                return;
            }
            Component component = item as Component;

            if (component != null)
            {
                VisitComponent(component);
                return;
            }
            Merge merge = item as Merge;

            if (merge != null)
            {
                VisitMerge(merge);
                return;
            }
            Custom custom = item as Custom;

            if (custom != null)
            {
                VisitCustom(custom);
                return;
            }
            WebError webError = item as WebError;

            if (webError != null)
            {
                VisitWebError(webError);
                return;
            }
            WebVirtualDir webVirtualDir = item as WebVirtualDir;

            if (webVirtualDir != null)
            {
                VisitWebVirtualDir(webVirtualDir);
                return;
            }
            WebDir webDir = item as WebDir;

            if (webDir != null)
            {
                VisitWebDir(webDir);
                return;
            }
            WebFilter webFilter = item as WebFilter;

            if (webFilter != null)
            {
                VisitWebFilter(webFilter);
                return;
            }
            MergeRef mergeRef = item as MergeRef;

            if (mergeRef != null)
            {
                VisitMergeRef(mergeRef);
                return;
            }
            Subscribe subscribe = item as Subscribe;

            if (subscribe != null)
            {
                VisitSubscribe(subscribe);
                return;
            }
            Publish publish = item as Publish;

            if (publish != null)
            {
                VisitPublish(publish);
                return;
            }
            TypeLib typeLib = item as TypeLib;

            if (typeLib != null)
            {
                VisitTypeLib(typeLib);
                return;
            }
            Shortcut shortcut = item as Shortcut;

            if (shortcut != null)
            {
                VisitShortcut(shortcut);
                return;
            }
            ODBCTranslator oDBCTranslator = item as ODBCTranslator;

            if (oDBCTranslator != null)
            {
                VisitODBCTranslator(oDBCTranslator);
                return;
            }
            Permission permission = item as Permission;

            if (permission != null)
            {
                VisitPermission(permission);
                return;
            }
            Class _class = item as Class;

            if (_class != null)
            {
                VisitClass(_class);
                return;
            }
            CopyFile copyFile = item as CopyFile;

            if (copyFile != null)
            {
                VisitCopyFile(copyFile);
                return;
            }
            Patch patch = item as Patch;

            if (patch != null)
            {
                VisitPatch(patch);
                return;
            }
            ODBCDriver oDBCDriver = item as ODBCDriver;

            if (oDBCDriver != null)
            {
                VisitODBCDriver(oDBCDriver);
                return;
            }
            PerfCounter perfCounter = item as PerfCounter;

            if (perfCounter != null)
            {
                VisitPerfCounter(perfCounter);
                return;
            }
            FileShare fileShare = item as FileShare;

            if (fileShare != null)
            {
                VisitFileShare(fileShare);
                return;
            }
            Certificate certificate = item as Certificate;

            if (certificate != null)
            {
                VisitCertificate(certificate);
                return;
            }
            Category category = item as Category;

            if (category != null)
            {
                VisitCategory(category);
                return;
            }
            WebAppPool webAppPool = item as WebAppPool;

            if (webAppPool != null)
            {
                VisitWebAppPool(webAppPool);
                return;
            }
            SqlString sqlString = item as SqlString;

            if (sqlString != null)
            {
                VisitSqlString(sqlString);
                return;
            }
            ServiceControl serviceControl = item as ServiceControl;

            if (serviceControl != null)
            {
                VisitServiceControl(serviceControl);
                return;
            }
            IsolateComponent isolateComponent = item as IsolateComponent;

            if (isolateComponent != null)
            {
                VisitIsolateComponent(isolateComponent);
                return;
            }
            ServiceConfig serviceConfig = item as ServiceConfig;

            if (serviceConfig != null)
            {
                VisitServiceConfig(serviceConfig);
                return;
            }
            WebProperty webProperty = item as WebProperty;

            if (webProperty != null)
            {
                VisitWebProperty(webProperty);
                return;
            }
            SqlScript sqlScript = item as SqlScript;

            if (sqlScript != null)
            {
                VisitSqlScript(sqlScript);
                return;
            }
            SqlDatabase sqlDatabase = item as SqlDatabase;

            if (sqlDatabase != null)
            {
                VisitSqlDatabase(sqlDatabase);
                return;
            }
            WebLockdown webLockdown = item as WebLockdown;

            if (webLockdown != null)
            {
                VisitWebLockdown(webLockdown);
                return;
            }
            Extension extension = item as Extension;

            if (extension != null)
            {
                VisitExtension(extension);
                return;
            }
            ReserveCost reserveCost = item as ReserveCost;

            if (reserveCost != null)
            {
                VisitReserveCost(reserveCost);
                return;
            }
            RemoveFile removeFile = item as RemoveFile;

            if (removeFile != null)
            {
                VisitRemoveFile(removeFile);
                return;
            }
            ProgId progId = item as ProgId;

            if (progId != null)
            {
                VisitProgId(progId);
                return;
            }
            Microsoft.Tools.WindowsInstallerXml.Serialize.Environment environment = item as
                                                                                    Microsoft.Tools.WindowsInstallerXml.Serialize.Environment;
            if (environment != null)
            {
                VisitEnvironment(environment);
                return;
            }
            ServiceInstall serviceInstall = item as ServiceInstall;

            if (serviceInstall != null)
            {
                VisitServiceInstall(serviceInstall);
                return;
            }
            IniFile iniFile = item as IniFile;

            if (iniFile != null)
            {
                VisitIniFile(iniFile);
                return;
            }
            Registry registry = item as Registry;

            if (registry != null)
            {
                VisitRegistry(registry);
                return;
            }
            CreateFolder createFolder = item as CreateFolder;

            if (createFolder != null)
            {
                VisitCreateFolder(createFolder);
                return;
            }
            MIME mIME = item as MIME;

            if (mIME != null)
            {
                VisitMIME(mIME);
                return;
            }
            Verb verb = item as Verb;

            if (verb != null)
            {
                VisitVerb(verb);
                return;
            }
        }
예제 #43
0
        /// <summary>Creates a fast invocation handler from a method and a module</summary>
        /// <param name="methodInfo">The method to invoke</param>
        /// <param name="module">The module context</param>
        /// <returns>The fast invocation handler</returns>
        public FastInvokeHandler Handler(MethodInfo methodInfo, Module module)
        {
            var result = methodInfo.GetFastDelegate(directBoxValueAccess);

            return((target, parameters) => result(target, parameters));
        }
예제 #44
0
 /// <summary>Creates a fast invocation handler from a method and a module</summary>
 /// <param name="methodInfo">The method to invoke</param>
 /// <param name="module">The module context</param>
 /// <returns>The fast invocation handler</returns>
 ///
 public static FastInvokeHandler GetHandler(DynamicMethod methodInfo, Module module)
 {
     return(Instance.Handler(methodInfo, module));
 }
예제 #45
0
 /// <summary>
 /// Gets the type of the basic type.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="typeId">The type identifier.</param>
 public BasicType GetTypeBasicType(Module module, uint typeId)
 {
     return((BasicType)GetTypeFromId(typeId).baseType);
 }
예제 #46
0
 static Class20()
 {
     Class20.module_0 = typeof(Class20).Assembly.ManifestModule;
 }
예제 #47
0
        /// <summary>
        /// Gets the global variable type identifier.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="globalVariableName">Name of the global variable.</param>
        public uint GetGlobalVariableTypeId(Module module, string globalVariableName)
        {
            var globalVariable = GetGlobalVariable(globalVariableName);

            return(GetTypeId(globalVariable.type));
        }
예제 #48
0
 /// <summary>
 /// Gets the name of the enumeration value.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="enumTypeId">The enumeration type identifier.</param>
 /// <param name="enumValue">The enumeration value.</param>
 public string GetEnumName(Module module, uint enumTypeId, ulong enumValue)
 {
     return(enumTypeNames[enumTypeId][enumValue]);
 }
예제 #49
0
 /// <summary>
 /// Gets the field type id and offset of the specified type.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="typeId">The type identifier.</param>
 /// <param name="fieldName">Name of the field.</param>
 public Tuple <uint, int> GetTypeAllFieldTypeAndOffset(Module module, uint typeId, string fieldName)
 {
     return(GetTypeFieldTypeAndOffset(GetTypeFromId(typeId), fieldName));
 }
예제 #50
0
        /// <summary>
        /// Gets the global variable address.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="globalVariableName">Name of the global variable.</param>
        public ulong GetGlobalVariableAddress(Module module, string globalVariableName)
        {
            var globalVariable = GetGlobalVariable(globalVariableName);

            return(globalVariable.relativeVirtualAddress + module.Offset);
        }
예제 #51
0
 /// <summary>
 /// Gets the element type of the specified type.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="typeId">The type identifier.</param>
 public uint GetTypeElementTypeId(Module module, uint typeId)
 {
     return(GetTypeFromId(typeId).typeId);
 }
예제 #52
0
 /// <summary>
 /// Gets the names of all fields of the specified type.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="typeId">The type identifier.</param>
 public string[] GetTypeAllFieldNames(Module module, uint typeId)
 {
     return(GetTypeAllFieldNames(GetTypeFromId(typeId)));
 }
예제 #53
0
 /// <summary>
 /// Gets the size of the specified type.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="typeId">The type identifier.</param>
 public uint GetTypeSize(Module module, uint typeId)
 {
     return((uint)GetTypeFromId(typeId).length);
 }
예제 #54
0
 /// <summary>
 /// Gets the name of the specified type.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="typeId">The type identifier.</param>
 public string GetTypeName(Module module, uint typeId)
 {
     return(TypeToString.GetTypeString(GetTypeFromId(typeId)));
 }
예제 #55
0
    public static unsafe void Initalize()
    {
        Module mod    = typeof(AntiTamper).Module;
        IntPtr modPtr = Marshal.GetHINSTANCE(mod);

        if (modPtr == (IntPtr)(-1))
        {
            Environment.FailFast("Module error");
        }
        Stream stream;

        stream = new UnmanagedMemoryStream((byte *)modPtr.ToPointer(), 0xfffffff, 0xfffffff, FileAccess.ReadWrite);

        byte[] buff;
        int    checkSumOffset;
        ulong  checkSum;

        byte[] iv;
        byte[] dats;
        int    sn;
        int    snLen;

        using (BinaryReader rdr = new BinaryReader(stream))
        {
            stream.Seek(0x3c, SeekOrigin.Begin);
            uint offset = rdr.ReadUInt32();
            stream.Seek(offset, SeekOrigin.Begin);
            stream.Seek(0x6, SeekOrigin.Current);
            uint sections = rdr.ReadUInt16();
            stream.Seek(0xC, SeekOrigin.Current);
            uint optSize = rdr.ReadUInt16();
            stream.Seek(offset = offset + 0x18, SeekOrigin.Begin);  //Optional hdr
            bool pe32 = (rdr.ReadUInt16() == 0x010b);
            stream.Seek(0x3e, SeekOrigin.Current);
            checkSumOffset = (int)stream.Position;
            uint md = rdr.ReadUInt32() ^ 0x11111111;
            if (md == 0x11111111)
            {
                Environment.FailFast("Broken file");
            }

            stream.Seek(md, SeekOrigin.Begin);
            using (MemoryStream str = new MemoryStream())
            {
                stream.Position += 12;
                stream.Position += rdr.ReadUInt32() + 4;
                stream.Position += 2;

                ushort streams = rdr.ReadUInt16();

                for (int i = 0; i < streams; i++)
                {
                    uint pos  = rdr.ReadUInt32() + md;
                    uint size = rdr.ReadUInt32();

                    int c = 0;
                    while (rdr.ReadByte() != 0)
                    {
                        c++;
                    }
                    long ori = stream.Position += (((c + 1) + 3) & ~3) - (c + 1);

                    stream.Position = pos;
                    str.Write(rdr.ReadBytes((int)size), 0, (int)size);
                    stream.Position = ori;
                }

                buff = str.ToArray();
            }

            stream.Seek(offset = offset + optSize, SeekOrigin.Begin);  //sect hdr
            uint datLoc = 0;
            for (int i = 0; i < sections; i++)
            {
                string str = "";
                for (int j = 0; j < 8; j++)
                {
                    byte chr = rdr.ReadByte();
                    if (chr != 0)
                    {
                        str += (char)chr;
                    }
                }
                uint vSize = rdr.ReadUInt32();
                uint vLoc  = rdr.ReadUInt32();
                uint rSize = rdr.ReadUInt32();
                uint rLoc  = rdr.ReadUInt32();
                if (str.GetHashCode() == 0x03d46cda)
                {
                    datLoc = vLoc;
                }
                stream.Seek(0x10, SeekOrigin.Current);
            }
            stream.Seek(datLoc, SeekOrigin.Begin);
            checkSum = rdr.ReadUInt64() ^ 0x2222222222222222;
            sn       = rdr.ReadInt32();
            snLen    = rdr.ReadInt32();
            iv       = rdr.ReadBytes(rdr.ReadInt32() ^ 0x33333333);
            dats     = rdr.ReadBytes(rdr.ReadInt32() ^ 0x44444444);
        }

        byte[] md5 = MD5.Create().ComputeHash(buff);
        ulong  tCs = BitConverter.ToUInt64(md5, 0) ^ BitConverter.ToUInt64(md5, 8);

        if (tCs != checkSum)
        {
            Environment.FailFast("Broken file");
        }

        byte[] b = Decrypt(buff, iv, dats);
        Buffer.BlockCopy(new byte[buff.Length], 0, buff, 0, buff.Length);
        if (b[0] != 0xd6 || b[1] != 0x6f)
        {
            Environment.FailFast("Broken file");
        }
        byte[] tB = new byte[b.Length - 2];
        Buffer.BlockCopy(b, 2, tB, 0, tB.Length);
        using (BinaryReader rdr = new BinaryReader(new MemoryStream(tB)))
        {
            uint     len      = rdr.ReadUInt32();
            int[]    codeLens = new int[len];
            IntPtr[] ptrs     = new IntPtr[len];
            for (int i = 0; i < len; i++)
            {
                uint pos = rdr.ReadUInt32() ^ 0x55555555;
                if (pos == 0)
                {
                    continue;
                }
                uint   rva  = rdr.ReadUInt32() ^ 0x55555555;
                byte[] cDat = rdr.ReadBytes(rdr.ReadInt32());
                uint   old;
                IntPtr ptr = (IntPtr)((uint)modPtr + rva);
                VirtualProtect(ptr, (uint)cDat.Length, 0x04, out old);
                Marshal.Copy(cDat, 0, ptr, cDat.Length);
                VirtualProtect(ptr, (uint)cDat.Length, old, out old);
                codeLens[i] = cDat.Length;
                ptrs[i]     = ptr;
            }
            //for (int i = 0; i < len; i++)
            //{
            //    if (codeLens[i] == 0) continue;
            //    RuntimeHelpers.PrepareMethod(mod.ModuleHandle.GetRuntimeMethodHandleFromMetadataToken(0x06000000 + i + 1));
            //}
            //for (int i = 0; i < len; i++)
            //{
            //    if (codeLens[i] == 0) continue;
            //    uint old;
            //    VirtualProtect(ptrs[i], (uint)codeLens[i], 0x04, out old);
            //    Marshal.Copy(new byte[codeLens[i]], 0, ptrs[i], codeLens[i]);
            //    VirtualProtect(ptrs[i], (uint)codeLens[i], old, out old);
            //}
        }
    }
예제 #56
0
 /// <summary>
 /// Gets the symbol tag of the specified type.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="typeId">The type identifier.</param>
 public SymTag GetTypeTag(Module module, uint typeId)
 {
     return((SymTag)GetTypeFromId(typeId).symTag);
 }
예제 #57
0
        private static void kraken()
        {
            var folderPath = "kraken-1.1";

            Action <string> _  = Console.WriteLine;
            var             sw = new Stopwatch();

            _("Directory: \"" + Directory.GetParent(folderPath) + "\"");
            _("Scaning directory...");
            var fls = Directory.EnumerateFiles(folderPath, "*.js", SearchOption.AllDirectories).ToArray();

            _("Found " + fls.Length + " js-files");

            long _total = 0;
            var  round  = 0;
            long min    = long.MaxValue;

            Context.ResetGlobalContext();
            for (; round < 1; round++)
            {
                TimeSpan total = new TimeSpan();

                for (var i = 0; i < fls.Length;)
                {
                    string data, body;
                    using (var f = new FileStream(fls[i++], FileMode.Open, FileAccess.Read))
                        using (var sr = new StreamReader(f))
                            data = sr.ReadToEnd();
                    _("Process " + fls[i]);
                    using (var f = new FileStream(fls[i++], FileMode.Open, FileAccess.Read))
                        using (var sr = new StreamReader(f))
                            body = sr.ReadToEnd();

                    sw.Restart();
                    var script = new Module(data);
                    script.Context.DefineVariable("print").Assign(new ExternalFunction((t, a) =>
                    {
                        for (var j = 0; j < a.Length; j++)
                        {
                            System.Console.WriteLine(a[j]);
                        }
                        return(JSValue.Undefined);
                    }));
                    script.Run();
                    script.Context.Eval(body, true);
                    sw.Stop();
                    total += sw.Elapsed;
                    _(sw.Elapsed.ToString());
                    Context.ResetGlobalContext();
                    GC.Collect(0);
                    GC.Collect(1);
                    GC.Collect(2);
                    GC.GetTotalMemory(true);
                }
                _("Total: " + total);
                _total += total.Ticks;
                min     = System.Math.Min(total.Ticks, min);
            }
            _("Average: " + new TimeSpan(_total / round));
            _("Minimum: " + new TimeSpan(min));
        }
예제 #58
0
        private static void sputnikTests(string folderPath = "tests\\sputnik\\")
        {
            bool            showAll    = false;
            bool            refresh    = true;
            int             lastUpdate = Environment.TickCount;
            Action <string> _          = Console.WriteLine;
            var             sw         = new Stopwatch();
            int             passed     = 0;
            int             failed     = 0;
            string          code;
            bool            negative = false;
            string          staCode  = "";
            Module          s        = null;

            _("Sputnik testing begun...");

            _("Load sta.js...");
            using (var staFile = new FileStream("sta.js", FileMode.Open, FileAccess.Read))
                staCode = new StreamReader(staFile).ReadToEnd();

            _("Directory: \"" + Directory.GetParent(folderPath) + "\"");
            _("Scaning directory...");
            var fls = Directory.EnumerateFiles(folderPath, "*.js", SearchOption.AllDirectories).ToArray();

            _("Found " + fls.Length + " js-files");

            bool skipedShowed = false;

            sw.Start();
            for (int i = 0; i < fls.Length; i++)
            {
                if (i != (i ^ i) && !skipedShowed)
                {
                    _("Skiped: " + i);
                }
                skipedShowed = true;
                bool pass = true;
                try
                {
                    if (showAll)
                    {
                        Console.Write("Processing file \"" + fls[i] + "\" ");
                    }
                    var f  = new FileStream(fls[i], FileMode.Open, FileAccess.Read);
                    var sr = new StreamReader(f);
                    code = sr.ReadToEnd();
                    sr.Dispose();
                    f.Dispose();
                    negative = code.IndexOf("@negative") != -1;
                    Context econtext = null;
                    if (refresh || s == null)
                    {
                        Context.ResetGlobalContext();
                        s = new Module(staCode);// инициализация
                        s.Run();
                        econtext = s.Context;
                    }
                    else
                    {
                        econtext = new Context(s.Context);
                    }
                    try
                    {
                        econtext.Eval(code, true);
                    }
                    finally
                    {
                        pass ^= negative;
                    }
                }
                catch (JSException e)
                {
                    pass = negative;
                    if (!pass)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                catch (Exception e)
                {
                    Debugger.Break();
                    Console.WriteLine(e);
                    pass = false;
                }
                if (pass)
                {
                    if (showAll)
                    {
                        _("Passed");
                    }
                    passed++;
                }
                else
                {
                    if (!showAll)
                    {
                        _("File: \"" + fls[i] + "\"" + Environment.NewLine);
                    }
                    else
                    {
                        _("Failed");
                    }
                    failed++;
                }
                if (Environment.TickCount - lastUpdate > 250)
                {
                    Console.Title = "passed: " + passed + ". failed: " + failed;
                    lastUpdate    = Environment.TickCount;
                }
                //if (failed == 1)
                //    break;
            }
            sw.Stop();
            _("passed: " + passed + ". (" + (passed * 100 / fls.Length) + "%)");
            _("failed: " + failed);
            _("time: " + sw.Elapsed);
            _("Sputnik test complite");
        }
예제 #59
0
        public void Assembly(TypeInfo typeInfo)
        {
            Module module = typeInfo.Module;

            Assert.Equal(typeInfo.Assembly, module.Assembly);
        }
예제 #60
0
 public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes)
 {
     throw new NotImplementedException();
 }