DynamoRIO / DynamoRIO/drmemory

handle size from prior call and other complications/missing info for some NtGdi syscalls

Open
#485 1 comment 0 reactions 0 assignees View on GitHub
Migrated OpSys-Windows Priority-Medium
Dominant language
C
Stars
2.7k
Forks
290
PR merge metrics
No merged PRs in 30d

Description

_From [bruen...@google.com](https://code.google.com/u/109494838902877177630/) on July 08, 2011 14:38:41_

split from issue #96 these are the remaining issues after mksystable.pl plus a number of manual fixes:
- \+ OUT params with no size where size comes from prior syscall
- return value (see FIXMEs in table below): so have to watch pairs
- of calls (but what if app is able to compute max size some other
- way, maybe caching older call?), unless willing to only check for
- unaddr in post-syscall and thus after potential write to
- unaddressable memory by kernel (which is what we do today)
*
- \+ missing ", return" annotations: NtGdiExtGetObjectW was missing one,
- and I'm afraid other ones that return int or UINT may also.
*
- \+ __out PVOID: for NtGdiGetUFIPathname and NtGdiDxgGenericThunk,
- is the PVOID that's written supposed to have a bcount (or ecount)
- annotation? for now treated as PVOID*.
*
- \+ bcount in, ecount out for NtGdiSfmGetNotificationTokens (which is
- missing annotations)? but what is size of token?

more info on the first problem:

from ntgdi.h:
// A few GDI API's fill buffers but have no input parameter saying how big
// the buffers are. The idiom is that you call it once with a NULL buffer
// pointer to find out how big the buffer should be, allocate that much,
// then call again. This sounds like a job for __out_bcount_opt(size), but
// this annotation requires (size) to be known beforehand (i.e. it is a
// precondition). The best we can do is to specify the size as a
// postcondition.

so have to watch pairs of calls (but what if app is able to compute max
size some other way, maybe caching older call?), unless willing to only
check for unaddr in post-syscall and thus after potential write to
unaddressable memory by kernel (which is what I'm putting in for now)

these are the ones with __out_post_bcount_opt() and __out_post_ecount_opt():
- NtGdiGetFontUnicodeRanges
- NtGdiFONTOBJ_cGetAllGlyphHandles
- NtGdiHT_Get8BPPFormatPalette
- NtGdiHT_Get8BPPMaskPalette

more info on third:

this is weird. is it supposed to be PVOID *? though the "pcjView" looks
like a count: so maybe missing bcount(pcjView) on pvView?
NtGdiGetUFIPathname(
__out_opt ULONG *pcjView,
__out_opt PVOID pvView,
psdk header is also just PVOID:
OUT OPTIONAL PVOID pvView,

this one: pdwSizeOfPtr1 => should be bcount?
NtGdiDxgGenericThunk(
__in ULONG_PTR ulIndex,
__in ULONG_PTR ulHandle,
__inout SIZE_T *pdwSizeOfPtr1,
__inout PVOID pvPtr1,
__inout SIZE_T *pdwSizeOfPtr2,
__inout PVOID pvPtr2

_Original issue: http://code.google.com/p/drmemory/issues/detail?id=485_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.