home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Dev32 / lxrmcall.asm < prev    next >
Assembly Source File  |  2002-04-26  |  37KB  |  1,327 lines

  1. ; $Id: lxrmcall.asm,v 1.2 2002/04/26 23:08:56 smilcke Exp $
  2.  
  3. ;
  4. ; lxrmcall.asm
  5. ; Autor:               Stefan Milcke
  6. ; Erstellt am:         02.03.2002
  7. ; Letzte Aenderung am: 29.03.2002
  8. ;
  9.        .386p
  10.        include seg32.inc
  11.        include rm.inc
  12.  
  13. ;************************
  14. ; Common variables for RM
  15. ;************************
  16. DATA16 segment
  17.        extrn   DeviceHelp : DWORD
  18.        public  _RM_Help0
  19.        public  _RM_Help1
  20.        public  _RM_Help3
  21.        public  _RMFlags
  22.        public  _RMIDCTable
  23.        public  _RMNAME
  24.        public  rm_hDriver
  25.        public  rm_hAdapter
  26.        public  rm_hDevice
  27.        public  rm_hResource
  28.        public  rm_tmpStr1
  29.        public  rm_tmpStr2
  30.        public  rm_tmpStr3
  31.        public  rm_DriverStruct
  32.        public  rm_AdapterStruct
  33.        public  rm_DeviceStruct
  34. _RM_Help0      DWORD 0
  35. _RM_Help1      DWORD 0
  36. _RM_Help3      DWORD 0
  37. _RMFlags       DWORD 0
  38. _RMIDCTable    BYTE[12] dup (0)
  39. _RMNAME        BYTE "RESMGR$ ",0
  40. rm_hDriver     dword   0
  41. rm_hAdapter    dword   0
  42. rm_hDevice     dword   0
  43. rm_hResource   dword   0
  44. rm_ModifyAction dword  0
  45. rm_tmpStr1     BYTE[255] dup (0)
  46. rm_ResourceList label byte
  47. rm_tmpStr2     BYTE[255] dup (0)
  48. rm_tmpStr3     BYTE[255] dup (0)
  49. rm_DriverStruct RM_DRIVERSTRUCT <DATA16:rm_tmpStr1,DATA16:rm_tmpStr2,DATA16:rm_tmpStr3>
  50. rm_AdapterStruct RM_ADAPTERSTRUCT <DATA16:rm_tmpStr1>
  51. rm_DeviceStruct RM_DEVICESTRUCT <DATA16:rm_tmpStr1>
  52. rm_ResourceStruct DWORD 0      ; Resource type
  53.                BYTE    12 DUP (0)
  54.                DWORD   0       ; Reserved
  55. rm_AdjunctBuffer BYTE 1024 DUP (0)
  56. DATA16 ends
  57.  
  58. ;***********************
  59. ; Common routines for RM
  60. ;***********************
  61. CODE16 segment
  62.        assume cs:CODE16,ds:DATA16
  63.        public  RM_ATTACHDD
  64.        public  _GetCS
  65.        public  _CallRM
  66.        public  __GetAdjList
  67. RM_ATTACHDD    proc near
  68.        push    bp
  69.        mov     bp,sp
  70.        push    di
  71.        mov     bx,08h[bp]
  72.        mov     di,06h[bp]
  73.        mov     dl,2ah
  74.        call    dword ptr ds:(offset DeviceHelp)
  75.        jb      short @RMATT1
  76.        sub     ax,ax
  77.        pop     di
  78.        leave
  79.        retf    4
  80.        ALIGN   2
  81. @RMATT1:
  82.        leave
  83.        ret
  84.        pop     di
  85.        leave
  86.        retf    4
  87. RM_ATTACHDD    endp
  88.  
  89. _GetCS proc    near
  90.        enter   2,0
  91.        push    cs
  92.        pop     word ptr -02h[bp]
  93.        mov     ax,-02h[bp]
  94.        leave
  95.        ret
  96. _GetCS endp
  97.  
  98. _CallRM        proc near
  99.        enter   2,0
  100.        call    _GetCS
  101.        test    al,03h
  102.        je      short @CALLRM1
  103.        push    word ptr 0ah[bp]
  104.        push    word ptr 08h[bp]
  105.        push    word ptr 06h[bp]
  106.        call    dword ptr ds:(offset _RM_Help3)
  107.        add     sp,6
  108.        leave
  109.        retf
  110.        ALIGN   2
  111. @CALLRM1:
  112.        push    word ptr 06h[bp]
  113.        call    dword ptr ds:(offset _RM_Help0)
  114.        leave
  115.        retf
  116. _CallRM        endp
  117.  
  118. ;******************************************************************************
  119. ; __GetAdjList
  120. ; Get pointer to adjunct list in ax:si
  121. ;******************************************************************************
  122. __GetAdjList proc near
  123.        mov     si,offset rm_AdjunctBuffer
  124. @@:    mov     ax,ds:[si]
  125.        or      ax,ds:[si+2]
  126.        je      @F
  127.        mov     ax,ds:[si+4]
  128.        add     ax,si
  129.        mov     ds:[si],ax
  130.        mov     ds:[si+2],ds
  131.        mov     si,ax
  132.        jmp     short @B
  133. @@:    mov     si,offset rm_AdjunctBuffer
  134.        cmp     word ptr ds:[si+4],0
  135.        je      @F
  136.        mov     ax,ds
  137.        ret
  138. @@:    mov     ax,0
  139.        mov     si,0
  140.        ret
  141. __GetAdjList endp
  142.  
  143. CODE16 ends
  144.  
  145. CODE32 segment
  146.        assume  cs:FLAT, ds:FLAT, es:FLAT
  147.        public  __scpy32
  148.        public  __CpyAdjToBuffer
  149. IFDEF KEE
  150.     extrn  KernThunkStackTo16 : near
  151.     extrn  KernThunkStackTo32 : near
  152. ENDIF
  153. ;******************************************************************************
  154. ; __scpy32
  155. ; Copy string esi->edi
  156. ;******************************************************************************
  157. __scpy32 proc    near
  158.        push    ecx
  159.        push    edi         ; Search
  160.        mov     edi,esi     ; for
  161.        sub     ecx,ecx     ; end
  162.        dec     ecx         ; of
  163.        xor     eax,eax     ; string
  164.        repne   scasb
  165.        not     ecx
  166.        pop     edi
  167.        repne   movsb       ; copy string
  168.        pop     ecx
  169.        ret
  170. __scpy32 endp
  171.  
  172. ;******************************************************************************
  173. ; __CpyAdjToBuffer
  174. ;   Copy Adjunct to buffer
  175. ;******************************************************************************
  176. __CpyAdjToBuffer proc near
  177.        ; EAX -> pointer to first adjunct
  178.        cmp     eax,0
  179.        jne     @F
  180.        mov     dword ptr rm_AdjunctBuffer,0
  181.        ret
  182. @@:    push    ecx
  183.        push    edi
  184.        push    esi
  185.        xor     ecx,ecx
  186.        mov     edi,offset rm_AdjunctBuffer
  187. @@:    mov     esi,eax
  188.        mov     eax,[esi].rm_ADJ_pNextAdj                     ; pNextAdj
  189.        mov     cx,[esi].rm_ADJ_AdjLength                     ; AdjLength
  190.        repne   movsb
  191.        cmp     eax,0
  192.        jne     @B
  193.        pop     esi
  194.        pop     edi
  195.        pop     ecx
  196.        ret
  197. __CpyAdjToBuffer endp
  198. CODE32 ends
  199.  
  200. ;******************************************************************************
  201. ; RMCreateDriver
  202. ;******************************************************************************
  203. CODE16 segment
  204.        assume cs:CODE16,ds:DATA16
  205.        public  _RMCreateDriver
  206.        public  th3216_rmcreatedriver
  207.        ALIGN   2
  208. _RMCreateDriver proc near
  209.        enter   4,0
  210.        test    byte ptr ds:(offset _RMFlags),1
  211.        je      short @RMCDRVR4
  212. @RMCDRVR3:
  213.        lea     ax,06h[bp]
  214.        push    ss
  215.        push    ax
  216.        push    02h
  217.        push    cs
  218.        call    _CallRM
  219.        add     sp,06h
  220.        leave
  221.        retf
  222.        ALIGN   2
  223. @RMCDRVR4:
  224.        test    byte ptr ds:(offset _RMFlags),2
  225.        je      short @RMCDRVR6
  226. @RMCDRVR5:
  227.        les     bx,0ah[bp]
  228.        mov     word ptr es:[bx],0ffffh
  229.        mov     word ptr es:02h[bx],0ffffh
  230.        sub     ax,ax
  231.        leave
  232.        retf
  233.        ALIGN   2
  234. @RMCDRVR6:
  235.        mov     ax,word ptr (offset DeviceHelp + 02h)
  236.        or      ax,word ptr (offset DeviceHelp)
  237.        jne     short @RMCDRVR7
  238.        mov     ax,8
  239.        leave
  240.        retf
  241.        ALIGN   2
  242. @RMCDRVR7:
  243.        push    (offset _RMNAME)
  244.        push    (offset _RMIDCTable)
  245.        push    cs
  246.        call    RM_ATTACHDD
  247.        or      ax,ax
  248.        je      short @RMCDRVR8
  249.        or      byte ptr ds:(offset _RMFlags),2
  250.        jmp     @RMCDRVR5
  251.        ALIGN   2
  252. @RMCDRVR8:
  253.        mov     ax,word ptr ds:(offset _RMIDCTable +04h)
  254.        mov     word ptr ds:(offset _RM_Help3 +02h),ax
  255.        mov     word ptr ds:(offset _RM_Help3),0
  256.        mov     ax,word ptr ds:(offset _RMIDCTable +02h)
  257.        mov     word ptr ds:(offset _RM_Help0 +02h),ax
  258.        mov     ax,word ptr ds:(offset _RMIDCTable +06h)
  259.        mov     word ptr ds:(offset _RM_Help0),ax
  260.        or      byte ptr ds:(offset _RMFlags),05h
  261.        jmp     short @RMCDRVR3
  262. _RMCreateDriver endp
  263. th3216_rmcreatedriver:
  264.        push    ds
  265.        push    es
  266.        push    DATA16
  267.        push    DATA16
  268.        pop     es
  269.        pop     ds
  270.  
  271.        push    ds
  272.        push    (offset rm_hDriver)
  273.        push    ds
  274.        push    (offset rm_DriverStruct)
  275.        call    far ptr _RMCreateDriver
  276.        add     sp,8
  277.        pop     es
  278.        pop     ds
  279.        jmp     far ptr FLAT:th1632_rmcreatedriver
  280. CODE16 ends
  281.  
  282. CODE32 segment
  283.        assume  cs:FLAT, ds:FLAT, es:FLAT
  284.        extrn   DevHlp : near
  285.        public  _RM32CreateDriver
  286.        public  th1632_rmcreatedriver
  287. _RM32CreateDriver      proc near
  288.        push    ebp
  289.        mov     ebp,esp
  290.        push    ebx
  291.        push    ecx
  292.        push    edx
  293.        push    esi
  294.        push    edi
  295.        ; 08h[ebp] ->    DRIVERSTRUCT*
  296.        ; 0ch[ebp] ->    HDRIVER*
  297.  
  298.        mov     esi,08h[ebp]
  299.        add     esi,12
  300.        mov     edi,(OFFSET rm_DriverStruct + 12)
  301.        mov     ecx,16 ; (24 Complete !!!)
  302.        cld
  303.        rep     movsb
  304.        mov     edx,08[ebp]
  305.        mov     esi,[edx]
  306.        mov     edi,offset rm_tmpStr1
  307.        call    __scpy32
  308.        add     edx,4
  309.        mov     esi,[edx]
  310.        mov     edi,offset rm_tmpStr2
  311.        call    __scpy32
  312.        add     edx,4
  313.        mov     esi,[edx]
  314.        mov     edi,offset rm_tmpStr3
  315.        call    __scpy32
  316. IFDEF  KEE
  317.        call    KernThunkStackTo16
  318. ENDIF
  319.        xor     eax,eax
  320.        jmp     far ptr CODE16:th3216_rmcreatedriver
  321. th1632_rmcreatedriver:
  322. IFDEF  KEE
  323.        push    eax
  324.        call    KernThunkStackTo32
  325.        pop     eax
  326. ENDIF
  327.        cmp     ax,0
  328.        jne     short @RM32CDRI_01
  329.        mov     ebx,dword ptr DATA16:(OFFSET rm_hDriver)
  330.        mov     edx,0ch[ebp]
  331.        mov     [edx],ebx
  332.        xor     eax,eax
  333. @RM32CDRI_01:
  334.        pop     edi
  335.        pop     esi
  336.        pop     edx
  337.        pop     ecx
  338.        pop     ebx
  339.        pop     ebp
  340.        ret
  341. _RM32CreateDriver      endp
  342. CODE32 ends
  343.  
  344. ;******************************************************************************
  345. ; RMDestroyDriver
  346. ;******************************************************************************
  347. CODE16 segment
  348.        assume  cs:CODE16,ds:DATA16
  349.        public  _RMDestroyDriver
  350.        public  th3216_rmdestroydriver
  351.        ALIGN   2
  352. _RMDestroyDriver proc near
  353.        push    bp
  354.        mov     bp,sp
  355.        test    byte ptr ds:(offset _RMFlags),1
  356.        je      @RMDDRVR1
  357.        lea     ax,06[bp]
  358.        push    ss
  359.        push    ax
  360.        push    03h
  361.        push    cs
  362.        call    _CallRM
  363.        mov     sp,bp
  364.        leave
  365.        retf
  366.        ALIGN   2
  367. @RMDDRVR1:
  368.        test    byte ptr ds:(offset _RMFlags),2
  369.        je      @RMDDRVR2
  370.        sub     ax,ax
  371.        leave
  372.        retf
  373.        nop
  374. @RMDDRVR2:
  375.        mov     ax,1
  376.        leave
  377.        retf
  378. _RMDestroyDriver endp
  379. th3216_rmdestroydriver:
  380.        push    ds
  381.        push    es
  382.        push    DATA16
  383.        push    DATA16
  384.        pop     es
  385.        pop     ds
  386.  
  387.        push    dword ptr (rm_hDriver)
  388.        call    far ptr _RMDestroyDriver
  389.        add     sp,4
  390.        pop     es
  391.        pop     ds
  392.        jmp     far ptr FLAT:th1632_rmdestroydriver
  393. CODE16 ends
  394.  
  395. CODE32 segment
  396.        assume  cs:FLAT, ds:FLAT, es:FLAT
  397.        public  _RM32DestroyDriver
  398.        public  th1632_rmdestroydriver
  399. _RM32DestroyDriver proc near
  400.        push    ebp
  401.        mov     ebp,esp
  402.        push    ebx
  403.        push    ecx
  404.        push    edx
  405.        push    esi
  406.        push    edi
  407.        ; 08h[ebp] ->    HDRIVER
  408.        mov     eax,08[ebp]
  409.        mov     dword ptr DATA16:(OFFSET rm_hDriver),eax
  410. IFDEF  KEE
  411.        call    KernThunkStackTo16
  412. ENDIF
  413.        xor     eax,eax
  414.        jmp     far ptr CODE16:th3216_rmdestroydriver
  415. th1632_rmdestroydriver:
  416. IFDEF  KEE
  417.        push    eax
  418.        call    KernThunkStackTo32
  419.        pop     eax
  420. ENDIF
  421.        cmp     ax,0
  422.        jne     short @RM32DDRI_01
  423.        mov     eax,eax
  424. @RM32DDRI_01:
  425.        pop     edi
  426.        pop     esi
  427.        pop     edx
  428.        pop     ecx
  429.        pop     ebx
  430.        pop     ebp
  431.        ret
  432. _RM32DestroyDriver endp
  433. CODE32 ends
  434.  
  435. ;******************************************************************************
  436. ; RMCreateAdapter
  437. ;******************************************************************************
  438. CODE16 segment
  439.        assume cs:CODE16,ds:DATA16
  440.        public  _RMCreateAdapter
  441.        public  th3216_rmcreateadapter
  442.        ALIGN   2
  443. _RMCreateAdapter proc near
  444.        push    bp
  445.        mov     bp,sp
  446.        test    byte ptr ds:(offset _RMFlags),1
  447.        je      short @RMCADPT1
  448.        lea     ax,06h[bp]
  449.        push    ss
  450.        push    ax
  451.        push    04h
  452.        push    cs
  453.        call    _CallRM
  454.        mov     sp,bp
  455.        leave
  456.        retf
  457.        ALIGN   2
  458. @RMCADPT1:
  459.        test    byte ptr ds:(offset _RMFlags),2
  460.        je      short @RMCADPT2
  461.        les     bx,0ah[bp]
  462.        mov     word ptr es:[bx],0ffffh
  463.        mov     word ptr es:02h[bx],0ffffh
  464.        sub     ax,ax
  465.        leave
  466.        retf
  467.        ALIGN   2
  468. @RMCADPT2:
  469.        mov     ax,1
  470.        leave
  471.        retf
  472. _RMCreateAdapter endp
  473. th3216_rmcreateadapter:
  474.        push    ds
  475.        push    es
  476.        push    DATA16
  477.        push    DATA16
  478.        pop     es
  479.        pop     ds
  480.  
  481.        call    __GetAdjList
  482.        mov     word ptr (rm_AdapterStruct.rm_AD_pAdjunctList),si
  483.        mov     word ptr (rm_AdapterStruct.rm_AD_pAdjunctList+2),ax
  484.  
  485.        mov     ax,0
  486.        mov     bx,0
  487.        cmp     dword ptr (rm_ResourceList),0
  488.        je      @F
  489.        mov     ax,DATA16
  490.        mov     bx,offset rm_ResourceList
  491. @@:    push    ax
  492.        push    bx
  493.        push    dword ptr (rm_hDevice)
  494.        push    ds
  495.        push    offset rm_AdapterStruct
  496.        push    ds
  497.        push    offset rm_hAdapter
  498.        push    dword ptr (rm_hDriver)
  499.        call    far ptr _RMCreateAdapter
  500.        add     sp,20
  501.        pop     es
  502.        pop     ds
  503.        jmp     far ptr FLAT:th1632_rmcreateadapter
  504. CODE16 ends
  505.  
  506. CODE32 segment
  507.        assume  cs:FLAT, ds:FLAT, es:FLAT
  508.        public  _RM32CreateAdapter
  509.        public  th1632_rmcreateadapter
  510. _RM32CreateAdapter     proc near
  511.        push    ebp
  512.        mov     ebp,esp
  513.        push    ebx
  514.        push    ecx
  515.        push    edx
  516.        push    esi
  517.        push    edi
  518.        ; 08h[ebp] ->    HDRIVER
  519.        ; 0ch[ebp] ->    HADAPTER*
  520.        ; 10h[ebp] ->    ADAPTERSTRUCT*
  521.        ; 14h[ebp] ->    HDEVICE
  522.        ; 18h[ebp] ->    AHRESOURCE*
  523.        mov     esi,10h[ebp]
  524.        add     esi,04h
  525.        mov     edi,(OFFSET rm_AdapterStruct + 4)
  526.        mov     ecx,20 ; (24 Complete !!)
  527.        cld
  528.        rep     movsb
  529.        mov     edx,10h[ebp]
  530.        mov     esi,[edx]
  531.        mov     edi,offset rm_tmpStr1
  532.        call    __scpy32
  533.        mov     eax,08h[ebp]
  534.        mov     dword ptr DATA16:(OFFSET rm_hDriver),eax
  535.        mov     eax,14h[ebp]
  536.        mov     dword ptr DATA16:(OFFSET rm_hDevice),eax
  537.        mov     esi,18h[ebp]
  538.        mov     dword ptr DATA16:(OFFSET rm_ResourceList),esi
  539.        cmp     esi,0
  540.        je      short @RM32CADAPT_01
  541.        mov     ecx,[esi]
  542.        sub     ecx,4
  543.        mov     edi,offset rm_ResourceList
  544.        repne   movsb
  545. @RM32CADAPT_01:
  546.        mov     eax,10h[ebp]            ; ADAPTERSTRUCT
  547.        mov     eax,[eax].rm_AD_pAdjunctList
  548.        call    __CpyAdjToBuffer        ; Copy adjuncts
  549. IFDEF  KEE
  550.        call    KernThunkStackTo16
  551. ENDIF
  552.        xor     eax,eax
  553.        jmp     far ptr CODE16:th3216_rmcreateadapter
  554. th1632_rmcreateadapter:
  555. IFDEF  KEE
  556.        push    eax
  557.        call    KernThunkStackTo32
  558.        pop     eax
  559. ENDIF
  560.        cmp     ax,0
  561.        jne     short @RM32CADAPT_03
  562.        mov     edx,0ch[ebp]
  563.        mov     ebx,dword ptr DATA16:(OFFSET rm_hAdapter)
  564.        mov     [edx],ebx
  565.        mov     edx,18h[ebp]
  566.        cmp     edx,0
  567.        je      short @RM32CADAPT_02
  568.        mov     ebx,dword ptr DATA16:(OFFSET rm_ResourceList)
  569.        mov     [edx],ebx
  570. @RM32CADAPT_02:
  571.        xor     eax,eax
  572. @RM32CADAPT_03:
  573.        pop     edi
  574.        pop     esi
  575.        pop     edx
  576.        pop     ecx
  577.        pop     ebx
  578.        pop     ebp
  579.        ret
  580. _RM32CreateAdapter     endp
  581. CODE32 ends
  582.  
  583. ;******************************************************************************
  584. ; RMDestroyAdapter
  585. ;******************************************************************************
  586. CODE16 segment
  587.        assume  cs:CODE16,ds:DATA16
  588.        public  _RMDestroyAdapter
  589.        public  th3216_rmdestroyadapter
  590.        ALIGN   2
  591. _RMDestroyAdapter proc near
  592.        push    bp
  593.        mov     bp,sp
  594.        test    byte ptr ds:(offset _RMFlags),1
  595.        je      @RMDADPT1
  596.        lea     ax,06[bp]
  597.        push    ss
  598.        push    ax
  599.        push    05h
  600.        push    cs
  601.        call    _CallRM
  602.        mov     sp,bp
  603.        leave
  604.        retf
  605.        ALIGN   2
  606. @RMDADPT1:
  607.        test    byte ptr ds:(offset _RMFlags),2
  608.        je      @RMDADPT2
  609.        sub     ax,ax
  610.        leave
  611.        retf
  612.        nop
  613. @RMDADPT2:
  614.        mov     ax,1
  615.        leave
  616.        retf
  617. _RMDestroyAdapter endp
  618. th3216_rmdestroyadapter:
  619.        push    ds
  620.        push    es
  621.        push    DATA16
  622.        push    DATA16
  623.        pop     es
  624.        pop     ds
  625.  
  626.        push    dword ptr (rm_hAdapter)
  627.        push    dword ptr (rm_hDriver)
  628.        call    far ptr _RMDestroyAdapter
  629.        add     sp,8
  630.        pop     es
  631.        pop     ds
  632.        jmp     far ptr FLAT:th1632_rmdestroyadapter
  633. CODE16 ends
  634.  
  635. CODE32 segment
  636.        assume  cs:FLAT, ds:FLAT, es:FLAT
  637.        public  _RM32DestroyAdapter
  638.        public  th1632_rmdestroyadapter
  639. _RM32DestroyAdapter proc near
  640.        push    ebp
  641.        mov     ebp,esp
  642.        push    ebx
  643.        push    ecx
  644.        push    edx
  645.        push    esi
  646.        push    edi
  647.        ; 08h[ebp] ->    HDRIVER
  648.        ; 0ch[ebp] ->    HADAPTER
  649.        mov     eax,08h[ebp]
  650.        mov     dword ptr DATA16:(OFFSET rm_hDriver),eax
  651.        mov     eax,0ch[ebp]
  652.        mov     dword ptr DATA16:(OFFSET rm_hAdapter),eax
  653. IFDEF  KEE
  654.        call    KernThunkStackTo16
  655. ENDIF
  656.        xor     eax,eax
  657.        jmp     far ptr CODE16:th3216_rmdestroyadapter
  658. th1632_rmdestroyadapter:
  659. IFDEF  KEE
  660.        push    eax
  661.        call    KernThunkStackTo32
  662.        pop     eax
  663. ENDIF
  664.        cmp     ax,0
  665.        jne     short @RM32DADPT_01
  666.        mov     eax,eax
  667. @RM32DADPT_01:
  668.        pop     edi
  669.        pop     esi
  670.        pop     edx
  671.        pop     ecx
  672.        pop     ebx
  673.        pop     ebp
  674.        ret
  675. _RM32DestroyAdapter endp
  676. CODE32 ends
  677.  
  678. ;******************************************************************************
  679. ; RMCreateDevice
  680. ;******************************************************************************
  681. CODE16 segment
  682.        assume cs:CODE16,ds:DATA16
  683.        public  _RMCreateDevice
  684.        public  th3216_rmcreatedevice
  685.        ALIGN   2
  686. _RMCreateDevice proc near
  687.        push    bp
  688.        mov     bp,sp
  689.        test    byte ptr ds:(offset _RMFlags),1
  690.        je      short @RMCDEV1
  691.        lea     ax,06h[bp]
  692.        push    ss
  693.        push    ax
  694.        push    06h
  695.        push    cs
  696.        call    _CallRM
  697.        mov     sp,bp
  698.        leave
  699.        retf
  700.        ALIGN   2
  701. @RMCDEV1:
  702.        test    byte ptr ds:(offset _RMFlags),2
  703.        je      short @RMCDEV2
  704.        les     bx,0ah[bp]
  705.        mov     word ptr es:[bx],0ffffh
  706.        mov     word ptr es:02h[bx],0ffffh
  707.        sub     ax,ax
  708.        leave
  709.        retf
  710.        ALIGN   2
  711. @RMCDEV2:
  712.        mov     ax,1
  713.        leave
  714.        retf
  715. _RMCreateDevice endp
  716. th3216_rmcreatedevice:
  717.        push    ds
  718.        push    es
  719.        push    DATA16
  720.        push    DATA16
  721.        pop     es
  722.        pop     ds
  723.  
  724.        call    __GetAdjList
  725.        mov     word ptr (rm_DeviceStruct.rm_DE_pAdjunctList),si
  726.        mov     word ptr (rm_DeviceStruct.rm_DE_pAdjunctList+2),ax
  727.  
  728.        mov     ax,0
  729.        mov     bx,0
  730.        cmp     dword ptr (rm_ResourceList),0
  731.        je      @F
  732.        mov     ax,DATA16
  733.        mov     bx,offset rm_ResourceList
  734. @@:    push    ax
  735.        push    bx
  736.        push    dword ptr (rm_hAdapter)
  737.        push    ds
  738.        push    offset rm_DeviceStruct
  739.        push    ds
  740.        push    offset rm_hDevice
  741.        push    dword ptr (rm_hDriver)
  742.        call    far ptr _RMCreateDevice
  743.        add     sp,20
  744.        pop     es
  745.        pop     ds
  746.        jmp     far ptr FLAT:th1632_rmcreatedevice
  747. CODE16 ends
  748.  
  749. CODE32 segment
  750.        assume  cs:FLAT, ds:FLAT, es:FLAT
  751.        public  _RM32CreateDevice
  752.        public  th1632_rmcreatedevice
  753. _RM32CreateDevice     proc near
  754.        push    ebp
  755.        mov     ebp,esp
  756.        push    ebx
  757.        push    ecx
  758.        push    edx
  759.        push    esi
  760.        push    edi
  761.        ; 08h[ebp] ->    HDRIVER
  762.        ; 0ch[ebp] ->    HDEVICE*
  763.        ; 10h[ebp] ->    DEVICESTRUCT*
  764.        ; 14h[ebp] ->    HADAPTER
  765.        ; 18h[ebp] ->    AHRESOURCE*
  766.        mov     esi,10h[ebp]
  767.        add     esi,04h
  768.        mov     edi,(OFFSET rm_DeviceStruct + 4)
  769.        mov     ecx,8 ; (12 Complete !!)
  770.        cld
  771.        rep     movsb
  772.        mov     edx,10h[ebp]
  773.        mov     esi,[edx]
  774.        mov     edi,offset rm_tmpStr1
  775.        call    __scpy32
  776.        mov     eax,08h[ebp]
  777.        mov     dword ptr DATA16:(OFFSET rm_hDriver),eax
  778.        mov     eax,14h[ebp]
  779.        mov     dword ptr DATA16:(OFFSET rm_hAdapter),eax
  780.        mov     esi,18h[ebp]
  781.        mov     dword ptr DATA16:(OFFSET rm_ResourceList),esi
  782.        cmp     esi,0
  783.        je      short @RM32CDEV_01
  784.        mov     ecx,[esi]
  785.        sub     ecx,4
  786.        mov     edi,offset rm_ResourceList
  787.        repne   movsb
  788. @RM32CDEV_01:
  789.        mov     eax,10h[ebp]            ; DEVICESTRUCT
  790.        mov     eax,[eax].rm_DE_pAdjunctList
  791.        call    __CpyAdjToBuffer        ; Copy adjuncts
  792. IFDEF  KEE
  793.        call    KernThunkStackTo16
  794. ENDIF
  795.        xor     eax,eax
  796.        jmp     far ptr CODE16:th3216_rmcreatedevice
  797. th1632_rmcreatedevice:
  798. IFDEF  KEE
  799.        push    eax
  800.        call    KernThunkStackTo32
  801.        pop     eax
  802. ENDIF
  803.        cmp     ax,0
  804.        jne     short @RM32CDEV_03
  805.        mov     edx,0ch[ebp]
  806.        mov     ebx,dword ptr DATA16:(OFFSET rm_hDevice)
  807.        mov     [edx],ebx
  808.        mov     edx,18h[ebp]
  809.        cmp     edx,0
  810.        je      short @RM32CDEV_02
  811.        mov     ebx,dword ptr DATA16:(OFFSET rm_ResourceList)
  812.        mov     [edx],ebx
  813. @RM32CDEV_02:
  814.        xor     eax,eax
  815. @RM32CDEV_03:
  816.        pop     edi
  817.        pop     esi
  818.        pop     edx
  819.        pop     ecx
  820.        pop     ebx
  821.        pop     ebp
  822.        ret
  823. _RM32CreateDevice     endp
  824. CODE32 ends
  825.  
  826. ;******************************************************************************
  827. ; RMDestroyDevice
  828. ;******************************************************************************
  829. CODE16 segment
  830.        assume  cs:CODE16,ds:DATA16
  831.        public  _RMDestroyDevice
  832.        public  th3216_rmdestroydevice
  833.        ALIGN   2
  834. _RMDestroyDevice proc near
  835.        push    bp
  836.        mov     bp,sp
  837.        test    byte ptr ds:(offset _RMFlags),1
  838.        je      @RMDDEV1
  839.        lea     ax,06h[bp]
  840.        push    ss
  841.        push    ax
  842.        push    07h
  843.        push    cs
  844.        call    _CallRM
  845.        mov     sp,bp
  846.        leave
  847.        retf
  848.        ALIGN   2
  849. @RMDDEV1:
  850.        test    byte ptr ds:(offset _RMFlags),2
  851.        je      @RMDDEV2
  852.        sub     ax,ax
  853.        leave
  854.        retf
  855.        nop
  856. @RMDDEV2:
  857.        mov     ax,1
  858.        leave
  859.        retf
  860. _RMDestroyDevice endp
  861. th3216_rmdestroydevice:
  862.        push    ds
  863.        push    es
  864.        push    DATA16
  865.        push    DATA16
  866.        pop     es
  867.        pop     ds
  868.  
  869.        push    dword ptr (rm_hDevice)
  870.        push    dword ptr (rm_hDriver)
  871.        call    far ptr _RMDestroyDevice
  872.        add     sp,8
  873.        pop     es
  874.        pop     ds
  875.        jmp     far ptr FLAT:th1632_rmdestroydevice
  876. CODE16 ends
  877.  
  878. CODE32 segment
  879.        assume  cs:FLAT, ds:FLAT, es:FLAT
  880.        public  _RM32DestroyDevice
  881.        public  th1632_rmdestroydevice
  882. _RM32DestroyDevice proc near
  883.        push    ebp
  884.        mov     ebp,esp
  885.        push    ebx
  886.        push    ecx
  887.        push    edx
  888.        push    esi
  889.        push    edi
  890.        ; 08h[ebp] ->    HDRIVER
  891.        ; 0ch[ebp] ->    HDEVICE
  892.        mov     eax,08h[ebp]
  893.        mov     dword ptr DATA16:(OFFSET rm_hDriver),eax
  894.        mov     eax,0ch[ebp]
  895.        mov     dword ptr DATA16:(OFFSET rm_hDevice),eax
  896. IFDEF  KEE
  897.        call    KernThunkStackTo16
  898. ENDIF
  899.        xor     eax,eax
  900.        jmp     far ptr CODE16:th3216_rmdestroydevice
  901. th1632_rmdestroydevice:
  902. IFDEF  KEE
  903.        push    eax
  904.        call    KernThunkStackTo32
  905.        pop     eax
  906. ENDIF
  907.        cmp     ax,0
  908.        jne     short @RM32DDEV_01
  909.        xor     eax,eax
  910. @RM32DDEV_01:
  911.        pop     edi
  912.        pop     esi
  913.        pop     edx
  914.        pop     ecx
  915.        pop     ebx
  916.        pop     ebp
  917.        ret
  918. _RM32DestroyDevice endp
  919. CODE32 ends
  920.  
  921. ;******************************************************************************
  922. ; RMAllocResource
  923. ;******************************************************************************
  924. CODE16 segment
  925.        assume  cs:CODE16,ds:DATA16
  926.        public  _RMAllocResource
  927.        public  th3216_rmallocresource
  928.        ALIGN   2
  929. _RMAllocResource proc near
  930.        push    bp
  931.        mov     bp,sp
  932.        test    byte ptr ds:(offset _RMFlags),1
  933.        je      @RMARES1
  934.        lea     ax,06h[bp]
  935.        push    ss
  936.        push    ax
  937.        push    08h
  938.        push    cs
  939.        call    _CallRM
  940.        mov     sp,bp
  941.        leave
  942.        retf
  943.        ALIGN   2
  944. @RMARES1:
  945.        test    byte ptr ds:(offset _RMFlags),2
  946.        je      @RMARES2
  947.        les     bx,0ah[bp]
  948.        mov     word ptr es:[bx],0ffffh
  949.        mov     word ptr es:02h[bx],0ffffh
  950.        sub     ax,ax
  951.        leave
  952.        retf
  953.        ALIGN   2
  954. @RMARES2:
  955.        mov     ax,1
  956.        leave
  957.        retf
  958. _RMAllocResource endp
  959. th3216_rmallocresource:
  960.        push    ds
  961.        push    es
  962.        push    DATA16
  963.        push    DATA16
  964.        pop     es
  965.        pop     ds
  966.  
  967.        push    ds
  968.        push    offset rm_ResourceStruct
  969.        push    ds
  970.        push    offset rm_hResource
  971.        push    dword ptr (rm_hDriver)
  972.        call    far ptr _RMAllocResource
  973.        add     sp,12
  974.        pop     es
  975.        pop     ds
  976.        jmp     far ptr FLAT:th1632_rmallocresource
  977. CODE16 ends
  978.  
  979. CODE32 segment
  980.        assume  cs:FLAT, ds:FLAT, es:FLAT
  981.        public  _RM32AllocResource
  982.        public  th1632_rmallocresource
  983. _RM32AllocResource proc near
  984.        push    ebp
  985.        mov     ebp,esp
  986.        push    ebx
  987.        push    ecx
  988.        push    edx
  989.        push    esi
  990.        push    edi
  991.        ; 08h[ebp] ->    HDRIVER
  992.        ; 0ch[ebp] ->    HRESOURCE*
  993.        ; 10h[ebp] ->    RESOURCESTRUCT*
  994.        mov     esi,10h[ebp]
  995.        mov     edi,(OFFSET rm_ResourceStruct)
  996.        mov     ecx,20
  997.        cld
  998.        rep     movsb
  999.        mov     eax,08h[ebp]
  1000.        mov     dword ptr DATA16:(OFFSET rm_hDriver),eax
  1001. IFDEF  KEE
  1002.        call    KernThunkStackTo16
  1003. ENDIF
  1004.        xor     eax,eax
  1005.        jmp     far ptr CODE16:th3216_rmallocresource
  1006. th1632_rmallocresource:
  1007. IFDEF  KEE
  1008.        push    eax
  1009.        call    KernThunkStackTo32
  1010.        pop     eax
  1011. ENDIF
  1012.        cmp     ax,0
  1013.        jne     short @RM32ARES_01
  1014.        mov     edx,0ch[ebp]
  1015.        mov     ebx,dword ptr DATA16:(OFFSET rm_hResource)
  1016.        mov     [edx],ebx
  1017.        xor     eax,eax
  1018. @RM32ARES_01:
  1019.        pop     edi
  1020.        pop     esi
  1021.        pop     edx
  1022.        pop     ecx
  1023.        pop     ebx
  1024.        pop     ebp
  1025.        ret
  1026. _RM32AllocResource endp
  1027. CODE32 ends
  1028.  
  1029. ;******************************************************************************
  1030. ; RMDeallocResource
  1031. ;******************************************************************************
  1032. CODE16 segment
  1033.        assume  cs:CODE16,ds:DATA16
  1034.        public  _RMDeallocResource
  1035.        public  th3216_rmdeallocresource
  1036.        ALIGN   2
  1037. _RMDeallocResource proc near
  1038.        push    bp
  1039.        mov     bp,sp
  1040.        test    byte ptr ds:(offset _RMFlags),1
  1041.        je      @RMDRES1
  1042.        lea     ax,06h[bp]
  1043.        push    ss
  1044.        push    ax
  1045.        push    09h
  1046.        push    cs
  1047.        call    _CallRM
  1048.        mov     sp,bp
  1049.        leave
  1050.        retf
  1051.        ALIGN   2
  1052. @RMDRES1:
  1053.        test    byte ptr ds:(offset _RMFlags),2
  1054.        je      @RMDRES2
  1055.        sub     ax,ax
  1056.        leave
  1057.        retf
  1058.        nop
  1059. @RMDRES2:
  1060.        mov     ax,1
  1061.        leave
  1062.        retf
  1063. _RMDeallocResource endp
  1064. th3216_rmdeallocresource:
  1065.        push    ds
  1066.        push    es
  1067.        push    DATA16
  1068.        push    DATA16
  1069.        pop     es
  1070.        pop     ds
  1071.  
  1072.        push    dword ptr (rm_hResource)
  1073.        push    dword ptr (rm_hDriver)
  1074.        call    far ptr _RMDeallocResource
  1075.        add     sp,8
  1076.        pop     es
  1077.        pop     ds
  1078.        jmp     far ptr FLAT:th1632_rmdeallocresource
  1079. CODE16 ends
  1080.  
  1081. CODE32 segment
  1082.        assume  cs:FLAT, ds:FLAT, es:FLAT
  1083.        public  _RM32DeallocResource
  1084.        public  th1632_rmdeallocresource
  1085. _RM32DeallocResource proc near
  1086.        push    ebp
  1087.        mov     ebp,esp
  1088.        push    ebx
  1089.        push    ecx
  1090.        push    edx
  1091.        push    esi
  1092.        push    edi
  1093.        ; 08h[ebp] ->    HDRIVER
  1094.        ; 0ch[ebp] ->    HRESOURCE
  1095.        mov     eax,08h[ebp]
  1096.        mov     dword ptr DATA16:(OFFSET rm_hDriver),eax
  1097.        mov     eax,0ch[ebp]
  1098.        mov     dword ptr DATA16:(OFFSET rm_hResource),eax
  1099. IFDEF  KEE
  1100.        call    KernThunkStackTo16
  1101. ENDIF
  1102.        xor     eax,eax
  1103.        jmp     far ptr CODE16:th3216_rmdeallocresource
  1104. th1632_rmdeallocresource:
  1105. IFDEF  KEE
  1106.        push    eax
  1107.        call    KernThunkStackTo32
  1108.        pop     eax
  1109. ENDIF
  1110.        cmp     ax,0
  1111.        jne     short @RM32DRES_01
  1112.        mov     eax,eax
  1113. @RM32DRES_01:
  1114.        pop     edi
  1115.        pop     esi
  1116.        pop     edx
  1117.        pop     ecx
  1118.        pop     ebx
  1119.        pop     ebp
  1120.        ret
  1121. _RM32DeallocResource endp
  1122. CODE32 ends
  1123.  
  1124. ;******************************************************************************
  1125. ; RMCreateLDev
  1126. ;******************************************************************************
  1127.  
  1128. ;******************************************************************************
  1129. ; RMDestroyLDev
  1130. ;******************************************************************************
  1131.  
  1132. ;******************************************************************************
  1133. ; RMCreateSysName
  1134. ;******************************************************************************
  1135.  
  1136. ;******************************************************************************
  1137. ; RMDestroySysName
  1138. ;******************************************************************************
  1139.  
  1140. ;******************************************************************************
  1141. ; RMADDToHDEVICE
  1142. ;******************************************************************************
  1143.  
  1144. ;******************************************************************************
  1145. ; RMKeyToHandleList
  1146. ;******************************************************************************
  1147.  
  1148. ;******************************************************************************
  1149. ; RMHandleToType
  1150. ;******************************************************************************
  1151.  
  1152. ;******************************************************************************
  1153. ; RMHandleToParent
  1154. ;******************************************************************************
  1155.  
  1156. ;******************************************************************************
  1157. ; RMModifyResources
  1158. ;******************************************************************************
  1159. CODE16 segment
  1160.        assume  cs:CODE16,ds:DATA16
  1161.        public  _RMModifyResources
  1162.        public  th3216_rmmodifyresources
  1163.        ALIGN   2
  1164. _RMModifyResources proc near
  1165.        push    bp
  1166.        mov     bp,sp
  1167.        test    byte ptr ds:(offset _RMFlags),1
  1168.        je      @RMMRES1
  1169.        lea     ax,06h[bp]
  1170.        push    ss
  1171.        push    ax
  1172.        push    1bh
  1173.        push    cs
  1174.        call    _CallRM
  1175.        mov     sp,bp
  1176.        leave
  1177.        retf
  1178.        ALIGN   2
  1179. @RMMRES1:
  1180.        test    byte ptr ds:(offset _RMFlags),2
  1181.        je      @RMMRES2
  1182.        mov     ax,15h
  1183.        leave
  1184.        retf
  1185. @RMMRES2:
  1186.        mov     ax,1
  1187.        leave
  1188.        retf
  1189. _RMModifyResources endp
  1190. th3216_rmmodifyresources:
  1191.        push    ds
  1192.        push    es
  1193.        push    DATA16
  1194.        push    DATA16
  1195.        pop     es
  1196.        pop     ds
  1197.  
  1198.        push    dword ptr (rm_hResource)
  1199.        push    word ptr (rm_ModifyAction)
  1200.        push    dword ptr (rm_hAdapter)
  1201.        push    dword ptr (rm_hDriver)
  1202.        call    far ptr _RMModifyResources
  1203.        add     sp,14
  1204.        pop     es
  1205.        pop     ds
  1206.        jmp     far ptr FLAT:th1632_rmmodifyresources
  1207. CODE16 ends
  1208.  
  1209. CODE32 segment
  1210.        assume  cs:FLAT, ds:FLAT, es:FLAT
  1211.        public  _RM32ModifyResources
  1212.        public  th1632_rmmodifyresources
  1213. _RM32ModifyResources proc near
  1214.        push    ebp
  1215.        mov     ebp,esp
  1216.        push    ebx
  1217.        push    ecx
  1218.        push    edx
  1219.        push    esi
  1220.        push    edi
  1221.        ; 08h[ebp] ->    HDRIVER
  1222.        ; 0ch[ebp] ->    HADAPTER
  1223.        ; 10h[ebp] ->    ModifyAction
  1224.        ; 14h[ebp] ->    HRESOURCE
  1225.        mov     eax,08h[ebp]
  1226.        mov     dword ptr DATA16:(OFFSET rm_hDriver),eax
  1227.        mov     eax,0ch[ebp]
  1228.        mov     dword ptr DATA16:(OFFSET rm_hAdapter),eax
  1229.        mov     eax,10h[ebp]
  1230.        mov     dword ptr DATA16:(OFFSET rm_ModifyAction),eax
  1231.        mov     eax,14h[ebp]
  1232.        mov     dword ptr DATA16:(OFFSET rm_hResource),eax
  1233. IFDEF  KEE
  1234.        call    KernThunkStackTo16
  1235. ENDIF
  1236.        xor     eax,eax
  1237.        jmp     far ptr CODE16:th3216_rmmodifyresources
  1238. th1632_rmmodifyresources:
  1239. IFDEF  KEE
  1240.        push    eax
  1241.        call    KernThunkStackTo32
  1242.        pop     eax
  1243. ENDIF
  1244.        cmp     ax,0
  1245.        jne     short @RM32MRES_01
  1246.        xor     eax,eax
  1247. @RM32MRES_01:
  1248.        pop     edi
  1249.        pop     esi
  1250.        pop     edx
  1251.        pop     ecx
  1252.        pop     ebx
  1253.        pop     ebp
  1254.        ret
  1255. _RM32ModifyResources endp
  1256. CODE32 ends
  1257.  
  1258. ;******************************************************************************
  1259. ; RMParseScsiInquiry
  1260. ;******************************************************************************
  1261.  
  1262. ;******************************************************************************
  1263. ; RMUpdateAdjunct
  1264. ;******************************************************************************
  1265.  
  1266. ;******************************************************************************
  1267. ; RMAdjToHandleList
  1268. ;******************************************************************************
  1269.  
  1270. ;******************************************************************************
  1271. ; RMHDevToHLDev
  1272. ;******************************************************************************
  1273.  
  1274. ;******************************************************************************
  1275. ; RMResToHandleList
  1276. ;******************************************************************************
  1277.  
  1278. ;******************************************************************************
  1279. ; RMGetNodeInfo
  1280. ;******************************************************************************
  1281.  
  1282. ;******************************************************************************
  1283. ; RMCreateDetected
  1284. ;******************************************************************************
  1285.  
  1286. ;******************************************************************************
  1287. ; RMDestroyDetected
  1288. ;******************************************************************************
  1289.  
  1290. ;******************************************************************************
  1291. ; RMDevIDToHandleList
  1292. ;******************************************************************************
  1293.  
  1294. ;******************************************************************************
  1295. ; RMHandleToResourceHandleList
  1296. ;******************************************************************************
  1297.  
  1298. ;******************************************************************************
  1299. ; RMModifyNodeFlags
  1300. ;******************************************************************************
  1301.  
  1302. ;******************************************************************************
  1303. ; RMConvertID
  1304. ;******************************************************************************
  1305.  
  1306. ;******************************************************************************
  1307. ; RMGetCommandLine
  1308. ;******************************************************************************
  1309.  
  1310. ;******************************************************************************
  1311. ; RMGetVersion
  1312. ;******************************************************************************
  1313.  
  1314. ;******************************************************************************
  1315. ; RMSetSnoopLevel
  1316. ;******************************************************************************
  1317.  
  1318. ;******************************************************************************
  1319. ; RMSaveDetectedData
  1320. ;******************************************************************************
  1321.  
  1322. ;******************************************************************************
  1323. ; RMDeleteDetectedData
  1324. ;******************************************************************************
  1325.  
  1326. end
  1327.