This is the line where it crashes:
if(!(PixelFormat = ChoosePixelFormat(hDC, &pfd))){
This is what errors it gives me on the SUA tool:
- 0x332D Error The application was denied access to an object.
- 0x331B Error Access was restricted to trusted users only.
How do i fix these errors and prevent the usage of Application Verifier with LuaPriv checks enabled from causing crash when debugging?
--
Here is the full program that crashes, i have stripped down the code as much as i could:
#pragma comment(lib, "opengl32.lib")
#include <windows.h>
#include <GL\gl.h>
HDC hDC = NULL;
HGLRC hRC = NULL;
HWND hWnd = NULL;
HINSTANCE hInstance;
bool CreateGLWindow(int width, int height, int bits){
GLuint PixelFormat;
WNDCLASS wc;
DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
DWORD dwStyle = WS_OVERLAPPEDWINDOW;
RECT WindowRect;
WindowRect.left = (long)0;
WindowRect.right = (long)width;
WindowRect.top = (long)0;
WindowRect.bottom = (long)height;
hInstance = GetModuleHandle(NULL);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)DefWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "OpenGL";
if(!RegisterClass(&wc)){
exit(1);
}
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
if(!(hWnd = CreateWindowEx(
dwExStyle,
"OpenGL",
"debug test",
dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0,
0,
WindowRect.right-WindowRect.left,
WindowRect.bottom-WindowRect.top,
NULL,
NULL,
hInstance,
NULL)))
{
exit(1);
}
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
(BYTE)bits,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
if(!(hDC = GetDC(hWnd))){
exit(1);
}
if(!(PixelFormat = ChoosePixelFormat(hDC, &pfd))){ // crash at here only when AV enabled with LuaPriv checks.
exit(1);
}
if(!SetPixelFormat(hDC, PixelFormat, &pfd)){
exit(1);
}
if(!(hRC = wglCreateContext(hDC))){
exit(1);
}
if(!wglMakeCurrent(hDC, hRC)){
exit(1);
}
ShowWindow(hWnd, SW_SHOW);
SetForegroundWindow(hWnd);
SetFocus(hWnd);
return 1;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
if(!CreateGLWindow(1024, 768, 32)){
exit(1);
}
while(1){
if(GetAsyncKeyState(VK_ESCAPE)){
exit(1);
}
}
return 1;
}