Skip to content

Instantly share code, notes, and snippets.

@blaquee
Last active September 13, 2021 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaquee/b31ec30148bcf71880c2d5cbc9683e10 to your computer and use it in GitHub Desktop.
Save blaquee/b31ec30148bcf71880c2d5cbc9683e10 to your computer and use it in GitHub Desktop.
fsd

Misc Notes on Windows Drivers and Object Management

Some terminology for File System Drivers:

FSD - File System Driver: A Driver that implements a File System

FCB - File Control Block: Uniquely represents an open, on-disk object in system memory. (a similarity to vnodes in UNIX). When an object is successfully opened in the Object Manager, an FCB is created by the IO Manager.

CCB - Context Control Block: A CCB is created by the FSD when a successful open operation in made by a user mode program. A Handle is returned and the CCB is a kernel representation of this handle.

VPB - Volume Parameter Block: Contains a pointer to the Physical Device Object and its Logical Device Object.

Object Manager namespaces

The Object manager maintains information about objects through three main mechanisms:

  • Object Types:
  • Directory Objects:
  • Symbolic Link Objects:

How Object Names are built and referred to in the heirarchy of the Object Tree

A Functional Device Object points to a Physical Device Object, the FDO creates a Device Object under the \Devices namespace named Serial0. The PDO creates an Object name under \Devices as well named 000005c.

The Serial0 Device create a symbolic link in the \Global?? namespace named COM1, making this accessible to Win32 Usermode Programs.

Therefore a call to CreateFile("COM1",..) will be internally converted to NtCreateFile("\Global??\COM",..)

The Object Manager traverses the Global?? directory and finds COM1. Because COM1 is a Symbolic Link, it reparses the Link, which points to \Device\Serial0. Since \Device is a directory it continues to search for the second part \Serial0. Because this is not a Symbolic link and is a leaf node, it has reached the end of parsing and uses this (Serial0) as the final Object to parse and return back to the caller.

Interesting tidbits

  • For device objects, this directory is by convention the \Device\ Object Manager directory. Note that there's no rule that device objects must be placed into this directory. It's just the way it's usually done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment