Discussion on Windows System Forwarder
Keywords: Forward service, DLL, HOOK, SKINMAGIC
It may be because I am tired of Windows2000's dead interface, I will write a program for germination, the main function is the interfacial replacement, just like WinAmp, replace the "skin" of Cool.
Principle: Use the third party to change the SDK, HOOK function. Analysis: There are many third-party exchanges on the Internet to replace their Application to replace their own Application with the API provided. However, it is still not possible for the entire system. Because in the App source code written in ourselves, the API can be explicitly called, but for other processes that are running, we can't get his source code, thereby filling the API function. We use the hook technology to encapsulate DLLs, and the dynamic snaps in other processes. So, first build your own DLL. Its action is to encapsulate the DLL of the SDK. Use VC as a development tool. Create a DLL project that extends MFC. Below is the main source code for the DLL itself.
// skin_dll.cpp: defines the initialization routines for the dll.//
#include "stdafx.h"
#include
#ifdef _debug # define new debug_new # undef this_filestatic char this_file [] = __file __; # ENDIF
#define mylibapi externaln "c" __declspec (dllexport)
#include "skin_dll.h"
#include "skinmagiclib.h"
#pragma data_seg ("MyData") hHOOK SKIN_HOOK = NULL; Hinstance Glhinstance = NULL; WNDPROC OLDWndProc = NULL; #pragma data_seg () int flag= 0; // flag. Indicates whether a WINDOW has been changed
LRESULT WINAPI skinhookproc (int nCode, WPARAM wparam, LPARAM lparam); BOOL stophook (); BOOL starthook (HWND hwnd); LRESULT CALLBACK DefWindowProc (HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam); BOOL SetInterface (HWND hwnd);
HWnd getframewindowhandle (hwnd hwnd);
Bool SelectclassName (HWND HWND);
Static AFX_EXTENSION_MODULE SKIN_DLLDLL = {null, null};
Extern "C" int apientrydllmain (Hinstance Hinstance, DWORD DWREASON, LPVOID LPRESERVED) {// Remove this if you use lpreserved unreferenced_parameter (lpreserved);
if (dwReason == DLL_PROCESS_ATTACH) {TRACE0 ( "SKIN_DLL.DLL Initializing / n!"); // Extension DLL one-time initialization if (! AfxInitExtensionModule (Skin_dllDLL, hInstance)) return 0; new CDynLinkLibrary (Skin_dllDLL);
glhInstance = hInstance; hInstance // then linked to the target process} else if (dwReason == DLL_PROCESS_DETACH) {TRACE0 ( "SKIN_DLL.DLL Terminating / n!"); // Terminate the library before destructors are called AfxTermExtensionModule (Skin_dllDLL); } Returnif 1; // ok}
Bool StartHook (hwnd hwnd) {
SKIN_HOOK = SETWINDOWSHOKEX (Wh_CallWndProc, SkinhookProc, Glhinstance, 0); // Set a global hook. About Hook's operation is not explained in detail, the type of this hook is wh_callwndproc, which is called before the system calls WndProc before each window. SkinhookProc. Return Truc.
}
Bool stophook () {if (unhookwindowshookex (skin_hook) {return true;} else {AFXMessageBox ("can not sharse!", Mb_ok, 0); Return False;}
}
LResult WinApi SkinhookProc (int Ncode, WPARAM WPARAM, LPARAM LPARAM) {
IF (Flag == 0) {hWnd hWnd = ((pcwpstruct) lparam) -> hwnd; char sclassname [201] = "/ 0";
HWnd framehandle = getframewindowhandle (hwnd);
if (framehandle) {// For the right window. Here only several examples can be made to the NOTEPAD, WORD, and various dialogs. GetClassName (FrameHandle, SclassName, 200); IF (STRCMP (SCLASSNAME, "NOTEPAD") == 0 ||
STRCMP (SclassName, "OPUSAPP") == 0 || Strcmp (SclassName, "# 32770") == 0 || StrCMP (SclassName, "HH Parent") == 0) {
IF (setInterface (FrameHandle) == 1) // According to the SkinMagicAPI function, you should use the FrameWindow's M_HWND to call. For the SkinmagicAPI function description, also explain {FLAG = 1;} else {
AfxMessageBox ("Error", MB_OK);}}} else {MessageBox (Null, "Can not find Find Frame", Error, MB_OK);}} Return CallNexthookex (Skin_HOOK, NCODE, WPARAM, LPARAM);
Bool setInterface (hwnd hwnd) {flag = 1; hrsrc findres = FindResource (Glhinstance, "Kromo", "Skinmagic"); HGlobal loading (GLHINSTANCE, FINDRES);
Verify (1 == INITSKINMAGICLIB (GLHINSTANCE, "DEMO", NULL, NULL); Verify (1 == LoadskinfromResource (Glhinstance, "Corona", "SkinMagic")); Verify (1 == setwindowskin (hwnd, "mainframe" ))); Verify (1 == setDialogskin ("dialog");
// The above is the API function of Skinmagic. The purpose of writing this DLL is to encapsulate these operations Return 1;
}
HWnd getframewindowhandle (hwnd hwnd) {// gets FrameWindow handle CWnd * tempwwnd; TempWnd = CWnd :: fromHandle (hwnd); //. Attach (hwnd);
CWND * pfinal = TempWnd-> getParentFrame (); if (pfinal == null) Return hwnd;
While (pfinal-> getparentframe ()) {pfinal = (cwnd *) pfinal-> getParentFrame ();
Return pfinal-> m_hwnd;
}
Filling SkinMagic.lib in Project-> Setting-> link-> lib
Finally, compile the connection.
Question: I think that the amount of work is great for all the windows in the system. In the example program above, I only change the limited application. If the in-depth point involved is, it is difficult to change the IE, the resource browser and other system interfaces. I have tried to win the IE, but the menu bar was blocked. Also, it is the judgment of the process window, which is really a displayed chicken rib.
The above program is just a responsible DEMO, and the consequences are at your own risk.
I hope everyone can give me a criticism! Email: alphaone@163.com