SoS (请高手指点,分不够可以再加) (100分)

  • 主题发起人 主题发起人 wlmmlw
  • 开始时间 开始时间
W

wlmmlw

Unregistered / Unconfirmed
GUEST, unregistred user!
function ModuleFromAddress(lpAddress: Pointer): Pointer;
var
lpBuffer: TMemoryBasicInformation;
iSize: Integer;
begin
iSize := Sizeof(lpBuffer);
if (VirtualQuery(lpAddress, lpBuffer, iSize) <> 0) then begin ///报错
Result := Pointer(lpBuffer.AllocationBase);
end else begin
Result := nil;
end;
end;
//报错:
//Types of actual and formal var paramters must be idential
请教是什么原因 ?
 
参数类型与定义的不一致啊.
 
可这里明明是一致的啊,我都快想破头了!!! help
 
Type Range Format
Integer -2147483648..2147483647 signed 32-bit
Cardinal 0..4294967295 unsigned 32-bit
Longword 0..4294967295 unsigned 32-bit

function VirtualQuery(lpAddress: Pointer;
var lpBuffer: TMemoryBasicInformation; dwLength: DWORD): DWORD; stdcall;

我把这一段贴出来,你可能就知道是什么原因了.看看VirtualQuery的原形,其第三个参数是
Dword即Longword型,而你的定义是Integer型,有负数呀.你把iSize 的定义改为LongWord 试试.
 
DEN:
试过了,还是不行。请指教!!!!!
 
//唉,好久还Code过了,这点也忘了
//以下就可以了,我可怜的时间啊,又没了一个上午
//多谢各位高手

function ModuleFromAddress(lpAddress: Pointer): Pointer;
var
lpBuffer: Windows.TMemoryBasicInformation;
iSize: LongWord;
begin
iSize := Sizeof(lpBuffer);

if (Windows.VirtualQuery(lpAddress, lpBuffer, iSize) <> 0) then begin
Result := Pointer(lpBuffer.AllocationBase);
end else begin
Result := nil;
end;
end;
 
多人接受答案了。
 
后退
顶部