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 


Why does VMCALL_KERNELMODE need to set IF to 0?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source
View previous topic :: View next topic  
Author Message
lcineyes
Newbie cheater
Reputation: 0

Joined: 19 May 2025
Posts: 10

PostPosted: Thu Jul 31, 2025 1:14 am    Post subject: Why does VMCALL_KERNELMODE need to set IF to 0? Reply with quote

​​Should IF be set to 1 immediately after entering ring 0 via VMCALL_KERNELMODE?​
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Thu Jul 31, 2025 7:09 am    Post subject: Reply with quote

Feel free to set IF to 1 afterwards. You're in ring0, so go ahead

This is just to protect you from unexpected interrupts that detect kernelmode running in usermode execution regions

_________________
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
lcineyes
Newbie cheater
Reputation: 0

Joined: 19 May 2025
Posts: 10

PostPosted: Sat Aug 02, 2025 8:47 am    Post subject: Reply with quote

Dark Byte wrote:
Feel free to set IF to 1 afterwards. You're in ring0, so go ahead

This is just to protect you from unexpected interrupts that detect kernelmode running in usermode execution regions



Why does my code crash on page faults even though the IRQL is ​​PASSIVE_LEVEL​​ after entering kernel mode? Normally, kernel modules (like your driver) can safely access a full user-mode PE image without locking memory, but mine fails.
Back to top
View user's profile Send private message
lcineyes
Newbie cheater
Reputation: 0

Joined: 19 May 2025
Posts: 10

PostPosted: Sun Aug 03, 2025 5:29 am    Post subject: Reply with quote

​​Issue​​: After entering kernel mode via VMCALL_KERNELMODE, enabling interrupts (STI) leads to memory corruption (e.g., recently accessed files overwritten with zeros). Despite IRQL being 0 (PASSIVE_LEVEL), page faults are unhandled.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sun Aug 03, 2025 10:58 am    Post subject: Reply with quote

Quote:

Why does my code crash on page faults even though the IRQL is ​​PASSIVE_LEVEL​​ after entering kernel mode? Normally, kernel modules (like your driver) can safely access a full user-mode PE image without locking memory, but mine fails.

Windows recognizes the cause of the issue to be my driver, checks it's security stuff and then allows it.
When done outside of a known loaded driver, it'll bug out. (same reason why Try/except don't work in manually loaded drivers)

also, CE's driver has a routine to read only paged in memory by looking at the pagetable, and a secondary fallback by disabling the pagefault interrupt handler while it's reading the memory, with interrupts disabled)

Look into VMCALL_DISABLE_DATAPAGEFAULTS and VMCALL_ENABLE_DATAPAGEFAULTS


Quote:

After entering kernel mode via VMCALL_KERNELMODE, enabling interrupts (STI) leads to memory corruption (e.g., recently accessed files overwritten with zeros). Despite IRQL being 0 (PASSIVE_LEVEL), page faults are unhandled.

Do you also call VMCALL_USERMODE to return?

_________________
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
lcineyes
Newbie cheater
Reputation: 0

Joined: 19 May 2025
Posts: 10

PostPosted: Sun Aug 03, 2025 7:35 pm    Post subject: Reply with quote

1.Currently, my approach to handling Ring-3 memory access exceptions is to return to user mode via VMCALL_USERMODE, access the target memory in user space, and then re-enter kernel mode.

2.The above method cannot handle code running in kernel space.

3.I've tried using VMCALL_DISABLE_DATAPAGEFAULTS and VMCALL_ENABLE_DATAPAGEFAULTS, but they fail to prevent page faults from occurring, still resulting in BSODs.

4.When I use VMCALL_KERNELMODE to operate in kernel address space and execute KeStackAttach before returning, after several runs it causes BSODs due to page faults. Additionally, I've observed that content from some recently accessed files gets completely overwritten with zeros while the file sizes remain unchanged.

5.When a page fault triggers a blue screen, Windbg can successfully query the target memory, which leads me to suspect CR3 corruption. I'll conduct two tests and report back here:

5.1 Test without KeStackAttach​​:
Verify whether CR3 corruption still occurs when avoiding process attachment.
5.2 ​​Continuous Process Memory Access Test​​:
Check if accessing memory within the same process triggers page faults
Validate whether such faults can be handled
(Given that Ring-3 faults couldn't be handled previously, this will likely fail too)

The testing environment is VMware 17 with an i7 CPU running Windows 10.
Back to top
View user's profile Send private message
lcineyes
Newbie cheater
Reputation: 0

Joined: 19 May 2025
Posts: 10

PostPosted: Mon Aug 04, 2025 7:20 pm    Post subject: Reply with quote

Root Cause Identified​​:
The Windows thread scheduler doesn't preserve CR4 during context switches. Many kernel APIs trigger thread scheduling, and enabling interrupts (STI) makes the thread susceptible to preemption. When the thread resumes execution:

1.It may land on a different CPU core
2.The new core's CR4 has SMEP/SMAP enabled (not disabled like the original context)
3.This causes page faults at DISPATCH_LEVEL
4.Paradoxically, the target data pages remain resident in memory


Thank you for taking the time to answer my questions.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Aug 05, 2025 1:55 am    Post subject: Reply with quote

Maybe you can edit the pagetable entrys your code runs in and mark it as a supervisor page before you enable interrupts
_________________
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 Source 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