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< string > SplitCommand, 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< string > SplitCommand,
string Command )

.logopen command handler

Parameters
SplitCommand
Command
Returns
VOID
44{
45 if (SplitCommand.size() == 1)
46 {
47 ShowMessages("please specify a file\n");
49 return;
50 }
51
52 if (g_LogOpened)
53 {
54 ShowMessages("log was opened previously, you have the close it first "
55 "(using .logclose)\n");
56 return;
57 }
58
59 //
60 // Trim the command
61 //
62 Trim(Command);
63
64 //
65 // Remove .logopen from it
66 //
67 Command.erase(0, SplitCommand.at(0).size());
68
69 //
70 // Trim it again
71 //
72 Trim(Command);
73
74 //
75 // Try to open it as file
76 //
77 g_LogOpenFile.open(Command.c_str());
78
79 //
80 // Check if it's okay
81 //
82 if (g_LogOpenFile.is_open())
83 {
84 //
85 // Start intercepting logs
86 //
88
89 //
90 // Enable save to the file (Message + time)
91 //
92 time_t t = time(NULL);
93 struct tm tm = *localtime(&t);
94
95 ShowMessages("save commands and results into file : %s (%d-%02d-%02d "
96 "%02d:%02d:%02d)\n",
97 Command.c_str(),
98 tm.tm_year + 1900,
99 tm.tm_mon + 1,
100 tm.tm_mday,
101 tm.tm_hour,
102 tm.tm_min,
103 tm.tm_sec);
104 }
105 else
106 {
107 ShowMessages("unable to open file : %s\n", Command.c_str());
108 return;
109 }
110}
#define TRUE
Definition BasicTypes.h:55
void Trim(std::string &s)
trim from both ends and start of a string (in place)
Definition common.cpp:594
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
BOOLEAN g_LogOpened
Shows whether the '.logopen' command is executed and the log file is open or not.
Definition globals.h:478
VOID CommandLogopenHelp()
help of the .logopen command
Definition logopen.cpp:28
ofstream g_LogOpenFile
The object of log file ('.logopen' command)
Definition globals.h:484

◆ 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}

◆ LogopenSaveToFile()

VOID LogopenSaveToFile ( const char * Text)

Append text to the file object.

Parameters
Text
Returns
VOID
120{
121 g_LogOpenFile << Text;
122}

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)