/* * Read data from a pipe. * Returns number of bytes read, or 0 if end-of-file * has been reached. */ static int Pipe_Read(struct File *file, void *buf, ulong_t numBytes) { TODO("Read from pipe"); }
bool CAttachDlg::StartAttach(HWND ahAttachWnd, DWORD anPID, DWORD anBits, AttachProcessType anType, BOOL abAltMode) { bool lbRc = false; // Тут нужно получить инфу из списка и дернуть собственно аттач wchar_t szPipe[MAX_PATH]; PROCESS_INFORMATION pi = {}; STARTUPINFO si = {sizeof(si)}; SHELLEXECUTEINFO sei = {sizeof(sei)}; CESERVER_REQ *pIn = NULL, *pOut = NULL; HANDLE hPipeTest = NULL, hProcTest = NULL; DWORD nErrCode = 0; bool lbCreate; CESERVER_CONSOLE_MAPPING_HDR srv; DWORD nWrapperWait = -1; DWORD nWrapperResult = -1; if (!ahAttachWnd || !anPID || !anBits || !anType) { MBoxAssert(ahAttachWnd && anPID && anBits && anType); goto wrap; } if (gpSetCls->isAdvLogging) { wchar_t szInfo[128]; _wsprintf(szInfo, SKIPLEN(countof(szInfo)) L"CAttachDlg::StartAttach HWND=x%08X, PID=%u, Bits%u, Type=%u, AltMode=%u", (DWORD)(DWORD_PTR)ahAttachWnd, anPID, anBits, (UINT)anType, abAltMode); gpConEmu->LogString(szInfo); } if (LoadSrvMapping(ahAttachWnd, srv)) { pIn = ExecuteNewCmd(CECMD_ATTACH2GUI, sizeof(CESERVER_REQ_HDR)); pOut = ExecuteSrvCmd(srv.nServerPID, pIn, ghWnd); if (pOut && (pOut->hdr.cbSize >= (sizeof(CESERVER_REQ_HDR)+sizeof(DWORD))) && (pOut->dwData[0] != 0)) { lbRc = true; // Успешно подцепились goto wrap; } ExecuteFreeResult(pIn); ExecuteFreeResult(pOut); } // Может быть в процессе уже есть ConEmuHk.dll? Или этот процесс вообще уже во вкладке другого ConEmu? _wsprintf(szPipe, SKIPLEN(countof(szPipe)) CEHOOKSPIPENAME, L".", anPID); hPipeTest = CreateFile(szPipe, GENERIC_READ|GENERIC_WRITE, 0, LocalSecurity(), OPEN_EXISTING, 0, NULL); if (hPipeTest && hPipeTest != INVALID_HANDLE_VALUE) { CloseHandle(hPipeTest); goto DoExecute; } wchar_t szSrv[MAX_PATH+64], szArgs[128]; wcscpy_c(szSrv, gpConEmu->ms_ConEmuBaseDir); wcscat_c(szSrv, (anBits==64) ? L"\\ConEmuC64.exe" : L"\\ConEmuC.exe"); if (abAltMode && (anType == apt_Console)) { _wsprintf(szArgs, SKIPLEN(countof(szArgs)) L" /ATTACH /CONPID=%u /GID=%u /GHWND=%08X", anPID, GetCurrentProcessId(), (DWORD)ghWnd); } else { _wsprintf(szArgs, SKIPLEN(countof(szArgs)) L" /INJECT=%u", anPID); abAltMode = FALSE; } TODO("Определить, может он уже под админом? Тогда и ConEmuC.exe под админом запускать нужно"); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; if (anType == apt_Gui) { gpConEmu->CreateGuiAttachMapping(anPID); } hProcTest = OpenProcess(PROCESS_CREATE_THREAD|PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ, FALSE, anPID); if (hProcTest == NULL) { nErrCode = GetLastError(); MBoxAssert(hProcTest!=NULL || nErrCode==ERROR_ACCESS_DENIED); sei.hwnd = ghWnd; sei.fMask = (abAltMode ? 0 : SEE_MASK_NO_CONSOLE)|SEE_MASK_NOCLOSEPROCESS|SEE_MASK_NOASYNC; sei.lpVerb = L"runas"; sei.lpFile = szSrv; sei.lpParameters = szArgs; sei.lpDirectory = gpConEmu->ms_ConEmuBaseDir; sei.nShow = SW_SHOWMINIMIZED; lbCreate = ShellExecuteEx(&sei); if (lbCreate) { MBoxAssert(sei.hProcess!=NULL); pi.hProcess = sei.hProcess; } } else { DWORD dwFlags = 0 | (abAltMode ? CREATE_NO_WINDOW : CREATE_NEW_CONSOLE) | CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS; lbCreate = CreateProcess(szSrv, szArgs, NULL, NULL, FALSE, dwFlags, NULL, NULL, &si, &pi); } if (!lbCreate) { wchar_t szErrMsg[MAX_PATH+255], szTitle[128]; DWORD dwErr = GetLastError(); _wsprintf(szErrMsg, SKIPLEN(countof(szErrMsg)) L"Can't start %s server\n%s %s", abAltMode ? L"injection" : L"console", szSrv, szArgs); _wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmu Attach, PID=%u, TID=%u", GetCurrentProcessId(), GetCurrentThreadId()); DisplayLastError(szErrMsg, dwErr, 0, szTitle); goto wrap; } if (abAltMode) { TODO("Подождать бы завершения процесса, или пока он подцепится к GUI"); lbRc = true; goto wrap; } nWrapperWait = WaitForSingleObject(pi.hProcess, INFINITE); nWrapperResult = -1; GetExitCodeProcess(pi.hProcess, &nWrapperResult); CloseHandle(pi.hProcess); if (pi.hThread) CloseHandle(pi.hThread); if (((int)nWrapperResult != CERR_HOOKS_WAS_SET) && ((int)nWrapperResult != CERR_HOOKS_WAS_ALREADY_SET)) { goto wrap; } DoExecute: // Теперь можно дернуть созданный в удаленном процессе пайп для запуска в той консоли сервера. pIn = ExecuteNewCmd(CECMD_STARTSERVER, sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_START)); pIn->NewServer.nGuiPID = GetCurrentProcessId(); pIn->NewServer.hGuiWnd = ghWnd; if (anType == apt_Gui) { _ASSERTE(ahAttachWnd && IsWindow(ahAttachWnd)); pIn->NewServer.hAppWnd = ahAttachWnd; } pOut = ExecuteCmd(szPipe, pIn, 500, ghWnd); if (!pOut || (pOut->hdr.cbSize < pIn->hdr.cbSize) || (pOut->dwData[0] == 0)) { _ASSERTE(pOut && pOut->hdr.cbSize == (sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_START))); wchar_t szMsg[255], szTitle[128]; wcscpy_c(szMsg, L"Failed to start console server in the remote process"); if (hPipeTest && hPipeTest != INVALID_HANDLE_VALUE) wcscat_c(szMsg, L"\nHooks already was set"); _wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmu Attach, PID=%u, TID=%u", GetCurrentProcessId(), GetCurrentThreadId()); DisplayLastError(szMsg, (pOut && (pOut->hdr.cbSize >= pIn->hdr.cbSize)) ? pOut->dwData[1] : -1, 0, szTitle); goto wrap; } lbRc = true; wrap: UNREFERENCED_PARAMETER(nErrCode); UNREFERENCED_PARAMETER(nWrapperWait); ExecuteFreeResult(pIn); ExecuteFreeResult(pOut); return lbRc; }
DimensionedValue::DimensionedValue() : DimensionedValue(0) { TODO("AR: rather create an invalid value?"); }
// Проверка окна переднего плана. Если оно принадлежит к хукаемым процесса - вставить хук. // ДИАЛОГИ НЕ ПРОВЕРЯЮТСЯ bool CDefaultTerminal::CheckForeground(HWND hFore, DWORD nForePID, bool bRunInThread /*= true*/) { if (!isDefaultTerminalAllowed()) return false; bool lbRc = false; bool lbLocked = false; DWORD nResult = 0; wchar_t szClass[MAX_PATH]; szClass[0] = 0; PROCESSENTRY32 prc; bool bMonitored = false; const wchar_t* pszMonitored = NULL; HANDLE hProcess = NULL; int nBits = 0; wchar_t szCmdLine[MAX_PATH*3]; wchar_t szName[64]; PROCESS_INFORMATION pi = {}; STARTUPINFO si = {sizeof(si)}; BOOL bStarted = FALSE; // Если главное окно еще не создано if (!mb_ReadyToHook) { // Сразу выходим goto wrap; } //_ASSERTE(gpConEmu->isMainThread()); if (!hFore || !nForePID) { _ASSERTE(hFore && nForePID); goto wrap; } if (hFore == mh_LastWnd || hFore == mh_LastIgnoredWnd) { // Это окно уже проверялось lbRc = (hFore == mh_LastWnd); goto wrap; } if (bRunInThread && (hFore == mh_LastCall)) { // Просто выйти. Это проверка на частые фоновые вызовы. goto wrap; } mh_LastCall = hFore; if (bRunInThread) { if (gpConEmu->isMainThread()) { // Clear finished threads ClearThreads(false); } HANDLE hPostThread = NULL; DWORD nThreadId = 0; ThreadArg* pArg = (ThreadArg*)malloc(sizeof(ThreadArg)); if (!pArg) { _ASSERTE(pArg); goto wrap; } pArg->pTerm = this; pArg->hFore = hFore; pArg->nForePID = nForePID; hPostThread = CreateThread(NULL, 0, PostCheckThread, pArg, 0, &nThreadId); _ASSERTE(hPostThread!=NULL); if (hPostThread) { m_Threads.push_back(hPostThread); } lbRc = (hPostThread != NULL); // вернуть OK? goto wrap; } EnterCriticalSection(&mcs); lbLocked = true; // Clear dead processes and windows ClearProcessed(false); // Check window class if (GetClassName(hFore, szClass, countof(szClass))) { if ((lstrcmp(szClass, VirtualConsoleClass) == 0) //|| (lstrcmp(szClass, L"#32770") == 0) // Ignore dialogs // -- Process dialogs too (Application may be dialog-based) || isConsoleClass(szClass)) { mh_LastIgnoredWnd = hFore; goto wrap; } } // Go and check if (!GetProcessInfo(nForePID, &prc)) { mh_LastIgnoredWnd = hFore; goto wrap; } CharLowerBuff(prc.szExeFile, lstrlen(prc.szExeFile)); if (lstrcmp(prc.szExeFile, L"csrss.exe") == 0) { // This is "System" process and may not be hooked mh_LastIgnoredWnd = hFore; goto wrap; } // Is it in monitored applications? pszMonitored = gpSet->GetDefaultTerminalAppsMSZ(); if (pszMonitored) { // All strings are lower case const wchar_t* psz = pszMonitored; while (*psz) { if (_tcscmp(psz, prc.szExeFile) == 0) { bMonitored = true; break; } psz += _tcslen(psz)+1; } } // And how it is? if (!bMonitored) { mh_LastIgnoredWnd = hFore; goto wrap; } // Need to process for (INT_PTR i = m_Processed.size(); i--;) { if (m_Processed[i].nPID == nForePID) { bMonitored = false; break; // already hooked } } // May be hooked already? if (!bMonitored) { mh_LastWnd = hFore; lbRc = true; goto wrap; } _ASSERTE(isDefaultTerminalAllowed()); hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|SYNCHRONIZE, FALSE, nForePID); if (!hProcess) { // Failed to hook mh_LastIgnoredWnd = hFore; goto wrap; } // Need to be hooked nBits = GetProcessBits(nForePID, hProcess); switch (nBits) { case 32: _wsprintf(szCmdLine, SKIPLEN(countof(szCmdLine)) L"\"%s\\%s\" /DEFTRM=%u", gpConEmu->ms_ConEmuBaseDir, L"ConEmuC.exe", nForePID); break; case 64: _wsprintf(szCmdLine, SKIPLEN(countof(szCmdLine)) L"\"%s\\%s\" /DEFTRM=%u", gpConEmu->ms_ConEmuBaseDir, L"ConEmuC64.exe", nForePID); break; } if (!*szCmdLine) { // Unsupported bitness? CloseHandle(hProcess); mh_LastIgnoredWnd = hFore; goto wrap; } // Prepare event _wsprintf(szName, SKIPLEN(countof(szName)) CEDEFAULTTERMHOOK, nForePID); SafeCloseHandle(mh_SignEvent); mh_SignEvent = CreateEvent(LocalSecurity(), FALSE, FALSE, szName); if (mh_SignEvent) SetEvent(mh_SignEvent); // May be excess, but if event already exists... // Run hooker si.dwFlags = STARTF_USESHOWWINDOW; bStarted = CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); if (!bStarted) { DisplayLastError(L"Failed to start hooking application!\nDefault terminal feature will not be available!"); CloseHandle(hProcess); mh_LastIgnoredWnd = hFore; goto wrap; } CloseHandle(pi.hThread); // Waiting for result TODO("Show status in status line?"); WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, &nResult); CloseHandle(pi.hProcess); // And what? if (nResult == (UINT)CERR_HOOKS_WAS_SET) { mh_LastWnd = hFore; ProcessInfo inf = {}; inf.hProcess = hProcess; hProcess = NULL; // его закрывать НЕ нужно, сохранен в массиве inf.nPID = nForePID; inf.nHookTick = GetTickCount(); m_Processed.push_back(inf); lbRc = true; goto wrap; } // Failed, remember this CloseHandle(hProcess); mh_LastIgnoredWnd = hFore; _ASSERTE(lbRc == false); wrap: if (lbLocked) { LeaveCriticalSection(&mcs); } return lbRc; }
/*ARGSUSED*/ int dtrace_getstackdepth(int aframes) { # if 1 TODO(); return 0; # else struct frame *fp = (struct frame *)dtrace_getfp(); struct frame *nextfp, *minfp, *stacktop; int depth = 0; int is_intr = 0; int on_intr; uintptr_t pc; if ((on_intr = CPU_ON_INTR(CPU)) != 0) stacktop = (struct frame *)(CPU->cpu_intr_stack + SA(MINFRAME)); else stacktop = (struct frame *)curthread->t_stk; minfp = fp; aframes++; for (;;) { depth++; if (is_intr) { struct regs *rp = (struct regs *)fp; nextfp = (struct frame *)rp->r_fp; pc = rp->r_pc; } else { nextfp = (struct frame *)fp->fr_savfp; pc = fp->fr_savpc; } if (nextfp <= minfp || nextfp >= stacktop) { if (on_intr) { /* * Hop from interrupt stack to thread stack. */ stacktop = (struct frame *)curthread->t_stk; minfp = (struct frame *)curthread->t_stkbase; on_intr = 0; continue; } break; } is_intr = pc - (uintptr_t)_interrupt < _interrupt_size || pc - (uintptr_t)_allsyscalls < _allsyscalls_size || pc - (uintptr_t)_cmntrap < _cmntrap_size; fp = nextfp; minfp = fp; } if (depth <= aframes) return (0); return (depth - aframes); # endif }
/*static*/ void V8::SetEntropySource(EntropySource source) { TODO(); }
bool SetResourceConstraints(ResourceConstraints *constraints) { TODO(); return false; }
void MetaDataStore::add_directories(const FrontendPath& path) { LOG_TRACE(path); FrontendPath p; for (const auto& s : path) { p = FrontendPath(p / s); DirectoryEntryPtr dentry(find(p)); while (true) { if (dentry == nullptr) { DirectoryEntryPtr dentry(boost::make_shared<DirectoryEntry>(DirectoryEntry::Type::Directory, alloc_inode(), default_directory_permissions, UserId(::getuid()), GroupId(::getgid()))); try { struct timespec timebuf; struct timeval tv; TODO("X42: Better use fungi::IOException here? WIP"); int rc = clock_gettime(CLOCK_REALTIME, &timebuf); if (rc != 0) { throw std::system_error(errno, std::system_category()); } add(p, dentry); tv.tv_sec = timebuf.tv_sec; tv.tv_usec = timebuf.tv_nsec / 1000; utimes(FrontendPath(p.parent_path()), tv, tv); break; } catch (FileExistsException&) { LOG_WARN(p << ": someone else created an eponymous entry at the same time"); } } else { if (dentry->type() != DirectoryEntry::Type::Directory) { LOG_ERROR(p << " already exists but is not a directory"); throw fungi::IOException("Entry is not a directory", p.string().c_str(), ENOTDIR); } break; } } } }
/*ARGSUSED*/ static void fbt_provide_module(void *arg, struct modctl *ctl) { int i; struct module *mp = (struct module *) ctl; char *modname = mp->name; char *str = mp->strtab; char *name; par_module_t *pmp; int ret; # if 0 struct module *mp = ctl->mod_mp; char *str = mp->strings; int nsyms = mp->nsyms; Shdr *symhdr = mp->symhdr; char *name; size_t symsize; /* * Employees of dtrace and their families are ineligible. Void * where prohibited. */ if (strcmp(modname, "dtrace") == 0) return; TODO(); if (ctl->mod_requisites != NULL) { struct modctl_list *list; list = (struct modctl_list *)ctl->mod_requisites; for (; list != NULL; list = list->modl_next) { if (strcmp(list->modl_modp->mod_modname, "dtrace") == 0) return; } } TODO(); /* * KMDB is ineligible for instrumentation -- it may execute in * any context, including probe context. */ if (strcmp(modname, "kmdbmod") == 0) return; if (str == NULL || symhdr == NULL || symhdr->sh_addr == NULL) { /* * If this module doesn't (yet) have its string or symbol * table allocated, clear out. */ return; } symsize = symhdr->sh_entsize; # endif int init; if (strcmp(modname, "dtracedrv") == 0) return; /***********************************************/ /* Possible memleak here...we allocate a */ /* parallel struct, but need to free if we */ /* are offloaded. */ /***********************************************/ pmp = par_alloc(PARD_FBT, mp, sizeof *pmp, &init); if (pmp == NULL || pmp->fbt_nentries) { /* * This module has some FBT entries allocated; we're afraid * to screw with it. */ return; } if (dtrace_here) printk("%s(%d):modname=%s num_symtab=%u\n", dtrace_basename(__FILE__), __LINE__, modname, (unsigned) mp->num_symtab); for (i = 1; i < mp->num_symtab; i++) { uint8_t *instr, *limit; Elf_Sym *sym = (Elf_Sym *) &mp->symtab[i]; int dtrace_here = 0; if (strcmp(modname, "dummy") == 0) dtrace_here = 1; name = str + sym->st_name; if (sym->st_name == NULL || *name == '\0') continue; /***********************************************/ /* Linux re-encodes the symbol types. */ /***********************************************/ if (sym->st_info != 't' && sym->st_info != 'T') continue; // if (strstr(name, "init")) // continue; //if (sym->st_info != 'T') {printk("skip -- %02d %c:%s\n", i, sym->st_info, name); continue;} #if 0 if (ELF_ST_TYPE(sym->st_info) != STT_FUNC) continue; /* * Weak symbols are not candidates. This could be made to * work (where weak functions and their underlying function * appear as two disjoint probes), but it's not simple. */ if (ELF_ST_BIND(sym->st_info) == STB_WEAK) continue; #endif if (strstr(name, "dtrace_") == name && strstr(name, "dtrace_safe_") != name) { /* * Anything beginning with "dtrace_" may be called * from probe context unless it explitly indicates * that it won't be called from probe context by * using the prefix "dtrace_safe_". */ continue; } if (strstr(name, "dtracedrv_") == name) continue; if (strstr(name, "kdi_") == name || strstr(name, "kprobe") == name) { /* * Anything beginning with "kdi_" is a part of the * kernel debugger interface and may be called in * arbitrary context -- including probe context. */ continue; } /* * Due to 4524008, _init and _fini may have a bloated st_size. * While this bug was fixed quite some time ago, old drivers * may be lurking. We need to develop a better solution to * this problem, such that correct _init and _fini functions * (the vast majority) may be correctly traced. One solution * may be to scan through the entire symbol table to see if * any symbol overlaps with _init. If none does, set a bit in * the module structure that this module has correct _init and * _fini sizes. This will cause some pain the first time a * module is scanned, but at least it would be O(N) instead of * O(N log N)... */ if (strcmp(name, "_init") == 0) continue; if (strcmp(name, "_fini") == 0) continue; /* * In order to be eligible, the function must begin with the * following sequence: * * pushl %esp * movl %esp, %ebp * * Note that there are two variants of encodings that generate * the movl; we must check for both. For 64-bit, we would * normally insist that a function begin with the following * sequence: * * pushq %rbp * movq %rsp, %rbp * * However, the compiler for 64-bit often splits these two * instructions -- and the first instruction in the function * is often not the pushq. As a result, on 64-bit we look * for any "pushq %rbp" in the function and we instrument * this with a breakpoint instruction. */ instr = (uint8_t *)sym->st_value; limit = (uint8_t *)(sym->st_value + sym->st_size); //printk("trying -- %02d %c:%s\n", i, sym->st_info, name); //HERE(); /***********************************************/ /* If we were called because a module is */ /* loaded after dtrace, then mp contains */ /* references to the .init section. We want */ /* to ignore these because the pages where */ /* the code resides will go away. Not only */ /* dont we want to put probes on */ /* non-existant pages, but /proc/dtrace/fbt */ /* will have problems and, fbt_enable will */ /* if that page is now used by some other */ /* driver. */ /***********************************************/ if (mp->module_init && mp->init_size && instr >= (uint8_t *) mp->module_init && instr < (uint8_t *) mp->module_init + mp->init_size) { continue; } /***********************************************/ /* We do have syms that appear to point to */ /* unmapped pages. Maybe these are freed */ /* pages after a driver loads. Double check */ /* - if /proc/kallsyms says its not there, */ /* then ignore it. */ /***********************************************/ if (!validate_ptr(instr)) continue; /***********************************************/ /* Look at the section this symbol is in - */ /* we dont want sections which can */ /* disappear or have disappeared (eg */ /* .init). */ /* */ /* I'm not sure I follow this code for all */ /* kernel releases - if we have the field, */ /* it should have a fixed meaning, but some */ /* modules have bogus section attributes */ /* pointers (maybe pointers to freed */ /* segments?). Lets be careful out there. */ /* */ /* 20090425 Ok - heres the deal. In 2.6.9 */ /* (at least) the section table is */ /* allocated but only for sections which */ /* are SHF_ALLOC. This means the array of */ /* sections cannot be indexed by */ /* sym->st_shndx since the mappings are now */ /* bogus (kernel doesnt adjust the symbol */ /* section indexes). What we need to do is */ /* attempt to find the section by address. */ /***********************************************/ ret = instr_in_text_seg(mp, name, sym); if (!ret) continue; /***********************************************/ /* We are good to go... */ /***********************************************/ fbt_provide_function(mp, pmp, modname, name, (uint8_t *) sym->st_value, instr, limit, i); } }
static kbool_t FuelVM_VisitTryNode(KonohaContext *kctx, KBuilder *builder, kNode *stmt, void *thunk) { //FIXME TODO(); return true; }
TextPartFlags CVConLine::isDialogBorderCoord(uint j) { //bool isDlgBorder = false, bMayBeFrame = false; TextPartFlags dlgBorder = TRF_None; if (NextDialog || (j == NextDialogX)) { NextDialog = false; CurDialogX1 = -1; NextDialogX = CurDialogX2 = TextWidth; CurDialogI = -1; CurDialogFlags = 0; int nMax = TextWidth-1; _ASSERTE((int)row >= 0 && (int)j >= 0); // Process dialogs in reverse order, to ensure tops (Z-order) dialogs would be first for (int i = mn_DialogsCount-1; i >= 0; i--) { if (mrc_Dialogs[i].Top <= (int)row && (int)row <= mrc_Dialogs[i].Bottom) { int border1 = mrc_Dialogs[i].Left; int border2 = mrc_Dialogs[i].Right; // Looking for a dialog edge, on the current row, nearest to the current X-coord (j) if ((int)j <= border1 && border1 < NextDialogX) NextDialogX = border1; else if (border2 < nMax && (int)j <= border2 && border2 < NextDialogX) NextDialogX = border2; // Looking for a dialog (not a Far Manager Panels), covering current coord // TODO: It would be nice to process Far's column separators too, but there is no nice API if (!(mn_DialogFlags[i] & (FR_LEFTPANEL|FR_RIGHTPANEL|FR_FULLPANEL|FR_VIEWEREDITOR))) { if ((border1 <= (int)j && (int)j <= border2) && (CurDialogX1 <= border1 && border2 <= CurDialogX2)) { CurDialogX1 = border1; CurDialogX2 = border2; CurDialogFlags = mn_DialogFlags[i]; _ASSERTE(CurDialogFlags!=0); CurDialogI = i; } } } } } if (j == NextDialogX) { NextDialog = true; // Is it visible dialog edge, or it's covered by other dialog? if (CurDialogFlags) { // Coord hits inside dialog space // treat right edge as frame too if ((j == CurDialogX1 || j == CurDialogX2)) dlgBorder |= TRF_PosFixed; } else { // ??? dlgBorder |= TRF_PosFixed; } } // Horizontal corrections of vertical frames: Far Manager Panels, etc. (Coord.X>0) if (!(dlgBorder & TRF_PosFixed) // if not marked as PosFixed yet... && j && isFixFrameCoord) { wchar_t c = ConCharLine[j]; // Already marked as dialog VBorder? if ((ConAttrLine[j].Flags & CharAttr_DialogVBorder) // Frames (vertical parts, pseudographics) || isCharBorderVertical(c) // Far Manager Panel scrollers || isCharScroll(c) // Far marks with '}' symbols file names, gone out of column width (too long name) // TODO: Take into account other rows? Or even Far Panels Mode? // TODO: we can't just check upper and lower rows to compare for frame/}, because // TODO: they may be covered with another dialog... || (isFilePanel && c==L'}') //TODO: vim/emacs/tmux/etc uses simple `|` as pane delimiter ) { dlgBorder |= TRF_PosRecommended; #if 0 // Пройти вверх и вниз от текущей строки, проверив, // есть ли в этой же X-координате вертикальная рамка (или угол) TODO("Хорошо бы для панелей определять границы колонок более корректно, лучше всего - через API?"); //if (!bBord && !bFrame) if (!isDlgBorder) { int R; wchar_t prevC; bool bBord = false; for (R = (row-1); bMayBeFrame && !bBord && R>=0; R--) { prevC = mpsz_ConChar[R*TextWidth+j]; bBord = isCharBorderVertical(prevC); bMayBeFrame = (bBord || isCharScroll(prevC) || (isFilePanel && prevC==L'}')); } for (R = (row+1); bMayBeFrame && !bBord && R < (int)TextHeight; R++) { prevC = mpsz_ConChar[R*TextWidth+j]; bBord = isCharBorderVertical(prevC); bMayBeFrame = (bBord || isCharScroll(prevC) || (isFilePanel && prevC==L'}')); } } // Это разделитель колонок панели, полоса прокрутки или явно найденная граница диалога if (bMayBeFrame) ConCharXLine[j-1] = j * nFontWidth; #endif } } return dlgBorder; }
/* * Clone a pipe. */ static int Pipe_Clone(struct File *file, struct File **pClone) { TODO("Clone a pipe"); }
/* * Close pipe. */ static int Pipe_Close(struct File *file) { TODO("Close a pipe"); }
/* * Write data to pipe. * Returns number of bytes written. */ static int Pipe_Write(struct File *file, void *buf, ulong_t numBytes) { TODO("Write to pipe"); }
pracAOC::pracAOC(int argc, char ** argv): QWidget() { mainWin=new QMainForm(); mainWin->setupUi(this); path= new QString (argv[0]); path->chop(7); ctable.resize(256); for(int i=0; i < 256; i++) ctable[i] = qRgb(i,i,i); imgO=new uchar[320*100]; // matriz de imagen origen imgM=new uchar[320*100]; // se usa solo para mostrar datos imgD=new uchar[320*100]; // matriz de imagen destino de los procesos for (int i=0; i<7;i++) imgdigit[i]=new uchar[32*55]; //grupo de siete matrices para matching final qimgOrig = new QImage(imgO,320, 100, QImage::Format_Indexed8); qimgOrig->setColorTable(ctable); qimgOrig->setNumColors(256); qimgDest = new QImage(imgM,320, 100, QImage::Format_Indexed8); qimgDest->setColorTable(ctable); qimgDest->setNumColors(256); for (int i=0; i<7; i++){ qimgDigit[i] = new QImage(imgdigit[i],32, 55, QImage::Format_Indexed8); qimgDigit[i]->setColorTable(ctable); qimgDigit[i]->setNumColors(256); } for (int i=0; i<320;i++) Vhor[i]=0; //guarda al integral proyectiva de cada columna Hmin=0; //almacena la fila inferior y superior donde se encuentra los caracteres Hmax=0; for (int j=0; j<7;j++) for(int i=0; i<32*55;i++) imgdigit[j][i]=0; for(int i=0; i<320*100;i++) { imgO[i]=0; imgM[i]=0; imgD[i]=0; } init_digit(); v=0; connect ( mainWin->pushButtonCargar, SIGNAL (clicked()), this, SLOT( cargar() ) ); connect ( mainWin->pushButtonCopiarO, SIGNAL (clicked()), this, SLOT( copiarOrigen() ) ); connect ( mainWin->pushButtonCopiarD, SIGNAL (clicked()), this, SLOT( copiarDestino() ) ); connect ( mainWin->pushButtonBorrar, SIGNAL (clicked()), this, SLOT( borrar() ) ); connect ( mainWin->pushButtonNegar, SIGNAL (clicked()), this, SLOT( negar() ) ); connect ( mainWin->pushButtonUmbralizar, SIGNAL (clicked()), this, SLOT( umbralizar() ) ); connect ( mainWin->pushButtonDetectarV, SIGNAL (clicked()), this, SLOT( detectarv() ) ); connect ( mainWin->pushButtonDetectarH, SIGNAL (clicked()), this, SLOT( detectarh() ) ); connect ( mainWin->pushButtonRecortar, SIGNAL (clicked()), this, SLOT( recortar() ) ); connect ( mainWin->pushButtonMatching, SIGNAL (clicked()), this, SLOT( matching() ) ); connect ( mainWin->pushButtonTodo, SIGNAL (clicked()), this, SLOT( TODO() ) ); connect ( mainWin->pushButtonSalir, SIGNAL (clicked()), this, SLOT( close() ) ); }
/*ARGSUSED*/ static void fbt_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc) { fbt_probe_t *fbt = parg; struct modctl *ctl = fbt->fbtp_ctl; struct module *mp = (struct module *) ctl; ctf_file_t *fp = NULL; ctf_funcinfo_t f; // int error; ctf_id_t argv[32], type; int argc = sizeof (argv) / sizeof (ctf_id_t); // const char *parent; if (mp->state != MODULE_STATE_LIVE || get_refcount(mp) != fbt->fbtp_loadcnt) return; if (fbt->fbtp_roffset != 0 && desc->dtargd_ndx == 0) { (void) strcpy(desc->dtargd_native, "int"); return; } # if 0 if ((fp = ctf_modopen(mp, &error)) == NULL) { /* * We have no CTF information for this module -- and therefore * no args[] information. */ goto err; } # endif //TODO(); if (fp == NULL) goto err; # if 0 /* * If we have a parent container, we must manually import it. */ if ((parent = ctf_parent_name(fp)) != NULL) { ctf_file_t *pfp; TODO(); struct modctl *mod; /* * We must iterate over all modules to find the module that * is our parent. */ for (mod = &modules; mod != NULL; mod = mod->mod_next) { if (strcmp(mod->mod_filename, parent) == 0) break; } if (mod == NULL) goto err; if ((pfp = ctf_modopen(mod->mod_mp, &error)) == NULL) goto err; if (ctf_import(fp, pfp) != 0) { ctf_close(pfp); goto err; } ctf_close(pfp); } # endif if (ctf_func_info(fp, fbt->fbtp_symndx, &f) == CTF_ERR) goto err; if (fbt->fbtp_roffset != 0) { if (desc->dtargd_ndx > 1) goto err; ASSERT(desc->dtargd_ndx == 1); type = f.ctc_return; } else { if (desc->dtargd_ndx + 1 > f.ctc_argc) goto err; if (ctf_func_args(fp, fbt->fbtp_symndx, argc, argv) == CTF_ERR) goto err; type = argv[desc->dtargd_ndx]; } if (ctf_type_name(fp, type, desc->dtargd_native, DTRACE_ARGTYPELEN) != NULL) { ctf_close(fp); return; } err: if (fp != NULL) ctf_close(fp); desc->dtargd_ndx = DTRACE_ARGNONE; }
/*static*/ void V8::AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type_filter) { TODO(); }
bool CPluginW1900::UpdateConEmuTabsApi(int windowCount) { if (!InfoW1900 || !InfoW1900->AdvControl || gbIgnoreUpdateTabs) return false; bool lbCh = false, lbDummy = false; WindowInfo WInfo = {sizeof(WindowInfo)}; wchar_t szWNameBuffer[CONEMUTABMAX]; int tabCount = 0; bool lbActiveFound = false; _ASSERTE(GetCurrentThreadId() == gnMainThreadId); WindowInfo WActive = {sizeof(WActive)}; WActive.Pos = -1; bool bActiveInfo = InfoW1900->AdvControl(&guid_ConEmu, ACTL_GETWINDOWINFO, 0, &WActive)!=0; // Если фар запущен с ключом "/e" (как standalone редактор) - будет ассерт при первой попытке // считать информацию об окне (редактор еще не создан?, а панелей вообще нет) _ASSERTE(bActiveInfo && (WActive.Flags & WIF_CURRENT)); static WindowInfo WLastActive; // Проверить, есть ли активный редактор/вьювер/панель if (bActiveInfo && (WActive.Type == WTYPE_EDITOR || WActive.Type == WTYPE_VIEWER || WActive.Type == WTYPE_PANELS)) { if (!(WActive.Flags & WIF_MODAL)) WLastActive = WActive; } else { int nTabs = 0, nModalTabs = 0; bool bFound = false; WindowInfo WModal, WFirst; // Поскольку в табах диалоги не отображаются - надо подменить "активное" окно // т.е. предпочитаем тот таб, который был активен ранее for (int i = 0; i < windowCount; i++) { WInfo.Pos = i; if (InfoW1900->AdvControl(&guid_ConEmu, ACTL_GETWINDOWINFO, 0, &WInfo) && (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER || WInfo.Type == WTYPE_PANELS)) { if (!nTabs) WFirst = WInfo; nTabs++; if (WInfo.Flags & WIF_MODAL) { nModalTabs++; WModal = WInfo; } if (WLastActive.StructSize && (WInfo.Type == WLastActive.Type) && (WInfo.Id == WLastActive.Id)) { bActiveInfo = bFound = true; WActive = WInfo; } } } if (!bFound) { if (nModalTabs) { bActiveInfo = true; WActive = WModal; } else if (nTabs) { bActiveInfo = true; WActive = WFirst; } } } for (int i = 0; i < windowCount; i++) { WInfo.Pos = i; InfoW1900->AdvControl(&guid_ConEmu, ACTL_GETWINDOWINFO, 0, &WInfo); if (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER || WInfo.Type == WTYPE_PANELS) { WInfo.Pos = i; WInfo.Name = szWNameBuffer; WInfo.NameSize = CONEMUTABMAX; InfoW1900->AdvControl(&guid_ConEmu, ACTL_GETWINDOWINFO, 0, &WInfo); WARNING("Для получения имени нужно пользовать ECTL_GETFILENAME"); //// Проверить, чего там... //_ASSERTE((WInfo.Flags & WIF_MODAL) == 0); if (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER || WInfo.Type == WTYPE_PANELS) { if ((WInfo.Flags & WIF_CURRENT)) { lbActiveFound = true; } else if (bActiveInfo && (WInfo.Type == WActive.Type) && (WInfo.Id == WActive.Id)) { WInfo.Flags |= WIF_CURRENT; lbActiveFound = true; } TODO("Определение ИД редактора/вьювера"); lbCh |= AddTab(tabCount, -1, false/*losingFocus*/, false/*editorSave*/, WInfo.Type, WInfo.Name, /*editorSave ? ei.FileName :*/ NULL, (WInfo.Flags & WIF_CURRENT), (WInfo.Flags & WIF_MODIFIED), (WInfo.Flags & WIF_MODAL), 0/*WInfo.Id?*/); } } } // Скорее всего это модальный редактор (или вьювер?) if (!lbActiveFound) { _ASSERTE("Active window must be detected already!" && 0); WInfo.Pos = -1; _ASSERTE(GetCurrentThreadId() == gnMainThreadId); if (InfoW1900->AdvControl(&guid_ConEmu, ACTL_GETWINDOWINFO, 0, &WInfo)) { // Проверить, чего там... _ASSERTE((WInfo.Flags & WIF_MODAL) == 0); if (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER) { WInfo.Pos = -1; WInfo.Name = szWNameBuffer; WInfo.NameSize = CONEMUTABMAX; InfoW1900->AdvControl(&guid_ConEmu, ACTL_GETWINDOWINFO, 0, &WInfo); if (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER) { tabCount = 0; TODO("Определение ИД Редактора/вьювера"); lbCh |= AddTab(tabCount, -1, false/*losingFocus*/, false/*editorSave*/, WInfo.Type, WInfo.Name, /*editorSave ? ei.FileName :*/ NULL, (WInfo.Flags & WIF_CURRENT), (WInfo.Flags & WIF_MODIFIED), 1/*Modal*/, 0); } } else if (WInfo.Type == WTYPE_PANELS) { gpTabs->Tabs.CurrentType = gnCurrentWindowType = WInfo.Type; } } } // 101224 - сразу запомнить количество! gpTabs->Tabs.nTabCount = tabCount; return lbCh; }
/*static*/ void V8::GetHeapStatistics(HeapStatistics *heap_statistics) { TODO(); }
bool CMatch::FindRangeStart(int& crFrom/*[In/Out]*/, int& crTo/*[In/Out]*/, bool& bUrlMode, LPCWSTR pszBreak, LPCWSTR pszUrlDelim, LPCWSTR pszSpacing, LPCWSTR pszUrl, LPCWSTR pszProtocol, LPCWSTR pChar, int nLen) { bool lbRc = false; // Курсор над скобкой "(3): ..." из текста "abc.py (3): ..." //if ((crFrom > 2) && wcschr(L"([", pChar[crFrom]) && wcschr(pszSpacing, pChar[crFrom-1]) && !wcschr(pszSpacing, pChar[crFrom-2])) // crFrom--; int iAlphas = 0; // Курсор над комментарием? // Попробуем найти начало имени файла // 131026 Allows '?', otherwise links like http://go.com/fwlink/?LinkID=1 may fail while ((crFrom > 0) && ((pChar[crFrom-1]==L'?') || !wcschr(bUrlMode ? pszUrlDelim : pszBreak, pChar[crFrom-1]))) { // Check this before pszSpacing comparison because otherwise we'll fail on smth like // Bla-bla-bla C:\your-file.txt // if the mouse was over "C:\" if (isAlpha(pChar[crFrom])) { iAlphas++; } if (iAlphas > 0) { TODO("Если вводить поддержку powershell 'Script.ps1:35 знак:23' нужно будет не прерываться перед национальными словами 'знак'"); // Disallow leading spaces if (wcschr(pszSpacing, pChar[crFrom-1])) break; } if (!bUrlMode && pChar[crFrom] == L'/') { if ((crFrom >= 2) && ((crFrom + 1) < nLen) && ((pChar[crFrom+1] == L'/') && (pChar[crFrom-1] == L':') && wcschr(pszUrl, pChar[crFrom-2]))) // как минимум одна буква на протокол { crFrom++; } if ((crFrom >= 3) && ((pChar[crFrom-1] == L'/') // как минимум одна буква на протокол && (((pChar[crFrom-2] == L':') && wcschr(pszUrl, pChar[crFrom-3])) // http://www.ya.ru || ((crFrom >= 4) && (pChar[crFrom-2] == L'/') && (pChar[crFrom-3] == L':') && wcschr(pszUrl, pChar[crFrom-4])) // file:///c:\file.html )) ) { bUrlMode = true; crTo = crFrom-2; crFrom -= 3; while ((crFrom > 0) && wcschr(pszProtocol, pChar[crFrom-1])) crFrom--; break; } else if ((pChar[crFrom] == L'/') && (crFrom >= 1) && (pChar[crFrom-1] == L'/')) { crFrom++; break; // Комментарий в строке? } } crFrom--; if (pChar[crFrom] == L':') { if (pChar[crFrom+1] == L' ') { // ASM - подсвечивать нужно "test.asasm(1,1)" // [email protected](1239): test.asasm(1,1): crFrom += 2; break; } else if (bUrlMode && pChar[crFrom+1] != L'\\' && pChar[crFrom+1] != L'/') { goto wrap; // Не оно } } } while (((crFrom+1) < nLen) && wcschr(pszSpacing, pChar[crFrom])) crFrom++; if (crFrom > crTo) { goto wrap; // Fail? } lbRc = true; wrap: return lbRc; }
void Compiler::ParseToByNumberDo(int toPointer, Oop oopNumber, bool bNegativeStep) { PushOptimizedScope(); // Add an "each". This should be at the top of the temporary stack as it is taken over by the do: block TempVarRef* pEachTempRef = AddOptimizedTemp(eachTempName); // Start to generate bytecodes // First we must store that from value into our 'each' counter variable/argument. This involves // stepping back a bit ... _ASSERTE(toPointer < m_codePointer); int currentPos = m_codePointer; m_codePointer = toPointer; // Note we store so leaving the value on the stack as the result of the whole expression GenStoreTemp(pEachTempRef); m_codePointer = currentPos + m_bytecodes[toPointer].instructionLength(); // Dup the to: value GenDup(); // And push the from value GenPushTemp(pEachTempRef); // We must jump over the block to the test first time through int jumpOver = GenJumpInstruction(LongJump); int loopHead = m_codePointer; // Parse the one argument block. // Leave nothing on the stack, expect 1 argument ParseOptimizeBlock(1); // Pop off the result of the optimized block GenPopStack(); GenDup(); GenPushTemp(pEachTempRef); // If the step is 1/-1, this will be optimised down to Increment/Decrement GenNumber(oopNumber, LastTokenRange()); int add = GenInstruction(SendArithmeticAdd); int store = GenStoreTemp(pEachTempRef); int comparePointer = m_codePointer; if (bNegativeStep) GenInstruction(SendArithmeticGT); else // Note that < is the best message to send, since it is normally directly implemented GenInstruction(SendArithmeticLT); GenJump(LongJumpIfFalse, loopHead); // Pop the to: value GenPopStack(); SetJumpTarget(jumpOver, comparePointer); TODO("Is this in the right place? What is the last real IP of the loop"); PopOptimizedScope(ThisTokenRange().m_stop); NextToken(); }
bool CMatch::MatchWord(LPCWSTR asLine/*This may be NOT 0-terminated*/, int anLineLen/*Length of buffer*/, int anFrom/*Cursor pos*/, int& rnStart, int& rnEnd, CRConDataGuard& data, int nFromLine) { rnStart = rnEnd = anFrom; TODO("Проверить на ошибки после добавления горизонтальной прокрутки"); if (!asLine || !*asLine || (anFrom < 0) || (anLineLen <= anFrom)) return false; TODO("Setting to define word-break characters (was gh-328 issue)"); struct cmp { static bool isChar(ucs32 inChar) { return (isCharSpace(inChar) || isCharSeparate(inChar)); } }; bool (*cmpFunc)(ucs32 inChar) = isCharNonWord; // If user double-clicks on "═════════════" - try to select this block of characters? if (isCharNonWord(asLine[rnStart])) cmpFunc = cmp::isChar; while ((rnStart > 0) && !(cmpFunc(asLine[rnStart-1]))) { rnStart--; } const wchar_t szLeftBkt[] = L"<({[", szRightBkt[] = L">)}]"; int iStopOnRghtBkt = -1; // Trim leading punctuation except of "." (accept dot-files like ".bashrc") while (((rnStart+1) < rnEnd) && (asLine[rnStart] != L'.') && isCharPunctuation(asLine[rnStart])) { if (iStopOnRghtBkt == -1) { const wchar_t* pchLeftBkt = wcschr(szLeftBkt, asLine[rnStart]); if (pchLeftBkt) { iStopOnRghtBkt = (int)(pchLeftBkt - szLeftBkt); _ASSERTE(iStopOnRghtBkt > 0 && (size_t)iStopOnRghtBkt < wcslen(szRightBkt)); } } rnStart++; } bool bStopOnBkt = false; while (((rnEnd+1) < anLineLen) && !(cmpFunc(asLine[rnEnd+1]))) { if ((iStopOnRghtBkt >= 0) && (asLine[rnEnd+1] == szRightBkt[iStopOnRghtBkt])) { bStopOnBkt = true; break; } rnEnd++; } if (!bStopOnBkt) { // Now trim trailing punctuation while (((rnEnd-1) > rnStart) && isCharPunctuation(asLine[rnEnd])) { rnEnd--; } // If part contains (leading) brackets - don't trim trailing brackets for (int i = rnStart; i <= rnEnd; i++) { if (wcschr(szLeftBkt, asLine[i])) { // Include trailing brackets while (((rnEnd+1) < anLineLen) && wcschr(szRightBkt, asLine[rnEnd+1])) { rnEnd++; } // Done break; } } } // Done StoreMatchText(NULL, NULL); return true; }
bool check(MMApi & mm, time_t now, BackEvent_t & signal) { //LOG(LOG_INFO, "================> ACL check: now=%u, signal=%u", // (unsigned)now, static_cast<unsigned>(signal)); if (signal == BACK_EVENT_STOP) { // here, mm.last_module should be false only when we are in login box mm.mod->get_event().reset(); return false; } if (mm.last_module) { // at a close box (mm.last_module is true), // we are only waiting for a stop signal // and Authentifier should not exist anymore. return true; } const uint32_t enddate = this->ini.get<cfg::context::end_date_cnx>(); if (enddate != 0 && ((uint32_t)now > enddate)) { LOG(LOG_INFO, "Session is out of allowed timeframe : closing"); const char * message = TR("session_out_time", language(this->ini)); mm.invoke_close_box(message, signal, now); return true; } // Close by rejeted message received if (!this->ini.get<cfg::context::rejected>().empty()) { this->ini.set<cfg::context::auth_error_message>(this->ini.get<cfg::context::rejected>()); LOG(LOG_INFO, "Close by Rejected message received : %s", this->ini.get<cfg::context::rejected>().c_str()); this->ini.set_acl<cfg::context::rejected>(""); mm.invoke_close_box(nullptr, signal, now); return true; } // Keep Alive if (this->keepalive.check(now, this->ini)) { mm.invoke_close_box(TR("miss_keepalive", language(this->ini)), signal, now); return true; } // Inactivity management if (this->inactivity.check(now)) { mm.invoke_close_box(TR("close_inactivity", language(this->ini)), signal, now); return true; } // Manage module (refresh or next) if (this->ini.changed_field_size()) { if (mm.connected) { // send message to acl with changed values when connected to // a module (rdp, vnc, xup ...) and something changed. // used for authchannel and keepalive. this->ask_acl(); } else if (signal == BACK_EVENT_REFRESH || signal == BACK_EVENT_NEXT) { this->remote_answer = false; this->ask_acl(); } } else if (this->remote_answer) { this->remote_answer = false; if (signal == BACK_EVENT_REFRESH) { LOG(LOG_INFO, "===========> MODULE_REFRESH"); signal = BACK_EVENT_NONE; TODO("signal management (refresh/next) should go to ModuleManager, " "it's basically the same behavior. It could be implemented by " "closing module then opening another one of the same kind"); mm.mod->refresh_context(this->ini); mm.mod->get_event().signal = BACK_EVENT_NONE; mm.mod->get_event().set(); } else if (signal == BACK_EVENT_NEXT) { LOG(LOG_INFO, "===========> MODULE_NEXT"); int next_state = mm.next_module(); if (next_state == MODULE_TRANSITORY) { this->remote_answer = false; return true; } signal = BACK_EVENT_NONE; if (next_state == MODULE_INTERNAL_CLOSE) { mm.invoke_close_box(nullptr, signal, now); return true; } mm.remove_mod(); try { mm.new_mod(next_state, now, this); } catch (Error & e) { if (e.id == ERR_SOCKET_CONNECT_FAILED) { this->ini.set_acl<cfg::context::module>(STRMODULE_TRANSITORY); signal = BACK_EVENT_NEXT; this->remote_answer = false; this->report("CONNECTION_FAILED", "Failed to connect to remote TCP host."); return true; } else if (e.id == ERR_RDP_SERVER_REDIR) { // SET new target in ini const char * host = char_ptr_cast( this->ini.get<cfg::mod_rdp::redir_info>().host); const char * password = char_ptr_cast( this->ini.get<cfg::mod_rdp::redir_info>().password); const char * username = char_ptr_cast( this->ini.get<cfg::mod_rdp::redir_info>().username); const char * change_user = ""; if (this->ini.get<cfg::mod_rdp::redir_info>().dont_store_username && (username[0] != 0)) { LOG(LOG_INFO, "SrvRedir: Change target username to '%s'", username); this->ini.set_acl<cfg::globals::target_user>(username); change_user = username; } if (password[0] != 0) { LOG(LOG_INFO, "SrvRedir: Change target password"); this->ini.set_acl<cfg::context::target_password>(password); } LOG(LOG_INFO, "SrvRedir: Change target host to '%s'", host); this->ini.set_acl<cfg::context::target_host>(host); char message[768] = {}; sprintf(message, "%s@%s", change_user, host); this->report("SERVER_REDIRECTION", message); this->remote_answer = true; signal = BACK_EVENT_NEXT; return true; } else { throw; } } if (!this->keepalive.is_started() && mm.connected) { this->keepalive.start(now); } } } if (this->wait_for_capture && mm.is_up_and_running()) { this->ini.check_record_config(); mm.record(this); this->wait_for_capture = false; } // LOG(LOG_INFO, "connect=%s ini.check=%s", this->connected?"Y":"N", this->ini.check()?"Y":"N"); // AuthCHANNEL CHECK // if an answer has been received, send it to // rdp serveur via mod (should be rdp module) TODO("Check if this->mod is RDP MODULE"); if (mm.connected && this->ini.get<cfg::globals::auth_channel>()[0]) { // Get sesman answer to AUTHCHANNEL_TARGET if (!this->ini.get<cfg::context::auth_channel_answer>().empty()) { // If set, transmit to auth_channel channel mm.mod->send_auth_channel_data(this->ini.get<cfg::context::auth_channel_answer>().c_str()); // Erase the context variable this->ini.get_ref<cfg::context::auth_channel_answer>().clear(); } } return true; }
bool CMatch::MatchAny(CRConDataGuard& data, int nFromLine) { bool bFound = false; // В именах файлов недопустимы: "/\:|*?<>~t~r~n а для простоты - учитываем и рамки const wchar_t* pszBreak = gszBreak; const wchar_t* pszSpacing = gszSpacing; // Пробел, таб, остальные для режима "Show white spaces" в редакторе фара const wchar_t* pszSeparat = L" \t:("; const wchar_t* pszTermint = L":)],"; const wchar_t* pszDigits = L"0123456789"; const wchar_t* pszSlashes = L"/\\"; const wchar_t* pszUrl = L":/\\:%#ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;?@&=+$,-_.!~*'()0123456789"; const wchar_t* pszUrlTrimRight = L".,;"; const wchar_t* pszProtocol = L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_+-."; const wchar_t* pszEMail = L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_+-."; const wchar_t* pszUrlDelim = L"\\\"<>{}[]^`'\r\n" MATCH_SPACINGS; const wchar_t* pszUrlFileDelim = L"\"<>^\r\n" MATCH_SPACINGS; const wchar_t* pszEndBrackets = L">])}"; const wchar_t* pszPuctuators = L".,:;…!?"; int nColons = 0; bool bUrlMode = false, bMaybeMail = false; SHORT MailX = -1; bool bDigits = false, bLineNumberFound = false, bWasSeparator = false; bool bWasPunctuator = false; bool bNakedFile = false; int nNakedFileLen = 0; enum { ef_NotFound = 0, ef_DotFound = 1, ef_ExtFound = 2, } iExtFound = ef_NotFound; int iBracket = 0; int iSpaces = 0; int iQuotStart = -1; const wchar_t* pszTest; mn_MatchLeft = mn_MatchRight = mn_SrcFrom; // Курсор над знаком препинания и за ним пробел? Допускать только ':' - это для строк/колонок с ошибками if ((wcschr(L";,.", m_SrcLine.ms_Val[mn_SrcFrom])) && (((mn_SrcFrom+1) >= mn_SrcLength) || wcschr(pszSpacing, m_SrcLine.ms_Val[mn_SrcFrom+1]))) { MatchTestAlert(); goto wrap; } // Курсор над протоколом? (http, etc) if (!CheckValidUrl(mn_MatchLeft, mn_MatchRight, bUrlMode, pszUrlDelim, pszUrl, pszProtocol, m_SrcLine.ms_Val, mn_SrcLength)) { MatchTestAlert(); goto wrap; } if (!bUrlMode) { // Not URL mode, restart searching mn_MatchLeft = mn_MatchRight = mn_SrcFrom; // Курсор над комментарием? // Попробуем найти начало имени файла if (!FindRangeStart(mn_MatchLeft, mn_MatchRight, bUrlMode, pszBreak, pszUrlDelim, pszSpacing, pszUrl, pszProtocol, m_SrcLine.ms_Val, mn_SrcLength)) { MatchTestAlert(); goto wrap; } // Try again with URL? if (mn_MatchLeft < mn_SrcFrom) { if (!CheckValidUrl(mn_MatchLeft, mn_MatchRight, bUrlMode, pszUrlDelim, pszUrl, pszProtocol, m_SrcLine.ms_Val, mn_SrcLength)) { MatchTestAlert(); goto wrap; } } } // Starts with quotation? if ((pszTest = wcschr(gszQuotStart, m_SrcLine.ms_Val[mn_MatchLeft])) != NULL) { iQuotStart = (int)(pszTest - gszQuotStart); } // Чтобы корректно флаги обработались (типа наличие расширения и т.п.) mn_MatchRight = mn_MatchLeft; // Теперь - найти конец. // Считаем, что для файлов конец это двоеточие, после которого идет описание ошибки // Для протоколов (http/...) - первый недопустимый символ TODO("Можно бы и просто открытие файлов прикрутить, без требования 'строки с ошибкой'"); // -- VC // 1>c:\sources\conemu\realconsole.cpp(8104) : error C2065: 'qqq' : undeclared identifier // DefResolve.cpp(18) : error C2065: 'sdgagasdhsahd' : undeclared identifier // DefResolve.cpp(18): warning: note xxx // -- GCC // ConEmuC.cpp:49: error: 'qqq' does not name a type // 1.c:3: some message // file.cpp:29:29: error // CPP Check // [common\PipeServer.h:1145]: (style) C-style pointer casting // Delphi // c:\sources\FarLib\FarCtrl.pas(1002) Error: Undeclared identifier: 'PCTL_GETPLUGININFO' // FPC // FarCtrl.pas(1002,49) Error: Identifier not found "PCTL_GETPLUGININFO" // PowerShell // Script.ps1:35 знак:23 // -- Possible? // abc.py (3): some message // ASM - подсвечивать нужно "test.asasm(1,1)" // [email protected](1239): test.asasm(1,1): // Issue 1594 // /src/class.c:123:m_func(...) // /src/class.c:123: m_func(...) // -- URL's // file://c:\temp\qqq.html // http://www.farmanager.com // $ http://www.KKK.ru - левее слеша - не срабатывает // C:\ConEmu>http://www.KKK.ru - ... // -- False detects // 29.11.2011 18:31:47 // C:\VC\unicode_far\macro.cpp 1251 Ln 5951/8291 Col 51 Ch 39 0043h 13:54 // InfoW1900->SettingsControl(sc.Handle, SCTL_FREE, 0, 0); // Нас не интересуют строки типа "11.05.2010 10:20:35" // В имени файла должна быть хотя бы одна буква (расширение), причем английская // Поехали if (bUrlMode) { LPCWSTR pszDelim = (wcsncmp(m_SrcLine.ms_Val+mn_MatchLeft, L"file://", 7) == 0) ? pszUrlFileDelim : pszUrlDelim; int nextLine = 1; while (true) { if ((mn_MatchRight+1) >= mn_SrcLength && data.isValid()) { if (!GetNextLine(data, nextLine+nFromLine)) break; ++nextLine; } if (((mn_MatchRight+1) >= mn_SrcLength) || wcschr(pszDelim, m_SrcLine.ms_Val[mn_MatchRight+1])) { break; } mn_MatchRight++; } DEBUGTEST(int i4break = 0); } else while ((mn_MatchRight+1) < mn_SrcLength) { if ((m_SrcLine.ms_Val[mn_MatchRight] == L'/') && ((mn_MatchRight+1) < mn_SrcLength) && (m_SrcLine.ms_Val[mn_MatchRight+1] == L'/') && !((mn_MatchRight > 1) && (m_SrcLine.ms_Val[mn_MatchRight] == L':'))) // и НЕ URL адрес { MatchTestAlert(); goto wrap; // Не оно (комментарий в строке) } if (bWasSeparator // " \t:(" && (isDigit(m_SrcLine.ms_Val[mn_MatchRight]) || (bDigits && (m_SrcLine.ms_Val[mn_MatchRight] == L',')))) // FarCtrl.pas(1002,49) Error: { if (!bDigits && (mn_MatchLeft < mn_MatchRight) /*&& (m_SrcLine.ms_Val[mn_MatchRight-1] == L':')*/) { bDigits = true; // Если перед разделителем был реальный файл - сразу выставим флажок "номер строки найден" if (IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft, mn_MatchRight - mn_MatchLeft - 1, pszBreak, pszSpacing, nNakedFileLen)) { bLineNumberFound = true; } // Skip leading quotation mark? else if ((iQuotStart >= 0) && IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft+1, mn_MatchRight - mn_MatchLeft - 2, pszBreak, pszSpacing, nNakedFileLen)) { mn_MatchLeft++; bLineNumberFound = true; } } } else if (bWasSeparator && bLineNumberFound && wcschr(L":)] \t", m_SrcLine.ms_Val[mn_MatchRight])) { //// gcc такие строки тоже может выкинуть //// file.cpp:29:29: error //mn_MatchRight--; break; } else { if (iExtFound != ef_ExtFound) { if (iExtFound == ef_NotFound) { if (m_SrcLine.ms_Val[mn_MatchRight] == L'.') iExtFound = ef_ExtFound; } else { // Не особо заморачиваясь с точками и прочим. Просто небольшая страховка от ложных срабатываний... if ((m_SrcLine.ms_Val[mn_MatchRight] >= L'a' && m_SrcLine.ms_Val[mn_MatchRight] <= L'z') || (m_SrcLine.ms_Val[mn_MatchRight] >= L'A' && m_SrcLine.ms_Val[mn_MatchRight] <= L'Z')) { iExtFound = ef_ExtFound; iBracket = 0; } } } if (iExtFound == 2) { if (m_SrcLine.ms_Val[mn_MatchRight] == L'.') { iExtFound = ef_DotFound; iBracket = 0; } else if (wcschr(pszSlashes, m_SrcLine.ms_Val[mn_MatchRight]) != NULL) { // Был слеш, значит расширения - еще нет iExtFound = ef_NotFound; iBracket = 0; bWasSeparator = false; } else if (wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight]) && wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight-1])) { // Слишком много пробелов iExtFound = ef_NotFound; iBracket = 0; bWasSeparator = false; } // Stop on naked file if we found space after it else if (!bLineNumberFound && !bMaybeMail && wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight]) // But don't stop if there is a line number: "abc.py (3): ..." && !(((mn_MatchRight+3) < mn_SrcLength) && (m_SrcLine.ms_Val[mn_MatchRight+1] == L'(') && isDigit(m_SrcLine.ms_Val[mn_MatchRight+2])) // Is this a file without digits (line/col)? && IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft, mn_MatchRight - mn_MatchLeft + 1, pszBreak, pszSpacing, nNakedFileLen)) { // File without digits, just for opening in the editor bNakedFile = true; break; } // Stop if after colon there is another letter but a digit else if (!bLineNumberFound && !bMaybeMail && (m_SrcLine.ms_Val[mn_MatchRight] == L':') && (((mn_MatchRight+1) >= mn_SrcLength) || !isDigit(m_SrcLine.ms_Val[mn_MatchRight+1])) // Is this a file without digits (line/col)? && IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft, mn_MatchRight - mn_MatchLeft, pszBreak, pszSpacing, nNakedFileLen)) { // File without digits, just for opening in the editor bNakedFile = true; mn_MatchRight--; break; } else { bWasSeparator = (wcschr(pszSeparat, m_SrcLine.ms_Val[mn_MatchRight]) != NULL); } } if ((iQuotStart >= 0) && (m_SrcLine.ms_Val[mn_MatchRight] == gszQuotEnd[iQuotStart])) { bNakedFile = IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft+1, mn_MatchRight - mn_MatchLeft - 1, pszBreak, pszSpacing, nNakedFileLen); if (bNakedFile || bMaybeMail) { mn_MatchLeft++; mn_MatchRight--; break; } } if (bWasPunctuator && !bLineNumberFound) { if (bMaybeMail) { // Если после мейла нашли что-то кроме точки if ((m_SrcLine.ms_Val[mn_MatchRight-1] != L'.') // или после точки - пробельный символ || wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight])) { break; } } else if (wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight])) { bNakedFile = IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft, mn_MatchRight - mn_MatchLeft - 1, pszBreak, pszSpacing, nNakedFileLen); if (bNakedFile) { mn_MatchRight--; break; } } } bWasPunctuator = (wcschr(pszPuctuators, m_SrcLine.ms_Val[mn_MatchRight]) != NULL); // Рассчитано на закрывающие : или ) или ] или , _ASSERTE(pszTermint[0]==L':' && pszTermint[1]==L')' && pszTermint[2]==L']' && pszTermint[3]==L',' && pszTermint[4]==0); // Script.ps1:35 знак:23 if (bDigits && IsFileLineTerminator(m_SrcLine.ms_Val+mn_MatchRight, pszTermint)) { // Validation if (((m_SrcLine.ms_Val[mn_MatchRight] == L':' || m_SrcLine.ms_Val[mn_MatchRight] == L' ') // Issue 1594: /src/class.c:123:m_func(...) /* && (wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight+1]) || wcschr(pszDigits, m_SrcLine.ms_Val[mn_MatchRight+1]))*/) // Если номер строки обрамлен скобками - скобки должны быть сбалансированы || ((m_SrcLine.ms_Val[mn_MatchRight] == L')') && (iBracket == 1) && ((m_SrcLine.ms_Val[mn_MatchRight+1] == L':') || wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight+1]) || wcschr(pszDigits, m_SrcLine.ms_Val[mn_MatchRight+1]))) // [file.cpp:1234]: (cppcheck) || ((m_SrcLine.ms_Val[mn_MatchRight] == L']') && (m_SrcLine.ms_Val[mn_MatchRight+1] == L':')) ) { //_ASSERTE(bLineNumberFound==false); //bLineNumberFound = true; break; // found? } } // Issue 1758: Support file/line format for php: C:\..\test.php:28 if (bDigits && !wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight])) { bDigits = false; } switch (m_SrcLine.ms_Val[mn_MatchRight]) { // Пока регулярок нет... case L'(': iBracket++; break; case L')': iBracket--; break; case L'/': case L'\\': iBracket = 0; break; case L'@': if (MailX != -1) { bMaybeMail = false; } else if (((mn_MatchRight > 0) && wcschr(pszEMail, m_SrcLine.ms_Val[mn_MatchRight-1])) && (((mn_MatchRight+1) < mn_SrcLength) && wcschr(pszEMail, m_SrcLine.ms_Val[mn_MatchRight+1]))) { bMaybeMail = true; MailX = mn_MatchRight; } break; } if (m_SrcLine.ms_Val[mn_MatchRight] == L':') nColons++; else if (m_SrcLine.ms_Val[mn_MatchRight] == L'\\' || m_SrcLine.ms_Val[mn_MatchRight] == L'/') nColons = 0; } if (nColons >= 2) break; mn_MatchRight++; if (wcschr(pszBreak, m_SrcLine.ms_Val[mn_MatchRight])) { if (bMaybeMail) break; if ((bLineNumberFound) || !IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft, mn_MatchRight - mn_MatchLeft + 1, pszBreak, pszSpacing, nNakedFileLen)) { MatchTestAlert(); goto wrap; // Не оно } // File without digits, just for opening in the editor _ASSERTE(!bLineNumberFound); bNakedFile = true; break; } else if (wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight])) { if ((++iSpaces) > 1) { if ((bLineNumberFound) || !IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft, mn_MatchRight - mn_MatchLeft + 1, pszBreak, pszSpacing, nNakedFileLen)) { if (!bLineNumberFound && bMaybeMail) break; MatchTestAlert(); goto wrap; // Не оно? } // File without digits, just for opening in the editor _ASSERTE(!bLineNumberFound); bNakedFile = true; break; } } else { iSpaces = 0; } } // end of 'while ((mn_MatchRight+1) < mn_SrcLength)' if (bUrlMode) { // Считаем, что OK bMaybeMail = false; // Cut off ending punctuators if (wcschr(pszPuctuators, m_SrcLine.ms_Val[mn_MatchRight])) mn_MatchRight--; // Cut off ending bracket if it is if (wcschr(pszEndBrackets, m_SrcLine.ms_Val[mn_MatchRight])) mn_MatchRight--; } else { if (!bNakedFile && !bMaybeMail && ((mn_MatchRight+1) == mn_SrcLength) && !bLineNumberFound && (iExtFound == ef_ExtFound)) { bNakedFile = IsValidFile(m_SrcLine.ms_Val+mn_MatchLeft, mn_MatchRight - mn_MatchLeft + 1, pszBreak, pszSpacing, nNakedFileLen); } if (bLineNumberFound) bMaybeMail = false; if (bNakedFile) { // correct the end pos mn_MatchRight = mn_MatchLeft + nNakedFileLen - 1; _ASSERTE(mn_MatchRight > mn_MatchLeft); // and no need to check for colon } else if (bMaybeMail) { // no need to check for colon } else if ((m_SrcLine.ms_Val[mn_MatchRight] != L':' && m_SrcLine.ms_Val[mn_MatchRight] != L' ' && !((m_SrcLine.ms_Val[mn_MatchRight] == L')') && iBracket == 1) && !((m_SrcLine.ms_Val[mn_MatchRight] == L']') && (m_SrcLine.ms_Val[mn_MatchRight+1] == L':')) ) || !bLineNumberFound || (nColons > 2)) { MatchTestAlert(); goto wrap; } if (bMaybeMail || (!bMaybeMail && !bNakedFile && m_SrcLine.ms_Val[mn_MatchRight] != L')')) mn_MatchRight--; // Откатить ненужные пробелы while ((mn_MatchLeft < mn_MatchRight) && wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchLeft])) mn_MatchLeft++; while ((mn_MatchRight > mn_MatchLeft) && wcschr(pszSpacing, m_SrcLine.ms_Val[mn_MatchRight])) mn_MatchRight--; if (bMaybeMail) { // Для мейлов - проверяем допустимые символы (чтобы пробелов не было и прочего мусора) int x = MailX - 1; _ASSERTE(x>=0); while ((x > 0) && wcschr(pszEMail, m_SrcLine.ms_Val[x-1])) x--; mn_MatchLeft = x; x = MailX + 1; _ASSERTE(x<mn_SrcLength); while (((x+1) < mn_SrcLength) && wcschr(pszEMail, m_SrcLine.ms_Val[x+1])) x++; mn_MatchRight = x; } else if (bNakedFile) { // ??? } else { if ((mn_MatchLeft + 4) > mn_MatchRight) // 1.c:1: //-V112 { // Слишком коротко, считаем что не оно MatchTestAlert(); goto wrap; } // Проверить, чтобы был в наличии номер строки if (!(m_SrcLine.ms_Val[mn_MatchRight] >= L'0' && m_SrcLine.ms_Val[mn_MatchRight] <= L'9') // ConEmuC.cpp:49: && !(m_SrcLine.ms_Val[mn_MatchRight] == L')' && (m_SrcLine.ms_Val[mn_MatchRight-1] >= L'0' && m_SrcLine.ms_Val[mn_MatchRight-1] <= L'9'))) // ConEmuC.cpp(49) : { MatchTestAlert(); goto wrap; // Номера строки нет } // [file.cpp:1234]: (cppcheck) ? if ((m_SrcLine.ms_Val[mn_MatchRight+1] == L']') && (m_SrcLine.ms_Val[mn_MatchLeft] == L'[')) mn_MatchLeft++; // Чтобы даты ошибочно не подсвечивать: // 29.11.2011 18:31:47 { bool bNoDigits = false; for (int i = mn_MatchLeft; i <= mn_MatchRight; i++) { if (m_SrcLine.ms_Val[i] < L'0' || m_SrcLine.ms_Val[i] > L'9') { bNoDigits = true; } } if (!bNoDigits) { MatchTestAlert(); goto wrap; } } // -- уже включены // Для красивости в VC включить скобки //if ((m_SrcLine.ms_Val[mn_MatchRight] == L')') && (m_SrcLine.ms_Val[mn_MatchRight+1] == L':')) // mn_MatchRight++; } } // end "else / if (bUrlMode)" // Check mouse pos, it must be inside region if ((mn_SrcFrom < mn_MatchLeft) || (mn_MatchRight < mn_SrcFrom)) { MatchTestAlert(); goto wrap; } // Ok if (mn_MatchRight >= mn_MatchLeft) { bFound = true; _ASSERTE(!bMaybeMail || !bUrlMode); // Одновременно - флаги не могут быть выставлены! LPCWSTR pszPrefix = (bMaybeMail && !bUrlMode) ? L"mailto:" : NULL; if (bMaybeMail && !bUrlMode) bUrlMode = true; StoreMatchText(pszPrefix, bUrlMode ? pszUrlTrimRight : NULL); #ifdef _DEBUG if (!bUrlMode && wcsstr(ms_Match.ms_Val, L"//")!=NULL) { _ASSERTE(FALSE); } #endif } if (bUrlMode) m_Type = etr_Url; else m_Type = (bLineNumberFound ? etr_FileRow : etr_File); wrap: return bFound; }
BOOL LoadPanelInfo995(BOOL abActive) { if (!InfoW995) return FALSE; CeFullPanelInfo* pcefpi = NULL; PanelInfo pi = {}; HANDLE hPanel = abActive ? PANEL_ACTIVE : PANEL_PASSIVE; int nRc = InfoW995->Control(hPanel, FCTL_GETPANELINFO, 0, (LONG_PTR)&pi); if (!nRc) { TODO("Показать информацию об ошибке"); return FALSE; } // Даже если невидима - обновить информацию! //// Проверим, что панель видима. Иначе - сразу выходим. //if (!pi.Visible) { // TODO("Показать информацию об ошибке"); // return NULL; //} if (pi.Flags & PFLAGS_PANELLEFT) pcefpi = &pviLeft; else pcefpi = &pviRight; pcefpi->cbSize = sizeof(*pcefpi); //pcefpi->hPanel = hPanel; // Если элементов на панели стало больше, чем выделено в (pviLeft/pviRight) if (pcefpi->ItemsNumber < pi.ItemsNumber) { if (!pcefpi->ReallocItems(pi.ItemsNumber)) return FALSE; } // Копируем что нужно pcefpi->bLeftPanel = (pi.Flags & PFLAGS_PANELLEFT) == PFLAGS_PANELLEFT; pcefpi->bPlugin = pi.Plugin; pcefpi->PanelRect = pi.PanelRect; pcefpi->ItemsNumber = pi.ItemsNumber; pcefpi->CurrentItem = pi.CurrentItem; pcefpi->TopPanelItem = pi.TopPanelItem; pcefpi->Visible = (pi.PanelType == PTYPE_FILEPANEL) && pi.Visible; pcefpi->ShortNames = pi.ShortNames; pcefpi->Focus = pi.Focus; pcefpi->Flags = pi.Flags; // CEPANELINFOFLAGS pcefpi->PanelMode = pi.ViewMode; pcefpi->IsFilePanel = (pi.PanelType == PTYPE_FILEPANEL); // Настройки интерфейса LoadFarSettingsW995(&pcefpi->FarInterfaceSettings, &pcefpi->FarPanelSettings); // Цвета фара BYTE FarConsoleColors[0x100]; INT_PTR nColorSize = InfoW995->AdvControl(InfoW995->ModuleNumber, ACTL_GETARRAYCOLOR, FarConsoleColors); #ifdef _DEBUG INT_PTR nDefColorSize = COL_LASTPALETTECOLOR; _ASSERTE(nColorSize==nDefColorSize); #endif pcefpi->nFarColors[col_PanelText] = FarConsoleColors[COL_PANELTEXT]; pcefpi->nFarColors[col_PanelSelectedCursor] = FarConsoleColors[COL_PANELSELECTEDCURSOR]; pcefpi->nFarColors[col_PanelSelectedText] = FarConsoleColors[COL_PANELSELECTEDTEXT]; pcefpi->nFarColors[col_PanelCursor] = FarConsoleColors[COL_PANELCURSOR]; pcefpi->nFarColors[col_PanelColumnTitle] = FarConsoleColors[COL_PANELCOLUMNTITLE]; pcefpi->nFarColors[col_PanelBox] = FarConsoleColors[COL_PANELBOX]; pcefpi->nFarColors[col_HMenuText] = FarConsoleColors[COL_HMENUTEXT]; pcefpi->nFarColors[col_WarnDialogBox] = FarConsoleColors[COL_WARNDIALOGBOX]; pcefpi->nFarColors[col_DialogBox] = FarConsoleColors[COL_DIALOGBOX]; pcefpi->nFarColors[col_CommandLineUserScreen] = FarConsoleColors[COL_COMMANDLINEUSERSCREEN]; pcefpi->nFarColors[col_PanelScreensNumber] = FarConsoleColors[COL_PANELSCREENSNUMBER]; pcefpi->nFarColors[col_KeyBarNum] = FarConsoleColors[COL_KEYBARNUM]; //int nColorSize = InfoW995->AdvControl(InfoW995->ModuleNumber, ACTL_GETARRAYCOLOR, NULL); //if ((pcefpi->nFarColors == NULL) || (nColorSize > pcefpi->nMaxFarColors)) //{ // if (pcefpi->nFarColors) free(pcefpi->nFarColors); // pcefpi->nFarColors = (BYTE*)calloc(nColorSize,1); // pcefpi->nMaxFarColors = nColorSize; //} //nColorSize = InfoW995->AdvControl(InfoW995->ModuleNumber, ACTL_GETARRAYCOLOR, pcefpi->nFarColors); // Текущая папка панели size_t nSize = InfoW995->Control(hPanel, FCTL_GETPANELDIR, 0, 0); if (nSize) { if ((pcefpi->pszPanelDir == NULL) || (nSize > pcefpi->nMaxPanelDir)) { pcefpi->nMaxPanelDir = nSize + MAX_PATH; // + выделим немножко заранее SafeFree(pcefpi->pszPanelDir); pcefpi->pszPanelDir = (wchar_t*)calloc(pcefpi->nMaxPanelDir,2); } nSize = InfoW995->Control(hPanel, FCTL_GETPANELDIR, (int)nSize, (LONG_PTR)pcefpi->pszPanelDir); if (!nSize) { free(pcefpi->pszPanelDir); pcefpi->pszPanelDir = NULL; pcefpi->nMaxPanelDir = 0; } } else { if (pcefpi->pszPanelDir) { free(pcefpi->pszPanelDir); pcefpi->pszPanelDir = NULL; } } // Готовим буфер для информации об элементах pcefpi->ReallocItems(pcefpi->ItemsNumber); // и буфер для загрузки элемента из FAR nSize = sizeof(PluginPanelItem)+6*MAX_PATH; if ((pcefpi->pFarTmpBuf == NULL) || (pcefpi->nFarTmpBuf < nSize)) { if (pcefpi->pFarTmpBuf) free(pcefpi->pFarTmpBuf); pcefpi->nFarTmpBuf = nSize; //-V101 pcefpi->pFarTmpBuf = malloc(pcefpi->nFarTmpBuf); } return TRUE; }
void ClientNG::recv_(mdsproto::Tag txtag, size_t txoff, Read&& read) { mdsproto::ResponseHeader rxhdr; client_.recv(ba::buffer(&rxhdr, sizeof(rxhdr)), timeout_); if (rxhdr.magic != mdsproto::magic) { LOG_ERROR("Response lacks our protocol magic, giving up"); throw mdsproto::NoMagicException("no magic key in received header"); } // LOG_TRACE("received hdr " << rxhdr.response_type << // ", tag " << rxhdr.tag << // ", size " << rxhdr.size << // ", flags " << rxhdr.flags); TODO("AR: better exceptions"); THROW_WHEN(rxhdr.tag != txtag); ++in_counters_.messages; in_counters_.data_bytes += rxhdr.size; in_counters_.data_bytes_sqsum += rxhdr.size * rxhdr.size; if (rxhdr.size) { if ((rxhdr.flags bitand mdsproto::ResponseHeader::Flags::UseShmem) == 0) { if (use_shmem_()) { ++in_counters_.shmem_overruns; } std::vector<capnp::word> rxbuf(rxhdr.size / sizeof(capnp::word)); client_.recv(ba::buffer(rxbuf), timeout_); capnp::FlatArrayMessageReader reader(kj::arrayPtr(rxbuf.data(), rxbuf.size())); handle_response_<T>(rxhdr, reader, std::move(read)); } else { THROW_UNLESS(use_shmem_()); const uint8_t* addr = static_cast<const uint8_t*>(mr_->address()) + txoff; THROW_UNLESS(addr + rxhdr.size <= static_cast<const uint8_t*>(mr_->address()) + mr_->size()); auto seg(kj::arrayPtr(reinterpret_cast<const capnp::word*>(addr), rxhdr.size / sizeof(capnp::word))); capnp::SegmentArrayMessageReader reader(kj::arrayPtr(&seg, 1)); handle_response_<T>(rxhdr, reader, std::move(read)); } } }
BOOL LoadPanelInfoA(BOOL abActive) { if (!InfoA) return FALSE; CeFullPanelInfo* pcefpi = NULL; PanelInfo pi = {}; int nCmd = abActive ? FCTL_GETPANELINFO : FCTL_GETANOTHERPANELINFO; int nRc = InfoA->Control(INVALID_HANDLE_VALUE, nCmd, &pi); if (!nRc) { TODO("Показать информацию об ошибке"); return FALSE; } // Даже если невидима - обновить информацию! //// Проверим, что панель видима. Иначе - сразу выходим. //if (!pi.Visible) { // TODO("Показать информацию об ошибке"); // return NULL; //} if (pi.Flags & PFLAGS_PANELLEFT) pcefpi = &pviLeft; else pcefpi = &pviRight; pcefpi->cbSize = sizeof(*pcefpi); //pcefpi->hPanel = hPanel; // Если элементов на панели стало больше, чем выделено в (pviLeft/pviRight) if (pcefpi->ItemsNumber < pi.ItemsNumber) //-V104 { if (!pcefpi->ReallocItems(pi.ItemsNumber)) return FALSE; } // Копируем что нужно pcefpi->bLeftPanel = (pi.Flags & PFLAGS_PANELLEFT) == PFLAGS_PANELLEFT; pcefpi->bPlugin = pi.Plugin; pcefpi->PanelRect = pi.PanelRect; pcefpi->ItemsNumber = pi.ItemsNumber; //-V101 pcefpi->CurrentItem = pi.CurrentItem; //-V101 pcefpi->TopPanelItem = pi.TopPanelItem; //-V101 pcefpi->Visible = (pi.PanelType == PTYPE_FILEPANEL) && pi.Visible; pcefpi->ShortNames = pi.ShortNames; pcefpi->Focus = pi.Focus; pcefpi->Flags = pi.Flags; // CEPANELINFOFLAGS pcefpi->PanelMode = pi.ViewMode; pcefpi->IsFilePanel = (pi.PanelType == PTYPE_FILEPANEL); // Настройки интерфейса LoadFarSettingsA(&pcefpi->FarInterfaceSettings, &pcefpi->FarPanelSettings); // Цвета фара BYTE FarConsoleColors[0x100]; INT_PTR nColorSize = InfoA->AdvControl(InfoA->ModuleNumber, ACTL_GETARRAYCOLOR, FarConsoleColors); #ifdef _DEBUG INT_PTR nDefColorSize = COL_LASTPALETTECOLOR; _ASSERTE(nColorSize==nDefColorSize); #endif pcefpi->nFarColors[col_PanelText] = FarConsoleColors[COL_PANELTEXT]; pcefpi->nFarColors[col_PanelSelectedCursor] = FarConsoleColors[COL_PANELSELECTEDCURSOR]; pcefpi->nFarColors[col_PanelSelectedText] = FarConsoleColors[COL_PANELSELECTEDTEXT]; pcefpi->nFarColors[col_PanelCursor] = FarConsoleColors[COL_PANELCURSOR]; pcefpi->nFarColors[col_PanelColumnTitle] = FarConsoleColors[COL_PANELCOLUMNTITLE]; pcefpi->nFarColors[col_PanelBox] = FarConsoleColors[COL_PANELBOX]; pcefpi->nFarColors[col_HMenuText] = FarConsoleColors[COL_HMENUTEXT]; pcefpi->nFarColors[col_WarnDialogBox] = FarConsoleColors[COL_WARNDIALOGBOX]; pcefpi->nFarColors[col_DialogBox] = FarConsoleColors[COL_DIALOGBOX]; pcefpi->nFarColors[col_CommandLineUserScreen] = FarConsoleColors[COL_COMMANDLINEUSERSCREEN]; pcefpi->nFarColors[col_PanelScreensNumber] = FarConsoleColors[COL_PANELSCREENSNUMBER]; pcefpi->nFarColors[col_KeyBarNum] = FarConsoleColors[COL_KEYBARNUM]; // Текущая папка панели int nSize = lstrlenA(pi.CurDir); //-V303 pcefpi->nMaxPanelDir = nSize + MAX_PATH; // + выделим немножко заранее SafeFree(pcefpi->pszPanelDir); pcefpi->pszPanelDir = (wchar_t*)calloc(pcefpi->nMaxPanelDir,2); //-V106 MultiByteToWideChar(CP_OEMCP, 0, pi.CurDir, nSize+1, pcefpi->pszPanelDir, nSize + MAX_PATH); // Готовим буфер для информации об элементах pcefpi->ReallocItems(pcefpi->ItemsNumber); // Копирование элементов панели в нашу внутреннюю структуру wchar_t szName[MAX_PATH+1], szDescription[255]; LARGE_INTEGER liFileSize; PluginPanelItem *ppi = pi.PanelItems; for(int i = 0; i < pi.ItemsNumber; i++, ppi++) { liFileSize.LowPart = ppi->FindData.nFileSizeLow; liFileSize.HighPart = ppi->FindData.nFileSizeHigh; MultiByteToWideChar(CP_OEMCP, 0, ppi->FindData.cFileName, -1, szName, countof(szName)); if (ppi->Description) MultiByteToWideChar(CP_OEMCP, 0, ppi->Description, -1, szDescription, countof(szDescription)); else szDescription[0] = 0; pcefpi->FarItem2CeItem(i, szName, szDescription[0] ? szDescription : NULL, ppi->FindData.dwFileAttributes, ppi->FindData.ftLastWriteTime, liFileSize.QuadPart, (pcefpi->bPlugin && (pi.Flags & CEPFLAGS_REALNAMES) == 0) /*abVirtualItem*/, NULL, ppi->UserData, NULL, ppi->Flags, ppi->NumberOfLinks); } return TRUE; }
BOOL TreeView_DeleteItem(HWND hwndTV, int nIDDlgItem, HTREEITEM hitem) { TODO(); }
void PrintDebugInfo() { _printf("Debugger successfully attached to PID=%u\n", gpSrv->dwRootProcess); TODO("Вывести информацию о загруженных модулях, потоках, и стеке потоков"); }
bool CPluginAnsi::UpdateConEmuTabsApi(int windowCount) { if (!InfoA || gbIgnoreUpdateTabs) return false; bool lbCh = false, lbDummy = false; WindowInfo WInfo; WCHAR* pszName = gszDir1; pszName[0] = 0; //(WCHAR*)calloc(CONEMUTABMAX, sizeof(WCHAR)); int tabCount = 0; bool lbActiveFound = false; for (int i = 0; i < windowCount; i++) { WInfo.Pos = i; _ASSERTE(GetCurrentThreadId() == gnMainThreadId); InfoA->AdvControl(InfoA->ModuleNumber, ACTL_GETSHORTWINDOWINFO, (void*)&WInfo); if (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER || WInfo.Type == WTYPE_PANELS) { InfoA->AdvControl(InfoA->ModuleNumber, ACTL_GETWINDOWINFO, (void*)&WInfo); if (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER || WInfo.Type == WTYPE_PANELS) { #ifdef SHOW_DEBUG_EVENTS char szDbg[255]; wsprintfA(szDbg, "Window %i (Type=%i, Modified=%i)\n", i, WInfo.Type, WInfo.Modified); OutputDebugStringA(szDbg); #endif if (WInfo.Current) lbActiveFound = true; MultiByteToWideChar(CP_OEMCP, 0, WInfo.Name, lstrlenA(WInfo.Name)+1, pszName, CONEMUTABMAX); TODO("Определение ИД редактора/вьювера"); lbCh |= AddTab(tabCount, -1, false/*losingFocus*/, false/*editorSave*/, WInfo.Type, pszName, /*editorSave ? pszFileName :*/ NULL, WInfo.Current, WInfo.Modified, 0, 0); //if (WInfo.Type == WTYPE_EDITOR && WInfo.Current) //2009-08-17 // lastModifiedStateW = WInfo.Modified; } } } // Скорее всего это модальный редактор (или вьювер?) if (!lbActiveFound) { WInfo.Pos = -1; _ASSERTE(GetCurrentThreadId() == gnMainThreadId); InfoA->AdvControl(InfoA->ModuleNumber, ACTL_GETSHORTWINDOWINFO, (void*)&WInfo); if (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER) { WInfo.Pos = -1; InfoA->AdvControl(InfoA->ModuleNumber, ACTL_GETWINDOWINFO, (void*)&WInfo); if (WInfo.Type == WTYPE_EDITOR || WInfo.Type == WTYPE_VIEWER) { tabCount = 0; MultiByteToWideChar(CP_OEMCP, 0, WInfo.Name, lstrlenA(WInfo.Name)+1, pszName, CONEMUTABMAX); TODO("Определение ИД редактора/вьювера"); lbCh |= AddTab(tabCount, -1, false/*losingFocus*/, false/*editorSave*/, WInfo.Type, pszName, /*editorSave ? pszFileName :*/ NULL, WInfo.Current, WInfo.Modified, 0, 0); } } else if (WInfo.Type == WTYPE_PANELS) { gpTabs->Tabs.CurrentType = gnCurrentWindowType = WInfo.Type; } } // 101224 - сразу запомнить количество! AddTabFinish(tabCount); return lbCh; }