+
+ /* Enter prolog */
+ if ((ErrorCode = WsApiProlog(&Process, &Thread)) != ERROR_SUCCESS)
+ {
+ /* FIXME: if WSANOTINITIALISED, we should init
+ * and perform the search!
+ */
+
+ /* Leave now */
+ *lpErrno = ErrorCode;
+ return SOCKET_ERROR;
+ }
+
+ /* Get the catalog */
+ Catalog = WsProcGetNsCatalog(Process);
+
+ /* Setup the context */
+ Context.ProviderId = *lpProviderId;
+ Context.ProviderDllPath = lpszProviderDllPath;
+ Context.ProviderDllPathLen = *lpProviderDllPathLen;
+ Context.FoundPathLen = 0;
+ Context.Found = 0;
+ Context.ErrorCode = ERROR_SUCCESS;
+
+ ErrorCode = ERROR_SUCCESS;
+
+ /* Enumerate the catalog */
+ WsNcEnumerateCatalogItems(Catalog, ProviderEnumerationProc, &Context);
+
+ /* Check the error code */
+ if (Context.ErrorCode == ERROR_SUCCESS)
+ {
+ /* Check if provider was found */
+ if (Context.Found)
+ {
+ PathLen = Context.FoundPathLen;
+
+ /* Check whether buffer is too small
+ * If it isn't, return length without null char
+ * (see ProviderEnumerationProc)
+ */
+ if (Context.FoundPathLen <= *lpProviderDllPathLen)
+ {
+ PathLen = Context.FoundPathLen - 1;
+ }
+ else
+ {
+ ErrorCode = WSAEFAULT;
+ }
+
+ /* Set returned/required length */
+ *lpProviderDllPathLen = PathLen;
+ }
+ else
+ {
+ ErrorCode = WSAEINVAL;
+ }
+ }
+ else
+ {
+ ErrorCode = Context.ErrorCode;
+ }
+
+ /* Do we have to return failure? */
+ if (ErrorCode != ERROR_SUCCESS)
+ {
+ *lpErrno = ErrorCode;
+ return SOCKET_ERROR;
+ }
+
+ return 0;