diff --git a/LibCmo/LibCmo.vcxproj b/LibCmo/LibCmo.vcxproj
index b0280a4..600f759 100644
--- a/LibCmo/LibCmo.vcxproj
+++ b/LibCmo/LibCmo.vcxproj
@@ -100,7 +100,7 @@
true
_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- $(BOOST_INCLUDE_PATH);$(ZLIB_PATH);%(AdditionalIncludeDirectories)
+ $(ZLIB_PATH);%(AdditionalIncludeDirectories)
stdcpp20
/utf-8 %(AdditionalOptions)
@@ -118,7 +118,7 @@
true
_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- $(BOOST_INCLUDE_PATH);$(ZLIB_PATH);%(AdditionalIncludeDirectories)
+ $(ZLIB_PATH);%(AdditionalIncludeDirectories)
stdcpp20
/utf-8 %(AdditionalOptions)
@@ -136,7 +136,7 @@
true
_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- $(BOOST_INCLUDE_PATH);$(ZLIB_PATH);%(AdditionalIncludeDirectories)
+ $(ZLIB_PATH);%(AdditionalIncludeDirectories)
stdcpp20
/utf-8 %(AdditionalOptions)
@@ -156,7 +156,7 @@
true
_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- $(BOOST_INCLUDE_PATH);$(ZLIB_PATH);%(AdditionalIncludeDirectories)
+ $(ZLIB_PATH);%(AdditionalIncludeDirectories)
stdcpp20
/utf-8 %(AdditionalOptions)
diff --git a/LibCmo/VTEncoding.hpp b/LibCmo/VTEncoding.hpp
index a2eb84a..16ef964 100644
--- a/LibCmo/VTEncoding.hpp
+++ b/LibCmo/VTEncoding.hpp
@@ -5,6 +5,7 @@
#if defined(LIBCMO_OS_WIN32)
#include
+#include
#else
#include
#endif
diff --git a/LibCmo/VTStruct.cpp b/LibCmo/VTStruct.cpp
index 603729c..9b172e7 100644
--- a/LibCmo/VTStruct.cpp
+++ b/LibCmo/VTStruct.cpp
@@ -28,43 +28,100 @@ namespace LibCmo {
#pragma region VxMemoryMappedFile
VxMemoryMappedFile::VxMemoryMappedFile(const char* u8_filepath) :
+ // init members
+#if defined(LIBCMO_OS_WIN32)
+ m_hFile(NULL), m_hFileMapping(NULL), m_hFileMapView(NULL),
+ m_dwFileSizeLow(0), m_dwFileSizeHigh(0),
+#else
+#error NO IMPLEMENTATION FOR LINUX MMAP!
+#endif
m_szFilePath(),
- m_hFile(nullptr), m_hFileMapping(nullptr),
- m_bIsValid(false) {
+ m_bIsValid(false), m_pMemoryMappedFileBase(nullptr), m_cbFile(0u) {
- // save file path and set region option
- boost::interprocess::map_options_t region_option;
+ // save file path
#if defined(LIBCMO_OS_WIN32)
Encoding::CharToWchar(u8_filepath, this->m_szFilePath, CP_UTF8);
- region_option = FILE_MAP_READ;
#else
this->m_szFilePath = u8_filepath;
- region_option = boost::interprocess::default_map_options;
#endif
+ // real mapping work
+#if defined(LIBCMO_OS_WIN32)
+
// open file
- this->m_hFile = new boost::interprocess::file_mapping(
- this->m_szFilePath.c_str(), boost::interprocess::read_only
+ this->m_hFile = CreateFileW(
+ this->m_szFilePath.c_str(),
+ GENERIC_READ,
+ 0, // do not share
+ NULL, // no security
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, // no attr
+ NULL // no template
);
+ if (this->m_hFile == INVALID_HANDLE_VALUE) {
+ return;
+ }
- // open region
- this->m_hFileMapping = new boost::interprocess::mapped_region(
- *(this->m_hFile), boost::interprocess::read_only,
- 0, 0, nullptr,
- region_option
+ // get size
+ m_dwFileSizeLow = ::GetFileSize(this->m_hFile, &this->m_dwFileSizeHigh);
+ if (m_dwFileSizeLow == INVALID_FILE_SIZE) {
+ CloseHandle(this->m_hFile);
+ return;
+ }
+
+ // open mapping
+ this->m_hFileMapping = CreateFileMappingW(
+ this->m_hFile,
+ NULL, // default security
+ PAGE_READONLY,
+ 0, 0, // expand to file size
+ NULL // no name
);
+ if (this->m_hFileMapping == NULL) {
+ CloseHandle(this->m_hFile);
+ return;
+ }
+
+ // open map view
+ this->m_hFileMapView = MapViewOfFile(
+ this->m_hFileMapping,
+ FILE_MAP_READ,
+ 0, 0, //no offset
+ 0 // expand to full file size
+ );
+ if (this->m_hFileMapView == NULL) {
+ CloseHandle(m_hFileMapping);
+ CloseHandle(m_hFile);
+ }
+
+ // write member data
+ m_pMemoryMappedFileBase = m_hFileMapView;
+ m_cbFile = static_cast(m_dwFileSizeLow) | (static_cast(m_dwFileSizeHigh) << 32);
+
+#else
+#error NO IMPLEMENTATION FOR LINUX MMAP!
+#endif
+
// set valid
this->m_bIsValid = true;
-
}
VxMemoryMappedFile::~VxMemoryMappedFile(void) {
- this->m_bIsValid = false;
+ if (this->m_bIsValid) {
+ // only success mapping need free
+ this->m_bIsValid = false;
+ m_cbFile = 0;
+ m_pMemoryMappedFileBase = nullptr;
- delete this->m_hFileMapping;
- boost::interprocess::file_mapping::remove(this->m_szFilePath.c_str());
- delete this->m_hFile;
+#if defined(LIBCMO_OS_WIN32)
+ UnmapViewOfFile(this->m_hFileMapView);
+ CloseHandle(m_hFileMapping);
+ CloseHandle(m_hFile);
+#else
+#error NO IMPLEMENTATION FOR LINUX MMAP!
+#endif
+ }
}
#pragma endregion
diff --git a/LibCmo/VTStruct.hpp b/LibCmo/VTStruct.hpp
index 9a2220d..83bcbf1 100644
--- a/LibCmo/VTStruct.hpp
+++ b/LibCmo/VTStruct.hpp
@@ -5,8 +5,11 @@
#include "VTEncoding.hpp"
#include
-#include
-#include
+#if defined(LIBCMO_OS_WIN32)
+#include
+#else
+#include
+#endif
namespace LibCmo {
@@ -27,12 +30,17 @@ namespace LibCmo {
#if defined(LIBCMO_OS_WIN32)
std::wstring m_szFilePath;
+ HANDLE m_hFile;
+ DWORD m_dwFileSizeLow, m_dwFileSizeHigh;
+ HANDLE m_hFileMapping;
+ LPVOID m_hFileMapView;
#else
std::string m_szFilePath;
+#error NO IMPLEMENTATION FOR LINUX MMAP!
#endif
- boost::interprocess::file_mapping* m_hFile;
- boost::interprocess::mapped_region* m_hFileMapping;
+ void* m_pMemoryMappedFileBase;
+ size_t m_cbFile;
bool m_bIsValid;
public:
VxMemoryMappedFile(const char* u8_filepath);
@@ -40,8 +48,8 @@ namespace LibCmo {
VxMemoryMappedFile& operator=(const VxMemoryMappedFile&) = delete;
~VxMemoryMappedFile(void);
- inline void* GetBase(void) { return this->m_hFileMapping->get_address(); }
- inline size_t GetFileSize(void) { return this->m_hFileMapping->get_size(); }
+ inline void* GetBase(void) { return this->m_pMemoryMappedFileBase; }
+ inline size_t GetFileSize(void) { return this->m_cbFile; }
inline bool IsValid(void) { return this->m_bIsValid; }
};
diff --git a/LibRef.props b/LibRef.props
index 47c1132..79a7fc2 100644
--- a/LibRef.props
+++ b/LibRef.props
@@ -2,8 +2,6 @@
- D:\CppLib\boost_1_81_0
-
D:\CppLib\SQLite\sqlite-amalgamation-3400100
D:\CppLib\SQLite\sqlite-dll-win32-x86-3400100
D:\CppLib\SQLite\sqlite-dll-win64-x64-3400100
@@ -13,10 +11,6 @@
-
- $(BOOST_INCLUDE_PATH)
-
-
$(SQLITE_HEADER_PATH)
diff --git a/Unvirt/InteractiveCmd.hpp b/Unvirt/InteractiveCmd.hpp
index 2c2ce69..5704f6a 100644
--- a/Unvirt/InteractiveCmd.hpp
+++ b/Unvirt/InteractiveCmd.hpp
@@ -3,18 +3,18 @@
#include
#include
#include
-#include
-#include
-#include
-#include
+//#include
+//#include
+//#include
+//#include
namespace Unvirt {
- struct CmdRegisteryEntry {
- boost::program_options::options_description mOptDesc;
- boost::program_options::positional_options_description mPosOptDesc;
- std::function mBindProc;
- };
+ //struct CmdRegisteryEntry {
+ // boost::program_options::options_description mOptDesc;
+ // boost::program_options::positional_options_description mPosOptDesc;
+ // std::function mBindProc;
+ //};
class InteractiveCmd {
public:
@@ -24,7 +24,7 @@ namespace Unvirt {
void Run(void) { ; }
private:
- std::unordered_map mCmdDispatcher;
+ //std::unordered_map mCmdDispatcher;
};
diff --git a/Unvirt/Unvirt.vcxproj b/Unvirt/Unvirt.vcxproj
index 0ddf306..e17fefa 100644
--- a/Unvirt/Unvirt.vcxproj
+++ b/Unvirt/Unvirt.vcxproj
@@ -100,7 +100,7 @@
true
_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- $(BOOST_INCLUDE_PATH);$(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)
+ $(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)
stdcpp20
/utf-8 %(AdditionalOptions)
@@ -119,7 +119,7 @@
true
_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- $(BOOST_INCLUDE_PATH);$(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)
+ $(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)
stdcpp20
/utf-8 %(AdditionalOptions)
@@ -138,7 +138,7 @@
true
_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- $(BOOST_INCLUDE_PATH);$(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)
+ $(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)
stdcpp20
/utf-8 %(AdditionalOptions)
@@ -157,7 +157,7 @@
true
_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- $(BOOST_INCLUDE_PATH);$(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)
+ $(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)
stdcpp20
/utf-8 %(AdditionalOptions)