home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / mag&info / msjv7_4.zip / NETBIOS2.ARJ / POST.ASM < prev    next >
Assembly Source File  |  1992-07-01  |  5KB  |  180 lines

  1. ;==========================================================================
  2. ; PROGRAM: post.asm
  3. ;
  4. ; PURPOSE: Provide a fixed-in-memory NetBIOS post processing routine
  5. ;          as well as a NCB submitting routine.
  6. ;
  7. ; FUNCTIONS:
  8. ;           NetBiosRequest - Allows submitting a NCB
  9. ;           PrivPostRoutine- Post processing routine
  10. ; HISTORY:
  11. ;           January, 1992       Ray Patch       Created
  12. ;==========================================================================
  13.  
  14. ;==============================================================================
  15. ;    SEGMENT DEFINTIONS
  16. ;==============================================================================
  17.  
  18. _TEXT    SEGMENT  WORD PUBLIC 'CODE'
  19. _TEXT    ENDS
  20.  
  21. _DATA    SEGMENT  WORD PUBLIC 'DATA'
  22. _DATA    ENDS
  23.  
  24. CONST    SEGMENT  WORD PUBLIC 'CONST'
  25. CONST    ENDS
  26.  
  27. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  28. _BSS    ENDS
  29.  
  30. DGROUP    GROUP    CONST, _BSS, _DATA
  31.     ASSUME    DS: DGROUP
  32.     ASSUME  SS: NOTHING
  33.  
  34.  
  35. .286        ; 80286 and above ONLY.
  36.  
  37. EXTRN _NcbTablePtr: DWORD
  38. EXTRN _TableEntriesUsed: WORD
  39. EXTRN  PostMessage:FAR
  40. EXTRN NETBIOSCALL: FAR
  41.  
  42. DEFAULT_MAX_NCBS    EQU 12
  43.             
  44. ENTRY struc
  45.     pNcbOff         dw  ?
  46.     pNcbSeg         dw  ?
  47.     hWnd            dw  ?
  48.     iMessage        dw    ?
  49. ENTRY ends
  50.  
  51. NCB struc
  52.     ncb_command        db    ?
  53.     ncb_retcode        db    ?
  54.     ncb_lsn         db  ?
  55.     ncb_num         db  ?
  56.     ncb_buffer        dd    ?
  57.     ncb_length        dw    ?
  58.     ncb_callname    db    16 dup(?)
  59.     ncb_name        db    16 dup(?)
  60.     ncb_rto         db  ?
  61.     ncb_sto         db  ?
  62.     ncb_post        dd    ?
  63.     ncb_lana_num    db    ?
  64.     ncb_cmd_cplt    db    ?
  65.     ncb_reserved    db    14 dup(?)
  66. NCB ends
  67.  
  68. _TEXT SEGMENT WORD PUBLIC 'CODE'
  69.     ASSUME CS:_TEXT, DS:DGROUP
  70.  
  71. PUBLIC _PrivPostRoutine
  72. PUBLIC  NetBiosRequest
  73.  
  74. _PrivPostRoutine PROC FAR
  75.     ;;;        ES:BX = NCB address.
  76.  
  77.     push    ds
  78.     push    ax
  79.     push    cx
  80.     push    si
  81.  
  82.     mov        ax, DGROUP
  83.     mov        ds, ax
  84.     push    ax                    ; save DS
  85.  
  86.     ;;;        set DS:SI equal to the NCB table.
  87.     ;;;        set CX equal to the table size.
  88.  
  89.     lds        si, DWORD PTR [_NcbTablePtr]
  90.     mov        cx, DEFAULT_MAX_NCBS
  91.     ;======================================================================
  92.     ;    main search loop.
  93.     ;======================================================================
  94.  
  95. _PrivPostRoutine_Loop:
  96.     ;;;        Check the NCB offsets first.
  97.  
  98.     cmp        bx, WORD PTR [si].pNcbOff        ; bx = offset of NCB received.
  99.     jne     _PrivPostRoutine_NextEntry
  100.  
  101.     ;;;        Now check the segments
  102.  
  103.     mov        ax, es                ; ax = segment of NCB received.
  104.     cmp        ax, WORD PTR [si].pNcbSeg
  105.     je        _PrivPostRoutine_PostMessage
  106.         
  107. _PrivPostRoutine_NextEntry:
  108.     ;;;        move pointer to next entry in the NCB table and continue if CX is not zero.
  109.  
  110.     add        si, SIZE ENTRY
  111.     loop    _PrivPostRoutine_loop
  112.  
  113.     pop     ds                      ; DS = DGROUP
  114.     jmp   short  _Not_In_Table
  115.  
  116.     ;======================================================================
  117.     ;    PostMessage(hWnd, iMessage, ncb_command, pNcb);
  118.     ;======================================================================
  119.  
  120. _PrivPostRoutine_PostMessage:
  121.  
  122.     mov        al, BYTE PTR es:[bx].ncb_command    ; AL = NCB command.
  123.     sub     ah, ah                              ; AX = NCB command.
  124.     
  125.     push    [si].hWnd                ; push window handle
  126.     push    [si].iMessage            ; push iMessage
  127.     push    ax                      ; push command code
  128.     push    [si].pNcbSeg            ; push NCB pointer
  129.     push    [si].pNcbOff
  130.     call    FAR PTR PostMessage
  131.  
  132.     ;;;        Now clear the NCB pointer field of the table to 0.
  133.  
  134.     xor        ax, ax
  135.     mov        [si].pNcbSeg, ax            ; Mark this entry in the table
  136.     mov        [si].pNcbOff, ax            ; as free.
  137.  
  138.     pop     ds                          ; DS = DGROUP
  139.     dec        _TableEntriesUsed            ; --TableEntriesUsed;
  140.  
  141. _Not_In_Table:
  142.     ;;;        Restore the registers and exit.
  143.  
  144.  
  145.     pop        si
  146.     pop        cx
  147.     pop        ax
  148.     pop        ds
  149.  
  150.     iret                    ; return to NetBIOS.
  151. _PrivPostRoutine ENDP
  152.  
  153. ;==========================================================================
  154. ; WORD _far _Pascal NetBiosRequest(PNCB pNcb);
  155. ;==========================================================================
  156.  
  157. NetBiosRequest PROC FAR
  158.     enter   0, 0
  159.     push    di
  160.     push    si
  161.  
  162.     les     bx, DWORD PTR [bp+6]
  163.     call    FAR PTR NETBIOSCALL
  164.     sub     ah, ah
  165.  
  166.     ;;;        AX = the NetBIOS return code.
  167.     xor     ah, ah
  168.     mov     al, BYTE PTR es:[bx+1] ; return the NCB return code
  169.  
  170.     pop si
  171.     pop di
  172.  
  173.     leave
  174.     ret
  175.  
  176. NetBiosRequest ENDP
  177.  
  178. _TEXT ENDS
  179.      END
  180.