|
|
Hallo...
I'm here to ask you - maybe - a strange info.
My program runs in background and check every s second the processes list to see if some process is started while it is running. If the process is not known my app should prompt an advice asking what should it do with this process.
The problem is: how can I stop/block etc... windows until user answer the msgbox? I need to stop windows to prevent viruses or trojan execution.... like anti-virus apps do: when the antivirus dialog box is shown the process is refearing to can't continue its execution...
I hope I was clear
thenk you
Comet
|
|
|
|
|
That is not how an anti-virus application works. It doesn't monitor processes - it monitors file accesses so it will scan an executable before it's ever launched. Since you're not preventing a process from being launched, the chances are high that the machine was already infected.
I understand that you're not writing AV software (because if you were you really should understand how this stuff works first), but this is how the execution of the application is prevented - because it actually hasn't started yet. Once the application is started there's not a lot you can do that is *safe*.
A very simple way would be to display a system modal Form (set TopMost to true ) that is the size of the desktop working area (see SystemInformation.WorkingArea ) and that can't be moved (override WndProc in your Form , watch for the WM_SIZING message (0x0214), and set Message.Result to newIntPtr(1) , then call base.WndProc ). WndProc should look something like this:
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0214 || m.Msg == 0x0216)
m.Result = new IntPtr(1);
base.WndProc(ref m);
} This would prevent users from resizing or moving the window.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes, you are right, i'm not writing an AV app. However I've never thought to file-access. I have 2 simple - I hope - questions:
1. where can I find more infos on how AV works??
2. The problem in my app is not about the app's window. I'm going to try to explain - hope quickly - how it should work:
- monitoring processes
- at first start collect processes "safe"
- monitor loop:
- if a process that is not known by my app is trying to start it should prompt if this process is safe - if so - it will be added to the "safe list" otherwise it should be closed or removed.
as you can see the problem is that when the process starts - as you wrote - it's too late to kill or close it.
strange app this ??
Ciao
Comet(italy)
|
|
|
|
|
_Comet_Keeper_ wrote:
1. where can I find more infos on how AV works??
There's no compedium of information about this. This is the result of years of research and experience into computer science and in-depth knowledge of the operating system you would target.
_Comet_Keeper_ wrote:
it's too late to kill or close it.
No it's not. Call Process.CloseMainWindow followed by Process.Close to exit the process gracefully, or Process.Kill to end the task.
Seriously, though, it sounds like you're trying to write AV-like software, where users are prompted if an unapproved application is started. First of all, 99% of users don't know what 99% of the processes are their system are. Many processes are Windows Services. Many processes run periodically to maintain the system. You're expecting too much of your clients. Besides, if you are going to right this type of management software, you should have more in-depth knowledge of the operating system.
For example, if you understand Windows Hooks, you can hook messages like WH_CBT to know when Windows are created. While you can do this in C# (search for "Windows Hooks" in the C# category here at CodeProject), it's very inefficient and you should definitely think about performance when righting such hooks (no matter what language you use).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i'm needin' a function that will take the following as parameters and output a string in the following format please help
<br />
int which_card = 0;
string bitsORbytes = "bits";
int upORdown = 0;
<br />
public int bandwidth_stat_info(int which_card, string bitsORbytes, int upORdown)<br />
{<br />
<br />
return data;
}<br />
thank's for the help ahead of time, i've been working on this project for almost 2 weeks now (a informative screensaver that displays certian data about your computer and it is fashionable too)
agian thanks your help it truely needed
|
|
|
|
|
You should take a look into performance counters. See the PerformanceCounter class documentation in the .NET Framework SDK, as well as the following articles that give a conceptual overview:Many of these statistics are already captures for you, so instantiating a PerformanceCounter around networking counters will give you these stats already. This is by far the simplest way in .NET to get these statistics.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm sort of new to C#.
I have had plenty of experience with Java, C, C++, you name it. C# is still a bit new to me.
My problem is this..
I am badly in need of a way to call a function from the Child to the Parent. The parent has the instance, so I'm not sure how to do this. Even if the function is public in parent, it doesn't seem to matter. I can't call it. I figure the answer lies with event handling, but I'm not sure how to set it up exactly. Can anyone help me out?
|
|
|
|
|
Try using the Parent or ParentForm propeties.
Happy Programming and God Bless!
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
If the "Child" you refer to is in the "Parent"'s Controls collection, then use the Parent property (as the other reply stated), but you must cast the return value to your "Parent"'s class. The Parent property, for example, returns a Control . Your "Parent" derives from that (if you're talking about controls for child and parents, that is), but your method is not defined on the Control class, is it? It's defined on your class. In C#, you can use the keyword as to perform a safe cast, so that if the type isn't valid an InvalidCastException is not thrown, like so:
MyForm form = this.Parent as Myform;
if (form != null) form.SomeMethod();
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
This question belongs in the ASP.NET Forum, not C#. This forum is for C# language related questions...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
This forum is for C# language related questions
Most of the questions here appear to be related to the .NET Framework and third party tools than the C# language itself. Anyway, I have removed the original message to the ASP.NET forum as per your request. Even although the second part of the question was not specific to ASP.NET.
Cheers,
Andy.
|
|
|
|
|
That's not entirely true. If questions about third-party controls show up, most of us tell the people to see the documentation for the third-party controls. For one, we may not know those controls (hell, there's hundreds if not thousands of third-party controls for the .NET Framework already...and good ones are all I'm counting). Second, that company should support their own work.
Also, C# questions relating to Windows Forms, graphics, etc., still use C#. ASP.NET is a culmination of a managed language, HTML, XML, etc. It's really in a class all its own, and since there's a specific forum for ASP.NET, such questions should be directed there.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I've got an application which responds to WM_COMMAND Message with some defined Wparams
Now I am writing a service in .NET which should control that application by sending him messages.
The question is: how do I send a message to a window? I already created the message using the Message class, obtained the handler of the window of the desired application, but still the sending part is missed.
can u help me?
DavidR
|
|
|
|
|
I'm not sure on what type of application you are creating, but if I were you, I would try to simply make a function to the child that can be called from the parent's instance to send the message. In other words
ChildInstance.sendData(params)
Wouldn't that work?
|
|
|
|
|
You simply P/Invoke SendMessage . See http://pinvoke.net/default.aspx/user32.SendMessage[^] for the syntax. This is how you would do it (well, one way) in a native C/C++ application (or even in VB6 and below by declaring the SendMessage API.
You'll need the HWND to the destination window, but it sounds like you already have it. You'll also most likely need to register your service either as a specific user with local login rights, or as the Local System with the "Allow service to interact with desktop" checked (search this message board using "Search comments" above for a previous reply about how to do this I wrote a day or two ago).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I would like to know how to capture data coming from a RFID Reader. The RFID reader can be connected to a computer. But what kind of data will I get from the serial port or the USB port.
If the data is some kind of HEX, then I could write a module to convert the data to ASCII. But I am really not sure what kind of Data will be there. All i will have is the driver supplied by the manufacturer.
Is there any kind of source code or tutorial which can show how data is captured from a serial or a USB Port?
Regards,
Tarakeshwar
CCIE Q(Routing and Switching), MCSE Security
|
|
|
|
|
Tarakeshwar wrote:
If the data is some kind of HEX
Would that not imply that it was a binary stream? Isn't HEX normally used to display binary data to the developer via a debugger or whatnot?
Tarakeshwar wrote:
All i will have is the driver supplied by the manufacturer.
Is there any kind of source code or tutorial which can show how data is captured from a serial or a USB Port?
I would guess that the driver gets the data from the USB or serial port, your program will then have to communicate with the driver. Surely the manufacturer's documentation will explain this? If not then I'd suggest having a look at their website, or calling their technical support and getting the information from them.
|
|
|
|
|
You need to read the developer documentation for the RFID reader you have. The APIs for that reader will most likely be different than any other reader. This is true for many devices, from scientific instruments to meteorlogical instruments, etc. There is no standard communication protocol for such specific devices.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
<br />
private string update_http()<br />
{<br />
byte[] buf = new byte[80];<br />
HttpWebRequest request = (HttpWebRequest)WebRequest.Create<br />
("http://wheeloftime.net/ever_lstmsg.php");<br />
<br />
HttpWebResponse response = (HttpWebResponse)request.GetResponse();<br />
Stream resStream = response.GetResponseStream();<br />
<br />
int count = resStream.Read(buf, 0, buf.Length);<br />
<br />
msg = Encoding.UTF8.GetString(buf,0,buf.Length);<br />
<br />
resStream.Close(); <br />
Console.WriteLine(msg);<br />
return msg;<br />
}<br />
in the above code i keep getting "Hello Loren||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
returned instead of just "Hello Loren"
it is returning those pipe symbols to fill the rest of the buffer and using console.writeline doesn't show them only when i display it using DirectX 9.0
surface.DrawText(0,0,update_http(),true);
onto a surface
please help me remove the | charactors somehow thank you
|
|
|
|
|
|
Also, don't assume that the response is UTF-8-encoded. Use Encoding.GetEncoding , passing in the HttpWebResponse.ContentEncoding property, or default to UTF8 (a good default since printable ASCII is supported).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how to make an application like jetaudio5, winamp5 and wmp9 appearance?
|
|
|
|
|