Announcement

Collapse
No announcement yet.

POPUP INTERRUPT and Returns

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • POPUP INTERRUPT and Returns

    Hey all,

    I am trying to create a TSR. This is done with the following code
    Code:
    'we need to create the popup
    lResult = SetMem(-500000)
    
    
    Popup Interrupt &H14, 0, off, off
    
    Do
    	popup sleep
    	'what function was called
    	lResult = Reg(%AX)
    	if lResult = &H1C00 then
    		lPort = REG(%DX)
    		Reg %AX, &H1954
    	End if 
    Loop
    I am calling the interrupt with this code

    Code:
     Port%=P%
            REG 1,&H1C00
            REG 4,Port%
            CALL INTERRUPT &H14
            lResult% = Reg(1)
            IF lResult%=&H1954 THEN 
                Print "GOOD"
            Else
                Print "BAD"
            End if
    This runs well but for the life of me I can not get the return value of &H1954, any ideas?

    TIA
    Sr. Software Development Engineer and Sr. Information Security Analyst,
    CEH, Digital Forensic Examiner

  • #2
    > any ideas?

    Only the obvious..

    Code:
    if lResult = &H1C00 then
    Is this ever true? I don't see that you test for it.

    Comment


    • #3
      In this case lResult is always = &HC100
      Sr. Software Development Engineer and Sr. Information Security Analyst,
      CEH, Digital Forensic Examiner

      Comment


      • #4
        The REG statement and function can be used to communicate via a register array in both directions with a TSR. This is outlined in chapter 14 of the PowerBASIC For DOS Reference Guide.
        Sincerely,

        Steve Rossell
        PowerBASIC Staff

        Comment


        • #5
          Steve,

          I am looking at chapter 14, where is it?

          THanks
          Sr. Software Development Engineer and Sr. Information Security Analyst,
          CEH, Digital Forensic Examiner

          Comment


          • #6
            Sorry, it is in the User's Guide...page 224
            Sincerely,

            Steve Rossell
            PowerBASIC Staff

            Comment


            • #7
              For some reason I can not get the value returned

              Prog1.bas
              Code:
              lResult = SetMem(-500000)
              PopUp Interrupt &H14, 0, Off, Off
              Do
                 PopUp Sleep
                 'what function was called
                 lResult = Reg(%AX)
                 REG %AX, &H1954
              Loop
              Prog2.bas
              Code:
                 REG 1, &H1C00
                 Call interrupt &H14
                 Print Hex$(REG(1))
              Do I need to perform another interrupt? or must I set the value using an ASM etc...
              Last edited by Thomas Tierney; 6 Nov 2007, 03:22 PM.
              Sr. Software Development Engineer and Sr. Information Security Analyst,
              CEH, Digital Forensic Examiner

              Comment


              • #8
                I think your last sentence is correct, Thomas. According to my reference guide, the REG statement does not load the register, it loads a register buffer that gets written to the register on the next CALL INTERRUPT. So load the register directly in your popup by replacing

                REG %AX, &H1954

                with

                ASM MOV AX, &h1954

                Comment


                • #9
                  I have tried it. Before doing the ASM statement I would get 1C00 as the return meaning that the registers are unchanged. Now when I do ASM MOV AX, &HXXXX I get 1900 for any value of XXXX.

                  Thanks Jerry.
                  Sr. Software Development Engineer and Sr. Information Security Analyst,
                  CEH, Digital Forensic Examiner

                  Comment


                  • #10
                    Steve,

                    I looked at page 224 in the users guide and there is no mention whatsoever on how to return values from the POPUP INTERRUPT back to the calling program. I did see an article in a newsgroup with an example on how to do this but it assumes that the developer has access to the calling programs source code which I do not have. Any help would be appreciated.

                    Thanks
                    Sr. Software Development Engineer and Sr. Information Security Analyst,
                    CEH, Digital Forensic Examiner

                    Comment


                    • #11
                      ... how to return values from the POPUP INTERRUPT back to the calling program ....assumes that the developer has access to the calling programs source code which I do not have
                      Huh?

                      If you do not have access to the calling program's source code, how can you do 'anything' with any return value? For that matter, what does the program do with it?

                      If this is some kind of "documented interface" to this program, I'd be interested in seeing the key points of that interface description... and your desciption of what you are trying to do with it.

                      Generally a TSR just does 'everything' and the program which is running at the time is totally agnostic about it - it does not know nor does it care.

                      Disclaimer: I have not done anything with PB/DOS for at least five years. But I did a lot with PB/DOS TSRs prior to that... in fact, that was my first paying job as an independent consultant (1994) so I doubt I will ever forget.

                      ($250.00 if you wanted to know).


                      MCM

                      Comment


                      • #12
                        Michael,

                        the sample program I was speaking of was actually posted by you quite awhile ago. What I am specifically referring to is a program that issues an interrupt then it decides on what to do with the results. What I am doing is creating an "emulator" for that interrupt and its functions so that I can bridge the communications between the actual sequence of calls in the 16 bit app to a TCP/IP Socket. I know what the responses from the TSR should be based on the spec for this interrupt.

                        BTW: the interrupt and its functions are in Ralph Browns Interrupt List under &14H (FOSSIL DRIVER API)
                        Sr. Software Development Engineer and Sr. Information Security Analyst,
                        CEH, Digital Forensic Examiner

                        Comment


                        • #13
                          Well, I dug out the help...
                          POPUP INTERRUPT int%, ticks%, ON|OFF, ON|OFF

                          The interrupt number may be defined only once, before the first
                          POPUP SLEEP. int sets interrupt number to "hook". ticks sets timeout
                          limit in ticks (18.2 per second). The first ON|OFF controls execution
                          or "chain" of the prior interrupt handler upon entry - typically on - if
                          on, whenever the interrupt is executed, the prior handler is called
                          immediately (even if the POPUP is active, therefore "busy"); when
                          complete, POPUP is attempted per the usual rules. The second ON|OFF
                          controls execution or "chain" of the prior interrupt handler upon exit
                          from the POPUP, typically off. One-way communication is possible:
                          upon POPUP, callers registers are stored in the REG array.
                          A couple of things come to mind:

                          First, your POPUP statement:
                          Code:
                          Popup Interrupt &H14, 0, off, off
                          This is way (way) outside my expertise, but it seems to me that if the interrupt is supposed to 'respond', at least one (the second one) of those "off" should be an "on" (I did NOT go hunting for the Ralf Brown List).

                          Second, the help talks about "one-way" communication. Maybe that's true and you have hit some kind of barrier if you create your TSR with PB/DOS; i.e., you may just have to write your TSR 100% in assembly language.

                          MCM

                          Comment


                          • #14
                            Thanks Michael!!

                            I tried
                            PopUp Interrupt &H14, 18, Off, on
                            with !mov ax, &hxxxx

                            this always returns &H1900 no matter what the value of xxxx is

                            I tried
                            PopUp Interrupt &H14, 18, On, off
                            with !mov ax, &hxxxx

                            this just hangs

                            I tried
                            PopUp Interrupt &H14, 18, On, On
                            with !mov ax, &hxxxx

                            this just throws an NTVDM error, Steve Rossel implies in an earlier statement that two way is possible and explained in the book which I do not see, I also have an email into support and am hoping to hear from them sometime today.

                            Thanks
                            Sr. Software Development Engineer and Sr. Information Security Analyst,
                            CEH, Digital Forensic Examiner

                            Comment


                            • #15
                              Confirmed from PB Support - this is one way communication only, need to find another method

                              Thanks for the help all!!
                              Sr. Software Development Engineer and Sr. Information Security Analyst,
                              CEH, Digital Forensic Examiner

                              Comment


                              • #16
                                >need to find another method

                                1. Save in, read from disk file will work.

                                2. In PB/DOS, another way to do it is to reserve some upper memory by using MEMSET (must use in both programs, IIRC), and read and write the integer value above that address somewhere.

                                3. Check out pbvUserArea. That says its only for RUN/CHAIN, so that probably will NOT work.

                                4.(Old faithful)... appropriate a couple of bytes (all you need to store is a 16-bit integer, right?) from an unused video page. For that matter, you could use a couple of bytes from a USED video page, just use something in a corner somewhere and nobody will ever notice.

                                MCM

                                Comment

                                Working...
                                X