1
我有問題與我的問題。使用WH_JOURNALRECORD和WH_JOURNALPLAYBACK在C++程序,一切都看不壞,但..程序關閉我的電腦錯誤0x0000008E 到藍屏幾秒鐘,這是我的代碼(DLL):C++ JournalPlayback和Bluescreen 0x0000008E(掛鉤)
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
#include <iostream>
using namespace std;
BOOL APIENTRY DllMain (HMODULE hModule /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */)
{
g_hInst = hModule;
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
LRESULT CALLBACK RecordProc (int code, WPARAM wParam, LPARAM lParam) //lparam to informacje wejscia a wparam wyjscia
{
if(code < 0) return CallNextHookEx(0, code, wParam, lParam);
if(code == HC_ACTION)
{
EVENTMSG * msg =(EVENTMSG *) lParam;
msg->time -= g_StartTime;
g_Events.push_back(* msg);
return 0;
}
return CallNextHookEx (0, code, wParam, lParam);
}
LRESULT CALLBACK PlaybackProc(int code, WPARAM wParam, LPARAM lParam)
{
if(code < 0) return CallNextHookEx(0, code, wParam, lParam);
if(code == HC_GETNEXT)
{
EVENTMSG * msg = (EVENTMSG *) lParam;
msg->hwnd = g_Events[ g_CurrentEvent ].hwnd;
msg->message = g_Events[ g_CurrentEvent ].message;
msg->paramH = g_Events[ g_CurrentEvent ].paramH;
msg->paramL = g_Events[ g_CurrentEvent ].paramL;
msg->time = g_StartTime + g_Events[ g_CurrentEvent ].time;
DWORD delta = msg->time - GetTickCount();
if(delta > 0) return delta;
else
return 0;
}
else if(code == HC_SKIP)
{
if(!g_PlaybackStopped)
g_CurrentEvent++;
if(g_CurrentEvent >= g_Events.size())
{
g_CurrentEvent = 0;
g_StartTime = GetTickCount();
g_PlaybackStopped = false;
return 0;
}
}
return 0;
}
DLLIMPORT void StartRecording(void)
{
g_StartTime = GetTickCount();
if(g_RecordHook==NULL)
g_RecordHook = SetWindowsHookEx(WH_JOURNALRECORD, RecordProc, g_hInst, 0);
else UnhookWindowsHookEx(g_RecordHook);
}
DLLIMPORT void StartPlayback(void)
{
g_CurrentEvent = 0;
g_StartTime = GetTickCount();
UnhookWindowsHookEx(g_RecordHook);
g_PlaybackStopped = false;
Sleep(1000);
g_PlaybackHook = SetWindowsHookEx(WH_JOURNALPLAYBACK, PlaybackProc, g_hInst, 0);
}
謝謝回答! :P我嘗試了它,但是如果我的錄音時間超過了幾秒,我在播放之後得到了藍屏。2/3秒。如果錄製時間短(如1秒),則效果會更好,而且我也沒有藍屏。也許這個問題是與我的電腦?無論如何,謝謝你對我的問題感興趣,並試圖提供幫助 – Kurogami12