Skip to content

Commit 549ebf5

Browse files
committed
refactor(share_plus): use win32's RtlGetVersion instead of manual lookup
1 parent 6427bc6 commit 549ebf5

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

packages/share_plus/share_plus/lib/src/windows_version_helper.dart

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import 'dart:io';
21
import 'dart:ffi';
2+
import 'dart:io';
3+
34
import 'package:ffi/ffi.dart';
45
import 'package:win32/win32.dart';
56

@@ -18,24 +19,9 @@ class VersionHelper {
1819

1920
VersionHelper._() {
2021
if (Platform.isWindows) {
21-
final pointer = calloc<OSVERSIONINFOEX>();
22-
pointer.ref
23-
..dwOSVersionInfoSize = sizeOf<OSVERSIONINFOEX>()
24-
..dwBuildNumber = 0
25-
..dwMajorVersion = 0
26-
..dwMinorVersion = 0
27-
..dwPlatformId = 0
28-
..szCSDVersion = ''
29-
..wServicePackMajor = 0
30-
..wServicePackMinor = 0
31-
..wSuiteMask = 0
32-
..wProductType = 0;
33-
final rtlGetVersion = DynamicLibrary.open('ntdll.dll')
34-
.lookupFunction<
35-
Void Function(Pointer<OSVERSIONINFOEX>),
36-
void Function(Pointer<OSVERSIONINFOEX>)
37-
>('RtlGetVersion');
38-
rtlGetVersion(pointer);
22+
final pointer = calloc<OSVERSIONINFOEX>()
23+
..ref.dwOSVersionInfoSize = sizeOf<OSVERSIONINFOEX>();
24+
RtlGetVersion(pointer.cast());
3925
isWindows10RS5OrGreater =
4026
pointer.ref.dwBuildNumber >= kWindows10RS5BuildNumber;
4127
calloc.free(pointer);

0 commit comments

Comments
 (0)