Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2022
- 51 participants
- 1216 messages
[PATCH vkd3d v2 4/5] vkd3d-shader/hlsl: Write SM4 logic or instructions.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl_sm4.c | 5 +++++
tests/logic-operations.shader_test | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c
index 0829c5e9..d2857e6a 100644
--- a/libs/vkd3d-shader/hlsl_sm4.c
+++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -1851,6 +1851,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
write_sm4_binary_op(buffer, VKD3D_SM4_OP_AND, &expr->node, arg1, arg2);
break;
+ case HLSL_OP2_LOGIC_OR:
+ assert(dst_type->base_type == HLSL_TYPE_BOOL);
+ write_sm4_binary_op(buffer, VKD3D_SM4_OP_OR, &expr->node, arg1, arg2);
+ break;
+
case HLSL_OP2_LSHIFT:
assert(type_is_integer(dst_type));
assert(dst_type->base_type != HLSL_TYPE_BOOL);
diff --git a/tests/logic-operations.shader_test b/tests/logic-operations.shader_test
index 032b5b23..360ca03b 100644
--- a/tests/logic-operations.shader_test
+++ b/tests/logic-operations.shader_test
@@ -48,7 +48,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 1.0, 1.0, 1.0)
[pixel shader]
@@ -101,7 +101,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 1.0, 1.0, 1.0)
[pixel shader]
@@ -154,5 +154,5 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 1.0, 1.0, 1.0)
--
2.36.1
July 1, 2022
[PATCH vkd3d v2 3/5] vkd3d-shader/hlsl: Write SM4 logic and instructions.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl_sm4.c | 5 +++++
tests/logic-operations.shader_test | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c
index 08f9d12c..0829c5e9 100644
--- a/libs/vkd3d-shader/hlsl_sm4.c
+++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -1846,6 +1846,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
break;
}
+ case HLSL_OP2_LOGIC_AND:
+ assert(dst_type->base_type == HLSL_TYPE_BOOL);
+ write_sm4_binary_op(buffer, VKD3D_SM4_OP_AND, &expr->node, arg1, arg2);
+ break;
+
case HLSL_OP2_LSHIFT:
assert(type_is_integer(dst_type));
assert(dst_type->base_type != HLSL_TYPE_BOOL);
diff --git a/tests/logic-operations.shader_test b/tests/logic-operations.shader_test
index 87e927f4..032b5b23 100644
--- a/tests/logic-operations.shader_test
+++ b/tests/logic-operations.shader_test
@@ -35,7 +35,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 0.0, 0.0, 1.0)
[pixel shader]
@@ -88,7 +88,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 0.0, 0.0, 1.0)
[pixel shader]
@@ -141,7 +141,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 0.0, 0.0, 1.0)
[pixel shader]
--
2.36.1
July 1, 2022
[PATCH vkd3d v2 2/5] vkd3d-shader/hlsl: Write SM4 logic not instructions.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl_sm4.c | 5 +++++
tests/logic-operations.shader_test | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c
index 1edc5818..08f9d12c 100644
--- a/libs/vkd3d-shader/hlsl_sm4.c
+++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -1648,6 +1648,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
write_sm4_unary_op(buffer, VKD3D_SM4_OP_LOG, &expr->node, arg1, 0);
break;
+ case HLSL_OP1_LOGIC_NOT:
+ assert(dst_type->base_type == HLSL_TYPE_BOOL);
+ write_sm4_unary_op(buffer, VKD3D_SM4_OP_NOT, &expr->node, arg1, 0);
+ break;
+
case HLSL_OP1_NEG:
switch (dst_type->base_type)
{
diff --git a/tests/logic-operations.shader_test b/tests/logic-operations.shader_test
index f888e831..87e927f4 100644
--- a/tests/logic-operations.shader_test
+++ b/tests/logic-operations.shader_test
@@ -22,7 +22,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 0.0, 0.0, 1.0)
[pixel shader]
@@ -75,7 +75,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 0.0, 0.0, 1.0)
[pixel shader]
@@ -128,7 +128,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 0.0, 0.0, 1.0)
[pixel shader]
--
2.36.1
July 1, 2022
[PATCH vkd3d v2 1/5] vkd3d-shader/hlsl: Write SM4 casts from bool.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v2:
* Do not hardcode the bit pattern of 1.0f.
* Make the mask a parameter to write_sm4_cast_from_bool().
---
libs/vkd3d-shader/hlsl_sm4.c | 33 +++++++++++++++++++++++++++---
tests/cast-to-float.shader_test | 2 +-
tests/cast-to-int.shader_test | 4 ++--
tests/cast-to-uint.shader_test | 4 ++--
tests/hlsl-bool-cast.shader_test | 18 ++++++++++++++++
tests/logic-operations.shader_test | 6 +++---
6 files changed, 56 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c
index 79027169..1edc5818 100644
--- a/libs/vkd3d-shader/hlsl_sm4.c
+++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -1459,9 +1459,36 @@ static bool type_is_float(const struct hlsl_type *type)
return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF;
}
+static void write_sm4_cast_from_bool(struct hlsl_ctx *ctx,
+ struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr,
+ const struct hlsl_ir_node *arg, uint32_t mask)
+{
+ struct sm4_instruction instr;
+
+ memset(&instr, 0, sizeof(instr));
+ instr.opcode = VKD3D_SM4_OP_AND;
+
+ sm4_dst_from_node(&instr.dsts[0], &expr->node);
+ instr.dst_count = 1;
+
+ sm4_src_from_node(&instr.srcs[0], arg, instr.dsts[0].writemask);
+ instr.srcs[1].swizzle_type = VKD3D_SM4_SWIZZLE_NONE;
+ instr.srcs[1].reg.type = VKD3D_SM4_RT_IMMCONST;
+ instr.srcs[1].reg.dim = VKD3D_SM4_DIMENSION_SCALAR;
+ instr.srcs[1].reg.immconst_uint[0] = mask;
+ instr.src_count = 2;
+
+ write_sm4_instruction(buffer, &instr);
+}
+
static void write_sm4_cast(struct hlsl_ctx *ctx,
struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_expr *expr)
{
+ static const union
+ {
+ uint32_t u;
+ float f;
+ } one = { .f = 1.0 };
const struct hlsl_ir_node *arg1 = expr->operands[0].node;
const struct hlsl_type *dst_type = expr->node.data_type;
const struct hlsl_type *src_type = arg1->data_type;
@@ -1488,7 +1515,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx,
break;
case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to float.");
+ write_sm4_cast_from_bool(ctx, buffer, expr, arg1, one.u);
break;
case HLSL_TYPE_DOUBLE:
@@ -1514,7 +1541,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx,
break;
case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to int.");
+ write_sm4_cast_from_bool(ctx, buffer, expr, arg1, 1);
break;
case HLSL_TYPE_DOUBLE:
@@ -1540,7 +1567,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx,
break;
case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast from bool to uint.");
+ write_sm4_cast_from_bool(ctx, buffer, expr, arg1, 1);
break;
case HLSL_TYPE_DOUBLE:
diff --git a/tests/cast-to-float.shader_test b/tests/cast-to-float.shader_test
index 1844b1f3..f0910020 100644
--- a/tests/cast-to-float.shader_test
+++ b/tests/cast-to-float.shader_test
@@ -12,7 +12,7 @@ uniform 0 int -1
uniform 1 uint 3
uniform 2 int -2
uniform 3 float 0.5
-todo draw quad
+draw quad
probe all rgba (0.5, 0.5, 0.5, 0.5)
[pixel shader]
diff --git a/tests/cast-to-int.shader_test b/tests/cast-to-int.shader_test
index ce42827b..4c5d0e2f 100644
--- a/tests/cast-to-int.shader_test
+++ b/tests/cast-to-int.shader_test
@@ -19,8 +19,8 @@ uniform 0 float 2.6
uniform 1 int -2
uniform 2 int -2
uniform 3 float -3.6
-todo draw quad
-probe all rgba (0.5, 0.5, 0.5, 0.5)
+draw quad
+todo probe all rgba (0.5, 0.5, 0.5, 0.5)
[pixel shader]
diff --git a/tests/cast-to-uint.shader_test b/tests/cast-to-uint.shader_test
index 8b7964ff..66f7267e 100644
--- a/tests/cast-to-uint.shader_test
+++ b/tests/cast-to-uint.shader_test
@@ -19,8 +19,8 @@ uniform 0 float 2.6
uniform 1 int 2
uniform 2 int -2
uniform 3 float -3.6
-todo draw quad
-probe all rgba (0.5, 0.5, 0.5, 0.5)
+draw quad
+todo probe all rgba (0.5, 0.5, 0.5, 0.5)
[pixel shader]
diff --git a/tests/hlsl-bool-cast.shader_test b/tests/hlsl-bool-cast.shader_test
index 8880b2f5..397cbcc0 100644
--- a/tests/hlsl-bool-cast.shader_test
+++ b/tests/hlsl-bool-cast.shader_test
@@ -12,3 +12,21 @@ float4 main() : SV_TARGET
[test]
draw quad
probe all rgba (0.0, 0.0, 1.0, 1.0)
+
+[require]
+shader model >= 4.0
+
+[pixel shader]
+uniform float4 x;
+uniform int4 y;
+
+float4 main() : SV_TARGET
+{
+ return (float4)(bool4)x + 10.0 * (float4)(int4)(bool4)y;
+}
+
+[test]
+uniform 0 float4 0.0 0.0 2.0 4.0
+uniform 4 int4 0 1 0 10
+draw quad
+probe all rgba (0.0, 10.0, 1.0, 11.0)
diff --git a/tests/logic-operations.shader_test b/tests/logic-operations.shader_test
index 9a5cec3f..f888e831 100644
--- a/tests/logic-operations.shader_test
+++ b/tests/logic-operations.shader_test
@@ -8,7 +8,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 1.0, 1.0, 1.0)
[pixel shader]
@@ -61,7 +61,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 1.0, 1.0, 1.0)
[pixel shader]
@@ -114,7 +114,7 @@ float4 main() : SV_TARGET
}
[test]
-todo draw quad
+draw quad
probe all rgba (0.0, 1.0, 1.0, 1.0)
[pixel shader]
--
2.36.1
July 1, 2022
Re: [PATCH vkd3d 1/5] vkd3d-shader/hlsl: Write SM4 casts from bool.
by Giovanni Mascellani
Hi,
Il 01/07/22 06:43, Zebediah Figura ha scritto:
> I kind of wonder if this should be a lowering pass instead. It wouldn't
> apply to sm1, but it would (maybe?) be a bit easier to write, and it
> would apply to a hypothetical sm6 backend, if we indeed write our own
> instead of leveraging the Microsoft compiler.
>
> Fine to leave it as is for now, I think, but food for thought.
I kind of thought the same, but then decided that at least for the time
being this is not inappropriate. A lowering pass, in the current state,
would generate longer code (it cannot inline the constant), at least by
instruction number, and would likely require more code for all the
bookkeeping. All of this, for no advantage I can see.
No problem with changing the approach in the future if a different
balance is established.
Giovanni.
July 1, 2022
Re: [PATCH vkd3d 5/5] tests: Test arithmetic int operations without constant operands.
by Giovanni Mascellani
Hi,
Il 01/07/22 06:43, Zebediah Figura ha scritto:
> Passing "uniform int" requires sm4 (well, sort of), but the actual
> operations should be possible with sm1. Perhaps pass the inputs as
> floats and then cast them to int variables before performing arithmetic?
The main point of that test is to run the code that does some int
operation lowering (division, modulus and absolute value; well, there is
not absolute value, I'll add it), patches still to be contributed. SM4
doesn't represent those operations directly and rather requires some
more complicated code to emulate them. I guess this doesn't happen in
SM1, given that those operations are silently converted to float anyway,
so I didn't consider it a priority anyway. But I can do what you suggested.
Giovanni.
July 1, 2022
[PATCH 3/3] atl: Avoid NULL pointer reference in AtlComModuleRevokeClassObjects().
by Zhiyi Zhang
From: Zhiyi Zhang <zzhang(a)codeweavers.com>
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/atl/atl.c | 6 ++++++
dlls/atl100/tests/atl.c | 26 ++++++++++++++++++++++++++
dlls/atl110/tests/atl.c | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+)
diff --git a/dlls/atl/atl.c b/dlls/atl/atl.c
index 5a302621d60..32e0c722f8b 100644
--- a/dlls/atl/atl.c
+++ b/dlls/atl/atl.c
@@ -598,6 +598,9 @@ HRESULT WINAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE *module)
return E_INVALIDARG;
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
+ if(!(*iter))
+ continue;
+
hres = CoRevokeClassObject((*iter)->dwRegister);
if(FAILED(hres))
return hres;
@@ -617,6 +620,9 @@ HRESULT WINAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE *module)
return E_INVALIDARG;
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
+ if(!(*iter))
+ continue;
+
hres = CoRevokeClassObject((*iter)->pCache->dwRegister);
if(FAILED(hres))
return hres;
diff --git a/dlls/atl100/tests/atl.c b/dlls/atl100/tests/atl.c
index 7da6e5a9cd6..a40c38df25a 100644
--- a/dlls/atl100/tests/atl.c
+++ b/dlls/atl100/tests/atl.c
@@ -1115,6 +1115,31 @@ static void test_AtlComModuleRegisterClassObjects(void)
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
}
+static void test_AtlComModuleRevokeClassObjects(void)
+{
+ _ATL_OBJMAP_ENTRY *null_entry = NULL;
+ _ATL_COM_MODULE module;
+ HRESULT hr;
+
+ /* Test NULL module */
+ hr = AtlComModuleRevokeClassObjects(NULL);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+
+ /* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = NULL;
+ module.m_ppAutoObjMapLast = NULL;
+ hr = AtlComModuleRevokeClassObjects(&module);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+ /* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = &null_entry;
+ module.m_ppAutoObjMapLast = &null_entry;
+ hr = AtlComModuleRevokeClassObjects(&module);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+}
+
START_TEST(atl)
{
if (!register_class())
@@ -1132,6 +1157,7 @@ START_TEST(atl)
test_AtlAxCreateControl();
test_AtlComModuleGetClassObject();
test_AtlComModuleRegisterClassObjects();
+ test_AtlComModuleRevokeClassObjects();
CoUninitialize();
}
diff --git a/dlls/atl110/tests/atl.c b/dlls/atl110/tests/atl.c
index 57e7f5b9b21..79958f2bd7a 100644
--- a/dlls/atl110/tests/atl.c
+++ b/dlls/atl110/tests/atl.c
@@ -31,6 +31,7 @@
static HRESULT (WINAPI *pAtlComModuleGetClassObject)(_ATL_COM_MODULE *, REFCLSID, REFIID, void **);
static HRESULT (WINAPI *pAtlComModuleRegisterClassObjects)(_ATL_COM_MODULE *, DWORD, DWORD);
+static HRESULT (WINAPI *pAtlComModuleRevokeClassObjects)(_ATL_COM_MODULE *);
static HMODULE atl110;
@@ -41,6 +42,7 @@ static void init_functions(void)
#define X(f) p##f = (void *)GetProcAddress(atl110, #f);
X(AtlComModuleGetClassObject)
X(AtlComModuleRegisterClassObjects)
+ X(AtlComModuleRevokeClassObjects)
#undef X
}
@@ -109,6 +111,37 @@ static void test_AtlComModuleRegisterClassObjects(void)
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
}
+static void test_AtlComModuleRevokeClassObjects(void)
+{
+ _ATL_OBJMAP_ENTRY_EX *null_entry = NULL;
+ _ATL_COM_MODULE module;
+ HRESULT hr;
+
+ if (!pAtlComModuleRevokeClassObjects)
+ {
+ win_skip("AtlComModuleRevokeClassObjects() is unavailable.\n");
+ return;
+ }
+
+ /* Test NULL module */
+ hr = pAtlComModuleRevokeClassObjects(NULL);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+
+ /* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = NULL;
+ module.m_ppAutoObjMapLast = NULL;
+ hr = pAtlComModuleRevokeClassObjects(&module);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+ /* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = &null_entry;
+ module.m_ppAutoObjMapLast = &null_entry;
+ hr = pAtlComModuleRevokeClassObjects(&module);
+ ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+}
+
START_TEST(atl)
{
CoInitialize(NULL);
@@ -116,6 +149,7 @@ START_TEST(atl)
test_AtlComModuleGetClassObject();
test_AtlComModuleRegisterClassObjects();
+ test_AtlComModuleRevokeClassObjects();
FreeLibrary(atl110);
CoUninitialize();
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/358
July 1, 2022
[PATCH 2/3] atl: Avoid NULL pointer reference in AtlComModuleRegisterClassObjects().
by Zhiyi Zhang
From: Zhiyi Zhang <zzhang(a)codeweavers.com>
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/atl/atl.c | 4 ++--
dlls/atl100/tests/atl.c | 28 ++++++++++++++++++++++++++++
dlls/atl110/tests/atl.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/dlls/atl/atl.c b/dlls/atl/atl.c
index d501e7a6d76..5a302621d60 100644
--- a/dlls/atl/atl.c
+++ b/dlls/atl/atl.c
@@ -538,7 +538,7 @@ HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD c
return E_INVALIDARG;
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
- if(!(*iter)->pfnGetClassObject)
+ if(!(*iter) || !(*iter)->pfnGetClassObject)
continue;
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk);
@@ -566,7 +566,7 @@ HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD c
return E_INVALIDARG;
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
- if(!(*iter)->pfnGetClassObject)
+ if(!(*iter) || !(*iter)->pfnGetClassObject)
continue;
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk);
diff --git a/dlls/atl100/tests/atl.c b/dlls/atl100/tests/atl.c
index e002af0d24c..7da6e5a9cd6 100644
--- a/dlls/atl100/tests/atl.c
+++ b/dlls/atl100/tests/atl.c
@@ -1088,6 +1088,33 @@ static void test_AtlComModuleGetClassObject(void)
ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
}
+static void test_AtlComModuleRegisterClassObjects(void)
+{
+ _ATL_OBJMAP_ENTRY *null_entry = NULL;
+ _ATL_COM_MODULE module;
+ HRESULT hr;
+
+ /* Test NULL module */
+ hr = AtlComModuleRegisterClassObjects(NULL, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+
+ /* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = NULL;
+ module.m_ppAutoObjMapLast = NULL;
+ hr = AtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
+ todo_wine_if(hr == S_OK)
+ ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
+
+ /* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = &null_entry;
+ module.m_ppAutoObjMapLast = &null_entry;
+ hr = AtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
+ todo_wine_if(hr == S_OK)
+ ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
+}
+
START_TEST(atl)
{
if (!register_class())
@@ -1104,6 +1131,7 @@ START_TEST(atl)
test_AtlAxAttachControl();
test_AtlAxCreateControl();
test_AtlComModuleGetClassObject();
+ test_AtlComModuleRegisterClassObjects();
CoUninitialize();
}
diff --git a/dlls/atl110/tests/atl.c b/dlls/atl110/tests/atl.c
index 12f3518b429..57e7f5b9b21 100644
--- a/dlls/atl110/tests/atl.c
+++ b/dlls/atl110/tests/atl.c
@@ -30,6 +30,7 @@
#include <wine/test.h>
static HRESULT (WINAPI *pAtlComModuleGetClassObject)(_ATL_COM_MODULE *, REFCLSID, REFIID, void **);
+static HRESULT (WINAPI *pAtlComModuleRegisterClassObjects)(_ATL_COM_MODULE *, DWORD, DWORD);
static HMODULE atl110;
@@ -39,6 +40,7 @@ static void init_functions(void)
#define X(f) p##f = (void *)GetProcAddress(atl110, #f);
X(AtlComModuleGetClassObject)
+ X(AtlComModuleRegisterClassObjects)
#undef X
}
@@ -74,12 +76,46 @@ static void test_AtlComModuleGetClassObject(void)
ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
}
+static void test_AtlComModuleRegisterClassObjects(void)
+{
+ _ATL_OBJMAP_ENTRY_EX *null_entry = NULL;
+ _ATL_COM_MODULE module;
+ HRESULT hr;
+
+ if (!pAtlComModuleRegisterClassObjects)
+ {
+ win_skip("AtlComModuleRegisterClassObjects() is unavailable.\n");
+ return;
+ }
+
+ /* Test NULL module */
+ hr = pAtlComModuleRegisterClassObjects(NULL, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+
+ /* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = NULL;
+ module.m_ppAutoObjMapLast = NULL;
+ hr = pAtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
+ todo_wine_if(hr == S_OK)
+ ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
+
+ /* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = &null_entry;
+ module.m_ppAutoObjMapLast = &null_entry;
+ hr = pAtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
+ todo_wine_if(hr == S_OK)
+ ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
+}
+
START_TEST(atl)
{
CoInitialize(NULL);
init_functions();
test_AtlComModuleGetClassObject();
+ test_AtlComModuleRegisterClassObjects();
FreeLibrary(atl110);
CoUninitialize();
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/358
July 1, 2022
[PATCH 1/3] atl: Avoid NULL pointer reference in AtlComModuleGetClassObject().
by Zhiyi Zhang
From: Zhiyi Zhang <zzhang(a)codeweavers.com>
Fix crash in CAXA CAD when clicking component library.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
configure.ac | 1 +
dlls/atl/atl.c | 4 +-
dlls/atl100/tests/atl.c | 27 +++++++++++
dlls/atl110/tests/Makefile.in | 6 +++
dlls/atl110/tests/atl.c | 86 +++++++++++++++++++++++++++++++++++
5 files changed, 122 insertions(+), 2 deletions(-)
create mode 100644 dlls/atl110/tests/Makefile.in
create mode 100644 dlls/atl110/tests/atl.c
diff --git a/configure.ac b/configure.ac
index 9ad1b19164c..f26e9cde350 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2394,6 +2394,7 @@ WINE_CONFIG_MAKEFILE(dlls/atl/tests)
WINE_CONFIG_MAKEFILE(dlls/atl100)
WINE_CONFIG_MAKEFILE(dlls/atl100/tests)
WINE_CONFIG_MAKEFILE(dlls/atl110)
+WINE_CONFIG_MAKEFILE(dlls/atl110/tests)
WINE_CONFIG_MAKEFILE(dlls/atl80)
WINE_CONFIG_MAKEFILE(dlls/atl80/tests)
WINE_CONFIG_MAKEFILE(dlls/atl90)
diff --git a/dlls/atl/atl.c b/dlls/atl/atl.c
index 87a24e33ed7..d501e7a6d76 100644
--- a/dlls/atl/atl.c
+++ b/dlls/atl/atl.c
@@ -482,7 +482,7 @@ HRESULT WINAPI AtlComModuleGetClassObject(_ATL_COM_MODULE *pm, REFCLSID rclsid,
return E_INVALIDARG;
for(iter = pm->m_ppAutoObjMapFirst; iter < pm->m_ppAutoObjMapLast; iter++) {
- if(IsEqualCLSID((*iter)->pclsid, rclsid) && (*iter)->pfnGetClassObject) {
+ if(*iter && IsEqualCLSID((*iter)->pclsid, rclsid) && (*iter)->pfnGetClassObject) {
if(!(*iter)->pCF)
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&(*iter)->pCF);
if((*iter)->pCF)
@@ -507,7 +507,7 @@ HRESULT WINAPI AtlComModuleGetClassObject(_ATL_COM_MODULE *pm, REFCLSID rclsid,
return E_INVALIDARG;
for(iter = pm->m_ppAutoObjMapFirst; iter < pm->m_ppAutoObjMapLast; iter++) {
- if(IsEqualCLSID((*iter)->pclsid, rclsid) && (*iter)->pfnGetClassObject) {
+ if(*iter && IsEqualCLSID((*iter)->pclsid, rclsid) && (*iter)->pfnGetClassObject) {
if(!(*iter)->pCache->pCF)
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&(*iter)->pCache->pCF);
if((*iter)->pCache->pCF)
diff --git a/dlls/atl100/tests/atl.c b/dlls/atl100/tests/atl.c
index e161878f8ea..e002af0d24c 100644
--- a/dlls/atl100/tests/atl.c
+++ b/dlls/atl100/tests/atl.c
@@ -1062,6 +1062,32 @@ static void test_AtlAxCreateControl(void)
DestroyWindow(hwnd);
}
+static void test_AtlComModuleGetClassObject(void)
+{
+ _ATL_OBJMAP_ENTRY *null_entry = NULL;
+ _ATL_COM_MODULE module;
+ HRESULT hr;
+ void *ret;
+
+ /* Test NULL module */
+ hr = AtlComModuleGetClassObject(NULL, &GUID_NULL, &IID_NULL, &ret);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+
+ /* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = NULL;
+ module.m_ppAutoObjMapLast = NULL;
+ hr = AtlComModuleGetClassObject(&module, &GUID_NULL, &IID_NULL, &ret);
+ ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
+
+ /* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = &null_entry;
+ module.m_ppAutoObjMapLast = &null_entry;
+ hr = AtlComModuleGetClassObject(&module, &GUID_NULL, &IID_NULL, &ret);
+ ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
+}
+
START_TEST(atl)
{
if (!register_class())
@@ -1077,6 +1103,7 @@ START_TEST(atl)
test_ax_win();
test_AtlAxAttachControl();
test_AtlAxCreateControl();
+ test_AtlComModuleGetClassObject();
CoUninitialize();
}
diff --git a/dlls/atl110/tests/Makefile.in b/dlls/atl110/tests/Makefile.in
new file mode 100644
index 00000000000..528c9180dc8
--- /dev/null
+++ b/dlls/atl110/tests/Makefile.in
@@ -0,0 +1,6 @@
+TESTDLL = atl110.dll
+IMPORTS = uuid ole32
+EXTRADEFS = -D_ATL_VER=_ATL_VER_110
+
+C_SRCS = \
+ atl.c
diff --git a/dlls/atl110/tests/atl.c b/dlls/atl110/tests/atl.c
new file mode 100644
index 00000000000..12f3518b429
--- /dev/null
+++ b/dlls/atl110/tests/atl.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2022 Zhiyi Zhang for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <atlbase.h>
+
+#include <wine/test.h>
+
+static HRESULT (WINAPI *pAtlComModuleGetClassObject)(_ATL_COM_MODULE *, REFCLSID, REFIID, void **);
+
+static HMODULE atl110;
+
+static void init_functions(void)
+{
+ atl110 = LoadLibraryA("atl110.dll");
+
+#define X(f) p##f = (void *)GetProcAddress(atl110, #f);
+ X(AtlComModuleGetClassObject)
+#undef X
+}
+
+static void test_AtlComModuleGetClassObject(void)
+{
+ _ATL_OBJMAP_ENTRY_EX *null_entry = NULL;
+ _ATL_COM_MODULE module;
+ HRESULT hr;
+ void *ret;
+
+ if (!pAtlComModuleGetClassObject)
+ {
+ win_skip("AtlComModuleGetClassObject() is unavailable.\n");
+ return;
+ }
+
+ /* Test NULL module */
+ hr = pAtlComModuleGetClassObject(NULL, &GUID_NULL, &IID_NULL, &ret);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+
+ /* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = NULL;
+ module.m_ppAutoObjMapLast = NULL;
+ hr = pAtlComModuleGetClassObject(&module, &GUID_NULL, &IID_NULL, &ret);
+ ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
+
+ /* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
+ module.cbSize = sizeof(module);
+ module.m_ppAutoObjMapFirst = &null_entry;
+ module.m_ppAutoObjMapLast = &null_entry;
+ hr = pAtlComModuleGetClassObject(&module, &GUID_NULL, &IID_NULL, &ret);
+ ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
+}
+
+START_TEST(atl)
+{
+ CoInitialize(NULL);
+ init_functions();
+
+ test_AtlComModuleGetClassObject();
+
+ FreeLibrary(atl110);
+ CoUninitialize();
+}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/358
July 1, 2022
[PATCH 0/3] MR358: atl: Avoid NULL pointer reference in AtlComModuleGetClassObject().
by Zhiyi Zhang (@zhiyi)
Fix crash in CAXA CAD when clicking component library.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/358
July 1, 2022