Index: Installer/dxgl.nsi |
— | — | @@ -423,4 +423,11 @@ |
424 | 424 | DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
|
425 | 425 | DeleteRegKey HKLM "Software\DXGL"
|
426 | 426 | SetAutoClose true
|
427 | | -SectionEnd |
\ No newline at end of file |
| 427 | +SectionEnd
|
| 428 | +
|
| 429 | +!if ${SIGNTOOL} == 1
|
| 430 | +!finalize 'signtool sign /t http://timestamp.comodoca.com %1'
|
| 431 | +!if ${COMPILER} == "VC2019_0"
|
| 432 | +!finalize 'signtool sign /tr http://timestamp.comodoca.com /td sha256 /fd sha256 /as %1'
|
| 433 | +!endif
|
| 434 | +!endif |
\ No newline at end of file |
Index: buildtool/buildtool.c |
— | — | @@ -106,6 +106,12 @@ |
107 | 107 | FILE *filein;
|
108 | 108 | FILE *fileout;
|
109 | 109 | int revision = GetSVNRev(path);
|
| 110 | + BOOL nosign = FALSE;
|
| 111 | + if (SIGNMODE < 1) nosign = TRUE;
|
| 112 | + if ((SIGNMODE == 1) && DXGLBETA) nosign = TRUE;
|
| 113 | + #ifdef _DEBUG
|
| 114 | + if (SIGNMODE <= 2) nosign = TRUE;
|
| 115 | + #endif
|
110 | 116 | strncpy(pathin,path,FILENAME_MAX);
|
111 | 117 | pathin[FILENAME_MAX] = 0;
|
112 | 118 | strncpy(pathout,path,FILENAME_MAX);
|
— | — | @@ -135,7 +141,7 @@ |
136 | 142 | findptr = strstr(buffer,"$MINOR");
|
137 | 143 | if(findptr) strncpy(findptr,STR(DXGLMINORVER) "\n",6);
|
138 | 144 | findptr = strstr(buffer,"$POINT");
|
139 | | - if(findptr) strncpy(findptr,STR(DXGLPOINTVER) "\n",6);
|
| 145 | + if(findptr) strncpy(findptr,STR(DXGLPOINTVER) "\n",9);
|
140 | 146 | findptr = strstr(buffer,"$REVISION");
|
141 | 147 | if(findptr)
|
142 | 148 | {
|
— | — | @@ -163,6 +169,12 @@ |
164 | 170 | {
|
165 | 171 | if (strstr(buffer, "//#define DXGLBETA")) strcpy(buffer, "#define DXGLBETA");
|
166 | 172 | }
|
| 173 | + findptr = strstr(buffer, "$SIGNTOOL");
|
| 174 | + if (findptr)
|
| 175 | + {
|
| 176 | + if (nosign) strncpy(findptr, "0", 10);
|
| 177 | + else strncpy(findptr, "1", 10);
|
| 178 | + }
|
167 | 179 | fputs(buffer,fileout);
|
168 | 180 | }
|
169 | 181 | fclose(filein);
|
— | — | @@ -442,7 +454,7 @@ |
443 | 455 | {
|
444 | 456 | int result = MessageBoxA(NULL,"Could not find NSIS, would you like to download it?","NSIS not found",
|
445 | 457 | MB_YESNO|MB_ICONERROR);
|
446 | | - if(result == IDYES) ShellExecuteA(NULL,"open","http://nsis.sourceforge.net/Main_Page",NULL,NULL,SW_SHOWNORMAL);
|
| 458 | + if(result == IDYES) ShellExecuteA(NULL,"open","https://nsis.sourceforge.io/Main_Page",NULL,NULL,SW_SHOWNORMAL);
|
447 | 459 | puts("ERROR: NSIS not found.");
|
448 | 460 | return -1;
|
449 | 461 | }
|
— | — | @@ -449,6 +461,52 @@ |
450 | 462 | return 0;
|
451 | 463 | }
|
452 | 464 |
|
| 465 | +int SignEXE(char *exefile)
|
| 466 | +{
|
| 467 | + PROCESS_INFORMATION process;
|
| 468 | + STARTUPINFOA startinfo;
|
| 469 | + const char signtoolsha1path[] = "signtool sign /t http://timestamp.comodoca.com ";
|
| 470 | + const char signtoolsha256path[] = "signtool sign /tr http://timestamp.comodoca.com /td sha256 /fd sha256 /as ";
|
| 471 | + char signpath[MAX_PATH + 80];
|
| 472 | + BOOL nosign = FALSE;
|
| 473 | + if (SIGNMODE < 1) nosign = TRUE;
|
| 474 | + if ((SIGNMODE == 1) && DXGLBETA) nosign = TRUE;
|
| 475 | + #ifdef _DEBUG
|
| 476 | + if (SIGNMODE <= 2) nosign = TRUE;
|
| 477 | + #endif
|
| 478 | + if (nosign)
|
| 479 | + {
|
| 480 | + puts("Skipping file signature.");
|
| 481 | + return 0;
|
| 482 | + }
|
| 483 | + strcpy(&signpath, &signtoolsha1path);
|
| 484 | + strcat(&signpath, "\"");
|
| 485 | + strncat(&signpath, exefile, MAX_PATH);
|
| 486 | + strcat(&signpath, "\"");
|
| 487 | + ZeroMemory(&startinfo, sizeof(STARTUPINFOA));
|
| 488 | + startinfo.cb = sizeof(STARTUPINFOA);
|
| 489 | + if (CreateProcessA(NULL, &signpath, NULL, NULL, FALSE, 0, NULL, NULL, &startinfo, &process))
|
| 490 | + {
|
| 491 | + WaitForSingleObject(process.hProcess, INFINITE);
|
| 492 | + CloseHandle(process.hProcess);
|
| 493 | + CloseHandle(process.hThread);
|
| 494 | + Sleep(15000);
|
| 495 | + }
|
| 496 | + strcpy(&signpath, &signtoolsha256path);
|
| 497 | + strcat(&signpath, "\"");
|
| 498 | + strncat(&signpath, exefile, MAX_PATH);
|
| 499 | + strcat(&signpath, "\"");
|
| 500 | + ZeroMemory(&startinfo, sizeof(STARTUPINFOA));
|
| 501 | + startinfo.cb = sizeof(STARTUPINFOA);
|
| 502 | + if (CreateProcessA(NULL, &signpath, NULL, NULL, FALSE, 0, NULL, NULL, &startinfo, &process))
|
| 503 | + {
|
| 504 | + WaitForSingleObject(process.hProcess, INFINITE);
|
| 505 | + CloseHandle(process.hProcess);
|
| 506 | + CloseHandle(process.hThread);
|
| 507 | + Sleep(15000);
|
| 508 | + }
|
| 509 | + return 0;
|
| 510 | +}
|
453 | 511 |
|
454 | 512 | int main(int argc, char *argv[])
|
455 | 513 | {
|
— | — | @@ -486,6 +544,15 @@ |
487 | 545 | }
|
488 | 546 | return MakeInstaller(argv[2]);
|
489 | 547 | }
|
| 548 | + if (!strcmp(argv[1], "sign"))
|
| 549 | + {
|
| 550 | + if (argc < 3)
|
| 551 | + {
|
| 552 | + puts("ERROR: file specified.");
|
| 553 | + return 1;
|
| 554 | + }
|
| 555 | + return SignEXE(argv[2]);
|
| 556 | + }
|
490 | 557 | }
|
491 | 558 | else
|
492 | 559 | {
|
Index: common/releasever.h |
— | — | @@ -12,6 +12,11 @@ |
13 | 13 |
|
14 | 14 | #define DXGLSTRVER STR(DXGLMAJORVER) "." STR(DXGLMINORVER) "." STR(DXGLPOINTVER)
|
15 | 15 |
|
| 16 | +/* sign modes
|
| 17 | +0 - never sign
|
| 18 | +1 - sign non-beta only
|
| 19 | +2 - sign release only
|
| 20 | +3 - sign all */
|
| 21 | +#define SIGNMODE 1
|
16 | 22 |
|
17 | | -
|
18 | 23 | #endif //__VERSION_H
|
Index: common/version.nsh.in |
— | — | @@ -1,5 +1,6 @@ |
2 | 2 | !define PRODUCT_VERSION $PRODUCTVERSTRING
|
3 | 3 | !define PRODUCT_REVISION $PRODUCTREVISION
|
4 | 4 | !define COMPILER $COMPILERTYPE
|
| 5 | +!define SIGNTOOL $SIGNTOOL
|
5 | 6 | ;!define _BETA
|
6 | 7 | ;!define _DEBUG |
\ No newline at end of file |
Index: ddraw/ddraw.vcxproj |
— | — | @@ -151,6 +151,9 @@ |
152 | 152 | <PreBuildEvent>
|
153 | 153 | <Message>Create version headers</Message>
|
154 | 154 | </PreBuildEvent>
|
| 155 | + <PostBuildEvent>
|
| 156 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 157 | + </PostBuildEvent>
|
155 | 158 | </ItemDefinitionGroup>
|
156 | 159 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2019|Win32'">
|
157 | 160 | <ClCompile>
|
— | — | @@ -174,6 +177,9 @@ |
175 | 178 | <PreBuildEvent>
|
176 | 179 | <Message>Create version headers</Message>
|
177 | 180 | </PreBuildEvent>
|
| 181 | + <PostBuildEvent>
|
| 182 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 183 | + </PostBuildEvent>
|
178 | 184 | </ItemDefinitionGroup>
|
179 | 185 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">
|
180 | 186 | <ClCompile>
|
— | — | @@ -197,6 +203,9 @@ |
198 | 204 | <PreBuildEvent>
|
199 | 205 | <Message>Create version headers</Message>
|
200 | 206 | </PreBuildEvent>
|
| 207 | + <PostBuildEvent>
|
| 208 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 209 | + </PostBuildEvent>
|
201 | 210 | </ItemDefinitionGroup>
|
202 | 211 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">
|
203 | 212 | <ClCompile>
|
— | — | @@ -224,6 +233,7 @@ |
225 | 234 | <PreBuildEvent>
|
226 | 235 | <Message>Create version headers</Message>
|
227 | 236 | </PreBuildEvent>
|
| 237 | + <PostBuildEvent />
|
228 | 238 | </ItemDefinitionGroup>
|
229 | 239 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
230 | 240 | <ClCompile>
|
— | — | @@ -252,6 +262,9 @@ |
253 | 263 | <PreBuildEvent>
|
254 | 264 | <Message>Create version headers</Message>
|
255 | 265 | </PreBuildEvent>
|
| 266 | + <PostBuildEvent>
|
| 267 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 268 | + </PostBuildEvent>
|
256 | 269 | </ItemDefinitionGroup>
|
257 | 270 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2019|Win32'">
|
258 | 271 | <ClCompile>
|
— | — | @@ -280,6 +293,9 @@ |
281 | 294 | <PreBuildEvent>
|
282 | 295 | <Message>Create version headers</Message>
|
283 | 296 | </PreBuildEvent>
|
| 297 | + <PostBuildEvent>
|
| 298 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 299 | + </PostBuildEvent>
|
284 | 300 | </ItemDefinitionGroup>
|
285 | 301 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">
|
286 | 302 | <ClCompile>
|
— | — | @@ -310,6 +326,7 @@ |
311 | 327 | <PreBuildEvent>
|
312 | 328 | <Message>Create version headers</Message>
|
313 | 329 | </PreBuildEvent>
|
| 330 | + <PostBuildEvent />
|
314 | 331 | </ItemDefinitionGroup>
|
315 | 332 | <ItemGroup>
|
316 | 333 | <None Include="ddraw.def" />
|
Index: dxgl.sln |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | ProjectSection(ProjectDependencies) = postProject
|
9 | 9 | {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE}
|
10 | 10 | {55A95F84-E00E-4C65-BB09-41D27C5845AC} = {55A95F84-E00E-4C65-BB09-41D27C5845AC}
|
| 11 | + {34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0} = {34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0}
|
11 | 12 | {87D591EB-B598-431B-9B3B-D0FF771AB473} = {87D591EB-B598-431B-9B3B-D0FF771AB473}
|
12 | 13 | EndProjectSection
|
13 | 14 | EndProject
|
Index: dxglcfg/dxglcfg.vcxproj |
— | — | @@ -132,6 +132,9 @@ |
133 | 133 | <GenerateDebugInformation>true</GenerateDebugInformation>
|
134 | 134 | <AdditionalDependencies>winmm.lib;$(OutDir)cfgmgr.lib;opengl32.lib;Comctl32.lib;Version.lib;Htmlhelp.lib;$(OutDir)ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
135 | 135 | </Link>
|
| 136 | + <PostBuildEvent>
|
| 137 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 138 | + </PostBuildEvent>
|
136 | 139 | </ItemDefinitionGroup>
|
137 | 140 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug VS2019|Win32'">
|
138 | 141 | <ClCompile>
|
— | — | @@ -147,6 +150,9 @@ |
148 | 151 | <GenerateDebugInformation>true</GenerateDebugInformation>
|
149 | 152 | <AdditionalDependencies>winmm.lib;$(OutDir)cfgmgr.lib;opengl32.lib;Comctl32.lib;Version.lib;Htmlhelp.lib;$(OutDir)ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
150 | 153 | </Link>
|
| 154 | + <PostBuildEvent>
|
| 155 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 156 | + </PostBuildEvent>
|
151 | 157 | </ItemDefinitionGroup>
|
152 | 158 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">
|
153 | 159 | <ClCompile>
|
— | — | @@ -162,6 +168,9 @@ |
163 | 169 | <GenerateDebugInformation>true</GenerateDebugInformation>
|
164 | 170 | <AdditionalDependencies>winmm.lib;$(OutDir)cfgmgr.lib;opengl32.lib;Comctl32.lib;Version.lib;Htmlhelp.lib;$(OutDir)ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
165 | 171 | </Link>
|
| 172 | + <PostBuildEvent>
|
| 173 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 174 | + </PostBuildEvent>
|
166 | 175 | </ItemDefinitionGroup>
|
167 | 176 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
168 | 177 | <ClCompile>
|
— | — | @@ -181,6 +190,9 @@ |
182 | 191 | <OptimizeReferences>true</OptimizeReferences>
|
183 | 192 | <AdditionalDependencies>winmm.lib;$(OutDir)cfgmgr.lib;opengl32.lib;Comctl32.lib;Version.lib;Htmlhelp.lib;$(OutDir)ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
184 | 193 | </Link>
|
| 194 | + <PostBuildEvent>
|
| 195 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 196 | + </PostBuildEvent>
|
185 | 197 | </ItemDefinitionGroup>
|
186 | 198 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release VS2019|Win32'">
|
187 | 199 | <ClCompile>
|
— | — | @@ -200,6 +212,9 @@ |
201 | 213 | <OptimizeReferences>true</OptimizeReferences>
|
202 | 214 | <AdditionalDependencies>winmm.lib;$(OutDir)cfgmgr.lib;opengl32.lib;Comctl32.lib;Version.lib;Htmlhelp.lib;$(OutDir)ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
203 | 215 | </Link>
|
| 216 | + <PostBuildEvent>
|
| 217 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 218 | + </PostBuildEvent>
|
204 | 219 | </ItemDefinitionGroup>
|
205 | 220 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">
|
206 | 221 | <ClCompile>
|
— | — | @@ -219,6 +234,9 @@ |
220 | 235 | <OptimizeReferences>true</OptimizeReferences>
|
221 | 236 | <AdditionalDependencies>winmm.lib;$(OutDir)cfgmgr.lib;opengl32.lib;Comctl32.lib;Version.lib;Htmlhelp.lib;$(OutDir)ddraw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
222 | 237 | </Link>
|
| 238 | + <PostBuildEvent>
|
| 239 | + <Command>"$(OutDir)buildtool.exe" sign "$(OutDir)$(TargetName)$(TargetExt)"</Command>
|
| 240 | + </PostBuildEvent>
|
223 | 241 | </ItemDefinitionGroup>
|
224 | 242 | <ItemGroup>
|
225 | 243 | <ResourceCompile Include="dxglcfg.rc" />
|