DXGL r835 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r834‎ | r835 | r836 >
Date:01:39, 14 July 2018
Author:admin
Status:new
Tags:
Comment:
Add detection for SSE2 processors.
Rename DXGL installer plugin, as it is no longer just SHA-512.
Modified paths:
  • /Installer/dxgl.nsi (modified) (history)
  • /dxgl-nsis (added) (history)
  • /dxgl-nsis/LibSha512.c (added) (history)
  • /dxgl-nsis/LibSha512.h (added) (history)
  • /dxgl-nsis/api.h (added) (history)
  • /dxgl-nsis/dxgl-nsis.c (added) (history)
  • /dxgl-nsis/dxgl-nsis.vcxproj (added) (history)
  • /dxgl-nsis/dxgl-nsis.vcxproj.filters (added) (history)
  • /dxgl-nsis/pluginapi.c (added) (history)
  • /dxgl-nsis/pluginapi.h (added) (history)
  • /dxgl.sln (modified) (history)
  • /sha512-nsis (deleted) (history)

Diff [purge]

Index: sha512-nsis/api.h
@@ -1,83 +0,0 @@
2 -/*
3 - * apih
4 - *
5 - * This file is a part of NSIS.
6 - *
7 - * Copyright (C) 1999-2009 Nullsoft and Contributors
8 - *
9 - * Licensed under the zlib/libpng license (the "License");
10 - * you may not use this file except in compliance with the License.
11 - *
12 - * Licence details can be found in the file COPYING.
13 - *
14 - * This software is provided 'as-is', without any express or implied
15 - * warranty.
16 - */
17 -
18 -#ifndef _NSIS_EXEHEAD_API_H_
19 -#define _NSIS_EXEHEAD_API_H_
20 -
21 -// Starting with NSIS 2.42, you can check the version of the plugin API in exec_flags->plugin_api_version
22 -// The format is 0xXXXXYYYY where X is the major version and Y is the minor version (MAKELONG(y,x))
23 -// When doing version checks, always remember to use >=, ex: if (pX->exec_flags->plugin_api_version >= NSISPIAPIVER_1_0) {}
24 -
25 -#define NSISPIAPIVER_1_0 0x00010000
26 -#define NSISPIAPIVER_CURR NSISPIAPIVER_1_0
27 -
28 -// NSIS Plug-In Callback Messages
29 -enum NSPIM
30 -{
31 - NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
32 - NSPIM_GUIUNLOAD, // Called after .onGUIEnd
33 -};
34 -
35 -// Prototype for callbacks registered with extra_parameters->RegisterPluginCallback()
36 -// Return NULL for unknown messages
37 -// Should always be __cdecl for future expansion possibilities
38 -typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM);
39 -
40 -// extra_parameters data structures containing other interesting stuff
41 -// but the stack, variables and HWND passed on to plug-ins.
42 -typedef struct
43 -{
44 - int autoclose;
45 - int all_user_var;
46 - int exec_error;
47 - int abort;
48 - int exec_reboot; // NSIS_SUPPORT_REBOOT
49 - int reboot_called; // NSIS_SUPPORT_REBOOT
50 - int XXX_cur_insttype; // depreacted
51 - int plugin_api_version; // see NSISPIAPIVER_CURR
52 - // used to be XXX_insttype_changed
53 - int silent; // NSIS_CONFIG_SILENT_SUPPORT
54 - int instdir_error;
55 - int rtl;
56 - int errlvl;
57 - int alter_reg_view;
58 - int status_update;
59 -} exec_flags_t;
60 -
61 -#ifndef NSISCALL
62 -# define NSISCALL __stdcall
63 -#endif
64 -
65 -typedef struct {
66 - exec_flags_t *exec_flags;
67 - int (NSISCALL *ExecuteCodeSegment)(int, HWND);
68 - void (NSISCALL *validate_filename)(char *);
69 - int (NSISCALL *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK); // returns 0 on success, 1 if already registered and < 0 on errors
70 -} extra_parameters;
71 -
72 -// Definitions for page showing plug-ins
73 -// See Ui.c to understand better how they're used
74 -
75 -// sent to the outer window to tell it to go to the next inner window
76 -#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
77 -
78 -// custom pages should send this message to let NSIS know they're ready
79 -#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
80 -
81 -// sent as wParam with WM_NOTIFY_OUTER_NEXT when user cancels - heed its warning
82 -#define NOTIFY_BYE_BYE 'x'
83 -
84 -#endif /* _PLUGIN_H_ */
Index: sha512-nsis/LibSha512.h
@@ -1,78 +0,0 @@
2 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3 -// LibSha512
4 -//
5 -// Implementation of SHA512 hash function.
6 -// Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org
7 -// Modified by WaterJuice retaining Public Domain license.
8 -//
9 -// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
10 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11 -
12 -#ifndef _LibSha512_h_
13 -#define _LibSha512_h_
14 -
15 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 -// IMPORTS
17 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
18 -
19 -#include <stdint.h>
20 -#include <stdio.h>
21 -
22 -typedef struct
23 -{
24 - uint64_t length;
25 - uint64_t state[8];
26 - uint32_t curlen;
27 - uint8_t buf[128];
28 -} Sha512Context;
29 -
30 -#define SHA512_HASH_SIZE ( 512 / 8 )
31 -
32 -typedef struct
33 -{
34 - uint8_t bytes [SHA512_HASH_SIZE];
35 -} SHA512_HASH;
36 -
37 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
38 -// PUBLIC FUNCTIONS
39 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40 -
41 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42 -// Sha512Initialise
43 -//
44 -// Initialises a SHA512 Context. Use this to initialise/reset a context.
45 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
46 -void Sha512Initialise
47 - (
48 - Sha512Context* Context
49 - );
50 -
51 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52 -// Sha512Update
53 -//
54 -// Adds data to the SHA512 context. This will process the data and update the internal state of the context. Keep on
55 -// calling this function until all the data has been added. Then call Sha512Finalise to calculate the hash.
56 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
57 -void Sha512Update
58 - (
59 - Sha512Context* Context,
60 - void* Buffer,
61 - uint32_t BufferSize
62 - );
63 -
64 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
65 -// Sha512Finalise
66 -//
67 -// Performs the final calculation of the hash and returns the digest (64 byte buffer containing 512bit hash). After
68 -// calling this, Sha512Initialised must be used to reuse the context.
69 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
70 -void
71 - Sha512Finalise
72 - (
73 - Sha512Context* Context,
74 - SHA512_HASH* Digest
75 - );
76 -
77 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
78 -#endif //_LibSha512_h_
79 -
Index: sha512-nsis/sha512-nsis.vcxproj
@@ -1,170 +0,0 @@
2 -<?xml version="1.0" encoding="utf-8"?>
3 -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 - <ItemGroup Label="ProjectConfigurations">
5 - <ProjectConfiguration Include="Debug VS2017|Win32">
6 - <Configuration>Debug VS2017</Configuration>
7 - <Platform>Win32</Platform>
8 - </ProjectConfiguration>
9 - <ProjectConfiguration Include="Debug|Win32">
10 - <Configuration>Debug</Configuration>
11 - <Platform>Win32</Platform>
12 - </ProjectConfiguration>
13 - <ProjectConfiguration Include="Release VS2017|Win32">
14 - <Configuration>Release VS2017</Configuration>
15 - <Platform>Win32</Platform>
16 - </ProjectConfiguration>
17 - <ProjectConfiguration Include="Release|Win32">
18 - <Configuration>Release</Configuration>
19 - <Platform>Win32</Platform>
20 - </ProjectConfiguration>
21 - </ItemGroup>
22 - <PropertyGroup Label="Globals">
23 - <ProjectGuid>{F822EDB0-63E2-4EB8-B80D-F72481CDE3E1}</ProjectGuid>
24 - <Keyword>Win32Proj</Keyword>
25 - <RootNamespace>sha512nsis</RootNamespace>
26 - </PropertyGroup>
27 - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28 - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29 - <ConfigurationType>DynamicLibrary</ConfigurationType>
30 - <UseDebugLibraries>true</UseDebugLibraries>
31 - <PlatformToolset>v100</PlatformToolset>
32 - <CharacterSet>MultiByte</CharacterSet>
33 - </PropertyGroup>
34 - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'" Label="Configuration">
35 - <ConfigurationType>DynamicLibrary</ConfigurationType>
36 - <UseDebugLibraries>true</UseDebugLibraries>
37 - <PlatformToolset>v141</PlatformToolset>
38 - <CharacterSet>MultiByte</CharacterSet>
39 - </PropertyGroup>
40 - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
41 - <ConfigurationType>DynamicLibrary</ConfigurationType>
42 - <UseDebugLibraries>false</UseDebugLibraries>
43 - <PlatformToolset>v100</PlatformToolset>
44 - <WholeProgramOptimization>true</WholeProgramOptimization>
45 - <CharacterSet>MultiByte</CharacterSet>
46 - </PropertyGroup>
47 - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'" Label="Configuration">
48 - <ConfigurationType>DynamicLibrary</ConfigurationType>
49 - <UseDebugLibraries>false</UseDebugLibraries>
50 - <PlatformToolset>v141</PlatformToolset>
51 - <WholeProgramOptimization>true</WholeProgramOptimization>
52 - <CharacterSet>MultiByte</CharacterSet>
53 - </PropertyGroup>
54 - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
55 - <ImportGroup Label="ExtensionSettings">
56 - </ImportGroup>
57 - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
58 - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
59 - </ImportGroup>
60 - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'" Label="PropertySheets">
61 - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62 - </ImportGroup>
63 - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64 - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65 - </ImportGroup>
66 - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'" Label="PropertySheets">
67 - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68 - </ImportGroup>
69 - <PropertyGroup Label="UserMacros" />
70 - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
71 - <LinkIncremental>true</LinkIncremental>
72 - <GenerateManifest>false</GenerateManifest>
73 - </PropertyGroup>
74 - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'">
75 - <LinkIncremental>true</LinkIncremental>
76 - <GenerateManifest>false</GenerateManifest>
77 - </PropertyGroup>
78 - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79 - <LinkIncremental>false</LinkIncremental>
80 - <GenerateManifest>false</GenerateManifest>
81 - </PropertyGroup>
82 - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'">
83 - <LinkIncremental>false</LinkIncremental>
84 - <GenerateManifest>false</GenerateManifest>
85 - </PropertyGroup>
86 - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
87 - <ClCompile>
88 - <PrecompiledHeader>
89 - </PrecompiledHeader>
90 - <WarningLevel>Level3</WarningLevel>
91 - <Optimization>Disabled</Optimization>
92 - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SHA512NSIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
93 - <BufferSecurityCheck>false</BufferSecurityCheck>
94 - <BasicRuntimeChecks>Default</BasicRuntimeChecks>
95 - </ClCompile>
96 - <Link>
97 - <SubSystem>Windows</SubSystem>
98 - <GenerateDebugInformation>true</GenerateDebugInformation>
99 - <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
100 - <EntryPointSymbol>DllMain</EntryPointSymbol>
101 - </Link>
102 - </ItemDefinitionGroup>
103 - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'">
104 - <ClCompile>
105 - <PrecompiledHeader>
106 - </PrecompiledHeader>
107 - <WarningLevel>Level3</WarningLevel>
108 - <Optimization>Disabled</Optimization>
109 - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SHA512NSIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
110 - <BufferSecurityCheck>false</BufferSecurityCheck>
111 - <BasicRuntimeChecks>Default</BasicRuntimeChecks>
112 - </ClCompile>
113 - <Link>
114 - <SubSystem>Windows</SubSystem>
115 - <GenerateDebugInformation>true</GenerateDebugInformation>
116 - <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
117 - <EntryPointSymbol>DllMain</EntryPointSymbol>
118 - </Link>
119 - </ItemDefinitionGroup>
120 - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
121 - <ClCompile>
122 - <WarningLevel>Level3</WarningLevel>
123 - <PrecompiledHeader>
124 - </PrecompiledHeader>
125 - <Optimization>MinSpace</Optimization>
126 - <FunctionLevelLinking>true</FunctionLevelLinking>
127 - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SHA512NSIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
128 - <BufferSecurityCheck>false</BufferSecurityCheck>
129 - </ClCompile>
130 - <Link>
131 - <SubSystem>Windows</SubSystem>
132 - <GenerateDebugInformation>true</GenerateDebugInformation>
133 - <EnableCOMDATFolding>true</EnableCOMDATFolding>
134 - <OptimizeReferences>true</OptimizeReferences>
135 - <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
136 - <EntryPointSymbol>DllMain</EntryPointSymbol>
137 - </Link>
138 - </ItemDefinitionGroup>
139 - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'">
140 - <ClCompile>
141 - <WarningLevel>Level3</WarningLevel>
142 - <PrecompiledHeader>
143 - </PrecompiledHeader>
144 - <Optimization>MinSpace</Optimization>
145 - <FunctionLevelLinking>true</FunctionLevelLinking>
146 - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SHA512NSIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
147 - <BufferSecurityCheck>false</BufferSecurityCheck>
148 - </ClCompile>
149 - <Link>
150 - <SubSystem>Windows</SubSystem>
151 - <GenerateDebugInformation>true</GenerateDebugInformation>
152 - <EnableCOMDATFolding>true</EnableCOMDATFolding>
153 - <OptimizeReferences>true</OptimizeReferences>
154 - <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
155 - <EntryPointSymbol>DllMain</EntryPointSymbol>
156 - </Link>
157 - </ItemDefinitionGroup>
158 - <ItemGroup>
159 - <ClCompile Include="LibSha512.c" />
160 - <ClCompile Include="pluginapi.c" />
161 - <ClCompile Include="sha512-nsis.c" />
162 - </ItemGroup>
163 - <ItemGroup>
164 - <ClInclude Include="api.h" />
165 - <ClInclude Include="LibSha512.h" />
166 - <ClInclude Include="pluginapi.h" />
167 - </ItemGroup>
168 - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
169 - <ImportGroup Label="ExtensionTargets">
170 - </ImportGroup>
171 -</Project>
\ No newline at end of file
Index: sha512-nsis/pluginapi.c
@@ -1,191 +0,0 @@
2 -#include <windows.h>
3 -
4 -#include "pluginapi.h"
5 -
6 -unsigned int g_stringsize;
7 -stack_t **g_stacktop;
8 -char *g_variables;
9 -
10 -// utility functions (not required but often useful)
11 -
12 -int NSISCALL popstring(char *str)
13 -{
14 - stack_t *th;
15 - if (!g_stacktop || !*g_stacktop) return 1;
16 - th=(*g_stacktop);
17 - if (str) lstrcpyA(str,th->text);
18 - *g_stacktop = th->next;
19 - GlobalFree((HGLOBAL)th);
20 - return 0;
21 -}
22 -
23 -int NSISCALL popstringn(char *str, int maxlen)
24 -{
25 - stack_t *th;
26 - if (!g_stacktop || !*g_stacktop) return 1;
27 - th=(*g_stacktop);
28 - if (str) lstrcpynA(str,th->text,maxlen?maxlen:g_stringsize);
29 - *g_stacktop = th->next;
30 - GlobalFree((HGLOBAL)th);
31 - return 0;
32 -}
33 -
34 -void NSISCALL pushstring(const char *str)
35 -{
36 - stack_t *th;
37 - if (!g_stacktop) return;
38 - th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
39 - lstrcpynA(th->text,str,g_stringsize);
40 - th->next=*g_stacktop;
41 - *g_stacktop=th;
42 -}
43 -
44 -char * NSISCALL getuservariable(const int varnum)
45 -{
46 - if (varnum < 0 || varnum >= __INST_LAST) return NULL;
47 - return g_variables+varnum*g_stringsize;
48 -}
49 -
50 -void NSISCALL setuservariable(const int varnum, const char *var)
51 -{
52 - if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
53 - lstrcpyA(g_variables + varnum*g_stringsize, var);
54 -}
55 -
56 -// playing with integers
57 -
58 -int NSISCALL myatoi(const char *s)
59 -{
60 - int v=0;
61 - if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
62 - {
63 - s++;
64 - for (;;)
65 - {
66 - int c=*(++s);
67 - if (c >= '0' && c <= '9') c-='0';
68 - else if (c >= 'a' && c <= 'f') c-='a'-10;
69 - else if (c >= 'A' && c <= 'F') c-='A'-10;
70 - else break;
71 - v<<=4;
72 - v+=c;
73 - }
74 - }
75 - else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
76 - {
77 - for (;;)
78 - {
79 - int c=*(++s);
80 - if (c >= '0' && c <= '7') c-='0';
81 - else break;
82 - v<<=3;
83 - v+=c;
84 - }
85 - }
86 - else
87 - {
88 - int sign=0;
89 - if (*s == '-') sign++; else s--;
90 - for (;;)
91 - {
92 - int c=*(++s) - '0';
93 - if (c < 0 || c > 9) break;
94 - v*=10;
95 - v+=c;
96 - }
97 - if (sign) v = -v;
98 - }
99 -
100 - return v;
101 -}
102 -
103 -unsigned NSISCALL myatou(const char *s)
104 -{
105 - unsigned int v=0;
106 -
107 - for (;;)
108 - {
109 - unsigned int c=*s++;
110 - if (c >= '0' && c <= '9') c-='0';
111 - else break;
112 - v*=10;
113 - v+=c;
114 - }
115 - return v;
116 -}
117 -
118 -int NSISCALL myatoi_or(const char *s)
119 -{
120 - int v=0;
121 - if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
122 - {
123 - s++;
124 - for (;;)
125 - {
126 - int c=*(++s);
127 - if (c >= '0' && c <= '9') c-='0';
128 - else if (c >= 'a' && c <= 'f') c-='a'-10;
129 - else if (c >= 'A' && c <= 'F') c-='A'-10;
130 - else break;
131 - v<<=4;
132 - v+=c;
133 - }
134 - }
135 - else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
136 - {
137 - for (;;)
138 - {
139 - int c=*(++s);
140 - if (c >= '0' && c <= '7') c-='0';
141 - else break;
142 - v<<=3;
143 - v+=c;
144 - }
145 - }
146 - else
147 - {
148 - int sign=0;
149 - if (*s == '-') sign++; else s--;
150 - for (;;)
151 - {
152 - int c=*(++s) - '0';
153 - if (c < 0 || c > 9) break;
154 - v*=10;
155 - v+=c;
156 - }
157 - if (sign) v = -v;
158 - }
159 -
160 - // Support for simple ORed expressions
161 - if (*s == '|')
162 - {
163 - v |= myatoi_or(s+1);
164 - }
165 -
166 - return v;
167 -}
168 -
169 -int NSISCALL popint()
170 -{
171 - char buf[128];
172 - if (popstringn(buf,sizeof(buf)))
173 - return 0;
174 -
175 - return myatoi(buf);
176 -}
177 -
178 -int NSISCALL popint_or()
179 -{
180 - char buf[128];
181 - if (popstringn(buf,sizeof(buf)))
182 - return 0;
183 -
184 - return myatoi_or(buf);
185 -}
186 -
187 -void NSISCALL pushint(int value)
188 -{
189 - char buffer[1024];
190 - wsprintf(buffer, "%d", value);
191 - pushstring(buffer);
192 -}
Index: sha512-nsis/LibSha512.c
@@ -1,277 +0,0 @@
2 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3 -// LibSha512
4 -//
5 -// Implementation of SHA512 hash function.
6 -// Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org
7 -// Modified by WaterJuice retaining Public Domain license.
8 -//
9 -// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
10 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11 -
12 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
13 -// IMPORTS
14 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
15 -
16 -#include "LibSha512.h"
17 -#include <memory.h>
18 -
19 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
20 -// MACROS
21 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
22 -
23 -#define ROR64( value, bits ) (((value) >> (bits)) | ((value) << (64 - (bits))))
24 -
25 -#define MIN( x, y ) ( ((x)<(y))?(x):(y) )
26 -
27 -#define LOAD64H( x, y ) \
28 - { x = (((uint64_t)((y)[0] & 255))<<56)|(((uint64_t)((y)[1] & 255))<<48) | \
29 - (((uint64_t)((y)[2] & 255))<<40)|(((uint64_t)((y)[3] & 255))<<32) | \
30 - (((uint64_t)((y)[4] & 255))<<24)|(((uint64_t)((y)[5] & 255))<<16) | \
31 - (((uint64_t)((y)[6] & 255))<<8)|(((uint64_t)((y)[7] & 255))); }
32 -
33 -#define STORE64H( x, y ) \
34 - { (y)[0] = (uint8_t)(((x)>>56)&255); (y)[1] = (uint8_t)(((x)>>48)&255); \
35 - (y)[2] = (uint8_t)(((x)>>40)&255); (y)[3] = (uint8_t)(((x)>>32)&255); \
36 - (y)[4] = (uint8_t)(((x)>>24)&255); (y)[5] = (uint8_t)(((x)>>16)&255); \
37 - (y)[6] = (uint8_t)(((x)>>8)&255); (y)[7] = (uint8_t)((x)&255); }
38 -
39 -
40 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
41 -// CONSTANTS
42 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
43 -
44 -// The K array
45 -static const uint64_t K[80] = {
46 - 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
47 - 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
48 - 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
49 - 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
50 - 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL,
51 - 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
52 - 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL,
53 - 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
54 - 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
55 - 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
56 - 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL,
57 - 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
58 - 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL,
59 - 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
60 - 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
61 - 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
62 - 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL,
63 - 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
64 - 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL,
65 - 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
66 -};
67 -
68 -#define BLOCK_SIZE 128
69 -
70 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
71 -// INTERNAL FUNCTIONS
72 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
73 -
74 -// Various logical functions
75 -#define Ch( x, y, z ) (z ^ (x & (y ^ z)))
76 -#define Maj(x, y, z ) (((x | y) & z) | (x & y))
77 -#define S( x, n ) ROR64( x, n )
78 -#define R( x, n ) (((x)&0xFFFFFFFFFFFFFFFFULL)>>((uint64_t)n))
79 -#define Sigma0( x ) (S(x, 28) ^ S(x, 34) ^ S(x, 39))
80 -#define Sigma1( x ) (S(x, 14) ^ S(x, 18) ^ S(x, 41))
81 -#define Gamma0( x ) (S(x, 1) ^ S(x, 8) ^ R(x, 7))
82 -#define Gamma1( x ) (S(x, 19) ^ S(x, 61) ^ R(x, 6))
83 -
84 -#define Sha512Round( a, b, c, d, e, f, g, h, i ) \
85 - t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
86 - t1 = Sigma0(a) + Maj(a, b, c); \
87 - d += t0; \
88 - h = t0 + t1;
89 -
90 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
91 -// TransformFunction
92 -//
93 -// Compress 1024-bits
94 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
95 -static
96 -void
97 - TransformFunction
98 - (
99 - Sha512Context* Context,
100 - uint8_t* Buffer
101 - )
102 -{
103 - uint64_t S[8];
104 - uint64_t W[80];
105 - uint64_t t0;
106 - uint64_t t1;
107 - int i;
108 -
109 - // Copy state into S
110 - for( i=0; i<8; i++ )
111 - {
112 - S[i] = Context->state[i];
113 - }
114 -
115 - // Copy the state into 1024-bits into W[0..15]
116 - for( i=0; i<16; i++ )
117 - {
118 - LOAD64H(W[i], Buffer + (8*i));
119 - }
120 -
121 - // Fill W[16..79]
122 - for( i=16; i<80; i++ )
123 - {
124 - W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
125 - }
126 -
127 - // Compress
128 - for( i=0; i<80; i+=8 )
129 - {
130 - Sha512Round(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
131 - Sha512Round(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
132 - Sha512Round(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
133 - Sha512Round(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
134 - Sha512Round(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
135 - Sha512Round(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
136 - Sha512Round(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
137 - Sha512Round(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
138 - }
139 -
140 - // Feedback
141 - for( i=0; i<8; i++ )
142 - {
143 - Context->state[i] = Context->state[i] + S[i];
144 - }
145 -}
146 -
147 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
148 -// PUBLIC FUNCTIONS
149 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
150 -
151 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
152 -// Sha512Initialise
153 -//
154 -// Initialises a SHA512 Context. Use this to initialise/reset a context.
155 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
156 -void
157 - Sha512Initialise
158 - (
159 - Sha512Context* Context
160 - )
161 -{
162 - Context->curlen = 0;
163 - Context->length = 0;
164 - Context->state[0] = 0x6a09e667f3bcc908ULL;
165 - Context->state[1] = 0xbb67ae8584caa73bULL;
166 - Context->state[2] = 0x3c6ef372fe94f82bULL;
167 - Context->state[3] = 0xa54ff53a5f1d36f1ULL;
168 - Context->state[4] = 0x510e527fade682d1ULL;
169 - Context->state[5] = 0x9b05688c2b3e6c1fULL;
170 - Context->state[6] = 0x1f83d9abfb41bd6bULL;
171 - Context->state[7] = 0x5be0cd19137e2179ULL;
172 -}
173 -
174 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
175 -// Sha512Update
176 -//
177 -// Adds data to the SHA512 context. This will process the data and update the internal state of the context. Keep on
178 -// calling this function until all the data has been added. Then call Sha512Finalise to calculate the hash.
179 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
180 -void
181 - Sha512Update
182 - (
183 - Sha512Context* Context,
184 - void* Buffer,
185 - uint32_t BufferSize
186 - )
187 -{
188 - uint32_t n;
189 -
190 - if( Context->curlen > sizeof(Context->buf) )
191 - {
192 - return;
193 - }
194 -
195 - while( BufferSize > 0 )
196 - {
197 - if( Context->curlen == 0 && BufferSize >= BLOCK_SIZE )
198 - {
199 - TransformFunction( Context, (uint8_t *)Buffer );
200 - Context->length += BLOCK_SIZE * 8;
201 - Buffer = (uint8_t*)Buffer + BLOCK_SIZE;
202 - BufferSize -= BLOCK_SIZE;
203 - }
204 - else
205 - {
206 - n = MIN( BufferSize, (BLOCK_SIZE - Context->curlen) );
207 - memcpy( Context->buf + Context->curlen, Buffer, (size_t)n );
208 - Context->curlen += n;
209 - Buffer = (uint8_t*)Buffer + n;
210 - BufferSize -= n;
211 - if( Context->curlen == BLOCK_SIZE )
212 - {
213 - TransformFunction( Context, Context->buf );
214 - Context->length += 8*BLOCK_SIZE;
215 - Context->curlen = 0;
216 - }
217 - }
218 - }
219 -}
220 -
221 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
222 -// Sha512Finalise
223 -//
224 -// Performs the final calculation of the hash and returns the digest (64 byte buffer containing 512bit hash). After
225 -// calling this, Sha512Initialised must be used to reuse the context.
226 -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
227 -void
228 - Sha512Finalise
229 - (
230 - Sha512Context* Context,
231 - SHA512_HASH* Digest
232 - )
233 -{
234 - int i;
235 -
236 - if( Context->curlen >= sizeof(Context->buf) )
237 - {
238 - return;
239 - }
240 -
241 - // Increase the length of the message
242 - Context->length += Context->curlen * 8ULL;
243 -
244 - // Append the '1' bit
245 - Context->buf[Context->curlen++] = (uint8_t)0x80;
246 -
247 - // If the length is currently above 112 bytes we append zeros
248 - // then compress. Then we can fall back to padding zeros and length
249 - // encoding like normal.
250 - if( Context->curlen > 112 )
251 - {
252 - while( Context->curlen < 128 )
253 - {
254 - Context->buf[Context->curlen++] = (uint8_t)0;
255 - }
256 - TransformFunction( Context, Context->buf );
257 - Context->curlen = 0;
258 - }
259 -
260 - // Pad up to 120 bytes of zeroes
261 - // note: that from 112 to 120 is the 64 MSB of the length. We assume that you won't hash
262 - // > 2^64 bits of data... :-)
263 - while( Context->curlen < 120 )
264 - {
265 - Context->buf[Context->curlen++] = (uint8_t)0;
266 - }
267 -
268 - // Store length
269 - STORE64H( Context->length, Context->buf+120 );
270 - TransformFunction( Context, Context->buf );
271 -
272 - // Copy output
273 - for( i=0; i<8; i++ )
274 - {
275 - STORE64H( Context->state[i], Digest->bytes+(8*i) );
276 - }
277 -}
278 -
Index: sha512-nsis/pluginapi.h
@@ -1,74 +0,0 @@
2 -#ifndef ___NSIS_PLUGIN__H___
3 -#define ___NSIS_PLUGIN__H___
4 -
5 -#ifdef __cplusplus
6 -extern "C" {
7 -#endif
8 -
9 -#include "api.h"
10 -
11 -#ifndef NSISCALL
12 -# define NSISCALL __stdcall
13 -#endif
14 -
15 -#define EXDLL_INIT() { \
16 - g_stringsize=string_size; \
17 - g_stacktop=stacktop; \
18 - g_variables=variables; }
19 -
20 -typedef struct _stack_t {
21 - struct _stack_t *next;
22 - char text[1]; // this should be the length of string_size
23 -} stack_t;
24 -
25 -enum
26 -{
27 -INST_0, // $0
28 -INST_1, // $1
29 -INST_2, // $2
30 -INST_3, // $3
31 -INST_4, // $4
32 -INST_5, // $5
33 -INST_6, // $6
34 -INST_7, // $7
35 -INST_8, // $8
36 -INST_9, // $9
37 -INST_R0, // $R0
38 -INST_R1, // $R1
39 -INST_R2, // $R2
40 -INST_R3, // $R3
41 -INST_R4, // $R4
42 -INST_R5, // $R5
43 -INST_R6, // $R6
44 -INST_R7, // $R7
45 -INST_R8, // $R8
46 -INST_R9, // $R9
47 -INST_CMDLINE, // $CMDLINE
48 -INST_INSTDIR, // $INSTDIR
49 -INST_OUTDIR, // $OUTDIR
50 -INST_EXEDIR, // $EXEDIR
51 -INST_LANG, // $LANGUAGE
52 -__INST_LAST
53 -};
54 -
55 -extern unsigned int g_stringsize;
56 -extern stack_t **g_stacktop;
57 -extern char *g_variables;
58 -
59 -int NSISCALL popstring(char *str); // 0 on success, 1 on empty stack
60 -int NSISCALL popstringn(char *str, int maxlen); // with length limit, pass 0 for g_stringsize
61 -int NSISCALL popint(); // pops an integer
62 -int NSISCALL popint_or(); // with support for or'ing (2|4|8)
63 -int NSISCALL myatoi(const char *s); // converts a string to an integer
64 -unsigned NSISCALL myatou(const char *s); // converts a string to an unsigned integer, decimal only
65 -int NSISCALL myatoi_or(const char *s); // with support for or'ing (2|4|8)
66 -void NSISCALL pushstring(const char *str);
67 -void NSISCALL pushint(int value);
68 -char * NSISCALL getuservariable(const int varnum);
69 -void NSISCALL setuservariable(const int varnum, const char *var);
70 -
71 -#ifdef __cplusplus
72 -}
73 -#endif
74 -
75 -#endif//!___NSIS_PLUGIN__H___
Index: sha512-nsis/sha512-nsis.vcxproj.filters
@@ -1,39 +0,0 @@
2 -<?xml version="1.0" encoding="utf-8"?>
3 -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 - <ItemGroup>
5 - <Filter Include="Source Files">
6 - <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
7 - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
8 - </Filter>
9 - <Filter Include="Header Files">
10 - <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
11 - <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
12 - </Filter>
13 - <Filter Include="Resource Files">
14 - <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
15 - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
16 - </Filter>
17 - </ItemGroup>
18 - <ItemGroup>
19 - <ClCompile Include="LibSha512.c">
20 - <Filter>Source Files</Filter>
21 - </ClCompile>
22 - <ClCompile Include="sha512-nsis.c">
23 - <Filter>Source Files</Filter>
24 - </ClCompile>
25 - <ClCompile Include="pluginapi.c">
26 - <Filter>Source Files</Filter>
27 - </ClCompile>
28 - </ItemGroup>
29 - <ItemGroup>
30 - <ClInclude Include="LibSha512.h">
31 - <Filter>Header Files</Filter>
32 - </ClInclude>
33 - <ClInclude Include="api.h">
34 - <Filter>Header Files</Filter>
35 - </ClInclude>
36 - <ClInclude Include="pluginapi.h">
37 - <Filter>Header Files</Filter>
38 - </ClInclude>
39 - </ItemGroup>
40 -</Project>
\ No newline at end of file
Index: sha512-nsis/sha512-nsis.c
@@ -1,137 +0,0 @@
2 -// SHA-512 plugin for NSIS, used to verify runtime files in the DXGL installer.
3 -// This plugin links to LibSha512, from waterjuice.org, which is published as
4 -// public domain. In addition, the source code to this plugin is public
5 -// domain.
6 -
7 -// This file uses the NSIS API from the NSIS Plugin Example, which is licensed
8 -// under the zlib/libpng license.
9 -
10 -
11 -#include <Windows.h>
12 -#include "LibSha512.h"
13 -#include "pluginapi.h"
14 -#ifndef _TCHAR_DEFINED
15 -#include <tchar.h>
16 -#endif
17 -
18 -BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
19 -{
20 - return TRUE;
21 -}
22 -
23 -unsigned char hexdigit(unsigned char c)
24 -{
25 - if (c < 10) return c + '0';
26 - else return (c + 'A' - 10);
27 -}
28 -
29 -// API: sha512-nsis::CalculateSha512Sum file comp
30 -
31 -void __declspec(dllexport) CalculateSha512Sum(HWND hwndParent, int string_size,
32 - TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
33 -{
34 - int i;
35 - TCHAR filename[1024];
36 - Sha512Context context;
37 - HANDLE file;
38 - char buffer[512];
39 - char comp[1024];
40 - DWORD bytesread;
41 - SHA512_HASH sha512;
42 - int compout;
43 - EXDLL_INIT();
44 - popstring(filename);
45 - popstring(comp);
46 - Sha512Initialise(&context);
47 - file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
48 - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
49 - if (!file)
50 - {
51 - filename[0] = '0';
52 - filename[1] = 0;
53 - pushstring(comp);
54 - pushstring(filename);
55 - return;
56 - }
57 - while (1)
58 - {
59 - ReadFile(file, buffer, 512, &bytesread, NULL);
60 - if (!bytesread) break;
61 - Sha512Update(&context, buffer, bytesread);
62 - if (bytesread < 512) break;
63 - }
64 - Sha512Finalise(&context, &sha512);
65 - CloseHandle(file);
66 - for (i = 0; i < (512 / 8); i++)
67 - {
68 - buffer[i * 2] = hexdigit(sha512.bytes[i] >> 4);
69 - buffer[(i * 2) + 1] = hexdigit(sha512.bytes[i] & 0xF);
70 - }
71 - buffer[512 / 4] = 0;
72 - compout = memcmp(buffer, comp, 128);
73 - if (compout)
74 - {
75 - filename[0] = '0';
76 - }
77 - else
78 - {
79 - filename[0] = '1';
80 - }
81 - filename[1] = 0;
82 - pushstring(comp);
83 - pushstring(filename);
84 -}
85 -
86 -
87 -// Quick and dirty memcpy
88 -void *memcpy(unsigned char *dest, unsigned char *src, size_t size)
89 -{
90 - size_t i;
91 - for (i = 0; i < size; i++)
92 - dest[i] = src[i];
93 - return dest;
94 -}
95 -
96 -// Quick and dirty memcmp
97 -int memcmp(unsigned char *ptr1, unsigned char *ptr2, size_t size)
98 -{
99 - size_t i;
100 - for (i = 0; i < size; i++)
101 - {
102 - if (ptr1[i] < ptr2[i]) return -1;
103 - if (ptr1[i] > ptr2[i]) return 1;
104 - }
105 - return 0;
106 -}
107 -
108 -
109 -// ASM shift instructions to replace MSVC dependency
110 -#ifndef _M_X64
111 -void __declspec(naked) _aullshr()
112 -{
113 - __asm
114 - {
115 - shrd eax, edx, cl
116 - shr edx, cl
117 - test ecx, 32
118 - jz done
119 - mov eax, edx
120 - xor edx, edx
121 - done:
122 - }
123 -}
124 -
125 -void __declspec(naked) _allshl()
126 -{
127 - __asm
128 - {
129 - shld edx, eax, cl
130 - sal eax, cl
131 - test ecx, 32
132 - jz done2
133 - mov edx, eax
134 - xor eax, eax
135 - done2:
136 - }
137 -}
138 -#endif
\ No newline at end of file
Index: sha512-nsis
Property changes on: sha512-nsis
___________________________________________________________________
Deleted: svn:ignore
## -1,5 +0,0 ##
139 -Debug
140 -Release
141 -sha512-nsis.vcxproj.user
142 -Debug VS2017
143 -Release VS2017
Index: Installer/dxgl.nsi
@@ -184,7 +184,7 @@
185185 DetailPrint "Downloading ${runtime_name} Runtime"
186186 NSISdl::download ${runtime_url} $TEMP\${runtime_filename}
187187 DetailPrint "Checking ${runtime_name} Runtime"
188 - sha512-nsis::CalculateSha512Sum $TEMP\${runtime_filename} ${runtime_sha512}
 188+ dxgl-nsis::CalculateSha512Sum $TEMP\${runtime_filename} ${runtime_sha512}
189189 Pop $0
190190 ${If} $0 == "0"
191191 MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON2 "Failed to download ${runtime_name} Redistributable. Would you like to retry?" IDYES vcdownloadretry
@@ -249,6 +249,13 @@
250250
251251 Function .onInit
252252 !if ${COMPILER} == "VC2017_7"
 253+ dxgl-nsis::CheckSSE2 $0
 254+ Pop $0
 255+ ${If} $0 == "0"
 256+ MessageBox MB_OK|MB_ICONSTOP "This version of DXGL requires a processor with SSE2 capability.$\r\
 257+ Please download the VS2010 build to use DXGL on your system."
 258+ Quit
 259+ ${EndIf}
253260 ${IfNot} ${AtLeastWinVista}
254261 MessageBox MB_OK|MB_ICONSTOP "This version of DXGL requires at least Windows Vista Service Pack 2.$\r\
255262 If you need to run DXGL on Windows XP, XP x64, or Server 2003, please download the VS2010 build."
Index: dxgl-nsis/LibSha512.c
@@ -0,0 +1,277 @@
 2+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 3+// LibSha512
 4+//
 5+// Implementation of SHA512 hash function.
 6+// Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org
 7+// Modified by WaterJuice retaining Public Domain license.
 8+//
 9+// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
 10+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 11+
 12+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 13+// IMPORTS
 14+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 15+
 16+#include "LibSha512.h"
 17+#include <memory.h>
 18+
 19+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 20+// MACROS
 21+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 22+
 23+#define ROR64( value, bits ) (((value) >> (bits)) | ((value) << (64 - (bits))))
 24+
 25+#define MIN( x, y ) ( ((x)<(y))?(x):(y) )
 26+
 27+#define LOAD64H( x, y ) \
 28+ { x = (((uint64_t)((y)[0] & 255))<<56)|(((uint64_t)((y)[1] & 255))<<48) | \
 29+ (((uint64_t)((y)[2] & 255))<<40)|(((uint64_t)((y)[3] & 255))<<32) | \
 30+ (((uint64_t)((y)[4] & 255))<<24)|(((uint64_t)((y)[5] & 255))<<16) | \
 31+ (((uint64_t)((y)[6] & 255))<<8)|(((uint64_t)((y)[7] & 255))); }
 32+
 33+#define STORE64H( x, y ) \
 34+ { (y)[0] = (uint8_t)(((x)>>56)&255); (y)[1] = (uint8_t)(((x)>>48)&255); \
 35+ (y)[2] = (uint8_t)(((x)>>40)&255); (y)[3] = (uint8_t)(((x)>>32)&255); \
 36+ (y)[4] = (uint8_t)(((x)>>24)&255); (y)[5] = (uint8_t)(((x)>>16)&255); \
 37+ (y)[6] = (uint8_t)(((x)>>8)&255); (y)[7] = (uint8_t)((x)&255); }
 38+
 39+
 40+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 41+// CONSTANTS
 42+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 43+
 44+// The K array
 45+static const uint64_t K[80] = {
 46+ 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
 47+ 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
 48+ 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
 49+ 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
 50+ 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL,
 51+ 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
 52+ 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL,
 53+ 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
 54+ 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
 55+ 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
 56+ 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL,
 57+ 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
 58+ 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL,
 59+ 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
 60+ 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
 61+ 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
 62+ 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL,
 63+ 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
 64+ 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL,
 65+ 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
 66+};
 67+
 68+#define BLOCK_SIZE 128
 69+
 70+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 71+// INTERNAL FUNCTIONS
 72+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 73+
 74+// Various logical functions
 75+#define Ch( x, y, z ) (z ^ (x & (y ^ z)))
 76+#define Maj(x, y, z ) (((x | y) & z) | (x & y))
 77+#define S( x, n ) ROR64( x, n )
 78+#define R( x, n ) (((x)&0xFFFFFFFFFFFFFFFFULL)>>((uint64_t)n))
 79+#define Sigma0( x ) (S(x, 28) ^ S(x, 34) ^ S(x, 39))
 80+#define Sigma1( x ) (S(x, 14) ^ S(x, 18) ^ S(x, 41))
 81+#define Gamma0( x ) (S(x, 1) ^ S(x, 8) ^ R(x, 7))
 82+#define Gamma1( x ) (S(x, 19) ^ S(x, 61) ^ R(x, 6))
 83+
 84+#define Sha512Round( a, b, c, d, e, f, g, h, i ) \
 85+ t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
 86+ t1 = Sigma0(a) + Maj(a, b, c); \
 87+ d += t0; \
 88+ h = t0 + t1;
 89+
 90+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 91+// TransformFunction
 92+//
 93+// Compress 1024-bits
 94+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 95+static
 96+void
 97+ TransformFunction
 98+ (
 99+ Sha512Context* Context,
 100+ uint8_t* Buffer
 101+ )
 102+{
 103+ uint64_t S[8];
 104+ uint64_t W[80];
 105+ uint64_t t0;
 106+ uint64_t t1;
 107+ int i;
 108+
 109+ // Copy state into S
 110+ for( i=0; i<8; i++ )
 111+ {
 112+ S[i] = Context->state[i];
 113+ }
 114+
 115+ // Copy the state into 1024-bits into W[0..15]
 116+ for( i=0; i<16; i++ )
 117+ {
 118+ LOAD64H(W[i], Buffer + (8*i));
 119+ }
 120+
 121+ // Fill W[16..79]
 122+ for( i=16; i<80; i++ )
 123+ {
 124+ W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
 125+ }
 126+
 127+ // Compress
 128+ for( i=0; i<80; i+=8 )
 129+ {
 130+ Sha512Round(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
 131+ Sha512Round(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
 132+ Sha512Round(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
 133+ Sha512Round(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
 134+ Sha512Round(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
 135+ Sha512Round(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
 136+ Sha512Round(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
 137+ Sha512Round(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
 138+ }
 139+
 140+ // Feedback
 141+ for( i=0; i<8; i++ )
 142+ {
 143+ Context->state[i] = Context->state[i] + S[i];
 144+ }
 145+}
 146+
 147+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 148+// PUBLIC FUNCTIONS
 149+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 150+
 151+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 152+// Sha512Initialise
 153+//
 154+// Initialises a SHA512 Context. Use this to initialise/reset a context.
 155+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 156+void
 157+ Sha512Initialise
 158+ (
 159+ Sha512Context* Context
 160+ )
 161+{
 162+ Context->curlen = 0;
 163+ Context->length = 0;
 164+ Context->state[0] = 0x6a09e667f3bcc908ULL;
 165+ Context->state[1] = 0xbb67ae8584caa73bULL;
 166+ Context->state[2] = 0x3c6ef372fe94f82bULL;
 167+ Context->state[3] = 0xa54ff53a5f1d36f1ULL;
 168+ Context->state[4] = 0x510e527fade682d1ULL;
 169+ Context->state[5] = 0x9b05688c2b3e6c1fULL;
 170+ Context->state[6] = 0x1f83d9abfb41bd6bULL;
 171+ Context->state[7] = 0x5be0cd19137e2179ULL;
 172+}
 173+
 174+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 175+// Sha512Update
 176+//
 177+// Adds data to the SHA512 context. This will process the data and update the internal state of the context. Keep on
 178+// calling this function until all the data has been added. Then call Sha512Finalise to calculate the hash.
 179+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 180+void
 181+ Sha512Update
 182+ (
 183+ Sha512Context* Context,
 184+ void* Buffer,
 185+ uint32_t BufferSize
 186+ )
 187+{
 188+ uint32_t n;
 189+
 190+ if( Context->curlen > sizeof(Context->buf) )
 191+ {
 192+ return;
 193+ }
 194+
 195+ while( BufferSize > 0 )
 196+ {
 197+ if( Context->curlen == 0 && BufferSize >= BLOCK_SIZE )
 198+ {
 199+ TransformFunction( Context, (uint8_t *)Buffer );
 200+ Context->length += BLOCK_SIZE * 8;
 201+ Buffer = (uint8_t*)Buffer + BLOCK_SIZE;
 202+ BufferSize -= BLOCK_SIZE;
 203+ }
 204+ else
 205+ {
 206+ n = MIN( BufferSize, (BLOCK_SIZE - Context->curlen) );
 207+ memcpy( Context->buf + Context->curlen, Buffer, (size_t)n );
 208+ Context->curlen += n;
 209+ Buffer = (uint8_t*)Buffer + n;
 210+ BufferSize -= n;
 211+ if( Context->curlen == BLOCK_SIZE )
 212+ {
 213+ TransformFunction( Context, Context->buf );
 214+ Context->length += 8*BLOCK_SIZE;
 215+ Context->curlen = 0;
 216+ }
 217+ }
 218+ }
 219+}
 220+
 221+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 222+// Sha512Finalise
 223+//
 224+// Performs the final calculation of the hash and returns the digest (64 byte buffer containing 512bit hash). After
 225+// calling this, Sha512Initialised must be used to reuse the context.
 226+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 227+void
 228+ Sha512Finalise
 229+ (
 230+ Sha512Context* Context,
 231+ SHA512_HASH* Digest
 232+ )
 233+{
 234+ int i;
 235+
 236+ if( Context->curlen >= sizeof(Context->buf) )
 237+ {
 238+ return;
 239+ }
 240+
 241+ // Increase the length of the message
 242+ Context->length += Context->curlen * 8ULL;
 243+
 244+ // Append the '1' bit
 245+ Context->buf[Context->curlen++] = (uint8_t)0x80;
 246+
 247+ // If the length is currently above 112 bytes we append zeros
 248+ // then compress. Then we can fall back to padding zeros and length
 249+ // encoding like normal.
 250+ if( Context->curlen > 112 )
 251+ {
 252+ while( Context->curlen < 128 )
 253+ {
 254+ Context->buf[Context->curlen++] = (uint8_t)0;
 255+ }
 256+ TransformFunction( Context, Context->buf );
 257+ Context->curlen = 0;
 258+ }
 259+
 260+ // Pad up to 120 bytes of zeroes
 261+ // note: that from 112 to 120 is the 64 MSB of the length. We assume that you won't hash
 262+ // > 2^64 bits of data... :-)
 263+ while( Context->curlen < 120 )
 264+ {
 265+ Context->buf[Context->curlen++] = (uint8_t)0;
 266+ }
 267+
 268+ // Store length
 269+ STORE64H( Context->length, Context->buf+120 );
 270+ TransformFunction( Context, Context->buf );
 271+
 272+ // Copy output
 273+ for( i=0; i<8; i++ )
 274+ {
 275+ STORE64H( Context->state[i], Digest->bytes+(8*i) );
 276+ }
 277+}
 278+
Index: dxgl-nsis/LibSha512.h
@@ -0,0 +1,78 @@
 2+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 3+// LibSha512
 4+//
 5+// Implementation of SHA512 hash function.
 6+// Original author: Tom St Denis, tomstdenis@gmail.com, http://libtom.org
 7+// Modified by WaterJuice retaining Public Domain license.
 8+//
 9+// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
 10+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 11+
 12+#ifndef _LibSha512_h_
 13+#define _LibSha512_h_
 14+
 15+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 16+// IMPORTS
 17+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 18+
 19+#include <stdint.h>
 20+#include <stdio.h>
 21+
 22+typedef struct
 23+{
 24+ uint64_t length;
 25+ uint64_t state[8];
 26+ uint32_t curlen;
 27+ uint8_t buf[128];
 28+} Sha512Context;
 29+
 30+#define SHA512_HASH_SIZE ( 512 / 8 )
 31+
 32+typedef struct
 33+{
 34+ uint8_t bytes [SHA512_HASH_SIZE];
 35+} SHA512_HASH;
 36+
 37+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 38+// PUBLIC FUNCTIONS
 39+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 40+
 41+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 42+// Sha512Initialise
 43+//
 44+// Initialises a SHA512 Context. Use this to initialise/reset a context.
 45+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 46+void Sha512Initialise
 47+ (
 48+ Sha512Context* Context
 49+ );
 50+
 51+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 52+// Sha512Update
 53+//
 54+// Adds data to the SHA512 context. This will process the data and update the internal state of the context. Keep on
 55+// calling this function until all the data has been added. Then call Sha512Finalise to calculate the hash.
 56+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 57+void Sha512Update
 58+ (
 59+ Sha512Context* Context,
 60+ void* Buffer,
 61+ uint32_t BufferSize
 62+ );
 63+
 64+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 65+// Sha512Finalise
 66+//
 67+// Performs the final calculation of the hash and returns the digest (64 byte buffer containing 512bit hash). After
 68+// calling this, Sha512Initialised must be used to reuse the context.
 69+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 70+void
 71+ Sha512Finalise
 72+ (
 73+ Sha512Context* Context,
 74+ SHA512_HASH* Digest
 75+ );
 76+
 77+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 78+#endif //_LibSha512_h_
 79+
Index: dxgl-nsis/api.h
@@ -0,0 +1,83 @@
 2+/*
 3+ * apih
 4+ *
 5+ * This file is a part of NSIS.
 6+ *
 7+ * Copyright (C) 1999-2009 Nullsoft and Contributors
 8+ *
 9+ * Licensed under the zlib/libpng license (the "License");
 10+ * you may not use this file except in compliance with the License.
 11+ *
 12+ * Licence details can be found in the file COPYING.
 13+ *
 14+ * This software is provided 'as-is', without any express or implied
 15+ * warranty.
 16+ */
 17+
 18+#ifndef _NSIS_EXEHEAD_API_H_
 19+#define _NSIS_EXEHEAD_API_H_
 20+
 21+// Starting with NSIS 2.42, you can check the version of the plugin API in exec_flags->plugin_api_version
 22+// The format is 0xXXXXYYYY where X is the major version and Y is the minor version (MAKELONG(y,x))
 23+// When doing version checks, always remember to use >=, ex: if (pX->exec_flags->plugin_api_version >= NSISPIAPIVER_1_0) {}
 24+
 25+#define NSISPIAPIVER_1_0 0x00010000
 26+#define NSISPIAPIVER_CURR NSISPIAPIVER_1_0
 27+
 28+// NSIS Plug-In Callback Messages
 29+enum NSPIM
 30+{
 31+ NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
 32+ NSPIM_GUIUNLOAD, // Called after .onGUIEnd
 33+};
 34+
 35+// Prototype for callbacks registered with extra_parameters->RegisterPluginCallback()
 36+// Return NULL for unknown messages
 37+// Should always be __cdecl for future expansion possibilities
 38+typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM);
 39+
 40+// extra_parameters data structures containing other interesting stuff
 41+// but the stack, variables and HWND passed on to plug-ins.
 42+typedef struct
 43+{
 44+ int autoclose;
 45+ int all_user_var;
 46+ int exec_error;
 47+ int abort;
 48+ int exec_reboot; // NSIS_SUPPORT_REBOOT
 49+ int reboot_called; // NSIS_SUPPORT_REBOOT
 50+ int XXX_cur_insttype; // depreacted
 51+ int plugin_api_version; // see NSISPIAPIVER_CURR
 52+ // used to be XXX_insttype_changed
 53+ int silent; // NSIS_CONFIG_SILENT_SUPPORT
 54+ int instdir_error;
 55+ int rtl;
 56+ int errlvl;
 57+ int alter_reg_view;
 58+ int status_update;
 59+} exec_flags_t;
 60+
 61+#ifndef NSISCALL
 62+# define NSISCALL __stdcall
 63+#endif
 64+
 65+typedef struct {
 66+ exec_flags_t *exec_flags;
 67+ int (NSISCALL *ExecuteCodeSegment)(int, HWND);
 68+ void (NSISCALL *validate_filename)(char *);
 69+ int (NSISCALL *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK); // returns 0 on success, 1 if already registered and < 0 on errors
 70+} extra_parameters;
 71+
 72+// Definitions for page showing plug-ins
 73+// See Ui.c to understand better how they're used
 74+
 75+// sent to the outer window to tell it to go to the next inner window
 76+#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
 77+
 78+// custom pages should send this message to let NSIS know they're ready
 79+#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
 80+
 81+// sent as wParam with WM_NOTIFY_OUTER_NEXT when user cancels - heed its warning
 82+#define NOTIFY_BYE_BYE 'x'
 83+
 84+#endif /* _PLUGIN_H_ */
Index: dxgl-nsis/dxgl-nsis.c
@@ -0,0 +1,153 @@
 2+// DXGL plugin for NSIS, used to verify runtime files in the DXGL installer,
 3+// and to verify certain CPU features on certain builds of DXGL.
 4+// This plugin links to LibSha512, from waterjuice.org, which is published as
 5+// public domain. In addition, the source code to this plugin is public
 6+// domain.
 7+
 8+// This file uses the NSIS API from the NSIS Plugin Example, which is licensed
 9+// under the zlib/libpng license.
 10+
 11+
 12+#include <Windows.h>
 13+#include "LibSha512.h"
 14+#include "pluginapi.h"
 15+#include <intrin.h>
 16+#ifndef _TCHAR_DEFINED
 17+#include <tchar.h>
 18+#endif
 19+
 20+BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
 21+{
 22+ return TRUE;
 23+}
 24+
 25+unsigned char hexdigit(unsigned char c)
 26+{
 27+ if (c < 10) return c + '0';
 28+ else return (c + 'A' - 10);
 29+}
 30+
 31+// API: dxgl-nsis::CalculateSha512Sum file comp
 32+
 33+void __declspec(dllexport) CalculateSha512Sum(HWND hwndParent, int string_size,
 34+ TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
 35+{
 36+ int i;
 37+ TCHAR filename[1024];
 38+ Sha512Context context;
 39+ HANDLE file;
 40+ char buffer[512];
 41+ char comp[1024];
 42+ DWORD bytesread;
 43+ SHA512_HASH sha512;
 44+ int compout;
 45+ EXDLL_INIT();
 46+ popstring(filename);
 47+ popstring(comp);
 48+ Sha512Initialise(&context);
 49+ file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
 50+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 51+ if (!file)
 52+ {
 53+ filename[0] = '0';
 54+ filename[1] = 0;
 55+ pushstring(comp);
 56+ pushstring(filename);
 57+ return;
 58+ }
 59+ while (1)
 60+ {
 61+ ReadFile(file, buffer, 512, &bytesread, NULL);
 62+ if (!bytesread) break;
 63+ Sha512Update(&context, buffer, bytesread);
 64+ if (bytesread < 512) break;
 65+ }
 66+ Sha512Finalise(&context, &sha512);
 67+ CloseHandle(file);
 68+ for (i = 0; i < (512 / 8); i++)
 69+ {
 70+ buffer[i * 2] = hexdigit(sha512.bytes[i] >> 4);
 71+ buffer[(i * 2) + 1] = hexdigit(sha512.bytes[i] & 0xF);
 72+ }
 73+ buffer[512 / 4] = 0;
 74+ compout = memcmp(buffer, comp, 128);
 75+ if (compout)
 76+ {
 77+ filename[0] = '0';
 78+ }
 79+ else
 80+ {
 81+ filename[0] = '1';
 82+ }
 83+ filename[1] = 0;
 84+ pushstring(comp);
 85+ pushstring(filename);
 86+}
 87+
 88+// API: dxgl-nsis::CheckSSE2
 89+
 90+void __declspec(dllexport) CheckSSE2(HWND hwndParent, int string_size,
 91+ TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
 92+{
 93+ int cpuid[4];
 94+ char out[256];
 95+ EXDLL_INIT();
 96+ __cpuid(cpuid, 1);
 97+ if ((cpuid[3] >> 26) & 1) out[0] = '1';
 98+ else out[0] = '0';
 99+ out[1] = 0;
 100+ pushstring(out);
 101+}
 102+
 103+// Quick and dirty memcpy
 104+void *memcpy(unsigned char *dest, unsigned char *src, size_t size)
 105+{
 106+ size_t i;
 107+ for (i = 0; i < size; i++)
 108+ dest[i] = src[i];
 109+ return dest;
 110+}
 111+
 112+// Quick and dirty memcmp
 113+int memcmp(unsigned char *ptr1, unsigned char *ptr2, size_t size)
 114+{
 115+ size_t i;
 116+ for (i = 0; i < size; i++)
 117+ {
 118+ if (ptr1[i] < ptr2[i]) return -1;
 119+ if (ptr1[i] > ptr2[i]) return 1;
 120+ }
 121+ return 0;
 122+}
 123+
 124+
 125+// ASM shift instructions to replace MSVC dependency
 126+#ifndef _M_X64
 127+void __declspec(naked) _aullshr()
 128+{
 129+ __asm
 130+ {
 131+ shrd eax, edx, cl
 132+ shr edx, cl
 133+ test ecx, 32
 134+ jz done
 135+ mov eax, edx
 136+ xor edx, edx
 137+ done:
 138+ }
 139+}
 140+
 141+void __declspec(naked) _allshl()
 142+{
 143+ __asm
 144+ {
 145+ shld edx, eax, cl
 146+ sal eax, cl
 147+ test ecx, 32
 148+ jz done2
 149+ mov edx, eax
 150+ xor eax, eax
 151+ done2:
 152+ }
 153+}
 154+#endif
\ No newline at end of file
Index: dxgl-nsis/dxgl-nsis.vcxproj
@@ -0,0 +1,173 @@
 2+<?xml version="1.0" encoding="utf-8"?>
 3+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 4+ <ItemGroup Label="ProjectConfigurations">
 5+ <ProjectConfiguration Include="Debug VS2017|Win32">
 6+ <Configuration>Debug VS2017</Configuration>
 7+ <Platform>Win32</Platform>
 8+ </ProjectConfiguration>
 9+ <ProjectConfiguration Include="Debug|Win32">
 10+ <Configuration>Debug</Configuration>
 11+ <Platform>Win32</Platform>
 12+ </ProjectConfiguration>
 13+ <ProjectConfiguration Include="Release VS2017|Win32">
 14+ <Configuration>Release VS2017</Configuration>
 15+ <Platform>Win32</Platform>
 16+ </ProjectConfiguration>
 17+ <ProjectConfiguration Include="Release|Win32">
 18+ <Configuration>Release</Configuration>
 19+ <Platform>Win32</Platform>
 20+ </ProjectConfiguration>
 21+ </ItemGroup>
 22+ <PropertyGroup Label="Globals">
 23+ <ProjectGuid>{F822EDB0-63E2-4EB8-B80D-F72481CDE3E1}</ProjectGuid>
 24+ <Keyword>Win32Proj</Keyword>
 25+ <RootNamespace>sha512nsis</RootNamespace>
 26+ <ProjectName>dxgl-nsis</ProjectName>
 27+ </PropertyGroup>
 28+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
 29+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
 30+ <ConfigurationType>DynamicLibrary</ConfigurationType>
 31+ <UseDebugLibraries>true</UseDebugLibraries>
 32+ <PlatformToolset>v100</PlatformToolset>
 33+ <CharacterSet>MultiByte</CharacterSet>
 34+ </PropertyGroup>
 35+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'" Label="Configuration">
 36+ <ConfigurationType>DynamicLibrary</ConfigurationType>
 37+ <UseDebugLibraries>true</UseDebugLibraries>
 38+ <PlatformToolset>v141</PlatformToolset>
 39+ <CharacterSet>MultiByte</CharacterSet>
 40+ </PropertyGroup>
 41+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
 42+ <ConfigurationType>DynamicLibrary</ConfigurationType>
 43+ <UseDebugLibraries>false</UseDebugLibraries>
 44+ <PlatformToolset>v100</PlatformToolset>
 45+ <WholeProgramOptimization>true</WholeProgramOptimization>
 46+ <CharacterSet>MultiByte</CharacterSet>
 47+ </PropertyGroup>
 48+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'" Label="Configuration">
 49+ <ConfigurationType>DynamicLibrary</ConfigurationType>
 50+ <UseDebugLibraries>false</UseDebugLibraries>
 51+ <PlatformToolset>v141</PlatformToolset>
 52+ <WholeProgramOptimization>true</WholeProgramOptimization>
 53+ <CharacterSet>MultiByte</CharacterSet>
 54+ </PropertyGroup>
 55+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
 56+ <ImportGroup Label="ExtensionSettings">
 57+ </ImportGroup>
 58+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 59+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 60+ </ImportGroup>
 61+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'" Label="PropertySheets">
 62+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 63+ </ImportGroup>
 64+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 65+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 66+ </ImportGroup>
 67+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'" Label="PropertySheets">
 68+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 69+ </ImportGroup>
 70+ <PropertyGroup Label="UserMacros" />
 71+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 72+ <LinkIncremental>true</LinkIncremental>
 73+ <GenerateManifest>false</GenerateManifest>
 74+ </PropertyGroup>
 75+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'">
 76+ <LinkIncremental>true</LinkIncremental>
 77+ <GenerateManifest>false</GenerateManifest>
 78+ </PropertyGroup>
 79+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 80+ <LinkIncremental>false</LinkIncremental>
 81+ <GenerateManifest>false</GenerateManifest>
 82+ </PropertyGroup>
 83+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'">
 84+ <LinkIncremental>false</LinkIncremental>
 85+ <GenerateManifest>false</GenerateManifest>
 86+ </PropertyGroup>
 87+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 88+ <ClCompile>
 89+ <PrecompiledHeader>
 90+ </PrecompiledHeader>
 91+ <WarningLevel>Level3</WarningLevel>
 92+ <Optimization>Disabled</Optimization>
 93+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SHA512NSIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 94+ <BufferSecurityCheck>false</BufferSecurityCheck>
 95+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
 96+ </ClCompile>
 97+ <Link>
 98+ <SubSystem>Windows</SubSystem>
 99+ <GenerateDebugInformation>true</GenerateDebugInformation>
 100+ <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
 101+ <EntryPointSymbol>DllMain</EntryPointSymbol>
 102+ </Link>
 103+ </ItemDefinitionGroup>
 104+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'">
 105+ <ClCompile>
 106+ <PrecompiledHeader>
 107+ </PrecompiledHeader>
 108+ <WarningLevel>Level3</WarningLevel>
 109+ <Optimization>Disabled</Optimization>
 110+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SHA512NSIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 111+ <BufferSecurityCheck>false</BufferSecurityCheck>
 112+ <BasicRuntimeChecks>Default</BasicRuntimeChecks>
 113+ </ClCompile>
 114+ <Link>
 115+ <SubSystem>Windows</SubSystem>
 116+ <GenerateDebugInformation>true</GenerateDebugInformation>
 117+ <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
 118+ <EntryPointSymbol>DllMain</EntryPointSymbol>
 119+ </Link>
 120+ </ItemDefinitionGroup>
 121+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 122+ <ClCompile>
 123+ <WarningLevel>Level3</WarningLevel>
 124+ <PrecompiledHeader>
 125+ </PrecompiledHeader>
 126+ <Optimization>MinSpace</Optimization>
 127+ <FunctionLevelLinking>true</FunctionLevelLinking>
 128+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SHA512NSIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 129+ <BufferSecurityCheck>false</BufferSecurityCheck>
 130+ <WholeProgramOptimization>false</WholeProgramOptimization>
 131+ </ClCompile>
 132+ <Link>
 133+ <SubSystem>Windows</SubSystem>
 134+ <GenerateDebugInformation>true</GenerateDebugInformation>
 135+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
 136+ <OptimizeReferences>true</OptimizeReferences>
 137+ <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
 138+ <EntryPointSymbol>DllMain</EntryPointSymbol>
 139+ </Link>
 140+ </ItemDefinitionGroup>
 141+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'">
 142+ <ClCompile>
 143+ <WarningLevel>Level3</WarningLevel>
 144+ <PrecompiledHeader>
 145+ </PrecompiledHeader>
 146+ <Optimization>MinSpace</Optimization>
 147+ <FunctionLevelLinking>true</FunctionLevelLinking>
 148+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SHA512NSIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 149+ <BufferSecurityCheck>false</BufferSecurityCheck>
 150+ <WholeProgramOptimization>false</WholeProgramOptimization>
 151+ </ClCompile>
 152+ <Link>
 153+ <SubSystem>Windows</SubSystem>
 154+ <GenerateDebugInformation>true</GenerateDebugInformation>
 155+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
 156+ <OptimizeReferences>true</OptimizeReferences>
 157+ <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
 158+ <EntryPointSymbol>DllMain</EntryPointSymbol>
 159+ </Link>
 160+ </ItemDefinitionGroup>
 161+ <ItemGroup>
 162+ <ClCompile Include="LibSha512.c" />
 163+ <ClCompile Include="pluginapi.c" />
 164+ <ClCompile Include="dxgl-nsis.c" />
 165+ </ItemGroup>
 166+ <ItemGroup>
 167+ <ClInclude Include="api.h" />
 168+ <ClInclude Include="LibSha512.h" />
 169+ <ClInclude Include="pluginapi.h" />
 170+ </ItemGroup>
 171+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 172+ <ImportGroup Label="ExtensionTargets">
 173+ </ImportGroup>
 174+</Project>
\ No newline at end of file
Index: dxgl-nsis/dxgl-nsis.vcxproj.filters
@@ -0,0 +1,39 @@
 2+<?xml version="1.0" encoding="utf-8"?>
 3+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 4+ <ItemGroup>
 5+ <Filter Include="Source Files">
 6+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
 7+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
 8+ </Filter>
 9+ <Filter Include="Header Files">
 10+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
 11+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
 12+ </Filter>
 13+ <Filter Include="Resource Files">
 14+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
 15+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
 16+ </Filter>
 17+ </ItemGroup>
 18+ <ItemGroup>
 19+ <ClCompile Include="LibSha512.c">
 20+ <Filter>Source Files</Filter>
 21+ </ClCompile>
 22+ <ClCompile Include="pluginapi.c">
 23+ <Filter>Source Files</Filter>
 24+ </ClCompile>
 25+ <ClCompile Include="dxgl-nsis.c">
 26+ <Filter>Source Files</Filter>
 27+ </ClCompile>
 28+ </ItemGroup>
 29+ <ItemGroup>
 30+ <ClInclude Include="LibSha512.h">
 31+ <Filter>Header Files</Filter>
 32+ </ClInclude>
 33+ <ClInclude Include="api.h">
 34+ <Filter>Header Files</Filter>
 35+ </ClInclude>
 36+ <ClInclude Include="pluginapi.h">
 37+ <Filter>Header Files</Filter>
 38+ </ClInclude>
 39+ </ItemGroup>
 40+</Project>
\ No newline at end of file
Index: dxgl-nsis/pluginapi.c
@@ -0,0 +1,191 @@
 2+#include <windows.h>
 3+
 4+#include "pluginapi.h"
 5+
 6+unsigned int g_stringsize;
 7+stack_t **g_stacktop;
 8+char *g_variables;
 9+
 10+// utility functions (not required but often useful)
 11+
 12+int NSISCALL popstring(char *str)
 13+{
 14+ stack_t *th;
 15+ if (!g_stacktop || !*g_stacktop) return 1;
 16+ th=(*g_stacktop);
 17+ if (str) lstrcpyA(str,th->text);
 18+ *g_stacktop = th->next;
 19+ GlobalFree((HGLOBAL)th);
 20+ return 0;
 21+}
 22+
 23+int NSISCALL popstringn(char *str, int maxlen)
 24+{
 25+ stack_t *th;
 26+ if (!g_stacktop || !*g_stacktop) return 1;
 27+ th=(*g_stacktop);
 28+ if (str) lstrcpynA(str,th->text,maxlen?maxlen:g_stringsize);
 29+ *g_stacktop = th->next;
 30+ GlobalFree((HGLOBAL)th);
 31+ return 0;
 32+}
 33+
 34+void NSISCALL pushstring(const char *str)
 35+{
 36+ stack_t *th;
 37+ if (!g_stacktop) return;
 38+ th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
 39+ lstrcpynA(th->text,str,g_stringsize);
 40+ th->next=*g_stacktop;
 41+ *g_stacktop=th;
 42+}
 43+
 44+char * NSISCALL getuservariable(const int varnum)
 45+{
 46+ if (varnum < 0 || varnum >= __INST_LAST) return NULL;
 47+ return g_variables+varnum*g_stringsize;
 48+}
 49+
 50+void NSISCALL setuservariable(const int varnum, const char *var)
 51+{
 52+ if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
 53+ lstrcpyA(g_variables + varnum*g_stringsize, var);
 54+}
 55+
 56+// playing with integers
 57+
 58+int NSISCALL myatoi(const char *s)
 59+{
 60+ int v=0;
 61+ if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
 62+ {
 63+ s++;
 64+ for (;;)
 65+ {
 66+ int c=*(++s);
 67+ if (c >= '0' && c <= '9') c-='0';
 68+ else if (c >= 'a' && c <= 'f') c-='a'-10;
 69+ else if (c >= 'A' && c <= 'F') c-='A'-10;
 70+ else break;
 71+ v<<=4;
 72+ v+=c;
 73+ }
 74+ }
 75+ else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
 76+ {
 77+ for (;;)
 78+ {
 79+ int c=*(++s);
 80+ if (c >= '0' && c <= '7') c-='0';
 81+ else break;
 82+ v<<=3;
 83+ v+=c;
 84+ }
 85+ }
 86+ else
 87+ {
 88+ int sign=0;
 89+ if (*s == '-') sign++; else s--;
 90+ for (;;)
 91+ {
 92+ int c=*(++s) - '0';
 93+ if (c < 0 || c > 9) break;
 94+ v*=10;
 95+ v+=c;
 96+ }
 97+ if (sign) v = -v;
 98+ }
 99+
 100+ return v;
 101+}
 102+
 103+unsigned NSISCALL myatou(const char *s)
 104+{
 105+ unsigned int v=0;
 106+
 107+ for (;;)
 108+ {
 109+ unsigned int c=*s++;
 110+ if (c >= '0' && c <= '9') c-='0';
 111+ else break;
 112+ v*=10;
 113+ v+=c;
 114+ }
 115+ return v;
 116+}
 117+
 118+int NSISCALL myatoi_or(const char *s)
 119+{
 120+ int v=0;
 121+ if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
 122+ {
 123+ s++;
 124+ for (;;)
 125+ {
 126+ int c=*(++s);
 127+ if (c >= '0' && c <= '9') c-='0';
 128+ else if (c >= 'a' && c <= 'f') c-='a'-10;
 129+ else if (c >= 'A' && c <= 'F') c-='A'-10;
 130+ else break;
 131+ v<<=4;
 132+ v+=c;
 133+ }
 134+ }
 135+ else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
 136+ {
 137+ for (;;)
 138+ {
 139+ int c=*(++s);
 140+ if (c >= '0' && c <= '7') c-='0';
 141+ else break;
 142+ v<<=3;
 143+ v+=c;
 144+ }
 145+ }
 146+ else
 147+ {
 148+ int sign=0;
 149+ if (*s == '-') sign++; else s--;
 150+ for (;;)
 151+ {
 152+ int c=*(++s) - '0';
 153+ if (c < 0 || c > 9) break;
 154+ v*=10;
 155+ v+=c;
 156+ }
 157+ if (sign) v = -v;
 158+ }
 159+
 160+ // Support for simple ORed expressions
 161+ if (*s == '|')
 162+ {
 163+ v |= myatoi_or(s+1);
 164+ }
 165+
 166+ return v;
 167+}
 168+
 169+int NSISCALL popint()
 170+{
 171+ char buf[128];
 172+ if (popstringn(buf,sizeof(buf)))
 173+ return 0;
 174+
 175+ return myatoi(buf);
 176+}
 177+
 178+int NSISCALL popint_or()
 179+{
 180+ char buf[128];
 181+ if (popstringn(buf,sizeof(buf)))
 182+ return 0;
 183+
 184+ return myatoi_or(buf);
 185+}
 186+
 187+void NSISCALL pushint(int value)
 188+{
 189+ char buffer[1024];
 190+ wsprintf(buffer, "%d", value);
 191+ pushstring(buffer);
 192+}
Index: dxgl-nsis/pluginapi.h
@@ -0,0 +1,74 @@
 2+#ifndef ___NSIS_PLUGIN__H___
 3+#define ___NSIS_PLUGIN__H___
 4+
 5+#ifdef __cplusplus
 6+extern "C" {
 7+#endif
 8+
 9+#include "api.h"
 10+
 11+#ifndef NSISCALL
 12+# define NSISCALL __stdcall
 13+#endif
 14+
 15+#define EXDLL_INIT() { \
 16+ g_stringsize=string_size; \
 17+ g_stacktop=stacktop; \
 18+ g_variables=variables; }
 19+
 20+typedef struct _stack_t {
 21+ struct _stack_t *next;
 22+ char text[1]; // this should be the length of string_size
 23+} stack_t;
 24+
 25+enum
 26+{
 27+INST_0, // $0
 28+INST_1, // $1
 29+INST_2, // $2
 30+INST_3, // $3
 31+INST_4, // $4
 32+INST_5, // $5
 33+INST_6, // $6
 34+INST_7, // $7
 35+INST_8, // $8
 36+INST_9, // $9
 37+INST_R0, // $R0
 38+INST_R1, // $R1
 39+INST_R2, // $R2
 40+INST_R3, // $R3
 41+INST_R4, // $R4
 42+INST_R5, // $R5
 43+INST_R6, // $R6
 44+INST_R7, // $R7
 45+INST_R8, // $R8
 46+INST_R9, // $R9
 47+INST_CMDLINE, // $CMDLINE
 48+INST_INSTDIR, // $INSTDIR
 49+INST_OUTDIR, // $OUTDIR
 50+INST_EXEDIR, // $EXEDIR
 51+INST_LANG, // $LANGUAGE
 52+__INST_LAST
 53+};
 54+
 55+extern unsigned int g_stringsize;
 56+extern stack_t **g_stacktop;
 57+extern char *g_variables;
 58+
 59+int NSISCALL popstring(char *str); // 0 on success, 1 on empty stack
 60+int NSISCALL popstringn(char *str, int maxlen); // with length limit, pass 0 for g_stringsize
 61+int NSISCALL popint(); // pops an integer
 62+int NSISCALL popint_or(); // with support for or'ing (2|4|8)
 63+int NSISCALL myatoi(const char *s); // converts a string to an integer
 64+unsigned NSISCALL myatou(const char *s); // converts a string to an unsigned integer, decimal only
 65+int NSISCALL myatoi_or(const char *s); // with support for or'ing (2|4|8)
 66+void NSISCALL pushstring(const char *str);
 67+void NSISCALL pushint(int value);
 68+char * NSISCALL getuservariable(const int varnum);
 69+void NSISCALL setuservariable(const int varnum, const char *var);
 70+
 71+#ifdef __cplusplus
 72+}
 73+#endif
 74+
 75+#endif//!___NSIS_PLUGIN__H___
Index: dxgl-nsis
Property changes on: dxgl-nsis
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
 76+Debug
 77+Debug VS2017
 78+Release
 79+Release VS2017
 80+dxgl-nsis.vcxproj.user
Index: dxgl.sln
@@ -47,7 +47,7 @@
4848 EndProject
4949 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "minhook\build\DXGL\libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}"
5050 EndProject
51 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sha512-nsis", "sha512-nsis\sha512-nsis.vcxproj", "{F822EDB0-63E2-4EB8-B80D-F72481CDE3E1}"
 51+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxgl-nsis", "dxgl-nsis\dxgl-nsis.vcxproj", "{F822EDB0-63E2-4EB8-B80D-F72481CDE3E1}"
5252 EndProject
5353 Global
5454 GlobalSection(SolutionConfigurationPlatforms) = preSolution