mirror of
https://github.com/stellarbear/YaraSharp
synced 2026-06-08 17:36:09 +00:00
@@ -26,6 +26,8 @@ namespace YaraSharp
|
||||
yr_compiler_destroy(compiler);
|
||||
}
|
||||
|
||||
callbackHandle.Free();
|
||||
|
||||
delete warnings;
|
||||
delete errors;
|
||||
}
|
||||
@@ -134,7 +136,7 @@ namespace YaraSharp
|
||||
void YSCompiler::SetCompilerCallback()
|
||||
{
|
||||
YaraCompilerCallback^ compilerCallback = gcnew YaraCompilerCallback(this, &YSCompiler::HandleCompilerCallback);
|
||||
GCHandle callbackHandle = GCHandle::Alloc(compilerCallback);
|
||||
callbackHandle = GCHandle::Alloc(compilerCallback);
|
||||
YR_COMPILER_CALLBACK_FUNC callbackPointer = (YR_COMPILER_CALLBACK_FUNC)(Marshal::GetFunctionPointerForDelegate(compilerCallback)).ToPointer();
|
||||
yr_compiler_set_callback(compiler, callbackPointer, NULL);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace YaraSharp
|
||||
YSReport^ errors;
|
||||
YSReport^ warnings;
|
||||
initonly YR_COMPILER* compiler;
|
||||
GCHandle callbackHandle;
|
||||
|
||||
public:
|
||||
YSCompiler(Dictionary<String^, Object^>^ externalVariables);
|
||||
|
||||
+99
-113
@@ -1,128 +1,114 @@
|
||||
#include "Stdafx.h"
|
||||
#include "YaraExceptions.h"
|
||||
|
||||
// YSException
|
||||
namespace YaraSharp
|
||||
{
|
||||
void YSException::ThrowOnError(int error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
return;
|
||||
|
||||
case ERROR_INSUFICIENT_MEMORY:
|
||||
throw gcnew OutOfMemoryException();
|
||||
|
||||
default:
|
||||
throw gcnew Exception(String::Format("Yara error: {0}. Code {1}", NiceErrorCode(error), error));
|
||||
case ERROR_SUCCESS:
|
||||
return;
|
||||
case ERROR_INSUFICIENT_MEMORY:
|
||||
throw gcnew OutOfMemoryException();
|
||||
case ERROR_COULD_NOT_ATTACH_TO_PROCESS:
|
||||
throw gcnew YaraAttachToProcessFailure();
|
||||
case ERROR_COULD_NOT_OPEN_FILE:
|
||||
throw gcnew YaraOpenFileFailure();
|
||||
case ERROR_COULD_NOT_MAP_FILE:
|
||||
throw gcnew YaraMapFileFailure();
|
||||
case ERROR_INVALID_FILE:
|
||||
throw gcnew YaraInvalidFile();
|
||||
case ERROR_CORRUPT_FILE:
|
||||
throw gcnew YaraCorruptFile();
|
||||
case ERROR_UNSUPPORTED_FILE_VERSION:
|
||||
throw gcnew YaraUnsupportedFileVersion();
|
||||
case ERROR_INVALID_REGULAR_EXPRESSION:
|
||||
throw gcnew YaraInvalidRegularExpression();
|
||||
case ERROR_INVALID_HEX_STRING:
|
||||
throw gcnew YaraInvalidHexString();
|
||||
case ERROR_SYNTAX_ERROR:
|
||||
throw gcnew YaraSyntaxError();
|
||||
case ERROR_LOOP_NESTING_LIMIT_EXCEEDED:
|
||||
throw gcnew YaraLoopNestingLimitExceeded();
|
||||
case ERROR_DUPLICATED_LOOP_IDENTIFIER:
|
||||
throw gcnew YaraDuplicatedLoopIdentifier();
|
||||
case ERROR_DUPLICATED_IDENTIFIER:
|
||||
throw gcnew YaraDuplicatedIdentifier();
|
||||
case ERROR_DUPLICATED_TAG_IDENTIFIER:
|
||||
throw gcnew YaraDuplicatedTagIdentifier();
|
||||
case ERROR_DUPLICATED_META_IDENTIFIER:
|
||||
throw gcnew YaraDuplicatedMetaIdentifier();
|
||||
case ERROR_DUPLICATED_STRING_IDENTIFIER:
|
||||
throw gcnew YaraDuplicatedStringIdentifier();
|
||||
case ERROR_UNREFERENCED_STRING:
|
||||
throw gcnew YaraUnreferencedString();
|
||||
case ERROR_UNDEFINED_STRING:
|
||||
throw gcnew YaraUndefinedString();
|
||||
case ERROR_UNDEFINED_IDENTIFIER:
|
||||
throw gcnew YaraUndefinedIdentifier();
|
||||
case ERROR_MISPLACED_ANONYMOUS_STRING:
|
||||
throw gcnew YaraMisplacedAnonymousString();
|
||||
case ERROR_INCLUDES_CIRCULAR_REFERENCE:
|
||||
throw gcnew YaraCircularReference();
|
||||
case ERROR_INCLUDE_DEPTH_EXCEEDED:
|
||||
throw gcnew YaraDepthExceeded();
|
||||
case ERROR_WRONG_TYPE:
|
||||
throw gcnew YaraWrongType();
|
||||
case ERROR_EXEC_STACK_OVERFLOW:
|
||||
throw gcnew YaraExecStackOverflow();
|
||||
case ERROR_SCAN_TIMEOUT:
|
||||
throw gcnew YaraScanTimeout();
|
||||
case ERROR_TOO_MANY_SCAN_THREADS:
|
||||
throw gcnew YaraTooManyScanThreads();
|
||||
case ERROR_CALLBACK_ERROR:
|
||||
throw gcnew YaraCallbackError();
|
||||
case ERROR_INVALID_ARGUMENT:
|
||||
throw gcnew YaraInvalidArgument();
|
||||
case ERROR_TOO_MANY_MATCHES:
|
||||
throw gcnew YaraTooManyMatches();
|
||||
case ERROR_INTERNAL_FATAL_ERROR:
|
||||
throw gcnew YaraInternalFatalError();
|
||||
case ERROR_NESTED_FOR_OF_LOOP:
|
||||
throw gcnew YaraNestedForOfLoop();
|
||||
case ERROR_INVALID_FIELD_NAME:
|
||||
throw gcnew YaraInvalidFieldName();
|
||||
case ERROR_UNKNOWN_MODULE:
|
||||
throw gcnew YaraUnknownModule();
|
||||
case ERROR_NOT_A_STRUCTURE:
|
||||
throw gcnew YaraNotAStructure();
|
||||
case ERROR_NOT_INDEXABLE:
|
||||
throw gcnew YaraNotIndexable();
|
||||
case ERROR_NOT_A_FUNCTION:
|
||||
throw gcnew YaraNotAFunction();
|
||||
case ERROR_INVALID_FORMAT:
|
||||
throw gcnew YaraInvalidFormat();
|
||||
case ERROR_TOO_MANY_ARGUMENTS:
|
||||
throw gcnew YaraTooManyArguments();
|
||||
case ERROR_WRONG_ARGUMENTS:
|
||||
throw gcnew YaraWrongArguments();
|
||||
case ERROR_WRONG_RETURN_TYPE:
|
||||
throw gcnew YaraWrongReturnType();
|
||||
case ERROR_DUPLICATED_STRUCTURE_MEMBER:
|
||||
throw gcnew YaraDuplicatedStructureMember();
|
||||
case ERROR_EMPTY_STRING:
|
||||
throw gcnew YaraEmptyString();
|
||||
case ERROR_DIVISION_BY_ZERO:
|
||||
throw gcnew YaraDivisionByZero();
|
||||
case ERROR_REGULAR_EXPRESSION_TOO_LARGE:
|
||||
throw gcnew YaraRegularExpressionTooLarge();
|
||||
case ERROR_TOO_MANY_RE_FIBERS:
|
||||
throw gcnew YaraTooManyReFibers();
|
||||
case ERROR_COULD_NOT_READ_PROCESS_MEMORY:
|
||||
throw gcnew YaraCouldNotReadProcessMemory();
|
||||
case ERROR_INVALID_EXTERNAL_VARIABLE_TYPE:
|
||||
throw gcnew YaraInvalidExternalVariableType();
|
||||
default:
|
||||
throw gcnew Exception("An unknown exception occured");
|
||||
}
|
||||
}
|
||||
void YSException::ThrowOnError(String^ error)
|
||||
{
|
||||
throw gcnew Exception(String::Format("Error: {0}", error));
|
||||
}
|
||||
|
||||
String^ YSException::NiceErrorCode(int error)
|
||||
{
|
||||
// TODO: nice erros
|
||||
switch (error)
|
||||
{
|
||||
case ERROR_INSUFICIENT_MEMORY:
|
||||
return "ERROR_INSUFICIENT_MEMORY";
|
||||
case ERROR_COULD_NOT_ATTACH_TO_PROCESS:
|
||||
return "COULD_NOT_ATTACH_TO_PROCESS";
|
||||
case ERROR_COULD_NOT_OPEN_FILE:
|
||||
return "ERROR_COULD_NOT_OPEN_FILE";
|
||||
case ERROR_COULD_NOT_MAP_FILE:
|
||||
return "ERROR_COULD_NOT_MAP_FILE";
|
||||
case ERROR_INVALID_FILE:
|
||||
return "ERROR_INVALID_FILE";
|
||||
case ERROR_CORRUPT_FILE:
|
||||
return "ERROR_CORRUPT_FILE";
|
||||
case ERROR_UNSUPPORTED_FILE_VERSION:
|
||||
return "ERROR_UNSUPPORTED_FILE_VERSION";
|
||||
case ERROR_INVALID_REGULAR_EXPRESSION:
|
||||
return "ERROR_INVALID_REGULAR_EXPRESSION";
|
||||
case ERROR_INVALID_HEX_STRING:
|
||||
return "ERROR_INVALID_HEX_STRING";
|
||||
case ERROR_SYNTAX_ERROR:
|
||||
return "ERROR_SYNTAX_ERROR";
|
||||
case ERROR_LOOP_NESTING_LIMIT_EXCEEDED:
|
||||
return "ERROR_LOOP_NESTING_LIMIT_EXCEEDED";
|
||||
case ERROR_DUPLICATED_LOOP_IDENTIFIER:
|
||||
return "ERROR_DUPLICATED_LOOP_IDENTIFIER";
|
||||
case ERROR_DUPLICATED_IDENTIFIER:
|
||||
return "ERROR_DUPLICATED_IDENTIFIER";
|
||||
case ERROR_DUPLICATED_TAG_IDENTIFIER:
|
||||
return "ERROR_DUPLICATED_TAG_IDENTIFIER";
|
||||
case ERROR_DUPLICATED_META_IDENTIFIER:
|
||||
return "ERROR_DUPLICATED_META_IDENTIFIER";
|
||||
case ERROR_DUPLICATED_STRING_IDENTIFIER:
|
||||
return "ERROR_DUPLICATED_STRING_IDENTIFIER";
|
||||
case ERROR_UNREFERENCED_STRING:
|
||||
return "ERROR_UNREFERENCED_STRING";
|
||||
case ERROR_UNDEFINED_STRING:
|
||||
return "ERROR_UNDEFINED_STRING";
|
||||
case ERROR_UNDEFINED_IDENTIFIER:
|
||||
return "ERROR_UNDEFINED_IDENTIFIER";
|
||||
case ERROR_MISPLACED_ANONYMOUS_STRING:
|
||||
return "ERROR_MISPLACED_ANONYMOUS_STRING";
|
||||
case ERROR_INCLUDES_CIRCULAR_REFERENCE:
|
||||
return "ERROR_INCLUDES_CIRCULAR_REFERENCE";
|
||||
case ERROR_INCLUDE_DEPTH_EXCEEDED:
|
||||
return "ERROR_INCLUDE_DEPTH_EXCEEDED";
|
||||
case ERROR_WRONG_TYPE:
|
||||
return "ERROR_WRONG_TYPE";
|
||||
case ERROR_EXEC_STACK_OVERFLOW:
|
||||
return "ERROR_EXEC_STACK_OVERFLOW";
|
||||
case ERROR_SCAN_TIMEOUT:
|
||||
return "ERROR_SCAN_TIMEOUT";
|
||||
case ERROR_TOO_MANY_SCAN_THREADS:
|
||||
return "ERROR_TOO_MANY_SCAN_THREADS";
|
||||
case ERROR_CALLBACK_ERROR:
|
||||
return "ERROR_CALLBACK_ERROR";
|
||||
case ERROR_INVALID_ARGUMENT:
|
||||
return "ERROR_INVALID_ARGUMENT";
|
||||
case ERROR_TOO_MANY_MATCHES:
|
||||
return "ERROR_TOO_MANY_MATCHES";
|
||||
case ERROR_INTERNAL_FATAL_ERROR:
|
||||
return "ERROR_INTERNAL_FATAL_ERROR";
|
||||
case ERROR_NESTED_FOR_OF_LOOP:
|
||||
return "ERROR_NESTED_FOR_OF_LOOP";
|
||||
case ERROR_INVALID_FIELD_NAME:
|
||||
return "ERROR_INVALID_FIELD_NAME";
|
||||
case ERROR_UNKNOWN_MODULE:
|
||||
return "ERROR_UNKNOWN_MODULE";
|
||||
case ERROR_NOT_A_STRUCTURE:
|
||||
return "ERROR_NOT_A_STRUCTURE";
|
||||
case ERROR_NOT_INDEXABLE:
|
||||
return "ERROR_NOT_INDEXABLE";
|
||||
case ERROR_NOT_A_FUNCTION:
|
||||
return "ERROR_NOT_A_FUNCTION";
|
||||
case ERROR_INVALID_FORMAT:
|
||||
return "ERROR_INVALID_FORMAT";
|
||||
case ERROR_TOO_MANY_ARGUMENTS:
|
||||
return "ERROR_TOO_MANY_ARGUMENTS";
|
||||
case ERROR_WRONG_ARGUMENTS:
|
||||
return "ERROR_WRONG_ARGUMENTS";
|
||||
case ERROR_WRONG_RETURN_TYPE:
|
||||
return "ERROR_WRONG_RETURN_TYPE";
|
||||
case ERROR_DUPLICATED_STRUCTURE_MEMBER:
|
||||
return "ERROR_DUPLICATED_STRUCTURE_MEMBER";
|
||||
case ERROR_EMPTY_STRING:
|
||||
return "ERROR_EMPTY_STRING";
|
||||
case ERROR_DIVISION_BY_ZERO:
|
||||
return "ERROR_DIVISION_BY_ZERO";
|
||||
case ERROR_REGULAR_EXPRESSION_TOO_LARGE:
|
||||
return "ERROR_REGULAR_EXPRESSION_TOO_LARGE";
|
||||
case ERROR_TOO_MANY_RE_FIBERS:
|
||||
return "ERROR_TOO_MANY_RE_FIBERS";
|
||||
case ERROR_COULD_NOT_READ_PROCESS_MEMORY:
|
||||
return "ERROR_COULD_NOT_READ_PROCESS_MEMORY";
|
||||
case ERROR_INVALID_EXTERNAL_VARIABLE_TYPE:
|
||||
return "ERROR_INVALID_EXTERNAL_VARIABLE_TYPE";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace YaraSharp
|
||||
{
|
||||
public ref class YSException abstract sealed
|
||||
{
|
||||
private:
|
||||
static String^ NiceErrorCode(int error);
|
||||
|
||||
public:
|
||||
static void ThrowOnError(int error);
|
||||
static void ThrowOnError(String^ error);
|
||||
|
||||
+30
-12
@@ -19,30 +19,48 @@ namespace YaraSharp
|
||||
{
|
||||
YSScanner^ FScanner = gcnew YSScanner(rules, externalVariables);
|
||||
|
||||
List<YSMatches^>^ results = FScanner->ScanFile(path);
|
||||
delete FScanner;
|
||||
|
||||
return results;
|
||||
try {
|
||||
List<YSMatches^>^ results = FScanner->ScanFile(path);
|
||||
return results;
|
||||
}
|
||||
catch (System::Exception^ e) {
|
||||
throw e;
|
||||
}
|
||||
finally{
|
||||
delete FScanner;
|
||||
}
|
||||
}
|
||||
// (not yet tested)
|
||||
List<YSMatches^>^ YSInstance::ScanProcess(int pID, YSRules^ rules, Dictionary<String^, Object^>^ externalVariables, int timeout)
|
||||
{
|
||||
YSScanner^ PScanner = gcnew YSScanner(rules, externalVariables);
|
||||
|
||||
List<YSMatches^>^ results = PScanner->ScanProcess(pID);
|
||||
delete PScanner;
|
||||
|
||||
return results;
|
||||
try {
|
||||
List<YSMatches^>^ results = PScanner->ScanProcess(pID);
|
||||
return results;
|
||||
}
|
||||
catch (System::Exception^ e) {
|
||||
throw e;
|
||||
}
|
||||
finally{
|
||||
delete PScanner;
|
||||
}
|
||||
}
|
||||
// (not yet tested)
|
||||
List<YSMatches^>^ YSInstance::ScanMemory(uint8_t* buffer, int length, YSRules^ rules, Dictionary<String^, Object^>^ externalVariables, int timeout)
|
||||
{
|
||||
YSScanner^ MScanner = gcnew YSScanner(rules, externalVariables);
|
||||
|
||||
List<YSMatches^>^ results = MScanner->ScanMemory(buffer, length);
|
||||
delete MScanner;
|
||||
|
||||
return results;
|
||||
try {
|
||||
List<YSMatches^>^ results = MScanner->ScanMemory(buffer, length);
|
||||
return results;
|
||||
}
|
||||
catch (System::Exception^ e) {
|
||||
throw e;
|
||||
}
|
||||
finally{
|
||||
delete MScanner;
|
||||
}
|
||||
}
|
||||
// (not yet tested)
|
||||
List<YSMatches^>^ YSInstance::ScanMemory(array<uint8_t>^ buffer, YSRules^ rules, Dictionary<String^, Object^>^ externalVariables, int timeout)
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace YaraSharp
|
||||
{
|
||||
yr_scanner_destroy(scanner);
|
||||
}
|
||||
|
||||
callbackHandle.Free();
|
||||
}
|
||||
|
||||
// Scan region
|
||||
@@ -78,9 +80,9 @@ namespace YaraSharp
|
||||
// Callback
|
||||
void YSScanner::SetScannerCallback()
|
||||
{
|
||||
YaraScanCallback^ ScannerCallback = gcnew YaraScanCallback(this, &YSScanner::HandleScannerCallback);
|
||||
GCHandle CallbackHandle = GCHandle::Alloc(ScannerCallback);
|
||||
YR_CALLBACK_FUNC CallbackPointer = (YR_CALLBACK_FUNC)Marshal::GetFunctionPointerForDelegate(ScannerCallback).ToPointer();
|
||||
YaraScanCallback^ scannerCallback = gcnew YaraScanCallback(this, &YSScanner::HandleScannerCallback);
|
||||
callbackHandle = GCHandle::Alloc(scannerCallback);
|
||||
YR_CALLBACK_FUNC CallbackPointer = (YR_CALLBACK_FUNC)Marshal::GetFunctionPointerForDelegate(scannerCallback).ToPointer();
|
||||
yr_scanner_set_callback(scanner, CallbackPointer, NULL);
|
||||
}
|
||||
int YSScanner::HandleScannerCallback(int message, void* data, void* context)
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace YaraSharp
|
||||
{
|
||||
initonly YR_SCANNER * scanner;
|
||||
List<YSMatches^>^ matches;
|
||||
GCHandle callbackHandle;
|
||||
|
||||
public:
|
||||
YSScanner(YSRules^ rules, Dictionary<String^, Object^>^ externalVariables);
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
#include "Stdafx.h"
|
||||
#include "YaraExceptions.h"
|
||||
|
||||
namespace YaraSharp
|
||||
{
|
||||
// Code 1 is handled by OutOfMemoryException
|
||||
|
||||
// Code 2
|
||||
YaraAttachToProcessFailure::YaraAttachToProcessFailure() : Exception(String::Format("{0} - Code {1}", "ERROR_COULD_NOT_ATTACH_TO_PROCESS", ERROR_COULD_NOT_ATTACH_TO_PROCESS)) {}
|
||||
|
||||
// Code 3
|
||||
YaraOpenFileFailure::YaraOpenFileFailure() : Exception(String::Format("{0} - Code {1}", "ERROR_COULD_NOT_OPEN_FILE", ERROR_COULD_NOT_OPEN_FILE)) {}
|
||||
|
||||
// Code 4
|
||||
YaraMapFileFailure::YaraMapFileFailure() : Exception(String::Format("{0} - Code {1}", "ERROR_COULD_NOT_MAP_FILE", ERROR_COULD_NOT_MAP_FILE)) {}
|
||||
|
||||
// Code 6
|
||||
YaraInvalidFile::YaraInvalidFile() : Exception(String::Format("{0} - Code {1}", "ERROR_INVALID_FILE", ERROR_INVALID_FILE)) {}
|
||||
|
||||
// Code 7
|
||||
YaraCorruptFile::YaraCorruptFile() : Exception(String::Format("{0} - Code {1}", "ERROR_CORRUPT_FILE", ERROR_CORRUPT_FILE)) {}
|
||||
|
||||
// Code 8
|
||||
YaraUnsupportedFileVersion::YaraUnsupportedFileVersion() : Exception(String::Format("{0} - Code {1}", "ERROR_UNSUPPORTED_FILE_VERSION", ERROR_UNSUPPORTED_FILE_VERSION)) {}
|
||||
|
||||
// Code 9
|
||||
YaraInvalidRegularExpression::YaraInvalidRegularExpression() : Exception(String::Format("{0} - Code {1}", "ERROR_INVALID_REGULAR_EXPRESSION", ERROR_INVALID_REGULAR_EXPRESSION)) {}
|
||||
|
||||
// Code 10
|
||||
YaraInvalidHexString::YaraInvalidHexString() : Exception(String::Format("{0} - Code {1}", "ERROR_INVALID_HEX_STRING", ERROR_INVALID_HEX_STRING)) {}
|
||||
|
||||
// Code 11
|
||||
YaraSyntaxError::YaraSyntaxError() : Exception(String::Format("{0} - Code {1}", "ERROR_SYNTAX_ERROR", ERROR_SYNTAX_ERROR)) {}
|
||||
|
||||
// Code 12
|
||||
YaraLoopNestingLimitExceeded::YaraLoopNestingLimitExceeded() : Exception(String::Format("{0} - Code {1}", "ERROR_LOOP_NESTING_LIMIT_EXCEEDED", ERROR_LOOP_NESTING_LIMIT_EXCEEDED)) {}
|
||||
|
||||
// Code 13
|
||||
YaraDuplicatedLoopIdentifier::YaraDuplicatedLoopIdentifier() : Exception(String::Format("{0} - Code {1}", "ERROR_DUPLICATED_LOOP_IDENTIFIER", ERROR_DUPLICATED_LOOP_IDENTIFIER)) {}
|
||||
|
||||
// Code 14
|
||||
YaraDuplicatedIdentifier::YaraDuplicatedIdentifier() : Exception(String::Format("{0} - Code {1}", "ERROR_DUPLICATED_IDENTIFIER", ERROR_DUPLICATED_IDENTIFIER)) {}
|
||||
|
||||
// Code 15
|
||||
YaraDuplicatedTagIdentifier::YaraDuplicatedTagIdentifier() : Exception(String::Format("{0} - Code {1}", "ERROR_DUPLICATED_TAG_IDENTIFIER", ERROR_DUPLICATED_TAG_IDENTIFIER)) {}
|
||||
|
||||
// Code 16
|
||||
YaraDuplicatedMetaIdentifier::YaraDuplicatedMetaIdentifier() : Exception(String::Format("{0} - Code {1}", "ERROR_DUPLICATED_META_IDENTIFIER", ERROR_DUPLICATED_META_IDENTIFIER)) {}
|
||||
|
||||
// Code 17
|
||||
YaraDuplicatedStringIdentifier::YaraDuplicatedStringIdentifier() : Exception(String::Format("{0} - Code {1}", "ERROR_DUPLICATED_STRING_IDENTIFIER", ERROR_DUPLICATED_STRING_IDENTIFIER)) {}
|
||||
|
||||
// Code 18
|
||||
YaraUnreferencedString::YaraUnreferencedString() : Exception(String::Format("{0} - Code {1}", "ERROR_UNREFERENCED_STRING", ERROR_UNREFERENCED_STRING)) {}
|
||||
|
||||
// Code 19
|
||||
YaraUndefinedString::YaraUndefinedString() : Exception(String::Format("{0} - Code {1}", "ERROR_UNDEFINED_STRING", ERROR_UNDEFINED_STRING)) {}
|
||||
|
||||
// Code 20
|
||||
YaraUndefinedIdentifier::YaraUndefinedIdentifier() : Exception(String::Format("{0} - Code {1}", "ERROR_UNDEFINED_IDENTIFIER", ERROR_UNDEFINED_IDENTIFIER)) {}
|
||||
|
||||
// Code 21
|
||||
YaraMisplacedAnonymousString::YaraMisplacedAnonymousString() : Exception(String::Format("{0} - Code {1}", "ERROR_MISPLACED_ANONYMOUS_STRING", ERROR_MISPLACED_ANONYMOUS_STRING)) {}
|
||||
|
||||
// Code 22
|
||||
YaraCircularReference::YaraCircularReference() : Exception(String::Format("{0} - Code {1}", "ERROR_INCLUDES_CIRCULAR_REFERENCE", ERROR_INCLUDES_CIRCULAR_REFERENCE)) {}
|
||||
|
||||
// Code 23
|
||||
YaraDepthExceeded::YaraDepthExceeded() : Exception(String::Format("{0} - Code {1}", "ERROR_INCLUDE_DEPTH_EXCEEDED", ERROR_INCLUDE_DEPTH_EXCEEDED)) {}
|
||||
|
||||
// Code 24
|
||||
YaraWrongType::YaraWrongType() : Exception(String::Format("{0} - Code {1}", "ERROR_WRONG_TYPE", ERROR_WRONG_TYPE)) {}
|
||||
|
||||
// Code 25
|
||||
YaraExecStackOverflow::YaraExecStackOverflow() : Exception(String::Format("{0} - Code {1}", "ERROR_EXEC_STACK_OVERFLOW", ERROR_EXEC_STACK_OVERFLOW)) {}
|
||||
|
||||
// Code 26
|
||||
YaraScanTimeout::YaraScanTimeout() : Exception(String::Format("{0} - Code {1}", "ERROR_SCAN_TIMEOUT", ERROR_SCAN_TIMEOUT)) {}
|
||||
|
||||
// Code 27
|
||||
YaraTooManyScanThreads::YaraTooManyScanThreads() : Exception(String::Format("{0} - Code {1}", "ERROR_TOO_MANY_SCAN_THREADS", ERROR_TOO_MANY_SCAN_THREADS)) {}
|
||||
|
||||
// Code 28
|
||||
YaraCallbackError::YaraCallbackError() : Exception(String::Format("{0} - Code {1}", "ERROR_CALLBACK_ERROR", ERROR_CALLBACK_ERROR)) {}
|
||||
|
||||
// Code 29
|
||||
YaraInvalidArgument::YaraInvalidArgument() : Exception(String::Format("{0} - Code {1}", "ERROR_INVALID_ARGUMENT", ERROR_INVALID_ARGUMENT)) {}
|
||||
|
||||
// Code 30
|
||||
YaraTooManyMatches::YaraTooManyMatches() : Exception(String::Format("{0} - Code {1}", "ERROR_TOO_MANY_MATCHES", ERROR_TOO_MANY_MATCHES)) {}
|
||||
|
||||
// Code 31
|
||||
YaraInternalFatalError::YaraInternalFatalError() : Exception(String::Format("{0} - Code {1}", "ERROR_INTERNAL_FATAL_ERROR", ERROR_INTERNAL_FATAL_ERROR)) {}
|
||||
|
||||
// Code 32
|
||||
YaraNestedForOfLoop::YaraNestedForOfLoop() : Exception(String::Format("{0} - Code {1}", "ERROR_NESTED_FOR_OF_LOOP", ERROR_NESTED_FOR_OF_LOOP)) {}
|
||||
|
||||
// Code 33
|
||||
YaraInvalidFieldName::YaraInvalidFieldName() : Exception(String::Format("{0} - Code {1}", "ERROR_INVALID_FIELD_NAME", ERROR_INVALID_FIELD_NAME)) {}
|
||||
|
||||
// Code 34
|
||||
YaraUnknownModule::YaraUnknownModule() : Exception(String::Format("{0} - Code {1}", "ERROR_UNKNOWN_MODULE", ERROR_UNKNOWN_MODULE)) {}
|
||||
|
||||
// Code 35
|
||||
YaraNotAStructure::YaraNotAStructure() : Exception(String::Format("{0} - Code {1}", "ERROR_NOT_A_STRUCTURE", ERROR_NOT_A_STRUCTURE)) {}
|
||||
|
||||
// Code 36
|
||||
YaraNotIndexable::YaraNotIndexable() : Exception(String::Format("{0} - Code {1}", "ERROR_NOT_INDEXABLE", ERROR_NOT_INDEXABLE)) {}
|
||||
|
||||
// Code 37
|
||||
YaraNotAFunction::YaraNotAFunction() : Exception(String::Format("{0} - Code {1}", "ERROR_NOT_A_FUNCTION", ERROR_NOT_A_FUNCTION)) {}
|
||||
|
||||
// Code 38
|
||||
YaraInvalidFormat::YaraInvalidFormat() : Exception(String::Format("{0} - Code {1}", "ERROR_INVALID_FORMAT", ERROR_INVALID_FORMAT)) {}
|
||||
|
||||
// Code 39
|
||||
YaraTooManyArguments::YaraTooManyArguments() : Exception(String::Format("{0} - Code {1}", "ERROR_TOO_MANY_ARGUMENTS", ERROR_TOO_MANY_ARGUMENTS)) {}
|
||||
|
||||
// Code 40
|
||||
YaraWrongArguments::YaraWrongArguments() : Exception(String::Format("{0} - Code {1}", "ERROR_WRONG_ARGUMENTS", ERROR_WRONG_ARGUMENTS)) {}
|
||||
|
||||
// Code 41
|
||||
YaraWrongReturnType::YaraWrongReturnType() : Exception(String::Format("{0} - Code {1}", "ERROR_WRONG_RETURN_TYPE", ERROR_WRONG_RETURN_TYPE)) {}
|
||||
|
||||
// Code 42
|
||||
YaraDuplicatedStructureMember::YaraDuplicatedStructureMember() : Exception(String::Format("{0} - Code {1}", "ERROR_DUPLICATED_STRUCTURE_MEMBER", ERROR_DUPLICATED_STRUCTURE_MEMBER)) {}
|
||||
|
||||
// Code 43
|
||||
YaraEmptyString::YaraEmptyString() : Exception(String::Format("{0} - Code {1}", "ERROR_EMPTY_STRING", ERROR_EMPTY_STRING)) {}
|
||||
|
||||
// Code 44
|
||||
YaraDivisionByZero::YaraDivisionByZero() : Exception(String::Format("{0} - Code {1}", "ERROR_DIVISION_BY_ZERO", ERROR_DIVISION_BY_ZERO)) {}
|
||||
|
||||
// Code 45
|
||||
YaraRegularExpressionTooLarge::YaraRegularExpressionTooLarge() : Exception(String::Format("{0} - Code {1}", "ERROR_REGULAR_EXPRESSION_TOO_LARGE", ERROR_REGULAR_EXPRESSION_TOO_LARGE)) {}
|
||||
|
||||
// Code 46
|
||||
YaraTooManyReFibers::YaraTooManyReFibers() : Exception(String::Format("{0} - Code {1}", "ERROR_TOO_MANY_RE_FIBERS", ERROR_TOO_MANY_RE_FIBERS)) {}
|
||||
|
||||
// Code 47
|
||||
YaraCouldNotReadProcessMemory::YaraCouldNotReadProcessMemory() : Exception(String::Format("{0} - Code {1}", "ERROR_COULD_NOT_READ_PROCESS_MEMORY", ERROR_COULD_NOT_READ_PROCESS_MEMORY)) {}
|
||||
|
||||
// Code 48
|
||||
YaraInvalidExternalVariableType::YaraInvalidExternalVariableType() : Exception(String::Format("{0} - Code {1}", "ERROR_INVALID_EXTERNAL_VARIABLE_TYPE", ERROR_INVALID_EXTERNAL_VARIABLE_TYPE)) {}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
#pragma once
|
||||
|
||||
namespace YaraSharp
|
||||
{
|
||||
// Code 1 is handled by OutOfMemoryException
|
||||
|
||||
// Code 2
|
||||
public ref class YaraAttachToProcessFailure : public Exception
|
||||
{
|
||||
public:
|
||||
YaraAttachToProcessFailure();
|
||||
};
|
||||
|
||||
// Code 3
|
||||
public ref class YaraOpenFileFailure : public Exception
|
||||
{
|
||||
public:
|
||||
YaraOpenFileFailure();
|
||||
};
|
||||
|
||||
// Code 4
|
||||
public ref class YaraMapFileFailure : public Exception
|
||||
{
|
||||
public:
|
||||
YaraMapFileFailure();
|
||||
};
|
||||
|
||||
// Code 6
|
||||
public ref class YaraInvalidFile : public Exception
|
||||
{
|
||||
public:
|
||||
YaraInvalidFile();
|
||||
};
|
||||
|
||||
// Code 7
|
||||
public ref class YaraCorruptFile : public Exception
|
||||
{
|
||||
public:
|
||||
YaraCorruptFile();
|
||||
};
|
||||
|
||||
// Code 8
|
||||
public ref class YaraUnsupportedFileVersion : public Exception
|
||||
{
|
||||
public:
|
||||
YaraUnsupportedFileVersion();
|
||||
};
|
||||
|
||||
// Code 9
|
||||
public ref class YaraInvalidRegularExpression : public Exception
|
||||
{
|
||||
public:
|
||||
YaraInvalidRegularExpression();
|
||||
};
|
||||
|
||||
// Code 10
|
||||
public ref class YaraInvalidHexString : public Exception
|
||||
{
|
||||
public:
|
||||
YaraInvalidHexString();
|
||||
};
|
||||
|
||||
// Code 11
|
||||
public ref class YaraSyntaxError : public Exception
|
||||
{
|
||||
public:
|
||||
YaraSyntaxError();
|
||||
};
|
||||
|
||||
// Code 12
|
||||
public ref class YaraLoopNestingLimitExceeded : public Exception
|
||||
{
|
||||
public:
|
||||
YaraLoopNestingLimitExceeded();
|
||||
};
|
||||
|
||||
// Code 13
|
||||
public ref class YaraDuplicatedLoopIdentifier : public Exception
|
||||
{
|
||||
public:
|
||||
YaraDuplicatedLoopIdentifier();
|
||||
};
|
||||
|
||||
// Code 14
|
||||
public ref class YaraDuplicatedIdentifier : public Exception
|
||||
{
|
||||
public:
|
||||
YaraDuplicatedIdentifier();
|
||||
};
|
||||
|
||||
// Code 15
|
||||
public ref class YaraDuplicatedTagIdentifier : public Exception
|
||||
{
|
||||
public:
|
||||
YaraDuplicatedTagIdentifier();
|
||||
};
|
||||
|
||||
// Code 16
|
||||
public ref class YaraDuplicatedMetaIdentifier : public Exception
|
||||
{
|
||||
public:
|
||||
YaraDuplicatedMetaIdentifier();
|
||||
};
|
||||
|
||||
// Code 17
|
||||
public ref class YaraDuplicatedStringIdentifier : public Exception
|
||||
{
|
||||
public:
|
||||
YaraDuplicatedStringIdentifier();
|
||||
};
|
||||
|
||||
// Code 18
|
||||
public ref class YaraUnreferencedString : public Exception
|
||||
{
|
||||
public:
|
||||
YaraUnreferencedString();
|
||||
};
|
||||
|
||||
// Code 19
|
||||
public ref class YaraUndefinedString : public Exception
|
||||
{
|
||||
public:
|
||||
YaraUndefinedString();
|
||||
};
|
||||
|
||||
// Code 20
|
||||
public ref class YaraUndefinedIdentifier : public Exception
|
||||
{
|
||||
public:
|
||||
YaraUndefinedIdentifier();
|
||||
};
|
||||
|
||||
// Code 21
|
||||
public ref class YaraMisplacedAnonymousString : public Exception
|
||||
{
|
||||
public:
|
||||
YaraMisplacedAnonymousString();
|
||||
};
|
||||
|
||||
// Code 22
|
||||
public ref class YaraCircularReference : public Exception
|
||||
{
|
||||
public:
|
||||
YaraCircularReference();
|
||||
};
|
||||
|
||||
// Code 23
|
||||
public ref class YaraDepthExceeded : public Exception
|
||||
{
|
||||
public:
|
||||
YaraDepthExceeded();
|
||||
};
|
||||
|
||||
// Code 24
|
||||
public ref class YaraWrongType : public Exception
|
||||
{
|
||||
public:
|
||||
YaraWrongType();
|
||||
};
|
||||
|
||||
// Code 25
|
||||
public ref class YaraExecStackOverflow : public Exception
|
||||
{
|
||||
public:
|
||||
YaraExecStackOverflow();
|
||||
};
|
||||
|
||||
// Code 26
|
||||
public ref class YaraScanTimeout : public Exception
|
||||
{
|
||||
public:
|
||||
YaraScanTimeout();
|
||||
};
|
||||
|
||||
// Code 27
|
||||
public ref class YaraTooManyScanThreads : public Exception
|
||||
{
|
||||
public:
|
||||
YaraTooManyScanThreads();
|
||||
};
|
||||
|
||||
// Code 28
|
||||
public ref class YaraCallbackError : public Exception
|
||||
{
|
||||
public:
|
||||
YaraCallbackError();
|
||||
};
|
||||
|
||||
// Code 29
|
||||
public ref class YaraInvalidArgument : public Exception
|
||||
{
|
||||
public:
|
||||
YaraInvalidArgument();
|
||||
};
|
||||
|
||||
// Code 30
|
||||
public ref class YaraTooManyMatches : public Exception
|
||||
{
|
||||
public:
|
||||
YaraTooManyMatches();
|
||||
};
|
||||
|
||||
// Code 31
|
||||
public ref class YaraInternalFatalError : public Exception
|
||||
{
|
||||
public:
|
||||
YaraInternalFatalError();
|
||||
};
|
||||
|
||||
// Code 32
|
||||
public ref class YaraNestedForOfLoop : public Exception
|
||||
{
|
||||
public:
|
||||
YaraNestedForOfLoop();
|
||||
};
|
||||
|
||||
// Code 33
|
||||
public ref class YaraInvalidFieldName : public Exception
|
||||
{
|
||||
public:
|
||||
YaraInvalidFieldName();
|
||||
};
|
||||
|
||||
// Code 34
|
||||
public ref class YaraUnknownModule : public Exception
|
||||
{
|
||||
public:
|
||||
YaraUnknownModule();
|
||||
};
|
||||
|
||||
// Code 35
|
||||
public ref class YaraNotAStructure : public Exception
|
||||
{
|
||||
public:
|
||||
YaraNotAStructure();
|
||||
};
|
||||
|
||||
// Code 36
|
||||
public ref class YaraNotIndexable : public Exception
|
||||
{
|
||||
public:
|
||||
YaraNotIndexable();
|
||||
};
|
||||
|
||||
// Code 37
|
||||
public ref class YaraNotAFunction : public Exception
|
||||
{
|
||||
public:
|
||||
YaraNotAFunction();
|
||||
};
|
||||
|
||||
// Code 38
|
||||
public ref class YaraInvalidFormat : public Exception
|
||||
{
|
||||
public:
|
||||
YaraInvalidFormat();
|
||||
};
|
||||
|
||||
// Code 39
|
||||
public ref class YaraTooManyArguments : public Exception
|
||||
{
|
||||
public:
|
||||
YaraTooManyArguments();
|
||||
};
|
||||
|
||||
// Code 40
|
||||
public ref class YaraWrongArguments : public Exception
|
||||
{
|
||||
public:
|
||||
YaraWrongArguments();
|
||||
};
|
||||
|
||||
// Code 41
|
||||
public ref class YaraWrongReturnType : public Exception
|
||||
{
|
||||
public:
|
||||
YaraWrongReturnType();
|
||||
};
|
||||
|
||||
// Code 42
|
||||
public ref class YaraDuplicatedStructureMember : public Exception
|
||||
{
|
||||
public:
|
||||
YaraDuplicatedStructureMember();
|
||||
};
|
||||
|
||||
// Code 43
|
||||
public ref class YaraEmptyString : public Exception
|
||||
{
|
||||
public:
|
||||
YaraEmptyString();
|
||||
};
|
||||
|
||||
// Code 44
|
||||
public ref class YaraDivisionByZero : public Exception
|
||||
{
|
||||
public:
|
||||
YaraDivisionByZero();
|
||||
};
|
||||
|
||||
// Code 45
|
||||
public ref class YaraRegularExpressionTooLarge : public Exception
|
||||
{
|
||||
public:
|
||||
YaraRegularExpressionTooLarge();
|
||||
};
|
||||
|
||||
// Code 46
|
||||
public ref class YaraTooManyReFibers : public Exception
|
||||
{
|
||||
public:
|
||||
YaraTooManyReFibers();
|
||||
};
|
||||
|
||||
// Code 47
|
||||
public ref class YaraCouldNotReadProcessMemory : public Exception
|
||||
{
|
||||
public:
|
||||
YaraCouldNotReadProcessMemory();
|
||||
};
|
||||
|
||||
// Code 48
|
||||
public ref class YaraInvalidExternalVariableType : public Exception
|
||||
{
|
||||
public:
|
||||
YaraInvalidExternalVariableType();
|
||||
};
|
||||
}
|
||||
Binary file not shown.
@@ -164,6 +164,7 @@
|
||||
<ClInclude Include="Scanner.h" />
|
||||
<ClInclude Include="Matches.h" />
|
||||
<ClInclude Include="Stdafx.h" />
|
||||
<ClInclude Include="YaraExceptions.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AssemblyInfo.cpp" />
|
||||
@@ -181,6 +182,7 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Instance.cpp" />
|
||||
<ClCompile Include="YaraExceptions.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="YaraSharp.rc" />
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="YaraExceptions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AssemblyInfo.cpp">
|
||||
@@ -73,6 +76,9 @@
|
||||
<ClCompile Include="Instance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="YaraExceptions.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="YaraSharp.rc" />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>YaraSharp</id>
|
||||
<version>1.3.0</version>
|
||||
<version>1.3.1</version>
|
||||
<title>YaraSharp</title>
|
||||
<authors>stellarbears</authors>
|
||||
<owners>stellarbears</owners>
|
||||
|
||||
Reference in New Issue
Block a user