Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6ec29b

Browse files
committed
Fix for default manifest test. Turns out LoadLibrary chokes sometimes on x86 when loading Debug assemblies. Switch to LoadLibraryEx, loading binaries as pure data files. (changeset 1236335)
1 parentd6b2bf8 commita6ec29b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

‎tests/fsharpqa/Source/Misc/DefaultManifest.fs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module NativeMethods =
1212
typeEnumResourceNamesCallback=delegateofIntPtr*IntPtr*IntPtr*IntPtr->bool
1313

1414
[<DllImport("kernel32.dll")>]
15-
extern IntPtrLoadLibrary(char[] lpFileName)
15+
extern IntPtrLoadLibraryEx(string lpFileName, IntPtr hReservedNull, uint32 dwFlags)
1616

1717
[<DllImport("kernel32.dll")>]
1818
extern bool EnumResourceNames(IntPtr hModule, int dwID, EnumResourceNamesCallback lpEnumFunc, IntPtr lParam)
@@ -31,6 +31,9 @@ module NativeMethods =
3131

3232
// ID of the manifest win32 resource type
3333
letRT_MANIFEST=24
34+
35+
// dwFlags to indicate that we are only loading binaries to read data, not to execute
36+
letLOAD_LIBRARY_AS_DATAFILE=2u
3437

3538
/// extracts the win32 manifest of the specified assembly
3639
letgetManifest(path:string)=
@@ -51,8 +54,12 @@ let getManifest (path:string) =
5154
true
5255
)
5356

54-
lethLib= NativeMethods.LoadLibrary(path.ToCharArray())
55-
NativeMethods.EnumResourceNames(hLib, NativeMethods.RT_MANIFEST, callback, IntPtr.Zero)|> ignore
57+
lethLib= NativeMethods.LoadLibraryEx(path, IntPtr.Zero, NativeMethods.LOAD_LIBRARY_AS_DATAFILE)
58+
if hLib= IntPtr.Zerothen
59+
printfn"Error loading library%s" path
60+
exit1
61+
else
62+
NativeMethods.EnumResourceNames(hLib, NativeMethods.RT_MANIFEST, callback, IntPtr.Zero)|> ignore
5663
!manifest
5764

5865
letexePath= System.Reflection.Assembly.GetExecutingAssembly().Location

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp