hi all,
I have this following structure,
typedef struct
{
int window;
UCHAR CommonMemData;
int offset;
}COMMONMEM_ACCESS_STRUCT,*PCOMMONMEM_ACCESS_STRUCT;
Using the deviceIoControl,I am reading the data which is sent from kernel
mode for the user mode entered offset and window.
I am using Buffered IO.
COMMONMEM_ACCESS_STRUCT UserBuff;
UserBuff.offset=offset;
UserBuff.CommonMemData=0x0;
UserBuff.window=window;
BOOL
res=DeviceIoControl(HPcmcia1,IOCTL_PCMCIA_READ_COMMON_MEMORY,&UserBuff,sizeof(UserBuff),&UserBuff,sizeof(UserBuff),&JUNK,NULL);
if(res)
{
printf(“\nPCMCIA common memory read successful”);
return UserBuff.CommonMemData;
}
In the Kernel mode,
case IOCTL_PCMCIA_READ_COMMON_MEMORY: // code == 0x800
{
KernelCommBuff=(PCOMMONMEM_ACCESS_STRUCT)Irp->AssociatedIrp.SystemBuffer;
KERNEL_REGISTER_OFFSET=KernelCommBuff->offset;
window=KernelCommBuff->window;
KdPrint(("Reading at Window : %d offset 0x%x
",window,KERNEL_REGISTER_OFFSET));
KernelCommBuff->CommonMemData=0x77;
KernelCommBuff->window=6;
info=sizeof(KernelCommBuff);
KdPrint((“Read the Buffer value :0x%x”,KernelCommBuff->CommonMemData));
break;
}
Now the problem is, In the Kernel mode KdPrint, the
KernelCommBuff->CommonMemData value gets printed…
but in the user mode,
UserBuff.CommMemData, it gives a junk value…
ie ,the window and offset data is transferred from Usermode to kernel mode
using the input buffer and gets printed in the kernel mode also…
but the dummy kernel data ,is not transferred to the User mode output
buffer…
Note: One more strange thing is,
KernelCommBuff->window=6;
Here I change the Window number which I entered in the user mode, say 1…
this change is reflected back in the user mode…
only data is not transferred to the user mode…
Please kindly tell me where I need to correct the code…
thanx,
Shiv