Typedefs in function argument types result in wrong calling convention being used
@plafosse ci sta già lavorando.
Dal 18/3/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Version and Platform (required):
- Binary Ninja Version: 4.3.7007-dev (53778246)
- OS: macOS 15.3.1
- CPU Architecture: arm64
Bug Description:
When analyzing calls to CoreFoundation functions that take typedefs such as CFAbsoluteTime or CFTimeInterval the analysis appears to treat these differently than if they the underlying double type, resulting in incorrect HLIL.
Steps To Reproduce:
- Open a shared cache from macOS 15.3
- Load HIToolbox, wait for analysis to complete, then navigate to
__ZL38PullEventsFromWindowServerOnConnectionjhP17__CFMachPortBoostin HLIL. - Look at the calls to
j__CFRunLoopTimerCreateWithHandlerandj__CFRunLoopTimerSetNextFireDatetowards the end of the function. Note the incorrect computation of the fire date.
- Load CoreFoundation in hopes it sorts out the types.
- Look at the same calls to
j__CFRunLoopTimerCreateWithHandlerandj__CFRunLoopTimerSetNextFireDate. Now the fire date forCFRunLoopTimerCreateWithHandleris also incorrectly computed.
- Use Override Call Type on both calls to change arguments of type
CFTimeIntervalandCFAbsoluteTimetodouble. The computations are now correct!
Here are the definitions of CFTimeInterval and CFAbsoluteTime from the CoreFoundation type library:
typedef double CFTimeInterval;
typedef CFTimeInterval CFAbsoluteTime;
They should be transparent from the point of view of the calling convention and treated identically to double, but are not.
One further point of confusion is that the type for CFRunLoopTimerCreateWithHandler is absent from the CoreFoundation type library. Loading CoreFoundation in step 4 causes Binary Ninja to infer the type signature for it, but it gets it wrong. It goes with:
CFRunLoopTimerRef CFRunLoopTimerCreateWithHandler(CFAllocatorRef, CFAbsoluteTime, CFTimeInterval)
when it should be:
CFRunLoopTimerRef CFRunLoopTimerCreateWithHandler(CFAllocatorRef, CFAbsoluteTime, CFTimeInterval, CFOptionFlags, CFIndex, void (^)(CFRunLoopTimerRef))
If I explicitly set the type of CFRunLoopTimerCreateWithHandler and j__CFRunLoopTimerCreateWithHandler to the correct signature, the problem still occurs. Replacing CFAbsoluteTime and CFTimeInterval with double again fixes the problem.
- Lingua principale
- C++
- Stelle
- 1.3k
- Fork
- 298
- Merge medio
- 5g 5h
- PR unite (30g)
- 19
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Vector35/binaryninja-api
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
Vector35/binaryninja-api#8540 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Vector35/binaryninja-api#8516 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
Vector35/binaryninja-api#8503 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Vector35/binaryninja-api#8446 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Vector35/binaryninja-api#8444 ·
Tutte le issue di Vector35/binaryninja-api
Issue simili
-
Website Doc Typo Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 92/100
autowarefoundation/autoware_universe#13413 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
automated-analysis bug memory-safety
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100