动态内存中加载DLL的问题
2008-02-28 11:59
281 查看
Private Sub RunMain(ByVal Dllpath As String, ByVal types As String)
Dim str(1) As String
Try
Dim asm As [Assembly]
'加载DLL
'这里要检测文件是否存在
Dim FS As New System.IO.FileStream(Dllpath, FileMode.Open) 'Application.StartupPath & "\jad.dll"
Dim ms As New MemoryStream
Dim data As Byte()
ReDim data(FS.Length)
FS.Read(data, 0, FS.Length)
FS.Close()
asm = System.Reflection.Assembly.Load(data)
Dim myType As System.Type = asm.GetType(types) '获得Class1的Type '"JcAppDll.ClassMain"
Dim obj As Object = Activator.CreateInstance(myType) '获得Class1的实例
' Application.Run(obj)
obj.Main()
Catch ex As Exception
Dim writer As IO.StreamWriter = New IO.StreamWriter(Application.StartupPath & "\UpdateMainLOG.log")
writer.WriteLine(Err.Number)
writer.WriteLine(Err.Description)
writer.Close()
End Try
Dim writerA As IO.StreamWriter = New IO.StreamWriter(Application.StartupPath & "\UpdateMainLOG.log")
writerA.WriteLine("Run Seccedd!")
writerA.Close()
End Sub
'///////////////////////////////////
以上代码加载是成功的
但无法在DLL调用HOOK一类的东西.
把DLL加载到内存中再Assembly.Load的这种方法使用不了HOOK,直接Load则可以.
不知有没朋友遇到过这种情况?
知道的帮帮忙
Dim str(1) As String
Try
Dim asm As [Assembly]
'加载DLL
'这里要检测文件是否存在
Dim FS As New System.IO.FileStream(Dllpath, FileMode.Open) 'Application.StartupPath & "\jad.dll"
Dim ms As New MemoryStream
Dim data As Byte()
ReDim data(FS.Length)
FS.Read(data, 0, FS.Length)
FS.Close()
asm = System.Reflection.Assembly.Load(data)
Dim myType As System.Type = asm.GetType(types) '获得Class1的Type '"JcAppDll.ClassMain"
Dim obj As Object = Activator.CreateInstance(myType) '获得Class1的实例
' Application.Run(obj)
obj.Main()
Catch ex As Exception
Dim writer As IO.StreamWriter = New IO.StreamWriter(Application.StartupPath & "\UpdateMainLOG.log")
writer.WriteLine(Err.Number)
writer.WriteLine(Err.Description)
writer.Close()
End Try
Dim writerA As IO.StreamWriter = New IO.StreamWriter(Application.StartupPath & "\UpdateMainLOG.log")
writerA.WriteLine("Run Seccedd!")
writerA.Close()
End Sub
'///////////////////////////////////
以上代码加载是成功的
但无法在DLL调用HOOK一类的东西.
把DLL加载到内存中再Assembly.Load的这种方法使用不了HOOK,直接Load则可以.
不知有没朋友遇到过这种情况?
知道的帮帮忙
相关文章推荐
- 【C/C++开发】C语言 DLL(动态链接库)中申请动态内存释放的问题
- 动态加载DLL的方法与注意的问题
- 动态加载DLL实现不同DLL的相同导出函数调用问题
- 关于动态加载dll问题
- 静态加载dll,动态加载dll及常见问题处理
- 解决JNA动态加载jar中dll问题
- 解决VC中动态加载DLL时,必须将DLL文件放在EXE文件路经和系统目录下的问题
- 关于内存加载DLL后修复重定位的问题
- 动态Dll加载若干问题
- java.lang.UnsatisfiedLinkError: Can not load XXX library ... JNA不能加载DLL动态库问题
- 内存问题 动态加载地址和运行时地址
- PHP intl扩展安装/ext/php_intl.dll文件无法动态加载的问题
- 从内存中动态加载C++ DLL
- 动态加载内存中DLL
- 在mfc的dll里再动态加载jvm.dll引发的问题--不要在构造函数里做复杂的init流程
- 关于内存加载DLL后修复重定位的问题
- DLL运行时动态加加载的问题
- 动态加载dll的导出函数的问题
- 完美解决SDWebImage加载多个图片内存崩溃的问题
- 完美解决SDWebImage加载多个图片内存崩溃的问题