Beispiel #1
0
Exec_stat MCPurchaseGet(MCPurchase *p_purchase, MCPurchaseProperty p_property, MCExecPoint &ep)
{
    //MCLog("MCPurchaseGet(%p, %d, ...)", p_purchase, p_property);
    MCAndroidPurchase *t_android_data = (MCAndroidPurchase*)p_purchase->platform_data;
    
    switch (p_property) {
        case kMCPurchasePropertyProductIdentifier:
            ep.copysvalue(t_android_data->product_id);
            return ES_NORMAL;
            
        case kMCPurchasePropertyDeveloperPayload:
            if (t_android_data->developer_payload == nil)
                ep.clear();
            else
                ep.copysvalue(t_android_data->developer_payload);
            return ES_NORMAL;
            
        case kMCPurchasePropertySignedData:
            if (t_android_data->signed_data == nil)
                ep.clear();
            else
                ep.copysvalue(t_android_data->signed_data);
            return ES_NORMAL;
            
        case kMCPurchasePropertySignature:
            if (t_android_data->signature == nil)
                ep.clear();
            else
                ep.copysvalue(t_android_data->signature);
            return ES_NORMAL;
            
        case kMCPurchasePropertyTransactionIdentifier:
            if (t_android_data->order_id == nil)
                ep.clear();
            else
                ep.copysvalue(t_android_data->order_id);
            return ES_NORMAL;
            
        case kMCPurchasePropertyPurchaseDate:
            ep.setint64(t_android_data->purchase_time);
            return ES_NORMAL;
            
        default:
            break;
    }
    
    return ES_NOT_HANDLED;
}
Beispiel #2
0
Exec_stat MCSHA1Digest::eval(MCExecPoint &ep)
{
	if (source->eval(ep) != ES_NORMAL)
	{
		MCeerror->add(EE_SHA1DIGEST_BADSOURCE, line, pos);
		return ES_ERROR;
	}
	sha1_state_t state;
	uint8_t digest[20];
	sha1_init(&state);
	sha1_append(&state, ep.getsvalue().getstring(), ep.getsvalue().getlength());
	sha1_finish(&state, digest);
	ep.copysvalue((char *)digest, 20);
	return ES_NORMAL;
}
Beispiel #3
0
Exec_stat MCMD5Digest::eval(MCExecPoint &ep)
{
	if (source->eval(ep) != ES_NORMAL)
	{
		MCeerror->add(EE_MD5DIGEST_BADSOURCE, line, pos);
		return ES_ERROR;
	}
	md5_state_t state;
	md5_byte_t digest[16];
	md5_init(&state);
	md5_append(&state, (const md5_byte_t *)ep.getsvalue().getstring(), ep.getsvalue().getlength());
	md5_finish(&state, digest);
	ep.copysvalue((char *)digest, 16);
	return ES_NORMAL;
}
Beispiel #4
0
void MCS_query_registry(MCExecPoint &dest, const char** type)
{
	HKEY hkey;
	char *key = dest.getsvalue().clone();
	//key = full path info such as: HKEY_LOCAL_MACHINE\\Software\\..\\valuename

	dest.clear();

	/* get the value name, it is at the end of the key          */
	char *str = strrchr(key, '\\');
	if (str == NULL)
	{ //invalid key path specified
		MCresult->sets("no key");
		delete key;
		return;
	}
	//chop off the end and make str point to the begining of the value name
	*str ++ = '\0';
	char *VName = str; //VName now points to the name of the value to be queryed

	/* get the root key, it is at the begining of the key       */
	str = strchr(key, '\\');
	if (str != NULL) /* key != HKEY_ROOT\.mc    case */
		*str ++ = '\0';  //str now pointing to the begining of subkey

	/** find the matching root key with the root string  **/
	uint2 i;
	MCString s = key;
	for (i = 0 ; i < ELEMENTS(Regkeys) ; i++)
		if (s == Regkeys[i].token)
			break;

	DWORD t_access;
	t_access = KEY_READ;
	if (MCmajorosversion >= 0x0501)
	{
		if (Regkeys[i].mode == kRegAccessAs32)
			t_access |= KEY_WOW64_32KEY;
		else if (Regkeys[i].mode == kRegAccessAs64)
			t_access |= KEY_WOW64_64KEY;
	}

	if (i >= ELEMENTS(Regkeys)
	        || (RegOpenKeyExA(Regkeys[i].key, str, 0, t_access, &hkey)
	            != ERROR_SUCCESS))
	{
		MCresult->sets("bad key");
		delete key;
		return;
	}

	//determine the size of value buffer needed

	LONG err = 0;
	DWORD VType;                         //value type
	DWORD VBufLen = 1;                   //value buffer len
	char *VValue;                        //value value
	err = RegQueryValueExA(hkey, VName, 0, NULL /*&VType*/, NULL, &VBufLen);
	if (err == ERROR_SUCCESS || err == ERROR_MORE_DATA)
	{
		VValue = new char[VBufLen]; //alloc space for the key value
		if ((err = RegQueryValueExA(hkey, VName, 0, &VType, (LPBYTE)VValue,
		                           &VBufLen)) == ERROR_SUCCESS && VBufLen)
		{
			DWORD t_original_buflen;
			t_original_buflen = VBufLen;
			if (VType == REG_SZ || VType == REG_EXPAND_SZ || VType == REG_MULTI_SZ)
			{
				while(VBufLen > 0 && VValue[VBufLen - 1] == '\0')
					VBufLen -= 1;
				if (VType == REG_MULTI_SZ && VBufLen < t_original_buflen)
					VBufLen += 1;
			}
			dest.copysvalue(VValue, VBufLen); //VBufLen - (VType == REG_SZ ? 1 : 0));
		}

		// MW-2006-01-15: Memory Leak
		delete VValue;
	}
	else
	{
		errno = err;
		MCresult->sets("can't find key");
	}
	RegCloseKey(hkey);
	delete key;

	if (type != NULL)
		for (i = 0 ; i < ELEMENTS(RegDatatypes) ; i++)
			if (VType == RegDatatypes[i].type)
			{
				*type = RegDatatypes[i] . token;
				break;
			}

	MCresult -> clear();

	return;
}