In function pefile_open_custom, pe_file->close_fn is never assigned to.
That means that the close_fn will not be called in pefile_close, and handles will be leaked until the used C runtime can no longer open any further files.
The simple fix would be to insert the line
pe_file->close_fn = close_fn;
after
pe_file->seek_fn = seek_fn;
In function pefile_open_custom, pe_file->close_fn is never assigned to. That means that the close_fn will not be called in pefile_close, and handles will be leaked until the used C runtime can no longer open any further files. The simple fix would be to insert the line pe_file->close_fn = close_fn; after pe_file->seek_fn = seek_fn;