diff --git a/.gitmodules b/.gitmodules index 1b84d1a..8da7f3b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "node-chakracore"] path = node-chakracore url = https://github.com/karikera/node-chakracore -[submodule "elementminus"] - path = elementminus - url = https://github.com/karikera/elementminus.git diff --git a/README.md b/README.md index 57b68ca..d2ed429 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,10 @@ It's the core for [bdsx](https://github.com/karikera/bdsx) [NASM](https://www.nasm.us/) & Set PATH - required by node-chakracore [Python2.x](https://www.python.org/downloads/release/python-2718/) & Set PATH - required by node-chakracore -1. Clone bdsx-core, bdsx, ken(ken is a personal library project) +1. Clone bdsx-core, elementminus, ken **[parent directory]** -├ ken (https://github.com/karikera/ken) +├ ken (https://github.com/karikera/ken) - personal library project +├ elementminus (https://github.com/karikera/elementminus) - dll injecter for BDS └ bdsx-core (https://github.com/karikera/bdsx-core) 2. Update git submodules. diff --git a/bdsx/makefunc.cpp b/bdsx/makefunc.cpp index 0dcd0e6..eb8e4d4 100644 --- a/bdsx/makefunc.cpp +++ b/bdsx/makefunc.cpp @@ -75,6 +75,10 @@ namespace JsPropertyId pnullableReturn = u"nullableReturn"; JsPropertyId pnullableThis = u"nullableThis"; JsPropertyId pnullableParams = u"nullableParams"; + JsPropertyId pnativeDebugBreak = u"nativeDebugBreak"; +#ifndef NDEBUG + JsPropertyId pnativeDebugBreakOnMake = u"nativeDebugBreakOnMake"; +#endif }; Deferred s_field(JsRuntime::initpack); @@ -361,11 +365,19 @@ namespace JsValueRef js_pointer_new(JsValueRef ctor, JsValueRef* out) noexcept { - JsValue ctorv = JsClass((JsRawData)ctor).newInstanceRaw({JsValue(true)}); - *out = ctorv.getRaw(); + try + { + JsValue ctorv = JsClass((JsRawData)ctor).newInstanceRaw({ JsValue(true) }); + *out = ctorv.getRaw(); - VoidPointer* nptr = ctorv.getNativeObject(); - return nptr->getAddressRaw(); + VoidPointer* nptr = ctorv.getNativeObject(); + return nptr->getAddressRaw(); + } + catch (JsException& err) + { + JsSetException(err.getValue().getRaw()); + } + getout(JsErrorScriptException); } int64_t bin64(JsValueRef value, uint32_t paramNum) noexcept @@ -405,8 +417,8 @@ namespace catch (JsException& err) { JsSetException(err.getValue().getRaw()); - return nullptr; } + getout(JsErrorScriptException); } JsValueRef np2js_wrapper_nullable(void* ptr, JsValueRef func, JsValueRef ctor) noexcept { @@ -428,8 +440,8 @@ namespace catch (JsException& err) { JsSetException(err.getValue().getRaw()); - return nullptr; } + getout(JsErrorScriptException); } struct FunctionTable @@ -633,6 +645,7 @@ namespace bool nullableReturn; bool useThis; bool nullableParams; + bool nativeDebugBreak; JsValue thisType; TmpArray typeIds; @@ -656,6 +669,13 @@ namespace nullableReturn = opts.get(s_field->pnullableReturn).cast(); nullableThis = opts.get(s_field->pnullableThis).cast(); nullableParams = opts.get(s_field->pnullableParams).cast(); + nativeDebugBreak = opts.get(s_field->pnativeDebugBreak).cast(); +#ifndef NDEBUG + if (opts.get(s_field->pnativeDebugBreakOnMake).cast()) + { + debug(); + } +#endif if (useThis) { if (!thisType.prototypeOf(VoidPointer::classObject)) @@ -679,10 +699,12 @@ namespace } else { - structureReturn = 0; - useThis = 0; - nullableReturn = 0; - nullableThis = 0; + structureReturn = false; + useThis = false; + nullableReturn = false; + nullableThis = false; + nullableParams = false; + nativeDebugBreak = false; } countOnCalling = countOnMaking == PARAM_OFFSET - 1 ? 0 : countOnMaking - PARAM_OFFSET; @@ -799,6 +821,8 @@ namespace Maker(ParamInfoMaker& pi, size_t size, int32_t stackSize, bool useGetOut) noexcept :JitFunction(size), pi(pi), stackSize(stackSize) { + if (pi.nativeDebugBreak) debugBreak(); + mov(RAX, (qword)&returnPoint); mov(R10, QwordPtr, RAX); @@ -1287,7 +1311,10 @@ namespace { case RawTypeId::StructureReturn: { lea(RDX, RBP, offsetForStructureReturn); - mov(RCX, (qword)info.type.getRaw()); + + JsValueRef ref = info.type.getRaw(); + JsAddRef(ref, nullptr); + mov(RCX, (qword)ref); CALL(js_pointer_new); _mov(target, TARGET_RETURN, RawTypeId::Void, true); break; diff --git a/bdsx/version.bat b/bdsx/version.bat index 5be4411..1e2d69b 100644 --- a/bdsx/version.bat +++ b/bdsx/version.bat @@ -1,2 +1,2 @@ -set BDSX_CORE_VERSION=1.0.0.3 +set BDSX_CORE_VERSION=1.0.0.4 diff --git a/elementminus b/elementminus deleted file mode 160000 index 30c97a7..0000000 --- a/elementminus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 30c97a7d0dd8eb963b18042785ceaf714ac5790b