Read A String At A Given Address

zhaozj2021-02-16  54

Date: 6/17 / 2000versions: VB4 / 32 VB5 VB6 level: IntermediateAuthor:

The vb2themax team

Private Declare Sub CopyMemory Lib "kernel32" Alias ​​"RTLMoveMemory" (DEST AS _

Any, Source as any, byval bytes as long

Private Declare Function Lstrlena Lib "Kernel32" (Byval LPSTRING As Long) AS _

Long

Private Declare Function Lstrlenw LIB "Kernel32" (Byval LPSTRING As Long) AS _

Long

'Retrieve A String At a Given Address

'if longth <0 the string is considered to be null-terminated

'and the function determines its length

Function stringfromaddr (Byval address as long, _

Optional byval isunicode as boolean) AS STRING

'determine the length, if neseary

IF length <0 THEN

IF isunicode thein

Length = lstrlenw (address)

Else

Length = lstrlena (address)

END IF

END IF

'Copy THE Characters

StringFromAddr = Space $ (Length)

IF isunicode thein

CopyMemory Byval Strptr (StringFromaddr), Byval Address, Length * 2

Else

CopyMemory Byval StringFromaddr, ByVal Address, Length

END IF

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-26993.html

New Post(0)