Skip to content

Commit

Permalink
Memory leaks repaired
Browse files Browse the repository at this point in the history
Some gui changes
more configuration possibilities
  • Loading branch information
skydive241 committed Mar 6, 2021
1 parent 1cc45ce commit b20c930
Show file tree
Hide file tree
Showing 18 changed files with 657 additions and 304 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,5 @@ ASALocalRun/
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb
healthchecksdb
/build/out/build/x64-Debug (Standard)
10 changes: 5 additions & 5 deletions language.ini
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Translator=Patrick (skydive241@gmx.de)
77=(*) Delete shot files
78=Default actions
79=Automatic compare
80=Don't log registry data
80=Don't log registry value data in these log formats
81=Log with old "unl order"
82=Open result in default editor
83=(*) Not saved to ini
Expand Down Expand Up @@ -125,11 +125,11 @@ Icon=german.bmp
25=Fehler beim Erstellen von Datei!
26=Fehler beim Öffnen von Dateien!
27=Fehler beim Verschieben von Dateizeiger!
28=&1. Schuss
29=&2. Schuss
28=1. Schuss
29=2. Schuss
30=&Vergleichen
31=&Leeren
32=&Beenden
32=&Ende
33=Übe&r...
34=Über&wachen..
35=Speichern Vergleichslogdatei als:
Expand Down Expand Up @@ -177,7 +177,7 @@ Icon=german.bmp
77=(*) Shotdateien löschen
78=Standardaktionen starten
79=Vergleich sofort starten
80=Registryinhalt nicht loggen
80=Registryinhalt bei diesen Formaten nicht loggen
81=Alte "unl"-Log-Reihenfolge
82=Standardeditor starten
83=(*) wird nicht gespeichert
Expand Down
35 changes: 26 additions & 9 deletions regshot.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[Setup]
Title=Regshot
Language=Deutsch
Flag=0
Flag=4
;ExtDir=C:\;D:\
NoFiltersWhenLoading=1
DontDisplayInfoAfterShot=1
Expand All @@ -25,6 +25,9 @@ BaseDir=\\vmware-host\Shared Folders\Downloads\Test\bin\VS2010\Regshot\x64\Debug
OnlyNewVals=0
Editor=C:\Temp\cuda\cudatext.exe
ShowSIDFilterRules=1
ExpandLevels=4
MaxNodes=999
MaxLines=5000

[Registry-Scan]
HKEY_LOCAL_MACHINE=0
Expand All @@ -35,10 +38,10 @@ HKEY_CURRENT_USER=1
OpenEditor=1
BATFile=0
UNLFile=1
HTMLFile=0
HTMFile=0
TXTFile=0
ISSDeinstallFile=0
ISSInstallFile=1
ISSInstallFile=0
NSIDeinstallFile=0
NSIInstallFile=0
RegDeinstallFile=0
Expand All @@ -54,8 +57,9 @@ LogUNLOrder=0
Codepage=65001
UseLongRegHead=0
OutSeparateObjs=0
OutMaxResultLines=50
CheckResult=1
OutMaxResultLines=100
CheckResult=0
SuppressLogs=1

[REG-COMMENT]
; --------------------------------------------------------------------------------------------------------------
Expand All @@ -82,7 +86,7 @@ ISSEditor=C:\Temp\Inno Setup 6\Compil32.exe
[NSI]
UseDifferentNSIOutputFolder=0
NSIOutputFolder=C:\Temp\Output
UseDifferentNSIEditor=0
UseDifferentNSIEditor=1
NSIEditor=C:\Temp\nsis-3.06.1-setup\makensisw.exe

[UNL-COMMENT]
Expand Down Expand Up @@ -135,6 +139,18 @@ HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer=1
HKCU\SOFTWARE\Classes\Local Settings\MuiCache=1
HKU\S-1-5-21-1360566374-1955924393-1205199517-1001_Classes=1
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer2=1
HKLM\COMPONENTS\DerivedData\Components=1
HKLM\SYSTEM\CurrentControlSet=1
HKLM\SYSTEM\CurrentControlSet\Services=1
HKLM\COMPONENTS\DerivedData=1
HKLM\SYSTEM\DriverDatabase=1
HKLM\COMPONENTS\CanonicalData=1
HKLM\Schema=1
HKLM\COMPONENTS\Drivers=1
HKU\S-1-5-80-3017052307-2994996872-1615411526-3164924635-3391446484_Classes=1
HKU\S-1-5-80-3017052307-2994996872-1615411526-3164924635-3391446484=1
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18=1
HKLM\SYSTEM\ResourcePolicyStore\ResourceSets\Policies=1

[SkipRegKey.test]
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib=1
Expand All @@ -148,10 +164,12 @@ HKCU\Software\Classes\VirtualStore=1
[SkipDir]
%ProgramFiles%=0
%ProgramFiles% (x86)=0
%ALLUSERSPROFILE%=0
; wird als Users\AllUsers protokolliert:
%ALLUSERSPROFILE%=1
%SystemRoot%\winsxs=0
%SystemDrive%\msdownld.tmp=1
%SystemDrive%\System=1
%SystemDrive%\temp=1
%SystemDrive%\msdownld.tmp=1
%USERPROFILE%\MicrosoftEdgeBackups=1
%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5=1
%APPDATA%\Microsoft\Windows\Recent=1
Expand All @@ -176,7 +194,6 @@ HKCU\Software\Classes\VirtualStore=1
%ALLUSERSPROFILE%\Microsoft\Windows Defender\Scans=1
%SystemDrive%\Users\All Users\Microsoft\Windows Defender\Scans\History=1
%SystemRoot%\Logs\WindowsUpdate=1
%SystemDrive%\System=1

[SkipFile-Comment]
; --------------------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions regshot_vs2010.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<EnableASAN>false</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Unicode Console|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
Expand Down
67 changes: 51 additions & 16 deletions src/CreateOutputLines.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,44 +109,73 @@ LPTSTR lpszNSIDirDelete = TEXT(" RMDir ");
// ----------------------------------------------------------------------
// Several routines to write to an output file
// ----------------------------------------------------------------------
LPTSTR CorrectISSOutputString(LPTSTR lpszText)
LPTSTR ReplaceISSMacros(LPTSTR lpszText)
{
LPTSTR pos = NULL;
int i = 0;
// iss macro replacements

if (lpszText != NULL)
pos = _tcsstr(lpszText, TEXT("}break}"));
while (pos) {
_tcsncpy(pos, TEXT("{"), 1);
pos++;
pos = _tcsstr(lpszText, TEXT("}break}"));
}

return lpszText;
}

// ----------------------------------------------------------------------
// Several routines to write to an output file
// ----------------------------------------------------------------------
LPTSTR EscapeSpecialCharacters(LPTSTR lpszText, TCHAR c, LPTSTR lpEscape)
{
LPTSTR pos = NULL;
size_t i = 0;

if (lpszText != NULL)
pos = _tcschr(lpszText, _T('{'));
pos = _tcschr(lpszText, c);
while (pos) {
i++;
pos = _tcschr(++pos, _T('{'));
pos = _tcschr(++pos, c);
}

/*
if (i > 0) {
LPTSTR lpszOutputStringCorrected = MYALLOC0((_tcslen(lpszText) + i + 1) * sizeof(TCHAR));
i = 0;
for (int j = 0; j <= _tcslen(lpszText); j++) {
if (lpszOutputStringCorrected + j + i != NULL)
_tcsncpy(lpszOutputStringCorrected + j + i, lpszText + j, 1);
if (_tcsncmp(lpszText + j, _TEXT("{"), 1) == 0) {
if (_tcsncmp(lpszText + j, &c, 1) == 0) {
if (lpszOutputStringCorrected + j + i + 1 != NULL)
_tcsncpy(lpszOutputStringCorrected + j + i + 1, _TEXT("{"), 1);
_tcsncpy(lpszOutputStringCorrected + j + i + 1, &c, 1);
i++;
}
}
MYFREE(lpszText);
lpszText = lpszOutputStringCorrected;
}

// nsis macro replacements
if (lpszText != NULL)
pos = _tcsstr(lpszText, TEXT("}break}"));
while (pos) {
_tcsncpy(pos, TEXT("{"), 1);
pos++;
pos = _tcsstr(lpszText, TEXT("}break}"));
*/
if (i > 0) {
LPTSTR lpszOutputStringCorrected = MYALLOC0((_tcslen(lpszText) + i * _tcslen(lpEscape) + 1) * sizeof(TCHAR));

i = 0;
for (int j = 0; j <= _tcslen(lpszText); j++) {
if (lpszOutputStringCorrected + j + i != NULL) {
if (_tcsncmp(lpszText + j, &c, 1) == 0) {
_tcsncpy(lpszOutputStringCorrected + j + i, lpEscape, _tcslen(lpEscape));
i = i + _tcslen(lpEscape);
}
if (lpszOutputStringCorrected + j + i != NULL)
_tcsncpy(lpszOutputStringCorrected + j + i, lpszText + j, 1);
}
}
MYFREE(lpszText);
return lpszOutputStringCorrected;
}

return lpszText;
}

Expand Down Expand Up @@ -373,6 +402,8 @@ LPTSTR BuildISSOutputString(LPTSTR lpszText, LPVOID lpContent, int nActionType,
size_t cchStringLen = 1; // terminating \0
LPTSTR pos = NULL;

// TODO: ISS-String-Korrekturen
//lpszText = EscapeSpecialCharacters(lpszText, _T('{'), lpEscape);
if ((nActionType == VALADD) || (nActionType == VALDEL) || (nActionType == VALMODI)) {
pos = _tcschr(lpszText, _T('\\'));
if (pos != NULL)
Expand Down Expand Up @@ -590,7 +621,11 @@ LPTSTR BuildISSOutputString(LPTSTR lpszText, LPVOID lpContent, int nActionType,
MYFREE(lpszTempString);
}

lpszOutputString = CorrectISSOutputString(lpszOutputString);
// TODO: Escape ISS special characters:
// hier kommt der komplette String OHNE Value-Data an
// hier kann also nur max. die { ersetzt werden
lpszOutputString = EscapeSpecialCharacters(lpszOutputString, _T('{'), TEXT("{"));
// lpszOutputString = EscapeSpecialCharacters(lpszOutputString, _T('"'), TEXT("\""));

return lpszOutputString;
}
Expand Down
1 change: 1 addition & 0 deletions src/fileshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ VOID CompareFiles(LPFILECONTENT lpStartFC1, LPFILECONTENT lpStartFC2)
if (REFRESHINTERVAL < (nCurrentTime - nLastTime)) {
lpszUIBuffer = GetWholeFileName(lpFC1, 0, FALSE);
UI_UpdateCounters(asLangTexts[iszTextDir].lpszText, asLangTexts[iszTextFile].lpszText, CompareResult.stcCompared.cDirs, CompareResult.stcCompared.cFiles, asLangTexts[iszTextDir].lpszText, lpszUIBuffer);
MYFREE(lpszUIBuffer);
}
if (!bRunning)
break;
Expand Down
12 changes: 10 additions & 2 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,21 @@ extern BOOL bRunning;
extern BOOL fNoVals;
extern BOOL fOnlyNewEntries;
extern BOOL fLogEnvironmentStrings;
extern BOOL fSuppressLogs;
extern BOOL fLogUNLOrder;
extern BOOL fStoreOnQuit;
extern BOOL fStoreOnlyUncompared;
extern BOOL fSaveSettingsOnExit;
extern BOOL fNoFiltersWhenLoading;
extern BOOL fShowSIDFilterRules;
extern UINT nExpandLevels;
extern UINT nMaxNodes;
extern UINT nMaxLines;
extern BOOL fOpenEditor;
extern BOOL fOutputTXTfile;
extern BOOL fOutputUNLfile;
extern BOOL fOutputBATfile;
extern BOOL fOutputHTMfile;
extern BOOL fISSInstallFile;
extern BOOL fISSDeinstallFile;
extern BOOL fNSIInstallFile;
Expand Down Expand Up @@ -669,14 +676,15 @@ BOOL SearchTVDown(HWND hwndTV, HTREEITEM hItem, int iPropertyPage);
BOOL BuildSkipString(HWND hwndTV, HTREEITEM hItem, int iPropertyPage);
BOOL ResetAdhocFilters(VOID);
BOOL InsertRootItems(HWND hwndTV, int iPropertyPage);
HTREEITEM FindOrCreateTreeItem(HWND hwndTV, HTREEITEM hParent, HTREEITEM hItem, int nLevel, LPTSTR lpszNodeText, int iPropertyPage, BOOL bKey);
HTREEITEM FindOrCreateTreeItem(HWND hwndTV, HTREEITEM hParent, HTREEITEM hItem, UINT nLevel, LPTSTR lpszNodeText, int iPropertyPage, BOOL bKey, LPCOMPRESULTNEW lpCR);
BOOL InitTreeViewItems(HWND hwndTV, int iPropertyPage);
BOOL InitTreeViewImageLists(HWND hwndTV);
BOOL CheckFilters(LPVOID lpContent, LPTSTR lpszKeyName, LPTSTR* lpszValueName, DWORD nActionType, BOOL* pbKey);



LPTSTR CorrectISSOutputString(LPTSTR lpszText);
LPTSTR EscapeSpecialCharacters(LPTSTR lpszText, TCHAR c, LPTSTR lpEscape);
LPTSTR ReplaceISSMacros(LPTSTR lpszText);

VOID CreateNewResult(DWORD nActionType, LPVOID lpContentOld, LPVOID lpContentNew);
size_t ResultToString(LPTSTR rgszResultStrings[], size_t iResultStringsMac, size_t iLinesWrittenOldPart, DWORD nActionType, LPVOID lpContent, BOOL fNewContent, BOOL bSuppressKey, int iOutputType);
Expand Down
2 changes: 1 addition & 1 deletion src/language.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ VOID SetTextsToDefaultLanguage(VOID)
asLangTexts[iszTextCheckNoVals].nIDDlgItem = IDC_CHECK_NOVALS;
asLangTexts[iszTextCheckUNLOrder].lpszText = TEXT("Log with old \"unl order\"");
asLangTexts[iszTextCheckUNLOrder].nIDDialog = DLG_MAIN;
asLangTexts[iszTextCheckUNLOrder].nIDDlgItem = IDC_CHECK_UNLORDER;
asLangTexts[iszTextCheckUNLOrder].nIDDlgItem = IDC_CHECK_OPT_UNLORDER;
asLangTexts[iszTextCheckOpenEditor].lpszText = TEXT("Open result in default editor");
asLangTexts[iszTextCheckOpenEditor].nIDDialog = DLG_MAIN;
asLangTexts[iszTextCheckOpenEditor].nIDDlgItem = IDC_CHECK_OPENEDITOR;
Expand Down
53 changes: 52 additions & 1 deletion src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,36 @@ BOOL CALLBACK DlgOptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_NOFILTERS), BM_SETCHECK, fNoFiltersWhenLoading, (LPARAM)0);
SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_SIDFILTERS), BM_SETCHECK, fShowSIDFilterRules, (LPARAM)0);
SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_ENVIRONMENT), BM_SETCHECK, fLogEnvironmentStrings, (LPARAM)0);
SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_UNLORDER), BM_SETCHECK, fLogUNLOrder, (LPARAM)0);
SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_READONLY), BM_SETCHECK, fDeleteReadOnly, (LPARAM)0);
SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_NONEMPTY), BM_SETCHECK, fDeleteDirNotEmpty, (LPARAM)0);
SetDlgItemText(hDlg, IDC_COMMON_EDIT_EDITOR, lpszEditor);

LPTSTR strExpandLevels = MYALLOC0(4 * sizeof(TCHAR));
if (strExpandLevels != NULL) {
_sntprintf(strExpandLevels, 3, TEXT("%i"), nExpandLevels);
strExpandLevels[3] = _T('\0');
SetDlgItemText(hDlg, IDC_EDIT_EXPANDLEVELS, strExpandLevels);
MYFREE(strExpandLevels);
}
SendMessage(GetDlgItem(hDlg, IDC_SPIN_EXPANDLEVELS), UDM_SETRANGE, (WPARAM)0, (LPARAM)MAKELPARAM(9,0));
LPTSTR strMaxNodes = MYALLOC0(5 * sizeof(TCHAR));
if (strMaxNodes != NULL) {
_sntprintf(strMaxNodes, 4, TEXT("%i"), nMaxNodes);
strMaxNodes[4] = _T('\0');
SetDlgItemText(hDlg, IDC_EDIT_MAXNODES, strMaxNodes);
MYFREE(strMaxNodes);
}
SendMessage(GetDlgItem(hDlg, IDC_SPIN_MAXNODES), UDM_SETRANGE, (WPARAM)0, (LPARAM)MAKELPARAM(9999,0));

LPTSTR strMaxLines = MYALLOC0(6 * sizeof(TCHAR));
if (strMaxLines != NULL) {
_sntprintf(strMaxLines, 5, TEXT("%i"), nMaxLines);
strMaxLines[5] = _T('\0');
SetDlgItemText(hDlg, IDC_EDIT_MAXLINES, strMaxLines);
MYFREE(strMaxLines);
}
SendMessage(GetDlgItem(hDlg, IDC_SPIN_MAXLINES), UDM_SETRANGE32, (WPARAM)5000, (LPARAM)99999);
// SendMessage(GetDlgItem(hDlg, IDC_SPIN_MAXLINES), UDM_SETRANGE, (WPARAM)0, (LPARAM)MAKELPARAM(30000, 1000));
FillComboboxWithLanguagesFromIni(hDlg);
}
else if (iIndex == PROP_COMMON_2) {
Expand Down Expand Up @@ -731,9 +757,34 @@ BOOL CALLBACK DlgOptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
fNoFiltersWhenLoading = (BOOL)SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_NOFILTERS), BM_GETCHECK, (WPARAM)0, (LPARAM)0);
fShowSIDFilterRules = (BOOL)SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_SIDFILTERS), BM_GETCHECK, (WPARAM)0, (LPARAM)0);
fLogEnvironmentStrings = (BOOL)SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_ENVIRONMENT), BM_GETCHECK, (WPARAM)0, (LPARAM)0);
fLogUNLOrder = (BOOL)SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_UNLORDER), BM_GETCHECK, (WPARAM)0, (LPARAM)0);
fDeleteReadOnly = (BOOL)SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_READONLY), BM_GETCHECK, (WPARAM)0, (LPARAM)0);
fDeleteDirNotEmpty = (BOOL)SendMessage(GetDlgItem(hDlg, IDC_CHECK_OPT_NONEMPTY), BM_GETCHECK, (WPARAM)0, (LPARAM)0);
GetDlgItemText(hDlg, IDC_COMMON_EDIT_EDITOR, lpszEditor, MAX_PATH); // length incl. NULL character
LPTSTR lpszValue = MYALLOC0(8 * sizeof(TCHAR));
if (lpszValue != NULL) {
GetDlgItemText(hDlg, IDC_EDIT_EXPANDLEVELS, lpszValue, 4);
lpszValue[4] = (TCHAR)'\0';
nExpandLevels = _tstoi(lpszValue);
}
if (lpszValue != NULL) {
GetDlgItemText(hDlg, IDC_EDIT_MAXNODES, lpszValue, 5);
lpszValue[5] = (TCHAR)'\0';
nMaxNodes = _tstoi(lpszValue);
if ((0 >= nMaxNodes) || (nMaxNodes > 9999)) {
nMaxNodes = 9999;
}
}
if (lpszValue != NULL) {
GetDlgItemText(hDlg, IDC_EDIT_MAXLINES, lpszValue, 7);
lpszValue[7] = (TCHAR)'\0';
nMaxLines = _tstoi(lpszValue);
if ((0 >= nMaxLines) || (nMaxLines > 99999)) {
nMaxNodes = 99999;
}
}
MYFREE(lpszValue);


WritePrivateProfileString(lpszIniSetup, lpszIniLanguage, lpszLanguage, lpszRegshotIni);

Expand Down
6 changes: 5 additions & 1 deletion src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,12 @@ VOID WriteNSISetupKeys(HANDLE hFile, BOOL bInstall)
_tcscat(_Notnull_ lpszBuffer, lpszCRLF);
WriteFileCP(hFile, nCodePage, lpszBuffer, (DWORD)(_tcslen(lpszBuffer) * sizeof(TCHAR)), &NBW, NULL);

//OutFile "C:\Temp\Example2.exe"
_tcscpy(lpszBuffer, TEXT("OutFile \""));
if (fUseDifferentNSIOutputFolder) {
_tcscat(lpszBuffer, lpszNSIOutputFolder);
if (_tcsrchr(lpszBuffer, _T('\\')) != lpszBuffer + _tcslen(lpszBuffer) - 1)
_tcscat(_Notnull_ lpszBuffer, TEXT("\\"));
}
_tcscat(_Notnull_ lpszBuffer, lpszTitle);
if (bInstall)
_tcscat(lpszBuffer, TEXT("-installer.exe"));
Expand Down
Loading

0 comments on commit b20c930

Please sign in to comment.