mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
dll: FspVersion
This commit is contained in:
parent
12704a3a4a
commit
50ed020e16
@ -202,6 +202,7 @@
|
|||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\security-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\security-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\stream-tests.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\stream-tests.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\timeout-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\timeout-test.c" />
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\version-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\winfsp-tests.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\winfsp-tests.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -82,6 +82,9 @@
|
|||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\exec-test.c">
|
<ClCompile Include="..\..\..\tst\winfsp-tests\exec-test.c">
|
||||||
<Filter>Source</Filter>
|
<Filter>Source</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\version-test.c">
|
||||||
|
<Filter>Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
||||||
|
@ -1627,6 +1627,7 @@ FSP_API NTSTATUS FspCallNamedPipeSecurely(PWSTR PipeName,
|
|||||||
PVOID InBuffer, ULONG InBufferSize, PVOID OutBuffer, ULONG OutBufferSize,
|
PVOID InBuffer, ULONG InBufferSize, PVOID OutBuffer, ULONG OutBufferSize,
|
||||||
PULONG PBytesTransferred, ULONG Timeout,
|
PULONG PBytesTransferred, ULONG Timeout,
|
||||||
PSID Sid);
|
PSID Sid);
|
||||||
|
FSP_API NTSTATUS FspVersion(PUINT32 PVersion);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delay load
|
* Delay load
|
||||||
|
@ -163,3 +163,47 @@ exit:
|
|||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FSP_API NTSTATUS FspVersion(PUINT32 PVersion)
|
||||||
|
{
|
||||||
|
static UINT32 Version;
|
||||||
|
|
||||||
|
if (0 == Version)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This check is not thread-safe, but that should be ok.
|
||||||
|
* Two threads competing to read the version will read
|
||||||
|
* the same value from the Version resource.
|
||||||
|
*/
|
||||||
|
extern HINSTANCE DllInstance;
|
||||||
|
WCHAR ModuleFileName[MAX_PATH];
|
||||||
|
PVOID VersionInfo;
|
||||||
|
DWORD Size;
|
||||||
|
VS_FIXEDFILEINFO *FixedFileInfo = 0;
|
||||||
|
|
||||||
|
if (0 != GetModuleFileNameW(DllInstance, ModuleFileName, MAX_PATH))
|
||||||
|
{
|
||||||
|
Size = GetFileVersionInfoSizeW(ModuleFileName, &Size/*dummy*/);
|
||||||
|
if (0 < Size)
|
||||||
|
{
|
||||||
|
VersionInfo = MemAlloc(Size);
|
||||||
|
if (0 != VersionInfo &&
|
||||||
|
GetFileVersionInfoW(ModuleFileName, 0, Size, VersionInfo) &&
|
||||||
|
VerQueryValueW(VersionInfo, L"\\", &FixedFileInfo, &Size))
|
||||||
|
{
|
||||||
|
/* 32-bit store should be atomic! */
|
||||||
|
Version = FixedFileInfo->dwFileVersionMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemFree(VersionInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == FixedFileInfo)
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*PVersion = Version;
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
44
tst/winfsp-tests/version-test.c
Normal file
44
tst/winfsp-tests/version-test.c
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* @file version-test.c
|
||||||
|
*
|
||||||
|
* @copyright 2015-2017 Bill Zissimopoulos
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* This file is part of WinFsp.
|
||||||
|
*
|
||||||
|
* You can redistribute it and/or modify it under the terms of the GNU
|
||||||
|
* General Public License version 3 as published by the Free Software
|
||||||
|
* Foundation.
|
||||||
|
*
|
||||||
|
* Licensees holding a valid commercial license may use this file in
|
||||||
|
* accordance with the commercial license agreement provided with the
|
||||||
|
* software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <winfsp/winfsp.h>
|
||||||
|
#include <tlib/testsuite.h>
|
||||||
|
|
||||||
|
#include "winfsp-tests.h"
|
||||||
|
|
||||||
|
static void version_test(void)
|
||||||
|
{
|
||||||
|
/* this is not a real test! */
|
||||||
|
|
||||||
|
UINT32 Version1, Version2;
|
||||||
|
NTSTATUS Result;
|
||||||
|
|
||||||
|
Result = FspVersion(&Version1);
|
||||||
|
ASSERT(NT_SUCCESS(Result));
|
||||||
|
|
||||||
|
Result = FspVersion(&Version2);
|
||||||
|
ASSERT(NT_SUCCESS(Result));
|
||||||
|
|
||||||
|
ASSERT(Version1 == Version2);
|
||||||
|
|
||||||
|
FspDebugLog(__FUNCTION__ ": FspVersion=%d.%d\n", HIWORD(Version1), LOWORD(Version1));
|
||||||
|
}
|
||||||
|
|
||||||
|
void version_tests(void)
|
||||||
|
{
|
||||||
|
TEST(version_test);
|
||||||
|
}
|
@ -184,6 +184,7 @@ int main(int argc, char *argv[])
|
|||||||
TESTSUITE(eventlog_tests);
|
TESTSUITE(eventlog_tests);
|
||||||
TESTSUITE(path_tests);
|
TESTSUITE(path_tests);
|
||||||
TESTSUITE(dirbuf_tests);
|
TESTSUITE(dirbuf_tests);
|
||||||
|
TESTSUITE(version_tests);
|
||||||
TESTSUITE(mount_tests);
|
TESTSUITE(mount_tests);
|
||||||
TESTSUITE(timeout_tests);
|
TESTSUITE(timeout_tests);
|
||||||
TESTSUITE(memfs_tests);
|
TESTSUITE(memfs_tests);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user