本文整理汇总了C#中System.IntPtr.Increment方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.Increment方法的具体用法?C# IntPtr.Increment怎么用?C# IntPtr.Increment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IntPtr
的用法示例。
在下文中一共展示了IntPtr.Increment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MemoryEditor
public MemoryEditor(int PID, IntPtr Address, long Length)
{
InitializeComponent();
this.AddEscapeToClose();
this.SetTopMost();
_pid = PID;
_address = Address;
_length = Length;
Program.MemoryEditors.Add(this.Id, this);
this.Text = Program.ProcessProvider.Dictionary[_pid].Name + " (PID " + _pid.ToString() +
"), " + Utils.FormatAddress(_address) + "-" +
Utils.FormatAddress(_address.Increment(_length)) + " - Memory Editor";
try
{
ReadMemory();
}
catch
{
this.Visible = false;
MessageBox.Show("Could not read process memory:\n\n" + Win32.GetLastErrorMessage(),
"Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}
hexBoxMemory.Select();
}
示例2: AlignedMemoryAlloc
public AlignedMemoryAlloc(int size, int alignment)
{
if (alignment <= 0 || Utils.CountBits(alignment) != 1)
throw new ArgumentOutOfRangeException("alignment");
_realMemory = MemoryAlloc.PrivateHeap.Allocate(0, size + alignment - 1);
this.Memory = _realMemory.Increment(alignment - 1).And((alignment - 1).ToIntPtr().Not());
this.Size = size;
}
示例3: SymbolInformation
internal SymbolInformation(IntPtr symbolInfo, int symbolSize)
{
SymbolInfo si = (SymbolInfo)Marshal.PtrToStructure(symbolInfo, typeof(SymbolInfo));
this.Flags = si.Flags;
this.Index = si.Index;
this.ModuleBase = si.ModBase;
this.Name = Marshal.PtrToStringAnsi(symbolInfo.Increment(Win32.SymbolInfoNameOffset), si.NameLen);
this.Size = symbolSize;
this.Address = si.Address;
}
示例4: CopyProcessParameters
//.........这里部分代码省略.........
status = Win32.RtlCreateProcessParameters(
out processParameters,
ref imagePathNameStr,
ref dllPathStr,
ref currentDirectoryStr,
ref commandLineStr,
environment,
ref windowTitleStr,
ref desktopInfoStr,
ref shellInfoStr,
ref runtimeInfoStr
);
if (status >= NtStatus.Error)
Win32.Throw(status);
try
{
// Allocate a new memory region in the remote process for
// the environment block and copy it over.
int environmentLength;
IntPtr newEnvironment;
environmentLength = environment.GetLength();
newEnvironment = processHandle.AllocateMemory(
environmentLength,
MemoryProtection.ReadWrite
);
processHandle.WriteMemory(
newEnvironment,
environment,
environmentLength
);
// Copy over the startup info data.
RtlUserProcessParameters* paramsStruct = (RtlUserProcessParameters*)processParameters;
paramsStruct->Environment = newEnvironment;
paramsStruct->StartingX = startupInfo.X;
paramsStruct->StartingY = startupInfo.Y;
paramsStruct->CountX = startupInfo.XSize;
paramsStruct->CountY = startupInfo.YSize;
paramsStruct->CountCharsX = startupInfo.XCountChars;
paramsStruct->CountCharsY = startupInfo.YCountChars;
paramsStruct->FillAttribute = startupInfo.FillAttribute;
paramsStruct->WindowFlags = startupInfo.Flags;
paramsStruct->ShowWindowFlags = startupInfo.ShowWindow;
if ((startupInfo.Flags & StartupFlags.UseStdHandles) == StartupFlags.UseStdHandles)
{
paramsStruct->StandardInput = startupInfo.StdInputHandle;
paramsStruct->StandardOutput = startupInfo.StdOutputHandle;
paramsStruct->StandardError = startupInfo.StdErrorHandle;
}
// TODO: Add console support.
// Allocate a new memory region in the remote process for
// the process parameters.
IntPtr newProcessParameters;
IntPtr regionSize = paramsStruct->Length.ToIntPtr();
newProcessParameters = processHandle.AllocateMemory(
IntPtr.Zero,
ref regionSize,
MemoryFlags.Commit,
MemoryProtection.ReadWrite
);
paramsStruct->MaximumLength = regionSize.ToInt32();
processHandle.WriteMemory(newProcessParameters, processParameters, paramsStruct->Length);
// Modify the process parameters pointer in the PEB.
processHandle.WriteMemory(
peb.Increment(Peb.ProcessParametersOffset),
&newProcessParameters,
IntPtr.Size
);
}
finally
{
Win32.RtlDestroyProcessParameters(processParameters);
}
}
finally
{
imagePathNameStr.Dispose();
dllPathStr.Dispose();
currentDirectoryStr.Dispose();
commandLineStr.Dispose();
windowTitleStr.Dispose();
desktopInfoStr.Dispose();
shellInfoStr.Dispose();
runtimeInfoStr.Dispose();
}
}
示例5: ReadOnce
private unsafe int ReadOnce(StructField field, IntPtr offset, out FieldValue valueOut)
{
FieldValue value = new FieldValue() { FieldType = field.Type, Name = field.Name };
int readSize = 0;
switch (field.Type)
{
case FieldType.Bool32:
value.Value = Utils.ToInt32(IOProvider.ReadBytes(offset, 4),
Utils.Endianness.Little) != 0;
readSize = 4;
break;
case FieldType.Bool8:
value.Value = IOProvider.ReadBytes(offset, 1)[0] != 0;
readSize = 1;
break;
case FieldType.CharASCII:
value.Value = (char)IOProvider.ReadBytes(offset, 1)[0];
readSize = 1;
break;
case FieldType.CharUTF16:
value.Value = Encoding.Unicode.GetString(IOProvider.ReadBytes(offset, 2))[0];
readSize = 2;
break;
case FieldType.Double:
{
long data = Utils.ToInt64(
IOProvider.ReadBytes(offset, 8), Utils.Endianness.Little);
value.Value = *(double*)&data;
readSize = 8;
}
break;
case FieldType.Int16:
value.Value = (short)Utils.ToUInt16(
IOProvider.ReadBytes(offset, 2), Utils.Endianness.Little);
readSize = 2;
break;
case FieldType.Int32:
value.Value = Utils.ToInt32(
IOProvider.ReadBytes(offset, 4), Utils.Endianness.Little);
readSize = 4;
break;
case FieldType.Int64:
value.Value = Utils.ToInt64(
IOProvider.ReadBytes(offset, 8), Utils.Endianness.Little);
readSize = 8;
break;
case FieldType.Int8:
value.Value = (sbyte)IOProvider.ReadBytes(offset, 1)[0];
readSize = 1;
break;
case FieldType.PVoid:
value.Value = IOProvider.ReadBytes(offset, IntPtr.Size).ToIntPtr();
readSize = IntPtr.Size;
break;
case FieldType.Single:
{
int data = Utils.ToInt32(
IOProvider.ReadBytes(offset, 4), Utils.Endianness.Little);
value.Value = *(float*)&data;
readSize = 4;
}
break;
case FieldType.StringASCII:
{
StringBuilder str = new StringBuilder();
if (field.VarLength == -1)
{
int i;
for (i = 0; ; i++)
{
byte b = IOProvider.ReadBytes(offset.Increment(i), 1)[0];
if (b == 0)
break;
str.Append((char)b);
}
readSize = i;
}
else
{
str.Append(Encoding.ASCII.GetString(
IOProvider.ReadBytes(offset, field.VarLength)));
readSize = field.VarLength;
}
value.Value = str.ToString();
}
break;
case FieldType.StringUTF16:
{
StringBuilder str = new StringBuilder();
//.........这里部分代码省略.........
示例6: Read
private int Read(StructField field, IntPtr offset, out FieldValue valueOut)
{
if (!field.IsArray)
return this.ReadOnce(field, offset, out valueOut);
// read array
FieldValue value = new FieldValue() { FieldType = field.RawType, Name = field.Name };
int readSize = 0;
List<FieldValue> valueArray = new List<FieldValue>();
for (int i = 0; i < field.VarArrayLength; i++)
{
FieldValue elementValue;
readSize = offset.Increment(readSize).Align(field.Alignment).Decrement(offset).ToInt32();
readSize += this.ReadOnce(field, offset.Increment(readSize), out elementValue);
elementValue.Name = "[" + i.ToString() + "]";
valueArray.Add(elementValue);
}
value.Value = valueArray.ToArray();
value.StructName = field.StructName;
valueOut = value;
return readSize;
}