From: Pierre Schweitzer Subject: [PATCH 2/2] mpr: Implement provider selection given remote name. Message-Id: <578E8FBE.8020706@reactos.org> Date: Tue, 19 Jul 2016 22:38:22 +0200 Ignore [PATCH 1/2] mpr: Implement provider selection given remote name, it was a mistake. -- Pierre Schweitzer System & Network Administrator Senior Kernel Developer ReactOS Deutschland e.V. From ed8c38e1bbbad9ab3b60e16aed129dcc49cb6ff4 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Tue, 19 Jul 2016 22:32:11 +0200 Subject: [PATCH 2/2] mpr: Implement provider selection given remote name. Signed-off-by: Pierre Schweitzer --- dlls/mpr/wnet.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/dlls/mpr/wnet.c b/dlls/mpr/wnet.c index b7b0222..475bd28 100644 --- a/dlls/mpr/wnet.c +++ b/dlls/mpr/wnet.c @@ -1617,11 +1617,52 @@ static void use_connection_set_accessnameW(struct use_connection_context *ctxt) strcpyW(accessname, ctxt->resource->lpRemoteName); } +static WCHAR * select_provider(struct use_connection_context *ctxt) +{ + DWORD ret, prov_size = 0x1000, len; + LPNETRESOURCEW provider; + PWSTR system; + + provider = HeapAlloc(GetProcessHeap(), 0, prov_size); + if (!provider) + { + return NULL; + } + + ret = WNetGetResourceInformationW(ctxt->resource, provider, &prov_size, &system); + if (ret == ERROR_MORE_DATA) + { + HeapFree(GetProcessHeap(), 0, provider); + provider = HeapAlloc(GetProcessHeap(), 0, prov_size); + if (!provider) + { + return NULL; + } + + ret = WNetGetResourceInformationW(ctxt->resource, provider, &prov_size, &system); + } + + if (ret != NO_ERROR) + { + HeapFree(GetProcessHeap(), 0, provider); + return NULL; + } + + len = WideCharToMultiByte(CP_ACP, 0, provider->lpProvider, -1, NULL, 0, NULL, NULL); + ctxt->resource->lpProvider = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (ctxt->resource->lpProvider) + memcpy(ctxt->resource->lpProvider, provider->lpProvider, len * sizeof(WCHAR)); + + HeapFree(GetProcessHeap(), 0, provider); + + return ctxt->resource->lpProvider; +} + static DWORD wnet_use_connection( struct use_connection_context *ctxt ) { WNetProvider *provider; DWORD index, ret, caps; - BOOLEAN redirect = FALSE; + BOOLEAN redirect = FALSE, prov = FALSE; WCHAR letter[3] = {'z', ':', 0}; if (!providerTable || providerTable->numProviders == 0) @@ -1647,17 +1688,22 @@ static DWORD wnet_use_connection( struct use_connection_context *ctxt ) ctxt->resource->lpLocalName = letter; } - if (!ctxt->resource->lpProvider) + if (ctxt->flags & CONNECT_INTERACTIVE) { - FIXME("Networking provider selection is not implemented.\n"); - ret = WN_NO_NETWORK; + ret = ERROR_BAD_NET_NAME; goto done; } - if (ctxt->flags & CONNECT_INTERACTIVE) + if (!ctxt->resource->lpProvider) { - ret = ERROR_BAD_NET_NAME; - goto done; + ctxt->resource->lpProvider = select_provider(ctxt); + if (!ctxt->resource->lpProvider) + { + ret = ERROR_NO_NET_OR_BAD_PATH; + goto done; + } + + prov = TRUE; } index = _findProviderIndexW(ctxt->resource->lpProvider); @@ -1696,6 +1742,12 @@ static DWORD wnet_use_connection( struct use_connection_context *ctxt ) ctxt->set_accessname(ctxt); done: + if (prov) + { + HeapFree(GetProcessHeap(), 0, ctxt->resource->lpProvider); + ctxt->resource->lpProvider = NULL; + } + if (redirect) ctxt->resource->lpLocalName = NULL; -- 2.7.4 0 *H 010  `He0 *H  040 0  *H 0}1 0 UIL10U  StartCom Ltd.1+0)U "Secure Digital Certificate Signing1)0'U StartCom Certification Authority0 071024210255Z 171024210255Z01 0 UIL10U  StartCom Ltd.1+0)U "Secure Digital Certificate Signing1806U/StartCom Class 2 Primary Intermediate Client CA0"0  *H 0 (E,3* U]"gFSݤ>}m w鞆FA7~ |-ql"/Q?Vp`G&viĜ73 {B'87ds Nfz1%TII|2o/mD \t :08VGqǴ3Rp}JTzF;&X}rD Q 600U00U0UUo1ʹk1㬻0U#0N @[i04hCA0f+Z0X0'+0http://ocsp.startssl.com/ca0-+0!http://www.startssl.com/sfsca.crt0[UT0R0'%#!http://www.startssl.com/sfsca.crl0'%#!http://crl.startssl.com/sfsca.crl0U y0w0u +70f0.+"http://www.startssl.com/policy.pdf04+(http://www.startssl.com/intermediate.pdf0  *H :' ӴiiL\};JBG Ƚ1Fa gR~9P1 Rvg}ȜsWr<];sY/Msߟq'ɽNpʧ`&pPz/ў-Eׁ1KeET5ꥊ@v錈{8@t e=ރt92Ow[%[kd+YO!_uyGYqE\pCbM~ @3xnM+RH?o'V=INjWbᑶYOuZk*9Jz)w󫦒jNnZqwZV=t+΄BMkd"ܧfVSąmzLu8¾ņVcoiQ^7|#Bl@ /D;+@8 ~brA+}TLVŜ 2J(Hn}Rt]fiZ U ]+nŚܓqEF$^fsȕP)*6\q)90a0IY 0  *H  01 0 UIL10U  StartCom Ltd.1+0)U "Secure Digital Certificate Signing1806U/StartCom Class 2 Primary Intermediate Client CA0 141124162727Z 161124202226Z0~1 0 UFR10UHaute-Normandie10U Montivilliers10UPierre Schweitzer1!0 *H  pierre@reactos.org0"0  *H 0 Ik9 Pd `V<%v͗9lyu.=\H~6I~䄅#dZ>4oME\'܎D_eQMUkb/}c T;*z?f aڀ8K,`]:E5˩ "` `=F7wnpZHāڒN[(Tk8b:I7+K00 U00 U0U%0++0UfL,U%Zm0U#0Uo1ʹk1㬻0U0pierre@reactos.org0LU C0?0; +70*0.+"http://www.startssl.com/policy.pdf0+00' StartCom Certification Authority0This certificate was issued according to the Class 2 Validation requirements of the StartCom CA policy, reliance only for the intended purpose in compliance of the relying party obligations.06U/0-0+)'%http://crl.startssl.com/crtu2-crl.crl0+009+0-http://ocsp.startssl.com/sub/class2/client/ca0B+06http://aia.startssl.com/certs/sub.class2.client.ca.crt0#U0http://www.startssl.com/0  *H  &ܚɮI]YugIcG3M\@8JVu=qؖ\ ё, a<]r{JKC'뢀pኡ֗ז'!Ewa2*jH=g_~#WRFjsEgo`\0R_ 2䑌LM1Zz־~r&S`ب+xY(5` Pš[810001 0 UIL10U  StartCom Ltd.1+0)U "Secure Digital Certificate Signing1806U/StartCom Class 2 Primary Intermediate Client CAY 0  `He0 *H  1  *H 0 *H  1 160719203822Z0/ *H  1" #䆭FcWiU–> ϝT0l *H  1_0]0  `He*0  `He0 *H 0*H 0 *H @0+0 *H (0  *H }ӂSj!PGmA>W}3H"Ij:E"wG'fY5]RVA!p8q&F^އyݔs%SQN.E+|pgT?vPIqU#bst8,CJ&pn ˗չ8b^ 4\ ϒdt. j 7kfh6^CXF 3쏏ئ&?jˏ=#