MCPcopy Create free account
hub / github.com/HyperDbg/HyperDbg / ParseIncludeFile

Function ParseIncludeFile

hyperdbg/script-engine/code/script_include.c:172–199  ·  view source on GitHub ↗

* @brief Reads and parses an include file into a buffer * * @param IncludeFile the path to the include file * @param Buffer pointer to receive the allocated file content buffer * @return BOOLEAN TRUE if the file was parsed successfully, FALSE otherwise */

Source from the content-addressed store, hash-verified

170 * @return BOOLEAN TRUE if the file was parsed successfully, FALSE otherwise
171 */
172BOOLEAN
173ParseIncludeFile(char * IncludeFile, char ** Buffer)
174{
175 FILE * Fp = fopen(IncludeFile, "r");
176 fseek(Fp, 0, SEEK_END);
177 LONG Size = ftell(Fp);
178 rewind(Fp);
179 *Buffer = calloc(Size + 1, 1);
180 fread(*Buffer, 1, Size, Fp);
181 (*Buffer)[Size] = '\0';
182 Trim(*Buffer);
183 SIZE_T Len = strlen(*Buffer);
184 if ((*Buffer)[0] == '?' &&
185 (*Buffer)[1] == ' ' &&
186 (*Buffer)[2] == '{' &&
187 (*Buffer)[Len - 1] == '}')
188 {
189 memmove(
190 *Buffer,
191 *Buffer + 3,
192 Len - 3 + 1);
193
194 (*Buffer)[strlen(*Buffer) - 1] = '\0';
195
196 return TRUE;
197 }
198 return FALSE;
199}

Callers 1

CodeGenFunction · 0.85

Calls 1

TrimFunction · 0.70

Tested by

no test coverage detected