Saturday, March 7, 2009

How ExitThread works!!! [WinCE]


This function ends a thread.This API takes exit code for the calling thread. To retrieve a thread's exit code, use the GetExitCodeThread function.
The steps are:
  1. It will release the owner process by using API GetCurrentThreadId which gives it current thread and check for the current process which own the thread and if it's the same application which own the thread then release all CS.
  2. Check for thread type:
    1. If it is the primary thread then
      1. Kill all other thread.
      2. Detach all DLL from the process.
      3. Call Dllmain function of dll with thread detach ioctl.
      4. Call core dll to detach the thread.
      5. Close all handle
    2. Else
      1. Get the thread attach status and call dllmain of dll with thread detach ioctl.
  3. Now it will call NKTerminateThread.
Note: If the primary thread calls ExitThread, the application will exit.

Friday, February 20, 2009

How InterruptInitialize wokrs!!! [WinCE]

This API takes basically two parameters:
1. Event name
2. Interrupt id(IRQ) which we choose manually.

It wil verify interrupt id is valid by comparing with SYSINTR_DEVICES, and SYSINTR_MAXIMUM.

Now check for valid event after getting handle for the event.
Next check for manualset and proxylist member.

Now it will convert the IRQ into sysirq and will check for maximum limit.

 If less then it will call OEMInterruptEnable whcih will send the sysintr.

So after that it will again call oalinterruptenable in intr.c.

For wince5.0 only!!!

Thursday, February 19, 2009

How CreateEvent works!!! [WinCE]

The API takes three parameters:
1. Initial status (we determine).
2. Set/reset option like manual or automatic
3. Name of event

First it will validate the parameter like caller needs to be trusted if the named object is system prefixed.
Next check for the name of event in the linked list if it has been already used.

Now call critical section.

Now if the name exists then it will return with error.
Next check for the same object is already opened but name does not exist.

Now if the object does not exist then it will get allocated memory from heap for synchronous object.

Now it will get a pointer of the memory allocated before, and will check the size if available.
If available, then grab the memory and then will call INTERRUPTS_ON() which is nesting interrupts.

Then it will get handle for the object.
Name and security related check will be done.
Also for out of memory.

Now after getting memory, we will clear it by filling 0.
Then copy name and security descriptor. Now will call pfnInit() for the particular object.
Then we will have to set the parameter on manual set/reset.
Note - wince5.0

How InitializeCriticalSection works!!! [WinCE]

This api Initializes a critical section object.
It will take the critical section object and initialize the member of the object with null then will call function CreateCrit which will again take the parameter as the critical section object and in the function it will check for the process trust level and then if it fulfill the trust level then if the object is equal to 1 then will map the critical section object to the base address of process VM base.
Now it verify the valid kernel pointer for the critical section's cric member.
After than it will call EnterCriticalSection on the global critical section object and then will do traversing to find in which location to save the new critical section object using linked list data structure.
When it will find the exact location then it will save there and then will call leave global critical section object (NameCS).
Note - This is for WCE5.0.

Monday, January 26, 2009

cl : Command line error D8004 : '/I' requires an argument [WinCE]

This problem is related with INCLUDES in sources file.
Make sure that it is not start with .. or real directory path.
Use always targetplatroot or commonoakroot.