-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShareCode.cpp
More file actions
36 lines (33 loc) · 982 Bytes
/
ShareCode.cpp
File metadata and controls
36 lines (33 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "ShareCode.h"
#include <algorithm>
CriticalHandle::CriticalHandle(LPCRITICAL_SECTION _pCritical) noexcept :
pCritical(_pCritical)
{
EnterCriticalSection(pCritical);
}
CriticalHandle::~CriticalHandle() noexcept
{
LeaveCriticalSection(pCritical);
}
VirtualProtectHandle::VirtualProtectHandle(LPVOID _lpAddress, SIZE_T _dwSize, DWORD _flNewProtect) noexcept :
lpAddress(_lpAddress), dwSize(_dwSize), flNewProtect(_flNewProtect)
{
if (lpAddress != NULL)
VirtualProtect(lpAddress, dwSize, flNewProtect, &flOldProtect);
}
VirtualProtectHandle::~VirtualProtectHandle() noexcept
{
if (lpAddress != NULL)
VirtualProtect(lpAddress, dwSize, flOldProtect, &flNewProtect);
}
std::string stringToLower(const std::string& _str)
{
std::string t_tmp(_str);
std::transform(t_tmp.begin(), t_tmp.end(), t_tmp.begin(), ::tolower);
return t_tmp;
}
std::string& stringToLower(std::string& _str)
{
std::transform(_str.begin(), _str.end(), _str.begin(), ::tolower);
return _str;
}