Source insight 3.x tag plug-in V1.0 released

Source: Internet
Author: User

Source insight can be said to be a programmer's essential development/reading Source Code tool. What is lacking in the United States is that Si does not have a tag bar and it is inconvenient to switch between multiple source codes, so I wrote this file in my spare time: sihook: Tag plug-in; but strictly speaking, sihook is not a plug-in, but an internal plug-in :)

How can I add a label bar to source insight? You can view the orbit blog <create a plug-in for source insight> series. Thanks to orbit's analysis, orbit has already created a tag plug-in very early, I also downloaded and tried his plug-in, but orbit is like a plug-in, and I am more like an internal plug-in :). Since I haven't written a Windows program for a long time, I am not familiar with Windows messages, I didn't even have spy ++ at hand. I thought I wanted to hook up an internal function of Si to hook up the creation and destruction of subwindows, after reading the orbit blog, I found that Si is a standard MDI program. the creation and destruction of sub-windows are all wm_mdi * messages, which is simple, we only need to replace the original Si wndproc to implement what we want. the orbit plug-in is actually a DLL made of MFC. There are threads and timers in the code, and a loader is needed for loading. it is not convenient to use, operations on the UI in the thread are a bit awkward. Since the SI program has been injected, we should make it more thorough and more underlying :).

After several years of programming experience, I feel that C ++ is too complicated, and the clarity and streamlining of C makes me more and more appreciated. A piece of C code can clearly express the logic, c ++ developers like to go around a large circle, not to mention the distorted VC and the mfc I have never understood, A few years ago, when I came into contact with MFC, I always couldn't understand what it was doing. Now, looking back, MFC is a totally failed design. okay, don't talk about C ++ and the damn VC + MFC. This time, sihook is developed in C, compiled in GCC, and lazy. msys is not installed with codeblocks for IDE, saving makefile :)

Below I will briefly introduce the implementation principle of sihook:

1. The plug-in automatically loads msimg32

A few years ago, the DLL was loaded using the createremotethread method, that is, there must be an EXE loader. Now, with the msimg32 delay loading vulnerability, the waist is no longer sour and the legs are no longer painful, loading plug-ins is more convenient :). I will not introduce the specific principles much.

2. dismember Si siframe

The main Si form is siframe. Because msimg32 is delayed loading, the hook createmediawex debugging found that when our DLL is loaded, siframe and mdiclient have been created, while si_sw has not, then we can directly obtain that the hwnd of the current process is the hwnd of the siframe, and then the setwindowlong replaces the window process. We only care about the wm_settext message. When wm_settext sets the title, we add the "enhanced version" to it, then, create the systabcontrol32 Control Using siframe as the parent form.

3. dismember the mdiclient OF Si

Mdiclient is the most important window in Si. It manages the creation and destruction of the source code window. First, use findjavaswex to get the mdiclinet handle, and then setwindowlong replaces the window process, the messages to be processed include wm_windowposchanging; wm_mdicreate; wm_mdidestroy; wm_mdiactivate;

Wm_windowposchanging is a message with a window size change. In this case, the tab size and mdiclient size must be processed before the oldwndproc execution;

Wm_mdicreate; wm_mdidestroy; wm_mdiactivate; it must be processed after oldwndproc is executed, so that the sub-window handle can be obtained directly.

The wm_mdicreate message uses findjavaswex to obtain the handle of the newly created si_sw source code window, replacing the window process.

Wm_mdidestroy messages can directly obtain the hwnd and delete the tab simultaneously.

Wm_mdiactivate can also directly obtain hwnd and synchronously activate the tab

4. dismember Si si_sw

The si_sw subwindow is the source code display window. In this window, we only care about the wm_settext message and get the title of the current source code (including the title change), which is directly displayed on the tab, in this way, you don't need a timer to keep the comparison;

5. tabctl Control

To streamline the process, you can only use the systabcontrol32 control that comes with the system as the label for SDK programming. I encapsulated an interface to facilitate upper-layer calls, including adding, deleting, double-clicking and closing, and changing the tab color, adjust the position and height. this is the first time I have used the systabcontrol32 control. It is very difficult to understand. If an SDK beautification expert knows how to make it more beautiful, I can leave a message and I would like to thank you first. in addition, when you double-click to close the tag, you need to close the source code window. To see the introduction of orbit, you need to send the wm_close message, and its code is indeed implemented in this way, and it is valid, but I cannot try it, finally, I used OD debugging and found that Si sent the wm_syscommand message and the wparam parameter was SC _close. So I also used the SC _close message to close the document :)

OK, the basic principle is the above points. It is easy to clearly create the label and put it in. The whole project does not count as the tabctl Control Source Code does not exceed 10 functions. below is the package downloaded with the plug-in.

Sihookv1.0 download: [Click me]

Install: Decompress the sihook.zip DLL and put it in the SI directory.

Delete: Delete the SI directory msimg32.dll and sihook. dll.

Source code: https://github.com/redxu/sihook

Note: Some servers installed with some guard on XP SP2 cannot use this plug-in, and msimg is not loaded. The cause is being investigated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.