Esempio n. 1
0
int yr_initialize(void)
{
  int i;

  for (i = 0; i < 256; i++)
  {
    if (i >= 'a' && i <= 'z')
      altercase[i] = (char)i - 32;
    else if (i >= 'A' && i <= 'Z')
      altercase[i] = (char)i + 32;
    else
      altercase[i] = (char)i;

    lowercase[i] = (char)tolower(i);
  }

  FAIL_ON_ERROR(yr_heap_alloc());

  #ifdef _WIN32
  tidx_key = TlsAlloc();
  recovery_state_key = TlsAlloc();
  #else
  pthread_key_create(&tidx_key, NULL);
  pthread_key_create(&recovery_state_key, NULL);
  #endif

  FAIL_ON_ERROR(yr_re_initialize());
  FAIL_ON_ERROR(yr_modules_initialize());

  return ERROR_SUCCESS;
}
Esempio n. 2
0
void yr_initialize(void)
{
  int i;

  for (i = 0; i < 256; i++)
  {
    if (i >= 'a' && i <= 'z')
      altercase[i] = i - 32;
    else if (i >= 'A' && i <= 'Z')
      altercase[i] = i + 32;
    else
      altercase[i] = i;

    lowercase[i] = tolower(i);
  }

  yr_heap_alloc();

  #ifdef WIN32
  key = TlsAlloc();
  #else
  pthread_key_create(&key, NULL);
  #endif

  yr_re_initialize();
}
Esempio n. 3
0
YR_API int yr_initialize(void)
{
  uint32_t def_stack_size = DEFAULT_STACK_SIZE;
  int i;

  init_count++;

  if (init_count > 1)
    return ERROR_SUCCESS;

  for (i = 0; i < 256; i++)
  {
    if (i >= 'a' && i <= 'z')
      altercase[i] = i - 32;
    else if (i >= 'A' && i <= 'Z')
      altercase[i] = i + 32;
    else
      altercase[i] = i;

    lowercase[i] = tolower(i);
  }

  FAIL_ON_ERROR(yr_heap_alloc());
  FAIL_ON_ERROR(yr_thread_storage_create(&tidx_key));
  FAIL_ON_ERROR(yr_thread_storage_create(&recovery_state_key));

  #if defined HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER < 0x10100000L

  openssl_locks = (YR_MUTEX*) OPENSSL_malloc(
      CRYPTO_num_locks() * sizeof(YR_MUTEX));

  for (i = 0; i < CRYPTO_num_locks(); i++)
    yr_mutex_create(&openssl_locks[i]);

  CRYPTO_set_id_callback(thread_id);
  CRYPTO_set_locking_callback(locking_function);

  #endif

  FAIL_ON_ERROR(yr_re_initialize());
  FAIL_ON_ERROR(yr_modules_initialize());

  // Initialize default configuration options
  FAIL_ON_ERROR(yr_set_configuration(YR_CONFIG_STACK_SIZE, &def_stack_size));

  return ERROR_SUCCESS;
}