Assuming that at the beginning of the application you have access to the file, then opening the handle for it should prevent the operating system from being erased by the file on disk until the last link to the file is closed. This will allow you to search for the file in your heart. using this file without worry.
Create a global variable:
int app_fd;
The process for most of them is the same, in the main procedure it simply gives:
app_fd = open(argv[0], O_RDONLY);
at the beginning of execution. When it comes to the fact that you need to access the zip file, just use the file descriptor, not the file name.
At run time, if you do not have any form of handle to the source content of the application, you probably will not be able to access the contents of the zip file. This is due to the display of only the bootloader in the sections of the expected file. Content at the end of the binary will be considered garbage and not displayed.
To map the zip file in memory, you will need to take a different approach. You will need to insert .zip into the ELF (linux) / COFF (Windows) / Mach-O (Mac OS X) section of the binary file, which has properties set in such a way that it is guaranteed to be displayed in the application (this requires a lot of preliminary work in the application and a lot more work after processing). This is not trivial and probably involves quite a bit of coding to do it right for each platform.
As an aside, it is not difficult to remove the application from the Windows system while this application is running (I think you can move it if it is on NTFS, though).
source share