summaryrefslogtreecommitdiffstats
path: root/src/file_lnk.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-09-16 16:34:29 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2012-09-16 16:34:29 +0200
commit25cd826553669535815657223c3ad80eef58d18b (patch)
treee9b3635ee9ebb0b8bb2ab3bb03c50dac3aaf146a /src/file_lnk.c
parentd5ec1a37dba590399170b2484efd7ece388ab160 (diff)
src/file_lnk.c: generate log only if DEBUG_LNK is defined
Diffstat (limited to 'src/file_lnk.c')
-rw-r--r--src/file_lnk.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/file_lnk.c b/src/file_lnk.c
index d050237..be1d428 100644
--- a/src/file_lnk.c
+++ b/src/file_lnk.c
@@ -30,7 +30,9 @@
#include "types.h"
#include "filegen.h"
#include "common.h"
+#ifdef DEBUG_LNK
#include "log.h"
+#endif
static void register_header_check_lnk(file_stat_t *file_stat);
static int header_check_lnk(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
@@ -98,8 +100,10 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_PIDL)!=0)
{ /* The Shell Item Id List */
len=buffer[i]+(buffer[i+1]<<8);
+#ifdef DEBUG_LNK
log_debug("LNK Shell Item Id List at 0x%04x=%04x\n",
i, len);
+#endif
i+=2;
i+=len;
}
@@ -109,7 +113,9 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_LOCATION)!=0)
{ /* File location info */
len=buffer[i] + (buffer[i+1]<<8) + (buffer[i+2]<<16) + (buffer[i+3]<<24);
+#ifdef DEBUG_LNK
log_debug("LNK File location info at 0x%04x=%04x\n", i, len);
+#endif
i+=2;
i+=len;
}
@@ -119,7 +125,9 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_DESCRIPTION)!=0)
{ /* Description string */
len=buffer[i]+(buffer[i+1]<<8);
+#ifdef DEBUG_LNK
log_debug("LNK description string at 0x%04x=%04x\n", i, len);
+#endif
i+=2;
if((flags& SCF_UNICODE)!=0)
len*=2;
@@ -131,7 +139,9 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_RELATIVE)!=0)
{ /* Relative path */
len=buffer[i]+(buffer[i+1]<<8);
+#ifdef DEBUG_LNK
log_debug("LNK relative path at 0x%04x=%04x\n", i, len);
+#endif
i+=2;
if((flags& SCF_UNICODE)!=0)
len*=2;
@@ -143,7 +153,9 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_WORKDIR)!=0)
{ /* Working directory */
len=buffer[i]+(buffer[i+1]<<8);
+#ifdef DEBUG_LNK
log_debug("LNK Working directory at 0x%04x=%04x\n", i, len);
+#endif
i+=2;
if((flags& SCF_UNICODE)!=0)
len*=2;
@@ -155,7 +167,9 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_ARGS)!=0)
{ /* Command line string */
len=buffer[i]+(buffer[i+1]<<8);
+#ifdef DEBUG_LNK
log_debug("LNK Command line string at 0x%04x=%04x\n", i, len);
+#endif
i+=2;
if((flags& SCF_UNICODE)!=0)
len*=2;
@@ -167,7 +181,9 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_CUSTOMICON)!=0)
{ /* Icon filename string */
len=buffer[i]+(buffer[i+1]<<8);
+#ifdef DEBUG_LNK
log_debug("LNK Icon filename string at 0x%04x=%04x\n", i, len);
+#endif
i+=2;
if((flags& SCF_UNICODE)!=0)
len*=2;
@@ -179,7 +195,9 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_PRODUCT)!=0)
{
len=buffer[i]+(buffer[i+1]<<8);
+#ifdef DEBUG_LNK
log_debug("LNK Icon product at 0x%04x=%04x\n", i, len);
+#endif
i+=2;
i+=len;
}
@@ -189,7 +207,9 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
if((flags&SCF_COMPONENT)!=0)
{
len=buffer[i]+(buffer[i+1]<<8);
+#ifdef DEBUG_LNK
log_debug("LNK Icon component at 0x%04x=%04x\n", i, len);
+#endif
i+=2;
i+=len;
}
@@ -198,10 +218,14 @@ static int header_check_lnk(const unsigned char *buffer, const unsigned int buff
return 0;
/* Extra stuff */
len=buffer[i] + (buffer[i+1]<<8) + (buffer[i+2]<<16) + (buffer[i+3]<<24);
+#ifdef DEBUG_LNK
log_debug("LNK extra stuff at 0x%04x=%04x\n", i, len);
+#endif
i+=4;
i+=len;
+#ifdef DEBUG_LNK
log_debug("LNK size %u (0x%04x)\n", i, i);
+#endif
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_lnk.extension;
file_recovery_new->calculated_file_size=i;