Couple of lessons learned during USB driver testing:

- In kern_ndis.c:ndis_unload_driver(), test that ndis_block->nmb_rlist
  is not NULL before trying to free() it.

- In subr_pe.c:pe_get_import_descriptor(), do a case-insensitive
  match on the import module name. Most drivers I have encountered
  link against "ntoskrnl.exe" but the ASIX USB ethernet driver I'm
  testing with wants "NTOSKRNL.EXE."

- In subr_ntoskrnl.c:IoAllocateIrp(), return a pointer to the IRP
  instead of NULL. (Stub code leftover.)

- Also in subr_ntoskrnl.c, add ExAllocatePoolWithTag() and ExFreePool()
  to the function table list so they'll get exported to drivers properly.
This commit is contained in:
Bill Paul 2005-02-24 17:58:27 +00:00
parent 524cfc25d0
commit 70211f5ef5
3 changed files with 10 additions and 3 deletions

View File

@ -1682,7 +1682,8 @@ ndis_unload_driver(arg)
sc = arg;
free(sc->ndis_block->nmb_rlist, M_DEVBUF);
if (sc->ndis_block->nmb_rlist != NULL)
free(sc->ndis_block->nmb_rlist, M_DEVBUF);
ndis_flush_sysctls(sc);

View File

@ -722,7 +722,7 @@ IoAllocateIrp(stsize, chargequota)
IoInitializeIrp(i, IoSizeOfIrp(stsize), stsize);
return (NULL);
return (i);
}
__stdcall static irp *
@ -2615,6 +2615,8 @@ image_patch_table ntoskrnl_functbl[] = {
IMPORT_FUNC(InterlockedPushEntrySList),
IMPORT_FUNC(ExInterlockedPopEntrySList),
IMPORT_FUNC(ExInterlockedPushEntrySList),
IMPORT_FUNC(ExAllocatePoolWithTag),
IMPORT_FUNC(ExFreePool),
IMPORT_FUNC(KefAcquireSpinLockAtDpcLevel),
IMPORT_FUNC(KefReleaseSpinLockFromDpcLevel),
IMPORT_FUNC_MAP(KeAcquireSpinLockRaiseToDpc, KfAcquireSpinLock),

View File

@ -53,6 +53,8 @@ __FBSDID("$FreeBSD$");
#include <sys/errno.h>
#ifdef _KERNEL
#include <sys/systm.h>
extern int ndis_strncasecmp(const char *, const char *, size_t);
#define strncasecmp(a, b, c) ndis_strncasecmp(a, b, c)
#else
#include <stdio.h>
#include <stdlib.h>
@ -431,6 +433,8 @@ pe_relocate(imgbase)
* may be linked against several modules, typically HAL.dll, ntoskrnl.exe
* and NDIS.SYS. For each module, there is a list of imported function
* names and their addresses.
*
* Note: module names are case insensitive!
*/
int
@ -455,7 +459,7 @@ pe_get_import_descriptor(imgbase, desc, module)
while (imp_desc->iid_nameaddr) {
modname = (char *)pe_translate_addr(imgbase,
imp_desc->iid_nameaddr);
if (!strncmp(module, modname, strlen(module))) {
if (!strncasecmp(module, modname, strlen(module))) {
bcopy((char *)imp_desc, (char *)desc,
sizeof(image_import_descriptor));
return(0);