'This function takes the flItms dict and patches the
executable entry point to jump to the first code cave.'

def patch_initial_instructions(self):

    print '[*]    Patching    initial    entry    instructions'
    self.f.seek(self.flItms['LocOfEntryinCode'], 0)
    self.f.write(struct.pack('=B', int('E9', 16)))
    if (self.flItms['JMPtoCodeAddress'] < 0):
        self.f.write(struct.pack('<I', (4294967295 + self.flItms['JMPtoCodeAddress'])))
    else:
        self.f.write(struct.pack('<I', self.flItms['JMPtoCodeAddress']))
    if (self.flItms['count_bytes'] > 5):
        for i in range((self.flItms['count_bytes'] - 5)):
            self.f.write(struct.pack('=B', 144))
