none
UNC work good .Question about STATUS_REPARSE ?? RRS feed

  • Question

  • Hello ,
    i developped a driver filesystem with mup function which work good ! BUT
    it is correct code on SECTION STATUS_REPARSE ?
    If no correct , then How do i work for good correct ?

    Thank.

    NTSTATUS drvdispatchmupdisk(PDEVICE_EXTENSION_MOTHER mu, PIRP Irp, PIO_STACK_LOCATION irps)
    {
    	//PDEVICE_EXTENSION_MOTHER mu = (PDEVICE_EXTENSION_MOTHER)DeviceObject->DeviceExtension;
    	NTSTATUS ret = STATUS_INVALID_DEVICE_REQUEST;
    	if (irps->MajorFunction == IRP_MJ_CREATE)
    	{
    		fileObject = irps->FileObject;
    
    		if (fileObject == NULL) {
    			KdPrintfSure2(("[MUP]  fileObject == NULL\n"));
    			ret = STATUS_INVALID_PARAMETER;
    			goto GGGH;
    		}
    		pSIn = &(fileObject->FileName);
    
    ...
    ...
    if (ISUNCREGISTERED(mu, source, &LEN, wchemin, &flagunc) == TRUE)
    		{
    ...
    ...
    				dest[0] = 0;
    
    				{
    					wcscat(dest, wchemin);
    				}
    				wcscat(dest, L"\\");
    				if ((flagunc&FL_UNC_ADDPATHUNC) != FL_UNC_ADDPATHUNC)
    					wcscat(dest, source + LEN);
    				else
    					wcscat(dest, source);
    				KdPrintfSure2(("IRP_MJ_CREATE %ws devient %ws\n", source, dest));
    				UNICODE_STRING SOut;
    				SOut.MaximumLength = 4096;
    				ret = SimRepAllocateUnicodeString(&SOut);
    				if (ret == STATUS_SUCCESS)
    				{
    					SOut.Length = wcslen(dest) << 1;
    					RtlCopyMemory(SOut.Buffer, dest, SOut.Length);
    					NRedSwapUnicodeString(pSIn, &SOut);
    					SimRepFreeUnicodeString(&SOut);
    					KDPublic(("File %ws matched\n", source));
    					ret = STATUS_REPARSE;
    				}
    
    
    
    
    
    
    
    
    
    VOID
    NRedSwapUnicodeString(
    	__in __out PUNICODE_STRING p1,
    	__in __out PUNICODE_STRING p2
    )
    {
    	UNICODE_STRING tmp;
    
    	//PAGED_CODE();
    
    	tmp.Length = p1->Length;
    	tmp.MaximumLength = p1->MaximumLength;
    	tmp.Buffer = p1->Buffer;
    
    	p1->Length = p2->Length;
    	p1->MaximumLength = p2->MaximumLength;
    	p1->Buffer = p2->Buffer;
    
    	p2->Length = tmp.Length;
    	p2->MaximumLength = tmp.MaximumLength;
    	p2->Buffer = tmp.Buffer;
    }
    
    
    
    NTSTATUS
    SimRepAllocateUnicodeString(
    	PUNICODE_STRING String
    )
    {
    
    	PAGED_CODE();
    
    	String->Buffer = (PWCH)
    		ExAllocatePool(
    			PagedPool,
    			String->MaximumLength
    
    		);
    
    	if (String->Buffer == NULL) {
    
    		/*DDbgPrint("[SimRep]: Failed to allocate unicode string of size 0x%x\n",
    		String->MaximumLength);
    		*/
    		return STATUS_INSUFFICIENT_RESOURCES;
    	}
    
    	String->Length = 0;
    
    	return STATUS_SUCCESS;
    }
    
    VOID
    SimRepFreeUnicodeString(
    	PUNICODE_STRING String
    )
    {
    	PAGED_CODE();
    
    	if (String->Buffer) {
    		ExFreePool(String->Buffer);
    		String->Buffer = NULL;
    	}
    
    	String->Length = String->MaximumLength = 0;
    	String->Buffer = NULL;
    }


    • Edited by Sizy458 Tuesday, December 3, 2019 7:20 PM
    Tuesday, December 3, 2019 7:18 PM