php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39773 WinAPI - shell_exec() - FindWindowA
Submitted: 2006-12-07 22:49 UTC Modified: 2008-05-12 11:11 UTC
From: sobieh at gmail dot com Assigned: pajoye (profile)
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.0 OS: Windows 2003 Server
Private report: No CVE-ID: None
 [2006-12-07 22:49 UTC] sobieh at gmail dot com
Description:
------------
Shell_Exec - FindWindowA BUG

MyApp.exe is a C++ written console application.
It usues FindWindowA WinAPI function.

When i start MyApp.exe normally it founds desired window
but when i run MuApp.exe by shell_exec command in PHP 
it can't find Any window even 'explorer'.

i tried to run it on php 5.1.0
and works great but on 5.2.0 not
so i think its a BUG.

Reproduce code:
---------------
<?
   echo shell_exec('myapp.exe');
?>

Expected result:
----------------
should return FindWindowA result by MyApp.exe
as String.

Actual result:
--------------
null

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-08 09:13 UTC] tony2001@php.net
What kind of Server API are you using?
 [2006-12-08 15:31 UTC] sobieh at gmail dot com
Apache 2.0.5 for Win32
 [2006-12-08 15:43 UTC] tony2001@php.net
I mean Server API, not web-server.
Open phpinfo() and at the top of the page you should see "Server API: ..." line.
 [2006-12-08 15:54 UTC] sobieh at gmail dot com
Apache 2.0 Handler

the most wired thing is :

php.exe test_myapp.php
works.

but shell_exec('myapp.exe');
not.
 [2006-12-08 16:21 UTC] tony2001@php.net
Why do you think your Apache service is run as a user who has enough privileges to access windows of other users?
AFAIK by default Apache service uses least privileged system account possible.
See here: http://httpd.apache.org/docs/2.2/platform/windows.html
 [2006-12-08 17:57 UTC] sobieh at gmail dot com
im using Administrator account.

i told :
PHP 5.1.0 WORKS
PHP 5.2.0 NOT WORKS

so there is something wrong with apache handler.
because the same script works on 5.2.0 by php.exe script.php
and not works by Apache and on 5.1.0 works in both ways.
 [2006-12-08 18:03 UTC] tony2001@php.net
YOU are using Administrator account, but your Apache does not.
 [2006-12-08 18:12 UTC] sobieh at gmail dot com
omg dont treat me like an idiot please

Apache2 Service in using Root Administrator account.
everything is using this account because its the ONLY ACCOUNT on this PC.

i checked it twice.
Apache is is using Administrator account.
and its RUNNING on this Account.

how many times i can tell that PHP 5.1.0 and ANY other version of PHP can run that script without any problem and ONLY PHP 5.2.0 CAN'T.
as Apache Module - CAN'T
as CGI - CAN'T
 [2006-12-08 18:26 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2006-12-08 18:42 UTC] sobieh at gmail dot com
You can download FindNotepad.exe here :
http://www.sendspace.com/file/3g0lrf

Usage :
Run Notepad.exe and then :

<?
  echo shell_exec ('FindNotepad.exe');
?>

FindNotepad.exe returns :
if found - FOUND Notepad Window - HWND [HWND]
if not - CANNOT FIND Notepad Window

as String in Console window then Terminates.
 [2006-12-09 23:05 UTC] sobieh at gmail dot com
I created own php extension with that function and other WinApi (because you removed w32api) so i don't need that EXE anymore.

anyway try to fix that bug.
 [2008-05-12 10:02 UTC] pajoye@php.net
See pecl.php.net for any w32api bugs or requests, given that is not maintained anymore, do not expect too much.
 [2008-05-12 10:58 UTC] sobieh at gmail dot com
I reported that 2 years ago and i don't expect anything.
 [2008-05-12 11:11 UTC] pajoye@php.net
I already noticed that but we still have to clean the bug DB.

However, you may be interested to maintain the extension in PECL as you seem to use it (or replace with your own version, or begin a new one, etc.), that's how OS works.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC