From 7cf6c0ee2581002375a7a5e54098650e55034c68 Mon Sep 17 00:00:00 2001 From: Vitaliy Cherepanov Date: Thu, 6 Nov 2014 18:50:19 +0300 Subject: [PATCH] [FIX] smack access to screenshots Change-Id: Ife047b0ad8ea87ee63a49a52d8ac31f226b3b2b1 Signed-off-by: Vitaliy Cherepanov --- helper/dacapture.c | 18 ++++++++++++++++-- include/binproto.h | 14 +++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/helper/dacapture.c b/helper/dacapture.c index d6cd076..29aa622 100755 --- a/helper/dacapture.c +++ b/helper/dacapture.c @@ -360,11 +360,25 @@ int captureScreen() { chmod(dstpath, 0777); - PREPARE_LOCAL_BUF(); + /* welcome to the hell */ + log_t log; + PREPARE_LOCAL_BUF_THOUGH((char *)&log); + + /* skip header */ + LOCAL_BUF += offsetof(log_t, data); + /* pack screenshot name */ + BUF_PTR = pack_string(LOCAL_BUF, dstpath); /* file name */ + LOCAL_BUF = BUF_PTR; + + /* pack probe */ PACK_COMMON_BEGIN(MSG_PROBE_SCREENSHOT, API_ID_captureScreen, "", 0); PACK_COMMON_END('d', 0, 0, 0); PACK_SCREENSHOT(dstpath, getOrientation()); - FLUSH_LOCAL_BUF(); + SET_MSG_LEN(); + log.length = GET_MSG_LEN() + MSG_LEN_OFFSET + strlen(dstpath) + 1; + + /* send all message */ + printLog(&log, MSG_IMAGE); } else { diff --git a/include/binproto.h b/include/binproto.h index 99fda6d..30db24c 100644 --- a/include/binproto.h +++ b/include/binproto.h @@ -491,10 +491,22 @@ static char __attribute__((used)) *pack_ret(char *to, char ret_type, ...) char *BUF_PTR = LOCAL_BUF; \ char *RET_PTR = NULL +#define PREPARE_LOCAL_BUF_THOUGH(BUFF) \ + char *LOCAL_BUF = BUFF; \ + char *BUF_PTR = LOCAL_BUF; \ + char *RET_PTR = NULL + #define MSG_LEN_OFFSET 16 #define MSG_HDR_LEN 20 + +#define SET_MSG_LEN() \ + *(uint32_t *)(msg_buf + MSG_LEN_OFFSET) = (p - msg_buf) - MSG_HDR_LEN; + +#define GET_MSG_LEN() \ + (p - msg_buf) - MSG_HDR_LEN + #define FLUSH_LOCAL_BUF() \ - *(uint32_t *)(msg_buf + MSG_LEN_OFFSET) = (p - msg_buf) - MSG_HDR_LEN; \ + SET_MSG_LEN(); \ send(gTraceInfo.socket.daemonSock, msg_buf, (p - msg_buf), 0); \ free(LOCAL_BUF); \ LOCAL_BUF = NULL -- 2.7.4