- RefreshVolume(hDevice);
- Sleep(2000);
- EnsureDriveReady(hDevice, 30000);
+ if (xbox_ref_capacity_is_game_view(entrySectors)) {
+ printf("[XBOX-REF] Entry state already exposes the Xbox game view; skipping the redundant initial handshake and tray cycle.\n");
+ } else {
+ printf("[XBOX-REF] Entry state appears locked/video; attempting the full handshake directly without a media transition.\n");
+ UnlockDrive(hDevice);
+ verifiedSectors = xbox_ref_refresh_ready_capacity(hDevice);
+ preparedAfterHandshake = TRUE;
+ printf("[XBOX-REF] Direct-handshake READ CAPACITY: %u sectors.\n", verifiedSectors);
+
+ if (!xbox_ref_capacity_is_game_view(verifiedSectors)) {
+ printf("[XBOX-REF][WARN] Direct handshake did not expose the Xbox game view; performing one tray-cycle recovery and retry.\n");
+ AutomateTrayCycle(hDevice);
+ printf("[XBOX-REF] Re-applying the full handshake after recovery media change.\n");
+ UnlockDrive(hDevice);
+ verifiedSectors = xbox_ref_refresh_ready_capacity(hDevice);
+ printf("[XBOX-REF] Recovery-handshake READ CAPACITY: %u sectors.\n", verifiedSectors);
+
+ if (!xbox_ref_capacity_is_game_view(verifiedSectors)) {
+ printf("[XBOX-REF] Fatal: Xbox game view was not established after direct and recovery handshakes.\n");
+ goto cleanup;
+ }
+ }
+ }
+
+ if (!preparedAfterHandshake)
+ xbox_ref_refresh_ready_capacity(hDevice);
+ }