Featured post
windows - Create a directory and get the handle by issuing one IRP -
when create file createfile, file created , handle.
createdirectory doesn't return directory's handle.
i'd handle when create directory.
want handle issuing 1 i/o request packet.
so, 'do createdirectory, createfile file_flag_backup_semantics.' won't answer.
issue 2 irps file system.
is there api can use in usermode(win32 api)?
nt can this, win32 doesn't expose it. need use nt apis this. ntcreatefile
, specifically. should follow same parameters of zwcreatefile.
here's illustrative example (hacked in hurry inside web form -- ymmv):
handle createdirectoryandgethandle(pwstr pszfilename) { ntstatus status; unicode_string filename; handle directoryhandle; io_status_block iostatus; object_attributes objectattributes; rtlinitunicodestring(&filename, pszfilename); initializeobjectattributes(&objectatributes, &filename, 0, null, null); status = ntcreatefile(&directoryhandle, generic_read | generic_write, &objectattributes, &iostatus, file_attribute_normal, file_share_read | file_share_write | file_share_delete, file_create, file_directory_file, null, 0); if (nt_success(status)) { return directoryhandle; } else { setlasterror(rtlntstatustodoserror(status)); return invalid_handle_value; } }
some things note...
nt paths have different conventions win32 paths... might have sanitize path.
when talking
handle
s, nt apis dealnull
ratherinvalid_handle_value
.i didn't here, changing
initializeobjectattributes
call can interesting things, create relative directory handle. of course flags i've put in here might want change. consult documentation and/or web best results.
- Get link
- X
- Other Apps
Comments
Post a Comment