powercfg returns different results depending on 32-bit vs. 64-bit version - c++

I was trying to call powercfg tool from my 32-bit application running on a 64-bit version of Windows 8.1 using CreateProcess with the following command as lpCommandLine parameter:
"powercfg -waketimers"
It worked fine, except that purely by chance I discovered that it was returning a different looking report than if I ran the same from the Command Line window.
Here's what I was getting in my 32-bit process:
Timer set by [PROCESS] Legacy Kernel Caller expires at 4:00:02 AM on 1/20/2016.
Reason:
Timer set by [PROCESS] Legacy Kernel Caller expires at 3:59:00 AM on 1/20/2016.
Reason:
and here's what I was seeing in Command Line window:
Timer set by [SERVICE] \Device\HarddiskVolume4\Windows\System32\svchost.exe (SystemEventsBroker) expires at 4:00:02 AM on 1/20/2016.
Reason: Windows will execute 'NT TASK\Microsoft\Windows\TaskScheduler\Regular Maintenance' scheduled task that requested waking the computer.
Timer set by [SERVICE] \Device\HarddiskVolume4\Program Files (x86)\Common Files\Acronis\Schedule2\schedul2.exe (AcrSch2Svc) expires at 3:59:00 AM on 1/20/2016.
So I'm curious, are 32-bit and 64-bit versions of that tool supposed to return different results? Because the only way I can remedy this and get a full report (2nd version above) from my 32-bit process is to detect it running as WOW64 and then use the following path for a forced 64-bit redirect:
"C:\\Windows\\SysWow64\\powercfg.exe -waketimers"

Related

Get user events from VTune doesn't work with attach to process

TLDR;
I am attempting to run a command line vtune attach to process analysis for some instrumented code with the application instrumentation lib supplied by intel. I have succeeded, in collecting user events when running within the vtune application (both command line and GUI). When I use -target-pid command line option to connect to the same application, user events do not show up in the profile. The environment setup suggested in the instructions for attaching to a process does not work.
The long version
I have broken this down again and again, and i have hit the minimum amount of things going on here. I am running Ubuntu 20.04 with intel vtune installed as part of the oneapi installer package. I have built an example application, which i can share, but it basically spawns threads and does some random computations. I have instrumented the code with itt as such:
#include <ittnotify.h>
__itt_event cloud_in_event = __itt_event_create( "CloudIn", 7 );
...
void add() {
__itt_event_start( cloud_in_event );
...
This works correctly when run through the gui. Aka, i compile my application with the following:
g++ -g -O3 -fno-asm -std=c++17 -I/opt/intel/oneapi/vtune/latest/sdk/include -DUSE_THR example.cpp -g -o ./example -lpthread -lm -L/opt/intel/oneapi/vtune/2021.4.0/sdk/lib64 -littnotify -ldl -D_LINUX
I start the gui using:
. /opt/intel/oneapi/setvars.sh && vtune-gui &
Run it using the cpu hotspot analysis in hw mode. The application runs and i get this in the output:
Yay, my user event is there. All is well.
The equivalent command line also works:
/opt/intel/oneapi/vtune/2021.4.0/bin64/vtune -collect hotspots -knob sampling-mode=hw -knob stack-size=0 -app-working-dir /home/development/example/example --app-working-dir=/home/development/example/example -- /home/development/hovermap/example/example
However, if i run the application on its own (using the correct setup for the link path in the environment variables for INTEL_LIBITTNOTIF), then attach with the GUI to that process (or with the command line). There are no user events (aka, the CloudIn event in the above image) in the profiler data.
If I print out the environment variables in the application, there are quite vast differences in the environments when profiling directly, vs when attaching. For example, there is the following:
INTEL_JIT_PROFILER32=/opt/intel/oneapi/vtune/2021.4.0/lib32/runtime/libittnotify_collector.so
INTEL_JIT_PROFILER64=/opt/intel/oneapi/vtune/2021.4.0/lib64/runtime/libittnotify_collector.so
ENABLE_JITPROFILING=1
Exists in the gui based run environment, but the setup instructional says nothing about these environment variables. I have also tried setting them with no luck.
Any ideas what extra stuff i need to set up?
If you want to attach to application that uses ITT API you need to set up additional environment variables before running it, for example:
export INTEL_LIBITTNOTIFY32=/opt/intel/oneapi/vtune/2021.4.0/lib64/runtime/libittnotify_collector.so
export INTEL_LIBITTNOTIFY64=/opt/intel/oneapi/vtune/2021.4.0/lib64/runtime/libittnotify_collector.so
./example
These environment variables are described in Attach ITT APIs to a Launched Application help topic in VTune User Guide.

Selenium Command line server for the IEDriverServer has stopped working App Crash error

I have a Selenium Python automated regression test script running on our 64bit Server on IE11, Windows Server 2008. Everytime when the test gets about half way through an error dialog appears and the test stops. The error is:
Command line server for the IEDriverServer has stopped working
The full trace is:
Problem signature:
Problem Event Name: APPCRASH
Application Name: IEDriverServer.exe
Application Version: 2.53.0.0
Application Timestamp: 56e9abe3
Fault Module Name: IEDriverServer.exe
Fault Module Version: 2.53.0.0
Fault Module Timestamp: 56e9abe3
Exception Code: 40000015
Exception Offset: 000000000001877a
OS Version: 6.1.7601.2.1.0.272.7
Locale ID: 2057
Additional Information 1: 9d60
Additional Information 2: 9d60a3c1cb1d5911598c0ff40a26278a
Additional Information 3: 1ee9
Additional Information 4: 1ee9da2f8e2415daed3ffe0e1066b74e
Anyone know why the IEDriverServer is crashing?
On our 32bit server the tests runs ok all the way to the end. Over 230 test cases. But on our 64bit server the App Crash error appears half way through.
I have set the registry DWORD value:
For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.
IEDriverServer.exe is also in my Path
And also i notice in Task Manager iexplore.exe it's memory usage is 2.95GB
Is this normal? The memory seems really high.
Does Selenium need over 2.95GB of memory to run the tests in IE11?
Thanks, Riaz
If you are using 32bit IEDriverServer.exe for 64Bit OS then you switch over to 64 Bit IEDriverServer.exe because there could be reason of mismatch 32bit to 64 bit combination behind crashing of IE driver, and now if using 64 bit IEdriverserver.exe and you are having slow typing issue then to overcome this issue for 64bit exe over IE 11 browser Follow these steps:-
Internet Options -> Security -> Check "Enable Protected Mode" for all zone
Go to Advanced -> Security -> Check "Enable Enhanced Protected Mode"
this works for me. Cheers!

qtdbus under windows 7

CONFIGURATION
I have this configuration:
QT Community 5.4.1
dbus-daemon.exe downloaded from http://sourceforge.net/projects/windbus/
link
I have copied in my local directory these qt example:
c:\Qt\Qt5.4.1\Examples\Qt-5.4\dbus\remotecontrolledcar\car
c:\Qt\Qt5.4.1\Examples\Qt-5.4\dbus\remotecontrolledcar\controller
I use Windows 7 and NOT Linux!!!!!!
Procedure:
I compiled both examples in debug mode in my local directory
I launched dbus-daemon.exe with these parameters:
DBUS_SESSION_BUS_ADDRESS sets to tcp; host sets to localhost,port sets to 12434.
set DBUS_SYSTEM_BUS_DEFAULT_ADDRESS=tcp:host=localhost,port=12434
dbus-daemon.exe --session --system --config-file=.\etc\session.conf
I execute car.exe
I execute controller.exe
PROBLEM
The dbus connection fails in particular the method sessionBus form DBusConnection class fails. Infact when i call the isConnected method, it returns false.
Someone can explain why? Is it wrong the way I call the daemon executable?
Or Qt Comunity 5.4.1 have problem with qtdbus? can someone pass me a correct configuration file (session.conf)?
Thank you very much for for the support.
Fausto

Compiling on Vortex86: "Illegal instruction"

I'm using an embedded PC which has a Vortex86-SG CPU, Ubuntu 10.04 w/ kernel 2.6.34.10-vortex86-sg. Unfortunately we can't compile a new kernel, cause we don't have any source code, not even drivers or patches.
I have to run a small project written in C++ with OpenFrameworks. The framework compiles right each script in of_v0071_linux_release/scripts/linux/ubuntu/install_*.sh.
I noticed that in order to compile against Vortex86/Ubuntu 10.04, the following options must be added in every config.make file:
USER_CFLAGS = -march=i486
USER_LDFLAGS = -lGLEW
In effects, it compiles without errors, but the generated binary doesn't start at all:
root#jb:~/openframeworks/of_v0071_linux_release/apps/myApps/emptyExample/bin# ./emptyExample
Illegal instruction
root#jb:~/openframeworks/of_v0071_linux_release/apps/myApps/emptyExample/bin# echo $?
132
Strace last lines:
munmap(0xb77c3000, 4096) = 0
rt_sigprocmask(SIG_BLOCK, [PIPE], NULL, 8) = 0
--- SIGILL (Illegal instruction) # 0 (0) ---
+++ killed by SIGILL +++
Illegal instruction
root#jb:~/openframeworks/of_v0071_linux_release/apps/myApps/emptyExample/bin#
Any idea to solve this problem?
I know I am a bit late on this but I recently had my own issues trying to compile the kernel for the vortex86dx. I finally was able to build the kernel as well. Use these steps at your own risk as I am not a Linux guru and some settings you may have to change to your own preference/hardware:
Download and use a Linux distribution that runs on a similar kernel version that you plan on compiling. Since I will be compiling Linux 2.6.34.14, I downloaded and installed Debian 6 on virtual box with adequate ram and processor allocations. You could potentially compile on the Vortex86DX itself, but that would likely take forever.
Made sure I hade decencies: #apt-get install ncurses-dev kernel-package
Download kernel from kernel.org (I grabbed Linux-2.6.34.14.tar.xz). Extract files from package.
Grab Config file from dmp ftp site: ftp://vxmx:gc301#ftp.dmp.com.tw/Linux/Source/config-2.6.34-vortex86-sg-r1.zip. Please note vxmx user name. Copy the config file to freshly extracted Linux source folder.
Grab Patch and at ftp://vxdx:gc301#ftp.dmp.com.tw/Driver/Linux/config%26patch/patch-2.6.34-hda.zip. Please note vxdx user name. Copy to kernel source folder.
Patch Kernel: #patch -p1 < patchfilename
configure kernel with #make menuconfig
Load Alternate Configuration File
Enable generic x86 support
Enable Math Emulation
I disabled generic IDE support because I will using legacy mode(selectable in bios)
Under Device Drivers -> Ethernet (10 or 100Mbit) -> Make sure RDC R6040 Fast Ethernet Adapter Support is selected
USB support -> Select Support for Host-side USB, EHCI HCD (USB 2.0) support, OHCI HCD support
safe config as .config
check serial ports: edit .config manually make sure CONFIG_SERIAL_8250_NR_UARTS = 4 (or more if you have additional), CONFIG_SERIAL_8250_RUNTIME_UARTS = 4(or more if you have additional). If you are to use more that 4 serial ports make use config_serail_8250_MANY_PORTs is set.
compile kernel headers and source: #make-kpkg --initrd kernel_image kernel_source kernel_headers modules_image

How can I execute a program from my VS2008/C++ application in windows that replaces the caller and runs on xp/vista/7?

My application downloads updates from a server. After downloading it runs updater.exe (which is set to run with administrative rights) so it can copy the update foo.exe over my application. Since you can't replace the file while it runs the helper application is necessary.
I am making the following system call to run it:
result=_execl(updaterexe,updaterstr,updateFilestr,exeFilestr,exeFilestr,NULL);
The parameters contained:
c:\program files\foo\updater.exe "c:\program files\foo\updater.exe" "c:\downloads\newfoo.exe" ""c:\program files\foo\foo.exe"
Under vista this works as expected.
Under windows 7 it returns error code 22 which is invalid parameter. I have also tried quoting the first parameter to no avail. Suspecting that maybe the old _execl was not supported on windows 7 I tried adjusting all the parameters and calling _wexecl but with no change in behaviour.
Can anyone suggest a correction to the call I'm making or suggest a different system call that will work consistently between versions of windows?
There are plenty of other alternatives, any of which would work from Windows 95 up:
CreateProcess() // Recommended Win32 API
ShellExecute ()
system ()