RenameFile, FileSetAttr, CopyFile...

delphi package - easy access to security apis
Post Reply
Mark-
Posts: 20
Joined: Sat May 24, 2014 4:51 pm

RenameFile, FileSetAttr, CopyFile...

Post by Mark- »

Hello,

Delphi XE.
madSecurity 1.2

I am renaming a file in directory X, copying a new file to directory X and renaming it.
Using MadExcept security wrappers I set the permissions.
This works on XP and W7.
It fails on W8 and W10.
UAC is off on all computers.
I have admin rights on all computers but, I still get "Access is denied".

It seems I need to set "Full control". How to do that is the question.

Ideas?

Thanks,

Mark
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: RenameFile, FileSetAttr, CopyFile...

Post by madshi »

You say "it fails", but you don't specify what fails exactly. The renaming? Copying? Or madSecurity access rights modification?
Mark-
Posts: 20
Joined: Sat May 24, 2014 4:51 pm

Re: RenameFile, FileSetAttr, CopyFile...

Post by Mark- »

All the RenameFile, FileSetAttr, CopyFile calls.

The first call is setting the permissions and I am not sure if it fails. I do know the "full control" checkbox in the security tabs is not set.
Then I call FileSetAttr if the file exist so I can delete it and it fails with access denied.
The I call DeleteFile and it fails with access denied.
Then RenameFile which copies and renames fails with access denied.

etc.

Finally I tried to clean up the file in the source directory and it fails when trying to rename it, access denied/

If I set the full control permission via the security tab the first part works. I stopped testing there and tried to set the full control permission and hit the wall.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: RenameFile, FileSetAttr, CopyFile...

Post by madshi »

Well, the exact flags which say "full control" differ from OS to OS. It's possible that you may need some special flags in newer OSs which madSecurity might not know about. In any case, I'd suggest that you double check if setting the permissions changes anything. It should be easy for you to check by looking at the security tab before and after calling madSecurity. E.g. try remove the permissions you need, then run the madSecurity code and see if anything changes. If not, maybe you need to enable some privileges to make it work. If yes, but RenameFile/CopyFile etc still fail, then maybe the flags added by madSecurity are not enough and you may need to add more flags.
Mark-
Posts: 20
Joined: Sat May 24, 2014 4:51 pm

Re: RenameFile, FileSetAttr, CopyFile...

Post by Mark- »

Thanks for the responses.

No joy on the change of permissions. I tried a bunch of stuff.
I will post a message in the newsgroup and post back when I have it solved.
Mark-
Posts: 20
Joined: Sat May 24, 2014 4:51 pm

Re: RenameFile, FileSetAttr, CopyFile...

Post by Mark- »

Well no joy.
I did not find any new flags/types/etc. for newer OS.
I found other strange things with W10.
Nothing to do with security.
I could rename a file and the file would disappear to Explorer. It was not hidden.
But, try to create or copy a file, with the same name, to the directory and the OS would say a file with the name existed.
But I could find the file with findfirst, findnext, delete the file and all was now fine. Like Explorer had a blind spot.

So, ended up modifying code to work for all OS. Not exactly what I wanted but will work.

Thanks for your help.
Post Reply