void FixAutoplay( LPCWSTR wszApplicationName, LPCWSTR wszCommandLine, LPCWSTR wszCurrentDirectory ) { LPCWSTR uppApplicationName = _wcsupr( _wcsdup( wszApplicationName ) ); // only UT2004 if( wcsstr(uppApplicationName,L"UT2004.EXE") == NULL ) return; // read mod name from commandline, must be specified LPCWSTR uppCommandLine = _wcsupr( _wcsdup( wszCommandLine ) ); LPWSTR pb = wcsstr(uppCommandLine,L"-MOD="); if( pb == NULL ) return; // mod name must be valid LPWSTR ps = pb + wcslen(L"-MOD="); LPWSTR token = wcstok( ps, L" " ); if( token == NULL ) return; // mod directory must be valid if( !SetCurrentDirectoryW(wszCurrentDirectory) || !SetCurrentDirectoryW(L"..") || !SetCurrentDirectoryW(token) ) return; // copy Autoplay.ut2 if( !CopyFileW( L"..\\Maps\\Autoplay.ut2", L"Maps\\Autoplay.ut2", FALSE ) ) return; //MessageBox( NULL, TEXT("Copy OK"), TEXT("SwAutoplayFix"), MB_OK ); }
local int FSusesLocalTimeW(const wchar_t *path) { wchar_t *tmp0; wchar_t rootPathName[4]; wchar_t tmp1[MAX_PATH], tmp2[MAX_PATH]; DWORD volSerNo, maxCompLen, fileSysFlags; #if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ wchar_t *ansi_path = (wchar_t *)alloca((wcslen(path) + 1) * sizeof(wchar_t)); CharToAnsiW(path, ansi_path); path = ansi_path; #endif if (iswalpha(path[0]) && (path[1] == (wchar_t)':')) tmp0 = (wchar_t *)path; else { GetFullPathNameW(path, MAX_PATH, tmp1, &tmp0); tmp0 = &tmp1[0]; } wcsncpy(rootPathName, tmp0, 3); /* Build the root path name, */ rootPathName[3] = (wchar_t)'\0'; /* e.g. "A:/" */ GetVolumeInformationW(rootPathName, tmp1, (DWORD)MAX_PATH, &volSerNo, &maxCompLen, &fileSysFlags, tmp2, (DWORD)MAX_PATH); /* Volumes in (V)FAT and (OS/2) HPFS format store file timestamps in * local time! */ return !wcsncmp(_wcsupr(tmp2), L"FAT", 3) || !wcsncmp(tmp2, L"VFAT", 4) || !wcsncmp(tmp2, L"HPFS", 4); } /* end function FSusesLocalTimeW() */
// --------------------------------------------------------------------------- // CPMapEntry: Constructors and Destructor // --------------------------------------------------------------------------- CPMapEntry::CPMapEntry( const char* const encodingName , const unsigned int cpId , const unsigned int ieId) : fEncodingName(0) , fCPId(cpId) , fIEId(ieId) { // Transcode the name to Unicode and store that copy const unsigned int srcLen = strlen(encodingName); const unsigned charLen = ::mblen(encodingName, MB_CUR_MAX); if (charLen != -1) { const unsigned int targetLen = srcLen/charLen; fEncodingName = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate ( (targetLen + 1) * sizeof(XMLCh) );//new XMLCh[targetLen + 1]; ::mbstowcs(fEncodingName, encodingName, srcLen); fEncodingName[targetLen] = 0; // // Upper case it because we are using a hash table and need to be // sure that we find all case combinations. // _wcsupr(fEncodingName); } }
wchar_t * _wcsupr( IN wchar_t * string ) { return (_wcsupr(string)); } // _wcsupr
XMLTranscoder* Win32TransService::makeNewXMLTranscoder(const XMLCh* const encodingName , XMLTransService::Codes& resValue , const XMLSize_t blockSize , MemoryManager* const manager) { const XMLSize_t upLen = 1024; XMLCh upEncoding[upLen + 1]; // // Get an upper cased copy of the encoding name, since we use a hash // table and we store them all in upper case. // XMLString::copyNString(upEncoding, encodingName, upLen); _wcsupr(upEncoding); // Now to try to find this guy in the CP map CPMapEntry* theEntry = fCPMap->get(upEncoding); // If not found, then return a null pointer if (!theEntry) { resValue = XMLTransService::UnsupportedEncoding; return 0; } // We found it, so return a Win32 transcoder for this encoding return new (manager) Win32Transcoder ( encodingName , theEntry->getIEEncoding() , blockSize , manager ); }
// --------------------------------------------------------------------------- // CPMapEntry: Constructors and Destructor // --------------------------------------------------------------------------- CPMapEntry::CPMapEntry( const char* const encodingName , const unsigned int ieId , MemoryManager* manager) : fEncodingName(0) , fIEId(ieId) , fManager(manager) { // Transcode the name to Unicode and store that copy int targetLen=::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, encodingName, -1, NULL, 0); if(targetLen!=0) { fEncodingName = (XMLCh*) fManager->allocate ( (targetLen + 1) * sizeof(XMLCh) );//new XMLCh[targetLen + 1]; ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, encodingName, -1, (LPWSTR)fEncodingName, targetLen); fEncodingName[targetLen] = 0; // // Upper case it because we are using a hash table and need to be // sure that we find all case combinations. // _wcsupr(fEncodingName); } }
EXPORT BOOL CALLBACK AddStringW (PCWSTR pStringIn) { PWSTR pString ; int i, iLength ; if (iTotal == MAX_STRINGS - 1) return FALSE ; if ((iLength = wcslen (pStringIn)) == 0) return FALSE ; // Allocate memory for storing string, copy it, convert to upper case pString = malloc (sizeof (WCHAR) * (1 + iLength)) ; wcscpy (pString, pStringIn) ; _wcsupr (pString) ; // Alphabetize the strings for (i = iTotal ; i > 0 ; i--) { if (wcscmp (pString, szStrings[i - 1]) >= 0) break ; wcscpy (szStrings[i], szStrings[i - 1]) ; } wcscpy (szStrings[i], pString) ; iTotal++ ; free (pString) ; return TRUE ; }
/* * @implemented */ void CHString::MakeUpper() throw (CHeap_Exception) { // We'll modify string, duplicate it first if needed CopyBeforeWrite(); // Let's use appropriate helper _wcsupr(m_pchData); }
static BOOLEAN NTAPI EnumModulesCallback( _In_ PPH_MODULE_INFO Module, _In_opt_ PVOID Context ) { PPH_STRING upperFileName; upperFileName = PhDuplicateString(Module->FileName); _wcsupr(upperFileName->Buffer); if (MatchSearchString(&upperFileName->sr) || (UseSearchPointer && Module->BaseAddress == (PVOID)SearchPointer)) { PPHP_OBJECT_SEARCH_RESULT searchResult; PWSTR typeName; switch (Module->Type) { case PH_MODULE_TYPE_MAPPED_FILE: typeName = L"Mapped file"; break; case PH_MODULE_TYPE_MAPPED_IMAGE: typeName = L"Mapped image"; break; default: typeName = L"DLL"; break; } searchResult = PhAllocate(sizeof(PHP_OBJECT_SEARCH_RESULT)); searchResult->ProcessId = (HANDLE)Context; searchResult->ResultType = (Module->Type == PH_MODULE_TYPE_MAPPED_FILE || Module->Type == PH_MODULE_TYPE_MAPPED_IMAGE) ? MappedFileSearchResult : ModuleSearchResult; searchResult->Handle = (HANDLE)Module->BaseAddress; searchResult->TypeName = PhCreateString(typeName); PhSetReference(&searchResult->Name, Module->FileName); PhPrintPointer(searchResult->HandleString, Module->BaseAddress); memset(&searchResult->Info, 0, sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX)); PhAcquireQueuedLockExclusive(&SearchResultsLock); PhAddItemList(SearchResults, searchResult); // Update the search results in batches of 40. if (SearchResults->Count % 40 == 0) PostMessage(PhFindObjectsWindowHandle, WM_PH_SEARCH_UPDATE, 0, 0); PhReleaseQueuedLockExclusive(&SearchResultsLock); } PhDereferenceObject(upperFileName); return TRUE; }
std::wstring toUpper(std::wstring a) { #ifdef _WIN32 return _wcsupr(const_cast<wchar_t *>(a.c_str())); #else std::wstring ret; for (int i = 0; i < (int)a.length(); i++) { wchar_t c = towupper(a[i]); ret += c; } return ret; #endif }
var& var::operator+=(const wstring& rhs) { wstring s; if(vt == STR) { wstring s=rhs; if (UnquoteString(s,'#','#')) { if (!isbuf) { //String + buf Hex Buffer to String ok size_t len=s.length()/2; wchar_t* buf = (wchar_t*)malloc(len*2+1); Str2Rgch(s,buf,len+1); s.assign(buf,len); str += s; size += len; free(buf); } else { // Buffer + Buffer str = L"#"+str.substr(1,str.length()-2)+s+L"#"; size += s.length()/2; } } else { if (!isbuf) { //str + str str += rhs; size += rhs.length(); } else { //buf + str wstring Hex; Str2Hex(s,Hex,s.length()); str = L"#"+str.substr(1,str.length()-2)+Hex+L"#"; size += s.length(); } } } else if(vt == DW) { var v=(wstring)rhs; wchar_t dwbuf[12]; if (v.isbuf) { //ulong + BUFFER >> CONCATE HEX s = strbuffhex(); wsprintf(dwbuf, L"%08X",dw); *this = L"#"+((wstring)dwbuf)+s+L"#"; } else { //ulong + STRING >> CONCATE _ultow+str s = _wcsupr(_ultow(dw, dwbuf, 16)); *this = s+v.str; } } return *this; }
BOOL IsThisAValidTransport(wchar_t *transport) { _wcsupr(transport); if( (wcscmp(transport,L"REVERSE_TCP") == 0) || (wcscmp(transport,L"BIND_TCP") == 0) || (wcscmp(transport,L"REVERSE_HTTP") == 0) || (wcscmp(transport,L"REVERSE_HTTPS") == 0) || (wcscmp(transport,L"REVERSE_METSVC") == 0) || (wcscmp(transport,L"BIND_METSVC") == 0) ) return true; return false; }
BOOL CFolder::OnInitDialog() { CDialog::OnInitDialog(); HTREEITEM hPar; CString csTitle; DWORD dwLen; DWORD i; int nType; WCHAR *p; WCHAR szLetter[4]; WCHAR szDrivesLetter[MAX_PATH]; CBitmap Bitmap; if (m_bShowFile) { csTitle.LoadString(IDS_SELECT_FILE_OR_DIR); SetWindowText(csTitle); } Bitmap.LoadBitmap(IDB_TREE); m_ImageList.Create(16,16,ILC_COLOR16,0,10); m_ImageList.Add(&Bitmap, RGB(0,0,0)); m_Tree.SetImageList(&m_ImageList, TVSIL_NORMAL); dwLen = GetLogicalDriveStrings(0,NULL); ::GetLogicalDriveStrings(dwLen,szDrivesLetter); _wcsupr( szDrivesLetter ); p = szDrivesLetter; dwLen = dwLen/4; for(i = 0;i<dwLen;i++) { wcscpy(szLetter,p); //szLetter[2] = 0; nType = GetLetterType(szLetter); szLetter[2] = 0; if (nType < 7) { hPar = m_Tree.InsertItem(szLetter, nType, nType); m_Tree.SetItemData(hPar, 1); CreateFolder(szLetter, &m_Tree, hPar); m_Tree.SortChildren(hPar); } p += 4; } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
std::wstring CGroup::CreateGroup(const std::wstring& str) { std::wstring strTmp; std::wstring::size_type pos = str.find_first_not_of(L" \t\r\n"); if (pos != std::wstring::npos) { // Trim white-space strTmp.assign(str, pos, str.find_last_not_of(L" \t\r\n") - pos + 1); _wcsupr(&strTmp[0]); } return strTmp; }
void __fastcall GetIconsIndexesW(LPWSTR wszMirVer, short *base, short *overlay, short *overlay2, short *overlay3, short *overlay4) { if (mir_wstrcmp(wszMirVer, L"?") == 0) { *base = UNKNOWN_MASK_NUMBER; *overlay = -1; *overlay2 = -1; *overlay3 = -1; *overlay4 = -1; return; } LPWSTR wszMirVerUp = NEWWSTR_ALLOCA(wszMirVer); _wcsupr(wszMirVerUp); MatchMasks(wszMirVerUp, base, overlay, overlay2, overlay3, overlay4); }
static INT_PTR ServiceGetClientDescrW(WPARAM wParam, LPARAM) { LPWSTR wszMirVer = (LPWSTR)wParam; // MirVer value to get client for. if (wszMirVer == NULL) return 0; LPWSTR wszMirVerUp = NEWWSTR_ALLOCA(wszMirVer); _wcsupr(wszMirVerUp); if (mir_wstrcmp(wszMirVerUp, L"?") == 0) return (INT_PTR)def_kn_fp_mask[UNKNOWN_MASK_NUMBER].szClientDescription; for (int index = 0; index < DEFAULT_KN_FP_MASK_COUNT; index++) if (WildCompareW(wszMirVerUp, def_kn_fp_mask[index].szMaskUpper)) return (INT_PTR)def_kn_fp_mask[index].szClientDescription; return NULL; }
CPMapEntry::CPMapEntry( const XMLCh* const encodingName , const unsigned int cpId , const unsigned int ieId) : fEncodingName(0) , fCPId(cpId) , fIEId(ieId) { fEncodingName = XMLString::replicate(encodingName, XMLPlatformUtils::fgMemoryManager); // // Upper case it because we are using a hash table and need to be // sure that we find all case combinations. // _wcsupr(fEncodingName); }
/* For reading in resource names and types. */ int GetNameOrd() { PWCHAR pch; int fString; /* get space delimited string */ if (!GetGenText()) return FALSE; /* convert to upper case */ _wcsupr(tokenbuf); /* is it a string or number */ for (pch=tokenbuf,fString=0 ; *pch ; pch++ ) if (!iswdigit(*pch)) fString = 1; /* determine if ordinal */ if (tokenbuf[0] == L'0' && tokenbuf[1] == L'X') { int HexNum; int inc; USHORT wCount; PWCHAR s; HexNum = 0; s = &tokenbuf[2]; for (wCount = 4 ; wCount && iswxdigit(*s) ; --wCount) { if (*s >= L'A') inc = *s - L'A' + 10; else inc = *s - L'0'; HexNum = HexNum * 16 + inc; s++; } token.val = (USHORT)HexNum; } else if (fString) { token.val = 0; } else { token.val = (USHORT)wcsatoi(tokenbuf); } return TRUE; }
void _log( wchar_t *pws_message, ... ) { PROCESS_BASIC_INFORMATION pbi; int last_error = GetLastError( ); wchar_t ws_args[MAX_PATH] = { 0 }; wchar_t ws_line[MAX_PATH] = { 0 }; HANDLE h_file; DWORD bytes; va_list args; static int count = 0; wchar_t ws_name[MAX_PATH]; NTSTATUS status; status = NtQueryInformationProcess( GetCurrentProcess( ), ProcessBasicInformation, &pbi, sizeof(pbi), NULL ); { _snwprintf( ws_name, sizeof_w(ws_name), L"dcrypt_%d.log", status == 0 ? pbi.UniqueProcessId : 0 ); } h_file = CreateFile( ws_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, count == 0 ? CREATE_ALWAYS : OPEN_ALWAYS, 0, NULL ); if ( h_file == INVALID_HANDLE_VALUE ) return; if ( SetFilePointer(h_file, 0, 0, FILE_END) != INVALID_SET_FILE_POINTER ) { va_start( args, pws_message ); if ( pws_message != NULL ) { _vsnwprintf( ws_args, sizeof_w(ws_line), pws_message, args ); } va_end( args ); _snwprintf( ws_line, sizeof_w(ws_line), L"line:%0.4X last error:%0.8X message:%s\r\n", count++, last_error, ws_args ); WriteFile( h_file, _wcsupr(ws_line), d32(wcslen(ws_line) * sizeof(wchar_t)), &bytes, NULL ); CloseHandle(h_file); } }
// S_OK : 성공 // S_FALSE : 데이터는 가져왔지만 Consumer가 원하는 데이터가 아님 // E_FAIL : 실패 static HRESULT FetchData(int hReq, CTABLESRow &trData, int table_type) { char *name; int type, ind, res; T_CCI_ERROR err_buf; res = cci_fetch(hReq, &err_buf); if(res<0) return RaiseError(E_FAIL, 1, __uuidof(IDBSchemaRowset), err_buf.err_msg); res = cci_get_data(hReq, 1, CCI_A_TYPE_STR, &name, &ind); if(res<0) return RaiseError(E_FAIL, 0, __uuidof(IDBSchemaRowset)); CA2W nametmp(name); wcsncpy(trData.m_szTable, nametmp, 128); trData.m_szTable[128] = 0; _wcsupr(trData.m_szTable); res = cci_get_data(hReq, 2, CCI_A_TYPE_INT, &type, &ind); if(res<0) return RaiseError(E_FAIL, 0, __uuidof(IDBSchemaRowset)); if((type==0 && (table_type & TABLE_TYPE_SYSTEM)) || (type==1 && (table_type & TABLE_TYPE_VIEW)) || (type==2 && (table_type & TABLE_TYPE_TABLE))) { switch(type) { case 0: wcscpy(trData.m_szType, L"SYSTEM TABLE"); wcscpy(trData.m_szDesc, L"System Class"); break; case 1: wcscpy(trData.m_szType, L"VIEW"); wcscpy(trData.m_szDesc, L"Virtual Class"); break; case 2: wcscpy(trData.m_szType, L"TABLE"); wcscpy(trData.m_szDesc, L"Class"); break; } } else return S_FALSE; return S_OK; }
PWSTR Uppercase( PCWSTR Id ) { size_t Length; PWSTR Dup; if (((size_t) Id) <= MAXUSHORT) { return (PWSTR) Id; } Length = ((wcslen(Id) + 1) * sizeof(WCHAR)); Dup = (PWSTR) malloc(Length); CopyMemory(Dup, Id, Length); #if 0 // try this either way -- no luck _wcsupr(Dup); #endif return Dup; }
BOOL AppendSystemPostfix(LPWSTR lpName, DWORD dwMaxLength) { WCHAR szSystemRoot[MAX_PATH]; LPWSTR lpszPostfix; LPWSTR lpszPtr; /* Build profile name postfix */ if (!ExpandEnvironmentStringsW(L"%SystemRoot%", szSystemRoot, MAX_PATH)) { DPRINT1("Error: %lu\n", GetLastError()); return FALSE; } _wcsupr(szSystemRoot); /* Get name postfix */ szSystemRoot[2] = L'.'; lpszPostfix = &szSystemRoot[2]; lpszPtr = lpszPostfix; while (*lpszPtr != (WCHAR)0) { if (*lpszPtr == L'\\') *lpszPtr = '_'; lpszPtr++; } if (wcslen(lpName) + wcslen(lpszPostfix) + 1 >= dwMaxLength) { DPRINT1("Error: buffer overflow\n"); SetLastError(ERROR_BUFFER_OVERFLOW); return FALSE; } wcscat(lpName, lpszPostfix); return TRUE; }
var& var::operator+=(const ulong& rhs) { if(vt == DW) dw += rhs; else if(vt == FLT) flt += rhs; else if(vt == STR) { wstring s; wchar_t dwbuf[12]; if (isbuf) { //Concate Num ulong to a buffer (4 octets) s = strbuffhex(); wsprintf(dwbuf, L"%08X",rev(rhs)); *this = L"#" + s + dwbuf + L"#"; } else { //Add Number to a String s = _wcsupr(_ultow(rhs, dwbuf, 16)); str += s; size += s.length(); } } return *this; }
NET_API_STATUS NET_API_FUNCTION NetrRplVendorDel( IN RPL_HANDLE ServerHandle, IN LPWSTR VendorName ) /*++ If VendorName is provided then delete matching record, else delete all adapter records. --*/ { DWORD Error; PRPL_SESSION pSession = &RG_ApiSession; if ( !ValidHexName( VendorName, RPL_VENDOR_NAME_LENGTH, TRUE)) { return( ERROR_INVALID_PARAMETER); } _wcsupr( VendorName); EnterCriticalSection( &RG_ProtectDatabase); Call( JetBeginTransaction( pSession->SesId)); if ( !RplFind( pSession, VENDOR_TABLE_TAG, VendorName)) { Error = NERR_RplVendorNotFound; goto cleanup; } CallJ( JetDelete( pSession->SesId, pSession->VendorTableId)); Error = NO_ERROR; cleanup: if ( Error == NO_ERROR) { Call( JetCommitTransaction( pSession->SesId, JET_bitCommitFlush)); } else { Call( JetRollback( pSession->SesId, JET_bitRollbackAll)); } LeaveCriticalSection( &RG_ProtectDatabase); return( Error); }
void CCOMStringW::MakeUpper() { _wcsupr(m_pszString); }
static VOID InsertFileType(HWND hDlgCtrl, WCHAR * szName, PINT iItem, WCHAR * szFile) { PFOLDER_FILE_TYPE_ENTRY Entry; HKEY hKey; LVITEMW lvItem; DWORD dwSize; if (szName[0] != L'.') { /* FIXME handle URL protocol handlers */ return; } /* allocate file type entry */ Entry = (PFOLDER_FILE_TYPE_ENTRY)HeapAlloc(GetProcessHeap(), 0, sizeof(FOLDER_FILE_TYPE_ENTRY)); if (!Entry) return; /* open key */ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szName, 0, KEY_READ, &hKey) != ERROR_SUCCESS) { HeapFree(GetProcessHeap(), 0, Entry); return; } /* FIXME check for duplicates */ /* query for the default key */ dwSize = sizeof(Entry->ClassKey); if (RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)Entry->ClassKey, &dwSize) != ERROR_SUCCESS) { /* no link available */ Entry->ClassKey[0] = 0; } if (Entry->ClassKey[0]) { HKEY hTemp; /* try open linked key */ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, Entry->ClassKey, 0, KEY_READ, &hTemp) == ERROR_SUCCESS) { /* use linked key */ RegCloseKey(hKey); hKey = hTemp; } } /* read friendly type name */ if (RegLoadMUIStringW(hKey, L"FriendlyTypeName", Entry->FileDescription, sizeof(Entry->FileDescription), NULL, 0, NULL) != ERROR_SUCCESS) { /* read file description */ dwSize = sizeof(Entry->FileDescription); Entry->FileDescription[0] = 0; /* read default key */ RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)Entry->FileDescription, &dwSize); } /* close key */ RegCloseKey(hKey); /* convert extension to upper case */ wcscpy(Entry->FileExtension, szName); _wcsupr(Entry->FileExtension); if (!Entry->FileDescription[0]) { /* construct default 'FileExtensionFile' */ wcscpy(Entry->FileDescription, &Entry->FileExtension[1]); wcscat(Entry->FileDescription, L" "); wcscat(Entry->FileDescription, szFile); } ZeroMemory(&lvItem, sizeof(LVITEMW)); lvItem.mask = LVIF_TEXT | LVIF_PARAM; lvItem.iSubItem = 0; lvItem.pszText = &Entry->FileExtension[1]; lvItem.iItem = *iItem; lvItem.lParam = (LPARAM)Entry; (void)SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&lvItem); ZeroMemory(&lvItem, sizeof(LVITEMW)); lvItem.mask = LVIF_TEXT; lvItem.pszText = Entry->FileDescription; lvItem.iItem = *iItem; lvItem.iSubItem = 1; (void)SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&lvItem); (*iItem)++; }
void Win32TransService::upperCase(XMLCh* const toUpperCase) const { _wcsupr(toUpperCase); }
// --------------------------------------------------------------------------- // Win32TransService: Constructors and Destructor // --------------------------------------------------------------------------- Win32TransService::Win32TransService() { fCPMap = new RefHashTableOf<CPMapEntry>(109); // // Open up the registry key that contains the info we want. Note that, // if this key does not exist, then we just return. It will just mean // that we don't have any support except for intrinsic encodings supported // by the parser itself (and the LCP support of course. // HKEY charsetKey; if (::RegOpenKeyExA ( HKEY_CLASSES_ROOT , "MIME\\Database\\Charset" , 0 , KEY_READ , &charsetKey)) { return; } // // Read in the registry keys that hold the code page ids. Skip for now // those entries which indicate that they are aliases for some other // encodings. We'll come back and do a second round for those and look // up the original name and get the code page id. // // Note that we have to use A versions here so that this will run on // 98, and transcode the strings to Unicode. // const unsigned int nameBufSz = 1024; char nameBuf[nameBufSz + 1]; unsigned int subIndex; unsigned long theSize; for (subIndex = 0;;++subIndex) { // Get the name of the next key theSize = nameBufSz; if (::RegEnumKeyExA ( charsetKey , subIndex , nameBuf , &theSize , 0, 0, 0, 0) == ERROR_NO_MORE_ITEMS) { break; } // Open this subkey HKEY encodingKey; if (::RegOpenKeyExA ( charsetKey , nameBuf , 0 , KEY_READ , &encodingKey)) { continue; } // // Lts see if its an alias. If so, then ignore it in this first // loop. Else, we'll add a new entry for this one. // if (!isAlias(encodingKey)) { // // Lets get the two values out of this key that we are // interested in. There should be a code page entry and an // IE entry. // unsigned long theType; unsigned int CPId; unsigned int IEId; theSize = sizeof(unsigned int); if (::RegQueryValueExA ( encodingKey , "Codepage" , 0 , &theType , (unsigned char*)&CPId , &theSize) != ERROR_SUCCESS) { ::RegCloseKey(encodingKey); continue; } // // If this is not a valid Id, and it might not be because its // not loaded on this system, then don't take it. // if (::IsValidCodePage(CPId)) { theSize = sizeof(unsigned int); if (::RegQueryValueExA ( encodingKey , "InternetEncoding" , 0 , &theType , (unsigned char*)&IEId , &theSize) != ERROR_SUCCESS) { ::RegCloseKey(encodingKey); continue; } CPMapEntry* newEntry = new CPMapEntry(nameBuf, CPId, IEId); fCPMap->put((void*)newEntry->getEncodingName(), newEntry); } } // And close the subkey handle ::RegCloseKey(encodingKey); } // // Now loop one more time and this time we do just the aliases. For // each one we find, we look up that name in the map we've already // built and add a new entry with this new name and the same id // values we stored for the original. // char aliasBuf[nameBufSz + 1]; for (subIndex = 0;;++subIndex) { // Get the name of the next key theSize = nameBufSz; if (::RegEnumKeyExA ( charsetKey , subIndex , nameBuf , &theSize , 0, 0, 0, 0) == ERROR_NO_MORE_ITEMS) { break; } // Open this subkey HKEY encodingKey; if (::RegOpenKeyExA ( charsetKey , nameBuf , 0 , KEY_READ , &encodingKey)) { continue; } // // If its an alias, look up the name in the map. If we find it, // then construct a new one with the new name and the aliased // ids. // if (isAlias(encodingKey, aliasBuf, nameBufSz)) { const unsigned int srcLen = strlen(aliasBuf); const unsigned charLen = ::mblen(aliasBuf, MB_CUR_MAX); if (charLen != -1) { const unsigned int targetLen = srcLen/charLen; XMLCh* uniAlias = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate ( (targetLen + 1) * sizeof(XMLCh) );//new XMLCh[targetLen + 1]; ::mbstowcs(uniAlias, aliasBuf, srcLen); uniAlias[targetLen] = 0; _wcsupr(uniAlias); // Look up the alias name CPMapEntry* aliasedEntry = fCPMap->get(uniAlias); if (aliasedEntry) { const unsigned int srcLen = strlen(nameBuf); const unsigned charLen = ::mblen(nameBuf, MB_CUR_MAX); const unsigned int targetLen = srcLen/charLen; XMLCh* uniName = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate ( (targetLen + 1) * sizeof(XMLCh) );//new XMLCh[targetLen + 1]; ::mbstowcs(uniName, nameBuf, srcLen); uniName[targetLen] = 0; _wcsupr(uniName); // // If the name is actually different, then take it. // Otherwise, don't take it. They map aliases that are // just different case. // if (::wcscmp(uniName, aliasedEntry->getEncodingName())) { CPMapEntry* newEntry = new CPMapEntry(uniName, aliasedEntry->getWinCP(), aliasedEntry->getIEEncoding()); fCPMap->put((void*)newEntry->getEncodingName(), newEntry); } XMLPlatformUtils::fgMemoryManager->deallocate(uniName);//delete [] uniName; } XMLPlatformUtils::fgMemoryManager->deallocate(uniAlias);//delete [] uniAlias; } } // And close the subkey handle ::RegCloseKey(encodingKey); } // And close the main key handle ::RegCloseKey(charsetKey); }
BOOLEAN NTAPI PhpCommandLineOptionCallback( _In_opt_ PPH_COMMAND_LINE_OPTION Option, _In_opt_ PPH_STRING Value, _In_opt_ PVOID Context ) { ULONG64 integer; if (Option) { switch (Option->Id) { case PH_ARG_SETTINGS: PhSwapReference(&PhStartupParameters.SettingsFileName, Value); break; case PH_ARG_NOSETTINGS: PhStartupParameters.NoSettings = TRUE; break; case PH_ARG_SHOWVISIBLE: PhStartupParameters.ShowVisible = TRUE; break; case PH_ARG_SHOWHIDDEN: PhStartupParameters.ShowHidden = TRUE; break; case PH_ARG_COMMANDMODE: PhStartupParameters.CommandMode = TRUE; break; case PH_ARG_COMMANDTYPE: PhSwapReference(&PhStartupParameters.CommandType, Value); break; case PH_ARG_COMMANDOBJECT: PhSwapReference(&PhStartupParameters.CommandObject, Value); break; case PH_ARG_COMMANDACTION: PhSwapReference(&PhStartupParameters.CommandAction, Value); break; case PH_ARG_COMMANDVALUE: PhSwapReference(&PhStartupParameters.CommandValue, Value); break; case PH_ARG_RUNASSERVICEMODE: PhSwapReference(&PhStartupParameters.RunAsServiceMode, Value); break; case PH_ARG_NOKPH: PhStartupParameters.NoKph = TRUE; break; case PH_ARG_INSTALLKPH: PhStartupParameters.InstallKph = TRUE; break; case PH_ARG_UNINSTALLKPH: PhStartupParameters.UninstallKph = TRUE; break; case PH_ARG_DEBUG: PhStartupParameters.Debug = TRUE; break; case PH_ARG_HWND: if (PhStringToInteger64(&Value->sr, 16, &integer)) PhStartupParameters.WindowHandle = (HWND)(ULONG_PTR)integer; break; case PH_ARG_POINT: { PH_STRINGREF xString; PH_STRINGREF yString; if (PhSplitStringRefAtChar(&Value->sr, ',', &xString, &yString)) { LONG64 x; LONG64 y; if (PhStringToInteger64(&xString, 10, &x) && PhStringToInteger64(&yString, 10, &y)) { PhStartupParameters.Point.x = (LONG)x; PhStartupParameters.Point.y = (LONG)y; } } } break; case PH_ARG_SHOWOPTIONS: PhStartupParameters.ShowOptions = TRUE; break; case PH_ARG_PHSVC: PhStartupParameters.PhSvc = TRUE; break; case PH_ARG_NOPLUGINS: PhStartupParameters.NoPlugins = TRUE; break; case PH_ARG_NEWINSTANCE: PhStartupParameters.NewInstance = TRUE; break; case PH_ARG_ELEVATE: PhStartupParameters.Elevate = TRUE; break; case PH_ARG_SILENT: PhStartupParameters.Silent = TRUE; break; case PH_ARG_HELP: PhStartupParameters.Help = TRUE; break; case PH_ARG_SELECTPID: if (PhStringToInteger64(&Value->sr, 0, &integer)) PhStartupParameters.SelectPid = (ULONG)integer; break; case PH_ARG_PRIORITY: if (PhEqualString2(Value, L"r", TRUE)) PhStartupParameters.PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME; else if (PhEqualString2(Value, L"h", TRUE)) PhStartupParameters.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH; else if (PhEqualString2(Value, L"n", TRUE)) PhStartupParameters.PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL; else if (PhEqualString2(Value, L"l", TRUE)) PhStartupParameters.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE; break; case PH_ARG_PLUGIN: if (!PhStartupParameters.PluginParameters) PhStartupParameters.PluginParameters = PhCreateList(3); PhReferenceObject(Value); PhAddItemList(PhStartupParameters.PluginParameters, Value); break; case PH_ARG_SELECTTAB: PhSwapReference(&PhStartupParameters.SelectTab, Value); break; } } else { PPH_STRING upperValue; upperValue = PhDuplicateString(Value); _wcsupr(upperValue->Buffer); if (PhFindStringInString(upperValue, 0, L"TASKMGR.EXE") != -1) { // User probably has Process Hacker replacing Task Manager. Force // the main window to start visible. PhStartupParameters.ShowVisible = TRUE; } PhDereferenceObject(upperValue); } return TRUE; }
wchar_t* wchar_traits::StrUpper( wchar_t* psz ) { return _wcsupr(psz); }