Ejemplo n.º 1
0
void NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
{
	if (*pFormat != FC_RP)
	{
		NdrpAlignLength((&pStubMsg->BufferLength), 4);
		NdrpIncrementLength((&pStubMsg->BufferLength), 4);
	}

	NdrpPointerBufferSize(pMemory, pFormat, pStubMsg);
}
Ejemplo n.º 2
0
void NdrSimpleTypeBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
{
	switch (*pFormat)
	{
		case FC_BYTE:
		case FC_CHAR:
		case FC_SMALL:
		case FC_USMALL:
			NdrpIncrementLength(&(pStubMsg->BufferLength), sizeof(BYTE));
			break;

		case FC_WCHAR:
		case FC_SHORT:
		case FC_USHORT:
		case FC_ENUM16:
			NdrpAlignLength(&(pStubMsg->BufferLength), sizeof(USHORT));
			NdrpIncrementLength(&(pStubMsg->BufferLength), sizeof(USHORT));
			break;

		case FC_LONG:
		case FC_ULONG:
		case FC_ENUM32:
		case FC_INT3264:
		case FC_UINT3264:
			NdrpAlignLength(&(pStubMsg->BufferLength), sizeof(ULONG));
			NdrpIncrementLength(&(pStubMsg->BufferLength), sizeof(ULONG));
			break;

		case FC_FLOAT:
			NdrpAlignLength(&(pStubMsg->BufferLength), sizeof(FLOAT));
			NdrpIncrementLength(&(pStubMsg->BufferLength), sizeof(FLOAT));
			break;

		case FC_DOUBLE:
			NdrpAlignLength(&(pStubMsg->BufferLength), sizeof(DOUBLE));
			NdrpIncrementLength(&(pStubMsg->BufferLength), sizeof(DOUBLE));
			break;

		case FC_HYPER:
			NdrpAlignLength(&(pStubMsg->BufferLength), sizeof(ULONGLONG));
			NdrpIncrementLength(&(pStubMsg->BufferLength), sizeof(ULONGLONG));
			break;

		case FC_ERROR_STATUS_T:
			NdrpAlignLength(&(pStubMsg->BufferLength), sizeof(error_status_t));
			NdrpIncrementLength(&(pStubMsg->BufferLength), sizeof(error_status_t));
			break;

		case FC_IGNORE:
			break;
	}
}
Ejemplo n.º 3
0
void NdrContextHandleBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
{
	unsigned char type = *pFormat;

	if (type == FC_BIND_PRIMITIVE)
	{
		/**
		 * FC_BIND_PRIMITIVE
		 * flag<1>
		 * offset<2>
		 */

		printf("warning: NdrContextHandleBufferSize FC_BIND_PRIMITIVE unimplemented\n");
	}
	else if (type == FC_BIND_GENERIC)
	{
		/**
		 * FC_BIND_GENERIC
		 * flag_and_size<1>
		 * offset<2>
		 * binding_routine_pair_index<1>
		 * FC_PAD
		 */

		printf("warning: NdrContextHandleBufferSize FC_BIND_GENERIC unimplemented\n");
	}
	else if (type == FC_BIND_CONTEXT)
	{
		/**
		 * FC_BIND_CONTEXT
		 * flags<1>
		 * offset<2>
		 * context_rundown_routine_index<1>
		 * param_num<1>
		 */

		NdrpAlignLength(&(pStubMsg->BufferLength), 4);
		NdrpIncrementLength(&(pStubMsg->BufferLength), 20);
	}
}
Ejemplo n.º 4
0
void NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
{
	/**
	 * FC_STRUCT
	 * alignment<1>
	 * memory_size<2>
	 * member_layout<>
	 * FC_END
	 */

	/**
	 * FC_PSTRUCT
	 * alignment<1>
	 * memory_size<2>
	 * pointer_layout<>
	 * member_layout<>
	 * FC_END
	 */

	unsigned char type;
	unsigned char alignment;
	unsigned short memory_size;

	type = pFormat[0];
	alignment = pFormat[1] + 1;
	memory_size = *(unsigned short*) &pFormat[2];

	NdrpAlignLength(&(pStubMsg->BufferLength), alignment);
	NdrpIncrementLength(&(pStubMsg->BufferLength), memory_size);

	pFormat += 4;

	if (*pFormat == FC_PSTRUCT)
		NdrpEmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);

	printf("warning: NdrSimpleStructBufferSize unimplemented\n");
}
Ejemplo n.º 5
0
void NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
{
	/**
	 * FC_BOGUS_STRUCT
	 * alignment<1>
	 * memory_size<2>
	 * offset_to_conformant_array_description<2>
	 * offset_to_pointer_layout<2>
	 * member_layout<>
	 * FC_END
	 * [pointer_layout<>]
	 */

	ULONG_PTR MaxCount;
	unsigned long Offset;
	unsigned long ActualCount;
	unsigned char* pMemoryCopy;

	unsigned char type;
	unsigned char alignment;
	unsigned short memory_size;
	unsigned char* pointer_layout;
	unsigned char* conformant_array_description;
	unsigned short offset_to_pointer_layout;
	unsigned short offset_to_conformant_array_description;

	type = pFormat[0];
	pMemoryCopy = pMemory;
	pointer_layout = conformant_array_description = NULL;

	if (type != FC_BOGUS_STRUCT)
	{
		printf("error: expected FC_BOGUS_STRUCT, got 0x%02X\n", type);
		return;
	}

	alignment = pFormat[1] + 1;
	memory_size = *(unsigned short*) &pFormat[2];

	NdrpAlignLength(&(pStubMsg->BufferLength), alignment);

	if (!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength)
	{
		unsigned long BufferLengthCopy = pStubMsg->BufferLength;
		int IgnoreEmbeddedPointersCopy = pStubMsg->IgnoreEmbeddedPointers;

		pStubMsg->IgnoreEmbeddedPointers = 1;
		NdrComplexStructBufferSize(pStubMsg, pMemory, pFormat);
		pStubMsg->IgnoreEmbeddedPointers = IgnoreEmbeddedPointersCopy;

		pStubMsg->PointerLength = pStubMsg->BufferLength;
		pStubMsg->BufferLength = BufferLengthCopy;
	}

	pFormat += 4;

	offset_to_conformant_array_description = *(unsigned short*) &pFormat[0];

	if (offset_to_conformant_array_description)
		conformant_array_description = (unsigned char*) pFormat + offset_to_conformant_array_description;
	pFormat += 2;

	offset_to_pointer_layout = *(unsigned short*) &pFormat[0];

	if (offset_to_pointer_layout)
		pointer_layout = (unsigned char*) pFormat + offset_to_pointer_layout;
	pFormat += 2;

	pStubMsg->Memory = pMemory;

	if (conformant_array_description)
	{
		ULONG size;
		unsigned char array_type;

		array_type = conformant_array_description[0];
		size = NdrComplexStructMemberSize(pStubMsg, pFormat);

		printf("warning: NdrComplexStructBufferSize array_type: 0x%02X unimplemented\n", array_type);

		NdrpComputeConformance(pStubMsg, pMemory + size, conformant_array_description);
		NdrpComputeVariance(pStubMsg, pMemory + size, conformant_array_description);

		MaxCount = pStubMsg->MaxCount;
		ActualCount = pStubMsg->ActualCount;
		Offset = pStubMsg->Offset;
	}

	if (conformant_array_description)
	{
		unsigned char array_type;

		array_type = conformant_array_description[0];

		pStubMsg->MaxCount = MaxCount;
		pStubMsg->ActualCount = ActualCount;
		pStubMsg->Offset = Offset;

		printf("warning: NdrComplexStructBufferSize array_type: 0x%02X unimplemented\n", array_type);
	}

	pStubMsg->Memory = pMemoryCopy;

	if (pStubMsg->PointerLength > 0)
	{
		pStubMsg->BufferLength = pStubMsg->PointerLength;
		pStubMsg->PointerLength = 0;
	}
}
Ejemplo n.º 6
0
ULONG NdrComplexStructMemberSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
{
	ULONG size = 0;

	while (*pFormat != FC_END)
	{
		switch (*pFormat)
		{
			case FC_BYTE:
			case FC_CHAR:
			case FC_SMALL:
			case FC_USMALL:
				size += sizeof(BYTE);
				break;

			case FC_WCHAR:
			case FC_SHORT:
			case FC_USHORT:
			case FC_ENUM16:
				size += sizeof(USHORT);
				break;

			case FC_LONG:
			case FC_ULONG:
			case FC_ENUM32:
				size += sizeof(ULONG);
				break;

			case FC_INT3264:
			case FC_UINT3264:
				size += sizeof(INT_PTR);
				break;

			case FC_FLOAT:
				size += sizeof(FLOAT);
				break;

			case FC_DOUBLE:
				size += sizeof(DOUBLE);
				break;

			case FC_HYPER:
				size += sizeof(ULONGLONG);
				break;

			case FC_ERROR_STATUS_T:
				size += sizeof(error_status_t);
				break;

			case FC_IGNORE:
				break;

			case FC_RP:
			case FC_UP:
			case FC_OP:
			case FC_FP:
			case FC_POINTER:
				size += sizeof(void*);
				if (*pFormat != FC_POINTER)
					pFormat += 4;
				break;

			case FC_ALIGNM2:
				NdrpAlignLength(&size, 2);
				break;

			case FC_ALIGNM4:
				NdrpAlignLength(&size, 4);
				break;

			case FC_ALIGNM8:
				NdrpAlignLength(&size, 8);
				break;

			case FC_STRUCTPAD1:
			case FC_STRUCTPAD2:
			case FC_STRUCTPAD3:
			case FC_STRUCTPAD4:
			case FC_STRUCTPAD5:
			case FC_STRUCTPAD6:
			case FC_STRUCTPAD7:
				size += *pFormat - FC_STRUCTPAD1 + 1;
				break;

			case FC_PAD:
				break;

			case FC_EMBEDDED_COMPLEX:
				printf("warning: NdrComplexStructMemberSize FC_EMBEDDED_COMPLEX unimplemented\n");
				break;

			default:
				printf("warning: NdrComplexStructMemberSize 0x%02X unimplemented\n", *pFormat);
				break;
		}

		pFormat++;
	}

	return size;
}