From dd1a2db2e3bb2846fb6461b99e9ae2b86be11ed2 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:57:13 +0200 Subject: [PATCH] Updates to the Installer (#51) --- .github/workflows/windows-web.yml | 2 +- windows/web/plugins/NsProcess/ConvFunc.h | 825 ++++++++++++++++++ windows/web/plugins/NsProcess/Readme.txt | 67 ++ windows/web/plugins/NsProcess/api.h | 83 ++ windows/web/plugins/NsProcess/nsProcess.c | 416 +++++++++ windows/web/plugins/NsProcess/nsProcess.nsh | 28 + windows/web/plugins/NsProcess/nsProcess.sln | 23 + .../web/plugins/NsProcess/nsProcess.vcproj | 372 ++++++++ .../web/plugins/NsProcess/nsProcessTest.nsi | 69 ++ windows/web/plugins/NsProcess/nsis_tchar.h | 214 +++++ windows/web/plugins/NsProcess/pluginapi.c | 290 ++++++ windows/web/plugins/NsProcess/pluginapi.h | 101 +++ .../plugins/NsProcess/x86-ansi/nsProcess.dll | Bin 0 -> 4608 bytes .../NsProcess/x86-unicode/nsProcess.dll | Bin 0 -> 4608 bytes windows/web/slimevr_web_installer.nsi | 219 ++++- windows/web/steamdetect.nsh | 85 ++ 16 files changed, 2746 insertions(+), 48 deletions(-) create mode 100644 windows/web/plugins/NsProcess/ConvFunc.h create mode 100644 windows/web/plugins/NsProcess/Readme.txt create mode 100644 windows/web/plugins/NsProcess/api.h create mode 100644 windows/web/plugins/NsProcess/nsProcess.c create mode 100644 windows/web/plugins/NsProcess/nsProcess.nsh create mode 100644 windows/web/plugins/NsProcess/nsProcess.sln create mode 100644 windows/web/plugins/NsProcess/nsProcess.vcproj create mode 100644 windows/web/plugins/NsProcess/nsProcessTest.nsi create mode 100644 windows/web/plugins/NsProcess/nsis_tchar.h create mode 100644 windows/web/plugins/NsProcess/pluginapi.c create mode 100644 windows/web/plugins/NsProcess/pluginapi.h create mode 100644 windows/web/plugins/NsProcess/x86-ansi/nsProcess.dll create mode 100644 windows/web/plugins/NsProcess/x86-unicode/nsProcess.dll create mode 100644 windows/web/steamdetect.nsh diff --git a/.github/workflows/windows-web.yml b/.github/workflows/windows-web.yml index 7c7a608..afd9939 100644 --- a/.github/workflows/windows-web.yml +++ b/.github/workflows/windows-web.yml @@ -23,7 +23,7 @@ jobs: shell: bash - name: Create NSIS installer - uses: joncloud/makensis-action@v3.6 + uses: joncloud/makensis-action@v4 with: script-file: ${{ env.WINDOWS_WEB_DIR }}/slimevr_web_installer.nsi additional-plugin-paths: ${{ env.PLUGINS_DIR }} diff --git a/windows/web/plugins/NsProcess/ConvFunc.h b/windows/web/plugins/NsProcess/ConvFunc.h new file mode 100644 index 0000000..739737b --- /dev/null +++ b/windows/web/plugins/NsProcess/ConvFunc.h @@ -0,0 +1,825 @@ +/***************************************************************** + * Conversion functions header v1.9 * + * * + * 2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) * + * * + * * + *Functions (ALLCONVFUNC): * + * xatoi, xatoiW, xitoa, xitoaW, xatoui, xatouiW, * + * xuitoa, xuitoaW, xatoi64, xatoi64W, xi64toa, xi64toaW, * + * hex2dec, hex2decW, dec2hex, dec2hexW * + * * + *Special functions (ALLCONVFUNCS): * + * str2hex, hex2str * + * * + *****************************************************************/ + +#ifndef _CONVFUNC_ +#define _CONVFUNC_ + +int xatoi(char *str); +int xatoiW(wchar_t *wstr); +char* xitoa(int number, char *str, int width); +wchar_t* xitoaW(int number, wchar_t *wstr, int width); +unsigned int xatoui(char *str); +unsigned int xatouiW(wchar_t *wstr); +char* xuitoa(unsigned int number, char *str, int width); +wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width); +__int64 xatoi64(char *str); +__int64 xatoi64W(wchar_t *wstr); +char* xi64toa(__int64 number, char *str, int width); +wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width); +int hex2dec(char *hex); +int hex2decW(wchar_t *whex); +void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width); +void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int width); + +void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes); +void hex2str(char *hex, char *str); + +#endif + +/******************************************************************** + * + * xatoi + * + *Converts string to int. + * + *[in] char *str -string number + * + *Returns: integer + * + *Examples: + * xatoi("45") == 45; + * xatoi(" -0045:value") == -45; + ********************************************************************/ +#if defined xatoi || defined ALLCONVFUNC +#define xatoi_INCLUDED +#undef xatoi +int xatoi(char *str) +{ + int nNumber=0; + BOOL bMinus=FALSE; + + while (*str == ' ') + ++str; + if (*str == '+') + ++str; + else if (*str == '-') + { + bMinus=TRUE; + ++str; + } + for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) + nNumber=(nNumber * 10) + (*str - '0'); + if (bMinus == TRUE) + nNumber=0 - nNumber; + return nNumber; +} +#endif + +/******************************************************************** + * + * xatoiW + * + *Converts unicode string to int. + * + *[in] wchar_t *wstr -string number + * + *Returns: integer + * + *Examples: + * xatoiW(L"45") == 45; + * xatoiW(L" -0045:value") == -45; + ********************************************************************/ +#if defined xatoiW || defined ALLCONVFUNC +#define xatoiW_INCLUDED +#undef xatoiW +int xatoiW(wchar_t *wstr) +{ + int nNumber=0; + BOOL bMinus=FALSE; + + while (*wstr == ' ') + ++wstr; + if (*wstr == '+') + ++wstr; + else if (*wstr == '-') + { + bMinus=TRUE; + ++wstr; + } + for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) + nNumber=(nNumber * 10) + (*wstr - '0'); + if (bMinus == TRUE) + nNumber=0 - nNumber; + return nNumber; +} +#endif + +/******************************************************************** + * + * xitoa [API: wsprintf(szResult, "%d", 45)] + * + *Converts int to string. + * + *[in] int number -integer + *[out] char *str -string number + *[in] int width -minimum number of characters to the output + * + *Returns: a pointer to string + * + *Examples: + * xitoa(45, szResult, 0); //szResult == "45" + * xitoa(-45, szResult, 0); //szResult == "-45" + * xitoa(45, szResult, 4); //szResult == "0045" + ********************************************************************/ +#if defined xitoa || defined ALLCONVFUNC +#define xitoa_INCLUDED +#undef xitoa +char* xitoa(int number, char *str, int width) +{ + char tmp[128]; + int a=0; + int b=0; + *tmp = 0; + + if (number == 0) + { + str[0]='0'; + --width; + b=1; + } + else if (number < 0) + { + str[0]='-'; + number=0 - number; + --width; + b=1; + } + for (tmp[a]='\0'; number != 0; ++a) + { + tmp[a]=(number % 10) + '0'; + number=number / 10; + } + if (a < width) + do + { + tmp[a]='0'; + } while (++a= 0; --a, ++b) str[b]=tmp[a]; + + str[b]='\0'; + return str; +} +#endif + +/******************************************************************** + * + * xitoaW [API: wsprintfW(wszResult, L"%d", 45)] + * + *Converts int to unicode string. + * + *[in] int number -integer + *[out] wchar_t *wstr -unicode string number + *[in] int width -minimum number of characters to the output + * + *Returns: a pointer to unicode string + * + *Examples: + * xitoaW(45, wszResult, 0); //wszResult == L"45" + * xitoaW(-45, wszResult, 0); //wszResult == L"-45" + * xitoaW(45, wszResult, 4); //wszResult == L"0045" + ********************************************************************/ +#if defined xitoaW || defined ALLCONVFUNC +#define xitoaW_INCLUDED +#undef xitoaW +wchar_t* xitoaW(int number, wchar_t *wstr, int width) +{ + wchar_t wtmp[128]=L""; + int a=0; + int b=0; + + if (number == 0) + { + wstr[0]='0'; + --width; + b=1; + } + else if (number < 0) + { + wstr[0]='-'; + number=0 - number; + --width; + b=1; + } + for (wtmp[a]='\0'; number != 0; ++a) + { + wtmp[a]=(number % 10) + '0'; + number=number / 10; + } + for (; width > a; ++a) wtmp[a]='0'; + for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; + + wstr[b]='\0'; + return wstr; +} +#endif + +/******************************************************************** + * + * xatoui + * + *Converts string to unsigned int. + * + *[in] char *str -string number + * + *Returns: unsigned integer + * + *Examples: + * xatoui("45") == 45; + * xatoui(" -0045:value") == 0; + ********************************************************************/ +#if defined xatoui || defined ALLCONVFUNC +#define xatoui_INCLUDED +#undef xatoui +unsigned int xatoui(char *str) +{ + unsigned int nNumber=0; + + while (*str == ' ') + ++str; + if (*str == '+') + ++str; + else if (*str == '-') + return 0; + for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) + nNumber=(nNumber * 10) + (*str - '0'); + return nNumber; +} +#endif + +/******************************************************************** + * + * xatouiW + * + *Converts unicode string to unsigned int. + * + *[in] wchar_t *wstr -unicode string number + * + *Returns: unsigned integer + * + *Examples: + * xatouiW(L"45") == 45; + * xatouiW(L" -0045:value") == 0; + ********************************************************************/ +#if defined xatouiW || defined ALLCONVFUNC +#define xatouiW_INCLUDED +#undef xatouiW +unsigned int xatouiW(wchar_t *wstr) +{ + unsigned int nNumber=0; + + while (*wstr == ' ') + ++wstr; + if (*wstr == '+') + ++wstr; + else if (*wstr == '-') + return 0; + for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) + nNumber=(nNumber * 10) + (*wstr - '0'); + return nNumber; +} +#endif + +/******************************************************************** + * + * xuitoa + * + *Converts unsigned int to string. + * + *[in] unsigned int number -unsigned integer + *[out] char *str -string number + *[in] int width -minimum number of characters to the output + * + *Returns: a pointer to string + * + *Examples: + * xuitoa(45, szResult, 0); //szResult == "45" + * xuitoa(45, szResult, 4); //szResult == "0045" + ********************************************************************/ +#if defined xuitoa || defined ALLCONVFUNC +#define xuitoa_INCLUDED +#undef xuitoa +char* xuitoa(unsigned int number, char *str, int width) +{ + char tmp[128]=""; + int a=0; + int b=0; + + if (number == 0) + { + str[0]='0'; + --width; + b=1; + } + for (tmp[a]='\0'; number != 0; ++a) + { + tmp[a]=(number % 10) + '0'; + number=number / 10; + } + for (; width > a; ++a) tmp[a]='0'; + for (--a; a >= 0; --a, ++b) str[b]=tmp[a]; + + str[b]='\0'; + return str; +} +#endif + +/******************************************************************** + * + * xuitoaW + * + *Converts unsigned int to unicode string. + * + *[in] unsigned int number -unsigned integer + *[out] wchar_t *wstr -unicode string number + *[in] int width -minimum number of characters to the output + * + *Returns: a pointer to unicode string + * + *Examples: + * xuitoaW(45, wszResult, 0); //wszResult == L"45" + * xuitoaW(45, wszResult, 4); //wszResult == L"0045" + ********************************************************************/ +#if defined xuitoaW || defined ALLCONVFUNC +#define xuitoaW_INCLUDED +#undef xuitoaW +wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width) +{ + wchar_t wtmp[128]=L""; + int a=0; + int b=0; + + if (number == 0) + { + wstr[0]='0'; + --width; + b=1; + } + for (wtmp[a]='\0'; number != 0; ++a) + { + wtmp[a]=(number % 10) + '0'; + number=number / 10; + } + for (; width > a; ++a) wtmp[a]='0'; + for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; + + wstr[b]='\0'; + return wstr; +} +#endif + +/******************************************************************** + * + * xatoi64 + * + *Converts string to int64. + * + *[in] char *str -string number + * + *Returns: 64-bit integer + * + *Examples: + * xatoi64("45") == 45; + * xatoi64(" -0045:value") == -45; + ********************************************************************/ +#if defined xatoi64 || defined ALLCONVFUNC +#define xatoi64_INCLUDED +#undef xatoi64 +__int64 xatoi64(char *str) +{ + __int64 nNumber=0; + BOOL bMinus=FALSE; + + while (*str == ' ') + ++str; + if (*str == '+') + ++str; + else if (*str == '-') + { + bMinus=TRUE; + ++str; + } + for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) + nNumber=(nNumber * 10) + (*str - '0'); + if (bMinus == TRUE) + nNumber=0 - nNumber; + return nNumber; +} +#endif + +/******************************************************************** + * + * xatoi64W + * + *Converts unicode string to int64. + * + *[in] wchar_t *wstr -unicode string number + * + *Returns: 64-bit integer + * + *Examples: + * xatoi64W(L"45") == 45; + * xatoi64W(L" -0045:value") == -45; + ********************************************************************/ +#if defined xatoi64W || defined ALLCONVFUNC +#define xatoi64W_INCLUDED +#undef xatoi64W +__int64 xatoi64W(wchar_t *wstr) +{ + __int64 nNumber=0; + BOOL bMinus=FALSE; + + while (*wstr == ' ') + ++wstr; + if (*wstr == '+') + ++wstr; + else if (*wstr == '-') + { + bMinus=TRUE; + ++wstr; + } + for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) + nNumber=(nNumber * 10) + (*wstr - '0'); + if (bMinus == TRUE) + nNumber=0 - nNumber; + return nNumber; +} +#endif + +/******************************************************************** + * + * xitoa64 + * + *Converts int64 to string. + * + *[in] __int64 number -64-bit integer + *[out] char *str -string number + *[in] int width -minimum number of characters to the output + * + *Returns: a pointer to string + * + *Examples: + * xi64toa(45, szResult, 0); //szResult == "45" + * xi64toa(-45, szResult, 0); //szResult == "-45" + * xi64toa(45, szResult, 4); //szResult == "0045" + ********************************************************************/ +#if defined xi64toa || defined ALLCONVFUNC +#define xi64toa_INCLUDED +#undef xi64toa +char* xi64toa(__int64 number, char *str, int width) +{ + char tmp[128]=""; + int a=0; + int b=0; + + if (number == 0) + { + str[0]='0'; + --width; + b=1; + } + else if (number < 0) + { + str[0]='-'; + number=0 - number; + --width; + b=1; + } + for (tmp[a]='\0'; number != 0; ++a) + { + tmp[a]=(char)((number % 10) + '0'); + number=number / 10; + } + for (; width > a; ++a) tmp[a]='0'; + for (--a; a >= 0; --a, ++b) str[b]=tmp[a]; + + str[b]='\0'; + return str; +} +#endif + +/******************************************************************** + * + * xitoa64W + * + *Converts int64 to unicode string. + * + *[in] __int64 number -64-bit integer + *[out] wchar_t *wstr -unicode string number + *[in] int width -minimum number of characters to the output + * + *Returns: a pointer to unicode string + * + *Examples: + * xi64toaW(45, wszResult, 0); //wszResult == L"45" + * xi64toaW(-45, wszResult, 0); //wszResult == L"-45" + * xi64toaW(45, wszResult, 4); //wszResult == L"0045" + ********************************************************************/ +#if defined xi64toaW || defined ALLCONVFUNC +#define xi64toaW_INCLUDED +#undef xi64toaW +wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width) +{ + wchar_t wtmp[128]=L""; + int a=0; + int b=0; + + if (number == 0) + { + wstr[0]='0'; + --width; + b=1; + } + else if (number < 0) + { + wstr[0]='-'; + number=0 - number; + --width; + b=1; + } + for (wtmp[a]='\0'; number != 0; ++a) + { + wtmp[a]=(char)((number % 10) + '0'); + number=number / 10; + } + for (; width > a; ++a) wtmp[a]='0'; + for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; + + wstr[b]='\0'; + return wstr; +} +#endif + +/******************************************************************** + * + * hex2dec + * + *Converts hex value to decimal. + * + *[in] char *hex -hex value + * + *Returns: integer + * -1 wrong hex value + * + *Examples: + * hex2dec("A1F") == 2591; + ********************************************************************/ +#if defined hex2dec || defined ALLCONVFUNC +#define hex2dec_INCLUDED +#undef hex2dec +int hex2dec(char *hex) +{ + int a; + int b=0; + + while (1) + { + a=*hex++; + if (a >= '0' && a <= '9') a-='0'; + else if (a >= 'a' && a <= 'f') a-='a'-10; + else if (a >= 'A' && a <= 'F') a-='A'-10; + else return -1; + + if (*hex) b=(b + a) * 16; + else return (b + a); + } +} +#endif + +/******************************************************************** + * + * hex2decW + * + *Converts unicode hex value to decimal. + * + *[in] wchar_t *whex -unicode hex value + * + *Returns: integer + * -1 wrong hex value + * + *Examples: + * hex2decW(L"A1F") == 2591; + ********************************************************************/ +#if defined hex2decW || defined ALLCONVFUNC +#define hex2decW_INCLUDED +#undef hex2decW +int hex2decW(wchar_t *whex) +{ + int a; + int b=0; + + while (1) + { + a=*whex++; + if (a >= '0' && a <= '9') a-='0'; + else if (a >= 'a' && a <= 'f') a-='a'-10; + else if (a >= 'A' && a <= 'F') a-='A'-10; + else return -1; + + if (*whex) b=(b + a) * 16; + else return (b + a); + } +} +#endif + +/******************************************************************** + * + * dec2hex [API: wsprintf(szResult, "%02x", 2591)] + * + *Converts decimal to hex value. + * + *[in] unsigned int dec -positive integer + *[out] char *hex -hex value (output) + *[in] BOOL lowercase -if TRUE hexadecimal value in lowercase + * if FALSE in uppercase. + *[in] unsigned int width -minimum number of characters to the output + * + *Examples: + * dec2hex(2591, szResult, FALSE, 2); //szResult == "A1F" + * dec2hex(10, szResult, TRUE, 2); //szResult == "0a" + ********************************************************************/ +#if defined dec2hex || defined ALLCONVFUNC +#define dec2hex_INCLUDED +#undef dec2hex +void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width) +{ + unsigned int a=dec; + unsigned int b=0; + unsigned int c=0; + char d='1'; + if (a == 0) d='0'; + + while (a) + { + b=a % 16; + a=a / 16; + if (b < 10) hex[c++]=b + '0'; + else if (lowercase == TRUE) hex[c++]=b + 'a' - 10; + else hex[c++]=b + 'A' - 10; + } + while (width > c) hex[c++]='0'; + hex[c]='\0'; + + if (d == '1') + for (b=0, --c; b < c; d=hex[b], hex[b++]=hex[c], hex[c--]=d); +} +#endif + +/******************************************************************** + * + * dec2hexW [API: wsprintfW(wszResult, L"%02x", 2591)] + * + *Converts decimal to unicode hex value. + * + *[in] unsigned int dec -positive integer + *[out] wchar_t *whex -unicode hex value (output) + *[in] BOOL lowercase -if TRUE hexadecimal value in lowercase + * if FALSE in uppercase. + *[in] unsigned int width -minimum number of characters to the output + * + *Examples: + * dec2hexW(2591, wszResult, FALSE, 2); //wszResult == L"A1F" + * dec2hexW(10, wszResult, TRUE, 2); //wszResult == L"0a" + ********************************************************************/ +#if defined dec2hexW || defined ALLCONVFUNC +#define dec2hexW_INCLUDED +#undef dec2hexW +void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int width) +{ + unsigned int a=dec; + unsigned int b=0; + unsigned int c=0; + wchar_t d='1'; + if (a == 0) d='0'; + + while (a) + { + b=a % 16; + a=a / 16; + if (b < 10) whex[c++]=b + '0'; + else if (lowercase == TRUE) whex[c++]=b + 'a' - 10; + else whex[c++]=b + 'A' - 10; + } + while (width > c) whex[c++]='0'; + whex[c]='\0'; + + if (d == '1') + for (b=0, --c; b < c; d=whex[b], whex[b++]=whex[c], whex[c--]=d); +} +#endif + +/******************************************************************** + * + * str2hex + * + *Converts string to hex values. + * + *[in] unsigned char *str -string + *[out] char *hex -hex string + *[in] BOOL lowercase -if TRUE hexadecimal value in lowercase + * if FALSE in uppercase. + *[in] unsigned int bytes -number of bytes in string + * + *Note: + * str2hex uses dec2hex + * + *Examples: + * str2hex((unsigned char *)"Some Text", szResult, TRUE, lstrlen("Some Text")); //szResult == "536f6d652054657874" + ********************************************************************/ +#if defined str2hex || defined ALLCONVFUNCS +#define str2hex_INCLUDED +#undef str2hex +void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes) +{ + char a[16]; + unsigned int b=0; + + for (hex[0]='\0'; b < bytes; ++b) + { + //wsprintf(a, "%02x", (unsigned int)str[b]); + dec2hex((unsigned int)str[b], a, lowercase, 2); + lstrcat(hex, a); + } +} +#endif + +/******************************************************************** + * + * hex2str + * + *Converts hex values to string. + * + *[in] char *hex -hex string + *[out] char *str -string + * + *Examples: + * hex2str("536f6d652054657874", szResult); //szResult == "Some Text" + ********************************************************************/ +#if defined hex2str || defined ALLCONVFUNCS +#define hex2str_INCLUDED +#undef hex2str +void hex2str(char *hex, char *str) +{ + char a[4]; + int b; + + while (*hex) + { + a[0]=*hex; + a[1]=*++hex; + a[2]='\0'; + + if (*hex++) + { + if ((b=hex2dec(a)) > 0) *str++=b; + else break; + } + else break; + } + *str='\0'; +} +#endif + + +/******************************************************************** + * * + * Example * + * * + ******************************************************************** + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include "ConvFunc.h" + +//insert functions +#define xatoi +#define xitoa +#include "ConvFunc.h" + +void main() +{ + char szResult[MAX_PATH]="43"; + char *pResult; + int nError; + + nError=xatoi(szResult); + printf("nError={%d}\n", nError); + + pResult=xitoa(45, szResult, 0); + printf("szResult={%s}, pResult={%s}\n", szResult, pResult); +} + +*/ \ No newline at end of file diff --git a/windows/web/plugins/NsProcess/Readme.txt b/windows/web/plugins/NsProcess/Readme.txt new file mode 100644 index 0000000..88cb454 --- /dev/null +++ b/windows/web/plugins/NsProcess/Readme.txt @@ -0,0 +1,67 @@ +***************************************************************** +*** nsProcess NSIS plugin v1.6 *** +***************************************************************** + +2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) + +Source function FIND_PROC_BY_NAME based + upon the Ravi Kochhar (kochhar@physiology.wisc.edu) code +Thanks iceman_k (FindProcDLL plugin) and + DITMan (KillProcDLL plugin) for direct me +NSIS UNICODE compatible version (1.6) by brainsucker + (sorry, installer missing, i'm too lazy :) + +Features: +- Find a process by name +- Kill all processes with specified name (not only one) +- Close all processes with specified name (first tries to close all process windows, +waits for 3 seconds for process to exit, terminates if still alive) +- The process name is case-insensitive +- Win95/98/ME/NT/2000/XP/Win7 support +- Small plugin size (4 Kb) +- NSIS UNICODE support (just rename nsProcessW.dll into nsProcess.dll) + +**** Find process **** +${nsProcess::FindProcess} "[file.exe]" $var + +"[file.exe]" - Process name (e.g. "notepad.exe") + +$var 0 Success + 603 Process was not currently running + 604 Unable to identify system type + 605 Unsupported OS + 606 Unable to load NTDLL.DLL + 607 Unable to get procedure address from NTDLL.DLL + 608 NtQuerySystemInformation failed + 609 Unable to load KERNEL32.DLL + 610 Unable to get procedure address from KERNEL32.DLL + 611 CreateToolhelp32Snapshot failed + + +**** Kill/Close process **** +${nsProcess::KillProcess} "[file.exe]" $var +${nsProcess::CloseProcess} "[file.exe]" $var + +"[file.exe]" - Process name (e.g. "notepad.exe") + +$var 0 Success + 601 No permission to terminate process + 602 Not all processes terminated successfully + 603 Process was not currently running + 604 Unable to identify system type + 605 Unsupported OS + 606 Unable to load NTDLL.DLL + 607 Unable to get procedure address from NTDLL.DLL + 608 NtQuerySystemInformation failed + 609 Unable to load KERNEL32.DLL + 610 Unable to get procedure address from KERNEL32.DLL + 611 CreateToolhelp32Snapshot failed + +**** Comment from brainsucker **** +I'm actually not using macros in my code, plugin calls are easy: + +nsProcess:_CloseProcess "notepad.exe" +Pop $R0 + +**** Unload plugin **** +${nsProcess::Unload} diff --git a/windows/web/plugins/NsProcess/api.h b/windows/web/plugins/NsProcess/api.h new file mode 100644 index 0000000..ed014b2 --- /dev/null +++ b/windows/web/plugins/NsProcess/api.h @@ -0,0 +1,83 @@ +/* + * apih + * + * This file is a part of NSIS. + * + * Copyright (C) 1999-2008 Nullsoft and Contributors + * + * Licensed under the zlib/libpng license (the "License"); + * you may not use this file except in compliance with the License. + * + * Licence details can be found in the file COPYING. + * + * This software is provided 'as-is', without any express or implied + * warranty. + */ + +#ifndef _NSIS_EXEHEAD_API_H_ +#define _NSIS_EXEHEAD_API_H_ + +// Starting with NSIS 2.42, you can check the version of the plugin API in exec_flags->plugin_api_version +// The format is 0xXXXXYYYY where X is the major version and Y is the minor version (MAKELONG(y,x)) +// When doing version checks, always remember to use >=, ex: if (pX->exec_flags->plugin_api_version >= NSISPIAPIVER_1_0) {} + +#define NSISPIAPIVER_1_0 0x00010000 +#define NSISPIAPIVER_CURR NSISPIAPIVER_1_0 + +// NSIS Plug-In Callback Messages +enum NSPIM +{ + NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup + NSPIM_GUIUNLOAD, // Called after .onGUIEnd +}; + +// Prototype for callbacks registered with extra_parameters->RegisterPluginCallback() +// Return NULL for unknown messages +// Should always be __cdecl for future expansion possibilities +typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM); + +// extra_parameters data structures containing other interesting stuff +// but the stack, variables and HWND passed on to plug-ins. +typedef struct +{ + int autoclose; + int all_user_var; + int exec_error; + int abort; + int exec_reboot; // NSIS_SUPPORT_REBOOT + int reboot_called; // NSIS_SUPPORT_REBOOT + int XXX_cur_insttype; // depreacted + int plugin_api_version; // see NSISPIAPIVER_CURR + // used to be XXX_insttype_changed + int silent; // NSIS_CONFIG_SILENT_SUPPORT + int instdir_error; + int rtl; + int errlvl; + int alter_reg_view; + int status_update; +} exec_flags_t; + +#ifndef NSISCALL +# define NSISCALL __stdcall +#endif + +typedef struct { + exec_flags_t *exec_flags; + int (NSISCALL *ExecuteCodeSegment)(int, HWND); + void (NSISCALL *validate_filename)(TCHAR *); + BOOL (NSISCALL *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK); +} extra_parameters; + +// Definitions for page showing plug-ins +// See Ui.c to understand better how they're used + +// sent to the outer window to tell it to go to the next inner window +#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8) + +// custom pages should send this message to let NSIS know they're ready +#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd) + +// sent as wParam with WM_NOTIFY_OUTER_NEXT when user cancels - heed its warning +#define NOTIFY_BYE_BYE 'x' + +#endif /* _PLUGIN_H_ */ diff --git a/windows/web/plugins/NsProcess/nsProcess.c b/windows/web/plugins/NsProcess/nsProcess.c new file mode 100644 index 0000000..b792db4 --- /dev/null +++ b/windows/web/plugins/NsProcess/nsProcess.c @@ -0,0 +1,416 @@ +/***************************************************************** + * nsProcess NSIS plugin v1.5 * + * * + * 2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) * + * * + * Source function FIND_PROC_BY_NAME based * + * upon the Ravi Kochhar (kochhar@physiology.wisc.edu) code * + * Thanks iceman_k (FindProcDLL plugin) and * + * DITMan (KillProcDLL plugin) for point me up * + *****************************************************************/ + + +#define WIN32_LEAN_AND_MEAN +#include +#include +//#include "ConvFunc.h" +#include "pluginapi.h" + +/* Defines */ +#define NSIS_MAX_STRLEN 1024 + +#define SystemProcessInformation 5 +#define STATUS_SUCCESS 0x00000000L +#define STATUS_INFO_LENGTH_MISMATCH 0xC0000004L + +typedef struct _SYSTEM_THREAD_INFO { + FILETIME ftCreationTime; + DWORD dwUnknown1; + DWORD dwStartAddress; + DWORD dwOwningPID; + DWORD dwThreadID; + DWORD dwCurrentPriority; + DWORD dwBasePriority; + DWORD dwContextSwitches; + DWORD dwThreadState; + DWORD dwUnknown2; + DWORD dwUnknown3; + DWORD dwUnknown4; + DWORD dwUnknown5; + DWORD dwUnknown6; + DWORD dwUnknown7; +} SYSTEM_THREAD_INFO; + +typedef struct _SYSTEM_PROCESS_INFO { + DWORD dwOffset; + DWORD dwThreadCount; + DWORD dwUnkown1[6]; + FILETIME ftCreationTime; + DWORD dwUnkown2; + DWORD dwUnkown3; + DWORD dwUnkown4; + DWORD dwUnkown5; + DWORD dwUnkown6; + WCHAR *pszProcessName; + DWORD dwBasePriority; + DWORD dwProcessID; + DWORD dwParentProcessID; + DWORD dwHandleCount; + DWORD dwUnkown7; + DWORD dwUnkown8; + DWORD dwVirtualBytesPeak; + DWORD dwVirtualBytes; + DWORD dwPageFaults; + DWORD dwWorkingSetPeak; + DWORD dwWorkingSet; + DWORD dwUnkown9; + DWORD dwPagedPool; + DWORD dwUnkown10; + DWORD dwNonPagedPool; + DWORD dwPageFileBytesPeak; + DWORD dwPageFileBytes; + DWORD dwPrivateBytes; + DWORD dwUnkown11; + DWORD dwUnkown12; + DWORD dwUnkown13; + DWORD dwUnkown14; + SYSTEM_THREAD_INFO ati[ANYSIZE_ARRAY]; +} SYSTEM_PROCESS_INFO; + + +/* Include conversion functions */ +//#define xatoi +//#define xitoa +//#include "ConvFunc.h" + +/* Global variables */ +TCHAR szBuf[NSIS_MAX_STRLEN]; + +/* Funtions prototypes and macros */ +int FIND_PROC_BY_NAME(TCHAR *szProcessName, BOOL bTerminate, BOOL bClose); + +/* NSIS functions code */ +void __declspec(dllexport) _FindProcess(HWND hwndParent, int string_size, + TCHAR *variables, stack_t **stacktop, extra_parameters *extra) +{ + EXDLL_INIT(); + { + int nError; + + popstringn(szBuf, NSIS_MAX_STRLEN); + nError=FIND_PROC_BY_NAME(szBuf, FALSE, FALSE); + pushint(nError); + } +} + +void __declspec(dllexport) _KillProcess(HWND hwndParent, int string_size, + TCHAR *variables, stack_t **stacktop, extra_parameters *extra) +{ + EXDLL_INIT(); + { + int nError=0; + + popstringn(szBuf, NSIS_MAX_STRLEN); + nError=FIND_PROC_BY_NAME(szBuf, TRUE, FALSE); + pushint(nError); + } +} + +void __declspec(dllexport) _CloseProcess(HWND hwndParent, int string_size, + TCHAR *variables, stack_t **stacktop, extra_parameters *extra) +{ + EXDLL_INIT(); + { + int nError=0; + + popstringn(szBuf, NSIS_MAX_STRLEN); + nError=FIND_PROC_BY_NAME(szBuf, TRUE, TRUE); + pushint(nError); + } +} + +void __declspec(dllexport) _Unload(HWND hwndParent, int string_size, + TCHAR *variables, stack_t **stacktop, extra_parameters *extra) +{ +} + +BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) +{ + return TRUE; +} + +BOOL CALLBACK EnumWindowsProc( HWND hwnd, + LPARAM lParam +) +{ + HANDLE *data = lParam; + DWORD pid; + GetWindowThreadProcessId(hwnd, &pid); + if (pid == data[0]) + { + PostMessage(data[1], WM_CLOSE, 0, 0); + data[1] = hwnd; + } + return TRUE; +} + +void NiceTerminate(DWORD id, BOOL bClose, BOOL *bSuccess, BOOL *bFailed) +{ + HANDLE hProc; + HANDLE data[2]; + DWORD ec; + BOOL bDone = FALSE; + if (hProc=OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE, FALSE, id)) + { + data[0] = id; + data[1] = NULL; + + if (bClose) + EnumWindows(EnumWindowsProc, data); + if (data[1] != NULL) + { + if (GetExitCodeProcess(hProc,&ec) && ec == STILL_ACTIVE) + if (WaitForSingleObject(hProc, 3000) == WAIT_OBJECT_0) + { + *bSuccess = bDone = TRUE; + } + else; + else + { + *bSuccess = bDone = TRUE; + } + } + if (!bDone) + { + // Open for termination + if (TerminateProcess(hProc, 0)) + *bSuccess=TRUE; + else + *bFailed=TRUE; + } + CloseHandle(hProc); + } +} + +int FIND_PROC_BY_NAME(TCHAR *szProcessName, BOOL bTerminate, BOOL bClose) +// Find the process "szProcessName" if it is currently running. +// This works for Win95/98/ME and also WinNT/2000/XP. +// The process name is case-insensitive, i.e. "notepad.exe" and "NOTEPAD.EXE" +// will both work. If bTerminate is TRUE, then process will be terminated. +// +// Return codes are as follows: +// 0 = Success +// 601 = No permission to terminate process +// 602 = Not all processes terminated successfully +// 603 = Process was not currently running +// 604 = Unable to identify system type +// 605 = Unsupported OS +// 606 = Unable to load NTDLL.DLL +// 607 = Unable to get procedure address from NTDLL.DLL +// 608 = NtQuerySystemInformation failed +// 609 = Unable to load KERNEL32.DLL +// 610 = Unable to get procedure address from KERNEL32.DLL +// 611 = CreateToolhelp32Snapshot failed +// +// Change history: +// created 06/23/2000 - Ravi Kochhar (kochhar@physiology.wisc.edu) +// http://www.neurophys.wisc.edu/ravi/software/ +// modified 03/08/2002 - Ravi Kochhar (kochhar@physiology.wisc.edu) +// - Borland-C compatible if BORLANDC is defined as +// suggested by Bob Christensen +// modified 03/10/2002 - Ravi Kochhar (kochhar@physiology.wisc.edu) +// - Removed memory leaks as suggested by +// Jonathan Richard-Brochu (handles to Proc and Snapshot +// were not getting closed properly in some cases) +// modified 14/11/2005 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru): +// - Combine functions FIND_PROC_BY_NAME and KILL_PROC_BY_NAME +// - Code has been optimized +// - Now kill all processes with specified name (not only one) +// - Cosmetic improvements +// - Removed error 632 (Invalid process name) +// - Changed error 602 (Unable to terminate process for some other reason) +// - BORLANDC define not needed +// modified 04/01/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru): +// - Removed CRT dependency +// modified 21/04/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru): +// - Removed memory leak as suggested by {_trueparuex^} +// (handle to hSnapShot was not getting closed properly in some cases) +// modified 21/04/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru): +// - Removed memory leak as suggested by {_trueparuex^} +// (handle to hSnapShot was not getting closed properly in some cases) +// modified 19/07/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru): +// - Code for WinNT/2000/XP has been rewritten +// - Changed error codes +// modified 31/08/2006 - Shengalts Aleksander aka Instructor (Shengalts@mail.ru): +// - Removed memory leak as suggested by Daniel Vanesse +{ + TCHAR szName[MAX_PATH]; + OSVERSIONINFO osvi; + HMODULE hLib; + HANDLE hProc; + ULONG uError; + BOOL bFound=FALSE; + BOOL bSuccess=FALSE; + BOOL bFailed=FALSE; + + // First check what version of Windows we're in + osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); + if (!GetVersionEx(&osvi)) return 604; + + if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT && + osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) + return 605; + + if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + // WinNT/2000/XP + + SYSTEM_PROCESS_INFO *spi; + SYSTEM_PROCESS_INFO *spiCount; + DWORD dwSize=0x4000; + DWORD dwData; + ULONG (WINAPI *NtQuerySystemInformationPtr)(ULONG, PVOID, LONG, PULONG); + + if (hLib=LoadLibraryW(L"NTDLL.DLL")) + { + NtQuerySystemInformationPtr=(ULONG(WINAPI *)(ULONG, PVOID, LONG, PULONG))GetProcAddress(hLib, "NtQuerySystemInformation"); + + if (NtQuerySystemInformationPtr) + { + while (1) + { + if (spi=LocalAlloc(LMEM_FIXED, dwSize)) + { + uError=(*NtQuerySystemInformationPtr)(SystemProcessInformation, spi, dwSize, &dwData); + + if (uError == STATUS_SUCCESS) break; + + LocalFree(spi); + + if (uError != STATUS_INFO_LENGTH_MISMATCH) + { + uError=608; + break; + } + } + else + { + uError=608; + break; + } + dwSize*=2; + } + } + else uError=607; + + FreeLibrary(hLib); + } + else uError=606; + + if (uError != STATUS_SUCCESS) return uError; + + spiCount=spi; + + while (1) + { + if (spiCount->pszProcessName) + { + +#ifdef UNICODE + lstrcpyn(szName, spiCount->pszProcessName, MAX_PATH); +#else + WideCharToMultiByte(CP_ACP, 0, spiCount->pszProcessName, -1, szName, MAX_PATH, NULL, NULL); +#endif + + if (!lstrcmpi(szName, szProcessName)) + { + // Process found + bFound=TRUE; + + if (bTerminate == TRUE) + { + NiceTerminate(spiCount->dwProcessID, bClose, &bSuccess, &bFailed); + } + else break; + } + } + if (spiCount->dwOffset == 0) break; + spiCount=(SYSTEM_PROCESS_INFO *)((char *)spiCount + spiCount->dwOffset); + } + LocalFree(spi); + } + else + { + // Win95/98/ME + + PROCESSENTRY32 pe; + char *pName; + HANDLE hSnapShot; + BOOL bResult; + HANDLE (WINAPI *CreateToolhelp32SnapshotPtr)(DWORD, DWORD); + BOOL (WINAPI *Process32FirstPtr)(HANDLE, LPPROCESSENTRY32); + BOOL (WINAPI *Process32NextPtr)(HANDLE, LPPROCESSENTRY32); + + if (hLib=LoadLibraryA("KERNEL32.DLL")) + { + CreateToolhelp32SnapshotPtr=(HANDLE(WINAPI *)(DWORD, DWORD)) GetProcAddress(hLib, "CreateToolhelp32Snapshot"); + Process32FirstPtr=(BOOL(WINAPI *)(HANDLE, LPPROCESSENTRY32)) GetProcAddress(hLib, "Process32First"); + Process32NextPtr=(BOOL(WINAPI *)(HANDLE, LPPROCESSENTRY32)) GetProcAddress(hLib, "Process32Next"); + + if (CreateToolhelp32SnapshotPtr && Process32NextPtr && Process32FirstPtr) + { + // Get a handle to a Toolhelp snapshot of all the systems processes. + if ((hSnapShot=(*CreateToolhelp32SnapshotPtr)(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE) + { + // Get the first process' information. + pe.dwSize=sizeof(PROCESSENTRY32); + bResult=(*Process32FirstPtr)(hSnapShot, &pe); + + // While there are processes, keep looping and checking. + while (bResult) + { + //Get file name + for (pName=pe.szExeFile + lstrlen(pe.szExeFile) - 1; *pName != '\\' && *pName != '\0'; --pName); + + ++pName; + +#ifdef UNICODE + MultiByteToWideChar(CP_ACP, 0, pName, lstrlenA(pName)+1, szName, MAX_PATH); +#else + lstrcpyn(szName, pName, MAX_PATH); +#endif + + if (!lstrcmpi(szName, szProcessName)) + { + // Process found + bFound=TRUE; + + if (bTerminate == TRUE) + { + // Open for termination + NiceTerminate(pe.th32ProcessID, bClose, &bSuccess, &bFailed); + } + else break; + } + //Keep looking + bResult=(*Process32NextPtr)(hSnapShot, &pe); + } + CloseHandle(hSnapShot); + } + else uError=611; + } + else uError=610; + + FreeLibrary(hLib); + } + else uError=609; + } + + if (bFound == FALSE) return 603; + if (bTerminate == TRUE) + { + if (bSuccess == FALSE) return 601; + if (bFailed == TRUE) return 602; + } + return 0; +} diff --git a/windows/web/plugins/NsProcess/nsProcess.nsh b/windows/web/plugins/NsProcess/nsProcess.nsh new file mode 100644 index 0000000..9ef6098 --- /dev/null +++ b/windows/web/plugins/NsProcess/nsProcess.nsh @@ -0,0 +1,28 @@ +!define nsProcess::FindProcess `!insertmacro nsProcess::FindProcess` + +!macro nsProcess::FindProcess _FILE _ERR + nsProcess::_FindProcess /NOUNLOAD `${_FILE}` + Pop ${_ERR} +!macroend + + +!define nsProcess::KillProcess `!insertmacro nsProcess::KillProcess` + +!macro nsProcess::KillProcess _FILE _ERR + nsProcess::_KillProcess /NOUNLOAD `${_FILE}` + Pop ${_ERR} +!macroend + +!define nsProcess::CloseProcess `!insertmacro nsProcess::CloseProcess` + +!macro nsProcess::CloseProcess _FILE _ERR + nsProcess::_CloseProcess /NOUNLOAD `${_FILE}` + Pop ${_ERR} +!macroend + + +!define nsProcess::Unload `!insertmacro nsProcess::Unload` + +!macro nsProcess::Unload + nsProcess::_Unload +!macroend diff --git a/windows/web/plugins/NsProcess/nsProcess.sln b/windows/web/plugins/NsProcess/nsProcess.sln new file mode 100644 index 0000000..1260acc --- /dev/null +++ b/windows/web/plugins/NsProcess/nsProcess.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nsProcess", "nsProcess.vcproj", "{BD73F235-28DE-40F5-B047-14222BC77FDC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release ANSI|Win32 = Release ANSI|Win32 + Release UNICODE|Win32 = Release UNICODE|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BD73F235-28DE-40F5-B047-14222BC77FDC}.Debug|Win32.ActiveCfg = Debug|Win32 + {BD73F235-28DE-40F5-B047-14222BC77FDC}.Debug|Win32.Build.0 = Debug|Win32 + {BD73F235-28DE-40F5-B047-14222BC77FDC}.Release ANSI|Win32.ActiveCfg = Release ANSI|Win32 + {BD73F235-28DE-40F5-B047-14222BC77FDC}.Release ANSI|Win32.Build.0 = Release ANSI|Win32 + {BD73F235-28DE-40F5-B047-14222BC77FDC}.Release UNICODE|Win32.ActiveCfg = Release UNICODE|Win32 + {BD73F235-28DE-40F5-B047-14222BC77FDC}.Release UNICODE|Win32.Build.0 = Release UNICODE|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/windows/web/plugins/NsProcess/nsProcess.vcproj b/windows/web/plugins/NsProcess/nsProcess.vcproj new file mode 100644 index 0000000..5d12f8a --- /dev/null +++ b/windows/web/plugins/NsProcess/nsProcess.vcproj @@ -0,0 +1,372 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/windows/web/plugins/NsProcess/nsProcessTest.nsi b/windows/web/plugins/NsProcess/nsProcessTest.nsi new file mode 100644 index 0000000..0591068 --- /dev/null +++ b/windows/web/plugins/NsProcess/nsProcessTest.nsi @@ -0,0 +1,69 @@ +Name "nsProcessTest" +OutFile "nsProcessTest.exe" + +!include "nsProcess.nsh" +!include "Sections.nsh" + +Var RADIOBUTTON + +Page components +Page instfiles + + +Section "Find process" FindProcess + ${nsProcess::FindProcess} "Calc.exe" $R0 + MessageBox MB_OK "nsProcess::FindProcess$\n$\n\ + Errorlevel: [$R0]" + + ${nsProcess::Unload} +SectionEnd + + +Section /o "Kill process" KillProcess + loop: + ${nsProcess::FindProcess} "NoTePad.exe" $R0 + StrCmp $R0 0 0 +2 + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION 'Close "notepad" before continue' IDOK loop IDCANCEL end + + ${nsProcess::KillProcess} "NoTePad.exe" $R0 + MessageBox MB_OK "nsProcess::KillProcess$\n$\n\ + Errorlevel: [$R0]" + + Exec "notepad.exe" + Exec "notepad.exe" + Exec "notepad.exe" + Sleep 1000 + BringToFront + MessageBox MB_OK "Press OK and 3 notepad's windows will be closed (TERMINATED)" + + ${nsProcess::KillProcess} "NoTePad.exe" $R0 + MessageBox MB_OK "nsProcess::KillProcess$\n$\n\ + Errorlevel: [$R0]" + + Exec "notepad.exe" + Exec "notepad.exe" + Exec "notepad.exe" + Sleep 1000 + BringToFront + MessageBox MB_OK "Press OK and 3 notepad's windows will be CLOSED" + + ${nsProcess::CloseProcess} "NoTePad.exe" $R0 + MessageBox MB_OK "nsProcess::CloseProcess$\n$\n\ + Errorlevel: [$R0]" + + + end: + ${nsProcess::Unload} +SectionEnd + + +Function .onInit + StrCpy $RADIOBUTTON ${FindProcess} +FunctionEnd + +Function .onSelChange + !insertmacro StartRadioButtons $RADIOBUTTON + !insertmacro RadioButton ${FindProcess} + !insertmacro RadioButton ${KillProcess} + !insertmacro EndRadioButtons +FunctionEnd diff --git a/windows/web/plugins/NsProcess/nsis_tchar.h b/windows/web/plugins/NsProcess/nsis_tchar.h new file mode 100644 index 0000000..92025cc --- /dev/null +++ b/windows/web/plugins/NsProcess/nsis_tchar.h @@ -0,0 +1,214 @@ +/* + * nsis_tchar.h + * + * This file is a part of NSIS. + * + * Copyright (C) 1999-2007 Nullsoft and Contributors + * + * This software is provided 'as-is', without any express or implied + * warranty. + * + * For Unicode support by Jim Park -- 08/30/2007 + */ + +// Jim Park: Only those we use are listed here. + +#pragma once + +#ifdef _UNICODE + +#ifndef _T +#define __T(x) L ## x +#define _T(x) __T(x) +#define _TEXT(x) __T(x) +#endif +typedef wchar_t TCHAR; +typedef wchar_t _TUCHAR; + +// program +#define _tmain wmain +#define _tWinMain wWinMain +#define _tenviron _wenviron +#define __targv __wargv + +// printfs +#define _ftprintf fwprintf +#define _sntprintf _snwprintf +#define _stprintf _swprintf +#define _tprintf wprintf +#define _vftprintf vfwprintf +#define _vsntprintf _vsnwprintf +#define _vstprintf _vswprintf + +// scanfs +#define _tscanf wscanf +#define _stscanf swscanf + +// string manipulations +#define _tcscat wcscat +#define _tcschr wcschr +#define _tcsclen wcslen +#define _tcscpy wcscpy +#define _tcsdup _wcsdup +#define _tcslen wcslen +#define _tcsnccpy wcsncpy +#define _tcsncpy wcsncpy +#define _tcsrchr wcsrchr +#define _tcsstr wcsstr +#define _tcstok wcstok + +// string comparisons +#define _tcscmp wcscmp +#define _tcsicmp _wcsicmp +#define _tcsncicmp _wcsnicmp +#define _tcsncmp wcsncmp +#define _tcsnicmp _wcsnicmp + +// upper / lower +#define _tcslwr _wcslwr +#define _tcsupr _wcsupr +#define _totlower towlower +#define _totupper towupper + +// conversions to numbers +#define _tcstoi64 _wcstoi64 +#define _tcstol wcstol +#define _tcstoul wcstoul +#define _tstof _wtof +#define _tstoi _wtoi +#define _tstoi64 _wtoi64 +#define _ttoi _wtoi +#define _ttoi64 _wtoi64 +#define _ttol _wtol + +// conversion from numbers to strings +#define _itot _itow +#define _ltot _ltow +#define _i64tot _i64tow +#define _ui64tot _ui64tow + +// file manipulations +#define _tfopen _wfopen +#define _topen _wopen +#define _tremove _wremove +#define _tunlink _wunlink + +// reading and writing to i/o +#define _fgettc fgetwc +#define _fgetts fgetws +#define _fputts fputws +#define _gettchar getwchar + +// directory +#define _tchdir _wchdir + +// environment +#define _tgetenv _wgetenv +#define _tsystem _wsystem + +// time +#define _tcsftime wcsftime + +#else // ANSI + +#ifndef _T +#define _T(x) x +#define _TEXT(x) x +#endif +typedef char TCHAR; +typedef unsigned char _TUCHAR; + +// program +#define _tmain main +#define _tWinMain WinMain +#define _tenviron environ +#define __targv __argv + +// printfs +#define _ftprintf fprintf +#define _sntprintf _snprintf +#define _stprintf sprintf +#define _tprintf printf +#define _vftprintf vfprintf +#define _vsntprintf _vsnprintf +#define _vstprintf vsprintf + +// scanfs +#define _tscanf scanf +#define _stscanf sscanf + +// string manipulations +#define _tcscat strcat +#define _tcschr strchr +#define _tcsclen strlen +#define _tcscnlen strnlen +#define _tcscpy strcpy +#define _tcsdup _strdup +#define _tcslen strlen +#define _tcsnccpy strncpy +#define _tcsrchr strrchr +#define _tcsstr strstr +#define _tcstok strtok + +// string comparisons +#define _tcscmp strcmp +#define _tcsicmp _stricmp +#define _tcsncmp strncmp +#define _tcsncicmp _strnicmp +#define _tcsnicmp _strnicmp + +// upper / lower +#define _tcslwr _strlwr +#define _tcsupr _strupr + +#define _totupper toupper +#define _totlower tolower + +// conversions to numbers +#define _tcstol strtol +#define _tcstoul strtoul +#define _tstof atof +#define _tstoi atoi +#define _tstoi64 _atoi64 +#define _tstoi64 _atoi64 +#define _ttoi atoi +#define _ttoi64 _atoi64 +#define _ttol atol + +// conversion from numbers to strings +#define _i64tot _i64toa +#define _itot _itoa +#define _ltot _ltoa +#define _ui64tot _ui64toa + +// file manipulations +#define _tfopen fopen +#define _topen _open +#define _tremove remove +#define _tunlink _unlink + +// reading and writing to i/o +#define _fgettc fgetc +#define _fgetts fgets +#define _fputts fputs +#define _gettchar getchar + +// directory +#define _tchdir _chdir + +// environment +#define _tgetenv getenv +#define _tsystem system + +// time +#define _tcsftime strftime + +#endif + +// is functions (the same in Unicode / ANSI) +#define _istgraph isgraph +#define _istascii __isascii + +#define __TFILE__ _T(__FILE__) +#define __TDATE__ _T(__DATE__) +#define __TTIME__ _T(__TIME__) diff --git a/windows/web/plugins/NsProcess/pluginapi.c b/windows/web/plugins/NsProcess/pluginapi.c new file mode 100644 index 0000000..a6562fa --- /dev/null +++ b/windows/web/plugins/NsProcess/pluginapi.c @@ -0,0 +1,290 @@ +#include + +#include "pluginapi.h" + +unsigned int g_stringsize; +stack_t **g_stacktop; +TCHAR *g_variables; + +// utility functions (not required but often useful) + +int NSISCALL popstring(TCHAR *str) +{ + stack_t *th; + if (!g_stacktop || !*g_stacktop) return 1; + th=(*g_stacktop); + lstrcpy(str,th->text); + *g_stacktop = th->next; + GlobalFree((HGLOBAL)th); + return 0; +} + +int NSISCALL popstringn(TCHAR *str, int maxlen) +{ + stack_t *th; + if (!g_stacktop || !*g_stacktop) return 1; + th=(*g_stacktop); + if (str) lstrcpyn(str,th->text,maxlen?maxlen:g_stringsize); + *g_stacktop = th->next; + GlobalFree((HGLOBAL)th); + return 0; +} + +void NSISCALL pushstring(const TCHAR *str) +{ + stack_t *th; + if (!g_stacktop) return; + th=(stack_t*)GlobalAlloc(GPTR,(sizeof(stack_t)+(g_stringsize)*sizeof(TCHAR))); + lstrcpyn(th->text,str,g_stringsize); + th->next=*g_stacktop; + *g_stacktop=th; +} + +TCHAR * NSISCALL getuservariable(const int varnum) +{ + if (varnum < 0 || varnum >= __INST_LAST) return NULL; + return g_variables+varnum*g_stringsize; +} + +void NSISCALL setuservariable(const int varnum, const TCHAR *var) +{ + if (var != NULL && varnum >= 0 && varnum < __INST_LAST) + lstrcpy(g_variables + varnum*g_stringsize, var); +} + +#ifdef _UNICODE +int NSISCALL PopStringA(char* ansiStr) +{ + wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t)); + int rval = popstring(wideStr); + WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL); + GlobalFree((HGLOBAL)wideStr); + return rval; +} + +int NSISCALL PopStringNA(char* ansiStr, int maxlen) +{ + int realLen = maxlen ? maxlen : g_stringsize; + wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, realLen*sizeof(wchar_t)); + int rval = popstringn(wideStr, realLen); + WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, realLen, NULL, NULL); + GlobalFree((HGLOBAL)wideStr); + return rval; +} + +void NSISCALL PushStringA(const char* ansiStr) +{ + wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, g_stringsize*sizeof(wchar_t)); + MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize); + pushstring(wideStr); + GlobalFree((HGLOBAL)wideStr); + return; +} + +void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr) +{ + lstrcpyW(wideStr, getuservariable(varnum)); +} + +void NSISCALL GetUserVariableA(const int varnum, char* ansiStr) +{ + wchar_t* wideStr = getuservariable(varnum); + WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL); +} + +void NSISCALL SetUserVariableA(const int varnum, const char* ansiStr) +{ + if (ansiStr != NULL && varnum >= 0 && varnum < __INST_LAST) + { + wchar_t* wideStr = g_variables + varnum * g_stringsize; + MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize); + } +} + +#else +// ANSI defs +int NSISCALL PopStringW(wchar_t* wideStr) +{ + char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize); + int rval = popstring(ansiStr); + MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize); + GlobalFree((HGLOBAL)ansiStr); + return rval; +} + +int NSISCALL PopStringNW(wchar_t* wideStr, int maxlen) +{ + int realLen = maxlen ? maxlen : g_stringsize; + char* ansiStr = (char*) GlobalAlloc(GPTR, realLen); + int rval = popstringn(ansiStr, realLen); + MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, realLen); + GlobalFree((HGLOBAL)ansiStr); + return rval; +} + +void NSISCALL PushStringW(wchar_t* wideStr) +{ + char* ansiStr = (char*) GlobalAlloc(GPTR, g_stringsize); + WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL); + pushstring(ansiStr); + GlobalFree((HGLOBAL)ansiStr); +} + +void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr) +{ + char* ansiStr = getuservariable(varnum); + MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize); +} + +void NSISCALL GetUserVariableA(const int varnum, char* ansiStr) +{ + lstrcpyA(ansiStr, getuservariable(varnum)); +} + +void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr) +{ + if (wideStr != NULL && varnum >= 0 && varnum < __INST_LAST) + { + char* ansiStr = g_variables + varnum * g_stringsize; + WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL); + } +} +#endif + +// playing with integers + +int NSISCALL myatoi(const TCHAR *s) +{ + int v=0; + if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X'))) + { + s++; + for (;;) + { + int c=*(++s); + if (c >= _T('0') && c <= _T('9')) c-=_T('0'); + else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10; + else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10; + else break; + v<<=4; + v+=c; + } + } + else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0')) + { + for (;;) + { + int c=*(++s); + if (c >= _T('0') && c <= _T('7')) c-=_T('0'); + else break; + v<<=3; + v+=c; + } + } + else + { + int sign=0; + if (*s == _T('-')) sign++; else s--; + for (;;) + { + int c=*(++s) - _T('0'); + if (c < 0 || c > 9) break; + v*=10; + v+=c; + } + if (sign) v = -v; + } + + return v; +} + +unsigned NSISCALL myatou(const TCHAR *s) +{ + unsigned int v=0; + + for (;;) + { + unsigned int c=*s++; + if (c >= _T('0') && c <= _T('9')) c-=_T('0'); + else break; + v*=10; + v+=c; + } + return v; +} + +int NSISCALL myatoi_or(const TCHAR *s) +{ + int v=0; + if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X'))) + { + s++; + for (;;) + { + int c=*(++s); + if (c >= _T('0') && c <= _T('9')) c-=_T('0'); + else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10; + else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10; + else break; + v<<=4; + v+=c; + } + } + else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0')) + { + for (;;) + { + int c=*(++s); + if (c >= _T('0') && c <= _T('7')) c-=_T('0'); + else break; + v<<=3; + v+=c; + } + } + else + { + int sign=0; + if (*s == _T('-')) sign++; else s--; + for (;;) + { + int c=*(++s) - _T('0'); + if (c < 0 || c > 9) break; + v*=10; + v+=c; + } + if (sign) v = -v; + } + + // Support for simple ORed expressions + if (*s == _T('|')) + { + v |= myatoi_or(s+1); + } + + return v; +} + +int NSISCALL popint() +{ + TCHAR buf[128]; + if (popstringn(buf,sizeof(buf)/sizeof(TCHAR))) + return 0; + + return myatoi(buf); +} + +int NSISCALL popint_or() +{ + TCHAR buf[128]; + if (popstringn(buf,sizeof(buf)/sizeof(TCHAR))) + return 0; + + return myatoi_or(buf); +} + +void NSISCALL pushint(int value) +{ + TCHAR buffer[1024]; + wsprintf(buffer, _T("%d"), value); + pushstring(buffer); +} diff --git a/windows/web/plugins/NsProcess/pluginapi.h b/windows/web/plugins/NsProcess/pluginapi.h new file mode 100644 index 0000000..b9bfee9 --- /dev/null +++ b/windows/web/plugins/NsProcess/pluginapi.h @@ -0,0 +1,101 @@ +#ifndef ___NSIS_PLUGIN__H___ +#define ___NSIS_PLUGIN__H___ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "api.h" +#include "nsis_tchar.h" + +#ifndef NSISCALL +# define NSISCALL __stdcall +#endif + +#define EXDLL_INIT() { \ + g_stringsize=string_size; \ + g_stacktop=stacktop; \ + g_variables=variables; } + +typedef struct _stack_t { + struct _stack_t *next; + TCHAR text[1]; // this should be the length of string_size +} stack_t; + +enum +{ +INST_0, // $0 +INST_1, // $1 +INST_2, // $2 +INST_3, // $3 +INST_4, // $4 +INST_5, // $5 +INST_6, // $6 +INST_7, // $7 +INST_8, // $8 +INST_9, // $9 +INST_R0, // $R0 +INST_R1, // $R1 +INST_R2, // $R2 +INST_R3, // $R3 +INST_R4, // $R4 +INST_R5, // $R5 +INST_R6, // $R6 +INST_R7, // $R7 +INST_R8, // $R8 +INST_R9, // $R9 +INST_CMDLINE, // $CMDLINE +INST_INSTDIR, // $INSTDIR +INST_OUTDIR, // $OUTDIR +INST_EXEDIR, // $EXEDIR +INST_LANG, // $LANGUAGE +__INST_LAST +}; + +extern unsigned int g_stringsize; +extern stack_t **g_stacktop; +extern TCHAR *g_variables; + +int NSISCALL popstring(TCHAR *str); // 0 on success, 1 on empty stack +int NSISCALL popstringn(TCHAR *str, int maxlen); // with length limit, pass 0 for g_stringsize +int NSISCALL popint(); // pops an integer +int NSISCALL popint_or(); // with support for or'ing (2|4|8) +int NSISCALL myatoi(const TCHAR *s); // converts a string to an integer +unsigned NSISCALL myatou(const TCHAR *s); // converts a string to an unsigned integer, decimal only +int NSISCALL myatoi_or(const TCHAR *s); // with support for or'ing (2|4|8) +void NSISCALL pushstring(const TCHAR *str); +void NSISCALL pushint(int value); +TCHAR * NSISCALL getuservariable(const int varnum); +void NSISCALL setuservariable(const int varnum, const TCHAR *var); + +#ifdef _UNICODE +#define PopStringW(x) popstring(x) +#define PushStringW(x) pushstring(x) +#define SetUserVariableW(x,y) setuservariable(x,y) + +int NSISCALL PopStringA(char* ansiStr); +void NSISCALL PushStringA(const char* ansiStr); +void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr); +void NSISCALL GetUserVariableA(const int varnum, char* ansiStr); +void NSISCALL SetUserVariableA(const int varnum, const char* ansiStr); + +#else +// ANSI defs + +#define PopStringA(x) popstring(x) +#define PushStringA(x) pushstring(x) +#define SetUserVariableA(x,y) setuservariable(x,y) + +int NSISCALL PopStringW(wchar_t* wideStr); +void NSISCALL PushStringW(wchar_t* wideStr); +void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr); +void NSISCALL GetUserVariableA(const int varnum, char* ansiStr); +void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif//!___NSIS_PLUGIN__H___ diff --git a/windows/web/plugins/NsProcess/x86-ansi/nsProcess.dll b/windows/web/plugins/NsProcess/x86-ansi/nsProcess.dll new file mode 100644 index 0000000000000000000000000000000000000000..4ce012103f940e219f1b48eebd923e2b9c05ad01 GIT binary patch literal 4608 zcmeHKZ){sv6+d>I#_iI^8Z{~?&{r?8O022v=Za==i?igV4RzbsI<-Tae~$gq_p;~r z!uyjZD1lavJGrkO6{>&_(WcP}5bQ$*Ekx6_g_bERq9DQ4RmueYFibU)Wh&IYY$X(x4^mO z5yx79HK=iyvA0pb2+^vglSUF_rJIck+h!f| znij$6TT5oZPz-;~WX%xm7Fso3OQFur6&18dumP#2MJS#o$SNBCjq0%mwjGVLrbPgr zsu3R!|Bn^8$}U8%G{O<IAjKwX}ortqbG11}j0P%XL|7!c+ji>YGN`7FqZJ^QUC~zyh*nm$Q z@$xv|Hn3`JD{%MddW|UO7K~4wnz>hp50B{)=N|#U3Aa6A)?1vX_-G6jE?a@3S!Zz@ z6N^BfHR8o1?HL+8cJ1nsg4}Zc)Sb8SI3`$9;9lYLGyVCQzWmJaBKOL9+c;bTT{qv4 zR<{$_WoLfvjKz(O$Q@0y>k)H)fX=mH_bNmH#5d5#`UCOqM4so;?Tf~k_!5qJ;tkoV zUR3RgTRZ$HCCH8T#Uduh^D$zIWA)@nueF*Z#urc`-Y3xH6u}26^R&oV`;JKTQNh{j@~3l)XJx%UY< zG)DMXjCfnnjhIFuN0k^NgK}=c+#Jbs{cYT&$rQL@zQFbI#GED*UCTTEK}hzO9%~IE zy6Wy0FI3~a-GJcY9L4iCV{hHe52V}w*fjfBETy%B<}RMZE=F#M|rk(lkq7E4g=@W-n5{)HM4;9(dJumVeKS!xpKYPt^?>*x_`Ch-dVizF7SF_z{ul|wjeUpp-~yBeFC7U^dJjqkH7b&P+PYPiJTPsOl?J)s&qXcA#*S3Ql%m@YqoH zb@|#=tEo`Q=SmgTV&| zh?f8y@#S~#(R2{tEmS=?fR_R|#t`6g1>oB@zzZ~Jd_W`FonW+Qr(0YQxBSKy%%c%2 zRsRCbjxTh(cw)5RNufJn`&b*|c{lM!P{x83>*#IchU_ki2S%Ii7tb!Z`LPJ`cF|(* zunTn;aT;yB8Z5}Ku|f0x!7DC$^_;pxYe-CYAqN<+_%;IILFq+?*_V|3^0S1HYv}N> z-KPT6TL8`=J%@A&=~qZMk={YNiv&J^MkF7SA1RFVWu$&28EG2n3=(ZWL;gFYTS(t8 z>v&B~3A)Y(50t)Bs&coa>GC#=v7r&6y$L>7*mqtx~S4m8ra7jKEOrUU~5-2 zO63E_Ayd$%VpF;yWO|fQRm&s|NmcAQ=!Gtb;;*&L0X~-oXr?)o+jnV93|?n7x;v=D zx7~f)|GGAv&?&3Bus5lsWdXLidIc>bDOiqjkpR-JL{c)kRV^kd$7SK*$e55a;C06y z!Qdt(qZ2=-tF~<2!Er&Uh(B@3x}l}Ur<4x3Y>#CDhwv9?R86L%(ukJSrci#VWS1G2 zI^b)rgp?LK#iZ7&?l)yadTPoL@Tr~~hfk^_X3x-Mi! zM2pkB=v0>DW$2pI%;f7shKB}dZu+E;A1jLMH&_K$_d%!3$*%u zyVtK{n6ROlxm@2o2r?tnewQz)_b3zU(}Lz>OsOM9@3vjO(WI;kzTM&NRqPKsSMh5sKC*gv`v+nT zZ?7he?&0l~dhX^s_>Qiwo&$UO`pSd)6N-n9g+@asLf;6T4Sg&0z0eOr7em)WZ-#KuhwWppz&`;@9Jy}* literal 0 HcmV?d00001 diff --git a/windows/web/plugins/NsProcess/x86-unicode/nsProcess.dll b/windows/web/plugins/NsProcess/x86-unicode/nsProcess.dll new file mode 100644 index 0000000000000000000000000000000000000000..2478624ee0bcceb6e2c0eee3a563e7cea272ba9a GIT binary patch literal 4608 zcmeHKeQaA-6+cd#)a}y7D)rc=LSNh)ERn#_aahBLk)igDAYKML#b?leg+4FOF zA8CW;X_e!F_hxMp6O&NHC`Cf!Ln>Ma5sc1iJ3^&xAR$6WC8(wfxg>uSsUUA;d;IS6 z2i^u#CB*oHUF+O)&*wYm-1DyQJ8essF zO@ps>4JT7FHzj3GO0hH-kBMSN;l_DRQbjH$a{ULxTso8B9c$OF>8`n6`+NCU`+oMR zxjKm1iMc_8-Z&Qm_Fw+y+BSpqCRmMfxd9vsmLhm?pZF{0<#=7VAAtO0Hs zenju6su9QP1ulC^{!1NnSX+)nwXCHWu!N$zEyR&kQ#-VPrKeq8KS}sm^=Y$iI|f1FQM0Es z<{v$N$-?Y%%N^l}rdpyA&-HN9WVVuSvoiZi&)=1Y3+kQ1@ygEQ9ZGL8a3_>pg*QyM z4MV>3ctzP-46Lx{b%4&7l>5(QS6cD1sMh5CJwy;#41wCF1*}W!!(f;V21vD43v7rk z5PP?D8(P>pHhT2xWdw9)If3Sndh}xc*YE0jsF1x~$SxPMcNPqK11xl#zv_6+{4q4@ ztw~I|pWlFXOE{u@vbr>N&bC2!{y5VJV!B9vqU5Wv)c&B`e87c3rDs8zOrFO&q}z5F ztTI@8BieQ^sHnc!v#^9TZ-&CUx-!|OA1-T^ysmr}lx}lE<&2Kkv!t$Ty&j$jea-sViF0htdU;W{{y`e(r6gtlJ)h zx~^IpbT{aHN!{cx1a9vPbf_HLjbdOqq^sE3{;~(T=dM__cK9;4-d=jX5#OziaGd-W z^Jn8QYuB)$J%8++T?4+ho#mXI#T3>TlM2IH1*-&Bh+Dg+FBSsjyxuwcDmE%#>YTm8 z@b%8wmw?e%E&A`YN=}Eu_rWOUzq5k)qYDP!!jk{Zt(+nFB@^hjjc{DN5cmbCrMB6U zvTEpwcHc4euSWj0bb}Gyb|3Wop$O|;-L}Dq<^$ER*Q>Fmxf(D20KUuicZ`D61H!%` z_`Is?I=Yam*;RKXm%UBus`;aA!|b_ihe>@PmtAJ8FEUnVE_=rW;s_&JJf+d2V^=S0 z{oR(xIkOYx?C;)i4ks&HSd;7+zQ}=!oU>pqKU*ylMar9vcsfGm`%(7MyLJ$%Ixt1b zZz8MQ6*ypj+jsB4#vGU?;oxlD0SjvM@>v!%y2YQ{K}t{Vk!~|ZG^f&qJUY;6ZD(0_ zp<>V+(v@!X4(mw6Mq3vtSae%IXjEgVm7PEq%I#+UNZDoBMT-4o2~GNS+W;%|cB4|a z;i$uK*yM}~?S|KabM%s#okwSu*?+sy`&7~OT2C(ru@Sgz{z{MIbBxT~f zEPLET)w@Z94yGg-mz6$=k170cCL<(yVanqUi?Jy=nK7<0`vZrD0)rm6qknLa`5#ig zpz_j8ct%$E^geMSBc)?XDkB;)8m4|4#LrQ~M4zeMmb#HoeVk`;afrW(XWop{6TE*l zK8hOkQJ;{J`GJ_25O~^Z9_FQVN<>*|#lo%69F3)vU`7h3#FGMlaD0-FEA)zKFRuhn zr<6WitQ)$X)`L^LSSKH7J)jCo>Y*7{MG|#iSX?erU+z>8VtdUZ}38X2d9N*FlNrYkKq!tl}|&vFNSpx>qo6dRz-4WTEsX z5)#^g=uYz!@Wg4R5#c2n`xrPKr6*hV3YqbmGs@Sfs=G!%Bm{wIQ%fi#D+k~;c9Msu zr&%?kDKU{bHJn6OC2A$um%!Oe0Z~m?g)&)MPsvkKN>nDIbT}M1gbp)2vi+}rGn_zA zm_V~rg24{Z1Ar00Tc0301(*l0dv*rAEZ_;ivjAq`zZ(GCndyO0Zn>0S~ zblGpL3pf zE;uVrw`-Rx=sMs!>Uz}myz82)?E19(LAS%*>khhy+#~KEx!-XA$^AF?=RBYHWId02 zp7DIcbJ4Tl`K{-=NB3B~_j)&ad%Q=zlirN?%U;d JAVA_RUNTIME_VERSION=) +!define JREVersion "17.0.10+7" +!define JREDownloadURL "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.10%2B7/OpenJDK17U-jre_x64_windows_hotspot_17.0.10_7.zip" +!define JREDownloadedFileZip "OpenJDK17U-jre_x64_windows_hotspot_17.0.10_7.zip" +Var JREneedInstall + +Var /GLOBAL SteamVRResult +Var /GLOBAL SteamVRLabelID +Var /GLOBAL SteamVRLabelTxt +Var /GLOBAL TestProcessReturn +Var /GLOBAL SlimeVRRunning +Var /GLOBAL SlimeVRLabelID +Var /GLOBAL SlimeVRLabelTxt # Define name of installer Name "SlimeVR" @@ -28,7 +47,7 @@ InstallDir "$PROGRAMFILES\SlimeVR Server" ; $InstDir default value. Defaults to ShowInstDetails show ShowUninstDetails show -BrandingText "SlimeVR Installer 0.1.9" +BrandingText "SlimeVR Installer 0.2.0" # Admin rights are required for: # 1. Removing Start Menu shortcut in Windows 7+ @@ -60,6 +79,9 @@ Function .onInit StrCpy $STEAMDIR $0 FunctionEnd +!insertmacro ProcessCheck "un." "SteamVRResult" +!insertmacro ProcessCheck "" "SteamVRResult" + # Detect Steam installation and just write path that we need to remove during uninstall (if present) Function un.onInit ${If} ${RunningX64} @@ -72,15 +94,7 @@ FunctionEnd # Clean up on exit Function cleanTemp - Delete "$TEMP\slimevr-openvr-driver-win64.zip" - Delete "$TEMP\SlimeVR-win64.zip" - Delete "$TEMP\OpenJDK17U-jre_x64_windows_hotspot_17.0.4.1_1.zip" - Delete "$TEMP\SlimeVR-Feeder-App-win64.zip" - RMDir /r "$TEMP\slimevr-openvr-driver-win64" - RMDir /r "$TEMP\SlimeVR" - RMDir /r "$TEMP\OpenJDK17U-jre_x64_windows_hotspot_17.0.4.1_1" - RMDir /r "$TEMP\slimevr_usb_drivers_inst" - RMDir /r "$TEMP\SlimeVR-Feeder-App-win64" + RMDir /r "${SLIMETEMP}" FunctionEnd Function .onInstFailed @@ -130,7 +144,10 @@ Page Custom startPage startPageLeave Page Custom endPage endPageLeave -!insertmacro MUI_UNPAGE_CONFIRM + +# Set MUI_UNCONFIMPAGE to get the translations +!insertmacro MUI_SET MUI_UNCONFIRMPAGE "" +UninstPage custom un.startPageConfirm un.endPageunConfirm !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_LANGUAGE "English" @@ -139,6 +156,7 @@ LangString START_PAGE_TITLE ${LANG_ENGLISH} "Welcome" LangString START_PAGE_SUBTITLE ${LANG_ENGLISH} "Welcome to SlimeVR Setup!" Function startPage + Call UpdateLabelTimer !insertmacro MUI_HEADER_TEXT $(START_PAGE_TITLE) $(START_PAGE_SUBTITLE) nsDialogs::Create 1018 Pop $0 @@ -169,20 +187,28 @@ Function startPage Pop $0 ${EndIf} + ${NSD_CreateLabel} 0 90u 100% 10u '$SteamVRLabelTxt' + Pop $SteamVRLabelID + ${NSD_CreateLabel} 0 100u 100% 10u '$SlimeVRLabelTxt' + Pop $SlimeVRLabelID + GetFunctionAddress $0 UpdateLabelTimer + nsDialogs::CreateTimer $0 2000 ; Set the timer interval to 1000 milliseconds (1 second) + nsDialogs::Show FunctionEnd Function startPageLeave + GetFunctionAddress $0 UpdateLabelTimer + nsDialogs::KillTimer $0 + ${NSD_GetState} $UPDATE $0 + ${NSD_GetState} $REPAIR $1 - ${NSD_GetState} $UPDATE $0 - ${NSD_GetState} $REPAIR $1 - - ${If} $0 = 1 - StrCpy $SELECTED_INSTALLER_ACTION "update" - ${ElseIf} $1 = 1 - StrCpy $SELECTED_INSTALLER_ACTION "repair" - ${EndIf} + ${If} $0 = 1 + StrCpy $SELECTED_INSTALLER_ACTION "update" + ${ElseIf} $1 = 1 + StrCpy $SELECTED_INSTALLER_ACTION "repair" + ${EndIf} FunctionEnd @@ -255,6 +281,23 @@ Function installerActionPre ${EndIf} FunctionEnd +# Provides a easy function to determit if the JRE is the desired Version or not +Function JREdetect + IfFileExists "$INSTDIR\jre\release" 0 SEC_JRE_JAVAVERSIONELSE + ${ConfigRead} "$INSTDIR\jre\release" "JAVA_RUNTIME_VERSION=" $R0 +; DetailPrint "Java JRE: $INSTDIR\jre\release JAVA_RUNTIME_VERSION=$R0" + ${If} $R0 == "$\"${JREVersion}$\"" + StrCpy $JREneedInstall "False" + ${Else} + StrCpy $JREneedInstall "True" + ${EndIf} + Goto SEC_JRE_JAVAVERSIONDONE + SEC_JRE_JAVAVERSIONELSE: + StrCpy $JREneedInstall "True" +; DetailPrint "Java JRE: $INSTDIR\jre\release File Not Found" + SEC_JRE_JAVAVERSIONDONE: +FunctionEnd + # GetTime function macro to get datetime !insertmacro GetTime @@ -299,20 +342,59 @@ Function DumpLog Exch $5 FunctionEnd +# Uninstall Confirm Page Clone to add some Labels +Function un.startPageConfirm + nsDialogs::Create 1018 + Pop $0 + ${If} $0 == error + Abort + ${EndIf} + + !insertmacro MUI_HEADER_TEXT $(MUI_UNTEXT_CONFIRM_TITLE) $(MUI_UNTEXT_CONFIRM_SUBTITLE) + + ; Uninstalling Text + ${NSD_CreateLabel} 0 0 450 30 "$(^UninstallingText)" + + ; Uninstalling Path Text + ${NSD_CreateLabel} 0 68 98 20 "$(^UninstallingSubText)" + + ; Uninstalling Path + ${NSD_CreateText} 98 65 350 20 "$INSTDIR" + Pop $0 + SendMessage $0 ${EM_SETREADONLY} 1 0 + + ; Create the SteamVR Warning Label + ${NSD_CreateLabel} 0 90u 100% 10u '$SteamVRLabelTxt' + Pop $SteamVRLabelID + ${NSD_CreateLabel} 0 100u 100% 10u '$SlimeVRLabelTxt' + Pop $SlimeVRLabelID + + Call un.UpdateLabelTimer + GetFunctionAddress $0 un.UpdateLabelTimer + nsDialogs::CreateTimer /NOUNLOAD $0 2000 ; Set the timer interval to 2000 milliseconds (2 second) + + nsDialogs::Show +FunctionEnd + +Function un.endPageunConfirm + GetFunctionAddress $0 un.UpdateLabelTimer + nsDialogs::KillTimer $0 +FunctionEnd + Section "SlimeVR Server" SEC_SERVER SectionIn RO SetOutPath $INSTDIR DetailPrint "Downloading SlimeVR Server..." - NScurl::http GET "https://github.com/SlimeVR/SlimeVR-Server/releases/latest/download/SlimeVR-win64.zip" "$TEMP\SlimeVR-win64.zip" /CANCEL /RESUME /END + NScurl::http GET "https://github.com/SlimeVR/SlimeVR-Server/releases/latest/download/SlimeVR-win64.zip" "${SLIMETEMP}\SlimeVR-win64.zip" /CANCEL /RESUME /END Pop $0 ; Status text ("OK" for success) ${If} $0 != "OK" Abort "Failed to download SlimeVR Server. Reason: $0." ${EndIf} DetailPrint "Downloaded!" - nsisunz::Unzip "$TEMP\SlimeVR-win64.zip" "$TEMP\SlimeVR\" + nsisunz::Unzip "${SLIMETEMP}\SlimeVR-win64.zip" "${SLIMETEMP}\SlimeVR\" Pop $0 DetailPrint "Unzipping finished with $0." @@ -321,7 +403,7 @@ Section "SlimeVR Server" SEC_SERVER ${EndIf} DetailPrint "Copying SlimeVR Server to installation folder..." - CopyFiles /SILENT "$TEMP\SlimeVR\SlimeVR\*" $INSTDIR + CopyFiles /SILENT "${SLIMETEMP}\SlimeVR\SlimeVR\*" $INSTDIR IfFileExists "$INSTDIR\slimevr-ui.exe" found not_found found: @@ -341,10 +423,10 @@ Section "Webview2" SEC_WEBVIEW # Read Only protects it from Installing when it is not needed DetailPrint "Downloading webview2!" - NScurl::http GET "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" /CANCEL /RESUME /END + NScurl::http GET "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "${SLIMETEMP}\MicrosoftEdgeWebView2RuntimeInstaller.exe" /CANCEL /RESUME /END DetailPrint "Installing webview2!" - nsExec::ExecToLog '"$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" /silent /install' $0 + nsExec::ExecToLog '"${SLIMETEMP}\MicrosoftEdgeWebView2RuntimeInstaller.exe" /silent /install' $0 Pop $0 DetailPrint "Installing finished with $0." ${If} $0 != 0 @@ -356,28 +438,42 @@ SectionEnd Section "Java JRE" SEC_JRE SectionIn RO - Var /GLOBAL DownloadedJreFile - DetailPrint "Downloading Java JRE 17..." - NScurl::http GET "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.4.1%2B1/OpenJDK17U-jre_x64_windows_hotspot_17.0.4.1_1.zip" "$TEMP\OpenJDK17U-jre_x64_windows_hotspot_17.0.4.1_1.zip" /CANCEL /RESUME /END - StrCpy $DownloadedJreFile "OpenJDK17U-jre_x64_windows_hotspot_17.0.4.1_1" + DetailPrint "Downloading Java JRE ${JREVersion}..." + NScurl::http GET "${JREDownloadURL}" "${SLIMETEMP}\${JREDownloadedFileZip}" /CANCEL /RESUME /END + Pop $0 ; Status text ("OK" for success) ${If} $0 != "OK" - Abort "Failed to download Java JRE 17. Reason: $0." + Abort "Failed to download Java JRE ${JREVersion}. Reason: $0." ${EndIf} DetailPrint "Downloaded!" - DetailPrint "Unzipping Java JRE 17 to installation folder...." - nsisunz::Unzip "$TEMP\$DownloadedJreFile.zip" "$TEMP\$DownloadedJreFile\" + # Make sure to delete all files on a update from jre, so if there is a new version no old files are left. + IfFileExists "$INSTDIR\jre" 0 SEC_JRE_DIRNOTFOUND + DetailPrint "Removing old Java JRE..." + RMdir /r "$INSTDIR\jre" + CreateDirectory "$INSTDIR\jre" + SEC_JRE_DIRNOTFOUND: + + DetailPrint "Unzipping Java JRE ${JREVersion} to installation folder...." + nsisunz::Unzip "${SLIMETEMP}\${JREDownloadedFileZip}" "${SLIMETEMP}\OpenJDK\" Pop $0 DetailPrint "Unzipping finished with $0." - CopyFiles /SILENT "$TEMP\$DownloadedJreFile\jdk-17.0.4.1+1-jre\*" "$INSTDIR\jre" + + FindFirst $0 $1 "${SLIMETEMP}\OpenJDK\jdk-17.*-jre" + loop: + StrCmp $1 "" done + CopyFiles /SILENT "${SLIMETEMP}\OpenJDK\$1\*" "$INSTDIR\jre" + FindNext $0 $1 + Goto loop + done: + FindClose $0 SectionEnd Section "SteamVR Driver" SEC_VRDRIVER SetOutPath $INSTDIR DetailPrint "Downloading SteamVR Driver..." - NScurl::http GET "https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-win64.zip" "$TEMP\slimevr-openvr-driver-win64.zip" /CANCEL /RESUME /END + NScurl::http GET "https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-win64.zip" "${SLIMETEMP}\slimevr-openvr-driver-win64.zip" /CANCEL /RESUME /END Pop $0 ; Status text ("OK" for success) ${If} $0 != "OK" Abort "Failed to download SteamVR Driver. Reason: $0." @@ -385,7 +481,7 @@ Section "SteamVR Driver" SEC_VRDRIVER DetailPrint "Downloaded!" DetailPrint "Unpacking downloaded files..." - nsisunz::Unzip "$TEMP\slimevr-openvr-driver-win64.zip" "$TEMP\slimevr-openvr-driver-win64\" + nsisunz::Unzip "${SLIMETEMP}\slimevr-openvr-driver-win64.zip" "${SLIMETEMP}\slimevr-openvr-driver-win64\" Pop $0 DetailPrint "Unzipping finished with $0." @@ -395,7 +491,7 @@ Section "SteamVR Driver" SEC_VRDRIVER DetailPrint "Copying SteamVR Driver to SteamVR..." # If powershell is present - rely on automatic detection. ${DisableX64FSRedirection} - nsExec::ExecToLog '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -File "$INSTDIR\steamvr.ps1" -SteamPath "$STEAMDIR" -DriverPath "$TEMP\slimevr-openvr-driver-win64\slimevr"' $0 + nsExec::ExecToLog '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -File "$INSTDIR\steamvr.ps1" -SteamPath "$STEAMDIR" -DriverPath "${SLIMETEMP}\slimevr-openvr-driver-win64\slimevr"' $0 ${EnableX64FSRedirection} Pop $0 ${If} $0 != 0 @@ -404,7 +500,7 @@ Section "SteamVR Driver" SEC_VRDRIVER ${If} $0 == "error" Abort "Failed to copy SlimeVR Driver." ${Endif} - CopyFiles /SILENT "$TEMP\slimevr-openvr-driver-win64\slimevr" "$0\drivers\slimevr" + CopyFiles /SILENT "${SLIMETEMP}\slimevr-openvr-driver-win64\slimevr" "$0\drivers\slimevr" ${EndIf} SectionEnd @@ -412,7 +508,7 @@ Section "SlimeVR Feeder App" SEC_FEEDER_APP SetOutPath $INSTDIR DetailPrint "Downloading SlimeVR Feeder App..." - NScurl::http GET "https://github.com/SlimeVR/SlimeVR-Feeder-App/releases/latest/download/SlimeVR-Feeder-App-win64.zip" "$TEMP\SlimeVR-Feeder-App-win64.zip" /CANCEL /RESUME /END + NScurl::http GET "https://github.com/SlimeVR/SlimeVR-Feeder-App/releases/latest/download/SlimeVR-Feeder-App-win64.zip" "${SLIMETEMP}\SlimeVR-Feeder-App-win64.zip" /CANCEL /RESUME /END Pop $0 ; Status text ("OK" for success) ${If} $0 != "OK" Abort "Failed to download SlimeVR Feeder App. Reason: $0." @@ -420,12 +516,12 @@ Section "SlimeVR Feeder App" SEC_FEEDER_APP DetailPrint "Downloaded!" DetailPrint "Unpacking downloaded files..." - nsisunz::Unzip "$TEMP\SlimeVR-Feeder-App-win64.zip" "$TEMP" + nsisunz::Unzip "${SLIMETEMP}\SlimeVR-Feeder-App-win64.zip" "${SLIMETEMP}" Pop $0 DetailPrint "Unzipping finished with $0." DetailPrint "Copying SlimeVR Feeder App..." - CopyFiles /SILENT "$TEMP\SlimeVR-Feeder-App-win64\*" "$INSTDIR\Feeder-App" + CopyFiles /SILENT "${SLIMETEMP}\SlimeVR-Feeder-App-win64\*" "$INSTDIR\Feeder-App" DetailPrint "Installing SlimeVR Feeder App driver..." nsExec::ExecToLog '"$INSTDIR\Feeder-App\SlimeVR-Feeder-App.exe" --install' @@ -435,11 +531,11 @@ SectionGroup /e "USB drivers" SEC_USBDRIVERS Section "CP210x driver" SEC_CP210X # CP210X drivers (NodeMCU v2) - SetOutPath "$TEMP\slimevr_usb_drivers_inst\CP201x" + SetOutPath "${SLIMETEMP}\slimevr_usb_drivers_inst\CP201x" DetailPrint "Installing CP210x driver..." File /r "CP201x\*" ${DisableX64FSRedirection} - nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "$TEMP\slimevr_usb_drivers_inst\CP201x\silabser.inf"' $0 + nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "${SLIMETEMP}\slimevr_usb_drivers_inst\CP201x\silabser.inf"' $0 ${EnableX64FSRedirection} Pop $0 ${If} $0 == 0 @@ -455,11 +551,11 @@ SectionGroup /e "USB drivers" SEC_USBDRIVERS Section "CH340 driver" SEC_CH340 # CH340 drivers (NodeMCU v3) - SetOutPath "$TEMP\slimevr_usb_drivers_inst\CH341SER" + SetOutPath "${SLIMETEMP}\slimevr_usb_drivers_inst\CH341SER" DetailPrint "Installing CH340 driver..." File /r "CH341SER\*" ${DisableX64FSRedirection} - nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "$TEMP\slimevr_usb_drivers_inst\CH341SER\CH341SER.INF"' $0 + nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "${SLIMETEMP}\slimevr_usb_drivers_inst\CH341SER\CH341SER.INF"' $0 ${EnableX64FSRedirection} Pop $0 ${If} $0 == 0 @@ -475,11 +571,11 @@ SectionGroup /e "USB drivers" SEC_USBDRIVERS Section /o "CH9102x driver" SEC_CH9102X # CH343 drivers (NodeMCU v2.1, some NodeMCU v3?) - SetOutPath "$TEMP\slimevr_usb_drivers_inst\CH343SER" + SetOutPath "${SLIMETEMP}\slimevr_usb_drivers_inst\CH343SER" DetailPrint "Installing CH910x driver..." File /r "CH343SER\*" ${DisableX64FSRedirection} - nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "$TEMP\slimevr_usb_drivers_inst\CH343SER\CH343SER.INF"' $0 + nsExec::Exec '"$SYSDIR\PnPutil.exe" -i -a "${SLIMETEMP}\slimevr_usb_drivers_inst\CH343SER\CH343SER.INF"' $0 ${EnableX64FSRedirection} Pop $0 ${If} $0 == 0 @@ -541,10 +637,10 @@ Section SectionEnd Function componentsPre + Call JREdetect ${If} $SELECTED_INSTALLER_ACTION == "update" SectionSetFlags ${SEC_FIREWALL} 0 SectionSetFlags ${SEC_REGISTERAPP} 0 - SectionSetFlags ${SEC_JRE} ${SF_SELECTED} SectionSetFlags ${SEC_WEBVIEW} ${SF_SELECTED} SectionSetFlags ${SEC_USBDRIVERS} ${SF_SECGRP} SectionSetFlags ${SEC_SERVER} ${SF_SELECTED} @@ -558,7 +654,19 @@ Function componentsPre SectionSetFlags ${SEC_FEEDER_APP} ${SF_SELECTED} ${EndIf} + # Select JRE Mandatory if not found or outdated on Repair Preselect it + ${If} $JREneedInstall == "True" + SectionSetFlags ${SEC_JRE} ${SF_SELECTED}|${SF_RO} + ${ElseIf} $SELECTED_INSTALLER_ACTION == "repair" + SectionSetFlags ${SEC_JRE} ${SF_SELECTED} + ${Else} + SectionSetFlags ${SEC_JRE} ${SF_USELECTED} + ${EndIf} + # Detect WebView2 + # https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#detect-if-a-suitable-webview2-runtime-is-already-installed + # Trying to solve #41 Installer doesn't always install WebView2 + # Ignoring only user installed WebView2 it seems to make problems ${If} ${RunningX64} ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv" ReadRegStr $1 HKCU "Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv" @@ -567,11 +675,25 @@ Function componentsPre ReadRegStr $1 HKCU "Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv" ${EndIf} + ${If} $0 == "" + ${OrIf} $0 == "0.0.0.0" + StrCpy $0 "" + ${Else} + StrCpy $0 "1" + ${EndIf} + + ${If} $1 == "" + ${OrIf} $1 == "0.0.0.0" + StrCpy $1 "" + ${Else} + StrCpy $1 "1" + ${EndIf} + ${If} $0 == "" ${AndIf} $1 == "" SectionSetFlags ${SEC_WEBVIEW} ${SF_SELECTED}|${SF_RO} ${Else} - SectionSetFlags ${SEC_WEBVIEW} ${SF_USELECTED}|${SF_RO} + SectionSetFlags ${SEC_WEBVIEW} ${SF_USELECTED} ${EndIf} FunctionEnd @@ -653,6 +775,9 @@ LangString DESC_SEC_CP210X ${LANG_ENGLISH} "Installs CP210X USB driver that come LangString DESC_SEC_CH340 ${LANG_ENGLISH} "Installs CH340 USB driver that comes with the following boards: NodeMCU v3, SlimeVR, Wemos D1 Mini." LangString DESC_SEC_CH9102x ${LANG_ENGLISH} "Installs CH9102x USB driver that comes with the following boards: NodeMCU v2.1." LangString DESC_STEAM_NOTFOUND ${LANG_ENGLISH} "No Steam installation detected. Steam and SteamVR are required to be installed and run at least once to install the SteamVR Driver." +LangString DESC_STEAMVR_RUNNING ${LANG_ENGLISH} "SteamVR is running! Please close SteamVR." +LangString DESC_SLIMEVR_RUNNING ${LANG_ENGLISH} "SlimeVR is running! Please close SlimeVR." +LangString DESC_PROCESS_ERROR ${LANG_ENGLISH} "An error happend while trying for look for $0 nsProcess::FindProcess Returns " !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SEC_SERVER} $(DESC_SEC_SERVER) diff --git a/windows/web/steamdetect.nsh b/windows/web/steamdetect.nsh new file mode 100644 index 0000000..012d81e --- /dev/null +++ b/windows/web/steamdetect.nsh @@ -0,0 +1,85 @@ +# check if one of the Processes is running to warn the user. +# vrwebhelper.exe +# vrserver.exe +# vrmonitor.exe +# vrdashboard.exe +# vrcompositor.exe +!macro ProcessCheck un GLOBVARRETURN + +Function ${un}SteamVRTest + StrCpy $${GLOBVARRETURN} "NotFound" + Push "vrwebhelper.exe" + Call ${un}TestProcess + Push "vrserver.exe" + Call ${un}TestProcess + Push "vrmonitor.exe" + Call ${un}TestProcess + Push "vrdashboard.exe" + Call ${un}TestProcess + Push "vrcompositor.exe" + Call ${un}TestProcess +# MessageBox MB_OK "SteamVRTest Result $${GLOBVARRETURN}" +FunctionEnd + +Function ${un}TestProcess + Pop $0 + ${nsProcess::FindProcess} $0 $TestProcessReturn +# MessageBox MB_OK "TestProcess $0 Result $TestProcessReturn" + ${if} $TestProcessReturn = 0 + StrCpy $${GLOBVARRETURN} "Found" + ${elseif} $TestProcessReturn != 603 + MessageBox MB_OK "$(DESC_PROCESS_ERROR) $TestProcessReturn" + # An error happend while trying for look for $0 nsProcess::FindProcess Returns $TestProcessReturn + StrCpy $${GLOBVARRETURN} "Error" + ${EndIf} +FunctionEnd + +Function ${un}NextButtonDisable + GetDlgItem $0 $hwndparent 1 ; 1 is the ID of the Next button + EnableWindow $0 0 +FunctionEnd + +Function ${un}NextButtonEnable + GetDlgItem $0 $hwndparent 1 ; 1 is the ID of the Next button + EnableWindow $0 1 +FunctionEnd + + +Function ${un}UpdateLabelTimer + ; Test if SlimeVR is Running + StrCpy $${GLOBVARRETURN} "NotFound" + Push "slimevr.exe" + Call ${un}TestProcess + StrCpy $SlimeVRRunning $${GLOBVARRETURN} + ; Test if SteamVR is Running + Call ${un}SteamVRTest + + ; Set the Warning lable for SteamVR + ${If} $${GLOBVARRETURN} == "Found" + StrCpy $SteamVRLabelTxt $(DESC_STEAMVR_RUNNING) + ${ElseIf} $${GLOBVARRETURN} == "NotFound" + StrCpy $SteamVRLabelTxt "" + ${EndIf} + + ; Set the Warning lable for SlimeVR + ${If} $SlimeVRRunning == "Found" + StrCpy $SlimeVRLabelTxt $(DESC_SLIMEVR_RUNNING) + ${ElseIf} $SlimeVRRunning == "NotFound" + StrCpy $SlimeVRLabelTxt "" + ${EndIf} + + ; Logic for Enable Disable the Buttons + ${If} $${GLOBVARRETURN} == "Found" + ${OrIf} $SlimeVRRunning == "Found" + Call ${un}NextButtonDisable + ${ElseIf} $${GLOBVARRETURN} == "NotFound" + ${AndIf} $SlimeVRRunning == "NotFound" + Call ${un}NextButtonEnable + ${EndIf} +# MessageBox MB_OK "SteamVRTest Result $SteamVRLabelTxt" + ${NSD_SetText} $SteamVRLabelID $SteamVRLabelTxt + ${NSD_SetText} $SlimeVRLabelID $SlimeVRLabelTxt +FunctionEnd + +!macroend +