4 * Copyright 2021 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define WIN32_NO_STATUS
34 #define __WINE_INIT_NPI_MODULEID
37 #include "wine/debug.h"
38 #include "wine/unixlib.h"
39 #include "unix_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(nsi
);
43 static const struct module
*modules
[] =
52 static const struct module_table
*get_module_table( const NPI_MODULEID
*id
, UINT table
)
54 const struct module_table
*entry
;
57 for (i
= 0; i
< ARRAY_SIZE(modules
); i
++)
58 if (NmrIsEqualNpiModuleId( modules
[i
]->module
, id
))
59 for (entry
= modules
[i
]->tables
; entry
->table
!= ~0u; entry
++)
60 if (entry
->table
== table
) return entry
;
65 NTSTATUS
nsi_enumerate_all_ex( struct nsi_enumerate_all_ex
*params
)
67 const struct module_table
*entry
= get_module_table( params
->module
, params
->table
);
68 UINT sizes
[4] = { params
->key_size
, params
->rw_size
, params
->dynamic_size
, params
->static_size
};
69 void *data
[4] = { params
->key_data
, params
->rw_data
, params
->dynamic_data
, params
->static_data
};
72 if (!entry
|| !entry
->enumerate_all
)
74 WARN( "table not found\n" );
75 return STATUS_INVALID_PARAMETER
;
78 for (i
= 0; i
< ARRAY_SIZE(sizes
); i
++)
80 if (!sizes
[i
]) data
[i
] = NULL
;
81 else if (sizes
[i
] != entry
->sizes
[i
]) return STATUS_INVALID_PARAMETER
;
84 return entry
->enumerate_all( data
[0], sizes
[0], data
[1], sizes
[1], data
[2], sizes
[2], data
[3], sizes
[3], ¶ms
->count
);
87 NTSTATUS
nsi_get_all_parameters_ex( struct nsi_get_all_parameters_ex
*params
)
89 const struct module_table
*entry
= get_module_table( params
->module
, params
->table
);
90 void *rw
= params
->rw_data
;
91 void *dyn
= params
->dynamic_data
;
92 void *stat
= params
->static_data
;
94 if (!entry
|| !entry
->get_all_parameters
)
96 WARN( "table not found\n" );
97 return STATUS_INVALID_PARAMETER
;
100 if (params
->key_size
!= entry
->sizes
[0]) return STATUS_INVALID_PARAMETER
;
101 if (!params
->rw_size
) rw
= NULL
;
102 else if (params
->rw_size
!= entry
->sizes
[1]) return STATUS_INVALID_PARAMETER
;
103 if (!params
->dynamic_size
) dyn
= NULL
;
104 else if (params
->dynamic_size
!= entry
->sizes
[2]) return STATUS_INVALID_PARAMETER
;
105 if (!params
->static_size
) stat
= NULL
;
106 else if (params
->static_size
!= entry
->sizes
[3]) return STATUS_INVALID_PARAMETER
;
108 return entry
->get_all_parameters( params
->key
, params
->key_size
, rw
, params
->rw_size
,
109 dyn
, params
->dynamic_size
, stat
, params
->static_size
);
112 NTSTATUS
nsi_get_parameter_ex( struct nsi_get_parameter_ex
*params
)
114 const struct module_table
*entry
= get_module_table( params
->module
, params
->table
);
116 if (!entry
|| !entry
->get_parameter
)
118 WARN( "table not found\n" );
119 return STATUS_INVALID_PARAMETER
;
122 if (params
->param_type
> 2) return STATUS_INVALID_PARAMETER
;
123 if (params
->key_size
!= entry
->sizes
[0]) return STATUS_INVALID_PARAMETER
;
124 if (params
->data_offset
+ params
->data_size
> entry
->sizes
[params
->param_type
+ 1])
125 return STATUS_INVALID_PARAMETER
;
126 return entry
->get_parameter( params
->key
, params
->key_size
, params
->param_type
,
127 params
->data
, params
->data_size
, params
->data_offset
);
130 static NTSTATUS
unix_nsi_enumerate_all_ex( void *args
)
132 struct nsi_enumerate_all_ex
*params
= (struct nsi_enumerate_all_ex
*)args
;
133 return nsi_enumerate_all_ex( params
);
136 static NTSTATUS
unix_nsi_get_all_parameters_ex( void *args
)
138 struct nsi_get_all_parameters_ex
*params
= (struct nsi_get_all_parameters_ex
*)args
;
139 return nsi_get_all_parameters_ex( params
);
142 static NTSTATUS
unix_nsi_get_parameter_ex( void *args
)
144 struct nsi_get_parameter_ex
*params
= (struct nsi_get_parameter_ex
*)args
;
145 return nsi_get_parameter_ex( params
);
148 const unixlib_entry_t __wine_unix_call_funcs
[] =
154 unix_nsi_enumerate_all_ex
,
155 unix_nsi_get_all_parameters_ex
,
156 unix_nsi_get_parameter_ex