mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:20:31 +00:00
c04673f44b
Support looking up a symbol in the process on Windows by using the Windows Process Status API to iterate over all loaded Modules. TEST=tests/ffi/has_symbol_test.dart TEST=tests/ffi/vmspecific_dynamic_library_test.dart Change-Id: I1029f1c7dae9a193b662d942388affb681842c90 Cq-Include-Trybots: luci.dart.try:vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,dart-sdk-win-try,vm-kernel-win-release-x64-try,vm-kernel-win-release-ia32-try,vm-kernel-precomp-win-product-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260760 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
36 lines
1 KiB
Dart
36 lines
1 KiB
Dart
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
//
|
|
// SharedObjects=ffi_test_functions
|
|
|
|
// @dart=2.9
|
|
|
|
import 'dart:ffi';
|
|
import 'dart:io';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
import 'ffi_test_helpers.dart';
|
|
|
|
void main() {
|
|
testHasSymbol();
|
|
}
|
|
|
|
void testHasSymbol() {
|
|
Expect.isTrue(ffiTestFunctions.providesSymbol('ReturnMaxUint8'));
|
|
Expect.isFalse(ffiTestFunctions.providesSymbol('SymbolNotInLibrary'));
|
|
|
|
final p = DynamicLibrary.process();
|
|
Expect.isFalse(p.providesSymbol('symbol_that_does_not_exist_in_process'));
|
|
if (Platform.isWindows) {
|
|
Expect.isTrue(p.providesSymbol('HeapAlloc'));
|
|
Expect.isTrue(p.providesSymbol('CoTaskMemAlloc'));
|
|
} else {
|
|
Expect.isTrue(p.providesSymbol('dlopen'));
|
|
}
|
|
|
|
final e = DynamicLibrary.executable();
|
|
Expect.isTrue(e.providesSymbol('Dart_Invoke'));
|
|
Expect.isFalse(e.providesSymbol('symbol_that_does_not_exist_in_executable'));
|
|
}
|