Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 257239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:04:50+00:00 2026-05-11T22:04:50+00:00

First of all, the keylogger that i am developing is not at all for

  • 0

First of all, the keylogger that i am developing is not at all for offensive and destructive purposes. 🙂

I am developing a client monitoring application in C#.NET.
Keylogging is one of the features in my application.
Though i have developed the code for the keylogger, i have not been able to implement it properly in my application.

There are two projects in my solution.
The UserInterface – for server side.
The Tracker – for client side PCs.
The keylogging module Keylogger is in the Tracker project.

I have used the helper classes for socket programming – TcpClient, TcpListener and NetworkStream to help them out.

Also, i am using asynchronous mode for communication.

I am posting the part of code with which i am facing the problem :

//This code resides on the server-side monitoring interface.When //the administrator hits a btnKeyLog button, a 

message //"StartKeyLog" is sent to the respective client, and the keylogging //is handled on the client.

private void btnKeyLog_Click ( object sender, EventArgs e )
{
messageBuffer = new byte[100];

    if ( btnKeyLog1.Text == "Start Keylogging" )
    {
        btnKeyLog1.Text = "Stop Keylogging";
        message = "StartKeyLog";

        messageBuffer = Encoding.ASCII.GetBytes ( message );
        try
        {
                //begin writing on the stream.
        clientConnections[0].networkStream.BeginWrite (messageBuffer, 0, messageBuffer.Length, new 

AsyncCallback ( onDataWrite ), null );
        }
        catch ( Exception exc )
        {
            MessageBox.Show ( exc.Message + exc.StackTrace );
        }
    }
    else
    {
        btnKeyLog1.Text = "Start Keylogging";
        message = "StopKeyLog";

        messageBuffer = Encoding.ASCII.GetBytes ( message );
        try
        {
        clientConnections[0].networkStream.BeginWrite ( messageBuffer, 0, messageBuffer.Length, new 

AsyncCallback ( onDataWrite ), null );
        }
        catch ( Exception exc )
        {
            MessageBox.Show ( exc.Message + exc.StackTrace );
        }
    }
}

Now, the client-side code :

public void onDataReceived ( IAsyncResult ar )
{
    int nBytesRead = 0;
    try
    {
        nBytesRead = clientConnection.networkStream.EndRead ( ar );
    }
    catch ( Exception exc )
    {
        MessageBox.Show ( exc.Message + exc.StackTrace );
    }
    message = Encoding.ASCII.GetString ( messageBuffer,0, nBytesRead);
    switch (message)
    {
        case "StartKeyLog" :
            MessageBox.Show ( "Keylogger started." );
                       //the following static method wraps the Win32 //implementation of SetWindowsHookEx - all given in Keylogger //module
            KeyboardHook.installHook ( );
                       //after this method is called, the hook is //actually installed; the callback function KeyboardHookProc is also //called.        

    Here, keylogger seems to be working fine, except that the //system slows down considerably when i type keystrokes.
        break;

        case "StopKeyLog":
            MessageBox.Show ( "Keylogger stopped." );
                        // the following method releases the hook
            KeyboardHook.releaseHook ( );
        break;
    }

    try
    {
        messageBuffer = new byte[100];
        clientConnection.networkStream.BeginRead ( messageBuffer, 0, messageBuffer.Length, new AsyncCallback ( onDataReceived ), null );
    }
    catch ( Exception exc )
    {
        MessageBox.Show ( exc.Message + exc.StackTrace );
    }
    //MessageBox.Show ( "Stop" );
//as soon as this function ends, however, the callback function of //the keyboard hook stops being called; keystrokes are not //processed.
//the keystrokes are caught until this function the control is in this //function. i assume that it has to do something with the thread.
}

I am trying to explain the situation here.
To start keylogging, the server UI would send a message “StartKeyLog” to the client.
On receiving the message, the client will process it in the callback function “onDataReceived”.In this function, the message is processed and the

installHook() method is called, which would install the hook.

When i ran the application, the hook got installed; also, the KeyboardHookProc() callback got called properly, and the keystrokes were processed. But this

was the case only till the onDataReceived callback method was alive. As soon as the that method ended, the KeyboardHookProc() stopped getting called; keys

were no longer processed, as if the hook was never installed.

Another problem was that after the hook got installed, the system got considerably slow when i hit any key.

My assumption is that both the things have something to do with the threading that happens here. But, i am not able to get the exact problem.
I have tried my best to explain the situation.Still, any questions are welcome.
Could anyone provide me with the solution??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:04:50+00:00Added an answer on May 11, 2026 at 10:04 pm

    well, i have managed to solve my problem. The problem was that i was setting the hook on a thread that the main thread of my application had invoked. Infact, i had started that thread just to install the hook. I just restructured my code so that the hook was installed on the main thread. It solved out the whole problem. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

First of all, I know about the command line parameter, but I don't want
First of all, the static keyword. I've read several articles and past threads on
First of all, I'm sorry about the feedback-nature of this question. I'm trying to
First of all I apologize for the long lead up to such a simplistic

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.