cwindowscd-rom

Different executables from different cds run always the same code


I burned 25 cd-rom with a c executable called "Data.exe". All cds had the same CD name and same executable name, but different executable versions. Here's the code:

CD0

system("C:\\_folder\\_folder.exe 0");

CD1

system("C:\\_folder\\_folder.exe 1");

.....and so on.....

CD24

system("C:\\_folder\\_folder.exe 24");

The "C:\_folder\_folder.exe" code was

printf(argv[1]);

Just to check if the cds were burned correctly. (The core idea behind all of this was to let the cds identify themselves and move the real logic to the hosting pc to make cds reusable for my needs.)


The problem is that when I randomly insert the cds into the pc, often the executable of the previous inserted cd gets "stuck" and shows itself instead of the new one.

For example if I insert CD16 I get printed 16, then I insert CD20 and I still get printed 16 from CD20 executable, also the last edit date of the CD20 executable is still the one from CD16. After a reboot everything gets "reset" and the first cd inserted becomes the new "stuck" one. The same problem applies to all other cds.

It seemed a trivial task and I am surely missing something. Where's my error?


Solution

  • Windows does a media changed test on the CD unit prior to access it, to check if the CD has been changed from the last call. If so, it discards all the buffered cache blocks and reloads it with fresh data from the CD. The mechanism for media changed functionality is commonly placed on the volume-id tag that is stored on formatting with a new uuid for each volume. The volume expected by windows id is not present in ISO-9660 formats, so normally the operating system follows an alternative way to detect if the media has been changed. Try to change the volume label, to use a different one on each CD disk, so windows probably uses this to check the volume has been changed (just opening the cd door is not enough, as not all the cd units have door open hardware check)

    If that's the case, then just reading the volume label of the cd unit can be enough than to simulate running a program that outputs different status or info each time.