| Bug # | Delphi versions | Description |
| 74 | 1.02 2.01 3.0 3.01 3.02 4.0 4.01 4.02 |
QuickReport There's a bug in QuickReport 2.0b (version released with Delphi 3.0 c/s) and QuickReport 2.0d (registered version) |
Bug #74; last modified: before April 1998| 1.02 | 2.01 | 3.0 | 3.01 | 3.02 | 4.0 | 4.01 | 4.02 |
| N/A | Exists | Exists | Unknown | Unknown | Unknown | Unknown | Unknown |
"I've located a bug in QuickReport 2.0b (version released with Delphi
3.0 c/s) and QuickReport 2.0d (registered version). It appears whenever
we attempt to drop a TQuickRep component on a form. We receive a message
box stating: Error, Privileged Instruction. My boss registered the source
and gave me the task of finding the problem. I built two packages for use
in Delphi 3.0 and traced the bug to QRPRNTR. The bug appears in the 'GPaperSizes'
procedure. The 'DCResult' parameter is hard coded to be 64 words long.
This is an invalid assumption: the DeviceCapabilities() call returns a
count of 69 which overwrites memory and causes all kinds of errors. When
I built the code with an array of [0..255], the problem disappeared. This
call appears to need some work as DeviceCapabilities() is able to return
the size of the word array necessary.
I would also like to suggest that you post some directions on repackaging
the QuickReport 2.0 source for Delphi 3.0.
Below is the source for GPaperSizes which exhibits the bug.
procedure GPaperSizes;
var
DCResult : array[0..64] of word;
I : integer;
J : TQRPaperSize;
Count : integer;
{$ifndef win32}
DeviceCapabilities : TDeviceCapabilities;
FDeviceHandle : THandle;
DriverName: array[0..255] of Char;
{$endif}
begin
Fillchar(DCResult,SizeOf(DCResult),#0);
Fillchar(FPaperSizes,Sizeof(FPaperSizes),#0);
{$ifdef win32}
Count := DeviceCapabilities(FDevice, FPort, DC_PAPERS, @DCResult,DevMode);
{$else}
StrCat(StrCopy(DriverName, FDriver), '.DRV');
FDeviceHandle := LoadLibrary(DriverName);
if FDeviceHandle <= 16 then FDeviceHandle := 0;
if FDeviceHandle <> 0 then
begin
@DeviceCapabilities := GetProcAddress(FDeviceHandle,'DeviceCapabilities');
if assigned(DeviceCapabilities) then
Count := DeviceCapabilities(FDevice,FPort,DC_PAPERS,@DCResult,DevMode^)
else
Count := 0;
end;
if FDeviceHandle <> 0 then FreeLibrary(FDeviceHandle);
{$endif}
for I := 0 to Count - 1 do
begin
for J := Default to Custom do
begin
if cQRPaperTranslate[J] = DCResult[I] then
begin
FPaperSizes[J] := true;
break;
end
end
end
end;"