Discussion:
Crashes on lineOpen
(too old to reply)
g***@gmx.com
2013-09-18 16:45:31 UTC
Permalink
Hello,

Can anyone please help me! I am trying to write a Telephony Service Provider (TSP), I can add the TSP through control panel, and dialer.exe recognizes my line and calls most of the functions that I need it to. However it always bugs out on TSPI_lineOpen. I belive that the data I pass should be accepted according to the documentation. Please could someone tell me where I am going wrong.

Many thanks

[code]

LONG TSPIAPI TSPI_lineOpen( DWORD dwDeviceID, HTAPILINE htLine, LPHDRVLINE lphdLine, DWORD dwTSPIVersion, LINEEVENT lpfnEventProc )
{
#ifdef DEV
ofstream newFile;
newFile.open ("C:\\temp\\test.txt", ios::app );
newFile << "- [TSPI_lineOpen] Device id: " << dwDeviceID << " with TSPI version: " << dwTSPIVersion << "\n";
newFile.close();
#endif

if(LPVOID foo = LocalAlloc(LPTR, sizeof(DRVLINE))) // A nasty hack, but it works (sort of)!
{
PDRVLINE pLine = (PDRVLINE)foo;
*lphdLine = (HDRVLINE) pLine;

pLine->htLine = htLine;
pLine->pfnEventProc = lpfnEventProc;
pLine->dwDeviceID = dwDeviceID;

}
else
return LINEERR_NOMEM;


return 0;
}

[/code]

Full project source (if needed) in 7zip format

https://www.dropbox.com/s/jl8ry9br5w6wke5/Cartwright%20TSPI%2010.7z
Andreas Marschall [exMVP TAPI]
2013-10-20 00:54:09 UTC
Permalink
Am Mittwoch, 18. September 2013 18:45:31 UTC+2 schrieb ***@gmx.com:
However it always bugs out on TSPI_lineOpen. I belive that the data I pass should be accepted according to the documentation. Please could someone tell me where I am going wrong.
Post by g***@gmx.com
LONG TSPIAPI TSPI_lineOpen( DWORD dwDeviceID, HTAPILINE htLine, LPHDRVLINE lphdLine, DWORD dwTSPIVersion, LINEEVENT lpfnEventProc )
if(LPVOID foo = LocalAlloc(LPTR, sizeof(DRVLINE))) // A nasty hack, but it works (sort of)!
{
PDRVLINE pLine = (PDRVLINE)foo;
*lphdLine = (HDRVLINE) pLine;
}
return 0;
}
Hi,
1st of all, what's wrong with omitting your "foo" stufflike this:
PDRVLINE pLine = (PDRVLINE)LocalAlloc(LPTR, sizeof(DRVLINE));

You are required to store/provide a pointer to your real DRVLINE data within your TSP, so that you can access this data later.
E.g. on TSPI_lineMakeCall(,hdLine,...) you get that pointer and need to determine the correct line device to place the call.

In addition, don't forget to LocalFree() the memory at TSPI_lineClose() when you no longer need it.

MSDN says on HDRVLINE:
"The HDRVLINE datatype represents a service provider's opaque handle for a line data structure. The service provider must resolve a value of this type into a reference to the appropriate data structure instance."
--
Best Regards
Andreas Marschall
Microsoft MVP for TAPI / Windows SDK / Visual C++ 2003-2008
TAPI / TSP Developer and Tester
My TAPI and TSPI FAQ:
http://www.I-B-A-M.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm
My Toto® Tools (a collection of free, mostly TAPI related tools):
http://www.I-B-A-M.de/Andreas_Marschall's_Toto_Tools.htm
* Please post all messages and replies to the group / forum so all may
* benefit from the discussion. Private mail is usually not replied to.
* This posting is provided "AS IS" with no warranties, and confers no rights.
Loading...