Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build saferarray as 0-based #16

Open
moteus opened this issue Sep 30, 2016 · 0 comments
Open

Build saferarray as 0-based #16

moteus opened this issue Sep 30, 2016 · 0 comments

Comments

@moteus
Copy link

moteus commented Sep 30, 2016

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}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant