All pastes #2008122 Raw Edit

Unnamed

public text v1 · immutable
#2008122 ·published 2010-12-01 22:51 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

/********************
 ** By Interest07  **
*********************/


namespace PerfectWorld
{
    class PacketSender : PWIoffsets
    {
        private IntPtr pr_processHandle;

        //======================//
        //  Packet structures   //
        //======================//


        //Move

        private int moveAddress;
        private byte[] moveAddressRev;

        private byte[] movePkt = new byte[] 
        { 
            0x00, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,      //x coord
            0x00, 0x00, 0x00, 0x00,      //y coord
            0x00, 0x00, 0x00, 0x00,      //z coord
            0x00, 0x00, 0x00, 0x00,      //x coord
            0x00, 0x00, 0x00, 0x00,      //y coord
            0x00, 0x00, 0x00, 0x00,       //z coord
            0x00, 0x00,                 //interval
            0x00, 0x00,                 //speed
            0x00,                       //moveType
            0x00, 0x00                  //counter

        };

        public void move(float xCoord, float yCoord, float zCoord, short interval, float speed, byte moveType, short moveCounter)
        {
            //Get size of the packet
            int packetSize = movePkt.Length;

            if (moveAddress == 0)
            {
                //load packet in memory
                loadPacket(movePkt, ref moveAddress, ref moveAddressRev);
            }

            byte[] xCoordRev = BitConverter.GetBytes(xCoord);
            xCoordRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 2, xCoordRev);
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 14, xCoordRev);

            byte[] yCoordRev = BitConverter.GetBytes(yCoord);
            yCoordRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 6, yCoordRev);
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 18, yCoordRev);

            byte[] zCoordRev = BitConverter.GetBytes(zCoord);
            zCoordRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 10, zCoordRev);
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 22, zCoordRev);

            byte[] intervalRev = BitConverter.GetBytes(interval);
            intervalRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 26, intervalRev);

            short shortSpeed = (short)(speed * 256 + 0.5);
            byte[] shortSpeedRev = BitConverter.GetBytes(shortSpeed);
            shortSpeedRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 28, shortSpeedRev);

            MemFunctions.MemWriteByte(pr_processHandle, moveAddress + 30, moveType);

            byte[] moveCounterRev = BitConverter.GetBytes(moveCounter);
            moveCounterRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveAddress + 31, moveCounterRev);

            sendPacket(moveAddressRev, packetSize);
        }

        //Log out

        private int logOutAddress;
        private byte[] logOutAddressRev;

        private byte[] logOutPkt = new byte[] 
        { 
            0x01, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00      //toAccount
        };

        public void logOut(int toAccount)
        {
            //Get size of the packet
            int packetSize = logOutPkt.Length;

            if (logOutAddress == 0)
            {
                //load packet in memory
                loadPacket(logOutPkt, ref logOutAddress, ref logOutAddressRev);
            }
            byte[] toAccountRev = BitConverter.GetBytes(toAccount);
            toAccountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, logOutAddress + 2, toAccountRev);

            sendPacket(logOutAddressRev, packetSize);
        }



        //Select Target

        private int selectAddress;
        private byte[] selectAddressRev;

        private byte[] selectPkt = new byte[] 
        { 
            0x02, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00      //objectId
        };

        public void select(int objectId)
        {
            //Get size of the packet
            int packetSize = selectPkt.Length;

            if (logOutAddress == 0)
            {
                //load packet in memory
                loadPacket(selectPkt, ref selectAddress, ref selectAddressRev);
            }
            byte[] objectIdRev = BitConverter.GetBytes(objectId);
            objectIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, selectAddress + 2, objectIdRev);

            sendPacket(selectAddressRev, packetSize);
        }


        //Regular Attack

        private int regularAttackAddress;
        private byte[] regularAttackAddressRev;
        
        private byte[] regularAttackPkt = new byte[] 
        { 
            0x03, 0x00,                 //Header
            0x00                        //afterSkill
        };

        public void regularAttack(byte afterSkill)
        {
            //Get size of the packet
            int packetSize = regularAttackPkt.Length;

            if (regularAttackAddress == 0)
            {
                //load packet in memory
                loadPacket(regularAttackPkt, ref regularAttackAddress, ref regularAttackAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, regularAttackAddress + 2, afterSkill);
            sendPacket(regularAttackAddressRev, packetSize);
        }

        //Resurrect to town

        private int resurrectToTownAddress;
        private byte[] resurrectToTownAddressRev;
   

        private byte[] resurrectToTownPkt = new byte[] 
        { 
            0x04, 0x00,                 //Header
        };

        public void resurrectToTown()
        {
            //Get size of the packet
            int packetSize = resurrectToTownPkt.Length;

            if (resurrectToTownAddress == 0)
            {
                //load packet in memory
                loadPacket(resurrectToTownPkt, ref resurrectToTownAddress, ref resurrectToTownAddressRev);
            }

            sendPacket(resurrectToTownAddressRev, packetSize);
        }




        //Resurrect with scroll

        private int resurrectWithScrollAddress;
        private byte[] resurrectWithScrollAddressRev;
   

        private byte[] resurrectWithScrollPkt = new byte[] 
        { 
            0x05, 0x00,                 //Header
        };

        public void resurrectWithScroll()
        {
            //Get size of the packet
            int packetSize = resurrectWithScrollPkt.Length;

            if (resurrectWithScrollAddress == 0)
            {
                //load packet in memory
                loadPacket(resurrectWithScrollPkt, ref resurrectWithScrollAddress, ref resurrectWithScrollAddressRev);
            }

            sendPacket(resurrectWithScrollAddressRev, packetSize);
        }




        //Pick up item

        private int pickUpItemAddress;
        private byte[] pickUpItemAddressRev;
   
        private byte[] pickUpItemPkt = new byte[] 
        { 
            0x06, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //uniqueId
            0x00, 0x00, 0x00, 0x00      //typeId
        };

        public void pickUpItem(int uniqueId, int typeId)
        {
            //Get size of the packet
            int packetSize = pickUpItemPkt.Length;

            if (pickUpItemAddress == 0)
            {
                //load packet in memory
                loadPacket(pickUpItemPkt, ref pickUpItemAddress, ref pickUpItemAddressRev);
            }

            byte[] uniqueIdRev = BitConverter.GetBytes(uniqueId);
            uniqueIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, selectAddress + 2, uniqueIdRev);

            byte[] typeIdRev = BitConverter.GetBytes(typeId);
            typeIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, selectAddress + 6, typeIdRev);


            sendPacket(pickUpItemAddressRev, packetSize);
        }


        //Move Stop

        private int moveStopAddress;
        private byte[] moveStopAddressRev;

        private byte[] moveStopPkt = new byte[] 
        { 
            0x07, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //x coord
            0x00, 0x00, 0x00, 0x00,     //y coord
            0x00, 0x00, 0x00, 0x00,     //z coord
            0x00, 0x00,                 //speed
            0x00,                       //direction
            0x00,                       //moveType
            0x00, 0x00,                 //counter
            0x00, 0x00                  //interval

        };

        public void moveStop(float xCoord, float yCoord, float zCoord, short interval, float speed, byte moveType, short moveCounter, byte direction)
        {
            //Get size of the packet
            int packetSize = moveStopPkt.Length;

            if (moveStopAddress == 0)
            {
                //load packet in memory
                loadPacket(moveStopPkt, ref moveStopAddress, ref moveStopAddressRev);
            }

            byte[] xCoordRev = BitConverter.GetBytes(xCoord);
            xCoordRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveStopAddress + 2, xCoordRev);

            byte[] yCoordRev = BitConverter.GetBytes(yCoord);
            yCoordRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveStopAddress + 6, yCoordRev);

            byte[] zCoordRev = BitConverter.GetBytes(zCoord);
            zCoordRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveStopAddress + 10, zCoordRev);

            byte[] intervalRev = BitConverter.GetBytes(interval);
            intervalRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveStopAddress + 20, intervalRev);

            short shortSpeed = (short)(speed * 256 + 0.5);
            byte[] shortSpeedRev = BitConverter.GetBytes(shortSpeed);
            shortSpeedRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveStopAddress + 14, shortSpeedRev);

            MemFunctions.MemWriteByte(pr_processHandle, moveStopAddress + 16, direction);
            MemFunctions.MemWriteByte(pr_processHandle, moveStopAddress + 17, moveType);

            byte[] moveCounterRev = BitConverter.GetBytes(moveCounter);
            moveCounterRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, moveStopAddress + 18, moveCounterRev);

            sendPacket(moveStopAddressRev, packetSize);
        }

        //Update inventory position

        private int updateInvPositionAddress;
        private byte[] updateInvPositionAddressRev;
   
        private byte[] updateInvPositionPkt = new byte[] 
        { 
            0x09, 0x00,                 //Header
            0x00                        //itemPosition
        };

        public void updateInvPosition(byte invIndex)
        {
            //Get size of the packet
            int packetSize = updateInvPositionPkt.Length;

            if (updateInvPositionAddress == 0)
            {
                //load packet in memory
                loadPacket(updateInvPositionPkt, ref updateInvPositionAddress, ref updateInvPositionAddressRev);
            }
            MemFunctions.MemWriteByte(pr_processHandle, updateInvPositionAddress + 2, invIndex);
            sendPacket(updateInvPositionAddressRev, packetSize);
        }




        //Swap item in inventory

        private int swapItemInInvAddress;
        private byte[] swapItemInInvAddressRev;
   
        private byte[] swapItemInInvPkt = new byte[] 
        { 
            0x0C, 0x00,                 //Header
            0x00,                       //itemInvIndex 1
            0x00                        //itemInvIndex 2
        };

        public void swapItemInInv(byte invIndex1, byte invIndex2)
        {
            //Get size of the packet
            int packetSize = swapItemInInvPkt.Length;

            if (swapItemInInvAddress == 0)
            {
                //load packet in memory
                loadPacket(swapItemInInvPkt, ref swapItemInInvAddress, ref swapItemInInvAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, swapItemInInvAddress + 2, invIndex1);
            MemFunctions.MemWriteByte(pr_processHandle, swapItemInInvAddress + 3, invIndex2);


            sendPacket(swapItemInInvAddressRev, packetSize);
        }




        //Split stack in inventory

        private int splitStackItemInInvAddress;
        private byte[] splitStackItemInInvAddressRev;
   
        private byte[] splitStackItemInInvPkt = new byte[] 
        { 
            0x0D, 0x00,                 //Header
            0x00,                       //itemInvIndexSource
            0x00,                       //itemInvIndexDestination
            0x00, 0x00                  //Amount
        };

        public void splitStackInInventory(byte invIndexSource, byte invIndexDestination, short amount)
        {
            //Get size of the packet
            int packetSize = splitStackItemInInvPkt.Length;

            if (splitStackItemInInvAddress == 0)
            {
                //load packet in memory
                loadPacket(splitStackItemInInvPkt, ref splitStackItemInInvAddress, ref splitStackItemInInvAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, splitStackItemInInvAddress + 2, invIndexSource);
            MemFunctions.MemWriteByte(pr_processHandle, splitStackItemInInvAddress + 3, invIndexDestination);

            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, splitStackItemInInvAddress + 4, amountRev);

            sendPacket(splitStackItemInInvAddressRev, packetSize);
        }




        //Drop item

        private int dropItemAddress;
        private byte[] dropItemAddressRev;
   
        private byte[] dropItemPkt = new byte[] 
        { 
            0x0E, 0x00,                 //Header
            0x00,                       //itemInvIndexSource
            0x00, 0x00                  //Amount
        };

        public void dropItem(byte invIndex, short amount)
        {
            //Get size of the packet
            int packetSize = dropItemPkt.Length;

            if (dropItemAddress == 0)
            {
                //load packet in memory
                loadPacket(dropItemPkt, ref dropItemAddress, ref dropItemAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, dropItemAddress + 2, invIndex);

            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, dropItemAddress + 3, amountRev);

            sendPacket(dropItemAddressRev, packetSize);
        }




        //Swap item in equip

        private int swapItemInEquipAddress;
        private byte[] swapItemInEquipAddressRev;
   
        private byte[] swapItemInEquipPkt = new byte[] 
        { 
            0x10, 0x00,                 //Header
            0x00,                       //itemEquipIndex 1
            0x00                        //itemEquipIndex 2
        };

        public void swapItemInEquip(byte equipIndex1, byte equipIndex2)
        {
            //Get size of the packet
            int packetSize = swapItemInEquipPkt.Length;

            if (swapItemInEquipAddress == 0)
            {
                //load packet in memory
                loadPacket(swapItemInEquipPkt, ref swapItemInEquipAddress, ref swapItemInEquipAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, swapItemInEquipAddress + 2, equipIndex1);
            MemFunctions.MemWriteByte(pr_processHandle, swapItemInEquipAddress + 3, equipIndex2);

            sendPacket(swapItemInEquipAddressRev, packetSize);
        }




        //Swap equipment with inventory

        private int swapEquipWithInvAddress;
        private byte[] swapEquipWithInvAddressRev;
   
        private byte[] swapEquipWithInvPkt = new byte[] 
        { 
            0x11, 0x00,                 //Header
            0x00,                       //invIndex 
            0x00                        //equipIndex
        };

        public void swapEquipWithInv(byte invIndex, byte equipIndex)
        {
            //Get size of the packet
            int packetSize = swapEquipWithInvPkt.Length;

            if (swapEquipWithInvAddress == 0)
            {
                //load packet in memory
                loadPacket(swapEquipWithInvPkt, ref swapEquipWithInvAddress, ref swapEquipWithInvAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, swapEquipWithInvAddress + 2, invIndex);
            MemFunctions.MemWriteByte(pr_processHandle, swapEquipWithInvAddress + 3, equipIndex);

            sendPacket(swapEquipWithInvAddressRev, packetSize);
        }




        //Drop gold

        private int dropGoldAddress;
        private byte[] dropGoldAddressRev;
   
        private byte[] dropGoldPkt = new byte[] 
        { 
            0x14, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00     //amount
        };

        public void dropGold(int amount)
        {
            //Get size of the packet
            int packetSize = dropGoldPkt.Length;

            if (dropGoldAddress == 0)
            {
                //load packet in memory
                loadPacket(dropGoldPkt, ref dropGoldAddress, ref dropGoldAddressRev);
            }

            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, dropGoldAddress + 2, amountRev);
            sendPacket(dropGoldAddressRev, packetSize);
        }




        //Update stats

        private int updateStatsAddress;
        private byte[] updateStatsAddressRev;
   
        private byte[] updateStatsPkt = new byte[] 
        { 
            0x15, 0x00                 //Header
        };

        public void updateStats()
        {
            //Get size of the packet
            int packetSize = updateStatsPkt.Length;

            if (updateStatsAddress == 0)
            {
                //load packet in memory
                loadPacket(updateStatsPkt, ref updateStatsAddress, ref updateStatsAddressRev);
            }

            sendPacket(updateStatsAddressRev, packetSize);
        }




        //Increase stats

        private int increaseStatsByAddress;
        private byte[] increaseStatsByAddressRev;
   
        private byte[] increaseStatsByPkt = new byte[] 
        { 
            0x16, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //con
            0x00, 0x00, 0x00, 0x00,     //int
            0x00, 0x00, 0x00, 0x00,     //str
            0x00, 0x00, 0x00, 0x00      //agi
        };

        public void increaseStatsBy(int constitution, int intelligence, int strength, int agility)
        {
            //Get size of the packet
            int packetSize = increaseStatsByPkt.Length;

            if (increaseStatsByAddress == 0)
            {
                //load packet in memory
                loadPacket(increaseStatsByPkt, ref increaseStatsByAddress, ref increaseStatsByAddressRev);
            }

            byte[] constitutionRev = BitConverter.GetBytes(constitution);
            constitutionRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, increaseStatsByAddress + 2, constitutionRev);
            byte[] intelligenceRev = BitConverter.GetBytes(intelligence);
            intelligenceRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, increaseStatsByAddress + 6, intelligenceRev);
            byte[] strengthRev = BitConverter.GetBytes(strength);
            strengthRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, increaseStatsByAddress + 10, strengthRev);
            byte[] agilityRev = BitConverter.GetBytes(agility);
            agilityRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, increaseStatsByAddress + 14, agilityRev);


            sendPacket(increaseStatsByAddressRev, packetSize);
        }




        //Invite to party

        private int invitePartyAddress;
        private byte[] invitePartyAddressRev;
   
        private byte[] invitePartyPkt = new byte[] 
        { 
            0x1B, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00     //playerId
        };

        public void inviteParty(int playerId)
        {
            //Get size of the packet
            int packetSize = invitePartyPkt.Length;

            if (invitePartyAddress == 0)
            {
                //load packet in memory
                loadPacket(invitePartyPkt, ref invitePartyAddress, ref invitePartyAddressRev);
            }

            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, invitePartyAddress + 2, playerIdRev);

            sendPacket(invitePartyAddressRev, packetSize);
        }




        //Accept party invite

        private int acceptPartyInviteAddress;
        private byte[] acceptPartyInviteAddressRev;
   
        private byte[] acceptPartyInvitePkt = new byte[] 
        { 
            0x1C, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //playerId
            0x00, 0x00, 0x00, 0x00      //partyInviteCounter
        };

        public void acceptPartyInvite(int playerId, int partyInviteCounter)
        {
            //Get size of the packet
            int packetSize = acceptPartyInvitePkt.Length;

            if (acceptPartyInviteAddress == 0)
            {
                //load packet in memory
                loadPacket(acceptPartyInvitePkt, ref acceptPartyInviteAddress, ref acceptPartyInviteAddressRev);
            }
            
            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, acceptPartyInviteAddress + 2, playerIdRev);

            byte[] partyInviteCounterRev = BitConverter.GetBytes(partyInviteCounter);
            partyInviteCounterRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, acceptPartyInviteAddress + 6, partyInviteCounterRev);
        

            sendPacket(acceptPartyInviteAddressRev, packetSize);
        }



        //Refuse party invite

        private int refusePartyInviteAddress;
        private byte[] refusePartyInviteAddressRev;
   
        private byte[] refusePartyInvitePkt = new byte[] 
        { 
            0x1D, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00     //playerId
        };

        public void refusePartyInvite(int playerId)
        {
            //Get size of the packet
            int packetSize = refusePartyInvitePkt.Length;

            if (refusePartyInviteAddress == 0)
            {
                //load packet in memory
                loadPacket(refusePartyInvitePkt, ref refusePartyInviteAddress, ref refusePartyInviteAddressRev);
            }
            
            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, refusePartyInviteAddress + 2, playerIdRev);
            
            sendPacket(refusePartyInviteAddressRev, packetSize);
        }



        //Leave party

        private int leavePartyAddress;
        private byte[] leavePartyAddressRev;
   
        private byte[] leavePartyPkt = new byte[] 
        { 
            0x1E, 0x00                 //Header
        };

        public void leaveParty()
        {
            //Get size of the packet
            int packetSize = leavePartyPkt.Length;

            if (leavePartyAddress == 0)
            {
                //load packet in memory
                loadPacket(leavePartyPkt, ref leavePartyAddress, ref leavePartyAddressRev);
            }

            sendPacket(leavePartyAddressRev, packetSize);
        }



        //Evict from party

        private int evictFromPartyAddress;
        private byte[] evictFromPartyAddressRev;
   
        private byte[] evictFromPartyPkt = new byte[] 
        { 
            0x1F, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00     //playerId
        };

        public void evictFromParty(int playerId)
        {
            //Get size of the packet
            int packetSize = evictFromPartyPkt.Length;

            if (evictFromPartyAddress == 0)
            {
                //load packet in memory
                loadPacket(evictFromPartyPkt, ref evictFromPartyAddress, ref evictFromPartyAddressRev);
            }

            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, evictFromPartyAddress + 2, playerIdRev);

            sendPacket(evictFromPartyAddressRev, packetSize);
        }



        //Start NPC dialogue

        private int startNpcDialogueAddress;
        private byte[] startNpcDialogueAddressRev;
   
        private byte[] startNpcDialoguePkt = new byte[] 
        { 
            0x23, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00     //npcId
        };

        public void startNpcDialogue(int npcId)
        {
            //Get size of the packet
            int packetSize = startNpcDialoguePkt.Length;

            if (startNpcDialogueAddress == 0)
            {
                //load packet in memory
                loadPacket(startNpcDialoguePkt, ref startNpcDialogueAddress, ref startNpcDialogueAddressRev);
            }
            byte[] npcIdRev = BitConverter.GetBytes(npcId);
            npcIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, startNpcDialogueAddress + 2, npcIdRev);

            sendPacket(startNpcDialogueAddressRev, packetSize);
        }



        //Use item

        private int useItemAddress;
        private byte[] useItemAddressRev;
   
        private byte[] useItemPkt = new byte[] 
        { 
            0x28, 0x00,                 //Header
            0x00,                       //isEquip
            0x01,                       
            0x00,                       //itemIndex
            0x00,
            0x00, 0x00, 0x00, 0x00      //typeId
        };

        public void useItem(byte isEquip, byte itemIndex, int typeId)
        {
            //Get size of the packet
            int packetSize = useItemPkt.Length;

            if (useItemAddress == 0)
            {
                //load packet in memory
                loadPacket(useItemPkt, ref useItemAddress, ref useItemAddressRev);
            }


            MemFunctions.MemWriteByte(pr_processHandle, useItemAddress + 2, isEquip);
            MemFunctions.MemWriteByte(pr_processHandle, useItemAddress + 4, itemIndex);

            
            byte[] typeIdRev = BitConverter.GetBytes(typeId);
            typeIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, useItemAddress + 6, typeIdRev);




            sendPacket(useItemAddressRev, packetSize);
        }



        //Use skill

        private int useSkillddress;
        private byte[] useSkillAddressRev;
   
        private byte[] useSkillPkt = new byte[] 
        { 
            0x29, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //skillId
            0x00, 0x01,
            0x00, 0x00, 0x00, 0x00      //targetId
        };

        public void useSkill(int skillId, int targetId)
        {
            //Get size of the packet
            int packetSize = useSkillPkt.Length;

            if (useSkillddress == 0)
            {
                //load packet in memory
                loadPacket(useSkillPkt, ref useSkillddress, ref useSkillAddressRev);
            }

            byte[] skillIdRev = BitConverter.GetBytes(skillId);
            skillIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, useSkillddress + 2, skillIdRev);
            
            byte[] targetIdRev = BitConverter.GetBytes(targetId);
            targetIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, useSkillddress + 8, targetIdRev);


            sendPacket(useSkillAddressRev, packetSize);
        }



        //Cancel action

        private int cancelActionAddress;
        private byte[] cancelActionAddressRev;
   
        private byte[] cancelActionPkt = new byte[] 
        { 
            0x2A, 0x00                 //Header
        };

        public void cancelAction()
        {
            //Get size of the packet
            int packetSize = cancelActionPkt.Length;

            if (cancelActionAddress == 0)
            {
                //load packet in memory
                loadPacket(cancelActionPkt, ref cancelActionAddress, ref cancelActionAddressRev);
            }

            sendPacket(cancelActionAddressRev, packetSize);
        }



        //Start meditating

        private int startMeditatingAddress;
        private byte[] startMeditatingAddressRev;
   
        private byte[] startMeditatingPkt = new byte[] 
        { 
            0x2E, 0x00,                 //Header
        };

        public void startMeditating()
        {
            //Get size of the packet
            int packetSize = startMeditatingPkt.Length;

            if (startMeditatingAddress == 0)
            {
                //load packet in memory
                loadPacket(startMeditatingPkt, ref startMeditatingAddress, ref startMeditatingAddressRev);
            }

            sendPacket(startMeditatingAddressRev, packetSize);
        }



        //Stop meditating

        private int stopMeditatingAddress;
        private byte[] stopMeditatingAddressRev;
   
        private byte[] stopMeditatingPkt = new byte[] 
        { 
            0x2F, 0x00,                 //Header
        };

        public void stopMeditating()
        {
            //Get size of the packet
            int packetSize = stopMeditatingPkt.Length;

            if (stopMeditatingAddress == 0)
            {
                //load packet in memory
                loadPacket(stopMeditatingPkt, ref stopMeditatingAddress, ref stopMeditatingAddressRev);
            }

            sendPacket(stopMeditatingAddressRev, packetSize);
        }



        //Use emotion

        private int useEmotionAddress;
        private byte[] useEmotionAddressRev;
   
        private byte[] useEmotionPkt = new byte[] 
        { 
            0x30, 0x00,                 //Header
            0x00, 0x00                  //EmoteId
        };

        public void useEmotion(short emoteId)
        {
            //Get size of the packet
            int packetSize = useEmotionPkt.Length;

            if (useEmotionAddress == 0)
            {
                //load packet in memory
                loadPacket(useEmotionPkt, ref useEmotionAddress, ref useEmotionAddressRev);
            }

            byte[] emoteIdRev = BitConverter.GetBytes(emoteId);
            emoteIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, useEmotionAddress, emoteIdRev);


            sendPacket(useEmotionAddressRev, packetSize);
        }



        //Be intimate

        private int beIntimateAddress;
        private byte[] beIntimateAddressRev;
   
        private byte[] beIntimatePkt = new byte[] 
        { 
            0x30, 0x00,                 //Header
            0x1D, 0x00                  //intimateId
        };

        public void beIntimate()
        {
            //Get size of the packet
            int packetSize = beIntimatePkt.Length;

            if (beIntimateAddress == 0)
            {
                //load packet in memory
                loadPacket(beIntimatePkt, ref beIntimateAddress, ref beIntimateAddressRev);
            }

            sendPacket(beIntimateAddressRev, packetSize);
        }




        //Harvest resource

        private int harvestResourceAddress;
        private byte[] harvestResourceAddressRev;
   

        private byte[] harvestResourcePkt = new byte[] 
        { 
            0x36, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //uniqueId
            0x00, 0x00, 0x1E, 0x00,     
            0x01, 0x0C, 0x00, 0x00,     
            0x00, 0x00, 0x00, 0x00    

        };

        public void harvestResource(int uniqueId)
        {
            //Get size of the packet
            int packetSize = harvestResourcePkt.Length;

            if (harvestResourceAddress == 0)
            {
                //load packet in memory
                loadPacket(harvestResourcePkt, ref harvestResourceAddress, ref harvestResourceAddressRev);
            }

            byte[] uniqueIdRev = BitConverter.GetBytes(uniqueId);
            uniqueIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, harvestResourceAddress + 2, uniqueIdRev);

            sendPacket(harvestResourceAddressRev, packetSize);
        }




        //Swap item in bank

        private int swapItemInBankAddress;
        private byte[] swapItemInBankAddressRev;
        private byte[] swapItemInBankPkt = new byte[] 
        { 
            0x38, 0x00,                 //Header
            0x03, 
            0x00,                       //bankIndex1
            0x00                        //bankIndex2
        };

        public void swapItemInBank(byte bankIndex1, byte bankIndex2)
        {
            //Get size of the packet
            int packetSize = swapItemInBankPkt.Length;

            if (swapItemInBankAddress == 0)
            {
                //load packet in memory
                loadPacket(swapItemInBankPkt, ref swapItemInBankAddress, ref swapItemInBankAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, swapEquipWithInvAddress + 3, bankIndex1);
            MemFunctions.MemWriteByte(pr_processHandle, swapEquipWithInvAddress + 4, bankIndex2);


            sendPacket(swapItemInBankAddressRev, packetSize);
        }




        //Split item in bank

        private int splitStackItemInBankAddress;
        private byte[] splitStackItemInBankAddressRev;
        private byte[] splitStackItemInBankPkt = new byte[] 
        { 
            0x39, 0x00,                 //Header
            0x03,
            0x00,                       //bankIndexSource
            0x00,                       //bankIndexDestination
            0x00, 0x00                  //amount
        };

        public void splitStackItemInBank(byte bankIndexSource, byte bankIndexDestination, short amount)
        {
            //Get size of the packet
            int packetSize = splitStackItemInBankPkt.Length;

            if (splitStackItemInBankAddress == 0)
            {
                //load packet in memory
                loadPacket(splitStackItemInBankPkt, ref splitStackItemInBankAddress, ref splitStackItemInBankAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, splitStackItemInBankAddress + 3, bankIndexSource);
            MemFunctions.MemWriteByte(pr_processHandle, splitStackItemInBankAddress + 4, bankIndexSource);
            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, splitStackItemInBankAddress + 5, amountRev);

            sendPacket(splitStackItemInBankAddressRev, packetSize);
        }




        //Swap item between bank and inv

        private int swapItemBankAndInvAddress;
        private byte[] swapItemBankAndInvAddressRev;
        private byte[] swapItemBankAndInvPkt = new byte[] 
        { 
            0x3A, 0x00,                 //Header
            0x03, 
            0x00,                       //bankIndex
            0x00,                       //invIndex
        };

        public void swapItemBankAndInv(byte bankIndex, byte invIndex)
        {
            //Get size of the packet
            int packetSize = swapItemBankAndInvPkt.Length;

            if (swapItemBankAndInvAddress == 0)
            {
                //load packet in memory
                loadPacket(swapItemBankAndInvPkt, ref swapItemBankAndInvAddress, ref swapItemBankAndInvAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, swapItemBankAndInvAddress + 3, bankIndex);
            MemFunctions.MemWriteByte(pr_processHandle, swapItemBankAndInvAddress + 4, invIndex);

            sendPacket(swapItemBankAndInvAddressRev, packetSize);
        }




        //Split stack from bank to inventory

        private int splitStackItemInBankToInvAddress;
        private byte[] splitStackItemInBankToInvAddressRev;
        private byte[] splitStackItemInBankToInvPkt = new byte[] 
        { 
            0x3B, 0x00,                 //Header
            0x00,
            0x00,                       //bankIndex
            0x00,                       //invIndex
            0x00, 0x00                  //amount
        };

        public void splitStackItemInBankToInv(byte bankIndex, byte invIndex, short amount)
        {
            //Get size of the packet
            int packetSize = splitStackItemInBankToInvPkt.Length;

            if (splitStackItemInBankToInvAddress == 0)
            {
                //load packet in memory
                loadPacket(splitStackItemInBankToInvPkt, ref splitStackItemInBankToInvAddress, ref splitStackItemInBankToInvAddressRev);
            }
            MemFunctions.MemWriteByte(pr_processHandle, splitStackItemInBankToInvAddress + 3, bankIndex);
            MemFunctions.MemWriteByte(pr_processHandle, splitStackItemInBankToInvAddress + 4, invIndex);
            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, splitStackItemInBankToInvAddress + 5, amountRev);

            sendPacket(splitStackItemInBankToInvAddressRev, packetSize);
        }


      

        //Split stack from bank to inventory

        private int splitStackItemInInvToBankAddress;
        private byte[] splitStackItemInInvToBankAddressRev;
        private byte[] splitStackItemInInvToBankPkt = new byte[] 
        { 
            0x3B, 0x00,                 //Header
            0x00,
            0x00,                       //bankIndex
            0x00,                       //invIndex
            0x00, 0x00                  //amount
        };

        public void splitStackItemInInvToBank(byte invIndex, byte bankIndex, short amount)
        {
            //Get size of the packet
            int packetSize = splitStackItemInInvToBankPkt.Length;

            if (splitStackItemInInvToBankAddress == 0)
            {
                //load packet in memory
                loadPacket(splitStackItemInInvToBankPkt, ref splitStackItemInInvToBankAddress, ref splitStackItemInInvToBankAddressRev);
            }
            MemFunctions.MemWriteByte(pr_processHandle, splitStackItemInInvToBankAddress + 3, invIndex);
            MemFunctions.MemWriteByte(pr_processHandle, splitStackItemInInvToBankAddress + 4, bankIndex);
            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, splitStackItemInInvToBankAddress + 5, amountRev);

            sendPacket(splitStackItemInInvToBankAddressRev, packetSize);
        }




        //Set party search settings

        private int setPartySearchSettingsAddress;
        private byte[] setPartySearchSettingsAddressRev;
        private byte[] setPartySearchSettingsPkt = new byte[] 
        { 
            0x3F, 0x00,                 //Header
            0x00,                       //jobId
            0x00,                       //lvl
            0x00,                       //recruit
            0x00,                       //slogan
            0x00, 0x00, 0x00, 0x00      
        };


        public void setPartySearchSettings(byte jobId, byte lvl, byte recruit, byte slogan)
        {
            //Get size of the packet
            int packetSize = setPartySearchSettingsPkt.Length;

            if (setPartySearchSettingsAddress == 0)
            {
                //load packet in memory
                loadPacket(setPartySearchSettingsPkt, ref setPartySearchSettingsAddress, ref setPartySearchSettingsAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, setPartySearchSettingsAddress + 2, jobId);
            MemFunctions.MemWriteByte(pr_processHandle, setPartySearchSettingsAddress + 3, lvl);
            MemFunctions.MemWriteByte(pr_processHandle, setPartySearchSettingsAddress + 4, recruit);
            MemFunctions.MemWriteByte(pr_processHandle, setPartySearchSettingsAddress + 5, slogan);


            sendPacket(setPartySearchSettingsAddressRev, packetSize);
        }




        //Change party captain

        private int shiftPartyCaptainAddress;
        private byte[] shiftPartyCaptainAddressRev;
        private byte[] shiftPartyCaptainPkt = new byte[] 
        { 
            0x48, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00     //playerId
        };

        public void shiftPartyCaptain(int playerId)
        {
            //Get size of the packet
            int packetSize = shiftPartyCaptainPkt.Length;

            if (shiftPartyCaptainAddress == 0)
            {
                //load packet in memory
                loadPacket(shiftPartyCaptainPkt, ref shiftPartyCaptainAddress, ref shiftPartyCaptainAddressRev);
            }

            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, shiftPartyCaptainAddress + 2, playerIdRev);

            sendPacket(shiftPartyCaptainAddressRev, packetSize);
        }




        //Use skill with no cast time

        private int useSkillWithoutCastTimeAddress;
        private byte[] useSkillWithoutCastTimeAddressRev;
        private byte[] useSkillWithoutCastTimePkt = new byte[] 
        { 
            0x50, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //skillId
            0x00, 0x01,
            0x00, 0x00, 0x00, 0x00      //targetId
        };

        public void useSkillWithoutCastTime(int skillId, int targetId)
        {
            //Get size of the packet
            int packetSize = useSkillWithoutCastTimePkt.Length;

            if (useSkillWithoutCastTimeAddress == 0)
            {
                //load packet in memory
                loadPacket(useSkillWithoutCastTimePkt, ref useSkillWithoutCastTimeAddress, ref useSkillWithoutCastTimeAddressRev);
            }

            byte[] skillIdRev = BitConverter.GetBytes(skillId);
            skillIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, useSkillWithoutCastTimeAddress + 2, skillIdRev);

            byte[] targetIdRev = BitConverter.GetBytes(targetId);
            targetIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, useSkillWithoutCastTimeAddress + 8, targetIdRev);


            sendPacket(useSkillWithoutCastTimeAddressRev, packetSize);
        }




        //Initiate setting up cat shop

        private int initiateSettingUpCatShopAddress;
        private byte[] initiateSettingUpCatShopAddressRev;
        private byte[] initiateSettingUpCatShopPkt = new byte[] 
        { 
            0x54, 0x00,                 //Header
        };

        public void initiateSettingUpCatShop()
        {
            //Get size of the packet
            int packetSize = initiateSettingUpCatShopPkt.Length;

            if (initiateSettingUpCatShopAddress == 0)
            {
                //load packet in memory
                loadPacket(initiateSettingUpCatShopPkt, ref initiateSettingUpCatShopAddress, ref initiateSettingUpCatShopAddressRev);
            }

            sendPacket(initiateSettingUpCatShopAddressRev, packetSize);
        }




        //Toggle fashion

        private int toggleFashionDisplayAddress;
        private byte[] toggleFashionDisplayAddressRev;
        private byte[] toggleFashionDisplayPkt = new byte[] 
        { 
            0x55, 0x00,                 //Header
        };

        public void toggleFashionDisplay()
        {
            //Get size of the packet
            int packetSize = toggleFashionDisplayPkt.Length;

            if (toggleFashionDisplayAddress == 0)
            {
                //load packet in memory
                loadPacket(toggleFashionDisplayPkt, ref toggleFashionDisplayAddress, ref toggleFashionDisplayAddressRev);
            }

            sendPacket(toggleFashionDisplayAddressRev, packetSize);
        }




        //acceptRessurectByCleric

        private int acceptRessurectByClericAddress;
        private byte[] acceptRessurectByClericAddressRev;
        private byte[] acceptRessurectByClericPkt = new byte[] 
        { 
            0x57, 0x00,                 //Header
        };

        public void acceptRessurectByCleric()
        {
            //Get size of the packet
            int packetSize = acceptRessurectByClericPkt.Length;

            if (acceptRessurectByClericAddress == 0)
            {
                //load packet in memory
                loadPacket(acceptRessurectByClericPkt, ref acceptRessurectByClericAddress, ref acceptRessurectByClericAddressRev);
            }

            sendPacket(acceptRessurectByClericAddressRev, packetSize);
        }




        //Increase fly speed

        private int increaseFlySpeedAddress;
        private byte[] increaseFlySpeedAddressRev;
        private byte[] increaseFlySpeedPkt = new byte[] 
        { 
            0x5A, 0x00,                 //Header
        };

        public void increaseFlySpeed()
        {
            //Get size of the packet
            int packetSize = increaseFlySpeedPkt.Length;

            if (increaseFlySpeedAddress == 0)
            {
                //load packet in memory
                loadPacket(increaseFlySpeedPkt, ref increaseFlySpeedAddress, ref increaseFlySpeedAddressRev);
            }

            sendPacket(increaseFlySpeedAddressRev, packetSize);
        }




        //Invite to duel

        private int inviteToDuelAddress;
        private byte[] inviteToDuelAddressRev;
        private byte[] inviteToDuelPkt = new byte[] 
        { 
            0x5C, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //playerId
        };

        public void inviteToDuel(int playerId)
        {
            //Get size of the packet
            int packetSize = inviteToDuelPkt.Length;

            if (inviteToDuelAddress == 0)
            {
                //load packet in memory
                loadPacket(inviteToDuelPkt, ref inviteToDuelAddress, ref inviteToDuelAddressRev);
            }

            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, inviteToDuelAddress + 2, playerIdRev);

            sendPacket(inviteToDuelAddressRev, packetSize);
        }




        //Regular Attack

        private int acceptDuelAddress;
        private byte[] acceptDuelAddressRev;
        private byte[] acceptDuelPkt = new byte[] 
        { 
            0x5D, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //playerId
        };

        public void acceptDuel(int playerId)
        {
            //Get size of the packet
            int packetSize = acceptDuelPkt.Length;

            if (acceptDuelAddress == 0)
            {
                //load packet in memory
                loadPacket(acceptDuelPkt, ref acceptDuelAddress, ref acceptDuelAddressRev);
            }
            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, acceptDuelAddress + 2, playerIdRev);
            sendPacket(acceptDuelAddressRev, packetSize);
        }




        //Ask male to carry you

        private int askMaleToCarryAddress;
        private byte[] askMaleToCarryAddressRev;
        private byte[] askMaleToCarryPkt = new byte[] 
        { 
            0x5E, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //playerId
        };

        public void askMaleToCarry(int playerId)
        {
            //Get size of the packet
            int packetSize = askMaleToCarryPkt.Length;

            if (askMaleToCarryAddress == 0)
            {
                //load packet in memory
                loadPacket(askMaleToCarryPkt, ref askMaleToCarryAddress, ref askMaleToCarryAddressRev);
            }
            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, askMaleToCarryAddress + 2, playerIdRev);
            sendPacket(askMaleToCarryAddressRev, packetSize);
        }




        //askFemaleToBeCarried

        private int askFemaleToBeCarriedAddress;
        private byte[] askFemaleToBeCarriedAddressRev;
        private byte[] askFemaleToBeCarriedPkt = new byte[] 
        { 
            0x5F, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //playerId
        };

        public void askFemaleToBeCarried(int playerId)
        {
            //Get size of the packet
            int packetSize = askFemaleToBeCarriedPkt.Length;

            if (askFemaleToBeCarriedAddress == 0)
            {
                //load packet in memory
                loadPacket(askFemaleToBeCarriedPkt, ref askFemaleToBeCarriedAddress, ref askFemaleToBeCarriedAddressRev);
            }
            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, askFemaleToBeCarriedAddress + 2, playerIdRev);
            sendPacket(askFemaleToBeCarriedAddressRev, packetSize);
        }




        //acceptRequestByFemaleToBeCarried

        private int acceptRequestByFemaleToBeCarriedAddress;
        private byte[] acceptRequestByFemaleToBeCarriedAddressRev;
        private byte[] acceptRequestByFemaleToBeCarriedPkt = new byte[] 
        { 
            0x60, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //playerId
            0x00, 0x00, 0x00, 0x00      
        };

        public void acceptRequestByFemaleToBeCarried(int playerId)
        {
            //Get size of the packet
            int packetSize = acceptRequestByFemaleToBeCarriedPkt.Length;

            if (acceptRequestByFemaleToBeCarriedAddress == 0)
            {
                //load packet in memory
                loadPacket(acceptRequestByFemaleToBeCarriedPkt, ref acceptRequestByFemaleToBeCarriedAddress, ref acceptRequestByFemaleToBeCarriedAddressRev);
            }
            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, acceptRequestByFemaleToBeCarriedAddress + 2, playerIdRev);
            sendPacket(acceptRequestByFemaleToBeCarriedAddressRev, packetSize);
        }




        //acceptRequestByMaleToCarryYou

        private int acceptRequestByMaleToCarryYouAddress;
        private byte[] acceptRequestByMaleToCarryYouAddressRev;
        private byte[] acceptRequestByMaleToCarryYouPkt = new byte[] 
        { 
            0x61, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //uniqueId
            0x00, 0x00, 0x00, 0x00      //typeId
        };

        public void acceptRequestByMaleToCarryYou(int playerId)
        {
            //Get size of the packet
            int packetSize = acceptRequestByMaleToCarryYouPkt.Length;

            if (acceptRequestByMaleToCarryYouAddress == 0)
            {
                //load packet in memory
                loadPacket(acceptRequestByMaleToCarryYouPkt, ref acceptRequestByMaleToCarryYouAddress, ref acceptRequestByMaleToCarryYouAddressRev);
            }
            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, acceptRequestByMaleToCarryYouAddress + 2, playerIdRev);
            sendPacket(acceptRequestByMaleToCarryYouAddressRev, packetSize);
        }




        //Regular Attack

        private int releaseCarryModeAddress;
        private byte[] releaseCarryModeAddressRev;
        private byte[] releaseCarryModePkt = new byte[] 
        { 
            0x62, 0x00,                 //Header
        };

        public void releaseCarryMode()
        {
            //Get size of the packet
            int packetSize = releaseCarryModePkt.Length;

            if (releaseCarryModeAddress == 0)
            {
                //load packet in memory
                loadPacket(releaseCarryModePkt, ref releaseCarryModeAddress, ref releaseCarryModeAddressRev);
            }

            sendPacket(releaseCarryModeAddressRev, packetSize);
        }




        //viewPlayerEquip

        private int viewPlayerEquipAddress;
        private byte[] viewPlayerEquipAddressRev;
        private byte[] viewPlayerEquipPkt = new byte[] 
        { 
            0x63, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //playerId
        };

        public void viewPlayerEquip(int playerId)
        {
            //Get size of the packet
            int packetSize = viewPlayerEquipPkt.Length;

            if (viewPlayerEquipAddress == 0)
            {
                //load packet in memory
                loadPacket(viewPlayerEquipPkt, ref viewPlayerEquipAddress, ref viewPlayerEquipAddressRev);
            }
            byte[] playerIdRev = BitConverter.GetBytes(playerId);
            playerIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, viewPlayerEquipAddress + 2, playerIdRev);
            sendPacket(viewPlayerEquipAddressRev, packetSize);
        }




        //Regular Attack

        private int summonPetAddress;
        private byte[] summonPetAddressRev;
        private byte[] summonPetPkt = new byte[] 
        { 
            0x64, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //petIndex
        };

        public void summonPet(int petIndex)
        {
            //Get size of the packet
            int packetSize = summonPetPkt.Length;

            if (summonPetAddress == 0)
            {
                //load packet in memory
                loadPacket(summonPetPkt, ref summonPetAddress, ref summonPetAddressRev);
            }
            byte[] petIndexRev = BitConverter.GetBytes(petIndex);
            petIndexRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, summonPetAddress + 2, petIndexRev);
            sendPacket(summonPetAddressRev, packetSize);
        }




        //Regular Attack

        private int recallPetAddress;
        private byte[] recallPetAddressRev;
        private byte[] recallPetPkt = new byte[] 
        { 
            0x65, 0x00,                 //Header
        };

        public void recallPet()
        {
            //Get size of the packet
            int packetSize = recallPetPkt.Length;

            if (recallPetAddress == 0)
            {
                //load packet in memory
                loadPacket(recallPetPkt, ref recallPetAddress, ref recallPetAddressRev);
            }

            sendPacket(recallPetAddressRev, packetSize);
        }

 

        //Regular Attack

        private int setPetModeAddress;
        private byte[] setPetModeAddressRev;
        private byte[] setPetModePkt = new byte[] 
        { 
            0x67, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,    
            0x03, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00      //petMode
        };

        public void setPetMode(int petMode)
        {
            //Get size of the packet
            int packetSize = setPetModePkt.Length;

            if (setPetModeAddress == 0)
            {
                //load packet in memory
                loadPacket(setPetModePkt, ref setPetModeAddress, ref setPetModeAddressRev);
            }

            byte[] petModeRev = BitConverter.GetBytes(petMode);
            petModeRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, setPetModeAddress + 10, petModeRev);

            sendPacket(setPetModeAddressRev, packetSize);
        }




        //Regular Attack

        private int setPetFollowAddress;
        private byte[] setPetFollowAddressRev;
        private byte[] setPetFollowPkt = new byte[] 
        { 
            0x67, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     
            0x02, 0x00, 0x00, 0x00,      
            0x00, 0x00, 0x00, 0x00
        };

        public void setPetFollow()
        {
            //Get size of the packet
            int packetSize = setPetFollowPkt.Length;

            if (setPetFollowAddress == 0)
            {
                //load packet in memory
                loadPacket(setPetFollowPkt, ref setPetFollowAddress, ref setPetFollowAddressRev);
            }

            sendPacket(setPetFollowAddressRev, packetSize);
        }

                              


        //Regular Attack

        private int setPetStopAddress;
        private byte[] setPetStopAddressRev;
        private byte[] setPetStopPkt = new byte[] 
        { 
            0x67, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     
            0x02, 0x00, 0x00, 0x00,      
            0x01, 0x00, 0x00, 0x00
        };

        public void setPetStop()
        {
            //Get size of the packet
            int packetSize = setPetStopPkt.Length;

            if (setPetStopAddress == 0)
            {
                //load packet in memory
                loadPacket(setPetStopPkt, ref setPetStopAddress, ref setPetStopAddressRev);
            }

            sendPacket(setPetStopAddressRev, packetSize);
        }




        //Regular Attack

        private int setPetAttackAddress;
        private byte[] setPetAttackAddressRev;
        private byte[] setPetAttackPkt = new byte[] 
        { 
            0x67, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //targetId
            0x01,
            0x00, 0x00, 0x00, 0x00      
        };

        public void setPetAttack(int targetId)
        {
            //Get size of the packet
            int packetSize = setPetAttackPkt.Length;

            if (setPetAttackAddress == 0)
            {
                //load packet in memory
                loadPacket(setPetAttackPkt, ref setPetAttackAddress, ref setPetAttackAddressRev);
            }

            byte[] targetIdRev = BitConverter.GetBytes(targetId);
            targetIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, setPetAttackAddress + 2, targetIdRev);

            sendPacket(setPetAttackAddressRev, packetSize);
        }




        //Regular Attack

        private int setPetUseSkillAddress;
        private byte[] setPetUseSkillAddressRev;
        private byte[] setPetUseSkillPkt = new byte[] 
        { 
            0x67, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     //targetId
            0x04, 0x00, 0x00, 0x00,     
            0x00, 0x00, 0x00, 0x00,     //skillId
            0x00      
        };

        public void setPetUseSkill(int targetId, int skillId)
        {
            //Get size of the packet
            int packetSize = setPetUseSkillPkt.Length;

            if (setPetUseSkillAddress == 0)
            {
                //load packet in memory
                loadPacket(setPetUseSkillPkt, ref setPetUseSkillAddress, ref setPetUseSkillAddressRev);
            }

            byte[] targetIdRev = BitConverter.GetBytes(targetId);
            targetIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, setPetUseSkillAddress + 2, targetIdRev);

            byte[] skillIdRev = BitConverter.GetBytes(skillId);
            skillIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, setPetUseSkillAddress + 10, skillIdRev);



            sendPacket(setPetUseSkillAddressRev, packetSize);
        }




        //Regular Attack

        private int setPetStandardSkillAddress;
        private byte[] setPetStandardSkillAddressRev;
        private byte[] setPetStandardSkillPkt = new byte[] 
        { 
            0x67, 0x00,                 //Header
            0x00, 0x00, 0x00, 0x00,     
            0x05, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00      //skillId
        };

        public void setPetStandardSkill(int skillId)
        {
            //Get size of the packet
            int packetSize = setPetStandardSkillPkt.Length;

            if (setPetStandardSkillAddress == 0)
            {
                //load packet in memory
                loadPacket(setPetStandardSkillPkt, ref setPetStandardSkillAddress, ref setPetStandardSkillAddressRev);
            }

            byte[] skillIdRev = BitConverter.GetBytes(skillId);
            skillIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, setPetStandardSkillAddress + 10, skillIdRev);

            sendPacket(setPetStandardSkillAddressRev, packetSize);
        }




        //Regular Attack

        private int useGenieSkillAddress;
        private byte[] useGenieSkillAddressRev;
        private byte[] useGenieSkillPkt = new byte[] 
        { 
            0x74, 0x00,                 //Header
            0x00, 0x00,                 //skillId
            0x00, 0x01,     
            0x00, 0x00, 0x00, 0x00      //targetId
        };

        public void useGenieSkill(short skillId, int targetId)
        {
            //Get size of the packet
            int packetSize = useGenieSkillPkt.Length;

            if (useGenieSkillAddress == 0)
            {
                //load packet in memory
                loadPacket(useGenieSkillPkt, ref useGenieSkillAddress, ref useGenieSkillAddressRev);
            }

            byte[] skillIdRev = BitConverter.GetBytes(skillId);
            skillIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, useGenieSkillAddress + 2, skillIdRev);

            byte[] targetIdRev = BitConverter.GetBytes(targetId);
            targetIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, useGenieSkillAddress + 6, targetIdRev);

            sendPacket(useGenieSkillAddressRev, packetSize);
        }



        //Regular Attack

        private int feedEquippedGenieAddress;
        private byte[] feedEquippedGenieAddressRev;
        private byte[] feedEquippedGeniePkt = new byte[] 
        { 
            0x75, 0x00,                 //Header
            0x00,                        //invIndex
            0x00, 0x00, 0x00, 0x00      //amount
        };

        public void feedEquippedGenie(byte invIndex, int amount)
        {
            //Get size of the packet
            int packetSize = feedEquippedGeniePkt.Length;

            if (feedEquippedGenieAddress == 0)
            {
                //load packet in memory
                loadPacket(feedEquippedGeniePkt, ref feedEquippedGenieAddress, ref feedEquippedGenieAddressRev);
            }

            MemFunctions.MemWriteByte(pr_processHandle, feedEquippedGenieAddress + 2, invIndex);
            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, feedEquippedGenieAddress + 3, amountRev);

            sendPacket(feedEquippedGenieAddressRev, packetSize);
        }




        //Regular Attack

        private int acceptQuestAddress;
        private byte[] acceptQuestAddressRev;
        private byte[] acceptQuestPkt = new byte[] 
        { 
            0x25, 0x00,                 //Header
            0x07, 0x00, 0x00, 0x00,     //npc interaction type
            0x04, 0x00, 0x00, 0x00,     //nBytes following
            0x00, 0x00, 0x00, 0x00      //questId
        };

        public void acceptQuest(int questId)
        {
            //Get size of the packet
            int packetSize = acceptQuestPkt.Length;

            if (acceptQuestAddress == 0)
            {
                //load packet in memory
                loadPacket(acceptQuestPkt, ref acceptQuestAddress, ref acceptQuestAddressRev);
            }

            byte[] questIdRev = BitConverter.GetBytes(questId);
            questIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, acceptQuestAddress + 10, questIdRev);

            sendPacket(acceptQuestAddressRev, packetSize);
        }




        //Regular Attack

        private int handInQuestAddress;
        private byte[] handInQuestAddressRev;
        private byte[] handInQuestPkt = new byte[] 
        { 
            0x25, 0x00,                 //Header
            0x06, 0x00, 0x00, 0x00,     //npcInteractionType
            0x08, 0x00, 0x00, 0x00,     //nBytes following
            0x00, 0x00, 0x00, 0x00,      //questId
            0x00, 0x00, 0x00, 0x00      //optionIndex
        };

        public void handInQuest(int questId, int optionIndex)
        {
            //Get size of the packet
            int packetSize = handInQuestPkt.Length;

            if (handInQuestAddress == 0)
            {
                //load packet in memory
                loadPacket(handInQuestPkt, ref handInQuestAddress, ref handInQuestAddressRev);
            }

            byte[] questIdRev = BitConverter.GetBytes(questId);
            questIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, handInQuestAddress + 10, questIdRev);
            byte[] optionIndexRev = BitConverter.GetBytes(optionIndex);
            optionIndexRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, handInQuestAddress + 14, optionIndexRev);



            sendPacket(handInQuestAddressRev, packetSize);
        }




        //Regular Attack

        private int sellSingleItemAddress;
        private byte[] sellSingleItemAddressRev;
        private byte[] sellSingleItemPkt = new byte[] 
        { 
            0x25, 0x00,                 //Header
            0x02, 0x00, 0x00, 0x00,     //npcInteraction type
            0x10, 0x00, 0x00, 0x00,      //nBytes following
            0x01, 0x00, 0x00, 0x00,      //nItems Sold
            0x00, 0x00, 0x00, 0x00,      //typeId
            0x00, 0x00, 0x00, 0x00,      //invIndex
            0x00, 0x00, 0x00, 0x00      //amount
        };

        public void sellSingleItem(int typeId, int invIndex, int amount)
        {
            //Get size of the packet
            int packetSize = sellSingleItemPkt.Length;

            if (sellSingleItemAddress == 0)
            {
                //load packet in memory
                loadPacket(sellSingleItemPkt, ref sellSingleItemAddress, ref sellSingleItemAddressRev);
            }

            byte[] typeIdRev = BitConverter.GetBytes(typeId);
            typeIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, sellSingleItemAddress + 14, typeIdRev);

            byte[] invIndexRev = BitConverter.GetBytes(invIndex);
            invIndexRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, sellSingleItemAddress + 18, invIndexRev);

            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, sellSingleItemAddress + 22, amountRev);


            sendPacket(sellSingleItemAddressRev, packetSize);
        }




        //Regular Attack

        private int buySingleItemAddress;
        private byte[] buySingleItemAddressRev;
        private byte[] buySingleItemPkt = new byte[] 
        { 
            0x25, 0x00,                 //Header
            0x01, 0x00, 0x00, 0x00,     //npcInteraction type
            0x14, 0x00, 0x00, 0x00,      //nBytes following
            0x00, 0x00, 0x00, 0x00,
            0x01, 0x00, 0x00, 0x00,      //nItems Sold
            0x00, 0x00, 0x00, 0x00,      //typeId
            0x00, 0x00, 0x00, 0x00,      //shopIndex
            0x00, 0x00, 0x00, 0x00      //amount
        };

        public void buySingleItem(int typeId, int shopIndex, int amount)
        {
            //Get size of the packet
            int packetSize = buySingleItemPkt.Length;

            if (buySingleItemAddress == 0)
            {
                //load packet in memory
                loadPacket(buySingleItemPkt, ref buySingleItemAddress, ref buySingleItemAddressRev);
            }
            byte[] typeIdRev = BitConverter.GetBytes(typeId);
            typeIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, buySingleItemAddress + 18, typeIdRev);

            byte[] shopIndexRev = BitConverter.GetBytes(shopIndex);
            shopIndexRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, buySingleItemAddress + 22, shopIndexRev);

            byte[] amountRev = BitConverter.GetBytes(amount);
            amountRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, buySingleItemAddress + 26, amountRev);
            sendPacket(buySingleItemAddressRev, packetSize);
        }




        //Regular Attack

        private int repairAllAddress;
        private byte[] repairAllAddressRev;
        private byte[] repairAllPkt = new byte[] 
        { 
            0x25, 0x00,                 //Header
            0x03, 0x00, 0x00, 0x00,     //npc interaction type
            0x06, 0x00, 0x00, 0x00,     //nBytes following
            0xFF, 0xFF, 0xFF, 0xFF,      //typeId
            0x00, 0x00

        };

        public void repairAll()
        {
            //Get size of the packet
            int packetSize = repairAllPkt.Length;

            if (repairAllAddress == 0)
            {
                //load packet in memory
                loadPacket(repairAllPkt, ref repairAllAddress, ref repairAllAddressRev);
            }

            sendPacket(repairAllAddressRev, packetSize);
        }




        //Regular Attack

        private int repairItemAddress;
        private byte[] repairItemAddressRev;
        private byte[] repairItemPkt = new byte[] 
        { 
            0x25, 0x00,                 //Header
            0x03, 0x00, 0x00, 0x00,     //npc interaction type
            0x06, 0x00, 0x00, 0x00,     //nBytes following
            0xFF, 0xFF, 0xFF, 0xFF,      //typeId
            0x00,                       //isEquipped
            0x00                        //locationIndex
        };

        public void repairItem(int typeId, byte isEquipped, byte locationIndex)
        {
            //Get size of the packet
            int packetSize = repairItemPkt.Length;

            if (repairItemAddress == 0)
            {
                //load packet in memory
                loadPacket(repairItemPkt, ref repairItemAddress, ref repairItemAddressRev);
            }
            byte[] typeIdRev = BitConverter.GetBytes(typeId);
            typeIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, repairItemAddress + 10, typeIdRev);

            MemFunctions.MemWriteByte(pr_processHandle, repairItemAddress + 14, isEquipped);
            MemFunctions.MemWriteByte(pr_processHandle, repairItemAddress + 15, locationIndex);


            sendPacket(repairItemAddressRev, packetSize);
        }




        //Regular Attack

        private int upgradeSkillAddress;
        private byte[] upgradeSkillAddressRev;
        private byte[] upgradeSkillPkt = new byte[] 
        { 
            0x25, 0x00,                 //Header
            0x09, 0x00, 0x00, 0x00,     //npc interaction type
            0x04, 0x00, 0x00, 0x00,     //nBytes following
            0x00, 0x00, 0x00, 0x00,      //skillId
        };

        public void upgradeSkill(int skillId)
        {
            //Get size of the packet
            int packetSize = upgradeSkillPkt.Length;

            if (upgradeSkillAddress == 0)
            {
                //load packet in memory
                loadPacket(upgradeSkillPkt, ref upgradeSkillAddress, ref upgradeSkillAddressRev);
            }

            byte[] skillIdRev = BitConverter.GetBytes(skillId);
            skillIdRev.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, upgradeSkillAddress + 10, skillIdRev);

            sendPacket(upgradeSkillAddressRev, packetSize);
        }


        //opcode for sending a packet
        private byte[] sendPacketOpcode = new byte[] 
        { 
            0x60,                                   //PUSHAD
            0xB8, 0x00, 0x00, 0x00, 0x00,           //MOV EAX, SendPacketAddress
            0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00,     //MOV ECX, DWORD PTR [realBaseAddress]
            0x8B, 0x49, 0x20,                       //MOV ECX, DWORD PTR [ECX+20]
            0xBF, 0x00, 0x00, 0x00, 0x00,           //MOV EDI, packetAddress
            0x6A, 0x00,                             //PUSH packetSize
            0x57,                                   //PUSH EDI
            0xFF, 0xD0,                             //CALL EAX
            0x61,                                   //POPAD
            0xC3                                    //RET
        };

        //======================//
        //   Memory Addresses   //
        //======================//

        //Main addresses
        private int packetAddressLocation;
        private int packetSizeAddress;
        private int sendPacketOpcodeAddress;

        //Constructor
        public PacketSender(IntPtr processHandle)
        {
            pr_processHandle = processHandle;
        }



        //Deselect Target

        private int deselectTargetAddress;
        private byte[] deselectTargetAddressRev;

        private byte[] deselectTargetPkt = new byte[] 
        { 
            0x08, 0x00                  //Header
        };

        public void deselectTarget()
        {
            //Get size of the packet
            int packetSize = deselectTargetPkt.Length;

            if (deselectTargetAddress == 0)
            {
                //load packet in memory
                loadPacket(deselectTargetPkt, ref deselectTargetAddress, ref deselectTargetAddressRev);
            }

            sendPacket(deselectTargetAddressRev, packetSize);
        }

        private void loadSendPacketOpcode()
        {
            //Allocate memory for the opcode to call the sendPacket function
            sendPacketOpcodeAddress = MemFunctions.AllocateMemory(pr_processHandle, sendPacketOpcode.Length);

            //Write the opcode to memory
            MemFunctions.MemWriteBytes(pr_processHandle, sendPacketOpcodeAddress, sendPacketOpcode);

            //Insert the reverse baseAddress and sendPacketFunctionAddress in opcode
            byte[] functionAddress = BitConverter.GetBytes(SEND_PACKET_ADDRESS);
            functionAddress.Reverse();
            byte[] realBaseAddress = BitConverter.GetBytes(REAL_BASE_ADDRESS);
            realBaseAddress.Reverse();
            MemFunctions.MemWriteBytes(pr_processHandle, sendPacketOpcodeAddress + 2, functionAddress);
            MemFunctions.MemWriteBytes(pr_processHandle, sendPacketOpcodeAddress + 8, realBaseAddress);
            packetAddressLocation = sendPacketOpcodeAddress + 16;
            packetSizeAddress = sendPacketOpcodeAddress + 21;
        }

        public void sendPacket(byte[] packetLocation, int packetSize)
        {
            if (sendPacketOpcodeAddress == 0)
            {
                loadSendPacketOpcode();
            }

            MemFunctions.MemWriteBytes(pr_processHandle, packetAddressLocation, packetLocation);
            MemFunctions.MemWriteByte(pr_processHandle, packetSizeAddress, (byte)packetSize);

            //Run the opcode
            IntPtr threadHandle = MemFunctions.CreateRemoteThread(pr_processHandle, sendPacketOpcodeAddress);

            //Wait for opcode to be done
            MemFunctions.WaitForSingleObject(threadHandle);

            //Close the thread
            MemFunctions.CloseProcess(threadHandle);

        }

        private void loadPacket(byte[] packet, ref int packetAddress, ref byte[] packetAddressRev)
        {
            //load packet in memory

            //Allocate memory to store packet
            packetAddress = MemFunctions.AllocateMemory(pr_processHandle, packet.Length);
 
            //Write packet to allocated memory
            MemFunctions.MemWriteBytes(pr_processHandle, packetAddress, packet);

            packetAddressRev = BitConverter.GetBytes(packetAddress);
            
            packetAddressRev.Reverse();
        }


        ~PacketSender()
        {
            //Free memory for the packets stored in memory

            if(packetAddressLocation != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, packetAddressLocation);
            }
            if(packetSizeAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, packetSizeAddress);
            }
            if(sendPacketOpcodeAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, sendPacketOpcodeAddress);
            }
            if (deselectTargetAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, deselectTargetAddress);
            }
            if (this.acceptDuelAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, acceptDuelAddress);
            }
            if (this.acceptPartyInviteAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, acceptPartyInviteAddress);
            }
            if (this.acceptQuestAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, acceptQuestAddress);
            }
            if (this.acceptRequestByFemaleToBeCarriedAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, acceptRequestByFemaleToBeCarriedAddress);
            }
            if (this.acceptRequestByMaleToCarryYouAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, acceptRequestByMaleToCarryYouAddress);
            }
            if (this.acceptRessurectByClericAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, acceptRessurectByClericAddress);
            }
            if (this.askFemaleToBeCarriedAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, askFemaleToBeCarriedAddress);
            }
            if (this.askMaleToCarryAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, askMaleToCarryAddress);
            }
            if (this.beIntimateAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, beIntimateAddress);
            }
            if (this.buySingleItemAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, buySingleItemAddress);
            }
            if (this.cancelActionAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, cancelActionAddress);
            }
            if (this.dropGoldAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, dropGoldAddress);
            }
            if (this.dropItemAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, dropItemAddress);
            }
            if (this.evictFromPartyAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, evictFromPartyAddress);
            }
            if (this.feedEquippedGenieAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, feedEquippedGenieAddress);
            }
            if (this.handInQuestAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, handInQuestAddress);
            }
            if (this.harvestResourceAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, harvestResourceAddress);
            }
            if (this.increaseFlySpeedAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, increaseFlySpeedAddress);
            }
            if (this.increaseStatsByAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, increaseStatsByAddress);
            }
            if (this.increaseStatsByAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, increaseStatsByAddress);
            }
            if (this.initiateSettingUpCatShopAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, initiateSettingUpCatShopAddress);
            }
            if (this.invitePartyAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, invitePartyAddress);
            }
            if (this.inviteToDuelAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, inviteToDuelAddress);
            }
            if (this.leavePartyAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, leavePartyAddress);
            }
            if (this.logOutAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, logOutAddress);
            }
            if (this.pickUpItemAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, pickUpItemAddress);
            }
            if (this.recallPetAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, recallPetAddress);
            }
            if (this.refusePartyInviteAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, refusePartyInviteAddress);
            }
            if (this.regularAttackAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, regularAttackAddress);
            }
            if (this.releaseCarryModeAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, releaseCarryModeAddress);
            }
            if (this.repairAllAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, repairAllAddress);
            }
            if (this.repairItemAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, repairItemAddress);
            }
            if (this.resurrectToTownAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, resurrectToTownAddress);
            }
            if (this.resurrectWithScrollAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, resurrectWithScrollAddress);
            }
            if (this.selectAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, selectAddress);
            }
            if (this.sellSingleItemAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, sellSingleItemAddress);
            }
            if (this.setPartySearchSettingsAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, setPartySearchSettingsAddress);
            }
            if (this.setPetAttackAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, setPetAttackAddress);
            }
            if (this.setPetFollowAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, setPetFollowAddress);
            }
            if (this.setPetModeAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, setPetModeAddress);
            }
            if (this.setPetStandardSkillAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, setPetStandardSkillAddress);
            }
            if (this.setPetStopAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, setPetStopAddress);
            }
            if (this.setPetUseSkillAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, setPetUseSkillAddress);
            }
            if (this.shiftPartyCaptainAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, shiftPartyCaptainAddress);
            }
            if (this.splitStackItemInBankAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, splitStackItemInBankAddress);
            }
            if (this.splitStackItemInBankToInvAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, splitStackItemInBankToInvAddress);
            }
            if (this.splitStackItemInInvAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, splitStackItemInInvAddress);
            }
            if (this.splitStackItemInInvToBankAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, splitStackItemInInvToBankAddress);
            }
            if (this.startMeditatingAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, startMeditatingAddress);
            }
            if (this.startNpcDialogueAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, startNpcDialogueAddress);
            }
            if (this.stopMeditatingAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, stopMeditatingAddress);
            }
            if (this.summonPetAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, summonPetAddress);
            }
            if (this.swapEquipWithInvAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, swapEquipWithInvAddress);
            }
            if (this.swapItemBankAndInvAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, swapItemBankAndInvAddress);
            }
            if (this.swapItemInBankAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, swapItemInBankAddress);
            }
            if (this.swapItemInEquipAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, swapItemInEquipAddress);
            }
            if (this.swapItemInInvAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, swapItemInInvAddress);
            }
            if (this.toggleFashionDisplayAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, toggleFashionDisplayAddress);
            }
            if (this.updateInvPositionAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, updateInvPositionAddress);
            }
            if (this.updateStatsAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, updateStatsAddress);
            }
            if (this.upgradeSkillAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, upgradeSkillAddress);
            }
            if (this.useEmotionAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, useEmotionAddress);
            }
            if (this.useGenieSkillAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, useGenieSkillAddress);
            }
            if (this.useItemAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, useItemAddress);
            }
            if (this.useSkillddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, useSkillddress);
            }
            if (this.useSkillWithoutCastTimeAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, useSkillWithoutCastTimeAddress);
            }
            if (this.viewPlayerEquipAddress != 0)
            {
                MemFunctions.FreeMemory(pr_processHandle, viewPlayerEquipAddress);
            }
            
        }
    }


public class MemFunctions
{
    public delegate int ThreadProc(IntPtr param);


    public enum EncodingType
    {
        ASCII,
        Unicode,
        UTF7,
        UTF8
    }

    [Flags]
    public enum FreeType
    {
        Decommit = 0x4000,
        Release = 0x8000,
    }

    const UInt32 INFINITE = 0xFFFFFFFF;
    const UInt32 WAIT_ABANDONED = 0x00000080;
    const UInt32 WAIT_OBJECT_0 = 0x00000000;
    const UInt32 WAIT_TIMEOUT = 0x00000102;

    [DllImport("kernel32.dll")]
    private static extern IntPtr OpenProcess(
        UInt32 dwDesiredAccess,
        Int32 bInheritHandle,
        UInt32 dwProcessId
        );

    [DllImport("Kernel32.dll")]
    private static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, 
        byte[] lpBuffer, UInt32 nSize, ref UInt32 lpNumberOfBytesRead);

    [DllImport("kernel32.dll")]
    private static extern Int32 CloseHandle(
        IntPtr hObject
        );

    [DllImport("kernel32.dll")]
    private static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
            byte[] lpBuffer, UInt32 nSize, ref UInt32 lpNumberOfBytesWritten);

    [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
    private static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress,
       int dwSize, FreeType dwFreeType);

    [DllImport("kernel32.dll", SetLastError = true)]
    private static extern UInt32 WaitForSingleObject(IntPtr hHandle, UInt32 dwMilliseconds);


    [DllImport("kernel32.dll")]
    private static extern IntPtr CreateRemoteThread(IntPtr hProcess,
       IntPtr lpThreadAttributes, uint dwStackSize, IntPtr
       lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);


    [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
    private static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress,
       uint dwSize, UInt32 flAllocationType, UInt32 flProtect);


    public static int AllocateMemory(IntPtr processHandle, int memorySize)
    {
        return (int)VirtualAllocEx(processHandle, (IntPtr)0, (uint)memorySize, 0x1000, 0x40);
    }

    public static IntPtr CreateRemoteThread(IntPtr processHandle, int address)
    {

        return CreateRemoteThread(processHandle, (IntPtr)0, 0, (IntPtr)address, (IntPtr)0, 0, (IntPtr)0);
    }

    public static void WaitForSingleObject(IntPtr threadHandle)
    {
        if (WaitForSingleObject(threadHandle, INFINITE) != WAIT_OBJECT_0)
        {
            Debug.WriteLine("Failed waiting for single object");
        }
    }

    public static void FreeMemory(IntPtr processHandle, int address)
    {
        bool result;
        result = VirtualFreeEx(processHandle, (IntPtr)address, 0, FreeType.Release);


    }

    public static IntPtr OpenProcess(int pId)
    {
        return OpenProcess(2035711, 0, (UInt32)pId);
    }

    public static void CloseProcess(IntPtr handle)
    {
        Int32 result = CloseHandle(handle);
    }

    public static void MemWriteBytes(IntPtr processHandle, int address, byte[] value)
    {
        bool success;
        UInt32 nBytesRead = 0;
        success = WriteProcessMemory(processHandle, (IntPtr)address, value, (uint)value.Length, ref nBytesRead);
    }

    public static void MemWriteStruct(IntPtr processHandle, int address, object value)
    {
        bool success;
        byte[] buffer = RawSerialize(value);
        UInt32 nBytesRead = 0;
        success = WriteProcessMemory(processHandle, (IntPtr)address, buffer, (uint)buffer.Length, ref nBytesRead);
    }

    public static void MemWriteInt(IntPtr processHandle, int address, int value)
    {
        bool success;
        byte[] buffer = BitConverter.GetBytes(value);
        UInt32 nBytesRead = 0;
        success = WriteProcessMemory(processHandle, (IntPtr)address, buffer, 4, ref nBytesRead);
    }

    public static void MemWriteFloat(IntPtr processHandle, int address, float value)
    {
        bool success;
        byte[] buffer = BitConverter.GetBytes(value);
        UInt32 nBytesRead = 0;
        success = WriteProcessMemory(processHandle, (IntPtr)address, buffer, 4, ref nBytesRead);
    }

    public static void MemWriteShort(IntPtr processHandle, int address, short value)
    {
        bool success;
        byte[] buffer = BitConverter.GetBytes(value);
        UInt32 nBytesRead = 0;
        success = WriteProcessMemory(processHandle, (IntPtr)address, buffer, 2, ref nBytesRead);
    }

    public static void MemWriteByte(IntPtr processHandle, int address, byte value)
    {
        bool success;
        byte[] buffer = BitConverter.GetBytes(value);
        UInt32 nBytesRead = 0;
        success = WriteProcessMemory(processHandle, (IntPtr)address, buffer, 1, ref nBytesRead);
    }

    public static byte[] MemReadBytes(IntPtr processHandle, int address, int size)
    {
        bool success;
        byte[] buffer = new byte[size];
        UInt32 nBytesRead = 0;
        success = ReadProcessMemory(processHandle, (IntPtr)address, buffer, (uint)size, ref nBytesRead);
        return buffer;
    }


    public static int MemReadInt(IntPtr processHandle, int address)
    {
        bool success;
        byte[] buffer = new byte[4];
        UInt32 nBytesRead = 0;
        success = ReadProcessMemory(processHandle, (IntPtr)address, buffer, 4, ref nBytesRead);
        return BitConverter.ToInt32(buffer, 0);
    }

    public static short MemReadShort(IntPtr processHandle, int address)
    {
        bool success;
        byte[] buffer = new byte[2];
        UInt32 nBytesRead = 0;
        success = ReadProcessMemory(processHandle, (IntPtr)address, buffer, 2, ref nBytesRead);
        return BitConverter.ToInt16(buffer, 0);
    }
    public static uint MemReadUInt(IntPtr processHandle, int address)
    {
        bool success;
        byte[] buffer = new byte[4];
        UInt32 nBytesRead = 0;
        success = ReadProcessMemory(processHandle, (IntPtr)address, buffer, 4, ref nBytesRead);
        return BitConverter.ToUInt32(buffer, 0);
    }
    public static float MemReadFloat(IntPtr processHandle, int address)
    {
        bool success;
        byte[] buffer = new byte[4];
        UInt32 nBytesRead = 0;
        success = ReadProcessMemory(processHandle, (IntPtr)address, buffer, 4, ref nBytesRead);
        return BitConverter.ToSingle(buffer, 0);
    }

    public static string MemReadUnicode(IntPtr processHandle, int address)
    {
        bool success;
        byte[] buffer = new byte[1600];
        UInt32 nBytesRead = 0;
        success = ReadProcessMemory(processHandle, (IntPtr)address, buffer, 1600, ref nBytesRead);
        //Debug.WriteLine(BitConverter.ToString(buffer));
        //Debug.WriteLine(ByteArrayToString(buffer, EncodingType.Unicode));
        return ByteArrayToString(buffer, EncodingType.Unicode);
    }

    public static object MemReadStruct(IntPtr processHandle, int address, Type anyType)
    {
        int rawsize = Marshal.SizeOf(anyType);
        bool success;
        byte[] buffer = new byte[rawsize];
        UInt32 nBytesRead = 0;
        success = ReadProcessMemory(processHandle, (IntPtr)address, buffer, (UInt32)rawsize, ref nBytesRead);
        return RawDeserialize(buffer, 0, anyType);
    }


    private static object RawDeserialize(byte[] rawData, int position, Type anyType)
    {
        int rawsize = Marshal.SizeOf(anyType);
        if (rawsize > rawData.Length)
            return null;
        IntPtr buffer = Marshal.AllocHGlobal(rawsize);
        Marshal.Copy(rawData, position, buffer, rawsize);
        object retobj = Marshal.PtrToStructure(buffer, anyType);
        Marshal.FreeHGlobal(buffer);
        return retobj;
    }


    private static byte[] RawSerialize(object anything)
    {
        int rawSize = Marshal.SizeOf(anything);
        IntPtr buffer = Marshal.AllocHGlobal(rawSize);
        Marshal.StructureToPtr(anything, buffer, false);
        byte[] rawDatas = new byte[rawSize];
        Marshal.Copy(buffer, rawDatas, 0, rawSize);
        Marshal.FreeHGlobal(buffer);
        return rawDatas;
    }

    private static string ByteArrayToString(byte[] bytes)
    {
        return ByteArrayToString(bytes, EncodingType.Unicode);
    }

    private static string ByteArrayToString(byte[] bytes, EncodingType encodingType)
    {
        System.Text.Encoding encoding = null;
        string result = "";
        switch (encodingType)
        {
            case EncodingType.ASCII:
                encoding = new System.Text.ASCIIEncoding();
                break;
            case EncodingType.Unicode:
                encoding = new System.Text.UnicodeEncoding();
                break;
            case EncodingType.UTF7:
                encoding = new System.Text.UTF7Encoding();
                break;
            case EncodingType.UTF8:
                encoding = new System.Text.UTF8Encoding();
                break;
        }

        for (int i = 0; i < bytes.Length; i += 2)
        {
            if (bytes[i] == 0 && bytes[i + 1] == 0)
            {
                result = encoding.GetString(bytes, 0, i);
                break;
            }
        }

        return result;
    }

    private static byte[] StringToByteArray(string str, EncodingType encodingType)
    {
        System.Text.Encoding encoding = null;
        switch (encodingType)
        {
            case EncodingType.ASCII:
                encoding = new System.Text.ASCIIEncoding();
                break;
            case EncodingType.Unicode:
                encoding = new System.Text.UnicodeEncoding();
                break;
            case EncodingType.UTF7:
                encoding = new System.Text.UTF7Encoding();
                break;
            case EncodingType.UTF8:
                encoding = new System.Text.UTF8Encoding();
                break;
        }
        return encoding.GetBytes(str);
    } 


}



    public class PWIoffsets
    {

        public const int REAL_BASE_ADDRESS = 0xA5B90C;
        public const int SEND_PACKET_ADDRESS = 0x0060E310;
        
        public const int STRUCTURE_OFFSET = 0x1C;

        public const int PLAYER_COUNTER_OFFSET = 0x8E4;

        public const int OBJECT_LISTS_OFFSET = 0x8;
        public const int PLAYER_OFFSET = 0x20;
        
        public const int PLAYER_LIST_OFFSET = 0x20;
        public const int NPC_LIST_OFFSET = 0x24;
        public const int WORLD_ITEM_LIST_OFFSET = 0x28;

        public const int LIST_COUNT_OFFSET = 0x14;
        public const int UNSORTED_LIST_OFFSET = 0x18;
        public const int SORTED_PLAYER_LIST_OFFSET = 0x88;
        public const int SORTED_NPC_LIST_OFFSET = 0x50;

    }
}