[summary of the invention]
The technical problem to be solved in the present invention, is to provide a kind of windows desktop method of taking over, and user can use windows desktop extender under not by the interference of desktop security software.
The present invention is achieved in that a kind of windows desktop method of taking over, and the present invention specifically comprises the steps:
After step 10, windows desktop extender start, this program creation one message sink processing module, and by this program, dynamic link library is loaded to the explorer that injects Windows;
Step 20, enter step 30 when Remote create dynamic link library when success; In the time of the failure of Remote create dynamic link library, exit this program and finish;
In step 30, described explorer, comprise a DLL module of being injected by this program; Described DLL module definition one extended operation Message Processing flow process, and extended message treatment scheme is set to the Message Processing flow process of explorer, and preserve the original inter-process flow process of explorer;
In the time that using windows desktop program, user produces desktop operated message; In the time that using the feature operation of windows desktop extender, user produces extended operation message; Explorer is in extended operation Message Processing flow process, and desktop operated message and extended operation message to Windows are processed;
Described extended operation Message Processing flow process is:
When described DLL module receives after desktop operated message, this desktop operated message is processed and performed an action by be allowed corresponding desktop programs by the original built-in function treatment scheme of explorer;
When described DLL module is received after this extended operation message, will in extended operation message, need the message that passes to described message sink processing module to be encrypted formation one encrypting messages, and this encrypting messages is distributed to described message sink processing module;
Described DLL module judges whether this extended operation message comprises the inside story that need to call described inter-process flow process, if needed, this inside story is distributed to explorer;
Step 40, described message sink processing module are received after encrypting messages, and this encrypting messages is decrypted into execution message; This program performs an action according to described execution message; Described explorer receives after inside story, and this explorer is processed and allowed corresponding desktop programs perform an action described inside information according to original inter-process flow process.
Further, described step 10 is further specially:
Described in RegisterClass function by Windows of step 11, this program and CreateWindow function creation, to process mould fast for message sink.
Further, described step 20 is further specially:
Step 21, described program obtain the process ID of described explorer;
Step 22, this program are opened explorer process by described process ID, obtain process handle;
Step 23, this program are distributed after a memory headroom in explorer, and the path of described dynamic link library is write to this memory headroom;
Step 24, this program creation remote thread, be loaded on explorer by described dynamic link library;
Step 25, after described dynamic link library is loaded on explorer and completes, described program discharges this memory headroom.
Further, described step 30 is further specially:
Step 31, described DLL module obtain the forms handle of the SysListView32 of windows desktop;
Step 32, DLL module are utilized described forms handle, by this extended operation Message Processing flow process of SetWindowLongPtr function definition of Windows;
Step 33, described program are by the class name of RegisterClass function registration one this message sink module of Windows; Described program is by the forms name of CreateWindow function creation one this message sink module of Windows; After described message sink processing module creates, Windows gives this message sink processing module one first handle;
Described DLL module, by the FindWindowEx function of Windows, utilizes described class name and forms name to find out described the first handle;
Step 34, described DLL module are offset conversion process by extended operation message and form an encrypting messages; Described DLL module by the PostMessage function of Windows, finds encrypting messages described message sink processing module according to described the first handle, and this encrypting messages is distributed to described message sink processing module.
Tool of the present invention has the following advantages: method is simple, method by described program Remote create dynamic link library is taken over windows desktop, solve by the technology of Remote create the problem that in traditional Hook Technique, message can be tackled and filter by desktop security software, allow can be smoothly right the moving of windows desktop extender on windows desktop.
[embodiment]
Refer to described in Fig. 1-2, a kind of windows desktop method of taking over of the present invention, comprises the steps:
After step 10, windows desktop extender start, this program creation one message sink processing module, and by this program, dynamic link library is loaded to the explorer that injects Windows;
Step 20, enter step 30 when Remote create dynamic link library when success; In the time of the failure of Remote create dynamic link library, exit this program and finish;
In step 30, described explorer, comprise a DLL module of being injected by this program; Described DLL module definition one extended operation Message Processing flow process, and extended message treatment scheme is set to the Message Processing flow process of explorer, and preserve the original inter-process flow process of explorer;
In the time that using windows desktop program, user produces desktop operated message; In the time that using the feature operation of windows desktop extender, user produces extended operation message; Explorer is in extended operation Message Processing flow process, and desktop operated message and extended operation message to Windows are processed;
Described extended operation Message Processing flow process is (seeing Fig. 2):
When described DLL module receives after desktop operated message, this desktop operated message is processed and performed an action by be allowed corresponding desktop programs by the original built-in function treatment scheme of explorer;
When described DLL module is received after this extended operation message, will in this extended operation message, need the part message that passes to described message acceptance processing module to be encrypted formation one encrypting messages, and this encrypting messages is distributed to described message sink processing module;
Described DLL module judges whether this extended operation message comprises the inside story that need to call described inter-process flow process, if needed, this inside story is distributed to explorer;
Step 40, described message sink processing module are received after encrypting messages, and this encrypting messages is decrypted into execution message; This program performs an action according to described execution message; Described explorer receives after inside story, and this explorer is processed and allowed corresponding desktop programs perform an action described inside information according to original inter-process flow process.
By the method for Remote create dynamic link library, avoid the problem that traditional hook is filtered by the interception of desktop security software in the time that message is transmitted, realize the desktop of Windows and take over, the extender (as shown 3D scene, carry out scene switching etc. with mouse roller at desktop) of desktop can under do not filtered by desktop security software and interception etc. disturbed, be moved.
Described step 10 is further specially:
Described in RegisterClass function by Windows of step 11, this program and CreateWindow function creation, to process mould fast for message sink.
Described step 20 is further specially:
Step 21, described program obtain the process ID of described explorer;
Step 22, this program are opened explorer process by described process ID, obtain process handle;
Step 23, this program are distributed after a memory headroom in explorer, and the path of described dynamic link library is write to this memory headroom;
Step 24, this program creation remote thread, be loaded on explorer by described dynamic link library;
Step 25, after described dynamic link library is loaded on explorer and completes, described program discharges this memory headroom.
Described step 30 is further specially:
Step 31, described DLL module obtain the forms handle of the SysListView32 of windows desktop;
Step 32, DLL module are utilized described forms handle, by this extended operation Message Processing flow process of SetWindowLongPtr function definition of Windows;
Step 33, described program are by the class name of RegisterClass function registration one this message sink module of Windows; Described program is by the forms name of CreateWindow function creation one this message sink module of Windows; After described message sink processing module creates, Windows gives this message sink processing module one first handle;
Described DLL module, by the FindWindowEx function of Windows, utilizes described class name and forms name to find out described the first handle;
Step 34, described DLL module are offset conversion process by extended operation message and form an encrypting messages; Described DLL module by the PostMessage function of Windows, finds encrypting messages described message sink processing module according to described the first handle, and this encrypting messages is distributed to described message sink processing module.
Concrete operations flow process of the present invention is as follows:
1.Windows desktop extender creates message sink processing module:
After 1-1. program starts, first define a forms process (being extended operation Message Processing flow process) that is used for receipt message, define a forms process (as MyWndProc) by the WNDPROC call back function type of Windows.
1-2. is by a self-defining class of RegisterClass function registration (as MyClassColor5201) of Windows, and it is the forms title (as MyWndProc) previously defining that its forms process is set simultaneously.
Then 1-3. is used for the window of receipt message with these forms of CreateWindow function creation of Windows, and this window name is called self-defining title (as MyClassColor5201), and the handle of parent window is hShellDefView; So just can receive encrypting messages that DLL module distributes.
1-4. is in the time that message sink processing module receives the encrypting messages that DLL module distributes, and this message sink processing module is decrypted described encrypting messages according to the method for 4-2; After described encrypting messages deciphering, form and carry out message, described message sink processing module is processed this execution message, complete the operational motion (as shown on the table 3D scene, can carrying out the switching of scene, convergent-divergent etc. by mouse roller) of described windows desktop extender.
2.Windows desktop extender loads dynamic link library the explorer that injects Windows:
2-1. obtains the process ID of explorer:
2-1-1. obtains the handle (being hProgram) of shell Program Manager by the FindWindowEx function of Windows.
2-1-2. obtains the handle (being hShellDefView) of the SHELLDLL_DefView subwindow of shell Program Manager.
2-1-3. obtains desktop handle (being hDesktopFolderView) by the FindWindowEx function of Windows.
2-1-4. obtains the process ID (being nDesktopProcessId) of explorer by the GetWindowThreadProcessId function of Windows.
2-2. opens explorer process by the process ID of explorer and obtains process handle:
2-2-1. uses the OpenProcess function of Windows to obtain the process handle of explorer.
2-3. after long-range storage allocation, writes the dynamic link library file path that will inject on explorer:
2-3-1. applies for memory headroom by the VirtualAllocEx function of Windows on explorer, and space size is the required space size of dynamic link library file complete trails that will inject.
2-3-2. is written in dynamic link library file complete trails in the space described in 2-3-1 by the WriteProcessMemory function of Windows.
2-4. creates remote thread and loads the dynamic link library of specifying above:
2-4-1. carries out the establishment of remote thread by the CreateRemoteThread function of Windows, and call LoadLibrary function and load described dynamic link library, if successfully move described DLL module in explorer, if failure is exited this program and finishes.
2-5. wait dynamic link library has loaded and has returned, and releasing memory space completes dynamic link library and injects:
2-5-1. uses the WaitForSingleObject function of Windows to wait for after remote thread creates loaded and returns.
2-5-2. uses the CloseHandle function of Windows to be closed in the process handle of opening in 2-2-1.
2-5-3. uses the VirtualFreeEx function of Windows to be released in the memory headroom described in 2-3-1.
The Window message process of 3.DLL module is taken over and message encryption forwards:
3-1., in the time of DLL module initialization, uses the technology of 2-1, obtains the handle of SHELLDLL_DefView window.
Self-defining forms process of 3-2.DLL module definition (being extended operation Message Processing flow process), defines a forms process title (as NewProgramProc) by the WNDPROC call back function type of Windows.
3-3. utilizes the handle of getting in 3-1, by the SetWindowLongPtr function of Windows, the forms process that explorer is set is self-defining forms process (being NewProgramProc), preserve its original forms process of returning (being the desktop operated of explorer to former Windows, the operational processes flow process of non-extender) pointer simultaneously.
3-4. obtains the forms handle (being hNewDesktopHandle) of the desktop extender receipt message creating in 1-3 with the FindWindowEx function of Windows.
3-5. is inner in self-defining forms process (being NewProgramProc), use the extended operation message (being the parameter m sg in self-defined forms process NewProgramProc) that the feature operation of windows desktop extender produces to process to user, contents processing depends on what function is program want to provide, simultaneously extended operation message is encrypted to formation encrypting messages by the method for 4-1, then encrypting messages is distributed in the message sink processing module of windows desktop extender and go by the PostMessage function of Windows.The inter-process flow process of the original explorer of CallWindowProc function call of Windows for other non-encrypted message (being the message producing under the operation of user's non-extender in use windows desktop), completes the adapter of message flow.
4. the encryption and decryption of extended operation message:
4-1. extended operation message encryption: extended message is offset to conversion process (as the ID predefine constant value of extended message is all added to WM_USER adds X, wherein WM_USER is the initial value of the user self-defined message of Windows definition, and X is the round values of a nonnegative number) formation encrypting messages.
4-2. extended operation decrypt messages: encrypting messages is entered to anti-line displacement conversion process (deduct X as the ID predefine constant value of encrypting messages is all deducted to WM_USER, wherein X is the round values of a nonnegative number again) and form execution message.
In summary, a kind of windows desktop method of taking over of the present invention is injected explorer by the mode of Remote create dynamic link library by DLL module, avoid desktop security software by the technology of Remote create and the message in traditional Hook Technique is tackled to the problem of filtering, realize and effectively take over windows desktop, allow Windows extender can on the desktop of Windows, carry out smoothly application.
Although more than described the specific embodiment of the present invention; but being familiar with those skilled in the art is to be understood that; our described specific embodiment is illustrative; instead of for the restriction to scope of the present invention; those of ordinary skill in the art are in equivalent modification and the variation done according to spirit of the present invention, all should be encompassed in the scope that claim of the present invention protects.