PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to read system module's memory in WM 5.0

Broken Sword · 09 Mar 2006, 19:59 UTC
Hi. I've a problem with reading memory of system module in WM 5.0.

Code:
; R4 -> Module structure

ldr R0, [R4, #0x7C] ; R0 -> module base
ldr R1, [R4, #0x8C]
add R1, R0, R1 ; R1 -> module export base
ldr R4, [R1, #0x20] ; AddressOfNames


WM 5.0 falls on ldr R4, [R1, #0x20] with "Memory can't be read". There is no problems in older versions of WM. How to read "ring0" memory in WM 5.0?
joshbu [MSFT] · 09 Mar 2006, 22:01 UTC
When you say "ring0" memory are you asking about kernel space memory?

On protected devices (all Smartphones, and some Pocket PCs,) applications are forbidden from reading or writing from the kernel space. It's a security risk.

What are you trying to do?
Use SetKMode(TRUE) - this would make your thread run in kernel mode.
In old days of WM2003[se] both user and kernel code ran in kernel mode, so each process could access kernel data.
In WM5 MS designed a more "secure" OS. That is why it recommends protecting kernel address space if the CPU supports it. And this is on by default (this is one of the reasons why WM5 is slower then previous OSes).
The SetProcPermissions(-1) may also help - this function allows you to access address space of other processes. Both these 2 functions are protected. But it is not a problem ;)
mamaich wrote: But it is not a problem ;)


Could you explain a bit more?

I use some of those protected functions on Smartphone to implement low level frame buffer access, and would be happy being able to use them without forcing the user to unlock his device or get my app signed in priviledged mode...
StephC wrote:Could you explain a bit more?

I have not tried that, but you can always find a trusted app (maybe GWES) and force it to run your code. The old WM_TIMER trick or something similar may work. WM5 is an OS from MS, which is full of security holes. And you have a partial and a bit obsolete source code of its kernel, so you can dig there.
I've patched the certmod.dll on my device so that it treats all apps as signed. Maybe I'll play with device security when I'll have time.

Edited. Under Win2K/XP it is possible to use some tricks in an exception filter/handler (you should use assembler language, otherwise C runtime would spoil everything). For example playing with debug registers is possible. You should test this under WinCE, something tells me that exception handler is excecuted in kmode.
Or there is a function SetThreadContext that may allow you to set PCR.