home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / mag&info / msjv7_6.zip / VXD.ARJ / FIND_API.C < prev    next >
C/C++ Source or Header  |  1992-10-01  |  4KB  |  140 lines

  1. /* 
  2. FIND_API.C
  3. from Microsoft Systems Journal, October 1992
  4. Copyright (c) 1992 Andrew Schulman.  All rights reserved.
  5.  
  6. Locate V86 and PM VxD API entry points in Windows.
  7. Built with DPMISHEL.C
  8. Runs first in V86 mode, then in protected mode
  9. Runs same code (find_api_loop) in each mode
  10. */
  11.  
  12. #include <stdlib.h>
  13. #include <stdio.h>
  14. #include <dos.h>
  15.  
  16. #define LOBYTE(w)           ((unsigned char)(w))
  17. #define HIBYTE(w)           ((unsigned char)((unsigned short)(w) >> 8))
  18.  
  19. // database of VxD ID's and names we know about
  20. typedef struct {
  21.     unsigned short id;
  22.     char *name;
  23.     } VXDNAME;
  24. VXDNAME vxdname[] = {
  25.     0x0001, "VMM -- Virtual Machine Manager",
  26.     0x0002, "Debug -- Win386 Debug Device",
  27.     0x0003, "VPICD -- Virtual Programmable Interrupt Controller "
  28.                 "(PIC) Device",
  29.     0x0004, "VDMAD -- Virtual Direct Memory Access (DMA) Device",
  30.     0x0005, "VTD -- Virtual Timer Device",
  31.     0x0006, "V86MMGR -- Virtual-8086 Mode Memory Manager Device",
  32.     0x0007, "PageSwap -- Demand Paging Swap Device Services",
  33.     0x0008, "Parity",
  34.     0x0009, "Reboot",
  35.     0x000A, "VDD -- Virtual Display Device",
  36.     0x000B, "VSD -- Virtual Sound Device",
  37.     0x000C, "VMD -- Virtual Mouse Device",
  38.     0x000D, "VKD -- Virtual Keyboard Device",
  39.     0x000E, "VCD -- Virtual COMM Device",
  40.     0x000F, "VPD -- Virtual Printer Device",
  41.     0x0010, "BlockDev -- formerly Virtual Hard Disk Device (VHD)",
  42.     0x0011, "VMCPD -- Virtual Math Coprocessor (MCP) Device",
  43.     0x0012, "EBIOS",
  44.     0x0013, "BIOSXlat -- BIOS Protected-Mode Translation",
  45.     0x0014, "VNETBIOS -- Virtual NetBIOS Device",
  46.     0x0015, "DOSMGR -- Virtual MS-DOS Manager",
  47.     0x0016, "WINLOAD",
  48.     0x0017, "SHELL",
  49.     0x0018, "VMPoll",
  50.     0x0019, "VPROD",
  51.     0x001A, "DOSNET",
  52.     0x001B, "VFD -- Virtual Floppy Device",
  53.     0x001C, "LoadHi -- Global EMM Import",
  54.     0x001D, "WINDEBUG",
  55.     0x001E, "TSRLoad -- TSR instance utility",
  56.     0x001F, "BIOSHook -- BIOS Interrupt Hooker VxD",
  57.     0x0020, "INT13 -- Virtual INT 13h (BIOS Disk) Device",
  58.     0x0021, "PageFile -- Demand Paging Swap Device Services",
  59.     0x0022, "SCSI",
  60.     0x0023, "MCA_POS -- Microchannel Architecture Programmable "
  61.                 "Option Select",
  62.     0x0024, "SCSIFD -- SCSI FastDisk",
  63.     0x0025, "VPEND -- Virtual Pen Device",
  64.     0x0026, "APM -- Advanced Power Management",
  65.     0x0200, "Novell IPX",
  66.     0x0202, "Win386 Soft-ICE/W Debugger",
  67.     0x0442, "VTDAPI",
  68.     0x0445, "VSBD -- Virtual SoundBlaster Device",
  69.     0x1020, "VCV -- Microsoft C/C++ 7.0 CodeView",
  70.     0x28C0, "VXD.386 -- Generic Virtual Device Driver",
  71.     0x28C1, "PUSHKEYS -- VKD_Force_Keys Device",
  72.     0x28C2, "VCR3D -- Virtual CR3 Device",
  73.     0,      "",
  74.     } ;
  75.  
  76. typedef void (far *FUNCPTR)(void);
  77.  
  78. // call the Windows "Get Device Entry Point Address" function
  79. // Interrupt 2Fh Function 1684h
  80. FUNCPTR GetDeviceAPI(unsigned short vxd_id)
  81. {
  82.     _asm    push    di
  83.     _asm    push    es
  84.     _asm    mov     ax, 0x1684
  85.     _asm    mov     bx, vxd_id
  86.     _asm    xor     di, di
  87.     _asm    mov     es, di
  88.     _asm    int     0x2f
  89.     _asm    mov     ax, di
  90.     _asm    mov     dx, es
  91.     _asm    pop     es
  92.     _asm    pop     di
  93.     // return value in DX:AX
  94. }
  95.  
  96. find_api_loop()
  97. {
  98.     unsigned i;
  99.     FUNCPTR fp;
  100.     VXDNAME *pname;
  101.     char *name;
  102.     
  103.     // for each possible device id, see if there's an API
  104.     for (i=0; i<0xffff; i++)
  105.         if (fp = GetDeviceAPI(i))
  106.         {
  107.             // see if we know this device's name
  108.             for (name="??", pname=vxdname; pname->id != 0; pname++)
  109.                 if (i == pname->id)
  110.                 {
  111.                     name = pname->name;
  112.                     break;
  113.                 }
  114.                 
  115.             // print the device number, name, and entry point
  116.             printf("Device %04Xh (%s) @ %Fp\n", 
  117.                 i, name, fp);
  118.         }
  119. }
  120.  
  121. v86_main()
  122. {
  123.     fputs("Find Windows VxD APIs version 1.00\n", stderr);
  124.     fputs("Copyright (c) 1992 Andrew Schulman.  All rights reserved.\n\n",
  125.         stderr);
  126.     
  127.     puts("Virtual-8086 (V86) VxD APIs:");
  128.     find_api_loop();
  129.     return 0;
  130. }
  131.  
  132. pmode_main()
  133. {
  134.     puts("\nProtected-mode VxD APIs:");
  135.     find_api_loop();
  136.     
  137.     return 0;
  138. }
  139.  
  140.