ntoskrnl/tests: Test the contents of the user IO_STATUS_BLOCK.
[wine/zf.git] / dlls / dhcpcsvc / dhcpcsvc.c
blobd5df635012bcddb66b6bbda0022fa0edb4580626
1 /*
2 * Copyright 2011 Stefan Leichter
3 * Copyright 2019 Hans Leidekker for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "dhcpcsdk.h"
24 #include "winioctl.h"
25 #define WINE_MOUNTMGR_EXTENSIONS
26 #include "ddk/mountmgr.h"
28 #include "wine/debug.h"
29 #include "wine/heap.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(dhcpcsvc);
33 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
35 TRACE("%p, %u, %p\n", hinst, reason, reserved);
37 switch (reason)
39 case DLL_WINE_PREATTACH:
40 return FALSE; /* prefer native version */
41 case DLL_PROCESS_ATTACH:
42 DisableThreadLibraryCalls( hinst );
43 break;
45 return TRUE;
48 void WINAPI DhcpCApiCleanup(void)
50 FIXME(": stub\n");
53 DWORD WINAPI DhcpCApiInitialize(LPDWORD version)
55 *version = 2; /* 98, XP, and 8 */
56 FIXME(": stub\n");
57 return ERROR_SUCCESS;
60 DWORD WINAPI DhcpRequestParams( DWORD flags, void *reserved, WCHAR *adapter, DHCPCAPI_CLASSID *class_id,
61 DHCPCAPI_PARAMS_ARRAY send_params, DHCPCAPI_PARAMS_ARRAY recv_params, BYTE *buf,
62 DWORD *buflen, WCHAR *request_id )
64 struct mountmgr_dhcp_request_params *query;
65 DWORD i, size, err = ERROR_OUTOFMEMORY;
66 BYTE *src, *dst;
67 HANDLE mgr;
69 TRACE( "(%08x, %p, %s, %p, %u, %u, %p, %p, %s)\n", flags, reserved, debugstr_w(adapter), class_id,
70 send_params.nParams, recv_params.nParams, buf, buflen, debugstr_w(request_id) );
72 if (!adapter || lstrlenW(adapter) > IF_MAX_STRING_SIZE || !buflen) return ERROR_INVALID_PARAMETER;
73 if (flags != DHCPCAPI_REQUEST_SYNCHRONOUS) FIXME( "unsupported flags %08x\n", flags );
75 for (i = 0; i < send_params.nParams; i++)
76 FIXME( "send option %u not supported\n", send_params.Params->OptionId );
78 mgr = CreateFileW( MOUNTMGR_DOS_DEVICE_NAME, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
79 OPEN_EXISTING, 0, 0 );
80 if (mgr == INVALID_HANDLE_VALUE) return GetLastError();
82 size = FIELD_OFFSET(struct mountmgr_dhcp_request_params, params[recv_params.nParams]) + *buflen;
83 if (!(query = heap_alloc_zero( size ))) goto done;
85 for (i = 0; i < recv_params.nParams; i++) query->params[i].id = recv_params.Params[i].OptionId;
86 query->count = recv_params.nParams;
87 lstrcpyW( query->adapter, adapter );
89 if (!DeviceIoControl( mgr, IOCTL_MOUNTMGR_QUERY_DHCP_REQUEST_PARAMS, query, size, query, size, NULL, NULL ))
91 err = GetLastError();
92 if (err == ERROR_MORE_DATA) *buflen = query->size - (size - *buflen);
93 goto done;
96 dst = buf;
97 for (i = 0; i < query->count; i++)
99 if (buf)
101 recv_params.Params[i].OptionId = query->params[i].id;
102 recv_params.Params[i].IsVendor = FALSE; /* FIXME */
103 if (query->params[i].size)
105 src = (BYTE *)query + query->params[i].offset;
106 memcpy( dst, src, query->params[i].size );
108 recv_params.Params[i].Data = dst;
109 recv_params.Params[i].nBytesData = query->params[i].size;
111 else
113 recv_params.Params[i].Data = NULL;
114 recv_params.Params[i].nBytesData = 0;
117 dst += query->params[i].size;
120 *buflen = dst - buf;
121 err = ERROR_SUCCESS;
123 done:
124 heap_free( query );
125 CloseHandle( mgr );
126 return err;