diff --git a/bdsx/bdsx.vcxproj b/bdsx/bdsx.vcxproj
index 1170516..9ce5d34 100644
--- a/bdsx/bdsx.vcxproj
+++ b/bdsx/bdsx.vcxproj
@@ -69,7 +69,7 @@
Chakra
- $(SolutionDir)node-chakracore\$(ConfigDir)\lib;$(LibraryPath)
+ $(SolutionDir)node-chakracore\$(ConfigDir)\lib;$(SolutionDir)node-chakracore\$(ConfigDir);$(LibraryPath)
Chakra
@@ -197,7 +197,7 @@ echo #define BUILD_TIME "%25date%-%time2:.=%">"gen/buildtime.h"
Document
gen\version.h;$(SolutionDir)..\bdsx\bdsx\version-bdsx.json
- gen\version.h;$(SolutionDir)..\bdsx\bdsx\version.json
+ gen\version.h;$(SolutionDir)..\bdsx\bdsx\version-bdsx.json
gen\version.h;$(SolutionDir)..\bdsx\bdsx\version-bdsx.json
@call "%(Identity)"
diff --git a/bdsx/main.cpp b/bdsx/main.cpp
index db6582c..3b6f83f 100644
--- a/bdsx/main.cpp
+++ b/bdsx/main.cpp
@@ -168,6 +168,7 @@ namespace
}
catch (ThrowAbort&)
{
+ _catch(param, "kr::ThrowAbort");
}
catch (std::exception& e)
{
@@ -396,6 +397,7 @@ void nodegate::initNativeModule(void* exports_raw) noexcept
}
s_globalScope.create();
}
+
void nodegate::clearNativeModule() noexcept
{
s_globalScope.remove();
diff --git a/bdsx/sehandler.cpp b/bdsx/sehandler.cpp
index a147077..831c24c 100644
--- a/bdsx/sehandler.cpp
+++ b/bdsx/sehandler.cpp
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "sehandler.h"
#include "voidpointer.h"
+#include "nativepointer.h"
#include "nodegate.h"
#include "jsctx.h"
#include "unwind.h"
@@ -28,6 +29,7 @@ namespace
JsPersistent handler;
JsPropertyId nativeStack = JsPropertyId(u"nativeStack");
DWORD threadId;
+ ULONG_PTR exceptionInfos[EXCEPTION_MAXIMUM_PARAMETERS];
DeferField() noexcept
{
@@ -75,11 +77,11 @@ namespace
}
return u"[Unknown]";
}
- bool addFunctionTable(VoidPointer* baseptr, int unwindcount, int fncount) throws(JsException)
+ bool addFunctionTable(VoidPointer* runtimeFunctionTable, int fncount, VoidPointer* baseptr) throws(JsException)
{
- if (baseptr == nullptr) throw JsException(u"Invalid arguments");
DWORD64 base = (DWORD64)baseptr->getAddressRawSafe();
- return RtlAddFunctionTable((RUNTIME_FUNCTION*)(base + unwindcount * sizeof(UNWIND_INFO)), fncount, base);
+ RUNTIME_FUNCTION* functionTable = (RUNTIME_FUNCTION*)runtimeFunctionTable->getAddressRawSafe();
+ return RtlAddFunctionTable(functionTable, fncount, base);
}
}
@@ -165,12 +167,12 @@ ATTR_NORETURN void runtimeError::raise(EXCEPTION_POINTERS* exptr) noexcept
AText16 stack = getStack(exptr);
if (stack.endsWith('\n')) stack.pop();
-
CsLock lock = s_stackLock;
if (s_nativeErrorCode != 0) break;
s_nativeErrorCode = code;
s_threadId = threadId;
s_nativeExceptionStack << move(stack);
+ memcpy(s_field->exceptionInfos, exptr->ExceptionRecord->ExceptionInformation, sizeof(s_field->exceptionInfos));
}
catch (...)
{
@@ -231,6 +233,13 @@ kr::JsValue runtimeError::getError() noexcept
message << u']';
err.set(u"stack", (Text16)message);
}
+ JsValue exceptionInfos = JsNewArray(EXCEPTION_MAXIMUM_PARAMETERS);
+ err.set(u"exceptionInfos", exceptionInfos);
+ for (size_t i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++) {
+ JsValue addr = NativePointer::newInstanceRaw({});
+ addr.getNativeObject()->setAddressRaw((void*)s_field->exceptionInfos[i]);
+ exceptionInfos.set((int)i, addr );
+ }
return err;
}
kr::JsValue runtimeError::getRuntimeErrorClass() noexcept
diff --git a/bdsx/version.bat b/bdsx/version.bat
index e2d3a9a..6502e96 100644
--- a/bdsx/version.bat
+++ b/bdsx/version.bat
@@ -1,2 +1,2 @@
-set BDSX_CORE_VERSION=1.0.7.0
+set BDSX_CORE_VERSION=1.0.8.0
diff --git a/bdsx/voidpointer.cpp b/bdsx/voidpointer.cpp
index 2537629..12efa2a 100644
--- a/bdsx/voidpointer.cpp
+++ b/bdsx/voidpointer.cpp
@@ -25,7 +25,9 @@ void* VoidPointer::getAddressRaw() noexcept
}
void* VoidPointer::getAddressRawSafe() noexcept
{
- if (this == nullptr) return nullptr;
+ if (this == nullptr) {
+ return nullptr;
+ }
return m_address;
}
int32_t VoidPointer::getAddressLow() noexcept
@@ -54,7 +56,7 @@ kr::JsValue VoidPointer::addressOfThis() noexcept
bool VoidPointer::equals(VoidPointer* other) noexcept
{
- if (other == nullptr) return false;
+ if (other == nullptr) return m_address == nullptr;
return m_address == other->m_address;
}
NativePointer* VoidPointer::pointer() noexcept
@@ -171,7 +173,6 @@ void VoidPointer::initMethods(JsClassT* cls) noexcept
cls->setMethod(u"addBin", &VoidPointer::addBin);
cls->setMethod(u"subBin", &VoidPointer::subBin);
cls->setMethod(u"subptr", &VoidPointer::subptr);
- cls->setMethod(u"clone", &VoidPointer::pointer);
cls->setMethod(u"as", &VoidPointer::as);
cls->setMethod(u"addAs", &VoidPointer::addAs);
@@ -182,6 +183,48 @@ void VoidPointer::initMethods(JsClassT* cls) noexcept
cls->setMethod(u"isNull", &VoidPointer::isNull);
cls->setMethod(u"isNotNull", &VoidPointer::isNotNull);
cls->setMethod(u"toString", &VoidPointer::toString);
+
+ cls->setStaticMethodRaw(u"fromAddress", [](const JsArguments& args) {
+ JsValue instance = JsClass(args.getThis()).newInstanceRaw({});
+ VoidPointer* ptr = instance.getNativeObject();
+ if (ptr == nullptr) throw JsException(TSZ16() << instance.get(u"name").cast() << u" is not *Pointer");
+
+ uint32_t low = args.at(0);
+ uint32_t high = args.at(1);
+ ptr->setAddressRaw((void*)(((uint64_t)high << 32) | low));
+ return instance;
+ });
+ cls->setStaticMethodRaw(u"fromAddressBin", [](const JsArguments& args) {
+ JsValue instance = JsClass(args.getThis()).newInstanceRaw({});
+ VoidPointer* ptr = instance.getNativeObject();
+ if (ptr == nullptr) throw JsException(TSZ16() << instance.get(u"name").cast() << u" is not *Pointer");
+ ptr->setAddressRaw((void*)::getBin64(args.at(0)));
+ return instance;
+ });
+ cls->setStaticMethodRaw(u"fromAddressBuffer", [](const JsArguments& args) {
+ JsValue instance = JsClass(args.getThis()).newInstanceRaw({});
+ VoidPointer* ptr = instance.getNativeObject();
+ if (ptr == nullptr) throw JsException(TSZ16() << instance.get(u"name").cast() << u" is not *Pointer");
+ if (args.size() == 0) return instance;
+ Buffer buf = args[0].getBuffer();
+ if (buf == nullptr) return instance;
+ ptr->setAddressRaw(buf.data());
+ return instance;
+ });
+ cls->setStaticMethodRaw(u"fromAddressString", [](const JsArguments& args) {
+ JsValue instance = JsClass(args.getThis()).newInstanceRaw({});
+ VoidPointer* ptr = instance.getNativeObject();
+ if (ptr == nullptr) throw JsException(TSZ16() << instance.get(u"name").cast() << u" is not *Pointer");
+ ptr->setAddressRaw(args.at(0).data());
+ return instance;
+ });
+ cls->setStaticMethodRaw(u"fromAddressFloat", [](const JsArguments& args) {
+ JsValue instance = JsClass(args.getThis()).newInstanceRaw({});
+ VoidPointer* ptr = instance.getNativeObject();
+ if (ptr == nullptr) throw JsException(TSZ16() << instance.get(u"name").cast() << u" is not *Pointer");
+ ptr->setAddressRaw((void*)(int64_t)args.at(0));
+ return instance;
+ });
}
template
diff --git a/packages/Microsoft.ChakraCore.vc140.1.11.24/build/native/Microsoft.ChakraCore.vc140.targets b/packages/Microsoft.ChakraCore.vc140.1.11.24/build/native/Microsoft.ChakraCore.vc140.targets
index f23e6a5..35f8379 100644
--- a/packages/Microsoft.ChakraCore.vc140.1.11.24/build/native/Microsoft.ChakraCore.vc140.targets
+++ b/packages/Microsoft.ChakraCore.vc140.1.11.24/build/native/Microsoft.ChakraCore.vc140.targets
@@ -4,13 +4,10 @@
$(MSBuildThisFileDirectory)..\..\lib\native\v140\arm\Debug\ChakraCore.lib;%(AdditionalDependencies)
$(MSBuildThisFileDirectory)..\..\lib\native\v140\arm\Release\ChakraCore.lib;%(AdditionalDependencies)
- $(MSBuildThisFileDirectory)..\..\lib\native\v140\arm\Release\ChakraCore.lib;%(AdditionalDependencies)
$(MSBuildThisFileDirectory)..\..\lib\native\v140\x64\Debug\ChakraCore.lib;%(AdditionalDependencies)
$(MSBuildThisFileDirectory)..\..\lib\native\v140\x64\Release\ChakraCore.lib;%(AdditionalDependencies)
- $(MSBuildThisFileDirectory)..\..\lib\native\v140\x64\Release\ChakraCore.lib;%(AdditionalDependencies)
$(MSBuildThisFileDirectory)..\..\lib\native\v140\x86\Debug\ChakraCore.lib;%(AdditionalDependencies)
$(MSBuildThisFileDirectory)..\..\lib\native\v140\x86\Release\ChakraCore.lib;%(AdditionalDependencies)
- $(MSBuildThisFileDirectory)..\..\lib\native\v140\x86\Release\ChakraCore.lib;%(AdditionalDependencies)
$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories)
@@ -28,7 +25,7 @@
-
+
@@ -36,7 +33,7 @@
-
+