size_t GetAppFolder(TCHAR* tcPath, size_t Len) { if(Len) { Len = GetModuleFileName(NULL, tcPath, Len); Len = TruncatePath(tcPath, Len ); } return Len; }
/* * Retrieves the path to the JRE home by locating JLI.DLL and * then truncating the path to JLI.DLL */ jboolean GetApplicationHomeFromDll(char *buf, jint bufsize) { HMODULE module; DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; if (GetModuleHandleEx(flags, (LPCSTR)&GetJREPath, &module) != 0) { if (GetModuleFileName(module, buf, bufsize) != 0) { return TruncatePath(buf); } } return JNI_FALSE; }
DllExport void GWFile::CreateDirectory(char *path) { if((_mkdir(path) == -1) && (errno == ENOENT)) { char *smallerPath = TruncatePath(path); if(smallerPath) { CreateDirectory(smallerPath); _mkdir(path); free(smallerPath); } } }
/* * Retrieves the path to the JRE home by locating the executable file * of the current process and then truncating the path to the executable */ jboolean GetApplicationHome(char *buf, jint bufsize) { GetModuleFileName(NULL, buf, bufsize); return TruncatePath(buf); }
VOID __cdecl DebugLog( DBG_LEVEL level, PCHAR file, ULONG line, PCHAR func, PCHAR fmt,...) //ANY_LEVEL { DBG_LEVEL DbgLevel; PCHAR DbgLevelName; va_list args; PCHAR buff; int left,res,len; CHAR Msg[MSG_MAX_LEN]; DbgLevel = level & DbgLevelMax; if( DbgLevel < g_DebugLevel) return; buff = Msg; left = MSG_MAX_LEN-1; #define CASE_DBG_LEVEL(x,y) case x: DbgLevelName = y; goto write; switch(DbgLevel) { CASE_DBG_LEVEL(DbgLevelNone,"None"); CASE_DBG_LEVEL(DbgLevelTrace,"Trace"); CASE_DBG_LEVEL(DbgLevelDebug,"Debug"); CASE_DBG_LEVEL(DbgLevelInfo,"Info"); CASE_DBG_LEVEL(DbgLevelError,"Error"); CASE_DBG_LEVEL(DbgLevelCriticalTrace,"CritTrace"); CASE_DBG_LEVEL(DbgLevelCriticalDebug,"CritDebug"); CASE_DBG_LEVEL(DbgLevelCriticalInfo,"CritInfo"); CASE_DBG_LEVEL(DbgLevelCriticalError,"CritError"); CASE_DBG_LEVEL(DbgLevelBeforeBsod,"BSOD"); write: WriteMsg(&buff,&left,"[%s,",DbgLevelName); break; default: DbgLevelName = "Unknown"; WriteMsg(&buff,&left,"[%s(%i),",DbgLevelName,DbgLevel); break; } WriteMsg(&buff,&left,KIP_DRIVER_NAMEA ": "); WriteMsg(&buff,&left,"%s() ",func); if ( DbgLevel >= DbgLevelDebug && file ){ WriteMsg(&buff,&left,":%s:%i,",TruncatePath(file),line); } WriteMsg(&buff,&left,"t%X] ",PsGetCurrentThreadId()); va_start(args,fmt); WriteMsg2(&buff,&left,fmt,args); va_end(args); Msg[MSG_MAX_LEN-1] = 0; len = strlen(Msg); DbgPrint("%s",Msg); return; }