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 — ShellcodeCompiler/ShellcodeCompiler/Utils.cpp at master · DevilBot000/ShellcodeCompiler Expand file tree/ Copy pathUtils.cppMore file actions 184 lines (128 loc) · 2.96 KB / Copy pathUtils.cppFile metadata and controls184 lines (128 loc) · 2.96 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 #include "Utils.h" // Check if a file exists bool Utils::FileExists(string p_sPath) { if (FILE * file = fopen(p_sPath.c_str(), "r")) { fclose(file); return true; } else { return false; } } // Delete a file bool Utils::DeleteSourceFile(string p_sFile) { return (bool)remove(p_sFile.c_str()); } // Function used to read a file string Utils::ReadSourceFile(string p_sFilename) { string contents = ""; FILE* f = fopen(p_sFilename.c_str(), "rb"); // Get file size fseek(f, 0, SEEK_END); size_t size = ftell(f); char* cdata = new char[size + 1]; cdata[size] = '\0'; // Read file rewind(f); fread(cdata, sizeof(char), size, f); fclose(f); // Return data contents = cdata; delete[] cdata; return contents; } // Get the size of a file size_t Utils::GetSize(string p_sFilename) { size_t size; FILE* f = fopen(p_sFilename.c_str(), "rb"); // Get file size fseek(f, 0, SEEK_END); size = ftell(f); rewind(f); fclose(f); return size; } // Read binary file unsigned char* Utils::ReadBinaryFile(string p_sFilename, size_t *p_rSize) { unsigned char *p = NULL; FILE* f = NULL; size_t res = 0; if (!FileExists(p_sFilename)) { cout << "Binary file does not exists!" << endl; return NULL; } // Get size and allocate space *p_rSize = GetSize(p_sFilename); if (*p_rSize == 0) return NULL; f = fopen(p_sFilename.c_str(), "rb"); p = new unsigned char[*p_rSize]; // Read file rewind(f); res = fread(p, sizeof(unsigned char), *p_rSize, f); fclose(f); if (res == 0) { delete[] p; return NULL; } return p; } // Write output to file void Utils::WriteToFile(string p_sOutputFile, string p_sData) { FILE* f = fopen(p_sOutputFile.c_str(), "ab"); // Write fwrite(p_sData.c_str(), p_sData.length(), sizeof(char), f); // Close fclose(f); } // Write a binary file size_t Utils::WriteBinaryFile(string p_sOutputFile, unsigned char *p_pcData, size_t p_nSize) { size_t nResult = 0; FILE* f = fopen(p_sOutputFile.c_str(), "wb"); // Write nResult = fwrite(p_pcData, p_nSize, sizeof(char), f); // Close fclose(f); return nResult; } // Return hex string for a char string Utils::CharToHexString(char p_cChar) { stringstream ss; ss << hex << (int)p_cChar; string mystr = ss.str(); return mystr; } // Convert int to hex string Utils::IntToHexString(size_t p_iNumber) { std::stringstream stream; stream << std::hex << p_iNumber; std::string result(stream.str()); return result; } // Function used to check if a character is "string": [a-z][A-Z][0-9][Specail] bool Utils::IsString(char p_cCharacter) { return (p_cCharacter >= 32 && p_cCharacter <= 126 && p_cCharacter != '"' && p_cCharacter != ')' && p_cCharacter != '(' && p_cCharacter != ','); } // Function to convert a string to lower string Utils::ToLower(string p_sString) { string result = ""; for (size_t i = 0; i < p_sString.length(); i++) { if (p_sString[i] >= 65 && p_sString[i] <= 90) result += (char)(p_sString[i] + 32); else result += p_sString[i]; } return result; } |
| You are visitor 01402503 — 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. |