├── .gitignore ├── LICENSE ├── README.md ├── help ├── WINFILE.CHM └── winfile.hlp └── src ├── Makefile ├── Makefile.deps ├── WinFile.mak ├── bitmap.bmp ├── bullet.bmp ├── dbg.c ├── dbg.h ├── fmifs.h ├── lfn.c ├── lfn.h ├── lfnmisc.c ├── mcopy.cur ├── mmove.cur ├── mpr.h ├── numfmt.c ├── numfmt.h ├── res.rc ├── scopy.cur ├── smove.cur ├── split.cur ├── suggest.c ├── suggest.db ├── suggest.h ├── tbar.c ├── toolbar.bmp ├── treectl.c ├── treectl.h ├── wbbitmap.bmp ├── wfassoc.c ├── wfchgnot.c ├── wfcomman.c ├── wfcopy.c ├── wfcopy.h ├── wfdir.c ├── wfdir.ico ├── wfdirrd.c ├── wfdirsrc.c ├── wfdlgs.c ├── wfdlgs.h ├── wfdlgs2.c ├── wfdlgs3.c ├── wfdoc.txt ├── wfdos.c ├── wfdrives.c ├── wfext.c ├── wfext.h ├── wfexti.h ├── wffile.c ├── wfgwl.h ├── wfhelp.h ├── wfinfo.c ├── wfinfo.h ├── wfinit.c ├── wfmem.c ├── wfmem.h ├── wfprint.c ├── wfsearch.c ├── wftrdir.ico ├── wftree.c ├── wftree.ico ├── wfutil.c ├── windows.ico ├── winexp.h ├── winfile.c ├── winfile.dlg ├── winfile.h ├── winfile.ico ├── wnetcaps.c ├── wnetcaps.h └── xtratool.bmp /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | 290 | # MinGW build output 291 | *.o 292 | *.exe 293 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Windows File Manager (WinFile) 2 | 3 | ## Table of Contents 4 | 5 | - [Introduction](#introduction) 6 | - [History](#history) 7 | - [License](#license) 8 | 9 | ## Introduction 10 | 11 | This is a fork of [Microsoft's Windows File Manager](https://github.com/Microsoft/winfile). It is an attempt to get the 12 | application running on older versions of Windows such as Windows NT 3.x and Windows 9x. 13 | 14 | Currently the Unicode build successfully builds with Visual C++ 4.2, and the application runs under Windows NT 3.51 and 15 | Windows NT 4. Windows NT 3.1 is not yet supported because the application uses functions which didn't exist back then. 16 | Windows 9x support will also be tricky because there are lots of compiler errors in the ANSI build. If Windows 9x is 17 | possible though, who knows? Could it run under [Win32s](https://en.wikipedia.org/wiki/Win32s)? 18 | 19 | ## History 20 | 21 | The Windows File Manager was originally released with Windows 3.0 in the early 1990s. You can 22 | [read more about File Manager's history](https://en.wikipedia.org/wiki/File_Manager_(Windows)) on Wikipedia. 23 | 24 | ## License 25 | 26 | Copyright (c) Microsoft Corporation. All rights reserved. 27 | 28 | This repository contains additional changes made outside of Microsoft. 29 | 30 | Licensed under the [MIT](LICENSE) License. 31 | -------------------------------------------------------------------------------- /help/WINFILE.CHM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/help/WINFILE.CHM -------------------------------------------------------------------------------- /help/winfile.hlp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/help/winfile.hlp -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # This Makefile will build the WinFile Classic application. 2 | 3 | # Object files to create for the executable 4 | OBJS = dbg.o \ 5 | lfn.o \ 6 | lfnmisc.o \ 7 | numfmt.o \ 8 | res.o \ 9 | suggest.o \ 10 | tbar.o \ 11 | treectl.o \ 12 | wfassoc.o \ 13 | wfchgnot.o \ 14 | wfcomman.o \ 15 | wfcopy.o \ 16 | wfdir.o \ 17 | wfdirrd.o \ 18 | wfdirsrc.o \ 19 | wfdlgs.o \ 20 | wfdlgs2.o \ 21 | wfdlgs3.o \ 22 | wfdos.o \ 23 | wfdrives.o \ 24 | wfext.o \ 25 | wffile.o \ 26 | wfinfo.o \ 27 | wfinit.o \ 28 | wfmem.o \ 29 | wfprint.o \ 30 | wfsearch.o \ 31 | wftree.o \ 32 | wfutil.o \ 33 | winfile.o \ 34 | wnetcaps.o 35 | 36 | # Warnings to be raised by the C compiler 37 | WARNS = 38 | 39 | # Names of tools to use when building 40 | CC = gcc 41 | RC = windres 42 | EXE = WinFile.exe 43 | 44 | # Compiler flags 45 | CFLAGS = -O2 -std=c99 -D UNICODE -D _UNICODE -D _WIN32_IE=0x0400 -D WINVER=0x0400 -D FASTMOVE -D LFNCLIPBOARD -D MEMDOUBLE -D USELASTDOT ${WARNS} 46 | 47 | # Linker flags 48 | LDFLAGS = -s -lgdi32 -lcomctl32 -Wl,--subsystem,windows 49 | 50 | .PHONY: all clean deps 51 | 52 | # Build executable by default 53 | all: ${EXE} 54 | 55 | # Delete all build output 56 | clean: 57 | if exist ${EXE} del /q ${EXE} 58 | if exist *.obj del /q *.obj 59 | 60 | # Compile object files for executable 61 | %.o: %.c 62 | ${CC} ${CFLAGS} -c "$<" -o "$@" 63 | 64 | # Build the resources 65 | res.o: res.rc *.bmp *.cur *.ico 66 | ${RC} -i "$<" -o "$@" 67 | 68 | # Build the exectuable 69 | ${EXE}: ${OBJS} 70 | ${CC} -o "$@" ${OBJS} ${LDFLAGS} 71 | 72 | deps: 73 | ${CC} -MM *.c > Makefile.deps 74 | 75 | -include Makefile.deps 76 | -------------------------------------------------------------------------------- /src/Makefile.deps: -------------------------------------------------------------------------------- 1 | dbg.o: dbg.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h wfhelp.h \ 2 | wfmem.h wfinfo.h wfdlgs.h dbg.h 3 | lfn.o: lfn.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h wfhelp.h \ 4 | wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h 5 | lfnmisc.o: lfnmisc.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 6 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h 7 | numfmt.o: numfmt.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 8 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h 9 | suggest.o: suggest.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 10 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h suggest.db 11 | tbar.o: tbar.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 12 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h 13 | treectl.o: treectl.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 14 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h treectl.h lfn.h wfcopy.h dbg.h 15 | wfassoc.o: wfassoc.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 16 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h 17 | wfchgnot.o: wfchgnot.c winfile.h mpr.h fmifs.h suggest.h numfmt.h \ 18 | wfexti.h wfhelp.h wfmem.h wfinfo.h wfdlgs.h 19 | wfcomman.o: wfcomman.c winfile.h mpr.h fmifs.h suggest.h numfmt.h \ 20 | wfexti.h wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h wnetcaps.h 21 | wfcopy.o: wfcopy.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 22 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h 23 | wfdir.o: wfdir.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 24 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h 25 | wfdirrd.o: wfdirrd.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 26 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h 27 | wfdirsrc.o: wfdirsrc.c winfile.h mpr.h fmifs.h suggest.h numfmt.h \ 28 | wfexti.h wfhelp.h wfmem.h wfinfo.h wfdlgs.h 29 | wfdlgs.o: wfdlgs.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 30 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h 31 | wfdlgs2.o: wfdlgs2.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 32 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h wnetcaps.h 33 | wfdlgs3.o: wfdlgs3.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 34 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h 35 | wfdos.o: wfdos.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 36 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h 37 | wfdrives.o: wfdrives.c winfile.h mpr.h fmifs.h suggest.h numfmt.h \ 38 | wfexti.h wfhelp.h wfmem.h wfinfo.h wfdlgs.h treectl.h lfn.h wfcopy.h 39 | wfext.o: wfext.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 40 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h 41 | wffile.o: wffile.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 42 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h treectl.h 43 | wfinfo.o: wfinfo.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 44 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h wnetcaps.h 45 | wfinit.o: wfinit.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 46 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wnetcaps.h 47 | wfmem.o: wfmem.c wfmem.h 48 | wfprint.o: wfprint.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 49 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h 50 | wfsearch.o: wfsearch.c winfile.h mpr.h fmifs.h suggest.h numfmt.h \ 51 | wfexti.h wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h 52 | wftree.o: wftree.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 53 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h wfcopy.h 54 | wfutil.o: wfutil.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 55 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h 56 | winfile.o: winfile.c winfile.h mpr.h fmifs.h suggest.h numfmt.h wfexti.h \ 57 | wfhelp.h wfmem.h wfinfo.h wfdlgs.h lfn.h 58 | wnetcaps.o: wnetcaps.c winfile.h mpr.h fmifs.h suggest.h numfmt.h \ 59 | wfexti.h wfhelp.h wfmem.h wfinfo.h wfdlgs.h wnetcaps.h 60 | -------------------------------------------------------------------------------- /src/bitmap.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/bitmap.bmp -------------------------------------------------------------------------------- /src/bullet.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/bullet.bmp -------------------------------------------------------------------------------- /src/dbg.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | dbg.c 4 | 5 | Debugging utilities 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include "winfile.h" 13 | #include "dbg.h" 14 | 15 | #if DBG 16 | 17 | TCHAR szAsrtFmt[] = TEXT("Assertion Failure in %s at %d\n"); 18 | TCHAR szFmt[300]; 19 | unsigned long TraceFlags = 20 | BF_START 21 | // | BF_PROCTRACE 22 | // | BF_PARMTRACE 23 | // | BF_MSGTRACE 24 | // | BF_DEFMSGTRACE 25 | ; // set these to print on TRACEs 26 | 27 | unsigned long BreakFlags = 0 28 | // | BF_START 29 | ; // set these to break on TRACEs 30 | 31 | VOID DbgAssert( 32 | LPTSTR file, 33 | int line) 34 | { 35 | wsprintf(szFmt,szAsrtFmt,file,line); 36 | OutputDebugString(szFmt); 37 | // DbgPrint(szAsrtFmt, file, line); 38 | DebugBreak(); 39 | } 40 | 41 | 42 | VOID DbgTrace( 43 | DWORD tf, 44 | LPTSTR lpstr) 45 | { 46 | if (tf & TraceFlags) { 47 | wsprintf(szFmt,TEXT("%s\n"),lpstr); 48 | OutputDebugString(szFmt); 49 | // DbgPrint("%s\n", lpstr); 50 | if (tf & BreakFlags) { 51 | DebugBreak(); 52 | } 53 | } 54 | } 55 | 56 | 57 | VOID DbgBreak( 58 | DWORD bf, 59 | LPTSTR file, 60 | int line) 61 | { 62 | if (bf & BreakFlags) { 63 | wsprintf(szFmt,TEXT("BREAK at %s:%d\n"), file, line); 64 | OutputDebugString(szFmt); 65 | // DbgPrint("BREAK at %s:%d\n", file, line); 66 | DebugBreak(); 67 | } 68 | } 69 | 70 | 71 | VOID DbgPrint1( 72 | DWORD tf, 73 | LPTSTR fmt, 74 | LPTSTR p1) 75 | { 76 | if (tf & TraceFlags) { 77 | wsprintf(szFmt,fmt, p1); 78 | OutputDebugString(szFmt); 79 | // DbgPrint("%d",GetTickCount()); 80 | OutputDebugString(TEXT("\n")); 81 | // DbgPrint(fmt, p1); 82 | // DbgPrint("\n"); 83 | } 84 | if (tf & BreakFlags) { 85 | DebugBreak(); 86 | } 87 | } 88 | 89 | 90 | VOID DbgEnter( 91 | LPTSTR funName) 92 | { 93 | DbgPrint1(BF_PROCTRACE, TEXT("> %s "), funName); 94 | } 95 | 96 | VOID DbgLeave( 97 | LPTSTR funName) 98 | { 99 | DbgPrint1(BF_PROCTRACE, TEXT(" <%s "), funName); 100 | } 101 | 102 | 103 | VOID DbgTraceMessage( 104 | LPTSTR funName, 105 | LPTSTR msgName) 106 | { 107 | if (BF_MSGTRACE & TraceFlags) { 108 | wsprintf(szFmt,TEXT("MSG: %s - %s\n"), funName, msgName); 109 | OutputDebugString(szFmt); 110 | // DbgPrint("MSG: %s - %s\n", funName, msgName); 111 | } 112 | if (BF_MSGTRACE & BreakFlags) { 113 | DebugBreak(); 114 | } 115 | } 116 | 117 | VOID DbgTraceDefMessage( 118 | LPTSTR funName, 119 | WORD msgId) 120 | { 121 | if (BF_DEFMSGTRACE & TraceFlags) { 122 | wsprintf(szFmt,TEXT("MSG: %s - default(0x%x)\n"), funName, msgId); 123 | OutputDebugString(szFmt); 124 | // DbgPrint("MSG: %s - default(0x%x)\n", funName, msgId); 125 | } 126 | if (BF_DEFMSGTRACE & BreakFlags) { 127 | DebugBreak(); 128 | } 129 | } 130 | 131 | #endif // DBG 132 | -------------------------------------------------------------------------------- /src/dbg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | dbg.h 4 | 5 | Debugging utilities header 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #if DBG 13 | 14 | extern TCHAR szAsrtFmt[]; 15 | extern unsigned long BreakFlags; 16 | extern unsigned long TraceFlags; 17 | 18 | DWORD DbgPrint( LPTSTR Format, ...); 19 | VOID DbgAssert(LPTSTR file, int line); 20 | VOID DbgTrace(DWORD tf, LPTSTR lpstr); 21 | VOID DbgBreak(DWORD bf, LPTSTR file, int line); 22 | VOID DbgPrint1(DWORD tf, LPTSTR fmt, LPTSTR p1); 23 | VOID DbgEnter(LPTSTR funName); 24 | VOID DbgLeave(LPTSTR funName); 25 | VOID DbgTraceMessage(LPTSTR funName, LPTSTR msgName); 26 | VOID DbgTraceDefMessage(LPTSTR funName, WORD msgId); 27 | 28 | // BreakFlags flags 29 | 30 | #define BF_SPECIAL 0x00800000 31 | 32 | #define BF_WM_CREATE 0x02000000 33 | #define BF_DEFMSGTRACE 0x04000000 34 | #define BF_MSGTRACE 0x08000000 35 | 36 | #define BF_PARMTRACE 0x20000000 37 | #define BF_PROCTRACE 0x40000000 38 | #define BF_START 0x80000000 39 | 40 | #define ASSERT(fOk) if (!(fOk)) DbgAssert(__FILE__, __LINE__) 41 | #define FBREAK(bf) DbgBreak(bf, __FILE__, __LINE__) 42 | #define TRACE(tf, lpstr) DbgTrace(tf, lpstr) 43 | #define PRINT(tf, fmt, p1) DbgPrint1(tf, fmt, (LPTSTR)(p1)) 44 | #define MSG(funName, msgName) DbgTraceMessage(funName, msgName) 45 | #define DEFMSG(funName, wMsgId) DbgTraceDefMessage(funName, wMsgId) 46 | 47 | #define ENTER(funName) DbgEnter(funName) 48 | #define LEAVE(funName) DbgLeave(funName) 49 | 50 | 51 | #else // !DBG 52 | 53 | #define ASSERT(fOk) 54 | #define FBREAK(bf) 55 | #define TRACE(tf, lpstr) 56 | #define PRINT(tf, fmt, p1) 57 | #define MSG(funName, msgName) 58 | #define DEFMSG(funName, wMsgId) 59 | #define ENTER(funName) 60 | #define LEAVE(funName) 61 | 62 | #endif // DBG 63 | -------------------------------------------------------------------------------- /src/fmifs.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | fmifs.h 4 | 5 | This header file contains the specification of the interface 6 | between the file manager and fmifs.dll for the purposes of 7 | accomplishing IFS functions. 8 | 9 | Copyright (c) Microsoft Corporation. All rights reserved. 10 | Licensed under the MIT License. 11 | 12 | ********************************************************************/ 13 | 14 | #if !defined( _FMIFS_DEFN_ ) 15 | 16 | #define _FMIFS_DEFN_ 17 | 18 | 19 | // 20 | // These are the defines for 'PacketType'. 21 | // 22 | 23 | typedef enum _FMIFS_PACKET_TYPE { 24 | FmIfsPercentCompleted, 25 | FmIfsFormatReport, 26 | FmIfsInsertDisk, 27 | FmIfsIncompatibleFileSystem, 28 | FmIfsFormattingDestination, 29 | FmIfsIncompatibleMedia, 30 | FmIfsAccessDenied, 31 | FmIfsMediaWriteProtected, 32 | FmIfsCantLock, 33 | FmIfsCantQuickFormat, 34 | FmIfsIoError, 35 | FmIfsFinished, 36 | FmIfsBadLabel, 37 | #if defined( DBLSPACE_ENABLED ) 38 | FmIfsDblspaceCreateFailed, 39 | FmIfsDblspaceMountFailed, 40 | FmIfsDblspaceDriveLetterFailed, 41 | FmIfsDblspaceCreated, 42 | FmIfsDblspaceMounted, 43 | #endif // DBLSPACE_ENABLED 44 | FmIfsCheckOnReboot, 45 | FmIfsTextMessage, 46 | FmIfsHiddenStatus 47 | } FMIFS_PACKET_TYPE, *PFMIFS_PACKET_TYPE; 48 | 49 | typedef struct _FMIFS_PERCENT_COMPLETE_INFORMATION { 50 | ULONG PercentCompleted; 51 | } FMIFS_PERCENT_COMPLETE_INFORMATION, *PFMIFS_PERCENT_COMPLETE_INFORMATION; 52 | 53 | typedef struct _FMIFS_FORMAT_REPORT_INFORMATION { 54 | ULONG KiloBytesTotalDiskSpace; 55 | ULONG KiloBytesAvailable; 56 | } FMIFS_FORMAT_REPORT_INFORMATION, *PFMIFS_FORMAT_REPORT_INFORMATION; 57 | 58 | // The packet for FmIfsDblspaceCreated is a Unicode string 59 | // giving the name of the Compressed Volume File; it is not 60 | // necessarily zero-terminated. 61 | // 62 | 63 | #define DISK_TYPE_GENERIC 0 64 | #define DISK_TYPE_SOURCE 1 65 | #define DISK_TYPE_TARGET 2 66 | #define DISK_TYPE_SOURCE_AND_TARGET 3 67 | 68 | typedef struct _FMIFS_INSERT_DISK_INFORMATION { 69 | ULONG DiskType; 70 | } FMIFS_INSERT_DISK_INFORMATION, *PFMIFS_INSERT_DISK_INFORMATION; 71 | 72 | typedef struct _FMIFS_IO_ERROR_INFORMATION { 73 | ULONG DiskType; 74 | ULONG Head; 75 | ULONG Track; 76 | } FMIFS_IO_ERROR_INFORMATION, *PFMIFS_IO_ERROR_INFORMATION; 77 | 78 | typedef struct _FMIFS_FINISHED_INFORMATION { 79 | BOOLEAN Success; 80 | } FMIFS_FINISHED_INFORMATION, *PFMIFS_FINISHED_INFORMATION; 81 | 82 | typedef struct _FMIFS_CHECKONREBOOT_INFORMATION { 83 | OUT BOOLEAN QueryResult; // TRUE for "yes", FALSE for "no" 84 | } FMIFS_CHECKONREBOOT_INFORMATION, *PFMIFS_CHECKONREBOOT_INFORMATION; 85 | 86 | typedef enum _TEXT_MESSAGE_TYPE { 87 | MESSAGE_TYPE_PROGRESS, 88 | MESSAGE_TYPE_RESULTS, 89 | MESSAGE_TYPE_FINAL 90 | } TEXT_MESSAGE_TYPE, *PTEXT_MESSAGE_TYPE; 91 | 92 | typedef struct _FMIFS_TEXT_MESSAGE { 93 | IN TEXT_MESSAGE_TYPE MessageType; 94 | IN PSTR Message; 95 | } FMIFS_TEXT_MESSAGE, *PFMIFS_TEXT_MESSAGE; 96 | 97 | 98 | 99 | 100 | // 101 | // This is a list of supported floppy media types for format. 102 | // 103 | 104 | typedef enum _FMIFS_MEDIA_TYPE { 105 | FmMediaUnknown, 106 | FmMediaF5_160_512, // 5.25", 160KB, 512 bytes/sector 107 | FmMediaF5_180_512, // 5.25", 180KB, 512 bytes/sector 108 | FmMediaF5_320_512, // 5.25", 320KB, 512 bytes/sector 109 | FmMediaF5_320_1024, // 5.25", 320KB, 1024 bytes/sector 110 | FmMediaF5_360_512, // 5.25", 360KB, 512 bytes/sector 111 | FmMediaF3_720_512, // 3.5", 720KB, 512 bytes/sector 112 | FmMediaF5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector 113 | FmMediaF3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector 114 | FmMediaF3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector 115 | FmMediaF3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector 116 | FmMediaRemovable, // Removable media other than floppy 117 | FmMediaFixed, 118 | FmMediaF3_120M_512 // 3.5", 120M Floppy 119 | } FMIFS_MEDIA_TYPE, *PFMIFS_MEDIA_TYPE; 120 | 121 | // 122 | // The structure below defines information to be passed into ChkdskEx. 123 | // When new fields are added, the version number will have to be upgraded 124 | // so that only new code will reference those new fields. 125 | // 126 | typedef struct { 127 | UCHAR Major; // initial version is 1.0 128 | UCHAR Minor; 129 | ULONG Flags; 130 | PWSTR PathToCheck; 131 | } FMIFS_CHKDSKEX_PARAM, *PFMIFS_CHKDSKEX_PARAM; 132 | 133 | // 134 | // Internal definitions for Flags field in FMIFS_CHKDSKEX_PARAM 135 | // 136 | #define FMIFS_CHKDSK_RECOVER_FREE_SPACE 0x00000002UL 137 | #define FMIFS_CHKDSK_RECOVER_ALLOC_SPACE 0x00000004UL 138 | 139 | // 140 | // External definitions for Flags field in FMIFS_CHKDSKEX_PARAM 141 | // 142 | 143 | // FMIFS_CHKDSK_VERBOSE 144 | // - For FAT, chkdsk will print every filename being processed 145 | // - For NTFS, chkdsk will print clean up messages 146 | // FMIFS_CHKDSK_RECOVER 147 | // - Perform sector checking on free and allocated space 148 | // FMIFS_CHKDSK_EXTEND 149 | // - For NTFS, chkdsk will extend a volume 150 | // FMIFS_CHKDSK_DOWNGRADE (for NT 5 or later but obsolete anyway) 151 | // - For NTFS, this downgrade a volume from most recent NTFS version 152 | // FMIFS_CHKDSK_ENABLE_UPGRADE (for NT 5 or later but obsolete anyway) 153 | // - For NTFS, this upgrades a volume to most recent NTFS version 154 | // FMIFS_CHKDSK_CHECK_IF_DIRTY 155 | // - Perform consistency check only if the volume is dirty 156 | // FMIFS_CHKDSK_FORCE (for NT 5 or later) 157 | // - Forces the volume to dismount first if necessary 158 | // FMIFS_CHKDSK_SKIP_INDEX_SCAN 159 | // - Skip the scanning of each index entry 160 | // FMIFS_CHKDSK_SKIP_CYCLE_SCAN 161 | // - Skip the checking of cycles within the directory tree 162 | 163 | 164 | #define FMIFS_CHKDSK_VERBOSE 0x00000001UL 165 | #define FMIFS_CHKDSK_RECOVER (FMIFS_CHKDSK_RECOVER_FREE_SPACE | \ 166 | FMIFS_CHKDSK_RECOVER_ALLOC_SPACE) 167 | #define FMIFS_CHKDSK_EXTEND 0x00000008UL 168 | #define FMIFS_CHKDSK_DOWNGRADE 0x00000010UL 169 | #define FMIFS_CHKDSK_ENABLE_UPGRADE 0x00000020UL 170 | #define FMIFS_CHKDSK_CHECK_IF_DIRTY 0x00000080UL 171 | #define FMIFS_CHKDSK_FORCE 0x00000100UL 172 | #define FMIFS_CHKDSK_SKIP_INDEX_SCAN 0x00000200UL 173 | #define FMIFS_CHKDSK_SKIP_CYCLE_SCAN 0x00000400UL 174 | 175 | // 176 | // Function types/interfaces. 177 | // 178 | 179 | typedef BOOLEAN 180 | (*FMIFS_CALLBACK)( 181 | IN FMIFS_PACKET_TYPE PacketType, 182 | IN ULONG PacketLength, 183 | IN PVOID PacketData 184 | ); 185 | 186 | typedef 187 | VOID 188 | (*PFMIFS_FORMAT_ROUTINE)( 189 | IN PWSTR DriveName, 190 | IN FMIFS_MEDIA_TYPE MediaType, 191 | IN PWSTR FileSystemName, 192 | IN PWSTR Label, 193 | IN BOOLEAN Quick, 194 | IN FMIFS_CALLBACK Callback 195 | ); 196 | 197 | typedef 198 | VOID 199 | (*PFMIFS_FORMATEX_ROUTINE)( 200 | IN PWSTR DriveName, 201 | IN FMIFS_MEDIA_TYPE MediaType, 202 | IN PWSTR FileSystemName, 203 | IN PWSTR Label, 204 | IN BOOLEAN Quick, 205 | IN ULONG ClusterSize, 206 | IN FMIFS_CALLBACK Callback 207 | ); 208 | 209 | typedef 210 | BOOLEAN 211 | (*PFMIFS_ENABLECOMP_ROUTINE)( 212 | IN PWSTR DriveName, 213 | IN USHORT CompressionFormat 214 | ); 215 | 216 | 217 | typedef 218 | VOID 219 | (*PFMIFS_CHKDSK_ROUTINE)( 220 | IN PWSTR DriveName, 221 | IN PWSTR FileSystemName, 222 | IN BOOLEAN Fix, 223 | IN BOOLEAN Verbose, 224 | IN BOOLEAN OnlyIfDirty, 225 | IN BOOLEAN Recover, 226 | IN PWSTR PathToCheck, 227 | IN BOOLEAN Extend, 228 | IN FMIFS_CALLBACK Callback 229 | ); 230 | 231 | typedef 232 | VOID 233 | (*PFMIFS_CHKDSKEX_ROUTINE)( 234 | IN PWSTR DriveName, 235 | IN PWSTR FileSystemName, 236 | IN BOOLEAN Fix, 237 | IN PFMIFS_CHKDSKEX_PARAM Param, 238 | IN FMIFS_CALLBACK Callback 239 | ); 240 | 241 | typedef 242 | VOID 243 | (*PFMIFS_EXTEND_ROUTINE)( 244 | IN PWSTR DriveName, 245 | IN BOOLEAN Verify, 246 | IN FMIFS_CALLBACK Callback 247 | ); 248 | 249 | 250 | typedef 251 | VOID 252 | (*PFMIFS_DISKCOPY_ROUTINE)( 253 | IN PWSTR SourceDrive, 254 | IN PWSTR DestDrive, 255 | IN BOOLEAN Verify, 256 | IN FMIFS_CALLBACK Callback 257 | ); 258 | 259 | typedef 260 | BOOLEAN 261 | (*PFMIFS_SETLABEL_ROUTINE)( 262 | IN PWSTR DriveName, 263 | IN PWSTR Label 264 | ); 265 | 266 | typedef 267 | BOOLEAN 268 | (*PFMIFS_QSUPMEDIA_ROUTINE)( 269 | IN PWSTR DriveName, 270 | OUT PFMIFS_MEDIA_TYPE MediaTypeArray OPTIONAL, 271 | IN ULONG NumberOfArrayEntries, 272 | OUT PULONG NumberOfMediaTypes 273 | ); 274 | 275 | 276 | typedef 277 | VOID 278 | (*PFMIFS_DOUBLESPACE_CREATE_ROUTINE)( 279 | IN PWSTR HostDriveName, 280 | IN ULONG Size, 281 | IN PWSTR Label, 282 | IN PWSTR NewDriveName, 283 | IN FMIFS_CALLBACK Callback 284 | ); 285 | 286 | #if defined( DBLSPACE_ENABLED ) 287 | typedef 288 | VOID 289 | (*PFMIFS_DOUBLESPACE_DELETE_ROUTINE)( 290 | IN PWSTR DblspaceDriveName, 291 | IN FMIFS_CALLBACK Callback 292 | ); 293 | 294 | typedef 295 | VOID 296 | (*PFMIFS_DOUBLESPACE_MOUNT_ROUTINE)( 297 | IN PWSTR HostDriveName, 298 | IN PWSTR CvfName, 299 | IN PWSTR NewDriveName, 300 | IN FMIFS_CALLBACK Callback 301 | ); 302 | 303 | typedef 304 | VOID 305 | (*PFMIFS_DOUBLESPACE_DISMOUNT_ROUTINE)( 306 | IN PWSTR DblspaceDriveName, 307 | IN FMIFS_CALLBACK Callback 308 | ); 309 | 310 | typedef 311 | BOOLEAN 312 | (*PFMIFS_DOUBLESPACE_QUERY_INFO_ROUTINE)( 313 | IN PWSTR DosDriveName, 314 | OUT PBOOLEAN IsRemovable, 315 | OUT PBOOLEAN IsFloppy, 316 | OUT PBOOLEAN IsCompressed, 317 | OUT PBOOLEAN Error, 318 | OUT PWSTR NtDriveName, 319 | IN ULONG MaxNtDriveNameLength, 320 | OUT PWSTR CvfFileName, 321 | IN ULONG MaxCvfFileNameLength, 322 | OUT PWSTR HostDriveName, 323 | IN ULONG MaxHostDriveNameLength 324 | ); 325 | 326 | typedef 327 | BOOLEAN 328 | (*PFMIFS_DOUBLESPACE_SET_AUTMOUNT_ROUTINE)( 329 | IN BOOLEAN EnableAutomount 330 | ); 331 | 332 | #endif // DBLSPACE_ENABLED 333 | 334 | 335 | VOID 336 | Format( 337 | IN PWSTR DriveName, 338 | IN FMIFS_MEDIA_TYPE MediaType, 339 | IN PWSTR FileSystemName, 340 | IN PWSTR Label, 341 | IN BOOLEAN Quick, 342 | IN FMIFS_CALLBACK Callback 343 | ); 344 | 345 | VOID 346 | FormatEx( 347 | IN PWSTR DriveName, 348 | IN FMIFS_MEDIA_TYPE MediaType, 349 | IN PWSTR FileSystemName, 350 | IN PWSTR Label, 351 | IN BOOLEAN Quick, 352 | IN ULONG ClusterSize, 353 | IN FMIFS_CALLBACK Callback 354 | ); 355 | 356 | BOOLEAN 357 | EnableVolumeCompression( 358 | IN PWSTR DriveName, 359 | IN USHORT CompressionFormat 360 | ); 361 | 362 | VOID 363 | Chkdsk( 364 | IN PWSTR DriveName, 365 | IN PWSTR FileSystemName, 366 | IN BOOLEAN Fix, 367 | IN BOOLEAN Verbose, 368 | IN BOOLEAN OnlyIfDirty, 369 | IN BOOLEAN Recover, 370 | IN PWSTR PathToCheck, 371 | IN BOOLEAN Extend, 372 | IN FMIFS_CALLBACK Callback 373 | ); 374 | 375 | VOID 376 | ChkdskEx( 377 | IN PWSTR DriveName, 378 | IN PWSTR FileSystemName, 379 | IN BOOLEAN Fix, 380 | IN PFMIFS_CHKDSKEX_PARAM Param, 381 | IN FMIFS_CALLBACK Callback 382 | ); 383 | 384 | VOID 385 | Extend( 386 | IN PWSTR DriveName, 387 | IN BOOLEAN Verify, 388 | IN FMIFS_CALLBACK Callback 389 | ); 390 | 391 | VOID 392 | DiskCopy( 393 | IN PWSTR SourceDrive, 394 | IN PWSTR DestDrive, 395 | IN BOOLEAN Verify, 396 | IN FMIFS_CALLBACK Callback 397 | ); 398 | 399 | BOOLEAN 400 | SetLabel( 401 | IN PWSTR DriveName, 402 | IN PWSTR Label 403 | ); 404 | 405 | BOOLEAN 406 | QuerySupportedMedia( 407 | IN PWSTR DriveName, 408 | OUT PFMIFS_MEDIA_TYPE MediaTypeArray OPTIONAL, 409 | IN ULONG NumberOfArrayEntries, 410 | OUT PULONG NumberOfMediaTypes 411 | ); 412 | 413 | VOID 414 | DoubleSpaceCreate( 415 | IN PWSTR HostDriveName, 416 | IN ULONG Size, 417 | IN PWSTR Label, 418 | IN PWSTR NewDriveName, 419 | IN FMIFS_CALLBACK Callback 420 | ); 421 | 422 | #if defined( DBLSPACE_ENABLED ) 423 | 424 | VOID 425 | DoubleSpaceDelete( 426 | IN PWSTR DblspaceDriveName, 427 | IN FMIFS_CALLBACK Callback 428 | ); 429 | 430 | VOID 431 | DoubleSpaceMount( 432 | IN PWSTR HostDriveName, 433 | IN PWSTR CvfName, 434 | IN PWSTR NewDriveName, 435 | IN FMIFS_CALLBACK Callback 436 | ); 437 | 438 | VOID 439 | DoubleSpaceDismount( 440 | IN PWSTR DblspaceDriveName, 441 | IN FMIFS_CALLBACK Callback 442 | ); 443 | 444 | // Miscellaneous prototypes: 445 | // 446 | BOOLEAN 447 | FmifsQueryDriveInformation( 448 | IN PWSTR DosDriveName, 449 | OUT PBOOLEAN IsRemovable, 450 | OUT PBOOLEAN IsFloppy, 451 | OUT PBOOLEAN IsCompressed, 452 | OUT PBOOLEAN Error, 453 | OUT PWSTR NtDriveName, 454 | IN ULONG MaxNtDriveNameLength, 455 | OUT PWSTR CvfFileName, 456 | IN ULONG MaxCvfFileNameLength, 457 | OUT PWSTR HostDriveName, 458 | IN ULONG MaxHostDriveNameLength 459 | ); 460 | 461 | BOOLEAN 462 | FmifsSetAutomount( 463 | IN BOOLEAN EnableAutomount 464 | ); 465 | 466 | #endif 467 | 468 | 469 | #endif // _FMIFS_DEFN_ 470 | -------------------------------------------------------------------------------- /src/lfn.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | lfn.c 4 | 5 | This file contains code that combines winnet long filename API's and 6 | the DOS INT 21h API's into a single interface. Thus, other parts of 7 | Winfile call a single piece of code with no worries about the 8 | underlying interface. 9 | 10 | Copyright (c) Microsoft Corporation. All rights reserved. 11 | Licensed under the MIT License. 12 | 13 | ********************************************************************/ 14 | 15 | #include "winfile.h" 16 | #include "lfn.h" // lfn includes 17 | #include "wfcopy.h" 18 | 19 | BOOL IsFATName(LPTSTR pName); 20 | 21 | 22 | /* WFFindFirst - 23 | * 24 | * returns: 25 | * TRUE for success - lpFind->fd,hFindFileset,attrFilter set. 26 | * FALSE for failure 27 | * 28 | * Performs the FindFirst operation and the first WFFindNext. 29 | */ 30 | 31 | BOOL 32 | WFFindFirst( 33 | LPLFNDTA lpFind, 34 | LPTSTR lpName, 35 | DWORD dwAttrFilter) 36 | { 37 | INT nLen; 38 | LPTSTR pEnd; 39 | 40 | // 41 | // We OR these additional bits because of the way DosFindFirst works 42 | // in Windows. It returns the files that are specified by the attrfilter 43 | // and ORDINARY files too. 44 | // 45 | 46 | dwAttrFilter |= ATTR_ARCHIVE | ATTR_READONLY | ATTR_NORMAL | 47 | ATTR_TEMPORARY | ATTR_COMPRESSED | ATTR_NOT_INDEXED; 48 | lpFind->hFindFile = FindFirstFile(lpName, &lpFind->fd); 49 | 50 | lpFind->fd.dwFileAttributes &= ATTR_USED; 51 | 52 | // 53 | // Keep track of length 54 | // 55 | nLen = lstrlen(lpName); 56 | pEnd = &lpName[nLen-1]; 57 | 58 | while (CHAR_BACKSLASH != *pEnd) { 59 | pEnd--; 60 | nLen--; 61 | } 62 | 63 | lpFind->nSpaceLeft = MAXPATHLEN-nLen-1; 64 | 65 | if (lpFind->hFindFile != INVALID_HANDLE_VALUE) { 66 | lpFind->dwAttrFilter = dwAttrFilter; 67 | if ((~dwAttrFilter & lpFind->fd.dwFileAttributes) == 0L || 68 | WFFindNext(lpFind)) { 69 | 70 | lpFind->err = 0; 71 | 72 | return(TRUE); 73 | } else { 74 | lpFind->err = GetLastError(); 75 | 76 | WFFindClose(lpFind); 77 | return(FALSE); 78 | } 79 | } else { 80 | lpFind->err = GetLastError(); 81 | return(FALSE); 82 | } 83 | } 84 | 85 | 86 | 87 | /* WFFindNext - 88 | * 89 | * Performs a single file FindNext operation. Only returns TRUE if a 90 | * file matching the dwAttrFilter is found. On failure WFFindClose is 91 | * called. 92 | */ 93 | BOOL 94 | WFFindNext(LPLFNDTA lpFind) 95 | { 96 | while (FindNextFile(lpFind->hFindFile, &lpFind->fd)) { 97 | 98 | lpFind->fd.dwFileAttributes &= ATTR_USED; 99 | 100 | // 101 | // only pick files that fit attr filter 102 | // 103 | if ((lpFind->fd.dwFileAttributes & ~lpFind->dwAttrFilter) != 0) 104 | continue; 105 | 106 | // 107 | // Don't allow viewage of files > MAXPATHLEN 108 | // 109 | if (lstrlen(lpFind->fd.cFileName) > lpFind->nSpaceLeft) { 110 | 111 | if (!lpFind->fd.cAlternateFileName[0] || 112 | lstrlen(lpFind->fd.cAlternateFileName) > lpFind->nSpaceLeft) { 113 | 114 | continue; 115 | } 116 | 117 | // 118 | // Force longname to be same as shortname 119 | // 120 | lstrcpy(lpFind->fd.cFileName, lpFind->fd.cAlternateFileName); 121 | } 122 | 123 | return TRUE; 124 | } 125 | 126 | lpFind->err = GetLastError(); 127 | return(FALSE); 128 | } 129 | 130 | 131 | /* WFFindClose - 132 | * 133 | * performs the find close operation 134 | */ 135 | BOOL 136 | WFFindClose(LPLFNDTA lpFind) 137 | { 138 | BOOL bRet; 139 | 140 | // ASSERT(lpFind->hFindFile != INVALID_HANDLE_VALUE); 141 | 142 | // This section WAS #defined DBG, but removed 143 | // Basically, when copying a directory into ITS subdirectory, we detect 144 | // an error. Since the error is detected late (after the file handle 145 | // is closed), we jump to error code that pops up a message, then tries 146 | // to close the same handle. This cause the a bomb. By un #define DBG ing 147 | // this code, we allow multiple file closes. This is sloppy, but works. 148 | 149 | // A better solution is to put another flag in the error code "ret" in 150 | // WFMoveCopyDriver right after it calls GetNextPair. 151 | 152 | if (lpFind->hFindFile == INVALID_HANDLE_VALUE) { 153 | return(FALSE); 154 | } 155 | 156 | bRet = FindClose(lpFind->hFindFile); 157 | 158 | // This section WAS #defined DBG, but removed 159 | lpFind->hFindFile = INVALID_HANDLE_VALUE; 160 | 161 | return(bRet); 162 | } 163 | 164 | 165 | 166 | 167 | /* WFIsDir 168 | * 169 | * Determines if the specified path is a directory 170 | */ 171 | BOOL 172 | WFIsDir(LPTSTR lpDir) 173 | { 174 | DWORD attr = GetFileAttributes(lpDir); 175 | 176 | if (attr & 0x8000) // BUG: what is this constant??? 177 | return FALSE; 178 | 179 | if (attr & ATTR_DIR) 180 | return TRUE; 181 | 182 | return FALSE; 183 | } 184 | 185 | /* GetNameType - 186 | * 187 | * Shell around LFNParse. Classifies name. 188 | * 189 | * NOTE: this should work on unqualified names. currently this isn't 190 | * very useful. 191 | */ 192 | DWORD 193 | GetNameType(LPTSTR lpName) 194 | { 195 | if (CHAR_COLON == *(lpName+1)) { 196 | if (!WF_IsLFNDrive(lpName)) 197 | return FILE_83_CI; 198 | } else if(IsFATName(lpName)) 199 | return FILE_83_CI; 200 | 201 | return(FILE_LONG); 202 | } 203 | 204 | BOOL 205 | WF_IsLFNDrive(LPTSTR szDrive) 206 | { 207 | DRIVE drive = DRIVEID(szDrive); 208 | 209 | if (CHAR_COLON == szDrive[1]) { 210 | 211 | U_VolInfo(drive); 212 | 213 | if (GETRETVAL(VolInfo,drive)) 214 | return FALSE; 215 | 216 | return aDriveInfo[drive].dwMaximumComponentLength == MAXDOSFILENAMELEN-1 ? 217 | FALSE : 218 | TRUE; 219 | 220 | } else { 221 | 222 | DWORD dwVolumeSerialNumber; 223 | DWORD dwMaximumComponentLength; 224 | DWORD dwFileSystemFlags; 225 | 226 | INT i; 227 | LPTSTR p; 228 | 229 | TCHAR szRootPath[MAXPATHLEN]; 230 | 231 | if (ISUNCPATH(szDrive)) { 232 | 233 | lstrcpy(szRootPath, szDrive); 234 | 235 | // 236 | // Stop at "\\foo\bar" 237 | // 238 | for (i=0, p=szRootPath+2; *p && i<2; p++) { 239 | 240 | if (CHAR_BACKSLASH == *p) 241 | i++; 242 | } 243 | 244 | switch (i) { 245 | case 0: 246 | 247 | return FALSE; 248 | 249 | case 1: 250 | 251 | if (lstrlen(szRootPath) < MAXPATHLEN-2) { 252 | 253 | *p = CHAR_BACKSLASH; 254 | *(p+1) = CHAR_NULL; 255 | 256 | } else { 257 | 258 | return FALSE; 259 | } 260 | break; 261 | 262 | case 2: 263 | 264 | *p = CHAR_NULL; 265 | break; 266 | } 267 | } 268 | 269 | if (GetVolumeInformation( szRootPath, 270 | NULL, 271 | 0, 272 | &dwVolumeSerialNumber, 273 | &dwMaximumComponentLength, 274 | &dwFileSystemFlags, 275 | NULL, 276 | 0 )) 277 | { 278 | if (dwMaximumComponentLength == MAXDOSFILENAMELEN - 1) 279 | return FALSE; 280 | else 281 | return TRUE; 282 | } 283 | return FALSE; 284 | } 285 | } 286 | 287 | BOOL 288 | IsFATName( 289 | IN LPTSTR FileName 290 | ) 291 | /*++ 292 | 293 | Routine Description: 294 | 295 | This routine computes whether or not the given file name would 296 | be appropriate under DOS's 8.3 naming convention. 297 | 298 | Arguments: 299 | 300 | FileName - Supplies the file name to check. 301 | 302 | Return Value: 303 | 304 | FALSE - The supplied name is not a DOS file name. 305 | TRUE - The supplied name is a valid DOS file name. 306 | 307 | --*/ 308 | { 309 | ULONG i, n, name_length, ext_length; 310 | BOOLEAN dot_yet; 311 | PTUCHAR p; 312 | 313 | n = lstrlen(FileName); 314 | p = (PTUCHAR) FileName; 315 | name_length = n; 316 | ext_length = 0; 317 | 318 | if (n > 12) { 319 | return FALSE; 320 | } 321 | 322 | dot_yet = FALSE; 323 | for (i = 0; i < n; i++) { 324 | 325 | if (p[i] < 32) { 326 | return FALSE; 327 | } 328 | 329 | switch (p[i]) { 330 | case CHAR_STAR: 331 | case CHAR_QUESTION: 332 | case CHAR_SLASH: 333 | case CHAR_BACKSLASH: 334 | case CHAR_PIPE: 335 | case CHAR_COMMA: 336 | case CHAR_SEMICOLON: 337 | case CHAR_COLON: 338 | case CHAR_PLUS: 339 | case CHAR_EQUAL: 340 | case CHAR_LESS: 341 | case CHAR_GREATER: 342 | case CHAR_OPENBRACK: 343 | case CHAR_CLOSEBRACK: 344 | case CHAR_DQUOTE: 345 | return FALSE; 346 | 347 | case CHAR_DOT: 348 | if (dot_yet) { 349 | return FALSE; 350 | } 351 | 352 | dot_yet = TRUE; 353 | name_length = i; 354 | ext_length = n - i - 1; 355 | break; 356 | } 357 | } 358 | 359 | if (!name_length) { 360 | return dot_yet && n == 1; 361 | } 362 | 363 | if (name_length > 8 || p[name_length - 1] == CHAR_SPACE) { 364 | return FALSE; 365 | } 366 | 367 | if (!ext_length) { 368 | return !dot_yet; 369 | } 370 | 371 | if (ext_length > 3 || p[name_length + 1 + ext_length - 1] == CHAR_SPACE) { 372 | return FALSE; 373 | } 374 | 375 | return TRUE; 376 | } 377 | 378 | 379 | BOOL 380 | IsLFN(LPTSTR pName) 381 | { 382 | return !IsFATName(pName); 383 | } 384 | 385 | // LFNMergePath 386 | // 387 | // IN: lpMask = path with wildcard to be expanded (relative or full) 388 | // NonZero. 389 | // lpFile = non-wildcarded filename (filespec only or "\" for root) 390 | // 391 | // OUT: True (no error checking) 392 | // 393 | // Note: This is not the same as LFNParse, since here, lpMask can be an 394 | // absolute path, while lpFile is almost always a file spec. 395 | // (or \). LFNParse assumes that lpFile a file path. 396 | // You may call LFNParse, and this will work since lpFile 397 | // just happens to be a filespec rather than a fully qualified path. 398 | // LFNParse will die lpFile is fully qualified. 399 | 400 | BOOL 401 | LFNMergePath(LPTSTR lpMask, LPTSTR lpFile) 402 | { 403 | TCHAR szT[MAXPATHLEN*2]; 404 | INT iResStrlen; 405 | 406 | // 407 | // Get the directory portion (from root to parent) of the destination. 408 | // ( a:\joe\martha\wilcox.* -> a:\joe\martha\ ) 409 | // 410 | lstrcpy( szT, lpMask ); 411 | RemoveLast( szT ); 412 | 413 | // 414 | // Add a blackslash if there isn't one already. 415 | // 416 | AddBackslash(szT); 417 | 418 | // hack fix: Normally, I_LFNEditName will return a:\xxxx\\. when lpFile 419 | // is "\\" (C-style string, so the first \ is an escape char). 420 | // Only do the file masking if lpFile is NOT the root directory. 421 | // If it is, the return value is a:\xxxx\ which is what is expected 422 | // when a root is merged. 423 | 424 | if (!( CHAR_BACKSLASH == lpFile[0] && CHAR_NULL == lpFile[1] )) { 425 | 426 | iResStrlen = lstrlen( szT ); 427 | 428 | I_LFNEditName(lpFile, // jack.bat 429 | FindFileName( lpMask ), // *.* 430 | szT + iResStrlen, // right after "a:\more\beer\" 431 | COUNTOF(szT) - iResStrlen); 432 | 433 | // If there is a trailing '.', always but always kill it. 434 | 435 | iResStrlen = lstrlen( szT ); 436 | if ( CHAR_DOT == szT[ iResStrlen-1 ] ) 437 | szT[ iResStrlen-1 ] = CHAR_NULL; 438 | } 439 | 440 | lstrcpy(lpMask, szT); 441 | return TRUE; 442 | } 443 | 444 | /* WFCopy 445 | * 446 | * Copies files 447 | */ 448 | DWORD 449 | WFCopy(LPTSTR pszFrom, LPTSTR pszTo) 450 | { 451 | DWORD dwRet; 452 | TCHAR szTemp[MAXPATHLEN]; 453 | 454 | Notify(hdlgProgress, IDS_COPYINGMSG, pszFrom, pszTo); 455 | 456 | if (CopyFile(pszFrom, pszTo, FALSE)) 457 | { 458 | ChangeFileSystem(FSC_CREATE, pszTo, NULL); 459 | dwRet = 0; 460 | } 461 | else 462 | { 463 | dwRet = GetLastError(); 464 | if (dwRet == ERROR_INVALID_NAME) 465 | { 466 | // 467 | // Try copying without the file name in the TO field. 468 | // This is for the case where it's trying to copy to a print 469 | // share. CopyFile fails if the file name is tacked onto the 470 | // end in the case of printer shares. 471 | // 472 | lstrcpy(szTemp, pszTo); 473 | RemoveLast(szTemp); 474 | if (CopyFile(pszFrom, szTemp, FALSE)) 475 | { 476 | ChangeFileSystem(FSC_CREATE, szTemp, NULL); 477 | dwRet = 0; 478 | } 479 | 480 | // else ... use the original dwRet value. 481 | } 482 | } 483 | 484 | return (dwRet); 485 | } 486 | 487 | /* WFRemove 488 | * 489 | * Deletes files 490 | */ 491 | DWORD 492 | WFRemove(LPTSTR pszFile) 493 | { 494 | DWORD dwRet; 495 | 496 | dwRet = FileRemove(pszFile); 497 | if (!dwRet) 498 | ChangeFileSystem(FSC_DELETE,pszFile,NULL); 499 | 500 | return dwRet; 501 | } 502 | 503 | /* WFMove 504 | * 505 | * Moves files on a volume 506 | */ 507 | DWORD 508 | WFMove(LPTSTR pszFrom, LPTSTR pszTo, PBOOL pbErrorOnDest, BOOL bSilent) 509 | { 510 | DWORD dwRet; 511 | 512 | *pbErrorOnDest = FALSE; 513 | dwRet = FileMove(pszFrom,pszTo, pbErrorOnDest, bSilent); 514 | 515 | if (!dwRet) 516 | ChangeFileSystem(FSC_RENAME,pszFrom,pszTo); 517 | 518 | return dwRet; 519 | } 520 | -------------------------------------------------------------------------------- /src/lfn.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | lfn.h 4 | 5 | declaration of lfn aware functions 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #define CCHMAXFILE MAXPATHLEN // max size of a long name 13 | #define CCHMAXPATHCOMP 256 14 | #define LFNCANON_MASK 1 15 | #define PATHLEN1_1 13 16 | 17 | #define FILE_83_CI 0 18 | #define FILE_83_CS 1 19 | #define FILE_LONG 2 20 | 21 | #define ERROR_OOM 8 22 | 23 | // we need to add an extra field to distinguish DOS vs. LFNs 24 | 25 | typedef struct { 26 | HANDLE hFindFile; // handle returned by FindFirstFile() 27 | DWORD dwAttrFilter; // search attribute mask. 28 | DWORD err; // error info if failure. 29 | WIN32_FIND_DATA fd; // FindFirstFile() data strucrure; 30 | INT nSpaceLeft; // Space left for deeper paths 31 | } LFNDTA, *LPLFNDTA, * PLFNDTA; 32 | 33 | VOID LFNInit( VOID ); 34 | VOID InvalidateVolTypes( VOID ); 35 | 36 | DWORD GetNameType(LPTSTR); 37 | BOOL IsLFN(LPTSTR pName); 38 | 39 | BOOL WFFindFirst(LPLFNDTA lpFind, LPTSTR lpName, DWORD dwAttrFilter); 40 | BOOL WFFindNext(LPLFNDTA); 41 | BOOL WFFindClose(LPLFNDTA); 42 | 43 | 44 | DWORD I_LFNCanon( USHORT CanonType, LPTSTR InFile, LPTSTR OutFile ); 45 | DWORD LFNParse(LPTSTR,LPTSTR,LPTSTR); 46 | WORD I_LFNEditName( LPTSTR lpSrc, LPTSTR lpEd, LPTSTR lpRes, INT iResBufSize ); 47 | 48 | BOOL WFIsDir(LPTSTR); 49 | BOOL LFNMergePath(LPTSTR,LPTSTR); 50 | 51 | BOOL IsLFNSelected(VOID); 52 | -------------------------------------------------------------------------------- /src/lfnmisc.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | lfnmisc.c 4 | 5 | Long filename support for windows: miscellaneous functions 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include 13 | 14 | #include "winfile.h" 15 | #include "lfn.h" 16 | 17 | 18 | #define FIL_STANDARD 1 19 | 20 | // Local Function prototypes 21 | DWORD I_Is83File( LPTSTR lpFile ) ; 22 | 23 | /**************************************************************************** 24 | * 25 | * I_LFNCanon() 26 | * 27 | * Purpose: basic canonicalization routine for LFN names. 28 | * 29 | * Input: 30 | * CanonType Type of canonization required 31 | * InFile points to a file name 32 | * 33 | * Output: 34 | * OutFile receives canonicalized name. 35 | * 36 | * Returns: 37 | * 0 If filename has been canonicalized 38 | * INVALID_PARAMETER If filename has invalid characters 39 | * 40 | ****************************************************************************/ 41 | DWORD 42 | I_LFNCanon(WORD CanonType, LPTSTR InFile, LPTSTR OutFile) 43 | { 44 | LPTSTR ins = InFile; 45 | LPTSTR outs = OutFile; 46 | unsigned size; 47 | unsigned trails; 48 | TCHAR c; 49 | 50 | if (!InFile || !OutFile) 51 | return ERROR_INVALID_PARAMETER; 52 | 53 | if (*InFile == CHAR_NULL) 54 | return ERROR_INVALID_PARAMETER; 55 | 56 | 57 | /* First, check if we have a fully qualified name, or a relative name */ 58 | if (*InFile != CHAR_BACKSLASH && *InFile != CHAR_SLASH) { 59 | if (isalpha(*InFile)) { 60 | if (InFile[1] == CHAR_COLON) { 61 | *outs++ = *ins++; 62 | *outs++ = *ins++; // Copy over the drive and colon 63 | } 64 | } 65 | } else { 66 | ins++; 67 | *outs++ = CHAR_BACKSLASH; 68 | } 69 | 70 | /* Note: When calculating size, we ignore the d:\ that may appear. This 71 | * is because that is not considered part of the path by OS/2. IT IS THE 72 | * RESPONSIBILITY OF THE CALLING FUNCTION TO RESERVE ENOUGH SPACE FOR THE 73 | * CANON NAME, WHICH CAN BE EITHER 256 or 260. 74 | */ 75 | 76 | size = 0; 77 | do { 78 | c = *ins++; 79 | if ((c < 0x001f && c != CHAR_NULL) || (c == CHAR_DQUOTE) || (c == CHAR_COLON) || (c == CHAR_PIPE) || 80 | (c == CHAR_GREATER) || (c == CHAR_LESS)) { 81 | *OutFile = CHAR_NULL; 82 | return ERROR_INVALID_PARAMETER; 83 | } 84 | if (CanonType != LFNCANON_MASK && ((c == CHAR_STAR) || (c == CHAR_QUESTION))) { 85 | *OutFile = CHAR_NULL; 86 | return ERROR_INVALID_PARAMETER; 87 | } 88 | if (c == CHAR_SLASH) 89 | c = CHAR_BACKSLASH; // Convert / to \ for canon 90 | 91 | if (c == CHAR_BACKSLASH || c == CHAR_NULL) { // Component separator: Trim file name 92 | 93 | /* We have to special case . and .. . we resolve, but .. we pass 94 | * through. 95 | */ 96 | if (outs > OutFile) { 97 | if (*(outs - 1) == CHAR_DOT) { 98 | if ((outs - 1) == OutFile || *(outs - 2) == CHAR_BACKSLASH) { // Single dot 99 | *(outs--) = c; 100 | if (size) 101 | size--; 102 | continue; 103 | } 104 | if (*(outs - 2) == CHAR_DOT) { // Possible .. 105 | if ((outs - 2) == OutFile || *(outs - 3) == CHAR_BACKSLASH || 106 | *(outs - 3) == CHAR_COLON) { 107 | *outs++ = c; 108 | size++; 109 | continue; 110 | } 111 | } 112 | } 113 | } 114 | 115 | /* Okay, the component is neither a . nor a .. so we go into trim 116 | * trailing dots and spaces mode. 117 | */ 118 | trails = 0; 119 | while (outs > OutFile && ((*(outs-1) == CHAR_DOT || *(outs-1) == CHAR_SPACE) 120 | && (*(outs-1) != CHAR_BACKSLASH && *(outs - 1) != CHAR_COLON)) ) { 121 | outs--; 122 | trails++; 123 | if (size) 124 | size--; 125 | } 126 | if (outs == OutFile) { 127 | *OutFile = CHAR_NULL; 128 | return ERROR_INVALID_PARAMETER; 129 | } 130 | if (outs > OutFile && *(outs-1) == CHAR_BACKSLASH) { 131 | *OutFile = CHAR_NULL; 132 | return ERROR_INVALID_PARAMETER; 133 | } 134 | } 135 | *outs++ = c; 136 | size++; 137 | if (size > CCHMAXPATHCOMP) { 138 | *OutFile = CHAR_NULL; 139 | return ERROR_INVALID_PARAMETER; 140 | } 141 | } while (c); 142 | 143 | /* Last check: We don't allow paths to end in \ or /. Since / has been 144 | * mapped to \, we just check for \ 145 | */ 146 | if (outs != OutFile) 147 | if (*(outs-1) == CHAR_BACKSLASH) { 148 | *OutFile = CHAR_NULL; 149 | return ERROR_INVALID_PARAMETER; 150 | } 151 | 152 | return 0; 153 | 154 | } 155 | 156 | // Manifests local to LFNParse 157 | #define FAT_FILE_COMP_LENGTH 8 158 | #define FAT_FILE_EXT_LENGTH 3 159 | #define DRIVE_COLON CHAR_COLON 160 | #define PATH_SEPARATOR CHAR_BACKSLASH 161 | #define DOT CHAR_DOT 162 | 163 | static TCHAR ach83InvalidChars[] = TEXT("<>|[]=;+/, \"\x01\x02\x03\x04\x05\x06\x07\ 164 | \x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\ 165 | \x1b\x1c\x1d\x1e\x1f") ; 166 | 167 | 168 | /***************************************************************************** 169 | * 170 | * I_LFNEditName 171 | * 172 | * Purpose: Given a file and a mask, I_LFNCombine will combine the two 173 | * according to the rules stated in the OS/2 function DosEditName. 174 | * 175 | * Entry: 176 | * lpSrc Pointer to file 177 | * lpEd Pointer to edit mask 178 | * lpRes Results of combining lpMask & lpFile 179 | * uResBuffSize Size of the result buffer 180 | * 181 | * Exit: 182 | * 183 | * lpResult contains the combined lpFile and lpMask. 184 | * 185 | * 186 | * Return Codes: 187 | * The return code is NO_ERROR if successful or: 188 | * ERROR_INVALID_PARAMETER A malformed name was passed or the result 189 | * buffer was too small. 190 | * 191 | *****************************************************************************/ 192 | 193 | WORD I_LFNEditName( LPTSTR lpSrc, LPTSTR lpEd, LPTSTR lpRes, INT iResBufSize ) 194 | { 195 | INT ResLen = 0; // Length of result 196 | 197 | // This is turned off until we agree 198 | // that cmd operates in the same way 199 | 200 | #ifdef USELASTDOT 201 | LPTSTR lpChar; 202 | 203 | // 204 | // We have a special case hack for the the dot, since when we do a 205 | // rename from foo.bar.baz to *.txt, we want to use the last dot, not 206 | // the first one (desired result = foo.bar.txt, not foo.txt) 207 | // 208 | // We find the dot (GetExtension rets first char after last dot if there 209 | // is a dot), then if the delimiter for the '*' is a CHAR_DOT, we continue 210 | // copying until we get to the last dot instead of finding the first one. 211 | // 212 | 213 | lpChar = GetExtension(lpSrc); 214 | if (*lpChar) { 215 | lpChar--; 216 | } else { 217 | lpChar = NULL; 218 | } 219 | #endif 220 | 221 | while (*lpEd) { 222 | 223 | if (ResLen < iResBufSize) { 224 | 225 | switch (*lpEd) { 226 | 227 | case CHAR_STAR: 228 | { 229 | TCHAR delimit = *(lpEd+1); 230 | 231 | #ifdef USELASTDOT 232 | 233 | // 234 | // For all other delimiters, we use the first 235 | // occurance (e.g., *f.txt). 236 | // 237 | if (CHAR_DOT != delimit) 238 | lpChar = NULL; 239 | 240 | while ((ResLen < iResBufSize) && ( *lpSrc != CHAR_NULL ) && 241 | ( *lpSrc != delimit || (lpChar && lpChar != lpSrc ))) { 242 | #else 243 | while ((ResLen < iResBufSize) && 244 | ( *lpSrc != CHAR_NULL ) && ( *lpSrc != delimit )) { 245 | #endif 246 | 247 | if (ResLen < iResBufSize) { 248 | 249 | *(lpRes++) = *(lpSrc++); 250 | ResLen++; 251 | } 252 | else 253 | return ERROR_INVALID_PARAMETER ; 254 | } 255 | } 256 | break; 257 | 258 | 259 | case CHAR_QUESTION: 260 | if ((*lpSrc != DOT ) && (*lpSrc != CHAR_NULL)) { 261 | 262 | if (ResLen < iResBufSize) { 263 | 264 | *(lpRes++) = *(lpSrc++); 265 | ResLen++; 266 | } 267 | else 268 | return ERROR_INVALID_PARAMETER ; 269 | } 270 | break; 271 | 272 | case CHAR_DOT: 273 | while ((*lpSrc != DOT ) && (*lpSrc != CHAR_NULL)) 274 | lpSrc++; 275 | 276 | *(lpRes++) = DOT ; // from EditMask, even if src doesn't 277 | // have one, so always put one. 278 | ResLen++; 279 | if (*lpSrc) // point one past CHAR_DOT 280 | lpSrc++; 281 | break; 282 | 283 | default: 284 | if ((*lpSrc != DOT ) && (*lpSrc != CHAR_NULL)) { 285 | 286 | lpSrc++; 287 | } 288 | 289 | if (ResLen < iResBufSize) { 290 | 291 | *(lpRes++) = *lpEd; 292 | ResLen++; 293 | } 294 | else 295 | return ERROR_INVALID_PARAMETER ; 296 | break; 297 | } 298 | lpEd++; 299 | 300 | } 301 | else { 302 | 303 | return ERROR_INVALID_PARAMETER ; 304 | } 305 | } 306 | 307 | if ((ResLen) < iResBufSize) { 308 | *lpRes = CHAR_NULL; 309 | return NO_ERROR ; 310 | } 311 | else 312 | return ERROR_INVALID_PARAMETER ; 313 | } 314 | -------------------------------------------------------------------------------- /src/mcopy.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/mcopy.cur -------------------------------------------------------------------------------- /src/mmove.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/mmove.cur -------------------------------------------------------------------------------- /src/mpr.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | mpr.h 4 | 5 | Standard MPR Header File for NT-WIN32 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include 13 | #ifndef _MPR_H_INCLUDED 14 | #define _MPR_H_INCLUDED 15 | 16 | //For restoring connection stuff. Add by congpay. 17 | // const used by connect.c 18 | #define SHOW_CONNECTION (WM_USER+200) 19 | #define DO_PASSWORD_DIALOG (WM_USER + 201) 20 | #define DO_ERROR_DIALOG (WM_USER + 202) 21 | 22 | // types used by connect.c 23 | 24 | typedef struct _CONNECTION_INFO *LPCONNECTION_INFO; 25 | 26 | // The following two structures are used by two threads in mpr.dll and 27 | // mprui.dll to share data. 28 | 29 | typedef struct _PARAMETERS { 30 | HWND hDlg; 31 | HANDLE hDlgCreated; //Initialized in WNetRestoreConnection 32 | HANDLE hDlgFailed; //Initialized in WNetRestoreConnection 33 | HANDLE hDonePassword; //Initialized in WNetRestoreConnection 34 | TCHAR * pchResource; //ShowReconnectDialog, DoRestoreConnection 35 | TCHAR * pchUserName; //For DoPasswordDialog 36 | TCHAR passwordBuffer[UNLEN+1]; //Used by WNetRestoreThisConnection 37 | BOOL fSuccess; //For the DoPasswordDialog 38 | BOOL fDidCancel; //For the DoPasswordDialog 39 | BOOL fDownLevel; //FALSE if error==ERROR_LOGON_FAILURE 40 | BOOL fTerminateThread; //TRUE if we want the second thread to be end 41 | DWORD status; //return value from DoRestoreConnection 42 | DWORD numSubKeys; //Initialized in WNetRestoreConnection 43 | DWORD RegMaxWait; 44 | LPCONNECTION_INFO ConnectArray; //Initialized in WNetRestoreConnection 45 | }PARAMETERS; 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | //function load from mprui.dll. 52 | 53 | DWORD DoPasswordDialog( 54 | HWND hwndOwner, 55 | TCHAR * pchResource, 56 | TCHAR * pchUserName, 57 | TCHAR * pchPasswordReturnBuffer, 58 | DWORD cbPasswordReturnBuffer, // bytes! 59 | BOOL * pfDidCancel, 60 | BOOL fDownLevel 61 | ); 62 | 63 | DWORD DoProfileErrorDialog( 64 | HWND hwndOwner, 65 | const TCHAR * pchDevice, 66 | const TCHAR * pchResource, 67 | const TCHAR * pchProvider, 68 | DWORD dwError, 69 | BOOL fAllowCancel, // ask whether to stop reconnecting devices 70 | // this time? 71 | BOOL * pfDidCancel, // stop reconnecting devices this time? 72 | // active iff fAllowCancel 73 | BOOL * pfDisconnect, // do not reconnect this device in future? 74 | BOOL * pfHideErrors // stop displaying error dialogs this time? 75 | // active iff fAllowCancel 76 | ); 77 | 78 | DWORD ShowReconnectDialog ( 79 | HWND hwndParent, 80 | PARAMETERS * Params); 81 | 82 | // 83 | // Return codes from WNetRestoreConnection 84 | // 85 | #define WN_CONTINUE 0x00000BB9 86 | 87 | DWORD APIENTRY 88 | RestoreConnectionA0( 89 | HWND hWnd, 90 | LPSTR lpDevice 91 | ); 92 | 93 | DWORD APIENTRY 94 | WNetClearConnections( 95 | HWND hWnd 96 | ) ; 97 | 98 | // 99 | // Authentication Provider (Credential Management) Functions 100 | // 101 | 102 | DWORD APIENTRY 103 | WNetLogonNotify( 104 | LPCWSTR lpPrimaryAuthenticator, 105 | PLUID lpLogonId, 106 | LPCWSTR lpAuthentInfoType, 107 | LPVOID lpAuthentInfo, 108 | LPCWSTR lpPreviousAuthentInfoType, 109 | LPVOID lpPreviousAuthentInfo, 110 | LPWSTR lpStationName, 111 | LPVOID StationHandle, 112 | LPWSTR *lpLogonScripts 113 | ); 114 | 115 | DWORD APIENTRY 116 | WNetPasswordChangeNotify( 117 | LPCWSTR lpPrimaryAuthenticator, 118 | LPCWSTR lpAuthentInfoType, 119 | LPVOID lpAuthentInfo, 120 | LPCWSTR lpPreviousAuthentInfoType, 121 | LPVOID lpPreviousAuthentInfo, 122 | LPWSTR lpStationName, 123 | LPVOID StationHandle, 124 | DWORD dwChangeInfo 125 | ); 126 | 127 | // 128 | // Directory functions 129 | // 130 | DWORD 131 | WNetGetDirectoryTypeA ( 132 | LPSTR lpName, 133 | LPDWORD lpType, 134 | BOOL bFlushCache 135 | ); 136 | 137 | DWORD 138 | WNetGetDirectoryTypeW ( 139 | LPTSTR lpName, 140 | LPINT lpType, 141 | BOOL bFlushCache 142 | ); 143 | 144 | #ifdef UNICODE 145 | #define WNetGetDirectoryType WNetGetDirectoryTypeW 146 | #else 147 | #define WNetGetDirectoryType WNetGetDirectoryTypeA 148 | #endif // UNICODE 149 | 150 | 151 | DWORD 152 | WNetDirectoryNotifyA ( 153 | HWND hwnd, 154 | LPSTR lpDir, 155 | DWORD dwOper 156 | ); 157 | 158 | DWORD 159 | WNetDirectoryNotifyW ( 160 | HWND hwnd, 161 | LPTSTR lpDir, 162 | DWORD dwOper 163 | ); 164 | 165 | #ifdef UNICODE 166 | #define WNetDirectoryNotify WNetDirectoryNotifyW 167 | #else 168 | #define WNetDirectoryNotify WNetDirectoryNotifyA 169 | #endif // UNICODE 170 | 171 | 172 | DWORD 173 | WNetPropertyDialogA ( 174 | HWND hwndParent, 175 | DWORD iButton, 176 | DWORD nPropSel, 177 | LPSTR lpszName, 178 | DWORD nType 179 | ); 180 | 181 | DWORD 182 | WNetPropertyDialogW ( 183 | HWND hwndParent, 184 | DWORD iButton, 185 | DWORD nPropSel, 186 | LPTSTR lpszName, 187 | DWORD nType 188 | ); 189 | 190 | #ifdef UNICODE 191 | #define WNetPropertyDialog WNetPropertyDialogW 192 | #else 193 | #define WNetPropertyDialog WNetPropertyDialogA 194 | #endif // UNICODE 195 | 196 | 197 | DWORD 198 | WNetGetPropertyTextA ( 199 | DWORD iButton, 200 | DWORD nPropSel, 201 | LPSTR lpszName, 202 | LPSTR lpszButtonName, 203 | DWORD nButtonNameLength, 204 | DWORD nType 205 | ); 206 | 207 | DWORD 208 | WNetGetPropertyTextW ( 209 | DWORD iButton, 210 | DWORD nPropSel, 211 | LPTSTR lpszName, 212 | LPTSTR lpszButtonName, 213 | DWORD nButtonNameLength, 214 | DWORD nType 215 | ); 216 | 217 | #ifdef UNICODE 218 | #define WNetGetPropertyText WNetGetPropertyTextW 219 | #else 220 | #define WNetGetPropertyText WNetGetPropertyTextA 221 | #endif // UNICODE 222 | 223 | typedef struct _WNET_CONNECTINFOA 224 | { 225 | LPSTR lpRemoteName ; 226 | LPSTR lpProvider ; 227 | } WNET_CONNECTIONINFOA, *LPWNET_CONNECTIONINFOA ; 228 | 229 | typedef struct _WNET_CONNECTINFOW 230 | { 231 | LPWSTR lpRemoteName ; 232 | LPWSTR lpProvider ; 233 | } WNET_CONNECTIONINFOW, *LPWNET_CONNECTIONINFOW ; 234 | 235 | #ifdef UNICODE 236 | #define WNET_CONNECTIONINFO WNET_CONNECTIONINFOW 237 | #define LPWNET_CONNECTIONINFO LPWNET_CONNECTIONINFOW 238 | #else 239 | #define WNET_CONNECTIONINFO WNET_CONNECTIONINFOA 240 | #define LPWNET_CONNECTIONINFO LPWNET_CONNECTIONINFOA 241 | #endif // UNICODE 242 | 243 | // 244 | // Used in conjunction with WNET_CONNECTIONINFO, gets the net provider name 245 | // in addition to the remote name for this connection. 246 | // 247 | DWORD 248 | WNetGetConnection2A( 249 | LPSTR lpLocalName, 250 | LPVOID lpBuffer, // Contains WNET_CONNECTIONINFOA struct 251 | LPDWORD lpBufferSize // In bytes! 252 | ) ; 253 | 254 | DWORD 255 | WNetGetConnection2W( 256 | LPWSTR lpLocalName, 257 | LPVOID lpBuffer, // Contains WNET_CONNECTIONINFOW struct 258 | LPDWORD lpBufferSize // In bytes! 259 | ) ; 260 | 261 | #ifdef UNICODE 262 | #define WNetGetConnection2 WNetGetConnection2W 263 | #else 264 | #define WNetGetConnection2 WNetGetConnection2A 265 | #endif // UNICODE 266 | 267 | // 268 | // Versions of the dialog with the ability to supply help. 269 | // These are not in Win32 because we do not want to force 270 | // nor encourage apps to have to document the way these 271 | // dialogs work, since they are liable to change. 272 | // 273 | DWORD WNetConnectionDialog2 ( 274 | HWND hwndParent, 275 | DWORD dwType, 276 | WCHAR *lpHelpFile, 277 | DWORD nHelpContext 278 | ); 279 | 280 | DWORD WNetDisconnectDialog2 ( 281 | HWND hwndParent, 282 | DWORD dwType, 283 | WCHAR *lpHelpFile, 284 | DWORD nHelpContext 285 | ); 286 | 287 | 288 | // 289 | // Browse dialog 290 | // 291 | 292 | // Type of the callback routine used by the browse dialog to validate 293 | // the path input by the user 294 | typedef BOOL (*PFUNC_VALIDATION_CALLBACK)( LPWSTR pszName ); 295 | 296 | // WNetBrowseDialog and WNetBrowsePrinterDialog 297 | // NOTE: WNetBrowsePrintDialog = 298 | // WNetBrowseDialog with dwType RESOURCETYPE_PRINT 299 | // 300 | /******************************************************************* 301 | 302 | NAME: WNetBrowseDialog, WNetBrowsePrinterDialog 303 | 304 | SYNOPSIS: Presents a dialog to the user from which the user can 305 | browse the network for disk or print shares. 306 | 307 | ENTRY: hwndParent - Parent window handle 308 | dwType - ( Only in WNetBrowseDialog ) 309 | RESOURCETYPE_DISK or RESOURCETYPE_PRINT 310 | lpszName - The path name typed by the user. It will be 311 | undefined if the user hits the CANCEL button. 312 | cchBufSize - The buffer size of the lpszName in characters 313 | lpszHelpFile- The helpfile to use when the user hits F1. 314 | nHelpContext- The helpcontext to use for the helpfile above 315 | pfuncValidation - Callback method to validate the path typed 316 | by the user. If NULL, no validation will 317 | be done. 318 | 319 | RETURNS: WN_CANCEL when the user cancels the dialog. NO_ERROR 320 | on success, standard ERROR_* error code otherwise 321 | 322 | NOTES: This is a UNICODE only API. 323 | 324 | HISTORY: 325 | Yi-HsinS 22-Nov-1992 Created 326 | 327 | ********************************************************************/ 328 | 329 | DWORD WNetBrowseDialog( 330 | HWND hwndParent, 331 | DWORD dwType, 332 | WCHAR *lpszName, 333 | DWORD cchBufSize, 334 | WCHAR *lpszHelpFile, 335 | DWORD nHelpContext, 336 | PFUNC_VALIDATION_CALLBACK pfuncValidation ); 337 | 338 | DWORD WNetBrowsePrinterDialog( 339 | HWND hwndParent, 340 | WCHAR *lpszName, 341 | DWORD cchBufSize, 342 | WCHAR *lpszHelpFile, 343 | DWORD nHelpContext, 344 | PFUNC_VALIDATION_CALLBACK pfuncValidation ); 345 | 346 | // 347 | // stuff in user, not driver, for shell apps ;Internal 348 | // 349 | DWORD APIENTRY WNetErrorText(DWORD,LPTSTR,DWORD); // ;Internal 350 | 351 | // 352 | // used by MPRUI.DLL to determine if a provider supports 353 | // NpSearchDialog() and obtain to a pointer to it. 354 | // 355 | FARPROC WNetGetSearchDialog(LPWSTR lpProvider) ; 356 | 357 | // 358 | // used by MPRUI.DLL to determine if a provider supports 359 | // NPFormatNetworkName() and obtain a pointer to it. 360 | // 361 | FARPROC WNetGetFormatNameProc(LPWSTR lpProvider) ; 362 | 363 | // 364 | // used by MPRUI.DLL to determine if a provider supports 365 | // WNNC_ENUM_GLOBAL 366 | // 367 | BOOL WNetSupportGlobalEnum(LPWSTR lpProvider) ; 368 | 369 | // 370 | // used by ACLEDIT.DLL to get provider-specific permission editor 371 | // 372 | 373 | DWORD WNetFMXGetPermCaps( LPWSTR lpDriveName ) ; 374 | DWORD WNetFMXEditPerm( LPWSTR lpDriveName, HWND hwndFMX, DWORD nDialogType ); 375 | DWORD WNetFMXGetPermHelp( LPWSTR lpDriveName, 376 | DWORD nDialogType, 377 | BOOL fDirectory, 378 | LPVOID lpFileNameBuffer, 379 | LPDWORD lpBufferSize, 380 | LPDWORD lpnHelpContext ); 381 | 382 | // 383 | // sections and keys used for persistent connections 384 | // 385 | 386 | #define WNNC_DLG_DISCONNECT 0x0008 387 | #define WNNC_DLG_CONNECT 0x0004 388 | 389 | #ifdef UNICODE 390 | 391 | #define MPR_MRU_FILE_SECTION L"NET_Files" 392 | #define MPR_MRU_PRINT_SECTION L"NET_Printers" 393 | #define MPR_MRU_ORDER_KEY L"Order" 394 | 395 | #define MPR_NETWORK_SECTION L"Network" 396 | #define MPR_SAVECONNECTION_KEY L"SaveConnections" 397 | #define MPR_RESTORECONNECTION_KEY L"RestoreConnections" 398 | #define MPR_EXPANDLOGONDOMAIN_KEY L"ExpandLogonDomain" 399 | 400 | #define MPR_YES_VALUE L"yes" 401 | #define MPR_NO_VALUE L"no" 402 | 403 | #else 404 | 405 | #define MPR_MRU_FILE_SECTION "NET_Files" 406 | #define MPR_MRU_PRINT_SECTION "NET_Printers" 407 | #define MPR_MRU_ORDER_KEY "Order" 408 | 409 | #define MPR_NETWORK_SECTION "Network" 410 | #define MPR_SAVECONNECTION_KEY "SaveConnections" 411 | #define MPR_RESTORECONNECTION_KEY "RestoreConnections" 412 | #define MPR_EXPANDLOGONDOMAIN_KEY "ExpandLogonDomain" 413 | 414 | #define MPR_YES_VALUE "yes" 415 | #define MPR_NO_VALUE "no" 416 | 417 | #endif // UNICODE 418 | 419 | 420 | // 421 | // Internal NP interface used to help the NTLM provider remember 422 | // whether a persistent connection is a DFS connection or not 423 | // 424 | 425 | DWORD APIENTRY 426 | NPGetReconnectFlags ( 427 | IN LPWSTR lpLocalName, 428 | OUT LPBYTE lpPersistFlags 429 | ); 430 | typedef DWORD (*PF_NPGetReconnectFlags) ( 431 | LPWSTR lpLocalName, 432 | LPBYTE lpPersistFlags 433 | ); 434 | 435 | // This macro operates on the dwFlags parameter of NPAddConnection3 436 | #define CONNECT_PROVIDER_FLAGS(dwFlags) ((BYTE) (((dwFlags) & 0xFF000000) >> 24)) 437 | 438 | #ifdef __cplusplus 439 | } 440 | #endif 441 | 442 | #endif // _MPR_H_INCLUDED 443 | -------------------------------------------------------------------------------- /src/numfmt.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | NumFmt.c 4 | 5 | Number formatting code 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include "winfile.h" 13 | 14 | static DWORD pdwOrders[] = 15 | { 16 | IDS_ORDERB, IDS_ORDERKB, IDS_ORDERMB, IDS_ORDERGB, IDS_ORDERTB 17 | } ; 18 | 19 | static TCHAR szFormat[] = TEXT("%s%02d"); 20 | extern TCHAR szInternational[]; 21 | 22 | // 23 | // atoi with decimal comma seperators 24 | // 25 | LPTSTR 26 | ShortSizeFormatInternal(LPTSTR szBuf, LARGE_INTEGER qw) 27 | { 28 | INT i; 29 | UINT uInt, uLen, uDec; 30 | TCHAR szTemp[10], szOrder[20]; 31 | 32 | LARGE_INTEGER qConstant; 33 | DWORD dw; 34 | 35 | qConstant.QuadPart = 1024L; 36 | 37 | if (qw.QuadPart < qConstant.QuadPart) 38 | { 39 | wsprintf(szTemp, SZ_PERCENTD, LOWORD(qw.LowPart)); 40 | i = 0; 41 | goto AddOrder; 42 | } 43 | 44 | qConstant.QuadPart = (1024L * 1000L - 1); 45 | 46 | for ( i = 1; 47 | (qw.QuadPart > qConstant.QuadPart); 48 | qw.QuadPart = qw.QuadPart / 1024L, ++i) 49 | 50 | /* do nothing */ 51 | ; 52 | 53 | dw = qw.LowPart; 54 | 55 | uInt = (UINT) (dw / 1024); 56 | uLen = wsprintf(szTemp, SZ_PERCENTD, uInt); 57 | if (uLen < 3) { 58 | uDec = (dw - uInt * 1024L) * 1000 / 1024; 59 | 60 | // 61 | // At this point, uDec should be between 0 and 1000 62 | // we want get the top one (or two) digits. 63 | // 64 | uDec /= 10; 65 | if (uLen == 2) { 66 | uDec /= 10; 67 | } 68 | 69 | // 70 | // Note that we need to set the format before getting the 71 | // intl CHAR. 72 | // 73 | szFormat[4] = CHAR_ZERO + 3 - uLen; 74 | uLen += wsprintf(szTemp+uLen, szFormat, szDecimal, uDec); 75 | } 76 | 77 | AddOrder: 78 | LoadString(hAppInstance, pdwOrders[i], szOrder, COUNTOF(szOrder)); 79 | wsprintf(szBuf, szOrder, szTemp); 80 | 81 | return(szBuf); 82 | } 83 | 84 | 85 | LARGE_INTEGER 86 | TriMultiply(DWORD dw1, DWORD dw2, DWORD dwSmall) 87 | { 88 | LARGE_INTEGER Result; 89 | 90 | Result.QuadPart = UInt32x32To64(dw1, dw2); 91 | Result.QuadPart = Result.QuadPart * dwSmall; 92 | 93 | return Result; 94 | } 95 | -------------------------------------------------------------------------------- /src/numfmt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | numfmt.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #define SPC_SET_INVALID(q) ((q).HighPart=(LONG)-1) 11 | #define SPC_SET_NOTREE(q) ((q).HighPart=(LONG)-2) 12 | #define SPC_SET_HITDISK(q) ((q).HighPart=(LONG)-3) 13 | 14 | #define SPC_IS_INVALID(q) ((q).HighPart==(LONG)-1) 15 | #define SPC_IS_NOTREE(q) ((q).HighPart==(LONG)-2) 16 | #define SPC_IS_HITDISK(q) ((q).HighPart==(LONG)-3) 17 | 18 | #define SPC_REFRESH(q) (SPC_IS_INVALID(q) || SPC_IS_HITDISK(q)) 19 | 20 | LPTSTR ShortSizeFormatInternal(LPTSTR szBuf, LARGE_INTEGER qw); 21 | 22 | #define LARGE_INTEGER_NULL(q) ((q).LowPart = 0, (q).HighPart = 0) 23 | 24 | LARGE_INTEGER TriMultiply(DWORD dw1, DWORD dw2, DWORD dwSmall); 25 | -------------------------------------------------------------------------------- /src/res.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/res.rc -------------------------------------------------------------------------------- /src/scopy.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/scopy.cur -------------------------------------------------------------------------------- /src/smove.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/smove.cur -------------------------------------------------------------------------------- /src/split.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/split.cur -------------------------------------------------------------------------------- /src/suggest.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | Suggest.c 4 | 5 | Handles error code messages and suggestions 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include "winfile.h" 13 | 14 | // 15 | // Create array 16 | // 17 | #define SUGGEST(id,err,flags,str) err, flags, id+IDS_SUGGESTBEGIN, 18 | DWORD adwSuggest[][3] = { 19 | #include "suggest.db" 20 | 0,0,0 21 | }; 22 | #undef SUGGEST 23 | 24 | 25 | ///////////////////////////////////////////////////////////////////// 26 | // 27 | // Name: FormatError 28 | // 29 | // Synopsis: Takes an error code and adds explanation/suggestions 30 | // 31 | // IN bNullString -- lpBuf is empty? 32 | // INOUT lpBuf LPTSTR buffer with initial string 33 | // !! Should end in " " or '\n' for formatting !! 34 | // lpBuf[0] must be 0 if no initial string 35 | // 36 | // IN iSize -- size of buffer _in_characters_ 37 | // IN dwError -- Error code from GetLastError() 38 | // 39 | // Return: DWORD # characters added 40 | // 41 | // Assumes: iError has DE_BIT off for system errors 42 | // lpBuf[0] if no inital string 43 | // 44 | // Effects: lpBuf appended with text 45 | // 46 | // Notes: FormatMessage usually takes lpArgList for any text 47 | // substitutions. This blocks out _all_ present strings 48 | // that would normally require lpArgList != NULL. 49 | // 50 | ///////////////////////////////////////////////////////////////////// 51 | 52 | DWORD 53 | FormatError( 54 | BOOL bNullString, 55 | LPTSTR lpBuf, 56 | INT iSize, 57 | DWORD dwError) 58 | { 59 | INT iLen; 60 | DWORD dwNumChars = 0; 61 | PDWORD pdwSuggest; 62 | INT iAddNewline = 0; 63 | 64 | WORD wLangId; 65 | BOOL bTryAgain; 66 | 67 | // 68 | // If error == 0, just return... 69 | // 70 | if (!dwError) 71 | return 0; 72 | 73 | if (bNullString) 74 | lpBuf[0] = 0; 75 | 76 | iLen = lstrlen(lpBuf); 77 | 78 | lpBuf += iLen; 79 | iSize -= iLen; 80 | 81 | if (iSize <=0) 82 | return 0; 83 | 84 | // Check suggestion flags before calling FormatMessage 85 | // in case we want to use our own string. 86 | 87 | pdwSuggest = FormatSuggest( dwError ); 88 | 89 | // 90 | // Only do a FormatMessage if the DE_BIT is off and the 91 | // SUG_IGN_FORMATMESSAGE bit is off. 92 | // (If no suggestion, default use format message) 93 | // 94 | 95 | if ( !(dwError & DE_BEGIN) && 96 | !(pdwSuggest && pdwSuggest[1] & SUG_IGN_FORMATMESSAGE) ) { 97 | 98 | // if extended error, use WNetErrorText! 99 | if ( ERROR_EXTENDED_ERROR == dwError ) { 100 | DWORD dwErrorCode; 101 | TCHAR szProvider[128]; 102 | 103 | 104 | if (WAITNET_LOADED) { 105 | 106 | // !! BUG: szProvider size hard coded, doesn't print provider !! 107 | 108 | WNetGetLastError( &dwErrorCode, lpBuf, iSize, szProvider, 109 | COUNTOF(szProvider)); 110 | } 111 | 112 | return lstrlen(lpBuf); 113 | } 114 | 115 | // 116 | // Begin with language from thread. 117 | // 118 | // loop again only if the there is an error, 119 | // the error is that the resource lang isn't found, 120 | // and we are not using the neutral language. 121 | // 122 | // If so, repeat query using neutral language. 123 | // 124 | wLangId = LANGIDFROMLCID(lcid); 125 | 126 | do { 127 | dwNumChars = FormatMessage( 128 | FORMAT_MESSAGE_FROM_SYSTEM | 129 | FORMAT_MESSAGE_IGNORE_INSERTS | 130 | FORMAT_MESSAGE_MAX_WIDTH_MASK, 131 | NULL, dwError, wLangId, 132 | lpBuf, iSize*sizeof(lpBuf[0]), NULL ); 133 | 134 | bTryAgain = !dwNumChars && 135 | MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) != wLangId && 136 | ERROR_RESOURCE_LANG_NOT_FOUND == GetLastError(); 137 | 138 | wLangId = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); 139 | 140 | } while (bTryAgain); 141 | 142 | iAddNewline = 2; 143 | } 144 | 145 | // 146 | // if !dwNumChars, NULL terminate for safety. 147 | // 148 | if (!dwNumChars) { 149 | lpBuf[0] = CHAR_NULL; 150 | } 151 | 152 | // 153 | // Now add suggestion if it exists. 154 | // 155 | if (pdwSuggest && pdwSuggest[2]) { 156 | 157 | DWORD dwNumTemp = 0; 158 | 159 | // Make sure we have space: 160 | 161 | lpBuf += dwNumChars + iAddNewline; 162 | iSize -= dwNumChars + iAddNewline; 163 | 164 | if (!iSize) 165 | goto SuggestPunt; 166 | 167 | // 168 | // We found one, add a new line in for formatting 169 | // 170 | 171 | for(;iAddNewline; iAddNewline--) 172 | lpBuf[-iAddNewline] = CHAR_NEWLINE; 173 | 174 | dwNumTemp = LoadString ( hAppInstance, pdwSuggest[2], lpBuf, iSize ); 175 | 176 | return dwNumTemp+dwNumChars+iAddNewline; 177 | } 178 | 179 | SuggestPunt: 180 | 181 | // if dwNumChars != 0 then just make sure last char 182 | // isn't \n. if it is, strip it! 183 | 184 | if ( dwNumChars ) { 185 | if ( CHAR_NEWLINE == lpBuf[dwNumChars-1] ) { 186 | lpBuf[dwNumChars-1] = CHAR_NULL; 187 | } 188 | 189 | if ( dwNumChars > 1 ) { 190 | if ( 0x000D == lpBuf[dwNumChars-2] ) { 191 | lpBuf[dwNumChars-2] = CHAR_NULL; 192 | } 193 | } 194 | } 195 | 196 | return dwNumChars; 197 | } 198 | 199 | PDWORD 200 | FormatSuggest( DWORD dwError ) 201 | { 202 | PDWORD pdwReturn = NULL; 203 | INT i; 204 | 205 | // If error == 0, just return... 206 | if (!dwError) 207 | return NULL; 208 | 209 | // scan through all suggests 210 | 211 | switch(dwError) { 212 | case ERROR_EXE_MARKED_INVALID: 213 | case ERROR_ITERATED_DATA_EXCEEDS_64k: 214 | case ERROR_INVALID_STACKSEG: 215 | case ERROR_INVALID_STARTING_CODESEG: 216 | case ERROR_INVALID_MODULETYPE: 217 | case ERROR_INVALID_MINALLOCSIZE: 218 | case ERROR_INVALID_SEGDPL: 219 | case ERROR_RELOC_CHAIN_XEEDS_SEGLIM: 220 | case ERROR_INFLOOP_IN_RELOC_CHAIN: 221 | dwError = ERROR_INVALID_ORDINAL; 222 | 223 | // no break 224 | 225 | default: 226 | for (i=0;adwSuggest[i][0]; i++) { 227 | if ( adwSuggest[i][0] == dwError ) { 228 | pdwReturn = adwSuggest[i]; 229 | break; 230 | } 231 | } 232 | } 233 | return pdwReturn; 234 | } 235 | -------------------------------------------------------------------------------- /src/suggest.db: -------------------------------------------------------------------------------- 1 | 2 | // Suggestion database info 3 | // Used to automate the suggestions compiled into winfile 4 | // 5 | // Copyright (c) Microsoft Corporation. All rights reserved. 6 | // Licensed under the MIT License. 7 | // 8 | // Usage: Just add a new entry of the format: 9 | 10 | // SUGGEST( resource_number, error-code, flags, "your-reason-string" ) 11 | // resource_number = incremental number for string ID 12 | // error-code = error this suggestion corresponds to 13 | // "your-reason-string" string displayed for error 14 | // flags: SUG_IGN_FORMATMESSAGE = prepend system FormatMessage text 15 | 16 | // Ok, so it's not perfect: your resource number can't clash 17 | // with any others in winfile.h. Use 1 .. 99 (1101 to 1199) 18 | // resource # 0 is reserved. 19 | 20 | // What it does: 21 | // For system errors (defined here in winfile land as < DE_BEGIN (bit 29 off)), 22 | // it puts the "suggestion" below the error text (a blank line is between 23 | // them. 24 | // 25 | // For our errors (>= DE_BEGIN), it places the text below (1 blank line) 26 | // the previous string. There is no longer any corresponding text called 27 | // "IDS_REASONS+DE_MYERROR" or "DE_MYERROR" in the resources. 28 | // Internal error messages and their reasons must be stored here in 29 | // the same string. 30 | 31 | #ifndef IDS_SUGGESTBEGIN 32 | #define IDS_SUGGESTBEGIN 1100 33 | #endif 34 | 35 | SUGGEST( 1, DE_SAMEFILE, 0L, \ 36 | "Source and destination are the same." ) 37 | SUGGEST( 2, DE_MANYSRC1DEST, 0L, \ 38 | "Select only one file to rename, or use wildcards (for example, *.TXT) to rename a group of files with similar names." ) 39 | SUGGEST( 3, DE_DIFFDIR, 0L, \ 40 | "Cannot rename to a different directory or disk.\nUse the File Move command instead." ) 41 | SUGGEST( 4, DE_ROOTDIR, 0L, \ 42 | "You cannot rename the root directory." ) 43 | SUGGEST( 5, DE_DESTSUBTREE, 0L, \ 44 | "The destination directory is a subdirectory of the source." ) 45 | SUGGEST( 6, DE_WINDOWSFILE, 0L, \ 46 | "File in use by Windows." ) 47 | SUGGEST( 7, DE_MANYDEST, 0L, \ 48 | "Specify only one file or directory in the To box. Or, if you want to specify a group of files, use wildcards (for example, *.TXT)." ) 49 | SUGGEST( 8, DE_RENAMREPLACE, 0L, \ 50 | "A file or directory by this name already exists. Within a directory, file and directory names must be unique." ) 51 | 52 | // This error is returned when selecting a grayed network drive and the rdr is not started 53 | SUGGEST( 9, ERROR_FILE_NOT_FOUND, 0L, \ 54 | "Make sure the correct path and filename are specified." ) 55 | SUGGEST(10, ERROR_PATH_NOT_FOUND, 0L, \ 56 | "Make sure the correct path is specified." ) 57 | SUGGEST(11, ERROR_NOT_ENOUGH_MEMORY, 0L, \ 58 | "Quit one or more applications, and then try again. Or, use the Systems option in Control Panel to increase your virtual memory." ) 59 | // 12 60 | SUGGEST(13, ERROR_WRITE_PROTECT, 0L, \ 61 | "Disable the write-protection on this disk or use another disk, and then try again." ) 62 | SUGGEST(14, ERROR_NETWORK_ACCESS_DENIED, 0L, \ 63 | "Be sure you have the correct network permissions to perform this operation." ) 64 | SUGGEST(15, ERROR_DISK_FULL, 0L, \ 65 | "Delete one or more files to increase disk space, and then try again." ) 66 | SUGGEST(16, ERROR_NO_DATA_DETECTED, SUG_IGN_FORMATMESSAGE, \ 67 | "No data detected on this medium." ) 68 | 69 | SUGGEST(17, DE_MAKEDIREXISTS, 0L, \ 70 | "The directory already exists." ) 71 | SUGGEST(18, DE_DIREXISTSASFILE, 0L, \ 72 | "The specified name is already used by a file." ) 73 | #ifdef ASSOC 74 | SUGGEST(19, DE_DELEXTWRONGMODE, 0L, \ 75 | "This can only be deleted when viewing Common File Types and extensions." ) 76 | #endif 77 | 78 | // Block out errors that require arguments 79 | SUGGEST(50, ERROR_WRONG_DISK, SUG_IGN_FORMATMESSAGE, \ 80 | "The wrong disk is in the drive." ) 81 | SUGGEST(51, ERROR_CHILD_NOT_COMPLETE, SUG_IGN_FORMATMESSAGE, \ 82 | "The application cannot be run in Windows NT mode." ) 83 | SUGGEST(52, ERROR_INVALID_ORDINAL, SUG_IGN_FORMATMESSAGE, \ 84 | "The operating system cannot run this component." ) 85 | SUGGEST(53, ERROR_INVALID_EXE_SIGNATURE, SUG_IGN_FORMATMESSAGE, \ 86 | "The component cannot be run in Windows NT mode." ) 87 | SUGGEST(54, ERROR_BAD_EXE_FORMAT, SUG_IGN_FORMATMESSAGE, \ 88 | "This program is not a valid Windows NT application." ) 89 | SUGGEST(55, ERROR_MR_MID_NOT_FOUND, SUG_IGN_FORMATMESSAGE, \ 90 | "An error occurred. There is no message text for this error." ) 91 | 92 | -------------------------------------------------------------------------------- /src/suggest.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | suggest.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #include "windows.h" 11 | 12 | #define DE_BIT 29 // bit for app errors 13 | #define DE_BEGIN (1 << DE_BIT) // beginning of DE_* 14 | 15 | 16 | // Suggestion flags 17 | 18 | #define SUG_NULL 0 19 | #define SUG_IGN_FORMATMESSAGE 1 20 | 21 | extern HINSTANCE hAppInstance; 22 | 23 | 24 | DWORD FormatError(BOOL bNullString, LPTSTR lpBuf, INT iSize, DWORD dwError); 25 | PDWORD FormatSuggest(DWORD dwError); 26 | 27 | // Internal error numbers begin here 28 | // They will not conflict with any system ones as long as DE_BEGIN 29 | // has bit 29 set. 30 | 31 | #define DE_OPCANCELLED DE_BEGIN 32 | #define DE_INSMEM DE_BEGIN+1 33 | #define DE_ROOTDIR DE_BEGIN+3 34 | #define DE_DESTSUBTREE DE_BEGIN+4 35 | #define DE_WINDOWSFILE DE_BEGIN+5 36 | #define DE_MANYDEST DE_BEGIN+6 37 | #define DE_SAMEFILE DE_BEGIN+7 38 | #define DE_RENAMREPLACE DE_BEGIN+8 39 | #define DE_DIFFDIR DE_BEGIN+9 40 | #define DE_HOWDIDTHISHAPPEN DE_BEGIN+10 41 | #define DE_MANYSRC1DEST DE_BEGIN+12 42 | #define DE_RETRY DE_BEGIN+13 43 | #define DE_DIREXISTSASFILE DE_BEGIN+14 44 | #define DE_MAKEDIREXISTS DE_BEGIN+15 45 | #define DE_UPDATING DE_BEGIN+16 46 | #define DE_DELEXTWRONGMODE DE_BEGIN+17 47 | #define DE_REGNAME DE_BEGIN+18 48 | -------------------------------------------------------------------------------- /src/toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/toolbar.bmp -------------------------------------------------------------------------------- /src/treectl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | treectl.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #define SHOVEIT(x) (MAKELONG((x),0)) 11 | 12 | /* Tree Node Flags. */ 13 | #define TF_LASTLEVELENTRY 0x01 14 | #define TF_HASCHILDREN 0x02 15 | #define TF_EXPANDED 0x04 16 | #define TF_DISABLED 0x08 17 | 18 | #ifdef USE_TF_LFN 19 | #define TF_LFN 0x10 20 | #endif 21 | 22 | #define TF_LOWERCASE 0x20 23 | 24 | typedef struct tagDNODE 25 | { 26 | struct tagDNODE *pParent; 27 | BYTE wFlags; 28 | BYTE nLevels; 29 | DWORD dwNetType; 30 | DWORD dwExtent; 31 | DWORD dwAttribs; 32 | TCHAR szName[1]; // variable length field 33 | } DNODE; 34 | typedef DNODE *PDNODE; 35 | -------------------------------------------------------------------------------- /src/wbbitmap.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/wbbitmap.bmp -------------------------------------------------------------------------------- /src/wfchgnot.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfchgnot.c 4 | 5 | WinFile Change Notify module. 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include "winfile.h" 13 | 14 | // 15 | // Forward Declarations 16 | // 17 | VOID NotifyReset(); 18 | VOID NotifyDeleteHandle(INT i); 19 | VOID NotifyAddHandle(INT i, HWND hwnd, LPTSTR lpPath, DWORD dwFilter); 20 | 21 | // 22 | // Maximum number of windows that are viewable 23 | // at once. 24 | // 25 | HWND ahwndWindows[MAX_WINDOWS]; 26 | DRIVE adrive[MAX_WINDOWS]; 27 | HANDLE ahEvents[MAX_WINDOWS]; 28 | INT nHandles; 29 | 30 | #define bNOTIFYACTIVE uChangeNotifyTime 31 | 32 | 33 | VOID 34 | vWaitMessage() 35 | { 36 | DWORD dwEvent; 37 | 38 | dwEvent = MsgWaitForMultipleObjects(nHandles, 39 | ahEvents, 40 | FALSE, 41 | INFINITE, 42 | QS_ALLINPUT); 43 | 44 | if (dwEvent != (DWORD) (WAIT_OBJECT_0 + nHandles)) { 45 | 46 | if (dwEvent == (DWORD)-1) { 47 | 48 | NotifyReset(); 49 | 50 | } else { 51 | 52 | dwEvent -= WAIT_OBJECT_0; 53 | 54 | // 55 | // Check to see if this handle has been removed already, if so 56 | // return before we try to refresh a non-existent window. 57 | // 58 | if ((dwEvent >= MAX_WINDOWS) || ahEvents[dwEvent] == NULL) 59 | return; 60 | 61 | // 62 | // Modify GWL_FSCFLAG directly. 63 | // 64 | // We do the ModifyWatchList right before we read (close then 65 | // open on the same path). This clears out any extra notifications 66 | // caused by fileman's move/copy etc. 67 | // 68 | SetWindowLong(ahwndWindows[dwEvent], GWL_FSCFLAG, TRUE); 69 | PostMessage(hwndFrame, FS_FSCREQUEST, 0, 0L); 70 | 71 | if (FindNextChangeNotification(ahEvents[dwEvent]) == FALSE) { 72 | 73 | // 74 | // If we can't find the next change notification, remove it. 75 | // 76 | NotifyDeleteHandle(dwEvent); 77 | } 78 | } 79 | } 80 | } 81 | 82 | 83 | ///////////////////////////////////////////////////////////////////// 84 | // 85 | // Name: InitializeWatchList 86 | // 87 | // Synopsis: Setups up change notifications 88 | // 89 | // IN VOID 90 | // 91 | // Return: VOID 92 | // 93 | // 94 | // Assumes: GetSettings has initialized uChangeNotifyTime 95 | // 96 | // Effects: nHandles, ahwndWindows, ahEvents 97 | // 98 | // 99 | // Notes: If not successful, bNOTIFYACTIVE = FALSE 100 | // 101 | ///////////////////////////////////////////////////////////////////// 102 | 103 | VOID 104 | InitializeWatchList(VOID) 105 | { 106 | INT i; 107 | 108 | // 109 | // Change notify system is off if uChangeNotifyTime == 0 110 | // No, this doesn't mean zero time. 111 | // 112 | if (!bNOTIFYACTIVE) 113 | return; 114 | 115 | for (i = 0; i < MAX_WINDOWS; i++) { 116 | ahwndWindows[i] = NULL; 117 | ahEvents[i] = NULL; 118 | } 119 | 120 | nHandles = 0; 121 | } 122 | 123 | 124 | 125 | ///////////////////////////////////////////////////////////////////// 126 | // 127 | // Name: DestroyWatchList 128 | // 129 | // Synopsis: Initializes change notify system 130 | // 131 | // IN VOID 132 | // 133 | // Return: VOID 134 | // 135 | // 136 | // Assumes: InitializeWatchList has been called: 137 | // 138 | // Effects: watchlist closed 139 | // 140 | // Notes: 141 | // 142 | ///////////////////////////////////////////////////////////////////// 143 | 144 | VOID 145 | DestroyWatchList(VOID) 146 | { 147 | PHANDLE phChange; 148 | 149 | // 150 | // Only destroy if successfully started 151 | // 152 | if (bNOTIFYACTIVE) { 153 | 154 | // 155 | // Clean up handles in hChange! 156 | // 157 | for(phChange = ahEvents; 158 | nHandles; 159 | nHandles--, phChange++) { 160 | 161 | FindCloseChangeNotification(*phChange); 162 | } 163 | } 164 | } 165 | 166 | 167 | VOID 168 | NotifyReset() 169 | { 170 | NotifyPause(-1, (UINT)-2); 171 | nHandles = 0; 172 | } 173 | 174 | ///////////////////////////////////////////////////////////////////// 175 | // 176 | // Name: NotifyPause 177 | // 178 | // Synopsis: Pause notification on a set of drives 179 | // 180 | // INC -- drive -2 == ALL 181 | // -1 == All of type uType 182 | // 0 < drive < 26 is the drive to stop 183 | // INC -- uType Type of drive to stop notification on 184 | // 185 | // 186 | // Return: VOID 187 | // 188 | // 189 | // Assumes: Called by main thread (drive windows stable) 190 | // 191 | // Effects: notification variables 192 | // if (drive != -1) GWL_FSCFLAG on that drive is cleared. 193 | // 194 | // 195 | // Notes: Setting drive limits notification ignore to just 1 drive. 196 | // This can be called many times 197 | // 198 | ///////////////////////////////////////////////////////////////////// 199 | 200 | VOID 201 | NotifyPause(DRIVE drive, UINT uType) 202 | { 203 | INT i; 204 | DRIVE driveCurrent; 205 | 206 | if (!bNOTIFYACTIVE) 207 | return; 208 | 209 | 210 | for(i=0;i 14 | #include 15 | #include "lfn.h" 16 | #include "wfcopy.h" 17 | 18 | VOID MDIClientSizeChange(HWND hwndActive, INT iFlags); 19 | 20 | extern INT maxExt; 21 | 22 | VOID 23 | SaveWindows(HWND hwndMain) 24 | { 25 | // 2* added to both lines 26 | TCHAR szPath[2*MAXPATHLEN]; 27 | TCHAR buf2[2*MAXPATHLEN + 6*12]; 28 | 29 | TCHAR key[10]; 30 | INT dir_num; 31 | HWND hwnd; 32 | BOOL bCounting; 33 | RECT rcT; 34 | DWORD view, sort, attribs; 35 | WINDOWPLACEMENT wp; 36 | 37 | // save main window position 38 | 39 | wp.length = sizeof(WINDOWPLACEMENT); 40 | if (!GetWindowPlacement(hwndMain, &wp)) 41 | return; 42 | 43 | SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)&rcT, 0); 44 | 45 | wsprintf(buf2, TEXT("%d,%d,%d,%d, , ,%d"), rcT.left + wp.rcNormalPosition.left, 46 | rcT.top + wp.rcNormalPosition.top, 47 | wp.rcNormalPosition.right - wp.rcNormalPosition.left, 48 | wp.rcNormalPosition.bottom - wp.rcNormalPosition.top, 49 | wp.showCmd); 50 | 51 | WritePrivateProfileString(szSettings, szWindow, buf2, szTheINIFile); 52 | 53 | // write out dir window strings in reverse order 54 | // so that when we read them back in we get the same Z order 55 | 56 | bCounting = TRUE; 57 | dir_num = 0; 58 | 59 | DO_AGAIN: 60 | 61 | for (hwnd = GetWindow(hwndMDIClient, GW_CHILD); hwnd; hwnd = GetWindow(hwnd, GW_HWNDNEXT)) { 62 | HWND ht = HasTreeWindow(hwnd); 63 | INT nReadLevel = ht ? GetWindowLong(ht, GWL_READLEVEL) : 0; 64 | 65 | // don't save MDI icon title windows or search windows, 66 | // or any dir window which is currently recursing 67 | 68 | if ((GetWindow(hwnd, GW_OWNER) == NULL) && 69 | GetWindowLong(hwnd, GWL_TYPE) != TYPE_SEARCH) /* nReadLevel == 0) */ { 70 | 71 | if (bCounting) { 72 | dir_num++; 73 | continue; 74 | } 75 | 76 | wp.length = sizeof(WINDOWPLACEMENT); 77 | if (!GetWindowPlacement(hwnd, &wp)) 78 | continue; 79 | view = GetWindowLong(hwnd, GWL_VIEW); 80 | sort = GetWindowLong(hwnd, GWL_SORT); 81 | attribs = GetWindowLong(hwnd, GWL_ATTRIBS); 82 | 83 | GetMDIWindowText(hwnd, szPath, COUNTOF(szPath)); 84 | 85 | wsprintf(key, szDirKeyFormat, dir_num--); 86 | 87 | // format: 88 | // x_win, y_win, 89 | // x_win, y_win, 90 | // x_icon, y_icon, 91 | // show_window, view, sort, attribs, split, directory 92 | 93 | wsprintf(buf2, TEXT("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s"), 94 | wp.rcNormalPosition.left, wp.rcNormalPosition.top, 95 | wp.rcNormalPosition.right, wp.rcNormalPosition.bottom, 96 | wp.ptMinPosition.x, wp.ptMinPosition.y, 97 | wp.showCmd, view, sort, attribs, 98 | GetSplit(hwnd), 99 | szPath); 100 | 101 | // the dir is an ANSI string (?) 102 | 103 | WritePrivateProfileString(szSettings, key, buf2, szTheINIFile); 104 | } 105 | } 106 | 107 | if (bCounting) { 108 | bCounting = FALSE; 109 | 110 | // erase the last dir window so that if they save with 111 | // fewer dirs open we don't pull in old open windows 112 | 113 | wsprintf(key, szDirKeyFormat, dir_num + 1); 114 | WritePrivateProfileString(szSettings, key, NULL, szTheINIFile); 115 | 116 | goto DO_AGAIN; 117 | } 118 | } 119 | 120 | 121 | 122 | 123 | /*--------------------------------------------------------------------------*/ 124 | /* */ 125 | /* OtherDlgProc() - */ 126 | /* */ 127 | /*--------------------------------------------------------------------------*/ 128 | 129 | BOOL 130 | CALLBACK 131 | OtherDlgProc(register HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) 132 | { 133 | DWORD dwView; 134 | register HWND hwndActive; 135 | 136 | UNREFERENCED_PARAMETER(lParam); 137 | 138 | hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); 139 | 140 | switch (wMsg) 141 | { 142 | case WM_INITDIALOG: 143 | 144 | dwView = GetWindowLong(hwndActive, GWL_VIEW); 145 | CheckDlgButton(hDlg, IDD_SIZE, dwView & VIEW_SIZE); 146 | CheckDlgButton(hDlg, IDD_DATE, dwView & VIEW_DATE); 147 | CheckDlgButton(hDlg, IDD_TIME, dwView & VIEW_TIME); 148 | CheckDlgButton(hDlg, IDD_FLAGS, dwView & VIEW_FLAGS); 149 | 150 | CheckDlgButton(hDlg, IDD_DOSNAMES, dwView & VIEW_DOSNAMES); 151 | 152 | break; 153 | 154 | case WM_COMMAND: 155 | switch (GET_WM_COMMAND_ID(wParam, lParam)) 156 | { 157 | case IDD_HELP: 158 | goto DoHelp; 159 | 160 | case IDCANCEL: 161 | EndDialog(hDlg, FALSE); 162 | break; 163 | 164 | case IDOK: 165 | { 166 | HWND hwnd; 167 | 168 | dwView = GetWindowLong(hwndActive, GWL_VIEW) & VIEW_PLUSES; 169 | 170 | if (IsDlgButtonChecked(hDlg, IDD_SIZE)) 171 | dwView |= VIEW_SIZE; 172 | if (IsDlgButtonChecked(hDlg, IDD_DATE)) 173 | dwView |= VIEW_DATE; 174 | if (IsDlgButtonChecked(hDlg, IDD_TIME)) 175 | dwView |= VIEW_TIME; 176 | if (IsDlgButtonChecked(hDlg, IDD_FLAGS)) 177 | dwView |= VIEW_FLAGS; 178 | 179 | if (IsDlgButtonChecked(hDlg, IDD_DOSNAMES)) 180 | dwView |= VIEW_DOSNAMES; 181 | 182 | EndDialog(hDlg, TRUE); 183 | 184 | if (hwnd = HasDirWindow(hwndActive)) 185 | SendMessage(hwnd, FS_CHANGEDISPLAY, CD_VIEW, dwView); 186 | else if (hwndActive == hwndSearch) { 187 | SetWindowLong(hwndActive, GWL_VIEW, dwView); 188 | 189 | SendMessage(hwndActive, FS_CHANGEDISPLAY, CD_VIEW, 0L); 190 | } 191 | 192 | break; 193 | } 194 | 195 | default: 196 | return FALSE; 197 | } 198 | break; 199 | 200 | default: 201 | 202 | if (wMsg == wHelpMessage) { 203 | DoHelp: 204 | WFHelp(hDlg); 205 | 206 | return TRUE; 207 | } else 208 | return FALSE; 209 | } 210 | return TRUE; 211 | } 212 | 213 | 214 | 215 | /*--------------------------------------------------------------------------*/ 216 | /* */ 217 | /* IncludeDlgProc() - */ 218 | /* */ 219 | /*--------------------------------------------------------------------------*/ 220 | 221 | BOOL 222 | CALLBACK 223 | IncludeDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) 224 | { 225 | DWORD dwAttribs; 226 | HWND hwndActive; 227 | 228 | // To handle LONG paths with LONG filters (illegal) 229 | TCHAR szTemp[2*MAXPATHLEN]; 230 | TCHAR szInclude[MAXFILENAMELEN]; 231 | HWND hwndDir; 232 | 233 | UNREFERENCED_PARAMETER(lParam); 234 | 235 | hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); 236 | 237 | switch (wMsg) 238 | { 239 | case WM_INITDIALOG: 240 | 241 | SendMessage(hwndActive, FS_GETFILESPEC, COUNTOF(szTemp), (LPARAM)szTemp); 242 | SetDlgItemText(hDlg, IDD_NAME, szTemp); 243 | SendDlgItemMessage(hDlg, IDD_NAME, EM_LIMITTEXT, MAXFILENAMELEN-1, 0L); 244 | 245 | dwAttribs = (DWORD)GetWindowLong(hwndActive, GWL_ATTRIBS); 246 | 247 | CheckDlgButton(hDlg, IDD_DIR, dwAttribs & ATTR_DIR); 248 | CheckDlgButton(hDlg, IDD_PROGRAMS, dwAttribs & ATTR_PROGRAMS); 249 | CheckDlgButton(hDlg, IDD_DOCS, dwAttribs & ATTR_DOCS); 250 | CheckDlgButton(hDlg, IDD_OTHER, dwAttribs & ATTR_OTHER); 251 | CheckDlgButton(hDlg, IDD_SHOWHIDDEN, dwAttribs & ATTR_HIDDEN); 252 | 253 | break; 254 | 255 | case WM_COMMAND: 256 | switch (GET_WM_COMMAND_ID(wParam, lParam)) 257 | { 258 | case IDD_HELP: 259 | goto DoHelp; 260 | 261 | case IDCANCEL: 262 | EndDialog(hDlg, FALSE); 263 | break; 264 | 265 | case IDOK: 266 | 267 | GetDlgItemText(hDlg, IDD_NAME, szInclude, COUNTOF(szInclude)); 268 | 269 | // strip out quotes and trailing spaces 270 | KillQuoteTrailSpace(szInclude); 271 | 272 | if (szInclude[0] == 0L) 273 | lstrcpy(szInclude, szStarDotStar); 274 | 275 | dwAttribs = 0; 276 | if (IsDlgButtonChecked(hDlg, IDD_DIR)) 277 | dwAttribs |= ATTR_DIR; 278 | if (IsDlgButtonChecked(hDlg, IDD_PROGRAMS)) 279 | dwAttribs |= ATTR_PROGRAMS; 280 | if (IsDlgButtonChecked(hDlg, IDD_DOCS)) 281 | dwAttribs |= ATTR_DOCS; 282 | if (IsDlgButtonChecked(hDlg, IDD_OTHER)) 283 | dwAttribs |= ATTR_OTHER; 284 | if (IsDlgButtonChecked(hDlg, IDD_SHOWHIDDEN)) 285 | dwAttribs |= ATTR_HS; 286 | 287 | if (!dwAttribs) 288 | dwAttribs = ATTR_EVERYTHING; 289 | 290 | EndDialog(hDlg, TRUE); // here to avoid exces repaints 291 | 292 | // we need to update the tree if they changed the system/hidden 293 | // flags. ... FIX31 294 | 295 | if (hwndDir = HasDirWindow(hwndActive)) { 296 | SendMessage(hwndDir, FS_GETDIRECTORY, COUNTOF(szTemp), (LPARAM)szTemp); 297 | lstrcat(szTemp, szInclude); 298 | SetMDIWindowText(hwndActive, szTemp); 299 | 300 | SetWindowLong(hwndActive, GWL_ATTRIBS, dwAttribs); 301 | SendMessage(hwndDir, FS_CHANGEDISPLAY, CD_PATH, 0L); 302 | } 303 | 304 | break; 305 | 306 | default: 307 | return FALSE; 308 | } 309 | break; 310 | 311 | default: 312 | if (wMsg == wHelpMessage) { 313 | DoHelp: 314 | WFHelp(hDlg); 315 | 316 | return TRUE; 317 | } else 318 | return FALSE; 319 | } 320 | return TRUE; 321 | } 322 | 323 | 324 | BOOL 325 | CALLBACK 326 | SelectDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) 327 | { 328 | HWND hwndActive, hwnd; 329 | TCHAR szList[128]; 330 | TCHAR szSpec[MAXFILENAMELEN]; 331 | LPTSTR p; 332 | 333 | UNREFERENCED_PARAMETER(lParam); 334 | 335 | switch (wMsg) { 336 | case WM_INITDIALOG: 337 | SendDlgItemMessage(hDlg, IDD_NAME, EM_LIMITTEXT, COUNTOF(szList)-1, 0L); 338 | SetDlgItemText(hDlg, IDD_NAME, szStarDotStar); 339 | break; 340 | 341 | case WM_COMMAND: 342 | switch (GET_WM_COMMAND_ID(wParam, lParam)) { 343 | case IDD_HELP: 344 | goto DoHelp; 345 | 346 | case IDCANCEL: 347 | EndDialog(hDlg, FALSE); 348 | break; 349 | 350 | case IDOK: // select 351 | case IDYES: // unselect 352 | 353 | // change "Cancel" to "Close" 354 | 355 | LoadString(hAppInstance, IDS_ANDCLOSE, szSpec, COUNTOF(szSpec)); 356 | SetDlgItemText(hDlg, IDCANCEL, szSpec); 357 | 358 | hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); 359 | 360 | if (!hwndActive) 361 | break; 362 | 363 | GetDlgItemText(hDlg, IDD_NAME, szList, COUNTOF(szList)); 364 | 365 | if (hwndActive == hwndSearch) 366 | hwnd = hwndSearch; 367 | else 368 | hwnd = HasDirWindow(hwndActive); 369 | 370 | if (hwnd) { 371 | 372 | p = szList; 373 | 374 | while (p = GetNextFile(p, szSpec, COUNTOF(szSpec))) 375 | SendMessage(hwnd, FS_SETSELECTION, (BOOL)(GET_WM_COMMAND_ID(wParam, lParam) == IDOK), (LPARAM)szSpec); 376 | } 377 | 378 | if (hwnd != hwndSearch) 379 | UpdateStatus(hwndActive); 380 | break; 381 | 382 | default: 383 | return FALSE; 384 | } 385 | break; 386 | 387 | default: 388 | if (wMsg == wHelpMessage) { 389 | DoHelp: 390 | WFHelp(hDlg); 391 | 392 | return TRUE; 393 | } else 394 | return FALSE; 395 | } 396 | return TRUE; 397 | } 398 | 399 | 400 | BOOL 401 | CALLBACK 402 | FontHookProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) 403 | { 404 | KOREAJAPANBEGIN 405 | // Steal from PBrush source to remove @font in the list - SangilJ 406 | TCHAR str[LF_FULLFACESIZE], sel[LF_FULLFACESIZE]; 407 | INT index; 408 | INT cnt; 409 | KOREAJAPANEND 410 | 411 | UNREFERENCED_PARAMETER(lParam); 412 | 413 | switch (wMsg) { 414 | case WM_INITDIALOG: 415 | 416 | // Delete the Vertical Font Face Name in Font Dialog Box of File Manager by Sabgilj 01.14.93 417 | 418 | if (bKOREAJAPAN) { 419 | 420 | cnt = (INT)SendDlgItemMessage(hDlg, cmb1, CB_GETCOUNT, 0, 0L); 421 | index = (INT)SendDlgItemMessage(hDlg, cmb1, CB_GETCURSEL, 0, 0L); 422 | SendDlgItemMessage(hDlg, cmb1, CB_GETLBTEXT, index, (LPARAM)sel); 423 | 424 | for (index = 0 ; index < cnt ; ) { 425 | SendDlgItemMessage( hDlg, cmb1, CB_GETLBTEXT, index, (LPARAM)str); 426 | if (str[0] == TEXT('@')) 427 | cnt = (INT)SendDlgItemMessage(hDlg,cmb1,CB_DELETESTRING,index,0L); 428 | else 429 | index++; 430 | } 431 | index = (INT)SendDlgItemMessage(hDlg, cmb1, CB_FINDSTRING, (WPARAM)-1, (LPARAM)sel); 432 | SendDlgItemMessage(hDlg, cmb1, CB_SETCURSEL, index, 0L); 433 | 434 | } 435 | CheckDlgButton(hDlg, chx3, wTextAttribs & TA_LOWERCASE); 436 | 437 | CheckDlgButton(hDlg, chx4, wTextAttribs & TA_LOWERCASEALL); 438 | break; 439 | 440 | case WM_COMMAND: 441 | switch (wParam) { 442 | case pshHelp: 443 | SendMessage(hwndFrame, wHelpMessage, 0, 0L); 444 | break; 445 | 446 | case IDOK: 447 | if (IsDlgButtonChecked(hDlg, chx3)) 448 | wTextAttribs |= TA_LOWERCASE; 449 | else 450 | wTextAttribs &= ~TA_LOWERCASE; 451 | 452 | if (IsDlgButtonChecked(hDlg, chx4)) 453 | wTextAttribs |= TA_LOWERCASEALL; 454 | else 455 | wTextAttribs &= ~TA_LOWERCASEALL; 456 | break; 457 | } 458 | } 459 | return FALSE; 460 | } 461 | 462 | VOID 463 | RepaintDrivesForFontChange(HWND hwndChild) 464 | { 465 | if (bDriveBar) 466 | MDIClientSizeChange(hwndChild,DRIVEBAR_FLAG); 467 | } 468 | 469 | VOID 470 | NewFont() 471 | { 472 | HFONT hOldFont; 473 | HANDLE hOld; 474 | 475 | HWND hwnd, hwndT, hwndT2; 476 | HDC hdc; 477 | LOGFONT lf; 478 | CHOOSEFONT cf; 479 | TCHAR szBuf[10]; 480 | INT res; 481 | UINT uOld,uNew; 482 | 483 | #define MAX_PT_SIZE 36 484 | 485 | GetObject(hFont, sizeof(lf), (LPVOID)(LPLOGFONT)&lf); 486 | 487 | // 488 | // As we use 'system' font as default, and set initial size 0 for logfont so 489 | // that we can get default size on system, we may haven't got real font 490 | // height yet. mskk. 491 | // 492 | if (bJAPAN && lf.lfHeight == 0) { 493 | TEXTMETRIC tm; 494 | 495 | hdc = GetDC(NULL); 496 | hOld = SelectObject(hdc, hFont); 497 | GetTextMetrics(hdc,&tm); 498 | if (hOld) 499 | SelectObject(hdc, hOld); 500 | ReleaseDC(NULL, hdc); 501 | lf.lfHeight = -(tm.tmHeight-tm.tmInternalLeading); 502 | } 503 | 504 | uOld = (UINT)abs(lf.lfHeight); 505 | 506 | cf.lStructSize = sizeof(cf); 507 | cf.hwndOwner = hwndFrame; 508 | cf.lpLogFont = &lf; 509 | cf.hInstance = hAppInstance; 510 | cf.lpTemplateName = (LPTSTR) MAKEINTRESOURCE(FONTDLG); 511 | cf.lpfnHook = FontHookProc; 512 | cf.nSizeMin = 4; 513 | cf.nSizeMax = 36; 514 | 515 | cf.Flags = bJAPAN ? 516 | CF_SCREENFONTS | CF_SHOWHELP | 517 | CF_ENABLEHOOK | CF_ENABLETEMPLATE | 518 | CF_INITTOLOGFONTSTRUCT | CF_LIMITSIZE : 519 | CF_SCREENFONTS | CF_SHOWHELP | 520 | CF_ENABLEHOOK | CF_ENABLETEMPLATE | 521 | CF_INITTOLOGFONTSTRUCT | CF_LIMITSIZE | 522 | CF_ANSIONLY; 523 | 524 | if (!LoadComdlg()) { 525 | return; 526 | } 527 | 528 | res = ChooseFontW(&cf); 529 | 530 | if (!res) 531 | return; 532 | 533 | wsprintf(szBuf, SZ_PERCENTD, cf.iPointSize / 10); 534 | 535 | uNew = (UINT)abs(lf.lfHeight); 536 | 537 | if (bJAPAN && lf.lfCharSet != SHIFTJIS_CHARSET) 538 | MyMessageBox(hwndFrame, IDS_WINFILE, IDS_WRNNOSHIFTJIS, 539 | MB_OK|MB_ICONEXCLAMATION); 540 | 541 | // Set wTextAttribs BOLD and ITALIC flags 542 | 543 | if (lf.lfItalic != 0) 544 | wTextAttribs |= TA_ITALIC; 545 | else 546 | wTextAttribs &= ~TA_ITALIC; 547 | 548 | WritePrivateProfileString(szSettings, szFace, lf.lfFaceName, szTheINIFile); 549 | WritePrivateProfileString(szSettings, szSize, szBuf, szTheINIFile); 550 | WritePrivateProfileBool(szLowerCase, wTextAttribs); 551 | WritePrivateProfileBool(szFaceWeight, lf.lfWeight); 552 | 553 | if (bJAPAN) 554 | WritePrivateProfileBool(szSaveCharset, lf.lfCharSet); 555 | 556 | hOldFont = hFont; 557 | 558 | hFont = CreateFontIndirect(&lf); 559 | 560 | if (!hFont) { 561 | DeleteObject(hOldFont); 562 | return; 563 | } 564 | 565 | // recalc all the metrics for the new font 566 | 567 | hdc = GetDC(NULL); 568 | hOld = SelectObject(hdc, hFont); 569 | GetTextStuff(hdc); 570 | if (hOld) 571 | SelectObject(hdc, hOld); 572 | ReleaseDC(NULL, hdc); 573 | 574 | 575 | RepaintDrivesForFontChange((HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L)); 576 | 577 | // now update all listboxes that are using the old 578 | // font with the new font 579 | 580 | for (hwnd = GetWindow(hwndMDIClient, GW_CHILD); hwnd; 581 | hwnd = GetWindow(hwnd, GW_HWNDNEXT)) { 582 | 583 | if (GetWindow(hwnd, GW_OWNER)) 584 | continue; 585 | 586 | if ((INT)GetWindowLong(hwnd, GWL_TYPE) == TYPE_SEARCH) { 587 | SendMessage((HWND)GetDlgItem(hwnd, IDCW_LISTBOX), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); 588 | SendMessage((HWND)GetDlgItem(hwnd, IDCW_LISTBOX), LB_SETITEMHEIGHT, 0, (LONG)dyFileName); 589 | 590 | // SearchWin font ext 591 | // in case font changed, update maxExt 592 | 593 | SendMessage(hwnd, FS_CHANGEDISPLAY, CD_SEARCHFONT, 0L); 594 | 595 | } else { 596 | 597 | if (hwndT = HasDirWindow(hwnd)) { 598 | 599 | hwndT2 = GetDlgItem(hwndT, IDCW_LISTBOX); 600 | SetLBFont(hwndT, 601 | hwndT2, 602 | hFont, 603 | GetWindowLong(hwnd, GWL_VIEW), 604 | (LPXDTALINK)GetWindowLong(hwndT, GWL_HDTA)); 605 | 606 | InvalidateRect(hwndT2, NULL, TRUE); 607 | } 608 | 609 | if (hwndT = HasTreeWindow(hwnd)) { 610 | 611 | // the tree list box 612 | 613 | hwndT = GetDlgItem(hwndT, IDCW_TREELISTBOX); 614 | 615 | SendMessage(hwndT, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); 616 | SendMessage(hwndT, LB_SETITEMHEIGHT, 0, (LONG)dyFileName); 617 | 618 | /* 619 | * Force the recalculation of GWL_XTREEMAX (max text extent). 620 | */ 621 | SendMessage(HasTreeWindow(hwnd), TC_RECALC_EXTENT, (WPARAM)hwndT, 0L); 622 | } 623 | } 624 | } 625 | DeleteObject(hOldFont); // done with this now, delete it 626 | } 627 | 628 | 629 | 630 | /*--------------------------------------------------------------------------*/ 631 | /* */ 632 | /* ConfirmDlgProc() - */ 633 | /* */ 634 | /*--------------------------------------------------------------------------*/ 635 | 636 | BOOL 637 | CALLBACK 638 | ConfirmDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) 639 | { 640 | UNREFERENCED_PARAMETER(lParam); 641 | 642 | switch (wMsg) 643 | { 644 | case WM_INITDIALOG: 645 | CheckDlgButton(hDlg, IDD_DELETE, bConfirmDelete); 646 | CheckDlgButton(hDlg, IDD_SUBDEL, bConfirmSubDel); 647 | CheckDlgButton(hDlg, IDD_REPLACE, bConfirmReplace); 648 | CheckDlgButton(hDlg, IDD_MOUSE, bConfirmMouse); 649 | CheckDlgButton(hDlg, IDD_CONFIG, bConfirmFormat); 650 | CheckDlgButton(hDlg, IDD_READONLY,bConfirmReadOnly); 651 | break; 652 | 653 | case WM_COMMAND: 654 | switch (GET_WM_COMMAND_ID(wParam, lParam)) 655 | { 656 | case IDD_HELP: 657 | goto DoHelp; 658 | 659 | case IDCANCEL: 660 | EndDialog(hDlg, FALSE); 661 | break; 662 | 663 | case IDOK: 664 | bConfirmDelete = IsDlgButtonChecked(hDlg, IDD_DELETE); 665 | bConfirmSubDel = IsDlgButtonChecked(hDlg, IDD_SUBDEL); 666 | bConfirmReplace = IsDlgButtonChecked(hDlg, IDD_REPLACE); 667 | bConfirmMouse = IsDlgButtonChecked(hDlg, IDD_MOUSE); 668 | bConfirmFormat = IsDlgButtonChecked(hDlg, IDD_CONFIG); 669 | 670 | bConfirmReadOnly= IsDlgButtonChecked(hDlg, IDD_READONLY); 671 | 672 | WritePrivateProfileBool(szConfirmDelete, bConfirmDelete); 673 | WritePrivateProfileBool(szConfirmSubDel, bConfirmSubDel); 674 | WritePrivateProfileBool(szConfirmReplace, bConfirmReplace); 675 | WritePrivateProfileBool(szConfirmMouse, bConfirmMouse); 676 | WritePrivateProfileBool(szConfirmFormat, bConfirmFormat); 677 | 678 | WritePrivateProfileBool(szConfirmReadOnly,bConfirmReadOnly); 679 | 680 | EndDialog(hDlg, TRUE); 681 | break; 682 | 683 | default: 684 | return(FALSE); 685 | } 686 | break; 687 | 688 | default: 689 | if (wMsg == wHelpMessage) { 690 | DoHelp: 691 | WFHelp(hDlg); 692 | 693 | return TRUE; 694 | } else 695 | return FALSE; 696 | } 697 | return TRUE; 698 | } 699 | 700 | VOID 701 | KillQuoteTrailSpace( LPTSTR szFile ) 702 | { 703 | register LPTSTR pc; 704 | register LPTSTR pcNext; 705 | LPTSTR pcLastSpace = NULL; 706 | 707 | // Could reuse szFile, but that's ok, 708 | // we use it as a register probably anyway. 709 | 710 | pc = pcNext = szFile; 711 | 712 | while ( *pcNext ) { 713 | 714 | if ( CHAR_DQUOTE == *pcNext ) { 715 | pcNext++; 716 | continue; 717 | } 718 | 719 | if ( CHAR_SPACE == *pcNext ) { 720 | if ( !pcLastSpace ) { 721 | pcLastSpace = pc; 722 | } 723 | } else { 724 | pcLastSpace = NULL; 725 | } 726 | 727 | *pc++ = *pcNext++; 728 | } 729 | 730 | // Delimit! 731 | *pc = CHAR_NULL; 732 | 733 | // Now axe trailing spaces; 734 | if (pcLastSpace) 735 | *pcLastSpace = CHAR_NULL; 736 | } 737 | -------------------------------------------------------------------------------- /src/wfdlgs.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfdlgs.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #define RUNDLG 10 11 | #define MYPRINTDLG 11 12 | #define ASSOCIATEDLG 12 13 | #define SEARCHDLG 13 14 | #define MOVECOPYDLG 14 15 | #define DELETEDLG 15 16 | #define ATTRIBSDLG 16 17 | #define MAKEDIRDLG 17 18 | #define EXITDLG 18 19 | #define CHOOSEDRIVEDLG 19 20 | #define DISKCOPYDLG 20 21 | #define DISKCOPY2DLG 21 22 | #define DISKCOPYPROGRESSDLG 22 23 | #define DISKLABELDLG 23 24 | #define FORMATDLG 24 25 | #define FORMAT2DLG 25 26 | #define FORMATPROGRESSDLG 26 27 | #define SYSDISKPROGRESSDLG 27 28 | #define CONNECTDLG 28 29 | #define PREVIOUSDLG 29 30 | #define OTHERDLG 30 31 | #define SORTBYDLG 31 32 | #define INCLUDEDLG 32 33 | #define CONFIRMDLG 33 34 | #define DMSTATUSDLG 35 35 | #define PRTDLG 36 36 | #define CHOOSENETDRIVEDLG 37 37 | #define MULTIPLEATTRIBSDLG 38 38 | #define CONFIRMREPLACE 39 39 | #define CONFIRMDELETE 40 40 | #define CONFIRMRMDIR 41 41 | #define CONFIRMMOVE 42 42 | #define CONFIRMRENAME 43 43 | #define SELECTDLG 44 44 | #define DRIVEDLG 45 45 | #define LFNTOFATDLG 46 46 | #define CHOOSESYSDRIVEDLG 47 47 | #define ATTRIBSDLGDIR 48 48 | #define FONTDLG 49 // was 145 and etc. 49 | #define CANCELDLG 50 50 | #define CONFIRMNOACCESS 51 51 | #define CONFIRMNOACCESSDEST 52 52 | #define SEARCHPROGDLG 53 53 | 54 | #define COPYTOCLIPBOARDDLG 54 55 | 56 | #define ASSOCIATEFILEDLG 55 57 | #define ASSOCIATEFILEDLGCONFIG 56 // Same dialog 58 | 59 | #define COMPRESSPROGDLG 57 // Compression progress dialogs 60 | #define UNCOMPRESSPROGDLG 58 61 | #define COMPRESSERRDLG 59 // Compression Error Dialog 62 | 63 | #define IDD_TEXT -1 64 | #define IDD_TEXT1 100 65 | #define IDD_DIR 101 66 | #define IDD_FROM 102 67 | #define IDD_TO 103 68 | #define IDD_STATUS 104 69 | #define IDD_DATE1 105 70 | #define IDD_DATE2 106 71 | #define IDD_YESALL 107 72 | #define IDD_TOSTATUS 108 73 | #define IDD_TONAME 109 74 | #define IDD_TEXT2 111 75 | #define IDD_IGNOREALL 112 76 | 77 | 78 | #define IDD_NAME 201 79 | #define IDD_TYPE 202 80 | #define IDD_SIZE 203 81 | #define IDD_DATE 204 82 | #define IDD_TIME 205 83 | #define IDD_FLAGS 206 84 | 85 | #define IDD_DOSNAMES 266 86 | 87 | #define IDD_UPPERCASE 207 88 | #define IDD_SETDEFAULT 208 89 | #define IDD_ASSOC 209 90 | #define IDD_PROGRAMS 210 91 | #define IDD_DOCS 211 92 | #define IDD_OTHER 212 93 | #define IDD_FOUND 213 94 | #define IDD_LOAD 214 95 | #define IDD_READONLY 215 96 | #define IDD_HIDDEN 216 97 | #define IDD_ARCHIVE 217 98 | #define IDD_SYSTEM 218 99 | #define IDD_DELETE 219 100 | #define IDD_SUBDEL 220 101 | #define IDD_REPLACE 221 102 | #define IDD_DRIVE 222 103 | #define IDD_PATH 223 104 | #define IDD_PASSWORD 224 105 | #define IDD_ADDPREV 225 106 | #define IDD_PREV 226 107 | #define IDD_NETBROWSE 227 108 | #define IDD_SERVERS 228 109 | #define IDD_SHARES 229 110 | #define IDD_SAVESETTINGS 231 111 | #define IDD_SEARCHALL 232 112 | #define IDD_HIGHCAP 241 113 | #define IDD_MAKESYS 242 114 | #define IDD_PROGRESS 243 115 | #define IDD_VERIFY 244 116 | #define IDD_DRIVE1 245 117 | #define IDD_DRIVE2 246 118 | #define IDD_DRIVE3 247 119 | #define IDD_DRIVE4 248 120 | #define IDD_MOUSE 249 121 | #define IDD_SHOWHIDDEN 250 122 | #define IDD_CONFIG 251 123 | #define IDD_CLOSE 252 124 | #define IDD_PERM 253 125 | #define IDD_HELP 254 126 | #define IDD_DISCONNECT 255 127 | #define IDD_COPYTOCLIP 256 128 | #define IDD_COPYTOFILE 257 129 | 130 | #define IDD_VERLABEL 258 131 | #define IDD_VERSION 259 132 | #define IDD_SIZELABEL 260 133 | #define IDD_NAMELABEL 261 134 | #define IDD_VERSION_FRAME 262 135 | #define IDD_VERSION_KEY 263 136 | #define IDD_VERSION_VALUE 264 137 | #define IDD_COPYRIGHT 265 138 | 139 | // Just to remind people... 140 | // #define IDD_DOSNAMES 266 141 | 142 | #define IDD_COMPRESSED 267 143 | #define IDD_CSIZELABEL 268 144 | #define IDD_CSIZE 269 145 | #define IDD_CRATIOLABEL 270 146 | #define IDD_CRATIO 271 147 | 148 | 149 | #define IDD_NEW 300 150 | #define IDD_DESC 301 151 | #define IDD_DESCTEXT 302 152 | #define IDD_ADD 303 153 | #define IDD_COMMAND 304 154 | #define IDD_ADVANCED 305 155 | #define IDD_ACTION 306 156 | #define IDD_DDE 308 157 | #define IDD_DDEMESG 309 158 | #define IDD_DDEAPP 310 159 | #define IDD_DDENOTRUN 311 160 | #define IDD_DDETOPIC 312 161 | 162 | #define IDD_COMMANDTEXT 313 163 | 164 | #define IDD_CLASSLIST 314 165 | 166 | #define IDD_EXT 315 167 | #define IDD_EXTTEXT 316 168 | #define IDD_EXTLIST 317 169 | 170 | #define IDD_BROWSE 318 171 | 172 | #define IDD_DDEMESGTEXT 320 173 | #define IDD_DDEAPPTEXT 321 174 | #define IDD_DDENOTRUNTEXT 322 175 | #define IDD_DDETOPICTEXT 323 176 | #define IDD_DDEOPTIONALTEXT 324 177 | 178 | #define IDD_COMPRESS_FILE 341 179 | #define IDD_COMPRESS_DIR 342 180 | #define IDD_COMPRESS_TDIRS 343 181 | #define IDD_COMPRESS_TFILES 344 182 | #define IDD_COMPRESS_USIZE 345 183 | #define IDD_COMPRESS_CSIZE 346 184 | #define IDD_COMPRESS_RATIO 347 185 | #define IDD_UNCOMPRESS_FILE 351 186 | #define IDD_UNCOMPRESS_DIR 352 187 | #define IDD_UNCOMPRESS_TDIRS 353 188 | #define IDD_UNCOMPRESS_TFILES 354 189 | 190 | 191 | #define IDD_ASSOCFIRST 100 192 | #define IDD_ASSOCLAST 109 193 | 194 | 195 | #define IDD_HIDE 110 196 | 197 | 198 | #define IDD_NETWORKFIRST 500 199 | 200 | // dialog item IDs 201 | #define IDD_MYTEXT 4000 202 | #define IDD_GASGAUGE 4001 203 | 204 | #define IDD_KK_TEXTTO 2001 205 | #define IDD_KK_TEXTFROM 2002 206 | -------------------------------------------------------------------------------- /src/wfdoc.txt: -------------------------------------------------------------------------------- 1 | WINFILE Development Documentation - 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | Licensed under the MIT License. 5 | 6 | This file contains notes on the conventions used while developing WINFILE.EXE. 7 | It is broken into several sections: 8 | 9 | o Window Definitions 10 | o Window Relationships 11 | o Message Conventions 12 | o Variable Conventions 13 | o Utility Functions 14 | o Source File Organization 15 | o Segmentation 16 | o Etc. 17 | 18 | 19 | 20 | Window Definitions - 21 | 22 | 23 | 24 | Window Relationships - 25 | 26 | 27 | 28 | Message Conventions - 29 | 30 | FS_CHANGEDISPLAY: 31 | This message causes the window to alter the contents of what it's 32 | displaying. It is valid for Directory and Search Results windows. 33 | There isn't a return value. 34 | 35 | wParam - Indicates the type of change being made: 36 | CD_PATH - Changes the path Directory window 37 | displays including a filespec 38 | with wildcards. Valid only for 39 | Directory windows. lParam points 40 | to the new path. If lParam is 41 | NULL, this is the REFRESH command. 42 | 43 | CD_VIEW - LOWORD(lParam) contains the new 44 | set of view flags. Valid only for 45 | Directory windows. 46 | 47 | CD_SORT - LOWORD(lParam) contains the new 48 | sort flags. 49 | 50 | lParam - Depends upon the setting of wParam. 51 | 52 | 53 | FS_GETDIRECTORY: 54 | This message stores the window's current directory in the buffer 55 | pointed to by lParam. It is valid for the Tree and Directory MDI 56 | windows. The path is returned in upper case and always ends with 57 | a backslash. 58 | 59 | ex.: "E:\PRE\", "C:\" 60 | 61 | wParam - Maximum length of string 62 | lParam - LPTSTR to buffer will contain the directory path 63 | 64 | 65 | FS_GETDRIVE: 66 | This message returns the single letter designation of the window's 67 | current drive. It is valid for Tree and Directory MDI windows. 68 | The letter is returned in upper case. 69 | 70 | ex.: 'C', 'A' 71 | 72 | wParam - Unused 73 | lParam - Unused 74 | 75 | FS_GETSELECTION: 76 | This messages returns a near pointer to a string containing the 77 | names of the window's selected file(s seperated by spaces. The 78 | string is returned upper case. No path info in included unless 79 | a directory is selected. The directories includes full path info 80 | and NOT terminated with backslash. 81 | 82 | The HIWORD of the return is a BOOL indicating if the last selected 83 | item is a directory or not. 84 | 85 | ex.: "FOO.TXT LOO.LOO E:\DIR" 86 | 87 | wParam - TRUE if only the latest file selected should be 88 | returned 89 | lParam - Unused 90 | 91 | NOTE: The sender is responsible for LocalFree()ing the returned 92 | string. 93 | 94 | 95 | Variable Conventions - 96 | 97 | Window Words - 98 | Each MDI Child window has the following extra bytes allocated with it: 99 | 100 | GWW_VIEW - The "current" view flags for the window 101 | GWW_SORT - The "current" sort flags for the window 102 | GWW_ATTRIBS - The "current" attributes to display 103 | 104 | Note: The Tree window contains the "System Wide" versions 105 | of these flags. The Search window is hard coded 106 | to VIEW_NAMEONLY, IDM_BYNAME, and ATTR_DEFAULT. 107 | 108 | In addition, MDI children have the following extra bytes which are 109 | specific to them: 110 | 111 | GWW_HWNDLB - (Directory) The hwnd of the window's list box 112 | GWW_HDTA - (Directory) The handle of the directories DTA list 113 | 114 | 115 | 116 | 117 | Utility Functions - 118 | 119 | 120 | 121 | Source File Organization - 122 | 123 | 124 | 125 | Segmentation - 126 | -------------------------------------------------------------------------------- /src/wfdos.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfdos.c 4 | 5 | Ported code from wfdos.asm 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include "winfile.h" 13 | 14 | // Warning: assumes bytes per sector < 2 gigs 15 | 16 | VOID 17 | GetDiskSpace(DRIVE drive, 18 | PLARGE_INTEGER pqFreeSpace, 19 | PLARGE_INTEGER pqTotalSpace) 20 | { 21 | DWORD dwSectorsPerCluster; 22 | DWORD dwBytesPerSector; 23 | DWORD dwFreeClusters; 24 | DWORD dwTotalClusters; 25 | 26 | TCHAR szDriveRoot[] = SZ_ACOLONSLASH; 27 | 28 | DRIVESET(szDriveRoot, drive); 29 | 30 | if (GetDiskFreeSpace(szDriveRoot, 31 | &dwSectorsPerCluster, 32 | &dwBytesPerSector, 33 | &dwFreeClusters, 34 | &dwTotalClusters)) { 35 | 36 | *pqFreeSpace = TriMultiply(dwFreeClusters,dwSectorsPerCluster,dwBytesPerSector); 37 | *pqTotalSpace= TriMultiply(dwTotalClusters,dwSectorsPerCluster,dwBytesPerSector); 38 | 39 | } else { 40 | LARGE_INTEGER_NULL(*pqFreeSpace); 41 | LARGE_INTEGER_NULL(*pqTotalSpace); 42 | } 43 | } 44 | 45 | 46 | INT 47 | ChangeVolumeLabel(DRIVE drive, LPTSTR lpNewVolName) 48 | { 49 | TCHAR szDrive[] = SZ_ACOLON; 50 | 51 | DRIVESET(szDrive,drive); 52 | 53 | return (*lpfnSetLabel)(szDrive, lpNewVolName); 54 | } 55 | 56 | 57 | // 58 | // All references to szVolumeName should go through GetVolumelabel! 59 | // (To assure correct ] ending!) 60 | // 61 | 62 | DWORD 63 | GetVolumeLabel(DRIVE drive, LPTSTR* ppszVol, BOOL bBrackets) 64 | { 65 | U_VolInfo(drive); 66 | 67 | *ppszVol = aDriveInfo[drive].szVolNameMinusFour+4; 68 | 69 | if (GETRETVAL(VolInfo,drive) || !**ppszVol) { 70 | 71 | return GETRETVAL(VolInfo,drive); 72 | } 73 | 74 | (*ppszVol)[aDriveInfo[drive].dwVolNameMax] = CHAR_NULL; 75 | 76 | if (bBrackets) { 77 | 78 | (*ppszVol)--; 79 | (*ppszVol)[0] = CHAR_OPENBRACK; 80 | 81 | lstrcat(*ppszVol, SZ_CLOSEBRACK); 82 | } 83 | return ERROR_SUCCESS; 84 | } 85 | 86 | 87 | DWORD 88 | FillVolumeInfo(DRIVE drive, LPTSTR lpszVolName, PDWORD pdwVolumeSerialNumber, 89 | PDWORD pdwMaximumComponentLength, PDWORD pdwFileSystemFlags, 90 | LPTSTR lpszFileSysName) 91 | { 92 | TCHAR szDrive[] = SZ_ACOLONSLASH; 93 | PDRIVEINFO pDriveInfo = &aDriveInfo[drive]; 94 | 95 | DRIVESET(szDrive,drive); 96 | 97 | if (!(GetVolumeInformation(szDrive, 98 | lpszVolName, COUNTOF(pDriveInfo->szVolNameMinusFour)-4, 99 | pdwVolumeSerialNumber, 100 | pdwMaximumComponentLength, 101 | pdwFileSystemFlags, 102 | lpszFileSysName, COUNTOF(pDriveInfo->szFileSysName)))) { 103 | 104 | lpszVolName[0] = CHAR_NULL; 105 | 106 | *pdwVolumeSerialNumber = 0; 107 | *pdwMaximumComponentLength = 0; 108 | *pdwFileSystemFlags = 0; 109 | 110 | lpszFileSysName[0] = CHAR_NULL; 111 | 112 | return GetLastError(); 113 | } 114 | 115 | return ERROR_SUCCESS; 116 | } 117 | -------------------------------------------------------------------------------- /src/wfext.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfExt.c 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #include "winfile.h" 11 | 12 | //---------------------------- 13 | // 14 | // Winfile Extension cache 15 | // 16 | //---------------------------- 17 | 18 | LPXDTA* lplpxdtaExtSelItems; 19 | UINT uExtSelItems = (UINT)-1; 20 | WCHAR szExtSelDir[MAXPATHLEN]; 21 | WCHAR szExtSelDirShort[MAXPATHLEN]; 22 | 23 | 24 | VOID 25 | ExtSelItemsInvalidate() 26 | { 27 | if (uExtSelItems != (UINT)-1) { 28 | 29 | if (lplpxdtaExtSelItems) { 30 | LocalFree(lplpxdtaExtSelItems); 31 | } 32 | 33 | uExtSelItems = (UINT)-1; 34 | } 35 | } 36 | 37 | 38 | LONG 39 | GetExtSelection( 40 | HWND hwnd, 41 | UINT uItem, 42 | LPARAM lParam, 43 | BOOL bSearch, 44 | BOOL bGetCount, 45 | BOOL bLFNAware, 46 | BOOL bUnicode) 47 | { 48 | #define lpSelW ((LPFMS_GETFILESELW)lParam) 49 | #define lpSelA ((LPFMS_GETFILESELA)lParam) 50 | 51 | LPXDTALINK lpStart; 52 | LPXDTA lpxdta = NULL; 53 | UINT uSel, i; 54 | HWND hwndLB; 55 | WCHAR szPath[COUNTOF(lpSelW->szName)]; 56 | BOOL bUsedDefaultChar; 57 | HWND hwndView; 58 | LPINT lpExtSelItems; 59 | LPWSTR pszAlternateFileName; 60 | LPWSTR pszFileName; 61 | 62 | hwndView = bSearch ? 63 | hwnd : 64 | HasDirWindow(hwnd); 65 | 66 | lpStart = (LPXDTALINK)GetWindowLong(hwndView, GWL_HDTA); 67 | hwndLB = GetDlgItem(hwndView, IDCW_LISTBOX); 68 | 69 | if (uExtSelItems == (UINT)-1) { 70 | 71 | // 72 | // Cache invalid, refresh 73 | // 74 | uExtSelItems = (UINT) SendMessage(hwndLB, LB_GETSELCOUNT, 0, 0L); 75 | 76 | lpExtSelItems = (LPINT) LocalAlloc(LMEM_FIXED, sizeof(INT) * uExtSelItems); 77 | 78 | if (lpExtSelItems == NULL) { 79 | uExtSelItems = (UINT)-1; 80 | return 0L; 81 | } 82 | 83 | lplpxdtaExtSelItems = (LPXDTA*) LocalAlloc(LMEM_FIXED, 84 | sizeof(LPXDTA) * uExtSelItems); 85 | 86 | if (lplpxdtaExtSelItems == NULL) { 87 | 88 | LocalFree(lpExtSelItems); 89 | uExtSelItems = (UINT)-1; 90 | return 0L; 91 | } 92 | 93 | uExtSelItems = (UINT)SendMessage(hwndLB, 94 | LB_GETSELITEMS, 95 | (WPARAM)uExtSelItems, 96 | (LPARAM)lpExtSelItems); 97 | 98 | for (i=0, uSel=0; i < uExtSelItems; i++) { 99 | 100 | SendMessage(hwndLB, 101 | LB_GETTEXT, 102 | lpExtSelItems[i], 103 | (LPARAM)&lplpxdtaExtSelItems[i]); 104 | } 105 | 106 | // 107 | // We can't cache this because there's files may be in many 108 | // different directories. 109 | // 110 | if (!bSearch) { 111 | SendMessage(hwnd, 112 | FS_GETDIRECTORY, 113 | COUNTOF(szExtSelDir), 114 | (LPARAM)szExtSelDir); 115 | 116 | GetShortPathName(szExtSelDir, szExtSelDirShort, COUNTOF(szExtSelDirShort)); 117 | } 118 | 119 | LocalFree(lpExtSelItems); 120 | } 121 | 122 | 123 | for (i=0, uSel=0; i < uExtSelItems; i++) { 124 | 125 | lpxdta = lplpxdtaExtSelItems[i]; 126 | 127 | if (!lpxdta || lpxdta->dwAttrs & ATTR_PARENT) 128 | continue; 129 | 130 | if ((!bLFNAware && (lpxdta->dwAttrs & ATTR_LFN)) && 131 | !MemGetAlternateFileName(lpxdta)[0]) { 132 | 133 | continue; 134 | } 135 | 136 | if (!bGetCount && uItem == uSel) { 137 | break; 138 | } 139 | 140 | uSel++; 141 | } 142 | 143 | if (!lpxdta) 144 | { 145 | // 146 | // Quit out if lpxdta is null. 147 | // 148 | return (0L); 149 | } 150 | 151 | // 152 | // We use uSel regardless; if we wanted item #4 but we ran out 153 | // at #2, give'm #2. This adheres to the previous semantics. 154 | // 155 | if (bGetCount) { 156 | return (LONG)uSel; 157 | } 158 | 159 | pszAlternateFileName = MemGetAlternateFileName(lpxdta); 160 | 161 | if (bUnicode) { 162 | 163 | // 164 | // lpxdta setup up above 165 | // 166 | lpSelW->bAttr = (BYTE)lpxdta->dwAttrs; 167 | lpSelW->ftTime = lpxdta->ftLastWriteTime; 168 | lpSelW->dwSize = lpxdta->qFileSize.LowPart; 169 | 170 | pszFileName = lpSelW->szName; 171 | 172 | } else { 173 | 174 | lpSelA->bAttr = (BYTE)lpxdta->dwAttrs; 175 | lpSelA->ftTime = lpxdta->ftLastWriteTime; 176 | lpSelA->dwSize = lpxdta->qFileSize.LowPart; 177 | 178 | pszFileName = szPath; 179 | } 180 | 181 | if (bSearch) { 182 | 183 | lstrcpy(pszFileName, MemGetFileName(lpxdta)); 184 | 185 | // 186 | // The search window can have any random directory for 187 | // each item, so don't use szExtSelDirShort caching 188 | // 189 | if (!bLFNAware) { 190 | 191 | GetShortPathName(MemGetFileName(lpxdta), pszFileName, COUNTOF(lpSelW->szName)); 192 | } 193 | 194 | } else { 195 | 196 | // 197 | // If we are LFNAware, then we need to get the dir. 198 | // 199 | if (bLFNAware) { 200 | 201 | lstrcpy(pszFileName, szExtSelDir); 202 | lstrcat(pszFileName, MemGetFileName(lpxdta)); 203 | 204 | } else { 205 | 206 | // 207 | // Need short dir; use cache. 208 | // 209 | lstrcpy(pszFileName, szExtSelDirShort); 210 | lstrcat(pszFileName, 211 | pszAlternateFileName[0] ? 212 | pszAlternateFileName : 213 | MemGetFileName(lpxdta)); 214 | } 215 | 216 | } 217 | 218 | if (!bUnicode) { 219 | 220 | // 221 | // Not unicode, must do the thunking now 222 | // from our temp buffer to lpSelA 223 | // 224 | bUsedDefaultChar = FALSE; 225 | 226 | if (!WideCharToMultiByte(CP_ACP, 0, szPath, -1, lpSelA->szName, 227 | COUNTOF(lpSelA->szName), NULL, &bUsedDefaultChar)) { 228 | 229 | lpSelA->szName[0] = CHAR_NULL; 230 | } 231 | 232 | if (bUsedDefaultChar) { 233 | 234 | if (!WideCharToMultiByte(CP_ACP, 0, szPath, -1, lpSelA->szName, 235 | COUNTOF(lpSelA->szName), NULL, &bUsedDefaultChar)) { 236 | 237 | lpSelA->szName[0] = CHAR_NULL; 238 | } 239 | } 240 | } 241 | 242 | return (LONG)uSel; 243 | } 244 | #undef lpSelW 245 | #undef lpSelA 246 | 247 | 248 | LONG 249 | GetDriveInfo(HWND hwnd, UINT uMsg, LPARAM lParam) 250 | { 251 | #define lpSelW ((LPFMS_GETDRIVEINFOW)lParam) 252 | #define lpSelA ((LPFMS_GETDRIVEINFOA)lParam) 253 | 254 | WCHAR szPath[MAXPATHLEN]; 255 | LPWSTR lpszVol; 256 | 257 | // this has to work for hwnd a tree or search window 258 | 259 | SendMessage(hwnd, FS_GETDIRECTORY, COUNTOF(szPath), (LPARAM)szPath); 260 | StripBackslash(szPath); 261 | 262 | if (FM_GETDRIVEINFOW == uMsg) 263 | { 264 | lpSelW->dwTotalSpace = qTotalSpace.LowPart; 265 | lpSelW->dwFreeSpace = qFreeSpace.LowPart; 266 | 267 | lstrcpy(lpSelW->szPath, szPath); 268 | 269 | if (ISUNCPATH(szPath)) 270 | { 271 | lpSelW->szVolume[0] = CHAR_NULL; 272 | } 273 | else 274 | { 275 | GetVolumeLabel(DRIVEID(szPath), &lpszVol, FALSE); 276 | StrNCpy(lpSelW->szVolume, lpszVol, COUNTOF(lpSelW->szVolume)-1); 277 | } 278 | } 279 | else 280 | { 281 | lpSelA->dwTotalSpace = qTotalSpace.LowPart; 282 | lpSelA->dwFreeSpace = qFreeSpace.LowPart; 283 | 284 | if (!WideCharToMultiByte( CP_ACP, 285 | 0, 286 | szPath, 287 | -1, 288 | lpSelA->szPath, 289 | COUNTOF(lpSelA->szPath), 290 | NULL, 291 | NULL )) 292 | { 293 | lpSelA->szPath[0] = CHAR_NULL; 294 | } 295 | 296 | if (ISUNCPATH(szPath)) 297 | { 298 | lpSelW->szVolume[0] = CHAR_NULL; 299 | } 300 | else 301 | { 302 | GetVolumeLabel(DRIVEID(szPath), &lpszVol, FALSE); 303 | 304 | if (!WideCharToMultiByte( CP_ACP, 305 | 0, 306 | lpszVol, 307 | -1, 308 | lpSelA->szVolume, 309 | COUNTOF(lpSelA->szVolume), 310 | NULL, 311 | NULL )) 312 | { 313 | lpSelA->szVolume[0] = CHAR_NULL; 314 | } 315 | lpSelA->szVolume[COUNTOF(lpSelA->szVolume)-1] = CHAR_NULL; 316 | } 317 | } 318 | 319 | // 320 | // Force update 321 | // 322 | 323 | WAITNET(); 324 | 325 | if (ISUNCPATH(szPath)) 326 | { 327 | lpSelW->szShare[0] = CHAR_NULL; 328 | return (1L); 329 | } 330 | 331 | U_NetCon(DRIVEID(szPath)); 332 | 333 | if (WFGetConnection(DRIVEID(szPath), &lpszVol, FALSE, ALTNAME_REG)) { 334 | lpSelW->szShare[0] = CHAR_NULL; 335 | } else { 336 | 337 | if (FM_GETDRIVEINFOW == uMsg) { 338 | 339 | StrNCpy(lpSelW->szShare, lpszVol, COUNTOF(lpSelW->szShare)-1); 340 | lpSelW->szShare[COUNTOF(lpSelW->szShare)-1] = CHAR_NULL; 341 | 342 | } else { 343 | 344 | if (!WideCharToMultiByte(CP_ACP, 0, lpszVol, -1, 345 | lpSelA->szShare, COUNTOF(lpSelA->szShare), NULL, NULL)) { 346 | 347 | lpSelA->szShare[0] = CHAR_NULL; 348 | } 349 | lpSelA->szShare[COUNTOF(lpSelA->szShare)-1] = CHAR_NULL; 350 | } 351 | } 352 | 353 | return (1L); 354 | } 355 | #undef lpSelW 356 | #undef lpSelA 357 | 358 | 359 | VOID 360 | FreeExtensions() 361 | { 362 | INT i; 363 | HMENU hMenuFrame; 364 | INT iMax; 365 | HWND hwndActive; 366 | 367 | FreeToolbarExtensions(); 368 | 369 | 370 | hMenuFrame = GetMenu(hwndFrame); 371 | hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); 372 | if (hwndActive && GetWindowLong(hwndActive, GWL_STYLE) & WS_MAXIMIZE) 373 | iMax = 1; 374 | else 375 | iMax = 0; 376 | 377 | for (i = 0; i < iNumExtensions; i++) { 378 | (extensions[i].ExtProc)(NULL, FMEVENT_UNLOAD, 0L); 379 | DeleteMenu(hMenuFrame, IDM_EXTENSIONS + iMax, MF_BYPOSITION); 380 | FreeLibrary((HANDLE)extensions[i].hModule); 381 | } 382 | iNumExtensions = 0; 383 | } 384 | 385 | 386 | LRESULT 387 | ExtensionMsgProc(UINT wMsg, WPARAM wParam, LPARAM lParam) 388 | { 389 | HWND hwndActive; 390 | HWND hwndTree, hwndDir, hwndFocus; 391 | 392 | hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L); 393 | GetTreeWindows(hwndActive, &hwndTree, &hwndDir); 394 | 395 | switch (wMsg) { 396 | 397 | case FM_RELOAD_EXTENSIONS: 398 | SendMessage(hwndFrame, WM_CANCELMODE, 0, 0L); 399 | 400 | SaveRestoreToolbar(TRUE); 401 | SendMessage(hwndToolbar, WM_SETREDRAW, FALSE, 0L); 402 | 403 | FreeExtensions(); 404 | 405 | InitExtensions(); 406 | SaveRestoreToolbar(FALSE); 407 | 408 | SendMessage(hwndToolbar, WM_SETREDRAW, TRUE, 0L); 409 | InvalidateRect(hwndToolbar, NULL, TRUE); 410 | 411 | DrawMenuBar(hwndFrame); 412 | break; 413 | 414 | case FM_GETFOCUS: 415 | // wParam unused 416 | // lParam unused 417 | // return window tyep with focus 418 | 419 | if (hwndActive == hwndSearch) 420 | return FMFOCUS_SEARCH; 421 | 422 | hwndFocus = GetTreeFocus(hwndActive); 423 | 424 | if (hwndFocus == hwndTree) 425 | return FMFOCUS_TREE; 426 | else if (hwndFocus == hwndDir) 427 | return FMFOCUS_DIR; 428 | else if (hwndFocus == hwndDriveBar) 429 | return FMFOCUS_DRIVES; 430 | break; 431 | 432 | case FM_GETDRIVEINFOA: 433 | case FM_GETDRIVEINFOW: 434 | 435 | // wParam unused 436 | // lParam LPFMS_GETDRIVEINFO structure to be filled in 437 | 438 | return GetDriveInfo(hwndActive, wMsg, lParam); 439 | break; 440 | 441 | case FM_REFRESH_WINDOWS: 442 | // wParam 0 refresh the current window 443 | // non zero refresh all windows 444 | // lParam unused 445 | 446 | 447 | // 448 | // Note: For all windows that it refreshes, 449 | // it requests a WNetGetDirectoryType flush cache. 450 | 451 | UpdateDriveList(); 452 | 453 | if (wParam == 0) { 454 | RefreshWindow(hwndActive, FALSE, TRUE); 455 | } else { 456 | HWND hwndT, hwndNext; 457 | 458 | hwndT = GetWindow(hwndMDIClient, GW_CHILD); 459 | while (hwndT) { 460 | hwndNext = GetWindow(hwndT, GW_HWNDNEXT); 461 | 462 | if (!GetWindow(hwndT, GW_OWNER)) { 463 | 464 | RefreshWindow(hwndT, FALSE, TRUE); 465 | } 466 | hwndT = hwndNext; 467 | } 468 | } 469 | 470 | SPC_SET_HITDISK(qFreeSpace); 471 | UpdateStatus(hwndActive); 472 | break; 473 | 474 | case FM_GETSELCOUNT: 475 | case FM_GETSELCOUNTLFN: 476 | // wParam unused 477 | // lParam unused 478 | // return # of selected items 479 | 480 | case FM_GETFILESELA: 481 | case FM_GETFILESELW: 482 | case FM_GETFILESELLFNA: 483 | case FM_GETFILESELLFNW: 484 | 485 | // wParam index of selected item to get 486 | // lParam LPFMS_GETFILESEL structure to be filled in 487 | 488 | if (hwndActive != hwndSearch && !hwndDir) 489 | return 0L; 490 | 491 | // note, this uses the fact that LFN messages are odd! 492 | 493 | return GetExtSelection(hwndActive, (UINT)wParam, lParam, 494 | hwndActive == hwndSearch, (wMsg & ~1) == FM_GETSELCOUNT, 495 | (BOOL)(wMsg & 1), 496 | (wMsg == FM_GETFILESELW || wMsg == FM_GETFILESELLFNW)); 497 | } 498 | 499 | return 0; 500 | } 501 | -------------------------------------------------------------------------------- /src/wfext.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfext.h 4 | 5 | Windows File Manager Extensions definitions (Win32 variant) 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #ifndef _INC_WFEXT 13 | #define _INC_WFEXT /* #defined if wfext.h has been included */ 14 | 15 | #ifdef __cplusplus /* Assume C declaration for C++ */ 16 | extern "C" { 17 | #endif /* __cplusplus */ 18 | 19 | #define MENU_TEXT_LEN 40 20 | 21 | #define FMMENU_FIRST 1 22 | #define FMMENU_LAST 99 23 | 24 | #define FMEVENT_LOAD 100 25 | #define FMEVENT_UNLOAD 101 26 | #define FMEVENT_INITMENU 102 27 | #define FMEVENT_USER_REFRESH 103 28 | #define FMEVENT_SELCHANGE 104 29 | #define FMEVENT_TOOLBARLOAD 105 30 | #define FMEVENT_HELPSTRING 106 31 | #define FMEVENT_HELPMENUITEM 107 32 | 33 | #define FMFOCUS_DIR 1 34 | #define FMFOCUS_TREE 2 35 | #define FMFOCUS_DRIVES 3 36 | #define FMFOCUS_SEARCH 4 37 | 38 | #define FM_GETFOCUS (WM_USER + 0x0200) 39 | #define FM_GETSELCOUNT (WM_USER + 0x0202) 40 | #define FM_GETSELCOUNTLFN (WM_USER + 0x0203) /* LFN versions are odd */ 41 | #define FM_REFRESH_WINDOWS (WM_USER + 0x0206) 42 | #define FM_RELOAD_EXTENSIONS (WM_USER + 0x0207) 43 | 44 | #define FM_GETDRIVEINFOA (WM_USER + 0x0201) 45 | #define FM_GETFILESELA (WM_USER + 0x0204) 46 | #define FM_GETFILESELLFNA (WM_USER + 0x0205) /* LFN versions are odd */ 47 | 48 | #define FM_GETDRIVEINFOW (WM_USER + 0x0211) 49 | #define FM_GETFILESELW (WM_USER + 0x0214) 50 | #define FM_GETFILESELLFNW (WM_USER + 0x0215) /* LFN versions are odd */ 51 | 52 | #ifdef UNICODE 53 | #define FM_GETDRIVEINFO FM_GETDRIVEINFOW 54 | #define FM_GETFILESEL FM_GETFILESELW 55 | #define FM_GETFILESELLFN FM_GETFILESELLFNW 56 | #else 57 | #define FM_GETDRIVEINFO FM_GETDRIVEINFOA 58 | #define FM_GETFILESEL FM_GETFILESELA 59 | #define FM_GETFILESELLFN FM_GETFILESELLFNA 60 | #endif 61 | 62 | 63 | typedef struct _FMS_GETFILESELA { 64 | FILETIME ftTime; 65 | DWORD dwSize; 66 | BYTE bAttr; 67 | CHAR szName[260]; // always fully qualified 68 | } FMS_GETFILESELA, FAR *LPFMS_GETFILESELA; 69 | 70 | typedef struct _FMS_GETFILESELW { 71 | FILETIME ftTime ; 72 | DWORD dwSize; 73 | BYTE bAttr; 74 | WCHAR szName[260]; // always fully qualified 75 | } FMS_GETFILESELW, FAR *LPFMS_GETFILESELW; 76 | 77 | #ifdef UNICODE 78 | #define FMS_GETFILESEL FMS_GETFILESELW 79 | #define LPFMS_GETFILESEL LPFMS_GETFILESELW 80 | #else 81 | #define FMS_GETFILESEL FMS_GETFILESELA 82 | #define LPFMS_GETFILESEL LPFMS_GETFILESELA 83 | #endif 84 | 85 | 86 | typedef struct _FMS_GETDRIVEINFOA { // for drive 87 | DWORD dwTotalSpace; 88 | DWORD dwFreeSpace; 89 | CHAR szPath[260]; // current directory 90 | CHAR szVolume[14]; // volume label 91 | CHAR szShare[128]; // if this is a net drive 92 | } FMS_GETDRIVEINFOA, FAR *LPFMS_GETDRIVEINFOA; 93 | 94 | typedef struct _FMS_GETDRIVEINFOW { // for drive 95 | DWORD dwTotalSpace; 96 | DWORD dwFreeSpace; 97 | WCHAR szPath[260]; // current directory 98 | WCHAR szVolume[14]; // volume label 99 | WCHAR szShare[128]; // if this is a net drive 100 | } FMS_GETDRIVEINFOW, FAR *LPFMS_GETDRIVEINFOW; 101 | 102 | #ifdef UNICODE 103 | #define FMS_GETDRIVEINFO FMS_GETDRIVEINFOW 104 | #define LPFMS_GETDRIVEINFO LPFMS_GETDRIVEINFOW 105 | #else 106 | #define FMS_GETDRIVEINFO FMS_GETDRIVEINFOA 107 | #define LPFMS_GETDRIVEINFO LPFMS_GETDRIVEINFOA 108 | #endif 109 | 110 | 111 | typedef struct _FMS_LOADA { 112 | DWORD dwSize; // for version checks 113 | CHAR szMenuName[MENU_TEXT_LEN]; // output 114 | HMENU hMenu; // output 115 | UINT wMenuDelta; // input 116 | } FMS_LOADA, FAR *LPFMS_LOADA; 117 | 118 | typedef struct _FMS_LOADW { 119 | DWORD dwSize; // for version checks 120 | WCHAR szMenuName[MENU_TEXT_LEN]; // output 121 | HMENU hMenu; // output 122 | UINT wMenuDelta; // input 123 | } FMS_LOADW, FAR *LPFMS_LOADW; 124 | 125 | #ifdef UNICODE 126 | #define FMS_LOAD FMS_LOADW 127 | #define LPFMS_LOAD LPFMS_LOADW 128 | #else 129 | #define FMS_LOAD FMS_LOADA 130 | #define LPFMS_LOAD LPFMS_LOADA 131 | #endif 132 | 133 | 134 | // Toolbar definitions 135 | 136 | typedef struct tagEXT_BUTTON { 137 | WORD idCommand; /* menu command to trigger */ 138 | WORD idsHelp; /* help string ID */ 139 | WORD fsStyle; /* button style */ 140 | } EXT_BUTTON, FAR *LPEXT_BUTTON; 141 | 142 | typedef struct tagFMS_TOOLBARLOAD { 143 | DWORD dwSize; /* for version checks */ 144 | LPEXT_BUTTON lpButtons; /* output */ 145 | WORD cButtons; /* output, 0==>no buttons */ 146 | WORD cBitmaps; /* number of non-sep buttons */ 147 | WORD idBitmap; /* output */ 148 | HBITMAP hBitmap; /* output if idBitmap==0 */ 149 | } FMS_TOOLBARLOAD, FAR *LPFMS_TOOLBARLOAD; 150 | 151 | typedef struct tagFMS_HELPSTRINGA { 152 | INT idCommand; /* input, -1==>the menu was selected */ 153 | HMENU hMenu; /* input, the extensions menu */ 154 | CHAR szHelp[128]; /* output, the help string */ 155 | } FMS_HELPSTRINGA, FAR *LPFMS_HELPSTRINGA; 156 | 157 | typedef struct tagFMS_HELPSTRINGW { 158 | INT idCommand; /* input, -1==>the menu was selected */ 159 | HMENU hMenu; /* input, the extensions menu */ 160 | WCHAR szHelp[128]; /* output, the help string */ 161 | } FMS_HELPSTRINGW, FAR *LPFMS_HELPSTRINGW; 162 | 163 | #ifdef UNICODE 164 | #define FMS_HELPSTRING FMS_HELPSTRINGW 165 | #define LPFMS_HELPSTRING LPFMS_HELPSTRINGW 166 | #else 167 | #define FMS_HELPSTRING FMS_HELPSTRINGA 168 | #define LPFMS_HELPSTRING LPFMS_HELPSTRINGA 169 | #endif 170 | 171 | 172 | typedef DWORD (APIENTRY *FM_EXT_PROC)(HWND, WORD, LONG); 173 | typedef DWORD (APIENTRY *FM_UNDELETE_PROC)(HWND, LPTSTR); 174 | 175 | #ifdef UNICODE 176 | LONG WINAPI FMExtensionProcW(HWND hwnd, WPARAM wEvent, LPARAM lParam); 177 | #else 178 | LONG WINAPI FMExtensionProc(HWND hwnd, WPARAM wEvent, LPARAM lParam); 179 | #endif 180 | 181 | #ifdef __cplusplus 182 | } /* End of extern "C" { */ 183 | #endif /* __cplusplus */ 184 | 185 | #endif /* _INC_WFEXT */ 186 | -------------------------------------------------------------------------------- /src/wfexti.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfexti.h 4 | 5 | Windows File Manager Extensions definitions 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #ifndef _INC_WFEXTI 13 | #define _INC_WFEXTI 14 | 15 | //------------------ private stuff --------------------------- /* ;Internal */ 16 | /* ;Internal */ 17 | typedef struct _EXTENSION { /* ;Internal */ 18 | DWORD (APIENTRY *ExtProc)(HWND, WORD, LONG); /* ;Internal */ 19 | WORD Delta; /* ;Internal */ 20 | HANDLE hModule; /* ;Internal */ 21 | HMENU hMenu; /* ;Internal */ 22 | DWORD dwFlags; /* ;Internal */ 23 | HBITMAP hbmButtons; /* ;Internal */ 24 | WORD idBitmap; /* ;Internal */ 25 | BOOL bUnicode; /* ;Internal */ 26 | } EXTENSION; /* ;Internal */ 27 | 28 | // !! WARNING !! 29 | // MAX_EXTENSIONS is assummed 5 in winfile 30 | // Must be changed there LATER 31 | 32 | #define MAX_EXTENSIONS 10 /* ;Internal */ 33 | extern EXTENSION extensions[MAX_EXTENSIONS]; /* ;Internal */ 34 | /* ;Internal */ 35 | LRESULT ExtensionMsgProc(UINT wMsg, WPARAM wParam, LPARAM lpSel); /* ;Internal */ 36 | VOID FreeExtensions(VOID); /* ;Internal */ 37 | 38 | #endif /* _INC_WFEXTI */ 39 | -------------------------------------------------------------------------------- /src/wfgwl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfgwl.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | typedef struct { 11 | HWND hwnd; 12 | HWND hwndLastFocus; 13 | WORD wDriveNum; 14 | WORD wView; 15 | BOOL fFSCFlag; 16 | WORD wSort; 17 | DWORD dwAttribs; 18 | INT iSplit; 19 | LPTREECTLDATA lptcd; 20 | LPDIRDDATA lpdird; 21 | LPDRIVESDATA lpdrvd; 22 | } TREEDATA, FAR *LPTREEDATA; 23 | 24 | typedef struct { 25 | HWND hwnd; 26 | INT iReadLevel; 27 | HWND hwndLB; 28 | LPTREEDATA lptreed; 29 | } TREECTLDATA, FAR *LPTREECTLDATA; 30 | 31 | typedef struct { 32 | HWND hwnd; 33 | INT iFirstTab; 34 | HANDLE hDTA; 35 | HWND hwndLB; 36 | LPTREEDATA lptreed; 37 | } DIRDATA, FAR *LPDIRDATA; 38 | 39 | typedef struct { 40 | HWND hwnd; 41 | LPTSTR lpstrVolume; 42 | INT iCurDriveInd; 43 | INT iCurDriveFocus; 44 | LPTREEDATA lptreed; 45 | } DRIVESDATA, FAR *LPDRIVESDATA; 46 | 47 | typedef struct { 48 | HWND hwnd; 49 | WORD wDriveNum; 50 | WORD wView; 51 | BOOL fFSCFlag; 52 | WORD wSort; 53 | DWORD dwAttribs; 54 | HANDLE hDTASearch; 55 | HWND hwndLB; 56 | LPTREEDATA lptreed; 57 | } SEARCHDATA, FAR *LPSEARCHDATA; 58 | -------------------------------------------------------------------------------- /src/wfhelp.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfhelp.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | // 11 | // 12 | // Help Context String map: 13 | // 14 | // begin: 5000 IDM_* 15 | // .. 16 | // 5000 + 2000 IDH_SYSMENU 17 | // 5000 + 2001 MB_* (message boxes) 18 | // 5000 + 2099 IDH_SYSMENUCHILD 19 | // 5000 + 3000 DLGs 20 | // 21 | 22 | #define IDH_HELPFIRST 5000 23 | #define IDH_SYSMENU (IDH_HELPFIRST + 2000) 24 | 25 | #define IDH_MBFIRST (IDH_HELPFIRST + 2001) 26 | #define IDH_MB_FORMATCURERR (IDH_MBFIRST + 0) 27 | #define IDH_ASSOC_BROWSE (IDH_MBFIRST + 1) 28 | #define IDH_FONT (IDH_MBFIRST + 3) 29 | #define IDH_MBLAST (IDH_HELPFIRST + 2098) 30 | 31 | #define IDH_SYSMENUCHILD (IDH_HELPFIRST + 2099) 32 | 33 | 34 | #define IDH_DLGFIRST (IDH_HELPFIRST + 3000) 35 | 36 | #define IDH_DLG_PREV (IDH_DLGFIRST + PREVIOUSDLG) 37 | #define IDH_DLG_CONFIRMREPLACE (IDH_DLGFIRST + CONFIRMREPLACE) 38 | #define IDH_DLG_CONFIRMRMDIR (IDH_DLGFIRST + CONFIRMRMDIR) 39 | #define IDH_DLG_CONFIRMRENAME (IDH_DLGFIRST + CONFIRMRENAME) 40 | #define IDH_DLG_CONFIRMMOVE (IDH_DLGFIRST + CONFIRMMOVE) 41 | #define IDH_DLG_CONFIRMDEL (IDH_DLGFIRST + CONFIRMDELETE) 42 | #define IDH_DLG_LFNTOFATDLG (IDH_DLGFIRST + LFNTOFATDLG) 43 | #define IDH_DLG_ASSOCIATEFILEDLG (IDH_DLGFIRST + ASSOCIATEFILEDLG) 44 | #define IDH_DLG_ASSOCIATEFILEDLGCONFIG (IDH_DLGFIRST + ASSOCIATEFILEDLGCONFIG) 45 | #define IDH_FILE (IDM_FILE + IDH_HELPFIRST) 46 | #define IDH_OPEN (IDM_OPEN + IDH_HELPFIRST) 47 | #define IDH_PRINT (IDM_PRINT + IDH_HELPFIRST) 48 | #define IDH_ASSOCIATE (IDM_ASSOCIATE + IDH_HELPFIRST) 49 | #define IDH_SEARCH (IDM_SEARCH + IDH_HELPFIRST) 50 | #define IDH_RUN (IDM_RUN + IDH_HELPFIRST) 51 | #define IDH_MOVE (IDM_MOVE + IDH_HELPFIRST) 52 | #define IDH_COPY (IDM_COPY + IDH_HELPFIRST) 53 | #define IDH_DELETE (IDM_DELETE + IDH_HELPFIRST) 54 | #define IDH_RENAME (IDM_RENAME + IDH_HELPFIRST) 55 | #define IDH_ATTRIBS (IDM_ATTRIBS + IDH_HELPFIRST) 56 | #define IDH_MAKEDIR (IDM_MAKEDIR + IDH_HELPFIRST) 57 | #define IDH_SELALL (IDM_SELALL + IDH_HELPFIRST) 58 | #define IDH_DESELALL (IDM_DESELALL + IDH_HELPFIRST) 59 | #define IDH_UNDO (IDM_UNDO + IDH_HELPFIRST) 60 | #define IDH_EXIT (IDM_EXIT + IDH_HELPFIRST) 61 | #define IDH_SELECT (IDM_SELECT + IDH_HELPFIRST) 62 | #define IDH_UNDELETE (IDM_UNDELETE + IDH_HELPFIRST) 63 | #define IDH_COPYTOCLIPBOARD (IDM_COPYTOCLIPBOARD + IDH_HELPFIRST) 64 | #define IDH_COMPRESS (IDM_COMPRESS + IDH_HELPFIRST) 65 | #define IDH_UNCOMPRESS (IDM_UNCOMPRESS + IDH_HELPFIRST) 66 | #define IDH_GROUP_ATTRIBS (IDM_GROUP_ATTRIBS + IDH_HELPFIRST) 67 | #define IDH_DISK (IDM_DISK + IDH_HELPFIRST) 68 | #define IDH_DISKCOPY (IDM_DISKCOPY + IDH_HELPFIRST) 69 | #define IDH_LABEL (IDM_LABEL + IDH_HELPFIRST) 70 | #define IDH_FORMAT (IDM_FORMAT + IDH_HELPFIRST) 71 | #define IDH_SYSDISK (IDM_SYSDISK + IDH_HELPFIRST) 72 | #define IDH_CONNECT (IDM_CONNECT + IDH_HELPFIRST) 73 | #define IDH_DISCONNECT (IDM_DISCONNECT + IDH_HELPFIRST) 74 | #define IDH_CONNECTIONS (IDM_CONNECTIONS + IDH_HELPFIRST) 75 | #define IDH_DRIVESMORE (IDM_DRIVESMORE + IDH_HELPFIRST) 76 | 77 | #define IDH_SHAREAS (IDM_SHAREAS + IDH_HELPFIRST) 78 | #define IDH_STOPSHARE (IDM_STOPSHARE + IDH_HELPFIRST) 79 | 80 | #define IDH_TREE (IDM_TREE + IDH_HELPFIRST) 81 | #define IDH_EXPONE (IDM_EXPONE + IDH_HELPFIRST) 82 | #define IDH_EXPSUB (IDM_EXPSUB + IDH_HELPFIRST) 83 | #define IDH_EXPALL (IDM_EXPALL + IDH_HELPFIRST) 84 | #define IDH_COLLAPSE (IDM_COLLAPSE + IDH_HELPFIRST) 85 | #define IDH_ADDPLUSES (IDM_ADDPLUSES + IDH_HELPFIRST) 86 | 87 | #define IDH_VIEW (IDM_VIEW + IDH_HELPFIRST) 88 | #define IDH_VNAME (IDM_VNAME + IDH_HELPFIRST) 89 | #define IDH_VDETAILS (IDM_VDETAILS + IDH_HELPFIRST) 90 | #define IDH_VOTHER (IDM_VOTHER + IDH_HELPFIRST) 91 | #define IDH_BYNAME (IDM_BYNAME + IDH_HELPFIRST) 92 | #define IDH_BYTYPE (IDM_BYTYPE + IDH_HELPFIRST) 93 | #define IDH_BYSIZE (IDM_BYSIZE + IDH_HELPFIRST) 94 | #define IDH_BYDATE (IDM_BYDATE + IDH_HELPFIRST) 95 | #define IDH_VINCLUDE (IDM_VINCLUDE + IDH_HELPFIRST) 96 | #define IDH_REPLACE (IDM_REPLACE + IDH_HELPFIRST) 97 | #define IDH_TREEONLY (IDM_TREEONLY + IDH_HELPFIRST) 98 | #define IDH_DIRONLY (IDM_DIRONLY + IDH_HELPFIRST) 99 | #define IDH_BOTH (IDM_BOTH + IDH_HELPFIRST) 100 | #define IDH_SPLIT (IDM_SPLIT + IDH_HELPFIRST) 101 | 102 | #define IDH_OPTIONS (IDM_OPTIONS + IDH_HELPFIRST) 103 | #define IDH_CONFIRM (IDM_CONFIRM + IDH_HELPFIRST) 104 | #define IDH_FONT_MENU (IDM_FONT + IDH_HELPFIRST) 105 | #define IDH_CTBAR (IDM_TOOLBARCUST + IDH_HELPFIRST) 106 | #define IDH_TOOLBAR (IDM_TOOLBAR + IDH_HELPFIRST) 107 | #define IDH_DRIVEBAR (IDM_DRIVEBAR + IDH_HELPFIRST) 108 | #define IDH_STATUSBAR (IDM_STATUSBAR + IDH_HELPFIRST) 109 | #define IDH_MINONRUN (IDM_MINONRUN + IDH_HELPFIRST) 110 | #define IDH_SAVESETTINGS (IDM_SAVESETTINGS + IDH_HELPFIRST) 111 | 112 | #define IDH_EXTENSIONS (IDM_EXTENSIONS + IDH_HELPFIRST) 113 | 114 | #define IDH_WINDOW (IDM_WINDOW + IDH_HELPFIRST) 115 | #define IDH_CASCADE (IDM_CASCADE + IDH_HELPFIRST) 116 | #define IDH_TILEH (IDM_TILEHORIZONTALLY + IDH_HELPFIRST) 117 | #define IDH_TILEV (IDM_TILE + IDH_HELPFIRST) 118 | #define IDH_REFRESH (IDM_REFRESH + IDH_HELPFIRST) 119 | #define IDH_CLOSEALL (IDM_CLOSEALL + IDH_HELPFIRST) 120 | #define IDH_CHILDSTART (IDM_CHILDSTART + IDH_HELPFIRST) 121 | #define IDH_SAVE (IDM_SAVE + IDH_HELPFIRST) 122 | #define IDH_ARRANGE (IDM_ARRANGE + IDH_HELPFIRST) 123 | #define IDH_NEWWINDOW (IDM_NEWWINDOW + IDH_HELPFIRST) 124 | #define IDH_ONWOCON (IDM_NEWWINONCONNECT + IDH_HELPFIRST) 125 | 126 | #define IDH_HELPGENERAL (IDM_HELP + IDH_HELPFIRST) 127 | #define IDH_HELPINDEX (IDM_HELPINDEX + IDH_HELPFIRST) 128 | #define IDH_HELPKEYS (IDM_HELPKEYS + IDH_HELPFIRST) 129 | #define IDH_HELPCOMMANDS (IDM_HELPCOMMANDS + IDH_HELPFIRST) 130 | #define IDH_HELPPROCS (IDM_HELPPROCS + IDH_HELPFIRST) 131 | #define IDH_HELPHELP (IDM_HELPHELP + IDH_HELPFIRST) 132 | #define IDH_ABOUT (IDM_ABOUT + IDH_HELPFIRST) 133 | 134 | #define IDH_LOWERCASE (IDM_LOWERCASE + IDH_HELPFIRST) 135 | #define IDH_EXPANDTREE (IDM_EXPANDTREE + IDH_HELPFIRST) 136 | -------------------------------------------------------------------------------- /src/wfinfo.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfinfo.h 4 | 5 | DriveInformation handler header: 6 | Handles caching and refreshing of drive information. 7 | 8 | Copyright (c) Microsoft Corporation. All rights reserved. 9 | Licensed under the MIT License. 10 | 11 | ********************************************************************/ 12 | 13 | #ifndef _WFINFO_H 14 | #define _WFINFO_H 15 | 16 | #ifdef _GLOBALS 17 | #define Extern 18 | #define EQ(x) = x 19 | #else 20 | #define Extern extern 21 | #define EQ(x) 22 | #endif 23 | 24 | // 25 | // Set up altname stuff 26 | // 27 | 28 | #define MAX_ALTNAME 2 29 | 30 | #define ALTNAME_MULTI 0 31 | #define ALTNAME_SHORT 1 32 | #define ALTNAME_REG MAX_ALTNAME // Request regular name 33 | 34 | 35 | // 36 | // Get RetVal 37 | // 38 | 39 | #define GETRETVAL(type, drive) \ 40 | (aDriveInfo[drive].s##type.dwRetVal) 41 | 42 | 43 | typedef struct _INFO_STATUS { 44 | BOOL bValid : 1; 45 | BOOL bRefresh : 1; 46 | DWORD dwRetVal; 47 | } INFOSTATUS, *PINFOSTATUS; 48 | 49 | #define STATUSNAME(name) INFOSTATUS s##name 50 | 51 | 52 | #define R_REFRESH(type, drive) \ 53 | aDriveInfo[drive].s##type.bRefresh = TRUE 54 | 55 | #define I_INVALIDATE(type, drive) \ 56 | aDriveInfo[drive].s##type.bValid = FALSE 57 | 58 | #define C_CLOSE(type, drive, retval) \ 59 | { \ 60 | aDriveInfo[drive].s##type.bValid = TRUE; \ 61 | aDriveInfo[drive].s##type.bRefresh = FALSE; \ 62 | aDriveInfo[drive].s##type.dwRetVal = retval;\ 63 | } 64 | 65 | #define R_Type(drive) R_REFRESH(Type, drive) 66 | #define R_Space(drive) R_REFRESH(Space, drive) 67 | #define R_NetCon(drive) R_REFRESH(NetCon, drive) 68 | #define R_VolInfo(drive) R_REFRESH(VolInfo, drive) 69 | 70 | 71 | #define I_Type(drive) I_INVALIDATE(Type, drive) 72 | #define I_Space(drive) I_INVALIDATE(Space, drive) 73 | #define I_NetCon(drive) I_INVALIDATE(NetCon, drive) 74 | #define I_VolInfo(drive) I_INVALIDATE(VolInfo, drive) 75 | 76 | 77 | #define C_Type(drive,retval) C_CLOSE(Type, drive, retval) 78 | #define C_Space(drive,retval) C_CLOSE(Space, drive, retval) 79 | #define C_NetCon(drive,retval) C_CLOSE(NetCon, drive, retval) 80 | #define C_VolInfo(drive,retval) C_CLOSE(VolInfo, drive, retval) 81 | 82 | 83 | 84 | #define U_PROTO(type) VOID U_##type(DRIVE drive) 85 | 86 | U_PROTO(Type); 87 | U_PROTO(Space); 88 | U_PROTO(NetCon); 89 | U_PROTO(VolInfo); 90 | 91 | 92 | // 93 | // Define variables 94 | // 95 | #define V_Variable(type) Extern CRITICAL_SECTION CriticalSectionInfo##type 96 | 97 | V_Variable(Type); 98 | V_Variable(Space); 99 | V_Variable(NetCon); 100 | V_Variable(VolInfo); 101 | 102 | 103 | 104 | // 105 | // Define constructors 106 | // 107 | 108 | #define M_PROTO(type) VOID M_##type(DRIVE drive) 109 | #define M_Make(type) InitializeCriticalSection(&CriticalSectionInfo##type) 110 | 111 | // Default Constructors or prototypes 112 | 113 | VOID M_Info(VOID); 114 | 115 | #define M_Type() M_Make(Type) 116 | #define M_Space() M_Make(Space) 117 | #define M_NetCon() M_Make(NetCon) 118 | #define M_VolInfo() M_Make(VolInfo) 119 | 120 | 121 | // 122 | // Define destructors 123 | // 124 | 125 | #define D_PROTO(type) VOID D_##type(VOID) 126 | #define D_Destroy(type) DeleteCriticalSection(&CriticalSectionInfo##type) 127 | 128 | // Default Destructors or prototypes 129 | 130 | VOID D_Info(VOID); 131 | 132 | #define D_Type() D_Destroy(Type) 133 | #define D_Space() D_Destroy(Space) 134 | D_PROTO(NetCon); 135 | #define D_VolInfo() D_Destroy(VolInfo) 136 | 137 | 138 | // 139 | // Misc prototypes 140 | // 141 | 142 | INT NetCon_UpdateAltName(DRIVE drive, DWORD dwRetVal); 143 | 144 | 145 | // 146 | // Background update support 147 | // 148 | 149 | BOOL NetLoad(VOID); 150 | 151 | DWORD WINAPI UpdateInit(PVOID ThreadParameter); 152 | DWORD WFGetConnection(DRIVE,LPTSTR*,BOOL,DWORD); 153 | DWORD GetVolShare(DRIVE drive, LPTSTR* ppszVolShare, DWORD dwType); 154 | VOID UpdateDriveListComplete(VOID); 155 | VOID UpdateDriveList(VOID); 156 | VOID ResetDriveInfo(VOID); 157 | 158 | BOOL LoadComdlg(VOID); 159 | VOID UpdateWaitQuit(VOID); 160 | VOID WaitLoadEvent(BOOL bNet); 161 | 162 | 163 | Extern BOOL bUpdateRun; 164 | Extern HANDLE hThreadUpdate; 165 | Extern HANDLE hEventUpdate; 166 | Extern HANDLE hEventUpdatePartial; 167 | 168 | 169 | // 170 | // Doc prototypes; typdefs 171 | // 172 | 173 | typedef struct _DOC_BUCKET** PPDOCBUCKET; 174 | typedef struct _DOC_BUCKET* PDOCBUCKET; 175 | 176 | PPDOCBUCKET DocConstruct(VOID); 177 | VOID DocDestruct(PPDOCBUCKET ppDocBucket); 178 | INT DocInsert(PPDOCBUCKET ppDocBucket, LPTSTR lpszExt, DWORD dwParam); 179 | PDOCBUCKET DocFind(PPDOCBUCKET ppDocBucket, LPTSTR lpszExt); 180 | DWORD DocGetParm(PDOCBUCKET pDocBucket); 181 | VOID DocSetParm(PDOCBUCKET pDocBucket, DWORD dwParm); 182 | 183 | #ifdef DOCENUM 184 | typedef struct _DOC_ENUM DOCENUM, *PDOCENUM; 185 | 186 | PDOCENUM DocOpenEnum(PPDOCBUCKET ppDocBucket); 187 | LPTSTR DocEnum(PDOCENUM pDocEnum, PDWORD pdwParm); 188 | VOID DocCloseEnum(PDOCENUM pDocEnum); 189 | #endif 190 | 191 | #endif // ndef _WFINFO_H 192 | -------------------------------------------------------------------------------- /src/wfmem.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfmem.c 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #define BLOCK_SIZE_GRANULARITY 1024 // must be larger than XDTA 11 | #define ALIGNBLOCK(x) (((x)+7)&~7) // quad word align for Alpha 12 | 13 | #ifdef HEAPCHECK 14 | #include "heap.h" 15 | #endif 16 | 17 | #include 18 | #include "wfmem.h" 19 | 20 | LPXDTALINK 21 | MemNew() 22 | { 23 | LPXDTALINK lpStart; 24 | LPXDTAHEAD lpHead; 25 | 26 | lpStart = (LPXDTALINK) LocalAlloc(LMEM_FIXED, BLOCK_SIZE_GRANULARITY); 27 | 28 | if (!lpStart) 29 | return NULL; 30 | 31 | // 32 | // Initialize the link structure 33 | // 34 | lpStart->next = NULL; 35 | #ifdef MEMDOUBLE 36 | lpStart->dwSize = BLOCK_SIZE_GRANULARITY; 37 | #endif 38 | lpStart->dwNextFree = LINKHEADSIZE; 39 | 40 | // 41 | // Create the XDTAHEAD block and initialize 42 | // 43 | lpHead = MemLinkToHead(lpStart); 44 | 45 | // 46 | // Initialize winfile specific data 47 | // 48 | lpHead->dwEntries = 0; 49 | lpHead->dwTotalCount = 0; 50 | lpHead->qTotalSize.HighPart = 0; 51 | lpHead->qTotalSize.LowPart = 0; 52 | lpHead->alpxdtaSorted = NULL; 53 | lpHead->fdwStatus = 0; 54 | 55 | // 56 | // lpHead->dwAlternateFileNameExtent = 0; 57 | // lpHead->iError = 0; 58 | // 59 | #ifdef TESTING 60 | // TESTING 61 | {TCHAR szT[100]; wsprintf(szT, 62 | L"MemNew %x\n", lpStart); OutputDebugString(szT);} 63 | #endif 64 | 65 | return lpStart; 66 | } 67 | 68 | 69 | VOID 70 | MemDelete( 71 | LPXDTALINK lpStart) 72 | { 73 | LPXDTALINK lpLink; 74 | LPXDTAHEAD lpHead; 75 | LPXDTA* plpxdta; 76 | 77 | #ifdef TESTING 78 | // TESTING 79 | {TCHAR szT[100]; wsprintf(szT, 80 | L"MemDelete %x\n", lpStart); OutputDebugString(szT);} 81 | #endif 82 | 83 | if (!lpStart) 84 | return; 85 | 86 | lpHead = MemLinkToHead(lpStart); 87 | plpxdta = lpHead->alpxdtaSorted; 88 | 89 | if (plpxdta) 90 | LocalFree(plpxdta); 91 | 92 | while (lpStart) { 93 | 94 | lpLink = lpStart->next; 95 | LocalFree(lpStart); 96 | 97 | lpStart = lpLink; 98 | } 99 | 100 | return; 101 | } 102 | 103 | 104 | 105 | ///////////////////////////////////////////////////////////////////// 106 | // 107 | // Name: MemAdd 108 | // 109 | // Synopsis: Allocates space (if nec) to the memory structure 110 | // 111 | // lpLast _must_ be the last link of the mem struct 112 | // cchFileName char count of name (not including NULL) 113 | // cchAlternateFileName char count of altname (not including NULL) 114 | // 115 | // Return: 116 | // 117 | // 118 | // Assumes: 119 | // 120 | // lpLast is really the last item block 121 | // 122 | // Effects: 123 | // 124 | // Sets up internal pointers 125 | // 126 | // Notes: 127 | // 128 | // Invariants: 129 | // 130 | // lpLast*->dwNextFree maintained 131 | // lpLast*->next linked list maintained 132 | // 133 | ///////////////////////////////////////////////////////////////////// 134 | 135 | LPXDTA 136 | MemAdd( 137 | LPXDTALINK* plpLast, 138 | UINT cchFileName, 139 | UINT cchAlternateFileName) 140 | { 141 | LPXDTA lpxdta; 142 | UINT cbSpace; 143 | LPXDTALINK lpLast = *plpLast; 144 | #ifdef MEMDOUBLE 145 | DWORD dwNewSize; 146 | #endif 147 | 148 | cbSpace = ALIGNBLOCK((cchFileName+ 149 | cchAlternateFileName+2)*sizeof(WCHAR)+ 150 | sizeof(XDTA)); 151 | 152 | #ifdef MEMDOUBLE 153 | if (cbSpace + lpLast->dwNextFree > lpLast->dwSize) { 154 | 155 | // 156 | // Must allocate a new block 157 | // 158 | dwNewSize = lpLast->dwSize*2; 159 | 160 | if (dwNewSize < lpLast->dwSize) 161 | dwNewSize = lpLast->dwSize; 162 | 163 | lpLast->next = LocalAlloc(LMEM_FIXED, dwNewSize); 164 | 165 | if (!lpLast->next) 166 | return NULL; 167 | 168 | lpLast = *plpLast = lpLast->next; 169 | 170 | lpLast->dwSize = dwNewSize; 171 | #else 172 | if (cbSpace + lpLast->dwNextFree > BLOCK_SIZE_GRANULARITY) { 173 | 174 | // 175 | // Must allocate a new block 176 | // 177 | lpLast->next = LocalAlloc(LMEM_FIXED, BLOCK_SIZE_GRANULARITY); 178 | 179 | if (!lpLast->next) 180 | return NULL; 181 | 182 | lpLast = *plpLast = lpLast->next; 183 | #endif 184 | 185 | lpLast->next = NULL; 186 | lpLast->dwNextFree = ALIGNBLOCK(sizeof(XDTALINK)); 187 | } 188 | 189 | // 190 | // We have enough space in this link now 191 | // Update everything 192 | // 193 | 194 | lpxdta = (LPXDTA)((PBYTE)lpLast+lpLast->dwNextFree); 195 | 196 | lpLast->dwNextFree += cbSpace; 197 | lpxdta->dwSize = cbSpace; 198 | lpxdta->cchFileNameOffset = cchFileName+1; 199 | 200 | return lpxdta; 201 | } 202 | 203 | 204 | 205 | 206 | 207 | ///////////////////////////////////////////////////////////////////// 208 | // 209 | // Name: MemClone 210 | // 211 | // Synopsis: returns a copy of the specified block 212 | // 213 | // 214 | // Return: Full Copy or NULL 215 | // 216 | // Assumes: lpStart stable and safe 217 | // 218 | // Effects: 219 | // 220 | // Notes: 221 | // 222 | ///////////////////////////////////////////////////////////////////// 223 | 224 | LPXDTALINK 225 | MemClone(LPXDTALINK lpStart) 226 | { 227 | LPXDTALINK lpStartCopy; 228 | LPXDTALINK lpPrev; 229 | LPXDTALINK lpLink; 230 | LPXDTALINK lpNext; 231 | DWORD dwSize; 232 | 233 | #ifdef TESTING 234 | // TESTING 235 | {TCHAR szT[100]; wsprintf(szT, 236 | L"MemClone %x ", lpStart); OutputDebugString(szT);} 237 | #endif 238 | 239 | for (lpPrev = NULL, lpStartCopy = NULL; lpStart; lpStart = lpNext) 240 | { 241 | lpNext = lpStart->next; 242 | 243 | dwSize = LocalSize((HLOCAL)lpStart); 244 | 245 | lpLink = LocalAlloc(LMEM_FIXED, dwSize); 246 | if (!lpLink) 247 | { 248 | MemDelete(lpStartCopy); 249 | return NULL; 250 | } 251 | 252 | CopyMemory((PBYTE)lpLink, (PBYTE)lpStart, dwSize); 253 | 254 | if (!lpStartCopy) 255 | { 256 | lpStartCopy = lpLink; 257 | 258 | // 259 | // MUST set lpxdtaDst->head.alpxdtaSorted to NULL, 260 | // otherwise it will attempt to use the original one's space 261 | // 262 | MemLinkToHead(lpStartCopy)->alpxdtaSorted = NULL; 263 | } 264 | 265 | // 266 | // Setup link (must null out last one since we can free it at 267 | // any time if memory alloc fails). 268 | // 269 | lpLink->next = NULL; 270 | 271 | if (lpPrev) 272 | { 273 | lpPrev->next = lpLink; 274 | } 275 | lpPrev = lpLink; 276 | } 277 | 278 | #ifdef TESTING 279 | // TESTING 280 | {TCHAR szT[100]; wsprintf(szT, 281 | L"rets %x\n", lpStartCopy); OutputDebugString(szT);} 282 | #endif 283 | 284 | return lpStartCopy; 285 | } 286 | 287 | LPXDTA 288 | MemNext(register LPXDTALINK* plpLink, register LPXDTA lpxdta) 289 | { 290 | register LPXDTALINK lpLinkCur = *plpLink; 291 | 292 | if ((PBYTE)lpxdta + lpxdta->dwSize - (PBYTE)lpLinkCur == (INT)lpLinkCur->dwNextFree) 293 | { 294 | *plpLink = lpLinkCur->next; 295 | return (LPXDTA)(((PBYTE)*plpLink)+sizeof(XDTALINK)); 296 | } 297 | else 298 | { 299 | return (LPXDTA)((PBYTE)lpxdta + lpxdta->dwSize); 300 | } 301 | } 302 | -------------------------------------------------------------------------------- /src/wfmem.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfmem.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #ifndef _WFMEM_H 11 | #define _WFMEM_H 12 | 13 | typedef struct _XDTAHEAD* LPXDTAHEAD; 14 | typedef struct _XDTA* LPXDTA; 15 | typedef struct _XDTALINK* LPXDTALINK; 16 | 17 | typedef struct _XDTALINK { 18 | LPXDTALINK next; 19 | #ifdef MEMDOUBLE 20 | DWORD dwSize; 21 | #endif 22 | DWORD dwNextFree; 23 | #ifdef MEMDOUBLE 24 | DWORD dwPad; /* quad word align for Alpha */ 25 | #endif 26 | } XDTALINK; 27 | 28 | #define LPXDTA_STATUS_READING 0x1 // Reading by ReadDirLevel 29 | #define LPXDTA_STATUS_CLOSE 0x2 // ReadDirLevel must free 30 | 31 | 32 | typedef struct _XDTAHEAD { 33 | 34 | DWORD dwEntries; 35 | DWORD dwTotalCount; 36 | LARGE_INTEGER qTotalSize; 37 | LPXDTA* alpxdtaSorted; 38 | 39 | DWORD dwAlternateFileNameExtent; 40 | DWORD fdwStatus; 41 | 42 | #ifdef PROGMAN 43 | INT iPrograms; 44 | #else 45 | DWORD dwPad; /* quad word align for Alpha */ 46 | #endif 47 | 48 | } XDTAHEAD; 49 | 50 | typedef struct _XDTA { 51 | 52 | DWORD dwSize; 53 | DWORD dwAttrs; 54 | FILETIME ftLastWriteTime; 55 | LARGE_INTEGER qFileSize; 56 | UINT cchFileNameOffset; 57 | 58 | #ifdef PROGMAN 59 | INT iIcon; 60 | BYTE byHolder; 61 | #endif 62 | 63 | BYTE byBitmap; 64 | BYTE byType; 65 | 66 | WCHAR cFileNames[1]; 67 | } XDTA; 68 | 69 | #define LINKHEADSIZE (sizeof(XDTALINK) + sizeof(XDTAHEAD)) 70 | 71 | LPXDTALINK MemNew(); 72 | VOID MemDelete(LPXDTALINK lpStart); 73 | 74 | LPXDTALINK MemClone(LPXDTALINK lpStart); 75 | LPXDTA MemAdd(LPXDTALINK* plpLast, UINT cchFileName, UINT cchAlternateFileName); 76 | LPXDTA MemNext(LPXDTALINK* plpLink, LPXDTA lpxdta); 77 | 78 | #define MemFirst(lpStart) ((LPXDTA)(((PBYTE)lpStart) + LINKHEADSIZE)) 79 | #define MemGetAlternateFileName(lpxdta) (&lpxdta->cFileNames[lpxdta->cchFileNameOffset]) 80 | #define MemGetFileName(lpxdta) (lpxdta->cFileNames) 81 | #define MemLinkToHead(link) ((LPXDTAHEAD)((PBYTE)link+sizeof(XDTALINK))) 82 | 83 | #define pdtaNext(pdta) ((LPXDTA)((PBYTE)(pdta) + ((LPXDTA)pdta)->dwSize)) 84 | 85 | 86 | #endif // ndef _WFMEM_H 87 | -------------------------------------------------------------------------------- /src/wfprint.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wfprint.c 4 | 5 | Windows Print Routines 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include "winfile.h" 13 | 14 | /*--------------------------------------------------------------------------*/ 15 | /* */ 16 | /* PrintFile() - */ 17 | /* */ 18 | /*--------------------------------------------------------------------------*/ 19 | 20 | DWORD 21 | PrintFile(HWND hwnd, LPTSTR szFile) 22 | { 23 | DWORD ret; 24 | INT iCurCount; 25 | INT i; 26 | HCURSOR hCursor; 27 | WCHAR szDir[MAXPATHLEN]; 28 | 29 | ret = 0; 30 | 31 | hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); 32 | iCurCount = ShowCursor(TRUE) - 1; 33 | 34 | // 35 | // This returns Ansi chars, and that's what ShellExecute expects 36 | // 37 | GetSelectedDirectory(0, szDir); 38 | 39 | // 40 | // open the object 41 | // 42 | SetErrorMode(0); 43 | ret = (DWORD)ShellExecute(hwnd, L"print", szFile, szNULL, szDir, SW_SHOWNORMAL); 44 | SetErrorMode(1); 45 | 46 | switch (ret) { 47 | case 0: 48 | case 8: 49 | ret = IDS_PRINTMEMORY; 50 | break; 51 | 52 | case 2: 53 | ret = IDS_FILENOTFOUNDMSG; 54 | break; 55 | 56 | case 3: 57 | ret = IDS_BADPATHMSG; 58 | break; 59 | 60 | case 5: 61 | ret = IDS_NOACCESSFILE; 62 | break; 63 | 64 | case SE_ERR_SHARE: 65 | ret = IDS_SHAREERROR; 66 | break; 67 | 68 | case SE_ERR_ASSOCINCOMPLETE: 69 | ret = IDS_ASSOCINCOMPLETE; 70 | break; 71 | 72 | case SE_ERR_DDETIMEOUT: 73 | case SE_ERR_DDEFAIL: 74 | case SE_ERR_DDEBUSY: 75 | ret = IDS_DDEFAIL; 76 | break; 77 | 78 | case SE_ERR_NOASSOC: 79 | ret = IDS_NOASSOCMSG; 80 | break; 81 | 82 | default: 83 | if (ret <= 32) 84 | goto EPExit; 85 | ret = 0; 86 | } 87 | 88 | EPExit: 89 | i = ShowCursor(FALSE); 90 | 91 | // 92 | // Make sure that the cursor count is still balanced. 93 | // 94 | if (i != iCurCount) 95 | ShowCursor(TRUE); 96 | 97 | SetCursor(hCursor); 98 | 99 | return(ret); 100 | } 101 | 102 | /*--------------------------------------------------------------------------*/ 103 | /* */ 104 | /* WFPrint() - */ 105 | /* */ 106 | /*--------------------------------------------------------------------------*/ 107 | 108 | DWORD 109 | WFPrint(LPTSTR pSel) 110 | { 111 | TCHAR szFile[MAXPATHLEN]; 112 | TCHAR szTemp[MAXPATHLEN]; 113 | DWORD ret; 114 | 115 | /* Turn off the print button. */ 116 | if (hdlgProgress) 117 | EnableWindow(GetDlgItem(hdlgProgress, IDOK), FALSE); 118 | 119 | if (!(pSel = GetNextFile(pSel, szFile, COUNTOF(szFile)))) 120 | return TRUE; 121 | 122 | /* See if there is more than one file to print. Abort if so 123 | */ 124 | if (pSel = GetNextFile(pSel, szTemp, COUNTOF(szTemp))) { 125 | MyMessageBox(hwndFrame, IDS_WINFILE, IDS_PRINTONLYONE, MB_OK | MB_ICONEXCLAMATION); 126 | return(FALSE); 127 | } 128 | 129 | if (hdlgProgress) { 130 | /* Display the name of the file being printed. */ 131 | LoadString(hAppInstance, IDS_PRINTINGMSG, szTitle, COUNTOF(szTitle)); 132 | wsprintf(szMessage, szTitle, szFile); 133 | SetDlgItemText(hdlgProgress, IDD_STATUS, szMessage); 134 | } 135 | 136 | ret = PrintFile(hdlgProgress ? hdlgProgress : hwndFrame, szFile); 137 | 138 | if (ret) { 139 | MyMessageBox(hwndFrame, IDS_PRINTERRTITLE, ret, MB_OK | MB_ICONEXCLAMATION); 140 | return FALSE; 141 | } 142 | 143 | return TRUE; 144 | } 145 | -------------------------------------------------------------------------------- /src/wftrdir.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/wftrdir.ico -------------------------------------------------------------------------------- /src/wftree.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/wftree.ico -------------------------------------------------------------------------------- /src/windows.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/windows.ico -------------------------------------------------------------------------------- /src/winexp.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | winexp.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #ifndef NOATOM 11 | /* atom manager internals */ 12 | #define ATOMSTRUC struct atomstruct 13 | typedef ATOMSTRUC *PATOM; 14 | typedef ATOMSTRUC { 15 | PATOM chain; 16 | WORD usage; /* Atoms are usage counted. */ 17 | BYTE len; /* length of ASCIZ name string */ 18 | BYTE name; /* beginning of ASCIZ name string */ 19 | } ATOMENTRY; 20 | 21 | typedef struct { 22 | int numEntries; 23 | PATOM pAtom[ 1 ]; 24 | } ATOMTABLE; 25 | ATOMTABLE * PASCAL pAtomTable; 26 | #endif 27 | 28 | LPTSTR FAR PASCAL lstrbscan(LPTSTR, LPTSTR); 29 | LPTSTR FAR PASCAL lstrbskip(LPTSTR, LPTSTR); 30 | 31 | int FAR PASCAL OpenPathName(LPTSTR, int); 32 | int FAR PASCAL DeletePathName(LPTSTR); 33 | WORD FAR PASCAL _ldup(int); 34 | 35 | 36 | /* scheduler things that the world knows not */ 37 | BOOL far PASCAL WaitEvent( HANDLE ); 38 | BOOL far PASCAL PostEvent( HANDLE ); 39 | BOOL far PASCAL KillTask( HANDLE ); 40 | 41 | /* print screen hooks */ 42 | BOOL FAR PASCAL SetPrtScHook(FARPROC); 43 | FARPROC FAR PASCAL GetPrtScHook(void); 44 | 45 | /* module stuff */ 46 | HANDLE FAR PASCAL GetDSModule( WORD ); 47 | HANDLE FAR PASCAL GetDSInstance( WORD ); 48 | -------------------------------------------------------------------------------- /src/winfile.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/winfile.ico -------------------------------------------------------------------------------- /src/wnetcaps.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | WNetCaps.c 4 | 5 | Returns net status 6 | 7 | Copyright (c) Microsoft Corporation. All rights reserved. 8 | Licensed under the MIT License. 9 | 10 | ********************************************************************/ 11 | 12 | #include "winfile.h" 13 | #include "wnetcaps.h" 14 | 15 | 16 | ///////////////////////////////////////////////////////////////////// 17 | // 18 | // Name: WNetStat 19 | // 20 | // Synopsis: Caches and returns requested network status information 21 | // 22 | // IN nIndex NS_* request 23 | // NS_REFRESH refreshes cached info 24 | // 25 | // Return: BOOL on NS_* => answer 26 | // on NS_REFRESH => unstable (FALSE) 27 | // 28 | // Assumes: nIndex < 1 << 31 and nIndex an even power of 2 29 | // 30 | // Effects: 31 | // 32 | // 33 | // Notes: 34 | // 35 | ///////////////////////////////////////////////////////////////////// 36 | 37 | BOOL 38 | WNetStat(INT nIndex) 39 | { 40 | static DWORD fdwRet = (DWORD)-1; 41 | DWORD dwError; 42 | 43 | BOOL bNetwork = FALSE; 44 | BOOL bConnect = FALSE; 45 | 46 | HKEY hKey; 47 | 48 | DWORD dwcbBuffer = 0; 49 | 50 | if ( 51 | // 52 | // Disable NS_REFRESH since we test for network installed on disk, 53 | // not network services started. 54 | // 55 | #if NSREFRESH 56 | NS_REFRESH == nIndex || 57 | #endif 58 | (DWORD) -1 == fdwRet) { 59 | 60 | fdwRet = 0; 61 | 62 | // 63 | // Check for connection dialog 64 | // 65 | 66 | dwError = RegOpenKey(HKEY_LOCAL_MACHINE, 67 | TEXT("System\\CurrentControlSet\\Control\\NetworkProvider\\Order"), 68 | &hKey); 69 | 70 | if (!dwError) { 71 | 72 | dwError = RegQueryValueEx(hKey, 73 | TEXT("ProviderOrder"), 74 | NULL, 75 | NULL, 76 | NULL, 77 | &dwcbBuffer); 78 | 79 | if (ERROR_SUCCESS == dwError && dwcbBuffer > 1) { 80 | 81 | bNetwork = TRUE; 82 | } 83 | 84 | RegCloseKey(hKey); 85 | } 86 | 87 | if (bNetwork) { 88 | #if 0 89 | // 90 | // Check the registry to see if the user can make connections 91 | // 92 | dwError = RegOpenKey(HKEY_CURRENT_USER, 93 | TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\File Manager\\Settings"), 94 | &hKey); 95 | 96 | if (dwError != ERROR_SUCCESS) { 97 | bConnect = TRUE; 98 | } else { 99 | 100 | cb = sizeof(dwTemp); 101 | dwTemp = 0; 102 | 103 | dwError = RegQueryValueEx(hKey, TEXT("Network"), 104 | NULL, NULL, (LPBYTE)&dwTemp, &cb); 105 | 106 | if (dwError != ERROR_SUCCESS || dwTemp) 107 | bConnect = TRUE; 108 | 109 | RegCloseKey(hKey); 110 | } 111 | 112 | 113 | if (bConnect) { 114 | fdwRet |= NS_CONNECTDLG|NS_CONNECT; 115 | } 116 | #else 117 | fdwRet |= NS_CONNECTDLG|NS_CONNECT; 118 | #endif 119 | } 120 | 121 | // 122 | // Check for share-ability 123 | // 124 | 125 | dwError = RegOpenKey(HKEY_LOCAL_MACHINE, 126 | TEXT("System\\CurrentControlSet\\Services\\LanmanServer"), 127 | &hKey); 128 | 129 | if (!dwError) { 130 | 131 | fdwRet |= NS_SHAREDLG|NS_PROPERTYDLG; 132 | RegCloseKey(hKey); 133 | } 134 | } 135 | 136 | return fdwRet & nIndex ? TRUE : FALSE; 137 | } 138 | -------------------------------------------------------------------------------- /src/wnetcaps.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 3 | wnetcaps.h 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the MIT License. 7 | 8 | ********************************************************************/ 9 | 10 | #ifndef _WNETCAPS_H 11 | #define _WNETCAPS_H 12 | 13 | 14 | // 15 | // Prototypes 16 | // 17 | BOOL WNetStat(INT nIndex); 18 | 19 | 20 | // 21 | // There must be < 32 controls here. 22 | // 23 | #define NS_NULL 0x0 24 | #define NS_REFRESH 0x1 25 | #define NS_CONNECT 0x2 26 | #define NS_CONNECTDLG 0x4 27 | #define NS_SHAREDLG 0x8 28 | #define NS_PROPERTYDLG 0x10 29 | 30 | 31 | #endif // ndef _WNETCAPS_H 32 | -------------------------------------------------------------------------------- /src/xtratool.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/WinFile-Classic/b2587390418d514409ca0aeb9befea05196e743f/src/xtratool.bmp --------------------------------------------------------------------------------