Skip to content

Commit 28b3562

Browse files
committed
[DHCPCSVC] Change AdapterName parameter to UNICODE
DhcpAcquireParameters and DhcpReleaseParameters use a UNICODE AdapterName parameter.
1 parent 49e652b commit 28b3562

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

base/services/dhcpcsvc/dhcp/adapter.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,17 @@ PDHCP_ADAPTER AdapterFindIndex( unsigned int indx ) {
511511
return NULL;
512512
}
513513

514-
PDHCP_ADAPTER AdapterFindName( const CHAR *name ) {
514+
PDHCP_ADAPTER AdapterFindName( const WCHAR *name ) {
515515
PDHCP_ADAPTER Adapter;
516516
PLIST_ENTRY ListEntry;
517+
WCHAR UnicodeName[45];
517518

518519
for( ListEntry = AdapterList.Flink;
519520
ListEntry != &AdapterList;
520521
ListEntry = ListEntry->Flink ) {
521522
Adapter = CONTAINING_RECORD( ListEntry, DHCP_ADAPTER, ListEntry );
522-
if( !stricmp((const CHAR*)Adapter->IfMib.bDescr, name ) ) return Adapter;
523+
mbstowcs(UnicodeName, (const CHAR *)Adapter->IfMib.bDescr, strlen((const CHAR *)Adapter->IfMib.bDescr) + 1);
524+
if( !wcsicmp(UnicodeName, name ) ) return Adapter;
523525
}
524526

525527
return NULL;

base/services/dhcpcsvc/dhcpcsvc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ DhcpCApiCleanup(VOID)
7979
DWORD
8080
APIENTRY
8181
DhcpAcquireParameters(
82-
_In_ PSTR AdapterName)
82+
_In_ PWSTR AdapterName)
8383
{
8484
COMM_DHCP_REQ Req;
8585
COMM_DHCP_REPLY Reply;
8686
DWORD BytesRead;
8787
BOOL Result;
8888

89-
DPRINT1("DhcpAcquireParameters(%s)\n", AdapterName);
89+
DPRINT1("DhcpAcquireParameters(%S)\n", AdapterName);
9090

9191
ASSERT(PipeHandle != INVALID_HANDLE_VALUE);
9292

9393
Req.Type = DhcpReqAcquireParams;
94-
strcpy(Req.Body.AcquireParams.AdapterName, AdapterName);
94+
wcscpy(Req.Body.AcquireParams.AdapterName, AdapterName);
9595

9696
Result = TransactNamedPipe(PipeHandle,
9797
&Req, sizeof(Req),
@@ -110,19 +110,19 @@ DhcpAcquireParameters(
110110
DWORD
111111
APIENTRY
112112
DhcpReleaseParameters(
113-
_In_ PSTR AdapterName)
113+
_In_ PWSTR AdapterName)
114114
{
115115
COMM_DHCP_REQ Req;
116116
COMM_DHCP_REPLY Reply;
117117
DWORD BytesRead;
118118
BOOL Result;
119119

120-
DPRINT1("DhcpReleaseParameters(%s)\n", AdapterName);
120+
DPRINT1("DhcpReleaseParameters(%S)\n", AdapterName);
121121

122122
ASSERT(PipeHandle != INVALID_HANDLE_VALUE);
123123

124124
Req.Type = DhcpReqReleaseParams;
125-
strcpy(Req.Body.AcquireParams.AdapterName, AdapterName);
125+
wcscpy(Req.Body.AcquireParams.AdapterName, AdapterName);
126126

127127
Result = TransactNamedPipe(PipeHandle,
128128
&Req, sizeof(Req),

base/services/dhcpcsvc/dhcpcsvc.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# PURPOSE: dhcpcsvc exports
66
# COPYRIGHT: Copyright 2006 Ge van Geldorp <[email protected]>
77
#
8-
@ stdcall DhcpAcquireParameters(str)
8+
@ stdcall DhcpAcquireParameters(wstr)
99
@ stub DhcpAcquireParametersByBroadcast
1010
@ stdcall DhcpCApiCleanup()
1111
@ stdcall DhcpCApiInitialize(ptr)
@@ -27,7 +27,7 @@
2727
@ stub DhcpRegisterParamChange
2828
@ stdcall DhcpReleaseIpAddressLease(long)
2929
@ stub DhcpReleaseIpAddressLeaseEx
30-
@ stdcall DhcpReleaseParameters(str)
30+
@ stdcall DhcpReleaseParameters(wstr)
3131
@ stub DhcpRemoveDNSRegistrations
3232
@ stdcall DhcpRenewIpAddressLease(long)
3333
@ stub DhcpRenewIpAddressLeaseEx

base/services/dhcpcsvc/include/rosdhcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void AdapterStop(VOID);
9090
extern PDHCP_ADAPTER AdapterGetFirst(VOID);
9191
extern PDHCP_ADAPTER AdapterGetNext(PDHCP_ADAPTER);
9292
extern PDHCP_ADAPTER AdapterFindIndex( unsigned int AdapterIndex );
93-
extern PDHCP_ADAPTER AdapterFindName(const CHAR *name);
93+
extern PDHCP_ADAPTER AdapterFindName(const WCHAR *name);
9494
extern PDHCP_ADAPTER AdapterFindInfo( struct interface_info *info );
9595
extern PDHCP_ADAPTER AdapterFindByHardwareAddress( u_int8_t haddr[16], u_int8_t hlen );
9696
extern HANDLE PipeInit(HANDLE hStopEvent);

base/services/dhcpcsvc/include/rosdhcp_pipe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ typedef struct _COMM_DHCP_REQ {
1818
{
1919
struct
2020
{
21-
CHAR AdapterName[64];
21+
WCHAR AdapterName[45];
2222
} AcquireParams;
2323
struct {
2424
BOOL Inserted;

sdk/include/psdk/dhcpcapi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ extern "C" {
88
DWORD
99
APIENTRY
1010
DhcpAcquireParameters(
11-
_In_ PSTR AdapterName);
11+
_In_ PWSTR AdapterName);
1212

1313
DWORD
1414
APIENTRY
1515
DhcpReleaseParameters(
16-
_In_ PSTR AdapterName);
16+
_In_ PWSTR AdapterName);
1717

1818
DWORD APIENTRY DhcpLeaseIpAddress( DWORD AdapterIndex );
1919
DWORD APIENTRY DhcpQueryHWInfo( DWORD AdapterIndex,

0 commit comments

Comments
 (0)