kernel32/wincon cleanup

This commit is contained in:
2025-11-18 21:53:16 -07:00
parent 2304c05ed0
commit 64511becf2
3 changed files with 21 additions and 14 deletions

View File

@@ -168,13 +168,16 @@ BOOL WINAPI IsProcessorFeaturePresent(DWORD ProcessorFeature) {
HOST_CONTEXT_GUARD(); HOST_CONTEXT_GUARD();
DEBUG_LOG("IsProcessorFeaturePresent(%u)\n", ProcessorFeature); DEBUG_LOG("IsProcessorFeaturePresent(%u)\n", ProcessorFeature);
if (ProcessorFeature == 0) { // PF_FLOATING_POINT_PRECISION_ERRATA if (ProcessorFeature == 0) { // PF_FLOATING_POINT_PRECISION_ERRATA
return TRUE; return FALSE;
}
if (ProcessorFeature == 1) { // PF_FLOATING_POINT_EMULATED
return FALSE;
} }
if (ProcessorFeature == 10) { // PF_XMMI64_INSTRUCTIONS_AVAILABLE (SSE2) if (ProcessorFeature == 10) { // PF_XMMI64_INSTRUCTIONS_AVAILABLE (SSE2)
return TRUE; return TRUE;
} }
if (ProcessorFeature == 23) { // PF_FASTFAIL_AVAILABLE (__fastfail() supported) if (ProcessorFeature == 23) { // PF_FASTFAIL_AVAILABLE (__fastfail)
return TRUE; return FALSE;
} }
DEBUG_LOG(" IsProcessorFeaturePresent: unknown feature %u, returning TRUE\n", ProcessorFeature); DEBUG_LOG(" IsProcessorFeaturePresent: unknown feature %u, returning TRUE\n", ProcessorFeature);
return TRUE; return TRUE;

View File

@@ -61,7 +61,7 @@ BOOL WINAPI GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, CONSOLE_SCREEN_BUF
return TRUE; return TRUE;
} }
BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumberOfCharsToWrite, BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCWSTR lpBuffer, DWORD nNumberOfCharsToWrite,
LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved) { LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved) {
HOST_CONTEXT_GUARD(); HOST_CONTEXT_GUARD();
DEBUG_LOG("WriteConsoleW(%p, %p, %u, %p, %p)\n", hConsoleOutput, lpBuffer, nNumberOfCharsToWrite, DEBUG_LOG("WriteConsoleW(%p, %p, %u, %p, %p)\n", hConsoleOutput, lpBuffer, nNumberOfCharsToWrite,
@@ -77,10 +77,14 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber
auto file = wibo::handles().getAs<FileObject>(hConsoleOutput); auto file = wibo::handles().getAs<FileObject>(hConsoleOutput);
if (file->fd == STDOUT_FILENO || file->fd == STDERR_FILENO) { if (file->fd == STDOUT_FILENO || file->fd == STDERR_FILENO) {
auto str = wideStringToString(static_cast<const uint16_t *>(lpBuffer), static_cast<int>(nNumberOfCharsToWrite)); auto str = wideStringToString(lpBuffer, static_cast<int>(nNumberOfCharsToWrite));
dprintf(file->fd, "%s", str.c_str()); auto io = files::write(file.get(), str.c_str(), str.size(), std::nullopt, true);
if (lpNumberOfCharsWritten) { if (lpNumberOfCharsWritten) {
*lpNumberOfCharsWritten = nNumberOfCharsToWrite; *lpNumberOfCharsWritten = io.bytesTransferred;
}
if (io.unixError != 0) {
setLastError(wibo::winErrorFromErrno(io.unixError));
return FALSE;
} }
return TRUE; return TRUE;
} }

View File

@@ -34,7 +34,7 @@ UINT WINAPI GetConsoleCP();
UINT WINAPI GetConsoleOutputCP(); UINT WINAPI GetConsoleOutputCP();
BOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add); BOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add);
BOOL WINAPI GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, CONSOLE_SCREEN_BUFFER_INFO *lpConsoleScreenBufferInfo); BOOL WINAPI GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, CONSOLE_SCREEN_BUFFER_INFO *lpConsoleScreenBufferInfo);
BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumberOfCharsToWrite, BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCWSTR lpBuffer, DWORD nNumberOfCharsToWrite,
LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved); LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved);
DWORD WINAPI GetConsoleTitleA(LPSTR lpConsoleTitle, DWORD nSize); DWORD WINAPI GetConsoleTitleA(LPSTR lpConsoleTitle, DWORD nSize);
DWORD WINAPI GetConsoleTitleW(LPWSTR lpConsoleTitle, DWORD nSize); DWORD WINAPI GetConsoleTitleW(LPWSTR lpConsoleTitle, DWORD nSize);