I am writing a DLL function which accepts a path to a file or directory and returns a bitmask double word which represents the current Access permissions.
I wish to be able to check that I can Read a file, write to a file, Add or delete a file from a direcotory. before I actually attempt to do it. The purpose being so that I can build my GUI dynamically, disabling areas of the GUI if the required file permissions are not available.
I am using Vis C++ 6 on windows NT with NTFS.
I am trying to tackle this using AccessCheck().
firstly calling GetNamedSecurityInfo to get the SD for the passed file. I then call OpenProcessToken to get the AccessToken for the current process - I think OpenThreadToken would be better here but I could not get it working ;-(
And finally I call AccessCheck to compare the SD and AccessToken.
My Problem :
AccessCheck always fails with error 998 (invalid access to memory location) I dont know why.
I think it may be due to the generic mapping structure I need to pass to AccessCheck, I have been passing NULL and empty PGENERIC_MAPPING's - I dont know how to get the generic mapping for the file.
My Question : Basicly in 3 parts -
a) am I tackling this in the correct way? Is there an easier way?
b) how do I get AccessCheck() to work!! (I would increase the points for an example that works!!)
c) how do I interperate the results - ie the access mask returned from accesscheck().