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

general functions used in test project More...

#include "pch.h"

Functions

std::string Uint64ToString (UINT64 Value)
 Convert a UINT64 value to a hex string.
BOOLEAN StringReplace (std::string &Str, const std::string &From, const std::string &To)
 Replace the first occurrence of a substring in a string.
std::string ConvertToString (CHAR *Str)
 Convert a C-string to a std::string.

Detailed Description

general functions used in test project

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2021-04-11

Function Documentation

◆ ConvertToString()

std::string ConvertToString ( CHAR * Str)

Convert a C-string to a std::string.

Parameters
Strthe C-string to convert
Returns
std::string the resulting string object
54{
55 string Result(Str);
56
57 return Result;
58}

◆ StringReplace()

BOOLEAN StringReplace ( std::string & Str,
const std::string & From,
const std::string & To )

Replace the first occurrence of a substring in a string.

Parameters
Strthe string to modify
Fromthe substring to search for
Tothe replacement substring
Returns
BOOLEAN TRUE if the replacement was made, FALSE otherwise
38{
39 SIZE_T StartPos = Str.find(From);
40 if (StartPos == string::npos)
41 return FALSE;
42 Str.replace(StartPos, From.length(), To);
43 return TRUE;
44}
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113

◆ Uint64ToString()

std::string Uint64ToString ( UINT64 Value)

Convert a UINT64 value to a hex string.

Parameters
Valuethe value to convert
Returns
std::string the hex string representation
22{
23 ostringstream Os;
24 Os << setw(16) << setfill('0') << hex << Value;
25 return Os.str();
26}
RequestedActionOfThePacket Value(0x1) 00000000