static PcreWrapper()
        {
            DllName = IntPtr.Size == 4 ? "pcre.dll" : "pcre64.dll";

            _dllHandle = LoadLibrary(DllName);

            if (_dllHandle != IntPtr.Zero)
            {
                IntPtr ptr;
                ptr = GetVarFromDll(_dllHandle, "pcre_free");
                pcre_free = (FreeDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(FreeDelegate));
                ptr = GetVarFromDll(_dllHandle, "pcre_stack_free");
                pcre_stack_free = (FreeDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(FreeDelegate));
                ptr = GetVarFromDll(_dllHandle, "pcre_malloc");
                pcre_malloc = (AllocDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(AllocDelegate));
                ptr = GetVarFromDll(_dllHandle, "pcre_stack_malloc");
                pcre_stack_malloc = (AllocDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(AllocDelegate));
                iptr_pcre_callout = GetProcAddress(_dllHandle, "pcre_callout");

                pcre_compile = (pcre_compile_delegate)GetDelegateFromDll(_dllHandle, "pcre_compile", typeof(pcre_compile_delegate));
                pcre_compile2 = (pcre_compile2_delegate)GetDelegateFromDll(_dllHandle, "pcre_compile2", typeof(pcre_compile2_delegate));
                pcre_study = (pcre_study_delegate)GetDelegateFromDll(_dllHandle, "pcre_study", typeof(pcre_study_delegate));
                pcre_free_study = (pcre_free_study_delegate)GetDelegateFromDll(_dllHandle, "pcre_free_study", typeof(pcre_free_study_delegate));
                pcre_exec = (pcre_exec_delegate)GetDelegateFromDll(_dllHandle, "pcre_exec", typeof(pcre_exec_delegate));
                pcre_dfa_exec = (pcre_dfa_exec_delegate)GetDelegateFromDll(_dllHandle, "pcre_dfa_exec", typeof(pcre_dfa_exec_delegate));

                pcre_copy_named_substring = (pcre_copy_named_substring_delegate)GetDelegateFromDll(_dllHandle, "pcre_copy_named_substring", typeof(pcre_copy_named_substring_delegate));
                pcre_copy_substring = (pcre_copy_substring_delegate)GetDelegateFromDll(_dllHandle, "pcre_copy_substring", typeof(pcre_copy_substring_delegate));
                pcre_get_named_substring = (pcre_get_named_substring_delegate)GetDelegateFromDll(_dllHandle, "pcre_get_named_substring", typeof(pcre_get_named_substring_delegate));
                pcre_get_stringnumber = (pcre_get_stringnumber_delegate)GetDelegateFromDll(_dllHandle, "pcre_get_stringnumber", typeof(pcre_get_stringnumber_delegate));
                pcre_get_stringtable_entries = (pcre_get_stringtable_entries_delegate)GetDelegateFromDll(_dllHandle, "pcre_get_stringtable_entries", typeof(pcre_get_stringtable_entries_delegate));
                pcre_get_substring = (pcre_get_substring_delegate)GetDelegateFromDll(_dllHandle, "pcre_get_substring", typeof(pcre_get_substring_delegate));
                pcre_get_substring_list = (pcre_get_substring_list_delegate)GetDelegateFromDll(_dllHandle, "pcre_get_substring_list", typeof(pcre_get_substring_list_delegate));
                pcre_free_substring = (pcre_free_substring_delegate)GetDelegateFromDll(_dllHandle, "pcre_free_substring", typeof(pcre_free_substring_delegate));
                pcre_free_substring_list = (pcre_free_substring_list_delegate)GetDelegateFromDll(_dllHandle, "pcre_free_substring_list", typeof(pcre_free_substring_list_delegate));

                pcre_jit_exec = (pcre_jit_exec_delegate)GetDelegateFromDll(_dllHandle, "pcre_jit_exec", typeof(pcre_jit_exec_delegate));
                pcre_jit_stack_alloc = (pcre_jit_stack_alloc_delegate)GetDelegateFromDll(_dllHandle, "pcre_jit_stack_alloc", typeof(pcre_jit_stack_alloc_delegate));
                pcre_jit_stack_free = (pcre_jit_stack_free_delegate)GetDelegateFromDll(_dllHandle, "pcre_jit_stack_free", typeof(pcre_jit_stack_free_delegate));
                pcre_assign_jit_stack = (pcre_assign_jit_stack_delegate)GetDelegateFromDll(_dllHandle, "pcre_assign_jit_stack", typeof(pcre_assign_jit_stack_delegate));
                pcre_maketables = (pcre_maketables_delegate)GetDelegateFromDll(_dllHandle, "pcre_maketables", typeof(pcre_maketables_delegate));
                pcre_fullinfo = (pcre_fullinfo_delegate)GetDelegateFromDll(_dllHandle, "pcre_fullinfo", typeof(pcre_fullinfo_delegate));
                pcre_refcount = (pcre_refcount_delegate)GetDelegateFromDll(_dllHandle, "pcre_refcount", typeof(pcre_refcount_delegate));
                pcre_config = (pcre_config_delegate)GetDelegateFromDll(_dllHandle, "pcre_config", typeof(pcre_config_delegate));
                pcre_version = (pcre_version_delegate)GetDelegateFromDll(_dllHandle, "pcre_version", typeof(pcre_version_delegate));
                pcre_pattern_to_host_byte_order = (pcre_pattern_to_host_byte_order_delegate)GetDelegateFromDll(_dllHandle, "pcre_pattern_to_host_byte_order", typeof(pcre_pattern_to_host_byte_order_delegate));
            }
        }
Beispiel #2
0
        static PcreWrapper()
        {
            IntPtr dllHandle = LoadLibrary(DllName);

            if (dllHandle != IntPtr.Zero)
            {
                IntPtr ptr;
                ptr = GetVarFromDll(dllHandle, "pcre_free");
                pcre_free = (FreeDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(FreeDelegate));
                ptr = GetVarFromDll(dllHandle, "pcre_stack_free");
                pcre_stack_free = (FreeDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(FreeDelegate));
                ptr = GetVarFromDll(dllHandle, "pcre_malloc");
                pcre_malloc = (AllocDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(AllocDelegate));
                ptr = GetVarFromDll(dllHandle, "pcre_stack_malloc");
                pcre_stack_malloc = (AllocDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(AllocDelegate));
                iptr_pcre_callout = GetProcAddress(dllHandle, "pcre_callout");
            }
        }