/************************************************************************************** ** Main *************************************************************************************** */ VOID main() { APTR oldfunct; APTR newfunct; if(!(AssemblyBase = OpenLibrary(ASSEMBLYNAME, ASSEMBLY_MINIMUM))) return(NULL); IntuitionBase = AssemblyBase->ab_IntuiBase; /* if(!(newfunct = AllocVec(1024,MEMF_FAST|MEMF_CLEAR))) { CloseLibrary(AssemblyBase); return(NULL); } CopyMemQuick(&MyRequest,newfunct,1024); */ Forbid(); /* oldfunct = SetFunction(IntuitionBase,_LVOEasyRequestArgs,newfunct); */ oldfunct = SetFunction(IntuitionBase,_LVOEasyRequestArgs,&MyRequest); Permit(); return(NULL); }
BrentsMethod<Real>::BrentsMethod (Function function, int maxIterations, Real negFTolerance, Real posFTolerance, Real stepXTolerance, Real convXTolerance, void* userData) { SetFunction(function); SetMaxIterations(maxIterations); SetNegFTolerance(negFTolerance); SetPosFTolerance(posFTolerance); SetStepXTolerance(stepXTolerance); SetConvXTolerance(convXTolerance); SetUserData(userData); }
void InstallPatches(void) { WORD i; Forbid(); for(i = 0; pi[i].library; i++) { SetFunction(GetLib(pi[i].library), -pi[i].whichfunc * LIB_VECTSIZE, __AROS_GETVECADDR(GetLib(pi[i].patchlibrary), pi[i].whichpatchfunc)); } Permit(); patches_installed = TRUE; }
// This function returns a pointer to a function or a Scilab pointer to a function // The choice is performed on the type of the given Scilab parameter voidf GetFunctionPtr(char * name, int n, FTAB Table[], voidf scifun, int * ifunc, int * lhs, int * rhs) { int type, rep, m_tmp, n_tmp, i; int * tmp_addr = NULL; int * pi_len = NULL; char ** pst_strings = NULL; voidf f; SciErr _SciErr; _SciErr = getVarAddressFromPosition(pvApiCtx, n, &tmp_addr); GLCPD_ERROR_RETURN_NULL; _SciErr = getVarType(pvApiCtx, tmp_addr, &type); GLCPD_ERROR_RETURN_NULL; switch(type) { case sci_strings: _SciErr = getMatrixOfString(pvApiCtx, tmp_addr, &n_tmp, &m_tmp, NULL, NULL); GLCPD_ERROR_RETURN_NULL; pi_len = (int *)MALLOC(n_tmp*m_tmp*sizeof(int)); pst_strings = (char **)MALLOC(n_tmp*m_tmp*sizeof(char *)); _SciErr = getMatrixOfString(pvApiCtx, tmp_addr, &n_tmp, &m_tmp, pi_len, NULL); GLCPD_ERROR_RETURN_NULL; for(i=0;i<n_tmp*m_tmp;i++) pst_strings[i] = (char *)MALLOC((pi_len[i]+1)*sizeof(char)); _SciErr = getMatrixOfString(pvApiCtx, tmp_addr, &n_tmp, &m_tmp, pi_len, pst_strings); GLCPD_ERROR_RETURN_NULL; f = SetFunction(pst_strings[0], &rep, Table); if (pst_strings) freeArrayOfString(pst_strings, n_tmp*m_tmp); if (pi_len) FREE(pi_len); if (rep==1) { Scierror(999,"Function not found is %s\n", name); return (voidf)0; } return f ; case sci_c_function: GetRhsVar(n, "f", lhs, rhs, ifunc); return (voidf)scifun ; default: Scierror(999,"Wrong parameter in %s ! (number %d)\r\n",name,n); return (voidf)0; } }
void SyGViewManPageDialog::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsViewButton && message.Is(JXButton::kPushed)) { ViewManPage(); if (!itsStayOpenCB->IsChecked()) { Deactivate(); } } else if (sender == itsCloseButton && message.Is(JXButton::kPushed)) { (GetWindow())->KillFocus(); Deactivate(); } else if (sender == itsHelpButton && message.Is(JXButton::kPushed)) { (JXGetHelpManager())->ShowSection(kSyGManPageHelpName); } else if (sender == itsFnHistoryMenu && message.Is(JXMenu::kItemSelected)) { SetFunction(itsFnHistoryMenu->GetItemText(message)); itsFnName->Focus(); } else if (sender == itsFnName && (message.Is(JTextEditor::kTextSet) || message.Is(JTextEditor::kTextChanged))) { UpdateDisplay(); } else { JXWindowDirector::Receive(sender, message); } }
StackFrame::~StackFrame() { for (int32 i = 0; Variable* variable = fParameters.ItemAt(i); i++) variable->ReleaseReference(); for (int32 i = 0; Variable* variable = fLocalVariables.ItemAt(i); i++) variable->ReleaseReference(); SetImage(NULL); SetFunction(NULL); SetPreviousCpuState(NULL); fDebugInfo->ReleaseReference(); fCpuState->ReleaseReference(); if (fValues != NULL) fValues->ReleaseReference(); if (fValueInfos != NULL) fValueInfos->ReleaseReference(); }
void gendrawselected(short *newselect, objectptr curobj, objinstptr curinst) { /* Don't draw selection color when selecting for edit */ if (eventmode == PENDING_MODE) return; if (*newselect >= curobj->parts) return; // Safety check XcSetFunction(GXcopy); XcSetForeground(BACKGROUND); geneasydraw(*newselect, DOFORALL, curobj, curinst); indicateparams(*(curobj->plist + *newselect)); XcSetFunction(GXxor); XcSetForeground(SELECTCOLOR ^ BACKGROUND); geneasydraw(*newselect, DOFORALL, curobj, curinst); SetForeground(dpy, areawin->gc, AUXCOLOR ^ BACKGROUND); indicateparams(*(curobj->plist + *newselect)); SetForeground(dpy, areawin->gc, areawin->gccolor); SetFunction(dpy, areawin->gc, areawin->gctype); }
bool CSPrimUserDefined::ReadFromXML(TiXmlNode &root) { if (CSPrimitives::ReadFromXML(root)==false) return false; int value; TiXmlElement* elem=root.ToElement(); if (elem==NULL) return false; if (elem->QueryIntAttribute("CoordSystem",&value)!=TIXML_SUCCESS) return false; SetCoordSystem((UserDefinedCoordSystem)value); //P1 TiXmlElement* P1=root.FirstChildElement("CoordShift"); if (P1==NULL) return false; if (ReadTerm(dPosShift[0],*P1,"X")==false) return false; if (ReadTerm(dPosShift[1],*P1,"Y")==false) return false; if (ReadTerm(dPosShift[2],*P1,"Z")==false) return false; TiXmlElement* FuncElem=root.FirstChildElement("Function"); if (FuncElem==NULL) return false; SetFunction(FuncElem->GetText()); return true; }
VOID InstallPatch () { Forbid(); APTR *patches = Patches; LONG offset = -30; while(*patches) { switch(offset) { /* case LVO_LockLayer: case LVO_UnlockLayer: case LVO_LockLayerInfo: case LVO_UnlockLayerInfo: */ /* case LVO_LockLayers: case LVO_UnlockLayers: case LVO_CreateUpfrontLayer: case LVO_CreateUpfrontHookLayer: case LVO_CreateBehindLayer: case LVO_CreateBehindHookLayer: case LVO_DeleteLayer: case LVO_DoHookClipRects: */ case LVO_SwapBitsRastPortClipRect: // case LVO_WhichLayer: break; default: SetFunction(LayersBase, offset, (ULONG(*)())*patches); break; } patches++; offset -= 6; } SetFunction((struct Library *)GfxBase, LVO_LockLayerRom, (ULONG(*)())pLockLayerRom); SetFunction((struct Library *)GfxBase, LVO_UnlockLayerRom, (ULONG(*)())pUnlockLayerRom); SetFunction((struct Library *)GfxBase, LVO_ScrollRaster, (ULONG(*)())pScrollRaster); SetFunction((struct Library *)GfxBase, LVO_ScrollRasterBF, (ULONG(*)())pScrollRasterBF); SetFunction((struct Library *)GfxBase, LVO_ClipBlit, (ULONG(*)())pClipBlit); Permit(); }
void DumpMemory() { HADESMEM_DETAIL_TRACE_A("Dumping image memory to disk."); hadesmem::Process const process{::GetCurrentProcessId()}; hadesmem::ModuleList modules(process); for (auto const& module : modules) { HADESMEM_DETAIL_TRACE_A("Checking for valid headers."); try { hadesmem::PeFile const pe_file(process, module.GetHandle(), hadesmem::PeFileType::Image, static_cast<DWORD>(module.GetSize())); hadesmem::NtHeaders nt_headers(process, pe_file); } catch (std::exception const& /*e*/) { HADESMEM_DETAIL_TRACE_A("WARNING! Invalid headers."); return; } HADESMEM_DETAIL_TRACE_A("Reading memory."); auto raw = hadesmem::ReadVectorEx<std::uint8_t>( process, module.GetHandle(), module.GetSize(), hadesmem::ReadFlags::kZeroFillReserved); hadesmem::Process const local_process(::GetCurrentProcessId()); hadesmem::PeFile const pe_file(local_process, raw.data(), hadesmem::PeFileType::Image, static_cast<DWORD>(raw.size())); hadesmem::NtHeaders nt_headers(local_process, pe_file); HADESMEM_DETAIL_TRACE_A("Copying headers."); std::vector<std::uint8_t> raw_new; std::copy(std::begin(raw), std::begin(raw) + nt_headers.GetSizeOfHeaders(), std::back_inserter(raw_new)); HADESMEM_DETAIL_TRACE_A("Copying section data."); hadesmem::SectionList const sections(local_process, pe_file); std::vector<std::pair<DWORD, DWORD>> raw_datas; for (auto const& section : sections) { auto const section_size = (std::max)(section.GetVirtualSize(), section.GetSizeOfRawData()); auto const ptr_raw_data_new = section.GetPointerToRawData() < raw_new.size() ? static_cast<DWORD>( RoundUp(raw_new.size(), nt_headers.GetFileAlignment())) : section.GetPointerToRawData(); raw_datas.emplace_back(ptr_raw_data_new, section_size); if (ptr_raw_data_new > raw_new.size()) { raw_new.resize(ptr_raw_data_new); } auto const raw_data = raw.data() + section.GetVirtualAddress(); auto const raw_data_end = raw_data + section_size; raw_new.reserve(raw_new.size() + section_size); std::copy(raw_data, raw_data_end, std::back_inserter(raw_new)); } HADESMEM_DETAIL_ASSERT(raw_new.size() < (std::numeric_limits<DWORD>::max)()); hadesmem::PeFile const pe_file_new(local_process, raw_new.data(), hadesmem::PeFileType::Data, static_cast<DWORD>(raw_new.size())); HADESMEM_DETAIL_TRACE_A("Fixing NT headers."); hadesmem::NtHeaders nt_headers_new(local_process, pe_file_new); nt_headers_new.SetImageBase( reinterpret_cast<ULONG_PTR>(module.GetHandle())); nt_headers_new.UpdateWrite(); HADESMEM_DETAIL_TRACE_A("Fixing section headers."); hadesmem::SectionList sections_new(local_process, pe_file_new); std::size_t n = 0; for (auto& section : sections_new) { section.SetPointerToRawData(raw_datas[n].first); section.SetSizeOfRawData(raw_datas[n].second); section.UpdateWrite(); ++n; } HADESMEM_DETAIL_TRACE_A("Fixing imports."); hadesmem::ImportDirList const import_dirs(local_process, pe_file); hadesmem::ImportDirList const import_dirs_new(local_process, pe_file_new); auto i = std::begin(import_dirs), j = std::begin(import_dirs_new); bool thunk_mismatch = false; for (; i != std::end(import_dirs) && j != std::end(import_dirs_new); ++i, ++j) { hadesmem::ImportThunkList const import_thunks( local_process, pe_file, i->GetOriginalFirstThunk()); hadesmem::ImportThunkList import_thunks_new( local_process, pe_file_new, j->GetFirstThunk()); auto a = std::begin(import_thunks); auto b = std::begin(import_thunks_new); for (; a != std::end(import_thunks) && b != std::end(import_thunks_new); ++a, ++b) { b->SetFunction(a->GetFunction()); b->UpdateWrite(); } thunk_mismatch = thunk_mismatch || ((a != std::end(import_thunks)) ^ (b != std::end(import_thunks_new))); } bool const dir_mismatch = (i != std::end(import_dirs)) ^ (j != std::end(import_dirs)); HADESMEM_DETAIL_TRACE_A("Writing file."); auto const proc_path = hadesmem::GetPath(process); auto const proc_name = proc_path.substr(proc_path.rfind(L'\\') + 1); auto const proc_pid_str = std::to_wstring(process.GetId()); std::wstring dump_path; std::uint32_t c = 0; do { dump_path = proc_name + L"_" + proc_pid_str + L"_" + module.GetName() + L"_" + std::to_wstring(c++) + L".dmp"; } while (hadesmem::detail::DoesFileExist(dump_path) && c < 10); auto const dump_file = hadesmem::detail::OpenFile<char>( dump_path, std::ios::out | std::ios::binary); if (!*dump_file) { HADESMEM_DETAIL_THROW_EXCEPTION(hadesmem::Error() << hadesmem::ErrorString( "Unable to open dump file.")); } if (!dump_file->write(reinterpret_cast<char const*>(raw_new.data()), raw_new.size())) { HADESMEM_DETAIL_THROW_EXCEPTION(hadesmem::Error() << hadesmem::ErrorString( "Unable to write to dump file.")); } if (dir_mismatch) { HADESMEM_DETAIL_THROW_EXCEPTION(hadesmem::Error() << hadesmem::ErrorString( "Mismatch in import dir processing.")); } if (thunk_mismatch) { HADESMEM_DETAIL_THROW_EXCEPTION( hadesmem::Error() << hadesmem::ErrorString( "Mismatch in import thunk processing.")); } } }
/** Old Test CaseID APPFWK-SSM-0012 New Test CaseID DEVSRVS-SSMA-SSM-0012 */ TVerdict CSsmValidSwpListTest::doTestStepL() { INFO_PRINTF1(_L("CSsmValidSwpListTest started....")); __UHEAP_MARK; TInt err = RProperty::Define(RProcess().SecureId(), key, RProperty::EInt); TEST(err == KErrNone || err == KErrAlreadyExists); INFO_PRINTF1(_L("Checking cmd list without a Publish System Swp command")); TInt exitReason(0); SetFunction(ESwpCmdWithoutPublishSwp); TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); TEST(err == KErrNone); INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); TEST(exitReason == ESwpTransitionEngineError16); INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError16); INFO_PRINTF1(_L("Checking cmd list with more than one Publish System Swp command")); exitReason=0; SetFunction(ESwpCmdTwoPublishSwp); TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); TEST(err == KErrNone); INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); TEST(exitReason == ESwpTransitionEngineError16); INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError16); INFO_PRINTF1(_L("Checking cmd list with a Publish System State")); exitReason=0; SetFunction(ESwpCmdPublishState); TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); TEST(err == KErrNone); INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); TEST(exitReason == ESwpTransitionEngineError16); INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError16); INFO_PRINTF1(_L("Checking cmd list with no Multiple Wait command and more than one deferred commands")); exitReason=0; SetFunction(ESwpCmdNoMultipleWait); TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); TEST(err == KErrNone); INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); TEST(exitReason == ESwpTransitionEngineError16); INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError16); INFO_PRINTF1(_L("Checking cmd list with too many Multiple Wait command and and no deferred commands - Validation should be OK - Panic comes from HandleCleReturnValue")); exitReason=0; SetFunction(ESwpCmdTooManyMultipleWaitErr1); TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); TEST(err == KErrNone); INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); const TInt threadExitReason = iThread.ExitReason(); TBuf<16> threadExitCategory = iThread.ExitCategory(); // This is the exit reason for the ssmswppolicyserver TEST(threadExitReason == KSsmTestAppRvError); // this is the exit reason for the engine. TEST(exitReason == ESwpTransitionEngineError20); iThread.Close(); INFO_PRINTF4(_L(" -- received panic '%d', category '%S', expected was '%d'."), threadExitReason, &threadExitCategory, KSsmTestAppRvError); INFO_PRINTF1(_L("Checking cmd list with too many Multiple Wait command and and no deferred commands - Validation should be OK - Panic originates in HandleCleReturnValue returning an error")); exitReason=0; SetFunction(ESwpCmdTooManyMultipleWaitErr2); TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); TEST(err == KErrNone); INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); TEST(exitReason == ESwpTransitionEngineError20); INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError20); INFO_PRINTF1(_L("Checking cmd list which leaves with an error when it is being prepared")); exitReason=0; SetFunction(ESwpCmdPrepareCmdListFailed); TRAP(err, exitReason = StartSwpInvalidListInThreadL(this)); TEST(err == KErrNone); INFO_PRINTF2(_L(" -- StartSwpInvalidListInThreadL method completed with '%d'."), err); TEST(exitReason == ESwpTransitionEngineError20); INFO_PRINTF3(_L(" -- received panic '%d', expected was '%d'."), exitReason, ESwpTransitionEngineError20); err = RProperty::Delete(RProcess().SecureId(), key); TEST(err == KErrNone); __UHEAP_MARKEND; // this test raises panics due to negative testing - close them to clear the screen. CloseAllPanicWindowsL(); INFO_PRINTF1(_L("....CSsmValidSwpListTest completed!!")); return TestStepResult(); }
void GetMessageFunction(uint8_t* Message) { if('f' == Message[6]) { if(0x03 == Message[7]) { if(0 == stringCMP(&Message[8], "AAA", 3)) // 计时工作开关 41H { // 计时加热 if('0' == Message[12]) { CancelKey(); Relay_Off_All(); FunctionReport(16); } else if('1' == Message[12]) { if(ENTER_START_WORK != DeviceStatus.enterMode) { SelectedFunction(); // 获取默认的时间、温度等参数。 showFunction(DeviceStatus.workState, ON); // 让功能指示灯常亮 showTime(DeviceStatus.workTime, ON, ON); // 显示工作时间 DeviceStatus.beepSW = ON; DeviceStatus.startWorkBeep = ON; // 工作提示音 DeviceStatus.beep = 0; DeviceStatus.knob = KNOB_DISABLE; // 禁用旋钮 DeviceStatus.setMode = SET_TIME; // 设置时间 DeviceStatus.preheat = OFF; // 让App控制时无预热功能。 showPreheat(ON); // 让预热指示灯显示, 如果带预热则亮,否则不会亮 if(DeviceStatus.preheat == ON) { DeviceStatus.startWork = OFF; // 清除工作指示标志 DeviceStatus.enterMode = ENTER_PREHEAT; // 预热工作状态 } else { DeviceStatus.startWork = ON; // 设置工作指示标志 DeviceStatus.enterMode = ENTER_START_WORK; // 倒计时加热 } if(DeviceStatus.workState == 8) RELAY_3_H; // 烤鸡功能 开转插 } else { KeyBeep(); } } } else if(0 == stringCMP(&Message[8], "AAB", 3)) // 自调 42H { SetFunction(16); } else if(0 == stringCMP(&Message[8], "AAC", 3)) // 预热自调 43H { SetFunction(15); } else if(0 == stringCMP(&Message[8], "AAD", 3)) // 发酵 44H { SetFunction(14); } else if(0 == stringCMP(&Message[8], "AAE", 3)) // 饼干 45H { SetFunction(13); } else if(0 == stringCMP(&Message[8], "AAF", 3)) // 烤饼 46H { SetFunction(12); } else if(0 == stringCMP(&Message[8], "AAG", 3)) // 蛋糕 47H { SetFunction(11); } else if(0 == stringCMP(&Message[8], "AAH", 3)) // 蛋挞 48H { SetFunction(10); } else if(0 == stringCMP(&Message[8], "AAI", 3)) // 面包 49H { SetFunction(9); } else if(0 == stringCMP(&Message[8], "AAJ", 3)) // 烤鸡 4AH { SetFunction(8); } else if(0 == stringCMP(&Message[8], "AAK", 3)) // 鸡翅 4BH { SetFunction(7); } else if(0 == stringCMP(&Message[8], "AAL", 3)) // 排骨 4CH { SetFunction(6); } else if(0 == stringCMP(&Message[8], "AAM", 3)) // 烤鱼 4DH { SetFunction(5); } else if(0 == stringCMP(&Message[8], "AAN", 3)) // 红薯 4EH { SetFunction(4); } else if(0 == stringCMP(&Message[8], "AAO", 3)) // 玉米 4FH { SetFunction(3); } else if(0 == stringCMP(&Message[8], "AAP", 3)) // 预热 50H { // DeviceStatus.workState = 2; // DeviceStatus.enterMode = ENTER_CHOICE_FUNCTION; showPreheat(ON); KeyBeep(); } else if(0 == stringCMP(&Message[8], "AAQ", 3)) // 炉灯 51H { //DeviceStatus.workState = 1; //DeviceStatus.enterMode = ENTER_CHOICE_FUNCTION; // 炉灯控制 if('0' == Message[12]) { RELAY_1_L; DeviceStatus.light = 0; } else if('1' == Message[12]) { RELAY_1_H; DeviceStatus.light = 1; } showLight(); KeyBeep(); } else if(0 == stringCMP(&Message[8], "AAR", 3)) // 52H { // DIY KeyBeep(); } else { KeyBeep(); } } } }
SentenciaProcedimiento::SentenciaProcedimiento(FunctionCall* function_call) { SetSiguiente(0); SetFunction(function_call); }