public static byte[] write() { byte[] temp = init(); ByteBuffer buff = new ByteBuffer(); buff.WriteD(temp.Length + 4); for (int i = 0; i < temp.Length - 1; i++) { buff.WriteByte(temp[i]); } buff.Resize(temp.Length + 4); size = buff.Length(); return buff.Get_ByteArray(); }
public void OnMessage(ClientSession session, ByteBuffer buffer) { string str = buffer.ReadString(); int uid = buffer.ReadInt(); ushort commandId = (ushort)Protocal.Login; ByteBuffer newBuffer = new ByteBuffer(); newBuffer.WriteShort(commandId); newBuffer.WriteByte(1); newBuffer.WriteString(str); SocketUtil.SendMessage(session, newBuffer); session.uid = uid; UserUtil.Add(uid, session); Console.WriteLine("OnMessage--->>>" + str + uid); }
void PatchRawSmallSection(ByteBuffer buffer, MetadataBuilder metadata) { var length = ReadByte(); buffer.WriteByte(length); Advance(2); buffer.WriteUInt16(0); var count = length / 12; PatchRawExceptionHandlers(buffer, metadata, count, false); }
void PatchRawSection(ByteBuffer buffer, MetadataBuilder metadata) { var position = base.position; Align(4); buffer.WriteBytes(base.position - position); const byte fat_format = 0x40; const byte more_sects = 0x80; var flags = ReadByte(); if ((flags & fat_format) == 0) { buffer.WriteByte(flags); PatchRawSmallSection(buffer, metadata); } else PatchRawFatSection(buffer, metadata); if ((flags & more_sects) != 0) PatchRawSection(buffer, metadata); }
public ByteBuffer PatchRawMethodBody(MethodDefinition method, CodeWriter writer, out MethodSymbols symbols) { var buffer = new ByteBuffer(); symbols = new MethodSymbols(method.Name); this.method = method; reader.context = method; MoveTo(method.RVA); var flags = ReadByte(); MetadataToken local_var_token; switch (flags & 0x3) { case 0x2: // tiny buffer.WriteByte(flags); local_var_token = MetadataToken.Zero; symbols.code_size = flags >> 2; PatchRawCode(buffer, symbols.code_size, writer); break; case 0x3: // fat base.position--; PatchRawFatMethod(buffer, symbols, writer, out local_var_token); break; default: throw new NotSupportedException(); } var symbol_reader = reader.module.symbol_reader; if (symbol_reader != null && writer.metadata.write_symbols) { symbols.method_token = GetOriginalToken(writer.metadata, method); symbols.local_var_token = local_var_token; symbol_reader.Read(symbols); } return buffer; }