| 480 | |
| 481 | |
| 482 | bool PluginCommand::IsValid(const PluginCommandContext& ctxt) const |
| 483 | { |
| 484 | if (!ctxt.binaryView) |
| 485 | return false; |
| 486 | |
| 487 | switch (m_command.type) |
| 488 | { |
| 489 | case DefaultPluginCommand: |
| 490 | if (!m_command.defaultIsValid) |
| 491 | return true; |
| 492 | return m_command.defaultIsValid(m_command.context, ctxt.binaryView->GetObject()); |
| 493 | case AddressPluginCommand: |
| 494 | if (!m_command.addressIsValid) |
| 495 | return true; |
| 496 | return m_command.addressIsValid(m_command.context, ctxt.binaryView->GetObject(), ctxt.address); |
| 497 | case RangePluginCommand: |
| 498 | if (ctxt.length == 0) |
| 499 | return false; |
| 500 | if (!m_command.rangeIsValid) |
| 501 | return true; |
| 502 | return m_command.rangeIsValid(m_command.context, ctxt.binaryView->GetObject(), ctxt.address, ctxt.length); |
| 503 | case FunctionPluginCommand: |
| 504 | if (!ctxt.function) |
| 505 | return false; |
| 506 | if (!m_command.functionIsValid) |
| 507 | return true; |
| 508 | return m_command.functionIsValid(m_command.context, ctxt.binaryView->GetObject(), ctxt.function->GetObject()); |
| 509 | case LowLevelILFunctionPluginCommand: |
| 510 | if (!ctxt.lowLevelILFunction) |
| 511 | return false; |
| 512 | if (!m_command.lowLevelILFunctionIsValid) |
| 513 | return true; |
| 514 | return m_command.lowLevelILFunctionIsValid( |
| 515 | m_command.context, ctxt.binaryView->GetObject(), ctxt.lowLevelILFunction->GetObject()); |
| 516 | case LowLevelILInstructionPluginCommand: |
| 517 | if (!ctxt.lowLevelILFunction) |
| 518 | return false; |
| 519 | if (ctxt.instrIndex == BN_INVALID_EXPR) |
| 520 | return false; |
| 521 | if (!m_command.lowLevelILInstructionIsValid) |
| 522 | return true; |
| 523 | return m_command.lowLevelILInstructionIsValid( |
| 524 | m_command.context, ctxt.binaryView->GetObject(), ctxt.lowLevelILFunction->GetObject(), ctxt.instrIndex); |
| 525 | case MediumLevelILFunctionPluginCommand: |
| 526 | if (!ctxt.mediumLevelILFunction) |
| 527 | return false; |
| 528 | if (!m_command.mediumLevelILFunctionIsValid) |
| 529 | return true; |
| 530 | return m_command.mediumLevelILFunctionIsValid( |
| 531 | m_command.context, ctxt.binaryView->GetObject(), ctxt.mediumLevelILFunction->GetObject()); |
| 532 | case MediumLevelILInstructionPluginCommand: |
| 533 | if (!ctxt.mediumLevelILFunction) |
| 534 | return false; |
| 535 | if (ctxt.instrIndex == BN_INVALID_EXPR) |
| 536 | return false; |
| 537 | if (!m_command.mediumLevelILInstructionIsValid) |
| 538 | return true; |
| 539 | return m_command.mediumLevelILInstructionIsValid( |
no test coverage detected