HyperDbg Debugger
Loading...
Searching...
No Matches
logopen.cpp File Reference

.logopen command More...

#include "pch.h"

Functions

VOID CommandLogopenHelp ()
 help of the .logopen command
VOID CommandLogopen (vector< CommandToken > CommandTokens, string Command)
 .logopen command handler
VOID LogopenSaveToFile (const CHAR *Text)
 Append text to the file object.

Variables

BOOLEAN g_LogOpened
 Shows whether the '.logopen' command is executed and the log file is open or not.
ofstream g_LogOpenFile
 The object of log file ('.logopen' command).

Detailed Description

.logopen command

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-07-16

Function Documentation

◆ CommandLogopen()

VOID CommandLogopen ( vector< CommandToken > CommandTokens,
string Command )

.logopen command handler

Parameters
CommandTokens
Command
Returns
VOID
49{
50 if (CommandTokens.size() != 2)
51 {
52 ShowMessages("incorrect use of the '%s'\n\n",
53 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
55 return;
56 }
57
58 if (g_LogOpened)
59 {
60 ShowMessages("log was opened previously, you have the close it first "
61 "(using .logclose)\n");
62 return;
63 }
64
65 //
66 // Try to open it as file
67 //
68 g_LogOpenFile.open(GetCaseSensitiveStringFromCommandToken(CommandTokens.at(1)).c_str());
69
70 //
71 // Check if it's okay
72 //
73 if (g_LogOpenFile.is_open())
74 {
75 //
76 // Start intercepting logs
77 //
79
80 //
81 // Enable save to the file (Message + time)
82 //
83 time_t t = time(NULL);
84 struct tm tm = *localtime(&t);
85
86 ShowMessages("save commands and results into file : %s (%d-%02d-%02d "
87 "%02d:%02d:%02d)\n",
88 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(1)).c_str(),
89 tm.tm_year + 1900,
90 tm.tm_mon + 1,
91 tm.tm_mday,
92 tm.tm_hour,
93 tm.tm_min,
94 tm.tm_sec);
95 }
96 else
97 {
98 ShowMessages("unable to open file : %s\n", GetCaseSensitiveStringFromCommandToken(CommandTokens.at(1)).c_str());
99 return;
100 }
101}
#define TRUE
Definition BasicTypes.h:114
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
ofstream g_LogOpenFile
The object of log file ('.logopen' command).
Definition globals.h:494
VOID CommandLogopenHelp()
help of the .logopen command
Definition logopen.cpp:28
BOOLEAN g_LogOpened
Shows whether the '.logopen' command is executed and the log file is open or not.
Definition globals.h:488

◆ CommandLogopenHelp()

VOID CommandLogopenHelp ( )

help of the .logopen command

Returns
VOID
29{
30 ShowMessages(".logopen : saves commands and results in a file.\n\n");
31
32 ShowMessages("syntax : \t.logopen [FilePath (string)]\n");
33
34 ShowMessages("\n");
35 ShowMessages("\t\te.g : .logopen c:\\users\\sina\\desktop\\log.txt\n");
36 ShowMessages("\t\te.g : .logopen \"c:\\users\\sina\\desktop\\log with space.txt\"\n");
37}

◆ LogopenSaveToFile()

VOID LogopenSaveToFile ( const CHAR * Text)

Append text to the file object.

Parameters
Text
Returns
VOID
111{
112 g_LogOpenFile << Text;
113}

Variable Documentation

◆ g_LogOpened

BOOLEAN g_LogOpened
extern

Shows whether the '.logopen' command is executed and the log file is open or not.

◆ g_LogOpenFile

ofstream g_LogOpenFile
extern

The object of log file ('.logopen' command).