├── .config ├── 1espt │ └── PipelineAutobaseliningConfig.yml └── guardian │ └── .gdnbaselines ├── .gitattributes ├── .github └── CODEOWNERS ├── .gitignore ├── .gitmodules ├── .pipelines ├── iis.compression.build.1es.yml ├── iis.compression.build.dev.yml └── iis.compression.build.official.yml ├── Compression.sln ├── CustomAction ├── avoid_restart.cpp ├── iiscompressionCA.cpp ├── iiscompressionCA.def ├── iiscompressionCA.rc ├── iiscompressionCA.vcxproj └── packages.config ├── Directory.Build.props ├── Installer ├── Setup.wixproj ├── ThirdPartyNotices.txt ├── bitmaps │ ├── bannrbmp.bmp │ ├── dlgbmp.bmp │ └── iiscompression.ico ├── iiscompression.wxs ├── iiscompression_readme.htm ├── license │ └── License.rtf └── packages.config ├── LICENSE ├── NuGet.config ├── README.md ├── SECURITY.md ├── ThirdPartyNotices.txt ├── brotli ├── brotli.vcxproj ├── brotli.vcxproj.filters └── packages.config ├── build.cmd ├── build ├── submodule-exports.props └── submodule.props ├── cgmanifest.json ├── iisbrotli ├── dllmain.cpp ├── iisbrotli.cpp ├── iisbrotli.def ├── iisbrotli.rc ├── iisbrotli.vcxproj ├── iisbrotli_msg.mc ├── packages.config ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── iiszlib ├── dllmain.cpp ├── iiszlib.cxx ├── iiszlib.def ├── iiszlib.rc ├── iiszlib.vcxproj ├── iiszlib_msg.mc ├── packages.config ├── stdafx.cpp ├── stdafx.h └── targetver.h └── zlib ├── packages.config └── zlib.vcxproj /.config/1espt/PipelineAutobaseliningConfig.yml: -------------------------------------------------------------------------------- 1 | ## DO NOT MODIFY THIS FILE MANUALLY. This is part of auto-baselining from 1ES Pipeline Templates. Go to [https://aka.ms/1espt-autobaselining] for more details. 2 | 3 | pipelines: 4 | 21134: 5 | retail: 6 | source: 7 | credscan: 8 | lastModifiedDate: 2025-02-13 9 | eslint: 10 | lastModifiedDate: 2025-02-13 11 | psscriptanalyzer: 12 | lastModifiedDate: 2025-02-13 13 | armory: 14 | lastModifiedDate: 2025-02-13 15 | binary: 16 | credscan: 17 | lastModifiedDate: 2025-02-13 18 | binskim: 19 | lastModifiedDate: 2025-02-13 20 | spotbugs: 21 | lastModifiedDate: 2025-02-13 22 | -------------------------------------------------------------------------------- /.config/guardian/.gdnbaselines: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/baselines" 4 | }, 5 | "version": "1.0.0", 6 | "baselines": { 7 | "default": { 8 | "name": "default", 9 | "createdDate": "2025-02-13 01:00:18Z", 10 | "lastUpdatedDate": "2025-02-13 01:00:18Z" 11 | } 12 | }, 13 | "results": { 14 | "e37031ee79362c9ff0735013edbeb833842bd30450c977d39d271f9d74c2c6a8": { 15 | "signature": "e37031ee79362c9ff0735013edbeb833842bd30450c977d39d271f9d74c2c6a8", 16 | "alternativeSignatures": [ 17 | "822d02459337aa61460710bc478bfa54f80107394b9a6e80edf431d87dd1a2f1" 18 | ], 19 | "target": "Binaries/arm64/iiszlib.dll", 20 | "memberOf": [ 21 | "default" 22 | ], 23 | "tool": "binskim", 24 | "ruleId": "BA2007", 25 | "createdDate": "2025-05-06 20:48:52Z" 26 | }, 27 | "8512889e3c4bfacec9c388518a64474bbb56443c73dfc158b935463bd1a46848": { 28 | "signature": "8512889e3c4bfacec9c388518a64474bbb56443c73dfc158b935463bd1a46848", 29 | "alternativeSignatures": [ 30 | "59a1005be0e80fa93deecbbdbf152e8e75233fe2ec3483eec6008c64fdf8e194" 31 | ], 32 | "target": "Binaries/x64/iiszlib.dll", 33 | "memberOf": [ 34 | "default" 35 | ], 36 | "tool": "binskim", 37 | "ruleId": "BA2007", 38 | "createdDate": "2025-02-13 01:00:18Z", 39 | "expirationDate": "2025-08-02 01:05:30Z", 40 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 41 | }, 42 | "66454d10288e2b2c2ab0ad564bd49c0db70b63c83a2d4688ec5984a5df9f193a": { 43 | "signature": "66454d10288e2b2c2ab0ad564bd49c0db70b63c83a2d4688ec5984a5df9f193a", 44 | "alternativeSignatures": [ 45 | "e653e764969c0e6420979849cf3610a7e8395b15dfaf2fe11fb12c9b03adbdad" 46 | ], 47 | "target": "Binaries/x86/iiszlib.dll", 48 | "memberOf": [ 49 | "default" 50 | ], 51 | "tool": "binskim", 52 | "ruleId": "BA2007", 53 | "createdDate": "2025-02-13 01:00:18Z", 54 | "expirationDate": "2025-08-02 01:05:30Z", 55 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 56 | }, 57 | "f6b430782fbc2806394a18df637061429eebf9af69b8408c2498948b95fd1d6f": { 58 | "signature": "f6b430782fbc2806394a18df637061429eebf9af69b8408c2498948b95fd1d6f", 59 | "alternativeSignatures": [ 60 | "637521c854de8234d1832945abab6b0e436d3eafc02cbbc20360a1a4b4a13f85" 61 | ], 62 | "target": "Sources/IIS-Common/Managed/References/v7Sp1/Microsoft.Web.administration.dll", 63 | "memberOf": [ 64 | "default" 65 | ], 66 | "tool": "binskim", 67 | "ruleId": "BA2009", 68 | "createdDate": "2025-02-13 01:03:51Z", 69 | "expirationDate": "2025-08-02 01:05:30Z", 70 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 71 | }, 72 | "b4dbb25b34967ae5ab0ae57f47be8b8d4bc85f35a22a9245642356542819bf9d": { 73 | "signature": "b4dbb25b34967ae5ab0ae57f47be8b8d4bc85f35a22a9245642356542819bf9d", 74 | "alternativeSignatures": [ 75 | "3af61c2964a083e60f189df73d9ba69fdd2698f045084b2ea59dbc9be263050d" 76 | ], 77 | "target": "Sources/IIS-Common/Managed/References/v7Sp1/Microsoft.Web.administration.dll", 78 | "memberOf": [ 79 | "default" 80 | ], 81 | "tool": "binskim", 82 | "ruleId": "BA2016", 83 | "createdDate": "2025-02-13 01:03:51Z", 84 | "expirationDate": "2025-08-02 01:05:30Z", 85 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 86 | }, 87 | "142d82423b56bfff9304ce7a055dde1466b07538afcb6796998cc8284cc32aad": { 88 | "signature": "142d82423b56bfff9304ce7a055dde1466b07538afcb6796998cc8284cc32aad", 89 | "alternativeSignatures": [ 90 | "e7c4d03544e21daf7e2f1ec3bbd2f72acf80c5e46896d439b5017cceba47999d" 91 | ], 92 | "target": "Sources/IIS-Common/Managed/References/v7Sp1/Microsoft.Web.management.dll", 93 | "memberOf": [ 94 | "default" 95 | ], 96 | "tool": "binskim", 97 | "ruleId": "BA2009", 98 | "createdDate": "2025-02-13 01:03:51Z", 99 | "expirationDate": "2025-08-02 01:05:30Z", 100 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 101 | }, 102 | "2b43dcf81fcf9a3a3775a02ac2da45ed7e1b4b25a7be7ca77eb8c4329ce81f1a": { 103 | "signature": "2b43dcf81fcf9a3a3775a02ac2da45ed7e1b4b25a7be7ca77eb8c4329ce81f1a", 104 | "alternativeSignatures": [ 105 | "3f6f4803523b60894bcbbc745d43c82825eaaf10dcbcd255867295793714b09f" 106 | ], 107 | "target": "Sources/IIS-Common/Managed/References/v7Sp1/Microsoft.Web.management.dll", 108 | "memberOf": [ 109 | "default" 110 | ], 111 | "tool": "binskim", 112 | "ruleId": "BA2016", 113 | "createdDate": "2025-02-13 01:03:51Z", 114 | "expirationDate": "2025-08-02 01:05:30Z", 115 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 116 | }, 117 | "d4a3b367fc7d906a5403e23374175d34924128437f2a398ca09aa0d98d9a80e5": { 118 | "signature": "d4a3b367fc7d906a5403e23374175d34924128437f2a398ca09aa0d98d9a80e5", 119 | "alternativeSignatures": [ 120 | "f7994281b8a70894438561f9aa19bf3efe7af50bc0b1a7b0e2b677a3475b7fa1" 121 | ], 122 | "target": "Sources/IIS-Common/tools/mof2trace/amd64fre/mof2trace.exe", 123 | "memberOf": [ 124 | "default" 125 | ], 126 | "tool": "binskim", 127 | "ruleId": "BA2010", 128 | "createdDate": "2025-02-13 01:03:51Z", 129 | "expirationDate": "2025-08-02 01:05:30Z", 130 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 131 | }, 132 | "d976d0c6ec31f8e48eec3f1f2590ca25b638cf275bb65c120cb718204e701426": { 133 | "signature": "d976d0c6ec31f8e48eec3f1f2590ca25b638cf275bb65c120cb718204e701426", 134 | "alternativeSignatures": [ 135 | "08f4a84105725a4b9f3b47a0a2ea1c58f935afba70f729c78d1d02441348bcb8" 136 | ], 137 | "target": "Sources/IIS-Common/tools/mof2trace/x86fre/mof2trace.exe", 138 | "memberOf": [ 139 | "default" 140 | ], 141 | "tool": "binskim", 142 | "ruleId": "BA2010", 143 | "createdDate": "2025-02-13 01:03:51Z", 144 | "expirationDate": "2025-08-02 01:05:30Z", 145 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 146 | }, 147 | "698fef2bb40721c880a17702b0340d1a1c8af219a7485c7034322d28715096e1": { 148 | "signature": "698fef2bb40721c880a17702b0340d1a1c8af219a7485c7034322d28715096e1", 149 | "alternativeSignatures": [ 150 | "e7dbee8575cbf08168750f3bbb62b01d79cb216a02e0c367a8944c2bcea66c88" 151 | ], 152 | "target": "Sources/IIS-Setup/IIS-Common/Managed/References/v7Sp1/Microsoft.Web.administration.dll", 153 | "memberOf": [ 154 | "default" 155 | ], 156 | "tool": "binskim", 157 | "ruleId": "BA2009", 158 | "createdDate": "2025-02-13 01:03:51Z", 159 | "expirationDate": "2025-08-02 01:05:30Z", 160 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 161 | }, 162 | "349ab50e57a8aa29a986f4e8b74146257629e25456d9f6a64d7b39329fdc1a2b": { 163 | "signature": "349ab50e57a8aa29a986f4e8b74146257629e25456d9f6a64d7b39329fdc1a2b", 164 | "alternativeSignatures": [ 165 | "06bec7e330b9097f7a81af7cf7ab95bfc91ff1ea496d02ef97f8644608c97592" 166 | ], 167 | "target": "Sources/IIS-Setup/IIS-Common/Managed/References/v7Sp1/Microsoft.Web.administration.dll", 168 | "memberOf": [ 169 | "default" 170 | ], 171 | "tool": "binskim", 172 | "ruleId": "BA2016", 173 | "createdDate": "2025-02-13 01:03:51Z", 174 | "expirationDate": "2025-08-02 01:05:30Z", 175 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 176 | }, 177 | "7b715daaceb0500038d273e791a11b88d2c3904f289ffc935cd96736989a68fc": { 178 | "signature": "7b715daaceb0500038d273e791a11b88d2c3904f289ffc935cd96736989a68fc", 179 | "alternativeSignatures": [ 180 | "ac77235f5d2490debb1530316df6d319e46d75aaff811dc4896d314a85d8058f" 181 | ], 182 | "target": "Sources/IIS-Setup/IIS-Common/Managed/References/v7Sp1/Microsoft.Web.management.dll", 183 | "memberOf": [ 184 | "default" 185 | ], 186 | "tool": "binskim", 187 | "ruleId": "BA2009", 188 | "createdDate": "2025-02-13 01:03:51Z", 189 | "expirationDate": "2025-08-02 01:05:30Z", 190 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 191 | }, 192 | "ef9e8a007b57d0b1dd3dc0fa18f4bf81fe52d3bcf929ce9dff314704f1041885": { 193 | "signature": "ef9e8a007b57d0b1dd3dc0fa18f4bf81fe52d3bcf929ce9dff314704f1041885", 194 | "alternativeSignatures": [ 195 | "aa76558afe30036a5103bedef031a9c5fe6ef8b32100a32efeb61fdce6dca424" 196 | ], 197 | "target": "Sources/IIS-Setup/IIS-Common/Managed/References/v7Sp1/Microsoft.Web.management.dll", 198 | "memberOf": [ 199 | "default" 200 | ], 201 | "tool": "binskim", 202 | "ruleId": "BA2016", 203 | "createdDate": "2025-02-13 01:03:51Z", 204 | "expirationDate": "2025-08-02 01:05:30Z", 205 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 206 | }, 207 | "2bddce988f50cfacea3df8ab3ac47c1118c3af84c531fce39f50c1fc7bc59add": { 208 | "signature": "2bddce988f50cfacea3df8ab3ac47c1118c3af84c531fce39f50c1fc7bc59add", 209 | "alternativeSignatures": [ 210 | "1a6412f0a821a7a0bcb8c1a25345f1166c8f5c5a808a7080609ab5f6dc66205b" 211 | ], 212 | "target": "Sources/IIS-Setup/IIS-Common/tools/mof2trace/amd64fre/mof2trace.exe", 213 | "memberOf": [ 214 | "default" 215 | ], 216 | "tool": "binskim", 217 | "ruleId": "BA2010", 218 | "createdDate": "2025-02-13 01:03:51Z", 219 | "expirationDate": "2025-08-02 01:05:30Z", 220 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 221 | }, 222 | "a67df0b4e70e5a60add1a9f64b820571ee4b5a5ea277f07aed63d32ceb4764e8": { 223 | "signature": "a67df0b4e70e5a60add1a9f64b820571ee4b5a5ea277f07aed63d32ceb4764e8", 224 | "alternativeSignatures": [ 225 | "d0426084b147fd570ff98d924d1f5d59a6bb5672b8c16f219953b0e96a74ec02" 226 | ], 227 | "target": "Sources/IIS-Setup/IIS-Common/tools/mof2trace/x86fre/mof2trace.exe", 228 | "memberOf": [ 229 | "default" 230 | ], 231 | "tool": "binskim", 232 | "ruleId": "BA2010", 233 | "createdDate": "2025-02-13 01:03:51Z", 234 | "expirationDate": "2025-08-02 01:05:30Z", 235 | "justification": "This error is baselined with an expiration date of 180 days from 2025-02-13 01:05:30Z" 236 | } 237 | } 238 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.doc diff=astextplain 2 | *.DOC diff=astextplain 3 | *.docx diff=astextplain 4 | *.DOCX diff=astextplain 5 | *.dot diff=astextplain 6 | *.DOT diff=astextplain 7 | *.pdf diff=astextplain 8 | *.PDF diff=astextplain 9 | *.rtf diff=astextplain 10 | *.RTF diff=astextplain 11 | 12 | *.jpg binary 13 | *.png binary 14 | *.gif binary 15 | 16 | *.cs text=auto diff=csharp 17 | *.vb text=auto 18 | *.resx text=auto 19 | *.c text=auto 20 | *.cpp text=auto 21 | *.cxx text=auto 22 | *.h text=auto 23 | *.hxx text=auto 24 | *.py text=auto 25 | *.rb text=auto 26 | *.java text=auto 27 | *.html text=auto 28 | *.htm text=auto 29 | *.css text=auto 30 | *.scss text=auto 31 | *.sass text=auto 32 | *.less text=auto 33 | *.js text=auto 34 | *.lisp text=auto 35 | *.clj text=auto 36 | *.sql text=auto 37 | *.php text=auto 38 | *.lua text=auto 39 | *.m text=auto 40 | *.asm text=auto 41 | *.erl text=auto 42 | *.fs text=auto 43 | *.fsx text=auto 44 | *.hs text=auto 45 | 46 | *.csproj text=auto 47 | *.vbproj text=auto 48 | *.fsproj text=auto 49 | *.dbproj text=auto 50 | *.sln text=auto eol=crlf 51 | *.sh eol=lf 52 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | @Microsoft/iis-contributor 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Oo]bj/ 2 | [Bb]in/ 3 | .nuget/ 4 | *.sln.ide/ 5 | _ReSharper.*/ 6 | packages/ 7 | artifacts/ 8 | PublishProfiles/ 9 | *.user 10 | *.suo 11 | *.cache 12 | *.docstates 13 | _ReSharper.* 14 | nuget.exe 15 | project.lock.json 16 | *net45.csproj 17 | *net451.csproj 18 | *k10.csproj 19 | *.psess 20 | *.vsp 21 | *.pidb 22 | *.userprefs 23 | *DS_Store 24 | *.ncrunchsolution 25 | *.*sdf 26 | *.ipch 27 | *.bin 28 | *.vs/ 29 | **/*.log 30 | **/*.binlog 31 | .testPublish/ 32 | 33 | *.obj 34 | *.tlog 35 | *.CppClean.log 36 | 37 | *.aps 38 | *.pdb 39 | *.lib 40 | *.idb 41 | 42 | .build 43 | 44 | *.VC.*db 45 | global.json 46 | korebuild-lock.txt 47 | 48 | *.exp 49 | *.exe 50 | *.iobj 51 | *.ipdb 52 | *.res 53 | **/RC* 54 | 55 | # Generated files 56 | GeneratedFiles 57 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "IIS-Common"] 2 | path = IIS-Common 3 | url = https://github.com/Microsoft/IIS.Common.git 4 | [submodule "IIS-Setup"] 5 | path = IIS-Setup 6 | url = https://github.com/Microsoft/IIS.Setup.git 7 | [submodule "submodules/zlib"] 8 | path = submodules/zlib 9 | url = https://github.com/madler/zlib.git 10 | [submodule "submodules/brotli"] 11 | path = submodules/brotli 12 | url = https://github.com/google/brotli.git 13 | -------------------------------------------------------------------------------- /.pipelines/iis.compression.build.1es.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: solution 3 | type: string 4 | default: '**\Compression.sln' 5 | - name: restoreSolution 6 | type: string 7 | default: 'Compression.sln;IIS-Setup/IIS-Setup.sln' 8 | - name: signType 9 | type: string 10 | default: 'Real' 11 | - name: productMajor 12 | type: number 13 | default: 1 14 | - name: productMinor 15 | type: number 16 | default: 0 17 | - name: buildMajor 18 | type: string 19 | default: '0' 20 | - name: buildMinor 21 | type: string 22 | default: '0' 23 | - name: indexSourcesAndPublishSymbols 24 | type: string 25 | default: 'true' 26 | - name: publishArtifactInstallers 27 | type: string 28 | default: 'true' 29 | - name: publishArtifactSources 30 | type: string 31 | default: 'true' 32 | - name: whiteListPathForAuthenticodeSign 33 | type: string 34 | default: '$(Build.SourcesDirectory)\IIS-Common\.azure\templates\no_authenticode.txt' 35 | - name: whiteListPathForStrongNameSign 36 | type: string 37 | default: ' ' 38 | - name: teamName 39 | type: string 40 | default: 'IIS.Compression' 41 | - name: codeQLEnabled 42 | type: string 43 | default: true 44 | name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) 45 | pr: none 46 | trigger: none 47 | resources: 48 | repositories: 49 | - repository: self 50 | type: git 51 | ref: refs/heads/main 52 | - repository: MicroBuildTemplate 53 | type: git 54 | name: 1ESPipelineTemplates/MicroBuildTemplate 55 | ref: refs/tags/release 56 | variables: 57 | TeamName: ${{ parameters.teamName }} 58 | ProductMajor: ${{ parameters.productMajor }} 59 | ProductMinor: ${{ parameters.productMinor }} 60 | BuildMajor: ${{ parameters.buildMajor }} 61 | BuildMinor: ${{ parameters.buildMinor }} 62 | SignType: ${{ parameters.signType }} 63 | SigningIdentity: 'Microsoft400' 64 | CodeQL.Enabled: ${{ parameters.codeQLEnabled }} 65 | msbuildArgs: '/p:RunWixToolsOutOfProc=true' 66 | buildConfiguration: Release 67 | extends: 68 | template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate 69 | parameters: 70 | sdl: 71 | sourceAnalysisPool: VSEngSS-MicroBuild2022-1ES 72 | pool: 73 | name: AzurePipelines-EO 74 | image: AzurePipelinesWindows2022compliantGPT 75 | os: windows 76 | customBuildTags: 77 | - ES365AIMigrationTooling 78 | stages: 79 | - stage: stage 80 | jobs: 81 | - job: Phase_1 82 | displayName: Build 83 | timeoutInMinutes: 0 84 | cancelTimeoutInMinutes: 1 85 | pool: 86 | name: VSEngSS-MicroBuild2022-1ES 87 | demands: 88 | - MSBuild_15.0_x64 89 | - MSBuild_15.0 90 | templateContext: 91 | mb: 92 | signing: 93 | enabled: true 94 | signType: $(SignType) 95 | outputs: 96 | - output: pipelineArtifact 97 | displayName: 'Publish Artifact: Binaries' 98 | targetPath: '$(Build.ArtifactStagingDirectory)\Binaries' 99 | artifactName: Binaries 100 | - output: pipelineArtifact 101 | displayName: 'Publish Artifact: Symbols' 102 | targetPath: '$(Build.ArtifactStagingDirectory)\Symbols' 103 | artifactName: Symbols 104 | - ${{ if eq(parameters.publishArtifactInstallers, 'true') }}: 105 | - output: pipelineArtifact 106 | displayName: 'Publish Artifact: Installers' 107 | targetPath: '$(Build.ArtifactStagingDirectory)\Installers' 108 | artifactName: Installers 109 | - ${{ if eq(parameters.publishArtifactSources, 'true') }}: 110 | - output: pipelineArtifact 111 | displayName: 'Publish Artifact: Sources' 112 | targetPath: '$(Build.ArtifactStagingDirectory)\Sources' 113 | artifactName: Sources 114 | steps: 115 | - checkout: self 116 | fetchTags: false 117 | persistCredentials: True 118 | clean: true 119 | submodules: recursive 120 | - task: CopyFiles@2 121 | displayName: 'Copy Sources' 122 | inputs: 123 | sourceFolder: '$(Build.SourcesDirectory)' 124 | contents: | 125 | ** 126 | !.git\**\* 127 | targetFolder: '$(Build.ArtifactStagingDirectory)\Sources' 128 | - task: NuGetToolInstaller@1 129 | displayName: 'Install NuGet Tool' 130 | inputs: 131 | versionSpec: '>=4.7.1' 132 | - task: NuGetCommand@2 133 | displayName: 'NuGet restore' 134 | inputs: 135 | command: 'restore' 136 | restoreSolution: ${{ parameters.restoreSolution }} 137 | feedsToUse: config 138 | nugetConfigPath: NuGet.config 139 | - task: PowerShell@2 140 | displayName: 'Process Msbuild Arguments' 141 | inputs: 142 | targetType: inline 143 | script: | 144 | $MsbuildArgsDict = 145 | @{ 146 | "PRODUCT_MAJOR" = $env:PRODUCTMAJOR; 147 | "PRODUCT_MINOR" = $env:PRODUCTMINOR; 148 | "BUILD_MAJOR" = $env:BUILDMAJOR; 149 | "BUILD_MINOR" = $env:BUILDMINOR; 150 | "SignType" = $env:SIGNTYPE; 151 | "SigningIdentity" = $env:SIGNINGIDENTITY; 152 | }; 153 | $MsbuildArgs = "" 154 | foreach ($key in $MsbuildArgsDict.Keys) 155 | { 156 | if (![string]::IsNullOrEmpty($MsbuildArgsDict[$key])) 157 | { 158 | $MsbuildArgs += "/p:$($key)=$($MsbuildArgsDict[$key]) " 159 | } 160 | } 161 | Write-Host "$("##vso[task.setvariable variable=MsbuildArgs]") $($MsbuildArgs)" 162 | Write-Host "MsbuildArgs: $($MsbuildArgs)" 163 | - task: VSBuild@1 164 | displayName: 'Build x86' 165 | inputs: 166 | solution: ${{ parameters.solution }} 167 | vsVersion: 15.0 168 | msbuildArgs: $(MsbuildArgs) 169 | platform: x86 170 | configuration: $(buildConfiguration) 171 | clean: true 172 | msbuildArchitecture: x64 173 | - task: VSBuild@1 174 | displayName: 'Build x64' 175 | inputs: 176 | solution: ${{ parameters.solution }} 177 | vsVersion: 15.0 178 | msbuildArgs: $(MsbuildArgs) 179 | platform: x64 180 | configuration: $(buildConfiguration) 181 | clean: true 182 | msbuildArchitecture: x64 183 | - task: VSBuild@1 184 | displayName: 'Build ARM64' 185 | inputs: 186 | solution: ${{ parameters.solution }} 187 | vsVersion: 15.0 188 | msbuildArgs: $(MsbuildArgs) 189 | platform: arm64ec 190 | configuration: $(buildConfiguration) 191 | clean: true 192 | msbuildArchitecture: x64 193 | - task: CopyFiles@2 194 | displayName: 'Copy Binaries x86' 195 | inputs: 196 | sourceFolder: '$(Build.SourcesDirectory)\bin\$(buildConfiguration)\x86' 197 | contents: | 198 | **\*.dll 199 | **\*.exe 200 | targetFolder: '$(Build.ArtifactStagingDirectory)\Binaries\x86' 201 | - task: CopyFiles@2 202 | displayName: 'Copy Binaries x64' 203 | inputs: 204 | sourceFolder: '$(Build.SourcesDirectory)\bin\$(buildConfiguration)\x64' 205 | contents: | 206 | **\*.dll 207 | **\*.exe 208 | targetFolder: '$(Build.ArtifactStagingDirectory)\Binaries\x64' 209 | - task: CopyFiles@2 210 | displayName: 'Copy Binaries ARM64' 211 | inputs: 212 | sourceFolder: '$(Build.SourcesDirectory)\bin\$(buildConfiguration)\arm64' 213 | contents: | 214 | **\*.dll 215 | **\*.exe 216 | targetFolder: '$(Build.ArtifactStagingDirectory)\Binaries\arm64' 217 | - task: CopyFiles@2 218 | displayName: 'Copy Symbols x86' 219 | inputs: 220 | sourceFolder: '$(Build.SourcesDirectory)' 221 | contents: '**\x86\**\*.pdb' 222 | targetFolder: '$(Build.ArtifactStagingDirectory)\Symbols\x86' 223 | - task: CopyFiles@2 224 | displayName: 'Copy Symbols x64' 225 | inputs: 226 | sourceFolder: '$(Build.SourcesDirectory)' 227 | contents: '**\x64\**\*pdb' 228 | targetFolder: '$(Build.ArtifactStagingDirectory)\Symbols\x64' 229 | - task: CopyFiles@2 230 | displayName: 'Copy Symbols ARM64' 231 | inputs: 232 | sourceFolder: '$(Build.SourcesDirectory)' 233 | contents: '**\bin\**\arm64\**\*pdb' 234 | targetFolder: '$(Build.ArtifactStagingDirectory)\Symbols\arm64' 235 | - ${{ if eq(parameters.publishArtifactInstallers, 'true') }}: 236 | - task: CopyFiles@2 237 | displayName: 'Copy Installers x86' 238 | inputs: 239 | sourceFolder: '$(Build.SourcesDirectory)\bin\$(buildConfiguration)\x86' 240 | contents: '**\*.msi' 241 | targetFolder: '$(Build.ArtifactStagingDirectory)\Installers\x86' 242 | - task: CopyFiles@2 243 | displayName: 'Copy Installers x64' 244 | inputs: 245 | sourceFolder: '$(Build.SourcesDirectory)\bin\$(buildConfiguration)\x64' 246 | contents: '**\*.msi' 247 | targetFolder: '$(Build.ArtifactStagingDirectory)\Installers\x64' 248 | - task: CopyFiles@2 249 | displayName: 'Copy Installers ARM64' 250 | inputs: 251 | sourceFolder: '$(Build.SourcesDirectory)\bin\$(buildConfiguration)\arm64' 252 | contents: '**\*.msi' 253 | targetFolder: '$(Build.ArtifactStagingDirectory)\Installers\arm64' 254 | - task: ms-vseng.MicroBuildShipTasks.7c429315-71ba-4cb3-94bb-f829c95f7915.MicroBuildCodesignVerify@2 255 | displayName: 'Verify Signed Binaries' 256 | inputs: 257 | targetFolders: '$(Build.ArtifactStagingDirectory)\Binaries' 258 | whiteListPathForCerts: ${{ parameters.whiteListPathForAuthenticodeSign }} 259 | whiteListPathForSigs: ${{ parameters.whiteListPathForStrongNameSign }} 260 | - ${{ if eq(parameters.publishArtifactInstallers, 'true') }}: 261 | - task: ms-vseng.MicroBuildShipTasks.7c429315-71ba-4cb3-94bb-f829c95f7915.MicroBuildCodesignVerify@2 262 | displayName: 'Verify Signed Installers' 263 | inputs: 264 | targetFolders: '$(Build.ArtifactStagingDirectory)\Installers' 265 | whiteListPathForCerts: ${{ parameters.whiteListPathForAuthenticodeSign }} 266 | - ${{ if eq(parameters.indexSourcesAndPublishSymbols, 'true') }}: 267 | - task: PublishSymbols@2 268 | displayName: 'Enable Source Server' 269 | inputs: 270 | symbolsFolder: '$(Build.ArtifactStagingDirectory)\Symbols' 271 | searchPattern: '**\*.pdb' 272 | symbolServerType: TeamServices -------------------------------------------------------------------------------- /.pipelines/iis.compression.build.dev.yml: -------------------------------------------------------------------------------- 1 | name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) 2 | 3 | pr: 4 | - main 5 | 6 | trigger: 7 | batch: true 8 | branches: 9 | include: 10 | - main 11 | 12 | resources: 13 | repositories: 14 | - repository: MicrosoftIISCommon 15 | type: github 16 | name: Microsoft/IIS.Common 17 | endpoint: GitHub-IIS-Token 18 | 19 | jobs: 20 | - template: .azure\templates\build.yml@MicrosoftIISCommon 21 | parameters: 22 | agentPoolName: 'VSEngSS-MicroBuild2022-1ES' 23 | solution: '**\Compression.sln' 24 | restoreSolution: 'Compression.sln;IIS-Setup/IIS-Setup.sln' 25 | productMajor: 1 26 | productMinor: 0 27 | signType: 'test' 28 | publishArtifactInstallers: 'true' 29 | msbuildArgs: '/p:RunWixToolsOutOfProc=true' -------------------------------------------------------------------------------- /.pipelines/iis.compression.build.official.yml: -------------------------------------------------------------------------------- 1 | name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) 2 | 3 | pr: none 4 | trigger: none 5 | 6 | resources: 7 | repositories: 8 | - repository: MicrosoftIISCommon 9 | type: github 10 | name: Microsoft/IIS.Common 11 | endpoint: IIS-Github 12 | 13 | jobs: 14 | - template: .azure\templates\build.yml@MicrosoftIISCommon 15 | parameters: 16 | agentPoolName: 'VSEngSS-MicroBuild2022-1ES' 17 | solution: '**\Compression.sln' 18 | restoreSolution: 'Compression.sln;IIS-Setup/IIS-Setup.sln' 19 | productMajor: 1 20 | productMinor: 0 21 | signType: 'real' 22 | indexSourcesAndPublishSymbols: 'true' 23 | publishArtifactInstallers: 'true' 24 | publishArtifactSources: 'true' 25 | whiteListPathForAuthenticodeSign: '$(Build.SourcesDirectory)\IIS-Common\.azure\templates\no_authenticode.txt' 26 | msbuildArgs: '/p:RunWixToolsOutOfProc=true' 27 | -------------------------------------------------------------------------------- /Compression.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.11.35431.28 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iiszlib", "iiszlib\iiszlib.vcxproj", "{57619DE0-503C-4758-97BC-5AFA0A029BFA}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iisbrotli", "iisbrotli\iisbrotli.vcxproj", "{CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcxproj", "{8D460A29-85AF-4884-A839-160862A94130}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "brotli", "brotli\brotli.vcxproj", "{67AAF490-C8A7-4020-BB96-593B2001EA4D}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CompressionSchemes", "CompressionSchemes", "{FED855C7-07AF-4376-A4DA-73A15970002D}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{634E96A0-30A6-4861-87A0-C7B45A6030F0}" 17 | EndProject 18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installer", "Installer", "{9505B06E-5E2A-4E50-8B7A-63D2358D6AE6}" 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iiscompressionCA", "CustomAction\iiscompressionCA.vcxproj", "{4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}" 21 | EndProject 22 | Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup", "Installer\Setup.wixproj", "{1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}" 23 | ProjectSection(ProjectDependencies) = postProject 24 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2} = {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2} 25 | {57619DE0-503C-4758-97BC-5AFA0A029BFA} = {57619DE0-503C-4758-97BC-5AFA0A029BFA} 26 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A} = {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A} 27 | EndProjectSection 28 | EndProject 29 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CommonLib", "IIS-Common\lib\CommonLib.vcxproj", "{B54A8F61-60DE-4AD9-87CA-D102F230678E}" 30 | EndProject 31 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iisca", "IIS-Setup\iisca\lib\iisca.vcxproj", "{7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}" 32 | EndProject 33 | Global 34 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 35 | Debug|ARM64 = Debug|ARM64 36 | Debug|ARM64EC = Debug|ARM64EC 37 | Debug|x64 = Debug|x64 38 | Debug|x86 = Debug|x86 39 | Release|ARM64 = Release|ARM64 40 | Release|ARM64EC = Release|ARM64EC 41 | Release|x64 = Release|x64 42 | Release|x86 = Release|x86 43 | EndGlobalSection 44 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 45 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Debug|ARM64.ActiveCfg = Debug|ARM64 46 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Debug|ARM64.Build.0 = Debug|ARM64 47 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC 48 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Debug|ARM64EC.Build.0 = Debug|ARM64EC 49 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Debug|x64.ActiveCfg = Debug|x64 50 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Debug|x64.Build.0 = Debug|x64 51 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Debug|x86.ActiveCfg = Debug|Win32 52 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Debug|x86.Build.0 = Debug|Win32 53 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Release|ARM64.ActiveCfg = Release|ARM64 54 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Release|ARM64.Build.0 = Release|ARM64 55 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Release|ARM64EC.ActiveCfg = Release|ARM64EC 56 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Release|ARM64EC.Build.0 = Release|ARM64EC 57 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Release|x64.ActiveCfg = Release|x64 58 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Release|x64.Build.0 = Release|x64 59 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Release|x86.ActiveCfg = Release|Win32 60 | {57619DE0-503C-4758-97BC-5AFA0A029BFA}.Release|x86.Build.0 = Release|Win32 61 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Debug|ARM64.ActiveCfg = Debug|ARM64 62 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Debug|ARM64.Build.0 = Debug|ARM64 63 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC 64 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Debug|ARM64EC.Build.0 = Debug|ARM64EC 65 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Debug|x64.ActiveCfg = Debug|x64 66 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Debug|x64.Build.0 = Debug|x64 67 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Debug|x86.ActiveCfg = Debug|Win32 68 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Debug|x86.Build.0 = Debug|Win32 69 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Release|ARM64.ActiveCfg = Release|ARM64 70 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Release|ARM64.Build.0 = Release|ARM64 71 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Release|ARM64EC.ActiveCfg = Release|ARM64EC 72 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Release|ARM64EC.Build.0 = Release|ARM64EC 73 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Release|x64.ActiveCfg = Release|x64 74 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Release|x64.Build.0 = Release|x64 75 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Release|x86.ActiveCfg = Release|Win32 76 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A}.Release|x86.Build.0 = Release|Win32 77 | {8D460A29-85AF-4884-A839-160862A94130}.Debug|ARM64.ActiveCfg = Debug|ARM64 78 | {8D460A29-85AF-4884-A839-160862A94130}.Debug|ARM64.Build.0 = Debug|ARM64 79 | {8D460A29-85AF-4884-A839-160862A94130}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC 80 | {8D460A29-85AF-4884-A839-160862A94130}.Debug|ARM64EC.Build.0 = Debug|ARM64EC 81 | {8D460A29-85AF-4884-A839-160862A94130}.Debug|x64.ActiveCfg = Debug|x64 82 | {8D460A29-85AF-4884-A839-160862A94130}.Debug|x64.Build.0 = Debug|x64 83 | {8D460A29-85AF-4884-A839-160862A94130}.Debug|x86.ActiveCfg = Debug|Win32 84 | {8D460A29-85AF-4884-A839-160862A94130}.Debug|x86.Build.0 = Debug|Win32 85 | {8D460A29-85AF-4884-A839-160862A94130}.Release|ARM64.ActiveCfg = Release|ARM64 86 | {8D460A29-85AF-4884-A839-160862A94130}.Release|ARM64.Build.0 = Release|ARM64 87 | {8D460A29-85AF-4884-A839-160862A94130}.Release|ARM64EC.ActiveCfg = Release|ARM64EC 88 | {8D460A29-85AF-4884-A839-160862A94130}.Release|ARM64EC.Build.0 = Release|ARM64EC 89 | {8D460A29-85AF-4884-A839-160862A94130}.Release|x64.ActiveCfg = Release|x64 90 | {8D460A29-85AF-4884-A839-160862A94130}.Release|x64.Build.0 = Release|x64 91 | {8D460A29-85AF-4884-A839-160862A94130}.Release|x86.ActiveCfg = Release|Win32 92 | {8D460A29-85AF-4884-A839-160862A94130}.Release|x86.Build.0 = Release|Win32 93 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Debug|ARM64.ActiveCfg = Debug|ARM64 94 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Debug|ARM64.Build.0 = Debug|ARM64 95 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC 96 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Debug|ARM64EC.Build.0 = Debug|ARM64EC 97 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Debug|x64.ActiveCfg = Debug|x64 98 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Debug|x64.Build.0 = Debug|x64 99 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Debug|x86.ActiveCfg = Debug|Win32 100 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Debug|x86.Build.0 = Debug|Win32 101 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Release|ARM64.ActiveCfg = Release|ARM64 102 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Release|ARM64.Build.0 = Release|ARM64 103 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Release|ARM64EC.ActiveCfg = Release|ARM64EC 104 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Release|ARM64EC.Build.0 = Release|ARM64EC 105 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Release|x64.ActiveCfg = Release|x64 106 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Release|x64.Build.0 = Release|x64 107 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Release|x86.ActiveCfg = Release|Win32 108 | {67AAF490-C8A7-4020-BB96-593B2001EA4D}.Release|x86.Build.0 = Release|Win32 109 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Debug|ARM64.ActiveCfg = Debug|ARM64 110 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Debug|ARM64.Build.0 = Debug|ARM64 111 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 112 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Debug|ARM64EC.Build.0 = Debug|ARM64 113 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Debug|x64.ActiveCfg = Debug|x64 114 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Debug|x64.Build.0 = Debug|x64 115 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Debug|x86.ActiveCfg = Debug|Win32 116 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Debug|x86.Build.0 = Debug|Win32 117 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Release|ARM64.ActiveCfg = Release|ARM64 118 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Release|ARM64.Build.0 = Release|ARM64 119 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Release|ARM64EC.ActiveCfg = Release|ARM64 120 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Release|ARM64EC.Build.0 = Release|ARM64 121 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Release|x64.ActiveCfg = Release|x64 122 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Release|x64.Build.0 = Release|x64 123 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Release|x86.ActiveCfg = Release|Win32 124 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2}.Release|x86.Build.0 = Release|Win32 125 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Debug|ARM64.ActiveCfg = Debug|ARM64 126 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Debug|ARM64.Build.0 = Debug|ARM64 127 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 128 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Debug|ARM64EC.Build.0 = Debug|ARM64 129 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Debug|x64.ActiveCfg = Debug|x64 130 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Debug|x64.Build.0 = Debug|x64 131 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Debug|x86.ActiveCfg = Debug|x86 132 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Debug|x86.Build.0 = Debug|x86 133 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Release|ARM64.ActiveCfg = Release|ARM64 134 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Release|ARM64.Build.0 = Release|ARM64 135 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Release|ARM64EC.ActiveCfg = Release|ARM64 136 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Release|ARM64EC.Build.0 = Release|ARM64 137 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Release|x64.ActiveCfg = Release|x64 138 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Release|x64.Build.0 = Release|x64 139 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Release|x86.ActiveCfg = Release|x86 140 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744}.Release|x86.Build.0 = Release|x86 141 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Debug|ARM64.ActiveCfg = Debug|ARM64 142 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Debug|ARM64.Build.0 = Debug|ARM64 143 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 144 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Debug|ARM64EC.Build.0 = Debug|ARM64 145 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Debug|x64.ActiveCfg = Debug|x64 146 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Debug|x64.Build.0 = Debug|x64 147 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Debug|x86.ActiveCfg = Debug|Win32 148 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Debug|x86.Build.0 = Debug|Win32 149 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Release|ARM64.ActiveCfg = Release|ARM64 150 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Release|ARM64.Build.0 = Release|ARM64 151 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Release|ARM64EC.ActiveCfg = Release|ARM64 152 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Release|ARM64EC.Build.0 = Release|ARM64 153 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Release|x64.ActiveCfg = Release|x64 154 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Release|x64.Build.0 = Release|x64 155 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Release|x86.ActiveCfg = Release|Win32 156 | {B54A8F61-60DE-4AD9-87CA-D102F230678E}.Release|x86.Build.0 = Release|Win32 157 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Debug|ARM64.ActiveCfg = Debug|ARM64 158 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Debug|ARM64.Build.0 = Debug|ARM64 159 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Debug|ARM64EC.ActiveCfg = Debug|ARM64 160 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Debug|ARM64EC.Build.0 = Debug|ARM64 161 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Debug|x64.ActiveCfg = Debug|x64 162 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Debug|x64.Build.0 = Debug|x64 163 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Debug|x86.ActiveCfg = Debug|Win32 164 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Debug|x86.Build.0 = Debug|Win32 165 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Release|ARM64.ActiveCfg = Release|ARM64 166 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Release|ARM64.Build.0 = Release|ARM64 167 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Release|ARM64EC.ActiveCfg = Release|ARM64 168 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Release|ARM64EC.Build.0 = Release|ARM64 169 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Release|x64.ActiveCfg = Release|x64 170 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Release|x64.Build.0 = Release|x64 171 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Release|x86.ActiveCfg = Release|Win32 172 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E}.Release|x86.Build.0 = Release|Win32 173 | EndGlobalSection 174 | GlobalSection(SolutionProperties) = preSolution 175 | HideSolutionNode = FALSE 176 | EndGlobalSection 177 | GlobalSection(NestedProjects) = preSolution 178 | {57619DE0-503C-4758-97BC-5AFA0A029BFA} = {FED855C7-07AF-4376-A4DA-73A15970002D} 179 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A} = {FED855C7-07AF-4376-A4DA-73A15970002D} 180 | {8D460A29-85AF-4884-A839-160862A94130} = {634E96A0-30A6-4861-87A0-C7B45A6030F0} 181 | {67AAF490-C8A7-4020-BB96-593B2001EA4D} = {634E96A0-30A6-4861-87A0-C7B45A6030F0} 182 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2} = {9505B06E-5E2A-4E50-8B7A-63D2358D6AE6} 183 | {1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744} = {9505B06E-5E2A-4E50-8B7A-63D2358D6AE6} 184 | {B54A8F61-60DE-4AD9-87CA-D102F230678E} = {634E96A0-30A6-4861-87A0-C7B45A6030F0} 185 | {7324770C-0871-4D73-BE3D-5E2F3E9E1B1E} = {634E96A0-30A6-4861-87A0-C7B45A6030F0} 186 | EndGlobalSection 187 | GlobalSection(ExtensibilityGlobals) = postSolution 188 | SolutionGuid = {446C09C4-34F0-4512-9E61-888C20633532} 189 | EndGlobalSection 190 | EndGlobal 191 | -------------------------------------------------------------------------------- /CustomAction/avoid_restart.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #include 5 | #include 6 | 7 | HRESULT 8 | GetServiceCurrentState( 9 | __in LPCWSTR pszServiceName, 10 | __out SERVICE_STATUS * pServiceStatus 11 | ) 12 | { 13 | HRESULT hr = S_OK; 14 | SC_HANDLE hServiceControlManager = NULL; 15 | SC_HANDLE hService = NULL; 16 | 17 | hServiceControlManager = OpenSCManager( NULL, // Local machine 18 | NULL, 19 | STANDARD_RIGHTS_READ ); 20 | if ( hServiceControlManager == NULL ) 21 | { 22 | hr = HRESULT_FROM_WIN32( GetLastError() ); 23 | DBGERROR_HR(hr); 24 | goto Finished; 25 | } 26 | 27 | hService = OpenService( hServiceControlManager, 28 | pszServiceName, 29 | SERVICE_QUERY_STATUS ); 30 | if ( hService == NULL ) 31 | { 32 | hr = HRESULT_FROM_WIN32( GetLastError() ); 33 | DBGERROR_HR(hr); 34 | goto Finished; 35 | } 36 | 37 | if ( !QueryServiceStatus( hService, 38 | pServiceStatus ) ) 39 | { 40 | hr = HRESULT_FROM_WIN32( GetLastError() ); 41 | DBGERROR_HR(hr); 42 | goto Finished; 43 | } 44 | 45 | Finished: 46 | 47 | if ( hService != NULL ) 48 | { 49 | CloseServiceHandle( hService ); 50 | hService = NULL; 51 | } 52 | 53 | if ( hServiceControlManager != NULL ) 54 | { 55 | CloseServiceHandle( hService ); 56 | hService = NULL; 57 | } 58 | 59 | return hr; 60 | } 61 | 62 | BOOL 63 | IsServiceRunning( 64 | const SERVICE_STATUS & ServiceStatus 65 | ) 66 | { 67 | switch( ServiceStatus.dwCurrentState ) 68 | { 69 | case SERVICE_RUNNING: 70 | case SERVICE_START_PENDING: 71 | case SERVICE_CONTINUE_PENDING: 72 | return TRUE; 73 | default: 74 | return FALSE; 75 | } 76 | } 77 | 78 | HRESULT 79 | IsQfeInstalled( 80 | __in LPCWSTR pszQfeName, 81 | __out BOOL * pfIsInstalled 82 | ) 83 | { 84 | HRESULT hr = S_OK; 85 | CComPtr< IWbemLocator > pLocator; 86 | CComPtr< IWbemServices > pService; 87 | CComPtr< IEnumWbemClassObject > pEnumerator; 88 | ULONG Count = 0; 89 | CComPtr< IWbemClassObject > pProcessor; 90 | CComBSTR bstrNamespace; 91 | CComBSTR bstrQueryLanguage; 92 | CComBSTR bstrQuery; 93 | 94 | if ( FAILED( hr = bstrNamespace.Append( L"root\\CIMV2", 10 ) ) || 95 | FAILED( hr = bstrQueryLanguage.Append( L"WQL", 3 ) ) || 96 | FAILED( hr = bstrQuery.Append( L"SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID='" ) ) || 97 | FAILED( hr = bstrQuery.Append( pszQfeName ) ) || 98 | FAILED( hr = bstrQuery.Append( L"'", 1 ) ) ) 99 | { 100 | goto Finished; 101 | } 102 | 103 | hr = CoCreateInstance( __uuidof(WbemAdministrativeLocator), 104 | NULL, // pUnkOuter 105 | CLSCTX_INPROC_SERVER, 106 | __uuidof(IWbemLocator), 107 | reinterpret_cast< void** >( &pLocator ) ); 108 | if ( FAILED( hr ) ) 109 | { 110 | goto Finished; 111 | } 112 | 113 | hr = pLocator->ConnectServer( bstrNamespace, 114 | NULL, // strUser 115 | NULL, // strPassword 116 | NULL, // strLocale 117 | WBEM_FLAG_CONNECT_USE_MAX_WAIT, 118 | NULL, // strAuthority 119 | NULL, // pCtx 120 | &pService ); 121 | if ( FAILED( hr ) ) 122 | { 123 | goto Finished; 124 | } 125 | 126 | // 127 | // Set the proxy so that impersonation of the client occurs. 128 | // 129 | hr = CoSetProxyBlanket( pService, 130 | RPC_C_AUTHN_DEFAULT, 131 | RPC_C_AUTHZ_NONE, 132 | NULL, 133 | RPC_C_AUTHN_LEVEL_CONNECT, 134 | RPC_C_IMP_LEVEL_IMPERSONATE, 135 | NULL, 136 | EOAC_NONE); 137 | if ( FAILED( hr ) ) 138 | { 139 | goto Finished; 140 | } 141 | 142 | hr = pService->ExecQuery( bstrQueryLanguage, 143 | bstrQuery, 144 | WBEM_FLAG_FORWARD_ONLY, 145 | NULL, 146 | &pEnumerator ); 147 | if ( FAILED( hr ) ) 148 | { 149 | goto Finished; 150 | } 151 | 152 | hr = pEnumerator->Next( WBEM_INFINITE, 153 | 1L, 154 | &pProcessor, 155 | &Count ); 156 | if ( FAILED( hr ) ) 157 | { 158 | goto Finished; 159 | } 160 | 161 | *pfIsInstalled = Count > 0; 162 | 163 | Finished: 164 | 165 | return hr; 166 | } 167 | 168 | UINT 169 | WINAPI 170 | CheckForServicesRunningCA( 171 | MSIHANDLE hInstall 172 | ) 173 | { 174 | HRESULT hr = S_OK; 175 | BOOL fIsServiceRunning = FALSE; 176 | SERVICE_STATUS ServiceStatus; 177 | LPCWSTR rgServiceNames[] = { L"WAS", L"WMSVC" }; 178 | 179 | IISLogInitialize(hInstall, UNITEXT(__FUNCTION__)); 180 | 181 | // 182 | // Check if any pService is running. 183 | // 184 | for( DWORD Index = 0; Index < _countof( rgServiceNames ); Index ++ ) 185 | { 186 | hr = GetServiceCurrentState( rgServiceNames[Index], 187 | &ServiceStatus ); 188 | if ( hr == HRESULT_FROM_WIN32( ERROR_SERVICE_DOES_NOT_EXIST ) ) 189 | { 190 | hr = S_OK; 191 | } 192 | else if ( FAILED( hr ) ) 193 | { 194 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 195 | L"Failed to query the state of the service '%s' hr=0x%x", 196 | rgServiceNames[Index], 197 | hr ); 198 | DBGERROR_HR(hr); 199 | goto Finished; 200 | } 201 | else 202 | { 203 | fIsServiceRunning = IsServiceRunning( ServiceStatus ); 204 | if ( fIsServiceRunning ) 205 | { 206 | break; 207 | } 208 | } 209 | } 210 | 211 | if ( fIsServiceRunning ) 212 | { 213 | BOOL fQfeInstalled = FALSE; 214 | 215 | hr = IsQfeInstalled( L"KB949172", 216 | &fQfeInstalled ); 217 | if ( FAILED( hr ) ) 218 | { 219 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 220 | L"Failed to query the QFE 'KB949172' information hr=0x%x", 221 | hr ); 222 | DBGERROR_HR(hr); 223 | goto Finished; 224 | } 225 | 226 | if ( fQfeInstalled ) 227 | { 228 | // 229 | // QFE is already installed. 230 | // 231 | goto Finished; 232 | } 233 | 234 | IISLogClose(); 235 | return LogMsiCustomActionError( hInstall, 30003 ); 236 | } 237 | 238 | Finished: 239 | 240 | IISLogClose(); 241 | 242 | // TODO Wire up when Rollback CA's are wired up 243 | return (SUCCEEDED(hr)) ? ERROR_SUCCESS : ERROR_SUCCESS; 244 | } -------------------------------------------------------------------------------- /CustomAction/iiscompressionCA.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #include 5 | 6 | DECLARE_DEBUG_PRINT_OBJECT( "iiscompressionCA.dll" ); 7 | 8 | HINSTANCE g_hinst; 9 | 10 | BOOL WINAPI 11 | DllMain( 12 | HINSTANCE hModule, 13 | DWORD dwReason, 14 | LPVOID lpReserved 15 | ) 16 | { 17 | UNREFERENCED_PARAMETER( lpReserved ); 18 | switch( dwReason ) 19 | { 20 | case DLL_PROCESS_ATTACH: 21 | CREATE_DEBUG_PRINT_OBJECT; 22 | DisableThreadLibraryCalls( hModule ); 23 | g_hinst = hModule; 24 | break; 25 | 26 | case DLL_PROCESS_DETACH: 27 | break; 28 | } 29 | 30 | return TRUE; 31 | } 32 | 33 | struct COMP_SCHEME 34 | { 35 | PCWSTR pszName; 36 | PCWSTR pszDll; 37 | }; 38 | 39 | // The installer inserts each scheme in g_compressionScheme to the beginning of 40 | // the scheme collection. Therefore, the scheme order appearing in the configuration 41 | // collection is opposite to their order in g_compressionScheme. 42 | COMP_SCHEME g_compressionScheme[] = 43 | { { L"gzip", L"%ProgramFiles%\\IIS\\IIS Compression\\iiszlib.dll" }, 44 | { L"br" , L"%ProgramFiles%\\IIS\\IIS Compression\\iisbrotli.dll" } }; 45 | 46 | COMP_SCHEME g_defaultGzipScheme = 47 | { L"gzip", L"%windir%\\system32\\inetsrv\\gzip.dll" }; 48 | 49 | /*++ 50 | 51 | Routine Description: 52 | 53 | Custom action for installation: 54 | 55 | Register the iiszlib (gzip) and iisbrotli (br) compression schemes 56 | 57 | --*/ 58 | UINT 59 | RegisterCompressionSchemesCA( 60 | IN MSIHANDLE hInstall 61 | ) 62 | { 63 | IAppHostWritableAdminManager * pAdminMgr = NULL; 64 | IAppHostElement * pHttpCompressionSection = NULL; 65 | IAppHostElement * pNewSchemeElement = NULL; 66 | IAppHostElementCollection * pSchemeCollection = NULL; 67 | HRESULT hr = NOERROR; 68 | BOOL fDeleted; 69 | VARIANT varPropValue; 70 | 71 | IISLogInitialize(hInstall, UNITEXT(__FUNCTION__)); 72 | IISLogWrite(SETUP_LOG_SEVERITY_INFORMATION, 73 | L"CA '%s' started to register iiszlib and iisbrotli compression schemes.", 74 | UNITEXT(__FUNCTION__)); 75 | 76 | VariantInit(&varPropValue); 77 | 78 | hr = CoCreateInstance(__uuidof(AppHostWritableAdminManager), 79 | NULL, 80 | CLSCTX_INPROC_SERVER, 81 | __uuidof(IAppHostWritableAdminManager), 82 | (VOID **)&pAdminMgr); 83 | if (FAILED(hr)) 84 | { 85 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 86 | L"Failed to create an AppHostWritableAdminManager: hr=0x%x.", 87 | hr); 88 | goto exit; 89 | } 90 | 91 | hr = pAdminMgr->GetAdminSection(L"system.webServer/httpCompression", 92 | L"MACHINE/WEBROOT/APPHOST", 93 | &pHttpCompressionSection); 94 | if (FAILED(hr)) 95 | { 96 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 97 | L"Failed to get the httpCompression section: hr=0x%x.", 98 | hr); 99 | goto exit; 100 | } 101 | 102 | hr = pHttpCompressionSection->get_Collection(&pSchemeCollection); 103 | if (FAILED(hr)) 104 | { 105 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 106 | L"Failed to get the scheme collection of the httpCompression section: hr=0x%x.", 107 | hr); 108 | goto exit; 109 | } 110 | 111 | for (DWORD i = 0; i < _countof(g_compressionScheme); i++) 112 | { 113 | hr = DeleteElementFromCollection(pSchemeCollection, 114 | L"name", 115 | g_compressionScheme[i].pszName, 116 | FIND_ELEMENT_CASE_SENSITIVE, 117 | &fDeleted); 118 | if (FAILED(hr)) 119 | { 120 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 121 | L"Failed to delete the original scheme: '%s', hr=0x%x.", 122 | g_compressionScheme[i].pszName, 123 | hr); 124 | goto exit; 125 | } 126 | if (fDeleted == TRUE) 127 | { 128 | IISLogWrite(SETUP_LOG_SEVERITY_INFORMATION, 129 | L"Successfully deleted the original scheme: '%s'.", 130 | g_compressionScheme[i].pszName); 131 | } 132 | 133 | hr = pSchemeCollection->CreateNewElement(L"scheme", 134 | &pNewSchemeElement); 135 | if (FAILED(hr)) 136 | { 137 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 138 | L"Failed to create a configuration element for the scheme: '%s', hr=0x%x.", 139 | g_compressionScheme[i].pszName, 140 | hr); 141 | goto exit; 142 | } 143 | 144 | hr = VariantAssign(&varPropValue, 145 | g_compressionScheme[i].pszName); 146 | if (FAILED(hr)) 147 | { 148 | goto exit; 149 | } 150 | 151 | hr = SetElementProperty(pNewSchemeElement, 152 | L"name", 153 | &varPropValue); 154 | if (FAILED(hr)) 155 | { 156 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 157 | L"Failed to set the name property for the scheme: '%s', hr=0x%x.", 158 | g_compressionScheme[i].pszName, 159 | hr); 160 | goto exit; 161 | } 162 | 163 | hr = VariantAssign(&varPropValue, 164 | g_compressionScheme[i].pszDll); 165 | if (FAILED(hr)) 166 | { 167 | goto exit; 168 | } 169 | 170 | hr = SetElementProperty(pNewSchemeElement, 171 | L"dll", 172 | &varPropValue); 173 | if (FAILED(hr)) 174 | { 175 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 176 | L"Failed to set the dll property for the scheme: '%s', hr=0x%x.", 177 | g_compressionScheme[i].pszName, 178 | hr); 179 | goto exit; 180 | } 181 | 182 | hr = pSchemeCollection->AddElement(pNewSchemeElement, 0); 183 | if (FAILED(hr)) 184 | { 185 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 186 | L"Failed to add the configuration element for the scheme: '%s', hr=0x%x.", 187 | g_compressionScheme[i].pszName, 188 | hr); 189 | goto exit; 190 | } 191 | 192 | IISLogWrite(SETUP_LOG_SEVERITY_INFORMATION, 193 | L"Successfully created the new scheme: '%s'.", 194 | g_compressionScheme[i].pszName); 195 | } 196 | 197 | hr = pAdminMgr->CommitChanges(); 198 | if (FAILED(hr)) 199 | { 200 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 201 | L"Failed to commit the configuration changes: hr=0x%x.", 202 | hr); 203 | goto exit; 204 | } 205 | 206 | exit: 207 | 208 | IISLogWrite(SETUP_LOG_SEVERITY_INFORMATION, 209 | L"CA '%s' completed with return code hr=0x%x", 210 | UNITEXT(__FUNCTION__), 211 | hr); 212 | 213 | IISLogClose(); 214 | VariantClear(&varPropValue); 215 | 216 | if (pNewSchemeElement != NULL) 217 | { 218 | pNewSchemeElement->Release(); 219 | pNewSchemeElement = NULL; 220 | } 221 | 222 | if (pSchemeCollection != NULL) 223 | { 224 | pSchemeCollection->Release(); 225 | pSchemeCollection = NULL; 226 | } 227 | 228 | if (pHttpCompressionSection != NULL) 229 | { 230 | pHttpCompressionSection->Release(); 231 | pHttpCompressionSection = NULL; 232 | } 233 | 234 | if (pAdminMgr != NULL) 235 | { 236 | pAdminMgr->Release(); 237 | pAdminMgr = NULL; 238 | } 239 | 240 | return (SUCCEEDED(hr)) ? ERROR_SUCCESS : ERROR_SUCCESS; 241 | } 242 | 243 | /*++ 244 | 245 | Routine Description: 246 | 247 | Custom action for uninstallation: 248 | 249 | Unregister the iiszlib (gzip) and iisbrotli (br) compression schemes 250 | and re-register the default in-box gzip compression scheme (gzip.dll) 251 | 252 | --*/ 253 | UINT 254 | CleanupCompressionSchemesCA( 255 | IN MSIHANDLE hInstall 256 | ) 257 | { 258 | IAppHostWritableAdminManager * pAdminMgr = NULL; 259 | IAppHostElement * pHttpCompressionSection = NULL; 260 | IAppHostElement * pNewSchemeElement = NULL; 261 | IAppHostElementCollection * pSchemeCollection = NULL; 262 | HRESULT hr = NOERROR; 263 | BOOL fDeleted; 264 | VARIANT varPropValue; 265 | 266 | IISLogInitialize(hInstall, UNITEXT(__FUNCTION__)); 267 | IISLogWrite(SETUP_LOG_SEVERITY_INFORMATION, 268 | L"CA '%s' started to unregister iiszlib and iisbrotli compression schemes.", 269 | UNITEXT(__FUNCTION__)); 270 | 271 | VariantInit(&varPropValue); 272 | 273 | hr = CoCreateInstance(__uuidof(AppHostWritableAdminManager), 274 | NULL, 275 | CLSCTX_INPROC_SERVER, 276 | __uuidof(IAppHostWritableAdminManager), 277 | (VOID **)&pAdminMgr); 278 | if (FAILED(hr)) 279 | { 280 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 281 | L"Failed to create an AppHostWritableAdminManager: hr=0x%x.", 282 | hr); 283 | goto exit; 284 | } 285 | 286 | hr = pAdminMgr->GetAdminSection(L"system.webServer/httpCompression", 287 | L"MACHINE/WEBROOT/APPHOST", 288 | &pHttpCompressionSection); 289 | if (FAILED(hr)) 290 | { 291 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 292 | L"Failed to get the httpCompression section: hr=0x%x.", 293 | hr); 294 | goto exit; 295 | } 296 | 297 | hr = pHttpCompressionSection->get_Collection(&pSchemeCollection); 298 | if (FAILED(hr)) 299 | { 300 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 301 | L"Failed to get the scheme collection of the httpCompression section: hr=0x%x.", 302 | hr); 303 | goto exit; 304 | } 305 | 306 | for (DWORD i = 0; i < _countof(g_compressionScheme); i++) 307 | { 308 | hr = DeleteElementFromCollection(pSchemeCollection, 309 | L"name", 310 | g_compressionScheme[i].pszName, 311 | FIND_ELEMENT_CASE_SENSITIVE, 312 | &fDeleted); 313 | if (FAILED(hr)) 314 | { 315 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 316 | L"Failed to delete the scheme: '%s', hr=0x%x.", 317 | g_compressionScheme[i].pszName, 318 | hr); 319 | goto exit; 320 | } 321 | if (fDeleted == TRUE) 322 | { 323 | IISLogWrite(SETUP_LOG_SEVERITY_INFORMATION, 324 | L"Successfully deleted the scheme: '%s'.", 325 | g_compressionScheme[i].pszName); 326 | } 327 | } 328 | 329 | hr = pSchemeCollection->CreateNewElement(L"scheme", 330 | &pNewSchemeElement); 331 | if (FAILED(hr)) 332 | { 333 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 334 | L"Failed to create a configuration element for the scheme: '%s', hr=0x%x.", 335 | g_defaultGzipScheme.pszName, 336 | hr); 337 | goto exit; 338 | } 339 | 340 | hr = VariantAssign(&varPropValue, 341 | g_defaultGzipScheme.pszName); 342 | if (FAILED(hr)) 343 | { 344 | goto exit; 345 | } 346 | 347 | hr = SetElementProperty(pNewSchemeElement, 348 | L"name", 349 | &varPropValue); 350 | if (FAILED(hr)) 351 | { 352 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 353 | L"Failed to set the name property for the scheme: '%s', hr=0x%x.", 354 | g_defaultGzipScheme.pszName, 355 | hr); 356 | goto exit; 357 | } 358 | 359 | hr = VariantAssign(&varPropValue, 360 | g_defaultGzipScheme.pszDll); 361 | if (FAILED(hr)) 362 | { 363 | goto exit; 364 | } 365 | 366 | hr = SetElementProperty(pNewSchemeElement, 367 | L"dll", 368 | &varPropValue); 369 | if (FAILED(hr)) 370 | { 371 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 372 | L"Failed to set the dll property for the scheme: '%s', hr=0x%x.", 373 | g_defaultGzipScheme.pszName, 374 | hr); 375 | goto exit; 376 | } 377 | 378 | hr = pSchemeCollection->AddElement(pNewSchemeElement, 0); 379 | if (FAILED(hr)) 380 | { 381 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 382 | L"Failed to add the configuration element for the scheme: '%s', hr=0x%x.", 383 | g_defaultGzipScheme.pszName, 384 | hr); 385 | goto exit; 386 | } 387 | 388 | IISLogWrite(SETUP_LOG_SEVERITY_INFORMATION, 389 | L"Successfully recreated the default scheme: '%s'.", 390 | g_defaultGzipScheme.pszName); 391 | 392 | hr = pAdminMgr->CommitChanges(); 393 | if (FAILED(hr)) 394 | { 395 | IISLogWrite(SETUP_LOG_SEVERITY_ERROR, 396 | L"Failed to commit the configuration changes: hr=0x%x.", 397 | hr); 398 | goto exit; 399 | } 400 | 401 | exit: 402 | 403 | IISLogWrite(SETUP_LOG_SEVERITY_INFORMATION, 404 | L"CA '%s' completed with return code hr=0x%x", 405 | UNITEXT(__FUNCTION__), 406 | hr); 407 | 408 | IISLogClose(); 409 | VariantClear(&varPropValue); 410 | 411 | if (pNewSchemeElement != NULL) 412 | { 413 | pNewSchemeElement->Release(); 414 | pNewSchemeElement = NULL; 415 | } 416 | 417 | if (pSchemeCollection != NULL) 418 | { 419 | pSchemeCollection->Release(); 420 | pSchemeCollection = NULL; 421 | } 422 | 423 | if (pHttpCompressionSection != NULL) 424 | { 425 | pHttpCompressionSection->Release(); 426 | pHttpCompressionSection = NULL; 427 | } 428 | 429 | if (pAdminMgr != NULL) 430 | { 431 | pAdminMgr->Release(); 432 | pAdminMgr = NULL; 433 | } 434 | 435 | return (SUCCEEDED(hr)) ? ERROR_SUCCESS : ERROR_SUCCESS; 436 | } -------------------------------------------------------------------------------- /CustomAction/iiscompressionCA.def: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Microsoft Corporation. All rights reserved. 2 | ; Licensed under the MIT license. 3 | 4 | LIBRARY iiscompressionCA 5 | 6 | EXPORTS 7 | 8 | ; IIS Common Config custom actions 9 | 10 | IISScheduleInstallCA 11 | IISScheduleUninstallCA 12 | IISExecuteCA 13 | IISBeginTransactionCA 14 | IISRollbackTransactionCA 15 | IISCommitTransactionCA 16 | 17 | CheckForSharedConfigurationCA 18 | 19 | ScheduleInstallWindowsHotfixCA 20 | ExecuteInstallWindowsHotfixCA 21 | ExecuteCleanUpWindowsHotfixCA 22 | ScheduleRebootIfRequiredCA 23 | 24 | ; Utility 25 | CheckForServicesRunningCA 26 | 27 | ExecuteCleanUpWindowsHotfixCA 28 | 29 | RegisterCompressionSchemesCA 30 | CleanupCompressionSchemesCA 31 | -------------------------------------------------------------------------------- /CustomAction/iiscompressionCA.rc: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #define VER_FILETYPE VFT_DLL 5 | #define RC_VERSION_INTERNAL_NAME "iiscompressionCA\0" 6 | #define RC_VERSION_ORIGINAL_FILE_NAME "iiscompressionCA.dll\0" 7 | #define RC_VERSION_FILE_DESCRIPTION "IIS Compression Schemes Custom Action DLL\0" 8 | 9 | #include 10 | -------------------------------------------------------------------------------- /CustomAction/iiscompressionCA.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Debug 11 | ARM64 12 | 13 | 14 | Debug 15 | ARM64EC 16 | 17 | 18 | Debug 19 | Win32 20 | 21 | 22 | Release 23 | ARM64 24 | 25 | 26 | Release 27 | ARM64EC 28 | 29 | 30 | Release 31 | Win32 32 | 33 | 34 | Debug 35 | x64 36 | 37 | 38 | Release 39 | x64 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | {b54a8f61-60de-4ad9-87ca-d102f230678e} 49 | 50 | 51 | {7324770c-0871-4d73-be3d-5e2f3e9e1b1e} 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | $(IIS-Common)version; 61 | $(IIS-Common)version; 62 | $(IIS-Common)version; 63 | $(IIS-Common)version; 64 | $(IIS-Common)version; 65 | $(IIS-Common)version; 66 | $(IIS-Common)version; 67 | $(IIS-Common)version; 68 | $(ResourceCompilePreprocessorDefinitions) 69 | $(ResourceCompilePreprocessorDefinitions) 70 | $(ResourceCompilePreprocessorDefinitions) 71 | $(ResourceCompilePreprocessorDefinitions) 72 | $(ResourceCompilePreprocessorDefinitions) 73 | $(ResourceCompilePreprocessorDefinitions) 74 | $(ResourceCompilePreprocessorDefinitions) 75 | $(ResourceCompilePreprocessorDefinitions) 76 | 77 | 78 | 79 | {4098A5FB-D3D2-4DB1-9F37-BAE0E08F80F2} 80 | Win32Proj 81 | iiscompressionCA 82 | iiscompressionCA 83 | 84 | 85 | $(WixSdkPath)\wix.nativeca.targets 86 | 87 | 88 | 89 | DynamicLibrary 90 | Unicode 91 | v143 92 | 93 | 94 | 95 | $(IIS-Common)version;$(IIS-Common)Include;$(AdditionalIncludeDirectories) 96 | Create 97 | precomp.h 98 | $(IntDir)precomp.pch 99 | bin\$(Configuration)\$(PlatformTarget)\ 100 | obj\$(Configuration)\$(PlatformTarget)\ 101 | 102 | 103 | 104 | $(IIS-Setup)iisca\lib;$(WixIncPath);$(AdditionalIncludeDirectories) 105 | Level3 106 | 107 | 108 | httpapi.lib;shlwapi.lib;ahadmin.lib;xmllite.lib;msi.lib;dutil.lib;wcautil.lib;Version.lib;%(AdditionalDependencies) 109 | $(TargetName).def 110 | Windows 111 | 112 | 113 | 114 | 115 | _DEBUG;_WINDOWS;_USRDLL;CUSTOMACTIONTEST_EXPORTS;%(PreprocessorDefinitions) 116 | 117 | 118 | 119 | 120 | $(VC_ReferencesPath_x86);$(WindowsSDK_LibraryPath)\$(PlatformTarget);$(WixLibPath)x86;%(AdditionalLibraryDirectories) 121 | MachineX86 122 | DebugFull 123 | 124 | 125 | false 126 | 127 | 128 | 129 | 130 | WIN32;%(PreprocessorDefinitions) 131 | false 132 | 133 | 134 | $(VC_ReferencesPath_x64);$(WindowsSDK_LibraryPath)\$(PlatformTarget);$(WixLibPath)x64;%(AdditionalLibraryDirectories) 135 | Machinex64 136 | DebugFull 137 | 138 | 139 | 140 | 141 | WIN32;%(PreprocessorDefinitions) 142 | false 143 | 144 | 145 | $(VC_ReferencesPath_ARM64EC);$(WindowsSDK_LibraryPath)\$(PlatformTarget);$(WixLibPath)x64;%(AdditionalLibraryDirectories) 146 | DebugFull 147 | 148 | 149 | 150 | 151 | WIN32;%(PreprocessorDefinitions) 152 | false 153 | 154 | 155 | $(VC_ReferencesPath_ARM64);$(WindowsSDK_LibraryPath)\$(PlatformTarget);$(WixLibPath)x64;%(AdditionalLibraryDirectories) 156 | DebugFull 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | $(WixSdkPath)\$(WixPlatformToolset)\lib\ 167 | $(WIX)sdk\$(WixPlatformToolset)\lib\ 168 | $(WixSdkPath)\inc\ 169 | $(WIX)sdk\$(WixPlatformToolset)\inc\ 170 | 171 | 172 | 173 | This project is trying to import a missing file: {0}. 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /CustomAction/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | $(MSBuildThisFileDirectory) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Installer/Setup.wixproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 3.10 12 | 1ABF68C6-4E3D-4C36-AB9E-3AD64F9FD744 13 | 2.0 14 | Package 15 | 16 | 17 | iiscompression_x86 18 | x86 19 | 20 | 21 | iiscompression_amd64 22 | x64 23 | 24 | 25 | iiscompression_arm64 26 | arm64 27 | 28 | 29 | True 30 | 31 | 32 | Platform=($Platform);$(WixVariables); 33 | $(SolutionDir)bin\$(Configuration)\$(Platform)\ 34 | $(OutputPath) 35 | obj\$(Platform)\$(Configuration)\ 36 | $(IncludeSearchPaths);$(IntermediateOutputPath);$(IIS-Setup) 37 | $(RepositoryRoot)bin\$(Configuration)\$(Platform) 38 | $(RepositoryRoot)bin\$(Configuration)\x86\ 39 | $(DefineConstants);NeutralWOW64BinRoot=$(NeutralWOW64BinRoot);NeutralBinRoot=$(NeutralBinRoot) 40 | 41 | 42 | Debug;$(DefineConstants) 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | $(WixExtDir)\WixUIExtension.dll 63 | WixUIExtension 64 | 65 | 66 | 67 | 68 | setupstrings.wxl 69 | 70 | 71 | 72 | 73 | iiscompressionCA 74 | {4098a5fb-d3d2-4db1-9f37-bae0e08f80f2} 75 | True 76 | True 77 | Binaries;Content;Satellites 78 | INSTALLFOLDER 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | This project is trying to import a missing file: {0}. 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /Installer/ThirdPartyNotices.txt: -------------------------------------------------------------------------------- 1 | THIRD PARTY NOTICES 2 | 3 | This file is based on or incorporates material from the projects listed below (Third Party IP). The original copyright notice and the license under which Microsoft received such Third Party IP, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft licenses the Third Party IP to you under the licensing terms for the Microsoft product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise. 4 | 5 | 6 | ************** 7 | MIT Licensed Files 8 | The following files were originally licensed under the MIT License. The notices and license text below are provided for informational/attribution purposes only and are not the license terms under which Microsoft distributes this Third Party Software. 9 | 10 | 11 | Google/brotli 12 | Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. 13 | 14 | 15 | MIT License 16 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | 23 | ************** 24 | Zlib Licensed Files 25 | 26 | The following Files were Originally Licensed under the Zlib License. The notices and license text below are provided for informational/attribution purposes only and are not the license terms under which Microsoft distributes these Third Party Materials. 27 | 28 | Zlib 29 | Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler 30 | 31 | 32 | Zlib License 33 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 34 | 35 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 36 | 37 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 38 | 39 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 40 | 41 | 3. This notice may not be removed or altered from any source distribution. 42 | 43 | Jean-loup Gailly Mark Adler 44 | jloup@gzip.org madler@alumni.caltech.edu 45 | -------------------------------------------------------------------------------- /Installer/bitmaps/bannrbmp.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/IIS.Compression/8984c6f66cb4da79b8dc3bcc8b047191a74dac45/Installer/bitmaps/bannrbmp.bmp -------------------------------------------------------------------------------- /Installer/bitmaps/dlgbmp.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/IIS.Compression/8984c6f66cb4da79b8dc3bcc8b047191a74dac45/Installer/bitmaps/dlgbmp.bmp -------------------------------------------------------------------------------- /Installer/bitmaps/iiscompression.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/IIS.Compression/8984c6f66cb4da79b8dc3bcc8b047191a74dac45/Installer/bitmaps/iiscompression.ico -------------------------------------------------------------------------------- /Installer/iiscompression.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 29 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Microsoft Corporation 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | (NOT DUPLICATEVERSIONFOUND) OR Installed 60 | 61 | 62 | 63 | (NOT NEWERVERSIONFOUND) OR Installed 64 | 65 | 66 | 67 | Privileged 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | "ARM64")]]> 80 | 81 | 82 | 83 | 84 | 2 85 | 86 | 87 | 88 | = 601)]]> 89 | 90 | 91 | 92 | 93 | ((IISCOREWEBENGINEINSTALLED = "#1") AND (IISW3SVCINSTALLED = "#1")) OR Installed 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 135 | 136 | 137 | 143 | 144 | 145 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 184 | 185 | 186 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | !(loc.Error30001) 241 | !(loc.Error30002) 242 | 243 | !(loc.WebServicesRunning) 244 | 245 | 246 | 247 | 248 | 254 | 255 | 261 | 262 | 263 | 264 | NOT Installed 265 | (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | -------------------------------------------------------------------------------- /Installer/iiscompression_readme.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/IIS.Compression/8984c6f66cb4da79b8dc3bcc8b047191a74dac45/Installer/iiscompression_readme.htm -------------------------------------------------------------------------------- /Installer/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | IIS Compression 2 | Copyright (c) Microsoft Corporation 3 | All rights reserved. 4 | 5 | MIT License 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://devdiv.visualstudio.com/DevDiv/_apis/build/status/IIS/IIS.Compression/IIS.Compression%20Test%20Sign%20(Yaml)?branchName=master)](https://devdiv.visualstudio.com/DevDiv/_build/latest?definitionId=11271&branchName=master) 2 | 3 | Microsoft IIS Compression 4 | -------------------------------- 5 | 6 | **IIS Compression** is a bundle of two IIS compression scheme providers `iisbrotli.dll` and `iiszlib.dll` that enable IIS to compress HTTP response contents. `iisbrotli.dll` supports **Brotli** compression, while `iiszlib.dll` supports both **Gzip** and **Deflate** compression. 7 | 8 | An IIS compression scheme provider is a pluggable extension of IIS `StaticCompressionModule` and `DynamicCompressionModule` - essentially a dynamic link library (dll) that implements the compression algorithm and exposes the [IIS HTTP Compression API](https://msdn.microsoft.com/en-us/library/dd692872.aspx). IIS `StaticCompressionModule` and `DynamicCompressionModule` load the registered compression scheme providers into worker process at runtime, and leverage them to perform compression for static files and dynamically-generated contents, respectively. 9 | 10 | ### Documentation 11 | - [IIS Compression Overview](https://docs.microsoft.com/iis/extensions/iis-compression/iis-compression-overview) 12 | - [Using IIS Compression](https://docs.microsoft.com/iis/extensions/iis-compression/using-iis-compression) 13 | 14 | ### Installation 15 | 16 | Download the Microsoft IIS Compression release from the following locations: 17 | 18 | - **Microsoft IIS Compression (x86)** [here](https://download.microsoft.com/download/6/1/C/61CC0718-ED0E-4351-BC54-46495EBF5CC3/iiscompression_x86.msi). 19 | 20 | - **Microsoft IIS Compression (x64)** [here](https://download.microsoft.com/download/6/1/C/61CC0718-ED0E-4351-BC54-46495EBF5CC3/iiscompression_amd64.msi). 21 | 22 | The IIS Compression installer registers `iisbrotli.dll` as the `br` (Brotli) compression scheme provider in `applicationHost.config`. It also replaces the default `gzip` compression scheme provider `gzip.dll` with `iiszlib.dll`. A sample `httpCompression` section in `applicationHost.config` is shown below: 23 | 24 | ``` 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | ``` 46 | 47 | ### Install Visual Studio 48 | 1. Install Visual Studio 2017 49 | 2. You need to install these components additionally after(or while) installing Desktop development with C++ 50 | - Wix Toolset Visual Studio 2017 Extension 51 | - Visual C++ ATL (x86/x64) with Spectre Mitigations 52 | - VC++ 2017 version 15.9 v14.16 latest v141 tools 53 | 54 | ### Build 55 | 1. Clone this project with submodules. 56 | ``` 57 | git clone --recurse-submodules https://github.com/Microsoft/IIS.Compression.git 58 | ``` 59 | 2. Build the code using the `build.cmd` (the location of msbuild.exe needs to be added into `PATH` environment variable). 60 | 61 | ### Contributing 62 | 63 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 64 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 65 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 66 | 67 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 68 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 69 | provided by the bot. You will only need to do this once across all repos using our CLA. 70 | 71 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 72 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 73 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 74 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /ThirdPartyNotices.txt: -------------------------------------------------------------------------------- 1 | THIRD PARTY NOTICES 2 | 3 | This file is based on or incorporates material from the projects listed below (Third Party IP). The original copyright notice and the license under which Microsoft received such Third Party IP, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft licenses the Third Party IP to you under the licensing terms for the Microsoft product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise. 4 | 5 | 6 | ************** 7 | MIT Licensed Files 8 | The following files were originally licensed under the MIT License. The notices and license text below are provided for informational/attribution purposes only and are not the license terms under which Microsoft distributes this Third Party Software. 9 | 10 | 11 | Google/brotli 12 | Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. 13 | 14 | 15 | MIT License 16 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | 23 | ************** 24 | Zlib Licensed Files 25 | 26 | The following Files were Originally Licensed under the Zlib License. The notices and license text below are provided for informational/attribution purposes only and are not the license terms under which Microsoft distributes these Third Party Materials. 27 | 28 | Zlib 29 | Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler 30 | 31 | 32 | Zlib License 33 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 34 | 35 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 36 | 37 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 38 | 39 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 40 | 41 | 3. This notice may not be removed or altered from any source distribution. 42 | 43 | Jean-loup Gailly Mark Adler 44 | jloup@gzip.org madler@alumni.caltech.edu 45 | -------------------------------------------------------------------------------- /brotli/brotli.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Debug 8 | ARM64 9 | 10 | 11 | Debug 12 | ARM64EC 13 | 14 | 15 | Debug 16 | Win32 17 | 18 | 19 | Release 20 | ARM64 21 | 22 | 23 | Release 24 | ARM64EC 25 | 26 | 27 | Release 28 | Win32 29 | 30 | 31 | Debug 32 | x64 33 | 34 | 35 | Release 36 | x64 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | {67AAF490-C8A7-4020-BB96-593B2001EA4D} 132 | Win32Proj 133 | Lib 134 | 135 | 136 | 137 | StaticLibrary 138 | v143 139 | 140 | 141 | 142 | $(IIS-Common)Include;$(VC_IncludePath);$(WindowsSDK_IncludePath); 143 | 144 | 145 | 146 | NotUsing 147 | _LIB;%(PreprocessorDefinitions) 148 | $(SubmoduleBrotli)\c\include 149 | $(SubmoduleBrotli)\c\include 150 | $(SubmoduleBrotli)\c\include 151 | $(SubmoduleBrotli)\c\include 152 | $(SubmoduleBrotli)\c\include 153 | $(SubmoduleBrotli)\c\include 154 | $(SubmoduleBrotli)\c\include 155 | $(SubmoduleBrotli)\c\include 156 | false 157 | false 158 | false 159 | false 160 | 161 | 162 | Windows 163 | 164 | 165 | 166 | 167 | 168 | This project is trying to import a missing file: {0}. 169 | 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /brotli/brotli.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {73dd61b3-b05a-4bc8-a800-e09a04deeba9} 6 | 7 | 8 | {051d0789-c627-452a-b786-ae76e53d3a15} 9 | 10 | 11 | {3ce82ce9-092a-42a3-97a9-e197028398c9} 12 | 13 | 14 | {fac72805-38f1-4b08-9fc2-dc723f11e284} 15 | 16 | 17 | 18 | 19 | dec 20 | 21 | 22 | dec 23 | 24 | 25 | dec 26 | 27 | 28 | dec 29 | 30 | 31 | 32 | enc 33 | 34 | 35 | enc 36 | 37 | 38 | enc 39 | 40 | 41 | enc 42 | 43 | 44 | enc 45 | 46 | 47 | enc 48 | 49 | 50 | enc 51 | 52 | 53 | enc 54 | 55 | 56 | enc 57 | 58 | 59 | enc 60 | 61 | 62 | enc 63 | 64 | 65 | enc 66 | 67 | 68 | enc 69 | 70 | 71 | enc 72 | 73 | 74 | enc 75 | 76 | 77 | enc 78 | 79 | 80 | enc 81 | 82 | 83 | enc 84 | 85 | 86 | enc 87 | 88 | 89 | enc 90 | 91 | 92 | enc 93 | 94 | 95 | enc 96 | 97 | 98 | enc 99 | 100 | 101 | enc 102 | 103 | 104 | enc 105 | 106 | 107 | enc 108 | 109 | 110 | enc 111 | 112 | 113 | enc 114 | 115 | 116 | enc 117 | 118 | 119 | enc 120 | 121 | 122 | enc 123 | 124 | 125 | enc 126 | 127 | 128 | enc 129 | 130 | 131 | enc 132 | 133 | 134 | enc 135 | 136 | 137 | enc 138 | 139 | 140 | enc 141 | 142 | 143 | enc 144 | 145 | 146 | enc 147 | 148 | 149 | enc 150 | 151 | 152 | enc 153 | 154 | 155 | enc 156 | 157 | 158 | common 159 | 160 | 161 | common 162 | 163 | 164 | common 165 | 166 | 167 | common 168 | 169 | 170 | common 171 | 172 | 173 | common 174 | 175 | include 176 | 177 | 178 | include 179 | 180 | 181 | include 182 | 183 | 184 | include 185 | 186 | 187 | 188 | 189 | dec 190 | 191 | 192 | dec 193 | 194 | 195 | dec 196 | 197 | 198 | dec 199 | 200 | 201 | enc 202 | 203 | 204 | enc 205 | 206 | 207 | enc 208 | 209 | 210 | enc 211 | 212 | 213 | enc 214 | 215 | 216 | enc 217 | 218 | 219 | enc 220 | 221 | 222 | enc 223 | 224 | 225 | enc 226 | 227 | 228 | enc 229 | 230 | 231 | enc 232 | 233 | 234 | enc 235 | 236 | 237 | enc 238 | 239 | 240 | enc 241 | 242 | 243 | enc 244 | 245 | 246 | enc 247 | 248 | 249 | enc 250 | 251 | 252 | enc 253 | 254 | 255 | enc 256 | 257 | 258 | enc 259 | 260 | 261 | common 262 | 263 | 264 | common 265 | 266 | 267 | common 268 | 269 | 270 | common 271 | 272 | 273 | common 274 | 275 | 276 | -------------------------------------------------------------------------------- /brotli/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | msbuild Compression.sln /p:platform=x64 /p:configuration=Release -------------------------------------------------------------------------------- /build/submodule-exports.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(MSBuildThisFileDirectory)..\ 7 | 8 | 9 | 10 | 11 | 12 | <_IIS-CommonExportsPath>$(IIS-Compression)IIS-Common\build\submodule-exports.props 13 | <_IIS-SetupExportsPath>$(IIS-Compression)IIS-Setup\build\submodule-exports.props 14 | 15 | 16 | 17 | <_SubmoduleZlibPath>$(IIS-Compression)submodules\zlib 18 | <_SubmoduleBrotliPath>$(IIS-Compression)submodules\brotli 19 | <_SubmoduleZlibHeaderPath>$(_SubmoduleZlibPath)\zlib.h 20 | <_SubmoduleBrotliHeaderPath>$(_SubmoduleBrotliPath)\c\include\brotli\encode.h 21 | 22 | 23 | 24 | $(_SubmoduleZlibPath) 25 | $(_SubmoduleBrotliPath) 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /build/submodule.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /cgmanifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "Registrations": [ 3 | { 4 | "component": { 5 | "type": "git", 6 | "git": { 7 | "repositoryUrl": "https://github.com/google/brotli", 8 | "commitHash": "e61745a6b7add50d380cfd7d3883dd6c62fc2c71" 9 | } 10 | } 11 | }, 12 | { 13 | "component": { 14 | "type": "git", 15 | "git": { 16 | "repositoryUrl": "https://github.com/madler/zlib", 17 | "commitHash": "cacf7f1d4e3d44d871b605da3b647f07d718623f" 18 | } 19 | } 20 | } 21 | ], 22 | "Version": 1 23 | } -------------------------------------------------------------------------------- /iisbrotli/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #include "stdafx.h" 5 | 6 | DECLARE_DEBUG_PRINT_OBJECT2("iisbrotli", DEBUG_FLAGS_ERROR); 7 | 8 | INT g_intEncoderOp = BROTLI_PARAMETER_UNSET; 9 | HANDLE g_hEventLog = NULL; 10 | BOOL g_fEventRaised = FALSE; 11 | 12 | VOID LoadGlobalConfiguration(VOID); 13 | 14 | BOOL APIENTRY 15 | DllMain( 16 | HMODULE hModule, 17 | DWORD dwReason, 18 | LPVOID lpReserved 19 | ) 20 | { 21 | switch (dwReason) 22 | { 23 | case DLL_PROCESS_ATTACH: 24 | LoadGlobalConfiguration(); 25 | CREATE_DEBUG_PRINT_OBJECT; 26 | break; 27 | case DLL_THREAD_ATTACH: 28 | case DLL_THREAD_DETACH: 29 | case DLL_PROCESS_DETACH: 30 | break; 31 | } 32 | return TRUE; 33 | } 34 | 35 | VOID 36 | LoadGlobalConfiguration( 37 | VOID 38 | ) 39 | { 40 | DWORD dwType = 0; 41 | DWORD dwData = 0; 42 | DWORD cbData = 0; 43 | HKEY hKey; 44 | 45 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, 46 | L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS Compression\\IISBrotli\\Parameters", 47 | 0, 48 | KEY_READ, 49 | &hKey) == ERROR_SUCCESS) 50 | { 51 | cbData = sizeof(dwData); 52 | if (RegQueryValueEx(hKey, 53 | L"FlushMode", 54 | NULL, 55 | &dwType, 56 | (LPBYTE) &dwData, 57 | &cbData) == ERROR_SUCCESS && 58 | dwType == REG_DWORD) 59 | { 60 | if (dwData <= 3) 61 | { 62 | // BrotliEncoderOperation enum only supports four enumerators 63 | // 0: BROTLI_OPERATION_PROCESS 64 | // 1: BROTLI_OPERATION_FLUSH 65 | // 2: BROTLI_OPERATION_FINISH 66 | // 3: BROTLI_OPERATION_EMIT_METADATA 67 | g_intEncoderOp = (INT)dwData; 68 | } 69 | } 70 | 71 | cbData = sizeof(dwData); 72 | if (RegQueryValueEx(hKey, 73 | L"DebugFlags", 74 | NULL, 75 | &dwType, 76 | (LPBYTE) &dwData, 77 | &cbData) == ERROR_SUCCESS && 78 | dwType == REG_DWORD) 79 | { 80 | DEBUG_FLAGS_VAR = dwData; 81 | } 82 | 83 | RegCloseKey(hKey); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /iisbrotli/iisbrotli.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #include "stdafx.h" 5 | 6 | class BROTLI_CONTEXT 7 | { 8 | public: 9 | 10 | BROTLI_CONTEXT() 11 | : _pState(NULL), 12 | _op(BROTLI_OPERATION_PROCESS) 13 | { 14 | } 15 | 16 | // brotli parameters 17 | BrotliEncoderState* _pState; 18 | BrotliEncoderOperation _op; 19 | }; 20 | 21 | BrotliEncoderOperation ConvertFlushMode(INT operation); 22 | HRESULT ReportCompressionLevelOutOfBounds(INT currentLevel, INT maxLevel); 23 | 24 | // 25 | // Initialize global compression 26 | // 27 | HRESULT WINAPI 28 | InitCompression( 29 | VOID 30 | ) 31 | { 32 | g_hEventLog = RegisterEventSource(NULL, 33 | IISBROTLI_EVENT_SOURCE_NAME); 34 | 35 | // Ignore the failure from RegisterEventSource 36 | return S_OK; 37 | } 38 | 39 | // 40 | // De-init global compression 41 | // 42 | VOID WINAPI 43 | DeInitCompression( 44 | VOID 45 | ) 46 | { 47 | if (g_hEventLog != NULL) 48 | { 49 | DeregisterEventSource(g_hEventLog); 50 | g_hEventLog = NULL; 51 | } 52 | return; 53 | } 54 | 55 | // 56 | // Reset compression context 57 | // 58 | HRESULT WINAPI 59 | ResetCompression( 60 | IN OUT PVOID context 61 | ) 62 | { 63 | return S_OK; 64 | } 65 | 66 | // 67 | // Create a compression context 68 | // 69 | HRESULT WINAPI 70 | CreateCompression( 71 | OUT PVOID * context, 72 | IN ULONG flags 73 | ) 74 | { 75 | HRESULT hr = S_OK; 76 | BROTLI_CONTEXT* pContext = NULL; 77 | 78 | pContext = new BROTLI_CONTEXT(); 79 | if (pContext == NULL) 80 | { 81 | DBGERROR((DBG_CONTEXT, 82 | "Failed to create BROTLI_CONTEXT\n")); 83 | hr = E_OUTOFMEMORY; 84 | goto Finished; 85 | } 86 | 87 | // encoder operation 88 | if (g_intEncoderOp != BROTLI_PARAMETER_UNSET) 89 | { 90 | pContext->_op = static_cast(g_intEncoderOp); 91 | } 92 | 93 | DBGINFO((DBG_CONTEXT, 94 | "BROTLI_CONTEXT initialized\n" 95 | "- ptr: %p\n" 96 | "- encoder operation: %d\n", 97 | pContext, 98 | pContext->_op)); 99 | 100 | Finished: 101 | 102 | *context = (PVOID)pContext; 103 | return hr; 104 | } 105 | 106 | // 107 | // Destroy a compression context 108 | // 109 | VOID WINAPI 110 | DestroyCompression( 111 | IN PVOID context 112 | ) 113 | { 114 | BROTLI_CONTEXT* pContext = static_cast(context); 115 | 116 | if (pContext != NULL) 117 | { 118 | if (pContext->_pState != NULL) 119 | { 120 | BrotliEncoderDestroyInstance(pContext->_pState); 121 | } 122 | 123 | delete pContext; 124 | } 125 | } 126 | 127 | // 128 | // Compress data 129 | // 130 | HRESULT WINAPI 131 | Compress( 132 | IN OUT PVOID context, 133 | IN CONST BYTE * input_buffer, 134 | IN LONG input_buffer_size, 135 | IN PBYTE output_buffer, 136 | IN LONG output_buffer_size, 137 | OUT PLONG input_used, 138 | OUT PLONG output_used, 139 | IN INT compression_level 140 | ) 141 | { 142 | BROTLI_CONTEXT* pContext = static_cast(context); 143 | size_t input_available = static_cast(input_buffer_size); 144 | size_t output_available = static_cast(output_buffer_size); 145 | size_t total_out = 0; 146 | BrotliEncoderOperation flushMode = input_buffer_size ? pContext->_op : BROTLI_OPERATION_FINISH; 147 | BROTLI_BOOL ret = BROTLI_TRUE; 148 | HRESULT hr = S_OK; 149 | 150 | if (pContext == NULL) 151 | { 152 | hr = E_INVALIDARG; 153 | goto Finished; 154 | } 155 | 156 | // IIS schema specifies staticCompressionLevel and dynamicCompressionLevel as uint, 157 | // so only the upper bound needs to be checked. 158 | if (compression_level > BROTLI_MAX_QUALITY) 159 | { 160 | // Ignore any failure from event reporting 161 | ReportCompressionLevelOutOfBounds(compression_level, BROTLI_MAX_QUALITY); 162 | 163 | compression_level = BROTLI_MAX_QUALITY; 164 | } 165 | 166 | if (pContext->_pState == NULL) 167 | { 168 | // Create a BrotliEncoderState instance 169 | pContext->_pState = BrotliEncoderCreateInstance(NULL, // alloc_func 170 | NULL, // free_func 171 | NULL); // opaque 172 | if (pContext->_pState == NULL) 173 | { 174 | DBGERROR((DBG_CONTEXT, 175 | "BrotliEncoderCreateInstance failed\n")); 176 | 177 | hr = E_OUTOFMEMORY; 178 | goto Finished; 179 | } 180 | 181 | // Set compression quality for the BrotliEncoderState 182 | ret = BrotliEncoderSetParameter(pContext->_pState, // state 183 | BROTLI_PARAM_QUALITY, // param 184 | compression_level); // value 185 | if (ret == BROTLI_FALSE) 186 | { 187 | DBGERROR((DBG_CONTEXT, 188 | "BrotliEncoderSetParameter failed\n")); 189 | 190 | BrotliEncoderDestroyInstance(pContext->_pState); 191 | pContext->_pState = NULL; 192 | 193 | hr = HRESULT_FROM_WIN32(ERROR_BAD_CONFIGURATION); 194 | goto Finished; 195 | } 196 | } 197 | 198 | DBGINFO((DBG_CONTEXT, 199 | "Start BrotliEncoderCompressStream\n" 200 | "- input buffer: %p\n" 201 | "- input buffer size: %d\n" 202 | "- output buffer: %p\n" 203 | "- output buffer size: %d\n" 204 | "- compression level: %d\n" 205 | "- flush mode: %d\n", 206 | input_buffer, 207 | input_buffer_size, 208 | output_buffer, 209 | output_buffer_size, 210 | compression_level, 211 | flushMode)); 212 | 213 | ret = BrotliEncoderCompressStream(pContext->_pState, // state 214 | flushMode, // op 215 | &input_available, // available_in 216 | &input_buffer, // next_in 217 | &output_available, // available_out 218 | &output_buffer, // next_out 219 | &total_out); // total_out 220 | if (ret == BROTLI_FALSE) 221 | { 222 | DBGERROR((DBG_CONTEXT, 223 | "BrotliEncoderCompressStream failed")); 224 | hr = E_FAIL; 225 | goto Finished; 226 | } 227 | 228 | *input_used = input_buffer_size - static_cast(input_available); 229 | *output_used = output_buffer_size - static_cast(output_available); 230 | 231 | DBGINFO((DBG_CONTEXT, 232 | "End BrotliEncoderCompressStream\n" 233 | "- input bytes consumed: %d\n" 234 | "- output bytes produced: %d\n", 235 | *input_used, 236 | *output_used)); 237 | 238 | if (input_buffer_size == 0 && 239 | BrotliEncoderHasMoreOutput(pContext->_pState) == BROTLI_FALSE) 240 | { 241 | DBGINFO((DBG_CONTEXT, 242 | "Completed Brotli compression of the stream\n")); 243 | 244 | // Return S_FALSE to indicate IIS that the stream compression is done. 245 | hr = S_FALSE; 246 | } 247 | 248 | Finished: 249 | 250 | return hr; 251 | } 252 | 253 | // 254 | // Compress data with a specified flush mode 255 | // 256 | HRESULT WINAPI 257 | Compress2( 258 | IN OUT PVOID context, 259 | IN CONST BYTE * input_buffer, 260 | IN LONG input_buffer_size, 261 | IN PBYTE output_buffer, 262 | IN LONG output_buffer_size, 263 | OUT PLONG input_used, 264 | OUT PLONG output_used, 265 | IN INT compression_level, 266 | IN INT operation 267 | ) 268 | { 269 | BROTLI_CONTEXT* pContext = static_cast(context); 270 | size_t input_available = static_cast(input_buffer_size); 271 | size_t output_available = static_cast(output_buffer_size); 272 | size_t total_out = 0; 273 | BrotliEncoderOperation flushMode = ConvertFlushMode(operation); 274 | BROTLI_BOOL ret = BROTLI_TRUE; 275 | HRESULT hr = S_OK; 276 | 277 | if (pContext == NULL) 278 | { 279 | hr = E_INVALIDARG; 280 | goto Finished; 281 | } 282 | 283 | // IIS schema specifies staticCompressionLevel and dynamicCompressionLevel as uint, 284 | // so only the upper bound needs to be checked. 285 | if (compression_level > BROTLI_MAX_QUALITY) 286 | { 287 | // Ignore any failure from event reporting 288 | ReportCompressionLevelOutOfBounds(compression_level, BROTLI_MAX_QUALITY); 289 | 290 | compression_level = BROTLI_MAX_QUALITY; 291 | } 292 | 293 | if (pContext->_pState == NULL) 294 | { 295 | // Create a BrotliEncoderState instance 296 | pContext->_pState = BrotliEncoderCreateInstance(NULL, // alloc_func 297 | NULL, // free_func 298 | NULL); // opaque 299 | if (pContext->_pState == NULL) 300 | { 301 | DBGERROR((DBG_CONTEXT, 302 | "BrotliEncoderCreateInstance failed\n")); 303 | 304 | hr = E_OUTOFMEMORY; 305 | goto Finished; 306 | } 307 | 308 | // Set compression quality for the BrotliEncoderState 309 | ret = BrotliEncoderSetParameter(pContext->_pState, // state 310 | BROTLI_PARAM_QUALITY, // param 311 | compression_level); // value 312 | if (ret == BROTLI_FALSE) 313 | { 314 | DBGERROR((DBG_CONTEXT, 315 | "BrotliEncoderSetParameter failed\n")); 316 | 317 | BrotliEncoderDestroyInstance(pContext->_pState); 318 | pContext->_pState = NULL; 319 | 320 | hr = HRESULT_FROM_WIN32(ERROR_BAD_CONFIGURATION); 321 | goto Finished; 322 | } 323 | } 324 | 325 | DBGINFO((DBG_CONTEXT, 326 | "Start BrotliEncoderCompressStream\n" 327 | "- input buffer: %p\n" 328 | "- input buffer size: %d\n" 329 | "- output buffer: %p\n" 330 | "- output buffer size: %d\n" 331 | "- compression level: %d\n" 332 | "- flush mode: %d\n", 333 | input_buffer, 334 | input_buffer_size, 335 | output_buffer, 336 | output_buffer_size, 337 | compression_level, 338 | flushMode)); 339 | 340 | ret = BrotliEncoderCompressStream(pContext->_pState, // state 341 | flushMode, // op 342 | &input_available, // available_in 343 | &input_buffer, // next_in 344 | &output_available, // available_out 345 | &output_buffer, // next_out 346 | &total_out); // total_out 347 | if (ret == BROTLI_FALSE) 348 | { 349 | DBGERROR((DBG_CONTEXT, 350 | "BrotliEncoderCompressStream failed\n")); 351 | hr = E_FAIL; 352 | goto Finished; 353 | } 354 | 355 | *input_used = input_buffer_size - static_cast(input_available); 356 | *output_used = output_buffer_size - static_cast(output_available); 357 | 358 | DBGINFO((DBG_CONTEXT, 359 | "End BrotliEncoderCompressStream\n" 360 | "- input bytes consumed: %d\n" 361 | "- output bytes produced: %d\n", 362 | *input_used, 363 | *output_used)); 364 | 365 | if (input_buffer_size == 0 && 366 | BrotliEncoderHasMoreOutput(pContext->_pState) == BROTLI_FALSE) 367 | { 368 | // Return S_FALSE to indicate IIS that all output bytes have been produced. 369 | hr = S_FALSE; 370 | } 371 | 372 | Finished: 373 | 374 | return hr; 375 | } 376 | 377 | BrotliEncoderOperation 378 | ConvertFlushMode( 379 | INT operation 380 | ) 381 | { 382 | BrotliEncoderOperation flushMode = BROTLI_OPERATION_PROCESS; 383 | 384 | if (g_intEncoderOp != BROTLI_PARAMETER_UNSET) 385 | { 386 | flushMode = static_cast(g_intEncoderOp); 387 | } 388 | 389 | switch (operation) 390 | { 391 | case IIS_COMPRESSION_OPERATION_PROCESS: 392 | break; 393 | case IIS_COMPRESSION_OPERATION_FLUSH: 394 | flushMode = BROTLI_OPERATION_FLUSH; 395 | break; 396 | case IIS_COMPRESSION_OPERATION_FINISH: 397 | flushMode = BROTLI_OPERATION_FINISH; 398 | break; 399 | default: 400 | break; 401 | } 402 | 403 | return flushMode; 404 | } 405 | 406 | HRESULT 407 | ReportCompressionLevelOutOfBounds( 408 | INT currentLevel, 409 | INT maxLevel 410 | ) 411 | { 412 | WCHAR bufCurrentLevel[COMPRESSION_LEVEL_BUFFER_LENGTH]; 413 | WCHAR bufMaxLevel[COMPRESSION_LEVEL_BUFFER_LENGTH]; 414 | PCWSTR apsz[2]; 415 | HRESULT hr = S_OK; 416 | BOOL fReport = TRUE; 417 | 418 | if (g_fEventRaised == TRUE) 419 | { 420 | hr = S_OK; 421 | goto Finished; 422 | } 423 | 424 | if (g_hEventLog == NULL) 425 | { 426 | hr = E_HANDLE; 427 | goto Finished; 428 | } 429 | 430 | if (_itow_s(currentLevel, 431 | bufCurrentLevel, 432 | COMPRESSION_LEVEL_BUFFER_LENGTH, 433 | 10) != 0 || 434 | _itow_s(maxLevel, 435 | bufMaxLevel, 436 | COMPRESSION_LEVEL_BUFFER_LENGTH, 437 | 10) != 0) 438 | { 439 | hr = E_UNEXPECTED; 440 | goto Finished; 441 | } 442 | 443 | apsz[0] = bufCurrentLevel; 444 | apsz[1] = bufMaxLevel; 445 | 446 | fReport = ReportEvent(g_hEventLog, // hEventLog 447 | EVENTLOG_WARNING_TYPE, // wType 448 | 0, // wCategory 449 | BROTLI_COMPRESSION_LEVEL_OUT_OF_BOUNDS, // dwEventID 450 | NULL, // lpUserSid 451 | 2, // wNumStrings 452 | 0, // dwDataSize 453 | apsz, // lpStrings 454 | NULL); // lpRawData 455 | if (fReport == FALSE) 456 | { 457 | hr = HRESULT_FROM_WIN32(GetLastError()); 458 | goto Finished; 459 | } 460 | 461 | g_fEventRaised = TRUE; 462 | 463 | Finished: 464 | 465 | return hr; 466 | } -------------------------------------------------------------------------------- /iisbrotli/iisbrotli.def: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Microsoft Corporation. All rights reserved. 2 | ; Licensed under the MIT license. 3 | 4 | LIBRARY iisbrotli 5 | 6 | EXPORTS 7 | 8 | InitCompression 9 | DeInitCompression 10 | CreateCompression 11 | ResetCompression 12 | Compress 13 | Compress2 14 | DestroyCompression 15 | -------------------------------------------------------------------------------- /iisbrotli/iisbrotli.rc: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #define VER_FILETYPE VFT_DLL 5 | #define VER_FILEDESCRIPTION_STR "IIS Brotli Compression Scheme" 6 | #define VER_INTERNALNAME_STR "iisbrotli.dll" 7 | #define VER_LANGNEUTRAL 8 | #define RC_VERSION_INTERNAL_NAME "iisbrotli\0" 9 | #define RC_VERSION_ORIGINAL_FILE_NAME "iisbrotli.dll\0" 10 | #define RC_VERSION_FILE_DESCRIPTION "IIS Brotli Compression Scheme" 11 | #define RC_VERSION_LEGAL_COPYRIGHT "Copyright \251 2018 Microsoft Corporation\0" 12 | 13 | #include 14 | #include "./GeneratedFiles/iisbrotli_msg.rc" 15 | -------------------------------------------------------------------------------- /iisbrotli/iisbrotli.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Debug 10 | ARM64 11 | 12 | 13 | Debug 14 | ARM64EC 15 | 16 | 17 | Debug 18 | Win32 19 | 20 | 21 | Release 22 | ARM64 23 | 24 | 25 | Release 26 | ARM64EC 27 | 28 | 29 | Release 30 | Win32 31 | 32 | 33 | Debug 34 | x64 35 | 36 | 37 | Release 38 | x64 39 | 40 | 41 | 42 | 43 | {67aaf490-c8a7-4020-bb96-593b2001ea4d} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | $(ResourceCompilePreprocessorDefinitions) 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | {CA3EFC47-0ABB-45AD-B672-F1D6066BF62A} 67 | Runtime 68 | 10.0 69 | 70 | 71 | 72 | DynamicLibrary 73 | v143 74 | 75 | 76 | 77 | $(ProjectDir)include;$(ProjectDir)GeneratedFiles;$(IIS-Common)version;$(IIS-Common)Include;$(WindowsSDK_IncludePath);$(IncludePath); 78 | $(ProjectName) 79 | 80 | 81 | true 82 | 83 | 84 | 85 | true 86 | 4091 87 | $(SolutionDir)\IIS-Common\Include;$(SubmoduleBrotli)\c\include;$(SubmoduleBrotli)\c\include\brotli;%(AdditionalIncludeDirectories) 88 | $(SolutionDir)\IIS-Common\Include;$(SubmoduleBrotli)\c\include;$(SubmoduleBrotli)\c\include\brotli;%(AdditionalIncludeDirectories) 89 | $(SolutionDir)\IIS-Common\Include;$(SubmoduleBrotli)\c\include;$(SubmoduleBrotli)\c\include\brotli;%(AdditionalIncludeDirectories) 90 | $(SolutionDir)\IIS-Common\Include;$(SubmoduleBrotli)\c\include;$(SubmoduleBrotli)\c\include\brotli;%(AdditionalIncludeDirectories) 91 | $(SolutionDir)\IIS-Common\Include;$(SubmoduleBrotli)\c\include;$(SubmoduleBrotli)\c\include\brotli;%(AdditionalIncludeDirectories) 92 | $(SolutionDir)\IIS-Common\Include;$(SubmoduleBrotli)\c\include;$(SubmoduleBrotli)\c\include\brotli;%(AdditionalIncludeDirectories) 93 | $(SolutionDir)\IIS-Common\Include;$(SubmoduleBrotli)\c\include;$(SubmoduleBrotli)\c\include\brotli;%(AdditionalIncludeDirectories) 94 | $(SolutionDir)\IIS-Common\Include;$(SubmoduleBrotli)\c\include;$(SubmoduleBrotli)\c\include\brotli;%(AdditionalIncludeDirectories) 95 | false 96 | false 97 | false 98 | false 99 | 100 | 101 | %(AdditionalDependencies) 102 | iisbrotli.def 103 | DebugFull 104 | DebugFull 105 | DebugFull 106 | DebugFull 107 | 108 | 109 | 110 | 111 | 112 | This project is trying to import a missing file: {0}. 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /iisbrotli/iisbrotli_msg.mc: -------------------------------------------------------------------------------- 1 | ;/*++ 2 | ; Copyright (c) Microsoft Corporation. All rights reserved. 3 | ; Licensed under the MIT license. 4 | ;--*/ 5 | ; 6 | ;#ifndef _IISBROTLI_MSG_H_ 7 | ;#define _IISBROTLI_MSG_H_ 8 | ; 9 | 10 | SeverityNames=(Success=0x0 11 | Informational=0x1 12 | Warning=0x2 13 | Error=0x3 14 | ) 15 | 16 | Messageid=1000 Severity=Warning SymbolicName=BROTLI_COMPRESSION_LEVEL_OUT_OF_BOUNDS 17 | Language=English 18 | The Brotli compression level '%1' is larger than the maximum allowed value '%2' and has been reset to '%2'. 19 | . 20 | 21 | ; 22 | ;#endif // _IISBROTLI_MSG_H_ 23 | ; 24 | -------------------------------------------------------------------------------- /iisbrotli/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /iisbrotli/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | // stdafx.cpp : source file that includes just the standard includes 5 | // iisbrotli.pch will be the pre-compiled header 6 | // stdafx.obj will contain the pre-compiled type information 7 | 8 | #include "stdafx.h" 9 | 10 | // TODO: reference any additional headers you need in STDAFX.H 11 | // and not in this file 12 | -------------------------------------------------------------------------------- /iisbrotli/stdafx.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | // stdafx.h : include file for standard system include files, 5 | // or project specific include files that are used frequently, but 6 | // are changed infrequently 7 | // 8 | 9 | #pragma once 10 | 11 | #include "targetver.h" 12 | 13 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 14 | // Windows Header Files: 15 | #include 16 | #include 17 | 18 | // Brotli Header Files 19 | #include "port.h" 20 | #include "types.h" 21 | #include "encode.h" 22 | 23 | // IIS Common Header Files 24 | // VS Debug build only automatically defines _DEBUG, but debug utilities require DEBUG 25 | #ifdef _DEBUG 26 | #ifndef DEBUG 27 | #define DEBUG 28 | #endif 29 | #endif 30 | #include "dbgutil.h" 31 | #include "iisbrotli_msg.h" 32 | 33 | // Constants 34 | #define IIS_COMPRESSION_OPERATION_PROCESS 0 35 | #define IIS_COMPRESSION_OPERATION_FLUSH 1 36 | #define IIS_COMPRESSION_OPERATION_FINISH 2 37 | 38 | #define BROTLI_PARAMETER_UNSET -1 39 | 40 | #define COMPRESSION_LEVEL_BUFFER_LENGTH 33 41 | 42 | #define IISBROTLI_EVENT_SOURCE_NAME L"IISBrotli" 43 | 44 | // Global variables 45 | extern INT g_intEncoderOp; 46 | extern HANDLE g_hEventLog; 47 | extern BOOL g_fEventRaised; 48 | -------------------------------------------------------------------------------- /iisbrotli/targetver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | // Including SDKDDKVer.h defines the highest available Windows platform. 7 | 8 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 9 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 10 | 11 | #include 12 | -------------------------------------------------------------------------------- /iiszlib/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #include "stdafx.h" 5 | 6 | DECLARE_DEBUG_PRINT_OBJECT2("iiszlib", DEBUG_FLAGS_ERROR); 7 | 8 | INT g_intWindowBits = ZLIB_PARAMETER_UNSET; 9 | INT g_intMemLevel = ZLIB_PARAMETER_UNSET; 10 | INT g_intFlushMode = ZLIB_PARAMETER_UNSET; 11 | BOOL g_fEnableZlibDeflate = FALSE; 12 | HANDLE g_hEventLog = NULL; 13 | BOOL g_fEventRaised = FALSE; 14 | 15 | VOID LoadGlobalConfiguration(VOID); 16 | 17 | BOOL APIENTRY 18 | DllMain( 19 | HMODULE hModule, 20 | DWORD dwReason, 21 | LPVOID lpReserved 22 | ) 23 | { 24 | switch (dwReason) 25 | { 26 | case DLL_PROCESS_ATTACH: 27 | LoadGlobalConfiguration(); 28 | CREATE_DEBUG_PRINT_OBJECT; 29 | break; 30 | case DLL_THREAD_ATTACH: 31 | case DLL_THREAD_DETACH: 32 | case DLL_PROCESS_DETACH: 33 | break; 34 | } 35 | return TRUE; 36 | } 37 | 38 | VOID 39 | LoadGlobalConfiguration( 40 | VOID 41 | ) 42 | { 43 | DWORD dwType = 0; 44 | DWORD dwData = 0; 45 | DWORD cbData = 0; 46 | HKEY hKey; 47 | 48 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, 49 | L"SOFTWARE\\Microsoft\\IIS Extensions\\IIS Compression\\IISZlib\\Parameters", 50 | 0, 51 | KEY_READ, 52 | &hKey) == ERROR_SUCCESS) 53 | { 54 | cbData = sizeof(dwData); 55 | if (RegQueryValueEx(hKey, 56 | L"WindowBits", 57 | NULL, 58 | &dwType, 59 | (LPBYTE) &dwData, 60 | &cbData) == ERROR_SUCCESS && 61 | dwType == REG_DWORD) 62 | { 63 | g_intWindowBits = (INT) dwData; 64 | } 65 | 66 | cbData = sizeof(dwData); 67 | if (RegQueryValueEx(hKey, 68 | L"MemLevel", 69 | NULL, 70 | &dwType, 71 | (LPBYTE) &dwData, 72 | &cbData) == ERROR_SUCCESS && 73 | dwType == REG_DWORD) 74 | { 75 | g_intMemLevel = (INT) dwData; 76 | } 77 | 78 | cbData = sizeof(dwData); 79 | if (RegQueryValueEx(hKey, 80 | L"FlushMode", 81 | NULL, 82 | &dwType, 83 | (LPBYTE) &dwData, 84 | &cbData) == ERROR_SUCCESS && 85 | dwType == REG_DWORD) 86 | { 87 | g_intFlushMode = (INT) dwData; 88 | } 89 | 90 | cbData = sizeof(dwData); 91 | if (RegQueryValueEx(hKey, 92 | L"EnableZlibDeflate", 93 | NULL, 94 | &dwType, 95 | (LPBYTE) &dwData, 96 | &cbData) == ERROR_SUCCESS && 97 | dwType == REG_DWORD) 98 | { 99 | g_fEnableZlibDeflate = !!dwData; 100 | } 101 | 102 | cbData = sizeof(dwData); 103 | if (RegQueryValueEx(hKey, 104 | L"DebugFlags", 105 | NULL, 106 | &dwType, 107 | (LPBYTE) &dwData, 108 | &cbData) == ERROR_SUCCESS && 109 | dwType == REG_DWORD) 110 | { 111 | DEBUG_FLAGS_VAR = dwData; 112 | } 113 | 114 | RegCloseKey(hKey); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /iiszlib/iiszlib.cxx: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #include "stdafx.h" 5 | 6 | class ZLIB_CONTEXT 7 | { 8 | public: 9 | 10 | ZLIB_CONTEXT() 11 | : _fInitialized(FALSE), 12 | _fGzip(FALSE), 13 | _windowBits(ZLIB_DEF_WINDOW_BITS), 14 | _memLevel(ZLIB_DEF_MEM_LEVEL), 15 | _flushMode(Z_NO_FLUSH) 16 | { 17 | _strm.zalloc = Z_NULL; 18 | _strm.zfree = Z_NULL; 19 | _strm.opaque = Z_NULL; 20 | 21 | _strm.next_in = Z_NULL; 22 | _strm.avail_in = 0; 23 | _strm.total_in = 0; 24 | 25 | _strm.next_out = Z_NULL; 26 | _strm.avail_out = 0; 27 | _strm.total_out = 0; 28 | } 29 | 30 | BOOL _fInitialized; 31 | BOOL _fGzip; 32 | 33 | // zlib parameters 34 | z_stream _strm; 35 | INT _windowBits; 36 | INT _memLevel; 37 | INT _flushMode; 38 | }; 39 | 40 | 41 | HRESULT HresultFromZlib(INT zlibErrCode); 42 | INT ConvertFlushMode(INT operation); 43 | HRESULT ReportCompressionLevelOutOfBounds(INT currentLevel, INT maxLevel); 44 | 45 | // 46 | // Initialize global compression 47 | // 48 | HRESULT WINAPI 49 | InitCompression( 50 | VOID 51 | ) 52 | { 53 | g_hEventLog = RegisterEventSource(NULL, 54 | IISZLIB_EVENT_SOURCE_NAME); 55 | 56 | // Ignore the failure from RegisterEventSource 57 | return S_OK; 58 | } 59 | 60 | // 61 | // De-init global compression 62 | // 63 | VOID WINAPI 64 | DeInitCompression( 65 | VOID 66 | ) 67 | { 68 | if (g_hEventLog != NULL) 69 | { 70 | DeregisterEventSource(g_hEventLog); 71 | g_hEventLog = NULL; 72 | } 73 | return; 74 | } 75 | 76 | // 77 | // Reset compression context 78 | // 79 | HRESULT WINAPI 80 | ResetCompression( 81 | IN OUT PVOID context 82 | ) 83 | { 84 | return S_OK; 85 | } 86 | 87 | // 88 | // Create a compression context 89 | // 90 | HRESULT WINAPI 91 | CreateCompression( 92 | OUT PVOID * context, 93 | IN ULONG flags 94 | ) 95 | { 96 | HRESULT hr = S_OK; 97 | ZLIB_CONTEXT* pContext = NULL; 98 | 99 | if (flags == COMPRESSION_FLAG_INVALID) 100 | { 101 | DBGERROR((DBG_CONTEXT, 102 | "Invalid flags\n")); 103 | hr = E_INVALIDARG; 104 | goto Finished; 105 | } 106 | 107 | pContext = new ZLIB_CONTEXT(); 108 | if (pContext == NULL) 109 | { 110 | DBGERROR((DBG_CONTEXT, 111 | "Failed to create ZLIB_CONTEXT\n")); 112 | hr = E_OUTOFMEMORY; 113 | goto Finished; 114 | } 115 | 116 | // window bits 117 | if (g_intWindowBits != ZLIB_PARAMETER_UNSET) 118 | { 119 | pContext->_windowBits = g_intWindowBits; 120 | } 121 | 122 | // mem level 123 | if (g_intMemLevel != ZLIB_PARAMETER_UNSET) 124 | { 125 | pContext->_memLevel = g_intMemLevel; 126 | } 127 | 128 | // flush mode 129 | if (g_intFlushMode != ZLIB_PARAMETER_UNSET) 130 | { 131 | pContext->_flushMode = g_intFlushMode; 132 | } 133 | 134 | // compressed data format 135 | if (flags & COMPRESSION_FLAG_GZIP) 136 | { 137 | // gzip content-encoding: 138 | // Add 16 to windowBits to ask zlib to write gzip format header & trailer. 139 | // By default zlib write zlib format header & trailer used by deflate content encoding. 140 | pContext->_fGzip = TRUE; 141 | pContext->_windowBits |= 16; 142 | } 143 | else 144 | { 145 | // deflate content-encoding: 146 | if (g_fEnableZlibDeflate == FALSE) 147 | { 148 | // default mode: raw deflate for IE compatibility 149 | // Flip the sign of windowBits to force zlib to produce raw deflate 150 | // without zlib header and checksum 151 | pContext->_windowBits = - pContext->_windowBits; 152 | } 153 | } 154 | 155 | DBGINFO((DBG_CONTEXT, 156 | "ZLIB_CONTEXT initialized\n" 157 | "- ptr: %p\n" 158 | "- scheme: %s\n" 159 | "- windowBits: %d\n" 160 | "- memLevel: %d\n" 161 | "- flush mode: %d\n", 162 | pContext, 163 | pContext->_fGzip ? "gzip" : "deflate", 164 | pContext->_windowBits, 165 | pContext->_memLevel, 166 | pContext->_flushMode)); 167 | 168 | Finished: 169 | 170 | *context = (PVOID)pContext; 171 | return hr; 172 | } 173 | 174 | // 175 | // Destroy a compression context 176 | // 177 | VOID WINAPI 178 | DestroyCompression( 179 | IN PVOID context 180 | ) 181 | { 182 | ZLIB_CONTEXT* pContext = static_cast(context); 183 | 184 | if (pContext != NULL) 185 | { 186 | if (pContext->_fInitialized == TRUE) 187 | { 188 | deflateEnd(&pContext->_strm); 189 | } 190 | delete pContext; 191 | } 192 | } 193 | 194 | // 195 | // Compress data 196 | // 197 | HRESULT WINAPI 198 | Compress( 199 | IN OUT PVOID context, 200 | IN CONST BYTE * input_buffer, 201 | IN LONG input_buffer_size, 202 | IN PBYTE output_buffer, 203 | IN LONG output_buffer_size, 204 | OUT PLONG input_used, 205 | OUT PLONG output_used, 206 | IN INT compression_level 207 | ) 208 | { 209 | ZLIB_CONTEXT* pContext = static_cast(context); 210 | HRESULT hr = S_OK; 211 | INT ret = Z_OK; 212 | INT flushMode = input_buffer_size ? pContext->_flushMode : Z_FINISH; 213 | 214 | if (pContext == NULL) 215 | { 216 | hr = E_INVALIDARG; 217 | goto Finished; 218 | } 219 | 220 | // IIS schema specifies staticCompressionLevel and dynamicCompressionLevel as uint, 221 | // so only the upper bound needs to be checked. 222 | if (compression_level > Z_BEST_COMPRESSION) 223 | { 224 | // Ignore any failure from event reporting 225 | ReportCompressionLevelOutOfBounds(compression_level, Z_BEST_COMPRESSION); 226 | 227 | compression_level = Z_BEST_COMPRESSION; 228 | } 229 | 230 | if (pContext->_fInitialized == FALSE) 231 | { 232 | ret = deflateInit2(&pContext->_strm, // strm 233 | compression_level, // level 234 | Z_DEFLATED, // method 235 | pContext->_windowBits, // windowBits 236 | pContext->_memLevel, // memLevel 237 | Z_DEFAULT_STRATEGY); // strategy 238 | 239 | if (FAILED(hr = HresultFromZlib(ret))) 240 | { 241 | DBGERROR((DBG_CONTEXT, 242 | "deflateInit2 failed: %d\n", 243 | ret)); 244 | deflateEnd(&pContext->_strm); 245 | goto Finished; 246 | } 247 | 248 | pContext->_fInitialized = TRUE; 249 | } 250 | 251 | pContext->_strm.next_in = (z_const Bytef *) input_buffer; 252 | pContext->_strm.avail_in = input_buffer_size; 253 | pContext->_strm.next_out = output_buffer; 254 | pContext->_strm.avail_out = output_buffer_size; 255 | 256 | DBGINFO((DBG_CONTEXT, 257 | "Start deflate\n" 258 | "- input buffer: %p\n" 259 | "- input buffer size: %d\n" 260 | "- output buffer: %p\n" 261 | "- output buffer size: %d\n" 262 | "- compression level: %d\n" 263 | "- flush mode: %d\n", 264 | input_buffer, 265 | input_buffer_size, 266 | output_buffer, 267 | output_buffer_size, 268 | compression_level, 269 | flushMode)); 270 | 271 | ret = deflate(&pContext->_strm, flushMode); 272 | 273 | if (ret == Z_OK || ret == Z_BUF_ERROR) 274 | { 275 | DBGINFO((DBG_CONTEXT, "Need to call Compress again\n")); 276 | hr = S_OK; 277 | } 278 | else if (ret == Z_STREAM_END) 279 | { 280 | DBGINFO((DBG_CONTEXT, "End of stream\n")); 281 | hr = S_FALSE; 282 | } 283 | else 284 | { 285 | hr = HresultFromZlib(ret); 286 | DBGERROR((DBG_CONTEXT, 287 | "deflate failed: %d\n", 288 | ret)); 289 | goto Finished; 290 | } 291 | 292 | *input_used = input_buffer_size - pContext->_strm.avail_in; 293 | *output_used = output_buffer_size - pContext->_strm.avail_out; 294 | 295 | DBGINFO((DBG_CONTEXT, 296 | "End deflate\n" 297 | "- input bytes consumed: %d\n" 298 | "- output bytes produced: %d\n", 299 | *input_used, 300 | *output_used)); 301 | 302 | Finished: 303 | 304 | return hr; 305 | } 306 | 307 | // 308 | // Compress data with a specified flush mode 309 | // 310 | HRESULT WINAPI 311 | Compress2( 312 | IN OUT PVOID context, 313 | IN CONST BYTE * input_buffer, 314 | IN LONG input_buffer_size, 315 | IN PBYTE output_buffer, 316 | IN LONG output_buffer_size, 317 | OUT PLONG input_used, 318 | OUT PLONG output_used, 319 | IN INT compression_level, 320 | IN INT operation 321 | ) 322 | { 323 | ZLIB_CONTEXT* pContext = static_cast(context); 324 | HRESULT hr = S_OK; 325 | INT ret = Z_OK; 326 | INT flushMode = ConvertFlushMode(operation); 327 | 328 | if (pContext == NULL) 329 | { 330 | hr = E_INVALIDARG; 331 | goto Finished; 332 | } 333 | 334 | // IIS schema specifies staticCompressionLevel and dynamicCompressionLevel as uint, 335 | // so only the upper bound needs to be checked. 336 | if (compression_level > Z_BEST_COMPRESSION) 337 | { 338 | // Ignore any failure from event reporting 339 | ReportCompressionLevelOutOfBounds(compression_level, Z_BEST_COMPRESSION); 340 | 341 | compression_level = Z_BEST_COMPRESSION; 342 | } 343 | 344 | if (pContext->_fInitialized == FALSE) 345 | { 346 | ret = deflateInit2(&pContext->_strm, // strm 347 | compression_level, // level 348 | Z_DEFLATED, // method 349 | pContext->_windowBits, // windowBits 350 | pContext->_memLevel, // memLevel 351 | Z_DEFAULT_STRATEGY); // strategy 352 | 353 | if (FAILED(hr = HresultFromZlib(ret))) 354 | { 355 | DBGERROR((DBG_CONTEXT, 356 | "deflateInit2 failed: %d\n", 357 | ret)); 358 | deflateEnd(&pContext->_strm); 359 | goto Finished; 360 | } 361 | 362 | pContext->_fInitialized = TRUE; 363 | } 364 | 365 | pContext->_strm.next_in = (z_const Bytef *) input_buffer; 366 | pContext->_strm.avail_in = input_buffer_size; 367 | pContext->_strm.next_out = output_buffer; 368 | pContext->_strm.avail_out = output_buffer_size; 369 | 370 | DBGINFO((DBG_CONTEXT, 371 | "Start deflate\n" 372 | "- input buffer: %p\n" 373 | "- input buffer size: %d\n" 374 | "- output buffer: %p\n" 375 | "- output buffer size: %d\n" 376 | "- compression level: %d\n" 377 | "- flush mode: %d\n", 378 | input_buffer, 379 | input_buffer_size, 380 | output_buffer, 381 | output_buffer_size, 382 | compression_level, 383 | flushMode)); 384 | 385 | ret = deflate(&pContext->_strm, flushMode); 386 | 387 | if (ret == Z_OK) 388 | { 389 | if (flushMode == Z_SYNC_FLUSH && 390 | input_buffer_size == 0 && 391 | pContext->_strm.avail_out > 0) // sufficient output buffer size 392 | { 393 | DBGINFO((DBG_CONTEXT,"End of flush\n")); 394 | hr = S_FALSE; 395 | } 396 | else 397 | { 398 | DBGINFO((DBG_CONTEXT, "Need to call Compress2 again\n")); 399 | hr = S_OK; 400 | } 401 | } 402 | else if (ret == Z_BUF_ERROR) 403 | { 404 | DBGINFO((DBG_CONTEXT, "Need to call Compress2 again\n")); 405 | hr = S_OK; 406 | } 407 | else if (ret == Z_STREAM_END) 408 | { 409 | DBGINFO((DBG_CONTEXT, "End of stream\n")); 410 | hr = S_FALSE; 411 | } 412 | else 413 | { 414 | hr = HresultFromZlib(ret); 415 | DBGERROR((DBG_CONTEXT, 416 | "deflate failed: %d\n", 417 | ret)); 418 | goto Finished; 419 | } 420 | 421 | *input_used = input_buffer_size - pContext->_strm.avail_in; 422 | *output_used = output_buffer_size - pContext->_strm.avail_out; 423 | 424 | DBGINFO((DBG_CONTEXT, 425 | "End deflate\n" 426 | "- input bytes consumed: %d\n" 427 | "- output bytes produced: %d\n", 428 | *input_used, 429 | *output_used)); 430 | 431 | if (*output_used == 0 && 432 | *input_used == 0 && 433 | ret == Z_BUF_ERROR && 434 | flushMode == Z_SYNC_FLUSH) 435 | { 436 | // If this function (Compress2) is called twice with zero input data and the same operation value (IIS_COMPRESSION_OPERATION_PROCESS), 437 | // the deflate() function will return Z_BUF_ERROR for the second call. 438 | DBGINFO((DBG_CONTEXT, "Compress2 was called twice with zero input data with Z_SYSNC_FLUSH. Compress2 should not be called again\n")); 439 | hr = S_FALSE; 440 | } 441 | 442 | Finished: 443 | 444 | return hr; 445 | } 446 | 447 | HRESULT 448 | HresultFromZlib( 449 | INT zlibErrCode 450 | ) 451 | { 452 | HRESULT hr = S_OK; 453 | 454 | switch (zlibErrCode) 455 | { 456 | case Z_OK: 457 | case Z_BUF_ERROR: // output buffer full, not a real error 458 | hr = S_OK; 459 | break; 460 | case Z_STREAM_END: // all input consumed, all output generated 461 | hr = S_FALSE; // S_FALSE is required by IIS to indicate final block done 462 | break; 463 | case Z_MEM_ERROR: 464 | hr = E_OUTOFMEMORY; 465 | break; 466 | case Z_DATA_ERROR: 467 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 468 | break; 469 | case Z_VERSION_ERROR: 470 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DLL); 471 | break; 472 | case Z_STREAM_ERROR: 473 | hr = E_INVALIDARG; 474 | break; 475 | case Z_ERRNO: 476 | default: 477 | hr = HRESULT_FROM_WIN32(zlibErrCode); 478 | break; 479 | } 480 | 481 | return hr; 482 | } 483 | 484 | INT 485 | ConvertFlushMode( 486 | INT operation 487 | ) 488 | { 489 | INT flushMode = Z_NO_FLUSH; 490 | 491 | if (g_intFlushMode != ZLIB_PARAMETER_UNSET) 492 | { 493 | flushMode = g_intFlushMode; 494 | } 495 | 496 | switch (operation) 497 | { 498 | case IIS_COMPRESSION_OPERATION_PROCESS: 499 | break; 500 | case IIS_COMPRESSION_OPERATION_FLUSH: 501 | flushMode = Z_SYNC_FLUSH; 502 | break; 503 | case IIS_COMPRESSION_OPERATION_FINISH: 504 | flushMode = Z_FINISH; 505 | break; 506 | default: 507 | break; 508 | } 509 | 510 | return flushMode; 511 | } 512 | 513 | HRESULT 514 | ReportCompressionLevelOutOfBounds( 515 | INT currentLevel, 516 | INT maxLevel 517 | ) 518 | { 519 | WCHAR bufCurrentLevel[COMPRESSION_LEVEL_BUFFER_LENGTH]; 520 | WCHAR bufMaxLevel[COMPRESSION_LEVEL_BUFFER_LENGTH]; 521 | PCWSTR apsz[2]; 522 | HRESULT hr = S_OK; 523 | BOOL fReport = TRUE; 524 | 525 | if (g_fEventRaised == TRUE) 526 | { 527 | hr = S_OK; 528 | goto Finished; 529 | } 530 | 531 | if (g_hEventLog == NULL) 532 | { 533 | hr = E_HANDLE; 534 | goto Finished; 535 | } 536 | 537 | if (_itow_s(currentLevel, 538 | bufCurrentLevel, 539 | COMPRESSION_LEVEL_BUFFER_LENGTH, 540 | 10) != 0 || 541 | _itow_s(maxLevel, 542 | bufMaxLevel, 543 | COMPRESSION_LEVEL_BUFFER_LENGTH, 544 | 10) != 0) 545 | { 546 | hr = E_UNEXPECTED; 547 | goto Finished; 548 | } 549 | 550 | apsz[0] = bufCurrentLevel; 551 | apsz[1] = bufMaxLevel; 552 | 553 | fReport = ReportEvent(g_hEventLog, // hEventLog 554 | EVENTLOG_WARNING_TYPE, // wType 555 | 0, // wCategory 556 | ZLIB_COMPRESSION_LEVEL_OUT_OF_BOUNDS, // dwEventID 557 | NULL, // lpUserSid 558 | 2, // wNumStrings 559 | 0, // dwDataSize 560 | apsz, // lpStrings 561 | NULL); // lpRawData 562 | if (fReport == FALSE) 563 | { 564 | hr = HRESULT_FROM_WIN32(GetLastError()); 565 | goto Finished; 566 | } 567 | 568 | g_fEventRaised = TRUE; 569 | 570 | Finished: 571 | 572 | return hr; 573 | } -------------------------------------------------------------------------------- /iiszlib/iiszlib.def: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Microsoft Corporation. All rights reserved. 2 | ; Licensed under the MIT license. 3 | 4 | LIBRARY iiszlib 5 | 6 | EXPORTS 7 | 8 | InitCompression 9 | DeInitCompression 10 | CreateCompression 11 | ResetCompression 12 | Compress 13 | Compress2 14 | DestroyCompression 15 | -------------------------------------------------------------------------------- /iiszlib/iiszlib.rc: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #define VER_FILETYPE VFT_DLL 5 | #define VER_FILEDESCRIPTION_STR "IIS Zlib Compression Scheme" 6 | #define VER_INTERNALNAME_STR "iiszlib.dll" 7 | #define VER_LANGNEUTRAL 8 | #define RC_VERSION_INTERNAL_NAME "iiszlib\0" 9 | #define RC_VERSION_ORIGINAL_FILE_NAME "iiszlib.dll\0" 10 | #define RC_VERSION_FILE_DESCRIPTION "IIS Zlib Compression Scheme" 11 | #define RC_VERSION_LEGAL_COPYRIGHT "Copyright \251 2018 Microsoft Corporation\0" 12 | 13 | #include 14 | #include "./GeneratedFiles/iiszlib_msg.rc" 15 | -------------------------------------------------------------------------------- /iiszlib/iiszlib.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Debug 10 | ARM64 11 | 12 | 13 | Debug 14 | ARM64EC 15 | 16 | 17 | Debug 18 | Win32 19 | 20 | 21 | Release 22 | ARM64 23 | 24 | 25 | Release 26 | ARM64EC 27 | 28 | 29 | Release 30 | Win32 31 | 32 | 33 | Debug 34 | x64 35 | 36 | 37 | Release 38 | x64 39 | 40 | 41 | 42 | {57619DE0-503C-4758-97BC-5AFA0A029BFA} 43 | Runtime 44 | 10.0 45 | 46 | 47 | 48 | DynamicLibrary 49 | v143 50 | 51 | 52 | 53 | $(ProjectDir)include;$(ProjectDir)GeneratedFiles;$(IIS-Common)version;$(IIS-Common)Include;$(WindowsSDK_IncludePath);$(IncludePath); 54 | $(ProjectName) 55 | 56 | 57 | true 58 | 59 | 60 | 61 | true 62 | 4091 63 | $(SolutionDir)\IIS-Common\include;$(SubmoduleZlib);%(AdditionalIncludeDirectories) 64 | $(SolutionDir)\IIS-Common\include;$(SubmoduleZlib);%(AdditionalIncludeDirectories) 65 | $(SolutionDir)\IIS-Common\include;$(SubmoduleZlib);%(AdditionalIncludeDirectories) 66 | $(SolutionDir)\IIS-Common\include;$(SubmoduleZlib);%(AdditionalIncludeDirectories) 67 | $(SolutionDir)\IIS-Common\include;$(SubmoduleZlib);%(AdditionalIncludeDirectories) 68 | $(SolutionDir)\IIS-Common\include;$(SubmoduleZlib);%(AdditionalIncludeDirectories) 69 | $(SolutionDir)\IIS-Common\include;$(SubmoduleZlib);%(AdditionalIncludeDirectories) 70 | $(SolutionDir)\IIS-Common\include;$(SubmoduleZlib);%(AdditionalIncludeDirectories) 71 | false 72 | false 73 | false 74 | false 75 | 76 | 77 | %(AdditionalDependencies) 78 | iiszlib.def 79 | DebugFull 80 | DebugFull 81 | DebugFull 82 | DebugFull 83 | 84 | 85 | 86 | 87 | $(ResourceCompilePreprocessorDefinitions) 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | {8d460a29-85af-4884-a839-160862a94130} 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | This project is trying to import a missing file: {0}. 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /iiszlib/iiszlib_msg.mc: -------------------------------------------------------------------------------- 1 | ;/*++ 2 | ; Copyright (c) Microsoft Corporation. All rights reserved. 3 | ; Licensed under the MIT license. 4 | ;--*/ 5 | ; 6 | ;#ifndef _IISZLIB_MSG_H_ 7 | ;#define _IISZLIB_MSG_H_ 8 | ; 9 | 10 | SeverityNames=(Success=0x0 11 | Informational=0x1 12 | Warning=0x2 13 | Error=0x3 14 | ) 15 | 16 | Messageid=1000 Severity=Warning SymbolicName=ZLIB_COMPRESSION_LEVEL_OUT_OF_BOUNDS 17 | Language=English 18 | The Zlib compression level '%1' is larger than the maximum allowed value '%2' and has been reset to '%2'. 19 | . 20 | 21 | ; 22 | ;#endif // _IISBROTLI_MSG_H_ 23 | ; 24 | -------------------------------------------------------------------------------- /iiszlib/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /iiszlib/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | // stdafx.cpp : source file that includes just the standard includes 5 | // iiszlib.pch will be the pre-compiled header 6 | // stdafx.obj will contain the pre-compiled type information 7 | 8 | #include "stdafx.h" 9 | 10 | // TODO: reference any additional headers you need in STDAFX.H 11 | // and not in this file -------------------------------------------------------------------------------- /iiszlib/stdafx.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | // stdafx.h : include file for standard system include files, 5 | // or project specific include files that are used frequently, but 6 | // are changed infrequently 7 | // 8 | 9 | #pragma once 10 | 11 | #include "targetver.h" 12 | 13 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 14 | // Windows Header Files: 15 | #include 16 | #include 17 | 18 | // zlib Header Files: 19 | #include "zlib.h" 20 | 21 | // IIS Common Header Files 22 | // VS Debug build only automatically defines _DEBUG, but debug utilities require DEBUG 23 | #ifdef _DEBUG 24 | #ifndef DEBUG 25 | #define DEBUG 26 | #endif 27 | #endif 28 | #include "dbgutil.h" 29 | #include "iiszlib_msg.h" 30 | 31 | // Constants 32 | #define COMPRESSION_FLAG_DEFLATE 0x00000000 33 | #define COMPRESSION_FLAG_GZIP 0x00000001 34 | #define COMPRESSION_FLAG_INVALID 0xFFFFFFFF 35 | 36 | #define IIS_COMPRESSION_OPERATION_PROCESS 0 37 | #define IIS_COMPRESSION_OPERATION_FLUSH 1 38 | #define IIS_COMPRESSION_OPERATION_FINISH 2 39 | 40 | #define ZLIB_DEF_MEM_LEVEL 8 // default memLevel 41 | #define ZLIB_DEF_WINDOW_BITS 15 // default windowBits, 2^15 ~ 32K window size, RFC 1951 42 | #define ZLIB_PARAMETER_UNSET -1 43 | 44 | #define COMPRESSION_LEVEL_BUFFER_LENGTH 33 45 | 46 | #define IISZLIB_EVENT_SOURCE_NAME L"IISZlib" 47 | 48 | // Global variables 49 | extern INT g_intWindowBits; 50 | extern INT g_intMemLevel; 51 | extern INT g_intFlushMode; 52 | extern BOOL g_fEnableZlibDeflate; 53 | extern HANDLE g_hEventLog; 54 | extern BOOL g_fEventRaised; 55 | -------------------------------------------------------------------------------- /iiszlib/targetver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | // Including SDKDDKVer.h defines the highest available Windows platform. 7 | 8 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 9 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 10 | 11 | #include 12 | -------------------------------------------------------------------------------- /zlib/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /zlib/zlib.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Debug 8 | ARM64 9 | 10 | 11 | Debug 12 | ARM64EC 13 | 14 | 15 | Debug 16 | Win32 17 | 18 | 19 | Release 20 | ARM64 21 | 22 | 23 | Release 24 | ARM64EC 25 | 26 | 27 | Release 28 | Win32 29 | 30 | 31 | Debug 32 | x64 33 | 34 | 35 | Release 36 | x64 37 | 38 | 39 | 40 | {8D460A29-85AF-4884-A839-160862A94130} 41 | Win32Proj 42 | Lib 43 | 44 | 45 | 46 | StaticLibrary 47 | v143 48 | 49 | 50 | 51 | $(IIS-Common)Include;$(VC_IncludePath);$(WindowsSDK_IncludePath); 52 | 53 | 54 | 55 | NotUsing 56 | _CRT_SECURE_NO_WARNINGS;_LIB;%(PreprocessorDefinitions) 57 | stdafx.h 58 | stdafx.h 59 | stdafx.h 60 | stdafx.h 61 | stdafx.h 62 | stdafx.h 63 | stdafx.h 64 | stdafx.h 65 | false 66 | false 67 | false 68 | false 69 | 4996;%(DisableSpecificWarnings) 70 | 4996;%(DisableSpecificWarnings) 71 | 4996;%(DisableSpecificWarnings) 72 | 4996;%(DisableSpecificWarnings) 73 | 4996;%(DisableSpecificWarnings) 74 | 4996;%(DisableSpecificWarnings) 75 | 4996;%(DisableSpecificWarnings) 76 | 4996;%(DisableSpecificWarnings) 77 | 78 | 79 | Windows 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | This project is trying to import a missing file: {0}. 116 | 117 | 118 | 119 | 120 | --------------------------------------------------------------------------------