私は、Visual Studio内の1つのソリューションファイルを持っている、と私は.Cファイルに二つのプロジェクトの.dllファイルと一つの他のプロジェクトのための1つを持っている:メモ帳でキーストロークを作成中に例外が発生するのはなぜですか?
これは.hファイルである:
#include <windows.h>
#ifndef BHANNAN_TEST_CLASS_H_
#define BHANNAN_TEST_CLASS_H_
extern int __declspec (dllexport) Factorial(int n);
#endif
と(DLLの).cのファイルに:今私はちょうどフックのメカニズムを理解するために、メモ帳でのキーストロークをフックするDLLをロードするために、それから試みるローダ/テスターを持って
#include "hanan.h"
#include <stdio.h>
int Factorial(int n) {
printf("in DLL %d \n" ,n);
return 0;
}
。
これはローダのコードである:
#include <windows.h>
#include <stdio.h>
typedef int (*functor) (int);
functor funcptr =NULL;
int main() {
HWND windowHandle;
HINSTANCE hMod;
HOOKPROC lpfn;
DWORD threadId;
HHOOK hook;
HMODULE myDLL = LoadLibraryW(L"dll123.dll");
funcptr = (functor) GetProcAddress(myDLL,"Factorial");
/// printing issues:////////////////
printf("%d \n\r" , myDLL);
printf("%d" , funcptr(33));
//////////////////////////////////////
lpfn = (HOOKPROC) funcptr;
hMod = myDLL;
windowHandle = FindWindow(L"Notepad",NULL);
threadId = GetWindowThreadProcessId(windowHandle, NULL);
hook = SetWindowsHookEx(WH_KEYBOARD,lpfn,hMod,threadId);//(WH_CBT, HookCBTProc, hInst, threadId);
/// printing issues:
printf("%d %d %d %d\n" , hook, WH_KEYBOARD , lpfn , hMod);
printf("%d %d \n",threadId , windowHandle);
getchar();
return 0;
}
iは全ての印刷全くゼロを取得していない、そこにはヌル(メモ帳が実行されていると仮定)はないが、私はメモ帳で任意のキーストロークを行うと私が得ることを意味します例外はすぐに、Visual Studioの2010とWindows 7
を使用して
は、例外のプロパティを追加しました:
Exception Offset: 0006632c
Exception Code: c0000409
Exception Data: 00000000
あなたがセットフックの呼び出しに渡す210
(2つのその他のparams ??です)
int Factorial(int n)
しかし、あなたが実際に受けている例外は言及していません。 –@ p.campbell - エラーメッセージを読むことは楽しいことです。 –