Error 14 on OSX

Hi There,

For some reason, all of a sudden, I'm seeing Error 14 return when I use GetPKey(); I referenced it and it says its a Windows only error, but I'm building and running my app on OSX. Maybe I didn't reference it correctly in the TurboActivate.h file? I can deactivate and reactivate the key, but if I just want to retreive the key, the error comes back. Any thoughts?

Thanks,Arie

//Get product key if (options[SERIAL]) { STRTYPE key; hr = IsActivated(TA_GUID); if (hr == TA_OK) { hr = GetPKey(key, 35); if (hr == TA_OK) { printf("%s\n", key); return 0; } else { printf("There was a problem retrieving the stored key. Error: %d\n\n", hr); return 1; } } else { printf("Product key is not activated.\nUnable to retrieve product key.\n\n"); return 0; } }

So, I thought Error 14 might relate to the buffer size problem, so I increased the buffer to like 32000, and then got the same error. Then I increased it to 1000000 and got the same issue, then I set the buffer to 0 and got Error 35. What's strange is that this was working and now it's not. I didn't touch the function to retrieve either. Can you help out?

Thanks,Arie

First, before you do anything else make sure you're using the latest version of TurboActivate. Next, the reason you're getting error 35 when you set the buffer size to 0, is because TurboActivate is returning the buffer size needed (see the comment documentation for the function).

My guess is that you're using an old version of TA.

I referenced it and it says its a Windows only error

It's not. Error code 14 is 0xE in hex. So, look that up in TurboActivate.h and you find this:

/* MessageId: TA_E_INSUFFICIENT_BUFFER

MessageText:

The the buffer size was too small. Create a larger buffer and try again.*/#define TA_E_INSUFFICIENT_BUFFER ((HRESULT)0x0000000EL)

I'm using the latest, unless you've released a newer version in the last four weeks.

Okay, I thought it was a buffer issue, but I'm still seeing the problem when I increase the buffer size.

I discovered that the issue was related to when I was declaring an array in another part of my code that I want to use for iterating through the features of a product key. This line of code causes the 14 error when I use GetPKey();

std::string featureNames[] = { "first_name", "last_name", "expiry"};

This line comes after the called to GetPKey(), so I'm not understanding how there could be a buffer issue especially when I set the buffer size to a number larger than what is returned when I set it to 0. I guess I'm unclear as to where the "buffer" is created, and why a declaration of a string array would interfere with it.

Thanks,Arie

If this is your code:

STRTYPE key;


hr = IsActivated(TA_GUID);


if (hr == TA_OK) {


hr = GetPKey(key, 35);

Then, there's no buffer allocated (if you're lucky the compiler is setting "key" to NULL, if you're not lucky then a random number will be in "key", and TurboActivate will write to that random pointer (causing either a segfault in your app, or causing other random memory in your app to be overwritten and eventually causing a crash).

So, initialize the "key" with a buffer of the correct size (see "API\C\Example.c" for an example showing how to do it with custom license fields -- the same thing applies for GetPKey):

        TCHAR * featureValue;


        hr = GetFeatureValue(_T("your feature value"), 0, 0);


        featureValue = (TCHAR *)malloc(hr * sizeof(TCHAR));


        hr = GetFeatureValue(_T("your feature value"), 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: %d\n", hr);


        free(featureValue);

The important line you're missing is this:

featureValue = (TCHAR *)malloc(hr * sizeof(TCHAR));

Or, in your case:

key = (TCHAR *)malloc(sizeOfBuffer * sizeof(TCHAR));

That was it! Thank you for your help Wyatt. Being a C++ noob I am in awe of your intuition for this stuff. I appreciate the time you help out for a beginner.