Some due bill info from a pdf titled "Understandin
Post# of 36536
"....no need for manual intervention on the part of U.S. securities
firms. For their framework to operate successfully, the U.S.
utilizes, through their securities depository, an automated system
to track any trading done between the record and ex-date.
These trades have what is known as a “Due Bill” applied to them
to ensure purchasers of the security during this period receive
their entitled shares at the expense of the sellers – a process
otherwise known as “Due-Bill Tracking”."
So it appears there is an automated system that keeps track of the shares that are entitled to a dividend if bought or sold between the record date and the ex-date. Sounds like DTC (Depository Trust Company) is responsible for assuring the correct owners get the dividend.