glReadPixels detour hook crashing, how to do a hook correctly?

  c++, debugging, detours, memory, opengl

I hook wglSwapBuffers(working) and glReadPixels, call the code in wglSwapBuffers:

unsigned char pixels[1 * 1 * 4] = { 0 };
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);

then the app crashes, how can this be hooked to change then pixels?

Error in the debugger:

0 0 1 1 0x19FB14
Exception thrown at 0x0019FB14 in game.exe: 0xC0000005: Access violation writing location 0x00000006.

my detour hook:

void hkglReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
    Log("%i %i %i %i 0x%Xn", x, y, width, height, pixels);

    ((glReadPixels_t)oglReadPixels)(x, y, width, height, format, type, pixels);

opengl32 without detour in memory

Source: Windows Questions C++