bool CNetAddr::IsRFC3927() const { return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); }
bool CNetAddr::IsRFC6598() const { return IsIPv4() && GetByte(3) == 100 && GetByte(2) >= 64 && GetByte(2) <= 127; }
bool Archive::GetComment(Array<wchar> *CmtData) { if (!MainComment) return false; SaveFilePos SavePos(*this); #ifndef SFX_MODULE ushort CmtLength; if (Format==RARFMT14) { Seek(SFXSize+SIZEOF_MAINHEAD14,SEEK_SET); CmtLength=GetByte(); CmtLength+=(GetByte()<<8); } else #endif { if (MainHead.CommentInHeader) { // Old style (RAR 2.9) archive comment embedded into the main // archive header. Seek(SFXSize+SIZEOF_MARKHEAD3+SIZEOF_MAINHEAD3,SEEK_SET); ReadHeader(); } else { // Current (RAR 3.0+) version of archive comment. Seek(GetStartPos(),SEEK_SET); return SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData); } #ifndef SFX_MODULE // Old style (RAR 2.9) comment header embedded into the main // archive header. if (BrokenHeader) { uiMsg(UIERROR_CMTBROKEN,FileName); return false; } CmtLength=CommHead.HeadSize-SIZEOF_COMMHEAD; #endif } #ifndef SFX_MODULE if (Format==RARFMT14 && MainHead.PackComment || Format!=RARFMT14 && CommHead.Method!=0x30) { if (Format!=RARFMT14 && (CommHead.UnpVer < 15 || CommHead.UnpVer > VER_UNPACK || CommHead.Method > 0x35)) return(false); ComprDataIO DataIO; DataIO.SetTestMode(true); uint UnpCmtLength; if (Format==RARFMT14) { #ifdef RAR_NOCRYPT return(false); #else UnpCmtLength=GetByte(); UnpCmtLength+=(GetByte()<<8); CmtLength-=2; DataIO.SetCmt13Encryption(); CommHead.UnpVer=15; #endif } else UnpCmtLength=CommHead.UnpSize; DataIO.SetFiles(this,NULL); DataIO.EnableShowProgress(false); DataIO.SetPackedSizeToRead(CmtLength); DataIO.UnpHash.Init(HASH_CRC32,1); Unpack CmtUnpack(&DataIO); CmtUnpack.Init(0x10000,false); CmtUnpack.SetDestSize(UnpCmtLength); CmtUnpack.DoUnpack(CommHead.UnpVer,false); if (Format!=RARFMT14 && (DataIO.UnpHash.GetCRC32()&0xffff)!=CommHead.CommCRC) { uiMsg(UIERROR_CMTBROKEN,FileName); return false; } else { byte *UnpData; size_t UnpDataSize; DataIO.GetUnpackedData(&UnpData,&UnpDataSize); #ifdef _WIN_ALL OemToCharBuffA((char *)UnpData,(char *)UnpData,(DWORD)UnpDataSize); #endif CmtData->Alloc(UnpDataSize+1); memset(CmtData->Addr(0),0,CmtData->Size()*sizeof(wchar)); CharToWide((char *)UnpData,CmtData->Addr(0),UnpDataSize); CmtData->Alloc(wcslen(CmtData->Addr(0))); } } else { Array<byte> CmtRaw(CmtLength); Read(&CmtRaw[0],CmtLength); if (Format!=RARFMT14 && CommHead.CommCRC!=(~CRC32(0xffffffff,&CmtRaw[0],CmtLength)&0xffff)) { uiMsg(UIERROR_CMTBROKEN,FileName); return false; } CmtData->Alloc(CmtLength+1); CmtRaw.Push(0); #ifdef _WIN_ALL OemToCharA((char *)&CmtRaw[0],(char *)&CmtRaw[0]); #endif CharToWide((char *)&CmtRaw[0],CmtData->Addr(0),CmtLength); CmtData->Alloc(wcslen(CmtData->Addr(0))); } #endif return CmtData->Size() > 0; }
bool CNetAddr::IsRFC2544() const { return IsIPv4() && GetByte(3) == 198 && (GetByte(2) == 18 || GetByte(2) == 19); }
bool CNetAddr::IsRFC4193() const { return ((GetByte(15) & 0xFE) == 0xFC); }
std::string CNetAddr::ToStringIP() const { if (IsTor()) return EncodeBase32(&ip[6], 10) + ".onion"; if (IsInternal()) return EncodeBase32(ip + sizeof(g_internal_prefix), sizeof(ip) - sizeof(g_internal_prefix)) + ".internal"; CService serv(*this, 0); struct sockaddr_storage sockaddr; socklen_t socklen = sizeof(sockaddr); if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) { char name[1025] = ""; if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), nullptr, 0, NI_NUMERICHOST)) return std::string(name); } if (IsIPv4()) return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0)); else return strprintf("%x:%x:%x:%x:%x:%x:%x:%x", GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12), GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8), GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4), GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0)); }
// This function is only called during the first pass, so there's no need to // check whether to skip the definition or not. // Return with GotByte = '}' void Macro_parse_definition(void) // Now GotByte = illegal char after "!macro" { char *formal_parameters; struct rwnode *macro_node; struct macro *new_macro; zone_t macro_zone = get_zone_and_title(); // now GotByte = first non-space after title DYNABUF_CLEAR(GlobalDynaBuf); // prepare to hold formal parameters // GlobalDynaBuf = "" (will hold formal parameter list) // user_macro_name = [LOCAL_PREFIX] MacroTitle NUL // internal_name = MacroTitle ARG_SEPARATOR (grows to signature) // Accept n>=0 comma-separated formal parameters before CHAR_SOB ('{'). // Valid argument formats are: // .LOCAL_LABEL_BY_VALUE // ~.LOCAL_LABEL_BY_REFERENCE // GLOBAL_LABEL_BY_VALUE global args are very uncommon, // ~GLOBAL_LABEL_BY_REFERENCE but not forbidden // now GotByte = non-space if (GotByte != CHAR_SOB) { // any at all? do { // handle call-by-reference character ('~') if (GotByte != REFERENCE_CHAR) { DynaBuf_append(internal_name, ARGTYPE_NUM_VAL); } else { DynaBuf_append(internal_name, ARGTYPE_NUM_REF); DynaBuf_append(GlobalDynaBuf, REFERENCE_CHAR); GetByte(); } // handle prefix for local symbols (LOCAL_PREFIX, normally '.') if (GotByte == LOCAL_PREFIX) { DynaBuf_append(GlobalDynaBuf, LOCAL_PREFIX); GetByte(); } // handle symbol name Input_append_keyword_to_global_dynabuf(); } while (pipe_comma()); // ensure CHAR_SOB ('{') if (GotByte != CHAR_SOB) Throw_serious_error(exception_no_left_brace); } DynaBuf_append(GlobalDynaBuf, CHAR_EOS); // terminate param list // now GlobalDynaBuf = comma-separated parameter list without spaces, // but terminated with CHAR_EOS. formal_parameters = DynaBuf_get_copy(GlobalDynaBuf); // now GlobalDynaBuf = unused // Reading the macro body would change the line number. To have correct // error messages, we're checking for "macro twice" *now*. // Search for macro. Create if not found. // But if found, complain (macro twice). if (search_for_macro(¯o_node, macro_zone, TRUE) == FALSE) report_redefinition(macro_node); // quits with serious error // Create new macro struct and set it up. Finally we'll read the body. new_macro = safe_malloc(sizeof(*new_macro)); new_macro->def_line_number = Input_now->line_number; new_macro->def_filename = get_string_copy(Input_now->original_filename); new_macro->original_name = get_string_copy(user_macro_name->buffer); new_macro->parameter_list = formal_parameters; new_macro->body = Input_skip_or_store_block(TRUE); // changes LineNumber macro_node->body = new_macro; // link macro struct to tree node // and that about sums it up }
bool CNetAddr::IsRFC3964() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x02); }
// //AbilityActiveMessage // int AbilityActiveMessage::handleMessage(SimulatorThread *sim, CharacterServerData *pld, SimulatorQuery *query, CreatureInstance *creatureInstance) { creatureInstance->RemoveNoncombatantStatus("abilityActivate"); // Flags appears to be intended for party casting, but isn't used outside the /do command. // We don't use it in the server, but we still need to read it from the message. short aID = GetShort(&sim->readPtr[sim->ReadPos], sim->ReadPos); //Ability ID // Unused? GetByte(&sim->readPtr[sim->ReadPos], sim->ReadPos); //unsigned char flags = GetByte(&sim->readPtr[sim->ReadPos], sim->ReadPos); //flags unsigned char ground = GetByte(&sim->readPtr[sim->ReadPos], sim->ReadPos); //ground float x, y, z; //LogMessageL(MSG_SHOW, "abilityActivate: %d, flags: %d", aID, flags); if (ground != 0) { x = GetFloat(&sim->RecBuf[sim->ReadPos], sim->ReadPos); y = GetFloat(&sim->RecBuf[sim->ReadPos], sim->ReadPos); z = GetFloat(&sim->RecBuf[sim->ReadPos], sim->ReadPos); creatureInstance->ab[0].SetPosition(x, y, z); //LogMessageL(MSG_DIAGV, "ground: %d, x: %g, y: %g, z: %g", ground, x, y, z); } if (creatureInstance->serverFlags & ServerFlags::IsTransformed) { const Ability2::AbilityEntry2 *abData = g_AbilityManager.GetAbilityPtrByID(aID); if (abData != NULL) { /* TODO: old junk, update or remove this if(abData->isMagic == true) { sim->SendInfoMessage("You may not use elemental abilities while transformed.", INFOMSG_INFO); return; } if(abData->isRanged == true) { sim->SendInfoMessage("You may not use ranged abilities while transformed.", INFOMSG_INFO); return; } */ } } if (aID == g_JumpConstant) { if (sim->IsGMInvisible() == false) sim->AddMessage(pld->CreatureID, 0, BCM_ActorJump); } else { bool allow = false; if (sim->CheckPermissionSimple(Perm_Account, Permission_Debug | Permission_Admin | Permission_Developer) == true) allow = true; else if (pld->charPtr->abilityList.GetAbilityIndex(aID) >= 0) allow = true; else { if (g_AbilityManager.IsGlobalIntrinsicAbility(aID) == true) allow = true; } if (allow == true) { creatureInstance->RequestAbilityActivation(aID); if (sim->TargetRarityAboveNormal() == false) { if (pld->NotifyCast(creatureInstance->CurrentX, creatureInstance->CurrentZ, aID) == true) { CreatureInstance *target = creatureInstance->CurrentTarget.targ; const char *targetName = "no target"; int targetID = 0; if (target != NULL) { targetID = target->CreatureID; targetName = target->css.display_name; } g_Logs.cheat->info( "[BOT] Attacks in area by %s @ %d:%d,%d(%d) (%d:%s) [%s:%d]", creatureInstance->css.display_name, pld->CurrentZoneID, creatureInstance->CurrentX, creatureInstance->CurrentZ, creatureInstance->Rotation, aID, g_AbilityManager.GetAbilityNameByID(aID), targetName, targetID); } } } } return 0; }
DWORD CpuExecute () { WORD addr; BOOL flagc; BOOL flagn; BOOL flagv; BOOL flagz; WORD temp; WORD val; DWORD cycles = 0; AF_TO_EF //get flags from regs.ps /**************************************************************************** * * OPCODE TABLE * ***/ // do { switch (GetByte(regs.pc++)) { case 0x00: BRK CYC(7) break; case 0x01: INDX ORA CYC(6) break; case 0x02: INVALID2 CYC(2) break; case 0x03: INVALID1 CYC(1) break; case 0x04: CMOS ZPG TSB CYC(5) break; case 0x05: ZPG ORA CYC(3) break; case 0x06: ZPG ASL CYC(5) break; case 0x07: CMOS ZPG RMB0 CYC(5) break; case 0x08: PHP CYC(3) break; case 0x09: IMM ORA CYC(2) break; case 0x0A: ASLA CYC(2) break; case 0x0B: INVALID1 CYC(1) break; case 0x0C: CMOS ABS TSB CYC(6) break; case 0x0D: ABS ORA CYC(4) break; case 0x0E: ABS ASL CYC(6) break; case 0x0F: CMOS ZPG BBR0 CYC(5) break; case 0x10: REL BPL CYC(2) break; case 0x11: INDY ORA CYC(5) break; case 0x12: CMOS IZPG ORA CYC(5) break; case 0x13: INVALID1 CYC(1) break; case 0x14: CMOS ZPG TRB CYC(5) break; case 0x15: ZPGX ORA CYC(4) break; case 0x16: ZPGX ASL CYC(6) break; case 0x17: CMOS ZPG RMB1 CYC(5) break; case 0x18: CLC CYC(2) break; case 0x19: ABSY ORA CYC(4) break; case 0x1A: CMOS INA CYC(2) break; case 0x1B: INVALID1 CYC(1) break; case 0x1C: CMOS ABS TRB CYC(6) break; case 0x1D: ABSX ORA CYC(4) break; case 0x1E: ABSX ASL CYC(6) break; case 0x1F: CMOS ZPG BBR1 CYC(5) break; case 0x20: ABS JSR CYC(6) break; case 0x21: INDX AND CYC(6) break; case 0x22: INVALID2 CYC(2) break; case 0x23: INVALID1 CYC(1) break; case 0x24: ZPG BIT CYC(3) break; case 0x25: ZPG AND CYC(3) break; case 0x26: ZPG ROL CYC(5) break; case 0x27: CMOS ZPG RMB2 CYC(5) break; case 0x28: PLP CYC(4) break; case 0x29: IMM AND CYC(2) break; case 0x2A: ROLA CYC(2) break; case 0x2B: INVALID1 CYC(1) break; case 0x2C: ABS BIT CYC(4) break; case 0x2D: ABS AND CYC(4) break; case 0x2E: ABS ROL CYC(6) break; case 0x2F: CMOS ZPG BBR2 CYC(5) break; case 0x30: REL BMI CYC(2) break; case 0x31: INDY AND CYC(5) break; case 0x32: CMOS IZPG AND CYC(5) break; case 0x33: INVALID1 CYC(1) break; case 0x34: CMOS ZPGX BIT CYC(4) break; case 0x35: ZPGX AND CYC(4) break; case 0x36: ZPGX ROL CYC(6) break; case 0x37: CMOS ZPG RMB3 CYC(5) break; case 0x38: SEC CYC(2) break; case 0x39: ABSY AND CYC(4) break; case 0x3A: CMOS DEA CYC(2) break; case 0x3B: INVALID1 CYC(1) break; case 0x3C: CMOS ABSX BIT CYC(4) break; case 0x3D: ABSX AND CYC(4) break; case 0x3E: ABSX ROL CYC(6) break; case 0x3F: CMOS ZPG BBR3 CYC(5) break; case 0x40: RTI CYC(6) break; case 0x41: INDX EOR CYC(6) break; case 0x42: INVALID2 CYC(2) break; case 0x43: INVALID1 CYC(1) break; case 0x44: INVALID2 CYC(3) break; case 0x45: ZPG EOR CYC(3) break; case 0x46: ZPG LSR CYC(5) break; case 0x47: CMOS ZPG RMB4 CYC(5) break; case 0x48: PHA CYC(3) break; case 0x49: IMM EOR CYC(2) break; case 0x4A: LSRA CYC(2) break; case 0x4B: INVALID1 CYC(1) break; case 0x4C: ABS JMP CYC(3) break; case 0x4D: ABS EOR CYC(4) break; case 0x4E: ABS LSR CYC(6) break; case 0x4F: CMOS ZPG BBR4 CYC(5) break; case 0x50: REL BVC CYC(2) break; case 0x51: INDY EOR CYC(5) break; case 0x52: CMOS IZPG EOR CYC(5) break; case 0x53: INVALID1 CYC(1) break; case 0x54: INVALID2 CYC(4) break; case 0x55: ZPGX EOR CYC(4) break; case 0x56: ZPGX LSR CYC(6) break; case 0x57: CMOS ZPG RMB5 CYC(5) break; case 0x58: CLI CYC(2) break; case 0x59: ABSY EOR CYC(4) break; case 0x5A: CMOS PHY CYC(3) break; case 0x5B: INVALID1 CYC(1) break; case 0x5C: INVALID3 CYC(8) break; case 0x5D: ABSX EOR CYC(4) break; case 0x5E: ABSX LSR CYC(6) break; case 0x5F: CMOS ZPG BBR5 CYC(5) break; case 0x60: RTS CYC(6) break; case 0x61: INDX ADC CYC(6) break; case 0x62: INVALID2 CYC(2) break; case 0x63: INVALID1 CYC(1) break; case 0x64: CMOS ZPG STZ CYC(3) break; case 0x65: ZPG ADC CYC(3) break; case 0x66: ZPG ROR CYC(5) break; case 0x67: CMOS ZPG RMB6 CYC(5) break; case 0x68: PLA CYC(4) break; case 0x69: IMM ADC CYC(2) break; case 0x6A: RORA CYC(2) break; case 0x6B: INVALID1 CYC(1) break; case 0x6C: IABS JMP CYC(6) break; case 0x6D: ABS ADC CYC(4) break; case 0x6E: ABS ROR CYC(6) break; case 0x6F: CMOS ZPG BBR6 CYC(5) break; case 0x70: REL BVS CYC(2) break; case 0x71: INDY ADC CYC(5) break; case 0x72: CMOS IZPG ADC CYC(5) break; case 0x73: INVALID1 CYC(1) break; case 0x74: CMOS ZPGX STZ CYC(4) break; case 0x75: ZPGX ADC CYC(4) break; case 0x76: ZPGX ROR CYC(6) break; case 0x77: CMOS ZPG RMB7 CYC(5) break; case 0x78: SEI CYC(2) break; case 0x79: ABSY ADC CYC(4) break; case 0x7A: CMOS PLY CYC(4) break; case 0x7B: INVALID1 CYC(1) break; case 0x7C: CMOS ABSIINDX JMP CYC(6) break; case 0x7D: ABSX ADC CYC(4) break; case 0x7E: ABSX ROR CYC(6) break; case 0x7F: CMOS ZPG BBR7 CYC(5) break; case 0x80: CMOS REL BRA CYC(3) break; case 0x81: INDX STA CYC(6) break; case 0x82: INVALID2 CYC(2) break; case 0x83: INVALID1 CYC(1) break; case 0x84: ZPG STY CYC(3) break; case 0x85: ZPG STA CYC(3) break; case 0x86: ZPG STX CYC(3) break; case 0x87: CMOS ZPG SMB0 CYC(5) break; case 0x88: DEY CYC(2) break; case 0x89: CMOS IMM BITI CYC(2) break; case 0x8A: TXA CYC(2) break; case 0x8B: INVALID1 CYC(1) break; case 0x8C: ABS STY CYC(4) break; case 0x8D: ABS STA CYC(4) break; case 0x8E: ABS STX CYC(4) break; case 0x8F: CMOS ZPG BBS0 CYC(5) break; case 0x90: REL BCC CYC(2) break; case 0x91: INDY STA CYC(6) break; case 0x92: CMOS IZPG STA CYC(5) break; case 0x93: INVALID1 CYC(1) break; case 0x94: ZPGX STY CYC(4) break; case 0x95: ZPGX STA CYC(4) break; case 0x96: ZPGY STX CYC(4) break; case 0x97: CMOS ZPG SMB1 CYC(5) break; case 0x98: TYA CYC(2) break; case 0x99: ABSY STA CYC(5) break; case 0x9A: TXS CYC(2) break; case 0x9B: INVALID1 CYC(1) break; case 0x9C: CMOS ABS STZ CYC(4) break; case 0x9D: ABSX STA CYC(5) break; case 0x9E: CMOS ABSX STZ CYC(5) break; case 0x9F: CMOS ZPG BBS1 CYC(5) break; case 0xA0: IMM LDY CYC(2) break; case 0xA1: INDX LDA CYC(6) break; case 0xA2: IMM LDX CYC(2) break; case 0xA3: INVALID1 CYC(1) break; case 0xA4: ZPG LDY CYC(3) break; case 0xA5: ZPG LDA CYC(3) break; case 0xA6: ZPG LDX CYC(3) break; case 0xA7: CMOS ZPG SMB2 CYC(5) break; case 0xA8: TAY CYC(2) break; case 0xA9: IMM LDA CYC(2) break; case 0xAA: TAX CYC(2) break; case 0xAB: INVALID1 CYC(1) break; case 0xAC: ABS LDY CYC(4) break; case 0xAD: ABS LDA CYC(4) break; case 0xAE: ABS LDX CYC(4) break; case 0xAF: CMOS ZPG BBS2 CYC(5) break; case 0xB0: REL BCS CYC(2) break; case 0xB1: INDY LDA CYC(5) break; case 0xB2: CMOS IZPG LDA CYC(5) break; case 0xB3: INVALID1 CYC(1) break; case 0xB4: ZPGX LDY CYC(4) break; case 0xB5: ZPGX LDA CYC(4) break; case 0xB6: ZPGY LDX CYC(4) break; case 0xB7: CMOS ZPG SMB3 CYC(5) break; case 0xB8: CLV CYC(2) break; case 0xB9: ABSY LDA CYC(4) break; case 0xBA: TSX CYC(2) break; case 0xBB: INVALID1 CYC(1) break; case 0xBC: ABSX LDY CYC(4) break; case 0xBD: ABSX LDA CYC(4) break; case 0xBE: ABSY LDX CYC(4) break; case 0xBF: CMOS ZPG BBS3 CYC(5) break; case 0xC0: IMM CPY CYC(2) break; case 0xC1: INDX CMP CYC(6) break; case 0xC2: INVALID2 CYC(2) break; case 0xC3: INVALID1 CYC(1) break; case 0xC4: ZPG CPY CYC(3) break; case 0xC5: ZPG CMP CYC(3) break; case 0xC6: ZPG DEC CYC(5) break; case 0xC7: CMOS ZPG SMB4 CYC(5) break; case 0xC8: INY CYC(2) break; case 0xC9: IMM CMP CYC(2) break; case 0xCA: DEX CYC(2) break; case 0xCB: CMOS WAI CYC(3) break; case 0xCC: ABS CPY CYC(4) break; case 0xCD: ABS CMP CYC(4) break; case 0xCE: ABS DEC CYC(6) break; case 0xCF: CMOS ZPG BBS4 CYC(5) break; case 0xD0: REL BNE CYC(2) break; case 0xD1: INDY CMP CYC(5) break; case 0xD2: CMOS IZPG CMP CYC(5) break; case 0xD3: INVALID1 CYC(1) break; case 0xD4: INVALID2 CYC(4) break; case 0xD5: ZPGX CMP CYC(4) break; case 0xD6: ZPGX DEC CYC(6) break; case 0xD7: CMOS ZPG SMB5 CYC(5) break; case 0xD8: CLD CYC(2) break; case 0xD9: ABSY CMP CYC(4) break; case 0xDA: CMOS PHX CYC(3) break; case 0xDB: CMOS STP CYC(3) break; case 0xDC: INVALID3 CYC(4) break; case 0xDD: ABSX CMP CYC(4) break; case 0xDE: ABSX DEC CYC(6) break; case 0xDF: CMOS ZPG BBS5 CYC(5) break; case 0xE0: IMM CPX CYC(2) break; case 0xE1: INDX SBC CYC(6) break; case 0xE2: INVALID2 CYC(2) break; case 0xE3: INVALID1 CYC(1) break; case 0xE4: ZPG CPX CYC(3) break; case 0xE5: ZPG SBC CYC(3) break; case 0xE6: ZPG INC CYC(5) break; case 0xE7: CMOS ZPG SMB6 CYC(5) break; case 0xE8: INX CYC(2) break; case 0xE9: IMM SBC CYC(2) break; case 0xEA: NOP CYC(2) break; case 0xEB: INVALID1 CYC(1) break; case 0xEC: ABS CPX CYC(4) break; case 0xED: ABS SBC CYC(4) break; case 0xEE: ABS INC CYC(6) break; case 0xEF: CMOS ZPG BBS6 CYC(5) break; case 0xF0: REL BEQ CYC(2) break; case 0xF1: INDY SBC CYC(5) break; case 0xF2: CMOS IZPG SBC CYC(5) break; case 0xF3: INVALID1 CYC(1) break; case 0xF4: INVALID2 CYC(4) break; case 0xF5: ZPGX SBC CYC(4) break; case 0xF6: ZPGX INC CYC(6) break; case 0xF7: CMOS ZPG SMB7 CYC(5) break; case 0xF8: SED CYC(2) break; case 0xF9: ABSY SBC CYC(4) break; case 0xFA: CMOS PLX CYC(4) break; case 0xFB: INVALID1 CYC(1) break; case 0xFC: INVALID3 CYC(4) break; case 0xFD: ABSX SBC CYC(4) break; case 0xFE: ABSX INC CYC(6) break; case 0xFF: CMOS ZPG BBS7 CYC(5) break; } if (!g_stp ) { // If STP, then no IRQ or NMI allowed if (g_nmi) NMI; // FIXME: NO MORE REVERSE if (g_irq) IRQ; // FIXME: NO MORE REVERSE } // } while (cycles < totalcycles); EF_TO_AF // put flags back in regs.ps return cycles; }
// //UpdateVelocityMessage // int UpdateVelocityMessage::handleMessage(SimulatorThread *sim, CharacterServerData *pld, SimulatorQuery *query, CreatureInstance *creatureInstance) { if (g_ServerTime < pld->MovementBlockTime) { creatureInstance->Speed = 0; return 0; } //When entering a new zone from a portal, a velocity update always seems to be sent. //This is designed to block that message from interrupting the noncombat status. if (pld->IgnoreNextMovement == true) pld->IgnoreNextMovement = false; else creatureInstance->RemoveNoncombatantStatus("updateVelocity"); int x = GetShort(&sim->readPtr[sim->ReadPos], sim->ReadPos); int z = GetShort(&sim->readPtr[sim->ReadPos], sim->ReadPos); int y = GetShort(&sim->readPtr[sim->ReadPos], sim->ReadPos); creatureInstance->Heading = GetByte(&sim->readPtr[sim->ReadPos], sim->ReadPos); creatureInstance->Rotation = GetByte(&sim->readPtr[sim->ReadPos], sim->ReadPos); int speed = GetByte(&sim->readPtr[sim->ReadPos], sim->ReadPos); // LogMessageL(MSG_SHOW, "Heading:%d, Rot:%d, Spd:%d, X: %d, Y: %d, Z: %d", creatureInstance->Heading, creatureInstance->Rotation, speed, x, y, z); if (g_Config.FallDamage && !creatureInstance->actInst->mZoneDefPtr->mGrove) { int deltaY = creatureInstance->CurrentY - y; if (deltaY >= 30) pld->bFalling = true; if (pld->bFalling == true) { pld->DeltaY += deltaY; g_Logs.simulator->debug("[%v] Delta: %v, %v", sim->InternalID, deltaY, pld->DeltaY); } if (deltaY < 30) { if (pld->bFalling == true) { creatureInstance->CheckFallDamage(pld->DeltaY); g_Logs.simulator->debug("[%v] Damage: %v", sim->InternalID, pld->DeltaY); pld->bFalling = false; } pld->DeltaY = 0; } } if (g_Config.HasAdministrativeBehaviorFlag(ADMIN_BEHAVIOR_VERIFYSPEED) == true) { if (sim->CheckPermissionSimple(Perm_Account, Permission_Debug | Permission_Admin | Permission_Developer) == false) { int xlen = abs(x - (creatureInstance->CurrentX & 0xFFFF)); int zlen = abs(z - (creatureInstance->CurrentZ & 0xFFFF)); if (xlen < SimulatorThread::OverflowThreshold && zlen < SimulatorThread::OverflowThreshold) { int pspeed = 120 + creatureInstance->css.mod_movement; int distPerSecond = (int) (((float) pspeed / 100.0F) * 40.0F); //The number of units to move for this update. if (speed > pspeed || xlen > distPerSecond || zlen > distPerSecond) { g_Logs.cheat->warn( "[SPEED] Spd: %d / %d, xlen: %d, zlen: %d (%d)", speed, pspeed, xlen, zlen, distPerSecond); return PrepExt_GeneralMoveUpdate(sim->SendBuf, creatureInstance); } } } } creatureInstance->Speed = speed; int oldX = creatureInstance->CurrentX; int oldZ = creatureInstance->CurrentZ; int newX = oldX; int newZ = oldZ; //Since these updates are unsigned short, the maximum value they can relay //is 65535. Some maps are much larger (Europe), thus some kind of overflow //handling must be supplied to prevent characters from having their //position reach 0. Check for an overflow by comparing the new location //with the last location. If the distance is too great, a rollover //must've happened (although coordinate warping might be a possibility //too?) If the resulting short value is small, it means it overflowed //into a higher value. If not, it underflowed into a smaller value. if (abs(x - (oldX & 0xFFFF)) >= SimulatorThread::OverflowThreshold) { if (x < SimulatorThread::OverflowThreshold) newX += SimulatorThread::OverflowAdditive; else newX -= SimulatorThread::OverflowAdditive; } if (abs(z - (oldZ & 0xFFFF)) >= SimulatorThread::OverflowThreshold) { if (z < SimulatorThread::OverflowThreshold) newZ += SimulatorThread::OverflowAdditive; else newZ -= SimulatorThread::OverflowAdditive; } //Zero out the lower short, then OR it back with the short coords we received from the client. newX = (newX ^ (newX & 0xFFFF)) | x; newZ = (newZ ^ (newZ & 0xFFFF)) | z; creatureInstance->CurrentX = newX; creatureInstance->CurrentY = y; creatureInstance->CurrentZ = newZ; //LogMessageL(MSG_SHOW, "Loc: X:%d, Y:%d, Z:%d", x, y, z); //LogMessageL(MSG_SHOW, "Vel: Hd:%d, Rot:%d, Spd:%d", creatureInstance->Heading, creatureInstance->Rotation, creatureInstance->Speed); if (creatureInstance->Speed != 0) { //Check movement timers. int xlen = newX - oldX; int zlen = newZ - oldZ; float offset = sqrt((float) ((xlen * xlen) + (zlen * zlen))); creatureInstance->CheckMovement(offset); pld->TotalDistanceMoved += (int) offset; //Movement data verification against cheats. Only run it for normal players. //If administrative /setstat command was used to increase speed above 255 (speed is 1 byte) //the expected velocity won't match. //The client uses a recurring event pulse to send the avatar's velocity updates to the server. //The pulse activates at 0.25 second intervals, regardless of whether movement occurred. //If the client's update flag is true (at least some movement happened), the update is sent //with the player's current position and rotation, then the update flag is cleared. The //closed beta does not use any forced updates, although the client function allows that as //an optional parameter (forced updating would send the velocity update immediately, //independently from the update pulse, and would not trigger the update flag. //The pulse is not always accurate, and can vary with framerate. Also, when first logging in //the pulse seems to be ignored, instead sending sporadic updates whenever required. For example, //autorunning into a hill too steep to climb produces an indefinite flood of updates. At some //currently unknown point, the pulse seems to take over and subsequent floods will stop. //There are tons of weird cases where verification fails on legit movement, so it may be necessary //to just disable it entirely. if(g_Config.VerifyMovement == true && !sim->CheckPermissionSimple(Perm_Account, Permission_Admin | Permission_Developer)) { int expectedSpeed = 100 + creatureInstance->css.base_movement + creatureInstance->css.mod_movement; //The heading and rotation fields use only a single byte (0 to 255) to represent 360 degree //rotation. So 90 degrees (360/4) -> (255/4) = 64. //Usually if we're moving backward in a single direction (pressing Backward only) //then the difference is almost always ~128. However, if we're moving Left or Right while //moving backward, sometimes heading and rotation is the same so we can't judge by that. //Instead we have to look at the incoming speed. Since moving backward is half speed, //division may be off slightly so we allow a small tolerance. int halfExpected = abs(speed - (expectedSpeed / 2)); if ((speed != expectedSpeed) && (halfExpected > 3)) { g_Logs.cheat->info( "[SPEED] Unexpected speed by %s @ Zn:%d,X%d,Y%d, Spd:%d, Expected:%d", creatureInstance->css.display_name, pld->CurrentZoneID, newX, newZ, speed, expectedSpeed); } else { //Moving backwards, change to half speed for distance calculations. if ((speed != expectedSpeed) && (halfExpected <= 3)) expectedSpeed /= 2; } //Movement updates are typically every 250 milliseconds, but even on localhost can vary a bit. //Using the client, update intervals of ~218ms were semi common. unsigned long timeSinceLastMovement = g_ServerTime - pld->MovementTime; /* Removed: natural latency triggers this so often that it spams too many logs messages. if(timeSinceLastMovement < 200) { Debug::cheatLogger.Log("[SPEED] Rapid request by %s @ Zn:%d,X%d,Y%d, Spd:%d, Time:%lu", creatureInstance->css.display_name, pld->CurrentZoneID, newX, newZ, speed, timeSinceLastMovement); LogMessageL(MSG_SHOW, "[SPEED] Rapid request by %s @ Zn:%d,X%d,Y%d, Spd:%d, Time:%lu", creatureInstance->css.display_name, pld->CurrentZoneID, newX, newZ, speed, timeSinceLastMovement); } */ //We want to limit this to a quarter second so that we can calculate our expected //distance correctly, accepting lower update intervals but not large intervals which //would otherwise translate to potentially huge gaps with spoofed movement. //if(timeSinceLastMovement > 250) timeSinceLastMovement = 250; //Calculate how far the creature should have moved. Default speed is 100, so //convert that into an expected distance while factoring the incoming time interval //and a 50% tolerance. float expectedOffset = ((expectedSpeed / 100.0F) * DEFAULT_CREATURE_SPEED) * (timeSinceLastMovement / 1000.0F) * 1.5F; // Disabled: was testing incoming movement for verification but it doesn't really help. /* Sleep(1); g_Log.AddMessageFormat("Offset:%g, Expected:%g", offset, expectedOffset); */ if (offset > expectedOffset) { g_Logs.cheat->info( "[SPEED] Moved too far by %s @ Zn:%d,X%d,Z%d, Spd:%d, Offset X:%d,Z:%d Moved:%g/Expected:%g", creatureInstance->css.display_name, pld->CurrentZoneID, newX, newZ, speed, xlen, zlen, offset, expectedOffset); } } //Check our current position against any quest objective locations. //The movement counter will help us check every other step instead as a small optimization. if ((pld->PendingMovement & 1) && (pld->charPtr != NULL)) { int r = pld->charPtr->questJournal.CheckTravelLocations( creatureInstance->CreatureID, sim->Aux1, creatureInstance->CurrentX, creatureInstance->CurrentY, creatureInstance->CurrentZ, pld->CurrentZoneID); if (r > 0) sim->AttemptSend(sim->Aux1, r); } if (pld->PendingMovement >= 10) { pld->PendingMovement = 0; } } if (creatureInstance->actInst != NULL) { creatureInstance->actInst->PlayerMovement(creatureInstance); } //Check for zone boundaries, if a player is trying to go somewhere they should not be able to access. if (g_ZoneBarrierManager.CheckCollision(pld->CurrentZoneID, creatureInstance->CurrentX, creatureInstance->CurrentZ) == true) sim->AddMessage((long) creatureInstance, 0, BCM_UpdateFullPosition); int wpos = 0; //If GM invisible, send the update to ourself. Otherwise broadcast it. if (sim->IsGMInvisible() == true) { wpos = PrepExt_GeneralMoveUpdate(sim->SendBuf, creatureInstance); } else { sim->AddMessage((long) creatureInstance, 0, BCM_UpdateVelocity); sim->AddMessage((long) creatureInstance, 0, BCM_UpdatePosInc); } pld->PendingMovement++; pld->MovementTime = g_ServerTime; sim->CheckSpawnTileUpdate(false); sim->CheckMapUpdate(false); return wpos; }
short int CEgIStream::GetShort() { register unsigned long n = GetByte(); return (short int) ((GetByte() << 8) | n); }
void CEgIStream::Read() { unsigned char c = GetByteSW(); while ( noErr() && c != 13 && c != 9 && c != 32 && c != 10 ) // Stop on a CR, LF, space or error c = GetByte(); }
bool CNetAddr::IsRFC5737() const { return IsIPv4() && ((GetByte(3) == 192 && GetByte(2) == 0 && GetByte(1) == 2) || (GetByte(3) == 198 && GetByte(2) == 51 && GetByte(1) == 100) || (GetByte(3) == 203 && GetByte(2) == 0 && GetByte(1) == 113)); }
// Parse macro call ("+MACROTITLE"). Has to be re-entrant. void Macro_parse_call(void) // Now GotByte = dot or first char of macro name { char local_gotbyte; struct symbol *symbol; struct section new_section, *outer_section; struct input new_input, *outer_input; struct macro *actual_macro; struct rwnode *macro_node, *symbol_node; zone_t macro_zone, symbol_zone; int arg_count = 0; // Enter deeper nesting level // Quit program if recursion too deep. if (--macro_recursions_left < 0) Throw_serious_error("Too deeply nested. Recursive macro calls?"); macro_zone = get_zone_and_title(); // now GotByte = first non-space after title // internal_name = MacroTitle ARG_SEPARATOR (grows to signature) // Accept n>=0 comma-separated arguments before CHAR_EOS. // Valid argument formats are: // EXPRESSION (everything that does NOT start with '~' // ~.LOCAL_LABEL_BY_REFERENCE // ~GLOBAL_LABEL_BY_REFERENCE // now GotByte = non-space if (GotByte != CHAR_EOS) { // any at all? do { // if arg table cannot take another element, enlarge if (argtable_size <= arg_count) enlarge_arg_table(); // Decide whether call-by-reference or call-by-value // In both cases, GlobalDynaBuf may be used. if (GotByte == REFERENCE_CHAR) { // read call-by-reference arg DynaBuf_append(internal_name, ARGTYPE_NUM_REF); GetByte(); // skip '~' character Input_read_zone_and_keyword(&symbol_zone); // GotByte = illegal char arg_table[arg_count].symbol = symbol_find(symbol_zone, 0); } else { // read call-by-value arg DynaBuf_append(internal_name, ARGTYPE_NUM_VAL); ALU_any_result(&(arg_table[arg_count].result)); } ++arg_count; } while (Input_accept_comma()); } // now arg_table contains the arguments // now GlobalDynaBuf = unused // check for "unknown macro" // Search for macro. Do not create if not found. search_for_macro(¯o_node, macro_zone, FALSE); if (macro_node == NULL) { Throw_error("Macro not defined (or wrong signature)."); Input_skip_remainder(); } else { // make macro_node point to the macro struct actual_macro = macro_node->body; local_gotbyte = GotByte; // CAUTION - ugly kluge // set up new input new_input.original_filename = actual_macro->def_filename; new_input.line_number = actual_macro->def_line_number; new_input.source_is_ram = TRUE; new_input.state = INPUTSTATE_NORMAL; // FIXME - fix others! new_input.src.ram_ptr = actual_macro->parameter_list; // remember old input outer_input = Input_now; // activate new input Input_now = &new_input; // remember old section outer_section = Section_now; // start new section (with new zone) // FALSE = title mustn't be freed Section_new_zone(&new_section, "Macro", actual_macro->original_name, FALSE); GetByte(); // fetch first byte of parameter list // assign arguments if (GotByte != CHAR_EOS) { // any at all? arg_count = 0; do { // Decide whether call-by-reference // or call-by-value // In both cases, GlobalDynaBuf may be used. if (GotByte == REFERENCE_CHAR) { // assign call-by-reference arg GetByte(); // skip '~' character Input_read_zone_and_keyword(&symbol_zone); if ((Tree_hard_scan(&symbol_node, symbols_forest, symbol_zone, TRUE) == FALSE) && (pass_count == 0)) Throw_error("Macro parameter twice."); symbol_node->body = arg_table[arg_count].symbol; } else { // assign call-by-value arg Input_read_zone_and_keyword(&symbol_zone); symbol = symbol_find(symbol_zone, 0); // FIXME - add a possibility to symbol_find to make it possible to find out // whether symbol was just created. Then check for the same error message here // as above ("Macro parameter twice."). symbol->result = arg_table[arg_count].result; } ++arg_count; } while (Input_accept_comma()); } // and now, finally, parse the actual macro body Input_now->state = INPUTSTATE_NORMAL; // FIXME - fix others! // maybe call parse_ram_block(actual_macro->def_line_number, actual_macro->body) Input_now->src.ram_ptr = actual_macro->body; Parse_until_eob_or_eof(); if (GotByte != CHAR_EOB) Bug_found("IllegalBlockTerminator", GotByte); // end section (free title memory, if needed) Section_finalize(&new_section); // restore previous section Section_now = outer_section; // restore previous input: Input_now = outer_input; // restore old Gotbyte context GotByte = local_gotbyte; // CAUTION - ugly kluge Input_ensure_EOS(); } ++macro_recursions_left; // leave this nesting level }
bool CNetAddr::IsRFC3849() const { return GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x0D && GetByte(12) == 0xB8; }
void RegConfig::LoadConfiguration() { HANDLE hk; bSomeValuesMissed = FALSE; BOOL lbKeyOpened = FALSE; #if FAR_UNICODE>=1900 FarSettingsCreate sc = {sizeof(FarSettingsCreate), guid_PluginGuid, INVALID_HANDLE_VALUE}; FarSettingsItem fsi = {0}; lbKeyOpened = psi.SettingsControl(INVALID_HANDLE_VALUE, SCTL_CREATE, 0, &sc) != 0; hk = sc.Handle; #else lbKeyOpened = (0 == RegOpenKeyEx(HKEY_CURRENT_USER, pszPluginKey, 0, KEY_READ, (HKEY*)&hk)); #endif if (!lbKeyOpened) { // Если ключа не было - сразу создать в реестре значения по умолчанию! bSomeValuesMissed = TRUE; } else { GetByte(hk, L"Wow64on32", &bWow64on32_); // Отображать 64-битный реестр в FAR.x32 GetByte(hk, L"Virtualize", &bVirtualize); // Отображать виртуализированные значения реестра GetString(hk, L"CommandPrefix", sCommandPrefix, countof(sCommandPrefix)); // _T("reg2") GetString(hk, L"RegTitlePrefix", sRegTitlePrefix, countof(sRegTitlePrefix)); // _T("REG2") GetString(hk, L"RegTitleDirty", sRegTitleDirty, countof(sRegTitleDirty)); // _T(" (*)") GetBool(hk, L"AddToDisksMenu", &bAddToDisksMenu); GetString(hk, L"DiskMenuHotkey", cDiskMenuHotkey, countof(cDiskMenuHotkey)); GetBool(hk, L"AddToPluginsMenu", &bAddToPluginsMenu); GetBool(hk, L"BrowseRegFiles", &bBrowseRegFiles); GetByte(hk, L"BrowseRegHives", &bBrowseRegHives); GetBool(hk, L"SkipAccessDeniedMessage", &bSkipAccessDeniedMessage); GetBool(hk, L"UseBackupRestore", &bUseBackupRestore); GetBool(hk, L"SkipPrivilegesDeniedMessage", &bSkipPrivilegesDeniedMessage); GetBool(hk, L"ShowKeysAsDirs", &bShowKeysAsDirs); GetBool(hk, L"UnsortLargeKeys", &bUnsortLargeKeys); GetDWORD(hk, L"LargeKeyCount", &nLargeKeyCount); GetDWORD(hk, L"LargeKeyTimeout", &nLargeKeyTimeout); GetBool(hk, L"CreateUnicodeFiles", &bCreateUnicodeFiles); GetDWORD(hk, L"AnsiCodePage", &nAnsiCodePage); if (nAnsiCodePage == CP_UTF7 || nAnsiCodePage == CP_UTF8) nAnsiCodePage = 1251; GetBool(hk, L"EscapeRNonExporting", &bEscapeRNonExporting); GetBool(hk, L"CheckMacroSequences", &bCheckMacroSequences); GetBool(hk, L"CheckMacrosInVars", &bCheckMacrosInVars); GetBool(hk, L"EditBinaryAsText", &bEditBinaryAsText); GetBool(hk, L"RefreshChanges", &bRefreshChanges); GetBool(hk, L"LoadDescriptions", &bLoadDescriptions); GetBool(hk, L"ExportDefaultValueFirst", &bExportDefaultValueFirst); GetBool(hk, L"ConfirmImport", &bConfirmImport); GetBool(hk, L"ShowImportResult", &bShowImportResult); GetDWORD(hk, L"RefreshKeyTimeout", &nRefreshKeyTimeout); GetDWORD(hk, L"RefreshSubkeyTimeout", &nRefreshSubkeyTimeout); GetString(hk, L"LastRegPath", &pszLastRegPath); nMaxRegPath = (pszLastRegPath == 0) ? 0 : (lstrlenW(pszLastRegPath)+1); GetBool(hk, L"RestorePanelMode", &bRestorePanelMode); #if FAR_UNICODE>=1900 psi.SettingsControl(sc.Handle, SCTL_FREE, 0, 0); #else RegCloseKey((HKEY)hk); #endif } // Если ключа не было, или в плагине появились новые параметры - сразу сохранить наши текущие настройки (умолчания) if (bSomeValuesMissed) { SaveConfiguration(); } }
bool CNetAddr::IsRFC4380() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0 && GetByte(12) == 0); }
bool CNetAddr::IsMulticast() const { return (IsIPv4() && (GetByte(3) & 0xF0) == 0xE0) || (GetByte(15) == 0xFF); }
bool CNetAddr::IsRFC4843() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && (GetByte(12) & 0xF0) == 0x10); }
void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, const char *msg, long tm, int stat, int utf8, int buddy_icon, const char *seqn, int sendn) { char *umsg; const char *c = msg; int oidx = 0; CCSDATA ccs; PROTORECVEVENT pre; HANDLE hContact; LOG(("YAHOO_GOT_IM id:%s %s: %s (len: %d) tm:%lu stat:%i utf8:%i buddy_icon: %i", me, who, msg, lstrlenA(msg), tm, stat, utf8, buddy_icon)); if(stat == 2) { char z[1024]; snprintf(z, sizeof z, "Error sending message to %s", who); LOG((z)); ShowError(Translate("Yahoo Error"), z); return; } if(!msg) { LOG(("Empty Incoming Message, exiting.")); return; } if (GetByte( "IgnoreUnknown", 0 )) { /* * Check our buddy list to see if we have it there. And if it's not on the list then we don't accept any IMs. */ if (getbuddyH(who) == NULL) { LOG(("Ignoring unknown user messages. User '%s'. Dropping Message.", who)); return; } } if ( BuddyIgnored( who )) { LOG(("User '%s' on our Ignore List. Dropping Message.", who)); return; } // make a bigger buffer for \n -> \r\n conversion (x2) umsg = (char *) alloca(lstrlenA(msg) * 2 + 1); while ( *c != '\0') { // Strip the font tag if (!_strnicmp(c,"<font ",6) || !_strnicmp(c,"</font>",6) || // strip the fade tag !_strnicmp(c, "<FADE ",6) || !_strnicmp(c,"</FADE>",7) || // strip the alternate colors tag !_strnicmp(c, "<ALT ",5) || !_strnicmp(c, "</ALT>",6)){ while ((*c++ != '>') && (*c != '\0')); } else // strip ANSI color combination if ((*c == 0x1b) && (*(c+1) == '[')){ while ((*c++ != 'm') && (*c != '\0')); } else if (*c != '\0'){ umsg[oidx++] = *c; /* Adding \r to \r\n conversion */ if (*c == '\r' && *(c + 1) != '\n') umsg[oidx++] = '\n'; c++; } } umsg[oidx++]= '\0'; /* Need to strip off formatting stuff first. Then do all decoding/converting */ LOG(("%s: %s", who, umsg)); //if(!strcmp(umsg, "<ding>")) // :P("\a"); ccs.szProtoService = PSR_MESSAGE; ccs.hContact = hContact = add_buddy(who, who, protocol, PALF_TEMPORARY); //SetWord(hContact, "yprotoid", protocol); Set_Protocol(hContact, protocol); ccs.wParam = 0; ccs.lParam = (LPARAM) ⪯ pre.flags = (utf8) ? PREF_UTF : 0; if (tm) { HANDLE hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0); if (hEvent) { // contact has events DBEVENTINFO dbei; DWORD dummy; dbei.cbSize = sizeof (DBEVENTINFO); dbei.pBlob = (BYTE*)&dummy; dbei.cbBlob = 2; if (!CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei)) // got that event, if newer than ts then reset to current time if ((DWORD)tm < dbei.timestamp) tm = (long)time(NULL); } pre.timestamp = (DWORD)time(NULL); if ((DWORD)tm < pre.timestamp) pre.timestamp = tm; } else pre.timestamp = (DWORD)time(NULL); pre.szMessage = umsg; pre.lParam = 0; // Turn off typing CallService(MS_PROTO_CONTACTISTYPING, (WPARAM) hContact, PROTOTYPE_CONTACTTYPING_OFF); CallService(MS_PROTO_CHAINRECV, 0, (LPARAM) & ccs); // ack the message we just got if (seqn) yahoo_send_im_ack(m_id, me, who, seqn, sendn); if (buddy_icon < 0) return; //?? Don't generate floods!! DBWriteContactSettingByte(hContact, m_szModuleName, "AvatarType", (BYTE)buddy_icon); if (buddy_icon != 2) { reset_avatar(hContact); } else if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) == 0) { /* request the buddy image */ request_avatar(who); } }
// get canonical identifier of an address' group // no two connections will be attempted to addresses with the same group std::vector<unsigned char> CNetAddr::GetGroup() const { std::vector<unsigned char> vchRet; int nClass = NET_IPV6; int nStartByte = 0; int nBits = 16; // all local addresses belong to the same group if (IsLocal()) { nClass = 255; nBits = 0; } // all internal-usage addresses get their own group if (IsInternal()) { nClass = NET_INTERNAL; nStartByte = sizeof(g_internal_prefix); nBits = (sizeof(ip) - sizeof(g_internal_prefix)) * 8; } // all other unroutable addresses belong to the same group else if (!IsRoutable()) { nClass = NET_UNROUTABLE; nBits = 0; } // for IPv4 addresses, '1' + the 16 higher-order bits of the IP // includes mapped IPv4, SIIT translated IPv4, and the well-known prefix else if (IsIPv4() || IsRFC6145() || IsRFC6052()) { nClass = NET_IPV4; nStartByte = 12; } // for 6to4 tunnelled addresses, use the encapsulated IPv4 address else if (IsRFC3964()) { nClass = NET_IPV4; nStartByte = 2; } // for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 address else if (IsRFC4380()) { vchRet.push_back(NET_IPV4); vchRet.push_back(GetByte(3) ^ 0xFF); vchRet.push_back(GetByte(2) ^ 0xFF); return vchRet; } else if (IsTor()) { nClass = NET_TOR; nStartByte = 6; nBits = 4; } // for he.net, use /36 groups else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x04 && GetByte(12) == 0x70) nBits = 36; // for the rest of the IPv6 network, use /32 groups else nBits = 32; vchRet.push_back(nClass); while (nBits >= 8) { vchRet.push_back(GetByte(15 - nStartByte)); nStartByte++; nBits -= 8; } if (nBits > 0) vchRet.push_back(GetByte(15 - nStartByte) | ((1 << (8 - nBits)) - 1)); return vchRet; }
const char* decodeDisasm(uint8_t *table[256],unsigned int address,int *count,int realLength) { static char temporaryBuffer[2048]; char sprintBuffer[256]; uint8_t byte = GetByte(address); if (byte>realLength) { sprintf(temporaryBuffer,"UNKNOWN OPCODE"); return temporaryBuffer; } else { const char* mnemonic=table[byte]; const char* sPtr=mnemonic; char* dPtr=temporaryBuffer; int counting = 0; int doingDecode=0; if (sPtr==NULL) { sprintf(temporaryBuffer,"UNKNOWN OPCODE"); return temporaryBuffer; } while (*sPtr) { if (!doingDecode) { if (*sPtr=='%') { doingDecode=1; if (*(sPtr+1)=='$') sPtr++; } else { *dPtr++=*sPtr; } } else { char *tPtr=sprintBuffer; int negOffs=1; if (*sPtr=='-') { sPtr++; negOffs=-1; } int offset=(*sPtr-'0')*negOffs; sprintf(sprintBuffer,"%02X",GetByte(address+offset)); while (*tPtr) { *dPtr++=*tPtr++; } doingDecode=0; counting++; } sPtr++; } *dPtr=0; *count=counting; } return temporaryBuffer; }