Forum Discussion
yitam
Nov 29, 2021Former Employee
Found a regression in Windows Server 2022
Found a regression in Windows Server 2022 since evaluating the preview. Have recently installed all the latest updates and the issue is still reproducible. How should we report this issue?
yitam
Nov 29, 2021Former Employee
Sure I have a *.cpp file that you can run to reproduce this issue. Should I simply copy and paste the content here?
Mary Hoffman
Nov 29, 2021Former Employee
Sure.
- yitamNov 29, 2021Former Employee
Mary Hoffman please see the code below. To reproduce, build this cpp file as a console app in Visual Studio (I used VS 2019 but should not matter) first and create a dummy file with the name "¢.¢" (also tested with "£.£"). It works in Windows 10 and some other Windows platforms but failed in Windows Server 2022.
The expected output is shown below (in Windows 10):
AreFileApisANSI() returned 1
cchBytesWritten: 2
fNotMappable: 0
pszFileName: ¢.¢
DeleteFileA() of dummy file returns: 1
DeleteFileA() of ¢.¢ returns: 1
But in Windows Server 2022, deleting the file "¢.¢" failed.// TestVar23.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <stdio.h> #include <iostream> #include <windows.h> #include <string> #include <strsafe.h> void ErrorExit() { // Retrieve the system error message for the last-error code LPVOID lpMsgBuf; LPVOID lpDisplayBuf; DWORD dw = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); // Display the error message and exit the process lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf) + 40) * sizeof(TCHAR)); StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), TEXT("Failed with error code %d: %s"), dw, lpMsgBuf); MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); ExitProcess(dw); } int main() { //WCHAR wch = 0x00A3; // Currency symbol, English Pound (different on ANSI and OEM) WCHAR wch = 0x00A2; // The cent symbol '¢' WCHAR wszFileName[] = { wch, L'.', wch, L'\0' }; WCHAR wszInitString[] = { wch, L'\0' }; BOOL r = AreFileApisANSI(); std::cout << "AreFileApisANSI() returned " << r << std::endl; BOOL fNotMappable = FALSE; WCHAR wszSource[2]; char szDst[5]; // up to 4 bytes for the mappable character, 1 byte for null-terminator ULONG cchBytesWritten = 0; wszSource[0] = wch; wszSource[1] = 0x0000; cchBytesWritten = WideCharToMultiByte(CP_ACP, 0, wszSource, -1, szDst, sizeof(szDst), NULL, &fNotMappable); std::cout << "cchBytesWritten: " << cchBytesWritten << std::endl; std::cout << "fNotMappable: " << fNotMappable << std::endl; CHAR pszDummy[] = "output.txt"; FILE* pfile = nullptr; fopen_s(&pfile, pszDummy, "w"); if (pfile != nullptr) { fprintf(pfile, "This is dummy output\n"); fclose(pfile); } //SetFileApisToANSI(); SetFileApisToOEM(); size_t cLen = wcslen(wszFileName) * sizeof(WCHAR); CHAR pszFileName[100]; UINT CodePage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; INT iResult = WideCharToMultiByte(CodePage, 0, wszFileName, -1, pszFileName, cLen + 1, NULL, NULL); std::cout << "pszFileName: " << pszFileName << std::endl; BOOL d1 = DeleteFileA(pszDummy); std::cout << "DeleteFileA() of dummy file returns: " << d1 << std::endl; BOOL d2 = DeleteFileA(pszFileName); std::cout << "DeleteFileA() of " << pszFileName << " returns: " << d2 << std::endl; ErrorExit(); }- yitamDec 03, 2021Former Employee
Mary Hoffman is there any update? Just wondering. Thanks!
- Mary HoffmanDec 03, 2021Former EmployeeI've forwarded this on to the appropriate team and they are investigating. I don't have any further updates yet. Thanks for your patience.