├── .gitattributes ├── .github └── workflows │ └── pack.yml ├── .gitignore ├── COPYING ├── COPYRIGHT ├── LICENSE ├── Makefile ├── README.md ├── README_zh.md ├── happynet.sln ├── happynet ├── ClassDiagram1.cd ├── happyn.ico ├── happynet.filters ├── happynet.user ├── happynet.vcproj ├── happynet.vcxproj ├── happynet.vcxproj.user ├── happynwinclient.cpp ├── maingui.h ├── manifestx64.xml ├── manifestx86.xml ├── netadapter.cpp ├── netadapter.h ├── netinterface.cpp ├── netinterface.h ├── process.cpp ├── process.h ├── registry.cpp ├── registry.h ├── res.rc ├── resource.h ├── service.cpp ├── service.h ├── sinstance.cpp ├── sinstance.h ├── systemsrv.cpp ├── systemsrv.h ├── tray.cpp ├── tray.h ├── utils.cpp ├── utils.h └── winerr.h ├── installer ├── happynet_install.exe ├── happynet_installer.nsi ├── n2n_release │ ├── happynet.ico │ ├── platforms │ │ ├── qminimal.dll │ │ ├── qoffscreen.dll │ │ └── qwindows.dll │ ├── winxp │ │ └── happynedge.exe │ ├── x64 │ │ ├── happynedge.exe │ │ ├── happynmonitor.exe │ │ ├── happynportfwd.exe │ │ ├── happynroute.exe │ │ └── happynssm.exe │ └── x86 │ │ ├── happynedge.exe │ │ ├── happynmonitor.exe │ │ ├── happynportfwd.exe │ │ ├── happynroute.exe │ │ └── happynssm.exe └── readme.txt ├── screenshots ├── happyn01.png ├── happyn02.png └── happyn03.png └── tap_driver ├── NDIS5_x64 ├── OemWin2k.inf ├── tap0901.cat ├── tap0901.map ├── tap0901.sys └── tapinstall.exe ├── NDIS5_x86 ├── OemWin2k.inf ├── tap0901.cat ├── tap0901.map ├── tap0901.sys └── tapinstall.exe ├── NDIS6_arm ├── OemVista.inf ├── tap0901.cat └── tap0901.sys ├── NDIS6_x64 ├── OemVista.inf ├── tap0901.cat ├── tap0901.sys └── tapinstall.exe └── NDIS6_x86 ├── OemVista.inf ├── tap0901.cat ├── tap0901.sys └── tapinstall.exe /.gitattributes: -------------------------------------------------------------------------------- 1 | happynmonitor.exe filter=lfs diff=lfs merge=lfs -text 2 | *.exe filter=lfs diff=lfs merge=lfs -text 3 | -------------------------------------------------------------------------------- /.github/workflows/pack.yml: -------------------------------------------------------------------------------- 1 | # auto pack release tag .zip package 2 | 3 | name: pack 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the main branch 8 | push: 9 | tags: 10 | - '*' 11 | 12 | # Allows you to run this workflow manually from the Actions tab 13 | workflow_dispatch: 14 | 15 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 16 | jobs: 17 | # This workflow contains a single job called "build" 18 | build: 19 | # The type of runner that the job will run on 20 | runs-on: ubuntu-22.04 21 | 22 | # Steps represent a sequence of tasks that will be executed as part of the job 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v2 26 | with: 27 | lfs: true 28 | 29 | - name: Install zip 30 | run: sudo apt-get install zip 31 | 32 | - run: make zip tagname=${GITHUB_REF#refs/*/} 33 | 34 | - name: Create Release 35 | uses: ncipollo/release-action@v1.5.0 36 | with: 37 | artifacts: "happynet-win-x86-x64-all-*.zip" 38 | release_name: happynet linux ${{ github.ref }} Release 39 | token: ${{ secrets.RElEASE_TOKEN }} 40 | body: | 41 | build by happyn.net 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # These are some examples of commonly ignored file patterns. 2 | # You should customize this list as applicable to your project. 3 | # Learn more about .gitignore: 4 | # https://www.atlassian.com/git/tutorials/saving-changes/gitignore 5 | 6 | # Node artifact files 7 | node_modules/ 8 | dist/ 9 | 10 | .vs 11 | 12 | # Compiled Java class files 13 | *.class 14 | 15 | # Compiled Python bytecode 16 | *.py[cod] 17 | 18 | # Log files 19 | *.log 20 | 21 | # Package files 22 | *.jar 23 | 24 | # Maven 25 | target/ 26 | dist/ 27 | 28 | # JetBrains IDE 29 | .idea/ 30 | 31 | # Unit test reports 32 | TEST*.xml 33 | 34 | # Generated by MacOS 35 | .DS_Store 36 | 37 | # Generated by Windows 38 | Thumbs.db 39 | 40 | # Applications 41 | *.app 42 | *.war 43 | 44 | # Large media files 45 | *.mp4 46 | *.tiff 47 | *.avi 48 | *.flv 49 | *.mov 50 | *.wmv 51 | *.opensdf 52 | *.suo 53 | *.sdf 54 | *.pdb 55 | *.obj 56 | *.aps 57 | Release 58 | Debug 59 | happynet/Release 60 | happynet/Debug 61 | happynetService/Release 62 | happynetService/Debug 63 | ipch 64 | hooks 65 | lfs 66 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/COPYING -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | ## Happynet 2 | 3 | Happynet Windows Client is a GUI program for N2N Client packaging, for N2N users to provide easy to use interface control; 4 | 5 | The original code of Happynet Windows Client comes from [n2NedgeGUI](https://sourceforge.net/projects/n2nedgegui/) project and adopts GPLV3 authorization. This project also adopts GPLV3. 6 | 7 | ## User Guide 8 | 9 | https://windows.happyn.cn 10 | 11 | ## License: 12 | 13 | [COPYRIGHT.GPL3](LICENSE) 14 | 15 | ## Powed by: 16 | 17 | https://happyn.cn 18 | 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | zip: $(shell find .) 2 | echo $(tagname) 3 | cp installer/happynet_install.exe happynet-win-x86-x64-all-$(tagname).exe 4 | zip happynet-win-x86-x64-all-$(tagname).zip happynet-win-x86-x64-all-$(tagname).exe 5 | clean: 6 | rm -rf happynet-win-x86-x64-all-* 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | #### [中文] 4 | 5 | Happynet Windows Client is a GUI program for N2N Client packaging, for N2N users to provide easy to use interface control; 6 | 7 | 8 | ## Compatibility 9 | 10 | Happynet Client is compatible with [N2N3.0](https://github.com/ntop/n2n/releases/tag/3.0) 11 | 12 | ## support 13 | 14 | * Windows Vista (X86/X64) 15 | * Windows 7 (X86/X64) 16 | * Windows 10 (X86/X64/ARM64) 17 | * Windows 11 (X86/X64/ARM64) 18 | 19 | 20 | ## User Guide 21 | 22 | 1. download and install package, the package will auto set tuntap driver 23 | 2. set ip address, community, encry key, supernode host, supernode port 24 | 3. start service 25 | 26 | 27 | The configuration is compatible with [n2n edge params](https://github.com/ntop/n2n/blob/dev/doc/ConfigurationFiles.md) 28 | 29 | 30 | ## ScreenShots 31 | 32 | ![Main GUI](screenshots/happyn01.png) 33 | 34 | ![Monitor](screenshots/happyn02.png) 35 | 36 | ![Ad Settings](screenshots/happyn03.png) 37 | 38 | ## Download 39 | 40 | [happynet download](https://github.com/happynclient/happynwindows/releases) 41 | 42 | 43 | ## FAQ 44 | 45 | #### Are there any plans for support previous version of n2n like v2.4 ? 46 | 47 | By default, we currently only support N2N 3.0; If you are using an older version of N2N (such as N2N V2); You can also change the file a little by yourself to support, it's easy: 48 | 49 | 1. Prepare your N2N `edge.exe` 50 | 51 | 2. Rename your `edge.exe` to `happynedge.exe` to replace happynet's default installation file: `C:\Program Files (x86)\happynet\happynedge.exe` 52 | 53 | 3. Most parameters of N2N V2 and V3 are compatible. If there are special parameters that are not compatible, you can go to "Custom Parameters" in `Advanced Settings` to set your own parameters 54 | 55 | ## License: 56 | 57 | [COPYRIGHT.GPL3](LICENSE) 58 | 59 | ## Powed by: 60 | 61 | https://happyn.net 62 | 63 | -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | 4 | ## Happyn是什么 5 | 6 | Happyn是一个网络互联的平台,我们通过整合优秀的开源软件组网工具,希望通过HAPPYN的服务,让您在世界上任何地方,使用任何联网设备都能建立虚拟网络; 7 | 8 | ## Happyn现在可以为您提供什么服务 9 | 10 | Happyn现在整合了N2N的服务,可以让您的不同设备、不同系统(Windows、Linux、Android、MacOS)在任何地方都能组建您的个人虚拟局域网 11 | 12 | 未来我们计划整合更多优秀的开源软件,为您提供更多的网络互联服务 13 | 14 | ## Happyn的使用场景 15 | 16 | * 远程办公 17 | * 局域网游戏互联 18 | * 不同设备间资源共享 19 | * 家用NAS设备资源分享 20 | * 远程监控 21 | * 智慧家电互联互通 22 | * 更多场景等待您的发掘 23 | 24 | ## 用户帮助 25 | 26 | https://windows.happyn.cn 27 | 28 | ## FAQ: 29 | 30 | #### 客户端支持哪些平台? 31 | 32 | * Windows Vista (X86/X64) 33 | * Windows 7 (X86/X64) 34 | * Windows 10 (X86/X64/ARM64) 35 | * Windows 11 (X86/X64/ARM64) 36 | 37 | #### 我所有设备上的程序已经显示运行成功,但是我Ping不通对方,为什么? 38 | 39 | 首先请检查是否参数都正确配置了,特别要保证 "服务ID+服务密钥" 是否在所有客户端都一致,有很多时候是我们太粗心; 40 | 41 | 其次请检查自己的机器是否开启了防火墙,可以先用机器的原有IP Ping一下,看看通不通;大部分情况下都是防火墙阻止了通讯,如何配置防火墙请参考这里 42 | 43 | 最后请仔细检查Happynet的输出Log,看是否有"[OK]"的连接成功输出,如果没有,最大的可能是您短时间内多次连接,被系统判断为恶意扫描禁止了;此时您先点击“停止”,然后等待2分钟,再次重连即可 44 | 45 | 另外,在极少数情况下,Windows系统从休眠中唤醒后,服务会因为长时间没有连接导致服务端Block客户端,此时需要 停止服务->退出程序->重新启动客户端->启动服务 46 | 47 | #### 怎样才能最小化隐藏到托盘呢? 48 | 49 | "程序设置"界面有此项设定,请勾选复选框,然后点击"保存当前设置"生效 50 | 51 | #### 怎样才能开机自动启动服务呢? 52 | 53 | "程序设置"界面有此项设定,请勾选复选框,然后点击"保存当前设置"生效 54 | 55 | #### 还有其它问题? 56 | 57 | 没关系,请到我们的[交流论坛](https://forum.happyn.cn/t/windows)向我们反馈问题,谢谢您的包容和支持! 58 | 59 | -------------------------------------------------------------------------------- /happynet.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.1705 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "happynet", "happynet\happynet.vcxproj", "{C01A3DD3-F5E3-4DA0-BB76-B5B36C17D955}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A46C77CF-C7D5-424F-B254-8DFE87253AAE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C01A3DD3-F5E3-4DA0-BB76-B5B36C17D955}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {C01A3DD3-F5E3-4DA0-BB76-B5B36C17D955}.Debug|Win32.Build.0 = Debug|Win32 18 | {C01A3DD3-F5E3-4DA0-BB76-B5B36C17D955}.Release|Win32.ActiveCfg = Release|Win32 19 | {C01A3DD3-F5E3-4DA0-BB76-B5B36C17D955}.Release|Win32.Build.0 = Release|Win32 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | GlobalSection(ExtensibilityGlobals) = postSolution 25 | SolutionGuid = {24233004-7695-44A5-A1E7-7722E6CD84CA} 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /happynet/ClassDiagram1.cd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /happynet/happyn.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/happynet/happyn.ico -------------------------------------------------------------------------------- /happynet/happynet.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;hpp;hxx;hm;inl;inc;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 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | 61 | 62 | Resource Files 63 | 64 | 65 | 66 | 67 | 68 | Resource Files 69 | 70 | 71 | -------------------------------------------------------------------------------- /happynet/happynet.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /happynet/happynet.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 26 | 29 | 32 | 35 | 38 | 41 | 52 | 55 | 58 | 61 | 69 | 72 | 76 | 79 | 82 | 85 | 88 | 91 | 92 | 100 | 103 | 106 | 109 | 112 | 115 | 126 | 129 | 132 | 135 | 145 | 148 | 152 | 155 | 158 | 161 | 164 | 167 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 181 | 184 | 185 | 188 | 189 | 192 | 193 | 194 | 199 | 202 | 203 | 206 | 207 | 210 | 211 | 214 | 215 | 218 | 219 | 220 | 225 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | -------------------------------------------------------------------------------- /happynet/happynet.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {C01A3DD3-F5E3-4DA0-BB76-B5B36C17D955} 15 | Happyn 16 | Win32Proj 17 | happynet 18 | 7.0 19 | 20 | 21 | 22 | Application 23 | Unicode 24 | true 25 | v141_xp 26 | 27 | 28 | Application 29 | Unicode 30 | v141_xp 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | <_ProjectFileVersion>10.0.30319.1 44 | $(SolutionDir)$(Configuration)\ 45 | $(Configuration)\ 46 | true 47 | $(SolutionDir)$(Configuration)\ 48 | $(Configuration)\ 49 | false 50 | AllRules.ruleset 51 | 52 | 53 | AllRules.ruleset 54 | 55 | 56 | 57 | 58 | 59 | Disabled 60 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 61 | true 62 | EnableFastChecks 63 | MultiThreadedDebug 64 | 65 | 66 | Level3 67 | EditAndContinue 68 | 69 | 70 | $(OutDir)happynet.exe 71 | true 72 | Windows 73 | MachineX86 74 | RequireAdministrator 75 | 5.1 76 | 77 | 78 | manifestx86.xml;%(AdditionalManifestFiles) 79 | 80 | 81 | 82 | 83 | MaxSpeed 84 | true 85 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 86 | MultiThreaded 87 | true 88 | 89 | 90 | Level3 91 | ProgramDatabase 92 | 93 | 94 | $(OutDir)happynet.exe 95 | true 96 | Windows 97 | true 98 | true 99 | MachineX86 100 | RequireAdministrator 101 | 5.01 102 | 103 | 104 | manifestx86.xml;%(AdditionalManifestFiles) 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /happynet/happynet.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /happynet/happynwinclient.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/happynet/happynwinclient.cpp -------------------------------------------------------------------------------- /happynet/maingui.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_MAINGUI 2 | #define _H_MAINGUI 3 | 4 | 5 | #define AUTOIP_TEXT "Auto Get IP Address" 6 | #define IsItemChecked(x,y) (SendDlgItemMessage(x, y, BM_GETCHECK, 0, 0) == BST_CHECKED) 7 | 8 | BOOL ValidateOptions(HWND hwndDlg); 9 | VOID UpdateAddressesInfo(HWND hwndDlg); 10 | VOID UpdateServiceStatus(HWND hwndDlg); 11 | //VOID CALLBACK RefreshScreen(HWND hwndDlg, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); 12 | VOID ReadOptions(HWND hwndDlg); 13 | BOOL SaveOptions(HWND hwndDlg); 14 | VOID HandleCommandEvent(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 15 | INT_PTR CALLBACK MainDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 16 | INT_PTR CALLBACK AdSettingsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); 17 | 18 | VOID SetupSystemMenu(HWND hwndDlg); 19 | int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /happynet/manifestx64.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | N2N Edge GUI 10 | 11 | 12 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /happynet/manifestx86.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | N2N Edge GUI 10 | 11 | 12 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /happynet/netadapter.cpp: -------------------------------------------------------------------------------- 1 | #include "netadapter.h" 2 | #include "winerr.h" 3 | #include 4 | 5 | #define ALLOCATE_FROM_PROCESS_HEAP( bytes ) ::HeapAlloc( ::GetProcessHeap(), HEAP_ZERO_MEMORY, bytes ) 6 | #define DEALLOCATE_FROM_PROCESS_HEAP( ptr ) if( ptr ) ::HeapFree( ::GetProcessHeap(), 0, ptr ) 7 | #define REALLOC_FROM_PROCESS_HEAP( ptr, bytes ) ::HeapReAlloc( ::GetProcessHeap(), HEAP_ZERO_MEMORY, ptr, bytes ) 8 | 9 | //////////////////////////////////////////////////////////// 10 | // Desc: 11 | // Builds a listing of all network adapters found 12 | // on the current system. If there is not enough 13 | // space in the passed in buffer ERROR_INSUFFICIENT_BUFFER 14 | // is returned. If error lpdwOutSzBuf contains the 15 | // needed buffer size. If no error it returned 16 | // used buffer size. 17 | //////////////////////////////////////////////////////////// 18 | DWORD EnumNetworkAdapters(CNetworkAdapter* pAdapters, ULONG ulSzBuf, LPDWORD lpdwOutSzBuf) { 19 | IP_ADAPTER_INFO* pAdptInfo = NULL; 20 | IP_ADAPTER_INFO* pNextAd = NULL; 21 | ULONG ulLen = 0; 22 | int nCnt = 0; 23 | CWinErr erradapt; 24 | 25 | 26 | erradapt = ::GetAdaptersInfo(pAdptInfo, &ulLen); 27 | if (erradapt == ERROR_BUFFER_OVERFLOW) { 28 | pAdptInfo = (IP_ADAPTER_INFO*)ALLOCATE_FROM_PROCESS_HEAP(ulLen); 29 | erradapt = ::GetAdaptersInfo(pAdptInfo, &ulLen); 30 | } 31 | 32 | // acquire a count of how many network adapters 33 | // we are going to need to work on so that 34 | // we can make sure we have adequate buffer space. 35 | pNextAd = pAdptInfo; 36 | while (pNextAd) { 37 | nCnt++; 38 | pNextAd = pNextAd->Next; 39 | } 40 | 41 | // now that we have the count we need to determine if the caller passed in an 42 | // adequate buffer for us to store all the needed adapters. we set the variable 43 | // to the needed number of bytes so the caller will now how many there are 44 | // and how much space is needed to hold them. 45 | *lpdwOutSzBuf = nCnt * sizeof(CNetworkAdapter); 46 | if (ulSzBuf < *lpdwOutSzBuf) { 47 | DEALLOCATE_FROM_PROCESS_HEAP(pAdptInfo); 48 | return ERROR_INSUFFICIENT_BUFFER; 49 | } 50 | 51 | // this needs to be reset for future use. 52 | nCnt = 0; 53 | 54 | if (erradapt == ERROR_SUCCESS) { 55 | // initialize the pointer we use the move through 56 | // the list. 57 | pNextAd = pAdptInfo; 58 | 59 | // loop through for all available interfaces and setup an associated 60 | // CNetworkAdapter class. 61 | while (pNextAd) { 62 | pAdapters[nCnt].SetupAdapterInfo(pNextAd); 63 | // move forward to the next adapter in the list so 64 | // that we can collect its information. 65 | pNextAd = pNextAd->Next; 66 | nCnt++; 67 | } 68 | } 69 | 70 | // free any memory we allocated from the heap before 71 | // exit. we wouldn't wanna leave memory leaks now would we? ;p 72 | DEALLOCATE_FROM_PROCESS_HEAP(pAdptInfo); 73 | 74 | return ERROR_SUCCESS; 75 | } 76 | 77 | //////////////////////////////////////////////////////////// 78 | // Desc: 79 | // Construction. Initializes the variables and makes 80 | // sure all the collection classes are cleaned out. 81 | //////////////////////////////////////////////////////////// 82 | CNetworkAdapter::CNetworkAdapter() { 83 | m_bDhcpUsed = FALSE; 84 | m_bWinsUsed = FALSE; 85 | m_dwIndex = 0; 86 | m_nAdapterType = 0; 87 | 88 | ::memset(&m_ucAddress.ucAddress, 0, MAX_ADAPTER_ADDRESS_LENGTH); 89 | m_ucAddress.nLen = 0; 90 | 91 | m_DnsAddresses.clear(); 92 | m_IpAddresses.clear(); 93 | m_GatewayList.clear(); 94 | 95 | return; 96 | } 97 | 98 | //////////////////////////////////////////////////////////// 99 | // Desc: 100 | // Deconstruction. 101 | //////////////////////////////////////////////////////////// 102 | CNetworkAdapter::~CNetworkAdapter() { 103 | #ifdef _DEBUG 104 | ::memset(&m_ucAddress.ucAddress, 0, MAX_ADAPTER_ADDRESS_LENGTH); 105 | m_ucAddress.nLen = 0; 106 | m_bDhcpUsed = FALSE; 107 | m_bWinsUsed = FALSE; 108 | m_dwIndex = 0; 109 | m_nAdapterType = 0; 110 | #endif 111 | 112 | m_DnsAddresses.clear(); 113 | m_IpAddresses.clear(); 114 | m_GatewayList.clear(); 115 | 116 | return; 117 | } 118 | 119 | //////////////////////////////////////////////////////////// 120 | // Desc: 121 | // 122 | //////////////////////////////////////////////////////////// 123 | BOOL CNetworkAdapter::SetupAdapterInfo(IP_ADAPTER_INFO* pAdaptInfo) { 124 | BOOL bSetupPassed = FALSE; 125 | IP_ADDR_STRING* pNext = NULL; 126 | IP_PER_ADAPTER_INFO* pPerAdapt = NULL; 127 | ULONG ulLen = 0; 128 | CWinErr err; 129 | 130 | _IPINFO iphold; 131 | 132 | if (pAdaptInfo) { 133 | #ifndef _UNICODE 134 | m_sName = pAdaptInfo->AdapterName; 135 | m_sDesc = pAdaptInfo->Description; 136 | m_sPriWins = pAdaptInfo->PrimaryWinsServer.IpAddress.String; 137 | m_sSecWins = pAdaptInfo->SecondaryWinsServer.IpAddress.String; 138 | m_sDhcpAddr = pAdaptInfo->DhcpServer.IpAddress.String; 139 | #else 140 | USES_CONVERSION; 141 | m_sName = A2W(pAdaptInfo->AdapterName); 142 | m_sDesc = A2W(pAdaptInfo->Description); 143 | m_sPriWins = A2W(pAdaptInfo->PrimaryWinsServer.IpAddress.String); 144 | m_sSecWins = A2W(pAdaptInfo->SecondaryWinsServer.IpAddress.String); 145 | m_sDhcpAddr = A2W(pAdaptInfo->DhcpServer.IpAddress.String); 146 | 147 | #endif 148 | m_dwIndex = pAdaptInfo->Index; 149 | m_nAdapterType = pAdaptInfo->Type; 150 | m_bDhcpUsed = pAdaptInfo->DhcpEnabled; 151 | m_bWinsUsed = pAdaptInfo->HaveWins; 152 | m_tLeaseObtained = pAdaptInfo->LeaseObtained; 153 | m_tLeaseExpires = pAdaptInfo->LeaseExpires; 154 | 155 | if (pAdaptInfo->CurrentIpAddress) { 156 | m_sCurIpAddr.sIp = pAdaptInfo->CurrentIpAddress->IpAddress.String; 157 | m_sCurIpAddr.sSubnet = pAdaptInfo->CurrentIpAddress->IpMask.String; 158 | } 159 | else { 160 | m_sCurIpAddr.sIp = "0.0.0.0"; 161 | m_sCurIpAddr.sSubnet = "0.0.0.0"; 162 | } 163 | 164 | // since an adapter may have more than one ip address we need 165 | // to populate the array we have setup with all available 166 | // ip addresses. 167 | pNext = &(pAdaptInfo->IpAddressList); 168 | while (pNext) { 169 | iphold.sIp = pNext->IpAddress.String; 170 | iphold.sSubnet = pNext->IpMask.String; 171 | m_IpAddresses.push_back(iphold); 172 | pNext = pNext->Next; 173 | } 174 | 175 | // an adapter usually has just one gateway however the provision exists 176 | // for more than one so to "play" as nice as possible we allow for it here 177 | // as well. 178 | pNext = &(pAdaptInfo->GatewayList); 179 | while (pNext) { 180 | m_GatewayList.push_back(pNext->IpAddress.String); 181 | pNext = pNext->Next; 182 | } 183 | 184 | // we need to generate a IP_PER_ADAPTER_INFO structure in order 185 | // to get the list of dns addresses used by this adapter. 186 | err = ::GetPerAdapterInfo(m_dwIndex, pPerAdapt, &ulLen); 187 | if (err == ERROR_BUFFER_OVERFLOW) { 188 | pPerAdapt = (IP_PER_ADAPTER_INFO*)ALLOCATE_FROM_PROCESS_HEAP(ulLen); 189 | err = ::GetPerAdapterInfo(m_dwIndex, pPerAdapt, &ulLen); 190 | 191 | // if we succeed than we need to drop into our loop 192 | // and fill the dns array will all available IP 193 | // addresses. 194 | if (err == ERROR_SUCCESS) { 195 | pNext = &(pPerAdapt->DnsServerList); 196 | while (pNext) { 197 | m_DnsAddresses.push_back(pNext->IpAddress.String); 198 | pNext = pNext->Next; 199 | } 200 | bSetupPassed = TRUE; 201 | } 202 | 203 | // this is done outside the err == ERROR_SUCCES just in case. the macro 204 | // uses NULL pointer checking so it is ok if pPerAdapt was never allocated. 205 | DEALLOCATE_FROM_PROCESS_HEAP(pPerAdapt); 206 | } 207 | } 208 | 209 | return bSetupPassed; 210 | } 211 | 212 | //////////////////////////////////////////////////////////// 213 | // Desc: 214 | // Releases the addresses held by this adapter. 215 | //////////////////////////////////////////////////////////// 216 | BOOL CNetworkAdapter::ReleaseAddress() { 217 | return DoRenewRelease(&::IpReleaseAddress); 218 | } 219 | 220 | //////////////////////////////////////////////////////////// 221 | // Desc: 222 | // Renews the address being held by this adapter. 223 | //////////////////////////////////////////////////////////// 224 | BOOL CNetworkAdapter::RenewAddress() { 225 | return DoRenewRelease(&::IpRenewAddress); 226 | } 227 | 228 | //////////////////////////////////////////////////////////// 229 | // Desc: 230 | // Generic function that can handle either renewing 231 | // or releasing an adapters ip address. 232 | //////////////////////////////////////////////////////////// 233 | BOOL CNetworkAdapter::DoRenewRelease(DWORD(__stdcall *func)(PIP_ADAPTER_INDEX_MAP AdapterInfo)) { 234 | IP_INTERFACE_INFO* pInfo = NULL; 235 | BOOL bDidIt = FALSE; 236 | ULONG ulLen = 0; 237 | int nNumInterfaces = 0; 238 | int nCnt = 0; 239 | CWinErr err; 240 | 241 | 242 | err = ::GetInterfaceInfo(pInfo, &ulLen); 243 | if (err == ERROR_INSUFFICIENT_BUFFER) { 244 | pInfo = (IP_INTERFACE_INFO*)ALLOCATE_FROM_PROCESS_HEAP(ulLen); 245 | err = ::GetInterfaceInfo(pInfo, &ulLen); 246 | 247 | if (err != NO_ERROR) { 248 | return FALSE; 249 | } 250 | } 251 | 252 | // we can assume from here out that we have a valid array 253 | // of IP_INTERFACE_INFO structures due to the error 254 | // checking one above. 255 | nNumInterfaces = ulLen / sizeof(IP_INTERFACE_INFO); 256 | for (nCnt = 0; nCnt < nNumInterfaces; nCnt++) { 257 | if (pInfo[nCnt].Adapter[0].Index == m_dwIndex) { 258 | err = func(&pInfo[nCnt].Adapter[0]); 259 | 260 | // free all used memory since we don't need it any more. 261 | DEALLOCATE_FROM_PROCESS_HEAP(pInfo); 262 | 263 | bDidIt = (err == NO_ERROR); 264 | if (!bDidIt) { 265 | return FALSE; 266 | } 267 | 268 | break; 269 | } 270 | } 271 | 272 | return bDidIt; 273 | } 274 | 275 | //////////////////////////////////////////////////////////// 276 | // Desc: 277 | // Generic function to grab a string from an array. 278 | // purpose of this function is just to add error 279 | // checking. 280 | //////////////////////////////////////////////////////////// 281 | std::string CNetworkAdapter::GetStringFromArray(const StringArray* pPtr, int nIndex) const { 282 | std::string sStr = ""; 283 | if (pPtr && ((SIZE_T)nIndex < pPtr->size())) { 284 | sStr = (*pPtr)[nIndex]; 285 | } 286 | 287 | return sStr; 288 | } 289 | 290 | //////////////////////////////////////////////////////////// 291 | // Desc: 292 | // Returns a string translation of the integer type 293 | // identifer for an adapter. 294 | //////////////////////////////////////////////////////////// 295 | tstring CNetworkAdapter::GetAdapterTypeString(UINT nType) { 296 | tstring sType = _T(""); 297 | switch (nType) { 298 | case MIB_IF_TYPE_OTHER: sType = _T("Other"); break; 299 | case MIB_IF_TYPE_ETHERNET: sType = _T("Ethernet"); break; 300 | case MIB_IF_TYPE_TOKENRING: sType = _T("Token Ring"); break; 301 | case MIB_IF_TYPE_FDDI: sType = _T("FDDI"); break; 302 | case MIB_IF_TYPE_PPP: sType = _T("PPP"); break; 303 | case MIB_IF_TYPE_LOOPBACK: sType = _T("Loopback"); break; 304 | case MIB_IF_TYPE_SLIP: sType = _T("SLIP"); break; 305 | default: sType = _T("Invalid Adapter Type"); break; 306 | }; 307 | 308 | return sType; 309 | } 310 | 311 | 312 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 313 | // Data Accessor Functions // 314 | // Pretty Self Explanitory // 315 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 316 | 317 | tstring CNetworkAdapter::GetAdapterName() const { return m_sName; } 318 | tstring CNetworkAdapter::GetAdapterDescription() const { return m_sDesc; } 319 | time_t CNetworkAdapter::GetLeaseObtained() const { return m_tLeaseObtained; } 320 | time_t CNetworkAdapter::GetLeaseExpired() const { return m_tLeaseExpires; } 321 | SIZE_T CNetworkAdapter::GetNumIpAddrs() const { return m_IpAddresses.size(); } 322 | SIZE_T CNetworkAdapter::GetNumDnsAddrs() const { return m_DnsAddresses.size(); } 323 | std::string CNetworkAdapter::GetDnsAddr(int nDns) const { return GetStringFromArray(&m_DnsAddresses, nDns); } 324 | std::string CNetworkAdapter::GetCurrentIpAddress() const { return m_sCurIpAddr.sIp; } 325 | BOOL CNetworkAdapter::IsDhcpUsed() const { return m_bDhcpUsed; } 326 | tstring CNetworkAdapter::GetDchpAddr() const { return m_sDhcpAddr; } 327 | BOOL CNetworkAdapter::IsWinsUsed() const { return m_bWinsUsed; } 328 | tstring CNetworkAdapter::GetPrimaryWinsServer() const { return m_sPriWins; } 329 | tstring CNetworkAdapter::GetSecondaryWinsServer() const { return m_sSecWins; } 330 | std::string CNetworkAdapter::GetGatewayAddr(int nGateway) const { return GetStringFromArray(&m_GatewayList, nGateway); } 331 | SIZE_T CNetworkAdapter::GetNumGatewayAddrs() const { return m_GatewayList.size(); } 332 | DWORD CNetworkAdapter::GetAdapterIndex() const { return m_dwIndex; } 333 | UINT CNetworkAdapter::GetAdapterType() const { return m_nAdapterType; } 334 | 335 | std::string CNetworkAdapter::GetIpAddr(int nIp) const { 336 | std::string sAddr = ""; 337 | if ((SIZE_T)nIp < m_IpAddresses.size()) { 338 | sAddr = m_IpAddresses[nIp].sIp; 339 | } 340 | 341 | return sAddr; 342 | } 343 | 344 | std::string CNetworkAdapter::GetSubnetForIpAddr(int nIp) const { 345 | std::string sAddr = ""; 346 | if ((SIZE_T)nIp < m_IpAddresses.size()) { 347 | sAddr = m_IpAddresses[nIp].sSubnet; 348 | } 349 | return sAddr; 350 | } 351 | 352 | //////////////////////////////////////////// End Accessor Functions //////////////////////////////////////////// -------------------------------------------------------------------------------- /happynet/netadapter.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAPTER_INFO_H____ 2 | #define _ADAPTER_INFO_H____ 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | class CNetworkAdapter; 12 | 13 | #ifndef tstring 14 | #ifdef _UNICODE 15 | #define tstring std::wstring 16 | #else 17 | #define tstring std::string 18 | #endif 19 | #endif 20 | 21 | // import the internet protocol helper libarary 22 | #pragma comment( lib, "iphlpapi.lib" ) 23 | 24 | #define DEFAULT_GATEWAY_ADDR 0 25 | 26 | struct _IPINFO { 27 | std::string sIp; 28 | std::string sSubnet; 29 | }; 30 | 31 | class CIpInfoArray : public vector< _IPINFO > {}; 32 | class StringArray : public vector< std::string > {}; 33 | 34 | ///////////////////////////////////////////// 35 | // Function Prototypes 36 | DWORD EnumNetworkAdapters(CNetworkAdapter* lpBuffer, ULONG ulSzBuf, LPDWORD lpdwOutSzBuf); 37 | 38 | ////////////////////////////////////////////////////////////////////////////////////////// 39 | // Desc: 40 | // Class wrapper for a single network adapter. A listing of these adapters 41 | // can be built using the EnumNetworkAdapters(...) function prototyped 42 | // above. 43 | ////////////////////////////////////////////////////////////////////////////////////////// 44 | class CNetworkAdapter { 45 | public: 46 | CNetworkAdapter(); 47 | ~CNetworkAdapter(); 48 | BOOL SetupAdapterInfo(IP_ADAPTER_INFO* pAdaptInfo); 49 | 50 | // information about the adapters name for the users 51 | // and its name to the system 52 | tstring GetAdapterName() const; 53 | tstring GetAdapterDescription() const; 54 | 55 | // dhcp lease access functions 56 | time_t GetLeaseObtained() const; 57 | time_t GetLeaseExpired() const; 58 | 59 | // access to lists of various server's ip address 60 | SIZE_T GetNumIpAddrs() const; 61 | SIZE_T GetNumDnsAddrs() const; 62 | std::string GetIpAddr(int nIp = 0) const; 63 | std::string GetSubnetForIpAddr(int nIp = 0) const; 64 | std::string GetDnsAddr(int nDns = 0) const; 65 | std::string GetCurrentIpAddress() const; 66 | 67 | // dhcp function 68 | BOOL IsDhcpUsed() const; 69 | tstring GetDchpAddr() const; 70 | 71 | // wins function 72 | BOOL IsWinsUsed() const; 73 | tstring GetPrimaryWinsServer() const; 74 | tstring GetSecondaryWinsServer() const; 75 | 76 | std::string GetGatewayAddr(int nGateway = DEFAULT_GATEWAY_ADDR) const; 77 | SIZE_T GetNumGatewayAddrs() const; 78 | 79 | static tstring GetAdapterTypeString(UINT nType); 80 | UINT GetAdapterType() const; 81 | 82 | DWORD GetAdapterIndex() const; 83 | BOOL ReleaseAddress(); 84 | BOOL RenewAddress(); 85 | 86 | protected: 87 | std::string GetStringFromArray(const StringArray* pPtr, int nIndex) const; 88 | BOOL DoRenewRelease(DWORD(__stdcall *func)(PIP_ADAPTER_INDEX_MAP AdapterInfo)); 89 | 90 | private: 91 | tstring m_sName; // adapter name with the computer. For human readable name use m_sDesc. 92 | tstring m_sDesc; 93 | tstring m_sPriWins; 94 | tstring m_sSecWins; 95 | tstring m_sDefGateway; 96 | tstring m_sDhcpAddr; 97 | _IPINFO m_sCurIpAddr; // this is also in the ip address list but this is the address currently active. 98 | DWORD m_dwIndex; // machine index of the adapter. 99 | UINT m_nAdapterType; 100 | BOOL m_bDhcpUsed; 101 | BOOL m_bWinsUsed; 102 | StringArray m_DnsAddresses; 103 | CIpInfoArray m_IpAddresses; 104 | StringArray m_GatewayList; 105 | time_t m_tLeaseObtained; 106 | time_t m_tLeaseExpires; 107 | 108 | struct UNNAMED { 109 | BYTE ucAddress[MAX_ADAPTER_ADDRESS_LENGTH]; 110 | UINT nLen; 111 | } m_ucAddress; 112 | }; 113 | 114 | #endif //_ADAPTER_INFO_H____ -------------------------------------------------------------------------------- /happynet/netinterface.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "registry.h" 10 | #include "netinterface.h" 11 | #include "utils.h" 12 | 13 | #pragma comment(lib, "iphlpapi.lib") 14 | #pragma comment(lib, "ole32.lib") 15 | #pragma comment(lib, "oleaut32.lib") 16 | 17 | #define MAX_TRIES 3 18 | #define MAX_ADAPTER_NAME_LEN 1024 19 | #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) 20 | #define FREE(x) HeapFree(GetProcessHeap(), 0, (x)) 21 | const ULONG WORKING_BUFFER_SIZE = 15000; 22 | #define NPCAP_LOOPBACK_INTERFACE_NAME TEXT("HAPPYNET") 23 | 24 | 25 | static BOOL RenameNetinterfaceById(INetSharingManager *pNSM, WCHAR* pszDeviceUUID) 26 | { // add a port mapping to every firewalled or shared connection 27 | BOOL bFound = FALSE; 28 | INetSharingEveryConnectionCollection * pINetNsecc = NULL; 29 | HRESULT hr = pNSM->get_EnumEveryConnection(&pINetNsecc); 30 | if (!pINetNsecc) { 31 | LogEvent(TEXT("failed to get EveryConnectionCollection!\r\n")); 32 | }else { 33 | // enumerate connections 34 | IEnumVARIANT * pEnumValue = NULL; 35 | IUnknown * pUnknown = NULL; 36 | hr = pINetNsecc->get__NewEnum(&pUnknown); 37 | if (pUnknown) { 38 | hr = pUnknown->QueryInterface(__uuidof(IEnumVARIANT), 39 | (void**)&pEnumValue); 40 | pUnknown->Release(); 41 | } 42 | if (pEnumValue) { 43 | VARIANT v; 44 | VariantInit(&v); 45 | 46 | while ((S_OK == pEnumValue->Next(1, &v, NULL)) && (bFound == FALSE)) { 47 | if (V_VT(&v) == VT_UNKNOWN) { 48 | INetConnection * pNC = NULL; 49 | V_UNKNOWN(&v)->QueryInterface(__uuidof(INetConnection), 50 | (void**)&pNC); 51 | if (pNC) { 52 | NETCON_PROPERTIES *pNETCON_PROPERTIES; 53 | pNC->GetProperties(&pNETCON_PROPERTIES); 54 | 55 | wchar_t currentGUID[255]; 56 | GUID guid = pNETCON_PROPERTIES->guidId; 57 | wsprintf(currentGUID, TEXT("{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}"), 58 | guid.Data1, guid.Data2, guid.Data3, 59 | guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], 60 | guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); 61 | 62 | if (wcscmp(currentGUID, pszDeviceUUID) == 0) 63 | { 64 | hr = pNC->Rename(NPCAP_LOOPBACK_INTERFACE_NAME); 65 | bFound = TRUE; 66 | if (hr != S_OK) 67 | { 68 | LogEvent(TEXT("failed to create rename NPCAP_LOOPBACK_INTERFACE_NAME\r\n")); 69 | } 70 | } 71 | 72 | pNC->Release(); 73 | } 74 | } 75 | VariantClear(&v); 76 | } 77 | pEnumValue->Release(); 78 | } 79 | pINetNsecc->Release(); 80 | } 81 | 82 | return bFound; 83 | } 84 | 85 | BOOL SetNetinterfaceNameById(WCHAR* pszDeviceUUID) 86 | { 87 | BOOL bSuccess = FALSE; 88 | /* CoInitialize (NULL);*/ 89 | 90 | // init security to enum RAS connections 91 | CoInitializeSecurity(NULL, -1, NULL, NULL, 92 | RPC_C_AUTHN_LEVEL_PKT, 93 | RPC_C_IMP_LEVEL_IMPERSONATE, 94 | NULL, EOAC_NONE, NULL); 95 | 96 | INetSharingManager * pINetNsm = NULL; 97 | HRESULT hr = ::CoCreateInstance(__uuidof(NetSharingManager), 98 | NULL, 99 | CLSCTX_ALL, 100 | __uuidof(INetSharingManager), 101 | (void**)&pINetNsm); 102 | if (!pINetNsm) { 103 | LogEvent(TEXT("failed to create NetSharingManager object\r\n")); 104 | return bSuccess; 105 | } 106 | else { 107 | 108 | // add a port mapping to every shared or firewalled connection. 109 | bSuccess = RenameNetinterfaceById(pINetNsm, pszDeviceUUID); 110 | 111 | pINetNsm->Release(); 112 | } 113 | 114 | /* CoUninitialize ();*/ 115 | return bSuccess; 116 | } 117 | 118 | 119 | VOID GetMacAddress(WCHAR* pszMacAddress, WCHAR* pszGuid) 120 | { 121 | PIP_ADAPTER_ADDRESSES sAddresses = NULL; 122 | PIP_ADAPTER_ADDRESSES sCurrAddr; 123 | ULONG nBufLen = 0; 124 | ULONG nError = GetAdaptersAddresses(AF_INET, NULL, NULL, NULL, &nBufLen); 125 | if (nError == ERROR_BUFFER_OVERFLOW) 126 | { 127 | sAddresses = (IP_ADAPTER_ADDRESSES*)HeapAlloc(GetProcessHeap(), 0, nBufLen); 128 | nError = GetAdaptersAddresses(AF_INET, NULL, NULL, sAddresses, &nBufLen); 129 | if (nError == ERROR_SUCCESS) 130 | { 131 | sCurrAddr = sAddresses; 132 | CHAR* pszGuidAnsi = NULL; 133 | pszGuidAnsi = new CHAR[wcslen(pszGuid) + 1]; 134 | UINT nConv = 0; 135 | wcstombs_s(&nConv, pszGuidAnsi, wcslen(pszGuid) + 1, pszGuid, _TRUNCATE); 136 | while (sCurrAddr != NULL) 137 | { 138 | if (_stricmp(sCurrAddr->AdapterName, pszGuidAnsi)) 139 | { 140 | sCurrAddr = sCurrAddr->Next; 141 | continue; 142 | } 143 | BYTE* a = sCurrAddr->PhysicalAddress; 144 | for (int i = 0; i < 5; i++) 145 | { 146 | wsprintf(pszMacAddress, TEXT("%02X:%02X:%02X:%02X:%02X:%02X"), 147 | a[0], a[1], a[2], a[3], a[4], a[5], a[6]); 148 | } 149 | break; 150 | } 151 | delete []pszGuidAnsi; 152 | } 153 | HeapFree(GetProcessHeap(), 0, sAddresses); 154 | } 155 | } 156 | 157 | DWORD GetAdapterFriendlyName(CHAR* pszAdapterName, WCHAR* pszFriendlyName, ULONG nMaxNameLength) 158 | { 159 | ULONG nOutBufLen = WORKING_BUFFER_SIZE; 160 | ULONG nIerations = 0; 161 | PIP_ADAPTER_ADDRESSES pAddresses = NULL; 162 | DWORD dwRet = 0; 163 | do { 164 | pAddresses = (IP_ADAPTER_ADDRESSES *)MALLOC(nOutBufLen); 165 | if (pAddresses == NULL) { 166 | LogEvent(TEXT("Error:%s"), TEXT("Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n")); 167 | return E_FAIL; 168 | } 169 | 170 | dwRet = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, NULL, pAddresses, &nOutBufLen); 171 | 172 | if (dwRet == ERROR_BUFFER_OVERFLOW) { 173 | FREE(pAddresses); 174 | pAddresses = NULL; 175 | return E_FAIL; 176 | } 177 | nIerations++; 178 | } while ((dwRet == ERROR_BUFFER_OVERFLOW) && (nIerations < MAX_TRIES)); 179 | 180 | PIP_ADAPTER_ADDRESSES pCurrAddresses = pAddresses; 181 | while (pCurrAddresses) { 182 | if (!lstrcmpA(pCurrAddresses->AdapterName, pszAdapterName)) { 183 | UINT friendly_name_length = lstrlenW(pCurrAddresses->FriendlyName); 184 | if (friendly_name_length < nMaxNameLength && friendly_name_length > 0) { 185 | lstrcpynW(pszFriendlyName, pCurrAddresses->FriendlyName, friendly_name_length + 1); 186 | if (pAddresses != NULL) { 187 | FREE(pAddresses); 188 | pAddresses = NULL; 189 | } 190 | return NOERROR; 191 | } 192 | } 193 | pCurrAddresses = pCurrAddresses->Next; 194 | } 195 | if (pAddresses != NULL) { 196 | FREE(pAddresses); 197 | pAddresses = NULL; 198 | } 199 | return E_FAIL; 200 | } 201 | 202 | 203 | VOID GetIpMacAddresses(WCHAR* pszIpAddress, WCHAR* pszMacAddress) 204 | { 205 | HKEY hkeyAdapters, hkeyAdapter, hkeyIp, hkeyIpg; 206 | DWORD i = 0; 207 | WCHAR arrcNetKey[] = TEXT("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"); 208 | WCHAR arrcTcpipKey[] = TEXT("SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\Interfaces"); 209 | WCHAR arrcSubkeyName[128]; 210 | WCHAR arrcComponentId[128]; 211 | WCHAR arrcGuid[39]; 212 | DWORD dwSubkeySize = 128; 213 | DWORD dwComponentSize = 128 * sizeof(WCHAR); 214 | DWORD dwGuidSize = 39 * sizeof(WCHAR); 215 | BOOL bIsAdapterFound = FALSE; 216 | 217 | // Clear the addresses 218 | wsprintf(pszIpAddress, TEXT("")); 219 | wsprintf(pszMacAddress, TEXT("")); 220 | 221 | // check if user select adapter manually by ad_option dialog 222 | WCHAR arrcTmpBuf[MAX_ADAPTER_NAME_LEN] = {0}; 223 | DWORD nBufLen = MAX_ADAPTER_NAME_LEN; 224 | WCHAR *pszStrtokBuf = NULL, *pAdapterId = NULL; 225 | const WCHAR s[4] = TEXT("_"); 226 | HKEY hkeyAdapterId; 227 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Happynet\\Parameters"), 228 | NULL, KEY_READ, &hkeyAdapterId) == ERROR_SUCCESS) 229 | { 230 | // Community 231 | GetRegString(hkeyAdapterId, TEXT("adapter"), arrcTmpBuf, nBufLen); 232 | pAdapterId = wcstok_s(arrcTmpBuf, s, &pszStrtokBuf); 233 | pAdapterId = wcstok_s(NULL, s, &pszStrtokBuf); 234 | RegCloseKey(hkeyAdapterId); 235 | } 236 | 237 | // First we need to find the TAP-Win32 adapter (identified by 'tap0901') and get its GUID 238 | RegOpenKeyEx(HKEY_LOCAL_MACHINE, arrcNetKey, NULL, KEY_READ, &hkeyAdapters); 239 | while (RegEnumKeyEx(hkeyAdapters, i, arrcSubkeyName, &dwSubkeySize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) 240 | { 241 | RegOpenKeyEx(hkeyAdapters, arrcSubkeyName, NULL, KEY_READ, &hkeyAdapter); 242 | RegQueryValueEx(hkeyAdapter, TEXT("ComponentId"), NULL, NULL, (LPBYTE)arrcComponentId, &dwComponentSize); 243 | RegQueryValueEx(hkeyAdapter, TEXT("NetCfgInstanceId"), NULL, NULL, (LPBYTE)arrcGuid, &dwGuidSize); 244 | RegCloseKey(hkeyAdapter); 245 | if ( 246 | // auto select adapter 247 | ((pAdapterId == NULL) && (!wcscmp(arrcComponentId, TEXT("tap0901")) || !wcscmp(arrcComponentId, TEXT("TAP0901")))) || 248 | // user select adapter manually by ad_option dialog 249 | ((pAdapterId != NULL) && (!wcscmp(arrcGuid, pAdapterId))) 250 | ) 251 | { 252 | bIsAdapterFound = true; 253 | break; 254 | } 255 | i++; 256 | dwSubkeySize = 128; 257 | } 258 | RegCloseKey(hkeyAdapters); 259 | 260 | // If we have the guid, fetch the IP address from the registry 261 | if (bIsAdapterFound) 262 | { 263 | DWORD dwDhcpEnabled = 0; 264 | DWORD nBufSize = sizeof(DWORD); 265 | DWORD nIpSize = 16 * sizeof(WCHAR); 266 | RegOpenKeyEx(HKEY_LOCAL_MACHINE, arrcTcpipKey, NULL, KEY_READ, &hkeyIp); 267 | RegOpenKeyEx(hkeyIp, arrcGuid, NULL, KEY_READ, &hkeyIpg); 268 | RegQueryValueEx(hkeyIpg, TEXT("EnableDHCP"), NULL, NULL, (LPBYTE)&dwDhcpEnabled, &nBufSize); 269 | if (dwDhcpEnabled) 270 | { 271 | RegQueryValueEx(hkeyIpg, TEXT("DhcpIPAddress"), NULL, NULL, (LPBYTE)pszIpAddress, &nIpSize); 272 | } 273 | else 274 | { 275 | RegQueryValueEx(hkeyIpg, TEXT("IPAddress"), NULL, NULL, (LPBYTE)pszIpAddress, &nIpSize); 276 | } 277 | RegCloseKey(hkeyIpg); 278 | RegCloseKey(hkeyIp); 279 | 280 | GetMacAddress(pszMacAddress, arrcGuid); 281 | } 282 | } 283 | 284 | BOOL ValidateIpv4Address(WCHAR* pszIpAddress) 285 | { 286 | WCHAR c; 287 | WCHAR arrcOctetValue[4]; 288 | arrcOctetValue[0] = 0; 289 | INT nOctets = 0; 290 | INT nOctetLen = 0; 291 | for (INT i = 0; i < (INT)wcslen(pszIpAddress); i++) 292 | { 293 | c = pszIpAddress[i]; 294 | if ((c < '0' || c > '9') && c != '.' && c != '/') return FALSE; 295 | if (c == '.' || c == '/') 296 | { 297 | if (nOctetLen < 1 || nOctetLen > 3) return FALSE; 298 | nOctets++; 299 | arrcOctetValue[nOctetLen] = 0; 300 | INT nOctetValue = _wtoi(arrcOctetValue); 301 | if (nOctetValue < 0 || nOctetValue > 255) return FALSE; 302 | if (nOctets > 3 && c != '/') return FALSE; 303 | nOctetLen = 0; 304 | continue; 305 | } 306 | arrcOctetValue[nOctetLen] = c; 307 | nOctetLen++; 308 | if (nOctetLen > 3) return FALSE; 309 | } 310 | nOctets++; 311 | if (nOctetLen < 1 || nOctetLen > 3 || (nOctets != 4 && nOctets != 5)) return FALSE; 312 | return TRUE; 313 | } 314 | 315 | BOOL ValidateMacAddress(WCHAR* pszMacAddress) 316 | { 317 | if (wcslen(pszMacAddress) != 17) return FALSE; 318 | WCHAR arrcMacAddressLower[18]; 319 | wcscpy_s(arrcMacAddressLower, 18, pszMacAddress); 320 | _wcslwr_s(arrcMacAddressLower, 18); 321 | WCHAR* w; 322 | for (INT i = 0; i < 6; i++) 323 | { 324 | w = arrcMacAddressLower + (i * 3); 325 | if ((w[0] < '0' || w[0] > '9') && (w[0] < 'a' || w[0] > 'f')) return FALSE; 326 | if ((w[1] < '0' || w[1] > '9') && (w[1] < 'a' || w[1] > 'f')) return FALSE; 327 | if (i != 5 && w[2] != ':') return FALSE; 328 | } 329 | return TRUE; 330 | } 331 | 332 | BOOL ValidateNumberRange(WCHAR* pNum, INT nMin, INT nMax) 333 | { 334 | INT v = _wtoi(pNum); 335 | if (nMin != -1 && v < nMin) return FALSE; 336 | if (nMax != -1 && v > nMax) return FALSE; 337 | return TRUE; 338 | } -------------------------------------------------------------------------------- /happynet/netinterface.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_NET_INTERFACE 2 | #define _H_NET_INTERfACE 3 | 4 | 5 | BOOL SetNetinterfaceNameById(WCHAR* pszDeviceUUID); 6 | DWORD GetAdapterFriendlyName(CHAR* pszAdapterName, WCHAR* pszFriendlyName, ULONG nMaxNameLength); 7 | VOID GetMacAddress(WCHAR* pszMacAddress, WCHAR* pszGuid); 8 | VOID GetIpMacAddresses(WCHAR* pszIpAddress, WCHAR* pszMacAddress); 9 | BOOL ValidateIpv4Address(WCHAR* pszIpAddress); 10 | BOOL ValidateMacAddress(WCHAR* pszMacAddress); 11 | BOOL ValidateNumberRange(WCHAR* pNum, INT nMin, INT nMax); 12 | 13 | #endif -------------------------------------------------------------------------------- /happynet/process.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "registry.h" 7 | #include "process.h" 8 | #include "service.h" 9 | #include "utils.h" 10 | 11 | #pragma comment(lib, "ws2_32.lib") 12 | 13 | 14 | static HANDLE m_hChildStdoutRead = NULL; 15 | static HANDLE m_hChildStdoutWrite = NULL; 16 | static HANDLE m_hInputFile = NULL; 17 | static HANDLE m_hProcess = NULL; 18 | static HANDLE m_hThread = NULL; 19 | static DWORD m_dwProcessId = 0; 20 | 21 | 22 | static INT SendStopSig(UINT nEdgeManagerPort) 23 | { 24 | WORD wVersionRequested; 25 | WSADATA wsaData; 26 | INT err; wVersionRequested = MAKEWORD( 1, 1 ); 27 | err = WSAStartup( wVersionRequested, &wsaData ); 28 | if (err != 0) { 29 | return -1; 30 | } 31 | if (LOBYTE( wsaData.wVersion ) != 1 || HIBYTE( wsaData.wVersion ) != 1) { 32 | WSACleanup( ); 33 | return -1; 34 | } 35 | SOCKET sockClient = socket(AF_INET , SOCK_DGRAM , 0) ; 36 | SOCKADDR_IN sockServerAddr; 37 | sockServerAddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1"); 38 | sockServerAddr.sin_family = AF_INET; 39 | sockServerAddr.sin_port = htons(nEdgeManagerPort); 40 | CHAR szSendBuf[8] = "stop"; 41 | INT nLen = sizeof(SOCKADDR); 42 | sendto(sockClient, szSendBuf, strlen(szSendBuf), 0, (SOCKADDR*)&sockServerAddr, nLen); 43 | closesocket(sockClient) ; 44 | WSACleanup(); 45 | return 0; 46 | } 47 | 48 | 49 | // Create a child process that uses the previously created pipes for STDIN and STDOUT. 50 | HANDLE CreateProcessService(WCHAR* pszCmdLine) 51 | { 52 | // Set the bInheritHandle flag so pipe handles are inherited. 53 | SECURITY_ATTRIBUTES saAttr; 54 | //ZeroMemory(&sa_attr, sizeof(STARTUPINFO)); 55 | saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); 56 | saAttr.bInheritHandle = TRUE; 57 | saAttr.lpSecurityDescriptor = NULL; 58 | 59 | // Create a pipe for the child process's STDOUT. 60 | if (!CreatePipe(&m_hChildStdoutRead, &m_hChildStdoutWrite, &saAttr, 0) ) 61 | GetProcessServiceError(TEXT("StdoutRd CreatePipe")); 62 | 63 | // Ensure the read handle to the pipe for STDOUT is not inherited. 64 | if (!SetHandleInformation(m_hChildStdoutRead, HANDLE_FLAG_INHERIT, 0) ) 65 | GetProcessServiceError(TEXT("Stdout SetHandleInformation")); 66 | 67 | BOOL bSuccess = FALSE; 68 | PROCESS_INFORMATION piProcessInfo; 69 | // Set up members of the PROCESS_INFORMATION structure. 70 | ZeroMemory( &piProcessInfo, sizeof(PROCESS_INFORMATION) ); 71 | 72 | 73 | // Set up members of the STARTUPINFO structure. 74 | STARTUPINFO siStartInfo; 75 | ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) ); 76 | siStartInfo.cb = sizeof(STARTUPINFO); 77 | siStartInfo.hStdError = m_hChildStdoutWrite; 78 | siStartInfo.hStdOutput = m_hChildStdoutWrite; 79 | siStartInfo.hStdInput = NULL; 80 | siStartInfo.dwFlags |= STARTF_USESTDHANDLES; 81 | 82 | // Create the child process. 83 | bSuccess = CreateProcess(NULL, 84 | pszCmdLine, // command line 85 | &saAttr, // process security attributes 86 | NULL, // primary thread security attributes 87 | TRUE, // handles are inherited 88 | //CREATE_NO_WINDOW|CREATE_DEFAULT_ERROR_MODE|CREATE_UNICODE_ENVIRONMENT|CREATE_NEW_CONSOLE, 89 | CREATE_NO_WINDOW|CREATE_DEFAULT_ERROR_MODE|CREATE_UNICODE_ENVIRONMENT|CREATE_NEW_PROCESS_GROUP, 90 | NULL, // use parent's environment 91 | NULL, // use parent's current directory 92 | &siStartInfo, // STARTUPINFO pointer 93 | &piProcessInfo); // receives PROCESS_INFORMATION 94 | 95 | // If an error occurs, exit the application. 96 | if (!bSuccess) { 97 | GetProcessServiceError(TEXT("create_service_process")); 98 | } else { 99 | // Close handles to the child process and its primary thread. 100 | // Some applications might keep these handles to monitor the status 101 | // of the child process, for example. 102 | } 103 | 104 | m_hProcess = piProcessInfo.hProcess; 105 | m_dwProcessId = piProcessInfo.dwProcessId; 106 | m_hThread = piProcessInfo.hThread; 107 | return piProcessInfo.hProcess; 108 | } 109 | 110 | VOID GraceStopProcessService(VOID) 111 | { 112 | DWORD dwEdgeManagerPort = 0; 113 | 114 | HKEY hkey; 115 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Happynet\\Parameters"), 116 | NULL, KEY_READ, &hkey) != ERROR_SUCCESS) { 117 | dwEdgeManagerPort = 0; 118 | } else { 119 | GetRegDword(hkey, L"local_port", &dwEdgeManagerPort); 120 | } 121 | 122 | if(dwEdgeManagerPort == 0) { 123 | dwEdgeManagerPort = 5644; 124 | } 125 | if (m_hProcess != NULL && m_dwProcessId) { 126 | u_short edge_manager_port = (u_short)(dwEdgeManagerPort); 127 | //CreateThread(NULL, 0, send_sig_stop, &edge_manager_port, 0, NULL); 128 | if (SendStopSig(edge_manager_port) != 0) { 129 | LogEvent(L"%s:%d (%s) - send sig to stop edge socket error.\n", __FILEW__, __LINE__, __FUNCTIONW__); 130 | } 131 | } else { 132 | LogEvent(L"%s:%d (%s) - Failed to stop or had been stopped.\n", __FILEW__, __LINE__, __FUNCTIONW__); 133 | } 134 | return; 135 | } 136 | 137 | VOID TerminalProcessService(VOID) 138 | { 139 | if (m_hProcess != NULL && m_dwProcessId) { 140 | //HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, m_dwprocess_id); 141 | if(TerminateProcess(m_hProcess, PROCESS_EXIT_CODE)) { 142 | // 500 ms timeout; use INFINITE for no timeout 143 | const DWORD result = WaitForSingleObject(m_hProcess, INFINITE); 144 | if (result == WAIT_OBJECT_0) { 145 | // Success 146 | CloseHandle(m_hProcess); 147 | CloseHandle(m_hThread); 148 | m_hThread = NULL; 149 | m_hProcess = NULL; 150 | m_dwProcessId = 0; 151 | m_hChildStdoutRead = NULL; 152 | m_hChildStdoutWrite = NULL; 153 | } 154 | else { 155 | // Timed out or an error occurred 156 | LogEvent(L"%s:%d (%s) - Failed to WatiForSingleObject.\n", __FILEW__, __LINE__, __FUNCTIONW__); 157 | } 158 | } else { 159 | LogEvent(L"%s:%d (%s) - Process had been stopped.\n", __FILEW__, __LINE__, __FUNCTIONW__); 160 | } 161 | } 162 | } 163 | 164 | 165 | DWORD GetProcessServiceStatus(VOID) 166 | { 167 | //if( STILL_ACTIVE == dwMark) //running 168 | //if( PROCESS_EXIT_CODE == dwMark) //stopped 169 | 170 | DWORD dwMark = PROCESS_EXIT_CODE; 171 | if (m_hProcess != NULL) { 172 | //HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, m_dwprocess_id); 173 | GetExitCodeProcess(m_hProcess, &dwMark); 174 | } 175 | 176 | if (dwMark > PROCESS_EXIT_CODE && dwMark != STILL_ACTIVE){ 177 | dwMark = PROCESS_EXIT_CODE; 178 | } 179 | return dwMark; 180 | } 181 | 182 | 183 | // Read output from the child process's pipe for STDOUT 184 | // and write to the parent process's pipe for STDOUT. 185 | // Stop when there is no more data. 186 | void GetProcessServiceOutput(WCHAR *pszReadBuf) 187 | { 188 | if (!m_hChildStdoutRead) { 189 | return; 190 | } 191 | DWORD dwRead; 192 | CHAR chbuf[PROCESS_STDOUT_BUFSIZE] = { 0 }; 193 | BOOL bsuccess = FALSE; 194 | HANDLE hparent_stdout = GetStdHandle(STD_OUTPUT_HANDLE); 195 | 196 | bsuccess = ReadFile( m_hChildStdoutRead, chbuf, PROCESS_STDOUT_BUFSIZE-1, &dwRead, NULL); 197 | if (!bsuccess || dwRead == 0) { 198 | return; 199 | } 200 | //Convert char* string to a wchar_t* string. 201 | UINT convertedChars = 0; 202 | UINT newsize = strlen(chbuf) + 1; 203 | if (newsize > PROCESS_STDOUT_BUFSIZE) { 204 | newsize = PROCESS_STDOUT_BUFSIZE; 205 | } 206 | mbstowcs_s(&convertedChars, pszReadBuf, newsize, chbuf, _TRUNCATE); 207 | //Display the result and indicate the type of string that it is. 208 | LogEvent(TEXT("%s\n"), pszReadBuf); 209 | } 210 | 211 | 212 | 213 | // Format a readable error message, display a message box, 214 | // and exit from the application. 215 | VOID GetProcessServiceError(PTSTR lpszFunction) 216 | { 217 | LPVOID lpMsgBuf; 218 | LPVOID lpDisplayBuf; 219 | DWORD dw = GetLastError(); 220 | 221 | FormatMessage( 222 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 223 | FORMAT_MESSAGE_FROM_SYSTEM | 224 | FORMAT_MESSAGE_IGNORE_INSERTS, 225 | NULL, 226 | dw, 227 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 228 | (LPTSTR) &lpMsgBuf, 229 | 0, NULL ); 230 | 231 | lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, 232 | (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR)); 233 | StringCchPrintf((LPTSTR)lpDisplayBuf, 234 | LocalSize(lpDisplayBuf) / sizeof(TCHAR), 235 | TEXT("%s failed with error %d: %s"), 236 | lpszFunction, dw, lpMsgBuf); 237 | MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK); 238 | 239 | LocalFree(lpMsgBuf); 240 | LocalFree(lpDisplayBuf); 241 | } 242 | -------------------------------------------------------------------------------- /happynet/process.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_PROCESS 2 | #define _H_PROCESS 3 | 4 | #include 5 | 6 | #define PROCESS_STDOUT_BUFSIZE 4096 7 | #define PROCESS_EXIT_CODE 0 8 | 9 | HANDLE CreateProcessService(WCHAR* pszCmdLine); 10 | VOID TerminalProcessService(VOID); 11 | VOID GraceStopProcessService(VOID); 12 | DWORD GetProcessServiceStatus(VOID); 13 | VOID GetProcessServiceError(PTSTR lpszFunction); 14 | VOID GetProcessServiceOutput(WCHAR *pszReadBuf); 15 | 16 | 17 | #endif -------------------------------------------------------------------------------- /happynet/registry.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "registry.h" 3 | 4 | INT GetRegDword(HKEY hkey, LPWSTR pszValueName, LPDWORD lpdwRetValue) 5 | { 6 | // Fetch DWORD value from registry 7 | DWORD buf_size = sizeof(DWORD); 8 | if (RegQueryValueEx(hkey, pszValueName, NULL, NULL, (LPBYTE)lpdwRetValue, &buf_size) != ERROR_SUCCESS) 9 | { 10 | *lpdwRetValue = 0; 11 | return 0; 12 | } 13 | return 1; 14 | } 15 | 16 | INT GetRegString(HKEY hkey, LPWSTR pszValueName, LPWSTR pszRetValue, DWORD dwBufSize) 17 | { 18 | // Fetch string value from registry 19 | if (RegQueryValueEx(hkey, pszValueName, NULL, NULL, (LPBYTE)pszRetValue, &dwBufSize) != ERROR_SUCCESS) 20 | { 21 | return 0; 22 | } 23 | return 1; 24 | } 25 | 26 | INT SetRegDword(HKEY hkey, LPWSTR pszValueName, DWORD dwValue) 27 | { 28 | // Set DWORD value in registry 29 | if (RegSetValueEx(hkey, pszValueName, NULL, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD)) != ERROR_SUCCESS) 30 | { 31 | return 0; 32 | } 33 | return 1; 34 | } 35 | 36 | INT SetRegString(HKEY hkey, LPWSTR pszValueName, LPWSTR pszValueString) 37 | { 38 | DWORD data_len = (wcslen(pszValueString) + 1) * sizeof(WCHAR); 39 | // Set string value in registry 40 | if (RegSetValueEx(hkey, pszValueName, NULL, REG_SZ, (LPBYTE)pszValueString, data_len) != ERROR_SUCCESS) 41 | { 42 | return 0; 43 | } 44 | return 1; 45 | } 46 | 47 | BOOL IsSetSystemService(VOID) 48 | { 49 | DWORD dword_buf; 50 | HKEY hkey; 51 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Happynet\\Parameters"), NULL, KEY_READ, &hkey) != ERROR_SUCCESS) 52 | { 53 | return FALSE; 54 | } 55 | // system_service 56 | GetRegDword(hkey, TEXT("system_service"), &dword_buf); 57 | RegCloseKey(hkey); 58 | 59 | return dword_buf != 0; 60 | } 61 | 62 | BOOL IsSetAutoStart(VOID) 63 | { 64 | DWORD dword_buf; 65 | HKEY hkey; 66 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Happynet\\Parameters"), NULL, KEY_READ, &hkey) != ERROR_SUCCESS) 67 | { 68 | return FALSE; 69 | } 70 | // auto_start 71 | GetRegDword(hkey, TEXT("auto_start"), &dword_buf); 72 | RegCloseKey(hkey); 73 | 74 | return dword_buf != 0; 75 | } 76 | 77 | BOOL IsSetAutoTray(VOID) 78 | { 79 | DWORD dword_buf; 80 | HKEY hkey; 81 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Happynet\\Parameters"), NULL, KEY_READ, &hkey) != ERROR_SUCCESS) 82 | { 83 | return FALSE; 84 | } 85 | // auto_tray 86 | GetRegDword(hkey, TEXT("auto_tray"), &dword_buf); 87 | RegCloseKey(hkey); 88 | 89 | return dword_buf != 0; 90 | } 91 | -------------------------------------------------------------------------------- /happynet/registry.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_REGISTRY 2 | #define _H_REGISTRY 3 | 4 | INT GetRegDword(HKEY hkey, LPWSTR pszValueName, LPDWORD lpdwRetValue); 5 | INT GetRegString(HKEY hkey, LPWSTR pszValueName, LPWSTR pszRetValue, DWORD dwBufSize); 6 | INT SetRegDword(HKEY hkey, LPWSTR pszValueName, DWORD dwValue); 7 | INT SetRegString(HKEY hkey, LPWSTR pszValueName, LPWSTR pszValueString); 8 | BOOL IsSetSystemService(VOID); 9 | BOOL IsSetAutoStart(VOID); 10 | BOOL IsSetAutoTray(VOID); 11 | 12 | #endif -------------------------------------------------------------------------------- /happynet/res.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/happynet/res.rc -------------------------------------------------------------------------------- /happynet/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/happynet/resource.h -------------------------------------------------------------------------------- /happynet/service.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "atlbase.h" 5 | #include "atlstr.h" 6 | 7 | #include "netinterface.h" 8 | #include "service.h" 9 | #include "registry.h" 10 | #include "process.h" 11 | #include "systemsrv.h" 12 | #include "utils.h" 13 | 14 | HANDLE m_pid; 15 | 16 | DWORD GetHappynetServiceStatus(VOID) 17 | { 18 | //if( STILL_ACTIVE == dwMark) //running 19 | //if( PROCESS_EXIT_CODE == dwMark) //stopped 20 | if (IsSetSystemService()) { 21 | return GetSystemServiceStatus(); 22 | } 23 | return GetProcessServiceStatus(); 24 | } 25 | 26 | VOID StartHappynetService(VOID) 27 | { 28 | if (IsSetSystemService()) { 29 | // re reg system service args 30 | RegSystemService(); 31 | SetArgsSystemService(); 32 | StartSystemService(); 33 | return; 34 | } 35 | 36 | WCHAR dir_path[MAX_PATH] = { 0 }; 37 | WCHAR command_line[MAX_COMMAND_LINE_LEN] = { 0 }; 38 | if (GetHappynetServiceStatus() == STILL_ACTIVE) { 39 | return; 40 | } 41 | 42 | // Build path and command line parameters 43 | if (!GetInstallDirPath(dir_path, MAX_PATH)) 44 | { 45 | LogEvent(TEXT("%s:%d (%s) - Error building executable path.\n"), 46 | __FILEW__, __LINE__, __FUNCTIONW__); 47 | return; 48 | } 49 | INT ret = 0; 50 | 51 | ret = GetEdgeCmdLine(dir_path, command_line, MAX_COMMAND_LINE_LEN); 52 | 53 | LogEvent(TEXT("%s:%d (%s) - building command line: %s \n"), 54 | __FILEW__, __LINE__, __FUNCTIONW__, command_line); 55 | LogEvent(TEXT("\n->Start of parent execution.\n")); 56 | 57 | // Create the child process. 58 | CreateProcessService(command_line); 59 | } 60 | 61 | VOID StopHappynetService(VOID) 62 | { 63 | if (IsSetSystemService()) { 64 | StopSystemService(); 65 | Sleep(1500); 66 | return; 67 | } 68 | 69 | GraceStopProcessService(); 70 | Sleep(1500); 71 | TerminalProcessService(); 72 | } 73 | 74 | // auto start exe when system startup 75 | VOID SetHappynetServiceAutoStart(VOID) 76 | { 77 | if (IsSetSystemService()) { 78 | SetSystemServiceAutoStart(); 79 | } 80 | 81 | HKEY hkey; 82 | WCHAR ret_val[512]; 83 | //std::string strRegPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; 84 | 85 | //open system auto run regedit item 86 | if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &hkey) == ERROR_SUCCESS) 87 | { 88 | //get exe path 89 | TCHAR str_exe_fulldir[MAX_PATH]; 90 | GetModuleFileName(NULL, str_exe_fulldir, MAX_PATH); 91 | 92 | //check if regedit item exists 93 | TCHAR str_dir[MAX_PATH] = {}; 94 | DWORD nLength = MAX_PATH; 95 | 96 | //already exist 97 | if (!GetRegString(hkey, L"Happynet", ret_val, 512) || _tcscmp(str_exe_fulldir, str_dir) != 0) 98 | { 99 | //append child Key and set value:"happynet" is exe name 100 | RegSetValueEx(hkey, TEXT("Happynet"), 0, REG_SZ, (LPBYTE)str_exe_fulldir, (lstrlen(str_exe_fulldir)+1)*sizeof(TCHAR)); 101 | 102 | //close regedit 103 | RegCloseKey(hkey); 104 | } 105 | } 106 | } 107 | 108 | 109 | //cancle auto start 110 | VOID UnsetHappynetServiceAutoStart(VOID) 111 | { 112 | if (IsSetSystemService()) { 113 | UnsetSystemServiceAutoStart(); 114 | } 115 | 116 | HKEY hkey; 117 | //std::string strRegPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; 118 | 119 | if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &hkey) == ERROR_SUCCESS) 120 | { 121 | RegDeleteValue(hkey, TEXT("Happynet")); 122 | RegCloseKey(hkey); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /happynet/service.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_SERVICE 2 | #define _H_SERVICE 3 | 4 | DWORD GetHappynetServiceStatus(VOID); 5 | VOID StartHappynetService(VOID); 6 | VOID StopHappynetService(VOID); 7 | VOID SetHappynetServiceAutoStart(VOID); 8 | VOID UnsetHappynetServiceAutoStart(VOID); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /happynet/sinstance.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Module : sinstance.cpp 3 | Purpose: Defines the implementation for an C++ wrapper class to do instance checking 4 | Created: PJN / 29-07-1998 5 | History: PJN / 25-03-2000 Neville Franks made the following changes. Contact nevf@getsoft.com, www.getsoft.com 6 | 1. Changed #pragma error to #pragma message. Former wouldn't compile under VC6 7 | 2. Replaced above #pragma with #include 8 | 3. Added TrackFirstInstanceRunning(), MakeMMFFilename() 9 | PJN / 27-03-2000 1. Fixed a potential handle leak where the file handle m_hPrevInstance was not being 10 | closed under certain circumstances. 11 | Neville Franks made the following changes. Contact nevf@getsoft.com, www.getsoft.com 12 | 2. Split PreviousInstanceRunning() up into separate functions so we 13 | can call it without needing the MainFrame window. 14 | 3. Changed ActivatePreviousInstance() to return hWnd. 15 | PJN / 15-05-2000 1. Serialized access to all of the CSingleInstance class to prevent race conditions 16 | which can occur when you app is programatically spawned. 17 | PJN / 17-05-2000 1. Updated sample to show how the code can be used for dialog based apps. 18 | PJN / 01-01-2001 1. Added a number of asserts to CInstanceChecker::ActivatePreviousInstance 19 | 2. Now includes copyright message in the source code and documentation. 20 | PJN / 15-01-2001 1. Now allows multiple calls to PreviousInstanceRunning without ASSERTing 21 | 2. Removed some unnecessary VERIFY's from ActivatePreviousInstance 22 | 3. Made the MMF filename used modifiable via a virtual function GetMMFFilename 23 | 4. Made the window to track modifiable via a virtual function GetWindowToTrack 24 | 5. Made destructor virtual since the introduction of other virtual functions in the class 25 | 6. Removed a number of unnecessary verifies 26 | 7. Changed the meaning of the return value from TrackFirstInstanceRunning 27 | PJN / 17-06-2001 1. Moved most of the code from CInstanceChecker::CInstanceChecker to 28 | CInstanceChecker::ActivateChecker. This allows client code to turn on or off the instance 29 | checking code easily. Thanks to Anders Rundegren for this addition. 30 | PJN / 31-08-2001 1. made the name of the mutex which the class uses to serialize access to itself a paramter 31 | to the constructor. That way multiple independent apps do not block each other while 32 | they are calling into the CSingleInstance class. Thanks to Eugene Shmelyov for spotting 33 | this problem. 34 | PJN / 23-03-2002 1. Provided a QuitPreviousInstance method. Thanks to Jon Bennett for providing this. 35 | PJN / 30-10-2002 1. The name of the internal memory mapped file is now based on the Mutex name rather than 36 | the application name. An example: a client was writing a webcam application and wanted it to 37 | run with multiple configuration for multiple camera support. So the app can run multiple times 38 | as long as a special configuration is given on the command line. But for that configuration 39 | only one instance is allowed. Using the application name for the memory mapped file was tying 40 | the single instance to the app rather than the unique mutex name. Thanks to Frank Fesevur for 41 | this nice update. 42 | PJN / 06-02-2003 1. Was missing a call to ReleaseLock in CInstanceChecker::ActivatePreviousInstance. Thanks to 43 | Pierrick Ingels for reporting this problem. 44 | PJN / 09-05-2004 1. Updated the copyright details. 45 | 2. Extended CInstanceChecker::ActivatePreviousInstance to now allow the command line of the 46 | second app to be passed to the original app. By default the parameter is null, meaning that 47 | you get the original behaviour which just activates the previous instance. To respond to this 48 | information you should add the following to your mainfrm module: 49 | 50 | mainfrm.h 51 | 52 | afx_msg LRESULT OnCopyData(WPARAM, LPARAM); 53 | 54 | 55 | mainfrm.cpp 56 | 57 | LRESULT CMyFrameWnd::OnCopyData(WPARAM wParam, LPARAM lParam) 58 | { 59 | COPYDATASTRUCT* pCDS = reinterpret_cast(lParam); 60 | TCHAR* pszCmdLine = static_cast(pCDS->lpData); 61 | if (pszCmdLine) 62 | { 63 | //DO SOMETHING with pszCmdLine here such as call AfxGetApp()->OpenDocumentFile(pszCmdLine); 64 | } 65 | return TRUE; 66 | } 67 | 68 | Also hook up your onCopyData to the windows message map using 69 | 70 | ON_MESSAGE(WM_COPYDATA, OnCopyData) 71 | 72 | 73 | Thanks to Ingo H. de Boer for providing this nice update. 74 | 75 | 3. Following a discussion on the Codeproject.com discussion forum for CSingleInstance on what 76 | exactly a single instance app means, Daniel Lohmann has produced a simple function called CreateUniqueName 77 | which given a number of settings as flags, will produce a name which is unique. You can then use this name 78 | in the constructor for CInstanceChecker. The concept of a single instance app is complicated by the concept 79 | of Window stations and desktops as used by NT Services and Windows Terminal Services. In addition you might 80 | want to allow your program to be run once per user. 81 | PJN / 30-05-2005 1. Fix for a crash where CWnd::GetLastActivePopup can sometimes return a null pointer. Thanks to 82 | Dominik Reichl for reporting this bug. 83 | PJN / 07-07-2006 1. Updated copyright details. 84 | 2. Addition of CSINGLEINSTANCE_EXT_CLASS and CSINGLEINSTANCE_EXT_API which allows the class to be easily used 85 | in an extension DLL. 86 | 3. Removed derivation from CObject as it was not really needed. 87 | 4. Updated the documentation to use the same style as the web site. 88 | 5. Code now uses newer C++ style casts instead of C style casts. 89 | 6. Fixed a number of level 4 warnings in the sample app. 90 | 7. Updated code to compile cleanly using VC 2005. 91 | PJN / 17-03-2007 1. Updated copyright details. 92 | 2. Optimized _INSTANCE_DATA constructor code 93 | 3. Reworked how the method CInstanceChecker::GetMMFFilename creates the name of the memory mapped filename 94 | the code requires for sharing. Now the main instance name appears before the hard coded string. This 95 | ensures that the CInstanceChecker class works correctly for terminal sessions i.e. kernel objects prefixed 96 | with the value "Local\". Thanks to Mathias Berchtold for reporting this issue. 97 | 4. Updated the sample app code to clean compile on VC 2005 98 | 5. QuitPreviousInstance now uses GetLastActivePopup API to ensure it posts the WM_QUIT message to the 99 | correct window of the previous instance. 100 | PJN / 02-02-2008 1. Updated copyright details 101 | 2. Removed VC 6 style classwizard comments from the sample apps code 102 | 3. Updated ActivatePreviousInstance method to support Win64 compliant data 103 | 4. ActivatePreviousInstance now takes a "dwTimeout" parameter which it now uses internally as the timeout when 104 | calling SendMessageTimeout instead of SendMessage. The code now uses SendMessageTimeout instead of SendMessage 105 | to ensure we do not hang if the previous instance itself is hung. Thanks to Paul Shore for suggesting this 106 | update. 107 | 5. Updated the sample apps to clean compile on VC 2008 108 | PJN / 04-03-2016 1. Updated copyright details. 109 | 2. Update the sample app project settings to more modern defaults. 110 | 3. Update the code to clean compile on VC 2010 - 2015 111 | 4. Added SAL annotations to all the code. 112 | 5. CInstanceChecker::PreviousInstanceRunning now uses FILE_MAP_READ flag when attempting to open the file 113 | mapping 114 | 6. The ActivatePreviousInstance method now includes a new HWND hSender parameter. 115 | 7. The sample app which uses a MFC CFrameWnd now shows some text in the client area to tell end-users 116 | what to do to exercise the code. 117 | 8. After updating the instructions on how to use the class, the code which referenced an internal 118 | _SINSTANCE_DATA global static instance has been refactored back into the main CInstanceChecker class 119 | 9. CInstanceChecker::TrackFirstInstanceRunning now takes a HWND hWindowToTrack parameter. This parameter 120 | now eliminates the need for the GetWindowToTrack method. 121 | 10. Reworked the internals of the CInstanceChecker class to avoid use of MFC. Instead now all the class uses 122 | ATL replacements for equivalent MFC functionality. 123 | 11. Reworked the internals of the QuitPreviousInstance method. 124 | 12. Removed the need for the ActivateChecker and GetMMFFilename methods. 125 | 13. The structure which is put into the memory mapped file now is 8 bytes in size. This is to allow 126 | interop between Win32 and Win64 instances of the same application. 127 | 14. Refactored the code in ActivatePreviousInstance & QuitPreviousInstance which finds the previous HWND into 128 | a new FindPreviousHWND method. 129 | 15. Reworked the code which serializes access to all instances of CInstanceChecker and in the process removed 130 | the need for the mutex which protects the memory mapped file. 131 | PJN / 30-10-2017 1. Updated copyright details 132 | 2. Replaced NULL with nullptr throughout the codebase. This means that the code now 133 | requires VC 2010 at a minimum to compile. 134 | 3. Replaced BOOL throughout the codebase with bool. 135 | 4. Fixed problems with the code when the _ATL_NO_AUTOMATIC_NAMESPACE define is used. Thanks to Victor Derks 136 | for reporting this issue. 137 | PJN / 15-07-2018 1. Updated copyright details 138 | 2. Fixed a number of C++ core guidelines compiler warnings. These changes mean that 139 | the code will now only compile on VC 2017 or later. 140 | PJN / 02-09-2018 1. Fixed a number of compiler warnings when using VS 2017 15.8.2 141 | PJN / 02-06-2019 1. Updated copyright details. 142 | 2. Updated the code to clean compile on VC 2019 143 | PJN / 21-09-2019 1. Fixed a number of compiler warnings when the code is compiled with VS 2019 Preview 144 | PJN / 17-03-2020 1. Updated copyright details. 145 | 2. Fixed more Clang-Tidy static code analysis warnings in the code. 146 | PJN / 09-03-2022 1. Updated copyright details 147 | 2. Updated the code to use C++ uniform initialization for all variable declarations. 148 | 149 | Copyright (c) 1996 - 2022 by PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com) 150 | 151 | All rights reserved. 152 | 153 | Copyright / Usage Details: 154 | 155 | You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 156 | when your product is released in binary form. You are allowed to modify the source code in any way you want 157 | except you cannot modify the copyright details at the top of each module. If you want to distribute source 158 | code with your application, then you are only allowed to distribute versions released by the author. This is 159 | to maintain a single distribution point for the source code. 160 | 161 | */ 162 | 163 | 164 | /////////////////////////// Includes ////////////////////////////////////////// 165 | 166 | #include "sinstance.h" 167 | 168 | 169 | /////////////////////////// Implementation //////////////////////////////////// 170 | 171 | //The struct which we put into the MMF 172 | struct CWindowInstance 173 | { 174 | unsigned __int64 hMainWnd; 175 | }; 176 | 177 | 178 | CInstanceChecker::CInstanceChecker(_In_z_ LPCTSTR pszUniqueName) : m_sName{pszUniqueName} 179 | { 180 | } 181 | 182 | #pragma warning(suppress: 26461) 183 | _Return_type_success_(return != false) bool CInstanceChecker::TrackFirstInstanceRunning(_In_ HWND hWindowToTrack) 184 | { 185 | //Create the mutex to serialize access to all instances of CInstanceChecker if required 186 | if (!CreateExecuteMutexIfNecessary()) 187 | return false; 188 | 189 | //Serialize access using the execute mutex 190 | ATL::CMutexLock ExecuteLock{m_ExecuteMutex, true}; 191 | 192 | //First create the MMF if required 193 | constexpr const int nMMFSize{sizeof(CWindowInstance)}; 194 | if (m_MMF == nullptr) 195 | { 196 | #pragma warning(suppress: 26477) 197 | ATLASSERT(m_sName.GetLength()); //Validate our parameter 198 | 199 | HANDLE hMMF{CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, nMMFSize, m_sName)}; 200 | if (hMMF == nullptr) 201 | { 202 | ATLTRACE(_T("CInstanceChecker::TrackFirstInstanceRunning, Failed in call to CreateFileMapping, Error:%u\n"), GetLastError()); 203 | return false; 204 | } 205 | m_MMF.Attach(hMMF); 206 | } 207 | 208 | //Open the MMF for writing 209 | auto pInstanceData{static_cast(MapViewOfFile(m_MMF, FILE_MAP_WRITE, 0, 0, nMMFSize))}; 210 | if (pInstanceData == nullptr) 211 | { 212 | ATLTRACE(_T("CInstanceChecker::TrackFirstInstanceRunning, Failed in call to MapViewOfFile, Error:%u\n"), GetLastError()); 213 | m_MMF.Close(); 214 | return false; 215 | } 216 | 217 | //Update the data in the MMF with the window handle we are to track 218 | #pragma warning(suppress: 26490) 219 | pInstanceData->hMainWnd = reinterpret_cast(hWindowToTrack); 220 | 221 | //Close the MMF 222 | if (!UnmapViewOfFile(pInstanceData)) 223 | { 224 | ATLTRACE(_T("CInstanceChecker::TrackFirstInstanceRunning, Failed in call to UnmapViewOfFile, Error:%u\n"), GetLastError()); 225 | m_MMF.Close(); 226 | return false; 227 | } 228 | 229 | return true; 230 | } 231 | 232 | _Return_type_success_(return != false) bool CInstanceChecker::PreviousInstanceRunning() 233 | { 234 | //Validate our parameters 235 | #pragma warning(suppress: 26477) 236 | ATLASSERT(m_sName.GetLength()); 237 | 238 | //Create the mutex to serialize access to all instances of CInstanceChecker if required 239 | if (!CreateExecuteMutexIfNecessary()) 240 | return false; 241 | 242 | //Serialize access using the execute mutex 243 | ATL::CMutexLock ExecuteLock{m_ExecuteMutex, true}; 244 | 245 | //Try to open the MMF first to see if we have an instance already running 246 | HANDLE hPrevInstance{OpenFileMapping(FILE_MAP_READ, FALSE, m_sName)}; 247 | const bool bPreviousInstance{hPrevInstance != nullptr}; 248 | if (hPrevInstance) 249 | CloseHandle(hPrevInstance); 250 | 251 | return bPreviousInstance; 252 | } 253 | 254 | ATL::CAtlString CInstanceChecker::GetExecuteMutexName() 255 | { 256 | ATL::CAtlString sExecuteMutexName{m_sName}; 257 | sExecuteMutexName += _T("_CInstanceChecker_XMUTEX"); 258 | return sExecuteMutexName; 259 | } 260 | 261 | _Return_type_success_(return != false) bool CInstanceChecker::CreateExecuteMutexIfNecessary() 262 | { 263 | if (m_ExecuteMutex == nullptr) 264 | { 265 | if (!m_ExecuteMutex.Create(nullptr, FALSE, GetExecuteMutexName())) 266 | { 267 | ATLTRACE(_T("CInstanceChecker::CreateExecuteMutexIfNecessary, Failed in call to create execute mutex, Error:%u\n"), GetLastError()); 268 | return false; 269 | } 270 | } 271 | 272 | return true; 273 | } 274 | 275 | _Return_type_success_(return != false) bool CInstanceChecker::FindPreviousHWND(_Out_ HWND& hPrevWnd) 276 | { 277 | //Validate our parameters 278 | #pragma warning(suppress: 26477) 279 | ATLASSERT(m_sName.GetLength()); 280 | 281 | //Create the mutex to serialize access to all instances of CInstanceChecker if required 282 | if (!CreateExecuteMutexIfNecessary()) 283 | return false; 284 | 285 | //Serialize access using the execute mutex 286 | ATL::CMutexLock ExecuteLock{m_ExecuteMutex, true}; 287 | 288 | //Try to open the MMF for reading 289 | HANDLE hInstance{OpenFileMapping(FILE_MAP_READ, FALSE, m_sName)}; 290 | if (hInstance == nullptr) 291 | { 292 | ATLTRACE(_T("CInstanceChecker::FindPreviousHWND, Failed in call to OpenFileMapping, Error:%u\n"), GetLastError()); 293 | return false; 294 | } 295 | ATL::CHandle hPrevInstance{hInstance}; 296 | 297 | //Open up the MMF to get the data 298 | constexpr const int nMMFSize{sizeof(CWindowInstance)}; 299 | auto pInstanceData{static_cast(MapViewOfFile(hPrevInstance, FILE_MAP_READ, 0, 0, nMMFSize))}; 300 | if (pInstanceData == nullptr) 301 | { 302 | ATLTRACE(_T("CInstanceChecker::FindPreviousHWND, Failed in call to MapViewOfFile, Error:%u\n"), GetLastError()); 303 | return false; 304 | } 305 | 306 | #pragma warning(suppress: 26490) 307 | hPrevWnd = reinterpret_cast(pInstanceData->hMainWnd); 308 | 309 | //Unmap the MMF we were using 310 | if (!UnmapViewOfFile(pInstanceData)) 311 | { 312 | ATLTRACE(_T("CInstanceChecker::FindPreviousHWND, Failed in call to UnmapViewOfFile, Error:%u\n"), GetLastError()); 313 | } 314 | 315 | return true; 316 | } 317 | 318 | #pragma warning(suppress: 26461) 319 | _Return_type_success_(return != false) bool CInstanceChecker::ActivatePreviousInstance(_In_opt_ LPCTSTR lpCmdLine, _In_ ULONG_PTR dwCopyDataItemData, _In_ DWORD dwTimeout, HWND hSender) 320 | { 321 | //Create the mutex to serialize access to all instances of CInstanceChecker if required 322 | if (!CreateExecuteMutexIfNecessary()) 323 | return false; 324 | 325 | //Serialize access using the execute mutex 326 | ATL::CMutexLock ExecuteLock{m_ExecuteMutex, true}; 327 | 328 | //First find the previous HWND 329 | HWND hPrevWnd{nullptr}; 330 | if (!FindPreviousHWND(hPrevWnd)) 331 | return false; 332 | if (hPrevWnd == nullptr) 333 | { 334 | ATLTRACE(_T("CInstanceChecker::ActivatePreviousInstance, HWND in memory mapping is null\n")); 335 | return false; 336 | } 337 | 338 | //activate, restore the focus and and bring to the foreground the previous instance's HWND 339 | HWND hWndChild{GetLastActivePopup(hPrevWnd)}; 340 | if (IsIconic(hPrevWnd)) 341 | ShowWindow(hPrevWnd, SW_RESTORE); 342 | if (hWndChild != nullptr) 343 | SetForegroundWindow(hWndChild); 344 | 345 | //Send the specified command line to the previous instance using SendMessageTimeout & WM_COPYDATA if required 346 | LRESULT lResult{0}; 347 | if (lpCmdLine != nullptr) 348 | { 349 | COPYDATASTRUCT cds{}; 350 | cds.dwData = dwCopyDataItemData; 351 | #pragma warning(suppress: 26472) 352 | const auto dwCmdLength{static_cast(_tcslen(lpCmdLine) + 1)}; 353 | cds.cbData = dwCmdLength * sizeof(TCHAR); 354 | ATL::CAtlString sCmdLine{lpCmdLine}; 355 | LPTSTR pszCmdLine{sCmdLine.GetBuffer()}; 356 | cds.lpData = pszCmdLine; 357 | 358 | //Send the message to the previous instance. Use SendMessageTimeout instead of SendMessage to ensure we 359 | //do not hang if the previous instance itself is hung 360 | DWORD_PTR dwResult{0}; 361 | #pragma warning(suppress: 26490) 362 | lResult = SendMessageTimeout(hPrevWnd, WM_COPYDATA, reinterpret_cast(hSender), reinterpret_cast(&cds), 363 | SMTO_ABORTIFHUNG, dwTimeout, &dwResult); 364 | if (lResult == 0) 365 | { 366 | ATLTRACE(_T("CInstanceChecker::ActivatePreviousInstance, SendMessageTimeout call failed, Error:%u\n"), GetLastError()); 367 | } 368 | sCmdLine.ReleaseBuffer(); 369 | } 370 | 371 | return (lResult != 0); 372 | } 373 | 374 | _Return_type_success_(return != false) bool CInstanceChecker::QuitPreviousInstance(_In_ int nExitCode) 375 | { 376 | //Create the mutex to serialize access to all instances of CInstanceChecker if required 377 | if (!CreateExecuteMutexIfNecessary()) 378 | return false; 379 | 380 | //Serialize access using the execute mutex 381 | ATL::CMutexLock ExecuteLock{m_ExecuteMutex, true}; 382 | 383 | //First find the previous HWND 384 | HWND hPrevWnd{nullptr}; 385 | if (!FindPreviousHWND(hPrevWnd)) 386 | return false; 387 | 388 | if (hPrevWnd == nullptr) 389 | { 390 | ATLTRACE(_T("CInstanceChecker::QuitPreviousInstance, HWND in memory mapping is null\n")); 391 | return false; 392 | } 393 | 394 | //Ask it to exit 395 | HWND hChildWnd{GetLastActivePopup(hPrevWnd)}; 396 | PostMessage(hChildWnd, WM_QUIT, nExitCode, 0); 397 | 398 | return true; 399 | } 400 | -------------------------------------------------------------------------------- /happynet/sinstance.h: -------------------------------------------------------------------------------- 1 | /* 2 | Module : sinstance.h 3 | Purpose: Defines the interface for a C++ wrapper class to do instance checking 4 | Created: PJN / 29-07-1998 5 | 6 | Copyright (c) 1996 - 2022 by PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com) 7 | 8 | All rights reserved. 9 | 10 | Copyright / Usage Details: 11 | 12 | You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 13 | when your product is released in binary form. You are allowed to modify the source code in any way you want 14 | except you cannot modify the copyright details at the top of each module. If you want to distribute source 15 | code with your application, then you are only allowed to distribute versions released by the author. This is 16 | to maintain a single distribution point for the source code. 17 | 18 | */ 19 | 20 | 21 | /////////////////////////// Macros / Defines ////////////////////////////////// 22 | 23 | #pragma once 24 | 25 | #ifndef __SINSTANCE_H__ 26 | #define __SINSTANCE_H__ 27 | 28 | #ifndef CSINGLEINSTANCE_EXT_CLASS 29 | #define CSINGLEINSTANCE_EXT_CLASS 30 | #endif //#ifndef CSINGLEINSTANCE_EXT_CLASS 31 | 32 | #ifndef CSINGLEINSTANCE_EXT_API 33 | #define CSINGLEINSTANCE_EXT_API 34 | #endif //#ifndef CSINGLEINSTANCE_EXT_API 35 | 36 | 37 | /////////////////////////// Includes ////////////////////////////////////////// 38 | 39 | #ifndef __ATLSYNC_H__ 40 | #pragma message("To avoid this message, please put atlsync.h in your pre compiled header (normally stdafx.h)") 41 | #include 42 | #endif //#ifndef __ATLSYNC_H__ 43 | 44 | #ifndef __ATLSTR_H__ 45 | #pragma message("To avoid this message, please put atlstr.h in your pre compiled header (normally stdafx.h)") 46 | #include 47 | #endif //#ifndef __ATLSTR_H__ 48 | 49 | 50 | /////////////////////////// Classes ////////////////////////////////////////// 51 | 52 | class CSINGLEINSTANCE_EXT_CLASS CInstanceChecker 53 | { 54 | public: 55 | //Constructors / Destructors 56 | CInstanceChecker(_In_z_ LPCTSTR pszUniqueName); 57 | CInstanceChecker(_In_ const CInstanceChecker&) = delete; 58 | CInstanceChecker(_In_ CInstanceChecker&&) = delete; 59 | virtual ~CInstanceChecker() = default; 60 | 61 | //General functions 62 | CInstanceChecker& operator=(_In_ const CInstanceChecker&) = delete; 63 | CInstanceChecker& operator=(_In_ CInstanceChecker&&) = delete; 64 | _Return_type_success_(return != false) virtual bool TrackFirstInstanceRunning(_In_ HWND hWindowToTrack); 65 | _Return_type_success_(return != false) virtual bool PreviousInstanceRunning(); 66 | _Return_type_success_(return != false) virtual bool ActivatePreviousInstance(_In_opt_ LPCTSTR lpCmdLine = nullptr, _In_ ULONG_PTR dwCopyDataItemData = 0, _In_ DWORD dwTimeout = 30000, HWND hSender = nullptr); 67 | _Return_type_success_(return != false) virtual bool QuitPreviousInstance(_In_ int nExitCode = 0); 68 | _Return_type_success_(return != false) virtual bool FindPreviousHWND(_Out_ HWND& hPrevWnd); 69 | 70 | protected: 71 | //Virtual methods 72 | virtual ATL::CAtlString GetExecuteMutexName(); 73 | _Return_type_success_(return != false) virtual bool CreateExecuteMutexIfNecessary(); 74 | 75 | //Member variables 76 | ATL::CAtlString m_sName; 77 | ATL::CHandle m_MMF; 78 | ATL::CMutex m_ExecuteMutex; 79 | }; 80 | 81 | #endif //#ifndef __SINSTANCE_H__ 82 | -------------------------------------------------------------------------------- /happynet/systemsrv.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "process.h" 7 | #include "registry.h" 8 | #include "systemsrv.h" 9 | #include "utils.h" 10 | 11 | static WCHAR* GetNssmExePath(VOID) 12 | { 13 | static WCHAR szNssmPath[MAX_PATH] = { 0 }; 14 | WCHAR szInstallPath[MAX_PATH] = { 0 }; 15 | 16 | // Build path and command line parameters 17 | if (!GetInstallDirPath(szInstallPath, MAX_PATH)) 18 | { 19 | LogEvent(TEXT("%s:%d (%s) - Error building executable path.\n"), 20 | __FILEW__, __LINE__, __FUNCTIONW__); 21 | return NULL; 22 | } 23 | swprintf_s(szNssmPath, MAX_PATH, TEXT("\"%s\\happynssm.exe\""), szInstallPath); 24 | return szNssmPath; 25 | } 26 | 27 | static WCHAR* GetNssmLogPath(VOID) 28 | { 29 | static WCHAR szNssmLogPath[MAX_PATH] = { 0 }; 30 | WCHAR szAppDataPath[MAX_PATH] = { 0 }; 31 | 32 | if (wcsstr(szNssmLogPath, TEXT("happynet")) == 0) { 33 | // Build path and command line parameters 34 | GetAppDatapath(szAppDataPath); 35 | swprintf_s(szNssmLogPath, MAX_PATH, L"%s\\happynet.log", szAppDataPath); 36 | 37 | // LogEvent(TEXT("%s:%d (%s) - building log path:%s \n"), 38 | // __FILEW__, __LINE__, __FUNCTIONW__, szNssmLogPath); 39 | } 40 | return szNssmLogPath; 41 | } 42 | 43 | 44 | // nssm install [] 45 | // nssm set Description "Happynet is a light VPN software which makes it easy to create virtual networks by passing intermediate firewalls. Powered by happyn.cn" 46 | VOID RegSystemService(VOID) 47 | { 48 | WCHAR szInstallPath[MAX_PATH] = { 0 }; 49 | WCHAR szEdgePath[MAX_PATH] = { 0 }; 50 | WCHAR szParamsLine[MAX_COMMAND_LINE_LEN] = { 0 }; 51 | WCHAR szNssmComandLine[MAX_COMMAND_LINE_LEN] = { 0 }; 52 | 53 | // Build path and command line parameters 54 | if (!GetInstallDirPath(szInstallPath, MAX_PATH)) 55 | { 56 | LogEvent(TEXT("%s:%d (%s) - Error building executable path.\n"), 57 | __FILEW__, __LINE__, __FUNCTIONW__); 58 | return; 59 | } 60 | swprintf_s(szEdgePath, MAX_PATH, TEXT("\"%s\\happynedge.exe\""), szInstallPath); 61 | 62 | GetEdgeParams(TEXT(" "), szParamsLine, MAX_COMMAND_LINE_LEN); 63 | 64 | // nssm install [] 65 | swprintf_s(szNssmComandLine, MAX_COMMAND_LINE_LEN, 66 | TEXT("%s install %s %s \"%s\""), 67 | GetNssmExePath(), SYSTEMSRV_NAME, szEdgePath, szParamsLine); 68 | 69 | WinExecW(szNssmComandLine, SW_HIDE); 70 | 71 | //nssm set Description "Happynet ..." 72 | swprintf_s(szNssmComandLine, MAX_COMMAND_LINE_LEN, 73 | TEXT("%s set %s Description \"Happynet is a light VPN software which makes it easy to create virtual networks bypassing intermediate firewalls. Powered by happyn.cn\""), 74 | GetNssmExePath(), SYSTEMSRV_NAME); 75 | WinExecW(szNssmComandLine, SW_HIDE); 76 | 77 | //nssm set AppStdout logpath 78 | swprintf_s(szNssmComandLine, MAX_COMMAND_LINE_LEN, 79 | TEXT("%s set %s AppStdout %s"), 80 | GetNssmExePath(), SYSTEMSRV_NAME, GetNssmLogPath()); 81 | WinExecW(szNssmComandLine, SW_HIDE); 82 | 83 | //nssm set AppStderr logpath 84 | swprintf_s(szNssmComandLine, MAX_COMMAND_LINE_LEN, 85 | TEXT("%s set %s AppStderr %s"), 86 | GetNssmExePath(), SYSTEMSRV_NAME, GetNssmLogPath()); 87 | WinExecW(szNssmComandLine, SW_HIDE); 88 | } 89 | 90 | 91 | // nssm.exe set AppParameters 92 | VOID SetArgsSystemService(VOID) 93 | { 94 | WCHAR szInstallPath[MAX_PATH] = { 0 }; 95 | WCHAR szParamsLine[MAX_COMMAND_LINE_LEN] = { 0 }; 96 | WCHAR szNssmComandLine[MAX_COMMAND_LINE_LEN] = { 0 }; 97 | 98 | // Build path and command line parameters 99 | if (!GetInstallDirPath(szInstallPath, MAX_PATH)) 100 | { 101 | LogEvent(TEXT("%s:%d (%s) - Error building executable path.\n"), 102 | __FILEW__, __LINE__, __FUNCTIONW__); 103 | return; 104 | } 105 | 106 | GetEdgeParams(TEXT(" "), szParamsLine, MAX_COMMAND_LINE_LEN); 107 | 108 | // nssm.exe set AppParameters 109 | swprintf_s(szNssmComandLine, MAX_COMMAND_LINE_LEN, 110 | TEXT("%s set %s AppParameters \"%s\""), 111 | GetNssmExePath(), SYSTEMSRV_NAME,szParamsLine); 112 | 113 | WinExecW(szNssmComandLine, SW_HIDE); 114 | } 115 | 116 | 117 | // nssm remove 118 | VOID UnregSystemService(VOID) 119 | { 120 | WCHAR nssm_path[MAX_PATH] = { 0 }; 121 | WCHAR szNssmCommandLine[MAX_COMMAND_LINE_LEN] = { 0 }; 122 | swprintf_s(szNssmCommandLine, MAX_COMMAND_LINE_LEN, 123 | TEXT("%s remove %s confirm"), GetNssmExePath(), SYSTEMSRV_NAME); 124 | 125 | StopSystemService(); 126 | WinExecW(szNssmCommandLine, SW_HIDE); 127 | } 128 | 129 | // nssm set Start SERVICE_AUTO_START 130 | VOID SetSystemServiceAutoStart(VOID) 131 | { 132 | WCHAR szNssmCommandLine[MAX_COMMAND_LINE_LEN] = { 0 }; 133 | //nssm set Start SERVICE_AUTO_START 134 | swprintf_s(szNssmCommandLine, MAX_COMMAND_LINE_LEN, 135 | TEXT("%s set %s Start SERVICE_AUTO_START"), 136 | GetNssmExePath(), SYSTEMSRV_NAME); 137 | WinExecW(szNssmCommandLine, SW_HIDE); 138 | return; 139 | } 140 | 141 | // nssm set Start SERVICE_DEMAND_START 142 | VOID UnsetSystemServiceAutoStart(VOID) 143 | { 144 | WCHAR szNssmCommandLine[MAX_COMMAND_LINE_LEN] = { 0 }; 145 | //nssm set Start SERVICE_DEMAND_START 146 | swprintf_s(szNssmCommandLine, MAX_COMMAND_LINE_LEN, 147 | TEXT("%s set %s Start SERVICE_DEMAND_START"), 148 | GetNssmExePath(), SYSTEMSRV_NAME); 149 | WinExecW(szNssmCommandLine, SW_HIDE); 150 | return; 151 | } 152 | 153 | // nssm start 154 | VOID StartSystemService(VOID) 155 | { 156 | WCHAR szNssmCommandLine[MAX_COMMAND_LINE_LEN] = { 0 }; 157 | //nssm set Start SERVICE_DEMAND_START 158 | swprintf_s(szNssmCommandLine, MAX_COMMAND_LINE_LEN, 159 | TEXT("%s start %s"), 160 | GetNssmExePath(), SYSTEMSRV_NAME); 161 | WinExecW(szNssmCommandLine, SW_HIDE); 162 | return; 163 | } 164 | 165 | // nssm stop 166 | VOID StopSystemService(VOID) 167 | { 168 | WCHAR szNssmCommandLine[MAX_COMMAND_LINE_LEN] = { 0 }; 169 | //nssm stop 170 | swprintf_s(szNssmCommandLine, MAX_COMMAND_LINE_LEN, 171 | TEXT("%s stop %s"), 172 | GetNssmExePath(), SYSTEMSRV_NAME); 173 | WinExecW(szNssmCommandLine, SW_HIDE); 174 | return; 175 | } 176 | 177 | 178 | DWORD GetSystemServiceStatus(VOID) 179 | { 180 | WCHAR *serviceName = SYSTEMSRV_NAME; 181 | 182 | SC_HANDLE sch = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 183 | if (sch == NULL) { 184 | LogEvent(TEXT("OpenSCManager failed\n")); 185 | return EXCEPTION_BREAKPOINT; 186 | } 187 | 188 | SC_HANDLE svc = OpenServiceW(sch, serviceName, SC_MANAGER_ALL_ACCESS); 189 | if (svc == NULL) { 190 | LogEvent(TEXT("OpenService failed\n")); 191 | return EXCEPTION_BREAKPOINT; 192 | } 193 | 194 | SERVICE_STATUS_PROCESS stat; 195 | DWORD needed = 0; 196 | BOOL ret = QueryServiceStatusEx(svc, SC_STATUS_PROCESS_INFO, 197 | (BYTE*)&stat, sizeof stat, &needed); 198 | 199 | CloseServiceHandle(svc); 200 | CloseServiceHandle(sch); 201 | 202 | if (ret == 0) { 203 | LogEvent(TEXT("QueryServiceStatusEx failed\n")); 204 | return EXCEPTION_BREAKPOINT; 205 | } 206 | 207 | if (stat.dwCurrentState == SERVICE_RUNNING) { 208 | return STILL_ACTIVE; 209 | } 210 | else { 211 | return PROCESS_EXIT_CODE; 212 | } 213 | 214 | return EXCEPTION_BREAKPOINT; 215 | } 216 | 217 | // nssm status 218 | // result: 219 | // Can't open service! 220 | // SERVICE_STOPPED 221 | // SERVICE_RUNNING 222 | DWORD GetSystemServiceStatusByNssm(VOID) 223 | { 224 | //create pipe 225 | SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; 226 | HANDLE hRead, hWrite; 227 | if (!CreatePipe(&hRead, &hWrite, &sa, 0)) 228 | { 229 | return EXCEPTION_BREAKPOINT; 230 | } 231 | 232 | //set thread output to pipe 233 | STARTUPINFO si = { sizeof(STARTUPINFO) }; 234 | GetStartupInfo(&si); 235 | si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; 236 | si.wShowWindow = SW_HIDE; 237 | si.hStdError = hWrite; 238 | si.hStdOutput = hWrite; 239 | 240 | //start commandline 241 | WCHAR szNssmCommandLine[MAX_COMMAND_LINE_LEN] = { 0 }; 242 | swprintf_s(szNssmCommandLine, MAX_COMMAND_LINE_LEN, 243 | TEXT("%s status %s"), 244 | GetNssmExePath(), SYSTEMSRV_NAME); 245 | 246 | PROCESS_INFORMATION pi; 247 | if (!CreateProcessW(NULL, szNssmCommandLine, NULL, NULL, TRUE, NULL, NULL, NULL, &si, &pi)) 248 | { 249 | CloseHandle(hRead); 250 | CloseHandle(hWrite); 251 | return EXCEPTION_BREAKPOINT; 252 | } 253 | 254 | //close hWrite 255 | CloseHandle(hWrite); 256 | 257 | DWORD dwRead; 258 | static CHAR arrcStdoutBuf[PROCESS_STDOUT_BUFSIZE] = { 0 }; 259 | SecureZeroMemory(arrcStdoutBuf, PROCESS_STDOUT_BUFSIZE); 260 | BOOL bSuccess = FALSE; 261 | HANDLE hParentStdout = GetStdHandle(STD_OUTPUT_HANDLE); 262 | 263 | 264 | bSuccess = ReadFile(hRead, arrcStdoutBuf, PROCESS_STDOUT_BUFSIZE, &dwRead, NULL); 265 | if (!bSuccess || dwRead == 0) { 266 | CloseHandle(hRead); 267 | return EXCEPTION_BREAKPOINT; 268 | } 269 | //LogEvent(TEXT("%s\n"), arrcStdoutBuf); 270 | CloseHandle(hRead); 271 | 272 | //Convert char* string to a wchar_t* string. 273 | UINT nConvertedChars = 0; 274 | UINT nNewsize = strlen(arrcStdoutBuf) + 1; 275 | static WCHAR arrcReadBuf[PROCESS_STDOUT_BUFSIZE] = { 0 }; 276 | SecureZeroMemory(arrcReadBuf, PROCESS_STDOUT_BUFSIZE); 277 | mbstowcs_s(&nConvertedChars, arrcReadBuf, nNewsize, arrcStdoutBuf, _TRUNCATE); 278 | //Display the result and indicate the type of string that it is. 279 | //LogEvent(TEXT("%s\n"), arrcReadBuf); 280 | 281 | if (wcsstr(arrcReadBuf, TEXT("SERVICE_STOPPED"))) { 282 | return PROCESS_EXIT_CODE; 283 | } 284 | 285 | if (wcsstr(arrcReadBuf, TEXT("SERVICE_RUNNING"))) { 286 | return STILL_ACTIVE; 287 | } 288 | return EXCEPTION_BREAKPOINT; 289 | } 290 | 291 | VOID GetSystemServiceOutput(WCHAR *szReadBuf) 292 | { 293 | static DWORD dwOffset = 0; 294 | 295 | CHAR chbuf[PROCESS_STDOUT_BUFSIZE] = { 0 }; 296 | BOOL bSuccess = FALSE; 297 | HANDLE hParentStdout = GetStdHandle(STD_OUTPUT_HANDLE); 298 | OVERLAPPED ol = { 0 }; 299 | INT nReadBufSize = 0; 300 | 301 | HANDLE hFile = CreateFileW( 302 | GetNssmLogPath(), // file to open 303 | GENERIC_READ, // open for reading 304 | FILE_SHARE_READ | FILE_SHARE_WRITE, // share for reading 305 | NULL, // default security 306 | OPEN_EXISTING, // existing file only 307 | FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, // normal file 308 | NULL); 309 | 310 | if (hFile == INVALID_HANDLE_VALUE) 311 | { 312 | LogEvent(TEXT("Open NssmLog failure.\n")); 313 | CloseHandle(hFile); 314 | return; 315 | } 316 | 317 | DWORD dwEndOffset = SetFilePointer(hFile, 0, NULL, FILE_END); 318 | if (dwEndOffset == INVALID_SET_FILE_POINTER) { 319 | LogEvent(TEXT("Terminal failure: unable to set file pointer.\n")); 320 | return; 321 | } 322 | if (dwEndOffset - dwOffset > PROCESS_STDOUT_BUFSIZE) { 323 | dwOffset = dwEndOffset - PROCESS_STDOUT_BUFSIZE; 324 | nReadBufSize = PROCESS_STDOUT_BUFSIZE; 325 | } else { 326 | nReadBufSize = dwEndOffset - dwOffset; 327 | } 328 | 329 | ol.Offset = dwOffset; 330 | bSuccess = ReadFileEx(hFile, chbuf, nReadBufSize - 1, &ol, NULL); 331 | if (!bSuccess) { 332 | CloseHandle(hFile); 333 | return; 334 | } 335 | dwOffset = dwEndOffset; 336 | 337 | //Convert char* string to a wchar_t* string. 338 | UINT convertedChars = 0; 339 | mbstowcs_s(&convertedChars, szReadBuf, nReadBufSize, chbuf, _TRUNCATE); 340 | //Display the result and indicate the type of string that it is. 341 | LogEvent(TEXT("%s\n"), szReadBuf); 342 | CloseHandle(hFile); 343 | } 344 | 345 | VOID TerminalSystemService(VOID) 346 | { 347 | return; 348 | } -------------------------------------------------------------------------------- /happynet/systemsrv.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_SYSTEMSRV 2 | #define _H_SYSTEMSRV 3 | 4 | #define SYSTEMSRV_NAME TEXT("Happynet") 5 | 6 | VOID RegSystemService(VOID); 7 | VOID UnregSystemService(VOID); 8 | VOID SetSystemServiceAutoStart(VOID); 9 | VOID SetArgsSystemService(VOID); 10 | VOID UnsetSystemServiceAutoStart(VOID); 11 | VOID StartSystemService(VOID); 12 | VOID StopSystemService(VOID); 13 | VOID TerminalSystemService(VOID); 14 | VOID GetSystemServiceOutput(WCHAR *read_buf); 15 | DWORD GetSystemServiceStatus(VOID); 16 | DWORD GetSystemServiceStatusByNssm(VOID); 17 | 18 | #endif -------------------------------------------------------------------------------- /happynet/tray.cpp: -------------------------------------------------------------------------------- 1 | #include "tray.h" 2 | 3 | VOID HideToTray(HWND hWnd) 4 | { 5 | NOTIFYICONDATA nid; 6 | nid.cbSize = (DWORD)sizeof(NOTIFYICONDATA); 7 | nid.hWnd = hWnd; 8 | nid.uID = IDI_ICON32; 9 | nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; 10 | nid.uCallbackMessage = WM_USER_SHELLICON; 11 | nid.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON32)); 12 | wcscpy_s(nid.szTip, TEXT("happynet")); 13 | Shell_NotifyIcon(NIM_ADD, &nid); 14 | } 15 | 16 | 17 | VOID DestroyTray(HWND hWnd) 18 | { 19 | NOTIFYICONDATA nid; 20 | nid.cbSize = (DWORD)sizeof(NOTIFYICONDATA); 21 | nid.hWnd = hWnd; 22 | nid.uID = IDI_ICON32; 23 | nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; 24 | nid.uCallbackMessage = WM_USER_SHELLICON; 25 | nid.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON32)); 26 | wcscpy_s(nid.szTip, TEXT("happynet")); 27 | //delete tray icon show 28 | Shell_NotifyIcon(NIM_DELETE, &nid); 29 | } -------------------------------------------------------------------------------- /happynet/tray.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRAY_H 2 | #define _TRAY_H 3 | 4 | #include "resource.h" 5 | #include 6 | 7 | #define WM_USER_SHELLICON WM_USER + 100 8 | 9 | VOID HideToTray(HWND hWnd); 10 | VOID DestroyTray(HWND hWnd); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /happynet/utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "atlbase.h" 9 | #include "atlstr.h" 10 | 11 | #include "netinterface.h" 12 | #include "service.h" 13 | #include "registry.h" 14 | #include "process.h" 15 | #include "utils.h" 16 | 17 | WCHAR *StripString(WCHAR *s) 18 | { 19 | size_t size; 20 | WCHAR *end; 21 | 22 | size = wcslen(s); 23 | 24 | if (!size) 25 | return s; 26 | 27 | end = s + size - 1; 28 | while (end >= s && isspace(*end)) 29 | end--; 30 | *(end + 1) = '\0'; 31 | 32 | while (*s && isspace(*s)) 33 | s++; 34 | 35 | return s; 36 | } 37 | 38 | LARGE_INTEGER IntToLargeInt(UINT nCount) { 39 | LARGE_INTEGER li; 40 | li.QuadPart = nCount; 41 | return li; 42 | } 43 | 44 | BOOL IsEmptyString(WCHAR* str) 45 | { 46 | if (wcslen(str) == 0) return true; 47 | for (INT i = 0; i < (INT)wcslen(str); i++) 48 | { 49 | if (str[i] != ' ') return false; 50 | } 51 | return true; 52 | } 53 | 54 | BOOL IsValidAsciiString(WCHAR *pszLine) 55 | { 56 | for (INT i = 0; i < lstrlenW(pszLine); i++) 57 | { 58 | if (!iswascii(pszLine[i])) { 59 | return FALSE; 60 | } 61 | } 62 | return TRUE; 63 | } 64 | 65 | BOOL StripNoAsciiString(WCHAR *pszLine) 66 | { 67 | INT i = 0; 68 | for (i = 0; i < lstrlenW(pszLine); i++) 69 | { 70 | if (!iswascii(pszLine[i])) { 71 | pszLine[i] = L'\0'; 72 | break; 73 | } 74 | } 75 | return i; 76 | } 77 | 78 | UINT WinExecW(WCHAR* pszCommandLine, UINT nCommandShow) 79 | { 80 | USES_CONVERSION; 81 | return WinExec(W2A(pszCommandLine), nCommandShow); 82 | } 83 | 84 | VOID LogEvent(WCHAR* format, ...) 85 | { 86 | INT n = 0; 87 | va_list arg; 88 | 89 | // Construct the message 90 | va_start(arg, format); 91 | INT size = _vscwprintf(format, arg) + 1; 92 | WCHAR *message = new WCHAR[size]; 93 | n = _vsnwprintf_s(message, size, size, format, arg); 94 | va_end(arg); 95 | 96 | // Check success 97 | if (n < 0 || n >= size) return; 98 | 99 | // Log the message 100 | OutputDebugStringW(message); 101 | delete[] message; 102 | } 103 | 104 | INT GetInstallDirPath(WCHAR* pszDirPath, DWORD dwBufLen) 105 | { 106 | WCHAR arrcExeDirBuf[MAX_PATH] = { 0 }; 107 | DWORD nExeDirBufLen = dwBufLen * sizeof(WCHAR); 108 | 109 | // get happyn exe dir path 110 | if (!GetModuleFileName(NULL, arrcExeDirBuf, MAX_PATH)) 111 | { 112 | return 0; 113 | } 114 | PathRemoveFileSpec(arrcExeDirBuf); 115 | swprintf_s(pszDirPath, dwBufLen, arrcExeDirBuf); 116 | return 1; 117 | } 118 | 119 | 120 | INT GetAppDatapath(WCHAR* pszDatapath) 121 | { 122 | WCHAR pszDefaultAppDatapath[MAX_PATH] = { 0 }; 123 | SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, pszDefaultAppDatapath); 124 | swprintf_s(pszDatapath, MAX_PATH, TEXT("%s\\happynet"), pszDefaultAppDatapath); 125 | return SHCreateDirectoryEx(NULL, pszDatapath, NULL); 126 | } 127 | 128 | 129 | INT GetEdgeCmdLine(WCHAR* pszDirPath, WCHAR* pszCommandLine, DWORD dwBufLen) 130 | { 131 | WCHAR edge_path[MAX_PATH] = { 0 }; 132 | swprintf_s(edge_path, MAX_PATH, TEXT("\"%s\\happynedge.exe\""), pszDirPath); 133 | return GetEdgeParams(edge_path, pszCommandLine, dwBufLen); 134 | } 135 | 136 | 137 | INT GetEdgeParams(WCHAR* pszEdgePath, WCHAR* pszCommandLine, DWORD dwCommandBufLen) 138 | { 139 | WCHAR arrcRetVal[MAX_COMMAND_LINE_LEN]; 140 | DWORD dwRetVal = 0; 141 | 142 | // Use 'ptr' to append to the end of the command line 143 | WCHAR* ptr = pszCommandLine; 144 | ptr += swprintf_s(pszCommandLine, dwCommandBufLen, TEXT("%s "), pszEdgePath); 145 | 146 | // Open registry key 147 | HKEY hkey; 148 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Happynet\\Parameters"), 149 | NULL, KEY_READ, &hkey) != ERROR_SUCCESS) 150 | { 151 | LogEvent(TEXT("%s:%d (%s) - Error opening registry key.\n"), 152 | __FILEW__, __LINE__, __FUNCTIONW__); 153 | return 0; 154 | } 155 | 156 | // Community 157 | if (!GetRegString(hkey, TEXT("community"), arrcRetVal, 512)) return 0; 158 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -c %s"), arrcRetVal); 159 | 160 | // Encryption key 161 | if (!GetRegString(hkey, TEXT("enckey"), arrcRetVal, 512)) return 0; 162 | if (wcslen(arrcRetVal) != 0) 163 | { 164 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -k %s"), arrcRetVal); 165 | } 166 | 167 | // IP address 168 | if (!GetRegString(hkey, TEXT("ip_address"), arrcRetVal, 512)) return 0; 169 | if (wcslen(arrcRetVal) != 0) 170 | { 171 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -a %s"), arrcRetVal); 172 | } 173 | 174 | // Encryption key file 175 | if (!GetRegString(hkey, TEXT("keyfile"), arrcRetVal, 512)) return 0; 176 | if (wcslen(arrcRetVal) != 0) 177 | { 178 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -K %s"), arrcRetVal); 179 | } 180 | 181 | // set adapter 182 | if (!GetRegString(hkey, TEXT("adapter"), arrcRetVal, 512)) return 0; 183 | if (wcslen(arrcRetVal) != 0) 184 | { 185 | CHAR *pAdapterId = NULL; 186 | const CHAR s[2] = "_"; 187 | _bstr_t b(arrcRetVal); 188 | CHAR *pTmpBuf = NULL; 189 | pAdapterId = strtok_s(b, s, &pTmpBuf); 190 | pAdapterId = strtok_s(NULL, s, &pTmpBuf); 191 | 192 | TCHAR adapter_firendly_name[512] = { 0 }; 193 | if (GetAdapterFriendlyName(pAdapterId, adapter_firendly_name, 512) == NOERROR) { 194 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -d \"%s\""), adapter_firendly_name); 195 | } 196 | } 197 | 198 | // Local Port 199 | if (!GetRegDword(hkey, TEXT("local_port"), &dwRetVal)) return 0; 200 | if (dwRetVal != 0) 201 | { 202 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -p %d"), dwRetVal); 203 | } 204 | 205 | 206 | // MAC address 207 | if (!GetRegString(hkey, TEXT("mac_address"), arrcRetVal, 512)) return 0; 208 | if (wcslen(arrcRetVal) != 0) 209 | { 210 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -m %s"), arrcRetVal); 211 | } 212 | 213 | // MTU 214 | if (!GetRegDword(hkey, TEXT("mtu"), &dwRetVal)) return 0; 215 | if (dwRetVal != 0) 216 | { 217 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -M %d"), dwRetVal); 218 | } 219 | 220 | // Multicast 221 | if (!GetRegDword(hkey, TEXT("multicast"), &dwRetVal)) return 0; 222 | if (dwRetVal != 0) 223 | { 224 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -E")); 225 | } 226 | 227 | // Packet forwarding 228 | if (!GetRegDword(hkey, TEXT("packet_forwarding"), &dwRetVal)) return 0; 229 | if (dwRetVal != 0) 230 | { 231 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -r")); 232 | } 233 | 234 | // header encryption 235 | if (!GetRegDword(hkey, TEXT("header_encry"), &dwRetVal)) return 0; 236 | if (dwRetVal != 0) 237 | { 238 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -H")); 239 | } 240 | 241 | // data compress 242 | if (!GetRegDword(hkey, TEXT("data_compress"), &dwRetVal)) return 0; 243 | if (dwRetVal != 0) 244 | { 245 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -z1")); 246 | } 247 | 248 | // select rtt 249 | if (!GetRegDword(hkey, TEXT("select_rtt"), &dwRetVal)) return 0; 250 | if (dwRetVal != 0) 251 | { 252 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" --select-rtt ")); 253 | } 254 | 255 | // Supernode address 256 | if (!GetRegString(hkey, TEXT("supernode_addr"), arrcRetVal, 512)) return 0; 257 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -l %s"), arrcRetVal); 258 | 259 | // Supernode port 260 | if (!GetRegDword(hkey, TEXT("supernode_port"), &dwRetVal)) return 0; 261 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(":%d"), dwRetVal); 262 | 263 | // device name 264 | const INT nInfoBufSize = MAX_COMPUTERNAME_LENGTH * 16; 265 | TCHAR arrcHostName[nInfoBufSize]; 266 | DWORD dwBufCount = nInfoBufSize; 267 | 268 | // Get and display the name of the computer. 269 | // TODO: support No-ASCII hostname 270 | if (GetComputerName(arrcHostName, &dwBufCount)) 271 | { 272 | HKEY hkeyHostName; 273 | WCHAR arrcRegHostname[nInfoBufSize] = { 0 }; 274 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"), 275 | NULL, KEY_READ, &hkeyHostName) == ERROR_SUCCESS && \ 276 | (GetRegString(hkeyHostName, TEXT("hostname"), arrcRegHostname, 512))) 277 | { 278 | lstrcpynW(arrcHostName, arrcRegHostname, lstrlenW(arrcRegHostname) + 1); 279 | } 280 | } 281 | 282 | if (IsValidAsciiString(arrcHostName) || (!IsValidAsciiString(arrcHostName) && StripNoAsciiString(arrcHostName))) 283 | { 284 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -I %s"), arrcHostName); 285 | } 286 | else 287 | { 288 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" -I unknown")); 289 | } 290 | 291 | //custom param 292 | if (!GetRegString(hkey, TEXT("custom_param"), arrcRetVal, MAX_COMMAND_LINE_LEN)) return 0; 293 | ptr += swprintf_s(ptr, dwCommandBufLen - (ptr - pszCommandLine), TEXT(" %s"), arrcRetVal); 294 | return 1; 295 | } 296 | -------------------------------------------------------------------------------- /happynet/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_UTILS 2 | #define _H_UTILS 3 | 4 | #include 5 | 6 | #define MAX_COMMAND_LINE_LEN 1024 * 8 7 | 8 | WCHAR *StripString(WCHAR *s); 9 | LARGE_INTEGER IntToLargeInt(UINT nCount); 10 | BOOL IsEmptyString(WCHAR* str); 11 | VOID LogEvent(WCHAR* format, ...); 12 | BOOL IsValidAsciiString(WCHAR *pszLine); 13 | BOOL StripNoAsciiString(WCHAR *pszLine); 14 | UINT WinExecW(WCHAR* pszCommandLine, UINT nCommandShow); 15 | INT GetAppDatapath(WCHAR* pszDatapath); 16 | INT GetInstallDirPath(WCHAR* pszDirPath, DWORD dwBufLen); 17 | INT GetEdgeCmdLine(WCHAR* pszDirPath, WCHAR* pszCommandLine, DWORD dwBufLen); 18 | INT GetEdgeParams(WCHAR* pszEdgePath, WCHAR* pszCommandLine, DWORD dwCommandBufLen); 19 | 20 | #endif -------------------------------------------------------------------------------- /happynet/winerr.h: -------------------------------------------------------------------------------- 1 | #ifndef __WIN_ERROR_CLASS_H___ 2 | #define __WIN_ERROR_CLASS_H___ 3 | #include 4 | #include 5 | 6 | #ifndef tstring 7 | #ifdef _UNICODE 8 | #define tstring std::wstring 9 | #else 10 | #define tstring std::string 11 | #endif 12 | #endif 13 | 14 | ////////////////////////////////////////////////////////// 15 | // Desc: 16 | // Class wrapper for windows errors. This class 17 | // allows easy translation of error codes into 18 | // readable strings however, in order for it to 19 | // work proper it must be given a correct 20 | // module handle if the error code is not 21 | // direct from system. 22 | ////////////////////////////////////////////////////////// 23 | class CWinErr { 24 | public: 25 | CWinErr() { 26 | m_dwErr = 0; 27 | return; 28 | } 29 | 30 | CWinErr& operator = (DWORD dwCode) { 31 | m_dwErr = dwCode; 32 | return *this; 33 | } 34 | 35 | void SetCode(DWORD dwCode) { 36 | m_dwErr = dwCode; 37 | return; 38 | } 39 | 40 | DWORD GetCode() { 41 | return m_dwErr; 42 | } 43 | 44 | operator DWORD() { 45 | return m_dwErr; 46 | } 47 | 48 | tstring GetFormattedMsg(LPCTSTR lpszModule = NULL) 49 | { 50 | DWORD dwFmtRt = 0; 51 | DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM; 52 | LPVOID lpMsgBuf = NULL; 53 | HMODULE hLookupMod = NULL; 54 | tstring sMsg = _T(""); 55 | 56 | if (lpszModule != NULL) { 57 | hLookupMod = ::LoadLibraryEx(lpszModule, NULL, LOAD_LIBRARY_AS_DATAFILE); 58 | if (hLookupMod) { 59 | dwFlags |= FORMAT_MESSAGE_FROM_HMODULE; 60 | } 61 | } 62 | 63 | dwFmtRt = ::FormatMessage( 64 | dwFlags, 65 | (LPCVOID)hLookupMod, 66 | m_dwErr, 67 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 68 | (LPTSTR)&lpMsgBuf, 69 | 0, 70 | NULL); 71 | 72 | 73 | if (dwFmtRt != 0) sMsg = (TCHAR*)lpMsgBuf; 74 | if (lpMsgBuf) ::LocalFree(lpMsgBuf); 75 | if (hLookupMod) ::FreeLibrary(hLookupMod); 76 | 77 | return sMsg; 78 | } 79 | 80 | protected: 81 | DWORD m_dwErr; 82 | }; 83 | 84 | #endif // __WIN_ERROR_CLASS_H___ -------------------------------------------------------------------------------- /installer/happynet_install.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e4dcaf5c661159e7299d490c8de85669207f846c47f7963baee8af929272b1d3 3 | size 72344377 4 | -------------------------------------------------------------------------------- /installer/happynet_installer.nsi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/installer/happynet_installer.nsi -------------------------------------------------------------------------------- /installer/n2n_release/happynet.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/installer/n2n_release/happynet.ico -------------------------------------------------------------------------------- /installer/n2n_release/platforms/qminimal.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/installer/n2n_release/platforms/qminimal.dll -------------------------------------------------------------------------------- /installer/n2n_release/platforms/qoffscreen.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/installer/n2n_release/platforms/qoffscreen.dll -------------------------------------------------------------------------------- /installer/n2n_release/platforms/qwindows.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/installer/n2n_release/platforms/qwindows.dll -------------------------------------------------------------------------------- /installer/n2n_release/winxp/happynedge.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9328591736f6a062a3e61f0e5704007a51f45549927f8f84fdb92145012f552e 3 | size 391805 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x64/happynedge.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d718232d7d53f5fcbcffde7d236776f52e7e2ec4f46ad0c8ac0fa3581165ea3a 3 | size 373760 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x64/happynmonitor.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4eba29530583bba10bd884a8e7745076b642ded43971785f7c6ac2ae1ec10443 3 | size 43857404 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x64/happynportfwd.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:722c42551056fefd1d42febfa2c928ba6d6d4ec715a7616887743b48cbc4e5bf 3 | size 61952 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x64/happynroute.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6e10ecb8747bb32346e0921a3359b2f932aef51d9564a9a8b3d2fcb3ac7e197e 3 | size 21504 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x64/happynssm.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:eee9c44c29c2be011f1f1e43bb8c3fca888cb81053022ec5a0060035de16d848 3 | size 368640 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x86/happynedge.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a46ac50b0f798f728151d0ea23d734a4125dffb3a42bc31fcfb1aac23518b7ed 3 | size 322560 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x86/happynmonitor.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:87dffd474860c0f7b4f84f4d9c8fa4c143da3790d293f9a0e88c4620c7a4fff2 3 | size 26447063 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x86/happynportfwd.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a1f970915679ea97ad1dcde6add73762ee2695d9ac2f04aaa42ed1cace391012 3 | size 51712 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x86/happynroute.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f9a048d1e53fb1a498a401ef6aaf5347cfff26af2f0da89d4e9346a51495488c 3 | size 16896 4 | -------------------------------------------------------------------------------- /installer/n2n_release/x86/happynssm.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:682f1025b4c410ae78b1c5bdc4de7ad315f2eff292c66947c13969930028c98d 3 | size 324608 4 | -------------------------------------------------------------------------------- /installer/readme.txt: -------------------------------------------------------------------------------- 1 | Happynet Windows Client 2 | 3 | Powered by happyn.net 4 | 5 | Driver Version: 6 | 7 | NDIS6: tap-windows-9.21.2 8 | NDIS5: 2009 version 9 | -------------------------------------------------------------------------------- /screenshots/happyn01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/screenshots/happyn01.png -------------------------------------------------------------------------------- /screenshots/happyn02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/screenshots/happyn02.png -------------------------------------------------------------------------------- /screenshots/happyn03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/screenshots/happyn03.png -------------------------------------------------------------------------------- /tap_driver/NDIS5_x64/OemWin2k.inf: -------------------------------------------------------------------------------- 1 | ; **************************************************************************** 2 | ; * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. * 3 | ; * This program is free software; you can redistribute it and/or modify * 4 | ; * it under the terms of the GNU General Public License version 2 * 5 | ; * as published by the Free Software Foundation. * 6 | ; **************************************************************************** 7 | 8 | ; SYNTAX CHECKER 9 | ; cd \WINDDK\3790\tools\chkinf 10 | ; chkinf c:\src\openvpn\tap-win32\i386\oemwin2k.inf 11 | ; OUTPUT -> file:///c:/WINDDK/3790/tools/chkinf/htm/c%23+src+openvpn+tap-win32+i386+__OemWin2k.htm 12 | 13 | ; INSTALL/REMOVE DRIVER 14 | ; tapinstall install OemWin2k.inf TAP0901 15 | ; tapinstall update OemWin2k.inf TAP0901 16 | ; tapinstall remove TAP0901 17 | 18 | ;********************************************************* 19 | ; Note to Developers: 20 | ; 21 | ; If you are bundling the TAP-Windows driver with your app, 22 | ; you should try to rename it in such a way that it will 23 | ; not collide with other instances of TAP-Windows defined 24 | ; by other apps. Multiple versions of the TAP-Windows 25 | ; driver, each installed by different apps, can coexist 26 | ; on the same machine if you follow these guidelines. 27 | ; NOTE: these instructions assume you are editing the 28 | ; generated OemWin2k.inf file, not the source 29 | ; OemWin2k.inf.in file which is preprocessed by winconfig 30 | ; and uses macro definitions from settings.in. 31 | ; 32 | ; (1) Rename all tapXXXX instances in this file to 33 | ; something different (use at least 5 characters 34 | ; for this name!) 35 | ; (2) Change the "!define TAP" definition in openvpn.nsi 36 | ; to match what you changed tapXXXX to. 37 | ; (3) Change TARGETNAME in SOURCES to match what you 38 | ; changed tapXXXX to. 39 | ; (4) Change TAP_COMPONENT_ID in common.h to match what 40 | ; you changed tapXXXX to. 41 | ; (5) Change SZDEPENDENCIES in service.h to match what 42 | ; you changed tapXXXX to. 43 | ; (6) Change DeviceDescription and Provider strings. 44 | ; (7) Change PRODUCT_TAP_WIN_DEVICE_DESCRIPTION in constants.h to what you 45 | ; set DeviceDescription to. 46 | ; 47 | ;********************************************************* 48 | 49 | [Version] 50 | Signature = "$Windows NT$" 51 | CatalogFile = tap0901.cat 52 | ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318} 53 | Provider = %Provider% 54 | Class = Net 55 | 56 | ; This version number should match the version 57 | ; number given in SOURCES. 58 | DriverVer=07/02/2012,9.00.00.9 59 | 60 | [Strings] 61 | DeviceDescription = "TAP-Windows Adapter V9" 62 | Provider = "TAP-Windows Provider V9" 63 | 64 | ;---------------------------------------------------------------- 65 | ; Manufacturer + Product Section (Done) 66 | ;---------------------------------------------------------------- 67 | [Manufacturer] 68 | %Provider% = tap0901, NTamd64 69 | 70 | [tap0901.NTamd64] 71 | %DeviceDescription% = tap0901.ndi, tap0901 72 | 73 | ;--------------------------------------------------------------- 74 | ; Driver Section (Done) 75 | ;--------------------------------------------------------------- 76 | 77 | ;----------------- Characteristics ------------ 78 | ; NCF_PHYSICAL = 0x04 79 | ; NCF_VIRTUAL = 0x01 80 | ; NCF_SOFTWARE_ENUMERATED = 0x02 81 | ; NCF_HIDDEN = 0x08 82 | ; NCF_NO_SERVICE = 0x10 83 | ; NCF_HAS_UI = 0x80 84 | ;----------------- Characteristics ------------ 85 | 86 | [tap0901.ndi] 87 | CopyFiles = tap0901.driver, tap0901.files 88 | AddReg = tap0901.reg 89 | AddReg = tap0901.params.reg 90 | Characteristics = 0x81 91 | 92 | [tap0901.ndi.Services] 93 | AddService = tap0901, 2, tap0901.service 94 | 95 | [tap0901.reg] 96 | HKR, Ndi, Service, 0, "tap0901" 97 | HKR, Ndi\Interfaces, UpperRange, 0, "ndis5" 98 | HKR, Ndi\Interfaces, LowerRange, 0, "ethernet" 99 | HKR, , Manufacturer, 0, "%Provider%" 100 | HKR, , ProductName, 0, "%DeviceDescription%" 101 | 102 | [tap0901.params.reg] 103 | HKR, Ndi\params\MTU, ParamDesc, 0, "MTU" 104 | HKR, Ndi\params\MTU, Type, 0, "int" 105 | HKR, Ndi\params\MTU, Default, 0, "1500" 106 | HKR, Ndi\params\MTU, Optional, 0, "0" 107 | HKR, Ndi\params\MTU, Min, 0, "100" 108 | HKR, Ndi\params\MTU, Max, 0, "1500" 109 | HKR, Ndi\params\MTU, Step, 0, "1" 110 | HKR, Ndi\params\MediaStatus, ParamDesc, 0, "Media Status" 111 | HKR, Ndi\params\MediaStatus, Type, 0, "enum" 112 | HKR, Ndi\params\MediaStatus, Default, 0, "0" 113 | HKR, Ndi\params\MediaStatus, Optional, 0, "0" 114 | HKR, Ndi\params\MediaStatus\enum, "0", 0, "Application Controlled" 115 | HKR, Ndi\params\MediaStatus\enum, "1", 0, "Always Connected" 116 | HKR, Ndi\params\MAC, ParamDesc, 0, "MAC Address" 117 | HKR, Ndi\params\MAC, Type, 0, "edit" 118 | HKR, Ndi\params\MAC, Optional, 0, "1" 119 | HKR, Ndi\params\AllowNonAdmin, ParamDesc, 0, "Non-Admin Access" 120 | HKR, Ndi\params\AllowNonAdmin, Type, 0, "enum" 121 | HKR, Ndi\params\AllowNonAdmin, Default, 0, "1" 122 | HKR, Ndi\params\AllowNonAdmin, Optional, 0, "0" 123 | HKR, Ndi\params\AllowNonAdmin\enum, "0", 0, "Not Allowed" 124 | HKR, Ndi\params\AllowNonAdmin\enum, "1", 0, "Allowed" 125 | 126 | ;---------------------------------------------------------------- 127 | ; Service Section 128 | ;---------------------------------------------------------------- 129 | 130 | ;---------- Service Type ------------- 131 | ; SERVICE_KERNEL_DRIVER = 0x01 132 | ; SERVICE_WIN32_OWN_PROCESS = 0x10 133 | ;---------- Service Type ------------- 134 | 135 | ;---------- Start Mode --------------- 136 | ; SERVICE_BOOT_START = 0x0 137 | ; SERVICE_SYSTEM_START = 0x1 138 | ; SERVICE_AUTO_START = 0x2 139 | ; SERVICE_DEMAND_START = 0x3 140 | ; SERVICE_DISABLED = 0x4 141 | ;---------- Start Mode --------------- 142 | 143 | [tap0901.service] 144 | DisplayName = %DeviceDescription% 145 | ServiceType = 1 146 | StartType = 3 147 | ErrorControl = 1 148 | LoadOrderGroup = NDIS 149 | ServiceBinary = %12%\tap0901.sys 150 | 151 | ;----------------------------------------------------------------- 152 | ; File Installation 153 | ;----------------------------------------------------------------- 154 | 155 | ;----------------- Copy Flags ------------ 156 | ; COPYFLG_NOSKIP = 0x02 157 | ; COPYFLG_NOVERSIONCHECK = 0x04 158 | ;----------------- Copy Flags ------------ 159 | 160 | ; SourceDisksNames 161 | ; diskid = description[, [tagfile] [, , subdir]] 162 | ; 1 = "Intel Driver Disk 1",e100bex.sys,, 163 | 164 | [SourceDisksNames] 165 | 1 = %DeviceDescription%, tap0901.sys 166 | 167 | ; SourceDisksFiles 168 | ; filename_on_source = diskID[, [subdir][, size]] 169 | ; e100bex.sys = 1,, ; on distribution disk 1 170 | 171 | [SourceDisksFiles] 172 | tap0901.sys = 1 173 | 174 | [DestinationDirs] 175 | tap0901.files = 11 176 | tap0901.driver = 12 177 | 178 | [tap0901.files] 179 | ; TapPanel.cpl,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 180 | ; cipsrvr.exe,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 181 | 182 | [tap0901.driver] 183 | tap0901.sys,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 184 | 185 | ;--------------------------------------------------------------- 186 | ; End 187 | ;--------------------------------------------------------------- 188 | -------------------------------------------------------------------------------- /tap_driver/NDIS5_x64/tap0901.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS5_x64/tap0901.cat -------------------------------------------------------------------------------- /tap_driver/NDIS5_x64/tap0901.map: -------------------------------------------------------------------------------- 1 | tap0901 2 | 3 | Timestamp is 51150f66 (Fri Feb 08 06:44:54 2013) 4 | 5 | Preferred load address is 0000000000010000 6 | 7 | Start Length Name Class 8 | 0001:00000000 00005430H .text CODE 9 | 0001:00005430 000001c1H .text$s CODE 10 | 0002:00000000 00000138H .idata$5 DATA 11 | 0002:00000140 00000128H .rdata DATA 12 | 0002:00000268 00000051H .rdata$debug DATA 13 | 0002:000002c0 000006bcH .xdata DATA 14 | 0003:00000000 00000160H .data DATA 15 | 0003:00000160 00000038H .bss DATA 16 | 0004:00000000 000004f8H .pdata DATA 17 | 0005:00000000 0000024eH INIT CODE 18 | 0005:00000250 00000028H .idata$2 CODE 19 | 0005:00000278 00000014H .idata$3 CODE 20 | 0005:00000290 00000138H .idata$4 CODE 21 | 0005:000003c8 00000396H .idata$6 CODE 22 | 0006:00000000 00000058H .rsrc$01 DATA 23 | 0006:00000060 00000360H .rsrc$02 DATA 24 | 25 | Address Publics by Value Rva+Base Lib:Object 26 | 27 | 0000:00000000 ___safe_se_handler_count 0000000000000000 28 | 0000:00000000 ___safe_se_handler_table 0000000000000000 29 | 0000:00000000 __ImageBase 0000000000010000 30 | 0001:00000010 RtlStringCchPrintfExA 0000000000011010 f i tapdrvr.obj 31 | 0001:000001a0 MemAlloc 00000000000111a0 f tapdrvr.obj 32 | 0001:00000220 MemFree 0000000000011220 f tapdrvr.obj 33 | 0001:00000250 QueuePush 0000000000011250 f tapdrvr.obj 34 | 0001:00000290 QueuePop 0000000000011290 f tapdrvr.obj 35 | 0001:000002d0 ParseMAC 00000000000112d0 f tapdrvr.obj 36 | 0001:00000400 GenerateRandomMac 0000000000011400 f tapdrvr.obj 37 | 0001:000004d0 ip_checksum 00000000000114d0 f tapdrvr.obj 38 | 0001:00000560 udp_checksum 0000000000011560 f tapdrvr.obj 39 | 0001:00000670 DHCPMessageOurs 0000000000011670 f tapdrvr.obj 40 | 0001:00000780 BuildDHCPPre 0000000000011780 f tapdrvr.obj 41 | 0001:00000910 SendDHCPMsg 0000000000011910 f tapdrvr.obj 42 | 0001:00000bb0 ProcessDHCP 0000000000011bb0 f tapdrvr.obj 43 | 0001:00000d80 AddAdapterToInstanceList 0000000000011d80 f tapdrvr.obj 44 | 0001:00000e70 RemoveAdapterFromInstanceList 0000000000011e70 f tapdrvr.obj 45 | 0001:00000f90 LookupAdapterInInstanceList 0000000000011f90 f tapdrvr.obj 46 | 0001:000010a0 TapDriverUnload 00000000000120a0 f tapdrvr.obj 47 | 0001:000010d0 AdapterCreate 00000000000120d0 f tapdrvr.obj 48 | 0001:00001640 AdapterHalt 0000000000012640 f tapdrvr.obj 49 | 0001:00001700 TapDeviceFreeResources 0000000000012700 f tapdrvr.obj 50 | 0001:000017b0 CreateTapDevice 00000000000127b0 f tapdrvr.obj 51 | 0001:00001b50 AdapterReset 0000000000012b50 f tapdrvr.obj 52 | 0001:00001b50 AdapterReceive 0000000000012b50 f tapdrvr.obj 53 | 0001:00001b60 AdapterQuery 0000000000012b60 f tapdrvr.obj 54 | 0001:00001ea0 AdapterModify 0000000000012ea0 f tapdrvr.obj 55 | 0001:00002140 icmpv6_checksum 0000000000013140 f tapdrvr.obj 56 | 0001:00002240 HandleIPv6NeighborDiscovery 0000000000013240 f tapdrvr.obj 57 | 0001:00002440 AdapterTransmit 0000000000013440 f tapdrvr.obj 58 | 0001:000028b0 TapDeviceHook 00000000000138b0 f tapdrvr.obj 59 | 0001:000036a0 CompleteIRP 00000000000146a0 f tapdrvr.obj 60 | 0001:000037d0 CancelIRPCallback 00000000000147d0 f tapdrvr.obj 61 | 0001:00003820 CancelIRP 0000000000014820 f tapdrvr.obj 62 | 0001:00003930 FlushQueues 0000000000014930 f tapdrvr.obj 63 | 0001:00003ad0 SetMediaStatus 0000000000014ad0 f tapdrvr.obj 64 | 0001:00003b30 CheckIfDhcpAndTunMode 0000000000014b30 f tapdrvr.obj 65 | 0001:00003b70 ProcessARP 0000000000014b70 f tapdrvr.obj 66 | 0001:00003d60 InjectPacketDeferred 0000000000014d60 f tapdrvr.obj 67 | 0001:00003e60 InjectPacketDpc 0000000000014e60 f tapdrvr.obj 68 | 0001:00003f20 InjectPacketNow 0000000000014f20 f tapdrvr.obj 69 | 0001:00003fa0 ResetTapAdapterState 0000000000014fa0 f tapdrvr.obj 70 | 0001:00004020 AllowNonAdmin 0000000000015020 f tapdrvr.obj 71 | 0001:00004180 __security_check_cookie 0000000000015180 f BufferOverflowK:amdsecgs.obj 72 | 0001:000041a8 __report_gsfailure 00000000000151a8 f BufferOverflowK:gs_report.obj 73 | 0001:000041d8 RtlStringExHandleOtherFlagsA 00000000000151d8 f ntstrsafe:ntstrsafe.obj 74 | 0001:0000429c RtlStringExHandleFillBehindNullA 000000000001529c f ntstrsafe:ntstrsafe.obj 75 | 0001:000042c8 RtlStringVPrintfWorkerA 00000000000152c8 f ntstrsafe:ntstrsafe.obj 76 | 0001:00004344 RtlStringExValidateSrcA 0000000000015344 f ntstrsafe:ntstrsafe.obj 77 | 0001:0000437c RtlStringExValidateDestA 000000000001537c f ntstrsafe:ntstrsafe.obj 78 | 0001:000043a8 _vsnprintf_l 00000000000153a8 f ntstrsafe:vsnprint.obj 79 | 0001:00004454 _vsnprintf 0000000000015454 f ntstrsafe:vsnprint.obj 80 | 0001:00004480 memset 0000000000015480 f ntstrsafe:memset.obj 81 | 0001:00004570 _flsbuf 0000000000015570 f ntstrsafe:_flsbuf.obj 82 | 0001:000046ac _output_l 00000000000156ac f ntstrsafe:output.obj 83 | 0001:00004eac _invalid_parameter 0000000000015eac f ntstrsafe:invargk.obj 84 | 0001:00004eb8 __GSHandlerCheckCommon 0000000000015eb8 f ntstrsafe:gshandler.obj 85 | 0001:00004f24 __GSHandlerCheck 0000000000015f24 f ntstrsafe:gshandler.obj 86 | 0001:00004f48 _get_printf_count_output 0000000000015f48 f ntstrsafe:printfcount.obj 87 | 0001:00004f68 _wctomb_s_l 0000000000015f68 f ntstrsafe:_wctomb.obj 88 | 0001:00005018 wctomb_s 0000000000016018 f ntstrsafe:_wctomb.obj 89 | 0001:00005032 RtlUnicodeToMultiByteN 0000000000016032 f ntoskrnl:ntoskrnl.exe 90 | 0001:0000503e __C_specific_handler 000000000001603e f ntoskrnl:ntoskrnl.exe 91 | 0001:00005060 memmove 0000000000016060 ntoskrnl:memcpy.obj 92 | 0001:00005060 memcpy 0000000000016060 f ntoskrnl:memcpy.obj 93 | 0001:0000539c __GSHandlerCheck_SEH 000000000001639c f ntoskrnl:gshandlerseh.obj 94 | 0001:00005430 ??_C@_00CNPNBAHC@?$AA@FNODOBFM@ 0000000000016430 ntstrsafe:ntstrsafe.obj 95 | 0001:00005440 ??_C@_1BK@KPLOIJDF@?$AAM?$AAi?$AAn?$AAi?$AAp?$AAo?$AAr?$AAt?$AAN?$AAa?$AAm?$AAe?$AA?$AA@FNODOBFM@ 0000000000016440 tapdrvr.obj 96 | 0001:00005460 ??_C@_1BI@FJLCDAFI@?$AAN?$AAd?$AAi?$AAs?$AAV?$AAe?$AAr?$AAs?$AAi?$AAo?$AAn?$AA?$AA@FNODOBFM@ 0000000000016460 tapdrvr.obj 97 | 0001:00005480 ??_C@_17EDIJECNL@?$AAM?$AAT?$AAU?$AA?$AA@FNODOBFM@ 0000000000016480 tapdrvr.obj 98 | 0001:00005490 ??_C@_1BI@OIOAKOGO@?$AAM?$AAe?$AAd?$AAi?$AAa?$AAS?$AAt?$AAa?$AAt?$AAu?$AAs?$AA?$AA@FNODOBFM@ 0000000000016490 tapdrvr.obj 99 | 0001:000054b0 ??_C@_1BM@GLFAMKNK@?$AAA?$AAl?$AAl?$AAo?$AAw?$AAN?$AAo?$AAn?$AAA?$AAd?$AAm?$AAi?$AAn?$AA?$AA@FNODOBFM@ 00000000000164b0 tapdrvr.obj 100 | 0001:000054d0 ??_C@_17GFOANJLA@?$AAM?$AAA?$AAC?$AA?$AA@FNODOBFM@ 00000000000164d0 tapdrvr.obj 101 | 0001:000054e0 ??_C@_0DB@OKCDKKLN@c?3?2users?2samuli?2tap?9windows?9gith@FNODOBFM@ 00000000000164e0 tapdrvr.obj 102 | 0001:00005520 ??_C@_04MFFLHGKN@?4tap?$AA@FNODOBFM@ 0000000000016520 tapdrvr.obj 103 | 0001:00005530 ??_C@_08MBBBEOPI@?2Device?2?$AA@FNODOBFM@ 0000000000016530 tapdrvr.obj 104 | 0001:00005540 ??_C@_06DIJPEION@?$CFs?$CFs?$CFs?$AA@FNODOBFM@ 0000000000016540 tapdrvr.obj 105 | 0001:00005550 ??_C@_0BE@DCPFOPDJ@?2DosDevices?2Global?2?$AA@FNODOBFM@ 0000000000016550 tapdrvr.obj 106 | 0001:00005570 ??_C@_0BH@DIGKNCEH@TAP?9Windows?5Adapter?5V9?$AA@FNODOBFM@ 0000000000016570 tapdrvr.obj 107 | 0001:00005590 ??_C@_0GB@BOPJCIOJ@State?$DN?$CFs?5Err?$DN?$FL?$CFs?1?$CFd?$FN?5?$CDO?$DN?$CFd?5Tx?$DN?$FL?$CF@FNODOBFM@ 0000000000016590 tapdrvr.obj 108 | 0002:00000000 __imp_NdisMRegisterAdapterShutdownHandler 0000000000017000 ndis:NDIS.SYS 109 | 0002:00000008 __imp_NdisAllocateMemoryWithTag 0000000000017008 ndis:NDIS.SYS 110 | 0002:00000010 __imp_NdisReadConfiguration 0000000000017010 ndis:NDIS.SYS 111 | 0002:00000018 __imp_NdisTerminateWrapper 0000000000017018 ndis:NDIS.SYS 112 | 0002:00000020 __imp_NdisMDeregisterDevice 0000000000017020 ndis:NDIS.SYS 113 | 0002:00000028 __imp_NdisMDeregisterAdapterShutdownHandler 0000000000017028 ndis:NDIS.SYS 114 | 0002:00000030 __imp_NdisMSetAttributesEx 0000000000017030 ndis:NDIS.SYS 115 | 0002:00000038 __imp_NdisInitializeWrapper 0000000000017038 ndis:NDIS.SYS 116 | 0002:00000040 __imp_NdisFreeMemory 0000000000017040 ndis:NDIS.SYS 117 | 0002:00000048 __imp_NdisMRegisterMiniport 0000000000017048 ndis:NDIS.SYS 118 | 0002:00000050 __imp_NdisCloseConfiguration 0000000000017050 ndis:NDIS.SYS 119 | 0002:00000058 __imp_NdisMRegisterDevice 0000000000017058 ndis:NDIS.SYS 120 | 0002:00000060 __imp_NdisMRegisterUnloadHandler 0000000000017060 ndis:NDIS.SYS 121 | 0002:00000068 __imp_NdisMIndicateStatus 0000000000017068 ndis:NDIS.SYS 122 | 0002:00000070 __imp_NdisMIndicateStatusComplete 0000000000017070 ndis:NDIS.SYS 123 | 0002:00000078 __imp_NdisMSleep 0000000000017078 ndis:NDIS.SYS 124 | 0002:00000080 __imp_NdisOpenConfiguration 0000000000017080 ndis:NDIS.SYS 125 | 0002:00000088 \177NDIS_NULL_THUNK_DATA 0000000000017088 ndis:NDIS.SYS 126 | 0002:00000090 __imp_KeBugCheckEx 0000000000017090 ntoskrnl:ntoskrnl.exe 127 | 0002:00000098 __imp_KeAcquireSpinLockRaiseToDpc 0000000000017098 ntoskrnl:ntoskrnl.exe 128 | 0002:000000a0 __imp_KeRemoveQueueDpc 00000000000170a0 ntoskrnl:ntoskrnl.exe 129 | 0002:000000a8 __imp_RtlCreateSecurityDescriptor 00000000000170a8 ntoskrnl:ntoskrnl.exe 130 | 0002:000000b0 __imp_IoReleaseCancelSpinLock 00000000000170b0 ntoskrnl:ntoskrnl.exe 131 | 0002:000000b8 __imp_ZwOpenFile 00000000000170b8 ntoskrnl:ntoskrnl.exe 132 | 0002:000000c0 __imp_RtlFreeAnsiString 00000000000170c0 ntoskrnl:ntoskrnl.exe 133 | 0002:000000c8 __imp_ZwSetSecurityObject 00000000000170c8 ntoskrnl:ntoskrnl.exe 134 | 0002:000000d0 __imp_IofCompleteRequest 00000000000170d0 ntoskrnl:ntoskrnl.exe 135 | 0002:000000d8 __imp_ZwClose 00000000000170d8 ntoskrnl:ntoskrnl.exe 136 | 0002:000000e0 __imp_KeInsertQueueDpc 00000000000170e0 ntoskrnl:ntoskrnl.exe 137 | 0002:000000e8 __imp_MmMapLockedPagesSpecifyCache 00000000000170e8 ntoskrnl:ntoskrnl.exe 138 | 0002:000000f0 __imp_RtlFreeUnicodeString 00000000000170f0 ntoskrnl:ntoskrnl.exe 139 | 0002:000000f8 __imp_KeReleaseSpinLock 00000000000170f8 ntoskrnl:ntoskrnl.exe 140 | 0002:00000100 __imp_KeInitializeDpc 0000000000017100 ntoskrnl:ntoskrnl.exe 141 | 0002:00000108 __imp_RtlUnicodeStringToAnsiString 0000000000017108 ntoskrnl:ntoskrnl.exe 142 | 0002:00000110 __imp_MmMapLockedPages 0000000000017110 ntoskrnl:ntoskrnl.exe 143 | 0002:00000118 __imp_RtlAnsiStringToUnicodeString 0000000000017118 ntoskrnl:ntoskrnl.exe 144 | 0002:00000120 __imp_RtlUnicodeToMultiByteN 0000000000017120 ntoskrnl:ntoskrnl.exe 145 | 0002:00000128 __imp___C_specific_handler 0000000000017128 ntoskrnl:ntoskrnl.exe 146 | 0002:00000130 \177ntoskrnl_NULL_THUNK_DATA 0000000000017130 ntoskrnl:ntoskrnl.exe 147 | 0002:00000160 ??_C@_1O@CEDCILHN@?$AA?$CI?$AAn?$AAu?$AAl?$AAl?$AA?$CJ?$AA?$AA@ 0000000000017160 ntstrsafe:output.obj 148 | 0002:00000170 ??_C@_06OJHGLDPL@?$CInull?$CJ?$AA@ 0000000000017170 ntstrsafe:output.obj 149 | 0002:00000180 __lookuptable 0000000000017180 ntstrsafe:output.obj 150 | 0002:000001e0 g_SupportedOIDList 00000000000171e0 tapdrvr.obj 151 | 0003:00000000 HotPatchBuffer 0000000000018000 hotpatch.obj 152 | 0003:00000100 __security_cookie 0000000000018100 BufferOverflowK:gs_support.obj 153 | 0003:00000108 __security_cookie_complement 0000000000018108 BufferOverflowK:gs_support.obj 154 | 0003:00000110 __nullstring 0000000000018110 ntstrsafe:output.obj 155 | 0003:00000118 __wnullstring 0000000000018118 ntstrsafe:output.obj 156 | 0003:00000120 _fltused 0000000000018120 ntstrsafe:stubs.obj 157 | 0003:00000124 _ldused 0000000000018124 ntstrsafe:stubs.obj 158 | 0003:00000128 __mb_cur_max 0000000000018128 ntstrsafe:nlsdata1.obj 159 | 0003:0000012c __decimal_point 000000000001812c ntstrsafe:nlsdata1.obj 160 | 0003:00000130 __decimal_point_length 0000000000018130 ntstrsafe:nlsdata1.obj 161 | 0003:00000160 __fastflag 0000000000018160 ntstrsafe:stubs.obj 162 | 0003:00000170 g_InstanceHash 0000000000018170 tapdrvr.obj 163 | 0003:00000178 errno 0000000000018178 164 | 0003:00000180 g_NdisWrapperHandle 0000000000018180 165 | 0003:00000188 g_LastErrorLineNumber 0000000000018188 166 | 0003:00000190 g_LastErrorFilename 0000000000018190 167 | 0005:00000010 DriverEntry 000000000001a010 f tapdrvr.obj 168 | 0005:000001d4 __security_init_cookie 000000000001a1d4 f BufferOverflowK:gs_support.obj 169 | 0005:00000230 GsDriverEntry 000000000001a230 f BufferOverflowK:gs_support.obj 170 | 0005:00000250 __IMPORT_DESCRIPTOR_ntoskrnl 000000000001a250 ntoskrnl:ntoskrnl.exe 171 | 0005:00000264 __IMPORT_DESCRIPTOR_NDIS 000000000001a264 ndis:NDIS.SYS 172 | 0005:00000278 __NULL_IMPORT_DESCRIPTOR 000000000001a278 ntoskrnl:ntoskrnl.exe 173 | 174 | entry point at 0005:00000230 175 | 176 | Static symbols 177 | 178 | 0001:00004580 write_char 0000000000015580 f ntstrsafe:output.obj 179 | 0001:000045d0 write_multi_char 00000000000155d0 f ntstrsafe:output.obj 180 | 0001:00004628 write_string 0000000000015628 f ntstrsafe:output.obj 181 | -------------------------------------------------------------------------------- /tap_driver/NDIS5_x64/tap0901.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS5_x64/tap0901.sys -------------------------------------------------------------------------------- /tap_driver/NDIS5_x64/tapinstall.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:af0c471e1612ddeed76562b64955df46318b1cf3996cf19f77f7843ef83b394b 3 | size 81408 4 | -------------------------------------------------------------------------------- /tap_driver/NDIS5_x86/OemWin2k.inf: -------------------------------------------------------------------------------- 1 | ; **************************************************************************** 2 | ; * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. * 3 | ; * This program is free software; you can redistribute it and/or modify * 4 | ; * it under the terms of the GNU General Public License version 2 * 5 | ; * as published by the Free Software Foundation. * 6 | ; **************************************************************************** 7 | 8 | ; SYNTAX CHECKER 9 | ; cd \WINDDK\3790\tools\chkinf 10 | ; chkinf c:\src\openvpn\tap-win32\i386\oemwin2k.inf 11 | ; OUTPUT -> file:///c:/WINDDK/3790/tools/chkinf/htm/c%23+src+openvpn+tap-win32+i386+__OemWin2k.htm 12 | 13 | ; INSTALL/REMOVE DRIVER 14 | ; tapinstall install OemWin2k.inf TAP0901 15 | ; tapinstall update OemWin2k.inf TAP0901 16 | ; tapinstall remove TAP0901 17 | 18 | ;********************************************************* 19 | ; Note to Developers: 20 | ; 21 | ; If you are bundling the TAP-Windows driver with your app, 22 | ; you should try to rename it in such a way that it will 23 | ; not collide with other instances of TAP-Windows defined 24 | ; by other apps. Multiple versions of the TAP-Windows 25 | ; driver, each installed by different apps, can coexist 26 | ; on the same machine if you follow these guidelines. 27 | ; NOTE: these instructions assume you are editing the 28 | ; generated OemWin2k.inf file, not the source 29 | ; OemWin2k.inf.in file which is preprocessed by winconfig 30 | ; and uses macro definitions from settings.in. 31 | ; 32 | ; (1) Rename all tapXXXX instances in this file to 33 | ; something different (use at least 5 characters 34 | ; for this name!) 35 | ; (2) Change the "!define TAP" definition in openvpn.nsi 36 | ; to match what you changed tapXXXX to. 37 | ; (3) Change TARGETNAME in SOURCES to match what you 38 | ; changed tapXXXX to. 39 | ; (4) Change TAP_COMPONENT_ID in common.h to match what 40 | ; you changed tapXXXX to. 41 | ; (5) Change SZDEPENDENCIES in service.h to match what 42 | ; you changed tapXXXX to. 43 | ; (6) Change DeviceDescription and Provider strings. 44 | ; (7) Change PRODUCT_TAP_WIN_DEVICE_DESCRIPTION in constants.h to what you 45 | ; set DeviceDescription to. 46 | ; 47 | ;********************************************************* 48 | 49 | [Version] 50 | Signature = "$Windows NT$" 51 | CatalogFile = tap0901.cat 52 | ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318} 53 | Provider = %Provider% 54 | Class = Net 55 | 56 | ; This version number should match the version 57 | ; number given in SOURCES. 58 | DriverVer=07/02/2012,9.00.00.9 59 | 60 | [Strings] 61 | DeviceDescription = "TAP-Windows Adapter V9" 62 | Provider = "TAP-Windows Provider V9" 63 | 64 | ;---------------------------------------------------------------- 65 | ; Manufacturer + Product Section (Done) 66 | ;---------------------------------------------------------------- 67 | [Manufacturer] 68 | %Provider% = tap0901 69 | 70 | [tap0901] 71 | %DeviceDescription% = tap0901.ndi, tap0901 72 | 73 | ;--------------------------------------------------------------- 74 | ; Driver Section (Done) 75 | ;--------------------------------------------------------------- 76 | 77 | ;----------------- Characteristics ------------ 78 | ; NCF_PHYSICAL = 0x04 79 | ; NCF_VIRTUAL = 0x01 80 | ; NCF_SOFTWARE_ENUMERATED = 0x02 81 | ; NCF_HIDDEN = 0x08 82 | ; NCF_NO_SERVICE = 0x10 83 | ; NCF_HAS_UI = 0x80 84 | ;----------------- Characteristics ------------ 85 | 86 | [tap0901.ndi] 87 | CopyFiles = tap0901.driver, tap0901.files 88 | AddReg = tap0901.reg 89 | AddReg = tap0901.params.reg 90 | Characteristics = 0x81 91 | 92 | [tap0901.ndi.Services] 93 | AddService = tap0901, 2, tap0901.service 94 | 95 | [tap0901.reg] 96 | HKR, Ndi, Service, 0, "tap0901" 97 | HKR, Ndi\Interfaces, UpperRange, 0, "ndis5" 98 | HKR, Ndi\Interfaces, LowerRange, 0, "ethernet" 99 | HKR, , Manufacturer, 0, "%Provider%" 100 | HKR, , ProductName, 0, "%DeviceDescription%" 101 | 102 | [tap0901.params.reg] 103 | HKR, Ndi\params\MTU, ParamDesc, 0, "MTU" 104 | HKR, Ndi\params\MTU, Type, 0, "int" 105 | HKR, Ndi\params\MTU, Default, 0, "1500" 106 | HKR, Ndi\params\MTU, Optional, 0, "0" 107 | HKR, Ndi\params\MTU, Min, 0, "100" 108 | HKR, Ndi\params\MTU, Max, 0, "1500" 109 | HKR, Ndi\params\MTU, Step, 0, "1" 110 | HKR, Ndi\params\MediaStatus, ParamDesc, 0, "Media Status" 111 | HKR, Ndi\params\MediaStatus, Type, 0, "enum" 112 | HKR, Ndi\params\MediaStatus, Default, 0, "0" 113 | HKR, Ndi\params\MediaStatus, Optional, 0, "0" 114 | HKR, Ndi\params\MediaStatus\enum, "0", 0, "Application Controlled" 115 | HKR, Ndi\params\MediaStatus\enum, "1", 0, "Always Connected" 116 | HKR, Ndi\params\MAC, ParamDesc, 0, "MAC Address" 117 | HKR, Ndi\params\MAC, Type, 0, "edit" 118 | HKR, Ndi\params\MAC, Optional, 0, "1" 119 | HKR, Ndi\params\AllowNonAdmin, ParamDesc, 0, "Non-Admin Access" 120 | HKR, Ndi\params\AllowNonAdmin, Type, 0, "enum" 121 | HKR, Ndi\params\AllowNonAdmin, Default, 0, "1" 122 | HKR, Ndi\params\AllowNonAdmin, Optional, 0, "0" 123 | HKR, Ndi\params\AllowNonAdmin\enum, "0", 0, "Not Allowed" 124 | HKR, Ndi\params\AllowNonAdmin\enum, "1", 0, "Allowed" 125 | 126 | ;---------------------------------------------------------------- 127 | ; Service Section 128 | ;---------------------------------------------------------------- 129 | 130 | ;---------- Service Type ------------- 131 | ; SERVICE_KERNEL_DRIVER = 0x01 132 | ; SERVICE_WIN32_OWN_PROCESS = 0x10 133 | ;---------- Service Type ------------- 134 | 135 | ;---------- Start Mode --------------- 136 | ; SERVICE_BOOT_START = 0x0 137 | ; SERVICE_SYSTEM_START = 0x1 138 | ; SERVICE_AUTO_START = 0x2 139 | ; SERVICE_DEMAND_START = 0x3 140 | ; SERVICE_DISABLED = 0x4 141 | ;---------- Start Mode --------------- 142 | 143 | [tap0901.service] 144 | DisplayName = %DeviceDescription% 145 | ServiceType = 1 146 | StartType = 3 147 | ErrorControl = 1 148 | LoadOrderGroup = NDIS 149 | ServiceBinary = %12%\tap0901.sys 150 | 151 | ;----------------------------------------------------------------- 152 | ; File Installation 153 | ;----------------------------------------------------------------- 154 | 155 | ;----------------- Copy Flags ------------ 156 | ; COPYFLG_NOSKIP = 0x02 157 | ; COPYFLG_NOVERSIONCHECK = 0x04 158 | ;----------------- Copy Flags ------------ 159 | 160 | ; SourceDisksNames 161 | ; diskid = description[, [tagfile] [, , subdir]] 162 | ; 1 = "Intel Driver Disk 1",e100bex.sys,, 163 | 164 | [SourceDisksNames] 165 | 1 = %DeviceDescription%, tap0901.sys 166 | 167 | ; SourceDisksFiles 168 | ; filename_on_source = diskID[, [subdir][, size]] 169 | ; e100bex.sys = 1,, ; on distribution disk 1 170 | 171 | [SourceDisksFiles] 172 | tap0901.sys = 1 173 | 174 | [DestinationDirs] 175 | tap0901.files = 11 176 | tap0901.driver = 12 177 | 178 | [tap0901.files] 179 | ; TapPanel.cpl,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 180 | ; cipsrvr.exe,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 181 | 182 | [tap0901.driver] 183 | tap0901.sys,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 184 | 185 | ;--------------------------------------------------------------- 186 | ; End 187 | ;--------------------------------------------------------------- 188 | -------------------------------------------------------------------------------- /tap_driver/NDIS5_x86/tap0901.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS5_x86/tap0901.cat -------------------------------------------------------------------------------- /tap_driver/NDIS5_x86/tap0901.map: -------------------------------------------------------------------------------- 1 | tap0901 2 | 3 | Timestamp is 51150f64 (Fri Feb 08 06:44:52 2013) 4 | 5 | Preferred load address is 00010000 6 | 7 | Start Length Name Class 8 | 0001:00000000 00004becH .text CODE 9 | 0001:00004bf0 000001bbH .text$s CODE 10 | 0002:00000000 000000b0H .idata$5 DATA 11 | 0002:000000b0 00000168H .rdata DATA 12 | 0002:00000218 00000050H .rdata$debug DATA 13 | 0002:00000270 00000008H .rdata$sxdata DATA 14 | 0002:00000278 000000d0H .xdata$x DATA 15 | 0003:00000000 0000005cH .data DATA 16 | 0003:00000060 0000001cH .bss DATA 17 | 0004:00000000 0000016fH INIT CODE 18 | 0004:00000170 0000003cH .idata$2 CODE 19 | 0004:000001ac 00000014H .idata$3 CODE 20 | 0004:000001c0 000000b0H .idata$4 CODE 21 | 0004:00000270 000003beH .idata$6 CODE 22 | 0005:00000000 00000058H .rsrc$01 DATA 23 | 0005:00000060 00000360H .rsrc$02 DATA 24 | 25 | Address Publics by Value Rva+Base Lib:Object 26 | 27 | 0000:00000002 ___safe_se_handler_count 00000002 28 | 0001:00000010 _RtlStringCchPrintfExA 00010490 f i tapdrvr.obj 29 | 0001:00000140 _MemAlloc@8 000105c0 f tapdrvr.obj 30 | 0001:00000220 _MemFree@8 000106a0 f tapdrvr.obj 31 | 0001:000002a0 _QueueInit@4 00010720 f tapdrvr.obj 32 | 0001:000002e0 _QueuePush@8 00010760 f tapdrvr.obj 33 | 0001:00000330 _QueuePop@4 000107b0 f tapdrvr.obj 34 | 0001:00000380 _QueueExtract@8 00010800 f tapdrvr.obj 35 | 0001:000003e0 _ParseMAC@8 00010860 f tapdrvr.obj 36 | 0001:000004c0 _GenerateRandomMac@8 00010940 f tapdrvr.obj 37 | 0001:000005a0 _SetDHCPOpt@12 00010a20 f tapdrvr.obj 38 | 0001:000005f0 _SetDHCPOpt8@12 00010a70 f tapdrvr.obj 39 | 0001:00000650 _SetDHCPOpt32@12 00010ad0 f tapdrvr.obj 40 | 0001:000006b0 _ip_checksum@8 00010b30 f tapdrvr.obj 41 | 0001:00000760 _udp_checksum@16 00010be0 f tapdrvr.obj 42 | 0001:00000830 _SetChecksumDHCPMsg@4 00010cb0 f tapdrvr.obj 43 | 0001:00000880 _GetDHCPMessageType@8 00010d00 f tapdrvr.obj 44 | 0001:000008f0 _DHCPMessageOurs@20 00010d70 f tapdrvr.obj 45 | 0001:00000a00 _BuildDHCPPre@32 00010e80 f tapdrvr.obj 46 | 0001:00000b70 _InitInstanceList@0 00010ff0 f tapdrvr.obj 47 | 0001:00000bb0 _AddAdapterToInstanceList@4 00011030 f tapdrvr.obj 48 | 0001:00000c60 _RemoveAdapterFromInstanceList@4 000110e0 f tapdrvr.obj 49 | 0001:00000d40 _LookupAdapterInInstanceList@4 000111c0 f tapdrvr.obj 50 | 0001:00000e10 _TapDriverUnload@4 00011290 f tapdrvr.obj 51 | 0001:00000e40 _TapDeviceFreeResources@4 000112c0 f tapdrvr.obj 52 | 0001:00000ee0 _AdapterReset@8 00011360 f tapdrvr.obj 53 | 0001:00000ef0 _AdapterReceive@24 00011370 f tapdrvr.obj 54 | 0001:00000f00 _AdapterQuery@24 00011380 f tapdrvr.obj 55 | 0001:000012a0 _AdapterModify@24 00011720 f tapdrvr.obj 56 | 0001:000014e0 _icmpv6_checksum@16 00011960 f tapdrvr.obj 57 | 0001:000015b0 _CompleteIRP@12 00011a30 f tapdrvr.obj 58 | 0001:00001710 _CancelIRP@12 00011b90 f tapdrvr.obj 59 | 0001:000017a0 _FlushQueues@4 00011c20 f tapdrvr.obj 60 | 0001:00001900 _SetMediaStatus@8 00011d80 f tapdrvr.obj 61 | 0001:00001960 _CheckIfDhcpAndTunMode@4 00011de0 f tapdrvr.obj 62 | 0001:000019b0 _InjectPacketDeferred@12 00011e30 f tapdrvr.obj 63 | 0001:00001a90 _InjectPacketNow@12 00011f10 f tapdrvr.obj 64 | 0001:00001b50 _ResetTapAdapterState@4 00011fd0 f tapdrvr.obj 65 | 0001:00001bd0 _AllowNonAdmin@4 00012050 f tapdrvr.obj 66 | 0001:00001d10 _SendDHCPMsg@24 00012190 f tapdrvr.obj 67 | 0001:00001e10 _ProcessDHCP@24 00012290 f tapdrvr.obj 68 | 0001:00001fc0 _HandleIPv6NeighborDiscovery@8 00012440 f tapdrvr.obj 69 | 0001:000021a0 _CancelIRPCallback@8 00012620 f tapdrvr.obj 70 | 0001:000021e0 _ProcessARP@24 00012660 f tapdrvr.obj 71 | 0001:000023b0 _InjectPacketDpc@16 00012830 f tapdrvr.obj 72 | 0001:00002450 _AdapterHalt@4 000128d0 f tapdrvr.obj 73 | 0001:000024f0 _AdapterTransmit@12 00012970 f tapdrvr.obj 74 | 0001:00002960 _TapDeviceHook@8 00012de0 f tapdrvr.obj 75 | 0001:00003450 _CreateTapDevice@8 000138d0 f tapdrvr.obj 76 | 0001:000036a0 _AdapterCreate@24 00013b20 f tapdrvr.obj 77 | 0001:00003ad1 @__security_check_cookie@4 00013f51 f BufferOverflowK:secchk.obj 78 | 0001:00003ae6 ___report_gsfailure 00013f66 f BufferOverflowK:gs_report.obj 79 | 0001:00003b12 _memset 00013f92 f ntoskrnl:ntoskrnl.exe 80 | 0001:00003b1e _memcpy 00013f9e f ntoskrnl:ntoskrnl.exe 81 | 0001:00003b2a _RtlStringExValidateSrcA@16 00013faa f ntstrsafe:ntstrsafe.obj 82 | 0001:00003b6c _RtlStringValidateDestA@12 00013fec f ntstrsafe:ntstrsafe.obj 83 | 0001:00003b8e _RtlStringExValidateDestA@16 0001400e f ntstrsafe:ntstrsafe.obj 84 | 0001:00003bce _RtlStringVPrintfWorkerA@20 0001404e f ntstrsafe:ntstrsafe.obj 85 | 0001:00003c20 _RtlStringExHandleFillBehindNullA@12 000140a0 f ntstrsafe:ntstrsafe.obj 86 | 0001:00003c50 _RtlStringExHandleOtherFlagsA@24 000140d0 f ntstrsafe:ntstrsafe.obj 87 | 0001:00003cf0 __except_handler4 00014170 f ntstrsafe:chandler4.obj 88 | 0001:00003e49 __vsnprintf_l 000142c9 f ntstrsafe:vsnprint.obj 89 | 0001:00003ee8 __vsnprintf 00014368 f ntstrsafe:vsnprint.obj 90 | 0001:00003f0c __local_unwind4 0001438c f ntstrsafe:exsup4.obj 91 | 0001:00003fe2 __seh_longjmp_unwind4@4 00014462 f ntstrsafe:exsup4.obj 92 | 0001:00003ffe @_EH4_CallFilterFunc@8 0001447e f ntstrsafe:exsup4.obj 93 | 0001:00004015 @_EH4_TransferToHandler@8 00014495 f ntstrsafe:exsup4.obj 94 | 0001:0000402e @_EH4_GlobalUnwind@4 000144ae f ntstrsafe:exsup4.obj 95 | 0001:00004048 @_EH4_LocalUnwind@16 000144c8 f ntstrsafe:exsup4.obj 96 | 0001:00004064 __flsbuf 000144e4 f ntstrsafe:_flsbuf.obj 97 | 0001:0000412e __output_l 000145ae f ntstrsafe:output.obj 98 | 0001:00004a3b __invalid_parameter 00014ebb f ntstrsafe:invargk.obj 99 | 0001:00004a44 __NLG_Notify1 00014ec4 f ntstrsafe:_nlgsupp.obj 100 | 0001:00004a4d __NLG_Notify 00014ecd f ntstrsafe:_nlgsupp.obj 101 | 0001:00004a64 __NLG_Dispatch 00014ee4 ntstrsafe:_nlgsupp.obj 102 | 0001:00004a64 __NLG_Dispatch2 00014ee4 ntstrsafe:_nlgsupp.obj 103 | 0001:00004a6c __NLG_Call 00014eec f ntstrsafe:_nlgsupp.obj 104 | 0001:00004a6e __NLG_Return2 00014eee ntstrsafe:_nlgsupp.obj 105 | 0001:00004a74 __get_printf_count_output 00014ef4 f ntstrsafe:printfcount.obj 106 | 0001:00004a8f __wctomb_s_l 00014f0f f ntstrsafe:_wctomb.obj 107 | 0001:00004b1b _wctomb_s 00014f9b f ntstrsafe:_wctomb.obj 108 | 0001:00004b40 __aulldvrm 00014fc0 f ntstrsafe:ulldvrm.obj 109 | 0001:00004bda _RtlUnwind@16 0001505a f ntoskrnl:ntoskrnl.exe 110 | 0001:00004be6 _RtlUnicodeToMultiByteN@20 00015066 f ntoskrnl:ntoskrnl.exe 111 | 0001:00004bf0 ??_C@_0BH@DIGKNCEH@TAP?9Windows?5Adapter?5V9?$AA@FNODOBFM@ 00015070 tapdrvr.obj 112 | 0001:00004c10 ??_C@_0DB@OKCDKKLN@c?3?2users?2samuli?2tap?9windows?9gith@FNODOBFM@ 00015090 tapdrvr.obj 113 | 0001:00004c50 ??_C@_0GB@BOPJCIOJ@State?$DN?$CFs?5Err?$DN?$FL?$CFs?1?$CFd?$FN?5?$CDO?$DN?$CFd?5Tx?$DN?$FL?$CF@FNODOBFM@ 000150d0 tapdrvr.obj 114 | 0001:00004cc0 ??_C@_0BE@DCPFOPDJ@?2DosDevices?2Global?2?$AA@FNODOBFM@ 00015140 tapdrvr.obj 115 | 0001:00004ce0 ??_C@_06DIJPEION@?$CFs?$CFs?$CFs?$AA@FNODOBFM@ 00015160 tapdrvr.obj 116 | 0001:00004cf0 ??_C@_08MBBBEOPI@?2Device?2?$AA@FNODOBFM@ 00015170 tapdrvr.obj 117 | 0001:00004d00 ??_C@_04MFFLHGKN@?4tap?$AA@FNODOBFM@ 00015180 tapdrvr.obj 118 | 0001:00004d10 ??_C@_17GFOANJLA@?$AAM?$AAA?$AAC?$AA?$AA@FNODOBFM@ 00015190 tapdrvr.obj 119 | 0001:00004d20 ??_C@_1BM@GLFAMKNK@?$AAA?$AAl?$AAl?$AAo?$AAw?$AAN?$AAo?$AAn?$AAA?$AAd?$AAm?$AAi?$AAn?$AA?$AA@FNODOBFM@ 000151a0 tapdrvr.obj 120 | 0001:00004d40 ??_C@_1BI@OIOAKOGO@?$AAM?$AAe?$AAd?$AAi?$AAa?$AAS?$AAt?$AAa?$AAt?$AAu?$AAs?$AA?$AA@FNODOBFM@ 000151c0 tapdrvr.obj 121 | 0001:00004d60 ??_C@_17EDIJECNL@?$AAM?$AAT?$AAU?$AA?$AA@FNODOBFM@ 000151e0 tapdrvr.obj 122 | 0001:00004d70 ??_C@_1BI@FJLCDAFI@?$AAN?$AAd?$AAi?$AAs?$AAV?$AAe?$AAr?$AAs?$AAi?$AAo?$AAn?$AA?$AA@FNODOBFM@ 000151f0 tapdrvr.obj 123 | 0001:00004d90 ??_C@_1BK@KPLOIJDF@?$AAM?$AAi?$AAn?$AAi?$AAp?$AAo?$AAr?$AAt?$AAN?$AAa?$AAm?$AAe?$AA?$AA@FNODOBFM@ 00015210 tapdrvr.obj 124 | 0001:00004daa ??_C@_00CNPNBAHC@?$AA@FNODOBFM@ 0001522a ntstrsafe:ntstrsafe.obj 125 | 0002:00000000 __imp_@KfAcquireSpinLock@4 00015280 hal:HAL.dll 126 | 0002:00000004 __imp_@KfReleaseSpinLock@8 00015284 hal:HAL.dll 127 | 0002:00000008 __imp__KeGetCurrentIrql@0 00015288 hal:HAL.dll 128 | 0002:0000000c \177HAL_NULL_THUNK_DATA 0001528c hal:HAL.dll 129 | 0002:00000010 __imp__NdisMRegisterMiniport@12 00015290 ndis:NDIS.SYS 130 | 0002:00000014 __imp__NdisTerminateWrapper@8 00015294 ndis:NDIS.SYS 131 | 0002:00000018 __imp__NdisMRegisterUnloadHandler@8 00015298 ndis:NDIS.SYS 132 | 0002:0000001c __imp__NdisMSetAttributesEx@20 0001529c ndis:NDIS.SYS 133 | 0002:00000020 __imp__NdisMRegisterAdapterShutdownHandler@12 000152a0 ndis:NDIS.SYS 134 | 0002:00000024 __imp__NdisOpenConfiguration@12 000152a4 ndis:NDIS.SYS 135 | 0002:00000028 __imp__NdisReadConfiguration@20 000152a8 ndis:NDIS.SYS 136 | 0002:0000002c __imp__NdisCloseConfiguration@4 000152ac ndis:NDIS.SYS 137 | 0002:00000030 __imp__NdisMRegisterDevice@24 000152b0 ndis:NDIS.SYS 138 | 0002:00000034 __imp__NdisMIndicateStatus@16 000152b4 ndis:NDIS.SYS 139 | 0002:00000038 __imp__NdisMIndicateStatusComplete@4 000152b8 ndis:NDIS.SYS 140 | 0002:0000003c __imp__NdisMDeregisterDevice@4 000152bc ndis:NDIS.SYS 141 | 0002:00000040 __imp__NdisMDeregisterAdapterShutdownHandler@4 000152c0 ndis:NDIS.SYS 142 | 0002:00000044 __imp__NdisMSleep@4 000152c4 ndis:NDIS.SYS 143 | 0002:00000048 __imp__NdisFreeMemory@12 000152c8 ndis:NDIS.SYS 144 | 0002:0000004c __imp__NdisAllocateMemoryWithTag@12 000152cc ndis:NDIS.SYS 145 | 0002:00000050 __imp__NdisInitializeWrapper@16 000152d0 ndis:NDIS.SYS 146 | 0002:00000054 \177NDIS_NULL_THUNK_DATA 000152d4 ndis:NDIS.SYS 147 | 0002:00000058 __imp__RtlFreeAnsiString@4 000152d8 ntoskrnl:ntoskrnl.exe 148 | 0002:0000005c __imp__memcpy 000152dc ntoskrnl:ntoskrnl.exe 149 | 0002:00000060 __imp__KeRemoveQueueDpc@4 000152e0 ntoskrnl:ntoskrnl.exe 150 | 0002:00000064 __imp__KeBugCheckEx@20 000152e4 ntoskrnl:ntoskrnl.exe 151 | 0002:00000068 __imp__KeTickCount 000152e8 ntoskrnl:ntoskrnl.exe 152 | 0002:00000068 _KeTickCount 000152e8 ntoskrnl:ntoskrnl.exe 153 | 0002:0000006c __imp__RtlUnicodeStringToAnsiString@12 000152ec ntoskrnl:ntoskrnl.exe 154 | 0002:00000070 __imp__RtlAnsiStringToUnicodeString@12 000152f0 ntoskrnl:ntoskrnl.exe 155 | 0002:00000074 __imp__KeInitializeDpc@12 000152f4 ntoskrnl:ntoskrnl.exe 156 | 0002:00000078 __imp__MmMapLockedPagesSpecifyCache@24 000152f8 ntoskrnl:ntoskrnl.exe 157 | 0002:0000007c __imp__MmMapLockedPages@8 000152fc ntoskrnl:ntoskrnl.exe 158 | 0002:00000080 __imp__RtlCreateSecurityDescriptor@8 00015300 ntoskrnl:ntoskrnl.exe 159 | 0002:00000084 __imp__ZwOpenFile@24 00015304 ntoskrnl:ntoskrnl.exe 160 | 0002:00000088 __imp__ZwSetSecurityObject@12 00015308 ntoskrnl:ntoskrnl.exe 161 | 0002:0000008c __imp__ZwClose@4 0001530c ntoskrnl:ntoskrnl.exe 162 | 0002:00000090 __imp__KeInsertQueueDpc@12 00015310 ntoskrnl:ntoskrnl.exe 163 | 0002:00000094 __imp__IoReleaseCancelSpinLock@4 00015314 ntoskrnl:ntoskrnl.exe 164 | 0002:00000098 __imp_@IofCompleteRequest@8 00015318 ntoskrnl:ntoskrnl.exe 165 | 0002:0000009c __imp__memset 0001531c ntoskrnl:ntoskrnl.exe 166 | 0002:000000a0 __imp__RtlFreeUnicodeString@4 00015320 ntoskrnl:ntoskrnl.exe 167 | 0002:000000a4 __imp__RtlUnwind@16 00015324 ntoskrnl:ntoskrnl.exe 168 | 0002:000000a8 __imp__RtlUnicodeToMultiByteN@20 00015328 ntoskrnl:ntoskrnl.exe 169 | 0002:000000ac \177ntoskrnl_NULL_THUNK_DATA 0001532c ntoskrnl:ntoskrnl.exe 170 | 0002:000000d0 _g_SupportedOIDList 00015350 tapdrvr.obj 171 | 0002:00000158 ??_C@_1O@CEDCILHN@?$AA?$CI?$AAn?$AAu?$AAl?$AAl?$AA?$CJ?$AA?$AA@ 000153d8 ntstrsafe:output.obj 172 | 0002:00000168 ??_C@_06OJHGLDPL@?$CInull?$CJ?$AA@ 000153e8 ntstrsafe:output.obj 173 | 0002:00000170 ___lookuptable 000153f0 ntstrsafe:output.obj 174 | 0002:000001d0 __load_config_used 00015450 ntoskrnl:loadcfg.obj 175 | 0002:00000270 ___safe_se_handler_table 000154f0 176 | 0003:00000020 ___security_cookie 00015620 BufferOverflowK:gs_support.obj 177 | 0003:00000024 ___security_cookie_complement 00015624 BufferOverflowK:gs_support.obj 178 | 0003:00000028 ___nullstring 00015628 ntstrsafe:output.obj 179 | 0003:0000002c ___wnullstring 0001562c ntstrsafe:output.obj 180 | 0003:00000030 __NLG_Destination 00015630 ntstrsafe:_nlgsupp.obj 181 | 0003:00000040 __fltused 00015640 ntstrsafe:stubs.obj 182 | 0003:00000044 __ldused 00015644 ntstrsafe:stubs.obj 183 | 0003:00000050 ___mb_cur_max 00015650 ntstrsafe:nlsdata1.obj 184 | 0003:00000054 ___decimal_point 00015654 ntstrsafe:nlsdata1.obj 185 | 0003:00000058 ___decimal_point_length 00015658 ntstrsafe:nlsdata1.obj 186 | 0003:00000060 _g_InstanceHash 00015660 tapdrvr.obj 187 | 0003:00000064 ___fastflag 00015664 ntstrsafe:stubs.obj 188 | 0003:0000006c _g_NdisWrapperHandle 0001566c 189 | 0003:00000070 _g_LastErrorLineNumber 00015670 190 | 0003:00000074 _g_LastErrorFilename 00015674 191 | 0003:00000078 _errno 00015678 192 | 0004:00000010 _DriverEntry@8 00015690 f tapdrvr.obj 193 | 0004:00000126 ___security_init_cookie 000157a6 f BufferOverflowK:gs_support.obj 194 | 0004:0000015f _GsDriverEntry@8 000157df f BufferOverflowK:gs_support.obj 195 | 0004:00000170 __IMPORT_DESCRIPTOR_ntoskrnl 000157f0 ntoskrnl:ntoskrnl.exe 196 | 0004:00000184 __IMPORT_DESCRIPTOR_HAL 00015804 hal:HAL.dll 197 | 0004:00000198 __IMPORT_DESCRIPTOR_NDIS 00015818 ndis:NDIS.SYS 198 | 0004:000001ac __NULL_IMPORT_DESCRIPTOR 0001582c ntoskrnl:ntoskrnl.exe 199 | 200 | entry point at 0004:0000015f 201 | 202 | Static symbols 203 | 204 | 0001:00003f9c __unwind_handler4 0001441c f ntstrsafe:exsup4.obj 205 | 0001:0000407a _write_char 000144fa f ntstrsafe:output.obj 206 | 0001:000040b2 _write_multi_char 00014532 f ntstrsafe:output.obj 207 | 0001:000040dd _write_string 0001455d f ntstrsafe:output.obj 208 | -------------------------------------------------------------------------------- /tap_driver/NDIS5_x86/tap0901.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS5_x86/tap0901.sys -------------------------------------------------------------------------------- /tap_driver/NDIS5_x86/tapinstall.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a79b15259617b0de6aee8287af994e623bffd06bb58d1037a0aa5a318b0b217d 3 | size 77312 4 | -------------------------------------------------------------------------------- /tap_driver/NDIS6_arm/OemVista.inf: -------------------------------------------------------------------------------- 1 | ; **************************************************************************** 2 | ; * Copyright (C) 2002-2014 OpenVPN Technologies, Inc. * 3 | ; * This program is free software; you can redistribute it and/or modify * 4 | ; * it under the terms of the GNU General Public License version 2 * 5 | ; * as published by the Free Software Foundation. * 6 | ; **************************************************************************** 7 | 8 | ; SYNTAX CHECKER 9 | ; cd \WINDDK\3790\tools\chkinf 10 | ; chkinf c:\src\openvpn\tap-win32\i386\oemvista.inf 11 | ; OUTPUT -> file:///c:/WINDDK/3790/tools/chkinf/htm/c%23+src+openvpn+tap-win32+i386+__OemWin2k.htm 12 | 13 | ; INSTALL/REMOVE DRIVER 14 | ; tapinstall install OemVista.inf tapoas 15 | ; tapinstall update OemVista.inf tapoas 16 | ; tapinstall remove tapoas 17 | 18 | ;********************************************************* 19 | ; Note to Developers: 20 | ; 21 | ; If you are bundling the TAP-Windows driver with your app, 22 | ; you should try to rename it in such a way that it will 23 | ; not collide with other instances of TAP-Windows defined 24 | ; by other apps. Multiple versions of the TAP-Windows 25 | ; driver, each installed by different apps, can coexist 26 | ; on the same machine if you follow these guidelines. 27 | ; NOTE: these instructions assume you are editing the 28 | ; generated OemWin2k.inf file, not the source 29 | ; OemWin2k.inf.in file which is preprocessed by winconfig 30 | ; and uses macro definitions from settings.in. 31 | ; 32 | ; (1) Rename all tapXXXX instances in this file to 33 | ; something different (use at least 5 characters 34 | ; for this name!) 35 | ; (2) Change the "!define TAP" definition in openvpn.nsi 36 | ; to match what you changed tapXXXX to. 37 | ; (3) Change TARGETNAME in SOURCES to match what you 38 | ; changed tapXXXX to. 39 | ; (4) Change TAP_COMPONENT_ID in common.h to match what 40 | ; you changed tapXXXX to. 41 | ; (5) Change SZDEPENDENCIES in service.h to match what 42 | ; you changed tapXXXX to. 43 | ; (6) Change DeviceDescription and Provider strings. 44 | ; (7) Change PRODUCT_TAP_WIN_DEVICE_DESCRIPTION in constants.h to what you 45 | ; set DeviceDescription to. 46 | ; 47 | ;********************************************************* 48 | 49 | [Version] 50 | Signature = "$Windows NT$" 51 | CatalogFile = tap0901.cat 52 | ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318} 53 | Provider = %Provider% 54 | Class = Net 55 | 56 | ; This version number should match the version 57 | ; number given in ..\version.m4. 58 | DriverVer = 04/23/2019,9.23.3.601 59 | 60 | [Strings] 61 | DeviceDescription = "TAP-Windows Adapter V9" 62 | Provider = "TAP-Windows Provider V9" 63 | 64 | ;---------------------------------------------------------------- 65 | ; Manufacturer + Product Section (Done) 66 | ;---------------------------------------------------------------- 67 | [Manufacturer] 68 | %Provider% = tap0901, NTARM64 69 | 70 | [tap0901.NTARM64] 71 | %DeviceDescription% = tap0901.ndi, root\tap0901 ; Root enumerated 72 | %DeviceDescription% = tap0901.ndi, tap0901 ; Legacy 73 | 74 | ;--------------------------------------------------------------- 75 | ; Driver Section (Done) 76 | ;--------------------------------------------------------------- 77 | 78 | ;----------------- Characteristics ------------ 79 | ; NCF_PHYSICAL = 0x04 80 | ; NCF_VIRTUAL = 0x01 81 | ; NCF_SOFTWARE_ENUMERATED = 0x02 82 | ; NCF_HIDDEN = 0x08 83 | ; NCF_NO_SERVICE = 0x10 84 | ; NCF_HAS_UI = 0x80 85 | ;----------------- Characteristics ------------ 86 | 87 | [tap0901.ndi] 88 | CopyFiles = tap0901.driver, tap0901.files 89 | AddReg = tap0901.reg 90 | AddReg = tap0901.params.reg 91 | Characteristics = 0x81 92 | *IfType = 0x6 ; IF_TYPE_ETHERNET_CSMACD 93 | *MediaType = 0x0 ; NdisMedium802_3 94 | *PhysicalMediaType = 14 ; NdisPhysicalMedium802_3 95 | 96 | [tap0901.ndi.Services] 97 | AddService = tap0901, 2, tap0901.service 98 | 99 | [tap0901.reg] 100 | HKR, Ndi, Service, 0, "tap0901" 101 | HKR, Ndi\Interfaces, UpperRange, 0, "ndis5" 102 | HKR, Ndi\Interfaces, LowerRange, 0, "ethernet" 103 | HKR, , Manufacturer, 0, "%Provider%" 104 | HKR, , ProductName, 0, "%DeviceDescription%" 105 | 106 | [tap0901.params.reg] 107 | HKR, Ndi\params\MTU, ParamDesc, 0, "MTU" 108 | HKR, Ndi\params\MTU, Type, 0, "int" 109 | HKR, Ndi\params\MTU, Default, 0, "1500" 110 | HKR, Ndi\params\MTU, Optional, 0, "0" 111 | HKR, Ndi\params\MTU, Min, 0, "100" 112 | HKR, Ndi\params\MTU, Max, 0, "1500" 113 | HKR, Ndi\params\MTU, Step, 0, "1" 114 | HKR, Ndi\params\MediaStatus, ParamDesc, 0, "Media Status" 115 | HKR, Ndi\params\MediaStatus, Type, 0, "enum" 116 | HKR, Ndi\params\MediaStatus, Default, 0, "0" 117 | HKR, Ndi\params\MediaStatus, Optional, 0, "0" 118 | HKR, Ndi\params\MediaStatus\enum, "0", 0, "Application Controlled" 119 | HKR, Ndi\params\MediaStatus\enum, "1", 0, "Always Connected" 120 | HKR, Ndi\params\MAC, ParamDesc, 0, "MAC Address" 121 | HKR, Ndi\params\MAC, Type, 0, "edit" 122 | HKR, Ndi\params\MAC, Optional, 0, "1" 123 | HKR, Ndi\params\AllowNonAdmin, ParamDesc, 0, "Non-Admin Access" 124 | HKR, Ndi\params\AllowNonAdmin, Type, 0, "enum" 125 | HKR, Ndi\params\AllowNonAdmin, Default, 0, "1" 126 | HKR, Ndi\params\AllowNonAdmin, Optional, 0, "0" 127 | HKR, Ndi\params\AllowNonAdmin\enum, "0", 0, "Not Allowed" 128 | HKR, Ndi\params\AllowNonAdmin\enum, "1", 0, "Allowed" 129 | 130 | ;---------------------------------------------------------------- 131 | ; Service Section 132 | ;---------------------------------------------------------------- 133 | 134 | ;---------- Service Type ------------- 135 | ; SERVICE_KERNEL_DRIVER = 0x01 136 | ; SERVICE_WIN32_OWN_PROCESS = 0x10 137 | ;---------- Service Type ------------- 138 | 139 | ;---------- Start Mode --------------- 140 | ; SERVICE_BOOT_START = 0x0 141 | ; SERVICE_SYSTEM_START = 0x1 142 | ; SERVICE_AUTO_START = 0x2 143 | ; SERVICE_DEMAND_START = 0x3 144 | ; SERVICE_DISABLED = 0x4 145 | ;---------- Start Mode --------------- 146 | 147 | [tap0901.service] 148 | DisplayName = %DeviceDescription% 149 | ServiceType = 1 150 | StartType = 3 151 | ErrorControl = 1 152 | LoadOrderGroup = NDIS 153 | ServiceBinary = %12%\tap0901.sys 154 | 155 | ;----------------------------------------------------------------- 156 | ; File Installation 157 | ;----------------------------------------------------------------- 158 | 159 | ;----------------- Copy Flags ------------ 160 | ; COPYFLG_NOSKIP = 0x02 161 | ; COPYFLG_NOVERSIONCHECK = 0x04 162 | ;----------------- Copy Flags ------------ 163 | 164 | ; SourceDisksNames 165 | ; diskid = description[, [tagfile] [, , subdir]] 166 | ; 1 = "Intel Driver Disk 1",e100bex.sys,, 167 | 168 | [SourceDisksNames] 169 | 1 = %DeviceDescription%, tap0901.sys 170 | 171 | ; SourceDisksFiles 172 | ; filename_on_source = diskID[, [subdir][, size]] 173 | ; e100bex.sys = 1,, ; on distribution disk 1 174 | 175 | [SourceDisksFiles] 176 | tap0901.sys = 1 177 | 178 | [DestinationDirs] 179 | tap0901.files = 11 180 | tap0901.driver = 12 181 | 182 | [tap0901.files] 183 | ; TapPanel.cpl,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 184 | ; cipsrvr.exe,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 185 | 186 | [tap0901.driver] 187 | tap0901.sys,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 188 | 189 | ;--------------------------------------------------------------- 190 | ; End 191 | ;--------------------------------------------------------------- 192 | -------------------------------------------------------------------------------- /tap_driver/NDIS6_arm/tap0901.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS6_arm/tap0901.cat -------------------------------------------------------------------------------- /tap_driver/NDIS6_arm/tap0901.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS6_arm/tap0901.sys -------------------------------------------------------------------------------- /tap_driver/NDIS6_x64/OemVista.inf: -------------------------------------------------------------------------------- 1 | ; **************************************************************************** 2 | ; * Copyright (C) 2002-2014 OpenVPN Technologies, Inc. * 3 | ; * This program is free software; you can redistribute it and/or modify * 4 | ; * it under the terms of the GNU General Public License version 2 * 5 | ; * as published by the Free Software Foundation. * 6 | ; **************************************************************************** 7 | 8 | ; SYNTAX CHECKER 9 | ; cd \WINDDK\3790\tools\chkinf 10 | ; chkinf c:\src\openvpn\tap-win32\i386\oemvista.inf 11 | ; OUTPUT -> file:///c:/WINDDK/3790/tools/chkinf/htm/c%23+src+openvpn+tap-win32+i386+__OemWin2k.htm 12 | 13 | ; INSTALL/REMOVE DRIVER 14 | ; tapinstall install OemVista.inf tapoas 15 | ; tapinstall update OemVista.inf tapoas 16 | ; tapinstall remove tapoas 17 | 18 | ;********************************************************* 19 | ; Note to Developers: 20 | ; 21 | ; If you are bundling the TAP-Windows driver with your app, 22 | ; you should try to rename it in such a way that it will 23 | ; not collide with other instances of TAP-Windows defined 24 | ; by other apps. Multiple versions of the TAP-Windows 25 | ; driver, each installed by different apps, can coexist 26 | ; on the same machine if you follow these guidelines. 27 | ; NOTE: these instructions assume you are editing the 28 | ; generated OemWin2k.inf file, not the source 29 | ; OemWin2k.inf.in file which is preprocessed by winconfig 30 | ; and uses macro definitions from settings.in. 31 | ; 32 | ; (1) Rename all tapXXXX instances in this file to 33 | ; something different (use at least 5 characters 34 | ; for this name!) 35 | ; (2) Change the "!define TAP" definition in openvpn.nsi 36 | ; to match what you changed tapXXXX to. 37 | ; (3) Change TARGETNAME in SOURCES to match what you 38 | ; changed tapXXXX to. 39 | ; (4) Change TAP_COMPONENT_ID in common.h to match what 40 | ; you changed tapXXXX to. 41 | ; (5) Change SZDEPENDENCIES in service.h to match what 42 | ; you changed tapXXXX to. 43 | ; (6) Change DeviceDescription and Provider strings. 44 | ; (7) Change PRODUCT_TAP_WIN_DEVICE_DESCRIPTION in constants.h to what you 45 | ; set DeviceDescription to. 46 | ; 47 | ;********************************************************* 48 | 49 | [Version] 50 | Signature = "$Windows NT$" 51 | CatalogFile = tap0901.cat 52 | ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318} 53 | Provider = %Provider% 54 | Class = Net 55 | 56 | ; This version number should match the version 57 | ; number given in SOURCES. 58 | DriverVer=04/21/2016,9.00.00.21 59 | 60 | [Strings] 61 | DeviceDescription = "TAP-Windows Adapter V9" 62 | Provider = "TAP-Windows Provider V9" 63 | 64 | ;---------------------------------------------------------------- 65 | ; Manufacturer + Product Section (Done) 66 | ;---------------------------------------------------------------- 67 | [Manufacturer] 68 | %Provider% = tap0901, NTamd64 69 | 70 | [tap0901.NTamd64] 71 | %DeviceDescription% = tap0901.ndi, root\tap0901 ; Root enumerated 72 | %DeviceDescription% = tap0901.ndi, tap0901 ; Legacy 73 | 74 | ;--------------------------------------------------------------- 75 | ; Driver Section (Done) 76 | ;--------------------------------------------------------------- 77 | 78 | ;----------------- Characteristics ------------ 79 | ; NCF_PHYSICAL = 0x04 80 | ; NCF_VIRTUAL = 0x01 81 | ; NCF_SOFTWARE_ENUMERATED = 0x02 82 | ; NCF_HIDDEN = 0x08 83 | ; NCF_NO_SERVICE = 0x10 84 | ; NCF_HAS_UI = 0x80 85 | ;----------------- Characteristics ------------ 86 | 87 | [tap0901.ndi] 88 | CopyFiles = tap0901.driver, tap0901.files 89 | AddReg = tap0901.reg 90 | AddReg = tap0901.params.reg 91 | Characteristics = 92 | *IfType = 0x6 ; IF_TYPE_ETHERNET_CSMACD 93 | *MediaType = 0x0 ; NdisMedium802_3 94 | *PhysicalMediaType = 14 ; NdisPhysicalMedium802_3 95 | 96 | [tap0901.ndi.Services] 97 | AddService = tap0901, 2, tap0901.service 98 | 99 | [tap0901.reg] 100 | HKR, Ndi, Service, 0, "tap0901" 101 | HKR, Ndi\Interfaces, UpperRange, 0, "ndis5" 102 | HKR, Ndi\Interfaces, LowerRange, 0, "ethernet" 103 | HKR, , Manufacturer, 0, "%Provider%" 104 | HKR, , ProductName, 0, "%DeviceDescription%" 105 | 106 | [tap0901.params.reg] 107 | HKR, Ndi\params\MTU, ParamDesc, 0, "MTU" 108 | HKR, Ndi\params\MTU, Type, 0, "int" 109 | HKR, Ndi\params\MTU, Default, 0, "1500" 110 | HKR, Ndi\params\MTU, Optional, 0, "0" 111 | HKR, Ndi\params\MTU, Min, 0, "100" 112 | HKR, Ndi\params\MTU, Max, 0, "1500" 113 | HKR, Ndi\params\MTU, Step, 0, "1" 114 | HKR, Ndi\params\MediaStatus, ParamDesc, 0, "Media Status" 115 | HKR, Ndi\params\MediaStatus, Type, 0, "enum" 116 | HKR, Ndi\params\MediaStatus, Default, 0, "0" 117 | HKR, Ndi\params\MediaStatus, Optional, 0, "0" 118 | HKR, Ndi\params\MediaStatus\enum, "0", 0, "Application Controlled" 119 | HKR, Ndi\params\MediaStatus\enum, "1", 0, "Always Connected" 120 | HKR, Ndi\params\MAC, ParamDesc, 0, "MAC Address" 121 | HKR, Ndi\params\MAC, Type, 0, "edit" 122 | HKR, Ndi\params\MAC, Optional, 0, "1" 123 | HKR, Ndi\params\AllowNonAdmin, ParamDesc, 0, "Non-Admin Access" 124 | HKR, Ndi\params\AllowNonAdmin, Type, 0, "enum" 125 | HKR, Ndi\params\AllowNonAdmin, Default, 0, "1" 126 | HKR, Ndi\params\AllowNonAdmin, Optional, 0, "0" 127 | HKR, Ndi\params\AllowNonAdmin\enum, "0", 0, "Not Allowed" 128 | HKR, Ndi\params\AllowNonAdmin\enum, "1", 0, "Allowed" 129 | 130 | ;---------------------------------------------------------------- 131 | ; Service Section 132 | ;---------------------------------------------------------------- 133 | 134 | ;---------- Service Type ------------- 135 | ; SERVICE_KERNEL_DRIVER = 0x01 136 | ; SERVICE_WIN32_OWN_PROCESS = 0x10 137 | ;---------- Service Type ------------- 138 | 139 | ;---------- Start Mode --------------- 140 | ; SERVICE_BOOT_START = 0x0 141 | ; SERVICE_SYSTEM_START = 0x1 142 | ; SERVICE_AUTO_START = 0x2 143 | ; SERVICE_DEMAND_START = 0x3 144 | ; SERVICE_DISABLED = 0x4 145 | ;---------- Start Mode --------------- 146 | 147 | [tap0901.service] 148 | DisplayName = %DeviceDescription% 149 | ServiceType = 1 150 | StartType = 3 151 | ErrorControl = 1 152 | LoadOrderGroup = NDIS 153 | ServiceBinary = %12%\tap0901.sys 154 | 155 | ;----------------------------------------------------------------- 156 | ; File Installation 157 | ;----------------------------------------------------------------- 158 | 159 | ;----------------- Copy Flags ------------ 160 | ; COPYFLG_NOSKIP = 0x02 161 | ; COPYFLG_NOVERSIONCHECK = 0x04 162 | ;----------------- Copy Flags ------------ 163 | 164 | ; SourceDisksNames 165 | ; diskid = description[, [tagfile] [, , subdir]] 166 | ; 1 = "Intel Driver Disk 1",e100bex.sys,, 167 | 168 | [SourceDisksNames] 169 | 1 = %DeviceDescription%, tap0901.sys 170 | 171 | ; SourceDisksFiles 172 | ; filename_on_source = diskID[, [subdir][, size]] 173 | ; e100bex.sys = 1,, ; on distribution disk 1 174 | 175 | [SourceDisksFiles] 176 | tap0901.sys = 1 177 | 178 | [DestinationDirs] 179 | tap0901.files = 11 180 | tap0901.driver = 12 181 | 182 | [tap0901.files] 183 | ; TapPanel.cpl,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 184 | ; cipsrvr.exe,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 185 | 186 | [tap0901.driver] 187 | tap0901.sys,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 188 | 189 | ;--------------------------------------------------------------- 190 | ; End 191 | ;--------------------------------------------------------------- 192 | -------------------------------------------------------------------------------- /tap_driver/NDIS6_x64/tap0901.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS6_x64/tap0901.cat -------------------------------------------------------------------------------- /tap_driver/NDIS6_x64/tap0901.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS6_x64/tap0901.sys -------------------------------------------------------------------------------- /tap_driver/NDIS6_x64/tapinstall.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c9963a3f8abf6fedc8f983a9655a387d67c752bd59b0d16fd6fc2396b4b4ca67 3 | size 92304 4 | -------------------------------------------------------------------------------- /tap_driver/NDIS6_x86/OemVista.inf: -------------------------------------------------------------------------------- 1 | ; **************************************************************************** 2 | ; * Copyright (C) 2002-2014 OpenVPN Technologies, Inc. * 3 | ; * This program is free software; you can redistribute it and/or modify * 4 | ; * it under the terms of the GNU General Public License version 2 * 5 | ; * as published by the Free Software Foundation. * 6 | ; **************************************************************************** 7 | 8 | ; SYNTAX CHECKER 9 | ; cd \WINDDK\3790\tools\chkinf 10 | ; chkinf c:\src\openvpn\tap-win32\i386\oemvista.inf 11 | ; OUTPUT -> file:///c:/WINDDK/3790/tools/chkinf/htm/c%23+src+openvpn+tap-win32+i386+__OemWin2k.htm 12 | 13 | ; INSTALL/REMOVE DRIVER 14 | ; tapinstall install OemVista.inf tapoas 15 | ; tapinstall update OemVista.inf tapoas 16 | ; tapinstall remove tapoas 17 | 18 | ;********************************************************* 19 | ; Note to Developers: 20 | ; 21 | ; If you are bundling the TAP-Windows driver with your app, 22 | ; you should try to rename it in such a way that it will 23 | ; not collide with other instances of TAP-Windows defined 24 | ; by other apps. Multiple versions of the TAP-Windows 25 | ; driver, each installed by different apps, can coexist 26 | ; on the same machine if you follow these guidelines. 27 | ; NOTE: these instructions assume you are editing the 28 | ; generated OemWin2k.inf file, not the source 29 | ; OemWin2k.inf.in file which is preprocessed by winconfig 30 | ; and uses macro definitions from settings.in. 31 | ; 32 | ; (1) Rename all tapXXXX instances in this file to 33 | ; something different (use at least 5 characters 34 | ; for this name!) 35 | ; (2) Change the "!define TAP" definition in openvpn.nsi 36 | ; to match what you changed tapXXXX to. 37 | ; (3) Change TARGETNAME in SOURCES to match what you 38 | ; changed tapXXXX to. 39 | ; (4) Change TAP_COMPONENT_ID in common.h to match what 40 | ; you changed tapXXXX to. 41 | ; (5) Change SZDEPENDENCIES in service.h to match what 42 | ; you changed tapXXXX to. 43 | ; (6) Change DeviceDescription and Provider strings. 44 | ; (7) Change PRODUCT_TAP_WIN_DEVICE_DESCRIPTION in constants.h to what you 45 | ; set DeviceDescription to. 46 | ; 47 | ;********************************************************* 48 | 49 | [Version] 50 | Signature = "$Windows NT$" 51 | CatalogFile = tap0901.cat 52 | ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318} 53 | Provider = %Provider% 54 | Class = Net 55 | 56 | ; This version number should match the version 57 | ; number given in SOURCES. 58 | DriverVer=04/21/2016,9.00.00.21 59 | 60 | [Strings] 61 | DeviceDescription = "TAP-Windows Adapter V9" 62 | Provider = "TAP-Windows Provider V9" 63 | 64 | ;---------------------------------------------------------------- 65 | ; Manufacturer + Product Section (Done) 66 | ;---------------------------------------------------------------- 67 | [Manufacturer] 68 | %Provider% = tap0901 69 | 70 | [tap0901] 71 | %DeviceDescription% = tap0901.ndi, root\tap0901 ; Root enumerated 72 | %DeviceDescription% = tap0901.ndi, tap0901 ; Legacy 73 | 74 | ;--------------------------------------------------------------- 75 | ; Driver Section (Done) 76 | ;--------------------------------------------------------------- 77 | 78 | ;----------------- Characteristics ------------ 79 | ; NCF_PHYSICAL = 0x04 80 | ; NCF_VIRTUAL = 0x01 81 | ; NCF_SOFTWARE_ENUMERATED = 0x02 82 | ; NCF_HIDDEN = 0x08 83 | ; NCF_NO_SERVICE = 0x10 84 | ; NCF_HAS_UI = 0x80 85 | ;----------------- Characteristics ------------ 86 | 87 | [tap0901.ndi] 88 | CopyFiles = tap0901.driver, tap0901.files 89 | AddReg = tap0901.reg 90 | AddReg = tap0901.params.reg 91 | Characteristics = 92 | *IfType = 0x6 ; IF_TYPE_ETHERNET_CSMACD 93 | *MediaType = 0x0 ; NdisMedium802_3 94 | *PhysicalMediaType = 14 ; NdisPhysicalMedium802_3 95 | 96 | [tap0901.ndi.Services] 97 | AddService = tap0901, 2, tap0901.service 98 | 99 | [tap0901.reg] 100 | HKR, Ndi, Service, 0, "tap0901" 101 | HKR, Ndi\Interfaces, UpperRange, 0, "ndis5" 102 | HKR, Ndi\Interfaces, LowerRange, 0, "ethernet" 103 | HKR, , Manufacturer, 0, "%Provider%" 104 | HKR, , ProductName, 0, "%DeviceDescription%" 105 | 106 | [tap0901.params.reg] 107 | HKR, Ndi\params\MTU, ParamDesc, 0, "MTU" 108 | HKR, Ndi\params\MTU, Type, 0, "int" 109 | HKR, Ndi\params\MTU, Default, 0, "1500" 110 | HKR, Ndi\params\MTU, Optional, 0, "0" 111 | HKR, Ndi\params\MTU, Min, 0, "100" 112 | HKR, Ndi\params\MTU, Max, 0, "1500" 113 | HKR, Ndi\params\MTU, Step, 0, "1" 114 | HKR, Ndi\params\MediaStatus, ParamDesc, 0, "Media Status" 115 | HKR, Ndi\params\MediaStatus, Type, 0, "enum" 116 | HKR, Ndi\params\MediaStatus, Default, 0, "0" 117 | HKR, Ndi\params\MediaStatus, Optional, 0, "0" 118 | HKR, Ndi\params\MediaStatus\enum, "0", 0, "Application Controlled" 119 | HKR, Ndi\params\MediaStatus\enum, "1", 0, "Always Connected" 120 | HKR, Ndi\params\MAC, ParamDesc, 0, "MAC Address" 121 | HKR, Ndi\params\MAC, Type, 0, "edit" 122 | HKR, Ndi\params\MAC, Optional, 0, "1" 123 | HKR, Ndi\params\AllowNonAdmin, ParamDesc, 0, "Non-Admin Access" 124 | HKR, Ndi\params\AllowNonAdmin, Type, 0, "enum" 125 | HKR, Ndi\params\AllowNonAdmin, Default, 0, "1" 126 | HKR, Ndi\params\AllowNonAdmin, Optional, 0, "0" 127 | HKR, Ndi\params\AllowNonAdmin\enum, "0", 0, "Not Allowed" 128 | HKR, Ndi\params\AllowNonAdmin\enum, "1", 0, "Allowed" 129 | 130 | ;---------------------------------------------------------------- 131 | ; Service Section 132 | ;---------------------------------------------------------------- 133 | 134 | ;---------- Service Type ------------- 135 | ; SERVICE_KERNEL_DRIVER = 0x01 136 | ; SERVICE_WIN32_OWN_PROCESS = 0x10 137 | ;---------- Service Type ------------- 138 | 139 | ;---------- Start Mode --------------- 140 | ; SERVICE_BOOT_START = 0x0 141 | ; SERVICE_SYSTEM_START = 0x1 142 | ; SERVICE_AUTO_START = 0x2 143 | ; SERVICE_DEMAND_START = 0x3 144 | ; SERVICE_DISABLED = 0x4 145 | ;---------- Start Mode --------------- 146 | 147 | [tap0901.service] 148 | DisplayName = %DeviceDescription% 149 | ServiceType = 1 150 | StartType = 3 151 | ErrorControl = 1 152 | LoadOrderGroup = NDIS 153 | ServiceBinary = %12%\tap0901.sys 154 | 155 | ;----------------------------------------------------------------- 156 | ; File Installation 157 | ;----------------------------------------------------------------- 158 | 159 | ;----------------- Copy Flags ------------ 160 | ; COPYFLG_NOSKIP = 0x02 161 | ; COPYFLG_NOVERSIONCHECK = 0x04 162 | ;----------------- Copy Flags ------------ 163 | 164 | ; SourceDisksNames 165 | ; diskid = description[, [tagfile] [, , subdir]] 166 | ; 1 = "Intel Driver Disk 1",e100bex.sys,, 167 | 168 | [SourceDisksNames] 169 | 1 = %DeviceDescription%, tap0901.sys 170 | 171 | ; SourceDisksFiles 172 | ; filename_on_source = diskID[, [subdir][, size]] 173 | ; e100bex.sys = 1,, ; on distribution disk 1 174 | 175 | [SourceDisksFiles] 176 | tap0901.sys = 1 177 | 178 | [DestinationDirs] 179 | tap0901.files = 11 180 | tap0901.driver = 12 181 | 182 | [tap0901.files] 183 | ; TapPanel.cpl,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 184 | ; cipsrvr.exe,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 185 | 186 | [tap0901.driver] 187 | tap0901.sys,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK 188 | 189 | ;--------------------------------------------------------------- 190 | ; End 191 | ;--------------------------------------------------------------- 192 | -------------------------------------------------------------------------------- /tap_driver/NDIS6_x86/tap0901.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS6_x86/tap0901.cat -------------------------------------------------------------------------------- /tap_driver/NDIS6_x86/tap0901.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happynclient/happynwindows/6dd3e8c173a3999fdc96a8650ac57057ac460695/tap_driver/NDIS6_x86/tap0901.sys -------------------------------------------------------------------------------- /tap_driver/NDIS6_x86/tapinstall.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5c6aae8c345e5eda7185cabafcf9270ef3d73f198290842654d8916f8321b150 3 | size 87696 4 | --------------------------------------------------------------------------------