本文整理汇总了C#中Framework.Network.Packets.PacketWriter.WriteBytes方法的典型用法代码示例。如果您正苦于以下问题:C# PacketWriter.WriteBytes方法的具体用法?C# PacketWriter.WriteBytes怎么用?C# PacketWriter.WriteBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Framework.Network.Packets.PacketWriter
的用法示例。
在下文中一共展示了PacketWriter.WriteBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleRealmList
public void HandleRealmList(PacketReader data)
{
Log.Message(LogType.NORMAL, "RealmList");
using (var realmData = new PacketWriter())
{
Realms.ToList().ForEach(r =>
{
using (var result = DB.Characters.Select("SELECT COUNT(*) as Count FROM characters WHERE AccountId = ? AND RealmId = ?", account.Id, r.Value.Id))
{
var charCount = result.Read<byte>(0, "Count");
realmData.WriteUInt8(1);
realmData.WriteUInt8(0);
realmData.WriteUInt8(0);
realmData.WriteCString(r.Key);
realmData.WriteCString(r.Value.IP + ":" + r.Value.Port);
realmData.WriteFloat(0);
realmData.WriteUInt8(charCount);
realmData.WriteUInt8(1);
realmData.WriteUInt8(0x2C);
}
});
using (var realmList = new PacketWriter())
{
realmList.WriteUInt8((byte)ClientLink.CMD_REALM_LIST);
realmList.WriteUInt16((ushort)(realmData.BaseStream.Length + 8));
realmList.WriteUInt32(0);
realmList.WriteUInt16((ushort)Realms.Count);
realmList.WriteBytes(realmData.ReadDataToSend());
realmList.WriteUInt8(0);
realmList.WriteUInt8(0x10);
Send(realmList);
}
}
}
示例2: HandleAuthLogonChallenge
public void HandleAuthLogonChallenge(PacketReader data)
{
Log.Message(LogType.NORMAL, "AuthLogonChallenge");
data.Skip(10);
ushort ClientBuild = data.Read<ushort>();
data.Skip(8);
account.Language = data.ReadStringFromBytes(4);
data.Skip(4);
account.IP = data.ReadIPAddress();
account.Name = data.ReadAccountName();
SQLResult result = DB.Realms.Select("SELECT id, name, password, expansion, gmlevel, securityFlags, online FROM accounts WHERE name = ?", account.Name);
using (var logonChallenge = new PacketWriter())
{
logonChallenge.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_CHALLENGE);
logonChallenge.WriteUInt8(0);
if (result.Count != 0)
{
if (result.Read<bool>(0, "online"))
{
logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_ALREADY_ONLINE);
Send(logonChallenge);
return;
}
account.Id = result.Read<Int32>(0, "id");
account.Expansion = result.Read<Byte>(0, "expansion");
account.SecurityFlags = result.Read<Byte>(0, "securityFlags");
DB.Realms.Execute("UPDATE accounts SET ip = ?, language = ? WHERE id = ?", account.IP, account.Language, account.Id);
var username = result.Read<String>(0, "name").ToUpperInvariant();
var password = result.Read<String>(0, "password").ToUpperInvariant();
// WoW 5.2.0.16826
if (ClientBuild == 16826)
{
SecureRemotePassword.CalculateX(username, password);
var randBytes = new byte[0x10];
var random = RNGCryptoServiceProvider.Create();
random.GetBytes(randBytes);
logonChallenge.WriteUInt8((byte)AuthResults.WOW_SUCCESS);
logonChallenge.WriteBytes(SecureRemotePassword.B);
logonChallenge.WriteUInt8(1);
logonChallenge.WriteUInt8(SecureRemotePassword.g.ToByteArray()[0]);
logonChallenge.WriteUInt8(0x20);
logonChallenge.WriteBytes(SecureRemotePassword.N);
logonChallenge.WriteBytes(SecureRemotePassword.Salt);
logonChallenge.WriteBytes(randBytes);
// Security flags
logonChallenge.WriteUInt8(account.SecurityFlags);
// Enable authenticator
if ((account.SecurityFlags & 4) != 0)
logonChallenge.WriteUInt8(1);
}
}
else
logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_UNKNOWN_ACCOUNT);
Send(logonChallenge);
}
}
示例3: HandleAuthLogonChallenge
public void HandleAuthLogonChallenge(RealmClass session, PacketReader data)
{
Log.Message(LogType.NORMAL, "AuthLogonChallenge");
data.Skip(10);
ushort ClientBuild = data.ReadUInt16();
data.Skip(8);
account.Language = data.ReadStringFromBytes(4);
data.Skip(4);
account.IP = data.ReadIPAddress();
account.Name = data.ReadAccountName();
SQLResult result = DB.Realms.Select("SELECT id, name, password, expansion, gmlevel, securityFlags FROM accounts WHERE name = '{0}'", account.Name);
var res = result.Read("id", "name", "password", "expansion", "securityFlags");
PacketWriter logonChallenge = new PacketWriter();
logonChallenge.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_CHALLENGE);
logonChallenge.WriteUInt8(0);
if (result.Count != 0)
{
account.Id = result.Read<Int32>("id");
account.Expansion = result.Read<Byte>("expansion");
account.SecurityFlags = result.Read<Byte>("securityFlags");
DB.Realms.Execute("UPDATE accounts SET ip = '{0}', language = '{1}' WHERE id = {2}", account.IP, account.Language, account.Id);
byte[] username = Encoding.UTF8.GetBytes(result.Read<String>("name").ToUpper());
byte[] password = Encoding.UTF8.GetBytes(result.Read<String>("password").ToUpper());
// WoW 5.1.0.16309 (5.1.0)
if (ClientBuild == 16309)
{
session.SecureRemotePassword.CalculateX(username, password);
byte[] buf = new byte[0x10];
SRP6.RAND_bytes(buf, 0x10);
logonChallenge.WriteUInt8((byte)AuthResults.WOW_SUCCESS);
logonChallenge.WriteBytes(session.SecureRemotePassword.B);
logonChallenge.WriteUInt8(1);
logonChallenge.WriteUInt8(session.SecureRemotePassword.g[0]);
logonChallenge.WriteUInt8(0x20);
logonChallenge.WriteBytes(session.SecureRemotePassword.N);
logonChallenge.WriteBytes(session.SecureRemotePassword.salt);
logonChallenge.WriteBytes(buf);
// Security flags
logonChallenge.WriteUInt8(account.SecurityFlags);
// Enable authenticator
if ((account.SecurityFlags & 4) != 0)
logonChallenge.WriteUInt8(1);
}
}
else
logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_UNKNOWN_ACCOUNT);
session.Send(logonChallenge);
}
示例4: HandleAuthLogonProof
public void HandleAuthLogonProof(PacketReader data)
{
Log.Message(LogType.NORMAL, "AuthLogonProof");
using (var logonProof = new PacketWriter())
{
var a = data.ReadBytes(32);
var m1 = data.ReadBytes(20);
SecureRemotePassword.CalculateU(a);
SecureRemotePassword.CalculateM2(m1);
SecureRemotePassword.CalculateK();
foreach (var b in SecureRemotePassword.K)
if (b < 0x10)
account.SessionKey += "0" + String.Format(CultureInfo.InvariantCulture, "{0:X}", b);
else
account.SessionKey += String.Format(CultureInfo.InvariantCulture, "{0:X}", b);
logonProof.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_PROOF);
logonProof.WriteUInt8(0);
logonProof.WriteBytes(SecureRemotePassword.M2);
logonProof.WriteUInt32(0x800000);
logonProof.WriteUInt32(0);
logonProof.WriteUInt16(0);
SecureRemotePassword.Dispose();
DB.Realms.Execute("UPDATE accounts SET sessionkey = ? WHERE id = ?", account.SessionKey, account.Id);
Send(logonProof);
}
}
示例5: HandleRealmList
public void HandleRealmList(RealmClass session, PacketReader data)
{
Log.Message(LogType.NORMAL, "RealmList");
PacketWriter realmData = new PacketWriter();
foreach (var r in Realms)
{
realmData.WriteUInt8(1);
realmData.WriteUInt8(0);
realmData.WriteUInt8(0);
realmData.WriteCString(r.Name);
realmData.WriteCString(r.IP + ":" + r.Port);
realmData.WriteFloat(0);
realmData.WriteUInt8(0); // CharCount
realmData.WriteUInt8(1);
realmData.WriteUInt8(0x2C);
}
PacketWriter realmList = new PacketWriter();
realmList.WriteUInt8((byte)ClientLink.CMD_REALM_LIST);
realmList.WriteUInt16((ushort)(realmData.BaseStream.Length + 8));
realmList.WriteUInt32(0);
realmList.WriteUInt16((ushort)Realms.Count);
realmList.WriteBytes(realmData.ReadDataToSend());
realmList.WriteUInt8(0);
realmList.WriteUInt8(0x10);
session.Send(realmList);
}
示例6: HandleAuthLogonProof
public void HandleAuthLogonProof(RealmClass session, PacketReader data)
{
Log.Message(LogType.NORMAL, "AuthLogonProof");
PacketWriter logonProof = new PacketWriter();
byte[] a = new byte[32];
byte[] m1 = new byte[20];
Array.Copy(DataBuffer, 1, a, 0, 32);
Array.Copy(DataBuffer, 33, m1, 0, 20);
session.SecureRemotePassword.CalculateU(a);
session.SecureRemotePassword.CalculateM2(m1);
session.SecureRemotePassword.CalculateK();
foreach (var b in session.SecureRemotePassword.K)
if (b < 0x10)
account.SessionKey += "0" + String.Format("{0:X}", b);
else
account.SessionKey += String.Format("{0:X}", b);
logonProof.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_PROOF);
logonProof.WriteUInt8(0);
logonProof.WriteBytes(session.SecureRemotePassword.M2);
logonProof.WriteUInt32(0x800000);
logonProof.WriteUInt32(0);
logonProof.WriteUInt16(0);
DB.Realms.Execute("UPDATE accounts SET sessionkey = '{0}' WHERE id = {1}", account.SessionKey, account.Id);
session.Send(logonProof);
}
示例7: WriteAddonData
public static void WriteAddonData(WorldClass session)
{
PacketWriter addonInfo = new PacketWriter(ServerMessage.AddonInfo);
BitPack BitPack = new BitPack(addonInfo);
int AddOnCount = session.Addons.Count;
BitPack.Write<int>(0, 18);
BitPack.Write<int>(AddOnCount, 23);
session.Addons.ForEach(addon =>
{
BitPack.Write<bool>(addon.Enabled != 0);
BitPack.Write<bool>(addon.HasPUBData != 0);
BitPack.Write<bool>(addon.HasUrlString != 0);
if (addon.HasUrlString != 0)
BitPack.Write<int>(addon.UrlString.Length, 8);
});
BitPack.Flush();
// Send Addon stored data for session
session.Addons.ForEach(addon =>
{
// atm not url string
if (addon.HasUrlString != 0x00)
addonInfo.WriteString(addon.UrlString, false);
if (addon.HasPUBData != 0x00)
addonInfo.WriteBytes(addon.PUBData, addon.PUBData.Length);
if (addon.Enabled != 0x00)
{
addonInfo.WriteUInt8(addon.Version);
addonInfo.WriteUInt32(addon.UrlStringCRC);
}
addonInfo.WriteUInt8(addon.AuthType);
});
session.Send(ref addonInfo);
}
示例8: HandleVendorTabeList
public static void HandleVendorTabeList(ref PacketReader packet, ref WorldClass session)
{
ulong targetGuid = packet.ReadUInt64();
if (targetGuid == session.Character.TargetGuid)
{
HighGuidType lol = Framework.ObjectDefines.ObjectGuid.GetGuidType(targetGuid);
ulong odd = ObjectGuid.GetGuid(targetGuid);
CreatureSpawn spawn = Globals.SpawnMgr.FindSpawn(targetGuid);
Creature npc = spawn.Creature;
PacketWriter Inventory = new PacketWriter(JAMCMessage.VendorInventory);
BitPack ss = new BitPack(Inventory);
Inventory.WriteInt8(0x01);//client expects counting to start at 1??
byte[] count = {00,10,00};//count dat bitstream fortmat unkown
Inventory.WriteBytes(count, 3);
/*Item1*/
Inventory.WriteInt8(11);//slot
Inventory.WriteInt32(0xFFF010);//left ub stock?
ss.Flush();
string ssss = "00 00 0C 34 00 00 0C 10 00 00 00 10 00 00 05 30 00 00 03 C0 00 00 00 10 00 00 0C 74 00 00 00 B0 E0 00 0F FF FF FF F0 00 00 00 00 20 00 00 00 10 00 00 02 80 00 00 01 40 00 00 00 10 00 00 0C 44 00 00 0C 20 00 00 0F FF FF FF F0 00 00 00 00 30 00 00 00 10 00 00 05 30 00 00 02 D0 00 00 00 10 00 00 0C 64 00 00 0C 30 00 00 0F FF FF FF F0 00 00 00 00 40 00 00 00 10 00 00 03 E0 00 00 01 E0 00 00 00 10 00 00 0C 84 00 00 00 C0 E0 00 0F FF FF FF F0 00 00 00 00 50 00 00 00 10 00 00 02 80 00 00 01 40 00 00 00 10 00 00 0C 54 00 00 0C 70 20 00 0F FF FF FF F0 00 00 00 00 60 00 00 00 10 00 00 02 C0 00 00 01 40 00 00 00 10 00 00 0F 34 10 00 05 50 00 00 0F FF FF FF F0 00 00 00 00 70 00 00 00 10 00 00 05 50 00 00 03 C0 00 00 00 10 00 00 06 B3 80 00 02 B0 70 00 0F FF FF FF F0 00 00 00 00 80 00 00 00 10 00 00 02 B0 00 00 01 40 00 00 00 10 00 00 0F 44 20 00 0D 10 00 00 0F FF FF FF F0 00 00 00 00 90 00 00 00 10 00 00 05 20 00 00 02 D0 00 00 00 10 00 00 06 C3 80 00 0D 20 00 00 0F FF FF FF F0 00 00 00 00 A0 00 00 00 10 00 00 03 D0 00 00 01 E0 00 00 00 10 00 00 0A 93 70 00 02 C0 70 00 0F FF FF FF F0 00 00 00 00 B0 00 00 00 10 00 00 02 B0 00 00 01 40 00 00 00 10 00 00 06 D3 80 00 0C A0 20 00 0F FF FF FF F0 00 00 00 00 C0 00 00 00 10 00 00 02 C0 00 00 01 40 00 00 05 99 CF 03 10 D9 C0";
string[] all = ssss.Split(' ');
// int gu = int.Parse(all[0] + " " + all[1] + " " + all[2] + " " + all[3], System.Globalization.NumberStyles.HexNumber);
foreach (string a in all)
{
byte test = byte.Parse(a, System.Globalization.NumberStyles.HexNumber);
Inventory.WriteUInt8(test);
}
/* Inventory.WriteGuid(121332123);
Item ii = npc.Data.VendorItems[0];
Inventory.WriteUInt32(1); // client expects counting to start at 1
Inventory.WriteUInt32(1); // unk 4.0.1 always 1
Inventory.WriteUInt32((uint)71634);
Inventory.WriteUInt32((uint)69314);
Inventory.WriteUInt32(0xFFFFFFFF);//left in stcok
Inventory.WriteUInt32(1);
Inventory.WriteUInt32(0);
Inventory.WriteUInt32(1);
Inventory.WriteUInt32(0);
Inventory.WriteInt8(0); ;*/
// unk 4.0.1
session.Send(ref Inventory);
Console.WriteLine(npc.Data.NpcFlags);
}
// Globals.WorldMgr.
}
示例9: HandleCharacterEnum
public static void HandleCharacterEnum(ref PacketReader packet, ref WorldClass session)
{
SQLResult result = DB.Characters.Select("SELECT guid, name, race, class, gender, skin, face, hairstyle, " +
"haircolor, facialhair, level, zone, map, x, y, z, guildguid, petdisplayid, " +
"petlevel, petfamily, characterflags, customizeflags FROM characters WHERE accountid = {0}", session.Account.Id);
PacketWriter enumCharacters = new PacketWriter(JAMCMessage.EnumCharactersResult);
BitPack BitPack = new BitPack(enumCharacters);
BitPack.Write(0, 23);
BitPack.Write(result.Count, 17);
if (result.Count != 0)
{
for (int c = 0; c < result.Count; c++)
{
string name = result.Read<String>(c, "Name");
BitPack.Guid = result.Read<UInt64>(c, "Guid");
BitPack.GuildGuid = result.Read<UInt64>(c, "GuildGuid");
BitPack.WriteGuidMask(4);
BitPack.WriteGuildGuidMask(7, 3, 0, 1);
BitPack.Write(0);
BitPack.WriteGuidMask(6);
BitPack.WriteGuildGuidMask(6);
BitPack.WriteGuidMask(1);
BitPack.Write((uint)Encoding.ASCII.GetBytes(name).Length, 7);
BitPack.WriteGuildGuidMask(2);
BitPack.WriteGuidMask(2, 0, 3, 5);
BitPack.WriteGuildGuidMask(4);
BitPack.WriteGuidMask(7);
BitPack.WriteGuildGuidMask(5);
}
BitPack.Write(1);
BitPack.Flush();
for (int c = 0; c < result.Count; c++)
{
string name = result.Read<String>(c, "Name");
BitPack.Guid = result.Read<UInt64>(c, "Guid");
BitPack.GuildGuid = result.Read<UInt64>(c, "GuildGuid");
// Not implanted
for (int j = 0; j < 23; j++)
{
enumCharacters.WriteUInt32(0);
enumCharacters.WriteUInt32(0);
enumCharacters.WriteUInt8(0);
}
enumCharacters.WriteUInt8(result.Read<Byte>(c, "HairStyle"));
enumCharacters.WriteUInt8(result.Read<Byte>(c, "Race"));
BitPack.WriteGuidBytes(0);
BitPack.WriteGuildGuidBytes(4);
enumCharacters.WriteUInt8(result.Read<Byte>(c, "FacialHair"));
enumCharacters.WriteUInt8(result.Read<Byte>(c, "HairColor"));
enumCharacters.WriteFloat(result.Read<Single>(c, "Z"));
BitPack.WriteGuildGuidBytes(6);
BitPack.WriteGuidBytes(7);
BitPack.WriteGuildGuidBytes(0);
enumCharacters.WriteUInt32(result.Read<UInt32>(c, "CharacterFlags"));
enumCharacters.WriteUInt32(result.Read<UInt32>(c, "Zone"));
BitPack.WriteGuidBytes(5, 6);
enumCharacters.WriteUInt32(result.Read<UInt32>(c, "CustomizeFlags"));
enumCharacters.WriteUInt32(result.Read<UInt32>(c, "Map"));
BitPack.WriteGuidBytes(1);
enumCharacters.WriteUInt32(result.Read<UInt32>(c, "PetDisplayId"));
BitPack.WriteGuildGuidBytes(1);
enumCharacters.WriteUInt8(result.Read<Byte>(c, "Face"));
enumCharacters.WriteUInt32(result.Read<UInt32>(c, "PetFamily"));
enumCharacters.WriteUInt8(result.Read<Byte>(c, "Skin"));
BitPack.WriteGuidBytes(4);
BitPack.WriteGuildGuidBytes(5);
enumCharacters.WriteBytes(Encoding.ASCII.GetBytes(name));
enumCharacters.WriteUInt32(result.Read<UInt32>(c, "PetLevel"));
enumCharacters.WriteUInt8(result.Read<Byte>(c, "Gender"));
enumCharacters.WriteFloat(result.Read<Single>(c, "X"));
enumCharacters.WriteUInt8(result.Read<Byte>(c, "Class"));
enumCharacters.WriteUInt8(0);
enumCharacters.WriteFloat(result.Read<Single>(c, "Y"));
BitPack.WriteGuildGuidBytes(3, 7, 2);
enumCharacters.WriteUInt8(result.Read<Byte>(c, "Level"));
BitPack.WriteGuidBytes(2, 3);
}
//.........这里部分代码省略.........