Reprinted [QQ anti-harassment "development notes]

xiaoxiao2021-03-06  52

National Day seven days, staying at home online chat is really not a pleasant thing: every day open QQ, welcome me is a string of advertising ... National Day Golden Week, even advertisements do not let go! ()

Helpless, open Visual C , started my "anti-harassment" road.

First of all, the question I face is: QQ has several ads, what can I use to destroy them?

The first half of the question is very good, I believe that all the friends who often q know. There are three ads of QQ: The first is a pop-up flash advertisement in the system message, the second is the Flash advertisement that pops up (the form is very fancy), and the third is a literal advertisement that appears in system broadcast.

For the latter half problem, the answer I give is: On the form corresponding to the advertisement, there is a corresponding button to close it, click.

No, it's so simple? Maybe you have to ask this.

Yes, but I said, let my "QQ anti-harass" help me click on these buttons. That is, after obtaining the handle of these buttons, send a click message to the button, as shown in the following code:

SendMessage (HButton, BM_Click, 0, 0);

Maybe there will be a friend, why not directly eliminate the dialog box, namely:

EndDialog (HDIALOG, TRUE);

Asked! The specific reason is ... Oh, I don't know :) But I can tell you, you can change my code to the above sentence, the effect may not be ideal, because I tried it. In addition, there are many shared software clickers that are called "click" is this truth. Singlely eliminate this window, it is likely that some system resources occupied by the window will be lost. Compared to the clicking method, let the dialog box call itself to eliminate the dialog box, isn't it more Safety?

There is also a question: When is it going to click? Or do you know when to click?

My answer is: time monitoring.

Yes, this is the "timer technology" I said in the readme.txt of the software. Very simple, just add the following code in the initialization of the dialog:

SetTimer (HDLG, 1, 100, NULL);

The first parameter is a dialog handle that needs to set the timer. Users who use the MFC can omit this parameter; the second parameter is the id of the timer; the third is the trigger time interval of the timer event (in subtle) The fourth parameter can specify the callback function of the response event, which is not used here, which is NULL.

In this way, the preliminary function can be achieved - always monitor. However, when the final handler exits the code, you must destroy the previously created timer, namely:

KillTimer (HDLG, 1);

Because the timer is something that consumes system resources, it is necessary to destroy the system resources when the program ends.

Let me start to show how to find the three ad windows for QQ in memory. The following code I have taken from the SDK source code of "QQ anti-harassment", please use the MFC's friends to make a corresponding change.

There are many windows in memory, then "QQ anti-harassment" is how to know which window is the qq advertising window? It is very simple, and two to three are taken as "filter" from the numerous features of the window. For example, the pop-up advertisement of the system message, its "filter" is its title - "Tencent QQ System Broadcast" and its "Close" button.

In this way, the code when the timer event is processed is as follows:

HWND HWNDCAP, HBTNCLOSE1; // Window handle and "Close" button handle

HWNDCAP = FindWindow (NULL, "Tencent QQ System Broadcast"); / / Find Window

IF (hwndcap! = null) // If the window exists

{

HBTnClose1 = FindWindowEx (HWNDCAP, NULL, "Button", "Close"); // Continue to filter, find the "Close" button

If (hbtnclose1! = null) // If this button exists, it is basically determined to be QQ's advertisement.

{

EnableWindow (HBTNClose1, true); // Take the button

SendMessage (HBTnClose1, BM_Click, 0, 0); // Send Click Message

}

}

Here I want to explain the code that will take effect. In the early versions of QQ (such as the version I am currently used at home), the Flash ad must be read after reading it, so I have to take effect immediately after finding it. Turn off the window. Of course, for new version of QQ, you can remove this line.

For the automatic Flash ad, there is no such thing as the above. Because it uses a graphical interface, it does not understand the so-called "filter" from the appearance, which requires other software help. The software I use is the "dialog box viewer" test version of I wrote V2.SVTF.00 (interested friends can mail this software), this is an instant access window title, window ID Tools with the window class name. I got the title of the "Close" button of this advertisement with the help - "Close". So my code is as follows:

HWnd hwndno, hbtnclose2;

HWndNO = FindWindowEx (NULL, NULL, "# 32770", ""); // # 32770 is the class name of the dialog

DO // Repeat "Close" button repeatedly in the None Title dialog found

{

HBTnClose2 = FindWindowEx (HWndNo, Null, "Button", "Close");

IF (HBTnClose2! = NULL)

Break; // If you find the button, jump out of the loop.

HWndNO = FindWindowEx (NULL, HWNDNO, "# 32770", ""); / / otherwise continue looking for a title window

} While (hwndno! = Null);

IF (HBTnClose2! = NULL)

{

EnableWindow (HBTNCLOSE2, TRUE); //, if you don't need, please delete this line

SendMessage (hbtnclose2, bm_click, 0, 0);

}

In this way, this advertisement is also conquered. In fact, it is most troubled with my third advertisement - QQ number of 10000. The reason why I call it "QQ No. 1000" is because my "filter" is "10000". This advertisement and "user ??????? the system information of the" user list "is the same, so it will filter out the important information. So I chose "10000" as my filter.

At first, I judged from the appearance of the dialog, the control of the user QQ number was a read-only (ES_READOONLY) edit box (Edit), and later I made the code and compiled and found it! So the version number of "QQ anti-harassment" is set to 1.SVOF.02, and two QQ ads can be eliminated. So I seem to be depressed. However, when I studied another software using Exescope, I suddenly came up with the Exescope expert to study QQ's main program, but can succeed, I have no bottom. I opened QQ's main program, found that dialog, and found a lot of static (static text, Delphi, and C Builder)! My day, why didn't I think that it is a Static Static? So I think three, in addition, my last code also came out:

HWND HWNDYW, HBTNCLOSE3, HEDIT;

HWndyw = FindWindow (NULL, System Message ");

IF (hwndyw! = null)

{

HBTnClose3 = FindWindowEx (HWndyw, Null, "Button", "Return");

Hedit = FindWindowEx (HWndyw, NULL, "Static", "10000");

IF (Hedit! = null && HBTnClose3! = NULL)

SendMessage (HBTnClose3, BM_Click, 0, 0);

}

You can see that in my code, identify the STATIC's handle is still called Hedit, that is because I have previously determined mistakes.

"QQ anti-harassment" V1.svof.12 core code is here, but there is still a little, it is a unclear bug in my "QQ anti-harassment". Do you notice? In the third paragraph, if you touch the title of 10000, send a click message to the "Return" button. This means that if a nickname is a 10,000 netizen adding you as a friend, then his system information is likely to be filtered out. The solution is to determine if the style of the "Add Friends" button is visible (ws_visible). If it is invisible, you can send a click message to the "Back" button. But because of my personal time, this code hasn't been achieved, I will give it to everyone, huh, huh.

Welcome to communicate with me: Titilima@163.com. In addition, you can also ask me to "QQ Anti-Harassment" by this mailbox.

Postscript: and "anti-harassment" say goodbye

"QQ anti-harassment" is my VC SDK virgin. I started writing this software since I last in October last year. I have experienced many upgrades, and I finally decided to stop.

The reason is very simple, QQ version is constantly upgrading, the picture of advertising is more and more, which determines that I have to upgrade this software again and again. And now there is a lot of skills about "anti-harassment", so I think I have a little bit more. Since my purpose - learning - reaching, then "upgrade" will lose meaning.

I still thank many netizens, thank them for their trust and concerned about me. I have no return, and I decided to take the source code of this woman's source, and no longer "core code demonstration version". Before my code is written with C , it mainly includes the CHECKBOX class I encapsulated. Now that the class is very ugly, it is afraid to bring misleading side effects, so I spent some time, put it with pure C Written over, I hope to meet the needs of beginners as me. By the way, this V1.37 is almost powerful for QQ2003. Also, the tool SPY from Visual Studio is much stronger than my "dialog box" feature. OK, then see you again, my "QQ anti-harassment".

转载请注明原文地址:https://www.9cbs.com/read-56651.html

New Post(0)