/* * DumpHeader */ void DumpHeader( FILE *fptr ) { time_t tm; char *str; tm = time( NULL ); str = GetRCString( STR_EVENT_LIST_LINE ); fprintf( fptr, str ); str = GetRCString( STR_EVENT_LIST_HEADER ); fprintf( fptr, str, ctime( &tm ) ); str = GetRCString( STR_EVENT_LIST_LINE ); fprintf( fptr, str ); } /* DumpHeader */
/* * ProcessIncomingMessage - get a string associated with a message id */ void ProcessIncomingMessage( int msgid, char *class_name, char *res ) { message *msg; char *fmtstr; char buf[256]; res[0] = 0; msg = GetMessageDataFromID( msgid, class_name ); if( msg != NULL ) { if( msg->bits[M_WATCH] ) { strcpy( res, msg->str ); } if( msg->bits[M_STOPON] ) { SetSpyState( OFF ); RCsprintf( buf, STR_SPYING_STOPPED, msg->str ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } msg->count++; } else if( msgid > WM_USER ) { userMsg->count++; if( userMsg->bits[M_WATCH] ) { fmtstr = GetRCString( STR_WM_USER_PLUS ); sprintf( res, fmtstr, msgid - WM_USER ); } if( userMsg->bits[M_STOPON] ) { SetSpyState( OFF ); fmtstr = GetRCString( STR_WM_USER_PLUS ); sprintf( res, fmtstr, msgid - WM_USER ); RCsprintf( buf, STR_SPYING_STOPPED, res ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } } else { if( Filters[MC_UNKNOWN].flag[M_WATCH] ) { fmtstr = GetRCString( STR_UNKNOWN_MSG ); sprintf( res, fmtstr, msgid ); } if( Filters[MC_UNKNOWN].flag[M_STOPON] ) { SetSpyState( OFF ); fmtstr = GetRCString( STR_UNKNOWN_MSG ); RCsprintf( buf, STR_SPYING_STOPPED, res ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } } } /* ProcessIncomingMessage */
void readSettings() { settings.showErrors = GetRCBoolDef("LSActiveDesktopShowErrors", TRUE) != FALSE; char line[MAX_LINE_LENGTH + 1]; const char *tokenStart = line; char token[MAX_LINE_LENGTH + 1]; GetRCLine("LSActiveDesktopWebWindows", line, MAX_LINE_LENGTH + 1, NULL); while (GetToken(tokenStart, token, &tokenStart, false)) { std::string name(token); std::transform(name.begin(), name.end(), name.begin(), tolower); LSADWebWndProp props; props.x = GetRCCoordinate((name + "X").c_str(), 0, GetSystemMetrics(SM_CXVIRTUALSCREEN)); props.y = GetRCCoordinate((name + "Y").c_str(), 0, GetSystemMetrics(SM_CYVIRTUALSCREEN)); props.width = GetRCInt((name + "Width").c_str(), 100); props.height = GetRCInt((name + "Height").c_str(), 100); props.showScrollbars = !(GetRCBool((name + "HideScrollbars").c_str(), TRUE) != FALSE); char url[MAX_LINE_LENGTH + 1]; GetRCString((name + "URL").c_str(), url, "http://tlundberg.com", MAX_LINE_LENGTH + 1); props.url = url; settings.windowProperties.insert(make_pair(name, props)); } }
/* * setSingleWindow - set window title for one window spyed on */ static void setSingleWindow( HWND hwnd, HWND selwin ) { char str[128]; char tmp[32]; char *fmtstr; int len; len = GetWindowText( selwin, tmp, sizeof( tmp ) ); tmp[len] = 0; if( len == 0 ) { fmtstr = GetRCString( STR_1_WIN_TITLE ); sprintf( str, fmtstr, SpyName, UINT_STR_LEN, (UINT)(pointer_int)selwin ); } else { fmtstr = GetRCString( STR_1_NAMED_WIN_TITLE ); sprintf( str, fmtstr, SpyName, UINT_STR_LEN, (UINT)(pointer_int)selwin, tmp ); } SetWindowText( hwnd, str ); } /* setSingleWindow */
/* * setMultipleWindows */ static void setMultipleWindows( HWND hwnd ) { char str[128]; char *rcstr; rcstr = GetRCString( STR_MULTIPLE_WIN_TITLE ); sprintf( str, rcstr, SpyName ); SetWindowText( hwnd, str ); } /* setMultipleWindows */
/* * SetSpyState - set current spy state */ void SetSpyState( spystate ss ) { char str[130]; char *rcstr; int len; SpyState = ss; len = GetWindowText( SpyMainWindow, &str[1], sizeof( str ) - 2 ); switch( ss ) { case OFF: if( str[ 1 ] != '<' ) { str[ 0 ] = '<'; str[ len + 1 ] = '>'; str[ len + 2 ] = 0; SetWindowText( SpyMainWindow, str ); } rcstr = GetRCString( STR_SPY_ON ); ModifyMenu( SpyMenu, SPY_OFFON, MF_BYCOMMAND | MF_ENABLED | MF_STRING, SPY_OFFON, rcstr ); break; case ON: rcstr = GetRCString( STR_SPY_OFF ); ModifyMenu( SpyMenu, SPY_OFFON, MF_BYCOMMAND | MF_ENABLED | MF_STRING, SPY_OFFON, rcstr ); if( str[ 1 ] == '<' ) { str[ len ] = 0; SetWindowText( SpyMainWindow, &str[ 2 ] ); } break; case NEITHER: rcstr = GetRCString( STR_SPY_OFF ); ModifyMenu( SpyMenu, SPY_OFFON, MF_BYCOMMAND | MF_GRAYED | MF_STRING, SPY_OFFON, rcstr ); if( str[ 1 ] == '<' ) { str[ len ] = 0; SetWindowText( SpyMainWindow, &str[ 2 ] ); } break; } SetOnOffTool( ss ); } /* SetSpyState */
int GetRCCoordinate(LPCSTR pszKeyName, int nDefault, int nMaxVal) { char strVal[MAX_LINE_LENGTH]; if (!GetRCString(pszKeyName, strVal, NULL, MAX_LINE_LENGTH)) { return nDefault; } return ParseCoordinate(strVal, nDefault, nMaxVal); }
/* * GetWindowStyleString - get string corrosponding to window style bits */ void GetWindowStyleString( HWND hwnd, char *str, char *sstr ) { UINT id; DWORD style; DWORD exstyle; char tmp[40]; int len; char *rcstr; int i; int j; style = GetWindowLong( hwnd, GWL_STYLE ); exstyle = GetWindowLong( hwnd, GWL_EXSTYLE ); GetHexStr( str, style, 8 ); str[8] = 0; sstr[0] = 0; if( style & WS_CHILD ) { id = GET_ID( hwnd ); rcstr = GetRCString( STR_CHILD_ID ); sprintf( tmp, rcstr, id, UINT_STR_LEN, id ); strcat( str, tmp ); } for( i = 0; i < StyleArraySize; i++ ) { if( (style & StyleArray[i].mask) == StyleArray[i].flags ) { strcat( sstr, StyleArray[i].name ); strcat( sstr, " " ); } } len = GetClassName( hwnd, tmp, sizeof( tmp ) ); tmp[len] = 0; for( i = 0; i < ClassStylesSize; i++ ) { if( !stricmp( tmp, ClassStyles[i].class_name ) ) { for( j = 0; j < *ClassStyles[i].style_array_size; j++ ) { if( (style & ClassStyles[i].style_array[j].mask) == ClassStyles[i].style_array[j].flags ) { strcat( sstr, ClassStyles[i].style_array[j].name ); strcat( sstr, " " ); } } } } for( i = 0; i < ExStyleArraySize; i++ ) { if( (exstyle & ExStyleArray[i].mask) == ExStyleArray[i].flags ) { strcat( sstr, ExStyleArray[i].name ); strcat( sstr, " " ); } } } /* GetWindowStyleString */
BOOL LSUtils::PrefixedGetRCString(LPCTSTR prefix, LPCTSTR setting, LPTSTR buffer, LPCTSTR defaultString, int maxLen) { BOOL res = FALSE; LPTSTR szTemp; AppendSetting(prefix, setting, szTemp); res = GetRCString(szTemp, buffer, defaultString, maxLen); #ifdef _DEBUG _LSLogPrintf(LOG_DEBUG, szLogName, "looking for setting: %s, got: %s", szTemp, buffer); #endif delete [] szTemp; return res; }
// // LSGetLitestepPath // BOOL WINAPI LSGetLitestepPath(LPSTR pszPath, size_t cchPath) { BOOL bReturn = FALSE; if (pszPath != NULL && cchPath > 0) { // Default to user defined variable if (GetRCString("litestepdir", pszPath, NULL, (int)cchPath)) { bReturn = TRUE; } } return bReturn; }
Mailbox::Mailbox(char* name, unsigned numSubjects): mail() { // Copy args strcpy(sName, name); iSubjects = numSubjects; // Copy the rest of the args derived from the mailbox name strcpy(sSetting, name); strcat(sSetting, "server"); if(GetRCString(sSetting, sServer, NULL, MAX_LINE_LENGTH)) { strcpy(sSetting, name); strcat(sSetting, "type"); GetRCString(sSetting, sType, "pop3", MAX_LINE_LENGTH); strcpy(sSetting, name); strcat(sSetting, "user"); GetRCString(sSetting, sUser, "anonymous", MAX_LINE_LENGTH); strcpy(sSetting, name); strcat(sSetting, "port"); if (!strcmp("imap", sType)) GetRCString(sSetting, sPort, "143", MAX_LINE_LENGTH); else GetRCString(sSetting, sPort, "110", MAX_LINE_LENGTH); strcpy(sSetting, name); strcat(sSetting, "password"); GetRCString(sSetting, sPass, "", MAX_LINE_LENGTH); strcpy(sSetting, name); strcat(sSetting, "folder"); GetRCString(sSetting, sFolder, "inbox", MAX_LINE_LENGTH); // If no password was found in config, get it from database/dialog if (!(*sPass)) GetPass(); // Set evars strcpy(sEvar, "AcidMail"); strcat(sEvar, name); LSSetVariable(sEvar, "0"); strcpy(sErrorVar, sEvar); strcat(sErrorVar, "Error"); LSSetVariable(sErrorVar, "none"); } else { ErrorHandler(Error(false, LOG_ERROR, "No host found in config files", NULL)); mail.bError = true; } }
/* * GetWindowName - set up a window name string */ void GetWindowName( HWND hwnd, char *str ) { int len; char name[64]; if( hwnd == NULL ) { strcpy( str, GetRCString( STR_NONE ) ); return; } len = GetWindowText( hwnd, name, sizeof( name ) ); name[len] = 0; if( len == 0 ) { GetHexStr( str, (UINT)hwnd, 4 ); str[4] = 0; } else { sprintf( str, "%0*x: %s", UINT_STR_LEN, (UINT)hwnd, name ); } } /* GetWindowName */
/* * WinMain - main entry point */ int WINMAINENTRY WinMain( HINSTANCE currinst, HINSTANCE previnst, LPSTR cmdline, int cmdshow ) { MSG msg; HWND prev_hwnd; char *errstr; cmdline = cmdline; errstr = errstr; SetInstance( currinst ); #ifdef __NT__ /* because of the shared memory used by the NT spy we can only allow * one spy to exist at a time */ prev_hwnd = FindWindow( SPY_CLASS_NAME, NULL ); if( prev_hwnd != NULL ) { errstr = GetRCString( STR_ONLY_1_SPY_ALLOWED ); MessageBox( NULL, errstr, SpyName, MB_OK | MB_ICONEXCLAMATION ); /* setting the window topmost then not topmost is a kludge to * make sure the window is really moved to the top */ SetWindowPos( prev_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetWindowPos( prev_hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); exit( 0 ); } #else prev_hwnd = prev_hwnd; #endif if( !spyInit( currinst, previnst, cmdshow ) ) { exit( 0 ); } while( GetMessage( &msg, (HWND)NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } SpyFini(); return( 1 ); } /* WinMain */
static void doSpyAll( HWND hwnd, BOOL state ) { char *rcstr; char tmp[32]; if( !state ) { SendMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( SPY_STOP, 0, 0 ) ); } else { spyAll = state; EnableMenuItem( SpyMenu, SPY_STOP, MF_ENABLED ); CheckMenuItem( SpyMenu, SPY_ALL_WINDOWS, MF_CHECKED ); SetFilter( HandleMessageInst ); ClearSelectedWindows(); if( SpyState == NEITHER ) { ClearMessageCount(); } rcstr = GetRCString( STR_ALL_WIN_TITLE ); sprintf( tmp, rcstr, SpyName ); SetWindowText( hwnd, tmp ); EnableMenuItem( SpyMenu, SPY_ADD_WINDOW, MF_GRAYED ); } }
// // LSGetImagePath // BOOL WINAPI LSGetImagePath(LPSTR pszPath, size_t cchPath) { BOOL bReturn = FALSE; if (pszPath != NULL && cchPath > 0) { if (GetRCString("LSImageFolder", pszPath, NULL, (int)cchPath)) { bReturn = SUCCEEDED(PathAddBackslashEx(pszPath, cchPath)); } else { if (LSGetLitestepPath(pszPath, cchPath)) { StringCchCat(pszPath, cchPath, "images\\"); bReturn = TRUE; } } } return bReturn; }
/* * WinMain - entry point for the uninstaller */ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { char szExePath[MAX_PATH]; char szCheckPath[MAX_PATH]; char szInstallPath[MAX_PATH]; char *pch; char *pszTitle; char *pszMessage; char *pszUninstallFile; HWND hDlg; WIN32_FIND_DATA wfd; HANDLE hFindFile; LPITEMIDLIST pidlPrograms; char szProgramsPath[MAX_PATH]; /* * Load the title for message boxes. */ pszTitle = AllocRCString( UNINS_TITLE ); /* * Get the directory where the uninstaller is located. */ GetModuleFileName( NULL, szExePath, MAX_PATH ); strcpy( szInstallPath, szExePath ); pch = strrchr( szInstallPath, '\\' ); *pch = '\0'; /* * Look for the check file to ensure that the uninstaller is being actually run from * an Open Watcom installation directory. */ strcpy( szCheckPath, szInstallPath ); strcat( szCheckPath, "\\" ); strcat( szCheckPath, CHECK_FILE_NAME ); hFindFile = FindFirstFile( szCheckPath, &wfd ); if( hFindFile == INVALID_HANDLE_VALUE ) { pszMessage = GetRCString( UNINS_NO_OW_INST ); MessageBox( NULL, pszMessage, pszTitle, MB_OK | MB_ICONSTOP ); FreeRCString( pszTitle ); return( 1 ); } FindClose( hFindFile ); /* * Check that the user actually wants to uninstall Open Watcom. */ pszMessage = GetRCString( UNINS_CONFIRM ); if( MessageBox( NULL, pszMessage, pszTitle, MB_YESNO | MB_ICONQUESTION ) == IDNO ) { FreeRCString( pszTitle ); return( 0 ); } /* * Display the progress dialog box during the uninstallation. */ hDlg = CreateDialog( hInstance, "PROGRESS", NULL, ProgressDlgProc ); /* * Get the name of the uninstaller. */ pszUninstallFile = strrchr( szExePath, '\\' ); pszUninstallFile++; /* * Delete all files except the uninstaller. */ DeleteFolder( hDlg, szInstallPath, pszUninstallFile ); /* * Delete the Open Watcom program folder from the start menu. */ if( SUCCEEDED( SHGetSpecialFolderLocation( NULL, CSIDL_PROGRAMS, &pidlPrograms ) ) ) { if( SHGetPathFromIDList( pidlPrograms, szProgramsPath ) ) { pch = szProgramsPath + strlen( szProgramsPath ); *pch = '\\'; pch++; strcpy( pch, "Open Watcom C - C++" ); DeleteFolder( hDlg, szProgramsPath, NULL ); RemoveDirectory( szProgramsPath ); strcpy( pch, "Open Watcom C - C++ Tools Help" ); DeleteFolder( hDlg, szProgramsPath, NULL ); RemoveDirectory( szProgramsPath ); } } /* * Tell Windows to delete the uninstaller and the folder in which it lives the next * time the computer is restarted. */ MoveFileEx( szExePath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT ); MoveFileEx( szInstallPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT ); /* * Remove the uninstaller from the Add/Remove Programs list. */ RegDeleteKey( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" UNINSTALL_NAME ); /* * Take away the progress dialog. */ EndDialog( hDlg, 0 ); /* * Inform the user that the uninstallation has been completed. */ pszMessage = GetRCString( UNINS_COMPLETED ); MessageBox( NULL, pszMessage, pszTitle, MB_OK ); FreeRCString( pszTitle ); return( 0 ); } /* WinMain */
/* * DDETrackingWndProc - handle messages from the tracking windows */ BOOL __export FAR PASCAL DDETrackingWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { DDETrackInfo *info; WORD i; void **ptr; RECT area; WORD cmd; char *wintitle; info = (DDETrackInfo *)GetWindowLong( hwnd, 0 ); switch( msg ) { case WM_CREATE: info = MemAlloc( sizeof( DDETrackInfo ) ); memset( info, 0, sizeof( DDETrackInfo ) ); info->type = *(WORD *)((CREATESTRUCT *)lparam)->lpCreateParams; SetWindowLong( hwnd, 0, (DWORD)info ); switch( info->type ) { case DDEMENU_TRK_CONV: info->sorttype = PUSH_CLIENT; makePushWin( info, hwnd, ConvHdr, CNV_HDR_CNT ); wintitle = GetRCString( STR_CONVERSATIONS ); break; case DDEMENU_TRK_STR: info->sorttype = PUSH_STR_TEXT; makePushWin( info, hwnd, StrHdr, STR_HDR_CNT ); wintitle = GetRCString( STR_STRINGS ); break; case DDEMENU_TRK_LINK: info->sorttype = PUSH_CLIENT; makePushWin( info, hwnd, LnkHdr, LNK_HDR_CNT ); wintitle = GetRCString( STR_LINKS ); break; case DDEMENU_TRK_SERVER: info->sorttype = PUSH_INST; makePushWin( info, hwnd, SrvHdr, SRV_HDR_CNT ); wintitle = GetRCString( STR_REG_SERVERS ); break; } SetWindowText( hwnd, wintitle ); CreateListBox( hwnd, &info->list ); info->config = &Tracking[info->type - DDE_TRK_FIRST]; if( info->config->visible ) { ShowWindow( hwnd, SW_SHOWNORMAL ); } break; case WM_MOVE: GetWindowRect( hwnd, &area ); info->config->xpos = area.left; info->config->ypos = area.top; break; case WM_SIZE: ResizeListBox( LOWORD( lparam ), HIWORD( lparam ), &info->list ); GetWindowRect( hwnd, &area ); if( wparam != SIZE_MAXIMIZED && wparam != SIZE_MINIMIZED ) { info->config->xsize = area.right - area.left; info->config->ysize = area.bottom - area.top; } break; case WM_COMMAND: cmd = LOWORD( wparam ); switch( info->type ) { case DDEMENU_TRK_STR: doStrSort( cmd, info ); break; case DDEMENU_TRK_CONV: doConvSort( cmd, info ); break; case DDEMENU_TRK_LINK: doLinkSort( cmd, info ); break; case DDEMENU_TRK_SERVER: doServerSort( cmd, info ); break; } break; case WM_CLOSE: DisplayTracking( info->type ); break; case WM_DESTROY: ptr = info->data; for( i = 0; i < info->cnt; i++ ) { MemFree( ptr[i] ); } if( ptr != NULL ) { MemFree( ptr ); } if( info->hdr != NULL ) { MemFree( info->hdr ); } MemFree( info ); break; default: return( DefWindowProc( hwnd, msg, wparam, lparam ) ); } return( TRUE ); } /* DDETrackingWndProc */
/* * ProcessIncomingMessage - get a string associated with a message id */ void ProcessIncomingMessage( UINT msgid, char *class_name, char *res ) { message *msg; const char *fmtstr; char buf[256]; char hexstr[20]; res[0] = '\0'; msg = GetMessageDataFromID( msgid, class_name ); if( msg != NULL ) { if( msg->watch ) { strcpy( res, msg->str ); } if( msg->stopon ) { SetSpyState( OFF ); RCsprintf( buf, STR_SPYING_STOPPED, msg->str ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } msg->count++; } else if( msgid >= WM_USER && msgid < WM_APP ) { userMsg->count++; if( userMsg->watch ) { fmtstr = GetRCString( STR_WM_USER_PLUS ); sprintf( res, fmtstr, msgid - WM_USER ); } if( userMsg->stopon ) { SetSpyState( OFF ); fmtstr = GetRCString( STR_WM_USER_PLUS ); sprintf( res, fmtstr, msgid - WM_USER ); RCsprintf( buf, STR_SPYING_STOPPED, res ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } } else if( msgid >= WM_APP && msgid < 0xC000 ) { appMsg->count++; if( appMsg->watch ) { fmtstr = GetRCString( STR_WM_APP_PLUS ); sprintf( res, fmtstr, msgid - WM_APP ); } if( appMsg->stopon ) { SetSpyState( OFF ); fmtstr = GetRCString( STR_WM_APP_PLUS ); sprintf( res, fmtstr, msgid - WM_APP ); RCsprintf( buf, STR_SPYING_STOPPED, res ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } } else { if( Filters[MC_UNKNOWN].watch ) { GetHexStr( hexstr, msgid, 0 ); fmtstr = GetRCString( STR_UNKNOWN_MSG ); sprintf( res, fmtstr, hexstr ); } if( Filters[MC_UNKNOWN].stopon ) { SetSpyState( OFF ); GetHexStr( hexstr, msgid, 0 ); fmtstr = GetRCString( STR_UNKNOWN_MSG ); sprintf( res, fmtstr, hexstr ); RCsprintf( buf, STR_SPYING_STOPPED, res ); MessageBox( SpyMainWindow, buf, SpyName, MB_OK | MB_ICONINFORMATION ); } } } /* ProcessIncomingMessage */
BOOL WINAPI LSLog(int nLevel, LPCSTR pszModule, LPCSTR pszMessage) { #if defined(LS_COMPAT_LOGGING) char szLogFile[MAX_PATH] = { 0 }; int nLogLevel = GetRCInt("LSLogLevel", 2); // Should this message be logged? if (!pszModule || !pszMessage || (nLevel > nLogLevel) || (nLevel < 1) || (nLevel > 4)) { return FALSE; } // Has a log file been assigned? if (!GetRCString("LSLogFile", szLogFile, NULL, MAX_PATH)) { return FALSE; } // If so, open it HANDLE hLogFile = CreateFile(szLogFile, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); // Did open succeed? if (hLogFile == INVALID_HANDLE_VALUE) { return FALSE; } // Move to the end of the file SetFilePointer(hLogFile, 0, NULL, FILE_END); // Get timestamp SYSTEMTIME st = { 0 }; GetLocalTime(&st); // Add timestamp and module name to message LPCSTR rszLevel[4] = { "Error", "Warning", "Notice", "Debug" }; TCHAR szLine[MAX_LINE_LENGTH] = { 0 }; size_t cbLine = sizeof(szLine); size_t cbRemaining = 0; if (SUCCEEDED(StringCbPrintfEx(szLine, cbLine, NULL, &cbRemaining, STRSAFE_IGNORE_NULLS, "%02d-%02d-%04d %02d:%02d:%02d - %s - %s: %s\r\n", st.wMonth, st.wDay, st.wYear, st.wHour, st.wMinute, st.wSecond, rszLevel[nLevel-1], pszModule, pszMessage))) { size_t cbToWrite = cbLine - cbRemaining; ASSERT(cbToWrite <= MAXDWORD); // Write it to the log file DWORD dwCount = 0; WriteFile(hLogFile, szLine, (DWORD)cbToWrite, &dwCount, NULL); } // Close the log CloseHandle(hLogFile); #endif // LS_COMPAT_LOGGING return TRUE; }
void Label::ReadConfig() { // Background and Borders TCHAR backgroundImageFile[MAX_PATH]; mBackgroundColor = GetRCColor(mName, "BackgroundColor", RGB(255, 255, 255)); GetRCString(mName, "BackgroundImage", backgroundImageFile, NULL, MAX_PATH); mBackgroundImage = LoadLSImage(backgroundImageFile, NULL); mBackgroundImageBorderTop = GetRCInt(mName, "BackgroundImageBorderTop", 0); mBackgroundImageBorderRight = GetRCInt(mName, "BackgroundImageBorderRight", 0); mBackgroundImageBorderBottom = GetRCInt(mName, "BackgroundImageBorderBottom", 0); mBackgroundImageBorderLeft = GetRCInt(mName, "BackgroundImageBorderLeft", 0); mBackgroundImageTile = GetRCEnum(mName, "BackgroundImageTile", gBackgroundImageTileEnum); mBorderColorTop = GetRCColor(mName, "BorderColorTop", RGB(0, 0, 0)); mBorderColorRight = GetRCColor(mName, "BorderColorRight", RGB(0, 0, 0)); mBorderColorBottom = GetRCColor(mName, "BorderColorBottom", RGB(0, 0, 0)); mBorderColorLeft = GetRCColor(mName, "BorderColorLeft", RGB(0, 0, 0)); mBorderTop = GetRCInt(mName, "BorderTop", 0); mBorderRight = GetRCInt(mName, "BorderRight", 0); mBorderBottom = GetRCInt(mName, "BorderBottom", 0); mBorderLeft = GetRCInt(mName, "BorderLeft", 0); // Font TCHAR fontName[LF_FACESIZE]; int fontHeight; bool fontBold; bool fontItalic; bool fontUnderline; GetRCString(mName, "Font", fontName, "Arial", LF_FACESIZE); fontHeight = GetRCInt(mName, "FontHeight", 15); fontBold = GetRCBoolDef(mName, "FontBold", FALSE); fontItalic = GetRCBoolDef(mName, "FontItalic", FALSE); fontUnderline = GetRCBoolDef(mName, "FontUnderline", FALSE); mFont = CreateSimpleFont(fontName, fontHeight, fontBold, fontItalic, fontUnderline); mFontColor = GetRCColor(mName, "FontColor", RGB(0, 0, 0)); mFontShadow = GetRCBoolDef(mName, "FontShadow", FALSE); mFontShadowColor = GetRCColor(mName, "FontShadowColor", RGB(128, 128, 128)); mFontShadowOffsetX = GetRCInt(mName, "FontShadowOffsetX", 1); mFontShadowOffsetY = GetRCInt(mName, "FontShadowOffsetY", 1); // Layout mAlign = GetRCEnum(mName, "Align", gAlignEnum); mImagePosition = GetRCEnum(mName, "ImagePosition", gImagePositionEnum); mImageTextGap = GetRCInt(mName, "ImageTextGap", 4); mPaddingLeft = GetRCInt(mName, "PaddingLeft", 0); mPaddingTop = GetRCInt(mName, "PaddingTop", 0); mPaddingRight = GetRCInt(mName, "PaddingRight", 0); mPaddingBottom = GetRCInt(mName, "PaddingBottom", 0); mVerticalAlign = GetRCEnum(mName, "VerticalAlign", gVerticalAlignEnum); // Content TCHAR imageFile[MAX_PATH]; GetRCString(mName, "Image", imageFile, NULL, MAX_PATH); mImage = LoadLSImage(imageFile, NULL); GetRCString(mName, "Text", mText, NULL, MAX_TEXT); // Position and Size mAlwaysOnTop = GetRCBoolDef(mName, "AlwaysOnTop", FALSE); mVisible = !GetRCBoolDef(mName, "StartHidden", FALSE); mX = GetRCInt(mName, "X", 0); mY = GetRCInt(mName, "Y", 0); mWidth = GetRCInt(mName, "Width", 64); mHeight = GetRCInt(mName, "Height", 64); }
/* * SetDisplayType - changes the heap display type to 'type' unless type is * 'HEAPMENU_DISPLAY_INIT' in which case this is assumed to * be the first call to SetDisplayType and the heap display * type is set to 'HeapType' */ static void SetDisplayType( HWND hwnd, HWND **title, WORD type ) { HMENU mh; char buf[256]; char *typename; if( type == HeapType ) return; if( type == HEAPMENU_DISPLAY_DPMI && !WDebug386 ) { RCMessageBox( HeapWalkMainWindow, STR_INSTALL_WDEBUG, HeapWalkName, MB_OK | MB_ICONEXCLAMATION ); return; } mh = GetMenu( hwnd ); if( type == HEAPMENU_DISPLAY_INIT ) { type = HeapType; HeapType = HEAPMENU_DISPLAY_INIT; } else { CheckMenuItem( mh, HeapType, MF_UNCHECKED | MF_BYCOMMAND ); } /* undo anything done for the previous state */ switch( HeapType ) { case HEAPMENU_DISPLAY_DPMI: EnableMenuItem( mh, HEAPMENU_ADD, MF_BYCOMMAND | MF_ENABLED ); EnableMenuItem( mh, HEAPMENU_OBJECT_DISCARD, MF_BYCOMMAND | MF_ENABLED ); EnableMenuItem( mh, HEAPMENU_OBJECT_OLDEST, MF_BYCOMMAND | MF_ENABLED ); EnableMenuItem( mh, HEAPMENU_OBJECT_NEWEST, MF_BYCOMMAND | MF_ENABLED ); EnableMenuItem( mh, HEAPMENU_LOCAL_LOCALWALK, MF_BYCOMMAND | MF_ENABLED ); EnableMenuItem( mh, HEAPMENU_COMPACT_AND_LOCALWALK, MF_BYCOMMAND | MF_ENABLED ); EnableMenuItem( mh, HEAPMENU_OBJECT_GET_SELECTOR, MF_BYCOMMAND | MF_ENABLED ); EnableMenuItem( mh, HEAPMENU_LOCAL_MONITOR, MF_BYCOMMAND | MF_ENABLED ); ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP, (UINT)LoadMenu( Instance, "SORTMENU" ), HWGetRCString( STR_SORT ) ); KillPushWin( *title ); *title = SetUpPushWindows( hwnd, HEAPMENU_DISPLAY_ENTIRE ); if( GSortType == HEAPMENU_SORT_GRAN || GSortType == HEAPMENU_SORT_DPL ) GSortType = HEAPMENU_SORT_HANDLE; break; case HEAPMENU_DISPLAY_LRU: DeleteMenu( mh, HEAPMENU_SORT_LRU, MF_BYCOMMAND ); if( GSortType == HEAPMENU_SORT_LRU ) GSortType = HEAPMENU_SORT_HANDLE; break; case HEAPMENU_DISPLAY_INIT: if( type != HEAPMENU_DISPLAY_DPMI ) { *title = SetUpPushWindows( hwnd, type ); ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP, (UINT)LoadMenu( Instance, "SORTMENU" ), HWGetRCString( STR_SORT ) ); } else { *title = NULL; } break; } /* do things for the new state */ switch( type ) { case HEAPMENU_DISPLAY_DPMI: ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP, (UINT)LoadMenu( Instance, "SORTDPMIMENU" ), HWGetRCString( STR_SORT ) ); EnableMenuItem( mh, HEAPMENU_ADD, MF_BYCOMMAND | MF_GRAYED ); EnableMenuItem( mh, HEAPMENU_OBJECT_DISCARD, MF_BYCOMMAND | MF_GRAYED ); EnableMenuItem( mh, HEAPMENU_OBJECT_OLDEST, MF_BYCOMMAND | MF_GRAYED ); EnableMenuItem( mh, HEAPMENU_OBJECT_NEWEST, MF_BYCOMMAND | MF_GRAYED ); EnableMenuItem( mh, HEAPMENU_LOCAL_LOCALWALK, MF_BYCOMMAND | MF_GRAYED ); EnableMenuItem( mh, HEAPMENU_COMPACT_AND_LOCALWALK, MF_BYCOMMAND | MF_GRAYED ); EnableMenuItem( mh, HEAPMENU_OBJECT_GET_SELECTOR, MF_BYCOMMAND | MF_GRAYED ); EnableMenuItem( mh, HEAPMENU_LOCAL_MONITOR, MF_BYCOMMAND | MF_GRAYED ); if( GSortType == HEAPMENU_SORT_MODULE || GSortType == HEAPMENU_SORT_TYPE ) { CheckMenuItem( mh, GSortType, MF_UNCHECKED | MF_BYCOMMAND ); GSortType = HEAPMENU_SORT_ADDR; } // SetTitle( HeapDPMITitles, title ); KillPushWin( *title ); *title = SetUpPushWindows( hwnd, type ); typename = HWAllocRCString( STR_SELECTOR_LIST_ITEMS ); break; case HEAPMENU_DISPLAY_LRU: InsertMenu( mh, HEAPMENU_SORT_FLAG, MF_BYCOMMAND, HEAPMENU_SORT_LRU, GetRCString( STR_BY_AGE ) ); typename = HWAllocRCString( STR_LRU_ITEMS ); break; case HEAPMENU_DISPLAY_ENTIRE: typename = HWAllocRCString( STR_ENTIRE_HEAP ); break; case HEAPMENU_DISPLAY_FREE: typename = HWAllocRCString( STR_FREE_ITEMS ); break; default: typename = ""; break; } CheckMenuItem( mh, type, MF_CHECKED | MF_BYCOMMAND ); CheckMenuItem( mh, GSortType, MF_CHECKED | MF_BYCOMMAND ); DrawMenuBar( hwnd ); sprintf( buf, "%s - %s", HeapWalkName, typename ); HWFreeRCString( typename ); SetWindowText( hwnd, buf ); HeapType = type; } /* SetDisplayType */