Discussion:
DEVMODE bug in App Verifier 3.4.0158
(too old to reply)
marko
2007-11-26 19:52:04 UTC
Permalink
hi there, AV 3.4.0158 has a bug that is hindering our testing. the Printing
PrintAPI test is falsely generating the stop error "A DEVMODE buffer
parameter spans across non-readable memory page(s)". the problem occurs when
ANSI applications are being verified, and the cause of the bug appears to be
that the AV hook is dereferencing ANSI DEVMODEA structures as if they were
Unicode DEVMODEW structures. I can tell this because of the expected DEVMODE
size reported by AV.

here is a sample app that causes the problem:

#include <windows.h>

int WINAPI WinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR pszCmdLine,
int nCmdShow)
{
HANDLE hPrinter;

// assume that this system has Microsoft XPS Document Writer
// if not, just change it to any existing printer
if (OpenPrinterA("Microsoft XPS Document Writer", &hPrinter, NULL)) {
DWORD cbInfo;
PRINTER_INFO_2 *pInfo;

GetPrinterA(hPrinter, 2, NULL, 0, &cbInfo);
pInfo = (PRINTER_INFO_2 *)new BYTE [cbInfo];
GetPrinterA(hPrinter, 2, (BYTE *)pInfo, cbInfo, &cbInfo);

// this call to SetPrinterA will cause Application Verifier to falsely
// generate a DEVMODE error
SetPrinterA(hPrinter, 2, (BYTE *)pInfo, 0);

ClosePrinter(hPrinter);
delete pInfo;
}
return (0);
}
Manski, MSFT
2007-11-26 23:30:00 UTC
Permalink
I confirm that this is a bug in our code. I just fixed it, it will take some
time for the fix to be shipped.

In the mean time there are two possible workarounds you can use:
1) disable temporarily only this particular verifier stop code
2) use SetPrinterW instead of SetPrinterA (the unicode version does not have
this bug)

You can disable the stop code this way:
1) start application verifier
2) select your executable in the left panel
3) expand the Printing treeview node on the right panel
4) right click on the PrintAPI treeview entry and pick "Verifier stop
options" from the context menu
5) Find the stop code in the list box (A01E, if I remember correctly)
6) set the Severity to "Ignore" and Error reporting to "No Break"

You can achieve the same in a scriptable way:
appverif -configure A01E -for MYAPP.exe -with ErrorReport=0x181
appverif -configure A01E -for MYAPP.exe -with Flavor=0x20
appverif -configure A01E -for MYAPP.exe -with Severity=0x0



I'm sorry for the inconvenience.

Manski
Post by marko
hi there, AV 3.4.0158 has a bug that is hindering our testing. the Printing
PrintAPI test is falsely generating the stop error "A DEVMODE buffer
parameter spans across non-readable memory page(s)". the problem occurs when
ANSI applications are being verified, and the cause of the bug appears to be
that the AV hook is dereferencing ANSI DEVMODEA structures as if they were
Unicode DEVMODEW structures. I can tell this because of the expected DEVMODE
size reported by AV.
#include <windows.h>
int WINAPI WinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR pszCmdLine,
int nCmdShow)
{
HANDLE hPrinter;
// assume that this system has Microsoft XPS Document Writer
// if not, just change it to any existing printer
if (OpenPrinterA("Microsoft XPS Document Writer", &hPrinter, NULL)) {
DWORD cbInfo;
PRINTER_INFO_2 *pInfo;
GetPrinterA(hPrinter, 2, NULL, 0, &cbInfo);
pInfo = (PRINTER_INFO_2 *)new BYTE [cbInfo];
GetPrinterA(hPrinter, 2, (BYTE *)pInfo, cbInfo, &cbInfo);
// this call to SetPrinterA will cause Application Verifier to falsely
// generate a DEVMODE error
SetPrinterA(hPrinter, 2, (BYTE *)pInfo, 0);
ClosePrinter(hPrinter);
delete pInfo;
}
return (0);
}
marko
2007-11-27 12:47:06 UTC
Permalink
thank you very much, I will do as you suggest!

--Mark
Post by Manski, MSFT
I confirm that this is a bug in our code. I just fixed it, it will take some
time for the fix to be shipped.
1) disable temporarily only this particular verifier stop code
2) use SetPrinterW instead of SetPrinterA (the unicode version does not have
this bug)
1) start application verifier
2) select your executable in the left panel
3) expand the Printing treeview node on the right panel
4) right click on the PrintAPI treeview entry and pick "Verifier stop
options" from the context menu
5) Find the stop code in the list box (A01E, if I remember correctly)
6) set the Severity to "Ignore" and Error reporting to "No Break"
appverif -configure A01E -for MYAPP.exe -with ErrorReport=0x181
appverif -configure A01E -for MYAPP.exe -with Flavor=0x20
appverif -configure A01E -for MYAPP.exe -with Severity=0x0
I'm sorry for the inconvenience.
Manski
Post by marko
hi there, AV 3.4.0158 has a bug that is hindering our testing. the Printing
PrintAPI test is falsely generating the stop error "A DEVMODE buffer
parameter spans across non-readable memory page(s)". the problem occurs when
ANSI applications are being verified, and the cause of the bug appears to be
that the AV hook is dereferencing ANSI DEVMODEA structures as if they were
Unicode DEVMODEW structures. I can tell this because of the expected DEVMODE
size reported by AV.
#include <windows.h>
int WINAPI WinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR pszCmdLine,
int nCmdShow)
{
HANDLE hPrinter;
// assume that this system has Microsoft XPS Document Writer
// if not, just change it to any existing printer
if (OpenPrinterA("Microsoft XPS Document Writer", &hPrinter, NULL)) {
DWORD cbInfo;
PRINTER_INFO_2 *pInfo;
GetPrinterA(hPrinter, 2, NULL, 0, &cbInfo);
pInfo = (PRINTER_INFO_2 *)new BYTE [cbInfo];
GetPrinterA(hPrinter, 2, (BYTE *)pInfo, cbInfo, &cbInfo);
// this call to SetPrinterA will cause Application Verifier to falsely
// generate a DEVMODE error
SetPrinterA(hPrinter, 2, (BYTE *)pInfo, 0);
ClosePrinter(hPrinter);
delete pInfo;
}
return (0);
}
Loading...