none
STATUS_REPARSE don't work with method PREPARSE_DATA_BUFFER RRS feed

  • Question

  • Hello,
    Then option '_shareconfig' is equal to 0 or 1 , it work good.
    Why the method redirect by PREPARSE_DATA_BUFFER don't work ???
    Thank.

    PREPARSE_DATA_BUFFER PrepareBufferForRedirect(WCHAR *destmount, int mode)
    {
    	PREPARSE_DATA_BUFFER Reparse=(PREPARSE_DATA_BUFFER)ExAllocatePoolWithTag(NonPagedPool, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, 'FwrI');
    	if (Reparse != NULL)
    	{
    		USHORT _len = wcslen(destmount);
    		USHORT len = (_len+1) << 1;
    		RtlZeroMemory(Reparse, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
    		Reparse->ReparseTag = mode;
    		//int len = wcslen(destmount);
    		
    		if (mode == IO_REPARSE_TAG_MOUNT_POINT)
    		{
    			Reparse->ReparseDataLength = 8+4 + len;//sizeof(L"\\??\\C:\\Documents and Settings");
    			Reparse->MountPointReparseBuffer.SubstituteNameLength = len - sizeof(UNICODE_NULL);
    			Reparse->MountPointReparseBuffer.PrintNameOffset = len;
    			RtlCopyMemory(Reparse->MountPointReparseBuffer.PathBuffer, destmount, len);
    		}		
    		else
    		if (mode== IO_REPARSE_TAG_SYMLINK)
    		{
    			Reparse->ReparseDataLength = 12 + 4 + len;
    			Reparse->SymbolicLinkReparseBuffer.SubstituteNameLength = len - sizeof(UNICODE_NULL);
    			Reparse->SymbolicLinkReparseBuffer.PrintNameOffset = len;
    			RtlCopyMemory(Reparse->SymbolicLinkReparseBuffer.PathBuffer, destmount, len);
    		}
    		else
    		{
    			ExFreePool(Reparse);
    			Reparse = NULL;
    			
    		}
    		
    		
    	}
    	return Reparse;
    }
    
    ..
    ..
    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)
    	{
    		PFILE_OBJECT fileObject;
    		fileObject = irps->FileObject;
    		//get destination from fileObject
    		WCHAR  dest[1024] = { 0 };
    		...
    		GetRedirect(fileObject,dest,1023);
    		...
    		...
    		//
    		#ifndef WINXP
    				if (_shareconfig1 == 1)
    				{
    					IoReplaceFileObjectName(fileObject, dest, wcslen(dest)<<1);
    					ret = STATUS_REPARSE;
    				}
    				else
    #else
    				_shareconfig1=0;
    #endif
    				if (_shareconfig1 == 0)
    				{
    					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;
    					}
    				}
    				else
    //#else
    				{
    					///It don't work !
    					int vi;
    					PREPARSE_DATA_BUFFER Reparse = PrepareBufferForRedirect(dest, vi= _shareconfig1);
    					if (Reparse != NULL)
    					{
    						Irp->Tail.Overlay.AuxiliaryBuffer = (PCHAR)Reparse;
    						Irp->IoStatus.Information = vi;
    						ret = STATUS_REPARSE;
    					}
    					else
    					{
    						ret = STATUS_INSUFFICIENT_RESOURCES;
    						KDPublic(("Status failure PrepareBufferForRedirect\n"));
    					}
    				}
    	}
    }
    
    

    Saturday, December 7, 2019 12:11 PM