当前位置:   article > 正文

c#利用API读取微信数据_c#获得微信数据

c#获得微信数据

现在微信电脑版运用比较普遍,平时很想向QQ那样抓取聊天内容,或者作一个自应答系统,在这里写出对微信好友昵称的抓取。希望对大家起到抛砖引玉的作用。
部分源码:

 foreach (Process process in processes)
            {
                if (process.ProcessName == "WeChat")
                {
                    WxProcess = process;
                    this.textBox1.AppendText("微信已找到!" + Environment.NewLine);
                    this.textBox1.AppendText("微信句柄:\t" + "0x" + ((int)(process.Handle)).ToString("X8") + Environment.NewLine);
                    foreach (ProcessModule processModule in process.Modules)
                    {
                        if (processModule.ModuleName == "WeChatWin.dll")
                        {
                            WeChatWinBaseAddress = processModule.BaseAddress;
                            this.textBox1.AppendText("微信基址:\t" + "0x" + ((int)(processModule.BaseAddress)).ToString("X8") + Environment.NewLine);

                            WeChatVersion = processModule.FileVersionInfo.FileVersion;
                            this.textBox1.AppendText("微信版本:\t" + processModule.FileVersionInfo.FileVersion + Environment.NewLine);
                            break;
                        }
                    }
                    break;
                }
            }

            if (WxProcess == null)
            {
                this.textBox1.AppendText("微信没有找到!");
                return;
            }

            //微信号
            int WxNameAddress = (int)WeChatWinBaseAddress + 0x1131B90;
            this.textBox1.AppendText("微信号地址:\t" + "0x" + ((int)(WxNameAddress)).ToString("X8") + Environment.NewLine);
            string str1=GetString(WxProcess.Handle, (IntPtr)WxNameAddress);
            byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(str1);
            string newString = Encoding.UTF8.GetString(buffer); 
            this.textBox1.AppendText("微信号:\t" + newString + Environment.NewLine);

            //微信昵称
            int WxNickNameAddress = (int)WeChatWinBaseAddress + 0x1131C64;
            this.textBox1.AppendText("微信昵称地址:\t" + "0x" + ((int)(WxNickNameAddress)).ToString("X8") + Environment.NewLine);
            string str2 = GetString(WxProcess.Handle, (IntPtr)WxNickNameAddress);
            byte[] buffer1 = Encoding.UTF8.GetBytes(str2);
            string newString1 = Encoding.UTF8.GetString(buffer1); 
            this.textBox1.AppendText("微信昵称:\t" + newString1 + Environment.NewLine);
       }

         String GetString(IntPtr hProcess, IntPtr lpBaseAddress, int nSize = 100)
        {
            byte[] data = new byte[nSize];
            if (ReadProcessMemory(hProcess, lpBaseAddress, data, nSize, 0) == 0)
            {
                //读取内存失败!
                return "";
            }
            String result = "";
            String TempString = Encoding.ASCII.GetString(data);
            // \0
            foreach (char item in TempString)
            {
                if (item == '\0')
                {
                    break;
                }
                result += item.ToString();
            }
            return result;
        }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67

源代码下载:下载地址

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/821747
推荐阅读
相关标签
  

闽ICP备14008679号