[問題] console模式下 使否有類似WndProc的方法取得message?

作者: godzilla1954 (阿維)   2017-09-15 13:45:02
這問題困擾我好久 希望知道的高手能夠指點一下
問題:
原本有一個C#視窗程式 這個程式呼叫別人寫的API
[DllImport(@"..\API.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool GetInformation(IntPtr app );
呼叫這個API 他就會把一些資訊用Message回傳
並且將一些參數 或是特定資訊紀錄在Msg LParam WParam 等等
為了要取得這些資訊 在視窗程式中會去複寫WndProc這個方 去取得Message
並且過濾只拿GetInformation所回傳的訊息:
protected override void WndProc(ref Message m)
{
if (m.Msg == APIMessage)
{
int wParam = m.WParam.ToInt32();
int lParam = m.LParam.ToInt32();
switch (wParam)
{
case (int)......
break;
....
}
}
base.WndProc(ref m);
}
我的問題是 今天如果我採用console模式去呼叫API
我想請問 在console模式下 使否有類似WndProc 這樣的方法
可以去取得呼叫API後所回傳的Message呢???
作者: pzyc79   2017-09-17 16:10:00
我試了 最後都得到Error: Access is denied.
作者: godzilla1954 (阿維)   2017-09-18 16:16:00
請問您是用怎樣方法 可以分享一下嗎
作者: pzyc79   2017-09-18 17:03:00
The console window belongs to the CSRSS process, notthe CMD.EXE process. CSRSS is a critical system servicthat is protected and cannot be hooked without specialdebug privileges.我是用 user32::SetWindowProc
作者: hatasum (我很可愛)   2017-11-03 14:01:00
如果用console呼叫一個隱藏的winform,那個winform接受wndproc呢?

Links booklink

Contact Us: admin [ a t ] ucptt.com