private void AddStruct(IType strct, StringBuilder key)
 {
     if (strct.Namespace == "")
     {
         lock (Structs)
         {
             foreach (var typeArg in strct.TypeParameters)
             {
                 foreach (var constraint in typeArg.Constraints)
                 {
                     key.Append(constraint.Name);
                 }
             }
             if (Structs.ContainsKey(key.ToString()))
             {
                 return;
             }
             Structs.Add(key.ToString(), new StructProperties(strct));
         }
     }
     else
     {
         AddNamespace(key, strct);
     }
 }
Exemple #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var attr in Attributes)
            {
                sb.AppendLine(attr.ToString());
            }
            sb.AppendLine($"namespace {NamespaceName}");
            sb.AppendLine("{");
            foreach (string interfaceLine in Interfaces.BreakIntoLines())
            {
                sb.AppendLine($"\t{interfaceLine}");
            }
            foreach (string classLine in Classes.BreakIntoLines())
            {
                sb.AppendLine($"\t{classLine}");
            }
            foreach (string enumLine in Enums.BreakIntoLines())
            {
                sb.AppendLine($"\t{enumLine}");
            }
            foreach (string structLine in Structs.BreakIntoLines())
            {
                sb.AppendLine($"\t{structLine}");
            }
            sb.AppendLine("}");
            return(sb.ToString());
        }
Exemple #3
0
        /// <summary>
        /// Gets the struct info for the given struct type (defined in managed code)
        /// </summary>
        /// <param name="type">The type of the struct</param>
        /// <returns>The struct info for the given type</returns>
        public static ManagedStruct GetManagedStruct(Type type)
        {
            ManagedStruct result;

            Structs.TryGetValue(type, out result);
            return(result);
        }
Exemple #4
0
        public unsafe void SizeOf_Int()
        {
            Structs.SizeInBytes <int>().Should().Be(4);
            int i = 6;

            Structs.SizeInBytes(ref i).Should().Be(4);
        }
Exemple #5
0
        // given an Ident or an Array node, look up the type representation
        private CbType lookUpType(AST node)
        {
            CbType result = CbType.Error;

            if (node.Tag == NodeType.Array)
            {
                CbType elemType = lookUpType(node[0]);
                result = CbType.Array(elemType);
            }
            else
            {
                // it has to be an Ident node
                result = lookUpIdenType(node);
                if (result == CbType.Error)
                {
                    // check if it's a struct
                    string name = ((AST_leaf)node).Sval;
                    if (Structs.ContainsKey(name))
                    {
                        result = Structs[name]; // it's a struct type
                    }
                    else
                    {
                        ReportError(node.LineNumber, "Unknown type {0}", name);
                    }
                }
            }
            node.Type = result; //annotate the node
            return(result);
        }
		private void SetupField(Structs.CompetitionTypeEnum CompetitionType, bool Norwegian,
			out ResultsReturn obj1, out ResultsReturn obj2,
			string testName,
			Structs.CompetitionChampionshipEnum ChampionShip)
		{
			obj1 = new ResultsReturn(
				CompetitionType, 
				Norwegian,
				ChampionShip);
			obj1.ClubId = "01-42";
			obj1.CompetitorId = 1;
			obj1.FigureHitsTotal = 12;
			obj1.FinalShootingPlace = 100;
			obj1.HitsTotal = 12;
			obj1.PointsTotal = 10;
			obj1.ShooterName = "First Shooter " + testName;
			obj1.HitsPerStn = new int[] {6, 6};
			obj1.FigureHitsPerStn = new int[] {2, 2};
			obj1.PointsPerStn = new int[] {0,11};

			obj2 = new ResultsReturn(
				CompetitionType, 
				Norwegian,
				ChampionShip);
			obj2.ClubId = "01-42";
			obj2.CompetitorId = 1;
			obj2.FigureHitsTotal = 12;
			obj2.FinalShootingPlace = 100;
			obj2.HitsTotal = 12;
			obj2.PointsTotal = 10;
			obj2.ShooterName = "Second Shooter " + testName;
			obj2.HitsPerStn = new int[] {6,6};
			obj2.FigureHitsPerStn = new int[] {2,2};
			obj2.PointsPerStn = new int[] {0,11};
		}
        public bool DefineStruct(StructElement data)
        {
            Structs.Add(data);


            return(true);
        }
        public void StructFromString()
        {
            var obj = new Structs();

            AssertEvaluation(obj, "sbyte", "3");
            AssertEvaluation(obj, "short", "3");
            AssertEvaluation(obj, "int", "3");
            AssertEvaluation(obj, "long", "3");

            AssertEvaluation(obj, "byte", "3");
            AssertEvaluation(obj, "ushort", "3");
            AssertEvaluation(obj, "uint", "3");
            AssertEvaluation(obj, "ulong", "3");

            AssertEvaluation(obj, "float", "3");
            AssertEvaluation(obj, "double", "3");
            AssertEvaluation(obj, "decimal", "3");

            AssertEvaluation(obj, "bool", "true");
            AssertEvaluation(obj, "char", "3");

            AssertEvaluation(obj, "dateTime", "3/30/2003");
            AssertEvaluation(obj, "dateTimeOffset", "3/30/2003");
            AssertEvaluation(obj, "timeSpan", "00:03");

            AssertEvaluation(obj, "guid", TEST_GUID);
        }
Exemple #9
0
        public override bool Equals(object obj)
        {
            if (!(obj is NamespaceDescription))
            {
                return(false);
            }
            NamespaceDescription other = (NamespaceDescription)obj;

            if (decl.GetName().Text != other.decl.GetName().Text)
            {
                return(false);
            }

            if (Methods.Count != other.Methods.Count ||
                Fields.Count != other.Fields.Count ||
                Structs.Count != other.Structs.Count ||
                Enrichments.Count != other.Enrichments.Count ||
                Usings.Count != other.Usings.Count ||
                Typedefs.Count != other.Typedefs.Count ||
                Namespaces.Count != other.Namespaces.Count)
            {
                return(false);
            }

            return(!(Methods.Where((t, i) => !t.Equals(other.Methods[i])).Any() ||
                     Fields.Where((t, i) => !t.Equals(other.Fields[i])).Any() ||
                     Structs.Where((t, i) => !t.Equals(other.Structs[i])).Any() ||
                     Enrichments.Where((t, i) => !t.Equals(other.Enrichments[i])).Any() ||
                     Usings.Where((t, i) => t != other.Usings[i]).Any() ||
                     Typedefs.Where((t, i) => !t.Equals(other.Typedefs[i])).Any() ||
                     Namespaces.Where((t, i) => !t.Equals(other.Namespaces[i])).Any()));
        }
Exemple #10
0
    void FixedUpdate()
    {
        int index = 0;

        Structs.AssignHumanStruct(inValues, index, out index, Human.GetComponent <HumanInfo>().human);

        _buffer.SetData(inValues);
    }
        /// <summary>
        ///		Creates a new instance of the MoLangEnvironment class
        /// </summary>
        public MoLangEnvironment()
        {
            Structs.TryAdd("math", MoLangMath.Library);
            Structs.TryAdd("temp", new VariableStruct());
            Structs.TryAdd("variable", new VariableStruct());
            Structs.TryAdd("array", new VariableArrayStruct());

            Structs.TryAdd("context", new ContextStruct());
        }
Exemple #12
0
        private StructDecl FindStructName(Lexeme nameToken)
        {
            if (Structs.ContainsKey(nameToken.Value))
            {
                return(Structs[nameToken.Value]);
            }

            return(Parent?.FindStructName(nameToken));
        }
Exemple #13
0
        public unsafe void AddressOf()
        {
            int  foo           = 6;
            int *directAddress = &foo;
            int *helper        = (int *)Structs.AddressOf(ref foo);

            (directAddress == helper).Should().BeTrue("Address should be the same");
            helper->Should().Be(*directAddress);
        }
Exemple #14
0
 public override string Build()
 {
     return(Load("Body").
            Replace("Name", Name).
            Replace("Properties", Properties.Build()).
            Replace("Structs", Structs.Build()).
            Replace("Main", Main.Build()).
            ToString());
 }
Exemple #15
0
        public EngineApi AnnotateTypes()
        {
            Structs.ForEach(AnnotateStructTypes);
            Structs.ForEach(AnnotateStructFieldCounts);
            Classes.ForEach(AnnotateClassTypes);
            Functions.ForEach(AnnotateFunctionTypes);

            return(this);
        }
Exemple #16
0
        /// <summary>
        /// Tests for Structs.cs
        /// </summary>
        public static void Structs()
        {
            Structs st = new Structs();

            st.changeProperties();
            st.changeStaticFieldInStruct();
            st.structInitializationWithConstructor();
            st.structInitializationWithoutConstructor();
        }
Exemple #17
0
        public void AddStruct(Lexeme nameToken, StructDecl node, ErrorHandler errorHandler)
        {
            if (FindStructName(nameToken) != null)
            {
                errorHandler.AddMessage(Severity.Error, $"Duplicate declaration of struct '{nameToken.Value}'", nameToken);
                return;
            }

            Structs.Add(nameToken.Value, node);
        }
        public static unsafe void ToUpperInvariant(ref UNICODE_STRING value)
        {
            NTSTATUS status = Imports.RtlUpcaseUnicodeString(
                (UNICODE_STRING *)Structs.AddressOf(ref value), (UNICODE_STRING *)Structs.AddressOf(ref value), false);

            if (!ErrorMacros.NT_SUCCESS(status))
            {
                ErrorMethods.GetIoExceptionForNTStatus(status);
            }
        }
        public void InvalidValueHandling()
        {
            var obj = new Structs();

            var compiler = new FilterExpressionCompiler <Structs>(false);

            Assert.Equal("False", compiler.Compile(new[] { "byte", "-3" }).Body.ToString());
            Assert.Equal("False", compiler.Compile(new[] { "byte", "257" }).Body.ToString());
            Assert.Equal("False", compiler.Compile(new[] { "int", "not-int" }).Body.ToString());
        }
 /// <summary>
 /// Returns the offset within the FAT of the next block
 /// </summary>
 /// <param name="baseBlock">The root block for the entry</param>
 public static long BlockToFATOffset(uint baseBlock, Structs.PartitionInfo Partition)
 {
     if (baseBlock > Partition.Clusters)
     {
         // throw new Exception("Cluster ref of range");
     }
     long rVal = baseBlock * (int)Partition.EntrySize;
     rVal += Partition.FATOffset;
     return rVal;
 }
 public Bulbs(Structs.Vector3 xyz, float r, float g, float b)
 {
     this.x = xyz.x;
     this.y = xyz.y;
     this.z = xyz.z;
     
     Glu.gluQuadricNormals(bulb, Glu.GLU_SMOOTH);
     Gl.glColor3f(r, g, b);
     this.Draw();
     
 }
 /// <summary>
 ///     Maps the native FileInfo3 Structure to a managed FileInfo3 Class.
 /// </summary>
 /// <param name="fileInfo">The native source FileInfo3.</param>
 /// <returns>A Managed FileInfo3 Object.</returns>
 internal static FileInfo3 MapToFileInfo3(Structs.FileInfo3 fileInfo)
 {
     return new FileInfo3
     {
         RessourceId = fileInfo.SessionID,
         NumberOfLocks = fileInfo.NumLocks,
         Path = fileInfo.PathName,
         Permission = (Enum.SharePermissions) fileInfo.Permission,
         Username = fileInfo.UserName
     };
 }
 public MemoryAddress(Memory memory, Structs.MemoryBasicInformation memoryRegion, ulong offset, ValueType type, uint length, bool isUnicode)
 {
     Memory = memory;
     MemoryRegion = memoryRegion;
     Offset = offset;
     Type = type;
     Length = length;
     IsUnicode = isUnicode;
     MemoryType = memoryRegion.Protect.ToString();
     _value = ReadValueFromProcessMemory();
 }
 public void Clear()
 {
     //Includes.Clear();
     Methods.Clear();
     Fields.Clear();
     Structs.Clear();
     Typedefs.Clear();
     Enrichments.Clear();
     Usings.Clear();
     Namespaces.Clear();
 }
 public void AddStruct(TSLStruct struct_)
 {
     Structs.Add(struct_);
     if (struct_.Depth < StructSettings.MaxDepth)
     {
         StructsBeforeMaxDepth.Add(struct_);
         if (!struct_.DynamicLengthed)
         {
             FixedLengthStructsBeforeMaxDepth.Add(struct_);
         }
     }
 }
        public void IntegralFromFloatString()
        {
            var obj = new Structs();

            AssertEvaluation(obj, "sbyte", "2.9");
            AssertEvaluation(obj, "int", "2.9");
            AssertEvaluation(obj, "long", "2.9");

            AssertEvaluation(obj, "byte", "2.9");
            AssertEvaluation(obj, "uint", "2.9");
            AssertEvaluation(obj, "ulong", "2.9");
        }
        public void DatesFromIsoFormatWithUtc()
        {
            var testDate       = new DateTime(2000, 1, 2, 3, 4, 5, DateTimeKind.Utc);
            var testDateString = "2000-01-02T03:04:05Z";

            var obj = new Structs {
                dateTime       = testDate,
                dateTimeOffset = (DateTimeOffset)testDate
            };

            AssertEvaluation(obj, "dateTime", testDateString);
            AssertEvaluation(obj, "dateTimeOffset", testDateString);
        }
        public void DatesWithTimeComponent()
        {
            var testDate       = new DateTime(2000, 1, 2, 3, 4, 5, 6);
            var testDateString = testDate.ToString("M/dd/yyyy HH:mm:ss.fff");

            var obj = new Structs {
                dateTime       = testDate,
                dateTimeOffset = (DateTimeOffset)testDate
            };

            AssertEvaluation(obj, "dateTime", testDateString);
            AssertEvaluation(obj, "dateTimeOffset", testDateString);
        }
        public void FilterByEnumField()
        {
            var structObj = new Structs();

            AssertEvaluation(structObj, "enum", "=", 3);
            AssertEvaluation(structObj, "enum", "=", "3");
            AssertEvaluation(structObj, "enum", "=", "wednesday");

            var nullableObj = new NullableStructs();

            AssertEvaluation(nullableObj, "enum", "=", 3);
            AssertEvaluation(nullableObj, "enum", "=", "3");
            AssertEvaluation(nullableObj, "enum", "=", "wednesday");
        }
        public void IntegralFromFloat()
        {
            var obj = new Structs();

            AssertEvaluation(obj, "sbyte", 2.9);
            AssertEvaluation(obj, "short", 2.9);
            AssertEvaluation(obj, "int", 2.9);
            AssertEvaluation(obj, "long", 2.9);

            AssertEvaluation(obj, "byte", 2.9);
            AssertEvaluation(obj, "ushort", 2.9);
            AssertEvaluation(obj, "uint", 2.9);
            AssertEvaluation(obj, "ulong", 2.9);
        }
Exemple #31
0
        public void Executa()
        {
            int opcao = 0;

            do
            {
                MontaMenu();
                Console.WriteLine("Digite uma opção: ");
                opcao = Convert.ToInt32(Console.ReadLine());

                Tipos          tipos          = new Tipos();
                TiposInteiros  tiposInteiros  = new TiposInteiros();
                PontoFlutuante pontoFlutuante = new PontoFlutuante();
                Booleano       booleano       = new Booleano();
                Structs        structs        = new Structs();
                Enums          enuns          = new Enums();

                switch (opcao)
                {
                case 1:
                    tipos.Executa();
                    break;

                case 2:
                    tiposInteiros.Executa();
                    break;

                case 3:
                    pontoFlutuante.Executa();
                    break;

                case 4:
                    booleano.Executa();
                    break;

                case 5:
                    structs.Executa();
                    break;

                case 6:
                    enuns.Executa();
                    break;

                default:
                    break;
                }
                Console.ReadLine();
                Console.Clear();
            } while (opcao != 0);
        }
Exemple #32
0
 /// <summary>
 /// Saves the settings.
 /// </summary>
 public override void SaveSettings()
 {
     Settings.Default.Reorganizing_MemberTypeClasses      = Classes.Serialize();
     Settings.Default.Reorganizing_MemberTypeConstructors = Constructors.Serialize();
     Settings.Default.Reorganizing_MemberTypeDelegates    = Delegates.Serialize();
     Settings.Default.Reorganizing_MemberTypeDestructors  = Destructors.Serialize();
     Settings.Default.Reorganizing_MemberTypeEnums        = Enums.Serialize();
     Settings.Default.Reorganizing_MemberTypeEvents       = Events.Serialize();
     Settings.Default.Reorganizing_MemberTypeFields       = Fields.Serialize();
     Settings.Default.Reorganizing_MemberTypeIndexers     = Indexers.Serialize();
     Settings.Default.Reorganizing_MemberTypeInterfaces   = Interfaces.Serialize();
     Settings.Default.Reorganizing_MemberTypeMethods      = Methods.Serialize();
     Settings.Default.Reorganizing_MemberTypeProperties   = Properties.Serialize();
     Settings.Default.Reorganizing_MemberTypeStructs      = Structs.Serialize();
 }
Exemple #33
0
 public void SetStruct(Class c)
 {
     if (c.IsClass)
     {
         return;
     }
     foreach (var @struct in Structs)
     {
         if (@struct == c)
         {
             return;
         }
     }
     Structs.Add(c);
 }
Exemple #34
0
        public StructDef LookupOrCreateStruct(string name)
        {
            var def = Structs.Lookup(name);

            if (def == null)
            {
                def = new StructDef {
                    Name        = name,
                    Predecl     = true,
                    TypeBuilder = this,
                };
                Structs.Add(name, def);
            }
            return(def);
        }
        public AirStrip(Structs.Vector3 xyz, int texId)
        {
            this.width = xyz.x;
            this.height = xyz.y;
            this.depth = xyz.z;

            Gl.glPushMatrix();
            {
                Gl.glTranslatef(0.0f, 0.0f, 20.0f);
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, texId);
                this.Draw();
            }
            Gl.glPopMatrix();

        }
        public void SetValue(MoPath name, IMoValue value)
        {
            if (!Structs.TryGetValue(name.Value, out var v))
            {
                throw new MoLangRuntimeException($"Invalid path: {name.Path}", null);
            }

            try
            {
                v.Set(name.Next, value);
            }
            catch (Exception ex)
            {
                throw new MoLangRuntimeException($"Cannot set value on struct: {name}", ex);
            }
        }
Exemple #37
0
 public List<Structs.Node> ReconstructPath(List<Structs.Node> ClosedList, Structs.Node End, Structs.Node Start)
 {
     List<Structs.Node> Path = new List<Structs.Node>();
     foreach (Structs.Node nd in ClosedList)
     {
         if (nd.X == End.X && nd.Y == End.Y)
         {
             Path.Add(nd); // First path point added.
         }
     }
     while (Path[Path.Count - 1].X != Start.X || Path[Path.Count -1].Y != Start.Y)
     {
         // Add last items parent to Path list (Path[Path.Count - 1].ParentID)
         Path.Add(getParent(Path[Path.Count - 1].parentID, ClosedList));
     }
     return Path;
 }
        public Base(Structs.Vector3 xyz, int texId)
        {
            this.x = xyz.x;
            this.y = xyz.y;
            this.z = xyz.z;

            Gl.glPushMatrix();
            {
                Gl.glMatrixMode(Gl.GL_TEXTURE);
                Gl.glLoadIdentity();
                Gl.glScalef(10.0f, 10.0f, 0.0f);
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_DECAL);
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, texId);
                Gl.glColor3f(0.4f, 0.4f, 0.4f);
                this.Draw();
                Gl.glMatrixMode(Gl.GL_TEXTURE);
                Gl.glLoadIdentity();
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_ADD);
            }
            Gl.glPopMatrix();
        }
Exemple #39
0
 public static extern bool Process32Next(IntPtr hSnapshot, ref Structs.PROCESSENTRY32 lppe);
 public static extern bool GetWindowRect(IntPtr hwnd, out Structs.RECT lpRect);
 public static extern bool GetClientRect(IntPtr hWnd, out Structs.RECT lpRect);
Exemple #42
0
        public List<Structs.Node> FindPath(Structs.Node Start, Structs.Node End, int[,] MapMatrix)
        {
            // A counter to check progress when debugging:
            int index = 0;
            float hMult;
            bool Finished = false;

            // Declare Open and Closed sets, Current Node
            List<Structs.Node> OpenSet = new List<Structs.Node>();
            List<Structs.Node> ClosedSet = new List<Structs.Node>();
            Structs.Node CurrentNode = Start;
            int i = 0;
            
            //Configure the current node X, Y, G, H, F, and ID
            CurrentNode.X = Start.X;
            CurrentNode.Y = Start.Y;
            CurrentNode.G = MapMatrix[Start.X, Start.Y]; // The G cost of each tile is the speed of that tile, as it costs that value to move to the next one.
            CurrentNode.heuristic = (Math.Abs(CurrentNode.X - End.X) + Math.Abs(CurrentNode.Y - End.Y)); // The heuristic of the starting tile will always be fixed
            CurrentNode.F = CurrentNode.G + CurrentNode.heuristic;
            CurrentNode.ID = i;

            // Add the current node (Starting Node) to the OpenSet for consideration.
            OpenSet.Add(CurrentNode);


            // While the open set contains nodes
            while (Finished == false)
            {
                i++;
                // Set the current node to the value in the open set with the lowest F (H + G)
                CurrentNode = GetLowestF(OpenSet);

                // If the current tile is the goal, return reconstruct path method
                if (CurrentNode.X == End.X && CurrentNode.Y == End.Y)
                {
                    // TODO : Add ReconstructPath to this return method.
                    ClosedSet.Add(CurrentNode);
                    return ClosedSet;
                }

                // Remove the current tile from the open set, but retain it in current tile var
                OpenSet.Remove(CurrentNode);

                // Add the current tile to the closed set, retaining it in the current tile var
                ClosedSet.Add(CurrentNode);

                // For each neighbor tile
                for (int x = -1; x < 2; x++)
                {
                    for (int y = -1; y < 2; y++)
                    {
                        if (CurrentNode.X + x < 0 || CurrentNode.Y + y < 0 || CurrentNode.X + x > 8 || CurrentNode.Y + y > 8 )
                        {
                            break;
                        }

                        if ((x == 1 && y == 1) || (x == -1 && y == -1) || (x == 1 && y == -1) || (x == -1 && y == 1))
                            hMult = 1.4f;
                        else
                            hMult = 1f;

                        index++;
                        // Create a neighbor node for investigation
                        Structs.Node neighbor = new Structs.Node();
                        neighbor.X = CurrentNode.X + x;
                        neighbor.Y = CurrentNode.Y + y;
                        neighbor.ID = i;
                        i++;

                        if (MapMatrix[neighbor.X, neighbor.Y] == 3)
                        {
                            break;
                        }

                        // Set Heuristic to the estimated heuristic
                        neighbor.heuristic = hMult * (Math.Abs(neighbor.X - End.X) + Math.Abs(neighbor.Y - End.Y));

                        // Set G score of neighbor to current G score + cost of moving from current to neighbor
                        neighbor.G = CurrentNode.G + MapMatrix[neighbor.X, neighbor.Y];

                        // TODO Modify this to set the parent to the best one for the node
                        neighbor.parentID = CurrentNode.ID; 


                        neighbor.G = CurrentNode.G + MapMatrix[neighbor.X, neighbor.Y];
                        neighbor.F = neighbor.G + neighbor.heuristic;

                        // If the neighbor is in the closed set or the G score is higher than the current G score, break
                        // If the neighbor is not in the open set or the neighbor G score is less than the current G score
                        if ((!OpenSet.Contains(neighbor) || neighbor.G >= CurrentNode.G) && (neighbor.G >= CurrentNode.G || !ClosedSet.Contains(neighbor)))
                        {
                            if (!OpenSet.Contains(neighbor))
                            {
                                OpenSet.Add(neighbor);
                            }
                            if (neighbor.X == End.X && neighbor.Y == End.Y)
                            {
                                ClosedSet.Add(neighbor);
                                Finished = true;
                            }
                        }
                    }
                }


            }

            // Return failure if the open set is empty (break the while loop)
            return ClosedSet;
        }
 public static uint GetBlockFromOffset(long offset, Structs.PartitionInfo Partition)
 {
     return (uint)(((offset - Partition.DataOffset)) / Partition.ClusterSize);
 }
 /// <summary>
 ///     Maps the native ShareInfo2 Structure to a managed ShareInfo2 Class.
 /// </summary>
 /// <param name="shareInfo">The native source ShareInfo2.</param>
 /// <returns>A managed ShareInfo2 Object.</returns>
 internal static ShareInfo2 MapToSessionInfo502(Structs.ShareInfo2 shareInfo)
 {
     return new ShareInfo2
     {
         CurrentUsers = shareInfo.CurrentUsers,
         MaxUsers = shareInfo.MaxUsers,
         NetName = shareInfo.NetName,
         Password = shareInfo.Password,
         Path = shareInfo.Path,
         Permissions = (Enum.SharePermissions) shareInfo.Permissions,
         Remark = shareInfo.Remark,
         ShareType = (Enum.ShareType) shareInfo.ShareType
     };
 }
Exemple #45
0
        private void ProcessSnapshot(short snap)
        {
            DebugOut.PrintLine("PROCESSING SNAPSHOT " + snap);
            // using this only if needed
            HsmlReader hsmlReader = new HsmlReader();

            // and make the directory, just to be safe
            try
            {
                Directory.CreateDirectory(GetSnapDir(outPath,snap));
            }
            catch (IOException e)
            {
                System.Console.WriteLine(e.Message);
            }

            int curFile = 0; // index of current read/write file
            int numFiles = 1; // total number of files
            if (snapshotFile >= 0)
            {
                curFile = snapshotFile;
                numFiles = snapshotFile+1;
            }
            if (useHsml)
                hsmlReader = new HsmlReader(GetHsmlPath(inPath, snap));

            while (curFile < numFiles)
            {
                DebugOut.PrintLine("..file " + curFile + "/" + numFiles);

                string filename = "";
                try
                {
                    filename = GetSnapFile(inPath, snap, curFile);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    return;
                }
                // now load the file
                SnapFile curSnap = new SnapFile(filename, samplingRate);
                // and open the stream for writing
                using (SqlBinaryWriter binwriter = new SqlBinaryWriter(new FileStream(GetSnapDefault(outPath, snap, snapshotFilePrefix, curFile), FileMode.Create)))
                {
                    Structs[] parts = new Structs[curSnap.numSample];
                    // now write each particle into the array
                    for (int i = 0; i < curSnap.numSample; i++)
                    {
                        parts[i].x = curSnap.pos[i, 0];
                        parts[i].y = curSnap.pos[i, 1];
                        parts[i].z = curSnap.pos[i, 2];
                        parts[i].vx = curSnap.vel[i, 0];
                        parts[i].vy = curSnap.vel[i, 1];
                        parts[i].vz = curSnap.vel[i, 2];
                        parts[i].snapnum = snap;
                        parts[i].id = curSnap.id[i];
                        // add in highest-order bit
                        parts[i].id |= ((UInt64)curSnap.nLargeSims[1]) << 32;
                        // make ph-key
                        parts[i].phkey = GetPHKey(parts[i].x, parts[i].y, parts[i].z);
                        // read hsml, if desired
                        if (useHsml) // TODO fix this part for random sampling
                        {
                            parts[i].hsml = hsmlReader.GetHsml();
                            parts[i].veldisp = hsmlReader.GetVelDisp();
                            parts[i].density = hsmlReader.GetDensity();
                            // and advance read pointer
                            hsmlReader.Next();
                        }
                    }
                    // now sort before writing files
                    Array.Sort<Structs>(parts, new ParticleComparator());
                    // and then write output
                    /*
                    if (useHsml)
                        for (int i = 0; i < curSnap.numSample; i++)
                            parts[i].WriteBinary(binwriter);
                    else
                        for (int i = 0; i < curSnap.numSample; i++)
                            parts[i].WriteBinaryNoHsml(binwriter);
                    */

                    for (int i = 0; i < curSnap.numSample; i++)
                        binwriter.Write(parts[i]);

                    // and add a bulk insert
                    DebugOut.AddCommand(GetSnapDefault(outPath, snap, snapshotFilePrefix,curFile), snapshotTable);

                    DebugOut.PrintLine("..wrote " + curSnap.numSample + "/" + curSnap.numTotals[1] + " points");
                }

                // and set numFiles
                numFiles = (int)curSnap.numSubfiles;

                curFile++;
                // avoid outofmemory errors
                GC.Collect();
                GC.WaitForPendingFinalizers();

            }
        }
        public static Structs.PatternList FindPatternList(Structs.PatternList patternList)
        {
            Structs.PatternList newPatternList = new Structs.PatternList();
            newPatternList.processName = patternList.processName;
            uint baseModule = 0;

            BlackMagic memread = new BlackMagic();
            if (memread.OpenProcessAndThread(SProcess.GetProcessFromProcessName(patternList.processName)))
            {
                try
                {
                    // Dump module
                    ProcessModuleCollection modules = Process.GetProcessById(memread.ProcessId).Modules;
                    foreach (ProcessModule o in modules)
                    {
                        Structs.ModuleList m = new Structs.ModuleList();
                        m.Name = o.ModuleName;
                        m.baseAddressDec = (int)o.BaseAddress;
                        m.baseAddressHex = (o.BaseAddress).ToString("X");
                        patternList.Modules.Add(m);

                        // Check module base if exist.
                        if (patternList.baseModuleName != "")
                            if (patternList.baseModuleName.ToLower() == o.ModuleName.ToLower())
                                baseModule = (uint)o.BaseAddress;
                    }
                }
                catch { }

                foreach (Structs.Pattern p in patternList.Patterns)
                {
                    try
                    {
                        uint dwCodeLoc = memread.FindPattern(p.pattern, p.mask);
                        uint offset = memread.ReadUInt((uint)((int)dwCodeLoc + p.offsetLocation));
                        if (offset > 0)
                        {
                            offset = offset - baseModule;
                            dwCodeLoc = dwCodeLoc - baseModule;
                        }

                        if (offset > 0)
                        {
                            // Dump offset
                            p.offset = offset.ToString("X");
                            p.offsetDec = offset;
                            p.offsetUsedAtDec = (uint)((int)dwCodeLoc + p.offsetLocation);
                            p.offsetUsedAt = ((int)dwCodeLoc + p.offsetLocation).ToString("X");
                            try
                            {
                                switch (p.type)
                                {
                                    case "int64":
                                        p.value = Convert.ToString(memread.ReadUInt64(p.offsetDec));
                                        break;
                                    case "int":
                                        p.value = Convert.ToString(memread.ReadInt(p.offsetDec));
                                        break;
                                    case "float":
                                        p.value = Convert.ToString(memread.ReadFloat(p.offsetDec));
                                        break;
                                    case "string":
                                        p.value = Convert.ToString(memread.ReadASCIIString(p.offsetDec, 30));
                                        break;
                                }
                            }
                            catch { p.value = "No Found"; }
                        }
                        else
                            p.offset = "No Found";

                    }
                    catch
                    { p.offset = "No Found"; }
                    newPatternList.Patterns.Add(p);
                }
                memread.Close();
            }
            else
            {
                MessageBox.Show("Process no found.");
            }
            return patternList;
        }
Exemple #47
0
        public static Entry CreateFromHeader(Structs.RPF7EntryInfoTemplate info, RPF7File file, MemoryStream entriesInfo, MemoryStream filenames)
        {
            bool isResource = info.Field1 == 1;
            long offset = (long)info.Field2;
            int compressedSize = (int)info.Field3;
            int filenameOffset = (int)info.Field4;

            filenames.Seek(filenameOffset << file.Info.ShiftNameAccessBy, SeekOrigin.Begin);
            String filename = "";
            // Read null-terminated filename
            int currentChar;
            while ((currentChar = filenames.ReadByte()) != 0)
            {
                if (currentChar == -1)
                {
                    throw new Exception("Unexpected EOF");
                }
                filename += (char)currentChar;
            }

            if (offset == 0x7FFFFF)
            {
                // Is a Directory
                if (isResource)
                {
                    throw new Exception("Invalid type");
                }
                int subentriesStartIndex = (int)info.Field5;
                int subentriesCount = (int)info.Field6;
                List<Entry> entries = new List<Entry>();
                for (int i = 0; i < subentriesCount; ++i)
                {
                    entriesInfo.Seek(0x10 * (i + subentriesStartIndex), SeekOrigin.Begin);
                    entries.Add(Entry.CreateFromHeader(new Structs.RPF7EntryInfoTemplate(entriesInfo), file, entriesInfo, filenames));
                }
                return new DirectoryEntry(filename, entries);
            }

            offset <<= 9;

            if (isResource)
            {
                if (compressedSize == 0xFFFFFF)
                {
                    throw new Exception("Resource with size -1, not supported");
                }
                uint systemFlag = info.Field5;
                uint graphicsFlag = info.Field6;
                return new ResourceEntry(filename, new ResourceStreamCreator(file, offset, compressedSize, systemFlag, graphicsFlag), systemFlag, graphicsFlag);
            }

            // Regular file
            int uncompressedSize = (int)info.Field5;
            int isEncrypted = (int)info.Field6;

            if (compressedSize == 0)
            {
                // Uncompressed file
                if (isEncrypted != 0)
                {
                    throw new Exception("Unexcepted value");
                }
                return new RegularFileEntry(filename, new FileStreamCreator(file, offset, uncompressedSize), false);
            }
            else
            {
                // Compressed file
                return new RegularFileEntry(filename, new CompressedFileStreamCreator(file, offset, compressedSize, uncompressedSize, isEncrypted != 0), true);
            }
        }
Exemple #48
0
 private Skill ConvertToSkill(Structs.TERASkill skill)
 {
     return new Skill { SkillId = skill.Id, Name = skill.Name, CastTimeSeconds = 0, DoubleAction = false, MaxRange = 0, MinRange = 0 };
 }
 public static extern bool ScreenToClient(IntPtr hWnd, ref Structs.POINT lpPoint);
 public DateTime PartitionTimeStamp(Structs.PartitionInfo PI)
 {
     return VariousFunctions.DateTimeFromFATInt((ushort)((PI.ID & ~0xFFFF) >> 8), (ushort)PI.ID);
 }
 /// <summary>
 /// Converts cluster (block) number to offset
 /// </summary>
 public static long GetBlockOffset(uint block, Structs.PartitionInfo Partition)
 {
     if (block > Partition.Clusters)
     {
         // throw new Exception("Cluster ref of range");
     }
     //The way that FATX works is that the root block is considered block 0,
     //so let's think about this like an array...  if the block is reading block
     //2, then it's really block 1 in an array
     block--;
     long rVal = (Partition.DataOffset + ((long)block * Partition.ClusterSize));
     return rVal;
 }
 internal static extern uint NetShareAdd(
     [MarshalAs(UnmanagedType.LPWStr)] string strServer,
     Int32 dwLevel,
     ref Structs.ShareInfo502 buf,
     out uint parm_err
     );
 /// <summary>
 ///     Maps the native SessionInfo2 Structure to a managed SessionInfo2 Class.
 /// </summary>
 /// <param name="sessionInfo">The native source SessionInfo2.</param>
 /// <returns>A managed SessionInfo2 Object.</returns>
 internal static SessionInfo2 MapToSessionInfo2(Structs.SessionInfo2 sessionInfo)
 {
     return new SessionInfo2
     {
         ClientType = sessionInfo.sesi2_cltype_name,
         ComputerName = sessionInfo.sesi2_cname,
         NumberOfOpens = sessionInfo.sesi2_num_opens,
         SecondsActive = sessionInfo.sesi2_time,
         SecondsIdle = sessionInfo.sesi2_idle_time,
         UserFlags = (Enum.SessionUserFlags) sessionInfo.sesi2_user_flags,
         UserName = sessionInfo.sesi2_username
     };
 }
 public static extern bool ClientToScreen(IntPtr hWnd, ref Structs.POINT lpPoint);
 internal virtual void OnEntryEvent(ref Structs.EntryEventArgs e)
 {
     if (EntryWatcher != null)
     {
         EntryWatcher(ref e);
     }
 }
 public static extern bool GetClassInfoEx(IntPtr hInstance, String lpClassName,
                                          ref Structs.WNDCLASSEX lpWndClass);
 public static extern Boolean AdjustWindowRect(ref Structs.RECT lpRect, uint dwStyle, bool bMenu);
 internal static extern int SHFileOperation(ref Structs.SHFILEOPSTRUCT FileOp);
 public static extern bool AdjustWindowRectEx(ref Structs.RECT lpRect, uint dwStyle, bool bMenu,
                                              uint dwExStyle);
 /// <summary>
 ///     Maps the native Statworkstation0 Structure to a managed Statworkstation0 Class.
 /// </summary>
 /// <param name="statworkstation0">The native source Statworkstation0.</param>
 /// <returns>A managed Statworkstation0 Object.</returns>
 internal static Statworkstation0 MapToStatworkstation0(Structs.StatWorkstation0 statworkstation0)
 {
     return new Statworkstation0
     {
         BytesReceived = statworkstation0.BytesReceived,
         BytesTransmitted = statworkstation0.BytesTransmitted,
         CacheReadBytesRequested = statworkstation0.CacheReadBytesRequested,
         CacheWriteBytesRequested = statworkstation0.CacheWriteBytesRequested,
         CoreConnects = statworkstation0.CoreConnects,
         CurrentCommands = statworkstation0.CurrentCommands,
         FailedCompletionOperations = statworkstation0.FailedCompletionOperations,
         FailedSessions = statworkstation0.FailedSessions,
         FailedUseCount = statworkstation0.FailedUseCount,
         HungSessions = statworkstation0.HungSessions,
         InitiallyFailedOperations = statworkstation0.InitiallyFailedOperations,
         Lanman20Connects = statworkstation0.Lanman20Connects,
         Lanman21Connects = statworkstation0.Lanman21Connects,
         LanmanNtConnects = statworkstation0.LanmanNtConnects,
         LargeReadSmbs = statworkstation0.LargeReadSmbs,
         LargeWriteSmbs = statworkstation0.LargeWriteSmbs,
         NetworkErrors = statworkstation0.NetworkErrors,
         NetworkReadBytesRequested = statworkstation0.NetworkReadBytesRequested,
         NetworkWriteBytesRequested = statworkstation0.NetworkWriteBytesRequested,
         NonPagingReadBytesRequested = statworkstation0.NonPagingReadBytesRequested,
         NonPagingWriteBytesRequested = statworkstation0.NonPagingWriteBytesRequested,
         PagingReadBytesRequested = statworkstation0.PagingReadBytesRequested,
         PagingWriteBytesRequested = statworkstation0.PagingWriteBytesRequested,
         RandomReadOperations = statworkstation0.RandomReadOperations,
         RawReadsDenied = statworkstation0.RawReadsDenied,
         RandomWriteOperations = statworkstation0.RandomWriteOperations,
         RawWritesDenied = statworkstation0.RawWritesDenied,
         ReadOperations = statworkstation0.ReadOperations,
         ReadSmbs = statworkstation0.ReadSmbs,
         Reconnects = statworkstation0.Reconnects,
         ServerDisconnects = statworkstation0.ServerDisconnects,
         Sessions = statworkstation0.Sessions,
         SmallReadSmbs = statworkstation0.SmallReadSmbs,
         SmallWriteSmbs = statworkstation0.SmallWriteSmbs,
         SmbsReceived = statworkstation0.SmbsReceived,
         SmbsTransmitted = statworkstation0.SmbsTransmitted,
         StatisticsStartTime = statworkstation0.StatisticsStartTime,
         UseCount = statworkstation0.UseCount,
         WriteOperations = statworkstation0.WriteOperations,
         WriteSmbs = statworkstation0.WriteSmbs
     };
 }