DWORD64 getLdrGetProcedureAddress() { DWORD64 modBase = getNTDLL64(); if (0 == modBase) return 0; IMAGE_DOS_HEADER idh; getMem64(&idh, modBase, sizeof(idh)); IMAGE_NT_HEADERS64 inh; getMem64(&inh, modBase + idh.e_lfanew, sizeof(IMAGE_NT_HEADERS64)); IMAGE_DATA_DIRECTORY& idd = inh.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT]; if (0 == idd.VirtualAddress) return 0; IMAGE_EXPORT_DIRECTORY ied; getMem64(&ied, modBase + idd.VirtualAddress, sizeof(ied)); DWORD* rvaTable = (DWORD*)malloc(sizeof(DWORD)*ied.NumberOfFunctions); if (nullptr == rvaTable) return 0; WATCH(rvaTable); getMem64(rvaTable, modBase + ied.AddressOfFunctions, sizeof(DWORD)*ied.NumberOfFunctions); WORD* ordTable = (WORD*)malloc(sizeof(WORD)*ied.NumberOfFunctions); if (nullptr == ordTable) return 0; WATCH(ordTable); getMem64(ordTable, modBase + ied.AddressOfNameOrdinals, sizeof(WORD)*ied.NumberOfFunctions); DWORD* nameTable = (DWORD*)malloc(sizeof(DWORD)*ied.NumberOfNames); if (nullptr == nameTable) return 0; WATCH(nameTable); getMem64(nameTable, modBase + ied.AddressOfNames, sizeof(DWORD)*ied.NumberOfNames); // lazy search, there is no need to use binsearch for just one function for (DWORD i = 0; i < ied.NumberOfFunctions; i++) { if (!cmpMem64("LdrGetProcedureAddress", modBase + nameTable[i], sizeof("LdrGetProcedureAddress"))) continue; else return modBase + rvaTable[ordTable[i]]; } return 0; }
void RNAProfileAlignment::getStructureAlignment(double t,string &s, deque<double> &pairprob) const { WATCH(DBG_GET_PROFILE_STRUCTURE,"Profile_RNA_Alignment_Forest::getStructureAlignment",size()); s=""; getStructureAlignmentFromCSF(s,pairprob,t,0,getMaxLength(0)); }
extern "C" DWORD64 __cdecl GetModuleHandle64(wchar_t* lpModuleName) { if (!g_isWow64) return 0; TEB64 teb64; getMem64(&teb64, getTEB64(), sizeof(TEB64)); PEB64 peb64; getMem64(&peb64, teb64.ProcessEnvironmentBlock, sizeof(PEB64)); PEB_LDR_DATA64 ldr; getMem64(&ldr, peb64.Ldr, sizeof(PEB_LDR_DATA64)); DWORD64 LastEntry = peb64.Ldr + offsetof(PEB_LDR_DATA64, InLoadOrderModuleList); LDR_DATA_TABLE_ENTRY64 head; head.InLoadOrderLinks.Flink = ldr.InLoadOrderModuleList.Flink; do { getMem64(&head, head.InLoadOrderLinks.Flink, sizeof(LDR_DATA_TABLE_ENTRY64)); wchar_t* tempBuf = (wchar_t*)malloc(head.BaseDllName.MaximumLength); if (nullptr == tempBuf) return 0; WATCH(tempBuf); getMem64(tempBuf, head.BaseDllName.Buffer, head.BaseDllName.MaximumLength); if (0 == _wcsicmp(lpModuleName, tempBuf)) return head.DllBase; } while (head.InLoadOrderLinks.Flink != LastEntry); return 0; }
void OMNeTBattery::initialize(int stage) { if(stage == 0) { notificationBoard = NotificationBoardAccess().get(); checkCompatibilityToRadioState(); voltageInVolts = par("voltage"); double capacityInMilliAmpereHours = par("capacity"); capacityInMilliWattSeconds = capacityInMilliAmpereHours * 60 * 60 * voltageInVolts; residualCapacityInMilliWattSeconds = capacityInMilliWattSeconds; energyVectorDelta = par("energyVectorDelta"); lastStoredResidualEnergyInMilliWattSeconds = residualCapacityInMilliWattSeconds; updateInterval = par("updateInterval"); if (updateInterval > 0) { lastUpdateTime = simTime(); publishMessage = new cMessage("Update energy"); publishMessage->setSchedulingPriority(2000); scheduleAt(updateInterval, publishMessage); } else { EV << "Warning: Battery is disabled (updateInterval is <= 0)" << std::endl; } residualEnergyOutVector.setName("energyLevel"); residualEnergyOutVector.record(residualCapacityInMilliWattSeconds); WATCH(residualCapacityInMilliWattSeconds); updateBatteryIcon(); } }
/* Do the watch. Return value is the number of descriptors that are ready, ** or 0 if the timeout expired, or -1 on errors. A timeout of INFTIM means ** wait indefinitely. */ int fdwatch( long timeout_msecs ) { ++nwatches; nreturned = WATCH( timeout_msecs ); next_ridx = 0; return nreturned; }
void Txc14::initialize() { // Initialize variables. sentPkgs = 0; receivedPkgs = 0; // Make them observable. WATCH(sentPkgs); WATCH(receivedPkgs); if (getIndex() == 0) { // Boot the process scheduling the initial message as self message. TicTocMsg14 *msg = generateMessage(); scheduleAt(0.0, msg); } }
void EARA::initialize(int stage) { AbstractOMNeTARAClient::initialize(stage); if(stage == 4) { OMNeTEARAConfiguration config = OMNeTEARAConfiguration(this); setLogger(config.getLogger()); AbstractEARAClient::initializeEARA(config); initializeNetworkInterfacesOf(this, config); notificationBoard->subscribe(this, NF_BATTERY_CHANGED); WATCH(nrOfDetectedLoops); WATCH(maximumBatteryCapacityInNetwork); LOOP_DETECTION_SIGNAL = registerSignal("routingLoopDetected"); DROP_PACKET_WITH_ZERO_TTL = registerSignal("dropZeroTTLPacket"); ROUTE_FAILURE_NO_HOP = registerSignal("routeFailureNoHopAvailable"); NEW_ROUTE_DISCOVERY = registerSignal("newRouteDiscovery"); ROUTE_FAILURE_NEXT_HOP_IS_SENDER = registerSignal("routeFailureNextHopIsSender"); new EARARoutingTableWatcher(routingTable); } }
double RNAProfileAlignment::bestPairs(size_type node) const { size_type i=node; double d1,d2; WATCH(DBG_GET_PROFILE_STRUCTURE,"RNAProfileForest::getStructureAlignment",node); if(isBase(node)) return 0; else { // node pairs not d1=bestPairs(node+1) + bestPairs(getRightmostBrotherIndex(node+1)); // node pairs d2=label(node).p[ALPHA_PRO_BASEPAIR]; // left path - righthand best pairs i=node+1; while(i < size() && isPair(i)) { d2+=bestPairs(getRightmostBrotherIndex(i+1)); i=i+1; } // right path - lefthand best pairs i=getRightmostBrotherIndex(node+1); while(isPair(i) && i < size()) { d2+=bestPairs(i+1); i=getRightmostBrotherIndex(i+1); } return max(d1,d2); } }
case COMMAND_COLOR_SUB: CHECK_LEN(cmd_color); for_color (c) ct[c] = Command_color[led][c] - ct[c]; command_color_set(ct, led); break; case COMMAND_SEQUENCE: command_sequence(cmdbuf.cmd_seq.seq, (z - offsetof(struct command_sequence, seq))/sizeof(*cmdbuf.cmd_seq.seq), led); break; } #undef CHECK_LEN } static struct watch Command_watch = { .events = WATCH(IN), .fun = &command_run }; int command_init() { struct sockaddr_un sa = { AF_UNIX, COMMAND_SOCKET }; if ((Command_sock = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) return Command_sock; if (fcntl(Command_sock, F_SETFL, O_NONBLOCK) < 0 || fcntl(Command_sock, F_SETFD, FD_CLOEXEC) < 0) return -1; unlink(sa.sun_path); mode_t omask = umask(0177); int r = bind(Command_sock, (struct sockaddr *)&sa, SUN_LEN(&sa)); umask(omask); if (r < 0)