Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using OpenSSL;
namespace Arco_Online
{
public class DataPacket : IClassPacket
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct PacketHeader
{
public ushort Length;
public ushort Type;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct GeneralData
{
public PacketHeader Header;
public uint TimeStamp;
public uint UniqueID;
public uint Param;
public ushort PosX;
public ushort PosY;
public ushort Direction;
public ushort Action;
}
[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
public static extern unsafe void* memcpy(void* dest, void* src, int count);
public const ushort
SetLocation = 74,
Hotkeys = 75,
ConfirmFriends = 76,
ConfirmProfincies = 77,
ConfirmSpells = 78,
ChangeDirection = 79,
ChangeAction = 81,
Portal = 86,
EndXpList = 93,
Revive = 94,
ChangePkMode = 96,
ConfirmGuild = 97,
BEGIN_MINE = 99,
EntitySpawn = 102,
CompleteMapChange = 104,
CorrectCords = 108,
Shop = 111,
OpenShop = 113,
GetSurroundings = 114,
RemoteCommands = 116,
PickupCashEffect = 121,
Dialog = 126,
GuardJump = 129,
CompleteLogin = 130,
RemoveEntity = 132,
Jump = 133,
RemoveWeaponMesh = 135,
RemoveWeaponMesh2 = 136,
Avatar = 132;
private GeneralData RealPacket;
public DataPacket(bool CreateInstance)
{
this.RealPacket = new GeneralData();
if (CreateInstance)
{
this.RealPacket.Header.Length = (ushort)Marshal.SizeOf(this.RealPacket);
this.RealPacket.Header.Type = 1010;
this.TimeStamp = (uint)Environment.TickCount;
}
}
public unsafe void Deserialize(byte[] Bytes)
{
fixed (byte* pckt = Bytes)
{
fixed (GeneralData* rlPacket = &this.RealPacket)
{
memcpy(rlPacket, pckt, Bytes.Length);
}
}
}
public unsafe byte[] Serialize()
{
byte[] Packet = new byte[Marshal.SizeOf(this.RealPacket)];
fixed (byte* pckt = Packet)
{
fixed (GeneralData* rlPacket = &this.RealPacket)
{
memcpy(pckt, rlPacket, Marshal.SizeOf(this.RealPacket));
}
}
return Packet;
}
public uint dwParam
{
get
{
return this.RealPacket.Param;
}
set
{
this.RealPacket.Param = value;
}
}
public uint TimeStamp
{
get
{
return this.RealPacket.TimeStamp;
}
set
{
this.RealPacket.TimeStamp = value;
}
}
public uint UID
{
get
{
return this.RealPacket.UniqueID;
}
set
{
this.RealPacket.UniqueID = value;
}
}
public ushort wParam1
{
get
{
return this.RealPacket.PosX;
}
set
{
this.RealPacket.PosX = value;
}
}
public ushort wParam2
{
get
{
return this.RealPacket.PosY;
}
set
{
this.RealPacket.PosY = value;
}
}
public ushort wParam3
{
get
{
return this.RealPacket.Action;
}
set
{
this.RealPacket.Action = value;
}
}
public ushort wParam4
{
get
{
return this.RealPacket.Direction;
}
set
{
this.RealPacket.Direction = value;
}
}
}
}