HowTo: use "PluginServiceFunc" in a external process! [Archive] - Quintessential Forum

PDA

View Full Version : HowTo: use "PluginServiceFunc" in a external process!


shaohao
09-04-2005, 10:28 AM
Hi, dear coders:
This will be cool for you to extend QCD/QMP's plug-in functionshttp://www.quinnware.com/forum/images/icons/icon14.gif.
Here we go:
As PDK says:

// Use to retrieve service func for DSP plugins (or other inproc process that
//doesn't have access to PluginServiceFunc)
// Eg: PluginServiceFunc Service = (PluginServiceFunc)SendMessage
//(hwndPlayer, WM_GETSERVICEFUNC, 0, 0);
// Set WPARAM = PLUGIN_API_WANTUTF8 for UTF8 string parameters
#define WM_GETSERVICEFUNC (WM_USER+1)


Is there any way to invoke the Service function in a outproc/external-proc?
Yes!

I get the idea from Robert Kuster's Three Ways To Inject Your Code Into Another Process (http://www.codeguru.com/Cpp/W-P/system/processesmodules/article.php/c5767).

And write a useful class "QMPService".
You can simply use it like below:

HWND hwndPlayer = FindWindow( "PlayerCanvas", NULL);
if ( hwndPlayer) {
char buf[512];

QMPService qmp;
qmp.Attach( hwndPlayer);

qmp.Service( opGetTrackName, buf, sizeof(buf), -1);
printf( "%s\n", buf);
}
.
.
.


Note:

You must compile your project into a Release version NOT a Debug version otherwise the player will be crashedhttp://www.quinnware.com/forum/images/icons/icon4.gif.
You can modify the class "QMPService" to make it better. Remember to attach back here for sharing:)
If you want to pass a pointer to param1/param2, you must use the class QMPMemory. find the solution in test project.
I attach a test project for understanding.

The project has tested on WinXP SP2 VS.Net 2003. It include a project converter which can convert project file for VC++7.1 to VC++6.0.

Usage of "QMPService": copy QMPService.h and QCDModDefs.h into your project and include "QMPService.h"

shaohao
09-06-2005, 05:01 PM
Updated!

Add a QMPMemory class to support more ops.

underplay
09-19-2005, 03:38 AM
Hey man, thanks, this is very helpful :) Btw, the link on your signature is dead.