Rev 2 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 4 | ||
---|---|---|---|
Line 111... | Line 111... | ||
111 | //////////////////////////////////////////////////////////////////////////////// |
111 | //////////////////////////////////////////////////////////////////////////////// |
112 | // TFixedStreamAdapter fixes several serious bugs in TStreamAdapter.CopyTo. |
112 | // TFixedStreamAdapter fixes several serious bugs in TStreamAdapter.CopyTo. |
113 | //////////////////////////////////////////////////////////////////////////////// |
113 | //////////////////////////////////////////////////////////////////////////////// |
114 | TFixedStreamAdapter = class(TStreamAdapter, IStream) |
114 | TFixedStreamAdapter = class(TStreamAdapter, IStream) |
115 | public |
115 | public |
116 | function CopyTo(stm: IStream; cb: Largeint; out cbRead: Largeint; |
116 | function CopyTo(stm: IStream; cb: LargeUInt; out cbRead: LargeUInt; |
117 | out cbWritten: Largeint): HResult; override; stdcall; |
117 | out cbWritten: LargeUInt): HResult; override; stdcall; |
118 | end; |
118 | end; |
119 | 119 | ||
120 | //////////////////////////////////////////////////////////////////////////////// |
120 | //////////////////////////////////////////////////////////////////////////////// |
121 | // |
121 | // |
122 | // TMemoryList |
122 | // TMemoryList |
Line 957... | Line 957... | ||
957 | //////////////////////////////////////////////////////////////////////////////// |
957 | //////////////////////////////////////////////////////////////////////////////// |
958 | // |
958 | // |
959 | // TFixedStreamAdapter |
959 | // TFixedStreamAdapter |
960 | // |
960 | // |
961 | //////////////////////////////////////////////////////////////////////////////// |
961 | //////////////////////////////////////////////////////////////////////////////// |
962 | function TFixedStreamAdapter.CopyTo(stm: IStream; cb: Largeint; out cbRead: Largeint; |
962 | function TFixedStreamAdapter.CopyTo(stm: IStream; cb: LargeUInt; out cbRead: LargeUInt; |
963 | out cbWritten: Largeint): HResult; |
963 | out cbWritten: LargeUInt): HResult; |
964 | const |
964 | const |
965 | MaxBufSize = 1024 * 1024; // 1mb |
965 | MaxBufSize = 1024 * 1024; // 1mb |
966 | var |
966 | var |
967 | Buffer: Pointer; |
967 | Buffer: Pointer; |
968 | BufSize, BurstReadSize, BurstWriteSize: Integer; |
968 | BufSize, BurstReadSize, BurstWriteSize: FixedUInt; |
969 | BytesRead, BytesWritten, BurstWritten: LongInt; |
969 | BytesRead, BytesWritten, BurstWritten: FixedUInt; |
970 | begin |
970 | begin |
971 | Result := S_OK; |
971 | Result := S_OK; |
972 | BytesRead := 0; |
972 | BytesRead := 0; |
973 | BytesWritten := 0; |
973 | BytesWritten := 0; |
974 | try |
974 | try |
Line 1067... | Line 1067... | ||
1067 | function TCustomSimpleClipboardFormat.DoGetDataSized(ADataObject: IDataObject; |
1067 | function TCustomSimpleClipboardFormat.DoGetDataSized(ADataObject: IDataObject; |
1068 | const AMedium: TStgMedium; Size: integer): boolean; |
1068 | const AMedium: TStgMedium; Size: integer): boolean; |
1069 | var |
1069 | var |
1070 | Buffer: pointer; |
1070 | Buffer: pointer; |
1071 | Stream: IStream; |
1071 | Stream: IStream; |
1072 | Remaining: longInt; |
1072 | Remaining: FixedUInt; |
1073 | Chunk: longInt; |
1073 | Chunk: FixedUInt; |
1074 | pChunk: PChar; |
1074 | pChunk: PChar; |
1075 | begin |
1075 | begin |
1076 | if (Size > 0) then |
1076 | if (Size > 0) then |
1077 | begin |
1077 | begin |
1078 | (* |
1078 | (* |
Line 1131... | Line 1131... | ||
1131 | function TCustomSimpleClipboardFormat.ReadDataInto(ADataObject: IDataObject; |
1131 | function TCustomSimpleClipboardFormat.ReadDataInto(ADataObject: IDataObject; |
1132 | const AMedium: TStgMedium; Buffer: pointer; Size: integer): boolean; |
1132 | const AMedium: TStgMedium; Buffer: pointer; Size: integer): boolean; |
1133 | var |
1133 | var |
1134 | Stream: IStream; |
1134 | Stream: IStream; |
1135 | p: pointer; |
1135 | p: pointer; |
1136 | Remaining: longInt; |
1136 | Remaining: FixedUInt; |
1137 | Chunk: longInt; |
1137 | Chunk: FixedUInt; |
1138 | begin |
1138 | begin |
1139 | Result := (Buffer <> nil) and (Size > 0); |
1139 | Result := (Buffer <> nil) and (Size > 0); |
1140 | if (Result) then |
1140 | if (Result) then |
1141 | begin |
1141 | begin |
1142 | // Read data from HGlobal |
1142 | // Read data from HGlobal |
Line 1771... | Line 1771... | ||
1771 | Medium: TStgMedium; |
1771 | Medium: TStgMedium; |
1772 | Stream: IStream; |
1772 | Stream: IStream; |
1773 | Name: string; |
1773 | Name: string; |
1774 | MemStream: TMemoryStream; |
1774 | MemStream: TMemoryStream; |
1775 | StatStg: TStatStg; |
1775 | StatStg: TStatStg; |
1776 | Size: longInt; |
1776 | Size: FixedUInt; |
1777 | Remaining: longInt; |
1777 | Remaining: FixedUInt; |
1778 | pChunk: PChar; |
1778 | pChunk: PChar; |
1779 | begin |
1779 | begin |
1780 | Result := False; |
1780 | Result := False; |
1781 | 1781 | ||
1782 | Clear; |
1782 | Clear; |