Armadillo DLL call

Discussion in 'Game Development (Technical)' started by Jack Norton, Aug 20, 2004.

  1. Jack Norton

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    5,130
    Likes Received:
    0
    BFG asked me to put armadillo in my game code... but I wasn't able to.
    Anyone here used it?
    How can I "Call IncrementCounter() from ArmAccess.dll " (that's what they asked me) ?
    since he said that 14 other programmer had no problem doing it in 10 minutes, maybe someone of them is a member of this forums and can help me...I'm just a beginner C programmer after all... :)
     
    #1 Jack Norton, Aug 20, 2004
    Last edited: Aug 20, 2004
  2. Matthew

    Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    493
    Likes Received:
    0
    I'm not much a system programmer, myself, but I managed to incorporate Armadillo into my Virtools-based project last year. I wrapped both the code install function and increment count function (I triggered this every minute--basically change a 60-use trial into a 60-minute trial...probably what Paul wants you to do).

    I honestly can't remember what else what needed, in terms of .DLL/LIB files for compilation. Armadillo intercepts the DLL loading call unless you rename ArmAccess.DLL. I'm sure someone here has a much more solid understanding of it than I do. Anyway, here's the code:

    Code:
    /* armadillo stuff start */
    // These typedefs show the compiler the formats of the functions  
    typedef bool (__stdcall *CheckCodeFn)(const char *name, const char *code);  
    typedef bool (__stdcall *VerifyKeyFn)(const char *name, const char *code);  
    typedef bool (__stdcall *InstallKeyFn)(const char *name, const char *code);  
    typedef bool (__stdcall *InstallKeyLaterFn)(const char *name, const char *code);  
    typedef bool (__stdcall *UninstallKeyFn)(void);  
    typedef bool (__stdcall *SetDefaultKeyFn)(void);  
    typedef bool (__stdcall *UpdateEnvironmentFn)(void);  
    typedef bool (__stdcall *IncrementCounterFn)(void);  
    typedef int  (__stdcall *CopiesRunningFn)(void);  
    typedef bool (__stdcall *ChangeHardwareLockFn)(void);  
    typedef DWORD (__stdcall *GetShellProcessIDFn)(void);  
    typedef bool (__stdcall *FixClockFn)(const char *fixclockkey);  
    typedef DWORD (__stdcall *RawFingerprintInfoFn)(DWORD item);  
    typedef bool (__stdcall *SetUserStringFn)(int which, const char *string);  
    typedef DWORD (__stdcall *GetUserStringFn)(int which, char *buffer, DWORD bufferlength);   
    
    bool InstallArmadilloCode(const char *name, const char *codestring) {  
    	bool returnvalue=false;  
    	
    	/* Change "ArmAccess.DLL" to whatever you renamed it to */  
    	HINSTANCE libInst=LoadLibrary("ArmAccess.DLL");  
    	if (!libInst) return false; /* Couldn't load library */  
    	
    	/* Substitute the typedefs above for functions other than CheckCode */  
    	CheckCodeFn CheckCode=(CheckCodeFn)GetProcAddress(libInst, "CheckCode");  
    	if (CheckCode==0) return false; /* Couldn't find function */  
    	
    	returnvalue=CheckCode(name, codestring);  
    	FreeLibrary(libInst);  
    	return returnvalue;  
    }; 
    
    bool IncrementArmadilloCounter(void) {  
    	bool returnvalue=false;  
    	
    	/* Change "ArmAccess.DLL" to whatever you renamed it to */  
    	HINSTANCE libInst=LoadLibrary("ArmAccess.DLL");  
    	if (!libInst) return false; /* Couldn't load library */  
    	
    	/* Substitute the typedefs above for functions other than CheckCode */  
    	IncrementCounterFn IncrementCounter=(IncrementCounterFn)GetProcAddress(libInst, "IncrementCounter");  
    	if (IncrementCounter==0) return false; /* Couldn't find function */  
    	
    	returnvalue=IncrementCounter();  
    	FreeLibrary(libInst);  
    	return returnvalue;  
    };
    
    /* armadillo stuff end */
    
     
  3. Scorpio

    Indie Author

    Joined:
    Aug 1, 2004
    Messages:
    101
    Likes Received:
    0
    I was about to post some code but Matthew's looks similar to mine. We do the exact same thing: increment the usage counter every 60 seconds to simulate a timed demo (works great too!) :)
     
  4. Jack Norton

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    5,130
    Likes Received:
    0
    Thanks :)
    Seems that worked, since don't have armadillo I guess I'll send the new version to them hoping that works :p at least it does compile without problems!
     
  5. mrfun

    Indie Author

    Joined:
    Jul 30, 2004
    Messages:
    21
    Likes Received:
    0
    Jack,

    I just added Armadillo/SoftwarePassport for a game for BigFish a few days ago. The standalone .dll they send really isn't enough info..

    If you download the real SDK it has an API help file showing how to add it in different languages as well as the wrapper utility so you can test out the time limit yourself.

    Click download from here: http://siliconrealms.com/armadillo.shtml - it asks for info but sends you a link to download right away:

    Also, after each increment I check to see if it's expired and quit if it is, seemed like it needed this on my tests.
     
  6. Jack Norton

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    5,130
    Likes Received:
    0
    Ha yes, infact right now I only increase that mysterious counter without any way to know if it is expired or not :)
    Would you mind sending me (even privately in an email to info@studio4.com)the piece of code that check for expiration? thanks in advance :)

    ...so seems that wasn't so easy (10 minutes to implement? hmm) :eek:
     
  7. mkovacic

    Original Member Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    127
    Likes Received:
    0
    Here...

    Code:
    #include <windows.h>
    
    typedef DWORD (__stdcall *GetUserStringFn)(int which, char *buffer, DWORD bufferlength);
    bool ARM_IsDemo()
    	{
    #ifdef _DEBUG
    	 return (true);
    #endif
    	 char str[256];
    	 if (!GetEnvironmentVariable("CRTTYPE", str, 255))
    		 return (false);
    
    	 strupr(str);
    	 if (strcmp(str, "CRTTRIAL")==0)
    		 return (true);
    	 else
    		 return (false);
    
    	}
    
    bool ARM_IsExpired()
    	{
    	 if (GetEnvironmentVariable("EXPIRED", NULL, 0))
    		 return (true);
    	 else
    		 return (false);
    	}
    
    int ARM_GetCounterCurrent()
    	{
    	 char value[256]="";
    	 int retVal;
    	 if (!GetEnvironmentVariable("USESLEFT", value, 255))
    		 return (0);
    	 else
    		 {
    //		  g_pLogFile->Infof("GetEnv(USESLEFT)=%s\n", value );
    		  sscanf(value, "%i", &retVal);
    //		  g_pLogFile->Infof("GetEnv(USESLEFT) parsed=%i\n", retVal );
    		  return(retVal);
    		 }
    	}
    typedef bool (__stdcall *IncrementCounterFn)(void);  
    void ARM_IncCounter()
    	{
        /* Change "ArmAccess.DLL" to whatever you renamed it to */  
        HINSTANCE libInst=LoadLibrary("ArmAccess.DLL");  
        if (!libInst) return; /* Couldn't load library */  
     
        /* Substitute the typedefs above for functions other than CheckCode */  
        IncrementCounterFn IncrementCounter=(IncrementCounterFn)GetProcAddress(libInst, "IncrementCounter");  
    	
    	if (IncrementCounter==0)
    		{
    		 return; /* Couldn't find function */  
    		 FreeLibrary(libInst);  
    		}
     
        IncrementCounter();  
        FreeLibrary(libInst);  
     	}
    
    BTW, we are the ones who told BFG about this "trick", but they didn't have the Pro version of Armadillo at that time, so we had to go with the sucky 3 uses expiration. *grumble*
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer