Another way of executing files

Something is missing in Far Manager? You have a great idea that should be heared? Write here.
Locked
geordi
Posts: 5
Joined: Thu Jul 20, 2006 6:23 am

Another way of executing files

Post by geordi » Thu Jul 20, 2006 8:43 am

Recently I've made some investigation of how FAR executes files (on ENTER, shift+ENTER, cmd line).

For files ending with good extension (.exe, .com. bat) FAR makes a CreateProcess API call with parameters:
"C:\windows\system32\cmdexe /C program.exe" (program.exe = executed file).
This is rather good.

But for every other file (not ending with .exe, .com, ...) FAR makes a ShellExecuteEx API call.
This is particulary good, because CreateProcess cann't execute documents for example.

The problem is that I've disabled "Traverse Folder / Execute File" NTFS permission on some files (mostly .exe files) so I cann't execute them accidently.
With FAR this works fine for .exe files (because of that CreateProcess). But for documents and other files this doesn't work, because ShellExecuteEx don't execute documents directly.

So my idea is to execute all files using CreateProcess, with parameter "C:\windows\system32\cmdexe /C file params".

This woul'd help in my case and I think it is a better solution in general (so users can disable execution of any file).

User avatar
t-rex
Admin
Posts: 417
Joined: Sun Mar 20, 2005 6:10 pm
Location: Ashdod
Contact:

Post by t-rex » Thu Jul 20, 2006 11:06 am

geordi
I think you got something wrong. Document files are never executed (they just can't be) they only get opened (read) by the program that works with them - so in reallity the program that can read such files is the one that is executed. So setting the execute permission for documents has no real value. And second of all CreateProcess has nothing to do with opening documents.

geordi
Posts: 5
Joined: Thu Jul 20, 2006 6:23 am

Post by geordi » Thu Jul 20, 2006 11:19 am

Sorry, maybe I explained it badly.


I know how things work :)

I try to describe what happens when you do something like this:
cmdexe /C document.txt

Cmdexe tries to call CreateProcess(document.txt, ...). It will fail obviously. But GetLastError returns error 0xC1 and so cmdexe tries to call ShellExecuteEx, which works in standard way (finds associated program and runs it with parameter document.txt).

And when permissions of that document.txt are set with "Execute File" disabled, CreateProcess will fail, but GetLastError returns 0x05 (acces denied).

So that's the difference.

And I want to suggest you to do it the same way in FAR.

User avatar
t-rex
Admin
Posts: 417
Joined: Sun Mar 20, 2005 6:10 pm
Location: Ashdod
Contact:

Post by t-rex » Thu Jul 20, 2006 12:42 pm

geordi
I think you need to work on your security measures instead.

geordi
Posts: 5
Joined: Thu Jul 20, 2006 6:23 am

Post by geordi » Thu Jul 20, 2006 12:56 pm

Look, I'm working in an antivirus company, so I know much about security and how to handle such "hot" files. But NTFS file system (with it's permissions) gives us posibility to make manipulation with viruses and malware even safer.

We are using FAR for a long time because it is best file manager for things we do. And I saw some progress in FAR development recently (1.70 final, 1.71 alpha ...). So I want to ask if this is technically problem to slightly change the way FAR executes files.

That's all.

User avatar
t-rex
Admin
Posts: 417
Joined: Sun Mar 20, 2005 6:10 pm
Location: Ashdod
Contact:

Post by t-rex » Thu Jul 20, 2006 1:29 pm

geordi
I see no reasonable need to change this because there is no problem in FAR but in your security settings.

Locked