Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Request]LUA get Game's version

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
peter4d5
Cheater
Reputation: 0

Joined: 21 Dec 2010
Posts: 37

PostPosted: Tue Aug 16, 2016 9:47 pm    Post subject: [Request]LUA get Game's version Reply with quote

I use aamaker.lua and want LUA automatic get Game's version when I create ct script.

How can I do that?

_________________
my name is peter4d5
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Wed Aug 17, 2016 5:49 am    Post subject: Re: [Request]LUA get Game's version Reply with quote

peter4d5 wrote:
I use aamaker.lua and want LUA automatic get Game's version when I create ct script.

How can I do that?


The version number is probably displayed in the main menu, the about screen or somewhere in the game, you could try to find it as a string (maybe a float), find out what accesses its address to find where it reads the version to display it, then you can read it from there, if the game gets an update, the function that displays the version number will probably stay the same, so AOB Scanning might be a solution.

OR:

If the version number is displayed on the website of the game authors, you could use the new Internet Lua features in CE (or Lua socket) to read data from the web page where the version number is displayed, then extract that part using the Lua string processing features, this solution will always require an internet connection, also, it might not always work because the authors website might be down at certain times (for maintenance for example).
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Wed Aug 17, 2016 6:05 am    Post subject: Reply with quote

one easy way to distinguish versions:
Code:

md5memory(process,8192)


if it's not the same result as the one you worked on, the version is different


hint: You 'could' write a database with MD5's of games, and always have an matching cheat table for whatever game you attach (excluding emulators and browsers obviously)

_________________
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
View user's profile Send private message MSN Messenger
peter4d5
Cheater
Reputation: 0

Joined: 21 Dec 2010
Posts: 37

PostPosted: Sat Aug 20, 2016 11:54 pm    Post subject: Reply with quote

Sorry, It's my fault.

What I want is file version that you can find by right click at Exe and see 'property-->detail-->file version'
and sometime it's not same as in-game version(no problem).I just want to add reference to ct script.

Result that I want when I create ct script is
Quote:

{ Game : BatmanAK.exe
File version : //------------------ here
Date : 08-18-16
Author : peter4d5

This script does blah blah blah

Make by aamaker Lua plugin Wink
}


Here is Delphi's example and I test it ok.
(I think LUA should have short and clean method more than delphi)


File version of Batman - Arkham Knight
Quote:


---------------------------
Fileversion
---------------------------
1.0.4.5
---------------------------
OK
---------------------------


Delphi source

Code:

var
  Form1: TForm1;
type
  TBytes = array of byte;

implementation

{$R *.dfm}

function GetAppVersionStr: string;
var
  Exe: string;
  Size, Handle: DWORD;
  Buffer: TBytes;
  FixedPtr: PVSFixedFileInfo;
begin
  //Exe := ParamStr(0);
  Exe := 'C:\Batman - Arkham Knight\Binaries\Win64\BatmanAK.exe';
  Size := GetFileVersionInfoSize(PChar(Exe), Handle);
  if Size = 0 then
    RaiseLastOSError;
  SetLength(Buffer, Size);

  if not GetFileVersionInfo(PChar(Exe), Handle, Size, Buffer) then
    RaiseLastOSError;
  if not VerQueryValue(Buffer, '\', Pointer(FixedPtr), Size) then
    RaiseLastOSError;
  Result := Format('%d.%d.%d.%d',
    [LongRec(FixedPtr.dwFileVersionMS).Hi,  //major
     LongRec(FixedPtr.dwFileVersionMS).Lo,  //minor
     LongRec(FixedPtr.dwFileVersionLS).Hi,  //release
     LongRec(FixedPtr.dwFileVersionLS).Lo]) //build
end;

procedure TForm1.Button1Click(Sender: TObject);
begin 
   ShowMessage(GetAppVersionStr);
end;

end.



Problem is that it read from Exe not process, you can find exe's path from process
but not me(with LUA), now I can little modify lua but far away from coding.

Anyone please transfer to lua,I will be appreciate and it will be useful for everyone that use ct script.

_________________
my name is peter4d5
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Sun Aug 21, 2016 12:09 am    Post subject: This post has 1 review(s) Reply with quote

enumModules()[1].PathToFile will return the path to the currently opened process

but there is currently no easy way to get the file version out of it

edit: next version has getFileVersion which returns the version info from a file

_________________
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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites