Exemple #1
0
void
irp_process_write_request(IRP* irp, char* data, int data_size)
{
	if (data)
	{
		irp->length = GET_UINT32(data, 0); /* length */
		irp->offset = GET_UINT64(data, 4); /* offset */
		/* 20-byte pad */
		irp->inputBuffer = data + 32;
		irp->inputBufferLength = irp->length;
	}

	if (!irp->dev->service->write)
	{
		irp->ioStatus = RD_STATUS_NOT_SUPPORTED;
	}
	else
	{
		irp->ioStatus = irp->dev->service->write(irp);
	}
	if (irp->ioStatus == RD_STATUS_SUCCESS)
	{
		irp->outputResult = irp->length;
		/* [MS-RDPEFS] says this is an optional padding, but unfortunately it's required! */
		irp->outputBufferLength = 1;
		irp->outputBuffer = malloc(1);
		irp->outputBuffer[0] = '\0';
	}
}
Exemple #2
0
int
tsmf_ifman_on_sample(TSMF_IFMAN * ifman)
{
	TSMF_PRESENTATION * presentation;
	TSMF_STREAM * stream;
	uint32 StreamId;
	uint64 SampleStartTime;
	uint64 SampleEndTime;
	uint64 ThrottleDuration;
	uint32 SampleExtensions;
	uint32 cbData;

	StreamId = GET_UINT32(ifman->input_buffer, 16);
	SampleStartTime = GET_UINT64(ifman->input_buffer, 24);
	SampleEndTime = GET_UINT64(ifman->input_buffer, 32);
	ThrottleDuration = GET_UINT64(ifman->input_buffer, 40);
	SampleExtensions = GET_UINT32(ifman->input_buffer, 52);
	cbData = GET_UINT32(ifman->input_buffer, 56);
	
	LLOGLN(10, ("tsmf_ifman_on_sample: MessageId %d StreamId %d SampleStartTime %d SampleEndTime %d "
		"ThrottleDuration %d SampleExtensions %d cbData %d",
		ifman->message_id, StreamId, (int)SampleStartTime, (int)SampleEndTime,
		(int)ThrottleDuration, SampleExtensions, cbData));

	presentation = tsmf_presentation_find_by_id(ifman->presentation_id);
	if (presentation == NULL)
	{
		LLOGLN(0, ("tsmf_ifman_on_sample: unknown presentation id"));
		return 1;
	}
	stream = tsmf_stream_find_by_id(presentation, StreamId);
	if (stream == NULL)
	{
		LLOGLN(0, ("tsmf_ifman_on_sample: unknown stream id"));
		return 1;
	}
	tsmf_stream_push_sample(stream, ifman->channel_callback,
		ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions,
		cbData, ifman->input_buffer + 60);

	ifman->output_pending = 1;
	return 0;
}
Exemple #3
0
/* http://msdn.microsoft.com/en-us/library/dd407326.aspx */
static int
tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE * mediatype, const uint8 * pFormat)
{
	/* VIDEOINFOHEADER2.rcSource, RECT(LONG left, LONG top, LONG right, LONG bottom) */
	mediatype->Width = GET_UINT32(pFormat, 8);
	mediatype->Height = GET_UINT32(pFormat, 12);
	/* VIDEOINFOHEADER2.dwBitRate */
	mediatype->BitRate = GET_UINT32(pFormat, 32);
	/* VIDEOINFOHEADER2.AvgTimePerFrame */
	mediatype->SamplesPerSecond.Numerator = 1000000;
	mediatype->SamplesPerSecond.Denominator = (int)(GET_UINT64(pFormat, 40) / 10LL);

	return 72;
}
Exemple #4
0
void
irp_process_read_request(IRP* irp, char* data, int data_size)
{
	if (data)
	{
		irp->length = GET_UINT32(data, 0); /* length */
		irp->offset = GET_UINT64(data, 4); /* offset */
		/* 20-byte pad */
	}

	if (!irp->dev->service->read)
	{
		irp->ioStatus = RD_STATUS_NOT_SUPPORTED;
	}
	else
	{
		irp->ioStatus = irp->dev->service->read(irp);
		irp->outputResult = irp->outputBufferLength;
	}
}
Exemple #5
0
void showFileHeader(nitf_FileHeader* header)
{
    unsigned int i;
    nitf_Uint32 num;
    nitf_Error error;
    nitf_Uint32 len;
    nitf_Uint64 dataLen;
    NITF_BOOL success;

    SHOW_VAL(header->fileHeader);
    SHOW_VAL(header->fileVersion);
    SHOW_VAL(header->complianceLevel);
    SHOW_VAL(header->systemType);
    SHOW_VAL(header->originStationID);
    SHOW_VAL(header->fileDateTime);
    SHOW_VAL(header->fileTitle);
    SHOW_VAL(header->classification);
    SHOW_VAL(header->messageCopyNum);
    SHOW_VAL(header->messageNumCopies);
    SHOW_VAL(header->encrypted);
    SHOW_VAL(header->backgroundColor);
    SHOW_VAL(header->originatorName);
    SHOW_VAL(header->originatorPhone);

    SHOW_VAL(header->fileLength);
    SHOW_VAL(header->headerLength);

    /*  Attention: If the classification is U, the security group  */
    /*  section should be empty!  For that reason, we wont print   */
    /*  The security group for now                                 */

    SHOW_VAL(header->securityGroup->classificationSystem);
    SHOW_VAL(header->securityGroup->codewords);
    SHOW_VAL(header->securityGroup->controlAndHandling);
    SHOW_VAL(header->securityGroup->releasingInstructions);
    SHOW_VAL(header->securityGroup->declassificationType);
    SHOW_VAL(header->securityGroup->declassificationDate);
    SHOW_VAL(header->securityGroup->declassificationExemption);
    SHOW_VAL(header->securityGroup->downgrade);
    SHOW_VAL(header->securityGroup->downgradeDateTime);
    SHOW_VAL(header->securityGroup->classificationText);
    SHOW_VAL(header->securityGroup->classificationAuthorityType);
    SHOW_VAL(header->securityGroup->classificationAuthority);
    SHOW_VAL(header->securityGroup->classificationReason);
    SHOW_VAL(header->securityGroup->securitySourceDate);
    SHOW_VAL(header->securityGroup->securityControlNumber);

    GET_UINT32(header->numImages, &num, &error);
    printf("The number of IMAGES contained in this file [%ld]\n", num);
    for (i = 0; i < num; i++)
    {
        GET_UINT32(header->imageInfo[i]->lengthSubheader, &len, &error);
        GET_UINT64(header->imageInfo[i]->lengthData, &dataLen, &error);
        printf("\tThe length of IMAGE subheader [%d]: %ld bytes\n",
               i, len);
        printf("\tThe length of the IMAGE data: %lld bytes\n\n",
               dataLen);
    }

    return;

CATCH_ERROR:
    printf("Error processing\n");
}
Exemple #6
0
static uint32
disk_set_info(IRP * irp)
{
	FILE_INFO *finfo;
	uint32 status;
	uint64 len;
	char * buf;
	int size;
	char * fullpath;
	struct stat file_stat;
	struct utimbuf tvs;
	int mode;
	uint32 attr;
	time_t t;

	LLOGLN(10, ("disk_set_info: class=%d id=%d", irp->infoClass, irp->fileID));
	finfo = disk_get_file_info(irp->dev, irp->fileID);
	if (finfo == NULL)
	{
		LLOGLN(0, ("disk_set_info: invalid file id"));
		return RD_STATUS_INVALID_HANDLE;
	}

	status = RD_STATUS_SUCCESS;

	switch (irp->infoClass)
	{
		case FileBasicInformation:
			if (stat(finfo->fullpath, &file_stat) != 0)
				return get_error_status();

			/* Change file time */
			tvs.actime = file_stat.st_atime;
			tvs.modtime = file_stat.st_mtime;
			t = get_system_filetime(GET_UINT64(irp->inputBuffer, 8)); /* LastAccessTime */
			if (t > 0)
				tvs.actime = t;
			t = get_system_filetime(GET_UINT64(irp->inputBuffer, 16)); /* LastWriteTime */
			if (t > 0)
				tvs.modtime = t;
			utime(finfo->fullpath, &tvs);

			/* Change read-only flag */
			attr = GET_UINT32(irp->inputBuffer, 32);
			if (attr == 0)
				break;
			mode = file_stat.st_mode;
			if (attr & FILE_ATTRIBUTE_READONLY)
				mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
			else
				mode |= S_IWUSR;
			mode &= 0777;
			chmod(finfo->fullpath, mode);
			break;

		case FileEndOfFileInformation:
		case FileAllocationInformation:
			len = GET_UINT64(irp->inputBuffer, 0);
			set_file_size(finfo->file, len);
			break;

		case FileDispositionInformation:
			/* Delete on close */
			finfo->delete_pending = 1;
			break;

		case FileRenameInformation:
			//replaceIfExists = GET_UINT8(irp->inputBuffer, 0); /* ReplaceIfExists */
			//rootDirectory = GET_UINT8(irp->inputBuffer, 1); /* RootDirectory */
			len = GET_UINT32(irp->inputBuffer, 2);
			size = len * 2;
			buf = malloc(size);
			memset(buf, 0, size);
			freerdp_get_wstr(buf, size, irp->inputBuffer + 6, len);
			fullpath = disk_get_fullpath(irp->dev, buf);
			free(buf);
			LLOGLN(10, ("disk_set_info: rename %s to %s", finfo->fullpath, fullpath));
			if (rename(finfo->fullpath, fullpath) == 0)
			{
				free(finfo->fullpath);
				finfo->fullpath = fullpath;
			}
			else
			{
				free(fullpath);
				return get_error_status();
			}
			break;

		default:
			LLOGLN(0, ("disk_set_info: invalid info class"));
			status = RD_STATUS_NOT_SUPPORTED;
			break;
	}

	return status;
}