search
HomeJavajavaTutorialHow to use Java to open multiple accounts on WeChat PC?

You can also open multiple WeChat accounts on your computer

Yesterday, I accidentally learned from my good friend Xiao Lin (WeChat public account: Xiao Lin Coding) that his computer can actually log in to two WeChat IDs at the same time.

Open WeChat on mobile phones. I know that mobile phone systems such as Huawei and Xiaomi have supported this. However, how to start two WeChat on a computer running Windows system? This really aroused my concern. curious.

Xiao Lin told me that he did this and wrote a batch process:

<code>start D:\WeChat\WeChat.exe<br>start D:\WeChat\WeChat.exe</code> 

Then he directly double-clicked the batch file to start two WeChat processes.

I tried it, and it was indeed the case!

Then I added another line, and I was able to start 3 more:

How to use Java to open multiple accounts on WeChat PC?

Then I searched on the Internet and found out that this trick had been used by others a long time ago. It seemed like I was on Mars. But why can I open more doors in this way? I really want to know the mystery.

TIPS: If you are not interested in the technical analysis part, you can skip and go directly to the truth part at the end.

WeChat’s singleton mode

Under normal circumstances, you can directly double-click the WeChat icon to start. The process started later will perform a global singleton mode check. If it is found that a WeChat process already exists, it will directly Activate the WeChat window of the corresponding process, position it at the front of the desktop, and then exit.

But why can we start both using the above method? Let’s find out.

First, let’s analyze how the single instance of WeChat described above is implemented.

Friends who have done Windows platform application development may be familiar with this. Generally, a mutex with a globally unique name is created after the process is started. If the creation is successful, it will start normally. If the creation fails, it will be judged whether the mutex is the same. The repeller already exists. If it already exists, it means that the corresponding program has been started before.

With this conjecture, use the tool procexp to check all the kernel objects opened by the WeChat process and find the mutex part:

How to use Java to open multiple accounts on WeChat PC?

Sure enough, there is a mutex named _WeChat_App_Instance_Identity_Mutex_Name. From this name, we can guess that this is definitely related to WeChat’s singleton mode.

Next, start the artifact APIMonitor, which can help you monitor the API calls of the specified process, and check the two Windows API functions CreateMutex and GetLastError. When WeChat is already running, use this tool to start another WeChat process and take a look at the function calls:

How to use Java to open multiple accounts on WeChat PC?

You can see that after creating the mutex with this name, the GetLastError function was subsequently called and 0x000000b7 was returned. Check the manual for its meaning:

How to use Java to open multiple accounts on WeChat PC?

means it already exists.

Let’s take a look at the stack of this CreateMutex call and see where the code is creating this global mutex:

How to use Java to open multiple accounts on WeChat PC?

It can be seen from the stack that the call comes from a dynamic library WeChatWin.dll in the WeChat directory. The specific location is the previous instruction at offset 0x8e271b.

Next, we will introduce the artifact among artifacts, the famous disassembly software IDA. This guy supports x86, x64, ARM, MIPS and other processor architectures as well as Windows, Linux, Android, MacOS, JVM Program analysis on various system platforms.

Open the WeChatWin.dll file with IDA and locate the offset 0x8e271b:

How to use Java to open multiple accounts on WeChat PC?
##As shown in the figure above, the action of creating a mutex, Occurs in function sub_108e26d0.

The upper layer is the sub_108e2660 function calling it:

How to use Java to open multiple accounts on WeChat PC?
The above picture reflects the judgment logic after creating the mutex:

  • If the return value of sub_108e26d0 is 0, it means there is no error, and the current function will return directly 0.

  • 如果sub_108e26d0的返回值不为0,表示出现了错误,则依次判断     WeChatMainWndForPC和     WeChatLoginWndForPC两个窗口是否存在,如果存在则使用     BringWindowToTop函数将其置顶弹出。这两个窗口分别代表的是微信的主界面窗口和登陆界面窗口,如果一个微信实例已经存在,则势必处于这两种状态之一。

问题就出在上面这个判断中,汇编代码看起来有点辣眼睛,咱们F5来还原一下C代码(还原效果只能凑合看,能看清楚逻辑就行):

How to use Java to open multiple accounts on WeChat PC?  

上面图片的注解已经说明了,函数sub_108e2660的返回值将决定是否启动微信实例进程,还是直接退出。 

真相只有一个

事情到这里就真相大白了,来总结一下。

微信判断是否启动的2个条件:

  • 如果能成功创建互斥体对象,则启动微信

  • 如果不能创建互斥体:

    • 如果找到对应窗口,则置顶之,自己退出

    • 如果没有找到,则启动微信

用伪代码来表示一下:

<code>if (CreateMutex() == SUCCESS) {<br>  启动微信<br>} else {<br>  if (FindWindow() == SUCCESS) {<br>    将已有窗口置顶<br>  } else {<br>    启动微信<br>  }<br>}</code> 

而直接使用脚本启动的多个进程,虽然操作系统内核层面保证了互斥体的唯一,但由于启动速度相差不大,相应的窗口还没有来得及创建出来,导致走入上面的第二个启动逻辑,从而可以启动多个实例。 

小发现

在分析的过程中,发现了一个有趣的事情:

在WeChatWin.dll中,上面的创建互斥体再上一级函数名字叫StartWaChat,也是作为导出函数被该DLL导出:

How to use Java to open multiple accounts on WeChat PC?

The above is the detailed content of How to use Java to open multiple accounts on WeChat PC?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
How does platform independence benefit enterprise-level Java applications?How does platform independence benefit enterprise-level Java applications?May 03, 2025 am 12:23 AM

Java is widely used in enterprise-level applications because of its platform independence. 1) Platform independence is implemented through Java virtual machine (JVM), so that the code can run on any platform that supports Java. 2) It simplifies cross-platform deployment and development processes, providing greater flexibility and scalability. 3) However, it is necessary to pay attention to performance differences and third-party library compatibility and adopt best practices such as using pure Java code and cross-platform testing.

What role does Java play in the development of IoT (Internet of Things) devices, considering platform independence?What role does Java play in the development of IoT (Internet of Things) devices, considering platform independence?May 03, 2025 am 12:22 AM

JavaplaysasignificantroleinIoTduetoitsplatformindependence.1)Itallowscodetobewrittenonceandrunonvariousdevices.2)Java'secosystemprovidesusefullibrariesforIoT.3)ItssecurityfeaturesenhanceIoTsystemsafety.However,developersmustaddressmemoryandstartuptim

Describe a scenario where you encountered a platform-specific issue in Java and how you resolved it.Describe a scenario where you encountered a platform-specific issue in Java and how you resolved it.May 03, 2025 am 12:21 AM

ThesolutiontohandlefilepathsacrossWindowsandLinuxinJavaistousePaths.get()fromthejava.nio.filepackage.1)UsePaths.get()withSystem.getProperty("user.dir")andtherelativepathtoconstructthefilepath.2)ConverttheresultingPathobjecttoaFileobjectifne

What are the benefits of Java's platform independence for developers?What are the benefits of Java's platform independence for developers?May 03, 2025 am 12:15 AM

Java'splatformindependenceissignificantbecauseitallowsdeveloperstowritecodeonceandrunitonanyplatformwithaJVM.This"writeonce,runanywhere"(WORA)approachoffers:1)Cross-platformcompatibility,enablingdeploymentacrossdifferentOSwithoutissues;2)Re

What are the advantages of using Java for web applications that need to run on different servers?What are the advantages of using Java for web applications that need to run on different servers?May 03, 2025 am 12:13 AM

Java is suitable for developing cross-server web applications. 1) Java's "write once, run everywhere" philosophy makes its code run on any platform that supports JVM. 2) Java has a rich ecosystem, including tools such as Spring and Hibernate, to simplify the development process. 3) Java performs excellently in performance and security, providing efficient memory management and strong security guarantees.

How does the JVM contribute to Java's 'write once, run anywhere' (WORA) capability?How does the JVM contribute to Java's 'write once, run anywhere' (WORA) capability?May 02, 2025 am 12:25 AM

JVM implements the WORA features of Java through bytecode interpretation, platform-independent APIs and dynamic class loading: 1. Bytecode is interpreted as machine code to ensure cross-platform operation; 2. Standard API abstract operating system differences; 3. Classes are loaded dynamically at runtime to ensure consistency.

How do newer versions of Java address platform-specific issues?How do newer versions of Java address platform-specific issues?May 02, 2025 am 12:18 AM

The latest version of Java effectively solves platform-specific problems through JVM optimization, standard library improvements and third-party library support. 1) JVM optimization, such as Java11's ZGC improves garbage collection performance. 2) Standard library improvements, such as Java9's module system reducing platform-related problems. 3) Third-party libraries provide platform-optimized versions, such as OpenCV.

Explain the process of bytecode verification performed by the JVM.Explain the process of bytecode verification performed by the JVM.May 02, 2025 am 12:18 AM

The JVM's bytecode verification process includes four key steps: 1) Check whether the class file format complies with the specifications, 2) Verify the validity and correctness of the bytecode instructions, 3) Perform data flow analysis to ensure type safety, and 4) Balancing the thoroughness and performance of verification. Through these steps, the JVM ensures that only secure, correct bytecode is executed, thereby protecting the integrity and security of the program.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor