Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion YaraSharp/Scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,27 @@ namespace YaraSharp
(marshal_as<std::wstring>(Path)).c_str()));
return matches;
}

List<YSMatches^>^ YSScanner::ScanMemory(uint8_t* Buffer, int Length)
{
YSException::ThrowOnError(yr_scanner_scan_mem(scanner, Buffer, Length));
return matches;
}

List<YSMatches^>^ YSScanner::ScanMemory(array<uint8_t>^ buffer)
{
if (buffer == nullptr || buffer->Length == 0)
{
return gcnew List<YSMatches^>();
}
else
{
pin_ptr<uint8_t> bufferPointer = &buffer[0];
YSException::ThrowOnError(yr_scanner_scan_mem(scanner, bufferPointer, buffer->Length));
return matches;
}
}

// Set externals
void YSScanner::SetScannerExternals(Dictionary<String^, Object^>^ externalVariables)
{
Expand All @@ -72,7 +87,7 @@ namespace YaraSharp
throw gcnew NotSupportedException(String::Format("Unsupported external variable: '{0}'", VariableType->Name));

if (ExternalError != ERROR_SUCCESS)
YSException::ThrowOnError("(Scanner) Error during external variable intialization");
YSException::ThrowOnError("(Scanner) Error during external variable initialization");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions YaraSharp/Scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace YaraSharp
List<YSMatches^>^ ScanProcess(int pID);
List<YSMatches^>^ ScanFile(String^ path);
List<YSMatches^>^ ScanMemory(uint8_t* buffer, int length);
List<YSMatches^>^ ScanMemory(array<uint8_t>^ buffer);
int HandleScannerCallback(int message, void* data, void* context);
private:
void SetScannerCallback();
Expand Down