Module: wine
Branch: master
Commit: 542dc085c91c249ca569473029578f4ed0d38537
URL: https://source.winehq.org/git/wine.git/?a=commit;h=542dc085c91c249ca5694730…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Mon Jul 19 14:23:41 2021 +0200
kernel32/tests: Allow failure when loading the 268 bytes minimal PE image.
Windows 10 1809+ rejects this minimal image so allow ERROR_BAD_EXE_FORMAT
as a valid result.
Also adjust the comment to reflect the range of Windows versions that
usually accept this image and note that there are some exceptions which
means there are other unidentified factors at play.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=51185
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/kernel32/tests/loader.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 0a13179b106..8faacb07587 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -860,7 +860,10 @@ static void test_Loader(void)
0,
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT } /* vista is more strict */
},
- /* Minimal PE image that Windows7 is able to load: 268 bytes */
+ /* Minimal PE image initially created for Windows 7 and accepted from
+ * Vista up to Windows 10 1709 with some unexplained exceptions:
+ * 268 bytes
+ */
{ 0x04,
0, 0xf0, /* optional header size just forces 0xf0 bytes to be written,
0 or another number don't change the behaviour, what really
@@ -868,7 +871,7 @@ static void test_Loader(void)
0x04 /* also serves as e_lfanew in the truncated MZ header */, 0x04,
0x40, /* minimal image size that Windows7 accepts */
0,
- { ERROR_SUCCESS }
+ { ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT } /* rejected by win10 1809+ */
},
/* the following data mimics the PE image which 8k demos have */
{ 0x04,
Module: wine
Branch: master
Commit: 7dc02dcd079c37e7838b51063eb197e8d4bfe591
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7dc02dcd079c37e7838b5106…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Fri Jul 16 16:07:11 2021 +0200
oleaut32: Update the SystemTimeToVariantTime() Y2K cutoff.
Old Windows versions used 29 as the Y2K cutoff, that is is they mapped
two digit years 00-29 to 2000-2029 and years 30-99 to 1930-1999.
But starting with Windows 10 1903 the cutoff is now 49 by default.
So update Wine to match the current Windows versions and adjust the
tests to work for both.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51453
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/oleaut32/tests/vartest.c | 41 +++++++++++++++++++++++++----------------
dlls/oleaut32/variant.c | 8 ++++----
2 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c
index ee21590706c..3f30eac5620 100644
--- a/dlls/oleaut32/tests/vartest.c
+++ b/dlls/oleaut32/tests/vartest.c
@@ -2530,7 +2530,7 @@ static void test_VarDateFromUdate(void)
}
static void test_st2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
- WORD s, WORD ms, INT r, double dt)
+ WORD s, WORD ms, INT r, double dt, double dt2)
{
SYSTEMTIME st;
double out;
@@ -2545,26 +2545,35 @@ static void test_st2dt(int line, WORD d, WORD m, WORD y, WORD h, WORD mn,
st.wMilliseconds = ms;
st.wDayOfWeek = 0;
res = pSystemTimeToVariantTime(&st, &out);
- ok_(__FILE__,line)(r == res && (!r || EQ_DOUBLE(out, dt)),
- "expected %d, %.16g, got %d, %.16g\n", r, dt, res, out);
+ ok_(__FILE__,line)(r == res, "expected %d, got %d\n", r, res);
+ if (r && res)
+ ok_(__FILE__,line)(EQ_DOUBLE(out, dt) || (dt2 && broken(EQ_DOUBLE(out, dt2))),
+ "expected %.16g or %.16g, got %.16g\n", dt, dt2, out);
}
-#define ST2DT(d,m,y,h,mn,s,ms,r,dt) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt)
+#define ST2DT(d,m,y,h,mn,s,ms,r,dt,dt2) test_st2dt(__LINE__,d,m,y,h,mn,s,ms,r,dt,dt2)
static void test_SystemTimeToVariantTime(void)
{
CHECKPTR(SystemTimeToVariantTime);
- ST2DT(1,1,1980,0,0,0,0,TRUE,29221.0);
- ST2DT(2,1,1980,0,0,0,0,TRUE,29222.0);
- ST2DT(0,1,1980,0,0,0,0,TRUE,29220.0); /* Rolls back to 31 Dec 1899 */
- ST2DT(1,13,1980,0,0,0,0,FALSE,29587.0); /* Fails on invalid month */
- ST2DT(32,1,1980,0,0,0,0,FALSE,0.0); /* Fails on invalid day */
- ST2DT(1,1,-1,0,0,0,0,FALSE,0.0); /* Fails on invalid year */
- ST2DT(1,1,10000,0,0,0,0,FALSE,0.0); /* Fails on invalid year */
- ST2DT(1,1,9999,0,0,0,0,TRUE,2958101.0); /* 9999 is last valid year */
- ST2DT(31,12,90,0,0,0,0,TRUE,33238.0); /* 30 <= year < 100 is 1900+year */
- ST2DT(1,1,30,0,0,0,0,TRUE,10959.0); /* 30 <= year < 100 is 1900+year */
- ST2DT(1,1,29,0,0,0,0,TRUE,47119.0); /* 0 <= year < 30 is 2000+year */
- ST2DT(1,1,0,0,0,0,0,TRUE,36526.0); /* 0 <= year < 30 is 2000+year */
+ ST2DT(1,1,1980,0,0,0,0,TRUE,29221.0,0.0);
+ ST2DT(2,1,1980,0,0,0,0,TRUE,29222.0,0.0);
+ ST2DT(0,1,1980,0,0,0,0,TRUE,29220.0,0.0); /* Rolls back to 31 Dec 1899 */
+ ST2DT(1,13,1980,0,0,0,0,FALSE,0.0,0.0); /* Fails on invalid month */
+ ST2DT(32,1,1980,0,0,0,0,FALSE,0.0,0.0); /* Fails on invalid day */
+ ST2DT(1,1,-1,0,0,0,0,FALSE,0.0,0.0); /* Fails on invalid year */
+ ST2DT(1,1,10000,0,0,0,0,FALSE,0.0,0.0); /* Fails on invalid year */
+ ST2DT(1,1,9999,0,0,0,0,TRUE,2958101.0,0.0); /* 9999 is last valid year */
+
+ /* Old Windows versions use 29 as the Y2K cutoff:
+ * years 00-29 map to 2000-2029 while years 30-99 map to 1930-1999
+ */
+ ST2DT(1,1,0,0,0,0,0,TRUE,36526.0,0.0);
+ ST2DT(1,1,29,0,0,0,0,TRUE,47119.0,0.0);
+ ST2DT(1,1,30,0,0,0,0,TRUE,47484.0,10959.0);
+ /* But Windows 1903+ uses 49 as the Y2K cutoff */
+ ST2DT(1,1,49,0,0,0,0,TRUE,54424.0,17899.0);
+ ST2DT(1,1,50,0,0,0,0,TRUE,18264.0,0.0);
+ ST2DT(31,12,99,0,0,0,0,TRUE,36525.0,0.0);
}
static void test_dt2st(int line, double dt, INT r, WORD d, WORD m, WORD y,
diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c
index 8e2b9dd4725..fdc402c7a62 100644
--- a/dlls/oleaut32/variant.c
+++ b/dlls/oleaut32/variant.c
@@ -1124,11 +1124,11 @@ static HRESULT VARIANT_RollUdate(UDATE *lpUd)
if (iYear > 9999 || iYear < -9999)
return E_INVALIDARG; /* Invalid value */
- /* Year 0 to 29 are treated as 2000 + year */
- if (iYear >= 0 && iYear < 30)
+ /* Years 0 to 49 are treated as 2000 + year, see also VARIANT_MakeDate() */
+ if (0 <= iYear && iYear <= 49)
iYear += 2000;
- /* Remaining years < 100 are treated as 1900 + year */
- else if (iYear >= 30 && iYear < 100)
+ /* Remaining years 50 to 99 are treated as 1900 + year */
+ else if (50 <= iYear && iYear <= 99)
iYear += 1900;
iMinute += iSecond / 60;
Module: wine
Branch: master
Commit: c83b7a0f39161aec4165d3d616c08afd18a62998
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c83b7a0f39161aec4165d3d6…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Fri Jul 16 16:07:08 2021 +0200
oleaut32: Update the VarDateFromStr() Y2K cutoff.
Old Windows versions used 29 as the Y2K cutoff, that is they mapped
two digit years 00-29 to 2000-2029 and years 30-99 to 1930-1999.
But starting with Windows 10 1903 the cutoff is now 49 by default.
So update Wine to match the current Windows versions and adjust the
tests to work for both.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51453
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/oleaut32/tests/vartype.c | 43 ++++++++++++++++++++++++++++---------------
dlls/oleaut32/vartype.c | 17 ++++++++++++-----
2 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index 4a32caae5c2..bf31fde2b7a 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -83,6 +83,8 @@ static BOOL has_locales;
#define EXPECT(x) EXPECTRES(S_OK, (x))
#define EXPECT_DBL(x) \
ok(hres == S_OK && EQ_DOUBLE(out, (x)), "expected %.16g, got %.16g; hres=0x%08x\n", (x), out, hres)
+#define EXPECT_DBL2(new,old) \
+ ok(hres == S_OK && (EQ_DOUBLE(out, (new)) || broken(EQ_DOUBLE(out, (old)))), "expected %.16g or %.16g, got %.16g; hres=0x%08x\n", (new), (old), out, hres)
#define CONVERT(func, val) in = val; hres = func(in, &out)
#define CONVERTRANGE(func,start,end) for (i = start; i < end; i+=1) { CONVERT(func, i); EXPECT(i); };
@@ -3048,21 +3050,23 @@ static void test_VarDateFromStr(void)
*/
DFS("14 1"); MKRELDATE(14,1); EXPECT_DBL(relative);
DFS("1 14"); EXPECT_DBL(relative);
- /* If the numbers can't be day/month, they are assumed to be year/month */
- DFS("30 2"); EXPECT_DBL(10990.0);
- DFS("2 30"); EXPECT_DBL(10990.0);
+ /* If the numbers can't be day/month, they are assumed to be year/month.
+ * But see the Y2K cutoff below.
+ */
+ DFS("30 2"); EXPECT_DBL2(47515.0, 10990.0);
+ DFS("2 30"); EXPECT_DBL2(47515.0, 10990.0);
DFS("32 49"); EXPECT_MISMATCH; /* Can't be any format */
DFS("0 49"); EXPECT_MISMATCH; /* Can't be any format */
/* If a month name is given the other number is the day */
DFS("Jan 2"); MKRELDATE(2,1); EXPECT_DBL(relative);
DFS("2 Jan"); EXPECT_DBL(relative);
/* Unless it can't be, in which case it becomes the year */
- DFS("Jan 35"); EXPECT_DBL(12785.0);
- DFS("35 Jan"); EXPECT_DBL(12785.0);
- DFS("Jan-35"); EXPECT_DBL(12785.0);
- DFS("35-Jan"); EXPECT_DBL(12785.0);
- DFS("Jan/35"); EXPECT_DBL(12785.0);
- DFS("35/Jan"); EXPECT_DBL(12785.0);
+ DFS("Jan 35"); EXPECT_DBL2(49310.0, 12785.0);
+ DFS("35 Jan"); EXPECT_DBL2(49310.0, 12785.0);
+ DFS("Jan-35"); EXPECT_DBL2(49310.0, 12785.0);
+ DFS("35-Jan"); EXPECT_DBL2(49310.0, 12785.0);
+ DFS("Jan/35"); EXPECT_DBL2(49310.0, 12785.0);
+ DFS("35/Jan"); EXPECT_DBL2(49310.0, 12785.0);
/* 3 elements */
/* 3 numbers and time separator => h:m:s */
DFS("0.1.0"); EXPECT_DBL(0.0006944444444444445);
@@ -3072,12 +3076,21 @@ static void test_VarDateFromStr(void)
DFS("14 2 3"); EXPECT_DBL(41673.0);
DFS("2 14 3"); EXPECT_DBL(37666.0);
DFS("2 3 14"); EXPECT_DBL(41673.0);
- DFS("32 2 3"); EXPECT_DBL(11722.0);
- DFS("2 3 32"); EXPECT_DBL(11722.0);
- DFS("1 2 29"); EXPECT_DBL(47120.0);
- /* After 30, two digit dates are expected to be in the 1900's */
- DFS("1 2 30"); EXPECT_DBL(10960.0);
- DFS("1 2 31"); EXPECT_DBL(11325.0);
+ DFS("32 2 3"); EXPECT_DBL2(48247.0, 11722.0);
+ DFS("2 3 32"); EXPECT_DBL2(48247.0, 11722.0);
+
+ /* Old Windows versions use 29 as the Y2K cutoff:
+ * years 00-29 map to 2000-2029 while years 30-99 map to 1930-1999
+ */
+ DFS("1 1 0"); EXPECT_DBL(36526.0);
+ DFS("12 31 29"); EXPECT_DBL(47483.0);
+ DFS("1 1 30"); EXPECT_DBL2(47484.0, 10959.0);
+ /* But Windows 1903+ uses 49 as the Y2K cutoff */
+ DFS("31 12 49"); EXPECT_DBL2(54788.0, 18263.0);
+ DFS("1 1 50"); EXPECT_DBL(18264.0);
+ DFS("12 31 99"); EXPECT_DBL(36525.0);
+ DFS("1 1 100"); EXPECT_DBL(-657434.0);
+
DFS("3 am 1 2"); MKRELDATE(2,1); relative += 0.125; EXPECT_DBL(relative);
DFS("1 2 3 am"); EXPECT_DBL(relative);
diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c
index f114da4ad21..dfdb0a15c51 100644
--- a/dlls/oleaut32/vartype.c
+++ b/dlls/oleaut32/vartype.c
@@ -7554,12 +7554,19 @@ VARIANT_MakeDate_OK:
st->wDay = v1;
st->wMonth = v2;
- /* FIXME: For 2 digit dates, I'm not sure if 30 is hard coded or not. It may
- * be retrieved from:
- * HKCU\Control Panel\International\Calendars\TwoDigitYearMax
- * But Wine doesn't have/use that key as at the time of writing.
+ /* FIXME: For 2 digit dates old versions of Windows used 29 but
+ * Windows 10 1903 and greater use 49. This cutoff may also be modified by
+ * setting the value as a string for the relevant calendar id in the
+ * registry.
+ *
+ * For instance to emulate old Windows versions:
+ * [HKCU\Control Panel\International\Calendars\TwoDigitYearMax]
+ * "1"="29"
+ * (also 2, 9, 10, 11 and 12 for the other Gregorian calendars)
+ *
+ * But Wine doesn't have/use that key at the time of writing.
*/
- st->wYear = v3 < 30 ? 2000 + v3 : v3 < 100 ? 1900 + v3 : v3;
+ st->wYear = v3 <= 49 ? 2000 + v3 : v3 <= 99 ? 1900 + v3 : v3;
TRACE("Returning date %d/%d/%d\n", v1, v2, st->wYear);
return S_OK;
}