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 


Check if file exists, file name in memory?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
thethiny
Cheater
Reputation: 0

Joined: 01 Apr 2012
Posts: 38
Location: earth

PostPosted: Sat Jul 16, 2016 6:57 pm    Post subject: Reply with quote

ParkourPenguin wrote:

Now that you mention it, file+100 is probably more than 2GB away from newmem which causes the instruction cmp [BOOL],1 to fail (it's not encodable). Pass it back via a register (i.e. eax) instead, or just put it inline like I suggested.

Yeah I noticed that and I fixed it Very Happy

ParkourPenguin wrote:

I also just now noticed you're swapping rax and rcx by popping them in the wrong order. Elements are accessed from the stack on a last-in-first-out basis.

I also fixed this in the edit.

ParkourPenguin wrote:

If PathFileExists always returns 0, then it's always failing to find the file specified. Try executing my example script in the game but instead of CE's path use '..\Loadr\FileName.txt',0

I got it, the Get Path thingy starts at the root directory, so I don't need the '..\', I fixed this by lea rcx,[DATA+3] instead of DATA

THANK YOU SO MUCH I NOW HAVE A FULLY WORKING DLC LOADER Very Happy

here's the code for those interested:
I expanded it to support 128 characters.
Code:

alloc(newmem,2048,"MK10.exe"+13FF5C4)
alloc(DATA,512)
label(returnhere)
label(originalcode)
label(exit)
label(file)
label(BOOL)
label(X0Backup)


DATA+90:
BOOL:
dd 424F4F4C

DATA+80:
X0Backup:
DB ?


newmem: //this is allocated memory, you have read,write,execute access
//place your code here
movaps [X0Backup],xmm0 //BACKUP XMM0
movaps [DATA],xmm0
movaps xmm1,[rax-70]
movaps [DATA+10],xmm1
//Expand Max Charachter Size
movaps xmm0,[rax-60]
movaps [DATA+20],xmm0
movaps xmm1,[rax-50]
movaps [DATA+30],xmm1
movaps xmm0,[rax-40]
movaps [DATA+40],xmm0
movaps xmm1,[rax-30]
movaps [DATA+50],xmm1
movaps xmm0,[rax-20]
movaps [DATA+60],xmm0
movaps xmm1,[rax-10]
movaps [DATA+70],xmm1

cmp [DATA],'..\A'
jnz originalcode
cmp [DATA+4],'sset'
jnz originalcode
cmp Byte Ptr [DATA+8],'\'
jnz originalcode
mov [DATA+3],'Load'
mov Word Ptr [DATA+7],'r\'

call file //Try to open ..\Loadr\YourFile
cmp [BOOL],1
jnz originalcode

movaps xmm0,[DATA]
movaps xmm1,[DATA+10]
movaps [rdx-80],xmm0
movaps [rdx-70],xmm1
movaps xmm0,[DATA+20]
movaps xmm1,[DATA+30]
movaps [rdx-60],xmm0
movaps [rdx-50],xmm1
movaps xmm0,[DATA+40]
movaps xmm1,[DATA+50]
movaps [rdx-40],xmm0
movaps [rdx-30],xmm1
movaps xmm0,[DATA+60]
movaps xmm1,[DATA+70]
movaps [rdx-20],xmm0
movaps [rdx-10],xmm1
jmp "MK10.exe"+13FF600

file:
  push rcx //Backup All 3 Registers
  push rax
  push rdx
  sub rsp,20
  lea rcx,[DATA+3]
  call SHLWAPI.PathFileExistsA
  mov [BOOL],eax
  add rsp,20
  pop rdx
  pop rax
  pop rcx
  ret


originalcode:
movaps xmm0,[X0Backup] //RESTORE XMM0
movaps [rdx-80],xmm0
movaps xmm1,[rax-70]

exit:
jmp returnhere

"MK10.exe"+13FF5C4:
jmp newmem
nop
nop
nop
returnhere:
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: Sat Jul 16, 2016 11:24 pm    Post subject: This post has 1 review(s) Reply with quote

You can use 'GetFileAttributes' instead which is exported from kernel32.dll and guaranteed to be available in every process. If the function fails, it will return 'INVALID_FILE_ATTRIBUTES' which allows you to determine if the file is on disk or not. You can also pull the specific reason for failing from GetLastError.

If you need more info see:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364944(v=vs.85).aspx

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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 Previous  1, 2
Page 2 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