Results 1 to 4 of 4

Thread: Calling BIOS Interrupt routine

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2001
    Location
    Cirebon - Indonesia
    Posts
    18

    Question

    Hi all,
    I want to call BIOS Interrupt routine from VB
    how can I use API to do that ?
    I use Windows 2000 and VB 6.
    Best regards,
    Privida

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    You will have to use ASM code to do that.
    The code is:
    Code:
    int <interrupt number>
    ret
    You can use a CallWindowProc trick to do this in VB.
    This passes 4 parameters to the function as well, so the 'ret' instruction has to be changed to fix the stack alignment thingie:
    Code:
    int <interrupt number>
    ret 0010
    And in VB:
    Code:
    Option Explicit
    
    Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
    Sub Main()
        Dim ASMCode(0 To 4) As Byte
        
        ' int <interrupt number> = CD <interrupt number>
        ASMCode(0) = &HCD
        ASMCode(1) = &H3 ' Testing: Interrupt 3h (debug break)
        
        ' ret 0010 = C2 10 00
        ASMCode(2) = &HC2
        ASMCode(3) = &H8
        ASMCode(4) = &H0
        
        Call CallWindowProc(VarPtr(ASMCode(0)), 0, 0, 0, 0)
    End Sub
    This will call interrupt 3h. You can change ASMCode(1) to the interrupt number you need.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2001
    Location
    Cirebon - Indonesia
    Posts
    18
    Thank's Yonatan.

    Some Interrupt have sub function dan return value
    ie. calling int 1AH, function 0 (read clock)
    returns cx= high word count
    dx= low word count
    al=0

    what is the code ?
    Best regards,
    Privida

  4. #4
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    That specific interrupt might work in DOS (16-bit), but definitely not in a Windows program...
    Interrupts are very rarely used in Win32 programs, not to mention VB programs.

    In DOS, you can use this code:
    Code:
    xor ax, ax
    int 1Ah
    
    push cx
    push dx
    call SomeFunctionWhichDealsWithCxAndDx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width