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.
This commit is contained in:
Bill Paul 2004-01-27 09:05:52 +00:00
parent 3f7266edd6
commit 307ca1d625

View File

@ -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;