#pragma comment(lib,"rasapi32.lib") // windows PPPoE 函数lib
增加如下几个函数体:
//截获RasDialA函数体,用户自己实现,在调用系统RasDialA函数之前系统会先调用此函数,而参数入口信息完全一致,这样我们就可以从中提取相应的参数信息,提取完成后再继续调用系统原来的RasDialA函数,达到Hook API的目的。
DWORD WINAPI MyRasDialA(
LPRASDIALEXTENSIONS lpRasDialExtensions, // pointer to function extensions data
LPCTSTR lpszPhonebook, // pointer to full path and file name of phone-book file
LPRASDIALPARAMS lpRasDialParams, // pointer to calling parameters data
DWORD dwNotifierType, // specifies type of RasDial event handler
LPVOID lpvNotifier, // specifies a handler for RasDial events
LPHRASCONN lphRasConn // pointer to variable to receive connection handle
);
//经过替换修饰后的RasDialA函数,用户可以在MyRasDialA函数中继续调用系统原来的RasDialA函数功能,在MyRasDialA函数中如果要调用系统原来的RasDialA函数必须调用经过修饰后的oldRasDialA函数,否则将造成无穷嵌套调用造成堆栈崩溃。
DETOUR_TRAMPOLINE(DWORD WINAPI oldRasDialA(
LPRASDIALEXTENSIONS lpRasDialExtensions, // pointer to function extensions data
LPCTSTR lpszPhonebook, // pointer to full path and file name of phone-book file
LPRASDIALPARAMS lpRasDialParams, // pointer to calling parameters data
DWORD dwNotifierType, // specifies type of RasDial event handler
LPVOID lpvNotifier, // specifies a handler for RasDial events
LPHRASCONN lphRasConn /* pointer to variable to receive connection handle*/ ),RasDialA
);
//截获RasDialA函数体,用户自己实现,比如在对话框中弹出ADSL账号和密码,然后继续调用系统的拨号函数RasDialA完成拨号,这样用户一旦使用星空极速拨号软件进行拨号将首先调用MyRasDialA函数,弹出加密后的账号和密码。
DWORD WINAPI MyRasDialA(
LPRASDIALEXTENSIONS lpRasDialExtensions, // pointer to function extensions data
LPCTSTR lpszPhonebook, // pointer to full path and file name of phone-book file
LPRASDIALPARAMS lpRasDialParams, // pointer to calling parameters data
DWORD dwNotifierType, // specifies type of RasDial event handler
LPVOID lpvNotifier, // specifies a handler for RasDial events
LPHRASCONN lphRasConn // pointer to variable to receive connection handle
)
{
//MessageBox(NULL,lpRasDialParams->szUserName,lpRasDialParams->szPassword,MB_OK);