title: Why does NdisFRegisterFilterDriver return NDIS_STATUS_FAILURE?
body: <p>I'm trying to write an NDIS Intermediate Filter driver, but I'm stuck before anything at all happens.</p>
  
  <p>My code doesn't do anything yet, beyond trying to register the filter driver:</p>
  
  <pre><code>NTSTATUS 
  DriverEntry(
  IN PDRIVER_OBJECT DriverObject,
  IN PUNICODE_STRING RegistryPath)
  {
  NDIS_FILTER_DRIVER_CHARACTERISTICS FChars;
  NDIS_STRING ServiceName, UniqueName, FriendlyName;
  NDIS_STATUS Status;
  
  UNUSED(RegistryPath);
  
  g_FilterObject = DriverObject;
  
  RtlInitUnicodeString(&amp;ServiceName, MIP_SERVICE_NAME);
  RtlInitUnicodeString(&amp;FriendlyName, MIP_FRIENDLY_NAME);
  RtlInitUnicodeString(&amp;UniqueName, MIP_UNIQUE_NAME);
  
  NdisZeroMemory(&amp;FChars, sizeof(NDIS_FILTER_DRIVER_CHARACTERISTICS));
  
  FChars.Header.Type = NDIS_OBJECT_TYPE_FILTER_DRIVER_CHARACTERISTICS;
  FChars.Header.Size = sizeof(NDIS_FILTER_DRIVER_CHARACTERISTICS);
  FChars.Header.Revision = NDIS_FILTER_CHARACTERISTICS_REVISION_1;
  FChars.MajorNdisVersion = 6;
  FChars.MinorNdisVersion = 0;
  FChars.MajorDriverVersion = 1;
  FChars.MinorDriverVersion = 0;
  FChars.Flags = 0;
  
  FChars.FriendlyName = FriendlyName;
  FChars.UniqueName = UniqueName;
  FChars.ServiceName = ServiceName;
  
  FChars.AttachHandler = FilterAttach;
  FChars.DetachHandler = FilterDetach;
  FChars.RestartHandler = FilterRestart;
  FChars.PauseHandler = FilterPause;
  
  FChars.SetOptionsHandler = FilterRegisterOptions;
  FChars.SetFilterModuleOptionsHandler = FilterSetModuleOptions;
  
  FChars.SendNetBufferListsHandler = FilterSend;
  FChars.ReturnNetBufferListsHandler = FilterReturnNetBufferLists;
  FChars.SendNetBufferListsCompleteHandler = FilterSendComplete;
  FChars.ReceiveNetBufferListsHandler = FilterReceive;
  FChars.CancelSendNetBufferListsHandler = FilterCancelSend;
  
  FChars.DevicePnPEventNotifyHandler = FilterDevicePnPEvent;
  FChars.NetPnPEventHandler = FilterNetPnPEvent;
  FChars.StatusHandler = FilterStatus;
  
  DriverObject-&gt;DriverUnload = FilterUnload;
  
  Status = NdisFRegisterFilterDriver(DriverObject,
          (NDIS_HANDLE)g_FilterObject,
          &amp;FChars,
          &amp;g_FilterHandle);
  if (Status != NDIS_STATUS_SUCCESS)
  {
      MDBG("Failed to register filter driver %x", Status);
      return Status;
  }
  
  return NDIS_STATUS_SUCCESS;
  }
  </code></pre>
  
  <p>All of the other functions are empty (except for some tracing code). They don't matter here.</p>
  
  <p>NdisFRegisterFilterDriver always returns NDIS_STATUS_FAILURE. The <a href="http://msdn.microsoft.com/en-us/library/windows/hardware/ff562608%28v=vs.85%29.aspx" rel="nofollow">documentation</a> does not describe why this can happen.
  (It shouldn't be a problem with the .inf file, as I've tried with a literal copy of the sample driver from the DDK.)</p>