Accessing the Clipboard and Overriding CPU listeners

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Soujiro
    New Member
    • Jan 2007
    • 35

    Accessing the Clipboard and Overriding CPU listeners

    I wanted to listen for a Ctrl+C in normal mode while my program is running at background.. after a Ctrl+C is detected i wanted to access the clipboard and and get whatever is in there and try to parse it and determine if that object should be parsed.

    I tried searching for C/C++ codes but to no luck can't find.. i know how to do it in java but obviously its not the same here in C++..

    Anyone got some ideas..
  • Soujiro
    New Member
    • Jan 2007
    • 35

    #2
    I know someone here knows about this.. Please help me..

    Comment

    • cyberking
      New Member
      • Jan 2007
      • 84

      #3
      Originally posted by Soujiro
      I know someone here knows about this.. Please help me..
      Hi!!
      Well, I think I know the answer to the first part of your question.. Hmmm.. But related to the clipboard aspect, I don think I'll be of any help..

      Let me try explaining my logic for the first part of detecting the sequence of 2 keys, ctrrl + c. Any key hit from the keyboard results in a harware interrupt.
      Thereby, the cpu suspend its current activity and goes to process the keyhit. All keys have their own scan codes. these scan codes are available at memory location 0x60, other than for special keys (ctrl,alt,num lock, caps lock, shift), For these keys, its at 0x417. Thereby, u would have to use an if statement and check for the combination of both the keys. it would be

      if( inportb (0x60) == 33 && (*kb & 4) == 4)
      then
      // call an interrupt to your clipboard function..

      however it is important to save your point of return. so u can use the getvect and setvect functions as

      prev = getvect(9);
      setvect ( 9, our);
      keep (0,1000);

      9 is the keyboard interrupt. That is interrupt 9 is generated everytime a key is hit. this is multiplied by 4 and stored at locations 36 to 39 in IVT.
      So what we are doing next in setvect statement is we are loading the locations 36 to 39 with the address of our function our(). Keep function is used to make it resident in memory.. Infact this is the logic behind Terminate And Stay Resident Programs(TSR).

      Once transfer is handed over to our function, Check the if condition I ve explained earlier and then its up to you mate to do the rest..

      Combining,

      #include<dos.h>

      char far *kb = (char far*) 0x417;
      void interrupt our(); // our function. Note the use of interrupt
      void interrupt (*prev)(); // Pointer to function

      void main()
      {
      prev = getvect(9);
      setvect ( 9, our);
      keep (0,1000);
      }

      void interrupt our()
      {
      if( inportb (0x60) == 33 && (*kb & 4) == 4) // Checks for ctrl + c
      then
      // call an interrupt to your clipboard function..

      (*prev)(); // Important. ROM-BIOS function is the only one that knows what to do once our() has been done with

      }
      Thats from my side buddy! Think I was of help. .
      Regards
      Sumanth
      Last edited by cyberking; Jan 27 '07, 10:59 AM. Reason: forgot

      Comment

      Working...