You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Taking another stab at supporting RAIIFree in Rust, but the following structs have the RAIIFree attribute but lack at least one InvalidHandleValue attribute. Is that intentional? Are we meant to assume that zero is thus the invalid value?
Conversely, there are many structs that have at least one InvalidHandleValue attribute but lack a corresponding RAIIFree attribute. Is that intentional?
Regarding the longer list of types that have InvalidHandleValue markings but not RAIIFree, this is just an artifact of the RAII effort not being complete. Will try to get those all covered.
Live checklist:
HCONN (❌ Not own-able by application)
HCOMDB
ADS_SEARCH_HANDLE (〰️Pending discussion on encoding IDirectorySearch::CloseSearchHandle)
HIFTIMESTAMPCHANGE
HAMSICONTEXT (〰️Pending discussion on encoding AmsiUninitialize / AmsiCloseSession)
HAMSISESSION (〰️Pending discussion on encoding AmsiUninitialize / AmsiCloseSession)
JET_LS (❌ Arbitrary application-specific data)
JET_OSSNAPID (❌ Lifetime managed through series of prepare, freeze, thaw, and end or abort functions)
OLE_HANDLE (❌ Not own-able by application)
HRSRC (❌ Not own-able by application)
PSID
HACCESSOR (Pending discussion on encoding IAccessor::ReleaseAccessor)
BCRYPT_ALG_HANDLE (⚠️ Already existed)
BCRYPT_HANDLE
PRJ_DIR_ENTRY_BUFFER_HANDLE (❌ Not own-able by application)
PRJ_NAMESPACE_VIRTUALIZATION_CONTEXT (〰️ Needs further discussion PrjStopVirtualizing)
HCS_CALLBACK (❌ Undocumented)
JET_API_PTR (❌ Polymorphic, base handle type for JET_xxx handles)
JET_HANDLE (〰️Pending discussion on encoding JetCloseFileInstance)
JET_INSTANCE
JET_SESID
JET_TABLEID (〰️Pending discussion on encoding JetCloseTable)
HDC (❌ Handle type too broad, handle can be passed into DeleteDC or ReleaseDC)
HGDIOBJ
HMONITOR (❌ Not own-able by application)
HCERTSTORE (❌ Has additional behavioral parameter)
HCERTSTOREPROV (❌ Needs further callback semantics investigation CertStoreProvFreeFindCTL)
HCRYPTPROV_LEGACY (❌ Unused and should always be NULL)
HCRYPTPROV_OR_NCRYPT_KEY_HANDLE (❌ Polymorphic)
NCRYPT_HANDLE
NCRYPT_HASH_HANDLE (❌ Needs further investigation)
NCRYPT_SECRET_HANDLE (❌ Needs further investigation)
HIMC
HIMCC (❌ Lifetime managed through ImmLockIMCC and ImmUnlockIMCC functions, needs closer investigation)
HSAVEDUILANGUAGES (❌ Not own-able by application)
CO_DEVICE_CATALOG_COOKIE
CO_MTA_USAGE_COOKIE
LPM_HANDLE
RHANDLE (❌ Undocumented)
HRASCONN (❌ Handle type is too broad, RasHangUpA and RasHangUpW exist)
HTASK
HPSS
HPSSWALK
HACMDRIVER
HACMDRIVERID (❌ Needs further investigation)
HACMOBJ
HACMSTREAM
HMIDI
HMIDIIN
HMIDIOUT
HMIDISTRM
HMIXER
HMIXEROBJ (❌ Handle type too broad)
HWAVE
HWAVEIN
HWAVEOUT
HCONV
HCONVLIST
HDDEDATA
HSZ
HTTP_PUSH_WAIT_HANDLE
WEB_SOCKET_HANDLE
HPTPROVIDER
SERVICE_STATUS_HANDLE
HRAWINPUT (❌ Not own-able by application)
CF_CONNECTION_KEY
FEATURE_STATE_CHANGE_SUBSCRIPTION
FH_SERVICE_PIPE_HANDLE
HWINWATCH
PFLT_CONTEXT (❌ Further investigation needed within WDK context)
HGESTUREINFO
HTOUCHINPUT
HRECOALT
HRECOCONTEXT
HRECOGNIZER
HRECOLATTICE (❌ Needs further investigation)
HRECOWORDLIST
HDROP (❌ Not own-able by application)
HPSXA
HUIAEVENT
HUIANODE
HUIAPATTERNOBJECT
HUIATEXTRANGE
AUTHZ_ACCESS_CHECK_RESULTS_HANDLE
AUTHZ_AUDIT_EVENT_HANDLE
AUTHZ_AUDIT_EVENT_TYPE_HANDLE (❌ Needs further investigation)
AUTHZ_CAP_CHANGE_SUBSCRIPTION_HANDLE
AUTHZ_CLIENT_CONTEXT_HANDLE
AUTHZ_RESOURCE_MANAGER_HANDLE
AUTHZ_SECURITY_EVENT_PROVIDER_HANDLE (〰️Pending discussion on backwards params AuthzUnregisterSecurityEventSource)
HINTERACTIONCONTEXT
HDPA
HDSA
HSYNTHETICPOINTERDEVICE
DPI_AWARENESS_CONTEXT (❌ Needs further investigation)
Activity
kennykerr commentedon Apr 30, 2024
Conversely, there are many structs that have at least one
InvalidHandleValueattribute but lack a correspondingRAIIFreeattribute. Is that intentional?[-]`RAIIFree` needs `InvalidHandleValue`[/-][+]How does `RAIIFree` relate to `InvalidHandleValue`?[/+]riverar commentedon Apr 30, 2024
Disassembling
kernelbase![...]::VerifyValidIoRingHandlereveals it returnsINVALID_HANDLE_VALUEwhen provided-1and0, so will add that.Documented as an opaque struct pointer. We can minimally add
0to the invalid handle value list here.Same as above.
Will add
-1perINVALID_SOCKET.riverar commentedon Apr 30, 2024
Regarding the longer list of types that have
InvalidHandleValuemarkings but notRAIIFree, this is just an artifact of the RAII effort not being complete. Will try to get those all covered.Live checklist:
IDirectorySearch::CloseSearchHandle)AmsiUninitialize/AmsiCloseSession)AmsiUninitialize/AmsiCloseSession)IAccessor::ReleaseAccessor)PrjStopVirtualizing)JetCloseFileInstance)JetCloseTable)DeleteDCorReleaseDC)CertStoreProvFreeFindCTL)NULL)ImmLockIMCCandImmUnlockIMCCfunctions, needs closer investigation)RasHangUpAandRasHangUpWexist)AuthzUnregisterSecurityEventSource)CloseDriver)mmioClose)[-]How does `RAIIFree` relate to `InvalidHandleValue`?[/-][+]`RAIIFree` implies `InvalidHandleValue`[/+]kennykerr commentedon Nov 26, 2024
Found
REGHANDLE- may want to add a test for this...riverar commentedon Nov 26, 2024
Good catch, will create a separate issue to track. Looks easy enough.