mirror of
https://github.com/github/codeql.git
synced 2026-03-05 15:16:47 +01:00
43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
import cil
|
|
import semmle.code.cil.Type
|
|
import semmle.code.csharp.commons.QualifiedName
|
|
|
|
bindingset[kind]
|
|
deprecated private string getKind(int kind) {
|
|
if kind = 1 then result = "modreq" else result = "modopt"
|
|
}
|
|
|
|
bindingset[t, e]
|
|
deprecated private string getAnnotatedType(Type t, Element e) {
|
|
cil_type_annotation(e, 32) and result = t.toString() + "&"
|
|
or
|
|
not cil_type_annotation(e, 32) and result = t.toString()
|
|
}
|
|
|
|
deprecated query predicate fnptr(
|
|
string fnptr, int paramCount, string returnType, int callingConvention
|
|
) {
|
|
exists(FunctionPointerType fn | fnptr = fn.toString() |
|
|
paramCount = fn.getNumberOfParameters() and
|
|
returnType = getAnnotatedType(fn.getReturnType(), fn) and
|
|
callingConvention = fn.getCallingConvention()
|
|
)
|
|
}
|
|
|
|
deprecated query predicate params(string fnptr, int i, string param, string t) {
|
|
exists(FunctionPointerType fn, Parameter p | fnptr = fn.toString() and param = p.toString() |
|
|
fn.getParameter(i) = p and t = getAnnotatedType(p.getType(), p)
|
|
)
|
|
}
|
|
|
|
deprecated query predicate modifiers(string fnptr, string modifier, string sKind) {
|
|
exists(Type modType, int kind, FunctionPointerType fn, string qualifier, string name |
|
|
fnptr = fn.toString()
|
|
|
|
|
cil_custom_modifiers(fn, modType, kind) and
|
|
modType.hasFullyQualifiedName(qualifier, name) and
|
|
modifier = getQualifiedName(qualifier, name) and
|
|
sKind = getKind(kind)
|
|
)
|
|
}
|