diff --git a/dll/win32/kernel32/client/file/npipe.c b/dll/win32/kernel32/client/file/npipe.c index 4af4965627a..a2eb601ecd5 100644 --- a/dll/win32/kernel32/client/file/npipe.c +++ b/dll/win32/kernel32/client/file/npipe.c @@ -1395,4 +1395,13 @@ TransactNamedPipe(IN HANDLE hNamedPipe, return TRUE; } +BOOL WINAPI GetNamedPipeClientProcessId( HANDLE pipe, ULONG *id ){ + NTSTATUS Status; + IO_STATUS_BLOCK iosb; + + Status = NtFsControlFile( pipe, NULL, NULL, NULL, &iosb, + FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE, (void *)"ClientProcessId", + sizeof("ClientProcessId"), id, sizeof(*id) ); + return NT_SUCCESS(Status); +} /* EOF */ diff --git a/dll/win32/kernel32/kernel32.spec b/dll/win32/kernel32/kernel32.spec index 831681d1aaa..c83bf5fc72a 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 GetNamedPipeClientProcessId(long ptr) @ stub -version=0x600+ GetNamedPipeClientSessionId @ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr str long) @ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long) diff --git a/dll/win32/ole32/compobj.c b/dll/win32/ole32/compobj.c index e0c1b0b745f..b8f9e12aadb 100644 --- a/dll/win32/ole32/compobj.c +++ b/dll/win32/ole32/compobj.c @@ -5238,9 +5238,10 @@ HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier) */ HRESULT WINAPI CoDisableCallCancellation(void *reserved) { - FIXME("(%p): stub\n", reserved); - - return E_NOTIMPL; + TRACE("(%p): stub\n", reserved); + struct oletls *info = COM_CurrentInfo(); + info->cancelcount--; + return S_OK; } /*********************************************************************** @@ -5248,9 +5249,10 @@ HRESULT WINAPI CoDisableCallCancellation(void *reserved) */ HRESULT WINAPI CoEnableCallCancellation(void *reserved) { - FIXME("(%p): stub\n", reserved); - - return E_NOTIMPL; + TRACE("(%p): stub\n", reserved); + struct oletls *info = COM_CurrentInfo(); + info->cancelcount++; + return S_OK; } /*********************************************************************** diff --git a/dll/win32/ole32/compobj_private.h b/dll/win32/ole32/compobj_private.h index bda1c6bff2a..3547a96f60c 100644 --- a/dll/win32/ole32/compobj_private.h +++ b/dll/win32/ole32/compobj_private.h @@ -180,6 +180,7 @@ struct oletls IUnknown *cancel_object; /* cancel object set by CoSetCancelObject (+F8h on x86) */ struct list spies; /* Spies installed with CoRegisterInitializeSpy */ DWORD spies_lock; + DWORD cancelcount; }; diff --git a/dll/win32/oleacc/main.c b/dll/win32/oleacc/main.c index 57b02a0e136..cd2864feab0 100644 --- a/dll/win32/oleacc/main.c +++ b/dll/win32/oleacc/main.c @@ -340,10 +340,116 @@ LRESULT WINAPI LresultFromObject( REFIID riid, WPARAM wParam, LPUNKNOWN pAcc ) return atom; } -HRESULT WINAPI AccessibleObjectFromPoint( POINT ptScreen, IAccessible** ppacc, VARIANT* pvarChild ) +static void variant_init_i4( VARIANT *v, int val ) { - FIXME("{%d,%d} %p %p: stub\n", ptScreen.x, ptScreen.y, ppacc, pvarChild ); - return E_NOTIMPL; + V_VT(v) = VT_I4; + V_I4(v) = val; +} + +HRESULT WINAPI AccessibleObjectFromEvent( HWND hwnd, DWORD object_id, DWORD child_id, + IAccessible **acc_out, VARIANT *child_id_out ) +{ + VARIANT child_id_variant; + IAccessible *acc = NULL; + IDispatch *child = NULL; + HRESULT hr; + + TRACE("%p %ld %ld %p %p\n", hwnd, object_id, child_id, acc_out, child_id_out); + + if (!acc_out) + return E_INVALIDARG; + *acc_out = NULL; + VariantInit(child_id_out); + + hr = AccessibleObjectFromWindow(hwnd, object_id, &IID_IAccessible, (void **)&acc); + if (FAILED(hr)) + return hr; + + variant_init_i4(&child_id_variant, child_id); + hr = IAccessible_get_accChild(acc, child_id_variant, &child); + if (FAILED(hr)) + TRACE("get_accChild failed with %#lx!\n", hr); + + if (SUCCEEDED(hr) && child) + { + IAccessible_Release(acc); + hr = IDispatch_QueryInterface(child, &IID_IAccessible, (void **)&acc); + IDispatch_Release(child); + if (FAILED(hr)) + return hr; + + variant_init_i4(&child_id_variant, CHILDID_SELF); + } + + *acc_out = acc; + *child_id_out = child_id_variant; + + return S_OK; +} + +HRESULT WINAPI AccessibleObjectFromPoint( POINT point, IAccessible** acc, VARIANT* child_id ) +{ + IAccessible *cur; + HRESULT hr; + VARIANT v; + HWND hwnd; + + TRACE("{%ld,%ld} %p %p\n", point.x, point.y, acc, child_id); + + if (!acc || !child_id) + return E_INVALIDARG; + + *acc = NULL; + V_VT(child_id) = VT_EMPTY; + + hwnd = WindowFromPoint(point); + if (!hwnd) + return E_FAIL; + hwnd = GetAncestor(hwnd, GA_ROOT); + + hr = AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, &IID_IAccessible, (void **)&cur); + if (FAILED(hr)) + return hr; + if (!cur) + return E_FAIL; + + V_VT(&v) = VT_EMPTY; + while (1) + { + hr = IAccessible_accHitTest(cur, point.x, point.y, &v); + if (FAILED(hr)) + { + IAccessible_Release(cur); + return hr; + } + + if (V_VT(&v) == VT_I4) + { + *acc = cur; + variant_init_i4(child_id, V_I4(&v)); + return S_OK; + } + else if (V_VT(&v) == VT_DISPATCH) + { + IAccessible_Release(cur); + + hr = IDispatch_QueryInterface(V_DISPATCH(&v), &IID_IAccessible, (void**)&cur); + VariantClear(&v); + if (FAILED(hr)) + return hr; + if (!cur) + return E_FAIL; + } + else + { + VariantClear(&v); + IAccessible_Release(cur); + FIXME("unhandled variant type: %d\n", V_VT(&v)); + return E_NOTIMPL; + } + } + + return S_OK; } HRESULT WINAPI AccessibleObjectFromWindow( HWND hwnd, DWORD dwObjectID, diff --git a/dll/win32/oleacc/oleacc.spec b/dll/win32/oleacc/oleacc.spec index 4cff0b8effc..9ad6e915965 100644 --- a/dll/win32/oleacc/oleacc.spec +++ b/dll/win32/oleacc/oleacc.spec @@ -1,5 +1,5 @@ @ stdcall AccessibleChildren(ptr long long ptr ptr) -@ stub AccessibleObjectFromEvent +@ stdcall AccessibleObjectFromEvent(ptr long long ptr ptr) @ stdcall AccessibleObjectFromPoint(int64 ptr ptr) @ stdcall AccessibleObjectFromWindow(ptr long ptr ptr) @ stdcall CreateStdAccessibleObject(ptr long ptr ptr) diff --git a/dll/win32/oleacc/window.c b/dll/win32/oleacc/window.c index 5957d49ef1f..1bd57743b2c 100644 --- a/dll/win32/oleacc/window.c +++ b/dll/win32/oleacc/window.c @@ -31,6 +31,7 @@ typedef struct { IEnumVARIANT IEnumVARIANT_iface; LONG ref; + HWND hwnd; } Window; static inline Window* impl_from_Window(IAccessible *iface) @@ -244,14 +245,43 @@ static HRESULT WINAPI Window_accNavigate(IAccessible *iface, return E_NOTIMPL; } -static HRESULT WINAPI Window_accHitTest(IAccessible *iface, - LONG xLeft, LONG yTop, VARIANT *pvarID) + +static HRESULT WINAPI Window_accHitTest(IAccessible *iface, LONG x, LONG y, VARIANT *v) { Window *This = impl_from_Window(iface); - FIXME("(%p)->(%d %d %p)\n", This, xLeft, yTop, pvarID); + IDispatch *disp; + POINT pt; + HRESULT hr; + RECT rect; + + TRACE("(%p)->(%ld %ld %p)\n", This, x, y, v); + + V_VT(v) = VT_EMPTY; + if (!GetClientRect(This->hwnd, &rect)) + return E_FAIL; + if (!ClientToScreen(This->hwnd, (POINT*)&rect) || + !ClientToScreen(This->hwnd, &((POINT*)&rect)[1])) + return E_FAIL; + pt.x = x; + pt.y = y; + if (PtInRect(&rect, pt)) + { + hr = AccessibleObjectFromWindow(This->hwnd, OBJID_CLIENT, &IID_IDispatch, (void**)&disp); + if (FAILED(hr)) + return hr; + if (!disp) + return E_FAIL; + + V_VT(v) = VT_DISPATCH; + V_DISPATCH(v) = disp; + return S_OK; + } + + FIXME("non-client area not handled yet\n"); return E_NOTIMPL; } + static HRESULT WINAPI Window_accDoDefaultAction(IAccessible *iface, VARIANT varID) { Window *This = impl_from_Window(iface); @@ -330,8 +360,9 @@ static ULONG WINAPI Window_OleWindow_Release(IOleWindow *iface) static HRESULT WINAPI Window_OleWindow_GetWindow(IOleWindow *iface, HWND *phwnd) { Window *This = impl_from_Window_OleWindow(iface); - FIXME("(%p)->(%p)\n", This, phwnd); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", This, phwnd); + *phwnd = This->hwnd; + return S_OK; } static HRESULT WINAPI Window_OleWindow_ContextSensitiveHelp(IOleWindow *iface, BOOL fEnterMode) @@ -426,6 +457,7 @@ HRESULT create_window_object(HWND hwnd, const IID *iid, void **obj) window->IAccessible_iface.lpVtbl = &WindowVtbl; window->IOleWindow_iface.lpVtbl = &WindowOleWindowVtbl; window->IEnumVARIANT_iface.lpVtbl = &WindowEnumVARIANTVtbl; + window->hwnd = hwnd; window->ref = 1; hres = IAccessible_QueryInterface(&window->IAccessible_iface, iid, obj); diff --git a/dll/win32/rpcrt4/ndr_marshall.c b/dll/win32/rpcrt4/ndr_marshall.c index 764b304a047..6ab9219810f 100644 --- a/dll/win32/rpcrt4/ndr_marshall.c +++ b/dll/win32/rpcrt4/ndr_marshall.c @@ -7269,6 +7269,7 @@ void WINAPI NdrCorrelationInitialize(PMIDL_STUB_MESSAGE pStubMsg, void *pMemory, pStubMsg->CorrDespIncrement = 2; /* size of the normal (non-range) /robust payload */ pStubMsg->fHasNewCorrDesc = TRUE; + pStubMsg->pCorrInfo = pMemory; } /*********************************************************************** diff --git a/dll/win32/rpcrt4/rpc_binding.c b/dll/win32/rpcrt4/rpc_binding.c index 80278b98570..4302e5b71b5 100644 --- a/dll/win32/rpcrt4/rpc_binding.c +++ b/dll/win32/rpcrt4/rpc_binding.c @@ -1681,7 +1681,7 @@ 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), + ERR("%p %s %u %u %p %u %p\n", Binding, debugstr_a((const char*)ServerPrincName), AuthnLevel, AuthnSvc, AuthIdentity, AuthzSvr, SecurityQos); if (SecurityQos) @@ -1986,6 +1986,19 @@ 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..206c3be60a0 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 */ diff --git a/dll/win32/rpcrt4/rpc_transport.c b/dll/win32/rpcrt4/rpc_transport.c index 9edc2ee718d..f4d58b233d2 100644 --- a/dll/win32/rpcrt4/rpc_transport.c +++ b/dll/win32/rpcrt4/rpc_transport.c @@ -790,6 +790,13 @@ static int rpcrt4_conn_np_wait_for_incoming_data(RpcConnection *conn) return rpcrt4_conn_np_read(conn, NULL, 0); } +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; +} + static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data, const char *networkaddr, const char *endpoint) @@ -3508,6 +3515,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 }, diff --git a/dll/win32/rpcrt4/rpcrt4.spec b/dll/win32/rpcrt4/rpcrt4.spec index 68d319fbc20..940a7f2f40d 100644 --- a/dll/win32/rpcrt4/rpcrt4.spec +++ b/dll/win32/rpcrt4/rpcrt4.spec @@ -521,3 +521,4 @@ 520 stub tree_into_ndr 521 stub tree_peek_ndr 522 stub tree_size_ndr +@ stdcall RpcServerRegisterIf3(ptr ptr ptr long long long ptr ptr) \ No newline at end of file diff --git a/drivers/filesystems/npfs/fsctrl.c b/drivers/filesystems/npfs/fsctrl.c index fff67ecd87a..be764f2f042 100644 --- a/drivers/filesystems/npfs/fsctrl.c +++ b/drivers/filesystems/npfs/fsctrl.c @@ -842,6 +842,12 @@ NpCommonFileSystemControl(IN PDEVICE_OBJECT DeviceObject, Status = NpSetClientProcess(DeviceObject, Irp); break; + case FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE: + + NpAcquireExclusiveVcb(); + Status = NpGetConnectionAttribute(DeviceObject, Irp); + break; + default: return STATUS_NOT_SUPPORTED; } @@ -875,4 +881,52 @@ NpFsdFileSystemControl(IN PDEVICE_OBJECT DeviceObject, return Status; } + +NTSTATUS +NTAPI +NpGetConnectionAttribute(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStackLocation; + NODE_TYPE_CODE NodeTypeCode; + PNP_CCB Ccb; + ULONG Length; + ULONG* pid; + PAGED_CODE(); + + /* Get the current stack location */ + IoStackLocation = IoGetCurrentIrpStackLocation(Irp); + + /* Decode the file object and check the node type */ + NodeTypeCode = NpDecodeFileObject(IoStackLocation->FileObject, 0, &Ccb, 0); + if (NodeTypeCode != NPFS_NTC_CCB) + { + return STATUS_PIPE_DISCONNECTED; + } + + /* Get the length of the query buffer */ + Length = IoStackLocation->Parameters.QueryFile.Length; + if (Length < sizeof(ULONG)) + { + return STATUS_INVALID_PARAMETER; + } + + /* Lock the Ccb */ + ExAcquireResourceExclusiveLite(&Ccb->NonPagedCcb->Lock, TRUE); + + Irp->IoStatus.Information = sizeof(ULONG); + pid = (ULONG*)(Irp->AssociatedIrp.SystemBuffer); + if (Ccb->ClientSession != NULL){ + PNP_CLIENT_PROCESS ClientSession = Ccb->ClientSession; + *pid = (ULONG)PsGetProcessId(ClientSession->Process); + } + else + *pid = (ULONG)PsGetProcessId(Ccb->Process); + + /* Unlock the Ccb */ + ExReleaseResourceLite(&Ccb->NonPagedCcb->Lock); + + return STATUS_SUCCESS; +} + /* EOF */ diff --git a/drivers/filesystems/npfs/npfs.h b/drivers/filesystems/npfs/npfs.h index 5d36d0cf3bf..b7d15b4419b 100644 --- a/drivers/filesystems/npfs/npfs.h +++ b/drivers/filesystems/npfs/npfs.h @@ -692,4 +692,9 @@ NTAPI NpFsdQueryVolumeInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); +NTSTATUS +NTAPI +NpGetConnectionAttribute(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + #endif /* _NPFS_PCH_ */ diff --git a/sdk/include/ndk/iotypes.h b/sdk/include/ndk/iotypes.h index 6f5ef0bbaea..e1755676bd4 100644 --- a/sdk/include/ndk/iotypes.h +++ b/sdk/include/ndk/iotypes.h @@ -1084,6 +1084,8 @@ typedef VOID CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_PIPE_QUERY_CLIENT_PROCESS \ CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE \ + CTL_CODE(FILE_DEVICE_NAMED_PIPE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_PIPE_INTERNAL_READ \ CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA) #define FSCTL_PIPE_INTERNAL_WRITE \ diff --git a/sdk/include/reactos/wine/winioctl.h b/sdk/include/reactos/wine/winioctl.h index 269f771b57e..76995791830 100644 --- a/sdk/include/reactos/wine/winioctl.h +++ b/sdk/include/reactos/wine/winioctl.h @@ -200,6 +200,7 @@ #define FSCTL_PIPE_IMPERSONATE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_PIPE_SET_CLIENT_PROCESS CTL_CODE(FILE_DEVICE_NAMED_PIPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_PIPE_QUERY_CLIENT_PROCESS CTL_CODE(FILE_DEVICE_NAMED_PIPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_PIPE_INTERNAL_READ CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2045, METHOD_BUFFERED, FILE_READ_DATA) #define FSCTL_PIPE_INTERNAL_WRITE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2046, METHOD_BUFFERED, FILE_WRITE_DATA) #define FSCTL_PIPE_INTERNAL_TRANSCEIVE CTL_CODE(FILE_DEVICE_NAMED_PIPE, 2047, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA) diff --git a/win32ss/user/ntuser/focus.c b/win32ss/user/ntuser/focus.c index ef566232dc3..ca4851a44ae 100644 --- a/win32ss/user/ntuser/focus.c +++ b/win32ss/user/ntuser/focus.c @@ -1127,7 +1127,7 @@ co_IntSetActiveWindow( // Set state flag to prevent recursions. Wnd->state |= WNDS_BEINGACTIVATED; - IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, Wnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); + //IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, Wnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); // Clear out activate EVENT messages. FindRemoveEventMsg(pti, POSTEVENT_SAW, POSTEVENT_DAW); diff --git a/win32ss/user/user32/windows/hook.c b/win32ss/user/user32/windows/hook.c index a9e9647eddf..9c9ca097f10 100644 --- a/win32ss/user/user32/windows/hook.c +++ b/win32ss/user/user32/windows/hook.c @@ -834,15 +834,16 @@ User32CallEventProcFromKernel(PVOID Arguments, ULONG ArgumentLength) } } - Proc(Common->hook, - Common->event, - Common->hwnd, - Common->idObject, - Common->idChild, - Common->dwEventThread, - Common->dwmsEventTime); - - if (Loaded) FreeLibrary(mod); + if (Loaded){ + Proc(Common->hook, + Common->event, + Common->hwnd, + Common->idObject, + Common->idChild, + Common->dwEventThread, + Common->dwmsEventTime); + FreeLibrary(mod); + } return ZwCallbackReturn(NULL, 0, STATUS_SUCCESS); }