From: Victor Chiletto v@hnn.net.br
More specifically: a mod for Fallout: New Vegas relies on rewind not modifying the first argument passed to it [1].
[1]: https://github.com/jazzisparis/UIO-User-Interface-Organizer/blob/426d96391f9... --- dlls/ucrtbase/tests/misc.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index 069de0787b7..17b1dca4fcf 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -1591,6 +1591,31 @@ static void test_fopen_exclusive( void ) unlink(path); }
+#if defined(__i386__) +static void test_rewind_i386_abi(void) +{ + FILE *fp = fopen("rewind_abi.tst", "wb"), *fp2; + + rewind(fp); + +#if defined(__GNUC__) + __asm__ volatile ("push %2; call %P1; movl (%%esp), %0; addl $4, %%esp;" : "=r" (fp2) : "i" (rewind), "r" (fp)); +#else + __asm + { + push fp; + call rewind; + mov fp2, [esp]; + add esp, 4; + } +#endif + + todo_wine ok(fp == fp2, "rewind modified the first argument in the stack\n"); + + fclose(fp); +} +#endif + START_TEST(misc) { int arg_c; @@ -1633,4 +1658,7 @@ START_TEST(misc) test_thread_storage(); test_fenv(); test_fopen_exclusive(); +#if defined(__i386__) + test_rewind_i386_abi(); +#endif }