THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/02/2010 at 17:23, xxxxxxxx wrote:
Here's all of the code that pertains to the serialization. Without the algorithm.
//SERIAL CODE/////////////////////////////////
//////////////////////////////////////////////
class PlanetXSerial : public SNHookClass
{
private:
const String title;
public:
PlanetXSerial() : title("Planet X Generator") {}
virtual LONG SNCheck(const String &c4dsn,const String &sn,LONG regdate,LONG curdate)
{
LONG err=0;
SerialInfo si;
GeGetSerialInfo(SERIAL_CINEMA4D, &si);
LONG mySN = si.nr.SubStr(6,5).StringToLong(&err);
LONG myAlgorithm = **REMOVED**
String mySerial = LongToString(myAlgorithm);
if (sn == mySerial)
{
return SN_OKAY;
}
else
{
return SN_WRONGNUMBER;
}
///return sn == mySerial ? SN_OKAY : SN_WRONGNUMBER;
}
virtual const String& GetTitle()
{
return title;
}
};
PlanetXSerial *snhook = NULL;
Bool RegisterPlanetXSerial()
{
snhook = gNew PlanetXSerial;
return snhook->Register(ID_PLANET_OBJECT_SERIAL, SNFLAG_OWN);
return FALSE;
}
void FreePlanetXSerial()
{
if (snhook)
gDelete(snhook);
}
And here is the main.cpp
/////////////////////////////////////////////////////////////
// Planet
// Starts the plugin registration
#include "c4d.h"
#include <string.h>
// forward declarations
Bool RegisterPlanet(void);
Bool RegisterSun(void);
Bool RegisterSpace(void);
Bool RegisterPlanetXSerial();
void FreePlanetXSerial();
C4D_CrashHandler old_handler;
void SDKCrashHandler(CHAR *crashinfo)
{
// don't forget to call the original handler!!!
if (old_handler) (*old_handler)(crashinfo);
}
void EnhanceMainMenu(void)
{
// do this only if necessary - otherwise the user will end up with dozens of menus!
if (!(GeGetVersionType()&VERSION_CINEMA4D)) // only if C4D is loaded
return;
BaseContainer *bc = GetMenuResource(String("M_EDITOR"));
if (!bc) return;
// search for the most important menu entry. if present, the user has customized the settings
// -> don't add menu again
if (SearchMenuResource(bc,String("PLUGIN_CMD_1000472")))
return;
GeData *last = SearchPluginMenuResource();
BaseContainer sc;
sc.InsData(MENURESOURCE_SUBTITLE,String("SDK Test"));
sc.InsData(MENURESOURCE_COMMAND,String("IDM_NEU")); // add C4D's new scene command to menu
sc.InsData(MENURESOURCE_SEPERATOR,TRUE);
sc.InsData(MENURESOURCE_COMMAND,String("PLUGIN_CMD_1000472")); // add ActiveObject dialog to menu
if (last)
bc->InsDataAfter(MENURESOURCE_STRING,sc,last);
else // user killed plugin menu - add as last overall entry
bc->InsData(MENURESOURCE_STRING,sc);
}
Bool PluginStart(void)
{
// example of installing a crashhandler
old_handler = C4DOS.CrashHandler; // backup the original handler (must be called!)
C4DOS.CrashHandler = SDKCrashHandler; // insert the own handler
// Planet Object
if (!RegisterPlanet()) return FALSE;
// Sun Object
if (!RegisterSun()) return FALSE;
// Space Object
if (!RegisterSpace()) return FALSE;
//SERIAL NUMBER
if (!RegisterPlanetXSerial()) return FALSE;
return RegisterPlanet() && RegisterSun() && RegisterSpace();
}
void PluginEnd(void)
{
FreePlanetXSerial();
}
Bool PluginMessage(LONG id, void *data)
{
//use the following lines to set a plugin priority
//
switch (id)
{
case C4DPL_INIT_SYS:
if (!resource.Init()) return FALSE; // don't start plugin without resource
if (!RegisterPlanetXSerial()) return FALSE;
return TRUE;
case C4DPL_ENDACTIVITY:
FreePlanetXSerial(); return TRUE;
case C4DMSG_PRIORITY:
return TRUE;
case C4DPL_BUILDMENU:
//EnhanceMainMenu();
break;
case C4DPL_COMMANDLINEARGS:
{
C4DPL_CommandLineArgs *args = (C4DPL_CommandLineArgs* )data;
LONG i;
for (i=0;i<args->argc;i++)
{
if (!args->argv[i]) continue;
if (!strcmp(args->argv[i],"--help") || !strcmp(args->argv[i],"-help"))
{
// do not clear the entry so that other plugins can make their output!!!
GePrint("\x01-SDK is here :-)");
}
else if (!strcmp(args->argv[i],"-SDK"))
{
args->argv[i] = NULL;
GePrint("\x01-SDK executed:-)");
}
else if (!strcmp(args->argv[i],"-plugincrash"))
{
args->argv[i] = NULL;
*((LONG* )0) = 1234;
}
}
}
break;
case C4DPL_EDITIMAGE:
{
GePrint("Something Changed");
C4DPL_EditImage *editimage = (C4DPL_EditImage* )data;
if (!data) break;
if (editimage->return_processed) break;
GePrint("C4DSDK - Edit Image Hook: "+editimage->imagefn->GetString());
// editimage->return_processed = TRUE; if image was processed
}
return FALSE;
}
return FALSE;
}
I'm a bit frustrated because I can't see why the user would be able to see the plugin when the serial number is not valid. If I start up C4D I get a message that say's WRONG SERIAL NUMBER for PLanet X Generator. Then I click cancel to bypass the serial number dialog and I go in to C4D and I am still able to use the plugin.
This is all I lack to finish before the release of my plugin so you can imagine my frustration that this is not playing nice. Does anyone see anything wrong with my code?
Thanks a million to the person who solves this and I will owe you a large PINT.
~Shawn