void PathHelper::RemoveFromPath(CStdString sPath) { CStdString sFullPath = GetProcessPath(); sFullPath.ToLower(); sPath.ToLower(); if ( sPath.Right(1) == _T("\\") ) { sPath = sPath.Left(sPath.length() - 1); } int nStart = (x64_int_cast)sFullPath.find(sPath); while (nStart >= 0) // there may be multiple copies { int nEnd = nStart + (x64_int_cast)sPath.length() + 1; sFullPath = sFullPath.Left(nStart) + sFullPath.Right(sFullPath.length() - nEnd ); sFullPath.TrimRight(); sFullPath.TrimLeft(); if (sFullPath.Left(1) == _T(";")) sFullPath = sFullPath.Mid(1); sFullPath.Replace(_T(";;"),_T(";")); nStart = (x64_int_cast)sFullPath.find(sPath); } SetProcessPath(sFullPath); }
void CIceClientBase::InitIce(void) { string strBasePath = ""; strBasePath = GetProcessPath(); try { Ice::InitializationData initData; initData.properties = Ice::createProperties(); // // Set a default value for "Hello.Proxy" so that the demo will // run without a configuration file. // //initData.properties->setProperty("SHMIAlarm.Proxy", "SHMIAlarm:tcp -p 11888"); // // Now, load the configuration file if present. Under WinCE we // use "config.txt" since it can be edited with pocket word. // std::string strConfigfile = ""; try { strConfigfile =strBasePath + "../config/"; strConfigfile += m_strConfigFileName; initData.properties->load(strConfigfile); } catch(const Ice::FileException& ex) { std::cout<< ex.what() << endl; std::cout<< "Maybe cannot find the config file: " << strConfigfile << endl; Sleep(1000); return; } int argc = 0; m_communicator = Ice::initialize(argc, 0, initData); string strProxy = m_strProxy; strProxy += ".Proxy"; m_objPrx = m_communicator->stringToProxy(initData.properties->getProperty(strProxy)); //IceInternal::ProxyHandle<T> //AlarmViewer = //IceInternal::ProxyHandle::checkedCast(m_objPrx); GetProxy(); } catch(const Ice::Exception& ex) { //MessageBox(NULL, CString(ex.ice_name().c_str()), L"Exception", MB_ICONEXCLAMATION | MB_OK); string strMsg; strMsg = ex.ice_name(); //printf("%s \n", strMsg.c_str()); LOG_ERROR("%s", strMsg.c_str()); return; } }
PathHelper::PathHelper(void) : m_sOriginalPath(_T("")) { // Save the original path so we can restore it later m_sOriginalPath = GetProcessPath(); }
std::string Sys::GetConfigPath( std::string appname ) { char path[EE_MAX_CFG_PATH_LEN]; #if EE_PLATFORM == EE_PLATFORM_WIN #ifdef EE_COMPILER_MSVC char * ppath; size_t ssize = EE_MAX_CFG_PATH_LEN; _dupenv_s( &ppath, &ssize, "APPDATA" ); String::StrCopy( path, ppath, EE_MAX_CFG_PATH_LEN ); free( ppath ); if( !ssize ) return std::string(); #else char * home = getenv("APPDATA"); if( !home ) return std::string(); _snprintf(path, EE_MAX_CFG_PATH_LEN, "%s\\%s", home, appname.c_str() ); #endif #elif EE_PLATFORM == EE_PLATFORM_MACOSX char *home = getenv("HOME"); if( NULL == home ) { return std::string(); } snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/Library/Application Support/%s", home, appname.c_str() ); #elif EE_PLATFORM == EE_PLATFORM_HAIKU char *home = getenv("HOME"); if( NULL == home ) { return std::string(); } snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/config/settings/%s", home, appname.c_str() ); #elif EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_BSD || EE_PLATFORM == EE_PLATFORM_SOLARIS char * config = getenv("XDG_CONFIG_HOME"); if ( NULL != config ) { snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/%s", config, appname.c_str() ); } else { char *home = getenv("HOME"); if( NULL == home ) { return std::string(); } snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/.config/%s", home, appname.c_str() ); } #elif EE_PLATFORM == EE_PLATFORM_IOS return GetProcessPath() + "config"; #elif EE_PLATFORM == EE_PLATFORM_ANDROID if ( NULL != Window::cEngine::instance() ) return Window::cEngine::instance()->GetCurrentWindow()->GetInternalStoragePath(); return std::string(); #else #warning Sys::GetConfigPath not implemented for this platform ( it will use HOME directory + /.appname ) char *home = getenv("HOME"); if( NULL == home ) { return std::string(); } snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/.%s", home, appname.c_str() ); #endif return std::string( path ); }
void main(int argc, char** argv) { int apiCnt; char pth[300] ; bool compare = false, display = false, help = false; while(argc-- > 1){ argv++; if(strcmp(*argv, "/f")==0) fullPath = true; if(strcmp(*argv, "/c")==0) compare = true; if(strcmp(*argv, "/d")==0) display = true; if(strcmp(*argv, "/?")==0) help = true; if(strcmp(*argv, "/h")==0) help = true; if(strcmp(*argv, "-h")==0) help = true; if(strcmp(*argv, "-?")==0) help = true; } if(help){ system("cls"); printf("\n" " GDI Process Scanner - \n\n" " Scans the GDISharedHandleTable for processes id's\n" " which rootkits may be trying to hide from other\n" " techniques.\n\n" " Usage: gdiprocs.exe [ /f /c /d /? ]\n" "\t/f\tDisplay Fullpath of processes\n" "\t/c\tCompare process list w/WinApi results\n" "\t/d\tDisplay GDI handle count per process\n" "\t/?\tthis help screen\n\n"); return; } lpfnNTQuery = (NTQIP *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQueryInformationProcess"); if(lpfnNTQuery == NULL){ printf("Could not GetProcAddress(NtQueryInformationProcess)\n"); printf("Have to use default PEB offset, Probably wont work on XP SP2\n"); } HWND hWin = CreateWindow(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); printf("GDI Process Scanner - \n\n" "Scanning GDIShared Handle Table for unique process ids...\n\n"); PEB *p = GetPEBAddress(GetCurrentProcess()); for(int i=0; i < MAX_GDI_HANDLE; i++){ AddUniquePid( p->GdiSharedHandleTable[i].ProcessID ); } if(!GetSeDebug()) printf(" Could not get SeDebug, should run as admin\n"); if(compare){ apiCnt = TakeAPISnapShot(); printf(" Compare Mode\n %5d processes returned by WinAPI\n", apiCnt ); PruneApiTree(apiCnt); } if(allocationUp){ //chance of happening slim so not worth redesign printf(" ERROR: more than 200 processes found allocation ran out :-\\\n"); } printf(" %5d processes returned by GDI table\n\n", gdiCnt); printf(" Processes listed in GDI:\n"); printf(" -------------------------------------------------\n"); for(i=0;i<gdiCnt+1;i++){ if(gdi_pids[i] != 0){ GetProcessPath(gdi_pids[i], pth); if(display) printf("%5d - %5d - %s\n", gdi_pids[i], handleCnt[i], pth); else printf("%5d - %s\n", gdi_pids[i], pth); } } if(compare){ printf("\n\n API Processes not listed in GDI Table\n" " ---------------------------------------------------\n"); for(i=0;i<apiCnt+1;i++){ if(api_pids[i] != 0){ GetProcessPath(api_pids[i], pth); printf("%5d - %s\n", api_pids[i], pth); } } } printf("\n\n"); }
void TestScene::init() { atlas = new PumpkinSpice::TextureAtlas(); atlas->init("sprites2.xml"); PumpkinSpice::AtlasSprite* sprite; sprite = atlas->sprite("floor_tile_1.png"); _background = new PumpkinSpice::Background(); _background->sprite(*sprite); add_object(*_background); _test_sprite = new TestSprite(); _test_sprite->init(*atlas, "sprite_front.png"); _test_sprite->x(400); _test_sprite->y(400); TestSprite* tsprite = new TestSprite(); tsprite->init(*atlas, "sprite_front.png"); tsprite->x(200); tsprite->y(200); add_object(*tsprite); add_object(*_test_sprite); //Load ttf std::string ttf_path =GetProcessPath() + "lazy.ttf"; _ttf_test.load_ttf(ttf_path.c_str(), 120); _box = new PumpkinSpice::TextBox(); _box->color(0.0f, 1.0f, 1.0f, 1.0f); Vector2<float>* pos = new Vector2<float>(100,100); _box->position(*pos); _box->init(_ttf_test, "test sdfsdf sdf"); add_object(*_box); // // button.init(400,200, 600, 400, 1); // PumpkinSpice::Rect* test_area = new PumpkinSpice::Rect(); // test_area->init(400, 200, 200, 200); // button.font(_ttf_test, "test button",test_area); // add_object(button); // PumpkinSpice::Sprite* rug_sprite = new PumpkinSpice::Sprite(); // rug_sprite->init(test); // PumpkinSpice::GameObject* rug = new PumpkinSpice::GameObject(); // rug->sprite(*rug_sprite); // rug->x(100); // rug->y(100); //// add_object(*rug); // // PumpkinSpice::Sprite* server_sprite = new PumpkinSpice::Sprite(); // server_sprite->init(server); // PumpkinSpice::GameObject* server_object = new PumpkinSpice::GameObject(); // server_object->sprite(*server_sprite); // server_object->x(100); // server_object->y(100); // add_object(*server_object); // PumpkinSpice::Sprite* font_sprite = new PumpkinSpice::Sprite(); // font_sprite->init(font,"test"); // PumpkinSpice::GameObject* font_object = new PumpkinSpice::GameObject(); // font_object->sprite(*font_sprite); // font_object->x(100); // font_object->y(400); // add_object(*font_object); // // PumpkinSpice::AtlasSprite* ttf_sprite = new PumpkinSpice::AtlasSprite(); // PumpkinSpice::Rect* area = new PumpkinSpice::Rect; // area->init(0, 0, 800, 600); // FONT_ALIGNMENT alignment = (FONT_ALIGNMENT)(FONT_ALIGN_CENTERED_H | FONT_ALIGN_CENTERED_V); // ttf_sprite->init(ttf,"test ttf",area,alignment); // PumpkinSpice::GameObject* ttf_object = new PumpkinSpice::GameObject(); // ttf_object->sprite(*ttf_sprite); // ttf_object->x(400); // ttf_object->y(400); // add_object(*ttf_object); }
// returns the full path to the file `fileName` in the resources directory of the app bundle static std::string ResourcePath(std::string fileName) { return GetProcessPath() + "/../resources/" + fileName; }
void CLogI::InitDbStore() { //g_logDB.ConnectDb("./Application Data/GemmaLog.db"); //g_logTable.Open(g_logDB.GetDBPtr()); DelOldFiles(); std::string strPath = GetProcessPath(); TCHAR wstrPath[1024] = {0}; std::string strDataPath; strDataPath = strPath + "..\\data\\"; mbstowcs(wstrPath,strDataPath.c_str(), strDataPath.size()); CreateDirectory(wstrPath,NULL); strDataPath = strPath + "..\\data\\log\\"; mbstowcs(wstrPath,strDataPath.c_str(), strDataPath.size()); CreateDirectory(wstrPath,NULL); m_strLogFileName = GetProcessPath() + "../data/log/"; m_strLogFileName += LOG_DB_FILE ; m_strLogFileName += ".logdb"; m_strAlarmFileName = GetProcessPath() + "../data/log/"; m_strAlarmFileName += ALARM_DB_FILE; m_strAlarmFileName += ".logdb"; BOOL bConnect = FALSE; BOOL bOpen = FALSE; WLock(m_muLogDB) { bConnect = m_logDB.ConnectDb(m_strLogFileName.c_str()); if (FALSE == bConnect) { return ; } bOpen = m_logTable.Open(m_logDB.GetDBPtr()); if (FALSE == bOpen) { MakeNewDB(); //return ; } } WLock(m_muAlarmDB) { bConnect = m_alarmDB.ConnectDb(m_strAlarmFileName.c_str()); if (FALSE == bConnect) { return ; } bOpen = m_alarmTable.Open(m_alarmDB.GetDBPtr()); if (FALSE == bOpen) { return ; } } InitBoundID(); //m_hThreadDbStore = _beginthread(); unsigned dwThreadId = 0; bool ret = false; m_eventStore = CreateEvent(NULL, true, false, NULL); m_hThreadDbStore = (HANDLE)_beginthreadex(NULL, 0, __DataDaseStore, (LPVOID)this, 0, &dwThreadId); if (m_hThreadDbStore) { SetThreadPriority(m_hThreadDbStore, THREAD_PRIORITY_BELOW_NORMAL); ret = true; } else { ret = false; } }