diff --git a/.gitattributes b/.gitattributes index 8aa99bd1f..54643ca82 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,10 +3,11 @@ # Declare files that will always have CRLF line endings on checkout. *.bat eol=crlf -hosts_tools/HostsToolforWindows/*.cpp eol=crlf -hosts_tools/HostsToolforWindows/*.hpp eol=crlf +tools/WinConsole/*.cpp eol=crlf +tools/WinConsole/*.hpp eol=crlf # Denote all files that are truly binary and should not be modified. *.png binary *.jpg binary *.gif binary +*.lib binary diff --git a/hosts_tools/HostsTool/README.MD b/hosts_tools/HostsTool/README.MD deleted file mode 100644 index 308eb0dcf..000000000 --- a/hosts_tools/HostsTool/README.MD +++ /dev/null @@ -1,4 +0,0 @@ -HostsTool是Windows平台下的一个简易桌面应用,它允许你通过简单的操作获取到最新的hosts更新。 - -![http://i13.tietuku.com/0de7fd3c2bedb5ec.png](http://i13.tietuku.com/0de7fd3c2bedb5ec.png) -![http://i13.tietuku.com/efb3a907553a9ee5.png](http://i13.tietuku.com/efb3a907553a9ee5.png) diff --git a/hosts_tools/README.md b/hosts_tools/README.md deleted file mode 100644 index 2b321fb03..000000000 --- a/hosts_tools/README.md +++ /dev/null @@ -1,28 +0,0 @@ -我们提供了一系列工具让您除了手动以 复制/粘贴 的方式部署和更新 hosts 之外,有一种方便、一键式的方式来应用我们的 hosts 。 - -我们现有的工具可以在下列平台上工作: - -- Microsoft Windows (`.bat` script; Qt GUI tool; console (service type) tool) - -- GNU Linux (bash script) - -另外,我们还推荐使用跨平台的 [**Hozz**](http://ppoffice.github.io/Hozz) 来管理、自动更新 hosts 。 - ------------------------------------ - -目前,我们共有: - -- Hozz: 跨平台的 hosts 自动 管理/更新 工具。是 @ppoffice 的项目。 - - - [项目主页](http://ppoffice.github.io/Hozz) - - [项目Github主页](https://github.com/ppoffice/Hozz) - -- HostTool: Windows 环境下的 hosts 自动更新应用,使用 **C++** 构建, GUI 基于 **Qt** 。由 @racaljk 贡献。 - -- HostToolforMac: Mac 环境下的 hosts 自动部署更新应用(适用于 OS X 10.10 或以上),基于 Swift 开发。由 @ZzzM 贡献。 - -- HostsToolforWindows: Windows console环境下的 hosts 自动更新应用(作为系统服务),使用 **C++** 构建。由 @Too-Naive 贡献。 - -- [`script_tool_for_windows.bat`](http://keving.pythonanywhere.com/hosts_scripts/script_tool_for_windows.bat): Windows 环境下的 hosts 一键部署脚本,由 @redapple0204 与 @lizongzeshunshun 贡献。以及 @lideming 提供的重要更新。 - -- [`script_tool_for_linux.bash`](http://keving.pythonanywhere.com/hosts_scripts/script_tool_for_linux.sh): Linux 环境下的 hosts 一键部署脚本,由 @lstoars 贡献; @fluviusmagnus 提供增强版本。 diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftAppKit.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftAppKit.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftAppKit.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftAppKit.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftCore.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftCore.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftCore.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftCore.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftCoreData.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftCoreData.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftCoreData.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftCoreData.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftCoreGraphics.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftCoreGraphics.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftCoreGraphics.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftCoreGraphics.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftCoreImage.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftCoreImage.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftCoreImage.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftCoreImage.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftDarwin.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftDarwin.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftDarwin.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftDarwin.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftDispatch.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftDispatch.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftDispatch.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftDispatch.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftFoundation.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftFoundation.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftFoundation.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftFoundation.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftObjectiveC.dylib b/tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftObjectiveC.dylib old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Frameworks/libswiftObjectiveC.dylib rename to tools/MacOS/HostsTool.app/Contents/Frameworks/libswiftObjectiveC.dylib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Info.plist b/tools/MacOS/HostsTool.app/Contents/Info.plist similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Info.plist rename to tools/MacOS/HostsTool.app/Contents/Info.plist diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/MacOS/HostsTool b/tools/MacOS/HostsTool.app/Contents/MacOS/HostsTool old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/MacOS/HostsTool rename to tools/MacOS/HostsTool.app/Contents/MacOS/HostsTool diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/PkgInfo b/tools/MacOS/HostsTool.app/Contents/PkgInfo similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/PkgInfo rename to tools/MacOS/HostsTool.app/Contents/PkgInfo diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/AppIcon.icns b/tools/MacOS/HostsTool.app/Contents/Resources/AppIcon.icns similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/AppIcon.icns rename to tools/MacOS/HostsTool.app/Contents/Resources/AppIcon.icns diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist b/tools/MacOS/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist rename to tools/MacOS/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/Info.plist diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib b/tools/MacOS/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib rename to tools/MacOS/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/MainMenu.nib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/NSViewController-XfG-lQ-9wD.nib b/tools/MacOS/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/NSViewController-XfG-lQ-9wD.nib similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/NSViewController-XfG-lQ-9wD.nib rename to tools/MacOS/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/NSViewController-XfG-lQ-9wD.nib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib b/tools/MacOS/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib rename to tools/MacOS/HostsTool.app/Contents/Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib diff --git a/hosts_tools/HostsToolforMac/HostsTool.app/Contents/_CodeSignature/CodeResources b/tools/MacOS/HostsTool.app/Contents/_CodeSignature/CodeResources similarity index 100% rename from hosts_tools/HostsToolforMac/HostsTool.app/Contents/_CodeSignature/CodeResources rename to tools/MacOS/HostsTool.app/Contents/_CodeSignature/CodeResources diff --git a/hosts_tools/HostsToolforMac/Preview/automatic.gif b/tools/MacOS/Preview/automatic.gif similarity index 100% rename from hosts_tools/HostsToolforMac/Preview/automatic.gif rename to tools/MacOS/Preview/automatic.gif diff --git a/hosts_tools/HostsToolforMac/Preview/manual.gif b/tools/MacOS/Preview/manual.gif similarity index 100% rename from hosts_tools/HostsToolforMac/Preview/manual.gif rename to tools/MacOS/Preview/manual.gif diff --git a/hosts_tools/HostsToolforMac/README.md b/tools/MacOS/README.md similarity index 99% rename from hosts_tools/HostsToolforMac/README.md rename to tools/MacOS/README.md index ceda1095c..7d9d9cbcf 100644 --- a/hosts_tools/HostsToolforMac/README.md +++ b/tools/MacOS/README.md @@ -10,4 +10,3 @@ HostsToolforMac(https://github.com/ZzzM/HostToolforMac) 是Mac平台下的 ![image](https://github.com/ZzzM/hosts/blob/master/hosts_tools/HostsToolforMac/Preview/manual.gif) ####自动更新: ![image](https://github.com/ZzzM/hosts/blob/master/hosts_tools/HostsToolforMac/Preview/automatic.gif) - diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 000000000..19bb4c370 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,31 @@ +# Hosts Tool Pool + +我们提供了一系列工具让您除了手动以 复制/粘贴 的方式部署和更新 hosts 之外,有一种方便、一键式的方式来应用我们的 hosts 。 + +## 支持的平台 + +- Microsoft Windows (`.bat` script; Qt GUI tool; console tool) +- GNU Linux (bash script) +- 跨平台的 [**Hozz**](http://ppoffice.github.io/Hozz) + +## 现有的自动更新Hosts工具(粗体字为文件夹名) + + - **WinGUI** : Windows环境下的GUI工具 + - 使用 **C++** 构建, GUI 基于 **Qt** 。由 [@racaljk](https://github.com/racaljk) 贡献 + + - **WinConsole** : Windows环境下的Console工具 + - 使用 **C++** 构建。由 [@Too-Naive](https://github.com/Too-Naive) 贡献 + + - **MacOS** : Mac 环境下的 hosts 自动部署更新应用(适用于 OS X 10.10 或以上) + - 基于 Swift 开发。由 [@ZzzM](https://github.com/ZzzM) 贡献。 + + - **Script**: 集合了各种系统下的脚本工具。 + - [`script_tool_for_windows.bat`](http://keving.pythonanywhere.com/hosts_scripts/script_tool_for_windows.bat): Windows 环境下的 hosts 一键部署脚本,由 [@redapple0204](https://github.com/redapple0204) 与 [@lizongzeshunshun](https://github.com/lizongzeshunshun) 贡献。以及 [@lideming](https://github.com/lideming) 提供的重要更新。 + + - [`script_tool_for_linux.bash`](http://keving.pythonanywhere.com/hosts_scripts/script_tool_for_linux.sh): Linux 环境下的 hosts 一键部署脚本,由 [@lstoars](https://github.com/lstoars) 贡献; [@fluviusmagnus](https://github.com/fluviusmagnus) 提供增强版本。 + +## 其他工具 + +- Hozz: 跨平台的 hosts 自动 管理/更新 工具。是 [@ppoffice](https://github.com/ppoffice) 的项目。 + - [项目主页](http://ppoffice.github.io/Hozz) + - [项目Github主页](https://github.com/ppoffice/Hozz) diff --git a/hosts_tools/HostsToolforWindows/MSVS/.gitignore b/tools/WinConsole/MSVS/.gitignore similarity index 99% rename from hosts_tools/HostsToolforWindows/MSVS/.gitignore rename to tools/WinConsole/MSVS/.gitignore index 78b49ee60..5663b359b 100644 --- a/hosts_tools/HostsToolforWindows/MSVS/.gitignore +++ b/tools/WinConsole/MSVS/.gitignore @@ -126,7 +126,7 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings +# TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj diff --git a/hosts_tools/HostsToolforWindows/MSVS/VS2013/HostsToolforWindows.sln b/tools/WinConsole/MSVS/VS2013/HostsToolforWindows.sln similarity index 100% rename from hosts_tools/HostsToolforWindows/MSVS/VS2013/HostsToolforWindows.sln rename to tools/WinConsole/MSVS/VS2013/HostsToolforWindows.sln diff --git a/hosts_tools/HostsToolforWindows/MSVS/VS2013/HostsToolforWindows.vcxproj b/tools/WinConsole/MSVS/VS2013/HostsToolforWindows.vcxproj similarity index 100% rename from hosts_tools/HostsToolforWindows/MSVS/VS2013/HostsToolforWindows.vcxproj rename to tools/WinConsole/MSVS/VS2013/HostsToolforWindows.vcxproj diff --git a/hosts_tools/HostsToolforWindows/MSVS/VS2013/HostsToolforWindows.vcxproj.filters b/tools/WinConsole/MSVS/VS2013/HostsToolforWindows.vcxproj.filters similarity index 100% rename from hosts_tools/HostsToolforWindows/MSVS/VS2013/HostsToolforWindows.vcxproj.filters rename to tools/WinConsole/MSVS/VS2013/HostsToolforWindows.vcxproj.filters diff --git a/hosts_tools/HostsToolforWindows/README.md b/tools/WinConsole/README.md similarity index 64% rename from hosts_tools/HostsToolforWindows/README.md rename to tools/WinConsole/README.md index e011f7fd6..442b85bdf 100644 --- a/hosts_tools/HostsToolforWindows/README.md +++ b/tools/WinConsole/README.md @@ -1,6 +1,15 @@ # Download Executable File -Download address:[hosts_tool.exe](https://git.io/vVSwE) [Mirror address](https://yunpan.cn/cq4amgJfUZwTM)(code:b9b1) +#### Download address: +- [hosts_tool.exe](https://git.io/vVSwE) +- [Mirror address](https://yunpan.cn/cq4amgJfUZwTM)(code:b9b1) + +OS type | Minimun Supported Version +--------|------------------- +WorkStation | Microsoft Windows XP Family +Server | Microsoft Windows Server 2003 Family + +>If you choose `Download`, It means you agreed the MIT license(redefined). #### Minimum Supported Operator System: - Client : Microsoft Windows XP Family @@ -8,7 +17,9 @@ Download address:[hosts_tool.exe](https://git.io/vVSwE) [Mirror address](https:/ # Hosts Tool -这个工具可以帮助你全自动的更换 备份原来的hosts文件 所有麻烦的事情只需要打开一个程序就能搞定 并且程序还可以作为服务安装随系统启动 每次开机后都每30分钟会自动检测hosts文件的更新噢 +这个工具可以帮助你全自动的更换 备份原来的hosts文件 所有麻烦的事情只需要打开一个程序就能搞定 如果你愿意,程序还可以作为服务安装随系统启动 每次开机后每隔30分钟会自动检测hosts文件的更新噢 + +**在此特别感谢[@qwerty258](https://githbu.com/qwerty258)为本程序提供了Visual Studio的工程文件** ## How to use? @@ -22,15 +33,15 @@ main program file: `hosts_tool.exe` ## 注意事项 -如果安装服务 程序会往`%SystemRoot%`下复制一个`hosts_tool.exe`文件用来作为服务启动的主程序 +1.如果安装服务 程序会往`%SystemRoot%`下复制一个`hosts_tool.exe`文件用来作为服务启动的主程序 -安装服务后 日志文件会保存在`C:\Hosts_Tool_log.log`下 您可以通过查看日志观察服务的工作状态 +2.安装服务后 日志文件会保存在`C:\Hosts_Tool_log.log`下 您可以通过查看日志观察服务的工作状态 -卸载服务请使用原来的`hosts_tool.exe`文件 请不要在命令行中直接执行`hosts_tool -fu`(如执行 需要手动删除`%SystemRoot%`目录下的`hoststools.exe`) +3.卸载服务请使用原来的`hosts_tool.exe`文件 请不要在命令行中直接执行`hosts_tool -fu`(如执行 需要手动删除`%SystemRoot%`目录下的`hoststools.exe`) -请间隔一段时间后清理`%SystemRoot%\system32\drivers\etc\`文件夹 (因为可能堆满了备份的文件) +4.请间隔一段时间后清理`%SystemRoot%\system32\drivers\etc\`文件夹 (因为可能堆满了备份的文件) -Bug Report: 请开新的issue并`@Too-Naive`或者发邮件给 sweheartiii[at]hotmail.com (请记得带上日志文件) +5.Bug Report: 请开新的issue并`@Too-Naive`或者发邮件给 sweheartiii[at]hotmail.com (请记得带上日志文件) ## for Developer @@ -44,6 +55,8 @@ Bug Report: 请开新的issue并`@Too-Naive`或者发邮件给 sweheartiii[at]ho >THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +>If you use the project's source code or its derivative products (including but not limited to the executable file), it means that you have agreed to the terms of this license and comply with the terms of the license. If you do not agree to this license agreement, please do not use this project's source code and its derivatives (including but not limited to the executable file). + ### Service Debug Mode : If you want to enter debug mode, follow the steps blow. diff --git a/hosts_tools/HostsToolforWindows/diff.hpp b/tools/WinConsole/diff.hpp similarity index 93% rename from hosts_tools/HostsToolforWindows/diff.hpp rename to tools/WinConsole/diff.hpp index d6650b710..8c2a7be9b 100644 --- a/hosts_tools/HostsToolforWindows/diff.hpp +++ b/tools/WinConsole/diff.hpp @@ -34,11 +34,11 @@ bool Func_CheckDiff(const TCHAR *lFilePath, const TCHAR * rFilePath) throw(){ return false; char *lBuffer = new char[BUFFER_SIZE]; char *rBuffer = new char[BUFFER_SIZE]; - if (!lBuffer||!rBuffer) + if (!lBuffer||!rBuffer) _tprintf(_T("Can't allocate memory to buffer in Func_diff\n")),abort(); do { - fread(lBuffer,sizeof(char),BUFFER_SIZE,lFile); - fread(rBuffer,sizeof(char),BUFFER_SIZE,rFile); + fread(lBuffer,sizeof(char),BUFFER_SIZE,lFile); + fread(rBuffer,sizeof(char),BUFFER_SIZE,rFile); if (memcmp(lBuffer, rBuffer, BUFFER_SIZE)|| ((!feof(lFile)&&feof(rFile))||(feof(lFile)&&!(feof(rFile))))){ delete[] lBuffer; diff --git a/hosts_tools/HostsToolforWindows/download.hpp b/tools/WinConsole/download.hpp similarity index 100% rename from hosts_tools/HostsToolforWindows/download.hpp rename to tools/WinConsole/download.hpp diff --git a/hosts_tools/HostsToolforWindows/hosts_tool.cpp b/tools/WinConsole/hosts_tool.cpp similarity index 98% rename from hosts_tools/HostsToolforWindows/hosts_tool.cpp rename to tools/WinConsole/hosts_tool.cpp index 4d10cc92b..6b2d77f56 100644 --- a/hosts_tools/HostsToolforWindows/hosts_tool.cpp +++ b/tools/WinConsole/hosts_tool.cpp @@ -66,8 +66,8 @@ struct expection{ #define PIPE_TIMEOUT 5000 #define BUFSIZE 4096 -typedef struct -{ +typedef struct +{ OVERLAPPED oOverlap; HANDLE hPipeInst; TCHAR chRequest[BUFSIZE]; @@ -437,7 +437,7 @@ void Func_Service_Install(bool _q){ THROWERR(_T("GetEnvironmentVariable() Error in Install Service.")); _stprintf(buf1,_T("%s\\hoststools.exe"),buf3); _stprintf(buf2,_T("\"%s\\hoststools.exe\" -svc"),buf3); - if (request_client) + if (request_client) _stprintf(szline,_T("%s %s"),buf2,szParameters[11]), _tcscpy(buf2,szline),memset(szline,0,sizeof(szline)/sizeof(TCHAR)); if (!GetModuleFileName(NULL,szline,sizeof(szline)/sizeof(TCHAR))) @@ -476,7 +476,7 @@ void Func_Service_Install(bool _q){ else if (!StartService(shSvc,1,SzName)) THROWERR(_T("StartService() Failed.")); - else + else MessageBox(NULL,_T("Service started successfully"),_T("Congratulations!"), MB_SETFOREGROUND|MB_ICONINFORMATION); } @@ -495,7 +495,7 @@ Please contact the application's support team for more information.\n"), } HANDLE ___pipeopen(){ - while (1){ + while (1){ if ((hdPipe = CreateFile(pipeName,GENERIC_READ|GENERIC_WRITE,0, NULL,OPEN_EXISTING,0,NULL))!=INVALID_HANDLE_VALUE) break; @@ -506,7 +506,7 @@ HANDLE ___pipeopen(){ } DWORD ___pipesentmessage(const TCHAR * szSent){ - DWORD dwReserved=PIPE_READMODE_MESSAGE; + DWORD dwReserved=PIPE_READMODE_MESSAGE; if (!SetNamedPipeHandleState(hdPipe,&dwReserved,NULL,NULL)); if (!WriteFile(hdPipe,szSent,(lstrlen(szSent)+1)*sizeof(TCHAR),&dwReserved,NULL)); return GetLastError(); @@ -542,7 +542,7 @@ DWORD __stdcall HostThread(LPVOID){ for (int errcunt=0;!Func_Download(hostsfile1,DownLocated)&& !Func_Download(hostsfile,DownLocated);errcunt++,Sleep(request_client?1000:10000)) if (errcunt>1) THROWERR(_T("DownLoad hosts file Error!")); - + if (!((fp=_tfopen(DownLocated,_T("r"))) && (_=_tfopen(ChangeCTLR,_T("w"))))) THROWERR(_T("Open file Error!")); while (!feof(fp)){ @@ -627,18 +627,18 @@ void WINAPI Service_Control(DWORD dwControl){ } DWORD __stdcall OpenPipeService(LPVOID){ - HANDLE hConnectEvent; - OVERLAPPED oConnect; - LPPIPEINST lpPipeInst; - DWORD dwWait, cbRet; - BOOL fSuccess, fPendingIO; + HANDLE hConnectEvent; + OVERLAPPED oConnect; + LPPIPEINST lpPipeInst; + DWORD dwWait, cbRet; + BOOL fSuccess, fPendingIO; if (!(hConnectEvent = CreateEvent(NULL,TRUE,TRUE,NULL))) return _tprintf(_T("CreateEvent failed with %ld.\n"), GetLastError()); oConnect.hEvent = hConnectEvent; fPendingIO = CreateAndConnectInstance(&oConnect); while (1){ dwWait = WaitForSingleObjectEx(hConnectEvent,INFINITE,TRUE); - switch (dwWait){ + switch (dwWait){ case 0: if (fPendingIO) if (!(fSuccess = GetOverlappedResult(hdPipe,&oConnect,&cbRet,FALSE))) @@ -654,34 +654,34 @@ DWORD __stdcall OpenPipeService(LPVOID){ break; default: return printf("WaitForSingleObjectEx (%ld)\n", GetLastError()); - } - } + } + } return 0; -} -void WINAPI CompletedWriteRoutine(DWORD dwErr,DWORD cbWritten,LPOVERLAPPED lpOverLap){ +} +void WINAPI CompletedWriteRoutine(DWORD dwErr,DWORD cbWritten,LPOVERLAPPED lpOverLap){ LPPIPEINST lpPipeInst; BOOL fRead = FALSE; lpPipeInst = (LPPIPEINST) lpOverLap; if ((dwErr == 0) && (cbWritten == lpPipeInst->cbToWrite)){ - fRead = ReadFileEx(lpPipeInst->hPipeInst,lpPipeInst->chRequest, + fRead = ReadFileEx(lpPipeInst->hPipeInst,lpPipeInst->chRequest, BUFSIZE*sizeof(TCHAR),(LPOVERLAPPED) lpPipeInst, (LPOVERLAPPED_COMPLETION_ROUTINE) CompletedReadRoutine); } if (!fRead) DisconnectAndClose(lpPipeInst); -} +} void WINAPI CompletedReadRoutine(DWORD dwErr,DWORD cbBytesRead,LPOVERLAPPED lpOverLap){ LPPIPEINST lpPipeInst; BOOL fWrite = FALSE; lpPipeInst = (LPPIPEINST) lpOverLap; - if ((dwErr == 0) && (cbBytesRead != 0)){ + if ((dwErr == 0) && (cbBytesRead != 0)){ GetAnswerToRequest(lpPipeInst); fWrite = WriteFileEx(lpPipeInst->hPipeInst,lpPipeInst->chReply, lpPipeInst->cbToWrite,(LPOVERLAPPED) lpPipeInst, (LPOVERLAPPED_COMPLETION_ROUTINE) CompletedWriteRoutine); } if (!fWrite) DisconnectAndClose(lpPipeInst); -} +} void DisconnectAndClose(LPPIPEINST lpPipeInst){ if (! DisconnectNamedPipe(lpPipeInst->hPipeInst)) @@ -689,10 +689,10 @@ void DisconnectAndClose(LPPIPEINST lpPipeInst){ CloseHandle(lpPipeInst->hPipeInst); if (lpPipeInst != NULL) HeapFree(GetProcessHeap(),0, lpPipeInst); -} +} -BOOL CreateAndConnectInstance(LPOVERLAPPED lpoOverlap) -{ +BOOL CreateAndConnectInstance(LPOVERLAPPED lpoOverlap) +{ if (!(hdPipe = CreateNamedPipe(pipeName,PIPE_ACCESS_DUPLEX |FILE_FLAG_OVERLAPPED, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,BUFSIZE*sizeof(TCHAR),BUFSIZE*sizeof(TCHAR), @@ -701,8 +701,8 @@ BOOL CreateAndConnectInstance(LPOVERLAPPED lpoOverlap) return ConnectToNewClient(hdPipe, lpoOverlap); } -BOOL ConnectToNewClient(HANDLE hPipe, LPOVERLAPPED lpo) -{ +BOOL ConnectToNewClient(HANDLE hPipe, LPOVERLAPPED lpo) +{ BOOL fConnected, fPendingIO = FALSE; if ((fConnected = ConnectNamedPipe(hPipe, lpo))) return 0*printf("ConnectNamedPipe failed with %ld.\n", GetLastError()); @@ -711,11 +711,11 @@ BOOL ConnectToNewClient(HANDLE hPipe, LPOVERLAPPED lpo) fPendingIO = TRUE; break; case ERROR_PIPE_CONNECTED: - if (SetEvent(lpo->hEvent)) + if (SetEvent(lpo->hEvent)) break; default: return 0*printf("ConnectNamedPipe failed with %ld.\n", GetLastError()); - } + } return fPendingIO; } diff --git a/hosts_tools/HostsToolforWindows/hosts_tool.exe.manifest b/tools/WinConsole/hosts_tool.exe.manifest similarity index 100% rename from hosts_tools/HostsToolforWindows/hosts_tool.exe.manifest rename to tools/WinConsole/hosts_tool.exe.manifest diff --git a/hosts_tools/HostsToolforWindows/hosts_tool.rc b/tools/WinConsole/hosts_tool.rc similarity index 100% rename from hosts_tools/HostsToolforWindows/hosts_tool.rc rename to tools/WinConsole/hosts_tool.rc diff --git a/hosts_tools/HostsToolforWindows/mitlicense.hpp b/tools/WinConsole/mitlicense.hpp similarity index 100% rename from hosts_tools/HostsToolforWindows/mitlicense.hpp rename to tools/WinConsole/mitlicense.hpp diff --git a/hosts_tools/HostsToolforWindows/ptrerr.hpp b/tools/WinConsole/ptrerr.hpp similarity index 100% rename from hosts_tools/HostsToolforWindows/ptrerr.hpp rename to tools/WinConsole/ptrerr.hpp diff --git a/hosts_tools/HostsToolforWindows/wininet.lib b/tools/WinConsole/wininet.lib similarity index 100% rename from hosts_tools/HostsToolforWindows/wininet.lib rename to tools/WinConsole/wininet.lib diff --git a/tools/WinGUI/README.MD b/tools/WinGUI/README.MD new file mode 100644 index 000000000..82e1a031b --- /dev/null +++ b/tools/WinGUI/README.MD @@ -0,0 +1,4 @@ +HostsTool是Windows平台下的一个简易桌面应用,它允许你通过简单的操作获取到最新的hosts更新。 + +![1](https://cloud.githubusercontent.com/assets/16496671/14585704/a68df23c-04b0-11e6-8282-3c9d0f05eb1a.png) +![2](https://cloud.githubusercontent.com/assets/16496671/14585705/b7f1a910-04b0-11e6-98a9-6e5274c9f4e2.png) diff --git a/hosts_tools/HostsTool/hosts_tool.pro b/tools/WinGUI/hosts_tool.pro similarity index 100% rename from hosts_tools/HostsTool/hosts_tool.pro rename to tools/WinGUI/hosts_tool.pro diff --git a/hosts_tools/HostsTool/hoststool.cpp b/tools/WinGUI/hoststool.cpp similarity index 100% rename from hosts_tools/HostsTool/hoststool.cpp rename to tools/WinGUI/hoststool.cpp diff --git a/hosts_tools/HostsTool/hoststool.h b/tools/WinGUI/hoststool.h similarity index 100% rename from hosts_tools/HostsTool/hoststool.h rename to tools/WinGUI/hoststool.h diff --git a/hosts_tools/HostsTool/hoststool.ui b/tools/WinGUI/hoststool.ui similarity index 100% rename from hosts_tools/HostsTool/hoststool.ui rename to tools/WinGUI/hoststool.ui diff --git a/hosts_tools/HostsTool/main.cpp b/tools/WinGUI/main.cpp similarity index 100% rename from hosts_tools/HostsTool/main.cpp rename to tools/WinGUI/main.cpp diff --git a/hosts_tools/scripts/lhosts b/tools/scripts/lhosts old mode 100755 new mode 100644 similarity index 100% rename from hosts_tools/scripts/lhosts rename to tools/scripts/lhosts diff --git a/hosts_tools/scripts/script_tool_for_linux.sh b/tools/scripts/script_tool_for_linux.sh similarity index 100% rename from hosts_tools/scripts/script_tool_for_linux.sh rename to tools/scripts/script_tool_for_linux.sh diff --git a/hosts_tools/scripts/script_tool_for_windows.bat b/tools/scripts/script_tool_for_windows.bat similarity index 100% rename from hosts_tools/scripts/script_tool_for_windows.bat rename to tools/scripts/script_tool_for_windows.bat