To clarify the layer data, the layer count is always there and the rest of the layer data is replaced by a UINT32_MAX if the layer is empty.

so the end of the patch file goes: patch index > layer count > layer data (for each layer, UINT32_MAX if empty)

good luck!