diff --git a/bdsx/main.cpp b/bdsx/main.cpp index 0451c85..a69e6c5 100644 --- a/bdsx/main.cpp +++ b/bdsx/main.cpp @@ -241,7 +241,7 @@ void nodegate::initNativeModule(void* exports_raw) noexcept bedrock_server_exe.set(u"mainOriginal12Bytes", VoidPointer::make(s_bedrockMainOriginal12Bytes)); bedrock_server_exe.setMethod(u"forceKill", kr::terminate); } - + { JsValue cgate = JsNewObject; exports.set(u"cgate", cgate); @@ -270,6 +270,10 @@ void nodegate::initNativeModule(void* exports_raw) noexcept cgate.set(u"toWide", VoidPointer::make(String_toWide)); cgate.set(u"toUtf8", VoidPointer::make(String_toUtf8)); + +#ifndef NDEBUG + cgate.setMethod(u"memcheck", memcheck); +#endif } { diff --git a/bdsx/staticpointer.cpp b/bdsx/staticpointer.cpp index f93dfee..9283ca8 100644 --- a/bdsx/staticpointer.cpp +++ b/bdsx/staticpointer.cpp @@ -211,6 +211,17 @@ void StaticPointer::copyFrom(VoidPointer* from, int bytes, int this_offset, int accessViolation(m_address); } } +void StaticPointer::copyTo(kr::JsValue buffer, int bytes, int offset) throws(kr::JsException) { + VoidPointer* ptr = buffer.getNativeObject(); + if (ptr != nullptr) { + memcpy(ptr->getAddressRaw(), m_address + offset, (uint32_t)bytes); + return; + } + WBuffer buf = buffer.getBuffer(); + if (buf == nullptr) throw JsException(u"argument must be buffer or pointer"); + size_t minv = maxt((size_t)buf.size(), (uint32_t)bytes); + memcpy(buf.data(), m_address + offset, minv); +} void StaticPointer::setBoolean(bool v, int offset) throws(JsException) { return _setas(v, offset); @@ -556,6 +567,7 @@ void StaticPointer::initMethods(JsClassT* cls) noexcept cls->setMethod(u"fill", &StaticPointer::fill); cls->setMethod(u"copyFrom", &StaticPointer::copyFrom); + cls->setMethod(u"copyTo", &StaticPointer::copyTo); cls->setMethod(u"setBoolean", &StaticPointer::setBoolean); cls->setMethod(u"setUint8", &StaticPointer::setUint8); cls->setMethod(u"setUint16", &StaticPointer::setUint16); diff --git a/bdsx/staticpointer.h b/bdsx/staticpointer.h index 6d637a4..70b6476 100644 --- a/bdsx/staticpointer.h +++ b/bdsx/staticpointer.h @@ -35,6 +35,7 @@ class StaticPointer :public kr::JsObjectT void fill(int bytevalue, int bytes, int offset) throws(kr::JsException); void copyFrom(VoidPointer* from, int bytes, int this_offset, int from_offset) throws(kr::JsException); + void copyTo(kr::JsValue buffer, int bytes, int offset) throws(kr::JsException); void setBoolean(bool v, int offset) throws(kr::JsException); void setUint8(uint8_t v, int offset) throws(kr::JsException); void setUint16(uint16_t v, int offset) throws(kr::JsException); diff --git a/bdsx/version.bat b/bdsx/version.bat index 48e1c14..8075fc0 100644 --- a/bdsx/version.bat +++ b/bdsx/version.bat @@ -1,2 +1,2 @@ -set BDSX_CORE_VERSION=1.0.10.0 +set BDSX_CORE_VERSION=1.0.11.0