您好,我对 root 手机上的硬件开发感兴趣。 我使用 libhardware.so 库访问硬件,但是当我使用硬件时,它崩溃了。 你能帮我解决这个话题吗?
#include <stdlib.h>
#include <stdint.h>
#include "hardware.h"
#include "camera.h"
int main(){
camera_module_t *rawModule;
int ret = hw_get_module(CAMERA_HARDWARE_MODULE_ID,(const hw_module_t **)&rawModule);
printf("[+] Return Code: %d\n",ret); //0
printf("[+] Module Name: %s\n",rawModule->common.name); // Qualcomm ...
rawModule->get_number_of_cameras(); //segmentation fault
}
Pixel 3 Android 10
I sh : type=1400 audit(0.0:5989): avc: denied { getattr } for path="/data/local/tmp/camera" dev="dm-6" ino=43725 scontext=u:r:kernel:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
I sh : type=1400 audit(0.0:5990): avc: denied { execute } for name="camera" dev="dm-6" ino=43725 scontext=u:r:kernel:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
I sh : type=1400 audit(0.0:5991): avc: denied { read open } for path="/data/local/tmp/camera" dev="dm-6" ino=43725 scontext=u:r:kernel:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
I sh : type=1400 audit(0.0:5992): avc: denied { execute_no_trans } for path="/data/local/tmp/camera" dev="dm-6" ino=43725 scontext=u:r:kernel:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
I camera : type=1400 audit(0.0:5993): avc: denied { read } for name="bin" dev="dm-4" ino=27 scontext=u:r:kernel:s0 tcontext=u:object_r:vendor_file:s0 tclass=dir permissive=1
W native : commandlineflags.cc:1311 Ignoring RegisterValidateFunction() for flag pointer 0x7d15344568: no flag found at that address
E CamX : [ERROR][CSL ] camxcslhwinternal.cpp:2615 CSLHwInternalDefaultOpen() Open failed for Device /dev/video1 with error reason Operation already in progress
E CamX : [ERROR][CSL ] camxcslhwinternal.cpp:1441 CSLHwAddKMDPrivateDeviceToInstance() Open failed for CSL Private device /dev/video1 with group id=65536 with error reason Operation already in progress
E CamX : [ERROR][CSL ] camxcslhw.cpp:96 CSLInitializeHW() Failed to acquire requestManager invalid
E CamX : [ERROR][CORE ] camxhwenvironment.cpp:267 Initialize() HwEnvironment initialization failed. We're going to die
E CamX : [ERROR][UTILS ] camxcmdbuffermanager.cpp:154 InitializePool() Out of memory
I camera : type=1400 audit(0.0:6155): avc: denied { read } for name="AE_calibration.cal" dev="sdf2" ino=233 scontext=u:r:kernel:s0 tcontext=u:object_r:persist_camera_file:s0 tclass=file permissive=1
E CamX : [ERROR][SENSOR ] camximagesensormoduledata.cpp:524 Probe() Failed to create Packet Manager cmdbuffermanager
E CamX : [ERROR][UTILS ] camxcmdbuffermanager.cpp:154 InitializePool() Out of memory
E CamX : [ERROR][SENSOR ] camximagesensormoduledata.cpp:524 Probe() Failed to create Packet Manager cmdbuffermanager
E CamX : [ERROR][UTILS ] camxcmdbuffermanager.cpp:154 InitializePool() Out of memory
E CamX : [ERROR][SENSOR ] camximagesensormoduledata.cpp:524 Probe() Failed to create Packet Manager cmdbuffermanager
I camera : type=1400 audit(0.0:6156): avc: denied { open } for path="/mnt/vendor/persist/camera/AE_calibration.cal" dev="sdf2" ino=233 scontext=u:r:kernel:s0 tcontext=u:object_r:persist_camera_file:s0 tclass=file permissive=1
F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 16537 (camera), pid 16537 (camera)
I crash_dump64: type=1400 audit(0.0:6158): avc: denied { ptrace } for scontext=u:r:crash_dump:s0 tcontext=u:r:kernel:s0 tclass=process permissive=1
I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
I /system/bin/tombstoned: received crash request for pid 16537
I crash_dump64: performing dump of process 16537 (target tid = 16537)
F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
F DEBUG : Revision: 'MP1.0'
F DEBUG : ABI: 'arm64'
F DEBUG : pid: 16537, tid: 16537, name: camera >>> ./camera <<<
F DEBUG : uid: 0
F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
F DEBUG : Cause: null pointer dereference
F DEBUG : x0 0000007d148610a8 x1 0000000000000008 x2 0000000000000000 x3 000000000000001c
F DEBUG : x4 0000000000000000 x5 0000000000000000 x6 0000000000000001 x7 8000000000800000
F DEBUG : x8 0000000000000000 x9 00000000000c2668 x10 0000000000004001 x11 0000000000000000
F DEBUG : x12 0000000000001000 x13 00000000002a8678 x14 0000000000000001 x15 001468a5bdbe6b54
F DEBUG : x16 0000007d1662f890 x17 0000007d16622078 x18 0000007d17776000 x19 0000007d1479ea40
F DEBUG : x20 0000007d169e9020 x21 0000007fc7b63030 x22 0000007d169e9020 x23 0000007d148610a4
F DEBUG : x24 0000007d148610a0 x25 0000000000000000 x26 0000000000000000 x27 0000000000000000
F DEBUG : x28 0000000000000000 x29 0000007fc7b63110
F DEBUG : sp 0000007fc7b63030 lr 0000007d146e0dd0 pc 0000000000000000
I crash_dump64: type=1400 audit(0.0:6159): avc: denied { read } for name="camera" dev="dm-6" ino=43725 scontext=u:r:crash_dump:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=1
F DEBUG :
F DEBUG : backtrace:
F DEBUG : #00 pc 0000000000000000 <unknown>
F DEBUG : #01 pc 000000000031edcc /vendor/lib64/hw/camera.sdm845.so (CamX::HwEnvironment::InitCaps()+324) (BuildId: 7b07e4892477864a45e33db5338941a4)
F DEBUG : #02 pc 000000000031eb80 /vendor/lib64/hw/camera.sdm845.so (CamX::HwEnvironment::GetInstance()+48) (BuildId: 7b07e4892477864a45e33db5338941a4)
F DEBUG : #03 pc 00000000001ba18c /vendor/lib64/hw/camera.sdm845.so (CamX::HAL3Module::HAL3Module()+56) (BuildId: 7b07e4892477864a45e33db5338941a4)
F DEBUG : #04 pc 00000000001b8ac4 /vendor/lib64/hw/camera.sdm845.so (CamX::HAL3Module::GetInstance()+76) (BuildId: 7b07e4892477864a45e33db5338941a4)
F DEBUG : #05 pc 00000000001b3530 /vendor/lib64/hw/camera.sdm845.so (CamX::get_number_of_cameras()+72) (BuildId: 7b07e4892477864a45e33db5338941a4)
F DEBUG : #06 pc 00000000000009a4 /data/local/tmp/camera
空指针,得有源/vendor/lib64/hw/camera.sdm845.so码才能修复