-
Notifications
You must be signed in to change notification settings - Fork 0
Guidance for pure JS #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Nope
Yes, you can run this function without Node.js, you just need a way to execute machine code from JavaScript. In
Those basically implement the below methods for V8 and Duktape, respectively:
For just running
The // Allocate r - readable, w - writable, e - executable memory
var sb = StaticBuffer.alloc(size, 'rwe');
// Write executable code to your sb
// Execute the code at offset 0 with no args
sb.call(0, []);
Write me at |
Hi Sir,
Thank you very much.I appreciate that.
Thanks for the efforts in giving me the msg.
I will try out.
Thanks,
M.Omkumar
…On Sat, Mar 4, 2017 at 8:34 AM, streamich ***@***.***> wrote:
Also In order to detect VM, Testing the virtual BIOS DMI information and
the hypervisor port
becomes necessary apart from getting CPU ID
Do you have code to get those in the jskernel lib?
Nope
I am looking for similiar approach with pure JS instead of Node.
Yes, you can run this function without Node.js, you just need a way to
execute machine code from JavaScript.
In full-js project I do it using a thing called StaticBuffer, which is
just like Node's Buffer but has a call function that can execute the
machine code that is written to the buffer buffer.call().
full-js creates the StaticBuffer constructor automatically given some low
level dependencies are provided by the JavaScript runtime, here is how I do
it for V8 and Duktape:
- V8: https://github.com/streamich/full-js/blob/master/runtime/
v8/full-v8.cpp
- Duktape: https://github.com/streamich/full-js/blob/master/runtime/
duktape/full-duktape.c
Those basically implement the below methods for V8 and Duktape,
respectively:
- process.syscall(number, ...args): number
- process.syscall64(number, ...args): number
- process.asyscall(number, ...args, callback)
- process.asyscall64(number, ...args, callback)
- process.frame(address, size): StaticArrayBuffer
- process.call(addr: any, offset?: number, args?: number[]): number
- process.errno(): number
For just running cpuid, you need process.syscall, process.frame and
process.call.
process.syscall to allocate executable memory, process.frame to wrap that
memory block into a Buffer and process.call to execute the machine code
in that block.
The StaticBuffer class (which you can find here
<https://github.com/streamich/full-js/blob/master/src/lib/static-buffer.js>)
does all of that for you, just include it and its dependencies and it will
work like this:
// Allocate r - readable, w - writable, e - executable memoryvar sb = StaticBuffer.alloc(size, 'rwe');
// Write executable code to you sb
// Execute the code at offset 0 with no argssb.call(0, []);
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ARTtoFXPWSaIdE1ZsnwDu6XMsrIkqZxbks5riZKigaJpZM4MS7HZ>
.
|
Did you manage to run this without Node.js and could you share the source code please? |
Hi ,
Thanks for this wonderful app for reading device via node
I am looking for similiar approach with pure JS instead of Node.
Is there any way to use this code.
Also In order to detect VM, Testing the virtual BIOS DMI information and the hypervisor port
becomes necessary apart from getting CPU ID
Do you have code to get those in the jskernel lib?
If possible can you give your contact email id.
The text was updated successfully, but these errors were encountered: