winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
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
List overview
wine-commits
September 2020
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
703 discussions
Start a n
N
ew thread
Zebediah Figura : wined3d: Read the SM5 resource data type instruction modifier.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: 2f94e72b8061d168b167e89333c1508c0e327ebb URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2f94e72b8061d168b167e893…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Sep 2 18:40:36 2020 -0500 wined3d: Read the SM5 resource data type instruction modifier. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/shader.c | 51 +++++++++++++++++++++--------------------- dlls/wined3d/shader_sm4.c | 16 +++++++++++++ dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index a8765fd445..0166746bfd 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2065,6 +2065,27 @@ static void shader_dump_resource_type(struct wined3d_string_buffer *buffer, enum shader_addline(buffer, "unknown"); } +static void shader_dump_data_type(struct wined3d_string_buffer *buffer, enum wined3d_data_type type) +{ + static const char *const data_type_names[] = + { + /* WINED3D_DATA_FLOAT */ "(float)", + /* WINED3D_DATA_INT */ "(int)", + /* WINED3D_DATA_RESOURCE */ "(resource)", + /* WINED3D_DATA_SAMPLER */ "(sampler)", + /* WINED3D_DATA_UAV */ "(uav)", + /* WINED3D_DATA_UINT */ "(uint)", + /* WINED3D_DATA_UNORM */ "(unorm)", + /* WINED3D_DATA_SNORM */ "(snorm)", + /* WINED3D_DATA_OPAQUE */ "(opaque)", + }; + + if (type <= ARRAY_SIZE(data_type_names)) + shader_addline(buffer, "%s", data_type_names[type]); + else + shader_addline(buffer, "(unknown)"); +} + static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, const struct wined3d_shader_semantic *semantic, unsigned int flags, const struct wined3d_shader_version *shader_version) @@ -2101,32 +2122,7 @@ static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, shader_dump_resource_type(buffer, semantic->resource_type); if (semantic->reg.reg.type == WINED3DSPR_UAV) shader_dump_uav_flags(buffer, flags); - switch (semantic->resource_data_type) - { - case WINED3D_DATA_FLOAT: - shader_addline(buffer, " (float)"); - break; - - case WINED3D_DATA_INT: - shader_addline(buffer, " (int)"); - break; - - case WINED3D_DATA_UINT: - shader_addline(buffer, " (uint)"); - break; - - case WINED3D_DATA_UNORM: - shader_addline(buffer, " (unorm)"); - break; - - case WINED3D_DATA_SNORM: - shader_addline(buffer, " (snorm)"); - break; - - default: - shader_addline(buffer, " (unknown)"); - break; - } + shader_dump_data_type(buffer, semantic->resource_data_type); } else { @@ -3101,6 +3097,9 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe shader_addline(&buffer, ")"); } + if (ins.resource_data_type != WINED3D_DATA_FLOAT) + shader_dump_data_type(&buffer, ins.resource_data_type); + for (i = 0; i < ins.dst_count; ++i) { shader_dump_ins_modifiers(&buffer, &ins.dst[i]); diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c index 54646174a2..90135553d8 100644 --- a/dlls/wined3d/shader_sm4.c +++ b/dlls/wined3d/shader_sm4.c @@ -28,6 +28,9 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode); #define WINED3D_SM4_MODIFIER_MASK 0x3fu +#define WINED3D_SM5_MODIFIER_DATA_TYPE_SHIFT 6 +#define WINED3D_SM5_MODIFIER_DATA_TYPE_MASK (0xffffu << WINED3D_SM5_MODIFIER_DATA_TYPE_SHIFT) + #define WINED3D_SM5_MODIFIER_RESOURCE_TYPE_SHIFT 6 #define WINED3D_SM5_MODIFIER_RESOURCE_TYPE_MASK (0xfu << WINED3D_SM5_MODIFIER_RESOURCE_TYPE_SHIFT) @@ -312,6 +315,7 @@ enum wined3d_sm4_instruction_modifier { WINED3D_SM4_MODIFIER_AOFFIMMI = 0x1, WINED3D_SM5_MODIFIER_RESOURCE_TYPE = 0x2, + WINED3D_SM5_MODIFIER_DATA_TYPE = 0x3, }; enum wined3d_sm4_register_type @@ -1651,6 +1655,17 @@ static void shader_sm4_read_instruction_modifier(DWORD modifier, struct wined3d_ break; } + case WINED3D_SM5_MODIFIER_DATA_TYPE: + { + DWORD components = (modifier & WINED3D_SM5_MODIFIER_DATA_TYPE_MASK) >> WINED3D_SM5_MODIFIER_DATA_TYPE_SHIFT; + enum wined3d_sm4_data_type data_type = components & 0xf; + + if ((components & 0xfff0) != (components & 0xf) * 0x1110) + FIXME("Components (%#x) have different data types.\n", components); + ins->resource_data_type = data_type_table[data_type]; + break; + } + case WINED3D_SM5_MODIFIER_RESOURCE_TYPE: { enum wined3d_sm4_resource_type resource_type @@ -1731,6 +1746,7 @@ static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wi ins->src_count = strlen(opcode_info->src_info); ins->src = priv->src_param; ins->resource_type = WINED3D_SHADER_RESOURCE_NONE; + ins->resource_data_type = WINED3D_DATA_FLOAT; memset(&ins->texel_offset, 0, sizeof(ins->texel_offset)); p = *ptr; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6e905ca6a4..b2605b837a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1247,6 +1247,7 @@ struct wined3d_shader_instruction const struct wined3d_shader_src_param *src; struct wined3d_shader_texel_offset texel_offset; enum wined3d_shader_resource_type resource_type; + enum wined3d_data_type resource_data_type; BOOL coissue; const struct wined3d_shader_src_param *predicate; union
1
0
0
0
Zebediah Figura : wined3d: Read the SM5 resource type instruction modifier.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: 9610e71f3423ba3443faad8477833a49345d16cb URL:
https://source.winehq.org/git/wine.git/?a=commit;h=9610e71f3423ba3443faad84…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Sep 2 18:40:35 2020 -0500 wined3d: Read the SM5 resource type instruction modifier. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/shader.c | 77 +++++++++++++++++------------------------- dlls/wined3d/shader_sm4.c | 74 +++++++++++++++++++++++++++------------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 83 insertions(+), 69 deletions(-) diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index f4c4eb07d8..a8765fd445 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2042,6 +2042,29 @@ static void shader_dump_shader_input_sysval_semantic(struct wined3d_string_buffe shader_addline(buffer, "unknown_shader_input_sysval_semantic(%#x)", semantic); } +static void shader_dump_resource_type(struct wined3d_string_buffer *buffer, enum wined3d_shader_resource_type type) +{ + static const char *const resource_type_names[] = + { + /* WINED3D_SHADER_RESOURCE_NONE */ "none", + /* WINED3D_SHADER_RESOURCE_BUFFER */ "buffer", + /* WINED3D_SHADER_RESOURCE_TEXTURE_1D */ "texture1d", + /* WINED3D_SHADER_RESOURCE_TEXTURE_2D */ "texture2d", + /* WINED3D_SHADER_RESOURCE_TEXTURE_2DMS */ "texture2dms", + /* WINED3D_SHADER_RESOURCE_TEXTURE_3D */ "texture3d", + /* WINED3D_SHADER_RESOURCE_TEXTURE_CUBE */ "texturecube", + /* WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY */ "texture1darray", + /* WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY */ "texture2darray", + /* WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY */ "texture2dmsarray", + /* WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY */ "texturecubearray", + }; + + if (type <= ARRAY_SIZE(resource_type_names)) + shader_addline(buffer, "%s", resource_type_names[type]); + else + shader_addline(buffer, "unknown"); +} + static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, const struct wined3d_shader_semantic *semantic, unsigned int flags, const struct wined3d_shader_version *shader_version) @@ -2075,52 +2098,7 @@ static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, shader_addline(buffer, "_resource_"); else shader_addline(buffer, "_uav_"); - switch (semantic->resource_type) - { - case WINED3D_SHADER_RESOURCE_BUFFER: - shader_addline(buffer, "buffer"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_1D: - shader_addline(buffer, "texture1d"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_2D: - shader_addline(buffer, "texture2d"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_2DMS: - shader_addline(buffer, "texture2dms"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_3D: - shader_addline(buffer, "texture3d"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE: - shader_addline(buffer, "texturecube"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY: - shader_addline(buffer, "texture1darray"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY: - shader_addline(buffer, "texture2darray"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY: - shader_addline(buffer, "texture2dmsarray"); - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY: - shader_addline(buffer, "texturecubearray"); - break; - - default: - shader_addline(buffer, "unknown"); - break; - } + shader_dump_resource_type(buffer, semantic->resource_type); if (semantic->reg.reg.type == WINED3DSPR_UAV) shader_dump_uav_flags(buffer, flags); switch (semantic->resource_data_type) @@ -3116,6 +3094,13 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe if (wined3d_shader_instruction_has_texel_offset(&ins)) shader_addline(&buffer, "(%d,%d,%d)", ins.texel_offset.u, ins.texel_offset.v, ins.texel_offset.w); + if (ins.resource_type != WINED3D_SHADER_RESOURCE_NONE) + { + shader_addline(&buffer, "("); + shader_dump_resource_type(&buffer, ins.resource_type); + shader_addline(&buffer, ")"); + } + for (i = 0; i < ins.dst_count; ++i) { shader_dump_ins_modifiers(&buffer, &ins.dst[i]); diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c index 443cfe7e4b..54646174a2 100644 --- a/dlls/wined3d/shader_sm4.c +++ b/dlls/wined3d/shader_sm4.c @@ -26,7 +26,11 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode); #define WINED3D_SM4_INSTRUCTION_MODIFIER (0x1u << 31) -#define WINED3D_SM4_MODIFIER_AOFFIMMI 0x1 +#define WINED3D_SM4_MODIFIER_MASK 0x3fu + +#define WINED3D_SM5_MODIFIER_RESOURCE_TYPE_SHIFT 6 +#define WINED3D_SM5_MODIFIER_RESOURCE_TYPE_MASK (0xfu << WINED3D_SM5_MODIFIER_RESOURCE_TYPE_SHIFT) + #define WINED3D_SM4_AOFFIMMI_U_SHIFT 9 #define WINED3D_SM4_AOFFIMMI_U_MASK (0xfu << WINED3D_SM4_AOFFIMMI_U_SHIFT) #define WINED3D_SM4_AOFFIMMI_V_SHIFT 13 @@ -304,6 +308,12 @@ enum wined3d_sm4_opcode WINED3D_SM5_OP_DCL_GS_INSTANCES = 0xce, }; +enum wined3d_sm4_instruction_modifier +{ + WINED3D_SM4_MODIFIER_AOFFIMMI = 0x1, + WINED3D_SM5_MODIFIER_RESOURCE_TYPE = 0x2, +}; + enum wined3d_sm4_register_type { WINED3D_SM4_RT_TEMP = 0x00, @@ -1609,32 +1619,49 @@ static BOOL shader_sm4_read_dst_param(struct wined3d_sm4_data *priv, const DWORD static void shader_sm4_read_instruction_modifier(DWORD modifier, struct wined3d_shader_instruction *ins) { - static const DWORD recognized_bits = WINED3D_SM4_INSTRUCTION_MODIFIER - | WINED3D_SM4_MODIFIER_AOFFIMMI - | WINED3D_SM4_AOFFIMMI_U_MASK - | WINED3D_SM4_AOFFIMMI_V_MASK - | WINED3D_SM4_AOFFIMMI_W_MASK; + enum wined3d_sm4_instruction_modifier modifier_type = modifier & WINED3D_SM4_MODIFIER_MASK; - if (modifier & ~recognized_bits) + switch (modifier_type) { - FIXME("Unhandled modifier 0x%08x.\n", modifier); - } - else - { - /* Bit fields are used for sign extension */ - struct + case WINED3D_SM4_MODIFIER_AOFFIMMI: { - int u : 4; - int v : 4; - int w : 4; + static const DWORD recognized_bits = WINED3D_SM4_INSTRUCTION_MODIFIER + | WINED3D_SM4_MODIFIER_MASK + | WINED3D_SM4_AOFFIMMI_U_MASK + | WINED3D_SM4_AOFFIMMI_V_MASK + | WINED3D_SM4_AOFFIMMI_W_MASK; + + /* Bit fields are used for sign extension. */ + struct + { + int u : 4; + int v : 4; + int w : 4; + } aoffimmi; + + if (modifier & ~recognized_bits) + FIXME("Unhandled instruction modifier %#x.\n", modifier); + + aoffimmi.u = (modifier & WINED3D_SM4_AOFFIMMI_U_MASK) >> WINED3D_SM4_AOFFIMMI_U_SHIFT; + aoffimmi.v = (modifier & WINED3D_SM4_AOFFIMMI_V_MASK) >> WINED3D_SM4_AOFFIMMI_V_SHIFT; + aoffimmi.w = (modifier & WINED3D_SM4_AOFFIMMI_W_MASK) >> WINED3D_SM4_AOFFIMMI_W_SHIFT; + ins->texel_offset.u = aoffimmi.u; + ins->texel_offset.v = aoffimmi.v; + ins->texel_offset.w = aoffimmi.w; + break; + } + + case WINED3D_SM5_MODIFIER_RESOURCE_TYPE: + { + enum wined3d_sm4_resource_type resource_type + = (modifier & WINED3D_SM5_MODIFIER_RESOURCE_TYPE_MASK) >> WINED3D_SM5_MODIFIER_RESOURCE_TYPE_SHIFT; + + ins->resource_type = resource_type_table[resource_type]; + break; } - aoffimmi; - aoffimmi.u = (modifier & WINED3D_SM4_AOFFIMMI_U_MASK) >> WINED3D_SM4_AOFFIMMI_U_SHIFT; - aoffimmi.v = (modifier & WINED3D_SM4_AOFFIMMI_V_MASK) >> WINED3D_SM4_AOFFIMMI_V_SHIFT; - aoffimmi.w = (modifier & WINED3D_SM4_AOFFIMMI_W_MASK) >> WINED3D_SM4_AOFFIMMI_W_SHIFT; - ins->texel_offset.u = aoffimmi.u; - ins->texel_offset.v = aoffimmi.v; - ins->texel_offset.w = aoffimmi.w; + + default: + FIXME("Unhandled instruction modifier %#x.\n", modifier); } } @@ -1703,6 +1730,7 @@ static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wi ins->dst = priv->dst_param; ins->src_count = strlen(opcode_info->src_info); ins->src = priv->src_param; + ins->resource_type = WINED3D_SHADER_RESOURCE_NONE; memset(&ins->texel_offset, 0, sizeof(ins->texel_offset)); p = *ptr; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 16b3d0325c..6e905ca6a4 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1246,6 +1246,7 @@ struct wined3d_shader_instruction const struct wined3d_shader_dst_param *dst; const struct wined3d_shader_src_param *src; struct wined3d_shader_texel_offset texel_offset; + enum wined3d_shader_resource_type resource_type; BOOL coissue; const struct wined3d_shader_src_param *predicate; union
1
0
0
0
Gijs Vermeulen : crypt32: Remove unused variable in test_CryptBinaryToString().
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: a963947322da7a4d572e73ca597cc3caf67e498f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a963947322da7a4d572e73ca…
Author: Gijs Vermeulen <gijsvrm(a)gmail.com> Date: Thu Sep 3 00:20:19 2020 +0200 crypt32: Remove unused variable in test_CryptBinaryToString(). This was missed in eb00dbd9134783242d0e3c21be8f5fafd4519d70. Signed-off-by: Gijs Vermeulen <gijsvrm(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/crypt32/tests/base64.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dlls/crypt32/tests/base64.c b/dlls/crypt32/tests/base64.c index 7b9f4c1077..a48f0a5c44 100644 --- a/dlls/crypt32/tests/base64.c +++ b/dlls/crypt32/tests/base64.c @@ -240,7 +240,6 @@ static void test_CryptBinaryToString(void) { static const DWORD flags[] = { 0, CRYPT_STRING_NOCR, CRYPT_STRING_NOCRLF }; static const WCHAR hexdig[] = L"0123456789abcdef"; - OSVERSIONINFOA ver = { sizeof(ver) }; BYTE input[256 * sizeof(WCHAR)]; DWORD strLen, strLen2, i, j; WCHAR *hex, *cmp, *ptr;
1
0
0
0
Hans Leidekker : mountmgr: Add ioctl to enumerate host credentials on macOS.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: bf9ae672754c3dc2480d0042df619ba87f8ed1da URL:
https://source.winehq.org/git/wine.git/?a=commit;h=bf9ae672754c3dc2480d0042…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Thu Sep 3 14:59:08 2020 +0200 mountmgr: Add ioctl to enumerate host credentials on macOS. Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/mountmgr.sys/device.c | 2 +- dlls/mountmgr.sys/mountmgr.c | 142 +++++++++++++++++++++++++++++++++++++++++++ dlls/mountmgr.sys/mountmgr.h | 2 + include/ddk/mountmgr.h | 10 +++ 4 files changed, 155 insertions(+), 1 deletion(-) diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c index 97208da481..ccb0685ced 100644 --- a/dlls/mountmgr.sys/device.c +++ b/dlls/mountmgr.sys/device.c @@ -159,7 +159,7 @@ static char *strdupA( const char *str ) return ret; } -static WCHAR *strdupW( const WCHAR *str ) +WCHAR *strdupW( const WCHAR *str ) { WCHAR *ret; diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c index 95b11d864a..54ba2857e0 100644 --- a/dlls/mountmgr.sys/mountmgr.c +++ b/dlls/mountmgr.sys/mountmgr.c @@ -836,6 +836,137 @@ static NTSTATUS delete_credential( void *buff, SIZE_T insize, SIZE_T outsize, IO CFRelease( item ); return STATUS_SUCCESS; } + +static BOOL match_credential( void *data, UInt32 data_len, const WCHAR *filter ) +{ + int len; + WCHAR *targetname; + const WCHAR *p; + BOOL ret; + + if (!*filter) return TRUE; + + len = MultiByteToWideChar( CP_UTF8, 0, data, data_len, NULL, 0 ); + if (!(targetname = RtlAllocateHeap( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return FALSE; + MultiByteToWideChar( CP_UTF8, 0, data, data_len, targetname, len ); + targetname[len] = 0; + + TRACE( "comparing filter %s to target name %s\n", debugstr_w(filter), debugstr_w(targetname) ); + + p = strchrW( filter, '*' ); + ret = CompareStringW( GetThreadLocale(), NORM_IGNORECASE, filter, + (p && !p[1]) ? p - filter : -1, targetname, (p && !p[1]) ? p - filter : -1 ) == CSTR_EQUAL; + RtlFreeHeap( GetProcessHeap(), 0, targetname ); + return ret; +} + +static NTSTATUS search_credentials( const WCHAR *filter, struct mountmgr_credential_list *list, SIZE_T *ret_count, SIZE_T *ret_size ) +{ + SecKeychainSearchRef search; + SecKeychainItemRef item; + int status; + ULONG i = 0; + SIZE_T data_offset, data_size = 0, size; + NTSTATUS ret = STATUS_NOT_FOUND; + + status = SecKeychainSearchCreateFromAttributes( NULL, kSecGenericPasswordItemClass, NULL, &search ); + if (status != noErr) + { + ERR( "SecKeychainSearchCreateFromAttributes returned status %d\n", status ); + return STATUS_INTERNAL_ERROR; + } + + while (SecKeychainSearchCopyNext( search, &item ) == noErr) + { + SecKeychainAttributeInfo info; + SecKeychainAttributeList *attr_list; + UInt32 info_tags[] = { kSecServiceItemAttr }; + BOOL match; + + info.count = ARRAY_SIZE(info_tags); + info.tag = info_tags; + info.format = NULL; + status = SecKeychainItemCopyAttributesAndData( item, &info, NULL, &attr_list, NULL, NULL ); + if (status != noErr) + { + WARN( "SecKeychainItemCopyAttributesAndData returned status %d\n", status ); + CFRelease( item ); + continue; + } + if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServiceItemAttr) + { + SecKeychainItemFreeAttributesAndData( attr_list, NULL ); + CFRelease( item ); + continue; + } + TRACE( "service item: %.*s\n", (int)attr_list->attr[0].length, (char *)attr_list->attr[0].data ); + + match = match_credential( attr_list->attr[0].data, attr_list->attr[0].length, filter ); + SecKeychainItemFreeAttributesAndData( attr_list, NULL ); + if (!match) + { + CFRelease( item ); + continue; + } + + if (!list) ret = fill_credential( item, FALSE, NULL, 0, 0, &size ); + else + { + data_offset = FIELD_OFFSET( struct mountmgr_credential_list, creds[list->count] ) - + FIELD_OFFSET( struct mountmgr_credential_list, creds[i] ) + data_size; + ret = fill_credential( item, FALSE, &list->creds[i], data_offset, list->size - data_offset, &size ); + } + + CFRelease( item ); + if (ret == STATUS_NOT_FOUND) continue; + if (ret != STATUS_SUCCESS) break; + data_size += size - sizeof(struct mountmgr_credential); + i++; + } + + if (ret_count) *ret_count = i; + if (ret_size) *ret_size = FIELD_OFFSET( struct mountmgr_credential_list, creds[i] ) + data_size; + + CFRelease( search ); + return ret; +} + +static NTSTATUS enumerate_credentials( void *buff, SIZE_T insize, SIZE_T outsize, IO_STATUS_BLOCK *iosb ) +{ + struct mountmgr_credential_list *list = buff; + WCHAR *filter; + SIZE_T size, count; + Boolean saved_user_interaction_allowed; + NTSTATUS status; + + if (!check_credential_string( buff, insize, list->filter_size, list->filter_offset )) return STATUS_INVALID_PARAMETER; + if (!(filter = strdupW( (const WCHAR *)((const char *)list + list->filter_offset) ))) return STATUS_NO_MEMORY; + + SecKeychainGetUserInteractionAllowed( &saved_user_interaction_allowed ); + SecKeychainSetUserInteractionAllowed( false ); + + if ((status = search_credentials( filter, NULL, &count, &size )) == STATUS_SUCCESS) + { + + if (size > outsize) + { + if (size >= sizeof(list->size)) list->size = size; + iosb->Information = sizeof(list->size); + status = STATUS_MORE_ENTRIES; + } + else + { + list->size = size; + list->count = count; + iosb->Information = size; + status = search_credentials( filter, list, NULL, NULL ); + } + } + + SecKeychainSetUserInteractionAllowed( saved_user_interaction_allowed ); + RtlFreeHeap( GetProcessHeap(), 0, filter ); + return status; +} #endif /* __APPLE__ */ /* handler for ioctls on the mount manager device */ @@ -937,6 +1068,17 @@ static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp ) irpsp->Parameters.DeviceIoControl.OutputBufferLength, &irp->IoStatus ); break; + case IOCTL_MOUNTMGR_ENUMERATE_CREDENTIALS: + if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(struct mountmgr_credential_list)) + { + irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER; + break; + } + irp->IoStatus.u.Status = enumerate_credentials( irp->AssociatedIrp.SystemBuffer, + irpsp->Parameters.DeviceIoControl.InputBufferLength, + irpsp->Parameters.DeviceIoControl.OutputBufferLength, + &irp->IoStatus ); + break; #endif default: FIXME( "ioctl %x not supported\n", irpsp->Parameters.DeviceIoControl.IoControlCode ); diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h index 5fb43119c6..3e4554c476 100644 --- a/dlls/mountmgr.sys/mountmgr.h +++ b/dlls/mountmgr.sys/mountmgr.h @@ -36,6 +36,8 @@ extern void initialize_dbus(void) DECLSPEC_HIDDEN; extern void initialize_diskarbitration(void) DECLSPEC_HIDDEN; +extern WCHAR *strdupW( const WCHAR * ) DECLSPEC_HIDDEN; + /* device functions */ enum device_type diff --git a/include/ddk/mountmgr.h b/include/ddk/mountmgr.h index a5aae2a085..3e4bacbb82 100644 --- a/include/ddk/mountmgr.h +++ b/include/ddk/mountmgr.h @@ -77,6 +77,7 @@ struct mountmgr_unix_drive #define IOCTL_MOUNTMGR_READ_CREDENTIAL CTL_CODE(MOUNTMGRCONTROLTYPE, 48, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_MOUNTMGR_WRITE_CREDENTIAL CTL_CODE(MOUNTMGRCONTROLTYPE, 49, METHOD_BUFFERED, FILE_WRITE_ACCESS) #define IOCTL_MOUNTMGR_DELETE_CREDENTIAL CTL_CODE(MOUNTMGRCONTROLTYPE, 50, METHOD_BUFFERED, FILE_WRITE_ACCESS) +#define IOCTL_MOUNTMGR_ENUMERATE_CREDENTIALS CTL_CODE(MOUNTMGRCONTROLTYPE, 51, METHOD_BUFFERED, FILE_READ_ACCESS) struct mountmgr_credential { @@ -92,6 +93,15 @@ struct mountmgr_credential FILETIME last_written; }; +struct mountmgr_credential_list +{ + ULONG size; + ULONG count; + ULONG filter_offset; + ULONG filter_size; + struct mountmgr_credential creds[1]; +}; + #define IOCTL_MOUNTMGR_QUERY_DHCP_REQUEST_PARAMS CTL_CODE(MOUNTMGRCONTROLTYPE, 64, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) struct mountmgr_dhcp_request_param
1
0
0
0
Hans Leidekker : advapi32: Delete host credentials through mountmgr.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: f69b9e244624155e9e53c172a0262bd467c77f4f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f69b9e244624155e9e53c172…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Thu Sep 3 14:59:07 2020 +0200 advapi32: Delete host credentials through mountmgr. Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/advapi32/cred.c | 87 +++++++++++++++++++--------------------------------- 1 file changed, 31 insertions(+), 56 deletions(-) diff --git a/dlls/advapi32/cred.c b/dlls/advapi32/cred.c index c17023959f..24bcd28414 100644 --- a/dlls/advapi32/cred.c +++ b/dlls/advapi32/cred.c @@ -826,59 +826,6 @@ static DWORD mac_enumerate_credentials(LPCWSTR filter, PCREDENTIALW *credentials SecKeychainSetUserInteractionAllowed(saved_user_interaction_allowed); return ERROR_SUCCESS; } - -static DWORD mac_delete_credential(LPCWSTR TargetName) -{ - int status; - SecKeychainSearchRef search; - status = SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, NULL, &search); - if (status == noErr) - { - SecKeychainItemRef item; - while (SecKeychainSearchCopyNext(search, &item) == noErr) - { - SecKeychainAttributeInfo info; - SecKeychainAttributeList *attr_list; - UInt32 info_tags[] = { kSecServiceItemAttr }; - LPWSTR target_name; - INT str_len; - info.count = ARRAY_SIZE(info_tags); - info.tag = info_tags; - info.format = NULL; - status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, NULL, NULL); - if (status != noErr) - { - WARN("SecKeychainItemCopyAttributesAndData returned status %d\n", status); - continue; - } - if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServiceItemAttr) - { - CFRelease(item); - continue; - } - str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, NULL, 0); - target_name = heap_alloc((str_len + 1) * sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, target_name, str_len); - /* nul terminate */ - target_name[str_len] = '\0'; - if (strcmpiW(TargetName, target_name)) - { - CFRelease(item); - heap_free(target_name); - continue; - } - heap_free(target_name); - SecKeychainItemFreeAttributesAndData(attr_list, NULL); - SecKeychainItemDelete(item); - CFRelease(item); - CFRelease(search); - - return ERROR_SUCCESS; - } - CFRelease(search); - } - return ERROR_NOT_FOUND; -} #endif /****************************************************************************** @@ -1095,6 +1042,36 @@ BOOL WINAPI CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags) return ret; } +static DWORD host_delete_credential( const WCHAR *targetname ) +{ + struct mountmgr_credential *cred; + DWORD size, name_size = (strlenW( targetname ) + 1) * sizeof(WCHAR); + HANDLE mgr; + WCHAR *ptr; + BOOL ret; + + mgr = CreateFileW( MOUNTMGR_DOS_DEVICE_NAME, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, 0 ); + if (mgr == INVALID_HANDLE_VALUE) return GetLastError(); + + size = sizeof(*cred) + name_size; + if (!(cred = heap_alloc( size ))) + { + CloseHandle( mgr ); + return ERROR_OUTOFMEMORY; + } + cred->targetname_offset = sizeof(*cred); + cred->targetname_size = name_size; + ptr = (WCHAR *)(cred + 1); + strcpyW( ptr, targetname ); + + ret = DeviceIoControl( mgr, IOCTL_MOUNTMGR_DELETE_CREDENTIAL, cred, size, NULL, 0, NULL, NULL ); + heap_free( cred ); + CloseHandle( mgr ); + + return ret ? ERROR_SUCCESS : GetLastError(); +} + /****************************************************************************** * CredDeleteW [ADVAPI32.@] */ @@ -1126,14 +1103,12 @@ BOOL WINAPI CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags) return FALSE; } -#ifdef __APPLE__ if (Type == CRED_TYPE_DOMAIN_PASSWORD) { - ret = mac_delete_credential(TargetName); + ret = host_delete_credential(TargetName); if (ret == ERROR_SUCCESS) return TRUE; } -#endif ret = open_cred_mgr_key(&hkeyMgr, TRUE); if (ret != ERROR_SUCCESS)
1
0
0
0
Hans Leidekker : mountmgr: Add ioctl to delete host credentials on macOS.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: 26daece790988d1cdaed9af4e0ec550f968cd1c8 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=26daece790988d1cdaed9af4…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Thu Sep 3 14:59:06 2020 +0200 mountmgr: Add ioctl to delete host credentials on macOS. Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/mountmgr.sys/mountmgr.c | 28 ++++++++++++++++++++++++++++ include/ddk/mountmgr.h | 1 + 2 files changed, 29 insertions(+) diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c index c3b9135ce1..95b11d864a 100644 --- a/dlls/mountmgr.sys/mountmgr.c +++ b/dlls/mountmgr.sys/mountmgr.c @@ -819,6 +819,23 @@ error: RtlFreeHeap( GetProcessHeap(), 0, password ); return ret; } + +static NTSTATUS delete_credential( void *buff, SIZE_T insize, SIZE_T outsize, IO_STATUS_BLOCK *iosb ) +{ + const struct mountmgr_credential *cred = buff; + const WCHAR *targetname; + SecKeychainItemRef item; + + if (!check_credential_string( buff, insize, cred->targetname_size, cred->targetname_offset )) + return STATUS_INVALID_PARAMETER; + targetname = (const WCHAR *)((const char *)cred + cred->targetname_offset); + + if (!(item = find_credential( targetname ))) return STATUS_NOT_FOUND; + + SecKeychainItemDelete( item ); + CFRelease( item ); + return STATUS_SUCCESS; +} #endif /* __APPLE__ */ /* handler for ioctls on the mount manager device */ @@ -909,6 +926,17 @@ static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp ) irpsp->Parameters.DeviceIoControl.OutputBufferLength, &irp->IoStatus ); break; + case IOCTL_MOUNTMGR_DELETE_CREDENTIAL: + if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(struct mountmgr_credential)) + { + irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER; + break; + } + irp->IoStatus.u.Status = delete_credential( irp->AssociatedIrp.SystemBuffer, + irpsp->Parameters.DeviceIoControl.InputBufferLength, + irpsp->Parameters.DeviceIoControl.OutputBufferLength, + &irp->IoStatus ); + break; #endif default: FIXME( "ioctl %x not supported\n", irpsp->Parameters.DeviceIoControl.IoControlCode ); diff --git a/include/ddk/mountmgr.h b/include/ddk/mountmgr.h index 162bbf7107..a5aae2a085 100644 --- a/include/ddk/mountmgr.h +++ b/include/ddk/mountmgr.h @@ -76,6 +76,7 @@ struct mountmgr_unix_drive #define IOCTL_MOUNTMGR_READ_CREDENTIAL CTL_CODE(MOUNTMGRCONTROLTYPE, 48, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_MOUNTMGR_WRITE_CREDENTIAL CTL_CODE(MOUNTMGRCONTROLTYPE, 49, METHOD_BUFFERED, FILE_WRITE_ACCESS) +#define IOCTL_MOUNTMGR_DELETE_CREDENTIAL CTL_CODE(MOUNTMGRCONTROLTYPE, 50, METHOD_BUFFERED, FILE_WRITE_ACCESS) struct mountmgr_credential {
1
0
0
0
Hans Leidekker : advapi32: Write host credentials through mountmgr.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: 98a3986c7d613af8f5c782c7890e2f2ca17926f5 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=98a3986c7d613af8f5c782c7…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Thu Sep 3 14:59:05 2020 +0200 advapi32: Write host credentials through mountmgr. Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/advapi32/cred.c | 126 +++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 70 deletions(-) diff --git a/dlls/advapi32/cred.c b/dlls/advapi32/cred.c index 07f4b9b03a..c17023959f 100644 --- a/dlls/advapi32/cred.c +++ b/dlls/advapi32/cred.c @@ -497,85 +497,73 @@ static DWORD registry_write_credential(HKEY hkey, const CREDENTIALW *credential, return ret; } -#ifdef __APPLE__ -static DWORD mac_write_credential(const CREDENTIALW *credential, BOOL preserve_blob) +static DWORD host_write_credential( const CREDENTIALW *credential, BOOL preserve_blob ) { - int status; - SecKeychainItemRef keychain_item; - char *username, *password, *servername; - UInt32 userlen, pwlen, serverlen; - SecKeychainAttribute attrs[1]; - SecKeychainAttributeList attr_list; + struct mountmgr_credential *cred; + HANDLE mgr; + DWORD size; + WCHAR *ptr; + BOOL ret; if (credential->Flags) - FIXME("Flags 0x%x not written\n", credential->Flags); + FIXME( "flags 0x%x not written\n", credential->Flags ); if (credential->Type != CRED_TYPE_DOMAIN_PASSWORD) - FIXME("credential type of %d not supported\n", credential->Type); + FIXME( "credential type of %d not supported\n", credential->Type ); if (credential->Persist != CRED_PERSIST_LOCAL_MACHINE) - FIXME("persist value of %d not supported\n", credential->Persist); + FIXME( "persist value of %d not supported\n", credential->Persist ); if (credential->AttributeCount) - FIXME("custom attributes not supported\n"); - - userlen = WideCharToMultiByte(CP_UTF8, 0, credential->UserName, -1, NULL, 0, NULL, NULL); - username = heap_alloc(userlen * sizeof(*username)); - WideCharToMultiByte(CP_UTF8, 0, credential->UserName, -1, username, userlen, NULL, NULL); - - serverlen = WideCharToMultiByte(CP_UTF8, 0, credential->TargetName, -1, NULL, 0, NULL, NULL); - servername = heap_alloc(serverlen * sizeof(*servername)); - WideCharToMultiByte(CP_UTF8, 0, credential->TargetName, -1, servername, serverlen, NULL, NULL); - pwlen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)credential->CredentialBlob, - credential->CredentialBlobSize / sizeof(WCHAR), NULL, 0, NULL, NULL); - password = heap_alloc(pwlen * sizeof(*password)); - WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)credential->CredentialBlob, - credential->CredentialBlobSize / sizeof(WCHAR), password, pwlen, NULL, NULL); - - TRACE("adding server %s, username %s using Keychain\n", servername, username); - status = SecKeychainAddGenericPassword(NULL, strlen(servername), servername, strlen(username), - username, strlen(password), password, &keychain_item); - if (status != noErr) - ERR("SecKeychainAddGenericPassword returned %d\n", status); - if (status == errSecDuplicateItem) + FIXME( "custom attributes not supported\n" ); + + if (credential->CredentialBlobSize % sizeof(WCHAR)) return ERROR_NOT_SUPPORTED; + + mgr = CreateFileW( MOUNTMGR_DOS_DEVICE_NAME, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, 0 ); + if (mgr == INVALID_HANDLE_VALUE) return GetLastError(); + + size = sizeof(*cred) + (strlenW( credential->TargetName ) + strlenW( credential->UserName ) + 2) * sizeof(WCHAR); + size += credential->CredentialBlobSize; + if (credential->Comment) size += (strlenW( credential->Comment ) + 1) * sizeof(WCHAR); + if (!(cred = heap_alloc( size ))) { - status = SecKeychainFindGenericPassword(NULL, strlen(servername), servername, strlen(username), - username, NULL, NULL, &keychain_item); - if (status != noErr) - ERR("SecKeychainFindGenericPassword returned %d\n", status); + CloseHandle( mgr ); + return ERROR_OUTOFMEMORY; } - heap_free(username); - heap_free(servername); - if (status != noErr) + ptr = (WCHAR *)(cred + 1); + + cred->targetname_offset = sizeof(*cred); + cred->targetname_size = (strlenW( credential->TargetName ) + 1) * sizeof(WCHAR); + strcpyW( ptr, credential->TargetName ); + ptr += cred->targetname_size / sizeof(WCHAR); + + cred->username_offset = cred->targetname_offset + cred->targetname_size; + cred->username_size = (strlenW( credential->UserName ) + 1) * sizeof(WCHAR); + strcpyW( ptr, credential->UserName ); + ptr += cred->username_size / sizeof(WCHAR); + + cred->blob_offset = cred->username_offset + cred->username_size; + if (credential->CredentialBlob) { - heap_free(password); - return ERROR_GEN_FAILURE; + cred->blob_size = credential->CredentialBlobSize; + memcpy( ptr, credential->CredentialBlob, credential->CredentialBlobSize ); + ptr += cred->blob_size / sizeof(WCHAR); } + else cred->blob_size = 0; + cred->blob_preserve = preserve_blob; + + cred->comment_offset = cred->blob_offset + cred->blob_size; if (credential->Comment) { - attr_list.count = 1; - attr_list.attr = attrs; - attrs[0].tag = kSecCommentItemAttr; - attrs[0].length = WideCharToMultiByte(CP_UTF8, 0, credential->Comment, -1, NULL, 0, NULL, NULL); - if (attrs[0].length) attrs[0].length--; - attrs[0].data = heap_alloc(attrs[0].length); - WideCharToMultiByte(CP_UTF8, 0, credential->Comment, -1, attrs[0].data, attrs[0].length, NULL, NULL); - } - else - { - attr_list.count = 0; - attr_list.attr = NULL; + cred->comment_size = (strlenW( credential->Comment ) + 1) * sizeof(WCHAR); + strcpyW( ptr, credential->Comment ); } - status = SecKeychainItemModifyAttributesAndData(keychain_item, &attr_list, - preserve_blob ? 0 : strlen(password), - preserve_blob ? NULL : password); - if (credential->Comment) - heap_free(attrs[0].data); - heap_free(password); - /* FIXME: set TargetAlias attribute */ - CFRelease(keychain_item); - if (status != noErr) - return ERROR_GEN_FAILURE; - return ERROR_SUCCESS; + else cred->comment_size = 0; + + ret = DeviceIoControl( mgr, IOCTL_MOUNTMGR_WRITE_CREDENTIAL, cred, size, NULL, 0, NULL, NULL ); + heap_free( cred ); + CloseHandle( mgr ); + + return ret ? ERROR_SUCCESS : GetLastError(); } -#endif static DWORD open_cred_mgr_key(HKEY *hkey, BOOL open_for_write) { @@ -1823,20 +1811,18 @@ BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags) } } -#ifdef __APPLE__ if (!Credential->AttributeCount && Credential->Type == CRED_TYPE_DOMAIN_PASSWORD && (Credential->Persist == CRED_PERSIST_LOCAL_MACHINE || Credential->Persist == CRED_PERSIST_ENTERPRISE)) { - ret = mac_write_credential(Credential, Flags & CRED_PRESERVE_CREDENTIAL_BLOB); - if (ret != ERROR_SUCCESS) + ret = host_write_credential(Credential, Flags & CRED_PRESERVE_CREDENTIAL_BLOB); + if (ret != ERROR_SUCCESS && ret != ERROR_NOT_SUPPORTED) { SetLastError(ret); return FALSE; } - return TRUE; + if (ret == ERROR_SUCCESS) return TRUE; } -#endif ret = open_cred_mgr_key(&hkeyMgr, FALSE); if (ret != ERROR_SUCCESS)
1
0
0
0
Hans Leidekker : mountmgr: Add ioctl to write host credentials on macOS.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: 7c000ca0f4b85271f1d11706194842abceb14504 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7c000ca0f4b85271f1d11706…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Thu Sep 3 14:59:04 2020 +0200 mountmgr: Add ioctl to write host credentials on macOS. Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/mountmgr.sys/mountmgr.c | 99 ++++++++++++++++++++++++++++++++++++++++++++ include/ddk/mountmgr.h | 1 + 2 files changed, 100 insertions(+) diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c index d55ca64301..c3b9135ce1 100644 --- a/dlls/mountmgr.sys/mountmgr.c +++ b/dlls/mountmgr.sys/mountmgr.c @@ -731,6 +731,94 @@ static NTSTATUS read_credential( void *buff, SIZE_T insize, SIZE_T outsize, IO_S iosb->Information = size; return (size > outsize) ? STATUS_BUFFER_OVERFLOW : STATUS_SUCCESS; } + +static NTSTATUS write_credential( void *buff, SIZE_T insize, SIZE_T outsize, IO_STATUS_BLOCK *iosb ) +{ + const struct mountmgr_credential *cred = buff; + int status, len, len_password = 0; + const WCHAR *ptr; + SecKeychainItemRef keychain_item; + char *targetname, *username = NULL, *password = NULL; + SecKeychainAttribute attrs[1]; + SecKeychainAttributeList attr_list; + NTSTATUS ret = STATUS_NO_MEMORY; + + if (!check_credential_string( buff, insize, cred->targetname_size, cred->targetname_offset ) || + !check_credential_string( buff, insize, cred->username_size, cred->username_offset ) || + ((cred->blob_size && cred->blob_size % sizeof(WCHAR)) || cred->blob_offset + cred->blob_size > insize) || + (cred->comment_size && !check_credential_string( buff, insize, cred->comment_size, cred->comment_offset )) || + sizeof(*cred) + cred->targetname_size + cred->username_size + cred->blob_size + cred->comment_size > insize) + { + return STATUS_INVALID_PARAMETER; + } + + ptr = (const WCHAR *)((const char *)cred + cred->targetname_offset); + len = WideCharToMultiByte( CP_UTF8, 0, ptr, -1, NULL, 0, NULL, NULL ); + if (!(targetname = RtlAllocateHeap( GetProcessHeap(), 0, len ))) goto error; + WideCharToMultiByte( CP_UTF8, 0, ptr, -1, targetname, len, NULL, NULL ); + + ptr = (const WCHAR *)((const char *)cred + cred->username_offset); + len = WideCharToMultiByte( CP_UTF8, 0, ptr, -1, NULL, 0, NULL, NULL ); + if (!(username = RtlAllocateHeap( GetProcessHeap(), 0, len ))) goto error; + WideCharToMultiByte( CP_UTF8, 0, ptr, -1, username, len, NULL, NULL ); + + if (cred->blob_size) + { + ptr = (const WCHAR *)((const char *)cred + cred->blob_offset); + len_password = WideCharToMultiByte( CP_UTF8, 0, ptr, cred->blob_size / sizeof(WCHAR), NULL, 0, NULL, NULL ); + if (!(password = RtlAllocateHeap( GetProcessHeap(), 0, len_password ))) goto error; + WideCharToMultiByte( CP_UTF8, 0, ptr, cred->blob_size / sizeof(WCHAR), password, len_password, NULL, NULL ); + } + + TRACE("adding target %s, username %s using Keychain\n", targetname, username ); + status = SecKeychainAddGenericPassword( NULL, strlen(targetname), targetname, strlen(username), username, + len_password, password, &keychain_item ); + if (status != noErr) ERR( "SecKeychainAddGenericPassword returned %d\n", status ); + if (status == errSecDuplicateItem) + { + status = SecKeychainFindGenericPassword( NULL, strlen(targetname), targetname, strlen(username), username, NULL, + NULL, &keychain_item ); + if (status != noErr) ERR( "SecKeychainFindGenericPassword returned %d\n", status ); + } + RtlFreeHeap( GetProcessHeap(), 0, username ); + RtlFreeHeap( GetProcessHeap(), 0, targetname ); + if (status != noErr) + { + RtlFreeHeap( GetProcessHeap(), 0, password ); + return STATUS_UNSUCCESSFUL; + } + if (cred->comment_size) + { + attr_list.count = 1; + attr_list.attr = attrs; + attrs[0].tag = kSecCommentItemAttr; + ptr = (const WCHAR *)((const char *)cred + cred->comment_offset); + attrs[0].length = WideCharToMultiByte( CP_UTF8, 0, ptr, -1, NULL, 0, NULL, NULL ); + if (attrs[0].length) attrs[0].length--; + if (!(attrs[0].data = RtlAllocateHeap( GetProcessHeap(), 0, attrs[0].length ))) goto error; + WideCharToMultiByte( CP_UTF8, 0, ptr, -1, attrs[0].data, attrs[0].length, NULL, NULL ); + } + else + { + attr_list.count = 0; + attr_list.attr = NULL; + } + status = SecKeychainItemModifyAttributesAndData( keychain_item, &attr_list, cred->blob_preserve ? 0 : len_password, + cred->blob_preserve ? NULL : password ); + + if (cred->comment_size) RtlFreeHeap( GetProcessHeap(), 0, attrs[0].data ); + RtlFreeHeap( GetProcessHeap(), 0, password ); + /* FIXME: set TargetAlias attribute */ + CFRelease( keychain_item ); + if (status != noErr) return STATUS_UNSUCCESSFUL; + return STATUS_SUCCESS; + +error: + RtlFreeHeap( GetProcessHeap(), 0, username ); + RtlFreeHeap( GetProcessHeap(), 0, targetname ); + RtlFreeHeap( GetProcessHeap(), 0, password ); + return ret; +} #endif /* __APPLE__ */ /* handler for ioctls on the mount manager device */ @@ -810,6 +898,17 @@ static NTSTATUS WINAPI mountmgr_ioctl( DEVICE_OBJECT *device, IRP *irp ) irpsp->Parameters.DeviceIoControl.OutputBufferLength, &irp->IoStatus ); break; + case IOCTL_MOUNTMGR_WRITE_CREDENTIAL: + if (irpsp->Parameters.DeviceIoControl.InputBufferLength < sizeof(struct mountmgr_credential)) + { + irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER; + break; + } + irp->IoStatus.u.Status = write_credential( irp->AssociatedIrp.SystemBuffer, + irpsp->Parameters.DeviceIoControl.InputBufferLength, + irpsp->Parameters.DeviceIoControl.OutputBufferLength, + &irp->IoStatus ); + break; #endif default: FIXME( "ioctl %x not supported\n", irpsp->Parameters.DeviceIoControl.IoControlCode ); diff --git a/include/ddk/mountmgr.h b/include/ddk/mountmgr.h index c3d9407819..162bbf7107 100644 --- a/include/ddk/mountmgr.h +++ b/include/ddk/mountmgr.h @@ -75,6 +75,7 @@ struct mountmgr_unix_drive }; #define IOCTL_MOUNTMGR_READ_CREDENTIAL CTL_CODE(MOUNTMGRCONTROLTYPE, 48, METHOD_BUFFERED, FILE_READ_ACCESS) +#define IOCTL_MOUNTMGR_WRITE_CREDENTIAL CTL_CODE(MOUNTMGRCONTROLTYPE, 49, METHOD_BUFFERED, FILE_WRITE_ACCESS) struct mountmgr_credential {
1
0
0
0
Isabella Bosia : ndis.sys/tests: Add tests for ndis ioctls.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: b8d710ce687045cca2d66d7a23b3688939935983 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b8d710ce687045cca2d66d7a…
Author: Isabella Bosia <ibosia(a)codeweavers.com> Date: Tue Sep 1 12:41:20 2020 +0100 ndis.sys/tests: Add tests for ndis ioctls. Signed-off-by: Isabella Bosia <ibosia(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- configure | 1 + configure.ac | 1 + dlls/ndis.sys/tests/Makefile.in | 5 ++ dlls/ndis.sys/tests/ndis.c | 146 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) diff --git a/configure b/configure index 96730fce69..538218fda1 100755 --- a/configure +++ b/configure @@ -21057,6 +21057,7 @@ wine_fn_config_makefile dlls/mtxdm enable_mtxdm wine_fn_config_makefile dlls/ncrypt enable_ncrypt wine_fn_config_makefile dlls/nddeapi enable_nddeapi wine_fn_config_makefile dlls/ndis.sys enable_ndis_sys +wine_fn_config_makefile dlls/ndis.sys/tests enable_tests wine_fn_config_makefile dlls/netapi32 enable_netapi32 wine_fn_config_makefile dlls/netapi32/tests enable_tests wine_fn_config_makefile dlls/netcfgx enable_netcfgx diff --git a/configure.ac b/configure.ac index 13adf2da7e..f60cd59354 100644 --- a/configure.ac +++ b/configure.ac @@ -3579,6 +3579,7 @@ WINE_CONFIG_MAKEFILE(dlls/mtxdm) WINE_CONFIG_MAKEFILE(dlls/ncrypt) WINE_CONFIG_MAKEFILE(dlls/nddeapi) WINE_CONFIG_MAKEFILE(dlls/ndis.sys) +WINE_CONFIG_MAKEFILE(dlls/ndis.sys/tests) WINE_CONFIG_MAKEFILE(dlls/netapi32) WINE_CONFIG_MAKEFILE(dlls/netapi32/tests) WINE_CONFIG_MAKEFILE(dlls/netcfgx) diff --git a/dlls/ndis.sys/tests/Makefile.in b/dlls/ndis.sys/tests/Makefile.in new file mode 100644 index 0000000000..8544dfdff2 --- /dev/null +++ b/dlls/ndis.sys/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = ndis.sys +IMPORTS = iphlpapi advapi32 ole32 + +C_SRCS = \ + ndis.c diff --git a/dlls/ndis.sys/tests/ndis.c b/dlls/ndis.sys/tests/ndis.c new file mode 100644 index 0000000000..679d29130c --- /dev/null +++ b/dlls/ndis.sys/tests/ndis.c @@ -0,0 +1,146 @@ +/* + * Unit tests for ndis ioctls + * + * Copyright (c) 2020 Isabella Bosia + * + * 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 <ntstatus.h> +#define WIN32_NO_STATUS +#include <windows.h> +#include <winioctl.h> +#include <ntddndis.h> +#include <winsock2.h> +#include <ws2ipdef.h> +#include <iphlpapi.h> +#include <netioapi.h> +#include <shlwapi.h> +#include <stdio.h> +#include <string.h> +#include <winternl.h> +#include <winnt.h> +#include "wine/test.h" + +static void test_device(const WCHAR *service_name, const MIB_IF_ROW2 *row) +{ + DWORD size; + int ret; + NDIS_MEDIUM medium; + UCHAR addr[IF_MAX_PHYS_ADDRESS_LENGTH]; + HANDLE netdev = INVALID_HANDLE_VALUE; + int oid; + UNICODE_STRING str; + OBJECT_ATTRIBUTES attr; + NTSTATUS status; + IO_STATUS_BLOCK iosb; + WCHAR meoW[47]; + + swprintf( meoW, ARRAY_SIZE(meoW), L"\\Device\\%s", service_name ); + RtlInitUnicodeString( &str, meoW ); + InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); + status = NtOpenFile( &netdev, GENERIC_READ, &attr, &iosb, FILE_SHARE_READ, 0 ); + + if (status != STATUS_SUCCESS) + { + skip( "Couldn't open the device (status = %d)\n", status ); + return; + } + + oid = OID_GEN_MEDIA_SUPPORTED; + ret = DeviceIoControl( netdev, IOCTL_NDIS_QUERY_GLOBAL_STATS, + &oid, sizeof(oid), &medium, sizeof(medium), &size, NULL ); + ok( ret, "OID_GEN_MEDIA_SUPPORTED failed (ret = %d)\n", ret ); + ok( medium == row->MediaType, "Wrong media type\n" ); + + oid = OID_GEN_MEDIA_IN_USE; + ret = DeviceIoControl( netdev, IOCTL_NDIS_QUERY_GLOBAL_STATS, + &oid, sizeof(oid), &medium, sizeof(medium), &size, NULL ); + ok( ret, "OID_GEN_MEDIA_IN_USE failed (ret = %d)\n", ret ); + ok( medium == row->MediaType, "Wrong media type\n" ); + + oid = OID_802_3_PERMANENT_ADDRESS; + ret = DeviceIoControl( netdev, IOCTL_NDIS_QUERY_GLOBAL_STATS, + &oid, sizeof(oid), addr, sizeof(addr), &size, NULL ); + ok( ret, "OID_802_3_PERMANENT_ADDRESS failed (ret = %d)\n", ret ); + ok( row->PhysicalAddressLength == size && !memcmp( row->PermanentPhysicalAddress, addr, size ), + "Wrong permanent address\n" ); + + oid = OID_802_3_CURRENT_ADDRESS; + ret = DeviceIoControl( netdev, IOCTL_NDIS_QUERY_GLOBAL_STATS, + &oid, sizeof(oid), addr, sizeof(addr), &size, NULL ); + ok( ret, "OID_802_3_CURRENT_ADDRESS failed (ret = %d)\n", ret ); + ok( row->PhysicalAddressLength == size && !memcmp( row->PhysicalAddress, addr, size ), + "Wrong current address\n" ); +} + +static void test_ndis_ioctl(void) +{ + HKEY nics, sub_key; + LSTATUS ret; + WCHAR card[16]; + WCHAR description[100], service_name[100]; + DWORD size, type, i = 0; + + ret = RegOpenKeyExW( HKEY_LOCAL_MACHINE, + L"Software\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards", 0, KEY_READ, &nics ); + ok( ret == ERROR_SUCCESS, "NetworkCards key missing\n" ); + + while (1) + { + MIB_IF_ROW2 row = {{0}}; + GUID guid; + + size = sizeof(card); + ret = RegEnumKeyExW( nics, i, card, &size, NULL, NULL, NULL, NULL ); + if (ret != ERROR_SUCCESS) + break; + i++; + + ret = RegOpenKeyExW( nics, card, 0, KEY_READ, &sub_key ); + ok( ret == ERROR_SUCCESS, "Could not open network card subkey\n" ); + + size = sizeof(service_name); + ret = RegQueryValueExW( sub_key, L"ServiceName", NULL, &type, (BYTE *)service_name, &size ); + ok( ret == ERROR_SUCCESS && type == REG_SZ, "Wrong ServiceName\n" ); + + CLSIDFromString( service_name, (LPCLSID)&guid ); + ConvertInterfaceGuidToLuid( &guid, &row.InterfaceLuid ); + + ret = GetIfEntry2(&row); + ok( ret == NO_ERROR, "GetIfEntry2 failed\n" ); + + ok( IsEqualGUID( &guid, &row.InterfaceGuid ), "Wrong ServiceName\n" ); + + size = sizeof(description); + ret = RegQueryValueExW( sub_key, L"Description", NULL, &type, (BYTE *)description, &size ); + ok( ret == ERROR_SUCCESS && type == REG_SZ, "Wrong Description\n" ); + + trace( "testing device <%s>\n", wine_dbgstr_w(description) ); + test_device( service_name, &row ); + + RegCloseKey( sub_key ); + } + + if (i == 0) + skip( "Network card subkeys missing\n" ); + + RegCloseKey( nics ); +} + +START_TEST(ndis) +{ + test_ndis_ioctl(); +}
1
0
0
0
Isabella Bosia : ndis.sys: Implement IOCTL_NDIS_QUERY_GLOBAL_STATS on network cards.
by Alexandre Julliard
03 Sep '20
03 Sep '20
Module: wine Branch: master Commit: f32c88a42a973af63765093266e3ec19a11f7329 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f32c88a42a973af637650932…
Author: Isabella Bosia <ibosia(a)codeweavers.com> Date: Tue Sep 1 12:41:19 2020 +0100 ndis.sys: Implement IOCTL_NDIS_QUERY_GLOBAL_STATS on network cards. Signed-off-by: Isabella Bosia <ibosia(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ndis.sys/main.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/dlls/ndis.sys/main.c b/dlls/ndis.sys/main.c index 73eeb8d584..358dc61dc7 100644 --- a/dlls/ndis.sys/main.c +++ b/dlls/ndis.sys/main.c @@ -40,6 +40,86 @@ WINE_DEFAULT_DEBUG_CHANNEL(ndis); +static void query_global_stats(IRP *irp, const MIB_IF_ROW2 *netdev) +{ + IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); + void *response = MmGetSystemAddressForMdlSafe( irp->MdlAddress, NormalPagePriority ); + DWORD len = irpsp->Parameters.DeviceIoControl.OutputBufferLength; + DWORD oid; + + if (irpsp->Parameters.DeviceIoControl.InputBufferLength != sizeof(oid)) + { + irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER; + return; + } + oid = *(DWORD *)irp->AssociatedIrp.SystemBuffer; + + switch (oid) + { + case OID_GEN_MEDIA_SUPPORTED: + case OID_GEN_MEDIA_IN_USE: + { + if (len < sizeof(NDIS_MEDIUM)) + { + irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER; + break; + } + *(NDIS_MEDIUM *)response = netdev->MediaType; + irp->IoStatus.Information = sizeof(netdev->MediaType); + irp->IoStatus.u.Status = STATUS_SUCCESS; + break; + } + case OID_802_3_PERMANENT_ADDRESS: + { + irp->IoStatus.Information = netdev->PhysicalAddressLength; + if (len < netdev->PhysicalAddressLength) + irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER; + else + memcpy( response, netdev->PermanentPhysicalAddress, sizeof(netdev->PermanentPhysicalAddress) ); + break; + } + case OID_802_3_CURRENT_ADDRESS: + { + irp->IoStatus.Information = netdev->PhysicalAddressLength; + if (len < netdev->PhysicalAddressLength) + irp->IoStatus.u.Status = STATUS_INVALID_PARAMETER; + else + memcpy( response, netdev->PhysicalAddress, sizeof(netdev->PhysicalAddress) ); + break; + + } + default: + FIXME( "Unsupported OID %x\n", oid ); + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + break; + } +} + +static NTSTATUS WINAPI ndis_ioctl(DEVICE_OBJECT *device, IRP *irp) +{ + IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); + MIB_IF_ROW2 *netdev = device->DeviceExtension; + + TRACE( "ioctl %x insize %u outsize %u\n", + irpsp->Parameters.DeviceIoControl.IoControlCode, + irpsp->Parameters.DeviceIoControl.InputBufferLength, + irpsp->Parameters.DeviceIoControl.OutputBufferLength ); + + switch (irpsp->Parameters.DeviceIoControl.IoControlCode) + { + case IOCTL_NDIS_QUERY_GLOBAL_STATS: + query_global_stats(irp, netdev); + break; + default: + FIXME( "ioctl %x not supported\n", irpsp->Parameters.DeviceIoControl.IoControlCode ); + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + break; + } + + IoCompleteRequest( irp, IO_NO_INCREMENT ); + return STATUS_SUCCESS; +} + static void add_key(const WCHAR *guidstrW, const MIB_IF_ROW2 *netdev) { HKEY card_key; @@ -110,6 +190,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path) { TRACE("(%p, %s)\n", driver, debugstr_w(path->Buffer)); + driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ndis_ioctl; + create_network_devices( driver ); return STATUS_SUCCESS;
1
0
0
0
← Newer
1
...
60
61
62
63
64
65
66
...
71
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Results per page:
10
25
50
100
200