[PROJECT] HaRET on WP7

Search This thread

Jaxbot

Inactive Recognized Developer
Mar 14, 2009
1,224
548
windowsphonehacker.com
Thanks for this insight, minDark. may I ask how you found out about the missing dependencies?
It's not so nice that the kernel mode function is missing in WP7. How are we going to start the kernel without it?
I did as you proposed and compiled haret.exe without it. I just commented out lines containing setkmode. But I didn't change the ordinals stuff because I have no idea what that is.

no-kmode haret.exe with minDark's proposed kmode patch is attached. Any WP7 device owners welcome to test.

diff to current haret.git HEAD:
Code:
haret$ git diff
diff --git a/src/memory.cpp b/src/memory.cpp
index ccba659..53c0826 100644
--- a/src/memory.cpp
+++ b/src/memory.cpp
@@ -320,7 +320,7 @@ err:  VirtualFree (pmWindow, 0, MEM_RELEASE);
   if (slot >= PHYS_CACHE_COUNT)
   {
     // Go into supervisor mode
-    SetKMode (TRUE);
+//    SetKMode (TRUE);
     cli ();
     cpuFlushCache ();
 
@@ -333,7 +333,7 @@ err:  VirtualFree (pmWindow, 0, MEM_RELEASE);
 
     // Back to user mode
     sti ();
-    SetKMode (FALSE);
+//    SetKMode (FALSE);
   }
 
   // Move least recently used slot to front
@@ -354,12 +354,12 @@ void memPhysReset ()
   if (pmInited)
   {
     // Go into supervisor mode
-    SetKMode (TRUE);
+//    SetKMode (TRUE);
     cpuFlushCache ();
     // Restore the page table entries
     for (int i = 0; i < 16 * PHYS_CACHE_COUNT; i++)
       pmPT [i] = pmOldPT [i];
-    SetKMode (FALSE);
+//    SetKMode (FALSE);
 
     VirtualFree (pmL2PT, 0, MEM_RELEASE);
     VirtualFree (pmWindow, 0, MEM_RELEASE);
diff --git a/src/wince/output.cpp b/src/wince/output.cpp
index cc65d40..e4be7ed 100644
--- a/src/wince/output.cpp
+++ b/src/wince/output.cpp
@@ -276,9 +276,9 @@ prepThread()
     // All wince 3.0 and later machines are automatically in "kernel
     // mode".  We enable kernel mode by default to make older PDAs
     // (ce2.x) work.
-    Output("Setting KMode to true.");
-    int kmode = SetKMode(TRUE);
-    Output("Old KMode was %d", kmode);
+//    Output("Setting KMode to true.");
+//    int kmode = SetKMode(TRUE);
+//    Output("Old KMode was %d", kmode);
 }
 
 // Initialize the haret application.

No dice on this one, either. I'm trying to get crash logs from the device to see if we can get some better pointers.
 
  • Like
Reactions: dcordes

Ttblondey

Senior Member
Jan 1, 2008
1,690
103
haret-nokmode.exe is not a valid Win32 application.I'm using 64bit win7. with Intrinsic custom rom HD7.
 

minDark

Member
Nov 15, 2007
16
6
Targoviste
@dcordes: It's something wrong with your compiler, try to do static compile or use an older version of mingw gcc. Your recompiled version of haret still depends on libgcc_s_sjlj-1.dll and it's ok about SetKmode. About import table, you can use any Win32 PE file editor to find dependencies, i use CFF File explorer (written by Daniel Pistelli, windows only), this is a good tool because it has Net Framework support also and you can rebuild the import table. About functions ordinals, I do not think is so important.
 
  • Like
Reactions: dcordes

dcordes

Retired Senior Recognized Developer
Nov 20, 2007
707
254
@dcordes: It's something wrong with your compiler, try to do static compile or use an older version of mingw gcc. Your recompiled version of haret still depends on libgcc_s_sjlj-1.dll and it's ok about SetKmode. About import table, you can use any Win32 PE file editor to find dependencies, i use CFF File explorer (written by Daniel Pistelli, windows only), this is a good tool because it has Net Framework support also and you can rebuild the import table. About functions ordinals, I do not think is so important.
Many thanks.

Compiled haret.exe from same source as above (same diff) with cegcc-mingw32ce-0.55

Didn't look into import table => Win32 PE file editor yet. Hope there is one for Linux.

Can somebody test the attached exe?

(btw, I would test myself but currently HD2 is my day2day phone)

thx
 

Attachments

  • haret-nokmode_arm-mingw32ce-055.zip
    76.8 KB · Views: 212
  • Like
Reactions: minDark

Jaxbot

Inactive Recognized Developer
Mar 14, 2009
1,224
548
windowsphonehacker.com
Many thanks.

Compiled haret.exe from same source as above (same diff) with cegcc-mingw32ce-0.55

Didn't look into import table => Win32 PE file editor yet. Hope there is one for Linux.

Can somebody test the attached exe?

(btw, I would test myself but currently HD2 is my day2day phone)

thx

Some progress ;)

(Ignore the background, I use dll import to launch it, just because I have a lot of scratch code on there).

The GUI doesn't load, but the process stays running in the background.
 

dcordes

Retired Senior Recognized Developer
Nov 20, 2007
707
254
Some progress ;)

(Ignore the background, I use dll import to launch it, just because I have a lot of scratch code on there).

The GUI doesn't load, but the process stays running in the background.

cool you could mess around with startup.txt a bit. I attached the files I used to create the experimental linload. the current startup.txt will try booting the zImage (it's hd2 'evo kernel' see above) but without the kmode I fear it won't get that far. You could try some other stuff though, e.g. touch earlyharetlog.txt again and see if you get the haretlog.txt out of it now. If that works you could try placing some commands in startup.txt
 

Attachments

  • wp7harettestfiles.zip
    5.2 MB · Views: 256
Last edited:

Jaxbot

Inactive Recognized Developer
Mar 14, 2009
1,224
548
windowsphonehacker.com
cool you could mess around with startup.txt a bit. I attached the files I used to create the experimental linload. the current startup.txt will try booting the zImage (it's hd2 'evo kernel' see above) but without the kmode I fear it won't get that far. You could try some other stuff though, e.g. touch earlyharetlog.txt again and see if you get the haretlog.txt out of it now. If that works you could try placing some commands in startup.txt

This gives me "Failed to lock 1341 pages (code 6)"
 

ted973

Senior Member
Feb 5, 2008
144
62
Beijing
cool you could mess around with startup.txt a bit. I attached the files I used to create the experimental linload. the current startup.txt will try booting the zImage (it's hd2 'evo kernel' see above) but without the kmode I fear it won't get that far. You could try some other stuff though, e.g. touch earlyharetlog.txt again and see if you get the haretlog.txt out of it now. If that works you could try placing some commands in startup.txt

Failed to lock 1341 pages (code 6)

and haRET is running not exit.

i made a haRET loader, to make more people can easy test.

copy new haRET.exe and kernel image start script to haRET folder of xap file.

then deploy haRET_Loader.xap to your device, run it and press the load haRET button,if any err there will be a MessageBox to show them.
 

Attachments

  • haRET_Loader.xap
    115.7 KB · Views: 314
  • Like
Reactions: dcordes

spavlin

Senior Member
Dec 26, 2006
321
643
===========================================
htcleo MACH_HTCLEO HTCLEO 2524
------------------------------------------
htcmozart MACH_HTCMOZART HTCMOZART 3544
------------------------------------------
htcgold MACH_HTCGOLD HTCGOLD 3545
===========================================
 
  • Like
Reactions: darxon

dcordes

Retired Senior Recognized Developer
Nov 20, 2007
707
254
I found something interesting: http://xdaforums.com/showthread.php?t=1453343 with this we can take kernel permissions for haret and move the app to TCB room.
P.S: The latest recompiled version of haret seems to be ok.

Awesome, this sounds like what we need. I downloaded the .zip and to me it looks very complicated and I have no clue where to begin. Will this permanently give us kernel mode or will we insert the functions where setkmode was ?

Is the "cannot lock n pages" due to missing permission to access protected mem induced by lack of kmode when nokmode-haret tries to start kernel ?
 

Jaxbot

Inactive Recognized Developer
Mar 14, 2009
1,224
548
windowsphonehacker.com
Awesome, this sounds like what we need. I downloaded the .zip and to me it looks very complicated and I have no clue where to begin. Will this permanently give us kernel mode or will we insert the functions where setkmode was ?

Is the "cannot lock n pages" due to missing permission to access protected mem induced by lack of kmode when nokmode-haret tries to start kernel ?

I was under the impression that we wouldn't need to elevate privileges, as we're already running a native application on a rooted device (if it weren't rooted like this, we wouldn't be able to run it).
I may be wrong, though.

Not sure about the cannot lock n pages, though.
 

Ttblondey

Senior Member
Jan 1, 2008
1,690
103
Ok,
I manage to install it to my hd7 but when i click Load haRET it says error Haret is not running in 'system' mode.Major functionality will not be present.
 
  • Like
Reactions: mdskrzypczyk

ultrashot

Inactive Recognized Developer
May 26, 2009
1,478
2,046
St.Petersburg
as for gui: you should call either windowtreeupdater or directly frame.dll

windowtreeupdater.dll way:
Code:
typedef HRESULT (*CREATEWINDOWTREEUPDATER)(HWND hWnd, DWORD unk, HANDLE *hWindowTreeUpdater);
typedef HRESULT (*UPDATEWINDOWTREE)(HANDLE hWindowTreeUpdater);
typedef HRESULT (*DELETEWINDOWTREEUPDATER)(HANDLE hWindowTreeUpdater);
usage:
Code:
HANDLE hWindowTreeUpdater = NULL;
CreateWindowTreeUpdater(hWnd, 1, &hWindowTreeUpdater);
// after that window should appear on the screen
...
DeleteWindowTreeUpdater(hWindowTreeUpdater);
// delete window's page when you don't need it.

don't call UpdateWindowTree, it isn't needed.

frame.dll way is much more complicated since it requires to rewrite wndproc of all windows to treat WM_GESTURE messages as WM_LBUTTONDOWN/WM_LBUTTONUP.
 

Attachments

  • windowtreeupdater.rar
    2.8 KB · Views: 79
Last edited:
  • Like
Reactions: dcordes and Jaxbot

spavlin

Senior Member
Dec 26, 2006
321
643
htcutility-kernmem_2011-11-10
 

Attachments

  • htcutility-kernmem_2011-11-10.rar
    436.2 KB · Views: 113
  • Like
Reactions: darxon

spavlin

Senior Member
Dec 26, 2006
321
643
HTC MOZART NhatHoa-CustomRom V9 8107

===== HaRET pre-0.5.3-20120209_233258 =====
Finished initializing output
Loading dynamically bound functions
Function 'AllocPhysMem' in library 'coredll' at 0x4079e059
Function 'FreePhysMem' in library 'coredll' at 0x4079e089
Unable to load library 'gx'
Unable to load library 'gx'
Unable to load library 'gx'
Unable to load library 'gx'
Function 'LoadLibraryExW' in library 'coredll' at 0x407ca9f4
Function 'NLedSetDevice' in library 'coredll' at 0x407a7269
Function 'GetSystemPowerStatusEx2' in library 'coredll' at 0x4076d059
Function 'SleepTillTick' in library 'coredll' at 0x4079e0b5
Function 'CreateToolhelp32Snapshot' in library 'toolhelp' at 0x421a1079
Function 'CloseToolhelp32Snapshot' in library 'toolhelp' at 0x421a10b1
Function 'Process32First' in library 'toolhelp' at 0x421a1131
Function 'Process32Next' in library 'toolhelp' at 0x421a1179
Function 'Module32First' in library 'toolhelp' at 0x421a1299
Function 'Module32Next' in library 'toolhelp' at 0x421a12e9
Function 'Heap32ListFirst' in library 'toolhelp' at 0x421a1351
Function 'Heap32ListNext' in library 'toolhelp' at 0x421a13fd
Function 'Heap32First' in library 'toolhelp' at 0x421a148d
Function 'Heap32Next' in library 'toolhelp' at 0x421a1561
Unable to load library 'ace_ddi'
Unable to load library 'ace_ddi'
Unable to load library 'ace_ddi'
Unable to load library 'ace_ddi'
Unable to load library 'ace_ddi'
Unable to load library 'ace_ddi'
Unable to load library 'ace_ddi'
Unable to load library 'ace_ddi'
Unable to load library 'clkregim'
Detecting current machine
Trying to detect machine (Plat='SmartPhone' OEM='HTC')
Wince reports processor: core=Snapdragon name=QSD8250 cat= vend=QUALCOMM
Looking at machine Alpine
Looking at machine Apache
Looking at machine AximX50
Looking at machine AximX5
Looking at machine Beetles
Looking at machine Blueangel
Looking at machine Himalaya
Looking at machine Magician
Looking at machine Universal
Looking at machine H1910
Looking at machine H1940
Looking at machine RX1950
Looking at machine H2200
Looking at machine H3600b
Looking at machine H3700
Looking at machine H3800
Looking at machine H3900
Looking at machine H4000
Looking at machine H4300
Looking at machine H5000
Looking at machine H6340
Looking at machine HX2000
Looking at machine HX4700
Looking at machine Sable
Looking at machine Wizard
Looking at machine Hermes
Looking at machine Trinity
Looking at machine Athena
Looking at machine G500
Looking at machine Artemis
Looking at machine Herald
Looking at machine Prophet
Looking at machine RX3000
Looking at machine Treo700wx
Looking at machine Treo850w
Looking at machine Treo850e
Looking at machine e310
Looking at machine e740
Looking at machine Acer_n30
Looking at machine Mio_P550
Looking at machine Kaiser
Looking at machine Loox5xx
Looking at machine Loox400
Looking at machine MioA701
Looking at machine Wallaby
Looking at machine Raphael
Looking at machine SGH_i900
Looking at machine Leo
Looking at machine Topaz
Looking at machine Rhodium
Looking at machine Jornada9xx0
Looking at machine Acer_S200
Looking at machine M800
Looking at machine X800
Looking at machine DX900
Looking at machine X900
Looking at machine M900
Looking at machine Jornada820
Looking at machine H3100
Looking at machine H3600a
Looking at machine Tornado
Looking at machine Libra
Looking at machine E4430
Looking at machine Generic Intel PXA27x
Looking at machine Generic Intel PXA
Looking at machine Generic Intel StrongArm
Looking at machine Generic TI OMAP
Looking at machine Generic TI OMAP15xx
Looking at machine Generic Samsung s3c24xx
Looking at machine Generic Samsung s3c64xx
Looking at machine Generic MSM7xxxA
Looking at machine Generic MSM7xxx
Looking at machine Generic QSD8xxx
Looking at machine FreeScale i.MX21
Looking at machine Generic Atlas
Looking at machine Generic ARM 920t
Looking at machine Generic ARM 926
Looking at machine Generic ARM v6
Looking at machine Generic ARM v7
Looking at arch Generic Intel PXA27x
Exception on arch Generic Intel PXA27x detect
Looking at arch Generic Intel PXA
Exception on arch Generic Intel PXA detect
Looking at arch Generic Intel StrongArm
Looking at arch Generic TI OMAP
Looking at arch Generic TI OMAP15xx
Looking at arch Generic Samsung s3c24xx
Looking at arch Generic Samsung s3c64xx
Looking at arch Generic MSM7xxxA
Looking at arch Generic MSM7xxx
Looking at arch Generic QSD8xxx
Detecting ram size
WinCE reports memory size 520093696 (phys=498970624 store=-1)
Mapping mmu table
Exception on mmu table lookup
Unable to map in mmu table! Many functions will not work.
Build L1 reverse map
Exception on arm6 type lookup
Found 0 uncached and 0 cached L1 mappings (ignored 0).
Not registering command IGPIO
Not registering command WG|PIO
Not registering command GPLR
Not registering command GPDR
Not registering command GAFR
Not registering command GPIO
Not registering command GPIOST
Registering command LOADLIBRARYEX
Registering command NLEDSET
Not registering command TRACE
Not registering command TRACEMASK
Not registering command TRACE2
Not registering command TRACETYPE
Not registering command TRACE2TYPE
Not registering command TRACEFORWATCH
Not registering command INSN
Not registering command INSNREENABLE
Not registering command INSNREG1
Not registering command INSNREG2
Not registering command INSN2
Not registering command INSN2REENABLE
Not registering command INSN2REG1
Not registering command INSN2REG2
Registering command KILL
Registering command PS
Registering command LSMOD
Registering command ADDR2MOD
Not registering command AC97
Not registering command ATIDBG
Not registering command EIM
Not registering command GPIO
Not registering command WB|ANK
Not registering command GPLR
Not registering command GPDR
Not registering command GPPUD
Not registering command GPSDR
Not registering command GPSPUD
Not registering command GPIOS
Not registering command GPIOSOUT
Not registering command GPIOST
Not registering command MSMCLKKHZ
Initializing for machine 'Generic QSD8xxx'
HaRET(1)# set ramaddr 0x18800000
HaRET(2)# addlist irqs p2v(0xac000080) 0x100 32 0
HaRET(3)# addlist irqs p2v(0xac000084) 0 32 0
HaRET(1)# addlist gpios p2v(0xa9000800)
HaRET(2)# addlist gpios p2v(0xa9100c00)
HaRET(3)# addlist gpios p2v(0xa9000804)
HaRET(4)# addlist gpios p2v(0xa9000808)
HaRET(5)# addlist gpios p2v(0xa900080c)
HaRET(6)# addlist gpios p2v(0xa9000810)
HaRET(7)# addlist gpios p2v(0xa9000814)
HaRET(8)# addlist gpios p2v(0xa9000818)
HaRET(9)# addlist gpios p2v(0xa9000850)
HaRET(10)# addlist gpios p2v(0xa9100c20)
HaRET(11)# addlist gpios p2v(0xa9000854)
HaRET(12)# addlist gpios p2v(0xa9000858)
HaRET(13)# addlist gpios p2v(0xa900085c)
HaRET(14)# addlist gpios p2v(0xa9000860)
HaRET(15)# addlist gpios p2v(0xa9000864)
HaRET(16)# addlist gpios p2v(0xa900086c)
HaRET(17)# addlist gpios p2v(0xa9000820)
HaRET(18)# addlist gpios p2v(0xa9100c08)
HaRET(19)# addlist gpios p2v(0xa9000824)
HaRET(20)# addlist gpios p2v(0xa9000828)
HaRET(21)# addlist gpios p2v(0xa900082c)
HaRET(22)# addlist gpios p2v(0xa9000830)
HaRET(23)# addlist gpios p2v(0xa9000834)
HaRET(24)# addlist gpios p2v(0xa9000838)
Haret is not running in 'system' mode. Major functionality will not be present.
Exception on cpu id detect
Welcome, this is HaRET pre-0.5.3-20120209_233258 running on WindowsCE v7.10
Minimal virtual address: 0x10000, maximal virtual address: 0x7fffffff
Detected machine Generic QSD8xxx/QSD8xxx (Plat='SmartPhone' OEM='HTC')
CPU is ? running in user mode
Enter 'HELP' for a short command summary.

Running WSAStartup
Starting gui
In initdialog
Found machine Generic QSD8xxx
executing startup.txt
HaRET(1)# set mtype 3544
HaRET(3)# set ramaddr 0x11800000
HaRET(4)# set ramsize 0x1E400000
HaRET(5)# set kernelcrc 0
HaRET(6)# set fbduringboot 1
HaRET(7)# set forcefbduringboot 1
HaRET(8)# dump mmu
----- Virtual address map -----
Terminating haret due to unhandled exception (pc=000218e0)
 

dcordes

Retired Senior Recognized Developer
Nov 20, 2007
707
254
Last edited:
  • Like
Reactions: dowenprs

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
Hey, just wanted to say that this looks awesome, and if you want anything using the HtcRoot project, let me know (I'm the guy who started it).

As for the error locking pages, I'm pretty sure that's a kernel-only API, yes. The version of CE on WP7 seems to work more like a desktop OS with regard to user/kernel split - that is, it uses hardware ring levels and by default all apps get loaded into a low-privilege ring and can't control things like the memory manager.

There are Linux kernels which are designed to work entirely in userspace of another OS, so that's a possibility. Another option would be to use the HtcUtility driver (assuming your ROMs have a working version; many don't) to make changes within kernel mode. Finally, you could write a driver (not *quite* as hard as it sounds, for an unlocked ROM) that does the KMode stuff for you (i.e. you use an IOCTL to tell it "Lock me these pages" and it does so).

It depends a bit on how many kernel APIs you need to call. The list of public kernel APIs is on MSDN, along with indicators of which can be called from usermode and which can't. You can also download the CE 6.0 or 7.0 source, including the kernel and pretty much all of the standard drivers, from Microsoft. WP7's kernel appears to be somewhere between the two, though, and is not available in source.

I may also take a break from working on the policy system to look at this; it sounds very interesting and would be a fun change. I've done a bit of kernel hacking on both CE and Linux (and NT. though I doubt that's relevant).
 
  • Like
Reactions: minDark and dcordes

Top Liked Posts

  • There are no posts matching your filters.
  • 80
    Hi
    * Please help keeping the noise level low: Don't ask for ETA (stuff will be anounced), use Thanks buttons to say thx, etc.
    * This will work on "fully unlocked" WP7 devices only and is not limited to specific phones

    thx, dcordes

    HaRET (Handhelds Reverse Engineering Tool) has been used on smartphones and PDAs with previous WinCE (Windows Mobile) versions to

    * boot the Linux kernel (=> use Linux based OS like Android)
    * obtain information about hardware and software (=> reverse engineering) in order to accordingly modify the Linux kernel (drivers).

    Famous HTC devices that are capable of running HaRET are the QSD8250 based HTC HD2 and a wide range of MSM7xxA based phones like the diamond, raphael and touch pro 2.

    WP7 is and will be shipped on many devices with quality hardware. In order to be able to run Linux on these, a novel aim is to investigate the use of HaRET on WP7 based devices. WP7 is known to posess several mechanisms to prevent this.

    A discussion about the problem has beend started on the official HaRET development mailing list by Jaxbot:
    http://lists.linuxtogo.org/pipermail/haret-devel/2012-January/000150.html
    You need to send a subscription mail in order to write to the list. The original creators of HaRET as well as many good developers with low level skills (from XDA: Cotulla, NetRipper, cr2) are subscribed to it but maybe not many of them have access to a WP7 device.

    HaRET source code repository with history:
    http://git.linuxtogo.org/?p=groups/haret/haret.git

    Documentation of the HaRET project (publicly accessible wiki):
    http://htc-linux.org/wiki/index.php?title=HaRET
    See http://htc-linux.org/wiki/index.php?title=HaRET/Documentation#Development for how to compile.

    We should discuss the technical possibilites and challenges (if any :cool:) about this project in this thread.

    Update: Lots of insight has been gained. Since progress is rapid, uptades are not listed here yet. Please read the full thread for now.
    8
    Delay

    Sorry for delay. I have got unused phone from last HaRET using, then I made:

    1. Full internal memory cleaning.
    2. SD card changing to 32GB class 10 (I can recommend it for everybody). One screw was lying on the table after the repair and I do not know where it belongs :).
    3. Data restoring (big thanks to Ultrashot).
    4. Actualisations (unfortunately, Microsoft is lying again, the phone with 8860+8862 updates under LockScreen very quickly discharged too, all livetiles closing helps only). I hope we will have WM6, Ubuntu or RT on our WP7 devices in near future. My very old S80 devices knew how much more and lasted a week on a single charge.
    5. Finishing WP7 native FTP Client library, you are welcome for testing.

    Next weak I have very much work in a occupation, but I hope I will send to Jessenic much HaRET updates next weakend.
    8
    VS

    Now I have got HaRET incremental version working under Visual Studio 2008. It is compiled by cygwin/make, deployed to device and started under debugger, all from VS IDE. All output (Warning, Information, Error) is redirected to VS Output window. For example now (instead MessageBox):
    ...
    KMD1: 0xD9456944 $device\KMD1 Drivers\BuiltIn\KMDriver $bus\KMD1
    ListRunningDrivers(KMD1:) returns HANDLE 0xD9456944
    Load module: toolhelp.dll
    WP7RunInKernelMode(kmodedll.dll, KGetProcInfo, 0x39F248, 1, 0x39F274, 576, 0x39F180, 198)
    DeviceIoControl returns 1
    Error: 'Haret is not running in 'system' mode. Major functionality will not be present.'
    Load module: WindowTreeUpdater.dll
    ...
    WP7VirtualAlloc, WP7VirtualFree, WP7VirtualCopy is used instead VirtualAlloc, VirtualFree, VirtualCopy. But, by error message, I mean a big part of cpu.cpp module must be tranfered to kmode_dll.cpp.

    PHP:
    // Get Program Status Register value
    static inline uint32 cpuGetPSR(void) {
        uint32 val;
        asm volatile("mrs %0, cpsr" : "=r" (val));
        return val;
    }
    
    unsigned long KcpuGetPSR(unsigned char * InStructurePointer,
    		unsigned long InStructureLength, unsigned char * OutStructurePointer,
    		unsigned long OutStructureLength) {
    
    	TRACE_SAVE(L"KcpuGetPSR(0x%X, %d, 0x%X, %d)\n", InStructurePointer,
    			InStructureLength, OutStructurePointer, OutStructureLength);
    
    	if (OutStructurePointer && sizeof(uint32) == OutStructureLength) 
    	{
    		uint32 * pRes = (uint32 *) OutStructurePointer;
    
    		*pRes = cpuGetPSR();
    
    		TRACE_SAVE(L"cpuGetPSR() returns 0x%X\n", *pRes);
    
    		return ERROR_SUCCESS;
    	}
    	return ERROR_INVALID_PARAMETER;
    }

    After it:
    ...
    KMD1: 0xD9456944 $device\KMD1 Drivers\BuiltIn\KMDriver $bus\KMD1
    ListRunningDrivers(KMD1:) returns HANDLE 0xD9456944
    Load module: toolhelp.dll
    WP7RunInKernelMode(kmodedll.dll, KGetProcInfo, 0x21EF248, 1, 0x21EF274, 576, 0x21EF180, 198)
    DeviceIoControl returns 1
    WP7RunInKernelMode(kmodedll.dll, KcpuGetPSR, 0x21EF378, 1, 0x21EF374, 4, 0x21EF2AC, 198)
    DeviceIoControl returns 1
    Load module: WindowTreeUpdater.dll
    ...


    KGetProcInfo(0x21F1CE4, 1, 0x21F1F00, 576)
    pinfo filled, GetProcInfo returns ERROR_SUCCESS
    wVersion = 1
    szProcessCore = Snapdragon
    wCoreRevision = 0
    szProcessorName = QSD8250
    wProcessorRevision = 0
    szCatalogNumber =
    szVendor = QUALCOMM
    dwInstructionSet = 0
    dwClockSpeed = 998
    KcpuGetPSR(0x21F5CE4, 1, 0x21F5F00, 4)
    cpuGetPSR() returns 0x2000011F

    KMD_Open
    KMD_Open
    KMD_IoControl entry, dwCode=9
    KMD_IoControl WP7_DLL_CALL, dwCode=9
    Function kmodedll.dll::KGetProcInfo returns 0
    KMD_IoControl returned 1
    KMD_IoControl entry, dwCode=6
    KMD_IoControl IOCTL_WP7_ALLOC_ADDRESS, dwCode=6
    Function VirtualAllocEx(0x42,0x0,65536,0x2000,0x1) returns D97A0000
    KMD_IoControl returned 1
    KMD_IoControl entry, dwCode=8
    KMD_IoControl IOCTL_WP7_COPY_ADDRESS, dwCode=8
    Function VirtualCopy(0xD97A0000,0xAC0000,65536,0x604) returns 1
    KMD_IoControl returned 1
    KMD_IoControl entry, dwCode=6
    KMD_IoControl IOCTL_WP7_ALLOC_ADDRESS, dwCode=6
    Function VirtualAllocEx(0x42,0x0,65536,0x2000,0x1) returns D9EE0000
    KMD_IoControl returned 1
    KMD_IoControl entry, dwCode=8
    KMD_IoControl IOCTL_WP7_COPY_ADDRESS, dwCode=8
    Function VirtualCopy(0xD9EE0000,0xA90000,65536,0x604) returns 1
    KMD_IoControl returned 1
    KMD_IoControl entry, dwCode=6
    KMD_IoControl IOCTL_WP7_ALLOC_ADDRESS, dwCode=6
    Function VirtualAllocEx(0x42,0x0,65536,0x2000,0x1) returns DA020000
    KMD_IoControl returned 1
    KMD_IoControl entry, dwCode=8
    KMD_IoControl IOCTL_WP7_COPY_ADDRESS, dwCode=8
    Function VirtualCopy(0xDA020000,0xA91000,65536,0x604) returns 1
    KMD_IoControl returned 1
    KMD_IoControl entry, dwCode=9
    KMD_IoControl WP7_DLL_CALL, dwCode=9
    Function kmodedll.dll::KcpuGetPSR returns 0
    KMD_IoControl returned 1


    Function kmodedll.dll::KFunctionName returns 0 means SUCCESS (nonzero is Error code),
    in other attempts nonzero means OK (zero is FALSE or 0 bytes).

    Console works for me now:
    NLEDSET 0 1 // Start vibration
    NLEDSET 0 0 // Stop vibration
    But very much directives must be reimplemented to driver calling still.


    Better way, then functions redefining by one, will DEF_GETCPR and DEF_SETCPR macros adjustment to kernel driver using.

    I tried to port PocketPutty for WM to communicate on WP7 device. But, Putty.exe not goes to WinMain function. Do you know anybody, why entrypoint may not be called? It is probably by missing linked dll or function in WP7.

    I tried also to connect from Silverlight Telnet client to second device with HaRET and WiFi internet tethering running. But, message is "he remote host is actively refusing a connection" on related IP (192.168.33.1) and all ports (not only 9999). Do you know anybody, if Telnet is theoretically available by WiFi tethered connection?
    8
    Thread Cleaned

    Please only post if you have something to contribute. Also please avoid posting thank you we have a "thanks" button for that.

    Stop with the ETA posts, it just annoys the good developers. Just be grateful for the work they do!​
    8
    does this work with devices unlocked with wp7 root tools??if yes, i will be always ready to test it on my omnia w..

    Prahlad

    Yes, I have got HaRET last version running in the Kernel mode with full hardware and physical memory access too. Any unlock needed. But, my HTC7Pro needed hard reset after this version using to unbrick, then I mean it is too danger when you like your phone. Only one function was succesfully tested before HR - Vibration On/Off low-level switching. I have idea to make HaRET safe equivalent, but the way needs to finish my other related projects and I am too busy now. No C++ coder here wants my unfinished codes? Especially shell/batch interpreter with registry export/import/backup and new directives simply adding (may be used for own macro language definition too), pipes for easy interprocess comunication (unmanged/managed too), native WP7 installer with plugins system and low-level system scheduler projects are near of finishing. Any C++ student with free time can finish it all relatively quickly.