microsoft / microsoft/wil

GetCurrentProcessExecutionOption should allow a process name to be passed in

Open
#379 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
C++
Stars
3k
Forks
300
Avg merge
19h 12m
Merged PRs (30d)
1

Description

Current code appends the process name from GetModuleFileNameW:

    // Lookup a DWORD value under HKLM\...\Image File Execution Options\<current process name>
    inline DWORD GetCurrentProcessExecutionOption(PCWSTR valueName, DWORD defaultValue = 0)
    {
        auto filePath = wil::GetModuleFileNameW<wil::unique_cotaskmem_string>();
        if (auto lastSlash = wcsrchr(filePath.get(), L'\\'))
        {
            const auto fileName = lastSlash + 1;
            auto keyPath = wil::str_concat<wil::unique_cotaskmem_string>(LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\)",
                fileName);

My code (for reasons) needs to use a value different from a process name that hosts my DLL and other DLLs, so I'd like a unique identifier. I realize this is probably overloading the intention of this method, but it would be convenient to have:

    inline DWORD GetCurrentProcessExecutionOption(PCWSTR valueName, DWORD defaultValue = 0, PCWSTR fileNameOverride = nullptr)
    {
      if (fileNameOverride) { fileName = filePathOverride; }
      else { /* existing filePath/lastSlash code */ }
       ...
    }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Find GetCurrentProcessExecutionOption and review its existing GetModuleFileNameW and Image File Execution Options path construction. Confirm how an optional file name should interact with the current-process fallback, then update the function and its coverage so callers can select a different identifier without changing existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.