native-code

Sandboxing a program using WinAPI hooks

非 Y 不嫁゛ 提交于 2019-12-06 06:02:36
I'd like to sandbox a native code and use hooking of WinAPI and system functions to block or allow this program to perform some operations like reading/writing files, modify Windows registry, using an Internet connection. Is it a good and secure way to do so? How difficult would it be for that program to bypass such a security layer? +1 to Hans, however if you are really into it then I can recommend Easyhook . I have personally used it successfully in Win XP, Vista and 7. I don't know how bypassable it is but other alternatives do exist - madSHI hooks, and, if you want to go the official way,

Math inaccuracy in Javascript: safe to use JS for important stuff?

纵饮孤独 提交于 2019-12-06 05:03:22
I was bored, so I started fidlling around in the console, and stumbled onto this (ignore the syntax error): Some variable "test" has a value, which I multiply by 10K, it suddenly changes into different number (you could call it a rounding error, but that depends on how much accuracy you need). I then multiply that number by 10, and it changes back/again. That raises a few questions for me: How in accurate is Javascript? Has this been determined? I.e. a number that can be taken into account? Is there a way to fix this? I.e. to do math in Javascript with complete accuracy (within the limitations

How does CreateStdDispatch know what method to invoke?

雨燕双飞 提交于 2019-12-06 04:58:25
问题 i'm faced with implementing an IDispatch interface. There are four methods, and fortunately 3 of them are easy: function TIEEventsSink.GetTypeInfoCount(...): HResult; { Result := E_NOTIMPL; } function TIEEventsSink.GetTypeInfo(...): HResult; { Result := E_NOTIMPL; } function TIEEventsSink.GetIDsOfNames(...): HResult; { Result := E_NOTIMPL; } It's the last method, Invoke that is difficult. Here i am faced with having to actually case the DispID , and call my appropriate method; unmarhsalling

How to Debug native code using ndk-gdb

风流意气都作罢 提交于 2019-12-06 03:35:07
This is what I am getting after running ndk-gdb according to many tutorials when it links to you to (gdb) server you have to type continue but what after that how to debug the code there after. In my case it displays Continuing and remain like this. WHat i have to do further I am totally clueless. Arathore@chd-arathore-AND /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo $ /cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/ndk-gdb --verbose --adb=/cygdrive/D/All_Required_Stuff/Android/android-sdk-windows/platform-tools/adb.exe Android NDK installation path: /cygdrive/d/All

Is it possible to get Android.mk or native source file from .apk file?

寵の児 提交于 2019-12-06 02:33:01
It seems that it is quite easy to get Java source files from .apk file. But is it possible to get Android.mk or native source file from .apk file, by tools or tricky methods? I am doing research on Android app native code security so that these files are quite important for me. Thanks. You cannot get Android.mk from an apk, it's only needed for building, as such, it's not stored in there (unless the programmer put it in the res/ folder or something like that). All of the native code for an app is stored in the libs/ directory in the root of the apk. It's compiled ARM or x86 code, or both. You

How to run assembly code without creating a new process?

邮差的信 提交于 2019-12-06 01:52:33
The file contains the native assembly code, and I want to run it in the current process. But I don't want to create a real file (.com or .exe), so I tried: ... using namespace std; typedef void bitcode(); void testcode(){ cout<<"test"; }; int main() { bitcode *c=&testcode; // bitcode *c stands for the file containing the assembly code. bitcode *d=reinterpret_cast<bitcode*> (malloc(20)); memcpy(d, c, 20); d(); // it doesn't work return 0; }; However, it doesn't work when I invoke d();. I want to know what's the correct way to do this with C/C++. (I'm on Windows, and I’d appreciate it very much

Invalid indirect reference on NewObject call

落花浮王杯 提交于 2019-12-05 05:10:45
OK, so I have the native code below. I'm trying to return an array of FilePermissionInfo from it, populated with some data returned by stat(). The problem is that I get the following error when NewObject is called the first time: 06-15 20:25:17.621: W/dalvikvm(2287): Invalid indirect reference 0x40005820 in decodeIndirectRef 06-15 20:25:17.621: E/dalvikvm(2287): VM aborting It's odd, because the only reference object I have is the jclass (for FilePermissionInfo) and I turn it to a global reference. The code is: JNIEXPORT jobjectArray JNICALL Java_com_mn_rootscape_utils_NativeMethods

Why native wrapped functions in Dart are such heavyweight in comparison with “DEFINE NATIVE ENTRY” functions that are very lightweight?

我是研究僧i 提交于 2019-12-05 00:39:22
问题 I cannot understand: "Why this reassurance?". This is wrapper for custom native function from dart/runtime/vm/native_entry.cc : It intended for the Dart programmers that want write native extensions . void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, Dart_NativeFunction func) { CHECK_STACK_ALIGNMENT; VERIFY_ON_TRANSITION; NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); Isolate* isolate = arguments->isolate(); ApiState* state = isolate->api_state(); ASSERT

Android NDK Native LIB, What to do about existing stdio?

落花浮王杯 提交于 2019-12-04 17:28:19
I have existing native C/C++ code that I am currently building into a native lib and Android app via the NDK. The native code is riddled with print statements to stdout and stderr. Is there a best practice for something like this? Can I just ignore them or do I need to go through and redirect them to the Android logging system? I built the existing code as a standalone native binary and ran it via adb and I was seeing all the output from printf (to stdout) to the console. Seems like a goofy question to ask but where does stdio go for an Android app? By default stdout and stderr are sent to

Can I create a Bitmap that uses malloced buffer I created in native code?

我们两清 提交于 2019-12-04 14:32:01
I have a piece of native code where I am mallocing (i.e. allocating) a buffer. I like to draw into this memory using Canvas draw operations. But Canvas code uses Bitmap as its backing plane. I am wondering if there is a way to wrap native block of memory with Android Bitmap. Thanks Videoguy You can pass a Buffer from JAVA, fill it in Native code and then render it using Canvas. Done, works perfectly. edited to add an example: warning, Java bloat ahead /* * Copyright (C) 2009 The Android Open Source Project */ package com.example.hellojni; import android.app.Activity; import android.widget