Announcement

Collapse
No announcement yet.

TSR to capture CTRL-C keys in order to not break third party software

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

  • TSR to capture CTRL-C keys in order to not break third party software

    I wrote this program to keep users from breaking a dos written program from crashing with the CTRL-C key combination.
    Because of an internet website that is capturing the right mouse click and is not functioning properly to copy the text highlighted contents to clipboard, we are having to use the CTRL-C key to copy the marked highlighted text to the clipboard from the web page inside of the web browser.
    Apparently the user hit the CRTL-C inside the dos program that was running and caused the program to have issues because it is run in batch mode JCL like form.
    I think(hope) this TSR program will capture the CTRL-C keys and disguard any unwanted keys shortly there after. It seems to be working with the test i have done.
    In windows xp, I could not find a way to keep the TRS from loading a second instance of itself more than once which is OK because the batch file that starts the console program ends and does not loop back to the begging in any manner. But, it would great if I could stop the multiple instances of this PBDOS program.

    But here it is anyways and it does not appear to stop batch file when mutlitple CTRL-C keys are pressed, but it appears to stop the CTRL-C in a dos program.
    The batch file that i tested to see if this program would stop it was just a simple BATCH program that looped running the DIR windows os program.
    Here is the simple batch routine that will eventually allow you abort out of using a CTRL-C with this program running, but we do not plan to for our JCL like third program like be broken like this simple batch routine.

    All i wanted to do was try to intercept the Ctrl-C key combination and keep it from reaching the third party dos program.

    Code:
    TSRCTRLC.EXE
    :START
    DIR
    SLEEP1
    GOTO START
    Code:
    REM TSRCTRLC.BAS
    REM TSR TO PREVENT CTRL-C characters being input
    REM this progam will popup and back down on a CTRL-C character input
    REM POWERBASIC SOURCE CODE
    REM VERSION 03-22-2018
    REM COMPILED WITH POWERBASIC 3.5 FOR DOS
    REM $CPU 80386 'program works on any CPU
    $CPU 80386 'program works on only 80386 CPU
    $OPTIMIZE SIZE  'make smallest possible executable
    $DEBUG MAP OFF 'turn off map file generation
    $DEBUG PBDEBUG OFF 'don't include pbdebug support in our executable
    $LIB COM OFF 'turn off PowerBASIC's communications library.
    $LIB CGA OFF 'turn off PowerBASIC's CGA graphics library.
    $LIB EGA OFF 'turn off PowerBASIC's EGA graphics library.
    $LIB VGA OFF 'turn off PowerBASIC's EGA graphics library.
    $LIB FULLFLOAT OFF 'turn off PowerBASIC's floating point support.
    $ERROR BOUNDS ON  'turn on bounds checking
    $ERROR NUMERIC OFF 'turn off numeric checking
    $ERROR OVERFLOW OFF 'turn off overflow checking
    $ERROR STACK OFF 'turn off stack checking
    $COM 0 'set communications buffer to nothing
    $STRING 1 'set largest string size at 1k
    $STACK 2048 'let's use a 2k stack
    $SOUND 0 'smallest music buffer possible
    $DYNAMIC 'all arrays will be dynamic by default
    $OPTION CNTLBREAK OFF 'don't allow Ctrl-Break to exit program
    $COMPILE EXE 'this tells PB to make a standalone EXE
    $EVENT OFF
    ON ERROR GOTO ErrorHandler
    
    x& = SETMEM( -700000 ) 'release unused memory
    
    POPUP KEY CHR$(04,&H2E,&H73) 'CTRL-C key press
    PRINT "loaded TSRCTRLC.EXE to block CTRL-C input"
    
    POPUP SLEEP ' before going to sleep
    WHILE 1 = 1
    I&=0
     '  PRINT "CTRL C WAS ENTERED "
     ' PRINT "DONE GOING TO SLEEP"
       A$=INKEY$
      WHILE LEN(A$)
       A$=INKEY$
      WEND
    POPUP SLEEP 'going to sleep
    WEND
    
    END
    
    ErrorHandler:
     RESUME NEXT
    Attached Files
    p purvis

  • #2
    I am not sure if you can keep the program from loading twice with a mutex design.
    But here is a method using a environment variable way in a batch routine

    Code:
    IF "%TSRCTRLC%" EQU "ON" GOTO TSRCTRLCSTARTED
    SET TSRCTRLC=ON
    C:\PB\TSRCTRLC
    :TSRCTRLCSTARTED



    p purvis

    Comment


    • #3
      I am not sure if you can keep the program from loading twice with a mutex design.
      Mutexes don't exist under MS-DOS. (I'd say "how soon we forget" except its been thirty+ years!)

      But IIRC you can prevent that in the DOS environment using the multiplex (&h2F) interrupt.

      Damn, I think I wrote a prototype program for everyone to use which automatically did that ... let me look... well, looky here, I found it ..

      Now let's see if we can attach it here TSRSKEL.BAS

      Wow, I think I pulled this off... and it DOES include the code to handle "already installed!"


      Attached Files
      Michael Mattias
      Tal Systems Inc.
      Racine WI USA
      mmattias@talsystems.com
      http://www.talsystems.com

      Comment


      • #4
        MCM I was just reading your post back in 2008. Thank you for your help. I cannot believe I am
        having to run such a program.
        p purvis

        Comment


        • #5
          >I cannot believe I am having to run such a program.
          And they said DOS was dead

          Comment


          • #6
            I cannot believe I am having to run such a program.
            I believe you meant to say, "I cannot believe I am choosing to run such a program."

            Based on your posts over the past year or two, I've already sold, developed, tested and installed some modern Windows-based versions.

            And FWIW, MS-DOS *IS* dead!
            Michael Mattias
            Tal Systems Inc.
            Racine WI USA
            mmattias@talsystems.com
            http://www.talsystems.com

            Comment


            • #7
              No Mike. I need to run this TSR.
              After your post I worked more on it and was able to reduce the footprint in memory thanks to your code.
              I played with your tsr code some but I have been sick with a chest infection and not been able to emplement the multiplex just yet.
              It works well when a 16bit exe is running to hold the CTRL-C from getting to the 16bit software.
              PBDOS makes use of the CRT-C to cause a page down in the IDE.
              With CTRL-C being a regular keyboard short for windows programs that copy highlighted text to the clipboard, it does not help a dos program that may break out and exit with possible bad results like when databases are open or being used, amongst other things. Too many dos programs do not handle the CTRL-C in a very positive manner.
              PBCC 32 apps are uneffected of course.
              p purvis

              Comment

              Working...
              X