private void CopyToBuffer(Buffer *buffer, byte *data, int len) { //if ( buffer->Length + buffer->Start + len >= SHARED_BUFF_SIZE ) // throw new NullReferenceException( String.Format( "Buffer OVERFLOW in CopyToBuffer [{0} + {1}] <- {2}", buffer->Start, buffer->Length, len ) ); Platform.memcpy((&buffer->Buff0) + buffer->Start + buffer->Length, data, len); buffer->Length += len; }
/// <summary>To be documented.</summary> public readonly unsafe int SubmitSourceBuffer(Buffer *pBuffer, BufferWma *pBufferWMA) { var @this = (IXAudio2SourceVoice *)Unsafe.AsPointer(ref Unsafe.AsRef(in this)); int ret = default; ret = ((delegate * unmanaged[Cdecl] < IXAudio2SourceVoice *, Buffer *, BufferWma *, int >)LpVtbl[21])(@this, pBuffer, pBufferWMA); return(ret); }
private MemoryStream GetOpsList() { unsafe { Buffer *buffer = TF_GetAllOpList(); _apimap = new ApiDefMap(buffer); var ret = new byte[(int)buffer->length]; Marshal.Copy(buffer->data, ret, 0, (int)buffer->length); return(new MemoryStream(ret)); } }
public unsafe ApiDefMap(Buffer *buffer) { using (var status = new Status()) { _handle = TF_NewApiDefMap((IntPtr)buffer, status); if (status.Error) { throw new ArgumentException("Failure to call TF_NewApiDefMap"); } } }
public static UIntPtr StreamCompress(CCtx *ctx, Buffer *output, Buffer *input, EndDirective endOp) { IL.Push(ctx); IL.Push(output); IL.Push(input); IL.Push(endOp); IL.Push(ZSTD_compressStream2); IL.Emit.Tail(); IL.Emit.Calli(new StandAloneMethodSig(CallingConvention.Cdecl, typeof(UIntPtr), typeof(CCtx *), typeof(Buffer *), typeof(Buffer *), typeof(EndDirective))); return(IL.Return <UIntPtr>()); }
private void CopyToBuffer(Buffer *buffer, byte *data, int len) { //if ( buffer->Length + buffer->Start + len >= SHARED_BUFF_SIZE ) // throw new NullReferenceException( String.Format( "Buffer OVERFLOW in CopyToBuffer [{0} + {1}] <- {2}", buffer->Start, buffer->Length, len ) ); /* IntPtr to = (IntPtr)(&buffer->Buff0 + buffer->Start + buffer->Length); * IntPtr from = (IntPtr)data; * DLLImport.Win.memcpy(to, from, new UIntPtr((uint)len)); * buffer->Length += len;*/ DLLImport.Win.memcpy((&buffer->Buff0) + buffer->Start + buffer->Length, data, len); buffer->Length += len; }
public abstract unsafe void CmdBindTransformFeedbackBuffers([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint firstBinding, [Count(Count = 0)] uint bindingCount, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] Buffer *pBuffers, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ulong *pOffsets, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ulong *pSizes);
public unsafe partial void ExtGetBuffers([Count(Parameter = "maxBuffers"), Flow(FlowDirection.Out)] Buffer *buffers, [Flow(FlowDirection.In)] int maxBuffers, [Count(Count = 1), Flow(FlowDirection.Out)] out int numBuffers);
private unsafe void HandleComm(Buffer *inBuff, Buffer *outBuff, ConcurrentQueue <Packet> queue, PacketPath path) { CommMutex.WaitOne(); while (inBuff->Length > 0) { byte *buff = (&inBuff->Buff0) + inBuff->Start; int len = DLLImport.Razor.GetPacketLength(buff, inBuff->Length); if (len > inBuff->Length || len <= 0) { break; } inBuff->Start += len; inBuff->Length -= len; bool viewer = false; bool filter = false; switch (path) { case PacketPath.ClientToServer: viewer = PacketHandler.HasClientViewer(buff[0]); filter = PacketHandler.HasClientFilter(buff[0]); break; case PacketPath.ServerToClient: viewer = PacketHandler.HasServerViewer(buff[0]); filter = PacketHandler.HasServerFilter(buff[0]); break; } Packet p = null; PacketReader pr = null; if (viewer) { pr = new PacketReader(buff, len, DLLImport.Razor.IsDynLength(buff[0])); if (filter) { p = MakePacketFrom(pr); } } else if (filter) { byte[] temp = new byte[len]; fixed(byte *ptr = temp) DLLImport.Win.memcpy(ptr, buff, len); p = new Packet(temp, len, DLLImport.Razor.IsDynLength(buff[0])); /*byte[] temp = new byte[len]; * fixed (byte* ptr = temp) * { * IntPtr to = (IntPtr)ptr; * IntPtr from = (IntPtr)buff; * DLLImport.Win.memcpy(to, from, new UIntPtr((uint)len)); * } * p = new Packet(temp, len, DLLImport.Razor.IsDynLength(buff[0])); */ } bool blocked = false; switch (path) { // yes it should be this way case PacketPath.ClientToServer: { blocked = PacketHandler.OnClientPacket(buff[0], pr, p); break; } case PacketPath.ServerToClient: { blocked = PacketHandler.OnServerPacket(buff[0], pr, p); break; } } if (filter) { byte[] data = p.Compile(); if (data[0] == 0xc8 || data[0] == 0x73 || data[0] == 0xbf || data[0] == 0xdc) { } else { //int something = len; //Debug.WriteLine("Packet id 0x{0:X}", data[0]); } fixed(byte *ptr = data) { Packet.Log(path, ptr, data.Length, blocked); if (!blocked) { CopyToBuffer(outBuff, ptr, data.Length); } } } else { //Packet.Log(path, buff, len, blocked); if (!blocked) { CopyToBuffer(outBuff, buff, len); } } while (queue.Count > 0) { if (!queue.TryDequeue(out p)) { continue; } byte[] data = p.Compile(); fixed(byte *ptr = data) { CopyToBuffer(outBuff, ptr, data.Length); //Packet.Log((PacketPath)(((int)path) + 1), ptr, data.Length); } } } CommMutex.ReleaseMutex(); }
internal static bool InstallHooks( IntPtr mainWindow ) { InitError error; int flags = 0; if ( Config.GetBool( "Negotiate" ) ) flags |= 0x04; if ( ClientEncrypted ) flags |= 0x08; if ( ServerEncrypted ) flags |= 0x10; //ClientProc.WaitForInputIdle(); WaitForWindow( ClientProc.Id ); error = (InitError)InstallLibrary( mainWindow, ClientProc.Id, flags ); if ( error != InitError.SUCCESS ) { FatalInit( error ); return false; } byte *baseAddr = (byte*)GetSharedAddress().ToPointer(); // ZIPPY REV 80 /*m_OutFwd = (Buffer*)baseAddr; m_InRecv = (Buffer*)(baseAddr+sizeof(Buffer)*1); m_OutRecv = (Buffer*)(baseAddr+sizeof(Buffer)*2); m_InSend = (Buffer*)(baseAddr+sizeof(Buffer)*3); m_OutSend = (Buffer*)(baseAddr+sizeof(Buffer)*4); m_TitleStr = (byte*)(baseAddr+sizeof(Buffer)*5);*/ m_InRecv = (Buffer*)baseAddr; m_OutRecv = (Buffer*)(baseAddr+sizeof(Buffer)); m_InSend = (Buffer*)(baseAddr+sizeof(Buffer)*2); m_OutSend = (Buffer*)(baseAddr+sizeof(Buffer)*3); m_TitleStr = (byte*)(baseAddr+sizeof(Buffer)*4); SetServer( m_ServerIP, m_ServerPort ); CommMutex = new Mutex(); #pragma warning disable 618 CommMutex.Handle = GetCommMutex(); #pragma warning restore 618 // ZIPPY REV 80 FwdMutex = new Mutex( false, String.Format( "UONetFwd_{0:X}", ClientProc.Id ) ); // ZIPPY REV 80 m_FwdWnd = IntPtr.Zero; try { string path = Ultima.Files.GetFilePath("art.mul"); if ( path != null && path != string.Empty ) SetDataPath( Path.GetDirectoryName( path ) ); else SetDataPath(Path.GetDirectoryName(Ultima.Files.Directory)); } catch { SetDataPath( "" ); } if ( Config.GetBool( "OldStatBar" ) ) ClientCommunication.RequestStatbarPatch( true ); return true; }
public unsafe partial void CmdBeginTransformFeedback([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint firstCounterBuffer, [Count(Count = 0)] uint counterBufferCount, [Count(Computed = "counterBufferCount"), Flow(FlowDirection.In)] Buffer *pCounterBuffers, [Count(Computed = "counterBufferCount"), Flow(FlowDirection.In)] in ulong pCounterBufferOffsets);
/// <summary>To be documented.</summary> public static unsafe void CmdBindTransformFeedbackBuffers(this ExtTransformFeedback thisApi, [Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint firstBinding, [Count(Count = 0)] uint bindingCount, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] Buffer *pBuffers, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ReadOnlySpan <ulong> pOffsets, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ReadOnlySpan <ulong> pSizes) { // SpanOverloader thisApi.CmdBindTransformFeedbackBuffers(commandBuffer, firstBinding, bindingCount, pBuffers, in pOffsets.GetPinnableReference(), in pSizes.GetPinnableReference()); }
internal static extern int socklynx_socket_recv(Socket *sock, Buffer *buf, int bufcount, Endpoint *endpoint);
public static unsafe void BindBuffersRange(this ArbMultiBind thisApi, [Flow(FlowDirection.In)] ARB target, [Flow(FlowDirection.In)] uint first, [Flow(FlowDirection.In)] uint count, [Count(Parameter = "count"), Flow(FlowDirection.In)] Buffer *buffers, [Count(Parameter = "count"), Flow(FlowDirection.In)] ReadOnlySpan <nint> offsets, [Count(Parameter = "count"), Flow(FlowDirection.In)] ReadOnlySpan <nuint> sizes) { // SpanOverloader thisApi.BindBuffersRange(target, first, count, buffers, in offsets.GetPinnableReference(), in sizes.GetPinnableReference()); }
public static unsafe void BindVertexBuffers(this ArbMultiBind thisApi, [Flow(FlowDirection.In)] uint first, [Flow(FlowDirection.In)] uint count, [Count(Parameter = "count"), Flow(FlowDirection.In)] Buffer *buffers, [Count(Parameter = "count"), Flow(FlowDirection.In)] ReadOnlySpan <nint> offsets, [Count(Parameter = "count"), Flow(FlowDirection.In)] uint *strides) { // SpanOverloader thisApi.BindVertexBuffers(first, count, buffers, in offsets.GetPinnableReference(), strides); }
public abstract unsafe void CmdEndTransformFeedback([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint firstCounterBuffer, [Count(Count = 0)] uint counterBufferCount, [Count(Computed = "counterBufferCount"), Flow(FlowDirection.In)] Buffer *pCounterBuffers, [Count(Computed = "counterBufferCount"), Flow(FlowDirection.In)] ulong *pCounterBufferOffsets);
public unsafe partial void CmdBindVertexBuffers2([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint firstBinding, [Count(Count = 0)] uint bindingCount, [Count(Parameter = "bindingCount"), Flow(FlowDirection.In)] Buffer *pBuffers, [Count(Parameter = "bindingCount"), Flow(FlowDirection.In)] ulong *pOffsets, [Count(Parameter = "bindingCount"), Flow(FlowDirection.In)] ulong *pSizes, [Count(Parameter = "bindingCount"), Flow(FlowDirection.In)] in ulong pStrides);
/// <summary>To be documented.</summary> public static unsafe void CmdBindVertexBuffers2(this ExtExtendedDynamicState thisApi, [Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint firstBinding, [Count(Count = 0)] uint bindingCount, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] Buffer *pBuffers, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ReadOnlySpan <ulong> pOffsets, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ReadOnlySpan <ulong> pSizes, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ReadOnlySpan <ulong> pStrides) { // SpanOverloader thisApi.CmdBindVertexBuffers2(commandBuffer, firstBinding, bindingCount, pBuffers, in pOffsets.GetPinnableReference(), in pSizes.GetPinnableReference(), in pStrides.GetPinnableReference()); }
/// <summary>To be documented.</summary> public static unsafe void CmdEndTransformFeedback(this ExtTransformFeedback thisApi, [Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint firstCounterBuffer, [Count(Count = 0)] uint counterBufferCount, [Count(Computed = "counterBufferCount"), Flow(FlowDirection.In)] Buffer *pCounterBuffers, [Count(Computed = "counterBufferCount"), Flow(FlowDirection.In)] ReadOnlySpan <ulong> pCounterBufferOffsets) { // SpanOverloader thisApi.CmdEndTransformFeedback(commandBuffer, firstCounterBuffer, counterBufferCount, pCounterBuffers, in pCounterBufferOffsets.GetPinnableReference()); }
public static unsafe void ExtGetBuffers(this QComExtendedGet thisApi, [Count(Parameter = "maxBuffers"), Flow(FlowDirection.Out)] Buffer *buffers, [Flow(FlowDirection.In)] int maxBuffers, [Count(Count = 1), Flow(FlowDirection.Out)] Span <int> numBuffers) { // SpanOverloader thisApi.ExtGetBuffers(buffers, maxBuffers, out numBuffers.GetPinnableReference()); }
//private DateTime m_LastActivate; public override bool OnMessage(MainForm razor, uint wParam, int lParam) { bool retVal = true; switch ((UONetMessage)(wParam & 0xFFFF)) { case UONetMessage.Ready: //Patch status if (lParam == (int)InitError.NO_MEMCOPY) { if (MessageBox.Show(Engine.ActiveWindow, Language.GetString(LocString.NoMemCpy), "No Client MemCopy", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { m_Ready = false; ClientProc = null; Engine.MainWindow.CanClose = true; Engine.MainWindow.Close(); break; } } byte *baseAddr = (byte *)GetSharedAddress().ToPointer(); m_InRecv = (Buffer *)baseAddr; m_OutRecv = (Buffer *)(baseAddr + sizeof(Buffer)); m_InSend = (Buffer *)(baseAddr + sizeof(Buffer) * 2); m_OutSend = (Buffer *)(baseAddr + sizeof(Buffer) * 3); m_TitleStr = (byte *)(baseAddr + sizeof(Buffer) * 4); SetServer(m_ServerIP, m_ServerPort); CommMutex = new Mutex(); #pragma warning disable 618 CommMutex.Handle = GetCommMutex(); #pragma warning restore 618 try { string path = Ultima.Files.GetFilePath("art.mul"); if (path != null && path != string.Empty) { SetDataPath(Path.GetDirectoryName(path)); } else { SetDataPath(Path.GetDirectoryName(Ultima.Files.Directory)); } } catch { SetDataPath(""); } if (Config.GetBool("OldStatBar")) { RequestStatbarPatch(true); } m_Ready = true; Engine.MainWindow.MainForm_EndLoad(); break; case UONetMessage.NotReady: m_Ready = false; FatalInit((InitError)lParam); ClientProc = null; Engine.MainWindow.CanClose = true; Engine.MainWindow.Close(); break; // Network events case UONetMessage.Recv: OnRecv(); break; case UONetMessage.Send: OnSend(); break; case UONetMessage.Connect: m_ConnStart = DateTime.UtcNow; try { m_LastConnection = new IPAddress((uint)lParam); } catch { } break; case UONetMessage.Disconnect: OnLogout(false); break; case UONetMessage.Close: OnLogout(true); ClientProc = null; Engine.MainWindow.CanClose = true; Engine.MainWindow.Close(); break; // Hot Keys case UONetMessage.Mouse: HotKey.OnMouse((ushort)(lParam & 0xFFFF), (short)(lParam >> 16)); break; case UONetMessage.KeyDown: retVal = HotKey.OnKeyDown(lParam, ModKeys.None); break; // Activation Tracking case UONetMessage.Activate: /*if ( Config.GetBool( "AlwaysOnTop" ) ) * { * if ( (lParam&0x0000FFFF) == 0 && (lParam&0xFFFF0000) != 0 && razor.WindowState != FormWindowState.Minimized && razor.Visible ) * {// if uo is deactivating and minimized and we are not minimized * if ( !razor.ShowInTaskbar && razor.Visible ) * razor.Hide(); * razor.WindowState = FormWindowState.Minimized; * m_LastActivate = DateTime.UtcNow; * } * else if ( (lParam&0x0000FFFF) != 0 && (lParam&0xFFFF0000) != 0 && razor.WindowState != FormWindowState.Normal ) * { // is UO is activating and minimized and we are minimized * if ( m_LastActivate+TimeSpan.FromSeconds( 0.2 ) < DateTime.UtcNow ) * { * if ( !razor.ShowInTaskbar && !razor.Visible ) * razor.Show(); * razor.WindowState = FormWindowState.Normal; * //SetForegroundWindow( FindUOWindow() ); * } * m_LastActivate = DateTime.UtcNow; * } * }*/ break; case UONetMessage.Focus: if (Config.GetBool("AlwaysOnTop")) { if (lParam != 0 && !razor.TopMost) { razor.TopMost = true; Platform.SetForegroundWindow(FindUOWindow()); } else if (lParam == 0 && razor.TopMost) { razor.TopMost = false; razor.SendToBack(); } } // always use smartness for the map window if (razor.MapWindow != null && razor.MapWindow.Visible) { if (lParam != 0 && !razor.MapWindow.TopMost) { razor.MapWindow.TopMost = true; Platform.SetForegroundWindow(FindUOWindow()); } else if (lParam == 0 && razor.MapWindow.TopMost) { razor.MapWindow.TopMost = false; razor.MapWindow.SendToBack(); } } break; case UONetMessage.DLL_Error: { string error = "Unknown"; switch ((UONetMessage)lParam) { case UONetMessage.StatBar: error = "Unable to patch status bar."; break; } MessageBox.Show(Engine.ActiveWindow, "An Error has occured : \n" + error, "Error Reported", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } case UONetMessage.OnTick: // Game engine tick Timer.Slice(); break; // Unknown default: MessageBox.Show(Engine.ActiveWindow, "Unknown message from uo client\n" + ((int)wParam).ToString(), "Error?"); break; } return(retVal); }
public override bool InstallHooks(IntPtr mainWindow) { InitError error; int flags = 0; if (RazorEnhanced.Settings.General.ReadBool("Negotiate")) { flags |= 0x04; } if (ClientEncrypted) { flags |= 0x08; } if (Assistant.Client.Instance.ServerEncrypted) { flags |= 0x10; } //ClientProc.WaitForInputIdle(); DLLImport.Razor.WaitForWindow(ClientProc.Id); error = (InitError)DLLImport.Razor.InstallLibrary(mainWindow, ClientProc.Id, flags); if (error != InitError.SUCCESS) { FatalInit(error); return(false); } byte *baseAddr = (byte *)DLLImport.Razor.GetSharedAddress().ToPointer(); // ZIPPY REV 80 /*m_OutFwd = (Buffer*)baseAddr; * m_InRecv = (Buffer*)(baseAddr+sizeof(Buffer)*1); * m_OutRecv = (Buffer*)(baseAddr+sizeof(Buffer)*2); * m_InSend = (Buffer*)(baseAddr+sizeof(Buffer)*3); * m_OutSend = (Buffer*)(baseAddr+sizeof(Buffer)*4); * m_TitleStr = (byte*)(baseAddr+sizeof(Buffer)*5);*/ m_InRecv = (Buffer *)baseAddr; m_OutRecv = (Buffer *)(baseAddr + sizeof(Buffer)); m_InSend = (Buffer *)(baseAddr + sizeof(Buffer) * 2); m_OutSend = (Buffer *)(baseAddr + sizeof(Buffer) * 3); m_TitleStr = baseAddr + sizeof(Buffer) * 4; DLLImport.Razor.SetServer(m_ServerIP, m_ServerPort); CommMutex = new Mutex { SafeWaitHandle = (new SafeWaitHandle(DLLImport.Razor.GetCommMutex(), true)) }; try { string path = Ultima.Files.GetFilePath("art.mul"); if (!string.IsNullOrEmpty(path)) { DLLImport.Razor.SetDataPath(Path.GetDirectoryName(path)); } else { DLLImport.Razor.SetDataPath(Path.GetDirectoryName(Ultima.Files.Directory)); } } catch { DLLImport.Razor.SetDataPath(""); } if (RazorEnhanced.Settings.General.ReadBool("OldStatBar")) { Assistant.Client.Instance.RequestStatbarPatch(true); } return(true); }
private void HandleComm(Buffer *inBuff, Buffer *outBuff, Queue <Packet> queue, PacketPath path) { CommMutex.WaitOne(); while (inBuff->Length > 0) { byte *buff = (&inBuff->Buff0) + inBuff->Start; short len = PacketsTable.GetPacketLength(buff, inBuff->Length); if (len > inBuff->Length || len <= 0) { break; } inBuff->Start += len; inBuff->Length -= len; bool viewer = false; bool filter = false; switch (path) { case PacketPath.ClientToServer: viewer = PacketHandler.HasClientViewer(buff[0]); filter = PacketHandler.HasClientFilter(buff[0]); break; case PacketPath.ServerToClient: viewer = PacketHandler.HasServerViewer(buff[0]); filter = PacketHandler.HasServerFilter(buff[0]); break; } Packet p = null; PacketReader pr = null; if (viewer) { pr = new PacketReader(buff, len, PacketsTable.IsDynLength(buff[0])); if (filter) { p = MakePacketFrom(pr); } } else if (filter) { byte[] temp = new byte[len]; fixed(byte *ptr = temp) Platform.memcpy(ptr, buff, len); p = new Packet(temp, len, PacketsTable.IsDynLength(buff[0])); } bool blocked = false; switch (path) { // yes it should be this way case PacketPath.ClientToServer: { blocked = PacketHandler.OnClientPacket(buff[0], pr, p); break; } case PacketPath.ServerToClient: { blocked = PacketHandler.OnServerPacket(buff[0], pr, p); break; } } if (filter) { byte[] data = p.Compile(); fixed(byte *ptr = data) { Packet.Log(path, ptr, data.Length, blocked); if (!blocked) { CopyToBuffer(outBuff, ptr, data.Length); } } } else { Packet.Log(path, buff, len, blocked); if (!blocked) { CopyToBuffer(outBuff, buff, len); } } while (queue.Count > 0) { p = (Packet)queue.Dequeue(); byte[] data = p.Compile(); fixed(byte *ptr = data) { CopyToBuffer(outBuff, ptr, data.Length); Packet.Log((PacketPath)(((int)path) + 1), ptr, data.Length); } } } CommMutex.ReleaseMutex(); }
public abstract unsafe void CmdBindVertexBuffers2([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint firstBinding, [Count(Count = 0)] uint bindingCount, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] Buffer *pBuffers, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ulong *pOffsets, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ulong *pSizes, [Count(Computed = "bindingCount"), Flow(FlowDirection.In)] ulong *pStrides);