Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Weird Serial Number issue

    Scheduled Pinned Locked Moved SDK Help
    16 Posts 0 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 26/01/2010 at 05:51, xxxxxxxx wrote:

      thanks for the info mallard.   I will try that when I get home.

      ~Shawn

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 26/01/2010 at 08:00, xxxxxxxx wrote:

        And thanks Steve!  🙂   We must have posted at the exact same time because I didn't see your reply until now.  LOL

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 26/01/2010 at 15:53, xxxxxxxx wrote:

          Awesome, thanks guys.   all of your ideas and techniques have led me to a working serial number system..     Now,  I have one last question on this issue.   How do I make the plugin do nothing if the serial number isn't correct?

          ~Shawn

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 27/01/2010 at 01:09, xxxxxxxx wrote:

            Depends whether you use SNHook or Read/WritePluginInfo

            In the first case return SN_WRONGNUMBER in the latter case just leave PluginStart() returning FALSE without calling RegisterMyPlugin()

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 06/02/2010 at 09:33, xxxxxxxx wrote:

              So I set the plugin to return SN_WRONGNUMBER and I get the dialog telling me that the serial is not correct,  however, if I simply press cancel from that Dialog, I am able to go in to C4D and my plugin is available.    Does anyone know why this is happening?

              ~Shawn

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 06/02/2010 at 09:49, xxxxxxxx wrote:

                SOrry..  let me be a bit more specific...

                Here's the code..

                  
                      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);  
                  
                      return sn == mySerial ? SN_OKAY : SN_WRONGNUMBER;  
                  
                

                When the serial number doesn't match mySerial..  I get the box that says incorrect serial number..  however,  I can just cancel out of that dialog and I am able to access C4D and my plugin is available. .    This is in my full version of C4D..

                Thanks,

                ~Shawn

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 07/02/2010 at 09:02, xxxxxxxx wrote:

                  any thoughts on this?

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    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

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 08/02/2010 at 06:01, xxxxxxxx wrote:

                      The SNHookClass will not prevent automatically the loading of plugins if a wrong or empty keyis entered. It only establishes a hook to the Personalize dialog. You have to check for the key independently from the dialog.

                      here is an example that illustrates this:

                      main.cpp

                        
                      #include "c4d.h"  
                        
                      // forward declarations  
                      Bool RegisterExampleSNHook();  
                      void FreeExampleSNHook();  
                      Bool IsSerialOKExampleHook();  
                        
                      Bool RegisterMenuTest(void);  
                        
                        
                      Bool PluginStart(void)  
                      {  
                        if (!IsSerialOKExampleHook()) return FALSE; //don't load plugins if key is wrong  
                        
                        if (!RegisterMenuTest()) return FALSE;  
                        
                        return TRUE;  
                      }  
                        
                      void PluginEnd(void)  
                      {  
                        FreeExampleSNHook();  
                      }  
                        
                      Bool PluginMessage(LONG id, void *data)  
                      {  
                        switch (id)  
                        {  
                            case C4DPL_INIT_SYS:  
                                if (!resource.Init()) return FALSE; // don't start plugin without resource  
                        
                                // important, the serial hook must be registered before PluginStart(), best in C4DPL_INIT_SYS  
                                if (!RegisterExampleSNHook()) return FALSE;  
                                  
                                return TRUE;  
                        
                        }  
                        
                        return FALSE;  
                      }  
                      

                      serial_hook.cpp

                        
                      #include "c4d_resource.h"  
                      #include "lib_sn.h"  
                      #include "c4d_symbols.h"  
                        
                      class ExampleSNHookClass : public SNHookClass  
                      {  
                        public:  
                            ExampleSNHookClass()  
                            {  
                                name = GeLoadString(IDS_SERIAL_HOOK);  
                                if(!name.Content())  
                                    name = "C++ SDK - Example Serial Hook";  
                        
                                sn_ok = FALSE;  
                            }  
                        
                            virtual LONG SNCheck(const String &c4dsn,const String &sn,LONG regdate,LONG curdate)  
                            {  
                                if (sn.Content() && sn == String("123456789-abcdef"))  
                                {  
                                    sn_ok = TRUE;  
                                    return SN_OKAY;  
                                }  
                        
                                sn_ok = FALSE;  
                                return SN_WRONGNUMBER;  
                            }  
                        
                            virtual const String& GetTitle()  
                            {  
                                return name;  
                            }  
                        
                            Bool IsSerialOK() const { return sn_ok; }  
                        
                        private:  
                            String name;  
                            Bool sn_ok;  
                      };  
                        
                      ExampleSNHookClass *snhook = NULL;  
                        
                      Bool RegisterExampleSNHook()  
                      {  
                        snhook = gNew ExampleSNHookClass;  
                        if (!snhook->Register(450000241, SNFLAG_OWN))  
                            return FALSE;  
                        return TRUE;  
                      }  
                        
                      void FreeExampleSNHook()  
                      {  
                        if (snhook)  
                            gDelete(snhook);  
                      }  
                        
                      Bool IsSerialOKExampleHook()  
                      {  
                        if (snhook)  
                            return snhook->IsSerialOK();  
                        
                        return FALSE;  
                      }  
                      

                      cheers,
                      Matthias

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 08/02/2010 at 06:30, xxxxxxxx wrote:

                        Thanks a million Matthias.    You've saved me yet again!   I truly appreciate your efforts here at the plugin cafe.    Top notch!

                        ~Shawn

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post