PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Re: GetCurrentProcessId import prblem
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Re: GetCurrentProcessId import prblem
![]() |
Re: GetCurrentProcessId import prblem |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Both these functions are defined as inline in the SDK. Current process ID
and current process handle are pseudo id and pseudo handle: _inline HANDLE GetCurrentProcess(void) { return ((HANDLE)(SH_CURPROC+SYS_HANDLE_BASE)); } _inline DWORD GetCurrentThreadId(void) { return ((DWORD)(((HANDLE *)(PUserKData+SYSHANDLE_OFFSET))[SH_CURTHREAD])); } _inline DWORD GetCurrentProcessId(void) { return ((DWORD)(((HANDLE *)(PUserKData+SYSHANDLE_OFFSET))[SH_CURPROC])); I've put together a sample that shows how to access this information on PPC: http://www.alexfeinman.com/download.asp?doc=kfuncs.zip Alex "Timo Meier" <t.meier@contrigo.de> wrote in message news:4thqt-6h.ln1@news.dt.contrigo.de... > Hi, i want to import the following function but i always get an Exception: > System.MissingMethodException > > What is wrong? > > [DllImport("coredll.dll")] > > public static extern int GetCurrentProcessId(); > > [DllImport("coredll.dll")] > > public static extern int GetCurrentProcess(); > > > > |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Alex,
I have tried to use your sample, but have some problems: I get an id, but this is a negative number. I use the ID in SetWindowsHookEx, which fails with a NotSupportedException, and I don't know, if this has something to do with the ID. The function for getting the current thread id: static int GetCurrentThreadID() { uint PUserKData = GetCPUArchitecture() ==PROCESSOR_ARCHITECTURE.PROCESSOR_ARCHITECTURE_ARM? PUserKDataARM:PUserKDataX86; IntPtr pBase = new IntPtr((int) (PUserKData + SYSHANDLE_OFFSET)); return Marshal.ReadInt32(pBase, SH_CURPROC * 4); } PUserKDataARM = 0xFFFFC800, SYSHANDLE_OFFSET = i think 4 in my case. This is uint. Converting it to int results in a negative number, is that correct? Thanks, Tibor "Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message news:<u93V0$WRDHA.3236@TK2MSFTNGP10.phx.gbl>... > Both these functions are defined as inline in the SDK. Current process ID > and current process handle are pseudo id and pseudo handle: > > _inline HANDLE GetCurrentProcess(void) { > return ((HANDLE)(SH_CURPROC+SYS_HANDLE_BASE)); > } > > _inline DWORD GetCurrentThreadId(void) { > return ((DWORD)(((HANDLE *)(PUserKData+SYSHANDLE_OFFSET))[SH_CURTHREAD])); > } > > _inline DWORD GetCurrentProcessId(void) { > return ((DWORD)(((HANDLE *)(PUserKData+SYSHANDLE_OFFSET))[SH_CURPROC])); > > I've put together a sample that shows how to access this information on PPC: > > http://www.alexfeinman.com/download.asp?doc=kfuncs.zip > > Alex > > > > "Timo Meier" <t.meier@contrigo.de> wrote in message > news:4thqt-6h.ln1@news.dt.contrigo.de... > > Hi, i want to import the following function but i always get an Exception: > > System.MissingMethodException > > > > What is wrong? > > > > [DllImport("coredll.dll")] > > > > public static extern int GetCurrentProcessId(); > > > > [DllImport("coredll.dll")] > > > > public static extern int GetCurrentProcess(); > > > > > > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

