CStdString CSysInfo::GetUserAgent() { CStdString result; result = "XBMC/" + g_infoManager.GetLabel(SYSTEM_BUILD_VERSION) + " ("; #if defined(_WIN32) result += "Windows; "; result += GetKernelVersion(); #elif defined(__APPLE__) #if defined(__arm__) result += "iOS; "; #else result += "Mac OS X; "; #endif result += GetUnameVersion(); #elif defined(__FreeBSD__) result += "FreeBSD; "; result += GetUnameVersion(); #elif defined(_LINUX) result += "Linux; "; result += GetLinuxDistro(); result += "; "; result += GetUnameVersion(); #endif result += "; http://www.xbmc.org)"; return result; }
QueryData genKernelInfo(QueryContext& context) { Row r; GetKernelVersion(r); GetBootArgs(r); GetSystemDriveGUID(r); r["path"] = SQL_TEXT(getSystemRoot().string() + "\\System32\\ntoskrnl.exe"); return {r}; }
//----------------------------------------------------------------------------- // Function: init // // init is a plugin_t function. It is executed when the plugin is // initially loaded by IDA. // Three return codes are possible: // PLUGIN_SKIP - Plugin is unloaded and not made available // PLUGIN_KEEP - Plugin is kept in memory // PLUGIN_OK - Plugin will be loaded upon 1st use // // Check are added here to ensure the plug-in is compatible with // the current disassembly. //----------------------------------------------------------------------------- int initPlugin(void) { char szBuffer[MAXSTR]; char sdkVersion[32]; int nRetCode = PLUGIN_OK; HINSTANCE hInstance = ::GetModuleHandle(NULL); // Initialize global strings LoadString(hInstance, IDS_PLUGIN_HELP, szBuffer, sizeof(szBuffer)); gszPluginHelp = qstrdup(szBuffer); LoadString(hInstance, IDS_PLUGIN_COMMENT, szBuffer, sizeof(szBuffer)); gszPluginComment = qstrdup(szBuffer); if ( !GetKernelVersion(sdkVersion, sizeof(sdkVersion)) ) { msg("%s: could not determine IDA version\n", gszWantedName); nRetCode = PLUGIN_SKIP; } else if ( gSdkVersion < 600 ) { warning("Sorry, the %s plugin required IDA v%s or higher\n", gszWantedName, sdkVersion); nRetCode = PLUGIN_SKIP; } else if ( ph.id != PLFM_386 || ( !inf.is_32bit() && !inf.is_64bit() ) || inf.like_binary() ) { msg("%s: could not load plugin\n", gszWantedName); nRetCode = PLUGIN_SKIP; } else { msg("\n--------------------------------------------------------------------------------------\n" "%s (v%s) plugin has been loaded\n" " The hotkeys to invoke the plugin is %s.\n" " Please check the Edit/Plugins menu for more informaton.\n", gszWantedName, gszVersion, gszWantedHotKey); PrintDefaultStrtype(); msg("--------------------------------------------------------------------------------------\n"); } return nRetCode; }
std::string CSysInfo::GetOsVersion(void) { static std::string osVersion; if (!osVersion.empty()) return osVersion; #if defined(TARGET_FREEBSD) osVersion = GetKernelVersion(); // FIXME: for Win32 and FreeBSD OS version is a kernel version #elif defined(TARGET_DARWIN_IOS) osVersion = CDarwinUtils::GetIOSVersionString(); #elif defined(TARGET_DARWIN_OSX) osVersion = CDarwinUtils::GetOSXVersionString(); #elif defined(TARGET_ANDROID) char versionCStr[PROP_VALUE_MAX]; int propLen = __system_property_get("ro.build.version.release", versionCStr); osVersion.assign(versionCStr, (propLen > 0 && propLen <= PROP_VALUE_MAX) ? propLen : 0); if (osVersion.empty() || std::string("0123456789").find(versionCStr[0]) == std::string::npos) osVersion.clear(); // can't correctly detect Android version else { size_t pointPos = osVersion.find('.'); if (pointPos == std::string::npos) osVersion += ".0.0"; else if (osVersion.find('.', pointPos + 1) == std::string::npos) osVersion += ".0"; } #elif defined(TARGET_LINUX) osVersion = getValueFromOs_release("VERSION_ID"); if (osVersion.empty()) osVersion = getValueFromLsb_release(lsb_rel_release); #endif // defined(TARGET_LINUX) if (osVersion.empty()) osVersion = "0.0"; return osVersion; }
std::string CSysInfo::GetUserAgent() { static std::string result; if (!result.empty()) return result; result = GetAppName() + "/" + (std::string)g_infoManager.GetLabel(SYSTEM_BUILD_VERSION_SHORT) + " ("; #if defined(TARGET_WINDOWS) result += GetKernelName() + " " + GetKernelVersion(); BOOL bIsWow = FALSE; if (IsWow64Process(GetCurrentProcess(), &bIsWow) && bIsWow) result.append("; WOW64"); else { SYSTEM_INFO si = {}; GetSystemInfo(&si); if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) result.append("; Win64; x64"); else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) result.append("; Win64; IA64"); else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM) result.append("; ARM"); } #elif defined(TARGET_DARWIN) #if defined(TARGET_DARWIN_IOS) std::string iDevStr(GetModelName()); // device model name with number of model version size_t iDevStrDigit = iDevStr.find_first_of("0123456789"); std::string iDev(iDevStr, 0, iDevStrDigit); // device model name without number if (iDevStrDigit == 0) iDev = "unknown"; result += iDev + "; "; std::string iOSVerison(GetOsVersion()); size_t lastDotPos = iOSVerison.rfind('.'); if (lastDotPos != std::string::npos && iOSVerison.find('.') != lastDotPos && iOSVerison.find_first_not_of('0', lastDotPos + 1) == std::string::npos) iOSVerison.erase(lastDotPos); StringUtils::Replace(iOSVerison, '.', '_'); if (iDev == "iPad" || iDev == "AppleTV") result += "CPU OS "; else result += "CPU iPhone OS "; result += iOSVerison + " like Mac OS X"; #else result += "Macintosh; "; std::string cpuFam(GetBuildTargetCpuFamily()); if (cpuFam == "x86") result += "Intel "; else if (cpuFam == "PowerPC") result += "PPC "; result += "Mac OS X "; std::string OSXVersion(GetOsVersion()); StringUtils::Replace(OSXVersion, '.', '_'); result += OSXVersion; #endif #elif defined(TARGET_ANDROID) result += "Linux; Android "; std::string versionStr(GetOsVersion()); const size_t verLen = versionStr.length(); if (verLen >= 2 && versionStr.compare(verLen - 2, 2, ".0", 2) == 0) versionStr.erase(verLen - 2); // remove last ".0" if any result += versionStr; std::string deviceInfo(GetModelName()); char buildId[PROP_VALUE_MAX]; int propLen = __system_property_get("ro.build.id", buildId); if (propLen > 0 && propLen <= PROP_VALUE_MAX) { if (!deviceInfo.empty()) deviceInfo += " "; deviceInfo += "Build/"; deviceInfo.append(buildId, propLen); } if (!deviceInfo.empty()) result += "; " + deviceInfo; #elif defined(TARGET_POSIX) result += "X11; "; struct utsname un; if (uname(&un) == 0) { std::string cpuStr(un.machine); if (cpuStr == "x86_64" && GetXbmcBitness() == 32) cpuStr = "i686 (x86_64)"; result += un.sysname; result += " "; result += cpuStr; } else result += "Unknown"; #else result += "Unknown"; #endif result += ")"; if (GetAppName() != "Kodi") result += " Kodi_Fork_" + GetAppName() + "/1.0"; // default fork number is '1.0', replace it with actual number if necessary #ifdef TARGET_LINUX // Add distribution name std::string linuxOSName(GetOsName(true)); if (!linuxOSName.empty()) result += " " + linuxOSName + "/" + GetOsVersion(); #endif #ifdef TARGET_RASPBERRY_PI result += " HW_RaspberryPi/1.0"; #elif defined (TARGET_DARWIN_IOS) std::string iDevVer; if (iDevStrDigit == std::string::npos) iDevVer = "0.0"; else iDevVer.assign(iDevStr, iDevStrDigit, std::string::npos); StringUtils::Replace(iDevVer, ',', '.'); result += " HW_" + iDev + "/" + iDevVer; #endif // add more device IDs here if needed. // keep only one device ID in result! Form: // result += " HW_" + "deviceID" + "/" + "1.0"; // '1.0' if device has no version #if defined(TARGET_ANDROID) // Android has no CPU string by default, so add it as additional parameter struct utsname un1; if (uname(&un1) == 0) { std::string cpuStr(un1.machine); StringUtils::Replace(cpuStr, ' ', '_'); result += " Sys_CPU/" + cpuStr; } #endif result += " App_Bitness/" + StringUtils::Format("%d", GetXbmcBitness()); std::string fullVer(g_infoManager.GetLabel(SYSTEM_BUILD_VERSION)); StringUtils::Replace(fullVer, ' ', '-'); result += " Version/" + fullVer; return result; }