Triggering Windows TDR (Timeout Detection and Recovery) - windows-7

I'm developing a Direct3D9Ex application, and some of my users are having problems with recovery after a TDR event. In order to fix that I need to test it on my machine, but to do that I need a way to trigger a TDR event on demand.
What's the best way to do that?

I was looking into doing the same and found the command DxgkDdiResetFromTimeout (https://msdn.microsoft.com/en-us/library/windows/hardware/ff559815(v=vs.85).aspx)
I have not attempted to implement it though.

Related

how to initialization script C++ before windows shutdown

i have no ideal for initialization code c++ before windows shutdown. For protect algorithm of my code when running. Any ideal here?
I am not sorry to report you cannot do this reliably. You can handle WM_QUERYENDSESSION or WM_ENDSESSION Windows messages, but that really traps logoff not shutdown. Alternately you could try a Windows service and react to the stop signal. But that is exactly that, your service being stopped.
HOWEVER; none of this happens reliably. If you have some defenses best broken by the shutdown code not running, somebody who wants to break them will just power the machine off. If I thought you were writing software that needed to be fault tolerant I would now advise you on crash-only software.
To make a backing store that can survive being powered off without being corrupted, the cheapest way is to use sqlite.
I think you should create an object of your own class and write something inside the destructor (or ~YourClass()).

DeviceUseTrigger doesn't result in long running background task

I'm using DeviceUseTrigger to get a "near-permanent" connection to the Microsoft Band. Explained in http://www.codeproject.com/Tips/1036512/Achieveing-Indefinite-Background-Execution-with-th
The method, described in the codeproject article, works perfectly in debug mode (without draining the battery). But running my app from the store results in a stopped backgroundtask; Windows 10 mobile stops the task due to some failing OS policy condition.
Does anybody found a workaround for this backgroundtask restrictions?
Microsoft Band does not initiate connections with channel A502CA9A-2BA5-413C-A4E0-13804E47B38F. Given that, we are uncertain what causes such RFCOMM trigger to start the background task.
Overall, today there is no supported way to solve this problem on Microsoft Mobile in RFCOMM trigger way using only the Band. Any successful experiments would hurt the behavior of Health Application.
What can help is any other device opening RFCOMM connection to the phone and a trigger set up for that connection.
Besides that it is not clear what "works perfectly in debug mode" means. When Visual Studio debugger is attached, the background tasks stay, helping the developer. Without debugger they get cancelled by OS.

How to simulate windows service crush

I have very basic question, How to simulate windows service crush,
I found a way how to set the rules of a service to restart himself in case of failure,
Now I just want to check it,
I don't want to add code to my projects (I have 3) to simulate the crush, I prefer to simulate it from external,
I prefer so generic solution.
Thanks.
Possibilities:
manually locate the .exe of the service in Task Manager and terminate it
programmatically locate the service process and use the WINAPI TerminateProcess()

Windows service stops working, recycling fixes it

I have a windows service that has a timer that fires a method every 30 seconds.
The method then calls thread.sleep() and when it finishes it calls thread.start();
All code in the method is wrapped in a try/catch except for the calls to the tread sleep/start.
For some reason the service stops working, but if I recycle it or set it to recycle upon a crash it works fine.
How can I diagnose the problem?
Is there other events like OnCrash or somethign that I can hook into to dig into the stack trace?
A windows service is just the same as a normal application, it's just executed differently. So ask yourself if your normal app didn't crash, but stopped working what could cause it? Lots of things spring to mind like locking issues, concurrency issues etc...
There is no OnCrash event though but what I do for Windows Services is put all logic in a seperate assembly with a simple start method and that way I can host it in a console application and do testing easily and moving to a windows service is also not too hard.
Your other option is to attach the Visual Studio debugger to the Windows service and debug as normal.
No, there aren't, but why not just put in a try/catch yourself and log the exception when it occurs?
Also, I find the call to Sleep and Start very dubious. You shouldn't be using these calls in general for synchronization. Why are you making these calls?
I think first and foremost you need to find the reasons why it is crashing. OnCrash? well, if it crashed it won't have much to say, I guess.
Its the timer!.
Get rid of it and your problem will be solved.
Check this post for more info .
You are better off doing the operation like this...
While (stopSignal = False)
'do your work'
Thread.Sleep(yourInterval)
End While
EDIT: If you want to debug a service and not have to suffer through attaching a debugger, then do this.
Whether you disagree with this or not, MS has confirmed that its a bug, and removing the timer is the only way to avoid this problem. You should also not be using exceptions as program flow control (Catch and Retry) if you can help it.
You can use Microsoft's Debug Diagnostic Tool v1.1 to monitor a service and create a dump when it crashes. Then you can debug the dump.
http://www.microsoft.com/download/en/details.aspx?id=24370

How to make computer return from standby mode

I would like my computer to do specific tasks periodically or at a specific time.
Such as:
to wake up each 15 minutes, connect to the Internet, check e-mail, beep (if there is unread mail), then go standby again
to wake up at 8 am and play music
In the best case, it should be asleep and therefore, silent and going low-power.
It's no problem to make it connect or check the mail, but how to make it wake up ... ?
Do you happen to know the software to achieve this or windows API to use ?
I feel like there is one, but I failed to find it.
WakeUpOnStandBy (Windows)
CreateWaitableTimer
SetWaitableTimer
SetSuspendState to enter the suspended state.
CancelWaitableTimer
More info for example here.
Other alternatives require some more hardware support - like for example the Wake-On-Lan feature or IPMI.
Some computers have options like what you want in BIOS. I don't believe there's any way without BIOS support. Once your computer is asleep there's no programmatic way for it to wake up, since any such program is asleep...

Resources