[Fact] public unsafe void Extractor_StructModel_Test() { StructModel[] structure = new StructModel[] { new StructModel(83948930), new StructModel(45453), new StructModel(5435332) }; structure[0].Alias = "FirstAlias"; structure[0].Name = "FirstName"; structure[1].Alias = "SecondAlia"; structure[1].Name = "SecondName"; structure[2].Alias = "ThirdAlias"; structure[2].Name = "ThirdName"; StructModels structures = new StructModels(structure); int size = Marshal.SizeOf(structure[0]); byte *pserial = ExtractOperation.ValueStructureToPointer(structure[0]); StructModel structure2 = new StructModel(); ValueType o = structure2; ExtractOperation.PointerToValueStructure(pserial, o, 0); structure2 = (StructModel)o; structure2.Alias = "FirstChange"; }
public unsafe static object PointerToStructure(IntPtr binary, object structure) { if (structure is ValueType) { Type t = structure.GetType(); if (t.IsPrimitive || t.IsLayoutSequential) { structure = ExtractOperation.PointerToValueStructure((byte *)binary, structure, 0); } else { structure = PointerToStructure(binary, structure.GetType(), 0); } } else { Marshal.PtrToStructure(binary, structure); } return(structure); }
public unsafe static ValueType PointerToStructure(IntPtr binary, ValueType structure) { return(ExtractOperation.PointerToValueStructure((byte *)binary, structure, 0)); }