forked from vic4key/Vutils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample.FileMapping.h
More file actions
46 lines (36 loc) · 1.06 KB
/
Sample.FileMapping.h
File metadata and controls
46 lines (36 loc) · 1.06 KB
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
37
38
39
40
41
42
43
44
45
46
#pragma once
#include "Sample.h"
DEF_SAMPLE(FileMapping)
{
vu::CFileMapping fm;
void* p = nullptr;
// if (fm.CreateNamedSharedMemory(_T("Global\\Sample"), KB) != vu::VU_OK)
// {
// std::tcout << _T("Create -> Failed") << vu::LastError(fm.GetLastErrorCode()) << std::endl;
// }
if (fm.CreateWithinFile(_T("Test.txt")) != vu::VU_OK)
{
std::tcout << _T("Create -> Failed ") << vu::LastError(fm.GetLastErrorCode()) << std::endl;
}
p = fm.View();
if (p == nullptr)
{
std::tcout << _T("View -> Failed ") << vu::LastError(fm.GetLastErrorCode()) << std::endl;
}
std::tcout << std::hex << _T("File Mapping at ") << p << std::endl;
if (p != nullptr)
{
if (fm.GetFileSize() != -1)
{
vu::HexDump(p, fm.GetFileSize());
}
else
{
std::tcout << _T("Waiting for a communication then enter ...") << std::endl; _getch();
std::cout << (char*)p << std::endl;
*(vu::ulong*)p = 0x48474645; // EFGH
std::tcout << _T("Wrote data to file mapping object") << std::endl; _getch();
}
}
return vu::VU_OK;
}