WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 23932cb1 authored by Kunshan Wang's avatar Kunshan Wang
Browse files

WIP: Tested id_of and name_of.

parent 325749b4
......@@ -101,15 +101,21 @@ object ClientAccessibleClassExposer {
val ptr = NativeClientSupport.stringPool.getOrElseUpdate(str, {
val bytes = str.getBytes(StandardCharsets.US_ASCII)
val newPtr = jnrMemoryManager.allocateDirect(bytes.size + 1)
newPtr.put(0L, bytes, 0, 0)
newPtr.put(0L, bytes, 0, bytes.length)
newPtr.putByte(bytes.length, 0)
private def getObj[T](buffer: Buffer, index: Int, orm: ObjectReferenceManager[T]): T = {
val addr = buffer.getLong(index)
val arg0 = buffer.getLong(index)
val objAddr = theMemory.getAddress(arg0)
val obj = orm.get(jnrMemoryManager.newPointer(objAddr))
if (obj == null) {
throw new UvmRefImplException("Exposed object not found. Address: %d 0x%x".format(objAddr, objAddr))
// Reflection utils.
......@@ -20,7 +20,7 @@ class NativeClientSupportTest extends UvmBundleTesterBase {
trait NcsTestsLib {
def test_basic(mvm: Word): Unit
def test_basic(mvm: Word, theID: Int, theName: String): Int
val ncs_tests = LibraryLoader.create(classOf[NcsTestsLib]).load(fileName)
......@@ -34,10 +34,16 @@ class NativeClientSupportTest extends UvmBundleTesterBase {
val funcTablePtr = NativeClientSupport.funcTableToPointer(funcTable)
val header = funcTablePtr.getAddress(0)
val mvm =NativeClientSupport.microVMs.get(jnrMemoryManager.newPointer(header))
val mvm = NativeClientSupport.microVMs.get(jnrMemoryManager.newPointer(header))
mvm shouldBe microVM
val theName = "@i64"
val theID = microVM.idOf(theName)
val result = ncs_tests.test_basic(funcTable, theID, theName)
if (result == 0) {
fail("Failed in the native program.")
\ No newline at end of file
#include <stdio.h>
#include <string.h>
#include <muapi.h>
void test_basic(MuVM *mvm) {
int test_basic(MuVM *mvm, int theID, char *theName) {
printf("[C] header: %p\n", mvm->header);
printf("[C] new_context: %p\n", mvm->new_context);
printf("[C] id_of: %p\n", mvm->id_of);
printf("[C] name_of: %p\n", mvm->name_of);
printf("[C] set_trap_handler: %p\n", mvm->set_trap_handler);
int id = mvm->id_of(mvm, theName);
printf("[C] id = %d\n", id);
if (id != theID) {
printf("[C] ID %d is not equal to %d\n", id, theID);
return 0;
char *name = mvm->name_of(mvm, theID);
printf("[C] name = %s\n", name);
if (strcmp(name, theName) != 0) {
printf("[C] name %s is not equal to %s\n", name, theName);
return 0;
return 1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment