その1

 C++で書くカーネルモードドライバについて
 2年ぐらい前になるが、とあるドライバ(PCI)の仕事をした時に、
 C++で書かれたドライバを目にしたような気がする。
 (お客さんのところのソースで。うちとは関係無く。)
 その時は忙しくてなんも気にしなかったが、どうやって書いてるんだろ。
 ・・・
 相変わらず日本語文献無いなぁ。(ググってみた)
 ・・・。アカン、CPPやとLinuxばっかりだ・・。
 いや、Linuxドライバもやること有るから良いんだろうケド
(やったこと無いけど)
 今度ちゃんと見せて貰ってくるか。

 こそっと

  class KdStatDevice : public KdDevice
  {
   public:

   KdStatDevice();
   ~KdStatDevice();

   virtual NTSTATUS DispatchDeviceControl (KdIrp &Irp);
   virtual void StartIo (KdIrp &Irp);

   // This is the DPC
   VOID DpcRoutine (PKdDpc Dpc,
    PVOID SystemArgument1,
    PVOID SystemArgument2);

   // This is the ISR
   BOOLEAN InterruptServiceRoutine(KdIrq *Irq, 
          PVOID Context);

   BOOLEAN DoIo();

   KdIrq            m_KdInterrupt;
   KdBusAddress    *m_pBusAddress;
   KdDpc            m_KdDpc;
   ULONG            m_InterruptCount;

   };

   // Driver entry point
   NTSTATUS
   DriverEntry(
    IN PDRIVER_OBJECT DriverObject,
    IN PUNICODE_STRING RegistryPath
   )
   {

   NTSTATUS Status = STATUS_INSUFFICIENT_RESOURCES;
   new KdStatDriver(Status, DriverObject, RegistryPath);

   if (!NT_SUCCESS(Status) && KdDriver::Driver())
     KdDriver::Driver()->Unload();
   return Status;

   }

   KdStatDriver::KdStatDriver(NTSTATUS &Status,
      PDRIVER_OBJECT
      pDriverObject PUNICODE_STRING
      puniRegistryPath) :
      KdDriver(Status, pDriverObject, puniRegistryPath)
   {
     ...
      KdStatDevice{*} pDevice = new KdStatDevice;

      // Initialize the device
      Status = pDevice->Init(FILE_DEVICE_UNKNOWN, L"Int");

      ...

      // This call will map our IRQ to an interrupt.
      pDevice->m_KdInterrupt.Init(
         (KDIRQ_CALLBACK) pDevice->InterruptServiceRoutine,
         pDevice,
         ISA,          // The bus of the device
         0,            // The number of the bus
         STAT_IRQ,     // The interrupt number 
                // we are waiting on
         STAT_IRQ,     // The interrupt vector
         Latched       // Type of interrupt (Latched or
                // Level Sensitive)
        );

      ...

      // Register the IRQ with the device
      Status = pDevice->m_KdInterrupt.Connect();
   ...
   }

 めっけた。出来るっぽいな。
 ・・・肝心のディスパッチ登録が・・・どこ・・・
 つかこのKdDriverってライブラリは何・・・
 英語、止めません?(しょぼぼん