Prevent OOM
This commit is contained in:
@@ -109,6 +109,43 @@ extern "C" __declspec(dllexport) int GetCurrentHardwareId(ANSCENTER::ANSLSHelper
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) int GetHardwareId(LStrHandle currentHwID) {
|
||||
try {
|
||||
std::string st = ANSCENTER::ANSLicenseHelper::GetHardwareId();
|
||||
int size = (int)st.length();
|
||||
if (size > 0) {
|
||||
MgErr error;
|
||||
error = DSSetHandleSize(currentHwID, sizeof(int32) + size * sizeof(uChar));
|
||||
if (error == noErr)
|
||||
{
|
||||
(*currentHwID)->cnt = size;
|
||||
memcpy((*currentHwID)->str, st.c_str(), size);
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
catch (...) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) int GetHardwareIdBuffer(char* buffer, int bufferSize) {
|
||||
try {
|
||||
if (!buffer || bufferSize <= 0) return 0;
|
||||
std::string st = ANSCENTER::ANSLicenseHelper::GetHardwareId();
|
||||
int size = (int)st.length();
|
||||
if (size <= 0) return 0;
|
||||
// Need room for the string plus the null terminator.
|
||||
if (size + 1 > bufferSize) return 0;
|
||||
memcpy(buffer, st.c_str(), size);
|
||||
buffer[size] = '\0';
|
||||
return size;
|
||||
}
|
||||
catch (...) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) int GenerateKey(ANSCENTER::ANSLSHelper * *Handle, int productId, const char* registrationName, int productFeature, int trialLicense, LStrHandle generatedKey) {
|
||||
try {
|
||||
if (!Handle || !(*Handle) || !registrationName) return 0;
|
||||
|
||||
Reference in New Issue
Block a user