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 


Script Execution not Retrieving File Path
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
VSCO.egirl
How do I cheat?
Reputation: 0

Joined: 28 Oct 2023
Posts: 7

PostPosted: Sat Oct 28, 2023 5:43 pm    Post subject: Script Execution not Retrieving File Path Reply with quote

I am having a bit of trouble executing a script when attached to a specific game. I can attach CE normally to the process and scan normally, however when I try to execute a script that results in an error, the process at the top of CE changes from '000043C0 - GAME NAME' to ''000043C0 - ???.' The block that results in the error is below:
Code:

local filePath = 'D:\\Program Files (x86)\\Steam\\steamapps\\common\\ELDEN RING\\Game\\eldenring.exe'
local baseAddress = getAddressSafe(filePath)
local processID = getOpenedProcessID(filePath)
if FilePath then
    local vernum=getFileVersion(FilePath)
    local tablever=0x2000000000000
    if not vernum then vernum=0 end
    end
else
    messageDialog("wrong process",0)
end


I believe the script is not properly finding the game path, and don't know what exactly is wrong that could be causing this error. Any help is appreciated.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sat Oct 28, 2023 5:56 pm    Post subject: Reply with quote

getAddressSafe is used to retrieve the address of a registered symbol/value.
Code:

local filePath = 'D:\\Program Files (x86)\\Steam\\steamapps\\common\\ELDEN RING\\Game\\eldenring.exe'
if filePath then -- Variable names are case-sensitive.
    local processID = getOpenedProcessID() -- No parameters required although the process ID isn't used in the script.
    openProcess(filePath) -- Open the process
    local vernum = getFileVersion(filePath)
    local tablever = 0x2000000000000
    if not vernum then vernum=0 end -- Not really sure what you want to achieve here.
    end
else
    error(messageDialog('wrong process',0))
end
Back to top
View user's profile Send private message
Famine
Cheater
Reputation: 0

Joined: 23 Oct 2023
Posts: 27
Location: A club where people wee on each other.

PostPosted: Sat Oct 28, 2023 8:36 pm    Post subject: Reply with quote

You're declaring the filePath variable, but in the subsequent lines, you're using FilePath (with a capital 'F'). Variable names in Lua are case-sensitive, so make sure to use consistent capitalization.
Indentation:

There seems to be an extra end statement without a corresponding if statement, which can lead to a syntax error. Make sure to maintain proper indentation and structure in your code.

Here's an improved version of your script with these issues addressed:
Code:
local filePath = 'D:\\Program Files (x86)\\Steam\\steamapps\\common\\ELDEN RING\\Game\\eldenring.exe'
if filePath then
    local baseAddress = getAddressSafe(filePath)
    local processID = getOpenedProcessID(filePath)
   
    if not baseAddress or not processID then
        messageDialog("Failed to obtain base address or process ID", 0)
    else
        local vernum = getFileVersion(filePath)
        local tablever = 0x2000000000000
        if not vernum then
            vernum = 0
        end
    end
else
    messageDialog("Invalid file path", 0)
end


Make sure to double-check the file path, the validity of the process, and the presence of the file before executing the script. Additionally, ensure that the script is attached to the game process correctly.
Back to top
View user's profile Send private message
VSCO.egirl
How do I cheat?
Reputation: 0

Joined: 28 Oct 2023
Posts: 7

PostPosted: Sat Oct 28, 2023 8:53 pm    Post subject: Reply with quote

Famine wrote:
You're declaring the filePath variable, but in the subsequent lines, you're using FilePath (with a capital 'F'). Variable names in Lua are case-sensitive, so make sure to use consistent capitalization.
Indentation:

There seems to be an extra end statement without a corresponding if statement, which can lead to a syntax error. Make sure to maintain proper indentation and structure in your code.

Here's an improved version of your script with these issues addressed:
Code:
local filePath = 'D:\\Program Files (x86)\\Steam\\steamapps\\common\\ELDEN RING\\Game\\eldenring.exe'
if filePath then
    local baseAddress = getAddressSafe(filePath)
    local processID = getOpenedProcessID(filePath)
   
    if not baseAddress or not processID then
        messageDialog("Failed to obtain base address or process ID", 0)
    else
        local vernum = getFileVersion(filePath)
        local tablever = 0x2000000000000
        if not vernum then
            vernum = 0
        end
    end
else
    messageDialog("Invalid file path", 0)
end


Make sure to double-check the file path, the validity of the process, and the presence of the file before executing the script. Additionally, ensure that the script is attached to the game process correctly.


Thank you for your response. When implementing your code, I am getting the error "Failed to obtain base address or process ID," which I'm assuming means the path is correct. The original issue still remains that when I try to execute the script, the CE current process becomes "???" Additionally, I get an "attempt to perform arithmetic on a nil value much later down in the script" which I'm assuming is a result of the script not finding the Base Address or ID of the process. What could be interfering with obtaining Addr and pID if the table can scan the table manually just fine?
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sat Oct 28, 2023 8:57 pm    Post subject: Reply with quote

Famine wrote:
You're declaring the filePath variable, but in the subsequent lines, you're using FilePath (with a capital 'F'). Variable names in Lua are case-sensitive, so make sure to use consistent capitalization.
Indentation:

There seems to be an extra end statement without a corresponding if statement, which can lead to a syntax error. Make sure to maintain proper indentation and structure in your code.

Here's an improved version of your script with these issues addressed:
Code:
local filePath = 'D:\\Program Files (x86)\\Steam\\steamapps\\common\\ELDEN RING\\Game\\eldenring.exe'
if filePath then
    local baseAddress = getAddressSafe(filePath)
    local processID = getOpenedProcessID(filePath)
   
    if not baseAddress or not processID then
        messageDialog("Failed to obtain base address or process ID", 0)
    else
        local vernum = getFileVersion(filePath)
        local tablever = 0x2000000000000
        if not vernum then
            vernum = 0
        end
    end
else
    messageDialog("Invalid file path", 0)
end


Make sure to double-check the file path, the validity of the process, and the presence of the file before executing the script. Additionally, ensure that the script is attached to the game process correctly.


You probably should read the replies to make sure someone else hasn't already mentioned what you are about to say. It gives the impression that you are ignorant of other members in this community.

Code:
local filePath = 'D:\\Program Files (x86)\\Steam\\steamapps\\common\\ELDEN RING\\Game\\eldenring.exe'
if filePath then
    local baseAddress = getAddressSafe(filePath)
    local processID = getOpenedProcessID(filePath)
   
    if not baseAddress or not processID then
        messageDialog("Failed to obtain base address or process ID", 0)
    else
        local vernum = getFileVersion(filePath)
        local tablever = 0x2000000000000
        if not vernum then
            vernum = 0
        end
    end
else
    messageDialog("Invalid file path", 0)
end


Will always fail, because getAddressSafe requires a module, or the name of a registered symbol. Secondly, getOpenedProcessID does not take any parameters, it simply returns the process ID of the currently attached process.
Back to top
View user's profile Send private message
VSCO.egirl
How do I cheat?
Reputation: 0

Joined: 28 Oct 2023
Posts: 7

PostPosted: Sat Oct 28, 2023 9:03 pm    Post subject: Reply with quote

LeFiXER wrote:
Famine wrote:
You're declaring the filePath variable, but in the subsequent lines, you're using FilePath (with a capital 'F'). Variable names in Lua are case-sensitive, so make sure to use consistent capitalization.
Indentation:

There seems to be an extra end statement without a corresponding if statement, which can lead to a syntax error. Make sure to maintain proper indentation and structure in your code.

Here's an improved version of your script with these issues addressed:
Code:
local filePath = 'D:\\Program Files (x86)\\Steam\\steamapps\\common\\ELDEN RING\\Game\\eldenring.exe'
if filePath then
    local baseAddress = getAddressSafe(filePath)
    local processID = getOpenedProcessID(filePath)
   
    if not baseAddress or not processID then
        messageDialog("Failed to obtain base address or process ID", 0)
    else
        local vernum = getFileVersion(filePath)
        local tablever = 0x2000000000000
        if not vernum then
            vernum = 0
        end
    end
else
    messageDialog("Invalid file path", 0)
end


Make sure to double-check the file path, the validity of the process, and the presence of the file before executing the script. Additionally, ensure that the script is attached to the game process correctly.


You probably should read the replies to make sure someone else hasn't already mentioned what you are about to say. It gives the impression that you are ignorant of other members in this community.

Code:
local filePath = 'D:\\Program Files (x86)\\Steam\\steamapps\\common\\ELDEN RING\\Game\\eldenring.exe'
if filePath then
    local baseAddress = getAddressSafe(filePath)
    local processID = getOpenedProcessID(filePath)
   
    if not baseAddress or not processID then
        messageDialog("Failed to obtain base address or process ID", 0)
    else
        local vernum = getFileVersion(filePath)
        local tablever = 0x2000000000000
        if not vernum then
            vernum = 0
        end
    end
else
    messageDialog("Invalid file path", 0)
end


Will always fail, because getAddressSafe requires a module, or the name of a registered symbol. Secondly, getOpenedProcessID does not take any parameters, it simply returns the process ID of the currently attached process.


I'm newer to CE; wouldn't getAddressSafe be able to obtain the module from the .exe?

Also, how would the following filePath line function?
Code:
local filePath=GetEXEFilePath(getAddressSafe("eldenring.exe"),getOpenedProcessID())


If need be, I can post the entirety of the script I am working with.


Last edited by VSCO.egirl on Sat Oct 28, 2023 9:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sat Oct 28, 2023 9:27 pm    Post subject: Reply with quote

VSCO.egirl wrote:

I'm newer to CE; wouldn't getAddressSafe be able to obtain the module from the .exe?

Also, how would the following filePath line function?
Code:
local filePath=GetEXEFilePath(getAddressSafe("eldenring.exe"),getOpenedProcessID())


If need be, I can post the entirety of the script I am working with.


We all started somewhere Smile. To get the base address of the attached process you can do this:
Code:

local gameName = 'eldenring.exe'                                                                           -- Declare game name
openProcess(gameName)                                                                                      -- Pass our game name to the openProcess function
local processID = getOpenedProcessID()                                                                     -- Store the ID of the process in our variable processID

if processID then                                                                                          -- Check there is a valid process ID
   local processInfo = enumModules()[1]                                                                    -- enumModules() is a function which returns a Lua table about all the modules Cheat Engine has access to
   local baseAddress = processInfo.Address                                                                 -- Access the 'Address' key of the table returned and store it in baseAddress
   printf('The base address for %s is 0x%X. And the process's ID is %d', gameName, baseAddress, processID) -- Print the info to the Lua Engine output section
end
Back to top
View user's profile Send private message
VSCO.egirl
How do I cheat?
Reputation: 0

Joined: 28 Oct 2023
Posts: 7

PostPosted: Sat Oct 28, 2023 9:43 pm    Post subject: Reply with quote

LeFiXER wrote:

We all started somewhere Smile. To get the base address of the attached process you can do this:
Code:

local gameName = 'eldenring.exe'                                                                           -- Declare game name
openProcess(gameName)                                                                                      -- Pass our game name to the openProcess function
local processID = getOpenedProcessID()                                                                     -- Store the ID of the process in our variable processID

if processID then                                                                                          -- Check there is a valid process ID
   local processInfo = enumModules()[1]                                                                    -- enumModules() is a function which returns a Lua table about all the modules Cheat Engine has access to
   local baseAddress = processInfo.Address                                                                 -- Access the 'Address' key of the table returned and store it in baseAddress
   printf('The base address for %s is 0x%X. And the process's ID is %d', gameName, baseAddress, processID) -- Print the info to the Lua Engine output section
end


Upon running that script, I get the output:
Code:

Error:[string "local gameName = 'eldenring.exe'             ..."]:7: attempt to index a nil value (local 'processInfo')
stack traceback:
   [string "local gameName = 'eldenring.exe'             ..."]:7: in main chunk


I've been getting nil values all throughout my original script as well, which I'm assuming is all stemming from not being able to access the base module.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sat Oct 28, 2023 9:46 pm    Post subject: Reply with quote

VSCO.egirl wrote:

Upon running that script, I get the output:
Code:

Error:[string "local gameName = 'eldenring.exe'             ..."]:7: attempt to index a nil value (local 'processInfo')
stack traceback:
   [string "local gameName = 'eldenring.exe'             ..."]:7: in main chunk


I've been getting nil values all throughout my original script as well, which I'm assuming is all stemming from not being able to access the base module.


In which case the game isn't open so that Cheat Engine can attach to the process. The error here is that the return data from the function enumModules()[1] is nil, it can't retrieve that information because there isn't a process attached.
Back to top
View user's profile Send private message
VSCO.egirl
How do I cheat?
Reputation: 0

Joined: 28 Oct 2023
Posts: 7

PostPosted: Sat Oct 28, 2023 9:52 pm    Post subject: Reply with quote

LeFiXER wrote:
VSCO.egirl wrote:

Upon running that script, I get the output:
Code:

Error:[string "local gameName = 'eldenring.exe'             ..."]:7: attempt to index a nil value (local 'processInfo')
stack traceback:
   [string "local gameName = 'eldenring.exe'             ..."]:7: in main chunk


I've been getting nil values all throughout my original script as well, which I'm assuming is all stemming from not being able to access the base module.


In which case the game isn't open so that Cheat Engine can attach to the process. The error here is that the return data from the function enumModules()[1] is nil, it can't retrieve that information because there isn't a process attached.


That's the issue then, as the game is open. I can actively scan its memory and pull addresses from CE's scan function, but it seems that scripts of any kind are just ignoring the attached process.
I think I said it in my original post, but after executing any script, the CE process goes from "ELDEN RING" to "???" even though I can continue to scan for addr's from the game. Any idea what might be causing this?
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sat Oct 28, 2023 9:58 pm    Post subject: Reply with quote

VSCO.egirl wrote:

That's the issue then, as the game is open. I can actively scan its memory and pull addresses from CE's scan function, but it seems that scripts of any kind are just ignoring the attached process.
I think I said it in my original post, but after executing any script, the CE process goes from "ELDEN RING" to "???" even though I can continue to scan for addr's from the game. Any idea what might be causing this?


You mentioned about making a UDCE, I would ensure you have compiled the source correctly.
Back to top
View user's profile Send private message
VSCO.egirl
How do I cheat?
Reputation: 0

Joined: 28 Oct 2023
Posts: 7

PostPosted: Sat Oct 28, 2023 10:03 pm    Post subject: Reply with quote

LeFiXER wrote:
VSCO.egirl wrote:

That's the issue then, as the game is open. I can actively scan its memory and pull addresses from CE's scan function, but it seems that scripts of any kind are just ignoring the attached process.
I think I said it in my original post, but after executing any script, the CE process goes from "ELDEN RING" to "???" even though I can continue to scan for addr's from the game. Any idea what might be causing this?


You mentioned about making a UDCE, I would ensure you have compiled the source correctly.


I was hoping that wouldn't be the case, but I fear you're right. I will recompile tomorrow to ensure its all correct and I'll reply with the result (so anyone else having this problem can find a potential solution)
Back to top
View user's profile Send private message
Famine
Cheater
Reputation: 0

Joined: 23 Oct 2023
Posts: 27
Location: A club where people wee on each other.

PostPosted: Sat Oct 28, 2023 11:15 pm    Post subject: Reply with quote

LeFiXER wrote:
You probably should read the replies to make sure someone else hasn't already mentioned what you are about to say. It gives the impression that you are ignorant of other members in this community.
I don't rightly care what impression it gives, maybe next time give more than a single sentence of "help" and I might actually be able to see your response. I'm one of the few people who actually give replies that are worth a damn on this site, and someone still finds something to complain about, cry me a river.

Egirl, if you still need help tomorrow I'll check in on this thread.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

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

PostPosted: Sun Oct 29, 2023 1:57 pm    Post subject: Reply with quote

Famine wrote:
I don't rightly care what impression it gives, maybe next time give more than a single sentence of "help" and I might actually be able to see your response. I'm one of the few people who actually give replies that are worth a damn on this site, and someone still finds something to complain about, cry me a river.

Egirl, if you still need help tomorrow I'll check in on this thread.


No need for the hostility is there? I'm sorry if you feel hurt that I corrected you. I won't bother wasting my time in future. That said, if you had taken the time to read the code you would have seen that I commented each line explaining what the OP's code did and what to do to rectify it. But more information surfaced to the point that a UDCE was being used therefore it could have been compiled incorrectly and that could cause such issues. It really is as simple as that.
Back to top
View user's profile Send private message
VSCO.egirl
How do I cheat?
Reputation: 0

Joined: 28 Oct 2023
Posts: 7

PostPosted: Sun Oct 29, 2023 10:45 pm    Post subject: Reply with quote

LeFiXER wrote:

No need for the hostility is there? I'm sorry if you feel hurt that I corrected you. I won't bother wasting my time in future. That said, if you had taken the time to read the code you would have seen that I commented each line explaining what the OP's code did and what to do to rectify it. But more information surfaced to the point that a UDCE was being used therefore it could have been compiled incorrectly and that could cause such issues. It really is as simple as that.


Still no success Sad

Took my time to compile correctly, and having the same issues. However, I did notice something during this whole ordeal.
Sometimes when I look at the memory view, I am able to see Opcodes while other times I am not. I found a script by CompiledCode that can pull modules, but this requires the Opcodes to not be null from my understanding.
Before I recompile with an older version of CE, what is usually the culprit of
"??" opcodes even when attached to a process?
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
Goto page 1, 2  Next
Page 1 of 2

 
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