复制内存问题请帮忙 [英] Copy Memory Problem Please Help

查看:72
本文介绍了复制内存问题请帮忙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图找出vb6中的一段有趣的代码,以便可以将其转换为vb.net.据我了解,"Any"关键字是指代码中使用的API使用的数据类型,但是我无法弄清最后一个数据类型,因为它会出错,但会出现"Mismatched type"异常.

如果我将pDst any替换为Long并将pSrc替换为Byte并将lpString替换为String,则程序将正确加载

I have run into a interesting bit of code in vb6 that I have been trying to figure out so that I can convert it to vb.net. To what i understand the "Any" keyword refers to the data type used by the API that is used in the code but I cannot figure out the last data type as it errors with the exception "Mismatched type".

The program will load correctly if I replace pDst any with Long and pSrc as Byte and lpString with String the program will load

Declare Sub ArrayDescriptor Lib "kernel32" Alias "RtlMoveMemory"(pDst As Any, pSrc() As Any, ByVal ByteLen As Long)
Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (lpString As Any) As Long
'Finding all references for ArrayDescriptor leads me to:


Dim ARD As Integer
        ArrayDescriptor(ARD, FDATA, 4)
        If ARD = 0 Then MsgBox("File isn't loaded yet!", MsgBoxStyle.Critical, "Error") : Exit Sub

        DISASM.BaseAddress = VIRTUALBASEADR + VIRTUALADR - POINTERTORAW

        Dim Forward As Byte 'Next Instruction!
        Dim CNT As Integer
        CNT = POINTERTORAW
        Dim u As Integer
        Dim DATAS() As String
        ReDim DATAS(SIZEOFRAW)



        Dim TC2 As Integer
        Dim TC As Integer

        Label1.Text = "Disassemble..."
        System.Windows.Forms.Application.DoEvents()
        TC = GetTickCount
        'DISASSEMBLE!!!
        Do
            DATAS(u) = DISASM.DisAssemble(FDATA, CNT, Forward, 1, 0) & vbCrLf
            u = u + 1
            CNT = CNT + Forward
        Loop While SIZEOFRAW + POINTERTORAW > CNT

        TC2 = GetTickCount



        Label1.Text = "Disassembled for " & TC2 - TC & " msec"
        System.Windows.Forms.Application.DoEvents()

        ReDim Preserve DATAS(u - 1)


        'UPGRADE_WARNING: TextRTF was upgraded to Text and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
        rt1.Text = Join(DATAS, "")
        Erase DATAS


这部分代码似乎在试图找出替换任何"的数据类型时给我带来了问题.当我将pSrc更改为Byte并将pDst保留为Any时,程序加载时没有任何问题,但它是我需要的最后一个数据类型,这是我的问题所在.


this part of the code is what seems to be giving me problems when trying to figure out what data type to replace "Any" with. When I change pSrc to Byte and leave pDst to Any the program loads without a hitch but its that last data type that i need and is the problem to my question.

Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)


有谁能告诉我在数组描述符子和子copyMemory子中使用什么数据类型代替"Any"?<

预先感谢您,冗长的问题我深表歉意.


''Is anyone able to tell me what data types are used in place of "Any" for the array descriptor sub and for sub copyMemory?<

Thank you in advance and I apologize for the lengthy question!

推荐答案

您最好的朋友是pinvoke.net.将其添加到您的收藏夹!

http://www.pinvoke.net/default.aspx/kernel32.MoveMemory [ ^ ]

艾伦.
我看到你已经发了两次帖,两次都得到了相同的答案.
Your best friend for this kind of information is pinvoke.net. Add it to your favourites!

http://www.pinvoke.net/default.aspx/kernel32.MoveMemory[^]

Alan.
I see that you''ve double posted and got the same answer both times.


这篇关于复制内存问题请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆