本文整理汇总了C#中System.VoidPtr类的典型用法代码示例。如果您正苦于以下问题:C# VoidPtr类的具体用法?C# VoidPtr怎么用?C# VoidPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VoidPtr类属于System命名空间,在下文中一共展示了VoidPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Duplicate
internal static unsafe SafeHandle Duplicate(VoidPtr hFile)
{
VoidPtr hProc = Process.GetCurrentProcess().Handle;
if (!DuplicateHandle(hProc, hFile, hProc, out hFile, 0, false, 2))
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
return new SafeHandle(hFile);
}
示例2: EncodeBlock
protected override void EncodeBlock(ARGBPixel* sPtr, VoidPtr blockAddr, int width)
{
wRGB5A3Pixel* dPtr = (wRGB5A3Pixel*)blockAddr;
for (int y = 0; y < BlockHeight; y++, sPtr += width)
for (int x = 0; x < BlockWidth; )
*dPtr++ = (wRGB5A3Pixel)sPtr[x++];
}
示例3: GetArrayFromAddress
/// <summary>
/// Copies data from memory at a specific address into an array
/// </summary>
/// <param name="source"></param>
/// <param name="sourceOffset"></param>
/// <param name="target"></param>
/// <param name="targetOffset"></param>
/// <param name="Length"></param>
public static byte[] GetArrayFromAddress(VoidPtr Address, int length)
{
byte[] arr = new byte[length];
for (int i = 0; i < length; i++)
arr[i] = *(byte*)(Address + i);
return arr;
}
示例4: Parse
public override void Parse(VoidPtr address)
{
MoveDefLookupOffsetNode o;
bint* addr = First;
VoidPtr current = BaseAddress + *addr++;
VoidPtr next = BaseAddress + *addr++;
int size = 0;
for (int i = 1; i < Count; i++)
{
size = (int)next - (int)current;
(o = new MoveDefLookupOffsetNode()).Initialize(this, current, size);
if (_root._lookupSizes.ContainsKey(o.DataOffset))
if (_root._lookupSizes[o.DataOffset].DataSize < o.DataSize)
_root._lookupSizes[o.DataOffset] = o;
else { }
else
_root._lookupSizes.Add(o.DataOffset, o);
current = next;
next = BaseAddress + *addr++;
}
size = ((int)_offset - (int)(current - BaseAddress));
(o = new MoveDefLookupOffsetNode()).Initialize(this, current, size);
if (!_root._lookupSizes.ContainsKey(o.DataOffset))
_root._lookupSizes.Add(o.DataOffset, o);
//Sorting by data offset will allow us to get the exact size of every entry!
Children.Sort(MoveDefLookupOffsetNode.LookupCompare);
}
示例5: IsDataCompressed
public static bool IsDataCompressed(VoidPtr addr, int length)
{
if (*(uint*)addr == YAZ0.Tag)
return true;
else
{
CompressionHeader* cmpr = (CompressionHeader*)addr;
if (cmpr->ExpandedSize < length)
return false;
if (!cmpr->HasLegitCompression())
return false;
char[] chars = characters.ToCharArray();
//Check to make sure we're not reading a tag
byte* c = (byte*)addr;
byte[] tag = { c[0], c[1], c[2], c[3] };
if ((Array.IndexOf(chars, (char)tag[0]) >= 0) &&
(Array.IndexOf(chars, (char)tag[1]) >= 0) &&
(Array.IndexOf(chars, (char)tag[2]) >= 0) &&
(Array.IndexOf(chars, (char)tag[3]) >= 0))
return false;
return true;
}
}
示例6: OnWrite
protected override void OnWrite(VoidPtr address)
{
_rebuildAddr = address;
*(buint*)address = v1._data;
*(buint*)(address + 4) = v2._data;
}
示例7: DecodeBlock
protected override void DecodeBlock(VoidPtr blockAddr, ARGBPixel* dPtr, int width)
{
byte* sPtr = (byte*)blockAddr;
byte b;
if (_workingPalette != null)
{
for (int y = 0; y < BlockHeight; y++, dPtr += width)
for (int x = 0; x < BlockWidth; )
{
b = *sPtr++;
dPtr[x++] = (ARGBPixel)_workingPalette.Entries[b >> 4];
dPtr[x++] = (ARGBPixel)_workingPalette.Entries[b & 0xF];
}
}
else
{
for (int y = 0; y < BlockHeight; y++, dPtr += width)
for (int x = 0; x < BlockWidth; )
{
b = *sPtr++;
dPtr[x++] = new ARGBPixel((byte)(b & 0xF0));
dPtr[x++] = new ARGBPixel((byte)(b << 4));
}
}
}
示例8: DataSource
public DataSource(VoidPtr addr, int len, CompressionType compression)
{
Address = addr;
Length = len;
Map = null;
Compression = compression;
}
示例9: OnRebuild
public override void OnRebuild(VoidPtr address, int length, bool force)
{
RWAR* header = (RWAR*)address;
header->_header._version = 0x100;
header->_header._tag = RWAR.Tag;
header->_header.Endian = Endian.Big;
header->_header._length = length;
header->_header._firstOffset = 0x20;
header->_header._numEntries = 2;
header->_tableOffset = 0x20;
RWARTableBlock* tabl = (RWARTableBlock*)(address + 0x20);
tabl->_header._tag = RWARTableBlock.Tag;
tabl->_header._length = (12 + Children.Count * 12).Align(0x20);
tabl->_entryCount = (uint)Children.Count;
header->_tableLength = tabl->_header._length;
header->_dataOffset = 0x20 + header->_tableLength;
RWARDataBlock* data = (RWARDataBlock*)(address + 0x20 + tabl->_header._length);
data->_header._tag = RWARDataBlock.Tag;
VoidPtr addr = (VoidPtr)data + 0x20;
foreach (RWAVNode n in Children)
{
tabl->Entries[n.Index].waveFileRef = (uint)(addr - (VoidPtr)data);
//Memory.Move(addr, n.WorkingSource.Address, (uint)n.WorkingSource.Length);
n.MoveRaw(addr, n.WorkingUncompressed.Length);
addr += (tabl->Entries[n.Index].waveFileSize = (uint)n.WorkingUncompressed.Length);
}
data->_header._length = (int)(addr - (VoidPtr)data);
header->_dataLength = data->_header._length;
}
示例10: DecodeFrames
public static void DecodeFrames(KeyframeArray kf, VoidPtr offset, int flags, int fixedBit)
{
if ((flags & fixedBit) != 0)
kf[0] = *(bfloat*)offset;
else
DecodeFrames(kf, offset + *(bint*)offset);
}
示例11: Expand
public static void Expand(CompressionHeader* header, VoidPtr dstAddress, int dstLen)
{
uint total = 0;
VoidPtr ceil = dstAddress + dstLen;
if (header->Parameter != 1)
{
byte* pSrc = (byte*)header->Data;
byte* pDst = (byte*)dstAddress;
do
{
total += *pSrc++;
*pDst++ = (byte)total;
}
while (pSrc < ceil);
}
else
{
bushort* pSrc = (bushort*)header->Data;
bushort* pDst = (bushort*)dstAddress;
do
{
total += *pSrc++;
*pDst++ = (ushort)total;
}
while (pSrc < ceil);
}
}
示例12: Fill
internal static unsafe void Fill(VoidPtr dest, uint length, byte value)
{
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32NT: { Win32.FillMemory(dest, length, value); break; }
case PlatformID.Unix: { Linux.memset(dest, value, length); break; }
}
}
示例13: DecodeBlock
protected override void DecodeBlock(VoidPtr blockAddr, ARGBPixel* dPtr, int width)
{
wRGB5A3Pixel* sPtr = (wRGB5A3Pixel*)blockAddr;
//ARGBPixel* dPtr = (ARGBPixel*)destAddr;
for (int y = 0; y < BlockHeight; y++, dPtr += width)
for (int x = 0; x < BlockWidth; )
dPtr[x++] = (ARGBPixel)(*sPtr++);
}
示例14: EncodeBlock
protected override void EncodeBlock(ARGBPixel* sPtr, VoidPtr blockAddr, int width)
{
byte* stPtr = (byte*)sPtr;
byte* dPtr = (byte*)blockAddr;
for (int y = 0; y < BlockHeight; y++, stPtr += width)
for (int x = 0; x < BlockWidth; )
*dPtr++ = stPtr[x++];
}
示例15: OnWrite
protected override void OnWrite(VoidPtr address)
{
VoidPtr addr = address;
foreach (ArticleEntry b in Children)
{
b._buildHeader = false;
b.Rebuild(addr, b._childLength, true);
addr += b._childLength;
}
VoidPtr start = addr;
foreach (ArticleEntry b in Children)
{
b._rebuildAddr = addr;
Article* article = (Article*)addr;
article->_id = b.id;
article->_boneID = b.charBone;
article->_arcGroup = b.articleBone;
article->_actionsStart = b.aStart;
article->_actionFlagsStart = b.aFlags;
article->_subactionFlagsStart = b.sFlags;
article->_subactionMainStart = b.sMStart;
article->_subactionGFXStart = b.sGStart;
article->_subactionSFXStart = b.sSStart;
article->_modelVisibility = b.visStart;
article->_collisionData = b.off1;
article->_unknownD2 = b.off2;
article->_unknownD3 = b.off3;
bint* ext = (bint*)((VoidPtr)article + 52);
ext[0] = (b._subActions == null ? 0 : b._subActions.Children.Count);
//Add all header offsets
bint* off = (bint*)(addr + 12);
for (int i = 0; i < 10 + b._extraOffsets.Count; i++)
if (off[i] > 1480 && off[i] < _root.dataSize)
b._lookupOffsets.Add(&off[i]);
_lookupOffsets.AddRange(b._lookupOffsets);
addr += b._entryLength;
}
FDefListOffset* header = (FDefListOffset*)addr;
_rebuildAddr = header;
if (Children.Count > 0)
{
header->_startOffset = (int)start - (int)RebuildBase;
_lookupOffsets.Add(header->_startOffset.Address);
}
header->_listCount = Children.Count;
}