Game plugin

Writing a game plugin for Force-Sender application (or use the existing plugins in own programs)

The code is written in C++ and MFC. You need Visual Studio 2005 or higher in standard edition as minimum.
The free express edition will not work.

If you own information’s about a ingame value read out solution which is designed from the from game developer, you can write a plugin for the force sender application. This plugin will use your found read out solution and some special DLL function to tell the sender the resulting values.
You will find the golden master plugin source code in the /other stuff/sourcecode/gameplugin directory of your x-sim2 installation.
The plugin must support four generally exported DLL functions. These are:
DllInfo GetType(int number);
GetInfo GetPluginName(int number);
GetPluginData GetDataArray(int number);
GetPluginDataEx GetDataArrayEx(int number);
AutoScanInfo GetAutoScanInfo(int number);

First the GetType() function is called, which must return two string information’s to identify the plugin itself. You can only exchange the short plugin name, that will be displayed in the force sender plugin selection menu. It is stored in dllinfo name. The name cannot be longer than ten character to reduce the menu width. Do not change the “SenderPlug” identification here.
After you have selected a plugin, the force sender will call the GetPluginName() function which will carry all other name string information’s about that plugin. Only fill out all the information lines and insure all effect names are 30 character long and the plugin description is 50 character long.
Now you have to insert your own code in the two GetDataArray() functions. If you have a external readout program, you can add here your inter process code to that external software. In our GrandPrix sample case the external tool is GPxPatch and the inter process code is a memory mapped file. The GetDataArrayEx() function is called in the new Force Sender 2 application that comes with X-Sim2. You need the old GetDataArray() function only for backward compatibility reason for X-Sim 1.8.
The GetAutoScanInfo() function will return a list of window names and game exe names. This list will be inserted in the plugin assistant list. If there is a new plugin written with a other number of entries this will be updated. If the entries are only changed, you have to delete the registry of this auto scan with the regedit. If this function is missing and not exported, there will be no entries in the assistant list but one empty user defined row for testing purpose.

To add the auto scan feature add following lines to your code:
struct AutoScanInfo
{
   intnumberofentries;
   charfindwindowsname[20][260];
   charexecutablename[20][260];
};

DLLEXPORT AutoScanInfo GetAutoScanInfo(int number);

AutoScanInfo GetAutoScanInfo(int number)
{
   AutoScanInfo newinfo={0};
   CString windowname="GTR2";
   for(int z=0; z < windowname.GetLength(); z++){newinfo.findwindowsname[0][z]=windowname[z];}
   CString programname="GTR2.exe";
   for(int z=0; z < programname.GetLength(); z++){newinfo.executablename[0][z]=programname[z];}
   newinfo.numberofentries=1;
   return newinfo;
}

Notes:
-The plugin polling can be different from about 1 ms up to e.g. one second. Insure the readout code in GetDataArray(Ex) is fast enough or threaded.
-If you use a external readout application. you can start your it in the init section of your DLL file and stop it in DLL_DETACH case.
-The integer “number” in all the function calls is not longer used.
-GetDataArray() is not used in X-Sim2, use GetDataArrayEx() instead and fill out the old function to support older x-sim versions.