L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

SoftEther VPN に関するご質問はこのフォーラムにお気軽にご投稿ください。
Post Reply
hiura
Posts: 141
Joined: Wed Mar 10, 2021 1:56 am

L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by hiura » Mon Mar 20, 2023 11:54 am

L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。
下記エラーが出ます。

VPN SERVERのコンソールログ抜粋


CreateFileA(\\.\SELOW_BASIC_DEVICE) Failed.
MsStartService(SeLow) Failed.
Fail Copying Files.

C:\Windows\system32\drivers\pxwfp.sys copy failed. 3

C:\Windows\system32\drivers\pxwfp.sys failed. Abort.

Code: Select all

1.テスト
1.1構成
INTERNET---ONU-----BL900HW-----WX3000HP(ルータ、DHCPサーバ)-----NIC3=====PC2
                            |                                    
                            |
                            ---NIC1=====PC1

 ①BL900HW:
    デュアルスタック
 ②WX3000HP:
    デュアルスタック 
1.2 PC1:
①OS:WIN10 PRO 21H2

②VPNTEST.EXEをVPN SERVERとして実行
③SoftEther VPN Server Developer Edition Version 5.02 Build 5180 (Japanese)
④DDNSを有効に設定
⑤NIC1をローカルブリッジに設定

1.3 PC2:
①OS:WIN10 HOME 21H2

②VPN CLIENT:BUILT IN L2TP/IPSEC
③サーバ名またはアドレスにSOFTETHER VPN SERVERのIPV6のDDNS名(*.v6.*)を設定

2.ソースコード
FileCopy()時、指定したパスにファイルがないのでエラーになる。バグでは!。
2.1 PROTO_WIN7.C

Code: Select all

bool IPsecWin7InitDriverInner()
{
	char sys_filename[MAX_PATH];
	bool install_driver = true;
	HANDLE hEngine;
	UINT ret;
	FWPM_SESSION0 session;
	UINT id;
	FWPM_CALLOUT0 callout;

	Format(sys_filename, sizeof(sys_filename), IPSEC_WIN7_DST_SYS, MsGetSystem32Dir());

	if (IsFileExists(sys_filename) && MsIsServiceInstalled(IPSEC_WIN7_DRIVER_NAME))
	{
		if (GetCurrentIPsecWin7DriverBuild() >= CEDAR_VERSION_BUILD)
		{
			// Not to install since the latest version has been already installed
			install_driver = false;
		}
	}

	if (install_driver)
	{
		char src_filename[MAX_PATH];

		if (MsIsWindows10() == false)
		{
			Format(src_filename, sizeof(src_filename),
				"|DriverPackages\\Wfp\\%s\\pxwfp_%s.sys",	<---①このパスにファイルがない
				(MsIsX64() ? "x64" : "x86"), (MsIsX64() ? "x64" : "x86"));
		}
		else
		{
			Format(src_filename, sizeof(src_filename),
				"|DriverPackages\\Wfp_Win10\\%s\\pxwfp_%s.sys",<---②このパスにファイルがない
				(MsIsX64() ? "x64" : "x86"), (MsIsX64() ? "x64" : "x86"));
		}

		// Copy the driver
		if (FileCopy(src_filename, sys_filename) == false)	<----③コピー元にファイルがないのでエラー発生
		{
			Debug("_____ IPsecWin7InitDriverInner_____src_filename=%s\n", src_filename);
			Debug("%s copy failed. %u\n", sys_filename, GetLastError());
			if (IsFileExists(sys_filename) == false)
			{
				Debug("%s failed. Abort.\n", sys_filename);
				return false;
			}
		}
		else
		{
			Debug("%s copied.\n", sys_filename);
		}

		// Set the build number
		SetCurrentIPsecWin7DriverBuild();
	}

	// Get whether the device drivers is already installed
	if (MsIsServiceInstalled(IPSEC_WIN7_DRIVER_NAME) == false)
	{
		wchar_t sys_filename_w[MAX_PATH];

		StrToUni(sys_filename_w, sizeof(sys_filename_w), sys_filename);

		// Run a new installation
		if (MsInstallDeviceDriverW(IPSEC_WIN7_DRIVER_NAME, IPSEC_WIN7_DRIVER_TITLE,
			sys_filename_w, NULL) == false)
		{
			// Installation failed
			Debug("MsInstallDeviceDriverW failed.\n");
			return false;
		}
	}

	// Start if the device driver is stopped
	if (MsIsServiceRunning(IPSEC_WIN7_DRIVER_NAME) == false)
	{
		if (MsStartService(IPSEC_WIN7_DRIVER_NAME) == false)
		{
			// Start failure
			Debug("MsStartService failed.\n");
			return false;
		}

		Debug("%s service started.\n", IPSEC_WIN7_DRIVER_NAME);
	}
	else
	{
		Debug("%s service was already started.\n", IPSEC_WIN7_DRIVER_NAME);
	}

	// Open the WFP
	Zero(&session, sizeof(session));

	ret = api->FwpmEngineOpen0(NULL, RPC_C_AUTHN_DEFAULT, NULL, &session, &hEngine);
	if (ret)
	{
		Debug("FwpmEngineOpen0 failed.\n");
		return false;
	}

	// Create the Callout Driver (IPv4)
	Zero(&callout, sizeof(callout));
	callout.calloutKey = GUID_WFP_CALLOUT_DRIVER_V4;
	callout.applicableLayer = FWPM_LAYER_INBOUND_IPPACKET_V4;
	callout.displayData.name = IPSEC_WIN7_DRIVER_TITLE_V4;
	ret = api->FwpmCalloutAdd0(hEngine, &callout, NULL, &id);
	if (ret)
	{
		Debug("FwpmCalloutAdd0 for IPv4 Failed: 0x%X\n", ret);
	}
	else
	{
		Debug("FwpmCalloutAdd0 for IPv4 Ok.\n");
	}

	// Create the Callout Driver (IPv6)
	Zero(&callout, sizeof(callout));
	callout.calloutKey = GUID_WFP_CALLOUT_DRIVER_V6;
	callout.applicableLayer = FWPM_LAYER_INBOUND_IPPACKET_V6;
	callout.displayData.name = IPSEC_WIN7_DRIVER_TITLE_V6;
	ret = api->FwpmCalloutAdd0(hEngine, &callout, NULL, &id);
	if (ret)
	{
		Debug("FwpmCalloutAdd0 for IPv6 Failed: 0x%X\n", ret);
	}
	else
	{
		Debug("FwpmCalloutAdd0 for IPv6 Ok.\n");
	}

	api->FwpmEngineClose0(hEngine);

	return true;
}
2.2 SELOWUSER.C

Code: Select all

bool SuInstallDriverInner(bool force)
{
	wchar_t sys_fullpath[MAX_PATH];
	UINT current_sl_ver = 0;
	bool ret = false;
	wchar_t src_cat[MAX_PATH];
	wchar_t src_inf[MAX_PATH];
	wchar_t src_sys[MAX_PATH];
	wchar_t dst_cat[MAX_PATH];
	wchar_t dst_inf[MAX_PATH];
	wchar_t dst_sys[MAX_PATH];
	wchar_t tmp_dir[MAX_PATH];
	char *cpu_type = MsIsX64() ? "x64" : "x86";

	if (SuIsSupportedOs(true) == false)
	{
		// Unsupported OS
		return false;
	}

	CombinePathW(tmp_dir, sizeof(tmp_dir), MsGetWindowsDirW(), L"Temp");
	MakeDirExW(tmp_dir);

	UniStrCat(tmp_dir, sizeof(tmp_dir), L"\\selowtmp");
	MakeDirExW(tmp_dir);

	// Confirm whether the driver is currently installed
	CombinePathW(sys_fullpath, sizeof(sys_fullpath), MsGetSystem32DirW(), L"drivers\\SeLow_%S.sys");
	UniFormat(sys_fullpath, sizeof(sys_fullpath), sys_fullpath, cpu_type);

	if (IsFileExistsW(sys_fullpath))
	{
		char *path;

		// Read the current version from the registry
		current_sl_ver = MsRegReadIntEx2(REG_LOCAL_MACHINE, SL_REG_KEY_NAME,
			(MsIsWindows10() ? SL_REG_VER_VALUE_WIN10 : SL_REG_VER_VALUE),
			false, true);

		path = MsRegReadStrEx2(REG_LOCAL_MACHINE, SL_REG_KEY_NAME, "ImagePath", false, true);

		if (IsEmptyStr(path) || IsFileExists(path) == false || MsIsServiceInstalled(SL_PROTOCOL_NAME) == false)
		{
			current_sl_ver = 0;
		}

		Free(path);
	}

	if (force == false && current_sl_ver >= SL_VER)
	{
		// Newer version has already been installed
		Debug("Newer SeLow is Installed. %u >= %u\n", current_sl_ver, SL_VER);
		return true;
	}

	// Copy necessary files to a temporary directory
	UniFormat(src_sys, sizeof(src_sys), L"|DriverPackages\\%S\\%S\\SeLow_%S.sys",	<---④このパスにファイルがない
		(MsIsWindows10() ? "SeLow_Win10" : "SeLow_Win8"),
		cpu_type, cpu_type);
	if (MsIsWindows8() == false)
	{
		// Windows Vista and Windows 7 uses SHA-1 catalog files
		UniFormat(src_cat, sizeof(src_cat), L"|DriverPackages\\SeLow_Win8\\%S\\inf.cat", cpu_type);<---⑤このパスにファイルがない
	}
	else
	{
		// Windows 8 or above uses SHA-256 catalog files
		UniFormat(src_cat, sizeof(src_cat), L"|DriverPackages\\SeLow_Win8\\%S\\inf2.cat", cpu_type);<---⑥このパスにファイルがない

		if (MsIsWindows10())
		{
			// Windows 10 uses WHQL catalog files
			UniFormat(src_cat, sizeof(src_cat), L"|DriverPackages\\SeLow_Win10\\%S\\SeLow_Win10_%S.cat", cpu_type, cpu_type);<----------⑦このパスにファイルがない
		}
	}
	UniFormat(src_inf, sizeof(src_inf), L"|DriverPackages\\%S\\%S\\SeLow_%S.inf",	<---⑧このパスにファイルがない
		(MsIsWindows10() ? "SeLow_Win10" : "SeLow_Win8"),
		cpu_type, cpu_type);

	UniFormat(dst_sys, sizeof(dst_cat), L"%s\\SeLow_%S.sys", tmp_dir, cpu_type);
	UniFormat(dst_cat, sizeof(dst_cat), L"%s\\SeLow_%S_%S.cat", tmp_dir,
		(MsIsWindows10() ? "Win10" : "Win8"),
		cpu_type);

	UniFormat(dst_inf, sizeof(dst_inf), L"%s\\SeLow_%S.inf", tmp_dir, cpu_type);

	if (FileCopyW(src_sys, dst_sys) &&
		FileCopyW(src_cat, dst_cat) &&
		FileCopyW(src_inf, dst_inf))		<---⑨コピー元にファイルがないのでエラー発生
	{
		NO_WARNING *nw;

		nw = MsInitNoWarningEx(SL_USER_AUTO_PUSH_TIMER);

		if (MsIsWindows10())
		{
			if (MsIsServiceInstalled(SL_PROTOCOL_NAME) == false && MsIsServiceRunning(SL_PROTOCOL_NAME) == false)
			{
				// On Windows 10, if there are no SwLow service installed, then uinstall the protocol driver first.
				// TODO: currently do nothing. On some versions of Windows 10 beta builds it is necessary to do something...
			}
		}

		if (MsIsWindows10())
		{
			// Delete garbage INFs
			SuDeleteGarbageInfs();
		}

		// Call the installer
		if (InstallNdisProtocolDriver(dst_inf, L"SeLow", SL_USER_INSTALL_LOCK_TIMEOUT) == false)
		{
			Debug("InstallNdisProtocolDriver Error.\n");
		}
		else
		{
			Debug("InstallNdisProtocolDriver Ok.\n");

			// Copy manually because there are cases where .sys file is not copied successfully for some reason
			Debug("SuCopySysFile from %S to %s: ret = %u\n", src_sys, sys_fullpath, SuCopySysFile(src_sys, sys_fullpath));

			ret = true;

			// Write the version number into the registry
			MsRegWriteIntEx2(REG_LOCAL_MACHINE, SL_REG_KEY_NAME,
				(MsIsWindows10() ? SL_REG_VER_VALUE_WIN10 : SL_REG_VER_VALUE),
				SL_VER, false, true);

			// Set to automatic startup
			MsRegWriteIntEx2(REG_LOCAL_MACHINE, SL_REG_KEY_NAME, "Start", SERVICE_SYSTEM_START, false, true);
		}

		MsFreeNoWarning(nw);
	}
	else
	{
		Debug("Fail Copying Files.\n");
	}

	if (ret)
	{
		// If the service is installed this time, start and wait until the enumeration is completed
		SuFree(SuInitEx(180 * 1000));
	}

	return ret;
}
Last edited by hiura on Mon Mar 27, 2023 4:25 pm, edited 2 times in total.

cedar
Site Admin
Posts: 2054
Joined: Sat Mar 09, 2013 5:37 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by cedar » Wed Mar 22, 2023 10:48 am

| で始まるファイル名へのアクセスは、hamcore.se2 のアーカイブ内のファイルへのアクセスとなります。
アーカイブの中身はこちらです。

https://github.com/SoftEtherVPN/SoftEth ... in/hamcore

system32 に書き込み権限のあるユーザーで実行されているでしょうか?

hiura
Posts: 141
Joined: Wed Mar 10, 2021 1:56 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by hiura » Tue Mar 28, 2023 1:47 am

VPN SERVERのPC1で下記の通りファイルをコピーして、VPN SERVER(VPNTEST.EXE)を実行したら、
エラーは出なくなりL2TP/IPSECもつながるようになりました。
ソースコード通りエラーが発生しないように無理やりコピーしましたが、本来はどのような操作をすべきだったのでしょうか?。

C:\Users\AAAAAA\source\repos\SoftEtherVPN\src\bin\hamcore以下を
C:\Users\AAAAAA\source\repos\SoftEtherVPN\out\build\x64-nativeへコピー。

Code: Select all

1.構成

①
実行ディレクトリーx64-nativeの下にhamcore...がない。
実行ディレクトリーには hamcore.se2,vpn*.exe、vpn*.config等がビルドされている。
C:\Users\AAAAAA\source\repos\SoftEtherVPN\out\build\x64-native

注:AAAAAAは変えています。


②
下記ディレクトリーbinの下にhamcore...がある。その下にDriverPackagesがある。
C:\Users\AAAAAA\source\repos\SoftEtherVPN\src\bin\hamcore\DriverPackages

binの下には4つの実行ファイルのみ。
C:\Users\AAAAAA\source\repos\SoftEtherVPN\src\bin

2022/08/06  13:20             9,472 vpn16.exe
2023/03/26  10:27           215,552 vpndrvinst.exe
2022/08/06  13:20           550,560 winpcap_installer.exe
2022/08/06  13:20           467,181 winpcap_installer_win9x.exe


2.ディレクトリ内容

 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は BED0-D998 です

 C:\Users\AAAAAA\source\repos\SoftEtherVPN\src\bin\hamcore のディレクトリ

2023/03/28  09:45    <DIR>          .
2023/03/28  09:45    <DIR>          ..
2022/08/06  13:27             4,376 authors.txt
2022/08/06  13:20               314 backup_dir_readme.txt
2023/03/28  09:45                 0 direxe.txt
2022/08/06  13:20    <DIR>          DriverPackages
2022/08/06  13:20                37 empty.config
2022/08/06  13:20             3,587 eula.txt
2022/08/06  13:20               698 lang.config
2022/08/06  13:20               584 languages.txt
2022/08/06  13:20               260 languages_wine.txt
2022/08/06  13:20            37,618 legal.txt
2022/08/06  13:20           490,556 openvpn_readme.pdf
2022/08/06  13:20            13,030 openvpn_readme.txt
2022/08/06  13:20             5,580 openvpn_sample.ovpn
2023/03/26  10:27         5,633,536 PenCore.dll
2023/03/26  10:27             1,004 PenCore.lib
2022/08/06  13:20           400,489 root_certs.dat
2022/08/06  13:20             5,178 SOURCES_OF_BINARY_FILES.TXT
2022/08/06  13:20           577,952 strtable_cn.stb
2022/08/06  13:20           661,365 strtable_en.stb
2022/08/06  13:20           827,251 strtable_ja.stb
2022/08/06  13:20           703,807 strtable_ko.stb
2022/08/06  13:20           656,031 strtable_pt_br.stb
2022/08/06  13:20           663,606 strtable_ru.stb
2022/08/06  13:20           575,099 strtable_tw.stb
2022/08/06  13:20             9,472 vpn16.exe
2023/03/26  10:27           215,552 vpndrvinst.exe
2022/08/06  13:20           627,154 vpnserver_api_doc.html
2022/08/06  13:20             3,964 vpnweb_sample_cn.htm
2022/08/06  13:20             3,964 vpnweb_sample_en.htm
2022/08/06  13:20             4,856 vpnweb_sample_ja.htm
2022/08/06  13:20             4,458 vpnweb_sample_ko.htm
2022/08/06  13:20             3,964 vpnweb_sample_tw.htm
2022/08/06  13:20            30,803 warning_cn.txt
2022/08/06  13:20            36,296 warning_en.txt
2022/08/06  13:20            50,698 warning_ja.txt
2022/08/06  13:20            43,067 warning_ko.txt
2022/08/06  13:20            36,296 warning_ru.txt
2022/08/06  13:20            30,896 warning_tw.txt
2022/08/06  13:20    <DIR>          webui
2022/08/06  13:20           550,560 winpcap_installer.exe
2022/08/06  13:20           467,181 winpcap_installer_win9x.exe
2022/08/06  13:20    <DIR>          wwwroot
              39 個のファイル          13,381,139 バイト
               5 個のディレクトリ  149,192,470,528 バイトの空き領域

cedar
Site Admin
Posts: 2054
Joined: Sat Mar 09, 2013 5:37 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by cedar » Tue Mar 28, 2023 6:28 am

bin/hamcore フォルダの内容を圧縮してまとめたものが hamcore.se2 です。
何らかの理由で、hamcore.se2 が不完全な状態になっているのかもしれません。

hiura
Posts: 141
Joined: Wed Mar 10, 2021 1:56 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by hiura » Thu Mar 30, 2023 10:30 am

「hamcore.se2」をメモ帳で見ると、下記の通り、ディレクトリーの区切りが/になっています。
DriverPackages/Wfp/x64/pxwfp_x64.sys

区切りは¥でないといけないのでは?。
DriverPackages¥Wfp¥x64¥pxwfp_x64.sys

cedar
Site Admin
Posts: 2054
Joined: Sat Mar 09, 2013 5:37 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by cedar » Thu Mar 30, 2023 10:39 am

SoftEther VPN は独自のファイルアクセスライブラリを持っていて、OSによって自動的にパス区切り文字を読み替えてアクセスすることができます。

hiura
Posts: 141
Joined: Wed Mar 10, 2021 1:56 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by hiura » Sat Apr 01, 2023 2:58 am

パス区切り文字を¥にした場合は、エラー。
"|DriverPackages\\Wfp_Win10\\%s\\pxwfp_%s.sys",
ReadHamcore()が返すアドレスはNULL

パス区切り文字を/にした場合は、正常。
"|DriverPackages/Wfp_Win10/%s/pxwfp_%s.sys",
ReadHamcore()が返すアドレスOK

となります。hamcore.se2内のパス区切り文字が/になっているためと推測します。

パス区切り文字を変えて実行した(”ソースコードA”)
Debug()文追加(”ソースコードB”、”ソースコードC”)

ケース1:
install_driver = true;<ーーー強制実行
Format(src_filename, sizeof(src_filename),
"|DriverPackages\\Wfp_Win10\\%s\\pxwfp_%s.sys", <ーーーケース1 パス区切り文字を¥
(MsIsX64() ? "x64" : "x86"), (MsIsX64() ? "x64" : "x86"));

ケース2:
install_driver = true;<ーーー強制実行
Format(src_filename, sizeof(src_filename),
"|DriverPackages/Wfp_Win10/%s/pxwfp_%s.sys", <ーーーケース2 パス区切り文字を/
(MsIsX64() ? "x64" : "x86"), (MsIsX64() ? "x64" : "x86"));
ケース1:エラー

Code: Select all

_____ FileOpenExW()  |1  ReadHamcoreW()    name =|DriverPackages\Wfp_Win10\x64\pxwfp_x64.sys
_____ FileOpenExW()   3  FileOpenInnerW()   tmp =C:\Users\AAAAAA\source\repos\SoftEtherVPN\out\build\x64-native\hamcore\DriverPackages\Wfp_Win10\x64\pxwfp_x64.sys
_____ FileOpenExW()   3  FileOpenInnerW()   tmp =C:\Users\AAAAAA\source\repos\SoftEtherVPN\out\build\x64-native\server_log\vpn_20230401.log
_____ ReadHamcore() MID  HAMCORE_DONE name=DriverPackages\Wfp_Win10\x64\pxwfp_x64.sys, buf=0, c=0, file=0
_____ ReadHamcore() RET  HAMCORE_DONE name=DriverPackages\Wfp_Win10\x64\pxwfp_x64.sys, buf=0<ーーーアドレスNULL
_____ FileOpenExW()  |2  ReadHamcoreW() o->Name =DriverPackages\Wfp_Win10\x64\pxwfp_x64.sys, o->HamBuf =0<ーーーアドレスNULL
_____ IPsecWin7InitDriverInner()_____src_filename=|DriverPackages\Wfp_Win10\x64\pxwfp_x64.sys
ケース2:正常

Code: Select all

_____ FileOpenExW()  |1  ReadHamcoreW()    name =|DriverPackages/Wfp_Win10/x64/pxwfp_x64.sys
_____ FileOpenExW()   3  FileOpenInnerW()   tmp =C:\Users\AAAAAA\source\repos\SoftEtherVPN\out\build\x64-native\hamcore\DriverPackages\Wfp_Win10\x64\pxwfp_x64.sys
_____ ReadHamcore() MID  HAMCORE_DONE name=DriverPackages/Wfp_Win10/x64/pxwfp_x64.sys, buf=0, c=1884167024, file=1836387536
_____ ReadHamcore() RET  HAMCORE_DONE name=DriverPackages/Wfp_Win10/x64/pxwfp_x64.sys, buf=1885201616<ーーーアドレスOK
_____ FileOpenExW()  |2  ReadHamcoreW()  o->Name=DriverPackages/Wfp_Win10/x64/pxwfp_x64.sys, o->HamBuf =1885201616<ーーーアドレスOK
下記ソースコード参照
1.ソースコードA

Code: Select all

bool IPsecWin7InitDriverInner()
{
	char sys_filename[MAX_PATH];
	bool install_driver = true;
	HANDLE hEngine;
	UINT ret;
	FWPM_SESSION0 session;
	UINT id;
	FWPM_CALLOUT0 callout;

	Format(sys_filename, sizeof(sys_filename), IPSEC_WIN7_DST_SYS, MsGetSystem32Dir());

	if (IsFileExists(sys_filename) && MsIsServiceInstalled(IPSEC_WIN7_DRIVER_NAME))
	{
		if (GetCurrentIPsecWin7DriverBuild() >= CEDAR_VERSION_BUILD)
		{
			// Not to install since the latest version has been already installed
			install_driver = false;
		}
	}
	install_driver = true;// by hiura		<ーーー強制実行

	if (install_driver)
	{
		char src_filename[MAX_PATH];

		if (MsIsWindows10() == false)
		{
			Format(src_filename, sizeof(src_filename),
				"|DriverPackages\\Wfp\\%s\\pxwfp_%s.sys",
				(MsIsX64() ? "x64" : "x86"), (MsIsX64() ? "x64" : "x86"));
		}
		else
		{
			Format(src_filename, sizeof(src_filename),
				"|DriverPackages\\Wfp_Win10\\%s\\pxwfp_%s.sys",	<ーーーケース1
//				"|DriverPackages/Wfp_Win10/%s/pxwfp_%s.sys",// by HIURA	<ーーーケース2
				(MsIsX64() ? "x64" : "x86"), (MsIsX64() ? "x64" : "x86"));
		}

		// Copy the driver
		if (FileCopy(src_filename, sys_filename) == false)
		{
			Debug("%s copy failed. %u\n", sys_filename, GetLastError());
Debug("_____ IPsecWin7InitDriverInner()_____src_filename=%s\n", src_filename);// by HIURA

			if (IsFileExists(sys_filename) == false)
			{
				Debug("%s failed. Abort.\n", sys_filename);
				return false;
			}
		}
		else
		{
			Debug("%s copied.\n", sys_filename);
		}

		// Set the build number
		SetCurrentIPsecWin7DriverBuild();
	}

	// Get whether the device drivers is already installed
	if (MsIsServiceInstalled(IPSEC_WIN7_DRIVER_NAME) == false)
	{
		wchar_t sys_filename_w[MAX_PATH];

		StrToUni(sys_filename_w, sizeof(sys_filename_w), sys_filename);

		// Run a new installation
		if (MsInstallDeviceDriverW(IPSEC_WIN7_DRIVER_NAME, IPSEC_WIN7_DRIVER_TITLE,
			sys_filename_w, NULL) == false)
		{
			// Installation failed
			Debug("MsInstallDeviceDriverW failed.\n");
			return false;
		}
	}

	// Start if the device driver is stopped
	if (MsIsServiceRunning(IPSEC_WIN7_DRIVER_NAME) == false)
	{
		if (MsStartService(IPSEC_WIN7_DRIVER_NAME) == false)
		{
			// Start failure
			Debug("MsStartService failed.\n");
			return false;
		}

		Debug("%s service started.\n", IPSEC_WIN7_DRIVER_NAME);
	}
	else
	{
		Debug("%s service was already started.\n", IPSEC_WIN7_DRIVER_NAME);
	}

	// Open the WFP
	Zero(&session, sizeof(session));

	ret = api->FwpmEngineOpen0(NULL, RPC_C_AUTHN_DEFAULT, NULL, &session, &hEngine);
	if (ret)
	{
		Debug("FwpmEngineOpen0 failed.\n");
		return false;
	}

	// Create the Callout Driver (IPv4)
	Zero(&callout, sizeof(callout));
	callout.calloutKey = GUID_WFP_CALLOUT_DRIVER_V4;
	callout.applicableLayer = FWPM_LAYER_INBOUND_IPPACKET_V4;
	callout.displayData.name = IPSEC_WIN7_DRIVER_TITLE_V4;
	ret = api->FwpmCalloutAdd0(hEngine, &callout, NULL, &id);
	if (ret)
	{
		Debug("FwpmCalloutAdd0 for IPv4 Failed: 0x%X\n", ret);
	}
	else
	{
		Debug("FwpmCalloutAdd0 for IPv4 Ok.\n");
	}

	// Create the Callout Driver (IPv6)
	Zero(&callout, sizeof(callout));
	callout.calloutKey = GUID_WFP_CALLOUT_DRIVER_V6;
	callout.applicableLayer = FWPM_LAYER_INBOUND_IPPACKET_V6;
	callout.displayData.name = IPSEC_WIN7_DRIVER_TITLE_V6;
	ret = api->FwpmCalloutAdd0(hEngine, &callout, NULL, &id);
	if (ret)
	{
		Debug("FwpmCalloutAdd0 for IPv6 Failed: 0x%X\n", ret);
	}
	else
	{
		Debug("FwpmCalloutAdd0 for IPv6 Ok.\n");
	}

	api->FwpmEngineClose0(hEngine);

	return true;
}
2.ソースコードB

Code: Select all

IO *FileOpenExW(wchar_t *name, bool write_mode, bool read_lock)
{
	wchar_t tmp[MAX_SIZE];
	// Validate arguments
	if (name == NULL)
	{
		return NULL;
	}

	InnerFilePathW(tmp, sizeof(tmp), name);

	if (name[0] == L'|')
	{
Debug("_____ FileOpenExW()  |1  ReadHamcoreW()    name =%S\n", name);
		IO *o = ZeroMalloc(sizeof(IO));
		name++;
		UniStrCpy(o->NameW, sizeof(o->NameW), name);
		UniToStr(o->Name, sizeof(o->Name), o->NameW);
		o->HamMode = true;
		o->HamBuf = ReadHamcoreW(name);
Debug("_____ FileOpenExW()  |2  ReadHamcoreW() o->Name =%s, o->HamBuf =%u\n", o->Name, o->HamBuf);
		if (o->HamBuf == NULL)
		{
			Free(o);
			return NULL;
		}
		return o;
	}
	else
	{
Debug("_____ FileOpenExW()   3  FileOpenInnerW()   tmp =%S\n", tmp);
		return FileOpenInnerW(tmp, write_mode, read_lock);
	}
}
3.ソースコードC

Code: Select all

// Read HamCore file
BUF *ReadHamcoreW(wchar_t *filename)
{
	char *filename_a = CopyUniToStr(filename);
	BUF *ret;

	ret = ReadHamcore(filename_a);

	Free(filename_a);

	return ret;
}
BUF *ReadHamcore(char *name)
{
//Debug("_____ ReadHamcore() START name=%s MayaquaIsMinimalMode=%d\n", name, MayaquaIsMinimalMode());
	if (name == NULL || MayaquaIsMinimalMode())
	{
		return NULL;
	}

	if (name[0] == '/')
	{
		++name;
	}

	char path[MAX_PATH];
	GetExeDir(path, sizeof(path));
	Format(path, sizeof(path), "%s/%s/%s", path, HAMCORE_DIR_NAME, name);
	BUF *buf = ReadDump(path);
	if (buf != NULL)
	{
Debug("_____ ReadHamcore() RET  NO_HAMCORE_DONE_OK path=%s, name=%s, buf=%u\n", path, name, buf);
		return buf;
	}

	LockList(hamcore);
	{
		HC t = {0};
		t.Path = name;
		HC *c = Search(hamcore, &t);
		if (c == NULL)
		{
			const HAMCORE_FILE *file = HamcoreFind(hamcore_io, name);
			if (file)
			{
				c = Malloc(sizeof(HC));
				c->Size = file->OriginalSize;
				c->Path = CopyStr(name);
				c->Buffer = Malloc(c->Size);

				if (HamcoreRead(hamcore_io, c->Buffer, file))
				{
					Add(hamcore, c);
				}
				else
				{
					Free(c->Buffer);
					Free(c->Path);
					Free(c);

					c = NULL;
				}
			}
Debug("_____ ReadHamcore() MID  HAMCORE_DONE name=%s, buf=%u, c=%u, file=%u\n", name, buf, c, file);
		}

		if (c != NULL)
		{
			buf = NewBuf();
			WriteBuf(buf, c->Buffer, c->Size);
			SeekBuf(buf, 0, 0);
			c->LastAccess = Tick64();
		}

		LIST *to_delete = NewListFast(NULL);

		for (UINT i = 0; i < LIST_NUM(hamcore); ++i)
		{
			HC *c = LIST_DATA(hamcore, i);
			if (c->LastAccess + HAMCORE_CACHE_EXPIRES <= Tick64())
			{
				Add(to_delete, c);
			}
		}

		for (UINT i = 0; i < LIST_NUM(to_delete); ++i)
		{
			HC *c = LIST_DATA(to_delete, i);

			Delete(hamcore, c);

			Free(c->Buffer);
			Free(c->Path);
			Free(c);
		}

		ReleaseList(to_delete);
	}
	UnlockList(hamcore);
Debug("_____ ReadHamcore() RET  HAMCORE_DONE name=%s, buf=%u\n", name, buf);

	return buf;
}
Last edited by hiura on Tue May 16, 2023 10:03 am, edited 6 times in total.

cedar
Site Admin
Posts: 2054
Joined: Sat Mar 09, 2013 5:37 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by cedar » Sat Apr 01, 2023 9:15 am

たしかに変ですね。
hamcore.se2 アーカイブへのアクセスではパス区切りは「/」に統一されているはずなので、バグのような気がします。
GitHub のメンテナチームに報告されてみるのが良いかと思います。

hiura
Posts: 141
Joined: Wed Mar 10, 2021 1:56 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by hiura » Sat Apr 01, 2023 10:25 am

STABLE EDITION
VPN4.0 (VER4.38, BUILD 9760)の「hamcore.se2」の区切りは¥になっていますが。
Last edited by hiura on Tue May 16, 2023 4:52 am, edited 1 time in total.

cedar
Site Admin
Posts: 2054
Joined: Sat Mar 09, 2013 5:37 am

Re: L2TP/IPSEC(WIN10)からSOFTETHER VPN SERVER(WIN10)へ接続できません。

Post by cedar » Sat Apr 01, 2023 12:36 pm

統一しようとして間違えたのかもしれませんね。

Post Reply