|
某staf.dll中有如下函数
int Submit(char **resultPtr, unsigned int *resultLength);
次函数会通过参数resultPtr返回内存中一字符串的首地址,字符串长度为resultLength
kernel32.dll中有如下函数
void RtlMoveMemory(
PVOID Destination,
const VOID* Source,
SIZE_T Length
);
此函数为windows sdk提供的函数,从首地址source移动Length字节的内容到首地址Destination,具体可参看msdn文档
在QTP中想调用第1个函数得到字符串地址和长度,再通过第2个函数复制到QTP中申明的变量中,脚本如下:
1 Extern.Declare micLong, "Submit", "STAF.dll", "Submit", micVPtr+micByRef ,micByRef+micLong
2 Extern.Declare micVoid, "MoveMemory", "kernel32.dll", "RtlMoveMemory", micVPtr, micVPtr, micLong
3
4 resultPtr = 0
5 resultLen = 0
6 ret = Extern.Submit (resultPtr, resultLen)
7 msgbox(resultLen) '4
8 msg = space(resultLen)
9 Extern.MoveMemory msg, resultPtr, resultLen
10 msgbox(msg)
结果执行到第9行报"无效的过程调用或参数: 'Extern.CopyMemory'"
如果将第2行申明改为
2 Extern.Declare micVoid, "MoveMemory", "kernel32.dll", "RtlMoveMemory", micString+micByRef, micVPtr, micLong
执行不抱错,但是第21行弹出的对话框中显示为空字符串, 实际返回的resultLen大于0
请问如何可以得到字符串的内容? |
|