fn is_generally_valid(current_payload: &[u8], starting_payload: &[u8]) -> bool {
        // Check to see if the payload itself was modified in memory.
        if current_payload != starting_payload {
            return false;
        }

        // Analyze the payload to determine if it should be treated as valid and stored
        // in the database. Treat payloads with branch instructions as invalid.
        let valid = panic::catch_unwind(|| {
            let instr_cursor = Cursor::new(current_payload);
            let mut instr_reader = InstructionReader::new(instr_cursor, Mode::Protected);

            let mut valid = true;
            loop {
                let instr_res = instr_reader.read();

                if instr_res.is_err() {
                    break;
                }

                let instr = instr_res.unwrap();

                match instr.mnemonic {
                    // Ignore conditional branch instructions
                    Mnemonic::JA
                    | Mnemonic::JAE
                    | Mnemonic::JB
                    | Mnemonic::JBE
                    | Mnemonic::JC
                    | Mnemonic::JCXZ
                    | Mnemonic::JE
                    | Mnemonic::JECXZ
                    | Mnemonic::JG
                    | Mnemonic::JGE
                    | Mnemonic::JL
                    | Mnemonic::JLE
                    | Mnemonic::JNA
                    | Mnemonic::JNAE
                    | Mnemonic::JNB
                    | Mnemonic::JNBE
                    | Mnemonic::JNC
                    | Mnemonic::JNE
                    | Mnemonic::JNG
                    | Mnemonic::JNGE
                    | Mnemonic::JNL
                    | Mnemonic::JNLE
                    | Mnemonic::JNO
                    | Mnemonic::JNP
                    | Mnemonic::JNS
                    | Mnemonic::JNZ
                    | Mnemonic::JO
                    | Mnemonic::JP
                    | Mnemonic::JPE
                    | Mnemonic::JPO
                    | Mnemonic::JRCXZ
                    | Mnemonic::JS
                    | Mnemonic::JZ
                    | Mnemonic::LOOP
                    | Mnemonic::LOOPE
                    | Mnemonic::LOOPNE => {
                        valid = false;
                        break;
                    }

                    // Ignore unconditional branch instructions
                    Mnemonic::CALL | Mnemonic::JMP | Mnemonic::RET => {
                        valid = false;
                        break;
                    }

                    _ => {}
                };
            }

            valid
        });

        if valid.is_err() || valid.unwrap() == false {
            return false;
        }

        true
    }
// Checks to see if the current payload is generally valid using the following logic:
//   - the payload does not exceed the maximum payload size.
//   - the current payload in memory matches the initial version that was stored in memory (e.g. not corrupted).
//   - the current payload does not contain a branch instruction
Checks to see if the current payload is generally valid using the following logic:
the payload does not exceed the maximum payload size.
the current payload in memory matches the initial version that was stored in memory .
the current payload does not contain a branch instruction
Checks to see if the current payload is generally valid using the following logic : the payload does not exceed the maximum payload size . the current payload in memory matches the initial version that was stored in memory . the current payload does not contain a branch instruction
fn is_generally_valid(current_payload: &[u8], starting_payload: &[u8]) -> bool {
        // Check to see if the payload itself was modified in memory.
        if current_payload != starting_payload {
            return false;
        }
        // Analyze the payload to determine if it should be treated as valid and stored
        // in the database. Treat payloads with branch instructions as invalid.
        let valid = panic::catch_unwind(|| {
            let instr_cursor = Cursor::new(current_payload);
            let mut instr_reader = InstructionReader::new(instr_cursor, Mode::Protected);
            let mut valid = true;
            loop {
                let instr_res = instr_reader.read();
                if instr_res.is_err() {
                    break;
                }
                let instr = instr_res.unwrap();
                match instr.mnemonic {
                    // Ignore conditional branch instructions
                    Mnemonic::JA
                    | Mnemonic::JAE
                    | Mnemonic::JB
                    | Mnemonic::JBE
                    | Mnemonic::JC
                    | Mnemonic::JCXZ
                    | Mnemonic::JE
                    | Mnemonic::JECXZ
                    | Mnemonic::JG
                    | Mnemonic::JGE
                    | Mnemonic::JL
                    | Mnemonic::JLE
                    | Mnemonic::JNA
                    | Mnemonic::JNAE
                    | Mnemonic::JNB
                    | Mnemonic::JNBE
                    | Mnemonic::JNC
                    | Mnemonic::JNE
                    | Mnemonic::JNG
                    | Mnemonic::JNGE
                    | Mnemonic::JNL
                    | Mnemonic::JNLE
                    | Mnemonic::JNO
                    | Mnemonic::JNP
                    | Mnemonic::JNS
                    | Mnemonic::JNZ
                    | Mnemonic::JO
                    | Mnemonic::JP
                    | Mnemonic::JPE
                    | Mnemonic::JPO
                    | Mnemonic::JRCXZ
                    | Mnemonic::JS
                    | Mnemonic::JZ
                    | Mnemonic::LOOP
                    | Mnemonic::LOOPE
                    | Mnemonic::LOOPNE => {
                        valid = false;
                        break;
                    }
                    // Ignore unconditional branch instructions
                    Mnemonic::CALL | Mnemonic::JMP | Mnemonic::RET => {
                        valid = false;
                        break;
                    }
                    _ => {}
                };
            }
            valid
        });
        if valid.is_err() || valid.unwrap() == false {
            return false;
        }
        true
    }
fn is_generally_valid ( current_payload : & [ u8 ] , starting_payload : & [ u8 ] ) -> bool { // Check to see if the payload itself was modified in memory. if current_payload != starting_payload { return false ; } // Analyze the payload to determine if it should be treated as valid and stored // in the database. Treat payloads with branch instructions as invalid. let valid = panic :: catch_unwind ( | | { let instr_cursor = Cursor :: new ( current_payload ) ; let mut instr_reader = InstructionReader :: new ( instr_cursor , Mode :: Protected ) ; let mut valid = true ; loop { let instr_res = instr_reader . read ( ) ; if instr_res . is_err ( ) { break ; } let instr = instr_res . unwrap ( ) ; match instr . mnemonic { // Ignore conditional branch instructions Mnemonic :: JA | Mnemonic :: JAE | Mnemonic :: JB | Mnemonic :: JBE | Mnemonic :: JC | Mnemonic :: JCXZ | Mnemonic :: JE | Mnemonic :: JECXZ | Mnemonic :: JG | Mnemonic :: JGE | Mnemonic :: JL | Mnemonic :: JLE | Mnemonic :: JNA | Mnemonic :: JNAE | Mnemonic :: JNB | Mnemonic :: JNBE | Mnemonic :: JNC | Mnemonic :: JNE | Mnemonic :: JNG | Mnemonic :: JNGE | Mnemonic :: JNL | Mnemonic :: JNLE | Mnemonic :: JNO | Mnemonic :: JNP | Mnemonic :: JNS | Mnemonic :: JNZ | Mnemonic :: JO | Mnemonic :: JP | Mnemonic :: JPE | Mnemonic :: JPO | Mnemonic :: JRCXZ | Mnemonic :: JS | Mnemonic :: JZ | Mnemonic :: LOOP | Mnemonic :: LOOPE | Mnemonic :: LOOPNE => { valid = false ; break ; } // Ignore unconditional branch instructions Mnemonic :: CALL | Mnemonic :: JMP | Mnemonic :: RET => { valid = false ; break ; } _ => { } } ; } valid } ) ; if valid . is_err ( ) || valid . unwrap ( ) == false { return false ; } true }
Checks to see if the current payload is generally valid using the following logic:
 the payload does not exceed the maximum payload size.
Checks to see if the current payload is generally valid using the following logic : the payload does not exceed the maximum payload size .
current_payload
&[u8]
starting_payload
&[u8]
current_payload
&[u8]
starting_payload
&[u8]