Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- extern "C"
- {
- int isOnPaintArrived = 0;
- _declspec(dllexport) LRESULT CALLBACK GeMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
- {
- if (nCode == HC_ACTION)
- {
- return CallNextHookEx(0, nCode, wParam, lParam);
- }
- return CallNextHookEx(0, nCode, wParam, lParam);
- }
- _declspec(dllexport) int GetFlag(void)
- {
- return (isOnPaintArrived);
- }
- _declspec(dllexport) void setFlag(void)
- {
- isOnPaintArrived = 0;
- }
- _declspec(dllexport) void resetFlag(void)
- {
- isOnPaintArrived = 0;
- }
- }
- /* OurDLL.c source code */
- /*#include <windows.h>
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main () {
- ofstream myfile;
- myfile << "Writing this to a file.\n";
- myfile.close();
- return 0;
- }
- BOOL WINAPI DllMain(HANDLE hModule,
- DWORD dwFunction,
- LPVOID lpNot)
- {
- return TRUE;
- }
- char* LEFT_BUTTON_STRING = "left";
- char* RIGHT_BUTTON_STRING = "right";
- bool isShiftPressed = false;
- int isOnPaintArrived = 0;
- extern "C"
- {
- _declspec (dllexport) LRESULT CALLBACK RecorderMouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
- {
- if (nCode == HC_ACTION)
- {
- if (wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN)
- {
- char* button = RIGHT_BUTTON_STRING;
- if (wParam == WM_LBUTTONDOWN)
- {
- button = LEFT_BUTTON_STRING;
- }
- DWORD result = ScreenToClient(GetActiveWindow(), &(((MSLLHOOKSTRUCT*)lParam)->pt));
- if (result == 0)
- {
- int xPos = ((MSLLHOOKSTRUCT*)lParam)->pt.x;
- int yPos = ((MSLLHOOKSTRUCT*)lParam)->pt.y;
- ofstream file;
- file.open("C:\\hook-output.au3", ios_base::app);
- file << "Error:MouseClick (\"" << button << "\", " << xPos << ", " << yPos << ")" << endl;
- file.close();
- }
- else
- {
- int xPos = ((MSLLHOOKSTRUCT*)lParam)->pt.x;
- int yPos = ((MSLLHOOKSTRUCT*)lParam)->pt.y;
- ofstream file;
- file.open("C:\\hook-output.au3", ios_base::app);
- file << "MouseClick (\"" << button << "\", " << xPos << ", " << yPos << ")" << endl;
- file.close();
- }
- }
- return CallNextHookEx(0, nCode, wParam, lParam);
- }
- return CallNextHookEx(0, nCode, wParam, lParam);
- }
- _declspec (dllexport) LRESULT CALLBACK RecorderKeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
- {
- if (nCode == HC_ACTION)
- {
- if (wParam == VK_SHIFT)
- {
- isShiftPressed = false;
- if (!(lParam & 0x80000000))
- {
- isShiftPressed = true;
- }
- }
- else
- {
- if (!(lParam & 0x80000000))
- {
- char character = MapVirtualKey(wParam, MAPVK_VK_TO_CHAR);
- if (character >= 'A' && character <= 'Z')
- {
- character = character - 'A' + 'a';
- ofstream file;
- file.open("C:\\hook-output.au3", ios_base::app);
- file << "Send (\"";
- if (isShiftPressed)
- {
- file << "+";
- }
- file << character << "\")" << endl;
- file.close();
- }
- }
- }
- return CallNextHookEx(0, nCode, wParam, lParam);
- }
- return CallNextHookEx(0, nCode, wParam, lParam);
- }
- _declspec (dllexport) LRESULT CALLBACK GeMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
- {
- if (nCode == HC_ACTION)
- {
- return CallNextHookEx(0, nCode, wParam, lParam);
- }
- return CallNextHookEx(0, nCode, wParam, lParam);
- }
- _declspec (dllexport) void GetOnPaintFlag()
- {
- //return (isOnPaintArrived);
- isOnPaintArrived = true;
- }
- _declspec (dllexport) int CALLBACK getFlag()
- {
- //return (isOnPaintArrived);
- return (0);
- }
- _declspec (dllexport) void CALLBACK setFlag()
- {
- //isOnPaintArrived = 0;
- }
- _declspec (dllexport) void CALLBACK resetFlag()
- {
- //isOnPaintArrived = 0;
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement