本文整理汇总了C#中System.Byte.GetLowerBound方法的典型用法代码示例。如果您正苦于以下问题:C# Byte.GetLowerBound方法的具体用法?C# Byte.GetLowerBound怎么用?C# Byte.GetLowerBound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Byte
的用法示例。
在下文中一共展示了Byte.GetLowerBound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public override Int32 Read(Byte[] buffer, Int32 offset, Int32 count)
{
// According to MS documentation, any implementation of the IO.Stream.Read function must:
// (a) throw an exception if offset & count reference an invalid part of the buffer,
// or if count < 0, or if buffer is null
// (b) return 0 only upon EOF, or if count = 0
// (c) if not EOF, then return at least 1 byte, up to <count> bytes
if (_streamMode == StreamMode.Undefined) {
if (!this._stream.CanRead) {
throw new ZlibException("The stream is not readable.");
}
// for the first read, set up some controls.
_streamMode = StreamMode.Reader;
// (The first reference to _z goes through the private accessor which
// may initialize it.)
z.AvailableBytesIn = 0;
if (_flavor == ZlibStreamFlavor.GZIP) {
_gzipHeaderByteCount = _ReadAndValidateGzipHeader();
// workitem 8501: handle edge case (decompress empty stream)
if (_gzipHeaderByteCount == 0) {
return 0;
}
}
}
if (_streamMode != StreamMode.Reader) {
throw new ZlibException("Cannot Read after Writing.");
}
if (count == 0) {
return 0;
}
if (nomoreinput && _wantCompress) {
return 0; // workitem 8557
}
if (buffer == null) {
throw new ArgumentNullException("buffer");
}
if (count < 0) {
throw new ArgumentOutOfRangeException("count");
}
if (offset < buffer.GetLowerBound(0)) {
throw new ArgumentOutOfRangeException("offset");
}
if ((offset + count) > buffer.GetLength(0)) {
throw new ArgumentOutOfRangeException("count");
}
int rc = 0;
// set up the output of the deflate/inflate codec:
_z.OutputBuffer = buffer;
_z.NextOut = offset;
_z.AvailableBytesOut = count;
// This is necessary in case _workingBuffer has been resized. (new byte[])
// (The first reference to _workingBuffer goes through the private accessor which
// may initialize it.)
_z.InputBuffer = workingBuffer;
do {
// need data in _workingBuffer in order to deflate/inflate. Here, we check if we have any.
if ((_z.AvailableBytesIn == 0) && (!nomoreinput)) {
// No data available, so try to Read data from the captive stream.
_z.NextIn = 0;
_z.AvailableBytesIn = _stream.Read(_workingBuffer, 0, _workingBuffer.Length);
if (_z.AvailableBytesIn == 0) {
nomoreinput = true;
}
}
// we have data in InputBuffer; now compress or decompress as appropriate
rc = (_wantCompress)
? _z.Deflate(_flushMode)
: _z.Inflate(_flushMode);
if (nomoreinput && (rc == ZlibConstants.Z_BUF_ERROR)) {
return 0;
}
if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END) {
throw new ZlibException(String.Format("{0}flating: rc={1} msg={2}", (_wantCompress ? "de" : "in"), rc, _z.Message));
}
if ((nomoreinput || rc == ZlibConstants.Z_STREAM_END) && (_z.AvailableBytesOut == count)) {
break; // nothing more to read
}
} //while (_z.AvailableBytesOut == count && rc == ZlibConstants.Z_OK);
while (_z.AvailableBytesOut > 0 && !nomoreinput && rc == ZlibConstants.Z_OK);
// workitem 8557
// is there more room in output?
if (_z.AvailableBytesOut > 0) {
if (rc == ZlibConstants.Z_OK && _z.AvailableBytesIn == 0) {
// deferred
}
// are we completely done reading?
if (nomoreinput) {
// and in compression?
//.........这里部分代码省略.........
示例2: PacketSender2
public void PacketSender2(Byte[] pPacket)
{
IntPtr BytesAddr;
long pSize;
Byte[] pCode;
pSize = pPacket.GetUpperBound(0) - pPacket.GetLowerBound(0) + 1;
BytesAddr = VirtualAllocEx(GameProcessHandle, IntPtr.Zero, pPacket.Length, MEM_COMMIT, PAGE_READWRITE);
if (DEBUG_MODE)
log("VAM Address: " + AlignDWORD(BytesAddr));
if (BytesAddr == IntPtr.Zero || BytesAddr == null)
{
if (DEBUG_MODE)
log(">>> Error commiting memory: " + AlignDWORD(BytesAddr));
VirtualFreeEx(GameProcessHandle, BytesAddr, 0, MEM_RELEASE);
return;
}
WriteProcessMemory(GameProcessHandle, BytesAddr, pPacket, pSize, 0);
String cCode = "608B0D" + AlignDWORD(new IntPtr(PTR_PKT)) + "68" + AlignDWORD(new IntPtr(pSize)) + "68" + AlignDWORD(BytesAddr) + "BF" + AlignDWORD(new IntPtr(SND_FNC)) + "FFD7C605" + AlignDWORD(new IntPtr(PTR_PKT + 0xC5)) + "0061C3";
pCode = ToByteArray(cCode);
ExecuteRemoteCode(pCode);
WriteMemory(new IntPtr(PTR_PKT + 0xC5), 0);
VirtualFreeEx(GameProcessHandle, BytesAddr, 0, MEM_RELEASE);
}