summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ndiscvt
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2005-02-16 05:41:18 +0000
committerwpaul <wpaul@FreeBSD.org>2005-02-16 05:41:18 +0000
commit07b632956a99a773db5488fdd2ffd5f209d38dea (patch)
treef3934335c485d66f4991e7d9fc75b2e17460984c /usr.sbin/ndiscvt
parent41238cc6d19537d94771e20dbde35067d8d8f618 (diff)
downloadFreeBSD-src-07b632956a99a773db5488fdd2ffd5f209d38dea.zip
FreeBSD-src-07b632956a99a773db5488fdd2ffd5f209d38dea.tar.gz
Add support for Windows/x86-64 binaries to Project Evil.
Ville-Pertti Keinonen (will at exomi dot comohmygodnospampleasekthx) deserves a big thanks for submitting initial patches to make it work. I have mangled his contributions appropriately. The main gotcha with Windows/x86-64 is that Microsoft uses a different calling convention than everyone else. The standard ABI requires using 6 registers for argument passing, with other arguments on the stack. Microsoft uses only 4 registers, and requires the caller to leave room on the stack for the register arguments incase the callee needs to spill them. Unlike x86, where Microsoft uses a mix of _cdecl, _stdcall and _fastcall, all routines on Windows/x86-64 uses the same convention. This unfortunately means that all the functions we export to the driver require an intermediate translation wrapper. Similarly, we have to wrap all calls back into the driver binary itself. The original patches provided macros to wrap every single routine at compile time, providing a secondary jump table with a customized wrapper for each exported routine. I decided to use a different approach: the call wrapper for each function is created from a template at runtime, and the routine to jump to is patched into the wrapper as it is created. The subr_pe module has been modified to patch in the wrapped function instead of the original. (On x86, the wrapping routine is a no-op.) There are some minor API differences that had to be accounted for: - KeAcquireSpinLock() is a real function on amd64, not a macro wrapper around KfAcquireSpinLock() - NdisFreeBuffer() is actually IoFreeMdl(). I had to change the whole NDIS_BUFFER API a bit to accomodate this. Bugs fixed along the way: - IoAllocateMdl() always returned NULL - kern_windrv.c:windrv_unload() wasn't releasing private driver object extensions correctly (found thanks to memguard) This has only been tested with the driver for the Broadcom 802.11g chipset, which was the only Windows/x86-64 driver I could find.
Diffstat (limited to 'usr.sbin/ndiscvt')
-rw-r--r--usr.sbin/ndiscvt/inf.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.sbin/ndiscvt/inf.c b/usr.sbin/ndiscvt/inf.c
index de6c342..e6389fc 100644
--- a/usr.sbin/ndiscvt/inf.c
+++ b/usr.sbin/ndiscvt/inf.c
@@ -61,7 +61,7 @@ static void dump_deviceids_pci (void);
static void dump_deviceids_pcmcia (void);
static void dump_pci_id (const char *);
static void dump_pcmcia_id (const char *);
-static void dump_regvals (void);
+/*static*/ void dump_regvals (void);
static void dump_paramreg (const struct section *,
const struct reg *, int);
@@ -246,7 +246,8 @@ dump_deviceids_pci()
if (manf->vals[1] != NULL &&
(strcasecmp(manf->vals[1], "NT.5.1") == 0 ||
strcasecmp(manf->vals[1], "NTx86") == 0 ||
- strcasecmp(manf->vals[1], "NTx86.5.1") == 0)) {
+ strcasecmp(manf->vals[1], "NTx86.5.1") == 0 ||
+ strcasecmp(manf->vals[1], "NTamd64") == 0)) {
/* Handle Windows XP INF files. */
snprintf(xpsec, sizeof(xpsec), "%s.%s",
manf->vals[0], manf->vals[1]);
@@ -325,7 +326,8 @@ dump_deviceids_pcmcia()
if (manf->vals[1] != NULL &&
(strcasecmp(manf->vals[1], "NT.5.1") == 0 ||
strcasecmp(manf->vals[1], "NTx86") == 0 ||
- strcasecmp(manf->vals[1], "NTx86.5.1") == 0)) {
+ strcasecmp(manf->vals[1], "NTx86.5.1") == 0 ||
+ strcasecmp(manf->vals[1], "NTamd64") == 0)) {
/* Handle Windows XP INF files. */
snprintf(xpsec, sizeof(xpsec), "%s.%s",
manf->vals[0], manf->vals[1]);
@@ -557,7 +559,7 @@ dump_paramreg(const struct section *s, const struct reg *r, int devidx)
return;
}
-static void
+/*static*/ void
dump_regvals(void)
{
struct assign *manf, *dev;
@@ -578,7 +580,8 @@ dump_regvals(void)
if (manf->vals[1] != NULL &&
(strcasecmp(manf->vals[1], "NT.5.1") == 0 ||
strcasecmp(manf->vals[1], "NTx86") == 0 ||
- strcasecmp(manf->vals[1], "NTx86.5.1") == 0)) {
+ strcasecmp(manf->vals[1], "NTx86.5.1") == 0 ||
+ strcasecmp(manf->vals[1], "NTamd64") == 0)) {
is_winxp++;
/* Handle Windows XP INF files. */
snprintf(sname, sizeof(sname), "%s.%s",
@@ -600,9 +603,15 @@ retry:
* Look for section names with .NT, unless
* this is a WinXP .INF file.
*/
+
if (is_winxp) {
sprintf(sname, "%s.NTx86", assign->vals[0]);
dev = find_assign(sname, "AddReg");
+ if (dev == NULL) {
+ sprintf(sname, "%s.NT",
+ assign->vals[0]);
+ dev = find_assign(sname, "AddReg");
+ }
if (dev == NULL)
dev = find_assign(assign->vals[0],
"AddReg");
OpenPOWER on IntegriCloud