using User buffer in Video driver ???

I’m using buffer in video driver(mirror driver).

When using user buffer in driver, the computer is rebootted…

the code follows…

----- application —
//
// DrvEscape test
//

LPSTR pvIn = (LPSTR)GlobalAlloc(GPTR, 100);
LPSTR pvOut= (LPSTR)GlobalAlloc(GPTR, 100);
if( !pvIn || !pvOut)
printf(“Error GlobalAlloc\n\n”);

memcpy(pvIn, “ABCDEFGHIJKLMNOPQRSTUVWXYZ”, 20);
memset(pvOut, 0, 100);
int cjIn = 10;
int cjOut = 100;

ULONG nR = ExtEscape(hdc, ESC_TEST, cjIn, pvIn, cjIn, pvOut);
printf(“Test: nR – %d\n”, nR);
printf(“Org(%X): %s\n”, (LPVOID)pvIn, pvIn);
printf(“Out(%X): %s\n”, (LPVOID)pvOut, pvOut);

printf(“Press anyKey\n”); getchar();

// this code cause rebooting… -.-;
nR = ExtEscape(hdc, ESC_TEST_COPY, cjIn, pvIn, cjIn, pvOut);
printf(“TestCopy: nR – %d\n”, nR);
printf(“Org(%X): %s\n”, (LPVOID)pvIn, pvIn);
printf(“Out(%X): %s\n”, (LPVOID)pvOut, pvOut);

---- enable.c in mirror driver sample ----

ULONG
DrvEscape(
SURFOBJ * pso,
ULONG iEsc,
ULONG cjIn,
PVOID pvIn,
ULONG cjOut,
PVOID pvOut)
{
//KIRQL irql = KeGetCurrentIrql();

switch (iEsc)
{
case ESC_TEST:
{
DISPDBG((0, “ESC %X: cjIn: %d(%X), cjOut: %d(%X)\n”,
iEsc, cjIn, pvIn, cjOut, pvOut));

return (100); // SUCCESS
}
case ESC_TEST_COPY:
{
DISPDBG((0, “ESC %X: cjIn: %d(%X), cjOut: %d(%X)\n”,
iEsc, cjIn, pvIn, cjOut, pvOut));
//if (irql >= DISPATCH_LEVEL) return 1001;
//ASSERT( irql < DISPATCH_LEVEL);
RtlCopyMemory( (void*)cjOut, (void*)cjIn, 10 );
return (101); // SUCCESS
}
}

return 0; // NOT SUPPORT.
}

(1) Make sure your escape codes values are not in the range 0 - 0x10000;
(2) Set a break in our DrvEscape and look at the memory passed in to you.