private void btnSend_Click(object sender, EventArgs e) { DynamicByteProvider BytePro = hexBox1.ByteProvider as DynamicByteProvider; try { strPipeMsgOut.sockid = int.Parse(txtSockID.Text, System.Globalization.NumberStyles.HexNumber); } catch { MessageBox.Show("Invalid socket ID.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSockID.SelectAll(); txtSockID.Focus(); return; } bcBytes = BytePro.Bytes; strPipeMsgOut.command = Glob.CMD_INJECT; strPipeMsgOut.function = Glob.FUNC_SEND; strPipeMsgOut.datasize = bcBytes.Count; for (int times = int.Parse(txtTimes.Text); times > 0; times--) { pipeOut.Write(Glob.RawSerializeEx(strPipeMsgOut), 0, Marshal.SizeOf(strPipeMsgOut)); pipeOut.Write(bcBytes.GetBytes(), 0, strPipeMsgOut.datasize); } }
private void closeToolStripMenuItem_Click(object sender, EventArgs e) { if (dgridSockets.SelectedRows.Count != 0) { strPipeMsgOut.command = Glob.CMD_INJECT; strPipeMsgOut.sockid = Int32.Parse(dgridSockets.SelectedRows[0].Cells["socket"].Value.ToString(), System.Globalization.NumberStyles.AllowHexSpecifier); strPipeMsgOut.function = Glob.FUNC_CLOSESOCKET; strPipeMsgOut.datasize = 0; pipeOut.Write(Glob.RawSerializeEx(strPipeMsgOut), 0, Marshal.SizeOf(strPipeMsgOut)); } }