microsoft / microsoft/terminal
Random NTSTATUS when calling user32.dll!ConsoleControl under WoW64
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
### Windows Terminal version
_No response_
### Windows build number
10.0.19045.3086
### Other Software
_No response_
### Steps to reproduce
Build the following code for 32-bit target and run on 64-bit host
```c++
#include
#include
typedef enum _CONSOLECONTROL {
Reserved1,
ConsoleNotifyConsoleApplication,
Reserved2,
ConsoleSetCaretInfo,
Reserved3,
ConsoleSetForeground,
ConsoleSetWindowOwner,
ConsoleEndTask,
} CONSOLECONTROL;
typedef struct _CONSOLEENDTASK {
HANDLE ProcessId;
HWND hwnd;
ULONG ConsoleEventCode;
ULONG ConsoleFlags;
} CONSOLEENDTASK, * PCONSOLEENDTASK;
typedef NTSTATUS(WINAPI* ConsoleControl)(
_In_ CONSOLECONTROL Command,
_In_reads_bytes_(ConsoleInformationLength) PVOID ConsoleInformation,
_In_ DWORD ConsoleInformationLength
);
int main()
{
auto user32_dll = ::LoadLibraryExA("user32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
auto ConsoleControl = (::ConsoleControl)::GetProcAddress(user32_dll, "ConsoleControl");
auto count = DWORD{};
auto rec = INPUT_RECORD{};
auto task = CONSOLEENDTASK{ .ProcessId = (HANDLE)::GetCurrentProcessId(), .ConsoleEventCode = CTRL_C_EVENT };
std::cout << "Press any key to generate event. Press Esc to exit.\n";
while (true)
{
::ReadConsoleInputW(::GetStdHandle(STD_INPUT_HANDLE), &rec, 1, &count);
if (rec.EventType == KEY_EVENT && rec.Event.KeyEvent.bKeyDown)
{
if (rec.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) return 0;
auto status = ConsoleControl(ConsoleEndTask, &task, sizeof(task));
std::cout << "status: 0x" << std::hex << status << "\n";
}
}
}
```
### Expected Behavior
Output
```
Press any key to generate event. Press Esc to exit.
status: 0x0
status: 0x0
status: 0x0
status: 0x0
```
### Actual Behavior
Output
```
Press any key to generate event. Press Esc to exit.
status: 0xb94a7
status: 0xb94ca
status: 0xb94db
status: 0xb94e6
status: 0xb955a
status: 0xb956b
status: 0xb9572
status: 0xb95fc
status: 0xb9603
status: 0xb962b
status: 0xb969b
```
Contributor guide
Research direction
Start by building and running the provided C++ repro as a 32-bit target on a 64-bit Windows host, then inspect the WoW64 path used by user32.dll!ConsoleControl. Compare repeated ConsoleControl status results with the expected 0 values; done when the reported NTSTATUS is stable and matches the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100