Dear Sir,

I use PXA27X, PSM 3.8 and WINCE 5.0 to develop my project.

I try to save registry before system go into suspend. But it have some
problem.
The following is my test.

Test 1 :
I add RegFlushKey function in XXX_PowerDown();
But system sometime will hang up.

Original :
PowerDown(DWORD dwContext)
{
}

After:
PowerDown(DWORD dwContext)
{
RegFlushKey(HKEY_LOCAL_MACHINE);
RegFlushKey(HKEY_CLASSES_ROOT);
RegFlushKey(HKEY_CURRENT_USER);
RegFlushKey(HKEY_USERS);
}

Test 2:
I add RegFlushKey function in PM Driver , platform.cpp , Line 676.
But system sometime will hang up.

Original :
if((dwNewStateFlags & (POWER_STATE_SUSPEND | POWER_STATE_OFF |
POWER_STATE_CRITICAL | POWER_STATE_RESET)) != 0)
{
fSuspendSystem = TRUE;
}

After :
if((dwNewStateFlags & (POWER_STATE_SUSPEND | POWER_STATE_OFF |
POWER_STATE_CRITICAL | POWER_STATE_RESET)) != 0)
{
RegFlushKey(HKEY_LOCAL_MACHINE);
RegFlushKey(HKEY_CLASSES_ROOT);
RegFlushKey(HKEY_CURRENT_USER);
RegFlushKey(HKEY_USERS);
fSuspendSystem = TRUE;
}

Test 3:
I add RegFlushKey function in PM Driver , platform.cpp , Line 880.
But system sometime will hang up.

Original :
if(fSuspendSystem) {
// clear activity flags
ResetEvent(ghevUserActive);
ResetEvent(ghevSignalUserActivity);
ResetEvent(ghevSystemActive);
ResetEvent(ghevSignalSystemActivity);

// set a flag to notify the resume thread that this was
a controlled
// suspend
gfSystemSuspended = TRUE;

PMLOGMSG(ZONE_PLATFORM || ZONE_RESUME, (_T("%s: calling
PowerOffSystem()\r\n"), pszFname));
PowerOffSystem(); // sets a flag in the kernel
for the scheduler
Sleep(0); // so we force the scheduler to
run

After:
if(fSuspendSystem) {
// clear activity flags
ResetEvent(ghevUserActive);
ResetEvent(ghevSignalUserActivity);
ResetEvent(ghevSystemActive);
ResetEvent(ghevSignalSystemActivity);

// set a flag to notify the resume thread that this was
a controlled
// suspend
gfSystemSuspended = TRUE;

RegFlushKey(HKEY_LOCAL_MACHINE);
RegFlushKey(HKEY_CLASSES_ROOT);
RegFlushKey(HKEY_CURRENT_USER);
RegFlushKey(HKEY_USERS);

PMLOGMSG(ZONE_PLATFORM || ZONE_RESUME, (_T("%s: calling
PowerOffSystem()\r\n"), pszFname));
PowerOffSystem(); // sets a flag in the kernel
for the scheduler
Sleep(0); // so we force the scheduler to
run

Test4 :
I add RegFlushKey function in PM Driver , platform.cpp , Line 800.
But system sometime will hang up.

Original:
if(fSuspendSystem) {
......
......
......
FileSystemPowerFunction(FSNOTIFY_POWER_OFF);
gfFileSystemsAvailable = FALSE;

After:
if(fSuspendSystem) {
......
......
......
RegFlushKey(HKEY_LOCAL_MACHINE);
RegFlushKey(HKEY_CLASSES_ROOT);
RegFlushKey(HKEY_CURRENT_USER);
RegFlushKey(HKEY_USERS);
FileSystemPowerFunction(FSNOTIFY_POWER_OFF);
gfFileSystemsAvailable = FALSE;


Do anyone have idea about this issue ?

BR,
dirwdirw.tw

Re: How to save Resgitry before system go into suspend? by yflier

yflier
Tue Jul 25 06:12:34 CDT 2006

I think that you can:
1. Create a thread, register system power state transition
notification, if suspend, then call RegFlushKey function to flush;
2. Monitor your suspend key event in your keyboard driver;
3. If you want to modify PM, I think that it's best to modify
PmSetSystemPowerState in MDD;
4. Use OS's auto-flush mechanism;

And,
For XXX_PowerDown callbacks, in general, the power handler functions
are not allowed to make system calls."!Unrecoverable Error: Exception
or calling API inside Power Handler".
The function PlatformSetSystemPowerState do last system pm state
operation, some modules have been shutdown, it's not safe to call some
APIs. If flush registry in front of this function, may be get it.

Study it together!

dirw wrote:
> Dear Sir,
>
> I use PXA27X, PSM 3.8 and WINCE 5.0 to develop my project.
>
> I try to save registry before system go into suspend. But it have some
> problem.
> The following is my test.
>
> Test 1 :
> I add RegFlushKey function in XXX_PowerDown();
> But system sometime will hang up.
>
> Original :
> PowerDown(DWORD dwContext)
> {
> }
>
> After:
> PowerDown(DWORD dwContext)
> {
> RegFlushKey(HKEY_LOCAL_MACHINE);
> RegFlushKey(HKEY_CLASSES_ROOT);
> RegFlushKey(HKEY_CURRENT_USER);
> RegFlushKey(HKEY_USERS);
> }
>
> Test 2:
> I add RegFlushKey function in PM Driver , platform.cpp , Line 676.
> But system sometime will hang up.
>
> Original :
> if((dwNewStateFlags & (POWER_STATE_SUSPEND | POWER_STATE_OFF |
> POWER_STATE_CRITICAL | POWER_STATE_RESET)) != 0)
> {
> fSuspendSystem = TRUE;
> }
>
> After :
> if((dwNewStateFlags & (POWER_STATE_SUSPEND | POWER_STATE_OFF |
> POWER_STATE_CRITICAL | POWER_STATE_RESET)) != 0)
> {
> RegFlushKey(HKEY_LOCAL_MACHINE);
> RegFlushKey(HKEY_CLASSES_ROOT);
> RegFlushKey(HKEY_CURRENT_USER);
> RegFlushKey(HKEY_USERS);
> fSuspendSystem = TRUE;
> }
>
> Test 3:
> I add RegFlushKey function in PM Driver , platform.cpp , Line 880.
> But system sometime will hang up.
>
> Original :
> if(fSuspendSystem) {
> // clear activity flags
> ResetEvent(ghevUserActive);
> ResetEvent(ghevSignalUserActivity);
> ResetEvent(ghevSystemActive);
> ResetEvent(ghevSignalSystemActivity);
>
> // set a flag to notify the resume thread that this was
> a controlled
> // suspend
> gfSystemSuspended = TRUE;
>
> PMLOGMSG(ZONE_PLATFORM || ZONE_RESUME, (_T("%s: calling
> PowerOffSystem()\r\n"), pszFname));
> PowerOffSystem(); // sets a flag in the kernel
> for the scheduler
> Sleep(0); // so we force the scheduler to
> run
>
> After:
> if(fSuspendSystem) {
> // clear activity flags
> ResetEvent(ghevUserActive);
> ResetEvent(ghevSignalUserActivity);
> ResetEvent(ghevSystemActive);
> ResetEvent(ghevSignalSystemActivity);
>
> // set a flag to notify the resume thread that this was
> a controlled
> // suspend
> gfSystemSuspended = TRUE;
>
> RegFlushKey(HKEY_LOCAL_MACHINE);
> RegFlushKey(HKEY_CLASSES_ROOT);
> RegFlushKey(HKEY_CURRENT_USER);
> RegFlushKey(HKEY_USERS);
>
> PMLOGMSG(ZONE_PLATFORM || ZONE_RESUME, (_T("%s: calling
> PowerOffSystem()\r\n"), pszFname));
> PowerOffSystem(); // sets a flag in the kernel
> for the scheduler
> Sleep(0); // so we force the scheduler to
> run
>
> Test4 :
> I add RegFlushKey function in PM Driver , platform.cpp , Line 800.
> But system sometime will hang up.
>
> Original:
> if(fSuspendSystem) {
> ......
> ......
> ......
> FileSystemPowerFunction(FSNOTIFY_POWER_OFF);
> gfFileSystemsAvailable = FALSE;
>
> After:
> if(fSuspendSystem) {
> ......
> ......
> ......
> RegFlushKey(HKEY_LOCAL_MACHINE);
> RegFlushKey(HKEY_CLASSES_ROOT);
> RegFlushKey(HKEY_CURRENT_USER);
> RegFlushKey(HKEY_USERS);
> FileSystemPowerFunction(FSNOTIFY_POWER_OFF);
> gfFileSystemsAvailable = FALSE;
>
>
> Do anyone have idea about this issue ?
>
> BR,
> dirwdirw.tw


Re: How to save Resgitry before system go into suspend? by Bruce

Bruce
Wed Jul 26 12:05:14 CDT 2006

Are you using Hive based registry? If so this is automatic.

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member

"dirw" <dirwdirw.tw@yahoo.com.tw> wrote in message
news:1153820266.154302.235270@i42g2000cwa.googlegroups.com...
> Dear Sir,
>
> I use PXA27X, PSM 3.8 and WINCE 5.0 to develop my project.
>
> I try to save registry before system go into suspend. But it have some
> problem.
> The following is my test.
>
> Test 1 :
> I add RegFlushKey function in XXX_PowerDown();
> But system sometime will hang up.
>
> Original :
> PowerDown(DWORD dwContext)
> {
> }
>
> After:
> PowerDown(DWORD dwContext)
> {
> RegFlushKey(HKEY_LOCAL_MACHINE);
> RegFlushKey(HKEY_CLASSES_ROOT);
> RegFlushKey(HKEY_CURRENT_USER);
> RegFlushKey(HKEY_USERS);
> }
>
> Test 2:
> I add RegFlushKey function in PM Driver , platform.cpp , Line 676.
> But system sometime will hang up.
>
> Original :
> if((dwNewStateFlags & (POWER_STATE_SUSPEND | POWER_STATE_OFF |
> POWER_STATE_CRITICAL | POWER_STATE_RESET)) != 0)
> {
> fSuspendSystem = TRUE;
> }
>
> After :
> if((dwNewStateFlags & (POWER_STATE_SUSPEND | POWER_STATE_OFF |
> POWER_STATE_CRITICAL | POWER_STATE_RESET)) != 0)
> {
> RegFlushKey(HKEY_LOCAL_MACHINE);
> RegFlushKey(HKEY_CLASSES_ROOT);
> RegFlushKey(HKEY_CURRENT_USER);
> RegFlushKey(HKEY_USERS);
> fSuspendSystem = TRUE;
> }
>
> Test 3:
> I add RegFlushKey function in PM Driver , platform.cpp , Line 880.
> But system sometime will hang up.
>
> Original :
> if(fSuspendSystem) {
> // clear activity flags
> ResetEvent(ghevUserActive);
> ResetEvent(ghevSignalUserActivity);
> ResetEvent(ghevSystemActive);
> ResetEvent(ghevSignalSystemActivity);
>
> // set a flag to notify the resume thread that this was
> a controlled
> // suspend
> gfSystemSuspended = TRUE;
>
> PMLOGMSG(ZONE_PLATFORM || ZONE_RESUME, (_T("%s: calling
> PowerOffSystem()\r\n"), pszFname));
> PowerOffSystem(); // sets a flag in the kernel
> for the scheduler
> Sleep(0); // so we force the scheduler to
> run
>
> After:
> if(fSuspendSystem) {
> // clear activity flags
> ResetEvent(ghevUserActive);
> ResetEvent(ghevSignalUserActivity);
> ResetEvent(ghevSystemActive);
> ResetEvent(ghevSignalSystemActivity);
>
> // set a flag to notify the resume thread that this was
> a controlled
> // suspend
> gfSystemSuspended = TRUE;
>
> RegFlushKey(HKEY_LOCAL_MACHINE);
> RegFlushKey(HKEY_CLASSES_ROOT);
> RegFlushKey(HKEY_CURRENT_USER);
> RegFlushKey(HKEY_USERS);
>
> PMLOGMSG(ZONE_PLATFORM || ZONE_RESUME, (_T("%s: calling
> PowerOffSystem()\r\n"), pszFname));
> PowerOffSystem(); // sets a flag in the kernel
> for the scheduler
> Sleep(0); // so we force the scheduler to
> run
>
> Test4 :
> I add RegFlushKey function in PM Driver , platform.cpp , Line 800.
> But system sometime will hang up.
>
> Original:
> if(fSuspendSystem) {
> ......
> ......
> ......
> FileSystemPowerFunction(FSNOTIFY_POWER_OFF);
> gfFileSystemsAvailable = FALSE;
>
> After:
> if(fSuspendSystem) {
> ......
> ......
> ......
> RegFlushKey(HKEY_LOCAL_MACHINE);
> RegFlushKey(HKEY_CLASSES_ROOT);
> RegFlushKey(HKEY_CURRENT_USER);
> RegFlushKey(HKEY_USERS);
> FileSystemPowerFunction(FSNOTIFY_POWER_OFF);
> gfFileSystemsAvailable = FALSE;
>
>
> Do anyone have idea about this issue ?
>
> BR,
> dirwdirw.tw
>