예제 #1
0
int msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, BYTE* data, int* offset)
{
	MSUSB_PIPE_DESCRIPTOR ** MsPipes;
	MSUSB_PIPE_DESCRIPTOR * MsPipe;
	int pnum = 0, move = 0;
	
	/* Length */
	data_write_UINT16(data, MsInterface->Length); 
	/* InterfaceNumber */
	data_write_BYTE(data + 2, MsInterface->InterfaceNumber); 
	/* AlternateSetting */
	data_write_BYTE(data + 3, MsInterface->AlternateSetting); 
	/* bInterfaceClass */
	data_write_BYTE(data + 4, MsInterface->bInterfaceClass); 
	/* bInterfaceSubClass */
	data_write_BYTE(data + 5, MsInterface->bInterfaceSubClass); 
	/* bInterfaceProtocol */
	data_write_BYTE(data + 6, MsInterface->bInterfaceProtocol);
	/* Padding */ 
	data_write_BYTE(data + 7, 0);
	/* InterfaceHandle */
	data_write_UINT32(data + 8, MsInterface->InterfaceHandle);
	/* NumberOfPipes */
	data_write_UINT32(data + 12, MsInterface->NumberOfPipes);
	move += 16;
	/* Pipes */
	MsPipes = MsInterface->MsPipes;
	for(pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++)
	{
		MsPipe = MsPipes[pnum];
		/* MaximumPacketSize */
		data_write_UINT16(data + move, MsPipe->MaximumPacketSize);
		/* EndpointAddress */
		data_write_BYTE(data + move + 2, MsPipe->bEndpointAddress);
		/* Interval */
		data_write_BYTE(data + move + 3, MsPipe->bInterval);
		/* PipeType */
		data_write_UINT32(data + move + 4, MsPipe->PipeType);
		/* PipeHandle */
		data_write_UINT32(data + move + 8, MsPipe->PipeHandle);
		/* MaximumTransferSize */
		data_write_UINT32(data + move + 12, MsPipe->MaximumTransferSize);
		/* PipeFlags */
		data_write_UINT32(data + move + 16, MsPipe->PipeFlags);
		
		move += 20;
	}
	
	*offset += move;
	
	return 0;
}
예제 #2
0
static int fun_device_string_send_set(char* out_data, int out_offset, char* str)
{
	int i = 0;
	int offset = 0;

	while (str[i])
	{
		data_write_UINT16(out_data + out_offset + offset, str[i]);   /* str */
		i++;
		offset += 2;
	}

	data_write_UINT16(out_data + out_offset + offset, 0x0000);   /* add "\0" */
	offset += 2;
	return offset + out_offset;
}