Robert Shearman : ole32: Implement CoQueryClientBlanket, CoImpersonateClient and

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 9 14:39:56 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 51e22f42bb95f8827b24e9860b8e5e57554ccaec
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=51e22f42bb95f8827b24e9860b8e5e57554ccaec

Author: Robert Shearman <rob at codeweavers.com>
Date:   Fri Jun  9 17:24:39 2006 +0100

ole32: Implement CoQueryClientBlanket, CoImpersonateClient and
CoRevertToSelf on top of CoGetCallContext, which is a stub.

---

 dlls/ole32/compobj.c  |  143 +++++++++++++++++++++++++++++++++++++++++++++++++
 dlls/ole32/ole32.spec |    8 +--
 2 files changed, 147 insertions(+), 4 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index d241bfb..796c4ab 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -2641,6 +2641,149 @@ HRESULT WINAPI CoCopyProxy(IUnknown *pPr
 }
 
 
+/***********************************************************************
+ *           CoGetCallContext [OLE32.@]
+ *
+ * Gets the context of the currently executing server call in the current
+ * thread.
+ *
+ * PARAMS
+ *  riid [I] Context interface to return.
+ *  ppv  [O] Pointer to memory that will receive the context on return.
+ *
+ * RETURNS
+ *  Success: S_OK.
+ *  Failure: HRESULT code.
+ */
+HRESULT WINAPI CoGetCallContext(REFIID riid, void **ppv)
+{
+    FIXME("(%s, %p): stub\n", debugstr_guid(riid), ppv);
+
+    *ppv = NULL;
+    return E_NOINTERFACE;
+}
+
+/***********************************************************************
+ *           CoQueryClientBlanket [OLE32.@]
+ *
+ * Retrieves the authentication information about the client of the currently
+ * executing server call in the current thread.
+ *
+ * PARAMS
+ *  pAuthnSvc     [O] Optional. The type of authentication service.
+ *  pAuthzSvc     [O] Optional. The type of authorization service.
+ *  pServerPrincName [O] Optional. The server prinicple name.
+ *  pAuthnLevel   [O] Optional. The authentication level.
+ *  pImpLevel     [O] Optional. The impersonation level.
+ *  pPrivs        [O] Optional. Information about the privileges of the client.
+ *  pCapabilities [IO] Optional. Flags affecting the security behaviour.
+ *
+ * RETURNS
+ *  Success: S_OK.
+ *  Failure: HRESULT code.
+ *
+ * SEE ALSO
+ *  CoImpersonateClient, CoRevertToSelf, CoGetCallContext.
+ */
+HRESULT WINAPI CoQueryClientBlanket(
+    DWORD *pAuthnSvc,
+    DWORD *pAuthzSvc,
+    OLECHAR **pServerPrincName,
+    DWORD *pAuthnLevel,
+    DWORD *pImpLevel,
+    RPC_AUTHZ_HANDLE *pPrivs,
+    DWORD *pCapabilities)
+{
+    IServerSecurity *pSrvSec;
+    HRESULT hr;
+
+    TRACE("(%p, %p, %p, %p, %p, %p, %p)\n",
+        pAuthnSvc, pAuthzSvc, pServerPrincName, pAuthnLevel, pImpLevel,
+        pPrivs, pCapabilities);
+
+    hr = CoGetCallContext(&IID_IServerSecurity, (void **)&pSrvSec);
+    if (SUCCEEDED(hr))
+    {
+        hr = IServerSecurity_QueryBlanket(
+            pSrvSec, pAuthnSvc, pAuthzSvc, pServerPrincName, pAuthnLevel,
+            pImpLevel, pPrivs, pCapabilities);
+        IServerSecurity_Release(pSrvSec);
+    }
+
+    return hr;
+}
+
+/***********************************************************************
+ *           CoImpersonateClient [OLE32.@]
+ *
+ * Impersonates the client of the currently executing server call in the
+ * current thread.
+ *
+ * PARAMS
+ *  None.
+ *
+ * RETURNS
+ *  Success: S_OK.
+ *  Failure: HRESULT code.
+ *
+ * NOTES
+ *  If this function fails then the current thread will not be impersonating
+ *  the client and all actions will take place on behalf of the server.
+ *  Therefore, it is important to check the return value from this function.
+ *
+ * SEE ALSO
+ *  CoRevertToSelf, CoQueryClientBlanket, CoGetCallContext.
+ */
+HRESULT WINAPI CoImpersonateClient(void)
+{
+    IServerSecurity *pSrvSec;
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = CoGetCallContext(&IID_IServerSecurity, (void **)&pSrvSec);
+    if (SUCCEEDED(hr))
+    {
+        hr = IServerSecurity_ImpersonateClient(pSrvSec);
+        IServerSecurity_Release(pSrvSec);
+    }
+
+    return hr;
+}
+
+/***********************************************************************
+ *           CoRevertToSelf [OLE32.@]
+ *
+ * Ends the impersonation of the client of the currently executing server
+ * call in the current thread.
+ *
+ * PARAMS
+ *  None.
+ *
+ * RETURNS
+ *  Success: S_OK.
+ *  Failure: HRESULT code.
+ *
+ * SEE ALSO
+ *  CoImpersonateClient, CoQueryClientBlanket, CoGetCallContext.
+ */
+HRESULT WINAPI CoRevertToSelf(void)
+{
+    IServerSecurity *pSrvSec;
+    HRESULT hr;
+
+    TRACE("\n");
+
+    hr = CoGetCallContext(&IID_IServerSecurity, (void **)&pSrvSec);
+    if (SUCCEEDED(hr))
+    {
+        hr = IServerSecurity_RevertToSelf(pSrvSec);
+        IServerSecurity_Release(pSrvSec);
+    }
+
+    return hr;
+}
+
 static BOOL COM_PeekMessage(struct apartment *apt, MSG *msg)
 {
     /* first try to retrieve messages for incoming COM calls to the apartment window */
diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec
index 26f7c6f..74f2bfc 100644
--- a/dlls/ole32/ole32.spec
+++ b/dlls/ole32/ole32.spec
@@ -20,7 +20,7 @@
 @ stdcall CoFreeAllLibraries()
 @ stdcall CoFreeLibrary(long)
 @ stdcall CoFreeUnusedLibraries()
-@ stub CoGetCallContext           #@ stdcall (ptr ptr) return 0,ERR_NOTIMPLEMENTED
+@ stdcall CoGetCallContext(ptr ptr)
 @ stub CoGetCallerTID
 @ stdcall CoGetClassObject(ptr long ptr ptr ptr)
 @ stub CoGetCurrentLogicalThreadId
@@ -36,7 +36,7 @@
 @ stdcall CoGetState(ptr)
 @ stub CoGetTIDFromIPID
 @ stdcall CoGetTreatAsClass(ptr ptr)
-@ stub CoImpersonateClient
+@ stdcall CoImpersonateClient()
 @ stdcall CoInitialize(ptr)
 @ stdcall CoInitializeEx(ptr long)
 @ stdcall CoInitializeSecurity(ptr long ptr ptr long long ptr long ptr)
@@ -49,7 +49,7 @@
 @ stdcall CoMarshalInterThreadInterfaceInStream(ptr ptr ptr)
 @ stdcall CoMarshalInterface(ptr ptr ptr long ptr long)
 @ stub CoQueryAuthenticationServices
-@ stub CoQueryClientBlanket
+@ stdcall CoQueryClientBlanket(ptr ptr ptr ptr ptr ptr ptr)
 @ stdcall CoQueryProxyBlanket(ptr ptr ptr ptr ptr ptr ptr ptr)
 @ stub CoQueryReleaseObject
 @ stub CoRegisterChannelHook
@@ -61,7 +61,7 @@
 @ stdcall CoReleaseMarshalData(ptr)
 @ stdcall CoReleaseServerProcess()
 @ stdcall CoResumeClassObjects()
-@ stub CoRevertToSelf             #@ stdcall () return 0,ERR_NOTIMPLEMENTED
+@ stdcall CoRevertToSelf()
 @ stdcall CoRevokeClassObject(long)
 @ stdcall CoRevokeMallocSpy()
 @ stdcall CoSetProxyBlanket(ptr long long wstr long long ptr long)




More information about the wine-cvs mailing list