Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: An interesting "feature"  (Read 5104 times)

0 Members and 1 Guest are viewing this topic.

BC_Programmer

    Topic Starter

    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
An interesting "feature"
« on: August 04, 2009, 04:07:06 AM »
I just "accidentally" discovered an interesting feature while messing about- it's possible to make a folder inaccessible to most every program really easily. It relies on the way the Unicode file access functions parse the filename, as well as how explorer and most programs deal with it as well.

step 1: open command prompt

step 2: use md to create the directory- include the FULL path. you must prepend \\?\, for example:

Code: [Select]
md \\?\D:\testfolder.

I'm not sure how quote parsing works, but I don't believe this "feature" will work with quotes around the name. Since for the most part this just creates that folder after the \\?\, but adding that allows us to basically override the command prompt behaviour that detects and removes trailing periods. You can copy files into the folder from command prompt, specifying the space, but trying to view the contents with Dir returns a error- you cannot seemingly access the files.

And in fact, you cannot- Windows explorer errors out as well, saying the location is unavailable.

The question is why? well, prepending \\?\ to a filename in file functions says to the function that the string can be much longer- under most circumstances (without the \\?\, that is) a path is limited to 240 characters). this is used to remove that limit.

Without the \\?\, most programs (the command interpreter, explorer) strip off ending periods before calling the function. for some reason they don't do this when \\?\ is given. Note however that even specifying the \\?\ in the address bar/location bar will not help- since it will strip off the period for user input (you cannot access it because explorer is stripping off the period at the end of the directory name).

Be warned that since explorer cannot access it, neither can file open/save dialogs, so save them elsewhere and them copy them into the "secret" folder.

I was trying to dereference Null Pointers before it was cool.

JJ 3000



    Egghead
  • Thanked: 237
  • Experience: Familiar
  • OS: Linux variant
Re: An interesting "feature"
« Reply #1 on: August 16, 2009, 01:16:26 AM »
nice 8)
thanks.
Save a Life!
Adopt a homeless pet.
http://www.petfinder.com/