├── .gitattributes ├── .gitignore ├── Chapter01 ├── Chapter01.sln ├── HelloWin │ ├── HelloWin.cpp │ ├── HelloWin.vcxproj │ ├── HelloWin.vcxproj.filters │ ├── pch.cpp │ └── pch.h └── ShowError │ ├── ShowError.cpp │ ├── ShowError.vcxproj │ ├── ShowError.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Chapter02 ├── BasicSharing │ ├── BasicSharing.cpp │ ├── BasicSharing.h │ ├── BasicSharing.rc │ ├── BasicSharing.vcxproj │ ├── BasicSharing.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa11136 │ ├── packages.config │ ├── res │ │ └── BasicSharing.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── Chapter02.sln ├── PrivateSharing │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── PrivateSharing.cpp │ ├── PrivateSharing.h │ ├── PrivateSharing.rc │ ├── PrivateSharing.vcxproj │ ├── PrivateSharing.vcxproj.filters │ ├── RCa11136 │ ├── packages.config │ ├── res │ │ └── PrivateSharing.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── PrivateSharing2 │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── PrivateSharing.cpp │ ├── PrivateSharing.h │ ├── PrivateSharing2.rc │ ├── PrivateSharing2.vcxproj │ ├── PrivateSharing2.vcxproj.filters │ ├── RCa11136 │ ├── packages.config │ ├── res │ │ └── PrivateSharing.ico │ ├── resource.h │ ├── stdafx.cpp │ ├── stdafx.h │ └── wilex.h └── SingleInstance │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa11136 │ ├── SingleInstance.cpp │ ├── SingleInstance.h │ ├── SingleInstance.rc │ ├── SingleInstance.vcxproj │ ├── SingleInstance.vcxproj.filters │ ├── packages.config │ ├── res │ └── singleinstance.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── Chapter03 ├── Chapter03.sln ├── InheritSharing │ ├── InheritSharing.cpp │ ├── InheritSharing.h │ ├── InheritSharing.rc │ ├── InheritSharing.vcxproj │ ├── InheritSharing.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa30368 │ ├── packages.config │ ├── res │ │ └── inheritsharing.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── MetroManager │ ├── AboutDlg.cpp │ ├── AboutDlg.h │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── MetroManager.cpp │ ├── MetroManager.h │ ├── MetroManager.rc │ ├── MetroManager.vcxproj │ ├── MetroManager.vcxproj.filters │ ├── SearchBar.cpp │ ├── SearchBar.h │ ├── View.cpp │ ├── View.h │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ ├── res │ │ ├── metromanager.ico │ │ └── toolbar.bmp │ └── resource.h ├── MiniProcExp │ ├── AboutDlg.cpp │ ├── AboutDlg.h │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── MiniProcExp.cpp │ ├── MiniProcExp.h │ ├── MiniProcExp.rc │ ├── MiniProcExp.vcxproj │ ├── MiniProcExp.vcxproj.filters │ ├── NtDll.h │ ├── ProcessManager.cpp │ ├── ProcessManager.h │ ├── View.cpp │ ├── View.h │ ├── packages.config │ ├── res │ │ ├── MiniProcExp.ico │ │ └── Toolbar.bmp │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── ProcEnum │ ├── ProcEnum.cpp │ ├── ProcEnum.vcxproj │ ├── ProcEnum.vcxproj.filters │ ├── packages.config │ ├── pch.cpp │ └── pch.h ├── ProcList │ ├── ProcList.cpp │ ├── ProcList.vcxproj │ ├── ProcList.vcxproj.filters │ ├── pch.cpp │ └── pch.h └── ProcList2 │ ├── ProcList2.cpp │ ├── ProcList2.vcxproj │ ├── ProcList2.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Chapter04 ├── Chapter04.sln ├── CpuLimit │ ├── CpuLimit.cpp │ ├── CpuLimit.vcxproj │ ├── CpuLimit.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── JobMon │ ├── JobMon.cpp │ ├── JobMon.h │ ├── JobMon.rc │ ├── JobMon.vcxproj │ ├── JobMon.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa18404 │ ├── packages.config │ ├── res │ │ └── JobMon.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h └── JobTree │ ├── JobTree.cpp │ ├── JobTree.vcxproj │ └── JobTree.vcxproj.filters ├── Chapter05 ├── Chapter05.sln └── PrimesCounter │ ├── PrimesCounter.cpp │ ├── PrimesCounter.vcxproj │ ├── PrimesCounter.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Chapter07 ├── Chapter07.sln ├── HashCalc │ ├── HashCalc.vcxproj │ ├── HashCalc.vcxproj.filters │ ├── MD5Calculator.cpp │ ├── MD5Calculator.h │ ├── packages.config │ ├── pch.cpp │ └── pch.h ├── MD5Calculator │ ├── AboutDlg.cpp │ ├── AboutDlg.h │ ├── EventParser.cpp │ ├── EventParser.h │ ├── HashCache.cpp │ ├── HashCache.h │ ├── MD5Calculator.cpp │ ├── MD5Calculator.h │ ├── MD5Calculator.rc │ ├── MD5Calculator.vcxproj │ ├── MD5Calculator.vcxproj.filters │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── TraceManager.cpp │ ├── TraceManager.h │ ├── View.cpp │ ├── View.h │ ├── packages.config │ ├── res │ │ ├── go.ico │ │ ├── md5calculator.ico │ │ ├── stop.ico │ │ └── toolbar.bmp │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── MD5Calculator2 │ ├── AboutDlg.cpp │ ├── AboutDlg.h │ ├── EventParser.cpp │ ├── EventParser.h │ ├── HashCache.cpp │ ├── HashCache.h │ ├── MD5Calculator.cpp │ ├── MD5Calculator.h │ ├── MD5Calculator.rc │ ├── MD5Calculator2.vcxproj │ ├── MD5Calculator2.vcxproj.filters │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── TraceManager.cpp │ ├── TraceManager.h │ ├── View.cpp │ ├── View.h │ ├── packages.config │ ├── res │ │ ├── go.ico │ │ ├── md5calculator.ico │ │ ├── stop.ico │ │ └── toolbar.bmp │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── MD5HashCalc │ ├── MD5HashCalc.cpp │ ├── MD5HashCalc.vcxproj │ └── MD5HashCalc.vcxproj.filters ├── QueueDemo │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── QueueDemo.cpp │ ├── QueueDemo.h │ ├── QueueDemo.rc │ ├── QueueDemo.vcxproj │ ├── QueueDemo.vcxproj.filters │ ├── RCa07176 │ ├── packages.config │ ├── res │ │ └── QueueDemo.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── SimpleIncrement │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa20380 │ ├── SimpleIncrement.cpp │ ├── SimpleIncrement.h │ ├── SimpleIncrement.rc │ ├── SimpleIncrement.vcxproj │ ├── SimpleIncrement.vcxproj.filters │ ├── packages.config │ ├── res │ │ └── simpleincrement.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h └── ThreadingHelpers │ ├── AutoCriticalSection.cpp │ ├── AutoCriticalSection.h │ ├── AutoReaderWriterLock.cpp │ ├── AutoReaderWriterLock.h │ ├── CriticalSection.cpp │ ├── CriticalSection.h │ ├── ReaderWriterLock.cpp │ ├── ReaderWriterLock.h │ ├── ThreadSafeQueue.cpp │ ├── ThreadSafeQueue.h │ ├── ThreadingHelpers.cpp │ ├── ThreadingHelpers.vcxproj │ ├── ThreadingHelpers.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Chapter08 ├── Chapter08.sln ├── MutexDemo │ ├── MutexDemo.cpp │ ├── MutexDemo.vcxproj │ ├── MutexDemo.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── QueueDemo │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── QueueDemo.cpp │ ├── QueueDemo.h │ ├── QueueDemo.rc │ ├── QueueDemo.vcxproj │ ├── QueueDemo.vcxproj.filters │ ├── RCa07176 │ ├── packages.config │ ├── res │ │ └── QueueDemo.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── SimpleTimer │ ├── SimpleTimer.cpp │ ├── SimpleTimer.vcxproj │ ├── SimpleTimer.vcxproj.filters │ ├── pch.cpp │ └── pch.h └── ThreadingHelpers │ ├── AutoCriticalSection.cpp │ ├── AutoCriticalSection.h │ ├── AutoReaderWriterLock.cpp │ ├── AutoReaderWriterLock.h │ ├── CriticalSection.cpp │ ├── CriticalSection.h │ ├── ReaderWriterLock.cpp │ ├── ReaderWriterLock.h │ ├── ThreadSafeQueue.cpp │ ├── ThreadSafeQueue.h │ ├── ThreadingHelpers.cpp │ ├── ThreadingHelpers.vcxproj │ ├── ThreadingHelpers.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Chapter09 ├── Chapter09.sln ├── HashCalc │ ├── HashCalc.vcxproj │ ├── HashCalc.vcxproj.filters │ ├── MD5Calculator.cpp │ ├── MD5Calculator.h │ ├── packages.config │ ├── pch.cpp │ └── pch.h ├── MD5Calculator2 │ ├── AboutDlg.cpp │ ├── AboutDlg.h │ ├── EventParser.cpp │ ├── EventParser.h │ ├── HashCache.cpp │ ├── HashCache.h │ ├── MD5Calculator.cpp │ ├── MD5Calculator.h │ ├── MD5Calculator.rc │ ├── MD5Calculator2.vcxproj │ ├── MD5Calculator2.vcxproj.filters │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── TraceManager.cpp │ ├── TraceManager.h │ ├── View.cpp │ ├── View.h │ ├── packages.config │ ├── res │ │ ├── go.ico │ │ ├── md5calculator.ico │ │ ├── stop.ico │ │ └── toolbar.bmp │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── SimpleTimer │ ├── SimpleTimer.cpp │ ├── SimpleTimer.vcxproj │ ├── SimpleTimer.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── SimpleWork │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa46940 │ ├── SimpleWork.cpp │ ├── SimpleWork.h │ ├── SimpleWork.rc │ ├── SimpleWork.vcxproj │ ├── SimpleWork.vcxproj.filters │ ├── packages.config │ ├── res │ │ └── simplework.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── SimpleWork2 │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa46940 │ ├── SimpleWork.cpp │ ├── SimpleWork.h │ ├── SimpleWork2.rc │ ├── SimpleWork2.vcxproj │ ├── SimpleWork2.vcxproj.filters │ ├── packages.config │ ├── res │ │ └── simplework.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── SimpleWork3 │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa46940 │ ├── SimpleWork.cpp │ ├── SimpleWork.h │ ├── SimpleWork3.rc │ ├── SimpleWork3.sln │ ├── SimpleWork3.vcxproj │ ├── SimpleWork3.vcxproj.filters │ ├── packages.config │ ├── res │ │ └── SimpleWork.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h └── ThreadingHelpers │ ├── AutoCriticalSection.cpp │ ├── AutoCriticalSection.h │ ├── AutoReaderWriterLock.cpp │ ├── AutoReaderWriterLock.h │ ├── CriticalSection.cpp │ ├── CriticalSection.h │ ├── ReaderWriterLock.cpp │ ├── ReaderWriterLock.h │ ├── ThreadSafeQueue.cpp │ ├── ThreadSafeQueue.h │ ├── ThreadingHelpers.cpp │ ├── ThreadingHelpers.vcxproj │ ├── ThreadingHelpers.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Chapter10 ├── Chapter10.sln ├── DeadlockDetector │ ├── DeadlockDetector.cpp │ ├── DeadlockDetector.h │ ├── DeadlockDetector.rc │ ├── DeadlockDetector.vcxproj │ ├── DeadlockDetector.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa34784 │ ├── packages.config │ ├── res │ │ ├── DeadlockDetector.ico │ │ └── refresh.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── FalseSharing │ ├── FalseSharing.cpp │ ├── FalseSharing.vcxproj │ ├── FalseSharing.vcxproj.filters │ ├── packages.config │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h ├── Inc │ └── Matrix.h ├── PrimesCounter │ ├── PrimesCounter.cpp │ ├── PrimesCounter.vcxproj │ ├── PrimesCounter.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── SimpleDeadlock1 │ ├── SimpleDeadlock1.cpp │ ├── SimpleDeadlock1.vcxproj │ └── SimpleDeadlock1.vcxproj.filters ├── SimpleDeadlock2 │ ├── SimpleDeadlock2.cpp │ ├── SimpleDeadlock2.vcxproj │ └── SimpleDeadlock2.vcxproj.filters ├── SumMatrix │ ├── SumMatrix.cpp │ ├── SumMatrix.vcxproj │ ├── SumMatrix.vcxproj.filters │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h ├── breakin │ ├── breakin.cpp │ ├── breakin.vcxproj │ └── breakin.vcxproj.filters └── thlist │ ├── pch.cpp │ ├── pch.h │ ├── thlist.cpp │ ├── thlist.vcxproj │ └── thlist.vcxproj.filters ├── Chapter11 ├── BulkCopy │ ├── BulkCopy.cpp │ ├── BulkCopy.h │ ├── BulkCopy.rc │ ├── BulkCopy.vcxproj │ ├── BulkCopy.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa41200 │ ├── packages.config │ ├── res │ │ ├── bulkcopy.ico │ │ ├── file.ico │ │ └── folder.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── BulkCopy2 │ ├── BulkCopy.cpp │ ├── BulkCopy.h │ ├── BulkCopy.rc │ ├── BulkCopy2.vcxproj │ ├── BulkCopy2.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa41200 │ ├── packages.config │ ├── res │ │ ├── bulkcopy.ico │ │ ├── file.ico │ │ └── folder.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── Chapter11.sln ├── DumpDrive │ ├── DumpDrive.cpp │ ├── DumpDrive.vcxproj │ └── DumpDrive.vcxproj.filters ├── EnumDevices │ ├── EnumDevices.cpp │ ├── EnumDevices.vcxproj │ └── EnumDevices.vcxproj.filters ├── SimpleRedirect │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa08444 │ ├── SimpleRedirect.cpp │ ├── SimpleRedirect.h │ ├── SimpleRedirect.rc │ ├── SimpleRedirect.vcxproj │ ├── SimpleRedirect.vcxproj.filters │ ├── packages.config │ ├── res │ │ └── SimpleRedirect.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h └── symlinks │ ├── symlinks.cpp │ ├── symlinks.vcxproj │ └── symlinks.vcxproj.filters ├── Chapter12 ├── Chapter12.sln ├── SimpleShare │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa22652 │ ├── SimpleShare.cpp │ ├── SimpleShare.h │ ├── SimpleShare.rc │ ├── SimpleShare.vcxproj │ ├── SimpleShare.vcxproj.filters │ ├── packages.config │ ├── res │ │ └── SimpleShare.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── SimpleVMMap │ ├── SimpleVMMap.cpp │ ├── SimpleVMMap.vcxproj │ └── SimpleVMMap.vcxproj.filters ├── SimpleVMMap2 │ ├── SimpleVMMap2.cpp │ ├── SimpleVMMap2.vcxproj │ └── SimpleVMMap2.vcxproj.filters └── sysinfo │ ├── sysinfo.cpp │ ├── sysinfo.vcxproj │ └── sysinfo.vcxproj.filters ├── Chapter13 ├── Chapter13.sln ├── MicroExcel │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── MicroExcel.cpp │ ├── MicroExcel.h │ ├── MicroExcel.rc │ ├── MicroExcel.vcxproj │ ├── MicroExcel.vcxproj.filters │ ├── RCa19240 │ ├── packages.config │ ├── res │ │ └── MicroExcel.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── WorkingSets │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── SortHelper.cpp │ ├── SortHelper.h │ ├── View.cpp │ ├── View.h │ ├── VirtualListView.h │ ├── WorkingSets.cpp │ ├── WorkingSets.h │ ├── WorkingSets.rc │ ├── WorkingSets.vcxproj │ ├── WorkingSets.vcxproj.filters │ ├── packages.config │ ├── res │ │ └── WorkingSets.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h └── memwatch │ ├── memwatch.cpp │ ├── memwatch.vcxproj │ └── memwatch.vcxproj.filters ├── Chapter14 ├── BasicSharing │ ├── BasicSharing.cpp │ ├── BasicSharing.h │ ├── BasicSharing.rc │ ├── BasicSharing.vcxproj │ ├── BasicSharing.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa11136 │ ├── packages.config │ ├── res │ │ └── BasicSharing.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── BasicSharingPlus │ ├── BasicSharing.h │ ├── BasicSharing.sln │ ├── BasicSharingPlus.cpp │ ├── BasicSharingPlus.rc │ ├── BasicSharingPlus.vcxproj │ ├── BasicSharingPlus.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── packages.config │ ├── res │ │ └── BasicSharing.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── Chapter14.sln ├── MicroExcel │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── MicroExcel.cpp │ ├── MicroExcel.h │ ├── MicroExcel.rc │ ├── MicroExcel.vcxproj │ ├── MicroExcel.vcxproj.filters │ ├── RCa19240 │ ├── packages.config │ ├── res │ │ └── MicroExcel.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── filehist │ ├── filehist.cpp │ ├── filehist.vcxproj │ └── filehist.vcxproj.filters └── memview │ ├── memview.cpp │ ├── memview.vcxproj │ └── memview.vcxproj.filters ├── Chapter15 ├── BasicSharing │ ├── BasicSharing.cpp │ ├── BasicSharing.h │ ├── BasicSharing.rc │ ├── BasicSharing.vcxproj │ ├── BasicSharing.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── RCa11136 │ ├── packages.config │ ├── res │ │ └── BasicSharing.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── Chapter15.sln ├── HookDll │ ├── HookDll.def │ ├── HookDll.vcxproj │ ├── HookDll.vcxproj.filters │ ├── dllmain.cpp │ ├── pch.cpp │ └── pch.h ├── HookInject │ ├── HookInject.cpp │ ├── HookInject.vcxproj │ └── HookInject.vcxproj.filters ├── IATHelper │ ├── IATHelper.cpp │ ├── IATHelper.h │ ├── IATHelper.vcxproj │ ├── IATHelper.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Injected │ ├── Injected.vcxproj │ ├── Injected.vcxproj.filters │ ├── dllmain.cpp │ ├── pch.cpp │ └── pch.h ├── Injector │ ├── Injector.cpp │ ├── Injector.vcxproj │ └── Injector.vcxproj.filters ├── SimpleDll │ ├── Simple.cpp │ ├── Simple.h │ ├── SimpleDll.def │ ├── SimpleDll.vcxproj │ ├── SimpleDll.vcxproj.filters │ ├── dllmain.cpp │ ├── framework.h │ ├── pch.cpp │ └── pch.h ├── SimplePrimes │ ├── SimplePrimes.cpp │ ├── SimplePrimes.vcxproj │ └── SimplePrimes.vcxproj.filters ├── SimplePrimes2 │ ├── SimplePrimes2.cpp │ ├── SimplePrimes2.vcxproj │ └── SimplePrimes2.vcxproj.filters └── WorkingSets │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── SortHelper.cpp │ ├── SortHelper.h │ ├── View.cpp │ ├── View.h │ ├── VirtualListView.h │ ├── WorkingSets.cpp │ ├── WorkingSets.h │ ├── WorkingSets.rc │ ├── WorkingSets.vcxproj │ ├── WorkingSets.vcxproj.filters │ ├── packages.config │ ├── res │ └── WorkingSets.ico │ ├── resource.h │ ├── stdafx.cpp │ └── stdafx.h ├── Chapter16 ├── Chapter16.sln ├── cfgdemo │ ├── cfgdemo.cpp │ ├── cfgdemo.vcxproj │ └── cfgdemo.vcxproj.filters ├── runas │ ├── runas.cpp │ ├── runas.vcxproj │ └── runas.vcxproj.filters ├── sd │ ├── sd.cpp │ ├── sd.vcxproj │ └── sd.vcxproj.filters ├── setvirt │ ├── setvirt.cpp │ ├── setvirt.vcxproj │ └── setvirt.vcxproj.filters ├── token │ ├── token.cpp │ ├── token.vcxproj │ └── token.vcxproj.filters └── wellknownsids │ ├── wellknownsids.cpp │ ├── wellknownsids.vcxproj │ └── wellknownsids.vcxproj.filters ├── Chapter17 ├── Chapter17.sln ├── DumpKey │ ├── DumpKey.cpp │ ├── DumpKey.vcxproj │ └── DumpKey.vcxproj.filters ├── RegWatch │ ├── RegWatch.cpp │ ├── RegWatch.vcxproj │ └── RegWatch.vcxproj.filters └── RegWatch2 │ ├── EventParser.cpp │ ├── EventParser.h │ ├── RegWatch2.cpp │ ├── RegWatch2.vcxproj │ ├── RegWatch2.vcxproj.filters │ ├── TraceManager.cpp │ ├── TraceManager.h │ └── packages.config ├── Chapter18 ├── CalcClient │ ├── CalcClient.cpp │ ├── CalcClient.vcxproj │ └── CalcClient.vcxproj.filters ├── CalculatorSvr │ ├── CalculatorSvr.cpp │ ├── CalculatorSvr.vcxproj │ └── CalculatorSvr.vcxproj.filters ├── Chapter18.sln ├── LoggerSvr │ ├── LoggerSvr.cpp │ ├── LoggerSvr.vcxproj │ └── LoggerSvr.vcxproj.filters ├── SimplePipe │ ├── SimplePipe.cpp │ ├── SimplePipe.vcxproj │ └── SimplePipe.vcxproj.filters └── TestLog │ ├── TestLog.cpp │ ├── TestLog.vcxproj │ └── TestLog.vcxproj.filters ├── Chapter19 ├── AlarmSvc │ ├── AlarmCommon.h │ ├── AlarmSvc.cpp │ ├── AlarmSvc.vcxproj │ ├── AlarmSvc.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Chapter19.sln ├── GenSvc │ ├── FileLogger.cpp │ ├── FileLogger.h │ ├── GenSvc.cpp │ ├── GenSvc.vcxproj │ ├── GenSvc.vcxproj.filters │ ├── Logger.cpp │ ├── Logger.h │ ├── pch.cpp │ └── pch.h ├── alarm │ ├── alarm.cpp │ ├── alarm.vcxproj │ └── alarm.vcxproj.filters ├── enumsvc │ ├── enumsvc.cpp │ ├── enumsvc.vcxproj │ └── enumsvc.vcxproj.filters └── svcpriv │ ├── svcpriv.cpp │ ├── svcpriv.vcxproj │ └── svcpriv.vcxproj.filters ├── Chapter20 ├── Chapter20.sln ├── CounterSelector │ ├── CounterSelector.cpp │ ├── CounterSelector.vcxproj │ └── CounterSelector.vcxproj.filters ├── DebugPrint │ ├── DebugPrint.cpp │ ├── DebugPrint.vcxproj │ └── DebugPrint.vcxproj.filters ├── EtwMeta │ ├── EtwMeta.cpp │ ├── EtwMeta.vcxproj │ └── EtwMeta.vcxproj.filters ├── KernelETW │ ├── KernelETW.cpp │ ├── KernelETW.vcxproj │ └── KernelETW.vcxproj.filters ├── MD5Calc │ ├── HashCache.cpp │ ├── HashCache.h │ ├── MD5Calc.cpp │ ├── MD5Calc.vcxproj │ ├── MD5Calc.vcxproj.filters │ ├── MD5Calculator.cpp │ ├── MD5Calculator.h │ ├── ProcessManager.cpp │ ├── ProcessManager.h │ ├── packages.config │ ├── pch.cpp │ └── pch.h ├── ParseETW │ ├── ParseETW.cpp │ ├── ParseETW.vcxproj │ └── ParseETW.vcxproj.filters ├── QSlice │ ├── PerfCountersQuery.cpp │ ├── PerfCountersQuery.h │ ├── ProcessManager.cpp │ ├── ProcessManager.h │ ├── QSlice.cpp │ ├── QSlice.vcxproj │ ├── QSlice.vcxproj.filters │ ├── packages.config │ ├── pch.cpp │ └── pch.h ├── RunETW │ ├── RunETW.cpp │ ├── RunETW.vcxproj │ └── RunETW.vcxproj.filters ├── RunETW2 │ ├── RunETW2.cpp │ ├── RunETW2.vcxproj │ └── RunETW2.vcxproj.filters ├── SimpleDebug │ ├── SimpleDebug.cpp │ ├── SimpleDebug.vcxproj │ └── SimpleDebug.vcxproj.filters └── snapproc │ ├── snapproc.cpp │ ├── snapproc.vcxproj │ └── snapproc.vcxproj.filters ├── Chapter21 ├── BitsDemo │ ├── BitsDemo.cpp │ ├── BitsDemo.vcxproj │ ├── BitsDemo.vcxproj.filters │ ├── JobNotifications.cpp │ └── JobNotifications.h ├── BitsDemoCS │ ├── App.config │ ├── BitsDemoCS.csproj │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── bits.dll ├── CalcCS │ ├── App.config │ ├── CalcCS.csproj │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Calculator │ ├── Calculator.cpp │ ├── Calculator.vcxproj │ └── Calculator.vcxproj.filters ├── Chapter21.sln └── RPNCalcSvr │ ├── RPNCalcInterfaces.h │ ├── RPNCalcSvr.def │ ├── RPNCalcSvr.vcxproj │ ├── RPNCalcSvr.vcxproj.filters │ ├── RPNCalculator.cpp │ ├── RPNCalculator.h │ ├── RPNCalculatorFactory.cpp │ ├── RPNCalculatorFactory.h │ ├── dllmain.cpp │ ├── pch.cpp │ └── pch.h ├── Chapter22 ├── AppList │ ├── AppList.vcxproj │ ├── AppList.vcxproj.filters │ ├── PropertySheet.props │ ├── main.cpp │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ └── readme.txt ├── Chapter22.sln ├── DateTime │ ├── DateTime.cpp │ ├── DateTime.vcxproj │ └── DateTime.vcxproj.filters ├── DateTime2 │ ├── DateTime2.cpp │ ├── DateTime2.vcxproj │ ├── DateTime2.vcxproj.filters │ ├── packages.config │ ├── pch.cpp │ └── pch.h ├── NetworkInfo │ ├── NetworkInfo.vcxproj │ ├── NetworkInfo.vcxproj.filters │ ├── PropertySheet.props │ ├── main.cpp │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ └── readme.txt └── NetworkInfoRaw │ ├── NetworkInfoRaw.cpp │ ├── NetworkInfoRaw.vcxproj │ ├── NetworkInfoRaw.vcxproj.filters │ ├── pch.cpp │ └── pch.h ├── Chapter23 ├── Chapter23.sln ├── SEHDemo │ ├── SEHDemo.cpp │ ├── SEHDemo.vcxproj │ └── SEHDemo.vcxproj.filters └── Unhandled │ ├── Unhandled.cpp │ ├── Unhandled.vcxproj │ └── Unhandled.vcxproj.filters ├── Cover2.png ├── LICENSE └── README.md /Chapter01/HelloWin/HelloWin.cpp: -------------------------------------------------------------------------------- 1 | // HelloWin.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include "pch.h" 5 | 6 | int main() { 7 | SYSTEM_INFO si; 8 | ::GetNativeSystemInfo(&si); 9 | 10 | printf("Number of Logical Processors: %d\n", si.dwNumberOfProcessors); 11 | printf("Page size: %d Bytes\n", si.dwPageSize); 12 | printf("Processor Mask: 0x%p\n", (PVOID)si.dwActiveProcessorMask); 13 | printf("Minimum process address: 0x%p\n", si.lpMinimumApplicationAddress); 14 | printf("Maximum process address: 0x%p\n", si.lpMaximumApplicationAddress); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Chapter01/HelloWin/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /Chapter01/HelloWin/pch.h: -------------------------------------------------------------------------------- 1 | #ifndef PCH_H 2 | #define PCH_H 3 | 4 | #include 5 | #include 6 | 7 | #endif //PCH_H 8 | -------------------------------------------------------------------------------- /Chapter01/ShowError/ShowError.cpp: -------------------------------------------------------------------------------- 1 | // ShowError.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include "pch.h" 5 | 6 | int main(int argc, const char* argv[]) { 7 | if (argc < 2) { 8 | printf("Usage: ShowError \n"); 9 | return 0; 10 | } 11 | 12 | int message = atoi(argv[1]); 13 | 14 | LPWSTR text; 15 | DWORD chars = ::FormatMessage( 16 | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 17 | nullptr, message, 0, (LPWSTR)&text, 0, nullptr); 18 | if (chars > 0) { 19 | printf("Message %d: %ws\n", message, text); 20 | ::LocalFree(text); 21 | } 22 | else { 23 | printf("No such error exists\n"); 24 | } 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Chapter01/ShowError/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /Chapter01/ShowError/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | 15 | #endif //PCH_H 16 | -------------------------------------------------------------------------------- /Chapter02/BasicSharing/BasicSharing.cpp: -------------------------------------------------------------------------------- 1 | // BasicSharing.cpp : main source file for BasicSharing.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | #include "MainDlg.h" 8 | 9 | CAppModule _Module; 10 | 11 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 12 | HRESULT hRes = ::CoInitialize(nullptr); 13 | ATLASSERT(SUCCEEDED(hRes)); 14 | 15 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 16 | 17 | hRes = _Module.Init(nullptr, hInstance); 18 | ATLASSERT(SUCCEEDED(hRes)); 19 | 20 | { 21 | CMainDlg dlgMain; 22 | dlgMain.DoModal(); 23 | } 24 | 25 | _Module.Term(); 26 | ::CoUninitialize(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter02/BasicSharing/BasicSharing.h: -------------------------------------------------------------------------------- 1 | // BasicSharing.h 2 | -------------------------------------------------------------------------------- /Chapter02/BasicSharing/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter02/BasicSharing/res/BasicSharing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter02/BasicSharing/res/BasicSharing.ico -------------------------------------------------------------------------------- /Chapter02/BasicSharing/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by BasicSharing.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_TEXT 1000 8 | #define IDC_WRITE 1001 9 | #define IDC_BUTTON2 1002 10 | #define IDC_READ 1002 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 202 17 | #define _APS_NEXT_COMMAND_VALUE 32775 18 | #define _APS_NEXT_CONTROL_VALUE 1003 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /Chapter02/BasicSharing/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BasicSharing.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing/PrivateSharing.cpp: -------------------------------------------------------------------------------- 1 | // PrivateSharing.cpp : main source file for PrivateSharing.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "MainDlg.h" 7 | 8 | CAppModule _Module; 9 | 10 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 11 | HRESULT hRes = ::CoInitialize(nullptr); 12 | ATLASSERT(SUCCEEDED(hRes)); 13 | 14 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 15 | 16 | hRes = _Module.Init(nullptr, hInstance); 17 | ATLASSERT(SUCCEEDED(hRes)); 18 | 19 | { 20 | CMainDlg dlgMain; 21 | dlgMain.DoModal(); 22 | } 23 | 24 | _Module.Term(); 25 | ::CoUninitialize(); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing/PrivateSharing.h: -------------------------------------------------------------------------------- 1 | // PrivateSharing.h 2 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing/res/PrivateSharing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter02/PrivateSharing/res/PrivateSharing.ico -------------------------------------------------------------------------------- /Chapter02/PrivateSharing/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by PrivateSharing.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_TEXT 1000 8 | #define IDC_WRITE 1001 9 | #define IDC_READ 1002 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NEXT_RESOURCE_VALUE 202 16 | #define _APS_NEXT_COMMAND_VALUE 32775 17 | #define _APS_NEXT_CONTROL_VALUE 1000 18 | #define _APS_NEXT_SYMED_VALUE 101 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // PrivateSharing.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing2/PrivateSharing.cpp: -------------------------------------------------------------------------------- 1 | // PrivateSharing.cpp : main source file for PrivateSharing.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | #include "MainDlg.h" 8 | 9 | CAppModule _Module; 10 | 11 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 12 | HRESULT hRes = ::CoInitialize(nullptr); 13 | ATLASSERT(SUCCEEDED(hRes)); 14 | 15 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 16 | 17 | hRes = _Module.Init(nullptr, hInstance); 18 | ATLASSERT(SUCCEEDED(hRes)); 19 | 20 | { 21 | CMainDlg dlgMain; 22 | dlgMain.DoModal(); 23 | } 24 | 25 | _Module.Term(); 26 | ::CoUninitialize(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing2/PrivateSharing.h: -------------------------------------------------------------------------------- 1 | // PrivateSharing.h 2 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing2/res/PrivateSharing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter02/PrivateSharing2/res/PrivateSharing.ico -------------------------------------------------------------------------------- /Chapter02/PrivateSharing2/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by PrivateSharing.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_TEXT 1000 8 | #define IDC_WRITE 1001 9 | #define IDC_READ 1002 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NEXT_RESOURCE_VALUE 202 16 | #define _APS_NEXT_COMMAND_VALUE 32775 17 | #define _APS_NEXT_CONTROL_VALUE 1000 18 | #define _APS_NEXT_SYMED_VALUE 101 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing2/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // PrivateSharing.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter02/PrivateSharing2/wilex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace wil { 4 | static void close_private_ns(HANDLE h) { 5 | ::ClosePrivateNamespace(h, 0); 6 | }; 7 | 8 | using unique_private_ns = unique_any_handle_null_only; 9 | 10 | using unique_bound_desc = unique_any_handle_null_only; 11 | } 12 | -------------------------------------------------------------------------------- /Chapter02/SingleInstance/SingleInstance.h: -------------------------------------------------------------------------------- 1 | // SingleInstance.h 2 | -------------------------------------------------------------------------------- /Chapter02/SingleInstance/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter02/SingleInstance/res/singleinstance.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter02/SingleInstance/res/singleinstance.ico -------------------------------------------------------------------------------- /Chapter02/SingleInstance/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SingleInstance.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_LIST1 1000 8 | #define IDC_LIST 1000 9 | 10 | // Next default values for new objects 11 | // 12 | #ifdef APSTUDIO_INVOKED 13 | #ifndef APSTUDIO_READONLY_SYMBOLS 14 | #define _APS_NEXT_RESOURCE_VALUE 202 15 | #define _APS_NEXT_COMMAND_VALUE 32775 16 | #define _APS_NEXT_CONTROL_VALUE 1001 17 | #define _APS_NEXT_SYMED_VALUE 101 18 | #endif 19 | #endif 20 | -------------------------------------------------------------------------------- /Chapter02/SingleInstance/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SingleInstance.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter03/InheritSharing/InheritSharing.cpp: -------------------------------------------------------------------------------- 1 | // InheritSharing.cpp : main source file for InheritSharing.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "MainDlg.h" 7 | 8 | CAppModule _Module; 9 | 10 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { 11 | HRESULT hRes = ::CoInitialize(nullptr); 12 | ATLASSERT(SUCCEEDED(hRes)); 13 | 14 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 15 | 16 | hRes = _Module.Init(nullptr, hInstance); 17 | ATLASSERT(SUCCEEDED(hRes)); 18 | 19 | { 20 | CMainDlg dlgMain; 21 | dlgMain.DoModal(); 22 | } 23 | 24 | _Module.Term(); 25 | ::CoUninitialize(); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Chapter03/InheritSharing/InheritSharing.h: -------------------------------------------------------------------------------- 1 | // InheritSharing.h 2 | -------------------------------------------------------------------------------- /Chapter03/InheritSharing/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter03/InheritSharing/res/inheritsharing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter03/InheritSharing/res/inheritsharing.ico -------------------------------------------------------------------------------- /Chapter03/InheritSharing/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by InheritSharing.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_TEXT 1000 8 | #define IDC_WRITE 1001 9 | #define IDC_READ 1002 10 | #define IDC_CREATE 1003 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 202 17 | #define _APS_NEXT_COMMAND_VALUE 32775 18 | #define _APS_NEXT_CONTROL_VALUE 1004 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /Chapter03/InheritSharing/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // InheritSharing.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter03/MetroManager/AboutDlg.cpp: -------------------------------------------------------------------------------- 1 | // aboutdlg.cpp : implementation of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "pch.h" 6 | #include "resource.h" 7 | 8 | #include "aboutdlg.h" 9 | 10 | LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 11 | { 12 | CenterWindow(GetParent()); 13 | return TRUE; 14 | } 15 | 16 | LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 17 | { 18 | EndDialog(wID); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Chapter03/MetroManager/AboutDlg.h: -------------------------------------------------------------------------------- 1 | // aboutdlg.h : interface of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CAboutDlg : public CDialogImpl 8 | { 9 | public: 10 | enum { IDD = IDD_ABOUTBOX }; 11 | 12 | BEGIN_MSG_MAP(CAboutDlg) 13 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 14 | COMMAND_ID_HANDLER(IDOK, OnCloseCmd) 15 | COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) 16 | END_MSG_MAP() 17 | 18 | // Handler prototypes (uncomment arguments if needed): 19 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 20 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 21 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 22 | 23 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 24 | LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 25 | }; 26 | -------------------------------------------------------------------------------- /Chapter03/MetroManager/MetroManager.h: -------------------------------------------------------------------------------- 1 | // MetroManager.h 2 | -------------------------------------------------------------------------------- /Chapter03/MetroManager/SearchBar.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "SearchBar.h" 3 | 4 | BOOL CSearchBar::PreTranslateMessage(MSG * pMsg) { 5 | return CWindow::IsDialogMessage(pMsg); 6 | } 7 | 8 | LRESULT CSearchBar::OnDoSearch(WORD, WORD wID, HWND, BOOL &) { 9 | CString text; 10 | GetDlgItemText(IDC_SEARCH, text); 11 | ::SendMessage(GetParent(), WM_USER + 100, 0, (LPARAM)(PCWSTR)text); 12 | 13 | return 0; 14 | } 15 | 16 | LRESULT CSearchBar::OnClear(WORD, WORD wID, HWND, BOOL &) { 17 | SetDlgItemText(IDC_SEARCH, L""); 18 | ::SendMessage(GetParent(), WM_USER + 100, 0, (LPARAM)L""); 19 | 20 | return 0; 21 | } 22 | 23 | LRESULT CSearchBar::OnEraseBackground(UINT, WPARAM wParam, LPARAM, BOOL &) { 24 | CDCHandle dc((HDC)wParam); 25 | RECT rc; 26 | GetClientRect(&rc); 27 | dc.FillSolidRect(&rc, ::GetSysColor(COLOR_WINDOW)); 28 | 29 | return 1; 30 | } 31 | 32 | LRESULT CSearchBar::OnControlColor(UINT, WPARAM, LPARAM, BOOL &) { 33 | return COLOR_WINDOW + 1; 34 | } 35 | -------------------------------------------------------------------------------- /Chapter03/MetroManager/SearchBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | 5 | class CSearchBar : 6 | public CDialogImpl { 7 | public: 8 | enum { IDD = IDD_SEARCHBAR }; 9 | 10 | BOOL PreTranslateMessage(MSG* pMsg); 11 | 12 | BEGIN_MSG_MAP(CSearchBar) 13 | COMMAND_ID_HANDLER(IDC_DOSEARCH, OnDoSearch) 14 | COMMAND_ID_HANDLER(IDC_CLEAR, OnClear) 15 | MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) 16 | MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnControlColor) 17 | END_MSG_MAP() 18 | 19 | private: 20 | LRESULT OnDoSearch(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 21 | LRESULT OnClear(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 22 | LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 23 | LRESULT OnControlColor(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 24 | 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /Chapter03/MetroManager/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter03/MetroManager/pch.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MetroManager.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "pch.h" 6 | -------------------------------------------------------------------------------- /Chapter03/MetroManager/res/metromanager.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter03/MetroManager/res/metromanager.ico -------------------------------------------------------------------------------- /Chapter03/MetroManager/res/toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter03/MetroManager/res/toolbar.bmp -------------------------------------------------------------------------------- /Chapter03/MetroManager/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MetroManager.rc 4 | // 5 | #define IDD_ABOUTBOX 100 6 | #define IDD_SEARCHBAR 103 7 | #define IDR_MAINFRAME 128 8 | #define IDC_SEARCH 1000 9 | #define IDC_DOSEARCH 1001 10 | #define IDC_CLEAR 1002 11 | #define ID_ACTION_EXECUTE 32777 12 | 13 | // Next default values for new objects 14 | // 15 | #ifdef APSTUDIO_INVOKED 16 | #ifndef APSTUDIO_READONLY_SYMBOLS 17 | #define _APS_NEXT_RESOURCE_VALUE 206 18 | #define _APS_NEXT_COMMAND_VALUE 32778 19 | #define _APS_NEXT_CONTROL_VALUE 1002 20 | #define _APS_NEXT_SYMED_VALUE 101 21 | #endif 22 | #endif 23 | -------------------------------------------------------------------------------- /Chapter03/MiniProcExp/AboutDlg.cpp: -------------------------------------------------------------------------------- 1 | // aboutdlg.cpp : implementation of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "resource.h" 7 | 8 | #include "aboutdlg.h" 9 | 10 | LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 11 | { 12 | CenterWindow(GetParent()); 13 | return TRUE; 14 | } 15 | 16 | LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 17 | { 18 | EndDialog(wID); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Chapter03/MiniProcExp/AboutDlg.h: -------------------------------------------------------------------------------- 1 | // aboutdlg.h : interface of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CAboutDlg : public CDialogImpl 8 | { 9 | public: 10 | enum { IDD = IDD_ABOUTBOX }; 11 | 12 | BEGIN_MSG_MAP(CAboutDlg) 13 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 14 | COMMAND_ID_HANDLER(IDOK, OnCloseCmd) 15 | COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) 16 | END_MSG_MAP() 17 | 18 | // Handler prototypes (uncomment arguments if needed): 19 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 20 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 21 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 22 | 23 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 24 | LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 25 | }; 26 | -------------------------------------------------------------------------------- /Chapter03/MiniProcExp/MiniProcExp.h: -------------------------------------------------------------------------------- 1 | // MiniProcExp.h 2 | -------------------------------------------------------------------------------- /Chapter03/MiniProcExp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter03/MiniProcExp/res/MiniProcExp.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter03/MiniProcExp/res/MiniProcExp.ico -------------------------------------------------------------------------------- /Chapter03/MiniProcExp/res/Toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter03/MiniProcExp/res/Toolbar.bmp -------------------------------------------------------------------------------- /Chapter03/MiniProcExp/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MiniProcExp.RC 4 | // 5 | 6 | 7 | #define IDD_ABOUTBOX 100 8 | #define IDR_MAINFRAME 128 9 | //#define IDR_MINIPROCEXPTYPE 129 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NEXT_RESOURCE_VALUE 201 16 | #define _APS_NEXT_CONTROL_VALUE 1000 17 | #define _APS_NEXT_SYMED_VALUE 101 18 | #define _APS_NEXT_COMMAND_VALUE 32775 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /Chapter03/MiniProcExp/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MiniProcExp.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter03/ProcEnum/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter03/ProcEnum/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /Chapter03/ProcEnum/pch.h: -------------------------------------------------------------------------------- 1 | #ifndef PCH_H 2 | #define PCH_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #endif //PCH_H 11 | -------------------------------------------------------------------------------- /Chapter03/ProcList/ProcList.cpp: -------------------------------------------------------------------------------- 1 | // ProcList.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include "pch.h" 5 | 6 | int Error(const char* text) { 7 | printf("%s (%d)\n", text, ::GetLastError()); 8 | return 1; 9 | } 10 | 11 | int main() { 12 | HANDLE hSnapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 13 | if (hSnapshot == INVALID_HANDLE_VALUE) 14 | return Error("Failed to create snapshot"); 15 | 16 | PROCESSENTRY32 pe; 17 | pe.dwSize = sizeof(pe); 18 | 19 | if (!::Process32First(hSnapshot, &pe)) 20 | return Error("Failed in Process32First"); 21 | 22 | do { 23 | printf("PID:%6d (PPID:%6d): %ws (Threads=%d) (Priority=%d)\n", 24 | pe.th32ProcessID, pe.th32ParentProcessID, pe.szExeFile, pe.cntThreads, pe.pcPriClassBase); 25 | } while (::Process32Next(hSnapshot, &pe)); 26 | 27 | ::CloseHandle(hSnapshot); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /Chapter03/ProcList/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /Chapter03/ProcList/pch.h: -------------------------------------------------------------------------------- 1 | #ifndef PCH_H 2 | #define PCH_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif //PCH_H 9 | -------------------------------------------------------------------------------- /Chapter03/ProcList2/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /Chapter03/ProcList2/pch.h: -------------------------------------------------------------------------------- 1 | // Tips for Getting Started: 2 | // 1. Use the Solution Explorer window to add/manage files 3 | // 2. Use the Team Explorer window to connect to source control 4 | // 3. Use the Output window to see build output and other messages 5 | // 4. Use the Error List window to view errors 6 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 7 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 8 | 9 | #ifndef PCH_H 10 | #define PCH_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #endif //PCH_H 18 | -------------------------------------------------------------------------------- /Chapter04/CpuLimit/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed 2 | 3 | #include "pch.h" 4 | 5 | // In general, ignore this file, but keep it around if you are using pre-compiled headers. 6 | -------------------------------------------------------------------------------- /Chapter04/CpuLimit/pch.h: -------------------------------------------------------------------------------- 1 | #ifndef PCH_H 2 | #define PCH_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif //PCH_H 9 | -------------------------------------------------------------------------------- /Chapter04/JobMon/JobMon.cpp: -------------------------------------------------------------------------------- 1 | // JobMon.cpp : main source file for JobMon.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | 8 | #include "MainDlg.h" 9 | 10 | CAppModule _Module; 11 | 12 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 13 | HRESULT hRes = ::CoInitialize(nullptr); 14 | ATLASSERT(SUCCEEDED(hRes)); 15 | 16 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 17 | 18 | hRes = _Module.Init(nullptr, hInstance); 19 | ATLASSERT(SUCCEEDED(hRes)); 20 | 21 | int nRet = 0; 22 | // BLOCK: Run application 23 | { 24 | CMainDlg dlgMain; 25 | nRet = (int)dlgMain.DoModal(); 26 | } 27 | 28 | _Module.Term(); 29 | ::CoUninitialize(); 30 | 31 | return nRet; 32 | } 33 | -------------------------------------------------------------------------------- /Chapter04/JobMon/JobMon.h: -------------------------------------------------------------------------------- 1 | // JobMon.h 2 | -------------------------------------------------------------------------------- /Chapter04/JobMon/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter04/JobMon/res/JobMon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter04/JobMon/res/JobMon.ico -------------------------------------------------------------------------------- /Chapter04/JobMon/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // JobMon.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter04/JobTree/JobTree.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter05/PrimesCounter/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter05/PrimesCounter/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #endif //PCH_H 17 | -------------------------------------------------------------------------------- /Chapter07/HashCalc/MD5Calculator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MD5Calculator { 6 | public: 7 | static std::vector Calculate(PCWSTR path); 8 | }; 9 | 10 | -------------------------------------------------------------------------------- /Chapter07/HashCalc/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter07/HashCalc/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter07/HashCalc/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #define WIN32_LEAN_AND_MEAN 11 | 12 | #include 13 | #include 14 | 15 | #endif //PCH_H 16 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/AboutDlg.cpp: -------------------------------------------------------------------------------- 1 | // aboutdlg.cpp : implementation of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "resource.h" 7 | 8 | #include "aboutdlg.h" 9 | 10 | LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 11 | { 12 | CenterWindow(GetParent()); 13 | return TRUE; 14 | } 15 | 16 | LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 17 | { 18 | EndDialog(wID); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/AboutDlg.h: -------------------------------------------------------------------------------- 1 | // aboutdlg.h : interface of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CAboutDlg : public CDialogImpl 8 | { 9 | public: 10 | enum { IDD = IDD_ABOUTBOX }; 11 | 12 | BEGIN_MSG_MAP(CAboutDlg) 13 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 14 | COMMAND_ID_HANDLER(IDOK, OnCloseCmd) 15 | COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) 16 | END_MSG_MAP() 17 | 18 | // Handler prototypes (uncomment arguments if needed): 19 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 20 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 21 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 22 | 23 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 24 | LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 25 | }; 26 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/HashCache.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "HashCache.h" 3 | #include "..\ThreadingHelpers\AutoCriticalSection.h" 4 | 5 | HashCache::HashCache() { 6 | _cache.reserve(512); 7 | } 8 | 9 | bool HashCache::Add(PCWSTR path, const Hash& hash) { 10 | AutoCriticalSection locker(_lock); 11 | auto it = _cache.find(path); 12 | if (it == _cache.end()) { 13 | _cache.insert({ path, hash }); 14 | return true; 15 | } 16 | return false; 17 | } 18 | 19 | const Hash HashCache::Get(PCWSTR path) const { 20 | AutoCriticalSection locker(_lock); 21 | auto it = _cache.find(path); 22 | return it == _cache.end() ? Hash() : it->second; 23 | } 24 | 25 | bool HashCache::Remove(PCWSTR path) { 26 | AutoCriticalSection locker(_lock); 27 | auto it = _cache.find(path); 28 | if (it != _cache.end()) { 29 | _cache.erase(it); 30 | return true; 31 | } 32 | return false; 33 | } 34 | 35 | void HashCache::Clear() { 36 | AutoCriticalSection locker(_lock); 37 | _cache.clear(); 38 | } 39 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/HashCache.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\ThreadingHelpers\CriticalSection.h" 4 | 5 | using Hash = std::vector; 6 | 7 | class HashCache { 8 | public: 9 | HashCache(); 10 | 11 | bool Add(PCWSTR path, const Hash& hash); 12 | const Hash Get(PCWSTR path) const; 13 | bool Remove(PCWSTR path); 14 | void Clear(); 15 | 16 | private: 17 | mutable CriticalSection _lock; 18 | std::unordered_map _cache; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/MD5Calculator.h: -------------------------------------------------------------------------------- 1 | // MD5Calculator.h 2 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/TraceManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class TraceManager final { 4 | public: 5 | ~TraceManager(); 6 | 7 | bool Start(std::function callback); 8 | bool Stop(); 9 | 10 | private: 11 | void OnEventRecord(PEVENT_RECORD rec); 12 | DWORD Run(); 13 | 14 | private: 15 | TRACEHANDLE _handle{ 0 }; 16 | TRACEHANDLE _hTrace{ 0 }; 17 | EVENT_TRACE_PROPERTIES* _properties; 18 | std::unique_ptr _propertiesBuffer; 19 | EVENT_TRACE_LOGFILE _traceLog = { 0 }; 20 | wil::unique_handle _hProcessThread; 21 | std::function _callback; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/res/go.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/MD5Calculator/res/go.ico -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/res/md5calculator.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/MD5Calculator/res/md5calculator.ico -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/res/stop.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/MD5Calculator/res/stop.ico -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/res/toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/MD5Calculator/res/toolbar.bmp -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MD5Calculator.rc 4 | // 5 | #define IDD_ABOUTBOX 100 6 | #define IDR_MAINFRAME 128 7 | #define IDI_GO 202 8 | #define IDI_ICON2 203 9 | #define IDI_STOP 203 10 | #define ID_CALCULATE_GO 32775 11 | #define ID_CALCULATE_STOP 32776 12 | #define ID_CALCULATE_USECACHE 32778 13 | #define ID_EDIT_CLEAR32779 32779 14 | 15 | // Next default values for new objects 16 | // 17 | #ifdef APSTUDIO_INVOKED 18 | #ifndef APSTUDIO_READONLY_SYMBOLS 19 | #define _APS_NEXT_RESOURCE_VALUE 204 20 | #define _APS_NEXT_COMMAND_VALUE 32780 21 | #define _APS_NEXT_CONTROL_VALUE 1000 22 | #define _APS_NEXT_SYMED_VALUE 101 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MD5Calculator.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/AboutDlg.cpp: -------------------------------------------------------------------------------- 1 | // aboutdlg.cpp : implementation of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "resource.h" 7 | 8 | #include "aboutdlg.h" 9 | 10 | LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 11 | { 12 | CenterWindow(GetParent()); 13 | return TRUE; 14 | } 15 | 16 | LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 17 | { 18 | EndDialog(wID); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/AboutDlg.h: -------------------------------------------------------------------------------- 1 | // aboutdlg.h : interface of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CAboutDlg : public CDialogImpl 8 | { 9 | public: 10 | enum { IDD = IDD_ABOUTBOX }; 11 | 12 | BEGIN_MSG_MAP(CAboutDlg) 13 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 14 | COMMAND_ID_HANDLER(IDOK, OnCloseCmd) 15 | COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) 16 | END_MSG_MAP() 17 | 18 | // Handler prototypes (uncomment arguments if needed): 19 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 20 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 21 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 22 | 23 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 24 | LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 25 | }; 26 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/HashCache.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "HashCache.h" 3 | #include "..\ThreadingHelpers\AutoReaderWriterLock.h" 4 | 5 | HashCache::HashCache() { 6 | _cache.reserve(512); 7 | } 8 | 9 | bool HashCache::Add(PCWSTR path, const Hash& hash) { 10 | AutoReaderWriterLockExclusive locker(_lock); 11 | auto it = _cache.find(path); 12 | if (it == _cache.end()) { 13 | _cache.insert({ path, hash }); 14 | return true; 15 | } 16 | return false; 17 | } 18 | 19 | const Hash HashCache::Get(PCWSTR path) const { 20 | AutoReaderWriterLockShared locker(_lock); 21 | auto it = _cache.find(path); 22 | return it == _cache.end() ? Hash() : it->second; 23 | } 24 | 25 | bool HashCache::Remove(PCWSTR path) { 26 | AutoReaderWriterLockExclusive locker(_lock); 27 | auto it = _cache.find(path); 28 | if (it != _cache.end()) { 29 | _cache.erase(it); 30 | return true; 31 | } 32 | return false; 33 | } 34 | 35 | void HashCache::Clear() { 36 | AutoReaderWriterLockExclusive locker(_lock); 37 | _cache.clear(); 38 | } 39 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/HashCache.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\ThreadingHelpers\ReaderWriterLock.h" 4 | 5 | using Hash = std::vector; 6 | 7 | class HashCache { 8 | public: 9 | HashCache(); 10 | 11 | bool Add(PCWSTR path, const Hash& hash); 12 | const Hash Get(PCWSTR path) const; 13 | bool Remove(PCWSTR path); 14 | void Clear(); 15 | 16 | private: 17 | mutable ReaderWriterLock _lock; 18 | std::unordered_map _cache; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/MD5Calculator.h: -------------------------------------------------------------------------------- 1 | // MD5Calculator.h 2 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/TraceManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class TraceManager final { 4 | public: 5 | ~TraceManager(); 6 | 7 | bool Start(std::function callback); 8 | bool Stop(); 9 | 10 | private: 11 | void OnEventRecord(PEVENT_RECORD rec); 12 | DWORD Run(); 13 | 14 | private: 15 | TRACEHANDLE _handle{ 0 }; 16 | TRACEHANDLE _hTrace{ 0 }; 17 | EVENT_TRACE_PROPERTIES* _properties; 18 | std::unique_ptr _propertiesBuffer; 19 | EVENT_TRACE_LOGFILE _traceLog = { 0 }; 20 | wil::unique_handle _hProcessThread; 21 | std::function _callback; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/res/go.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/MD5Calculator2/res/go.ico -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/res/md5calculator.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/MD5Calculator2/res/md5calculator.ico -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/res/stop.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/MD5Calculator2/res/stop.ico -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/res/toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/MD5Calculator2/res/toolbar.bmp -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MD5Calculator.rc 4 | // 5 | #define IDD_ABOUTBOX 100 6 | #define IDR_MAINFRAME 128 7 | #define IDI_GO 202 8 | #define IDI_ICON2 203 9 | #define IDI_STOP 203 10 | #define ID_CALCULATE_GO 32775 11 | #define ID_CALCULATE_STOP 32776 12 | #define ID_CALCULATE_USECACHE 32778 13 | #define ID_EDIT_CLEAR32779 32779 14 | 15 | // Next default values for new objects 16 | // 17 | #ifdef APSTUDIO_INVOKED 18 | #ifndef APSTUDIO_READONLY_SYMBOLS 19 | #define _APS_NEXT_RESOURCE_VALUE 204 20 | #define _APS_NEXT_COMMAND_VALUE 32780 21 | #define _APS_NEXT_CONTROL_VALUE 1000 22 | #define _APS_NEXT_SYMED_VALUE 101 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /Chapter07/MD5Calculator2/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MD5Calculator.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter07/MD5HashCalc/MD5HashCalc.cpp: -------------------------------------------------------------------------------- 1 | // MD5HashCalc.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | #include 6 | #include "..\HashCalc\MD5Calculator.h" 7 | 8 | void DisplayHash(const std::vector& hash) { 9 | for(auto b : hash) 10 | printf("%02X", b); 11 | printf("\n"); 12 | } 13 | 14 | int wmain(int argc, const wchar_t* argv[]) { 15 | if (argc < 2) { 16 | printf("Usage: md5hashcalc \n"); 17 | return 0; 18 | } 19 | 20 | auto hash = MD5Calculator::Calculate(argv[1]); 21 | if (hash.empty()) { 22 | printf("Error: %d\n", ::GetLastError()); 23 | } 24 | else { 25 | DisplayHash(hash); 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Chapter07/MD5HashCalc/MD5HashCalc.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter07/QueueDemo/QueueDemo.cpp: -------------------------------------------------------------------------------- 1 | // QueueDemo.cpp : main source file for QueueDemo.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | 8 | #include "MainDlg.h" 9 | 10 | CAppModule _Module; 11 | 12 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 13 | HRESULT hRes = ::CoInitialize(nullptr); 14 | ATLASSERT(SUCCEEDED(hRes)); 15 | 16 | AtlInitCommonControls(ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES); 17 | 18 | hRes = _Module.Init(nullptr, hInstance); 19 | ATLASSERT(SUCCEEDED(hRes)); 20 | 21 | CMainDlg dlgMain; 22 | auto ret = (int)dlgMain.DoModal(); 23 | 24 | _Module.Term(); 25 | ::CoUninitialize(); 26 | 27 | return ret; 28 | } 29 | -------------------------------------------------------------------------------- /Chapter07/QueueDemo/QueueDemo.h: -------------------------------------------------------------------------------- 1 | // QueueDemo.h 2 | -------------------------------------------------------------------------------- /Chapter07/QueueDemo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter07/QueueDemo/res/QueueDemo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/QueueDemo/res/QueueDemo.ico -------------------------------------------------------------------------------- /Chapter07/QueueDemo/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by QueueDemo.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_PRODUCERS 1000 8 | #define IDC_CONSUMERS 1001 9 | #define IDC_RUN 1002 10 | #define IDC_LOAD 1003 11 | #define IDC_STOP 1004 12 | #define IDC_LIST_THREADS 1005 13 | #define IDC_QUEUE_SIZE 1006 14 | 15 | // Next default values for new objects 16 | // 17 | #ifdef APSTUDIO_INVOKED 18 | #ifndef APSTUDIO_READONLY_SYMBOLS 19 | #define _APS_NEXT_RESOURCE_VALUE 202 20 | #define _APS_NEXT_COMMAND_VALUE 32775 21 | #define _APS_NEXT_CONTROL_VALUE 1007 22 | #define _APS_NEXT_SYMED_VALUE 101 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /Chapter07/QueueDemo/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // QueueDemo.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter07/SimpleIncrement/SimpleIncrement.cpp: -------------------------------------------------------------------------------- 1 | // SimpleIncrement.cpp : main source file for SimpleIncrement.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "resource.h" 6 | #include "MainDlg.h" 7 | 8 | CAppModule _Module; 9 | 10 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 11 | HRESULT hRes = ::CoInitialize(nullptr); 12 | ATLASSERT(SUCCEEDED(hRes)); 13 | 14 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 15 | 16 | hRes = _Module.Init(nullptr, hInstance); 17 | ATLASSERT(SUCCEEDED(hRes)); 18 | 19 | int nRet = 0; 20 | { 21 | CMainDlg dlgMain; 22 | nRet = (int)dlgMain.DoModal(); 23 | } 24 | 25 | _Module.Term(); 26 | ::CoUninitialize(); 27 | 28 | return nRet; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter07/SimpleIncrement/SimpleIncrement.h: -------------------------------------------------------------------------------- 1 | // SimpleIncrement.h 2 | -------------------------------------------------------------------------------- /Chapter07/SimpleIncrement/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter07/SimpleIncrement/res/simpleincrement.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter07/SimpleIncrement/res/simpleincrement.ico -------------------------------------------------------------------------------- /Chapter07/SimpleIncrement/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SimpleIncrement.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_THREADS 1000 8 | #define IDC_LOOPS 1001 9 | #define IDC_ALGORITHM 1002 10 | #define IDC_RUN 1003 11 | #define IDC_TOTALCOUNT 1004 12 | #define IDC_ELAPSED 1005 13 | #define IDC_EDIT4 1006 14 | #define IDC_EXPECTED 1006 15 | 16 | // Next default values for new objects 17 | // 18 | #ifdef APSTUDIO_INVOKED 19 | #ifndef APSTUDIO_READONLY_SYMBOLS 20 | #define _APS_NEXT_RESOURCE_VALUE 203 21 | #define _APS_NEXT_COMMAND_VALUE 32775 22 | #define _APS_NEXT_CONTROL_VALUE 1007 23 | #define _APS_NEXT_SYMED_VALUE 101 24 | #endif 25 | #endif 26 | -------------------------------------------------------------------------------- /Chapter07/SimpleIncrement/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SimpleIncrement.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/AutoCriticalSection.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AutoCriticalSection.h" 3 | 4 | AutoCriticalSection::AutoCriticalSection(CRITICAL_SECTION& cs) : _cs(cs) { 5 | ::EnterCriticalSection(&_cs); 6 | } 7 | 8 | AutoCriticalSection::~AutoCriticalSection() { 9 | ::LeaveCriticalSection(&_cs); 10 | } 11 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/AutoCriticalSection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct AutoCriticalSection { 4 | AutoCriticalSection(CRITICAL_SECTION& cs); 5 | ~AutoCriticalSection(); 6 | 7 | // delete copy ctor, move ctor, assignment 8 | AutoCriticalSection(const AutoCriticalSection&) = delete; 9 | AutoCriticalSection& operator=(const AutoCriticalSection&) = delete; 10 | AutoCriticalSection(AutoCriticalSection&&) = delete; 11 | AutoCriticalSection& operator=(AutoCriticalSection&&) = delete; 12 | 13 | private: 14 | CRITICAL_SECTION& _cs; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/AutoReaderWriterLock.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AutoReaderWriterLock.h" 3 | 4 | AutoReaderWriterLockExclusive::AutoReaderWriterLockExclusive(SRWLOCK& lock) : _lock(lock) { 5 | ::AcquireSRWLockExclusive(&_lock); 6 | } 7 | 8 | AutoReaderWriterLockExclusive::~AutoReaderWriterLockExclusive() { 9 | ::ReleaseSRWLockExclusive(&_lock); 10 | } 11 | 12 | AutoReaderWriterLockShared::AutoReaderWriterLockShared(SRWLOCK& lock) : _lock(lock) { 13 | ::AcquireSRWLockShared(&_lock); 14 | } 15 | 16 | AutoReaderWriterLockShared::~AutoReaderWriterLockShared() { 17 | ::ReleaseSRWLockShared(&_lock); 18 | } 19 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/AutoReaderWriterLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ReaderWriterLock.h" 4 | 5 | struct AutoReaderWriterLockExclusive { 6 | AutoReaderWriterLockExclusive(SRWLOCK& lock); 7 | ~AutoReaderWriterLockExclusive(); 8 | 9 | private: 10 | SRWLOCK& _lock; 11 | }; 12 | 13 | struct AutoReaderWriterLockShared { 14 | AutoReaderWriterLockShared(SRWLOCK& lock); 15 | ~AutoReaderWriterLockShared(); 16 | 17 | private: 18 | SRWLOCK& _lock; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/CriticalSection.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "CriticalSection.h" 3 | 4 | CriticalSection::CriticalSection(DWORD spinCount, DWORD flags) { 5 | ::InitializeCriticalSectionEx(this, (DWORD)spinCount, flags); 6 | } 7 | 8 | CriticalSection::~CriticalSection() { 9 | ::DeleteCriticalSection(this); 10 | } 11 | 12 | void CriticalSection::Lock() { 13 | ::EnterCriticalSection(this); 14 | } 15 | 16 | void CriticalSection::Unlock() { 17 | ::LeaveCriticalSection(this); 18 | } 19 | 20 | bool CriticalSection::TryLock() { 21 | return ::TryEnterCriticalSection(this); 22 | } 23 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/CriticalSection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CriticalSection : public CRITICAL_SECTION { 4 | public: 5 | CriticalSection(DWORD spinCount = 0, DWORD flags = 0); 6 | ~CriticalSection(); 7 | 8 | void Lock(); 9 | void Unlock(); 10 | bool TryLock(); 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/ReaderWriterLock.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ReaderWriterLock.h" 3 | 4 | ReaderWriterLock::ReaderWriterLock() { 5 | ::InitializeSRWLock(this); 6 | } 7 | 8 | void ReaderWriterLock::LockShared() { 9 | ::AcquireSRWLockShared(this); 10 | } 11 | 12 | void ReaderWriterLock::UnlockShared() { 13 | ::ReleaseSRWLockShared(this); 14 | } 15 | 16 | void ReaderWriterLock::LockExclusive() { 17 | ::AcquireSRWLockExclusive(this); 18 | } 19 | 20 | void ReaderWriterLock::UnlockExclusive() { 21 | ::ReleaseSRWLockExclusive(this); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/ReaderWriterLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ReaderWriterLock : public SRWLOCK { 4 | public: 5 | ReaderWriterLock(); 6 | ReaderWriterLock(const ReaderWriterLock&) = delete; 7 | 8 | void LockShared(); 9 | void UnlockShared(); 10 | 11 | void LockExclusive(); 12 | void UnlockExclusive(); 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/ThreadSafeQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ThreadSafeQueue.h" 3 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/ThreadingHelpers.cpp: -------------------------------------------------------------------------------- 1 | // ThreadingHelpers.cpp : Defines the functions for the static library. 2 | // 3 | 4 | #include "pch.h" 5 | 6 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter07/ThreadingHelpers/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | 12 | #endif //PCH_H 13 | -------------------------------------------------------------------------------- /Chapter08/MutexDemo/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter08/MutexDemo/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #endif //PCH_H 15 | -------------------------------------------------------------------------------- /Chapter08/QueueDemo/QueueDemo.cpp: -------------------------------------------------------------------------------- 1 | // QueueDemo.cpp : main source file for QueueDemo.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | 8 | #include "MainDlg.h" 9 | 10 | CAppModule _Module; 11 | 12 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 13 | HRESULT hRes = ::CoInitialize(nullptr); 14 | ATLASSERT(SUCCEEDED(hRes)); 15 | 16 | AtlInitCommonControls(ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES); 17 | 18 | hRes = _Module.Init(nullptr, hInstance); 19 | ATLASSERT(SUCCEEDED(hRes)); 20 | 21 | CMainDlg dlgMain; 22 | auto ret = (int)dlgMain.DoModal(); 23 | 24 | _Module.Term(); 25 | ::CoUninitialize(); 26 | 27 | return ret; 28 | } 29 | -------------------------------------------------------------------------------- /Chapter08/QueueDemo/QueueDemo.h: -------------------------------------------------------------------------------- 1 | // QueueDemo.h 2 | -------------------------------------------------------------------------------- /Chapter08/QueueDemo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter08/QueueDemo/res/QueueDemo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter08/QueueDemo/res/QueueDemo.ico -------------------------------------------------------------------------------- /Chapter08/QueueDemo/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by QueueDemo.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_PRODUCERS 1000 8 | #define IDC_CONSUMERS 1001 9 | #define IDC_QUEUESIZE 1002 10 | #define IDC_RUN 1003 11 | #define IDC_LOAD 1004 12 | #define IDC_STOP 1005 13 | #define IDC_LIST_THREADS 1006 14 | #define IDC_MAX_QUEUE_SIZE 1007 15 | 16 | // Next default values for new objects 17 | // 18 | #ifdef APSTUDIO_INVOKED 19 | #ifndef APSTUDIO_READONLY_SYMBOLS 20 | #define _APS_NEXT_RESOURCE_VALUE 202 21 | #define _APS_NEXT_COMMAND_VALUE 32775 22 | #define _APS_NEXT_CONTROL_VALUE 1008 23 | #define _APS_NEXT_SYMED_VALUE 101 24 | #endif 25 | #endif 26 | -------------------------------------------------------------------------------- /Chapter08/QueueDemo/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // QueueDemo.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter08/SimpleTimer/SimpleTimer.cpp: -------------------------------------------------------------------------------- 1 | // SimpleTimer.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include "pch.h" 5 | 6 | void CALLBACK OnTimer(void* param, DWORD low, DWORD high) { 7 | printf("TID: %u Ticks: %u\n", ::GetCurrentThreadId(), ::GetTickCount()); 8 | } 9 | 10 | int main() { 11 | auto hTimer = ::CreateWaitableTimer(nullptr, TRUE, nullptr); 12 | LARGE_INTEGER interval; 13 | interval.QuadPart = -10000 * 1000LL; 14 | ::SetWaitableTimer(hTimer, &interval, 1000, OnTimer, nullptr, FALSE); 15 | printf("Main thread ID: %u\n", ::GetCurrentThreadId()); 16 | 17 | while (true) 18 | ::SleepEx(INFINITE, TRUE); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Chapter08/SimpleTimer/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter08/SimpleTimer/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | 13 | #endif //PCH_H 14 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/AutoCriticalSection.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AutoCriticalSection.h" 3 | 4 | AutoCriticalSection::AutoCriticalSection(CRITICAL_SECTION& cs) : _cs(cs) { 5 | ::EnterCriticalSection(&_cs); 6 | } 7 | 8 | AutoCriticalSection::~AutoCriticalSection() { 9 | ::LeaveCriticalSection(&_cs); 10 | } 11 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/AutoCriticalSection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct AutoCriticalSection { 4 | AutoCriticalSection(CRITICAL_SECTION& cs); 5 | ~AutoCriticalSection(); 6 | 7 | // delete copy ctor, move ctor, assignment 8 | AutoCriticalSection(const AutoCriticalSection&) = delete; 9 | AutoCriticalSection& operator=(const AutoCriticalSection&) = delete; 10 | AutoCriticalSection(AutoCriticalSection&&) = delete; 11 | AutoCriticalSection& operator=(AutoCriticalSection&&) = delete; 12 | 13 | private: 14 | CRITICAL_SECTION& _cs; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/AutoReaderWriterLock.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AutoReaderWriterLock.h" 3 | 4 | AutoReaderWriterLockExclusive::AutoReaderWriterLockExclusive(SRWLOCK& lock) : _lock(lock) { 5 | ::AcquireSRWLockExclusive(&_lock); 6 | } 7 | 8 | AutoReaderWriterLockExclusive::~AutoReaderWriterLockExclusive() { 9 | ::ReleaseSRWLockExclusive(&_lock); 10 | } 11 | 12 | AutoReaderWriterLockShared::AutoReaderWriterLockShared(SRWLOCK& lock) : _lock(lock) { 13 | ::AcquireSRWLockShared(&_lock); 14 | } 15 | 16 | AutoReaderWriterLockShared::~AutoReaderWriterLockShared() { 17 | ::ReleaseSRWLockShared(&_lock); 18 | } 19 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/AutoReaderWriterLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ReaderWriterLock.h" 4 | 5 | struct AutoReaderWriterLockExclusive { 6 | AutoReaderWriterLockExclusive(SRWLOCK& lock); 7 | ~AutoReaderWriterLockExclusive(); 8 | 9 | private: 10 | SRWLOCK& _lock; 11 | }; 12 | 13 | struct AutoReaderWriterLockShared { 14 | AutoReaderWriterLockShared(SRWLOCK& lock); 15 | ~AutoReaderWriterLockShared(); 16 | 17 | private: 18 | SRWLOCK& _lock; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/CriticalSection.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "CriticalSection.h" 3 | 4 | CriticalSection::CriticalSection(DWORD spinCount, DWORD flags) { 5 | ::InitializeCriticalSectionEx(this, (DWORD)spinCount, flags); 6 | } 7 | 8 | CriticalSection::~CriticalSection() { 9 | ::DeleteCriticalSection(this); 10 | } 11 | 12 | void CriticalSection::Lock() { 13 | ::EnterCriticalSection(this); 14 | } 15 | 16 | void CriticalSection::Unlock() { 17 | ::LeaveCriticalSection(this); 18 | } 19 | 20 | bool CriticalSection::TryLock() { 21 | return ::TryEnterCriticalSection(this); 22 | } 23 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/CriticalSection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CriticalSection : public CRITICAL_SECTION { 4 | public: 5 | CriticalSection(DWORD spinCount = 0, DWORD flags = 0); 6 | ~CriticalSection(); 7 | 8 | void Lock(); 9 | void Unlock(); 10 | bool TryLock(); 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/ReaderWriterLock.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ReaderWriterLock.h" 3 | 4 | ReaderWriterLock::ReaderWriterLock() { 5 | ::InitializeSRWLock(this); 6 | } 7 | 8 | void ReaderWriterLock::LockShared() { 9 | ::AcquireSRWLockShared(this); 10 | } 11 | 12 | void ReaderWriterLock::UnlockShared() { 13 | ::ReleaseSRWLockShared(this); 14 | } 15 | 16 | void ReaderWriterLock::LockExclusive() { 17 | ::AcquireSRWLockExclusive(this); 18 | } 19 | 20 | void ReaderWriterLock::UnlockExclusive() { 21 | ::ReleaseSRWLockExclusive(this); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/ReaderWriterLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ReaderWriterLock : public SRWLOCK { 4 | public: 5 | ReaderWriterLock(); 6 | ReaderWriterLock(const ReaderWriterLock&) = delete; 7 | 8 | void LockShared(); 9 | void UnlockShared(); 10 | 11 | void LockExclusive(); 12 | void UnlockExclusive(); 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/ThreadSafeQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ThreadSafeQueue.h" 3 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/ThreadingHelpers.cpp: -------------------------------------------------------------------------------- 1 | // ThreadingHelpers.cpp : Defines the functions for the static library. 2 | // 3 | 4 | #include "pch.h" 5 | 6 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter08/ThreadingHelpers/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | 12 | #endif //PCH_H 13 | -------------------------------------------------------------------------------- /Chapter09/HashCalc/MD5Calculator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MD5Calculator { 6 | public: 7 | static std::vector Calculate(PCWSTR path); 8 | }; 9 | 10 | -------------------------------------------------------------------------------- /Chapter09/HashCalc/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter09/HashCalc/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter09/HashCalc/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #define WIN32_LEAN_AND_MEAN 11 | 12 | #include 13 | #include 14 | 15 | #endif //PCH_H 16 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/AboutDlg.cpp: -------------------------------------------------------------------------------- 1 | // aboutdlg.cpp : implementation of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "resource.h" 7 | 8 | #include "aboutdlg.h" 9 | 10 | LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 11 | { 12 | CenterWindow(GetParent()); 13 | return TRUE; 14 | } 15 | 16 | LRESULT CAboutDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 17 | { 18 | EndDialog(wID); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/AboutDlg.h: -------------------------------------------------------------------------------- 1 | // aboutdlg.h : interface of the CAboutDlg class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #pragma once 6 | 7 | class CAboutDlg : public CDialogImpl 8 | { 9 | public: 10 | enum { IDD = IDD_ABOUTBOX }; 11 | 12 | BEGIN_MSG_MAP(CAboutDlg) 13 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 14 | COMMAND_ID_HANDLER(IDOK, OnCloseCmd) 15 | COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) 16 | END_MSG_MAP() 17 | 18 | // Handler prototypes (uncomment arguments if needed): 19 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 20 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) 21 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) 22 | 23 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 24 | LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 25 | }; 26 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/HashCache.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "HashCache.h" 3 | #include "..\ThreadingHelpers\AutoReaderWriterLock.h" 4 | 5 | HashCache::HashCache() { 6 | _cache.reserve(512); 7 | } 8 | 9 | bool HashCache::Add(PCWSTR path, const Hash& hash) { 10 | AutoReaderWriterLockExclusive locker(_lock); 11 | auto it = _cache.find(path); 12 | if (it == _cache.end()) { 13 | _cache.insert({ path, hash }); 14 | return true; 15 | } 16 | return false; 17 | } 18 | 19 | const Hash HashCache::Get(PCWSTR path) const { 20 | AutoReaderWriterLockShared locker(_lock); 21 | auto it = _cache.find(path); 22 | return it == _cache.end() ? Hash() : it->second; 23 | } 24 | 25 | bool HashCache::Remove(PCWSTR path) { 26 | AutoReaderWriterLockExclusive locker(_lock); 27 | auto it = _cache.find(path); 28 | if (it != _cache.end()) { 29 | _cache.erase(it); 30 | return true; 31 | } 32 | return false; 33 | } 34 | 35 | void HashCache::Clear() { 36 | AutoReaderWriterLockExclusive locker(_lock); 37 | _cache.clear(); 38 | } 39 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/HashCache.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\ThreadingHelpers\ReaderWriterLock.h" 4 | 5 | using Hash = std::vector; 6 | 7 | class HashCache { 8 | public: 9 | HashCache(); 10 | 11 | bool Add(PCWSTR path, const Hash& hash); 12 | const Hash Get(PCWSTR path) const; 13 | bool Remove(PCWSTR path); 14 | void Clear(); 15 | 16 | private: 17 | mutable ReaderWriterLock _lock; 18 | std::unordered_map _cache; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/MD5Calculator.h: -------------------------------------------------------------------------------- 1 | // MD5Calculator.h 2 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/TraceManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class TraceManager final { 4 | public: 5 | ~TraceManager(); 6 | 7 | bool Start(std::function callback); 8 | bool Stop(); 9 | 10 | private: 11 | void OnEventRecord(PEVENT_RECORD rec); 12 | DWORD Run(); 13 | 14 | private: 15 | TRACEHANDLE _handle{ 0 }; 16 | TRACEHANDLE _hTrace{ 0 }; 17 | EVENT_TRACE_PROPERTIES* _properties; 18 | std::unique_ptr _propertiesBuffer; 19 | EVENT_TRACE_LOGFILE _traceLog = { 0 }; 20 | wil::unique_handle _hProcessThread; 21 | std::function _callback; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/res/go.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter09/MD5Calculator2/res/go.ico -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/res/md5calculator.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter09/MD5Calculator2/res/md5calculator.ico -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/res/stop.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter09/MD5Calculator2/res/stop.ico -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/res/toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter09/MD5Calculator2/res/toolbar.bmp -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MD5Calculator.rc 4 | // 5 | #define IDD_ABOUTBOX 100 6 | #define IDR_MAINFRAME 128 7 | #define IDI_GO 202 8 | #define IDI_ICON2 203 9 | #define IDI_STOP 203 10 | #define ID_CALCULATE_GO 32775 11 | #define ID_CALCULATE_STOP 32776 12 | #define ID_CALCULATE_USECACHE 32778 13 | #define ID_EDIT_CLEAR32779 32779 14 | 15 | // Next default values for new objects 16 | // 17 | #ifdef APSTUDIO_INVOKED 18 | #ifndef APSTUDIO_READONLY_SYMBOLS 19 | #define _APS_NEXT_RESOURCE_VALUE 204 20 | #define _APS_NEXT_COMMAND_VALUE 32780 21 | #define _APS_NEXT_CONTROL_VALUE 1000 22 | #define _APS_NEXT_SYMED_VALUE 101 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /Chapter09/MD5Calculator2/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MD5Calculator.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter09/SimpleTimer/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter09/SimpleTimer/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | 13 | #endif //PCH_H 14 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork/SimpleWork.cpp: -------------------------------------------------------------------------------- 1 | // SimpleWork.cpp : main source file for SimpleWork.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "resource.h" 6 | #include "MainDlg.h" 7 | 8 | CAppModule _Module; 9 | 10 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 11 | HRESULT hRes = ::CoInitialize(nullptr); 12 | ATLASSERT(SUCCEEDED(hRes)); 13 | 14 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 15 | 16 | hRes = _Module.Init(nullptr, hInstance); 17 | ATLASSERT(SUCCEEDED(hRes)); 18 | 19 | int nRet = 0; 20 | { 21 | CMainDlg dlgMain; 22 | nRet = (int)dlgMain.DoModal(); 23 | } 24 | 25 | _Module.Term(); 26 | ::CoUninitialize(); 27 | 28 | return nRet; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork/SimpleWork.h: -------------------------------------------------------------------------------- 1 | // SimpleWork.h 2 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork/res/simplework.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter09/SimpleWork/res/simplework.ico -------------------------------------------------------------------------------- /Chapter09/SimpleWork/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SimpleWork.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_WORKITEMS 1000 8 | #define IDC_SUBMIT 1001 9 | #define IDC_SUBMIT10 1002 10 | #define IDC_BUTTON1 1003 11 | #define IDC_CLEAR 1003 12 | #define IDC_THREADS 1004 13 | 14 | // Next default values for new objects 15 | // 16 | #ifdef APSTUDIO_INVOKED 17 | #ifndef APSTUDIO_READONLY_SYMBOLS 18 | #define _APS_NEXT_RESOURCE_VALUE 202 19 | #define _APS_NEXT_COMMAND_VALUE 32775 20 | #define _APS_NEXT_CONTROL_VALUE 1005 21 | #define _APS_NEXT_SYMED_VALUE 101 22 | #endif 23 | #endif 24 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SimpleWork.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork2/SimpleWork.cpp: -------------------------------------------------------------------------------- 1 | // SimpleWork.cpp : main source file for SimpleWork.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "resource.h" 6 | #include "MainDlg.h" 7 | 8 | CAppModule _Module; 9 | 10 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 11 | HRESULT hRes = ::CoInitialize(nullptr); 12 | ATLASSERT(SUCCEEDED(hRes)); 13 | 14 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 15 | 16 | hRes = _Module.Init(nullptr, hInstance); 17 | ATLASSERT(SUCCEEDED(hRes)); 18 | 19 | int nRet = 0; 20 | { 21 | CMainDlg dlgMain; 22 | nRet = (int)dlgMain.DoModal(); 23 | } 24 | 25 | _Module.Term(); 26 | ::CoUninitialize(); 27 | 28 | return nRet; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork2/SimpleWork.h: -------------------------------------------------------------------------------- 1 | // SimpleWork.h 2 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork2/res/simplework.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter09/SimpleWork2/res/simplework.ico -------------------------------------------------------------------------------- /Chapter09/SimpleWork2/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SimpleWork2.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_WORKITEMS 1000 8 | #define IDC_SUBMIT 1001 9 | #define IDC_SUBMIT10 1002 10 | #define IDC_CLEAR 1003 11 | #define IDC_THREADS 1004 12 | 13 | // Next default values for new objects 14 | // 15 | #ifdef APSTUDIO_INVOKED 16 | #ifndef APSTUDIO_READONLY_SYMBOLS 17 | #define _APS_NEXT_RESOURCE_VALUE 202 18 | #define _APS_NEXT_COMMAND_VALUE 32775 19 | #define _APS_NEXT_CONTROL_VALUE 1005 20 | #define _APS_NEXT_SYMED_VALUE 101 21 | #endif 22 | #endif 23 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork2/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SimpleWork.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork3/SimpleWork.cpp: -------------------------------------------------------------------------------- 1 | // SimpleWork.cpp : main source file for SimpleWork.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "resource.h" 6 | #include "MainDlg.h" 7 | 8 | CAppModule _Module; 9 | 10 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 11 | HRESULT hRes = ::CoInitialize(nullptr); 12 | ATLASSERT(SUCCEEDED(hRes)); 13 | 14 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 15 | 16 | hRes = _Module.Init(nullptr, hInstance); 17 | ATLASSERT(SUCCEEDED(hRes)); 18 | 19 | int nRet = 0; 20 | { 21 | CMainDlg dlgMain; 22 | nRet = (int)dlgMain.DoModal(); 23 | } 24 | 25 | _Module.Term(); 26 | ::CoUninitialize(); 27 | 28 | return nRet; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork3/SimpleWork.h: -------------------------------------------------------------------------------- 1 | // SimpleWork.h 2 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork3/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork3/res/SimpleWork.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter09/SimpleWork3/res/SimpleWork.ico -------------------------------------------------------------------------------- /Chapter09/SimpleWork3/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SimpleWork.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_WORKITEMS 1000 8 | #define IDC_SUBMIT 1001 9 | #define IDC_SUBMIT10 1002 10 | #define IDC_BUTTON1 1003 11 | #define IDC_CLEAR 1003 12 | #define IDC_THREADS 1004 13 | 14 | // Next default values for new objects 15 | // 16 | #ifdef APSTUDIO_INVOKED 17 | #ifndef APSTUDIO_READONLY_SYMBOLS 18 | #define _APS_NEXT_RESOURCE_VALUE 202 19 | #define _APS_NEXT_COMMAND_VALUE 32775 20 | #define _APS_NEXT_CONTROL_VALUE 1005 21 | #define _APS_NEXT_SYMED_VALUE 101 22 | #endif 23 | #endif 24 | -------------------------------------------------------------------------------- /Chapter09/SimpleWork3/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SimpleWork.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/AutoCriticalSection.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AutoCriticalSection.h" 3 | 4 | AutoCriticalSection::AutoCriticalSection(CRITICAL_SECTION& cs) : _cs(cs) { 5 | ::EnterCriticalSection(&_cs); 6 | } 7 | 8 | AutoCriticalSection::~AutoCriticalSection() { 9 | ::LeaveCriticalSection(&_cs); 10 | } 11 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/AutoCriticalSection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct AutoCriticalSection { 4 | AutoCriticalSection(CRITICAL_SECTION& cs); 5 | ~AutoCriticalSection(); 6 | 7 | // delete copy ctor, move ctor, assignment 8 | AutoCriticalSection(const AutoCriticalSection&) = delete; 9 | AutoCriticalSection& operator=(const AutoCriticalSection&) = delete; 10 | AutoCriticalSection(AutoCriticalSection&&) = delete; 11 | AutoCriticalSection& operator=(AutoCriticalSection&&) = delete; 12 | 13 | private: 14 | CRITICAL_SECTION& _cs; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/AutoReaderWriterLock.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "AutoReaderWriterLock.h" 3 | 4 | AutoReaderWriterLockExclusive::AutoReaderWriterLockExclusive(SRWLOCK& lock) : _lock(lock) { 5 | ::AcquireSRWLockExclusive(&_lock); 6 | } 7 | 8 | AutoReaderWriterLockExclusive::~AutoReaderWriterLockExclusive() { 9 | ::ReleaseSRWLockExclusive(&_lock); 10 | } 11 | 12 | AutoReaderWriterLockShared::AutoReaderWriterLockShared(SRWLOCK& lock) : _lock(lock) { 13 | ::AcquireSRWLockShared(&_lock); 14 | } 15 | 16 | AutoReaderWriterLockShared::~AutoReaderWriterLockShared() { 17 | ::ReleaseSRWLockShared(&_lock); 18 | } 19 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/AutoReaderWriterLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ReaderWriterLock.h" 4 | 5 | struct AutoReaderWriterLockExclusive { 6 | AutoReaderWriterLockExclusive(SRWLOCK& lock); 7 | ~AutoReaderWriterLockExclusive(); 8 | 9 | private: 10 | SRWLOCK& _lock; 11 | }; 12 | 13 | struct AutoReaderWriterLockShared { 14 | AutoReaderWriterLockShared(SRWLOCK& lock); 15 | ~AutoReaderWriterLockShared(); 16 | 17 | private: 18 | SRWLOCK& _lock; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/CriticalSection.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "CriticalSection.h" 3 | 4 | CriticalSection::CriticalSection(DWORD spinCount, DWORD flags) { 5 | ::InitializeCriticalSectionEx(this, (DWORD)spinCount, flags); 6 | } 7 | 8 | CriticalSection::~CriticalSection() { 9 | ::DeleteCriticalSection(this); 10 | } 11 | 12 | void CriticalSection::Lock() { 13 | ::EnterCriticalSection(this); 14 | } 15 | 16 | void CriticalSection::Unlock() { 17 | ::LeaveCriticalSection(this); 18 | } 19 | 20 | bool CriticalSection::TryLock() { 21 | return ::TryEnterCriticalSection(this); 22 | } 23 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/CriticalSection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CriticalSection : public CRITICAL_SECTION { 4 | public: 5 | CriticalSection(DWORD spinCount = 0, DWORD flags = 0); 6 | ~CriticalSection(); 7 | 8 | void Lock(); 9 | void Unlock(); 10 | bool TryLock(); 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/ReaderWriterLock.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ReaderWriterLock.h" 3 | 4 | ReaderWriterLock::ReaderWriterLock() { 5 | ::InitializeSRWLock(this); 6 | } 7 | 8 | void ReaderWriterLock::LockShared() { 9 | ::AcquireSRWLockShared(this); 10 | } 11 | 12 | void ReaderWriterLock::UnlockShared() { 13 | ::ReleaseSRWLockShared(this); 14 | } 15 | 16 | void ReaderWriterLock::LockExclusive() { 17 | ::AcquireSRWLockExclusive(this); 18 | } 19 | 20 | void ReaderWriterLock::UnlockExclusive() { 21 | ::ReleaseSRWLockExclusive(this); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/ReaderWriterLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ReaderWriterLock : public SRWLOCK { 4 | public: 5 | ReaderWriterLock(); 6 | ReaderWriterLock(const ReaderWriterLock&) = delete; 7 | 8 | void LockShared(); 9 | void UnlockShared(); 10 | 11 | void LockExclusive(); 12 | void UnlockExclusive(); 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/ThreadSafeQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ThreadSafeQueue.h" 3 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/ThreadingHelpers.cpp: -------------------------------------------------------------------------------- 1 | // ThreadingHelpers.cpp : Defines the functions for the static library. 2 | // 3 | 4 | #include "pch.h" 5 | 6 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter09/ThreadingHelpers/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | 12 | #endif //PCH_H 13 | -------------------------------------------------------------------------------- /Chapter10/DeadlockDetector/DeadlockDetector.h: -------------------------------------------------------------------------------- 1 | // DeadlockDetector.h 2 | -------------------------------------------------------------------------------- /Chapter10/DeadlockDetector/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter10/DeadlockDetector/res/DeadlockDetector.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/DeadlockDetector/res/DeadlockDetector.ico -------------------------------------------------------------------------------- /Chapter10/DeadlockDetector/res/refresh.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/DeadlockDetector/res/refresh.ico -------------------------------------------------------------------------------- /Chapter10/DeadlockDetector/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by DeadlockDetector.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDI_ICON1 202 8 | #define IDI_REFRESH 202 9 | #define IDC_PROCESSES 1000 10 | #define IDC_DETECT 1001 11 | #define IDC_CHAINS 1002 12 | #define IDC_REFRESH 1003 13 | 14 | // Next default values for new objects 15 | // 16 | #ifdef APSTUDIO_INVOKED 17 | #ifndef APSTUDIO_READONLY_SYMBOLS 18 | #define _APS_NEXT_RESOURCE_VALUE 203 19 | #define _APS_NEXT_COMMAND_VALUE 32775 20 | #define _APS_NEXT_CONTROL_VALUE 1004 21 | #define _APS_NEXT_SYMED_VALUE 101 22 | #endif 23 | #endif 24 | -------------------------------------------------------------------------------- /Chapter10/DeadlockDetector/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // DeadlockDetector.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter10/FalseSharing/FalseSharing.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/FalseSharing/FalseSharing.cpp -------------------------------------------------------------------------------- /Chapter10/FalseSharing/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter10/FalseSharing/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/FalseSharing/stdafx.cpp -------------------------------------------------------------------------------- /Chapter10/FalseSharing/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/FalseSharing/stdafx.h -------------------------------------------------------------------------------- /Chapter10/FalseSharing/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/FalseSharing/targetver.h -------------------------------------------------------------------------------- /Chapter10/Inc/Matrix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | struct Matrix { 5 | Matrix(int rows, int columns) : 6 | _data(std::make_unique(rows * columns)), _rows(rows), _columns(columns) { 7 | } 8 | 9 | int Rows() const { 10 | return _rows; 11 | } 12 | 13 | int Columns() const { 14 | return _columns; 15 | } 16 | 17 | struct DataRow { 18 | DataRow(const Matrix& m, int row) : _m(m), _row(row) { 19 | } 20 | 21 | const T& operator[](int column) const { 22 | return _m._data[_row * _m.Columns() + column]; 23 | } 24 | 25 | T& operator[](int column) { 26 | return _m._data[_row * _m.Columns() + column]; 27 | } 28 | 29 | private: 30 | const Matrix& _m; 31 | int _row; 32 | }; 33 | 34 | const DataRow operator[](int row) const { 35 | const DataRow dr(*this, row); 36 | return dr; 37 | } 38 | 39 | DataRow operator[](int row) { 40 | DataRow dr(*this, row); 41 | return dr; 42 | } 43 | 44 | private: 45 | std::unique_ptr _data; 46 | int _columns, _rows; 47 | }; 48 | -------------------------------------------------------------------------------- /Chapter10/PrimesCounter/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter10/PrimesCounter/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #endif //PCH_H 17 | -------------------------------------------------------------------------------- /Chapter10/SimpleDeadlock1/SimpleDeadlock1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | HANDLE hMutex1, hMutex2; 5 | 6 | DWORD WINAPI Thread1(PVOID) { 7 | printf("Thread1 %u\n", ::GetCurrentThreadId()); 8 | ::WaitForSingleObject(hMutex1, INFINITE); 9 | ::Sleep(1000); 10 | ::WaitForSingleObject(hMutex2, INFINITE); 11 | return 0; 12 | } 13 | 14 | DWORD WINAPI Thread2(PVOID) { 15 | printf("Thread2 %u\n", ::GetCurrentThreadId()); 16 | ::WaitForSingleObject(hMutex2, INFINITE); 17 | ::Sleep(1000); 18 | ::WaitForSingleObject(hMutex1, INFINITE); 19 | return 0; 20 | } 21 | 22 | int main() { 23 | hMutex1 = ::CreateMutex(nullptr, FALSE, L"SimpleDeadlockMutex1"); 24 | hMutex2 = ::CreateMutex(nullptr, FALSE, L"SimpleDeadlockMutex2"); 25 | 26 | HANDLE hThread[2]; 27 | hThread[0] = ::CreateThread(nullptr, 0, Thread1, nullptr, 0, nullptr); 28 | hThread[1] = ::CreateThread(nullptr, 0, Thread2, nullptr, 0, nullptr); 29 | 30 | printf("Waiting for threads to exit...\n"); 31 | ::WaitForMultipleObjects(2, hThread, TRUE, INFINITE); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Chapter10/SumMatrix/SumMatrix.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/SumMatrix/SumMatrix.cpp -------------------------------------------------------------------------------- /Chapter10/SumMatrix/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/SumMatrix/stdafx.cpp -------------------------------------------------------------------------------- /Chapter10/SumMatrix/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/SumMatrix/stdafx.h -------------------------------------------------------------------------------- /Chapter10/SumMatrix/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter10/SumMatrix/targetver.h -------------------------------------------------------------------------------- /Chapter10/breakin/breakin.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter10/thlist/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter10/thlist/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #endif //PCH_H 19 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy/BulkCopy.cpp: -------------------------------------------------------------------------------- 1 | // BulkCopy.cpp : main source file for BulkCopy.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | 8 | #include "MainDlg.h" 9 | 10 | CAppModule _Module; 11 | 12 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 13 | HRESULT hRes = ::CoInitialize(nullptr); 14 | ATLASSERT(SUCCEEDED(hRes)); 15 | 16 | AtlInitCommonControls(ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES); 17 | 18 | hRes = _Module.Init(nullptr, hInstance); 19 | ATLASSERT(SUCCEEDED(hRes)); 20 | 21 | CMessageLoop ml; 22 | _Module.AddMessageLoop(&ml); 23 | 24 | CMainDlg dlg; 25 | dlg.Create(nullptr); 26 | dlg.ShowWindow(SW_SHOW); 27 | 28 | int ret = ml.Run(); 29 | 30 | _Module.RemoveMessageLoop(); 31 | _Module.Term(); 32 | 33 | ::CoUninitialize(); 34 | 35 | return ret; 36 | } 37 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy/BulkCopy.h: -------------------------------------------------------------------------------- 1 | // BulkCopy.h 2 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy/res/bulkcopy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter11/BulkCopy/res/bulkcopy.ico -------------------------------------------------------------------------------- /Chapter11/BulkCopy/res/file.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter11/BulkCopy/res/file.ico -------------------------------------------------------------------------------- /Chapter11/BulkCopy/res/folder.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter11/BulkCopy/res/folder.ico -------------------------------------------------------------------------------- /Chapter11/BulkCopy/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by BulkCopy.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDI_FILE 202 8 | #define IDI_FOLDER 203 9 | #define IDC_LIST 1000 10 | #define IDC_ADDFILES 1001 11 | #define IDC_ADDDIR 1002 12 | #define IDC_SETDEST 1003 13 | #define IDC_REMOVE 1004 14 | #define IDC_GO 1005 15 | #define IDC_PROGRESS 1006 16 | 17 | // Next default values for new objects 18 | // 19 | #ifdef APSTUDIO_INVOKED 20 | #ifndef APSTUDIO_READONLY_SYMBOLS 21 | #define _APS_NEXT_RESOURCE_VALUE 204 22 | #define _APS_NEXT_COMMAND_VALUE 32777 23 | #define _APS_NEXT_CONTROL_VALUE 1007 24 | #define _APS_NEXT_SYMED_VALUE 101 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BulkCopy.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy2/BulkCopy.cpp: -------------------------------------------------------------------------------- 1 | // BulkCopy.cpp : main source file for BulkCopy.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | 8 | #include "MainDlg.h" 9 | 10 | CAppModule _Module; 11 | 12 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 13 | HRESULT hRes = ::CoInitialize(nullptr); 14 | ATLASSERT(SUCCEEDED(hRes)); 15 | 16 | AtlInitCommonControls(ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES); 17 | 18 | hRes = _Module.Init(nullptr, hInstance); 19 | ATLASSERT(SUCCEEDED(hRes)); 20 | 21 | CMessageLoop ml; 22 | _Module.AddMessageLoop(&ml); 23 | 24 | CMainDlg dlg; 25 | dlg.Create(nullptr); 26 | dlg.ShowWindow(SW_SHOW); 27 | 28 | int ret = ml.Run(); 29 | 30 | _Module.RemoveMessageLoop(); 31 | _Module.Term(); 32 | 33 | ::CoUninitialize(); 34 | 35 | return ret; 36 | } 37 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy2/BulkCopy.h: -------------------------------------------------------------------------------- 1 | // BulkCopy.h 2 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy2/res/bulkcopy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter11/BulkCopy2/res/bulkcopy.ico -------------------------------------------------------------------------------- /Chapter11/BulkCopy2/res/file.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter11/BulkCopy2/res/file.ico -------------------------------------------------------------------------------- /Chapter11/BulkCopy2/res/folder.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter11/BulkCopy2/res/folder.ico -------------------------------------------------------------------------------- /Chapter11/BulkCopy2/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by BulkCopy.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDI_FILE 202 8 | #define IDI_FOLDER 203 9 | #define IDC_LIST 1000 10 | #define IDC_ADDFILES 1001 11 | #define IDC_ADDDIR 1002 12 | #define IDC_SETDEST 1003 13 | #define IDC_REMOVE 1004 14 | #define IDC_GO 1005 15 | #define IDC_PROGRESS 1006 16 | 17 | // Next default values for new objects 18 | // 19 | #ifdef APSTUDIO_INVOKED 20 | #ifndef APSTUDIO_READONLY_SYMBOLS 21 | #define _APS_NEXT_RESOURCE_VALUE 204 22 | #define _APS_NEXT_COMMAND_VALUE 32777 23 | #define _APS_NEXT_CONTROL_VALUE 1007 24 | #define _APS_NEXT_SYMED_VALUE 101 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /Chapter11/BulkCopy2/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BulkCopy.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter11/DumpDrive/DumpDrive.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter11/EnumDevices/EnumDevices.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter11/SimpleRedirect/SimpleRedirect.cpp: -------------------------------------------------------------------------------- 1 | // SimpleRedirect.cpp : main source file for SimpleRedirect.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "MainDlg.h" 6 | 7 | CAppModule _Module; 8 | 9 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 10 | HRESULT hRes = ::CoInitialize(nullptr); 11 | ATLASSERT(SUCCEEDED(hRes)); 12 | 13 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 14 | 15 | hRes = _Module.Init(nullptr, hInstance); 16 | ATLASSERT(SUCCEEDED(hRes)); 17 | 18 | int nRet = 0; 19 | { 20 | CMainDlg dlgMain; 21 | nRet = (int)dlgMain.DoModal(); 22 | } 23 | 24 | _Module.Term(); 25 | ::CoUninitialize(); 26 | 27 | return nRet; 28 | } 29 | -------------------------------------------------------------------------------- /Chapter11/SimpleRedirect/SimpleRedirect.h: -------------------------------------------------------------------------------- 1 | // SimpleRedirect.h 2 | -------------------------------------------------------------------------------- /Chapter11/SimpleRedirect/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter11/SimpleRedirect/res/SimpleRedirect.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter11/SimpleRedirect/res/SimpleRedirect.ico -------------------------------------------------------------------------------- /Chapter11/SimpleRedirect/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SimpleRedirect.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_TEXT 1000 8 | #define IDC_REDIRECT 1001 9 | #define IDC_BUTTON1 1004 10 | #define IDC_CLEAR 1004 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 202 17 | #define _APS_NEXT_COMMAND_VALUE 32775 18 | #define _APS_NEXT_CONTROL_VALUE 1005 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /Chapter11/SimpleRedirect/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SimpleRedirect.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter11/symlinks/symlinks.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter12/SimpleShare/SimpleShare.cpp: -------------------------------------------------------------------------------- 1 | // SimpleShare.cpp : main source file for SimpleShare.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "MainDlg.h" 6 | 7 | CAppModule _Module; 8 | 9 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 10 | HRESULT hRes = ::CoInitialize(nullptr); 11 | ATLASSERT(SUCCEEDED(hRes)); 12 | 13 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 14 | 15 | hRes = _Module.Init(nullptr, hInstance); 16 | ATLASSERT(SUCCEEDED(hRes)); 17 | 18 | int nRet = 0; 19 | { 20 | CMainDlg dlgMain; 21 | nRet = (int)dlgMain.DoModal(); 22 | } 23 | 24 | _Module.Term(); 25 | ::CoUninitialize(); 26 | 27 | return nRet; 28 | } 29 | -------------------------------------------------------------------------------- /Chapter12/SimpleShare/SimpleShare.h: -------------------------------------------------------------------------------- 1 | // SimpleShare.h 2 | -------------------------------------------------------------------------------- /Chapter12/SimpleShare/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter12/SimpleShare/res/SimpleShare.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter12/SimpleShare/res/SimpleShare.ico -------------------------------------------------------------------------------- /Chapter12/SimpleShare/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by SimpleShare.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_VALUE 1000 8 | #define IDC_INC 1001 9 | #define IDC_RESET 1002 10 | #define IDC_ADDRESS 1003 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 202 17 | #define _APS_NEXT_COMMAND_VALUE 32775 18 | #define _APS_NEXT_CONTROL_VALUE 1004 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /Chapter12/SimpleShare/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SimpleShare.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter12/SimpleVMMap/SimpleVMMap.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter12/sysinfo/sysinfo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter13/MicroExcel/MicroExcel.cpp: -------------------------------------------------------------------------------- 1 | // MicroExcel.cpp : main source file for MicroExcel.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | 8 | #include "MainDlg.h" 9 | 10 | CAppModule _Module; 11 | 12 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 13 | HRESULT hRes = ::CoInitialize(nullptr); 14 | ATLASSERT(SUCCEEDED(hRes)); 15 | 16 | AtlInitCommonControls(ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES); 17 | 18 | hRes = _Module.Init(nullptr, hInstance); 19 | ATLASSERT(SUCCEEDED(hRes)); 20 | 21 | int nRet = 0; 22 | { 23 | CMainDlg dlgMain; 24 | nRet = (int)dlgMain.DoModal(); 25 | } 26 | 27 | _Module.Term(); 28 | ::CoUninitialize(); 29 | 30 | return nRet; 31 | } 32 | -------------------------------------------------------------------------------- /Chapter13/MicroExcel/MicroExcel.h: -------------------------------------------------------------------------------- 1 | // MicroExcel.h 2 | -------------------------------------------------------------------------------- /Chapter13/MicroExcel/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter13/MicroExcel/res/MicroExcel.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter13/MicroExcel/res/MicroExcel.ico -------------------------------------------------------------------------------- /Chapter13/MicroExcel/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MicroExcel.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter13/WorkingSets/SortHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "SortHelper.h" 3 | 4 | bool SortHelper::SortStrings(const CString& s1, const CString& s2, bool ascending) { 5 | return ascending ? s2.CompareNoCase(s1) > 0 : s2.CompareNoCase(s1) < 0; 6 | } 7 | 8 | bool SortHelper::SortStrings(PCWSTR s1, PCWSTR s2, bool ascending) { 9 | auto compare = ::_wcsicmp(s2, s1); 10 | return ascending ? compare > 0 : compare < 0; 11 | } 12 | 13 | bool SortHelper::SortBoolean(bool a, bool b, bool asc) { 14 | return asc ? b > a : a > b; 15 | } 16 | -------------------------------------------------------------------------------- /Chapter13/WorkingSets/SortHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SortHelper final abstract { 4 | static bool SortStrings(const ATL::CString& s1, const ATL::CString& s2, bool ascending); 5 | static bool SortStrings(PCWSTR s1, PCWSTR s2, bool ascending); 6 | static bool SortBoolean(bool a, bool b, bool asc); 7 | 8 | template 9 | static bool SortNumbers(const Number& n1, const Number& n2, bool ascending) { 10 | return ascending ? n2 > n1 : n2 < n1; 11 | } 12 | }; 13 | 14 | 15 | -------------------------------------------------------------------------------- /Chapter13/WorkingSets/WorkingSets.h: -------------------------------------------------------------------------------- 1 | // WorkingSets.h 2 | -------------------------------------------------------------------------------- /Chapter13/WorkingSets/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter13/WorkingSets/res/WorkingSets.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter13/WorkingSets/res/WorkingSets.ico -------------------------------------------------------------------------------- /Chapter13/WorkingSets/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by WorkingSets.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define ID_VIEW_REFRESH32775 32775 7 | #define ID_FILE_RUNASADMINISTRATOR 32776 8 | #define ID_VIEW_SHOWONLYACCESSIBLEPROCESSES 32777 9 | #define ID_HELP_ABOUTWORKINGSETS 32778 10 | #define ID_PROCESS_EMPTYWORKINGSET 32779 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 202 17 | #define _APS_NEXT_COMMAND_VALUE 32780 18 | #define _APS_NEXT_CONTROL_VALUE 1000 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /Chapter13/WorkingSets/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // WorkingSets.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter13/memwatch/memwatch.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter14/BasicSharing/BasicSharing.cpp: -------------------------------------------------------------------------------- 1 | // BasicSharing.cpp : main source file for BasicSharing.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | #include "MainDlg.h" 8 | 9 | CAppModule _Module; 10 | 11 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 12 | HRESULT hRes = ::CoInitialize(nullptr); 13 | ATLASSERT(SUCCEEDED(hRes)); 14 | 15 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 16 | 17 | hRes = _Module.Init(nullptr, hInstance); 18 | ATLASSERT(SUCCEEDED(hRes)); 19 | 20 | { 21 | CMainDlg dlgMain; 22 | dlgMain.DoModal(); 23 | } 24 | 25 | _Module.Term(); 26 | ::CoUninitialize(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter14/BasicSharing/BasicSharing.h: -------------------------------------------------------------------------------- 1 | // BasicSharing.h 2 | -------------------------------------------------------------------------------- /Chapter14/BasicSharing/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter14/BasicSharing/res/BasicSharing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter14/BasicSharing/res/BasicSharing.ico -------------------------------------------------------------------------------- /Chapter14/BasicSharing/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by BasicSharing.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_TEXT 1000 8 | #define IDC_WRITE 1001 9 | #define IDC_BUTTON2 1002 10 | #define IDC_READ 1002 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 202 17 | #define _APS_NEXT_COMMAND_VALUE 32775 18 | #define _APS_NEXT_CONTROL_VALUE 1003 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /Chapter14/BasicSharing/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BasicSharing.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter14/BasicSharingPlus/BasicSharing.h: -------------------------------------------------------------------------------- 1 | // BasicSharing.h 2 | -------------------------------------------------------------------------------- /Chapter14/BasicSharingPlus/BasicSharingPlus.cpp: -------------------------------------------------------------------------------- 1 | // BasicSharing.cpp : main source file for BasicSharing.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | #include "MainDlg.h" 8 | 9 | CAppModule _Module; 10 | 11 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 12 | HRESULT hRes = ::CoInitialize(nullptr); 13 | ATLASSERT(SUCCEEDED(hRes)); 14 | 15 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 16 | 17 | hRes = _Module.Init(nullptr, hInstance); 18 | ATLASSERT(SUCCEEDED(hRes)); 19 | 20 | { 21 | CMainDlg dlgMain; 22 | dlgMain.DoModal(); 23 | } 24 | 25 | _Module.Term(); 26 | ::CoUninitialize(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter14/BasicSharingPlus/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter14/BasicSharingPlus/res/BasicSharing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter14/BasicSharingPlus/res/BasicSharing.ico -------------------------------------------------------------------------------- /Chapter14/BasicSharingPlus/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by BasicSharingPlus.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_TEXT 1000 8 | #define IDC_WRITE 1001 9 | #define IDC_BUTTON2 1002 10 | #define IDC_READ 1002 11 | #define IDC_FILENAME 1003 12 | #define IDC_BUTTON1 1004 13 | #define IDC_CREATE 1004 14 | 15 | // Next default values for new objects 16 | // 17 | #ifdef APSTUDIO_INVOKED 18 | #ifndef APSTUDIO_READONLY_SYMBOLS 19 | #define _APS_NEXT_RESOURCE_VALUE 202 20 | #define _APS_NEXT_COMMAND_VALUE 32775 21 | #define _APS_NEXT_CONTROL_VALUE 1005 22 | #define _APS_NEXT_SYMED_VALUE 101 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /Chapter14/BasicSharingPlus/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BasicSharing.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter14/MicroExcel/MicroExcel.cpp: -------------------------------------------------------------------------------- 1 | // MicroExcel.cpp : main source file for MicroExcel.exe 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include "resource.h" 7 | 8 | #include "MainDlg.h" 9 | 10 | CAppModule _Module; 11 | 12 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) { 13 | HRESULT hRes = ::CoInitialize(nullptr); 14 | ATLASSERT(SUCCEEDED(hRes)); 15 | 16 | AtlInitCommonControls(ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES); 17 | 18 | hRes = _Module.Init(nullptr, hInstance); 19 | ATLASSERT(SUCCEEDED(hRes)); 20 | 21 | int nRet = 0; 22 | { 23 | CMainDlg dlgMain; 24 | nRet = (int)dlgMain.DoModal(); 25 | } 26 | 27 | _Module.Term(); 28 | ::CoUninitialize(); 29 | 30 | return nRet; 31 | } 32 | -------------------------------------------------------------------------------- /Chapter14/MicroExcel/MicroExcel.h: -------------------------------------------------------------------------------- 1 | // MicroExcel.h 2 | -------------------------------------------------------------------------------- /Chapter14/MicroExcel/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter14/MicroExcel/res/MicroExcel.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter14/MicroExcel/res/MicroExcel.ico -------------------------------------------------------------------------------- /Chapter14/MicroExcel/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MicroExcel.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter14/filehist/filehist.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter14/memview/memview.cpp: -------------------------------------------------------------------------------- 1 | // memview.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | #include 6 | 7 | int main() { 8 | HANDLE hMemMap = ::OpenFileMapping(FILE_MAP_READ, FALSE, L"MySharedMemory"); 9 | if (!hMemMap) { 10 | printf("File mapping object is not available\n"); 11 | return 1; 12 | } 13 | 14 | WCHAR text[1024] = { 0 }; 15 | auto data = (const WCHAR*)::MapViewOfFile(hMemMap, FILE_MAP_READ, 0, 0, 0); 16 | if (!data) { 17 | printf("Failed to map shared memory\n"); 18 | return 1; 19 | } 20 | 21 | for (;;) { 22 | if (::_wcsicmp(text, data) != 0) { 23 | // text changed, update and display 24 | ::wcscpy_s(text, data); 25 | printf("%ws\n", text); 26 | } 27 | ::Sleep(1000); 28 | } 29 | 30 | ::UnmapViewOfFile(data); 31 | ::CloseHandle(hMemMap); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Chapter14/memview/memview.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter15/BasicSharing/BasicSharing.h: -------------------------------------------------------------------------------- 1 | // BasicSharing.h 2 | -------------------------------------------------------------------------------- /Chapter15/BasicSharing/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter15/BasicSharing/res/BasicSharing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter15/BasicSharing/res/BasicSharing.ico -------------------------------------------------------------------------------- /Chapter15/BasicSharing/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by BasicSharing.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define IDD_MAINDLG 129 7 | #define IDC_TEXT 1000 8 | #define IDC_WRITE 1001 9 | #define IDC_BUTTON2 1002 10 | #define IDC_READ 1002 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 202 17 | #define _APS_NEXT_COMMAND_VALUE 32775 18 | #define _APS_NEXT_CONTROL_VALUE 1003 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /Chapter15/BasicSharing/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BasicSharing.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter15/HookDll/HookDll.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | EXPORTS 3 | SetNotificationThread 4 | HookFunction 5 | -------------------------------------------------------------------------------- /Chapter15/HookDll/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter15/HookDll/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | #include 12 | #include 13 | 14 | #endif //PCH_H 15 | -------------------------------------------------------------------------------- /Chapter15/HookInject/HookInject.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter15/IATHelper/IATHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct IATHelper final abstract { 4 | static int HookFunction(PCWSTR callerModule, PCSTR moduleName, PVOID originalProc, PVOID hookProc); 5 | static int HookAllModules(PCSTR moduleName, PVOID originalProc, PVOID hookProc); 6 | }; 7 | -------------------------------------------------------------------------------- /Chapter15/IATHelper/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter15/IATHelper/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | #include 12 | #include 13 | #include 14 | 15 | #endif //PCH_H 16 | -------------------------------------------------------------------------------- /Chapter15/Injected/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "pch.h" 3 | 4 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, PVOID lpReserved) { 5 | switch (reason) { 6 | case DLL_PROCESS_ATTACH: 7 | wchar_t text[128]; 8 | ::StringCchPrintf(text, _countof(text), L"Injected into process %u", ::GetCurrentProcessId()); 9 | ::MessageBox(nullptr, text, L"Injected.Dll", MB_OK); 10 | break; 11 | 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Chapter15/Injected/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter15/Injected/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | 13 | 14 | #endif //PCH_H 15 | -------------------------------------------------------------------------------- /Chapter15/Injector/Injector.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter15/SimpleDll/Simple.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Simple.h" 3 | #include 4 | 5 | bool __stdcall IsPrime(int n) { 6 | int limit = (int)::sqrt(n); 7 | for (int i = 2; i <= limit; i++) 8 | if (n % i == 0) 9 | return false; 10 | return true; 11 | } 12 | 13 | bool PrimeCalculator::IsPrime(int n) const { 14 | return ::IsPrime(n); 15 | } 16 | -------------------------------------------------------------------------------- /Chapter15/SimpleDll/Simple.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern "C" bool __stdcall IsPrime(int n); 4 | 5 | class __declspec(dllexport) PrimeCalculator { 6 | public: 7 | bool IsPrime(int n) const; 8 | }; 9 | -------------------------------------------------------------------------------- /Chapter15/SimpleDll/SimpleDll.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | EXPORTS 3 | IsPrime -------------------------------------------------------------------------------- /Chapter15/SimpleDll/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "pch.h" 3 | 4 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) { 5 | switch (reason) { 6 | case DLL_PROCESS_ATTACH: 7 | ::DisableThreadLibraryCalls(hModule); 8 | break; 9 | 10 | case DLL_THREAD_ATTACH: 11 | case DLL_THREAD_DETACH: 12 | case DLL_PROCESS_DETACH: 13 | break; 14 | } 15 | return TRUE; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Chapter15/SimpleDll/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 4 | // Windows Header Files 5 | #include 6 | -------------------------------------------------------------------------------- /Chapter15/SimpleDll/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter15/SimpleDll/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | 12 | #endif //PCH_H 13 | -------------------------------------------------------------------------------- /Chapter15/SimplePrimes/SimplePrimes.cpp: -------------------------------------------------------------------------------- 1 | 2 | // SimplePrimes.cpp : This file contains the 'main' function. Program execution begins and ends there. 3 | // 4 | 5 | #include 6 | #include 7 | #include "..\SimpleDll\Simple.h" 8 | 9 | //#ifdef _WIN64 10 | //#pragma comment(lib, "../x64/Debug/SimpleDll.lib") 11 | //#else 12 | //#pragma comment(lib, "../Debug/SimpleDll.lib") 13 | //#endif 14 | 15 | //using PIsPrime = bool (__stdcall *)(int); 16 | typedef bool(__stdcall* PIsPrime)(int); 17 | 18 | int main() { 19 | auto hPrimesLib = ::LoadLibrary(L"SimpleDll.dll"); 20 | if (hPrimesLib) { 21 | // DLL found 22 | auto IsPrime = (PIsPrime)::GetProcAddress(hPrimesLib, "IsPrime"); 23 | if (IsPrime) { 24 | bool test = IsPrime(17); 25 | printf("%d\n", (int)test); 26 | } 27 | 28 | } 29 | 30 | //bool test = IsPrime(17); 31 | //printf("%d\n", (int)test); 32 | 33 | //PrimeCalculator calc; 34 | //printf("123 prime? %s\n", calc.IsPrime(123) ? "Yes" : "No"); 35 | 36 | ::FreeLibrary(hPrimesLib); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /Chapter15/SimplePrimes2/SimplePrimes2.cpp: -------------------------------------------------------------------------------- 1 | // SimplePrimes2.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | #include 6 | 7 | #include "..\SimpleDll\Simple.h" 8 | #include 9 | 10 | bool IsLoaded() { 11 | auto hModule = ::GetModuleHandle(L"simpledll"); 12 | printf("SimpleDll loaded: %s\n", hModule ? "Yes" : "No"); 13 | return hModule != nullptr; 14 | } 15 | 16 | int main() { 17 | IsLoaded(); 18 | 19 | bool prime = IsPrime(17); 20 | 21 | IsLoaded(); 22 | 23 | printf("17 is prime? %s\n", prime ? "Yes" : "No"); 24 | __FUnloadDelayLoadedDLL2("SimpleDll.dll"); 25 | 26 | IsLoaded(); 27 | 28 | prime = IsPrime(1234567); 29 | 30 | IsLoaded(); 31 | 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Chapter15/WorkingSets/SortHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "SortHelper.h" 3 | 4 | bool SortHelper::SortStrings(const CString& s1, const CString& s2, bool ascending) { 5 | return ascending ? s2.CompareNoCase(s1) > 0 : s2.CompareNoCase(s1) < 0; 6 | } 7 | 8 | bool SortHelper::SortStrings(PCWSTR s1, PCWSTR s2, bool ascending) { 9 | auto compare = ::_wcsicmp(s2, s1); 10 | return ascending ? compare > 0 : compare < 0; 11 | } 12 | 13 | bool SortHelper::SortBoolean(bool a, bool b, bool asc) { 14 | return asc ? b > a : a > b; 15 | } 16 | -------------------------------------------------------------------------------- /Chapter15/WorkingSets/SortHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SortHelper final abstract { 4 | static bool SortStrings(const ATL::CString& s1, const ATL::CString& s2, bool ascending); 5 | static bool SortStrings(PCWSTR s1, PCWSTR s2, bool ascending); 6 | static bool SortBoolean(bool a, bool b, bool asc); 7 | 8 | template 9 | static bool SortNumbers(const Number& n1, const Number& n2, bool ascending) { 10 | return ascending ? n2 > n1 : n2 < n1; 11 | } 12 | }; 13 | 14 | 15 | -------------------------------------------------------------------------------- /Chapter15/WorkingSets/WorkingSets.h: -------------------------------------------------------------------------------- 1 | // WorkingSets.h 2 | -------------------------------------------------------------------------------- /Chapter15/WorkingSets/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter15/WorkingSets/res/WorkingSets.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter15/WorkingSets/res/WorkingSets.ico -------------------------------------------------------------------------------- /Chapter15/WorkingSets/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by WorkingSets.rc 4 | // 5 | #define IDR_MAINFRAME 128 6 | #define ID_VIEW_REFRESH32775 32775 7 | #define ID_FILE_RUNASADMINISTRATOR 32776 8 | #define ID_VIEW_SHOWONLYACCESSIBLEPROCESSES 32777 9 | #define ID_HELP_ABOUTWORKINGSETS 32778 10 | #define ID_PROCESS_EMPTYWORKINGSET 32779 11 | 12 | // Next default values for new objects 13 | // 14 | #ifdef APSTUDIO_INVOKED 15 | #ifndef APSTUDIO_READONLY_SYMBOLS 16 | #define _APS_NEXT_RESOURCE_VALUE 202 17 | #define _APS_NEXT_COMMAND_VALUE 32780 18 | #define _APS_NEXT_CONTROL_VALUE 1000 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /Chapter15/WorkingSets/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // WorkingSets.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Chapter16/cfgdemo/cfgdemo.cpp: -------------------------------------------------------------------------------- 1 | // cfgdemo.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | 6 | class A { 7 | public: 8 | virtual ~A() = default; 9 | virtual void DoWork(int x) { 10 | printf("A::DoWork %d\n", x); 11 | } 12 | }; 13 | 14 | class B : public A { 15 | public: 16 | void DoWork(int x) override { 17 | printf("B::DoWork %d\n", x); 18 | } 19 | }; 20 | 21 | 22 | int main() { 23 | A a; 24 | a.DoWork(10); 25 | B b; 26 | b.DoWork(20); 27 | 28 | A* pA = new B; 29 | pA->DoWork(30); 30 | 31 | delete pA; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Chapter16/cfgdemo/cfgdemo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter16/runas/runas.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter16/sd/sd.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter16/setvirt/setvirt.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter16/token/token.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter17/DumpKey/DumpKey.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter17/RegWatch/RegWatch.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter17/RegWatch2/TraceManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define INITGUID 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class TraceManager final { 11 | public: 12 | ~TraceManager(); 13 | 14 | bool Start(std::function callback); 15 | bool Stop(); 16 | 17 | private: 18 | void OnEventRecord(PEVENT_RECORD rec); 19 | DWORD Run(); 20 | 21 | private: 22 | TRACEHANDLE _handle{ 0 }; 23 | TRACEHANDLE _hTrace{ 0 }; 24 | EVENT_TRACE_PROPERTIES* _properties; 25 | std::unique_ptr _propertiesBuffer; 26 | EVENT_TRACE_LOGFILE _traceLog = { 0 }; 27 | wil::unique_handle _hProcessThread; 28 | std::function _callback; 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /Chapter17/RegWatch2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter18/TestLog/TestLog.cpp: -------------------------------------------------------------------------------- 1 | // TestLog.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | #include 6 | 7 | int Error(const char* msg, DWORD error = ::GetLastError()) { 8 | printf("%s (%u)\n", msg, error); 9 | return 1; 10 | } 11 | 12 | int main() { 13 | HANDLE hFile = ::CreateFile(L"\\\\.\\mailslot\\loggerbox", GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr); 14 | if (hFile == INVALID_HANDLE_VALUE) 15 | return Error("Failed to open mailslot"); 16 | 17 | DWORD written; 18 | char text[256]; 19 | do { 20 | printf("Enter message (q to quit): "); 21 | gets_s(text); 22 | if (_stricmp(text, "q") == 0) 23 | break; 24 | } while (::WriteFile(hFile, text, (DWORD)strlen(text) + 1, &written, nullptr)); 25 | 26 | ::CloseHandle(hFile); 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Chapter18/TestLog/TestLog.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter19/AlarmSvc/AlarmCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class MessageType { 4 | SetAlarm, 5 | CancelAlarm, 6 | }; 7 | 8 | struct AlarmMessage { 9 | MessageType Type; 10 | FILETIME Time; 11 | }; 12 | -------------------------------------------------------------------------------- /Chapter19/AlarmSvc/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter19/AlarmSvc/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #endif //PCH_H 17 | -------------------------------------------------------------------------------- /Chapter19/GenSvc/FileLogger.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "FileLogger.h" 3 | 4 | FileLogger::FileLogger(const wchar_t* filename) { 5 | _hFile = ::CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, 0, nullptr); 6 | } 7 | 8 | FileLogger::~FileLogger() { 9 | if (_hFile != INVALID_HANDLE_VALUE) 10 | ::CloseHandle(_hFile); 11 | } 12 | 13 | void FileLogger::DoWrite(const wchar_t* buffer) { 14 | std::lock_guard locker(_lock); 15 | ::SetFilePointer(_hFile, 0, nullptr, FILE_END); 16 | DWORD bytes; 17 | ::WriteFile(_hFile, buffer, DWORD(::wcslen(buffer) * sizeof(WCHAR)), &bytes, nullptr); 18 | } 19 | -------------------------------------------------------------------------------- /Chapter19/GenSvc/FileLogger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Logger.h" 4 | #include 5 | 6 | class FileLogger : public Logger { 7 | public: 8 | explicit FileLogger(const wchar_t* filename); 9 | ~FileLogger(); 10 | 11 | operator bool() const { 12 | return _hFile != INVALID_HANDLE_VALUE; 13 | } 14 | 15 | void DoWrite(const wchar_t* buffer); 16 | 17 | private: 18 | HANDLE _hFile; 19 | std::mutex _lock; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /Chapter19/GenSvc/Logger.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Logger.h" 3 | 4 | -------------------------------------------------------------------------------- /Chapter19/GenSvc/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /Chapter19/GenSvc/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /Chapter19/alarm/alarm.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter19/enumsvc/enumsvc.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter19/svcpriv/svcpriv.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter20/EtwMeta/EtwMeta.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter20/MD5Calc/HashCache.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "HashCache.h" 3 | 4 | HashCache::HashCache() { 5 | _cache.reserve(512); 6 | } 7 | 8 | bool HashCache::Add(PCWSTR path, const Hash& hash) { 9 | auto it = _cache.find(path); 10 | if (it == _cache.end()) { 11 | _cache.insert({ path, hash }); 12 | return true; 13 | } 14 | return false; 15 | } 16 | 17 | const Hash HashCache::Get(PCWSTR path) const { 18 | auto it = _cache.find(path); 19 | return it == _cache.end() ? Hash() : it->second; 20 | } 21 | 22 | bool HashCache::Remove(PCWSTR path) { 23 | auto it = _cache.find(path); 24 | if (it != _cache.end()) { 25 | _cache.erase(it); 26 | return true; 27 | } 28 | return false; 29 | } 30 | 31 | void HashCache::Clear() { 32 | _cache.clear(); 33 | } 34 | -------------------------------------------------------------------------------- /Chapter20/MD5Calc/HashCache.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | using Hash = std::vector; 4 | 5 | #include 6 | 7 | class HashCache { 8 | public: 9 | HashCache(); 10 | 11 | bool Add(PCWSTR path, const Hash& hash); 12 | const Hash Get(PCWSTR path) const; 13 | bool Remove(PCWSTR path); 14 | void Clear(); 15 | 16 | private: 17 | std::unordered_map _cache; 18 | }; 19 | 20 | 21 | -------------------------------------------------------------------------------- /Chapter20/MD5Calc/MD5Calculator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class MD5Calculator { 4 | public: 5 | static std::vector Calculate(PCWSTR path); 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /Chapter20/MD5Calc/ProcessManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ProcessManager { 6 | public: 7 | ProcessManager(); 8 | 9 | bool Refresh(); 10 | const std::vector& GetNewProcesses(); 11 | 12 | std::vector EnumModules(DWORD pid) const; 13 | 14 | private: 15 | std::unordered_set _pids; 16 | std::vector _newPids; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /Chapter20/MD5Calc/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter20/MD5Calc/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter20/MD5Calc/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #endif //PCH_H 23 | -------------------------------------------------------------------------------- /Chapter20/ParseETW/ParseETW.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter20/QSlice/ProcessManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "PerfCountersQuery.h" 5 | 6 | struct ProcessInfo { 7 | DWORD Pid; 8 | std::wstring Name; 9 | std::wstring PerfCounterPath; 10 | double CPU; 11 | int CounterIndex; 12 | }; 13 | 14 | class ProcessManager { 15 | public: 16 | std::vector> EnumProcesses(); 17 | void Update(); 18 | 19 | const std::vector>& GetProcesses() const; 20 | 21 | private: 22 | PerfCountersQuery _cpuQuery; 23 | std::vector> _processes; 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /Chapter20/QSlice/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter20/QSlice/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /Chapter20/QSlice/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | -------------------------------------------------------------------------------- /Chapter20/RunETW/RunETW.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter20/RunETW2/RunETW2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter20/snapproc/snapproc.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter21/BitsDemo/JobNotifications.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct JobNotifications : IBackgroundCopyCallback { 6 | explicit JobNotifications(HANDLE hEvent = nullptr); 7 | 8 | virtual HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override; 9 | virtual ULONG __stdcall AddRef(void) override; 10 | virtual ULONG __stdcall Release(void) override; 11 | virtual HRESULT __stdcall JobTransferred(IBackgroundCopyJob* pJob) override; 12 | virtual HRESULT __stdcall JobError(IBackgroundCopyJob* pJob, IBackgroundCopyError* pError) override; 13 | virtual HRESULT __stdcall JobModification(IBackgroundCopyJob* pJob, DWORD dwReserved) override; 14 | 15 | private: 16 | ULONG _refCount{ 0 }; 17 | HANDLE _hEvent; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /Chapter21/BitsDemoCS/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter21/BitsDemoCS/bits.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Chapter21/BitsDemoCS/bits.dll -------------------------------------------------------------------------------- /Chapter21/CalcCS/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter21/CalcCS/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace CalcCS { 5 | [ComImport, Guid("7020B8D9-CEFE-46DC-89D7-F0261C3CDE66")] 6 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | interface IRPNCalculator { 8 | void Push(double value); 9 | double Pop(); 10 | void Add(); 11 | void Subtract(); 12 | }; 13 | 14 | [ComImport, Guid("FA523D4E-DB35-4D0B-BD0A-002281FE3F31")] 15 | class RPNCalculator { } 16 | 17 | static class Program { 18 | [STAThread] 19 | static void Main(string[] args) { 20 | IRPNCalculator calc = (IRPNCalculator)new RPNCalculator(); 21 | calc.Push(10); 22 | calc.Push(20); 23 | calc.Add(); 24 | Console.WriteLine(calc.Pop()); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter21/Calculator/Calculator.cpp: -------------------------------------------------------------------------------- 1 | // Calculator.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | #include 6 | #include 7 | #include "..\RPNCalcSvr\RPNCalcInterfaces.h" 8 | 9 | int main() { 10 | ::CoInitialize(nullptr); 11 | 12 | { 13 | CComPtr spCalc; 14 | auto hr = spCalc.CoCreateInstance(__uuidof(RPNCalculator)); 15 | if (SUCCEEDED(hr)) { 16 | spCalc->Push(10); 17 | spCalc->Push(6); 18 | spCalc->Push(12); 19 | spCalc->Add(); 20 | double result; 21 | spCalc->Pop(&result); 22 | printf("Value popped: %lf\n", result); 23 | spCalc->Push(result); 24 | spCalc->Subtract(); 25 | spCalc->Pop(&result); 26 | printf("Value popped: %lf\n", result); 27 | } 28 | } 29 | 30 | ::CoUninitialize(); 31 | 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Chapter21/RPNCalcSvr/RPNCalcInterfaces.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct __declspec(uuid("7020B8D9-CEFE-46DC-89D7-F0261C3CDE66")) IRPNCalculator : IUnknown { 4 | virtual HRESULT __stdcall Push(double value) = 0; 5 | virtual HRESULT __stdcall Pop(double* value) = 0; 6 | virtual HRESULT __stdcall Add() = 0; 7 | virtual HRESULT __stdcall Subtract() = 0; 8 | }; 9 | 10 | // {7020B8D9-CEFE-46DC-89D7-F0261C3CDE66} 11 | DEFINE_GUID(IID_IRPNCalculator, 12 | 0x7020b8d9, 0xcefe, 0x46dc, 0x89, 0xd7, 0xf0, 0x26, 0x1c, 0x3c, 0xde, 0x66); 13 | 14 | // {FA523D4E-DB35-4D0B-BD0A-002281FE3F31} 15 | DEFINE_GUID(CLSID_RPNCalculator, 16 | 0xfa523d4e, 0xdb35, 0x4d0b, 0xbd, 0xa, 0x0, 0x22, 0x81, 0xfe, 0x3f, 0x31); 17 | 18 | class __declspec(uuid("FA523D4E-DB35-4D0B-BD0A-002281FE3F31")) RPNCalculator; 19 | -------------------------------------------------------------------------------- /Chapter21/RPNCalcSvr/RPNCalcSvr.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | EXPORTS 3 | DllGetClassObject PRIVATE 4 | DllRegisterServer PRIVATE 5 | DllUnregisterServer PRIVATE 6 | -------------------------------------------------------------------------------- /Chapter21/RPNCalcSvr/RPNCalculator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "RPNCalcInterfaces.h" 5 | 6 | class RPNCalculator : public IRPNCalculator { 7 | public: 8 | // from IUnknown 9 | virtual HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override; 10 | virtual ULONG __stdcall AddRef(void) override; 11 | virtual ULONG __stdcall Release(void) override; 12 | // from IRPNCalculator 13 | virtual HRESULT __stdcall Push(double value) override; 14 | virtual HRESULT __stdcall Pop(double* value) override; 15 | virtual HRESULT __stdcall Add() override; 16 | virtual HRESULT __stdcall Subtract() override; 17 | 18 | private: 19 | ULONG _refCount{ 1 }; 20 | std::stack _data; 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /Chapter21/RPNCalcSvr/RPNCalculatorFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct RPNCalculatorFactory : IClassFactory { 4 | // methods from IUnknown 5 | virtual HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override; 6 | virtual ULONG __stdcall AddRef(void) override; 7 | virtual ULONG __stdcall Release(void) override; 8 | // methods from IClassFactory 9 | virtual HRESULT __stdcall CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppvObject) override; 10 | virtual HRESULT __stdcall LockServer(BOOL fLock) override; 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /Chapter21/RPNCalcSvr/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter21/RPNCalcSvr/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | #include 12 | #include 13 | 14 | #endif //PCH_H 15 | -------------------------------------------------------------------------------- /Chapter22/AppList/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Chapter22/AppList/main.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | using namespace winrt; 4 | using namespace Windows::Foundation; 5 | using namespace Windows::Management::Deployment; 6 | 7 | int main() { 8 | init_apartment(); 9 | 10 | PackageManager pm; 11 | auto packages = pm.FindPackagesForUser(L""); 12 | int count = 0; 13 | for (auto package : packages) { 14 | if (package.IsFramework() || package.IsResourcePackage() || package.IsBundle()) 15 | continue; 16 | 17 | count++; 18 | printf("%-40ws (%ws) %ws\n", 19 | package.DisplayName().c_str(), 20 | package.Id().FullName().c_str(), 21 | package.Description().c_str()); 22 | } 23 | printf("%d packages found.\n", count); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Chapter22/AppList/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter22/AppList/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /Chapter22/AppList/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /Chapter22/DateTime/DateTime.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Chapter22/DateTime2/DateTime2.cpp: -------------------------------------------------------------------------------- 1 | // DateTime2.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include "pch.h" 5 | 6 | using namespace winrt::Windows::Foundation; 7 | using namespace winrt::Windows::Globalization; 8 | 9 | int main() { 10 | winrt::init_apartment(); 11 | 12 | { 13 | Calendar calendar; 14 | calendar.SetToNow(); 15 | printf("The time is %02d:%02d:%02d\n", 16 | calendar.Hour(), calendar.Minute(), calendar.Second()); 17 | printf("Time zone: %ws\n", calendar.TimeZoneAsString().c_str()); 18 | } 19 | winrt::uninit_apartment(); 20 | } 21 | -------------------------------------------------------------------------------- /Chapter22/DateTime2/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter22/DateTime2/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter22/DateTime2/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #endif //PCH_H 15 | -------------------------------------------------------------------------------- /Chapter22/NetworkInfo/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Chapter22/NetworkInfo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter22/NetworkInfo/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /Chapter22/NetworkInfo/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | -------------------------------------------------------------------------------- /Chapter22/NetworkInfoRaw/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /Chapter22/NetworkInfoRaw/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #endif //PCH_H 19 | -------------------------------------------------------------------------------- /Chapter23/SEHDemo/SEHDemo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Cover2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/Win10SysProgBookSamples/9f2d1bb61a24fee4e08ec46738680e44f6c132de/Cover2.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Windows 10 System Programming book samples 2 | 3 | The book is available here: https://leanpub.com/windows10systemprogramming and on [Amazon](https://www.amazon.com/gp/product/B086Y6M7LH/) 4 | 5 | ![](https://github.com/zodiacon/Win10SysProgBookSamples/blob/master/Cover2.png) 6 | --------------------------------------------------------------------------------