int main() { char* text = "I love to break free"; int arr[] = { 7, 3, 2, 10, -5 }; size_t size = sizeof(arr) / sizeof(int); memoryDump(text, strlen(text) + 1, 5); printf("\n"); memoryDump(arr, size * sizeof(int), 4); return 0; }
void MemoryManager<AllocatorType>::deallocate(Byte* address) { if(address == nullptr) return; // Find the block corresponding to the address size_t index{0}; typename BlockList::iterator it; while(index < _addressSize) { it = findBlock(_allocatedBlocks[index], address, index); if(it != _allocatedBlocks[index].end()) break; index++; } if(it != _allocatedBlocks[index].end()) { // Add the freed block to the free list _allocatedBlocks[index].erase(it); _freeBlocks[index].pushFront(address); tryMerge(_freeBlocks[index].begin(), index); } else out << "Error: MemoryMamanger::deallocate: invalid pointer argument (" << address << ")\n"; if(_activateMemoryDump) memoryDump(); }
Bool DOSUtilKeyHandler(CITWINDOW *, int key) { switch (key) { case CSDM_EXIT: case MK_ESC: { // exit user menu stuff return (FALSE); } case CSDM_COPY: { break; } case CSDM_MOVE: { break; } case CSDM_DELETE: { break; } case CSDM_RENAME: { break; } case CSDM_VIEW: { break; } case CSDM_MAKEDIR: { break; } case CSDM_RMVDIR: { break; } case CSDM_MEMDUMP: { memoryDump(); break; } } return (TRUE); }
Byte* MemoryManager<AllocatorType>::allocate(size_t size, size_t alignment) { const size_t index{getIndexFromSize(size + alignment)}; typename BlockList::iterator it{allocateBlock(index)}; if(_activateMemoryDump) memoryDump(); if(it == _allocatedBlocks[index].end()) { out << "Error: MemoryMamanger::allocate: no more memory, nullptr returned\n"; return nullptr; } else return getAlignedAddress(it, alignment); }
std::wstring DebugHelper::DumpMemory(void *pMemory, uint32 dwSize) const { Utils::ByteBuffer memoryDump(dwSize); SIZE_T dwNumberOfBytesRead = 0; if (ReadProcessMemory(GetCurrentProcess(), pMemory, memoryDump.data(), dwSize, &dwNumberOfBytesRead) == FALSE) throw std::runtime_error("Invalid memory location for dump!"); memoryDump.resize(dwNumberOfBytesRead); DWORD_PTR dwStartAddress = reinterpret_cast<DWORD_PTR>(pMemory); std::wostringstream strmMemory; for (DWORD_PTR j = 0; j < dwNumberOfBytesRead; j += 0x10) { strmMemory << std::hex << std::uppercase << L" 0x" << reinterpret_cast<void*>(dwStartAddress + j) << L':'; for (DWORD_PTR i = 0; i < 0x10 && (i + j < dwNumberOfBytesRead); ++i) { if ((i % 4) == 0) strmMemory << L' '; strmMemory << std::hex << std::setfill(L'0') << std::setw(2) << memoryDump[j + i] << L' '; } strmMemory << L' '; for (DWORD_PTR i = 0; i < 0x10 && (i + j < dwNumberOfBytesRead); ++i) { char c = static_cast<char>(memoryDump[j + i]); strmMemory << (isprint(c) ? wchar_t(c) : L'.'); } strmMemory << L"\r\n"; } return strmMemory.str(); }
void TERMWINDOWMEMBER fkey(uint inkey) { int key = inkey >> 8; // this handles the keys for dialout mode if (DoWhat == DIALOUT) { dialout_fkey = key; return; } // let RLM take over keyboard if it wants if (!CitadelIsConfiguring && rlmEvent(LT_KEYSTROKE, key, inkey)) { return; } if (cfg.FullConLock && ConsoleLock.IsLocked() && ScreenSaver.IsOn() && key != ALT_L) { return; } if (!LockMessages(MSG_CONSOLE)) { cOutOfMemory(49); } if (key == CTL_F2) // CTRL_F2 is never locked. { #ifndef WINCIT if (allWindows) { setFocus(allWindows->wnd); } #endif } else if (key != ALT_F1 && ConsoleLock.IsLocked(key == F6 || key == ALT_F6 || key == SFT_F6 || key == CTL_F6)) { #ifndef WINCIT if (key == ALT_L && ConsoleLock.MayUnlock()) { GetStringFromConsole(getmsg(MSG_CONSOLE, 0), LABELSIZE, ns, GetSysPWHandler, TRUE); } else { if (cfg.VerboseConsole) { CitWindowsNote(NULL, (key == ALT_L) ? getmsg(MSG_CONSOLE, 1) : getmsg(MSG_CONSOLE, 2)); } } #endif } else { // Console is not locked if (CitadelIsConfiguring) { // Only let certain keystrokes through if configuring if (key != CTL_F6 && key != F7 && key != F8 && key != ALT_D && key != ALT_L && key != ALT_M && key != ALT_S && key != ALT_U) { WaitUntilDoneConfiguring(); key = 0; } } ScreenSaver.Update(); switch (key) { case F1: { CITWINDOW *w = CitWindowsMsg(NULL, getmsg(MSG_CONSOLE, 3)); #ifndef WINCIT CommPort->DropDtr(); #endif if (w) { destroyCitWindow(w, FALSE); } break; } #ifndef WINCIT case CTL_F1: { if (say_ascii != (int (cdecl *)(const char *, int)) nullFunc) { cfg.speechOn = !cfg.speechOn; if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 4), cfg.speechOn ? getmsg(317) : getmsg(316)); } } else { cfg.speechOn = FALSE; if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 5)); } } break; } #endif case ALT_F1: { cls(SCROLL_SAVE); break; } case F2: { CITWINDOW *w = CitWindowsMsg(NULL, getmsg(19)); Initport(); if (w) { destroyCitWindow(w, FALSE); } break; } case F3: { sysReq = !sysReq; if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 6), sysReq ? getmsg(317) : getmsg(316)); } break; } case ALT_F3: { if (sysReq) { altF3Timeout = 0; sysReq = FALSE; if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 6), getmsg(316)); } } else { altF3Timeout = time(NULL) + cfg.altF3Time; sysReq = TRUE; if (cfg.VerboseConsole) { long tme = time(NULL); CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 7), (altF3Timeout - tme) / 60, (altF3Timeout - tme) % 60); } } break; } case F4: { if (!StatusLine.ToggleFullScreen(WC_TWp)) { if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 8)); } } break; } case F5: { if (onConsole) { OC.whichIO = MODEM; OC.setio(); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 9), getmsg(MSG_CONSOLE, 10)); } } else { OC.whichIO = CONSOLE; OC.setio(); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 9), getmsg(MSG_CONSOLE, 11)); } } break; } case F6: { sysopkey = TRUE; break; } #ifndef WINCIT case CTL_F6: { doConsoleSysop(); break; } #endif case ALT_F6: { CurrentUser->SetAide(!CurrentUser->IsAide()); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12), CurrentUser->IsAide() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14), getmsg(385)); } break; } case SFT_F6: { CurrentUser->SetSysop(!CurrentUser->IsSysop()); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12), CurrentUser->IsSysop() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14), getmsg(386)); } break; } case F7: { cfg.noBells++; if (cfg.noBells == 3) { cfg.noBells = 0; } if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 15), getmsg(MSG_CONSOLE, 16 + cfg.noBells)); } break; } case ALT_C: case F8: { chatkey = !chatkey; break; } case F9: { cfg.noChat = !cfg.noChat; chatReq = FALSE; if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 19), cfg.noChat ? getmsg(316) : getmsg(317)); } break; } case F10: case ALT_H: { StatusLine.ToggleHelp(WC_TWp); break; } case ALT_F10: { StatusLine.ToggleSecond(WC_TWp); break; } case SFT_F10: { StatusLine.Toggle(WC_TWp); break; } #ifdef WINCIT case F11: { TermWindowCollection.FocusPrev(); break; } case F12: { TermWindowCollection.FocusNext(); break; } #endif case ALT_A: { CurrentUser->SetAccounting(!CurrentUser->IsAccounting()); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 20), CurrentUser->IsAccounting() ? getmsg(317) : getmsg(316)); } break; } case ALT_D: { if (debug) { TurnDebugOff(); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 21), getmsg(316)); } } else { if (TurnDebugOn()) { if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 21), getmsg(317)); } } else { if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 22)); } } } break; } #ifndef WINCIT case ALT_K: { if (!allWindows) { if (cfg.scrollSize) { DisplayScrollBackBuffer(); time(&LastActiveTime); } else { if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 23), citfiles[C_CONFIG_CIT]); } } } else { if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 24)); } } break; } #endif case ALT_L: { if (*cfg.f6pass) { if (!SameString(cfg.f6pass, getmsg(670))) { ConsoleLock.Lock(); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 32)); } } } else { if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 33), citfiles[C_CONFIG_CIT]); } } break; } case ALT_M: { memoryDump(); break; } case ALT_P: { if (OC.Printing) { OC.Printing = FALSE; fclose(OC.PrintFile); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 25)); } } else { #ifndef WINCIT if (cfg.printerprompt) { GetStringFromConsole(getmsg(289), 63, cfg.printer, StartPrinting, FALSE); } else #endif { char Buffer[sizeof(cfg.homepath) + sizeof(cfg.printer)]; sprintf(Buffer, sbs, cfg.homepath, cfg.printer); StartPrinting(Buffer); } } break; } case ALT_R: repeatevent = TRUE; // fall through case ALT_F: forceevent = TRUE; // fall through case ALT_E: eventkey = TRUE; break; case ALT_S: { if (ScreenSaver.TurnOn()) { #ifndef WINCIT while ((*sp_press)()); #endif } else { if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 26)); } } break; } case ALT_T: { CurrentUser->SetProblem(!CurrentUser->IsProblem()); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12), CurrentUser->IsProblem() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14), getmsg(MSG_CONSOLE, 27)); } break; } case ALT_U: { cfg.ignore_uptime = !cfg.ignore_uptime; if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 28), citfiles[C_CONFIG_CIT], cfg.ignore_uptime ? getmsg(317) : getmsg(316)); } break; } case ALT_V: { CurrentUser->SetVerified(!CurrentUser->IsVerified()); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12), CurrentUser->IsVerified() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14), getmsg(MSG_CONSOLE, 29)); } break; } case ALT_X: case ALT_F4: { #ifndef WINCIT if (cfg.AltXPrompt) { GetYNFromConsole(getmsg(MSG_CONSOLE, 30), 0, ExitYNHandler); } else #endif { ExitToMsdos = TRUE; } break; } case ALT_Z: { if (CommPort->HaveConnection() || debug) { sleepkey = TRUE; } break; } case ALT_3: { CurrentUser->SetOut300(!CurrentUser->IsOut300()); if (cfg.VerboseConsole) { CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12), CurrentUser->IsOut300() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14), getmsg(MSG_CONSOLE, 31)); } break; } case PGUP: { CurrentUser->SetCredits(CurrentUser->GetCredits() + 5 * 60); break; } case PGDN: { CurrentUser->SetCredits(CurrentUser->GetCredits() - 5 * 60); break; } } } UnlockMessages(MSG_CONSOLE); StatusLine.Update(WC_TWp); }