home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / APR94_2.ZIP / LISTDVCB / VMCBSPY.C < prev    next >
C/C++ Source or Header  |  1994-03-01  |  2KB  |  82 lines

  1. /*
  2. VMCBSPY.C
  3. From Dr. Dobbs Journal, April 1994
  4. Klaus Mueller 1994, All Rights Reserved.
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <dos.h>
  10. #include <alloc.h>
  11. #include <listdvcb.h>
  12.  
  13.  
  14.  
  15. VMCB_Hook_Struc far *VMCB_Buf;
  16.  
  17. long int i, VMCB_Buf_Size;
  18.  
  19. /* Get entry point for the VxD API using Int 2Fh AX=1684h */
  20. typedef void (far *api_entry)(void);
  21.  
  22. api_entry get_vxd_api(int vxd_id)
  23. {   
  24.     asm {
  25.             push es
  26.             push di
  27.             mov ax,1684h
  28.             mov bx,vxd_id
  29.             mov di,0
  30.             mov es,di
  31.             int 2fh
  32.             mov ax,di
  33.             mov dx,es
  34.             pop di
  35.             pop es
  36.         }
  37. }
  38.  
  39. void main(int argc, char *argv[])
  40. {
  41.   static api_entry api = NULL;
  42.   api = get_vxd_api(ListDVCB_ID);
  43.   if (api == 0)
  44.     {
  45.         printf("Error: ListDVCB.386 not loaded.");
  46.         exit(1);
  47.     }   
  48.   asm { mov bx,offset VMCB_Buf_Size
  49.         mov ax,Hook_Buf_Size        /* Determine size of VMCB buffer */                         
  50.       }
  51.   (*api)();                         /* Call V86API of ListInst.386 */
  52.   if ( (VMCB_Buf=malloc(VMCB_Buf_Size)) == 0)           
  53.    {
  54.     printf("Memory allocation error");
  55.     exit (1);
  56.    };   
  57.  
  58.  
  59.   printf("\nVMCBSPY - Dumps the VxD specific data in the Virtual");
  60.   printf(" Machine Control Block.\n");
  61.   printf("Copyright Klaus Mueller 1994, All Rights Reserved.\n");
  62.   printf("\nCalling ListDVCB.386 ... \n");
  63.  
  64.   asm { mov dx,offset VMCB_Buf
  65.         mov ax,Copy_Hook_Data           /* Request VMCB map */                      
  66.       }
  67.   (*api)();                             /* Call V86API of ListDVCB.386 */
  68.   asm jnc cbok
  69.   printf("Error: Cannot create VMCB map."); 
  70.   exit(1);
  71.  
  72. cbok:                                       /* Print received VxD data */
  73.   printf("\nV86 API from ListDVCB.386: Result of _Allocate_Device_CB_Area");
  74.   printf(" Hook.\n");
  75.   printf("\nName of VxD\t\t\t\tOffset in VMCB\t\tSize\n");
  76.    
  77.   for ( i=0; i < VMCB_Buf_Size/sizeof(VMCB_Hook_Struc); i++)     
  78.         printf("\n%s\t0x%08lX\t\t0x%08lX", &VMCB_Buf[i].caller_string, \
  79.         VMCB_Buf[i].VMCB_Hook.VMCB_Offset, VMCB_Buf[i].VMCB_Hook.VMCB_Len);
  80.  
  81. }   
  82.