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 


get all user-defined comments

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

Joined: 17 Mar 2016
Posts: 42

PostPosted: Mon Aug 09, 2021 9:17 am    Post subject: get all user-defined comments Reply with quote

is there a function that gets all user-defined comments?
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Mon Aug 09, 2021 10:51 am    Post subject: Reply with quote

Ctrl + Spacebar in the Lua Engine window.
Back to top
View user's profile Send private message
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 42

PostPosted: Mon Aug 09, 2021 1:37 pm    Post subject: Reply with quote

LeFiXER wrote:
Ctrl + Spacebar in the Lua Engine window.

that just shows all the functions and variables/objects. I am asking if there is a way to get all the comments that are shown in the disassembler(but only the comments that the user typed, either manually[CTRL+ENTER] or by using setComment())
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Mon Aug 09, 2021 2:12 pm    Post subject: Reply with quote

It wasn't entirely clear what you were asking but that makes more sense. Unfortunately, I can't say if it's possible or not because it is beyond the scope of my knowledge, sorry.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Mon Aug 09, 2021 3:03 pm    Post subject: Reply with quote

No easy way of doing that right now with Lua.

If you're fine with parsing xml, the disassembler comments are saved in the cheat table file.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Mon Aug 09, 2021 3:48 pm    Post subject: Reply with quote

Definitely not an ideal situation to do it but these are available:

- getComment(address)
- getHeader(address)

You can walk every available address in the process and check for a comment. (This will be incredibly slow though.)

The Dissassembler class also exposes a table of information per data block that you can walk to pull the comments from, see here:

Code:

Disassembler Class (Inheritance: Object)



createDisassembler() - Creates a disassembler object that can be used to disassemble an instruction and at the same time get more data
getDefaultDisassembler() - Returns the default disassembler object used by a lot of ce's disassembler routines
getVisibleDisassembler() - Returns the disassembler used by the disassemblerview. Special codes are: {H}=Hex value {R}=Register {S}=Symbol {N}=Nothing special {C######}=RGB color , {B######}=Background RGB color were ###### is 0xBBGGRR

registerGlobalDisassembleOverride(function(sender: Disassembler, address: integer, LastDisassembleData: Table): opcode, description): Same as Disassembler.OnDisassembleOverride, but does it for all disassemblers, including newly created ones.  Tip: Check the sender to see if you should use syntax highlighting codes or not
  This function returns an ID you can pass on to unregisterGlobalDisassembleOverride()  6.4+

unregisterGlobalDisassembleOverride(id)

properties
  LastDisassembleData : Table
  OnDisassembleOverride: function(sender: Disassembler, address: integer, LastDisassembleData: Table): opcode, description
  OnPostDisassemble: function(sender: Disassembler, address: integer, LastDisassembleData: Table, result: string, description: string): result, description
  syntaxhighlighting: boolean : This property is set if the syntax highlighting codes are accepted or not

Methods
  disassemble(address): Disassembles the given instruction and returns the opcode. It also fills in a LastDisassembleData record
  decodeLastParametersToString() : Returns the unedited "Comments" information. Does not display userdefined comments
  getLastDisassembleData() : Returns the LastDisassembleData table.
    The table is build-up as follow:
      address: integer - The address that was disassembled
      opcode: string - The opcode without parameters
      parameters: string - The parameters
      description: string - The description of this opcode
      commentsoverride: string - If set, this will be the comments/LastParamatersToString result
      bytes: table - A table containing the bytes this instruction consists of (1.. )

      modrmValueType: DisAssemblerValueType  - Defines the type of the modrmValue field (dvtNone=0, dvtAddress=1, dvtValue=2)
      modrmValue: Integer - The value that the modrm specified. modrmValueType defines what kind of value

      parameterValueType: DisAssemblerValueType
      parameterValue: Integer - The value that the parameter part specified

      isJump: boolean - Set to true if the disassembled instruction can change the EIP/RIP (not ret)
      isCall: boolean - Set to true if it's a Call
      isRet: boolean - Set to true if it's a Ret
      isConditionalJump: boolean - Set to true if it's a conditional jump


For the time being, the XML parsing method ParkourPenguin recommended would be the fastest.

This is something you could request Dark Byte add a Lua call for though to return a table of addresses/comments in the future.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 42

PostPosted: Tue Aug 10, 2021 6:39 am    Post subject: Reply with quote

Ok, thanks. I recompiled the CE from source and added the function myself Very Happy
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Tue Aug 10, 2021 6:46 am    Post subject: Reply with quote

Care to share? Smile
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Tue Aug 10, 2021 7:16 am    Post subject: Reply with quote

Code:

function getDisassemblerComments()
  local results={}

  local ss=createStringStream()

  saveTable(ss)

  local xp=require("xmlSimple").newParser()
  local parsed=xp:ParseXmlText(ss.DataString)
  if parsed and parsed.CheatTable.DisassemblerComments then
    for i=1,parsed.CheatTable.DisassemblerComments:numChildren() do
      local ce=parsed.CheatTable.DisassemblerComments:children()[i]
      local e={}
      e.Address=getAddressSafe(ce.Address:value())

      if ce.Comment then
        e.Comment=ce.Comment:value()
      end

      if ce.Header then
        e.Header=ce.Header:value()
      end

      table.insert(results,e)
    end
  else
    results=nil
  end

  ss.destroy()

  return results
end


this will return an indexed array containing Address and Comment and/or Header fields

_________________
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
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 42

PostPosted: Thu Aug 12, 2021 4:18 am    Post subject: Reply with quote

LeFiXER wrote:
Care to share? Smile

https://github.com/cheat-engine/cheat-engine/pull/1738
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Thu Aug 12, 2021 7:21 am    Post subject: Reply with quote

Thanks! Have to love communal projects.
Back to top
View user's profile Send private message
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