aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorBill Paul <wpaul@FreeBSD.org>2004-01-27 09:05:52 +0000
committerBill Paul <wpaul@FreeBSD.org>2004-01-27 09:05:52 +0000
commit307ca1d6256316fa7515d6f612bea4c6078f2df3 (patch)
tree3aab61050ee69147c4d64a755360f48dbf63987a /usr.sbin
parent3f7266edd66c66de8d05dcba1beb69dd03cdca91 (diff)
downloadsrc-307ca1d6256316fa7515d6f612bea4c6078f2df3.tar.gz
src-307ca1d6256316fa7515d6f612bea4c6078f2df3.zip
Some Windows .INF files are deliberately sabotaged to prevent them from
loading on a particular version of Windows. For example, a .INF file for a Windows 2000 driver may have an empty [foo.NT.5.1] section which will be ingored on Win2K (whose .INF parser won't look for sections decorated with .NT.5.1) in favor of a [foo] section. Likewise, a WinXP file will have an empty [foo] section which will be ignored in favor of [foo.NT.5.1]. The problem is, we can handle both Win2K and WinXP drivers, and we don't want to exclude either one. As a workaround, we try to pretend we are WinXP by default and search for sections decorated with .NT.5.1, but if we don't turn up any records, we assume that maybe we're being fooled by a sabotaged .INF file and make one more pass looking for undecorated sections instead. This allows us to parse the .INF files for both the Win2K and the WinXP Centrino wireless drivers. I'd give anything for 5 minutes alone in a room with whoever wrote Microsoft's .INF file parser. Just 5 minutes. That's all.
Notes
Notes: svn path=/head/; revision=125073
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ndiscvt/inf.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/usr.sbin/ndiscvt/inf.c b/usr.sbin/ndiscvt/inf.c
index f0cacee5dcc0..100fd903545c 100644
--- a/usr.sbin/ndiscvt/inf.c
+++ b/usr.sbin/ndiscvt/inf.c
@@ -184,6 +184,7 @@ dump_deviceids()
struct section *sec;
struct assign *assign;
char xpsec[256];
+ int found = 0;
/* Find manufacturer name */
manf = find_assign("Manufacturer", NULL);
@@ -203,6 +204,8 @@ dump_deviceids()
/* Emit start of device table */
fprintf (ofp, "#define NDIS_DEV_TABLE");
+retry:
+
/*
* Now run through all the device names listed
* in the manufacturer section and dump out the
@@ -222,9 +225,17 @@ dump_deviceids()
#endif
/* Emit device description */
fprintf (ofp, "\t\\\n\t\"%s\" },", dev->vals[0]);
+ found++;
}
}
+ /* Someone tried to fool us. Shame on them. */
+ if (!found) {
+ found++;
+ sec = find_section(manf->vals[0]);
+ goto retry;
+ }
+
/* Emit end of table */
fprintf(ofp, "\n\n");
@@ -407,7 +418,7 @@ dump_regvals(void)
struct section *sec;
struct assign *assign;
char sname[256];
- int i, is_winxp = 0, is_winnt = 0, devidx = 0;
+ int found = 0, i, is_winxp = 0, is_winnt = 0, devidx = 0;
/* Find signature to check for special case of WinNT. */
assign = find_assign("version", "signature");
@@ -433,8 +444,11 @@ dump_regvals(void)
/* Emit start of block */
fprintf (ofp, "ndis_cfg ndis_regvals[] = {");
+retry:
+
TAILQ_FOREACH(assign, &ah, link) {
if (assign->section == sec) {
+ found++;
/*
* Find all the AddReg sections.
* Look for section names with .NT, unless
@@ -464,6 +478,13 @@ dump_regvals(void)
}
}
+ if (!found) {
+ sec = find_section(manf->vals[0]);
+ is_winxp = 0;
+ found++;
+ goto retry;
+ }
+
fprintf(ofp, "\n\t{ NULL, NULL, { 0 }, 0 }\n};\n\n");
return;