WSALookupServiceBegin crashes when LUP_FLUSHCACHE is specified

0

I have a C++/CLI dll implementing some Bluetooth functionalities that is loaded by a .NET application. If the dll is compiled with .NET 3.5 (the same goes for the application), everything works fine.

I have updated the dll to .NET 4.0 (in VS 2010) and to platform toolset v100 (VS2010); the application has been updated to the same version of .NET framework, of course. Since then, the WSALookupServiceBegin has been crashing if I specify the LUP_FLUSHCACHE flag.

Here's the code:

HANDLE hLookup = 0;
WSAQUERYSET qs;
::memset(&qs, 0, sizeof(WSAQUERYSET));

// Start the lookup service
qs.dwSize = sizeof(WSAQUERYSET);
qs.dwNameSpace = NS_BTH;

iResult = ::WSALookupServiceBegin(&qs, LUP_CONTAINERS | LUP_RETURN_TYPE | LUP_RETURN_NAME | LUP_RETURN_ADDR | LUP_FLUSHCACHE, &hLookup); **<= Crash here**

The error indicated is -1073740791 (0xc0000409) (Buffer overrun if you check ntstatus.h).

I have tried everything, adding a blob (to specify the inquiry period), etc. The problem persists.

Winsock is correctly initialized, the connections (to BT SPP devices) work fine. Only device inquiries crash.

Does anybody have any idea why I am experiencing this crash?

Thanks, Alek

bluetooth
asked on Stack Overflow Nov 23, 2012 by alek_1977

1 Answer

0

Have you tried initializing your WSAQUERYSET to zero?

memset(&qs, 0, sizeof(WSAQUERYSET));

Sometimes the system will initialize your WSAQUERYSET to garbage - this could be causing your buffer overrun.

answered on Stack Overflow Jan 29, 2013 by user2022677

User contributions licensed under CC BY-SA 3.0