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 


VirtualAllocEx and other functions fail with ACCESS_DENIED

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Artikash
How do I cheat?
Reputation: 0

Joined: 14 Jul 2018
Posts: 5

PostPosted: Wed May 29, 2019 12:27 pm    Post subject: VirtualAllocEx and other functions fail with ACCESS_DENIED Reply with quote

I'm the developer of Textractor (google it and you'll find the GitHub page with more info, I can't post links) trying to make it work with as many games as I can. The first thing Textractor does is inject a dll into the game process with this code:

[code]if (AutoHandle<> process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId))
{
#ifdef _WIN64
BOOL invalidProcess = FALSE;
IsWow64Process(process, &invalidProcess);
if (invalidProcess) return AddConsoleOutput(NEED_32_BIT);
#endif
static std::wstring location = Util::GetModuleFilename(LoadLibraryExW(ITH_DLL, nullptr, DONT_RESOLVE_DLL_REFERENCES)).value();
if (LPVOID remoteData = VirtualAllocEx(process, nullptr, (location.size() + 1) * sizeof(wchar_t), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE))
{
WriteProcessMemory(process, remoteData, location.c_str(), (location.size() + 1) * sizeof(wchar_t), nullptr);
if (AutoHandle<> thread = CreateRemoteThread(process, nullptr, 0, (LPTHREAD_START_ROUTINE)LoadLibraryW, remoteData, 0, nullptr)) WaitForSingleObject(thread, INFINITE);
else if (GetLastError() == ERROR_ACCESS_DENIED) AddConsoleOutput(NEED_64_BIT);
VirtualFreeEx(process, remoteData, 0, MEM_RELEASE);
return;
}
}

AddConsoleOutput(INJECT_FAILED);[/code]

The problem is that in the game I'm trying to add support for VirtualAllocEx returns null i.e. it failed, and checking the last error code it is 5 (ACCESS_DENIED). The official MS documentation for VirtualAllocEx doesn't say how this could happen, and I've never seen it fail like this before. Presumably it's a result of the antihacking software used by the game. I get the same result (ACCESS_DENIED last error) if I remove VirtualAllocEx and try WriteProcessMemory or CreateRemoteThread with addresses I know should be valid. I've tried setting SeDebugPrivilege and I also tried using the native API (NtAllocateVirtualMemory) and all of that failed.

So what to do next? I'd like to try CE's custom functions for opening process and writing its memory, but the antihack detects CE. So, could someone point me to the source where those are implemented? And is there anything else I should try?


Last edited by Artikash on Thu May 30, 2019 8:12 am; edited 2 times in total
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1587

PostPosted: Wed May 29, 2019 1:52 pm    Post subject: Reply with quote

adjust process token and token privilege.
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Artikash
How do I cheat?
Reputation: 0

Joined: 14 Jul 2018
Posts: 5

PostPosted: Wed May 29, 2019 4:07 pm    Post subject: Reply with quote

I tried that too, didn't work.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1587

PostPosted: Wed May 29, 2019 4:27 pm    Post subject: Reply with quote

ensure you are logged using admin account, and make sure to run your executable as admin.

add this manifest to your resource, also save it as .xml:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
            </requestedPrivileges>
        </security>
    </trustInfo>
</assembly>


otherwise adjusting process token privilege will fail, and there is nothing higher (by mean powerful) than these API from usermode. (unless you write your own device driver and handle things from there)

edit:
also im not sure if changing descriptor security is required or not, but you can try that. (i think it is not limited to process only maybe threads as well)

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Artikash
How do I cheat?
Reputation: 0

Joined: 14 Jul 2018
Posts: 5

PostPosted: Wed May 29, 2019 4:44 pm    Post subject: Reply with quote

I was always running the executable as admin.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1587

PostPosted: Wed May 29, 2019 4:55 pm    Post subject: Reply with quote

sorry i cant help you, as i never experienced such issues. (just a tip: do a quick revision maybe you are missing something)
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Wed May 29, 2019 10:57 pm    Post subject: Reply with quote

Based on the game name you gave, will say that it's due to the anti-cheat.

As for that as well, we do not assist with online/multiplayer hacking on this site.
https://forum.cheatengine.org/faq.php#0

_________________
- 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 -> General Gamehacking 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