Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SoftEtherVPN/SoftEtherVPN_Stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mayaqua/Microsoft.c')
-rw-r--r--src/Mayaqua/Microsoft.c162
1 files changed, 117 insertions, 45 deletions
diff --git a/src/Mayaqua/Microsoft.c b/src/Mayaqua/Microsoft.c
index 1c92db6d..8248274f 100644
--- a/src/Mayaqua/Microsoft.c
+++ b/src/Mayaqua/Microsoft.c
@@ -218,6 +218,8 @@ static LOCK *vlan_lock = NULL;
static COUNTER *suspend_handler_singleton = NULL;
static COUNTER *vlan_card_counter = NULL;
static volatile BOOL vlan_card_should_stop_flag = false;
+static volatile BOOL vlan_is_in_suspend_mode = false;
+static volatile UINT64 vlan_suspend_mode_begin_tick = 0;
// msi.dll
static HINSTANCE hMsi = NULL;
@@ -5794,10 +5796,14 @@ bool MsIsVLanCardShouldStop()
void MsProcEnterSuspend()
{
UINT64 giveup_tick = Tick64() + 2000;
- UINT num = 0;
+ UINT num = Count(vlan_card_counter);
+
+ vlan_is_in_suspend_mode = true;
vlan_card_should_stop_flag = true;
+ vlan_suspend_mode_begin_tick = Tick64();
+
while (true)
{
UINT64 now = Tick64();
@@ -5811,19 +5817,29 @@ void MsProcEnterSuspend()
{
break;
}
- num++;
SleepThread(100);
}
if (num >= 1)
{
- SleepThread(512);
+ SleepThread(3000);
}
}
void MsProcLeaveSuspend()
{
vlan_card_should_stop_flag = false;
+ vlan_is_in_suspend_mode = false;
+ vlan_suspend_mode_begin_tick = Tick64();
+}
+UINT64 MsGetSuspendModeBeginTick()
+{
+ if (vlan_is_in_suspend_mode)
+ {
+ return Tick64();
+ }
+
+ return vlan_suspend_mode_begin_tick;
}
// Suspend handler window proc
@@ -5852,26 +5868,22 @@ LRESULT CALLBACK MsSuspendHandlerWindowProc(HWND hWnd, UINT msg, WPARAM wParam,
break;
case WM_POWERBROADCAST:
- switch (wParam)
+ if (MsIsVista())
{
- case PBT_APMSUSPEND:
- MsProcEnterSuspend();
- return 1;
+ switch (wParam)
+ {
+ case PBT_APMSUSPEND:
+ MsProcEnterSuspend();
+ return 1;
- case PBT_APMRESUMEAUTOMATIC:
- case PBT_APMRESUMESUSPEND:
- MsProcLeaveSuspend();
- return 1;
+ case PBT_APMRESUMEAUTOMATIC:
+ case PBT_APMRESUMESUSPEND:
+ MsProcLeaveSuspend();
+ return 1;
+ }
}
break;
- case WM_LBUTTONUP:
- /*
- MsProcEnterSuspend();
- MsgBox(hWnd, 0, L"TEST");
- MsProcLeaveSuspend();*/
- break;
-
case WM_CLOSE:
/*if (h->AboutToClose == false)
{
@@ -5940,6 +5952,8 @@ void MsSuspendHandlerThreadProc(THREAD *thread, void *param)
}
vlan_card_should_stop_flag = false;
+ vlan_is_in_suspend_mode = false;
+ vlan_suspend_mode_begin_tick = 0;
DestroyWindow(hWnd);
@@ -5958,6 +5972,10 @@ MS_SUSPEND_HANDLER *MsNewSuspendHandler()
return NULL;
}
+ vlan_card_should_stop_flag = false;
+ vlan_is_in_suspend_mode = false;
+ vlan_suspend_mode_begin_tick = 0;
+
h = ZeroMalloc(sizeof(MS_SUSPEND_HANDLER));
t = NewThread(MsSuspendHandlerThreadProc, h);
@@ -5966,8 +5984,6 @@ MS_SUSPEND_HANDLER *MsNewSuspendHandler()
h->Thread = t;
- vlan_card_should_stop_flag = false;
-
return h;
}
@@ -8625,7 +8641,7 @@ bool MsInstallVLan9x(char *instance_name, MS_DRIVER_VER *ver)
MakeDir(otherdir);
- Format(neo_sys, sizeof(neo_sys), DRIVER_INSTALL_SYS_NAME_TAG, instance_name);
+ Format(neo_sys, sizeof(neo_sys), "Neo_%s.sys", instance_name);
// Copy of vpn16.exe
FileCopy("|vpn16.exe", vpn16);
@@ -9552,7 +9568,7 @@ void MsGetInfCatalogDir(char *dst, UINT size)
return;
}
- Format(dst, size, "|inf\\%s", (MsIsX64() ? "x64" : "x86"));
+ Format(dst, size, "|DriverPackages\\%s\\%s", (MsIsWindows10() ? "Neo6_Win10" : "Neo6_Win8"), (MsIsX64() ? "x64" : "x86"));
}
// Examine whether the virtual LAN card name can be used as a instance name of the VLAN
@@ -9569,7 +9585,8 @@ bool MsIsValidVLanInstanceNameForInfCatalog(char *instance_name)
MsGetInfCatalogDir(src_dir, sizeof(src_dir));
- Format(tmp, sizeof(tmp), "%s\\INF_%s.inf", src_dir, instance_name);
+ Format(tmp, sizeof(tmp), "%s\\Neo6_%s_%s.inf", src_dir, (MsIsX64() ? "x64" : "x86"), instance_name);
+
ret = IsFile(tmp);
return ret;
@@ -9719,7 +9736,14 @@ bool MsInstallVLanWithoutLock(char *tag_name, char *connection_tag_name, char *i
}
else
{
- Format(neo_sys, sizeof(neo_sys), DRIVER_INSTALL_SYS_NAME_TAG, instance_name);
+ if (MsIsWindows10() == false)
+ {
+ Format(neo_sys, sizeof(neo_sys), "Neo_%s.sys", instance_name);
+ }
+ else
+ {
+ Format(neo_sys, sizeof(neo_sys), "Neo6_%s_%s.sys", (MsIsX64() ? "x64" : "x86"), instance_name);
+ }
}
// Starting the Installation
@@ -10511,42 +10535,50 @@ void MsGetDriverPath(char *instance_name, wchar_t *src_inf, wchar_t *src_sys, wc
return;
}
- src_filename = DRIVER_INF_FILE_NAME;
- src_sys_filename = DRIVER_SYS_FILE_NAME;
+ // WinNT x86
+ src_filename = L"|DriverPackages\\Neo\\x86\\Neo_x86.inf";
+ src_sys_filename = L"|DriverPackages\\Neo\\x86\\Neo_x86.sys";
if (MsIsNt() == false)
{
- src_filename = DRIVER_INF_FILE_NAME_9X;
- src_sys_filename = DRIVER_SYS_FILE_NAME_9X;
+ // Win9x
+ src_filename = L"|DriverPackages\\Neo9x\\x86\\Neo9x_x86.inf";
+ src_sys_filename = L"|DriverPackages\\Neo9x\\x86\\Neo9x_x86.sys";
}
- else if (MsIsIA64() || MsIsX64())
+ else if (MsIsX64())
{
+ // WinNT x64
+ src_filename = L"|DriverPackages\\Neo\\x64\\Neo_x64.inf";
+ src_sys_filename = L"|DriverPackages\\Neo\\x64\\Neo_x64.sys";
+ }
+
+ if (MsIsWindows7())
+ {
+ // Use the NDIS 6.2 driver for Windows 7 or later
if (MsIsX64())
{
- src_filename = DRIVER_INF_FILE_NAME_X64;
- src_sys_filename = DRIVER_SYS_FILE_NAME_X64;
+ src_filename = L"|DriverPackages\\Neo6\\x64\\Neo6_x64.inf";
+ src_sys_filename = L"|DriverPackages\\Neo6\\x64\\Neo6_x64.sys";
}
else
{
- src_filename = DRIVER_INF_FILE_NAME_IA64;
- src_sys_filename = DRIVER_SYS_FILE_NAME_IA64;
+ src_filename = L"|DriverPackages\\Neo6\\x86\\Neo6_x86.inf";
+ src_sys_filename = L"|DriverPackages\\Neo6\\x86\\Neo6_x86.sys";
}
}
- if (MsIsWindows7())
+ if (MsIsInfCatalogRequired())
{
- // Use the NDIS 6.2 driver for Windows 7 or later
+ // Windows 8 or later
if (MsIsX64())
{
- src_sys_filename = DRIVER_SYS6_FILE_NAME_X64;
- }
- else if (MsIsIA64())
- {
- src_sys_filename = DRIVER_SYS6_FILE_NAME_IA64;
+ src_filename = L"|DriverPackages\\Neo6_Win8\\x64\\Neo6_x64.inf";
+ src_sys_filename = L"|DriverPackages\\Neo6_Win8\\x64\\Neo6_x64.sys";
}
else
{
- src_sys_filename = DRIVER_SYS6_FILE_NAME;
+ src_filename = L"|DriverPackages\\Neo6_Win8\\x86\\Neo6_x86.inf";
+ src_sys_filename = L"|DriverPackages\\Neo6_Win8\\x86\\Neo6_x86.sys";
}
}
@@ -10554,27 +10586,43 @@ void MsGetDriverPath(char *instance_name, wchar_t *src_inf, wchar_t *src_sys, wc
{
if (MsIsInfCatalogRequired() == false)
{
+ // Windows 7 or before
UniStrCpy(src_inf, MAX_PATH, src_filename);
}
else
{
+ // Windows 8.1 or later
char tmp[MAX_SIZE];
MsGetInfCatalogDir(tmp, sizeof(tmp));
- UniFormat(src_inf, MAX_PATH, L"%S\\INF_%S.inf", tmp, instance_name);
+ UniFormat(src_inf, MAX_PATH, L"%S\\Neo6_%S_%S.inf", tmp, (MsIsX64() ? "x64" : "x86"), instance_name);
}
}
if (src_sys != NULL)
{
UniStrCpy(src_sys, MAX_PATH, src_sys_filename);
+
+ if (MsIsWindows10())
+ {
+ UniFormat(src_sys, MAX_PATH, L"|DriverPackages\\Neo6_Win10\\%S\\Neo6_%S_%S.sys",
+ (MsIsX64() ? "x64" : "x86"), (MsIsX64() ? "x64" : "x86"), instance_name);
+ }
}
if (dest_inf != NULL)
{
char inf_name[MAX_PATH];
- Format(inf_name, sizeof(inf_name), DRIVER_INSTALL_INF_NAME_TAG, instance_name);
+
+ if (MsIsInfCatalogRequired() == false)
+ {
+ Format(inf_name, sizeof(inf_name), "Neo_%s.inf", instance_name);
+ }
+ else
+ {
+ Format(inf_name, sizeof(inf_name), "Neo6_%s_%s.inf", (MsIsX64() ? "x64" : "x86"), instance_name);
+ }
UniFormat(dest_inf, MAX_PATH, L"%s\\%S", ms->MyTempDirW, inf_name);
}
@@ -10592,7 +10640,24 @@ void MsGetDriverPath(char *instance_name, wchar_t *src_inf, wchar_t *src_sys, wc
char tmp[MAX_SIZE];
MsGetInfCatalogDir(tmp, sizeof(tmp));
- UniFormat(src_cat, MAX_PATH, L"%S\\inf.cat", tmp);
+
+ if (MsIsWindows8() == false)
+ {
+ // Windows Vista and Windows 7 uses SHA-1 catalog files
+ // (Unused? Never reach here!)
+ UniFormat(src_cat, MAX_PATH, L"%S\\inf.cat", tmp);
+ }
+ else
+ {
+ // Windows 8 or above uses SHA-256 catalog files
+ UniFormat(src_cat, MAX_PATH, L"%S\\inf2.cat", tmp);
+ }
+
+ if (MsIsWindows10())
+ {
+ // Windows 10
+ UniFormat(src_cat, MAX_PATH, L"%S\\Neo6_%S_%S.cat", tmp, (MsIsX64() ? "x64" : "x86"), instance_name);
+ }
}
else
{
@@ -10604,7 +10669,14 @@ void MsGetDriverPath(char *instance_name, wchar_t *src_inf, wchar_t *src_sys, wc
{
if (MsIsInfCatalogRequired())
{
- UniFormat(dest_cat, MAX_PATH, L"%s\\inf_%S.cat", ms->MyTempDirW, instance_name);
+ if (MsIsWindows10() == false)
+ {
+ UniFormat(dest_cat, MAX_PATH, L"%s\\inf_%S.cat", ms->MyTempDirW, instance_name);
+ }
+ else
+ {
+ UniFormat(dest_cat, MAX_PATH, L"%s\\Neo6_%S_%S.cat", ms->MyTempDirW, (MsIsX64() ? "x64" : "x86"), instance_name);
+ }
}
else
{