コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting 'poedbg' C# sample...");

            // We'll define the callback handlers here as anonymous functions just
            // for the sake of example.

            PoeDbgErrorCallback ErrorCallback =
                (ErrorCode) =>
            {
                Console.WriteLine("[ERROR] The 'poedbg' module reported an error code of '{0}'.", ErrorCode);
            };

            PoeDbgPacketCallback SendCallback =
                (Length, Id, Data) =>
            {
                Console.WriteLine("[SENT] Packet with ID of '{0}' and length of '{1}'.", Id, Length);

                PrintPacketData(Data, Length);
            };

            PoeDbgPacketCallback ReceiveCallback =
                (Length, Id, Data) =>
            {
                Console.WriteLine("[RECEIVED] Packet with ID of '{0}' and length of '{1}'.", Id, Length);

                PrintPacketData(Data, Length);
            };

            // Now we'll register all of our callbacks. It is important, especially,
            // that we register the error handling callback before we attempt to
            // initialize the poedbg module.

            int Status = PoeDbgRegisterErrorCallback(ErrorCallback);

            if (Status < 0)
            {
                Console.WriteLine("[ERROR] Could not register error callback. Error code: '{0}'.", Status);
            }

            Status = PoeDbgRegisterPacketSendCallback(SendCallback);
            if (Status < 0)
            {
                Console.WriteLine("[ERROR] Could not register packet send callback. Error code: '{0}'.", Status);
            }

            Status = PoeDbgRegisterPacketReceiveCallback(ReceiveCallback);
            if (Status < 0)
            {
                Console.WriteLine("[ERROR] Could not register packet receive callback. Error code: '{0}'.", Status);
            }

            Status = PoeDbgInitialize();
            if (Status < 0)
            {
                Console.WriteLine("[ERROR] Could not initialize. Error code: '{0}'.", Status);
            }

            Console.WriteLine("Started successfully.");

            // Wait.
            Console.ReadKey(true);

            Status = PoeDbgDestroy();
            if (Status < 0)
            {
                Console.WriteLine("[ERROR] Could not destroy. Error code: '{0}'.", Status);
            }

            Console.WriteLine("Removed successfully.");

            // Wait.
            Console.ReadKey(true);
        }
コード例 #2
0
 public static extern int PoeDbgRegisterErrorCallback([MarshalAs(UnmanagedType.FunctionPtr)] PoeDbgErrorCallback Callback);