Merge pull request #46 from Vulpovile/datamodelv2

Must fix possible ACE insecurity before making DataModelV2
This commit is contained in:
Vulpovile
2021-03-05 08:10:47 -08:00
committed by GitHub
13 changed files with 234 additions and 16 deletions

2
.gitignore vendored
View File

@@ -52,6 +52,4 @@ G3DTest.suo
G3DTest.suo
stderr.txt
desktop.ini
main.cpp
*.db
G3DTest.sln

View File

@@ -50,6 +50,7 @@
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories=""C:\Users\Andreja\Documents\C++\G3D-Fun\src\include""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
StringPooling="true"
RuntimeLibrary="2"

View File

@@ -78,7 +78,7 @@
}
}
</script>
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border:0;">
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border: outset 2px;">
<table height="100%">
<tr>
<th>

View File

@@ -11,7 +11,7 @@
image.src = image.src.replace("_dn.png",".png");
}
</script>
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border:0;">
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border: outset 2px;">
<img src="../images/Controller1Tool.png" onclick="window.external.SetController(1)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
<img src="../images/Controller2Tool.png" onclick="window.external.SetController(2)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
<img src="../images/ControllerAI1Tool.png" onclick="window.external.SetController(5)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>

View File

@@ -21,7 +21,7 @@
margin-right: 10px;
}
</style>
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border:0;">
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border: outset 2px;">
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="alert(window.external.ToggleHopperBin(0))">
<img src="../images/GameTool.png" />
</span>

View File

@@ -11,7 +11,7 @@
image.src = image.src.replace("_dn.png",".png");
}
</script>
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border:0;">
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border: outset 2px;">
<img src="../images/FlatTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(0)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
<img src="../images/BumpTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(1)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
<img src="../images/HingeTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(2)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>

View File

@@ -24,5 +24,5 @@ class IEBrowser {
unsigned int FAR* puArgErr);
private:
IWebBrowser2* webBrowser;
HWND hwnd;
HWND parentHwnd;
};

View File

@@ -1,4 +1,5 @@
#pragma once
#include <windows.h>
bool createWindowClass(const char* name,WNDPROC proc,HMODULE hInstance);

View File

@@ -65,7 +65,7 @@ HRESULT IEBrowser::doExternal(std::wstring funcName,
DWORD rgbCurrent = 0xFFFFFFFF; //Will be dynamic later
ZeroMemory(&color, sizeof(CHOOSECOLOR));
color.lStructSize = sizeof(color);
color.hwndOwner = hwnd;
color.hwndOwner = parentHwnd;
color.lpCustColors = (LPDWORD) g_acrCustClr;
color.rgbResult = rgbCurrent;
color.Flags = CC_FULLOPEN | CC_RGBINIT;
@@ -91,19 +91,19 @@ HRESULT IEBrowser::doExternal(std::wstring funcName,
}
IEBrowser::IEBrowser(HWND attachHWnd) {
webBrowser = 0;
parentHwnd = attachHWnd;
MSG messages;
while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE))
{
if (IsDialogMessage(hwnd, &messages) == 0)
if (IsDialogMessage(parentHwnd, &messages) == 0)
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
}
hwnd = attachHWnd;
webBrowser = 0;
SendMessage(hwnd,AX_INPLACE,1,0);
SendMessage(hwnd,AX_QUERYINTERFACE,(WPARAM)&IID_IWebBrowser2,(LPARAM)&webBrowser);
SendMessage(parentHwnd,AX_INPLACE,1,0);
SendMessage(parentHwnd,AX_QUERYINTERFACE,(WPARAM)&IID_IWebBrowser2,(LPARAM)&webBrowser);
}
IEBrowser::~IEBrowser(void) {

View File

@@ -1,7 +1,6 @@
#include "Mouse.h"
#include "Application.h"
#include "Globals.h"
#include <algorithm>
Mouse::Mouse(){
x = y = 0;

View File

@@ -2,7 +2,6 @@
#include <sstream>
#include "ErrorFunctions.h"
#include "StringFunctions.h"
#include <windows.h>
std::string Convert (float number)
{

View File

@@ -1,7 +1,6 @@
#include "WindowFunctions.h"
#include <sstream>
#include <string>
using namespace std;

221
src/source/main.cpp Normal file
View File

@@ -0,0 +1,221 @@
// TODO: Move toolbar buttons with resized window.
#define _WIN32_WINNT 0x0400
#define _WIN32_WINDOWS 0x0400
#define WINVER 0x0400
#include "resource.h"
#include "Application.h"
#include "WindowFunctions.h"
#include "ax.h"
#include <commctrl.h>
#include "ErrorFunctions.h"
#if G3D_VER < 61000
#error Requires G3D 6.10
#endif
HWND hwnd;
HRESULT hresult;
OLECHAR dat = ((OLECHAR)"SayHello");
OLECHAR * szMember = &dat;
DISPID dispid;
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
EXCEPINFO excepinfo;
UINT nArgErr;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
Application *app = (Application *)GetWindowLongPtr(hwnd, GWL_USERDATA);
if (app==NULL)
{
return DefWindowProc(hwnd, msg, wParam, lParam);
}
switch(msg)
{
case WM_KEYDOWN:
if ((HIWORD(lParam)&0x4000)==0) // single key press
{
app->onKeyPressed(wParam);
}
break;
case WM_KEYUP:
{
app->onKeyUp(wParam);
}
break;
case WM_MOUSEWHEEL:
app->onMouseWheel(LOWORD(lParam),HIWORD(lParam),HIWORD(wParam));
break;
case WM_SIZE:
app->resizeWithParent(hwnd);
break;
case WM_ACTIVATE:
if(wParam > WA_INACTIVE) app->setFocus(false);
else app->setFocus(true);
default:
{
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
return 0;
}
LRESULT CALLBACK ToolboxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
//Application *app = (Application *)GetWindowLongPtr(hwnd, GWL_USERDATA);
MessageBox(NULL, (LPCSTR)wParam, (LPCSTR)lParam, 1);
//if (app==NULL)
//{
//return DefWindowProc(hwnd, msg, wParam, lParam);
//}
switch(msg)
{
case WM_SIZE:
break;
default:
{
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
return 0;
}
LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
Application *app = (Application *)GetWindowLongPtr(hwnd, GWL_USERDATA);
if (app==NULL)
{
return DefWindowProc(hwnd, msg, wParam, lParam);
}
switch(msg)
{
case WM_QUIT:
app->QuitApp();
break;
case WM_DESTROY:
app->QuitApp();
break;
case WM_LBUTTONDOWN:
app->onMouseLeftPressed(hwnd,LOWORD(lParam),HIWORD(lParam));
break;
case WM_LBUTTONUP:
app->onMouseLeftUp(app->getRenderDevice(),LOWORD(lParam),HIWORD(lParam));
break;
case WM_RBUTTONDOWN:
app->onMouseRightPressed(LOWORD(lParam),HIWORD(lParam));
break;
case WM_RBUTTONUP:
app->onMouseRightUp(LOWORD(lParam),HIWORD(lParam));
break;
case WM_MOUSEMOVE:
app->onMouseMoved(LOWORD(lParam),HIWORD(lParam));
break;
case WM_KEYDOWN:
if ((HIWORD(lParam)&0x4000)==0) // single key press
{
app->onKeyPressed(wParam);
}
break;
case WM_KEYUP:
{
app->onKeyUp(wParam);
}
break;
case WM_SYSKEYDOWN:
if ((HIWORD(lParam)&0x4000)==0) // single key press
{
app->onKeyPressed(wParam);
}
break;
case WM_SYSKEYUP:
{
app->onKeyUp(wParam);
}
case WM_SIZE:
{
app->onGraphics(app->getRenderDevice());
}
break;
default:
{
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
return 0;
}
int main(int argc, char** argv) {
try{
hresult = OleInitialize(NULL);
/* IInternetSecurityManager *pSecurityMgr;
IInternetZoneManager *pZoneMgr;
LPCWSTR site1 = SysAllocString(L"http://www.androdome.com");
hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_INPROC_SERVER, IID_IInternetSecurityManager, (void**)&pSecurityMgr);
pSecurityMgr->SetZoneMapping((DWORD)2, site1, (DWORD)0); // 2 = Trusted Site, site1 is the URL to add, and 0 is to create the entry.
*/
if (!AXRegister())
return 0;
INITCOMMONCONTROLSEX icc;
// WNDCLASSEX wcx;
/* Initialize common controls. Also needed for MANIFEST's */
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_WIN95_CLASSES/*|ICC_COOL_CLASSES|ICC_DATE_CLASSES|
ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES*/;
InitCommonControlsEx(&icc);
AudioPlayer::init();
/* GAppSettings settings;
settings.window.resizable = true;
settings.writeLicenseFile = false;
settings.window.center = true; */
HMODULE hThisInstance = GetModuleHandle(NULL);
if (!createWindowClass("mainHWND",WndProc,hThisInstance))
return false;
if (!createWindowClass("toolboxHWND",ToolboxProc,hThisInstance))
return false;
if (!createWindowClass("G3DWindow",G3DProc,hThisInstance))
return false;
HWND hwndMain = CreateWindowEx(
WS_EX_APPWINDOW,
"mainHWND",
"Main test",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
800,
660,
NULL, // parent
NULL, // menu
hThisInstance,
NULL
);
if(hwndMain == NULL)
{
MessageBox(NULL, "Critical error loading: Failed to create HWND, must exit", (g_PlaceholderName + " Crash").c_str() , MB_OK);
return 0;
}
SendMessage(hwndMain, WM_SETICON, ICON_BIG,(LPARAM)LoadImage(GetModuleHandle(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE));
Application app = Application(hwndMain);
app.run();
}
catch(...)
{
OnError(-1);
}
return 0;
}