diff --git a/Updater/auto-config-tools/GetSectionNamesFunc.nsh b/Updater/auto-config-tools/GetSectionNamesFunc.nsh new file mode 100644 index 0000000..18fe058 --- /dev/null +++ b/Updater/auto-config-tools/GetSectionNamesFunc.nsh @@ -0,0 +1,77 @@ +; Version 1.0 +; https://nsis.sourceforge.io/Get_all_section_names_of_INI_file + +!define GetSectionNames `!insertmacro GetSectionNamesCall` + +!macro GetSectionNamesCall _FILE _FUNC + Push $0 + Push `${_FILE}` + GetFunctionAddress $0 `${_FUNC}` + Push `$0` + Call GetSectionNames + Pop $0 +!macroend + +Function GetSectionNames + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + Push $5 + Push $8 + Push $9 + + System::Call *(&t1024)i.r2 + StrCpy $3 $2 + + System::Call "kernel32::GetPrivateProfileSectionNames(i, i, t)i (r3, 1024, r0).r4" + + enumok: + System::Call 'kernel32::lstrlen(t)i (i r3).r5' ; (t) is here to trigger A/W detection + StrCmp $5 '0' enumex + + System::Call '*$3(&t1024 .r9)' + + Push $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $8 + Call $1 + Pop $9 + Pop $8 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + StrCmp $9 'StopGetSectionNames' enumex + + enumnext: +!if "${NSIS_CHAR_SIZE}" > 1 + IntOp $5 $5 * ${NSIS_CHAR_SIZE} + IntOp $5 $5 + ${NSIS_CHAR_SIZE} +!else + IntOp $5 $5 + 1 +!endif + IntOp $3 $3 + $5 + goto enumok + + enumex: + System::Free $2 + + Pop $9 + Pop $8 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd diff --git a/Updater/auto-config-tools/auto-config-tools.exe b/Updater/auto-config-tools/auto-config-tools.exe new file mode 100644 index 0000000..39cfd34 Binary files /dev/null and b/Updater/auto-config-tools/auto-config-tools.exe differ diff --git a/Updater/auto-config-tools/auto-config-tools.nsi b/Updater/auto-config-tools/auto-config-tools.nsi new file mode 100644 index 0000000..1c4581e --- /dev/null +++ b/Updater/auto-config-tools/auto-config-tools.nsi @@ -0,0 +1,63 @@ +; general options +name "auto-config-tools" +Icon "favicon.ico" +SilentInstall silent +OutFile "auto-config-tools.exe" +RequestExecutionLevel user +SetCompressor /SOLID lzma +CRCCheck on + +!include FileFunc.nsh +!include LogicLib.nsh +!include GetSectionNamesFunc.nsh + +var RAW_PARAMS +var CONFIG_PATH +var UPDATE_FOLDER_PATH + +; exe info +VIProductVersion "1.0.0.0" +VIAddVersionKey /LANG=1033 "ProductName" "auto-config-tools" +VIAddVersionKey /LANG=1033 "FileDescription" "Indetectables Toolkit updater auto config tools.ini" +VIAddVersionKey /LANG=1033 "FileVersion" "1.0.0.0" +VIAddVersionKey /LANG=1033 "LegalCopyright" "2022" + +Function .onInit + ; read exe params + ${GetParameters} $RAW_PARAMS + ${GetOptions} $RAW_PARAMS "/FOLDER=" $UPDATE_FOLDER_PATH + + ; error control + ${If} $UPDATE_FOLDER_PATH == "" + MessageBox MB_ICONEXCLAMATION "Missing default params:$\r \ + /FOLDER=updater_folder_path" + Abort + ${EndIf} + + StrCpy $CONFIG_PATH "$UPDATE_FOLDER_PATH\tools.ini" + IfFileExists "$CONFIG_PATH" +3 0 + MessageBox MB_ICONEXCLAMATION "Config file read error!" + Abort +FunctionEnd + +; script +Section "" + ; debug + ;MessageBox MB_OK "$CONFIG_PATH" + + ${GetSectionNames} "$CONFIG_PATH" "ReadSectionCallback" +SectionEnd + +Function ReadSectionCallback + ; analyze all except the updater config + ${If} $9 != "Updater" + ReadINIStr $0 "$CONFIG_PATH" "$9" folder + ;MessageBox MB_OK "$0" + + IfFileExists "$UPDATE_FOLDER_PATH\$0" +2 0 + DeleteINISec "$CONFIG_PATH" "$9" + ${EndIf} + + ; move on to the next + Push $0 +FunctionEnd diff --git a/Updater/auto-config-tools/favicon.ico b/Updater/auto-config-tools/favicon.ico new file mode 100644 index 0000000..cc537ce Binary files /dev/null and b/Updater/auto-config-tools/favicon.ico differ