Author: tretiakov Date: Wed Mar 29 21:42:29 2006 New Revision: 21407
URL: http://svn.reactos.ru/svn/reactos?rev=21407&view=rev Log: Test application for demonstration of how undocumented context handle function work.
Added: trunk/reactos/base/applications/testsets/rpcrt4/ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/client.c trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.acf trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.h trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.idl trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx_c.c trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx_s.c trunk/reactos/base/applications/testsets/rpcrt4/context_handles/server.c
Added: trunk/reactos/base/applications/testsets/rpcrt4/context_handles/client.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/testsets/r... ============================================================================== --- trunk/reactos/base/applications/testsets/rpcrt4/context_handles/client.c (added) +++ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/client.c Wed Mar 29 21:42:29 2006 @@ -1,0 +1,297 @@ +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> +#include "ctx.h" + +#define TYPE_FORMAT_STRING_SIZE 23 +#define PROC_FORMAT_STRING_SIZE 21 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } MIDL_TYPE_FORMAT_STRING; + +typedef struct _MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; +} MIDL_PROC_FORMAT_STRING; + +extern const MIDL_STUB_DESC hello_StubDesc; +extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString; +//extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;*/ + +/***************************************************************** + * Modified from midl-generated stubs * + *****************************************************************/ + + +void m_CtxOpen( + /* [out] */ PCTXTYPE __RPC_FAR *pphContext, + /* [in] */ long Value) +{ + RPC_BINDING_HANDLE _Handle = 0; + + RPC_MESSAGE _RpcMessage; + + MIDL_STUB_MESSAGE _StubMsg; + + char *ctx, *buf; + int i; + + printf("\n*******************************************************************\n"); + printf("**** CtxOpen() ***\n"); + printf("*******************************************************************\n\n"); + + if(!pphContext) + { + RpcRaiseException(RPC_X_NULL_REF_POINTER); + } + RpcTryFinally + { + NdrClientInitializeNew( + ( PRPC_MESSAGE )&_RpcMessage, + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( PMIDL_STUB_DESC )&hello_StubDesc, + 0); + + + _Handle = hBinding; + + + _StubMsg.BufferLength = 4U; + NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle ); + + *(( long __RPC_FAR * )_StubMsg.Buffer)++ = Value; + + NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer ); + + if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION ) + NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] ); + + + printf("Before NdrClientContextUnmarshall: Buflen=%d\nBuffer: ", _StubMsg.RpcMsg->BufferLength); + for(buf = _StubMsg.Buffer, i = 0; i < _StubMsg.RpcMsg->BufferLength; i++) + printf("0x%x, ", buf[i] & 0x0FF); + printf("\n\n"); + + *pphContext = (void *)0; + NdrClientContextUnmarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_CCONTEXT __RPC_FAR * )pphContext, + _Handle); + + ctx = (char*)*pphContext; + printf("\nNdrClientContextUnmarshall returned: handle=0x%p\n", ctx); + printf("00: 0x%x <- obviously pointer to binding handle copyed from _Handle\n", *((int*)ctx)); + ctx+=4; + printf("04: 0x%x <- unknown field\n", *((int*)ctx)); + printf("08: "); + + for(ctx+=4, i = 0; i < 20; i++) + printf("0x%x,", *(ctx+i) & 0x0FF); printf(" <- ndr 20 bytes\n\n"); + + printf("Buflen=%d, Buffer: ", _StubMsg.BufferLength); + for(buf = _StubMsg.BufferStart; buf < _StubMsg.BufferEnd; buf++) + printf("0x%x,", *buf & 0x0FF); + printf("\n"); + + + } + RpcFinally + { + NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg ); + + } + RpcEndFinally + +} + + +void m_CtxHello( + /* [in] */ PCTXTYPE phContext) +{ + + RPC_BINDING_HANDLE _Handle = 0; + + RPC_MESSAGE _RpcMessage; + + MIDL_STUB_MESSAGE _StubMsg; + + char *buf; + int i; + + printf("\n*******************************************************************\n"); + printf("**** CtxHello() ***\n"); + printf("*******************************************************************\n\n"); + + RpcTryFinally + { + NdrClientInitializeNew( + ( PRPC_MESSAGE )&_RpcMessage, + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( PMIDL_STUB_DESC )&hello_StubDesc, + 1); + + + if(phContext != 0) + { + _Handle = NDRCContextBinding(( NDR_CCONTEXT )phContext);; + + } + else + { + RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT); + } + + _StubMsg.BufferLength = 20U; + NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle ); + + NdrClientContextMarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_CCONTEXT )phContext, + 1); + printf("After NdrClientContextMarshall: Buflen=%d\nBuffer: ", _StubMsg.BufferLength ); + for(buf = _StubMsg.Buffer, i = 0; i < _StubMsg.BufferLength; i++) + printf("0x%x, ", buf[i] & 0x0FF); + printf("\n\n"); + + NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer ); + + } + RpcFinally + { + NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg ); + + } + RpcEndFinally + +} + + +void m_CtxClose( + /* [out][in] */ PCTXTYPE __RPC_FAR *pphContext) +{ + + RPC_BINDING_HANDLE _Handle = 0; + + RPC_MESSAGE _RpcMessage; + + MIDL_STUB_MESSAGE _StubMsg; + char *buf; + int i; + + printf("\n*******************************************************************\n"); + printf("**** CtxClose() ***\n"); + printf("*******************************************************************\n\n"); + + if(!pphContext) + { + RpcRaiseException(RPC_X_NULL_REF_POINTER); + } + RpcTryFinally + { + NdrClientInitializeNew( + ( PRPC_MESSAGE )&_RpcMessage, + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( PMIDL_STUB_DESC )&hello_StubDesc, + 2); + + + if(*pphContext != 0) + { + _Handle = NDRCContextBinding(( NDR_CCONTEXT )*pphContext);; + + } + + _StubMsg.BufferLength = 20U; + NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle ); + + NdrClientContextMarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_CCONTEXT )*pphContext, + 0); + + NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer ); + + if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION ) + NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[14] ); + + + printf("Before NdrClientContextUnmarshall: Buflen=%d\nBuffer: ", _StubMsg.BufferLength ); + for(buf = _StubMsg.Buffer, i = 0; i < _StubMsg.BufferLength; i++) + printf("0x%x, ", buf[i] & 0x0FF); + printf("\n\n"); + + NdrClientContextUnmarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_CCONTEXT __RPC_FAR * )pphContext, + _Handle); + + + printf("\nNdrClientContextUnmarshall returned: handle=0x%p\n", *pphContext); + + + } + RpcFinally + { + NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg ); + + } + RpcEndFinally + +} + +void main() +{ + RPC_STATUS status; + unsigned long ulCode; + PCTXTYPE hContext; + char *pszStringBinding = NULL; + + status = RpcStringBindingCompose(NULL, + "ncacn_np", + NULL, + "\pipe\hello", + NULL, + &pszStringBinding); + + if (status) + { + printf("RpcStringBindingCompose %x\n", status); + exit(status); + } + + status = RpcBindingFromStringBinding(pszStringBinding, &hBinding); + + if (status) + { + printf("RpcBindingFromStringBinding %x\n", status); + exit(status); + } + + RpcStringFree(&pszStringBinding); + + m_CtxOpen(&hContext, 31337); + RpcBindingFree(&hBinding); + + m_CtxHello(hContext); + + m_CtxClose(&hContext); + + +} + + +void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) +{ + return(malloc(len)); +} + +void __RPC_USER midl_user_free(void __RPC_FAR * ptr) +{ + free(ptr); +}
Added: trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.acf URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/testsets/r... ============================================================================== --- trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.acf (added) +++ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.acf Wed Mar 29 21:42:29 2006 @@ -1,0 +1,8 @@ +//file hello.idl +[ + implicit_handle(handle_t hBinding) +] +interface hello +{ + +}
Added: trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.h URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/testsets/r... ============================================================================== --- trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.h (added) +++ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.h Wed Mar 29 21:42:29 2006 @@ -1,0 +1,80 @@ + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 5.03.0280 */ +/* at Fri Mar 24 18:32:16 2006 + */ +/* Compiler settings for ctx.idl: + Os (OptLev=s), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + + +/* verify that the <rpcndr.h> version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 440 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __ctx_h__ +#define __ctx_h__ + +/* Forward Declarations */ + +#ifdef __cplusplus +extern "C"{ +#endif + +void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); +void __RPC_USER MIDL_user_free( void __RPC_FAR * ); + +#ifndef __hello_INTERFACE_DEFINED__ +#define __hello_INTERFACE_DEFINED__ + +/* interface hello */ +/* [implicit_handle][version][uuid] */ + +typedef long CTXTYPE; + +typedef /* [context_handle] */ CTXTYPE __RPC_FAR *PCTXTYPE; + +void CtxOpen( + /* [out] */ PCTXTYPE __RPC_FAR *pphContext, + /* [in] */ long Value); + +void CtxHello( + /* [in] */ PCTXTYPE phContext); + +void CtxClose( + /* [out][in] */ PCTXTYPE __RPC_FAR *pphContext); + + +extern handle_t hBinding; + + +extern RPC_IF_HANDLE hello_v1_0_c_ifspec; +extern RPC_IF_HANDLE hello_v1_0_s_ifspec; +#endif /* __hello_INTERFACE_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +void __RPC_USER PCTXTYPE_rundown( PCTXTYPE ); + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + +
Added: trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.idl URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/testsets/r... ============================================================================== --- trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.idl (added) +++ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx.idl Wed Mar 29 21:42:29 2006 @@ -1,0 +1,19 @@ +//file hello.idl +[ + uuid(7a98c250-6808-11cf-b73b-00aa00b677a7), + version(1.0) +] +interface hello +{ + +typedef long CTXTYPE; +typedef [context_handle] CTXTYPE, *PCTXTYPE; + +void CtxOpen( [out] PCTXTYPE *pphContext, + [in] long Value); + +void CtxHello( [in] PCTXTYPE phContext ); + +void CtxClose( [in, out] PCTXTYPE *pphContext ); + +}
Added: trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx_c.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/testsets/r... ============================================================================== --- trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx_c.c (added) +++ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx_c.c Wed Mar 29 21:42:29 2006 @@ -1,0 +1,335 @@ + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + +/* this ALWAYS GENERATED file contains the RPC client stubs */ + + + /* File created by MIDL compiler version 5.03.0280 */ +/* at Fri Mar 24 18:32:16 2006 + */ +/* Compiler settings for ctx.idl: + Os (OptLev=s), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#if !defined(_M_IA64) && !defined(_M_AXP64) +#include <string.h> +#if defined( _ALPHA_ ) +#include <stdarg.h> +#endif + +#include "ctx.h" + +#define TYPE_FORMAT_STRING_SIZE 23 +#define PROC_FORMAT_STRING_SIZE 21 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } MIDL_TYPE_FORMAT_STRING; + +typedef struct _MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } MIDL_PROC_FORMAT_STRING; + + +extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString; +extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString; + +#define GENERIC_BINDING_TABLE_SIZE 0 + + +/* Standard interface: hello, ver. 1.0, + GUID={0x7a98c250,0x6808,0x11cf,{0xb7,0x3b,0x00,0xaa,0x00,0xb6,0x77,0xa7}} */ + +handle_t hBinding; + + +static const RPC_CLIENT_INTERFACE hello___RpcClientInterface = + { + sizeof(RPC_CLIENT_INTERFACE), + {{0x7a98c250,0x6808,0x11cf,{0xb7,0x3b,0x00,0xaa,0x00,0xb6,0x77,0xa7}},{1,0}}, + {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}, + 0, + 0, + 0, + 0, + 0, + 0 + }; +RPC_IF_HANDLE hello_v1_0_c_ifspec = (RPC_IF_HANDLE)& hello___RpcClientInterface; + +extern const MIDL_STUB_DESC hello_StubDesc; + +RPC_BINDING_HANDLE hello__MIDL_AutoBindHandle; + + +void CtxOpen( + /* [out] */ PCTXTYPE __RPC_FAR *pphContext, + /* [in] */ long Value) +{ + + RPC_BINDING_HANDLE _Handle = 0; + + RPC_MESSAGE _RpcMessage; + + MIDL_STUB_MESSAGE _StubMsg; + + if(!pphContext) + { + RpcRaiseException(RPC_X_NULL_REF_POINTER); + } + RpcTryFinally + { + NdrClientInitializeNew( + ( PRPC_MESSAGE )&_RpcMessage, + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( PMIDL_STUB_DESC )&hello_StubDesc, + 0); + + + _Handle = hBinding; + + + _StubMsg.BufferLength = 4U; + NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle ); + + *(( long __RPC_FAR * )_StubMsg.Buffer)++ = Value; + + NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer ); + + if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION ) + NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] ); + + *pphContext = (void *)0; + NdrClientContextUnmarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_CCONTEXT __RPC_FAR * )pphContext, + _Handle); + + } + RpcFinally + { + NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg ); + + } + RpcEndFinally + +} + + +void CtxHello( + /* [in] */ PCTXTYPE phContext) +{ + + RPC_BINDING_HANDLE _Handle = 0; + + RPC_MESSAGE _RpcMessage; + + MIDL_STUB_MESSAGE _StubMsg; + + RpcTryFinally + { + NdrClientInitializeNew( + ( PRPC_MESSAGE )&_RpcMessage, + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( PMIDL_STUB_DESC )&hello_StubDesc, + 1); + + + if(phContext != 0) + { + _Handle = NDRCContextBinding(( NDR_CCONTEXT )phContext);; + + } + else + { + RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT); + } + + _StubMsg.BufferLength = 20U; + NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle ); + + NdrClientContextMarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_CCONTEXT )phContext, + 1); + NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer ); + + } + RpcFinally + { + NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg ); + + } + RpcEndFinally + +} + + +void CtxClose( + /* [out][in] */ PCTXTYPE __RPC_FAR *pphContext) +{ + + RPC_BINDING_HANDLE _Handle = 0; + + RPC_MESSAGE _RpcMessage; + + MIDL_STUB_MESSAGE _StubMsg; + + if(!pphContext) + { + RpcRaiseException(RPC_X_NULL_REF_POINTER); + } + RpcTryFinally + { + NdrClientInitializeNew( + ( PRPC_MESSAGE )&_RpcMessage, + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( PMIDL_STUB_DESC )&hello_StubDesc, + 2); + + + if(*pphContext != 0) + { + _Handle = NDRCContextBinding(( NDR_CCONTEXT )*pphContext);; + + } + + _StubMsg.BufferLength = 20U; + NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle ); + + NdrClientContextMarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_CCONTEXT )*pphContext, + 0); + NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer ); + + if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION ) + NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[14] ); + + NdrClientContextUnmarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_CCONTEXT __RPC_FAR * )pphContext, + _Handle); + + } + RpcFinally + { + NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg ); + + } + RpcEndFinally + +} + + +const MIDL_STUB_DESC hello_StubDesc = + { + (void __RPC_FAR *)& hello___RpcClientInterface, + MIDL_user_allocate, + MIDL_user_free, + &hBinding, + 0, + 0, + 0, + 0, + __MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x10001, /* Ndr library version */ + 0, + 0x5030118, /* MIDL Version 5.3.280 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* Reserved3 */ + 0, /* Reserved4 */ + 0 /* Reserved5 */ + }; + +#if !defined(__RPC_WIN32__) +#error Invalid build platform for this stub. +#endif + +const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString = + { + 0, + { + + 0x51, /* FC_OUT_PARAM */ +#ifndef _ALPHA_ + 0x1, /* x86, MIPS & PPC stack size = 1 */ +#else + 0x2, /* Alpha stack size = 2 */ +#endif +/* 2 */ NdrFcShort( 0x2 ), /* Type Offset=2 */ +/* 4 */ 0x4e, /* FC_IN_PARAM_BASETYPE */ + 0x8, /* FC_LONG */ +/* 6 */ 0x5b, /* FC_END */ + 0x5c, /* FC_PAD */ +/* 8 */ + 0x4d, /* FC_IN_PARAM */ +#ifndef _ALPHA_ + 0x1, /* x86, MIPS & PPC stack size = 1 */ +#else + 0x2, /* Alpha stack size = 2 */ +#endif +/* 10 */ NdrFcShort( 0xa ), /* Type Offset=10 */ +/* 12 */ 0x5b, /* FC_END */ + 0x5c, /* FC_PAD */ +/* 14 */ + 0x50, /* FC_IN_OUT_PARAM */ +#ifndef _ALPHA_ + 0x1, /* x86, MIPS & PPC stack size = 1 */ +#else + 0x2, /* Alpha stack size = 2 */ +#endif +/* 16 */ NdrFcShort( 0xe ), /* Type Offset=14 */ +/* 18 */ 0x5b, /* FC_END */ + 0x5c, /* FC_PAD */ + + 0x0 + } + }; + +const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x11, 0x0, /* FC_RP */ +/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */ +/* 6 */ 0x30, /* FC_BIND_CONTEXT */ + 0xa0, /* Ctxt flags: via ptr, out, */ +/* 8 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 10 */ 0x30, /* FC_BIND_CONTEXT */ + 0x41, /* Ctxt flags: in, can't be null */ +/* 12 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 14 */ + 0x11, 0x0, /* FC_RP */ +/* 16 */ NdrFcShort( 0x2 ), /* Offset= 2 (18) */ +/* 18 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe1, /* Ctxt flags: via ptr, in, out, can't be null */ +/* 20 */ 0x0, /* 0 */ + 0x0, /* 0 */ + + 0x0 + } + }; + + +#endif /* !defined(_M_IA64) && !defined(_M_AXP64)*/ +
Added: trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx_s.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/testsets/r... ============================================================================== --- trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx_s.c (added) +++ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/ctx_s.c Wed Mar 29 21:42:29 2006 @@ -1,0 +1,349 @@ + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + +/* this ALWAYS GENERATED file contains the RPC server stubs */ + + + /* File created by MIDL compiler version 5.03.0280 */ +/* at Fri Mar 24 18:32:16 2006 + */ +/* Compiler settings for ctx.idl: + Os (OptLev=s), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#if !defined(_M_IA64) && !defined(_M_AXP64) +#include <string.h> +#include "ctx.h" + +#define TYPE_FORMAT_STRING_SIZE 23 +#define PROC_FORMAT_STRING_SIZE 21 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } MIDL_TYPE_FORMAT_STRING; + +typedef struct _MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } MIDL_PROC_FORMAT_STRING; + +extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString; +extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString; + +/* Standard interface: hello, ver. 1.0, + GUID={0x7a98c250,0x6808,0x11cf,{0xb7,0x3b,0x00,0xaa,0x00,0xb6,0x77,0xa7}} */ + + +extern RPC_DISPATCH_TABLE hello_v1_0_DispatchTable; + +static const RPC_SERVER_INTERFACE hello___RpcServerInterface = + { + sizeof(RPC_SERVER_INTERFACE), + {{0x7a98c250,0x6808,0x11cf,{0xb7,0x3b,0x00,0xaa,0x00,0xb6,0x77,0xa7}},{1,0}}, + {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}, + &hello_v1_0_DispatchTable, + 0, + 0, + 0, + 0, + 0 + }; +RPC_IF_HANDLE hello_v1_0_s_ifspec = (RPC_IF_HANDLE)& hello___RpcServerInterface; + +extern const MIDL_STUB_DESC hello_StubDesc; + +void __RPC_STUB +hello_CtxOpen( + PRPC_MESSAGE _pRpcMessage ) +{ + long Value; + MIDL_STUB_MESSAGE _StubMsg; + NDR_SCONTEXT pphContext; + RPC_STATUS _Status; + + ((void)(_Status)); + NdrServerInitializeNew( + _pRpcMessage, + &_StubMsg, + &hello_StubDesc); + + ( PCTXTYPE __RPC_FAR * )pphContext = 0; + RpcTryFinally + { + RpcTryExcept + { + if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION ) + NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] ); + + Value = *(( long __RPC_FAR * )_StubMsg.Buffer)++; + + if(_StubMsg.Buffer > _StubMsg.BufferEnd) + { + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + } + RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER ) + { + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + RpcEndExcept + pphContext = NDRSContextUnmarshall( (char *)0, _pRpcMessage->DataRepresentation ); + + + CtxOpen(( PCTXTYPE __RPC_FAR * )NDRSContextValue(pphContext),Value); + + _StubMsg.BufferLength = 20U; + _pRpcMessage->BufferLength = _StubMsg.BufferLength; + + _Status = I_RpcGetBuffer( _pRpcMessage ); + if ( _Status ) + RpcRaiseException( _Status ); + + _StubMsg.Buffer = (unsigned char __RPC_FAR *) _pRpcMessage->Buffer; + + NdrServerContextMarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_SCONTEXT )pphContext, + ( NDR_RUNDOWN )PCTXTYPE_rundown); + + } + RpcFinally + { + } + RpcEndFinally + _pRpcMessage->BufferLength = + (unsigned int)(_StubMsg.Buffer - (unsigned char __RPC_FAR *)_pRpcMessage->Buffer); + +} + +void __RPC_STUB +hello_CtxHello( + PRPC_MESSAGE _pRpcMessage ) +{ + MIDL_STUB_MESSAGE _StubMsg; + NDR_SCONTEXT phContext; + RPC_STATUS _Status; + + ((void)(_Status)); + NdrServerInitializeNew( + _pRpcMessage, + &_StubMsg, + &hello_StubDesc); + + RpcTryFinally + { + RpcTryExcept + { + if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION ) + NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[8] ); + + phContext = NdrServerContextUnmarshall(( PMIDL_STUB_MESSAGE )&_StubMsg); + + if(_StubMsg.Buffer > _StubMsg.BufferEnd) + { + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + } + RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER ) + { + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + RpcEndExcept + + CtxHello(( PCTXTYPE )*NDRSContextValue(phContext)); + + } + RpcFinally + { + } + RpcEndFinally + _pRpcMessage->BufferLength = + (unsigned int)(_StubMsg.Buffer - (unsigned char __RPC_FAR *)_pRpcMessage->Buffer); + +} + +void __RPC_STUB +hello_CtxClose( + PRPC_MESSAGE _pRpcMessage ) +{ + MIDL_STUB_MESSAGE _StubMsg; + NDR_SCONTEXT pphContext; + RPC_STATUS _Status; + + ((void)(_Status)); + NdrServerInitializeNew( + _pRpcMessage, + &_StubMsg, + &hello_StubDesc); + + ( PCTXTYPE __RPC_FAR * )pphContext = 0; + RpcTryFinally + { + RpcTryExcept + { + if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION ) + NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[14] ); + + pphContext = NdrServerContextUnmarshall(( PMIDL_STUB_MESSAGE )&_StubMsg); + + if(_StubMsg.Buffer > _StubMsg.BufferEnd) + { + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + } + RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER ) + { + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + RpcEndExcept + + CtxClose(( PCTXTYPE __RPC_FAR * )NDRSContextValue(pphContext)); + + _StubMsg.BufferLength = 20U; + _pRpcMessage->BufferLength = _StubMsg.BufferLength; + + _Status = I_RpcGetBuffer( _pRpcMessage ); + if ( _Status ) + RpcRaiseException( _Status ); + + _StubMsg.Buffer = (unsigned char __RPC_FAR *) _pRpcMessage->Buffer; + + NdrServerContextMarshall( + ( PMIDL_STUB_MESSAGE )&_StubMsg, + ( NDR_SCONTEXT )pphContext, + ( NDR_RUNDOWN )PCTXTYPE_rundown); + + } + RpcFinally + { + } + RpcEndFinally + _pRpcMessage->BufferLength = + (unsigned int)(_StubMsg.Buffer - (unsigned char __RPC_FAR *)_pRpcMessage->Buffer); + +} + + +static const MIDL_STUB_DESC hello_StubDesc = + { + (void __RPC_FAR *)& hello___RpcServerInterface, + MIDL_user_allocate, + MIDL_user_free, + 0, + 0, + 0, + 0, + 0, + __MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x10001, /* Ndr library version */ + 0, + 0x5030118, /* MIDL Version 5.3.280 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* Reserved3 */ + 0, /* Reserved4 */ + 0 /* Reserved5 */ + }; + +static RPC_DISPATCH_FUNCTION hello_table[] = + { + hello_CtxOpen, + hello_CtxHello, + hello_CtxClose, + 0 + }; +RPC_DISPATCH_TABLE hello_v1_0_DispatchTable = + { + 3, + hello_table + }; + +#if !defined(__RPC_WIN32__) +#error Invalid build platform for this stub. +#endif + +static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString = + { + 0, + { + + 0x51, /* FC_OUT_PARAM */ +#ifndef _ALPHA_ + 0x1, /* x86, MIPS & PPC stack size = 1 */ +#else + 0x2, /* Alpha stack size = 2 */ +#endif +/* 2 */ NdrFcShort( 0x2 ), /* Type Offset=2 */ +/* 4 */ 0x4e, /* FC_IN_PARAM_BASETYPE */ + 0x8, /* FC_LONG */ +/* 6 */ 0x5b, /* FC_END */ + 0x5c, /* FC_PAD */ +/* 8 */ + 0x4d, /* FC_IN_PARAM */ +#ifndef _ALPHA_ + 0x1, /* x86, MIPS & PPC stack size = 1 */ +#else + 0x2, /* Alpha stack size = 2 */ +#endif +/* 10 */ NdrFcShort( 0xa ), /* Type Offset=10 */ +/* 12 */ 0x5b, /* FC_END */ + 0x5c, /* FC_PAD */ +/* 14 */ + 0x50, /* FC_IN_OUT_PARAM */ +#ifndef _ALPHA_ + 0x1, /* x86, MIPS & PPC stack size = 1 */ +#else + 0x2, /* Alpha stack size = 2 */ +#endif +/* 16 */ NdrFcShort( 0xe ), /* Type Offset=14 */ +/* 18 */ 0x5b, /* FC_END */ + 0x5c, /* FC_PAD */ + + 0x0 + } + }; + +static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x11, 0x0, /* FC_RP */ +/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */ +/* 6 */ 0x30, /* FC_BIND_CONTEXT */ + 0xa0, /* Ctxt flags: via ptr, out, */ +/* 8 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 10 */ 0x30, /* FC_BIND_CONTEXT */ + 0x41, /* Ctxt flags: in, can't be null */ +/* 12 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 14 */ + 0x11, 0x0, /* FC_RP */ +/* 16 */ NdrFcShort( 0x2 ), /* Offset= 2 (18) */ +/* 18 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe1, /* Ctxt flags: via ptr, in, out, can't be null */ +/* 20 */ 0x0, /* 0 */ + 0x0, /* 0 */ + + 0x0 + } + }; + + +#endif /* !defined(_M_IA64) && !defined(_M_AXP64)*/ +
Added: trunk/reactos/base/applications/testsets/rpcrt4/context_handles/server.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/testsets/r... ============================================================================== --- trunk/reactos/base/applications/testsets/rpcrt4/context_handles/server.c (added) +++ trunk/reactos/base/applications/testsets/rpcrt4/context_handles/server.c Wed Mar 29 21:42:29 2006 @@ -1,0 +1,77 @@ +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> +#include "ctx.h" + +void CtxOpen( PCTXTYPE *pphContext, + long Value) +{ + printf("CtxOpen()\n"); + *pphContext = (PCTXTYPE)midl_user_allocate( sizeof(CTXTYPE) ); + **pphContext = Value; +} + +void CtxHello( PCTXTYPE phContext ) +{ + printf("Hello, World! Context value: %d\n", *phContext); +} + +void CtxClose(PCTXTYPE *pphContext ) +{ + printf("CtxClose()\n"); + midl_user_free(*pphContext); + *pphContext = NULL; +} + + +void main() +{ + RPC_STATUS status; + unsigned int cMinCalls = 1; + unsigned int cMaxCalls = 20; + int i; + + status = RpcServerUseProtseqEp("ncacn_np", 20, "\pipe\hello", NULL); + + if (status) + { + printf("RpcServerUseProtseqEp %x\n", status); + exit(status); + } + + status = RpcServerRegisterIf(hello_v1_0_s_ifspec, NULL, NULL); + + if (status) + { + printf("RpcServerRegisterIf %x\n", status); + exit(status); + } + + status = RpcServerListen(1, 20, FALSE); + + if (status) + { + printf("RpcServerListen %x", status); + exit(status); + } + + scanf("%d", &i); +} + + +void __RPC_USER PCTXTYPE_rundown( + PCTXTYPE hContext) +{ + printf("Context rundown \n"); + midl_user_free(hContext); +} + +void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) +{ + return(malloc(len)); +} + +void __RPC_USER midl_user_free(void __RPC_FAR * ptr) +{ + free(ptr); +}