178 lines
4.9 KiB
Plaintext
178 lines
4.9 KiB
Plaintext
#include <common/string.hpp>
|
|
#include <hookproc/main.hpp>
|
|
#include <hookproc/mainwnd.hpp>
|
|
|
|
HINSTANCE Main::smhInstance=0;
|
|
HINSTANCE Main::smhPrevInstance=0;
|
|
int Main::smnCmdShow=0;
|
|
|
|
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR /*lpszCmdLine*/,int nCmdShow)
|
|
{
|
|
Main::processInstance(hInstance);
|
|
Main::previousProcessInstance(hPrevInstance);
|
|
Main::cmdShow(nCmdShow);
|
|
if(Main::previousProcessInstance())
|
|
{
|
|
HWND hWnd=::FindWindow(MainWindow::className(),MainWindow::className());
|
|
if(!hWnd)
|
|
{
|
|
::MessageBox(::GetFocus(),(LPSTR)"Failed to maximize previous instance",(LPSTR)"Error",MB_ICONSTOP|MB_SYSTEMMODAL);
|
|
return FALSE;
|
|
}
|
|
::PostMessage(hWnd,WM_REACTIVATE,0,0L);
|
|
return FALSE;
|
|
}
|
|
MainWindow applicationWindow;
|
|
return applicationWindow.messageLoop();
|
|
}
|
|
|
|
|
|
|
|
|
|
#include <common/windows.hpp>
|
|
#include <hookproc/excptdlg.hpp>
|
|
|
|
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
|
{
|
|
ExceptDlg exceptDlg;
|
|
exceptDlg.performDialog(0L);
|
|
return FALSE;
|
|
}
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
|
|
staticDS.className(staticControl);
|
|
staticDS.titleText("ds:");
|
|
staticDS.style(WS_CHILD|WS_VISIBLE);
|
|
staticDS.posRect(Rect(282,10,13,8));
|
|
staticDS.itemID(-1);
|
|
|
|
staticES.className(staticControl);
|
|
staticES.titleText("es:");
|
|
staticES.style(WS_CHILD|WS_VISIBLE);
|
|
staticES.posRect(Rect(282,22,12,8));
|
|
staticES.itemID(-1);
|
|
|
|
staticFS.className(staticControl);
|
|
staticFS.titleText("fs:");
|
|
staticFS.style(WS_CHILD|WS_VISIBLE);
|
|
staticFS.posRect(Rect(282,35,13,8));
|
|
staticFS.itemID(-1);
|
|
|
|
staticGS.className(staticControl);
|
|
staticGS.titleText("gs:");
|
|
staticGS.style(WS_CHILD|WS_VISIBLE);
|
|
staticGS.posRect(Rect(282,48,13,8));
|
|
staticGS.itemID(-1);
|
|
|
|
|
|
class ExceptionHandler
|
|
{
|
|
public:
|
|
ExceptionHandler(void);
|
|
virtual ~ExceptionHandler();
|
|
private:
|
|
static PureExceptionRegistration::ExceptionDisposition _cdecl exceptionHandler(EXCEPTION_RECORD *pExceptionRecord,void *pEstablisherFrame,CONTEXT *pContext,void *pDispatcherContext);
|
|
|
|
PureExceptionRegistration *mpCurrentExceptionFrame;
|
|
ExceptionRegistration mExceptionFrame;
|
|
};
|
|
|
|
ExceptionHandler::ExceptionHandler(void)
|
|
: mpCurrentExceptionFrame(0)
|
|
{
|
|
installFrame(&mpCurrentExceptionFrame);
|
|
mExceptionFrame.prevRegistration(mpCurrentExceptionFrame);
|
|
mExceptionFrame.currHandler(ExceptionHandler::exceptionHandler);
|
|
mpCurrentExceptionFrame=&((PureExceptionRegistration&)mExceptionFrame);
|
|
PureExceptionRegistration *pCurrentExceptionFrame;
|
|
pCurrentExceptionFrame=mpCurrentExceptionFrame;
|
|
_asm mov eax,pCurrentExceptionFrame;
|
|
_asm mov fs:[0],eax
|
|
}
|
|
|
|
ExceptionHandler::~ExceptionHandler()
|
|
{
|
|
// PureExceptionRegistration *pCurrentExceptionFrame;
|
|
// pCurrentExceptionFrame=mpCurrentExceptionFrame;
|
|
// _asm mov eax,pCurrentExceptionFrame;
|
|
// _asm mov fs:[0],eax
|
|
}
|
|
|
|
PureExceptionRegistration::ExceptionDisposition ExceptionHandler::exceptionHandler(EXCEPTION_RECORD *pExceptionRecord,void *pEstablisherFrame,CONTEXT *pContext,void *pDispatcherContext)
|
|
{
|
|
ExceptionRecord exceptionRecord(*pExceptionRecord);
|
|
|
|
ExceptDlg exceptDlg;
|
|
exceptDlg.performDialog(exceptionRecord,*pContext);
|
|
return PureExceptionRegistration::ExceptionContinueSearch;
|
|
}
|
|
|
|
// ****************************************************************************************************
|
|
|
|
|
|
|
|
PureExceptionRegistration *pCurrentExceptionFrame;
|
|
ExceptionRegistration exceptionFrame;
|
|
// _asm mov eax,fs:[0];
|
|
// _asm mov pCurrentExceptionFrame,eax
|
|
|
|
pCurrentExceptionFrame=getFS();
|
|
|
|
exceptionFrame.prevRegistration(pCurrentExceptionFrame);
|
|
exceptionFrame.currHandler(exceptionHandler);
|
|
pCurrentExceptionFrame=&((PureExceptionRegistration&)exceptionFrame);
|
|
setFS(pCurrentExceptionFrame);
|
|
// _asm mov eax,pCurrentExceptionFrame;
|
|
// _asm mov fs:[0],eax
|
|
//#endif
|
|
|
|
char *ptrData=0;
|
|
*ptrData=0;
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <hookproc/excpthk.hpp>
|
|
#include <hookproc/excptdlg.hpp>
|
|
#include <decode/disasm.hpp>
|
|
|
|
extern "C"
|
|
{
|
|
PureExceptionRegistration *getFS(void);
|
|
void setFS(PureExceptionRegistration *pPureExceptionRegistration);
|
|
}
|
|
|
|
PureExceptionRegistration::ExceptionDisposition _cdecl exceptionHandler(EXCEPTION_RECORD *pExceptionRecord,void *pEstablisherFrame,CONTEXT *pContext,void *pDispatcherContext);
|
|
|
|
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR /*lpszCmdLine*/,int nCmdShow)
|
|
{
|
|
PureExceptionRegistration *pCurrentExceptionFrame;
|
|
ExceptionRegistration exceptionFrame;
|
|
pCurrentExceptionFrame=getFS();
|
|
exceptionFrame.prevRegistration(pCurrentExceptionFrame);
|
|
exceptionFrame.currHandler(exceptionHandler);
|
|
pCurrentExceptionFrame=&((PureExceptionRegistration&)exceptionFrame);
|
|
setFS(pCurrentExceptionFrame);
|
|
|
|
char *ptrData=0;
|
|
*ptrData=0;
|
|
return FALSE;
|
|
}
|
|
|
|
PureExceptionRegistration::ExceptionDisposition _cdecl exceptionHandler(EXCEPTION_RECORD *pExceptionRecord,void *pEstablisherFrame,CONTEXT *pContext,void *pDispatcherContext)
|
|
{
|
|
ExceptionRecord exceptionRecord(*pExceptionRecord);
|
|
|
|
ExceptDlg exceptDlg;
|
|
exceptDlg.performDialog(exceptionRecord,*pContext);
|
|
return PureExceptionRegistration::ExceptionContinueSearch;
|
|
}
|