home *** CD-ROM | disk | FTP | other *** search
/ PC World 1999 October / PCWorld_1999-10_cd1.bin / Hardware / Drivers / APISpy / LinkList.cpp < prev    next >
C/C++ Source or Header  |  1999-07-15  |  1KB  |  83 lines

  1. // ----------------------------------- //
  2. //            APISpy32 v2.0            //
  3. //     Copyright 1999 Yariv Kaplan     //
  4. //          WWW.INTERNALS.COM          //
  5. // ----------------------------------- //
  6.  
  7. #include "LinkList.h"
  8. #include "APISpy32.h"
  9.  
  10. tagAPIInfo *Head = NULL;
  11. tagAPIInfo *Tail = NULL;
  12.  
  13. #ifdef WIN95
  14.  
  15. DWORD dwItemIndex = 0;
  16. tagAPIInfo APIInfoArray[MAX_API];
  17.  
  18. #endif
  19.  
  20. tagAPIInfo *AddItem()
  21. {
  22.   tagAPIInfo *Item;
  23.  
  24.   #ifdef WIN95
  25.  
  26.   if (dwItemIndex == MAX_API)
  27.     return NULL;
  28.  
  29.   Item = &APIInfoArray[dwItemIndex];
  30.   dwItemIndex++;
  31.  
  32.   #endif
  33.  
  34.   #ifdef WINNT
  35.  
  36.   Item = new tagAPIInfo;
  37.  
  38.   #endif
  39.  
  40.   if (Head == NULL)
  41.   {
  42.     Head = Item;
  43.     Tail = Item;
  44.   }
  45.   else
  46.   {
  47.     Tail->Next = Item;
  48.     Tail = Tail->Next;
  49.   }  
  50.  
  51.   Tail->Next = NULL;
  52.   
  53.   return Item;
  54. }
  55.  
  56. #ifdef WINNT
  57.  
  58. void RemoveItem(tagAPIInfo *Item)
  59. {
  60.   tagAPIInfo *CurrentItem = Head;
  61.  
  62.   if (Head == NULL) return;
  63.  
  64.   if (Item == Head)
  65.   {
  66.     if (Head == Tail) Tail = NULL;
  67.     Head = Head->Next;
  68.     delete Item;
  69.     return;
  70.   }
  71.  
  72.   while (CurrentItem->Next != Item)
  73.     CurrentItem = CurrentItem->Next;
  74.   
  75.   CurrentItem->Next = Item->Next;
  76.  
  77.   if (Item == Tail) Tail = CurrentItem;
  78.  
  79.   delete Item;
  80. }
  81.  
  82. #endif
  83.