source: trunk/kitgen/8.x/libusb-win32/registry.h

Last change on this file was 175, checked in by demin, 12 years ago

initial commit

File size: 6.9 KB
RevLine 
[175]1/* libusb-win32, Generic Windows USB Library
2* Copyright (c) 2002-2005 Stephan Meyer <ste_meyer@web.de>
3* Copyright (c) 2010 Travis Robinson <libusbdotnet@gmail.com>
4*
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 of the License, or (at your option) any later version.
9*
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.
14*
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20
21
22#ifndef __USB_REGISTRY_H__
23#define __USB_REGISTRY_H__
24
25#include <windows.h>
26#include <setupapi.h>
27
28
29#define LIBUSB_DRIVER_NAME_NT "libusb0"
30#define LIBUSB_DRIVER_NAME_9X "libusb0.sys"
31
32typedef int bool_t;
33
34#ifndef FALSE
35#define FALSE 0
36#endif
37#ifndef TRUE
38#define TRUE (!(FALSE))
39#endif
40
41#define REGISTRY_BUF_SIZE 512
42
43typedef struct _filter_file_t filter_file_t;
44struct _filter_file_t
45{
46 filter_file_t* next;
47 char name[MAX_PATH];
48};
49
50typedef int filter_mode_e;
51enum _filter_mode_e
52{
53 FM_NONE = 0,
54 FM_LIST = 1 << 0,
55 FM_INSTALL = 1 << 1,
56 FM_REMOVE = 1 << 2,
57};
58
59typedef int filter_type_e;
60enum _filter_type_e
61{
62 FT_NONE = 0,
63 FT_CLASS_UPPERFILTER = 1 << 0,
64 FT_CLASS_LOWERFILTER = 1 << 1,
65 FT_DEVICE_UPPERFILTER = 1 << 2,
66 FT_DEVICE_LOWERFILTER = 1 << 3,
67};
68
69typedef struct _filter_hwid_t filter_hwid_t;
70struct _filter_hwid_t
71{
72 int vid;
73 int pid;
74 int mi;
75 int rev;
76};
77
78typedef struct _filter_device_t filter_device_t;
79struct _filter_device_t
80{
81 filter_device_t* next;
82
83 char device_name[MAX_PATH];
84 char device_hwid[MAX_PATH];
85 char device_mfg[MAX_PATH];
86 char device_uppers[MAX_PATH];
87 char device_lowers[MAX_PATH];
88 char device_id[MAX_PATH];
89
90 filter_type_e action;
91};
92
93typedef struct _filter_class_t filter_class_t;
94struct _filter_class_t
95{
96 filter_class_t* next;
97
98 char name[MAX_PATH]; // key
99
100 char class_name[MAX_PATH];
101 char class_guid[MAX_PATH];
102 char class_uppers[MAX_PATH];
103 char class_lowers[MAX_PATH];
104 filter_device_t* class_filter_devices;
105 filter_type_e action;
106};
107
108typedef struct _filter_context_t filter_context_t;
109struct _filter_context_t
110{
111 union
112 {
113 int switches_value;
114 struct
115 {
116 bool_t add_all_classes:1;
117 bool_t add_device_classes:1;
118 bool_t add_default_classes:1;
119 };
120 }switches;
121
122 filter_mode_e filter_mode;
123 filter_class_t* class_filters;
124 filter_device_t* device_filters;
125 filter_file_t* inf_files;
126 bool_t show_help_only;
127 bool_t remove_all_device_filters;
128 bool_t class_filters_modified;
129 char* prompt_string;
130 char* wait_string;
131};
132
133bool_t usb_registry_is_nt(void);
134
135bool_t usb_registry_restart_device(HDEVINFO dev_info,
136 SP_DEVINFO_DATA *dev_info_data);
137bool_t usb_registry_stop_device(HDEVINFO dev_info,
138 SP_DEVINFO_DATA *dev_info_data);
139bool_t usb_registry_start_device(HDEVINFO dev_info,
140 SP_DEVINFO_DATA *dev_info_data);
141
142bool_t usb_registry_get_property(DWORD which, HDEVINFO dev_info,
143 SP_DEVINFO_DATA *dev_info_data,
144 char *buf, int size);
145bool_t usb_registry_set_property(DWORD which, HDEVINFO dev_info,
146 SP_DEVINFO_DATA *dev_info_data,
147 char *buf, int size);
148
149bool_t usb_registry_restart_all_devices(void);
150
151
152void usb_registry_stop_libusb_devices(void);
153void usb_registry_start_libusb_devices(void);
154
155bool_t usb_registry_get_mz_value(const char *key, const char *value,
156 char *buf, int size);
157bool_t usb_registry_set_mz_value(const char *key, const char *value,
158 char *buf, int size);
159int usb_registry_mz_string_size(const char *src);
160char *usb_registry_mz_string_find(const char *src, const char *str, bool_t no_case);
161char *usb_registry_mz_string_find_sub(const char *src, const char *str);
162bool_t usb_registry_mz_string_insert(char *src, const char *str);
163bool_t usb_registry_mz_string_remove(char *src, const char *str, bool_t no_case);
164void usb_registry_mz_string_lower(char *src);
165
166bool_t usb_registry_get_hardware_id(HDEVINFO dev_info,
167 SP_DEVINFO_DATA *dev_info_data,
168 char* max_path_buffer);
169bool_t usb_registry_is_service_libusb(HDEVINFO dev_info,
170 SP_DEVINFO_DATA *dev_info_data,
171 bool_t* is_libusb_service);
172bool_t usb_registry_is_service_or_filter_libusb(HDEVINFO dev_info,
173 SP_DEVINFO_DATA *dev_info_data,
174 bool_t* is_libusb_service);
175
176bool_t usb_registry_insert_class_filter(filter_context_t* filter_context);
177bool_t usb_registry_remove_class_filter(filter_context_t* filter_context);
178bool_t usb_registry_remove_device_filter(filter_context_t* filter_context);
179bool_t usb_registry_free_class_keys(filter_class_t **head);
180bool_t usb_registry_get_usb_class_keys(filter_context_t* filter_context, bool_t refresh_only);
181bool_t usb_registry_get_all_class_keys(filter_context_t* filter_context, bool_t refresh_only);
182bool_t usb_registry_get_device_filter_type(HDEVINFO dev_info,
183 SP_DEVINFO_DATA *dev_info_data,
184 filter_type_e* filter_type);
185
186bool_t usb_registry_add_usb_class_key(filter_context_t* filter_context, const char* class_guid);
187bool_t usb_registry_add_filter_device_keys(filter_device_t** head,
188 const char* id,
189 const char* hwid,
190 const char* name,
191 const char* mfg,
192 const char* uppers_mz,
193 const char* lowers_mz,
194 filter_device_t** found);
195
196bool_t usb_registry_add_filter_file_keys(filter_file_t** head,
197 const char* name,
198 filter_file_t** found);
199
200bool_t usb_registry_lookup_class_keys_by_name(filter_class_t** head);
201bool_t usb_registry_add_class_key(filter_class_t **head,
202 const char *key,
203 const char *class_name,
204 const char *class_guid,
205 filter_class_t **found,
206 bool_t update_only);
207
208bool_t usb_registry_insert_device_filters(filter_context_t* filter_context);
209bool_t usb_registry_insert_device_filter(filter_context_t* filter_context, char* hwid, bool_t upper,
210 HDEVINFO dev_info, SP_DEVINFO_DATA *dev_info_data);
211
212bool_t usb_registry_free_filter_devices(filter_device_t **head);
213bool_t usb_registry_free_filter_files(filter_file_t **head);
214
215filter_device_t* usb_registry_match_filter_device(filter_device_t** head,
216 HDEVINFO dev_info, PSP_DEVINFO_DATA dev_info_data);
217
218bool_t usb_registry_mz_to_sz(char* buf_mz, char separator);
219bool_t usb_registry_fill_filter_hwid(const char* hwid, filter_hwid_t* filter_hwid);
220
221#endif
Note: See TracBrowser for help on using the repository browser.