Example #1
0
String JSCryptoKeySerializationJWK::serialize(ExecState* exec, const CryptoKey& key)
{
    std::unique_ptr<CryptoKeyData> keyData = key.exportData();
    if (!keyData) {
        // This generally shouldn't happen as long as all key types implement exportData(), but as underlying libraries return errors, there may be some rare failure conditions.
        throwTypeError(exec, "Couldn't export key material");
        return String();
    }

    JSObject* result = constructEmptyObject(exec);

    addJWKAlgorithmToJSON(exec, result, key);
    if (exec->hadException())
        return String();

    addBoolToJSON(exec, result, "extractable", key.extractable());

    addJWKUseToJSON(exec, result, key.usagesBitmap());
    if (exec->hadException())
        return String();

    if (isCryptoKeyDataOctetSequence(*keyData))
        buildJSONForOctetSequence(exec, toCryptoKeyDataOctetSequence(*keyData).octetSequence(), result);
    else if (isCryptoKeyDataRSAComponents(*keyData))
        buildJSONForRSAComponents(exec, toCryptoKeyDataRSAComponents(*keyData), result);
    else {
        throwTypeError(exec, "Key doesn't support exportKey");
        return String();
    }
    if (exec->hadException())
        return String();

    return JSONStringify(exec, result, 4);
}
Example #2
0
String Database::toJSON() const
{
    JSGlobalObject* globalObject = JSGlobalObject::create(
        m_vm, JSGlobalObject::createStructure(m_vm, jsNull()));
    
    return JSONStringify(globalObject->globalExec(), toJS(globalObject->globalExec()), 0);
}
Example #3
0
String Database::toJSON() const
{
    auto scope = DECLARE_THROW_SCOPE(m_vm);
    JSGlobalObject* globalObject = JSGlobalObject::create(
        m_vm, JSGlobalObject::createStructure(m_vm, jsNull()));

    auto value = toJS(globalObject->globalExec());
    RETURN_IF_EXCEPTION(scope, String());
    scope.release();
    return JSONStringify(globalObject->globalExec(), value, 0);
}
BOOL handleExceptionThreadName32(DEBUG_EVENT& oDebugEvent, cThreadContext& oThreadContext, cProcessInformation& oProcessInformation) {
  if (oDebugEvent.u.Exception.ExceptionRecord.ExceptionCode == 0x406D1388 && oDebugEvent.u.Exception.ExceptionRecord.NumberParameters == 4) {
    THREADNAME_INFO32& oThreadNameInfo = *(THREADNAME_INFO32*)oDebugEvent.u.Exception.ExceptionRecord.ExceptionInformation;
    if (oThreadNameInfo.dwType == 0x1000) {
      PTSTR siChance = oDebugEvent.u.Exception.dwFirstChance ? _T("1") : _T("2");
      PTSTR sbContinuable = oDebugEvent.u.Exception.ExceptionRecord.ExceptionFlags == 0 ? _T("true") : _T("false");
      oThreadContext.setThreadName(oProcessInformation.readString((PBYTE)oThreadNameInfo.szName, oDebugEvent.u.DebugString.fUnicode ? sizeof(WCHAR) : sizeof(CHAR), FALSE));
      _tprintf(_T("{\"sEventName\": \"threadName\", \"iProcessId\": %u, \"iThreadId\": %u, \"sThreadISA\": \"%s\", \"iChance\": %s, \"bContinuable\": %s, \"iNamedThreadId\": %u, \"sThreadName\": %s};\r\n"),
          oDebugEvent.dwProcessId, oDebugEvent.dwThreadId, oThreadContext.bThreadIs64Bit ? _T("x64") : _T("x86"),
          siChance, sbContinuable, oThreadNameInfo.dwThreadID, JSONStringify(*oThreadContext.getThreadName()).c_str());
    }
  }
  return FALSE;
}