void str_wrap_text_lowercase(wchar_t *out, aint maxlen) { if (IS_UNICODE_OS()) { CharLowerBuffW(out, maxlen); } else { blk_copy_fwd(out, to_wstr( to_str(wsptr(out, maxlen)).case_down() ).cstr(), maxlen ); } }
rktio_char16_t *rktio_recase_utf16(rktio_t *rktio, rktio_bool_t to_up, rktio_char16_t *s1, intptr_t l1, intptr_t *olen) { #ifdef MACOS_UNICODE_SUPPORT CFMutableStringRef mstr; CFStringRef str; CFRange rng; rktio_char16_t *result; intptr_t len; str = CFStringCreateWithBytes(NULL, (unsigned char *)s1, (l1 * sizeof(rktio_char16_t)), kCFStringEncodingUnicode, FALSE); mstr = CFStringCreateMutableCopy(NULL, 0, str); CFRelease(str); if (to_up) CFStringUppercase(mstr, NULL); else CFStringLowercase(mstr, NULL); len = CFStringGetLength(mstr); result = malloc((len + 1) * sizeof(rktio_char16_t)); rng = CFRangeMake(0, len); CFStringGetCharacters(mstr, rng, (UniChar *)result); CFRelease(mstr); result[len] = 0; if (olen) *olen = len; return result; #elif defined(RKTIO_SYSTEM_WINDOWS) rktio_char16_t *result; result = malloc((l1 + 1) * sizeof(rktio_char16_t)); memcpy(result, s1, l1 * sizeof(rktio_char16_t)); result[l1] = 0; if (to_up) CharUpperBuffW((wchar_t *)result, l1); else CharLowerBuffW((wchar_t *)result, l1); if (olen) *olen = l1; return result; #else return NULL; #endif }
int strcasecmp(LPCWSTR s1,LPCWSTR s2) { WCHAR *tmp1,*tmp2; int ret; DWORD nLen1=(DWORD)istrlenw(s1); DWORD nLen2=(DWORD)istrlenw(s2); tmp1=new WCHAR[nLen1+2]; if (tmp1==NULL) SetHFCError(HFC_CANNOTALLOC); CopyMemory(tmp1,s1,nLen1*2+2); tmp2=new WCHAR[nLen2+2]; if (tmp2==NULL) SetHFCError(HFC_CANNOTALLOC); CopyMemory(tmp2,s2,nLen2*2+2); CharLowerBuffW(tmp1,nLen1); CharLowerBuffW(tmp2,nLen2); ret=wcscmp(tmp1,tmp2); delete[] tmp1; delete[] tmp2; return ret; }
/* * @implemented */ DWORD WINAPI CharLowerBuffA(LPSTR str, DWORD len) { DWORD lenW; WCHAR *strW; if (!str) return 0; /* YES */ lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0); strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR)); if (strW) { MultiByteToWideChar(CP_ACP, 0, str, len, strW, lenW); CharLowerBuffW(strW, lenW); len = WideCharToMultiByte(CP_ACP, 0, strW, lenW, str, len, NULL, NULL); HeapFree(GetProcessHeap(), 0, strW); return len; } return 0; }
LPWSTR WINAPI CharLowerW( LPWSTR pwsz) { /* * Early out for NULL string or '\0' */ if (pwsz == NULL) { return pwsz; } if (!IS_PTR(pwsz)) { if (!LCMapStringW( LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, (LPWSTR)&pwsz, 1, (LPWSTR)&pwsz, 1 )) { /* * We don't expect LCMapString to fail! The caller is not expecting * failure, CharLowerW does not have a failure indicator, so we do * nothing. */ RIPMSG1(RIP_WARNING, "CharLowerW(%#p): LCMapString failed\n", pwsz); } return pwsz; } /* * pwsz is a null-terminated string */ CharLowerBuffW(pwsz, wcslen(pwsz)+1); return pwsz; }
UnicodeString& UnicodeString::Lower(size_t nStartPos, size_t nLength) { Inflate(m_pData->GetSize()); CharLowerBuffW(m_pData->GetData()+nStartPos, nLength==(size_t)-1?(DWORD)(m_pData->GetLength()-nStartPos):(DWORD)nLength); return *this; }
// cmd.exe only! LONG WINAPI OnRegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData) { //typedef LONG (WINAPI* OnRegQueryValueExW_t)(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData); ORIGINAL_EX(RegQueryValueExW); LONG lRc = -1; if (gbIsCmdProcess && hKey && lpValueName) { // Allow `CD` to network paths if (lstrcmpi(lpValueName, L"DisableUNCCheck") == 0) { if (lpData) { if (lpcbData && *lpcbData >= sizeof(DWORD)) *((LPDWORD)lpData) = gbAllowUncPaths; else *lpData = gbAllowUncPaths; } if (lpType) *lpType = REG_DWORD; if (lpcbData) *lpcbData = sizeof(DWORD); lRc = 0; goto wrap; } if (gbIsCmdProcess && hKey && lpValueName && (lstrcmpi(lpValueName, L"AutoRun") == 0) && InitializeClink()) { if (gbAllowClinkUsage && gszClinkCmdLine && IsInteractive()) { // Is already loaded? if (!IsClinkLoaded() && !gbClinkInjectRequested) { // Do this once, to avoid multiple initializations gbClinkInjectRequested = true; // May be it is set up itself? typedef LONG (WINAPI* RegOpenKeyEx_t)(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult); typedef LONG (WINAPI* RegCloseKey_t)(HKEY hKey); HMODULE hAdvApi = LoadLibrary(L"AdvApi32.dll"); if (hAdvApi) { RegOpenKeyEx_t _RegOpenKeyEx = (RegOpenKeyEx_t)GetProcAddress(hAdvApi, "RegOpenKeyExW"); RegCloseKey_t _RegCloseKey = (RegCloseKey_t)GetProcAddress(hAdvApi, "RegCloseKey"); if (_RegOpenKeyEx && _RegCloseKey) { const DWORD cchMax = 0x3FF0; const DWORD cbMax = cchMax*2; wchar_t* pszCmd = (wchar_t*)malloc(cbMax); if (pszCmd) { DWORD cbSize; bool bClinkInstalled = false; for (int i = 0; i <= 1 && !bClinkInstalled; i++) { HKEY hk; if (_RegOpenKeyEx(i?HKEY_LOCAL_MACHINE:HKEY_CURRENT_USER, L"Software\\Microsoft\\Command Processor", 0, KEY_READ, &hk)) continue; if (!F(RegQueryValueExW)(hk, lpValueName, NULL, NULL, (LPBYTE)pszCmd, &(cbSize = cbMax)) && (cbSize+2) < cbMax) { cbSize /= 2; pszCmd[cbSize] = 0; CharLowerBuffW(pszCmd, cbSize); if (wcsstr(pszCmd, L"\\clink.bat")) bClinkInstalled = true; } _RegCloseKey(hk); } // Not installed via "Autorun" if (!bClinkInstalled) { int iLen = lstrlen(gszClinkCmdLine); _wcscpy_c(pszCmd, cchMax, gszClinkCmdLine); _wcscpy_c(pszCmd+iLen, cchMax-iLen, L" & "); // conveyer next command indifferent to %errorlevel% cbSize = cbMax - (iLen + 3)*sizeof(*pszCmd); if (F(RegQueryValueExW)(hKey, lpValueName, NULL, NULL, (LPBYTE)(pszCmd + iLen + 3), &cbSize) || (pszCmd[iLen+3] == 0)) { pszCmd[iLen] = 0; // There is no self value in registry } cbSize = (lstrlen(pszCmd)+1)*sizeof(*pszCmd); // Return lRc = 0; if (lpData && lpcbData) { if (*lpcbData < cbSize) lRc = ERROR_MORE_DATA; else _wcscpy_c((wchar_t*)lpData, (*lpcbData)/2, pszCmd); } if (lpcbData) *lpcbData = cbSize; free(pszCmd); FreeLibrary(hAdvApi); goto wrap; } free(pszCmd); } } FreeLibrary(hAdvApi); } } } } } if (F(RegQueryValueExW)) lRc = F(RegQueryValueExW)(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData); wrap: return lRc; }
void str_wrap_text_lowercase(wchar_t *out, ZSTRINGS_SIGNED maxlen) { CharLowerBuffW(out, maxlen); }