Problem mounting with WNetAddConnection for nulmrx ddk sample

device driver

    Sponsored Links

    Next

  • 1. A question about 'MmMapIoSpace'
    My WDM driver uses MmMapIoSpace() to translate BAR0 of the configuration space. It works fine with one board or mutiple boards. Now HW group has a cost down version; it has two exact same cores in one chip. It becomes a multi-fuction PCI device. I saw BIOS, Control Panel and the driver get the the same value of the physcal bar (BAR0) of Function 0 from its configuratuion space, so is Function 1. However, after the translation of MmMapIoSpace(), the mapped addresses cannot be use to access the new chip for either core. It looks like MmMapIoSpace() maps to _wrong_ addresses?! How could that happen? Many thanks in advance. Art
  • 2. Driectly access disk in vista
    Hi all, I have to write a kernel mode driver to driectly access disk ( driectly write on sectors ) in vista . Can anybody provide any guidence what kind of driver i should develope ( disk driver or file system filter driver ) as i am new to driver development. I am using WDM tool for developing driver and WinDbg for Debugging. Also what internals of vista i should know before developing that driver. Driver is software only driver. Thanks in advance Nidhi
  • 3. DTM -HELP
    How many machines are needed for me to run the DTM.I am a bit confused. windows server 2003,service pack 1-controller(Jobs will be run from here) windows xp-client machine where the device is connected. windows xp-studio,where is it installed??? Do I need three machines or two machines. where should I install studio,in controller machine(server 2003) or client machine(windows xp) I have gone thru the docs.I am not clear of this.I have even seen the video but not sure.The video doent tell anything regarding this.It jus says the way in which the studio,controller and client are installed. please help me out in this.I need to test my driver using DTM.
  • 4. DTM installation
    I have problem in installing DTM in my system.I have installed DTM controller in server 2003 machine.But I am not able to find any setup.exe for studio or client in that server machine.I tried clicking the studio.msi file It said that it requires setup.exe for installing studio in the controller machine.but I am not seeing any setup.exe other than the main setup.exe which we use to install wdk. Is there anything I need to do extra.I dont know where I am going wrong. Help me out!!

Problem mounting with WNetAddConnection for nulmrx ddk sample

Postby Raj » Sun, 25 Mar 2007 02:19:18 GMT

Hello All,

I was playing with nulmrx sample in ddk.

I built it for 64 bit and installed it 64 machine. Every thing works
fine until I try to mount network drive using WNetAddConnection2W api.

I wrote a very simple program that does what is equivalent of "net use
w: \\nulsvr\share", I have pasted it below.

When I build this program for 64 bit and run it, w: gets mounted fine.

But if I build the 32 bit version of this program and I try to run it
I get error 1203 or No Network provider accepted the given network
path".


Any help will be appreciated.

Thanks,
Rajesh


-----

#include "windows.h"
#include "tchar.h"
#include "stdio.h"

//
//  Include winnetwk.h and link with mpr.lib
//
#include <winnetwk.h>

int _tmain(int argc, _TCHAR* argv[])
{
  DWORD Res;
  NETRESOURCE Nr =
  {
    0,
    1,
    0,
    0,
    NULL,
    NULL,
    NULL,
    NULL
  };

  Nr.lpLocalName = _T("W:");
  Nr.lpRemoteName = _T("\\\\nulsvr\\share");

  Res = WNetAddConnection2( &Nr, NULL, NULL, 0x809);

  if(Res == NO_ERROR)
  {
    _tprintf(_T("Connection added: %s \n"), Nr.lpRemoteName);
	return 0;
  }
  else
    _tprintf(_T("Error: %ld\n"), Res);

  return 1;
}


Similar Threads:

1.I need a network miniredirector sample, NulMRx DDK sample does

2.I need a network miniredirector sample, NulMRx DDK sample doesn't

Hi,
 
I downloaded WDK 6001.18001. I built NullMRx sample and installed it. I 
tried it on WinXP and W2K3..
Unfortunatelly "net use * \\nulsvr\share" does not work. It returns with 
"System error 67 has occurred. The network name cannot be found."

In init.c (Line 284) RxStartMinirdr function failed. It returns with 
"c000000e" (STATUS_NO_SUCH_DEVICE).

I found this in the MSDN:
"The call to RxStartMinirdr cannot be made from the DriverEntry routine of 
the network mini-redirector after a successful call to RxRegisterMinirdr 
since some of the start processing requires that the driver initialization be 
completed." But the RxStartMinirdr is called from DriverEntry.

Could someone help me to solve this problem or give me a sample which works.
Would be very important.

Thanks,
Misi.


3.Problem with BulkUSB sample driver from DDK

Hi,

I use this sample driver with the PDIUSBD12D. If I only send data from pc to 
the controller it works. Send data from the controller it works also.

But if I do both together there is a problem. If I send 400 bytes and then 
send this 400 bytes back sometimes I reseive on PC not all of the 400 bytes. 
But if I send the next packet from the controller to the pc the lost data 
come with this packet.

I think windows buffers this lost data and dont create an receive event.

I use the overlapped struckture to send and receive data from the sample 
driver

while(!ubThreadExit)
{
if (INVALID_HANDLE_VALUE != hRead)
{
// Empfangsevent?
if (WAIT_OBJECT_0 == WaitForSingleObject(ov.hEvent,500))
{
if ((ov.InternalHigh > 0)&& (pUSBRxHandler))
if (GetOverlappedResult(hRead, &ov, &ulNBytesRead, true))
pUSBRxHandler(RxBuffer, ulNBytesRead, pUSBTag);
ReadFile(hRead, RxBuffer, 256, &ulNBytesRead, &ov); 
}
}
}

Does anybody knows about this problem?

best regards Maik Hnig

4.About the Problem with the DDK's PortIO SAMPLE.

Respected Sir,

              Here, I do have a very big problem with one of the sample 
source driver codes provided with Windows DDK. 

      the problem is here with the following one :-

PORTIO SUMMARY

This generic port I/O device driver sample shows how to reserve I/O ports 
and read and write to it from an user application. 






CODE TOUR
File Manifest
File		Description

Portio.htm	Sample Tour documentation for this sample (this file).
Sources		Generic file for building the code sample.
genport.inf	File for installing the driver.
Gpioctl.h	Include file for defining IOCTL codes used by driver and test 
applications.
Gpdread.c	Source file that shows how to read a byte from a port using the 
genport driver.
Gpdwrite.c	Source file that shows how to write a byte to a port using the 
genport driver.
Genport.h	Include file for Generic Port I/O Driver.
Genport.c	Source file for Generic Port I/O Driver.



              Problem as Described in detailed manner :->

          The Technical Problem, that I am facing here is that, 

 1st what it does :-


Routine Description:
    This routine is the dispatch handler for the driver.  It is responsible 
for processing the IRPs.


    DriverObject->MajorFunction[IRP_MJ_CREATE]          = GpdDispatch;






NTSTATUS
GpdDispatch(
    IN    PDEVICE_OBJECT pDO,
    IN    PIRP pIrp             
    )

/*++

Routine Description:
    This routine is the dispatch handler for the driver.  It is responsible
    for processing the IRPs.

Arguments:
    
    pDO - Pointer to device object.

    pIrp - Pointer to the current IRP.

Return Value:

    STATUS_SUCCESS if the IRP was processed successfully, otherwise an error
    indicating the reason for failure.

--*/

{
    PLOCAL_DEVICE_INFO pLDI;
    PIO_STACK_LOCATION pIrpStack;
    NTSTATUS Status;

    PAGED_CODE();

    pIrp->IoStatus.Information = 0;
    pLDI = (PLOCAL_DEVICE_INFO)pDO->DeviceExtension;    // Get local info 
struct

    DebugPrint (("Entered GpdDispatch\n"));

    Status = IoAcquireRemoveLock (&pLDI->RemoveLock, pIrp);
    if (!NT_SUCCESS (Status)) {
        pIrp->IoStatus.Information = 0;
        pIrp->IoStatus.Status = Status;
        IoCompleteRequest (pIrp, IO_NO_INCREMENT);
        return Status;
    }

    if (!pLDI->Started) {
        //
        // We fail all the IRPs that arrive before the device is started.
        //
        pIrp->IoStatus.Status = Status = STATUS_DEVICE_NOT_READY;
        IoCompleteRequest(pIrp, IO_NO_INCREMENT );
        IoReleaseRemoveLock(&pLDI->RemoveLock, pIrp);       
        return Status;
    }
    
    pIrpStack = IoGetCurrentIrpStackLocation(pIrp);

    // Dispatch based on major fcn code.

    switch (pIrpStack->MajorFunction)
    {
        case IRP_MJ_CREATE:
        case IRP_MJ_CLOSE:
            // We don't need any special processing on open/close so we'll
            // just return success.
            Status = STATUS_SUCCESS;
            break;

        case IRP_MJ_DEVICE_CONTROL:
            //  Dispatch on IOCTL
            switch (pIrpStack->Parameters.DeviceIoControl.IoControlCode)
            {
            case IOCTL_GPD_READ_PORT_UCHAR:
            case IOCTL_GPD_READ_PORT_USHORT:
            case IOCTL_GPD_READ_PORT_ULONG:
                Status = GpdIoctlReadPort(
                            pLDI,
                            pIrp,
                            pIrpStack,
                            
pIrpStack->Parameters.DeviceIoControl.IoControlCode
                            );
                break;

            case IOCTL_GPD_WRITE_PORT_UCHAR:
            case IOCTL_GPD_WRITE_PORT_USHORT:
            case IOCTL_GPD_WRITE_PORT_ULONG:
                Status = GpdIoctlWritePort(
                            pLDI, 
                            pIrp,
                            pIrpStack,
                            
pIrpStack->Parameters.DeviceIoControl.IoControlCode
                            );
                break;
            default:      
                Status = STATUS_INVALID_PARAMETER;

            }
            break;
        default: 
            Status = STATUS_NOT_IMPLEMENTED;
            break;
    }

    // We're done with I/O request.  Record the status of the I/O action.
    pIrp->IoStatus.Status = Status;

    // Don't boost priority when returning since this took little time.
    IoCompleteRequest(pIrp, IO_NO_INCREMENT );
    IoReleaseRemoveLock(&pLDI->RemoveLock, pIrp);       
    return Status;
}










NTSTATUS
GpdIoctlReadPort(
    IN PLOCAL_DEVICE_INFO pLDI,
    IN PIRP pIrp,
    IN PIO_STACK_LOCATION IrpStack,
    IN ULONG IoctlCode  )


/*++

Routine Description:
    This routine processes the IOCTLs which read from the ports.

Arguments:
    
    pLDI        - our local device data
    pIrp        - IO request packet
    IrpStack    - The current stack location
    IoctlCode   - The ioctl code from the IRP

Return Value:
    STATUS_SUCCESS           -- OK

    STATUS_INVALID_PARAMETER -- The buffer sent to the driver
                                was too small to contain the
                                port, or the buffer which
                                would be sent back to the driver
                                was not a multiple of the data size.

    STATUS_ACCESS_VIOLATION  -- An illegal port number was given.

--*/

{
                                // NOTE:  Use METHOD_BUFFERED ioctls.
    PULONG pIOBuffer;           // Pointer to transfer buffer
                                //      (treated as an array of longs).
    ULONG InBufferSize;         // Amount of data avail. from caller.
    ULONG OutBufferSize;        // Max data that caller can accept.
    ULONG nPort;                // Port number to read
    ULONG DataBufferSize;

    PAGED_CODE();

    // Size of buffer containing data from application
    InBufferSize  = IrpStack->Parameters.DeviceIoControl.InputBufferLength;

    // Size of buffer for data to be sent to application
    OutBufferSize = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;

    // NT copies inbuf here before entry and copies this to outbuf after
    // return, for METHOD_BUFFERED IOCTL's.
    pIOBuffer     = (PULONG)pIrp->AssociatedIrp.SystemBuffer;

    // Check to ensure input buffer is big enough to hold a port number and
    // the output buffer is at least as big as the port data width.
    //
    switch (IoctlCode)
    {
    case IOCTL_GPD_READ_PORT_UCHAR:
        DataBufferSize = sizeof(UCHAR);
        break;
    case IOCTL_GPD_READ_PORT_USHORT:
        DataBufferSize = sizeof(USHORT);
        break;
    case IOCTL_GPD_READ_PORT_ULONG:
        DataBufferSize = sizeof(ULONG);
        break;
    default:      
        return STATUS_INVALID_PARAMETER;

    }

    if ( InBufferSize != sizeof(ULONG) || OutBufferSize < DataBufferSize )
    {
        return STATUS_INVALID_PARAMETER;
    }

    // Buffers are big enough.

    nPort = *pIOBuffer;             // Get the I/O port number from the 
buffer.

    if (nPort >= pLDI->PortCount ||
        (nPort + DataBufferSize) > pLDI->PortCount ||
        (((ULONG_PTR)pLDI->PortBase + nPort) & (DataBufferSize - 1)) != 0)
    {
        return STATUS_ACCESS_VIOLATION;   // It was not legal.
    }
    
    if (pLDI->PortMemoryType == 1)
    {
        // Address is in I/O space
        
        switch (IoctlCode)
        {
        case IOCTL_GPD_READ_PORT_UCHAR:
            *(PUCHAR)pIOBuffer = READ_PORT_UCHAR(
                            (PUCHAR)((ULONG_PTR)pLDI->PortBase + nPort) );
            break;
        case IOCTL_GPD_READ_PORT_USHORT:
            *(PUSHORT)pIOBuffer = READ_PORT_USHORT(
                            (PUSHORT)((ULONG_PTR)pLDI->PortBase + nPort) );
            break;
        case IOCTL_GPD_READ_PORT_ULONG:
            *(PULONG)pIOBuffer = READ_PORT_ULONG(
                            (PULONG)((ULONG_PTR)pLDI->PortBase + nPort) );
            break;
        default:      
            return STATUS_INVALID_PARAMETER;


        }
    } 
    else if (pLDI->PortMemoryType == 0)
    {
        // Address is in Memory space
        
        switch (IoctlCode)
        {
        case IOCTL_GPD_READ_PORT_UCHAR:
            *(PUCHAR)pIOBuffer = READ_REGISTER_UCHAR(
                            (PUCHAR)((ULONG_PTR)pLDI->PortBase + nPort) );
            break;
        case IOCTL_GPD_READ_PORT_USHORT:
            *(PUSHORT)pIOBuffer = READ_REGISTER_USHORT(
                            (PUSHORT)((ULONG_PTR)pLDI->PortBase + nPort) );
            break;
        case IOCTL_GPD_READ_PORT_ULONG:
            *(PULONG)pIOBuffer = READ_REGISTER_ULONG(
                            (PULONG)((ULONG_PTR)pLDI->PortBase + nPort) );
            break;
        default:      
            return STATUS_INVALID_PARAMETER;

        }
    } 
    else
    {
        return STATUS_UNSUCCESSFUL;
    }

    //
    // Indicate # of bytes read
    //
    
    pIrp->IoStatus.Information = DataBufferSize;

    return STATUS_SUCCESS;
}

    // We're done with I/O request.  Record the status of the I/O action.
    pIrp->IoStatus.Status = Status;

    // Don't boost priority when returning since this took little time.
    IoCompleteRequest(pIrp, IO_NO_INCREMENT );
    IoReleaseRemoveLock(&pLDI->RemoveLock, pIrp);       
    return Status;








    When the driver executes the GpdIoctlReadPort() dispatch function , 
which is under the IOCTL_GPD_READ_PORT_ULONG , And that too, in the 
GpdIoctlReadPort() function I specified that the Computer should execute 
ExAllocatePool() & to free up resources thereof I used ExFreePool() function 
to free up any allocated buffer. Hence, when I execute these functions, even 
by putting these function after the KeAcquireSpinLock() & before the 
KeReleaseSpinLock() functions, the communication with the device by 
interacting to device via DeviceIOControl() upto merely 6 successfull times 
only, oherwise, it just restarts the Operating System? I did not be able to 
know as to why so ? Hence, I came to a final conclusion that, it requires to 
fix these problems. Hence, I am sending the source code, which I want you to 
fix these problems. I may request you to please resolve this problem and 
please fix the code as early as possible. I am waiting for your reply.

I also want to pass IRP the buffer address returned in pIrp so that, the 
user mode application will be able to use the buffer address provided by the 
driver. Also when I use     

(PULONG)pIrp->AssociatedIrp.SystemBuffer=(PULONG)myaddress; , here myaddress 
is of pvoid type, the Operating System restarts ? Please also fix this 
problem.



regards,

Sudhanshu Deshmukh

5.Poblem in Installing sample driver given in DDK sample

I m facing problem in installing sample driver perm2dll.dll and perm2.sys 
which are given in DDK samples. When I install these with inf message comes 
"This device cannot start. (Code 10)"
Can any one tell why this is happening.

6. Problem with and NDIS IM driver based on the PassThru DDK sample



Return to device driver

 

Who is online

Users browsing this forum: No registered users and 10 guest