Newbie question on proper path for devices and files

I’m still a bit confused about the meaning of \?? . I know it expands to \Global?? but what’s the rationale behind this?

I was trying to open this file “C:\pic.jpg” with ZwOpenFile and it failed, changing it to “\??\C:\pic.jpg” solved the problem but I really want to understand WHY

History. It’s just that simple.

The ?? prefix goes back to the original NT OS/2 design in 1989. Remember that, at that point, they were trying to design a kernel that was totally agnostic to the systems running above it. OS/2, Win16, Win32, Posix – they would all just be things bolted on top of the kernel. There was (supposedly) nothing Windows-specific in the kernel. So, the kernel has its own object name space, for events, drivers, processes, threads, etc. In the real world, they needed to have a way to manage the system namespaces. The ?? name was created so it would not collide with any real names.

When Terminal Services was added in the mid-1990s to allow multiple simultaneous sessions in a single server, they needed a way to separate names that are global to the whole system and names that are local to the current session. Thus, they creates \Global?? and \Local?? to keep those two separate.

1 Like

@Tim_Roberts said:
History. It’s just that simple.

The ?? prefix goes back to the original NT OS/2 design in 1989. Remember that, at that point, they were trying to design a kernel that was totally agnostic to the systems running above it. OS/2, Win16, Win32, Posix – they would all just be things bolted on top of the kernel. There was (supposedly) nothing Windows-specific in the kernel. So, the kernel has its own object name space, for events, drivers, processes, threads, etc. In the real world, they needed to have a way to manage the system namespaces. The ?? name was created so it would not collide with any real names.

When Terminal Services was added in the mid-1990s to allow multiple simultaneous sessions in a single server, they needed a way to separate names that are global to the whole system and names that are local to the current session. Thus, they creates \Global?? and \Local?? to keep those two separate.

Thank you Tim, but I still don’t get it why my call to ZwOpenFile worked only when I changed “C:\pic.jpg” to “\??\C:\pic.jpg”

The ?? prefix goes back to the original NT OS/2 design in 1989

Almost 100% correct. Everything Mr. Roberts writes is true, but he mis-remembers the history of naming the name space.

The original directory was \DosDevices\ – This was changed to ??\ as a “shortcut” to avoid having to recopy the name on every open. The change was made… I don’t remember when.

To expand just a tiny bit on what Mr. Roberts wrote, and to try to address your question… kernel-mode names (what are called “native” names) can exist anywhere in the Object Manager’s namespace. When a Win32 program specifies a device name, the I/O Manager asks the Object Manager to resolve that name by looking first in his \Global??\ directory, and if that is not successful in his local session’s device name directory. This allowed the namespace for devices that were being used for devices that were made available to Win32 programs to be separate from the namespace being used for devices that were being made available to programs of other subsystems (OS/2 or POSIX, for example). This was to prevent naming clashes or ambiguity.

ETA:

why my call to ZwOpenFile worked only when I changed “C:\pic.jpg” to “??\C:\pic.jpg”

You need to look at the Object Manager’s directory structure. There IS no device named “C:” in its root directory. There IS one, however, in his "\Global??" directory. And ??\ is effectively a synonym for "\Global??"

Peter

1 Like

@“Peter_Viscarola_(OSR)” said:

The ?? prefix goes back to the original NT OS/2 design in 1989

Almost 100% correct. Everything Mr. Roberts writes is true, but he mis-remembers the history of naming the name space.

The original directory was \DosDevices\ – This was changed to ??\ as a “shortcut” to avoid having to recopy the name on every open. The change was made… I don’t remember when.

To expand just a tiny bit on what Mr. Roberts wrote, and to try to address your question… kernel-mode names (what are called “native” names) can exist anywhere in the Object Manager’s namespace. When a Win32 program specifies a device name, the I/O Manager asks the Object Manager to resolve that name by looking first in his \Global??\ directory, and if that is not successful in his local session’s device name directory. This allowed the namespace for devices that were being used for devices that were made available to Win32 programs to be separate from the namespace being used for devices that were being made available to programs of other subsystems (OS/2 or POSIX, for example). This was to prevent naming clashes or ambiguity.

ETA:

why my call to ZwOpenFile worked only when I changed “C:\pic.jpg” to “??\C:\pic.jpg”

You need to look at the Object Manager’s directory structure. There IS no device named “C:” in its root directory. There IS one, however, in his "\Global??" directory. And ??\ is effectively a synonym for "\Global??"

Peter

Now I get it. Thanks Peter!