Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

handles.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

#define GROW_COUNT   16
#define CheckHandleTable()

Functions

HANDLE CreateHandle (ULONG_PTR dwData, DWORD type, DWORD inst)
ULONG_PTR DestroyHandle (HANDLE h)
ULONG_PTR GetHandleData (HANDLE h)
VOID SetHandleData (HANDLE h, ULONG_PTR dwData)
ULONG_PTR ValidateCHandle (HANDLE h, DWORD ExpectedType, DWORD ExpectedInstance)
PCL_INSTANCE_INFO PciiFromHandle (HANDLE h)
VOID ApplyFunctionToObjects (DWORD ExpectedType, DWORD ExpectedInstance, PFNHANDLEAPPLY pfn)
DWORD GetFullUserHandle (WORD wHandle)
VOID BestSetLastDDEMLError (DWORD error)

Variables

PCHANDLEENTRY aHandleEntry = NULL
int cHandlesAllocated = 0
int iFirstFree = 0
DWORD nextId = 1


Define Documentation

 
#define CheckHandleTable  ) 
 

Definition at line 60 of file handles.c.

Referenced by CreateHandle(), DestroyHandle(), GetHandleData(), and ValidateCHandle().

#define GROW_COUNT   16
 

Definition at line 36 of file handles.c.

Referenced by CreateHandle().


Function Documentation

VOID ApplyFunctionToObjects DWORD  ExpectedType,
DWORD  ExpectedInstance,
PFNHANDLEAPPLY  pfn
 

Definition at line 263 of file handles.c.

References aHandleEntry, cHandlesAllocated, CheckDDECritIn, CheckDDECritOut, EnterDDECrit, tagCHANDLEENTRY::handle, HTYPE_ANY, InstFromHandle, LeaveDDECrit, TypeFromHandle, and VOID().

Referenced by DdeUninitialize().

00267 { 00268 PCHANDLEENTRY phe; 00269 00270 CheckDDECritIn; 00271 00272 if (!cHandlesAllocated) { 00273 return; 00274 } 00275 phe = &aHandleEntry[cHandlesAllocated]; 00276 00277 do { 00278 phe--; 00279 if (phe->handle != 0 && 00280 (ExpectedType == HTYPE_ANY || 00281 ExpectedType == TypeFromHandle(phe->handle)) && 00282 (ExpectedInstance == HTYPE_ANY || 00283 ExpectedInstance == InstFromHandle(phe->handle))) { 00284 LeaveDDECrit; 00285 CheckDDECritOut; 00286 (*pfn)(phe->handle); 00287 EnterDDECrit; 00288 } 00289 } while (phe != aHandleEntry); 00290 }

VOID BestSetLastDDEMLError DWORD  error  ) 
 

Definition at line 336 of file handles.c.

References aHandleEntry, cHandlesAllocated, CheckDDECritIn, tagCHANDLEENTRY::dwData, tagCHANDLEENTRY::handle, HTYPE_INSTANCE, SetLastDDEMLError(), TypeFromHandle, and VOID().

Referenced by DdeAddData(), DdeClientTransaction(), DdeCreateDataHandle(), DdeDisconnect(), DdeDisconnectList(), DdeEnableCallback(), DdeFreeStringHandle(), DdeGetData(), DdeImpersonateClient(), DdeKeepStringHandle(), DdeNameService(), DdePostAdvise(), DdeQueryNextServer(), DdeReconnect(), DdeUninitialize(), InternalDdeCreateStringHandle(), InternalDdeQueryString(), and ValidateTransaction().

00338 { 00339 PCHANDLEENTRY phe; 00340 00341 CheckDDECritIn; 00342 00343 if (!cHandlesAllocated) { 00344 return; 00345 } 00346 phe = &aHandleEntry[cHandlesAllocated]; 00347 do { 00348 phe--; 00349 if (phe->handle != 0 && TypeFromHandle(phe->handle) == HTYPE_INSTANCE) { 00350 SetLastDDEMLError((PCL_INSTANCE_INFO)phe->dwData, error); 00351 } 00352 } while (phe != aHandleEntry); 00353 }

HANDLE CreateHandle ULONG_PTR  dwData,
DWORD  type,
DWORD  inst
 

Definition at line 75 of file handles.c.

References aHandleEntry, cHandlesAllocated, CheckHandleTable, DDEMLAlloc, DDEMLReAlloc, tagCHANDLEENTRY::dwData, GROW_COUNT, tagCHANDLEENTRY::handle, HandleFromId, HandleFromIndex, HandleFromInst, HandleFromType, iFirstFree, nextId, NULL, and type.

Referenced by AddInstance(), DdeClientTransaction(), DdeConnectList(), DDEMLClientWndProc(), FreeConversationResources(), InternalCreateDataHandle(), and ProcessDDEMLInitiate().

00079 { 00080 HANDLE h; 00081 int i, iNextFree; 00082 PCHANDLEENTRY phe; 00083 00084 if (iFirstFree >= cHandlesAllocated) { 00085 if (cHandlesAllocated == 0) { 00086 aHandleEntry = (PCHANDLEENTRY)DDEMLAlloc(sizeof(CHANDLEENTRY) * GROW_COUNT); 00087 } else { 00088 aHandleEntry = (PCHANDLEENTRY)DDEMLReAlloc(aHandleEntry, 00089 sizeof(CHANDLEENTRY) * (cHandlesAllocated + GROW_COUNT)); 00090 } 00091 if (aHandleEntry == NULL) { 00092 return (0); 00093 } 00094 i = cHandlesAllocated; 00095 cHandlesAllocated += GROW_COUNT; 00096 phe = &aHandleEntry[i]; 00097 while (i < cHandlesAllocated) { 00098 // phe->handle = 0; // indicates empty - ZERO init. 00099 phe->dwData = ++i; // index to next free spot. 00100 phe++; 00101 } 00102 } 00103 h = aHandleEntry[iFirstFree].handle = (HANDLE)LongToHandle( 00104 HandleFromId(nextId) | 00105 HandleFromIndex(iFirstFree) | 00106 HandleFromType(type) | 00107 HandleFromInst(inst) ); 00108 iNextFree = (int)aHandleEntry[iFirstFree].dwData; 00109 aHandleEntry[iFirstFree].dwData = dwData; 00110 nextId++; 00111 if (nextId == 0) { // guarentees HIWORD of handle != 0 00112 nextId++; 00113 } 00114 iFirstFree = iNextFree; 00115 00116 CheckHandleTable(); 00117 return (h); 00118 }

ULONG_PTR DestroyHandle HANDLE  h  ) 
 

Definition at line 137 of file handles.c.

References aHandleEntry, CheckHandleTable, tagCHANDLEENTRY::dwData, tagCHANDLEENTRY::handle, iFirstFree, and IndexFromHandle.

Referenced by ClRespExecuteAck(), ClRespPokeAck(), ClRespUnadviseAck(), DdeClientTransaction(), DdeConnectList(), DdeDisconnectList(), DestroyInstance(), FreeConversationResources(), InternalFreeDataHandle(), TransactionComplete(), and UnpackAndFreeDDEMLDataHandle().

00139 { 00140 register int i; 00141 register ULONG_PTR dwRet; 00142 00143 CheckHandleTable(); 00144 00145 i = IndexFromHandle(h); 00146 UserAssert(aHandleEntry[i].handle == h); 00147 aHandleEntry[i].handle = 0; 00148 dwRet = aHandleEntry[i].dwData; 00149 aHandleEntry[i].dwData = iFirstFree; 00150 iFirstFree = i; 00151 00152 return (dwRet); 00153 }

DWORD GetFullUserHandle WORD  wHandle  ) 
 

Definition at line 293 of file handles.c.

References tagSHAREDINFO::aheList, _HANDLEENTRY::bType, tagSERVERINFO::cHandleEntries, DWORD, gpsi, gSharedInfo, HMIndexFromHandle, TYPE_WINDOW, and _HANDLEENTRY::wUniq.

Referenced by UserRegisterWowHandlers().

00294 { 00295 DWORD dwHandle; 00296 PHE phe; 00297 00298 dwHandle = HMIndexFromHandle(wHandle); 00299 00300 if (dwHandle < gpsi->cHandleEntries) { 00301 00302 phe = &gSharedInfo.aheList[dwHandle]; 00303 00304 if (phe->bType == TYPE_WINDOW) 00305 return(MAKELONG(dwHandle, phe->wUniq)); 00306 } 00307 00308 /* 00309 * object may be gone, but we must pass something. 00310 * DDE terminates will fail if we don't map this right even after 00311 * the window is dead! 00312 * 00313 * NOTE: This fix will only work for WOW apps, but since the 32bit 00314 * tracking layer locks dde windows until the last terminate is 00315 * received, we won't see this problem on the 32bit side. 00316 * 00317 * BUG: We WILL see a problem for OLE32 thunked DDE though. 00318 */ 00319 return(wHandle); 00320 }

ULONG_PTR GetHandleData HANDLE  h  ) 
 

Definition at line 165 of file handles.c.

References aHandleEntry, CheckHandleTable, tagCHANDLEENTRY::dwData, and IndexFromHandle.

Referenced by DdeConnectList(), and UnlinkConvFromOthers().

00167 { 00168 register ULONG_PTR dwRet; 00169 00170 CheckHandleTable(); 00171 dwRet = aHandleEntry[IndexFromHandle(h)].dwData; 00172 return (dwRet); 00173 }

PCL_INSTANCE_INFO PciiFromHandle HANDLE  h  ) 
 

Definition at line 226 of file handles.c.

References aHandleEntry, cHandlesAllocated, CheckDDECritIn, tagCHANDLEENTRY::dwData, tagCHANDLEENTRY::handle, HTYPE_INSTANCE, InstFromHandle, NULL, and TypeFromHandle.

Referenced by DdeAccessData(), DdeAddData(), DdeDisconnect(), DdeDisconnectList(), DdeGetData(), DdeImpersonateClient(), DdeQueryNextServer(), and DdeReconnect().

00228 { 00229 PCHANDLEENTRY phe; 00230 00231 CheckDDECritIn; 00232 00233 if (!cHandlesAllocated) { 00234 return(NULL); 00235 } 00236 phe = &aHandleEntry[cHandlesAllocated]; 00237 00238 do { 00239 phe--; 00240 if (phe->handle != 0 && 00241 TypeFromHandle(phe->handle) == HTYPE_INSTANCE && 00242 (InstFromHandle(phe->handle) == InstFromHandle(h))) { 00243 return(((PCL_INSTANCE_INFO)phe->dwData)->tid == GetCurrentThreadId() ? 00244 (PCL_INSTANCE_INFO)phe->dwData : NULL); 00245 } 00246 } while (phe != aHandleEntry); 00247 return(NULL); 00248 }

VOID SetHandleData HANDLE  h,
ULONG_PTR  dwData
 

Definition at line 185 of file handles.c.

References aHandleEntry, tagCHANDLEENTRY::dwData, IndexFromHandle, and VOID().

Referenced by DdeConnectList(), and InternalDdeInitialize().

00188 { 00189 aHandleEntry[IndexFromHandle(h)].dwData = dwData; 00190 }

ULONG_PTR ValidateCHandle HANDLE  h,
DWORD  ExpectedType,
DWORD  ExpectedInstance
 

Definition at line 204 of file handles.c.

References aHandleEntry, cHandlesAllocated, CheckHandleTable, tagCHANDLEENTRY::dwData, tagCHANDLEENTRY::handle, IndexFromHandle, InstFromHandle, and TypeFromHandle.

Referenced by DdeAccessData(), DdeAddData(), DdeClientTransaction(), DdeDisconnect(), DdeDisconnectList(), DdeEnableCallback(), DdeFreeDataHandle(), DdeGetData(), DdeImpersonateClient(), DdeQueryNextServer(), DdeReconnect(), DdeUnaccessData(), InitiateEnumerationProc(), InternalFreeDataHandle(), ProcessSyncDDEMessage(), UnpackAndFreeDDEMLDataHandle(), ValidateConnectParameters(), ValidateInstance(), ValidateTransaction(), and WaitForZombieTerminate().

00208 { 00209 register int i; 00210 register ULONG_PTR dwRet; 00211 00212 CheckHandleTable(); 00213 dwRet = 0; 00214 i = IndexFromHandle(h); 00215 if (i < cHandlesAllocated && 00216 aHandleEntry[i].handle == h && 00217 (ExpectedType == -1 || ExpectedType == TypeFromHandle(h)) && 00218 (ExpectedInstance == -1 || ExpectedInstance == InstFromHandle(h))) { 00219 dwRet = aHandleEntry[i].dwData; 00220 } 00221 00222 return (dwRet); 00223 }


Variable Documentation

PCHANDLEENTRY aHandleEntry = NULL
 

Definition at line 28 of file handles.c.

Referenced by ApplyFunctionToObjects(), BestSetLastDDEMLError(), CreateHandle(), DestroyHandle(), GetHandleData(), PciiFromHandle(), SetHandleData(), and ValidateCHandle().

int cHandlesAllocated = 0
 

Definition at line 32 of file handles.c.

Referenced by ApplyFunctionToObjects(), BestSetLastDDEMLError(), CreateHandle(), PciiFromHandle(), and ValidateCHandle().

int iFirstFree = 0
 

Definition at line 33 of file handles.c.

Referenced by CreateHandle(), and DestroyHandle().

DWORD nextId = 1
 

Definition at line 34 of file handles.c.

Referenced by CreateHandle().


Generated on Sat May 15 19:44:01 2004 for test by doxygen 1.3.7