+#define DEF_WRAP_FUNC(n) \
+STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_flush_ex_img#n(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token) \
+{\
+ (VOID)This;\
+ (VOID)Token;\
+ return EFI_SUCCESS;\
+}
+
+#define ITEM_WRAP_FUNC(n) ventoy_wrapper_file_flush_ex_img#n
+
+#if (VTOY_MAX_CONF_REPLACE > 2)
+DEF_WRAP_FUNC(2);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 3)
+DEF_WRAP_FUNC(3);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 4)
+DEF_WRAP_FUNC(4);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 5)
+DEF_WRAP_FUNC(5);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 6)
+DEF_WRAP_FUNC(6);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 7)
+DEF_WRAP_FUNC(7);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 8)
+#error "VTOY_MAX_CONF_REPLACE overflow"
+#endif
+
+static EFI_FILE_FLUSH_EX g_img_flush_func[VTOY_MAX_CONF_REPLACE] =
+{
+ ventoy_wrapper_file_flush_ex_img0,
+ ventoy_wrapper_file_flush_ex_img1,
+#if (VTOY_MAX_CONF_REPLACE > 2)
+ ITEM_WRAP_FUNC(2),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 3)
+ ITEM_WRAP_FUNC(3),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 4)
+ ITEM_WRAP_FUNC(4),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 5)
+ ITEM_WRAP_FUNC(5),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 6)
+ ITEM_WRAP_FUNC(6),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 7)
+ ITEM_WRAP_FUNC(7),
+#endif
+};
+
+STATIC ventoy_efi_file_replace *ventoy_wrapper_get_replace(EFI_FILE_HANDLE This)
+{
+ UINTN i;
+
+ if (This->FlushEx == ventoy_wrapper_file_flush_ex)
+ {
+ return &g_efi_file_replace;
+ }
+
+ for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
+ {
+ if (This->FlushEx == g_img_flush_func[i])
+ {
+ return g_img_file_replace + i;
+ }
+ }
+
+ return NULL;
+}