Notes on the programming of the shawl plugin

Source: Internet
Author: User

1. After the plugin is activated, the game's loader will be loaded according to the settings, each game has a corresponding loader,
The form is Loader.dll, needs the game side to develop itself, the function is equivalent to the original Launcher.exe.


2. Plugin will create good one standard Win32 window passed to Loader.dll, we are for this window programming, as usual development, basically is the standard Win32 programming way.


3. Loader.dll need to export several standard interfaces for plug-in calls, code implementation at the end of the file.
When writing Loader.dll, according to these standard interfaces to implement the corresponding functions (such as updating the client, call the client, said before, equivalent to launcher).


4. The client is also loaded as a DLL by loader, i.e. Client.dll, preferably using LoadLibraryEx.


5. This standard Win32 window is UNICODE!!!
Can be judged using Winuserapi BOOL WINAPI iswindowunicode (__in hwnd hwnd).
Loader.dll and Client.dll preferably also Unicode, not MBCS, so from the plug-in, to loader, to the client, are Unicode, do not have to do any extra processing, do not need any hack code.


6. In general, Windows messages that are not processed by the client themselves are called DefWindowProc for processing.
According to the previous rule, these "Windows messages that you do not process yourself", be sure to call DEFWINDOWPROCW for processing because the window is Unicode.
If Loader.dll and Client.dll are Unicode, calling DefWindowProc is equivalent to calling DEFWINDOWPROCW.
If Loader.dll and Client.dll are MBCS, it is necessary to display the call DEFWINDOWPROCW when running in the browser, otherwise the window title bar can be garbled and so on, client.exe need to call Defwindowproca when running alone.
To invoke the window if the window is Unicode, the windows that call the Defwindowproc,mbcs must call the Defwindowproca,unicode window must call DEFWINDOWPROCW, or an unexpected problem occurs.
Whether the window is Unicode is determined by the registerclass, RegisterClassEx version that was called before the window was created (Baidu Encyclopedia).


7. The plug-in invokes DefWindowProc, processing Loader.dll and Client.dll messages that are not processed, judging by the return value of one of the interfaces _fancymessage.
_fancymessage returns non-0, the plug-in does not call DefWindowProc; _fancymessage returns 0, the plug-in calls DefWindowProc.
In general, in the client code, when writing WndProc, some of the original programming habits are: the processing of their own message after processing, return 0, do not handle the break, go to call DefWindowProc;
This programming habit will result in returning 0 of those messages, will be processed again by the defwindowproc of the plug-in layer, may lead to unpredictable problems, the most typical is the wm_setcursor message, you set the return 0,
The DefWindowProc of the plug-in layer handles the wm_setcursor again, causing the mouse pointer to be reset to the default shape, and you will see the mouse pointer flashing, a moment in the game shape, and a standard arrow for a moment.


Question: If the client calls the DEFWINDOWPROCW, processing the game logic does not process the message, whether the return value of DEFWINDOWPROCW is 0, this has not been studied, not clear,
To be sure, if the DEFWINDOWPROCW in the client returns 0, the DEFWINDOWPROCW of the plug-in layer will be processed again, which will produce problems that are unknown.


8. The game save directory for c:\users\[user name]\fancy\[game name], such as the dark light of the game directory for C:\Users\admin\fancy\lost.
To get this directory, you can call the system function SHGetSpecialFolderPath, and make a certain processing of its results.

9. Loader.dll needs to be signed with a shawl, otherwise the plugin is not recognized ~ ~


10. Launch the plugin's page code, which can be obtained by studying the Dark light page.
When docking with the shawl, they will give you a simple example, but the light is not enough, you still need to study the dark light of the page mechanism.


When loading Client.dll in Loader.dll, it is best to use LoadLibraryEx (Szdllabsolutepath, 0, Load_with_altered_search_path); So basically all the browsers are fine.
Otherwise, when running under a different browser, some of the client.dll may not be found, resulting in a failure to load.
ie, Chrome, 360se are also more robust, using LoadLibrary is no problem.
Firefox, Safari, QQ browser are a little toss, with LoadLibrary very easy to find Client.dll.


12. No plug-in case with 360 Security browser to start JZWL no problem, start black light can.
360 Security browser comes with the plugin to the loader URL in the domain name has checked, not in his white list does not load.
Put Loader.dll in 360CDN can solve the problem, or go to 360 official website to do URL authentication http://trust.360.cn/join.html.


13. If the right mouse button in the game, such as dress up, in the browser with the right-click gesture, the game will appear the "right-click action" and the "browser right-click gesture" conflict situations.
The right-click message can be masked by a mouse hook, and the callback function returns 1, and the browser will not receive it. It can then be passed to the client in other ways.
At present 360 Safe browser gesture is blocked, travel also can, 2345, Sogou and so on still can't block gesture.

/************************************************************************/
/*                                                                      */
/************************************************************************/




Loader.dll exported standard interface (direct copy, paste can be used):


#include "stdafx.h"
#include "Fancy.h"


unsigned long gtls = 0;
extern "C"
{


//----------------------------------------------------------------------------
_fancycreate implementation
//----------------------------------------------------------------------------


unsigned int __declspec (dllexport) _fancycreate (void* window, const wchar_t* game, const wchar_t* vers, Const wchar_t* Host, unsigned long mode)
{
:: TlsSetValue (Gtls, Fancy3dloader::createloader (window, mode));


:: SetTimer (HWND) window, 0, 10, 0);


return 1;
}


//----------------------------------------------------------------------------
_fancydelete implementation
//----------------------------------------------------------------------------


void __declspec (dllexport) _fancydelete (void* window)
{
:: KillTimer (HWND) window, 0);


fancy3dloader* loader = (fancy3dloader*):: TlsGetValue (GTLS);
if (loader)
Delete loader;


:: TlsSetValue (GTLS, 0);
}


//----------------------------------------------------------------------------
_fancysetup implementation
//----------------------------------------------------------------------------


void __declspec (dllexport) _fancysetup (const wchar_t* name, const wchar_t* value)
{
fancy3dloader* loader = (fancy3dloader*):: TlsGetValue (GTLS);
if (loader)
Loader->setup (name, value);
}


//----------------------------------------------------------------------------
_fancyupdate implementation
//----------------------------------------------------------------------------


unsigned int __declspec (dllexport) _fancyupdate (void* window, unsigned long elapse)
{
fancy3dloader* loader = (fancy3dloader*):: TlsGetValue (GTLS);
if (loader)
Loader->update (elapse);


return 1;
}


//----------------------------------------------------------------------------
_fancyrender implementation
//----------------------------------------------------------------------------


void __declspec (dllexport) _fancyrender (void* window)
{
fancy3dloader* loader = (fancy3dloader*):: TlsGetValue (GTLS);
if (loader)
Loader->render ();
}


//----------------------------------------------------------------------------
_fancymessage implementation
//----------------------------------------------------------------------------


unsigned int __declspec (dllexport) _fancymessage (void* window, unsigned long msgid, unsigned long wparam, unsigned long LPARAM)
{
fancy3dloader* loader = (fancy3dloader*):: TlsGetValue (GTLS);
if (loader)
Return Loader->message (MsgId, wparam, lparam);


return 1;
}


//----------------------------------------------------------------------------
_fancyprogress implementation
//----------------------------------------------------------------------------


Float __declspec (dllexport) _fancyprogress ()
{
For backwards compatibility.


fancy3dloader* loader = (fancy3dloader*):: TlsGetValue (GTLS);
if (loader)
return loader->getprogress ();


return 0.0f;
}


}

Notes on the programming of the shawl plugin

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.