/***************************************************************************\ * HMValidateHandleNoSecure * * This routine validates a handle manager handle. * * 01-22-92 ScottLu Created. \***************************************************************************/ PVOID FASTCALL HMValidateHandleNoSecure( HANDLE h, BYTE bType) { KERNEL_PVOID pobj = NULL; PCLIENTINFO pci; GET_CURRENT_CLIENTINFO(); #if !defined(_USERK_) /* * We don't want 32 bit apps passing 16 bit handles * we should consider failing this before we get * stuck supporting it (Some VB apps do this). */ if (pci && (h != NULL) && (HMUniqFromHandle(h) == 0) && !(pci->dwTIFlags & TIF_16BIT)) { RIPMSG3(RIP_WARNING, "HMValidateHandle: 32bit process [%d] using 16 bit handle [%#p] bType:%#lx", HandleToUlong(NtCurrentTeb()->ClientId.UniqueProcess), h, (DWORD)bType); } #endif /* * Object can't be located in shared memory. */ UserAssert(bType != TYPE_MONITOR); /* * Validation macro. */ ValidateHandleMacro(pci, pobj, h, bType); return pobj; }
PVOID FASTCALL HMValidateSharedHandle( HANDLE h, BYTE bType) { DWORD dwError; KERNEL_PVOID pobj = NULL; #if DBG != 0 && !defined(_USERK_) /* * We don't want 32 bit apps passing 16 bit handles * we should consider failing this before we get * stuck supporting it (Some VB apps do this). */ if ((h != NULL) && (HMUniqFromHandle(h) == 0) && !(GetClientInfo()->dwTIFlags & TIF_16BIT)) { RIPMSG3(RIP_WARNING, "HMValidateHandle: 32bit process [%d] using 16 bit handle [%#p] bType:%#lx", HandleToUlong(NtCurrentTeb()->ClientId.UniqueProcess), h, (DWORD)bType); } #endif /* * Validation macro. Falls through if the handle is invalid. */ ValidateSharedHandleMacro(pobj, h, bType); if (pobj != NULL) return pobj; switch (bType) { case TYPE_MONITOR: dwError = ERROR_INVALID_MONITOR_HANDLE; break; default: UserAssertMsg0(0, "Logic error in HMValidateSharedHandle"); break; } RIPERR2(dwError, RIP_WARNING, "HMValidateSharedHandle: Invalid:%#p Type:%#lx", h, (DWORD)bType); /* * If we get here, it's an error. */ return NULL; }
PVOID FASTCALL HMValidateHandle( HANDLE h, BYTE bType) { DWORD dwError; KERNEL_PVOID pobj = NULL; PCLIENTINFO pci; GET_CURRENT_CLIENTINFO(); #if DBG != 0 && !defined(_USERK_) /* * We don't want 32 bit apps passing 16 bit handles * we should consider failing this before we get * stuck supporting it (Some VB apps do this). */ if (pci && (h != NULL) && (HMUniqFromHandle(h) == 0) && !(pci->dwTIFlags & TIF_16BIT)) { RIPMSG3(RIP_WARNING, "HMValidateHandle: 32bit process [%d] using 16 bit handle [%#p] bType:%#lx", HandleToUlong(NtCurrentTeb()->ClientId.UniqueProcess), h, (DWORD)bType); } #endif /* * Object can't be located in shared memory. */ UserAssert(bType != TYPE_MONITOR); /* * Validation macro. Falls through if the handle is invalid. */ ValidateHandleMacro(pci, pobj, h, bType); /* * check for secure process */ CHECK_RESTRICTED(); if (pobj != NULL) { return pobj; } switch (bType) { case TYPE_WINDOW: dwError = ERROR_INVALID_WINDOW_HANDLE; break; case TYPE_MENU: dwError = ERROR_INVALID_MENU_HANDLE; break; case TYPE_CURSOR: dwError = ERROR_INVALID_CURSOR_HANDLE; break; case TYPE_ACCELTABLE: dwError = ERROR_INVALID_ACCEL_HANDLE; break; case TYPE_HOOK: dwError = ERROR_INVALID_HOOK_HANDLE; break; case TYPE_SETWINDOWPOS: dwError = ERROR_INVALID_DWP_HANDLE; break; default: dwError = ERROR_INVALID_HANDLE; break; } RIPERR2(dwError, RIP_WARNING, "HMValidateHandle: Invalid:%#p Type:%#lx", h, (DWORD)bType); /* * If we get here, it's an error. */ return NULL; }
PVOID FASTCALL HMValidateHandle( HANDLE h, BYTE bType) { DWORD dwError; #if defined(DEBUG) && !defined(_USERK_) && !defined(WOW) /* * We don't want 32 bit apps passing 16 bit handles * we should consider failing this before we get * stuck supporting it (Some VB apps do this). */ if ((h != NULL) && (HMUniqFromHandle(h) == 0) && !(GetClientInfo()->dwTIFlags & TIF_16BIT)) { //RIPMSG3(RIP_WARNING, "HMValidateHandle: 32bit process [%d] using 16 bit handle [%#lx]. bType:%#lx", //((DWORD)NtCurrentTeb()->ClientId.UniqueProcess), h, (DWORD)bType); } #endif /* * Include this macro, which does validation - this is the fastest * way to do validation, without the need to pass a third parameter * into a general rip routine, and we don't have two sets of * validation to maintain. */ ValidateHandleMacro(h, bType) switch (bType) { case TYPE_WINDOW: dwError = ERROR_INVALID_WINDOW_HANDLE; break; case TYPE_MENU: dwError = ERROR_INVALID_MENU_HANDLE; break; case TYPE_CURSOR: dwError = ERROR_INVALID_CURSOR_HANDLE; break; case TYPE_ACCELTABLE: dwError = ERROR_INVALID_ACCEL_HANDLE; break; case TYPE_HOOK: dwError = ERROR_INVALID_HOOK_HANDLE; break; case TYPE_SETWINDOWPOS: dwError = ERROR_INVALID_DWP_HANDLE; break; default: dwError = ERROR_INVALID_HANDLE; break; } RIPERR1(dwError, RIP_WARNING, "HMValidateHandle: Invalid handle (0x%08lx)", h); /* * If we get here, it's an error. */ return NULL; }