Ubuntu under use VirtualBox run Baidu hi

Source: Internet
Author: User

Original url:http://blog.csdn.net/u012859646/article/details/16840309 [2009] This article is the old article, almost finishing in 09, the record is also a small problem of positioning and resolution. The contents of the inside may be in disrepair, not necessarily directly applied, but believe that if there are similar problems, methods can be used for reference.

Running Baidu hi under Unbuntu or other Linux desktops, two commonly used methods are 1 wine before the Linux version is introduced in Hi; 2) Virtual machine.

Method 1 and the wine and GCC and other versions are related, the steps are also more, not necessarily successful, even if the successful operation, there are generally slow problems, and some features of hi can not be used smoothly.

Method 2, the main disadvantage of using virtual machines is that switching and sharing between the two systems is inconvenient, regardless of whether your virtual machine is using Windows or full-screen mode.

The method described in this article is the use of HI on Virtual box VMs, and introduces two problems in the use process:

1 Virtual Box addition features: Seamless Windows, files and clipboard sharing, etc.

2 made a little customization to hi to solve a small problem found in this process

an installation

The Guest Additions feature in virtual box is very powerful and can only be implemented when this feature is installed. The Guest Additions feature is not installed by default (at least in my version), but its installation package is included, the file name is Vboxguestadditions.iso, the default location should be/usr/share/virtualbox/ Vboxguestadditions.iso

If the installation path is different, you can locate or find it.

You can mount a bit first, this ISO

$ sudo mount-o loop/usr/share/virtualbox/vboxguestadditions.iso/media/cdrom0/

After that, the installation

$sudo Sh./vboxlinuxadditions-x86.run

The virtual box will need to be restarted after installation. This can be done in the help documentation as soon as this step is installed. In practice, it is found that the corresponding guest additions must be installed in the virtual window environment to work. Specifically, you can select Vboxguestadditions.iso in the virtual machine management--Virtual Media Management menu. Can be installed from a CD in a virtual window environment. The window must also be restarted after installation. All the preparations have been completed.

After restarting the virtual window, ctrl+l can enter the seamless window mode, as shown below,

As you can see, the effect of this mode and wine is actually similar, in addition to other applications on the virtual machine does not need to change, you can directly like a Linux desktop program to use, such as you can also use other popular input methods or use IE. As in the above diagram Linux under the Gvim and window under the Hi, just like on the same desktop running.

The previously mentioned Clipboard and file sharing operations are also simple and can only be configured under Virtual box. Clipboard shared. In the advanced shared Pasteboard, general, Virtual box settings, select the two-way file share. To add data space in virtual box, set-up data space, you need to specify a name, and a location. If we use "/MEDIA/SDA3/VB" as a shared folder, it is named "VB". When you are finished, start the virtual window machine, and at the command line, use the command

> net use x: \\vboxsvr\vb

You can access the shared folders under the Linux machine by using the X-disk.

Two customization

The above process is relatively simple. However, this problem is found in use. See figure below.

Is the left side of hi, often a black window, and sometimes after the hi minimized, this "black block" or "lingering", is very annoying. This window, should be the mouse hover on friends, display a detail window, will show the user's latest articles and so on. It may be that hi or virtual box has a problem with the details, causing the black block. This feature is not very obvious to me, because the friends in the latest news also have relevant content.

What I want to do now is to get rid of this window. The following process is not as smooth as the rusty because it has not been developed under window for several years. Tool preparation. 工欲善其事, its prerequisite, of course, is to prepare some relevant tools, such as Spy + +, ollydbg, Ida and so on. Determines the window. First Use Spy + + to view, but in the Hi's child window, did not find this invisible window. Fortunately, when looking for Spy + +, download a similar tool Winspector spy in some ways more powerful, you can see, as shown below

As shown in the red box is the hidden window in the Highligh, you can see that this window title is Dialog.MainFrame.CradTipWindow. After the window is positioned, the code generated by the subsequent location window is more convenient. Determines the timing of window generation. In order to set breakpoints more effectively, it is necessary to understand the timing of window generation. ollydbg or previous Winspector spy can view a list of the windows of the process. Here, simply refresh the window to see the window titled Dialog.MainFrame.CradTipWindow Generation. Through the "human flesh" method, you can see that the window is generated on the first display, and then will not destroy, in the need to show when the gradient appears, gradient hidden. There should be a more efficient way to do this, such as a specific string breakpoint. Determine the modification scenario. The modifications that can be considered are: 1 handles hover messages, returns directly without processing, 2 modifies some of the window's genus so that it does not display, and so on. In the process of positioning, it can be seen that the most of the window controls are not standard, but developed by themselves. If the second scenario works, it is certainly simpler than the scenario and the possible side effects are small, because the corresponding window handle is likely to be used elsewhere, which may introduce more modifications. In addition, Winspector has a useful function, you can directly modify the properties of other windows, as shown below. In this attempt, the "Black block" window of the ws_visble attribute removed, found to solve the problem, that is, "black block" can be removed. Therefore, it can be determined that the idea of Scenario II continues.

API and breakpoints. There are several APIs that may be relevant to window properties, such as CreateWindowEx, ShowWindow, SetWindowLong, and, of course, HI is the Unicode version, and the actual concern is the API version of CREATEWINDOWEXW. In addition, in the 3rd step, it is determined that the window is created the first time, so you can log in hi and then go to attach, set breakpoints and debug, so you can skip a lot of interference, improve efficiency. Using ollydbg, the attach process sets breakpoints on the API mentioned above. Then hover over one of your friends to trigger the creation of the window. During the recording process, the information about entering the breakpoint is about 7, 8 times. Among them, the following information is worth paying attention to.

0012fbe4 10068104/call to ShowWindow from Basement.100680fe

0012fbe8 0035026C |hwnd = 0035026C (' Dialog.MainFrame.CradTipWindow ', class= ' Basegui ', parent=000303e4)

0012FBEC 00000008 \showstate = Sw_showna

From the window caption you can confirm that this window is the "black block" we are interested in. Also, because "the application creates the main window function by calling the Cteatewindow function that clears the WS_VISIBLE flag, and then calls the ShowWindow function with the SW_SHOW flag to display the window" is the usual way to create the window. And the information obtained from other breakpoints, such as CREATEWINDOWEXW, can be learned that the creation of this window does use a regular scenario.  Moreover, it is this ShowWindow call that resets the window's Ws_visible property. Positioning. Set a breakpoint in the ShowWindow above and view its call stack. In the diagram on the next page, a diagram of the partial call stack is given. In addition, first intercept a portion of the window corresponding header file definition

#define SW_HIDE 0

#define SW_SHOWNA 8

It can be seen that in the original program, the parameter called ShowWindow is a value of 8, and we want to change it to 0 (not visible)

In the figure above, basement refers to a function in the Basement.dll called Hi, which should be encapsulated in a number of regular calls. In general, the ShowWindow API should also be a bit encapsulated, so it can be viewed in several stacks of nearby frames. In the second frame of the ShowWindow call, you can see the following assembly code:

005446C6 6A PUSH 8

005446c8 PUSH EAX

005446C9 FF91 C8000000 call DWORD PTR Ds:[ecx+c8]

The push 8 here is likely to be sw_showa the parameters into the stack. Of course, this can be verified from the parameters of the assembly code. From this code guess API ShowWindow The first function, with two parameters, where 8 is the second parameter. Because, either cdecl or stdcall, the function arguments are in the stack from right to left. Patch. You can try to change push 8 to push 0, which is ShowWindow with the Sw_hide parameter, so that the window does not take the Ws_visble property. The following figure:

And then regenerate an EXE program. Test it, and sure enough, when you hover your friend, the prompt box does not appear. The small "black Block" under the Linux desktop also disappears!

Three summary

This article describes the way to run Hi using Virtual box's seamless window under Unbuntu, while solving a minor problem with the Hi and Virtual box compatibility by patch approach. This article can also be used as a small demo to modify a binary program without code. Of course, this example may be relatively simple, I believe this program is not the best way to solve this problem, right when a technical approach to solve practical problems of the example bar.

2009

--end--


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.