public INativeStructureFieldInfo[] GetRefs(ObjPtr obj) { var ptr = stackalloc IntPtr[1]; _typeIdFieldInfo.GetValue(this.ObjToBlock(obj), new IntPtr(ptr)); return(this.GetLayoutInfo(ptr[0]).Fields.Where(f => f.IsReference).ToArray()); }
public TElWind(NativeData nativeData) { // TElWind object pointer InstancePtr = new IntPtr(nativeData.Pointers[NativePointer.ElWdw_InstancePtr]); // Object pointers ElementIdPtr = new ObjPtr(InstancePtr, nativeData.Pointers[NativePointer.ElWdw_ElementIdPtr]); ObjectsPtr = new ObjPtr(InstancePtr, nativeData.Pointers[NativePointer.ElWdw_ObjectsPtr]); ComponentsDataPtr = new ObjPtr(InstancePtr, nativeData.Pointers[NativePointer.ElWdw_ComponentsDataPtr]); RecentGradePtr = new ObjPtr(InstancePtr, nativeData.Pointers[NativePointer.ElWdw_RecentGradePtr]); FocusedComponentPtr = new ObjPtr(InstancePtr, nativeData.Pointers[NativePointer.ElWdw_FocusedComponentPtr]); LearningModePtr = new ObjPtr(InstancePtr, nativeData.Pointers[NativePointer.ElWdw_LearningModePtr]); // Memory patterns EnterUpdateLockCallSig = nativeData.GetMemoryPattern(NativeMethod.ElWdw_EnterUpdateLock); QuitUpdateLockCallSig = nativeData.GetMemoryPattern(NativeMethod.ElWdw_QuitUpdateLock); // Procedures EnterUpdateLock = new Procedure <Action <IntPtr, bool, DelphiUTF16String> >( "EnterUpdateLock", CallingConventions.Register, EnterUpdateLockCallSig ); QuitUpdateLock = new Procedure <Action <IntPtr, bool> >( "QuitUpdateLock", CallingConventions.Register, QuitUpdateLockCallSig ); // Substructure Components = new TComponentData(ComponentsDataPtr, nativeData); }
public TApplication(NativeData nativeData) { OnMessageOffset = nativeData.Pointers[NativePointers.Application_OnMessageOffset]; TApplicationInstanceAddr = new IntPtr(nativeData.Pointers[NativePointers.Application_InstancePtr]); TApplicationOnMessagePtr = new ObjPtr(TApplicationInstanceAddr, OnMessageOffset); }
public static T Read <T>(this IMemory memory, ObjPtr objPtr, int offset = 0) { int instanceAddr = objPtr.ReadInstanceAddress(memory); return(memory.Read <T>(new IntPtr(instanceAddr + objPtr.Offset + offset))); }
public TComponentData(ObjPtr componentsDataPtr, NativeData nativeData) { ComponentDataArrOffset = nativeData.Pointers[NativePointers.ElWdw_ComponentData_ComponentDataArrOffset]; ComponentDataArrItemLength = nativeData.Pointers[NativePointers.ElWdw_ComponentData_ComponentDataArrItemLength]; ComponentCountPtr = new ObjPtr(componentsDataPtr, nativeData.Pointers[NativePointers.ElWdw_ComponentData_ComponentCountPtr]); IsModifiedPtr = new ObjPtr(componentsDataPtr, nativeData.Pointers[NativePointers.ElWdw_ComponentData_IsModifiedPtr]); }
public static void Write <T>(this IMemory memory, ObjPtr objPtr, T value, int offset = 0) { int instanceAddr = objPtr.ReadInstanceAddress(memory); memory.Write <T>(new IntPtr(instanceAddr + objPtr.Offset + offset), value); }
private unsafe ObjPtr AllocImpl(IntPtr typeId) { var layoutInfo = this.GetLayoutInfo(typeId); var blockPtr = _memoryManager.Alloc(layoutInfo.AlignedSize); var objPtr = new ObjPtr(blockPtr.value + _typeIdFieldInfo.Offset); WinApi.RtlZeroMemory(objPtr.value, new IntPtr(layoutInfo.AlignedSize - _typeIdFieldInfo.Offset)); _typeIdFieldInfo.SetValue(blockPtr, new IntPtr(&typeId)); return(objPtr); }
public void ObjPtr_Deref_ReferenceEquals() { // Arrange object pointedValue = new OtherClass("tmp"); var ptr = new ObjPtr <object>(() => pointedValue, (v) => pointedValue = v); // Act var val = ptr.Deref; // Assert; Assert.Same(pointedValue, val); }
public void ObjPtr_Deref_Value() { // Arrange object pointedValue = new OtherClass("tmp"); var ptr = new ObjPtr <object>(() => pointedValue, (v) => pointedValue = v); // Act ptr.Deref = new DummyClass { x = 10L }; // Assert; Assert.Equal(10L, (pointedValue as DummyClass).x); }
public TFileSpace(TDatabase db, NativeData nativeData) { InstancePtr = new ObjPtr(db.InstancePtr, nativeData.Pointers[NativePointer.Registry_FileSpaceInstance]); EmptySlotsPtr = new ObjPtr(InstancePtr, nativeData.Pointers[NativePointer.FileSpace_EmptySlotsOffset]); AllocatedSlotsPtr = new ObjPtr(InstancePtr, nativeData.Pointers[NativePointer.FileSpace_AllocatedSlotsOffset]); GetTopSlotCallSig = nativeData.GetMemoryPattern(NativeMethod.FileSpace_GetTopSlot); IsSlotOccupiedCallSig = nativeData.GetMemoryPattern(NativeMethod.FileSpace_IsSlotOccupied); GetTopSlot = new Procedure <Func <IntPtr, bool, int> >( "GetTopSlot", CallingConventions.Register, GetTopSlotCallSig ); IsSlotOccupied = new Procedure <Func <IntPtr, int, bool> >( "IsSlotOccupied", CallingConventions.Register, IsSlotOccupiedCallSig ); }
public TRegistry(TDatabase db, NativeData nativeData) { TextRegistryInstance = new ObjPtr(db.InstancePtr, nativeData.Pointers[NativePointers.Registry_TextRegistryInstance]); ImageRegistryInstance = new ObjPtr(db.InstancePtr, nativeData.Pointers[NativePointers.Registry_ImageRegistryInstance]); SoundRegistryInstance = new ObjPtr(db.InstancePtr, nativeData.Pointers[NativePointers.Registry_SoundRegistryInstance]); VideoRegistryInstance = new ObjPtr(db.InstancePtr, nativeData.Pointers[NativePointers.Registry_VideoRegistryInstance]); BinaryRegistryInstance = new ObjPtr(db.InstancePtr, nativeData.Pointers[NativePointers.Registry_BinaryRegistryInstance]); TemplateRegistryInstance = new ObjPtr(db.InstancePtr, nativeData.Pointers[NativePointers.Registry_TemplateRegistryInstance]); ConceptRegistryInstance = new ObjPtr(db.InstancePtr, nativeData.Pointers[NativePointers.Registry_ConceptRegistryInstance]); AddMemberCallSig = nativeData.GetMemoryPattern(NativeMethod.TRegistry_AddMember); ImportFileCallSig = nativeData.GetMemoryPattern(NativeMethod.TRegistry_ImportFile); AddMember = new Procedure <Func <IntPtr, DelphiUTF16String, int> >( "AddMember", CallingConventions.Register, AddMemberCallSig ); ImportFile = new Procedure <Func <IntPtr, DelphiUTF16String, DelphiUTF16String, int> >( "ImportFile", CallingConventions.Register, ImportFileCallSig ); }
public BlockPtr ObjToBlock(ObjPtr ptr) { return(new BlockPtr(ptr.value - _typeIdFieldInfo.Offset)); }