GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — linuxKernelRoot/patch_kernel_root/base_func.h at master · DXCyber409/linuxKernelRoot Expand file tree/ Copy pathbase_func.hMore file actions 75 lines (69 loc) · 1.89 KB / Copy pathbase_func.hFile metadata and controls75 lines (69 loc) · 1.89 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 #pragma once #include <iostream> #include <string> #include <fstream> #include <sstream> #include <algorithm> #include <vector> #include <math.h> static std::vector<char> read_file_buf(const std::string& file_path) { std::ifstream file(file_path, std::ios::binary | std::ios::ate); if (file) { auto size = file.tellg(); std::vector<char> buffer(size); file.seekg(0, std::ios::beg); file.read(buffer.data(), size); file.close(); return buffer; } return {}; } static void get_rand_str(char* dest, int n) { int i, randno; char stardstring[63] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; srand((unsigned)time(NULL)); for (i = 0; i < n; i++) { randno = rand() % 62; *dest = stardstring[randno]; dest++; } } static std::string generate_random_root_key() { const int key_len = 48; char root_key_data[key_len] = { 0 }; get_rand_str(root_key_data, sizeof(root_key_data)); std::string str_root_key(root_key_data, sizeof(root_key_data)); return str_root_key; } static auto hex2byte(uint8_t* hex, uint8_t* str) -> void { char high, low; for (size_t i = 0, length = strlen((char*)hex); i < length; i += 2) { high = toupper(hex[i]) - '0'; low = toupper(hex[i + 1]) - '0'; str[i / 2] = ((high > 9 ? high - 7 : high) << 4) + (low > 9 ? low - 7 : low); } } static bool write_file_bytes(const char* file_path, size_t offset, const char* bytes, size_t len) { std::fstream file_stream(file_path, std::ios::in | std::ios::out | std::ios::binary); if (!file_stream) { return false; } file_stream.seekp(offset); if (!file_stream.good()) { file_stream.close(); return false; } file_stream.write(bytes, len); if (!file_stream.good()) { file_stream.close(); return false; } file_stream.close(); return true; } static size_t align8(size_t addr) { if (addr % 8 != 0) { addr = (addr + 7) & ~static_cast<size_t>(7); // Align to next 8-byte boundary } return addr; } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |