Skip to content
Permalink
Browse files

winport - make it so you can only open one of each disassembler views…

… at a time (reportedly theyre crashy if theres more than one of them open.. seems likely to be the case for any of our tool windows)
  • Loading branch information...
zeromus committed Apr 18, 2018
1 parent deffcaa commit 9c128460c47ec38cd21c8e9da0b43c41876ebe88
@@ -18,6 +18,7 @@

#include "CWindow.h"

#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>

@@ -803,6 +804,7 @@ TOOLSCLASS::TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC dlgproc)
hwnd = NULL;
hInstance = hInst;
idd=IDD;
isOpen = false;
memset(class_name, 0, sizeof(class_name));
memset(class_name2, 0, sizeof(class_name2));
}
@@ -812,6 +814,11 @@ TOOLSCLASS::~TOOLSCLASS()
close();
}

void TOOLSCLASS::Activate()
{
SetForegroundWindow(hwnd);
}

bool TOOLSCLASS::open(bool useThread)
{
if(useThread)
@@ -842,6 +849,7 @@ DWORD TOOLSCLASS::doOpen()

ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
isOpen = true;

return 0;
}
@@ -850,6 +858,7 @@ void TOOLSCLASS::doClose()
{
unregClass();
hwnd = NULL;
isOpen = false;
}

DWORD TOOLSCLASS::ThreadFunc()
@@ -289,12 +289,12 @@ class TOOLSCLASS : public THREADCLASS
HWND hwnd;
HINSTANCE hInstance;
DLGPROC dlgproc;
bool isOpen;
int idd;
char class_name[256];
char class_name2[256];

DWORD doOpen();
void doClose();

protected:
DWORD ThreadFunc();
@@ -306,6 +306,9 @@ class TOOLSCLASS : public THREADCLASS
bool close();
void regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg = false);
void unregClass();
bool IsOpen() { return isOpen; }
void doClose();
void Activate();
};

#endif
@@ -44,6 +44,9 @@ typedef struct
disview_struct *DisView7 = NULL;
disview_struct *DisView9 = NULL;

extern TOOLSCLASS *ViewDisasm_ARM7;
extern TOOLSCLASS *ViewDisasm_ARM9;

static HWND DisViewWnd[2] = {NULL, NULL};

#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF))
@@ -319,6 +322,7 @@ BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARA
delete DisView7;
DisView7 = NULL;
DisViewWnd[1] = NULL;
ViewDisasm_ARM7->doClose();
//INFO("Close ARM7 disassembler\n");
return 1;
}
@@ -564,6 +568,7 @@ BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARA
delete DisView9;
DisView9 = NULL;
DisViewWnd[0] = NULL;
ViewDisasm_ARM9->doClose();
//INFO("Close ARM9 disassembler\n");
return 1;
}
@@ -5833,12 +5833,20 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
return 0;
case IDM_DISASSEMBLER:
ViewDisasm_ARM7->regClass("DesViewBox7",ViewDisasm_ARM7BoxProc);
if (!ViewDisasm_ARM7->open(false))
ViewDisasm_ARM7->unregClass();
if(!ViewDisasm_ARM7->IsOpen())
{
if (!ViewDisasm_ARM7->open(false))
ViewDisasm_ARM7->unregClass();
}
else ViewDisasm_ARM7->Activate();

ViewDisasm_ARM9->regClass("DesViewBox9",ViewDisasm_ARM9BoxProc);
if (!ViewDisasm_ARM9->open(false))
ViewDisasm_ARM9->unregClass();
if(!ViewDisasm_ARM9->IsOpen())
{
if (!ViewDisasm_ARM9->open(false))
ViewDisasm_ARM9->unregClass();
}
else ViewDisasm_ARM9->Activate();
return 0;
case IDM_MAP:
ViewMaps->open();

0 comments on commit 9c12846

Please sign in to comment.
You can’t perform that action at this time.