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 


On disable: failure writing referenced addresses

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

Joined: 06 Dec 2009
Posts: 36

PostPosted: Tue May 21, 2024 3:25 pm    Post subject: On disable: failure writing referenced addresses Reply with quote

when im trying to disable MR, I get error (right click context menu): failure writing referenced addresses.
Other code the same. The code is:
Code:

[ENABLE]
{ Game   : helldivers2.exe
  Version:
  Date   : 2024-04-05
  Author : ZoDDeL

  This script does blah blah blah
}
{$c}
// YOU CAN EDIT SECTION START
#define MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY VK_NUMPAD2
int MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY_STATE = 0;
int *main_mission_status;
int *side_mission_status;
#define MAIN_AND_SIDE_MISSIONS_RESTORE_HOTKEY VK_NUMPAD3
//#define MAIN_MISSIONS_COMPLETED_HOTKEY VK_NUMPAD3
// YOU CAN EDIT SECTION END
#define NO_OLDNAMES
#include <windows.h>
short GetAsyncKeyState(int);
//extern float ext_damage_mult;
{$asm}

[ENABLE]
// MAIN MISSION
aobscanmodule(missionA,game.dll,45 8B 4A 18 48 8D 8E 20 01 00 00 41 8B D5) // should be unique
alloc(missionA_newmem,$1000)
label(missionA_code)
label(missionA_return)
missionA_newmem:
{$ccode r10=r10}
main_mission_status = (int*)(r10+0x18);
if (GetAsyncKeyState(MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY) & 0x8000) {
   if (!MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY_STATE) {
     MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY_STATE = 1;
     if (*main_mission_status != 1) {
       *main_mission_status = 1;
     } else {
       *main_mission_status = 0;
     }
   }
} else {
  MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY_STATE = 0;
}
{$asm}
missionA_code:
  mov r9d,[r10+18]
  lea rcx,[rsi+00000120]
  mov edx,r13d
  jmp missionA_return
missionA:
  jmp far missionA_newmem
missionA_return:
registersymbol(missionA)
//--------------------------------------------------------
// SIDE MISSION
aobscanmodule(missionB,game.dll,41 8B 47 38 83 E8 02 83 F8 01 8B 83 14 08 00 00) // should be unique
alloc(missionB_newmem,$1000)
label(missionB_code)
label(missionB_return)

missionB_newmem:
{$ccode r15=r15}
side_mission_status = (int*)(r15+0x38);
if (GetAsyncKeyState(MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY) & 0x8000) {
   if (!MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY_STATE) {
     MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY_STATE = 1;
     if (*side_mission_status != 2) {
       *side_mission_status = 2;
     } else {
       *side_mission_status = 0;
     }
   }
} else {
  MAIN_AND_SIDE_MISSIONS_COMPLETED_HOTKEY_STATE = 0;
}
{$asm}
missionB_code:
  mov eax,[r15+38]
  sub eax,02
  cmp eax,01
  mov eax,[rbx+00000814]
  jmp missionB_return
missionB:
  jmp far missionB_newmem
  nop 2
missionB_return:
registersymbol(missionB)
[DISABLE]
dealloc(missionA_newmem)
missionA:
  db 45 8B 4A 18 48 8D 8E 20 01 00 00 41 8B D5
dealloc(missionB_newmem)
missionB:
  db 41 8B 47 38 83 E8 02 83 F8 01 8B 83 14 08 00 00
Back to top
View user's profile Send private message
Autem
Expert Cheater
Reputation: 1

Joined: 30 Jan 2023
Posts: 155

PostPosted: Tue May 21, 2024 4:19 pm    Post subject: Reply with quote

Just a guess but maybe because you have two "enable" sections. Delete the first [enable] and see if that fixes things.

Another idea might be to again reinforce ASM at the start of the disable section by adding another {$asm} right under [disable] just in case for some reason the asm label toward the end of your second enable block wasn't carried down. I can't fully explain why that happens sometimes, but it has happened to me in the past where if I add another asm label right at the start of the disable section, things work again. *shrug*

Also try having the deallocs from the disable section appear AFTER both of the AOBs have been run to restore the code. Don't deallocate it before you used it to restore the bytes. <-- edit: I stand corrected on this per Dark Byte's reply. The order shouldn't matter.

Let me know if any of this helped you out. I am curious!


Last edited by Autem on Wed May 22, 2024 2:58 pm; edited 2 times in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4715

PostPosted: Tue May 21, 2024 5:29 pm    Post subject: Reply with quote

You have two [ENABLE] sections. CE wouldn't even accept that as a valid AA script.
I'm assuming the first one shouldn't be there.

Execute the {$c} block only in the [ENABLE] section. Don't put it above [ENABLE] - that section of the AA script is executed when both enabling and disabling the script.

_________________
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
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Tue May 21, 2024 11:57 pm    Post subject: Reply with quote

Quote:

Also try having the deallocs from the disable section appear AFTER both of the AOBs have been run to restore the code. Don't deallocate it before you used it to restore the bytes. <-- I would actually try this before my other suggestions, but noticed it last.


dealloc order doesn't matter. It only deallocates at the end, and only if all allocs are mentioned. If you miss one, nothing will be deallocated

_________________
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
Dave_Scream
Cheater
Reputation: 0

Joined: 06 Dec 2009
Posts: 36

PostPosted: Wed May 22, 2024 2:16 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Execute the {$c} block only in the [ENABLE] section. Don't put it above [ENABLE] - that section of the AA script is executed when both enabling and disabling the script.


Yes the problem is here.
BUT
Isn't it true that the {$c} block before [ENABLE] lets you declare global variables? If I put this block in the [ENABLE] section, the variables won't be global anymore. And will be not possible to use them in other scripts?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Wed May 22, 2024 2:20 pm    Post subject: Reply with quote

no. if it's outside of [enable] it just means it gets compiled by both enable and disable. Which is not very useful for {$c} blocks as all {$c} code generated is global to begin with
_________________
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 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