Skip to content

DEVINSTID in many calls should be const #1598

@dorssel

Description

@dorssel

Actual behavior

Many configuration manager functions (e.g, CM_Locate_DevNode) take a DEVINSTID as parameter. This is defined as WCHAR * (for DEVINSTID_W). However, in all cases that I encountered the "string" is actually const. I don't know why the Windows API does not have a const DEVINSTID instead, but the result is that CSWin32 generates only PWSTR calls, requiring an unsafe context.

Expected behavior

For those cases where DEVINSTID is in reality const (which could actually even be all cases), string overrides are generated, such that no unsafe context is required.

Repro steps

  1. NativeMethods.txt content:
CM_Locate_DevNode
  1. NativeMethods.json content (if present):
  1. Any of your own code that should be shared?

https://github.com/dorssel/usbipd-win/blob/master/Usbipd/WindowsDevice.cs#L58-L67

Context

  • CsWin32 version: 0.3.264
  • Win32Metadata version (if explicitly set by project):
  • Target Framework: net10.0
  • LangVersion (if explicitly set by project): 14

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions