HRESULT GetTokenFromPublicKey(SBuffer &publicKeyBLOB, SBuffer &publicKeyTokenBLOB) { HRESULT hr = S_OK; BINDER_LOG_ENTER(W("GetTokenFromPublicKey")); const BYTE *pByteKey = publicKeyBLOB; DWORD dwKeyLen = publicKeyBLOB.GetSize(); BYTE *pByteToken = NULL; DWORD dwTokenLen = 0; if (!StrongNameTokenFromPublicKey(const_cast<BYTE *>(pByteKey), dwKeyLen, &pByteToken, &dwTokenLen)) { BINDER_LOG(W("StrongNameTokenFromPublicKey failed!")); IF_FAIL_GO(StrongNameErrorInfo()); } else { _ASSERTE(pByteToken != NULL); publicKeyTokenBLOB.Set(pByteToken, dwTokenLen); StrongNameFreeBuffer(pByteToken); } Exit: BINDER_LOG_LEAVE_HR(W("GetTokenFromPublicKey"), hr); return hr; }
HRESULT BindingLog::Flush() { HRESULT hr = S_OK; BINDER_LOG_ENTER(L"BindingLog::Flush"); hr = GetDebugLog()->Flush(0, FUSION_BIND_LOG_CATEGORY_DEFAULT); if (hr == E_ACCESSDENIED) { // We've been impersonated differently and have a old log entry BINDER_LOG(L"Impersonated: E_ACCESSDENIED"); hr = S_OK; } BINDER_LOG_LEAVE_HR(L"BindingLog::Flush", hr); return hr; }
StringLexer::LEXEME_TYPE StringLexer::ParseString(SString ¤tString, BOOL fPermitUnescapedQuotes) { BOOL fIsFirstCharacter = TRUE; WCHAR wcCurrentChar = INVALID_CHARACTER; WCHAR wcOpeningQuote = INVALID_CHARACTER; currentString.Clear(); // Read until we find another lexeme that's not a string character for (;;) { BOOL fIsEscaped = FALSE; wcCurrentChar = PopCharacter(&fIsEscaped); if (wcCurrentChar == INVALID_CHARACTER) { // Found invalid character encoding BINDER_LOG(L"StringLexer::ParseString: Invalid character encoding"); return LEXEME_TYPE_INVALID; } if (IsEOS(wcCurrentChar)) { if (IsQuoteCharacter(wcOpeningQuote)) { // EOS and unclosed quotes is an error BINDER_LOG(L"StringLexer::ParseString: EOS and unclosed quotes"); return LEXEME_TYPE_INVALID; } else { // Reached end of input and therefore of string break; } } if (fIsFirstCharacter) { fIsFirstCharacter = FALSE; // If first character is quote, then record its quoteness if (IsQuoteCharacter(wcCurrentChar)) { wcOpeningQuote = wcCurrentChar; continue; } } if (wcCurrentChar == wcOpeningQuote) { // We've found the closing quote for a quoted string break; } if (!fPermitUnescapedQuotes && !fIsEscaped && IsQuoteCharacter(wcCurrentChar) && !IsQuoteCharacter(wcOpeningQuote)) { // Unescaped quotes in the middle of the string are an error BINDER_LOG(L"StringLexer::ParseString: Quote in the middle of a string"); return LEXEME_TYPE_INVALID; } if (IsSeparatorChar(wcCurrentChar) && !IsQuoteCharacter(wcOpeningQuote) && !fIsEscaped) { // Unescaped separator char terminates the string PushCharacter(wcCurrentChar, fIsEscaped); break; } // Add character to current string currentString.Append(wcCurrentChar); } if (!IsQuoteCharacter(wcOpeningQuote)) { // Remove trailing white spaces from unquoted string BINDER_LOG(L"StringLexer::ParseString: Trimming string"); TrimTrailingWhiteSpaces(currentString); } BINDER_LOG_STRING(L"string", currentString); return LEXEME_TYPE_STRING; }