#include "Stdafx.h" // Matches namespace YaraSharp { // Rule compilation YSCompiler^ YSInstance::CompileFromFiles(List^ FilePathList, Dictionary^ externalVariables) { // TODO: add namespace support YSCompiler^ compiler = gcnew YSCompiler(externalVariables); compiler->AddFiles(FilePathList, externalVariables); return compiler; } // Scanning region List^ YSInstance::ScanFile(String^ path, YSRules^ rules, Dictionary^ externalVariables, int timeout) { YSScanner^ FScanner = gcnew YSScanner(rules, externalVariables); try { List^ results = FScanner->ScanFile(path); return results; } catch (System::Exception^ e) { throw e; } finally{ delete FScanner; } } // (not yet tested) List^ YSInstance::ScanProcess(int pID, YSRules^ rules, Dictionary^ externalVariables, int timeout) { YSScanner^ PScanner = gcnew YSScanner(rules, externalVariables); try { List^ results = PScanner->ScanProcess(pID); return results; } catch (System::Exception^ e) { throw e; } finally{ delete PScanner; } } // (not yet tested) List^ YSInstance::ScanMemory(uint8_t* buffer, int length, YSRules^ rules, Dictionary^ externalVariables, int timeout) { YSScanner^ MScanner = gcnew YSScanner(rules, externalVariables); try { List^ results = MScanner->ScanMemory(buffer, length); return results; } catch (System::Exception^ e) { throw e; } finally{ delete MScanner; } } // (not yet tested) List^ YSInstance::ScanMemory(array^ buffer, YSRules^ rules, Dictionary^ externalVariables, int timeout) { if (buffer == nullptr || buffer->Length == 0) return gcnew List(); else { pin_ptr bufferPointer = &buffer[0]; return ScanMemory(bufferPointer, buffer->Length, rules, externalVariables, timeout); } } Version^ YSInstance::GetVersion() { return Assembly::GetExecutingAssembly()->GetName()->Version; } }