static PRBool dhwEnsureImageHlpInitialized() { static PRBool gInitialized = PR_FALSE; static PRBool gTried = PR_FALSE; if (!gInitialized && !gTried) { gTried = PR_TRUE; HMODULE module = ::LoadLibrary("DBGHELP.DLL"); if (!module) { DWORD dw = GetLastError(); printf("DumpStack Error: DBGHELP.DLL wasn't found. GetLastError() returned 0x%8.8X\n" " This DLL is needed for succeessfully implementing trace-malloc.\n" " This dll ships by default on Win2k. Disabling trace-malloc functionality.\n" , dw); return PR_FALSE; } #define INIT_PROC(typename_, name_) \ dhw##name_ = (typename_) ::GetProcAddress(module, #name_); \ if(!dhw##name_) return PR_FALSE; INIT_PROC(ENUMERATELOADEDMODULES, EnumerateLoadedModules); INIT_PROC(IMAGEDIRECTORYENTRYTODATA, ImageDirectoryEntryToData); #undef INIT_PROC gInitialized = PR_TRUE; } return gInitialized; }
bool COldPlugin::load(const STRING file) { if (m_hModule || !g_pCallbacks) return false; m_hModule = LoadLibrary(file.c_str()); if (!m_hModule) return false; INIT_PROC pInit = INIT_PROC(GetProcAddress(m_hModule, _T("TKPlugInit"))); VERSION_PROC pVersion = VERSION_PROC(GetProcAddress(m_hModule, _T("TKPlugVersion"))); if (pInit) { pInit(&g_oldCallbacks[0], (!pVersion) ? 45 : g_oldCallbacks.size()); } else { FreeLibrary(m_hModule); return false; } m_plugBegin = BEGIN_PROC(GetProcAddress(m_hModule, _T("TKPlugBegin"))); m_plugQuery = QUERY_PROC(GetProcAddress(m_hModule, _T("TKPlugQuery"))); m_plugExecute = EXECUTE_PROC(GetProcAddress(m_hModule, _T("TKPlugExecute"))); m_plugEnd = END_PROC(GetProcAddress(m_hModule, _T("TKPlugEnd"))); m_plugType = TYPE_PROC(GetProcAddress(m_hModule, _T("TKPlugType"))); m_plugMenu = MENU_PROC(GetProcAddress(m_hModule, _T("TKPlugMenu"))); m_plugFight = FIGHT_PROC(GetProcAddress(m_hModule, _T("TKPlugFight"))); m_plugFightInform = FIGHT_INFORM_PROC(GetProcAddress(m_hModule, _T("TKPlugFightInform"))); m_plugInputRequested = INPUT_REQUESTED_PROC(GetProcAddress(m_hModule, _T("TKPlugInputRequested"))); m_plugEventInform = EVENT_INFORM_PROC(GetProcAddress(m_hModule, _T("TKPlugEventInform"))); if (m_plugInputRequested) { // This plugin accepts 'special' input. g_inputPlugins.insert(this); } return true; }
bool InitDriverTable(VkInstance instance, PFN_vkGetInstanceProcAddr get_proc, const std::bitset<ProcHook::EXTENSION_COUNT>& extensions) { auto& data = GetData(instance); bool success = true; // clang-format off INIT_PROC(instance, DestroyInstance); INIT_PROC(instance, EnumeratePhysicalDevices); INIT_PROC(instance, GetInstanceProcAddr); INIT_PROC(instance, CreateDevice); INIT_PROC(instance, EnumerateDeviceExtensionProperties); INIT_PROC_EXT(EXT_debug_report, instance, CreateDebugReportCallbackEXT); INIT_PROC_EXT(EXT_debug_report, instance, DestroyDebugReportCallbackEXT); INIT_PROC_EXT(EXT_debug_report, instance, DebugReportMessageEXT); // clang-format on return success; }
bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc, const std::bitset<ProcHook::EXTENSION_COUNT>& extensions) { auto& data = GetData(dev); bool success = true; // clang-format off INIT_PROC(true, dev, GetDeviceProcAddr); INIT_PROC(true, dev, DestroyDevice); INIT_PROC(true, dev, GetDeviceQueue); INIT_PROC(true, dev, CreateImage); INIT_PROC(true, dev, DestroyImage); INIT_PROC(true, dev, AllocateCommandBuffers); INIT_PROC(false, dev, GetDeviceQueue2); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage2ANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, AcquireImageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, QueueSignalReleaseImageANDROID); // clang-format on return success; }
Node build_proc_init_ara(Symbol type_name) /*;build_proc_init_ara*/ { /* * This is the main procedure for building default initialization * procedures for array types. Those initialization procedures are * built if the type given contains some subcomponent for which a * default initialization exists (at any level of nesting), or if it * has determinants. * Note that scalar objects are not initialized at all, which implies * that they get whatever initial value is in that location in memory * This saves some time in object creation. * * All init. procedures have an 'out' parameter that designates the * object being initialized (the space has already been allocated). * */ int side_effect; Tuple tup, formals, subscripts; Symbol c_type, ip, index_t, proc_name, index_sym; Node one_component, init_stmt, out_param, i_nodes, d_node, iter_node; Fortup ft1; Node iterator, index_node; #ifdef TRACE if (debug_flag) { gen_trace_symbol("BUILD_PROC_INIT_ARR", type_name); } #endif side_effect = FALSE; /* Let's hope... TBSL */ tup = SIGNATURE(type_name); c_type = (Symbol) tup[2]; one_component = new_node(as_index); ip = INIT_PROC(base_type(c_type)); if (ip != (Symbol)0 ){ /* Use the initialization procedure for the component type */ init_stmt = (Node) build_init_call(one_component, ip, c_type, OPT_NODE); } else if (is_task_type(c_type)) { /* initialization is task creation. */ init_stmt = new_assign_node(one_component, new_create_task_node(c_type)); } else if (is_access_type(c_type)) { /* default value is the null pointer. */ init_stmt = new_assign_node(one_component, new_null_node(c_type)); } else { init_stmt = (Node) 0; } if (init_stmt != (Node)0) { /* body of initialization procedure is a loop over the indices */ /* allocating each component. Generate loop variables and code */ /* for iteration, using the attributes of the type. */ proc_name = new_unique_name("type_name+INIT"); out_param = new_param_node("param_type_name", proc_name, type_name, na_out); generate_object(N_UNQ(out_param)); formals = tup_new1((char *) out_param); subscripts = tup_new(0); FORTUP(index_t=(Symbol), index_types(type_name), ft1); /*index = index_t + 'INDEX';*/ index_sym = new_unique_name("index_t+INDEX"); NATURE (index_sym) = na_obj; TYPE_OF(index_sym) = index_t; subscripts = tup_with(subscripts, (char *)new_name_node(index_sym)); ENDFORTUP(ft1); i_nodes = new_node(as_list); /* need tup_copy since subscripts used destructively below */ N_LIST(i_nodes) = tup_copy(subscripts); /* Build the tree for the one_component of the array. */ N_AST1(one_component) = out_param; N_AST2(one_component) = i_nodes; N_TYPE(one_component) = c_type; while (tup_size(subscripts)) { /* Build loop from innermost index outwards. The iterations */ /* span the ranges of the array being initialized. */ /* dimension spanned by this loop: */ d_node = new_ivalue_node(int_const(tup_size(subscripts)), symbol_integer); iterator = new_attribute_node(ATTR_O_RANGE, new_name_node(N_UNQ(out_param)), d_node, type_name); index_node = (Node) tup_frome(subscripts); iter_node = new_node(as_for); N_AST1(iter_node) = index_node; N_AST2(iter_node) = iterator; init_stmt = new_loop_node(OPT_NODE, iter_node, tup_new1((char *)init_stmt)); } INIT_PROC(type_name) = proc_name; return initialization_proc(proc_name, type_name, formals, tup_new1((char *) init_stmt)); } else { return OPT_NODE; } }
static Tuple proc_init_rec(Symbol type_name, Tuple field_names, Node variant_node, Node out_param) /*;proc_init_rec*/ { /* * This is a subsidiary procedure to BUILD_PROC_INIT, which performs * the recursive part of construction of an initialization procedure * for a record type. * * Input: field_names is a list of component unique names (excluding * discriminants. Variant node is the AST for the variant part * of a component list. * variant_node is the variant part of the record declaration * and has the same structure as a case statement. * * out_param designates the object being initialized * * Output: the statement list required to initialize this fragment of * the record, or [] if not default initialization is needed. */ Tuple init_stmt, stmts; Node one_component, f_init, c_node, variant_list; Symbol f_type, f_name, ip; Fortup ft1; int empty_case; Tuple case_list, comp_case_list; Node choice_list, comp_list, disc_node; Node invariant_node, new_case, list_node, case_node; Tuple tup, index_list; int nb_dim, i; Node d_node, node, node1, node2, node3, node4, node5; Symbol one_index_type; /* process fixed part first. */ init_stmt = tup_new(0); FORTUP(f_name=(Symbol), field_names, ft1); one_component = new_selector_node(out_param, f_name); f_type = TYPE_OF(f_name); CONTAINS_TASK(type_name) = (char *) ((int)CONTAINS_TASK(type_name) | (int) CONTAINS_TASK(f_type)); f_init = (Node) default_expr(f_name); if (f_init != OPT_NODE) { init_stmt = tup_with(init_stmt, (char *) new_assign_node(one_component, remove_discr_ref(f_init, out_param))); } else if ((ip = INIT_PROC(base_type(f_type)))!=(Symbol)0) { init_stmt = tup_with(init_stmt, (char *) build_init_call(one_component, ip, f_type, out_param)); } else if (is_task_type(f_type)) { init_stmt = tup_with(init_stmt, (char *) new_assign_node(one_component, new_create_task_node(f_type))); } else if (is_access_type(f_type)) { init_stmt = tup_with(init_stmt, (char *) new_assign_node(one_component, new_null_node(f_type))); } /* if we have an aray then we have to check if its bounds are * compatible with the index subtypes (of the unconstrained array) * (This code was generated beforehand in type.c ("need_qual_r") but * it was wrong : we have to test the bounds only if the field is * present (case of variant record). * The generation of the tests is easier here */ if (is_array_type (f_type)) { tup = (Tuple) SIGNATURE(TYPE_OF(f_type)); index_list = tup_copy((Tuple) tup[1]); nb_dim = tup_size(index_list); for (i = 1; i <= nb_dim; i++) { one_index_type = (Symbol) (tup_fromb (index_list)); d_node = new_ivalue_node(int_const(i), symbol_integer); node1 = new_attribute_node(ATTR_O_FIRST, one_component, d_node, one_index_type); node2 = new_attribute_node(ATTR_O_LAST, one_component, d_node, one_index_type); node3 = new_attribute_node(ATTR_T_FIRST, new_name_node(one_index_type), OPT_NODE, one_index_type); node4 = new_attribute_node(ATTR_T_LAST, new_name_node(one_index_type), OPT_NODE, one_index_type); node5 = new_binop_node(symbol_or, new_binop_node(symbol_lt, node1, node3, symbol_boolean), new_binop_node(symbol_gt, node2, node4, symbol_boolean), symbol_boolean); node = node_new (as_list); make_if_node(node, tup_new1((char *) new_cond_stmts_node( new_binop_node(symbol_and, new_binop_node(symbol_le, node1, node2, symbol_boolean), node5, symbol_boolean), new_raise_node(symbol_constraint_error))), OPT_NODE); init_stmt = tup_with(init_stmt, (char *) (node)); } } ENDFORTUP(ft1); /* then build case statement to parallel structure of variant part. */ empty_case = TRUE; /* assumption */ if (variant_node != OPT_NODE) { disc_node= N_AST1(variant_node); variant_list = N_AST2(variant_node); case_list = tup_new(0); comp_case_list = N_LIST(variant_list); FORTUP(c_node=(Node), comp_case_list, ft1); choice_list = N_AST1(c_node); comp_list = N_AST2(c_node); invariant_node = N_AST1(comp_list); variant_node = N_AST2(comp_list); field_names = build_comp_names(invariant_node); stmts = proc_init_rec(type_name,field_names,variant_node, out_param); /*empty_case and= stmts = [];*/ empty_case = empty_case ? (tup_size(stmts)==0) : FALSE; new_case = (N_KIND(c_node) == as_others_choice) ? new_node(as_others_choice) : new_node(as_variant_choices); N_AST1(new_case) = copy_tree(choice_list); N_AST2(new_case) = new_statements_node(stmts); case_list = tup_with(case_list, (char *) new_case ); ENDFORTUP(ft1); if (! empty_case) { /* Build a case statement ruled by the value of the discriminant */ /* for this variant part. */ list_node = new_node(as_list); N_LIST(list_node) = case_list; case_node = new_node(as_case); N_AST1(case_node) = new_selector_node(out_param, N_UNQ(disc_node)); N_AST2(case_node) = list_node; init_stmt = tup_with(init_stmt, (char *) case_node ); } } return init_stmt; }
Node build_proc_init_rec(Symbol type_name) /*;build_proc_init_rec*/ { /* * This is the main procedure for building default initialization * procedures for record types. Those initialization procedures are * built if the type given contains some subcomponent for which a * default initialization exists (at any level of nesting), or if it * has determinants. * Note that scalar objects are not initialized at all, which implies * that they get whatever initial value is in that location in memory * This saves some time in object creation. * * All init. procedures have an 'out' parameter that designates the * object begin initialized (the space has already been allocated). * */ int side_effect; Node invar_node; /* TBSL: is invar_node local??*/ Tuple stmts, tup, nstmts, formals, invariant_fields; Tuple discr_list; /* is this local ?? TBSL */ Fortup ft1; Symbol d, proc_name; Node param, var_node, out_param; Node node, node1, node2, discr_value_node; #ifdef TRACE if (debug_flag) gen_trace_symbol("BUILD_PROC_INIT_REC", type_name); #endif side_effect = FALSE; /* Let's hope... TBSL */ /* * The initialization procedure for records has the usual out param., * and one in parameter per discriminant. The CONSTRAINED flag is the * first of the discriminants */ proc_name = new_unique_name("Init_ type_name"); out_param = new_param_node("param_type_name", proc_name, type_name, na_out); generate_object(proc_name); generate_object(N_UNQ(out_param)); tup = SIGNATURE(type_name); invar_node = (Node) tup[1]; var_node = (Node) tup[2]; discr_list = (Tuple) tup[3]; invariant_fields = build_comp_names(invar_node); stmts = tup_new(0); if (tup_size(discr_list)) { /* Generate formal parameters for each. The body of the procedure */ /* assigns them to the field of the object. */ /* Note: the 'constrained' field is part of the discriminants. */ formals = tup_new(0); FORTUP(d=(Symbol), discr_list, ft1); param = new_param_node("param_type_name", proc_name, TYPE_OF(d), na_in); generate_object(N_UNQ(param)); formals = tup_with(formals, (char *) param ); stmts = tup_with(stmts, (char *) new_assign_node(new_selector_node(out_param, d), param)); discr_value_node = new_selector_node (out_param, d); /* generate code in order to test if the value of discriminant is * compatible with its subtype */ node1 = new_attribute_node(ATTR_T_FIRST, new_name_node(TYPE_OF(d)), OPT_NODE, TYPE_OF(d)); node2 = new_attribute_node(ATTR_T_LAST, new_name_node(TYPE_OF(d)), OPT_NODE, TYPE_OF(d)); node = node_new (as_list); make_if_node(node, tup_new1((char *) new_cond_stmts_node( new_binop_node(symbol_or, new_binop_node(symbol_lt, discr_value_node, node1, symbol_boolean), new_binop_node(symbol_gt, discr_value_node, node2, symbol_boolean), symbol_boolean), new_raise_node(symbol_constraint_error))), OPT_NODE); stmts = tup_with(stmts, (char *) node); ENDFORTUP(ft1); formals = tup_with(formals, (char *) out_param ); /* if there are default expressions for any other components, */ /* further initialization steps are needed. */ tup = proc_init_rec(type_name, invariant_fields, var_node, out_param); /*stmts += proc_init_rec(invariant_fields, var_node, out_param);*/ nstmts = tup_add(stmts, tup); tup_free(stmts); tup_free(tup); stmts = nstmts; } else { /* record without discriminants. There may still be default values */ /* for some components. */ formals = tup_new1((char *) out_param); stmts = proc_init_rec(type_name,invariant_fields,var_node, out_param); } if (tup_size(stmts)) { INIT_PROC(type_name) = proc_name; return initialization_proc(proc_name, type_name, formals, stmts); } else { return OPT_NODE; } }