DBG: renamed filereader to filehelper
This commit is contained in:
parent
d0ed3a7c96
commit
e5c18df86f
|
@ -0,0 +1,29 @@
|
|||
#include "filehelper.h"
|
||||
|
||||
bool FileHelper::ReadAllText(const String & fileName, String & content)
|
||||
{
|
||||
Handle hFile = CreateFileW(StringUtils::Utf8ToUtf16(fileName).c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
unsigned int filesize = GetFileSize(hFile, 0);
|
||||
if(!filesize)
|
||||
{
|
||||
content.clear();
|
||||
return true;
|
||||
}
|
||||
Memory<char*> filedata(filesize + 1, "FileReader::ReadAllText:filedata");
|
||||
DWORD read = 0;
|
||||
if(!ReadFile(hFile, filedata(), filesize, &read, 0))
|
||||
return false;
|
||||
content = String(filedata());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileHelper::WriteAllText(const String & fileName, const String & content)
|
||||
{
|
||||
Handle hFile = CreateFileW(StringUtils::Utf8ToUtf16(fileName).c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, nullptr);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
DWORD written = 0;
|
||||
return !!WriteFile(hFile, content.c_str(), content.length(), &written, nullptr);
|
||||
}
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
#include "_global.h"
|
||||
|
||||
class FileReader
|
||||
class FileHelper
|
||||
{
|
||||
public:
|
||||
static bool ReadAllText(const String & fileName, String & content);
|
||||
static bool WriteAllText(const String & fileName, const String & content);
|
||||
};
|
||||
|
||||
#endif //_FILEREADER_H
|
|
@ -1,20 +0,0 @@
|
|||
#include "filereader.h"
|
||||
|
||||
bool FileReader::ReadAllText(const String & fileName, String & content)
|
||||
{
|
||||
Handle hFile = CreateFileW(StringUtils::Utf8ToUtf16(fileName).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
unsigned int filesize = GetFileSize(hFile, 0);
|
||||
if(!filesize)
|
||||
{
|
||||
content.clear();
|
||||
return true;
|
||||
}
|
||||
Memory<char*> filedata(filesize + 1, "FileReader::ReadAllText:filedata");
|
||||
DWORD read = 0;
|
||||
if(!ReadFile(hFile, filedata(), filesize, &read, 0))
|
||||
return false;
|
||||
content = String(filedata());
|
||||
return true;
|
||||
}
|
|
@ -25,7 +25,7 @@
|
|||
#include "patternfind.h"
|
||||
#include "module.h"
|
||||
#include "stringformat.h"
|
||||
#include "filereader.h"
|
||||
#include "filehelper.h"
|
||||
#include "linearanalysis.h"
|
||||
#include "controlflowanalysis.h"
|
||||
#include "analysis_nukem.h"
|
||||
|
@ -1756,7 +1756,7 @@ CMDRESULT cbInstrYara(int argc, char* argv[])
|
|||
}
|
||||
|
||||
String rulesContent;
|
||||
if(!FileReader::ReadAllText(argv[1], rulesContent))
|
||||
if(!FileHelper::ReadAllText(argv[1], rulesContent))
|
||||
{
|
||||
dprintf("Failed to read the rules file \"%s\"\n", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
|
@ -1971,7 +1971,7 @@ CMDRESULT cbInstrCfanalyse(int argc, char* argv[])
|
|||
uint base = MemFindBaseAddr(sel.start, &size);
|
||||
ControlFlowAnalysis anal(base, size, exceptionDirectory);
|
||||
anal.Analyse();
|
||||
//anal.SetMarkers();
|
||||
anal.SetMarkers();
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue