void LogW(enum LogType type, const wchar_t* fmt, ...) { #ifdef DISABLE_LOG SP_UNREFERENCED_PARAMETER(type); SP_UNREFERENCED_PARAMETER(fmt); return; #else AMDTScopeLock s(&sMutex); bool s_LogConsole = false; va_list arg_ptr; va_start(arg_ptr, fmt); // check to see if logging of the level is enabled, or if s_LogConsole is specified // if not, don't process it. if (type > OptionLogLevel) { va_end(arg_ptr); return; } // Define buffer to store maximum current log message. // Different destinations will receive a subset of this string. // On Win32 the entire string is passed to OutputDebugString() wchar_t fullString[SP_LOG_MAX_LENGTH] = L"\0"; int nLen = 0; int nSize; bool truncated = false; wchar_t* pLogString; // String to print to logfile wchar_t* pConsole; // String to print to console doesn't include debug information wchar_t* pRaw; // Raw string passed in without any additional decoration if (truncated == false) { // Prepend "CodeXL GPU Profiler: " for windows OutputDebugString() messages nSize = _snwprintf_s(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, _TRUNCATE, L"CodeXL GPU Profiler: "); if ((truncated = (nSize == -1)) == false) { nLen += nSize; } } pLogString = &fullString[nLen]; // logfile message doesn't include above WIN32 section pConsole = &fullString[nLen]; // String to print to console starts here if (truncated == false) { // Add the message type string switch (type) { case logERROR: nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"Error: "); break; case logWARNING: nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"Warning: "); break; case logMESSAGE: nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"Message: "); break; case logTRACE: nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"Trace: "); break; case logASSERT: nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"Assert: "); break; case logRAW: // Skip nSize = 0; break; case traceENTER: case traceEXIT: case traceMESSAGE: nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"Trace: "); break; default: nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"Unknown: "); break; } if ((truncated = (nSize == -1)) == false) { nLen += nSize; } } // Add the module identifier if (s_LogModule && (truncated == false)) { nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"%-14s: ", s_LogModule); if ((truncated = (nSize == -1)) == false) { nLen += nSize; } } if (truncated == false) { if (OptionLogLevel >= logTRACE - logERROR) { // Add the indent for (int i = 0; (i < logIndent) && (nLen < SP_LOG_MAX_LENGTH); i++, nLen++) { fullString[nLen] = L' '; } truncated = (nLen == SP_LOG_MAX_LENGTH); } } pRaw = &fullString[nLen]; // Raw undecorated string starts here // Add the actual Log Message if (truncated == false) { nSize = SP_vsnwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, fmt, arg_ptr); if ((truncated = (nSize == -1)) == false) { nLen += nSize; } } // Check if message has been truncated and clean up accordingly if (truncated == true) { // Truncation occurred - change end of line to reflect this wchar_t truncationString[] = L" ... \n"; swprintf_s(&fullString[SP_LOG_MAX_LENGTH - sizeof(truncationString)], sizeof(truncationString), L"%ws", truncationString); } if (type > logTRACE) { // For trace messages - force a "\n" at the end if (truncated == false) { nSize = SP_snwprintf(&fullString[nLen], SP_LOG_MAX_LENGTH - nLen, L"\n"); if ((truncated = (nSize == -1)) == false) { nLen += nSize; } } } // Message Constructed. Print to Log, Console, and OutputDebugString as necessary // if (type == logRAW) { if (s_LogConsole) { // Send string to console wprintf(L"%ws", pRaw); } _logWriteW(pRaw); } else { if (s_LogConsole) { // Console messages are always printed in console and in log file // regardless of logLEVEL wprintf(L"%ws", pConsole); _logWriteW(pLogString); OutputDebugStringW(fullString); } else { // not a console message - filter based on log level if ((type - logERROR) <= OptionLogLevel) { if (type == logTRACE) { // Trace messages also go to the console wprintf(L"%ws", pConsole); } _logWriteW(pLogString); OutputDebugStringW(fullString); } } } va_end(arg_ptr); #endif }
static void vprintf_stderr_common(const char* format, va_list args) { #if PLATFORM(MAC) if (strstr(format, "%@")) { CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8); CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args); int length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); char* buffer = (char*)malloc(length + 1); CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8); fputs(buffer, stderr); free(buffer); CFRelease(str); CFRelease(cfFormat); } else #elif PLATFORM(BREWMP) // When str is 0, the return value is the number of bytes needed // to accept the result including null termination. int size = vsnprintf(0, 0, format, args); if (size > 0) { Vector<char> buffer(size); vsnprintf(buffer.data(), size, format, args); printLog(buffer); } #elif HAVE(ISDEBUGGERPRESENT) if (IsDebuggerPresent()) { size_t size = 1024; do { char* buffer = (char*)malloc(size); if (buffer == NULL) break; if (_vsnprintf(buffer, size, format, args) != -1) { #if OS(WINCE) // WinCE only supports wide chars wchar_t* wideBuffer = (wchar_t*)malloc(size * sizeof(wchar_t)); if (wideBuffer == NULL) break; for (unsigned int i = 0; i < size; ++i) { if (!(wideBuffer[i] = buffer[i])) break; } OutputDebugStringW(wideBuffer); free(wideBuffer); #else OutputDebugStringA(buffer); #endif free(buffer); break; } free(buffer); size *= 2; } while (size > 1024); } #endif #if OS(SYMBIAN) vfprintf(stdout, format, args); #else vfprintf(stderr, format, args); #endif }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*prevInstance*/, PSTR /*cmdLine*/, int /*showCmd*/) { //notify user if heap is corrupt #if defined _DEBUG HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); #endif #pragma region junk //*********************** //get command line params //LPCWSTR int numArgs=0; WCHAR **sArgList = CommandLineToArgvW(GetCommandLineW(), &numArgs); //print arguments if( NULL == sArgList ) { wprintf(L"CommandLineToArgvW failed\n"); return 0; } else { wstringstream strstr; for(int i=0; i < numArgs; i++) { strstr << i << sArgList[i] << _T("\n"); } OutputDebugStringW(strstr.str().c_str()); } LocalFree(sArgList);//free memory //end of parameters experiment //**************************** #pragma endregion //create game singleton object Engine* pEngine = new Engine(hInstance); MainGame* pGame = new MainGame(); #if defined DEBUG || _DEBUG cout << "-Engine & Game created\n"; #endif pEngine->SetGame(pGame); pEngine->Initialize(); #if defined DEBUG || _DEBUG cout << "------------------------\n:::Engine Initialized:::\n------------------------\n\n"; #endif int ret = pEngine->Run(); //destroy objects delete pGame; delete pEngine; cout << "\n\n"; cout << " Happy Engine wishes you a happy day! \n"; cout << "--------------\\Press any key/-------------\n"; cin.get(); #if defined _DEBUG _CrtDumpMemoryLeaks(); #endif return ret; }
WBRETURN CDownloadOperation::IsNewTBCacheFile( wchar_t * pFileName ) { WBRETURN bReturn = NONE; //黑白名单位于 Config文件夹内 if( wcscmp(L"Config.cab", pFileName) != 0 ) return bReturn; std::wstring newFile ; newFile = this->getBankCachePath( true ); std::wstring existingFile ; existingFile = getBankCachePath(); existingFile += pFileName; CCabExtract tt; if(tt.ExtractFile(existingFile.c_str(), newFile.c_str() ) ) { OutputDebugStringW(L"extractFile is OK!"); } #define BUFSIZEFORMD5 4 * 1024 * 1024 unsigned char * pBuf = new unsigned char[BUFSIZEFORMD5]; unsigned char * pCheckE = new unsigned char[16]; unsigned char * pCheckN = new unsigned char[16]; DWORD dwTmp = 0; if( pBuf && pCheckN && pCheckE ) { for( int i=0; i < m_vecWBFileName.size(); i++) { std::wstring wsNewFile = newFile; std::wstring wsExistingFile = getModulePath(); wsNewFile += L"Config\\"; wsExistingFile += L"Config\\"; wsNewFile += m_vecWBFileName[i].c_str(); wsExistingFile += m_vecWBFileName[i].c_str(); HANDLE hFileE = CreateFile(wsExistingFile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING ,FILE_ATTRIBUTE_NORMAL, NULL); HANDLE hFileN = CreateFile(wsNewFile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING ,FILE_ATTRIBUTE_NORMAL, NULL); if( !(INVALID_HANDLE_VALUE == hFileE || INVALID_HANDLE_VALUE == hFileN) ) { /////对缓存文件进行MD5计算 ZeroMemory(pBuf, BUFSIZEFORMD5); CMD5 md5E; while(1) { if( ReadFile(hFileE, pBuf, BUFSIZEFORMD5, &dwTmp, NULL) ) { if( 0 == dwTmp) break; md5E.MD5Update(pBuf, dwTmp); } } md5E.MD5Final(pCheckE); /////对黑白名单文件文件进行MD5计算 ZeroMemory(pBuf, BUFSIZEFORMD5); CMD5 md5N; while(1) { CMD5 md5; if( ReadFile(hFileN, pBuf, BUFSIZEFORMD5, &dwTmp, NULL) ) { if( 0 == dwTmp) break; md5N.MD5Update(pBuf, dwTmp); } } md5N.MD5Final(pCheckN); } CloseHandle(hFileE); CloseHandle(hFileN); if( 0 != memcmp(pCheckN, pCheckE, 16) ) { if( i==0 ) { if( bReturn == WHITEUPDATE ) { bReturn = ALL; break; } bReturn = BLACKUPDATE; } else { if( bReturn == BLACKUPDATE ) { bReturn = ALL; break; } bReturn = WHITEUPDATE; } } } } return bReturn; }
/** * bIndex == 1 遍历指定文件夹并解压缩 * 数据升级Config因为包括黑白名单缓存,需特殊处理 */ void CDownloadOperation::uncompressTraverse(IN LPWSTR path ,IN BYTE bIndex, IN OUT LPWSTR parentDirectory ) { USES_CONVERSION; WIN32_FIND_DATAW fw; HANDLE hFind= FindFirstFileW(path,&fw); if(hFind == INVALID_HANDLE_VALUE) return ; WBRETURN bIsWBCab = NONE; do { if(wcscmp(fw.cFileName,L".") == 0 || wcscmp(fw.cFileName,L"..") == 0 || wcscmp(fw.cFileName,L".svn") == 0) continue; if(fw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if(bIndex == 1) { } } else { if(bIndex == 1 && strstr(W2A(fw.cFileName),"cab") != NULL) { std::wstring newFile ; bool bIsSC = isSpecialCab(fw.cFileName); newFile = this->getAppDataPath(); if( !bIsSC ) newFile += BANKINFOPATHNOFIND; WBRETURN bWBCab = IsNewTBCacheFile(fw.cFileName); if( bWBCab != NONE) if( bWBCab != bIsWBCab && bIsWBCab != ALL ) { if( bIsWBCab == NONE) bIsWBCab = bWBCab; else bIsWBCab = ALL; } std::wstring existingFile ; existingFile = getBankCachePath(); existingFile += fw.cFileName; //没有通过验证的升级包不允许升级 if( _UpdateMgr.isSafeFile((wchar_t *)existingFile.c_str() ) ) { moveFiles(fw.cFileName, true); CCabExtract tt; if(tt.ExtractFile(existingFile.c_str(), newFile.c_str() ) ) OutputDebugStringW(L"extractFile is OK!"); else { moveFiles(fw.cFileName, false); } } } } } while( FindNextFile(hFind,&fw) ); this->UpdateWBFile(bIsWBCab); FindClose(hFind); }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; TCHAR szHello[MAX_LOADSTRING]; TCHAR szMsgDbg[1000]; wsprintf(szMsgDbg, TEXT("rcvd msg #%d (0x%04X)\n"), message, message); OutputDebugStringW(szMsgDbg); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_TEST: main(); break; case IDOK: SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_KILLFOCUS: SendMessage (hWnd, WM_CLOSE, 0, 0); break; case WM_CREATE: g_hwndCB = CreateRpCommandBar(hWnd); // Initialize the shell activate info structure memset (&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); LoadString(g_hInst, IDS_HELLO, szHello, MAX_LOADSTRING); DrawText(hdc, szHello, _tcslen(szHello), &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(g_hwndCB); PostQuitMessage(0); break; case WM_CLOSE: DestroyWindow(hWnd); break; case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
static void complain(const wchar_t *s) { std::fputws(s, stderr); OutputDebugStringW(s); }
static int LS_LOG( lua_State* L ) { int n = lua_gettop(L); /* number of arguments */ int i; lua_getglobal(L, "towstring"); lua_getglobal(L, "tostring"); for (i=1; i<=n; i++) { const char *s = NULL; const lua_WChar *ws = NULL; if (lua_type(L, i) == LUA_TSTRING) { s = lua_tostring(L, -1); } else if (lua_type(L, i) != LUA_TWSTRING) { lua_pushvalue(L, -1); /* function to be called */ lua_pushvalue(L, i); /* value to print */ lua_call(L, 1, 1); s = lua_tostring(L, -1); /* get result */ if (s == NULL) return luaL_error(L, "`tostring' must return a string to `print'"); } else { lua_pushvalue(L, -2); /* function to be called */ lua_pushvalue(L, i); /* value to print */ lua_call(L, 1, 1); ws = lua_towstring(L, -1); /* get result */ if (ws == NULL) return luaL_error(L, "`tostring' must return a string to `print'"); } if (i>1) { #ifdef WIN32 OutputDebugStringA("\t"); #else fputs("\t", stdout); #endif } if (s) { #ifdef WIN32 OutputDebugStringA(s); #else fputs(s, stdout); #endif } else if (ws) { wchar_t out[512]; wchar_t* outEnd = out + sizeof(out) - 2; while (*ws) { wchar_t* outPos = out; while (*ws && outPos != outEnd) { *outPos++ = *ws++; } *outPos++ = 0; #ifdef WIN32 OutputDebugStringW(out); #else fputws(out, stdout); #endif } } lua_pop(L, 1); /* pop result */ } #ifdef WIN32 OutputDebugStringA("\n"); #else fputs("\n", stdout); #endif return 0; }
STDMETHODIMP CAdminNotifyHandler::Begin(ULONG uEvent, IDataObject* pArg1, IDataObject* pArg2, ULONG* puFlags, BSTR* pBstr) { OutputDebugString(TEXT("CAdminNotifyHandler::Begin\n")); if(NULL == pArg1) { return E_INVALIDARG; } if(NULL == puFlags) { return E_INVALIDARG; } if(NULL == pBstr) { return E_INVALIDARG; } //release any data objects this handler may already have End(); //save the data objects pArg1->QueryInterface(IID_IDataObject, (LPVOID*)&m_pdoFrom); if(NULL != pArg2) { pArg2->QueryInterface(IID_IDataObject, (LPVOID*)&m_pdoTo); } STGMEDIUM stm; FORMATETC fe; HRESULT hr; fe.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_DSOBJECTNAMES); fe.ptd = NULL; fe.dwAspect = DVASPECT_CONTENT; fe.lindex = -1; fe.tymed = TYMED_HGLOBAL; hr = pArg1->GetData(&fe, &stm); if(SUCCEEDED(hr)) { LPDSOBJECTNAMES pdson = (LPDSOBJECTNAMES)GlobalLock(stm.hGlobal); if(pdson) { LPWSTR pwszName = (LPWSTR)((LPBYTE)pdson + pdson->aObjects[0].offsetName); LPWSTR pwszClass = (LPWSTR)((LPBYTE)pdson + pdson->aObjects[0].offsetClass); OutputDebugString(TEXT("\t")); OutputDebugStringW(pwszClass); OutputDebugString(TEXT(" - ")); OutputDebugStringW(pwszName); OutputDebugString(TEXT("\n")); GlobalUnlock(stm.hGlobal); } ReleaseStgMedium(&stm); } if(pArg2) { fe.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_DSOBJECTNAMES); fe.ptd = NULL; fe.dwAspect = DVASPECT_CONTENT; fe.lindex = -1; fe.tymed = TYMED_HGLOBAL; hr = pArg2->GetData(&fe, &stm); if(SUCCEEDED(hr)) { LPDSOBJECTNAMES pdson = (LPDSOBJECTNAMES)GlobalLock(stm.hGlobal); if(pdson) { LPWSTR pwszName = (LPWSTR)((LPBYTE)pdson + pdson->aObjects[0].offsetName); LPWSTR pwszClass = (LPWSTR)((LPBYTE)pdson + pdson->aObjects[0].offsetClass); OutputDebugString(TEXT("\t")); OutputDebugStringW(pwszClass); OutputDebugString(TEXT(" - ")); OutputDebugStringW(pwszName); OutputDebugString(TEXT("\n")); GlobalUnlock(stm.hGlobal); } ReleaseStgMedium(&stm); } } *puFlags = DSA_NOTIFY_FLAG_ADDITIONAL_DATA | DSA_NOTIFY_FLAG_FORCE_ADDITIONAL_DATA; WCHAR wszTitle[MAX_PATH]; LocalToWideChar(wszTitle, ARRAYSIZE(wszTitle), g_szMainTitle, MAX_PATH); *pBstr = SysAllocString(wszTitle); return *pBstr ? S_OK : E_OUTOFMEMORY; }
void vLoggerConsole(const QString& message) { OutputDebugStringW(reinterpret_cast<const WCHAR*>(message.utf16())); }
Bool CodeSet_Init(const char *icuDataDir) // IN: ICU data file location in Current code page. // Default is used if NULL. { #ifdef NO_ICU /* Nothing required if not using ICU. */ return TRUE; #else // NO_ICU DynBuf dbpath; #ifdef _WIN32 DWORD attribs; utf16_t *modPath = NULL; utf16_t *lastSlash; utf16_t *wpath; HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE hMapping = NULL; void *memMappedData = NULL; #else struct stat finfo; #endif char *path = NULL; Bool ret = FALSE; DynBuf_Init(&dbpath); #ifdef USE_ICU /* * We're using system ICU, which finds its own data. So nothing to * do here. */ dontUseIcu = FALSE; ret = TRUE; goto exit; #endif /* * ********************* WARNING * Must avoid recursive calls into the codeset library here, hence * the idiotic hoop-jumping. DO NOT change any of these calls to * wrapper equivalents or call any other functions that may perform * string conversion. * ********************* WARNING */ #ifdef _WIN32 // { #if vmx86_devel && !defined(TEST_CUSTOM_ICU_DATA_FILE) /* * Devel builds use toolchain directory first. */ { WCHAR icuFilePath[MAX_PATH] = { 0 }; DWORD n = ExpandEnvironmentStringsW(ICU_DATA_FILE_PATH, icuFilePath, ARRAYSIZE(icuFilePath)); if (n > 0 && n < ARRAYSIZE(icuFilePath)) { attribs = GetFileAttributesW(icuFilePath); if ((INVALID_FILE_ATTRIBUTES != attribs) || (attribs & FILE_ATTRIBUTE_DIRECTORY) == 0) { if (!CodeSetOld_Utf16leToCurrent((const char *) icuFilePath, n * sizeof *icuFilePath, &path, NULL)) { goto exit; } goto found; } } } #endif if (icuDataDir) { /* * Data file must be in the specified directory. */ size_t length = strlen(icuDataDir); if (!DynBuf_Append(&dbpath, icuDataDir, length)) { goto exit; } if (length && icuDataDir[length - 1] != DIRSEPC) { if (!DynBuf_Append(&dbpath, DIRSEPS, strlen(DIRSEPS))) { goto exit; } } if (!DynBuf_Append(&dbpath, ICU_DATA_FILE, strlen(ICU_DATA_FILE)) || !DynBuf_Append(&dbpath, "\0", 1)) { goto exit; } /* * Check for file existence. */ attribs = GetFileAttributesA(DynBuf_Get(&dbpath)); if ((INVALID_FILE_ATTRIBUTES == attribs) || (attribs & FILE_ATTRIBUTE_DIRECTORY)) { goto exit; } path = (char *) DynBuf_Detach(&dbpath); } else { /* * Data file must be in the directory of the current module * (i.e. the module that contains CodeSet_Init()). */ HMODULE hModule = W32Util_GetModuleByAddress((void *) CodeSet_Init); if (!hModule) { goto exit; } modPath = CodeSetGetModulePath(hModule); if (!modPath) { goto exit; } lastSlash = wcsrchr(modPath, DIRSEPC_W); if (!lastSlash) { goto exit; } *lastSlash = L'\0'; if (!DynBuf_Append(&dbpath, modPath, wcslen(modPath) * sizeof(utf16_t)) || !DynBuf_Append(&dbpath, DIRSEPS_W, wcslen(DIRSEPS_W) * sizeof(utf16_t)) || !DynBuf_Append(&dbpath, ICU_DATA_FILE_W, wcslen(ICU_DATA_FILE_W) * sizeof(utf16_t)) || !DynBuf_Append(&dbpath, L"\0", 2)) { goto exit; } /* * Since u_setDataDirectory can't handle UTF-16, we would have to * now convert this path to local encoding. But that fails when * the module is in a path containing characters not in the * local encoding (see 282524). So we'll memory-map the file * instead and call udata_setCommonData() below. */ wpath = (utf16_t *) DynBuf_Get(&dbpath); hFile = CreateFileW(wpath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); if (INVALID_HANDLE_VALUE == hFile) { goto exit; } hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); if (NULL == hMapping) { goto exit; } memMappedData = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0); if (NULL == memMappedData) { goto exit; } } #else // } _WIN32 { #if vmx86_devel && !defined(TEST_CUSTOM_ICU_DATA_FILE) { char *modPath; char *lastSlash; /* * Devel builds use toolchain directory first. */ if (stat(ICU_DATA_FILE_PATH, &finfo) >= 0 && !S_ISDIR(finfo.st_mode)) { if ((path = strdup(ICU_DATA_FILE_PATH)) == NULL) { goto exit; } goto found; } /* * Then we try module directory, if we can get it. */ modPath = CodeSetGetModulePath(HGMP_PRIVILEGE); if (modPath) { lastSlash = strrchr(modPath, DIRSEPC); if (lastSlash) { *lastSlash = '\0'; if (DynBuf_Append(&dbpath, modPath, strlen(modPath)) && DynBuf_Append(&dbpath, DIRSEPS, strlen(DIRSEPS)) && DynBuf_Append(&dbpath, ICU_DATA_FILE, strlen(ICU_DATA_FILE)) && DynBuf_Append(&dbpath, "\0", 1)) { if ((stat((const char *) DynBuf_Get(&dbpath), &finfo) >= 0) && !S_ISDIR(finfo.st_mode)) { free(modPath); path = DynBuf_Detach(&dbpath); goto found; } else { DynBuf_SetSize(&dbpath, 0); } } } free(modPath); } } #endif // vmx86_devel if (icuDataDir) { /* Use the caller-specified ICU data dir. */ if (!DynBuf_Append(&dbpath, icuDataDir, strlen(icuDataDir))) { goto exit; } } else { /* Use a default ICU data dir. */ # if defined __APPLE__ Location_GetLibrary_Type *Location_GetLibrary = Location_GetLibrary_Addr(); if (Location_GetLibrary) { char *libDir = Location_GetLibrary(); Bool success = libDir && DynBuf_Append(&dbpath, libDir, strlen(libDir)); free(libDir); if (!success) { goto exit; } } else # endif { if (!DynBuf_Append(&dbpath, POSIX_ICU_DIR, strlen(POSIX_ICU_DIR))) { goto exit; } } if (!DynBuf_Append(&dbpath, "/icu", strlen("/icu"))) { goto exit; } } if (!DynBuf_Append(&dbpath, DIRSEPS, strlen(DIRSEPS)) || !DynBuf_Append(&dbpath, ICU_DATA_FILE, strlen(ICU_DATA_FILE)) || !DynBuf_Append(&dbpath, "\0", 1)) { goto exit; } /* * Check for file existence. (DO NOT CHANGE TO 'stat' WRAPPER). */ path = (char *) DynBuf_Detach(&dbpath); if (stat(path, &finfo) < 0 || S_ISDIR(finfo.st_mode)) { goto exit; } #endif // } _WIN32 #if vmx86_devel && !defined(TEST_CUSTOM_ICU_DATA_FILE) found: #endif #ifdef _WIN32 if (memMappedData) { /* * Tell ICU to use this mapped data. */ UErrorCode uerr = U_ZERO_ERROR; ASSERT(memMappedData); udata_setCommonData(memMappedData, &uerr); if (uerr != U_ZERO_ERROR) { UnmapViewOfFile(memMappedData); goto exit; } udata_setAppData(ICU_DATA_ITEM, memMappedData, &uerr); if (uerr != U_ZERO_ERROR) { UnmapViewOfFile(memMappedData); goto exit; } } else { #endif /* * Tell ICU to use this directory. */ u_setDataDirectory(path); #ifdef _WIN32 } #endif dontUseIcu = FALSE; ret = TRUE; exit: if (!ret) { /* * There was an error initing ICU, but if we can fall back on * non-ICU (old CodeSet) then things are OK. */ if (CODESET_CAN_FALLBACK_ON_NON_ICU) { ret = TRUE; dontUseIcu = TRUE; #ifdef _WIN32 OutputDebugStringW(L"CodeSet_Init: no ICU\n"); #endif } } #ifdef _WIN32 free(modPath); if (hMapping) { CloseHandle(hMapping); } if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); } #endif free(path); DynBuf_Destroy(&dbpath); return ret; #endif }
void QsDebugOutput::output( const QString& message ) { OutputDebugStringW(reinterpret_cast<const WCHAR*>(message.utf16())); OutputDebugStringW(L"\n"); }
static void vprintf_stderr_common(const char* format, va_list args) { #if PLATFORM(MAC) if (strstr(format, "%@")) { CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8); CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args); int length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); char* buffer = (char*)malloc(length + 1); CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8); fputs(buffer, stderr); free(buffer); CFRelease(str); CFRelease(cfFormat); } else #elif COMPILER(MSVC) && !defined(WINCEBASIC) # if !defined(_WIN32_WCE) || (_WIN32_WCE >= 0x600) if (IsDebuggerPresent()) # endif { size_t size = 1024; do { char* buffer = (char*)malloc(size); if (buffer == NULL) break; if (_vsnprintf(buffer, size, format, args) != -1) { #if OS(WINCE) // WinCE only supports wide chars wchar_t* wideBuffer = (wchar_t*)malloc(size * sizeof(wchar_t)); if (wideBuffer == NULL) break; for (unsigned int i = 0; i < size; ++i) { if (!(wideBuffer[i] = buffer[i])) break; } OutputDebugStringW(wideBuffer); free(wideBuffer); #else OutputDebugStringA(buffer); #endif free(buffer); break; } free(buffer); size *= 2; } while (size > 1024); } #endif #if OS(SYMBIAN) vfprintf(stdout, format, args); #else vfprintf(stderr, format, args); #endif }
/* * ucmStandardAutoElevation * * Purpose: * * Leo Davidson AutoElevation method with derivatives. * * M1W7 - Original Leo Davidson concept. * M1W8 - Windows 8.1 adapted M1W7 (bypassing sysprep embedded manifest dlls redirection). * M1W7T - Leo Davidson concept with different target dll, used by Win32/Tilon. * M1W10 - Windows 10 adapter M1W7. * M1WALL - WinNT/Pitou derivative from Leo Davidson concept. * */ BOOL ucmStandardAutoElevation( DWORD dwType, CONST PVOID ProxyDll, DWORD ProxyDllSize ) { BOOL cond = FALSE, bResult = FALSE; HINSTANCE hKrnl, hOle32, hShell32; LPWSTR lpSourceDll, lpTargetDir, lpTargetProcess; WCHAR szBuffer[MAX_PATH + 1]; switch (dwType) { case METHOD_SYSPREP1: lpSourceDll = M1W7_SOURCEDLL; lpTargetDir = M1W7_TARGETDIR; lpTargetProcess = M1W7_TARGETPROCESS; break; case METHOD_SYSPREP2: lpSourceDll = M1W8_SOURCEDLL; lpTargetDir = M1W7_TARGETDIR; lpTargetProcess = M1W7_TARGETPROCESS; break; case METHOD_SYSPREP3: lpSourceDll = M1W10_SOURCEDLL; lpTargetDir = M1W7_TARGETDIR; lpTargetProcess = M1W7_TARGETPROCESS; break; case METHOD_OOBE: lpSourceDll = M1WALL_SOURCEDLL; lpTargetDir = M1WALL_TARGETDIR; lpTargetProcess = M1WALL_TARGETPROCESS; break; case METHOD_TILON: lpSourceDll = M1W7T_SOURCEDLL; lpTargetDir = M1W7_TARGETDIR; lpTargetProcess = M1W7_TARGETPROCESS; break; default: return FALSE; } do { // load/reference required dlls hKrnl = GetModuleHandle(KERNEL32DLL); hOle32 = GetModuleHandle(OLE32DLL); if (hOle32 == NULL) { hOle32 = LoadLibrary(OLE32DLL); if (hOle32 == NULL) { break; } } hShell32 = GetModuleHandle(SHELL32DLL); if (hShell32 == NULL) { hShell32 = LoadLibrary(SHELL32DLL); if (hShell32 == NULL) { break; } } //source filename if (ExpandEnvironmentStringsW(lpSourceDll, g_ElevParams.SourceFilePathAndName, MAX_PATH) == 0) { break; } OutputDebugStringW(g_ElevParams.SourceFilePathAndName); if (!supWriteBufferToFile(g_ElevParams.SourceFilePathAndName, ProxyDll, ProxyDllSize)) { break; } //dest directory RtlSecureZeroMemory(szBuffer, sizeof(szBuffer)); _strcpy_w(szBuffer, lpTargetDir); if (ExpandEnvironmentStringsW(szBuffer, g_ElevParams.DestinationDir, MAX_PATH) == 0) { break; } OutputDebugStringW(g_ElevParams.DestinationDir); //target RtlSecureZeroMemory(szBuffer, sizeof(szBuffer)); _strcpy_w(szBuffer, lpTargetProcess); if (ExpandEnvironmentStringsW(szBuffer, g_ElevParams.ExePathAndName, MAX_PATH) == 0) { break; } OutputDebugStringW(g_ElevParams.ExePathAndName); //elevation moniker _strcpy_w(g_ElevParams.EleMoniker, L"Elevation:Administrator!new:{3ad05575-8857-4850-9277-11b85bdb8e09}"); g_ElevParams.xIID = IID_IFileOperation; g_ElevParams.xIID_IShellItem = IID_IShellItem; g_ElevParams.xCLSID = CLSID_FileOperation; g_ElevParams.xCoInitialize = (pfnCoInitialize)GetProcAddress(hOle32, "CoInitialize"); g_ElevParams.xCoCreateInstance = (pfnCoCreateInstance)GetProcAddress(hOle32, "CoCreateInstance"); g_ElevParams.xCoGetObject = (pfnCoGetObject)GetProcAddress(hOle32, "CoGetObject"); g_ElevParams.xCoUninitialize = (pfnCoUninitialize)GetProcAddress(hOle32, "CoUninitialize"); g_ElevParams.xSHCreateItemFromParsingName = (pfnSHCreateItemFromParsingName)GetProcAddress(hShell32, "SHCreateItemFromParsingName"); g_ElevParams.xShellExecuteExW = (pfnShellExecuteExW)GetProcAddress(hShell32, "ShellExecuteExW"); g_ElevParams.xWaitForSingleObject = (pfnWaitForSingleObject)GetProcAddress(hKrnl, "WaitForSingleObject"); g_ElevParams.xCloseHandle = (pfnCloseHandle)GetProcAddress(hKrnl, "CloseHandle"); bResult = ucmInjectExplorer(&g_ElevParams, ucmElevatedLoadProc); } while (cond); return bResult; }
BOOL ReloadFarInfoW995(/*BOOL abFull*/) { if (!InfoW995 || !FSFW995) return FALSE; if (!gpFarInfo) { _ASSERTE(gpFarInfo!=NULL); return FALSE; } // Заполнить gpFarInfo-> //BYTE nFarColors[col_LastIndex]; // Массив цветов фара //DWORD nFarInterfaceSettings; //DWORD nFarPanelSettings; //DWORD nFarConfirmationSettings; //BOOL bFarPanelAllowed, bFarLeftPanel, bFarRightPanel; // FCTL_CHECKPANELSEXIST, FCTL_GETPANELSHORTINFO,... //CEFAR_SHORT_PANEL_INFO FarLeftPanel, FarRightPanel; DWORD ldwConsoleMode = 0; GetConsoleMode(/*ghConIn*/GetStdHandle(STD_INPUT_HANDLE), &ldwConsoleMode); #ifdef _DEBUG static DWORD ldwDbgMode = 0; if (IsDebuggerPresent()) { if (ldwDbgMode != ldwConsoleMode) { wchar_t szDbg[128]; _wsprintf(szDbg, SKIPLEN(countof(szDbg)) L"Far.ConEmuW: ConsoleMode(STD_INPUT_HANDLE)=0x%08X\n", ldwConsoleMode); OutputDebugStringW(szDbg); ldwDbgMode = ldwConsoleMode; } } #endif gpFarInfo->nFarConsoleMode = ldwConsoleMode; LoadFarColorsW995(gpFarInfo->nFarColors); //_ASSERTE(FPS_SHOWCOLUMNTITLES==0x20 && FPS_SHOWSTATUSLINE==0x40); //-V112 LoadFarSettingsW995(&gpFarInfo->FarInterfaceSettings, &gpFarInfo->FarPanelSettings); //gpFarInfo->nFarConfirmationSettings = // (DWORD)InfoW995->AdvControl(InfoW995->ModuleNumber, ACTL_GETCONFIRMATIONS, 0); gpFarInfo->bMacroActive = IsMacroActiveW995(); ActlKeyMacro area = {MCMD_GETAREA}; INT_PTR nArea = InfoW995->AdvControl(InfoW995->ModuleNumber, ACTL_KEYMACRO, &area); switch(nArea) { case MACROAREA_SHELL: case MACROAREA_INFOPANEL: case MACROAREA_QVIEWPANEL: case MACROAREA_TREEPANEL: case MACROAREA_SEARCH: gpFarInfo->nMacroArea = fma_Panels; break; case MACROAREA_VIEWER: gpFarInfo->nMacroArea = fma_Viewer; break; case MACROAREA_EDITOR: gpFarInfo->nMacroArea = fma_Editor; break; case MACROAREA_DIALOG: case MACROAREA_DISKS: case MACROAREA_FINDFOLDER: case MACROAREA_AUTOCOMPLETION: case MACROAREA_MAINMENU: case MACROAREA_MENU: case MACROAREA_USERMENU: gpFarInfo->nMacroArea = fma_Dialog; break; default: gpFarInfo->nMacroArea = fma_Unknown; } gpFarInfo->bFarPanelAllowed = InfoW995->Control(PANEL_NONE, FCTL_CHECKPANELSEXIST, 0, 0); gpFarInfo->bFarPanelInfoFilled = FALSE; gpFarInfo->bFarLeftPanel = FALSE; gpFarInfo->bFarRightPanel = FALSE; // -- пока, во избежание глюков в FAR при неожиданных запросах информации о панелях //if (FALSE == (gpFarInfo->bFarPanelAllowed)) { // gpConMapInfo->bFarLeftPanel = FALSE; // gpConMapInfo->bFarRightPanel = FALSE; //} else { // PanelInfo piA = {}, piP = {}; // BOOL lbActive = InfoW995->Control(PANEL_ACTIVE, FCTL_GETPANELINFO, 0, (LONG_PTR)&piA); // BOOL lbPassive = InfoW995->Control(PANEL_PASSIVE, FCTL_GETPANELINFO, 0, (LONG_PTR)&piP); // if (!lbActive && !lbPassive) // { // gpConMapInfo->bFarLeftPanel = FALSE; // gpConMapInfo->bFarRightPanel = FALSE; // } else { // PanelInfo *ppiL = NULL; // PanelInfo *ppiR = NULL; // if (lbActive) { // if (piA.Flags & PFLAGS_PANELLEFT) ppiL = &piA; else ppiR = &piA; // } // if (lbPassive) { // if (piP.Flags & PFLAGS_PANELLEFT) ppiL = &piP; else ppiR = &piP; // } // gpConMapInfo->bFarLeftPanel = ppiL!=NULL; // gpConMapInfo->bFarRightPanel = ppiR!=NULL; // if (ppiL) FarPanel2CePanel(ppiL, &(gpConMapInfo->FarLeftPanel)); // if (ppiR) FarPanel2CePanel(ppiR, &(gpConMapInfo->FarRightPanel)); // } //} return TRUE; }
void CNTService::Running(DWORD dwArgc,LPTSTR *lpszArgv) { int index = 0; m_hStopEvent = CreateEventW(NULL, // default security attributes TRUE, // manual reset event FALSE, // not signaled NULL); // no name if (NULL == m_hStopEvent) { ReportSvcStatus(SERVICE_STOPPED,NO_ERROR,0); return; } m_hOnlyMutex = CreateMutex(NULL,FALSE,m_wszMutexName); if (NULL != m_hOnlyMutex) { if (ERROR_ALREADY_EXISTS == GetLastError()) { ReportSvcStatus(SERVICE_STOPPED,NO_ERROR,0); return; } } else { ReportSvcStatus(SERVICE_STOPPED,NO_ERROR,0); return; } //Report running status when initialization is complete. ReportSvcStatus(SERVICE_RUNNING,NO_ERROR,0); //Perform work until service stops. for (index = 0; index < m_nWorkDispCount; index++) { m_lpWorkDispHandles[index] = CreateThread(NULL,0,m_lpWorkDisp[index].pDisHandler, m_lpWorkDisp[index].lpParam,0,NULL); if (NULL != m_lpWorkDispHandles[index]) { OutputDebugStringW(L"SVR: CreateThread() OK!"); } } OutputDebugStringW(L"SVR: call WaitForSingleObject()!"); //Check whether to stop the service. WaitForSingleObject(m_hStopEvent,INFINITE); OutputDebugStringW(L"SVR: WaitForSingleObject() OK!"); for (index = 0; index < m_nWorkDispCount; index++) { //stop thread by event_name. if (NULL != m_lpWorkDispHandles[index]) { HANDLE hThreadStopEvent = OpenEventW(EVENT_MODIFY_STATE,FALSE,m_lpWorkDisp[index].wszStopEventName); if (NULL != hThreadStopEvent) { SetEvent(hThreadStopEvent); WaitForSingleObject(m_lpWorkDispHandles[index],INFINITE); CloseHandle(hThreadStopEvent); hThreadStopEvent = NULL; } CloseHandle(m_lpWorkDispHandles[index]); m_lpWorkDispHandles[index] = NULL; } } OutputDebugStringW(L"SVR: Service over!"); ReportSvcStatus(SERVICE_STOPPED,NO_ERROR,0); }
void CSXSView::OnTimer(UINT_PTR nIDEvent) { CAutoBrowser AutoBrowser((IWebBrowser2 *)GetApplication(),GetIEServerWnd()); if (nIDEvent == TIME_ID_INPUT_LOGIN) { KillTimer(nIDEvent); //输入用户名 { CElementInformation ElemInfo; ElemInfo.SetTagName(L"input"); ElemInfo.AddElementAttribute(L"id",L"edit-name",TRUE); CElemRectList ElemList; AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo); if (ElemList.GetElemRectCount() == 1) { ELEM_RECT ElemRect; ElemList.GetElemRectByIndex(0,&ElemRect); CComQIPtr<IHTMLInputElement> pInput; ElemRect.pElem->QueryInterface(IID_IHTMLInputElement,(void **)&pInput); pInput->put_value(theApp.m_strUserName.AllocSysString()); } } //输入密码 { CElementInformation ElemInfo; ElemInfo.SetTagName(L"input"); ElemInfo.AddElementAttribute(L"id",L"edit-pass",TRUE); CElemRectList ElemList; AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo); if (ElemList.GetElemRectCount() == 1) { ELEM_RECT ElemRect; ElemList.GetElemRectByIndex(0,&ElemRect); CComQIPtr<IHTMLInputElement> pInput; ElemRect.pElem->QueryInterface(IID_IHTMLInputElement,(void **)&pInput); pInput->put_value(theApp.m_strPassWord.AllocSysString()); } } //选中验证码框 { CElementInformation ElemInfo; ElemInfo.SetTagName(L"input"); ElemInfo.AddElementAttribute(L"id",L"edit-captcha-response",TRUE); AutoBrowser.ClickFirstMatchWebPageElement(&ElemInfo); } } if (nIDEvent == TIME_ID_MOUSE_MOVE) { CRect rcClient; GetClientRect(&rcClient); AutoBrowser.SetWebPageMousePos(CAutoBrowser::GetRandValue(0,rcClient.Width()),CAutoBrowser::GetRandValue(0,rcClient.Height())); } if ( nIDEvent == TIME_ID_QUERY_USER_INFO ) { KillTimer(nIDEvent); CString strUserRealName; CElementInformation ElemInfo; ElemInfo.SetTagName(L"a"); ElemInfo.AddElementAttribute(L"href",L"/admin/std/info",TRUE); CElementInformation *pParentInfo = ElemInfo.CreateParentInfo(); pParentInfo->SetTagName(L"span"); pParentInfo->AddElementAttribute(L"class",L"user-title",TRUE); CElemRectList ElemList; AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo); if (ElemList.GetElemRectCount() == 1) { ELEM_RECT ElemRect; ElemList.GetElemRectByIndex(0,&ElemRect); CComQIPtr<IHTMLElement> pElem; ElemRect.pElem->QueryInterface(IID_IHTMLElement,(void **)&pElem); if (pElem) { CComBSTR bstrInnerText; pElem->get_innerText(&bstrInnerText); strUserRealName = bstrInnerText; } } CMainFrame *pParentFrame = (CMainFrame *)GetParent(); if (pParentFrame) { pParentFrame->UpdateFrameTitle(theApp.m_strUserName+L" "+strUserRealName); g_loger.StatusOut(L"获取用户信息:%s %s",theApp.m_strUserName,strUserRealName); } } if( nIDEvent == TIME_ID_CLICK_WATCH_CONTINE ) { KillTimer(nIDEvent); CElementInformation ElemInfo; ElemInfo.SetTagName(L"a"); ElemInfo.SetTextName(L"继续观看",FALSE); ElemInfo.AddElementAttribute(L"href",L"/admin/std/training/",FALSE); AutoBrowser.ClickFirstMatchWebPageElement(&ElemInfo); g_loger.StatusOut(L"点击继续学习按钮"); } if ( nIDEvent == TIME_ID_CLICK_RESUME ) { KillTimer(nIDEvent); CElementInformation ElemInfo; CElemRectList ElemList; ElemInfo.SetTagName(L"object"); ElemInfo.AddElementAttribute(L"id",L"VMSPlayer",TRUE); AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo); if ( ElemList.GetElemRectCount() == 1 ) { // 51 382 ELEM_RECT ElemRect; ElemList.GetElemRectByIndex(0,&ElemRect); AutoBrowser.ClickWebPagePoint(ElemRect.rcElem.left+51,ElemRect.rcElem.top+382); g_loger.StatusOut(L"点击重新观看按钮 X:%d Y:%d",ElemRect.rcElem.left+51,ElemRect.rcElem.top+382); } } if ( nIDEvent == TIME_ID_CHECK_VIDEO_PAUSE ) { CElementInformation ElemInfo; CElemRectList ElemList; ElemInfo.SetTagName(L"object"); ElemInfo.AddElementAttribute(L"id",L"VMSPlayer",TRUE); AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo); if ( ElemList.GetElemRectCount() == 1 ) { // 51 382 ELEM_RECT ElemRect; ElemList.GetElemRectByIndex(0,&ElemRect); CRect rcElem; rcElem = ElemRect.rcElem; CPoint ptCenter; ptCenter = rcElem.CenterPoint(); COLORREF refColor = 0; HDC hDc = ::GetDC(GetIEServerWnd()); refColor = GetPixel(hDc,ptCenter.x,ptCenter.y); ::ReleaseDC(GetIEServerWnd(),hDc); if ( m_refPreColor == refColor ) { m_nColorSameCount++; } else { m_nColorSameCount=0; } m_refPreColor = refColor; if ( m_nColorSameCount > 20 ) { g_loger.StatusOut(L"窗口定点颜色 %x 超过 20*5 秒没有变化",m_refPreColor); KillTimer(nIDEvent); CElementInformation ElemInfo; ElemInfo.SetTagName(L"input"); ElemInfo.AddElementAttribute(L"value",L"退出学习",FALSE); //ElemInfo.AddElementAttribute(L"type",L"submit",TRUE); AutoBrowser.ClickFirstMatchWebPageElement(&ElemInfo); } #ifdef DEBUG CString strMsgOut; strMsgOut.Format(L"0x%x\r\n",refColor); OutputDebugStringW(strMsgOut); #endif } } CIECoreView::OnTimer(nIDEvent); }
static void vprintf_stderr_common(bool shouldAssert, const char* format, va_list args) { #if PLATFORM(MAC) if (strstr(format, "%@")) { CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8); CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args); int length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); char* buffer = (char*)malloc(length + 1); CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8); fputs(buffer, stderr); free(buffer); CFRelease(str); CFRelease(cfFormat); return; } #elif PLATFORM(BREWMP) // When str is 0, the return value is the number of bytes needed // to accept the result including null termination. int size = vsnprintf(0, 0, format, args); if (size > 0) { Vector<char> buffer(size); vsnprintf(buffer.data(), size, format, args); printLog(buffer); } #elif PLATFORM(EA) if (JSLogCallback logger = JSGetLogCallback()) { eastl::string8 str; str.sprintf_va_list(format, args); logger(str, shouldAssert); } #if _DEBUG //Print a log in debug in case the logger does not exist yet (For example,Assert before Init is called) else { eastl::string8 str; str.sprintf_va_list(format, args); #if defined(_MSC_VER) OutputDebugStringA(str.c_str()); OutputDebugStringA("\n"); #else printf("%s", str.c_str()); printf("\n"); #endif } #endif //_DEBUG return; #elif HAVE(ISDEBUGGERPRESENT) if (IsDebuggerPresent()) { size_t size = 1024; do { char* buffer = (char*)malloc(size); if (buffer == NULL) break; if (_vsnprintf(buffer, size, format, args) != -1) { #if OS(WINCE) // WinCE only supports wide chars wchar_t* wideBuffer = (wchar_t*)malloc(size * sizeof(wchar_t)); if (wideBuffer == NULL) break; for (unsigned int i = 0; i < size; ++i) { if (!(wideBuffer[i] = buffer[i])) break; } OutputDebugStringW(wideBuffer); free(wideBuffer); #else OutputDebugStringA(buffer); #endif free(buffer); break; } free(buffer); size *= 2; } while (size > 1024); } #endif #if OS(SYMBIAN) vfprintf(stdout, format, args); #else vfprintf(stderr, format, args); #endif }
JsErrorCode StringifyJsTypedArray(JsValueRef value) { JsTypedArrayType arrayType; JsValueRef arrayBuffer; UINT byteOffset, byteLength; IfFailRet(JsGetTypedArrayInfo(value, &arrayType, &arrayBuffer, &byteOffset, &byteLength)); switch (arrayType) { case JsArrayTypeInt8: OutputDebugStringW(L"Int8Array "); break; case JsArrayTypeUint8: OutputDebugStringW(L"Uint8Array "); break; case JsArrayTypeUint8Clamped: OutputDebugStringW(L"Uint8ClampedArray "); break; case JsArrayTypeInt16: OutputDebugStringW(L"Int16Array "); break; case JsArrayTypeUint16: OutputDebugStringW(L"Uint16Array "); break; case JsArrayTypeInt32: OutputDebugStringW(L"Int32Array "); break; case JsArrayTypeUint32: OutputDebugStringW(L"Uint32Array "); break; case JsArrayTypeFloat32: OutputDebugStringW(L"Float32Array "); break; case JsArrayTypeFloat64: OutputDebugStringW(L"Float64Array "); break; } JsPropertyIdRef lengthId; JsValueRef lengthProp; int lengthValue; IfFailRet(JsGetPropertyIdFromName(L"length", &lengthId)); IfFailRet(JsGetProperty(value, lengthId, &lengthProp)); IfFailRet(JsNumberToInt(lengthProp, &lengthValue)); OutputDebugStringW(L"[ "); for (int i = 0; i < lengthValue; i++) { if (i == DEFAULT_ARRAY_MAX_LENGTH) { OutputDebugStringW(DEFAULT_TRUNCATED_VALUE); break; } JsValueRef index, indexResult; IfFailRet(JsIntToNumber(i, &index)); IfFailRet(JsGetIndexedProperty(value, index, &indexResult)); IfFailRet(StringifyToString(indexResult)); if (i != lengthValue - 1) { OutputDebugStringW(L", "); } else { OutputDebugStringW(L" "); } } OutputDebugStringW(L"]"); return JsNoError; }
void console::vprintf(eConsoleMessageType type, const wchar_t* p, va_list args) { init(); scoped_mutex lock(*m_pMutex); m_num_messages[type]++; wchar_t buf[cConsoleBufSize]; #ifdef _MSC_VER vswprintf_s(buf, cConsoleBufSize, p, args); #else vswprintf(buf, p, args); #endif bool handled = false; if (m_output_funcs.size()) { for (uint i = 0; i < m_output_funcs.size(); i++) if (m_output_funcs[i].m_func(type, buf, m_output_funcs[i].m_pData)) handled = true; } const wchar_t* pPrefix = NULL; if (m_prefixes) { switch (type) { case cDebugConsoleMessage: pPrefix = L"Debug: "; break; case cWarningConsoleMessage: pPrefix = L"Warning: "; break; case cErrorConsoleMessage: pPrefix = L"Error: "; break; default: break; } } if ((!m_output_disabled) && (!handled)) { #ifdef _XBOX if (pPrefix) OutputDebugStringW(pPrefix); OutputDebugStringW(buf); if (m_crlf) OutputDebugStringW(L"\n"); #else if (pPrefix) ::wprintf(pPrefix); ::wprintf(m_crlf ? L"%s\n" : L"%s", buf); #endif } if ((type != cProgressConsoleMessage) && (m_pLog_stream)) { // Yes this is bad. dynamic_wstring utf16_buf(buf); dynamic_string ansi_buf; utf16_buf.as_ansi(ansi_buf); ansi_buf.translate_lf_to_crlf(); m_pLog_stream->printf(m_crlf ? "%s\r\n" : "%s", ansi_buf.get_ptr()); m_pLog_stream->flush(); } }
HRESULT HDMediaSource::Shutdown() { DbgLogPrintf(L"%s::Shutdown...",L"HDMediaSource"); if (_key_frames) free(_key_frames); _key_frames = nullptr; _key_frames_count = 0; if (_pMediaIOEx && _network_mode) _pMediaIOEx->CancelReading(); if (_network_mode) { IMFByteStream* stream = nullptr; if (_pMediaIO) stream = _pMediaIO->GetMFByteStream(); else if (_pMediaIOEx) stream = _pMediaIOEx->GetMFByteStream(); if (stream) stream->Close(); } if (_enterReadPacketFlag) { while (1) { if (!StreamsNeedData()) break; } } CritSec::AutoLock lock(_cs); HRESULT hr = CheckShutdown(); if (FAILED(hr)) return hr; unsigned count = _streamList.Count(); for (unsigned i = 0;i < count;i++) { ComPtr<HDMediaStream> pStream; HRESULT hr = _streamList.GetAt(i,pStream.GetAddressOf()); HR_FAILED_CONTINUE(hr); hr = pStream->Shutdown(); HR_FAILED_RET(hr); } _pChapters = nullptr; _pMetadata = nullptr; if (_pMediaParser != nullptr) { auto ave = _pMediaParser->Close(); if (AVE_FAILED(ave)) { if (IsDebuggerPresent()) OutputDebugStringW(L"Close Parser FAILED!\n"); } } _streamList.Clear(); _pEventQueue->Shutdown(); _pByteStreamTimeSeek.Reset(); _pByteStream.Reset(); _pOpenResult.Reset(); _pEventQueue.Reset(); _pPresentationDescriptor.Reset(); _pMediaIO.reset(); _pMediaIOEx.Reset(); _taskMagicNumber = -1; _state = STATE_SHUTDOWN; DbgLogPrintf(L"%s::Shutdown OK.",L"HDMediaSource"); return S_OK; }
static void vprintf_stderr_common(const char* format, va_list args) { #if USE(CF) && !OS(WINDOWS) if (strstr(format, "%@")) { CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8); #if COMPILER(CLANG) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-nonliteral" #endif CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args); #if COMPILER(CLANG) #pragma clang diagnostic pop #endif CFIndex length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8); char* buffer = (char*)malloc(length + 1); CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8); #if USE(APPLE_SYSTEM_LOG) asl_log(0, 0, ASL_LEVEL_NOTICE, "%s", buffer); #endif fputs(buffer, stderr); free(buffer); CFRelease(str); CFRelease(cfFormat); return; } #if USE(APPLE_SYSTEM_LOG) va_list copyOfArgs; va_copy(copyOfArgs, args); asl_vlog(0, 0, ASL_LEVEL_NOTICE, format, copyOfArgs); va_end(copyOfArgs); #endif // Fall through to write to stderr in the same manner as other platforms. #elif PLATFORM(BLACKBERRY) BBLOGV(BlackBerry::Platform::LogLevelCritical, format, args); #elif HAVE(ISDEBUGGERPRESENT) if (IsDebuggerPresent()) { size_t size = 1024; do { char* buffer = (char*)malloc(size); if (buffer == NULL) break; if (_vsnprintf(buffer, size, format, args) != -1) { #if OS(WINCE) // WinCE only supports wide chars wchar_t* wideBuffer = (wchar_t*)malloc(size * sizeof(wchar_t)); if (wideBuffer == NULL) break; for (unsigned int i = 0; i < size; ++i) { if (!(wideBuffer[i] = buffer[i])) break; } OutputDebugStringW(wideBuffer); free(wideBuffer); #else OutputDebugStringA(buffer); #endif free(buffer); break; } free(buffer); size *= 2; } while (size > 1024); } #endif #if !PLATFORM(BLACKBERRY) vfprintf(stderr, format, args); #endif }
size_t __cdecl Output::PrintBuffer(const wchar_t * buf, size_t size) { Output::s_Column += size; const wchar_t * endbuf = wcschr(buf, '\n'); while (endbuf != nullptr) { Output::s_Column = size - (endbuf - buf) - 1; endbuf = wcschr(endbuf + 1, '\n'); } bool useConsoleOrFile = true; if (!Output::s_capture) { if (Output::s_useDebuggerWindow) { OutputDebugStringW(buf); useConsoleOrFile = false; } #ifdef ENABLE_TRACE if (Output::s_inMemoryLogger) { s_inMemoryLogger->Write(buf); useConsoleOrFile = false; } #endif } if (useConsoleOrFile) { if (s_file == nullptr || Output::s_capture) { bool addToBuffer = true; if (Output::bufferFreeSize < size + 1) { if (Output::bufferAllocSize > MAX_OUTPUT_BUFFER_SIZE && !Output::s_capture) { Output::Flush(); if (Output::bufferFreeSize < size + 1) { DirectPrint(buf); addToBuffer = false; } } else { size_t oldBufferSize = bufferAllocSize - bufferFreeSize; size_t newBufferAllocSize = (bufferAllocSize + size + 1) * 4 / 3; wchar_t * newBuffer = (wchar_t *)realloc(buffer, (newBufferAllocSize * sizeof(wchar_t))); if (newBuffer == nullptr) { // See if I can just flush it and print directly Output::Flush(); // Reset the buffer free(Output::buffer); Output::buffer = nullptr; Output::bufferAllocSize = 0; Output::bufferFreeSize = 0; // Print it directly DirectPrint(buf); addToBuffer = false; } else { bufferAllocSize = newBufferAllocSize; buffer = newBuffer; bufferFreeSize = bufferAllocSize - oldBufferSize; } } } if (addToBuffer) { Assert(Output::bufferFreeSize >= size + 1); memcpy_s(Output::buffer + Output::bufferAllocSize - Output::bufferFreeSize, Output::bufferFreeSize * sizeof(wchar_t), buf, (size + 1) * sizeof(wchar_t)); bufferFreeSize -= size; } } else { fwprintf_s(Output::s_file, L"%s", buf); } if(s_outputFile != nullptr && !Output::s_capture) { fwprintf_s(s_outputFile, L"%s", buf); } } if (IsDebuggerPresent()) { Output::Flush(); } return size; }
BOOL CDeskTopDlg::OnInitDialog() { CDialog::OnInitDialog(); HWND hProgMan = ::FindWindow(L"ProgMan", NULL); if(hProgMan) { HWND hShellDefView = ::FindWindowEx(hProgMan, NULL, L"SHELLDLL_DefView", NULL); if(hShellDefView) m_hWndDesktop = ::FindWindowEx(hShellDefView, NULL, L"SysListView32", NULL); } ::SetParent(m_hWnd,m_hWndDesktop); MoveWindow(0,0,GetSystemMetrics ( SM_CXSCREEN ) ,GetSystemMetrics ( SM_CYSCREEN )); m_DeskIconManager.SetShowWnd(m_hWnd); CFileFind finder; CString strPath; BOOL bWorking = finder.FindFile(L"C:\\Users\\GaoZan\\Desktop\\*.*"); while(bWorking) { bWorking = finder.FindNextFile(); strPath = finder.GetFilePath(); OutputDebugStringW(strPath+L"\n"); if(finder.IsDirectory() && !finder.IsDots()) { int a=0; } else if(!finder.IsDirectory() && !finder.IsDots()) { CString strIconText; strIconText = finder.GetFileTitle(); CString strNotePadPath(strPath); SHFILEINFO stFileInfo; :: SHGetFileInfo( strNotePadPath,0,&stFileInfo,sizeof(stFileInfo),SHGFI_ICON); HICON hIcon = GetFileIcon(strPath); m_DeskIconManager.AddIcon(strIconText,/*stFileInfo.hIcon*/hIcon,strPath); } } bWorking = finder.FindFile(L"C:\\Users\\Public\\Desktop\\*.*"); while(bWorking) { bWorking = finder.FindNextFile(); strPath = finder.GetFilePath(); OutputDebugStringW(strPath+L"\n"); if(finder.IsDirectory() && !finder.IsDots()) { int a=0; } else if(!finder.IsDirectory() && !finder.IsDots()) { CString strIconText; strIconText = finder.GetFileTitle(); CString strNotePadPath(strPath); SHFILEINFO stFileInfo; :: SHGetFileInfo( strNotePadPath,0,&stFileInfo,sizeof(stFileInfo),SHGFI_ICON); HICON hIcon = GetFileIcon(strPath); m_DeskIconManager.AddIcon(strIconText,/*stFileInfo.hIcon*/hIcon,strPath); } } // for (int i=0;i<10;i++) // { // CString strIconText; // strIconText.Format(L"图标_%d",i); // // CString strNotePadPath("C:\\Users\\GaoZan\\Desktop\\ADSafe.lnk"); // SHFILEINFO stFileInfo; // :: SHGetFileInfo( strNotePadPath,0,&stFileInfo,sizeof(stFileInfo),SHGFI_ICON); // // m_DeskIconManager.AddIcon(strIconText,stFileInfo.hIcon); // } return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }
template<> void basic_debugbuf<wchar_t>::output_debug_string(const wchar_t *text) { OutputDebugStringW(text); }
virtual void write(const Record& record) // This is a method from IAppender that MUST be implemented. { util::nstring str = Formatter::format(record); // Use the formatter to get a string from a record. OutputDebugStringW(str.c_str()); }
HRESULT CCodec::LoadFormats(IWMCodecInfo2* pICodecInfo, GUID guidType, int nIndex) { HRESULT hr = S_OK; DWORD dwFormatCount = 0; hr = pICodecInfo->GetCodecFormatCount(guidType, nIndex, &dwFormatCount); if (FAILED(hr)) return hr; OutputDebugString("\n\nListing formats for AudioCodec:"); OutputDebugStringW(m_strCodecName); OutputDebugStringW(L"\n\n"); for (int i=0;i<(long)dwFormatCount;i++) { DWORD dwCount = 0; hr = pICodecInfo->GetCodecFormatDesc(guidType, nIndex, i, NULL, NULL, &dwCount); if (SUCCEEDED(hr)) { CComPtr<IWMStreamConfig> pStreamConfig; WCHAR *wszDesc = new WCHAR[ dwCount + 1 ]; hr = pICodecInfo->GetCodecFormatDesc(guidType, nIndex, i, &pStreamConfig, wszDesc, &dwCount); if (SUCCEEDED(hr)) { DWORD dwBitrate = 0; pStreamConfig->GetBitrate(&dwBitrate); char sz[128]; sprintf(sz, "Bitrate=%lu\n", dwBitrate); OutputDebugString(sz); Format* pFormat = new Format; pFormat->strName = wszDesc; pFormat->nFormatIndex = i; pFormat->dwBitrate = dwBitrate; m_arrFormats.Add(pFormat); if (m_codecGuid == WMMEDIASUBTYPE_ACELPnet) { if (dwBitrate >= 16000) m_nIdealCodecFormat = i; } else if (m_codecGuid == WMMEDIASUBTYPE_WMSP1) { if (dwBitrate >= 20000) m_nIdealCodecFormat = i; } else if (m_codecGuid == WMMEDIASUBTYPE_WMAudioV9 || m_codecGuid == WMMEDIASUBTYPE_WMAudioV8 || m_codecGuid == WMMEDIASUBTYPE_WMAudioV7) { //if (dwBitrate > 192000 ) // m_nIdealCodecFormat = i; } else { m_nIdealCodecFormat = i; // last listed format, usually maximum } } delete [] wszDesc; pStreamConfig = NULL; } } return NOERROR; }
// Log format : "<LogType> <ThreadNo> <FileName> <Line> <ProcessName> : <Msg>" void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message ) { bool needSpace = false; //stringstream ss; string str; if (args.LogType != CLog::LOG_NO) { //ss << logTypeToString(args.LogType); str += logTypeToString(args.LogType); needSpace = true; } // Write thread identifier if ( args.ThreadId != 0 ) { //ss << setw(5) << args.ThreadId; if (needSpace) { str += " "; needSpace = false; } #ifdef NL_OS_WINDOWS str += NLMISC::toString("%5x", args.ThreadId); #else str += NLMISC::toString("%08x", args.ThreadId); #endif needSpace = true; } if (args.FileName != NULL) { //if (needSpace) { ss << " "; needSpace = false; } if (needSpace) { str += " "; needSpace = false; } //ss << CFile::getFilename(args.FileName); str += CFile::getFilename(args.FileName); needSpace = true; } if (args.Line != -1) { //if (needSpace) { ss << " "; needSpace = false; } if (needSpace) { str += " "; needSpace = false; } //ss << args.Line; str += NLMISC::toString(args.Line); needSpace = true; } if (args.FuncName != NULL) { //if (needSpace) { ss << " "; needSpace = false; } if (needSpace) { str += " "; needSpace = false; } //ss << args.FuncName; str += args.FuncName; needSpace = true; } if (!args.ProcessName.empty()) { //if (needSpace) { ss << " "; needSpace = false; } if (needSpace) { str += " "; needSpace = false; } //ss << args.ProcessName; str += args.ProcessName; needSpace = true; } //if (needSpace) { ss << " : "; needSpace = false; } if (needSpace) { str += " : "; needSpace = false; } //ss << message; str += message; // string s = ss.str(); static bool consoleMode = true; #if defined(NL_OS_WINDOWS) static bool consoleModeTest = false; if (!consoleModeTest) { HANDLE handle = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); consoleMode = handle != INVALID_HANDLE_VALUE; if (consoleMode) CloseHandle (handle); consoleModeTest = true; } #endif // NL_OS_WINDOWS // Printf ? if (consoleMode) { // we don't use cout because sometimes, it crashs because cout isn't already init, printf doesn t crash. if (!str.empty()) printf ("%s", str.c_str()); if (!args.CallstackAndLog.empty()) printf ("%s", args.CallstackAndLog.c_str()); fflush(stdout); } #ifdef NL_OS_WINDOWS // display the string in the debugger is the application is started with the debugger if (IsDebuggerPresent ()) { //stringstream ss2; string str2; needSpace = false; if (args.FileName != NULL) str2 += args.FileName; if (args.Line != -1) { str2 += "(" + NLMISC::toString(args.Line) + ")"; needSpace = true; } if (needSpace) { str2 += " : "; needSpace = false; } if (args.FuncName != NULL) str2 += string(args.FuncName) + " "; if (args.LogType != CLog::LOG_NO) { str2 += logTypeToString(args.LogType); needSpace = true; } // Write thread identifier if ( args.ThreadId != 0 ) { str2 += NLMISC::toString("%5x: ", args.ThreadId); } str2 += message; const sint maxOutString = 2*1024; if(str2.size() < maxOutString) { ////////////////////////////////////////////////////////////////// // WARNING: READ THIS !!!!!!!!!!!!!!!! /////////////////////////// // If at the release time, it freezes here, it's a microsoft bug: // http://support.microsoft.com/support/kb/articles/q173/2/60.asp OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(str2).c_str()); } else { /*OutputDebugString(ss2.str().c_str()); OutputDebugString("\n\t\t\t"); OutputDebugString("message end: "); OutputDebugString(&message[strlen(message) - 1024]); OutputDebugString("\n");*/ sint count = 0; uint n = (uint)strlen(message); std::string s(&str2.c_str()[0], (str2.size() - n)); OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str()); for(;;) { if((n - count) < maxOutString ) { s = std::string(&message[count], (n - count)); OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str()); OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8("\n").c_str()); break; } else { s = std::string(&message[count] , count + maxOutString); OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str()); OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8("\n\t\t\t").c_str()); count += maxOutString; } } } // OutputDebugString is a big shit, we can't display big string in one time, we need to split uint32 pos = 0; string splited; for(;;) { if (pos+1000 < args.CallstackAndLog.size ()) { splited = args.CallstackAndLog.substr (pos, 1000); OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(splited).c_str()); pos += 1000; } else { splited = args.CallstackAndLog.substr (pos); OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(splited).c_str()); break; } } } #endif }
void trick1() { for(int i=0;i<1000;i++,OutputDebugStringW(GetCommandLineW())){} }
double CUniversalKriging::Evaluate(const CGridPoint& pt, int iXval)const { //if variogram is not initialised correckly, we retuern no data; if (!m_pVariogram->IsInit()) return m_param.m_noData; // Find the nearest samples: CGridPointVector va; Init_va(pt, iXval, va); int mdt = GetMDT(); // Test number of samples found: // Test if there are enough samples to estimate all drift terms: if ((int)va.size() < m_p.m_nbPoint || (int)va.size() <= mdt) return m_param.m_noData; if ( /*iXval<0 &&*/ va[0].GetDistance(pt) > m_param.m_maxDistance) return m_param.m_noData; // There are enough samples - proceed with estimation. // Go ahead and set up the OK portion of the kriging matrix: NEWMAT::ColumnVector r; NEWMAT::Matrix a; Init_a(pt, va, a); Init_r(pt, va, r); // If estimating the trend then reset all the right hand side terms=0.0: if (m_p.m_bTrend) r = 0; //copy r to compute variance NEWMAT::ColumnVector rr(r); // Solve the kriging system: int neq = mdt + int(va.size()); //reduce the matrix until the 2/3 of the number of neightbor bool bOK = false; while (!bOK && neq >= mdt + m_p.m_nbPoint * 2 / 3)//by RSA 25/10/2010 { Try { a = a.i(); bOK = true; } Catch(NEWMAT::Exception) { OutputDebugStringW(L"a=a.i() failled; Reduce number of point"); Init_a(pt, va, a); Init_r(pt, va, r); neq--; int firstRow = 1 + mdt + int(va.size()) - neq; a = a.SubMatrix(firstRow, a.Nrows(), firstRow, a.Ncols()); r = r.SubMatrix(firstRow, r.Nrows(), 1, 1); } if (m_pAgent && m_pAgent->TestConnection(m_hxGridSessionID) == S_FALSE) throw(CHxGridException()); } //if we don't solve system, return missing if (!bOK) return m_param.m_noData; NEWMAT::ColumnVector s = a*r; CDiscretisation m_discr; m_discr.Initialization(pt, *m_pVariogram, m_p, m_param.m_bFillNugget); // Compute the solution: double uuk = 0.0; double ukv = m_discr.cbb; for (int j = 0; j < neq; j++) { ukv -= s[j] * rr[j]; if (j < (int)va.size()) uuk += s[j] * (m_prePostTransfo.Transform(va[j].m_event) - m_p.m_SKmean); } uuk += m_p.m_SKmean; uuk = m_prePostTransfo.InvertTransform(uuk, m_param.m_noData); // if ( /*iXval<0 &&*/ m_param.m_bRegionalLimit && uuk > m_param.m_noData) { CStatistic stat; for (size_t i = 0; i < va.size(); i++) stat += va[i].m_event; bool bOutside = uuk<stat[LOWEST] - m_param.m_regionalLimitSD*stat[STD_DEV] || uuk>stat[HIGHEST] + m_param.m_regionalLimitSD*stat[STD_DEV]; if (bOutside) { if (m_param.m_bRegionalLimitToBound) uuk = min(stat[HIGHEST] + m_param.m_regionalLimitSD*stat[STD_DEV], max(stat[LOWEST] - m_param.m_regionalLimitSD*stat[STD_DEV], uuk)); else uuk = m_param.m_noData; } } if ( /*iXval<0 &&*/ m_param.m_bGlobalLimit && uuk > m_param.m_noData) { bool bOutside = uuk<m_stat[LOWEST] - m_param.m_globalLimitSD*m_stat[STD_DEV] || uuk>m_stat[HIGHEST] + m_param.m_globalLimitSD*m_stat[STD_DEV]; if (bOutside) { if (m_param.m_bGlobalLimitToBound) uuk = min(m_stat[HIGHEST] + m_param.m_globalLimitSD*m_stat[STD_DEV], max(m_stat[LOWEST] - m_param.m_globalLimitSD*m_stat[STD_DEV], uuk)); else uuk = m_param.m_noData; } } if ( /*iXval<0 &&*/ m_param.m_bGlobalMinMaxLimit && uuk > m_param.m_noData) { bool bOutside = uuk<m_param.m_globalMinLimit || uuk>m_param.m_globalMaxLimit; if (bOutside) { if (m_param.m_bGlobalMinMaxLimitToBound) uuk = min(m_param.m_globalMaxLimit, max(m_param.m_globalMinLimit, uuk)); else uuk = m_param.m_noData; } } return uuk; }