• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

vendor/intel/houdini


Commit MetaInfo

修訂cf2804ce8c89dc62c4c94a80a431f3aaace6d49d (tree)
時間2015-01-01 19:49:24
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Retry the hook library until successful

Change Summary

差異

--- a/bin/enable_houdini
+++ b/bin/enable_houdini
@@ -1,5 +1,26 @@
11 #!/system/bin/sh
22
3+cd /system/lib/arm
4+if [ ! -e ../libhoudini.so -a ! -e libhoudini.so ]; then
5+ if touch .dl_houdini; then
6+ rm -f .dl_houdini
7+ else
8+ cd .. && cp -a arm /data/local/tmp
9+ mount -t tmpfs tmpfs arm && cd arm &&
10+ cp -a /data/local/tmp/arm/* . && rm -rf /data/local/tmp/arm
11+ fi
12+fi
13+
14+while [ ! -e ../libhoudini.so -a ! -e libhoudini.so ]; do
15+ while [ "$(getprop net.dns1)" = "" ]; do
16+ sleep 10
17+ done
18+ [ "`uname -m`" = "x86_64" ] && url=http://goo.gl/sfZRr5 || url=http://goo.gl/vvsfmp
19+ wget $url -cO houdini.tgz &&
20+ bzcat houdini.tgz | tar xvf - && rm -f houdini.tgz
21+ sleep 30
22+done
23+
324 # if you don't see the files 'register' and 'status' in /proc/sys/fs/binfmt_misc
425 # then run the following command:
526 # mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
@@ -23,14 +44,13 @@ if [ -e /proc/sys/fs/binfmt_misc/register ]; then
2344 houdini_bin=1
2445 fi
2546 else
26- echo "No binfmt_misc support"
47+ log -pe -thoudini "No binfmt_misc support"
2748 fi
2849
2950 if [ $houdini_bin -eq 0 ]; then
30- echo "houdini enabling failed !!!"
31-fi
32-if [ $houdini_bin -eq 1 ]; then
33- echo "houdini enabled"
51+ log -pe -thoudini "houdini enabling failed!"
52+else
53+ log -pi -thoudini "houdini enabled"
3454 fi
3555
3656 exit 0
--- a/src/libhoudini_hook.cpp
+++ b/src/libhoudini_hook.cpp
@@ -20,11 +20,18 @@ extern "C" void dvmPlatformInvoke(void *pEnv, void *clazz, int argInfo, int argc
2020
2121 namespace houdini {
2222
23+static void *(*h_dvmHookDlopen)(const char *, int, bool *) = 0;
24+static int (*h_dvmHookJniOnload)(bool, void *, void *, void *) = 0;
25+static bool (*h_dvmHookCheckMethod)(void *) = 0;
26+static void (*h_dvmHookCreateActivity)(bool, void *, void *, void *, void *, size_t) = 0;
27+static void (*h_dvmHookPlatformInvoke)(void *, void *, int, int, const int *, const char *, void *, void *) = 0;
28+static void *(*h_dvmHookDlsym)(bool, void *, const char *) = 0;
29+
2330 static void *get_symbol(const char *symbol)
2431 {
25- static void *h_handle = dlopen("libdvm_houdini.so", RTLD_LAZY);
32+ static void *h_handle = 0;
2633
27- if (!h_handle) {
34+ if (!h_handle && !(h_handle = dlopen("libdvm_houdini.so", RTLD_LAZY))) {
2835 ALOGE("Unable to open libdvm_houdini lib");
2936 return 0;
3037 }
@@ -36,35 +43,41 @@ static void *get_symbol(const char *symbol)
3643 return func;
3744 }
3845
46+static void hookInit()
47+{
48+ h_dvmHookDlopen = (void *(*)(const char *, int, bool *)) get_symbol("_ZN7houdini10hookDlopenEPKciPb");
49+ h_dvmHookJniOnload = (int (*)(bool, void *, void *, void *)) get_symbol("_ZN7houdini13hookJniOnloadEbPvS0_S0_");
50+ h_dvmHookCheckMethod = (bool (*)(void *)) get_symbol("_ZN7houdini15hookCheckMethodEPv");
51+ h_dvmHookCreateActivity = (void (*)(bool, void *, void *, void *, void *, size_t)) get_symbol("_ZN7houdini18hookCreateActivityEbPvS0_S0_S0_j");
52+ h_dvmHookPlatformInvoke = (void (*)(void *, void *, int, int, const int *, const char *, void *, void *)) get_symbol("_ZN7houdini21dvmHookPlatformInvokeEPvS0_iiPKiPKcS0_S0_");
53+ h_dvmHookDlsym = (void *(*)(bool, void *, const char *)) get_symbol("_ZN7houdini9hookDlsymEbPvPKc");
54+}
55+
3956 void *hookDlopen(const char *filename, int flag, bool *useHoudini)
4057 {
41- static void *(*h_dvmHookDlopen)(const char *, int, bool *) =
42- (void *(*)(const char *, int, bool *)) get_symbol("_ZN7houdini10hookDlopenEPKciPb");
58+ if (!h_dvmHookDlopen) {
59+ hookInit();
60+ }
4361
4462 return h_dvmHookDlopen ? h_dvmHookDlopen(filename, flag, useHoudini) : dlopen(filename, flag);
4563 }
4664
4765 int hookJniOnload(bool useHoudini, void *func, void *jniVm, void *arg)
4866 {
49- static int (*h_dvmHookJniOnload)(bool, void *, void *, void *) =
50- (int (*)(bool, void *, void *, void *)) get_symbol("_ZN7houdini13hookJniOnloadEbPvS0_S0_");
51-
5267 return h_dvmHookJniOnload ? h_dvmHookJniOnload(useHoudini, func, jniVm, arg) : ((int (*)(void *, void *))func)(jniVm, arg);
5368 }
5469
5570 bool hookCheckMethod(void *fnPtr)
5671 {
57- static bool (*h_dvmHookCheckMethod)(void *) =
58- (bool (*)(void *)) get_symbol("_ZN7houdini15hookCheckMethodEPv");
59-
6072 return h_dvmHookCheckMethod ? h_dvmHookCheckMethod(fnPtr) : false;
6173 }
6274
6375 void hookCreateActivity(bool useHoudini, void *createActivityFunc,
6476 void *activity, void *houdiniActivity, void *savedState, size_t savedStateSize)
6577 {
66- static void (*h_dvmHookCreateActivity)(bool, void *, void *, void *, void *, size_t) =
67- (void (*)(bool, void *, void *, void *, void *, size_t)) get_symbol("_ZN7houdini18hookCreateActivityEbPvS0_S0_S0_j");
78+ if (!h_dvmHookCreateActivity) {
79+ hookInit();
80+ }
6881 if (h_dvmHookCreateActivity) {
6982 h_dvmHookCreateActivity(useHoudini, createActivityFunc, activity, houdiniActivity, savedState, savedStateSize);
7083 } else {
@@ -75,9 +88,6 @@ void hookCreateActivity(bool useHoudini, void *createActivityFunc,
7588 void dvmHookPlatformInvoke(void *pEnv, void *clazz, int argInfo, int argc,
7689 const int *argv, const char *shorty, void *func, void *pReturn)
7790 {
78- static void (*h_dvmHookPlatformInvoke)(void *, void *, int, int, const int *, const char *, void *, void *) =
79- (void (*)(void *, void *, int, int, const int *, const char *, void *, void *)) get_symbol("_ZN7houdini21dvmHookPlatformInvokeEPvS0_iiPKiPKcS0_S0_");
80-
8191 if (h_dvmHookPlatformInvoke) {
8292 h_dvmHookPlatformInvoke(pEnv, clazz, argInfo, argc, argv, shorty, func, pReturn);
8393 } else {
@@ -87,9 +97,6 @@ void dvmHookPlatformInvoke(void *pEnv, void *clazz, int argInfo, int argc,
8797
8898 void *hookDlsym(bool useHoudini, void *handle, const char *symbol)
8999 {
90- static void *(*h_dvmHookDlsym)(bool, void *, const char *) =
91- (void *(*)(bool, void *, const char *)) get_symbol("_ZN7houdini9hookDlsymEbPvPKc");
92-
93100 return h_dvmHookDlsym ? h_dvmHookDlsym(useHoudini, handle, symbol) : dlsym(handle, symbol);
94101 }
95102