6
6
7
7
namespace AssetStudio . PInvoke
8
8
{
9
- public static partial class DllLoader
9
+ public static class DllLoader
10
10
{
11
11
12
12
public static void PreloadDll ( string dllName )
@@ -46,9 +46,9 @@ internal static void LoadDll(string dllDir, string dllName)
46
46
var directedDllPath = Path . Combine ( dllDir , dllFileName ) ;
47
47
48
48
// Specify SEARCH_DLL_LOAD_DIR to load dependent libraries located in the same platform-specific directory.
49
- var hLibrary = LoadLibraryEx ( directedDllPath , nint . Zero , LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR ) ;
49
+ var hLibrary = LoadLibraryEx ( directedDllPath , IntPtr . Zero , LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR ) ;
50
50
51
- if ( hLibrary == nint . Zero )
51
+ if ( hLibrary == IntPtr . Zero )
52
52
{
53
53
var errorCode = Marshal . GetLastWin32Error ( ) ;
54
54
var exception = new Win32Exception ( errorCode ) ;
@@ -59,15 +59,15 @@ internal static void LoadDll(string dllDir, string dllName)
59
59
60
60
// HMODULE LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
61
61
// HMODULE LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
62
- [ LibraryImport ( "kernel32.dll" , EntryPoint = "LoadLibraryExA" , SetLastError = true , StringMarshalling = StringMarshalling . Utf8 ) ]
63
- private static partial IntPtr LoadLibraryEx ( string lpLibFileName , IntPtr hFile , uint dwFlags ) ;
62
+ [ DllImport ( "kernel32.dll" , SetLastError = true ) ]
63
+ private static extern IntPtr LoadLibraryEx ( string lpLibFileName , IntPtr hFile , uint dwFlags ) ;
64
64
65
65
private const uint LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x1000 ;
66
66
private const uint LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x100 ;
67
67
68
68
}
69
69
70
- private static partial class Posix
70
+ private static class Posix
71
71
{
72
72
73
73
internal static void LoadDll ( string dllDir , string dllName )
@@ -93,7 +93,7 @@ internal static void LoadDll(string dllDir, string dllName)
93
93
const int ldFlags = RTLD_NOW | RTLD_GLOBAL ;
94
94
var hLibrary = DlOpen ( directedDllPath , ldFlags ) ;
95
95
96
- if ( hLibrary == nint . Zero )
96
+ if ( hLibrary == IntPtr . Zero )
97
97
{
98
98
var pErrStr = DlError ( ) ;
99
99
// `PtrToStringAnsi` always uses the specific constructor of `String` (see dotnet/core#2325),
@@ -107,12 +107,12 @@ internal static void LoadDll(string dllDir, string dllName)
107
107
108
108
// OSX and most Linux OS use LP64 so `int` is still 32-bit even on 64-bit platforms.
109
109
// void *dlopen(const char *filename, int flag);
110
- [ LibraryImport ( "libdl" , EntryPoint = "dlopen" , StringMarshalling = StringMarshalling . Utf8 ) ]
111
- private static partial nint DlOpen ( string fileName , int flags ) ;
110
+ [ DllImport ( "libdl" , EntryPoint = "dlopen" ) ]
111
+ private static extern IntPtr DlOpen ( [ MarshalAs ( UnmanagedType . LPStr ) ] string fileName , int flags ) ;
112
112
113
113
// char *dlerror(void);
114
- [ LibraryImport ( "libdl" , EntryPoint = "dlerror" ) ]
115
- private static partial nint DlError ( ) ;
114
+ [ DllImport ( "libdl" , EntryPoint = "dlerror" ) ]
115
+ private static extern IntPtr DlError ( ) ;
116
116
117
117
private const int RTLD_LAZY = 0x1 ;
118
118
private const int RTLD_NOW = 0x2 ;
0 commit comments