From 3e2b1859898da80dce35665ecc656fd0bcf2fd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sat, 28 Apr 2012 22:27:04 -0400 Subject: [PATCH] libfreerdp-core: started implementing NdrClientCall2 --- libfreerdp-core/ndr.c | 31 +++++++++++++++++++ libfreerdp-core/ndr.h | 41 +++++++++++++++++++++++++ libfreerdp-core/tsg.c | 70 +++++++++++-------------------------------- 3 files changed, 89 insertions(+), 53 deletions(-) diff --git a/libfreerdp-core/ndr.c b/libfreerdp-core/ndr.c index ed8c627f3..6a3a083e5 100644 --- a/libfreerdp-core/ndr.c +++ b/libfreerdp-core/ndr.c @@ -28,10 +28,41 @@ CLIENT_CALL_RETURN NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ...) { + unsigned char oiFlags; + unsigned short procNum; + unsigned short stackSize; + unsigned char numberParams; + NDR_PROC_HEADER* procHeader; CLIENT_CALL_RETURN client_call_return; + procNum = stackSize = numberParams = 0; + procHeader = (NDR_PROC_HEADER*) &pFormat[0]; + client_call_return.Pointer = NULL; + oiFlags = procHeader->OiFlags; + procNum = procHeader->ProcNum; + stackSize = procHeader->StackSize; + pFormat += sizeof(NDR_PROC_HEADER); + + if (pStubDescriptor->Version >= 0x20000) + { + NDR_PROC_OI2_HEADER* procHeaderOi2 = (NDR_PROC_OI2_HEADER*) pFormat; + + oiFlags = procHeaderOi2->Oi2Flags; + numberParams = procHeaderOi2->NumberParams; + + if (oiFlags & OI2_FLAG_HAS_EXTENSIONS) + { + NDR_PROC_HEADER_EXTS* extensions = (NDR_PROC_HEADER_EXTS*) pFormat; + + pFormat += extensions->Size; + } + } + + printf("ProcHeader: ProcNum:%d OiFlags: 0x%02X, handleType: 0x%02X StackSize: %d NumberParams: %d\n", + procNum, oiFlags, procHeader->HandleType, stackSize, numberParams); + return client_call_return; } diff --git a/libfreerdp-core/ndr.h b/libfreerdp-core/ndr.h index 0989dfb2a..d514eb954 100644 --- a/libfreerdp-core/ndr.h +++ b/libfreerdp-core/ndr.h @@ -222,6 +222,41 @@ typedef struct _MIDL_STUB_DESC typedef const MIDL_STUB_DESC *PMIDL_STUB_DESC; +#define OI2_FLAG_SERVER_MUST_SIZE 0x01 +#define OI2_FLAG_CLIENT_MUST_SIZE 0x02 +#define OI2_FLAG_HAS_RETURN 0x04 +#define OI2_FLAG_HAS_PIPES 0x08 +#define OI2_FLAG_HAS_ASYNC_UUID 0x20 +#define OI2_FLAG_HAS_EXTENSIONS 0x40 +#define OI2_FLAG_HAS_ASYNC_HANDLE 0x80 + +typedef struct +{ + unsigned char Size; + unsigned char Flags2; + unsigned short ClientCorrHint; + unsigned short ServerCorrHint; + unsigned short NotifyIndex; +} NDR_PROC_HEADER_EXTS; + +typedef struct _NDR_PROC_HEADER +{ + unsigned char HandleType; + unsigned char OiFlags; + unsigned short RpcFlagsLow; + unsigned short RpcFlagsHi; + unsigned short ProcNum; + unsigned short StackSize; +} NDR_PROC_HEADER; + +typedef struct _NDR_PROC_OI2_HEADER +{ + unsigned short ClientBufferSize; + unsigned short ServerBufferSize; + unsigned int Oi2Flags; + unsigned char NumberParams; +} NDR_PROC_OI2_HEADER; + /* Type Format Strings: http://msdn.microsoft.com/en-us/library/windows/desktop/aa379093/ */ #define FC_BYTE 0x01 @@ -242,6 +277,12 @@ typedef const MIDL_STUB_DESC *PMIDL_STUB_DESC; #define FC_INT3264 0xB8 #define FC_UINT3264 0xB9 +#define FC_BIND_CONTEXT 0x30 +#define FC_BIND_GENERIC 0x31 +#define FC_BIND_PRIMITIVE 0x32 +#define FC_AUTO_HANDLE 0x33 +#define FC_CALLBACK_HANDLE 0x34 + #define NdrFcShort(s) (byte)(s & 0xFF), (byte)(s >> 8) #define NdrFcLong(s) (byte)(s & 0xFF), (byte)((s & 0x0000FF00) >> 8), \ diff --git a/libfreerdp-core/tsg.c b/libfreerdp-core/tsg.c index d570083e4..01ffe570b 100644 --- a/libfreerdp-core/tsg.c +++ b/libfreerdp-core/tsg.c @@ -1607,59 +1607,6 @@ uint8 tsg_packet5[20] = 0x00, 0x00, 0x00, 0x00 }; -#if 0 - -void Opnum0NotUsedOnWire(handle_t IDL_handle) -{ - -} - -HRESULT TsProxyCreateTunnel(PTSG_PACKET tsgPacket, PTSG_PACKET* tsgPacketResponse, - PTUNNEL_CONTEXT_HANDLE_SERIALIZE* tunnelContext, unsigned long* tunnelId) -{ - return 0; -} - -HRESULT TsProxyAuthorizeTunnel(PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext, - PTSG_PACKET tsgPacket, PTSG_PACKET* tsgPacketResponse) -{ - return 0; -} - -HRESULT TsProxyMakeTunnelCall(PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext, - unsigned long procId, PTSG_PACKET tsgPacket, PTSG_PACKET* tsgPacketResponse) -{ - return 0; -} - -HRESULT TsProxyCreateChannel(PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext, - PTSENDPOINTINFO tsEndPointInfo, PCHANNEL_CONTEXT_HANDLE_SERIALIZE* channelContext, unsigned long* channelId) -{ - return 0; -} - -void Opnum5NotUsedOnWire(handle_t IDL_handle) -{ - -} - -HRESULT TsProxyCloseChannel(PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE* context) -{ - return 0; -} - -HRESULT TsProxyCloseTunnel(PTUNNEL_CONTEXT_HANDLE_SERIALIZE* context) -{ - return 0; -} - -DWORD TsProxySetupReceivePipe(handle_t IDL_handle, byte pRpcMessage[]) -{ - return 0; -} - -#endif - DWORD TsProxySendToServer(handle_t IDL_handle, byte pRpcMessage[], uint32 count, uint32* lengths) { STREAM* s; @@ -1770,6 +1717,15 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) * ); */ + { + TSG_PACKET tsgPacket; + PTSG_PACKET tsgPacketResponse; + PTUNNEL_CONTEXT_HANDLE_SERIALIZE tunnelContext; + unsigned long tunnelId; + + TsProxyCreateTunnel(&tsgPacket, &tsgPacketResponse, &tunnelContext, &tunnelId); + } + DEBUG_TSG("TsProxyCreateTunnel"); status = rpc_tsg_write(rpc, tsg_packet1, sizeof(tsg_packet1), 1); @@ -1810,6 +1766,14 @@ boolean tsg_connect(rdpTsg* tsg, const char* hostname, uint16 port) * */ + { + TSG_PACKET tsgPacket; + PTSG_PACKET tsgPacketResponse; + PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext; + + TsProxyAuthorizeTunnel(&tunnelContext, &tsgPacket, &tsgPacketResponse); + } + DEBUG_TSG("TsProxyAuthorizeTunnel"); status = rpc_tsg_write(rpc, tsg_packet2, sizeof(tsg_packet2), 2);