Re: Tracking Clipboard Paste
I don't know how exactly you're wanting to go about a function hook, but if we're talking C:
Code:
#include <windows.h>
#pragma comment(lib, "detours.lib")
#include "detours.h" // Detours for everything else
HANDLE (WINAPI *origGetClipboardData)(UINT uFormat);
HANDLE WINAPI hookGetClipboardData(UINT uFormat) {
// Do whatever
// Call original
return origGetClipboardData(uFormat);
}
void doHooking() {
origGetClipboardData = (HANDLE (__stdcall *)(UINT))DetourFunction((PBYTE)GetClipboardData, (PBYTE)hookGetClipboardData);
}
Re: Tracking Clipboard Paste
hmm ok, if we're gonna do it in C, I need more help, so the code above applies the hook, where can I check if the paste is actually done?
like If(Paste) { /*do something*/ } ?
thanks
Re: Tracking Clipboard Paste
Well one of us doesn't understand something ;)
I thought that by your mentioning of the functions GetClipboardData, EmptyClipboard and SetClipboardData - You knew the process which would happen. I was just helping you with the hook :)
Providing the user hasn't got any applications running that are going to abnormally call GetClipboardData, you can just set your next string in that function.
I'm guessing you want the same functionality as one of these powerpasters, where you list a lot of strings and each time you paste from the clipboard it has a different one? I'm fairly sure that it would work to just alter the data on every call to GetClipboardData.
Re: Tracking Clipboard Paste
ok, I'm not so good in C ... so yea I kinda need more help
I'm trying to run ur code
Code:
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "detours.lib")
#include "detours.h" // Detours for everything else
HANDLE (WINAPI *origGetClipboardData)(UINT uFormat);
HANDLE WINAPI hookGetClipboardData(UINT uFormat) {
// Do whatever
printf("test\n");
// Call original
return origGetClipboardData(uFormat);
}
void doHooking() {
origGetClipboardData = (HANDLE (__stdcall *)(UINT))DetourFunction((PBYTE)GetClipboardData, (PBYTE)hookGetClipboardData);
}
but I'm getting the error:
Quote:
(.text+0x3c)||undefined reference to `_DetourFunction@8'|
text+0x104)||undefined reference to `_WinMain@16'|
||=== Build finished: 2 errors, 0 warnings ===|
can you please help ?
and btw, according to my code, when will the program print test ? when Clipboard changes ? or is used ? or never ?
Re: Tracking Clipboard Paste
Hmmm well I'm unsure, I made a test app that hooks the GetClipboardData function, tried to Paste, and the hook wasn't called - So either that function isn't used by Windows Ctrl-V/Right-Click->Paste, or it's the wrong function all together.
I had a look around for example clipboard history managers (as they'll probably use the same concept that you want to do) and I think the closest one I found (infact almost the only one that isn't closed source) was Ditto, but I think it may be too complex for what you're doing. I don't have the time (at the moment) to go through it and see exactly how it works, if I have time later I'll take a look for you.
Re: Tracking Clipboard Paste
some people told me to use SetClipboardViewer API, but I'm not sure it will work, do you have any idea if this API can help ?