本文整理汇总了C++中FAIL_ON_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ FAIL_ON_ERROR函数的具体用法?C++ FAIL_ON_ERROR怎么用?C++ FAIL_ON_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FAIL_ON_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: yr_finalize
YR_API int yr_finalize(void)
{
#if defined HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER < 0x10100000L
int i;
#endif
// yr_finalize shouldn't be called without calling yr_initialize first
if (init_count == 0)
return ERROR_INTERNAL_FATAL_ERROR;
yr_re_finalize_thread();
init_count--;
if (init_count > 0)
return ERROR_SUCCESS;
#if defined HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER < 0x10100000L
for (i = 0; i < CRYPTO_num_locks(); i ++)
yr_mutex_destroy(&openssl_locks[i]);
OPENSSL_free(openssl_locks);
#endif
FAIL_ON_ERROR(yr_thread_storage_destroy(&tidx_key));
FAIL_ON_ERROR(yr_thread_storage_destroy(&recovery_state_key));
FAIL_ON_ERROR(yr_re_finalize());
FAIL_ON_ERROR(yr_modules_finalize());
FAIL_ON_ERROR(yr_heap_free());
return ERROR_SUCCESS;
}
示例2: yr_initialize
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;
}
示例3: UnregisterShellMenu
void UnregisterShellMenu(std::wstring opt, wchar_t* keyBaseName)
{
HKEY root = GetRootKey(opt);
HKEY cmderKey;
FAIL_ON_ERROR(
RegCreateKeyEx(root, keyBaseName, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &cmderKey, NULL));
#ifdef XP
FAIL_ON_ERROR(SHDeleteKey(cmderKey, NULL));
FAIL_ON_ERROR(SHDeleteKey(root, SHELL_MENU_REGISTRY_PATH));
#else
FAIL_ON_ERROR(RegDeleteTree(cmderKey, NULL)););
示例4: yr_arena_append
int yr_arena_append(
YR_ARENA* target_arena,
YR_ARENA* source_arena)
{
uint8_t padding_data[15];
size_t padding_size = 16 - target_arena->current_page->used % 16;
if (padding_size < 16)
{
memset(&padding_data, 0xCC, padding_size);
FAIL_ON_ERROR(yr_arena_write_data(
target_arena,
padding_data,
padding_size,
NULL));
}
target_arena->current_page->next = source_arena->page_list_head;
source_arena->page_list_head->prev = target_arena->current_page;
target_arena->current_page = source_arena->current_page;
yr_free(source_arena);
return ERROR_SUCCESS;
}
示例5: _yr_re_fiber_split
int _yr_re_fiber_split(
RE_FIBER* fiber,
RE_FIBER_LIST* fiber_list,
RE_FIBER_POOL* fiber_pool,
RE_FIBER** new_fiber)
{
int32_t i;
FAIL_ON_ERROR(_yr_re_fiber_create(fiber_pool, new_fiber));
(*new_fiber)->sp = fiber->sp;
(*new_fiber)->ip = fiber->ip;
for (i = 0; i <= fiber->sp; i++)
(*new_fiber)->stack[i] = fiber->stack[i];
(*new_fiber)->next = fiber->next;
(*new_fiber)->prev = fiber;
if (fiber->next != NULL)
fiber->next->prev = *new_fiber;
fiber->next = *new_fiber;
if (fiber_list->tail == fiber)
fiber_list->tail = *new_fiber;
assert(fiber_list->tail->next == NULL);
assert(fiber_list->head->prev == NULL);
return ERROR_SUCCESS;
}
示例6: yr_finalize
int yr_finalize(void)
{
yr_re_finalize_thread();
#ifdef _WIN32
TlsFree(tidx_key);
TlsFree(recovery_state_key);
#else
pthread_key_delete(tidx_key);
pthread_key_delete(recovery_state_key);
#endif
FAIL_ON_ERROR(yr_re_finalize());
FAIL_ON_ERROR(yr_modules_finalize());
FAIL_ON_ERROR(yr_heap_free());
return ERROR_SUCCESS;
}
示例7: yr_scan_verify_match
int yr_scan_verify_match(
YR_AC_MATCH* ac_match,
uint8_t* data,
size_t data_size,
size_t data_base,
size_t offset,
YR_ARENA* matches_arena,
int flags)
{
YR_STRING* string = ac_match->string;
#ifdef PROFILING_ENABLED
clock_t start = clock();
#endif
if (data_size - offset <= 0)
return ERROR_SUCCESS;
if (flags & SCAN_FLAGS_FAST_MODE &&
STRING_IS_SINGLE_MATCH(string) &&
STRING_FOUND(string))
return ERROR_SUCCESS;
if (STRING_IS_FIXED_OFFSET(string) &&
string->fixed_offset != data_base + offset)
return ERROR_SUCCESS;
if (STRING_IS_LITERAL(string))
{
FAIL_ON_ERROR(_yr_scan_verify_literal_match(
ac_match, data, data_size, data_base, offset, matches_arena));
}
else
{
FAIL_ON_ERROR(_yr_scan_verify_re_match(
ac_match, data, data_size, data_base, offset, matches_arena));
}
#ifdef PROFILING_ENABLED
string->clock_ticks += clock() - start;
#endif
return ERROR_SUCCESS;
}
示例8: yr_scan_verify_match
int yr_scan_verify_match(
YR_SCAN_CONTEXT* context,
YR_AC_MATCH* ac_match,
uint8_t* data,
size_t data_size,
size_t data_base,
size_t offset)
{
YR_STRING* string = ac_match->string;
#ifdef PROFILING_ENABLED
clock_t start = clock();
#endif
if (data_size - offset <= 0)
return ERROR_SUCCESS;
if (context->flags & SCAN_FLAGS_FAST_MODE &&
STRING_IS_SINGLE_MATCH(string) &&
string->matches[context->tidx].head != NULL)
return ERROR_SUCCESS;
if (STRING_IS_FIXED_OFFSET(string) &&
string->fixed_offset != data_base + offset)
return ERROR_SUCCESS;
if (STRING_IS_LITERAL(string))
{
FAIL_ON_ERROR(_yr_scan_verify_literal_match(
context, ac_match, data, data_size, data_base, offset));
}
else
{
FAIL_ON_ERROR(_yr_scan_verify_re_match(
context, ac_match, data, data_size, data_base, offset));
}
#ifdef PROFILING_ENABLED
string->clock_ticks += clock() - start;
#endif
return ERROR_SUCCESS;
}
示例9: yr_parser_reduce_meta_declaration
int yr_parser_reduce_meta_declaration(
yyscan_t yyscanner,
int32_t type,
const char* identifier,
const char* string,
int64_t integer,
YR_META** meta)
{
YR_COMPILER* compiler = yyget_extra(yyscanner);
FAIL_ON_ERROR(yr_arena_allocate_struct(
compiler->metas_arena,
sizeof(YR_META),
(void**) meta,
offsetof(YR_META, identifier),
offsetof(YR_META, string),
EOL));
FAIL_ON_ERROR(yr_arena_write_string(
compiler->sz_arena,
identifier,
(char**) &(*meta)->identifier));
if (string != NULL)
{
FAIL_ON_ERROR(yr_arena_write_string(
compiler->sz_arena,
string,
&(*meta)->string));
}
else
{
(*meta)->string = NULL;
}
(*meta)->integer = integer;
(*meta)->type = type;
return ERROR_SUCCESS;
}
示例10: _yr_scan_verify_match
inline int _yr_scan_verify_match(
YR_AC_MATCH* ac_match,
uint8_t* data,
size_t data_size,
size_t offset,
YR_ARENA* matches_arena,
int fast_scan_mode)
{
YR_STRING* string = ac_match->string;
#ifdef PROFILING_ENABLED
clock_t start = clock();
#endif
if (data_size - offset <= 0)
return ERROR_SUCCESS;
if (fast_scan_mode &&
STRING_IS_SINGLE_MATCH(string) &&
STRING_FOUND(string))
return ERROR_SUCCESS;
if (STRING_IS_LITERAL(string))
{
FAIL_ON_ERROR(_yr_scan_verify_literal_match(
ac_match, data, data_size, offset, matches_arena));
}
else
{
FAIL_ON_ERROR(_yr_scan_verify_re_match(
ac_match, data, data_size, offset, matches_arena));
}
#ifdef PROFILING_ENABLED
string->clock_ticks += clock() - start;
#endif
return ERROR_SUCCESS;
}
示例11: _yr_ac_optimize_failure_links
int _yr_ac_optimize_failure_links(
YR_AC_AUTOMATON* automaton)
{
QUEUE queue = { NULL, NULL};
// Push root's children.
YR_AC_STATE* root_state = automaton->root;
YR_AC_STATE* state = root_state->first_child;
while (state != NULL)
{
FAIL_ON_ERROR(_yr_ac_queue_push(&queue, state));
state = state->siblings;
}
while (!_yr_ac_queue_is_empty(&queue))
{
YR_AC_STATE* current_state = _yr_ac_queue_pop(&queue);
if (current_state->failure != root_state)
{
if (_yr_ac_transitions_subset(current_state, current_state->failure))
current_state->failure = current_state->failure->failure;
}
// Push childrens of current_state
state = current_state->first_child;
while (state != NULL)
{
FAIL_ON_ERROR(_yr_ac_queue_push(&queue, state));
state = state->siblings;
}
}
return ERROR_SUCCESS;
}
示例12: module_load
int module_load(
YR_SCAN_CONTEXT* context,
YR_OBJECT* module_object,
void* module_data,
size_t module_data_size)
{
YR_HASH_TABLE* hash_table;
FAIL_ON_ERROR(yr_hash_table_create(17, &hash_table));
module_object->data = hash_table;
return ERROR_SUCCESS;
}
示例13: yr_arena_allocate_memory
int yr_arena_allocate_memory(
YR_ARENA* arena,
size_t size,
void** allocated_memory)
{
FAIL_ON_ERROR(yr_arena_reserve_memory(arena, size));
*allocated_memory = arena->current_page->address + \
arena->current_page->used;
arena->current_page->used += size;
return ERROR_SUCCESS;
}
示例14: _yr_emit_split
int _yr_emit_split(
RE_EMIT_CONTEXT* emit_context,
uint8_t opcode,
int16_t argument,
uint8_t** instruction_addr,
int16_t** argument_addr,
int* code_size)
{
assert(opcode == RE_OPCODE_SPLIT_A || opcode == RE_OPCODE_SPLIT_B);
if (emit_context->next_split_id == RE_MAX_SPLIT_ID)
return ERROR_REGULAR_EXPRESSION_TOO_COMPLEX;
FAIL_ON_ERROR(yr_arena_write_data(
emit_context->arena,
&opcode,
sizeof(uint8_t),
(void**) instruction_addr));
FAIL_ON_ERROR(yr_arena_write_data(
emit_context->arena,
&emit_context->next_split_id,
sizeof(RE_SPLIT_ID_TYPE),
NULL));
emit_context->next_split_id++;
FAIL_ON_ERROR(yr_arena_write_data(
emit_context->arena,
&argument,
sizeof(int16_t),
(void**) argument_addr));
*code_size = sizeof(uint8_t) + sizeof(RE_SPLIT_ID_TYPE) + sizeof(int16_t);
return ERROR_SUCCESS;
}
示例15: _yr_emit_inst_arg_int16
int _yr_emit_inst_arg_int16(
RE_EMIT_CONTEXT* emit_context,
uint8_t opcode,
int16_t argument,
uint8_t** instruction_addr,
int16_t** argument_addr,
int* code_size)
{
FAIL_ON_ERROR(yr_arena_write_data(
emit_context->arena,
&opcode,
sizeof(uint8_t),
(void**) instruction_addr));
FAIL_ON_ERROR(yr_arena_write_data(
emit_context->arena,
&argument,
sizeof(int16_t),
(void**) argument_addr));
*code_size = sizeof(uint8_t) + sizeof(int16_t);
return ERROR_SUCCESS;
}