MCPcopy Create free account
hub / github.com/NtQuery/Scylla / saveLogToFile

Method saveLogToFile

Scylla/MainGui.cpp:675–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

673}
674
675bool MainGui::saveLogToFile(const WCHAR * file)
676{
677 const BYTE BOM[] = {0xFF, 0xFE}; // UTF-16 little-endian
678 const WCHAR newLine[] = L"\r\n";
679 bool success = true;
680
681 HANDLE hFile = CreateFile(file, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
682 if(hFile != INVALID_HANDLE_VALUE)
683 {
684 ProcessAccessHelp::writeMemoryToFileEnd(hFile, sizeof(BOM), BOM);
685
686 WCHAR * buffer = 0;
687 size_t bufsize = 0;
688 for(int i = 0; i < ListLog.GetCount(); i++)
689 {
690 size_t size = ListLog.GetTextLen(i);
691 size += _countof(newLine)-1;
692 if(size+1 > bufsize)
693 {
694 bufsize = size+1;
695 delete[] buffer;
696 try
697 {
698 buffer = new WCHAR[bufsize];
699 }
700 catch(std::bad_alloc&)
701 {
702 buffer = 0;
703 success = false;
704 break;
705 }
706 }
707
708 ListLog.GetText(i, buffer);
709 wcscat_s(buffer, bufsize, newLine);
710
711 ProcessAccessHelp::writeMemoryToFileEnd(hFile, (DWORD)(size * sizeof(WCHAR)), buffer);
712 }
713 delete[] buffer;
714 CloseHandle(hFile);
715 }
716 return success;
717}
718
719void MainGui::showInvalidImportsActionHandler()
720{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected