File: nullsoft.c

package info (click to toggle)
orange 0.3.2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,780 kB
  • ctags: 506
  • sloc: sh: 9,533; ansic: 4,449; makefile: 96
file content (72 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifdef HAVE_CONFIG_H 
#include "config.h"
#endif
#include "liborange_internal.h"

#include <stdio.h>
#include <string.h>

#include "pe.h"

                        /* deadbeef -- very funny */
#define SIGNATURE       "\x00\x00\x00\x00\xef\xbe\xad\xdeNullsoft"
#define SIGNATURE_SIZE  16

bool orange_is_nullsoft_installer(const char* input_filename)
{
  bool success = false;
  uint32_t offset;
  FILE* input_file = NULL;
  int error;
  char signature[SIGNATURE_SIZE+1];
  unsigned bytes;

#if VERBOSE
  synce_trace("here");
#endif

  input_file = fopen(input_filename, "r");

  if (!pe_size(input_file, &offset))
  {
#if VERBOSE
    synce_trace("pe_size failed");
#endif
    goto exit;
  }

  error = fseek(input_file, offset, SEEK_SET);
  if (error)
  {
#if VERBOSE
    synce_trace("fseek failed");
#endif
    goto exit;
  }

  bytes = fread(signature, 1, SIGNATURE_SIZE, input_file);
  if (bytes != SIGNATURE_SIZE)
  {
#if VERBOSE
    synce_trace("fread failed");
#endif
    goto exit;
  }

  signature[SIGNATURE_SIZE] = '\0';

  if (strcmp(signature, SIGNATURE) != 0)
  {
#if VERBOSE
    synce_trace("signature comparison failed");
#endif
    goto exit;
  }

  success = true;

exit:
  FCLOSE(input_file);
  return success;
}