 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Alice0725 Expert Cheater
Reputation: 11
Joined: 24 Jul 2012 Posts: 145
|
Posted: Sun Dec 09, 2012 7:39 am Post subject: Need help about a very weird problem? |
|
|
This is about the WINAPI 'SymFromName'.
This is MSDN'S C++ CODE:
| Code: | TCHAR szSymbolName[MAX_SYM_NAME];
ULONG64 buffer[(sizeof(SYMBOL_INFO) +
MAX_SYM_NAME * sizeof(TCHAR) +
sizeof(ULONG64) - 1) /
sizeof(ULONG64)];
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
_tcscpy_s(szSymbolName, MAX_SYM_NAME, TEXT("WinMain"));
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
pSymbol->MaxNameLen = MAX_SYM_NAME;
if (SymFromName(hProcess, szSymbolName, pSymbol))
{
// SymFromName returned success
}
else
{
// SymFromName failed
DWORD error = GetLastError();
_tprintf(TEXT("SymFromName returned error : %d\n"), error);
}
|
Here is my code(object pascal): | Code: | function GetAddressFromSymbol(phd:Thandle;s:string):ptruint;
const
BSIZE = (sizeof(SYMBOL_INFO)+MAX_SYM_NAME*SizeOf(TCHAR)+SizeOf(ULONG64)-1) div SizeOf(ULONG64);
var
buffer:array[0..BSIZE-1]of ULONG64;
sn:array[0..MAX_SYM_NAME-1] of Char;
pi:PSYMBOL_INFO;
begin
if not SymInitialize(phd,nil,true) then
begin
MessageBox(0,pchar(SysErrorMessage(GetLastError)),'SymInit Error',MB_OK);
Exit($00000000);
end;
SymSetOptions(SymGetOptions or SYMOPT_CASE_INSENSITIVE);
ZeroMemory(@sn,SizeOf(sn));
ZeroMemory(@buffer,SizeOf(buffer));
sn := s;
pi := PSYMBOL_INFO(@buffer);
pi^.SizeOfStruct := SizeOf(SYMBOL_INFO);
pi^.MaxNameLen := MAX_SYM_NAME;
if SymFromName(phd,sn,pi) then
begin
result:=pi^.Address;
MessageBox(0,pchar(SysErrorMessage(GetLastError)),'Kidding Me!',MB_OK);
end else
begin
result:=$00000000;
MessageBox(0,pchar(SysErrorMessage(GetLastError)),'Last Error!',MB_OK);
end;
SymCleanup(phd);
end; |
The weird thing is that return value of SymFromName is true, but I got error message "The parameter is incorrect!" as the pic showing.At the same time, pi^.address value is $0000000
| Description: |
|
| Filesize: |
59.01 KB |
| Viewed: |
3753 Time(s) |

|
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25832 Location: The netherlands
|
Posted: Sun Dec 09, 2012 7:22 pm Post subject: |
|
|
print out the size of SYMBOL_INFO in both pascal and C , make sure they are the same (for the same architecure)
I often find that the pascal headers aren't always 100% correct due to alignment issues which is why I copy the structures to my own units
http://code.google.com/p/cheat-engine/source/browse/Cheat+Engine+6/symbolhandler.pas?r=818 still uses SymFromName
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Alice0725 Expert Cheater
Reputation: 11
Joined: 24 Jul 2012 Posts: 145
|
Posted: Sun Dec 09, 2012 11:00 pm Post subject: |
|
|
| Dark Byte wrote: | print out the size of SYMBOL_INFO in both pascal and C , make sure they are the same (for the same architecure)
I often find that the pascal headers aren't always 100% correct due to alignment issues which is why I copy the structures to my own units
http://code.google.com/p/cheat-engine/source/browse/Cheat+Engine+6/symbolhandler.pas?r=818 still uses SymFromName |
You are right , Dark Byte! The size is different, one is 84, the other one is 88. Thanks! Now, CETack 1.0 finished!
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|