






 NuMega DriverStudio   WDM-

  ,    -     .



 ,  ,       .   ,          .    Windows  Microsoft   . ,   UNIX      ,    ,   Windows     .

    MS DOS,          .      , , ,    .     o蠗 , CD-ROM , ,      .   ,  ,    ,    .  ,           .           , ,   ,  o,    .   ,         Linux  .      ? ? ?     ,          - ?               ?  䠗   ,   ,   .   -,   ,       .        .  , ,    ,     ,    "".  -     ,      ,     .

          Windows        .        PCI-  Win 98/ME/2000     WDM   NuMega DriverStudio.  ,  ,     ,       i386    .     PCI,    .

              PCI- XDSP680c.

        "  "  "   "    ,      . ,        Win32   Visual C++.



1.        Windows.

,           .          ,     -:

 ,           ,   -, DMA     .          :         3-    ( ).                    (Exception).      ,    , 0-  .

            ( -,     ..) Plug and Play (PnP).   , ,    ,    ,     ,            (IRQ),    -.    " ",      IRQ          .        .

  Windows,      ,    :   ,     ,    ..         : ,  ,    ""   ,      . 1.1  -  Windows.

        Windows: Windows NT,   Windows NT, 2000, XP,  Windows 9x (Win 95, 98, ME).        9,        .         -.  ,       .

 Windows 9x    .vxd.         Windows 3.1.  .vxd   " ": .. ,   Windows 3.1,      Windows 95,   ,  98.   .vxd   Win32,   Win16 .

 Windows NT 4.0    .         ,      ,   ..      Windows NT 4.0 ,  , ""  ,    .    Win98  Win2000    ⠗ WDM (Windows Driver Model).      Windows NT 4.0   . WDM           Win 98,    Win 2000.

 Win 98      : User Mode ( )  Kernel Mode ( ).      .    3-  ;        .   DOS  Windows     (Virtual Machine, VM),         . ..   ,                     .       (Virtual Machine Manager, VMM).  VMM   ,         VM. , VM,       (Virtual Device Drivers), ,     (Kernel Mode).

. 1.  - Win 98.


 Windows 98    -   DOS    Win16      Win32.  DOS     (DOS virtual machine), Win 16  Win32     Windows (System Virtual Machine). ,     - (,   API ReadFile   ),        DLL (  堗 kernel32.dll).           .    &#8594;dll&#8594;   .

 Windows 2000   ,   Win98.      ,      (, Win2000  ,    Win2000   Alpha, MIPS  .).        Win2000    ,       .

. 2   Windows2000.


 Win2000  ,      (User mode)     (Kernel mode).      ,  Win32- (  API  Windows),  POSIX ( ).        :  - (I/O manager),   (Configuration Manager),  PnP,    (Power Manager),   (Memory Manager)     .   Win2000    -.          .       Hardware Abstraction Level, HAL (  ). HAL    Win2000,     (     )  . .. Win2000     (    Win2000   Alpha  RISC),  HAL       , ,  -    ,    ,     .  ,            .


  NT     ,  , , ,   ,  .  Windows 2000   WDM (Windows Driver Model).  Windows 2000    :

 Kernel mode drivers (  ).   .       :  , , ,  ,     ..

 Graphics drivers ( ).  ,     .    ,           .  ,      .

 Multimedia drivers (-).   :

 ⠗ ,    .

        .

  ⠗ ,  ,   .

 Network drivers ( )         .

 Virtual DOS Drivers     MS-DOS.     .

  ,     ,        .

 Device drivers ( ),       ,     .       , . .        Windows NT.

 Intermediate drivers ( ),       .        .

 File system drivers (FSDs).   ,   FAT, NTFS, CDFS,      Intermediate drivers  Device drivers.

 Windows 2000    :

      .

  .

  .

   .

 -.

   -   I/O request packets (IRPs,  -).

   -.

 - Windows 2000   :

  - NT     kernel-mode ,    ,       .

  - .  ,  ,  ,    ,      -  " "    .  ,     ,  - Windows      ;       ;        .             .

       ,      - (I/O manager). 



2.   NuMega Driver Studio   WDM .


 WDM    DDK     .       :   ,  inf   ,      ..         .        . ,        PCI,     : 

   .inf   ;

     :  ,     (, ,   IRQ  );

    (  );

   Windows  ;

      (  ,          ).


    ,  ,    .

        Windows     .      DriverStudio  NuMega.         DDK ( DDK 2000   )   Visual C++    5.0.     :

DriverStudio 2.01(    DS);

DDK 2000;

Visual C++ 6.0 (    VC++).

    :

DriverWorks      DriverStudio.    DriverWorks     Windows 98/ME/2K   WDM.    .   DriverWorks     Visual C++.

VtoolsD    .vxd.        DS  VC++    ,   .  ,     .vxd,     .

SoftIce kernel-mode .         ,     .     ,         .          .   SoftIce        :       . ,       - .

DriverNetworks      .      ,     .


  DS      DDK   VC++.      DS.            VC++, .       C:\Program Files\NuMega\DriverStudio.    DS      .       <__DS>.    DS   ,   .      VC++    <__DS>\DriverVorks\source\vdwlibs.dsw.    ,  DS       .      ,   MFC    UNIX.       VC++  .

         VdwLibs Win32 WDM Checked (    )  Win32 WDM Free.     .     <__DS>\DriverVorks\lib\i386\checked   vdw.lib (   win2K)  vdw_wdm.lib (win 9x). DS   . 



2.1.   DriverWorks.

,    -      .       DriverStudio     , ,         .   DriverWorks   WDM     ,    .  DriverWorks    ,      ,    ,            .

    DriverWorks  ,   .       ""  WDM,  DriverWorks        .  DriverWorks         DDK,        .  ,        .  ,     DDK     ,        .

  DriverWorks    :   KFile         .

 ,   DriverWorks  Visual C++   MFC. MFC     ,       API    - ,        .

,    DriverWorks   :    .   :    DriverWorks     ,     ( , ,  ,  -),  ,     ,   ..         ,        .  , , , .

   DriverWorks    .


  (Driver Object).

     KDriver.        .      ,    ,         .  ࠗ     :    ,   ..        ,  ,   .

   ,        .      - (I/O Manager)      .          .    - (I/O request),   ,    -.

 - ,         ,    .    ,     ,       .      KDriver    .      DriverEntry ,    .

    -WDM ,   WDM-     :           . WDM-         EntryPoint.     .

WDM-   AddDevice,   ,   ,   .       ,      (Physical Device Object, PDO).

              .   ,      ,     . ,    .

 ,       Unload,     .      .


 KRegistryKey

   ,       .   (registry)   ,    ,    .     ()   (key),     (value). ,   ,    :  (integer), ,  .

       .        .       HKLM\SYSTEM\CurrentControlSet\Services\< >\Parameters\.

 DriverWorks   KRegistryKey,      .      (QueryValue),  (WriteValue),  (Delete)   .    KRegistryKey   ,      .        Reconstruct.


   - (I/O Request Object)

   -,  ,     - (I/O request packet, IRP        ),      .

 IRP      ,   ,    ,    ,   IRP    ,    ..         ,    ,  IRP      . ..   IRP     .     IRP    蠗 . Win2000 DDK.

       IRP    :           ,  -  IRP    ,    .     IRP        .  ,  ,      ,     ,     .     ,   ,   IRP,         .  ,    ,    IRP        -.

 IRP   /,     .  ,       ,      , IRP    :     ,     :  ,    ,   ..     IRP         .          ,      蠗   " IRP", "IRP stack location".     ,         ,          ,    IRP.

. 3       IRP


IRP     /,    .        CreateFile, CloseFile, ReadFile, WriteFile  DeviceControl.

IRP   ,     /, ,   .  IRP    ,    .


  (Device Object).

     KDevice  KPnpDevice.       DriverWorks:         ,    .           ,   蠗  ,  ,   ,  /  ..      CreateFile, ReadFile, WriteFile,  /  IRP  .   ,   ,        ࠗ             IRP.  ,    젗   ,     .

 KDevice      .        .       KPnpDevice.      PnP-, .. ,   .        PnP-.        :  KPnpDevice  ,    ,  KDevice.  ,                .

         ,     (device control).        API ReadFile(), WriteFile(), DeviceControl().

      .    ,     ,     KDevice  KPnpDevice.            ,   ,     IRP,         .         DriverStudio,    DDK. ,      DDK   .

,      .     .      :     ,     .   ,      (   ).  ,   , .

 , ,    ,    :    - ,   ,  ?  ,  Win2000  . ..,       Intel,          ,  Alpha.  ,            ,    HAL   .            ,    .       ,                    .       / ,    .          ,          . ,   ,    ,  . ,  ,           堗   HAL   ,   .

    ,   , ,         ,        ().      KMemoryRange,      ,  堗   KInterrupt,      ,  ,    .        , , ,        KMemoryRange.

         (Lower devices).    ,   WDM    ,     IRP-  .       :


. 4  


 .4   ,     .  1   ()  ,  3   ()  .      1  2    .      1 .  2      ( 1)     ( 3).   3      ( 2),      ,  3   .

   ,       ,    ,    . ,     ,   USB.    3  USB.  2  ,      :     - , ""  ,    (,     ).       1.  1    ,       .      ;    CapsLock, Shift  ..

       ,       2.      ,   2      3,   -  .       ,   ,      .  ,      ,      .

   ,    1,   2    .      ,   IRP  3.  ,       IRP   ,      (KLowerDevice, KPnpLowerDevice). ,     ,        IRP.

,         .           ,  " ".

   ,         .      DriverWorks   DDK. ,      - ,  ,    .      ,   Win2000, .         3        inp / outp.       0 , ,     .        ,  ReadFile(), WriteFile(), DeviceControl()         ,  ,     (      -). ,     -     .           ,  ,  ,    .          ,       ,      .


    .

       ? ,      .       - . ,              ,      .   IRP     !       -      (serialization) , ..          .             .

,    ,    KDeviceQueue.        ,      . ,  ,       : "      ,      ,     ".          .     :       .  ,       .     ,   .         ,     .         .     KDriverManagedQueue.

. 5  ,    .

   ,     KDeviceQueue. , ,         ,      .


      DriverWorks

     ,   (Interrupt)    ,   ,      . ""  ,        (  ).      ,   ,    (   , Interrupt Service Routine, ISR)     .              .

 ,    ,           ,        (Interrupt Request Level), IRQL.   32 IRQL   ,   0  31.   0   , 31  .

. 1   IRQL.


        (3129).   頗      (21). PassiveLevel    . IRQL,     ,  -   .  ,       ,  HAL.

,           .        ,       .

       ,      .                .   ISR ,      ,       .      .     ,   ,       ?        (Deferred Procedure Call, DPC).    ISR     (DPC). DPC  ,       . DriverWorks   KDeferredCall,      ,     DPC.

DriverWorks   ,    ,   KInterrupt.   KInterrupt   ,     .        MyDevice,   KInterrupt  m_TheInterrupt.       ISR: 



,   OnStartDevice      ISR  : 



 Context    (void),  ISR.

Isr  ISR,   .

       : 











  ISR    Disconnect().

,          ,        .    ,  ,    ,      .        DPC     DriverWorks  DDK.


   

   ,         ,      /, , ,  .         .

      .      .  ,  -,       ,       .        ,     ,   .      -.    PCI.           ,   .       ,    ..

    " "     ,        .       :           ""  -   .  ,       ,    ,     (mapping)      ,    .       ,    ,  ,      .        .        Windows (     ):      !        ,  ,     ,  .      ?

 .          ,       .            :               ,        .              ,      .      .

,     ,   KPeripherialAdress, KIoRange, KMemoryRange, KIoregister, KMemoryRegister. KPeripherialAdress             -.   KperipherialAdress  ,  . ,  ,   :

 KIoRange   -.       /    -      .    KIoRange       8, 16,  32- .

 KIoRegister       -.    KIoRegister     -    . , KIoRange     KIoRegister,   .   KioRegister ,    ,     []  KIoRange, : 









 KIoRegister       .

 KMemoryRange               (  ).  ,    ,       ,   8, 16  32  .

 KMemoryRegister  KIoRegister,   ,               .

 KMemoryToProcessMap            .     :         ,    . ,       :  ,      ,         .    ,     .

 ,           .     ,      .   PCI-⠗ 32 .

          .         .    , ,   ,   DDK    ,    , ..       HAL.        ,         .

   ,      :       !


 

   Windows,      ,       . ,   ,     .  , ,      ,      ..        . Windows 2000      ,       ,        .

    WDM (, , DriverWorks)   .       (Spin Lock),   KSpinLock.     :          ,    Lock .  ,      , .   ,    Unlock.

  KDispatcherObject       .     Windows      ,       .  ,   KDispatcherObject,    :

      ,      :  (TRUE)   (FALSE).

     Wait ,     ,       "".

           ,       .   .

  KDispatcherObject:

KEvent     . Kevent      .

KSemaphore    .      ,   .     ,    .    , ,     .

KTimer .         "".      Set    100 .         >= 10 .     ,     "".  Ktimer   KTimedCallBack.           (DPC).

KSystemThread      .       .           .      ,        Start.   ࠗ  Terminate.           .


 .

DriverWorks      .   , , ;    Unicode;  .

   KList, KInterlockedList, KInterruptSafeList.          ,    .     . KList        . KInterLockedList   (spin locks)      . KInterruptSafeList       .       FIFO (): KFifo, KLockableFifo, KInterruptSafeFifo.  KFile      .              .   Unicode     KUstring.      , ,        .


    

     ,   :            ?      ,      (anonymous) .       :

   GUID.

    .

1.GUID (Globally Unique Identifier,   ) 16-  . GUID      , -  ..  ,         GUID,  GUID      . GUID     ,     ,   ,          ,        : 

#define MyDevice_CLASS_GUID \



2.  (symbloic link)           : 



    ,     ++,      \\.\MyDevice.      ,  ,        ,    : , ,  ,   ..      ,       .            .            API.

      ?   GUID   ?

    GUID   .    ,    ,  GUID   .    ,     ,          \\.\MyDevice? -, .    ,          ,     ,      GUID.  , ,               ,     ࠗ GUID. 



2.     DriverStudio.



2.1  Driver Wizard

     DriverStudio   s     Visual C++.       DriverWizard,    Visual C++.       (&#8594;&#8594;DriverStudio&#8594;DriverWorks&#8594;DriverWizard)    Visual C++     DriverStudio DriverWizard.  DriverWizard  

       ,     ,     .

 6.   DriverWizard


         (  堗 XDSP    .      Next,     .

 7.   DriverWizard


     ,     : Windows NT 4.0 (    )  WDM,     .

 8.   DriverWizard


    ,    ,    .        ,      None driver does not control any hardware.          ,   PCI    .   PCI     :

   (PCI Vendor ID)   ,     .        1999.

   (PCI Device ID)    ,      .       680C.

   PCI.      +  .   堗 680C1999.

    (PCI Revision ID)   .    01.

   :        .       PCI-.   ,    (  ,        ,    堗 inf-),      PCI-,    .

 9.   DriverWizard


      ,  DriverWizard   ++,    ,     (Driver Class).

 13.   DriverWizard


    ,     .   :

  (read)    .

  (write)    .

  (flush)       .

   (device control)   .

    (internal device control)      .

 14.   DriverWizard


   DriverWizard      .  Select queuing method ,       -:

 None     .     .

 DriverManaged       ,      -,      .

 SystemManaged      .

  ,        .    ,     -  , ,     ,      .        ,   (Serialize)      ,    .   Seralize all Read requests  Serialize all Write requests        ,    .

. 15   DriverWizard.


     ,       Windows  ,   .     ,  ,    ,        .    ,          BreakOnEntry  boolean,      m_BreakOnEntry.     ࠗ false.  m_BreakOnEntry    .

         -  ,  ,      .

   Add, Edit  Delete   ,    .

. 16   DriverWizard.


  DriverWizard         PCI   DriverWorks.          .

          .          ,   , ,    Rename,      .

 DriverWizard    :

.17  Resource


 Resource.      ,          .     ,   -,           (DMA),     .          .

,   ,   " " , ,    Add Memory Range.     ,         :    KMemoryRange,      ,     PCI (PCI header)  ,     ,       :   (Read Only),   (Write Only)    (Read/Write).        (Share options).       :          (Exclusive to this device),     (Shareable within this driver)       (Shareable system wide). ,             .           m_MainMemoryRange,      PCIheader'e,   .

. 18    .


       -   DMA.      :     DriverWizard'     ISR, DPC    (Make ISR/DPC class functions).

          - ,             .   ,      Delete,     Edit  .

. 19  Interface.


  Interface  ,         DLL  .

      GUID . GUID  ,    -  .   GUID    ,   ̖  .

       .    , ..     ࠗ  ,     GUID.

. 20  Buffers.


  Buffers  ,      .

 (buffered) 䠗     , ,         .  (direct) 䠗          , ,    .

. 21  Power.


  WDM     .        (Manage power for this device)         .         .

. 22   DriverWizard.


,  -           .         .   (Device IO control code, IOCTL)    ,   .       .        - . ,         ,   PCI-.      XDSP_GetMemSize.      Add,    Edit IO Control Code (  ).

. 23    .


            ,     (  ).      (Ordinal) ,    . ,  0x800    , ,  ,   ..

 IOCTL   ,      .      Queue (serialize) this request code.

      ,       .    XDSPioctl.h.      ,    Remove  ,   Edit.

. 24   DriverWizard.


   DriverWorks  ,  DriverWizard        . ,      ,   ,         .  ,  DriverWizard   ,    Create test console application (    )    .     .       DriverStudio.      ,  ,  .

   ,    Finish.    ,          ,     .   OK DriverWizard     ,         Visual C++.



2.2    .

,  DriverWizard,    XDSP.        (Workspace) VC++: XDSP.dsw, XDSP.ncd  XDSP.opt     sys  exe.     XDSPioctl.h.     ,         DeviceIOControl.

  sys   DriverWizard        .   ,  :

Function.h

 ,    ,   ;

Makefile, Sources

  ,      VC++.

XDSP.h , XDSP.cpp

,   .

XDSP.plg, XDSP.dsp

 VC++;

XDSP.inf

   ;

XDSP.rc

  .  ,     .

XDSPDevice.cpp, XDSPDevice.h

,   .

        TextXDSP,     .     ,      ,    ,   .   -       .    :

Makefile,Sources

  ,      VC++.

Test_XDSP.plg, Test_XDSP.dsp

 VC++;

Test_XDSP.cpp

  .

        VC++  ,    .     VC++   ,   File&#8594;Open Workspace.         XDSP.dsw.      ,      VC++.  ,    ,     DriverStudio.       DriverStudio&#8594;Driver Build Settings:        :

.25    .


     :

1.CPU   ,    .   ,  Win2000     i386 (  Intel), IA64 (64-  Intel)  Alpha.       i386.

2.BASEDIR    DDK,   .  ,       ,    Edit:  .     .

  ,   Set.     Exit.   ,   Accept.    .

      : Checked  Free.

Checked   .        . ,       ,     VC++, Delphi  ..     3-       ,     .      ,     .       SoftIce,   DriverStudio.

Free     .

        Build&#8594;Set Active Configuration:

  DriverWizard     ,     : XDSP  Test_XDSP.   , XDSP   ,  Test_XDSP  .       Workspace  VC++.

         .      .     :                Set as Active Project (  ).

    .               ,  :     DriverWorks,     .

       Test_XDSP.     - .

        :    . , ,      .     .

      XDSP.sys.     /XDSP/sys/obj/i386.       DriverStudio .          XDSP.inf.       XDSP.

,          PCI  XDSP-680.    (     Foundation)   .            .            .      ,        .        xdsp.inf     xdsp.sys.

    ,    -       PnP       Windows: &#8594;&#8594; &#8594; .  Windows       ,     ,    .

       -    ,  " "    .      , ,      ,    .  ,     -    Windows  .

 ,    ,     .    test_xdsp.exe   test_xdsp r 32 (  32   ).   ,   : 













            32 .      , , ,   .       









        .    .



2.3    .

   ,  DriverWizard      .

     :

XDSP

 ;

XDSPDevice

 .

      :

PNPMinorFunctionName        IOCTL.     ,       IOCTL     .

POOLTAG DefaultPoolTag('PSDX')    BoundsChecker        .

KTrace t("XDSPdrv")    .          .       iostream  ++.        <<.         , : 



         "m_bBreakOnEntry loaded from registry, resulting value: ["     m_bBreakOnEntry.        SoftIce.

      XDSP ( ).   31    DECLARE_DRIVER_CLASS    XDSP.    DriverEntry,     : 





















































 LoadRegistryParameters a     ,   . ,     ,         (    m_bBreakOnEntry). 











     .    AddDevice.  ,    ,     (     ).          (Physical Device Object, PDO).          ,   .      XDSPDevice.    ,     (Functional Device Object, FDO). 

























































.      .    ,      -   ,        .       -   ,  DriverWizard.

     .   XDSPdrvDevice    KpnpDevice.    :   PDO     . 









































   m_Lower.Initialize(this, Pdo), SetLowerDevice(&m_Lower)  SetPnpPolicy()   .         .     ,  DriverWizard.

      .    ,    ,      ,         .           . 







 DefaultPnp  ,       .      IRP-,      (major function code)  IRP_MJ_PNP.      ,       IRP_MN_STOP_DEVICE, IRP_MN_START_DEVICE  .. (. )     .   ,     ,   .      ,        (  , ).      . 











 SystemControl     IRP-,      IRP_MJ_SYSTEM_CONTROL.           ,    IRP-   . -          ,     WMI-. 











 Invalidate ,         :   OnStopDevice, OnRemoveDevice     .  Invalidate      .     砗    ;    Invalidate     . ..     Invalidate      -  Invalidate    ,   DriverWorks,   Windows    .         ,        .

  Invalidate     Invalidate  ,   :  , ,  DMA  ..    ,   :   ,  ,    ,          .       -     ࠗ DriverWizard    .  ,          .            .    -   ,         Invalidate. 









    OnStartDevice.     IRP     IRP_MJ_PNP    IRP_MN_START_DEVICE.             .             .      ,    .        .        ,       .            .        , ..    PnP ,      . 















































  OnStopDevice    .       IRP    IRP_MJ_PNP    IRP_MN_STOP_DEVICE.      .

















  OnRemoveDevice      .     PnP     PDO.















     IRP,     (     /).     ?

  :          -    .  IRP-           .  ,   "" IRP-   .         .  Win2000 DDK  ,       .  ,  ,       .    堗 , ,    .

  KPnPDevice        CancelQueuedIrp. 



























































 StartIo   .   ,        .    :       -,    .       ,      IOCTL.  ,  DriverWizard               .  ,      -   IRP-.

















































































 Create ,            API CreateFile().                .



















  Close       .



















      - .      PCI-           . ,              .  ,                -  .  ,       .  ,    ,      ,   ,    ,    - .    :

































































 SerialRead ,      .   . ..  ,          ,       .   ,  ,    :



             .     ,      4  .         ind/outd. 











































 SerialWrite    ,       ,    .

























   ,         . -        :  ,    , -  .        -, IO Control;  IOCTL. IOCTL           .

 ,    ,     ,   IOCTL-.      32- .     #define  -  . ,     IOCTL-,         " " PCI-. 



     IRP-     IRP_MJ_READ,  蠗 IRP_MJ_WRITE,     DeviceIOControl          IRP_MJ_IOCONTROL  젗   IOCTL-.  DeviceControl     IRP    IRP_MJ_DEVICE_CONTROL.     StartIo.     IOCTL    . 





















































 XDSPDRV_IOCTL_GETMEMSIZE_Handler   IOCTL XDSPDRV_IOCTL_GETMEMSIZE.   ,      .    DriverWizard,        .

































  . ,    ,  DriverWizard      ࠗ   .    ,    -   ,       .        .

        DDK,              (,  -).          ,  DriverWizard    .      ,              .



2.4  dll-    

dll- (Dynamic Link Library)  ,        . Dll     .   dll         .

   ,   :        dll-,        .   -     ,        .

Dll-    :  (External)   (Internal).       dll,      ,  .    ,  dll-    .

   ,          &#8594; dll&#8594;.         -   dll-,       . ,    dll,     .    :

      , , ,      .          :    /,   IOCTL-.  堗      API-    .  ,          .  dll-,       ,   ,     .

         ,             dll.      .

,     .        ,      -,    .

      dll-,      :  ,         . , dll         Visual C++.

  VC++       XDSPInter.      Win32 Dynamic-Link Library.       A Simple DLL ( dll-).  VC++          DllMain().

 DllMain()      dll . DllMain()    BOOL APIENTRY (,     BOOL)   ࠗHANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved.

:

 HANDLE hModule  ()  dll;

 DWORD ul_reason_for_call , ,    .   :

 DLL_PROCESS_ATTACH  DLL_THREAD_ATTACH    ;

 DLL_PROCESS_DETACH  DLL_THREAD_DETACH    .

 LPVOID lpReserved  .

 DllMain()  ,      .           .

   dll    : bool IsDriverPresent(void).   ,           .      true,   堗 false.

int ReadMem(char data, int len)     . Char* data   , int len  32-   .     .

int WriteMem(char *data, int len)  ;    .

int GetMemSize(void)     .  ,    ,        : 



 ,           ,  ,   : 



         EXPORT.     dll-,         : 











     . 






























































































































































































 ,          .         .  dll           ,     ,     ,      .



2.5  dll-  .

 ,     dll-    ,     ,   .       dll-. ,       Visual C++.  ,        Visual Basic, Delphi  Cuilder,      ,         .   ,    ,   -  ,        .

       .       HMODULE LoadLibrary(char* LibraryName),  LibraryName     dll-.  堗  () .    NULL,      .

       .        



 hModule  ,  LoadLibrary;

 ProcName     .  GetProcAdress        NULL,      .

        ,   ,        .  ,      ,  ,    . ,              .             ,         .

  ,   dll-        ࠗ __declspec(dllimport).         #define. 



     ,     : ,   ,  .       typedef: 





















       : 









  ,  dll-  .    dll-        .   true     false  . .. VC++ - ,          (  堗  ). 













































































  ConnectToDriver()     .      ,     .          .







































,        :

























       :

















,    ,   , ,    .









    ,    .     .





























,     dll-  . ,   ,     .           dll     .     .    ,      .  젗  . ,    ,   ,  .          1024   .

,      .            WDM  Windows  DriverStudio.



2.6  

     ,      . ..           ,          .

, ,     Linux,       :      -   ,     gdb.                  .        printk,         .

 ,    Windows  .  ,     ,        . ,       ,         : WinDbg (   DDK)  SoftIce (   NuMega DriverStudio). SoftIce       Windows  .  ,       . SoftIce     :      ,       ..  ,   SoftIce    .

   Win98, SoftIce   Autoexec.bat  : c:\Progra~1\numega\driver~1\softice\winice

.. SoftIce    DOS    Windows.   Windows SoftIce    -      ,    .   SoftIce ,  Ctrl+D.     .

  SoftIce ,    ;      .

 SoftIce    .      ,             .     ,      .

    SoftIce   . SoftIce    ,         . SoftIce     .      help. ,   ࠗ     SoftIce.      F5     (   ).

   ,         ,       .  ,     ,     .   ,     -     ,     ,       .        .

, ,     ,  .          (breakpoint),   .  , SoftIce   .

      INT 3.     MS-DOS,  Windows INT 3    .     ,    breakpoint,    : 







     INT 3.

   SoftIce    INT 3.  ,      ,   SoftIce   :



   INT 3  <>    .      INT 3    SET I3HERE OFF.

 ,    <>  SoftIce,        :



      ;



    ();



 ;



   ;



 ;



   (  SoftIce).

      ,       ,   ++.

SoftIce      .  ,  /    (Watch),    WW   Alt+F4. /         WATCH.

  ,       SoftIce.   ,                   .


,      .     , ,   -   .

 : mailto:tarvo@cs.stu.cn.ua

    : http://cs.stu.cn.ua/~tarvo

 젗  .





