static int lookup_rules(void) { static import_t imports[] = { IMPORT("rule_engine.free", rules_free_result), IMPORT("rule_engine.dump", rules_dump_result), IMPORT("rule_engine.find", rule_find ), IMPORT("rule_engine.eval", rule_eval ) }; static rule_def_t ruldefs[] = { {"notification_request" , 2, ¬req }, {"notification_events" , 2, ¬evnt }, {"notification_play_short", 2, ¬plsh }, }; import_t *imp; rule_def_t *rd; unsigned int i; unsigned int n; int success; for (i = 0, success = TRUE; i < DIM(imports); i++) { imp = imports + i; if (*imp->methptr != NULL) continue; if (!ohm_module_find_method(imp->name, imp->sigptr, imp->methptr)) { OHM_ERROR("notification: can't find method '%s'", imp->name); success = FALSE; } } if (!success) return FALSE; for (i = n = 0; i < DIM(ruldefs); i++) { rd = ruldefs + i; if ((*(rd->rule) = rule_find(rd->name, rd->arity)) >= 0) n++; else { OHM_ERROR("notification can't find rule '%s/%d'", rd->name, rd->arity); success = FALSE; } } if (n == DIM(ruldefs)) OHM_INFO("notification: found all rules"); return success; }
/******************** * console_init ********************/ static int console_init(char *address) { char *signature; #define IMPORT(name, ptr) ({ \ signature = (char *)ptr##_SIGNATURE; \ ohm_module_find_method((name), &signature, (void *)&(ptr)); \ }) extension_init(); if (!strcmp(address, "disabled")) { OHM_INFO("resolver: console disabled"); return 0; } if (!IMPORT("console.open", console_open)) { OHM_INFO("resolver: no console methods available, console disabled"); return 0; } IMPORT("console.close" , console_close); IMPORT("console.printf", console_printf); IMPORT("console.grab" , console_grab); IMPORT("console.ungrab", console_ungrab); if (console_close == NULL || console_printf == NULL || console_grab == NULL || console_ungrab == NULL) { OHM_WARNING("resolver: missing console methods, console disabled"); return 0; } OHM_INFO("resolver: using console %s", address); console = console_open(address, console_opened, console_closed, console_input, NULL, FALSE); return console < 0 ? EINVAL : 0; #undef IMPORT }
static void dbgHelpLoad(LPCWSTR name, DbgHelp* dest) { HMODULE hMod = wenforce(LoadLibrary(name), L"Could not load " + std::wstring(name)); IMPORT(StackWalk64); IMPORT(SymFunctionTableAccess64); IMPORT(SymGetModuleBase64); IMPORT(SymCleanup); IMPORT(SymEnumerateModulesW64); IMPORT(SymSetSearchPathW); IMPORT(SymInitializeW); IMPORT(SymSetOptions); IMPORT(SymGetOptions); IMPORT(SymGetModuleInfoW64); IMPORT(SymFromAddrW); IMPORT(SymGetLineFromAddrW64); IMPORT(SymRegisterCallbackW64); IMPORT(SymRefreshModuleList); IMPORT(SymLoadModuleExW); IMPORT(SymSetDbgPrint); // Custom Wine extension IMPORT(MiniDumpWriteDump); }