bool PatchHook::install() { if(installed) { return true; } //If the user provided a signature instead of an address if(PatchAddress == NULL) { PatchAddress = FindCode(GetModuleHandle(0), &signature[0], signature.size()); if(PatchAddress == NULL) { return false; } } PatchAddress += offset; size_t originalSize = replacement.size(); //Back current code up originalCode.resize(originalSize); std::copy((char*)PatchAddress, (char*)PatchAddress + originalSize, originalCode.begin()); //Install the patch and restore the page protection DWORD oldProtect = 0; VirtualProtect((void*)PatchAddress, originalSize, PAGE_EXECUTE_READWRITE, &oldProtect); memcpy((void*)PatchAddress, &replacement[0], originalSize); VirtualProtect((void*)PatchAddress, originalSize, oldProtect, &oldProtect); this->installed = true; return true; }
/* * The key must be determined with GTIFKeyCode() before * the name can be encoded. */ int GTIFValueCode(geokey_t key, char *name) { KeyInfo *info; switch (key) { /* All codes using linear/angular/whatever units */ case GeogLinearUnitsGeoKey: case ProjLinearUnitsGeoKey: case GeogAngularUnitsGeoKey: case GeogAzimuthUnitsGeoKey: info=_geounitsValue; break; /* put other key-dependent lists here */ case GTModelTypeGeoKey: info=_modeltypeValue; break; case GTRasterTypeGeoKey: info=_rastertypeValue; break; case GeographicTypeGeoKey: info=_geographicValue; break; case GeogGeodeticDatumGeoKey: info=_geodeticdatumValue; break; case GeogEllipsoidGeoKey: info=_ellipsoidValue; break; case GeogPrimeMeridianGeoKey: info=_primemeridianValue; break; case ProjectedCSTypeGeoKey: info=_pcstypeValue; break; case ProjectionGeoKey: info=_projectionValue; break; case ProjCoordTransGeoKey: info=_coordtransValue; break; case VerticalCSTypeGeoKey: info=_vertcstypeValue; break; case VerticalDatumGeoKey: info=_vdatumValue; break; /* And if all else fails... */ default: info = _csdefaultValue;break; } return FindCode( info,name); }
void COrderManageDlg::InitOrder() { //当前用户单子 bool bHasOrder = false; COrder order; CString strCustomer = m_pCustomerCombo->GetText(); if (!strCustomer.IsEmpty() && COrderManager::Instance()->GetOrder(strCustomer, order)) { bHasOrder = true; } //添加号码 for (int i=1; i<=12; i++) { for (int j=0; j<=4; j++) { int nCode = i+j*12; if (nCode > COrder::CODE_NUMBER) { continue; } DuiLib::CControlUI* pCodeMoney = FindCode(nCode); if (pCodeMoney == NULL) //还没有添加一个 { pCodeMoney = AddCode(nCode); if (pCodeMoney == NULL) { continue; } } if (bHasOrder && order.Money(nCode)>0) { pCodeMoney->SetText(CStringUtil::Int64ToStr(order.Money(nCode))); } else { pCodeMoney->SetText(_T("")); } } } //总共下注数 16=%s总共下注%I64d CString strTotal; strTotal.Format(CLanguageManager::Instance()->LoadString(16), strCustomer, bHasOrder?order.GetTotalBuyMoney():0); m_pTotalInfoLabel->SetText(strTotal); //显示删除单子按钮 和 删除所有单子按钮 m_pDeleteOrderBtn->SetVisible(bHasOrder); m_pDeleteAllOrderBtn->SetVisible(COrderManager::Instance()->IsHasOrder()); }
void PrevPos(void) { do { epos--; if(epos<0) { epos=cnt-1; } } while(!IsInput(format[epos])); FindCode(estr[epos]); first=1; }
void NextPos(void) { do { epos++; if(epos>=cnt) { epos=0; } } while(!IsInput(format[epos])); FindCode(estr[epos]); first=1; }
bool CaveHook::install() { if(this->installed) { return true; } try { if(PatchAddress == NULL) { PatchAddress = FindCode(GetModuleHandle(0), &signature[0], signature.size()); PatchAddress += this->offset; } } catch(std::exception) { return false; } if(PatchAddress == NULL) { return false; } unsigned char *cc_code = (unsigned char*)PatchAddress; size_t copied = 0; xde_instr info; while(copied < 5) { xde_disasm(cc_code + copied, &info); copied += info.len; } this->copied = copied; if(type == JMP_TP || type == CALL_TP || type == CALL_DETOUR) { destination = (std::uintptr_t)generateTrampoline(PatchAddress, destination, copied); } if(type == CALL_DETOUR) { destination += 2; } originalCode.resize(copied); std::copy(cc_code, cc_code + copied, originalCode.begin()); if(type == JMP_TP) { *pReturn = destination + 7; } else if(type == NAKED) { *pReturn = PatchAddress + copied; } else if(type == CALL_DETOUR) { *pReturn = destination + 7; } else if(type == CALL_NO_TP && pReturn != NULL) { *pReturn = *(std::uintptr_t*)(PatchAddress + 1) + PatchAddress + 5; } // insert codecave jump DWORD OldProtect; if(VirtualProtect((LPVOID)PatchAddress, copied, PAGE_EXECUTE_READWRITE, &OldProtect) == 0) { return false; } cc_code[0] = (type == CALL_NO_TP)? NEAR_CALL : REL_JMP; std::uintptr_t CallOffset = destination - (PatchAddress + 5); *(std::uintptr_t*)(&cc_code[1]) = CallOffset; //Calculate how many bytes of the original instruction are remaining and then overwrite them with nops size_t bytesLeft = copied - 5; //a jmp hook is five bytes memset(&cc_code[5], 0x90, bytesLeft); //Restore original page protection VirtualProtect((LPVOID)PatchAddress, copied, OldProtect, &OldProtect); this->installed = true; return true; }
int GTIFTagCode(char *tag) { return FindCode( &_tagInfo[0],tag); }
int GTIFTypeCode(char *type) { return FindCode( &_formatInfo[0],type); }
int GTIFKeyCode(char *key) { return FindCode( &_keyInfo[0],key); }
//装载INI配置文件 void CINIsoc::Loadini() { if( !m_SectMap.empty() ) { //清理列表 Clear(); } //纳入内存池,从缓存中申请,更快 char* buf = theApp.m_memPool.NewMem(SECTION_BUF); if(NULL==buf) return; memset(buf,0,SECTION_BUF); //日志标记 UINT uiRet = ::GetPrivateProfileInt("System", "IsLog", 0, theApp.m_sPathDll+"s_tztredis.ini"); if( uiRet > 0 ) theApp.m_logMgt.m_bStartlog = true; //数据库相关信息 { CString sGlobleFile = theApp.m_sPath+_T("server.ini"); char chTemp[50] = {0}; #ifdef XWB_SQL_LINK //2013.06.06 xuwb SQL版 ::GetPrivateProfileString("connect", "address", "", chTemp, 50, sGlobleFile); m_DataSource = chTemp; m_DataSource.Trim(); #else//Oracle版 ::GetPrivateProfileString("connect", "sysdb", "", chTemp, 50, sGlobleFile); m_DataSource = chTemp; m_DataSource.Trim(); #endif memset(chTemp,0,50); ::GetPrivateProfileString("connect", "username", "", chTemp, 50, sGlobleFile); m_UserID = chTemp; m_UserID.Trim(); memset(chTemp,0,50); ::GetPrivateProfileString("connect", "password", "", chTemp, 50, sGlobleFile); m_Password = chTemp; m_Password.Trim(); //增加多APP支持,2015.09.07 memset(chTemp,0,50); ::GetPrivateProfileString("HSCOMM", "IsMultiApp", "", chTemp, 50, sGlobleFile); m_isMultiApp = chTemp; m_Password.Trim(); //2013.06.06 增加sql数据库配置 InitialCatalog memset(chTemp,0,50); ::GetPrivateProfileString("connect", "sysdb", "", chTemp, 50, sGlobleFile); m_InitialCatalog = chTemp; m_InitialCatalog.Trim(); memset(chTemp,0,50); ::GetPrivateProfileString("comm", "systype", "0", chTemp, 50, sGlobleFile); m_SysType = chTemp; m_SysType.Trim(); memset(chTemp,0,50); ::GetPrivateProfileString("HSCOMM", "centerNo", "", chTemp, 50, sGlobleFile); m_center_no = chTemp; m_center_no.Trim(); ::GetPrivateProfileString("HSCOMM", "IsCluster", "N", chTemp, 50, sGlobleFile); //2015.07.30 m_isCluster = chTemp; m_isCluster.Trim(); m_PageSize = ::GetPrivateProfileInt("connect", "Page_size", 50, sGlobleFile); m_centerCount = ::GetPrivateProfileInt("HSCOMM", "centerCount", 1, sGlobleFile); memset(chTemp, 0, 50); ::GetPrivateProfileString("HSCOMM", "Port", "", chTemp, 50, sGlobleFile); //外壳监听端口 m_MainPort = chTemp; m_MainPort.Trim(); } CString sFile = theApp.m_sPathDll+_T("s_tztredis.ini"); char chTemp[50] = {0}; ::GetPrivateProfileString("alarm", "StockBgnTime", "", chTemp, 50, sFile);//开始同步股票市场号时间2015.06.27 m_StockBgnTime = chTemp; m_StockBgnTime.Trim(); memset(chTemp, 0, 50); ::GetPrivateProfileString("alarm", "StockEndTime", "", chTemp, 50, sFile);//结束同步股票市场号时间2015.06.27 m_StockEndTime = chTemp; m_StockEndTime.Trim(); m_AlarmThreadNo = ::GetPrivateProfileInt("alarm", "AlarmThreadNo", 10, sFile); //预警线程数 m_msgTimeOut = ::GetPrivateProfileInt("comm", "MsgTimeOut", 30, sFile); //消息超时删除时间(默认30天) memset(chTemp, 0, 50); ::GetPrivateProfileString("alarm", "AlarmMenu", "203", chTemp, 50, sFile);//预警栏目2016.03.04 m_alarmMenu = chTemp; m_alarmMenu.Trim(); memset(chTemp, 0, 50); ::GetPrivateProfileString("alarm", "MenuType", "2", chTemp, 50, sFile);//预警栏目类型 m_alarmType = chTemp; m_alarmType.Trim(); memset(chTemp, 0, 50); ::GetPrivateProfileString("account", "ShowAlert", "0", chTemp, 50, sFile);//是否弹框 m_ShowAlert = chTemp; m_ShowAlert.Trim(); //获取所有的[section] memset(buf,0,SECTION_BUF); DWORD wRet = ::GetPrivateProfileSectionNames(buf,SECTION_BUF,sFile); if(wRet > 0){ //从文件配置 CutString(buf,wRet,sFile); } m_zjjip = FindCode("comm", "zjjip"); m_zjjport = FindCode("comm", "zjjport"); m_gjip = FindCode("comm", "gjip"); m_gjport = FindCode("comm", "gjport"); m_isForGj = FindCode("comm", "IsForGJ"); //是否供国金使用 m_hqAddr = FindCode("comm", "hqAddr"); // 行情服务器地址 m_hqPort = FindCode("comm", "hqPort"); // 行情服务器端口 m_XJTAddr = FindCode("comm", "XJTAddr"); // 中山证券 现金通服务器地址 m_XJTPort = FindCode("comm", "XJTPort"); // 中山证券 现金通服务器端口 m_SyncTime = FindCode("comm", "SyncTime"); // 同步现金通数据的时间 m_noDelMenu = FindCode("comm", "NoDelMenu"); //不做历史消息清理的栏目 m_NewStockMsg = FindCode("comm", "NewStockMsg"); // 当日有新股时推送的内容 m_isForHt=FindCode("comm","IsForHt");//是否供华泰使用 m_ipoBgnTime = FindCode("IPO","IpoBgnTime");//新股提醒开始时间 m_ipoBgnTime.Format("%06s",m_ipoBgnTime); m_ipoEndTime = FindCode("IPO","IpoEndTime");//新股提醒结束时间 m_ipoEndTime.Format("%06s",m_ipoEndTime); m_alarmFrom=FindCode("alarm","AlarmFrom");//预警消息来源 m_alarmMode=FindCode("alarm","AlarmMode");//预警模式 m_mobileSupport = FindCode("comm","MobileSupport"); //是否支持手机号发送(2016.01.19) m_ipoPush = FindCode("IPO","IpoPush"); //是否支持新股提醒推送(2016.02.02) m_ipoMenu = FindCode("IPO","IpoMenu"); //新股提醒推送栏目id(2016.02.02) m_InfoServerIp = FindCode("IPO","InfoServerIp"); //资讯服务器地址(用于获取当日新股) m_InfoServerPort = FindCode("IPO","InfoServerPort"); m_PushServerIp = FindCode("IPO","PushServerIp"); //推送服务器地址(用于消息群推) m_PushServerPort = FindCode("IPO","PushServerPort"); m_ipoMsgFrom = FindCode("IPO","IpoMsgFrom"); m_ipoTimeOutMin = FindCode("IPO","TimeOutMin"); m_ipoMsgMark = FindCode("IPO","MsgMark"); m_queryip = FindCode("account","AccQueryIp"); //账号权限查询ip m_queryport = FindCode("account","AccQueryPort"); //账号权限查询端口 m_accNotice = FindCode("account","AccNotice");//账号绑定提醒 m_accType = FindCode("account","AccType");//唯一登录推送的消息类型 }
/* * The key must be determined with GTIFKeyCode() before * the name can be encoded. */ int GTIFValueCode(geokey_t key, char *name) { return FindCode(FindTable(key),name); }