Skip to content

Build saferarray as 0-based #16

@moteus

Description

@moteus

moteus@0542f4b
I found problem with some Microsoft interfaces wich crashes when you try send
1-based arrays. And because VBS uses 0-based arrays I think it should be safer
use it.
Test example crash with Access violation.

local luacom = require "luacom"

local FwPolicy2PROGID = "HNetCfg.FwPolicy2"
local FwPolicy2CLSID  = luacom.CLSIDfromProgID(FwPolicy2PROGID)

local policy = luacom.CreateObject(FwPolicy2CLSID)

-- Important that profile had interfaces
policy:getExcludedInterfaces(2)
policy:setExcludedInterfaces(2, {'{01C221C0-0000-0000-2E7E-974EF0F8D046}'})

Tracestack is

kernel32.dll!_LongCompareString@4()
kernel32.dll!_SortCompareString@32()
KernelBase.dll!_SortCompareString@36()
KernelBase.dll!_CompareStringW@24()
FirewallAPI.dll!FwInterfaceNameToLuid(struct _IP_ADAPTER_ADDRESSES_LH *,unsigned short * const,struct _GUID *)
FirewallAPI.dll!FwSafearrayToLuids(struct tagVARIANT,struct _tag_FW_INTERFACE_LUIDS *)
FirewallAPI.dll!FwPolicy2::put_ExcludedInterfaces(enum NET_FW_PROFILE_TYPE2_,struct tagVARIANT)
oleaut32.dll!_DispCallFunc@32()
oleaut32.dll!CTypeInfo2::Invoke(void *,long,unsigned short,struct tagDISPPARAMS *,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *)
FirewallAPI.dll!ATL::IDispatchImpl<struct INetFwPolicy2,&struct __s_GUID const _GUID_98325047_c671_4174_8d81_defcd3f03186,&struct _GUID const LIBID_NetFwTypeLib,1,0,class ATL::CComTypeInfoHolder>::Invoke(long,struct _GUID const &,unsigned long,unsigned short,struct tagDISPPARAMS *,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *)
luacom.dll!tLuaCOM::call(lua_State * L, long dispid, int invkind, tagFUNCDESC * pfuncdesc, tLuaObjList params)

This example does not crash

Set fwPolicy2 = CreateObject("HNetCfg.FwPolicy2")
InterfaceArray = fwPolicy2.ExcludedInterfaces(2)
fwPolicy2.ExcludedInterfaces(2) = Array("{01C5E0B0-0000-0000-2E7E-974EF0F8D046}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions