Ejemplo n.º 1
0
void Get_URL_Text( PA_PluginParameters params )
{
	char* c_url;
	char *returnString;
	PA_Unichar* URL_uchars;
	PA_Unistring* URL;
	PA_Unichar* returnValue_uchars;
	MemoryBuffer buffer;

	URL = PA_GetStringParameter( params, 1 );
	URL_uchars = PA_GetUnistring( URL );

	c_url = PA_UnistringToChar(URL);
	
	buffer = getURL(c_url);
	
	returnString = malloc(buffer.size + 1);
	bzero(returnString, buffer.size + 1);
	memcpy(returnString, buffer.data, buffer.size);
	
	returnValue_uchars = charToPA_Unichar(returnString);
	
	PA_ReturnString( params, returnValue_uchars );
}
Ejemplo n.º 2
0
void sys_ShellExecute( PA_PluginParameters params )
{
	LONG_PTR returnValue = 0;
	LONG_PTR len = 0;
	char returnText[255]; // MWD & Mark De Wever #12225
	INT_PTR	 howToShow;
	//char *pChar;

	//char *operation = NULL;
	//char *file = NULL;
	//char *parameters = NULL;
	//char *directory = NULL;

	PA_Unistring *UnistringFile;
	PA_Unistring *UnistringOperation; 
	PA_Unistring *UnistringParameters; 
	PA_Unistring *UnistringDirectory; 

	PA_Unichar *file; 
	PA_Unichar *operation; 
	PA_Unichar *parameters; 
	PA_Unichar *directory; 
	PA_Unichar *pChar; 

	// Get the function parameters.
	//operation = getTextParameter(params, 1);
	//file = getTextParameter(params, 2);
	//parameters = getTextParameter(params, 3);
	//directory = getTextParameter(params, 4);

	UnistringOperation = PA_GetStringParameter( params, 1); 
	UnistringFile = PA_GetStringParameter( params, 2); 
	UnistringParameters = PA_GetStringParameter( params, 3); 
	UnistringDirectory = PA_GetStringParameter( params, 4); 
	howToShow = PA_GetLongParameter( params, 5 ); 

	operation = PA_GetUnistring(UnistringOperation); // AMS /28/14
	file = PA_GetUnistring(UnistringFile); // AMS 2/28/14
	len = (PA_GetUnistringLength(UnistringFile) + 1); // AMS 2/28/14
	parameters = PA_GetUnistring(UnistringParameters); // AMS 2/28/14
	directory = PA_GetUnistring(UnistringDirectory); // AMS 2/28/14

	//if ((strcmp(_strlwr(operation), "open")			!= 0) &&
	//	 (strcmp(_strlwr(operation),  "explore")	!= 0) &&
	//	 (strcmp(_strlwr(operation),  "print")		!= 0) &&
	//	 (file == NULL || strlen(file) == 0)) {
	//	//strcpy(returnText, "Invalid Operation");
	//	strncpy(returnText, message->InvalidOperation, 255); // Mark De Wever #12225 replaced the line above
	//}
	if((lstrcmpiW(operation, L"open")    != 0) &&
	   (lstrcmpiW(operation, L"explore") != 0) &&
	   (lstrcmpiW(operation, L"print")   != 0) &&
	   (file == NULL || len == 0)) {
		strncpy(returnText, message->InvalidOperation, 255); 
	}
	else if (howToShow > 11) {
		//strcpy(returnText, "Invalid HowToShow Constant");
		strncpy(returnText, message->InvalidShowConstant, 255); // Mark De Wever #12225 replaced the line above
	}
	else
	{
		pChar = file; // added 10/28/02 shellExecute wants backslashes
		do {
			if (*pChar == '/') {
				*pChar = '\\';
			}
		} while (*pChar++ != '\0') ;
		
		if (directory != NULL) {
			pChar = directory;
			do  {
				if (*pChar == '/') {
					*pChar = '\\';
				}
			} while (*pChar++ != '\0');
		}
		
		CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); // AMS 5/6/14 #38727

		returnValue = (LONG_PTR) ShellExecuteW(NULL, operation, file, parameters, directory, howToShow);
		
		strcpy(returnText, "");
		if (returnValue <= 32) { // error occurred
			switch (returnValue)
			{
			case ERROR_FILE_NOT_FOUND :
				//strcpy(returnText, "File Not Found");		
				strncpy(returnText, message->FileNotFound, 255); // Mark De Wever #12225 replaced line above
				break;
				
			case ERROR_PATH_NOT_FOUND :
				//strcpy(returnText, "Path Not Found");
				strncpy(returnText, message->PathNotFound, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case ERROR_BAD_FORMAT :
				//strcpy(returnText, ".EXE File is Invalid");		
				strncpy(returnText, message->BadFormat, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case SE_ERR_ACCESSDENIED :
				//strcpy(returnText, "OS Denied Access to File");		
				strncpy(returnText, message->AccessDenied, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case SE_ERR_ASSOCINCOMPLETE  :
				//strcpy(returnText, "File Name Association is Incomplete or Invalid");		
				strncpy(returnText, message->AssocIncomplete, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case SE_ERR_DDEBUSY  :
			case SE_ERR_DDEFAIL   :
				//strcpy(returnText, "DDE Transaction Could Not be Completed");
        strncpy(returnText, message->DDEFail, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case SE_ERR_DDETIMEOUT   :
				//strcpy(returnText, "DDE Request Timed Out");		
				strncpy(returnText, message->DDETimeOut, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case SE_ERR_DLLNOTFOUND    :
				//strcpy(returnText, "DLL Libray Not Found");
        strncpy(returnText, message->DLLNotFound, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case SE_ERR_NOASSOC   :
				//strcpy(returnText, "No Application Associated with File Extenstion");
        strncpy(returnText, message->NoAssoc, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case SE_ERR_OOM :
				//strcpy(returnText, "Insufficient Memory");
        strncpy(returnText, message->OOM, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			case SE_ERR_SHARE    :
				//strcpy(returnText, "Sharing Violation Occurred");
        strncpy(returnText, message->ShareViolation, 255); // Mark De Wever #12225 Replaced line above
				break;
				
			default:
				//strcpy(returnText, "Unknown error occurred");	
				strncpy(returnText, message->Default, 255); // Mark De Wever #12225 Replaced line above
				break;
			}
		}
	}

	//freeTextParameter(operation);
	//freeTextParameter(file);
	//freeTextParameter(parameters);
	//freeTextParameter(directory);

	PA_ReturnText( params, returnText, strlen(returnText));
}