diff --git a/dll/win32/kernel32/kernel32.spec b/dll/win32/kernel32/kernel32.spec index 46dac12d824..11b4491d90e 100644 --- a/dll/win32/kernel32/kernel32.spec +++ b/dll/win32/kernel32/kernel32.spec @@ -524,7 +524,7 @@ @ stub -version=0x600+ GetNamedPipeAttribute @ stub -version=0x600+ GetNamedPipeClientComputerNameA @ stub -version=0x600+ GetNamedPipeClientComputerNameW -@ stub -version=0x600+ GetNamedPipeClientProcessId +@ stdcall -version=0x600+ GetNamedPipeClientProcessId(ptr ptr) @ stub -version=0x600+ GetNamedPipeClientSessionId @ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr str long) @ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long) @@ -1104,6 +1104,7 @@ @ stdcall SetTermsrvAppInstallMode(long) @ stdcall SetThreadAffinityMask(long long) @ stdcall SetThreadContext(long ptr) +@ stdcall -version=0xA00+ SetThreadDescription(ptr wstr) @ stdcall -stub -version=0x600+ SetThreadErrorMode(long ptr) @ stdcall SetThreadExecutionState(long) @ stdcall SetThreadIdealProcessor(long long) diff --git a/dll/win32/kernel32/kernel32_vista/CMakeLists.txt b/dll/win32/kernel32/kernel32_vista/CMakeLists.txt index d945ccbd6da..867216c1362 100644 --- a/dll/win32/kernel32/kernel32_vista/CMakeLists.txt +++ b/dll/win32/kernel32/kernel32_vista/CMakeLists.txt @@ -12,12 +12,14 @@ list(APPEND SOURCE GetLocaleInfoEx.c GetFileInformationByHandleEx.c GetFinalPathNameByHandle.c + GetNamedPipeClientProcessId.c GetTickCount64.c GetUserDefaultLocaleName.c InitOnce.c IsValidLocaleName.c LCIDToLocaleName.c LocaleNameToLCID.c + SetThreadDescription.c sync.c vista.c) diff --git a/dll/win32/kernel32/kernel32_vista/GetNamedPipeClientProcessId.c b/dll/win32/kernel32/kernel32_vista/GetNamedPipeClientProcessId.c new file mode 100644 index 00000000000..98e28785438 --- /dev/null +++ b/dll/win32/kernel32/kernel32_vista/GetNamedPipeClientProcessId.c @@ -0,0 +1,22 @@ + +#include "k32_vista.h" + +#define FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS) + +static inline BOOL set_ntstatus( NTSTATUS status ) +{ + if (status) SetLastError( RtlNtStatusToDosError( status )); + return !status; +} + +/*********************************************************************** + * GetNamedPipeClientProcessId (KERNEL32.@) + */ +BOOL WINAPI GetNamedPipeClientProcessId( HANDLE pipe, ULONG *id ) +{ + IO_STATUS_BLOCK iosb; + + return set_ntstatus( NtFsControlFile( pipe, NULL, NULL, NULL, &iosb, + FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE, (void *)"ClientProcessId", + sizeof("ClientProcessId"), id, sizeof(*id) )); +} diff --git a/dll/win32/kernel32/kernel32_vista/SetThreadDescription.c b/dll/win32/kernel32/kernel32_vista/SetThreadDescription.c new file mode 100644 index 00000000000..35ead9efd61 --- /dev/null +++ b/dll/win32/kernel32/kernel32_vista/SetThreadDescription.c @@ -0,0 +1,28 @@ + +#include "k32_vista.h" +#define NDEBUG +#include + +#undef TRACE +#define TRACE DPRINT + +/*********************************************************************** + * SetThreadDescription (kernelbase.@) + */ +HRESULT WINAPI DECLSPEC_HOTPATCH SetThreadDescription( HANDLE thread, PCWSTR description ) +{ + THREAD_NAME_INFORMATION info; + int length; + + TRACE( "(%p, %s)\n", thread, debugstr_w( description )); + + length = description ? lstrlenW( description ) * sizeof(WCHAR) : 0; + + if (length > USHRT_MAX) + return HRESULT_FROM_NT(STATUS_INVALID_PARAMETER); + + info.ThreadName.Length = info.ThreadName.MaximumLength = length; + info.ThreadName.Buffer = (WCHAR *)description; + + return HRESULT_FROM_NT(NtSetInformationThread( thread, ThreadNameInformation, &info, sizeof(info) )); +} diff --git a/dll/win32/kernel32/kernel32_vista/kernel32_vista.spec b/dll/win32/kernel32/kernel32_vista/kernel32_vista.spec index 71b8a9c3d1f..5ec7e332523 100644 --- a/dll/win32/kernel32/kernel32_vista/kernel32_vista.spec +++ b/dll/win32/kernel32/kernel32_vista/kernel32_vista.spec @@ -56,3 +56,6 @@ @ stdcall RegisterApplicationRestart(wstr long) @ stdcall SetFileBandwidthReservation(ptr long long long ptr ptr) @ stdcall SetThreadPreferredUILanguages(long wstr ptr) + +@ stdcall GetNamedPipeClientProcessId(ptr ptr) +@ stdcall SetThreadDescription(ptr wstr) # Win 10 diff --git a/dll/win32/rpcrt4/CMakeLists.txt b/dll/win32/rpcrt4/CMakeLists.txt index 3c38e389efa..0fda3f72e67 100644 --- a/dll/win32/rpcrt4/CMakeLists.txt +++ b/dll/win32/rpcrt4/CMakeLists.txt @@ -28,6 +28,7 @@ list(APPEND SOURCE ndr_marshall.c ndr_ole.c ndr_stubless.c + ros_extra.c rpc_assoc.c rpc_async.c rpc_binding.c @@ -36,15 +37,17 @@ list(APPEND SOURCE rpcrt4_main.c rpc_server.c rpc_transport.c + thunks.c unix_func.c ${CMAKE_CURRENT_BINARY_DIR}/epm_c.c) if(MSVC) - add_asm_files(rpcrt4_asm msvc.S) + add_asm_files(rpcrt4_asm msvc.S thunks-msvc.s) endif() list(APPEND PCH_SKIP_SOURCE ndr_typelib.c + thunks.c ${CMAKE_CURRENT_BINARY_DIR}/ndr_types_p.c ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${CMAKE_CURRENT_BINARY_DIR}/rpcrt4_stubs.c) @@ -62,8 +65,8 @@ if(MSVC) endif() set_module_type(rpcrt4 win32dll) -target_link_libraries(rpcrt4 wine uuid ${PSEH_LIB} oldnames) -add_delay_importlibs(rpcrt4 iphlpapi wininet secur32 user32 oleaut32) +target_link_libraries(rpcrt4 wine wine_dll_register uuid ${PSEH_LIB} oldnames) +add_delay_importlibs(rpcrt4 iphlpapi wininet secur32 user32 ole32 oleaut32) add_importlibs(rpcrt4 advapi32 advapi32_vista kernel32_vista ws2_32 msvcrt kernel32 ntdll) add_dependencies(rpcrt4 ndr_types_header) add_pch(rpcrt4 precomp.h "${PCH_SKIP_SOURCE}") diff --git a/dll/win32/rpcrt4/cproxy.c b/dll/win32/rpcrt4/cproxy.c index 968c7b51568..c912041d962 100644 --- a/dll/win32/rpcrt4/cproxy.c +++ b/dll/win32/rpcrt4/cproxy.c @@ -50,255 +50,23 @@ static inline StdProxyImpl *impl_from_proxy_obj( void *iface ) return CONTAINING_RECORD(iface, StdProxyImpl, PVtbl); } -#ifdef __i386__ - -extern void call_stubless_func(void); -__ASM_GLOBAL_FUNC(call_stubless_func, - "movl 4(%esp),%ecx\n\t" /* This pointer */ - "movl (%ecx),%ecx\n\t" /* This->lpVtbl */ - "movl -8(%ecx),%ecx\n\t" /* MIDL_STUBLESS_PROXY_INFO */ - "movl 8(%ecx),%edx\n\t" /* info->FormatStringOffset */ - "movzwl (%edx,%eax,2),%edx\n\t" /* FormatStringOffset[index] */ - "addl 4(%ecx),%edx\n\t" /* info->ProcFormatString + offset */ - "movzbl 1(%edx),%eax\n\t" /* Oi_flags */ - "andl $0x08,%eax\n\t" /* Oi_HAS_RPCFLAGS */ - "shrl $1,%eax\n\t" - "movzwl 4(%edx,%eax),%eax\n\t" /* arguments size */ - "pushl %eax\n\t" - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "leal 8(%esp),%eax\n\t" /* &This */ - "pushl %eax\n\t" - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "pushl %edx\n\t" /* format string */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "pushl (%ecx)\n\t" /* info->pStubDesc */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "call " __ASM_NAME("ndr_client_call") "\n\t" - "leal 12(%esp),%esp\n\t" - __ASM_CFI(".cfi_adjust_cfa_offset -12\n\t") - "popl %edx\n\t" /* arguments size */ - __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t") - "movl (%esp),%ecx\n\t" /* return address */ - "addl %edx,%esp\n\t" - "jmp *%ecx" ); - -#include "pshpack1.h" -struct thunk -{ - BYTE mov_eax; - DWORD index; - BYTE jmp; - LONG handler; -}; -#include "poppack.h" - -static inline void init_thunk( struct thunk *thunk, unsigned int index ) -{ - thunk->mov_eax = 0xb8; /* movl $n,%eax */ - thunk->index = index; - thunk->jmp = 0xe9; /* jmp */ - thunk->handler = (char *)call_stubless_func - (char *)(&thunk->handler + 1); -} - -#elif defined(__x86_64__) - -extern void call_stubless_func(void); -__ASM_GLOBAL_FUNC(call_stubless_func, - "subq $0x38,%rsp\n\t" - __ASM_SEH(".seh_stackalloc 0x38\n\t") - __ASM_SEH(".seh_endprologue\n\t") - __ASM_CFI(".cfi_adjust_cfa_offset 0x38\n\t") - "movq %rcx,0x40(%rsp)\n\t" - "movq %rdx,0x48(%rsp)\n\t" - "movq %r8,0x50(%rsp)\n\t" - "movq %r9,0x58(%rsp)\n\t" - "leaq 0x40(%rsp),%r8\n\t" /* &This */ - "movq (%rcx),%rcx\n\t" /* This->lpVtbl */ - "movq -0x10(%rcx),%rcx\n\t" /* MIDL_STUBLESS_PROXY_INFO */ - "movq 0x10(%rcx),%rdx\n\t" /* info->FormatStringOffset */ - "movzwq (%rdx,%r10,2),%rdx\n\t" /* FormatStringOffset[index] */ - "addq 8(%rcx),%rdx\n\t" /* info->ProcFormatString + offset */ - "movq (%rcx),%rcx\n\t" /* info->pStubDesc */ - "movq %xmm1,0x20(%rsp)\n\t" - "movq %xmm2,0x28(%rsp)\n\t" - "movq %xmm3,0x30(%rsp)\n\t" - "leaq 0x18(%rsp),%r9\n\t" /* fpu_args */ - "call " __ASM_NAME("ndr_client_call") "\n\t" - "addq $0x38,%rsp\n\t" - __ASM_CFI(".cfi_adjust_cfa_offset -0x38\n\t") - "ret" ); - -#include "pshpack1.h" -struct thunk -{ - BYTE mov_r10[3]; - DWORD index; - BYTE mov_rax[2]; - void *call_stubless; - BYTE jmp_rax[2]; -}; -#include "poppack.h" - -static const struct thunk thunk_template = -{ - { 0x49, 0xc7, 0xc2 }, 0, /* movq $index,%r10 */ - { 0x48, 0xb8 }, 0, /* movq $call_stubless_func,%rax */ - { 0xff, 0xe0 } /* jmp *%rax */ -}; - -static inline void init_thunk( struct thunk *thunk, unsigned int index ) -{ - *thunk = thunk_template; - thunk->index = index; - thunk->call_stubless = call_stubless_func; -} - -#elif defined(__arm__) - -extern void call_stubless_func(void); -__ASM_GLOBAL_FUNC(call_stubless_func, - "push {r0-r3}\n\t" - "mov r2, sp\n\t" /* stack_top */ - "push {fp,lr}\n\t" - "mov fp, sp\n\t" - "ldr r0, [r0]\n\t" /* This->lpVtbl */ - "ldr r0, [r0,#-8]\n\t" /* MIDL_STUBLESS_PROXY_INFO */ - "ldr r1, [r0,#8]\n\t" /* info->FormatStringOffset */ - "ldrh r1, [r1,ip]\n\t" /* info->FormatStringOffset[index] */ - "ldr ip, [r0,#4]\n\t" /* info->ProcFormatString */ - "add r1, ip\n\t" /* info->ProcFormatString + offset */ - "ldr r0, [r0]\n\t" /* info->pStubDesc */ -#ifdef __SOFTFP__ - "mov r3, #0\n\t" -#else - "vpush {s0-s15}\n\t" /* store the s0-s15/d0-d7 arguments */ - "mov r3, sp\n\t" /* fpu_stack */ -#endif - "bl " __ASM_NAME("ndr_client_call") "\n\t" - "mov sp, fp\n\t" - "pop {fp,lr}\n\t" - "add sp, #16\n\t" - "bx lr" ); - -struct thunk -{ - DWORD ldr_ip; /* ldr ip,[pc] */ - DWORD ldr_pc; /* ldr pc,[pc] */ - DWORD index; - void *func; -}; - -static inline void init_thunk( struct thunk *thunk, unsigned int index ) -{ - thunk->ldr_ip = 0xe59fc000; /* ldr ip,[pc] */ - thunk->ldr_pc = 0xe59ff000; /* ldr pc,[pc] */ - thunk->index = index * sizeof(unsigned short); - thunk->func = call_stubless_func; -} - -#elif defined(__aarch64__) - -extern void call_stubless_func(void); -__ASM_GLOBAL_FUNC( call_stubless_func, - "stp x29, x30, [sp, #-0x90]!\n\t" - "mov x29, sp\n\t" - "stp d0, d1, [sp, #0x10]\n\t" - "stp d2, d3, [sp, #0x20]\n\t" - "stp d4, d5, [sp, #0x30]\n\t" - "stp d6, d7, [sp, #0x40]\n\t" - "stp x0, x1, [sp, #0x50]\n\t" - "stp x2, x3, [sp, #0x60]\n\t" - "stp x4, x5, [sp, #0x70]\n\t" - "stp x6, x7, [sp, #0x80]\n\t" - "ldr x0, [x0]\n\t" /* This->lpVtbl */ - "ldr x0, [x0, #-16]\n\t" /* MIDL_STUBLESS_PROXY_INFO */ - "ldp x1, x4, [x0, #8]\n\t" /* info->ProcFormatString, FormatStringOffset */ - "ldrh w4, [x4, x16, lsl #1]\n\t" /* info->FormatStringOffset[index] */ - "add x1, x1, x4\n\t" /* info->ProcFormatString + offset */ - "ldr x0, [x0]\n\t" /* info->pStubDesc */ - "add x2, sp, #0x50\n\t" /* stack */ - "add x3, sp, #0x10\n\t" /* fpu_stack */ - "bl " __ASM_NAME("ndr_client_call") "\n\t" - "ldp x29, x30, [sp], #0x90\n\t" - "ret" ) - -struct thunk -{ - DWORD ldr_index; /* ldr w16, index */ - DWORD ldr_func; /* ldr x17, func */ - DWORD br; /* br x17 */ - DWORD index; - void *func; -}; - -static inline void init_thunk( struct thunk *thunk, unsigned int index ) -{ - thunk->ldr_index = 0x18000070; /* ldr w16,index */ - thunk->ldr_func = 0x58000071; /* ldr x17,func */ - thunk->br = 0xd61f0220; /* br x17 */ - thunk->index = index; - thunk->func = call_stubless_func; -} - -#else /* __i386__ */ - -#warning You must implement stubless proxies for your CPU - -struct thunk -{ - DWORD index; -}; - -static inline void init_thunk( struct thunk *thunk, unsigned int index ) -{ - thunk->index = index; -} - -#endif /* __i386__ */ - -#define BLOCK_SIZE 1024 -#define MAX_BLOCKS 64 /* 64k methods should be enough for anybody */ - -static const struct thunk *method_blocks[MAX_BLOCKS]; - -static const struct thunk *allocate_block( unsigned int num ) -{ - unsigned int i; - struct thunk *prev, *block; - DWORD oldprot; - - block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block), - MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE ); - if (!block) return NULL; - - for (i = 0; i < BLOCK_SIZE; i++) init_thunk( &block[i], BLOCK_SIZE * num + i + 3 ); - VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, &oldprot ); - prev = InterlockedCompareExchangePointer( (void **)&method_blocks[num], block, NULL ); - if (prev) /* someone beat us to it */ - { - VirtualFree( block, 0, MEM_RELEASE ); - block = prev; - } - return block; -} +extern void ObjectStublessClient3(void); +extern void ObjectStublessClient4(void); BOOL fill_stubless_table( IUnknownVtbl *vtbl, DWORD num ) { + size_t entry_size = (char *)ObjectStublessClient4 - (char *)ObjectStublessClient3; const void **entry = (const void **)(vtbl + 1); - DWORD i, j; + DWORD i; - if (num - 3 > BLOCK_SIZE * MAX_BLOCKS) + if (num >= NB_THUNK_ENTRIES) { - FIXME( "%u methods not supported\n", num ); + FIXME( "%lu methods not supported\n", num ); return FALSE; } - for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++) - { - const struct thunk *block = method_blocks[i]; - if (!block && !(block = allocate_block( i ))) return FALSE; - for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++, entry++) - if (*entry == (LPVOID)-1) *entry = &block[j]; - } + for (i = 0; i < num - 3; i++, entry++) + if (*entry == (void *)-1) *entry = (char *)ObjectStublessClient3 + i * entry_size; + return TRUE; } @@ -320,7 +88,7 @@ HRESULT StdProxy_Construct(REFIID riid, if (ProxyInfo->TableVersion > 1) { ULONG count = ProxyInfo->pStubVtblList[Index]->header.DispatchTableCount; vtbl = (CInterfaceProxyVtbl *)((const void **)vtbl + 1); - TRACE("stubless vtbl %p: count=%d\n", vtbl->Vtbl, count ); + TRACE("stubless vtbl %p: count=%ld\n", vtbl->Vtbl, count ); fill_stubless_table( (IUnknownVtbl *)vtbl->Vtbl, count ); } @@ -329,10 +97,10 @@ HRESULT StdProxy_Construct(REFIID riid, return RPC_E_UNEXPECTED; } - This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(StdProxyImpl)); + This = calloc(1, sizeof(StdProxyImpl)); if (!This) return E_OUTOFMEMORY; - if (!pUnkOuter) pUnkOuter = (IUnknown *)This; + if (!pUnkOuter) pUnkOuter = (IUnknown *)&This->IRpcProxyBuffer_iface; This->IRpcProxyBuffer_iface.lpVtbl = &StdProxy_Vtbl; This->PVtbl = vtbl->Vtbl; /* one reference for the proxy */ @@ -351,7 +119,7 @@ HRESULT StdProxy_Construct(REFIID riid, &This->base_proxy, (void **)&This->base_object ); if (FAILED(r)) { - HeapFree( GetProcessHeap(), 0, This ); + free( This ); return r; } } @@ -411,7 +179,7 @@ static ULONG WINAPI StdProxy_Release(LPRPCPROXYBUFFER iface) if (This->base_proxy) IRpcProxyBuffer_Release( This->base_proxy ); IPSFactoryBuffer_Release(This->pPSFactory); - HeapFree(GetProcessHeap(),0,This); + free(This); } return refs; @@ -454,6 +222,9 @@ static void StdProxy_GetChannel(LPVOID iface, StdProxyImpl *This = impl_from_proxy_obj( iface ); TRACE("(%p)->GetChannel(%p) %s\n",This,ppChannel,This->name); + if(This->pChannel) + IRpcChannelBuffer_AddRef(This->pChannel); + *ppChannel = This->pChannel; } @@ -583,8 +354,10 @@ void WINAPI NdrProxyFreeBuffer(void *This, { IRpcChannelBuffer_FreeBuffer(pStubMsg->pRpcChannelBuffer, (RPCOLEMESSAGE*)pStubMsg->RpcMsg); - pStubMsg->fBufferValid = TRUE; + pStubMsg->fBufferValid = FALSE; } + IRpcChannelBuffer_Release(pStubMsg->pRpcChannelBuffer); + pStubMsg->pRpcChannelBuffer = NULL; } /*********************************************************************** @@ -592,7 +365,7 @@ void WINAPI NdrProxyFreeBuffer(void *This, */ HRESULT WINAPI NdrProxyErrorHandler(DWORD dwExceptionCode) { - WARN("(0x%08x): a proxy call failed\n", dwExceptionCode); + WARN("(0x%08lx): a proxy call failed\n", dwExceptionCode); if (FAILED(dwExceptionCode)) return dwExceptionCode; diff --git a/dll/win32/rpcrt4/cpsf.c b/dll/win32/rpcrt4/cpsf.c index 0deb3beac74..c5baef096e4 100644 --- a/dll/win32/rpcrt4/cpsf.c +++ b/dll/win32/rpcrt4/cpsf.c @@ -41,11 +41,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); static void format_clsid( WCHAR *buffer, const CLSID *clsid ) { - static const WCHAR clsid_formatW[] = {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X','-', - '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X', - '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','}',0}; - - swprintf( buffer, clsid_formatW, clsid->Data1, clsid->Data2, clsid->Data3, + swprintf( buffer, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", + clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0], clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7] ); @@ -222,15 +219,6 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid) { - static const WCHAR bothW[] = {'B','o','t','h',0}; - static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0}; - static const WCHAR clsid32W[] = {'P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0}; - static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0}; - static const WCHAR psfactoryW[] = {'P','S','F','a','c','t','o','r','y','B','u','f','f','e','r',0}; - static const WCHAR numformatW[] = {'%','u',0}; - static const WCHAR nummethodsW[] = {'N','u','m','M','e','t','h','o','d','s',0}; - static const WCHAR inprocserverW[] = {'I','n','P','r','o','c','S','e','r','v','e','r','3','2',0}; - static const WCHAR threadingmodelW[] = {'T','h','r','e','a','d','i','n','g','M','o','d','e','l',0}; WCHAR clsid[39], keyname[50], module[MAX_PATH]; HKEY key, subkey; DWORD len; @@ -257,15 +245,15 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll, TRACE("registering %s %s => %s\n", debugstr_a(name), debugstr_guid(proxy->header.piid), debugstr_w(clsid)); - lstrcpyW( keyname, interfaceW ); + lstrcpyW( keyname, L"Interface\\" ); format_clsid( keyname + lstrlenW(keyname), proxy->header.piid ); if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) { WCHAR num[10]; if (name) RegSetValueExA(key, NULL, 0, REG_SZ, (const BYTE *)name, strlen(name)+1); - RegSetValueW( key, clsid32W, REG_SZ, clsid, 0 ); - swprintf(num, numformatW, proxy->header.DispatchTableCount); - RegSetValueW( key, nummethodsW, REG_SZ, num, 0 ); + RegSetValueW( key, L"ProxyStubClsid32", REG_SZ, clsid, 0 ); + swprintf(num, L"%u", proxy->header.DispatchTableCount); + RegSetValueW( key, L"NumMethods", REG_SZ, num, 0 ); RegCloseKey(key); } } @@ -273,16 +261,16 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll, } /* register clsid to point to module */ - lstrcpyW( keyname, clsidW ); + lstrcpyW( keyname, L"CLSID\\" ); lstrcatW( keyname, clsid ); len = GetModuleFileNameW(hDll, module, ARRAY_SIZE(module)); if (len && len < sizeof(module)) { TRACE("registering CLSID %s => %s\n", debugstr_w(clsid), debugstr_w(module)); if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) { - RegSetValueExW(key, NULL, 0, REG_SZ, (const BYTE *)psfactoryW, sizeof(psfactoryW)); - if (RegCreateKeyW(key, inprocserverW, &subkey) == ERROR_SUCCESS) { + RegSetValueExW(key, NULL, 0, REG_SZ, (const BYTE *)L"PSFactoryBuffer", sizeof(L"PSFactoryBuffer")); + if (RegCreateKeyW(key, L"InProcServer32", &subkey) == ERROR_SUCCESS) { RegSetValueExW(subkey, NULL, 0, REG_SZ, (LPBYTE)module, (lstrlenW(module)+1)*sizeof(WCHAR)); - RegSetValueExW(subkey, threadingmodelW, 0, REG_SZ, (const BYTE *)bothW, sizeof(bothW)); + RegSetValueExW(subkey, L"ThreadingModel", 0, REG_SZ, (const BYTE *)L"Both", sizeof(L"Both")); RegCloseKey(subkey); } RegCloseKey(key); @@ -299,8 +287,6 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid) { - static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0}; - static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0}; WCHAR keyname[50]; WCHAR clsid[39]; @@ -321,7 +307,7 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll, TRACE("unregistering %s %s\n", debugstr_a(name), debugstr_guid(proxy->header.piid)); - lstrcpyW( keyname, interfaceW ); + lstrcpyW( keyname, L"Interface\\" ); format_clsid( keyname + lstrlenW(keyname), proxy->header.piid ); RegDeleteTreeW(HKEY_CLASSES_ROOT, keyname); } @@ -329,7 +315,7 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll, } /* unregister clsid */ - lstrcpyW( keyname, clsidW ); + lstrcpyW( keyname, L"CLSID\\" ); lstrcatW( keyname, clsid ); RegDeleteTreeW(HKEY_CLASSES_ROOT, keyname); diff --git a/dll/win32/rpcrt4/cpsf.h b/dll/win32/rpcrt4/cpsf.h index 3cfbf77ff66..caa4d30298b 100644 --- a/dll/win32/rpcrt4/cpsf.h +++ b/dll/win32/rpcrt4/cpsf.h @@ -39,37 +39,46 @@ typedef struct typedef struct { - IUnknownVtbl *base_obj; + IUnknown base_obj; IRpcStubBuffer *base_stub; CStdStubBuffer stub_buffer; } cstdstubbuffer_delegating_t; HRESULT StdProxy_Construct(REFIID riid, LPUNKNOWN pUnkOuter, const ProxyFileInfo *ProxyInfo, int Index, LPPSFACTORYBUFFER pPSFactory, LPRPCPROXYBUFFER *ppProxy, - LPVOID *ppvObj) DECLSPEC_HIDDEN; -HRESULT WINAPI StdProxy_QueryInterface(IRpcProxyBuffer *iface, REFIID iid, void **obj) DECLSPEC_HIDDEN; -ULONG WINAPI StdProxy_AddRef(IRpcProxyBuffer *iface) DECLSPEC_HIDDEN; -HRESULT WINAPI StdProxy_Connect(IRpcProxyBuffer *iface, IRpcChannelBuffer *channel) DECLSPEC_HIDDEN; -void WINAPI StdProxy_Disconnect(IRpcProxyBuffer *iface) DECLSPEC_HIDDEN; + LPVOID *ppvObj); +HRESULT WINAPI StdProxy_QueryInterface(IRpcProxyBuffer *iface, REFIID iid, void **obj); +ULONG WINAPI StdProxy_AddRef(IRpcProxyBuffer *iface); +HRESULT WINAPI StdProxy_Connect(IRpcProxyBuffer *iface, IRpcChannelBuffer *channel); +void WINAPI StdProxy_Disconnect(IRpcProxyBuffer *iface); HRESULT CStdStubBuffer_Construct(REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name, CInterfaceStubVtbl *vtbl, LPPSFACTORYBUFFER pPSFactory, - LPRPCSTUBBUFFER *ppStub) DECLSPEC_HIDDEN; + LPRPCSTUBBUFFER *ppStub); HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name, CInterfaceStubVtbl *vtbl, REFIID delegating_iid, - LPPSFACTORYBUFFER pPSFactory, LPRPCSTUBBUFFER *ppStub) DECLSPEC_HIDDEN; + LPPSFACTORYBUFFER pPSFactory, LPRPCSTUBBUFFER *ppStub); -const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface) DECLSPEC_HIDDEN; +const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface); -extern const IRpcStubBufferVtbl CStdStubBuffer_Vtbl DECLSPEC_HIDDEN; -extern const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl DECLSPEC_HIDDEN; +extern const IRpcStubBufferVtbl CStdStubBuffer_Vtbl; +extern const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl; -BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num) DECLSPEC_HIDDEN; -HRESULT create_proxy(REFIID iid, IUnknown *pUnkOuter, IRpcProxyBuffer **pproxy, void **ppv) DECLSPEC_HIDDEN; -HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub) DECLSPEC_HIDDEN; -BOOL fill_stubless_table(IUnknownVtbl *vtbl, DWORD num) DECLSPEC_HIDDEN; -IUnknownVtbl *get_delegating_vtbl(DWORD num_methods) DECLSPEC_HIDDEN; -void release_delegating_vtbl(IUnknownVtbl *vtbl) DECLSPEC_HIDDEN; +BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num); +HRESULT create_proxy(REFIID iid, IUnknown *pUnkOuter, IRpcProxyBuffer **pproxy, void **ppv); +HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub); +BOOL fill_stubless_table(IUnknownVtbl *vtbl, DWORD num); +const IUnknownVtbl *get_delegating_vtbl(DWORD num_methods); + +#define NB_THUNK_ENTRIES 1024 + +struct delegating_vtbl +{ + IUnknownVtbl vtbl; + const void *methods[NB_THUNK_ENTRIES - 3]; +}; + +extern const struct delegating_vtbl delegating_vtbl; #endif /* __WINE_CPSF_H */ diff --git a/dll/win32/rpcrt4/cstub.c b/dll/win32/rpcrt4/cstub.c index 7c351c002e8..719ee859163 100644 --- a/dll/win32/rpcrt4/cstub.c +++ b/dll/win32/rpcrt4/cstub.c @@ -32,14 +32,13 @@ #include "rpcproxy.h" #include "wine/debug.h" +#include "wine/asm.h" #include "wine/exception.h" #include "cpsf.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); -#define STUB_HEADER(This) (((const CInterfaceStubHeader*)((This)->lpVtbl))[-1]) - static LONG WINAPI stub_filter(EXCEPTION_POINTERS *eptr) { if (eptr->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE) @@ -47,9 +46,21 @@ static LONG WINAPI stub_filter(EXCEPTION_POINTERS *eptr) return EXCEPTION_EXECUTE_HANDLER; } +static CStdStubBuffer *impl_from_IRpcStubBuffer(IRpcStubBuffer *iface) +{ + return CONTAINING_RECORD(&iface->lpVtbl, CStdStubBuffer, lpVtbl); +} + static inline cstdstubbuffer_delegating_t *impl_from_delegating( IRpcStubBuffer *iface ) { - return CONTAINING_RECORD((void *)iface, cstdstubbuffer_delegating_t, stub_buffer); + return CONTAINING_RECORD(impl_from_IRpcStubBuffer(iface), cstdstubbuffer_delegating_t, stub_buffer); +} + +static const CInterfaceStubHeader *get_stub_header(const CStdStubBuffer *stub) +{ + const CInterfaceStubVtbl *vtbl = CONTAINING_RECORD(stub->lpVtbl, CInterfaceStubVtbl, Vtbl); + + return &vtbl->header; } HRESULT CStdStubBuffer_Construct(REFIID riid, @@ -75,7 +86,7 @@ HRESULT CStdStubBuffer_Construct(REFIID riid, if(FAILED(r)) return r; - This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CStdStubBuffer)); + This = calloc(1, sizeof(CStdStubBuffer)); if (!This) { IUnknown_Release(pvServer); return E_OUTOFMEMORY; @@ -91,250 +102,33 @@ HRESULT CStdStubBuffer_Construct(REFIID riid, return S_OK; } -static CRITICAL_SECTION delegating_vtbl_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &delegating_vtbl_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": delegating_vtbl_section") } -}; -static CRITICAL_SECTION delegating_vtbl_section = { &critsect_debug, -1, 0, 0, 0, 0 }; - -typedef struct -{ - DWORD ref; - DWORD size; - IUnknownVtbl vtbl; - /* remaining entries in vtbl */ -} ref_counted_vtbl; - -static ref_counted_vtbl *current_vtbl; - - -static HRESULT WINAPI delegating_QueryInterface(IUnknown *pUnk, REFIID iid, void **ppv) -{ - *ppv = pUnk; - return S_OK; -} - -static ULONG WINAPI delegating_AddRef(IUnknown *pUnk) -{ - return 1; -} - -static ULONG WINAPI delegating_Release(IUnknown *pUnk) -{ - return 1; -} - -/* The idea here is to replace the first param on the stack - ie. This (which will point to cstdstubbuffer_delegating_t) - with This->stub_buffer.pvServerObject and then jump to the - relevant offset in This->stub_buffer.pvServerObject's vtbl. -*/ -#ifdef __i386__ - -#include "pshpack1.h" -typedef struct { - BYTE mov1[4]; /* mov 0x4(%esp),%eax 8b 44 24 04 */ - BYTE mov2[3]; /* mov 0x10(%eax),%eax 8b 40 10 */ - BYTE mov3[4]; /* mov %eax,0x4(%esp) 89 44 24 04 */ - BYTE mov4[2]; /* mov (%eax),%eax 8b 00 */ - BYTE mov5[2]; /* jmp *offset(%eax) ff a0 offset */ - DWORD offset; - BYTE pad[1]; /* nop 90 */ -} vtbl_method_t; -#include "poppack.h" - -static const BYTE opcodes[20] = { 0x8b, 0x44, 0x24, 0x04, 0x8b, 0x40, 0x10, 0x89, 0x44, 0x24, 0x04, - 0x8b, 0x00, 0xff, 0xa0, 0, 0, 0, 0, 0x90 }; - -#elif defined(__x86_64__) - -#include "pshpack1.h" -typedef struct -{ - BYTE mov1[4]; /* movq 0x20(%rcx),%rcx 48 8b 49 20 */ - BYTE mov2[3]; /* movq (%rcx),%rax 48 8b 01 */ - BYTE jmp[2]; /* jmp *offset(%rax) ff a0 offset */ - DWORD offset; - BYTE pad[3]; /* lea 0x0(%rsi),%rsi 48 8d 36 */ -} vtbl_method_t; -#include "poppack.h" - -static const BYTE opcodes[16] = { 0x48, 0x8b, 0x49, 0x20, 0x48, 0x8b, 0x01, - 0xff, 0xa0, 0, 0, 0, 0, 0x48, 0x8d, 0x36 }; -#elif defined(__arm__) - -static const DWORD opcodes[] = -{ - 0xe52d4004, /* push {r4} */ - 0xe5900010, /* ldr r0, [r0, #16] */ - 0xe5904000, /* ldr r4, [r0] */ - 0xe59fc008, /* ldr ip, [pc, #8] */ - 0xe08cc004, /* add ip, ip, r4 */ - 0xe49d4004, /* pop {r4} */ - 0xe59cf000 /* ldr pc, [ip] */ -}; - -typedef struct -{ - DWORD opcodes[ARRAY_SIZE(opcodes)]; - DWORD offset; -} vtbl_method_t; - -#elif defined(__aarch64__) - -static const DWORD opcodes[] = -{ - 0xf9401000, /* ldr x0, [x0,#32] */ - 0xf9400010, /* ldr x16, [x0] */ - 0x18000071, /* ldr w17, offset */ - 0xf8716a10, /* ldr x16, [x16,x17] */ - 0xd61f0200 /* br x16 */ -}; - -typedef struct -{ - DWORD opcodes[ARRAY_SIZE(opcodes)]; - DWORD offset; -} vtbl_method_t; - -#else - -#warning You must implement delegated proxies/stubs for your CPU -typedef struct -{ - DWORD offset; -} vtbl_method_t; -static const BYTE opcodes[1]; - -#endif - -#define BLOCK_SIZE 1024 -#define MAX_BLOCKS 64 /* 64k methods should be enough for anybody */ - -static const vtbl_method_t *method_blocks[MAX_BLOCKS]; - -static const vtbl_method_t *allocate_block( unsigned int num ) -{ - unsigned int i; - vtbl_method_t *prev, *block; - DWORD oldprot; - - block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block), - MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE ); - if (!block) return NULL; - - for (i = 0; i < BLOCK_SIZE; i++) - { - memcpy( &block[i], opcodes, sizeof(opcodes) ); - block[i].offset = (BLOCK_SIZE * num + i + 3) * sizeof(void *); - } - VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, &oldprot ); - prev = InterlockedCompareExchangePointer( (void **)&method_blocks[num], block, NULL ); - if (prev) /* someone beat us to it */ - { - VirtualFree( block, 0, MEM_RELEASE ); - block = prev; - } - return block; -} - -static BOOL fill_delegated_stub_table(IUnknownVtbl *vtbl, DWORD num) -{ - const void **entry = (const void **)(vtbl + 1); - DWORD i, j; - - if (num - 3 > BLOCK_SIZE * MAX_BLOCKS) - { - FIXME( "%u methods not supported\n", num ); - return FALSE; - } - vtbl->QueryInterface = delegating_QueryInterface; - vtbl->AddRef = delegating_AddRef; - vtbl->Release = delegating_Release; - for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++) - { - const vtbl_method_t *block = method_blocks[i]; - if (!block && !(block = allocate_block( i ))) return FALSE; - for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++) *entry++ = &block[j]; - } - return TRUE; -} BOOL fill_delegated_proxy_table(IUnknownVtbl *vtbl, DWORD num) { const void **entry = (const void **)(vtbl + 1); - DWORD i, j; + DWORD i; - if (num - 3 > BLOCK_SIZE * MAX_BLOCKS) + if (num > NB_THUNK_ENTRIES) { - FIXME( "%u methods not supported\n", num ); + FIXME( "%lu methods not supported\n", num ); return FALSE; } vtbl->QueryInterface = IUnknown_QueryInterface_Proxy; vtbl->AddRef = IUnknown_AddRef_Proxy; vtbl->Release = IUnknown_Release_Proxy; - for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++) - { - const vtbl_method_t *block = method_blocks[i]; - if (!block && !(block = allocate_block( i ))) return FALSE; - for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++, entry++) - if (!*entry) *entry = &block[j]; - } + for (i = 0; i < num - 3; i++) + if (!entry[i]) entry[i] = delegating_vtbl.methods[i]; return TRUE; } -IUnknownVtbl *get_delegating_vtbl(DWORD num_methods) +const IUnknownVtbl *get_delegating_vtbl(DWORD num) { - IUnknownVtbl *ret; - - if (num_methods < 256) num_methods = 256; /* avoid frequent reallocations */ - - EnterCriticalSection(&delegating_vtbl_section); - - if(!current_vtbl || num_methods > current_vtbl->size) + if (num > NB_THUNK_ENTRIES) { - ref_counted_vtbl *table = HeapAlloc(GetProcessHeap(), 0, - FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*)); - if (!table) - { - LeaveCriticalSection(&delegating_vtbl_section); - return NULL; - } - - table->ref = 0; - table->size = num_methods; - fill_delegated_stub_table(&table->vtbl, num_methods); - - if (current_vtbl && current_vtbl->ref == 0) - { - TRACE("freeing old table\n"); - HeapFree(GetProcessHeap(), 0, current_vtbl); - } - current_vtbl = table; + FIXME( "%lu methods not supported\n", num ); + return NULL; } - - current_vtbl->ref++; - ret = ¤t_vtbl->vtbl; - LeaveCriticalSection(&delegating_vtbl_section); - return ret; -} - -void release_delegating_vtbl(IUnknownVtbl *vtbl) -{ - ref_counted_vtbl *table = (ref_counted_vtbl*)((DWORD *)vtbl - 1); - - EnterCriticalSection(&delegating_vtbl_section); - table->ref--; - TRACE("ref now %d\n", table->ref); - if(table->ref == 0 && table != current_vtbl) - { - TRACE("... and we're not current so free'ing\n"); - HeapFree(GetProcessHeap(), 0, table); - } - LeaveCriticalSection(&delegating_vtbl_section); + return &delegating_vtbl.vtbl; } HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid, @@ -362,19 +156,18 @@ HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid, r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer); if(FAILED(r)) return r; - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This)); + This = calloc(1, sizeof(*This)); if (!This) { IUnknown_Release(pvServer); return E_OUTOFMEMORY; } - This->base_obj = get_delegating_vtbl( vtbl->header.DispatchTableCount ); - r = create_stub(delegating_iid, (IUnknown*)&This->base_obj, &This->base_stub); + This->base_obj.lpVtbl = get_delegating_vtbl( vtbl->header.DispatchTableCount ); + r = create_stub(delegating_iid, &This->base_obj, &This->base_stub); if(FAILED(r)) { - release_delegating_vtbl(This->base_obj); - HeapFree(GetProcessHeap(), 0, This); + free(This); IUnknown_Release(pvServer); return r; } @@ -393,7 +186,7 @@ HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *obj) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj); if (IsEqualIID(&IID_IUnknown, riid) || @@ -409,7 +202,7 @@ HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface, ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); TRACE("(%p)->AddRef()\n",This); return InterlockedIncrement(&This->RefCount); } @@ -417,7 +210,7 @@ ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface) ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface, LPPSFACTORYBUFFER pPSF) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); ULONG refs; TRACE("(%p)->Release()\n",This); @@ -430,7 +223,7 @@ ULONG WINAPI NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface, IRpcStubBuffer_Disconnect(iface); IPSFactoryBuffer_Release(pPSF); - HeapFree(GetProcessHeap(),0,This); + free(This); } return refs; } @@ -451,10 +244,8 @@ ULONG WINAPI NdrCStdStubBuffer2_Release(LPRPCSTUBBUFFER iface, IRpcStubBuffer_Disconnect((IRpcStubBuffer *)&This->stub_buffer); IRpcStubBuffer_Release(This->base_stub); - release_delegating_vtbl(This->base_obj); - IPSFactoryBuffer_Release(pPSF); - HeapFree(GetProcessHeap(), 0, This); + free(This); } return refs; @@ -463,13 +254,13 @@ ULONG WINAPI NdrCStdStubBuffer2_Release(LPRPCSTUBBUFFER iface, HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN lpUnkServer) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); HRESULT r; IUnknown *new = NULL; TRACE("(%p)->Connect(%p)\n",This,lpUnkServer); - r = IUnknown_QueryInterface(lpUnkServer, STUB_HEADER(This).piid, (void**)&new); + r = IUnknown_QueryInterface(lpUnkServer, get_stub_header(This)->piid, (void**)&new); new = InterlockedExchangePointer((void**)&This->pvServerObject, new); if(new) IUnknown_Release(new); @@ -478,7 +269,7 @@ HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface, void WINAPI CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); IUnknown *old; TRACE("(%p)->Disconnect()\n",This); @@ -492,7 +283,8 @@ HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface, PRPCOLEMESSAGE pMsg, LPRPCCHANNELBUFFER pChannel) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); + const CInterfaceStubHeader *header = get_stub_header(This); DWORD dwPhase = STUB_UNMARSHAL; HRESULT hr = S_OK; @@ -500,15 +292,15 @@ HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface, __TRY { - if (STUB_HEADER(This).pDispatchTable) - STUB_HEADER(This).pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase); + if (header->pDispatchTable) + header->pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase); else /* pure interpreted */ NdrStubCall2(iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase); } __EXCEPT(stub_filter) { DWORD dwExceptionCode = GetExceptionCode(); - WARN("a stub call failed with exception 0x%08x (%d)\n", dwExceptionCode, dwExceptionCode); + WARN("a stub call failed with exception 0x%08lx (%ld)\n", dwExceptionCode, dwExceptionCode); if (FAILED(dwExceptionCode)) hr = dwExceptionCode; else @@ -522,14 +314,18 @@ HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface, LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface, REFIID riid) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; - TRACE("(%p)->IsIIDSupported(%s)\n",This,debugstr_guid(riid)); - return IsEqualGUID(STUB_HEADER(This).piid, riid) ? iface : NULL; + CStdStubBuffer *stub = impl_from_IRpcStubBuffer(iface); + + TRACE("(%p)->IsIIDSupported(%s)\n", stub, debugstr_guid(riid)); + + if (IsEqualGUID(get_stub_header(stub)->piid, riid)) + return iface; + return NULL; } ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); TRACE("(%p)->CountRefs()\n",This); return This->RefCount; } @@ -537,7 +333,7 @@ ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface) HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface, LPVOID *ppv) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); TRACE("(%p)->DebugServerQueryInterface(%p)\n",This,ppv); return S_OK; } @@ -545,7 +341,7 @@ HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface, void WINAPI CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface, LPVOID pv) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); TRACE("(%p)->DebugServerRelease(%p)\n",This,pv); } @@ -614,8 +410,9 @@ const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl = const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; - return STUB_HEADER(This).pServerInfo; + CStdStubBuffer *stub = impl_from_IRpcStubBuffer(iface); + + return get_stub_header(stub)->pServerInfo; } /************************************************************************ @@ -655,14 +452,14 @@ void WINAPI NdrStubGetBuffer(LPRPCSTUBBUFFER iface, LPRPCCHANNELBUFFER pRpcChannelBuffer, PMIDL_STUB_MESSAGE pStubMsg) { - CStdStubBuffer *This = (CStdStubBuffer *)iface; + CStdStubBuffer *This = impl_from_IRpcStubBuffer(iface); HRESULT hr; TRACE("(%p, %p, %p)\n", This, pRpcChannelBuffer, pStubMsg); pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength; hr = IRpcChannelBuffer_GetBuffer(pRpcChannelBuffer, - (RPCOLEMESSAGE *)pStubMsg->RpcMsg, STUB_HEADER(This).piid); + (RPCOLEMESSAGE *)pStubMsg->RpcMsg, get_stub_header(This)->piid); if (FAILED(hr)) { RpcRaiseException(hr); diff --git a/dll/win32/rpcrt4/epm.h b/dll/win32/rpcrt4/epm.h new file mode 100644 index 00000000000..ef25b7897a7 --- /dev/null +++ b/dll/win32/rpcrt4/epm.h @@ -0,0 +1,4 @@ + +#pragma once + +#include "epm_c.h" diff --git a/dll/win32/rpcrt4/epm_towers.h b/dll/win32/rpcrt4/epm_towers.h index 6208deb5f1f..3eec37aa228 100644 --- a/dll/win32/rpcrt4/epm_towers.h +++ b/dll/win32/rpcrt4/epm_towers.h @@ -19,9 +19,7 @@ * */ -#pragma once - -#include +#include "epm.h" #define EPM_PROTOCOL_DNET_NSP 0x04 #define EPM_PROTOCOL_OSI_TP4 0x05 diff --git a/dll/win32/rpcrt4/msvc.S b/dll/win32/rpcrt4/msvc.S index a1da254285b..e0fe5eda26c 100644 --- a/dll/win32/rpcrt4/msvc.S +++ b/dll/win32/rpcrt4/msvc.S @@ -8,7 +8,7 @@ #ifdef _M_IX86 .code32 -EXTERN _ndr_client_call:PROC +EXTERN _NdrpClientCall2@16:PROC PUBLIC _call_stubless_func _call_stubless_func: @@ -24,21 +24,64 @@ _call_stubless_func: shr eax, 1 movzx eax, word ptr [edx+eax+4] /* arguments size */ push eax - lea eax, [esp+8] /* &This */ + // .cfi_adjust_cfa_offset 4 + push 0 /* fpu_stack */ + // .cfi_adjust_cfa_offset 4 + lea eax, [esp + 12] /* &This */ push eax + // .cfi_adjust_cfa_offset 4 push edx /* format string */ - push [ecx] /* info->pstubdesc */ - call _ndr_client_call - lea esp, [esp+12] + // .cfi_adjust_cfa_offset 4 + push [ecx] /* info->pStubDesc */ + // .cfi_adjust_cfa_offset 4 + call _NdrpClientCall2@16 + // .cfi_adjust_cfa_offset -16 pop edx /* arguments size */ + // .cfi_adjust_cfa_offset -4 mov ecx, [esp] /* return address */ add esp, edx jmp ecx +PUBLIC _NdrClientCall2 +_NdrClientCall2: + push ebp + // .cfi_adjust_cfa_offset 4 + // .cfi_rel_offset %ebp,0 + mov ebp, esp + // .cfi_def_cfa_register %ebp + push 0 /* fpu_stack */ + push [ebp + 16] /* stack */ + push [ebp + 12] /* format */ + push [ebp + 8] /* desc */ + call _NdrpClientCall2@16 + leave + // .cfi_def_cfa %esp,4 + // .cfi_same_value %ebp + ret + +EXTERN _ndr_async_client_call:PROC +PUBLIC _NdrAsyncClientCall +_NdrAsyncClientCall: + push ebp + // .cfi_adjust_cfa_offset 4 + // .cfi_rel_offset %ebp,0 + mov ebp, esp + // .cfi_def_cfa_register %ebp + push 0 /* fpu_stack */ + push [ebp + 16] /* stack */ + push [ebp + 12] /* format */ + push [ebp + 8] /* desc */ + call _ndr_async_client_call + leave + // .cfi_def_cfa %esp,4 + // .cfi_same_value %ebp + ret + #elif _M_AMD64 .code64 -EXTERN ndr_client_call:PROC +EXTERN NdrpClientCall2:PROC +EXTERN ndr_stubless_client_call:PROC PUBLIC call_stubless_func FUNC call_stubless_func @@ -54,19 +97,13 @@ FUNC call_stubless_func .ALLOCSTACK 38h .ENDPROLOG - lea r8, [rsp +38h + 8] /* &This */ - mov rcx, [rcx] /* This->lpVtbl */ - mov rcx, [rcx - 10h] /* MIDL_STUBLESS_PROXY_INFO */ - mov rdx, [rcx + 10h] /* info->FormatStringOffset */ - movzx rdx, word ptr [rdx+r10*2] /* FormatStringOffset[index] */ - add rdx, [rcx + 8] /* info->ProcFormatString + offset */ - mov rcx, [rcx] /* info->pStubDesc */ - + lea rdx, [rsp + 40h] /* args */ movsd qword ptr [rsp + 20h], xmm1 movsd qword ptr [rsp + 28h], xmm2 movsd qword ptr [rsp + 30h], xmm3 - lea r9, [rsp + 18h] /* fpu_args */ - call ndr_client_call + lea r8, [rsp + 18h] /* fpu_regs */ + mov ecx, r10d /* index */ + call ndr_stubless_client_call add rsp, 38h ret ENDFUNC @@ -129,9 +166,9 @@ FUNC NdrClientCall2 .ALLOCSTACK 28h .ENDPROLOG - lea r8, [rsp + 28h + 18h] - xor r9, r9 - call ndr_client_call + lea r8, [rsp + 28h + 18h] /* stack */ + xor r9, r9 /* fpu_stack */ + call NdrpClientCall2 add rsp, 28h ret @@ -148,13 +185,43 @@ FUNC NdrAsyncClientCall .ALLOCSTACK 28h .ENDPROLOG - lea r8, [rsp + 28h + 18h] + lea r8, [rsp + 28h + 18h] /* stack */ + xor r9, r9 /* fpu_stack */ call ndr_async_client_call add rsp, 28h ret ENDFUNC +EXTERN ndr64_client_call:PROC +PUBLIC NdrClientCall3 +FUNC NdrClientCall3 + sub rsp, 28h + .ALLOCSTACK 28h + .ENDPROLOG + + mov [rsp + 48h], r9 + lea r9, [rsp + 48h] /* stack */ + call ndr64_client_call + add rsp, 28h + ret +ENDFUNC + +EXTERN ndr64_async_client_call:PROC +PUBLIC Ndr64AsyncClientCall +FUNC Ndr64AsyncClientCall + mov [rsp + 20h], r9 + lea r9, [rsp + 20h] + push 0 + sub rsp, 20h + .ALLOCSTACK 28h + .ENDPROLOG + + call ndr64_async_client_call + add rsp, 28h + ret +ENDFUNC + #elif _M_ARM TEXTAREA diff --git a/dll/win32/rpcrt4/ndr_clientserver.c b/dll/win32/rpcrt4/ndr_clientserver.c index 66fe33b2839..e67046e4c08 100644 --- a/dll/win32/rpcrt4/ndr_clientserver.c +++ b/dll/win32/rpcrt4/ndr_clientserver.c @@ -78,7 +78,6 @@ void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg->PointerLength = 0; pStubMsg->fInDontFree = 0; pStubMsg->fDontCallFreeInst = 0; - pStubMsg->fInOnlyParam = 0; pStubMsg->fHasReturn = 0; pStubMsg->fHasExtensions = 0; pStubMsg->fHasNewCorrDesc = 0; @@ -89,7 +88,7 @@ void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg->fHasMemoryValidateCallback = 0; pStubMsg->fInFree = 0; pStubMsg->fNeedMCCP = 0; - pStubMsg->fUnused = 0; + pStubMsg->fUnused2 = 0; pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE; pStubMsg->pvDestContext = NULL; pStubMsg->pRpcChannelBuffer = NULL; @@ -132,7 +131,6 @@ unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_M pStubMsg->PointerLength = 0; pStubMsg->fInDontFree = 0; pStubMsg->fDontCallFreeInst = 0; - pStubMsg->fInOnlyParam = 0; pStubMsg->fHasReturn = 0; pStubMsg->fHasExtensions = 0; pStubMsg->fHasNewCorrDesc = 0; @@ -142,7 +140,7 @@ unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_M pStubMsg->fHasMemoryValidateCallback = 0; pStubMsg->fInFree = 0; pStubMsg->fNeedMCCP = 0; - pStubMsg->fUnused = 0; + pStubMsg->fUnused2 = 0; pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE; pStubMsg->pvDestContext = NULL; pStubMsg->pRpcChannelBuffer = NULL; @@ -164,7 +162,7 @@ unsigned char *WINAPI NdrGetBuffer(PMIDL_STUB_MESSAGE stubmsg, ULONG buflen, RPC { RPC_STATUS status; - TRACE("(stubmsg == ^%p, buflen == %u, handle == %p)\n", stubmsg, buflen, handle); + TRACE("(stubmsg == ^%p, buflen == %lu, handle == %p)\n", stubmsg, buflen, handle); stubmsg->RpcMsg->Handle = handle; stubmsg->RpcMsg->BufferLength = buflen; @@ -233,7 +231,7 @@ RPC_STATUS RPC_ENTRY NdrMapCommAndFaultStatus( PMIDL_STUB_MESSAGE pStubMsg, ULONG *pFaultStatus, RPC_STATUS Status ) { - TRACE("(%p, %p, %p, %d)\n", pStubMsg, pCommStatus, pFaultStatus, Status); + TRACE("(%p, %p, %p, %ld)\n", pStubMsg, pCommStatus, pFaultStatus, Status); switch (Status) { diff --git a/dll/win32/rpcrt4/ndr_contexthandle.c b/dll/win32/rpcrt4/ndr_contexthandle.c index 848d924e970..1bff1e82936 100644 --- a/dll/win32/rpcrt4/ndr_contexthandle.c +++ b/dll/win32/rpcrt4/ndr_contexthandle.c @@ -19,9 +19,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include + #include "ndr_misc.h" #include "rpc_assoc.h" #include "rpcndr.h" +#include "cguid.h" #include "wine/debug.h" #include "wine/list.h" @@ -139,7 +142,7 @@ RPC_STATUS WINAPI RpcSmDestroyClientContext(void **ContextHandle) if (che) { RpcBindingFree(&che->handle); - HeapFree(GetProcessHeap(), 0, che); + free(che); } return status; @@ -179,14 +182,14 @@ static RPC_STATUS ndr_update_context_handle(NDR_CCONTEXT *CContext, return RPC_X_SS_CONTEXT_MISMATCH; list_remove(&che->entry); RpcBindingFree(&che->handle); - HeapFree(GetProcessHeap(), 0, che); + free(che); che = NULL; } } /* if there's no existing entry matching the GUID, allocate one */ else if (!(che = context_entry_from_guid(&chi->uuid))) { - che = HeapAlloc(GetProcessHeap(), 0, sizeof *che); + che = malloc(sizeof *che); if (!che) return RPC_X_NO_MEMORY; che->magic = NDR_CONTEXT_HANDLE_MAGIC; @@ -209,7 +212,7 @@ void WINAPI NDRCContextUnmarshall(NDR_CCONTEXT *CContext, { RPC_STATUS status; - TRACE("*%p=(%p) %p %p %08x\n", + TRACE("*%p=(%p) %p %p %08lx\n", CContext, *CContext, hBinding, pBuff, DataRepresentation); EnterCriticalSection(&ndr_context_cs); @@ -257,7 +260,7 @@ void WINAPI NDRSContextMarshall2(RPC_BINDING_HANDLE hBinding, RPC_STATUS status; ndr_context_handle *ndr = pBuff; - TRACE("(%p %p %p %p %p %u)\n", + TRACE("(%p %p %p %p %p %lu)\n", hBinding, SContext, pBuff, userRunDownIn, CtxGuard, Flags); if (!binding->server || !binding->Assoc) @@ -297,7 +300,7 @@ void WINAPI NDRSContextMarshall2(RPC_BINDING_HANDLE hBinding, NDR_SCONTEXT WINAPI NDRSContextUnmarshall(void *pBuff, ULONG DataRepresentation) { - TRACE("(%p %08x)\n", pBuff, DataRepresentation); + TRACE("(%p %08lx)\n", pBuff, DataRepresentation); return NDRSContextUnmarshall2(I_RpcGetCurrentCallHandle(), pBuff, DataRepresentation, NULL, RPC_CONTEXT_HANDLE_DEFAULT_FLAGS); @@ -310,7 +313,7 @@ NDR_SCONTEXT WINAPI NDRSContextUnmarshallEx(RPC_BINDING_HANDLE hBinding, void *pBuff, ULONG DataRepresentation) { - TRACE("(%p %p %08x)\n", hBinding, pBuff, DataRepresentation); + TRACE("(%p %p %08lx)\n", hBinding, pBuff, DataRepresentation); return NDRSContextUnmarshall2(hBinding, pBuff, DataRepresentation, NULL, RPC_CONTEXT_HANDLE_DEFAULT_FLAGS); } @@ -328,7 +331,7 @@ NDR_SCONTEXT WINAPI NDRSContextUnmarshall2(RPC_BINDING_HANDLE hBinding, RPC_STATUS status; const ndr_context_handle *context_ndr = pBuff; - TRACE("(%p %p %08x %p %u)\n", + TRACE("(%p %p %08lx %p %lu)\n", hBinding, pBuff, DataRepresentation, CtxGuard, Flags); if (!binding->server || !binding->Assoc) @@ -342,7 +345,7 @@ NDR_SCONTEXT WINAPI NDRSContextUnmarshall2(RPC_BINDING_HANDLE hBinding, { if (context_ndr->attributes) { - ERR("non-null attributes 0x%x\n", context_ndr->attributes); + ERR("non-null attributes 0x%lx\n", context_ndr->attributes); status = RPC_X_SS_CONTEXT_MISMATCH; } else diff --git a/dll/win32/rpcrt4/ndr_es.c b/dll/win32/rpcrt4/ndr_es.c index 158bc7cda2a..3c870f41d78 100644 --- a/dll/win32/rpcrt4/ndr_es.c +++ b/dll/win32/rpcrt4/ndr_es.c @@ -20,6 +20,7 @@ #include #include +#include #include "windef.h" #include "winbase.h" @@ -55,7 +56,7 @@ RPC_STATUS WINAPI MesEncodeIncrementalHandleCreate( TRACE("(%p, %p, %p, %p)\n", UserState, AllocFn, WriteFn, pHandle); - pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg)); + pEsMsg = malloc(sizeof(*pEsMsg)); if (!pEsMsg) return RPC_S_OUT_OF_MEMORY; @@ -82,7 +83,7 @@ RPC_STATUS WINAPI MesDecodeIncrementalHandleCreate( TRACE("(%p, %p, %p)\n", UserState, ReadFn, pHandle); - pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg)); + pEsMsg = malloc(sizeof(*pEsMsg)); if (!pEsMsg) return RPC_S_OUT_OF_MEMORY; @@ -130,7 +131,7 @@ RPC_STATUS WINAPI MesBufferHandleReset(handle_t Handle, ULONG HandleStyle, { MIDL_ES_MESSAGE *pEsMsg = (MIDL_ES_MESSAGE *)Handle; - TRACE("(%p, %u, %d, %p, %u, %p)\n", Handle, HandleStyle, Operation, Buffer, + TRACE("(%p, %lu, %d, %p, %lu, %p)\n", Handle, HandleStyle, Operation, Buffer, BufferSize, EncodedSize); if (!Handle || !Buffer || !EncodedSize) @@ -162,7 +163,7 @@ RPC_STATUS WINAPI MesBufferHandleReset(handle_t Handle, ULONG HandleStyle, RPC_STATUS WINAPI MesHandleFree(handle_t Handle) { TRACE("(%p)\n", Handle); - HeapFree(GetProcessHeap(), 0, Handle); + free(Handle); return RPC_S_OK; } @@ -186,7 +187,7 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate( MIDL_ES_MESSAGE *pEsMsg; RPC_STATUS status; - TRACE("(%p, %d, %p, %p)\n", Buffer, BufferSize, pEncodedSize, pHandle); + TRACE("(%p, %ld, %p, %p)\n", Buffer, BufferSize, pEncodedSize, pHandle); if ((status = validate_mes_buffer_pointer(Buffer))) return status; @@ -196,7 +197,7 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate( /* FIXME: check BufferSize too */ - pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg)); + pEsMsg = malloc(sizeof(*pEsMsg)); if (!pEsMsg) return RPC_S_OUT_OF_MEMORY; @@ -226,7 +227,7 @@ RPC_STATUS RPC_ENTRY MesEncodeDynBufferHandleCreate(char **Buffer, if (!pEncodedSize) return RPC_S_INVALID_ARG; - pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg)); + pEsMsg = malloc(sizeof(*pEsMsg)); if (!pEsMsg) return RPC_S_OUT_OF_MEMORY; @@ -251,12 +252,12 @@ RPC_STATUS RPC_ENTRY MesDecodeBufferHandleCreate( MIDL_ES_MESSAGE *pEsMsg; RPC_STATUS status; - TRACE("(%p, %d, %p)\n", Buffer, BufferSize, pHandle); + TRACE("(%p, %ld, %p)\n", Buffer, BufferSize, pHandle); if ((status = validate_mes_buffer_pointer(Buffer))) return status; - pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg)); + pEsMsg = malloc(sizeof(*pEsMsg)); if (!pEsMsg) return RPC_S_OUT_OF_MEMORY; @@ -277,17 +278,17 @@ static void es_data_alloc(MIDL_ES_MESSAGE *pEsMsg, ULONG size) if (pEsMsg->HandleStyle == MES_INCREMENTAL_HANDLE) { unsigned int tmpsize = size; - TRACE("%d with incremental handle\n", size); + TRACE("%ld with incremental handle\n", size); pEsMsg->Alloc(pEsMsg->UserState, (char **)&pEsMsg->StubMsg.Buffer, &tmpsize); if (tmpsize < size) { - ERR("not enough bytes allocated - requested %d, got %d\n", size, tmpsize); + ERR("not enough bytes allocated - requested %ld, got %d\n", size, tmpsize); RpcRaiseException(RPC_S_OUT_OF_MEMORY); } } else if (pEsMsg->HandleStyle == MES_FIXED_BUFFER_HANDLE) { - TRACE("%d with fixed buffer handle\n", size); + TRACE("%ld with fixed buffer handle\n", size); pEsMsg->StubMsg.Buffer = pEsMsg->Buffer; } pEsMsg->StubMsg.RpcMsg->Buffer = pEsMsg->StubMsg.BufferStart = pEsMsg->StubMsg.Buffer; @@ -298,17 +299,17 @@ static void es_data_read(MIDL_ES_MESSAGE *pEsMsg, ULONG size) if (pEsMsg->HandleStyle == MES_INCREMENTAL_HANDLE) { unsigned int tmpsize = size; - TRACE("%d from incremental handle\n", size); + TRACE("%ld from incremental handle\n", size); pEsMsg->Read(pEsMsg->UserState, (char **)&pEsMsg->StubMsg.Buffer, &tmpsize); if (tmpsize < size) { - ERR("not enough bytes read - requested %d, got %d\n", size, tmpsize); + ERR("not enough bytes read - requested %ld, got %d\n", size, tmpsize); RpcRaiseException(RPC_S_OUT_OF_MEMORY); } } else { - TRACE("%d from fixed or dynamic buffer handle\n", size); + TRACE("%ld from fixed or dynamic buffer handle\n", size); /* FIXME: validate BufferSize? */ pEsMsg->StubMsg.Buffer = pEsMsg->Buffer; pEsMsg->Buffer += size; @@ -323,12 +324,12 @@ static void es_data_write(MIDL_ES_MESSAGE *pEsMsg, ULONG size) { if (pEsMsg->HandleStyle == MES_INCREMENTAL_HANDLE) { - TRACE("%d to incremental handle\n", size); + TRACE("%ld to incremental handle\n", size); pEsMsg->Write(pEsMsg->UserState, (char *)pEsMsg->StubMsg.BufferStart, size); } else { - TRACE("%d to dynamic or fixed buffer handle\n", size); + TRACE("%ld to dynamic or fixed buffer handle\n", size); *pEsMsg->pEncodedSize += size; } } @@ -386,7 +387,7 @@ static void mes_proc_header_unmarshal(MIDL_ES_MESSAGE *pEsMsg) pEsMsg->ProcNumber = *(DWORD *)pEsMsg->StubMsg.Buffer; pEsMsg->StubMsg.Buffer += 4; if (*(DWORD *)pEsMsg->StubMsg.Buffer != 0x00000001) - FIXME("unknown value 0x%08x, expected 0x00000001\n", *(DWORD *)pEsMsg->StubMsg.Buffer); + FIXME("unknown value 0x%08lx, expected 0x00000001\n", *(DWORD *)pEsMsg->StubMsg.Buffer); pEsMsg->StubMsg.Buffer += 4; pEsMsg->ByteCount = *(DWORD *)pEsMsg->StubMsg.Buffer; pEsMsg->StubMsg.Buffer += 4; @@ -407,7 +408,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu /* header for procedure string */ const NDR_PROC_HEADER *pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0]; const RPC_CLIENT_INTERFACE *client_interface; - __ms_va_list args; + va_list args; unsigned int number_of_params; ULONG_PTR arg_buffer[256]; @@ -416,7 +417,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu /* Later NDR language versions probably won't be backwards compatible */ if (pStubDesc->Version > 0x50002) { - FIXME("Incompatible stub description version: 0x%x\n", pStubDesc->Version); + FIXME("Incompatible stub description version: 0x%lx\n", pStubDesc->Version); RpcRaiseException(RPC_X_WRONG_STUB_VERSION); } @@ -457,7 +458,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu } TRACE("stack size: 0x%x\n", stack_size); - TRACE("proc num: %d\n", pEsMsg->ProcNumber); + TRACE("proc num: %ld\n", pEsMsg->ProcNumber); memset(&rpcMsg, 0, sizeof(rpcMsg)); pEsMsg->StubMsg.RpcMsg = &rpcMsg; @@ -470,13 +471,13 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu pEsMsg->StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_CLIENT); TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags); - TRACE("stubdesc version = 0x%x\n", pStubDesc->Version); - TRACE("MIDL stub version = 0x%x\n", pStubDesc->MIDLVersion); + TRACE("stubdesc version = 0x%lx\n", pStubDesc->Version); + TRACE("MIDL stub version = 0x%lx\n", pStubDesc->MIDLVersion); /* needed for conformance of top-level objects */ - __ms_va_start( args, pFormat ); + va_start( args, pFormat ); pEsMsg->StubMsg.StackTop = va_arg( args, unsigned char * ); - __ms_va_end( args ); + va_end( args ); pFormat = convert_old_args( &pEsMsg->StubMsg, pFormat, stack_size, FALSE, arg_buffer, sizeof(arg_buffer), &number_of_params ); @@ -486,14 +487,14 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu case MES_ENCODE: pEsMsg->StubMsg.BufferLength = mes_proc_header_buffer_size(); - client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_CALCSIZE, NULL, number_of_params, NULL ); + client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_CALCSIZE, FALSE, number_of_params, NULL ); pEsMsg->ByteCount = pEsMsg->StubMsg.BufferLength - mes_proc_header_buffer_size(); es_data_alloc(pEsMsg, pEsMsg->StubMsg.BufferLength); mes_proc_header_marshal(pEsMsg); - client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_MARSHAL, NULL, number_of_params, NULL ); + client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_MARSHAL, FALSE, number_of_params, NULL ); es_data_write(pEsMsg, pEsMsg->ByteCount); break; @@ -502,7 +503,7 @@ void WINAPIV NdrMesProcEncodeDecode(handle_t Handle, const MIDL_STUB_DESC * pStu es_data_read(pEsMsg, pEsMsg->ByteCount); - client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_UNMARSHAL, NULL, number_of_params, NULL ); + client_do_args( &pEsMsg->StubMsg, pFormat, STUBLESS_UNMARSHAL, FALSE, number_of_params, NULL ); break; default: RpcRaiseException(RPC_S_INTERNAL_ERROR); diff --git a/dll/win32/rpcrt4/ndr_fullpointer.c b/dll/win32/rpcrt4/ndr_fullpointer.c index 2bbd2b2b1aa..39e1b18c828 100644 --- a/dll/win32/rpcrt4/ndr_fullpointer.c +++ b/dll/win32/rpcrt4/ndr_fullpointer.c @@ -19,6 +19,7 @@ */ #include +#include #include "windef.h" #include "winbase.h" @@ -33,25 +34,19 @@ PFULL_PTR_XLAT_TABLES WINAPI NdrFullPointerXlatInit(ULONG NumberOfPointers, XLAT_SIDE XlatSide) { ULONG NumberOfBuckets; - PFULL_PTR_XLAT_TABLES pXlatTables = HeapAlloc(GetProcessHeap(), 0, sizeof(*pXlatTables)); + FULL_PTR_XLAT_TABLES *pXlatTables = malloc(sizeof(*pXlatTables)); - TRACE("(%d, %d)\n", NumberOfPointers, XlatSide); + TRACE("(%ld, %d)\n", NumberOfPointers, XlatSide); if (!NumberOfPointers) NumberOfPointers = 512; NumberOfBuckets = ((NumberOfPointers + 3) & ~3) - 1; - pXlatTables->RefIdToPointer.XlatTable = - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(void *) * NumberOfPointers); - pXlatTables->RefIdToPointer.StateTable = - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(unsigned char) * NumberOfPointers); + pXlatTables->RefIdToPointer.XlatTable = calloc(NumberOfPointers, sizeof(void *)); + pXlatTables->RefIdToPointer.StateTable = calloc(NumberOfPointers, sizeof(unsigned char)); pXlatTables->RefIdToPointer.NumberOfEntries = NumberOfPointers; - TRACE("NumberOfBuckets = %d\n", NumberOfBuckets); - pXlatTables->PointerToRefId.XlatTable = - HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(PFULL_PTR_TO_REFID_ELEMENT) * NumberOfBuckets); + TRACE("NumberOfBuckets = %ld\n", NumberOfBuckets); + pXlatTables->PointerToRefId.XlatTable = calloc(NumberOfBuckets, sizeof(FULL_PTR_TO_REFID_ELEMENT *)); pXlatTables->PointerToRefId.NumberOfBuckets = NumberOfBuckets; pXlatTables->PointerToRefId.HashMask = NumberOfBuckets - 1; @@ -75,34 +70,36 @@ void WINAPI NdrFullPointerXlatFree(PFULL_PTR_XLAT_TABLES pXlatTables) XlatTableEntry; ) { PFULL_PTR_TO_REFID_ELEMENT Next = XlatTableEntry->Next; - HeapFree(GetProcessHeap(), 0, XlatTableEntry); + free(XlatTableEntry); XlatTableEntry = Next; } } - HeapFree(GetProcessHeap(), 0, pXlatTables->RefIdToPointer.XlatTable); - HeapFree(GetProcessHeap(), 0, pXlatTables->RefIdToPointer.StateTable); - HeapFree(GetProcessHeap(), 0, pXlatTables->PointerToRefId.XlatTable); + free(pXlatTables->RefIdToPointer.XlatTable); + free(pXlatTables->RefIdToPointer.StateTable); + free(pXlatTables->PointerToRefId.XlatTable); - HeapFree(GetProcessHeap(), 0, pXlatTables); + free(pXlatTables); } static void expand_pointer_table_if_necessary(PFULL_PTR_XLAT_TABLES pXlatTables, ULONG RefId) { if (RefId >= pXlatTables->RefIdToPointer.NumberOfEntries) { - pXlatTables->RefIdToPointer.NumberOfEntries = RefId * 2; pXlatTables->RefIdToPointer.XlatTable = - HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - pXlatTables->RefIdToPointer.XlatTable, - sizeof(void *) * pXlatTables->RefIdToPointer.NumberOfEntries); + realloc(pXlatTables->RefIdToPointer.XlatTable, sizeof(void *) * RefId * 2); pXlatTables->RefIdToPointer.StateTable = - HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - pXlatTables->RefIdToPointer.StateTable, - sizeof(unsigned char) * pXlatTables->RefIdToPointer.NumberOfEntries); - + realloc(pXlatTables->RefIdToPointer.StateTable, RefId * 2); if (!pXlatTables->RefIdToPointer.XlatTable || !pXlatTables->RefIdToPointer.StateTable) + { pXlatTables->RefIdToPointer.NumberOfEntries = 0; + return; + } + memset(pXlatTables->RefIdToPointer.XlatTable + pXlatTables->RefIdToPointer.NumberOfEntries, 0, + (RefId * 2 - pXlatTables->RefIdToPointer.NumberOfEntries) * sizeof(void *)); + memset(pXlatTables->RefIdToPointer.StateTable + pXlatTables->RefIdToPointer.NumberOfEntries, 0, + RefId * 2 - pXlatTables->RefIdToPointer.NumberOfEntries); + pXlatTables->RefIdToPointer.NumberOfEntries = RefId * 2; } } @@ -137,7 +134,7 @@ int WINAPI NdrFullPointerQueryPointer(PFULL_PTR_XLAT_TABLES pXlatTables, return 0; } - XlatTableEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(*XlatTableEntry)); + XlatTableEntry = malloc(sizeof(*XlatTableEntry)); XlatTableEntry->Next = pXlatTables->PointerToRefId.XlatTable[Hash & pXlatTables->PointerToRefId.HashMask]; XlatTableEntry->Pointer = pPointer; XlatTableEntry->RefId = *pRefId = pXlatTables->NextRefId++; @@ -159,7 +156,7 @@ int WINAPI NdrFullPointerQueryRefId(PFULL_PTR_XLAT_TABLES pXlatTables, ULONG RefId, unsigned char QueryType, void **ppPointer) { - TRACE("(%p, 0x%x, %d, %p)\n", pXlatTables, RefId, QueryType, ppPointer); + TRACE("(%p, 0x%lx, %d, %p)\n", pXlatTables, RefId, QueryType, ppPointer); if (!RefId) return 1; @@ -192,13 +189,13 @@ void WINAPI NdrFullPointerInsertRefId(PFULL_PTR_XLAT_TABLES pXlatTables, unsigned int i; PFULL_PTR_TO_REFID_ELEMENT XlatTableEntry; - TRACE("(%p, 0x%x, %p)\n", pXlatTables, RefId, pPointer); + TRACE("(%p, 0x%lx, %p)\n", pXlatTables, RefId, pPointer); /* simple hashing algorithm, don't know whether it matches native */ for (i = 0; i < sizeof(pPointer); i++) Hash = (Hash * 3) ^ ((unsigned char *)&pPointer)[i]; - XlatTableEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(*XlatTableEntry)); + XlatTableEntry = malloc(sizeof(*XlatTableEntry)); XlatTableEntry->Next = pXlatTables->PointerToRefId.XlatTable[Hash & pXlatTables->PointerToRefId.HashMask]; XlatTableEntry->Pointer = pPointer; XlatTableEntry->RefId = RefId; diff --git a/dll/win32/rpcrt4/ndr_marshall.c b/dll/win32/rpcrt4/ndr_marshall.c index 5fdc1dbd106..9ea8390a2d1 100644 --- a/dll/win32/rpcrt4/ndr_marshall.c +++ b/dll/win32/rpcrt4/ndr_marshall.c @@ -33,7 +33,6 @@ #include #include -#define NONAMELESSUNION #include "windef.h" #include "winbase.h" #include "winerror.h" @@ -121,9 +120,9 @@ static inline void align_pointer_offset_clear( unsigned char **ptr, unsigned cha } #define STD_OVERFLOW_CHECK(_Msg) do { \ - TRACE("buffer=%d/%d\n", (ULONG)(_Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer), _Msg->BufferLength); \ + TRACE("buffer=%Id/%ld\n", _Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer, _Msg->BufferLength); \ if (_Msg->Buffer > (unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength) \ - ERR("buffer overflow %d bytes\n", (ULONG)(_Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength))); \ + ERR("buffer overflow %Id bytes\n", _Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength)); \ } while (0) #define NDR_POINTER_ID_BASE 0x20000 @@ -428,7 +427,7 @@ void * WINAPI NdrAllocate(MIDL_STUB_MESSAGE *pStubMsg, SIZE_T len) /* check for overflow */ if (adjusted_len < len) { - ERR("overflow of adjusted_len %ld, len %ld\n", adjusted_len, len); + ERR("overflow of adjusted_len %Id, len %Id\n", adjusted_len, len); RpcRaiseException(RPC_X_BAD_STUB_DATA); } @@ -477,7 +476,7 @@ static PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRIN RpcRaiseException(RPC_X_BAD_STUB_DATA); pStubMsg->MaxCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer); pStubMsg->Buffer += 4; - TRACE("unmarshalled conformance is %ld\n", pStubMsg->MaxCount); + TRACE("unmarshalled conformance is %Id\n", pStubMsg->MaxCount); return SkipConformance(pStubMsg, pFormat); } @@ -495,15 +494,15 @@ static inline PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_S RpcRaiseException(RPC_X_BAD_STUB_DATA); pStubMsg->Offset = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer); pStubMsg->Buffer += 4; - TRACE("offset is %d\n", pStubMsg->Offset); + TRACE("offset is %ld\n", pStubMsg->Offset); pStubMsg->ActualCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer); pStubMsg->Buffer += 4; - TRACE("variance is %d\n", pStubMsg->ActualCount); + TRACE("variance is %ld\n", pStubMsg->ActualCount); if ((pStubMsg->ActualCount > MaxValue) || (pStubMsg->ActualCount + pStubMsg->Offset > MaxValue)) { - ERR("invalid array bound(s): ActualCount = %d, Offset = %d, MaxValue = %d\n", + ERR("invalid array bound(s): ActualCount = %ld, Offset = %ld, MaxValue = %ld\n", pStubMsg->ActualCount, pStubMsg->Offset, MaxValue); RpcRaiseException(RPC_S_INVALID_BOUND); return NULL; @@ -589,7 +588,7 @@ PFORMAT_STRING ComputeConformanceOrVariance( break; case FC_CONSTANT_CONFORMANCE: data = ofs | ((DWORD)pFormat[1] << 16); - TRACE("constant conformance, val=%ld\n", data); + TRACE("constant conformance, val=%Id\n", data); *pCount = data; goto finish_conf; case FC_TOP_LEVEL_MULTID_CONFORMANCE: @@ -661,7 +660,7 @@ PFORMAT_STRING ComputeConformanceOrVariance( FIXME("unknown conformance data type %x\n", dtype); goto done_conf_grab; } - TRACE("dereferenced data type %x at %p, got %ld\n", dtype, ptr, data); + TRACE("dereferenced data type %x at %p, got %Id\n", dtype, ptr, data); done_conf_grab: switch (pFormat[1]) { @@ -687,7 +686,7 @@ done_conf_grab: } finish_conf: - TRACE("resulting conformance is %ld\n", *pCount); + TRACE("resulting conformance is %Id\n", *pCount); return SkipConformance(pStubMsg, pFormat); } @@ -722,7 +721,7 @@ static inline void safe_buffer_length_increment(MIDL_STUB_MESSAGE *pStubMsg, ULO { if (pStubMsg->BufferLength + size < pStubMsg->BufferLength) /* integer overflow of pStubMsg->BufferSize */ { - ERR("buffer length overflow - BufferLength = %u, size = %u\n", + ERR("buffer length overflow - BufferLength = %lu, size = %lu\n", pStubMsg->BufferLength, size); RpcRaiseException(RPC_X_BAD_STUB_DATA); } @@ -736,7 +735,7 @@ static inline void safe_copy_from_buffer(MIDL_STUB_MESSAGE *pStubMsg, void *p, U if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */ (pStubMsg->Buffer + size > pStubMsg->BufferEnd)) { - ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %u\n", + ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %lu\n", pStubMsg->Buffer, pStubMsg->BufferEnd, size); RpcRaiseException(RPC_X_BAD_STUB_DATA); } @@ -752,7 +751,7 @@ static inline void safe_copy_to_buffer(MIDL_STUB_MESSAGE *pStubMsg, const void * if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */ (pStubMsg->Buffer + size > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)) { - ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %u\n", + ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %lu\n", pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength, size); RpcRaiseException(RPC_X_BAD_STUB_DATA); @@ -771,7 +770,7 @@ static void validate_string_data(MIDL_STUB_MESSAGE *pStubMsg, ULONG bufsize, ULO if ((pStubMsg->Buffer + bufsize < pStubMsg->Buffer) || (pStubMsg->Buffer + bufsize > pStubMsg->BufferEnd)) { - ERR("bufsize 0x%x exceeded buffer end %p of buffer %p\n", bufsize, + ERR("bufsize 0x%lx exceeded buffer end %p of buffer %p\n", bufsize, pStubMsg->BufferEnd, pStubMsg->Buffer); RpcRaiseException(RPC_X_BAD_STUB_DATA); } @@ -779,14 +778,14 @@ static void validate_string_data(MIDL_STUB_MESSAGE *pStubMsg, ULONG bufsize, ULO /* strings must always have null terminating bytes */ if (bufsize < esize) { - ERR("invalid string length of %d\n", bufsize / esize); + ERR("invalid string length of %ld\n", bufsize / esize); RpcRaiseException(RPC_S_INVALID_BOUND); } for (i = bufsize - esize; i < bufsize; i++) if (pStubMsg->Buffer[i] != 0) { - ERR("string not null-terminated at byte position %d, data is 0x%x\n", + ERR("string not null-terminated at byte position %ld, data is 0x%x\n", i, pStubMsg->Buffer[i]); RpcRaiseException(RPC_S_INVALID_BOUND); } @@ -843,13 +842,13 @@ static void PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, else pointer_needs_marshaling = FALSE; pointer_id = Pointer ? NDR_POINTER_ID(pStubMsg) : 0; - TRACE("writing 0x%08x to buffer\n", pointer_id); + TRACE("writing 0x%08lx to buffer\n", pointer_id); NDR_LOCAL_UINT32_WRITE(Buffer, pointer_id); break; case FC_FP: pointer_needs_marshaling = !NdrFullPointerQueryPointer( pStubMsg->FullPtrXlatTables, Pointer, 1, &pointer_id); - TRACE("writing 0x%08x to buffer\n", pointer_id); + TRACE("writing 0x%08lx to buffer\n", pointer_id); NDR_LOCAL_UINT32_WRITE(Buffer, pointer_id); break; default: @@ -905,7 +904,7 @@ static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, break; case FC_UP: /* unique pointer */ pointer_id = NDR_LOCAL_UINT32_READ(Buffer); - TRACE("pointer_id is 0x%08x\n", pointer_id); + TRACE("pointer_id is 0x%08lx\n", pointer_id); if (pointer_id) pointer_needs_unmarshaling = TRUE; else { @@ -915,7 +914,7 @@ static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, break; case FC_OP: /* object pointer - we must free data before overwriting it */ pointer_id = NDR_LOCAL_UINT32_READ(Buffer); - TRACE("pointer_id is 0x%08x\n", pointer_id); + TRACE("pointer_id is 0x%08lx\n", pointer_id); /* An object pointer always allocates new memory (it cannot point to the * buffer). */ @@ -933,7 +932,7 @@ static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, break; case FC_FP: pointer_id = NDR_LOCAL_UINT32_READ(Buffer); - TRACE("pointer_id is 0x%08x\n", pointer_id); + TRACE("pointer_id is 0x%08lx\n", pointer_id); pointer_needs_unmarshaling = !NdrFullPointerQueryRefId( pStubMsg->FullPtrXlatTables, pointer_id, 1, (void **)pPointer); break; @@ -1079,7 +1078,7 @@ static ULONG PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, case FC_UP: /* unique pointer */ case FC_OP: /* object pointer - we must free data before overwriting it */ pointer_id = NDR_LOCAL_UINT32_READ(Buffer); - TRACE("pointer_id is 0x%08x\n", pointer_id); + TRACE("pointer_id is 0x%08lx\n", pointer_id); if (pointer_id) pointer_needs_sizing = TRUE; else @@ -1089,7 +1088,7 @@ static ULONG PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, { void *pointer; pointer_id = NDR_LOCAL_UINT32_READ(Buffer); - TRACE("pointer_id is 0x%08x\n", pointer_id); + TRACE("pointer_id is 0x%08lx\n", pointer_id); pointer_needs_sizing = !NdrFullPointerQueryRefId( pStubMsg->FullPtrXlatTables, pointer_id, 1, &pointer); break; @@ -1693,7 +1692,7 @@ void WINAPI NdrSimpleTypeUnmarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* case FC_ERROR_STATUS_T: case FC_ENUM32: BASE_TYPE_UNMARSHALL(ULONG); - TRACE("value: 0x%08x\n", *(ULONG *)pMemory); + TRACE("value: 0x%08lx\n", *(ULONG *)pMemory); break; case FC_FLOAT: BASE_TYPE_UNMARSHALL(float); @@ -1720,14 +1719,14 @@ void WINAPI NdrSimpleTypeUnmarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* /* 32-bits on the wire, but int_ptr in memory */ *(INT_PTR *)pMemory = *(INT *)pStubMsg->Buffer; pStubMsg->Buffer += sizeof(INT); - TRACE("value: 0x%08lx\n", *(INT_PTR *)pMemory); + TRACE("value: 0x%08Ix\n", *(INT_PTR *)pMemory); break; case FC_UINT3264: align_pointer(&pStubMsg->Buffer, sizeof(UINT)); /* 32-bits on the wire, but int_ptr in memory */ *(UINT_PTR *)pMemory = *(UINT *)pStubMsg->Buffer; pStubMsg->Buffer += sizeof(UINT); - TRACE("value: 0x%08lx\n", *(UINT_PTR *)pMemory); + TRACE("value: 0x%08Ix\n", *(UINT_PTR *)pMemory); break; case FC_IGNORE: break; @@ -2225,13 +2224,13 @@ static inline ULONG array_read_variance_and_unmarshall( if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount)) { - ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n", + ERR("buffer size %ld must equal memory size %Id for non-sized conformant strings\n", pStubMsg->ActualCount, pStubMsg->MaxCount); RpcRaiseException(RPC_S_INVALID_BOUND); } if (pStubMsg->Offset) { - ERR("conformant strings can't have Offset (%d)\n", pStubMsg->Offset); + ERR("conformant strings can't have Offset (%ld)\n", pStubMsg->Offset); RpcRaiseException(RPC_S_INVALID_BOUND); } @@ -2356,13 +2355,13 @@ static inline void array_memory_size( if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount)) { - ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n", + ERR("buffer size %ld must equal memory size %Id for non-sized conformant strings\n", pStubMsg->ActualCount, pStubMsg->MaxCount); RpcRaiseException(RPC_S_INVALID_BOUND); } if (pStubMsg->Offset) { - ERR("conformant strings can't have Offset (%d)\n", pStubMsg->Offset); + ERR("conformant strings can't have Offset (%ld)\n", pStubMsg->Offset); RpcRaiseException(RPC_S_INVALID_BOUND); } @@ -2636,7 +2635,7 @@ unsigned char * WINAPI NdrNonConformantStringUnmarshall(PMIDL_STUB_MESSAGE pStu ReadVariance(pStubMsg, NULL, maxsize); if (pStubMsg->Offset) { - ERR("non-conformant strings can't have Offset (%d)\n", pStubMsg->Offset); + ERR("non-conformant strings can't have Offset (%ld)\n", pStubMsg->Offset); RpcRaiseException(RPC_S_INVALID_BOUND); } @@ -2728,7 +2727,7 @@ ULONG WINAPI NdrNonConformantStringMemorySize(PMIDL_STUB_MESSAGE pStubMsg, if (pStubMsg->Offset) { - ERR("non-conformant strings can't have Offset (%d)\n", pStubMsg->Offset); + ERR("non-conformant strings can't have Offset (%ld)\n", pStubMsg->Offset); RpcRaiseException(RPC_S_INVALID_BOUND); } @@ -2869,7 +2868,7 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, case FC_ENUM16: { USHORT val = *(DWORD *)pMemory; - TRACE("enum16=%d <= %p\n", *(DWORD*)pMemory, pMemory); + TRACE("enum16=%ld <= %p\n", *(DWORD*)pMemory, pMemory); if (32767 < *(DWORD*)pMemory) RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE); safe_copy_to_buffer(pStubMsg, &val, 2); @@ -2879,7 +2878,7 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, case FC_LONG: case FC_ULONG: case FC_ENUM32: - TRACE("long=%d <= %p\n", *(DWORD*)pMemory, pMemory); + TRACE("long=%ld <= %p\n", *(DWORD*)pMemory, pMemory); safe_copy_to_buffer(pStubMsg, pMemory, 4); pMemory += 4; break; @@ -2887,7 +2886,7 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, case FC_UINT3264: { UINT val = *(UINT_PTR *)pMemory; - TRACE("int3264=%ld <= %p\n", *(UINT_PTR *)pMemory, pMemory); + TRACE("int3264=%Id <= %p\n", *(UINT_PTR *)pMemory, pMemory); safe_copy_to_buffer(pStubMsg, &val, sizeof(UINT)); pMemory += sizeof(UINT_PTR); break; @@ -2970,7 +2969,7 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, pFormat += 2; desc = pFormat + *(const SHORT*)pFormat; size = EmbeddedComplexSize(pStubMsg, desc); - TRACE("embedded complex (size=%d) <= %p\n", size, pMemory); + TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory); m = NdrMarshaller[*desc & NDR_TABLE_MASK]; if (m) { @@ -3031,7 +3030,7 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, WORD val; safe_copy_from_buffer(pStubMsg, &val, 2); *(DWORD*)pMemory = val; - TRACE("enum16=%d => %p\n", *(DWORD*)pMemory, pMemory); + TRACE("enum16=%ld => %p\n", *(DWORD*)pMemory, pMemory); if (32767 < *(DWORD*)pMemory) RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE); pMemory += 4; @@ -3041,7 +3040,7 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, case FC_ULONG: case FC_ENUM32: safe_copy_from_buffer(pStubMsg, pMemory, 4); - TRACE("long=%d => %p\n", *(DWORD*)pMemory, pMemory); + TRACE("long=%ld => %p\n", *(DWORD*)pMemory, pMemory); pMemory += 4; break; case FC_INT3264: @@ -3049,7 +3048,7 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, INT val; safe_copy_from_buffer(pStubMsg, &val, 4); *(INT_PTR *)pMemory = val; - TRACE("int3264=%ld => %p\n", *(INT_PTR*)pMemory, pMemory); + TRACE("int3264=%Id => %p\n", *(INT_PTR*)pMemory, pMemory); pMemory += sizeof(INT_PTR); break; } @@ -3058,7 +3057,7 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, UINT val; safe_copy_from_buffer(pStubMsg, &val, 4); *(UINT_PTR *)pMemory = val; - TRACE("uint3264=%ld => %p\n", *(UINT_PTR*)pMemory, pMemory); + TRACE("uint3264=%Id => %p\n", *(UINT_PTR*)pMemory, pMemory); pMemory += sizeof(UINT_PTR); break; } @@ -3140,7 +3139,7 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, pFormat += 2; desc = pFormat + *(const SHORT*)pFormat; size = EmbeddedComplexSize(pStubMsg, desc); - TRACE("embedded complex (size=%d) => %p\n", size, pMemory); + TRACE("embedded complex (size=%ld) => %p\n", size, pMemory); if (fMustAlloc) /* we can't pass fMustAlloc=TRUE into the marshaller for this type * since the type is part of the memory block that is encompassed by @@ -3629,7 +3628,7 @@ unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, /* save it for use by embedded pointer code later */ pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength; - TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - pStubMsg->Buffer)); + TRACE("difference = 0x%Ix\n", pStubMsg->PointerBufferMark - pStubMsg->Buffer); pointer_buffer_mark_set = TRUE; /* restore the original buffer length */ @@ -3715,7 +3714,7 @@ unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, /* save it for use by embedded pointer code later */ pStubMsg->PointerBufferMark = pStubMsg->Buffer; - TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - saved_buffer)); + TRACE("difference = 0x%Ix\n", pStubMsg->PointerBufferMark - saved_buffer); pointer_buffer_mark_set = TRUE; /* restore the original buffer */ @@ -3803,7 +3802,7 @@ void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, /* save it for use by embedded pointer code later */ pStubMsg->PointerLength = pStubMsg->BufferLength; pointer_length_set = 1; - TRACE("difference = 0x%x\n", pStubMsg->PointerLength - saved_buffer_length); + TRACE("difference = 0x%lx\n", pStubMsg->PointerLength - saved_buffer_length); /* restore the original buffer length */ pStubMsg->BufferLength = saved_buffer_length; @@ -4186,7 +4185,7 @@ unsigned char * WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, /* save it for use by embedded pointer code later */ pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength; - TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer)); + TRACE("difference = 0x%Ix\n", pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer); pointer_buffer_mark_set = TRUE; /* restore fields */ @@ -4242,7 +4241,7 @@ unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, NdrComplexArrayMemorySize(pStubMsg, pFormat); pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded; - TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - saved_buffer)); + TRACE("difference = 0x%Ix\n", pStubMsg->Buffer - saved_buffer); if (!pStubMsg->PointerBufferMark) { /* save it for use by embedded pointer code later */ @@ -4362,10 +4361,10 @@ void WINAPI NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg, pFormat += 4; pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def); - TRACE("conformance = %ld\n", pStubMsg->MaxCount); + TRACE("conformance = %Id\n", pStubMsg->MaxCount); pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount); - TRACE("variance = %d\n", pStubMsg->ActualCount); + TRACE("variance = %ld\n", pStubMsg->ActualCount); count = pStubMsg->ActualCount; for (i = 0; i < count; i++) @@ -4533,7 +4532,7 @@ void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg, align_length(&pStubMsg->BufferLength, (flags & 0xf) + 1); if (bufsize) { - TRACE("size=%d\n", bufsize); + TRACE("size=%ld\n", bufsize); safe_buffer_length_increment(pStubMsg, bufsize); } else @@ -4612,20 +4611,20 @@ RPC_STATUS RPC_ENTRY NdrGetUserMarshalInfo(ULONG *flags, ULONG level, NDR_USER_M { USER_MARSHAL_CB *umcb = CONTAINING_RECORD(flags, USER_MARSHAL_CB, Flags); - TRACE("(%p,%u,%p)\n", flags, level, umi); + TRACE("(%p,%lu,%p)\n", flags, level, umi); if (level != 1) return RPC_S_INVALID_ARG; - memset(&umi->u1.Level1, 0, sizeof(umi->u1.Level1)); + memset(&umi->Level1, 0, sizeof(umi->Level1)); umi->InformationLevel = level; if (umcb->Signature != USER_MARSHAL_CB_SIGNATURE) return RPC_S_INVALID_ARG; - umi->u1.Level1.pfnAllocate = umcb->pStubMsg->pfnAllocate; - umi->u1.Level1.pfnFree = umcb->pStubMsg->pfnFree; - umi->u1.Level1.pRpcChannelBuffer = umcb->pStubMsg->pRpcChannelBuffer; + umi->Level1.pfnAllocate = umcb->pStubMsg->pfnAllocate; + umi->Level1.pfnFree = umcb->pStubMsg->pfnFree; + umi->Level1.pRpcChannelBuffer = umcb->pStubMsg->pRpcChannelBuffer; switch (umcb->CBType) { @@ -4641,8 +4640,8 @@ RPC_STATUS RPC_ENTRY NdrGetUserMarshalInfo(ULONG *flags, ULONG level, NDR_USER_M umcb->pStubMsg->Buffer > buffer_end) return RPC_X_INVALID_BUFFER; - umi->u1.Level1.Buffer = umcb->pStubMsg->Buffer; - umi->u1.Level1.BufferSize = buffer_end - umcb->pStubMsg->Buffer; + umi->Level1.Buffer = umcb->pStubMsg->Buffer; + umi->Level1.BufferSize = buffer_end - umcb->pStubMsg->Buffer; break; } case USER_MARSHAL_CB_BUFFER_SIZE: @@ -4680,7 +4679,7 @@ void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat ) */ void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, LONG NumberParams ) { - FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %d): stub.\n", + FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n", pStubMsg, pFormat, NumberParams); /* FIXME: since this stub doesn't do any converting, the proper behavior is to raise an exception */ @@ -4739,7 +4738,7 @@ unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, bufsize = safe_multiply(esize, pStubMsg->MaxCount); if (pCStructFormat->memory_size + bufsize < pCStructFormat->memory_size) /* integer overflow */ { - ERR("integer overflow of memory_size %u with bufsize %u\n", + ERR("integer overflow of memory_size %u with bufsize %lu\n", pCStructFormat->memory_size, bufsize); RpcRaiseException(RPC_X_BAD_STUB_DATA); } @@ -4794,7 +4793,7 @@ unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMs bufsize = safe_multiply(esize, pStubMsg->MaxCount); if (pCStructFormat->memory_size + bufsize < pCStructFormat->memory_size) /* integer overflow */ { - ERR("integer overflow of memory_size %u with bufsize %u\n", + ERR("integer overflow of memory_size %u with bufsize %lu\n", pCStructFormat->memory_size, bufsize); RpcRaiseException(RPC_X_BAD_STUB_DATA); } @@ -5706,13 +5705,13 @@ static PFORMAT_STRING get_arm_offset_from_union_arm_selector(PMIDL_STUB_MESSAGE { if(type == 0xffff) { - ERR("no arm for 0x%x and no default case\n", discriminant); + ERR("no arm for 0x%lx and no default case\n", discriminant); RpcRaiseException(RPC_S_INVALID_TAG); return NULL; } if(type == 0) { - TRACE("falling back to empty default case for 0x%x\n", discriminant); + TRACE("falling back to empty default case for 0x%lx\n", discriminant); return NULL; } } @@ -6036,7 +6035,7 @@ unsigned char * WINAPI NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg align_pointer_clear(&pStubMsg->Buffer, increment); switch_value = get_discriminant(switch_type, pMemory); - TRACE("got switch value 0x%x\n", switch_value); + TRACE("got switch value 0x%lx\n", switch_value); NdrBaseTypeMarshall(pStubMsg, pMemory, &switch_type); pMemory += increment; @@ -6067,7 +6066,7 @@ unsigned char * WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubM align_pointer(&pStubMsg->Buffer, increment); switch_value = get_discriminant(switch_type, pStubMsg->Buffer); - TRACE("got switch value 0x%x\n", switch_value); + TRACE("got switch value 0x%lx\n", switch_value); size = *(const unsigned short*)pFormat + increment; if (!fMustAlloc && !*ppMemory) @@ -6109,7 +6108,7 @@ void WINAPI NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, align_length(&pStubMsg->BufferLength, increment); switch_value = get_discriminant(switch_type, pMemory); - TRACE("got switch value 0x%x\n", switch_value); + TRACE("got switch value 0x%lx\n", switch_value); /* Add discriminant size */ NdrBaseTypeBufferSize(pStubMsg, (unsigned char *)&switch_value, &switch_type); @@ -6134,7 +6133,7 @@ ULONG WINAPI NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg, align_pointer(&pStubMsg->Buffer, increment); switch_value = get_discriminant(switch_type, pStubMsg->Buffer); - TRACE("got switch value 0x%x\n", switch_value); + TRACE("got switch value 0x%lx\n", switch_value); pStubMsg->Memory += increment; @@ -6160,7 +6159,7 @@ void WINAPI NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg, pFormat++; switch_value = get_discriminant(switch_type, pMemory); - TRACE("got switch value 0x%x\n", switch_value); + TRACE("got switch value 0x%lx\n", switch_value); pMemory += increment; @@ -6183,7 +6182,7 @@ unsigned char * WINAPI NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStub pFormat++; pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0); - TRACE("got switch value 0x%lx\n", pStubMsg->MaxCount); + TRACE("got switch value 0x%Ix\n", pStubMsg->MaxCount); /* Marshall discriminant */ NdrBaseTypeMarshall(pStubMsg, (unsigned char *)&pStubMsg->MaxCount, &switch_type); @@ -6252,7 +6251,7 @@ unsigned char * WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pSt /* Unmarshall discriminant */ discriminant = unmarshall_discriminant(pStubMsg, &pFormat); - TRACE("unmarshalled discriminant %x\n", discriminant); + TRACE("unmarshalled discriminant %lx\n", discriminant); pFormat += *(const SHORT*)pFormat; @@ -6290,7 +6289,7 @@ void WINAPI NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, pFormat++; pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0); - TRACE("got switch value 0x%lx\n", pStubMsg->MaxCount); + TRACE("got switch value 0x%Ix\n", pStubMsg->MaxCount); /* Add discriminant size */ NdrBaseTypeBufferSize(pStubMsg, (unsigned char *)&pStubMsg->MaxCount, &switch_type); @@ -6308,7 +6307,7 @@ ULONG WINAPI NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg, pFormat++; /* Unmarshall discriminant */ discriminant = unmarshall_discriminant(pStubMsg, &pFormat); - TRACE("unmarshalled discriminant 0x%x\n", discriminant); + TRACE("unmarshalled discriminant 0x%lx\n", discriminant); return union_arm_memory_size(pStubMsg, discriminant, pFormat + *(const SHORT*)pFormat); } @@ -6325,7 +6324,7 @@ void WINAPI NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg, pFormat++; pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0); - TRACE("got switch value 0x%lx\n", pStubMsg->MaxCount); + TRACE("got switch value 0x%Ix\n", pStubMsg->MaxCount); union_arm_free(pStubMsg, pMemory, pStubMsg->MaxCount, pFormat + *(const SHORT*)pFormat); } @@ -6483,7 +6482,7 @@ unsigned char *WINAPI NdrRangeUnmarshall( } base_type = pRange->flags_type & 0xf; - TRACE("base_type = 0x%02x, low_value = %d, high_value = %d\n", + TRACE("base_type = 0x%02x, low_value = %ld, high_value = %ld\n", base_type, pRange->low_value, pRange->high_value); #define RANGE_UNMARSHALL(mem_type, wire_type, format_spec) \ @@ -6537,12 +6536,12 @@ unsigned char *WINAPI NdrRangeUnmarshall( break; case FC_LONG: case FC_ENUM32: - RANGE_UNMARSHALL(LONG, LONG, "%d"); - TRACE("value: 0x%08x\n", **(ULONG **)ppMemory); + RANGE_UNMARSHALL(LONG, LONG, "%ld"); + TRACE("value: 0x%08lx\n", **(ULONG **)ppMemory); break; case FC_ULONG: - RANGE_UNMARSHALL(ULONG, ULONG, "%u"); - TRACE("value: 0x%08x\n", **(ULONG **)ppMemory); + RANGE_UNMARSHALL(ULONG, ULONG, "%lu"); + TRACE("value: 0x%08lx\n", **(ULONG **)ppMemory); break; case FC_ENUM16: RANGE_UNMARSHALL(UINT, USHORT, "%u"); @@ -6647,7 +6646,7 @@ static unsigned char *WINAPI NdrBaseTypeMarshall( case FC_ENUM32: align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONG)); safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONG)); - TRACE("value: 0x%08x\n", *(ULONG *)pMemory); + TRACE("value: 0x%08lx\n", *(ULONG *)pMemory); break; case FC_FLOAT: align_pointer_clear(&pStubMsg->Buffer, sizeof(float)); @@ -6739,7 +6738,7 @@ static unsigned char *WINAPI NdrBaseTypeUnmarshall( case FC_ERROR_STATUS_T: case FC_ENUM32: BASE_TYPE_UNMARSHALL(ULONG); - TRACE("value: 0x%08x\n", **(ULONG **)ppMemory); + TRACE("value: 0x%08lx\n", **(ULONG **)ppMemory); break; case FC_FLOAT: BASE_TYPE_UNMARSHALL(float); @@ -6779,7 +6778,7 @@ static unsigned char *WINAPI NdrBaseTypeUnmarshall( *ppMemory = NdrAllocate(pStubMsg, sizeof(INT_PTR)); safe_copy_from_buffer(pStubMsg, &val, sizeof(INT)); **(INT_PTR **)ppMemory = val; - TRACE("value: 0x%08lx\n", **(INT_PTR **)ppMemory); + TRACE("value: 0x%08Ix\n", **(INT_PTR **)ppMemory); } break; case FC_UINT3264: @@ -6794,7 +6793,7 @@ static unsigned char *WINAPI NdrBaseTypeUnmarshall( *ppMemory = NdrAllocate(pStubMsg, sizeof(UINT_PTR)); safe_copy_from_buffer(pStubMsg, &val, sizeof(UINT)); **(UINT_PTR **)ppMemory = val; - TRACE("value: 0x%08lx\n", **(UINT_PTR **)ppMemory); + TRACE("value: 0x%08Ix\n", **(UINT_PTR **)ppMemory); } break; case FC_IGNORE: @@ -7264,15 +7263,13 @@ NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, */ void WINAPI NdrCorrelationInitialize(PMIDL_STUB_MESSAGE pStubMsg, void *pMemory, ULONG CacheSize, ULONG Flags) { - static int once; - - if (!once++) - FIXME("(%p, %p, %d, 0x%x): semi-stub\n", pStubMsg, pMemory, CacheSize, Flags); + TRACE("(%p, %p, %ld, 0x%lx)\n", pStubMsg, pMemory, CacheSize, Flags); if (pStubMsg->CorrDespIncrement == 0) pStubMsg->CorrDespIncrement = 2; /* size of the normal (non-range) /robust payload */ pStubMsg->fHasNewCorrDesc = TRUE; + pStubMsg->pCorrInfo = pMemory; } /*********************************************************************** @@ -7305,8 +7302,5 @@ void WINAPI NdrCorrelationPass(PMIDL_STUB_MESSAGE pStubMsg) */ void WINAPI NdrCorrelationFree(PMIDL_STUB_MESSAGE pStubMsg) { - static int once; - - if (!once++) - FIXME("(%p): stub\n", pStubMsg); + /* FIXME: free memory */ } diff --git a/dll/win32/rpcrt4/ndr_misc.h b/dll/win32/rpcrt4/ndr_misc.h index 2ca89b1744d..b0150c3a2eb 100644 --- a/dll/win32/rpcrt4/ndr_misc.h +++ b/dll/win32/rpcrt4/ndr_misc.h @@ -32,7 +32,7 @@ struct IPSFactoryBuffer; PFORMAT_STRING ComputeConformanceOrVariance( MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory, - PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount) DECLSPEC_HIDDEN; + PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount); static inline PFORMAT_STRING ComputeConformance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG def) { @@ -56,12 +56,12 @@ typedef void (WINAPI *NDR_BUFFERSIZE)(PMIDL_STUB_MESSAGE, unsigned cha typedef ULONG (WINAPI *NDR_MEMORYSIZE)(PMIDL_STUB_MESSAGE, PFORMAT_STRING); typedef void (WINAPI *NDR_FREE) (PMIDL_STUB_MESSAGE, unsigned char*, PFORMAT_STRING); -extern const NDR_MARSHALL NdrMarshaller[] DECLSPEC_HIDDEN; -extern const NDR_UNMARSHALL NdrUnmarshaller[] DECLSPEC_HIDDEN; -extern const NDR_BUFFERSIZE NdrBufferSizer[] DECLSPEC_HIDDEN; -extern const NDR_MEMORYSIZE NdrMemorySizer[] DECLSPEC_HIDDEN; -extern const NDR_FREE NdrFreer[] DECLSPEC_HIDDEN; +extern const NDR_MARSHALL NdrMarshaller[]; +extern const NDR_UNMARSHALL NdrUnmarshaller[]; +extern const NDR_BUFFERSIZE NdrBufferSizer[]; +extern const NDR_MEMORYSIZE NdrMemorySizer[]; +extern const NDR_FREE NdrFreer[]; -ULONG ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat) DECLSPEC_HIDDEN; +ULONG ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat); #endif /* __WINE_NDR_MISC_H */ diff --git a/dll/win32/rpcrt4/ndr_ole.c b/dll/win32/rpcrt4/ndr_ole.c index c8026c0ff15..aa7ca1ab765 100644 --- a/dll/win32/rpcrt4/ndr_ole.c +++ b/dll/win32/rpcrt4/ndr_ole.c @@ -26,8 +26,6 @@ #include #define COBJMACROS -#define NONAMELESSUNION - #include "windef.h" #include "winbase.h" #include "winerror.h" @@ -44,33 +42,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); -static HMODULE hOLE; - -static HRESULT (WINAPI *COM_GetMarshalSizeMax)(ULONG *,REFIID,LPUNKNOWN,DWORD,LPVOID,DWORD); -static HRESULT (WINAPI *COM_MarshalInterface)(LPSTREAM,REFIID,LPUNKNOWN,DWORD,LPVOID,DWORD); -static HRESULT (WINAPI *COM_UnmarshalInterface)(LPSTREAM,REFIID,LPVOID*); -static HRESULT (WINAPI *COM_ReleaseMarshalData)(LPSTREAM); -static HRESULT (WINAPI *COM_GetClassObject)(REFCLSID,DWORD,COSERVERINFO *,REFIID,LPVOID *); -static HRESULT (WINAPI *COM_GetPSClsid)(REFIID,CLSID *); -static LPVOID (WINAPI *COM_MemAlloc)(ULONG); -static void (WINAPI *COM_MemFree)(LPVOID); - -static HMODULE LoadCOM(void) -{ - if (hOLE) return hOLE; - hOLE = LoadLibraryA("OLE32.DLL"); - if (!hOLE) return 0; - COM_GetMarshalSizeMax = (LPVOID)GetProcAddress(hOLE, "CoGetMarshalSizeMax"); - COM_MarshalInterface = (LPVOID)GetProcAddress(hOLE, "CoMarshalInterface"); - COM_UnmarshalInterface = (LPVOID)GetProcAddress(hOLE, "CoUnmarshalInterface"); - COM_ReleaseMarshalData = (LPVOID)GetProcAddress(hOLE, "CoReleaseMarshalData"); - COM_GetClassObject = (LPVOID)GetProcAddress(hOLE, "CoGetClassObject"); - COM_GetPSClsid = (LPVOID)GetProcAddress(hOLE, "CoGetPSClsid"); - COM_MemAlloc = (LPVOID)GetProcAddress(hOLE, "CoTaskMemAlloc"); - COM_MemFree = (LPVOID)GetProcAddress(hOLE, "CoTaskMemFree"); - return hOLE; -} - /* CoMarshalInterface/CoUnmarshalInterface works on streams, * so implement a simple stream on top of the RPC buffer * (which also implements the MInterfacePointer structure) */ @@ -116,9 +87,9 @@ static ULONG WINAPI RpcStream_Release(LPSTREAM iface) RpcStreamImpl *This = impl_from_IStream(iface); ULONG ref = InterlockedDecrement( &This->RefCount ); if (!ref) { - TRACE("size=%d\n", *This->size); + TRACE("size=%ld\n", *This->size); This->pMsg->Buffer = This->data + *This->size; - HeapFree(GetProcessHeap(),0,This); + free(This); } return ref; } @@ -166,13 +137,13 @@ static HRESULT WINAPI RpcStream_Seek(LPSTREAM iface, RpcStreamImpl *This = impl_from_IStream(iface); switch (origin) { case STREAM_SEEK_SET: - This->pos = move.u.LowPart; + This->pos = move.LowPart; break; case STREAM_SEEK_CUR: - This->pos = This->pos + move.u.LowPart; + This->pos = This->pos + move.LowPart; break; case STREAM_SEEK_END: - This->pos = *This->size + move.u.LowPart; + This->pos = *This->size + move.LowPart; break; default: return STG_E_INVALIDFUNCTION; @@ -188,7 +159,7 @@ static HRESULT WINAPI RpcStream_SetSize(LPSTREAM iface, ULARGE_INTEGER newSize) { RpcStreamImpl *This = impl_from_IStream(iface); - *This->size = newSize.u.LowPart; + *This->size = newSize.LowPart; return S_OK; } @@ -203,7 +174,7 @@ static HRESULT WINAPI RpcStream_CopyTo(IStream *iface, IStream *dest, static HRESULT WINAPI RpcStream_Commit(IStream *iface, DWORD flags) { RpcStreamImpl *This = impl_from_IStream(iface); - FIXME("(%p)->(0x%08x): stub\n", This, flags); + FIXME("(%p)->(0x%08lx): stub\n", This, flags); return E_NOTIMPL; } @@ -267,7 +238,7 @@ static HRESULT RpcStream_Create(PMIDL_STUB_MESSAGE pStubMsg, BOOL init, ULONG *s RpcStreamImpl *This; *stream = NULL; - This = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcStreamImpl)); + This = malloc(sizeof(RpcStreamImpl)); if (!This) return E_OUTOFMEMORY; This->IStream_iface.lpVtbl = &RpcStream_Vtbl; This->RefCount = 1; @@ -276,7 +247,7 @@ static HRESULT RpcStream_Create(PMIDL_STUB_MESSAGE pStubMsg, BOOL init, ULONG *s This->data = pStubMsg->Buffer + sizeof(DWORD); This->pos = 0; if (init) *This->size = 0; - TRACE("init size=%d\n", *This->size); + TRACE("init size=%ld\n", *This->size); if (size) *size = *This->size; *stream = &This->IStream_iface; @@ -313,14 +284,13 @@ unsigned char * WINAPI NdrInterfacePointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat); pStubMsg->MaxCount = 0; - if (!LoadCOM()) return NULL; if (pStubMsg->Buffer + sizeof(DWORD) <= (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) { hr = RpcStream_Create(pStubMsg, TRUE, NULL, &stream); if (hr == S_OK) { if (pMemory) - hr = COM_MarshalInterface(stream, riid, (LPUNKNOWN)pMemory, - pStubMsg->dwDestContext, pStubMsg->pvDestContext, - MSHLFLAGS_NORMAL); + hr = CoMarshalInterface(stream, riid, (IUnknown *)pMemory, + pStubMsg->dwDestContext, pStubMsg->pvDestContext, + MSHLFLAGS_NORMAL); IStream_Release(stream); } @@ -343,7 +313,6 @@ unsigned char * WINAPI NdrInterfacePointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg HRESULT hr; TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc); - if (!LoadCOM()) return NULL; /* Avoid reference leaks for [in, out] pointers. */ if (pStubMsg->IsClient && *unk) @@ -356,7 +325,7 @@ unsigned char * WINAPI NdrInterfacePointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg hr = RpcStream_Create(pStubMsg, FALSE, &size, &stream); if (hr == S_OK) { if (size != 0) - hr = COM_UnmarshalInterface(stream, &IID_NULL, (void **)unk); + hr = CoUnmarshalInterface(stream, &IID_NULL, (void **)unk); IStream_Release(stream); } @@ -378,11 +347,10 @@ void WINAPI NdrInterfacePointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, ULONG size = 0; TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat); - if (!LoadCOM()) return; - COM_GetMarshalSizeMax(&size, riid, (LPUNKNOWN)pMemory, - pStubMsg->dwDestContext, pStubMsg->pvDestContext, - MSHLFLAGS_NORMAL); - TRACE("size=%d\n", size); + CoGetMarshalSizeMax(&size, riid, (IUnknown *)pMemory, + pStubMsg->dwDestContext, pStubMsg->pvDestContext, + MSHLFLAGS_NORMAL); + TRACE("size=%ld\n", size); pStubMsg->BufferLength += sizeof(DWORD) + size; } @@ -422,8 +390,7 @@ void WINAPI NdrInterfacePointerFree(PMIDL_STUB_MESSAGE pStubMsg, */ void * WINAPI NdrOleAllocate(SIZE_T Size) { - if (!LoadCOM()) return NULL; - return COM_MemAlloc(Size); + return CoTaskMemAlloc(Size); } /*********************************************************************** @@ -431,8 +398,7 @@ void * WINAPI NdrOleAllocate(SIZE_T Size) */ void WINAPI NdrOleFree(void *NodeToFree) { - if (!LoadCOM()) return; - COM_MemFree(NodeToFree); + CoTaskMemFree(NodeToFree); } /*********************************************************************** @@ -445,12 +411,10 @@ HRESULT create_proxy(REFIID iid, IUnknown *pUnkOuter, IRpcProxyBuffer **pproxy, IPSFactoryBuffer *psfac; HRESULT r; - if(!LoadCOM()) return E_FAIL; - - r = COM_GetPSClsid( iid, &clsid ); + r = CoGetPSClsid(iid, &clsid); if(FAILED(r)) return r; - r = COM_GetClassObject( &clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void**)&psfac ); + r = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void **)&psfac); if(FAILED(r)) return r; r = IPSFactoryBuffer_CreateProxy(psfac, pUnkOuter, iid, pproxy, ppv); @@ -469,12 +433,10 @@ HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub) IPSFactoryBuffer *psfac; HRESULT r; - if(!LoadCOM()) return E_FAIL; - - r = COM_GetPSClsid( iid, &clsid ); + r = CoGetPSClsid(iid, &clsid); if(FAILED(r)) return r; - r = COM_GetClassObject( &clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void**)&psfac ); + r = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void **)&psfac); if(FAILED(r)) return r; r = IPSFactoryBuffer_CreateStub(psfac, iid, pUnk, ppstub); diff --git a/dll/win32/rpcrt4/ndr_stubless.c b/dll/win32/rpcrt4/ndr_stubless.c index c84d8977c10..0a4ef6873d2 100644 --- a/dll/win32/rpcrt4/ndr_stubless.c +++ b/dll/win32/rpcrt4/ndr_stubless.c @@ -184,7 +184,7 @@ static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat) break; case FC_BOGUS_ARRAY: pFormat = ComputeConformance(pStubMsg, NULL, pFormat + 4, *(const WORD*)&pFormat[2]); - TRACE("conformance = %ld\n", pStubMsg->MaxCount); + TRACE("conformance = %Id\n", pStubMsg->MaxCount); pFormat = ComputeVariance(pStubMsg, NULL, pFormat, pStubMsg->MaxCount); size = ComplexStructSize(pStubMsg, pFormat); size *= pStubMsg->MaxCount; @@ -210,6 +210,12 @@ static DWORD calc_arg_size(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat) pStubMsg->MaxCount = 0; size *= pStubMsg->MaxCount; break; + case FC_NON_ENCAPSULATED_UNION: + { + DWORD offset = *(const WORD *)(pFormat + 6 + pStubMsg->CorrDespIncrement); + size = *(const WORD *)(pFormat + 8 + pStubMsg->CorrDespIncrement + offset); + break; + } default: FIXME("Unhandled type %02x\n", *pFormat); /* fallthrough */ @@ -340,9 +346,9 @@ static handle_t client_get_handle(const MIDL_STUB_MESSAGE *pStubMsg, { ERR("null context handle isn't allowed\n"); RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT); - return NULL; } /* FIXME: should we store this structure in stubMsg.pContext? */ + return NULL; } default: ERR("bad explicit binding handle type (0x%02x)\n", pProcHeader->handle_type); @@ -476,7 +482,7 @@ static size_t basetype_arg_size( unsigned char fc ) } void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum stubless_phase phase, - void **fpu_args, unsigned short number_of_params, unsigned char *pRetVal ) + BOOLEAN fpu_args, unsigned short number_of_params, unsigned char *pRetVal ) { const NDR_PARAM_OIF *params = (const NDR_PARAM_OIF *)pFormat; unsigned int i; @@ -486,7 +492,7 @@ void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum s unsigned char *pArg = pStubMsg->StackTop + params[i].stack_offset; PFORMAT_STRING pTypeFormat = (PFORMAT_STRING)&pStubMsg->StubDesc->pFormatTypes[params[i].u.type_offset]; -#ifdef __x86_64__ /* floats are passed as doubles through varargs functions */ +#ifndef __i386__ /* floats are passed as doubles through varargs functions */ float f; if (params[i].attr.IsBasetype && @@ -698,10 +704,10 @@ static void CALLBACK ndr_client_call_finally(BOOL normal, void *arg) } } -/* Helper for ndr_client_call, to factor out the part that may or may not be +/* Helper for NdrpClientCall2, to factor out the part that may or may not be * guarded by a try/except block. */ -static LONG_PTR do_ndr_client_call( const MIDL_STUB_DESC *stub_desc, const PFORMAT_STRING format, - const PFORMAT_STRING handle_format, void **stack_top, void **fpu_stack, MIDL_STUB_MESSAGE *stub_msg, +static LONG_PTR ndr_client_call( const MIDL_STUB_DESC *stub_desc, const PFORMAT_STRING format, + const PFORMAT_STRING handle_format, void **stack_top, BOOLEAN fpu_args, MIDL_STUB_MESSAGE *stub_msg, unsigned short procedure_number, unsigned short stack_size, unsigned int number_of_params, INTERPRETER_OPT_FLAGS Oif_flags, INTERPRETER_OPT_FLAGS2 ext_flags, const NDR_PROC_HEADER *proc_header ) { @@ -743,10 +749,7 @@ static LONG_PTR do_ndr_client_call( const MIDL_STUB_DESC *stub_desc, const PFORM /* we only need a handle if this isn't an object method */ if (!(proc_header->Oi_flags & Oi_OBJECT_PROC)) - { hbinding = client_get_handle(stub_msg, proc_header, handle_format); - if (!hbinding) return 0; - } stub_msg->BufferLength = 0; @@ -787,13 +790,13 @@ static LONG_PTR do_ndr_client_call( const MIDL_STUB_DESC *stub_desc, const PFORM if (proc_header->Oi_flags & Oi_OBJECT_PROC) { TRACE( "INITOUT\n" ); - client_do_args(stub_msg, format, STUBLESS_INITOUT, fpu_stack, + client_do_args(stub_msg, format, STUBLESS_INITOUT, fpu_args, number_of_params, (unsigned char *)&retval); } /* 2. CALCSIZE */ TRACE( "CALCSIZE\n" ); - client_do_args(stub_msg, format, STUBLESS_CALCSIZE, fpu_stack, + client_do_args(stub_msg, format, STUBLESS_CALCSIZE, fpu_args, number_of_params, (unsigned char *)&retval); /* 3. GETBUFFER */ @@ -813,7 +816,7 @@ static LONG_PTR do_ndr_client_call( const MIDL_STUB_DESC *stub_desc, const PFORM /* 4. MARSHAL */ TRACE( "MARSHAL\n" ); - client_do_args(stub_msg, format, STUBLESS_MARSHAL, fpu_stack, + client_do_args(stub_msg, format, STUBLESS_MARSHAL, fpu_args, number_of_params, (unsigned char *)&retval); /* 5. SENDRECEIVE */ @@ -839,7 +842,7 @@ static LONG_PTR do_ndr_client_call( const MIDL_STUB_DESC *stub_desc, const PFORM /* 6. UNMARSHAL */ TRACE( "UNMARSHAL\n" ); - client_do_args(stub_msg, format, STUBLESS_UNMARSHAL, fpu_stack, + client_do_args(stub_msg, format, STUBLESS_UNMARSHAL, fpu_args, number_of_params, (unsigned char *)&retval); } __FINALLY_CTX(ndr_client_call_finally, &finally_ctx) @@ -847,8 +850,8 @@ static LONG_PTR do_ndr_client_call( const MIDL_STUB_DESC *stub_desc, const PFORM return retval; } -LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, - void **stack_top, void **fpu_stack ) +LONG_PTR WINAPI NdrpClientCall2( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, + void **stack_top, BOOLEAN fpu_args ) { /* pointer to start of stack where arguments start */ MIDL_STUB_MESSAGE stubMsg; @@ -871,7 +874,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc, pFormat); - TRACE("NDR Version: 0x%x\n", pStubDesc->Version); + TRACE("NDR Version: 0x%lx\n", pStubDesc->Version); if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS) { @@ -889,7 +892,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM TRACE("stack size: 0x%x\n", stack_size); TRACE("proc num: %d\n", procedure_number); TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags); - TRACE("MIDL stub version = 0x%x\n", pStubDesc->MIDLVersion); + TRACE("MIDL stub version = 0x%lx\n", pStubDesc->MIDLVersion); pHandleFormat = pFormat; @@ -914,19 +917,6 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM const NDR_PROC_HEADER_EXTS *pExtensions = (const NDR_PROC_HEADER_EXTS *)pFormat; ext_flags = pExtensions->Flags2; pFormat += pExtensions->Size; -#ifdef __x86_64__ - if (pExtensions->Size > sizeof(*pExtensions) && fpu_stack) - { - int i; - unsigned short fpu_mask = *(unsigned short *)(pExtensions + 1); - for (i = 0; i < 4; i++, fpu_mask >>= 2) - switch (fpu_mask & 3) - { - case 1: *(float *)&stack_top[i] = *(float *)&fpu_stack[i]; break; - case 2: *(double *)&stack_top[i] = *(double *)&fpu_stack[i]; break; - } - } -#endif } } else @@ -940,15 +930,16 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM { __TRY { - RetVal = do_ndr_client_call(pStubDesc, pFormat, pHandleFormat, - stack_top, fpu_stack, &stubMsg, procedure_number, stack_size, - number_of_params, Oif_flags, ext_flags, pProcHeader); + RetVal = ndr_client_call(pStubDesc, pFormat, pHandleFormat, + stack_top, fpu_args, &stubMsg, procedure_number, stack_size, + number_of_params, Oif_flags, ext_flags, pProcHeader); } __EXCEPT_ALL { /* 7. FREE */ TRACE( "FREE\n" ); - client_do_args(&stubMsg, pFormat, STUBLESS_FREE, fpu_stack, + stubMsg.StackTop = (unsigned char *)stack_top; + client_do_args(&stubMsg, pFormat, STUBLESS_FREE, fpu_args, number_of_params, (unsigned char *)&RetVal); RetVal = NdrProxyErrorHandler(GetExceptionCode()); } @@ -958,9 +949,9 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM { __TRY { - RetVal = do_ndr_client_call(pStubDesc, pFormat, pHandleFormat, - stack_top, fpu_stack, &stubMsg, procedure_number, stack_size, - number_of_params, Oif_flags, ext_flags, pProcHeader); + RetVal = ndr_client_call(pStubDesc, pFormat, pHandleFormat, + stack_top, fpu_args, &stubMsg, procedure_number, stack_size, + number_of_params, Oif_flags, ext_flags, pProcHeader); } __EXCEPT_ALL { @@ -991,226 +982,163 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORM } else { - RetVal = do_ndr_client_call(pStubDesc, pFormat, pHandleFormat, - stack_top, fpu_stack, &stubMsg, procedure_number, stack_size, - number_of_params, Oif_flags, ext_flags, pProcHeader); + RetVal = ndr_client_call(pStubDesc, pFormat, pHandleFormat, + stack_top, fpu_args, &stubMsg, procedure_number, stack_size, + number_of_params, Oif_flags, ext_flags, pProcHeader); } - TRACE("RetVal = 0x%lx\n", RetVal); + TRACE("RetVal = 0x%Ix\n", RetVal); return RetVal; } -#ifdef __x86_64__ - +#ifdef __aarch64__ +__ASM_GLOBAL_FUNC( NdrClientCall2, + "stp x29, x30, [sp, #-0x40]!\n\t" + ".seh_save_fplr_x 0x40\n\t" + ".seh_endprologue\n\t" + "stp x2, x3, [sp, #0x10]\n\t" + "stp x4, x5, [sp, #0x20]\n\t" + "stp x6, x7, [sp, #0x30]\n\t" + "add x2, sp, #0x10\n\t" /* stack */ + "mov x3, #0\n\t" /* fpu_stack */ + "bl NdrpClientCall2\n\t" + "ldp x29, x30, [sp], #0x40\n\t" + "ret" ) +#elif defined(__arm64ec__) +CLIENT_CALL_RETURN __attribute__((naked)) NdrClientCall2( PMIDL_STUB_DESC desc, PFORMAT_STRING fmt, ... ) +{ + asm( ".seh_proc \"#NdrClientCall2\"\n\t" + "stp x29, x30, [sp, #-0x20]!\n\t" + ".seh_save_fplr_x 0x20\n\t" + ".seh_endprologue\n\t" + "stp x2, x3, [x4, #-0x10]!\n\t" + "mov x2, x4\n\t" /* stack */ + "mov x3, #0\n\t" /* fpu_stack */ + "bl \"#NdrpClientCall2\"\n\t" + "ldp x29, x30, [sp], #0x20\n\t" + "ret\n\t" + ".seh_endproc" ); +} +#elif defined(__arm__) +__ASM_GLOBAL_FUNC( NdrClientCall2, + "push {r2-r3}\n\t" + ".seh_save_regs {r2,r3}\n\t" + "push {fp,lr}\n\t" + ".seh_save_regs_w {fp,lr}\n\t" + ".seh_endprologue\n\t" + "add r2, sp, #8\n\t" /* stack */ + "mov r3, #0\n\t" /* fpu_stack */ + "bl NdrpClientCall2\n\t" + "pop {fp,lr}\n\t" + "add sp, #8\n\t" + "bx lr" ) +#elif defined(__x86_64__) __ASM_GLOBAL_FUNC( NdrClientCall2, - "movq %r8,0x18(%rsp)\n\t" - "movq %r9,0x20(%rsp)\n\t" - "leaq 0x18(%rsp),%r8\n\t" - "xorq %r9,%r9\n\t" "subq $0x28,%rsp\n\t" + __ASM_SEH(".seh_stackalloc 0x28\n\t") + __ASM_SEH(".seh_endprologue\n\t") __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t") - "call " __ASM_NAME("ndr_client_call") "\n\t" + "movq %r8,0x40(%rsp)\n\t" + "movq %r9,0x48(%rsp)\n\t" + "leaq 0x40(%rsp),%r8\n\t" /* stack */ + "xorq %r9,%r9\n\t" /* fpu_stack */ + "call " __ASM_NAME("NdrpClientCall2") "\n\t" "addq $0x28,%rsp\n\t" __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t") - "ret" ); - -#else /* __x86_64__ */ - -/*********************************************************************** - * NdrClientCall2 [RPCRT4.@] - */ -CLIENT_CALL_RETURN WINAPIV NdrClientCall2( PMIDL_STUB_DESC desc, PFORMAT_STRING format, ... ) -{ - __ms_va_list args; - LONG_PTR ret; - - __ms_va_start( args, format ); - ret = ndr_client_call( desc, format, va_arg( args, void ** ), NULL ); - __ms_va_end( args ); - return *(CLIENT_CALL_RETURN *)&ret; -} - -#endif /* __x86_64__ */ - -/* Calls a function with the specified arguments, restoring the stack - * properly afterwards as we don't know the calling convention of the - * function */ -#if defined __i386__ && defined _MSC_VER -__declspec(naked) LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size) -{ - __asm - { - push ebp - mov ebp, esp - push edi ; Save registers - push esi - mov eax, [ebp+16] ; Get stack size - sub esp, eax ; Make room in stack for arguments - and esp, 0xFFFFFFF0 - mov edi, esp - mov ecx, eax - mov esi, [ebp+12] - shr ecx, 2 - cld - rep movsd ; Copy dword blocks - call [ebp+8] ; Call function - lea esp, [ebp-8] ; Restore stack - pop esi ; Restore registers - pop edi - pop ebp - ret - } -} -#elif defined __i386__ && defined __GNUC__ -LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size); -__ASM_GLOBAL_FUNC(call_server_func, - "pushl %ebp\n\t" - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - __ASM_CFI(".cfi_rel_offset %ebp,0\n\t") - "movl %esp,%ebp\n\t" - __ASM_CFI(".cfi_def_cfa_register %ebp\n\t") - "pushl %edi\n\t" /* Save registers */ - __ASM_CFI(".cfi_rel_offset %edi,-4\n\t") - "pushl %esi\n\t" - __ASM_CFI(".cfi_rel_offset %esi,-8\n\t") - "movl 16(%ebp), %eax\n\t" /* Get stack size */ - "subl %eax, %esp\n\t" /* Make room in stack for arguments */ - "andl $~15, %esp\n\t" /* Make sure stack has 16-byte alignment for Mac OS X */ - "movl %esp, %edi\n\t" - "movl %eax, %ecx\n\t" - "movl 12(%ebp), %esi\n\t" - "shrl $2, %ecx\n\t" /* divide by 4 */ - "cld\n\t" - "rep; movsl\n\t" /* Copy dword blocks */ - "call *8(%ebp)\n\t" /* Call function */ - "leal -8(%ebp), %esp\n\t" /* Restore stack */ - "popl %esi\n\t" /* Restore registers */ - __ASM_CFI(".cfi_same_value %esi\n\t") - "popl %edi\n\t" - __ASM_CFI(".cfi_same_value %edi\n\t") - "popl %ebp\n\t" - __ASM_CFI(".cfi_def_cfa %esp,4\n\t") - __ASM_CFI(".cfi_same_value %ebp\n\t") - "ret" ) -#elif defined __x86_64__ -LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size); -__ASM_GLOBAL_FUNC( call_server_func, - "pushq %rbp\n\t" - __ASM_SEH(".seh_pushreg %rbp\n\t") - __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t") - __ASM_CFI(".cfi_rel_offset %rbp,0\n\t") - "movq %rsp,%rbp\n\t" - __ASM_SEH(".seh_setframe %rbp,0\n\t") - __ASM_CFI(".cfi_def_cfa_register %rbp\n\t") - "pushq %rsi\n\t" - __ASM_SEH(".seh_pushreg %rsi\n\t") - __ASM_CFI(".cfi_rel_offset %rsi,-8\n\t") - "pushq %rdi\n\t" - __ASM_SEH(".seh_pushreg %rdi\n\t") - __ASM_SEH(".seh_endprologue\n\t") - __ASM_CFI(".cfi_rel_offset %rdi,-16\n\t") - "movq %rcx,%rax\n\t" /* function to call */ - "movq $32,%rcx\n\t" /* allocate max(32,stack_size) bytes of stack space */ - "cmpq %rcx,%r8\n\t" - "cmovgq %r8,%rcx\n\t" - "subq %rcx,%rsp\n\t" - "andq $~15,%rsp\n\t" - "movq %r8,%rcx\n\t" - "shrq $3,%rcx\n\t" - "movq %rsp,%rdi\n\t" - "movq %rdx,%rsi\n\t" - "rep; movsq\n\t" /* copy arguments */ - "movq 0(%rsp),%rcx\n\t" - "movq 8(%rsp),%rdx\n\t" - "movq 16(%rsp),%r8\n\t" - "movq 24(%rsp),%r9\n\t" - "movq 0(%rsp),%xmm0\n\t" - "movq 8(%rsp),%xmm1\n\t" - "movq 16(%rsp),%xmm2\n\t" - "movq 24(%rsp),%xmm3\n\t" - "callq *%rax\n\t" - "leaq -16(%rbp),%rsp\n\t" /* restore stack */ - "popq %rdi\n\t" - __ASM_CFI(".cfi_same_value %rdi\n\t") - "popq %rsi\n\t" - __ASM_CFI(".cfi_same_value %rsi\n\t") - __ASM_CFI(".cfi_def_cfa_register %rsp\n\t") - "popq %rbp\n\t" - __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") - __ASM_CFI(".cfi_same_value %rbp\n\t") - "ret") -#elif defined __arm__ -LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char *args, unsigned int stack_size); -__ASM_GLOBAL_FUNC( call_server_func, - ".arm\n\t" - "push {r4, r5, LR}\n\t" - "mov r4, r0\n\t" - "mov r5, SP\n\t" - "lsr r3, r2, #2\n\t" - "cmp r3, #0\n\t" - "beq 5f\n\t" - "sub SP, SP, r2\n\t" - "tst r3, #1\n\t" - "subeq SP, SP, #4\n\t" - "1:\tsub r2, r2, #4\n\t" - "ldr r0, [r1, r2]\n\t" - "str r0, [SP, r2]\n\t" - "cmp r2, #0\n\t" - "bgt 1b\n\t" - "cmp r3, #1\n\t" - "bgt 2f\n\t" - "pop {r0}\n\t" - "b 5f\n\t" - "2:\tcmp r3, #2\n\t" - "bgt 3f\n\t" - "pop {r0-r1}\n\t" - "b 5f\n\t" - "3:\tcmp r3, #3\n\t" - "bgt 4f\n\t" - "pop {r0-r2}\n\t" - "b 5f\n\t" - "4:\tpop {r0-r3}\n\t" - "5:\tblx r4\n\t" - "mov SP, r5\n\t" - "pop {r4, r5, PC}" ) -#elif defined __aarch64__ -LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char *args, unsigned int stack_size); -__ASM_GLOBAL_FUNC( call_server_func, - "stp x29, x30, [sp, #-16]!\n\t" - "mov x29, sp\n\t" - "add x3, x2, #15\n\t" - "lsr x3, x3, #4\n\t" - "sub sp, sp, x3, lsl #4\n\t" - "cbz x2, 2f\n" - "1:\tsub x2, x2, #8\n\t" - "ldr x4, [x1, x2]\n\t" - "str x4, [sp, x2]\n\t" - "cbnz x2, 1b\n" - "2:\tmov x8, x0\n\t" - "cbz x3, 3f\n\t" - "ldp x0, x1, [sp], #16\n\t" - "cmp x3, #1\n\t" - "b.le 3f\n\t" - "ldp x2, x3, [sp], #16\n\t" - "cmp x3, #2\n\t" - "b.le 3f\n\t" - "ldp x4, x5, [sp], #16\n\t" - "cmp x3, #3\n\t" - "b.le 3f\n\t" - "ldp x6, x7, [sp], #16\n" - "3:\tblr x8\n\t" - "mov sp, x29\n\t" - "ldp x29, x30, [sp], #16\n\t" "ret" ) -#else -#warning call_server_func not implemented for your architecture -LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned short stack_size) +#elif defined(__i386__) +__ASM_GLOBAL_FUNC( NdrClientCall2, + "pushl %ebp\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + __ASM_CFI(".cfi_rel_offset %ebp,0\n\t") + "movl %esp,%ebp\n\t" + __ASM_CFI(".cfi_def_cfa_register %ebp\n\t") + "push $0\n\t" /* fpu_stack */ + "push 16(%ebp)\n\t" /* stack */ + "push 12(%ebp)\n\t" /* format */ + "push 8(%ebp)\n\t" /* desc */ + "call " __ASM_STDCALL("NdrpClientCall2",16) "\n\t" + "leave\n\t" + __ASM_CFI(".cfi_def_cfa %esp,4\n\t") + __ASM_CFI(".cfi_same_value %ebp\n\t") + "ret" ) +#endif + +#if defined(__aarch64__) || defined(__arm__) +static void **args_regs_to_stack( void **regs, void **fpu_regs, const NDR_PROC_PARTIAL_OIF_HEADER *header ) { - FIXME("Not implemented for your architecture\n"); - return 0; + static const unsigned int nb_gpregs = sizeof(void *); /* 4 gpregs on arm32, 8 on arm64 */ + const NDR_PROC_HEADER_EXTS *ext = (const NDR_PROC_HEADER_EXTS *)(header + 1); + unsigned int i, size, count, pos, params; + unsigned char *data; + void **stack, **args = regs + nb_gpregs; + + if (ext->Size < sizeof(*ext) + 3) return NULL; + data = (unsigned char *)(ext + 1); + params = data[0] + (data[1] << 8); + if (!(stack = malloc( params * sizeof(*stack) ))) return NULL; + size = min( ext->Size - sizeof(*ext) - 3, data[2] ); + data += 3; + for (i = pos = 0; i < size; i++, pos++) + { + if (data[i] < 0x80) continue; + else if (data[i] < 0x80 + nb_gpregs) stack[pos] = regs[data[i] - 0x80]; + else if (data[i] < 0x94) stack[pos] = fpu_regs[data[i] - 0x80 - nb_gpregs]; + else if (data[i] == 0x9d) /* repeat */ + { + if (i + 3 >= size) break; + count = data[i + 2] + (data[i + 3] << 8); + memcpy( &stack[pos], &args[pos + (signed char)data[i + 1]], count * sizeof(*args) ); + pos += count - 1; + i += 3; + } + else if (data[i] < 0xa0) continue; + else stack[pos] = args[pos + (signed char)data[i]]; + } + return stack; } #endif +extern LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size, + const NDR_PROC_PARTIAL_OIF_HEADER *header); + +#ifndef __i386__ +LONG_PTR WINAPI ndr_stubless_client_call( unsigned int index, void **args, void **fpu_regs ) +{ + void **this = args[0]; + const void **vtbl = *this; + const MIDL_STUBLESS_PROXY_INFO *proxy_info = vtbl[-2]; + const unsigned char *format = proxy_info->ProcFormatString + proxy_info->FormatStringOffset[index]; + const NDR_PROC_HEADER *proc = (const NDR_PROC_HEADER *)format; + void **stack_top = args; + LONG_PTR ret; + + if (is_oicf_stubdesc( proxy_info->pStubDesc )) + { + unsigned int hdr_size = (proc->Oi_flags & Oi_HAS_RPCFLAGS) ? sizeof(NDR_PROC_HEADER_RPC) : sizeof(NDR_PROC_HEADER); + const NDR_PROC_PARTIAL_OIF_HEADER *hdr = (const NDR_PROC_PARTIAL_OIF_HEADER *)(format + hdr_size); + + if (hdr->Oi2Flags.HasExtensions) + { + const NDR_PROC_HEADER_EXTS *ext = (const NDR_PROC_HEADER_EXTS *)(hdr + 1); + if (ext->Size > sizeof(*ext)) + { +#ifdef __x86_64__ + unsigned short fpu_mask = *(unsigned short *)(ext + 1); + for (int i = 0; i < 4; i++, fpu_mask >>= 2) if (fpu_mask & 3) args[i] = fpu_regs[i]; +#else + stack_top = args_regs_to_stack( args, fpu_regs, hdr ); +#endif + } + } + } + + ret = NdrpClientCall2( proxy_info->pStubDesc, format, stack_top, TRUE ); + if (stack_top != args) free( stack_top ); + return ret; +} +#endif /* __i386__ */ + static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat, enum stubless_phase phase, unsigned short number_of_params) @@ -1244,7 +1172,7 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg, case STUBLESS_FREE: if (params[i].attr.ServerAllocSize) { - HeapFree(GetProcessHeap(), 0, *(void **)pArg); + free(*(void **)pArg); } else if (param_needs_alloc(params[i].attr) && (!params[i].attr.MustFree || params[i].attr.IsSimpleRef)) @@ -1275,8 +1203,7 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg, break; case STUBLESS_UNMARSHAL: if (params[i].attr.ServerAllocSize) - *(void **)pArg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - params[i].attr.ServerAllocSize * 8); + *(void **)pArg = calloc(params[i].attr.ServerAllocSize, 8); if (params[i].attr.IsIn) call_unmarshaller(pStubMsg, &pArg, ¶ms[i], 0); @@ -1326,6 +1253,7 @@ LONG WINAPI NdrStubCall2( enum stubless_phase phase; /* header for procedure string */ const NDR_PROC_HEADER *pProcHeader; + const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader = NULL; /* location to put retval into */ LONG_PTR *retval_ptr = NULL; /* correlation cache */ @@ -1343,14 +1271,21 @@ LONG WINAPI NdrStubCall2( pFormat = pServerInfo->ProcString + pServerInfo->FmtStringOffset[pRpcMsg->ProcNum]; pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0]; - TRACE("NDR Version: 0x%x\n", pStubDesc->Version); + if (pProcHeader->Oi_flags & Oi_OBJECT_PROC) + NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel); + else + NdrServerInitializeNew(pRpcMsg, &stubMsg, pStubDesc); + + /* create the full pointer translation tables, if requested */ + if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED) + stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_SERVER); if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS) { - const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)&pFormat[0]; + const NDR_PROC_HEADER_RPC *header_rpc = (const NDR_PROC_HEADER_RPC *)pFormat; + pRpcMsg->RpcFlags = header_rpc->rpc_flags; stack_size = header_rpc->stack_size; pFormat += sizeof(NDR_PROC_HEADER_RPC); - } else { @@ -1358,7 +1293,19 @@ LONG WINAPI NdrStubCall2( pFormat += sizeof(NDR_PROC_HEADER); } - TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags); + /* use alternate memory allocation routines */ + if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED) +#if 0 + NdrRpcSsEnableAllocate(&stubMsg); +#else + FIXME("Set RPCSS memory allocation routines\n"); +#endif + + TRACE("version 0x%lx, Oi_flags %02x, stack size %x, format %p\n", + pStubDesc->Version, pProcHeader->Oi_flags, stack_size, pFormat); + + args = calloc(1, stack_size); + stubMsg.StackTop = args; /* used by conformance of top-level objects */ /* binding */ switch (pProcHeader->handle_type) @@ -1368,9 +1315,16 @@ LONG WINAPI NdrStubCall2( switch (*pFormat) /* handle_type */ { case FC_BIND_PRIMITIVE: /* explicit primitive */ - BindingHandleOffset = ((NDR_EHD_PRIMITIVE*)pFormat)->offset; - pFormat += sizeof(NDR_EHD_PRIMITIVE); - break; + { + BindingHandleOffset = ((NDR_EHD_PRIMITIVE*)pFormat)->offset; + const NDR_EHD_PRIMITIVE *pDesc = (const NDR_EHD_PRIMITIVE *)pFormat; + if (pDesc->flag) + **(handle_t **)ARG_FROM_OFFSET(stubMsg.StackTop, pDesc->offset) = pRpcMsg->Handle; + else + *(handle_t *)ARG_FROM_OFFSET(stubMsg.StackTop, pDesc->offset) = pRpcMsg->Handle; + pFormat += sizeof(NDR_EHD_PRIMITIVE); + break; + } case FC_BIND_GENERIC: /* explicit generic */ BindingHandleOffset = ((NDR_EHD_GENERIC*)pFormat)->offset; pFormat += sizeof(NDR_EHD_GENERIC); @@ -1394,32 +1348,6 @@ LONG WINAPI NdrStubCall2( RpcRaiseException(RPC_X_BAD_STUB_DATA); } - if (pProcHeader->Oi_flags & Oi_OBJECT_PROC) - NdrStubInitialize(pRpcMsg, &stubMsg, pStubDesc, pChannel); - else - NdrServerInitializeNew(pRpcMsg, &stubMsg, pStubDesc); - - /* create the full pointer translation tables, if requested */ - if (pProcHeader->Oi_flags & Oi_FULL_PTR_USED) - stubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,XLAT_SERVER); - - /* store the RPC flags away */ - if (pProcHeader->Oi_flags & Oi_HAS_RPCFLAGS) - pRpcMsg->RpcFlags = ((const NDR_PROC_HEADER_RPC *)pProcHeader)->rpc_flags; - - /* use alternate memory allocation routines */ - if (pProcHeader->Oi_flags & Oi_RPCSS_ALLOC_USED) -#if 0 - NdrRpcSsEnableAllocate(&stubMsg); -#else - FIXME("Set RPCSS memory allocation routines\n"); -#endif - - TRACE("allocating memory for stack of size %x\n", stack_size); - - args = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, stack_size); - stubMsg.StackTop = args; /* used by conformance of top-level objects */ - /* add the implicit This pointer as the first arg to the function if we * are calling an object method */ if (pThis) @@ -1431,8 +1359,7 @@ LONG WINAPI NdrStubCall2( if (is_oicf_stubdesc(pStubDesc)) { - const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader = (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat; - + pOIFHeader = (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat; Oif_flags = pOIFHeader->Oi2Flags; number_of_params = pOIFHeader->number_of_params; @@ -1442,9 +1369,9 @@ LONG WINAPI NdrStubCall2( if (Oif_flags.HasExtensions) { - const NDR_PROC_HEADER_EXTS *pExtensions = (const NDR_PROC_HEADER_EXTS *)pFormat; - ext_flags = pExtensions->Flags2; - pFormat += pExtensions->Size; + const NDR_PROC_HEADER_EXTS *extensions = (const NDR_PROC_HEADER_EXTS *)pFormat; + ext_flags = extensions->Flags2; + pFormat += extensions->Size; } if (Oif_flags.HasPipes) @@ -1497,12 +1424,11 @@ LONG WINAPI NdrStubCall2( else func = pServerInfo->DispatchTable[pRpcMsg->ProcNum]; - /* FIXME: what happens with return values that don't fit into a single register on x86? */ - retval = call_server_func(func, args, stack_size); + retval = call_server_func(func, args, stack_size, pOIFHeader); if (retval_ptr) { - TRACE("stub implementation returned 0x%lx\n", retval); + TRACE("stub implementation returned 0x%Ix\n", retval); *retval_ptr = retval; } else @@ -1560,7 +1486,7 @@ LONG WINAPI NdrStubCall2( NdrFullPointerXlatFree(stubMsg.FullPtrXlatTables); /* free server function stack */ - HeapFree(GetProcessHeap(), 0, args); + free(args); return S_OK; } @@ -1620,9 +1546,9 @@ static void do_ndr_async_client_call( const MIDL_STUB_DESC *pStubDesc, PFORMAT_S RPC_STATUS status; /* Later NDR language versions probably won't be backwards compatible */ - if (pStubDesc->Version > 0x50002) + if (pStubDesc->Version > 0x60001) { - FIXME("Incompatible stub description version: 0x%x\n", pStubDesc->Version); + FIXME("Incompatible stub description version: 0x%lx\n", pStubDesc->Version); RpcRaiseException(RPC_X_WRONG_STUB_VERSION); } @@ -1663,7 +1589,7 @@ static void do_ndr_async_client_call( const MIDL_STUB_DESC *pStubDesc, PFORMAT_S NdrClientInitializeNew(pRpcMsg, pStubMsg, pStubDesc, procedure_number); TRACE("Oi_flags = 0x%02x\n", pProcHeader->Oi_flags); - TRACE("MIDL stub version = 0x%x\n", pStubDesc->MIDLVersion); + TRACE("MIDL stub version = 0x%lx\n", pStubDesc->MIDLVersion); /* needed for conformance of top-level objects */ pStubMsg->StackTop = I_RpcAllocate(async_call_data->stack_size); @@ -1746,7 +1672,7 @@ static void do_ndr_async_client_call( const MIDL_STUB_DESC *pStubDesc, PFORMAT_S /* 1. CALCSIZE */ TRACE( "CALCSIZE\n" ); - client_do_args(pStubMsg, pFormat, STUBLESS_CALCSIZE, NULL, async_call_data->number_of_params, NULL); + client_do_args(pStubMsg, pFormat, STUBLESS_CALCSIZE, FALSE, async_call_data->number_of_params, NULL); /* 2. GETBUFFER */ TRACE( "GETBUFFER\n" ); @@ -1771,7 +1697,7 @@ static void do_ndr_async_client_call( const MIDL_STUB_DESC *pStubDesc, PFORMAT_S /* 3. MARSHAL */ TRACE( "MARSHAL\n" ); - client_do_args(pStubMsg, pFormat, STUBLESS_MARSHAL, NULL, async_call_data->number_of_params, NULL); + client_do_args(pStubMsg, pFormat, STUBLESS_MARSHAL, FALSE, async_call_data->number_of_params, NULL); /* 4. SENDRECEIVE */ TRACE( "SEND\n" ); @@ -1798,8 +1724,8 @@ static void do_ndr_async_client_call( const MIDL_STUB_DESC *pStubDesc, PFORMAT_S } } -LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, - void **stack_top ) +LONG_PTR CDECL ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, + void **stack_top ) { LONG_PTR ret = 0; const NDR_PROC_HEADER *pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0]; @@ -1814,7 +1740,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, } __EXCEPT_ALL { - FIXME("exception %x during ndr_async_client_call()\n", GetExceptionCode()); + FIXME("exception %lx during ndr_async_client_call()\n", GetExceptionCode()); ret = GetExceptionCode(); } __ENDTRY @@ -1822,7 +1748,7 @@ LONG_PTR CDECL DECLSPEC_HIDDEN ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, else do_ndr_async_client_call( pStubDesc, pFormat, stack_top); - TRACE("returning %ld\n", ret); + TRACE("returning %Id\n", ret); return ret; } @@ -1883,7 +1809,7 @@ RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply) /* 2. UNMARSHAL */ TRACE( "UNMARSHAL\n" ); client_do_args(pStubMsg, async_call_data->pParamFormat, STUBLESS_UNMARSHAL, - NULL, async_call_data->number_of_params, Reply); + FALSE, async_call_data->number_of_params, Reply); cleanup: if (pStubMsg->fHasNewCorrDesc) @@ -1903,12 +1829,52 @@ cleanup: I_RpcFree(pStubMsg->StackTop); I_RpcFree(async_call_data); - TRACE("-- 0x%x\n", status); + TRACE("-- 0x%lx\n", status); return status; } -#ifdef __x86_64__ - +#ifdef __aarch64__ +__ASM_GLOBAL_FUNC( NdrAsyncClientCall, + "stp x29, x30, [sp, #-0x40]!\n\t" + ".seh_save_fplr_x 0x40\n\t" + ".seh_endprologue\n\t" + "stp x2, x3, [sp, #0x10]\n\t" + "stp x4, x5, [sp, #0x20]\n\t" + "stp x6, x7, [sp, #0x30]\n\t" + "add x2, sp, #0x10\n\t" /* stack */ + "mov x3, #0\n\t" /* fpu_stack */ + "bl ndr_async_client_call\n\t" + "ldp x29, x30, [sp], #0x40\n\t" + "ret" ) +#elif defined(__arm64ec__) +CLIENT_CALL_RETURN __attribute__((naked)) NdrAsyncClientCall( PMIDL_STUB_DESC desc, PFORMAT_STRING fmt, ... ) +{ + asm( ".seh_proc \"#NdrAsyncClientCall\"\n\t" + "stp x29, x30, [sp, #-0x20]!\n\t" + ".seh_save_fplr_x 0x20\n\t" + ".seh_endprologue\n\t" + "stp x2, x3, [x4, #-0x10]!\n\t" + "mov x2, x4\n\t" /* stack */ + "mov x3, #0\n\t" /* fpu_stack */ + "bl \"#ndr_async_client_call\"\n\t" + "ldp x29, x30, [sp], #0x20\n\t" + "ret\n\t" + ".seh_endproc" ); +} +#elif defined(__arm__) +__ASM_GLOBAL_FUNC( NdrAsyncClientCall, + "push {r2-r3}\n\t" + ".seh_save_regs {r2,r3}\n\t" + "push {fp,lr}\n\t" + ".seh_save_regs_w {fp,lr}\n\t" + ".seh_endprologue\n\t" + "add r2, sp, #8\n\t" /* stack */ + "mov r3, #0\n\t" /* fpu_stack */ + "bl ndr_async_client_call\n\t" + "pop {fp,lr}\n\t" + "add sp, #8\n\t" + "bx lr" ) +#elif defined(__x86_64__) __ASM_GLOBAL_FUNC( NdrAsyncClientCall, "subq $0x28,%rsp\n\t" __ASM_SEH(".seh_stackalloc 0x28\n\t") @@ -1916,29 +1882,29 @@ __ASM_GLOBAL_FUNC( NdrAsyncClientCall, __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t") "movq %r8,0x40(%rsp)\n\t" "movq %r9,0x48(%rsp)\n\t" - "leaq 0x40(%rsp),%r8\n\t" + "leaq 0x40(%rsp),%r8\n\t" /* stack */ + "xorq %r9,%r9\n\t" /* fpu_stack */ "call " __ASM_NAME("ndr_async_client_call") "\n\t" "addq $0x28,%rsp\n\t" __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t") - "ret" ); - -#else /* __x86_64__ */ - -/*********************************************************************** - * NdrAsyncClientCall [RPCRT4.@] - */ -CLIENT_CALL_RETURN WINAPIV NdrAsyncClientCall( PMIDL_STUB_DESC desc, PFORMAT_STRING format, ... ) -{ - __ms_va_list args; - LONG_PTR ret; - - __ms_va_start( args, format ); - ret = ndr_async_client_call( desc, format, va_arg( args, void ** )); - __ms_va_end( args ); - return *(CLIENT_CALL_RETURN *)&ret; -} - -#endif /* __x86_64__ */ + "ret" ) +#elif defined(__i386__) +__ASM_GLOBAL_FUNC( NdrAsyncClientCall, + "pushl %ebp\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + __ASM_CFI(".cfi_rel_offset %ebp,0\n\t") + "movl %esp,%ebp\n\t" + __ASM_CFI(".cfi_def_cfa_register %ebp\n\t") + "push $0\n\t" /* fpu_stack */ + "push 16(%ebp)\n\t" /* stack */ + "push 12(%ebp)\n\t" /* format */ + "push 8(%ebp)\n\t" /* desc */ + "call " __ASM_NAME("ndr_async_client_call") "\n\t" + "leave\n\t" + __ASM_CFI(".cfi_def_cfa %esp,4\n\t") + __ASM_CFI(".cfi_same_value %ebp\n\t") + "ret" ) +#endif RPCRTAPI LONG RPC_ENTRY NdrAsyncStubCall(struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, @@ -1957,6 +1923,7 @@ void RPC_ENTRY NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg) unsigned char *args; /* header for procedure string */ const NDR_PROC_HEADER *pProcHeader; + const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader = NULL; struct async_call_data *async_call_data; PRPC_ASYNC_STATE pAsync; RPC_STATUS status; @@ -1969,7 +1936,7 @@ void RPC_ENTRY NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg) pFormat = pServerInfo->ProcString + pServerInfo->FmtStringOffset[pRpcMsg->ProcNum]; pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0]; - TRACE("NDR Version: 0x%x\n", pStubDesc->Version); + TRACE("NDR Version: 0x%lx\n", pStubDesc->Version); async_call_data = I_RpcAllocate(sizeof(*async_call_data) + sizeof(MIDL_STUB_MESSAGE) + sizeof(RPC_MESSAGE)); if (!async_call_data) RpcRaiseException(RPC_X_NO_MEMORY); @@ -2046,7 +2013,7 @@ void RPC_ENTRY NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg) TRACE("allocating memory for stack of size %x\n", async_call_data->stack_size); - args = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, async_call_data->stack_size); + args = calloc(1, async_call_data->stack_size); async_call_data->pStubMsg->StackTop = args; /* used by conformance of top-level objects */ pAsync = I_RpcAllocate(sizeof(*pAsync)); @@ -2064,27 +2031,23 @@ void RPC_ENTRY NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg) if (is_oicf_stubdesc(pStubDesc)) { - const NDR_PROC_PARTIAL_OIF_HEADER *pOIFHeader = (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat; - /* cache of Oif_flags from v2 procedure header */ - INTERPRETER_OPT_FLAGS Oif_flags; - /* cache of extension flags from NDR_PROC_HEADER_EXTS */ INTERPRETER_OPT_FLAGS2 ext_flags = { 0 }; - Oif_flags = pOIFHeader->Oi2Flags; + pOIFHeader = (const NDR_PROC_PARTIAL_OIF_HEADER *)pFormat; async_call_data->number_of_params = pOIFHeader->number_of_params; pFormat += sizeof(NDR_PROC_PARTIAL_OIF_HEADER); - TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(Oif_flags) ); + TRACE("Oif_flags = %s\n", debugstr_INTERPRETER_OPT_FLAGS(pOIFHeader->Oi2Flags) ); - if (Oif_flags.HasExtensions) + if (pOIFHeader->Oi2Flags.HasExtensions) { - const NDR_PROC_HEADER_EXTS *pExtensions = (const NDR_PROC_HEADER_EXTS *)pFormat; - ext_flags = pExtensions->Flags2; - pFormat += pExtensions->Size; + const NDR_PROC_HEADER_EXTS *extensions = (const NDR_PROC_HEADER_EXTS *)pFormat; + ext_flags = extensions->Flags2; + pFormat += extensions->Size; } - if (Oif_flags.HasPipes) + if (pOIFHeader->Oi2Flags.HasPipes) { FIXME("pipes not supported yet\n"); RpcRaiseException(RPC_X_WRONG_STUB_VERSION); /* FIXME: remove when implemented */ @@ -2127,7 +2090,8 @@ void RPC_ENTRY NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg) if (pServerInfo->ThunkTable && pServerInfo->ThunkTable[pRpcMsg->ProcNum]) pServerInfo->ThunkTable[pRpcMsg->ProcNum](async_call_data->pStubMsg); else - call_server_func(pServerInfo->DispatchTable[pRpcMsg->ProcNum], args, async_call_data->stack_size); + call_server_func(pServerInfo->DispatchTable[pRpcMsg->ProcNum], args, async_call_data->stack_size, + pOIFHeader); } RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply) @@ -2149,7 +2113,7 @@ RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply) if (async_call_data->retval_ptr) { - TRACE("stub implementation returned 0x%lx\n", *(LONG_PTR *)Reply); + TRACE("stub implementation returned 0x%Ix\n", *(LONG_PTR *)Reply); *async_call_data->retval_ptr = *(LONG_PTR *)Reply; } else @@ -2164,7 +2128,7 @@ RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply) if (async_call_data->pProcHeader->Oi_flags & Oi_OBJECT_PROC) { ERR("objects not supported\n"); - HeapFree(GetProcessHeap(), 0, async_call_data->pStubMsg->StackTop); + free(async_call_data->pStubMsg->StackTop); I_RpcFree(async_call_data); I_RpcFree(pAsync); RpcRaiseException(RPC_X_BAD_STUB_DATA); @@ -2210,9 +2174,152 @@ RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply) #endif /* free server function stack */ - HeapFree(GetProcessHeap(), 0, async_call_data->pStubMsg->StackTop); + free(async_call_data->pStubMsg->StackTop); I_RpcFree(async_call_data); I_RpcFree(pAsync); return S_OK; } + +static const RPC_SYNTAX_IDENTIFIER ndr_syntax_id = + {{0x8a885d04, 0x1ceb, 0x11c9, {0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60}}, {2, 0}}; + +LONG_PTR CDECL ndr64_client_call( MIDL_STUBLESS_PROXY_INFO *info, + ULONG proc, void *retval, void **stack_top ) +{ + ULONG_PTR i; + + TRACE("info %p, proc %lu, retval %p, stack_top %p\n", info, proc, retval, stack_top); + + for (i = 0; i < info->nCount; ++i) + { + const MIDL_SYNTAX_INFO *syntax_info = &info->pSyntaxInfo[i]; + const RPC_SYNTAX_IDENTIFIER *id = &syntax_info->TransferSyntax; + + TRACE("Found syntax %s, version %u.%u.\n", debugstr_guid(&id->SyntaxGUID), + id->SyntaxVersion.MajorVersion, id->SyntaxVersion.MinorVersion); + if (!memcmp(id, &ndr_syntax_id, sizeof(RPC_SYNTAX_IDENTIFIER))) + { + if (retval) + FIXME("Complex return types are not supported.\n"); + + return NdrpClientCall2( info->pStubDesc, + syntax_info->ProcString + syntax_info->FmtStringOffset[proc], stack_top, FALSE ); + } + } + + FIXME("NDR64 syntax is not supported.\n"); + return 0; +} + +#ifdef __aarch64__ +__ASM_GLOBAL_FUNC( NdrClientCall3, + "stp x29, x30, [sp, #-0x40]!\n\t" + ".seh_save_fplr_x 0x40\n\t" + ".seh_endprologue\n\t" + "str x3, [sp, #0x18]\n\t" + "stp x4, x5, [sp, #0x20]\n\t" + "stp x6, x7, [sp, #0x30]\n\t" + "add x3, sp, #0x18\n\t" /* stack */ + "bl ndr64_client_call\n\t" + "ldp x29, x30, [sp], #0x40\n\t" + "ret" ) +#elif defined(__arm64ec__) +CLIENT_CALL_RETURN __attribute__((naked)) NdrClientCall3( MIDL_STUBLESS_PROXY_INFO *info, ULONG proc, void *retval, ... ) +{ + asm( ".seh_proc \"#NdrClientCall3\"\n\t" + "stp x29, x30, [sp, #-0x20]!\n\t" + ".seh_save_fplr_x 0x20\n\t" + ".seh_endprologue\n\t" + "str x3, [x4, #-0x8]!\n\t" + "mov x3, x4\n\t" /* stack */ + "bl \"#ndr64_client_call\"\n\t" + "ldp x29, x30, [sp], #0x20\n\t" + "ret\n\t" + ".seh_endproc" ); +} +#elif defined(__x86_64__) +__ASM_GLOBAL_FUNC( NdrClientCall3, + "subq $0x28,%rsp\n\t" + __ASM_SEH(".seh_stackalloc 0x28\n\t") + __ASM_SEH(".seh_endprologue\n\t") + __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t") + "movq %r9,0x48(%rsp)\n\t" + "leaq 0x48(%rsp),%r9\n\t" /* stack */ + "call " __ASM_NAME("ndr64_client_call") "\n\t" + "addq $0x28,%rsp\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t") + "ret" ) +#endif + +LONG_PTR CDECL ndr64_async_client_call( MIDL_STUBLESS_PROXY_INFO *info, + ULONG proc, void *retval, void **stack_top, void **fpu_stack ) +{ + ULONG_PTR i; + + TRACE("info %p, proc %lu, retval %p, stack_top %p, fpu_stack %p\n", + info, proc, retval, stack_top, fpu_stack); + + for (i = 0; i < info->nCount; ++i) + { + const MIDL_SYNTAX_INFO *syntax_info = &info->pSyntaxInfo[i]; + const RPC_SYNTAX_IDENTIFIER *id = &syntax_info->TransferSyntax; + + TRACE("Found syntax %s, version %u.%u.\n", debugstr_guid(&id->SyntaxGUID), + id->SyntaxVersion.MajorVersion, id->SyntaxVersion.MinorVersion); + if (!memcmp(id, &ndr_syntax_id, sizeof(RPC_SYNTAX_IDENTIFIER))) + { + if (retval) + FIXME("Complex return types are not supported.\n"); + + return ndr_async_client_call( info->pStubDesc, + syntax_info->ProcString + syntax_info->FmtStringOffset[proc], stack_top ); + } + } + + FIXME("NDR64 syntax is not supported.\n"); + return 0; +} + +#ifdef __aarch64__ +__ASM_GLOBAL_FUNC( Ndr64AsyncClientCall, + "stp x29, x30, [sp, #-0x40]!\n\t" + ".seh_save_fplr_x 0x40\n\t" + ".seh_endprologue\n\t" + "str x3, [sp, #0x18]\n\t" + "stp x4, x5, [sp, #0x20]\n\t" + "stp x6, x7, [sp, #0x30]\n\t" + "add x3, sp, #0x18\n\t" /* stack */ + "mov x4, #0\n\t" /* fpu_stack */ + "bl ndr64_async_client_call\n\t" + "ldp x29, x30, [sp], #0x40\n\t" + "ret" ) +#elif defined(__arm64ec__) +CLIENT_CALL_RETURN __attribute__((naked)) Ndr64AsyncClientCall( MIDL_STUBLESS_PROXY_INFO *info, ULONG proc, void *retval, ... ) +{ + asm( ".seh_proc \"#Ndr64AsyncClientCall\"\n\t" + "stp x29, x30, [sp, #-0x20]!\n\t" + ".seh_save_fplr_x 0x20\n\t" + ".seh_endprologue\n\t" + "str x3, [x4, #-0x8]!\n\t" + "mov x3, x4\n\t" /* stack */ + "mov x4, #0\n\t" /* fpu_stack */ + "bl \"#ndr64_async_client_call\"\n\t" + "ldp x29, x30, [sp], #0x20\n\t" + "ret\n\t" + ".seh_endproc" ); +} +#elif defined(__x86_64__) +__ASM_GLOBAL_FUNC( Ndr64AsyncClientCall, + "subq $0x28,%rsp\n\t" + __ASM_SEH(".seh_stackalloc 0x28\n\t") + __ASM_SEH(".seh_endprologue\n\t") + __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t") + "movq %r9,0x48(%rsp)\n\t" + "leaq 0x48(%rsp),%r9\n\t" /* stack */ + "movq $0,0x20(%rsp)\n\t" /* fpu_stack */ + "call " __ASM_NAME("ndr64_async_client_call") "\n\t" + "addq $0x28,%rsp\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t") + "ret" ) +#endif diff --git a/dll/win32/rpcrt4/ndr_stubless.h b/dll/win32/rpcrt4/ndr_stubless.h index fa2c5e4ee61..e8de77c43c3 100644 --- a/dll/win32/rpcrt4/ndr_stubless.h +++ b/dll/win32/rpcrt4/ndr_stubless.h @@ -255,14 +255,10 @@ enum stubless_phase STUBLESS_FREE }; -LONG_PTR CDECL ndr_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, - void **stack_top, void **fpu_stack ) DECLSPEC_HIDDEN; -LONG_PTR CDECL ndr_async_client_call( PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, - void **stack_top ) DECLSPEC_HIDDEN; void client_do_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, enum stubless_phase phase, - void **fpu_args, unsigned short number_of_params, unsigned char *pRetVal ) DECLSPEC_HIDDEN; + BOOLEAN fpu_args, unsigned short number_of_params, unsigned char *pRetVal ); PFORMAT_STRING convert_old_args( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, unsigned int stack_size, BOOL object_proc, - void *buffer, unsigned int size, unsigned int *count ) DECLSPEC_HIDDEN; -RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply) DECLSPEC_HIDDEN; -RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply) DECLSPEC_HIDDEN; + void *buffer, unsigned int size, unsigned int *count ); +RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply); +RPC_STATUS NdrpCompleteAsyncServerCall(RPC_ASYNC_STATE *pAsync, void *Reply); diff --git a/dll/win32/rpcrt4/ndr_typelib.c b/dll/win32/rpcrt4/ndr_typelib.c index ba4e3398976..545f965afa6 100644 --- a/dll/win32/rpcrt4/ndr_typelib.c +++ b/dll/win32/rpcrt4/ndr_typelib.c @@ -29,7 +29,6 @@ #include "rpcproxy.h" #include "ndrtypes.h" #include "wine/debug.h" -#include "wine/heap.h" #include "cpsf.h" #include "initguid.h" @@ -47,6 +46,7 @@ static size_t write_type_tfs(ITypeInfo *typeinfo, unsigned char *str, do { if ((str)) *((short *)((str) + (len))) = (val); (len) += 2; } while (0) #define WRITE_INT(str, len, val) \ do { if ((str)) *((int *)((str) + (len))) = (val); (len) += 4; } while (0) +#define ROUND_SIZE(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1)) extern const ExtendedProxyFileInfo ndr_types_ProxyFileInfo; @@ -149,17 +149,21 @@ static unsigned char get_basetype(ITypeInfo *typeinfo, TYPEDESC *desc) } } -static unsigned int type_memsize(ITypeInfo *typeinfo, TYPEDESC *desc) +static unsigned int type_memsize(ITypeInfo *typeinfo, TYPEDESC *desc, unsigned int *align_ret) { + unsigned int size, align; + switch (desc->vt) { case VT_I1: case VT_UI1: - return 1; + size = align = 1; + break; case VT_I2: case VT_UI2: case VT_BOOL: - return 2; + size = align = 2; + break; case VT_I4: case VT_UI4: case VT_R4: @@ -167,45 +171,52 @@ static unsigned int type_memsize(ITypeInfo *typeinfo, TYPEDESC *desc) case VT_UINT: case VT_ERROR: case VT_HRESULT: - return 4; + size = align = 4; + break; case VT_I8: case VT_UI8: case VT_R8: case VT_DATE: - return 8; + size = align = 8; + break; case VT_BSTR: case VT_SAFEARRAY: case VT_PTR: case VT_UNKNOWN: case VT_DISPATCH: - return sizeof(void *); + size = align = sizeof(void *); + break; case VT_VARIANT: - return sizeof(VARIANT); + align = 8; + size = sizeof(VARIANT); + break; case VT_CARRAY: { - unsigned int size = type_memsize(typeinfo, &desc->lpadesc->tdescElem); unsigned int i; + size = type_memsize(typeinfo, &desc->lpadesc->tdescElem, &align); for (i = 0; i < desc->lpadesc->cDims; i++) size *= desc->lpadesc->rgbounds[i].cElements; - return size; + break; } case VT_USERDEFINED: { - unsigned int size = 0; ITypeInfo *refinfo; TYPEATTR *attr; ITypeInfo_GetRefTypeInfo(typeinfo, desc->hreftype, &refinfo); ITypeInfo_GetTypeAttr(refinfo, &attr); size = attr->cbSizeInstance; + align = attr->cbAlignment; ITypeInfo_ReleaseTypeAttr(refinfo, attr); ITypeInfo_Release(refinfo); - return size; + break; } default: FIXME("unhandled type %u\n", desc->vt); return 0; } + if (align_ret) *align_ret = align; + return size; } static BOOL type_pointer_is_iface(ITypeInfo *typeinfo, TYPEDESC *tdesc) @@ -404,16 +415,9 @@ static void write_struct_members(ITypeInfo *typeinfo, unsigned char *str, ITypeInfo_GetVarDesc(typeinfo, i, &desc); tdesc = &desc->elemdescVar.tdesc; - /* This may not match the intended alignment, but we don't have enough - * information to determine that. This should always give the correct - * layout. */ - if ((struct_offset & 7) && !(desc->oInst & 7)) - WRITE_CHAR(str, *len, FC_ALIGNM8); - else if ((struct_offset & 3) && !(desc->oInst & 3)) - WRITE_CHAR(str, *len, FC_ALIGNM4); - else if ((struct_offset & 1) && !(desc->oInst & 1)) - WRITE_CHAR(str, *len, FC_ALIGNM2); - struct_offset = desc->oInst + type_memsize(typeinfo, tdesc); + if (struct_offset != desc->oInst) + WRITE_CHAR(str, *len, FC_STRUCTPAD1 + desc->oInst - struct_offset - 1); + struct_offset = desc->oInst + type_memsize(typeinfo, tdesc, NULL); if ((basetype = get_basetype(typeinfo, tdesc))) WRITE_CHAR(str, *len, basetype); @@ -574,7 +578,7 @@ static void write_complex_struct_tfs(ITypeInfo *typeinfo, unsigned char *str, if (struct_offset != desc->oInst) member_layout++; /* alignment directive */ - struct_offset = desc->oInst + type_memsize(typeinfo, tdesc); + struct_offset = desc->oInst + type_memsize(typeinfo, tdesc, NULL); if (get_basetype(typeinfo, tdesc)) member_layout++; @@ -644,11 +648,13 @@ static size_t write_array_tfs(ITypeInfo *typeinfo, unsigned char *str, { WRITE_SHORT(str, *len, size); WRITE_INT(str, *len, 0xffffffff); /* conformance */ + WRITE_SHORT(str, *len, 0); WRITE_INT(str, *len, 0xffffffff); /* variance */ + WRITE_SHORT(str, *len, 0); } else { - size *= type_memsize(typeinfo, &desc->tdescElem); + size *= type_memsize(typeinfo, &desc->tdescElem, NULL); WRITE_INT(str, *len, size); } @@ -790,9 +796,7 @@ static size_t write_type_tfs(ITypeInfo *typeinfo, unsigned char *str, ITypeInfo *refinfo; TYPEATTR *attr; size_t off; -#ifdef __REACTOS__ GUID guid; -#endif TRACE("vt %d%s\n", desc->vt, toplevel ? " (toplevel)" : ""); @@ -814,7 +818,6 @@ static size_t write_type_tfs(ITypeInfo *typeinfo, unsigned char *str, case TKIND_RECORD: off = write_struct_tfs(refinfo, str, len, attr); break; -#ifdef __REACTOS__ case TKIND_INTERFACE: case TKIND_DISPATCH: /* These are treated as if they were interface pointers. */ @@ -826,13 +829,6 @@ static size_t write_type_tfs(ITypeInfo *typeinfo, unsigned char *str, get_default_iface(refinfo, attr->cImplTypes, &guid); write_ip_tfs(str, len, &guid); break; -#else - case TKIND_INTERFACE: - case TKIND_DISPATCH: - case TKIND_COCLASS: - assert(0); - break; -#endif case TKIND_ALIAS: off = write_type_tfs(refinfo, str, len, &attr->tdescAlias, toplevel, onstack); break; @@ -858,15 +854,52 @@ static size_t write_type_tfs(ITypeInfo *typeinfo, unsigned char *str, return off; } -static unsigned short get_stack_size(ITypeInfo *typeinfo, TYPEDESC *desc) +static unsigned int get_stack_size(ITypeInfo *typeinfo, TYPEDESC *desc, unsigned int *align, int *by_value) { -#if defined(__i386__) || defined(__arm__) - if (desc->vt == VT_CARRAY) - return sizeof(void *); - return (type_memsize(typeinfo, desc) + 3) & ~3; -#else - return sizeof(void *); + unsigned int size = *align = sizeof(void *); + int byval = 1; + + switch (desc->vt) + { + case VT_R8: + case VT_I8: + case VT_UI8: + case VT_DATE: +#ifdef __arm__ + case VT_R4: + *align = 8; #endif + size = 8; + break; + case VT_PTR: + case VT_UNKNOWN: + case VT_DISPATCH: + case VT_CARRAY: + byval = 0; + break; + case VT_VARIANT: + case VT_USERDEFINED: + size = type_memsize(typeinfo, desc, align); + break; + default: + break; + } + +#ifdef __i386__ + *align = sizeof(void *); +#endif + if (byval) + { +#ifdef __x86_64__ + byval = (size == 1 || size == 2 || size == 4 || size == 8); +#elif defined __aarch64__ + byval = (size <= 16); +#endif + } + if (!byval) size = *align = sizeof(void *); + else if (*align < sizeof(void *)) *align = sizeof(void *); + if (by_value) *by_value = byval; + return ROUND_SIZE( size, *align ); } static const unsigned short MustSize = 0x0001; @@ -906,7 +939,7 @@ static HRESULT get_param_pointer_info(ITypeInfo *typeinfo, TYPEDESC *tdesc, int break; case VT_CARRAY: *flags |= IsSimpleRef | MustFree; - *server_size = type_memsize(typeinfo, tdesc); + *server_size = type_memsize(typeinfo, tdesc, NULL); *tfs_tdesc = tdesc; break; case VT_USERDEFINED: @@ -949,9 +982,11 @@ static HRESULT get_param_pointer_info(ITypeInfo *typeinfo, TYPEDESC *tdesc, int *flags |= IsSimpleRef; *tfs_tdesc = tdesc; if (!is_in && is_out) - *server_size = type_memsize(typeinfo, tdesc); + *server_size = type_memsize(typeinfo, tdesc, NULL); if ((*basetype = get_basetype(typeinfo, tdesc))) *flags |= IsBasetype; + else + *flags |= MustFree; break; } @@ -959,7 +994,7 @@ static HRESULT get_param_pointer_info(ITypeInfo *typeinfo, TYPEDESC *tdesc, int } static HRESULT get_param_info(ITypeInfo *typeinfo, TYPEDESC *tdesc, int is_in, - int is_out, unsigned short *server_size, unsigned short *flags, + int is_out, int by_val, unsigned short *server_size, unsigned short *flags, unsigned char *basetype, TYPEDESC **tfs_tdesc) { ITypeInfo *refinfo; @@ -976,15 +1011,10 @@ static HRESULT get_param_info(ITypeInfo *typeinfo, TYPEDESC *tdesc, int is_in, switch (tdesc->vt) { case VT_VARIANT: -#if !defined(__i386__) && !defined(__arm__) - *flags |= IsSimpleRef | MustFree; - break; -#endif - /* otherwise fall through */ case VT_BSTR: case VT_SAFEARRAY: case VT_CY: - *flags |= IsByValue | MustFree; + *flags |= (by_val ? IsByValue : IsSimpleRef) | MustFree; break; case VT_UNKNOWN: case VT_DISPATCH: @@ -1005,27 +1035,20 @@ static HRESULT get_param_info(ITypeInfo *typeinfo, TYPEDESC *tdesc, int is_in, *basetype = FC_ENUM32; break; case TKIND_RECORD: -#if defined(__i386__) || defined(__arm__) - *flags |= IsByValue | MustFree; -#else - if (attr->cbSizeInstance <= 8) - *flags |= IsByValue | MustFree; - else - *flags |= IsSimpleRef | MustFree; -#endif + *flags |= (by_val ? IsByValue : IsSimpleRef) | MustFree; break; case TKIND_ALIAS: - hr = get_param_info(refinfo, &attr->tdescAlias, is_in, is_out, + hr = get_param_info(refinfo, &attr->tdescAlias, is_in, is_out, 0, server_size, flags, basetype, tfs_tdesc); break; -#ifdef __REACTOS__ + case TKIND_INTERFACE: case TKIND_DISPATCH: case TKIND_COCLASS: /* These are treated as if they were interface pointers. */ *flags |= MustFree; break; -#endif + default: FIXME("unhandled kind %#x\n", attr->typekind); hr = E_NOTIMPL; @@ -1056,7 +1079,8 @@ static HRESULT write_param_fs(ITypeInfo *typeinfo, unsigned char *type, USHORT param_flags = desc->paramdesc.wParamFlags; TYPEDESC *tdesc = &desc->tdesc, *tfs_tdesc; unsigned short server_size; - unsigned short stack_size = get_stack_size(typeinfo, tdesc); + int byval; + unsigned int align, stack_size = get_stack_size(typeinfo, tdesc, &align, &byval); unsigned char basetype; unsigned short flags; int is_in, is_out; @@ -1066,7 +1090,7 @@ static HRESULT write_param_fs(ITypeInfo *typeinfo, unsigned char *type, is_out = param_flags & PARAMFLAG_FOUT; is_in = (param_flags & PARAMFLAG_FIN) || (!is_out && !is_return); - hr = get_param_info(typeinfo, tdesc, is_in, is_out, &server_size, &flags, + hr = get_param_info(typeinfo, tdesc, is_in, is_out, byval, &server_size, &flags, &basetype, &tfs_tdesc); if (is_in) flags |= IsIn; @@ -1082,6 +1106,8 @@ static HRESULT write_param_fs(ITypeInfo *typeinfo, unsigned char *type, if (SUCCEEDED(hr)) { + *stack_offset = ROUND_SIZE( *stack_offset, align ); + WRITE_SHORT(proc, *proclen, flags); WRITE_SHORT(proc, *proclen, *stack_offset); WRITE_SHORT(proc, *proclen, basetype ? basetype : off); @@ -1092,46 +1118,188 @@ static HRESULT write_param_fs(ITypeInfo *typeinfo, unsigned char *type, return hr; } +#if defined __arm__ || defined __aarch64__ + +/* replace consecutive params code by a repeat sequence: 0x9d code<1> repeat_count<2> */ +static unsigned int compress_params_array( unsigned char *params, unsigned int count ) +{ + unsigned int i, j; + + for (i = 0; i + 4 <= count; i++) + { + for (j = 1; i + j < count; j++) if (params[i + j] != params[i]) break; + if (j < 4) continue; + params[i] = 0x9d; + params[i + 2] = j & 0xff; + params[i + 3] = j >> 8; + memmove( params + i + 4, params + i + j, count - (i + j) ); + count -= j - 4; + i += 3; + } + return count; +} + +/* fill the parameters array for the procedure extra data on ARM platforms */ +static unsigned int fill_params_array( ITypeInfo *typeinfo, FUNCDESC *desc, + unsigned char *params, unsigned int count ) +{ + static const unsigned int pointer_size = sizeof(void *); + unsigned int reg_count = 0, float_count = 0, double_count = 0, stack_pos = 0, offset = 0; + unsigned int i, size, pos, align; + + memset( params, 0x9f /* padding */, count ); + + /* This pointer */ + params[0] = 0x80 + reg_count++; + offset += pointer_size; + + for (i = 0; i < desc->cParams; i++) + { + unsigned char basetype = get_basetype( typeinfo, &desc->lprgelemdescParam[i].tdesc ); + + size = get_stack_size( typeinfo, &desc->lprgelemdescParam[i].tdesc, &align, NULL ); + offset = ROUND_SIZE( offset, align ); + pos = offset / pointer_size; + +#ifdef __aarch64__ + switch (basetype) + { + case FC_FLOAT: + case FC_DOUBLE: + if (double_count >= 8) break; + params[pos] = 0x88 + double_count++; + offset += size; + continue; + + default: + reg_count = ROUND_SIZE( reg_count, align / pointer_size ); + if (reg_count > 8 - size / pointer_size) break; + while (size) + { + params[pos++] = 0x80 + reg_count++; + offset += pointer_size; + size -= pointer_size; + } + continue; + } + (void)float_count; /* unused on arm64 */ +#else + switch (basetype) + { + case FC_FLOAT: + if (!(float_count % 2)) float_count = max( float_count, double_count * 2 ); + if (float_count >= 16) + { + stack_pos = ROUND_SIZE( stack_pos, align ); + params[pos] = 0x100 - (offset - stack_pos) / pointer_size; + stack_pos += size; + } + else + { + params[pos] = 0x84 + float_count++; + } + offset += size; + continue; + + case FC_DOUBLE: + double_count = max( double_count, (float_count + 1) / 2 ); + if (double_count >= 8) break; + params[pos] = 0x84 + 2 * double_count; + params[pos + 1] = 0x84 + 2 * double_count + 1; + double_count++; + offset += size; + continue; + + default: + reg_count = ROUND_SIZE( reg_count, align / pointer_size ); + if (reg_count <= 4 - size / pointer_size || !stack_pos) + { + while (size && reg_count < 4) + { + params[pos++] = 0x80 + reg_count++; + offset += pointer_size; + size -= pointer_size; + } + } + break; + } +#endif + stack_pos = ROUND_SIZE( stack_pos, align ); + memset( params + pos, 0x100 - (offset - stack_pos) / pointer_size, size / pointer_size ); + stack_pos += size; + offset += size; + } + + while (count && params[count - 1] == 0x9f) count--; + return count; +} + +#endif /* __arm__ || __aarch64__ */ + static void write_proc_func_header(ITypeInfo *typeinfo, FUNCDESC *desc, WORD proc_idx, unsigned char *proc, size_t *proclen) { - unsigned short stack_size = 2 * sizeof(void *); /* This + return */ -#ifdef __x86_64__ - unsigned short float_mask = 0; - unsigned char basetype; -#endif - WORD param_idx; + unsigned int i, align, size, stack_size = sizeof(void *); /* This */ + + for (i = 0; i < desc->cParams; i++) + { + size = get_stack_size(typeinfo, &desc->lprgelemdescParam[i].tdesc, &align, NULL ); + stack_size = ROUND_SIZE( stack_size, align ); + stack_size += size; + } + stack_size += sizeof(void *); /* return */ WRITE_CHAR (proc, *proclen, FC_AUTO_HANDLE); WRITE_CHAR (proc, *proclen, Oi_OBJECT_PROC | Oi_OBJ_USE_V2_INTERPRETER); WRITE_SHORT(proc, *proclen, proc_idx); - for (param_idx = 0; param_idx < desc->cParams; param_idx++) - stack_size += get_stack_size(typeinfo, &desc->lprgelemdescParam[param_idx].tdesc); WRITE_SHORT(proc, *proclen, stack_size); WRITE_SHORT(proc, *proclen, 0); /* constant_client_buffer_size */ WRITE_SHORT(proc, *proclen, 0); /* constant_server_buffer_size */ -#ifdef __x86_64__ WRITE_CHAR (proc, *proclen, 0x47); /* HasExtensions | HasReturn | ClientMustSize | ServerMustSize */ -#else - WRITE_CHAR (proc, *proclen, 0x07); /* HasReturn | ClientMustSize | ServerMustSize */ -#endif WRITE_CHAR (proc, *proclen, desc->cParams + 1); /* incl. return value */ -#ifdef __x86_64__ - WRITE_CHAR (proc, *proclen, 10); /* extension size */ - WRITE_CHAR (proc, *proclen, 0); /* INTERPRETER_OPT_FLAGS2 */ + +#ifdef __i386__ + WRITE_CHAR (proc, *proclen, 8); /* extension size */ + WRITE_CHAR (proc, *proclen, 1); /* HasNewCorrDesc */ WRITE_SHORT(proc, *proclen, 0); /* ClientCorrHint */ WRITE_SHORT(proc, *proclen, 0); /* ServerCorrHint */ WRITE_SHORT(proc, *proclen, 0); /* NotifyIndex */ - for (param_idx = 0; param_idx < desc->cParams && param_idx < 3; param_idx++) +#elif defined __x86_64__ { - basetype = get_basetype(typeinfo, &desc->lprgelemdescParam[param_idx].tdesc); - if (basetype == FC_FLOAT) - float_mask |= (1 << ((param_idx + 1) * 2)); - else if (basetype == FC_DOUBLE) - float_mask |= (2 << ((param_idx + 1) * 2)); + unsigned short float_mask = 0; + + for (i = 0; i < desc->cParams && i < 3; i++) + { + unsigned char basetype = get_basetype(typeinfo, &desc->lprgelemdescParam[i].tdesc); + if (basetype == FC_FLOAT) float_mask |= (1 << ((i + 1) * 2)); + else if (basetype == FC_DOUBLE) float_mask |= (2 << ((i + 1) * 2)); + } + WRITE_CHAR (proc, *proclen, 10); /* extension size */ + WRITE_CHAR (proc, *proclen, 1); /* HasNewCorrDesc */ + WRITE_SHORT(proc, *proclen, 0); /* ClientCorrHint */ + WRITE_SHORT(proc, *proclen, 0); /* ServerCorrHint */ + WRITE_SHORT(proc, *proclen, 0); /* NotifyIndex */ + WRITE_SHORT(proc, *proclen, float_mask); + } +#else + { + unsigned int len, count = stack_size / sizeof(void *); + unsigned char *params = malloc( count ); + + count = fill_params_array( typeinfo, desc, params, count ); + len = compress_params_array( params, count ); + WRITE_CHAR (proc, *proclen, 8 + 3 + len + !(len % 2) ); /* extension size */ + WRITE_CHAR (proc, *proclen, 1); /* HasNewCorrDesc */ + WRITE_SHORT(proc, *proclen, 0); /* ClientCorrHint */ + WRITE_SHORT(proc, *proclen, 0); /* ServerCorrHint */ + WRITE_SHORT(proc, *proclen, 0); /* NotifyIndex */ + WRITE_SHORT(proc, *proclen, count); + WRITE_CHAR (proc, *proclen, len); + for (i = 0; i < len; i++) WRITE_CHAR (proc, *proclen, params[i]); + if (!(len % 2)) WRITE_CHAR (proc, *proclen, 0); + free( params ); } - WRITE_SHORT(proc, *proclen, float_mask); #endif } @@ -1198,9 +1366,9 @@ static HRESULT build_format_strings(ITypeInfo *typeinfo, WORD funcs, hr = write_iface_fs(typeinfo, funcs, parentfuncs, NULL, &typelen, NULL, &proclen, NULL); if (FAILED(hr)) return hr; - type = heap_alloc(typelen); - proc = heap_alloc(proclen); - offset = heap_alloc((parentfuncs + funcs - 3) * sizeof(*offset)); + type = malloc(typelen); + proc = malloc(proclen); + offset = malloc((parentfuncs + funcs - 3) * sizeof(*offset)); if (!type || !proc || !offset) { ERR("Failed to allocate format strings.\n"); @@ -1222,17 +1390,17 @@ static HRESULT build_format_strings(ITypeInfo *typeinfo, WORD funcs, } err: - heap_free(type); - heap_free(proc); - heap_free(offset); + free(type); + free(proc); + free(offset); return hr; } /* Common helper for Create{Proxy,Stub}FromTypeInfo(). */ -static HRESULT get_iface_info(ITypeInfo **typeinfo, WORD *funcs, WORD *parentfuncs, - GUID *parentiid) +static HRESULT get_iface_info(ITypeInfo *typeinfo, WORD *funcs, WORD *parentfuncs, + GUID *parentiid, ITypeInfo **real_typeinfo) { - ITypeInfo *real_typeinfo, *parentinfo; + ITypeInfo *parentinfo; TYPEATTR *typeattr; ITypeLib *typelib; TLIBATTR *libattr; @@ -1244,59 +1412,64 @@ static HRESULT get_iface_info(ITypeInfo **typeinfo, WORD *funcs, WORD *parentfun /* Dual interfaces report their size to be sizeof(IDispatchVtbl) and their * implemented type to be IDispatch. We need to retrieve the underlying * interface to get that information. */ - hr = ITypeInfo_GetTypeAttr(*typeinfo, &typeattr); + hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr); if (FAILED(hr)) return hr; typekind = typeattr->typekind; - ITypeInfo_ReleaseTypeAttr(*typeinfo, typeattr); + ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr); if (typekind == TKIND_DISPATCH) { - hr = ITypeInfo_GetRefTypeOfImplType(*typeinfo, -1, &reftype); + hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, -1, &reftype); if (FAILED(hr)) return hr; - hr = ITypeInfo_GetRefTypeInfo(*typeinfo, reftype, &real_typeinfo); + hr = ITypeInfo_GetRefTypeInfo(typeinfo, reftype, real_typeinfo); if (FAILED(hr)) return hr; - - ITypeInfo_Release(*typeinfo); - *typeinfo = real_typeinfo; } + else + ITypeInfo_AddRef(*real_typeinfo = typeinfo); - hr = ITypeInfo_GetContainingTypeLib(*typeinfo, &typelib, NULL); + hr = ITypeInfo_GetContainingTypeLib(*real_typeinfo, &typelib, NULL); if (FAILED(hr)) - return hr; + goto err; hr = ITypeLib_GetLibAttr(typelib, &libattr); if (FAILED(hr)) { ITypeLib_Release(typelib); - return hr; + goto err; } syskind = libattr->syskind; ITypeLib_ReleaseTLibAttr(typelib, libattr); ITypeLib_Release(typelib); - hr = ITypeInfo_GetTypeAttr(*typeinfo, &typeattr); + hr = ITypeInfo_GetTypeAttr(*real_typeinfo, &typeattr); if (FAILED(hr)) - return hr; + goto err; *funcs = typeattr->cFuncs; *parentfuncs = typeattr->cbSizeVft / (syskind == SYS_WIN64 ? 8 : 4) - *funcs; - ITypeInfo_ReleaseTypeAttr(*typeinfo, typeattr); + ITypeInfo_ReleaseTypeAttr(*real_typeinfo, typeattr); - hr = ITypeInfo_GetRefTypeOfImplType(*typeinfo, 0, &reftype); + hr = ITypeInfo_GetRefTypeOfImplType(*real_typeinfo, 0, &reftype); if (FAILED(hr)) - return hr; - hr = ITypeInfo_GetRefTypeInfo(*typeinfo, reftype, &parentinfo); + goto err; + hr = ITypeInfo_GetRefTypeInfo(*real_typeinfo, reftype, &parentinfo); if (FAILED(hr)) - return hr; + goto err; + hr = ITypeInfo_GetTypeAttr(parentinfo, &typeattr); - if (FAILED(hr)) - return hr; - *parentiid = typeattr->guid; - ITypeInfo_ReleaseTypeAttr(parentinfo, typeattr); + if (SUCCEEDED(hr)) + { + *parentiid = typeattr->guid; + ITypeInfo_ReleaseTypeAttr(parentinfo, typeattr); + } ITypeInfo_Release(parentinfo); + if (SUCCEEDED(hr)) + return hr; +err: + ITypeInfo_Release(*real_typeinfo); return hr; } @@ -1324,7 +1497,7 @@ static ULONG WINAPI typelib_proxy_Release(IRpcProxyBuffer *iface) struct typelib_proxy *proxy = CONTAINING_RECORD(iface, struct typelib_proxy, proxy.IRpcProxyBuffer_iface); ULONG refcount = InterlockedDecrement(&proxy->proxy.RefCount); - TRACE("(%p) decreasing refs to %d\n", proxy, refcount); + TRACE("(%p) decreasing refs to %ld\n", proxy, refcount); if (!refcount) { @@ -1334,11 +1507,11 @@ static ULONG WINAPI typelib_proxy_Release(IRpcProxyBuffer *iface) IUnknown_Release(proxy->proxy.base_object); if (proxy->proxy.base_proxy) IRpcProxyBuffer_Release(proxy->proxy.base_proxy); - heap_free((void *)proxy->stub_desc.pFormatTypes); - heap_free((void *)proxy->proxy_info.ProcFormatString); - heap_free(proxy->offset_table); - heap_free(proxy->proxy_vtbl); - heap_free(proxy); + free((void *)proxy->stub_desc.pFormatTypes); + free((void *)proxy->proxy_info.ProcFormatString); + free(proxy->offset_table); + free(proxy->proxy_vtbl); + free(proxy); } return refcount; } @@ -1385,30 +1558,33 @@ HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer, { struct typelib_proxy *proxy; WORD funcs, parentfuncs, i; + ITypeInfo *real_typeinfo; GUID parentiid; HRESULT hr; TRACE("typeinfo %p, outer %p, iid %s, proxy_buffer %p, out %p.\n", typeinfo, outer, debugstr_guid(iid), proxy_buffer, out); - hr = get_iface_info(&typeinfo, &funcs, &parentfuncs, &parentiid); + hr = get_iface_info(typeinfo, &funcs, &parentfuncs, &parentiid, &real_typeinfo); if (FAILED(hr)) return hr; - if (!(proxy = heap_alloc_zero(sizeof(*proxy)))) + if (!(proxy = calloc(1, sizeof(*proxy)))) { ERR("Failed to allocate proxy object.\n"); + ITypeInfo_Release(real_typeinfo); return E_OUTOFMEMORY; } init_stub_desc(&proxy->stub_desc); proxy->proxy_info.pStubDesc = &proxy->stub_desc; - proxy->proxy_vtbl = heap_alloc_zero(sizeof(proxy->proxy_vtbl->header) + (funcs + parentfuncs) * sizeof(void *)); + proxy->proxy_vtbl = calloc(1, sizeof(proxy->proxy_vtbl->header) + (funcs + parentfuncs) * sizeof(void *)); if (!proxy->proxy_vtbl) { ERR("Failed to allocate proxy vtbl.\n"); - heap_free(proxy); + free(proxy); + ITypeInfo_Release(real_typeinfo); return E_OUTOFMEMORY; } proxy->proxy_vtbl->header.pStublessProxyInfo = &proxy->proxy_info; @@ -1418,12 +1594,13 @@ HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer, for (i = 0; i < funcs; i++) proxy->proxy_vtbl->Vtbl[parentfuncs + i] = (void *)-1; - hr = build_format_strings(typeinfo, funcs, parentfuncs, &proxy->stub_desc.pFormatTypes, + hr = build_format_strings(real_typeinfo, funcs, parentfuncs, &proxy->stub_desc.pFormatTypes, &proxy->proxy_info.ProcFormatString, &proxy->offset_table); + ITypeInfo_Release(real_typeinfo); if (FAILED(hr)) { - heap_free(proxy->proxy_vtbl); - heap_free(proxy); + free(proxy->proxy_vtbl); + free(proxy); return hr; } proxy->proxy_info.FormatStringOffset = &proxy->offset_table[-3]; @@ -1431,11 +1608,11 @@ HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer, hr = typelib_proxy_init(proxy, outer, funcs + parentfuncs, &parentiid, proxy_buffer, out); if (FAILED(hr)) { - heap_free((void *)proxy->stub_desc.pFormatTypes); - heap_free((void *)proxy->proxy_info.ProcFormatString); - heap_free((void *)proxy->offset_table); - heap_free(proxy->proxy_vtbl); - heap_free(proxy); + free((void *)proxy->stub_desc.pFormatTypes); + free((void *)proxy->proxy_info.ProcFormatString); + free((void *)proxy->offset_table); + free(proxy->proxy_vtbl); + free(proxy); } return hr; @@ -1457,7 +1634,7 @@ static ULONG WINAPI typelib_stub_Release(IRpcStubBuffer *iface) struct typelib_stub *stub = CONTAINING_RECORD(iface, struct typelib_stub, stub.stub_buffer); ULONG refcount = InterlockedDecrement(&stub->stub.stub_buffer.RefCount); - TRACE("(%p) decreasing refs to %d\n", stub, refcount); + TRACE("(%p) decreasing refs to %ld\n", stub, refcount); if (!refcount) { @@ -1468,14 +1645,13 @@ static ULONG WINAPI typelib_stub_Release(IRpcStubBuffer *iface) if (stub->stub.base_stub) { IRpcStubBuffer_Release(stub->stub.base_stub); - release_delegating_vtbl(stub->stub.base_obj); - heap_free(stub->dispatch_table); + free(stub->dispatch_table); } - heap_free((void *)stub->stub_desc.pFormatTypes); - heap_free((void *)stub->server_info.ProcString); - heap_free(stub->offset_table); - heap_free(stub); + free((void *)stub->stub_desc.pFormatTypes); + free((void *)stub->server_info.ProcString); + free(stub->offset_table); + free(stub); } return refcount; @@ -1490,7 +1666,7 @@ static HRESULT typelib_stub_init(struct typelib_stub *stub, IUnknown *server, (void **)&stub->stub.stub_buffer.pvServerObject); if (FAILED(hr)) { - WARN("Failed to get interface %s, hr %#x.\n", + WARN("Failed to get interface %s, hr %#lx.\n", debugstr_guid(stub->stub_vtbl.header.piid), hr); stub->stub.stub_buffer.pvServerObject = server; IUnknown_AddRef(server); @@ -1498,11 +1674,10 @@ static HRESULT typelib_stub_init(struct typelib_stub *stub, IUnknown *server, if (!IsEqualGUID(parentiid, &IID_IUnknown)) { - stub->stub.base_obj = get_delegating_vtbl(stub->stub_vtbl.header.DispatchTableCount); - hr = create_stub(parentiid, (IUnknown *)&stub->stub.base_obj, &stub->stub.base_stub); + stub->stub.base_obj.lpVtbl = get_delegating_vtbl(stub->stub_vtbl.header.DispatchTableCount); + hr = create_stub(parentiid, &stub->stub.base_obj, &stub->stub.base_stub); if (FAILED(hr)) { - release_delegating_vtbl(stub->stub.base_obj); IUnknown_Release(stub->stub.stub_buffer.pvServerObject); return hr; } @@ -1520,30 +1695,33 @@ HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid, { WORD funcs, parentfuncs, i; struct typelib_stub *stub; + ITypeInfo *real_typeinfo; GUID parentiid; HRESULT hr; TRACE("typeinfo %p, iid %s, server %p, stub_buffer %p.\n", typeinfo, debugstr_guid(iid), server, stub_buffer); - hr = get_iface_info(&typeinfo, &funcs, &parentfuncs, &parentiid); + hr = get_iface_info(typeinfo, &funcs, &parentfuncs, &parentiid, &real_typeinfo); if (FAILED(hr)) return hr; - if (!(stub = heap_alloc_zero(sizeof(*stub)))) + if (!(stub = calloc(1, sizeof(*stub)))) { ERR("Failed to allocate stub object.\n"); + ITypeInfo_Release(real_typeinfo); return E_OUTOFMEMORY; } init_stub_desc(&stub->stub_desc); stub->server_info.pStubDesc = &stub->stub_desc; - hr = build_format_strings(typeinfo, funcs, parentfuncs, &stub->stub_desc.pFormatTypes, + hr = build_format_strings(real_typeinfo, funcs, parentfuncs, &stub->stub_desc.pFormatTypes, &stub->server_info.ProcString, &stub->offset_table); + ITypeInfo_Release(real_typeinfo); if (FAILED(hr)) { - heap_free(stub); + free(stub); return hr; } stub->server_info.FmtStringOffset = &stub->offset_table[-3]; @@ -1555,7 +1733,7 @@ HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid, if (!IsEqualGUID(&parentiid, &IID_IUnknown)) { - stub->dispatch_table = heap_alloc((funcs + parentfuncs) * sizeof(void *)); + stub->dispatch_table = malloc((funcs + parentfuncs) * sizeof(void *)); for (i = 3; i < parentfuncs; i++) stub->dispatch_table[i - 3] = NdrStubForwardingFunction; for (; i < funcs + parentfuncs; i++) @@ -1570,10 +1748,10 @@ HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid, hr = typelib_stub_init(stub, server, &parentiid, stub_buffer); if (FAILED(hr)) { - heap_free((void *)stub->stub_desc.pFormatTypes); - heap_free((void *)stub->server_info.ProcString); - heap_free(stub->offset_table); - heap_free(stub); + free((void *)stub->stub_desc.pFormatTypes); + free((void *)stub->server_info.ProcString); + free(stub->offset_table); + free(stub); } return hr; diff --git a/dll/win32/rpcrt4/precomp.h b/dll/win32/rpcrt4/precomp.h index e0225805909..8bc83c8fecc 100644 --- a/dll/win32/rpcrt4/precomp.h +++ b/dll/win32/rpcrt4/precomp.h @@ -9,8 +9,6 @@ #define _INC_WINDOWS #define COBJMACROS -#define NONAMELESSUNION -#define NONAMELESSSTRUCT #include #define WIN32_NO_STATUS diff --git a/dll/win32/rpcrt4/ros_extra.c b/dll/win32/rpcrt4/ros_extra.c new file mode 100644 index 00000000000..93161f6d9d2 --- /dev/null +++ b/dll/win32/rpcrt4/ros_extra.c @@ -0,0 +1,59 @@ + +#include + +#include "rpc.h" +#include "rpcndr.h" +#include "rpcasync.h" + +#include "wine/debug.h" + +#include "rpc_binding.h" +#include "rpc_message.h" +#include "ndr_stubless.h" + +WINE_DEFAULT_DEBUG_CHANNEL(rpc); + +/*********************************************************************** + * RpcGetAuthorizationContextForClient [RPCRT4.@] + * + * Called by RpcFreeAuthorizationContext to return the Authz context. + * + * PARAMS + * ClientBinding [I] Binding handle, represents a binding to a client on the server. + * ImpersonateOnReturn [I] Directs this function to be represented the client on return. + * Reserved1 [I] Reserved, equal to null. + * expiration_time [I] Points to the exact date and time when the token expires. + * Reserved2 [I] Reserved, equal to a LUID structure which has a members, + * each of them is set to zero. + * Reserved3 [I] Reserved, equal to zero. + * Reserved4 [I] Reserved, equal to null. + * authz_client_context [I] Points to an AUTHZ_CLIENT_CONTEXT_HANDLE structure + * that has direct pass to Authz functions. + * + * RETURNS + * Success: RPC_S_OK. + * Failure: Any error code. + */ +RPC_STATUS +WINAPI +RpcGetAuthorizationContextForClient(RPC_BINDING_HANDLE ClientBinding, + BOOL ImpersonateOnReturn, + void * Reserved1, + PLARGE_INTEGER expiration_time, + LUID Reserved2, + DWORD Reserved3, + PVOID Reserved4, + PVOID *authz_client_context) +{ + FIXME("(%p, %d, %p, %p, (%d, %u), %u, %p, %p): stub\n", + ClientBinding, + ImpersonateOnReturn, + Reserved1, + expiration_time, + Reserved2.HighPart, + Reserved2.LowPart, + Reserved3, + Reserved4, + authz_client_context); + return RPC_S_NO_CONTEXT_AVAILABLE; +} diff --git a/dll/win32/rpcrt4/rpc_assoc.c b/dll/win32/rpcrt4/rpc_assoc.c index 0daa466238f..c3eec9558dd 100644 --- a/dll/win32/rpcrt4/rpc_assoc.c +++ b/dll/win32/rpcrt4/rpc_assoc.c @@ -20,11 +20,11 @@ */ #include +#include #include #include "rpc.h" #include "rpcndr.h" -#include "wine/winternl.h" #include "wine/debug.h" @@ -55,7 +55,7 @@ typedef struct _RpcContextHandle NDR_RUNDOWN rundown_routine; void *ctx_guard; UUID uuid; - RTL_RWLOCK rw_lock; + CRITICAL_SECTION lock; unsigned int refs; } RpcContextHandle; @@ -66,18 +66,18 @@ static RPC_STATUS RpcAssoc_Alloc(LPCSTR Protseq, LPCSTR NetworkAddr, RpcAssoc **assoc_out) { RpcAssoc *assoc; - assoc = HeapAlloc(GetProcessHeap(), 0, sizeof(*assoc)); + assoc = malloc(sizeof(*assoc)); if (!assoc) return RPC_S_OUT_OF_RESOURCES; assoc->refs = 1; list_init(&assoc->free_connection_pool); list_init(&assoc->context_handle_list); - InitializeCriticalSection(&assoc->cs); + InitializeCriticalSectionEx(&assoc->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); assoc->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcAssoc.cs"); - assoc->Protseq = RPCRT4_strdupA(Protseq); - assoc->NetworkAddr = RPCRT4_strdupA(NetworkAddr); - assoc->Endpoint = RPCRT4_strdupA(Endpoint); - assoc->NetworkOptions = NetworkOptions ? RPCRT4_strdupW(NetworkOptions) : NULL; + assoc->Protseq = strdup(Protseq); + assoc->NetworkAddr = strdup(NetworkAddr); + assoc->Endpoint = strdup(Endpoint); + assoc->NetworkOptions = wcsdup(NetworkOptions); assoc->assoc_group_id = 0; assoc->connection_cnt = 0; UuidCreate(&assoc->http_uuid); @@ -210,15 +210,15 @@ ULONG RpcAssoc_Release(RpcAssoc *assoc) LIST_FOR_EACH_ENTRY_SAFE(context_handle, context_handle_cursor, &assoc->context_handle_list, RpcContextHandle, entry) RpcContextHandle_Destroy(context_handle); - HeapFree(GetProcessHeap(), 0, assoc->NetworkOptions); - HeapFree(GetProcessHeap(), 0, assoc->Endpoint); - HeapFree(GetProcessHeap(), 0, assoc->NetworkAddr); - HeapFree(GetProcessHeap(), 0, assoc->Protseq); + free(assoc->NetworkOptions); + free(assoc->Endpoint); + free(assoc->NetworkAddr); + free(assoc->Protseq); assoc->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&assoc->cs); - HeapFree(GetProcessHeap(), 0, assoc); + free(assoc); } return refs; @@ -245,14 +245,14 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection * InterfaceId, TransferSyntax); status = RPCRT4_Send(conn, hdr, NULL, 0); - RPCRT4_FreeHeader(hdr); + free(hdr); if (status != RPC_S_OK) return status; status = RPCRT4_ReceiveWithAuth(conn, &response_hdr, &msg, &auth_data, &auth_length); if (status != RPC_S_OK) { - ERR("receive failed with error %d\n", status); + ERR("receive failed with error %ld\n", status); return status; } @@ -356,8 +356,8 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection * } I_RpcFree(msg.Buffer); - RPCRT4_FreeHeader(response_hdr); - HeapFree(GetProcessHeap(), 0, auth_data); + free(response_hdr); + free(auth_data); return status; } @@ -458,17 +458,18 @@ RPC_STATUS RpcServerAssoc_AllocateContextHandle(RpcAssoc *assoc, void *CtxGuard, { RpcContextHandle *context_handle; - context_handle = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context_handle)); + context_handle = calloc(1, sizeof(*context_handle)); if (!context_handle) return RPC_S_OUT_OF_MEMORY; context_handle->ctx_guard = CtxGuard; - RtlInitializeResource(&context_handle->rw_lock); + InitializeCriticalSectionEx(&context_handle->lock, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); + context_handle->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcContextHandle.lock"); context_handle->refs = 1; /* lock here to mirror unmarshall, so we don't need to special-case the * freeing of a non-marshalled context handle */ - RtlAcquireResourceExclusive(&context_handle->rw_lock, TRUE); + EnterCriticalSection(&context_handle->lock); EnterCriticalSection(&assoc->cs); list_add_tail(&assoc->context_handle_list, &context_handle->entry); @@ -500,7 +501,7 @@ RPC_STATUS RpcServerAssoc_FindContextHandle(RpcAssoc *assoc, const UUID *uuid, { LeaveCriticalSection(&assoc->cs); TRACE("found %p\n", context_handle); - RtlAcquireResourceExclusive(&context_handle->rw_lock, TRUE); + EnterCriticalSection(&context_handle->lock); return RPC_S_OK; } } @@ -555,9 +556,10 @@ static void RpcContextHandle_Destroy(RpcContextHandle *context_handle) context_handle->rundown_routine(context_handle->user_context); } - RtlDeleteResource(&context_handle->rw_lock); + context_handle->lock.DebugInfo->Spare[0] = 0; + DeleteCriticalSection(&context_handle->lock); - HeapFree(GetProcessHeap(), 0, context_handle); + free(context_handle); } unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, BOOL release_lock) @@ -566,7 +568,7 @@ unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT S unsigned int refs; if (release_lock) - RtlReleaseResource(&context_handle->rw_lock); + LeaveCriticalSection(&context_handle->lock); EnterCriticalSection(&assoc->cs); refs = --context_handle->refs; diff --git a/dll/win32/rpcrt4/rpc_assoc.h b/dll/win32/rpcrt4/rpc_assoc.h index b83d5492f46..c5898e138f7 100644 --- a/dll/win32/rpcrt4/rpc_assoc.h +++ b/dll/win32/rpcrt4/rpc_assoc.h @@ -49,17 +49,17 @@ typedef struct _RpcAssoc struct list context_handle_list; /* protected by cs */ } RpcAssoc; -RPC_STATUS RPCRT4_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAssoc **assoc) DECLSPEC_HIDDEN; +RPC_STATUS RPCRT4_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAssoc **assoc); RPC_STATUS RpcAssoc_GetClientConnection(RpcAssoc *assoc, const RPC_SYNTAX_IDENTIFIER *InterfaceId, const RPC_SYNTAX_IDENTIFIER *TransferSyntax, RpcAuthInfo *AuthInfo, RpcQualityOfService *QOS, - LPCWSTR CookieAuth, RpcConnection **Connection, BOOL *from_cache) DECLSPEC_HIDDEN; -void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection) DECLSPEC_HIDDEN; -ULONG RpcAssoc_Release(RpcAssoc *assoc) DECLSPEC_HIDDEN; -RPC_STATUS RpcServerAssoc_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, ULONG assoc_gid, RpcAssoc **assoc_out) DECLSPEC_HIDDEN; -RPC_STATUS RpcServerAssoc_AllocateContextHandle(RpcAssoc *assoc, void *CtxGuard, NDR_SCONTEXT *SContext) DECLSPEC_HIDDEN; -RPC_STATUS RpcServerAssoc_FindContextHandle(RpcAssoc *assoc, const UUID *uuid, void *CtxGuard, ULONG Flags, NDR_SCONTEXT *SContext) DECLSPEC_HIDDEN; -RPC_STATUS RpcServerAssoc_UpdateContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, void *CtxGuard, NDR_RUNDOWN rundown_routine) DECLSPEC_HIDDEN; -unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, BOOL release_lock) DECLSPEC_HIDDEN; -void RpcContextHandle_GetUuid(NDR_SCONTEXT SContext, UUID *uuid) DECLSPEC_HIDDEN; -BOOL RpcContextHandle_IsGuardCorrect(NDR_SCONTEXT SContext, void *CtxGuard) DECLSPEC_HIDDEN; -void RpcAssoc_ConnectionReleased(RpcAssoc *assoc) DECLSPEC_HIDDEN; + LPCWSTR CookieAuth, RpcConnection **Connection, BOOL *from_cache); +void RpcAssoc_ReleaseIdleConnection(RpcAssoc *assoc, RpcConnection *Connection); +ULONG RpcAssoc_Release(RpcAssoc *assoc); +RPC_STATUS RpcServerAssoc_GetAssociation(LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, ULONG assoc_gid, RpcAssoc **assoc_out); +RPC_STATUS RpcServerAssoc_AllocateContextHandle(RpcAssoc *assoc, void *CtxGuard, NDR_SCONTEXT *SContext); +RPC_STATUS RpcServerAssoc_FindContextHandle(RpcAssoc *assoc, const UUID *uuid, void *CtxGuard, ULONG Flags, NDR_SCONTEXT *SContext); +RPC_STATUS RpcServerAssoc_UpdateContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, void *CtxGuard, NDR_RUNDOWN rundown_routine); +unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, BOOL release_lock); +void RpcContextHandle_GetUuid(NDR_SCONTEXT SContext, UUID *uuid); +BOOL RpcContextHandle_IsGuardCorrect(NDR_SCONTEXT SContext, void *CtxGuard); +void RpcAssoc_ConnectionReleased(RpcAssoc *assoc); diff --git a/dll/win32/rpcrt4/rpc_async.c b/dll/win32/rpcrt4/rpc_async.c index 40628b4b4ef..d194496812b 100644 --- a/dll/win32/rpcrt4/rpc_async.c +++ b/dll/win32/rpcrt4/rpc_async.c @@ -143,7 +143,7 @@ RPC_STATUS WINAPI RpcAsyncCompleteCall(PRPC_ASYNC_STATE pAsync, void *Reply) */ RPC_STATUS WINAPI RpcAsyncAbortCall(PRPC_ASYNC_STATE pAsync, ULONG ExceptionCode) { - FIXME("(%p, %d/0x%x): stub\n", pAsync, ExceptionCode, ExceptionCode); + FIXME("(%p, %ld/0x%lx): stub\n", pAsync, ExceptionCode, ExceptionCode); return RPC_S_INVALID_ASYNC_HANDLE; } @@ -166,50 +166,3 @@ RPC_STATUS WINAPI RpcAsyncCancelCall(PRPC_ASYNC_STATE pAsync, BOOL fAbortCall) FIXME("(%p, %s): stub\n", pAsync, fAbortCall ? "TRUE" : "FALSE"); return RPC_S_INVALID_ASYNC_HANDLE; } - -#ifdef __REACTOS__ -/*********************************************************************** - * RpcGetAuthorizationContextForClient [RPCRT4.@] - * - * Called by RpcFreeAuthorizationContext to return the Authz context. - * - * PARAMS - * ClientBinding [I] Binding handle, represents a binding to a client on the server. - * ImpersonateOnReturn [I] Directs this function to be represented the client on return. - * Reserved1 [I] Reserved, equal to null. - * expiration_time [I] Points to the exact date and time when the token expires. - * Reserved2 [I] Reserved, equal to a LUID structure which has a members, - * each of them is set to zero. - * Reserved3 [I] Reserved, equal to zero. - * Reserved4 [I] Reserved, equal to null. - * authz_client_context [I] Points to an AUTHZ_CLIENT_CONTEXT_HANDLE structure - * that has direct pass to Authz functions. - * - * RETURNS - * Success: RPC_S_OK. - * Failure: Any error code. - */ -RPC_STATUS -WINAPI -RpcGetAuthorizationContextForClient(RPC_BINDING_HANDLE ClientBinding, - BOOL ImpersonateOnReturn, - void * Reserved1, - PLARGE_INTEGER expiration_time, - LUID Reserved2, - DWORD Reserved3, - PVOID Reserved4, - PVOID *authz_client_context) -{ - FIXME("(%p, %d, %p, %p, (%d, %u), %u, %p, %p): stub\n", - ClientBinding, - ImpersonateOnReturn, - Reserved1, - expiration_time, - Reserved2.HighPart, - Reserved2.LowPart, - Reserved3, - Reserved4, - authz_client_context); - return RPC_S_NO_CONTEXT_AVAILABLE; -} -#endif diff --git a/dll/win32/rpcrt4/rpc_binding.c b/dll/win32/rpcrt4/rpc_binding.c index 80278b98570..7a7c22da4a1 100644 --- a/dll/win32/rpcrt4/rpc_binding.c +++ b/dll/win32/rpcrt4/rpc_binding.c @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -30,7 +31,7 @@ #include "winbase.h" #include "winnls.h" #include "winerror.h" -#include "wine/winternl.h" +#include "winternl.h" #include "rpc.h" #include "rpcndr.h" @@ -42,26 +43,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(rpc); -LPSTR RPCRT4_strndupA(LPCSTR src, INT slen) -{ - DWORD len; - LPSTR s; - if (!src) return NULL; - if (slen == -1) slen = strlen(src); - len = slen; - s = HeapAlloc(GetProcessHeap(), 0, len+1); - memcpy(s, src, len); - s[len] = 0; - return s; -} - LPSTR RPCRT4_strdupWtoA(LPCWSTR src) { DWORD len; LPSTR s; if (!src) return NULL; len = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL); - s = HeapAlloc(GetProcessHeap(), 0, len); + s = malloc(len); WideCharToMultiByte(CP_ACP, 0, src, -1, s, len, NULL, NULL); return s; } @@ -72,7 +60,7 @@ LPWSTR RPCRT4_strdupAtoW(LPCSTR src) LPWSTR s; if (!src) return NULL; len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0); - s = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + s = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, src, -1, s, len); return s; } @@ -83,7 +71,7 @@ static LPWSTR RPCRT4_strndupAtoW(LPCSTR src, INT slen) LPWSTR s; if (!src) return NULL; len = MultiByteToWideChar(CP_ACP, 0, src, slen, NULL, 0); - s = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + s = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, src, slen, s, len); return s; } @@ -95,22 +83,17 @@ LPWSTR RPCRT4_strndupW(LPCWSTR src, INT slen) if (!src) return NULL; if (slen == -1) slen = lstrlenW(src); len = slen; - s = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)); + s = malloc((len + 1) * sizeof(WCHAR)); memcpy(s, src, len*sizeof(WCHAR)); s[len] = 0; return s; } -void RPCRT4_strfree(LPSTR src) -{ - HeapFree(GetProcessHeap(), 0, src); -} - static RPC_STATUS RPCRT4_AllocBinding(RpcBinding** Binding, BOOL server) { RpcBinding* NewBinding; - NewBinding = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcBinding)); + NewBinding = calloc(1, sizeof(RpcBinding)); NewBinding->refs = 1; NewBinding->server = server; @@ -124,7 +107,7 @@ static RPC_STATUS RPCRT4_CreateBindingA(RpcBinding** Binding, BOOL server, LPCST RpcBinding* NewBinding; RPCRT4_AllocBinding(&NewBinding, server); - NewBinding->Protseq = RPCRT4_strdupA(Protseq); + NewBinding->Protseq = strdup(Protseq); TRACE("binding: %p\n", NewBinding); *Binding = NewBinding; @@ -153,11 +136,11 @@ static RPC_STATUS RPCRT4_CompleteBindingA(RpcBinding* Binding, LPCSTR NetworkAdd TRACE("(RpcBinding == ^%p, NetworkAddr == %s, EndPoint == %s, NetworkOptions == %s)\n", Binding, debugstr_a(NetworkAddr), debugstr_a(Endpoint), debugstr_a(NetworkOptions)); - RPCRT4_strfree(Binding->NetworkAddr); - Binding->NetworkAddr = RPCRT4_strdupA(NetworkAddr); - RPCRT4_strfree(Binding->Endpoint); - Binding->Endpoint = RPCRT4_strdupA(Endpoint); - HeapFree(GetProcessHeap(), 0, Binding->NetworkOptions); + free(Binding->NetworkAddr); + Binding->NetworkAddr = strdup(NetworkAddr); + free(Binding->Endpoint); + Binding->Endpoint = strdup(Endpoint); + free(Binding->NetworkOptions); Binding->NetworkOptions = RPCRT4_strdupAtoW(NetworkOptions); /* only attempt to get an association if the binding is complete */ @@ -181,12 +164,12 @@ static RPC_STATUS RPCRT4_CompleteBindingW(RpcBinding* Binding, LPCWSTR NetworkAd TRACE("(RpcBinding == ^%p, NetworkAddr == %s, EndPoint == %s, NetworkOptions == %s)\n", Binding, debugstr_w(NetworkAddr), debugstr_w(Endpoint), debugstr_w(NetworkOptions)); - RPCRT4_strfree(Binding->NetworkAddr); + free(Binding->NetworkAddr); Binding->NetworkAddr = RPCRT4_strdupWtoA(NetworkAddr); - RPCRT4_strfree(Binding->Endpoint); + free(Binding->Endpoint); Binding->Endpoint = RPCRT4_strdupWtoA(Endpoint); - HeapFree(GetProcessHeap(), 0, Binding->NetworkOptions); - Binding->NetworkOptions = RPCRT4_strdupW(NetworkOptions); + free(Binding->NetworkOptions); + Binding->NetworkOptions = wcsdup(NetworkOptions); /* only attempt to get an association if the binding is complete */ if (Endpoint && Endpoint[0] != '\0') @@ -207,8 +190,8 @@ RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint) TRACE("(RpcBinding == ^%p, EndPoint == \"%s\"\n", Binding, Endpoint); - RPCRT4_strfree(Binding->Endpoint); - Binding->Endpoint = RPCRT4_strdupA(Endpoint); + free(Binding->Endpoint); + Binding->Endpoint = strdup(Endpoint); if (Binding->Assoc) RpcAssoc_Release(Binding->Assoc); Binding->Assoc = NULL; @@ -235,9 +218,9 @@ RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection) TRACE("(RpcBinding == ^%p, Connection == ^%p)\n", Binding, Connection); RPCRT4_AllocBinding(&NewBinding, Connection->server); - NewBinding->Protseq = RPCRT4_strdupA(rpcrt4_conn_get_name(Connection)); - NewBinding->NetworkAddr = RPCRT4_strdupA(Connection->NetworkAddr); - NewBinding->Endpoint = RPCRT4_strdupA(Connection->Endpoint); + NewBinding->Protseq = strdup(rpcrt4_conn_get_name(Connection)); + NewBinding->NetworkAddr = strdup(Connection->NetworkAddr); + NewBinding->Endpoint = strdup(Connection->Endpoint); NewBinding->FromConn = Connection; TRACE("binding: %p\n", NewBinding); @@ -258,14 +241,14 @@ RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding) TRACE("binding: %p\n", Binding); if (Binding->Assoc) RpcAssoc_Release(Binding->Assoc); - RPCRT4_strfree(Binding->Endpoint); - RPCRT4_strfree(Binding->NetworkAddr); - RPCRT4_strfree(Binding->Protseq); - HeapFree(GetProcessHeap(), 0, Binding->NetworkOptions); - HeapFree(GetProcessHeap(), 0, Binding->CookieAuth); + free(Binding->Endpoint); + free(Binding->NetworkAddr); + free(Binding->Protseq); + free(Binding->NetworkOptions); + free(Binding->CookieAuth); if (Binding->AuthInfo) RpcAuthInfo_Release(Binding->AuthInfo); if (Binding->QOS) RpcQualityOfService_Release(Binding->QOS); - HeapFree(GetProcessHeap(), 0, Binding); + free(Binding); return RPC_S_OK; } @@ -308,10 +291,10 @@ RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection) static LPSTR RPCRT4_strconcatA(LPSTR dst, LPCSTR src) { DWORD len = strlen(dst), slen = strlen(src); - LPSTR ndst = HeapReAlloc(GetProcessHeap(), 0, dst, (len+slen+2)*sizeof(CHAR)); + char *ndst = realloc(dst, len + slen + 2); if (!ndst) { - HeapFree(GetProcessHeap(), 0, dst); + free(dst); return NULL; } ndst[len] = ','; @@ -322,10 +305,10 @@ static LPSTR RPCRT4_strconcatA(LPSTR dst, LPCSTR src) static LPWSTR RPCRT4_strconcatW(LPWSTR dst, LPCWSTR src) { DWORD len = lstrlenW(dst), slen = lstrlenW(src); - LPWSTR ndst = HeapReAlloc(GetProcessHeap(), 0, dst, (len+slen+2)*sizeof(WCHAR)); - if (!ndst) + WCHAR *ndst = realloc(dst, (len + slen + 2) * sizeof(WCHAR)); + if (!ndst) { - HeapFree(GetProcessHeap(), 0, dst); + free(dst); return NULL; } ndst[len] = ','; @@ -414,7 +397,7 @@ static RPC_CSTR unescape_string_binding_component( if (len == -1) len = strlen((const char *)string_binding); - component = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(*component)); + component = malloc((len + 1) * sizeof(*component)); if (!component) return NULL; for (p = component; len > 0; string_binding++, len--) { if (*string_binding == '\\') { @@ -436,7 +419,7 @@ static RPC_WSTR unescape_string_binding_componentW( if (len == -1) len = lstrlenW(string_binding); - component = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(*component)); + component = malloc((len + 1) * sizeof(*component)); if (!component) return NULL; for (p = component; len > 0; string_binding++, len--) { if (*string_binding == '\\') { @@ -473,7 +456,7 @@ RPC_STATUS WINAPI RpcStringBindingComposeA(RPC_CSTR ObjUuid, RPC_CSTR Protseq, if (Endpoint && *Endpoint) len += strlen((char*)Endpoint) * 2 + 2; if (Options && *Options) len += strlen((char*)Options) * 2 + 2; - data = HeapAlloc(GetProcessHeap(), 0, len); + data = malloc(len); *StringBinding = data; if (ObjUuid && *ObjUuid) { @@ -526,7 +509,7 @@ RPC_STATUS WINAPI RpcStringBindingComposeW( RPC_WSTR ObjUuid, RPC_WSTR Protseq, if (Endpoint && *Endpoint) len += lstrlenW(Endpoint) * 2 + 2; if (Options && *Options) len += lstrlenW(Options) * 2 + 2; - data = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + data = malloc(len * sizeof(WCHAR)); *StringBinding = data; if (ObjUuid && *ObjUuid) { @@ -587,13 +570,13 @@ RPC_STATUS WINAPI RpcStringBindingParseA( RPC_CSTR StringBinding, RPC_CSTR *ObjU RPC_CSTR str_uuid = unescape_string_binding_component(data, next - data); status = UuidFromStringA(str_uuid, &uuid); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, str_uuid); + free(str_uuid); return status; } if (ObjUuid) *ObjUuid = str_uuid; else - HeapFree(GetProcessHeap(), 0, str_uuid); + free(str_uuid); data = next+1; } @@ -629,14 +612,14 @@ RPC_STATUS WINAPI RpcStringBindingParseA( RPC_CSTR StringBinding, RPC_CSTR *ObjU /* not an option, must be an endpoint */ if (endpoint_already_found) goto fail; if (Endpoint) *Endpoint = opt; - else HeapFree(GetProcessHeap(), 0, opt); + else free(opt); endpoint_already_found = TRUE; } else { if (strncmp((const char *)opt, ep_opt, strlen(ep_opt)) == 0) { /* endpoint option */ if (endpoint_already_found) goto fail; if (Endpoint) *Endpoint = unescape_string_binding_component(next+1, -1); - HeapFree(GetProcessHeap(), 0, opt); + free(opt); endpoint_already_found = TRUE; } else { /* network option */ @@ -644,11 +627,11 @@ RPC_STATUS WINAPI RpcStringBindingParseA( RPC_CSTR StringBinding, RPC_CSTR *ObjU if (*Options) { /* FIXME: this is kind of inefficient */ *Options = (unsigned char*) RPCRT4_strconcatA( (char*)*Options, (char *)opt); - HeapFree(GetProcessHeap(), 0, opt); + free(opt); } else *Options = opt; } else - HeapFree(GetProcessHeap(), 0, opt); + free(opt); } } } @@ -678,7 +661,6 @@ RPC_STATUS WINAPI RpcStringBindingParseW( RPC_WSTR StringBinding, RPC_WSTR *ObjU RPC_WSTR *Endpoint, RPC_WSTR *Options) { const WCHAR *data, *next; - static const WCHAR ep_opt[] = {'e','n','d','p','o','i','n','t','=',0}; BOOL endpoint_already_found = FALSE; TRACE("(%s,%p,%p,%p,%p,%p)\n", debugstr_w(StringBinding), @@ -699,13 +681,13 @@ RPC_STATUS WINAPI RpcStringBindingParseW( RPC_WSTR StringBinding, RPC_WSTR *ObjU RPC_WSTR str_uuid = unescape_string_binding_componentW(data, next - data); status = UuidFromStringW(str_uuid, &uuid); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, str_uuid); + free(str_uuid); return status; } if (ObjUuid) *ObjUuid = str_uuid; else - HeapFree(GetProcessHeap(), 0, str_uuid); + free(str_uuid); data = next+1; } @@ -741,14 +723,14 @@ RPC_STATUS WINAPI RpcStringBindingParseW( RPC_WSTR StringBinding, RPC_WSTR *ObjU /* not an option, must be an endpoint */ if (endpoint_already_found) goto fail; if (Endpoint) *Endpoint = opt; - else HeapFree(GetProcessHeap(), 0, opt); + else free(opt); endpoint_already_found = TRUE; } else { - if (wcsncmp(opt, ep_opt, lstrlenW(ep_opt)) == 0) { + if (wcsncmp(opt, L"endpoint=", lstrlenW(L"endpoint=")) == 0) { /* endpoint option */ if (endpoint_already_found) goto fail; if (Endpoint) *Endpoint = unescape_string_binding_componentW(next+1, -1); - HeapFree(GetProcessHeap(), 0, opt); + free(opt); endpoint_already_found = TRUE; } else { /* network option */ @@ -756,11 +738,11 @@ RPC_STATUS WINAPI RpcStringBindingParseW( RPC_WSTR StringBinding, RPC_WSTR *ObjU if (*Options) { /* FIXME: this is kind of inefficient */ *Options = RPCRT4_strconcatW(*Options, opt); - HeapFree(GetProcessHeap(), 0, opt); + free(opt); } else *Options = opt; } else - HeapFree(GetProcessHeap(), 0, opt); + free(opt); } } } @@ -805,7 +787,7 @@ RPC_STATUS WINAPI RpcBindingVectorFree( RPC_BINDING_VECTOR** BindingVector ) TRACE("(%p)\n", BindingVector); for (c=0; c<(*BindingVector)->Count; c++) RpcBindingFree(&(*BindingVector)->BindingH[c]); - HeapFree(GetProcessHeap(), 0, *BindingVector); + free(*BindingVector); *BindingVector = NULL; return RPC_S_OK; } @@ -1001,11 +983,11 @@ RPC_STATUS RPC_ENTRY RpcBindingCopy( DestBinding->ObjectUuid = SrcBinding->ObjectUuid; DestBinding->BlockingFn = SrcBinding->BlockingFn; - DestBinding->Protseq = RPCRT4_strndupA(SrcBinding->Protseq, -1); - DestBinding->NetworkAddr = RPCRT4_strndupA(SrcBinding->NetworkAddr, -1); - DestBinding->Endpoint = RPCRT4_strndupA(SrcBinding->Endpoint, -1); - DestBinding->NetworkOptions = RPCRT4_strdupW(SrcBinding->NetworkOptions); - DestBinding->CookieAuth = RPCRT4_strdupW(SrcBinding->CookieAuth); + DestBinding->Protseq = strdup(SrcBinding->Protseq); + DestBinding->NetworkAddr = strdup(SrcBinding->NetworkAddr); + DestBinding->Endpoint = strdup(SrcBinding->Endpoint); + DestBinding->NetworkOptions = wcsdup(SrcBinding->NetworkOptions); + DestBinding->CookieAuth = wcsdup(SrcBinding->CookieAuth); if (SrcBinding->Assoc) SrcBinding->Assoc->refs++; DestBinding->Assoc = SrcBinding->Assoc; @@ -1027,7 +1009,7 @@ RPC_STATUS RPC_ENTRY RpcBindingReset(RPC_BINDING_HANDLE Binding) TRACE("(%p)\n", Binding); - RPCRT4_strfree(bind->Endpoint); + free(bind->Endpoint); bind->Endpoint = NULL; if (bind->Assoc) RpcAssoc_Release(bind->Assoc); bind->Assoc = NULL; @@ -1120,7 +1102,7 @@ RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret) { - RpcAuthInfo *AuthInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*AuthInfo)); + RpcAuthInfo *AuthInfo = malloc(sizeof(*AuthInfo)); if (!AuthInfo) return RPC_S_OUT_OF_MEMORY; @@ -1138,10 +1120,10 @@ RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, if (identity && has_nt_auth_identity(AuthnSvc)) { const SEC_WINNT_AUTH_IDENTITY_W *nt_identity = identity; - AuthInfo->nt_identity = HeapAlloc(GetProcessHeap(), 0, sizeof(*AuthInfo->nt_identity)); + AuthInfo->nt_identity = malloc(sizeof(*AuthInfo->nt_identity)); if (!AuthInfo->nt_identity) { - HeapFree(GetProcessHeap(), 0, AuthInfo); + free(AuthInfo); return RPC_S_OUT_OF_MEMORY; } @@ -1166,11 +1148,11 @@ RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, (nt_identity->Domain && !AuthInfo->nt_identity->Domain) || (nt_identity->Password && !AuthInfo->nt_identity->Password)) { - HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity->User); - HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity->Domain); - HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity->Password); - HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity); - HeapFree(GetProcessHeap(), 0, AuthInfo); + free(AuthInfo->nt_identity->User); + free(AuthInfo->nt_identity->Domain); + free(AuthInfo->nt_identity->Password); + free(AuthInfo->nt_identity); + free(AuthInfo); return RPC_S_OUT_OF_MEMORY; } } @@ -1194,13 +1176,13 @@ ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo) FreeCredentialsHandle(&AuthInfo->cred); if (AuthInfo->nt_identity) { - HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity->User); - HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity->Domain); - HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity->Password); - HeapFree(GetProcessHeap(), 0, AuthInfo->nt_identity); + free(AuthInfo->nt_identity->User); + free(AuthInfo->nt_identity->Domain); + free(AuthInfo->nt_identity->Password); + free(AuthInfo->nt_identity); } - HeapFree(GetProcessHeap(), 0, AuthInfo->server_principal_name); - HeapFree(GetProcessHeap(), 0, AuthInfo); + free(AuthInfo->server_principal_name); + free(AuthInfo); } return refs; @@ -1249,13 +1231,13 @@ BOOL RpcAuthInfo_IsEqual(const RpcAuthInfo *AuthInfo1, const RpcAuthInfo *AuthIn static RPC_STATUS RpcQualityOfService_Create(const RPC_SECURITY_QOS *qos_src, BOOL unicode, RpcQualityOfService **qos_dst) { - RpcQualityOfService *qos = HeapAlloc(GetProcessHeap(), 0, sizeof(*qos)); + RpcQualityOfService *qos = malloc(sizeof(*qos)); if (!qos) return RPC_S_OUT_OF_RESOURCES; qos->refs = 1; - qos->qos = HeapAlloc(GetProcessHeap(), 0, sizeof(*qos->qos)); + qos->qos = malloc(sizeof(*qos->qos)); if (!qos->qos) goto error; qos->qos->Version = qos_src->Version; qos->qos->Capabilities = qos_src->Capabilities; @@ -1272,7 +1254,7 @@ static RPC_STATUS RpcQualityOfService_Create(const RPC_SECURITY_QOS *qos_src, BO const RPC_HTTP_TRANSPORT_CREDENTIALS_W *http_credentials_src = qos_src2->u.HttpCredentials; RPC_HTTP_TRANSPORT_CREDENTIALS_W *http_credentials_dst; - http_credentials_dst = HeapAlloc(GetProcessHeap(), 0, sizeof(*http_credentials_dst)); + http_credentials_dst = malloc(sizeof(*http_credentials_dst)); qos->qos->u.HttpCredentials = http_credentials_dst; if (!http_credentials_dst) goto error; http_credentials_dst->TransportCredentials = NULL; @@ -1284,7 +1266,7 @@ static RPC_STATUS RpcQualityOfService_Create(const RPC_SECURITY_QOS *qos_src, BO if (http_credentials_src->TransportCredentials) { SEC_WINNT_AUTH_IDENTITY_W *cred_dst; - cred_dst = http_credentials_dst->TransportCredentials = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cred_dst)); + cred_dst = http_credentials_dst->TransportCredentials = calloc(1, sizeof(*cred_dst)); if (!cred_dst) goto error; cred_dst->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE; if (unicode) @@ -1303,9 +1285,9 @@ static RPC_STATUS RpcQualityOfService_Create(const RPC_SECURITY_QOS *qos_src, BO cred_dst->UserLength = MultiByteToWideChar(CP_ACP, 0, (char *)cred_src->User, cred_src->UserLength, NULL, 0); cred_dst->DomainLength = MultiByteToWideChar(CP_ACP, 0, (char *)cred_src->Domain, cred_src->DomainLength, NULL, 0); cred_dst->PasswordLength = MultiByteToWideChar(CP_ACP, 0, (char *)cred_src->Password, cred_src->PasswordLength, NULL, 0); - cred_dst->User = HeapAlloc(GetProcessHeap(), 0, cred_dst->UserLength * sizeof(WCHAR)); - cred_dst->Password = HeapAlloc(GetProcessHeap(), 0, cred_dst->PasswordLength * sizeof(WCHAR)); - cred_dst->Domain = HeapAlloc(GetProcessHeap(), 0, cred_dst->DomainLength * sizeof(WCHAR)); + cred_dst->User = malloc(cred_dst->UserLength * sizeof(WCHAR)); + cred_dst->Password = malloc(cred_dst->PasswordLength * sizeof(WCHAR)); + cred_dst->Domain = malloc(cred_dst->DomainLength * sizeof(WCHAR)); if (!cred_dst->Password || !cred_dst->Domain) goto error; MultiByteToWideChar(CP_ACP, 0, (char *)cred_src->User, cred_src->UserLength, cred_dst->User, cred_dst->UserLength); MultiByteToWideChar(CP_ACP, 0, (char *)cred_src->Domain, cred_src->DomainLength, cred_dst->Domain, cred_dst->DomainLength); @@ -1314,7 +1296,7 @@ static RPC_STATUS RpcQualityOfService_Create(const RPC_SECURITY_QOS *qos_src, BO } if (http_credentials_src->NumberOfAuthnSchemes) { - http_credentials_dst->AuthnSchemes = HeapAlloc(GetProcessHeap(), 0, http_credentials_src->NumberOfAuthnSchemes * sizeof(*http_credentials_dst->AuthnSchemes)); + http_credentials_dst->AuthnSchemes = malloc(http_credentials_src->NumberOfAuthnSchemes * sizeof(*http_credentials_dst->AuthnSchemes)); if (!http_credentials_dst->AuthnSchemes) goto error; memcpy(http_credentials_dst->AuthnSchemes, http_credentials_src->AuthnSchemes, http_credentials_src->NumberOfAuthnSchemes * sizeof(*http_credentials_dst->AuthnSchemes)); } @@ -1342,18 +1324,18 @@ error: { if (qos->qos->u.HttpCredentials->TransportCredentials) { - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->TransportCredentials->User); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->TransportCredentials->Domain); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->TransportCredentials->Password); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->TransportCredentials); + free(qos->qos->u.HttpCredentials->TransportCredentials->User); + free(qos->qos->u.HttpCredentials->TransportCredentials->Domain); + free(qos->qos->u.HttpCredentials->TransportCredentials->Password); + free(qos->qos->u.HttpCredentials->TransportCredentials); } - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->AuthnSchemes); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->ServerCertificateSubject); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials); + free(qos->qos->u.HttpCredentials->AuthnSchemes); + free(qos->qos->u.HttpCredentials->ServerCertificateSubject); + free(qos->qos->u.HttpCredentials); } - HeapFree(GetProcessHeap(), 0, qos->qos); + free(qos->qos); } - HeapFree(GetProcessHeap(), 0, qos); + free(qos); return RPC_S_OUT_OF_RESOURCES; } @@ -1372,17 +1354,17 @@ ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) { if (qos->qos->u.HttpCredentials->TransportCredentials) { - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->TransportCredentials->User); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->TransportCredentials->Domain); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->TransportCredentials->Password); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->TransportCredentials); + free(qos->qos->u.HttpCredentials->TransportCredentials->User); + free(qos->qos->u.HttpCredentials->TransportCredentials->Domain); + free(qos->qos->u.HttpCredentials->TransportCredentials->Password); + free(qos->qos->u.HttpCredentials->TransportCredentials); } - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->AuthnSchemes); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials->ServerCertificateSubject); - HeapFree(GetProcessHeap(), 0, qos->qos->u.HttpCredentials); + free(qos->qos->u.HttpCredentials->AuthnSchemes); + free(qos->qos->u.HttpCredentials->ServerCertificateSubject); + free(qos->qos->u.HttpCredentials); } - HeapFree(GetProcessHeap(), 0, qos->qos); - HeapFree(GetProcessHeap(), 0, qos); + free(qos->qos); + free(qos); } return refs; } @@ -1395,7 +1377,7 @@ BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQuali if (!qos1 || !qos2) return FALSE; - TRACE("qos1 = { %d %d %d %d }, qos2 = { %d %d %d %d }\n", + TRACE("qos1 = { %ld %ld %ld %ld }, qos2 = { %ld %ld %ld %ld }\n", qos1->qos->Capabilities, qos1->qos->IdentityTracking, qos1->qos->ImpersonationType, qos1->qos->AdditionalSecurityInfoType, qos2->qos->Capabilities, qos2->qos->IdentityTracking, @@ -1486,7 +1468,7 @@ RpcBindingInqAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR *ServerPrincName, RPC_STATUS status; RPC_WSTR principal; - TRACE("%p %p %p %p %p %p %u %p\n", Binding, ServerPrincName, AuthnLevel, + TRACE("%p %p %p %p %p %p %lu %p\n", Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, RpcQosVersion, SecurityQOS); status = RpcBindingInqAuthInfoExW(Binding, ServerPrincName ? &principal : NULL, AuthnLevel, @@ -1511,7 +1493,7 @@ RpcBindingInqAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR *ServerPrincName, { RpcBinding *bind = Binding; - TRACE("%p %p %p %p %p %p %u %p\n", Binding, ServerPrincName, AuthnLevel, + TRACE("%p %p %p %p %p %p %lu %p\n", Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvc, RpcQosVersion, SecurityQOS); if (!bind->AuthInfo) return RPC_S_BINDING_HAS_NO_AUTH; @@ -1526,7 +1508,7 @@ RpcBindingInqAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR *ServerPrincName, { if (bind->AuthInfo->server_principal_name) { - *ServerPrincName = RPCRT4_strdupW(bind->AuthInfo->server_principal_name); + *ServerPrincName = wcsdup(bind->AuthInfo->server_principal_name); if (!*ServerPrincName) return RPC_S_OUT_OF_MEMORY; } else *ServerPrincName = NULL; @@ -1600,7 +1582,7 @@ RpcBindingInqAuthClientExA( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE * RPC_STATUS status; RPC_WSTR principal; - TRACE("%p %p %p %p %p %p 0x%x\n", ClientBinding, Privs, ServerPrincName, AuthnLevel, + TRACE("%p %p %p %p %p %p 0x%lx\n", ClientBinding, Privs, ServerPrincName, AuthnLevel, AuthnSvc, AuthzSvc, Flags); status = RpcBindingInqAuthClientExW(ClientBinding, Privs, ServerPrincName ? &principal : NULL, @@ -1625,7 +1607,7 @@ RpcBindingInqAuthClientExW( RPC_BINDING_HANDLE ClientBinding, RPC_AUTHZ_HANDLE * { RpcBinding *bind; - TRACE("%p %p %p %p %p %p 0x%x\n", ClientBinding, Privs, ServerPrincName, AuthnLevel, + TRACE("%p %p %p %p %p %p 0x%lx\n", ClientBinding, Privs, ServerPrincName, AuthnLevel, AuthnSvc, AuthzSvc, Flags); if (!ClientBinding) ClientBinding = I_RpcGetCurrentCallHandle(); @@ -1655,8 +1637,8 @@ RpcBindingServerFromClient(RPC_BINDING_HANDLE ClientBinding, RPC_BINDING_HANDLE* return RPC_S_INVALID_BINDING; RPCRT4_AllocBinding(&NewBinding, TRUE); - NewBinding->Protseq = RPCRT4_strdupA(bind->Protseq); - NewBinding->NetworkAddr = RPCRT4_strdupA(bind->NetworkAddr); + NewBinding->Protseq = strdup(bind->Protseq); + NewBinding->NetworkAddr = strdup(bind->NetworkAddr); *ServerBinding = NewBinding; @@ -1681,21 +1663,21 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName, PSecPkgInfoA packages; ULONG cbMaxToken; - TRACE("%p %s %u %u %p %u %p\n", Binding, debugstr_a((const char*)ServerPrincName), + TRACE("%p %s %lu %lu %p %lu %p\n", Binding, debugstr_a((const char*)ServerPrincName), AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvr, SecurityQos); if (SecurityQos) { RPC_STATUS status; - TRACE("SecurityQos { Version=%d, Capabilities=0x%x, IdentityTracking=%d, ImpersonationLevel=%d", + TRACE("SecurityQos { Version=%ld, Capabilities=0x%lx, IdentityTracking=%ld, ImpersonationLevel=%ld", SecurityQos->Version, SecurityQos->Capabilities, SecurityQos->IdentityTracking, SecurityQos->ImpersonationType); if (SecurityQos->Version >= 2) { const RPC_SECURITY_QOS_V2_A *SecurityQos2 = (const RPC_SECURITY_QOS_V2_A *)SecurityQos; - TRACE(", AdditionalSecurityInfoType=%d", SecurityQos2->AdditionalSecurityInfoType); + TRACE(", AdditionalSecurityInfoType=%ld", SecurityQos2->AdditionalSecurityInfoType); if (SecurityQos2->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP) - TRACE(", { %p, 0x%x, %d, %d, %p(%u), %s }", + TRACE(", { %p, 0x%lx, %ld, %ld, %p(%lu), %s }", SecurityQos2->u.HttpCredentials->TransportCredentials, SecurityQos2->u.HttpCredentials->Flags, SecurityQos2->u.HttpCredentials->AuthenticationTarget, @@ -1731,21 +1713,21 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName, if (AuthnLevel > RPC_C_AUTHN_LEVEL_PKT_PRIVACY) { - FIXME("unknown AuthnLevel %u\n", AuthnLevel); + FIXME("unknown AuthnLevel %lu\n", AuthnLevel); return RPC_S_UNKNOWN_AUTHN_LEVEL; } /* RPC_C_AUTHN_WINNT ignores the AuthzSvr parameter */ if (AuthzSvr && AuthnSvc != RPC_C_AUTHN_WINNT) { - FIXME("unsupported AuthzSvr %u\n", AuthzSvr); + FIXME("unsupported AuthzSvr %lu\n", AuthzSvr); return RPC_S_UNKNOWN_AUTHZ_SERVICE; } r = EnumerateSecurityPackagesA(&package_count, &packages); if (r != SEC_E_OK) { - ERR("EnumerateSecurityPackagesA failed with error 0x%08x\n", r); + ERR("EnumerateSecurityPackagesA failed with error 0x%08lx\n", r); return RPC_S_SEC_PKG_ERROR; } @@ -1755,12 +1737,12 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName, if (i == package_count) { - FIXME("unsupported AuthnSvc %u\n", AuthnSvc); + FIXME("unsupported AuthnSvc %lu\n", AuthnSvc); FreeContextBuffer(packages); return RPC_S_UNKNOWN_AUTHN_SERVICE; } - TRACE("found package %s for service %u\n", packages[i].Name, AuthnSvc); + TRACE("found package %s for service %lu\n", packages[i].Name, AuthnSvc); r = AcquireCredentialsHandleA(NULL, packages[i].Name, SECPKG_CRED_OUTBOUND, NULL, AuthIdentity, NULL, NULL, &cred, &exp); cbMaxToken = packages[i].cbMaxToken; @@ -1790,7 +1772,7 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName, } else { - ERR("AcquireCredentialsHandleA failed with error 0x%08x\n", r); + ERR("AcquireCredentialsHandleA failed with error 0x%08lx\n", r); return RPC_S_SEC_PKG_ERROR; } } @@ -1812,21 +1794,21 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, PSecPkgInfoW packages; ULONG cbMaxToken; - TRACE("%p %s %u %u %p %u %p\n", Binding, debugstr_w(ServerPrincName), + TRACE("%p %s %lu %lu %p %lu %p\n", Binding, debugstr_w(ServerPrincName), AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvr, SecurityQos); if (SecurityQos) { RPC_STATUS status; - TRACE("SecurityQos { Version=%d, Capabilities=0x%x, IdentityTracking=%d, ImpersonationLevel=%d", + TRACE("SecurityQos { Version=%ld, Capabilities=0x%lx, IdentityTracking=%ld, ImpersonationLevel=%ld", SecurityQos->Version, SecurityQos->Capabilities, SecurityQos->IdentityTracking, SecurityQos->ImpersonationType); if (SecurityQos->Version >= 2) { const RPC_SECURITY_QOS_V2_W *SecurityQos2 = (const RPC_SECURITY_QOS_V2_W *)SecurityQos; - TRACE(", AdditionalSecurityInfoType=%d", SecurityQos2->AdditionalSecurityInfoType); + TRACE(", AdditionalSecurityInfoType=%ld", SecurityQos2->AdditionalSecurityInfoType); if (SecurityQos2->AdditionalSecurityInfoType == RPC_C_AUTHN_INFO_TYPE_HTTP) - TRACE(", { %p, 0x%x, %d, %d, %p(%u), %s }", + TRACE(", { %p, 0x%lx, %ld, %ld, %p(%lu), %s }", SecurityQos2->u.HttpCredentials->TransportCredentials, SecurityQos2->u.HttpCredentials->Flags, SecurityQos2->u.HttpCredentials->AuthenticationTarget, @@ -1862,21 +1844,21 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, if (AuthnLevel > RPC_C_AUTHN_LEVEL_PKT_PRIVACY) { - FIXME("unknown AuthnLevel %u\n", AuthnLevel); + FIXME("unknown AuthnLevel %lu\n", AuthnLevel); return RPC_S_UNKNOWN_AUTHN_LEVEL; } /* RPC_C_AUTHN_WINNT ignores the AuthzSvr parameter */ if (AuthzSvr && AuthnSvc != RPC_C_AUTHN_WINNT) { - FIXME("unsupported AuthzSvr %u\n", AuthzSvr); + FIXME("unsupported AuthzSvr %lu\n", AuthzSvr); return RPC_S_UNKNOWN_AUTHZ_SERVICE; } r = EnumerateSecurityPackagesW(&package_count, &packages); if (r != SEC_E_OK) { - ERR("EnumerateSecurityPackagesW failed with error 0x%08x\n", r); + ERR("EnumerateSecurityPackagesW failed with error 0x%08lx\n", r); return RPC_S_SEC_PKG_ERROR; } @@ -1886,12 +1868,12 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, if (i == package_count) { - FIXME("unsupported AuthnSvc %u\n", AuthnSvc); + FIXME("unsupported AuthnSvc %lu\n", AuthnSvc); FreeContextBuffer(packages); return RPC_S_UNKNOWN_AUTHN_SERVICE; } - TRACE("found package %s for service %u\n", debugstr_w(packages[i].Name), AuthnSvc); + TRACE("found package %s for service %lu\n", debugstr_w(packages[i].Name), AuthnSvc); r = AcquireCredentialsHandleW(NULL, packages[i].Name, SECPKG_CRED_OUTBOUND, NULL, AuthIdentity, NULL, NULL, &cred, &exp); cbMaxToken = packages[i].cbMaxToken; @@ -1903,7 +1885,7 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, AuthIdentity, &new_auth_info); if (r == RPC_S_OK) { - new_auth_info->server_principal_name = RPCRT4_strdupW(ServerPrincName); + new_auth_info->server_principal_name = wcsdup(ServerPrincName); if (!ServerPrincName || new_auth_info->server_principal_name) { if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo); @@ -1921,7 +1903,7 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, } else { - ERR("AcquireCredentialsHandleW failed with error 0x%08x\n", r); + ERR("AcquireCredentialsHandleW failed with error 0x%08lx\n", r); return RPC_S_SEC_PKG_ERROR; } } @@ -1933,7 +1915,7 @@ RPCRTAPI RPC_STATUS RPC_ENTRY RpcBindingSetAuthInfoA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName, ULONG AuthnLevel, ULONG AuthnSvc, RPC_AUTH_IDENTITY_HANDLE AuthIdentity, ULONG AuthzSvr ) { - TRACE("%p %s %u %u %p %u\n", Binding, debugstr_a((const char*)ServerPrincName), + TRACE("%p %s %lu %lu %p %lu\n", Binding, debugstr_a((const char*)ServerPrincName), AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvr); return RpcBindingSetAuthInfoExA(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvr, NULL); } @@ -1945,7 +1927,7 @@ RPCRTAPI RPC_STATUS RPC_ENTRY RpcBindingSetAuthInfoW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, ULONG AuthnLevel, ULONG AuthnSvc, RPC_AUTH_IDENTITY_HANDLE AuthIdentity, ULONG AuthzSvr ) { - TRACE("%p %s %u %u %p %u\n", Binding, debugstr_w(ServerPrincName), + TRACE("%p %s %lu %lu %p %lu\n", Binding, debugstr_w(ServerPrincName), AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvr); return RpcBindingSetAuthInfoExW(Binding, ServerPrincName, AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvr, NULL); } @@ -1955,7 +1937,7 @@ RpcBindingSetAuthInfoW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, UL */ RPC_STATUS WINAPI RpcBindingSetOption(RPC_BINDING_HANDLE BindingHandle, ULONG Option, ULONG_PTR OptionValue) { - TRACE("(%p, %d, %ld)\n", BindingHandle, Option, OptionValue); + TRACE("(%p, %ld, %Id)\n", BindingHandle, Option, OptionValue); switch (Option) { @@ -1966,15 +1948,15 @@ RPC_STATUS WINAPI RpcBindingSetOption(RPC_BINDING_HANDLE BindingHandle, ULONG Op int len = MultiByteToWideChar(CP_ACP, 0, cookie->Buffer, cookie->BufferSize, NULL, 0); WCHAR *str; - if (!(str = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)))) return RPC_S_OUT_OF_MEMORY; + if (!(str = malloc((len + 1) * sizeof(WCHAR)))) return RPC_S_OUT_OF_MEMORY; MultiByteToWideChar(CP_ACP, 0, cookie->Buffer, cookie->BufferSize, str, len); str[len] = 0; - HeapFree(GetProcessHeap(), 0, binding->CookieAuth); + free(binding->CookieAuth); binding->CookieAuth = str; break; } default: - FIXME("option %u not supported\n", Option); + FIXME("option %lu not supported\n", Option); break; } return RPC_S_OK; @@ -1986,6 +1968,18 @@ RPC_STATUS WINAPI RpcBindingSetOption(RPC_BINDING_HANDLE BindingHandle, ULONG Op RPC_STATUS WINAPI I_RpcBindingInqLocalClientPID(RPC_BINDING_HANDLE ClientBinding, ULONG *ClientPID) { - FIXME("%p %p: stub\n", ClientBinding, ClientPID); - return RPC_S_INVALID_BINDING; + RpcConnection *connection = NULL; + RpcBinding *binding; + + TRACE("%p %p\n", ClientBinding, ClientPID); + + binding = ClientBinding ? ClientBinding : RPCRT4_GetThreadCurrentCallHandle(); + if (!binding) + return RPC_S_NO_CALL_ACTIVE; + + connection = binding->FromConn; + if (!connection->ops->inquire_client_pid) + return RPC_S_INVALID_BINDING; + + return connection->ops->inquire_client_pid(connection, ClientPID); } diff --git a/dll/win32/rpcrt4/rpc_binding.h b/dll/win32/rpcrt4/rpc_binding.h index 8faacbd66e2..a80433d01db 100644 --- a/dll/win32/rpcrt4/rpc_binding.h +++ b/dll/win32/rpcrt4/rpc_binding.h @@ -118,6 +118,7 @@ struct connection_ops { RPC_STATUS (*impersonate_client)(RpcConnection *conn); RPC_STATUS (*revert_to_self)(RpcConnection *conn); RPC_STATUS (*inquire_auth_client)(RpcConnection *, RPC_AUTHZ_HANDLE *, RPC_WSTR *, ULONG *, ULONG *, ULONG *, ULONG); + RPC_STATUS (*inquire_client_pid)(RpcConnection *conn, ULONG *pid); }; /* don't know what MS's structure looks like */ @@ -142,43 +143,38 @@ typedef struct _RpcBinding LPWSTR CookieAuth; } RpcBinding; -LPSTR RPCRT4_strndupA(LPCSTR src, INT len) DECLSPEC_HIDDEN; -LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len) DECLSPEC_HIDDEN; -LPSTR RPCRT4_strdupWtoA(LPCWSTR src) DECLSPEC_HIDDEN; -LPWSTR RPCRT4_strdupAtoW(LPCSTR src) DECLSPEC_HIDDEN; -void RPCRT4_strfree(LPSTR src) DECLSPEC_HIDDEN; +LPWSTR RPCRT4_strndupW(LPCWSTR src, INT len); +LPSTR RPCRT4_strdupWtoA(LPCWSTR src); +LPWSTR RPCRT4_strdupAtoW(LPCSTR src); -#define RPCRT4_strdupA(x) RPCRT4_strndupA((x),-1) -#define RPCRT4_strdupW(x) RPCRT4_strndupW((x),-1) - -RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, CredHandle cred, TimeStamp exp, ULONG cbMaxToken, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret) DECLSPEC_HIDDEN; -ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN; -ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo) DECLSPEC_HIDDEN; -BOOL RpcAuthInfo_IsEqual(const RpcAuthInfo *AuthInfo1, const RpcAuthInfo *AuthInfo2) DECLSPEC_HIDDEN; -ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos) DECLSPEC_HIDDEN; -ULONG RpcQualityOfService_Release(RpcQualityOfService *qos) DECLSPEC_HIDDEN; -BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2) DECLSPEC_HIDDEN; +RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, CredHandle cred, TimeStamp exp, ULONG cbMaxToken, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret); +ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo); +ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo); +BOOL RpcAuthInfo_IsEqual(const RpcAuthInfo *AuthInfo1, const RpcAuthInfo *AuthInfo2); +ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos); +ULONG RpcQualityOfService_Release(RpcQualityOfService *qos); +BOOL RpcQualityOfService_IsEqual(const RpcQualityOfService *qos1, const RpcQualityOfService *qos2); RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, - RpcQualityOfService *QOS, LPCWSTR CookieAuth) DECLSPEC_HIDDEN; -RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn ) DECLSPEC_HIDDEN; -void RPCRT4_ReleaseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_IsServerListening(const char *protseq, const char *endpoint) DECLSPEC_HIDDEN; + RpcQualityOfService *QOS, LPCWSTR CookieAuth); +RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn ); +void RPCRT4_ReleaseConnection(RpcConnection* Connection); +RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection* Connection); +RPC_STATUS RPCRT4_CloseConnection(RpcConnection* Connection); +RPC_STATUS RPCRT4_IsServerListening(const char *protseq, const char *endpoint); -RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection) DECLSPEC_HIDDEN; -void RPCRT4_AddRefBinding(RpcBinding* Binding) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding) DECLSPEC_HIDDEN; +RPC_STATUS RPCRT4_ResolveBinding(RpcBinding* Binding, LPCSTR Endpoint); +RPC_STATUS RPCRT4_SetBindingObject(RpcBinding* Binding, const UUID* ObjectUuid); +RPC_STATUS RPCRT4_MakeBinding(RpcBinding** Binding, RpcConnection* Connection); +void RPCRT4_AddRefBinding(RpcBinding* Binding); +RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding* Binding); RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId, - BOOL *from_cache) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection) DECLSPEC_HIDDEN; + BOOL *from_cache); +RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection); -void rpcrt4_conn_release_and_wait(RpcConnection *connection) DECLSPEC_HIDDEN; +void rpcrt4_conn_release_and_wait(RpcConnection *connection); static inline const char *rpcrt4_conn_get_name(const RpcConnection *Connection) { @@ -258,14 +254,14 @@ static inline RPC_STATUS rpcrt4_conn_inquire_auth_client( } /* floors 3 and up */ -RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint) DECLSPEC_HIDDEN; -RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint) DECLSPEC_HIDDEN; +RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint); +RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint); -void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection) DECLSPEC_HIDDEN; -void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding) DECLSPEC_HIDDEN; -RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void) DECLSPEC_HIDDEN; -void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext) DECLSPEC_HIDDEN; -void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext) DECLSPEC_HIDDEN; -NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void) DECLSPEC_HIDDEN; +void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection); +void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding); +RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void); +void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext); +void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext); +NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void); #endif diff --git a/dll/win32/rpcrt4/rpc_epmap.c b/dll/win32/rpcrt4/rpc_epmap.c index f5f866e84e2..1c1fa84eb75 100644 --- a/dll/win32/rpcrt4/rpc_epmap.c +++ b/dll/win32/rpcrt4/rpc_epmap.c @@ -33,7 +33,7 @@ #include "wine/exception.h" #include "rpc_binding.h" -#include "epm_c.h" +#include "epm.h" #include "epm_towers.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); @@ -78,7 +78,6 @@ static const struct epm_endpoints static BOOL start_rpcss(void) { - static const WCHAR rpcssW[] = {'R','p','c','S','s',0}; SC_HANDLE scm, service; SERVICE_STATUS_PROCESS status; BOOL ret = FALSE; @@ -90,7 +89,7 @@ static BOOL start_rpcss(void) ERR( "failed to open service manager\n" ); return FALSE; } - if (!(service = OpenServiceW( scm, rpcssW, SERVICE_START | SERVICE_QUERY_STATUS ))) + if (!(service = OpenServiceW( scm, L"RpcSs", SERVICE_START | SERVICE_QUERY_STATUS ))) { ERR( "failed to open RpcSs service\n" ); CloseServiceHandle( scm ); @@ -117,7 +116,7 @@ static BOOL start_rpcss(void) } while (status.dwCurrentState == SERVICE_START_PENDING); if (status.dwCurrentState != SERVICE_RUNNING) - WARN( "RpcSs failed to start %u\n", status.dwCurrentState ); + WARN( "RpcSs failed to start %lu\n", status.dwCurrentState ); } else ERR( "failed to start RpcSs service\n" ); @@ -207,24 +206,24 @@ static RPC_STATUS epm_register( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bindin TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID)); for (i=0; iCount; i++) { RpcBinding* bind = BindingVector->BindingH[i]; - TRACE(" protseq[%d]=%s\n", i, debugstr_a(bind->Protseq)); - TRACE(" endpoint[%d]=%s\n", i, debugstr_a(bind->Endpoint)); + TRACE(" protseq[%ld]=%s\n", i, debugstr_a(bind->Protseq)); + TRACE(" endpoint[%ld]=%s\n", i, debugstr_a(bind->Endpoint)); } if (UuidVector) { for (i=0; iCount; i++) - TRACE(" obj[%d]=%s\n", i, debugstr_guid(UuidVector->Uuid[i])); + TRACE(" obj[%ld]=%s\n", i, debugstr_guid(UuidVector->Uuid[i])); } if (!BindingVector->Count) return RPC_S_OK; - entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1)); + entries = calloc(BindingVector->Count * (UuidVector ? UuidVector->Count : 1), sizeof(*entries)); if (!entries) return RPC_S_OUT_OF_MEMORY; status = get_epm_handle_server(&handle); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, entries); + free(entries); return status; } @@ -271,7 +270,7 @@ static RPC_STATUS epm_register( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bindin continue; } if (status2 != RPC_S_OK) - ERR("ept_insert failed with error %d\n", status2); + ERR("ept_insert failed with error %ld\n", status2); status = status2; /* FIXME: convert status? */ break; } @@ -285,7 +284,7 @@ static RPC_STATUS epm_register( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bindin I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower); } - HeapFree(GetProcessHeap(), 0, entries); + free(entries); return status; } @@ -319,7 +318,7 @@ RPC_STATUS WINAPI RpcEpRegisterW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bind status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, TRUE); - HeapFree(GetProcessHeap(), 0, annA); + free(annA); return status; } @@ -334,7 +333,7 @@ RPC_STATUS WINAPI RpcEpRegisterNoReplaceW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VEC status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, FALSE); - HeapFree(GetProcessHeap(), 0, annA); + free(annA); return status; } @@ -355,22 +354,22 @@ RPC_STATUS WINAPI RpcEpUnregister( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bin TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID)); for (i=0; iCount; i++) { RpcBinding* bind = BindingVector->BindingH[i]; - TRACE(" protseq[%d]=%s\n", i, debugstr_a(bind->Protseq)); - TRACE(" endpoint[%d]=%s\n", i, debugstr_a(bind->Endpoint)); + TRACE(" protseq[%ld]=%s\n", i, debugstr_a(bind->Protseq)); + TRACE(" endpoint[%ld]=%s\n", i, debugstr_a(bind->Endpoint)); } if (UuidVector) { for (i=0; iCount; i++) - TRACE(" obj[%d]=%s\n", i, debugstr_guid(UuidVector->Uuid[i])); + TRACE(" obj[%ld]=%s\n", i, debugstr_guid(UuidVector->Uuid[i])); } - entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1)); + entries = calloc(BindingVector->Count * (UuidVector ? UuidVector->Count : 1), sizeof(*entries)); if (!entries) return RPC_S_OUT_OF_MEMORY; status = get_epm_handle_server(&handle); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, entries); + free(entries); return status; } @@ -408,7 +407,7 @@ RPC_STATUS WINAPI RpcEpUnregister( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bin if (status2 == RPC_S_SERVER_UNAVAILABLE) status2 = EPT_S_NOT_REGISTERED; if (status2 != RPC_S_OK) - ERR("ept_insert failed with error %d\n", status2); + ERR("ept_insert failed with error %ld\n", status2); status = status2; /* FIXME: convert status? */ } RpcBindingFree(&handle); @@ -420,7 +419,7 @@ RPC_STATUS WINAPI RpcEpUnregister( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *Bin I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower); } - HeapFree(GetProcessHeap(), 0, entries); + free(entries); return status; } @@ -502,7 +501,7 @@ RPC_STATUS WINAPI RpcEpResolveBinding( RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE if (!resolved_endpoint) { status = TowerExplode(towers[i], NULL, NULL, NULL, &resolved_endpoint, NULL); - TRACE("status = %d\n", status); + TRACE("status = %ld\n", status); } I_RpcFree(towers[i]); } @@ -656,10 +655,10 @@ RPC_STATUS WINAPI TowerConstruct( void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len) { - return HeapAlloc(GetProcessHeap(), 0, len); + return malloc(len); } void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr) { - HeapFree(GetProcessHeap(), 0, ptr); + free(ptr); } diff --git a/dll/win32/rpcrt4/rpc_message.c b/dll/win32/rpcrt4/rpc_message.c index 59cd438a26a..3c5dc5c3f5b 100644 --- a/dll/win32/rpcrt4/rpc_message.c +++ b/dll/win32/rpcrt4/rpc_message.c @@ -22,6 +22,7 @@ #include #include +#include #include #include "windef.h" @@ -105,21 +106,21 @@ static BOOL packet_does_auth_negotiation(const RpcPktHdr *Header) } } -static VOID RPCRT4_BuildCommonHeader(RpcPktHdr *Header, unsigned char PacketType, +static VOID RPCRT4_BuildCommonHeader(RpcPktCommonHdr *Header, unsigned char PacketType, ULONG DataRepresentation) { - Header->common.rpc_ver = RPC_VER_MAJOR; - Header->common.rpc_ver_minor = RPC_VER_MINOR; - Header->common.ptype = PacketType; - Header->common.drep[0] = LOBYTE(LOWORD(DataRepresentation)); - Header->common.drep[1] = HIBYTE(LOWORD(DataRepresentation)); - Header->common.drep[2] = LOBYTE(HIWORD(DataRepresentation)); - Header->common.drep[3] = HIBYTE(HIWORD(DataRepresentation)); - Header->common.auth_len = 0; - Header->common.call_id = 1; - Header->common.flags = 0; + Header->rpc_ver = RPC_VER_MAJOR; + Header->rpc_ver_minor = RPC_VER_MINOR; + Header->ptype = PacketType; + Header->drep[0] = LOBYTE(LOWORD(DataRepresentation)); + Header->drep[1] = HIBYTE(LOWORD(DataRepresentation)); + Header->drep[2] = LOBYTE(HIWORD(DataRepresentation)); + Header->drep[3] = HIBYTE(HIWORD(DataRepresentation)); + Header->auth_len = 0; + Header->call_id = 1; + Header->flags = 0; /* Flags and fragment length are computed in RPCRT4_Send. */ -} +} static RpcPktHdr *RPCRT4_BuildRequestHeader(ULONG DataRepresentation, ULONG BufferLength, @@ -131,13 +132,12 @@ static RpcPktHdr *RPCRT4_BuildRequestHeader(ULONG DataRepresentation, RPC_STATUS status; has_object = (ObjectUuid != NULL && !UuidIsNil(ObjectUuid, &status)); - header = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(header->request) + (has_object ? sizeof(UUID) : 0)); + header = calloc(1, sizeof(header->request) + (has_object ? sizeof(UUID) : 0)); if (header == NULL) { return NULL; } - RPCRT4_BuildCommonHeader(header, PKT_REQUEST, DataRepresentation); + RPCRT4_BuildCommonHeader(&header->common, PKT_REQUEST, DataRepresentation); header->common.frag_len = sizeof(header->request); header->request.alloc_hint = BufferLength; header->request.context_id = 0; @@ -153,34 +153,34 @@ static RpcPktHdr *RPCRT4_BuildRequestHeader(ULONG DataRepresentation, RpcPktHdr *RPCRT4_BuildResponseHeader(ULONG DataRepresentation, ULONG BufferLength) { - RpcPktHdr *header; + RpcPktResponseHdr *header; - header = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(header->response)); + header = calloc(1, sizeof(*header)); if (header == NULL) { return NULL; } - RPCRT4_BuildCommonHeader(header, PKT_RESPONSE, DataRepresentation); - header->common.frag_len = sizeof(header->response); - header->response.alloc_hint = BufferLength; + RPCRT4_BuildCommonHeader(&header->common, PKT_RESPONSE, DataRepresentation); + header->common.frag_len = sizeof(*header); + header->alloc_hint = BufferLength; - return header; + return (RpcPktHdr *)header; } RpcPktHdr *RPCRT4_BuildFaultHeader(ULONG DataRepresentation, RPC_STATUS Status) { - RpcPktHdr *header; + RpcPktFaultHdr *header; - header = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(header->fault)); + header = calloc(1, sizeof(*header)); if (header == NULL) { return NULL; } - RPCRT4_BuildCommonHeader(header, PKT_FAULT, DataRepresentation); - header->common.frag_len = sizeof(header->fault); - header->fault.status = Status; + RPCRT4_BuildCommonHeader(&header->common, PKT_FAULT, DataRepresentation); + header->common.frag_len = sizeof(*header); + header->status = Status; - return header; + return (RpcPktHdr *)header; } RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation, @@ -193,14 +193,13 @@ RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation, RpcPktHdr *header; RpcContextElement *ctxt_elem; - header = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(header->bind) + FIELD_OFFSET(RpcContextElement, transfer_syntaxes[1])); + header = calloc(1, sizeof(header->bind) + FIELD_OFFSET(RpcContextElement, transfer_syntaxes[1])); if (header == NULL) { return NULL; } ctxt_elem = (RpcContextElement *)(&header->bind + 1); - RPCRT4_BuildCommonHeader(header, PKT_BIND, DataRepresentation); + RPCRT4_BuildCommonHeader(&header->common, PKT_BIND, DataRepresentation); header->common.frag_len = sizeof(header->bind) + FIELD_OFFSET(RpcContextElement, transfer_syntaxes[1]); header->bind.max_tsize = MaxTransmissionSize; header->bind.max_rsize = MaxReceiveSize; @@ -215,17 +214,16 @@ RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation, static RpcPktHdr *RPCRT4_BuildAuthHeader(ULONG DataRepresentation) { - RpcPktHdr *header; + RpcPktAuth3Hdr *header; - header = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(header->auth3)); + header = calloc(1, sizeof(*header)); if (header == NULL) return NULL; - RPCRT4_BuildCommonHeader(header, PKT_AUTH3, DataRepresentation); - header->common.frag_len = sizeof(header->auth3); + RPCRT4_BuildCommonHeader(&header->common, PKT_AUTH3, DataRepresentation); + header->common.frag_len = sizeof(*header); - return header; + return (RpcPktHdr*)header; } RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation, @@ -233,21 +231,24 @@ RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation, unsigned char RpcVersionMinor, unsigned short RejectReason) { - RpcPktHdr *header; + RpcPktBindNAckHdr *header; +#ifndef _MSC_VER + C_ASSERT(sizeof(*header) >= FIELD_OFFSET(RpcPktBindNAckHdr, protocols[1])); +#endif - header = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(RpcPktHdr, bind_nack.protocols[1])); + header = calloc(1, sizeof(*header)); if (header == NULL) { return NULL; } - RPCRT4_BuildCommonHeader(header, PKT_BIND_NACK, DataRepresentation); - header->common.frag_len = FIELD_OFFSET(RpcPktHdr, bind_nack.protocols[1]); - header->bind_nack.reject_reason = RejectReason; - header->bind_nack.protocols_count = 1; - header->bind_nack.protocols[0].rpc_ver = RpcVersion; - header->bind_nack.protocols[0].rpc_ver_minor = RpcVersionMinor; + RPCRT4_BuildCommonHeader(&header->common, PKT_BIND_NACK, DataRepresentation); + header->common.frag_len = FIELD_OFFSET(RpcPktBindNAckHdr, protocols[1]); + header->reject_reason = RejectReason; + header->protocols_count = 1; + header->protocols[0].rpc_ver = RpcVersion; + header->protocols[0].rpc_ver_minor = RpcVersionMinor; - return header; + return (RpcPktHdr *)header; } RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation, @@ -267,12 +268,12 @@ RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation, ROUND_UP(FIELD_OFFSET(RpcAddressString, string[strlen(ServerAddress) + 1]), 4) + FIELD_OFFSET(RpcResultList, results[ResultCount]); - header = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, header_size); + header = calloc(1, header_size); if (header == NULL) { return NULL; } - RPCRT4_BuildCommonHeader(header, PKT_BIND_ACK, DataRepresentation); + RPCRT4_BuildCommonHeader(&header->common, PKT_BIND_ACK, DataRepresentation); header->common.frag_len = header_size; header->bind_ack.max_tsize = MaxTransmissionSize; header->bind_ack.max_rsize = MaxReceiveSize; @@ -295,13 +296,13 @@ RpcPktHdr *RPCRT4_BuildHttpHeader(ULONG DataRepresentation, { RpcPktHdr *header; - header = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(header->http) + payload_size); + header = calloc(1, sizeof(header->http) + payload_size); if (header == NULL) { ERR("failed to allocate memory\n"); return NULL; } - RPCRT4_BuildCommonHeader(header, PKT_HTTP, DataRepresentation); + RPCRT4_BuildCommonHeader(&header->common, PKT_HTTP, DataRepresentation); /* since the packet isn't current sent using RPCRT4_Send, set the flags * manually here */ header->common.flags = RPC_FLG_FIRST|RPC_FLG_LAST; @@ -400,11 +401,6 @@ RpcPktHdr *RPCRT4_BuildHttpFlowControlHeader(BOOL server, ULONG bytes_transmitte return header; } -VOID RPCRT4_FreeHeader(RpcPktHdr *Header) -{ - HeapFree(GetProcessHeap(), 0, Header); -} - NCA_STATUS RPC2NCA_STATUS(RPC_STATUS status) { switch (status) @@ -524,7 +520,7 @@ BOOL RPCRT4_IsValidHttpPacket(RpcPktHdr *hdr, unsigned char *data, data_len -= 24; break; default: - FIXME("unimplemented type 0x%x\n", type); + FIXME("unimplemented type 0x%lx\n", type); break; } } @@ -554,7 +550,7 @@ static unsigned char *RPCRT4_NextHttpHeaderField(unsigned char *data) case 0x1: return data + 24; default: - FIXME("unimplemented type 0x%x\n", type); + FIXME("unimplemented type 0x%lx\n", type); return data; } } @@ -580,7 +576,7 @@ RPC_STATUS RPCRT4_ParseHttpPrepareHeader1(RpcPktHdr *header, type = READ_HTTP_PAYLOAD_FIELD_TYPE(data); if (type != 0x00000002) { - ERR("invalid type 0x%08x\n", type); + ERR("invalid type 0x%08lx\n", type); return RPC_S_PROTOCOL_ERROR; } *field1 = *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data); @@ -608,7 +604,7 @@ RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, type = READ_HTTP_PAYLOAD_FIELD_TYPE(data); if (type != 0x00000006) { - ERR("invalid type for field 1: 0x%08x\n", type); + ERR("invalid type for field 1: 0x%08lx\n", type); return RPC_S_PROTOCOL_ERROR; } *field1 = *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data); @@ -617,7 +613,7 @@ RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, type = READ_HTTP_PAYLOAD_FIELD_TYPE(data); if (type != 0x00000000) { - ERR("invalid type for field 2: 0x%08x\n", type); + ERR("invalid type for field 2: 0x%08lx\n", type); return RPC_S_PROTOCOL_ERROR; } *bytes_until_next_packet = *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data); @@ -626,7 +622,7 @@ RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, type = READ_HTTP_PAYLOAD_FIELD_TYPE(data); if (type != 0x00000002) { - ERR("invalid type for field 3: 0x%08x\n", type); + ERR("invalid type for field 3: 0x%08lx\n", type); return RPC_S_PROTOCOL_ERROR; } *field3 = *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data); @@ -655,12 +651,12 @@ RPC_STATUS RPCRT4_ParseHttpFlowControlHeader(RpcPktHdr *header, type = READ_HTTP_PAYLOAD_FIELD_TYPE(data); if (type != 0x0000000d) { - ERR("invalid type for field 1: 0x%08x\n", type); + ERR("invalid type for field 1: 0x%08lx\n", type); return RPC_S_PROTOCOL_ERROR; } if (*(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data) != (server ? 0x3 : 0x0)) { - ERR("invalid type for 0xd field data: 0x%08x\n", *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data)); + ERR("invalid type for 0xd field data: 0x%08lx\n", *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data)); return RPC_S_PROTOCOL_ERROR; } data = RPCRT4_NextHttpHeaderField(data); @@ -668,7 +664,7 @@ RPC_STATUS RPCRT4_ParseHttpFlowControlHeader(RpcPktHdr *header, type = READ_HTTP_PAYLOAD_FIELD_TYPE(data); if (type != 0x00000001) { - ERR("invalid type for field 2: 0x%08x\n", type); + ERR("invalid type for field 2: 0x%08lx\n", type); return RPC_S_PROTOCOL_ERROR; } *bytes_transmitted = *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data); @@ -714,7 +710,7 @@ RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection, sec_status = EncryptMessage(&Connection->ctx, 0, &message, 0 /* FIXME */); if (sec_status != SEC_E_OK) { - ERR("EncryptMessage failed with 0x%08x\n", sec_status); + ERR("EncryptMessage failed with 0x%08lx\n", sec_status); return RPC_S_SEC_PKG_ERROR; } } @@ -723,7 +719,7 @@ RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection, sec_status = MakeSignature(&Connection->ctx, 0, &message, 0 /* FIXME */); if (sec_status != SEC_E_OK) { - ERR("MakeSignature failed with 0x%08x\n", sec_status); + ERR("MakeSignature failed with 0x%08lx\n", sec_status); return RPC_S_SEC_PKG_ERROR; } } @@ -735,7 +731,7 @@ RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection, sec_status = DecryptMessage(&Connection->ctx, &message, 0 /* FIXME */, 0); if (sec_status != SEC_E_OK) { - ERR("DecryptMessage failed with 0x%08x\n", sec_status); + ERR("DecryptMessage failed with 0x%08lx\n", sec_status); return RPC_S_SEC_PKG_ERROR; } } @@ -744,7 +740,7 @@ RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection, sec_status = VerifySignature(&Connection->ctx, &message, 0 /* FIXME */, NULL); if (sec_status != SEC_E_OK) { - ERR("VerifySignature failed with 0x%08x\n", sec_status); + ERR("VerifySignature failed with 0x%08lx\n", sec_status); return RPC_S_SEC_PKG_ERROR; } } @@ -752,10 +748,10 @@ RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection, return RPC_S_OK; } - + /*********************************************************************** * RPCRT4_SendWithAuth (internal) - * + * * Transmit a packet with authorization data over connection in acceptable fragments. */ RPC_STATUS RPCRT4_SendWithAuth(RpcConnection *Connection, RpcPktHdr *Header, @@ -806,7 +802,7 @@ RPC_STATUS RPCRT4_SendWithAuth(RpcConnection *Connection, RpcPktHdr *Header, hdr_size + alen; } - pkt = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Header->common.frag_len); + pkt = calloc(1, Header->common.frag_len); memcpy(pkt, Header, hdr_size); @@ -839,7 +835,7 @@ RPC_STATUS RPCRT4_SendWithAuth(RpcConnection *Connection, RpcPktHdr *Header, (unsigned char *)(auth_hdr + 1), Header->common.auth_len); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, pkt); + free(pkt); RPCRT4_SetThreadCurrentConnection(NULL); return status; } @@ -848,7 +844,7 @@ RPC_STATUS RPCRT4_SendWithAuth(RpcConnection *Connection, RpcPktHdr *Header, write: count = rpcrt4_conn_write(Connection, pkt, Header->common.frag_len); - HeapFree(GetProcessHeap(), 0, pkt); + free(pkt); if (count<0) { WARN("rpcrt4_conn_write failed (auth)\n"); RPCRT4_SetThreadCurrentConnection(NULL); @@ -945,11 +941,11 @@ RPC_STATUS RPCRT4_default_authorize(RpcConnection *conn, BOOL first_time, } if (FAILED(r)) { - WARN("InitializeSecurityContext failed with error 0x%08x\n", r); + WARN("InitializeSecurityContext failed with error 0x%08lx\n", r); goto failed; } - TRACE("r = 0x%08x, attr = 0x%08x\n", r, conn->attr); + TRACE("r = 0x%08lx, attr = 0x%08lx\n", r, conn->attr); continue_needed = ((r == SEC_I_CONTINUE_NEEDED) || (r == SEC_I_COMPLETE_AND_CONTINUE)); @@ -959,19 +955,19 @@ RPC_STATUS RPCRT4_default_authorize(RpcConnection *conn, BOOL first_time, r = CompleteAuthToken(&conn->ctx, &out_desc); if (FAILED(r)) { - WARN("CompleteAuthToken failed with error 0x%08x\n", r); + WARN("CompleteAuthToken failed with error 0x%08lx\n", r); goto failed; } } - TRACE("cbBuffer = %d\n", out.cbBuffer); + TRACE("cbBuffer = %ld\n", out.cbBuffer); if (!continue_needed) { r = QueryContextAttributesA(&conn->ctx, SECPKG_ATTR_SIZES, &secctx_sizes); if (FAILED(r)) { - WARN("QueryContextAttributes failed with error 0x%08x\n", r); + WARN("QueryContextAttributes failed with error 0x%08lx\n", r); goto failed; } conn->signature_auth_len = secctx_sizes.cbMaxSignature; @@ -997,11 +993,11 @@ RPC_STATUS RPCRT4_ClientConnectionAuth(RpcConnection* conn, BYTE *challenge, unsigned char *out_buffer; unsigned int out_len = 0; - TRACE("challenge %s, %d bytes\n", challenge, count); + TRACE("challenge %s, %ld bytes\n", challenge, count); status = rpcrt4_conn_authorize(conn, FALSE, challenge, count, NULL, &out_len); if (status) return status; - out_buffer = HeapAlloc(GetProcessHeap(), 0, out_len); + out_buffer = malloc(out_len); if (!out_buffer) return RPC_S_OUT_OF_RESOURCES; status = rpcrt4_conn_authorize(conn, FALSE, challenge, count, out_buffer, &out_len); if (status) return status; @@ -1013,8 +1009,8 @@ RPC_STATUS RPCRT4_ClientConnectionAuth(RpcConnection* conn, BYTE *challenge, else status = RPC_S_OUT_OF_RESOURCES; - HeapFree(GetProcessHeap(), 0, out_buffer); - RPCRT4_FreeHeader(resp_hdr); + free(out_buffer); + free(resp_hdr); return status; } @@ -1086,7 +1082,7 @@ RPC_STATUS RPCRT4_ServerConnectionAuth(RpcConnection* conn, auth_length_in - sizeof(RpcAuthVerifier), NULL, &out_size); if (status) return status; - out_buffer = HeapAlloc(GetProcessHeap(), 0, out_size); + out_buffer = malloc(out_size); if (!out_buffer) return RPC_S_OUT_OF_RESOURCES; status = rpcrt4_conn_authorize( @@ -1094,7 +1090,7 @@ RPC_STATUS RPCRT4_ServerConnectionAuth(RpcConnection* conn, auth_length_in - sizeof(RpcAuthVerifier), out_buffer, &out_size); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, out_buffer); + free(out_buffer); return status; } @@ -1102,7 +1098,7 @@ RPC_STATUS RPCRT4_ServerConnectionAuth(RpcConnection* conn, { ERR("expected authentication to be complete but SSP returned data of " "%u bytes to be sent back to client\n", out_size); - HeapFree(GetProcessHeap(), 0, out_buffer); + free(out_buffer); return RPC_S_SEC_PKG_ERROR; } else @@ -1138,7 +1134,7 @@ RPC_STATUS RPCRT4_default_impersonate_client(RpcConnection *conn) return RPC_S_NO_CONTEXT_AVAILABLE; sec_status = ImpersonateSecurityContext(&conn->ctx); if (sec_status != SEC_E_OK) - WARN("ImpersonateSecurityContext returned 0x%08x\n", sec_status); + WARN("ImpersonateSecurityContext returned 0x%08lx\n", sec_status); switch (sec_status) { case SEC_E_UNSUPPORTED_FUNCTION: @@ -1166,7 +1162,7 @@ RPC_STATUS RPCRT4_default_revert_to_self(RpcConnection *conn) return RPC_S_NO_CONTEXT_AVAILABLE; sec_status = RevertSecurityContext(&conn->ctx); if (sec_status != SEC_E_OK) - WARN("RevertSecurityContext returned 0x%08x\n", sec_status); + WARN("RevertSecurityContext returned 0x%08lx\n", sec_status); switch (sec_status) { case SEC_E_UNSUPPORTED_FUNCTION: @@ -1199,7 +1195,7 @@ RPC_STATUS RPCRT4_default_inquire_auth_client( } if (server_princ_name) { - *server_princ_name = RPCRT4_strdupW(conn->AuthInfo->server_principal_name); + *server_princ_name = wcsdup(conn->AuthInfo->server_principal_name); if (!*server_princ_name) return ERROR_OUTOFMEMORY; } if (authn_level) *authn_level = conn->AuthInfo->AuthnLevel; @@ -1210,14 +1206,14 @@ RPC_STATUS RPCRT4_default_inquire_auth_client( *authz_svc = RPC_C_AUTHZ_NONE; } if (flags) - FIXME("flags 0x%x not implemented\n", flags); + FIXME("flags 0x%lx not implemented\n", flags); return RPC_S_OK; } /*********************************************************************** * RPCRT4_Send (internal) - * + * * Transmit a packet over connection in acceptable fragments. */ RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, @@ -1235,7 +1231,7 @@ RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, r = rpcrt4_conn_authorize(Connection, TRUE, NULL, 0, NULL, &out_size); if (r != RPC_S_OK) return r; - out_buffer = HeapAlloc(GetProcessHeap(), 0, out_size); + out_buffer = malloc(out_size); if (!out_buffer) return RPC_S_OUT_OF_RESOURCES; /* tack on a negotiate packet */ @@ -1243,7 +1239,7 @@ RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, if (r == RPC_S_OK) r = RPCRT4_SendWithAuth(Connection, Header, Buffer, BufferLength, out_buffer, out_size); - HeapFree(GetProcessHeap(), 0, out_buffer); + free(out_buffer); } else r = RPCRT4_SendWithAuth(Connection, Header, Buffer, BufferLength, NULL, 0); @@ -1282,7 +1278,7 @@ RPC_STATUS RPCRT4_ValidateCommonHeader(const RpcPktCommonHdr *hdr) /*********************************************************************** * RPCRT4_default_receive_fragment (internal) - * + * * Receive a fragment from a connection. */ static RPC_STATUS RPCRT4_default_receive_fragment(RpcConnection *Connection, RpcPktHdr **Header, void **Payload) @@ -1300,7 +1296,7 @@ static RPC_STATUS RPCRT4_default_receive_fragment(RpcConnection *Connection, Rpc /* read packet common header */ dwRead = rpcrt4_conn_read(Connection, &common_hdr, sizeof(common_hdr)); if (dwRead != sizeof(common_hdr)) { - WARN("Short read of header, %d bytes\n", dwRead); + WARN("Short read of header, %ld bytes\n", dwRead); status = RPC_S_CALL_FAILED; goto fail; } @@ -1315,20 +1311,20 @@ static RPC_STATUS RPCRT4_default_receive_fragment(RpcConnection *Connection, Rpc goto fail; } - *Header = HeapAlloc(GetProcessHeap(), 0, hdr_length); + *Header = malloc(hdr_length); memcpy(*Header, &common_hdr, sizeof(common_hdr)); /* read the rest of packet header */ dwRead = rpcrt4_conn_read(Connection, &(*Header)->common + 1, hdr_length - sizeof(common_hdr)); if (dwRead != hdr_length - sizeof(common_hdr)) { - WARN("bad header length, %d bytes, hdr_length %d\n", dwRead, hdr_length); + WARN("bad header length, %ld bytes, hdr_length %ld\n", dwRead, hdr_length); status = RPC_S_CALL_FAILED; goto fail; } if (common_hdr.frag_len - hdr_length) { - *Payload = HeapAlloc(GetProcessHeap(), 0, common_hdr.frag_len - hdr_length); + *Payload = malloc(common_hdr.frag_len - hdr_length); if (!*Payload) { status = RPC_S_OUT_OF_RESOURCES; @@ -1338,7 +1334,7 @@ static RPC_STATUS RPCRT4_default_receive_fragment(RpcConnection *Connection, Rpc dwRead = rpcrt4_conn_read(Connection, *Payload, common_hdr.frag_len - hdr_length); if (dwRead != common_hdr.frag_len - hdr_length) { - WARN("bad data length, %d/%d\n", dwRead, common_hdr.frag_len - hdr_length); + WARN("bad data length, %ld/%ld\n", dwRead, common_hdr.frag_len - hdr_length); status = RPC_S_CALL_FAILED; goto fail; } @@ -1351,9 +1347,9 @@ static RPC_STATUS RPCRT4_default_receive_fragment(RpcConnection *Connection, Rpc fail: if (status != RPC_S_OK) { - RPCRT4_FreeHeader(*Header); + free(*Header); *Header = NULL; - HeapFree(GetProcessHeap(), 0, *Payload); + free(*Payload); *Payload = NULL; } return status; @@ -1426,7 +1422,7 @@ RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, first_flag = RPC_FLG_FIRST; auth_length = (*Header)->common.auth_len; if (auth_length) { - auth_data = HeapAlloc(GetProcessHeap(), 0, RPC_AUTH_VERIFIER_LEN(&(*Header)->common)); + auth_data = malloc(RPC_AUTH_VERIFIER_LEN(&(*Header)->common)); if (!auth_data) { status = RPC_S_OUT_OF_RESOURCES; goto fail; @@ -1442,14 +1438,14 @@ RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, if ((CurrentHeader->common.frag_len < hdr_length) || (CurrentHeader->common.frag_len - hdr_length < header_auth_len)) { - WARN("frag_len %d too small for hdr_length %d and auth_len %d\n", + WARN("frag_len %d too small for hdr_length %ld and auth_len %d\n", CurrentHeader->common.frag_len, hdr_length, CurrentHeader->common.auth_len); status = RPC_S_PROTOCOL_ERROR; goto fail; } if (CurrentHeader->common.auth_len != auth_length) { - WARN("auth_len header field changed from %d to %d\n", + WARN("auth_len header field changed from %ld to %d\n", auth_length, CurrentHeader->common.auth_len); status = RPC_S_PROTOCOL_ERROR; goto fail; @@ -1463,7 +1459,7 @@ RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, data_length = CurrentHeader->common.frag_len - hdr_length - header_auth_len; if (data_length + buffer_length > pMsg->BufferLength) { - TRACE("allocation hint exceeded, new buffer length = %d\n", + TRACE("allocation hint exceeded, new buffer length = %ld\n", data_length + buffer_length); pMsg->BufferLength = data_length + buffer_length; status = I_RpcReAllocateBuffer(pMsg); @@ -1507,10 +1503,10 @@ RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, if (*Header != CurrentHeader) { - RPCRT4_FreeHeader(CurrentHeader); + free(CurrentHeader); CurrentHeader = NULL; } - HeapFree(GetProcessHeap(), 0, payload); + free(payload); payload = NULL; status = RPCRT4_receive_fragment(Connection, &CurrentHeader, &payload); @@ -1529,11 +1525,11 @@ RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, fail: RPCRT4_SetThreadCurrentConnection(NULL); if (CurrentHeader != *Header) - RPCRT4_FreeHeader(CurrentHeader); + free(CurrentHeader); if (status != RPC_S_OK) { I_RpcFree(pMsg->Buffer); pMsg->Buffer = NULL; - RPCRT4_FreeHeader(*Header); + free(*Header); *Header = NULL; } if (auth_data_out && status == RPC_S_OK) { @@ -1541,8 +1537,8 @@ fail: *auth_data_out = auth_data; } else - HeapFree(GetProcessHeap(), 0, auth_data); - HeapFree(GetProcessHeap(), 0, payload); + free(auth_data); + free(payload); return status; } @@ -1644,7 +1640,7 @@ RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg) if (!bind) { - ERR("no binding\n"); + WARN("no binding\n"); return RPC_S_INVALID_BINDING; } @@ -1672,7 +1668,7 @@ RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg) static RPC_STATUS I_RpcReAllocateBuffer(PRPC_MESSAGE pMsg) { TRACE("(%p): BufferLength=%d\n", pMsg, pMsg->BufferLength); - pMsg->Buffer = HeapReAlloc(GetProcessHeap(), 0, pMsg->Buffer, pMsg->BufferLength); + pMsg->Buffer = realloc(pMsg->Buffer, pMsg->BufferLength); TRACE("Buffer=%p\n", pMsg->Buffer); return pMsg->Buffer ? RPC_S_OK : ERROR_OUTOFMEMORY; @@ -1741,7 +1737,7 @@ static DWORD WINAPI async_notifier_proc(LPVOID p) QueueUserAPC(async_apc_notifier_proc, state->u.APC.hThread, (ULONG_PTR)state); break; case RpcNotificationTypeIoc: - TRACE("RpcNotificationTypeIoc %p, 0x%x, 0x%lx, %p\n", + TRACE("RpcNotificationTypeIoc %p, 0x%lx, 0x%Ix, %p\n", state->u.IOC.hIOPort, state->u.IOC.dwNumberOfBytesTransferred, state->u.IOC.dwCompletionKey, state->u.IOC.lpOverlapped); PostQueuedCompletionStatus(state->u.IOC.hIOPort, @@ -1811,7 +1807,7 @@ RPC_STATUS WINAPI I_RpcSend(PRPC_MESSAGE pMsg) hdr->common.call_id = conn->NextCallId++; status = RPCRT4_Send(conn, hdr, pMsg->Buffer, pMsg->BufferLength); - RPCRT4_FreeHeader(hdr); + free(hdr); if (status == RPC_S_OK || conn->server || !from_cache) break; @@ -1867,7 +1863,7 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg) conn = pMsg->ReservedForRuntime; status = RPCRT4_Receive(conn, &hdr, pMsg); if (status != RPC_S_OK) { - WARN("receive failed with error %x\n", status); + WARN("receive failed with error %lx\n", status); goto fail; } @@ -1887,11 +1883,11 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg) } /* success */ - RPCRT4_FreeHeader(hdr); + free(hdr); return status; fail: - RPCRT4_FreeHeader(hdr); + free(hdr); RPCRT4_ReleaseConnection(conn); pMsg->ReservedForRuntime = NULL; return status; @@ -1976,6 +1972,6 @@ RPC_STATUS WINAPI I_RpcAsyncSetHandle(PRPC_MESSAGE pMsg, PRPC_ASYNC_STATE pAsync */ RPC_STATUS WINAPI I_RpcAsyncAbortCall(PRPC_ASYNC_STATE pAsync, ULONG ExceptionCode) { - FIXME("(%p, %d): stub\n", pAsync, ExceptionCode); + FIXME("(%p, %ld): stub\n", pAsync, ExceptionCode); return RPC_S_INVALID_ASYNC_HANDLE; } diff --git a/dll/win32/rpcrt4/rpc_message.h b/dll/win32/rpcrt4/rpc_message.h index a3729cc784d..c156554c1d0 100644 --- a/dll/win32/rpcrt4/rpc_message.h +++ b/dll/win32/rpcrt4/rpc_message.h @@ -25,35 +25,34 @@ typedef unsigned int NCA_STATUS; -RpcPktHdr *RPCRT4_BuildFaultHeader(ULONG DataRepresentation, RPC_STATUS Status) DECLSPEC_HIDDEN; -RpcPktHdr *RPCRT4_BuildResponseHeader(ULONG DataRepresentation, ULONG BufferLength) DECLSPEC_HIDDEN; -RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation, unsigned short MaxTransmissionSize, unsigned short MaxReceiveSize, ULONG AssocGroupId, const RPC_SYNTAX_IDENTIFIER *AbstractId, const RPC_SYNTAX_IDENTIFIER *TransferId) DECLSPEC_HIDDEN; -RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation, unsigned char RpcVersion, unsigned char RpcVersionMinor, unsigned short RejectReason) DECLSPEC_HIDDEN; -RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation, unsigned short MaxTransmissionSize, unsigned short MaxReceiveSize, ULONG AssocGroupId, LPCSTR ServerAddress, unsigned char ResultCount, const RpcResult *Results) DECLSPEC_HIDDEN; -RpcPktHdr *RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size) DECLSPEC_HIDDEN; -RpcPktHdr *RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid) DECLSPEC_HIDDEN; -RpcPktHdr *RPCRT4_BuildHttpFlowControlHeader(BOOL server, ULONG bytes_transmitted, ULONG flow_control_increment, const UUID *pipe_uuid) DECLSPEC_HIDDEN; -VOID RPCRT4_FreeHeader(RpcPktHdr *Header) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_SendWithAuth(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength, const void *Auth, unsigned int AuthLength) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg, unsigned char **auth_data_out, ULONG *auth_length_out) DECLSPEC_HIDDEN; -DWORD RPCRT4_GetHeaderSize(const RpcPktHdr *Header) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ValidateCommonHeader(const RpcPktCommonHdr *hdr) DECLSPEC_HIDDEN; +RpcPktHdr *RPCRT4_BuildFaultHeader(ULONG DataRepresentation, RPC_STATUS Status); +RpcPktHdr *RPCRT4_BuildResponseHeader(ULONG DataRepresentation, ULONG BufferLength); +RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation, unsigned short MaxTransmissionSize, unsigned short MaxReceiveSize, ULONG AssocGroupId, const RPC_SYNTAX_IDENTIFIER *AbstractId, const RPC_SYNTAX_IDENTIFIER *TransferId); +RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation, unsigned char RpcVersion, unsigned char RpcVersionMinor, unsigned short RejectReason); +RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation, unsigned short MaxTransmissionSize, unsigned short MaxReceiveSize, ULONG AssocGroupId, LPCSTR ServerAddress, unsigned char ResultCount, const RpcResult *Results); +RpcPktHdr *RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size); +RpcPktHdr *RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid); +RpcPktHdr *RPCRT4_BuildHttpFlowControlHeader(BOOL server, ULONG bytes_transmitted, ULONG flow_control_increment, const UUID *pipe_uuid); +RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength); +RPC_STATUS RPCRT4_SendWithAuth(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength, const void *Auth, unsigned int AuthLength); +RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg, unsigned char **auth_data_out, ULONG *auth_length_out); +DWORD RPCRT4_GetHeaderSize(const RpcPktHdr *Header); +RPC_STATUS RPCRT4_ValidateCommonHeader(const RpcPktCommonHdr *hdr); -BOOL RPCRT4_IsValidHttpPacket(RpcPktHdr *hdr, unsigned char *data, unsigned short data_len) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ParseHttpPrepareHeader1(RpcPktHdr *header, unsigned char *data, ULONG *field1) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, unsigned char *data, ULONG *field1, ULONG *bytes_until_next_packet, ULONG *field3) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ParseHttpFlowControlHeader(RpcPktHdr *header, unsigned char *data, BOOL server, ULONG *bytes_transmitted, ULONG *flow_control_increment, UUID *pipe_uuid) DECLSPEC_HIDDEN; -NCA_STATUS RPC2NCA_STATUS(RPC_STATUS status) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ClientConnectionAuth(RpcConnection* conn, BYTE *challenge, ULONG count) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ServerConnectionAuth(RpcConnection* conn, BOOL start, RpcAuthVerifier *auth_data_in, ULONG auth_length_in, unsigned char **auth_data_out, ULONG *auth_length_out) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_AuthorizeConnection(RpcConnection* conn, BYTE *challenge, ULONG count) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_ServerGetRegisteredAuthInfo(USHORT auth_type, CredHandle *cred, TimeStamp *exp, ULONG *max_token) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_default_authorize(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_size, unsigned char *out_buffer, unsigned int *out_size) DECLSPEC_HIDDEN; -BOOL RPCRT4_default_is_authorized(RpcConnection *Connection) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection, enum secure_packet_direction dir, RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data, unsigned int stub_data_size, RpcAuthVerifier *auth_hdr, unsigned char *auth_value, unsigned int auth_value_size) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_default_impersonate_client(RpcConnection *conn) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_default_revert_to_self(RpcConnection *conn) DECLSPEC_HIDDEN; -RPC_STATUS RPCRT4_default_inquire_auth_client(RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name, ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags) DECLSPEC_HIDDEN; +BOOL RPCRT4_IsValidHttpPacket(RpcPktHdr *hdr, unsigned char *data, unsigned short data_len); +RPC_STATUS RPCRT4_ParseHttpPrepareHeader1(RpcPktHdr *header, unsigned char *data, ULONG *field1); +RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, unsigned char *data, ULONG *field1, ULONG *bytes_until_next_packet, ULONG *field3); +RPC_STATUS RPCRT4_ParseHttpFlowControlHeader(RpcPktHdr *header, unsigned char *data, BOOL server, ULONG *bytes_transmitted, ULONG *flow_control_increment, UUID *pipe_uuid); +NCA_STATUS RPC2NCA_STATUS(RPC_STATUS status); +RPC_STATUS RPCRT4_ClientConnectionAuth(RpcConnection* conn, BYTE *challenge, ULONG count); +RPC_STATUS RPCRT4_ServerConnectionAuth(RpcConnection* conn, BOOL start, RpcAuthVerifier *auth_data_in, ULONG auth_length_in, unsigned char **auth_data_out, ULONG *auth_length_out); +RPC_STATUS RPCRT4_AuthorizeConnection(RpcConnection* conn, BYTE *challenge, ULONG count); +RPC_STATUS RPCRT4_ServerGetRegisteredAuthInfo(USHORT auth_type, CredHandle *cred, TimeStamp *exp, ULONG *max_token); +RPC_STATUS RPCRT4_default_authorize(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_size, unsigned char *out_buffer, unsigned int *out_size); +BOOL RPCRT4_default_is_authorized(RpcConnection *Connection); +RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection, enum secure_packet_direction dir, RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data, unsigned int stub_data_size, RpcAuthVerifier *auth_hdr, unsigned char *auth_value, unsigned int auth_value_size); +RPC_STATUS RPCRT4_default_impersonate_client(RpcConnection *conn); +RPC_STATUS RPCRT4_default_revert_to_self(RpcConnection *conn); +RPC_STATUS RPCRT4_default_inquire_auth_client(RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name, ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags); #endif diff --git a/dll/win32/rpcrt4/rpc_server.c b/dll/win32/rpcrt4/rpc_server.c index a7cad5e273f..02193b862ba 100644 --- a/dll/win32/rpcrt4/rpc_server.c +++ b/dll/win32/rpcrt4/rpc_server.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -164,7 +165,7 @@ static void RPCRT4_release_server_interface(RpcServerInterface *sif) * CallsCompletedEvent is set */ if (sif->CallsCompletedEvent) SetEvent(sif->CallsCompletedEvent); - HeapFree(GetProcessHeap(), 0, sif); + free(sif); } } @@ -190,7 +191,7 @@ static RpcPktHdr *handle_bind_error(RpcConnection *conn, RPC_STATUS error) reject_reason = REJECT_INVALID_CHECKSUM; break; default: - FIXME("unexpected status value %d\n", error); + FIXME("unexpected status value %ld\n", error); /* fall through */ case RPC_S_INVALID_BOUND: reject_reason = REJECT_REASON_NOT_SPECIFIED; @@ -234,8 +235,7 @@ static RPC_STATUS process_bind_packet_no_send( return RPC_S_INVALID_BOUND; } - results = HeapAlloc(GetProcessHeap(), 0, - hdr->num_elements * sizeof(*results)); + results = malloc(hdr->num_elements * sizeof(*results)); if (!results) return RPC_S_OUT_OF_RESOURCES; @@ -290,7 +290,7 @@ static RPC_STATUS process_bind_packet_no_send( status = RPCRT4_MakeBinding(&conn->server_binding, conn); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, results); + free(results); return status; } @@ -301,7 +301,7 @@ static RPC_STATUS process_bind_packet_no_send( &conn->server_binding->Assoc); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, results); + free(results); return status; } @@ -313,7 +313,7 @@ static RPC_STATUS process_bind_packet_no_send( auth_length_out); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, results); + free(results); return status; } } @@ -324,7 +324,7 @@ static RPC_STATUS process_bind_packet_no_send( conn->server_binding->Assoc->assoc_group_id, conn->Endpoint, hdr->num_elements, results); - HeapFree(GetProcessHeap(), 0, results); + free(results); if (*ack_response) conn->MaxTransmissionSize = hdr->max_tsize; @@ -353,7 +353,7 @@ static RPC_STATUS process_bind_packet(RpcConnection *conn, RpcPktBindHdr *hdr, status = RPCRT4_SendWithAuth(conn, response, NULL, 0, auth_data_out, auth_length_out); else status = ERROR_OUTOFMEMORY; - RPCRT4_FreeHeader(response); + free(response); return status; } @@ -377,7 +377,7 @@ static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr * status); RPCRT4_Send(conn, response, NULL, 0); - RPCRT4_FreeHeader(response); + free(response); return RPC_S_OK; } @@ -394,7 +394,7 @@ static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr * NCA_S_UNK_IF); RPCRT4_Send(conn, response, NULL, 0); - RPCRT4_FreeHeader(response); + free(response); return RPC_S_OK; } msg->RpcInterfaceInformation = sif->If; @@ -417,7 +417,7 @@ static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr * NCA_S_OP_RNG_ERROR); RPCRT4_Send(conn, response, NULL, 0); - RPCRT4_FreeHeader(response); + free(response); } func = sif->If->DispatchTable->DispatchTable[msg->ProcNum]; } @@ -435,7 +435,7 @@ static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr * __TRY { if (func) func(msg); } __EXCEPT_ALL { - WARN("exception caught with code 0x%08x = %d\n", GetExceptionCode(), GetExceptionCode()); + WARN("exception caught with code 0x%08lx = %ld\n", GetExceptionCode(), GetExceptionCode()); exception = TRUE; if (GetExceptionCode() == STATUS_ACCESS_VIOLATION) status = ERROR_NOACCESS; @@ -458,7 +458,7 @@ static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr * if (response) { status = RPCRT4_Send(conn, response, exception ? NULL : msg->Buffer, exception ? 0 : msg->BufferLength); - RPCRT4_FreeHeader(response); + free(response); } else ERR("out of memory\n"); @@ -525,9 +525,9 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, /* clean up */ I_RpcFree(msg->Buffer); - RPCRT4_FreeHeader(hdr); - HeapFree(GetProcessHeap(), 0, msg); - HeapFree(GetProcessHeap(), 0, auth_data); + free(hdr); + free(msg); + free(auth_data); } static DWORD CALLBACK RPCRT4_worker_thread(LPVOID the_arg) @@ -536,7 +536,7 @@ static DWORD CALLBACK RPCRT4_worker_thread(LPVOID the_arg) RPCRT4_process_packet(pkt->conn, pkt->hdr, pkt->msg, pkt->auth_data, pkt->auth_length); RPCRT4_ReleaseConnection(pkt->conn); - HeapFree(GetProcessHeap(), 0, pkt); + free(pkt); return 0; } @@ -551,15 +551,16 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg) ULONG auth_length; TRACE("(%p)\n", conn); + SetThreadDescription(GetCurrentThread(), L"wine_rpcrt4_io"); for (;;) { - msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RPC_MESSAGE)); + msg = calloc(1, sizeof(RPC_MESSAGE)); if (!msg) break; status = RPCRT4_ReceiveWithAuth(conn, &hdr, msg, &auth_data, &auth_length); if (status != RPC_S_OK) { - WARN("receive failed with error %x\n", status); - HeapFree(GetProcessHeap(), 0, msg); + WARN("receive failed with error %lx\n", status); + free(msg); break; } @@ -574,12 +575,12 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg) case PKT_REQUEST: TRACE("got request packet\n"); - packet = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcPacket)); + packet = malloc(sizeof(RpcPacket)); if (!packet) { I_RpcFree(msg->Buffer); - RPCRT4_FreeHeader(hdr); - HeapFree(GetProcessHeap(), 0, msg); - HeapFree(GetProcessHeap(), 0, auth_data); + free(hdr); + free(msg); + free(auth_data); goto exit; } packet->conn = RPCRT4_GrabConnection( conn ); @@ -588,8 +589,8 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg) packet->auth_data = auth_data; packet->auth_length = auth_length; if (!QueueUserWorkItem(RPCRT4_worker_thread, packet, WT_EXECUTELONGFUNCTION)) { - ERR("couldn't queue work item for worker thread, error was %d\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, packet); + ERR("couldn't queue work item for worker thread, error was %ld\n", GetLastError()); + free(packet); status = RPC_S_OUT_OF_RESOURCES; } else { continue; @@ -608,12 +609,12 @@ static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg) } I_RpcFree(msg->Buffer); - RPCRT4_FreeHeader(hdr); - HeapFree(GetProcessHeap(), 0, msg); - HeapFree(GetProcessHeap(), 0, auth_data); + free(hdr); + free(msg); + free(auth_data); if (status != RPC_S_OK) { - WARN("processing packet failed with error %u\n", status); + WARN("processing packet failed with error %lu\n", status); break; } } @@ -627,7 +628,7 @@ void RPCRT4_new_client(RpcConnection* conn) HANDLE thread = CreateThread(NULL, 0, RPCRT4_io_thread, conn, 0, NULL); if (!thread) { DWORD err = GetLastError(); - ERR("failed to create thread, error=%08x\n", err); + ERR("failed to create thread, error=%08lx\n", err); RPCRT4_ReleaseConnection(conn); } /* we could set conn->thread, but then we'd have to make the io_thread wait @@ -648,6 +649,7 @@ static DWORD CALLBACK RPCRT4_server_thread(LPVOID the_arg) BOOL set_ready_event = FALSE; TRACE("(the_arg == ^%p)\n", the_arg); + SetThreadDescription(GetCurrentThread(), L"wine_rpcrt4_server"); for (;;) { objs = cps->ops->get_wait_array(cps, objs, &count); @@ -881,9 +883,7 @@ RPC_STATUS WINAPI RpcServerInqBindings( RPC_BINDING_VECTOR** BindingVector ) } if (count) { /* export bindings */ - *BindingVector = HeapAlloc(GetProcessHeap(), 0, - sizeof(RPC_BINDING_VECTOR) + - sizeof(RPC_BINDING_HANDLE)*(count-1)); + *BindingVector = malloc(sizeof(RPC_BINDING_VECTOR) + sizeof(RPC_BINDING_HANDLE) * (count - 1)); (*BindingVector)->Count = count; count = 0; LIST_FOR_EACH_ENTRY(ps, &protseqs, RpcServerProtseq, entry) { @@ -957,11 +957,11 @@ static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, const char *Protseq, RpcSe if (!*ps) return RPC_S_OUT_OF_RESOURCES; (*ps)->MaxCalls = MaxCalls; - (*ps)->Protseq = RPCRT4_strdupA(Protseq); + (*ps)->Protseq = strdup(Protseq); (*ps)->ops = ops; list_init(&(*ps)->listeners); list_init(&(*ps)->connections); - InitializeCriticalSection(&(*ps)->cs); + InitializeCriticalSectionEx(&(*ps)->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); (*ps)->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcServerProtseq.cs"); list_add_head(&protseqs, &(*ps)->entry); @@ -974,13 +974,13 @@ static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, const char *Protseq, RpcSe /* must be called with server_cs held */ static void destroy_serverprotoseq(RpcServerProtseq *ps) { - RPCRT4_strfree(ps->Protseq); + free(ps->Protseq); ps->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&ps->cs); CloseHandle(ps->mgr_mutex); CloseHandle(ps->server_ready_event); list_remove(&ps->entry); - HeapFree(GetProcessHeap(), 0, ps); + free(ps); } /* Finds a given protseq or creates a new one if one doesn't already exist */ @@ -1016,7 +1016,7 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpExA( RPC_CSTR Protseq, UINT MaxCalls, RPC RpcServerProtseq* ps; RPC_STATUS status; - TRACE("(%s,%u,%s,%p,{%u,%u,%u})\n", debugstr_a((const char *)Protseq), + TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_a((const char *)Protseq), MaxCalls, debugstr_a((const char *)Endpoint), SecurityDescriptor, lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags ); @@ -1038,19 +1038,19 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpExW( RPC_WSTR Protseq, UINT MaxCalls, RPC LPSTR ProtseqA; LPSTR EndpointA; - TRACE("(%s,%u,%s,%p,{%u,%u,%u})\n", debugstr_w( Protseq ), MaxCalls, + TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_w( Protseq ), MaxCalls, debugstr_w( Endpoint ), SecurityDescriptor, lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags ); ProtseqA = RPCRT4_strdupWtoA(Protseq); status = RPCRT4_get_or_create_serverprotseq(MaxCalls, ProtseqA, &ps); - RPCRT4_strfree(ProtseqA); + free(ProtseqA); if (status != RPC_S_OK) return status; EndpointA = RPCRT4_strdupWtoA(Endpoint); status = RPCRT4_use_protseq(ps, EndpointA); - RPCRT4_strfree(EndpointA); + free(EndpointA); return status; } @@ -1084,7 +1084,7 @@ RPC_STATUS WINAPI RpcServerUseProtseqW(RPC_WSTR Protseq, unsigned int MaxCalls, ProtseqA = RPCRT4_strdupWtoA(Protseq); status = RPCRT4_get_or_create_serverprotseq(MaxCalls, ProtseqA, &ps); - RPCRT4_strfree(ProtseqA); + free(ProtseqA); if (status != RPC_S_OK) return status; @@ -1166,13 +1166,13 @@ RPC_STATUS WINAPI RpcServerRegisterIf3( RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, for (i=0; iDispatchTable->DispatchTableCount; i++) { TRACE(" entry %d: %p\n", i, If->DispatchTable->DispatchTable[i]); } - TRACE(" reserved: %ld\n", If->DispatchTable->Reserved); + TRACE(" reserved: %Id\n", If->DispatchTable->Reserved); } TRACE(" protseq endpoint count: %d\n", If->RpcProtseqEndpointCount); TRACE(" default manager epv: %p\n", If->DefaultManagerEpv); TRACE(" interpreter info: %p\n", If->InterpreterInfo); - sif = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcServerInterface)); + sif = calloc(1, sizeof(RpcServerInterface)); sif->If = If; if (MgrTypeUuid) { sif->MgrTypeUuid = *MgrTypeUuid; @@ -1236,7 +1236,7 @@ RPC_STATUS WINAPI RpcServerUnregisterIf( RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid } if (completed) - HeapFree(GetProcessHeap(), 0, cif); + free(cif); else if (event) { /* sif will be freed when the last call is completed, so be careful not to * touch that memory here as that could happen before we get here */ @@ -1302,14 +1302,14 @@ RPC_STATUS WINAPI RpcObjectSetType( UUID* ObjUuid, UUID* TypeUuid ) prev->next = map->next; else RpcObjTypeMaps = map->next; - HeapFree(GetProcessHeap(), 0, map); + free(map); } } else { /* ... , fail if we found it ... */ if (map) return RPC_S_ALREADY_REGISTERED; /* ... otherwise create a new one and add it in. */ - map = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcObjTypeMap)); + map = malloc(sizeof(RpcObjTypeMap)); map->Object = *ObjUuid; map->Type = *TypeUuid; map->next = NULL; @@ -1341,7 +1341,7 @@ static RPC_STATUS find_security_package(ULONG auth_type, SecPkgInfoW **packages_ sec_status = EnumerateSecurityPackagesW(&package_count, &packages); if (sec_status != SEC_E_OK) { - ERR("EnumerateSecurityPackagesW failed with error 0x%08x\n", sec_status); + ERR("EnumerateSecurityPackagesW failed with error 0x%08lx\n", sec_status); return RPC_S_SEC_PKG_ERROR; } @@ -1351,12 +1351,12 @@ static RPC_STATUS find_security_package(ULONG auth_type, SecPkgInfoW **packages_ if (i == package_count) { - WARN("unsupported AuthnSvc %u\n", auth_type); + WARN("unsupported AuthnSvc %lu\n", auth_type); FreeContextBuffer(packages); return RPC_S_UNKNOWN_AUTHN_SERVICE; } - TRACE("found package %s for service %u\n", debugstr_w(packages[i].Name), auth_type); + TRACE("found package %s for service %lu\n", debugstr_w(packages[i].Name), auth_type); *packages_buf = packages; *ret = packages + i; return RPC_S_OK; @@ -1400,9 +1400,9 @@ void RPCRT4_ServerFreeAllRegisteredAuthInfo(void) EnterCriticalSection(&server_auth_info_cs); LIST_FOR_EACH_ENTRY_SAFE(auth_info, cursor2, &server_registered_auth_info, struct rpc_server_registered_auth_info, entry) { - HeapFree(GetProcessHeap(), 0, auth_info->package_name); - HeapFree(GetProcessHeap(), 0, auth_info->principal); - HeapFree(GetProcessHeap(), 0, auth_info); + free(auth_info->package_name); + free(auth_info->principal); + free(auth_info); } LeaveCriticalSection(&server_auth_info_cs); DeleteCriticalSection(&server_auth_info_cs); @@ -1417,14 +1417,14 @@ RPC_STATUS WINAPI RpcServerRegisterAuthInfoA( RPC_CSTR ServerPrincName, ULONG Au WCHAR *principal_name = NULL; RPC_STATUS status; - TRACE("(%s,%u,%p,%p)\n", ServerPrincName, AuthnSvc, GetKeyFn, Arg); + TRACE("(%s,%lu,%p,%p)\n", ServerPrincName, AuthnSvc, GetKeyFn, Arg); if(ServerPrincName && !(principal_name = RPCRT4_strdupAtoW((const char*)ServerPrincName))) return RPC_S_OUT_OF_RESOURCES; status = RpcServerRegisterAuthInfoW(principal_name, AuthnSvc, GetKeyFn, Arg); - HeapFree(GetProcessHeap(), 0, principal_name); + free(principal_name); return status; } @@ -1440,27 +1440,27 @@ RPC_STATUS WINAPI RpcServerRegisterAuthInfoW( RPC_WSTR ServerPrincName, ULONG Au ULONG max_token; RPC_STATUS status; - TRACE("(%s,%u,%p,%p)\n", debugstr_w(ServerPrincName), AuthnSvc, GetKeyFn, Arg); + TRACE("(%s,%lu,%p,%p)\n", debugstr_w(ServerPrincName), AuthnSvc, GetKeyFn, Arg); status = find_security_package(AuthnSvc, &packages, &package); if (status != RPC_S_OK) return status; - package_name = RPCRT4_strdupW(package->Name); + package_name = wcsdup(package->Name); max_token = package->cbMaxToken; FreeContextBuffer(packages); if (!package_name) return RPC_S_OUT_OF_RESOURCES; - auth_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*auth_info)); + auth_info = calloc(1, sizeof(*auth_info)); if (!auth_info) { - HeapFree(GetProcessHeap(), 0, package_name); + free(package_name); return RPC_S_OUT_OF_RESOURCES; } - if (ServerPrincName && !(auth_info->principal = RPCRT4_strdupW(ServerPrincName))) { - HeapFree(GetProcessHeap(), 0, package_name); - HeapFree(GetProcessHeap(), 0, auth_info); + if (ServerPrincName && !(auth_info->principal = wcsdup(ServerPrincName))) { + free(package_name); + free(auth_info); return RPC_S_OUT_OF_RESOURCES; } @@ -1483,7 +1483,7 @@ RPC_STATUS RPC_ENTRY RpcServerInqDefaultPrincNameA(ULONG AuthnSvc, RPC_CSTR *Pri RPC_STATUS ret; RPC_WSTR principalW; - TRACE("%u, %p\n", AuthnSvc, PrincName); + TRACE("%lu, %p\n", AuthnSvc, PrincName); if ((ret = RpcServerInqDefaultPrincNameW( AuthnSvc, &principalW )) == RPC_S_OK) { @@ -1500,14 +1500,14 @@ RPC_STATUS RPC_ENTRY RpcServerInqDefaultPrincNameW(ULONG AuthnSvc, RPC_WSTR *Pri { ULONG len = 0; - FIXME("%u, %p\n", AuthnSvc, PrincName); + FIXME("%lu, %p\n", AuthnSvc, PrincName); if (AuthnSvc != RPC_C_AUTHN_WINNT) return RPC_S_UNKNOWN_AUTHN_SERVICE; GetUserNameExW( NameSamCompatible, NULL, &len ); if (GetLastError() != ERROR_MORE_DATA) return RPC_S_INTERNAL_ERROR; - if (!(*PrincName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + if (!(*PrincName = malloc(len * sizeof(WCHAR)))) return RPC_S_OUT_OF_MEMORY; GetUserNameExW( NameSamCompatible, *PrincName, &len ); @@ -1575,7 +1575,7 @@ RPC_STATUS WINAPI RpcMgmtWaitServerListen( void ) if (!wait_thread) break; - TRACE("waiting for thread %u\n", GetThreadId(wait_thread)); + TRACE("waiting for thread %lu\n", GetThreadId(wait_thread)); LeaveCriticalSection(&listen_cs); WaitForSingleObject(wait_thread, INFINITE); CloseHandle(wait_thread); @@ -1639,7 +1639,7 @@ RPC_STATUS WINAPI I_RpcServerStopListening( void ) */ UINT WINAPI I_RpcWindowProc( void *hWnd, UINT Message, UINT wParam, ULONG lParam ) { - FIXME( "(%p,%08x,%08x,%08x): stub\n", hWnd, Message, wParam, lParam ); + FIXME( "(%p,%08x,%08x,%08lx): stub\n", hWnd, Message, wParam, lParam ); return 0; } @@ -1662,7 +1662,7 @@ RPC_STATUS WINAPI RpcMgmtInqStats(RPC_BINDING_HANDLE Binding, RPC_STATS_VECTOR * FIXME("(%p,%p)\n", Binding, Statistics); - if ((stats = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_STATS_VECTOR)))) + if ((stats = malloc(sizeof(RPC_STATS_VECTOR)))) { stats->Count = 1; stats->Stats[0] = 0; @@ -1681,7 +1681,7 @@ RPC_STATUS WINAPI RpcMgmtStatsVectorFree(RPC_STATS_VECTOR **StatsVector) if (StatsVector) { - HeapFree(GetProcessHeap(), 0, *StatsVector); + free(*StatsVector); *StatsVector = NULL; } return RPC_S_OK; @@ -1693,7 +1693,7 @@ RPC_STATUS WINAPI RpcMgmtStatsVectorFree(RPC_STATS_VECTOR **StatsVector) RPC_STATUS WINAPI RpcMgmtEpEltInqBegin(RPC_BINDING_HANDLE Binding, ULONG InquiryType, RPC_IF_ID *IfId, ULONG VersOption, UUID *ObjectUuid, RPC_EP_INQ_HANDLE* InquiryContext) { - FIXME("(%p,%u,%p,%u,%p,%p): stub\n", + FIXME("(%p,%lu,%p,%lu,%p,%p): stub\n", Binding, InquiryType, IfId, VersOption, ObjectUuid, InquiryContext); return RPC_S_INVALID_BINDING; } @@ -1733,7 +1733,7 @@ RPC_STATUS WINAPI RpcMgmtSetAuthorizationFn(RPC_MGMT_AUTHORIZATION_FN fn) */ RPC_STATUS WINAPI RpcMgmtSetServerStackSize(ULONG ThreadStackSize) { - FIXME("(0x%x): stub\n", ThreadStackSize); + FIXME("(0x%lx): stub\n", ThreadStackSize); return RPC_S_OK; } diff --git a/dll/win32/rpcrt4/rpc_server.h b/dll/win32/rpcrt4/rpc_server.h index 5e043651e55..3360d411741 100644 --- a/dll/win32/rpcrt4/rpc_server.h +++ b/dll/win32/rpcrt4/rpc_server.h @@ -77,10 +77,10 @@ typedef struct _RpcServerInterface BOOL Delete; /* delete when the last call finishes */ } RpcServerInterface; -void RPCRT4_new_client(RpcConnection* conn) DECLSPEC_HIDDEN; -const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq) DECLSPEC_HIDDEN; +void RPCRT4_new_client(RpcConnection* conn); +const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq); -void RPCRT4_destroy_all_protseqs(void) DECLSPEC_HIDDEN; -void RPCRT4_ServerFreeAllRegisteredAuthInfo(void) DECLSPEC_HIDDEN; +void RPCRT4_destroy_all_protseqs(void); +void RPCRT4_ServerFreeAllRegisteredAuthInfo(void); #endif /* __WINE_RPC_SERVER_H */ diff --git a/dll/win32/rpcrt4/rpc_transport.c b/dll/win32/rpcrt4/rpc_transport.c index d7acf3245a3..a3f8ad88c6b 100644 --- a/dll/win32/rpcrt4/rpc_transport.c +++ b/dll/win32/rpcrt4/rpc_transport.c @@ -25,9 +25,6 @@ #include "ntstatus.h" #define WIN32_NO_STATUS -#ifdef __REACTOS__ -#define NONAMELESSUNION -#endif #include "ws2tcpip.h" #include @@ -40,7 +37,7 @@ #include "winnls.h" #include "winerror.h" #include "wininet.h" -#include "wine/winternl.h" +#include "winternl.h" #include "winioctl.h" #include "rpc.h" @@ -64,9 +61,9 @@ static BOOL WINAPI CancelIoEx_(HANDLE handle, LPOVERLAPPED lpOverlapped) IO_STATUS_BLOCK io_status; NtCancelIoFile(handle, &io_status); - if (io_status.u.Status) + if (io_status.Status) { - SetLastError( RtlNtStatusToDosError( io_status.u.Status ) ); + SetLastError( RtlNtStatusToDosError( io_status.Status ) ); return FALSE; } return TRUE; @@ -91,7 +88,7 @@ typedef struct _RpcConnection_np static RpcConnection *rpcrt4_conn_np_alloc(void) { - RpcConnection_np *npc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcConnection_np)); + RpcConnection_np *npc = calloc(1, sizeof(RpcConnection_np)); return &npc->common; } @@ -340,7 +337,7 @@ static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *conn) #endif if (connection->pipe == INVALID_HANDLE_VALUE) { - WARN("CreateNamedPipe failed with error %d\n", GetLastError()); + WARN("CreateNamedPipe failed with error %ld\n", GetLastError()); if (GetLastError() == ERROR_FILE_EXISTS) { return RPC_S_DUPLICATE_ENDPOINT; @@ -397,7 +394,7 @@ static RPC_STATUS rpcrt4_conn_open_pipe(RpcConnection *Connection, LPCSTR pname, TRACE("retrying busy server\n"); continue; } - TRACE("connection failed, error=%x\n", err); + TRACE("connection failed, error=%lx\n", err); return RPC_S_SERVER_TOO_BUSY; #ifdef __REACTOS__ } else if (err == ERROR_BAD_NETPATH) { @@ -407,7 +404,7 @@ static RPC_STATUS rpcrt4_conn_open_pipe(RpcConnection *Connection, LPCSTR pname, } if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) { err = GetLastError(); - WARN("connection failed, error=%x\n", err); + WARN("connection failed, error=%lx\n", err); return RPC_S_SERVER_UNAVAILABLE; } } @@ -462,7 +459,7 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq DWORD process_id = GetCurrentProcessId(); ULONG id = InterlockedIncrement(&lrpc_nameless_id); snprintf(generated_endpoint, sizeof(generated_endpoint), - "LRPC%08x.%08x", process_id, id); + "LRPC%08lx.%08lx", process_id, id); endpoint = generated_endpoint; } @@ -565,7 +562,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protse DWORD process_id = GetCurrentProcessId(); ULONG id = InterlockedExchangeAdd(&np_nameless_id, 1 ); snprintf(generated_endpoint, sizeof(generated_endpoint), - "\\\\pipe\\\\%08x.%03x", process_id, id); + "\\\\pipe\\\\%08lx.%03lx", process_id, id); endpoint = generated_endpoint; } @@ -590,7 +587,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protse } static void rpcrt4_conn_np_handoff(RpcConnection_np *old_npc, RpcConnection_np *new_npc) -{ +{ /* because of the way named pipes work, we'll transfer the connected pipe * to the child, then reopen the server binding to continue listening */ @@ -609,10 +606,10 @@ static RPC_STATUS rpcrt4_ncacn_np_handoff(RpcConnection *old_conn, RpcConnection /* Store the local computer name as the NetworkAddr for ncacn_np as long as * we don't support named pipes over the network. */ - new_conn->NetworkAddr = HeapAlloc(GetProcessHeap(), 0, len); + new_conn->NetworkAddr = malloc(len); if (!GetComputerNameA(new_conn->NetworkAddr, &len)) { - ERR("Failed to retrieve the computer name, error %u\n", GetLastError()); + ERR("Failed to retrieve the computer name, error %lu\n", GetLastError()); return RPC_S_OUT_OF_RESOURCES; } @@ -661,10 +658,10 @@ static RPC_STATUS rpcrt4_ncalrpc_handoff(RpcConnection *old_conn, RpcConnection status = rpcrt4_conn_create_pipe(old_conn); /* Store the local computer name as the NetworkAddr for ncalrpc. */ - new_conn->NetworkAddr = HeapAlloc(GetProcessHeap(), 0, len); + new_conn->NetworkAddr = malloc(len); if (!GetComputerNameA(new_conn->NetworkAddr, &len)) { - ERR("Failed to retrieve the computer name, error %u\n", GetLastError()); + ERR("Failed to retrieve the computer name, error %lu\n", GetLastError()); return RPC_S_OUT_OF_RESOURCES; } @@ -698,7 +695,7 @@ static int rpcrt4_conn_np_read(RpcConnection *conn, void *buffer, unsigned int c #endif } WaitForSingleObject(event, INFINITE); - status = connection->io_status.u.Status; + status = connection->io_status.Status; } release_np_event(connection, event); return status && status != STATUS_BUFFER_OVERFLOW ? -1 : connection->io_status.Information; @@ -719,7 +716,7 @@ static int rpcrt4_conn_np_write(RpcConnection *conn, const void *buffer, unsigne if (status == STATUS_PENDING) { WaitForSingleObject(event, INFINITE); - status = io_status.u.Status; + status = io_status.Status; } release_np_event(connection, event); if (status) @@ -902,7 +899,7 @@ static RPC_STATUS rpcrt4_conn_np_impersonate_client(RpcConnection *conn) if (!ret) { DWORD error = GetLastError(); - WARN("ImpersonateNamedPipeClient failed with error %u\n", error); + WARN("ImpersonateNamedPipeClient failed with error %lu\n", error); switch (error) { case ERROR_CANNOT_IMPERSONATE: @@ -924,7 +921,7 @@ static RPC_STATUS rpcrt4_conn_np_revert_to_self(RpcConnection *conn) ret = RevertToSelf(); if (!ret) { - WARN("RevertToSelf failed with error %u\n", GetLastError()); + WARN("RevertToSelf failed with error %lu\n", GetLastError()); return RPC_S_NO_CONTEXT_AVAILABLE; } return RPC_S_OK; @@ -938,7 +935,7 @@ typedef struct _RpcServerProtseq_np static RpcServerProtseq *rpcrt4_protseq_np_alloc(void) { - RpcServerProtseq_np *ps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ps)); + RpcServerProtseq_np *ps = calloc(1, sizeof(*ps)); if (ps) ps->mgr_event = CreateEventW(NULL, FALSE, FALSE, NULL); return &ps->common; @@ -955,9 +952,9 @@ static void *rpcrt4_protseq_np_get_wait_array(RpcServerProtseq *protseq, void *p HANDLE *objs = prev_array; RpcConnection_np *conn; RpcServerProtseq_np *npps = CONTAINING_RECORD(protseq, RpcServerProtseq_np, common); - + EnterCriticalSection(&protseq->cs); - + /* open and count connections */ *count = 1; LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_np, common.protseq_entry) @@ -978,13 +975,13 @@ static void *rpcrt4_protseq_np_get_wait_array(RpcServerProtseq *protseq, void *p { case STATUS_SUCCESS: case STATUS_PIPE_CONNECTED: - conn->io_status.u.Status = status; + conn->io_status.Status = status; SetEvent(event); break; case STATUS_PENDING: break; default: - ERR("pipe listen error %x\n", status); + ERR("pipe listen error %lx\n", status); continue; } @@ -992,19 +989,16 @@ static void *rpcrt4_protseq_np_get_wait_array(RpcServerProtseq *protseq, void *p } (*count)++; } - + /* make array of connections */ - if (objs) - objs = HeapReAlloc(GetProcessHeap(), 0, objs, *count*sizeof(HANDLE)); - else - objs = HeapAlloc(GetProcessHeap(), 0, *count*sizeof(HANDLE)); + objs = realloc(objs, *count * sizeof(HANDLE)); if (!objs) { ERR("couldn't allocate objs\n"); LeaveCriticalSection(&protseq->cs); return NULL; } - + objs[0] = npps->mgr_event; *count = 1; LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_np, common.protseq_entry) @@ -1018,7 +1012,7 @@ static void *rpcrt4_protseq_np_get_wait_array(RpcServerProtseq *protseq, void *p static void rpcrt4_protseq_np_free_wait_array(RpcServerProtseq *protseq, void *array) { - HeapFree(GetProcessHeap(), 0, array); + free(array); } static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array) @@ -1028,7 +1022,7 @@ static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq, DWORD res; RpcConnection *cconn = NULL; RpcConnection_np *conn; - + if (!objs) return -1; @@ -1045,7 +1039,7 @@ static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq, return 0; else if (res == WAIT_FAILED) { - ERR("wait failed with error %d\n", GetLastError()); + ERR("wait failed with error %ld\n", GetLastError()); return -1; } else @@ -1059,10 +1053,10 @@ static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq, { release_np_event(conn, conn->listen_event); conn->listen_event = NULL; - if (conn->io_status.u.Status == STATUS_SUCCESS || conn->io_status.u.Status == STATUS_PIPE_CONNECTED) + if (conn->io_status.Status == STATUS_SUCCESS || conn->io_status.Status == STATUS_PIPE_CONNECTED) cconn = rpcrt4_spawn_connection(&conn->common); else - ERR("listen failed %x\n", conn->io_status.u.Status); + ERR("listen failed %lx\n", conn->io_status.Status); break; } } @@ -1174,7 +1168,7 @@ static RPC_STATUS rpcrt4_ncalrpc_inquire_auth_client( RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name, ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags) { - TRACE("(%p, %p, %p, %p, %p, %p, 0x%x)\n", conn, privs, + TRACE("(%p, %p, %p, %p, %p, %p, 0x%lx)\n", conn, privs, server_princ_name, authn_level, authn_svc, authz_svc, flags); if (privs) @@ -1195,11 +1189,18 @@ static RPC_STATUS rpcrt4_ncalrpc_inquire_auth_client( *authz_svc = RPC_C_AUTHZ_NONE; } if (flags) - FIXME("flags 0x%x not implemented\n", flags); + FIXME("flags 0x%lx not implemented\n", flags); return RPC_S_OK; } +static RPC_STATUS rpcrt4_ncalrpc_inquire_client_pid(RpcConnection *conn, ULONG *pid) +{ + RpcConnection_np *connection = (RpcConnection_np *)conn; + + return GetNamedPipeClientProcessId(connection->pipe, pid) ? RPC_S_OK : RPC_S_INVALID_BINDING; +} + /**** ncacn_ip_tcp support ****/ static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned char *tower_data, @@ -1260,7 +1261,7 @@ static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned char *tower_data, ret = getaddrinfo("0.0.0.0", endpoint, &hints, &ai); if (ret) { - ERR("getaddrinfo failed: %s\n", gai_strerror(ret)); + ERR("getaddrinfo failed, error %u\n", WSAGetLastError()); return 0; } } @@ -1401,7 +1402,7 @@ static BOOL rpcrt4_sock_wait_for_recv(RpcConnection_tcp *tcpc) case WAIT_OBJECT_0 + 1: return FALSE; default: - ERR("WaitForMultipleObjects() failed with error %d\n", GetLastError()); + ERR("WaitForMultipleObjects() failed with error %ld\n", GetLastError()); return FALSE; } } @@ -1420,7 +1421,7 @@ static BOOL rpcrt4_sock_wait_for_send(RpcConnection_tcp *tcpc) case WAIT_OBJECT_0: return TRUE; default: - ERR("WaitForMultipleObjects() failed with error %d\n", GetLastError()); + ERR("WaitForMultipleObjects() failed with error %ld\n", GetLastError()); return FALSE; } } @@ -1428,13 +1429,13 @@ static BOOL rpcrt4_sock_wait_for_send(RpcConnection_tcp *tcpc) static RpcConnection *rpcrt4_conn_tcp_alloc(void) { RpcConnection_tcp *tcpc; - tcpc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcConnection_tcp)); + tcpc = calloc(1, sizeof(RpcConnection_tcp)); if (tcpc == NULL) return NULL; tcpc->sock = -1; if (!rpcrt4_sock_wait_init(tcpc)) { - HeapFree(GetProcessHeap(), 0, tcpc); + free(tcpc); return NULL; } return &tcpc->common; @@ -1466,8 +1467,8 @@ static RPC_STATUS rpcrt4_ncacn_ip_tcp_open(RpcConnection* Connection) ret = getaddrinfo(Connection->NetworkAddr, Connection->Endpoint, &hints, &ai); if (ret) { - ERR("getaddrinfo for %s:%s failed: %s\n", Connection->NetworkAddr, - Connection->Endpoint, gai_strerror(ret)); + ERR("getaddrinfo for %s:%s failed, error %u\n", Connection->NetworkAddr, + Connection->Endpoint, WSAGetLastError()); return RPC_S_SERVER_UNAVAILABLE; } @@ -1547,8 +1548,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr ret = getaddrinfo(NULL, endpoint ? endpoint : "0", &hints, &ai); if (ret) { - ERR("getaddrinfo for port %s failed: %s\n", endpoint, - gai_strerror(ret)); + ERR("getaddrinfo for port %s failed, error %u\n", endpoint, WSAGetLastError()); if ((ret == EAI_SERVICE) || (ret == EAI_NONAME)) return RPC_S_INVALID_ENDPOINT_FORMAT; return RPC_S_CANT_CREATE_ENDPOINT; @@ -1612,7 +1612,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr NI_NUMERICSERV); if (ret) { - WARN("getnameinfo failed: %s\n", gai_strerror(ret)); + WARN("getnameinfo failed, error %u\n", WSAGetLastError()); closesocket(sock); status = RPC_S_CANT_CREATE_ENDPOINT; continue; @@ -1690,7 +1690,7 @@ static RPC_STATUS rpcrt4_conn_tcp_handoff(RpcConnection *old_conn, RpcConnection ioctlsocket(ret, FIONBIO, &nonblocking); client->sock = ret; - client->common.NetworkAddr = HeapAlloc(GetProcessHeap(), 0, INET6_ADDRSTRLEN); + client->common.NetworkAddr = malloc(INET6_ADDRSTRLEN); ret = getnameinfo((struct sockaddr*)&address, addrsize, client->common.NetworkAddr, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); if (ret != 0) { @@ -1817,7 +1817,7 @@ typedef struct _RpcServerProtseq_sock static RpcServerProtseq *rpcrt4_protseq_sock_alloc(void) { - RpcServerProtseq_sock *ps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ps)); + RpcServerProtseq_sock *ps = calloc(1, sizeof(*ps)); if (ps) { static BOOL wsa_inited; @@ -1857,10 +1857,7 @@ static void *rpcrt4_protseq_sock_get_wait_array(RpcServerProtseq *protseq, void } /* make array of connections */ - if (objs) - objs = HeapReAlloc(GetProcessHeap(), 0, objs, *count*sizeof(HANDLE)); - else - objs = HeapAlloc(GetProcessHeap(), 0, *count*sizeof(HANDLE)); + objs = realloc(objs, *count * sizeof(HANDLE)); if (!objs) { ERR("couldn't allocate objs\n"); @@ -1890,7 +1887,7 @@ static void *rpcrt4_protseq_sock_get_wait_array(RpcServerProtseq *protseq, void static void rpcrt4_protseq_sock_free_wait_array(RpcServerProtseq *protseq, void *array) { - HeapFree(GetProcessHeap(), 0, array); + free(array); } static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array) @@ -1917,7 +1914,7 @@ static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq return 0; if (res == WAIT_FAILED) { - ERR("wait failed with error %d\n", GetLastError()); + ERR("wait failed with error %ld\n", GetLastError()); return -1; } @@ -1983,10 +1980,10 @@ static ULONG RpcHttpAsyncData_Release(RpcHttpAsyncData *data) { TRACE("destroying async data %p\n", data); CloseHandle(data->completion_event); - HeapFree(GetProcessHeap(), 0, data->inet_buffers.lpvBuffer); + free(data->inet_buffers.lpvBuffer); data->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&data->cs); - HeapFree(GetProcessHeap(), 0, data); + free(data); } return refs; } @@ -2009,7 +2006,7 @@ static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret if(GetLastError() != ERROR_IO_PENDING) { RpcHttpAsyncData_Release(async_data); - ERR("Request failed with error %d\n", GetLastError()); + ERR("Request failed with error %ld\n", GetLastError()); return RPC_S_SERVER_UNAVAILABLE; } @@ -2063,19 +2060,19 @@ typedef struct _RpcConnection_http static RpcConnection *rpcrt4_ncacn_http_alloc(void) { RpcConnection_http *httpc; - httpc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*httpc)); + httpc = calloc(1, sizeof(*httpc)); if (!httpc) return NULL; - httpc->async_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcHttpAsyncData)); + httpc->async_data = calloc(1, sizeof(RpcHttpAsyncData)); if (!httpc->async_data) { - HeapFree(GetProcessHeap(), 0, httpc); + free(httpc); return NULL; } TRACE("async data = %p\n", httpc->async_data); httpc->cancel_event = CreateEventW(NULL, FALSE, FALSE, NULL); httpc->async_data->refs = 1; httpc->async_data->inet_buffers.dwStructSize = sizeof(INTERNET_BUFFERSW); - InitializeCriticalSection(&httpc->async_data->cs); + InitializeCriticalSectionEx(&httpc->async_data->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); httpc->async_data->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcHttpAsyncData.cs"); return &httpc->common; } @@ -2098,7 +2095,7 @@ static VOID rpcrt4_http_keep_connection_active_timer_proc(PVOID param, BOOLEAN d { DWORD bytes_written; InternetWriteFile(in_request, idle_pkt, idle_pkt->common.frag_len, &bytes_written); - RPCRT4_FreeHeader(idle_pkt); + free(idle_pkt); } } @@ -2115,8 +2112,10 @@ static DWORD CALLBACK rpcrt4_http_timer_thread(PVOID param) HttpTimerThreadData data; DWORD timeout; + SetThreadDescription(GetCurrentThread(), L"wine_rpcrt4_http_timer"); + data = *data_in; - HeapFree(GetProcessHeap(), 0, data_in); + free(data_in); for (timeout = HTTP_IDLE_TIME; WaitForSingleObject(data.timer_cancelled, timeout) == WAIT_TIMEOUT; @@ -2179,12 +2178,12 @@ static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor) ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index); if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - status_text = HeapAlloc(GetProcessHeap(), 0, size); + status_text = malloc(size); ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index); } - ERR("server returned: %d %s\n", status_code, ret ? debugstr_w(status_text) : ""); - if(status_text != buf) HeapFree(GetProcessHeap(), 0, status_text); + ERR("server returned: %ld %s\n", status_code, ret ? debugstr_w(status_text) : ""); + if(status_text != buf) free(status_text); if (status_code == HTTP_STATUS_DENIED) return ERROR_ACCESS_DENIED; @@ -2193,7 +2192,6 @@ static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor) static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc) { - static const WCHAR wszUserAgent[] = {'M','S','R','P','C',0}; LPWSTR proxy = NULL; LPWSTR user = NULL; LPWSTR password = NULL; @@ -2210,7 +2208,7 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc) WCHAR *p; const SEC_WINNT_AUTH_IDENTITY_W *cred = http_cred->TransportCredentials; ULONG len = cred->DomainLength + 1 + cred->UserLength; - user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + user = malloc((len + 1) * sizeof(WCHAR)); if (!user) return RPC_S_OUT_OF_RESOURCES; p = user; @@ -2231,12 +2229,9 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc) for (option = httpc->common.NetworkOptions; option; option = (wcschr(option, ',') ? wcschr(option, ',')+1 : NULL)) { - static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0}; - static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0}; - - if (!_wcsnicmp(option, wszRpcProxy, ARRAY_SIZE(wszRpcProxy)-1)) + if (!_wcsnicmp(option, L"RpcProxy=", ARRAY_SIZE(L"RpcProxy=")-1)) { - const WCHAR *value_start = option + ARRAY_SIZE(wszRpcProxy)-1; + const WCHAR *value_start = option + ARRAY_SIZE(L"RpcProxy=")-1; const WCHAR *value_end; const WCHAR *p; @@ -2253,9 +2248,9 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc) TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start)); servername = RPCRT4_strndupW(value_start, value_end-value_start); } - else if (!_wcsnicmp(option, wszHttpProxy, ARRAY_SIZE(wszHttpProxy)-1)) + else if (!_wcsnicmp(option, L"HttpProxy=", ARRAY_SIZE(L"HttpProxy=")-1)) { - const WCHAR *value_start = option + ARRAY_SIZE(wszHttpProxy)-1; + const WCHAR *value_start = option + ARRAY_SIZE(L"HttpProxy=")-1; const WCHAR *value_end; value_end = wcschr(option, ','); @@ -2268,15 +2263,15 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc) FIXME("unhandled option %s\n", debugstr_w(option)); } - httpc->app_info = InternetOpenW(wszUserAgent, proxy ? INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_PRECONFIG, + httpc->app_info = InternetOpenW(L"MSRPC", proxy ? INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC); if (!httpc->app_info) { - HeapFree(GetProcessHeap(), 0, password); - HeapFree(GetProcessHeap(), 0, user); - HeapFree(GetProcessHeap(), 0, proxy); - HeapFree(GetProcessHeap(), 0, servername); - ERR("InternetOpenW failed with error %d\n", GetLastError()); + free(password); + free(user); + free(proxy); + free(servername); + ERR("InternetOpenW failed with error %ld\n", GetLastError()); return RPC_S_SERVER_UNAVAILABLE; } InternetSetStatusCallbackW(httpc->app_info, rpcrt4_http_internet_callback); @@ -2285,12 +2280,12 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc) * RPC server address */ if (!servername) { - servername = HeapAlloc(GetProcessHeap(), 0, (strlen(httpc->common.NetworkAddr) + 1)*sizeof(WCHAR)); + servername = malloc((strlen(httpc->common.NetworkAddr) + 1) * sizeof(WCHAR)); if (!servername) { - HeapFree(GetProcessHeap(), 0, password); - HeapFree(GetProcessHeap(), 0, user); - HeapFree(GetProcessHeap(), 0, proxy); + free(password); + free(user); + free(proxy); return RPC_S_OUT_OF_RESOURCES; } MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1); @@ -2304,14 +2299,14 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc) httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password, INTERNET_SERVICE_HTTP, 0, 0); - HeapFree(GetProcessHeap(), 0, password); - HeapFree(GetProcessHeap(), 0, user); - HeapFree(GetProcessHeap(), 0, proxy); + free(password); + free(user); + free(proxy); if (!httpc->session) { - ERR("InternetConnectW failed with error %d\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, servername); + ERR("InternetConnectW failed with error %ld\n", GetLastError()); + free(servername); return RPC_S_SERVER_UNAVAILABLE; } httpc->servername = servername; @@ -2326,7 +2321,7 @@ static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, H unsigned int bytes_left = count; RPC_STATUS status = RPC_S_OK; - async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, count); + async_data->inet_buffers.lpvBuffer = malloc(count); while (bytes_left) { @@ -2350,10 +2345,10 @@ static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, H buf += async_data->inet_buffers.dwBufferLength; } - HeapFree(GetProcessHeap(), 0, async_data->inet_buffers.lpvBuffer); + free(async_data->inet_buffers.lpvBuffer); async_data->inet_buffers.lpvBuffer = NULL; - TRACE("%p %p %u -> %u\n", req, buffer, count, status); + TRACE("%p %p %u -> %lu\n", req, buffer, count, status); return status == RPC_S_OK ? count : -1; } @@ -2381,11 +2376,9 @@ static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len) { - static const WCHAR fmtW[] = - {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0}; - WCHAR header[ARRAY_SIZE(fmtW) + 10]; + WCHAR header[ARRAY_SIZE(L"Content-Length: %u\r\n") + 10]; - swprintf(header, fmtW, len); + swprintf(header, L"Content-Length: %u\r\n", len); if ((HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD))) return RPC_S_OK; return RPC_S_SERVER_UNAVAILABLE; } @@ -2423,10 +2416,10 @@ static RPC_STATUS rpcrt4_http_prepare_in_pipe(HINTERNET in_request, RpcHttpAsync hdr = RPCRT4_BuildHttpConnectHeader(FALSE, connection_uuid, in_pipe_uuid, association_uuid); if (!hdr) return RPC_S_OUT_OF_RESOURCES; ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written); - RPCRT4_FreeHeader(hdr); + free(hdr); if (!ret) { - ERR("InternetWriteFile failed with error %d\n", GetLastError()); + ERR("InternetWriteFile failed with error %ld\n", GetLastError()); return RPC_S_SERVER_UNAVAILABLE; } @@ -2455,12 +2448,12 @@ static RPC_STATUS rpcrt4_http_read_http_packet(HINTERNET request, RpcHttpAsyncDa data_len = hdr->common.frag_len - sizeof(hdr->http); if (data_len) { - *data = HeapAlloc(GetProcessHeap(), 0, data_len); + *data = malloc(data_len); if (!*data) return RPC_S_OUT_OF_RESOURCES; if (rpcrt4_http_async_read(request, async_data, cancel_event, *data, data_len) < 0) { - HeapFree(GetProcessHeap(), 0, *data); + free(*data); return RPC_S_SERVER_UNAVAILABLE; } } @@ -2470,7 +2463,7 @@ static RPC_STATUS rpcrt4_http_read_http_packet(HINTERNET request, RpcHttpAsyncDa if (!RPCRT4_IsValidHttpPacket(hdr, *data, data_len)) { ERR("invalid http packet\n"); - HeapFree(GetProcessHeap(), 0, *data); + free(*data); return RPC_S_PROTOCOL_ERROR; } @@ -2506,7 +2499,7 @@ static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request, RpcHttpAsy status = insert_content_length_header(out_request, hdr->common.frag_len); if (status != RPC_S_OK) { - RPCRT4_FreeHeader(hdr); + free(hdr); return status; } @@ -2514,7 +2507,7 @@ static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request, RpcHttpAsy prepare_async_request(async_data); ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len); status = wait_async_request(async_data, ret, cancel_event); - RPCRT4_FreeHeader(hdr); + free(hdr); if (status != RPC_S_OK) return status; status = rpcrt4_http_check_response(out_request); @@ -2525,9 +2518,9 @@ static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request, RpcHttpAsy if (status != RPC_S_OK) return status; status = RPCRT4_ParseHttpPrepareHeader1(&pkt_from_server, data_from_server, &field1); - HeapFree(GetProcessHeap(), 0, data_from_server); + free(data_from_server); if (status != RPC_S_OK) return status; - TRACE("received (%d) from first prepare header\n", field1); + TRACE("received (%ld) from first prepare header\n", field1); for (;;) { @@ -2537,7 +2530,7 @@ static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request, RpcHttpAsy if (pkt_from_server.http.flags != 0x0001) break; TRACE("http idle packet, waiting for real packet\n"); - HeapFree(GetProcessHeap(), 0, data_from_server); + free(data_from_server); if (pkt_from_server.http.num_data_items != 0) { ERR("HTTP idle packet should have no data items instead of %d\n", @@ -2548,9 +2541,9 @@ static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request, RpcHttpAsy status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server, &field1, flow_control_increment, &field3); - HeapFree(GetProcessHeap(), 0, data_from_server); + free(data_from_server); if (status != RPC_S_OK) return status; - TRACE("received (0x%08x 0x%08x %d) from second prepare header\n", field1, *flow_control_increment, field3); + TRACE("received (0x%08lx 0x%08lx %ld) from second prepare header\n", field1, *flow_control_increment, field3); return RPC_S_OK; } @@ -2671,7 +2664,7 @@ static struct authinfo *alloc_authinfo(void) { struct authinfo *ret; - if (!(ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret) ))) return NULL; + if (!(ret = malloc(sizeof(*ret)))) return NULL; SecInvalidateHandle(&ret->cred); SecInvalidateHandle(&ret->ctx); @@ -2694,16 +2687,10 @@ static void destroy_authinfo(struct authinfo *info) if (SecIsValidHandle(&info->cred)) FreeCredentialsHandle(&info->cred); - HeapFree(GetProcessHeap(), 0, info->data); - HeapFree(GetProcessHeap(), 0, info); + free(info->data); + free(info); } -static const WCHAR basicW[] = {'B','a','s','i','c',0}; -static const WCHAR ntlmW[] = {'N','T','L','M',0}; -static const WCHAR passportW[] = {'P','a','s','s','p','o','r','t',0}; -static const WCHAR digestW[] = {'D','i','g','e','s','t',0}; -static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',0}; - static const struct { const WCHAR *str; @@ -2712,11 +2699,11 @@ static const struct } auth_schemes[] = { - { basicW, ARRAY_SIZE(basicW) - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC }, - { ntlmW, ARRAY_SIZE(ntlmW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM }, - { passportW, ARRAY_SIZE(passportW) - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT }, - { digestW, ARRAY_SIZE(digestW) - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST }, - { negotiateW, ARRAY_SIZE(negotiateW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE } + { L"Basic", ARRAY_SIZE(L"Basic") - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC }, + { L"NTLM", ARRAY_SIZE(L"NTLM") - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM }, + { L"Passport", ARRAY_SIZE(L"Passport") - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT }, + { L"Digest", ARRAY_SIZE(L"Digest") - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST }, + { L"Negotiate", ARRAY_SIZE(L"Negotiate") - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE } }; static DWORD auth_scheme_from_header( const WCHAR *header ) @@ -2759,7 +2746,7 @@ static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, int passlen = WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, NULL, 0, NULL, NULL); info->data_len = userlen + passlen + 1; - if (!(info->data = HeapAlloc(GetProcessHeap(), 0, info->data_len))) + if (!(info->data = malloc(info->data_len))) { status = RPC_S_OUT_OF_MEMORY; break; @@ -2777,7 +2764,7 @@ static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, case RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE: { - static SEC_WCHAR ntlmW[] = {'N','T','L','M',0}, negotiateW[] = {'N','e','g','o','t','i','a','t','e',0}; + static SEC_WCHAR ntlmW[] = L"NTLM", negotiateW[] = L"Negotiate"; SECURITY_STATUS ret; SecBufferDesc out_desc, in_desc; SecBuffer out, in; @@ -2830,14 +2817,14 @@ static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, { int len = lstrlenW(++p); in.cbBuffer = decode_base64(p, len, NULL); - if (!(in.pvBuffer = HeapAlloc(GetProcessHeap(), 0, in.cbBuffer))) break; + if (!(in.pvBuffer = malloc(in.cbBuffer))) break; decode_base64(p, len, in.pvBuffer); } out.BufferType = SECBUFFER_TOKEN; out.cbBuffer = info->max_token; - if (!(out.pvBuffer = HeapAlloc(GetProcessHeap(), 0, out.cbBuffer))) + if (!(out.pvBuffer = malloc(out.cbBuffer))) { - HeapFree(GetProcessHeap(), 0, in.pvBuffer); + free(in.pvBuffer); break; } out_desc.ulVersion = 0; @@ -2848,10 +2835,10 @@ static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, first ? servername : NULL, flags, 0, SECURITY_NETWORK_DREP, in.pvBuffer ? &in_desc : NULL, 0, &info->ctx, &out_desc, &info->attr, &info->exp); - HeapFree(GetProcessHeap(), 0, in.pvBuffer); + free(in.pvBuffer); if (ret == SEC_E_OK) { - HeapFree(GetProcessHeap(), 0, info->data); + free(info->data); info->data = out.pvBuffer; info->data_len = out.cbBuffer; info->finished = TRUE; @@ -2860,7 +2847,7 @@ static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, } else if (ret == SEC_I_CONTINUE_NEEDED) { - HeapFree(GetProcessHeap(), 0, info->data); + free(info->data); info->data = out.pvBuffer; info->data_len = out.cbBuffer; TRACE("sending next auth packet\n"); @@ -2868,15 +2855,15 @@ static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, } else { - ERR("InitializeSecurityContextW failed with error 0x%08x\n", ret); - HeapFree(GetProcessHeap(), 0, out.pvBuffer); + ERR("InitializeSecurityContextW failed with error 0x%08lx\n", ret); + free(out.pvBuffer); break; } info->scheme = creds->AuthnSchemes[0]; break; } default: - FIXME("scheme %u not supported\n", creds->AuthnSchemes[0]); + FIXME("scheme %lu not supported\n", creds->AuthnSchemes[0]); break; } @@ -2916,10 +2903,10 @@ static RPC_STATUS insert_authorization_header(HINTERNET request, ULONG scheme, c scheme_len = ARRAY_SIZE(ntlmW); break; default: - ERR("unknown scheme %u\n", scheme); + ERR("unknown scheme %lu\n", scheme); return RPC_S_SERVER_UNAVAILABLE; } - if ((header = HeapAlloc(GetProcessHeap(), 0, (auth_len + scheme_len + len + 2) * sizeof(WCHAR)))) + if ((header = malloc((auth_len + scheme_len + len + 2) * sizeof(WCHAR)))) { memcpy(header, authW, auth_len * sizeof(WCHAR)); ptr = header + auth_len; @@ -2931,7 +2918,7 @@ static RPC_STATUS insert_authorization_header(HINTERNET request, ULONG scheme, c ptr[len] = 0; if (HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE)) status = RPC_S_OK; - HeapFree(GetProcessHeap(), 0, header); + free(header); } return status; } @@ -2953,7 +2940,6 @@ static void drain_content(HINTERNET request, RpcHttpAsyncData *async_data, HANDL static RPC_STATUS authorize_request(RpcConnection_http *httpc, HINTERNET request) { - static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':','\r','\n',0}; struct authinfo *info = NULL; RPC_STATUS status; BOOL ret; @@ -2977,7 +2963,7 @@ static RPC_STATUS authorize_request(RpcConnection_http *httpc, HINTERNET request } if (info->scheme != RPC_C_HTTP_AUTHN_SCHEME_BASIC) - HttpAddRequestHeadersW(request, authW, -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD); + HttpAddRequestHeadersW(request, L"Authorization:\r\n", -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD); destroy_authinfo(info); return status; @@ -3010,8 +2996,8 @@ static BOOL is_secure(RpcConnection_http *httpc) static RPC_STATUS set_auth_cookie(RpcConnection_http *httpc, const WCHAR *value) { - static WCHAR httpW[] = {'h','t','t','p',0}; - static WCHAR httpsW[] = {'h','t','t','p','s',0}; + static WCHAR httpW[] = L"http"; + static WCHAR httpsW[] = L"https"; URL_COMPONENTSW uc; DWORD len; WCHAR *url; @@ -3037,17 +3023,17 @@ static RPC_STATUS set_auth_cookie(RpcConnection_http *httpc, const WCHAR *value) if (!InternetCreateUrlW(&uc, 0, NULL, &len) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER)) return RPC_S_SERVER_UNAVAILABLE; - if (!(url = HeapAlloc(GetProcessHeap(), 0, len))) return RPC_S_OUT_OF_MEMORY; + if (!(url = malloc(len))) return RPC_S_OUT_OF_MEMORY; len = len / sizeof(WCHAR) - 1; if (!InternetCreateUrlW(&uc, 0, url, &len)) { - HeapFree(GetProcessHeap(), 0, url); + free(url); return RPC_S_SERVER_UNAVAILABLE; } ret = InternetSetCookieW(url, NULL, value); - HeapFree(GetProcessHeap(), 0, url); + free(url); if (!ret) return RPC_S_SERVER_UNAVAILABLE; return RPC_S_OK; @@ -3056,12 +3042,8 @@ static RPC_STATUS set_auth_cookie(RpcConnection_http *httpc, const WCHAR *value) static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection) { RpcConnection_http *httpc = (RpcConnection_http *)Connection; - static const WCHAR wszVerbIn[] = {'R','P','C','_','I','N','_','D','A','T','A',0}; - static const WCHAR wszVerbOut[] = {'R','P','C','_','O','U','T','_','D','A','T','A',0}; - static const WCHAR wszRpcProxyPrefix[] = {'/','r','p','c','/','r','p','c','p','r','o','x','y','.','d','l','l','?',0}; - static const WCHAR wszColon[] = {':',0}; - static const WCHAR wszAcceptType[] = {'a','p','p','l','i','c','a','t','i','o','n','/','r','p','c',0}; - LPCWSTR wszAcceptTypes[] = { wszAcceptType, NULL }; + static const WCHAR wszRpcProxyPrefix[] = L"/rpc/rpcproxy.dll?"; + LPCWSTR wszAcceptTypes[] = { L"application/rpc", NULL }; DWORD flags; WCHAR *url; RPC_STATUS status; @@ -3090,13 +3072,14 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection) if (status != RPC_S_OK) return status; - url = HeapAlloc(GetProcessHeap(), 0, sizeof(wszRpcProxyPrefix) + (strlen(Connection->NetworkAddr) + 1 + strlen(Connection->Endpoint))*sizeof(WCHAR)); + url = malloc(sizeof(wszRpcProxyPrefix) + + (strlen(Connection->NetworkAddr) + 1 + strlen(Connection->Endpoint)) * sizeof(WCHAR)); if (!url) return RPC_S_OUT_OF_MEMORY; memcpy(url, wszRpcProxyPrefix, sizeof(wszRpcProxyPrefix)); MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+ARRAY_SIZE(wszRpcProxyPrefix)-1, strlen(Connection->NetworkAddr)+1); - lstrcatW(url, wszColon); + lstrcatW(url, L":"); MultiByteToWideChar(CP_ACP, 0, Connection->Endpoint, -1, url+lstrlenW(url), strlen(Connection->Endpoint)+1); secure = is_secure(httpc); @@ -3110,15 +3093,15 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection) status = set_auth_cookie(httpc, Connection->CookieAuth); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, url); + free(url); return status; } - httpc->in_request = HttpOpenRequestW(httpc->session, wszVerbIn, url, NULL, NULL, wszAcceptTypes, + httpc->in_request = HttpOpenRequestW(httpc->session, L"RPC_IN_DATA", url, NULL, NULL, wszAcceptTypes, flags, (DWORD_PTR)httpc->async_data); if (!httpc->in_request) { - ERR("HttpOpenRequestW failed with error %d\n", GetLastError()); - HeapFree(GetProcessHeap(), 0, url); + ERR("HttpOpenRequestW failed with error %ld\n", GetLastError()); + free(url); return RPC_S_SERVER_UNAVAILABLE; } @@ -3127,24 +3110,24 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection) status = authorize_request(httpc, httpc->in_request); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, url); + free(url); return status; } status = rpcrt4_http_check_response(httpc->in_request); if (status != RPC_S_OK) { - HeapFree(GetProcessHeap(), 0, url); + free(url); return status; } drain_content(httpc->in_request, httpc->async_data, httpc->cancel_event); } - httpc->out_request = HttpOpenRequestW(httpc->session, wszVerbOut, url, NULL, NULL, wszAcceptTypes, + httpc->out_request = HttpOpenRequestW(httpc->session, L"RPC_OUT_DATA", url, NULL, NULL, wszAcceptTypes, flags, (DWORD_PTR)httpc->async_data); - HeapFree(GetProcessHeap(), 0, url); + free(url); if (!httpc->out_request) { - ERR("HttpOpenRequestW failed with error %d\n", GetLastError()); + ERR("HttpOpenRequestW failed with error %ld\n", GetLastError()); return RPC_S_SERVER_UNAVAILABLE; } @@ -3171,7 +3154,7 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection) httpc->last_sent_time = GetTickCount(); httpc->timer_cancelled = CreateEventW(NULL, FALSE, FALSE, NULL); - timer_data = HeapAlloc(GetProcessHeap(), 0, sizeof(*timer_data)); + timer_data = malloc(sizeof(*timer_data)); if (!timer_data) return ERROR_OUTOFMEMORY; timer_data->timer_param = httpc->in_request; @@ -3181,7 +3164,7 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection) thread = CreateThread(NULL, 0, rpcrt4_http_timer_thread, timer_data, 0, NULL); if (!thread) { - HeapFree(GetProcessHeap(), 0, timer_data); + free(timer_data); return GetLastError(); } CloseHandle(thread); @@ -3218,7 +3201,7 @@ again: /* read packet common header */ dwRead = rpcrt4_ncacn_http_read(Connection, &common_hdr, sizeof(common_hdr)); if (dwRead != sizeof(common_hdr)) { - WARN("Short read of header, %d bytes\n", dwRead); + WARN("Short read of header, %ld bytes\n", dwRead); status = RPC_S_PROTOCOL_ERROR; goto fail; } @@ -3240,7 +3223,7 @@ again: goto fail; } - *Header = HeapAlloc(GetProcessHeap(), 0, hdr_length); + *Header = malloc(hdr_length); if (!*Header) { status = RPC_S_OUT_OF_RESOURCES; @@ -3251,14 +3234,14 @@ again: /* read the rest of packet header */ dwRead = rpcrt4_ncacn_http_read(Connection, &(*Header)->common + 1, hdr_length - sizeof(common_hdr)); if (dwRead != hdr_length - sizeof(common_hdr)) { - WARN("bad header length, %d bytes, hdr_length %d\n", dwRead, hdr_length); + WARN("bad header length, %ld bytes, hdr_length %ld\n", dwRead, hdr_length); status = RPC_S_PROTOCOL_ERROR; goto fail; } if (common_hdr.frag_len - hdr_length) { - *Payload = HeapAlloc(GetProcessHeap(), 0, common_hdr.frag_len - hdr_length); + *Payload = malloc(common_hdr.frag_len - hdr_length); if (!*Payload) { status = RPC_S_OUT_OF_RESOURCES; @@ -3268,7 +3251,7 @@ again: dwRead = rpcrt4_ncacn_http_read(Connection, *Payload, common_hdr.frag_len - hdr_length); if (dwRead != common_hdr.frag_len - hdr_length) { - WARN("bad data length, %d/%d\n", dwRead, common_hdr.frag_len - hdr_length); + WARN("bad data length, %ld/%ld\n", dwRead, common_hdr.frag_len - hdr_length); status = RPC_S_PROTOCOL_ERROR; goto fail; } @@ -3306,7 +3289,7 @@ again: &pipe_uuid); if (status != RPC_S_OK) goto fail; - TRACE("received http flow control header (0x%x, 0x%x, %s)\n", + TRACE("received http flow control header (0x%lx, 0x%lx, %s)\n", bytes_transmitted, flow_control_increment, debugstr_guid(&pipe_uuid)); /* FIXME: do something with parsed data */ } @@ -3316,9 +3299,9 @@ again: status = RPC_S_PROTOCOL_ERROR; goto fail; } - RPCRT4_FreeHeader(*Header); + free(*Header); *Header = NULL; - HeapFree(GetProcessHeap(), 0, *Payload); + free(*Payload); *Payload = NULL; goto again; } @@ -3328,7 +3311,7 @@ again: httpc->bytes_received += common_hdr.frag_len; - TRACE("httpc->bytes_received = 0x%x\n", httpc->bytes_received); + TRACE("httpc->bytes_received = 0x%lx\n", httpc->bytes_received); if (httpc->bytes_received > httpc->flow_control_mark) { @@ -3340,9 +3323,9 @@ again: { DWORD bytes_written; BOOL ret2; - TRACE("sending flow control packet at 0x%x\n", httpc->bytes_received); + TRACE("sending flow control packet at 0x%lx\n", httpc->bytes_received); ret2 = InternetWriteFile(httpc->in_request, hdr, hdr->common.frag_len, &bytes_written); - RPCRT4_FreeHeader(hdr); + free(hdr); if (ret2) httpc->flow_control_mark = httpc->bytes_received + httpc->flow_control_increment / 2; } @@ -3350,9 +3333,9 @@ again: fail: if (status != RPC_S_OK) { - RPCRT4_FreeHeader(*Header); + free(*Header); *Header = NULL; - HeapFree(GetProcessHeap(), 0, *Payload); + free(*Payload); *Payload = NULL; } return status; @@ -3394,7 +3377,7 @@ static int rpcrt4_ncacn_http_close(RpcConnection *Connection) RpcHttpAsyncData_Release(httpc->async_data); if (httpc->cancel_event) CloseHandle(httpc->cancel_event); - HeapFree(GetProcessHeap(), 0, httpc->servername); + free(httpc->servername); httpc->servername = NULL; return 0; @@ -3471,6 +3454,7 @@ static const struct connection_ops conn_protseq_list[] = { rpcrt4_conn_np_impersonate_client, rpcrt4_conn_np_revert_to_self, RPCRT4_default_inquire_auth_client, + NULL }, { "ncalrpc", { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE }, @@ -3493,6 +3477,7 @@ static const struct connection_ops conn_protseq_list[] = { rpcrt4_conn_np_impersonate_client, rpcrt4_conn_np_revert_to_self, rpcrt4_ncalrpc_inquire_auth_client, + rpcrt4_ncalrpc_inquire_client_pid }, { "ncacn_ip_tcp", { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP }, @@ -3515,6 +3500,7 @@ static const struct connection_ops conn_protseq_list[] = { RPCRT4_default_impersonate_client, RPCRT4_default_revert_to_self, RPCRT4_default_inquire_auth_client, + NULL }, { "ncacn_http", { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_HTTP }, @@ -3537,6 +3523,7 @@ static const struct connection_ops conn_protseq_list[] = { RPCRT4_default_impersonate_client, RPCRT4_default_revert_to_self, RPCRT4_default_inquire_auth_client, + NULL }, }; @@ -3631,10 +3618,10 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, NewConnection->ref = 1; NewConnection->server = server; NewConnection->ops = ops; - NewConnection->NetworkAddr = RPCRT4_strdupA(NetworkAddr); - NewConnection->Endpoint = RPCRT4_strdupA(Endpoint); - NewConnection->NetworkOptions = RPCRT4_strdupW(NetworkOptions); - NewConnection->CookieAuth = RPCRT4_strdupW(CookieAuth); + NewConnection->NetworkAddr = strdup(NetworkAddr); + NewConnection->Endpoint = strdup(Endpoint); + NewConnection->NetworkOptions = wcsdup(NetworkOptions); + NewConnection->CookieAuth = wcsdup(CookieAuth); NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE; NewConnection->NextCallId = 1; @@ -3695,7 +3682,7 @@ void rpcrt4_conn_release_and_wait(RpcConnection *connection) RpcConnection *RPCRT4_GrabConnection(RpcConnection *connection) { LONG ref = InterlockedIncrement(&connection->ref); - TRACE("%p ref=%u\n", connection, ref); + TRACE("%p ref=%lu\n", connection, ref); return connection; } @@ -3720,15 +3707,15 @@ void RPCRT4_ReleaseConnection(RpcConnection *connection) ref = InterlockedDecrement(&connection->ref); } - TRACE("%p ref=%u\n", connection, ref); + TRACE("%p ref=%lu\n", connection, ref); if (!ref) { RPCRT4_CloseConnection(connection); - RPCRT4_strfree(connection->Endpoint); - RPCRT4_strfree(connection->NetworkAddr); - HeapFree(GetProcessHeap(), 0, connection->NetworkOptions); - HeapFree(GetProcessHeap(), 0, connection->CookieAuth); + free(connection->Endpoint); + free(connection->NetworkAddr); + free(connection->NetworkOptions); + free(connection->CookieAuth); if (connection->AuthInfo) RpcAuthInfo_Release(connection->AuthInfo); if (connection->QOS) RpcQualityOfService_Release(connection->QOS); @@ -3738,7 +3725,7 @@ void RPCRT4_ReleaseConnection(RpcConnection *connection) if (connection->wait_release) SetEvent(connection->wait_release); - HeapFree(GetProcessHeap(), 0, connection); + free(connection); } } @@ -3892,8 +3879,8 @@ RPC_STATUS WINAPI RpcProtseqVectorFreeA(RPC_PROTSEQ_VECTORA **protseqs) { unsigned int i; for (i = 0; i < (*protseqs)->Count; i++) - HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]); - HeapFree(GetProcessHeap(), 0, *protseqs); + free((*protseqs)->Protseq[i]); + free(*protseqs); *protseqs = NULL; } return RPC_S_OK; @@ -3910,8 +3897,8 @@ RPC_STATUS WINAPI RpcProtseqVectorFreeW(RPC_PROTSEQ_VECTORW **protseqs) { unsigned int i; for (i = 0; i < (*protseqs)->Count; i++) - HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]); - HeapFree(GetProcessHeap(), 0, *protseqs); + free((*protseqs)->Protseq[i]); + free(*protseqs); *protseqs = NULL; } return RPC_S_OK; @@ -3928,14 +3915,14 @@ RPC_STATUS WINAPI RpcNetworkInqProtseqsW( RPC_PROTSEQ_VECTORW** protseqs ) TRACE("(%p)\n", protseqs); - *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAY_SIZE(protseq_list))); + *protseqs = malloc(sizeof(RPC_PROTSEQ_VECTORW) + sizeof(unsigned short*) * ARRAY_SIZE(protseq_list)); if (!*protseqs) goto end; pvector = *protseqs; pvector->Count = 0; for (i = 0; i < ARRAY_SIZE(protseq_list); i++) { - pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, (strlen(protseq_list[i].name)+1)*sizeof(unsigned short)); + pvector->Protseq[i] = malloc((strlen(protseq_list[i].name) + 1) * sizeof(unsigned short)); if (pvector->Protseq[i] == NULL) goto end; MultiByteToWideChar(CP_ACP, 0, (CHAR*)protseq_list[i].name, -1, @@ -3961,14 +3948,14 @@ RPC_STATUS WINAPI RpcNetworkInqProtseqsA(RPC_PROTSEQ_VECTORA** protseqs) TRACE("(%p)\n", protseqs); - *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAY_SIZE(protseq_list))); + *protseqs = malloc(sizeof(RPC_PROTSEQ_VECTORW) + sizeof(unsigned char*) * ARRAY_SIZE(protseq_list)); if (!*protseqs) goto end; pvector = *protseqs; pvector->Count = 0; for (i = 0; i < ARRAY_SIZE(protseq_list); i++) { - pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_list[i].name)+1); + pvector->Protseq[i] = malloc(strlen(protseq_list[i].name) + 1); if (pvector->Protseq[i] == NULL) goto end; strcpy((char*)pvector->Protseq[i], protseq_list[i].name); diff --git a/dll/win32/rpcrt4/rpcrt4.spec b/dll/win32/rpcrt4/rpcrt4.spec index 68d319fbc20..7b946ca37ff 100644 --- a/dll/win32/rpcrt4/rpcrt4.spec +++ b/dll/win32/rpcrt4/rpcrt4.spec @@ -1,523 +1,527 @@ -1 stdcall CreateProxyFromTypeInfo(ptr ptr ptr ptr ptr) -2 stdcall CreateStubFromTypeInfo(ptr ptr ptr ptr) -# I_RpcServerTurnOnOffKeepalives -4 stdcall CStdStubBuffer_AddRef(ptr) -5 stdcall CStdStubBuffer_Connect(ptr ptr) -6 stdcall CStdStubBuffer_CountRefs(ptr) -7 stdcall CStdStubBuffer_DebugServerQueryInterface(ptr ptr) -8 stdcall CStdStubBuffer_DebugServerRelease(ptr ptr) -9 stdcall CStdStubBuffer_Disconnect(ptr) -10 stdcall CStdStubBuffer_Invoke(ptr ptr ptr) -11 stdcall CStdStubBuffer_IsIIDSupported(ptr ptr) -12 stdcall CStdStubBuffer_QueryInterface(ptr ptr ptr) -13 stdcall DceErrorInqTextA (long ptr) -14 stdcall DceErrorInqTextW (long ptr) -# DllGetClassObject -# DllInstall +@ stdcall CreateProxyFromTypeInfo(ptr ptr ptr ptr ptr) +@ stdcall CreateStubFromTypeInfo(ptr ptr ptr ptr) +@ stub I_RpcServerTurnOnOffKeepalives +@ stdcall CStdStubBuffer_AddRef(ptr) +@ stdcall CStdStubBuffer_Connect(ptr ptr) +@ stdcall CStdStubBuffer_CountRefs(ptr) +@ stdcall CStdStubBuffer_DebugServerQueryInterface(ptr ptr) +@ stdcall CStdStubBuffer_DebugServerRelease(ptr ptr) +@ stdcall CStdStubBuffer_Disconnect(ptr) +@ stdcall CStdStubBuffer_Invoke(ptr ptr ptr) +@ stdcall CStdStubBuffer_IsIIDSupported(ptr ptr) +@ stdcall CStdStubBuffer_QueryInterface(ptr ptr ptr) +@ stdcall DceErrorInqTextA (long ptr) +@ stdcall DceErrorInqTextW (long ptr) +#@ stub DllGetClassObject +@ stub DllInstall @ stdcall -private DllRegisterServer() -18 stub GlobalMutexClearExternal -19 stub GlobalMutexRequestExternal -20 stdcall IUnknown_AddRef_Proxy(ptr) -21 stdcall IUnknown_QueryInterface_Proxy(ptr ptr ptr) -22 stdcall IUnknown_Release_Proxy(ptr) -23 stdcall I_RpcAbortAsyncCall(ptr long) I_RpcAsyncAbortCall -24 stdcall I_RpcAllocate(long) -25 stdcall I_RpcAsyncAbortCall(ptr long) -26 stdcall I_RpcAsyncSetHandle(ptr ptr) -27 stub I_RpcBCacheAllocate -28 stub I_RpcBCacheFree -29 stub I_RpcBindingCopy -# I_RpcBindingHandleToAsyncHandle -31 stub I_RpcBindingInqConnId -32 stub I_RpcBindingInqDynamicEndPoint -33 stub I_RpcBindingInqDynamicEndPointA -34 stub I_RpcBindingInqDynamicEndPointW -35 stdcall I_RpcBindingInqLocalClientPID(ptr ptr) -# I_RpcBindingInqMarshalledTargetInfo -37 stub I_RpcBindingInqSecurityContext -38 stdcall I_RpcBindingInqTransportType(ptr ptr) -39 stub I_RpcBindingInqWireIdForSnego -40 stub I_RpcBindingIsClientLocal -41 stub I_RpcBindingToStaticStringBindingW -42 stub I_RpcClearMutex -43 stub I_RpcConnectionInqSockBuffSize -44 stub I_RpcConnectionSetSockBuffSize -45 stub I_RpcDeleteMutex -46 stub I_RpcEnableWmiTrace -47 stdcall I_RpcExceptionFilter(long) RpcExceptionFilter -48 stdcall I_RpcFree(ptr) -49 stdcall I_RpcFreeBuffer(ptr) -50 stub I_RpcFreePipeBuffer -51 stdcall I_RpcGetBuffer(ptr) -52 stub I_RpcGetBufferWithObject -53 stdcall I_RpcGetCurrentCallHandle() -54 stub I_RpcGetExtendedError -55 stub I_RpcIfInqTransferSyntaxes -56 stub I_RpcLogEvent -57 stdcall I_RpcMapWin32Status(long) -# I_RpcNDRCGetWireRepresentation -# I_RpcNDRSContextEmergencyCleanup -60 stdcall I_RpcNegotiateTransferSyntax(ptr) -61 stub I_RpcNsBindingSetEntryName -62 stub I_RpcNsBindingSetEntryNameA -63 stub I_RpcNsBindingSetEntryNameW -64 stub I_RpcNsInterfaceExported -65 stub I_RpcNsInterfaceUnexported -66 stub I_RpcParseSecurity -67 stub I_RpcPauseExecution -68 stub I_RpcProxyNewConnection -69 stub I_RpcReallocPipeBuffer -70 stdcall I_RpcReceive(ptr) -# I_RpcRecordCalloutFailure -# I_RpcReplyToClientWithStatus -73 stub I_RpcRequestMutex -74 stub I_RpcSNCHOption -75 stdcall I_RpcSend(ptr) -76 stdcall I_RpcSendReceive(ptr) -77 stub I_RpcServerAllocateIpPort -# I_RpcServerCheckClientRestriction -79 stub I_RpcServerInqAddressChangeFn -80 stub I_RpcServerInqLocalConnAddress -81 stub I_RpcServerInqTransportType -# I_RpcServerIsClientDisconnected -83 stub I_RpcServerRegisterForwardFunction -84 stub I_RpcServerSetAddressChangeFn -85 stub I_RpcServerUseProtseq2A -86 stub I_RpcServerUseProtseq2W -87 stub I_RpcServerUseProtseqEp2A -88 stub I_RpcServerUseProtseqEp2W -# I_RpcSessionStrictContextHandle -90 stub I_RpcSetAsyncHandle -91 stub I_RpcSsDontSerializeContext -92 stub I_RpcSystemFunction001 -93 stub I_RpcTransConnectionAllocatePacket -94 stub I_RpcTransConnectionFreePacket -95 stub I_RpcTransConnectionReallocPacket -96 stub I_RpcTransDatagramAllocate2 -97 stub I_RpcTransDatagramAllocate -98 stub I_RpcTransDatagramFree -99 stub I_RpcTransGetThreadEvent -100 stub I_RpcTransIoCancelled -101 stub I_RpcTransServerNewConnection -102 stub I_RpcTurnOnEEInfoPropagation -103 stdcall I_UuidCreate(ptr) -104 stub MIDL_wchar_strcpy -105 stub MIDL_wchar_strlen -106 stdcall MesBufferHandleReset(ptr long long ptr long ptr) -107 stdcall MesDecodeBufferHandleCreate(ptr long ptr) -108 stdcall MesDecodeIncrementalHandleCreate(ptr ptr ptr) -109 stdcall MesEncodeDynBufferHandleCreate(ptr ptr ptr) -110 stdcall MesEncodeFixedBufferHandleCreate(ptr long ptr ptr) -111 stdcall MesEncodeIncrementalHandleCreate(ptr ptr ptr ptr) -112 stdcall MesHandleFree(ptr) -113 stdcall MesIncrementalHandleReset(ptr ptr ptr ptr ptr long) -114 stub MesInqProcEncodingId -115 stdcall NDRCContextBinding(ptr) -116 stdcall NDRCContextMarshall(ptr ptr) -117 stdcall NDRCContextUnmarshall(ptr ptr ptr long) -118 stdcall NDRSContextMarshall2(ptr ptr ptr ptr ptr long) -119 stdcall NDRSContextMarshall(ptr ptr ptr) -120 stdcall NDRSContextMarshallEx(ptr ptr ptr ptr) -121 stdcall NDRSContextUnmarshall2(ptr ptr long ptr long) -122 stdcall NDRSContextUnmarshall(ptr long) -123 stdcall NDRSContextUnmarshallEx(ptr ptr long) -124 stub NDRcopy -125 stdcall NdrAllocate(ptr long) -126 varargs NdrAsyncClientCall(ptr ptr) -127 stdcall NdrAsyncServerCall(ptr) -128 stdcall NdrByteCountPointerBufferSize(ptr ptr ptr) -129 stdcall NdrByteCountPointerFree(ptr ptr ptr) -130 stdcall NdrByteCountPointerMarshall(ptr ptr ptr) -131 stdcall NdrByteCountPointerUnmarshall(ptr ptr ptr long) -132 stdcall NdrCStdStubBuffer2_Release(ptr ptr) -133 stdcall NdrCStdStubBuffer_Release(ptr ptr) -134 stdcall NdrClearOutParameters(ptr ptr ptr) -135 varargs -arch=i386 NdrClientCall(ptr ptr) NdrClientCall2 -136 varargs NdrClientCall2(ptr ptr) -137 stdcall NdrClientContextMarshall(ptr ptr long) -138 stdcall NdrClientContextUnmarshall(ptr ptr ptr) -139 stub NdrClientInitialize -140 stdcall NdrClientInitializeNew(ptr ptr ptr long) -141 stdcall NdrComplexArrayBufferSize(ptr ptr ptr) -142 stdcall NdrComplexArrayFree(ptr ptr ptr) -143 stdcall NdrComplexArrayMarshall(ptr ptr ptr) -144 stdcall NdrComplexArrayMemorySize(ptr ptr) -145 stdcall NdrComplexArrayUnmarshall(ptr ptr ptr long) -146 stdcall NdrComplexStructBufferSize(ptr ptr ptr) -147 stdcall NdrComplexStructFree(ptr ptr ptr) -148 stdcall NdrComplexStructMarshall(ptr ptr ptr) -149 stdcall NdrComplexStructMemorySize(ptr ptr) -150 stdcall NdrComplexStructUnmarshall(ptr ptr ptr long) -151 stdcall NdrConformantArrayBufferSize(ptr ptr ptr) -152 stdcall NdrConformantArrayFree(ptr ptr ptr) -153 stdcall NdrConformantArrayMarshall(ptr ptr ptr) -154 stdcall NdrConformantArrayMemorySize(ptr ptr) -155 stdcall NdrConformantArrayUnmarshall(ptr ptr ptr long) -156 stdcall NdrConformantStringBufferSize(ptr ptr ptr) -157 stdcall NdrConformantStringMarshall(ptr ptr ptr) -158 stdcall NdrConformantStringMemorySize(ptr ptr) -159 stdcall NdrConformantStringUnmarshall(ptr ptr ptr long) -160 stdcall NdrConformantStructBufferSize(ptr ptr ptr) -161 stdcall NdrConformantStructFree(ptr ptr ptr) -162 stdcall NdrConformantStructMarshall(ptr ptr ptr) -163 stdcall NdrConformantStructMemorySize(ptr ptr) -164 stdcall NdrConformantStructUnmarshall(ptr ptr ptr long) -165 stdcall NdrConformantVaryingArrayBufferSize(ptr ptr ptr) -166 stdcall NdrConformantVaryingArrayFree(ptr ptr ptr) -167 stdcall NdrConformantVaryingArrayMarshall(ptr ptr ptr) -168 stdcall NdrConformantVaryingArrayMemorySize(ptr ptr) -169 stdcall NdrConformantVaryingArrayUnmarshall(ptr ptr ptr long) -170 stdcall NdrConformantVaryingStructBufferSize(ptr ptr ptr) -171 stdcall NdrConformantVaryingStructFree(ptr ptr ptr) -172 stdcall NdrConformantVaryingStructMarshall(ptr ptr ptr) -173 stdcall NdrConformantVaryingStructMemorySize(ptr ptr) -174 stdcall NdrConformantVaryingStructUnmarshall(ptr ptr ptr long) -175 stdcall NdrContextHandleInitialize(ptr ptr) -176 stdcall NdrContextHandleSize(ptr ptr ptr) -177 stdcall NdrConvert2(ptr ptr long) -178 stdcall NdrConvert(ptr ptr) -179 stdcall NdrCorrelationFree(ptr) -180 stdcall NdrCorrelationInitialize(ptr ptr long long) -181 stdcall NdrCorrelationPass(ptr) -182 stub NdrCreateServerInterfaceFromStub -183 stub NdrDcomAsyncClientCall -184 stub NdrDcomAsyncStubCall -185 stdcall NdrDllCanUnloadNow(ptr) -186 stdcall NdrDllGetClassObject(ptr ptr ptr ptr ptr ptr) -187 stdcall NdrDllRegisterProxy(long ptr ptr) -188 stdcall NdrDllUnregisterProxy(long ptr ptr) -189 stdcall NdrEncapsulatedUnionBufferSize(ptr ptr ptr) -190 stdcall NdrEncapsulatedUnionFree(ptr ptr ptr) -191 stdcall NdrEncapsulatedUnionMarshall(ptr ptr ptr) -192 stdcall NdrEncapsulatedUnionMemorySize(ptr ptr) -193 stdcall NdrEncapsulatedUnionUnmarshall(ptr ptr ptr long) -194 stdcall NdrFixedArrayBufferSize(ptr ptr ptr) -195 stdcall NdrFixedArrayFree(ptr ptr ptr) -196 stdcall NdrFixedArrayMarshall(ptr ptr ptr) -197 stdcall NdrFixedArrayMemorySize(ptr ptr) -198 stdcall NdrFixedArrayUnmarshall(ptr ptr ptr long) -199 stdcall NdrFreeBuffer(ptr) -200 stdcall NdrFullPointerFree(ptr ptr) -201 stdcall NdrFullPointerInsertRefId(ptr long ptr) -202 stdcall NdrFullPointerQueryPointer(ptr ptr long ptr) -203 stdcall NdrFullPointerQueryRefId(ptr long long ptr) -204 stdcall NdrFullPointerXlatFree(ptr) -205 stdcall NdrFullPointerXlatInit(long long) -206 stdcall NdrGetBuffer(ptr long ptr) -207 stub NdrGetDcomProtocolVersion -208 stub NdrGetSimpleTypeBufferAlignment -209 stub NdrGetSimpleTypeBufferSize -210 stub NdrGetSimpleTypeMemorySize -211 stub NdrGetTypeFlags -212 stdcall NdrGetUserMarshalInfo(ptr long ptr) -213 stdcall NdrInterfacePointerBufferSize(ptr ptr ptr) -214 stdcall NdrInterfacePointerFree(ptr ptr ptr) -215 stdcall NdrInterfacePointerMarshall(ptr ptr ptr) -216 stdcall NdrInterfacePointerMemorySize(ptr ptr) -217 stdcall NdrInterfacePointerUnmarshall(ptr ptr ptr long) -218 stdcall NdrMapCommAndFaultStatus(ptr ptr ptr long) -219 varargs NdrMesProcEncodeDecode(ptr ptr ptr) -220 stub NdrMesProcEncodeDecode2 -221 stub NdrMesSimpleTypeAlignSize -222 stub NdrMesSimpleTypeDecode -223 stub NdrMesSimpleTypeEncode -224 stub NdrMesTypeAlignSize2 -225 stub NdrMesTypeAlignSize -226 stdcall NdrMesTypeDecode2(ptr ptr ptr ptr ptr) -227 stub NdrMesTypeDecode -228 stdcall NdrMesTypeEncode2(ptr ptr ptr ptr ptr) -229 stub NdrMesTypeEncode -230 stdcall NdrMesTypeFree2(ptr ptr ptr ptr ptr) -231 stdcall NdrNonConformantStringBufferSize(ptr ptr ptr) -232 stdcall NdrNonConformantStringMarshall(ptr ptr ptr) -233 stdcall NdrNonConformantStringMemorySize(ptr ptr) -234 stdcall NdrNonConformantStringUnmarshall(ptr ptr ptr long) -235 stdcall NdrNonEncapsulatedUnionBufferSize(ptr ptr ptr) -236 stdcall NdrNonEncapsulatedUnionFree(ptr ptr ptr) -237 stdcall NdrNonEncapsulatedUnionMarshall(ptr ptr ptr) -238 stdcall NdrNonEncapsulatedUnionMemorySize(ptr ptr) -239 stdcall NdrNonEncapsulatedUnionUnmarshall(ptr ptr ptr long) -240 stub NdrNsGetBuffer -241 stub NdrNsSendReceive -242 stdcall NdrOleAllocate(long) -243 stdcall NdrOleFree(ptr) -244 stub NdrOutInit -245 stub NdrPartialIgnoreClientBufferSize -246 stub NdrPartialIgnoreClientMarshall -247 stub NdrPartialIgnoreServerInitialize -248 stub NdrPartialIgnoreServerUnmarshall -249 stdcall NdrPointerBufferSize(ptr ptr ptr) -250 stdcall NdrPointerFree(ptr ptr ptr) -251 stdcall NdrPointerMarshall(ptr ptr ptr) -252 stdcall NdrPointerMemorySize(ptr ptr) -253 stdcall NdrPointerUnmarshall(ptr ptr ptr long) -254 stdcall NdrProxyErrorHandler(long) -255 stdcall NdrProxyFreeBuffer(ptr ptr) -256 stdcall NdrProxyGetBuffer(ptr ptr) -257 stdcall NdrProxyInitialize(ptr ptr ptr ptr long) -258 stdcall NdrProxySendReceive(ptr ptr) -259 stdcall NdrRangeUnmarshall(ptr ptr ptr long) -260 stub NdrRpcSmClientAllocate -261 stub NdrRpcSmClientFree -262 stdcall NdrRpcSmSetClientToOsf(ptr) -263 stub NdrRpcSsDefaultAllocate -264 stub NdrRpcSsDefaultFree -265 stub NdrRpcSsDisableAllocate -266 stub NdrRpcSsEnableAllocate -267 stdcall NdrSendReceive(ptr ptr) -268 stdcall NdrServerCall2(ptr) -269 stdcall NdrServerCall(ptr) +@ stub GlobalMutexClearExternal +@ stub GlobalMutexRequestExternal +@ stdcall IUnknown_AddRef_Proxy(ptr) +@ stdcall IUnknown_QueryInterface_Proxy(ptr ptr ptr) +@ stdcall IUnknown_Release_Proxy(ptr) +@ stdcall I_RpcAbortAsyncCall(ptr long) I_RpcAsyncAbortCall +@ stdcall I_RpcAllocate(long) +@ stdcall I_RpcAsyncAbortCall(ptr long) +@ stdcall I_RpcAsyncSetHandle(ptr ptr) +@ stub I_RpcBCacheAllocate +@ stub I_RpcBCacheFree +@ stub I_RpcBindingCopy +@ stub I_RpcBindingHandleToAsyncHandle +@ stub I_RpcBindingInqConnId +@ stub I_RpcBindingInqDynamicEndPoint +@ stub I_RpcBindingInqDynamicEndPointA +@ stub I_RpcBindingInqDynamicEndPointW +@ stdcall I_RpcBindingInqLocalClientPID(ptr ptr) +@ stub I_RpcBindingInqMarshalledTargetInfo +@ stub I_RpcBindingInqSecurityContext +@ stdcall I_RpcBindingInqTransportType(ptr ptr) +@ stub I_RpcBindingInqWireIdForSnego +@ stub I_RpcBindingIsClientLocal +@ stub I_RpcBindingToStaticStringBindingW +@ stub I_RpcClearMutex +@ stub I_RpcConnectionInqSockBuffSize +@ stub I_RpcConnectionSetSockBuffSize +@ stub I_RpcDeleteMutex +@ stub I_RpcEnableWmiTrace +@ stdcall I_RpcExceptionFilter(long) RpcExceptionFilter +@ stdcall I_RpcFree(ptr) +@ stdcall I_RpcFreeBuffer(ptr) +@ stub I_RpcFreePipeBuffer +@ stdcall I_RpcGetBuffer(ptr) +@ stub I_RpcGetBufferWithObject +@ stdcall I_RpcGetCurrentCallHandle() +@ stub I_RpcGetExtendedError +@ stub I_RpcIfInqTransferSyntaxes +@ stub I_RpcLogEvent +@ stdcall I_RpcMapWin32Status(long) +@ stub I_RpcNDRCGetWireRepresentation +@ stub I_RpcNDRSContextEmergencyCleanup +@ stdcall I_RpcNegotiateTransferSyntax(ptr) +@ stub I_RpcNsBindingSetEntryName +@ stub I_RpcNsBindingSetEntryNameA +@ stub I_RpcNsBindingSetEntryNameW +@ stub I_RpcNsInterfaceExported +@ stub I_RpcNsInterfaceUnexported +@ stub I_RpcParseSecurity +@ stub I_RpcPauseExecution +@ stub I_RpcProxyNewConnection +@ stub I_RpcReallocPipeBuffer +@ stdcall I_RpcReceive(ptr) +@ stub I_RpcRecordCalloutFailure +@ stub I_RpcReplyToClientWithStatus +@ stub I_RpcRequestMutex +@ stub I_RpcSNCHOption +@ stdcall I_RpcSend(ptr) +@ stdcall I_RpcSendReceive(ptr) +@ stub I_RpcServerAllocateIpPort +@ stub I_RpcServerCheckClientRestriction +@ stub I_RpcServerInqAddressChangeFn +@ stub I_RpcServerInqLocalConnAddress +@ stub I_RpcServerInqTransportType +@ stub I_RpcServerIsClientDisconnected +@ stub I_RpcServerRegisterForwardFunction +@ stub I_RpcServerSetAddressChangeFn +@ stub I_RpcServerUseProtseq2A +@ stub I_RpcServerUseProtseq2W +@ stub I_RpcServerUseProtseqEp2A +@ stub I_RpcServerUseProtseqEp2W +@ stub I_RpcSessionStrictContextHandle +@ stub I_RpcSetAsyncHandle +@ stub I_RpcSsDontSerializeContext +@ stub I_RpcSystemFunction001 +@ stub I_RpcTransConnectionAllocatePacket +@ stub I_RpcTransConnectionFreePacket +@ stub I_RpcTransConnectionReallocPacket +@ stub I_RpcTransDatagramAllocate2 +@ stub I_RpcTransDatagramAllocate +@ stub I_RpcTransDatagramFree +@ stub I_RpcTransGetThreadEvent +@ stub I_RpcTransIoCancelled +@ stub I_RpcTransServerNewConnection +@ stub I_RpcTurnOnEEInfoPropagation +@ stdcall I_UuidCreate(ptr) +@ stub MIDL_wchar_strcpy +@ stub MIDL_wchar_strlen +@ stdcall MesBufferHandleReset(ptr long long ptr long ptr) +@ stdcall MesDecodeBufferHandleCreate(ptr long ptr) +@ stdcall MesDecodeIncrementalHandleCreate(ptr ptr ptr) +@ stdcall MesEncodeDynBufferHandleCreate(ptr ptr ptr) +@ stdcall MesEncodeFixedBufferHandleCreate(ptr long ptr ptr) +@ stdcall MesEncodeIncrementalHandleCreate(ptr ptr ptr ptr) +@ stdcall MesHandleFree(ptr) +@ stdcall MesIncrementalHandleReset(ptr ptr ptr ptr ptr long) +@ stub MesInqProcEncodingId +@ stdcall NDRCContextBinding(ptr) +@ stdcall NDRCContextMarshall(ptr ptr) +@ stdcall NDRCContextUnmarshall(ptr ptr ptr long) +@ stdcall NDRSContextMarshall2(ptr ptr ptr ptr ptr long) +@ stdcall NDRSContextMarshall(ptr ptr ptr) +@ stdcall NDRSContextMarshallEx(ptr ptr ptr ptr) +@ stdcall NDRSContextUnmarshall2(ptr ptr long ptr long) +@ stdcall NDRSContextUnmarshall(ptr long) +@ stdcall NDRSContextUnmarshallEx(ptr ptr long) +@ stub NDRcopy +@ varargs -arch=win64 Ndr64AsyncClientCall(ptr long ptr) +@ stdcall NdrAllocate(ptr long) +@ varargs NdrAsyncClientCall(ptr ptr) +@ stdcall NdrAsyncServerCall(ptr) +@ stdcall NdrByteCountPointerBufferSize(ptr ptr ptr) +@ stdcall NdrByteCountPointerFree(ptr ptr ptr) +@ stdcall NdrByteCountPointerMarshall(ptr ptr ptr) +@ stdcall NdrByteCountPointerUnmarshall(ptr ptr ptr long) +@ stdcall NdrCStdStubBuffer2_Release(ptr ptr) +@ stdcall NdrCStdStubBuffer_Release(ptr ptr) +@ stdcall NdrClearOutParameters(ptr ptr ptr) +@ varargs -arch=i386 NdrClientCall(ptr ptr) NdrClientCall2 +@ varargs NdrClientCall2(ptr ptr) +@ varargs -arch=win64 NdrClientCall3(ptr long ptr) +@ stdcall NdrClientContextMarshall(ptr ptr long) +@ stdcall NdrClientContextUnmarshall(ptr ptr ptr) +@ stub NdrClientInitialize +@ stdcall NdrClientInitializeNew(ptr ptr ptr long) +@ stdcall NdrComplexArrayBufferSize(ptr ptr ptr) +@ stdcall NdrComplexArrayFree(ptr ptr ptr) +@ stdcall NdrComplexArrayMarshall(ptr ptr ptr) +@ stdcall NdrComplexArrayMemorySize(ptr ptr) +@ stdcall NdrComplexArrayUnmarshall(ptr ptr ptr long) +@ stdcall NdrComplexStructBufferSize(ptr ptr ptr) +@ stdcall NdrComplexStructFree(ptr ptr ptr) +@ stdcall NdrComplexStructMarshall(ptr ptr ptr) +@ stdcall NdrComplexStructMemorySize(ptr ptr) +@ stdcall NdrComplexStructUnmarshall(ptr ptr ptr long) +@ stdcall NdrConformantArrayBufferSize(ptr ptr ptr) +@ stdcall NdrConformantArrayFree(ptr ptr ptr) +@ stdcall NdrConformantArrayMarshall(ptr ptr ptr) +@ stdcall NdrConformantArrayMemorySize(ptr ptr) +@ stdcall NdrConformantArrayUnmarshall(ptr ptr ptr long) +@ stdcall NdrConformantStringBufferSize(ptr ptr ptr) +@ stdcall NdrConformantStringMarshall(ptr ptr ptr) +@ stdcall NdrConformantStringMemorySize(ptr ptr) +@ stdcall NdrConformantStringUnmarshall(ptr ptr ptr long) +@ stdcall NdrConformantStructBufferSize(ptr ptr ptr) +@ stdcall NdrConformantStructFree(ptr ptr ptr) +@ stdcall NdrConformantStructMarshall(ptr ptr ptr) +@ stdcall NdrConformantStructMemorySize(ptr ptr) +@ stdcall NdrConformantStructUnmarshall(ptr ptr ptr long) +@ stdcall NdrConformantVaryingArrayBufferSize(ptr ptr ptr) +@ stdcall NdrConformantVaryingArrayFree(ptr ptr ptr) +@ stdcall NdrConformantVaryingArrayMarshall(ptr ptr ptr) +@ stdcall NdrConformantVaryingArrayMemorySize(ptr ptr) +@ stdcall NdrConformantVaryingArrayUnmarshall(ptr ptr ptr long) +@ stdcall NdrConformantVaryingStructBufferSize(ptr ptr ptr) +@ stdcall NdrConformantVaryingStructFree(ptr ptr ptr) +@ stdcall NdrConformantVaryingStructMarshall(ptr ptr ptr) +@ stdcall NdrConformantVaryingStructMemorySize(ptr ptr) +@ stdcall NdrConformantVaryingStructUnmarshall(ptr ptr ptr long) +@ stdcall NdrContextHandleInitialize(ptr ptr) +@ stdcall NdrContextHandleSize(ptr ptr ptr) +@ stdcall NdrConvert2(ptr ptr long) +@ stdcall NdrConvert(ptr ptr) +@ stdcall NdrCorrelationFree(ptr) +@ stdcall NdrCorrelationInitialize(ptr ptr long long) +@ stdcall NdrCorrelationPass(ptr) +@ stub NdrCreateServerInterfaceFromStub +@ stub NdrDcomAsyncClientCall +@ stub NdrDcomAsyncStubCall +@ stdcall NdrDllCanUnloadNow(ptr) +@ stdcall NdrDllGetClassObject(ptr ptr ptr ptr ptr ptr) +@ stdcall NdrDllRegisterProxy(long ptr ptr) +@ stdcall NdrDllUnregisterProxy(long ptr ptr) +@ stdcall NdrEncapsulatedUnionBufferSize(ptr ptr ptr) +@ stdcall NdrEncapsulatedUnionFree(ptr ptr ptr) +@ stdcall NdrEncapsulatedUnionMarshall(ptr ptr ptr) +@ stdcall NdrEncapsulatedUnionMemorySize(ptr ptr) +@ stdcall NdrEncapsulatedUnionUnmarshall(ptr ptr ptr long) +@ stdcall NdrFixedArrayBufferSize(ptr ptr ptr) +@ stdcall NdrFixedArrayFree(ptr ptr ptr) +@ stdcall NdrFixedArrayMarshall(ptr ptr ptr) +@ stdcall NdrFixedArrayMemorySize(ptr ptr) +@ stdcall NdrFixedArrayUnmarshall(ptr ptr ptr long) +@ stdcall NdrFreeBuffer(ptr) +@ stdcall NdrFullPointerFree(ptr ptr) +@ stdcall NdrFullPointerInsertRefId(ptr long ptr) +@ stdcall NdrFullPointerQueryPointer(ptr ptr long ptr) +@ stdcall NdrFullPointerQueryRefId(ptr long long ptr) +@ stdcall NdrFullPointerXlatFree(ptr) +@ stdcall NdrFullPointerXlatInit(long long) +@ stdcall NdrGetBuffer(ptr long ptr) +@ stub NdrGetDcomProtocolVersion +@ stub NdrGetSimpleTypeBufferAlignment +@ stub NdrGetSimpleTypeBufferSize +@ stub NdrGetSimpleTypeMemorySize +@ stub NdrGetTypeFlags +@ stdcall NdrGetUserMarshalInfo(ptr long ptr) +@ stdcall NdrInterfacePointerBufferSize(ptr ptr ptr) +@ stdcall NdrInterfacePointerFree(ptr ptr ptr) +@ stdcall NdrInterfacePointerMarshall(ptr ptr ptr) +@ stdcall NdrInterfacePointerMemorySize(ptr ptr) +@ stdcall NdrInterfacePointerUnmarshall(ptr ptr ptr long) +@ stdcall NdrMapCommAndFaultStatus(ptr ptr ptr long) +@ varargs NdrMesProcEncodeDecode(ptr ptr ptr) +@ stub NdrMesProcEncodeDecode2 +@ stub NdrMesSimpleTypeAlignSize +@ stub NdrMesSimpleTypeDecode +@ stub NdrMesSimpleTypeEncode +@ stub NdrMesTypeAlignSize2 +@ stub NdrMesTypeAlignSize +@ stdcall NdrMesTypeDecode2(ptr ptr ptr ptr ptr) +@ stub NdrMesTypeDecode +@ stdcall NdrMesTypeEncode2(ptr ptr ptr ptr ptr) +@ stub NdrMesTypeEncode +@ stdcall NdrMesTypeFree2(ptr ptr ptr ptr ptr) +@ stdcall NdrNonConformantStringBufferSize(ptr ptr ptr) +@ stdcall NdrNonConformantStringMarshall(ptr ptr ptr) +@ stdcall NdrNonConformantStringMemorySize(ptr ptr) +@ stdcall NdrNonConformantStringUnmarshall(ptr ptr ptr long) +@ stdcall NdrNonEncapsulatedUnionBufferSize(ptr ptr ptr) +@ stdcall NdrNonEncapsulatedUnionFree(ptr ptr ptr) +@ stdcall NdrNonEncapsulatedUnionMarshall(ptr ptr ptr) +@ stdcall NdrNonEncapsulatedUnionMemorySize(ptr ptr) +@ stdcall NdrNonEncapsulatedUnionUnmarshall(ptr ptr ptr long) +@ stub NdrNsGetBuffer +@ stub NdrNsSendReceive +@ stdcall NdrOleAllocate(long) +@ stdcall NdrOleFree(ptr) +@ stub NdrOutInit +@ stub NdrPartialIgnoreClientBufferSize +@ stub NdrPartialIgnoreClientMarshall +@ stub NdrPartialIgnoreServerInitialize +@ stub NdrPartialIgnoreServerUnmarshall +@ stdcall NdrPointerBufferSize(ptr ptr ptr) +@ stdcall NdrPointerFree(ptr ptr ptr) +@ stdcall NdrPointerMarshall(ptr ptr ptr) +@ stdcall NdrPointerMemorySize(ptr ptr) +@ stdcall NdrPointerUnmarshall(ptr ptr ptr long) +@ stdcall NdrProxyErrorHandler(long) +@ stdcall NdrProxyFreeBuffer(ptr ptr) +@ stdcall NdrProxyGetBuffer(ptr ptr) +@ stdcall NdrProxyInitialize(ptr ptr ptr ptr long) +@ stdcall NdrProxySendReceive(ptr ptr) +@ stdcall NdrRangeUnmarshall(ptr ptr ptr long) +@ stub NdrRpcSmClientAllocate +@ stub NdrRpcSmClientFree +@ stdcall NdrRpcSmSetClientToOsf(ptr) +@ stub NdrRpcSsDefaultAllocate +@ stub NdrRpcSsDefaultFree +@ stub NdrRpcSsDisableAllocate +@ stub NdrRpcSsEnableAllocate +@ stdcall NdrSendReceive(ptr ptr) +@ stdcall NdrServerCall2(ptr) +@ stdcall NdrServerCall(ptr) @ stdcall -arch=x86_64 NdrServerCallAll(ptr) -270 stdcall NdrServerContextMarshall(ptr ptr ptr) -271 stdcall NdrServerContextNewMarshall(ptr ptr ptr ptr) -272 stdcall NdrServerContextNewUnmarshall(ptr ptr) -273 stdcall NdrServerContextUnmarshall(ptr) -274 stub NdrServerInitialize -275 stub NdrServerInitializeMarshall -276 stdcall NdrServerInitializeNew(ptr ptr ptr) -277 stub NdrServerInitializePartial -278 stub NdrServerInitializeUnmarshall -279 stub NdrServerMarshall -280 stub NdrServerUnmarshall -281 stdcall NdrSimpleStructBufferSize(ptr ptr ptr) -282 stdcall NdrSimpleStructFree(ptr ptr ptr) -283 stdcall NdrSimpleStructMarshall(ptr ptr ptr) -284 stdcall NdrSimpleStructMemorySize(ptr ptr) -285 stdcall NdrSimpleStructUnmarshall(ptr ptr ptr long) -286 stdcall NdrSimpleTypeMarshall(ptr ptr long) -287 stdcall NdrSimpleTypeUnmarshall(ptr ptr long) -288 stdcall NdrStubCall2(ptr ptr ptr ptr) -289 stdcall NdrStubCall(ptr ptr ptr ptr) -290 stdcall NdrStubForwardingFunction(ptr ptr ptr ptr) -291 stdcall NdrStubGetBuffer(ptr ptr ptr) -292 stdcall NdrStubInitialize(ptr ptr ptr ptr) -293 stub NdrStubInitializeMarshall -294 stub NdrTypeFlags -295 stub NdrTypeFree -296 stub NdrTypeMarshall -297 stub NdrTypeSize -298 stub NdrTypeUnmarshall -299 stub NdrUnmarshallBasetypeInline -300 stdcall NdrUserMarshalBufferSize(ptr ptr ptr) -301 stdcall NdrUserMarshalFree(ptr ptr ptr) -302 stdcall NdrUserMarshalMarshall(ptr ptr ptr) -303 stdcall NdrUserMarshalMemorySize(ptr ptr) -304 stub NdrUserMarshalSimpleTypeConvert -305 stdcall NdrUserMarshalUnmarshall(ptr ptr ptr long) -306 stdcall NdrVaryingArrayBufferSize(ptr ptr ptr) -307 stdcall NdrVaryingArrayFree(ptr ptr ptr) -308 stdcall NdrVaryingArrayMarshall(ptr ptr ptr) -309 stdcall NdrVaryingArrayMemorySize(ptr ptr) -310 stdcall NdrVaryingArrayUnmarshall(ptr ptr ptr long) -311 stdcall NdrXmitOrRepAsBufferSize(ptr ptr ptr) -312 stdcall NdrXmitOrRepAsFree(ptr ptr ptr) -313 stdcall NdrXmitOrRepAsMarshall(ptr ptr ptr) -314 stdcall NdrXmitOrRepAsMemorySize(ptr ptr) -315 stdcall NdrXmitOrRepAsUnmarshall(ptr ptr ptr long) -316 stub NdrpCreateProxy -317 stub NdrpCreateStub -318 stub NdrpGetProcFormatString -319 stub NdrpGetTypeFormatString -320 stub NdrpGetTypeGenCookie -321 stub NdrpMemoryIncrement -322 stub NdrpReleaseTypeFormatString -323 stub NdrpReleaseTypeGenCookie -324 stub NdrpSetRpcSsDefaults -325 stub NdrpVarVtOfTypeDesc -326 stdcall RpcAbortAsyncCall(ptr long) RpcAsyncAbortCall -327 stdcall RpcAsyncAbortCall(ptr long) -328 stdcall RpcAsyncCancelCall(ptr long) -329 stdcall RpcAsyncCompleteCall(ptr ptr) -330 stdcall RpcAsyncGetCallStatus(ptr) -331 stdcall RpcAsyncInitializeHandle(ptr long) -332 stub RpcAsyncRegisterInfo -333 stdcall RpcBindingCopy(ptr ptr) -334 stdcall RpcBindingFree(ptr) -335 stdcall RpcBindingFromStringBindingA(str ptr) -336 stdcall RpcBindingFromStringBindingW(wstr ptr) -337 stdcall RpcBindingInqAuthClientA(ptr ptr ptr ptr ptr ptr) -338 stdcall RpcBindingInqAuthClientExA(ptr ptr ptr ptr ptr ptr long) -339 stdcall RpcBindingInqAuthClientExW(ptr ptr ptr ptr ptr ptr long) -340 stdcall RpcBindingInqAuthClientW(ptr ptr ptr ptr ptr ptr) -341 stdcall RpcBindingInqAuthInfoA(ptr ptr ptr ptr ptr ptr) -342 stdcall RpcBindingInqAuthInfoExA(ptr ptr ptr ptr ptr ptr long ptr) -343 stdcall RpcBindingInqAuthInfoExW(ptr ptr ptr ptr ptr ptr long ptr) -344 stdcall RpcBindingInqAuthInfoW(ptr ptr ptr ptr ptr ptr) -345 stdcall RpcBindingInqObject(ptr ptr) -346 stub RpcBindingInqOption -347 stdcall RpcBindingReset(ptr) -348 stdcall RpcBindingServerFromClient(ptr ptr) -349 stdcall RpcBindingSetAuthInfoA(ptr str long long ptr long) -350 stdcall RpcBindingSetAuthInfoExA(ptr str long long ptr long ptr) -351 stdcall RpcBindingSetAuthInfoExW(ptr wstr long long ptr long ptr) -352 stdcall RpcBindingSetAuthInfoW(ptr wstr long long ptr long) -353 stdcall RpcBindingSetObject(ptr ptr) -354 stdcall RpcBindingSetOption(ptr long long) -355 stdcall RpcBindingToStringBindingA(ptr ptr) -356 stdcall RpcBindingToStringBindingW(ptr ptr) -357 stdcall RpcBindingVectorFree(ptr) -358 stdcall RpcCancelAsyncCall(ptr long) RpcAsyncCancelCall -359 stdcall RpcCancelThread(ptr) -360 stdcall RpcCancelThreadEx(ptr long) -361 stub RpcCertGeneratePrincipalNameA -362 stub RpcCertGeneratePrincipalNameW -363 stdcall RpcCompleteAsyncCall(ptr ptr) RpcAsyncCompleteCall -364 stdcall RpcEpRegisterA(ptr ptr ptr str) -365 stdcall RpcEpRegisterNoReplaceA(ptr ptr ptr str) -366 stdcall RpcEpRegisterNoReplaceW(ptr ptr ptr wstr) -367 stdcall RpcEpRegisterW(ptr ptr ptr wstr) -368 stdcall RpcEpResolveBinding(ptr ptr) -369 stdcall RpcEpUnregister(ptr ptr ptr) -370 stub RpcErrorAddRecord -371 stub RpcErrorClearInformation -372 stdcall RpcErrorEndEnumeration(ptr) -373 stdcall RpcErrorGetNextRecord(ptr long ptr) -# RpcErrorGetNumberOfRecords -375 stdcall RpcErrorLoadErrorInfo(ptr long ptr) -376 stub RpcErrorResetEnumeration -377 stdcall RpcErrorSaveErrorInfo(ptr ptr ptr) -378 stdcall RpcErrorStartEnumeration(ptr) -379 stub RpcFreeAuthorizationContext -380 stdcall RpcGetAsyncCallStatus(ptr) RpcAsyncGetCallStatus -381 stdcall RpcGetAuthorizationContextForClient(ptr long ptr ptr int64 long ptr ptr) -382 stub RpcIfIdVectorFree -383 stub RpcIfInqId -384 stdcall RpcImpersonateClient(ptr) -385 stdcall RpcInitializeAsyncHandle(ptr long) RpcAsyncInitializeHandle -386 stdcall RpcMgmtEnableIdleCleanup() -387 stdcall RpcMgmtEpEltInqBegin(ptr long ptr long ptr ptr) -388 stub RpcMgmtEpEltInqDone -389 stub RpcMgmtEpEltInqNextA -390 stub RpcMgmtEpEltInqNextW -391 stub RpcMgmtEpUnregister -392 stub RpcMgmtInqComTimeout -393 stub RpcMgmtInqDefaultProtectLevel -394 stdcall RpcMgmtInqIfIds(ptr ptr) -395 stdcall -stub RpcMgmtInqServerPrincNameA(ptr long ptr) -396 stdcall -stub RpcMgmtInqServerPrincNameW(ptr long ptr) -397 stdcall RpcMgmtInqStats(ptr ptr) -398 stdcall RpcMgmtIsServerListening(ptr) -399 stdcall RpcMgmtSetAuthorizationFn(ptr) -400 stdcall RpcMgmtSetCancelTimeout(long) -401 stdcall RpcMgmtSetComTimeout(ptr long) -402 stdcall RpcMgmtSetServerStackSize(long) -403 stdcall RpcMgmtStatsVectorFree(ptr) -404 stdcall RpcMgmtStopServerListening(ptr) -405 stdcall RpcMgmtWaitServerListen() -406 stdcall RpcNetworkInqProtseqsA(ptr) -407 stdcall RpcNetworkInqProtseqsW(ptr) -408 stdcall RpcNetworkIsProtseqValidA(str) -409 stdcall RpcNetworkIsProtseqValidW(wstr) -410 stub RpcNsBindingInqEntryNameA -411 stub RpcNsBindingInqEntryNameW -412 stub RpcObjectInqType -413 stub RpcObjectSetInqFn -414 stdcall RpcObjectSetType(ptr ptr) -415 stdcall RpcProtseqVectorFreeA(ptr) -416 stdcall RpcProtseqVectorFreeW(ptr) -417 stdcall RpcRaiseException(long) -418 stub RpcRegisterAsyncInfo -419 stdcall RpcRevertToSelf() -420 stdcall RpcRevertToSelfEx(ptr) -421 stdcall RpcServerInqBindings(ptr) -422 stub RpcServerInqCallAttributesA -423 stub RpcServerInqCallAttributesW -424 stdcall RpcServerInqDefaultPrincNameA(long ptr) -425 stdcall RpcServerInqDefaultPrincNameW(long ptr) -426 stub RpcServerInqIf -427 stdcall RpcServerListen(long long long) -428 stdcall RpcServerRegisterAuthInfoA(str long ptr ptr) -429 stdcall RpcServerRegisterAuthInfoW(wstr long ptr ptr) -430 stdcall RpcServerRegisterIf2(ptr ptr ptr long long long ptr) -431 stdcall RpcServerRegisterIf(ptr ptr ptr) -432 stdcall RpcServerRegisterIfEx(ptr ptr ptr long long ptr) -433 stub RpcServerTestCancel -434 stdcall RpcServerUnregisterIf(ptr ptr long) -435 stdcall RpcServerUnregisterIfEx(ptr ptr long) -436 stub RpcServerUseAllProtseqs -437 stub RpcServerUseAllProtseqsEx -438 stub RpcServerUseAllProtseqsIf -439 stub RpcServerUseAllProtseqsIfEx -440 stdcall RpcServerUseProtseqA(str long ptr) -441 stdcall RpcServerUseProtseqEpA(str long str ptr) -442 stdcall RpcServerUseProtseqEpExA(str long str ptr ptr) -443 stdcall RpcServerUseProtseqEpExW(wstr long wstr ptr ptr) -444 stdcall RpcServerUseProtseqEpW(wstr long wstr ptr) -445 stub RpcServerUseProtseqExA -446 stub RpcServerUseProtseqExW -447 stub RpcServerUseProtseqIfA -448 stub RpcServerUseProtseqIfExA -449 stub RpcServerUseProtseqIfExW -450 stub RpcServerUseProtseqIfW -451 stdcall RpcServerUseProtseqW(wstr long ptr) -452 stub RpcServerYield -453 stub RpcSmAllocate -454 stub RpcSmClientFree -455 stdcall RpcSmDestroyClientContext(ptr) -456 stub RpcSmDisableAllocate -457 stub RpcSmEnableAllocate -458 stub RpcSmFree -459 stub RpcSmGetThreadHandle -460 stub RpcSmSetClientAllocFree -461 stub RpcSmSetThreadHandle -462 stub RpcSmSwapClientAllocFree -463 stub RpcSsAllocate -464 stub RpcSsContextLockExclusive -465 stub RpcSsContextLockShared -466 stdcall RpcSsDestroyClientContext(ptr) -467 stub RpcSsDisableAllocate -468 stdcall RpcSsDontSerializeContext() -469 stub RpcSsEnableAllocate -470 stub RpcSsFree -471 stub RpcSsGetContextBinding -472 stub RpcSsGetThreadHandle -473 stub RpcSsSetClientAllocFree -474 stub RpcSsSetThreadHandle -475 stub RpcSsSwapClientAllocFree -476 stdcall RpcStringBindingComposeA(str str str str str ptr) -477 stdcall RpcStringBindingComposeW(wstr wstr wstr wstr wstr ptr) -478 stdcall RpcStringBindingParseA(str ptr ptr ptr ptr ptr) -479 stdcall RpcStringBindingParseW(wstr ptr ptr ptr ptr ptr) -480 stdcall RpcStringFreeA(ptr) -481 stdcall RpcStringFreeW(ptr) -482 stub RpcTestCancel -483 stub RpcUserFree -484 stub SimpleTypeAlignment -485 stub SimpleTypeBufferSize -486 stub SimpleTypeMemorySize -487 stdcall TowerConstruct(ptr ptr ptr ptr ptr ptr) -488 stdcall TowerExplode(ptr ptr ptr ptr ptr ptr) -489 stdcall UuidCompare(ptr ptr ptr) -490 stdcall UuidCreate(ptr) -491 stdcall UuidCreateNil(ptr) -492 stdcall UuidCreateSequential(ptr) -493 stdcall UuidEqual(ptr ptr ptr) -494 stdcall UuidFromStringA(str ptr) -495 stdcall UuidFromStringW(wstr ptr) -496 stdcall UuidHash(ptr ptr) -497 stdcall UuidIsNil(ptr ptr) -498 stdcall UuidToStringA(ptr ptr) -499 stdcall UuidToStringW(ptr ptr) -500 stub char_array_from_ndr -501 stub char_from_ndr -502 stub data_from_ndr -503 stub data_into_ndr -504 stub data_size_ndr -505 stub double_array_from_ndr -506 stub double_from_ndr -507 stub enum_from_ndr -508 stub float_array_from_ndr -509 stub float_from_ndr -510 stub long_array_from_ndr -511 stub long_from_ndr -512 stub long_from_ndr_temp -513 stub pfnFreeRoutines -514 stub pfnMarshallRoutines -515 stub pfnSizeRoutines -516 stub pfnUnmarshallRoutines -517 stub short_array_from_ndr -518 stub short_from_ndr -519 stub short_from_ndr_temp -520 stub tree_into_ndr -521 stub tree_peek_ndr -522 stub tree_size_ndr +@ stdcall NdrServerContextMarshall(ptr ptr ptr) +@ stdcall NdrServerContextNewMarshall(ptr ptr ptr ptr) +@ stdcall NdrServerContextNewUnmarshall(ptr ptr) +@ stdcall NdrServerContextUnmarshall(ptr) +@ stub NdrServerInitialize +@ stub NdrServerInitializeMarshall +@ stdcall NdrServerInitializeNew(ptr ptr ptr) +@ stub NdrServerInitializePartial +@ stub NdrServerInitializeUnmarshall +@ stub NdrServerMarshall +@ stub NdrServerUnmarshall +@ stdcall NdrSimpleStructBufferSize(ptr ptr ptr) +@ stdcall NdrSimpleStructFree(ptr ptr ptr) +@ stdcall NdrSimpleStructMarshall(ptr ptr ptr) +@ stdcall NdrSimpleStructMemorySize(ptr ptr) +@ stdcall NdrSimpleStructUnmarshall(ptr ptr ptr long) +@ stdcall NdrSimpleTypeMarshall(ptr ptr long) +@ stdcall NdrSimpleTypeUnmarshall(ptr ptr long) +@ stdcall NdrStubCall2(ptr ptr ptr ptr) +@ stdcall NdrStubCall(ptr ptr ptr ptr) +@ stdcall NdrStubForwardingFunction(ptr ptr ptr ptr) +@ stdcall NdrStubGetBuffer(ptr ptr ptr) +@ stdcall NdrStubInitialize(ptr ptr ptr ptr) +@ stub NdrStubInitializeMarshall +@ stub NdrTypeFlags +@ stub NdrTypeFree +@ stub NdrTypeMarshall +@ stub NdrTypeSize +@ stub NdrTypeUnmarshall +@ stub NdrUnmarshallBasetypeInline +@ stdcall NdrUserMarshalBufferSize(ptr ptr ptr) +@ stdcall NdrUserMarshalFree(ptr ptr ptr) +@ stdcall NdrUserMarshalMarshall(ptr ptr ptr) +@ stdcall NdrUserMarshalMemorySize(ptr ptr) +@ stub NdrUserMarshalSimpleTypeConvert +@ stdcall NdrUserMarshalUnmarshall(ptr ptr ptr long) +@ stdcall NdrVaryingArrayBufferSize(ptr ptr ptr) +@ stdcall NdrVaryingArrayFree(ptr ptr ptr) +@ stdcall NdrVaryingArrayMarshall(ptr ptr ptr) +@ stdcall NdrVaryingArrayMemorySize(ptr ptr) +@ stdcall NdrVaryingArrayUnmarshall(ptr ptr ptr long) +@ stdcall NdrXmitOrRepAsBufferSize(ptr ptr ptr) +@ stdcall NdrXmitOrRepAsFree(ptr ptr ptr) +@ stdcall NdrXmitOrRepAsMarshall(ptr ptr ptr) +@ stdcall NdrXmitOrRepAsMemorySize(ptr ptr) +@ stdcall NdrXmitOrRepAsUnmarshall(ptr ptr ptr long) +@ stdcall -arch=!i386 NdrpClientCall2(ptr ptr ptr long) +@ stub NdrpCreateProxy +@ stub NdrpCreateStub +@ stub NdrpGetProcFormatString +@ stub NdrpGetTypeFormatString +@ stub NdrpGetTypeGenCookie +@ stub NdrpMemoryIncrement +@ stub NdrpReleaseTypeFormatString +@ stub NdrpReleaseTypeGenCookie +@ stub NdrpSetRpcSsDefaults +@ stub NdrpVarVtOfTypeDesc +@ stdcall RpcAbortAsyncCall(ptr long) RpcAsyncAbortCall +@ stdcall RpcAsyncAbortCall(ptr long) +@ stdcall RpcAsyncCancelCall(ptr long) +@ stdcall RpcAsyncCompleteCall(ptr ptr) +@ stdcall RpcAsyncGetCallStatus(ptr) +@ stdcall RpcAsyncInitializeHandle(ptr long) +@ stub RpcAsyncRegisterInfo +@ stdcall RpcBindingCopy(ptr ptr) +@ stdcall RpcBindingFree(ptr) +@ stdcall RpcBindingFromStringBindingA(str ptr) +@ stdcall RpcBindingFromStringBindingW(wstr ptr) +@ stdcall RpcBindingInqAuthClientA(ptr ptr ptr ptr ptr ptr) +@ stdcall RpcBindingInqAuthClientExA(ptr ptr ptr ptr ptr ptr long) +@ stdcall RpcBindingInqAuthClientExW(ptr ptr ptr ptr ptr ptr long) +@ stdcall RpcBindingInqAuthClientW(ptr ptr ptr ptr ptr ptr) +@ stdcall RpcBindingInqAuthInfoA(ptr ptr ptr ptr ptr ptr) +@ stdcall RpcBindingInqAuthInfoExA(ptr ptr ptr ptr ptr ptr long ptr) +@ stdcall RpcBindingInqAuthInfoExW(ptr ptr ptr ptr ptr ptr long ptr) +@ stdcall RpcBindingInqAuthInfoW(ptr ptr ptr ptr ptr ptr) +@ stdcall RpcBindingInqObject(ptr ptr) +@ stub RpcBindingInqOption +@ stdcall RpcBindingReset(ptr) +@ stdcall RpcBindingServerFromClient(ptr ptr) +@ stdcall RpcBindingSetAuthInfoA(ptr str long long ptr long) +@ stdcall RpcBindingSetAuthInfoExA(ptr str long long ptr long ptr) +@ stdcall RpcBindingSetAuthInfoExW(ptr wstr long long ptr long ptr) +@ stdcall RpcBindingSetAuthInfoW(ptr wstr long long ptr long) +@ stdcall RpcBindingSetObject(ptr ptr) +@ stdcall RpcBindingSetOption(ptr long long) +@ stdcall RpcBindingToStringBindingA(ptr ptr) +@ stdcall RpcBindingToStringBindingW(ptr ptr) +@ stdcall RpcBindingVectorFree(ptr) +@ stdcall RpcCancelAsyncCall(ptr long) RpcAsyncCancelCall +@ stdcall RpcCancelThread(ptr) +@ stdcall RpcCancelThreadEx(ptr long) +@ stub RpcCertGeneratePrincipalNameA +@ stub RpcCertGeneratePrincipalNameW +@ stdcall RpcCompleteAsyncCall(ptr ptr) RpcAsyncCompleteCall +@ stdcall RpcEpRegisterA(ptr ptr ptr str) +@ stdcall RpcEpRegisterNoReplaceA(ptr ptr ptr str) +@ stdcall RpcEpRegisterNoReplaceW(ptr ptr ptr wstr) +@ stdcall RpcEpRegisterW(ptr ptr ptr wstr) +@ stdcall RpcEpResolveBinding(ptr ptr) +@ stdcall RpcEpUnregister(ptr ptr ptr) +@ stub RpcErrorAddRecord +@ stub RpcErrorClearInformation +@ stdcall RpcErrorEndEnumeration(ptr) +@ stdcall RpcErrorGetNextRecord(ptr long ptr) +@ stub RpcErrorGetNumberOfRecords +@ stdcall RpcErrorLoadErrorInfo(ptr long ptr) +@ stub RpcErrorResetEnumeration +@ stdcall RpcErrorSaveErrorInfo(ptr ptr ptr) +@ stdcall RpcErrorStartEnumeration(ptr) +@ stdcall -version=0x600+ RpcExceptionFilter(long) +@ stub RpcFreeAuthorizationContext +@ stdcall RpcGetAsyncCallStatus(ptr) RpcAsyncGetCallStatus +@ stdcall RpcGetAuthorizationContextForClient(ptr long ptr ptr int64 long ptr ptr) +@ stub RpcIfIdVectorFree +@ stdcall RpcIfInqId(ptr ptr) +@ stdcall RpcImpersonateClient(ptr) +@ stdcall RpcInitializeAsyncHandle(ptr long) RpcAsyncInitializeHandle +@ stdcall RpcMgmtEnableIdleCleanup() +@ stdcall RpcMgmtEpEltInqBegin(ptr long ptr long ptr ptr) +@ stub RpcMgmtEpEltInqDone +@ stub RpcMgmtEpEltInqNextA +@ stub RpcMgmtEpEltInqNextW +@ stub RpcMgmtEpUnregister +@ stub RpcMgmtInqComTimeout +@ stub RpcMgmtInqDefaultProtectLevel +@ stdcall RpcMgmtInqIfIds(ptr ptr) +@ stdcall -stub RpcMgmtInqServerPrincNameA(ptr long ptr) +@ stdcall -stub RpcMgmtInqServerPrincNameW(ptr long ptr) +@ stdcall RpcMgmtInqStats(ptr ptr) +@ stdcall RpcMgmtIsServerListening(ptr) +@ stdcall RpcMgmtSetAuthorizationFn(ptr) +@ stdcall RpcMgmtSetCancelTimeout(long) +@ stdcall RpcMgmtSetComTimeout(ptr long) +@ stdcall RpcMgmtSetServerStackSize(long) +@ stdcall RpcMgmtStatsVectorFree(ptr) +@ stdcall RpcMgmtStopServerListening(ptr) +@ stdcall RpcMgmtWaitServerListen() +@ stdcall RpcNetworkInqProtseqsA(ptr) +@ stdcall RpcNetworkInqProtseqsW(ptr) +@ stdcall RpcNetworkIsProtseqValidA(str) +@ stdcall RpcNetworkIsProtseqValidW(wstr) +@ stub RpcNsBindingInqEntryNameA +@ stub RpcNsBindingInqEntryNameW +@ stub RpcObjectInqType +@ stub RpcObjectSetInqFn +@ stdcall RpcObjectSetType(ptr ptr) +@ stdcall RpcProtseqVectorFreeA(ptr) +@ stdcall RpcProtseqVectorFreeW(ptr) +@ stdcall RpcRaiseException(long) +@ stub RpcRegisterAsyncInfo +@ stdcall RpcRevertToSelf() +@ stdcall RpcRevertToSelfEx(ptr) +@ stdcall RpcServerInqBindings(ptr) +@ stub RpcServerInqCallAttributesA +@ stub RpcServerInqCallAttributesW +@ stdcall RpcServerInqDefaultPrincNameA(long ptr) +@ stdcall RpcServerInqDefaultPrincNameW(long ptr) +@ stub RpcServerInqIf +@ stdcall RpcServerListen(long long long) +@ stdcall RpcServerRegisterAuthInfoA(str long ptr ptr) +@ stdcall RpcServerRegisterAuthInfoW(wstr long ptr ptr) +@ stdcall RpcServerRegisterIf2(ptr ptr ptr long long long ptr) +@ stdcall RpcServerRegisterIf(ptr ptr ptr) +@ stdcall RpcServerRegisterIfEx(ptr ptr ptr long long ptr) +@ stub RpcServerTestCancel +@ stdcall RpcServerUnregisterIf(ptr ptr long) +@ stdcall RpcServerUnregisterIfEx(ptr ptr long) +@ stub RpcServerUseAllProtseqs +@ stub RpcServerUseAllProtseqsEx +@ stub RpcServerUseAllProtseqsIf +@ stub RpcServerUseAllProtseqsIfEx +@ stdcall RpcServerUseProtseqA(str long ptr) +@ stdcall RpcServerUseProtseqEpA(str long str ptr) +@ stdcall RpcServerUseProtseqEpExA(str long str ptr ptr) +@ stdcall RpcServerUseProtseqEpExW(wstr long wstr ptr ptr) +@ stdcall RpcServerUseProtseqEpW(wstr long wstr ptr) +@ stub RpcServerUseProtseqExA +@ stub RpcServerUseProtseqExW +@ stub RpcServerUseProtseqIfA +@ stub RpcServerUseProtseqIfExA +@ stub RpcServerUseProtseqIfExW +@ stub RpcServerUseProtseqIfW +@ stdcall RpcServerUseProtseqW(wstr long ptr) +@ stub RpcServerYield +@ stub RpcSmAllocate +@ stub RpcSmClientFree +@ stdcall RpcSmDestroyClientContext(ptr) +@ stub RpcSmDisableAllocate +@ stub RpcSmEnableAllocate +@ stub RpcSmFree +@ stub RpcSmGetThreadHandle +@ stub RpcSmSetClientAllocFree +@ stub RpcSmSetThreadHandle +@ stub RpcSmSwapClientAllocFree +@ stub RpcSsAllocate +@ stub RpcSsContextLockExclusive +@ stub RpcSsContextLockShared +@ stdcall RpcSsDestroyClientContext(ptr) +@ stub RpcSsDisableAllocate +@ stdcall RpcSsDontSerializeContext() +@ stub RpcSsEnableAllocate +@ stub RpcSsFree +@ stub RpcSsGetContextBinding +@ stub RpcSsGetThreadHandle +@ stub RpcSsSetClientAllocFree +@ stub RpcSsSetThreadHandle +@ stub RpcSsSwapClientAllocFree +@ stdcall RpcStringBindingComposeA(str str str str str ptr) +@ stdcall RpcStringBindingComposeW(wstr wstr wstr wstr wstr ptr) +@ stdcall RpcStringBindingParseA(str ptr ptr ptr ptr ptr) +@ stdcall RpcStringBindingParseW(wstr ptr ptr ptr ptr ptr) +@ stdcall RpcStringFreeA(ptr) +@ stdcall RpcStringFreeW(ptr) +@ stub RpcTestCancel +@ stub RpcUserFree +@ stub SimpleTypeAlignment +@ stub SimpleTypeBufferSize +@ stub SimpleTypeMemorySize +@ stdcall TowerConstruct(ptr ptr str str str ptr) +@ stdcall TowerExplode(ptr ptr ptr ptr ptr ptr) +@ stdcall UuidCompare(ptr ptr ptr) +@ stdcall UuidCreate(ptr) +@ stdcall UuidCreateNil(ptr) +@ stdcall UuidCreateSequential(ptr) +@ stdcall UuidEqual(ptr ptr ptr) +@ stdcall UuidFromStringA(str ptr) +@ stdcall UuidFromStringW(wstr ptr) +@ stdcall UuidHash(ptr ptr) +@ stdcall UuidIsNil(ptr ptr) +@ stdcall UuidToStringA(ptr ptr) +@ stdcall UuidToStringW(ptr ptr) +@ stub char_array_from_ndr +@ stub char_from_ndr +@ stub data_from_ndr +@ stub data_into_ndr +@ stub data_size_ndr +@ stub double_array_from_ndr +@ stub double_from_ndr +@ stub enum_from_ndr +@ stub float_array_from_ndr +@ stub float_from_ndr +@ stub long_array_from_ndr +@ stub long_from_ndr +@ stub long_from_ndr_temp +@ stub pfnFreeRoutines +@ stub pfnMarshallRoutines +@ stub pfnSizeRoutines +@ stub pfnUnmarshallRoutines +@ stub short_array_from_ndr +@ stub short_from_ndr +@ stub short_from_ndr_temp +@ stub tree_into_ndr +@ stub tree_peek_ndr +@ stub tree_size_ndr diff --git a/dll/win32/rpcrt4/rpcrt4_main.c b/dll/win32/rpcrt4/rpcrt4_main.c index 7cc8d0b06b2..136ec55cb00 100644 --- a/dll/win32/rpcrt4/rpcrt4_main.c +++ b/dll/win32/rpcrt4/rpcrt4_main.c @@ -95,6 +95,12 @@ struct threaddata struct context_handle_list *context_handle_list; }; +struct interface_header +{ + unsigned int length; + RPC_SYNTAX_IDENTIFIER id; +}; + /*********************************************************************** * DllMain * @@ -130,7 +136,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ERR("tdata->connection should be NULL but is still set to %p\n", tdata->connection); if (tdata->server_binding) ERR("tdata->server_binding should be NULL but is still set to %p\n", tdata->server_binding); - HeapFree(GetProcessHeap(), 0, tdata); + free(tdata); } break; @@ -157,7 +163,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) */ RPC_STATUS WINAPI RpcStringFreeA(RPC_CSTR* String) { - HeapFree( GetProcessHeap(), 0, *String); + free(*String); if (String) *String = NULL; return RPC_S_OK; @@ -174,12 +180,31 @@ RPC_STATUS WINAPI RpcStringFreeA(RPC_CSTR* String) */ RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR* String) { - HeapFree( GetProcessHeap(), 0, *String); + free(*String); if (String) *String = NULL; return RPC_S_OK; } +/************************************************************************* + * RpcIfInqId [RPCRT4.@] + * + * Get interface UUID and version. + */ +RPC_STATUS WINAPI RpcIfInqId(RPC_IF_HANDLE if_handle, RPC_IF_ID *if_id) +{ + struct interface_header *header = (struct interface_header *)if_handle; + + TRACE("(%p,%p)\n", if_handle, if_id); + + if_id->Uuid = header->id.SyntaxGUID; + if_id->VersMajor = header->id.SyntaxVersion.MajorVersion; + if_id->VersMinor = header->id.SyntaxVersion.MinorVersion; + TRACE("UUID:%s VersMajor:%hu VersMinor:%hu.\n", debugstr_guid(&if_id->Uuid), if_id->VersMajor, + if_id->VersMinor); + return RPC_S_OK; +} + /************************************************************************* * RpcRaiseException [RPCRT4.@] * @@ -347,11 +372,11 @@ static RPC_STATUS RPC_UuidGetNodeAddress(BYTE *address) DWORD status = RPC_S_OK; ULONG buflen = sizeof(IP_ADAPTER_INFO); - PIP_ADAPTER_INFO adapter = HeapAlloc(GetProcessHeap(), 0, buflen); + PIP_ADAPTER_INFO adapter = malloc(buflen); if (GetAdaptersInfo(adapter, &buflen) == ERROR_BUFFER_OVERFLOW) { - HeapFree(GetProcessHeap(), 0, adapter); - adapter = HeapAlloc(GetProcessHeap(), 0, buflen); + free(adapter); + adapter = malloc(buflen); } if (GetAdaptersInfo(adapter, &buflen) == NO_ERROR) { @@ -367,7 +392,7 @@ static RPC_STATUS RPC_UuidGetNodeAddress(BYTE *address) status = RPC_S_UUID_LOCAL_ONLY; } - HeapFree(GetProcessHeap(), 0, adapter); + free(adapter); return status; } @@ -513,18 +538,26 @@ unsigned short WINAPI UuidHash(UUID *uuid, RPC_STATUS *Status) */ RPC_STATUS WINAPI UuidToStringA(UUID *Uuid, RPC_CSTR* StringUuid) { - *StringUuid = HeapAlloc( GetProcessHeap(), 0, sizeof(char) * 37); + *StringUuid = malloc(37); if(!(*StringUuid)) return RPC_S_OUT_OF_MEMORY; if (!Uuid) Uuid = &uuid_nil; +#ifdef __REACTOS__ sprintf( (char*)*StringUuid, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", Uuid->Data1, Uuid->Data2, Uuid->Data3, Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2], Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5], Uuid->Data4[6], Uuid->Data4[7] ); +#else + sprintf( (char*)*StringUuid, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + Uuid->Data1, Uuid->Data2, Uuid->Data3, + Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2], + Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5], + Uuid->Data4[6], Uuid->Data4[7] ); +#endif return RPC_S_OK; } @@ -543,11 +576,19 @@ RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR* StringUuid) if (!Uuid) Uuid = &uuid_nil; +#ifdef __REACTOS__ sprintf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", Uuid->Data1, Uuid->Data2, Uuid->Data3, Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2], Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5], Uuid->Data4[6], Uuid->Data4[7] ); +#else + sprintf(buf, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + Uuid->Data1, Uuid->Data2, Uuid->Data3, + Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2], + Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5], + Uuid->Data4[6], Uuid->Data4[7] ); +#endif *StringUuid = RPCRT4_strdupAtoW(buf); @@ -647,16 +688,6 @@ RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid) return RPC_S_OK; } -/*********************************************************************** - * DllRegisterServer (RPCRT4.@) - */ - -HRESULT WINAPI DllRegisterServer( void ) -{ - FIXME( "(): stub\n" ); - return S_OK; -} - #define MAX_RPC_ERROR_TEXT 256 /****************************************************************************** @@ -715,7 +746,7 @@ RPC_STATUS RPC_ENTRY DceErrorInqTextA (RPC_STATUS e, RPC_CSTR buffer) */ void * WINAPI I_RpcAllocate(unsigned int Size) { - return HeapAlloc(GetProcessHeap(), 0, Size); + return malloc(Size); } /****************************************************************************** @@ -723,7 +754,7 @@ void * WINAPI I_RpcAllocate(unsigned int Size) */ void WINAPI I_RpcFree(void *Object) { - HeapFree(GetProcessHeap(), 0, Object); + free(Object); } /****************************************************************************** @@ -739,7 +770,7 @@ void WINAPI I_RpcFree(void *Object) */ LONG WINAPI I_RpcMapWin32Status(RPC_STATUS status) { - TRACE("(%d)\n", status); + TRACE("(%ld)\n", status); switch (status) { case ERROR_ACCESS_DENIED: return STATUS_ACCESS_DENIED; @@ -858,7 +889,7 @@ LONG WINAPI I_RpcMapWin32Status(RPC_STATUS status) */ int WINAPI RpcExceptionFilter(ULONG ExceptionCode) { - TRACE("0x%x\n", ExceptionCode); + TRACE("0x%lx\n", ExceptionCode); switch (ExceptionCode) { case STATUS_DATATYPE_MISALIGNMENT: @@ -907,7 +938,7 @@ RPC_STATUS RPC_ENTRY RpcErrorSaveErrorInfo(RPC_ERROR_ENUM_HANDLE *EnumHandle, vo */ RPC_STATUS RPC_ENTRY RpcErrorLoadErrorInfo(void *ErrorBlob, SIZE_T BlobSize, RPC_ERROR_ENUM_HANDLE *EnumHandle) { - FIXME("(%p %lu %p): stub\n", ErrorBlob, BlobSize, EnumHandle); + FIXME("(%p %Iu %p): stub\n", ErrorBlob, BlobSize, EnumHandle); return ERROR_CALL_NOT_IMPLEMENTED; } @@ -925,7 +956,7 @@ RPC_STATUS RPC_ENTRY RpcErrorGetNextRecord(RPC_ERROR_ENUM_HANDLE *EnumHandle, BO */ RPC_STATUS RPC_ENTRY RpcMgmtSetCancelTimeout(LONG Timeout) { - FIXME("(%d): stub\n", Timeout); + FIXME("(%ld): stub\n", Timeout); return RPC_S_OK; } @@ -934,10 +965,10 @@ static struct threaddata *get_or_create_threaddata(void) struct threaddata *tdata = NtCurrentTeb()->ReservedForNtRpc; if (!tdata) { - tdata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*tdata)); + tdata = calloc(1, sizeof(*tdata)); if (!tdata) return NULL; - InitializeCriticalSection(&tdata->cs); + InitializeCriticalSectionEx(&tdata->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); tdata->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": threaddata.cs"); tdata->thread_id = GetCurrentThreadId(); @@ -984,7 +1015,7 @@ void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext) if (!tdata) return; - context_handle_list = HeapAlloc(GetProcessHeap(), 0, sizeof(*context_handle_list)); + context_handle_list = malloc(sizeof(*context_handle_list)); if (!context_handle_list) return; context_handle_list->context_handle = SContext; @@ -1007,7 +1038,7 @@ void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext) prev->next = current->next; else tdata->context_handle_list = current->next; - HeapFree(GetProcessHeap(), 0, current); + free(current); return; } } @@ -1026,7 +1057,7 @@ NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void) tdata->context_handle_list = context_handle_list->next; context_handle = context_handle_list->context_handle; - HeapFree(GetProcessHeap(), 0, context_handle_list); + free(context_handle_list); return context_handle; } @@ -1064,7 +1095,7 @@ RPC_STATUS RPC_ENTRY RpcCancelThreadEx(void* ThreadHandle, LONG Timeout) { DWORD target_tid; - FIXME("(%p, %d)\n", ThreadHandle, Timeout); + FIXME("(%p, %ld)\n", ThreadHandle, Timeout); target_tid = GetThreadId(ThreadHandle); if (!target_tid) @@ -1072,7 +1103,7 @@ RPC_STATUS RPC_ENTRY RpcCancelThreadEx(void* ThreadHandle, LONG Timeout) if (Timeout) { - FIXME("(%p, %d)\n", ThreadHandle, Timeout); + FIXME("(%p, %ld)\n", ThreadHandle, Timeout); return RPC_S_OK; } else diff --git a/dll/win32/rpcrt4/thunks-msvc.s b/dll/win32/rpcrt4/thunks-msvc.s new file mode 100644 index 00000000000..a13f04dd698 --- /dev/null +++ b/dll/win32/rpcrt4/thunks-msvc.s @@ -0,0 +1,114 @@ + +#if defined(_M_IX86) || defined(_M_AMD64) +#include +#elif defined(_M_ARM) +#include +#endif + +#ifdef _M_IX86 +.code32 + +THUNK_ENTRY MACRO num:REQ + ALIGN 4 + PUBLIC _ObjectStublessClient&num + _ObjectStublessClient&num: + mov eax, num + jmp _call_stubless_func +ENDM + +THUNK_ENTRY_VTBL MACRO num:REQ + ALIGN 4 + PUBLIC _NdrProxyForwardingFunction&num + _NdrProxyForwardingFunction&num: + mov eax, [esp + 4] + mov eax, [eax + 16] + mov [esp + 4], eax + mov eax, [eax] + DB 0ffh, 0a0h /* jmp *offset(%eax) */ + DD 4 * num +ENDM + +#elif defined(_M_AMD64) +.code64 + +THUNK_ENTRY MACRO num:REQ + ALIGN 4 + PUBLIC ObjectStublessClient&num + ObjectStublessClient&num: + mov r10d, num + jmp call_stubless_func +ENDM + +THUNK_ENTRY_VTBL MACRO num:REQ + ALIGN 4 + PUBLIC NdrProxyForwardingFunction&num + NdrProxyForwardingFunction&num: + mov rcx, [rcx + 020h] + mov rax, [rcx] + DB 0ffh, 0a0h /* jmp *offset(%rax) */ + DD 8 * num +ENDM + +#elif defined(_M_ARM) +.code32 + +// FIXME: this is probably broken +THUNK_ENTRY MACRO num:REQ + ldr ip, .number + b.w call_stubless_func + .number DB num +ENDM + +THUNK_ENTRY_VTBL MACRO num:REQ + ALIGN 4 + ldr r0, [r0, 10h] + ldr ip, [r0] + ldr pc, [ip, 4 * num] +ENDM + +#elif defined(_M_ARM64) +.code64 + +// FIXME: this is probably broken +THUNK_ENTRY MACRO num:REQ + mov w16, num + b call_stubless_func +ENDM + +THUNK_ENTRY_VTBL MACRO num:REQ + ldr x0, [x0, 20h] + ldr x16, [x0] + mov x17, num + ldr x16, [x16, x17, lsl 3] + br x16 +ENDM + +#endif + +ALL_THUNK_ENTRIES MACRO entry + blk = 3 + REPT 1021 + entry %blk + blk = blk + 1 + ENDM +ENDM + +#ifdef _M_IX86 +EXTERN _call_stubless_func:PROC +PUBLIC _stubless_thunks +_stubless_thunks: + ALL_THUNK_ENTRIES THUNK_ENTRY +PUBLIC _vtbl_thunks +_vtbl_thunks: + ALL_THUNK_ENTRIES THUNK_ENTRY_VTBL +#else +EXTERN call_stubless_func:PROC +PUBLIC stubless_thunks +stubless_thunks: + ALL_THUNK_ENTRIES THUNK_ENTRY +PUBLIC vtbl_thunks +vtbl_thunks: + ALL_THUNK_ENTRIES THUNK_ENTRY_VTBL +#endif + +END diff --git a/dll/win32/rpcrt4/thunks.c b/dll/win32/rpcrt4/thunks.c new file mode 100644 index 00000000000..67eef9e4334 --- /dev/null +++ b/dll/win32/rpcrt4/thunks.c @@ -0,0 +1,543 @@ +/* + * vtbl thunks + * + * Copyright 2009, 2023 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep arm64ec_x64 +#endif + +#define COBJMACROS + +#include + +#include "windef.h" +#include "winbase.h" +#include "objbase.h" +#include "rpcproxy.h" +#include "cpsf.h" +#include "ndrtypes.h" +#include "ndr_stubless.h" +#include "wine/asm.h" + +#define ALL_THUNK_ENTRIES \ + T(3) T(4) T(5) T(6) T(7) T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15) \ + T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23) T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31) \ + T(32) T(33) T(34) T(35) T(36) T(37) T(38) T(39) T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) \ + T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55) T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63) \ + T(64) T(65) T(66) T(67) T(68) T(69) T(70) T(71) T(72) T(73) T(74) T(75) T(76) T(77) T(78) T(79) \ + T(80) T(81) T(82) T(83) T(84) T(85) T(86) T(87) T(88) T(89) T(90) T(91) T(92) T(93) T(94) T(95) \ + T(96) T(97) T(98) T(99) T(100) T(101) T(102) T(103) T(104) T(105) T(106) T(107) T(108) T(109) T(110) T(111) \ + T(112) T(113) T(114) T(115) T(116) T(117) T(118) T(119) T(120) T(121) T(122) T(123) T(124) T(125) T(126) T(127) \ + T(128) T(129) T(130) T(131) T(132) T(133) T(134) T(135) T(136) T(137) T(138) T(139) T(140) T(141) T(142) T(143) \ + T(144) T(145) T(146) T(147) T(148) T(149) T(150) T(151) T(152) T(153) T(154) T(155) T(156) T(157) T(158) T(159) \ + T(160) T(161) T(162) T(163) T(164) T(165) T(166) T(167) T(168) T(169) T(170) T(171) T(172) T(173) T(174) T(175) \ + T(176) T(177) T(178) T(179) T(180) T(181) T(182) T(183) T(184) T(185) T(186) T(187) T(188) T(189) T(190) T(191) \ + T(192) T(193) T(194) T(195) T(196) T(197) T(198) T(199) T(200) T(201) T(202) T(203) T(204) T(205) T(206) T(207) \ + T(208) T(209) T(210) T(211) T(212) T(213) T(214) T(215) T(216) T(217) T(218) T(219) T(220) T(221) T(222) T(223) \ + T(224) T(225) T(226) T(227) T(228) T(229) T(230) T(231) T(232) T(233) T(234) T(235) T(236) T(237) T(238) T(239) \ + T(240) T(241) T(242) T(243) T(244) T(245) T(246) T(247) T(248) T(249) T(250) T(251) T(252) T(253) T(254) T(255) \ + T(256) T(257) T(258) T(259) T(260) T(261) T(262) T(263) T(264) T(265) T(266) T(267) T(268) T(269) T(270) T(271) \ + T(272) T(273) T(274) T(275) T(276) T(277) T(278) T(279) T(280) T(281) T(282) T(283) T(284) T(285) T(286) T(287) \ + T(288) T(289) T(290) T(291) T(292) T(293) T(294) T(295) T(296) T(297) T(298) T(299) T(300) T(301) T(302) T(303) \ + T(304) T(305) T(306) T(307) T(308) T(309) T(310) T(311) T(312) T(313) T(314) T(315) T(316) T(317) T(318) T(319) \ + T(320) T(321) T(322) T(323) T(324) T(325) T(326) T(327) T(328) T(329) T(330) T(331) T(332) T(333) T(334) T(335) \ + T(336) T(337) T(338) T(339) T(340) T(341) T(342) T(343) T(344) T(345) T(346) T(347) T(348) T(349) T(350) T(351) \ + T(352) T(353) T(354) T(355) T(356) T(357) T(358) T(359) T(360) T(361) T(362) T(363) T(364) T(365) T(366) T(367) \ + T(368) T(369) T(370) T(371) T(372) T(373) T(374) T(375) T(376) T(377) T(378) T(379) T(380) T(381) T(382) T(383) \ + T(384) T(385) T(386) T(387) T(388) T(389) T(390) T(391) T(392) T(393) T(394) T(395) T(396) T(397) T(398) T(399) \ + T(400) T(401) T(402) T(403) T(404) T(405) T(406) T(407) T(408) T(409) T(410) T(411) T(412) T(413) T(414) T(415) \ + T(416) T(417) T(418) T(419) T(420) T(421) T(422) T(423) T(424) T(425) T(426) T(427) T(428) T(429) T(430) T(431) \ + T(432) T(433) T(434) T(435) T(436) T(437) T(438) T(439) T(440) T(441) T(442) T(443) T(444) T(445) T(446) T(447) \ + T(448) T(449) T(450) T(451) T(452) T(453) T(454) T(455) T(456) T(457) T(458) T(459) T(460) T(461) T(462) T(463) \ + T(464) T(465) T(466) T(467) T(468) T(469) T(470) T(471) T(472) T(473) T(474) T(475) T(476) T(477) T(478) T(479) \ + T(480) T(481) T(482) T(483) T(484) T(485) T(486) T(487) T(488) T(489) T(490) T(491) T(492) T(493) T(494) T(495) \ + T(496) T(497) T(498) T(499) T(500) T(501) T(502) T(503) T(504) T(505) T(506) T(507) T(508) T(509) T(510) T(511) \ + T(512) T(513) T(514) T(515) T(516) T(517) T(518) T(519) T(520) T(521) T(522) T(523) T(524) T(525) T(526) T(527) \ + T(528) T(529) T(530) T(531) T(532) T(533) T(534) T(535) T(536) T(537) T(538) T(539) T(540) T(541) T(542) T(543) \ + T(544) T(545) T(546) T(547) T(548) T(549) T(550) T(551) T(552) T(553) T(554) T(555) T(556) T(557) T(558) T(559) \ + T(560) T(561) T(562) T(563) T(564) T(565) T(566) T(567) T(568) T(569) T(570) T(571) T(572) T(573) T(574) T(575) \ + T(576) T(577) T(578) T(579) T(580) T(581) T(582) T(583) T(584) T(585) T(586) T(587) T(588) T(589) T(590) T(591) \ + T(592) T(593) T(594) T(595) T(596) T(597) T(598) T(599) T(600) T(601) T(602) T(603) T(604) T(605) T(606) T(607) \ + T(608) T(609) T(610) T(611) T(612) T(613) T(614) T(615) T(616) T(617) T(618) T(619) T(620) T(621) T(622) T(623) \ + T(624) T(625) T(626) T(627) T(628) T(629) T(630) T(631) T(632) T(633) T(634) T(635) T(636) T(637) T(638) T(639) \ + T(640) T(641) T(642) T(643) T(644) T(645) T(646) T(647) T(648) T(649) T(650) T(651) T(652) T(653) T(654) T(655) \ + T(656) T(657) T(658) T(659) T(660) T(661) T(662) T(663) T(664) T(665) T(666) T(667) T(668) T(669) T(670) T(671) \ + T(672) T(673) T(674) T(675) T(676) T(677) T(678) T(679) T(680) T(681) T(682) T(683) T(684) T(685) T(686) T(687) \ + T(688) T(689) T(690) T(691) T(692) T(693) T(694) T(695) T(696) T(697) T(698) T(699) T(700) T(701) T(702) T(703) \ + T(704) T(705) T(706) T(707) T(708) T(709) T(710) T(711) T(712) T(713) T(714) T(715) T(716) T(717) T(718) T(719) \ + T(720) T(721) T(722) T(723) T(724) T(725) T(726) T(727) T(728) T(729) T(730) T(731) T(732) T(733) T(734) T(735) \ + T(736) T(737) T(738) T(739) T(740) T(741) T(742) T(743) T(744) T(745) T(746) T(747) T(748) T(749) T(750) T(751) \ + T(752) T(753) T(754) T(755) T(756) T(757) T(758) T(759) T(760) T(761) T(762) T(763) T(764) T(765) T(766) T(767) \ + T(768) T(769) T(770) T(771) T(772) T(773) T(774) T(775) T(776) T(777) T(778) T(779) T(780) T(781) T(782) T(783) \ + T(784) T(785) T(786) T(787) T(788) T(789) T(790) T(791) T(792) T(793) T(794) T(795) T(796) T(797) T(798) T(799) \ + T(800) T(801) T(802) T(803) T(804) T(805) T(806) T(807) T(808) T(809) T(810) T(811) T(812) T(813) T(814) T(815) \ + T(816) T(817) T(818) T(819) T(820) T(821) T(822) T(823) T(824) T(825) T(826) T(827) T(828) T(829) T(830) T(831) \ + T(832) T(833) T(834) T(835) T(836) T(837) T(838) T(839) T(840) T(841) T(842) T(843) T(844) T(845) T(846) T(847) \ + T(848) T(849) T(850) T(851) T(852) T(853) T(854) T(855) T(856) T(857) T(858) T(859) T(860) T(861) T(862) T(863) \ + T(864) T(865) T(866) T(867) T(868) T(869) T(870) T(871) T(872) T(873) T(874) T(875) T(876) T(877) T(878) T(879) \ + T(880) T(881) T(882) T(883) T(884) T(885) T(886) T(887) T(888) T(889) T(890) T(891) T(892) T(893) T(894) T(895) \ + T(896) T(897) T(898) T(899) T(900) T(901) T(902) T(903) T(904) T(905) T(906) T(907) T(908) T(909) T(910) T(911) \ + T(912) T(913) T(914) T(915) T(916) T(917) T(918) T(919) T(920) T(921) T(922) T(923) T(924) T(925) T(926) T(927) \ + T(928) T(929) T(930) T(931) T(932) T(933) T(934) T(935) T(936) T(937) T(938) T(939) T(940) T(941) T(942) T(943) \ + T(944) T(945) T(946) T(947) T(948) T(949) T(950) T(951) T(952) T(953) T(954) T(955) T(956) T(957) T(958) T(959) \ + T(960) T(961) T(962) T(963) T(964) T(965) T(966) T(967) T(968) T(969) T(970) T(971) T(972) T(973) T(974) T(975) \ + T(976) T(977) T(978) T(979) T(980) T(981) T(982) T(983) T(984) T(985) T(986) T(987) T(988) T(989) T(990) T(991) \ + T(992) T(993) T(994) T(995) T(996) T(997) T(998) T(999) T(1000) T(1001) T(1002) T(1003) T(1004) T(1005) T(1006) T(1007) \ + T(1008) T(1009) T(1010) T(1011) T(1012) T(1013) T(1014) T(1015) T(1016) T(1017) T(1018) T(1019) T(1020) T(1021) T(1022) T(1023) + +#ifdef __i386__ + +__ASM_GLOBAL_FUNC( call_stubless_func, + "movl 4(%esp),%ecx\n\t" /* This pointer */ + "movl (%ecx),%ecx\n\t" /* This->lpVtbl */ + "movl -8(%ecx),%ecx\n\t" /* MIDL_STUBLESS_PROXY_INFO */ + "movl 8(%ecx),%edx\n\t" /* info->FormatStringOffset */ + "movzwl (%edx,%eax,2),%edx\n\t" /* FormatStringOffset[index] */ + "addl 4(%ecx),%edx\n\t" /* info->ProcFormatString + offset */ + "movzbl 1(%edx),%eax\n\t" /* Oi_flags */ + "andl $0x08,%eax\n\t" /* Oi_HAS_RPCFLAGS */ + "shrl $1,%eax\n\t" + "movzwl 4(%edx,%eax),%eax\n\t" /* arguments size */ + "pushl %eax\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl $0\n\t" /* fpu_stack */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "leal 12(%esp),%eax\n\t" /* &This */ + "pushl %eax\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl %edx\n\t" /* format string */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl (%ecx)\n\t" /* info->pStubDesc */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "call " __ASM_STDCALL("NdrpClientCall2",16) "\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset -16\n\t") + "popl %edx\n\t" /* arguments size */ + __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t") + "movl (%esp),%ecx\n\t" /* return address */ + "addl %edx,%esp\n\t" + "jmp *%ecx" ) + +#define T(num) \ + ".balign 4\n\t" \ + ".globl " __ASM_NAME("ObjectStublessClient" #num) "\n" \ + __ASM_NAME("ObjectStublessClient" #num) ":\n\t" \ + "movl $"#num",%eax\n\t" \ + ".byte 0xe9\n\t" /* jmp */ \ + ".long " __ASM_NAME("call_stubless_func") "-1f\n" \ + "1:\n\t" + +#elif defined __x86_64__ + +__ASM_GLOBAL_FUNC( call_stubless_func, + "subq $0x38,%rsp\n\t" + __ASM_SEH(".seh_stackalloc 0x38\n\t") + __ASM_SEH(".seh_endprologue\n\t") + __ASM_CFI(".cfi_adjust_cfa_offset 0x38\n\t") + "movq %rcx,0x40(%rsp)\n\t" + "movq %rdx,0x48(%rsp)\n\t" + "movq %r8,0x50(%rsp)\n\t" + "movq %r9,0x58(%rsp)\n\t" + "leaq 0x40(%rsp),%rdx\n\t" /* args */ + "movq %xmm1,0x20(%rsp)\n\t" + "movq %xmm2,0x28(%rsp)\n\t" + "movq %xmm3,0x30(%rsp)\n\t" + "leaq 0x18(%rsp),%r8\n\t" /* fpu_regs */ + "movl %r10d,%ecx\n\t" /* index */ + "call " __ASM_NAME("ndr_stubless_client_call") "\n\t" + "addq $0x38,%rsp\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset -0x38\n\t") + "ret" ) + +#define T(num) \ + ".balign 4\n\t" \ + ".globl " __ASM_NAME("ObjectStublessClient" #num) "\n" \ + __ASM_NAME("ObjectStublessClient" #num) ":\n\t" \ + "movl $"#num",%r10d\n\t" \ + ".byte 0xe9\n\t" /* jmp */ \ + ".long " __ASM_NAME("call_stubless_func") "-1f\n" \ + "1:\n\t" + +#elif defined __aarch64__ + +__ASM_GLOBAL_FUNC( call_stubless_func, + "stp x29, x30, [sp, #-0x90]!\n\t" + ".seh_save_fplr_x 0x90\n\t" + "mov x29, sp\n\t" + ".seh_set_fp\n\t" + ".seh_endprologue\n\t" + "stp d0, d1, [sp, #0x10]\n\t" + "stp d2, d3, [sp, #0x20]\n\t" + "stp d4, d5, [sp, #0x30]\n\t" + "stp d6, d7, [sp, #0x40]\n\t" + "stp x0, x1, [sp, #0x50]\n\t" + "stp x2, x3, [sp, #0x60]\n\t" + "stp x4, x5, [sp, #0x70]\n\t" + "stp x6, x7, [sp, #0x80]\n\t" + "mov w0, w16\n\t" /* index */ + "add x1, sp, #0x50\n\t" /* args */ + "add x2, sp, #0x10\n\t" /* fpu_regs */ + "bl ndr_stubless_client_call\n\t" + "ldp x29, x30, [sp], #0x90\n\t" + "ret" ) + +#define T(num) \ + ".globl ObjectStublessClient" #num "\n" \ + "ObjectStublessClient" #num ":\n\t" \ + "mov w16,#"#num"\n\t" \ + "b call_stubless_func\n\t" + +#elif defined __arm__ + +__ASM_GLOBAL_FUNC( call_stubless_func, + "push {r0-r3}\n\t" + ".seh_save_regs {r0-r3}\n\t" + "push {fp,lr}\n\t" + ".seh_save_regs_w {fp,lr}\n\t" + "mov fp, sp\n\t" + ".seh_save_sp fp\n\t" + ".seh_endprologue\n\t" + "mov r0, ip\n\t" /* index */ + "add r1, sp, #8\n\t" /* args */ + "vpush {s0-s15}\n\t" /* store the s0-s15/d0-d7 arguments */ + "mov r2, sp\n\t" /* fpu_regs */ + "bl ndr_stubless_client_call\n\t" + "mov sp, fp\n\t" + "pop {fp,lr}\n\t" + "add sp, #16\n\t" + "bx lr" ) + +#define T(num) \ + ".globl ObjectStublessClient" #num "\n" \ + "ObjectStublessClient" #num ":\n\t" \ + "ldr ip,1f\n\t" \ + "b.w call_stubless_func\n" \ + "1:\t.long "#num"\n\t" + +#endif /* __i386__ */ + +__ASM_GLOBAL_FUNC( stubless_thunks, ALL_THUNK_ENTRIES ) + +#undef T + + +/* The idea here is to replace the first param on the stack + ie. This (which will point to cstdstubbuffer_delegating_t) + with This->stub_buffer.pvServerObject and then jump to the + relevant offset in This->stub_buffer.pvServerObject's vtbl. +*/ +#ifdef __i386__ + +#define T(num) \ + ".balign 4\n\t" \ + ".globl " __ASM_NAME("NdrProxyForwardingFunction" #num) "\n" \ + __ASM_NAME("NdrProxyForwardingFunction" #num) ":\n\t" \ + "mov 4(%esp),%eax\n\t" \ + "mov 0x10(%eax),%eax\n\t" \ + "mov %eax,4(%esp)\n\t" \ + "mov (%eax),%eax\n\t" \ + ".byte 0xff,0xa0\n\t" /* jmp *offset(%eax) */ \ + ".long 4*"#num"\n\t" + +#elif defined __x86_64__ + +#define T(num) \ + ".balign 4\n\t" \ + ".globl " __ASM_NAME("NdrProxyForwardingFunction" #num) "\n" \ + __ASM_NAME("NdrProxyForwardingFunction" #num) ":\n\t" \ + "movq 0x20(%rcx),%rcx\n\t" \ + "movq (%rcx),%rax\n\t" \ + ".byte 0xff,0xa0\n\t" /* jmp *offset(%rax) */ \ + ".long 8*"#num"\n\t" + +#elif defined __aarch64__ + +#define T(num) \ + ".globl NdrProxyForwardingFunction" #num "\n" \ + "NdrProxyForwardingFunction" #num ":\n\t" \ + "ldr x0, [x0, #0x20]\n\t" \ + "ldr x16, [x0]\n\t" \ + "mov x17, #"#num"\n\t" \ + "ldr x16, [x16, x17, lsl #3]\n\t" \ + "br x16\n\t" + +#elif defined __arm__ + +#define T(num) \ + ".balign 4\n\t" \ + ".globl NdrProxyForwardingFunction" #num "\n" \ + "NdrProxyForwardingFunction" #num ":\n\t" \ + "ldr r0, [r0, #0x10]\n\t" \ + "ldr ip, [r0]\n\t" \ + "ldr pc, [ip, #(4*"#num")]\n\t" + +#endif /* __i386__ */ + +__ASM_GLOBAL_FUNC( vtbl_thunks, ALL_THUNK_ENTRIES ) + +#undef T + +static HRESULT WINAPI delegating_QueryInterface(IUnknown *pUnk, REFIID iid, void **ppv) +{ + *ppv = pUnk; + return S_OK; +} + +static ULONG WINAPI delegating_AddRef(IUnknown *pUnk) +{ + return 1; +} + +static ULONG WINAPI delegating_Release(IUnknown *pUnk) +{ + return 1; +} + +#define T(num) extern void NdrProxyForwardingFunction##num(void); +ALL_THUNK_ENTRIES +#undef T + +const struct delegating_vtbl delegating_vtbl = +{ + { delegating_QueryInterface, delegating_AddRef, delegating_Release }, + { +#define T(num) (void *)NdrProxyForwardingFunction##num, + ALL_THUNK_ENTRIES +#undef T + } +}; + + +#if defined(__aarch64__) || defined(__arm__) +static void __attribute__((used)) args_stack_to_regs( void **args, void **regs, void **stack, + const NDR_PROC_PARTIAL_OIF_HEADER *header ) +{ + const NDR_PROC_HEADER_EXTS *ext = (const NDR_PROC_HEADER_EXTS *)(header + 1); + unsigned int i, size, count, pos; + unsigned char *data; + +#ifdef __arm__ + const NDR_PARAM_OIF *params = (const NDR_PARAM_OIF *)((const char *)ext + ext->Size); + + for (i = 0; i < header->number_of_params; i++) + if (params[i].attr.IsIn && params[i].attr.IsBasetype) + { + int *arg = (int *)((char *)args + params[i].stack_offset); + + switch (params[i].u.type_format_char) + { + case FC_BYTE: + case FC_USMALL: + *arg = (unsigned char)*arg; + break; + case FC_CHAR: + case FC_SMALL: + *arg = (signed char)*arg; + break; + case FC_WCHAR: + case FC_USHORT: + *arg = (unsigned short)*arg; + break; + case FC_SHORT: + *arg = (short)*arg; + break; + } + } +#endif + + if (ext->Size < sizeof(*ext) + 3) return; + data = (unsigned char *)(ext + 1); + size = min( ext->Size - sizeof(*ext) - 3, data[2] ); + data += 3; + for (i = pos = 0; i < size; i++, pos++) + { + if (data[i] < 0x80) continue; + else if (data[i] < 0x94) regs[data[i] - 0x80] = args[pos]; + else if (data[i] == 0x9d) /* repeat */ + { + if (i + 3 >= size) break; + count = data[i + 2] + (data[i + 3] << 8); + memcpy( &stack[pos + (signed char)data[i + 1]], &args[pos], count * sizeof(*args) ); + pos += count - 1; + i += 3; + } + else if (data[i] < 0xa0) continue; + else stack[pos + (signed char)data[i]] = args[pos]; + } +} +#endif + + +/* Call a function with the specified arguments, restoring the stack + * properly afterwards as we don't know the calling convention of the + * function */ +#if defined __i386__ && defined _MSC_VER && defined __REACTOS__ // Wine has removed this :( +__declspec(naked) LONG_PTR __cdecl call_server_func(SERVER_ROUTINE func, unsigned char * args, unsigned int stack_size, + const NDR_PROC_PARTIAL_OIF_HEADER *header ) +{ + __asm + { + push ebp + mov ebp, esp + push edi ; Save registers + push esi + mov eax, [ebp+16] ; Get stack size + sub esp, eax ; Make room in stack for arguments + and esp, 0xFFFFFFF0 + mov edi, esp + mov ecx, eax + mov esi, [ebp+12] + shr ecx, 2 + cld + rep movsd ; Copy dword blocks + call [ebp+8] ; Call function + lea esp, [ebp-8] ; Restore stack + pop esi ; Restore registers + pop edi + pop ebp + ret + } +} +#elif defined __i386__ // remove above, replace here with #ifdef __i386__ +__ASM_GLOBAL_FUNC( call_server_func, + "pushl %ebp\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + __ASM_CFI(".cfi_rel_offset %ebp,0\n\t") + "movl %esp,%ebp\n\t" + __ASM_CFI(".cfi_def_cfa_register %ebp\n\t") + "pushl %edi\n\t" /* Save registers */ + __ASM_CFI(".cfi_rel_offset %edi,-4\n\t") + "pushl %esi\n\t" + __ASM_CFI(".cfi_rel_offset %esi,-8\n\t") + "movl 16(%ebp), %eax\n\t" /* Get stack size */ + "subl %eax, %esp\n\t" /* Make room in stack for arguments */ + "andl $~15, %esp\n\t" /* Make sure stack has 16-byte alignment for Mac OS X */ + "movl %esp, %edi\n\t" + "movl %eax, %ecx\n\t" + "movl 12(%ebp), %esi\n\t" + "shrl $2, %ecx\n\t" /* divide by 4 */ + "cld\n\t" + "rep; movsl\n\t" /* Copy dword blocks */ + "call *8(%ebp)\n\t" /* Call function */ + "leal -8(%ebp), %esp\n\t" /* Restore stack */ + "popl %esi\n\t" /* Restore registers */ + __ASM_CFI(".cfi_same_value %esi\n\t") + "popl %edi\n\t" + __ASM_CFI(".cfi_same_value %edi\n\t") + "popl %ebp\n\t" + __ASM_CFI(".cfi_def_cfa %esp,4\n\t") + __ASM_CFI(".cfi_same_value %ebp\n\t") + "ret" ) +#elif defined __x86_64__ +__ASM_GLOBAL_FUNC( call_server_func, + "pushq %rbp\n\t" + __ASM_SEH(".seh_pushreg %rbp\n\t") + __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t") + __ASM_CFI(".cfi_rel_offset %rbp,0\n\t") + "movq %rsp,%rbp\n\t" + __ASM_SEH(".seh_setframe %rbp,0\n\t") + __ASM_CFI(".cfi_def_cfa_register %rbp\n\t") + "pushq %rsi\n\t" + __ASM_SEH(".seh_pushreg %rsi\n\t") + __ASM_CFI(".cfi_rel_offset %rsi,-8\n\t") + "pushq %rdi\n\t" + __ASM_SEH(".seh_pushreg %rdi\n\t") + __ASM_SEH(".seh_endprologue\n\t") + __ASM_CFI(".cfi_rel_offset %rdi,-16\n\t") + "movq %rcx,%rax\n\t" /* function to call */ + "movq $32,%rcx\n\t" /* allocate max(32,stack_size) bytes of stack space */ + "cmpq %rcx,%r8\n\t" + "cmovgq %r8,%rcx\n\t" + "subq %rcx,%rsp\n\t" + "andq $~15,%rsp\n\t" + "movq %r8,%rcx\n\t" + "shrq $3,%rcx\n\t" + "movq %rsp,%rdi\n\t" + "movq %rdx,%rsi\n\t" + "rep; movsq\n\t" /* copy arguments */ + "movq 0(%rsp),%rcx\n\t" + "movq 8(%rsp),%rdx\n\t" + "movq 16(%rsp),%r8\n\t" + "movq 24(%rsp),%r9\n\t" + "movq 0(%rsp),%xmm0\n\t" + "movq 8(%rsp),%xmm1\n\t" + "movq 16(%rsp),%xmm2\n\t" + "movq 24(%rsp),%xmm3\n\t" + "callq *%rax\n\t" + "leaq -16(%rbp),%rsp\n\t" /* restore stack */ + "popq %rdi\n\t" + __ASM_CFI(".cfi_same_value %rdi\n\t") + "popq %rsi\n\t" + __ASM_CFI(".cfi_same_value %rsi\n\t") + __ASM_CFI(".cfi_def_cfa_register %rsp\n\t") + "popq %rbp\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") + __ASM_CFI(".cfi_same_value %rbp\n\t") + "ret" ) +#elif defined __arm__ +__ASM_GLOBAL_FUNC( call_server_func, + "push {r4,r5,fp,lr}\n\t" + ".seh_save_regs_w {r4,r5,fp,lr}\n\t" + "mov fp, sp\n\t" + ".seh_save_sp fp\n\t" + ".seh_endprologue\n\t" + "add r2, r2, #20*4+8+4\n\t" + "and r2, r2, #~7\n\t" + "sub sp, sp, r2\n\t" + "mov r4, r0\n\t" /* func */ + "mov r0, r1\n\t" /* args */ + "add r1, sp, #8\n\t" /* regs */ + "add r2, r1, #20*4\n\t" /* stack */ + "bl args_stack_to_regs\n\t" + "add sp, sp, #8\n\t" + "pop {r0-r3}\n\t" + "vpop {s0-s15}\n\t" + "blx r4\n\t" + "mov sp, fp\n\t" + "pop {r4,r5,fp,pc}" ) +#elif defined __aarch64__ +__ASM_GLOBAL_FUNC( call_server_func, + "stp x29, x30, [sp, #-0x20]!\n\t" + ".seh_save_fplr_x 0x20\n\t" + "stp x19, x20, [sp, #0x10]\n\t" + ".seh_save_regp x19, 0x10\n\t" + "mov x29, sp\n\t" + ".seh_set_fp\n\t" + ".seh_endprologue\n\t" + "add x9, x2, #16*8+15\n\t" + "lsr x9, x9, #4\n\t" + "sub sp, sp, x9, lsl #4\n\t" + "mov x19, x0\n\t" /* func */ + "mov x0, x1\n\t" /* args */ + "mov x1, sp\n\t" /* regs */ + "add x2, sp, #16*8\n\t" /* stack */ + "bl args_stack_to_regs\n\t" + "ldp x2, x3, [sp, #0x10]\n\t" + "ldp x4, x5, [sp, #0x20]\n\t" + "ldp x6, x7, [sp, #0x30]\n\t" + "ldp d0, d1, [sp, #0x40]\n\t" + "ldp d2, d3, [sp, #0x50]\n\t" + "ldp d4, d5, [sp, #0x60]\n\t" + "ldp d6, d7, [sp, #0x70]\n\t" + "ldp x0, x1, [sp], #0x80\n\t" + "blr x19\n\t" + "mov sp, x29\n\t" + "ldp x19, x20, [sp, #0x10]\n\t" + "ldp x29, x30, [sp], #0x20\n\t" + "ret" ) +#endif diff --git a/media/doc/WINESYNC.txt b/media/doc/WINESYNC.txt index 0eccb10e888..dbda7d7e6ae 100644 --- a/media/doc/WINESYNC.txt +++ b/media/doc/WINESYNC.txt @@ -21,6 +21,9 @@ sdk/tools/unicode # Synced to WineStaging-4.18 sdk/tools/widl # Synced to Wine-10.0 sdk/tools/wpp # Synced to Wine-10.0 (Module was moved into wrc tool) +The following headers are shared with Wine. +sdk/include/psdk/rpcproxy.h # Synced to Wine-10.0 + The following libraries are shared with Wine. dll/directx/wine/amstream # Synced to WineStaging-3.9 diff --git a/modules/rostests/winetests/rpcrt4/CMakeLists.txt b/modules/rostests/winetests/rpcrt4/CMakeLists.txt index 753de69ef8b..aae70c3d918 100644 --- a/modules/rostests/winetests/rpcrt4/CMakeLists.txt +++ b/modules/rostests/winetests/rpcrt4/CMakeLists.txt @@ -2,9 +2,12 @@ remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502) add_definitions( + -DCONST_VTABLE -DUSE_WINE_TODOS -DWINETEST_USE_DBGSTR_LONGLONG - -DPROXY_DELEGATION) + -DPROXY_DELEGATION + -Dstrdup=_strdup +) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(OLD_IDL_FLAGS ${IDL_FLAGS}) @@ -12,6 +15,10 @@ set(IDL_FLAGS ${IDL_FLAGS} --prefix-server=s_ -Os --prefix-client=mixed_) add_rpc_files(client server.idl) add_rpc_files(server server.idl) set(IDL_FLAGS ${OLD_IDL_FLAGS}) +set(IDL_FLAGS ${IDL_FLAGS} --prefix-server=s_ -Os --prefix-client=) +add_rpc_files(client explicit_handle.idl) +add_rpc_files(server explicit_handle.idl) +set(IDL_FLAGS ${OLD_IDL_FLAGS}) set(IDL_FLAGS ${IDL_FLAGS} --prefix-server=s_ -Oicf --prefix-client=interp_) add_rpc_files(client server_interp.idl) add_rpc_files(server server_interp.idl) @@ -27,6 +34,8 @@ list(APPEND SOURCE server.c testlist.c ${CMAKE_CURRENT_BINARY_DIR}/cstub_p.c + ${CMAKE_CURRENT_BINARY_DIR}/explicit_handle_c.c + ${CMAKE_CURRENT_BINARY_DIR}/explicit_handle_s.c ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${CMAKE_CURRENT_BINARY_DIR}/server_c.c ${CMAKE_CURRENT_BINARY_DIR}/server_s.c diff --git a/modules/rostests/winetests/rpcrt4/cstub.c b/modules/rostests/winetests/rpcrt4/cstub.c index c9e4fbf3dd0..54f029aaae3 100644 --- a/modules/rostests/winetests/rpcrt4/cstub.c +++ b/modules/rostests/winetests/rpcrt4/cstub.c @@ -22,9 +22,6 @@ #include #define COBJMACROS -#ifdef __REACTOS__ -#define CONST_VTABLE -#endif #include #include @@ -37,7 +34,6 @@ #include "rpcdce.h" #include "rpcproxy.h" -#include "wine/heap.h" #include "wine/test.h" #include "cstub_p.h" @@ -66,13 +62,13 @@ static int my_free_called; static void * CALLBACK my_alloc(SIZE_T size) { my_alloc_called++; - return NdrOleAllocate(size); + return malloc(size); } static void CALLBACK my_free(void *ptr) { my_free_called++; - NdrOleFree(ptr); + free(ptr); } typedef struct _MIDL_PROC_FORMAT_STRING @@ -502,13 +498,13 @@ static IPSFactoryBuffer *test_NdrDllGetClassObject(void) r = NdrDllGetClassObject(&CLSID_Unknown, &IID_IPSFactoryBuffer, (void**)&ppsf, proxy_file_list, &CLSID_psfact, &PSFactoryBuffer); - ok(r == CLASS_E_CLASSNOTAVAILABLE, "NdrDllGetClassObject with unknown clsid should have returned CLASS_E_CLASSNOTAVAILABLE instead of 0x%x\n", r); + ok(r == CLASS_E_CLASSNOTAVAILABLE, "NdrDllGetClassObject with unknown clsid should have returned CLASS_E_CLASSNOTAVAILABLE instead of 0x%lx\n", r); ok(ppsf == NULL, "NdrDllGetClassObject should have set ppsf to NULL on failure\n"); r = NdrDllGetClassObject(&CLSID_psfact, &IID_IPSFactoryBuffer, (void**)&ppsf, proxy_file_list, &CLSID_psfact, &PSFactoryBuffer); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); ok(ppsf != NULL, "ppsf == NULL\n"); proxy_vtbl = PSFactoryBuffer.pProxyFileList[0]->pProxyVtblList; @@ -625,31 +621,31 @@ static IPSFactoryBuffer *test_NdrDllGetClassObject(void) ok( proxy_vtbl[i]->header.piid == interfaces[i], "wrong proxy %u iid %p/%p\n", i, proxy_vtbl[i]->header.piid, interfaces[i] ); - ok(PSFactoryBuffer.RefCount == 1, "ref count %d\n", PSFactoryBuffer.RefCount); + ok(PSFactoryBuffer.RefCount == 1, "ref count %ld\n", PSFactoryBuffer.RefCount); IPSFactoryBuffer_Release(ppsf); /* One can also search by IID */ r = NdrDllGetClassObject(&IID_if3, &IID_IPSFactoryBuffer, (void**)&ppsf, proxy_file_list, &CLSID_psfact, &PSFactoryBuffer); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); ok(ppsf != NULL, "ppsf == NULL\n"); IPSFactoryBuffer_Release(ppsf); r = NdrDllGetClassObject(&IID_if3, &IID_IPSFactoryBuffer, (void**)&ppsf, proxy_file_list, NULL, &PSFactoryBuffer); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); ok(ppsf != NULL, "ppsf == NULL\n"); IPSFactoryBuffer_Release(ppsf); /* but only if the PS factory implements it */ r = NdrDllGetClassObject(&IID_IDispatch, &IID_IPSFactoryBuffer, (void**)&ppsf, proxy_file_list, &CLSID_psfact, &PSFactoryBuffer); - ok(r == CLASS_E_CLASSNOTAVAILABLE, "ret %08x\n", r); + ok(r == CLASS_E_CLASSNOTAVAILABLE, "ret %08lx\n", r); /* Create it again to return */ r = NdrDllGetClassObject(&CLSID_psfact, &IID_IPSFactoryBuffer, (void**)&ppsf, proxy_file_list, &CLSID_psfact, &PSFactoryBuffer); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); ok(ppsf != NULL, "ppsf == NULL\n"); /* Because this PS factory is not loaded as a dll in the normal way, Windows 8 / 10 @@ -657,13 +653,13 @@ static IPSFactoryBuffer *test_NdrDllGetClassObject(void) Registering the ifaces fixes this (in fact calling CoRegisterPSClsid() with any IID / CLSID is enough). */ r = CoRegisterPSClsid(&IID_if1, &CLSID_psfact); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); r = CoRegisterPSClsid(&IID_if2, &CLSID_psfact); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); r = CoRegisterPSClsid(&IID_if3, &CLSID_psfact); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); r = CoRegisterPSClsid(&IID_if4, &CLSID_psfact); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); return ppsf; } @@ -715,7 +711,7 @@ static IRpcStubBuffer *create_stub(IPSFactoryBuffer *ppsf, REFIID iid, IUnknown HRESULT r; r = IPSFactoryBuffer_CreateStub(ppsf, iid, obj, &pstub); - ok(r == expected_result, "CreateStub returned %08x expected %08x\n", r, expected_result); + ok(r == expected_result, "CreateStub returned %08lx expected %08lx\n", r, expected_result); return pstub; } @@ -792,25 +788,25 @@ static void create_proxy_test( IPSFactoryBuffer *ppsf, REFIID iid, const void *e ULONG count; r = IPSFactoryBuffer_CreateProxy(ppsf, NULL, iid, &proxy, (void **)&iface); - ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %x\n", r ); + ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %lx\n", r ); ok( *(void **)iface == expected_vtbl, "wrong iface pointer %p/%p\n", *(void **)iface, expected_vtbl ); count = IUnknown_Release( iface ); - ok( count == 1, "wrong refcount %u\n", count ); + ok( count == 1, "wrong refcount %lu\n", count ); count = IRpcProxyBuffer_Release( proxy ); - ok( count == 0, "wrong refcount %u\n", count ); + ok( count == 0, "wrong refcount %lu\n", count ); dummy_unknown.ref = 4; r = IPSFactoryBuffer_CreateProxy(ppsf, &dummy_unknown.IUnknown_iface, iid, &proxy, (void **)&iface); - ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %x\n", r ); - ok( dummy_unknown.ref == 5, "wrong refcount %u\n", dummy_unknown.ref ); + ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %lx\n", r ); + ok( dummy_unknown.ref == 5, "wrong refcount %lu\n", dummy_unknown.ref ); ok( *(void **)iface == expected_vtbl, "wrong iface pointer %p/%p\n", *(void **)iface, expected_vtbl ); count = IUnknown_Release( iface ); - ok( count == 4, "wrong refcount %u\n", count ); - ok( dummy_unknown.ref == 4, "wrong refcount %u\n", dummy_unknown.ref ); + ok( count == 4, "wrong refcount %lu\n", count ); + ok( dummy_unknown.ref == 4, "wrong refcount %lu\n", dummy_unknown.ref ); count = IRpcProxyBuffer_Release( proxy ); - ok( count == 0, "wrong refcount %u\n", count ); - ok( dummy_unknown.ref == 4, "wrong refcount %u\n", dummy_unknown.ref ); + ok( count == 0, "wrong refcount %lu\n", count ); + ok( dummy_unknown.ref == 4, "wrong refcount %lu\n", dummy_unknown.ref ); } static void test_CreateProxy( IPSFactoryBuffer *ppsf ) @@ -830,7 +826,7 @@ static void test_CreateStub(IPSFactoryBuffer *ppsf) const CInterfaceStubHeader *header = &CONTAINING_RECORD(cstd_stub->lpVtbl, const CInterfaceStubVtbl, Vtbl)->header; ok(IsEqualIID(header->piid, &IID_if1), "header iid differs\n"); - ok(cstd_stub->RefCount == 1, "ref count %d\n", cstd_stub->RefCount); + ok(cstd_stub->RefCount == 1, "ref count %ld\n", cstd_stub->RefCount); /* 0xdeadbeef returned from create_stub_test_QI */ ok(cstd_stub->pvServerObject == (void*)0xdeadbeef, "pvServerObject %p\n", cstd_stub->pvServerObject); ok(cstd_stub->pPSFactory != NULL, "pPSFactory was NULL\n"); @@ -839,7 +835,7 @@ static void test_CreateStub(IPSFactoryBuffer *ppsf) vtbl = &create_stub_test_fail_vtbl; pstub = create_stub(ppsf, &IID_if1, obj, E_NOINTERFACE); - ok(pstub == NULL, "create_stub failed: %u\n", GetLastError()); + ok(pstub == NULL, "create_stub failed: %lu\n", GetLastError()); } @@ -929,14 +925,14 @@ static void test_Connect(IPSFactoryBuffer *ppsf) obj = (IUnknown*)&new_vtbl; r = IRpcStubBuffer_Connect(pstub, obj); - ok(r == S_OK, "r %08x\n", r); + ok(r == S_OK, "r %08lx\n", r); ok(connect_test_orig_release_called == 1, "release called %d\n", connect_test_orig_release_called); ok(cstd_stub->pvServerObject == (void*)0xcafebabe, "pvServerObject %p\n", cstd_stub->pvServerObject); cstd_stub->pvServerObject = (IUnknown*)&orig_vtbl; obj = (IUnknown*)&new_fail_vtbl; r = IRpcStubBuffer_Connect(pstub, obj); - ok(r == E_NOINTERFACE, "r %08x\n", r); + ok(r == E_NOINTERFACE, "r %08lx\n", r); ok(cstd_stub->pvServerObject == (void*)0xdeadbeef, "pvServerObject %p\n", cstd_stub->pvServerObject); ok(connect_test_orig_release_called == 2, "release called %d\n", connect_test_orig_release_called); @@ -957,7 +953,7 @@ static void test_Connect(IPSFactoryBuffer *ppsf) obj = (IUnknown*)&new_vtbl; r = IRpcStubBuffer_Connect(pstub, obj); - ok(r == S_OK, "r %08x\n", r); + ok(r == S_OK, "r %08lx\n", r); ok(connect_test_base_Connect_called == 1, "connect_test_bsae_Connect called %d times\n", connect_test_base_Connect_called); ok(connect_test_orig_release_called == 3, "release called %d\n", connect_test_orig_release_called); @@ -1007,21 +1003,21 @@ static void test_Release(IPSFactoryBuffer *ppsf) facbuf_refs = PSFactoryBuffer.RefCount; /* This shows that NdrCStdStubBuffer_Release doesn't call Disconnect */ - ok(cstd_stub->RefCount == 1, "ref count %d\n", cstd_stub->RefCount); + ok(cstd_stub->RefCount == 1, "ref count %ld\n", cstd_stub->RefCount); connect_test_orig_release_called = 0; IRpcStubBuffer_Release(pstub); todo_wine { ok(connect_test_orig_release_called == 0, "release called %d\n", connect_test_orig_release_called); } - ok(PSFactoryBuffer.RefCount == facbuf_refs - 1, "factory buffer refs %d orig %d\n", PSFactoryBuffer.RefCount, facbuf_refs); + ok(PSFactoryBuffer.RefCount == facbuf_refs - 1, "factory buffer refs %ld orig %ld\n", PSFactoryBuffer.RefCount, facbuf_refs); /* This shows that NdrCStdStubBuffer_Release calls Release on its 2nd arg, rather than on This->pPSFactory (which are usually the same and indeed it's odd that _Release requires this 2nd arg). */ pstub = create_stub(ppsf, &IID_if1, obj, S_OK); - ok(PSFactoryBuffer.RefCount == facbuf_refs, "factory buffer refs %d orig %d\n", PSFactoryBuffer.RefCount, facbuf_refs); + ok(PSFactoryBuffer.RefCount == facbuf_refs, "factory buffer refs %ld orig %ld\n", PSFactoryBuffer.RefCount, facbuf_refs); NdrCStdStubBuffer_Release(pstub, (IPSFactoryBuffer*)pretend_psfacbuf); ok(release_test_psfacbuf_release_called == 1, "pretend_psfacbuf_release called %d\n", release_test_psfacbuf_release_called); - ok(PSFactoryBuffer.RefCount == facbuf_refs, "factory buffer refs %d orig %d\n", PSFactoryBuffer.RefCount, facbuf_refs); + ok(PSFactoryBuffer.RefCount == facbuf_refs, "factory buffer refs %ld orig %ld\n", PSFactoryBuffer.RefCount, facbuf_refs); } static HRESULT WINAPI delegating_invoke_test_QI(ITypeLib *pUnk, REFIID iid, void** ppv) @@ -1085,7 +1081,7 @@ static HRESULT WINAPI delegating_invoke_chan_get_buffer(IRpcChannelBuffer *pchan RPCOLEMESSAGE *msg, REFIID iid) { - msg->Buffer = HeapAlloc(GetProcessHeap(), 0, msg->cbBuffer); + msg->Buffer = malloc(msg->cbBuffer); return S_OK; } @@ -1145,14 +1141,14 @@ static void test_delegating_Invoke(IPSFactoryBuffer *ppsf) msg.dataRepresentation = NDR_LOCAL_DATA_REPRESENTATION; msg.iMethod = 3; r = IRpcStubBuffer_Invoke(pstub, &msg, pchan); - ok(r == S_OK, "ret %08x\n", r); + ok(r == S_OK, "ret %08lx\n", r); if(r == S_OK) { - ok(*(DWORD*)msg.Buffer == 0xabcdef, "buf[0] %08x\n", *(DWORD*)msg.Buffer); - ok(*((DWORD*)msg.Buffer + 1) == S_OK, "buf[1] %08x\n", *((DWORD*)msg.Buffer + 1)); + ok(*(DWORD*)msg.Buffer == 0xabcdef, "buf[0] %08lx\n", *(DWORD*)msg.Buffer); + ok(*((DWORD*)msg.Buffer + 1) == S_OK, "buf[1] %08lx\n", *((DWORD*)msg.Buffer + 1)); } /* free the buffer allocated by delegating_invoke_chan_get_buffer */ - HeapFree(GetProcessHeap(), 0, msg.Buffer); + free(msg.Buffer); IRpcStubBuffer_Release(pstub); } static const CInterfaceProxyVtbl *cstub_ProxyVtblList2[] = @@ -1203,19 +1199,19 @@ static void test_NdrDllRegisterProxy( void ) res = NdrDllRegisterProxy(NULL, NULL, NULL); - ok(res == E_HANDLE, "Incorrect return code %x\n",res); + ok(res == E_HANDLE, "Incorrect return code %lx\n",res); pf = NULL; res = NdrDllRegisterProxy(hmod, &pf, NULL); - ok(res == E_NOINTERFACE, "Incorrect return code %x\n",res); + ok(res == E_NOINTERFACE, "Incorrect return code %lx\n",res); res = NdrDllRegisterProxy(hmod, proxy_file_list2, NULL); - ok(res == E_NOINTERFACE, "Incorrect return code %x\n",res); + ok(res == E_NOINTERFACE, "Incorrect return code %lx\n",res); /* This fails on Vista and Windows 7 due to permissions */ res = NdrDllRegisterProxy(hmod, proxy_file_list, NULL); - ok(res == S_OK || res == E_ACCESSDENIED, "NdrDllRegisterProxy failed %x\n",res); + ok(res == S_OK || res == E_ACCESSDENIED, "NdrDllRegisterProxy failed %lx\n",res); if (res == S_OK) { res = NdrDllUnregisterProxy(hmod,proxy_file_list, NULL); - ok(res == S_OK, "NdrDllUnregisterProxy failed %x\n",res); + ok(res == S_OK, "NdrDllUnregisterProxy failed %lx\n",res); } } @@ -1231,7 +1227,7 @@ static HANDLE create_process(const char *arg) winetest_get_mainargs(&argv); sprintf(cmdline, "\"%s\" %s %s", argv[0], argv[1], arg); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); - ok(ret, "CreateProcess failed: %u\n", GetLastError()); + ok(ret, "CreateProcess failed: %lu\n", GetLastError()); CloseHandle(pi.hThread); return pi.hProcess; } @@ -1303,7 +1299,7 @@ static ULONG WINAPI test_cf_Release(IClassFactory *iface) static HRESULT WINAPI test_cf_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **out) { - ITest1 *obj = heap_alloc(sizeof(*obj)); + ITest1 *obj = malloc(sizeof(*obj)); obj->lpVtbl = &test1_vtbl; @@ -1343,30 +1339,30 @@ static void local_server_proc(void) hr = CoRegisterClassObject(&CLSID_test1, (IUnknown *)&test_cf, CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &obj_cookie); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = NdrDllGetClassObject(&CLSID_test_ps, &IID_IPSFactoryBuffer, (void **)&ps, &aProxyFileList, &CLSID_test_ps, &gPFactory); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = CoRegisterClassObject(&CLSID_test_ps, (IUnknown *)ps, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &ps_cookie); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = CoRegisterPSClsid(&IID_ITest1, &CLSID_test_ps); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); SetEvent(ready_event); hr = CoWaitForMultipleHandles(0, 1000, 1, &stop_event, &index); - ok(hr == S_OK, "got %#x\n", hr); - ok(!index, "got %u\n", index); + ok(hr == S_OK, "got %#lx\n", hr); + ok(!index, "got %lu\n", index); hr = CoRevokeClassObject(ps_cookie); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = CoRevokeClassObject(obj_cookie); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); CoUninitialize(); ExitProcess(0); @@ -1386,27 +1382,27 @@ static void test_delegated_methods(void) ready_event = CreateEventA(NULL, TRUE, FALSE, "wine_cstub_test_server_ready"); process = create_process("server"); - ok(!WaitForSingleObject(ready_event, 1000), "wait failed\n"); + ok(!WaitForSingleObject(ready_event, 5000), "wait failed\n"); hr = NdrDllGetClassObject(&CLSID_test_ps, &IID_IPSFactoryBuffer, (void **)&ps, &aProxyFileList, &CLSID_test_ps, &gPFactory); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = CoRegisterClassObject(&CLSID_test_ps, (IUnknown *)ps, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &ps_cookie); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = CoRegisterPSClsid(&IID_ITest1, &CLSID_test_ps); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = CoCreateInstance(&CLSID_test1, NULL, CLSCTX_LOCAL_SERVER, &IID_ITest1, (void **)&test_obj); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); ret = ITest1_square(test_obj, 3); ok(ret == 9, "got %d\n", ret); hr = ITest1_GetClassID(test_obj, &clsid); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); ok(IsEqualGUID(&clsid, &CLSID_test1), "got %s\n", wine_dbgstr_guid(&clsid)); ITest1_Release(test_obj); @@ -1415,7 +1411,141 @@ static void test_delegated_methods(void) ok(!WaitForSingleObject(process, 1000), "wait failed\n"); hr = CoRevokeClassObject(ps_cookie); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); +} + +typedef struct tagChannelBufferRefCount +{ + IRpcChannelBuffer IRpcChannelBuffer_iface; + LONG RefCount; +} CChannelBufferRefCount; + +static CChannelBufferRefCount* impl_from_IRpcChannelBuffer(IRpcChannelBuffer* iface) +{ + return CONTAINING_RECORD(iface, CChannelBufferRefCount, IRpcChannelBuffer_iface); +} + +static HRESULT WINAPI test_chanbuf_refcount_chan_query_interface(IRpcChannelBuffer* pchan, + REFIID iid, + void** ppv) +{ + if (IsEqualGUID(&IID_IRpcChannelBuffer, iid)) + { + *ppv = pchan; + IRpcChannelBuffer_AddRef(pchan); + return S_OK; + } + return E_NOINTERFACE; +} + +static ULONG WINAPI test_chanbuf_refcount_chan_add_ref(IRpcChannelBuffer* pchan) +{ + CChannelBufferRefCount* This = impl_from_IRpcChannelBuffer(pchan); + return InterlockedIncrement(&This->RefCount); +} + +static ULONG WINAPI test_chanbuf_refcount_chan_release(IRpcChannelBuffer* pchan) +{ + CChannelBufferRefCount* This = impl_from_IRpcChannelBuffer(pchan); + return InterlockedDecrement(&This->RefCount); +} + +static HRESULT WINAPI test_chanbuf_refcount_chan_get_buffer(IRpcChannelBuffer* pchan, + RPCOLEMESSAGE* msg, + REFIID iid) +{ + ok(0, "call to GetBuffer not expected\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_chanbuf_refcount_chan_send_receive(IRpcChannelBuffer* pchan, + RPCOLEMESSAGE* pMessage, + ULONG* pStatus) +{ + ok(0, "call to SendReceive not expected\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_chanbuf_refcount_chan_free_buffer(IRpcChannelBuffer* pchan, + RPCOLEMESSAGE* pMessage) +{ + ok(0, "call to FreeBuffer not expected\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI test_chanbuf_refcount_chan_get_dest_ctx(IRpcChannelBuffer* pchan, + DWORD* pdwDestContext, + void** ppvDestContext) +{ + *pdwDestContext = MSHCTX_LOCAL; + *ppvDestContext = NULL; + return S_OK; +} + +static HRESULT WINAPI test_chanbuf_refcount_chan_is_connected(IRpcChannelBuffer* pchan) +{ + ok(0, "call to IsConnected not expected\n"); + return E_NOTIMPL; +} + +static IRpcChannelBufferVtbl test_chanbuf_refcount_test_rpc_chan_vtbl = +{ + test_chanbuf_refcount_chan_query_interface, + test_chanbuf_refcount_chan_add_ref, + test_chanbuf_refcount_chan_release, + test_chanbuf_refcount_chan_get_buffer, + test_chanbuf_refcount_chan_send_receive, + test_chanbuf_refcount_chan_free_buffer, + test_chanbuf_refcount_chan_get_dest_ctx, + test_chanbuf_refcount_chan_is_connected +}; + +static void test_ChannelBufferRefCount(IPSFactoryBuffer *ppsf) +{ + IRpcProxyBuffer* proxy_buffer = NULL; + IUnknown* proxy_if1 = NULL; + CChannelBufferRefCount test_chanbuf = {{&test_chanbuf_refcount_test_rpc_chan_vtbl}, 1}; + + RPC_MESSAGE rpcMessage = {0}; + MIDL_STUB_MESSAGE stubMessage = {0}; + MIDL_STUB_DESC stubDesc = {0}; + ULONG refs; + + HRESULT hr = IPSFactoryBuffer_CreateProxy(ppsf, NULL, &IID_if1, &proxy_buffer, (void**)&proxy_if1); + ok(hr == S_OK, "got %#lx\n", hr); + + ok(test_chanbuf.RefCount == 1, "got %ld\n", test_chanbuf.RefCount); + hr = IRpcProxyBuffer_Connect(proxy_buffer, &test_chanbuf.IRpcChannelBuffer_iface); + ok(hr == S_OK, "got %#lx\n", hr); + /* proxy_buffer should have acquired its own refcount on test_chanbuf */ + ok(test_chanbuf.RefCount == 2, "got %ld\n", test_chanbuf.RefCount); + + /* which therefore survives releasing the initial one */ + refs = IRpcChannelBuffer_Release(&test_chanbuf.IRpcChannelBuffer_iface); + ok(refs == 1, "got %ld\n", refs); + + NdrProxyInitialize(proxy_if1, &rpcMessage, &stubMessage, &stubDesc, 0); + /* stubMessage should add its own refcount on test_chanbuf */ + ok(test_chanbuf.RefCount == 2, "got %ld\n", test_chanbuf.RefCount); + ok(stubMessage.pRpcChannelBuffer != NULL, "NULL pRocChannelBuffer\n"); + + /* stubMessage doesn't add its own refcounts on proxy_if1 or proxy_buffer, + * so it's possible these are freed out from under it. + * E.g. an event sink might unadvise upon receiving the event it was waiting for; + * this unadvise could be reentrant to Invoke because SendReceive pumps STA messages. + * The source would then erase that connection point entry and Release the proxy. */ + IRpcProxyBuffer_Disconnect(proxy_buffer); + ok(test_chanbuf.RefCount == 1, "got %ld\n", test_chanbuf.RefCount); + IRpcProxyBuffer_Release(proxy_buffer); + refs = IUnknown_Release(proxy_if1); + ok(refs == 0, "got %ld\n", refs); + ok(test_chanbuf.RefCount == 1, "got %ld\n", test_chanbuf.RefCount); + + /* NdrProxyFreeBuffer must not dereference the now-freed proxy_if1, + * yet should still free the remaining reference on test_chanbuf */ + NdrProxyFreeBuffer(proxy_if1, &stubMessage); + ok(test_chanbuf.RefCount == 0, "got %ld\n", test_chanbuf.RefCount); + ok(!stubMessage.pRpcChannelBuffer, "dangling pRpcChannelBuffer = %p\n", stubMessage.pRpcChannelBuffer); } START_TEST( cstub ) @@ -1443,6 +1573,7 @@ START_TEST( cstub ) test_delegating_Invoke(ppsf); test_NdrDllRegisterProxy(); test_delegated_methods(); + test_ChannelBufferRefCount(ppsf); OleUninitialize(); } diff --git a/modules/rostests/winetests/rpcrt4/explicit_handle.h b/modules/rostests/winetests/rpcrt4/explicit_handle.h new file mode 100644 index 00000000000..9b1dd7893e6 --- /dev/null +++ b/modules/rostests/winetests/rpcrt4/explicit_handle.h @@ -0,0 +1,2 @@ + +#include "explicit_handle_s.h" diff --git a/modules/rostests/winetests/rpcrt4/explicit_handle.idl b/modules/rostests/winetests/rpcrt4/explicit_handle.idl new file mode 100644 index 00000000000..ab41f771fe7 --- /dev/null +++ b/modules/rostests/winetests/rpcrt4/explicit_handle.idl @@ -0,0 +1,32 @@ +/* + * Copyright 2023 Haoyang Chen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#pragma makedep client +#pragma makedep server + +[ + uuid(00000000-4114-0704-2301-000000000002), + explicit_handle +] + +interface RPCExplicitHandle +{ + int add([in] handle_t hBinding, [in] int a, [in] int b); + int getNum([in] int a, [in] handle_t hBinding); + void Shutdown([in] handle_t hBinding); +} diff --git a/modules/rostests/winetests/rpcrt4/generated.c b/modules/rostests/winetests/rpcrt4/generated.c index 72672cd3a91..57e2a387cf1 100644 --- a/modules/rostests/winetests/rpcrt4/generated.c +++ b/modules/rostests/winetests/rpcrt4/generated.c @@ -31,7 +31,7 @@ #if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus) # define _TYPE_ALIGNMENT(type) __alignof(type) -#elif defined(__GNUC__) +#elif defined(__GNUC__) || defined(__clang__) # define _TYPE_ALIGNMENT(type) __alignof__(type) #else /* @@ -53,23 +53,23 @@ * Test helper macros */ -#define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size); +#define TEST_TYPE_SIZE(type, size) C_ASSERT(sizeof(type) == size); #ifdef TYPE_ALIGNMENT -# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align); +# define TEST_TYPE_ALIGN(type, align) C_ASSERT(TYPE_ALIGNMENT(type) == align); #else # define TEST_TYPE_ALIGN(type, align) #endif #ifdef _TYPE_ALIGNMENT -# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align); -# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align); +# define TEST_TARGET_ALIGN(type, align) C_ASSERT(_TYPE_ALIGNMENT(*(type)0) == align); +# define TEST_FIELD_ALIGN(type, field, align) C_ASSERT(_TYPE_ALIGNMENT(((type*)0)->field) == align); #else # define TEST_TARGET_ALIGN(type, align) # define TEST_FIELD_ALIGN(type, field, align) #endif -#define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset); +#define TEST_FIELD_OFFSET(type, field, offset) C_ASSERT(FIELD_OFFSET(type, field) == offset); #define TEST_TARGET_SIZE(type, size) TEST_TYPE_SIZE(*(type)0, size) #define TEST_FIELD_SIZE(type, field, size) TEST_TYPE_SIZE((((type*)0)->field), size) @@ -91,6 +91,7 @@ static void test_pack_RPC_STATUS(void) /* RPC_STATUS */ TEST_TYPE_SIZE (RPC_STATUS, 4) TEST_TYPE_ALIGN (RPC_STATUS, 4) + TEST_TYPE_SIGNED (RPC_STATUS) } static void test_pack_PRPC_POLICY(void) @@ -593,6 +594,15 @@ static void test_pack_MIDL_STUB_MESSAGE(void) TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, Memory, 8) TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, Memory, 8) TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, Memory, 48) + TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, IsClient, 1) + TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, IsClient, 1) + TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, IsClient, 56) + TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, Pad, 1) + TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, Pad, 1) + TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, Pad, 57) + TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, uFlags2, 2) + TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, uFlags2, 2) + TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, uFlags2, 58) TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, ReuseBuffer, 4) TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, ReuseBuffer, 4) TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, ReuseBuffer, 60) @@ -614,6 +624,9 @@ static void test_pack_MIDL_STUB_MESSAGE(void) TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, uFlags, 1) TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, uFlags, 1) TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, uFlags, 97) + TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, UniquePtrCount, 2) + TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, UniquePtrCount, 2) + TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, UniquePtrCount, 98) TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, MaxCount, 8) TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, MaxCount, 8) TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, MaxCount, 104) @@ -673,9 +686,9 @@ static void test_pack_MIDL_SYNTAX_INFO(void) TEST_FIELD_SIZE (MIDL_SYNTAX_INFO, aUserMarshalQuadruple, 8) TEST_FIELD_ALIGN (MIDL_SYNTAX_INFO, aUserMarshalQuadruple, 8) TEST_FIELD_OFFSET(MIDL_SYNTAX_INFO, aUserMarshalQuadruple, 56) - TEST_FIELD_SIZE (MIDL_SYNTAX_INFO, pReserved1, 8) - TEST_FIELD_ALIGN (MIDL_SYNTAX_INFO, pReserved1, 8) - TEST_FIELD_OFFSET(MIDL_SYNTAX_INFO, pReserved1, 64) + TEST_FIELD_SIZE (MIDL_SYNTAX_INFO, pMethodProperties, 8) + TEST_FIELD_ALIGN (MIDL_SYNTAX_INFO, pMethodProperties, 8) + TEST_FIELD_OFFSET(MIDL_SYNTAX_INFO, pMethodProperties, 64) TEST_FIELD_SIZE (MIDL_SYNTAX_INFO, pReserved2, 8) TEST_FIELD_ALIGN (MIDL_SYNTAX_INFO, pReserved2, 8) TEST_FIELD_OFFSET(MIDL_SYNTAX_INFO, pReserved2, 72) @@ -940,6 +953,7 @@ static void test_pack_RPC_STATUS(void) /* RPC_STATUS */ TEST_TYPE_SIZE (RPC_STATUS, 4) TEST_TYPE_ALIGN (RPC_STATUS, 4) + TEST_TYPE_SIGNED (RPC_STATUS) } static void test_pack_PRPC_POLICY(void) @@ -1442,6 +1456,15 @@ static void test_pack_MIDL_STUB_MESSAGE(void) TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, Memory, 4) TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, Memory, 4) TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, Memory, 28) + TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, IsClient, 1) + TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, IsClient, 1) + TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, IsClient, 32) + TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, Pad, 1) + TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, Pad, 1) + TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, Pad, 33) + TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, uFlags2, 2) + TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, uFlags2, 2) + TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, uFlags2, 34) TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, ReuseBuffer, 4) TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, ReuseBuffer, 4) TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, ReuseBuffer, 36) @@ -1463,6 +1486,9 @@ static void test_pack_MIDL_STUB_MESSAGE(void) TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, uFlags, 1) TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, uFlags, 1) TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, uFlags, 57) + TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, UniquePtrCount, 2) + TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, UniquePtrCount, 2) + TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, UniquePtrCount, 58) TEST_FIELD_SIZE (MIDL_STUB_MESSAGE, MaxCount, 4) TEST_FIELD_ALIGN (MIDL_STUB_MESSAGE, MaxCount, 4) TEST_FIELD_OFFSET(MIDL_STUB_MESSAGE, MaxCount, 60) @@ -1522,9 +1548,9 @@ static void test_pack_MIDL_SYNTAX_INFO(void) TEST_FIELD_SIZE (MIDL_SYNTAX_INFO, aUserMarshalQuadruple, 4) TEST_FIELD_ALIGN (MIDL_SYNTAX_INFO, aUserMarshalQuadruple, 4) TEST_FIELD_OFFSET(MIDL_SYNTAX_INFO, aUserMarshalQuadruple, 36) - TEST_FIELD_SIZE (MIDL_SYNTAX_INFO, pReserved1, 4) - TEST_FIELD_ALIGN (MIDL_SYNTAX_INFO, pReserved1, 4) - TEST_FIELD_OFFSET(MIDL_SYNTAX_INFO, pReserved1, 40) + TEST_FIELD_SIZE (MIDL_SYNTAX_INFO, pMethodProperties, 4) + TEST_FIELD_ALIGN (MIDL_SYNTAX_INFO, pMethodProperties, 4) + TEST_FIELD_OFFSET(MIDL_SYNTAX_INFO, pMethodProperties, 40) TEST_FIELD_SIZE (MIDL_SYNTAX_INFO, pReserved2, 4) TEST_FIELD_ALIGN (MIDL_SYNTAX_INFO, pReserved2, 4) TEST_FIELD_OFFSET(MIDL_SYNTAX_INFO, pReserved2, 44) diff --git a/modules/rostests/winetests/rpcrt4/ndr_marshall.c b/modules/rostests/winetests/rpcrt4/ndr_marshall.c index b206c37b233..0281dd241f6 100644 --- a/modules/rostests/winetests/rpcrt4/ndr_marshall.c +++ b/modules/rostests/winetests/rpcrt4/ndr_marshall.c @@ -34,7 +34,6 @@ #include "midles.h" #include "ndrtypes.h" -#include "wine/heap.h" #include "wine/test.h" static int my_alloc_called; @@ -42,13 +41,13 @@ static int my_free_called; static void * CALLBACK my_alloc(SIZE_T size) { my_alloc_called++; - return NdrOleAllocate(size); + return malloc(size); } static void CALLBACK my_free(void *ptr) { my_free_called++; - NdrOleFree(ptr); + free(ptr); } static const MIDL_STUB_DESC Object_StubDesc = @@ -126,14 +125,14 @@ static void determine_pointer_marshalling_style(void) 0); StubMsg.BufferLength = 8; - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); NdrPointerMarshall(&StubMsg, (unsigned char*)&ch, fmtstr_up_char); ok(StubMsg.Buffer == StubMsg.BufferStart + 5, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart); use_pointer_ids = (*(unsigned int *)StubMsg.BufferStart != (UINT_PTR)&ch); trace("Pointer marshalling using %s\n", use_pointer_ids ? "pointer ids" : "pointer value"); - HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart); + NdrOleFree(StubMsg.BufferStart); } static void test_ndr_simple_type(void) @@ -153,23 +152,24 @@ static void test_ndr_simple_type(void) 0); StubMsg.BufferLength = 16; - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); + StubMsg.BufferEnd = StubMsg.Buffer + StubMsg.BufferLength; l = 0xcafebabe; NdrSimpleTypeMarshall(&StubMsg, (unsigned char*)&l, FC_LONG); ok(StubMsg.Buffer == StubMsg.BufferStart + 4, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart); - ok(*(LONG*)StubMsg.BufferStart == l, "%d\n", *(LONG*)StubMsg.BufferStart); + ok(*(LONG*)StubMsg.BufferStart == l, "%ld\n", *(LONG*)StubMsg.BufferStart); StubMsg.Buffer = StubMsg.BufferStart + 1; NdrSimpleTypeMarshall(&StubMsg, (unsigned char*)&l, FC_LONG); ok(StubMsg.Buffer == StubMsg.BufferStart + 8, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart); - ok(*(LONG*)(StubMsg.BufferStart + 4) == l, "%d\n", *(LONG*)StubMsg.BufferStart); + ok(*(LONG*)(StubMsg.BufferStart + 4) == l, "%ld\n", *(LONG*)StubMsg.BufferStart); StubMsg.Buffer = StubMsg.BufferStart + 1; NdrSimpleTypeUnmarshall(&StubMsg, (unsigned char*)&l2, FC_LONG); ok(StubMsg.Buffer == StubMsg.BufferStart + 8, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart); - ok(l2 == l, "%d\n", l2); + ok(l2 == l, "%ld\n", l2); - HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart); + NdrOleFree(StubMsg.BufferStart); } static void test_pointer_marshal(const unsigned char *formattypes, @@ -203,10 +203,10 @@ static void test_pointer_marshal(const unsigned char *formattypes, NdrPointerBufferSize( &StubMsg, memsrc, formattypes ); - ok(StubMsg.BufferLength >= wiredatalen, "%s: length %d\n", msgpfx, StubMsg.BufferLength); + ok(StubMsg.BufferLength >= wiredatalen, "%s: length %ld\n", msgpfx, StubMsg.BufferLength); /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; memset(StubMsg.BufferStart, 0x0, StubMsg.BufferLength); /* This is a hack to clear the padding between the ptr and longlong/double */ @@ -220,7 +220,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, } else { - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); ok(!memcmp(StubMsg.BufferStart, wiredata, wiredatalen), "%s: incorrectly marshaled\n", msgpfx); } @@ -228,32 +228,32 @@ static void test_pointer_marshal(const unsigned char *formattypes, StubMsg.MemorySize = 0; size = NdrPointerMemorySize( &StubMsg, formattypes ); - ok(size == StubMsg.MemorySize, "%s: mem size %u size %u\n", msgpfx, StubMsg.MemorySize, size); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(size == StubMsg.MemorySize, "%s: mem size %lu size %lu\n", msgpfx, StubMsg.MemorySize, size); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); if (formattypes[1] & FC_POINTER_DEREF) - ok(size == srcsize + sizeof(void *), "%s: mem size %u\n", msgpfx, size); + ok(size == srcsize + sizeof(void *), "%s: mem size %lu\n", msgpfx, size); else - ok(size == srcsize, "%s: mem size %u\n", msgpfx, size); + ok(size == srcsize, "%s: mem size %lu\n", msgpfx, size); StubMsg.Buffer = StubMsg.BufferStart; StubMsg.MemorySize = 16; size = NdrPointerMemorySize( &StubMsg, formattypes ); - ok(size == StubMsg.MemorySize, "%s: mem size %u size %u\n", msgpfx, StubMsg.MemorySize, size); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(size == StubMsg.MemorySize, "%s: mem size %lu size %lu\n", msgpfx, StubMsg.MemorySize, size); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); if (formattypes[1] & FC_POINTER_DEREF) - ok(size == srcsize + sizeof(void *) + 16, "%s: mem size %u\n", msgpfx, size); + ok(size == srcsize + sizeof(void *) + 16, "%s: mem size %lu\n", msgpfx, size); else - ok(size == srcsize + 16, "%s: mem size %u\n", msgpfx, size); + ok(size == srcsize + 16, "%s: mem size %lu\n", msgpfx, size); StubMsg.Buffer = StubMsg.BufferStart; StubMsg.MemorySize = 1; size = NdrPointerMemorySize( &StubMsg, formattypes ); - ok(size == StubMsg.MemorySize, "%s: mem size %u size %u\n", msgpfx, StubMsg.MemorySize, size); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(size == StubMsg.MemorySize, "%s: mem size %lu size %lu\n", msgpfx, StubMsg.MemorySize, size); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); if (formattypes[1] & FC_POINTER_DEREF) - ok(size == srcsize + sizeof(void *) + (srcsize == 8 ? 8 : sizeof(void *)), "%s: mem size %u\n", msgpfx, size); + ok(size == srcsize + sizeof(void *) + (srcsize == 8 ? 8 : sizeof(void *)), "%s: mem size %lu\n", msgpfx, size); else - ok(size == srcsize + (srcsize == 8 ? 8 : sizeof(void *)), "%s: mem size %u\n", msgpfx, size); + ok(size == srcsize + (srcsize == 8 ? 8 : sizeof(void *)), "%s: mem size %lu\n", msgpfx, size); size = srcsize; if (formattypes[1] & FC_POINTER_DEREF) size += 4; @@ -270,10 +270,10 @@ static void test_pointer_marshal(const unsigned char *formattypes, ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); ok(mem == mem_orig, "%s: mem has changed %p %p\n", msgpfx, mem, mem_orig); ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %ld\n", msgpfx, StubMsg.MemorySize); ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); - /* On Windows 7+ unmarshalling may involve calls to NdrFree, for unclear reasons. */ + /* On Windows 7+ unmarshalling may involve calls to StubMsg.pfnFree, for unclear reasons. */ my_free_called = 0; NdrPointerFree(&StubMsg, mem, formattypes); @@ -281,7 +281,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, { /* In this case the top-level pointer is not freed. */ ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called); - HeapFree(GetProcessHeap(), 0, mem); + free(mem); } else ok(my_free_called == 1 + num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called); @@ -289,7 +289,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, /* reset the buffer and call with must alloc */ my_alloc_called = my_free_called = 0; StubMsg.Buffer = StubMsg.BufferStart; - mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + mem_orig = mem = calloc(1, size); if (formattypes[1] & FC_POINTER_DEREF) *(void**)mem = NULL; ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 1 ); @@ -297,8 +297,8 @@ static void test_pointer_marshal(const unsigned char *formattypes, /* doesn't allocate mem in this case */ ok(mem == mem_orig, "%s: mem has changed %p %p\n", msgpfx, mem, mem_orig); ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %ld\n", msgpfx, StubMsg.MemorySize); ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); ok(!my_free_called, "%s: my_free got called %d times\n", msgpfx, my_free_called); @@ -307,7 +307,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, { /* In this case the top-level pointer is not freed. */ ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called); - HeapFree(GetProcessHeap(), 0, mem); + free(mem); } else ok(my_free_called == 1 + num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called); @@ -322,8 +322,8 @@ static void test_pointer_marshal(const unsigned char *formattypes, ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); ok(mem != StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem points to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); ok(!cmp(mem, memsrc, size), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %ld\n", msgpfx, StubMsg.MemorySize); ok(my_alloc_called == num_additional_allocs + 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); my_alloc_called = 0; NdrPointerFree(&StubMsg, mem, formattypes); @@ -341,8 +341,8 @@ static void test_pointer_marshal(const unsigned char *formattypes, else ok(mem == StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem doesn't point to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); ok(!cmp(mem, memsrc, size), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %ld\n", msgpfx, StubMsg.MemorySize); if (formattypes[2] != FC_ENUM16) { ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); @@ -363,8 +363,8 @@ static void test_pointer_marshal(const unsigned char *formattypes, ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); ok(!!mem, "%s: mem was not allocated\n", msgpfx); ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %ld\n", msgpfx, StubMsg.MemorySize); if (formattypes[2] == FC_ENUM16) ok(my_alloc_called == 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); else @@ -382,7 +382,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, * stack memory. In practice it always *is* stack memory if ON_STACK is * set, so this leak isn't a concern. */ ok(my_free_called == 0, "%s: my_free got called %d times\n", msgpfx, my_free_called); - HeapFree(GetProcessHeap(), 0, mem); + free(mem); } else ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called); @@ -395,8 +395,8 @@ static void test_pointer_marshal(const unsigned char *formattypes, ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); ok(!!mem, "%s: mem was not allocated\n", msgpfx); ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %ld\n", msgpfx, StubMsg.MemorySize); if (formattypes[2] == FC_ENUM16) ok(my_alloc_called == 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); else @@ -409,7 +409,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, else if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF)) { ok(my_free_called == 0, "%s: my_free got called %d times\n", msgpfx, my_free_called); - HeapFree(GetProcessHeap(), 0, mem); + free(mem); } else ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called); @@ -420,7 +420,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, my_alloc_called = my_free_called = 0; StubMsg.Buffer = StubMsg.BufferStart; - mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + mem_orig = mem = calloc(1, size); if (formattypes[1] & FC_POINTER_DEREF) *(void**)mem = NULL; ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 ); @@ -430,11 +430,11 @@ static void test_pointer_marshal(const unsigned char *formattypes, else { ok(mem != mem_orig, "%s: mem has not changed\n", msgpfx); - HeapFree(GetProcessHeap(), 0, mem_orig); + free(mem_orig); } ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %ld\n", msgpfx, StubMsg.MemorySize); if (formattypes[2] == FC_ENUM16) ok(my_alloc_called == 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); else if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF)) @@ -449,7 +449,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, else if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF)) { ok(my_free_called == 0, "%s: my_free got called %d times\n", msgpfx, my_free_called); - HeapFree(GetProcessHeap(), 0, mem); + free(mem); } else ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called); @@ -457,7 +457,7 @@ static void test_pointer_marshal(const unsigned char *formattypes, /* reset the buffer and call with must alloc */ my_alloc_called = my_free_called = 0; StubMsg.Buffer = StubMsg.BufferStart; - mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + mem_orig = mem = calloc(1, size); if (formattypes[1] & FC_POINTER_DEREF) *(void**)mem = NULL; ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 1 ); @@ -467,11 +467,11 @@ static void test_pointer_marshal(const unsigned char *formattypes, else { ok(mem != mem_orig, "%s: mem has not changed\n", msgpfx); - HeapFree(GetProcessHeap(), 0, mem_orig); + free(mem_orig); } ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %ld\n", msgpfx, StubMsg.MemorySize); if (formattypes[2] == FC_ENUM16) ok(my_alloc_called == 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); else if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF)) @@ -486,12 +486,12 @@ static void test_pointer_marshal(const unsigned char *formattypes, else if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF)) { ok(my_free_called == 0, "%s: my_free got called %d times\n", msgpfx, my_free_called); - HeapFree(GetProcessHeap(), 0, mem); + free(mem); } else ok(my_free_called == num_additional_allocs, "%s: my_free got called %d times\n", msgpfx, my_free_called); - HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart); + NdrOleFree(StubMsg.BufferStart); } static int deref_cmp(const void *s1, const void *s2, size_t num) @@ -753,16 +753,16 @@ static void test_nontrivial_pointer_types(void) &fmtstr_ref_unique_out[4] ); /* Windows overestimates the buffer size */ - ok(StubMsg.BufferLength >= 5, "length %d\n", StubMsg.BufferLength); + ok(StubMsg.BufferLength >= 5, "length %ld\n", StubMsg.BufferLength); /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; ptr = NdrPointerMarshall( &StubMsg, (unsigned char *)p1, &fmtstr_ref_unique_out[4] ); ok(ptr == NULL, "ret %p\n", ptr); size = StubMsg.Buffer - StubMsg.BufferStart; - ok(size == 5, "Buffer %p Start %p len %d\n", StubMsg.Buffer, StubMsg.BufferStart, size); + ok(size == 5, "Buffer %p Start %p len %ld\n", StubMsg.Buffer, StubMsg.BufferStart, size); ok(*(unsigned int *)StubMsg.BufferStart != 0, "pointer ID marshalled incorrectly\n"); ok(*(unsigned char *)(StubMsg.BufferStart + 4) == 0x22, "char data marshalled incorrectly: 0x%x\n", *(unsigned char *)(StubMsg.BufferStart + 4)); @@ -774,7 +774,7 @@ static void test_nontrivial_pointer_types(void) /* Client */ my_alloc_called = 0; StubMsg.Buffer = StubMsg.BufferStart; - mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(void *)); + mem = mem_orig = malloc(sizeof(void *)); *(void **)mem = NULL; NdrPointerUnmarshall( &StubMsg, &mem, &fmtstr_ref_unique_out[4], 0); ok(mem == mem_orig, "mem alloced\n"); @@ -863,8 +863,8 @@ static void test_nontrivial_pointer_types(void) ok(my_free_called == 1, "free called %d\n", my_free_called); my_free(mem); - HeapFree(GetProcessHeap(), 0, mem_orig); - HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer); + free(mem_orig); + NdrOleFree(StubMsg.RpcMsg->Buffer); } static void test_simple_struct_marshal(const unsigned char *formattypes, @@ -893,32 +893,32 @@ static void test_simple_struct_marshal(const unsigned char *formattypes, StubMsg.BufferLength = 0; NdrSimpleStructBufferSize( &StubMsg, memsrc, formattypes ); - ok(StubMsg.BufferLength >= wiredatalen, "%s: length %d\n", msgpfx, StubMsg.BufferLength); - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + ok(StubMsg.BufferLength >= wiredatalen, "%s: length %ld\n", msgpfx, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; ptr = NdrSimpleStructMarshall( &StubMsg, memsrc, formattypes ); ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart); - ok(!memcmp(StubMsg.BufferStart, wiredata, wiredatalen), "%s: incorrectly marshaled %08x %08x %08x\n", msgpfx, *(DWORD*)StubMsg.BufferStart,*((DWORD*)StubMsg.BufferStart+1),*((DWORD*)StubMsg.BufferStart+2)); + ok(!memcmp(StubMsg.BufferStart, wiredata, wiredatalen), "%s: incorrectly marshaled %08lx %08lx %08lx\n", msgpfx, *(DWORD*)StubMsg.BufferStart,*((DWORD*)StubMsg.BufferStart+1),*((DWORD*)StubMsg.BufferStart+2)); StubMsg.Buffer = StubMsg.BufferStart; StubMsg.MemorySize = 0; size = NdrSimpleStructMemorySize( &StubMsg, formattypes ); ok(size == StubMsg.MemorySize, "%s: size != MemorySize\n", msgpfx); - ok(size == srcsize, "%s: mem size %u\n", msgpfx, size); + ok(size == srcsize, "%s: mem size %lu\n", msgpfx, size); ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart); StubMsg.Buffer = StubMsg.BufferStart; size = NdrSimpleStructMemorySize( &StubMsg, formattypes ); ok(size == StubMsg.MemorySize, "%s: size != MemorySize\n", msgpfx); - ok(StubMsg.MemorySize == ((srcsize + 3) & ~3) + srcsize, "%s: mem size %u\n", msgpfx, size); + ok(StubMsg.MemorySize == ((srcsize + 3) & ~3) + srcsize, "%s: mem size %lu\n", msgpfx, size); ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart); size = srcsize; /*** Unmarshalling first with must_alloc false ***/ StubMsg.Buffer = StubMsg.BufferStart; StubMsg.MemorySize = 0; - mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, srcsize); + mem_orig = mem = calloc(1, srcsize); ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 0 ); ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart); @@ -1031,8 +1031,8 @@ static void test_simple_struct_marshal(const unsigned char *formattypes, ok(my_free_called == num_additional_allocs, "free called %d\n", my_free_called); my_free(mem); - HeapFree(GetProcessHeap(), 0, mem_orig); - HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart); + free(mem_orig); + NdrOleFree(StubMsg.BufferStart); } typedef struct @@ -1237,7 +1237,7 @@ static void test_struct_align(void) 0x5b, /* FC_END */ }; - memsrc_orig = heap_alloc_zero(sizeof(struct aligned) + 8); + memsrc_orig = calloc(1, sizeof(struct aligned) + 8); /* intentionally mis-align memsrc */ memsrc = (struct aligned *)((((ULONG_PTR)memsrc_orig + 7) & ~7) + 4); @@ -1251,7 +1251,7 @@ static void test_struct_align(void) StubMsg.BufferLength = 0; NdrComplexStructBufferSize(&StubMsg, (unsigned char *)memsrc, fmtstr); - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = heap_alloc(StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; ptr = NdrComplexStructMarshall(&StubMsg, (unsigned char *)memsrc, fmtstr); @@ -1266,8 +1266,8 @@ static void test_struct_align(void) ok(!memcmp(mem, memsrc, sizeof(*memsrc)), "struct wasn't unmarshalled correctly\n"); StubMsg.pfnFree(mem); - heap_free(StubMsg.RpcMsg->Buffer); - heap_free(memsrc_orig); + NdrOleFree(StubMsg.RpcMsg->Buffer); + free(memsrc_orig); } struct testiface @@ -1359,7 +1359,7 @@ static void test_iface_ptr(void) StubMsg.BufferLength = 0; NdrInterfacePointerBufferSize(&StubMsg, (unsigned char *)&client_obj.IPersist_iface, fmtstr_ip); - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; /* server -> client */ @@ -1370,12 +1370,12 @@ static void test_iface_ptr(void) IPersist_AddRef(&server_obj.IPersist_iface); ptr = NdrInterfacePointerMarshall(&StubMsg, (unsigned char *)&server_obj.IPersist_iface, fmtstr_ip); ok(!ptr, "ret %p\n", ptr); - ok(server_obj.ref > 2, "got %d references\n", server_obj.ref); + ok(server_obj.ref > 2, "got %ld references\n", server_obj.ref); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); NdrInterfacePointerFree(&StubMsg, (unsigned char *)&server_obj.IPersist_iface, fmtstr_ip); - ok(server_obj.ref > 1, "got %d references\n", server_obj.ref); + ok(server_obj.ref > 1, "got %ld references\n", server_obj.ref); StubMsg.IsClient = 1; my_alloc_called = my_free_called = 0; @@ -1386,15 +1386,15 @@ static void test_iface_ptr(void) ok(!!proxy, "mem not alloced\n"); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); - ok(server_obj.ref > 1, "got %d references\n", server_obj.ref); + ok(server_obj.ref > 1, "got %ld references\n", server_obj.ref); hr = IPersist_GetClassID(proxy, &clsid); - ok(hr == S_OK, "got hr %#x\n", hr); + ok(hr == S_OK, "got hr %#lx\n", hr); ok(IsEqualGUID(&clsid, &IID_IPersist), "wrong clsid %s\n", wine_dbgstr_guid(&clsid)); ref = IPersist_Release(proxy); - ok(ref == 1, "got %d references\n", ref); - ok(server_obj.ref == 1, "got %d references\n", server_obj.ref); + ok(ref == 1, "got %ld references\n", ref); + ok(server_obj.ref == 1, "got %ld references\n", server_obj.ref); /* An existing interface pointer is released; this is necessary so that an * [in, out] pointer which changes does not leak references. */ @@ -1405,12 +1405,12 @@ static void test_iface_ptr(void) IPersist_AddRef(&server_obj.IPersist_iface); ptr = NdrInterfacePointerMarshall(&StubMsg, (unsigned char *)&server_obj.IPersist_iface, fmtstr_ip); ok(!ptr, "ret %p\n", ptr); - ok(server_obj.ref > 2, "got %d references\n", server_obj.ref); + ok(server_obj.ref > 2, "got %ld references\n", server_obj.ref); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); NdrInterfacePointerFree(&StubMsg, (unsigned char *)&server_obj.IPersist_iface, fmtstr_ip); - ok(server_obj.ref > 1, "got %d references\n", server_obj.ref); + ok(server_obj.ref > 1, "got %ld references\n", server_obj.ref); StubMsg.IsClient = 1; my_alloc_called = my_free_called = 0; @@ -1422,16 +1422,16 @@ static void test_iface_ptr(void) ok(!!proxy && proxy != &client_obj.IPersist_iface, "mem not alloced\n"); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); - ok(server_obj.ref > 1, "got %d references\n", server_obj.ref); - ok(client_obj.ref == 1, "got %d references\n", client_obj.ref); + ok(server_obj.ref > 1, "got %ld references\n", server_obj.ref); + ok(client_obj.ref == 1, "got %ld references\n", client_obj.ref); hr = IPersist_GetClassID(proxy, &clsid); - ok(hr == S_OK, "got hr %#x\n", hr); + ok(hr == S_OK, "got hr %#lx\n", hr); ok(IsEqualGUID(&clsid, &IID_IPersist), "wrong clsid %s\n", wine_dbgstr_guid(&clsid)); ref = IPersist_Release(proxy); - ok(ref == 1, "got %d references\n", ref); - ok(server_obj.ref == 1, "got %d references\n", server_obj.ref); + ok(ref == 1, "got %ld references\n", ref); + ok(server_obj.ref == 1, "got %ld references\n", server_obj.ref); /* client -> server */ @@ -1441,7 +1441,7 @@ static void test_iface_ptr(void) IPersist_AddRef(&client_obj.IPersist_iface); ptr = NdrInterfacePointerMarshall(&StubMsg, (unsigned char *)&client_obj.IPersist_iface, fmtstr_ip); ok(!ptr, "ret %p\n", ptr); - ok(client_obj.ref > 2, "got %d references\n", client_obj.ref); + ok(client_obj.ref > 2, "got %ld references\n", client_obj.ref); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); @@ -1454,18 +1454,18 @@ static void test_iface_ptr(void) ok(!!proxy, "mem not alloced\n"); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); - ok(client_obj.ref > 2, "got %d references\n", client_obj.ref); + ok(client_obj.ref > 2, "got %ld references\n", client_obj.ref); hr = IPersist_GetClassID(proxy, &clsid); - ok(hr == S_OK, "got hr %#x\n", hr); + ok(hr == S_OK, "got hr %#lx\n", hr); ok(IsEqualGUID(&clsid, &IID_IPersist), "wrong clsid %s\n", wine_dbgstr_guid(&clsid)); ref = IPersist_Release(proxy); - ok(client_obj.ref > 1, "got %d references\n", client_obj.ref); - ok(ref == client_obj.ref, "expected %d references, got %d\n", client_obj.ref, ref); + ok(client_obj.ref > 1, "got %ld references\n", client_obj.ref); + ok(ref == client_obj.ref, "expected %ld references, got %ld\n", client_obj.ref, ref); NdrInterfacePointerFree(&StubMsg, (unsigned char *)proxy, fmtstr_ip); - ok(client_obj.ref == 1, "got %d references\n", client_obj.ref); + ok(client_obj.ref == 1, "got %ld references\n", client_obj.ref); /* same, but free the interface after calling NdrInterfacePointerFree */ @@ -1475,7 +1475,7 @@ static void test_iface_ptr(void) IPersist_AddRef(&client_obj.IPersist_iface); ptr = NdrInterfacePointerMarshall(&StubMsg, (unsigned char *)&client_obj.IPersist_iface, fmtstr_ip); ok(!ptr, "ret %p\n", ptr); - ok(client_obj.ref > 2, "got %d references\n", client_obj.ref); + ok(client_obj.ref > 2, "got %ld references\n", client_obj.ref); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); @@ -1488,18 +1488,18 @@ static void test_iface_ptr(void) ok(!!proxy, "mem not alloced\n"); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); - ok(client_obj.ref > 2, "got %d references\n", client_obj.ref); + ok(client_obj.ref > 2, "got %ld references\n", client_obj.ref); NdrInterfacePointerFree(&StubMsg, (unsigned char *)proxy, fmtstr_ip); - ok(client_obj.ref > 1, "got %d references\n", client_obj.ref); + ok(client_obj.ref > 1, "got %ld references\n", client_obj.ref); hr = IPersist_GetClassID(proxy, &clsid); - ok(hr == S_OK, "got hr %#x\n", hr); + ok(hr == S_OK, "got hr %#lx\n", hr); ok(IsEqualGUID(&clsid, &IID_IPersist), "wrong clsid %s\n", wine_dbgstr_guid(&clsid)); ref = IPersist_Release(proxy); - ok(ref == 1, "got %d references\n", ref); - ok(client_obj.ref == 1, "got %d references\n", client_obj.ref); + ok(ref == 1, "got %ld references\n", ref); + ok(client_obj.ref == 1, "got %ld references\n", client_obj.ref); /* An existing interface pointer is *not* released (in fact, it is ignored * and may be invalid). In practice it will always be NULL anyway. */ @@ -1510,7 +1510,7 @@ static void test_iface_ptr(void) IPersist_AddRef(&client_obj.IPersist_iface); ptr = NdrInterfacePointerMarshall(&StubMsg, (unsigned char *)&client_obj.IPersist_iface, fmtstr_ip); ok(!ptr, "ret %p\n", ptr); - ok(client_obj.ref > 2, "got %d references\n", client_obj.ref); + ok(client_obj.ref > 2, "got %ld references\n", client_obj.ref); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); @@ -1524,22 +1524,22 @@ static void test_iface_ptr(void) ok(!!proxy && proxy != &server_obj.IPersist_iface, "mem not alloced\n"); ok(!my_alloc_called, "alloc called %d\n", my_alloc_called); ok(!my_free_called, "free called %d\n", my_free_called); - ok(client_obj.ref > 2, "got %d references\n", client_obj.ref); - ok(server_obj.ref == 2, "got %d references\n", server_obj.ref); + ok(client_obj.ref > 2, "got %ld references\n", client_obj.ref); + ok(server_obj.ref == 2, "got %ld references\n", server_obj.ref); IPersist_Release(&server_obj.IPersist_iface); hr = IPersist_GetClassID(proxy, &clsid); - ok(hr == S_OK, "got hr %#x\n", hr); + ok(hr == S_OK, "got hr %#lx\n", hr); ok(IsEqualGUID(&clsid, &IID_IPersist), "wrong clsid %s\n", wine_dbgstr_guid(&clsid)); ref = IPersist_Release(proxy); - ok(client_obj.ref > 1, "got %d references\n", client_obj.ref); - ok(ref == client_obj.ref, "expected %d references, got %d\n", client_obj.ref, ref); + ok(client_obj.ref > 1, "got %ld references\n", client_obj.ref); + ok(ref == client_obj.ref, "expected %ld references, got %ld\n", client_obj.ref, ref); NdrInterfacePointerFree(&StubMsg, (unsigned char *)proxy, fmtstr_ip); - ok(client_obj.ref == 1, "got %d references\n", client_obj.ref); + ok(client_obj.ref == 1, "got %ld references\n", client_obj.ref); - HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart); + NdrOleFree(StubMsg.BufferStart); CoUninitialize(); } @@ -1557,23 +1557,23 @@ static void test_fullpointer_xlat(void) ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 1, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x1, "RefId should be 0x1 instead of 0x%x\n", RefId); + ok(RefId == 0x1, "RefId should be 0x1 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 0, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x1, "RefId should be 0x1 instead of 0x%x\n", RefId); + ok(RefId == 0x1, "RefId should be 0x1 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebabe, 0, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x2, "RefId should be 0x2 instead of 0x%x\n", RefId); + ok(RefId == 0x2, "RefId should be 0x2 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 0, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId); + ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, NULL, 0, &RefId); ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret); - ok(RefId == 0, "RefId should be 0 instead of 0x%x\n", RefId); + ok(RefId == 0, "RefId should be 0 instead of 0x%lx\n", RefId); /* "unmarshaling" phase */ @@ -1618,23 +1618,23 @@ static void test_fullpointer_xlat(void) ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 1, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId); + ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 1, &RefId); ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret); - ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId); + ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 0, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId); + ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebabe, 0, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x2, "RefId should be 0x2 instead of 0x%x\n", RefId); + ok(RefId == 0x2, "RefId should be 0x2 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 0, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId); + ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%lx\n", RefId); /* "freeing" phase */ @@ -1643,11 +1643,11 @@ static void test_fullpointer_xlat(void) ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 0x20, &RefId); ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret); - ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId); + ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 1, &RefId); ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret); - ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId); + ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%lx\n", RefId); ret = NdrFullPointerFree(pXlatTables, (void *)0xcafebabe); ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret); @@ -1657,15 +1657,15 @@ static void test_fullpointer_xlat(void) ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 0x20, &RefId); ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret); - ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId); + ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 1, &RefId); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); - ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId); + ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%lx\n", RefId); ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 1, &RefId); ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret); - ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId); + ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%lx\n", RefId); ret = NdrFullPointerFree(pXlatTables, (void *)0xdeadbeef); ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret); @@ -1682,8 +1682,8 @@ static void test_common_stub_data( const char *prefix, const MIDL_STUB_MESSAGE * #define TEST_ZERO(field, fmt) ok(stubMsg->field == 0, "%s: " #field " should have been set to zero instead of " fmt "\n", prefix, stubMsg->field) #define TEST_POINTER_UNSET(field) ok(stubMsg->field == unset_ptr, "%s: " #field " should have been unset instead of %p\n", prefix, stubMsg->field) -#define TEST_ULONG_UNSET(field) ok(stubMsg->field == 0xcccccccc, "%s: " #field " should have been unset instead of 0x%x\n", prefix, stubMsg->field) -#define TEST_ULONG_PTR_UNSET(field) ok(stubMsg->field == (ULONG_PTR)unset_ptr, "%s: " #field " should have been unset instead of 0x%lx\n", prefix, stubMsg->field) +#define TEST_ULONG_UNSET(field) ok(stubMsg->field == 0xcccccccc, "%s: " #field " should have been unset instead of 0x%lx\n", prefix, stubMsg->field) +#define TEST_ULONG_PTR_UNSET(field) ok(stubMsg->field == (ULONG_PTR)unset_ptr, "%s: " #field " should have been unset instead of 0x%Ix\n", prefix, stubMsg->field) TEST_POINTER_UNSET(BufferMark); TEST_ULONG_UNSET(MemorySize); @@ -1712,10 +1712,10 @@ static void test_common_stub_data( const char *prefix, const MIDL_STUB_MESSAGE * TEST_POINTER_UNSET(SavedHandle); ok(stubMsg->StubDesc == &Object_StubDesc, "%s: StubDesc should have been %p instead of %p\n", prefix, &Object_StubDesc, stubMsg->StubDesc); - TEST_ZERO(FullPtrRefId, "%d"); + TEST_ZERO(FullPtrRefId, "%ld"); ok( stubMsg->PointerLength == 0 || broken(stubMsg->PointerLength == 1), /* win9x, nt4 */ - "%s: pAsyncMsg should have been set to zero instead of %d\n", prefix, stubMsg->PointerLength ); + "%s: pAsyncMsg should have been set to zero instead of %ld\n", prefix, stubMsg->PointerLength ); TEST_ZERO(fInDontFree, "%d"); TEST_ZERO(fDontCallFreeInst, "%d"); ok( stubMsg->fHasReturn == 0 || broken(stubMsg->fHasReturn), /* win9x, nt4 */ @@ -1728,13 +1728,13 @@ static void test_common_stub_data( const char *prefix, const MIDL_STUB_MESSAGE * ok(stubMsg->fBufferValid == 0, "%s: fBufferValid should have been set to 0 instead of %d\n", prefix, stubMsg->fBufferValid); TEST_ZERO(fNeedMCCP, "%d"); - ok(stubMsg->fUnused == 0 || - stubMsg->fUnused == -2, /* Vista */ - "%s: fUnused should have been set to 0 or -2 instead of %d\n", prefix, stubMsg->fUnused); - ok(stubMsg->fUnused2 == 0xffffcccc, "%s: fUnused2 should have been 0xffffcccc instead of 0x%x\n", - prefix, stubMsg->fUnused2); + ok(stubMsg->fUnused2 == 0 || + stubMsg->fUnused2 == -2, /* Vista */ + "%s: fUnused2 should have been set to 0 or -2 instead of %d\n", prefix, stubMsg->fUnused2); + ok(stubMsg->fUnused3 == 0xffffcccc, "%s: fUnused3 should have been 0xffffcccc instead of 0x%x\n", + prefix, stubMsg->fUnused3); ok(stubMsg->dwDestContext == MSHCTX_DIFFERENTMACHINE, - "%s: dwDestContext should have been MSHCTX_DIFFERENTMACHINE instead of %d\n", + "%s: dwDestContext should have been MSHCTX_DIFFERENTMACHINE instead of %ld\n", prefix, stubMsg->dwDestContext); TEST_ZERO(pvDestContext, "%p"); TEST_POINTER_UNSET(SavedContextHandles); @@ -1745,7 +1745,7 @@ static void test_common_stub_data( const char *prefix, const MIDL_STUB_MESSAGE * TEST_POINTER_UNSET(SizePtrOffsetArray); TEST_POINTER_UNSET(SizePtrLengthArray); TEST_POINTER_UNSET(pArgQueue); - TEST_ZERO(dwStubPhase, "%d"); + TEST_ZERO(dwStubPhase, "%ld"); /* FIXME: where does this value come from? */ trace("%s: LowStackMark is %p\n", prefix, stubMsg->LowStackMark); ok( stubMsg->pAsyncMsg == 0 || broken(stubMsg->pAsyncMsg == unset_ptr), /* win9x, nt4 */ @@ -1759,7 +1759,7 @@ static void test_common_stub_data( const char *prefix, const MIDL_STUB_MESSAGE * TEST_POINTER_UNSET(pCSInfo); TEST_POINTER_UNSET(ConformanceMark); TEST_POINTER_UNSET(VarianceMark); - ok(stubMsg->Unused == (ULONG_PTR)unset_ptr, "%s: Unused should have be unset instead of 0x%lx\n", + ok(stubMsg->Unused == (ULONG_PTR)unset_ptr, "%s: Unused should have be unset instead of 0x%Ix\n", prefix, stubMsg->Unused); TEST_POINTER_UNSET(pContext); TEST_POINTER_UNSET(ContextHandleHash); @@ -1801,7 +1801,7 @@ static void test_client_init(void) /* Note: ReservedForRuntime not tested */ ok(rpcMsg.ManagerEpv == unset_ptr, "rpcMsg.ManagerEpv should have been unset instead of %p\n", rpcMsg.ManagerEpv); ok(rpcMsg.ImportContext == unset_ptr, "rpcMsg.ImportContext should have been unset instead of %p\n", rpcMsg.ImportContext); - ok(rpcMsg.RpcFlags == 0, "rpcMsg.RpcFlags should have been 0 instead of 0x%x\n", rpcMsg.RpcFlags); + ok(rpcMsg.RpcFlags == 0, "rpcMsg.RpcFlags should have been 0 instead of 0x%lx\n", rpcMsg.RpcFlags); ok(stubMsg.Buffer == unset_ptr, "stubMsg.Buffer should have been unset instead of %p\n", stubMsg.Buffer); @@ -1809,7 +1809,7 @@ static void test_client_init(void) stubMsg.BufferStart); ok(stubMsg.BufferEnd == NULL, "stubMsg.BufferEnd should have been NULL instead of %p\n", stubMsg.BufferEnd); - ok(stubMsg.BufferLength == 0, "stubMsg.BufferLength should have been 0 instead of %u\n", + ok(stubMsg.BufferLength == 0, "stubMsg.BufferLength should have been 0 instead of %lu\n", stubMsg.BufferLength); ok(stubMsg.IsClient == 1, "stubMsg.IsClient should have been 1 instead of %u\n", stubMsg.IsClient); ok(stubMsg.ReuseBuffer == 0, "stubMsg.ReuseBuffer should have been 0 instead of %d\n", @@ -1843,8 +1843,8 @@ static void test_server_init(void) ok(stubMsg.Buffer == buffer, "stubMsg.Buffer should have been %p instead of %p\n", buffer, stubMsg.Buffer); ok(stubMsg.BufferStart == buffer, "stubMsg.BufferStart should have been %p instead of %p\n", buffer, stubMsg.BufferStart); ok(stubMsg.BufferEnd == buffer + sizeof(buffer), "stubMsg.BufferEnd should have been %p instead of %p\n", buffer + sizeof(buffer), stubMsg.BufferEnd); -todo_wine - ok(stubMsg.BufferLength == 0, "stubMsg.BufferLength should have been 0 instead of %u\n", stubMsg.BufferLength); + todo_wine + ok(stubMsg.BufferLength == 0, "stubMsg.BufferLength should have been 0 instead of %lu\n", stubMsg.BufferLength); ok(stubMsg.IsClient == 0, "stubMsg.IsClient should have been 0 instead of %u\n", stubMsg.IsClient); ok(stubMsg.ReuseBuffer == 0 || broken(stubMsg.ReuseBuffer == 1), /* win2k */ @@ -1885,17 +1885,17 @@ static void test_ndr_allocate(void) { trace("v2 mem list format\n"); ok((char *)mem_list_v2 == (char *)p2 + 24, "expected mem_list_v2 pointer %p, but got %p\n", (char *)p2 + 24, mem_list_v2); - ok(mem_list_v2->magic == magic_MEML, "magic %08x\n", mem_list_v2->magic); - ok(mem_list_v2->size == 24, "wrong size for p2 %d\n", mem_list_v2->size); - ok(mem_list_v2->unknown == 0, "wrong unknown for p2 0x%x\n", mem_list_v2->unknown); + ok(mem_list_v2->magic == magic_MEML, "magic %08lx\n", mem_list_v2->magic); + ok(mem_list_v2->size == 24, "wrong size for p2 %ld\n", mem_list_v2->size); + ok(mem_list_v2->unknown == 0, "wrong unknown for p2 0x%lx\n", mem_list_v2->unknown); ok(mem_list_v2->next != NULL, "next NULL\n"); mem_list_v2 = mem_list_v2->next; if(mem_list_v2) { ok((char *)mem_list_v2 == (char *)p1 + 16, "expected mem_list_v2 pointer %p, but got %p\n", (char *)p1 + 16, mem_list_v2); - ok(mem_list_v2->magic == magic_MEML, "magic %08x\n", mem_list_v2->magic); - ok(mem_list_v2->size == 16, "wrong size for p1 %d\n", mem_list_v2->size); - ok(mem_list_v2->unknown == 0, "wrong unknown for p1 0x%x\n", mem_list_v2->unknown); + ok(mem_list_v2->magic == magic_MEML, "magic %08lx\n", mem_list_v2->magic); + ok(mem_list_v2->size == 16, "wrong size for p1 %ld\n", mem_list_v2->size); + ok(mem_list_v2->unknown == 0, "wrong unknown for p1 0x%lx\n", mem_list_v2->unknown); ok(mem_list_v2->next == NULL, "next %p\n", mem_list_v2->next); } } @@ -1944,10 +1944,10 @@ static void test_conformant_array(void) NdrConformantArrayBufferSize( &StubMsg, memsrc, fmtstr_conf_array ); - ok(StubMsg.BufferLength >= 20, "length %d\n", StubMsg.BufferLength); + ok(StubMsg.BufferLength >= 20, "length %ld\n", StubMsg.BufferLength); /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; ptr = NdrConformantArrayMarshall( &StubMsg, memsrc, fmtstr_conf_array ); @@ -2021,7 +2021,7 @@ static void test_conformant_array(void) StubMsg.pfnFree(mem); StubMsg.pfnFree(mem_orig); - HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer); + NdrOleFree(StubMsg.RpcMsg->Buffer); } static void test_conformant_string(void) @@ -2055,16 +2055,16 @@ static void test_conformant_string(void) NdrPointerBufferSize( &StubMsg, (unsigned char *)memsrc, fmtstr_conf_str ); - ok(StubMsg.BufferLength >= sizeof(memsrc) + 12, "length %d\n", StubMsg.BufferLength); + ok(StubMsg.BufferLength >= sizeof(memsrc) + 12, "length %ld\n", StubMsg.BufferLength); /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; ptr = NdrPointerMarshall( &StubMsg, (unsigned char *)memsrc, fmtstr_conf_str ); ok(ptr == NULL, "ret %p\n", ptr); size = StubMsg.Buffer - StubMsg.BufferStart; - ok(size == sizeof(memsrc) + 12, "Buffer %p Start %p len %d\n", + ok(size == sizeof(memsrc) + 12, "Buffer %p Start %p len %ld\n", StubMsg.Buffer, StubMsg.BufferStart, size); ok(!memcmp(StubMsg.BufferStart + 12, memsrc, sizeof(memsrc)), "incorrectly marshaled\n"); @@ -2075,7 +2075,7 @@ static void test_conformant_string(void) /* Client */ my_alloc_called = 0; StubMsg.Buffer = StubMsg.BufferStart; - mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc)); + mem = mem_orig = malloc(sizeof(memsrc)); /* Windows apparently checks string length on the output buffer to determine its size... */ memset( mem, 'x', sizeof(memsrc) - 1 ); mem[sizeof(memsrc) - 1] = 0; @@ -2092,7 +2092,7 @@ static void test_conformant_string(void) /* Prevent a memory leak when running with Wine. Remove once the todo_wine block above is fixed. */ if (mem != mem_orig) - HeapFree(GetProcessHeap(), 0, mem_orig); + free(mem_orig); my_free_called = 0; StubMsg.Buffer = StubMsg.BufferStart; @@ -2124,7 +2124,7 @@ static void test_conformant_string(void) ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called); my_alloc_called = 0; - mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc)); + mem = mem_orig = malloc(sizeof(memsrc)); StubMsg.Buffer = StubMsg.BufferStart; NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 0); ok(mem == StubMsg.BufferStart + 12 || broken(!mem), /* win9x, nt4 */ @@ -2145,8 +2145,8 @@ static void test_conformant_string(void) NdrPointerFree( &StubMsg, mem, fmtstr_conf_str ); ok(my_free_called == 1, "free called %d\n", my_free_called); - HeapFree(GetProcessHeap(), 0, mem_orig); - HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer); + free(mem_orig); + NdrOleFree(StubMsg.RpcMsg->Buffer); } static void test_nonconformant_string(void) @@ -2180,16 +2180,16 @@ static void test_nonconformant_string(void) StubMsg.BufferLength = 0; NdrNonConformantStringBufferSize( &StubMsg, memsrc, fmtstr_nonconf_str ); - ok(StubMsg.BufferLength >= strlen((char *)memsrc) + 1 + 8, "length %d\n", StubMsg.BufferLength); + ok(StubMsg.BufferLength >= strlen((char *)memsrc) + 1 + 8, "length %ld\n", StubMsg.BufferLength); /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; ptr = NdrNonConformantStringMarshall( &StubMsg, memsrc, fmtstr_nonconf_str ); ok(ptr == NULL, "ret %p\n", ptr); size = StubMsg.Buffer - StubMsg.BufferStart; - ok(size == strlen((char *)memsrc) + 1 + 8, "Buffer %p Start %p len %d\n", + ok(size == strlen((char *)memsrc) + 1 + 8, "Buffer %p Start %p len %ld\n", StubMsg.Buffer, StubMsg.BufferStart, size); ok(!memcmp(StubMsg.BufferStart + 8, memsrc, strlen((char *)memsrc) + 1), "incorrectly marshaled\n"); @@ -2200,7 +2200,7 @@ static void test_nonconformant_string(void) /* Client */ my_alloc_called = 0; StubMsg.Buffer = StubMsg.BufferStart; - mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc)); + mem = mem_orig = malloc(sizeof(memsrc)); NdrNonConformantStringUnmarshall( &StubMsg, &mem, fmtstr_nonconf_str, 0); ok(mem == mem_orig, "mem alloced\n"); ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called); @@ -2222,7 +2222,7 @@ static void test_nonconformant_string(void) ok(mem != mem_orig, "mem not alloced\n"); ok(mem != StubMsg.BufferStart + 8, "mem pointing at buffer\n"); ok(my_alloc_called == 1, "alloc called %d\n", my_alloc_called); - NdrOleFree(mem); + free(mem); my_alloc_called = 0; mem = mem_orig; @@ -2240,8 +2240,8 @@ static void test_nonconformant_string(void) todo_wine ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called); - HeapFree(GetProcessHeap(), 0, mem_orig); - HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer); + free(mem_orig); + NdrOleFree(StubMsg.RpcMsg->Buffer); /* length = size */ NdrClientInitializeNew( @@ -2253,16 +2253,16 @@ static void test_nonconformant_string(void) StubMsg.BufferLength = 0; NdrNonConformantStringBufferSize( &StubMsg, memsrc2, fmtstr_nonconf_str ); - ok(StubMsg.BufferLength >= strlen((char *)memsrc2) + 1 + 8, "length %d\n", StubMsg.BufferLength); + ok(StubMsg.BufferLength >= strlen((char *)memsrc2) + 1 + 8, "length %ld\n", StubMsg.BufferLength); /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; ptr = NdrNonConformantStringMarshall( &StubMsg, memsrc2, fmtstr_nonconf_str ); ok(ptr == NULL, "ret %p\n", ptr); size = StubMsg.Buffer - StubMsg.BufferStart; - ok(size == strlen((char *)memsrc2) + 1 + 8, "Buffer %p Start %p len %d\n", + ok(size == strlen((char *)memsrc2) + 1 + 8, "Buffer %p Start %p len %ld\n", StubMsg.Buffer, StubMsg.BufferStart, size); ok(!memcmp(StubMsg.BufferStart + 8, memsrc2, strlen((char *)memsrc2) + 1), "incorrectly marshaled\n"); @@ -2273,7 +2273,7 @@ static void test_nonconformant_string(void) /* Client */ my_alloc_called = 0; StubMsg.Buffer = StubMsg.BufferStart; - mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc)); + mem = mem_orig = malloc(sizeof(memsrc)); NdrNonConformantStringUnmarshall( &StubMsg, &mem, fmtstr_nonconf_str, 0); ok(mem == mem_orig, "mem alloced\n"); ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called); @@ -2295,7 +2295,7 @@ static void test_nonconformant_string(void) ok(mem != mem_orig, "mem not alloced\n"); ok(mem != StubMsg.BufferStart + 8, "mem pointing at buffer\n"); ok(my_alloc_called == 1, "alloc called %d\n", my_alloc_called); - NdrOleFree(mem); + free(mem); my_alloc_called = 0; mem = mem_orig; @@ -2313,8 +2313,8 @@ static void test_nonconformant_string(void) todo_wine ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called); - HeapFree(GetProcessHeap(), 0, mem_orig); - HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer); + free(mem_orig); + NdrOleFree(StubMsg.RpcMsg->Buffer); } static void test_conf_complex_struct(void) @@ -2326,53 +2326,46 @@ static void test_conf_complex_struct(void) unsigned int i; struct conf_complex { - unsigned int size; - unsigned int *array[1]; + enum {dummy} enum16; + unsigned int size; + unsigned int array[1]; }; struct conf_complex *memsrc; struct conf_complex *mem; + /* + struct conf_complex + { + enum {dummy} enum16; + int size; + [size_is(size), unique] int array[]; + }; + */ static const unsigned char fmtstr_complex_struct[] = { -/* 0 */ - 0x1b, /* FC_CARRAY */ - 0x3, /* 3 */ -/* 2 */ NdrFcShort( 0x4 ), /* 4 */ -/* 4 */ 0x8, /* Corr desc: FC_LONG */ - 0x0, /* */ -/* 6 */ NdrFcShort( 0xfffc ), /* -4 */ -/* 8 */ - 0x4b, /* FC_PP */ - 0x5c, /* FC_PAD */ -/* 10 */ - 0x48, /* FC_VARIABLE_REPEAT */ - 0x49, /* FC_FIXED_OFFSET */ -/* 12 */ NdrFcShort( 0x4 ), /* 4 */ -/* 14 */ NdrFcShort( 0x0 ), /* 0 */ -/* 16 */ NdrFcShort( 0x1 ), /* 1 */ -/* 18 */ NdrFcShort( 0x0 ), /* 0 */ -/* 20 */ NdrFcShort( 0x0 ), /* 0 */ -/* 22 */ 0x12, 0x8, /* FC_UP [simple_pointer] */ -/* 24 */ 0x8, /* FC_LONG */ - 0x5c, /* FC_PAD */ -/* 26 */ - 0x5b, /* FC_END */ - - 0x8, /* FC_LONG */ -/* 28 */ 0x5c, /* FC_PAD */ - 0x5b, /* FC_END */ -/* 30 */ - 0x1a, /* FC_BOGUS_STRUCT */ - 0x3, /* 3 */ -/* 32 */ NdrFcShort( 0x4 ), /* 4 */ -/* 34 */ NdrFcShort( 0xffffffde ), /* Offset= -34 (0) */ -/* 36 */ NdrFcShort( 0x0 ), /* Offset= 0 (36) */ -/* 38 */ 0x8, /* FC_LONG */ - 0x5b, /* FC_END */ + NdrFcShort(0x0), +/* 2 (int[]) */ + 0x1b, /* FC_CARRAY */ + 0x3, /* 3 */ + NdrFcShort(0x4), /* 4 */ + 0x8, /* Corr desc: field size, FC_LONG */ + 0x0, /* no operators */ + NdrFcShort(0xfffc), /* offset = -4 */ + 0x08, /* FC_LONG */ + 0x5b, /* FC_END */ +/* 12 (struct conf_complex) */ + 0x1a, /* FC_BOGUS_STRUCT */ + 0x3, /* 3 */ + NdrFcShort(0x8), /* 8 */ + NdrFcShort(0xfff2), /* Offset= -14 (2) */ + NdrFcShort(0x0), /* Offset= 0 (18) */ + 0x0d, /* FC_ENUM16 */ + 0x08, /* FC_LONG */ + 0x5c, /* FC_PAD */ + 0x5b, /* FC_END */ }; - memsrc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - FIELD_OFFSET(struct conf_complex, array[20])); + memsrc = calloc(1, FIELD_OFFSET(struct conf_complex, array[20])); memsrc->size = 20; StubDesc = Object_StubDesc; @@ -2385,36 +2378,38 @@ static void test_conf_complex_struct(void) 0); StubMsg.BufferLength = 0; - NdrComplexStructBufferSize( &StubMsg, - (unsigned char *)memsrc, - &fmtstr_complex_struct[30] ); - ok(StubMsg.BufferLength >= 28, "length %d\n", StubMsg.BufferLength); + NdrComplexStructBufferSize(&StubMsg, (unsigned char *)memsrc, &fmtstr_complex_struct[12]); + ok(StubMsg.BufferLength >= 92, "length %ld\n", StubMsg.BufferLength); /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; - ptr = NdrComplexStructMarshall( &StubMsg, (unsigned char *)memsrc, - &fmtstr_complex_struct[30] ); + ptr = NdrComplexStructMarshall(&StubMsg, (unsigned char *)memsrc, &fmtstr_complex_struct[12]); ok(ptr == NULL, "ret %p\n", ptr); - ok(*(unsigned int *)StubMsg.BufferStart == 20, "Conformance should have been 20 instead of %d\n", *(unsigned int *)StubMsg.BufferStart); - ok(*(unsigned int *)(StubMsg.BufferStart + 4) == 20, "conf_complex.size should have been 20 instead of %d\n", *(unsigned int *)(StubMsg.BufferStart + 4)); + ok(*(unsigned int *)StubMsg.BufferStart == 20, "Conformance should have been 20 instead of %u\n", + *(unsigned int *)StubMsg.BufferStart); + todo_wine + ok(*(unsigned int *)(StubMsg.BufferStart + 8) == 20, "conf_complex.size should have been 20 instead of %u\n", + *(unsigned int *)(StubMsg.BufferStart + 8)); for (i = 0; i < 20; i++) - ok(*(unsigned int *)(StubMsg.BufferStart + 8 + i * 4) == 0, "pointer id for conf_complex.array[%d] should have been 0 instead of 0x%x\n", i, *(unsigned int *)(StubMsg.BufferStart + 8 + i * 4)); + ok(*(unsigned int *)(StubMsg.BufferStart + 12 + i * 4) == 0, + "pointer id for conf_complex.array[%u] should have been 0 instead of 0x%x\n", i, + *(unsigned int *)(StubMsg.BufferStart + 12 + i * 4)); /* Server */ my_alloc_called = 0; StubMsg.IsClient = 0; mem = NULL; StubMsg.Buffer = StubMsg.BufferStart; - ptr = NdrComplexStructUnmarshall( &StubMsg, (unsigned char **)&mem, &fmtstr_complex_struct[30], 0); + ptr = NdrComplexStructUnmarshall(&StubMsg, (unsigned char **)&mem, &fmtstr_complex_struct[12], 0); ok(ptr == NULL, "ret %p\n", ptr); ok(mem->size == 20, "mem->size wasn't unmarshalled correctly (%d)\n", mem->size); - ok(mem->array[0] == NULL, "mem->array[0] wasn't unmarshalled correctly (%p)\n", mem->array[0]); + ok(mem->array[0] == 0, "mem->array[0] wasn't unmarshalled correctly (%u)\n", mem->array[0]); StubMsg.pfnFree(mem); - HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer); - HeapFree(GetProcessHeap(), 0, memsrc); + NdrOleFree(StubMsg.RpcMsg->Buffer); + free(memsrc); } @@ -2496,11 +2491,11 @@ static void test_conf_complex_array(void) memsrc.dim1 = 5; memsrc.dim2 = 3; - memsrc.array = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, memsrc.dim1 * sizeof(DWORD*)); + memsrc.array = calloc(memsrc.dim1, sizeof(DWORD *)); for(i = 0; i < memsrc.dim1; i++) { - memsrc.array[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, memsrc.dim2 * sizeof(DWORD)); + memsrc.array[i] = calloc(memsrc.dim2, sizeof(DWORD)); for(j = 0; j < memsrc.dim2; j++) memsrc.array[i][j] = i * memsrc.dim2 + j; } @@ -2527,10 +2522,10 @@ static void test_conf_complex_array(void) #endif expected_length = (4 + memsrc.dim1 * (2 + memsrc.dim2)) * 4; - ok(StubMsg.BufferLength >= expected_length, "length %d\n", StubMsg.BufferLength); + ok(StubMsg.BufferLength >= expected_length, "length %ld\n", StubMsg.BufferLength); /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ - StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength); + StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = NdrOleAllocate(StubMsg.BufferLength); StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength; #ifdef _WIN64 @@ -2546,13 +2541,13 @@ static void test_conf_complex_array(void) buf = (DWORD *)StubMsg.BufferStart; - ok(*buf == memsrc.dim1, "dim1 should have been %d instead of %08x\n", memsrc.dim1, *buf); + ok(*buf == memsrc.dim1, "dim1 should have been %d instead of %08lx\n", memsrc.dim1, *buf); buf++; - ok(*buf == memsrc.dim2, "dim2 should have been %d instead of %08x\n", memsrc.dim2, *buf); + ok(*buf == memsrc.dim2, "dim2 should have been %d instead of %08lx\n", memsrc.dim2, *buf); buf++; ok(*buf != 0, "pointer id should be non-zero\n"); buf++; - ok(*buf == memsrc.dim1, "Conformance should have been %d instead of %08x\n", memsrc.dim1, *buf); + ok(*buf == memsrc.dim1, "Conformance should have been %d instead of %08lx\n", memsrc.dim1, *buf); buf++; for(i = 0; i < memsrc.dim1; i++) { @@ -2561,11 +2556,11 @@ static void test_conf_complex_array(void) } for(i = 0; i < memsrc.dim1; i++) { - ok(*buf == memsrc.dim2, "Conformance should have been %d instead of %08x\n", memsrc.dim2, *buf); + ok(*buf == memsrc.dim2, "Conformance should have been %d instead of %08lx\n", memsrc.dim2, *buf); buf++; for(j = 0; j < memsrc.dim2; j++) { - ok(*buf == i * memsrc.dim2 + j, "got %08x\n", *buf); + ok(*buf == i * memsrc.dim2 + j, "got %08lx\n", *buf); buf++; } } @@ -2585,7 +2580,7 @@ static void test_conf_complex_array(void) ok(ptr == NULL, "ret %p\n", ptr); ok(mem->dim1 == memsrc.dim1, "mem->dim1 wasn't unmarshalled correctly (%d)\n", mem->dim1); ok(mem->dim2 == memsrc.dim2, "mem->dim2 wasn't unmarshalled correctly (%d)\n", mem->dim2); - ok(mem->array[1][0] == memsrc.dim2, "mem->array[1][0] wasn't unmarshalled correctly (%d)\n", mem->array[1][0]); + ok(mem->array[1][0] == memsrc.dim2, "mem->array[1][0] wasn't unmarshalled correctly (%ld)\n", mem->array[1][0]); StubMsg.Buffer = StubMsg.BufferStart; #ifdef _WIN64 @@ -2594,11 +2589,11 @@ static void test_conf_complex_array(void) NdrSimpleStructFree( &StubMsg, (unsigned char*)mem, &fmtstr_complex_array[32]); #endif - HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer); + NdrOleFree(StubMsg.RpcMsg->Buffer); for(i = 0; i < memsrc.dim1; i++) - HeapFree(GetProcessHeap(), 0, memsrc.array[i]); - HeapFree(GetProcessHeap(), 0, memsrc.array); + free(memsrc.array[i]); + free(memsrc.array); } static void test_ndr_buffer(void) @@ -2618,11 +2613,11 @@ static void test_ndr_buffer(void) StubDesc.RpcInterfaceInformation = (void *)&IFoo___RpcServerInterface; status = RpcServerUseProtseqEpA(ncalrpc, 20, endpoint, NULL); - ok(RPC_S_OK == status, "RpcServerUseProtseqEp failed with status %u\n", status); + ok(RPC_S_OK == status, "RpcServerUseProtseqEp failed with status %lu\n", status); status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL); - ok(RPC_S_OK == status, "RpcServerRegisterIf failed with status %u\n", status); + ok(RPC_S_OK == status, "RpcServerRegisterIf failed with status %lu\n", status); status = RpcServerListen(1, 20, TRUE); - ok(RPC_S_OK == status, "RpcServerListen failed with status %u\n", status); + ok(RPC_S_OK == status, "RpcServerListen failed with status %lu\n", status); if (status != RPC_S_OK) { /* Failed to create a server, running client tests is useless */ @@ -2630,27 +2625,29 @@ static void test_ndr_buffer(void) } status = RpcStringBindingComposeA(NULL, ncalrpc, NULL, endpoint, NULL, &binding); - ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%lu)\n", status); status = RpcBindingFromStringBindingA(binding, &Handle); - ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%lu)\n", status); RpcStringFreeA(&binding); NdrClientInitializeNew(&RpcMessage, &StubMsg, &StubDesc, 5); + my_alloc_called = 0; ret = NdrGetBuffer(&StubMsg, 10, Handle); + ok(!my_alloc_called, "my_alloc got called\n"); ok(ret == StubMsg.Buffer, "NdrGetBuffer should have returned the same value as StubMsg.Buffer instead of %p\n", ret); ok(RpcMessage.Handle != NULL, "RpcMessage.Handle should not have been NULL\n"); ok(RpcMessage.Buffer != NULL, "RpcMessage.Buffer should not have been NULL\n"); ok(RpcMessage.BufferLength == 10 || broken(RpcMessage.BufferLength == 12), /* win2k */ "RpcMessage.BufferLength should have been 10 instead of %d\n", RpcMessage.BufferLength); - ok(RpcMessage.RpcFlags == 0, "RpcMessage.RpcFlags should have been 0x0 instead of 0x%x\n", RpcMessage.RpcFlags); + ok(RpcMessage.RpcFlags == 0, "RpcMessage.RpcFlags should have been 0x0 instead of 0x%lx\n", RpcMessage.RpcFlags); ok(StubMsg.Buffer != NULL, "Buffer should not have been NULL\n"); ok(!StubMsg.BufferStart, "BufferStart should have been NULL instead of %p\n", StubMsg.BufferStart); ok(!StubMsg.BufferEnd, "BufferEnd should have been NULL instead of %p\n", StubMsg.BufferEnd); -todo_wine - ok(StubMsg.BufferLength == 0, "BufferLength should have left as 0 instead of being set to %d\n", StubMsg.BufferLength); + todo_wine + ok(StubMsg.BufferLength == 0, "BufferLength should have left as 0 instead of being set to %ld\n", StubMsg.BufferLength); old_buffer_valid_location = !StubMsg.fBufferValid; if (old_buffer_valid_location) ok(broken(StubMsg.CorrDespIncrement == TRUE), "fBufferValid should have been TRUE instead of 0x%x\n", StubMsg.CorrDespIncrement); @@ -2659,12 +2656,14 @@ todo_wine prev_buffer_length = RpcMessage.BufferLength; StubMsg.BufferLength = 1; + my_free_called = 0; NdrFreeBuffer(&StubMsg); + ok(!my_free_called, "my_free got called\n"); ok(RpcMessage.Handle != NULL, "RpcMessage.Handle should not have been NULL\n"); ok(RpcMessage.Buffer != NULL, "RpcMessage.Buffer should not have been NULL\n"); - ok(RpcMessage.BufferLength == prev_buffer_length, "RpcMessage.BufferLength should have been left as %d instead of %d\n", prev_buffer_length, RpcMessage.BufferLength); + ok(RpcMessage.BufferLength == prev_buffer_length, "RpcMessage.BufferLength should have been left as %ld instead of %d\n", prev_buffer_length, RpcMessage.BufferLength); ok(StubMsg.Buffer != NULL, "Buffer should not have been NULL\n"); - ok(StubMsg.BufferLength == 1, "BufferLength should have left as 1 instead of being set to %d\n", StubMsg.BufferLength); + ok(StubMsg.BufferLength == 1, "BufferLength should have left as 1 instead of being set to %ld\n", StubMsg.BufferLength); if (old_buffer_valid_location) ok(broken(StubMsg.CorrDespIncrement == FALSE), "fBufferValid should have been FALSE instead of 0x%x\n", StubMsg.CorrDespIncrement); else @@ -2676,7 +2675,7 @@ todo_wine RpcBindingFree(&Handle); status = RpcServerUnregisterIf(NULL, NULL, FALSE); - ok(status == RPC_S_OK, "RpcServerUnregisterIf failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcServerUnregisterIf failed (%lu)\n", status); } static void test_NdrMapCommAndFaultStatus(void) @@ -2695,7 +2694,7 @@ static void test_NdrMapCommAndFaultStatus(void) ULONG expected_comm_status = 0; ULONG expected_fault_status = 0; status = NdrMapCommAndFaultStatus(&StubMsg, &comm_status, &fault_status, rpc_status); - ok(status == RPC_S_OK, "NdrMapCommAndFaultStatus failed with error %d\n", status); + ok(status == RPC_S_OK, "NdrMapCommAndFaultStatus failed with error %ld\n", status); switch (rpc_status) { case ERROR_INVALID_HANDLE: @@ -2715,9 +2714,9 @@ static void test_NdrMapCommAndFaultStatus(void) default: expected_fault_status = rpc_status; } - ok(comm_status == expected_comm_status, "NdrMapCommAndFaultStatus should have mapped %d to comm status %d instead of %d\n", + ok(comm_status == expected_comm_status, "NdrMapCommAndFaultStatus should have mapped %ld to comm status %ld instead of %ld\n", rpc_status, expected_comm_status, comm_status); - ok(fault_status == expected_fault_status, "NdrMapCommAndFaultStatus should have mapped %d to fault status %d instead of %d\n", + ok(fault_status == expected_fault_status, "NdrMapCommAndFaultStatus should have mapped %ld to fault status %ld instead of %ld\n", rpc_status, expected_fault_status, fault_status); } } @@ -2759,25 +2758,25 @@ static void test_NdrGetUserMarshalInfo(void) memset(&umi, 0xaa, sizeof(umi)); status = NdrGetUserMarshalInfo(&umcb.Flags, 1, &umi); - ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %d\n", status); + ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %ld\n", status); ok( umi.InformationLevel == 1, - "umi.InformationLevel was %u instead of 1\n", + "umi.InformationLevel was %lu instead of 1\n", umi.InformationLevel); - ok( U1(umi).Level1.Buffer == buffer + 15, + ok( umi.Level1.Buffer == buffer + 15, "umi.Level1.Buffer was %p instead of %p\n", - U1(umi).Level1.Buffer, buffer); - ok( U1(umi).Level1.BufferSize == 1, - "umi.Level1.BufferSize was %u instead of 1\n", - U1(umi).Level1.BufferSize); - ok( U1(umi).Level1.pfnAllocate == my_alloc, + umi.Level1.Buffer, buffer); + ok( umi.Level1.BufferSize == 1, + "umi.Level1.BufferSize was %lu instead of 1\n", + umi.Level1.BufferSize); + ok( umi.Level1.pfnAllocate == my_alloc, "umi.Level1.pfnAllocate was %p instead of %p\n", - U1(umi).Level1.pfnAllocate, my_alloc); - ok( U1(umi).Level1.pfnFree == my_free, + umi.Level1.pfnAllocate, my_alloc); + ok( umi.Level1.pfnFree == my_free, "umi.Level1.pfnFree was %p instead of %p\n", - U1(umi).Level1.pfnFree, my_free); - ok( U1(umi).Level1.pRpcChannelBuffer == rpc_channel_buffer, + umi.Level1.pfnFree, my_free); + ok( umi.Level1.pRpcChannelBuffer == rpc_channel_buffer, "umi.Level1.pRpcChannelBuffer was %p instead of %p\n", - U1(umi).Level1.pRpcChannelBuffer, rpc_channel_buffer); + umi.Level1.pRpcChannelBuffer, rpc_channel_buffer); /* buffer size */ @@ -2793,25 +2792,25 @@ static void test_NdrGetUserMarshalInfo(void) memset(&umi, 0xaa, sizeof(umi)); status = NdrGetUserMarshalInfo(&umcb.Flags, 1, &umi); - ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %d\n", status); + ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %ld\n", status); ok( umi.InformationLevel == 1, - "umi.InformationLevel was %u instead of 1\n", + "umi.InformationLevel was %lu instead of 1\n", umi.InformationLevel); - ok( U1(umi).Level1.Buffer == NULL, + ok( umi.Level1.Buffer == NULL, "umi.Level1.Buffer was %p instead of NULL\n", - U1(umi).Level1.Buffer); - ok( U1(umi).Level1.BufferSize == 0, - "umi.Level1.BufferSize was %u instead of 0\n", - U1(umi).Level1.BufferSize); - ok( U1(umi).Level1.pfnAllocate == my_alloc, + umi.Level1.Buffer); + ok( umi.Level1.BufferSize == 0, + "umi.Level1.BufferSize was %lu instead of 0\n", + umi.Level1.BufferSize); + ok( umi.Level1.pfnAllocate == my_alloc, "umi.Level1.pfnAllocate was %p instead of %p\n", - U1(umi).Level1.pfnAllocate, my_alloc); - ok( U1(umi).Level1.pfnFree == my_free, + umi.Level1.pfnAllocate, my_alloc); + ok( umi.Level1.pfnFree == my_free, "umi.Level1.pfnFree was %p instead of %p\n", - U1(umi).Level1.pfnFree, my_free); - ok( U1(umi).Level1.pRpcChannelBuffer == rpc_channel_buffer, + umi.Level1.pfnFree, my_free); + ok( umi.Level1.pRpcChannelBuffer == rpc_channel_buffer, "umi.Level1.pRpcChannelBuffer was %p instead of %p\n", - U1(umi).Level1.pRpcChannelBuffer, rpc_channel_buffer); + umi.Level1.pRpcChannelBuffer, rpc_channel_buffer); /* marshall */ @@ -2827,25 +2826,25 @@ static void test_NdrGetUserMarshalInfo(void) memset(&umi, 0xaa, sizeof(umi)); status = NdrGetUserMarshalInfo(&umcb.Flags, 1, &umi); - ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %d\n", status); + ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %ld\n", status); ok( umi.InformationLevel == 1, - "umi.InformationLevel was %u instead of 1\n", + "umi.InformationLevel was %lu instead of 1\n", umi.InformationLevel); - ok( U1(umi).Level1.Buffer == buffer + 15, + ok( umi.Level1.Buffer == buffer + 15, "umi.Level1.Buffer was %p instead of %p\n", - U1(umi).Level1.Buffer, buffer); - ok( U1(umi).Level1.BufferSize == 1, - "umi.Level1.BufferSize was %u instead of 1\n", - U1(umi).Level1.BufferSize); - ok( U1(umi).Level1.pfnAllocate == my_alloc, + umi.Level1.Buffer, buffer); + ok( umi.Level1.BufferSize == 1, + "umi.Level1.BufferSize was %lu instead of 1\n", + umi.Level1.BufferSize); + ok( umi.Level1.pfnAllocate == my_alloc, "umi.Level1.pfnAllocate was %p instead of %p\n", - U1(umi).Level1.pfnAllocate, my_alloc); - ok( U1(umi).Level1.pfnFree == my_free, + umi.Level1.pfnAllocate, my_alloc); + ok( umi.Level1.pfnFree == my_free, "umi.Level1.pfnFree was %p instead of %p\n", - U1(umi).Level1.pfnFree, my_free); - ok( U1(umi).Level1.pRpcChannelBuffer == rpc_channel_buffer, + umi.Level1.pfnFree, my_free); + ok( umi.Level1.pRpcChannelBuffer == rpc_channel_buffer, "umi.Level1.pRpcChannelBuffer was %p instead of %p\n", - U1(umi).Level1.pRpcChannelBuffer, rpc_channel_buffer); + umi.Level1.pRpcChannelBuffer, rpc_channel_buffer); /* free */ @@ -2861,25 +2860,25 @@ static void test_NdrGetUserMarshalInfo(void) memset(&umi, 0xaa, sizeof(umi)); status = NdrGetUserMarshalInfo(&umcb.Flags, 1, &umi); - ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %d\n", status); + ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %ld\n", status); ok( umi.InformationLevel == 1, - "umi.InformationLevel was %u instead of 1\n", + "umi.InformationLevel was %lu instead of 1\n", umi.InformationLevel); - ok( U1(umi).Level1.Buffer == NULL, + ok( umi.Level1.Buffer == NULL, "umi.Level1.Buffer was %p instead of NULL\n", - U1(umi).Level1.Buffer); - ok( U1(umi).Level1.BufferSize == 0, - "umi.Level1.BufferSize was %u instead of 0\n", - U1(umi).Level1.BufferSize); - ok( U1(umi).Level1.pfnAllocate == my_alloc, + umi.Level1.Buffer); + ok( umi.Level1.BufferSize == 0, + "umi.Level1.BufferSize was %lu instead of 0\n", + umi.Level1.BufferSize); + ok( umi.Level1.pfnAllocate == my_alloc, "umi.Level1.pfnAllocate was %p instead of %p\n", - U1(umi).Level1.pfnAllocate, my_alloc); - ok( U1(umi).Level1.pfnFree == my_free, + umi.Level1.pfnAllocate, my_alloc); + ok( umi.Level1.pfnFree == my_free, "umi.Level1.pfnFree was %p instead of %p\n", - U1(umi).Level1.pfnFree, my_free); - ok( U1(umi).Level1.pRpcChannelBuffer == rpc_channel_buffer, + umi.Level1.pfnFree, my_free); + ok( umi.Level1.pRpcChannelBuffer == rpc_channel_buffer, "umi.Level1.pRpcChannelBuffer was %p instead of %p\n", - U1(umi).Level1.pRpcChannelBuffer, rpc_channel_buffer); + umi.Level1.pRpcChannelBuffer, rpc_channel_buffer); /* boundary test */ @@ -2893,32 +2892,32 @@ static void test_NdrGetUserMarshalInfo(void) umcb.CBType = USER_MARSHAL_CB_MARSHALL; status = NdrGetUserMarshalInfo(&umcb.Flags, 1, &umi); - ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %d\n", status); - ok( U1(umi).Level1.BufferSize == 0, - "umi.Level1.BufferSize was %u instead of 0\n", - U1(umi).Level1.BufferSize); + ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %ld\n", status); + ok( umi.Level1.BufferSize == 0, + "umi.Level1.BufferSize was %lu instead of 0\n", + umi.Level1.BufferSize); /* error conditions */ rpc_msg.BufferLength = 14; status = NdrGetUserMarshalInfo(&umcb.Flags, 1, &umi); ok(status == ERROR_INVALID_USER_BUFFER, - "NdrGetUserMarshalInfo should have failed with ERROR_INVALID_USER_BUFFER instead of %d\n", status); + "NdrGetUserMarshalInfo should have failed with ERROR_INVALID_USER_BUFFER instead of %ld\n", status); rpc_msg.BufferLength = 15; status = NdrGetUserMarshalInfo(&umcb.Flags, 9999, &umi); ok(status == RPC_S_INVALID_ARG, - "NdrGetUserMarshalInfo should have failed with RPC_S_INVALID_ARG instead of %d\n", status); + "NdrGetUserMarshalInfo should have failed with RPC_S_INVALID_ARG instead of %ld\n", status); umcb.CBType = 9999; status = NdrGetUserMarshalInfo(&umcb.Flags, 1, &umi); - ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %d\n", status); + ok(status == RPC_S_OK, "NdrGetUserMarshalInfo failed with error %ld\n", status); umcb.CBType = USER_MARSHAL_CB_MARSHALL; umcb.Signature = 0; status = NdrGetUserMarshalInfo(&umcb.Flags, 1, &umi); ok(status == RPC_S_INVALID_ARG, - "NdrGetUserMarshalInfo should have failed with RPC_S_INVALID_ARG instead of %d\n", status); + "NdrGetUserMarshalInfo should have failed with RPC_S_INVALID_ARG instead of %ld\n", status); } static void test_MesEncodeFixedBufferHandleCreate(void) @@ -2929,54 +2928,54 @@ static void test_MesEncodeFixedBufferHandleCreate(void) char *buffer; status = MesEncodeFixedBufferHandleCreate(NULL, 0, NULL, NULL); - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); status = MesEncodeFixedBufferHandleCreate(NULL, 0, NULL, &handle); - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); status = MesEncodeFixedBufferHandleCreate((char*)0xdeadbeef, 0, NULL, &handle); - ok(status == RPC_X_INVALID_BUFFER, "got %d\n", status); + ok(status == RPC_X_INVALID_BUFFER, "got %ld\n", status); buffer = (void*)((0xdeadbeef + 7) & ~7); status = MesEncodeFixedBufferHandleCreate(buffer, 0, NULL, &handle); - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); status = MesEncodeFixedBufferHandleCreate(buffer, 0, &encoded_size, &handle); -todo_wine - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + todo_wine + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); if (status == RPC_S_OK) { MesHandleFree(handle); } status = MesEncodeFixedBufferHandleCreate(buffer, 32, NULL, &handle); - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); status = MesEncodeFixedBufferHandleCreate(buffer, 32, &encoded_size, &handle); - ok(status == RPC_S_OK, "got %d\n", status); + ok(status == RPC_S_OK, "got %ld\n", status); status = MesBufferHandleReset(NULL, MES_DYNAMIC_BUFFER_HANDLE, MES_ENCODE, &buffer, 32, &encoded_size); - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); /* convert to dynamic buffer handle */ status = MesBufferHandleReset(handle, MES_DYNAMIC_BUFFER_HANDLE, MES_ENCODE, &buffer, 32, &encoded_size); - ok(status == RPC_S_OK, "got %d\n", status); + ok(status == RPC_S_OK, "got %ld\n", status); status = MesBufferHandleReset(handle, MES_DYNAMIC_BUFFER_HANDLE, MES_ENCODE, NULL, 32, &encoded_size); - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); status = MesBufferHandleReset(handle, MES_DYNAMIC_BUFFER_HANDLE, MES_ENCODE, &buffer, 32, NULL); - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); /* invalid handle type */ status = MesBufferHandleReset(handle, MES_DYNAMIC_BUFFER_HANDLE+1, MES_ENCODE, &buffer, 32, &encoded_size); - ok(status == RPC_S_INVALID_ARG, "got %d\n", status); + ok(status == RPC_S_INVALID_ARG, "got %ld\n", status); status = MesHandleFree(handle); - ok(status == RPC_S_OK, "got %d\n", status); + ok(status == RPC_S_OK, "got %ld\n", status); } static void test_NdrCorrelationInitialize(void) diff --git a/modules/rostests/winetests/rpcrt4/rpc.c b/modules/rostests/winetests/rpcrt4/rpc.c index 32cd77bdafc..139f98abacf 100644 --- a/modules/rostests/winetests/rpcrt4/rpc.c +++ b/modules/rostests/winetests/rpcrt4/rpc.c @@ -40,6 +40,10 @@ #include "rpcdce.h" #include "secext.h" +#ifdef __REACTOS__ // I_RpcExceptionFilter is Vista+ +#define RpcExceptionFilter I_RpcExceptionFilter +#endif + typedef unsigned int unsigned32; typedef struct twr_t { @@ -78,35 +82,49 @@ static BOOL Uuid_Comparison_Grid[11][11] = { { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE } }; -static void UuidConversionAndComparison(void) { +static void test_UuidEqual(void) +{ + UUID Uuid1, Uuid2, *PUuid1, *PUuid2; + RPC_STATUS status; + int i1, i2; + + /* Uuid Equality */ + for (i1 = 0; i1 < 11; i1++) + { + for (i2 = 0; i2 < 11; i2++) + { + if (i1 < 10) + { + Uuid1 = Uuid_Table[i1]; + PUuid1 = &Uuid1; + } + else + PUuid1 = NULL; + + if (i2 < 10) + { + Uuid2 = Uuid_Table[i2]; + PUuid2 = &Uuid2; + } + else + PUuid2 = NULL; + ok(UuidEqual(PUuid1, PUuid2, &status) == Uuid_Comparison_Grid[i1][i2], "UUID Equality\n" ); + } + } +} + +static void test_UuidFromString(void) +{ CHAR strx[100], x; LPSTR str = strx; WCHAR wstrx[100], wx; LPWSTR wstr = wstrx; - UUID Uuid1, Uuid2, *PUuid1, *PUuid2; + UUID Uuid1, Uuid2; RPC_STATUS rslt; int i1,i2; - /* Uuid Equality */ - for (i1 = 0; i1 < 11; i1++) - for (i2 = 0; i2 < 11; i2++) { - if (i1 < 10) { - Uuid1 = Uuid_Table[i1]; - PUuid1 = &Uuid1; - } else { - PUuid1 = NULL; - } - if (i2 < 10) { - Uuid2 = Uuid_Table[i2]; - PUuid2 = &Uuid2; - } else { - PUuid2 = NULL; - } - ok( (UuidEqual(PUuid1, PUuid2, &rslt) == Uuid_Comparison_Grid[i1][i2]), "UUID Equality\n" ); - } - /* Uuid to String to Uuid (char) */ for (i1 = 0; i1 < 10; i1++) { Uuid1 = Uuid_Table[i1]; @@ -141,44 +159,30 @@ static void UuidConversionAndComparison(void) { } } -static void TestDceErrorInqText (void) +static void test_DceErrorInqTextA(void) { char bufferInvalid [1024]; - char buffer [1024]; /* The required size is not documented but would - * appear to be 256. - */ + char buffer [1024]; DWORD dwCount; + RPC_STATUS status; dwCount = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, RPC_S_NOT_RPC_ERROR, 0, bufferInvalid, ARRAY_SIZE(bufferInvalid), NULL); + ok(dwCount, "Cannot set up for DceErrorInqText\n"); - /* A random sample of DceErrorInqText */ /* 0 is success */ - ok ((DceErrorInqTextA (0, (unsigned char*)buffer) == RPC_S_OK), - "DceErrorInqTextA(0...)\n"); - /* A real RPC_S error */ - ok ((DceErrorInqTextA (RPC_S_INVALID_STRING_UUID, (unsigned char*)buffer) == RPC_S_OK), - "DceErrorInqTextA(valid...)\n"); + status = DceErrorInqTextA(0, (unsigned char*)buffer); + ok(status == RPC_S_OK, "got %lx\n", status); - if (dwCount) - { - /* A message for which FormatMessage should fail - * which should return RPC_S_OK and the - * fixed "not valid" message - */ - ok ((DceErrorInqTextA (35, (unsigned char*)buffer) == RPC_S_OK && - strcmp (buffer, bufferInvalid) == 0), - "DceErrorInqTextA(unformattable...)\n"); - /* One for which FormatMessage should succeed but - * DceErrorInqText should "fail" - * 3814 is generally quite a long message - */ - ok ((DceErrorInqTextA (3814, (unsigned char*)buffer) == RPC_S_OK && - strcmp (buffer, bufferInvalid) == 0), - "DceErrorInqTextA(deviation...)\n"); - } - else - ok (0, "Cannot set up for DceErrorInqText\n"); + /* A real RPC_S error */ + status = DceErrorInqTextA(RPC_S_INVALID_STRING_UUID, (unsigned char*)buffer); + ok(status == RPC_S_OK, "got %lx\n", status); + + /* A message for which FormatMessage should fail which should return RPC_S_OK and the + * fixed "not valid" message */ + status = DceErrorInqTextA(35, (unsigned char*)buffer); + ok(status == RPC_S_OK, "got %lx\n", status); + ok(!strcmp(buffer, bufferInvalid), "got %s vs %s\n", wine_dbgstr_a(buffer), wine_dbgstr_a(bufferInvalid)); } static RPC_DISPATCH_FUNCTION IFoo_table[] = @@ -228,48 +232,48 @@ static void test_rpc_ncacn_ip_tcp(void) status = RpcMgmtStopServerListening(NULL); ok(status == RPC_S_NOT_LISTENING, - "wrong RpcMgmtStopServerListening error (%u)\n", status); + "wrong RpcMgmtStopServerListening error (%lu)\n", status); status = RpcMgmtWaitServerListen(); ok(status == RPC_S_NOT_LISTENING, - "wrong RpcMgmtWaitServerListen error status (%u)\n", status); + "wrong RpcMgmtWaitServerListen error status (%lu)\n", status); status = RpcServerListen(1, 20, FALSE); ok(status == RPC_S_NO_PROTSEQS_REGISTERED, - "wrong RpcServerListen error (%u)\n", status); + "wrong RpcServerListen error (%lu)\n", status); status = RpcServerUseProtseqEpA(ncacn_ip_tcp, 20, endpoint, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseqEp failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseqEp failed (%lu)\n", status); status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIf failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed (%lu)\n", status); status = RpcServerListen(1, 20, TRUE); - ok(status == RPC_S_OK, "RpcServerListen failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcServerListen failed (%lu)\n", status); status = RpcServerListen(1, 20, TRUE); ok(status == RPC_S_ALREADY_LISTENING, - "wrong RpcServerListen error (%u)\n", status); + "wrong RpcServerListen error (%lu)\n", status); status = RpcStringBindingComposeA(NULL, ncacn_ip_tcp, address, endpoint, NULL, &binding); - ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%lu)\n", status); status = RpcBindingFromStringBindingA(binding, &IFoo_IfHandle); - ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%u)\n", + ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%lu)\n", status); status = RpcBindingSetAuthInfoA(IFoo_IfHandle, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_AUTHN_WINNT, NULL, RPC_C_AUTHZ_NAME); - ok(status == RPC_S_OK, "RpcBindingSetAuthInfo failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcBindingSetAuthInfo failed (%lu)\n", status); status = RpcBindingInqAuthInfoA(IFoo_IfHandle, NULL, NULL, NULL, NULL, NULL); - ok(status == RPC_S_BINDING_HAS_NO_AUTH, "RpcBindingInqAuthInfo failed (%u)\n", + ok(status == RPC_S_BINDING_HAS_NO_AUTH, "RpcBindingInqAuthInfo failed (%lu)\n", status); status = RpcBindingSetAuthInfoA(IFoo_IfHandle, spn, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_AUTHN_WINNT, NULL, RPC_C_AUTHZ_NAME); - ok(status == RPC_S_OK, "RpcBindingSetAuthInfo failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcBindingSetAuthInfo failed (%lu)\n", status); level = authnsvc = authzsvc = 0; principal = (unsigned char *)0xdeadbeef; @@ -277,33 +281,33 @@ static void test_rpc_ncacn_ip_tcp(void) status = RpcBindingInqAuthInfoA(IFoo_IfHandle, &principal, &level, &authnsvc, &identity, &authzsvc); - ok(status == RPC_S_OK, "RpcBindingInqAuthInfo failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcBindingInqAuthInfo failed (%lu)\n", status); ok(identity == NULL, "expected NULL identity, got %p\n", identity); ok(principal != (unsigned char *)0xdeadbeef, "expected valid principal, got %p\n", principal); - ok(level == RPC_C_AUTHN_LEVEL_PKT_PRIVACY, "expected RPC_C_AUTHN_LEVEL_PKT_PRIVACY, got %d\n", level); - ok(authnsvc == RPC_C_AUTHN_WINNT, "expected RPC_C_AUTHN_WINNT, got %d\n", authnsvc); - todo_wine ok(authzsvc == RPC_C_AUTHZ_NAME, "expected RPC_C_AUTHZ_NAME, got %d\n", authzsvc); + ok(level == RPC_C_AUTHN_LEVEL_PKT_PRIVACY, "expected RPC_C_AUTHN_LEVEL_PKT_PRIVACY, got %ld\n", level); + ok(authnsvc == RPC_C_AUTHN_WINNT, "expected RPC_C_AUTHN_WINNT, got %ld\n", authnsvc); + todo_wine ok(authzsvc == RPC_C_AUTHZ_NAME, "expected RPC_C_AUTHZ_NAME, got %ld\n", authzsvc); if (status == RPC_S_OK) RpcStringFreeA(&principal); status = RpcMgmtStopServerListening(NULL); - ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%u)\n", + ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%lu)\n", status); status = RpcMgmtStopServerListening(NULL); - ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%u)\n", + ok(status == RPC_S_OK, "RpcMgmtStopServerListening failed (%lu)\n", status); status = RpcServerUnregisterIf(NULL, NULL, FALSE); - ok(status == RPC_S_OK, "RpcServerUnregisterIf failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcServerUnregisterIf failed (%lu)\n", status); status = RpcMgmtWaitServerListen(); - ok(status == RPC_S_OK, "RpcMgmtWaitServerListen failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcMgmtWaitServerListen failed (%lu)\n", status); status = RpcStringFreeA(&binding); - ok(status == RPC_S_OK, "RpcStringFree failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcStringFree failed (%lu)\n", status); status = RpcBindingFree(&IFoo_IfHandle); - ok(status == RPC_S_OK, "RpcBindingFree failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcBindingFree failed (%lu)\n", status); } /* this is what's generated with MS/RPC - it includes an extra 2 @@ -349,7 +353,7 @@ static void test_towers(void) ret = TowerConstruct(&mapi_if_id, &ndr_syntax, "ncacn_ip_tcp", "135", "10.0.0.1", &tower); ok(ret == RPC_S_OK || broken(ret == RPC_S_INVALID_RPC_PROTSEQ), /* Vista */ - "TowerConstruct failed with error %d\n", ret); + "TowerConstruct failed with error %ld\n", ret); if (ret == RPC_S_INVALID_RPC_PROTSEQ) { /* Windows Vista fails with this error and crashes if we continue */ @@ -382,7 +386,7 @@ static void test_towers(void) } ret = TowerExplode(tower, &object, &syntax, &protseq, &endpoint, &address); - ok(ret == RPC_S_OK, "TowerExplode failed with error %d\n", ret); + ok(ret == RPC_S_OK, "TowerExplode failed with error %ld\n", ret); ok(!memcmp(&object, &mapi_if_id, sizeof(mapi_if_id)), "object id didn't match\n"); ok(!memcmp(&syntax, &ndr_syntax, sizeof(syntax)), "syntax id didn't match\n"); ok(!strcmp(protseq, "ncacn_ip_tcp"), "protseq was \"%s\" instead of \"ncacn_ip_tcp\"\n", protseq); @@ -394,15 +398,15 @@ static void test_towers(void) I_RpcFree(address); ret = TowerExplode(tower, NULL, NULL, NULL, NULL, NULL); - ok(ret == RPC_S_OK, "TowerExplode failed with error %d\n", ret); + ok(ret == RPC_S_OK, "TowerExplode failed with error %ld\n", ret); I_RpcFree(tower); /* test the behaviour for ip_tcp with name instead of dotted IP notation */ ret = TowerConstruct(&mapi_if_id, &ndr_syntax, "ncacn_ip_tcp", "135", "localhost", &tower); - ok(ret == RPC_S_OK, "TowerConstruct failed with error %d\n", ret); + ok(ret == RPC_S_OK, "TowerConstruct failed with error %ld\n", ret); ret = TowerExplode(tower, NULL, NULL, NULL, NULL, &address); - ok(ret == RPC_S_OK, "TowerExplode failed with error %d\n", ret); + ok(ret == RPC_S_OK, "TowerExplode failed with error %ld\n", ret); ok(!strcmp(address, "0.0.0.0") || broken(!strcmp(address, "255.255.255.255")), "address was \"%s\" instead of \"0.0.0.0\"\n", address); @@ -412,11 +416,11 @@ static void test_towers(void) /* test the behaviour for np with no address */ ret = TowerConstruct(&mapi_if_id, &ndr_syntax, "ncacn_np", "\\pipe\\test", NULL, &tower); - ok(ret == RPC_S_OK, "TowerConstruct failed with error %d\n", ret); + ok(ret == RPC_S_OK, "TowerConstruct failed with error %ld\n", ret); ret = TowerExplode(tower, NULL, NULL, NULL, NULL, &address); ok(ret == RPC_S_OK || broken(ret != RPC_S_OK), /* win2k, indeterminate */ - "TowerExplode failed with error %d\n", ret); + "TowerExplode failed with error %ld\n", ret); /* Windows XP SP3 sets address to NULL */ ok(!address || !strcmp(address, ""), "address was \"%s\" instead of \"\" or NULL (XP SP3)\n", address); @@ -562,7 +566,7 @@ static void test_I_RpcMapWin32Status(void) ok(win32status == expected_win32status || broken(missing && win32status == rpc_status), - "I_RpcMapWin32Status(%d) should have returned 0x%x instead of 0x%x%s\n", + "I_RpcMapWin32Status(%ld) should have returned 0x%lx instead of 0x%lx%s\n", rpc_status, expected_win32status, win32status, broken(missing) ? " (or have returned with the given status)" : ""); } @@ -584,7 +588,7 @@ static void test_RpcStringBindingParseA(void) /* test all parameters */ status = RpcStringBindingParseA(valid_binding, &uuid, &protseq, &network_addr, &endpoint, &options); - ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %d\n", status); + ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status); ok(!strcmp((char *)uuid, "00000000-0000-0000-c000-000000000046"), "uuid should have been 00000000-0000-0000-C000-000000000046 instead of %s\n", uuid); ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq); ok(!strcmp((char *)network_addr, "."), "network_addr should have been . instead of %s\n", network_addr); @@ -601,7 +605,7 @@ static void test_RpcStringBindingParseA(void) /* test all parameters with different type of string binding */ status = RpcStringBindingParseA(valid_binding2, &uuid, &protseq, &network_addr, &endpoint, &options); - ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %d\n", status); + ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status); ok(!strcmp((char *)uuid, "00000000-0000-0000-c000-000000000046"), "uuid should have been 00000000-0000-0000-C000-000000000046 instead of %s\n", uuid); ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq); ok(!strcmp((char *)network_addr, "."), "network_addr should have been . instead of %s\n", network_addr); @@ -618,27 +622,30 @@ static void test_RpcStringBindingParseA(void) /* test with as many parameters NULL as possible */ status = RpcStringBindingParseA(valid_binding, NULL, &protseq, NULL, NULL, NULL); - ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %d\n", status); + ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status); ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq); RpcStringFreeA(&protseq); /* test with invalid uuid */ status = RpcStringBindingParseA(invalid_uuid_binding, NULL, &protseq, NULL, NULL, NULL); - ok(status == RPC_S_INVALID_STRING_UUID, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_UUID instead of %d\n", status); + ok(status == RPC_S_INVALID_STRING_UUID, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_UUID instead of %ld\n", status); ok(protseq == NULL, "protseq was %p instead of NULL\n", protseq); /* test with invalid endpoint */ status = RpcStringBindingParseA(invalid_ep_binding, NULL, &protseq, NULL, NULL, NULL); - ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %d\n", status); + ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status); RpcStringFreeA(&protseq); /* test with invalid binding */ status = RpcStringBindingParseA(invalid_binding, &uuid, &protseq, &network_addr, &endpoint, &options); - ok(status == RPC_S_INVALID_STRING_BINDING, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_BINDING instead of %d\n", status); + todo_wine + ok(status == RPC_S_INVALID_STRING_BINDING, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_BINDING instead of %ld\n", status); + todo_wine ok(uuid == NULL, "uuid was %p instead of NULL\n", uuid); if (uuid) RpcStringFreeA(&uuid); ok(protseq == NULL, "protseq was %p instead of NULL\n", protseq); + todo_wine ok(network_addr == NULL, "network_addr was %p instead of NULL\n", network_addr); if (network_addr) RpcStringFreeA(&network_addr); @@ -646,17 +653,10 @@ static void test_RpcStringBindingParseA(void) ok(options == NULL, "options was %p instead of NULL\n", options); } -static void test_RpcExceptionFilter(const char *func_name) +static void test_RpcExceptionFilter(void) { + int retval, retval2; ULONG exception; - int retval; - int (WINAPI *pRpcExceptionFilter)(ULONG) = (void *)GetProcAddress(GetModuleHandleA("rpcrt4.dll"), func_name); - - if (!pRpcExceptionFilter) - { - win_skip("%s not exported\n", func_name); - return; - } for (exception = 0; exception < STATUS_REG_NAT_CONSUMPTION; exception++) { @@ -665,7 +665,8 @@ static void test_RpcExceptionFilter(const char *func_name) if (exception == 0x40000005) exception = 0x80000000; if (exception == 0x80000005) exception = 0xc0000000; - retval = pRpcExceptionFilter(exception); + retval = RpcExceptionFilter(exception); + retval2 = I_RpcExceptionFilter(exception); switch (exception) { case STATUS_DATATYPE_MISALIGNMENT: @@ -676,17 +677,25 @@ static void test_RpcExceptionFilter(const char *func_name) case STATUS_INSTRUCTION_MISALIGNMENT: case STATUS_STACK_OVERFLOW: case STATUS_POSSIBLE_DEADLOCK: - ok(retval == EXCEPTION_CONTINUE_SEARCH, "%s(0x%x) should have returned %d instead of %d\n", - func_name, exception, EXCEPTION_CONTINUE_SEARCH, retval); + ok(retval == EXCEPTION_CONTINUE_SEARCH, "RpcExceptionFilter(0x%lx) should have returned %d instead of %d\n", + exception, EXCEPTION_CONTINUE_SEARCH, retval); + ok(retval2 == EXCEPTION_CONTINUE_SEARCH, "I_RpcExceptionFilter(0x%lx) should have returned %d instead of %d\n", + exception, EXCEPTION_CONTINUE_SEARCH, retval); break; case STATUS_GUARD_PAGE_VIOLATION: case STATUS_IN_PAGE_ERROR: case STATUS_HANDLE_NOT_CLOSABLE: - trace("%s(0x%x) returned %d\n", func_name, exception, retval); + todo_wine + { + ok(!retval, "Unexpected return value %d.\n", retval); + ok(!retval2, "Unexpected return value %d.\n", retval2); + } break; default: - ok(retval == EXCEPTION_EXECUTE_HANDLER, "%s(0x%x) should have returned %d instead of %d\n", - func_name, exception, EXCEPTION_EXECUTE_HANDLER, retval); + ok(retval == EXCEPTION_EXECUTE_HANDLER, "RpcExceptionFilter(0x%lx) should have returned %d instead of %d\n", + exception, EXCEPTION_EXECUTE_HANDLER, retval); + ok(retval2 == EXCEPTION_EXECUTE_HANDLER, "I_RpcExceptionFilter(0x%lx) should have returned %d instead of %d\n", + exception, EXCEPTION_EXECUTE_HANDLER, retval); } } } @@ -702,21 +711,21 @@ static void test_RpcStringBindingFromBinding(void) status = RpcStringBindingComposeA(NULL, ncacn_np, address, endpoint, NULL, &binding); - ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcStringBindingCompose failed (%lu)\n", status); status = RpcBindingFromStringBindingA(binding, &handle); - ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%u)\n", status); + ok(status == RPC_S_OK, "RpcBindingFromStringBinding failed (%lu)\n", status); RpcStringFreeA(&binding); status = RpcBindingToStringBindingA(handle, &binding); - ok(status == RPC_S_OK, "RpcStringBindingFromBinding failed with error %u\n", status); + ok(status == RPC_S_OK, "RpcStringBindingFromBinding failed with error %lu\n", status); ok(!strcmp((const char *)binding, "ncacn_np:.[\\\\pipe\\\\wine_rpc_test]"), "binding string didn't match what was expected: \"%s\"\n", binding); RpcStringFreeA(&binding); status = RpcBindingFree(&handle); - ok(status == RPC_S_OK, "RpcBindingFree failed with error %u\n", status); + ok(status == RPC_S_OK, "RpcBindingFree failed with error %lu\n", status); } static void test_UuidCreate(void) @@ -793,7 +802,7 @@ static void test_UuidCreateSequential(void) ret = pUuidCreateSequential(&guid1); ok(!ret || ret == RPC_S_UUID_LOCAL_ONLY, - "expected RPC_S_OK or RPC_S_UUID_LOCAL_ONLY, got %08x\n", ret); + "expected RPC_S_OK or RPC_S_UUID_LOCAL_ONLY, got %08lx\n", ret); version = (guid1.Data3 & 0xf000) >> 12; ok(version == 1, "unexpected version %d\n", version); if (version == 1) @@ -823,7 +832,7 @@ static void test_UuidCreateSequential(void) */ ret = pUuidCreateSequential(&guid2); ok(!ret || ret == RPC_S_UUID_LOCAL_ONLY, - "expected RPC_S_OK or RPC_S_UUID_LOCAL_ONLY, got %08x\n", ret); + "expected RPC_S_OK or RPC_S_UUID_LOCAL_ONLY, got %08lx\n", ret); version = (guid2.Data3 & 0xf000) >> 12; ok(version == 1, "unexpected version %d\n", version); ok(!memcmp(guid1.Data4, guid2.Data4, sizeof(guid2.Data4)), @@ -847,10 +856,11 @@ static void test_RpcBindingFree(void) status = RpcBindingFree(&binding); ok(status == RPC_S_INVALID_BINDING, - "RpcBindingFree should have returned RPC_S_INVALID_BINDING instead of %d\n", + "RpcBindingFree should have returned RPC_S_INVALID_BINDING instead of %ld\n", status); } +#ifdef __REACTOS__ static void test_RpcStringFree(void) { RPC_WSTR string = NULL; @@ -866,6 +876,56 @@ static void test_RpcStringFree(void) ok(string == NULL, "String is %p expected NULL!\n", string); } +#endif + +static void test_RpcIfInqId(void) +{ + static const GUID guid = {0x12345678, 0xdead, 0xbeef, {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}}; + static RPC_STATUS (WINAPI *pRpcIfInqId)(RPC_IF_HANDLE, RPC_IF_ID *); + RPC_SERVER_INTERFACE server_interface; + RPC_CLIENT_INTERFACE client_interface; + RPC_IF_HANDLE test_handles[2]; + RPC_STATUS status; + RPC_IF_ID if_id; + UINT test_idx; + + pRpcIfInqId = (void *)GetProcAddress(GetModuleHandleA("rpcrt4.dll"), "RpcIfInqId"); + + memset(&server_interface, 0, sizeof(server_interface)); + memset(&client_interface, 0, sizeof(client_interface)); + server_interface.InterfaceId.SyntaxGUID = guid; + server_interface.InterfaceId.SyntaxVersion.MajorVersion = 1; + server_interface.InterfaceId.SyntaxVersion.MinorVersion = 2; + client_interface.InterfaceId.SyntaxGUID = guid; + client_interface.InterfaceId.SyntaxVersion.MajorVersion = 1; + client_interface.InterfaceId.SyntaxVersion.MinorVersion = 2; + + /* Crash on Windows */ + if (0) + { + status = pRpcIfInqId(NULL, &if_id); + ok(status == RPC_S_INVALID_ARG, "Expected %#x, got %#lx.\n", RPC_S_INVALID_ARG, status); + + status = pRpcIfInqId((RPC_IF_HANDLE)&server_interface, NULL); + ok(status == RPC_S_INVALID_ARG, "Expected %#x, got %#lx.\n", RPC_S_INVALID_ARG, status); + } + + test_handles[0] = (RPC_IF_HANDLE)&server_interface; + test_handles[1] = (RPC_IF_HANDLE)&client_interface; + + for (test_idx = 0; test_idx < ARRAY_SIZE(test_handles); ++test_idx) + { + memset(&if_id, 0, sizeof(if_id)); + status = pRpcIfInqId(test_handles[test_idx], &if_id); + ok(status == RPC_S_OK, "Test %u: Expected %#x, got %#lx.\n", test_idx, RPC_S_OK, status); + ok(!memcmp(&if_id.Uuid, &guid, sizeof(guid)), "Test %u: Expected UUID %s, got %s.\n", test_idx, + wine_dbgstr_guid(&guid), wine_dbgstr_guid(&if_id.Uuid)); + ok(if_id.VersMajor == 1, "Test %u: Expected major version 1, got %hu.\n", test_idx, + if_id.VersMajor); + ok(if_id.VersMinor == 2, "Test %u: Expected minor version 2, got %hu.\n", test_idx, + if_id.VersMinor); + } +} static void test_RpcServerInqDefaultPrincName(void) { @@ -875,42 +935,42 @@ static void test_RpcServerInqDefaultPrincName(void) ULONG len = 0; GetUserNameExA( NameSamCompatible, NULL, &len ); - username = HeapAlloc( GetProcessHeap(), 0, len ); + username = malloc( len ); GetUserNameExA( NameSamCompatible, username, &len ); ret = RpcServerInqDefaultPrincNameA( 0, NULL ); - ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %u\n", ret ); + ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %lu\n", ret ); ret = RpcServerInqDefaultPrincNameA( RPC_C_AUTHN_DEFAULT, NULL ); - ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %u\n", ret ); + ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %lu\n", ret ); principal = (RPC_CSTR)0xdeadbeef; ret = RpcServerInqDefaultPrincNameA( RPC_C_AUTHN_DEFAULT, &principal ); - ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %u\n", ret ); + ok( ret == RPC_S_UNKNOWN_AUTHN_SERVICE, "got %lu\n", ret ); ok( principal == (RPC_CSTR)0xdeadbeef, "got unexpected principal\n" ); saved_principal = (RPC_CSTR)0xdeadbeef; ret = RpcServerInqDefaultPrincNameA( RPC_C_AUTHN_WINNT, &saved_principal ); - ok( ret == RPC_S_OK, "got %u\n", ret ); + ok( ret == RPC_S_OK, "got %lu\n", ret ); ok( saved_principal != (RPC_CSTR)0xdeadbeef, "expected valid principal\n" ); ok( !strcmp( (const char *)saved_principal, username ), "got \'%s\'\n", saved_principal ); trace("%s\n", saved_principal); ret = RpcServerRegisterAuthInfoA( (RPC_CSTR)"wine\\test", RPC_C_AUTHN_WINNT, NULL, NULL ); - ok( ret == RPC_S_OK, "got %u\n", ret ); + ok( ret == RPC_S_OK, "got %lu\n", ret ); principal = (RPC_CSTR)0xdeadbeef; ret = RpcServerInqDefaultPrincNameA( RPC_C_AUTHN_WINNT, &principal ); - ok( ret == RPC_S_OK, "got %u\n", ret ); + ok( ret == RPC_S_OK, "got %lu\n", ret ); ok( principal != (RPC_CSTR)0xdeadbeef, "expected valid principal\n" ); ok( !strcmp( (const char *)principal, username ), "got \'%s\'\n", principal ); RpcStringFreeA( &principal ); ret = RpcServerRegisterAuthInfoA( saved_principal, RPC_C_AUTHN_WINNT, NULL, NULL ); - ok( ret == RPC_S_OK, "got %u\n", ret ); + ok( ret == RPC_S_OK, "got %lu\n", ret ); RpcStringFreeA( &saved_principal ); - HeapFree( GetProcessHeap(), 0, username ); + free( username ); } static void test_RpcServerRegisterAuthInfo(void) @@ -918,7 +978,7 @@ static void test_RpcServerRegisterAuthInfo(void) RPC_STATUS status; status = RpcServerRegisterAuthInfoW(NULL, 600, NULL, NULL); - ok(status == RPC_S_UNKNOWN_AUTHN_SERVICE, "status = %x\n", status); + ok(status == RPC_S_UNKNOWN_AUTHN_SERVICE, "status = %lx\n", status); } static void test_RpcServerUseProtseq(void) @@ -941,12 +1001,12 @@ static void test_RpcServerUseProtseq(void) else { binding_count_before = bindings->Count; - ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %ld\n", status); for (i = 0; i < bindings->Count; i++) { RPC_CSTR str_bind; status = RpcBindingToStringBindingA(bindings->BindingH[i], &str_bind); - ok(status == RPC_S_OK, "RpcBindingToStringBinding failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcBindingToStringBinding failed with status %ld\n", status); if (lstrlenA((const char *)str_bind) > 12 && !memcmp(str_bind, "ncacn_ip_tcp", 12)) iptcp_registered = TRUE; if (lstrlenA((const char *)str_bind) > 8 && !memcmp(str_bind, "ncacn_np", 8)) @@ -962,7 +1022,7 @@ static void test_RpcServerUseProtseq(void) * RpcServerUseProtseq(...) */ status = RpcServerUseProtseqEpA(ncalrpc, 0, NULL, NULL); ok(status == RPC_S_OK || broken(status == RPC_S_INVALID_ENDPOINT_FORMAT), - "RpcServerUseProtseqEp with NULL endpoint failed with status %d\n", + "RpcServerUseProtseqEp with NULL endpoint failed with status %ld\n", status); /* register protocol sequences without explicit endpoints */ @@ -970,28 +1030,28 @@ static void test_RpcServerUseProtseq(void) if (status == RPC_S_PROTSEQ_NOT_SUPPORTED) win_skip("ncacn_np not supported\n"); else - ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %ld\n", status); if (status == RPC_S_OK && !np_registered) endpoints_registered++; status = RpcServerUseProtseqA(iptcp, 0, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %ld\n", status); if (status == RPC_S_OK && !iptcp_registered) endpoints_registered++; status = RpcServerUseProtseqA(ncalrpc, 0, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %ld\n", status); if (status == RPC_S_OK && !ncalrpc_registered) endpoints_registered++; status = RpcServerInqBindings(&bindings); - ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %ld\n", status); binding_count_after1 = bindings->Count; ok(binding_count_after1 == binding_count_before + endpoints_registered, - "wrong binding count - before: %u, after %u, endpoints registered %u\n", + "wrong binding count - before: %lu, after %lu, endpoints registered %lu\n", binding_count_before, binding_count_after1, endpoints_registered); for (i = 0; i < bindings->Count; i++) { RPC_CSTR str_bind; status = RpcBindingToStringBindingA(bindings->BindingH[i], &str_bind); - ok(status == RPC_S_OK, "RpcBindingToStringBinding failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcBindingToStringBinding failed with status %ld\n", status); trace("string binding: %s\n", str_bind); RpcStringFreeA(&str_bind); } @@ -1002,19 +1062,19 @@ static void test_RpcServerUseProtseq(void) if (status == RPC_S_PROTSEQ_NOT_SUPPORTED) win_skip("ncacn_np not supported\n"); else - ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %ld\n", status); status = RpcServerUseProtseqA(iptcp, 0, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %ld\n", status); status = RpcServerUseProtseqA(ncalrpc, 0, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %ld\n", status); status = RpcServerInqBindings(&bindings); - ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %ld\n", status); binding_count_after2 = bindings->Count; ok(binding_count_after2 == binding_count_after1, - "bindings should have been re-used - after1: %u after2: %u\n", + "bindings should have been re-used - after1: %lu after2: %lu\n", binding_count_after1, binding_count_after2); RpcBindingVectorFree(&bindings); } @@ -1028,48 +1088,48 @@ static void test_endpoint_mapper(RPC_CSTR protseq, RPC_CSTR address) unsigned char *binding; status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL); - ok(status == RPC_S_OK, "%s: RpcServerRegisterIf failed (%u)\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcServerRegisterIf failed (%lu)\n", protseq, status); status = RpcServerInqBindings(&binding_vector); - ok(status == RPC_S_OK, "%s: RpcServerInqBindings failed with error %u\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcServerInqBindings failed with error %lu\n", protseq, status); /* register endpoints created in test_RpcServerUseProtseq */ status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, annotation); - ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %lu\n", protseq, status); /* reregister the same endpoint with no annotation */ status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, NULL); - ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %lu\n", protseq, status); status = RpcStringBindingComposeA(NULL, protseq, address, NULL, NULL, &binding); - ok(status == RPC_S_OK, "%s: RpcStringBindingCompose failed (%u)\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcStringBindingCompose failed (%lu)\n", protseq, status); status = RpcBindingFromStringBindingA(binding, &handle); - ok(status == RPC_S_OK, "%s: RpcBindingFromStringBinding failed (%u)\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcBindingFromStringBinding failed (%lu)\n", protseq, status); RpcStringFreeA(&binding); status = RpcBindingReset(handle); - ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %lu\n", protseq, status); status = RpcEpResolveBinding(handle, IFoo_v0_0_s_ifspec); ok(status == RPC_S_OK || broken(status == RPC_S_SERVER_UNAVAILABLE), /* win9x */ - "%s: RpcEpResolveBinding failed with error %u\n", protseq, status); + "%s: RpcEpResolveBinding failed with error %lu\n", protseq, status); status = RpcBindingReset(handle); - ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %lu\n", protseq, status); status = RpcBindingFree(&handle); - ok(status == RPC_S_OK, "%s: RpcBindingFree failed with error %u\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcBindingFree failed with error %lu\n", protseq, status); status = RpcServerUnregisterIf(NULL, NULL, FALSE); - ok(status == RPC_S_OK, "%s: RpcServerUnregisterIf failed (%u)\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcServerUnregisterIf failed (%lu)\n", protseq, status); status = RpcEpUnregister(IFoo_v0_0_s_ifspec, binding_vector, NULL); - ok(status == RPC_S_OK, "%s: RpcEpUnregisterA failed with error %u\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcEpUnregisterA failed with error %lu\n", protseq, status); status = RpcBindingVectorFree(&binding_vector); - ok(status == RPC_S_OK, "%s: RpcBindingVectorFree failed with error %u\n", protseq, status); + ok(status == RPC_S_OK, "%s: RpcBindingVectorFree failed with error %lu\n", protseq, status); } static BOOL is_process_elevated(void) @@ -1100,18 +1160,18 @@ static BOOL is_firewall_enabled(void) hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr, (void **)&mgr ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwMgr_get_LocalPolicy( mgr, &policy ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwPolicy_get_CurrentProfile( policy, &profile ); if (hr != S_OK) goto done; hr = INetFwProfile_get_FirewallEnabled( profile, &enabled ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); done: if (policy) INetFwPolicy_Release( policy ); @@ -1129,7 +1189,6 @@ enum firewall_op static HRESULT set_firewall( enum firewall_op op ) { - static const WCHAR testW[] = {'r','p','c','r','t','4','_','t','e','s','t',0}; HRESULT hr, init; INetFwMgr *mgr = NULL; INetFwPolicy *policy = NULL; @@ -1147,32 +1206,32 @@ static HRESULT set_firewall( enum firewall_op op ) hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr, (void **)&mgr ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwMgr_get_LocalPolicy( mgr, &policy ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwPolicy_get_CurrentProfile( policy, &profile ); if (hr != S_OK) goto done; hr = INetFwProfile_get_AuthorizedApplications( profile, &apps ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = CoCreateInstance( &CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwAuthorizedApplication, (void **)&app ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwAuthorizedApplication_put_ProcessImageFileName( app, image ); if (hr != S_OK) goto done; - name = SysAllocString( testW ); + name = SysAllocString( L"rpcrt4_test" ); hr = INetFwAuthorizedApplication_put_Name( app, name ); SysFreeString( name ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; if (op == APP_ADD) @@ -1200,24 +1259,28 @@ START_TEST( rpc ) static unsigned char np_address[] = "."; BOOL firewall_enabled = is_firewall_enabled(); + test_UuidEqual(); + test_UuidFromString(); + test_UuidCreate(); + test_UuidCreateSequential(); + test_DceErrorInqTextA(); + test_I_RpcMapWin32Status(); + test_RpcStringBindingParseA(); + test_RpcExceptionFilter(); + if (firewall_enabled && !is_process_elevated()) { skip("no privileges, skipping tests to avoid firewall dialog\n"); return; } - UuidConversionAndComparison(); - TestDceErrorInqText(); test_towers(); - test_I_RpcMapWin32Status(); - test_RpcStringBindingParseA(); - test_RpcExceptionFilter("I_RpcExceptionFilter"); - test_RpcExceptionFilter("RpcExceptionFilter"); test_RpcStringBindingFromBinding(); - test_UuidCreate(); - test_UuidCreateSequential(); test_RpcBindingFree(); +#ifdef __REACTOS__ test_RpcStringFree(); +#endif + test_RpcIfInqId(); test_RpcServerInqDefaultPrincName(); test_RpcServerRegisterAuthInfo(); @@ -1226,7 +1289,7 @@ START_TEST( rpc ) HRESULT hr = set_firewall(APP_ADD); if (hr != S_OK) { - skip("can't authorize app in firewall %08x\n", hr); + skip("can't authorize app in firewall %08lx\n", hr); return; } } diff --git a/modules/rostests/winetests/rpcrt4/rpc_async.c b/modules/rostests/winetests/rpcrt4/rpc_async.c index 15c57fefb57..0552560bf06 100644 --- a/modules/rostests/winetests/rpcrt4/rpc_async.c +++ b/modules/rostests/winetests/rpcrt4/rpc_async.c @@ -34,27 +34,27 @@ static void test_RpcAsyncInitializeHandle(void) void *unset_ptr; status = RpcAsyncInitializeHandle((PRPC_ASYNC_STATE)buffer, sizeof(buffer)); - ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with large Size should have returned ERROR_INVALID_PARAMETER instead of %d\n", status); + ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with large Size should have returned ERROR_INVALID_PARAMETER instead of %ld\n", status); status = RpcAsyncInitializeHandle(&async, sizeof(async) - 1); - ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with small Size should have returned ERROR_INVALID_PARAMETER instead of %d\n", status); + ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with small Size should have returned ERROR_INVALID_PARAMETER instead of %ld\n", status); memset(&async, 0xcc, sizeof(async)); memset(&unset_ptr, 0xcc, sizeof(unset_ptr)); status = RpcAsyncInitializeHandle(&async, sizeof(async)); - ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %d\n", status); + ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %ld\n", status); ok(async.Size == sizeof(async), "async.Size wrong: %d\n", async.Size); - ok(async.Signature == 0x43595341, "async.Signature should be 0x43595341, but is 0x%x instead\n", async.Signature); - ok(async.Lock == 0, "async.Lock should be 0, but is %d instead\n", async.Lock); - ok(async.Flags == 0, "async.Flags should be 0, but is %d instead\n", async.Flags); + ok(async.Signature == 0x43595341, "async.Signature should be 0x43595341, but is 0x%lx instead\n", async.Signature); + ok(async.Lock == 0, "async.Lock should be 0, but is %ld instead\n", async.Lock); + ok(async.Flags == 0, "async.Flags should be 0, but is %ld instead\n", async.Flags); ok(async.StubInfo == NULL, "async.StubInfo should be NULL, not %p\n", async.StubInfo); ok(async.UserInfo == unset_ptr, "async.UserInfo should be unset, not %p\n", async.UserInfo); ok(async.RuntimeInfo == NULL, "async.RuntimeInfo should be NULL, not %p\n", async.RuntimeInfo); ok(async.Event == 0xcccccccc, "async.Event should be unset, not %d\n", async.Event); ok(async.NotificationType == 0xcccccccc, "async.NotificationType should be unset, not %d\n", async.NotificationType); for (i = 0; i < 4; i++) - ok(async.Reserved[i] == 0x0, "async.Reserved[%d] should be 0x0, not 0x%lx\n", i, async.Reserved[i]); + ok(async.Reserved[i] == 0x0, "async.Reserved[%d] should be 0x0, not 0x%Ix\n", i, async.Reserved[i]); } static void test_RpcAsyncGetCallStatus(void) @@ -63,16 +63,16 @@ static void test_RpcAsyncGetCallStatus(void) RPC_STATUS status; status = RpcAsyncInitializeHandle(&async, sizeof(async)); - ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %d\n", status); + ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %ld\n", status); status = RpcAsyncGetCallStatus(&async); todo_wine - ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %d\n", status); + ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %ld\n", status); memset(&async, 0, sizeof(async)); status = RpcAsyncGetCallStatus(&async); todo_wine - ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %d\n", status); + ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %ld\n", status); } START_TEST( rpc_async ) diff --git a/modules/rostests/winetests/rpcrt4/server.c b/modules/rostests/winetests/rpcrt4/server.c index 0622e81877b..2aeec176d3a 100644 --- a/modules/rostests/winetests/rpcrt4/server.c +++ b/modules/rostests/winetests/rpcrt4/server.c @@ -30,6 +30,7 @@ #define SKIP_TYPE_DECLS #include "server_interp_s.h" #include "server_defines.h" +#include "explicit_handle.h" #include #include @@ -40,10 +41,11 @@ #define INT_CODE 4198 -static const char *progname; +static const char *progname, *client_test_name; static BOOL old_windows_version; static HANDLE stop_event, stop_wait_event; +static PROCESS_INFORMATION client_info; static void (WINAPI *pNDRSContextMarshall2)(RPC_BINDING_HANDLE, NDR_SCONTEXT, void*, NDR_RUNDOWN, void*, ULONG); static NDR_SCONTEXT (WINAPI *pNDRSContextUnmarshall2)(RPC_BINDING_HANDLE, void*, ULONG, void*, ULONG); @@ -66,6 +68,20 @@ static hyper (__cdecl *sum_hyper)(hyper x, hyper y); static int (__cdecl *sum_hyper_int)(hyper x, hyper y); static int (__cdecl *sum_char_hyper)(signed char x, hyper y); static void (__cdecl *square_out)(int x, int *y); +static int (__cdecl *sum_chars)(int a, chars_t x, chars_t y); +static int (__cdecl *sum_ints)(int a, ints_t x, ints_t y); +static int (__cdecl *sum_flts)(int a, flts_t x, flts_t y); +static int (__cdecl *sum_dbls)(int a, dbls_t x, dbls_t y); +static int (__cdecl *sum_iiff)(int x0, int y0, float x1, float y1); +static int (__cdecl *sum_ifif)(int x0, float y0, int x1, float y1); +static int (__cdecl *sum_iidd)(int x0, int y0, double x1, double y1); +static int (__cdecl *sum_idid)(int x0, double y0, int x1, double y1); +static int (__cdecl *sum_ififififififif)(int x0, float y0, int x1, float y1, int x2, float y2, int x3, float y3, int x4, float y4, int x5, float y5, int x6, float y6); +static int (__cdecl *sum_ididididididid)(int x0, double y0, int x1, double y1, int x2, double y2, int x3, double y3, int x4, double y4, int x5, double y5, int x6, double y6); +static int (__cdecl *sum_idfdifdfifdfidifdidf)(int x0, double y0, float z0, double y1, int x1, float z1, double y2, float z2, int x2, float z3, double y3, float z4, int x3, double y4, int x4, float z5, double y5, int x5, double y6, float z6); +static int (__cdecl *sum_ididididididididididid)(int x0, double y0, int x1, double y1, int x2, double y2, int x3, double y3, int x4, double y4, int x5, double y5, int x6, double y6, int x7, double y7, int x8, double y8); +static int (__cdecl *sum_iidiidiidiidiidiidiidiidiidiidiid)(int x0, int x1, double y0, int x2, int x3, double y1, int x4, int x5, double y2, int x6, int x7, double y3, int x8, int x9, double y4, int x10, int x11, double y5, int x12, int x13, double y6, int x14, int x15, double y7, int x16, int x17, double y8); +static int (__cdecl *sum_iyiy)(int x0, hyper y0, int x1, hyper y1); static void (__cdecl *square_ref)(int *x); static int (__cdecl *str_length)(const char *s); static int (__cdecl *str_t_length)(str_t s); @@ -94,6 +110,9 @@ static int (__cdecl *sum_cps)(cps_t *cps); static int (__cdecl *sum_cpsc)(cpsc_t *cpsc); static int (__cdecl *get_cpsc)(int n, cpsc_t *cpsc); static int (__cdecl *sum_complex_array)(int n, refpint_t pi[]); +static int (__cdecl *sum_blob)(cs_blob_t *blob); +static int (__cdecl *sum_data)(cs_data_t *data); +static int (__cdecl *sum_container)(cs_container_t *container); static int (__cdecl *square_puint)(puint_t p); static int (__cdecl *sum_puints)(puints_t *p); static int (__cdecl *sum_cpuints)(cpuints_t *p); @@ -144,6 +163,7 @@ static int (__cdecl *sum_array_ptr)(int (*a)[2]); static ctx_handle_t (__cdecl *get_handle)(void); static void (__cdecl *get_handle_by_ptr)(ctx_handle_t *r); static void (__cdecl *test_handle)(ctx_handle_t ctx_handle); +static void (__cdecl *test_I_RpcBindingInqLocalClientPID)(unsigned int protseq, RPC_BINDING_HANDLE binding); #define SERVER_FUNCTIONS \ X(int_return) \ @@ -156,6 +176,20 @@ static void (__cdecl *test_handle)(ctx_handle_t ctx_handle); X(sum_hyper) \ X(sum_hyper_int) \ X(sum_char_hyper) \ + X(sum_chars) \ + X(sum_ints) \ + X(sum_flts) \ + X(sum_dbls) \ + X(sum_iiff) \ + X(sum_ifif) \ + X(sum_iidd) \ + X(sum_idid) \ + X(sum_ififififififif) \ + X(sum_ididididididid) \ + X(sum_idfdifdfifdfidifdidf) \ + X(sum_ididididididididididid) \ + X(sum_iidiidiidiidiidiidiidiidiidiidiid) \ + X(sum_iyiy) \ X(square_out) \ X(square_ref) \ X(str_length) \ @@ -185,6 +219,9 @@ static void (__cdecl *test_handle)(ctx_handle_t ctx_handle); X(sum_cpsc) \ X(get_cpsc) \ X(sum_complex_array) \ + X(sum_blob) \ + X(sum_data) \ + X(sum_container) \ X(square_puint) \ X(sum_puints) \ X(sum_cpuints) \ @@ -234,20 +271,14 @@ static void (__cdecl *test_handle)(ctx_handle_t ctx_handle); X(sum_array_ptr) \ X(get_handle) \ X(get_handle_by_ptr) \ - X(test_handle) + X(test_handle) \ + X(test_I_RpcBindingInqLocalClientPID) /* type check statements generated in header file */ fnprintf *p_printf = printf; -static const WCHAR helloW[] = { 'H','e','l','l','o',0 }; -static const WCHAR worldW[] = { 'W','o','r','l','d','!',0 }; - -static BOOL is_interp; - static void set_interp_interface(void) { - is_interp = TRUE; - #define X(name) name = interp_##name; SERVER_FUNCTIONS #undef X @@ -255,8 +286,6 @@ static void set_interp_interface(void) static void set_mixed_interface(void) { - is_interp = FALSE; - #define X(name) name = mixed_##name; SERVER_FUNCTIONS #undef X @@ -278,21 +307,13 @@ static void InitFunctionPointers(void) void __RPC_FAR *__RPC_USER midl_user_allocate(SIZE_T n) { - return HeapAlloc(GetProcessHeap(), 0, n); + return malloc(n); } void __RPC_USER midl_user_free(void __RPC_FAR *p) { - HeapFree(GetProcessHeap(), 0, p); -} - -static char * -xstrdup(const char *s) -{ - char *d = HeapAlloc(GetProcessHeap(), 0, strlen(s) + 1); - strcpy(d, s); - return d; + free(p); } int __cdecl s_int_return(void) @@ -345,6 +366,76 @@ int __cdecl s_sum_char_hyper(signed char x, hyper y) return x + y; } +int __cdecl s_sum_chars(int a, chars_t x, chars_t y) +{ + return a * (x.a + x.b + x.c + x.d + x.e + y.a + y.b + y.c + y.d + y.e); +} + +int __cdecl s_sum_ints(int a, ints_t x, ints_t y) +{ + return a * (x.i + x.j + y.i + y.j); +} + +int __cdecl s_sum_flts(int a, flts_t x, flts_t y) +{ + return a * (x.i + x.f + y.i + y.f); +} + +int __cdecl s_sum_dbls(int a, dbls_t x, dbls_t y) +{ + return a * (x.i + x.d + y.i + y.d); +} + +int __cdecl s_sum_iiff(int x0, int y0, float x1, float y1) +{ + return x0 + y0 + x1 + y1; +} + +int __cdecl s_sum_ifif(int x0, float y0, int x1, float y1) +{ + return x0 + y0 + x1 + y1; +} + +int __cdecl s_sum_iidd(int x0, int y0, double x1, double y1) +{ + return x0 + y0 + x1 + y1; +} + +int __cdecl s_sum_idid(int x0, double y0, int x1, double y1) +{ + return x0 + y0 + x1 + y1; +} + +int __cdecl s_sum_ififififififif(int x0, float y0, int x1, float y1, int x2, float y2, int x3, float y3, int x4, float y4, int x5, float y5, int x6, float y6) +{ + return x0 + y0 + x1 + y1 + x2 + y2 + x3 + y3 + x4 + y4 + x5 + y5 + x6 + y6; +} + +int __cdecl s_sum_ididididididid(int x0, double y0, int x1, double y1, int x2, double y2, int x3, double y3, int x4, double y4, int x5, double y5, int x6, double y6) +{ + return x0 + y0 + x1 + y1 + x2 + y2 + x3 + y3 + x4 + y4 + x5 + y5 + x6 + y6; +} + +int __cdecl s_sum_idfdifdfifdfidifdidf(int x0, double y0, float z0, double y1, int x1, float z1, double y2, float z2, int x2, float z3, double y3, float z4, int x3, double y4, int x4, float z5, double y5, int x5, double y6, float z6) +{ + return x0 + y0 + z0 + x1 + y1 + z1 + x2 + y2 + z2 + x3 + y3 + z3 + x4 + y4 + z4 + x5 + y5 + z5 + y6 + z6; +} + +int __cdecl s_sum_ididididididididididid(int x0, double y0, int x1, double y1, int x2, double y2, int x3, double y3, int x4, double y4, int x5, double y5, int x6, double y6, int x7, double y7, int x8, double y8) +{ + return x0 + y0 + x1 + y1 + x2 + y2 + x3 + y3 + x4 + y4 + x5 + y5 + x6 + y6 + x7 + y7 + x8 + y8; +} + +int __cdecl s_sum_iidiidiidiidiidiidiidiidiidiidiid(int x0, int x1, double y0, int x2, int x3, double y1, int x4, int x5, double y2, int x6, int x7, double y3, int x8, int x9, double y4, int x10, int x11, double y5, int x12, int x13, double y6, int x14, int x15, double y7, int x16, int x17, double y8) +{ + return x0 + x1 + y0 + x2 + x3 + y1 + x4 + x5 + y2 + x6 + x7 + y3 + x8 + x9 + y4 + x10 + x11 + y5 + x12 + x13 + y6 + x14 + x15 + y7 + x16 + x17 + y8; +} + +int __cdecl s_sum_iyiy(int x0, hyper y0, int x1, hyper y1) +{ + return x0 + y0 + x1 + y1; +} + void __cdecl s_square_out(int x, int *y) { *y = s_square(x); @@ -507,6 +598,36 @@ int __cdecl s_sum_complex_array(int n, refpint_t pi[]) return total; } +int __cdecl s_sum_blob(cs_blob_t *blob) +{ + int i, total = 0; + + for (i = 0; i < blob->n; i++) + total += blob->ca[i]; + + return total; +} + +int __cdecl s_sum_data(cs_data_t *data) +{ + int i, total = 0; + + for (i = 0; i < data->blob.n; i++) + total += data->blob.ca[i]; + + return total; +} + +int __cdecl s_sum_container(cs_container_t *container) +{ + int i, total = 0; + + for (i = 0; i < container->data.blob.n; i++) + total += container->data.blob.ca[i]; + + return total; +} + int __cdecl s_dot_two_vectors(vector_t vs[2]) { return vs[0].x * vs[1].x + vs[0].y * vs[1].y + vs[0].z * vs[1].z; @@ -764,7 +885,7 @@ void __cdecl s_get_a_bstr(bstr_t *b) { bstr_t bstr; short str[] = {5, 'W', 'i', 'n', 'e', 0}; - bstr = HeapAlloc(GetProcessHeap(), 0, sizeof(str)); + bstr = malloc(sizeof(str)); memcpy(bstr, str, sizeof(str)); *b = bstr + 1; } @@ -797,10 +918,10 @@ void __cdecl s_get_namesw(int *n, wstr_array_t *names) wstr_array_t list; list = MIDL_user_allocate(2 * sizeof(list[0])); - list[0] = MIDL_user_allocate(sizeof(helloW)); - lstrcpyW(list[0], helloW); - list[1] = MIDL_user_allocate(sizeof(worldW)); - lstrcpyW(list[1], worldW); + list[0] = MIDL_user_allocate(sizeof(L"Hello")); + lstrcpyW(list[0], L"Hello"); + list[1] = MIDL_user_allocate(sizeof(L"World!")); + lstrcpyW(list[1], L"World!"); *names = list; *n = 2; @@ -831,7 +952,9 @@ s123_t * __cdecl s_get_s123(void) str_t __cdecl s_get_filename(void) { - return (char *)__FILE__; + void *ptr = MIDL_user_allocate(strlen(__FILE__) + 1); + strcpy(ptr, __FILE__); + return (char *)ptr; } int __cdecl s_echo_ranged_int(int i, int j, int k) @@ -883,7 +1006,7 @@ void __cdecl s_context_handle_test(void) /* marshal a context handle with NULL userContext */ memset(buf, 0xcc, sizeof(buf)); pNDRSContextMarshall2(binding, h, buf, NULL, NULL, 0); - ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG *)buf); + ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%lx\n", *(ULONG *)buf); ok(UuidIsNil((UUID *)&buf[4], &status), "uuid should have been nil\n"); h = pNDRSContextUnmarshall2(binding, NULL, NDR_LOCAL_DATA_REPRESENTATION, NULL, 0); @@ -893,7 +1016,7 @@ void __cdecl s_context_handle_test(void) memset(buf, 0xcc, sizeof(buf)); h->userContext = (void *)0xdeadbeef; pNDRSContextMarshall2(binding, h, buf, NULL, NULL, 0); - ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG *)buf); + ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%lx\n", *(ULONG *)buf); ok(!UuidIsNil((UUID *)&buf[4], &status), "uuid should not have been nil\n"); /* raises ERROR_INVALID_HANDLE exception on Vista upwards */ @@ -910,7 +1033,7 @@ void __cdecl s_context_handle_test(void) memset(buf, 0xcc, sizeof(buf)); h->userContext = (void *)0xcafebabe; pNDRSContextMarshall2(binding, h, buf, NULL, &server_if.InterfaceId, 0); - ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG *)buf); + ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%lx\n", *(ULONG *)buf); ok(!UuidIsNil((UUID *)&buf[4], &status), "uuid should not have been nil\n"); h = pNDRSContextUnmarshall2(binding, buf, NDR_LOCAL_DATA_REPRESENTATION, &server_if.InterfaceId, 0); @@ -951,7 +1074,7 @@ void __cdecl s_context_handle_test(void) binding = NULL; status = RpcBindingServerFromClient(NULL, &binding); - ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + ok(status == RPC_S_OK, "expected RPC_S_OK got %lu\n", status); ok(binding != NULL, "binding is NULL\n"); if (status == RPC_S_OK && binding != NULL) @@ -964,11 +1087,11 @@ void __cdecl s_context_handle_test(void) unsigned char* network_options = NULL; status = RpcBindingToStringBindingA(binding, &string_binding); - ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + ok(status == RPC_S_OK, "expected RPC_S_OK got %lu\n", status); ok(string_binding != NULL, "string_binding is NULL\n"); status = RpcStringBindingParseA(string_binding, &object_uuid, &protseq, &network_address, &endpoint, &network_options); - ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + ok(status == RPC_S_OK, "expected RPC_S_OK got %lu\n", status); ok(protseq != NULL && *protseq != '\0', "protseq is %s\n", protseq); ok(network_address != NULL && *network_address != '\0', "network_address is %s\n", network_address); @@ -1051,8 +1174,8 @@ void __cdecl s_stop_autolisten(void) { RPC_STATUS status; status = RpcServerUnregisterIf(NULL, NULL, FALSE); -todo_wine - ok(status == RPC_S_UNKNOWN_MGR_TYPE, "got %u\n", status); + todo_wine + ok(status == RPC_S_UNKNOWN_MGR_TYPE, "got %lu\n", status); } void __cdecl s_ip_test(ipu_t *a) @@ -1061,7 +1184,7 @@ void __cdecl s_ip_test(ipu_t *a) HRESULT hr; hr = IStream_Stat(a->tagged_union.stream, &st, STATFLAG_NONAME); - ok(hr == S_OK, "got %#x\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); } int __cdecl s_sum_ptr_array(int *a[2]) @@ -1089,6 +1212,105 @@ void __cdecl s_test_handle(ctx_handle_t ctx_handle) ok(ctx_handle == (ctx_handle_t)0xdeadbeef, "Unexpected ctx_handle %p\n", ctx_handle); } +struct test_thread_params +{ + unsigned int protseq; + RPC_BINDING_HANDLE binding; +}; + +static DWORD CALLBACK test_I_RpcBindingInqLocalClientPID_thread_func(void *args) +{ + struct test_thread_params *params = (struct test_thread_params *)args; + RPC_STATUS status; + ULONG pid; + + winetest_push_context("%s", client_test_name); + + status = I_RpcBindingInqLocalClientPID(NULL, &pid); + ok(status == RPC_S_NO_CALL_ACTIVE, "Got unexpected %ld.\n", status); + + /* Other protocol sequences throw exceptions */ + if (params->protseq == RPC_PROTSEQ_LRPC) + { + status = I_RpcBindingInqLocalClientPID(params->binding, &pid); + ok(status == RPC_S_OK, "Got unexpected %ld.\n", status); + ok(pid == client_info.dwProcessId, "Got unexpected pid.\n"); + } + + winetest_pop_context(); + return 0; +} + +void __cdecl s_test_I_RpcBindingInqLocalClientPID(unsigned int protseq, RPC_BINDING_HANDLE binding) +{ + struct test_thread_params params; + RPC_STATUS status; + HANDLE thread; + ULONG pid; + + winetest_push_context("%s", client_test_name); + + /* Crash on Windows */ + if (0) + { + status = I_RpcBindingInqLocalClientPID(NULL, NULL); + ok(status == RPC_S_INVALID_ARG, "Got unexpected %ld.\n", status); + + status = I_RpcBindingInqLocalClientPID(binding, NULL); + ok(status == RPC_S_INVALID_ARG, "Got unexpected %ld.\n", status); + } + + status = I_RpcBindingInqLocalClientPID(NULL, &pid); + if (protseq == RPC_PROTSEQ_LRPC) + { + ok(status == RPC_S_OK, "Got unexpected %ld.\n", status); + ok(pid == client_info.dwProcessId, "Got unexpected pid.\n"); + } + else + { + ok(status == RPC_S_INVALID_BINDING, "Got unexpected %ld.\n", status); + } + + if (protseq == RPC_PROTSEQ_LRPC) /* Other protocol sequences throw exceptions */ + { + status = I_RpcBindingInqLocalClientPID(binding, &pid); + ok(status == RPC_S_OK, "Got unexpected %ld.\n", status); + ok(pid == client_info.dwProcessId, "Got unexpected pid.\n"); + } + + params.protseq = protseq; + params.binding = binding; + thread = CreateThread(NULL, 0, test_I_RpcBindingInqLocalClientPID_thread_func, ¶ms, 0, NULL); + WaitForSingleObject(thread, INFINITE); + CloseHandle(thread); + + winetest_pop_context(); +} + +int __cdecl s_add(handle_t binding, int a, int b) +{ + ok(binding != NULL, "explicit handle is NULL\n"); + return a + b; +} + +int __cdecl s_getNum(int a, handle_t binding) +{ + ok(binding != NULL, "explicit handle is NULL\n"); + return a + 2; +} + +void __cdecl s_Shutdown(handle_t binding) +{ + RPC_STATUS status; + ULONG pid = 0; + ok(binding != NULL, "explicit handle is NULL\n"); + + status = I_RpcBindingInqLocalClientPID(binding, &pid); + ok(status == RPC_S_OK, "Got unexpected %ld.\n", status); + ok(pid == client_info.dwProcessId, "Got unexpected pid: %ld client pid: %ld.\n", pid, client_info.dwProcessId); + ok(SetEvent(stop_event), "SetEvent\n"); +} + void __RPC_USER ctx_handle_t_rundown(ctx_handle_t ctx_handle) { ok(ctx_handle == (ctx_handle_t)0xdeadbeef, "Unexpected ctx_handle %p\n", ctx_handle); @@ -1104,24 +1326,24 @@ static void run_client(const char *test) { char cmdline[MAX_PATH]; - PROCESS_INFORMATION info; STARTUPINFOA startup; memset(&startup, 0, sizeof startup); startup.cb = sizeof startup; + client_test_name = test; make_cmdline(cmdline, test); - ok(CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - winetest_wait_child_process( info.hProcess ); - ok(CloseHandle(info.hProcess), "CloseHandle\n"); - ok(CloseHandle(info.hThread), "CloseHandle\n"); + ok(CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &client_info), "CreateProcess\n"); + wait_child_process(client_info.hProcess); + ok(CloseHandle(client_info.hProcess), "CloseHandle\n"); + ok(CloseHandle(client_info.hThread), "CloseHandle\n"); } static void basic_tests(void) { char string[] = "I am a string"; - WCHAR wstring[] = {'I',' ','a','m',' ','a',' ','w','s','t','r','i','n','g', 0}; + WCHAR wstring[] = L"I am a wstring"; int f[5] = {1, 3, 0, -2, -4}; vector_t a = {1, 3, 7}; vector_t vec1 = {4, -2, 1}, vec2 = {-5, 2, 3}, *pvec2 = &vec2; @@ -1147,6 +1369,10 @@ basic_tests(void) str_t str; se_t se; renum_t re; + chars_t cs1 = { 2, 4, 6, 8, 10 }, cs2 = { -1, -2, -3, -4, -5 }; + ints_t is1 = { 2, 4 }, is2 = { 5, 8 }; + flts_t fs1 = { 3, 5.5 }, fs2 = { 8, 2.3 }; + dbls_t ds1 = { 9, -2.5 }, ds2 = { 2, -4.2 }; ok(int_return() == INT_CODE, "RPC int_return\n"); @@ -1167,6 +1393,35 @@ basic_tests(void) ok(x == 0x12120000, "RPC hyper_int got 0x%x\n", x); x = sum_char_hyper( 12, ((hyper)0x42424242 << 32) | 0x33334444 ); ok(x == 0x33334450, "RPC char_hyper got 0x%x\n", x); + x = sum_chars( 4, cs1, cs2 ); + ok(x == 60, "got %d\n", x); + x = sum_ints( 2, is1, is2 ); + ok(x == 38, "got %d\n", x); + x = sum_flts( 3, fs1, fs2 ); + ok(x == 56, "got %d\n", x); + x = sum_dbls( 7, ds1, ds2 ); + ok(x == 30, "got %d\n", x); + x = sum_iiff( 12, 23, 3.4, 4.7 ); + ok(x == 43, "got %d\n", x); + x = sum_ifif( 12, 11.2, 23, 34.5 ); + ok(x == 80, "got %d\n", x); + x = sum_iidd( 6, 5, 4.3, 2.1 ); + ok(x == 17, "got %d\n", x); + x = sum_idid( 55, 44.55, 33, 22.44 ); + ok(x == 154, "got %d\n", x); + x = sum_ififififififif( 1, 2.1, 3, 4.2, 5, 6.3, 7, 8.4, 9, 10.5, 11, 12.2, 13, 14.9 ); + ok(x == 107, "got %d\n", x); + x = sum_ididididididid( -1, -2.1, -3, -4, -5, -6.7, -8, -9.1, -11, -12.3, -13, -14.2, -15, -16.3 ); + ok(x == -120, "got %d\n", x); + x = sum_idfdifdfifdfidifdidf( 2, 1.2, 2.1, 2.3, 4, 3.2, 4.5, 5.5, -3, -2.2, -4.4, -5.5, 6, 6.4, -3, 8.1, 9.2, 7, -10.3, 12.4 ); + ok(x == 45, "got %d\n", x); + x = sum_ididididididididididid( 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8, -9, 5 ); + ok(x == 4, "got %d\n", x); + x = sum_iidiidiidiidiidiidiidiidiidiidiid( 11, 22, 33.1, 44, 55, 66.1, 77, 88, 99.1, 111, 222, 333.1, 444, + 555, 666.1, 777, 888, 999.1, 1, 2, 3.1, 4, 5, 6.1, 7, 8, 9.1 ); + ok(x == 5535, "got %d\n", x); + x = sum_iyiy( 1, 1234567890, 2, -1234567800 ); + ok(x == 93, "got %d\n", x); x = 0; square_out(11, &x); @@ -1266,11 +1521,9 @@ basic_tests(void) check_null(NULL); - if (!is_interp || sizeof(void*) != 8) { /* broken in widl for win64 */ str = get_filename(); ok(!strcmp(str, __FILE__), "get_filename() returned %s instead of %s\n", str, __FILE__); midl_user_free(str); - } x = echo_ranged_int(0,0,0); ok(x == 0, "echo_ranged_int() returned %d instead of 0\n", x); @@ -1344,7 +1597,7 @@ union_tests(void) CreateStreamOnHGlobal(NULL, TRUE, &ipu.tagged_union.stream); ip_test(&ipu); ref = IStream_Release(ipu.tagged_union.stream); - ok(!ref, "got %u refs\n", ref); + ok(!ref, "got %lu refs\n", ref); CoUninitialize(); } @@ -1352,7 +1605,7 @@ union_tests(void) static test_list_t * null_list(void) { - test_list_t *n = HeapAlloc(GetProcessHeap(), 0, sizeof *n); + test_list_t *n = malloc(sizeof *n); n->t = TL_NULL; n->u.x = 0; return n; @@ -1361,7 +1614,7 @@ null_list(void) static test_list_t * make_list(test_list_t *tail) { - test_list_t *n = HeapAlloc(GetProcessHeap(), 0, sizeof *n); + test_list_t *n = malloc(sizeof *n); n->t = TL_LIST; n->u.tail = tail; return n; @@ -1372,7 +1625,7 @@ free_list(test_list_t *list) { if (list->t == TL_LIST) free_list(list->u.tail); - HeapFree(GetProcessHeap(), 0, list); + free(list); } ULONG __RPC_USER @@ -1394,7 +1647,7 @@ puint_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, puint_t *p) { int n; memcpy(&n, buffer, sizeof n); - *p = HeapAlloc(GetProcessHeap(), 0, 10); + *p = malloc(10); sprintf(*p, "%d", n); return buffer + sizeof n; } @@ -1402,7 +1655,7 @@ puint_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, puint_t *p) void __RPC_USER puint_t_UserFree(ULONG *flags, puint_t *p) { - HeapFree(GetProcessHeap(), 0, *p); + free(*p); } ULONG __RPC_USER @@ -1425,7 +1678,7 @@ us_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, us_t *pus) { struct wire_us wus; memcpy(&wus, buffer, sizeof wus); - pus->x = HeapAlloc(GetProcessHeap(), 0, 10); + pus->x = malloc(10); sprintf(pus->x, "%d", wus.x); return buffer + sizeof wus; } @@ -1433,7 +1686,7 @@ us_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, us_t *pus) void __RPC_USER us_t_UserFree(ULONG *flags, us_t *pus) { - HeapFree(GetProcessHeap(), 0, pus->x); + free(pus->x); } ULONG __RPC_USER @@ -1455,7 +1708,7 @@ unsigned char * __RPC_USER bstr_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, bstr_t *b) { wire_bstr_t wb = (wire_bstr_t) buffer; - short *data = HeapAlloc(GetProcessHeap(), 0, (wb->n + 1) * sizeof *data); + short *data = malloc((wb->n + 1) * sizeof *data); data[0] = wb->n; memcpy(&data[1], wb->data, wb->n * sizeof data[1]); *b = &data[1]; @@ -1465,7 +1718,7 @@ bstr_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, bstr_t *b) void __RPC_USER bstr_t_UserFree(ULONG *flags, bstr_t *b) { - HeapFree(GetProcessHeap(), 0, &((*b)[-1])); + free(&((*b)[-1])); } static void @@ -1489,29 +1742,29 @@ pointer_tests(void) ok(test_list_length(list) == 3, "RPC test_list_length\n"); ok(square_puint(p1) == 121, "RPC square_puint\n"); pus.n = 4; - pus.ps = HeapAlloc(GetProcessHeap(), 0, pus.n * sizeof pus.ps[0]); - pus.ps[0] = xstrdup("5"); - pus.ps[1] = xstrdup("6"); - pus.ps[2] = xstrdup("7"); - pus.ps[3] = xstrdup("8"); + pus.ps = malloc(pus.n * sizeof pus.ps[0]); + pus.ps[0] = strdup("5"); + pus.ps[1] = strdup("6"); + pus.ps[2] = strdup("7"); + pus.ps[3] = strdup("8"); ok(sum_puints(&pus) == 26, "RPC sum_puints\n"); - HeapFree(GetProcessHeap(), 0, pus.ps[0]); - HeapFree(GetProcessHeap(), 0, pus.ps[1]); - HeapFree(GetProcessHeap(), 0, pus.ps[2]); - HeapFree(GetProcessHeap(), 0, pus.ps[3]); - HeapFree(GetProcessHeap(), 0, pus.ps); + free(pus.ps[0]); + free(pus.ps[1]); + free(pus.ps[2]); + free(pus.ps[3]); + free(pus.ps); cpus.n = 4; - cpus.ps = HeapAlloc(GetProcessHeap(), 0, cpus.n * sizeof cpus.ps[0]); - cpus.ps[0] = xstrdup("5"); - cpus.ps[1] = xstrdup("6"); - cpus.ps[2] = xstrdup("7"); - cpus.ps[3] = xstrdup("8"); + cpus.ps = malloc(cpus.n * sizeof cpus.ps[0]); + cpus.ps[0] = strdup("5"); + cpus.ps[1] = strdup("6"); + cpus.ps[2] = strdup("7"); + cpus.ps[3] = strdup("8"); ok(sum_cpuints(&cpus) == 26, "RPC sum_puints\n"); - HeapFree(GetProcessHeap(), 0, cpus.ps[0]); - HeapFree(GetProcessHeap(), 0, cpus.ps[1]); - HeapFree(GetProcessHeap(), 0, cpus.ps[2]); - HeapFree(GetProcessHeap(), 0, cpus.ps[3]); - HeapFree(GetProcessHeap(), 0, cpus.ps); + free(cpus.ps[0]); + free(cpus.ps[1]); + free(cpus.ps[2]); + free(cpus.ps[3]); + free(cpus.ps); ok(square_test_us(&tus) == 121, "RPC square_test_us\n"); pa[0] = &a[0]; @@ -1530,8 +1783,8 @@ pointer_tests(void) get_a_bstr(&bstr); s_get_a_bstr(&bstr2); ok(!lstrcmpW((LPCWSTR)bstr, (LPCWSTR)bstr2), "bstr mismatch\n"); - HeapFree(GetProcessHeap(), 0, bstr - 1); - HeapFree(GetProcessHeap(), 0, bstr2 - 1); + free(bstr - 1); + free(bstr2 - 1); free_list(list); @@ -1542,13 +1795,12 @@ pointer_tests(void) wstr_array_t namesw; name.size = 10; - name.name = buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, name.size); + name.name = buffer = calloc(1, name.size); get_name(&name); ok(name.name == buffer, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name.name, buffer); ok(!strcmp(name.name, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name.name); - HeapFree(GetProcessHeap(), 0, name.name); + free(name.name); - if (!is_interp) { /* broken in widl */ n = -1; names = NULL; get_names(&n, &names); @@ -1566,20 +1818,17 @@ pointer_tests(void) get_namesw(&n, &namesw); ok(n == 2, "expected 2, got %d\n", n); ros_skip_flaky - ok(!lstrcmpW(namesw[0], helloW), "expected Hello, got %s\n", wine_dbgstr_w(namesw[0])); + ok(!lstrcmpW(namesw[0], L"Hello"), "expected Hello, got %s\n", wine_dbgstr_w(namesw[0])); ros_skip_flaky - ok(!lstrcmpW(namesw[1], worldW), "expected World!, got %s\n", wine_dbgstr_w(namesw[1])); + ok(!lstrcmpW(namesw[1], L"World!"), "expected World!, got %s\n", wine_dbgstr_w(namesw[1])); MIDL_user_free(namesw[0]); MIDL_user_free(namesw[1]); MIDL_user_free(namesw); - } } - if (!is_interp) { /* broken in widl */ pa2 = a; ros_skip_flaky ok(sum_pcarr2(4, &pa2) == 10, "RPC sum_pcarr2\n"); - } s123 = get_s123(); ok(s123->f1 == 1 && s123->f2 == 2 && s123->f3 == 3, "RPC get_s123\n"); @@ -1623,6 +1872,9 @@ array_tests(void) vector_t vs[2] = {{1, -2, 3}, {4, -5, -6}}; cps_t cps; cpsc_t cpsc; + cs_blob_t blob; + cs_data_t data; + cs_container_t container; cs_t *cs; int n; int ca[5] = {1, -2, 3, -4, 5}; @@ -1667,7 +1919,7 @@ array_tests(void) ok(sum_var_array(&c[2], 0) == 0, "RPC sum_conf_array\n"); ok(dot_two_vectors(vs) == -4, "RPC dot_two_vectors\n"); - cs = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(cs_t, ca[5])); + cs = malloc(FIELD_OFFSET(cs_t, ca[5])); cs->n = 5; cs->ca[0] = 3; cs->ca[1] = 5; @@ -1675,7 +1927,7 @@ array_tests(void) cs->ca[3] = -1; cs->ca[4] = -4; ok(sum_cs(cs) == 1, "RPC sum_cs\n"); - HeapFree(GetProcessHeap(), 0, cs); + free(cs); n = 5; cps.pn = &n; @@ -1711,21 +1963,21 @@ array_tests(void) ok(sum_toplev_conf_cond(c, 5, 6, 1) == 10, "RPC sum_toplev_conf_cond\n"); ok(sum_toplev_conf_cond(c, 5, 6, 0) == 15, "RPC sum_toplev_conf_cond\n"); - dc = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_t, a[2])); + dc = malloc(FIELD_OFFSET(doub_carr_t, a[2])); dc->n = 2; - dc->a[0] = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_1_t, a[3])); + dc->a[0] = malloc(sizeof(doub_carr_1_t) + 3); dc->a[0]->n = 3; dc->a[0]->a[0] = 5; dc->a[0]->a[1] = 1; dc->a[0]->a[2] = 8; - dc->a[1] = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_1_t, a[2])); + dc->a[1] = malloc(sizeof(doub_carr_1_t) + 2); dc->a[1]->n = 2; dc->a[1]->a[0] = 2; dc->a[1]->a[1] = 3; ok(sum_doub_carr(dc) == 19, "RPC sum_doub_carr\n"); - HeapFree(GetProcessHeap(), 0, dc->a[0]); - HeapFree(GetProcessHeap(), 0, dc->a[1]); - HeapFree(GetProcessHeap(), 0, dc); + free(dc->a[0]); + free(dc->a[1]); + free(dc); dc = NULL; make_pyramid_doub_carr(4, &dc); @@ -1735,7 +1987,7 @@ array_tests(void) ok(sum_L1_norms(2, vs) == 21, "RPC sum_L1_norms\n"); memset(api, 0, sizeof(api)); - pi = HeapAlloc(GetProcessHeap(), 0, sizeof(*pi)); + pi = malloc(sizeof(*pi)); *pi = -1; api[0].pi = pi; get_numbers(1, 1, api); @@ -1744,28 +1996,43 @@ array_tests(void) if (!old_windows_version) { - ns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(numbers_struct_t, numbers[5])); + ns = calloc(1, FIELD_OFFSET(numbers_struct_t, numbers[5])); ns->length = 5; ns->size = 5; ns->numbers[0].pi = pi; get_numbers_struct(&ns); ok(ns->numbers[0].pi == pi, "RPC conformant varying struct embedded pointer changed from %p to %p\n", pi, ns->numbers[0].pi); ok(*ns->numbers[0].pi == 5, "pi unmarshalled incorrectly %d\n", *ns->numbers[0].pi); - HeapFree(GetProcessHeap(), 0, ns); + free(ns); } - HeapFree(GetProcessHeap(), 0, pi); + free(pi); - pi = HeapAlloc(GetProcessHeap(), 0, 5 * sizeof(*pi)); + pi = malloc(5 * sizeof(*pi)); pi[0] = 3; rpi[0] = &pi[0]; pi[1] = 5; rpi[1] = &pi[1]; pi[2] = -2; rpi[2] = &pi[2]; pi[3] = -1; rpi[3] = &pi[3]; pi[4] = -4; rpi[4] = &pi[4]; ok(sum_complex_array(5, rpi) == 1, "RPC sum_complex_array\n"); - HeapFree(GetProcessHeap(), 0, pi); + free(pi); ok(sum_ptr_array(ptr_array) == 3, "RPC sum_ptr_array\n"); ok(sum_array_ptr(&array) == 7, "RPC sum_array_ptr\n"); + + blob.n = ARRAY_SIZE(c); + blob.ca = c; + n = sum_blob(&blob); + ok(n == 45, "RPC sum_blob = %d\n", n); + + data.blob.n = ARRAY_SIZE(c); + data.blob.ca = c; + n = sum_data(&data); + ok(n == 45, "RPC sum_data = %d\n", n); + + container.data.blob.n = ARRAY_SIZE(c); + container.data.blob.ca = c; + n = sum_container(&container); + ok(n == 45, "RPC sum_container = %d\n", n); } void __cdecl s_authinfo_test(unsigned int protseq, int secure) @@ -1791,7 +2058,7 @@ void __cdecl s_authinfo_test(unsigned int protseq, int secure) win_skip("RpcBindingInqAuthClientA not supported\n"); return; } - ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + ok(status == RPC_S_OK, "expected RPC_S_OK got %lu\n", status); ok(privs != (RPC_AUTHZ_HANDLE)0xdeadbeef, "privs unchanged\n"); ok(principal != (unsigned char *)0xdeadbeef, "principal unchanged\n"); if (protseq != RPC_PROTSEQ_LRPC) @@ -1805,38 +2072,38 @@ void __cdecl s_authinfo_test(unsigned int protseq, int secure) char *spn; len = WideCharToMultiByte(CP_ACP, 0, (const WCHAR *)privs, -1, NULL, 0, NULL, NULL); - spn = HeapAlloc( GetProcessHeap(), 0, len ); + spn = malloc(len); WideCharToMultiByte(CP_ACP, 0, (const WCHAR *)privs, -1, spn, len, NULL, NULL); ok(!strcmp(domain_and_user, spn), "expected %s got %s\n", domain_and_user, spn); - HeapFree( GetProcessHeap(), 0, spn ); + free(spn); } ok(level == RPC_C_AUTHN_LEVEL_PKT_PRIVACY, "level unchanged\n"); ok(authnsvc == RPC_C_AUTHN_WINNT, "authnsvc unchanged\n"); RpcStringFreeA(&principal); status = RpcBindingInqAuthClientA(NULL, &privs, &principal, &level, &authnsvc, NULL); - ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + ok(status == RPC_S_OK, "expected RPC_S_OK got %lu\n", status); RpcStringFreeA(&principal); status = RpcBindingInqAuthClientExA(NULL, &privs, &principal, &level, &authnsvc, NULL, 0); - ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + ok(status == RPC_S_OK, "expected RPC_S_OK got %lu\n", status); RpcStringFreeA(&principal); status = RpcImpersonateClient(NULL); - ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + ok(status == RPC_S_OK, "expected RPC_S_OK got %lu\n", status); status = RpcRevertToSelf(); - ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + ok(status == RPC_S_OK, "expected RPC_S_OK got %lu\n", status); } else { status = RpcBindingInqAuthClientA(binding, &privs, &principal, &level, &authnsvc, NULL); - ok(status == RPC_S_BINDING_HAS_NO_AUTH, "expected RPC_S_BINDING_HAS_NO_AUTH got %u\n", status); + ok(status == RPC_S_BINDING_HAS_NO_AUTH, "expected RPC_S_BINDING_HAS_NO_AUTH got %lu\n", status); ok(privs == (RPC_AUTHZ_HANDLE)0xdeadbeef, "got %p\n", privs); ok(principal == (unsigned char *)0xdeadbeef, "got %s\n", principal); - ok(level == 0xdeadbeef, "got %u\n", level); - ok(authnsvc == 0xdeadbeef, "got %u\n", authnsvc); + ok(level == 0xdeadbeef, "got %lu\n", level); + ok(authnsvc == 0xdeadbeef, "got %lu\n", authnsvc); } } @@ -1874,7 +2141,7 @@ set_auth_info(RPC_BINDING_HANDLE handle) status = pRpcBindingSetAuthInfoExA(handle, (RPC_CSTR)domain_and_user, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_AUTHN_WINNT, NULL, 0, &qos); - ok(status == RPC_S_OK, "RpcBindingSetAuthInfoExA failed %d\n", status); + ok(status == RPC_S_OK, "RpcBindingSetAuthInfoExA failed %ld\n", status); } #define test_is_server_listening(a,b) _test_is_server_listening(__LINE__,a,b) @@ -1882,7 +2149,7 @@ static void _test_is_server_listening(unsigned line, RPC_BINDING_HANDLE binding, { RPC_STATUS status; status = RpcMgmtIsServerListening(binding); - ok_(__FILE__,line)(status == expected_status, "RpcMgmtIsServerListening returned %u, expected %u\n", + ok_(__FILE__,line)(status == expected_status, "RpcMgmtIsServerListening returned %lu, expected %lu\n", status, expected_status); } @@ -1893,7 +2160,7 @@ static void _test_is_server_listening2(unsigned line, RPC_BINDING_HANDLE binding RPC_STATUS status; status = RpcMgmtIsServerListening(binding); ok_(__FILE__,line)(status == expected_status || status == expected_status2, - "RpcMgmtIsServerListening returned %u, expected %u or %u\n", + "RpcMgmtIsServerListening returned %lu, expected %lu or %lu\n", status, expected_status, expected_status2); } @@ -1908,6 +2175,7 @@ client(const char *test) static unsigned char port[] = PORT; static unsigned char pipe[] = PIPE; static unsigned char guid[] = "00000000-4114-0704-2301-000000000000"; + static unsigned char explicit_handle_guid[] = "00000000-4114-0704-2301-000000000002"; unsigned char *binding; @@ -1918,6 +2186,7 @@ client(const char *test) run_tests(); authinfo_test(RPC_PROTSEQ_TCP, 0); + test_I_RpcBindingInqLocalClientPID(RPC_PROTSEQ_TCP, IMixedServer_IfHandle); test_is_server_listening2(IMixedServer_IfHandle, RPC_S_OK, RPC_S_ACCESS_DENIED); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); @@ -1930,6 +2199,7 @@ client(const char *test) set_auth_info(IMixedServer_IfHandle); authinfo_test(RPC_PROTSEQ_TCP, 1); + test_I_RpcBindingInqLocalClientPID(RPC_PROTSEQ_TCP, IMixedServer_IfHandle); test_is_server_listening(IMixedServer_IfHandle, RPC_S_ACCESS_DENIED); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); @@ -1942,6 +2212,7 @@ client(const char *test) run_tests(); /* can cause RPC_X_BAD_STUB_DATA exception */ authinfo_test(RPC_PROTSEQ_LRPC, 0); + test_I_RpcBindingInqLocalClientPID(RPC_PROTSEQ_LRPC, IMixedServer_IfHandle); test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); @@ -1954,7 +2225,8 @@ client(const char *test) run_tests(); authinfo_test(RPC_PROTSEQ_LRPC, 0); -todo_wine + test_I_RpcBindingInqLocalClientPID(RPC_PROTSEQ_LRPC, IMixedServer_IfHandle); + todo_wine test_is_server_listening(IMixedServer_IfHandle, RPC_S_NOT_LISTENING); stop_autolisten(); @@ -1970,6 +2242,7 @@ todo_wine set_auth_info(IMixedServer_IfHandle); authinfo_test(RPC_PROTSEQ_LRPC, 1); + test_I_RpcBindingInqLocalClientPID(RPC_PROTSEQ_LRPC, IMixedServer_IfHandle); test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); @@ -1983,6 +2256,7 @@ todo_wine test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); run_tests(); authinfo_test(RPC_PROTSEQ_NMP, 0); + test_I_RpcBindingInqLocalClientPID(RPC_PROTSEQ_NMP, IMixedServer_IfHandle); test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); stop(); test_is_server_listening(IMixedServer_IfHandle, RPC_S_NOT_LISTENING); @@ -2000,11 +2274,27 @@ todo_wine test_is_server_listening(IInterpServer_IfHandle, RPC_S_OK); run_tests(); authinfo_test(RPC_PROTSEQ_NMP, 0); + test_I_RpcBindingInqLocalClientPID(RPC_PROTSEQ_NMP, IInterpServer_IfHandle); test_is_server_listening(IInterpServer_IfHandle, RPC_S_OK); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); ok(RPC_S_OK == RpcBindingFree(&IInterpServer_IfHandle), "RpcBindingFree\n"); } + else if (strcmp(test, "explicit_handle") == 0) + { + IMixedServer_IfHandle = NULL; + ok(RPC_S_OK == RpcStringBindingComposeA(NULL, ncalrpc, NULL, explicit_handle_guid, NULL, &binding), "RpcStringBindingCompose\n"); + ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); + + test_is_server_listening(IMixedServer_IfHandle, RPC_S_OK); + + ok(add(IMixedServer_IfHandle, 2, 3) == 5, "RPC add\n"); + ok(getNum(7, IMixedServer_IfHandle) == 9, "RPC getNum\n"); + Shutdown(IMixedServer_IfHandle); + + ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); + ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); + } } static void @@ -2016,6 +2306,7 @@ server(void) static unsigned char pipe[] = PIPE; static unsigned char ncalrpc[] = "ncalrpc"; static unsigned char guid[] = "00000000-4114-0704-2301-000000000000"; + static unsigned char explicit_handle_guid[] = "00000000-4114-0704-2301-000000000002"; RPC_STATUS status, iptcp_status, np_status, ncalrpc_status; DWORD ret; @@ -2023,16 +2314,16 @@ server(void) CoInitializeEx(NULL, COINIT_MULTITHREADED); iptcp_status = RpcServerUseProtseqEpA(iptcp, 20, port, NULL); - ok(iptcp_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_ip_tcp) failed with status %d\n", iptcp_status); + ok(iptcp_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_ip_tcp) failed with status %ld\n", iptcp_status); ncalrpc_status = RpcServerUseProtseqEpA(ncalrpc, 0, guid, NULL); - ok(ncalrpc_status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", ncalrpc_status); + ok(ncalrpc_status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %ld\n", ncalrpc_status); np_status = RpcServerUseProtseqEpA(np, 0, pipe, NULL); if (np_status == RPC_S_PROTSEQ_NOT_SUPPORTED) skip("Protocol sequence ncacn_np is not supported\n"); else - ok(np_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", np_status); + ok(np_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %ld\n", np_status); if (pRpcServerRegisterIfEx) { @@ -2040,25 +2331,25 @@ server(void) status = pRpcServerRegisterIfEx(s_IMixedServer_v0_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIfEx failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerRegisterIfEx failed with status %ld\n", status); status = pRpcServerRegisterIfEx(s_IInterpServer_v0_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIfEx failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerRegisterIfEx failed with status %ld\n", status); } else { status = RpcServerRegisterIf(s_IMixedServer_v0_0_s_ifspec, NULL, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %ld\n", status); status = RpcServerRegisterIf(s_IInterpServer_v0_0_s_ifspec, NULL, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %ld\n", status); } test_is_server_listening(NULL, RPC_S_NOT_LISTENING); - status = RpcServerListen(1, 20, TRUE); - ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status); + status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); + ok(status == RPC_S_OK, "RpcServerListen failed with status %ld\n", status); test_is_server_listening(NULL, RPC_S_OK); stop_event = CreateEventW(NULL, FALSE, FALSE, NULL); - ok(stop_event != NULL, "CreateEvent failed with error %d\n", GetLastError()); + ok(stop_event != NULL, "CreateEvent failed with error %ld\n", GetLastError()); if (iptcp_status == RPC_S_OK) run_client("tcp_basic"); @@ -2095,7 +2386,7 @@ server(void) if (ret == WAIT_OBJECT_0) { status = RpcMgmtWaitServerListen(); - ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %ld\n", status); } CloseHandle(stop_event); @@ -2106,14 +2397,59 @@ server(void) status = pRpcServerRegisterIfEx(s_IMixedServer_v0_0_s_ifspec, NULL, NULL, RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH | RPC_IF_AUTOLISTEN, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIf() failed: %u\n", status); + ok(status == RPC_S_OK, "RpcServerRegisterIf() failed: %lu\n", status); run_client("ncalrpc_autolisten"); status = RpcServerUnregisterIf(s_IMixedServer_v0_0_s_ifspec, NULL, TRUE); - ok(status == RPC_S_OK, "RpcServerUnregisterIf() failed: %u\n", status); + ok(status == RPC_S_OK, "RpcServerUnregisterIf() failed: %lu\n", status); } + /* explicit handle */ + stop_event = CreateEventW(NULL, FALSE, FALSE, NULL); + ok(stop_event != NULL, "CreateEvent failed with error %ld\n", GetLastError()); + + ncalrpc_status = RpcServerUseProtseqEpA(ncalrpc, 0, explicit_handle_guid, NULL); + if (ncalrpc_status == RPC_S_PROTSEQ_NOT_SUPPORTED) + skip("Protocol sequence ncacn_np is not supported\n"); + else + ok(ncalrpc_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %ld\n", ncalrpc_status); + + if (pRpcServerRegisterIfEx) + { + trace("Using RpcServerRegisterIfEx\n"); + status = pRpcServerRegisterIfEx(s_RPCExplicitHandle_v0_0_s_ifspec, NULL, NULL, + RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL); + ok(status == RPC_S_OK, "RpcServerRegisterIfEx failed with status %ld\n", status); + test_is_server_listening(NULL, RPC_S_NOT_LISTENING); + status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); + ok(status == RPC_S_OK, "RpcServerListen failed with status %ld\n", status); + } + else + { + status = RpcServerRegisterIf(s_RPCExplicitHandle_v0_0_s_ifspec, NULL, NULL); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %ld\n", status); + status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); + ok(status == RPC_S_OK, "RpcServerListen failed with status %ld\n", status); + } + + test_is_server_listening(NULL, RPC_S_OK); + + run_client("explicit_handle"); + + ret = WaitForSingleObject(stop_event, 1000); + ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject\n"); + + if (pRpcServerRegisterIfEx) + { + status = RpcServerUnregisterIf(s_RPCExplicitHandle_v0_0_s_ifspec, NULL, TRUE); + ok(status == RPC_S_OK, "RpcServerUnregisterIf() failed: %lu\n", status); + } + + CloseHandle(stop_event); + stop_event = NULL; + CoUninitialize(); } @@ -2139,7 +2475,7 @@ static DWORD WINAPI wait_listen_proc(void *arg) trace("waiting\n"); status = RpcMgmtWaitServerListen(); - ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %ld\n", status); trace("done\n"); return 0; @@ -2151,14 +2487,14 @@ static void test_stop_wait_for_call(unsigned char *binding) RPC_STATUS status; DWORD ret; - status = RpcServerListen(1, 20, TRUE); - ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status); + status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); + ok(status == RPC_S_OK, "RpcServerListen failed with status %ld\n", status); test_is_server_listening(NULL, RPC_S_OK); stop_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL); - ok(stop_wait_event != NULL, "CreateEvent failed with error %d\n", GetLastError()); + ok(stop_wait_event != NULL, "CreateEvent failed with error %ld\n", GetLastError()); stop_event = CreateEventW(NULL, FALSE, FALSE, NULL); - ok(stop_event != NULL, "CreateEvent failed with error %d\n", GetLastError()); + ok(stop_event != NULL, "CreateEvent failed with error %ld\n", GetLastError()); wait_listen_thread = CreateThread(NULL, 0, wait_listen_proc, 0, 0, NULL); ok(wait_listen_thread != NULL, "CreateThread failed\n"); @@ -2180,7 +2516,7 @@ static void test_stop_wait_for_call(unsigned char *binding) SetEvent(stop_wait_event); ret = WaitForSingleObject(wait_listen_thread, 10000); - ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject returned %u\n", ret); + ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject returned %lu\n", ret); CloseHandle(wait_listen_thread); @@ -2201,28 +2537,28 @@ static void test_server_listening(void) RPC_STATUS status; status = RpcServerUseProtseqEpA(np, 0, pipe, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %ld\n", status); status = RpcServerRegisterIf(s_IMixedServer_v0_0_s_ifspec, NULL, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %ld\n", status); test_is_server_listening(NULL, RPC_S_NOT_LISTENING); - status = RpcServerListen(1, 20, TRUE); - ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status); + status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); + ok(status == RPC_S_OK, "RpcServerListen failed with status %ld\n", status); test_is_server_listening(NULL, RPC_S_OK); - status = RpcServerListen(1, 20, TRUE); - ok(status == RPC_S_ALREADY_LISTENING, "RpcServerListen failed with status %d\n", status); + status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); + ok(status == RPC_S_ALREADY_LISTENING, "RpcServerListen failed with status %ld\n", status); status = RpcMgmtStopServerListening(NULL); ok(status == RPC_S_OK, "RpcMgmtStopServerListening\n"); test_is_server_listening(NULL, RPC_S_NOT_LISTENING); status = RpcMgmtWaitServerListen(); - ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %ld\n", status); status = RpcMgmtWaitServerListen(); - ok(status == RPC_S_NOT_LISTENING, "RpcMgmtWaitServerListening failed with status %d\n", status); + ok(status == RPC_S_NOT_LISTENING, "RpcMgmtWaitServerListening failed with status %ld\n", status); /* test that server stop waits for a call in progress */ status = RpcStringBindingComposeA(NULL, np, address_np, pipe, NULL, &binding); @@ -2235,7 +2571,7 @@ static void test_server_listening(void) /* repeat the test using ncalrpc */ status = RpcServerUseProtseqEpA(ncalrpc, 0, guid, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %ld\n", status); status = RpcStringBindingComposeA(NULL, ncalrpc, NULL, guid, NULL, &binding); ok(status == RPC_S_OK, "RpcStringBindingCompose\n"); @@ -2259,13 +2595,9 @@ static HANDLE create_server_process(void) startup.cb = sizeof startup; ready_event = CreateEventW(&sec_attr, TRUE, FALSE, NULL); - ok(ready_event != NULL, "CreateEvent failed: %u\n", GetLastError()); + ok(ready_event != NULL, "CreateEvent failed: %lu\n", GetLastError()); -#ifdef __REACTOS__ sprintf(cmdline, "%s server run %Ix", progname, (UINT_PTR)ready_event); -#else - sprintf(cmdline, "%s server run %lx", progname, (UINT_PTR)ready_event); -#endif trace("running server process...\n"); ok(CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); ret = WaitForSingleObject(ready_event, 10000); @@ -2284,26 +2616,26 @@ static void run_server(HANDLE ready_event) BOOL ret; status = RpcServerUseProtseqEpA(np, 0, pipe, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %ld\n", status); status = RpcServerRegisterIf(s_IMixedServer_v0_0_s_ifspec, NULL, NULL); - ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %ld\n", status); test_is_server_listening(NULL, RPC_S_NOT_LISTENING); - status = RpcServerListen(1, 20, TRUE); - ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status); + status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE); + ok(status == RPC_S_OK, "RpcServerListen failed with status %ld\n", status); stop_event = CreateEventW(NULL, FALSE, FALSE, NULL); - ok(stop_event != NULL, "CreateEvent failed with error %d\n", GetLastError()); + ok(stop_event != NULL, "CreateEvent failed with error %ld\n", GetLastError()); ret = SetEvent(ready_event); - ok(ret, "SetEvent failed: %u\n", GetLastError()); + ok(ret, "SetEvent failed: %lu\n", GetLastError()); - ret = WaitForSingleObject(stop_event, 1000); + ret = WaitForSingleObject(stop_event, 5000); ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject\n"); status = RpcMgmtWaitServerListen(); - ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %d\n", status); + ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %ld\n", status); CloseHandle(stop_event); stop_event = NULL; @@ -2334,7 +2666,7 @@ static void test_reconnect(void) for (i = 0; i < ARRAY_SIZE(threads); i++) { threads[i] = CreateThread(NULL, 0, basic_tests_thread, 0, 0, NULL); - ok(threads[i] != NULL, "CreateThread failed: %u\n", GetLastError()); + ok(threads[i] != NULL, "CreateThread failed: %lu\n", GetLastError()); } for (i = 0; i < ARRAY_SIZE(threads); i++) @@ -2346,7 +2678,7 @@ static void test_reconnect(void) stop(); - winetest_wait_child_process(server_process); + wait_child_process(server_process); ok(CloseHandle(server_process), "CloseHandle\n"); /* create new server, rpcrt4 will connect to it once sending to existing connection fails @@ -2355,7 +2687,7 @@ static void test_reconnect(void) basic_tests(); stop(); - winetest_wait_child_process(server_process); + wait_child_process(server_process); ok(CloseHandle(server_process), "CloseHandle\n"); ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); @@ -2390,18 +2722,18 @@ static BOOL is_firewall_enabled(void) hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr, (void **)&mgr ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwMgr_get_LocalPolicy( mgr, &policy ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwPolicy_get_CurrentProfile( policy, &profile ); if (hr != S_OK) goto done; hr = INetFwProfile_get_FirewallEnabled( profile, &enabled ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); done: if (policy) INetFwPolicy_Release( policy ); @@ -2419,7 +2751,6 @@ enum firewall_op static HRESULT set_firewall( enum firewall_op op ) { - static const WCHAR testW[] = {'r','p','c','r','t','4','_','t','e','s','t',0}; HRESULT hr, init; INetFwMgr *mgr = NULL; INetFwPolicy *policy = NULL; @@ -2437,32 +2768,32 @@ static HRESULT set_firewall( enum firewall_op op ) hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr, (void **)&mgr ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwMgr_get_LocalPolicy( mgr, &policy ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwPolicy_get_CurrentProfile( policy, &profile ); if (hr != S_OK) goto done; hr = INetFwProfile_get_AuthorizedApplications( profile, &apps ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = CoCreateInstance( &CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwAuthorizedApplication, (void **)&app ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; hr = INetFwAuthorizedApplication_put_ProcessImageFileName( app, image ); if (hr != S_OK) goto done; - name = SysAllocString( testW ); + name = SysAllocString( L"rpcrt4_test" ); hr = INetFwAuthorizedApplication_put_Name( app, name ); SysFreeString( name ); - ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08lx\n", hr ); if (hr != S_OK) goto done; if (op == APP_ADD) @@ -2494,7 +2825,7 @@ START_TEST(server) set_mixed_interface(); ok(!GetUserNameExA(NameSamCompatible, NULL, &size), "GetUserNameExA\n"); - domain_and_user = HeapAlloc(GetProcessHeap(), 0, size); + domain_and_user = malloc(size); ok(GetUserNameExA(NameSamCompatible, domain_and_user, &size), "GetUserNameExA\n"); argc = winetest_get_mainargs(&argv); @@ -2520,13 +2851,9 @@ START_TEST(server) } else if(!strcmp(argv[2], "run")) { - UINT_PTR event; -#ifdef __REACTOS__ - sscanf(argv[3], "%Ix", &event); -#else + ULONG event; sscanf(argv[3], "%lx", &event); -#endif - run_server((HANDLE)event); + run_server(ULongToHandle(event)); } } else @@ -2543,7 +2870,7 @@ START_TEST(server) } else { - skip("can't authorize app in firewall %08x\n", hr); + skip("can't authorize app in firewall %08lx\n", hr); } } else @@ -2564,5 +2891,5 @@ START_TEST(server) if (firewall_disabled) set_firewall(APP_REMOVE); } - HeapFree(GetProcessHeap(), 0, domain_and_user); + free(domain_and_user); } diff --git a/modules/rostests/winetests/rpcrt4/server.idl b/modules/rostests/winetests/rpcrt4/server.idl index afda2eddd04..d8886ee2dd2 100644 --- a/modules/rostests/winetests/rpcrt4/server.idl +++ b/modules/rostests/winetests/rpcrt4/server.idl @@ -95,6 +95,29 @@ cpp_quote("#ifndef SKIP_TYPE_DECLS") int s; } sun_t; + + typedef struct + { + signed char a, b, c, d, e; + } chars_t; + + typedef struct + { + int i; + hyper j; + } ints_t; + + typedef struct + { + int i; + float f; + } flts_t; + + typedef struct + { + int i; + double d; + } dbls_t; cpp_quote("#endif") int int_return(void); @@ -107,6 +130,20 @@ cpp_quote("#endif") hyper sum_hyper(hyper x, hyper y); int sum_hyper_int(hyper x, hyper y); int sum_char_hyper(signed char x, hyper y); + int sum_ints(int a, ints_t x, ints_t y); + int sum_chars(int a, chars_t x, chars_t y); + int sum_flts(int a, flts_t x, flts_t y); + int sum_dbls(int a, dbls_t x, dbls_t y); + int sum_iiff(int x0, int y0, float x1, float y1); + int sum_ifif(int x0, float y0, int x1, float y1); + int sum_iidd(int x0, int y0, double x1, double y1); + int sum_idid(int x0, double y0, int x1, double y1); + int sum_ififififififif(int x0, float y0, int x1, float y1, int x2, float y2, int x3, float y3, int x4, float y4, int x5, float y5, int x6, float y6); + int sum_ididididididid(int x0, double y0, int x1, double y1, int x2, double y2, int x3, double y3, int x4, double y4, int x5, double y5, int x6, double y6); + int sum_idfdifdfifdfidifdidf(int x0, double y0, float z0, double y1, int x1, float z1, double y2, float z2, int x2, float z3, double y3, float z4, int x3, double y4, int x4, float z5, double y5, int x5, double y6, float z6); + int sum_ididididididididididid(int x0, double y0, int x1, double y1, int x2, double y2, int x3, double y3, int x4, double y4, int x5, double y5, int x6, double y6, int x7, double y7, int x8, double y8); + int sum_iidiidiidiidiidiidiidiidiidiidiid(int x0, int x1, double y0, int x2, int x3, double y1, int x4, int x5, double y2, int x6, int x7, double y3, int x8, int x9, double y4, int x10, int x11, double y5, int x12, int x13, double y6, int x14, int x15, double y7, int x16, int x17, double y8); + int sum_iyiy(int x0, hyper y0, int x1, hyper y1); void square_out(int x, [out] int *y); void square_ref([in, out] int *x); int str_length([string] const char *s); @@ -169,6 +206,30 @@ cpp_quote("#ifndef SKIP_TYPE_DECLS") [size_is(n)] int ca[]; } cs_t; + typedef struct + { + int n; + [size_is(n)] int *ca; + } cs_blob_t; + + typedef struct + { +/* FIXME: widl generates incorrect correlation descriptor and the tests crash */ +#if 0 + int dummy[1]; /* to make offset to conformant array unique */ +#endif + cs_blob_t blob; + } cs_data_t; + + typedef struct + { +/* FIXME: widl generates incorrect correlation descriptor and the tests crash */ +#if 0 + int dummy[2]; /* to make offset to conformant array unique */ +#endif + cs_data_t data; + } cs_container_t; + typedef struct { int *pn; @@ -191,6 +252,9 @@ cpp_quote("#endif") int sum_cpsc(cpsc_t *cpsc); int get_cpsc(int n, [out] cpsc_t *cpsc ); int sum_complex_array(int n, [size_is(n)] refpint_t pi[]); + int sum_blob([in] cs_blob_t *blob); + int sum_data([in] cs_data_t *data); + int sum_container([in] cs_container_t *container); cpp_quote("#ifndef SKIP_TYPE_DECLS") typedef [wire_marshal(int)] void *puint_t; @@ -458,4 +522,6 @@ cpp_quote("#endif") ctx_handle_t get_handle(); void get_handle_by_ptr([out] ctx_handle_t *r); void test_handle(ctx_handle_t ctx_handle); + + void test_I_RpcBindingInqLocalClientPID([in] unsigned int protseq, [in] handle_t binding); } diff --git a/sdk/include/ndk/pstypes.h b/sdk/include/ndk/pstypes.h index b7d6858d1c5..d52ccad32dd 100644 --- a/sdk/include/ndk/pstypes.h +++ b/sdk/include/ndk/pstypes.h @@ -412,6 +412,29 @@ typedef enum _THREADINFOCLASS ThreadActualBasePriority, ThreadTebInformation, ThreadCSwitchMon, + + // Windows 7 + ThreadCSwitchPmu, // 0x1C + ThreadWow64Context, + ThreadGroupInformation, + ThreadUmsInformation, + ThreadCounterProfiling, + ThreadIdealProcessorEx, + + // Windows 8 + ThreadCpuAccountingInformation, // 0x22 + + // Windows 8.1 + ThreadSuspendCount, // 0x23 + + // Windows 10 + ThreadHeterogeneousCpuPolic, // 0x24 + ThreadContainerId, + ThreadNameInformation, + ThreadSelectedCpuSets, + ThreadSystemThreadInformation, + ThreadActualGroupAffinity, + MaxThreadInfoClass } THREADINFOCLASS; @@ -1047,6 +1070,11 @@ typedef struct _THREAD_BASIC_INFORMATION KPRIORITY BasePriority; } THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION; +typedef struct _THREAD_NAME_INFORMATION +{ + UNICODE_STRING ThreadName; +} THREAD_NAME_INFORMATION, *PTHREAD_NAME_INFORMATION; + #ifndef NTOS_MODE_USER // diff --git a/sdk/include/psdk/processthreadsapi.h b/sdk/include/psdk/processthreadsapi.h index c0ce622fe05..3282cc35076 100644 --- a/sdk/include/psdk/processthreadsapi.h +++ b/sdk/include/psdk/processthreadsapi.h @@ -71,6 +71,20 @@ typedef struct _PROCESS_INFORMATION typedef struct _PROC_THREAD_ATTRIBUTE_LIST *PPROC_THREAD_ATTRIBUTE_LIST, *LPPROC_THREAD_ATTRIBUTE_LIST; +WINBASEAPI +HRESULT +WINAPI +GetThreadDescription( + _In_ HANDLE hThread, + _Outptr_result_z_ PWSTR* ppszThreadDescription); + +WINBASEAPI +HRESULT +WINAPI +SetThreadDescription( + _In_ HANDLE hThread, + _In_ PCWSTR lpThreadDescription); + WINBASEAPI BOOL WINAPI diff --git a/sdk/include/psdk/rpcasync.h b/sdk/include/psdk/rpcasync.h index 3203c6d7433..ba4ae2bf04a 100644 --- a/sdk/include/psdk/rpcasync.h +++ b/sdk/include/psdk/rpcasync.h @@ -23,6 +23,14 @@ #pragma warning(disable:4820) #endif +#ifdef RPC_NO_WINDOWS_H +# include +#endif + +#ifdef __RPC_WIN64__ +# include +#endif + typedef struct tagRPC_ERROR_ENUM_HANDLE { ULONG Signature; @@ -158,6 +166,10 @@ typedef struct _RPC_ASYNC_STATE #define RpcAsyncGetCallHandle(async) (((PRPC_ASYNC_STATE)async)->RuntimeInfo) +#ifdef __RPC_WIN64__ +# include +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/sdk/include/psdk/rpcdce.h b/sdk/include/psdk/rpcdce.h index e2812f0fc21..fc1fcea77b9 100644 --- a/sdk/include/psdk/rpcdce.h +++ b/sdk/include/psdk/rpcdce.h @@ -324,6 +324,8 @@ RPC_STATUS RPC_ENTRY DceErrorInqTextW(RPC_STATUS e, RPC_WSTR buffer); RPCRTAPI DECLSPEC_NORETURN void RPC_ENTRY RpcRaiseException( RPC_STATUS exception ); + +RPCRTAPI int RPC_ENTRY RpcExceptionFilter(ULONG); RPCRTAPI RPC_STATUS RPC_ENTRY RpcBindingCopy( RPC_BINDING_HANDLE SourceBinding, RPC_BINDING_HANDLE* DestinationBinding ); diff --git a/sdk/include/psdk/rpcdcep.h b/sdk/include/psdk/rpcdcep.h index fd0acda235e..bf518064553 100644 --- a/sdk/include/psdk/rpcdcep.h +++ b/sdk/include/psdk/rpcdcep.h @@ -220,6 +220,9 @@ RPCRTAPI UINT RPC_ENTRY #endif +RPCRTAPI RPC_STATUS RPC_ENTRY + I_RpcBindingInqLocalClientPID (RPC_BINDING_HANDLE Binding, ULONG *Pid ); + RPCRTAPI RPC_STATUS RPC_ENTRY I_RpcBindingInqTransportType( RPC_BINDING_HANDLE Binding, unsigned int* Type ); diff --git a/sdk/include/psdk/rpcndr.h b/sdk/include/psdk/rpcndr.h index 52e24b18472..0ebf7327fd4 100644 --- a/sdk/include/psdk/rpcndr.h +++ b/sdk/include/psdk/rpcndr.h @@ -24,6 +24,7 @@ #define __WINE_RPCNDR_H #include +#include #ifdef __cplusplus extern "C" { @@ -35,6 +36,7 @@ extern "C" { #pragma warning(disable:4255) #pragma warning(disable:4820) #endif + #undef CONST_VTBL #ifdef CONST_VTABLE # define CONST_VTBL const @@ -45,7 +47,6 @@ extern "C" { #ifndef EXTERN_GUID #ifdef __cplusplus #define EXTERN_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - EXTERN_C const GUID DECLSPEC_SELECTANY name DECLSPEC_HIDDEN; \ EXTERN_C const GUID DECLSPEC_SELECTANY name = \ { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } #else @@ -54,59 +55,18 @@ extern "C" { #endif #endif -/* stupid #if can't handle casts... this __stupidity - is just a workaround for that limitation */ - -#define __NDR_CHAR_REP_MASK 0x000f -#define __NDR_INT_REP_MASK 0x00f0 -#define __NDR_FLOAT_REP_MASK 0xff00 - -#define __NDR_IEEE_FLOAT 0x0000 -#define __NDR_VAX_FLOAT 0x0100 -#define __NDR_IBM_FLOAT 0x0300 - -#define __NDR_ASCII_CHAR 0x0000 -#define __NDR_EBCDIC_CHAR 0x0001 - -#define __NDR_LITTLE_ENDIAN 0x0010 -#define __NDR_BIG_ENDIAN 0x0000 - -/* Mac's are special */ -#if defined(__RPC_MAC__) -# define __NDR_LOCAL_DATA_REPRESENTATION \ - (__NDR_IEEE_FLOAT | __NDR_ASCII_CHAR | __NDR_BIG_ENDIAN) -#else -# define __NDR_LOCAL_DATA_REPRESENTATION \ - (__NDR_IEEE_FLOAT | __NDR_ASCII_CHAR | __NDR_LITTLE_ENDIAN) -#endif - -#define __NDR_LOCAL_ENDIAN \ - (__NDR_LOCAL_DATA_REPRESENTATION & __NDR_INT_REP_MASK) - -/* for convenience, define NDR_LOCAL_IS_BIG_ENDIAN iff it is */ -#if __NDR_LOCAL_ENDIAN == __NDR_BIG_ENDIAN -# define NDR_LOCAL_IS_BIG_ENDIAN -#elif __NDR_LOCAL_ENDIAN == __NDR_LITTLE_ENDIAN -# undef NDR_LOCAL_IS_BIG_ENDIAN -#else -# error alien NDR_LOCAL_ENDIAN - Greg botched the defines again, please report -#endif - -/* finally, do the casts like Microsoft */ - -#define NDR_CHAR_REP_MASK ((ULONG) __NDR_CHAR_REP_MASK) -#define NDR_INT_REP_MASK ((ULONG) __NDR_INT_REP_MASK) -#define NDR_FLOAT_REP_MASK ((ULONG) __NDR_FLOAT_REP_MASK) -#define NDR_IEEE_FLOAT ((ULONG) __NDR_IEEE_FLOAT) -#define NDR_VAX_FLOAT ((ULONG) __NDR_VAX_FLOAT) -#define NDR_IBM_FLOAT ((ULONG) __NDR_IBM_FLOAT) -#define NDR_ASCII_CHAR ((ULONG) __NDR_ASCII_CHAR) -#define NDR_EBCDIC_CHAR ((ULONG) __NDR_EBCDIC_CHAR) -#define NDR_LITTLE_ENDIAN ((ULONG) __NDR_LITTLE_ENDIAN) -#define NDR_BIG_ENDIAN ((ULONG) __NDR_BIG_ENDIAN) -#define NDR_LOCAL_DATA_REPRESENTATION ((ULONG) __NDR_LOCAL_DATA_REPRESENTATION) -#define NDR_LOCAL_ENDIAN ((ULONG) __NDR_LOCAL_ENDIAN) - +#define NDR_CHAR_REP_MASK ((ULONG)0x000f) +#define NDR_INT_REP_MASK ((ULONG)0x00f0) +#define NDR_FLOAT_REP_MASK ((ULONG)0xff00) +#define NDR_IEEE_FLOAT ((ULONG)0x0000) +#define NDR_VAX_FLOAT ((ULONG)0x0100) +#define NDR_IBM_FLOAT ((ULONG)0x0300) +#define NDR_ASCII_CHAR ((ULONG)0x0000) +#define NDR_EBCDIC_CHAR ((ULONG)0x0001) +#define NDR_LITTLE_ENDIAN ((ULONG)0x0010) +#define NDR_BIG_ENDIAN ((ULONG)0x0000) +#define NDR_LOCAL_DATA_REPRESENTATION NDR_LITTLE_ENDIAN +#define NDR_LOCAL_ENDIAN NDR_LITTLE_ENDIAN #define TARGET_IS_NT50_OR_LATER 1 #define TARGET_IS_NT40_OR_LATER 1 @@ -118,8 +78,13 @@ typedef INT64 hyper; typedef UINT64 MIDL_uhyper; typedef unsigned char boolean; +#ifndef _ERROR_STATUS_T_DEFINED +typedef ULONG error_status_t; +#define _ERROR_STATUS_T_DEFINED +#endif + #define __RPC_CALLEE WINAPI -#define RPC_VAR_ENTRY __cdecl +#define RPC_VAR_ENTRY WINAPIV #define NDR_SHAREABLE static #define MIDL_ascii_strlen(s) strlen(s) @@ -128,8 +93,8 @@ typedef unsigned char boolean; #define midl_user_free MIDL_user_free #define midl_user_allocate MIDL_user_allocate -void * __RPC_USER MIDL_user_allocate(SIZE_T); void __RPC_USER MIDL_user_free(void *); +void * __RPC_USER MIDL_user_allocate(SIZE_T) __WINE_ALLOC_SIZE(1) __WINE_DEALLOC(MIDL_user_free) __WINE_MALLOC; #define NdrFcShort(s) (unsigned char)(s & 0xff), (unsigned char)(s >> 8) #define NdrFcLong(s) (unsigned char)(s & 0xff), (unsigned char)((s & 0x0000ff00) >> 8), \ @@ -154,15 +119,33 @@ typedef void (__RPC_USER *NDR_RUNDOWN)(void *context); typedef void (__RPC_USER *NDR_NOTIFY_ROUTINE)(void); typedef void (__RPC_USER *NDR_NOTIFY2_ROUTINE)(boolean flag); -#ifndef DECLSPEC_UUID - #if defined(_MSC_VER) && defined(__cplusplus) - #define DECLSPEC_UUID(x) __declspec(uuid(x)) - #else - #define DECLSPEC_UUID(x) - #endif -#endif /* DECLSPEC_UUID */ +#ifdef __REACTOS__ +#ifndef __has_declspec_attribute +# if defined(_MSC_VER) +# define __has_declspec_attribute(x) 1 +# else +# define __has_declspec_attribute(x) 0 +# endif +#endif +#endif -#define MIDL_INTERFACE(x) struct +#ifndef DECLSPEC_NOVTABLE +# if __has_declspec_attribute(novtable) && defined(__cplusplus) +# define DECLSPEC_NOVTABLE __declspec(novtable) +# else +# define DECLSPEC_NOVTABLE +# endif +#endif + +#ifndef DECLSPEC_UUID +# if __has_declspec_attribute(uuid) && defined (__cplusplus) +# define DECLSPEC_UUID(x) __declspec(uuid(x)) +# else +# define DECLSPEC_UUID(x) +# endif +#endif + +#define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x) DECLSPEC_NOVTABLE struct _MIDL_STUB_MESSAGE; struct _MIDL_STUB_DESC; @@ -233,7 +216,7 @@ typedef struct _MIDL_STUB_MESSAGE ULONG PointerLength; unsigned int fInDontFree:1; unsigned int fDontCallFreeInst:1; - unsigned int fInOnlyParam:1; + unsigned int fUnused1 :1; unsigned int fHasReturn:1; unsigned int fHasExtensions:1; unsigned int fHasNewCorrDesc:1; @@ -244,8 +227,8 @@ typedef struct _MIDL_STUB_MESSAGE unsigned int fHasMemoryValidateCallback:1; unsigned int fInFree:1; unsigned int fNeedMCCP:1; - int fUnused:3; - int fUnused2:16; + int fUnused2:3; + int fUnused3:16; DWORD dwDestContext; void *pvDestContext; NDR_SCONTEXT *SavedContextHandles; @@ -357,6 +340,39 @@ typedef struct _COMM_FAULT_OFFSETS short FaultOffset; } COMM_FAULT_OFFSETS; +typedef enum _IDL_CS_CONVERT +{ + IDL_CS_NO_CONVERT, + IDL_CS_IN_PLACE_CONVERT, + IDL_CS_NEW_BUFFER_CONVERT +} IDL_CS_CONVERT; + +typedef void (__RPC_USER * CS_TYPE_NET_SIZE_ROUTINE)(RPC_BINDING_HANDLE,ULONG,ULONG,IDL_CS_CONVERT*,ULONG*,error_status_t*); +typedef void (__RPC_USER * CS_TYPE_TO_NETCS_ROUTINE)(RPC_BINDING_HANDLE,ULONG,void*,ULONG,byte*,ULONG*,error_status_t*); +typedef void (__RPC_USER * CS_TYPE_LOCAL_SIZE_ROUTINE)(RPC_BINDING_HANDLE,ULONG,ULONG,IDL_CS_CONVERT*,ULONG*,error_status_t*); +typedef void (__RPC_USER * CS_TYPE_FROM_NETCS_ROUTINE)(RPC_BINDING_HANDLE,ULONG,byte*,ULONG,ULONG,void*,ULONG*,error_status_t*); +typedef void (__RPC_USER * CS_TAG_GETTING_ROUTINE)(RPC_BINDING_HANDLE,int,ULONG*,ULONG*,ULONG*,error_status_t*); + +typedef struct _NDR_CS_SIZE_CONVERT_ROUTINES +{ + CS_TYPE_NET_SIZE_ROUTINE pfnNetSize; + CS_TYPE_TO_NETCS_ROUTINE pfnToNetCs; + CS_TYPE_LOCAL_SIZE_ROUTINE pfnLocalSize; + CS_TYPE_FROM_NETCS_ROUTINE pfnFromNetCs; +} NDR_CS_SIZE_CONVERT_ROUTINES; + +typedef struct _NDR_CS_ROUTINES +{ + NDR_CS_SIZE_CONVERT_ROUTINES *pSizeConvertRoutines; + CS_TAG_GETTING_ROUTINE *pTagGettingRoutines; +} NDR_CS_ROUTINES; + +typedef struct _NDR_EXPR_DESC +{ + const unsigned short *pOffset; + PFORMAT_STRING pFormatExpr; +} NDR_EXPR_DESC; + typedef struct _MIDL_STUB_DESC { void *RpcInterfaceInformation; @@ -380,22 +396,36 @@ typedef struct _MIDL_STUB_DESC const USER_MARSHAL_ROUTINE_QUADRUPLE *aUserMarshalQuadruple; const NDR_NOTIFY_ROUTINE *NotifyRoutineTable; ULONG_PTR mFlags; - ULONG_PTR Reserved3; - ULONG_PTR Reserved4; - ULONG_PTR Reserved5; + const NDR_CS_ROUTINES *CsRoutineTables; + void *ProxyServerInfo; + const NDR_EXPR_DESC *pExprInfo; } MIDL_STUB_DESC; typedef const MIDL_STUB_DESC *PMIDL_STUB_DESC; typedef struct _MIDL_FORMAT_STRING { short Pad; -#if defined(__GNUC__) - unsigned char Format[0]; -#else - unsigned char Format[1]; -#endif + unsigned char Format[]; } MIDL_FORMAT_STRING; +typedef struct _MIDL_METHOD_PROPERTY +{ + ULONG Id; + ULONG_PTR Value; +} MIDL_METHOD_PROPERTY, *PMIDL_METHOD_PROPERTY; + +typedef struct _MIDL_METHOD_PROPERTY_MAP +{ + ULONG Count; + const MIDL_METHOD_PROPERTY *Properties; +} MIDL_METHOD_PROPERTY_MAP, *PMIDL_METHOD_PROPERTY_MAP; + +typedef struct _MIDL_INTERFACE_METHOD_PROPERTIES +{ + unsigned short MethodCount; + const MIDL_METHOD_PROPERTY_MAP * const *MethodProperties; +} MIDL_INTERFACE_METHOD_PROPERTIES; + typedef struct _MIDL_SYNTAX_INFO { RPC_SYNTAX_IDENTIFIER TransferSyntax; @@ -404,13 +434,13 @@ typedef struct _MIDL_SYNTAX_INFO const unsigned short* FmtStringOffset; PFORMAT_STRING TypeString; const void* aUserMarshalQuadruple; - ULONG_PTR pReserved1; + const MIDL_INTERFACE_METHOD_PROPERTIES *pMethodProperties; ULONG_PTR pReserved2; } MIDL_SYNTAX_INFO, *PMIDL_SYNTAX_INFO; typedef void (__RPC_API *STUB_THUNK)( PMIDL_STUB_MESSAGE ); -#ifdef WINE_STRICT_PROTOTYPES +#ifndef WINE_NO_STRICT_PROTOTYPES typedef LONG (__RPC_API *SERVER_ROUTINE)(void); #else typedef LONG (__RPC_API *SERVER_ROUTINE)(); @@ -438,11 +468,17 @@ typedef struct _MIDL_STUBLESS_PROXY_INFO PMIDL_SYNTAX_INFO pSyntaxInfo; } MIDL_STUBLESS_PROXY_INFO, *PMIDL_STUBLESS_PROXY_INFO; + +#if defined(__i386__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) +/* Calling convention for returning structures/unions is different between Windows and gcc on i386 */ +typedef LONG_PTR CLIENT_CALL_RETURN; +#else typedef union _CLIENT_CALL_RETURN { void *Pointer; LONG_PTR Simple; } CLIENT_CALL_RETURN; +#endif typedef enum { STUB_UNMARSHAL, @@ -491,7 +527,6 @@ typedef struct _FULL_PTR_XLAT_TABLES { struct IRpcStubBuffer; -typedef ULONG error_status_t; typedef void * NDR_CCONTEXT; typedef struct _SCONTEXT_QUEUE { @@ -669,12 +704,16 @@ RPCRTAPI void RPC_ENTRY RPCRTAPI unsigned char* RPC_ENTRY NdrUserMarshalSimpleTypeConvert( ULONG *pFlags, unsigned char *pBuffer, unsigned char FormatChar ); -CLIENT_CALL_RETURN RPC_VAR_ENTRY - NdrClientCall2( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... ); CLIENT_CALL_RETURN RPC_VAR_ENTRY NdrClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... ); +CLIENT_CALL_RETURN RPC_VAR_ENTRY + NdrClientCall2( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... ); +CLIENT_CALL_RETURN RPC_VAR_ENTRY + NdrClientCall3( MIDL_STUBLESS_PROXY_INFO *info, ULONG proc, void *retval, ... ); CLIENT_CALL_RETURN RPC_VAR_ENTRY NdrAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... ); +CLIENT_CALL_RETURN RPC_VAR_ENTRY + Ndr64AsyncClientCall( MIDL_STUBLESS_PROXY_INFO *info, ULONG proc, void *retval, ... ); CLIENT_CALL_RETURN RPC_VAR_ENTRY NdrDcomAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... ); @@ -697,7 +736,7 @@ RPCRTAPI LONG RPC_ENTRY NdrDcomAsyncStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, DWORD * pdwStubPhase ); RPCRTAPI void* RPC_ENTRY - NdrAllocate( PMIDL_STUB_MESSAGE pStubMsg, SIZE_T Len ) __WINE_ALLOC_SIZE(2); + NdrAllocate( PMIDL_STUB_MESSAGE pStubMsg, SIZE_T Len ) __WINE_ALLOC_SIZE(2) __WINE_MALLOC; RPCRTAPI void RPC_ENTRY NdrClearOutParameters( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, void *ArgAddr ); @@ -706,10 +745,10 @@ RPCRTAPI RPC_STATUS RPC_ENTRY NdrMapCommAndFaultStatus( PMIDL_STUB_MESSAGE pStubMsg, ULONG *pCommStatus, ULONG *pFaultStatus, RPC_STATUS Status_ ); -RPCRTAPI void* RPC_ENTRY - NdrOleAllocate( SIZE_T Size ) __WINE_ALLOC_SIZE(1); RPCRTAPI void RPC_ENTRY NdrOleFree( void* NodeToFree ); +RPCRTAPI void* RPC_ENTRY + NdrOleAllocate( SIZE_T Size ) __WINE_ALLOC_SIZE(1) __WINE_DEALLOC(NdrOleFree) __WINE_MALLOC; RPCRTAPI void RPC_ENTRY NdrClientInitialize( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg, @@ -732,7 +771,8 @@ RPCRTAPI void RPC_ENTRY PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, void *pParamList ); RPCRTAPI unsigned char* RPC_ENTRY - NdrGetBuffer( PMIDL_STUB_MESSAGE stubmsg, ULONG buflen, RPC_BINDING_HANDLE handle ); + NdrGetBuffer( PMIDL_STUB_MESSAGE stubmsg, ULONG buflen, RPC_BINDING_HANDLE handle ) + __WINE_ALLOC_SIZE(2) __WINE_MALLOC; RPCRTAPI void RPC_ENTRY NdrFreeBuffer( PMIDL_STUB_MESSAGE pStubMsg ); RPCRTAPI unsigned char* RPC_ENTRY @@ -767,14 +807,14 @@ RPCRTAPI void RPC_ENTRY NdrRpcSsDisableAllocate( PMIDL_STUB_MESSAGE pMessage ); RPCRTAPI void RPC_ENTRY NdrRpcSmSetClientToOsf( PMIDL_STUB_MESSAGE pMessage ); -RPCRTAPI void * RPC_ENTRY - NdrRpcSmClientAllocate( SIZE_T Size ) __WINE_ALLOC_SIZE(1); RPCRTAPI void RPC_ENTRY NdrRpcSmClientFree( void *NodeToFree ); RPCRTAPI void * RPC_ENTRY - NdrRpcSsDefaultAllocate( SIZE_T Size ) __WINE_ALLOC_SIZE(1); + NdrRpcSmClientAllocate( SIZE_T Size ) __WINE_ALLOC_SIZE(1) __WINE_DEALLOC(NdrRpcSmClientFree) __WINE_MALLOC; RPCRTAPI void RPC_ENTRY NdrRpcSsDefaultFree( void *NodeToFree ); +RPCRTAPI void * RPC_ENTRY + NdrRpcSsDefaultAllocate( SIZE_T Size ) __WINE_ALLOC_SIZE(1) __WINE_DEALLOC(NdrRpcSsDefaultFree) __WINE_MALLOC; RPCRTAPI RPC_STATUS RPC_ENTRY NdrGetUserMarshalInfo( ULONG *pFlags, ULONG InformationLevel, NDR_USER_MARSHAL_INFO *pMarshalInfo ); diff --git a/sdk/include/psdk/rpcproxy.h b/sdk/include/psdk/rpcproxy.h index 4d2c63e62d6..85f50164db5 100644 --- a/sdk/include/psdk/rpcproxy.h +++ b/sdk/include/psdk/rpcproxy.h @@ -17,8 +17,7 @@ */ #ifndef __RPCPROXY_H_VERSION__ -/* FIXME: Find an appropriate version number. I guess something is better than nothing */ -#define __RPCPROXY_H_VERSION__ ( 399 ) +#define __RPCPROXY_H_VERSION__ (477) #endif #ifndef __WINE_RPCPROXY_H @@ -78,11 +77,7 @@ typedef struct tagCInterfaceProxyHeader typedef struct tagCInterfaceProxyVtbl { CInterfaceProxyHeader header; -#if defined(__GNUC__) - void *Vtbl[0]; -#else - void *Vtbl[1]; -#endif + void *Vtbl[]; } CInterfaceProxyVtbl; typedef void (__RPC_STUB *PRPC_STUB_FUNCTION)( @@ -125,34 +120,22 @@ typedef struct tagCStdPSFactoryBuffer #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction -ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This) DECLSPEC_HIDDEN; -ULONG STDMETHODCALLTYPE NdrCStdStubBuffer2_Release(IRpcStubBuffer *This, IPSFactoryBuffer *pPSF); - #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0 +RPCRTAPI HRESULT WINAPI CStdStubBuffer_QueryInterface( IRpcStubBuffer *This, REFIID riid, void **ppvObject ); +RPCRTAPI ULONG WINAPI CStdStubBuffer_AddRef( IRpcStubBuffer *This ); +RPCRTAPI HRESULT WINAPI CStdStubBuffer_Connect( IRpcStubBuffer *This, IUnknown *pUnkServer ); +RPCRTAPI void WINAPI CStdStubBuffer_Disconnect( IRpcStubBuffer *This ); +RPCRTAPI HRESULT WINAPI CStdStubBuffer_Invoke( IRpcStubBuffer *This, RPCOLEMESSAGE *pRpcMsg, IRpcChannelBuffer *pRpcChannelBuffer ); +RPCRTAPI IRpcStubBuffer * WINAPI CStdStubBuffer_IsIIDSupported( IRpcStubBuffer *This, REFIID riid ); +RPCRTAPI ULONG WINAPI CStdStubBuffer_CountRefs( IRpcStubBuffer *This ); +RPCRTAPI HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface( IRpcStubBuffer *This, void **ppv ); +RPCRTAPI void WINAPI CStdStubBuffer_DebugServerRelease( IRpcStubBuffer *This, void *pv ); +RPCRTAPI ULONG WINAPI NdrCStdStubBuffer_Release( IRpcStubBuffer *This, IPSFactoryBuffer *pPSF ); +RPCRTAPI ULONG WINAPI NdrCStdStubBuffer2_Release(IRpcStubBuffer *This, IPSFactoryBuffer *pPSF); -HRESULT WINAPI - CStdStubBuffer_QueryInterface( IRpcStubBuffer *This, REFIID riid, void **ppvObject ); -ULONG WINAPI - CStdStubBuffer_AddRef( IRpcStubBuffer *This ); -ULONG WINAPI - CStdStubBuffer_Release( IRpcStubBuffer *This ) DECLSPEC_HIDDEN; -ULONG WINAPI - NdrCStdStubBuffer_Release( IRpcStubBuffer *This, IPSFactoryBuffer *pPSF ); -HRESULT WINAPI - CStdStubBuffer_Connect( IRpcStubBuffer *This, IUnknown *pUnkServer ); -void WINAPI - CStdStubBuffer_Disconnect( IRpcStubBuffer *This ); -HRESULT WINAPI - CStdStubBuffer_Invoke( IRpcStubBuffer *This, RPCOLEMESSAGE *pRpcMsg, IRpcChannelBuffer *pRpcChannelBuffer ); -IRpcStubBuffer * WINAPI - CStdStubBuffer_IsIIDSupported( IRpcStubBuffer *This, REFIID riid ); -ULONG WINAPI - CStdStubBuffer_CountRefs( IRpcStubBuffer *This ); -HRESULT WINAPI - CStdStubBuffer_DebugServerQueryInterface( IRpcStubBuffer *This, void **ppv ); -void WINAPI - CStdStubBuffer_DebugServerRelease( IRpcStubBuffer *This, void *pv ); +ULONG STDMETHODCALLTYPE CStdStubBuffer_Release( IRpcStubBuffer *This ); +ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This); #define CStdStubBuffer_METHODS \ CStdStubBuffer_QueryInterface, \ @@ -203,8 +186,15 @@ RPCRTAPI HRESULT RPC_ENTRY RPCRTAPI HRESULT RPC_ENTRY NdrDllUnregisterProxy( HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid ); -HRESULT __wine_register_resources( HMODULE module ) DECLSPEC_HIDDEN; -HRESULT __wine_unregister_resources( HMODULE module ) DECLSPEC_HIDDEN; +#ifdef USE_NEW_WINE_REGISTER_RESOURCES // This needs a global fix. See wine git rev 1331a8e. +#define __wine_register_resources __wine_register_resources_new +#define __wine_unregister_resources __wine_unregister_resources_new +HRESULT __cdecl __wine_register_resources(void); +HRESULT __cdecl __wine_unregister_resources(void); +#else +HRESULT __cdecl __wine_register_resources( HMODULE module ); +HRESULT __cdecl __wine_unregister_resources( HMODULE module ); +#endif #define CSTDSTUBBUFFERRELEASE(pFactory) \ ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \ @@ -236,10 +226,10 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ /* macros used in dlldata.c files */ #define EXTERN_PROXY_FILE(proxy) \ - EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo DECLSPEC_HIDDEN; + EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo; #define PROXYFILE_LIST_START \ - const ProxyFileInfo * aProxyFileList[] DECLSPEC_HIDDEN = \ + const ProxyFileInfo * aProxyFileList[] = \ { #define REFERENCE_PROXY_FILE(proxy) \ @@ -254,11 +244,10 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ /* define PROXY_CLSID_IS to specify the CLSID data of the PSFactoryBuffer */ /* define neither to use the GUID of the first interface */ #ifdef PROXY_CLSID -# define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID DECLSPEC_HIDDEN; +# define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID; #else # ifdef PROXY_CLSID_IS -# define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer DECLSPEC_HIDDEN; \ - const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS; +# define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS; # define PROXY_CLSID CLSID_PSFactoryBuffer # else # define CLSID_PSFACTORYBUFFER @@ -289,8 +278,13 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ #endif #ifdef WINE_REGISTER_DLL +#ifdef USE_NEW_WINE_REGISTER_RESOURCES +# define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources() +# define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources() +#else # define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources( hProxyDll ) # define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources( hProxyDll ) +#endif #else # define WINE_DO_REGISTER_DLL(pfl, clsid) return NdrDllRegisterProxy( hProxyDll, (pfl), (clsid) ) # define WINE_DO_UNREGISTER_DLL(pfl, clsid) return NdrDllUnregisterProxy( hProxyDll, (pfl), (clsid) ) @@ -299,7 +293,7 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ #define DLLDATA_GETPROXYDLLINFO(pfl, rclsid) \ void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \ - const CLSID **ppClsid) DECLSPEC_HIDDEN; \ + const CLSID **ppClsid); \ void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \ const CLSID **ppClsid) \ { \ @@ -308,7 +302,7 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ } #define DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, factory) \ - HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN; \ + HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, void **ppv); \ HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, \ void **ppv) \ { \ @@ -317,16 +311,16 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ } #define DLLCANUNLOADNOW(factory) \ - HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) DECLSPEC_HIDDEN; \ + HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void); \ HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) \ { \ return NdrDllCanUnloadNow((factory)); \ } #define REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid) \ - HINSTANCE hProxyDll DECLSPEC_HIDDEN = NULL; \ + HINSTANCE hProxyDll = NULL; \ \ - BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DECLSPEC_HIDDEN; \ + BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); \ BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, \ LPVOID lpvReserved) \ { \ @@ -338,13 +332,13 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ return TRUE; \ } \ \ - HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) DECLSPEC_HIDDEN; \ + HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void); \ HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) \ { \ WINE_DO_REGISTER_DLL( (pfl), (factory_clsid) ); \ } \ \ - HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) DECLSPEC_HIDDEN; \ + HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void); \ HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) \ { \ WINE_DO_UNREGISTER_DLL( (pfl), (factory_clsid) ); \ @@ -359,7 +353,7 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ #define DLLDATA_ROUTINES(pfl, factory_clsid) \ CLSID_PSFACTORYBUFFER \ - CStdPSFactoryBuffer DECLSPEC_HIDDEN gPFactory = { NULL, 0, NULL, 0 }; \ + CStdPSFactoryBuffer gPFactory = { NULL, 0, NULL, 0 }; \ DLLDATA_GETPROXYDLLINFO(pfl, factory_clsid) \ DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, &gPFactory) \ DLLCANUNLOADNOW(&gPFactory) \ diff --git a/sdk/include/psdk/rpcsal.h b/sdk/include/psdk/rpcsal.h new file mode 100644 index 00000000000..72a61ef298d --- /dev/null +++ b/sdk/include/psdk/rpcsal.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2011 Francois Gouget + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#ifndef __RPCSAL_H_VERSION__ +# define __RPCSAL_H_VERSION__ 100 +#endif + +#define __RPC__deref_in +#define __RPC__deref_in_opt +#define __RPC__deref_in_string +#define __RPC__deref_in_opt_string +#define __RPC__deref_in_ecount(size) +#define __RPC__deref_in_ecount_opt(size) +#define __RPC__deref_in_ecount_opt_string(size) +#define __RPC__deref_in_ecount_full(size) +#define __RPC__deref_in_ecount_full_opt(size) +#define __RPC__deref_in_ecount_full_string(size) +#define __RPC__deref_in_ecount_full_opt_string(size) +#define __RPC__deref_in_ecount_part(size, length) +#define __RPC__deref_in_ecount_part_opt(size, length) +#define __RPC__deref_in_xcount(size) +#define __RPC__deref_in_xcount_opt(size) +#define __RPC__deref_in_xcount_opt_string(size) +#define __RPC__deref_in_xcount_full(size) +#define __RPC__deref_in_xcount_full_opt(size) +#define __RPC__deref_in_xcount_full_string(size) +#define __RPC__deref_in_xcount_full_opt_string(size) +#define __RPC__deref_in_xcount_part(size, length) +#define __RPC__deref_in_xcount_part_opt(size, length) + +#define __RPC__deref_inout +#define __RPC__deref_inout_opt +#define __RPC__deref_inout_string +#define __RPC__deref_inout_opt_string +#define __RPC__deref_inout_ecount_opt(size) +#define __RPC__deref_inout_ecount_full(size) +#define __RPC__deref_inout_ecount_full_opt(size) +#define __RPC__deref_inout_ecount_full_string(size) +#define __RPC__deref_inout_ecount_full_opt_string(size) +#define __RPC__deref_inout_ecount_part_opt(size, length) +#define __RPC__deref_inout_xcount_opt(size) +#define __RPC__deref_inout_xcount_full(size) +#define __RPC__deref_inout_xcount_full_opt(size) +#define __RPC__deref_inout_xcount_full_string(size) +#define __RPC__deref_inout_xcount_full_opt_string(size) +#define __RPC__deref_inout_xcount_part_opt(size, length) + +#define __RPC__deref_out +#define __RPC__deref_out_opt +#define __RPC__deref_out_string +#define __RPC__deref_out_opt_string +#define __RPC__deref_out_ecount(size) +#define __RPC__deref_out_ecount_opt(size) +#define __RPC__deref_out_ecount_full(size) +#define __RPC__deref_out_ecount_full_opt(size) +#define __RPC__deref_out_ecount_full_string(size) +#define __RPC__deref_out_ecount_full_opt_string(size) +#define __RPC__deref_out_ecount_part(size, length) +#define __RPC__deref_out_ecount_part_opt(size, length) +#define __RPC__deref_out_xcount(size) +#define __RPC__deref_out_xcount_opt(size) +#define __RPC__deref_out_xcount_full(size) +#define __RPC__deref_out_xcount_full_opt(size) +#define __RPC__deref_out_xcount_full_string(size) +#define __RPC__deref_out_xcount_full_opt_string(size) +#define __RPC__deref_out_xcount_part(size, length) +#define __RPC__deref_out_xcount_part_opt(size, length) + +#define __RPC__deref_opt_in +#define __RPC__deref_opt_in_opt +#define __RPC__deref_opt_in_string +#define __RPC__deref_opt_in_opt_string + +#define __RPC__deref_opt_inout +#define __RPC__deref_opt_inout_opt +#define __RPC__deref_opt_inout_string +#define __RPC__deref_opt_inout_opt_string +#define __RPC__deref_opt_inout_ecount(size) +#define __RPC__deref_opt_inout_ecount_opt(size) +#define __RPC__deref_opt_inout_ecount_full(size) +#define __RPC__deref_opt_inout_ecount_full_opt(size) +#define __RPC__deref_opt_inout_ecount_full_string(size) +#define __RPC__deref_opt_inout_ecount_full_opt_string(size) +#define __RPC__deref_opt_inout_ecount_part(size, length) +#define __RPC__deref_opt_inout_ecount_part_opt(size, length) +#define __RPC__deref_opt_inout_xcount(size) +#define __RPC__deref_opt_inout_xcount_opt(size) +#define __RPC__deref_opt_inout_xcount_full(size) +#define __RPC__deref_opt_inout_xcount_full_opt(size) +#define __RPC__deref_opt_inout_xcount_full_string(size) +#define __RPC__deref_opt_inout_xcount_full_opt_string(size) +#define __RPC__deref_opt_inout_xcount_part(size, length) +#define __RPC__deref_opt_inout_xcount_part_opt(size, length) + +#define __RPC__in +#define __RPC__in_opt +#define __RPC__in_string +#define __RPC__in_opt_string +#define __RPC__in_ecount(size) +#define __RPC__in_ecount_opt(size) +#define __RPC__in_ecount_full(size) +#define __RPC__in_ecount_full_opt(size) +#define __RPC__in_ecount_full_string(size) +#define __RPC__in_ecount_full_opt_string(size) +#define __RPC__in_ecount_part(size, length) +#define __RPC__in_ecount_part_opt(size, length) +#define __RPC__in_xcount(size) +#define __RPC__in_xcount_opt(size) +#define __RPC__in_xcount_full(size) +#define __RPC__in_xcount_full_opt(size) +#define __RPC__in_xcount_full_string(size) +#define __RPC__in_xcount_full_opt_string(size) +#define __RPC__in_xcount_part(size, length) +#define __RPC__in_xcount_part_opt(size, length) + +#define __RPC__inout +#define __RPC__inout_opt +#define __RPC__inout_string +#define __RPC__inout_opt_string +#define __RPC__opt_inout +#define __RPC__inout_ecount(size) +#define __RPC__inout_ecount_opt(size) +#define __RPC__inout_ecount_full(size) +#define __RPC__inout_ecount_full_opt(size) +#define __RPC__inout_ecount_full_string(size) +#define __RPC__inout_ecount_full_opt_string(size) +#define __RPC__inout_ecount_part(size, length) +#define __RPC__inout_ecount_part_opt(size, length) +#define __RPC__inout_xcount(size) +#define __RPC__inout_xcount_opt(size) +#define __RPC__inout_xcount_full(size) +#define __RPC__inout_xcount_full_opt(size) +#define __RPC__inout_xcount_full_string(size) +#define __RPC__inout_xcount_full_opt_string(size) +#define __RPC__inout_xcount_part(size, length) +#define __RPC__inout_xcount_part_opt(size, length) + +#define __RPC__out +#define __RPC__out_ecount(size) +#define __RPC__out_ecount_full(size) +#define __RPC__out_ecount_full_string(size) +#define __RPC__out_ecount_part(size, length) +#define __RPC__out_xcount(size) +#define __RPC__out_xcount_full(size) +#define __RPC__out_xcount_full_string(size) +#define __RPC__out_xcount_part(size, length) + +#define __RPC_full_pointer +#define __RPC_ref_pointer +#define __RPC_string +#define __RPC_unique_pointer + +#define __RPC__range(min,max) +#define __RPC__in_range(min,max) diff --git a/sdk/include/psdk/winbase.h b/sdk/include/psdk/winbase.h index 86575d8df55..e5eaa8af581 100644 --- a/sdk/include/psdk/winbase.h +++ b/sdk/include/psdk/winbase.h @@ -1973,6 +1973,13 @@ WINBASEAPI BOOL WINAPI NeedCurrentDirectoryForExePathA(LPCSTR ExeName); WINBASEAPI BOOL WINAPI NeedCurrentDirectoryForExePathW(LPCWSTR ExeName); #endif +WINBASEAPI +BOOL +WINAPI +GetNamedPipeClientProcessId( + _In_ HANDLE Pipe, + _Out_ PULONG ClientProcessId); + BOOL WINAPI GetNamedPipeHandleStateA( diff --git a/sdk/lib/3rdparty/libwine/register.c b/sdk/lib/3rdparty/libwine/register.c index 70a4a35dc92..a000e6f4f69 100644 --- a/sdk/lib/3rdparty/libwine/register.c +++ b/sdk/lib/3rdparty/libwine/register.c @@ -30,9 +30,21 @@ #include "rpcproxy.h" #include "atliface.h" +static inline void *image_base(void) +{ +#if defined(__MINGW32__) || defined(_MSC_VER) + extern IMAGE_DOS_HEADER __ImageBase; + return (void *)&__ImageBase; +#else + extern IMAGE_NT_HEADERS __wine_spec_nt_header; + return (void *)((__wine_spec_nt_header.OptionalHeader.ImageBase + 0xffff) & ~0xffff); +#endif +} + static const WCHAR atl100W[] = {'a','t','l','1','0','0','.','d','l','l',0}; static const WCHAR regtypeW[] = {'W','I','N','E','_','R','E','G','I','S','T','R','Y',0}; static const WCHAR moduleW[] = {'M','O','D','U','L','E',0}; +static const WCHAR systemrootW[] = {'S','y','s','t','e','m','R','o','o','t',0}; struct reg_info { @@ -63,6 +75,8 @@ static IRegistrar *create_registrar( HMODULE inst, struct reg_info *info ) GetModuleFileNameW( inst, str, MAX_PATH ); IRegistrar_AddReplacement( info->registrar, moduleW, str ); + GetEnvironmentVariableW( systemrootW, str, MAX_PATH ); + IRegistrar_AddReplacement( info->registrar, systemrootW, str ); } return info->registrar; } @@ -118,3 +132,29 @@ HRESULT __wine_unregister_resources( HMODULE module ) if (info.registrar) IRegistrar_Release( info.registrar ); return info.result; } + +// FIXME: Workaround until all modules use the new prototype +// See rpcproxy.h +HRESULT __cdecl __wine_register_resources_new(void) +{ + struct reg_info info; + + info.registrar = NULL; + info.do_register = TRUE; + info.result = S_OK; + EnumResourceNamesW( image_base(), regtypeW, register_resource, (LONG_PTR)&info ); + if (info.registrar) IRegistrar_Release( info.registrar ); + return info.result; +} + +HRESULT __cdecl __wine_unregister_resources_new(void) +{ + struct reg_info info; + + info.registrar = NULL; + info.do_register = FALSE; + info.result = S_OK; + EnumResourceNamesW( image_base(), regtypeW, register_resource, (LONG_PTR)&info ); + if (info.registrar) IRegistrar_Release( info.registrar ); + return info.result; +} diff --git a/sdk/lib/rtl/threadpool.c b/sdk/lib/rtl/threadpool.c index 52aa7da5115..19b0e8cc7c8 100644 --- a/sdk/lib/rtl/threadpool.c +++ b/sdk/lib/rtl/threadpool.c @@ -34,11 +34,6 @@ #define ARRAY_SIZE(_x) (sizeof((_x))/sizeof((_x)[0])) #endif -typedef struct _THREAD_NAME_INFORMATION -{ - UNICODE_STRING ThreadName; -} THREAD_NAME_INFORMATION, *PTHREAD_NAME_INFORMATION; - typedef void (CALLBACK *PNTAPCFUNC)(ULONG_PTR,ULONG_PTR,ULONG_PTR); typedef void (CALLBACK *PRTL_THREAD_START_ROUTINE)(LPVOID); typedef DWORD (CALLBACK *PRTL_WORK_ITEM_ROUTINE)(LPVOID); @@ -1883,7 +1878,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON if (environment) { -#ifndef __REACTOS__ //Windows 7 stuff +#ifndef __REACTOS__ //Windows 7 stuff /* Validate environment parameters. */ if (environment->Version == 3) { @@ -1920,7 +1915,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON pool = default_threadpool; } - + RtlEnterCriticalSection( &pool->cs ); /* Make sure that the threadpool has at least one thread. */ diff --git a/sdk/tools/winesync/rpcrt4.cfg b/sdk/tools/winesync/rpcrt4.cfg new file mode 100644 index 00000000000..b7bde2bb7de --- /dev/null +++ b/sdk/tools/winesync/rpcrt4.cfg @@ -0,0 +1,8 @@ +directories: + dlls/rpcrt4: dll/win32/rpcrt4 + dlls/rpcrt4/tests: modules/rostests/winetests/rpcrt4 +files: + include/rpcndr.h: sdk/include/psdk/rpcndr.h + include/rpcproxy.h: sdk/include/psdk/rpcproxy.h +tags: + wine: wine-10.0-rc2