From f5238be33012c31af8a7c40023ec65c82e7a1456 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 1 Jul 2021 09:27:08 +0100 Subject: [PATCH] nsiproxy: Implement NDIS ifinfo get_parameter for a few parameters. Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/nsi/tests/nsi.c | 13 ++++++-- dlls/nsiproxy.sys/ndis.c | 70 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/dlls/nsi/tests/nsi.c b/dlls/nsi/tests/nsi.c index 207d3941c0d..d7f6ac9c739 100644 --- a/dlls/nsi/tests/nsi.c +++ b/dlls/nsi/tests/nsi.c @@ -113,9 +113,7 @@ static void test_nsi_api( void ) err = NsiGetParameter( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, luid_tbl + i, sizeof(*luid_tbl), NSI_PARAM_TYPE_RW, &get_rw.alias, sizeof(get_rw.alias), FIELD_OFFSET(struct nsi_ndis_ifinfo_rw, alias) ); -todo_wine ok( !err, "got %d\n", err ); - if (err) continue; ok( get_rw.alias.Length == rw->alias.Length, "mismatch\n" ); ok( !memcmp( get_rw.alias.String, rw->alias.String, rw->alias.Length ), "mismatch\n" ); @@ -362,12 +360,23 @@ static void test_ndis_ifinfo( void ) ok( !err, "got %d\n", err ); ok( IsEqualGUID( &stat_tbl[0].if_guid, &stat_get.if_guid ), "mismatch\n" ); + err = NsiGetParameter( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, luid_tbl, sizeof(*luid_tbl), + NSI_PARAM_TYPE_STATIC, &stat_get.if_guid, sizeof(stat_get.if_guid), + FIELD_OFFSET(struct nsi_ndis_ifinfo_static, if_guid) ); + ok( !err, "got %d\n", err ); + ok( IsEqualGUID( &stat_tbl[0].if_guid, &stat_get.if_guid ), "mismatch\n" ); + luid_get.Value = ~0u; err = NsiGetAllParameters( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, &luid_get, sizeof(luid_get), &rw_get, rw_size, &dyn_get, sizeof(dyn_get), &stat_get, sizeof(stat_get) ); ok( err == ERROR_FILE_NOT_FOUND, "got %d\n", err ); + err = NsiGetParameter( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, &luid_get, sizeof(luid_get), + NSI_PARAM_TYPE_STATIC, &stat_get.if_guid, sizeof(stat_get.if_guid), + FIELD_OFFSET(struct nsi_ndis_ifinfo_static, if_guid) ); + ok( err == ERROR_FILE_NOT_FOUND, "got %d\n", err ); + FreeMibTable( table ); NsiFreeTable( luid_tbl_2, NULL, dyn_tbl_2, NULL ); NsiFreeTable( luid_tbl, rw_tbl, dyn_tbl, stat_tbl ); diff --git a/dlls/nsiproxy.sys/ndis.c b/dlls/nsiproxy.sys/ndis.c index 8e5eccbbf23..647fd650cd3 100644 --- a/dlls/nsiproxy.sys/ndis.c +++ b/dlls/nsiproxy.sys/ndis.c @@ -515,6 +515,75 @@ static NTSTATUS ifinfo_get_all_parameters( const void *key, DWORD key_size, void return status; } +static NTSTATUS ifinfo_get_rw_parameter( struct if_entry *entry, void *data, DWORD data_size, DWORD data_offset ) +{ + switch (data_offset) + { + case FIELD_OFFSET( struct nsi_ndis_ifinfo_rw, alias ): + { + IF_COUNTED_STRING *str = (IF_COUNTED_STRING *)data; + if (data_size != sizeof(*str)) return STATUS_INVALID_PARAMETER; + if_counted_string_init( str, entry->if_name ); + return STATUS_SUCCESS; + } + default: + FIXME( "Offset %#x not handled\n", data_offset ); + } + + return STATUS_INVALID_PARAMETER; +} + +static NTSTATUS ifinfo_get_static_parameter( struct if_entry *entry, void *data, DWORD data_size, DWORD data_offset ) +{ + switch (data_offset) + { + case FIELD_OFFSET( struct nsi_ndis_ifinfo_static, if_index ): + if (data_size != sizeof(DWORD)) return STATUS_INVALID_PARAMETER; + *(DWORD *)data = entry->if_index; + return STATUS_SUCCESS; + + case FIELD_OFFSET( struct nsi_ndis_ifinfo_static, if_guid ): + if (data_size != sizeof(GUID)) return STATUS_INVALID_PARAMETER; + *(GUID *)data = entry->if_guid; + return STATUS_SUCCESS; + + default: + FIXME( "Offset %#x not handled\n", data_offset ); + } + return STATUS_INVALID_PARAMETER; +} + +static NTSTATUS ifinfo_get_parameter( const void *key, DWORD key_size, DWORD param_type, + void *data, DWORD data_size, DWORD data_offset ) +{ + struct if_entry *entry; + NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND; + + TRACE( "%p %d %d %p %d %d\n", key, key_size, param_type, data, data_size, data_offset ); + + EnterCriticalSection( &if_list_cs ); + + update_if_table(); + + entry = find_entry_from_luid( (const NET_LUID *)key ); + if (entry) + { + switch (param_type) + { + case NSI_PARAM_TYPE_RW: + status = ifinfo_get_rw_parameter( entry, data, data_size, data_offset ); + break; + case NSI_PARAM_TYPE_STATIC: + status = ifinfo_get_static_parameter( entry, data, data_size, data_offset ); + break; + } + } + + LeaveCriticalSection( &if_list_cs ); + + return status; +} + static const struct module_table tables[] = { { @@ -525,6 +594,7 @@ static const struct module_table tables[] = }, ifinfo_enumerate_all, ifinfo_get_all_parameters, + ifinfo_get_parameter }, { ~0u } };