├── .github
└── workflows
│ └── build_and_test.yml
├── .gitignore
├── CHANGELOG.txt
├── COPYING.txt
├── README.md
├── VncSharpCore.sln
└── VncSharpCore
├── ConnectEventArgs.cs
├── EncodedRectangleFactory.cs
├── Encodings
├── CPixelReader.cs
├── CoRreRectangle.cs
├── CopyRectRectangle.cs
├── EncodedRectangle.cs
├── HextileRectangle.cs
├── PixelReader.cs
├── PixelReader16.cs
├── PixelReader32.cs
├── PixelReader8.cs
├── RawRectangle.cs
├── RreRectangle.cs
└── ZrleRectangle.cs
├── Framebuffer.cs
├── IDesktopUpdater.cs
├── IVncInputPolicy.cs
├── KeyboardHook.cs
├── NativeMethods.cs
├── PasswordDialog.cs
├── PasswordDialog.resx
├── Properties
├── Resources.Designer.cs
└── Resources.resx
├── RemoteDesktop.cs
├── RemoteDesktop.resx
├── Resources
├── screenshot.png
├── vnccursor.cur
└── vncviewer.ico
├── RfbProtocol.cs
├── VncClient.cs
├── VncClippedDesktopPolicy.cs
├── VncDefaultInputPolicy.cs
├── VncDesignModeDesktopPolicy.cs
├── VncDesktopTransformPolicy.cs
├── VncEventArgs.cs
├── VncProtocolException.cs
├── VncScaledDesktopPolicy.cs
├── VncSharpCore.csproj
├── VncSharpKey.snk
├── VncViewInputPolicy.cs
└── zlib.NET
├── Adler32.cs
├── Deflate.cs
├── InfBlocks.cs
├── InfCodes.cs
├── InfTree.cs
├── Inflate.cs
├── StaticTree.cs
├── SupportClass.cs
├── Tree.cs
├── ZInputStream.cs
├── ZOutputStream.cs
├── ZStream.cs
├── ZStreamException.cs
├── Zlib.cs
├── history.txt
├── license.txt
└── readme.txt
/.github/workflows/build_and_test.yml:
--------------------------------------------------------------------------------
1 | name: Build and Test
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: windows-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v2
16 | - name: Setup .NET
17 | uses: actions/setup-dotnet@v1
18 | with:
19 | dotnet-version: 6.0.x
20 | - name: Restore dependencies
21 | run: dotnet restore
22 | - name: Build
23 | run: dotnet build --no-restore
24 | - name: Test
25 | run: dotnet test --no-build --verbosity normal
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | ## Ignore Visual Studio temporary files, build results, and
33 | ## files generated by popular Visual Studio add-ons.
34 | ##
35 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
36 |
37 | # User-specific files
38 | *.suo
39 | *.user
40 | *.userosscache
41 | *.sln.docstates
42 |
43 | # User-specific files (MonoDevelop/Xamarin Studio)
44 | *.userprefs
45 |
46 | # Build results
47 | [Dd]ebug/
48 | [Dd]ebugPublic/
49 | [Rr]elease/
50 | [Rr]eleases/
51 | x64/
52 | x86/
53 | bld/
54 | [Bb]in/
55 | [Oo]bj/
56 | [Ll]og/
57 |
58 | # Visual Studio 2015/2017 cache/options directory
59 | .vs/
60 | # Uncomment if you have tasks that create the project's static files in wwwroot
61 | #wwwroot/
62 |
63 | # Visual Studio 2017 auto generated files
64 | Generated\ Files/
65 |
66 | # MSTest test Results
67 | [Tt]est[Rr]esult*/
68 | [Bb]uild[Ll]og.*
69 |
70 | # NUNIT
71 | *.VisualState.xml
72 | TestResult.xml
73 |
74 | # Build Results of an ATL Project
75 | [Dd]ebugPS/
76 | [Rr]eleasePS/
77 | dlldata.c
78 |
79 | # Benchmark Results
80 | BenchmarkDotNet.Artifacts/
81 |
82 | # .NET Core
83 | project.lock.json
84 | project.fragment.lock.json
85 | artifacts/
86 | **/Properties/launchSettings.json
87 |
88 | # StyleCop
89 | StyleCopReport.xml
90 |
91 | # Files built by Visual Studio
92 | *_i.c
93 | *_p.c
94 | *_i.h
95 | *.ilk
96 | *.meta
97 | *.obj
98 | *.iobj
99 | *.pch
100 | *.pdb
101 | *.ipdb
102 | *.pgc
103 | *.pgd
104 | *.rsp
105 | *.sbr
106 | *.tlb
107 | *.tli
108 | *.tlh
109 | *.tmp
110 | *.tmp_proj
111 | *.log
112 | *.vspscc
113 | *.vssscc
114 | .builds
115 | *.pidb
116 | *.svclog
117 | *.scc
118 |
119 | # Chutzpah Test files
120 | _Chutzpah*
121 |
122 | # Visual C++ cache files
123 | ipch/
124 | *.aps
125 | *.ncb
126 | *.opendb
127 | *.opensdf
128 | *.sdf
129 | *.cachefile
130 | *.VC.db
131 | *.VC.VC.opendb
132 |
133 | # Visual Studio profiler
134 | *.psess
135 | *.vsp
136 | *.vspx
137 | *.sap
138 |
139 | # Visual Studio Trace Files
140 | *.e2e
141 |
142 | # TFS 2012 Local Workspace
143 | $tf/
144 |
145 | # Guidance Automation Toolkit
146 | *.gpState
147 |
148 | # ReSharper is a .NET coding add-in
149 | _ReSharper*/
150 | *.[Rr]e[Ss]harper
151 | *.DotSettings.user
152 |
153 | # JustCode is a .NET coding add-in
154 | .JustCode
155 |
156 | # TeamCity is a build add-in
157 | _TeamCity*
158 |
159 | # DotCover is a Code Coverage Tool
160 | *.dotCover
161 |
162 | # AxoCover is a Code Coverage Tool
163 | .axoCover/*
164 | !.axoCover/settings.json
165 |
166 | # Visual Studio code coverage results
167 | *.coverage
168 | *.coveragexml
169 |
170 | # NCrunch
171 | _NCrunch_*
172 | .*crunch*.local.xml
173 | nCrunchTemp_*
174 |
175 | # MightyMoose
176 | *.mm.*
177 | AutoTest.Net/
178 |
179 | # Web workbench (sass)
180 | .sass-cache/
181 |
182 | # Installshield output folder
183 | [Ee]xpress/
184 |
185 | # DocProject is a documentation generator add-in
186 | DocProject/buildhelp/
187 | DocProject/Help/*.HxT
188 | DocProject/Help/*.HxC
189 | DocProject/Help/*.hhc
190 | DocProject/Help/*.hhk
191 | DocProject/Help/*.hhp
192 | DocProject/Help/Html2
193 | DocProject/Help/html
194 |
195 | # Click-Once directory
196 | publish/
197 |
198 | # Publish Web Output
199 | *.[Pp]ublish.xml
200 | *.azurePubxml
201 | # Note: Comment the next line if you want to checkin your web deploy settings,
202 | # but database connection strings (with potential passwords) will be unencrypted
203 | *.pubxml
204 | *.publishproj
205 |
206 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
207 | # checkin your Azure Web App publish settings, but sensitive information contained
208 | # in these scripts will be unencrypted
209 | PublishScripts/
210 |
211 | # NuGet Packages
212 | *.nupkg
213 | # The packages folder can be ignored because of Package Restore
214 | **/[Pp]ackages/*
215 | # except build/, which is used as an MSBuild target.
216 | !**/[Pp]ackages/build/
217 | # Uncomment if necessary however generally it will be regenerated when needed
218 | #!**/[Pp]ackages/repositories.config
219 | # NuGet v3's project.json files produces more ignorable files
220 | *.nuget.props
221 | *.nuget.targets
222 |
223 | # Microsoft Azure Build Output
224 | csx/
225 | *.build.csdef
226 |
227 | # Microsoft Azure Emulator
228 | ecf/
229 | rcf/
230 |
231 | # Windows Store app package directories and files
232 | AppPackages/
233 | BundleArtifacts/
234 | Package.StoreAssociation.xml
235 | _pkginfo.txt
236 | *.appx
237 |
238 | # Visual Studio cache files
239 | # files ending in .cache can be ignored
240 | *.[Cc]ache
241 | # but keep track of directories ending in .cache
242 | !*.[Cc]ache/
243 |
244 | # Others
245 | ClientBin/
246 | ~$*
247 | *~
248 | *.dbmdl
249 | *.dbproj.schemaview
250 | *.jfm
251 | *.pfx
252 | *.publishsettings
253 | orleans.codegen.cs
254 |
255 | # Including strong name files can present a security risk
256 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
257 | #*.snk
258 |
259 | # Since there are multiple workflows, uncomment next line to ignore bower_components
260 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
261 | #bower_components/
262 |
263 | # RIA/Silverlight projects
264 | Generated_Code/
265 |
266 | # Backup & report files from converting an old project file
267 | # to a newer Visual Studio version. Backup files are not needed,
268 | # because we have git ;-)
269 | _UpgradeReport_Files/
270 | Backup*/
271 | UpgradeLog*.XML
272 | UpgradeLog*.htm
273 | ServiceFabricBackup/
274 | *.rptproj.bak
275 |
276 | # SQL Server files
277 | *.mdf
278 | *.ldf
279 | *.ndf
280 |
281 | # Business Intelligence projects
282 | *.rdl.data
283 | *.bim.layout
284 | *.bim_*.settings
285 | *.rptproj.rsuser
286 |
287 | # Microsoft Fakes
288 | FakesAssemblies/
289 |
290 | # GhostDoc plugin setting file
291 | *.GhostDoc.xml
292 |
293 | # Node.js Tools for Visual Studio
294 | .ntvs_analysis.dat
295 | node_modules/
296 |
297 | # Visual Studio 6 build log
298 | *.plg
299 |
300 | # Visual Studio 6 workspace options file
301 | *.opt
302 |
303 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
304 | *.vbw
305 |
306 | # Visual Studio LightSwitch build output
307 | **/*.HTMLClient/GeneratedArtifacts
308 | **/*.DesktopClient/GeneratedArtifacts
309 | **/*.DesktopClient/ModelManifest.xml
310 | **/*.Server/GeneratedArtifacts
311 | **/*.Server/ModelManifest.xml
312 | _Pvt_Extensions
313 |
314 | # Paket dependency manager
315 | .paket/paket.exe
316 | paket-files/
317 |
318 | # FAKE - F# Make
319 | .fake/
320 |
321 | # JetBrains Rider
322 | .idea/
323 | *.sln.iml
324 |
325 | # CodeRush
326 | .cr/
327 |
328 | # Python Tools for Visual Studio (PTVS)
329 | __pycache__/
330 | *.pyc
331 |
332 | # Cake - Uncomment if you are using it
333 | # tools/**
334 | # !tools/packages.config
335 |
336 | # Tabs Studio
337 | *.tss
338 |
339 | # Telerik's JustMock configuration file
340 | *.jmconfig
341 |
342 | # BizTalk build output
343 | *.btp.cs
344 | *.btm.cs
345 | *.odx.cs
346 | *.xsd.cs
347 |
348 | # OpenCover UI analysis results
349 | OpenCover/
350 |
351 | # Azure Stream Analytics local run output
352 | ASALocalRun/
353 |
354 | # MSBuild Binary and Structured Log
355 | *.binlog
356 |
357 | # NVidia Nsight GPU debugger configuration file
358 | *.nvuser
359 |
360 | # MFractors (Xamarin productivity tool) working folder
361 | .mfractor/
362 |
363 |
364 | #############
365 | ## Windows detritus
366 | #############
367 |
368 | # Windows image file caches
369 | Thumbs.db
370 | ehthumbs.db
371 |
372 | # Folder config file
373 | Desktop.ini
374 |
375 | # Recycle Bin used on file shares
376 | $RECYCLE.BIN/
377 |
378 | # Mac crap
379 | .DS_Store
380 |
381 |
382 | #############
383 | ## Python
384 | #############
385 |
386 | *.py[co]
387 |
388 | # Packages
389 | *.egg
390 | *.egg-info
391 | dist/
392 | build/
393 | eggs/
394 | parts/
395 | var/
396 | sdist/
397 | develop-eggs/
398 | .installed.cfg
399 |
400 | # Installer logs
401 | pip-log.txt
402 |
403 | # Unit test / coverage reports
404 | .coverage
405 | .tox
406 |
407 | #Translations
408 | *.mo
409 |
410 | #Mr Developer
411 | .mr.developer.cfg
412 |
--------------------------------------------------------------------------------
/CHANGELOG.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1Remote/VncSharpCore/085a0eb224e2871c9c05a91ae4bcbea6c0e95f15/CHANGELOG.txt
--------------------------------------------------------------------------------
/COPYING.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Library General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VncSharpCoreCore
2 |
3 | VncSharpCore is a Free and Open Source (GPL) implementation of the VNC Remote Framebuffer (RFB) Protocol for the .NET Framework. [VNC] (Virtual Network Computing) is a cross-platform client/server protocol allowing remote systems to be controlled over a network. VNC was originally developed at A
4 | T&T Laboratories in Cambridge and is now being developed by RealVNC in the UK. You [can download] VNC clients and servers from RealVNC's website, or from a number of other parallel development projects.
5 |
6 | VncSharpCore is a VNC Client Library and custom Windows Forms Control. VncSharpCore is also Free Software, released under the GPL. You can freely use VncSharpCore to bundle VNC functionality into your own .NET6 applications simply by dragging and dropping a control onto your form.
7 |
8 | VncSharpCore was originally (https://github.com/humphd/VncSharpCore) written by David Humphrey (david.humphrey@senecac.on.ca) with contributions from many others (see CHANGELOG).
9 | As it is being used in mRemoteNG it still receives occasional updates when necessary.
10 |
--------------------------------------------------------------------------------
/VncSharpCore.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31919.166
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VncSharpCore", "VncSharpCore\VncSharpCore.csproj", "{E0695F0F-0FAF-44BC-AE55-A1FCBFE70271}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {E0695F0F-0FAF-44BC-AE55-A1FCBFE70271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {E0695F0F-0FAF-44BC-AE55-A1FCBFE70271}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {E0695F0F-0FAF-44BC-AE55-A1FCBFE70271}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {E0695F0F-0FAF-44BC-AE55-A1FCBFE70271}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {63809778-B119-4D94-BFB5-897D32FA17D4}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/VncSharpCore/ConnectEventArgs.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System;
19 |
20 | namespace VncSharpCore
21 | {
22 | ///
23 | /// Used in connection with the ConnectComplete event. Contains information about the remote desktop useful for setting-up the client's GUI.
24 | ///
25 | public class ConnectEventArgs : EventArgs
26 | {
27 | ///
28 | /// Constructor for ConnectEventArgs
29 | ///
30 | /// An Integer indicating the Width of the remote framebuffer.
31 | /// An Integer indicating the Height of the remote framebuffer.
32 | /// A String containing the name of the remote Desktop.
33 | public ConnectEventArgs(int width, int height, string name)
34 | {
35 | DesktopWidth = width;
36 | DesktopHeight = height;
37 | DesktopName = name;
38 | }
39 |
40 | ///
41 | /// Gets the Width of the remote Desktop.
42 | ///
43 | public int DesktopWidth { get; }
44 |
45 | ///
46 | /// Gets the Height of the remote Desktop.
47 | ///
48 | public int DesktopHeight { get; }
49 |
50 | ///
51 | /// Gets the name of the remote Desktop, if any.
52 | ///
53 | public string DesktopName { get; }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/VncSharpCore/EncodedRectangleFactory.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Diagnostics;
19 | using System.Drawing;
20 | using VncSharpCore.Encodings;
21 |
22 | namespace VncSharpCore
23 | {
24 | ///
25 | /// Factory class used to create derived EncodedRectangle objects at runtime based on data sent by VNC Server.
26 | ///
27 | public class EncodedRectangleFactory
28 | {
29 | private RfbProtocol rfb;
30 | private Framebuffer framebuffer;
31 |
32 | ///
33 | /// Creates an instance of the EncodedRectangleFactory using the connected RfbProtocol object and associated Framebuffer object.
34 | ///
35 | /// An RfbProtocol object that will be passed to any created EncodedRectangle objects. Must be non-null, already initialized, and connected.
36 | /// A Framebuffer object which will be used by any created EncodedRectangle objects in order to decode and draw rectangles locally.
37 | public EncodedRectangleFactory(RfbProtocol rfb, Framebuffer framebuffer)
38 | {
39 | Debug.Assert(rfb != null, "RfbProtocol object must be non-null");
40 | Debug.Assert(framebuffer != null, "Framebuffer object must be non-null");
41 |
42 | this.rfb = rfb;
43 | this.framebuffer = framebuffer;
44 | }
45 |
46 | ///
47 | /// Creates an object type derived from EncodedRectangle, based on the value of encoding.
48 | ///
49 | /// A Rectangle object defining the bounds of the rectangle to be created
50 | /// An Integer indicating the encoding type to be used for this rectangle. Used to determine the type of EncodedRectangle to create.
51 | ///
52 | public EncodedRectangle Build(Rectangle rectangle, int encoding)
53 | {
54 | EncodedRectangle e;
55 |
56 | switch (encoding) {
57 | case RfbProtocol.RAW_ENCODING:
58 | e = new RawRectangle(rfb, framebuffer, rectangle);
59 | break;
60 | case RfbProtocol.COPYRECT_ENCODING:
61 | e = new CopyRectRectangle(rfb, framebuffer, rectangle);
62 | break;
63 | case RfbProtocol.RRE_ENCODING:
64 | e = new RreRectangle(rfb, framebuffer, rectangle);
65 | break;
66 | case RfbProtocol.CORRE_ENCODING:
67 | e = new CoRreRectangle(rfb, framebuffer, rectangle);
68 | break;
69 | case RfbProtocol.HEXTILE_ENCODING:
70 | e = new HextileRectangle(rfb, framebuffer, rectangle);
71 | break;
72 | case RfbProtocol.ZRLE_ENCODING:
73 | e = new ZrleRectangle(rfb, framebuffer, rectangle);
74 | break;
75 | default:
76 | // Sanity check
77 | throw new VncProtocolException("Unsupported Encoding Format received: " + encoding + ".");
78 | }
79 | return e;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/CPixelReader.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.IO;
19 |
20 | namespace VncSharpCore.Encodings
21 | {
22 | ///
23 | /// A compressed PixelReader.
24 | ///
25 | public sealed class CPixelReader : PixelReader
26 | {
27 | public CPixelReader(BinaryReader reader, Framebuffer framebuffer) : base(reader, framebuffer)
28 | {
29 | }
30 |
31 | public override int ReadPixel()
32 | {
33 | var b = reader.ReadBytes(3);
34 | return ToGdiPlusOrder(b[2], b[1], b[0]);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/CoRreRectangle.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 |
20 | // FIXME: I can't understand why yet, but under the Xvnc server in Unix (v. 3.3.7), this doesn't work.
21 | // Everything is fine using the Windows server!?
22 |
23 | namespace VncSharpCore.Encodings
24 | {
25 | ///
26 | /// Implementation of CoRRE encoding, as well as drawing support. See RFB Protocol document v. 3.8 section 6.5.4.
27 | ///
28 | public sealed class CoRreRectangle : EncodedRectangle
29 | {
30 | public CoRreRectangle(RfbProtocol rfb, Framebuffer framebuffer, Rectangle rectangle) : base(rfb, framebuffer, rectangle, RfbProtocol.CORRE_ENCODING)
31 | {
32 | }
33 |
34 | ///
35 | /// Decodes a CoRRE Encoded Rectangle.
36 | ///
37 | public override void Decode()
38 | {
39 | var numSubRect = (int) rfb.ReadUint32(); // Number of sub-rectangles within this rectangle
40 | var bgPixelVal = preader.ReadPixel(); // Background colour
41 | var subRectVal = 0; // Colour to be used for each sub-rectangle
42 |
43 | // Dimensions of each sub-rectangle will be read into these
44 | int x, y, w, h;
45 |
46 | // Initialize the full pixel array to the background colour
47 | FillRectangle(rectangle, bgPixelVal);
48 |
49 | // Colour in all the subrectangles, reading the properties of each one after another.
50 | for (var i = 0; i < numSubRect; i++) {
51 | subRectVal = preader.ReadPixel();
52 | x = rfb.ReadByte();
53 | y = rfb.ReadByte();
54 | w = rfb.ReadByte();
55 | h = rfb.ReadByte();
56 |
57 | // Colour in this sub-rectangle with the colour provided.
58 | FillRectangle(new Rectangle(x, y, w, h), subRectVal);
59 | }
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/CopyRectRectangle.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 | using System.Drawing.Imaging;
20 |
21 | namespace VncSharpCore.Encodings
22 | {
23 | ///
24 | /// Implementation of CopyRect encoding, as well as drawing support. See RFB Protocol document v. 3.8 section 6.5.2.
25 | ///
26 | public sealed class CopyRectRectangle : EncodedRectangle
27 | {
28 | public CopyRectRectangle(RfbProtocol rfb, Framebuffer framebuffer, Rectangle rectangle)
29 | : base(rfb, framebuffer, rectangle, RfbProtocol.COPYRECT_ENCODING)
30 | {
31 | }
32 |
33 | // CopyRect Source Point (x,y) from which to copy pixels in Draw
34 | private Point source;
35 |
36 | ///
37 | /// Decodes a CopyRect encoded rectangle.
38 | ///
39 | public override void Decode()
40 | {
41 | // Read the source point from which to begin copying pixels
42 | source = new Point();
43 | source.X = rfb.ReadUInt16();
44 | source.Y = rfb.ReadUInt16();
45 | }
46 |
47 | public unsafe override void Draw(Bitmap desktop)
48 | {
49 | // Given a source area, copy this region to the point specified by destination
50 | var bmpd = desktop.LockBits(new Rectangle(new Point(0,0), desktop.Size),
51 | ImageLockMode.ReadWrite,
52 | desktop.PixelFormat);
53 |
54 |
55 | // Avoid exception if window is dragged bottom of screen
56 | if (rectangle.Top + rectangle.Height >= framebuffer.Height)
57 | {
58 | rectangle.Height = framebuffer.Height - rectangle.Top - 1;
59 | }
60 |
61 | try {
62 | var pSrc = (int*)(void*)bmpd.Scan0;
63 | var pDest = (int*)(void*)bmpd.Scan0;
64 |
65 | // Calculate the difference between the stride of the desktop, and the pixels we really copied.
66 | var nonCopiedPixelStride = desktop.Width - rectangle.Width;
67 |
68 | // Move source and destination pointers
69 | pSrc += source.Y * desktop.Width + source.X;
70 | pDest += rectangle.Y * desktop.Width + rectangle.X;
71 |
72 | // BUG FIX (Peter Wentworth) EPW: we need to guard against overwriting old pixels before
73 | // they've been moved, so we need to work out whether this slides pixels upwards in memeory,
74 | // or downwards, and run the loop backwards if necessary.
75 | if (pDest < pSrc) { // we can copy with pointers that increment
76 | for (var y = 0; y < rectangle.Height; ++y) {
77 | for (var x = 0; x < rectangle.Width; ++x) {
78 | *pDest++ = *pSrc++;
79 | }
80 |
81 | // Move pointers to beginning of next row in rectangle
82 | pSrc += nonCopiedPixelStride;
83 | pDest += nonCopiedPixelStride;
84 | }
85 | } else {
86 | // Move source and destination pointers to just beyond the furthest-from-origin
87 | // pixel to be copied.
88 | pSrc += rectangle.Height * desktop.Width + rectangle.Width;
89 | pDest += rectangle.Height * desktop.Width + rectangle.Width;
90 |
91 | for (var y = 0; y < rectangle.Height; ++y) {
92 | for (var x = 0; x < rectangle.Width; ++x) {
93 | *--pDest = *--pSrc;
94 | }
95 |
96 | // Move pointers to end of previous row in rectangle
97 | pSrc -= nonCopiedPixelStride;
98 | pDest -= nonCopiedPixelStride;
99 | }
100 | }
101 | } finally {
102 | desktop.UnlockBits(bmpd);
103 | bmpd = null;
104 | }
105 | }
106 | }
107 | }
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/EncodedRectangle.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System;
19 | using System.Drawing;
20 | using System.Drawing.Imaging;
21 |
22 | namespace VncSharpCore.Encodings
23 | {
24 | ///
25 | /// Abstract class representing an Encoded Rectangle to be read, decoded, and drawn.
26 | ///
27 | public abstract class EncodedRectangle : IDesktopUpdater
28 | {
29 | protected RfbProtocol rfb;
30 | protected Rectangle rectangle;
31 | protected Framebuffer framebuffer;
32 | protected PixelReader preader;
33 |
34 | public EncodedRectangle(RfbProtocol rfb, Framebuffer framebuffer, Rectangle rectangle, int encoding)
35 | {
36 | this.rfb = rfb;
37 | this.framebuffer = framebuffer;
38 | this.rectangle = rectangle;
39 |
40 | //Select appropriate reader
41 | var reader = encoding == RfbProtocol.ZRLE_ENCODING ? rfb.ZrleReader : rfb.Reader;
42 |
43 | // Create the appropriate PixelReader depending on screen size and encoding
44 | switch (framebuffer.BitsPerPixel)
45 | {
46 | case 32:
47 | if (encoding == RfbProtocol.ZRLE_ENCODING)
48 | {
49 | preader = new CPixelReader(reader, framebuffer);
50 | }
51 | else
52 | {
53 | preader = new PixelReader32(reader, framebuffer);
54 | }
55 | break;
56 | case 16:
57 | preader = new PixelReader16(reader, framebuffer);
58 | break;
59 | case 8:
60 | preader = new PixelReader8(reader, framebuffer, rfb);
61 | break;
62 | default:
63 | throw new ArgumentOutOfRangeException("BitsPerPixel", framebuffer.BitsPerPixel, "Valid VNC Pixel Widths are 8, 16 or 32 bits.");
64 | }
65 | }
66 |
67 | ///
68 | /// Gets the rectangle that needs to be decoded and drawn.
69 | ///
70 | public Rectangle UpdateRectangle {
71 | get {
72 | return rectangle;
73 | }
74 | }
75 |
76 | ///
77 | /// Obtain all necessary information from VNC Host (i.e., read) in order to Draw the rectangle, and store in colours[].
78 | ///
79 | public abstract void Decode();
80 |
81 | ///
82 | /// After calling Decode() an EncodedRectangle can be drawn to a Bitmap, which is the local representation of the remote desktop.
83 | ///
84 | /// The image the represents the remote desktop. NOTE: this image will be altered.
85 | public unsafe virtual void Draw(Bitmap desktop)
86 | {
87 | // Lock the bitmap's scan-lines in RAM so we can iterate over them using pointers and update the area
88 | // defined in rectangle.
89 | var bmpd = desktop.LockBits(new Rectangle(new Point(0,0), desktop.Size), ImageLockMode.ReadWrite, desktop.PixelFormat);
90 |
91 | try {
92 | // For speed I'm using pointers to manipulate the desktop bitmap, which is unsafe.
93 | // Get a pointer to the start of the bitmap in memory (IntPtr) and cast to a
94 | // Byte pointer (need void* first) so desktop can be traversed as GDI+
95 | // colour values form.
96 | var pInt = (int*)(void*)bmpd.Scan0;
97 |
98 | // Move pointer to position in desktop bitmap where rectangle begins
99 | pInt += rectangle.Y * desktop.Width + rectangle.X;
100 |
101 | var offset = desktop.Width - rectangle.Width;
102 | var row = 0;
103 |
104 | for (var y = 0; y < rectangle.Height; ++y) {
105 | row = y * rectangle.Width;
106 |
107 | for (var x = 0; x < rectangle.Width; ++x) {
108 | *pInt++ = framebuffer[row + x];
109 | }
110 |
111 | // Move pointer to beginning of next row in rectangle
112 | pInt += offset;
113 | }
114 | } finally {
115 | desktop.UnlockBits(bmpd);
116 | bmpd = null;
117 | }
118 | }
119 |
120 | ///
121 | /// Fills the given Rectangle with a solid colour (i.e., all pixels will have the same value--colour).
122 | ///
123 | /// The rectangle to be filled.
124 | /// The colour to use when filling the rectangle.
125 | protected void FillRectangle(Rectangle rect, int colour)
126 | {
127 | var ptr = 0;
128 | var offset = 0;
129 |
130 | // If the two rectangles don't match, then rect is contained within rectangle, and
131 | // ptr and offset need to be adjusted to position things at the proper starting point.
132 | if (rect != rectangle) {
133 | ptr = rect.Y * rectangle.Width + rect.X; // move to the start of the rectangle in pixels
134 | offset = rectangle.Width - rect.Width; // calculate the offset to get to the start of the next row
135 | }
136 |
137 | for (var y = 0; y < rect.Height; ++y) {
138 | for (var x = 0; x < rect.Width; ++x) {
139 | framebuffer[ptr++] = colour; // colour every pixel the same
140 | }
141 | ptr += offset; // advance to next row within pixels
142 | }
143 | }
144 |
145 | protected void FillRectangle(Rectangle rect, int[] tile)
146 | {
147 | var ptr = 0;
148 | var offset = 0;
149 |
150 | // If the two rectangles don't match, then rect is contained within rectangle, and
151 | // ptr and offset need to be adjusted to position things at the proper starting point.
152 | if (rect != rectangle) {
153 | ptr = rect.Y * rectangle.Width + rect.X; // move to the start of the rectangle in pixels
154 | offset = rectangle.Width - rect.Width; // calculate the offset to get to the start of the next row
155 | }
156 |
157 | var idx = 0;
158 | for (var y = 0; y < rect.Height; ++y) {
159 | for (var x = 0; x < rect.Width; ++x) {
160 | framebuffer[ptr++] = tile[idx++];
161 | }
162 | ptr += offset; // advance to next row within pixels
163 | }
164 | }
165 |
166 | ///
167 | /// Fills the given Rectangle with pixel values read from the server (i.e., each pixel may have its own value).
168 | ///
169 | /// The rectangle to be filled.
170 | protected void FillRectangle(Rectangle rect)
171 | {
172 | var ptr = 0;
173 | var offset = 0;
174 |
175 | // If the two rectangles don't match, then rect is contained within rectangle, and
176 | // ptr and offset need to be adjusted to position things at the proper starting point.
177 | if (rect != rectangle) {
178 | ptr = rect.Y * rectangle.Width + rect.X; // move to the start of the rectangle in pixels
179 | offset = rectangle.Width - rect.Width; // calculate the offset to get to the start of the next row
180 | }
181 |
182 | for (var y = 0; y < rect.Height; ++y) {
183 | for (var x = 0; x < rect.Width; ++x) {
184 | framebuffer[ptr++] = preader.ReadPixel(); // every pixel needs to be read from server
185 | }
186 | ptr += offset; // advance to next row within pixels
187 | }
188 | }
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/HextileRectangle.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 |
20 | namespace VncSharpCore.Encodings
21 | {
22 | ///
23 | /// Implementation of Hextile encoding, as well as drawing support. See RFB Protocol document v. 3.8 section 6.5.5.
24 | ///
25 | public sealed class HextileRectangle : EncodedRectangle
26 | {
27 | private const int RAW = 0x01;
28 | private const int BACKGROUND_SPECIFIED = 0x02;
29 | private const int FOREGROUND_SPECIFIED = 0x04;
30 | private const int ANY_SUBRECTS = 0x08;
31 | private const int SUBRECTS_COLOURED = 0x10;
32 |
33 | public HextileRectangle(RfbProtocol rfb, Framebuffer framebuffer, Rectangle rectangle)
34 | : base(rfb, framebuffer, rectangle, RfbProtocol.HEXTILE_ENCODING)
35 | {
36 | }
37 |
38 | public override void Decode()
39 | {
40 | // Subrectangle co-ordinates and info
41 | int sx;
42 | int sy;
43 | int sw;
44 | int sh;
45 | var numSubrects = 0;
46 | int xANDy;
47 | int widthANDheight;
48 |
49 | // Colour values to be used--black by default.
50 | var backgroundPixelValue = 0;
51 | var foregroundPixelValue = 0;
52 |
53 | // NOTE: the way that this is set-up, a Rectangle can be anywhere within the bounds
54 | // of the framebuffer (i.e., its x and y may not be (0,0)). However, I ignore this
55 | // since the pixels for the tiles and subrectangles are all relative to this rectangle.
56 | // When the rectangle is drawn to the desktop later, its (x,y) position will become
57 | // significant again. All of this to say that in the two main loops below, ty=0 and
58 | // tx=0, and all calculations are based on a (0,0) origin.
59 | for (var ty = 0; ty < rectangle.Height; ty += 16) {
60 | // Tiles in the last row will often be less than 16 pixels high.
61 | // All others will be 16 high.
62 | var th = rectangle.Height - ty < 16 ? rectangle.Height - ty : 16;
63 |
64 | for (var tx = 0; tx < rectangle.Width; tx += 16) {
65 | // Tiles in the list column will often be less than 16 pixels wide.
66 | // All others will be 16 wide.
67 | var tw = rectangle.Width - tx < 16 ? rectangle.Width - tx : 16;
68 |
69 | var tlStart = ty * rectangle.Width + tx;
70 | var tlOffset = rectangle.Width - tw;
71 |
72 | var subencoding = rfb.ReadByte();
73 |
74 | // See if Raw bit is set in subencoding, and if so, ignore all other bits
75 | if ((subencoding & RAW) != 0) {
76 | FillRectangle(new Rectangle(tx, ty, tw, th));
77 | } else {
78 | if ((subencoding & BACKGROUND_SPECIFIED) != 0) {
79 | backgroundPixelValue = preader.ReadPixel();
80 | }
81 |
82 | // Fill-in background colour
83 | FillRectangle(new Rectangle(tx, ty, tw, th), backgroundPixelValue);
84 |
85 | if ((subencoding & FOREGROUND_SPECIFIED) != 0) {
86 | foregroundPixelValue = preader.ReadPixel();
87 | }
88 |
89 | if ((subencoding & ANY_SUBRECTS) != 0) {
90 | // Get the number of sub-rectangles in this tile
91 | numSubrects = rfb.ReadByte();
92 |
93 | for (var i = 0; i < numSubrects; i++) {
94 | if ((subencoding & SUBRECTS_COLOURED) != 0) {
95 | foregroundPixelValue = preader.ReadPixel(); // colour of this sub rectangle
96 | }
97 |
98 | xANDy = rfb.ReadByte(); // X-position (4 bits) and Y-Postion (4 bits) of this sub rectangle in the tile
99 | widthANDheight = rfb.ReadByte(); // Width (4 bits) and Height (4 bits) of this sub rectangle
100 |
101 | // Get the proper x, y, w, and h values out of xANDy and widthANDheight
102 | sx = (xANDy >> 4) & 0xf;
103 | sy = xANDy & 0xf;
104 | sw = ((widthANDheight >> 4) & 0xf) + 1; // have to add 1 to get width
105 | sh = (widthANDheight & 0xf) + 1; // same for height.
106 |
107 | FillRectangle(new Rectangle(tx + sx, ty + sy, sw, sh), foregroundPixelValue);
108 | }
109 | }
110 | }
111 | }
112 | }
113 | }
114 | }
115 | }
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/PixelReader.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.IO;
19 |
20 | namespace VncSharpCore.Encodings
21 | {
22 | ///
23 | /// Used to read the appropriate number of bytes from the server based on the
24 | /// width of pixels and convert to a GDI+ colour value (i.e., BGRA).
25 | ///
26 | public abstract class PixelReader
27 | {
28 | protected BinaryReader reader;
29 | protected Framebuffer framebuffer;
30 |
31 | protected PixelReader(BinaryReader reader, Framebuffer framebuffer)
32 | {
33 | this.reader = reader;
34 | this.framebuffer = framebuffer;
35 | }
36 |
37 | public abstract int ReadPixel();
38 |
39 | protected int ToGdiPlusOrder(byte red, byte green, byte blue)
40 | {
41 | // Put colour values into proper order for GDI+ (i.e., BGRA, where Alpha is always 0xFF)
42 | return blue & 0xFF | green << 8 | red << 16 | 0xFF << 24;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/PixelReader16.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.IO;
19 |
20 | namespace VncSharpCore.Encodings
21 | {
22 | ///
23 | /// A 16-bit PixelReader.
24 | ///
25 | public sealed class PixelReader16 : PixelReader
26 | {
27 | public PixelReader16(BinaryReader reader, Framebuffer framebuffer) : base(reader, framebuffer)
28 | {
29 | }
30 |
31 | public override int ReadPixel()
32 | {
33 | var b = reader.ReadBytes(2);
34 |
35 | var pixel = (ushort)((uint)b[0] & 0xFF | (uint)b[1] << 8);
36 |
37 | var red = (byte)(((pixel >> framebuffer.RedShift) & framebuffer.RedMax) * 255 / framebuffer.RedMax);
38 | var green = (byte)(((pixel >> framebuffer.GreenShift) & framebuffer.GreenMax) * 255 / framebuffer.GreenMax);
39 | var blue = (byte)(((pixel >> framebuffer.BlueShift) & framebuffer.BlueMax) * 255 / framebuffer.BlueMax);
40 |
41 | return ToGdiPlusOrder(red, green, blue);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/PixelReader32.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.IO;
19 |
20 | namespace VncSharpCore.Encodings
21 | {
22 | ///
23 | /// A 32-bit PixelReader.
24 | ///
25 | public sealed class PixelReader32 : PixelReader
26 | {
27 | public PixelReader32(BinaryReader reader, Framebuffer framebuffer) : base(reader, framebuffer)
28 | {
29 | }
30 |
31 | public override int ReadPixel()
32 | {
33 | // Read the pixel value
34 | var b = reader.ReadBytes(4);
35 |
36 | var pixel = (uint)b[0] & 0xFF |
37 | (uint)b[1] << 8 |
38 | (uint)b[2] << 16 |
39 | (uint)b[3] << 24;
40 |
41 | // Extract RGB intensities from pixel
42 | var red = (byte) ((pixel >> framebuffer.RedShift) & framebuffer.RedMax);
43 | var green = (byte) ((pixel >> framebuffer.GreenShift) & framebuffer.GreenMax);
44 | var blue = (byte) ((pixel >> framebuffer.BlueShift) & framebuffer.BlueMax);
45 |
46 | return ToGdiPlusOrder(red, green, blue);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/PixelReader8.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.IO;
19 |
20 | namespace VncSharpCore.Encodings
21 | {
22 | ///
23 | /// An 8-bit PixelReader
24 | ///
25 | public sealed class PixelReader8 : PixelReader
26 | {
27 | private RfbProtocol rfb;
28 |
29 | public PixelReader8(BinaryReader reader, Framebuffer framebuffer, RfbProtocol rfb) : base(reader, framebuffer)
30 | {
31 | this.rfb = rfb;
32 | }
33 |
34 | ///
35 | /// Reads an 8-bit pixel.
36 | ///
37 | /// Returns an Integer value representing the pixel in GDI+ format.
38 | public override int ReadPixel()
39 | {
40 | var idx = reader.ReadByte();
41 | return ToGdiPlusOrder((byte)rfb.MapEntries[idx, 0], (byte)rfb.MapEntries[idx, 1], (byte)rfb.MapEntries[idx, 2]);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/RawRectangle.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 |
20 | namespace VncSharpCore.Encodings
21 | {
22 | ///
23 | /// Implementation of Raw encoding, as well as drawing support. See RFB Protocol document v. 3.8 section 6.5.1.
24 | ///
25 | public sealed class RawRectangle : EncodedRectangle
26 | {
27 | public RawRectangle(RfbProtocol rfb, Framebuffer framebuffer, Rectangle rectangle)
28 | : base(rfb, framebuffer, rectangle, RfbProtocol.RAW_ENCODING)
29 | {
30 | }
31 |
32 | public override void Decode()
33 | {
34 | // Each pixel from the remote server represents a pixel to be drawn
35 | for (var i = 0; i < rectangle.Width * rectangle.Height; ++i) {
36 | framebuffer[i] = preader.ReadPixel();
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/RreRectangle.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 |
20 | namespace VncSharpCore.Encodings
21 | {
22 | ///
23 | /// Implementation of RRE encoding, as well as drawing support. See RFB Protocol document v. 3.8 section 6.5.3.
24 | ///
25 | public sealed class RreRectangle : EncodedRectangle
26 | {
27 | public RreRectangle(RfbProtocol rfb, Framebuffer framebuffer, Rectangle rectangle)
28 | : base(rfb, framebuffer, rectangle, RfbProtocol.RRE_ENCODING)
29 | {
30 | }
31 |
32 | public override void Decode()
33 | {
34 | var numSubRect = (int) rfb.ReadUint32(); // Number of sub-rectangles within this rectangle
35 | var bgPixelVal = preader.ReadPixel(); // Background colour
36 | var subRectVal = 0; // Colour to be used for each sub-rectangle
37 |
38 | // Dimensions of each sub-rectangle will be read into these
39 | int x, y, w, h;
40 |
41 | // Initialize the full pixel array to the background colour
42 | FillRectangle(rectangle, bgPixelVal);
43 |
44 | // Colour in all the subrectangles, reading the properties of each one after another.
45 | for (var i = 0; i < numSubRect; i++) {
46 | subRectVal = preader.ReadPixel();
47 | x = rfb.ReadUInt16();
48 | y = rfb.ReadUInt16();
49 | w = rfb.ReadUInt16();
50 | h = rfb.ReadUInt16();
51 |
52 | // Colour in this sub-rectangle
53 | FillRectangle(new Rectangle(x, y, w, h), subRectVal);
54 | }
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/VncSharpCore/Encodings/ZrleRectangle.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System;
19 | using System.Drawing;
20 |
21 | namespace VncSharpCore.Encodings
22 | {
23 | ///
24 | /// Implementation of ZRLE encoding, as well as drawing support. See RFB Protocol document v. 3.8 section 6.6.5.
25 | ///
26 | public sealed class ZrleRectangle : EncodedRectangle
27 | {
28 | private const int TILE_WIDTH = 64;
29 | private const int TILE_HEIGHT = 64;
30 |
31 | private readonly int[] palette = new int[128];
32 | private readonly int[] tileBuffer = new int[TILE_WIDTH * TILE_HEIGHT];
33 |
34 | public ZrleRectangle(RfbProtocol rfb, Framebuffer framebuffer, Rectangle rectangle)
35 | : base(rfb, framebuffer, rectangle, RfbProtocol.ZRLE_ENCODING)
36 | {
37 | }
38 |
39 | public override void Decode()
40 | {
41 | rfb.ZrleReader.DecodeStream();
42 |
43 | for (var ty = 0; ty < rectangle.Height; ty += TILE_HEIGHT) {
44 | var th = Math.Min(rectangle.Height - ty, TILE_HEIGHT);
45 |
46 | for (var tx = 0; tx < rectangle.Width; tx += TILE_WIDTH) {
47 | var tw = Math.Min(rectangle.Width - tx, TILE_WIDTH);
48 |
49 | var subencoding = rfb.ZrleReader.ReadByte();
50 |
51 | if (subencoding >= 17 && subencoding <= 127 || subencoding == 129)
52 | throw new Exception("Invalid subencoding value");
53 |
54 | var isRLE = (subencoding & 128) != 0;
55 | var paletteSize = subencoding & 127;
56 |
57 | // Fill palette
58 | for (var i = 0; i < paletteSize; i++)
59 | palette[i] = preader.ReadPixel();
60 |
61 | if (paletteSize == 1) {
62 | // Solid tile
63 | FillRectangle(new Rectangle(tx, ty, tw, th), palette[0]);
64 | continue;
65 | }
66 |
67 | if (!isRLE) {
68 | if (paletteSize == 0) {
69 | // Raw pixel data
70 | FillRectangle(new Rectangle(tx, ty, tw, th));
71 | } else {
72 | // Packed palette
73 | ReadZrlePackedPixels(tw, th, palette, paletteSize, tileBuffer);
74 | FillRectangle(new Rectangle(tx, ty, tw, th), tileBuffer);
75 | }
76 | } else {
77 | if (paletteSize == 0) {
78 | // Plain RLE
79 | ReadZrlePlainRLEPixels(tw, th, tileBuffer);
80 | FillRectangle(new Rectangle(tx, ty, tw, th), tileBuffer);
81 | } else {
82 | // Packed RLE palette
83 | ReadZrlePackedRLEPixels(tx, ty, tw, th, palette, tileBuffer);
84 | FillRectangle(new Rectangle(tx, ty, tw, th), tileBuffer);
85 | }
86 | }
87 | }
88 | }
89 | }
90 |
91 | private void ReadZrlePackedPixels(int tw, int th, int[] palette, int palSize, int[] tile)
92 | {
93 | var bppp = palSize > 16 ? 8 :
94 | (palSize > 4 ? 4 : (palSize > 2 ? 2 : 1));
95 | var ptr = 0;
96 |
97 | for (var i = 0; i < th; i++) {
98 | var eol = ptr + tw;
99 | var b = 0;
100 | var nbits = 0;
101 |
102 | while (ptr < eol) {
103 | if (nbits == 0) {
104 | b = rfb.ZrleReader.ReadByte();
105 | nbits = 8;
106 | }
107 | nbits -= bppp;
108 | var index = (b >> nbits) & ((1 << bppp) - 1) & 127;
109 | tile[ptr++] = palette[index];
110 | }
111 | }
112 | }
113 |
114 | private void ReadZrlePlainRLEPixels(int tw, int th, int[] tileBuffer)
115 | {
116 | var ptr = 0;
117 | var end = ptr + tw * th;
118 | while (ptr < end) {
119 | var pix = preader.ReadPixel();
120 | var len = 1;
121 | int b;
122 | do {
123 | b = rfb.ZrleReader.ReadByte();
124 | len += b;
125 | } while (b == byte.MaxValue);
126 |
127 | while (len-- > 0) tileBuffer[ptr++] = pix;
128 | }
129 | }
130 |
131 | private void ReadZrlePackedRLEPixels(int tx, int ty, int tw, int th, int[] palette, int[] tile)
132 | {
133 | var ptr = 0;
134 | var end = ptr + tw * th;
135 | while (ptr < end) {
136 | int index = rfb.ZrleReader.ReadByte();
137 | var len = 1;
138 | if ((index & 128) != 0) {
139 | int b;
140 | do {
141 | b = rfb.ZrleReader.ReadByte();
142 | len += b;
143 | } while (b == byte.MaxValue);
144 | }
145 |
146 | index &= 127;
147 |
148 | while (len-- > 0) tile[ptr++] = palette[index];
149 | }
150 | }
151 | }
152 | }
--------------------------------------------------------------------------------
/VncSharpCore/Framebuffer.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System;
19 | using System.Drawing;
20 |
21 | // ReSharper disable ArrangeAccessorOwnerBody
22 |
23 | namespace VncSharpCore
24 | {
25 | ///
26 | /// Properties of a VNC Framebuffer, and its Pixel Format.
27 | ///
28 | public class Framebuffer
29 | {
30 | private string name;
31 |
32 | private readonly int[] pixels; // I'm reusing the same pixel buffer for all update rectangles.
33 | // Pixel values will always be 32-bits to match GDI representation
34 |
35 |
36 | ///
37 | /// Creates a new Framebuffer with (width x height) pixels.
38 | ///
39 | /// The width in pixels of the remote desktop.
40 | /// The height in pixels of the remote desktop.
41 | private Framebuffer(int width, int height)
42 | {
43 | Width = width;
44 | Height = height;
45 |
46 | // Cache the total size of the pixel array and initialize
47 | // The total number of pixels (w x h) assigned in SetSize()
48 | var pixelCount = width * height;
49 | pixels = new int[pixelCount];
50 | }
51 |
52 | ///
53 | /// An indexer to allow access to the internal pixel buffer.
54 | ///
55 | public int this[int index] {
56 | get {
57 | return pixels[index];
58 | }
59 | set {
60 | pixels[index] = value;
61 | }
62 | }
63 |
64 | ///
65 | /// The Width of the Framebuffer, measured in Pixels.
66 | ///
67 | public int Width { get; }
68 |
69 | ///
70 | /// The Height of the Framebuffer, measured in Pixels.
71 | ///
72 | public int Height { get; }
73 |
74 | ///
75 | /// Gets a Rectangle object constructed out of the Width and Height for the Framebuffer. Used as a convenience in other classes.
76 | ///
77 | public Rectangle Rectangle
78 | {
79 | get { return new Rectangle(0, 0, Width, Height); }
80 | }
81 |
82 | ///
83 | /// The number of Bits Per Pixel for the Framebuffer--one of 8, 16, or 32.
84 | ///
85 | public int BitsPerPixel { get; private set; }
86 |
87 | ///
88 | /// The Colour Depth of the Framebuffer.
89 | ///
90 | private int Depth { get; set; }
91 |
92 | ///
93 | /// Indicates whether the remote host uses Big- or Little-Endian order when sending multi-byte values.
94 | ///
95 | private bool BigEndian { get; set; }
96 |
97 | ///
98 | /// Indicates whether the remote host supports True Colour.
99 | ///
100 | private bool TrueColour { get; set; }
101 |
102 | ///
103 | /// The maximum value for Red in a pixel's colour value.
104 | ///
105 | public int RedMax { get; private set; }
106 |
107 | ///
108 | /// The maximum value for Green in a pixel's colour value.
109 | ///
110 | public int GreenMax { get; private set; }
111 |
112 | ///
113 | /// The maximum value for Blue in a pixel's colour value.
114 | ///
115 | public int BlueMax { get; private set; }
116 |
117 | ///
118 | /// The number of bits to shift pixel values in order to obtain Red values.
119 | ///
120 | public int RedShift { get; private set; }
121 |
122 | ///
123 | /// The number of bits to shift pixel values in order to obtain Green values.
124 | ///
125 | public int GreenShift { get; private set; }
126 |
127 | ///
128 | /// The number of bits to shift pixel values in order to obtain Blue values.
129 | ///
130 | public int BlueShift { get; private set; }
131 |
132 | ///
133 | /// The name of the remote destkop, if any. Must be non-null.
134 | ///
135 | /// Thrown if a null string is used when setting DesktopName.
136 | public string DesktopName {
137 | get {
138 | return name;
139 | }
140 | set {
141 | if (value == null)
142 | throw new ArgumentNullException($"DesktopName");
143 | name = value;
144 | }
145 | }
146 |
147 | ///
148 | /// When communicating with the VNC Server, bytes are used to represent many of the values above. However, internally it is easier to use Integers. This method provides a translation between the two worlds.
149 | ///
150 | /// A byte array of 16 bytes containing the properties of the framebuffer in a format ready for transmission to the VNC server.
151 | public byte[] ToPixelFormat()
152 | {
153 | var b = new byte[16];
154 |
155 | b[0] = (byte) BitsPerPixel;
156 | b[1] = (byte) Depth;
157 | b[2] = (byte) (BigEndian ? 1 : 0);
158 | b[3] = (byte) (TrueColour ? 1 : 0);
159 | b[4] = (byte) ((RedMax >> 8) & 0xff);
160 | b[5] = (byte) (RedMax & 0xff);
161 | b[6] = (byte) ((GreenMax >> 8) & 0xff);
162 | b[7] = (byte) (GreenMax & 0xff);
163 | b[8] = (byte) ((BlueMax >> 8) & 0xff);
164 | b[9] = (byte) (BlueMax & 0xff);
165 | b[10] = (byte) RedShift;
166 | b[11] = (byte) GreenShift;
167 | b[12] = (byte) BlueShift;
168 | // plus 3 bytes padding = 16 bytes
169 |
170 | return b;
171 | }
172 |
173 | ///
174 | /// Given the dimensions and 16-byte PIXEL_FORMAT record from the VNC Host, deserialize this into a Framebuffer object.
175 | ///
176 | /// The 16-byte PIXEL_FORMAT record.
177 | /// The width in pixels of the remote desktop.
178 | /// The height in pixles of the remote desktop.
179 | /// The number of Bits Per Pixel for the Framebuffer--one of 8, 16, or 32.
180 | /// The Colour Depth of the Framebuffer--one of 3, 6, 8 or 16.
181 | /// Returns a Framebuffer object matching the specification of b[].
182 | public static Framebuffer FromPixelFormat(byte[] b, int width, int height, int bitsPerPixel, int depth)
183 | {
184 | if (b.Length != 16)
185 | throw new ArgumentException("Length of b must be 16 bytes.");
186 |
187 | var buffer = new Framebuffer(width, height);
188 |
189 | if ((bitsPerPixel == 16) && (depth == 16))
190 | {
191 | buffer.BitsPerPixel = 16;
192 | buffer.Depth = 16;
193 | buffer.BigEndian = b[2] != 0;
194 | buffer.TrueColour = false;
195 | buffer.RedMax = 31;
196 | buffer.GreenMax = 63;
197 | buffer.BlueMax = 31;
198 | buffer.RedShift = 11;
199 | buffer.GreenShift = 5;
200 | buffer.BlueShift = 0;
201 | }
202 | else if ((bitsPerPixel) == 16 && (depth == 8))
203 | {
204 | buffer.BitsPerPixel = 16;
205 | buffer.Depth = 8;
206 | buffer.BigEndian = b[2] != 0;
207 | buffer.TrueColour = false;
208 | buffer.RedMax = 31;
209 | buffer.GreenMax = 63;
210 | buffer.BlueMax = 31;
211 | buffer.RedShift = 11;
212 | buffer.GreenShift = 5;
213 | buffer.BlueShift = 0;
214 | }
215 | else if ((bitsPerPixel) == 8 && (depth == 8))
216 | {
217 | buffer.BitsPerPixel = 8;
218 | buffer.BigEndian = b[2] != 0;
219 | buffer.TrueColour = false;
220 | buffer.Depth = 8;
221 | buffer.RedMax = 7;
222 | buffer.GreenMax = 7;
223 | buffer.BlueMax = 3;
224 | buffer.RedShift = 0;
225 | buffer.GreenShift = 3;
226 | buffer.BlueShift = 6;
227 | }
228 | else if ((bitsPerPixel) == 8 && (depth == 6))
229 | {
230 | buffer.BitsPerPixel = 8;
231 | buffer.Depth = 6;
232 | buffer.BigEndian = b[2] != 0;
233 | buffer.TrueColour = false;
234 | buffer.RedMax = 3;
235 | buffer.GreenMax = 3;
236 | buffer.BlueMax = 3;
237 | buffer.RedShift = 4;
238 | buffer.GreenShift = 2;
239 | buffer.BlueShift = 0;
240 | }
241 | else if ((bitsPerPixel == 8) && (depth == 3))
242 | {
243 | buffer.BitsPerPixel = 8;
244 | buffer.Depth = 3;
245 | buffer.BigEndian = b[2] != 0;
246 | buffer.TrueColour = false;
247 | buffer.RedMax = 1;
248 | buffer.GreenMax = 1;
249 | buffer.BlueMax = 1;
250 | buffer.RedShift = 2;
251 | buffer.GreenShift = 1;
252 | buffer.BlueShift = 0;
253 | }
254 | else
255 | {
256 | buffer.BitsPerPixel = b[0];
257 | buffer.Depth = b[1];
258 | buffer.BigEndian = b[2] != 0;
259 | buffer.TrueColour = b[3] != 0;
260 | buffer.RedMax = b[5] | b[4] << 8;
261 | buffer.GreenMax = b[7] | b[6] << 8;
262 | buffer.BlueMax = b[9] | b[8] << 8;
263 | buffer.RedShift = b[10];
264 | buffer.GreenShift = b[11];
265 | buffer.BlueShift = b[12];
266 | }
267 |
268 | // Last 3 bytes are padding, ignore
269 |
270 | return buffer;
271 | }
272 | }
273 | }
274 |
--------------------------------------------------------------------------------
/VncSharpCore/IDesktopUpdater.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 |
20 | namespace VncSharpCore
21 | {
22 | ///
23 | /// Classes that implement IDesktopUpdater are used to update and Draw on a local Bitmap representation of the remote desktop.
24 | ///
25 | public interface IDesktopUpdater
26 | {
27 | ///
28 | /// Given a desktop Bitmap that is a local representation of the remote desktop, updates sent by the server are drawn into the area specifed by UpdateRectangle.
29 | ///
30 | /// The desktop Bitmap on which updates should be drawn.
31 | void Draw(Bitmap desktop);
32 |
33 | ///
34 | /// The region of the desktop Bitmap that needs to be re-drawn.
35 | ///
36 | Rectangle UpdateRectangle {
37 | get;
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/VncSharpCore/IVncInputPolicy.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 |
20 | namespace VncSharpCore
21 | {
22 | ///
23 | /// A strategy encapsulating mouse/keyboard input. Used by VncClient.
24 | ///
25 | public interface IVncInputPolicy
26 | {
27 | void WriteKeyboardEvent(uint keysym, bool pressed);
28 |
29 | void WritePointerEvent(byte buttonMask, Point point);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/VncSharpCore/KeyboardHook.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Based on code from Stephen Toub's MSDN blog at
3 | * http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx
4 | *
5 | * Originally written by https://github.com/rmcardle for https://github.com/mRemoteNG/VncSharpNG
6 | * Additional fixes and porting to (upstream) https://github.com/humphd/VncSharp by https://github.com/kmscode
7 | */
8 |
9 | using System;
10 | using System.Collections.Generic;
11 | using System.ComponentModel;
12 | using System.Diagnostics;
13 | using System.Runtime.InteropServices;
14 |
15 | namespace VncSharpCore
16 | {
17 | public class KeyboardHook
18 | {
19 | // ReSharper disable InconsistentNaming
20 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
21 | [return: MarshalAs(UnmanagedType.Bool)]
22 | private static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, HookKeyMsgData lParam);
23 | // ReSharper restore InconsistentNaming
24 |
25 | [Flags]
26 | public enum ModifierKeys
27 | {
28 | None = 0x0000,
29 | Shift = 0x0001,
30 | LeftShift = 0x002,
31 | RightShift = 0x004,
32 | Control = 0x0008,
33 | LeftControl = 0x010,
34 | RightControl = 0x20,
35 | Alt = 0x0040,
36 | LeftAlt = 0x0080,
37 | RightAlt = 0x0100,
38 | Win = 0x0200,
39 | LeftWin = 0x0400,
40 | RightWin = 0x0800
41 | }
42 |
43 | protected class KeyNotificationEntry: IEquatable
44 | {
45 | public IntPtr WindowHandle;
46 | public int KeyCode;
47 | public ModifierKeys ModifierKeys;
48 | public bool Block;
49 |
50 | public bool Equals(KeyNotificationEntry obj)
51 | {
52 | return obj != null && WindowHandle == obj.WindowHandle && KeyCode == obj.KeyCode && ModifierKeys == obj.ModifierKeys && Block == obj.Block;
53 | }
54 | }
55 |
56 | private const string HookKeyMsgName = "HOOKKEYMSG-{EC4E5587-8F3A-4A56-A00B-2A5F827ABA79}";
57 | private static uint _hookKeyMsg;
58 | public static uint HookKeyMsg
59 | {
60 | get
61 | {
62 | if (_hookKeyMsg != 0) return _hookKeyMsg;
63 | _hookKeyMsg = NativeMethods.RegisterWindowMessage(HookKeyMsgName);
64 | if (_hookKeyMsg == 0)
65 | throw new Win32Exception(Marshal.GetLastWin32Error());
66 | return _hookKeyMsg;
67 | }
68 | }
69 |
70 | // this is a custom structure that will be passed to
71 | // the requested hWnd via a WM_APP_HOOKKEYMSG message
72 | [StructLayout(LayoutKind.Sequential)]
73 | public class HookKeyMsgData
74 | {
75 | public int KeyCode;
76 | public ModifierKeys ModifierKeys;
77 | public bool WasBlocked;
78 | }
79 |
80 | private static int _referenceCount;
81 | private static IntPtr _hook;
82 | private static readonly NativeMethods.LowLevelKeyboardProcDelegate LowLevelKeyboardProcStaticDelegate = LowLevelKeyboardProc;
83 | private static readonly List NotificationEntries = new List();
84 |
85 | public KeyboardHook()
86 | {
87 | _referenceCount++;
88 | SetHook();
89 | }
90 |
91 | ~KeyboardHook()
92 | {
93 | _referenceCount--;
94 | if (_referenceCount < 1) UnsetHook();
95 | }
96 |
97 | private static void SetHook()
98 | {
99 | if (_hook != IntPtr.Zero) return;
100 |
101 | var curProcess = Process.GetCurrentProcess();
102 | var curModule = curProcess.MainModule;
103 |
104 | var hook = NativeMethods.SetWindowsHookEx(NativeMethods.WH_KEYBOARD_LL, LowLevelKeyboardProcStaticDelegate, NativeMethods.GetModuleHandle(curModule.ModuleName), 0);
105 | if (hook == IntPtr.Zero)
106 | throw new Win32Exception(Marshal.GetLastWin32Error());
107 |
108 | _hook = hook;
109 | }
110 |
111 | private static void UnsetHook()
112 | {
113 | if (_hook == IntPtr.Zero) return;
114 |
115 | NativeMethods.UnhookWindowsHookEx(_hook);
116 | _hook = IntPtr.Zero;
117 | }
118 |
119 | private static IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, NativeMethods.KBDLLHOOKSTRUCT lParam)
120 | {
121 | var wParamInt = wParam.ToInt32();
122 | var result = 0;
123 |
124 | if (nCode != NativeMethods.HC_ACTION)
125 | return result != 0 ? new IntPtr(result) : NativeMethods.CallNextHookEx(_hook, nCode, wParam, lParam);
126 | // ReSharper disable once SwitchStatementMissingSomeCases
127 | switch (wParamInt)
128 | {
129 | case NativeMethods.WM_KEYDOWN:
130 | case NativeMethods.WM_SYSKEYDOWN:
131 | case NativeMethods.WM_KEYUP:
132 | case NativeMethods.WM_SYSKEYUP:
133 | result = OnKey(wParamInt, lParam);
134 | break;
135 | }
136 |
137 | return result != 0 ? new IntPtr(result) : NativeMethods.CallNextHookEx(_hook, nCode, wParam, lParam);
138 | }
139 |
140 | private static int OnKey(int msg, NativeMethods.KBDLLHOOKSTRUCT key)
141 | {
142 | var result = 0;
143 |
144 | foreach (var notificationEntry in NotificationEntries)
145 | // It error code is Null, have to ignore the exception
146 | // For some unknow raison, sometime GetFocuseWindows throw an exception
147 | // Mainly when the station is unlocked, or after an admin password is asked
148 | try
149 | {
150 | if (GetFocusWindow() != notificationEntry.WindowHandle || notificationEntry.KeyCode != key.vkCode)
151 | continue;
152 | var modifierKeys = GetModifierKeyState();
153 | if (!ModifierKeysMatch(notificationEntry.ModifierKeys, modifierKeys)) continue;
154 |
155 | var wParam = new IntPtr(msg);
156 | var lParam = new HookKeyMsgData
157 | {
158 | KeyCode = key.vkCode,
159 | ModifierKeys = modifierKeys,
160 | WasBlocked = notificationEntry.Block
161 | };
162 |
163 | if (!PostMessage(notificationEntry.WindowHandle, HookKeyMsg, wParam, lParam))
164 | throw new Win32Exception(Marshal.GetLastWin32Error());
165 |
166 | if (notificationEntry.Block) result = 1;
167 | }
168 | catch (Win32Exception e)
169 | {
170 | if (e.NativeErrorCode != 0)
171 | {
172 | throw;
173 | }
174 | }
175 |
176 | return result;
177 | }
178 |
179 | private static IntPtr GetFocusWindow()
180 | {
181 | var guiThreadInfo = new NativeMethods.GUITHREADINFO();
182 | if (NativeMethods.GetGUIThreadInfo(0, guiThreadInfo))
183 | return NativeMethods.GetAncestor(guiThreadInfo.hwndFocus, NativeMethods.GA_ROOT);
184 | var except = Marshal.GetLastWin32Error();
185 | throw new Win32Exception(except);
186 | }
187 |
188 | private static readonly Dictionary ModifierKeyTable = new Dictionary
189 | {
190 | { NativeMethods.VK_SHIFT, ModifierKeys.Shift },
191 | { NativeMethods.VK_LSHIFT, ModifierKeys.LeftShift },
192 | { NativeMethods.VK_RSHIFT, ModifierKeys.RightShift },
193 | { NativeMethods.VK_CONTROL, ModifierKeys.Control },
194 | { NativeMethods.VK_LCONTROL, ModifierKeys.LeftControl },
195 | { NativeMethods.VK_RCONTROL, ModifierKeys.RightControl },
196 | { NativeMethods.VK_MENU, ModifierKeys.Alt },
197 | { NativeMethods.VK_LMENU, ModifierKeys.LeftAlt },
198 | { NativeMethods.VK_RMENU, ModifierKeys.RightAlt },
199 | { NativeMethods.VK_LWIN, ModifierKeys.LeftWin },
200 | { NativeMethods.VK_RWIN, ModifierKeys.RightWin }
201 | };
202 |
203 | public static ModifierKeys GetModifierKeyState()
204 | {
205 | var modifierKeyState = ModifierKeys.None;
206 |
207 | foreach (var pair in ModifierKeyTable)
208 | {
209 | if ((NativeMethods.GetAsyncKeyState(pair.Key) & NativeMethods.KEYSTATE_PRESSED) != 0) modifierKeyState |= pair.Value;
210 | }
211 |
212 | if ((modifierKeyState & ModifierKeys.LeftWin) != 0) modifierKeyState |= ModifierKeys.Win;
213 | if ((modifierKeyState & ModifierKeys.RightWin) != 0) modifierKeyState |= ModifierKeys.Win;
214 |
215 | return modifierKeyState;
216 | }
217 |
218 | private static bool ModifierKeysMatch(ModifierKeys requestedKeys, ModifierKeys pressedKeys)
219 | {
220 | if ((requestedKeys & ModifierKeys.Shift) != 0) pressedKeys &= ~(ModifierKeys.LeftShift | ModifierKeys.RightShift);
221 | if ((requestedKeys & ModifierKeys.Control) != 0) pressedKeys &= ~(ModifierKeys.LeftControl | ModifierKeys.RightControl);
222 | if ((requestedKeys & ModifierKeys.Alt) != 0) pressedKeys &= ~(ModifierKeys.LeftAlt | ModifierKeys.RightAlt);
223 | if ((requestedKeys & ModifierKeys.Win) != 0) pressedKeys &= ~(ModifierKeys.LeftWin | ModifierKeys.RightWin);
224 | return requestedKeys == pressedKeys;
225 | }
226 |
227 | public static void RequestKeyNotification(IntPtr windowHandle, int keyCode, bool block)
228 | {
229 | RequestKeyNotification(windowHandle, keyCode, ModifierKeys.None, block);
230 | }
231 |
232 | public static void RequestKeyNotification(IntPtr windowHandle, int keyCode, ModifierKeys modifierKeys = ModifierKeys.None, bool block = false)
233 | {
234 | var newNotificationEntry = new KeyNotificationEntry
235 | {
236 | WindowHandle = windowHandle,
237 | KeyCode = keyCode,
238 | ModifierKeys = modifierKeys,
239 | Block = block
240 | };
241 |
242 | foreach (var notificationEntry in NotificationEntries)
243 | if (notificationEntry == newNotificationEntry) return;
244 |
245 | NotificationEntries.Add(newNotificationEntry);
246 | }
247 |
248 | public static void CancelKeyNotification(IntPtr windowHandle, int keyCode, bool block)
249 | {
250 | CancelKeyNotification(windowHandle, keyCode, ModifierKeys.None, block);
251 | }
252 |
253 | private static void CancelKeyNotification(IntPtr windowHandle, int keyCode, ModifierKeys modifierKeys = ModifierKeys.None, bool block = false)
254 | {
255 | var notificationEntry = new KeyNotificationEntry
256 | {
257 | WindowHandle = windowHandle,
258 | KeyCode = keyCode,
259 | ModifierKeys = modifierKeys,
260 | Block = block
261 | };
262 |
263 | NotificationEntries.Remove(notificationEntry);
264 | }
265 | }
266 | }
267 |
--------------------------------------------------------------------------------
/VncSharpCore/NativeMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace VncSharpCore
5 | {
6 | public static class NativeMethods
7 | {
8 | #region Functions
9 |
10 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
11 | internal static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProcDelegate lpfn, IntPtr hMod, int dwThreadId);
12 |
13 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
14 | [return: MarshalAs(UnmanagedType.Bool)]
15 | internal static extern bool UnhookWindowsHookEx(IntPtr hhk);
16 |
17 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
18 | internal static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, KBDLLHOOKSTRUCT lParam);
19 |
20 | [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
21 | internal static extern IntPtr GetModuleHandle(string lpModuleName);
22 |
23 | [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
24 | internal static extern uint RegisterWindowMessage(string lpString);
25 |
26 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
27 | [return: MarshalAs(UnmanagedType.Bool)]
28 | internal static extern bool PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
29 |
30 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
31 | [return: MarshalAs(UnmanagedType.Bool)]
32 | internal static extern bool GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui);
33 |
34 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
35 | internal static extern short GetAsyncKeyState(int vKey);
36 |
37 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
38 | [return: MarshalAs(UnmanagedType.Bool)]
39 | internal static extern bool GetKeyboardState(byte[] lpKeyState);
40 |
41 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
42 | internal static extern int MapVirtualKey(int uCode, int uMapType);
43 |
44 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
45 | internal static extern int ToAscii(int uVirtKey, int uScanCode, byte[] lpKeyState, byte[] lpwTransKey, int fuState);
46 |
47 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
48 | internal static extern IntPtr GetAncestor(IntPtr hwnd, uint gaFlags);
49 |
50 | #endregion
51 |
52 | #region Delegates
53 |
54 | public delegate IntPtr LowLevelKeyboardProcDelegate(int nCode, IntPtr wParam, KBDLLHOOKSTRUCT lParam);
55 |
56 | #endregion
57 |
58 | #region Structures
59 |
60 | [StructLayout(LayoutKind.Sequential)]
61 | public class KBDLLHOOKSTRUCT
62 | {
63 | internal int vkCode;
64 | internal int scanCode;
65 | internal int flags;
66 | internal int time;
67 | internal IntPtr dwExtraInfo;
68 | }
69 |
70 | [StructLayout(LayoutKind.Sequential)]
71 | public struct RECT
72 | {
73 | internal int left;
74 | internal int top;
75 | internal int right;
76 | internal int bottom;
77 | }
78 |
79 | [StructLayout(LayoutKind.Sequential)]
80 | public class GUITHREADINFO
81 | {
82 | public GUITHREADINFO()
83 | {
84 | cbSize = Convert.ToInt32(Marshal.SizeOf(this));
85 | }
86 |
87 | internal int cbSize;
88 | internal int flags;
89 | internal IntPtr hwndActive;
90 | internal IntPtr hwndFocus;
91 | internal IntPtr hwndCapture;
92 | internal IntPtr hwndMenuOwner;
93 | internal IntPtr hwndMoveSize;
94 | internal IntPtr hwndCaret;
95 | internal RECT rcCaret;
96 | }
97 |
98 | #endregion
99 |
100 | #region Constants
101 | // GetAncestor
102 | public const int GA_ROOT = 2;
103 |
104 | // SetWindowsHookEx
105 | public const int WH_KEYBOARD_LL = 13;
106 |
107 | // LowLevelKeyboardProcDelegate
108 | public const int HC_ACTION = 0;
109 |
110 | // SendMessage
111 | public const int WM_KEYDOWN = 0x0100;
112 | public const int WM_KEYUP = 0x0101;
113 | public const int WM_SYSKEYDOWN = 0x0104;
114 | public const int WM_SYSKEYUP = 0x0105;
115 |
116 | // GetAsyncKeyState
117 | public const int KEYSTATE_PRESSED = 0x8000;
118 |
119 | #region Virtual Keys
120 | public const int VK_CANCEL = 0x0003;
121 | public const int VK_BACK = 0x0008;
122 | public const int VK_TAB = 0x0009;
123 | public const int VK_CLEAR = 0x000C;
124 | public const int VK_RETURN = 0x000D;
125 | public const int VK_PAUSE = 0x0013;
126 | public const int VK_ESCAPE = 0x001B;
127 | public const int VK_SNAPSHOT = 0x002C;
128 | public const int VK_INSERT = 0x002D;
129 | public const int VK_DELETE = 0x002E;
130 | public const int VK_HOME = 0x0024;
131 | public const int VK_END = 0x0023;
132 | public const int VK_PRIOR = 0x0021;
133 | public const int VK_NEXT = 0x0022;
134 | public const int VK_LEFT = 0x0025;
135 | public const int VK_UP = 0x0026;
136 | public const int VK_RIGHT = 0x0027;
137 | public const int VK_DOWN = 0x0028;
138 | public const int VK_SELECT = 0x0029;
139 | public const int VK_PRINT = 0x002A;
140 | public const int VK_EXECUTE = 0x002B;
141 | public const int VK_HELP = 0x002F;
142 | public const int VK_LWIN = 0x005B;
143 | public const int VK_RWIN = 0x005C;
144 | public const int VK_APPS = 0x005D;
145 | public const int VK_F1 = 0x0070;
146 | public const int VK_F2 = 0x0071;
147 | public const int VK_F3 = 0x0072;
148 | public const int VK_F4 = 0x0073;
149 | public const int VK_F5 = 0x0074;
150 | public const int VK_F6 = 0x0075;
151 | public const int VK_F7 = 0x0076;
152 | public const int VK_F8 = 0x0077;
153 | public const int VK_F9 = 0x0078;
154 | public const int VK_F10 = 0x0079;
155 | public const int VK_F11 = 0x007A;
156 | public const int VK_F12 = 0x007B;
157 | public const int VK_SHIFT = 0x0010;
158 | public const int VK_LSHIFT = 0x00A0;
159 | public const int VK_RSHIFT = 0x00A1;
160 | public const int VK_CONTROL = 0x0011;
161 | public const int VK_LCONTROL = 0x00A2;
162 | public const int VK_RCONTROL = 0x00A3;
163 | public const int VK_MENU = 0x0012;
164 | public const int VK_LMENU = 0x00A4;
165 | public const int VK_RMENU = 0x00A5;
166 |
167 | public const int VK_OEM_1 = 0x00BA;
168 | public const int VK_OEM_2 = 0x00BF;
169 | public const int VK_OEM_3 = 0x00C0;
170 | public const int VK_OEM_4 = 0x00DB;
171 | public const int VK_OEM_5 = 0x00DC;
172 | public const int VK_OEM_6 = 0x00DD;
173 | public const int VK_OEM_7 = 0x00DE;
174 | public const int VK_OEM_8 = 0x00DF;
175 | public const int VK_OEM_102 = 0x00E2;
176 |
177 | #endregion
178 |
179 | #endregion
180 |
181 | // ReSharper restore InconsistentNaming
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/VncSharpCore/PasswordDialog.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.ComponentModel;
19 | using System.Windows.Forms;
20 |
21 | // ReSharper disable ArrangeAccessorOwnerBody
22 |
23 | namespace VncSharpCore
24 | {
25 | ///
26 | /// A simple GUI Form for obtaining a user's password. More elaborate interfaces could be used, but this is the default.
27 | ///
28 | public class PasswordDialog : Form
29 | {
30 | private Button btnOk;
31 | private Button btnCancel;
32 | private TextBox txtPassword;
33 |
34 | private Container components = null;
35 |
36 | private PasswordDialog()
37 | {
38 | InitializeComponent();
39 | }
40 |
41 | ///
42 | /// Gets the Password entered by the user.
43 | ///
44 | public string Password
45 | {
46 | get { return txtPassword.Text; }
47 | }
48 |
49 | protected override void Dispose( bool disposing )
50 | {
51 | if( disposing )
52 | {
53 | components?.Dispose();
54 | }
55 | base.Dispose( disposing );
56 | }
57 |
58 | #region Windows Form Designer generated code
59 | ///
60 | /// Required method for Designer support - do not modify
61 | /// the contents of this method with the code editor.
62 | ///
63 | private void InitializeComponent()
64 | {
65 | this.btnOk = new System.Windows.Forms.Button();
66 | this.btnCancel = new System.Windows.Forms.Button();
67 | this.txtPassword = new System.Windows.Forms.TextBox();
68 | this.SuspendLayout();
69 | //
70 | // btnOk
71 | //
72 | this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
73 | this.btnOk.Location = new System.Drawing.Point(144, 8);
74 | this.btnOk.Name = "btnOk";
75 | this.btnOk.Size = new System.Drawing.Size(64, 23);
76 | this.btnOk.TabIndex = 1;
77 | this.btnOk.Text = "OK";
78 | //
79 | // btnCancel
80 | //
81 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
82 | this.btnCancel.Location = new System.Drawing.Point(144, 40);
83 | this.btnCancel.Name = "btnCancel";
84 | this.btnCancel.Size = new System.Drawing.Size(64, 23);
85 | this.btnCancel.TabIndex = 2;
86 | this.btnCancel.Text = "Cancel";
87 | //
88 | // txtPassword
89 | //
90 | this.txtPassword.Location = new System.Drawing.Point(16, 16);
91 | this.txtPassword.Name = "txtPassword";
92 | this.txtPassword.PasswordChar = '*';
93 | this.txtPassword.Size = new System.Drawing.Size(112, 20);
94 | this.txtPassword.TabIndex = 0;
95 | this.txtPassword.Text = "";
96 | //
97 | // ConnectionPassword
98 | //
99 | this.AcceptButton = this.btnOk;
100 | this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
101 | this.CancelButton = this.btnCancel;
102 | this.ClientSize = new System.Drawing.Size(216, 73);
103 | this.Controls.AddRange(new System.Windows.Forms.Control[] {
104 | this.txtPassword,
105 | this.btnCancel,
106 | this.btnOk});
107 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
108 | this.MaximizeBox = false;
109 | this.MinimizeBox = false;
110 | this.Name = "ConnectionPassword";
111 | this.ShowInTaskbar = false;
112 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
113 | this.Text = "Password";
114 | this.ResumeLayout(false);
115 |
116 | }
117 | #endregion
118 |
119 | ///
120 | /// Creates an instance of PasswordDialog and uses it to obtain the user's password.
121 | ///
122 | /// Returns the user's password as entered, or null if he/she clicked Cancel.
123 | public static string GetPassword()
124 | {
125 | using(var dialog = new PasswordDialog())
126 | {
127 | // If the user clicks Cancel, return null and not the empty string.
128 | return dialog.ShowDialog() == DialogResult.OK ? dialog.Password : null;
129 | }
130 | }
131 | }
132 | }
--------------------------------------------------------------------------------
/VncSharpCore/PasswordDialog.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
89 |
90 |
91 | 1.3
92 |
93 |
94 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
95 |
96 |
97 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
98 |
99 |
100 | ConnectionPassword
101 |
102 |
--------------------------------------------------------------------------------
/VncSharpCore/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion:4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7 | // der Code erneut generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace VncSharpCore.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
17 | ///
18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
19 | // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
21 | // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VncSharpCore.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
51 | /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
65 | ///
66 | internal static System.Drawing.Icon vncviewer {
67 | get {
68 | object obj = ResourceManager.GetObject("vncviewer", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/VncSharpCore/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\vncviewer.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
--------------------------------------------------------------------------------
/VncSharpCore/RemoteDesktop.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
89 |
90 |
91 | 1.3
92 |
93 |
94 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
95 |
96 |
97 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
98 |
99 |
100 | RemoteDesktop
101 |
102 |
103 | False
104 |
105 |
--------------------------------------------------------------------------------
/VncSharpCore/Resources/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1Remote/VncSharpCore/085a0eb224e2871c9c05a91ae4bcbea6c0e95f15/VncSharpCore/Resources/screenshot.png
--------------------------------------------------------------------------------
/VncSharpCore/Resources/vnccursor.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1Remote/VncSharpCore/085a0eb224e2871c9c05a91ae4bcbea6c0e95f15/VncSharpCore/Resources/vnccursor.cur
--------------------------------------------------------------------------------
/VncSharpCore/Resources/vncviewer.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1Remote/VncSharpCore/085a0eb224e2871c9c05a91ae4bcbea6c0e95f15/VncSharpCore/Resources/vncviewer.ico
--------------------------------------------------------------------------------
/VncSharpCore/VncClient.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1Remote/VncSharpCore/085a0eb224e2871c9c05a91ae4bcbea6c0e95f15/VncSharpCore/VncClient.cs
--------------------------------------------------------------------------------
/VncSharpCore/VncClippedDesktopPolicy.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 |
20 | // ReSharper disable ArrangeAccessorOwnerBody
21 |
22 | namespace VncSharpCore
23 | {
24 | ///
25 | /// A clipped version of VncDesktopTransformPolicy.
26 | ///
27 | public sealed class VncClippedDesktopPolicy : VncDesktopTransformPolicy
28 | {
29 | public VncClippedDesktopPolicy(VncClient vnc,
30 | RemoteDesktop remoteDesktop)
31 | : base(vnc, remoteDesktop)
32 | {
33 | }
34 |
35 | public override bool AutoScroll
36 | {
37 | get { return true; }
38 | }
39 |
40 | public override Size AutoScrollMinSize
41 | {
42 | get
43 | {
44 | return vnc?.Framebuffer != null
45 | ? new Size(vnc.Framebuffer.Width, vnc.Framebuffer.Height)
46 | : new Size(100, 100);
47 | }
48 | }
49 |
50 | public override Point UpdateRemotePointer(Point current)
51 | {
52 | var adjusted = new Point();
53 | if (remoteDesktop.ClientSize.Width > remoteDesktop.Desktop.Size.Width) {
54 | adjusted.X = current.X - (remoteDesktop.ClientRectangle.Width - remoteDesktop.Desktop.Width) / 2;
55 | } else {
56 | adjusted.X = current.X - remoteDesktop.AutoScrollPosition.X;
57 | }
58 |
59 | if (remoteDesktop.ClientSize.Height > remoteDesktop.Desktop.Size.Height ) {
60 | adjusted.Y = current.Y - (remoteDesktop.ClientRectangle.Height - remoteDesktop.Desktop.Height) / 2;
61 | } else {
62 | adjusted.Y = current.Y - remoteDesktop.AutoScrollPosition.Y;
63 | }
64 |
65 | return adjusted;
66 | }
67 |
68 | public override Rectangle AdjustUpdateRectangle(Rectangle updateRectangle)
69 | {
70 | int x, y;
71 |
72 | if (remoteDesktop.ClientSize.Width > remoteDesktop.Desktop.Size.Width) {
73 | x = updateRectangle.X + (remoteDesktop.ClientRectangle.Width - remoteDesktop.Desktop.Width) / 2;
74 | } else {
75 | x = updateRectangle.X + remoteDesktop.AutoScrollPosition.X;
76 | }
77 |
78 | if (remoteDesktop.ClientSize.Height > remoteDesktop.Desktop.Size.Height ) {
79 | y = updateRectangle.Y + (remoteDesktop.ClientRectangle.Height - remoteDesktop.Desktop.Height) / 2;
80 | } else {
81 | y = updateRectangle.Y + remoteDesktop.AutoScrollPosition.Y;
82 | }
83 |
84 | return new Rectangle(x, y, updateRectangle.Width, updateRectangle.Height);
85 | }
86 |
87 | public override Rectangle RepositionImage(Image desktopImage)
88 | {
89 | // See if the image needs to be clipped (i.e., it is too big for the
90 | // available space) or centered (i.e., it is too small)
91 | int x, y;
92 |
93 | if (remoteDesktop.ClientSize.Width > desktopImage.Width) {
94 | x = (remoteDesktop.ClientRectangle.Width - desktopImage.Width) / 2;
95 | } else {
96 | x = remoteDesktop.DisplayRectangle.X;
97 | }
98 |
99 | if (remoteDesktop.ClientSize.Height > desktopImage.Height ) {
100 | y = (remoteDesktop.ClientRectangle.Height - desktopImage.Height) / 2;
101 | } else {
102 | y = remoteDesktop.DisplayRectangle.Y;
103 | }
104 |
105 | return new Rectangle(x, y, desktopImage.Width, desktopImage.Height);
106 | }
107 |
108 | public override Rectangle GetMouseMoveRectangle()
109 | {
110 | var desktopRect = vnc.Framebuffer.Rectangle;
111 |
112 | if (remoteDesktop.ClientSize.Width > remoteDesktop.Desktop.Size.Width) {
113 | desktopRect.X = (remoteDesktop.ClientRectangle.Width - remoteDesktop.Desktop.Width) / 2;
114 | }
115 |
116 | if (remoteDesktop.ClientSize.Height > remoteDesktop.Desktop.Size.Height) {
117 | desktopRect.Y = (remoteDesktop.ClientRectangle.Height - remoteDesktop.Desktop.Height) / 2;
118 | }
119 |
120 | return desktopRect;
121 | }
122 |
123 | public override Point GetMouseMovePoint(Point current)
124 | {
125 | return current;
126 | }
127 | }
128 | }
--------------------------------------------------------------------------------
/VncSharpCore/VncDefaultInputPolicy.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Diagnostics;
19 | using System.Drawing;
20 |
21 | namespace VncSharpCore
22 | {
23 | ///
24 | /// An interaction enabled version of IVncInputPolicy.
25 | ///
26 | public sealed class VncDefaultInputPolicy : IVncInputPolicy
27 | {
28 | private RfbProtocol rfb;
29 |
30 | public VncDefaultInputPolicy(RfbProtocol rfb)
31 | {
32 | Debug.Assert(rfb != null);
33 | this.rfb = rfb;
34 | }
35 |
36 | // Let all exceptions get caught in VncClient
37 |
38 | public void WriteKeyboardEvent(uint keysym, bool pressed)
39 | {
40 | rfb.WriteKeyEvent(keysym, pressed);
41 | }
42 |
43 | public void WritePointerEvent(byte buttonMask, Point point)
44 | {
45 | rfb.WritePointerEvent(buttonMask, point);
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/VncSharpCore/VncDesignModeDesktopPolicy.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System;
19 | using System.Drawing;
20 |
21 | // ReSharper disable ArrangeAccessorOwnerBody
22 |
23 | namespace VncSharpCore
24 | {
25 | ///
26 | /// A Design Mode version of VncDesktopTransformPolicy.
27 | ///
28 | public sealed class VncDesignModeDesktopPolicy : VncDesktopTransformPolicy
29 | {
30 | public VncDesignModeDesktopPolicy(RemoteDesktop remoteDesktop)
31 | : base(null, remoteDesktop)
32 | {
33 | }
34 |
35 | public override bool AutoScroll
36 | {
37 | get { return true; }
38 | }
39 |
40 | public override Size AutoScrollMinSize
41 | {
42 | get { return new Size(608, 427); }
43 | }
44 |
45 | public override Point UpdateRemotePointer(Point current)
46 | {
47 | throw new NotImplementedException();
48 | }
49 |
50 | public override Rectangle AdjustUpdateRectangle(Rectangle updateRectangle)
51 | {
52 | throw new NotImplementedException();
53 | }
54 |
55 | public override Rectangle RepositionImage(Image desktopImage)
56 | {
57 | // See if the image needs to be clipped (i.e., it is too big for the
58 | // available space) or centered (i.e., it is too small)
59 | int x, y;
60 |
61 | if (remoteDesktop.ClientSize.Width > desktopImage.Width) {
62 | x = (remoteDesktop.ClientRectangle.Width - desktopImage.Width) / 2;
63 | } else {
64 | x = remoteDesktop.DisplayRectangle.X;
65 | }
66 |
67 | if (remoteDesktop.ClientSize.Height > desktopImage.Height ) {
68 | y = (remoteDesktop.ClientRectangle.Height - desktopImage.Height) / 2;
69 | } else {
70 | y = remoteDesktop.DisplayRectangle.Y;
71 | }
72 |
73 | return new Rectangle(x, y, remoteDesktop.ClientSize.Width, remoteDesktop.ClientSize.Height);
74 | }
75 |
76 | public override Rectangle GetMouseMoveRectangle()
77 | {
78 | throw new NotImplementedException();
79 | }
80 |
81 | public override Point GetMouseMovePoint(Point current)
82 | {
83 | throw new NotImplementedException();
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/VncSharpCore/VncDesktopTransformPolicy.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Drawing;
19 |
20 | // ReSharper disable ArrangeAccessorOwnerBody
21 |
22 | namespace VncSharpCore
23 | {
24 | ///
25 | /// Base class for desktop clipping/scaling policies. Used by RemoteDesktop.
26 | ///
27 | public abstract class VncDesktopTransformPolicy
28 | {
29 | protected VncClient vnc;
30 | protected RemoteDesktop remoteDesktop;
31 |
32 | public VncDesktopTransformPolicy(VncClient vnc,
33 | RemoteDesktop remoteDesktop)
34 | {
35 | this.vnc = vnc;
36 | this.remoteDesktop = remoteDesktop;
37 | }
38 |
39 | public virtual bool AutoScroll
40 | {
41 | get { return false; }
42 | }
43 |
44 | public abstract Size AutoScrollMinSize { get; }
45 |
46 | public abstract Rectangle AdjustUpdateRectangle(Rectangle updateRectangle);
47 |
48 | public abstract Rectangle RepositionImage(Image desktopImage);
49 |
50 | public abstract Rectangle GetMouseMoveRectangle();
51 |
52 | public abstract Point GetMouseMovePoint(Point current);
53 |
54 | public abstract Point UpdateRemotePointer(Point current);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/VncSharpCore/VncEventArgs.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System;
19 |
20 | namespace VncSharpCore
21 | {
22 | public class VncEventArgs : EventArgs
23 | {
24 | public VncEventArgs(IDesktopUpdater updater)
25 | {
26 | DesktopUpdater = updater;
27 | }
28 |
29 | ///
30 | /// Gets the IDesktopUpdater object that will handling re-drawing the desktop.
31 | ///
32 | public IDesktopUpdater DesktopUpdater { get; }
33 | }
34 | }
--------------------------------------------------------------------------------
/VncSharpCore/VncProtocolException.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System;
19 | using System.Runtime.Serialization;
20 |
21 | namespace VncSharpCore
22 | {
23 | public class VncProtocolException : ApplicationException
24 | {
25 | public VncProtocolException()
26 | {
27 | }
28 |
29 | public VncProtocolException(string message) : base(message)
30 | {
31 | }
32 |
33 | public VncProtocolException(string message, Exception inner) : base(message, inner)
34 | {
35 | }
36 |
37 | public VncProtocolException(SerializationInfo info, StreamingContext cxt) : base(info, cxt)
38 | {
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/VncSharpCore/VncScaledDesktopPolicy.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System;
19 | using System.Drawing;
20 |
21 | // ReSharper disable ArrangeAccessorOwnerBody
22 |
23 | namespace VncSharpCore
24 | {
25 | ///
26 | /// A scaled version of VncDesktopTransformPolicy.
27 | ///
28 | public sealed class VncScaledDesktopPolicy : VncDesktopTransformPolicy
29 | {
30 | public VncScaledDesktopPolicy(VncClient vnc, RemoteDesktop remoteDesktop)
31 | : base(vnc, remoteDesktop)
32 | {
33 | }
34 |
35 | public override Size AutoScrollMinSize
36 | {
37 | get { return new Size(100, 100); }
38 | }
39 |
40 | public override Rectangle AdjustUpdateRectangle(Rectangle updateRectangle)
41 | {
42 | var scaledSize = GetScaledSize(remoteDesktop.ClientRectangle.Size);
43 | var adjusted = new Rectangle(AdjusteNormalToScaled(updateRectangle.X) + (remoteDesktop.ClientRectangle.Width - scaledSize.Width) / 2,
44 | AdjusteNormalToScaled(updateRectangle.Y) + (remoteDesktop.ClientRectangle.Height - scaledSize.Height) / 2,
45 | AdjusteNormalToScaled(updateRectangle.Width),
46 | AdjusteNormalToScaled(updateRectangle.Height));
47 | adjusted.Inflate(1, 1);
48 | return adjusted;
49 | }
50 |
51 | public override Rectangle RepositionImage(Image desktopImage)
52 | {
53 | return GetScaledRectangle(remoteDesktop.ClientRectangle);
54 | }
55 |
56 | public override Point UpdateRemotePointer(Point current)
57 | {
58 | return GetScaledMouse(current);
59 | }
60 |
61 | public override Rectangle GetMouseMoveRectangle()
62 | {
63 | return GetScaledRectangle(remoteDesktop.ClientRectangle);
64 | }
65 |
66 | public override Point GetMouseMovePoint(Point current)
67 | {
68 | return GetScaledMouse(current);
69 | }
70 |
71 | private Size GetScaledSize(Size s)
72 | {
73 | if (vnc == null)
74 | return new Size(remoteDesktop.Width, remoteDesktop.Height);
75 |
76 | return (double)s.Width / vnc.Framebuffer.Width <= (double)s.Height / vnc.Framebuffer.Height ? new Size(s.Width, (int)((double)s.Width / vnc.Framebuffer.Width * vnc.Framebuffer.Height)) : new Size((int)((double)s.Height / vnc.Framebuffer.Height * vnc.Framebuffer.Width), s.Height);
77 | }
78 |
79 | private double ScaleFactor {
80 | get
81 | {
82 | if ((double)remoteDesktop.ClientRectangle.Width / vnc.Framebuffer.Width <=
83 | (double)remoteDesktop.ClientRectangle.Height / vnc.Framebuffer.Height) {
84 | return (double)remoteDesktop.ClientRectangle.Width / vnc.Framebuffer.Width;
85 | }
86 | return (double)remoteDesktop.ClientRectangle.Height / vnc.Framebuffer.Height;
87 | }
88 | }
89 |
90 | private Point GetScaledMouse(Point src)
91 | {
92 | var scaledSize = GetScaledSize(remoteDesktop.ClientRectangle.Size);
93 | src.X = AdjusteScaledToNormal(src.X - (remoteDesktop.ClientRectangle.Width - scaledSize.Width) / 2);
94 | src.Y = AdjusteScaledToNormal(src.Y - (remoteDesktop.ClientRectangle.Height - scaledSize.Height) / 2);
95 | return src;
96 | }
97 |
98 | private Rectangle GetScaledRectangle(Rectangle rect)
99 | {
100 | var scaledSize = GetScaledSize(rect.Size);
101 | return new Rectangle((rect.Width - scaledSize.Width) / 2,
102 | (rect.Height - scaledSize.Height) / 2,
103 | scaledSize.Width,
104 | scaledSize.Height);
105 | }
106 |
107 | private int AdjusteScaledToNormal(double value)
108 | {
109 | return (int)Math.Round(value / ScaleFactor);
110 | }
111 |
112 | private int AdjusteNormalToScaled(double value)
113 | {
114 | return (int)Math.Round(value * ScaleFactor);
115 | }
116 | }
117 | }
--------------------------------------------------------------------------------
/VncSharpCore/VncSharpCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net9.0-windows;net6.0-windows;net48;
4 | Library
5 | true
6 | VncSharpKey.snk
7 | Resources\vncviewer.ico
8 | false
9 | true
10 | true
11 | True
12 | GPL-2.0-only
13 | True
14 | en
15 | 1.2.1
16 | 1.2.1
17 | 1.2.1
18 | git
19 | https://github.com/mRemoteNG/VncSharp
20 | VNC Client Library
21 | The mRemoteNG Team, David Humphrey
22 | https://github.com/mRemoteNG/VncSharp
23 | README.md
24 |
25 |
26 | TRACE;DEBUG;Win32
27 | true
28 |
29 |
30 | Win32
31 | true
32 | true
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | True
41 | True
42 | Resources.resx
43 |
44 |
45 | Component
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | True
58 | \
59 |
60 |
61 |
62 |
63 | ResXFileCodeGenerator
64 | Resources.Designer.cs
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/VncSharpCore/VncSharpKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/1Remote/VncSharpCore/085a0eb224e2871c9c05a91ae4bcbea6c0e95f15/VncSharpCore/VncSharpKey.snk
--------------------------------------------------------------------------------
/VncSharpCore/VncViewInputPolicy.cs:
--------------------------------------------------------------------------------
1 | // VncSharp - .NET VNC Client Library
2 | // Copyright (C) 2008 David Humphrey
3 | //
4 | // This program is free software; you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation; either version 2 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program; if not, write to the Free Software
16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 |
18 | using System.Diagnostics;
19 | using System.Drawing;
20 |
21 | namespace VncSharpCore
22 | {
23 | ///
24 | /// A view-only version of IVncInputPolicy.
25 | ///
26 | public sealed class VncViewInputPolicy : IVncInputPolicy
27 | {
28 | public VncViewInputPolicy(RfbProtocol rfb)
29 | {
30 | Debug.Assert(rfb != null);
31 | }
32 |
33 | public void WriteKeyboardEvent(uint keysym, bool pressed)
34 | {
35 | }
36 |
37 | public void WritePointerEvent(byte buttonMask, Point point)
38 | {
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/Adler32.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2006, ComponentAce
2 | // http://www.componentace.com
3 | // All rights reserved.
4 |
5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 |
12 |
13 |
14 | /*
15 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
16 |
17 | Redistribution and use in source and binary forms, with or without
18 | modification, are permitted provided that the following conditions are met:
19 |
20 | 1. Redistributions of source code must retain the above copyright notice,
21 | this list of conditions and the following disclaimer.
22 |
23 | 2. Redistributions in binary form must reproduce the above copyright
24 | notice, this list of conditions and the following disclaimer in
25 | the documentation and/or other materials provided with the distribution.
26 |
27 | 3. The names of the authors may not be used to endorse or promote products
28 | derived from this software without specific prior written permission.
29 |
30 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
31 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
32 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
33 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
34 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
36 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
37 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
38 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
39 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 | */
41 | /*
42 | * This program is based on zlib-1.1.3, so all credit should go authors
43 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
44 | * and contributors of zlib.
45 | */
46 |
47 | namespace VncSharpCore.zlib.NET
48 | {
49 | internal sealed class Adler32
50 | {
51 |
52 | // largest prime smaller than 65536
53 | private const int BASE = 65521;
54 | // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
55 | private const int NMAX = 5552;
56 |
57 | internal long adler32(long adler, byte[] buf, int index, int len)
58 | {
59 | if (buf == null)
60 | {
61 | return 1L;
62 | }
63 |
64 | var s1 = adler & 0xffff;
65 | var s2 = (adler >> 16) & 0xffff;
66 | int k;
67 |
68 | while (len > 0)
69 | {
70 | k = len < NMAX?len:NMAX;
71 | len -= k;
72 | while (k >= 16)
73 | {
74 | s1 += buf[index++] & 0xff; s2 += s1;
75 | s1 += buf[index++] & 0xff; s2 += s1;
76 | s1 += buf[index++] & 0xff; s2 += s1;
77 | s1 += buf[index++] & 0xff; s2 += s1;
78 | s1 += buf[index++] & 0xff; s2 += s1;
79 | s1 += buf[index++] & 0xff; s2 += s1;
80 | s1 += buf[index++] & 0xff; s2 += s1;
81 | s1 += buf[index++] & 0xff; s2 += s1;
82 | s1 += buf[index++] & 0xff; s2 += s1;
83 | s1 += buf[index++] & 0xff; s2 += s1;
84 | s1 += buf[index++] & 0xff; s2 += s1;
85 | s1 += buf[index++] & 0xff; s2 += s1;
86 | s1 += buf[index++] & 0xff; s2 += s1;
87 | s1 += buf[index++] & 0xff; s2 += s1;
88 | s1 += buf[index++] & 0xff; s2 += s1;
89 | s1 += buf[index++] & 0xff; s2 += s1;
90 | k -= 16;
91 | }
92 | if (k != 0)
93 | {
94 | do
95 | {
96 | s1 += buf[index++] & 0xff; s2 += s1;
97 | }
98 | while (--k != 0);
99 | }
100 | s1 %= BASE;
101 | s2 %= BASE;
102 | }
103 | return (s2 << 16) | s1;
104 | }
105 |
106 | }
107 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/Inflate.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2006, ComponentAce
2 | // http://www.componentace.com
3 | // All rights reserved.
4 |
5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 |
12 | /*
13 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions are met:
17 |
18 | 1. Redistributions of source code must retain the above copyright notice,
19 | this list of conditions and the following disclaimer.
20 |
21 | 2. Redistributions in binary form must reproduce the above copyright
22 | notice, this list of conditions and the following disclaimer in
23 | the documentation and/or other materials provided with the distribution.
24 |
25 | 3. The names of the authors may not be used to endorse or promote products
26 | derived from this software without specific prior written permission.
27 |
28 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
30 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
31 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
34 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 | */
39 | /*
40 | * This program is based on zlib-1.1.3, so all credit should go authors
41 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
42 | * and contributors of zlib.
43 | */
44 |
45 | namespace VncSharpCore.zlib.NET
46 | {
47 | internal sealed class Inflate
48 | {
49 |
50 | private const int MAX_WBITS = 15; // 32K LZ77 window
51 |
52 | // preset dictionary flag in zlib header
53 | private const int PRESET_DICT = 0x20;
54 |
55 | internal const int Z_NO_FLUSH = 0;
56 | internal const int Z_PARTIAL_FLUSH = 1;
57 | internal const int Z_SYNC_FLUSH = 2;
58 | internal const int Z_FULL_FLUSH = 3;
59 | internal const int Z_FINISH = 4;
60 |
61 | private const int Z_DEFLATED = 8;
62 |
63 | private const int Z_OK = 0;
64 | private const int Z_STREAM_END = 1;
65 | private const int Z_NEED_DICT = 2;
66 | private const int Z_ERRNO = - 1;
67 | private const int Z_STREAM_ERROR = - 2;
68 | private const int Z_DATA_ERROR = - 3;
69 | private const int Z_MEM_ERROR = - 4;
70 | private const int Z_BUF_ERROR = - 5;
71 | private const int Z_VERSION_ERROR = - 6;
72 |
73 | private const int METHOD = 0; // waiting for method byte
74 | private const int FLAG = 1; // waiting for flag byte
75 | private const int DICT4 = 2; // four dictionary check bytes to go
76 | private const int DICT3 = 3; // three dictionary check bytes to go
77 | private const int DICT2 = 4; // two dictionary check bytes to go
78 | private const int DICT1 = 5; // one dictionary check byte to go
79 | private const int DICT0 = 6; // waiting for inflateSetDictionary
80 | private const int BLOCKS = 7; // decompressing blocks
81 | private const int CHECK4 = 8; // four check bytes to go
82 | private const int CHECK3 = 9; // three check bytes to go
83 | private const int CHECK2 = 10; // two check bytes to go
84 | private const int CHECK1 = 11; // one check byte to go
85 | private const int DONE = 12; // finished check, done
86 | private const int BAD = 13; // got an error--stay here
87 |
88 | internal int mode; // current inflate mode
89 |
90 | // mode dependent information
91 | internal int method; // if FLAGS, method byte
92 |
93 | // if CHECK, check values to compare
94 | internal long[] was = new long[1]; // computed check value
95 | internal long need; // stream check value
96 |
97 | // if BAD, inflateSync's marker bytes count
98 | internal int marker;
99 |
100 | // mode independent information
101 | internal int nowrap; // flag for no wrapper
102 | internal int wbits; // log2(window size) (8..15, defaults to 15)
103 |
104 | internal InfBlocks blocks; // current inflate_blocks state
105 |
106 | internal int inflateReset(ZStream z)
107 | {
108 | if (z == null || z.istate == null)
109 | return Z_STREAM_ERROR;
110 |
111 | z.total_in = z.total_out = 0;
112 | z.msg = null;
113 | z.istate.mode = z.istate.nowrap != 0?BLOCKS:METHOD;
114 | z.istate.blocks.reset(z, null);
115 | return Z_OK;
116 | }
117 |
118 | internal int inflateEnd(ZStream z)
119 | {
120 | if (blocks != null)
121 | blocks.free(z);
122 | blocks = null;
123 | // ZFREE(z, z->state);
124 | return Z_OK;
125 | }
126 |
127 | internal int inflateInit(ZStream z, int w)
128 | {
129 | z.msg = null;
130 | blocks = null;
131 |
132 | // handle undocumented nowrap option (no zlib header or check)
133 | nowrap = 0;
134 | if (w < 0)
135 | {
136 | w = - w;
137 | nowrap = 1;
138 | }
139 |
140 | // set window size
141 | if (w < 8 || w > 15)
142 | {
143 | inflateEnd(z);
144 | return Z_STREAM_ERROR;
145 | }
146 | wbits = w;
147 |
148 | z.istate.blocks = new InfBlocks(z, z.istate.nowrap != 0?null:this, 1 << w);
149 |
150 | // reset state
151 | inflateReset(z);
152 | return Z_OK;
153 | }
154 |
155 | internal int inflate(ZStream z, int f)
156 | {
157 | int r;
158 | int b;
159 |
160 | if (z == null || z.istate == null || z.next_in == null)
161 | return Z_STREAM_ERROR;
162 | f = f == Z_FINISH?Z_BUF_ERROR:Z_OK;
163 | r = Z_BUF_ERROR;
164 | while (true)
165 | {
166 | //System.out.println("mode: "+z.istate.mode);
167 | switch (z.istate.mode)
168 | {
169 |
170 | case METHOD:
171 |
172 | if (z.avail_in == 0)
173 | return r; r = f;
174 |
175 | z.avail_in--; z.total_in++;
176 | if (((z.istate.method = z.next_in[z.next_in_index++]) & 0xf) != Z_DEFLATED)
177 | {
178 | z.istate.mode = BAD;
179 | z.msg = "unknown compression method";
180 | z.istate.marker = 5; // can't try inflateSync
181 | break;
182 | }
183 | if ((z.istate.method >> 4) + 8 > z.istate.wbits)
184 | {
185 | z.istate.mode = BAD;
186 | z.msg = "invalid window size";
187 | z.istate.marker = 5; // can't try inflateSync
188 | break;
189 | }
190 | z.istate.mode = FLAG;
191 | goto case FLAG;
192 |
193 | case FLAG:
194 |
195 | if (z.avail_in == 0)
196 | return r; r = f;
197 |
198 | z.avail_in--; z.total_in++;
199 | b = z.next_in[z.next_in_index++] & 0xff;
200 |
201 | if (((z.istate.method << 8) + b) % 31 != 0)
202 | {
203 | z.istate.mode = BAD;
204 | z.msg = "incorrect header check";
205 | z.istate.marker = 5; // can't try inflateSync
206 | break;
207 | }
208 |
209 | if ((b & PRESET_DICT) == 0)
210 | {
211 | z.istate.mode = BLOCKS;
212 | break;
213 | }
214 | z.istate.mode = DICT4;
215 | goto case DICT4;
216 |
217 | case DICT4:
218 |
219 | if (z.avail_in == 0)
220 | return r; r = f;
221 |
222 | z.avail_in--; z.total_in++;
223 | z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int) 0xff000000L);
224 | z.istate.mode = DICT3;
225 | goto case DICT3;
226 |
227 | case DICT3:
228 |
229 | if (z.avail_in == 0)
230 | return r; r = f;
231 |
232 | z.avail_in--; z.total_in++;
233 | z.istate.need += ((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L;
234 | z.istate.mode = DICT2;
235 | goto case DICT2;
236 |
237 | case DICT2:
238 |
239 | if (z.avail_in == 0)
240 | return r; r = f;
241 |
242 | z.avail_in--; z.total_in++;
243 | z.istate.need += ((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L;
244 | z.istate.mode = DICT1;
245 | goto case DICT1;
246 |
247 | case DICT1:
248 |
249 | if (z.avail_in == 0)
250 | return r; r = f;
251 |
252 | z.avail_in--; z.total_in++;
253 | z.istate.need += z.next_in[z.next_in_index++] & 0xffL;
254 | z.adler = z.istate.need;
255 | z.istate.mode = DICT0;
256 | return Z_NEED_DICT;
257 |
258 | case DICT0:
259 | z.istate.mode = BAD;
260 | z.msg = "need dictionary";
261 | z.istate.marker = 0; // can try inflateSync
262 | return Z_STREAM_ERROR;
263 |
264 | case BLOCKS:
265 |
266 | r = z.istate.blocks.proc(z, r);
267 | if (r == Z_DATA_ERROR)
268 | {
269 | z.istate.mode = BAD;
270 | z.istate.marker = 0; // can try inflateSync
271 | break;
272 | }
273 | if (r == Z_OK)
274 | {
275 | r = f;
276 | }
277 | if (r != Z_STREAM_END)
278 | {
279 | return r;
280 | }
281 | r = f;
282 | z.istate.blocks.reset(z, z.istate.was);
283 | if (z.istate.nowrap != 0)
284 | {
285 | z.istate.mode = DONE;
286 | break;
287 | }
288 | z.istate.mode = CHECK4;
289 | goto case CHECK4;
290 |
291 | case CHECK4:
292 |
293 | if (z.avail_in == 0)
294 | return r; r = f;
295 |
296 | z.avail_in--; z.total_in++;
297 | z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 24) & unchecked((int) 0xff000000L);
298 | z.istate.mode = CHECK3;
299 | goto case CHECK3;
300 |
301 | case CHECK3:
302 |
303 | if (z.avail_in == 0)
304 | return r; r = f;
305 |
306 | z.avail_in--; z.total_in++;
307 | z.istate.need += ((z.next_in[z.next_in_index++] & 0xff) << 16) & 0xff0000L;
308 | z.istate.mode = CHECK2;
309 | goto case CHECK2;
310 |
311 | case CHECK2:
312 |
313 | if (z.avail_in == 0)
314 | return r; r = f;
315 |
316 | z.avail_in--; z.total_in++;
317 | z.istate.need += ((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L;
318 | z.istate.mode = CHECK1;
319 | goto case CHECK1;
320 |
321 | case CHECK1:
322 |
323 | if (z.avail_in == 0)
324 | return r; r = f;
325 |
326 | z.avail_in--; z.total_in++;
327 | z.istate.need += z.next_in[z.next_in_index++] & 0xffL;
328 |
329 | if ((int) z.istate.was[0] != (int) z.istate.need)
330 | {
331 | z.istate.mode = BAD;
332 | z.msg = "incorrect data check";
333 | z.istate.marker = 5; // can't try inflateSync
334 | break;
335 | }
336 |
337 | z.istate.mode = DONE;
338 | goto case DONE;
339 |
340 | case DONE:
341 | return Z_STREAM_END;
342 |
343 | case BAD:
344 | return Z_DATA_ERROR;
345 |
346 | default:
347 | return Z_STREAM_ERROR;
348 |
349 | }
350 | }
351 | }
352 |
353 |
354 | internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength)
355 | {
356 | var index = 0;
357 | var length = dictLength;
358 | if (z == null || z.istate == null || z.istate.mode != DICT0)
359 | return Z_STREAM_ERROR;
360 |
361 | if (z._adler.adler32(1L, dictionary, 0, dictLength) != z.adler)
362 | {
363 | return Z_DATA_ERROR;
364 | }
365 |
366 | z.adler = z._adler.adler32(0, null, 0, 0);
367 |
368 | if (length >= 1 << z.istate.wbits)
369 | {
370 | length = (1 << z.istate.wbits) - 1;
371 | index = dictLength - length;
372 | }
373 | z.istate.blocks.set_dictionary(dictionary, index, length);
374 | z.istate.mode = BLOCKS;
375 | return Z_OK;
376 | }
377 |
378 | private static byte[] mark = {0, 0, (byte) SupportClass.Identity(0xff), (byte) SupportClass.Identity(0xff)};
379 |
380 | internal int inflateSync(ZStream z)
381 | {
382 | int n; // number of bytes to look at
383 | int p; // pointer to bytes
384 | int m; // number of marker bytes found in a row
385 | long r, w; // temporaries to save total_in and total_out
386 |
387 | // set up
388 | if (z == null || z.istate == null)
389 | return Z_STREAM_ERROR;
390 | if (z.istate.mode != BAD)
391 | {
392 | z.istate.mode = BAD;
393 | z.istate.marker = 0;
394 | }
395 | if ((n = z.avail_in) == 0)
396 | return Z_BUF_ERROR;
397 | p = z.next_in_index;
398 | m = z.istate.marker;
399 |
400 | // search
401 | while (n != 0 && m < 4)
402 | {
403 | if (z.next_in[p] == mark[m])
404 | {
405 | m++;
406 | }
407 | else if (z.next_in[p] != 0)
408 | {
409 | m = 0;
410 | }
411 | else
412 | {
413 | m = 4 - m;
414 | }
415 | p++; n--;
416 | }
417 |
418 | // restore
419 | z.total_in += p - z.next_in_index;
420 | z.next_in_index = p;
421 | z.avail_in = n;
422 | z.istate.marker = m;
423 |
424 | // return no joy or set up to restart on a new block
425 | if (m != 4)
426 | {
427 | return Z_DATA_ERROR;
428 | }
429 | r = z.total_in; w = z.total_out;
430 | inflateReset(z);
431 | z.total_in = r; z.total_out = w;
432 | z.istate.mode = BLOCKS;
433 | return Z_OK;
434 | }
435 |
436 | // Returns true if inflate is currently at the end of a block generated
437 | // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
438 | // implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
439 | // but removes the length bytes of the resulting empty stored block. When
440 | // decompressing, PPP checks that at the end of input packet, inflate is
441 | // waiting for these length bytes.
442 | internal int inflateSyncPoint(ZStream z)
443 | {
444 | if (z == null || z.istate == null || z.istate.blocks == null)
445 | return Z_STREAM_ERROR;
446 | return z.istate.blocks.sync_point();
447 | }
448 | }
449 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/StaticTree.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2006, ComponentAce
2 | // http://www.componentace.com
3 | // All rights reserved.
4 |
5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 |
12 | /*
13 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions are met:
17 |
18 | 1. Redistributions of source code must retain the above copyright notice,
19 | this list of conditions and the following disclaimer.
20 |
21 | 2. Redistributions in binary form must reproduce the above copyright
22 | notice, this list of conditions and the following disclaimer in
23 | the documentation and/or other materials provided with the distribution.
24 |
25 | 3. The names of the authors may not be used to endorse or promote products
26 | derived from this software without specific prior written permission.
27 |
28 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
30 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
31 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
34 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 | */
39 | /*
40 | * This program is based on zlib-1.1.3, so all credit should go authors
41 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
42 | * and contributors of zlib.
43 | */
44 |
45 | namespace VncSharpCore.zlib.NET
46 | {
47 | internal sealed class StaticTree
48 | {
49 | private const int MAX_BITS = 15;
50 |
51 | private const int BL_CODES = 19;
52 | private const int D_CODES = 30;
53 | private const int LITERALS = 256;
54 | private const int LENGTH_CODES = 29;
55 | private static readonly int L_CODES = LITERALS + 1 + LENGTH_CODES;
56 |
57 | // Bit length codes must not exceed MAX_BL_BITS bits
58 | internal const int MAX_BL_BITS = 7;
59 |
60 | internal static readonly short[] static_ltree = {12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7
61 | , 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8};
62 |
63 | internal static readonly short[] static_dtree = {0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5};
64 |
65 | internal static StaticTree static_l_desc;
66 |
67 | internal static StaticTree static_d_desc;
68 |
69 | internal static StaticTree static_bl_desc;
70 |
71 | internal short[] static_tree; // static tree or null
72 | internal int[] extra_bits; // extra bits for each code or null
73 | internal int extra_base; // base index for extra_bits
74 | internal int elems; // max number of elements in the tree
75 | internal int max_length; // max bit length for the codes
76 |
77 | internal StaticTree(short[] static_tree, int[] extra_bits, int extra_base, int elems, int max_length)
78 | {
79 | this.static_tree = static_tree;
80 | this.extra_bits = extra_bits;
81 | this.extra_base = extra_base;
82 | this.elems = elems;
83 | this.max_length = max_length;
84 | }
85 | static StaticTree()
86 | {
87 | static_l_desc = new StaticTree(static_ltree, Tree.extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);
88 | static_d_desc = new StaticTree(static_dtree, Tree.extra_dbits, 0, D_CODES, MAX_BITS);
89 | static_bl_desc = new StaticTree(null, Tree.extra_blbits, 0, BL_CODES, MAX_BL_BITS);
90 | }
91 | }
92 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/SupportClass.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Text;
3 |
4 | namespace VncSharpCore.zlib.NET
5 | {
6 | public class SupportClass
7 | {
8 | ///
9 | /// This method returns the literal value received
10 | ///
11 | /// The literal to return
12 | /// The received value
13 | public static long Identity(long literal)
14 | {
15 | return literal;
16 | }
17 |
18 | ///
19 | /// This method returns the literal value received
20 | ///
21 | /// The literal to return
22 | /// The received value
23 | public static ulong Identity(ulong literal)
24 | {
25 | return literal;
26 | }
27 |
28 | ///
29 | /// This method returns the literal value received
30 | ///
31 | /// The literal to return
32 | /// The received value
33 | public static float Identity(float literal)
34 | {
35 | return literal;
36 | }
37 |
38 | ///
39 | /// This method returns the literal value received
40 | ///
41 | /// The literal to return
42 | /// The received value
43 | public static double Identity(double literal)
44 | {
45 | return literal;
46 | }
47 |
48 | /*******************************/
49 | ///
50 | /// Performs an unsigned bitwise right shift with the specified number
51 | ///
52 | /// Number to operate on
53 | /// Ammount of bits to shift
54 | /// The resulting number from the shift operation
55 | public static int URShift(int number, int bits)
56 | {
57 | if ( number >= 0)
58 | return number >> bits;
59 | return (number >> bits) + (2 << ~bits);
60 | }
61 |
62 | ///
63 | /// Performs an unsigned bitwise right shift with the specified number
64 | ///
65 | /// Number to operate on
66 | /// Ammount of bits to shift
67 | /// The resulting number from the shift operation
68 | public static int URShift(int number, long bits)
69 | {
70 | return URShift(number, (int)bits);
71 | }
72 |
73 | ///
74 | /// Performs an unsigned bitwise right shift with the specified number
75 | ///
76 | /// Number to operate on
77 | /// Ammount of bits to shift
78 | /// The resulting number from the shift operation
79 | public static long URShift(long number, int bits)
80 | {
81 | if ( number >= 0)
82 | return number >> bits;
83 | return (number >> bits) + (2L << ~bits);
84 | }
85 |
86 | ///
87 | /// Performs an unsigned bitwise right shift with the specified number
88 | ///
89 | /// Number to operate on
90 | /// Ammount of bits to shift
91 | /// The resulting number from the shift operation
92 | public static long URShift(long number, long bits)
93 | {
94 | return URShift(number, (int)bits);
95 | }
96 |
97 | /*******************************/
98 | /// Reads a number of characters from the current source Stream and writes the data to the target array at the specified index.
99 | /// The source Stream to read from.
100 | /// Contains the array of characteres read from the source Stream.
101 | /// The starting index of the target array.
102 | /// The maximum number of characters to read from the source Stream.
103 | /// The number of characters read. The number will be less than or equal to count depending on the data available in the source Stream. Returns -1 if the end of the stream is reached.
104 | public static int ReadInput(Stream sourceStream, byte[] target, int start, int count)
105 | {
106 | // Returns 0 bytes if not enough space in target
107 | if (target.Length == 0)
108 | return 0;
109 |
110 | var receiver = new byte[target.Length];
111 | var bytesRead = sourceStream.Read(receiver, start, count);
112 |
113 | // Returns -1 if EOF
114 | if (bytesRead == 0)
115 | return -1;
116 |
117 | for(var i = start; i < start + bytesRead; i++)
118 | target[i] = receiver[i];
119 |
120 | return bytesRead;
121 | }
122 |
123 | /// Reads a number of characters from the current source TextReader and writes the data to the target array at the specified index.
124 | /// The source TextReader to read from
125 | /// Contains the array of characteres read from the source TextReader.
126 | /// The starting index of the target array.
127 | /// The maximum number of characters to read from the source TextReader.
128 | /// The number of characters read. The number will be less than or equal to count depending on the data available in the source TextReader. Returns -1 if the end of the stream is reached.
129 | public static int ReadInput(TextReader sourceTextReader, byte[] target, int start, int count)
130 | {
131 | // Returns 0 bytes if not enough space in target
132 | if (target.Length == 0) return 0;
133 |
134 | var charArray = new char[target.Length];
135 | var bytesRead = sourceTextReader.Read(charArray, start, count);
136 |
137 | // Returns -1 if EOF
138 | if (bytesRead == 0) return -1;
139 |
140 | for(var index=start; index
147 | /// Converts a string to an array of bytes
148 | ///
149 | /// The string to be converted
150 | /// The new array of bytes
151 | public static byte[] ToByteArray(string sourceString)
152 | {
153 | return Encoding.UTF8.GetBytes(sourceString);
154 | }
155 |
156 | ///
157 | /// Converts an array of bytes to an array of chars
158 | ///
159 | /// The array of bytes to convert
160 | /// The new array of chars
161 | public static char[] ToCharArray(byte[] byteArray)
162 | {
163 | return Encoding.UTF8.GetChars(byteArray);
164 | }
165 |
166 |
167 | }
168 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/ZInputStream.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2006, ComponentAce
2 | // http://www.componentace.com
3 | // All rights reserved.
4 |
5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 |
12 | /*
13 | Copyright (c) 2001 Lapo Luchini.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions are met:
17 |
18 | 1. Redistributions of source code must retain the above copyright notice,
19 | this list of conditions and the following disclaimer.
20 |
21 | 2. Redistributions in binary form must reproduce the above copyright
22 | notice, this list of conditions and the following disclaimer in
23 | the documentation and/or other materials provided with the distribution.
24 |
25 | 3. The names of the authors may not be used to endorse or promote products
26 | derived from this software without specific prior written permission.
27 |
28 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
30 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS
31 | OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
34 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 | */
39 | /*
40 | * This program is based on zlib-1.1.3, so all credit should go authors
41 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
42 | * and contributors of zlib.
43 | */
44 |
45 | using System.IO;
46 |
47 | namespace VncSharpCore.zlib.NET
48 | {
49 |
50 | public class ZInputStream:BinaryReader
51 | {
52 | internal void InitBlock()
53 | {
54 | flush = zlibConst.Z_NO_FLUSH;
55 | buf = new byte[bufsize];
56 | }
57 | virtual public int FlushMode
58 | {
59 | get
60 | {
61 | return flush;
62 | }
63 |
64 | set
65 | {
66 | flush = value;
67 | }
68 |
69 | }
70 | /// Returns the total number of bytes input so far.
71 | virtual public long TotalIn
72 | {
73 | get
74 | {
75 | return z.total_in;
76 | }
77 |
78 | }
79 | /// Returns the total number of bytes output so far.
80 | virtual public long TotalOut
81 | {
82 | get
83 | {
84 | return z.total_out;
85 | }
86 |
87 | }
88 |
89 | protected ZStream z = new ZStream();
90 | protected int bufsize = 512;
91 | protected int flush;
92 | protected byte[] buf, buf1 = new byte[1];
93 | protected bool compress;
94 |
95 | internal Stream in_Renamed;
96 |
97 | public ZInputStream(Stream in_Renamed):base(in_Renamed)
98 | {
99 | InitBlock();
100 | this.in_Renamed = in_Renamed;
101 | z.inflateInit();
102 | compress = false;
103 | z.next_in = buf;
104 | z.next_in_index = 0;
105 | z.avail_in = 0;
106 | }
107 |
108 | public ZInputStream(Stream in_Renamed, int level):base(in_Renamed)
109 | {
110 | InitBlock();
111 | this.in_Renamed = in_Renamed;
112 | z.deflateInit(level);
113 | compress = true;
114 | z.next_in = buf;
115 | z.next_in_index = 0;
116 | z.avail_in = 0;
117 | }
118 |
119 | /*public int available() throws IOException {
120 | return inf.finished() ? 0 : 1;
121 | }*/
122 |
123 | public override int Read()
124 | {
125 | if (read(buf1, 0, 1) == - 1)
126 | return - 1;
127 | return buf1[0] & 0xFF;
128 | }
129 |
130 | internal bool nomoreinput;
131 |
132 | public int read(byte[] b, int off, int len)
133 | {
134 | if (len == 0)
135 | return 0;
136 | int err;
137 | z.next_out = b;
138 | z.next_out_index = off;
139 | z.avail_out = len;
140 | do
141 | {
142 | if (z.avail_in == 0 && !nomoreinput)
143 | {
144 | // if buffer is empty and more input is avaiable, refill it
145 | z.next_in_index = 0;
146 | z.avail_in = SupportClass.ReadInput(in_Renamed, buf, 0, bufsize); //(bufsize Returns the total number of bytes input so far.
73 | virtual public long TotalIn
74 | {
75 | get
76 | {
77 | return z.total_in;
78 | }
79 |
80 | }
81 | /// Returns the total number of bytes output so far.
82 | virtual public long TotalOut
83 | {
84 | get
85 | {
86 | return z.total_out;
87 | }
88 |
89 | }
90 |
91 | protected internal ZStream z = new ZStream();
92 | protected internal int bufsize = 4096;
93 | protected internal int flush_Renamed_Field;
94 | protected internal byte[] buf, buf1 = new byte[1];
95 | protected internal bool compress;
96 |
97 | private Stream out_Renamed;
98 |
99 | public ZOutputStream(Stream out_Renamed)
100 | {
101 | InitBlock();
102 | this.out_Renamed = out_Renamed;
103 | z.inflateInit();
104 | compress = false;
105 | }
106 |
107 | public ZOutputStream(Stream out_Renamed, int level)
108 | {
109 | InitBlock();
110 | this.out_Renamed = out_Renamed;
111 | z.deflateInit(level);
112 | compress = true;
113 | }
114 |
115 | public void WriteByte(int b)
116 | {
117 | buf1[0] = (byte) b;
118 | Write(buf1, 0, 1);
119 | }
120 | //UPGRADE_TODO: The differences in the Expected value of parameters for method 'WriteByte' may cause compilation errors. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1092_3"'
121 | public override void WriteByte(byte b)
122 | {
123 | WriteByte(b);
124 | }
125 |
126 | public override void Write(byte[] b1, int off, int len)
127 | {
128 | if (len == 0)
129 | return ;
130 | int err;
131 | var b = new byte[b1.Length];
132 | Array.Copy(b1, 0, b, 0, b1.Length);
133 | z.next_in = b;
134 | z.next_in_index = off;
135 | z.avail_in = len;
136 | do
137 | {
138 | z.next_out = buf;
139 | z.next_out_index = 0;
140 | z.avail_out = bufsize;
141 | if (compress)
142 | err = z.deflate(flush_Renamed_Field);
143 | else
144 | err = z.inflate(flush_Renamed_Field);
145 | if (err != zlibConst.Z_OK && err != zlibConst.Z_STREAM_END)
146 | throw new ZStreamException((compress?"de":"in") + "flating: " + z.msg);
147 | out_Renamed.Write(buf, 0, bufsize - z.avail_out);
148 | }
149 | while (z.avail_in > 0 || z.avail_out == 0);
150 | }
151 |
152 | public virtual void finish()
153 | {
154 | int err;
155 | do
156 | {
157 | z.next_out = buf;
158 | z.next_out_index = 0;
159 | z.avail_out = bufsize;
160 | if (compress)
161 | {
162 | err = z.deflate(zlibConst.Z_FINISH);
163 | }
164 | else
165 | {
166 | err = z.inflate(zlibConst.Z_FINISH);
167 | }
168 | if (err != zlibConst.Z_STREAM_END && err != zlibConst.Z_OK)
169 | throw new ZStreamException((compress?"de":"in") + "flating: " + z.msg);
170 | if (bufsize - z.avail_out > 0)
171 | {
172 | out_Renamed.Write(buf, 0, bufsize - z.avail_out);
173 | }
174 | }
175 | while (z.avail_in > 0 || z.avail_out == 0);
176 | try
177 | {
178 | Flush();
179 | }
180 | catch
181 | {
182 | }
183 | }
184 | public virtual void end()
185 | {
186 | if (compress)
187 | {
188 | z.deflateEnd();
189 | }
190 | else
191 | {
192 | z.inflateEnd();
193 | }
194 | z.free();
195 | z = null;
196 | }
197 | public override void Close()
198 | {
199 | try
200 | {
201 | try
202 | {
203 | finish();
204 | }
205 | catch
206 | {
207 | }
208 | }
209 | finally
210 | {
211 | end();
212 | out_Renamed.Close();
213 | out_Renamed = null;
214 | }
215 | }
216 |
217 | public override void Flush()
218 | {
219 | out_Renamed.Flush();
220 | }
221 | //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"'
222 | public override int Read(byte[] buffer, int offset, int count)
223 | {
224 | return 0;
225 | }
226 | //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"'
227 | public override void SetLength(long value)
228 | {
229 | }
230 | //UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"'
231 | public override long Seek(long offset, SeekOrigin origin)
232 | {
233 | return 0;
234 | }
235 | //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"'
236 | public override bool CanRead
237 | {
238 | get
239 | {
240 | return false;
241 | }
242 |
243 | }
244 | //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"'
245 | public override bool CanSeek
246 | {
247 | get
248 | {
249 | return false;
250 | }
251 |
252 | }
253 | //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"'
254 | public override bool CanWrite
255 | {
256 | get
257 | {
258 | return false;
259 | }
260 |
261 | }
262 | //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"'
263 | public override long Length
264 | {
265 | get
266 | {
267 | return 0;
268 | }
269 |
270 | }
271 | //UPGRADE_TODO: The following property was automatically generated and it must be implemented in order to preserve the class logic. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1232_3"'
272 | public override long Position
273 | {
274 | get
275 | {
276 | return 0;
277 | }
278 |
279 | set
280 | {
281 | }
282 |
283 | }
284 | }
285 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/ZStream.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2006, ComponentAce
2 | // http://www.componentace.com
3 | // All rights reserved.
4 |
5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 |
12 | /*
13 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions are met:
17 |
18 | 1. Redistributions of source code must retain the above copyright notice,
19 | this list of conditions and the following disclaimer.
20 |
21 | 2. Redistributions in binary form must reproduce the above copyright
22 | notice, this list of conditions and the following disclaimer in
23 | the documentation and/or other materials provided with the distribution.
24 |
25 | 3. The names of the authors may not be used to endorse or promote products
26 | derived from this software without specific prior written permission.
27 |
28 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
30 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
31 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
34 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 | */
39 | /*
40 | * This program is based on zlib-1.1.3, so all credit should go authors
41 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
42 | * and contributors of zlib.
43 | */
44 |
45 | using System;
46 |
47 | namespace VncSharpCore.zlib.NET
48 | {
49 |
50 | sealed public class ZStream
51 | {
52 |
53 | private const int MAX_WBITS = 15; // 32K LZ77 window
54 | private static readonly int DEF_WBITS = MAX_WBITS;
55 |
56 | private const int Z_NO_FLUSH = 0;
57 | private const int Z_PARTIAL_FLUSH = 1;
58 | private const int Z_SYNC_FLUSH = 2;
59 | private const int Z_FULL_FLUSH = 3;
60 | private const int Z_FINISH = 4;
61 |
62 | private const int MAX_MEM_LEVEL = 9;
63 |
64 | private const int Z_OK = 0;
65 | private const int Z_STREAM_END = 1;
66 | private const int Z_NEED_DICT = 2;
67 | private const int Z_ERRNO = - 1;
68 | private const int Z_STREAM_ERROR = - 2;
69 | private const int Z_DATA_ERROR = - 3;
70 | private const int Z_MEM_ERROR = - 4;
71 | private const int Z_BUF_ERROR = - 5;
72 | private const int Z_VERSION_ERROR = - 6;
73 |
74 | public byte[] next_in; // next input byte
75 | public int next_in_index;
76 | public int avail_in; // number of bytes available at next_in
77 | public long total_in; // total nb of input bytes read so far
78 |
79 | public byte[] next_out; // next output byte should be put there
80 | public int next_out_index;
81 | public int avail_out; // remaining free space at next_out
82 | public long total_out; // total nb of bytes output so far
83 |
84 | public string msg;
85 |
86 | internal Deflate dstate;
87 | internal Inflate istate;
88 |
89 | internal int data_type; // best guess about the data type: ascii or binary
90 |
91 | public long adler;
92 | internal Adler32 _adler = new Adler32();
93 |
94 | public int inflateInit()
95 | {
96 | return inflateInit(DEF_WBITS);
97 | }
98 | public int inflateInit(int w)
99 | {
100 | istate = new Inflate();
101 | return istate.inflateInit(this, w);
102 | }
103 |
104 | public int inflate(int f)
105 | {
106 | if (istate == null)
107 | return Z_STREAM_ERROR;
108 | return istate.inflate(this, f);
109 | }
110 | public int inflateEnd()
111 | {
112 | if (istate == null)
113 | return Z_STREAM_ERROR;
114 | var ret = istate.inflateEnd(this);
115 | istate = null;
116 | return ret;
117 | }
118 | public int inflateSync()
119 | {
120 | if (istate == null)
121 | return Z_STREAM_ERROR;
122 | return istate.inflateSync(this);
123 | }
124 | public int inflateSetDictionary(byte[] dictionary, int dictLength)
125 | {
126 | if (istate == null)
127 | return Z_STREAM_ERROR;
128 | return istate.inflateSetDictionary(this, dictionary, dictLength);
129 | }
130 |
131 | public int deflateInit(int level)
132 | {
133 | return deflateInit(level, MAX_WBITS);
134 | }
135 | public int deflateInit(int level, int bits)
136 | {
137 | dstate = new Deflate();
138 | return dstate.deflateInit(this, level, bits);
139 | }
140 | public int deflate(int flush)
141 | {
142 | if (dstate == null)
143 | {
144 | return Z_STREAM_ERROR;
145 | }
146 | return dstate.deflate(this, flush);
147 | }
148 | public int deflateEnd()
149 | {
150 | if (dstate == null)
151 | return Z_STREAM_ERROR;
152 | var ret = dstate.deflateEnd();
153 | dstate = null;
154 | return ret;
155 | }
156 | public int deflateParams(int level, int strategy)
157 | {
158 | if (dstate == null)
159 | return Z_STREAM_ERROR;
160 | return dstate.deflateParams(this, level, strategy);
161 | }
162 | public int deflateSetDictionary(byte[] dictionary, int dictLength)
163 | {
164 | if (dstate == null)
165 | return Z_STREAM_ERROR;
166 | return dstate.deflateSetDictionary(this, dictionary, dictLength);
167 | }
168 |
169 | // Flush as much pending output as possible. All deflate() output goes
170 | // through this function so some applications may wish to modify it
171 | // to avoid allocating a large strm->next_out buffer and copying into it.
172 | // (See also read_buf()).
173 | internal void flush_pending()
174 | {
175 | var len = dstate.pending;
176 |
177 | if (len > avail_out)
178 | len = avail_out;
179 | if (len == 0)
180 | return ;
181 |
182 | if (dstate.pending_buf.Length <= dstate.pending_out || next_out.Length <= next_out_index || dstate.pending_buf.Length < dstate.pending_out + len || next_out.Length < next_out_index + len)
183 | {
184 | //System.Console.Out.WriteLine(dstate.pending_buf.Length + ", " + dstate.pending_out + ", " + next_out.Length + ", " + next_out_index + ", " + len);
185 | //System.Console.Out.WriteLine("avail_out=" + avail_out);
186 | }
187 |
188 | Array.Copy(dstate.pending_buf, dstate.pending_out, next_out, next_out_index, len);
189 |
190 | next_out_index += len;
191 | dstate.pending_out += len;
192 | total_out += len;
193 | avail_out -= len;
194 | dstate.pending -= len;
195 | if (dstate.pending == 0)
196 | {
197 | dstate.pending_out = 0;
198 | }
199 | }
200 |
201 | // Read a new buffer from the current input stream, update the adler32
202 | // and total number of bytes read. All deflate() input goes through
203 | // this function so some applications may wish to modify it to avoid
204 | // allocating a large strm->next_in buffer and copying from it.
205 | // (See also flush_pending()).
206 | internal int read_buf(byte[] buf, int start, int size)
207 | {
208 | var len = avail_in;
209 |
210 | if (len > size)
211 | len = size;
212 | if (len == 0)
213 | return 0;
214 |
215 | avail_in -= len;
216 |
217 | if (dstate.noheader == 0)
218 | {
219 | adler = _adler.adler32(adler, next_in, next_in_index, len);
220 | }
221 | Array.Copy(next_in, next_in_index, buf, start, len);
222 | next_in_index += len;
223 | total_in += len;
224 | return len;
225 | }
226 |
227 | public void free()
228 | {
229 | next_in = null;
230 | next_out = null;
231 | msg = null;
232 | _adler = null;
233 | }
234 | }
235 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/ZStreamException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2006, ComponentAce
2 | // http://www.componentace.com
3 | // All rights reserved.
4 |
5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 |
12 | /*
13 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions are met:
17 |
18 | 1. Redistributions of source code must retain the above copyright notice,
19 | this list of conditions and the following disclaimer.
20 |
21 | 2. Redistributions in binary form must reproduce the above copyright
22 | notice, this list of conditions and the following disclaimer in
23 | the documentation and/or other materials provided with the distribution.
24 |
25 | 3. The names of the authors may not be used to endorse or promote products
26 | derived from this software without specific prior written permission.
27 |
28 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
30 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
31 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
34 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 | */
39 | /*
40 | * This program is based on zlib-1.1.3, so all credit should go authors
41 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
42 | * and contributors of zlib.
43 | */
44 |
45 | using System.IO;
46 |
47 | namespace VncSharpCore.zlib.NET
48 | {
49 |
50 |
51 | public class ZStreamException:IOException
52 | {
53 | public ZStreamException()
54 | {
55 | }
56 | public ZStreamException(string s):base(s)
57 | {
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/Zlib.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2006, ComponentAce
2 | // http://www.componentace.com
3 | // All rights reserved.
4 |
5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 |
12 | /*
13 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
14 |
15 | Redistribution and use in source and binary forms, with or without
16 | modification, are permitted provided that the following conditions are met:
17 |
18 | 1. Redistributions of source code must retain the above copyright notice,
19 | this list of conditions and the following disclaimer.
20 |
21 | 2. Redistributions in binary form must reproduce the above copyright
22 | notice, this list of conditions and the following disclaimer in
23 | the documentation and/or other materials provided with the distribution.
24 |
25 | 3. The names of the authors may not be used to endorse or promote products
26 | derived from this software without specific prior written permission.
27 |
28 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
30 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
31 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
34 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 | */
39 | /*
40 | * This program is based on zlib-1.1.3, so all credit should go authors
41 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
42 | * and contributors of zlib.
43 | */
44 |
45 | namespace VncSharpCore.zlib.NET
46 | {
47 |
48 | sealed public class zlibConst
49 | {
50 | private const string version_Renamed_Field = "1.0.2";
51 | public static string version()
52 | {
53 | return version_Renamed_Field;
54 | }
55 |
56 | // compression levels
57 | public const int Z_NO_COMPRESSION = 0;
58 | public const int Z_BEST_SPEED = 1;
59 | public const int Z_BEST_COMPRESSION = 9;
60 | public const int Z_DEFAULT_COMPRESSION = - 1;
61 |
62 | // compression strategy
63 | public const int Z_FILTERED = 1;
64 | public const int Z_HUFFMAN_ONLY = 2;
65 | public const int Z_DEFAULT_STRATEGY = 0;
66 |
67 | public const int Z_NO_FLUSH = 0;
68 | public const int Z_PARTIAL_FLUSH = 1;
69 | public const int Z_SYNC_FLUSH = 2;
70 | public const int Z_FULL_FLUSH = 3;
71 | public const int Z_FINISH = 4;
72 |
73 | public const int Z_OK = 0;
74 | public const int Z_STREAM_END = 1;
75 | public const int Z_NEED_DICT = 2;
76 | public const int Z_ERRNO = - 1;
77 | public const int Z_STREAM_ERROR = - 2;
78 | public const int Z_DATA_ERROR = - 3;
79 | public const int Z_MEM_ERROR = - 4;
80 | public const int Z_BUF_ERROR = - 5;
81 | public const int Z_VERSION_ERROR = - 6;
82 | }
83 | }
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/history.txt:
--------------------------------------------------------------------------------
1 | ZLIB.NET: History of changes
2 | =============================
3 |
4 | version 1.04 (03/28/2007)
5 |
6 | - Problem with decompression some files is solved
7 |
8 |
9 | version 1.03 (03/05/2007)
10 |
11 | - Problem with decomressing some files is solved
12 |
13 |
14 | version 1.02 (01/29/2007)
15 |
16 | - Problem with decompressing large files using ZOutputStream is solved
17 |
18 |
19 | version 1.01 (08/17/2006)
20 |
21 | - Demos are updated
22 | - Some minor bugs are fixed
23 |
24 |
25 | version 1.0 (07/06/2006)
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006-2007, ComponentAce
2 | http://www.componentace.com
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 | Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 |
--------------------------------------------------------------------------------
/VncSharpCore/zlib.NET/readme.txt:
--------------------------------------------------------------------------------
1 | ZLIB.NET: README
2 | ==================================================
3 |
4 | Contents
5 | --------
6 |
7 | Program information
8 | Company information
9 | Description
10 | Specification
11 | Other ComponentAce compression products
12 |
13 |
14 |
15 | Program information
16 | -------------------
17 |
18 | Program Name:
19 | ZLIB.NET
20 | License Type: freeware
21 |
22 | Program Version:
23 | 1.04
24 | Program Release Date:
25 | 03/28/2007
26 | Program Purpose:
27 | version of ZLIB compression library for .NET framework
28 | Target Environment:
29 | Visual Studio 2003, Visual Studio 2005, Borland Developer Studio 2005, Borland Developer Studio 2006 and other
30 |
31 |
32 | Company information
33 | -------------------
34 |
35 | Company Name:
36 | ComponentAce
37 | Contact E-mail Address:
38 | support@componentace.com
39 | Contact WWW URL:
40 | http://www.componentace.com
41 |
42 |
43 | Description
44 | -----------
45 |
46 | 100% managed version of ZLIB compression library.
47 | Based on JZlib library (c) 2000,2001,2002,2003 ymnk, JCraft,Inc.
48 |
49 | The zlib compression library was written by Jean-loup Gailly gzip@prep.ai.mit.edu and Mark Adler madler@alumni.caltech.edu.
50 |
51 | The primary site for the zlib compression library is http://www.zlib.org.
52 |
53 | Copyright and license
54 | ---------------------
55 |
56 | See "license.txt" file.
57 |
58 |
59 | Warranty and guarantee
60 | ----------------------
61 |
62 | See "license.txt" file.
63 |
64 |
65 | Other ComponentAce compression products
66 | ---------------------------------------
67 |
68 | ZipForge.NET
69 | ------------
70 |
71 | ZipForge.NET is an advanced ZIP compression library for .NET framework.
72 | ZipForge.NET features include streaming support, transaction system, ZIP encryption, repair,
73 | progress indication, Zip64 support, SFX (self-extracting) archives, unicode filenames, spanning support and much more.
74 |
75 | FlexCompress.NET
76 | ----------------
77 |
78 | FlexCompress.NET is an advanced compression and encryption .NET component designed to provide archive
79 | functionality for your applications. This solution provides flexible compression and strong encryption algorithms that
80 | allows you to integrate archiving or backup features into your programs in a fast and easy way.
81 | FlexCompres.NET uses its own file format which allows to achieve high compression rate.
82 |
83 | For more info visit
84 | http://www.componentace.com/.NET_components
--------------------------------------------------------------------------------