cLogBuff::cLogBuff() { g_Buff.Lock(); }
//unsigned int __stdcall Thread_SendMsg(void *data) unsigned int __stdcall Thread_SendMsg(LPVOID lpParam) { //test for message comunicate ThreadProcInfo* pInfo = (ThreadProcInfo*) lpParam; FILE *fpMsg = fopen(dataFileName,"rb"); int readNum; int counter = 0; int nRet; while(1) { //for pause control critical_section.Lock(); if(exit_flag) { critical_section.Unlock(); fclose(fpMsg); //shutdown(sockClient,SD_SEND); shutdown(sockClient,SD_BOTH); closesocket(sockClient); ResetEvent(g_readyEvent_Send); //reset g_readyEvent_Send to no signal return -1; } critical_section.Unlock(); WaitForSingleObject(g_readyEvent_Send, INFINITE); uint8* recvBuffP = (uint8*)&headerBuf; int readLen; //step 1: read header length readLen = sizeof(headerBuf.msgHeader.headerLen); readNum = fread(&(headerBuf.msgHeader.headerLen), readLen, 1, fpMsg); if(readNum != 1) { fseek(fpMsg, 0, SEEK_SET); counter = 0; continue; } //read header recvBuffP += sizeof(headerBuf.msgHeader.headerLen); readLen = headerBuf.msgHeader.headerLen - sizeof(headerBuf.msgHeader.headerLen); readNum = fread(recvBuffP, readLen, 1, fpMsg); if(readNum != 1) { fseek(fpMsg, 0, SEEK_SET); counter = 0; continue; } //read payload readLen = headerBuf.msgHeader.payloadLen; if(readLen != 0) { readNum = fread(payloadBuf, readLen,1,fpMsg); if(readNum != 1) { fseek(fpMsg, 0, SEEK_SET); counter = 0; continue; } } if(headerBuf.msgHeader.payloadLen != 0) { //printf("message Count = %d\n",counter); //display message count PostMessage(pInfo->hWnd,WM_DISPLAYCOUNT,NULL,counter); counter++; //send header nRet = send(sockClient,(char*)&headerBuf,headerBuf.msgHeader.headerLen,0); if ((nRet == SOCKET_ERROR) || (nRet == 0)) { trySetConnectSocket(true); } else { if((headerBuf.msgHeader.payloadLen > 0)) { nRet = send(sockClient,(char*)payloadBuf,headerBuf.msgHeader.payloadLen,0); if ((nRet == SOCKET_ERROR) || (nRet == 0)) { trySetConnectSocket(true); } } } Sleep(timeDelay); } } fclose(fpMsg); }
cLogErrorLock::cLogErrorLock() { g_LogErrorLock.Lock(); }
cLogFlowLock::cLogFlowLock() { g_LogFlowLock.Lock(); }
void StatsAddTotalBytesSent( size_t inLength ) { ms_StatsCS.Lock(); ms_HttpTotalBytesSent += inLength; ms_StatsCS.Unlock(); }
//====================================================================================== // MessageHandler() // // Handles messages from DirectPlay. //====================================================================================== HRESULT CDarkPeer::MessageHandler(void* pContext, DWORD messageType, void* pMessage) { switch (messageType) { case DPN_MSGID_CREATE_PLAYER: { HandleCreatePlayerMsg((DPNMSG_CREATE_PLAYER*)pMessage); break; } case DPN_MSGID_DESTROY_PLAYER: { // Translate DPlay8's destroy player message to DPlay4 PDPNMSG_DESTROY_PLAYER pDestroyPlayer = (PDPNMSG_DESTROY_PLAYER) pMessage; DPNID dpnidPlayer = pDestroyPlayer->dpnidPlayer; DPMSG_DESTROYPLAYERORGROUP* pDP4DestroyPlayer = new DPMSG_DESTROYPLAYERORGROUP; if (dpnidPlayer != m_dpnidLocal && g_pNetMan) { #if (GAME == GAME_THIEF) #if 1 DPN_PLAYER_INFO* pPeerInfo = GetPeerInfo(pDestroyPlayer->dpnidPlayer); if (pPeerInfo) { char playerName[kMaxPlayerName]; WideToAnsi(playerName, pPeerInfo->pwszName, sizeof(playerName)); const char* str = "%s has left the game."; MessageMgr::Get()->AddLineFormat(true, str, playerName); ConPrintF(str, playerName); SAFE_DELETE_ARRAY(pPeerInfo); } #else const char* playerName = Players.NameFromDPNID(pDestroyPlayer->dpnidPlayer); const char* msg = "%s has left the game."; MessageMgr::Get()->AddLineFormat(true, msg, playerName); ConPrintF(msg, playerName); #endif #endif ZeroMemory(pDP4DestroyPlayer, sizeof(DPMSG_DESTROYPLAYERORGROUP)); pDP4DestroyPlayer->lpLocalData = m_DP4PlayerData[dpnidPlayer]; pDP4DestroyPlayer->dpId = dpnidPlayer; pDP4DestroyPlayer->dwType = DPSYS_DESTROYPLAYERORGROUP; pDP4DestroyPlayer->dwPlayerType = DPPLAYERTYPE_PLAYER; // send Thief the destroy player notification in the form it expects from DPlay 4 NetMessage* pMsg = new NetMessage; pMsg->m_pMsgData = (BYTE*)pDP4DestroyPlayer; pMsg->m_size = sizeof(DPMSG_DESTROYPLAYERORGROUP); pMsg->m_dpnidSender = DPID_SYSMSG; m_DarkQueue.Push(pMsg); // find the player's index and destroy the player data } break; } case DPN_MSGID_INDICATE_CONNECT: { if (g_Net == STATE_Host) { #ifndef _RELEASE if (Client.MissionStarted() && !Cfg.GetBool("AllowJoinsInProgress")) #else if (Client.MissionStarted()) #endif return DPNERR_HOSTREJECTEDCONNECTION; } break; } case DPN_MSGID_CONNECT_COMPLETE: { PDPNMSG_CONNECT_COMPLETE pConnComplete = (PDPNMSG_CONNECT_COMPLETE)pMessage; if (pConnComplete->hResultCode == DPN_OK) { #if (GAME == GAME_THIEF || GAME == GAME_DROMED) m_dpnidLocal = (pConnComplete->dpnidLocal); ConPrintF("Connected to session."); _SFX_Play_Raw(1, 0, "pickloot.wav"); #endif SetEvent(m_ConnectedEvent); } break; } case DPN_MSGID_ENUM_HOSTS_RESPONSE: { m_csEnumResponse.Lock(); DPNMSG_ENUM_HOSTS_RESPONSE* pResponse = (DPNMSG_ENUM_HOSTS_RESPONSE*)pMessage; OnEnumerationResponse(pResponse); m_csEnumResponse.Unlock(); break; } case DPN_MSGID_RECEIVE: { PDPNMSG_RECEIVE pRecvData = (PDPNMSG_RECEIVE)pMessage; Packet* packet = (Packet*)pRecvData->pReceiveData; csReceive.Lock(); // this may not be a good idea... some original packets are very close to these numbers if (packet->type > NewPacketStart && packet->type < NewPacketEnd) { HandleNewPacket(pRecvData->pReceiveData, pRecvData->dwReceiveDataSize, pRecvData->dpnidSender); csReceive.Unlock(); return DPN_OK; } NetMessage* pMsg = new NetMessage; pMsg->m_pMsgData = pRecvData->pReceiveData; pMsg->m_size = pRecvData->dwReceiveDataSize; pMsg->m_bufferHandle = pRecvData->hBufferHandle; // Save buffer handle so we can return it to DirectPlay with ReturnBuffer() later pMsg->m_dpnidSender = pRecvData->dpnidSender; m_DarkQueue.Push(pMsg); csReceive.Unlock(); return DPNSUCCESS_PENDING; } case DPN_MSGID_TERMINATE_SESSION: { // Translate DPlay8's terminate session message to DPlay4 PDPNMSG_TERMINATE_SESSION pTerminateSession = (PDPNMSG_TERMINATE_SESSION)pMessage; DPMSG_SESSIONLOST* pDP4SessLost = new DPMSG_SESSIONLOST; NetMessage* pMsg = new NetMessage; ZeroMemory(pDP4SessLost, sizeof(DPMSG_SESSIONLOST)); pDP4SessLost->dwType = DPSYS_SESSIONLOST; pMsg->m_pMsgData = (BYTE*)pDP4SessLost; pMsg->m_size = sizeof(DPMSG_SESSIONLOST); pMsg->m_dpnidSender = DPID_SYSMSG; m_DarkQueue.Push(pMsg); #if (GAME == GAME_THIEF || GAME == GAME_DROMED) if (pTerminateSession->pvTerminateData) { SDestroyReason* pMsg = (SDestroyReason*)pTerminateSession->pvTerminateData; switch (pMsg->reason) { case DReason_CrcFailed: Client.StartEndGameTimer(EndGameTime, ER_KickedCrc); break; default: case DReason_Kicked: Client.StartEndGameTimer(EndGameTime, ER_Kicked); break; } } else Client.StartEndGameTimer(EndGameTime, ER_HostLeft); #endif break; } } return DPN_OK; }
UINT ThreadProc(LPVOID pParam) { HWND hwnd = AfxGetMainWnd()->GetSafeHwnd(); LPTHREADDATA pData = (LPTHREADDATA)pParam; Mat dst_temp = Mat::zeros(pData->Roi_dst->size(), 16); //Vec3b NullPixel = Vec3b(255, 255, 255); float x_, y_; Point StartPoint; Point EndPoint; StartPoint = pData->Roi->tl(); EndPoint = pData->Roi->br(); int x_s, x_l, y_s, y_l; Vec3b* src_tl; Vec3b* dst_; float* xmap_; float* ymap_; unsigned char* mask_; int CamIdx; int i = 1; while (TRUE) { //MessageBox(NULL, _T("checkpoint1"),NULL , MB_OK); //WaitForSingleObject(g_event[pData->ID],INFINITE); g_Semaphore.Lock(); //MessageBox(NULL, _T("checkpoint2"), NULL, MB_OK); for (int y = StartPoint.y; y < EndPoint.y; y++) { //Vec3b* dst_ = pData->Obj->m_dst.ptr<Vec3b>(y - StartPoint.y); dst_ = dst_temp.ptr<Vec3b>(y - StartPoint.y); xmap_ = pData->Obj->m_xmap.ptr<float>(y); ymap_ = pData->Obj->m_ymap.ptr<float>(y); mask_ = pData->Obj->m_mask.ptr<unsigned char>(y); for (int x = StartPoint.x; x < EndPoint.x; x++) { CamIdx = (int)mask_[x]; if (CamIdx == 255) { //dst_[x] = NullPixel; dst_[x - StartPoint.x] = Vec3b(0, 0, 0); } else { x_ = xmap_[x]; y_ = ymap_[x]; x_s = (int)floor(x_); x_l = (int)ceil(x_); y_s = (int)floor(y_); y_l = (int)ceil(y_); //float n = y_ - y_s, m = x_ - x_s; if (x_s < 0 || y_s < 0 || x_l>(*pData->Images)[CamIdx].cols - 1 || y_l>(*pData->Images)[CamIdx].rows - 1) { //cout << "out of range" << endl; dst_[x - StartPoint.x] = Vec3b(0, 0, 0); } else { src_tl = (*pData->Images)[CamIdx].ptr<Vec3b>(y_s, x_s); dst_[x - StartPoint.x] = *src_tl; } } } } CCritical.Lock(); pData->Obj->m_dst = pData->Obj->m_dst | dst_temp; //signal++; ::PostMessage(hwnd, WM_LOOP, NULL, NULL); CCritical.Unlock(); //MessageBox(NULL, _T("threadend"), NULL, NULL); //Sleep(10); //i--; } dst_temp.release(); return 0; };
// 扫描帖子线程 UINT AFX_CDECL ScanPostThread(LPVOID _threadID) { int threadID = (int)_threadID; CTiebaManagerDlg* dlg = (CTiebaManagerDlg*)AfxGetApp()->m_pMainWnd; // 初始化日志文档 CoInitializeEx(NULL, COINIT_MULTITHREADED); CComPtr<IHTMLDocument2> document; dlg->GetLogDocument(document); CComPtr<IHTMLDocument2>* pDocument = (CComPtr<IHTMLDocument2>*)&(int&)document; CString pageCount, src; map<__int64, int>::iterator historyReplyIt; g_threadIndexLock.Lock(); while (!g_stopScanFlag && g_threadIndex < (int)g_threads.size()) { ThreadInfo& thread = g_threads[g_threadIndex++]; g_threadIndexLock.Unlock(); if (g_deletedTID.find(_ttoi64(thread.tid)) != g_deletedTID.end()) // 已删 goto next; g_optionsLock.Lock(); if (g_trustedThread.find(thread.tid) != g_trustedThread.end()) // 信任 { g_optionsLock.Unlock(); goto next; } g_optionsLock.Unlock(); __int64 tid = _ttoi64(thread.tid); int reply = _ttoi(thread.reply); historyReplyIt = g_reply.find(tid); BOOL hasHistoryReply = historyReplyIt != g_reply.end(); if (hasHistoryReply && reply <= historyReplyIt->second) // 无新回复 { historyReplyIt->second = reply; goto next; } // 第一页 src = HTTPGet(_T("http://tieba.baidu.com/p/" + thread.tid), FALSE, &g_stopScanFlag); if (src == NET_STOP_TEXT) goto next; if (src == NET_TIMEOUT_TEXT) { if (!g_briefLog) dlg->Log(_T("<a href=\"http://tieba.baidu.com/p/") + thread.tid + _T("\">") + thread.title + _T("</a> <font color=red>获取贴子列表失败(超时),暂时跳过</font>"), pDocument); goto next; } // 帖子页数 pageCount = GetStringBetween(src, PAGE_COUNT_LEFT, PAGE_COUNT_RIGHT); if (pageCount == _T("")) { WriteString(src, _T("thread.txt")); if (!g_briefLog) dlg->Log(_T("<a href=\"http://tieba.baidu.com/p/") + thread.tid + _T("\">") + thread.title + _T("</a> <font color=red>获取贴子列表失败(可能已被删),暂时跳过</font>"), pDocument); goto next; } // 扫描帖子页 int iPageCount = _ttoi(pageCount); BOOL res = ScanPostPage(thread.tid, 1, thread.title, hasHistoryReply, 0, src, threadID, dlg, pDocument); if (iPageCount > 1 && !g_stopScanFlag) res = ScanPostPage(thread.tid, iPageCount, thread.title, hasHistoryReply, 0, _T(""), threadID, dlg, pDocument); // 记录历史回复 if (res) g_reply[tid] = reply; next: g_threadIndexLock.Lock(); } g_threadIndexLock.Unlock(); CoUninitialize(); dlg->m_stateList.DeleteString(threadID); dlg->m_stateList.InsertString(threadID, _T("线程结束")); return 0; }
void StatsBytesDeallocated( int nBodyLength ) { ms_StatsCS.Lock(); ms_AllocationStats.uiActiveKBAllocated -= nBodyLength / 1024; ms_StatsCS.Unlock(); }
Lock( CCriticalSection cs ) : m_cs(cs) { m_cs.Lock(); }
void StatsNumResponsesDec( void ) { ms_StatsCS.Lock(); ms_AllocationStats.uiActiveNumResponses--; ms_StatsCS.Unlock(); }
int CALLBACK OptionsDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if(uMsg==WM_INITDIALOG){ iBegin=0; iBegin2=0; hDiag=hwndDlg; bAutoDelRight=0; if(GetKeyState(VK_CONTROL)<0){ bReplaceMode=1; } ::SetWindowText(GetDlgItem(hwndDlg,IDC_STATUS),CString(" ")+_l("Preparing for search")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGL_DEL),_l("Delete this image")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGR_DEL),_l("Delete this image")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGR_DEL_ALL),_l("Auto")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_LI_ST),_l("No image, please wait")); ::SetWindowText(GetDlgItem(hwndDlg,IDC_RI_ST),_l("No image, please wait")); if(bReplaceMode){ ::SetWindowText(GetDlgItem(hwndDlg,ID_NEXT),"Stop renamer"); }else{ ::SetWindowText(GetDlgItem(hwndDlg,ID_NEXT),_l("Stop processing")); } ::SetWindowText(hwndDlg,_l("Search for duplicated images")); ::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGR_DEL_ALL),FALSE); ::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGL_DEL),FALSE); ::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGR_DEL),FALSE); SetTaskbarButton(hwndDlg); //::EnableWindow(GetDlgItem(hwndDlg,ID_NEXT),FALSE); } if(uMsg==WM_KEYDOWN){ if(GetKeyState(VK_CONTROL)<0){ if(wParam==VK_RETURN){ uMsg=WM_COMMAND; wParam=IDOK; } } } if(bStopCheck==0){ if(uMsg==WM_COMMAND && wParam==WM_USER){ // Выбираем у кого разрешение ниже... CString sPath; if(dwPathInRightRes<dwPathInLeftRes){ uMsg=WM_COMMAND; wParam=IDC_IMGR_DEL; }else{ uMsg=WM_COMMAND; wParam=IDC_IMGL_DEL; } } if(uMsg==WM_COMMAND && wParam==IDC_IMGL_DEL){ if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_IMGL_DEL))){ if(sPathInLeft!=""){ sListOfImagesToDelete.Add(sPathInLeft); } } sPathInLeft=""; sPathInRight=""; uMsg=WM_COMMAND; wParam=ID_NEXT; } if(uMsg==WM_COMMAND && wParam==IDC_IMGR_DEL){ if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_IMGR_DEL))){ if(sPathInRight!=""){ sListOfImagesToDelete.Add(sPathInRight); } } sPathInLeft=""; sPathInRight=""; uMsg=WM_COMMAND; wParam=ID_NEXT; } if(uMsg==WM_COMMAND && wParam==IDC_IMGR_DEL_ALL){ if(bAutoDelRight || AfxMessageBox(_l("Delete duplicated images automatically")+"?",MB_YESNO|MB_ICONQUESTION)==IDYES){ bAutoDelRight=1-bAutoDelRight; if(bAutoDelRight){ ::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGR_DEL_ALL),_l("Stop")); PostMessage(hwndDlg,WM_COMMAND,WM_USER,0); }else{ ::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGR_DEL_ALL),_l("Auto")); } } } if(uMsg==WM_COMMAND && wParam==ID_NEXT){ if(iMode==0){ bStopLoad=1; }else if(bStopCheck==0){ iBegin2++; ::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGL_DEL),FALSE); ::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGR_DEL),FALSE); ::EnableWindow(GetDlgItem(hwndDlg,ID_NEXT),FALSE); FORK(ContinueCheck,hwndDlg); } } } if(uMsg==WM_PAINT){ PAINTSTRUCT lpPaint; memset(&lpPaint,0,sizeof(lpPaint)); HDC dcH=BeginPaint(hwndDlg,&lpPaint); CDC dc; dc.Attach(lpPaint.hdc); dc.SetStretchBltMode(HALFTONE); //DefWindowProc( if(sPathInLeft!=""){ if(btLeft){ CRect rt,rtw; ::GetClientRect(GetDlgItem(hwndDlg,IDC_IMGL),&rt); ::GetWindowRect(GetDlgItem(hwndDlg,IDC_IMGL),&rtw); CPoint ptLT(rtw.left,rtw.top); ScreenToClient(hwndDlg,&ptLT); CDC dc2; CDesktopDC dcDesk; dc2.CreateCompatibleDC(&dcDesk); CBitmap* bmpTmp=dc2.SelectObject(btLeft); FitImageToRect(rt,szLeftSize); dc.StretchBlt(ptLT.x+rt.left,ptLT.y+rt.top,rt.Width(),rt.Height(),&dc2,0,0,szLeftSize.cx,szLeftSize.cy,SRCCOPY); dc2.SelectObject(bmpTmp); } } if(sPathInRight!=""){ if(btRight){ CRect rt,rtw; ::GetClientRect(GetDlgItem(hwndDlg,IDC_IMGR),&rt); ::GetWindowRect(GetDlgItem(hwndDlg,IDC_IMGR),&rtw); CPoint ptLT(rtw.left,rtw.top); ScreenToClient(hwndDlg,&ptLT); CDC dc2; CDesktopDC dcDesk; dc2.CreateCompatibleDC(&dcDesk); CBitmap* bmpTmp=dc2.SelectObject(btRight); FitImageToRect(rt,szLeftSize); dc.StretchBlt(ptLT.x+rt.left,ptLT.y+rt.top,rt.Width(),rt.Height(),&dc2,0,0,szRightSize.cx,szRightSize.cy,SRCCOPY); dc2.SelectObject(bmpTmp); } } dc.Detach(); EndPaint(hwndDlg,&lpPaint); return TRUE; } if(uMsg==WM_SYSCOMMAND && wParam==SC_CLOSE){ uMsg=WM_COMMAND; wParam=IDOK; } if(uMsg==WM_COMMAND && wParam==IDOK){ bStopCheck=1; csCheck.Lock(); csCheck.Unlock(); if(sListOfImagesToDelete.GetSize()>0){ if(dwDeleteOptions){ if(AfxMessageBox(Format("%s. %s: %i\n%s?",_l("Search for duplicated images: finished"),_l("Image(s) found"),sListOfImagesToDelete.GetSize(),_l("Do you really want to delete image(s)")),MB_YESNO|MB_ICONQUESTION)==IDYES){ for(int i=0;i<sListOfImagesToDelete.GetSize();i++){ char szPath[MAX_PATH+2]=""; memset(&szPath,0,sizeof(szPath)); strcpy(szPath,sListOfImagesToDelete[i]); if(isFileExist(szPath)){ SHFILEOPSTRUCT str; memset(&str,0,sizeof(str)); str.hwnd=hwndDlg; str.wFunc=FO_DELETE; str.pFrom=szPath; str.pTo=NULL; str.fFlags=FOF_ALLOWUNDO|FOF_NOCONFIRMATION|FOF_SILENT; SHFileOperation(&str); lDeletedFiles++; } } } }else{ lDeletedFiles+=sListOfImagesToDelete.GetSize(); } } if(bReplaceMode){ CString sDump; int ik=0; for(ik=0;ik<aClosestImage.GetSize();ik++){ sDump+=Format("%i -> %i, %i %s\n",ik,aClosestImage[ik],aClosestImageTaken[ik],sListOfImages[ik]); aClosestImageTaken[ik]=0; } int iCnt=0; int iJumper=-1; CStringArray aFrom; CStringArray aFromTo; while(1){ if(iJumper==-1){ // Ищем первую картинку for(ik=0;ik<aClosestImage.GetSize();ik++){ if(aClosestImageTaken[ik]==0){ iJumper=ik; break; } } } if(iJumper==-1){ // Не нашли!! break; } aClosestImageTaken[iJumper]=1;// Чтобы не циклится int iNext=aClosestImage[iJumper]; if(iNext==-1 || aClosestImageTaken[iNext]!=0){ iJumper=-1; continue; } CString sFrom=sListOfImages[iJumper]; CString sTo=Format("%s%05i_%s",GetPathPart(sFrom,1,1,0,0),iCnt+1,GetPathPart(sFrom,0,0,1,1)); aFrom.SetAtGrow(iCnt,sFrom); aFromTo.SetAtGrow(iCnt,sTo); sDump+=Format("Jumping %i -> %i\n",iJumper,iNext); iJumper=iNext; iCnt++; } SaveFile("f:\\rename.txt",sDump); for(int i=0;i<aFrom.GetSize();i++) { if(isFileExist(aFrom[i])){ SHFILEOPSTRUCT str; memset(&str,0,sizeof(str)); str.hwnd=hwndDlg; str.wFunc=FO_RENAME; char szPath[MAX_PATH+2]=""; memset(&szPath,0,sizeof(szPath)); strcpy(szPath,aFrom[i]); str.pFrom=szPath; char szPath2[MAX_PATH+2]=""; memset(&szPath2,0,sizeof(szPath2)); strcpy(szPath2,aFromTo[i]); str.pTo=szPath2; str.fFlags=FOF_NOCONFIRMATION|FOF_SILENT; SHFileOperation(&str); } } } EndDialog(hwndDlg,0); return TRUE; } if(uMsg==WM_NCDESTROY){ SetEvent(hStopEvent); } return FALSE; }
// Debugging void SharedUtil::AddTickCount( long long llTickCountAdd ) { ms_criticalSection.Lock (); ms_llTickCountAdd = llTickCountAdd; ms_criticalSection.Unlock (); }
/* * Should be used to lock access to internal injection data. * Only ne first thread that calls this function would continue * to run until InjectionLeaveCriticalSection() is called. * That thread can call InjectionEnterCriticalSection() any number * of times. */ void InjectionEnterCriticalSection() { InjectionCriticalSectionVar.Lock(); }
cLogLock::cLogLock() { g_logLock.Lock(); }
// 读方案 void ReadOptions(LPCTSTR path) { CString strBuf; gzFile f = gzopen_w(path, "rb"); if (f == NULL) goto UseDefaultOptions; // 头部 char header[2]; gzread(f, header, sizeof(header)); if (header[0] != 'T' || header[1] != 'B') { gzclose(f); goto UseDefaultOptions; } g_optionsLock.Lock(); // 违规内容 ReadRegexTexts(f, g_keywords); // 屏蔽用户 ReadRegexTexts(f, g_blackList); // 信任用户 int intBuf; gzread(f, &intBuf, sizeof(int)); // 长度 for (int i = 0; i < intBuf; i++) { ReadText(f, strBuf); g_whiteList.insert(strBuf); } // 信任内容 ReadRegexTexts(f, g_whiteContent); gzread(f, &g_scanInterval, sizeof(int)); // 扫描间隔 gzread(f, &g_banID, sizeof(BOOL)); // 封ID gzread(f, &g_banDuration, sizeof(int)); // 封禁时长 BOOL banIP; gzread(f, &banIP, sizeof(BOOL)); // 封IP gzread(f, &g_banTrigCount, sizeof(int)); // 封禁违规次数 gzread(f, &g_onlyScanTitle, sizeof(BOOL)); // 只扫描标题 gzread(f, &g_deleteInterval, sizeof(float));// 删帖间隔 gzread(f, &g_confirm, sizeof(BOOL)); // 操作前提示 gzread(f, &g_scanPageCount, sizeof(int)); // 扫描最后页数 gzread(f, &g_briefLog, sizeof(BOOL)); // 只输出删帖封号 if (gzread(f, &g_delete, sizeof(BOOL)) != sizeof(BOOL)) // 删帖 g_delete = TRUE; if (gzread(f, &g_threadCount, sizeof(int)) != sizeof(int)) // 线程数 g_threadCount = 2; ReadText(f, g_banReason); // 封禁原因 if (!ReadText(f, g_imageDir)) // 违规图片目录 g_images.clear(); else ReadImages(g_imageDir); // 违规图片 if (gzread(f, &g_SSIMThreshold, sizeof(double)) != sizeof(double)) // 阈值 g_SSIMThreshold = 2.43; // 信任主题 g_trustedThread.clear(); if (gzread(f, &intBuf, sizeof(int)) == sizeof(int)) // 长度 for (int i = 0; i < intBuf; i++) { ReadText(f, strBuf); g_trustedThread.insert(strBuf); } if (gzread(f, &g_defriend, sizeof(BOOL)) != sizeof(BOOL)) // 拉黑 g_defriend = FALSE; if (gzread(f, &g_defriendTrigCount, sizeof(int)) != sizeof(int)) // 拉黑违规次数 g_defriendTrigCount = 5; if (gzread(f, &g_autoSaveLog, sizeof(BOOL)) != sizeof(BOOL)) // 自动保存日志 g_autoSaveLog = FALSE; g_optionsLock.Unlock(); gzclose(f); return; UseDefaultOptions: g_optionsLock.Lock(); g_keywords.clear(); // 违规内容 g_blackList.clear(); // 屏蔽用户 g_whiteList.clear(); // 信任用户 g_whiteContent.clear(); // 信任内容 g_scanInterval = 5; // 扫描间隔 g_banID = FALSE; // 封ID g_banDuration = 1; // 封禁时长 g_banTrigCount = 1; // 封禁违规次数 g_onlyScanTitle = FALSE; // 只扫描标题 g_deleteInterval = 2.0f; // 删帖间隔 g_confirm = TRUE; // 操作前提示 g_scanPageCount = 1; // 扫描最后页数 g_briefLog = FALSE; // 只输出删帖封号 g_delete = TRUE; // 删帖 g_threadCount = 2; // 线程数 g_banReason = _T(""); // 封禁原因 g_imageDir = _T(""); // 违规图片目录 g_images.clear(); // 违规图片 g_SSIMThreshold = 2.43; // 阈值 g_trustedThread.clear(); // 信任主题 g_defriend = FALSE; // 拉黑 g_defriendTrigCount = 5; // 拉黑违规次数 g_autoSaveLog = FALSE; // 自动保存日志 g_optionsLock.Unlock(); }
cSockListLock::cSockListLock() { g_Lock.Lock(); }
void EHS::StaticGetAllocationStats ( SAllocationStats& outAllocationStats ) { ms_StatsCS.Lock(); outAllocationStats = ms_AllocationStats; ms_StatsCS.Unlock(); }
cGetDbLock::cGetDbLock() { g_GetDbLock.Lock(); }
void StatsNumRequestsDec( void ) { ms_StatsCS.Lock(); ms_AllocationStats.uiActiveNumRequests--; ms_StatsCS.Unlock(); }
//====================================================================================== // HandleCreatePlayerMsg() // // Handles create player system message from DPlay. //====================================================================================== void CDarkPeer::HandleCreatePlayerMsg(DPNMSG_CREATE_PLAYER* pCreatePlayer) { csReceive.Lock(); // Block packet receives while we're handling this // Translate DPlay8's create player message to DPlay4 char playerName[kMaxPlayerName] = ""; DPMSG_CREATEPLAYERORGROUP* pDP4CreatePlayer = new DPMSG_CREATEPLAYERORGROUP; // Retrieve the peer info and set the host and local DPNIDs DPN_PLAYER_INFO* pdpPlayerInfo = GetPeerInfo(pCreatePlayer->dpnidPlayer); //Log.Print("Connection from DPNID: %08x", pCreatePlayer->dpnidPlayer); if (pdpPlayerInfo) { if (pdpPlayerInfo->dwPlayerFlags == DPNPLAYER_HOST) { m_dpnidHost = pCreatePlayer->dpnidPlayer; if (Debug.IsFlagSet(DEBUG_NET)) ConPrintF("Set host DPNID to %x.", m_dpnidHost); } else if (pdpPlayerInfo->dwPlayerFlags == DPNPLAYER_LOCAL) m_dpnidLocal = pCreatePlayer->dpnidPlayer; char playerName[kMaxPlayerName]; WideToAnsi(playerName, pdpPlayerInfo->pwszName, kMaxPlayerName); // Display the connection message if this isn't the local player if (!(pdpPlayerInfo->dwPlayerFlags & DPNPLAYER_LOCAL)) { ConPrintF("%s connected.", playerName); MessageMgr::Get()->AddLineFormat(false, "%s connected.", playerName); } SAFE_DELETE_ARRAY(pdpPlayerInfo); } else ConPrintF("Failed to get peer info for DPNID %x.", pCreatePlayer->dpnidPlayer); if (g_pNetMan->AmDefaultHost() && !IsStagingMode()) { if (Client.MissionStarted()) { IPtr<IQuestData> pQuest = _AppGetAggregated(IID_IQuestData); CNetMsg_StartMission msg; msg.difficulty = pQuest->Get("Difficulty"); msg.missionID = _GetMissionData()->missNumber; Send(pCreatePlayer->dpnidPlayer, (void*)&msg, sizeof(CNetMsg_StartMission), NULL, DPNSEND_GUARANTEED | DPNSEND_NOLOOPBACK); } } if (g_Net == STATE_Client && m_bReceivedExistingPlayers || g_Net == STATE_Host) { if (pCreatePlayer->pvPlayerContext == this) { if (Debug.IsFlagSet(DEBUG_NET)) ConPrintF("Creating local host. (%x)", pCreatePlayer->dpnidPlayer); m_dpnidLocal = (pCreatePlayer->dpnidPlayer); csReceive.Unlock(); return;// DPN_OK; } // send Thief the new player notification in the form it expects from DPlay 4 ZeroMemory(pDP4CreatePlayer, sizeof(DPMSG_CREATEPLAYERORGROUP)); pDP4CreatePlayer->dwType = DPSYS_CREATEPLAYERORGROUP; pDP4CreatePlayer->dwPlayerType = DPPLAYERTYPE_PLAYER; pDP4CreatePlayer->dpId = pCreatePlayer->dpnidPlayer; NetMessage* pMsg = new NetMessage; pMsg->m_pMsgData = (BYTE*)pDP4CreatePlayer; pMsg->m_size = sizeof(DPMSG_CREATEPLAYERORGROUP); pMsg->m_dpnidSender = DPID_SYSMSG; m_DarkQueue.Push(pMsg); #ifdef _THIEFBUILD _SFX_Play_Raw(1, 0, "pickloot.wav"); #endif } csReceive.Unlock(); }