NtQueryInformationFile for FileStreamInformation succeeds in 32-bit fails in 64-bit


i'm trying list alternate streams of file hosted on smb server using ntqueryinformationfile function. code i've written far works correctly servers fails when run against non-samba mac os x smb server.

i've reduced code form application following bit of code reproduces issue reliably:

using microsoft.win32.safehandles;    namespace streams  {      class program      {          [structlayout(layoutkind.sequential, charset = charset.unicode)]          public class netresource          {              public uint dwscope;              public uint dwtype;              public uint dwdisplaytype;              public uint dwusage;                public string lplocalname;              public string lpremotename;              public string lpcomment;              public string lpprovider;          }            [dllimport("ntdll.dll", setlasterror = false, charset = charset.unicode)]          public static extern uint ntqueryinformationfile(              safefilehandle handle,              intptr iostatusblock,              intptr pinfoblock,              uint length,              uint fileinformationclass);              [dllimport("kernel32.dll", charset = charset.unicode, setlasterror = true)]          public static extern safefilehandle createfile(              string filename,              uint desiredaccessmask,              uint sharemode,              intptr lpsecurityattributes,              uint creationdisposition,              uint flagsandattributes,              intptr htemplatefile);            [dllimport("mpr.dll", setlasterror = true, charset = charset.unicode)]          public static extern uint wnetaddconnection2(netresource netresource, [marshalas(unmanagedtype.lptstr)] string password, [marshalas(unmanagedtype.lptstr)] string username, uint flags);            static void main(string[] args)          {              var server = args[0];              var username = args[1];              var password = args[2];              var uncpath = args[3];                netresource netresource = new netresource();              netresource.dwtype = 0x1 /* disk */;              netresource.lpremotename = server;              wnetaddconnection2(netresource, password, username, 0x00000004 /* connect_temporary */);                var fh = createfile(                  uncpath,                  0x80000000 /* generic_read */,                  (uint)(fileshare.read | fileshare.write | fileshare.delete),                   intptr.zero,                  3 /* open_existing */,                  0x08000000 /* sequentialscan */ | 0x02000000 /* backupsemantics */,                   intptr.zero                  );                intptr status = marshal.allochglobal(1024);              uint buffersize = 64*1024;              intptr buffer = marshal.allochglobal((int)buffersize);                uint ntstatus = ntqueryinformationfile(fh, status, buffer, buffersize, 22 /* filestreaminformation */);                console.writeline($"ntqueryfileinformation returned {ntstatus}");              console.readkey();          }      }  }

in cases value of ntstatus status_ok expected. when try use on file has alternate data streams mac os x smb server status_invalid_network_response instead. error code seems indicate response server incorrect, when inspect wireshark there no differences compared when status_ok returned.

make things stranger, code works when run in 32-bit mode (set 'prefer 32-bit' in visual studio project settings). when run in 64-bit mode error code. obvious error code in question not 64-bit clean, afaict code above is.

i've tried replacing ntqueryinformationfile call call getfileinformationbyhandleex, gives me same result (with win32 error code instead of nt status code of course).

explain difference in behaviour between 32-bit , 64-bit mode?

hi kmarivoe,

i've checked ntqueryinformationfile  in msdn. method of windows driver. belongs to underlying systems. this forum discussing , ask questions issues regarding core of .net, including security, performance, hosting, base classes, interop, reliability, debugging, gc, , profiling. actually, out of forum support.

from point of view, maybe hardware support 32bit application as it's own ability of support.

best regards,

kristin


we trying better understand customer views on social support experience, participation in interview project appreciated if have time. helping make community forums great place.
click here participate survey.




.NET Framework  >  Common Language Runtime Internals and Architecture



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'