403Webshell
Server IP : 82.208.35.60  /  Your IP : 216.73.216.238
Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31
System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64
User : studiokobylisy_cz ( 1008)
PHP Version : 7.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/ports/benchmarks/mangohud/files/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/ports/benchmarks/mangohud/files/patch-src_file__utils.cpp
--- src/file_utils.cpp.orig	2021-07-08 06:23:59 UTC
+++ src/file_utils.cpp
@@ -2,6 +2,7 @@
 #include "string_utils.h"
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysctl.h>
 #include <unistd.h>
 #include <dirent.h>
 #include <limits.h>
@@ -107,9 +108,36 @@ std::string read_symlink(const char * link)
     return std::string(result, (count > 0) ? count : 0);
 }
 
+template <>
+int read_sysctl(const char* name)
+{
+    int value;
+    size_t len = sizeof(value);
+
+    if (sysctlbyname(name, &value, &len, NULL, 0) == 0)
+        return value;
+    else return -1;
+}
+
+template <>
+std::string read_sysctl(const char* name)
+{
+    size_t len;
+
+    // How large buffer do we need?
+    if (sysctlbyname(name, NULL, &len, NULL, 0) != 0)
+        return "";
+
+    char value[len];
+    // Now read the actual value into it.
+    if (sysctlbyname(name, value, &len, NULL, 0) == 0)
+        return value;
+    else return "";
+}
+
 std::string get_exe_path()
 {
-    return read_symlink("/proc/self/exe");
+    return read_symlink(PROCDIR "/self/exe");
 }
 
 std::string get_wine_exe_name(bool keep_ext)
@@ -119,14 +147,14 @@ std::string get_wine_exe_name(bool keep_ext)
         return std::string();
     }
 
-    std::string line = read_line("/proc/self/comm"); // max 16 characters though
+    std::string line = read_line(PROCDIR "/self/comm"); // max 16 characters though
     if (ends_with(line, ".exe", true))
     {
         auto dot = keep_ext ? std::string::npos : line.find_last_of('.');
         return line.substr(0, dot);
     }
 
-    std::ifstream cmdline("/proc/self/cmdline");
+    std::ifstream cmdline(PROCDIR "/self/cmdline");
     // Iterate over arguments (separated by NUL byte).
     while (std::getline(cmdline, line, '\0')) {
         auto n = std::string::npos;

Youez - 2016 - github.com/yon3zu
LinuXploit