/// <summary> /// IOCTL_ATA_PASS_THROUGH IOCTL ( https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_ata_pass_through ) /// </summary> /// <param name="IoControl"></param> /// <param name="Header"></param> /// <param name="Data"></param> /// <returns></returns> public static bool AtaPassThroughSmartData(this IoControl IoControl, out IAtaPassThroughEx <SmartData> value, out uint ReturnBytes) { if (IntPtr.Size == 4) { var request = new AtaPassThroughEx32WithSmartData( AtaFlags: AtaFlags.DataIn | AtaFlags.NoMultiple, TimeOutValue: 3, Feature: 0xd0, Cylinder: 0xc24f, Command: 0xb0 ); System.Diagnostics.Debug.Assert(request.DataTransferLength == 512, "データが不正"); var ptr = new StructPtr <AtaPassThroughEx32WithSmartData>(request); var result = IoControl.AtaPassThrough(ptr, out ReturnBytes); value = ptr.Get(); return(result); } else if (IntPtr.Size == 8) { var request = new AtaPassThroughExWithSmartData( AtaFlags: AtaFlags.DataIn | AtaFlags.NoMultiple, TimeOutValue: 3, Feature: 0xd0, Cylinder: 0xc24f, Command: 0xb0 ); System.Diagnostics.Debug.Assert(request.DataTransferLength == 512, "データが不正"); var ptr = new StructPtr <AtaPassThroughExWithSmartData>(request); var result = IoControl.AtaPassThrough(ptr, out ReturnBytes); value = ptr.Get(); return(result); } throw new NotSupportedException(); }
internal static void TextOverlay(Text2D textStruct) { using (StructPtr textPtr = new StructPtr(textStruct)) { TextFunctions.DrawText.Call(0x5004D4, textPtr); } }
/// <summary> /// IOCTL_ATA_PASS_THROUGH IOCTL ( https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_ata_pass_through ) /// </summary> /// <param name="IoControl"></param> /// <param name="Header"></param> /// <param name="Data"></param> /// <returns></returns> public static bool AtaPassThroughIdentifyDevice(this IoControl IoControl, out IAtaPassThroughEx <IdentifyDevice> value, out uint ReturnBytes) { if (IntPtr.Size == 4) { var ptr = new StructPtr <AtaPassThroughEx32WithIdentifyDevice>(new AtaPassThroughEx32WithIdentifyDevice( AtaFlags: AtaFlags.DataIn | AtaFlags.NoMultiple, TimeOutValue: 3, Feature: 0, Cylinder: 0, Command: 0xEC )); var result = IoControl.AtaPassThrough(ptr, out ReturnBytes); value = ptr.Get(); return(result); } else if (IntPtr.Size == 8) { var ptr = new StructPtr <AtaPassThroughExWithIdentifyDevice>(new AtaPassThroughExWithIdentifyDevice( AtaFlags: AtaFlags.DataIn | AtaFlags.NoMultiple, TimeOutValue: 3, Feature: 0, Cylinder: 0, Command: 0xEC )); var result = IoControl.AtaPassThrough(ptr, out ReturnBytes); value = ptr.Get(); return(result); } throw new NotSupportedException(); }
public void SetPtrTest(StructPtr <TestData> StructPtr, TestData data) { using (StructPtr.CreatePtr(out var Ptr, out var Size)) { StructPtr.SetPtr(Ptr, Size); Assert.AreEqual(data, StructPtr.Get()); } }
public override void EmitPreRemoteCallStatements(CodeBuilder b, string var) { b.BeginIf("{0} != null", var); b.AppendLine("call.{0} = new IntPtr[{0}.Length];", var); b.BeginBlock("for(int i = 0; i < {0}.Length; ++i)", var); b.AppendLine("call.{0}[i] = {1};", var, StructPtr.RemoteUnwrapExpression(var + "[i]")); b.EndBlock(); b.EndBlock(); }
public void GetPtrTest(StructPtr <TestData> StructPtr, TestData data) { var Size = (uint)Marshal.SizeOf <TestData>(); using (StructPtr.CreatePtr(out var Ptr, out var _Size)) { Assert.AreEqual(Size, _Size); Assert.AreEqual(data, (TestData)Marshal.PtrToStructure(Ptr, typeof(TestData))); } }
public override void EmitRemotePreCallStatements(CodeBuilder b, string var) { b.BeginIf("{0} != null", var); b.AppendLine("call.{0} = new IntPtr[{0}.Length];", var); b.BeginBlock("for(int i = 0; i < {0}.Length; ++i)", var); b.AppendLine("if(!CheckConnection({0}[i], connection)) throw new ArgumentException(\"Render process connection mismatch.\", \"{1}[\" + i + \"]\");", CSharp.Escape(var), var); b.AppendLine("call.{0}[i] = {1};", var, StructPtr.RemoteUnwrapExpression(var + "[i]")); b.EndBlock(); b.EndBlock(); }
public override void EmitPreProxyCallStatements(CodeBuilder b, string var) { b.AppendLine("{0}[] {1}_unwrapped;", Struct.ClassName, var); b.BeginIf("{0} != null", var); b.AppendLine("{0}_unwrapped = new {1}[{0}.Length];", var, Struct.ClassName); b.BeginBlock("for(int i = 0; i < {0}.Length; ++i)", var); b.AppendLine("{0}_unwrapped[i] = {1};", var, StructPtr.ProxyUnwrapExpression(var + "[i]")); b.EndBlock(); b.BeginElse(); b.AppendLine("{0}_unwrapped = null;", var); b.EndBlock(); }
public static bool AtaPassThroughCheckPowerMode(this IoControl IoControl, out IAtaPassThroughEx value, out uint ReturnBytes) { var AtaFlags = Controller.AtaFlags.DataIn | Controller.AtaFlags.NoMultiple; if (IntPtr.Size == 4) { var _value = new AtaPassThroughEx32WithMiniBuffer( AtaFlags: AtaFlags, TimeOutValue: 20, TaskFile: new TaskFile( AtaFlags: AtaFlags, Feature: 0, Cylinder: 0, DeviceHead: 0, Command: 0xE5 ) ); var ptr = new StructPtr <AtaPassThroughEx32WithMiniBuffer>(_value); var result = IoControl.AtaPassThrough(ptr, out ReturnBytes); value = ptr.Get(); return(result); } else if (IntPtr.Size == 8) { var _value = new AtaPassThroughExWithMiniBuffer( AtaFlags: AtaFlags, TimeOutValue: 20, TaskFile: new TaskFile( AtaFlags: AtaFlags, Feature: 0, Cylinder: 0, DeviceHead: 0x0, Command: 0xE5 ) ); var ptr = new StructPtr <AtaPassThroughExWithMiniBuffer>(_value); var result = IoControl.AtaPassThrough(ptr, out ReturnBytes); value = ptr.Get(); return(result); } throw new NotSupportedException(); }
public void Run(RemoteInterface remoteInterface) { // All particles, HUD icons and other GFX objects should always be drawn in the main engine loop. GlobalActions.Engine += () => { // Create 2 vectors - upper-left and lower-right corner of the icon. // For HUD icons, the screen space is mapped to a 100x100 area. // Only X and Y coordinates are used to position the icon. // The Z coordinate of the 2nd vector is the alpha/transparency value. Vector3 vPos1 = new Vector3(5, 5, 0); Vector3 vPos2 = new Vector3(20, 20, 255); // StructPtr copies the vector structure to unmanaged memory and provides a pointer. // The memory is freed automatically at the end of the using block. using (StructPtr pos1 = new StructPtr(vPos1), pos2 = new StructPtr(vPos2)) { // Particle type 125 is the HUD icon type. // The last parameter "a6" varies between particle types - in this case it's an index. // A specific index value can only be used by one icon. If multiple icons are drawn // with the same index, only the last one will be displayed. GfxFunctions.VAddParticle.Call(125, pos1, pos2, TexturePointers.rayIcon, 11); } }; }
public override void EmitProxyEventArgSetter(CodeBuilder b, string var) { b.AppendLine("e.{0} = {1};", var, StructPtr.ProxyUnwrapExpression("value")); }
public override void EmitPostPublicCallStatements(CodeBuilder b, string var) { b.AppendLine("{0} = {1};", var, StructPtr.PublicWrapExpression(var + "_ptr")); }
public override string RemoteCallParameter(string var) { return("out " + StructPtr.RemoteCallParameter(var)); }
public override string PublicCallParameter(string var) { return("out " + StructPtr.PublicCallParameter(var)); }
public override void EmitPostRemoteRaiseEventStatements(CodeBuilder b, string var) { b.AppendLine("{0} = {1};", var, StructPtr.RemoteUnwrapExpression(string.Concat("e.m_", var, "_wrapped"))); }
public override string PublicEventConstructorArgument(string var) { return(StructPtr.PublicEventConstructorArgument(var) + ", " + CountArg.PublicEventConstructorArgument); }
public override string PublicEventConstructorParameter(string var) { return(StructPtr.PublicEventConstructorParameter(var) + ", " + CountArg.PublicEventConstructorParameter); }
public override string ProxyCallSignature(string var) { return("out " + StructPtr.ProxyCallSignature(var)); }
public override void EmitPostPublicRaiseEventStatements(CodeBuilder b, string var) { Debug.Assert(Struct.IsRefCounted); b.AppendLine("{0} = {1};", var, StructPtr.PublicUnwrapExpression(string.Concat("e.m_", var, "_wrapped"))); }