void CTemplatesCfg::SaveSettings( CIniConfig& ini ) { FarFileName Root = FarFileName(ini.GetIniFileName()).GetPath(); FarFileName Def = FarFileName(ini.GetIniFileName()).GetPath(); Def.SetName("MailView.tpl"); Def = ExtractRelativePath(Root, Def); WriteString(ini, INI_MAILVIEW, "qTpl", ExtractRelativePath(Root, FixTpl(m_qTpl)), Def); WriteString(ini, INI_MAILVIEW, "eTpl", ExtractRelativePath(Root, FixTpl(m_eTpl)), Def); WriteString(ini, INI_MAILVIEW, "vTpl", ExtractRelativePath(Root, FixTpl(m_vTpl)), Def); }
void SVNListBase::GetSelectedFiles ( JPtrArray<JString>* fullNameList, const JBoolean includeDeleted ) { fullNameList->CleanOut(); fullNameList->SetCleanUpAction(JPtrArrayT::kDeleteAll); JTableSelection& s = GetTableSelection(); JTableSelectionIterator iter(&s); JString name, fullName; JPoint cell; const JString& basePath = GetPath(); while (iter.Next(&cell)) { const JString* line = itsLineList->NthElement(cell.y); name = ExtractRelativePath(*line); const JBoolean exists = JConvertToAbsolutePath(name, basePath, &fullName); if (exists || includeDeleted) { fullNameList->Append(fullName); } } }
void SVNListBase::ReceiveMessageLine() { assert( itsMessageLink != NULL ); JString line; const JBoolean ok = itsMessageLink->GetNextMessage(&line); assert( ok ); if (!ShouldDisplayLine(&line)) { return; } const JFontStyle red(kJTrue, kJFalse, 0, kJFalse, (GetColormap())->GetRedColor()); const JFontStyle blue = (GetColormap())->GetBlueColor(); const JFontStyle strike(kJFalse, kJFalse, 0, kJTrue); JString* temp = new JString(line); assert( temp != NULL ); JIndex i; itsLineList->InsertSorted(temp, kJTrue, &i); StyleLine(i, line, red, blue, strike); JString relPath = ExtractRelativePath(line); JIndex j; if (itsSavedSelection->SearchSorted(&relPath, JOrderedSetT::kAnyMatch, &j)) { (GetTableSelection()).SelectRow(i); } }
void SVNListBase::RefreshContent() { if (itsProcess != NULL) { JProcess* p = itsProcess; itsProcess = NULL; p->Kill(); delete p; DeleteLinks(); } else { itsSavedSelection->CleanOut(); JTableSelection& s = GetTableSelection(); JTableSelectionIterator iter(&s); JPoint cell; while (iter.Next(&cell)) { const JString* line = itsLineList->NthElement(cell.y); itsSavedSelection->InsertSorted(new JString(ExtractRelativePath(*line))); } } itsDisplayState = SaveDisplayState(); itsLineList->CleanOut(); int outFD, errFD; JError err = JNoError(); if ((GetDirector())->HasPath()) { err = JProcess::Create(&itsProcess, GetPath(), itsCmd, kJIgnoreConnection, NULL, kJCreatePipe, &outFD, kJCreatePipe, &errFD); } else // working with URL { err = JProcess::Create(&itsProcess, itsCmd, kJIgnoreConnection, NULL, kJCreatePipe, &outFD, kJCreatePipe, &errFD); } if (err.OK()) { itsProcess->ShouldDeleteWhenFinished(); ListenTo(itsProcess); (GetDirector())->RegisterActionProcess(this, itsProcess, itsRefreshRepoFlag, itsRefreshStatusFlag, itsReloadOpenFilesFlag); SetConnection(outFD, errFD); } else { err.ReportIfError(); } }
void FWindowsPlatformStackWalkExt::GetModuleInfoDetailed() { // The the number of loaded modules ULONG LoadedModuleCount = 0; ULONG UnloadedModuleCount = 0; Symbol->GetNumberModules( &LoadedModuleCount, &UnloadedModuleCount ); CrashInfo.Modules.Empty( LoadedModuleCount ); for( uint32 ModuleIndex = 0; ModuleIndex < LoadedModuleCount; ModuleIndex++ ) { FCrashModuleInfo* CrashModule = new ( CrashInfo.Modules ) FCrashModuleInfo(); ULONG64 ModuleBase = 0; Symbol->GetModuleByIndex( ModuleIndex, &ModuleBase ); // Get the full path of the module name TCHAR ModuleName[MAX_PATH] = { 0 }; Symbol->GetModuleNameStringWide( DEBUG_MODNAME_IMAGE, ModuleIndex, ModuleBase, ModuleName, MAX_PATH, NULL ); FString RelativeModuleName = ExtractRelativePath( TEXT( "binaries" ), ModuleName ); if( RelativeModuleName.Len() > 0 ) { CrashModule->Name = RelativeModuleName; } else { CrashModule->Name = ModuleName; } CrashModule->Extension = CrashModule->Name.Right( 4 ).ToLower(); CrashModule->BaseOfImage = ModuleBase; DEBUG_MODULE_PARAMETERS ModuleParameters = { 0 }; Symbol->GetModuleParameters( 1, NULL, ModuleIndex, &ModuleParameters ); CrashModule->SizeOfImage = ModuleParameters.Size; VS_FIXEDFILEINFO VersionInfo = { 0 }; Symbol->GetModuleVersionInformationWide( ModuleIndex, ModuleBase, TEXT( "\\" ), &VersionInfo, sizeof( VS_FIXEDFILEINFO ), NULL ); CrashModule->Major = HIWORD( VersionInfo.dwProductVersionMS ); CrashModule->Minor = LOWORD( VersionInfo.dwProductVersionMS ); CrashModule->Patch = HIWORD( VersionInfo.dwProductVersionLS ); CrashModule->Revision = LOWORD( VersionInfo.dwProductVersionLS ); // Ensure all the images are synced - need the full path here Symbol->ReloadWide( *CrashModule->Name ); } CrashInfo.Modules.Sort( FSortModulesByName() ); }
void FWindowsPlatformStackWalkExt::GetExeFileVersionAndModuleList( FCrashModuleInfo& out_ExeFileVersion ) { // The the number of loaded modules ULONG LoadedModuleCount = 0; ULONG UnloadedModuleCount = 0; Symbol->GetNumberModules( &LoadedModuleCount, &UnloadedModuleCount ); UE_LOG( LogCrashDebugHelper, Log, TEXT( "Modules loaded: %i, unloaded: %i" ), LoadedModuleCount, UnloadedModuleCount ); // Find the relative names of all the modules so we know which files to sync int ExecutableIndex = -1; for( uint32 ModuleIndex = 0; ModuleIndex < LoadedModuleCount; ModuleIndex++ ) { ULONG64 ModuleBase = 0; Symbol->GetModuleByIndex( ModuleIndex, &ModuleBase ); // Get the full path of the module name TCHAR ModuleName[MAX_PATH] = {0}; Symbol->GetModuleNameStringWide( DEBUG_MODNAME_IMAGE, ModuleIndex, ModuleBase, ModuleName, MAX_PATH, NULL ); const FString RelativeModuleName = ExtractRelativePath( TEXT( "binaries" ), ModuleName ); // Get the exe, which we extract the version number, so we know what label to sync to if (RelativeModuleName.Len() > 0 && RelativeModuleName.EndsWith( TEXT( ".exe" ) )) { ExecutableIndex = ModuleIndex; } // Add only modules in Binaries folders if (RelativeModuleName.Len() > 0) { CrashInfo.ModuleNames.Add( ModuleName ); } } // Get the executable version info. if( ExecutableIndex > -1 ) { VS_FIXEDFILEINFO VersionInfo = {0}; Symbol->GetModuleVersionInformationWide( ExecutableIndex, 0, TEXT( "\\" ), &VersionInfo, sizeof( VS_FIXEDFILEINFO ), NULL ); out_ExeFileVersion.Major = HIWORD( VersionInfo.dwProductVersionMS ); out_ExeFileVersion.Minor = LOWORD( VersionInfo.dwProductVersionMS ); out_ExeFileVersion.Patch = HIWORD( VersionInfo.dwProductVersionLS ); } else { UE_LOG( LogCrashDebugHelper, Warning, TEXT( "Unable to locate the executable" ) ); } }
FarString CMailViewPlugins::MakeKeyName( LPCSTR Root, LPCSTR FileName ) { FarString Key = ExtractRelativePath( Root, FileName ); Key.Insert( 0, "Mailbox_" ); Key.SetLength( Key.Length() - 4 ); Key += "_Masks"; int nIdx = Key.IndexOf( '\\' ); while ( nIdx != -1 ) { Key[ nIdx ] = '_'; nIdx = Key.IndexOf( '\\' ); } return Key; }
int FWindowsPlatformStackWalkExt::GetCallstacks() { const int32 MAX_NAME_LENGHT = FProgramCounterSymbolInfo::MAX_NAME_LENGHT; int32 NumValidFunctionNames = 0; FCrashExceptionInfo& Exception = CrashInfo.Exception; FMemMark Mark(FMemStack::Get()); //const float int int32 FString const int32 ContextSize = 4096; byte* Context = new(FMemStack::Get()) byte[ContextSize]; ULONG DebugEvent = 0; ULONG ProcessID = 0; ULONG ThreadID = 0; ULONG ContextUsed = 0; // Get the context of the crashed thread HRESULT hr = Control->GetStoredEventInformation(&DebugEvent, &ProcessID, &ThreadID, Context, ContextSize, &ContextUsed, NULL, 0, 0); if( FAILED(hr) ) { return NumValidFunctionNames; } // Some magic number checks if( ContextUsed == 716 ) { UE_LOG( LogCrashDebugHelper, Log, TEXT( "Context size matches x86 sizeof( CONTEXT )" ) ); } else if( ContextUsed == 1232 ) { UE_LOG( LogCrashDebugHelper, Log, TEXT( "Context size matches x64 sizeof( CONTEXT )" ) ); } // Get the entire stack trace const uint32 MaxFrames = 8192; const uint32 MaxFramesSize = MaxFrames * ContextUsed; DEBUG_STACK_FRAME* StackFrames = new(FMemStack::Get()) DEBUG_STACK_FRAME[MaxFrames]; ULONG Count = 0; bool bFoundSourceFile = false; void* ContextData = FMemStack::Get().PushBytes( MaxFramesSize, 0 ); FMemory::Memzero( ContextData, MaxFramesSize ); HRESULT HR = Control->GetContextStackTrace( Context, ContextUsed, StackFrames, MaxFrames, ContextData, MaxFramesSize, ContextUsed, &Count ); int32 AssertOrEnsureIndex = -1; for( uint32 StackIndex = 0; StackIndex < Count; StackIndex++ ) { const uint64 Offset = StackFrames[StackIndex].InstructionOffset; if( IsOffsetWithinModules( Offset ) ) { // Get the module, function, and offset uint64 Displacement = 0; TCHAR NameByOffset[MAX_PATH] = {0}; Symbol->GetNameByOffsetWide( Offset, NameByOffset, ARRAYSIZE( NameByOffset ) - 1, NULL, &Displacement ); FString ModuleAndFunction = NameByOffset; // Don't care about any more entries higher than this if (ModuleAndFunction.Contains( TEXT( "tmainCRTStartup" ) ) || ModuleAndFunction.Contains( TEXT( "FRunnableThreadWin::GuardedRun" ) )) { break; } // Look for source file name and line number TCHAR SourceName[MAX_PATH] = { 0 }; ULONG LineNumber = 0; Symbol->GetLineByOffsetWide( Offset, &LineNumber, SourceName, ARRAYSIZE( SourceName ) - 1, NULL, NULL ); // Remember the top of the stack to locate in the source file if( !bFoundSourceFile && FCString::Strlen( SourceName ) > 0 && LineNumber > 0 ) { CrashInfo.SourceFile = ExtractRelativePath( TEXT( "source" ), SourceName ); CrashInfo.SourceLineNumber = LineNumber; bFoundSourceFile = true; } FString ModuleName; FString FunctionName; // According to MSDN, the symbol name will include an ! if the function name could be discovered, delimiting it from the module name // https://msdn.microsoft.com/en-us/library/windows/hardware/ff547186(v=vs.85).aspx if( ModuleAndFunction.Contains( TEXT( "!" ) ) ) { NumValidFunctionNames++; ModuleAndFunction.Split( TEXT( "!" ), &ModuleName, &FunctionName ); FunctionName += TEXT( "()" ); } else { ModuleName = ModuleAndFunction; } // #YRX_Crash: 2015-07-24 Add for other platforms // If we find an assert, the actual source file we're interested in is the next one up, so reset the source file found flag if( FunctionName.Len() > 0 ) { if( FunctionName.Contains( TEXT( "FDebug::" ), ESearchCase::CaseSensitive ) || FunctionName.Contains( TEXT( "NewReportEnsure" ), ESearchCase::CaseSensitive ) ) { bFoundSourceFile = false; AssertOrEnsureIndex = FMath::Max( AssertOrEnsureIndex, (int32)StackIndex ); } } // FString InModuleName, FString InFunctionName, FString InFilename, uint32 InLineNumber, uint64 InSymbolDisplacement, uint64 InOffsetInModule, uint64 InProgramCounter FProgramCounterSymbolInfoEx SymbolInfo( ModuleName, FunctionName, SourceName, LineNumber, Displacement, Offset, 0 ); FString GenericFormattedCallstackLine; FGenericPlatformStackWalk::SymbolInfoToHumanReadableStringEx( SymbolInfo, GenericFormattedCallstackLine ); Exception.CallStackString.Add( GenericFormattedCallstackLine ); UE_LOG( LogCrashDebugHelper, Log, TEXT( "%3u: %s" ), StackIndex, *GenericFormattedCallstackLine ); } } // Remove callstack entries below FDebug, we don't need them. if (AssertOrEnsureIndex > 0) { Exception.CallStackString.RemoveAt( 0, AssertOrEnsureIndex ); UE_LOG( LogCrashDebugHelper, Warning, TEXT( "Callstack trimmed to %i entries" ), Exception.CallStackString.Num() ); } UE_LOG( LogCrashDebugHelper, Warning, TEXT( "Callstack generated with %i valid function names" ), NumValidFunctionNames ); return NumValidFunctionNames; }
//=========================================================================== // 暗号化するファイルリストとファイル情報のリストを同時生成する //=========================================================================== __int64 __fastcall TAttacheCaseFileEncrypt::GetFileInfoList ( int &Index, String DirPath, String FileName, String BasePath, TStringList *FileList, TStringList *DataList ) { /* ------------------------------------------------ ファイルリストのファイル番号の頭に「Fn_*:」と なぜ重複するような記号が挿入されているかと言いますと あまり意味はございません・・・お恥ずかしいかぎり・・・ すみません、これもver.1からの仕様を引きずっているのと、 習作時代にやっちゃった無意味なデータ仕様の一つです。 --------------------------------------------------- */ int ret; __int64 TotalSize = 0; bool fParent = false; String OneLine; String FilePath; String FileNameString; TSearchRec sr; //_WIN32_FIND_DATAW fd; DirPath = IncludeTrailingPathDelimiter(DirPath); if (FileName == "") { //ディレクトリ FileName = "*.*"; } else{ fParent = true; } ret = FindFirst(DirPath + FileName, faAnyFile, sr); while (ret == 0) { if (sr.Name != "." && sr.Name != "..") { FilePath = DirPath + sr.Name; FileNameString = ExtractRelativePath(BasePath, FilePath); //----------------------------------- //ディレクトリ if (sr.Attr & faDirectory) { // Win95/98系(非対応だが一応) if ( Win32Platform == VER_PLATFORM_WIN32_WINDOWS ){ OneLine = "Fn_" + IntToStr((int)Index) + ":" + //インデックス FileNameString + "\\\t" + //ディレクトリ名 "*\t16\t0\t0\t0\t0"; //残りは0 } else{ // _WIN32_FIND_DATAW 構造体 //fd = sr.FindData; OneLine = "Fn_" + IntToStr((int)Index) + ":" + //インデックス FileNameString + "\\\t" + //ディレクトリの相対パス "*\t" + //ファイルサイズ(=0) IntToStr(sr.Attr) + "\t" + //属性 TimeStampToString(sr.FindData.ftLastWriteTime)+"\t"+ //更新日時 TimeStampToString(sr.FindData.ftCreationTime); //作成日時 //出力する暗号化ファイルのタイムスタンプを元ファイルに合わせるため保持 if ( fKeepTimeStamp == true && first_fd.cFileName[0] == NULL ) { first_fd = sr.FindData; } } FileList->Add(""); //ディレクトリは空行 DataList->Add(OneLine); Index++; if (fParent == false) { //再帰呼び出し TotalSize += GetFileInfoList(Index, FilePath, "", BasePath, FileList, DataList); } } //----------------------------------- //ファイル else{ OneLine = "Fn_" + IntToStr((int)Index) + ":" + //インデックス FileNameString + "\t" + //ファイルの相対パス IntToStr(sr.Size) + "\t" + //ファイルサイズ IntToStr(sr.Attr) + "\t" + //属性 TimeStampToString(sr.FindData.ftLastWriteTime)+"\t"+ //更新日時 TimeStampToString(sr.FindData.ftCreationTime); //作成日時 //出力する暗号化ファイルのタイムスタンプを元ファイルに合わせるため保持 if ( fKeepTimeStamp == true && first_fd.cFileName[0] == NULL ) { first_fd = sr.FindData; } if (sr.Size > 0) { FileList->Add(FilePath); } else{ FileList->Add(""); //空ファイルは加えない } DataList->Add(OneLine); Index++; //ファイル総計 TotalSize += sr.Size; } //----------------------------------- }//end if; ret = FindNext(sr); }//while; FindClose(sr); return(TotalSize); }//end GetFileInfoList;
//--------------------------------------------------------------------------- AnsiString __fastcall GetRelativeName( AnsiString FullName, AnsiString DirPart) // Breaks full file name on two parts - DirPart and Relative Name { return ExtractRelativePath( IncludeTrailingBackslash(DirPart), FullName); }