How does the particular piece of flap behind an engine on a B777 work?
It is called "inboard aileron" or "high-speed aileron" and is actually a flaperon. It will deflect with the flaps but not extend backwards. At high speed, the outboard ailerons are locked and all roll control is achieved by deflecting the inboard ailerons (and spoilers, if needed). This helps to reduce wing torsion and twist.

Background: Since the trailing edge's sweep angle has a break at the wing station of the engine, and since in Boeing aircraft the flaps extend perpendicularly to the hinge line, there must be a gap between inboard and outboard flaps, otherwise they would collide during extension. This gap is best placed in the station of the engine blast, and is filled with a simple hinged flap. Note that Airbus aircraft have rear-sliding flaps, which stay at a constant span location and can be adjacent to each other even at the wing station of the sweep change.



Boeing 767 from below. Picture by Adrian Pingstone (source)

The picture is of a Boeing 767, but shows the flap arrangement nicely. Note the offset of the forward and rear part of the Küchemann bodies which house the flap tracks.