ふらっとC♯(Part5)
■ このスレッドは過去ログ倉庫に格納されています
0251デフォルトの名無しさん
NGNGusing HANDLE=System.IntPtr;using LPVOID=System.IntPtr;using SIZE_T=System.UInt32;using DWORD=System.UInt32;
class CMyApp:System.Windows.Forms.Form
{
[System.Runtime.InteropServices.DllImportAttribute("kernel32")]
static extern LPVOID VirtualAllocEx(HANDLE hProcess,LPVOID lpAddress,SIZE_T dwSize,DWORD flAllocationType,DWORD flProtect);
DWORD PAGE_READWRITE=0x04;
DWORD MEM_COMMIT= 0x1000;
static void Main()
{
System.Windows.Forms.Application.Run(new CMyApp());
}
CMyApp()
{
this.Click+=new System.EventHandler(OnClick);
}
void OnClick(object sender,System.EventArgs e)
{
LPVOID 自分側の領域=VirtualAllocEx(System.Diagnostics.Process.GetCurrentProcess().Handle,(LPVOID)0,(DWORD)System.Runtime.InteropServices.Marshal.SizeOf(typeof(System.TimeSpan)),MEM_COMMIT,PAGE_READWRITE);
LPVOID 他人側の領域=new LPVOID();
foreach(System.Diagnostics.Process inc in System.Diagnostics.Process.GetProcesses())
if("Explorer"==inc.ProcessName)
他人側の領域=VirtualAllocEx(inc.Handle,(LPVOID)0,(DWORD)System.Runtime.InteropServices.Marshal.SizeOf(typeof(System.TimeSpan)),MEM_COMMIT,PAGE_READWRITE);
System.Runtime.InteropServices.Marshal.PtrToStructure(自分側の領域,typeof(System.TimeSpan));//自分側の領域では例外は発生しない
System.Windows.Forms.MessageBox.Show("次で例外発生");
System.Runtime.InteropServices.Marshal.PtrToStructure(他人側の領域,typeof(System.TimeSpan));
}
}
■ このスレッドは過去ログ倉庫に格納されています