I can't write into the Control register for parallel port on window 7 64 bit platform, why?

232 views Asked by At

I am using inpout32.dll to deal with parallel port on my pc. I find I can change value of control register (0x37a) on windows 7 32bit, but I can't on 64bit.

Anyone knows the reason?

The home page of the dll is http://www.highrez.co.uk/

I paste the source code for inpoutx64.sys as follows, it's pretty simple, just call WRITE_PORT_UCHAR system api, any differences for 64bit version and 32bit version of this function?

NTSTATUS hwinterfaceDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP pIrp)
{
PIO_STACK_LOCATION  stkloc;
NTSTATUS            ntStatus = STATUS_SUCCESS; 
struct              tagPhys32Struct Phys32Struct;

PUCHAR              cData;
PUSHORT             sData;
PULONG              lData;
PUSHORT             address;

ULONG               inBuffersize;   
ULONG               outBuffersize;  
ULONG               inBuf;         
PVOID               CtrlBuff;

stkloc = IoGetCurrentIrpStackLocation( pIrp );
inBuffersize = stkloc->Parameters.DeviceIoControl.InputBufferLength;
outBuffersize = stkloc->Parameters.DeviceIoControl.OutputBufferLength;

CtrlBuff    = pIrp->AssociatedIrp.SystemBuffer;
cData  = (PUCHAR) CtrlBuff;
sData  = (PUSHORT) CtrlBuff;
lData  = (PULONG) CtrlBuff;
address = (PUSHORT) CtrlBuff;

switch ( stkloc->Parameters.DeviceIoControl.IoControlCode )
 {
    case IOCTL_READ_PORT_UCHAR:
        if ((inBuffersize >= 2) && (outBuffersize >= 1)) 
        {
            UCHAR value;
            value = READ_PORT_UCHAR((PUCHAR)address[0]);
            cData[0] = value;
        } 
        else 
        {   
            ntStatus = STATUS_BUFFER_TOO_SMALL;
        }
        pIrp->IoStatus.Information = sizeof(UCHAR); 
        ntStatus = STATUS_SUCCESS;

        break;
    case IOCTL_WRITE_PORT_UCHAR:
        if (inBuffersize >= 3) 
        {
            WRITE_PORT_UCHAR((PUCHAR)address[0], cData[2]); //Byte 0,1=Address Byte 2=Value
            pIrp->IoStatus.Information = 10;
        } 
        else 
        {
            ntStatus = STATUS_BUFFER_TOO_SMALL;
            pIrp->IoStatus.Information = 0; 
            ntStatus = STATUS_SUCCESS;
        }
        break;
1

There are 1 answers

4
Edison Junior On

I think you have some knowledge about hardware architecture, well, 64bit architecture change completely, and change register values can be protected for the hardware level or software level.

try to share what you want to do, Your ask don't left clear what you main deal.