|
- function GetAddressFromSymbol(phd:Thandle;s:string):ptruint;
- var
- pi:PSYMBOL_INFO;
- sn:array[0..MAX_SYM_NAME-1] of char;
- begin
- sn:=s;
- if not SymInitialize(phd,nil,true) then Exit($00000000);
- SymSetOptions(SymGetOptions or SYMOPT_CASE_INSENSITIVE);
- getmem(pi, (sizeof(SYMBOL_INFO)+MAX_SYM_NAME*sizeof(char)+sizeof(ULONG64)-1)
- div sizeof(ULONG64) );
- pi^.SizeOfStruct:=sizeof(SYMBOL_INFO);
- pi^.MaxNameLen:= MAX_SYM_NAME;
- if SymFromName(phd,sn,pi)then
- begin
- result:=pi^.Address;
- end else
- begin
- result:=$00000000;
- end;
- MessageBox(0,pchar(SysErrorMessage(GetLastError)),'Last Error',MB_OK);
- freemem(pi);
- SymCleanup(phd);
- end;
复制代码 GetLastError总是说我参数错误(‘The parameter is incorrect!’)。实在不知哪里错了。 |
|