ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

dcatitem.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS WinSock 2 API
00004  * FILE:        dcatitem.c
00005  * PURPOSE:     Transport Catalog Entry Object
00006  * PROGRAMMER:  Alex Ionescu (alex@relsoft.net)
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 #include "ws2_32.h"
00011 
00012 /* DATA **********************************************************************/
00013 
00014 /* FUNCTIONS *****************************************************************/
00015 
00016 PTCATALOG_ENTRY
00017 WSAAPI
00018 WsTcEntryAllocate(VOID)
00019 {
00020     PTCATALOG_ENTRY CatalogEntry;
00021 
00022     /* Allocate the catalog entry */
00023     CatalogEntry = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*CatalogEntry));
00024 
00025     /* Set the default non-null members */
00026     CatalogEntry->RefCount = 1;
00027 
00028     /* Return it */
00029     return CatalogEntry;
00030 }
00031 
00032 VOID
00033 WSAAPI
00034 WsTcEntryDelete(IN PTCATALOG_ENTRY CatalogEntry)
00035 {
00036     /* Check if a provider is loaded */
00037     if (CatalogEntry->Provider)
00038     {
00039         /* Dereference it too */
00040         WsTpDereference(CatalogEntry->Provider);
00041         CatalogEntry->Provider = NULL;
00042     }
00043 
00044     /* Delete us */
00045     HeapFree(WsSockHeap, 0, CatalogEntry);
00046 }
00047 
00048 VOID
00049 WSAAPI
00050 WsTcEntryDereference(IN PTCATALOG_ENTRY CatalogEntry)
00051 {
00052     /* Dereference and check if it's now 0 */
00053     if (!(InterlockedDecrement(&CatalogEntry->RefCount)))
00054     {
00055         /* We can delete the Provider now */
00056         WsTcEntryDelete(CatalogEntry);
00057     }
00058 }
00059 
00060 DWORD
00061 WSAAPI
00062 WsTcEntryInitializeFromRegistry(IN PTCATALOG_ENTRY CatalogEntry,
00063                                 IN HKEY ParentKey,
00064                                 IN DWORD UniqueId)
00065 {
00066     CHAR CatalogEntryName[13];
00067     DWORD RegSize;
00068     DWORD RegType = REG_BINARY;
00069     HKEY EntryKey;
00070     DWORD Return;
00071 
00072     /* Convert to a 00000xxx string */
00073     sprintf(CatalogEntryName, "%0""12""lu", UniqueId);
00074 
00075     /* Open the Entry */
00076     Return = RegOpenKeyEx(ParentKey,
00077                           CatalogEntryName,
00078                           0,
00079                           KEY_READ,
00080                           &EntryKey);
00081 
00082     /* Get Size of Catalog Entry Structure */
00083     Return = RegQueryValueExW(EntryKey, 
00084                               L"PackedCatalogItem",
00085                               0,
00086                               NULL,
00087                               NULL,
00088                               &RegSize);
00089     
00090     /* Read the Whole Catalog Entry Structure */
00091     Return = RegQueryValueExW(EntryKey, 
00092                               L"PackedCatalogItem",
00093                               0,
00094                               &RegType,
00095                               (LPBYTE)&CatalogEntry->DllPath,
00096                               &RegSize);
00097 
00098     /* Done */
00099     RegCloseKey(EntryKey);
00100     return Return;
00101 }
00102 
00103 VOID
00104 WSAAPI
00105 WsTcEntrySetProvider(IN PTCATALOG_ENTRY Entry,
00106                      IN PTPROVIDER Provider)
00107 {
00108     /* Reference the provider */
00109     InterlockedIncrement(&Provider->RefCount);
00110 
00111     /* Set it */
00112     Entry->Provider = Provider;
00113 }

Generated on Sat May 26 2012 04:25:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.