Hey Wyatt,
I investigated the problem a bit further and could reproduce the issue with a slightly modified version of file "Example.c" that is part of the downloaded zip file.
I made following four changes:1. Adder a for loop to execute the example several times2. Added a call to TA_SetCustomProxy3. Replaced TA_IsGenuineEx with TA_IsGenuine4. Uncommented TA_GetFeatureValue
The modified file can be found at the end op this post.
My observations are as follows:1. When I comment out the call to TA_SetCustomProxy all is fine.2. When I replace TA_IsGenuine with TA_IsGenuineEx all is fine (because the servers are not accessed I assume).3. Setting the for loop to iterate only once works fine.4. Iterating at lease two times with a call to TA_SetCustomProxy and TA_IsGenuine crashes the application. With this setup I mostly get segmentation faults. Other faults do happen.
A strange thing though is that when I run the application with Valgrind Memory Analyzer it runs smoothly.
This is the modified Example.c file (as usual, I replaced the version GUID with all Xs in this post):
#include <stdio.h>#include <stdlib.h>
// Support Unicode compilation and non-Windows compilation#ifdef _WIN32 #include <tchar.h>#else #define _T(x) x typedef char TCHAR;#endif
// To use the static version of TurboActivate then uncomment the next line//#define TURBOACTIVATE_STATIC
// Include the correct library on Windows#ifdef TURBOACTIVATE_STATIC #ifdef _DEBUG #ifdef _DLL #pragma comment(lib, "TurboActivate-MDd.lib") #else #pragma comment(lib, "TurboActivate-MTd.lib") #endif #else #ifdef _DLL #pragma comment(lib, "TurboActivate-MD.lib") #else #pragma comment(lib, "TurboActivate-MT.lib") #endif #endif#else #pragma comment (lib, "TurboActivate.lib")#endif
#include "TurboActivate.h"
/* The handle used for TurboActivate function calls. */uint32_t taHandle;
int main(int argc, char** argv){ // Set the trial flags you want to use. Here we've selected that the // trial data should be stored system-wide (TA_SYSTEM) and that we should // use un-resetable verified trials (TA_VERIFIED_TRIAL). uint32_t trialFlags = TA_VERIFIED_TRIAL | TA_SYSTEM;
/* Used to store TurboActivate responses. */ HRESULT hr; GENUINE_OPTIONS opts = {0}; opts.nLength = sizeof(GENUINE_OPTIONS);
// In this example we won't show an error if the activation // was done offline by passing the TA_SKIP_OFFLINE flag opts.flags = TA_SKIP_OFFLINE;
// How often to verify with the LimeLM servers (90 days) opts.nDaysBetweenChecks = 90;
// The grace period if TurboActivate couldn't connect to the servers. // after the grace period is over TA_IsGenuineEx() will return TA_FAIL instead of // TA_E_INET or TA_E_INET_DELAYED opts.nGraceDaysOnInetErr = 14;
for (int i=0; i<2; i++) {
STRCTYPE proxy = "http://192.168.1.4:8080"; hr = TA_SetCustomProxy(proxy); // working when commented out printf("TA_SetCustomProxy - hr = %d\n", hr);
/* Get the handle that will be used for TurboActivate function calls.
TODO: paste your Version GUID here. */ taHandle = TA_GetHandle(_T("XXXXXXXXXXXXXXXXXXXXXX.XXXXXXXX"));
if (taHandle == 0) { printf("Failed to get the handle for the Version GUID specified. "); printf("Make sure the Version GUID is correct, and that TurboActivate.dat is in the same folder as your app.\n\n"); printf("Or use TA_PDetsFromPath() to load the TurboActivate.dat first before getting the handle.\n"); exit(1); }
// hr = TA_IsGenuineEx(taHandle, &opts); hr = TA_IsGenuine(taHandle);
if (hr == TA_OK || hr == TA_E_FEATURES_CHANGED || hr == TA_E_INET || hr == TA_E_INET_DELAYED) { TCHAR * featureValue;
printf("YourApp is activated and genuine! Enable any app features now.\n");
if (hr == TA_E_INET || hr == TA_E_INET_DELAYED) { // TODO: show a warning to your customers that this time (or the last time) // the IsGenuineEx() failed to connect to the LimeLM servers. printf("YourApp is activated, but it failed to verify the activation with the LimeLM servers. You can still use the app for the duration of the grace period.\n"); }
// If this app is activated then you can get a custom license // field value (completely optional) // See: https://wyday.com/limelm/help/license-features/
// First get the size of the buffer that we need to store the custom license // field. hr = TA_GetFeatureValue(taHandle, _T("Expiration date"), 0, 0);
// allocate the buffer based on the size TurboActivate told us. featureValue = (TCHAR *)malloc(hr * sizeof(TCHAR));
// try to get the value and store it in the buffer hr = TA_GetFeatureValue(taHandle, _T("Expiration date"), featureValue, hr);
if (hr == TA_OK) {#ifdef _WIN32 wprintf(L"Feature value: %s\n", featureValue);#else printf("Feature value: %s\n", featureValue);#endif } else printf("Getting feature failed: 0x%x\n", hr);
free(featureValue);
} else // not activated or genuine { uint32_t trialDays = 0;
// Look in TurboActivate.h for what the error codes mean. printf("Not activated: hr = 0x%x\n", hr);
// Check if the failure was a result of the customer not being activated // OR if the failure was a result the customer not being able to re-verify with // the activations servers. if (TA_IsActivated(taHandle) == TA_OK) { // There is still activation data on the computer, and it's valid.
// This means that IsGenuineEx() is saying "not activated" (a.k.a. TA_FAIL) // because the customer blocked connections to the activation servers (intentionally or not) // for nDaysBetweenChecks + nGraceDaysOnInetErr days.
// What you should do now is prompt the user telling them before they can use your app that they need // to reverify with the activation servers.
char userResp = 0;
printf("You must reverify with the activation servers before you can use this app. "); printf("Type R and then press enter to retry after you've ensured that you're connected to the internet. "); printf("Or to exit the app press X.\n");
while ((userResp = getchar()) != 'X' && userResp != 'x') { if (userResp == 'R' || userResp == 'r') { // Now we're using TA_IsGenuine() to retry immediately. Note that we're not using // TA_IsGenuineEx() because TA_IsGenuineEx() waits 5 hours after an internet failure // before retrying to contact the servers. TA_IsGenuine() retries immediately. hr = TA_IsGenuine(taHandle);
if (hr == TA_OK || hr == TA_E_FEATURES_CHANGED) { printf("Successfully reverified with the servers! You can now continue to use the app!\n"); break; } else { printf("Failed to reverify with the servers. "); printf("Make sure you're connected to the internet and that you're not blocking access to the activation servers. "); printf("Then press R to retry again.: Error code = 0x%x\n", hr);
// Note: actually show a human readable error code to the customer! // hr = 0xNN is not a useful error code. Look in TurboActivate.h for a // full list of error codes and what they mean. } } else { printf("Invalid input. Press R to try to reverify with the servers. Press X to exit the app.\n"); } }
// exit the app if (userResp == 'X' || userResp == 'x') exit(1); } else { // The customer was never activated or deactivated (or got deactivated). }
// Start or re-validate the trial if it has already started. // This need to be called at least once before you can use // any other trial functions. hr = TA_UseTrial(taHandle, trialFlags, NULL);
if (hr == TA_OK) { // Get the number of trial days remaining. hr = TA_TrialDaysRemaining(taHandle, trialFlags, &trialDays);
if (hr == TA_OK) printf("Trial days remaining: %d\n", trialDays); else printf("Failed to get the trial days remaining: hr = 0x%x\n", hr); } else printf("TA_UseTrial failed: hr = 0x%x\n", hr);
//TODO: prompt for a product key (if it's not present) //Note: here we're just hard-coding the product key to show how you // save the product key and try to activation
// Also note we're using the TA_SYSTEM flag. This means the activation will be system-wide. // However calling using the TA_SYSTEM flag (the first time only) requires system-admin privileges. // If your app will never have system admin privileges then you can use the TA_USER flag. hr = TA_CheckAndSavePKey(taHandle, _T("V4Y4-3QYX-3ZRJ-ASM6-FVDZ-V3BN-M2TA"), TA_SYSTEM); if (hr == TA_OK) { printf("Product key saved successfully.\n");
// try to activate hr = TA_Activate(taHandle, NULL);
if (hr == TA_OK) printf("Activated successfully\n"); else printf("Activation failed: hr = 0x%x\n", hr); } else printf("Product key failed to save: hr = 0x%x\n", hr); } }
printf("Hello world.\n"); return 0;}