|
I’m writing telnet program. All chars I get from client socket (except telnet commands of course) I pass to command.com/cmd.exe (running in separate process).
Problem is: when client passes “regedit.exe” for instance – it is run on server machine ( !!) which is not what I intended …..
So the question is: HOW to protect from running GUI programs by my command interpreter?
(I’m pretty sure it can be done ... in pure DOS you can see the message “This program can not be run in DOS mode … this is what I want)
Please HELP
|
|
|
|
|
You mean you're writing a telnet _server_.
But anyway, that's not necessarily a bad thing to run windows apps. For remote administration I find it useful to run, for example, "shutdown.exe /l /r /c /y /t:60" from the NT Reskit via telnet or remote shell, which I believe is a non-console app.
|
|
|
|
|
No, it cannot be done, at least not in a simple way.
There is no "pure DOS" in the modern Windows. cdm.exe executes both Windows and DOS programs.
As far as I know the only way to distinguish between a Win32 console (DOS-like) and Win32 GUI executable is to follow its WinAPI function calls AFTER it was executed or to perform a kind of reverse engineering to know which DLLs and functions supposed to be used by this executable.
Another way (not suitable but still) is to enumerate all windows in the executed process and detect the console window.
--
Best Regards,
Andrew
|
|
|
|
|
If you have control over which programs are run (ie. it's not by cmd.exe ), then you can read the subsystem from the .EXE file header to determine if it's a GUI program or a console program before you run it. I don't have time to go into the specifics here, but look up the PE file format on MSDN.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello, everyone!
I find even if I use signal(SIGCLD,SIG_IGN), I can not prevent
child process from becoming zombie process. I have used ps -aux
to check the result.
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
pid_t pid;
signal(SIGCLD,SIG_IGN);
pid = fork();
if(pid)
{
sleep(20); // parent sleep
}
else //child exit
{
exit(1);
}
return 1;
}
Can anyone help?
Thanks in advance,
George
|
|
|
|
|
The result of signal (SIGCLD, SIG_IGN) varies depending on the system. A better solution is to use 'sigaction' with the SA_NOCLDWAIT flag - this stops a child sending the SIGCLD signal in the first place, and works on all systems (as far as Im aware). 'sigaction' is also more preferred to signal, so its worth looking into it more
|
|
|
|
|
Thanks, Johnny buddy!
Can 'sigaction' also prevent a child process from becoming zombie process?
Can you show me a simple example?
regards,
George
|
|
|
|
|
Yes, the SA_NOCLDSTOP flag means that no signal will be raised by the child when it stops, and this should be consistent across different flavours of Unix (check the man page to be sure - it should have been in Linux for several years now)
Its more work to setup, but its a lot more powerful version of signal. You can use it like this:
sigaction sig;<br />
<br />
sigemptyset (&sig);<br />
sig.sa_flags = SA_NOCLDSTOP;<br />
sig.sa_handler = SIG_IGN;<br />
<br />
sigaction (SIGCHLD, &sig, NULL);
|
|
|
|
|
Thanks, Johnny buddy!
I have tried your code, but it does not work. Here is all my sample
code,
Source code:
--------
#include <signal.h>
#include <sys types.h="">
#include <unistd.h>
int main(void)
{
struct sigaction sig;
pid_t pid;
sigemptyset (&sig);
sig.sa_flags = SA_NOCLDSTOP;
sig.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sig, NULL);
//signal(SIGCLD,SIG_IGN);
pid = fork();
if(pid)
{
sleep(20); // parent sleep
}
else //child exit
{
exit(1);
}
return 1;
}
--------
Here is what I noticed from ps - aux during the running time of the process,
Output:
--------
root 10914 0.0 0.1 1372 280 pts/0 S 19:47 0:00 ./SigZombie
root 10915 0.0 0.0 0 0 pts/0 Z 19:47 0:00 [SigZombie
|
|
|
|
|
The above will work on Solaris, but I have not tried it on Linux. Rather than go to all this hassle of trying to avoid dealing with the SIGCHLD I think the easiest thing is going to be actually handle the signal and call waitpid on the child. Not only will this stop zombies, but its the cleanest and most portable, and you can get all sorts of information back from the child (esp if you use sigaction).
|
|
|
|
|
Thanks, for your advice Johnny buddy!
Thanks, Johnny buddy!
What do you mean "will work"? Do you mean you can not see "defunc" process from "ps -aux"?
I have referenced some materials, and write a sample from your idea, but it does not work. (still can see "defunc" process from "ps -aux")
Source Code:
--------
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
struct sigaction sig;
pid_t pid;
sigemptyset (&sig.sa_mask);
sig.sa_flags = SA_NOCLDSTOP;
sig.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sig, NULL);
//signal(SIGCLD,SIG_IGN);
pid = fork();
if(pid)
{
sleep(20); // parent sleep
}
else //child exit
{
exit(1);
}
return 1;
}
--------
Can you help?
regards,
George
|
|
|
|
|
hi there..
thanks for your time firstly..
i am having a strange problem in the invoke of my IDispatch..
This method is called from the get property of an aX control.
When i call this get method, i dont seem to get any return vaule in the pvarresult variable..
any suggestions..
here is the method:
double CControl:: GetNumber(long nRow, long nCol)
{
DISPPARAMS DispParam1;
EXCEPINFO excep;
UINT nArgErr;
VARIANT pVarResult;
double temp;
DispParam1.cArgs = 2; //number of arguments
DispParam1.cNamedArgs = 0;// Number of named arguments.
DispParam1.rgvarg = new VARIANTARG[2];
DispParam1.rgvarg->vt = VT_ARRAY;
DispParam1.rgvarg[1].vt = VT_I4;
DispParam1.rgvarg[1].lVal = nRow;
DispParam1.rgvarg[0].vt = VT_I4;
DispParam1.rgvarg[0].lVal = nCol;
IImpl::Invoke(DISPID_Number , IID_NULL , 0 , DISPATCH_PROPERTYGET, &DispParam1, &pVarResult , &excep, &nArgErr);
temp = pVarResult.dblVal;
//delete [] DispParam1.rgvarg;
return temp;
}
|
|
|
|
|
try to VariantInit the result variant.
VariantInit( &pVarResult );
this can help (and if not, it's anyway better)
|
|
|
|
|
thanks
kindest regards
|
|
|
|
|
Hello
I'm developing my own controls library and want to implement Office XP menu support, but there is a promblem: I don't know how to calculate appropriate colors. I took a look at ProfUIS, GuiLib, CMenuXP and few other libraries and controls and everybody calculate colors in his own way, but in wrong way. Such applications as SmartFTP, ASP.NET Web Matrix, PHP Expert Editor, etc does the same.
Only one library calculate correct colors. It is Xtreme Toolkit by Codejock Software.
Can anybody help me?
__________________________________________________
Best regards,
v0id
|
|
|
|
|
If the xp colors work and they have no trouble in errors or anything else and are pretty efficient then it really doesn't matter if you use the classes or not. Just first get their permission to use their code and ideas.
[It is possible to represent everything in this universe by using 0 and 1]
I'm going to live forever or die trying.
|
|
|
|
|
I'm new in the programming for Windows (but have few year expirence in programming for Unix).
My app will be work with unlimit number of grouped object. Each object consists of predefined number of text fields and unlimited number of accociated binary objects.
The database will support only one client/database builder.
I can build the db by simply creating directory structure but is there any solution to do this by using Access datafiles of something like that?
|
|
|
|
|
Have a look a this link [^].
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Mastering MFC Development Using Microsoft Visual C++ 6
Chapter 7: Using OLE DB Templates for Data Access
Chapter 8: Creating ADO Database Applications
M$PRESS
|
|
|
|
|
Hello all,
I'm writing a quick/dirty class wrapper for the Win32 MDI API. After developing most of the code, I came across this article by Jason Henderson, who has done the same thing, and found my code was about 99% identical . I am using the same strategy of calling CreateWindow and passing 'this' in lParam, then using SetWindowLong/GetWindowLong in WndProc to store/retrieve the class pointer in the HWND.
My code successfully creates a Frame, Client, and Child windows. However, for some reason when creating the Child window, the class pointer in lParam gets corrupted when the WndProc tries to retreive it from the CREATESTRUCT. In the debugger lParam is 0x00891030, then in WndProc it retrieves 0x0012fcfc every time.
How can this happen? I'm creating the Frame and Child WndProc's the exact same way, so why would the Child have this problem?
Thanks for reading.
|
|
|
|
|
For the archives, I was able to work around this problem by using the WM_MDICHILD message instead of CreateMDIWindow or CreateWindowEx. I can't explain why it works, but it now works like a charm.
If anyone can shed light, I would appreciate it. One day I may need to use CreateWindowEx because you can run multithreaded MDI children, but you can't with WM_MDICHILD.
|
|
|
|
|
Hello, I'm just a little curious. When i browse through some librarys I sometimes see functions delclared this way:
<returntype> SomeFunc(<arg list>) = 0;
Now my question is: What does the = 0; mean and what is its purpuse?
thanks in advance.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
If it's in a class, you might be referring to a pure virtual declaration
class SomeClass
{
virtual void someFunc() = 0;
};
Which means that there is no body of the function supplied, or in other words, that you need to derive from that class, adding the required functionality.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks, now I can go to sleep without wondering what it might be...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Hi guys (sorry for the last incomplete message).
Do you have a fast algorithm to generate the permutations of a string.
Ex:
4-3-2
4-3-2 4-2-3 3-4-2 3-2-4 2-4-3 2-3-4
And another one that ignore repeated chars?
Ex
4-1-1
4-1-1 1-4-1 1-1-4
Actually 4-1-1 had to appear twice but I only want that appears one.
Best Regards
Dr.Pi
|
|
|
|