DeviceIoControl native windows call not supported. Marshal.GetLastWin32Error() returns error code 50 (ERROR_NOT_SUPPORTED)

Calls to DeviceIoControl result in not supported error code. That is after the call Marshal.GetLastWin32Error() returns error code 50 ( ERROR_NOT_SUPPORTED). This method is on the kernel32.dll:

[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeviceIoControl(IntPtr hDevice,
                                                  UInt32 dwIoControlCode,
                                                  IntPtr lpInBuffer, 
                                                  Int32 nInBufferSize,
                                                  [Out] IntPtr lpOutBuffer, 
                                                  Int32 nOutBufferSize,
                                                  out uint lpBytesReturned, 
                                                  IntPtr lpOverlapped);

To give some context I create the file I am querying using:

[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr CreateFile(string lpFileName, 
                                                          uint dwDesiredAccess,
                                                          uint dwShareMode,
                                                          IntPtr lpSecurityAttributes,
                                                          uint dwCreationDisposition, 
                                                          uint dwFlagsAndAttributes,
                                                          IntPtr hTemplateFile);

which succeeds.

The file I am inspecting is under the Users\ContainerAdministrator directory. If I make this call in a directory outside of the Users\ContainerAdministrator directory, Marshal.GetLastWin32Error() returns error code 5 ( ERROR_ACCESS_DENIED)

The base image I am using is mcr.microsoft.com/dotnet/framework/runtime:4.8 and I am using C#.

Any help or suggestions would be greatly appreciated.