Created
June 30, 2021 05:07
-
-
Save bakueikozo/ae5c14bd53f286593f4e9fea62b1dc9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static uint32_t (*real_local_sdk_video_set_encode_frame_callback)(uint32_t param1,uint32_t param2)=NULL; | |
typedef uint32_t (* framecb)(uint32_t); | |
void *pfunccb=NULL; | |
int cnt=0; | |
char fname[255]; | |
static uint32_t test_capture(void *param){ | |
// param is malloc'd pointer | |
if( cnt < 1000) { | |
fprintf(stderr,"callback!!!!!![%p]\n",param); | |
uint32_t *ptr=(uint32_t *)param; | |
uint32_t length=ptr[1]; | |
fprintf(stderr,"pack size=%d\n",length); | |
sprintf(fname,"/media/mmc/stream",cnt); | |
FILE *fp=fopen(fname,"wb"); | |
fseek(fp,0,SEEK_END); | |
fwrite((void *)(*(uint32_t*)param),1,length,fp); | |
fclose(fp); | |
cnt++; | |
} | |
return ((framecb)pfunccb)((uint32_t)param); | |
} | |
uint32_t local_sdk_video_set_encode_frame_callback(uint32_t param1,uint32_t param2){ | |
void *handle; | |
fprintf(stderr,"!!! injected local_sdk_video_set_encode_frame_callback !!!\n"); | |
fflush(stderr); | |
if (real_local_sdk_video_set_encode_frame_callback == NULL){ | |
handle = dlopen ("/system/lib/liblocalsdk.so", RTLD_LAZY); | |
if (!handle) { | |
fputs (dlerror(), stderr); | |
} | |
real_local_sdk_video_set_encode_frame_callback = dlsym(handle, "local_sdk_video_set_encode_frame_callback"); | |
fprintf(stderr,"ptr=%d injected!!! err=%s\n",real_local_sdk_video_set_encode_frame_callback,dlerror()); | |
} | |
fprintf(stderr,"param1=0x%x,param2=0x%x,*param2=0x%x",param1,param2,*(int32_t*)param2); | |
if(param1==0){ | |
pfunccb=param2; | |
fprintf(stderr,"ch0 func injection save pcb=0x%x\n",pfunccb); | |
param2=(uint32_t)test_capture; | |
fprintf(stderr,"override to 0x%x\n",param2); | |
} | |
int ret=real_local_sdk_video_set_encode_frame_callback(param1,param2); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment