Skip to content

Commit 8fd581d

Browse files
authored
Merge pull request github#18093 from MathiasVP/more-win32-command-execution-functions
C++: Add more `CommandExecutionFunction`s
2 parents c2b342f + 03ab74e commit 8fd581d

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

cpp/ql/lib/semmle/code/cpp/models/Models.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ private import implementations.PostgreSql
4949
private import implementations.System
5050
private import implementations.StructuredExceptionHandling
5151
private import implementations.ZMQ
52+
private import implementations.Win32CommandExecution
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
private import semmle.code.cpp.models.interfaces.CommandExecution
2+
3+
/** The `ShellExecute` family of functions from Win32. */
4+
class ShellExecute extends Function {
5+
ShellExecute() { this.hasGlobalName("ShellExecute" + ["", "A", "W"]) }
6+
}
7+
8+
private class ShellExecuteModel extends ShellExecute, CommandExecutionFunction {
9+
override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(2) }
10+
}
11+
12+
/** The `WinExec` function from Win32. */
13+
class WinExec extends Function {
14+
WinExec() { this.hasGlobalName("WinExec") }
15+
}
16+
17+
private class WinExecModel extends WinExec, CommandExecutionFunction {
18+
override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(0) }
19+
}
20+
21+
/** The `CreateProcess` family of functions from Win32. */
22+
class CreateProcess extends Function {
23+
CreateProcess() { this.hasGlobalName("CreateProcess" + ["", "A", "W"]) }
24+
}
25+
26+
private class CreateProcessModel extends CreateProcess, CommandExecutionFunction {
27+
override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(0) }
28+
}
29+
30+
/** The `CreateProcessAsUser` family of functions from Win32. */
31+
class CreateProcessAsUser extends Function {
32+
CreateProcessAsUser() { this.hasGlobalName("CreateProcessAsUser" + ["", "A", "W"]) }
33+
}
34+
35+
private class CreateProcessAsUserModel extends CreateProcessAsUser, CommandExecutionFunction {
36+
override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(1) }
37+
}
38+
39+
/** The `CreateProcessWithLogonW` function from Win32. */
40+
class CreateProcessWithLogonW extends Function {
41+
CreateProcessWithLogonW() { this.hasGlobalName("CreateProcessWithLogonW") }
42+
}
43+
44+
private class CreateProcessWithLogonModel extends CreateProcessWithLogonW, CommandExecutionFunction {
45+
override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(4) }
46+
}
47+
48+
/** The `CreateProcessWithTokenW` function from Win32. */
49+
class CreateProcessWithTokenW extends Function {
50+
CreateProcessWithTokenW() { this.hasGlobalName("CreateProcessWithTokenW") }
51+
}
52+
53+
private class CreateProcessWithTokenWModel extends CreateProcessWithTokenW, CommandExecutionFunction
54+
{
55+
override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(2) }
56+
}

0 commit comments

Comments
 (0)