System Programming help

c code for keyboard buffer........

Page 1 of 1

6 Replies - 1500 Views - Last Post: 21 June 2009 - 08:52 AM Rate Topic: -----

#1 irfan_furion   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-October 08

System Programming help

Post icon  Posted 20 June 2009 - 04:53 AM

i am trying to write a code in c that changes the result of keystrokes by using keyboard buffer.
Here is what the programme will do...

if user presses "A" the result would be somthing else, like any other letter except "A"
the code that i have written so no errors but it also does'nt give any output
Herz the code....

i am using borland compiler to run the code......



#include<stdio.h>
#include<conio.h>
#include<bios.h>
#include<dos.h>

void interrupt (*oldint15)();
void interrupt newint15(unsigned int BP,unsigned int DI,
			unsigned int SI,unsigned int DS,
			unsigned int ES,unsigned int DX,
			unsigned int CX,unsigned int BX,
			unsigned int AX,unsigned int CS,
			unsigned int IP,unsigned int flags);
void main()
{
oldint15 = getvect(0x15);
setvect(0x15,newint15);
keep(0,1000);
getch();
}
void interrupt newint15(unsigned int BP,unsigned int DI,
			unsigned int SI,unsigned int DS,
			unsigned int ES,unsigned int DX,
			unsigned int CX,unsigned int BX,
			unsigned int AX,unsigned int CS,
			unsigned int IP,unsigned int flags)
{
if(*(((char*)&AX)+1)==0x4F)
{
//q to a

if(*((char*)&AX)==0x10)
*((char*)&AX)=0x1E;
else if(*((char*)&AX)==0x1E)
*((char*)&AX)=0x10;

//w to s

if(*((char*)&AX)==0x11)
*((char*)&AX)=0x1F;
else if(*((char*)&AX)==0x1F)
*((char*)&AX)=0x11;

//e to d
if(*((char*)&AX)==0x12)
*((char*)&AX)=0x20;
else if(*((char*)&AX)==0x20)
*((char*)&AX)=0x12;


//r to f
if(*((char*)&AX)==0x13)
*((char*)&AX)=0x21;
else if(*((char*)&AX)==0x21)
*((char*)&AX)=0x13;



//t to g
if(*((char*)&AX)==0x14)
*((char*)&AX)=0x22;
else if(*((char*)&AX)==0x22)
*((char*)&AX)=0x14;


//y to h
if(*((char*)&AX)==0x15)
*((char*)&AX)=0x23;
else if(*((char*)&AX)==0x23)
*((char*)&AX)=0x15;


//u to j
if(*((char*)&AX)==0x16)
*((char*)&AX)=0x24;
else if(*((char*)&AX)==0x24)
*((char*)&AX)=0x16;



//i to k
if(*((char*)&AX)==0x17)
*((char*)&AX)=0x25;
else if(*((char*)&AX)==0x25)
*((char*)&AX)=0x17;


//o to l
if(*((char*)&AX)==0x18)
*((char*)&AX)=0x26;
else if(*((char*)&AX)==0x26)
*((char*)&AX)=0x18;


}
  getch();
}


This post has been edited by irfan_furion: 21 June 2009 - 01:00 AM


Is This A Good Question/Topic? 0
  • +

Replies To: System Programming help

#2 NickDMax   User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: System Programming help

Posted 20 June 2009 - 06:09 PM

Moved to C++
Was This Post Helpful? 0
  • +
  • -

#3 erik.price   User is offline

  • D.I.C Lover
  • member icon

Reputation: 486
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: System Programming help

Posted 20 June 2009 - 06:56 PM

void interrupt newint15(unsigned int BP,unsigned int DI...

You can't have multiword (space separated) function/ variable names. should be

void interrupt_newint15(etc. etc. etc.)

I didn't look through your code thoroughly, this is just the first thing that jumped out at me.

This post has been edited by erik.price: 20 June 2009 - 06:57 PM

Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: System Programming help

Posted 20 June 2009 - 07:02 PM

If this is for Windows (I see you have dos.h?) I would think it's going to be easier to hook the Windows API (by process ID) rather than get access to the keyboard buffer.
Was This Post Helpful? 0
  • +
  • -

#5 irfan_furion   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-October 08

Re: System Programming help

Posted 21 June 2009 - 12:54 AM

View Postno2pencil, on 20 Jun, 2009 - 06:02 PM, said:

If this is for Windows (I see you have dos.h?) I would think it's going to be easier to hook the Windows API (by process ID) rather than get access to the keyboard buffer.



I understand.......
but this is my assignment and the idea is to use keyboard buffer and alter the effect of keystrokes as pressed....
as i mentioned in the topic if user presses "A" key on the keyboard the result should any alpahbet execpt "A"....

This post has been edited by irfan_furion: 21 June 2009 - 01:01 AM

Was This Post Helpful? 0
  • +
  • -

#6 irfan_furion   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-October 08

Re: System Programming help

Posted 21 June 2009 - 01:05 AM

View Posterik.price, on 20 Jun, 2009 - 05:56 PM, said:

void interrupt newint15(unsigned int BP,unsigned int DI...

You can't have multiword (space separated) function/ variable names. should be

void interrupt_newint15(etc. etc. etc.)

I didn't look through your code thoroughly, this is just the first thing that jumped out at me.



i think this is how interrupt functions are declared........?
Was This Post Helpful? 0
  • +
  • -

#7 erik.price   User is offline

  • D.I.C Lover
  • member icon

Reputation: 486
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: System Programming help

Posted 21 June 2009 - 08:52 AM

View Postirfan_furion, on 21 Jun, 2009 - 04:05 AM, said:

i think this is how interrupt functions are declared........?


Oh, okay, sorry wasn't thinking. I'm not too familiar with DOS code
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1