Skip to content

Commit ed50ecd

Browse files
committed
CIL: Add CIL specific dbscheme entities to the binary dbscheme.
1 parent 37a3a29 commit ed50ecd

1 file changed

Lines changed: 377 additions & 1 deletion

File tree

binary/ql/lib/semmlecode.binary.dbscheme

Lines changed: 377 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ sourceLocationPrefix(
33
varchar(900) prefix: string ref
44
);
55

6+
/**
7+
* External data, loaded from CSV files during snapshot creation.
8+
* This allows importing additional data into CodeQL databases.
9+
*/
10+
externalData(
11+
int id: @externalDataElement,
12+
string path: string ref,
13+
int column: int ref,
14+
string value: string ref
15+
);
16+
617
/* Entity Locations */
718
@location = @location_default;
819

@@ -2094,4 +2105,369 @@ export_table_entry(
20942105
int ordinal: int ref,
20952106
string name: string ref,
20962107
int address: int ref
2097-
);
2108+
);
2109+
2110+
/**
2111+
* Compiled .NET assemblies.
2112+
* Each assembly represents a DLL file that has been extracted.
2113+
* The file field references the DLL/EXE file in the files table.
2114+
*/
2115+
assemblies(
2116+
unique int id: @assembly,
2117+
int file: @file ref,
2118+
string name: string ref,
2119+
string version: string ref
2120+
);
2121+
2122+
/**
2123+
* Types defined in assemblies.
2124+
* Includes classes, structs, interfaces, enums, and delegates.
2125+
*/
2126+
types(
2127+
unique int id: @type,
2128+
string full_name: string ref,
2129+
string namespace: string ref,
2130+
string name: string ref
2131+
);
2132+
2133+
/**
2134+
* Methods defined in types.
2135+
* Includes instance methods, static methods, constructors, and property accessors.
2136+
*/
2137+
methods(
2138+
unique int id: @method,
2139+
string name: string ref,
2140+
string signature: string ref,
2141+
int type_id: @type ref
2142+
);
2143+
2144+
case @il_instruction.mnemonic of
2145+
0 = @il_nop
2146+
| 1 = @il_break
2147+
| 2 = @il_ldarg_0
2148+
| 3 = @il_ldarg_1
2149+
| 4 = @il_ldarg_2
2150+
| 5 = @il_ldarg_3
2151+
| 6 = @il_ldloc_0
2152+
| 7 = @il_ldloc_1
2153+
| 8 = @il_ldloc_2
2154+
| 9 = @il_ldloc_3
2155+
| 10 = @il_stloc_0
2156+
| 11 = @il_stloc_1
2157+
| 12 = @il_stloc_2
2158+
| 13 = @il_stloc_3
2159+
| 14 = @il_ldarg_S
2160+
| 15 = @il_ldarga_S
2161+
| 16 = @il_starg_S
2162+
| 17 = @il_ldloc_S
2163+
| 18 = @il_ldloca_S
2164+
| 19 = @il_stloc_S
2165+
| 20 = @il_ldnull
2166+
| 21 = @il_ldc_I4_M1
2167+
| 22 = @il_ldc_I4_0
2168+
| 23 = @il_ldc_I4_1
2169+
| 24 = @il_ldc_I4_2
2170+
| 25 = @il_ldc_I4_3
2171+
| 26 = @il_ldc_I4_4
2172+
| 27 = @il_ldc_I4_5
2173+
| 28 = @il_ldc_I4_6
2174+
| 29 = @il_ldc_I4_7
2175+
| 30 = @il_ldc_I4_8
2176+
| 31 = @il_ldc_I4_S
2177+
| 32 = @il_ldc_I4
2178+
| 33 = @il_ldc_I8
2179+
| 34 = @il_ldc_R4
2180+
| 35 = @il_ldc_R8
2181+
| 37 = @il_dup
2182+
| 38 = @il_il_pop
2183+
| 39 = @il_il_jmp
2184+
| 40 = @il_il_call
2185+
| 41 = @il_calli
2186+
| 42 = @il_il_ret
2187+
| 43 = @il_br_S
2188+
| 44 = @il_brfalse_S
2189+
| 45 = @il_brtrue_S
2190+
| 46 = @il_beq_S
2191+
| 47 = @il_bge_S
2192+
| 48 = @il_bgt_S
2193+
| 49 = @il_ble_S
2194+
| 50 = @il_blt_S
2195+
| 51 = @il_bne_un_S
2196+
| 52 = @il_bge_un_S
2197+
| 53 = @il_bgt_un_S
2198+
| 54 = @il_ble_un_S
2199+
| 55 = @il_blt_un_S
2200+
| 56 = @il_br
2201+
| 57 = @il_brfalse
2202+
| 58 = @il_brtrue
2203+
| 59 = @il_beq
2204+
| 60 = @il_bge
2205+
| 61 = @il_bgt
2206+
| 62 = @il_ble
2207+
| 63 = @il_blt
2208+
| 64 = @il_bne_un
2209+
| 65 = @il_bge_un
2210+
| 66 = @il_bgt_un
2211+
| 67 = @il_ble_un
2212+
| 68 = @il_blt_un
2213+
| 69 = @il_switch
2214+
| 70 = @il_ldind_I1
2215+
| 71 = @il_ldind_U1
2216+
| 72 = @il_ldind_I2
2217+
| 73 = @il_ldind_U2
2218+
| 74 = @il_ldind_I4
2219+
| 75 = @il_ldind_U4
2220+
| 76 = @il_ldind_I8
2221+
| 77 = @il_ldind_I
2222+
| 78 = @il_ldind_R4
2223+
| 79 = @il_ldind_R8
2224+
| 80 = @il_ldind_Ref
2225+
| 81 = @il_stind_Ref
2226+
| 82 = @il_stind_I1
2227+
| 83 = @il_stind_I2
2228+
| 84 = @il_stind_I4
2229+
| 85 = @il_stind_I8
2230+
| 86 = @il_stind_R4
2231+
| 87 = @il_stind_R8
2232+
| 88 = @il_add
2233+
| 89 = @il_sub
2234+
| 90 = @il_mul
2235+
| 91 = @il_div
2236+
| 92 = @il_div_un
2237+
| 93 = @il_rem
2238+
| 94 = @il_rem_un
2239+
| 95 = @il_and
2240+
| 96 = @il_or
2241+
| 97 = @il_xor
2242+
| 98 = @il_shl
2243+
| 99 = @il_shr
2244+
| 100 = @il_shr_un
2245+
| 101 = @il_neg
2246+
| 102 = @il_not
2247+
| 103 = @il_conv_I1
2248+
| 104 = @il_conv_I2
2249+
| 105 = @il_conv_I4
2250+
| 106 = @il_conv_I8
2251+
| 107 = @il_conv_R4
2252+
| 108 = @il_conv_R8
2253+
| 109 = @il_conv_U4
2254+
| 110 = @il_conv_U8
2255+
| 111 = @il_callvirt
2256+
| 112 = @il_cpobj
2257+
| 113 = @il_ldobj
2258+
| 114 = @il_ldstr
2259+
| 115 = @il_newobj
2260+
| 116 = @il_castclass
2261+
| 117 = @il_isinst
2262+
| 118 = @il_conv_R_Un
2263+
| 121 = @il_unbox
2264+
| 122 = @il_throw
2265+
| 123 = @il_ldfld
2266+
| 124 = @il_ldflda
2267+
| 125 = @il_stfld
2268+
| 126 = @il_ldsfld
2269+
| 127 = @il_ldsflda
2270+
| 128 = @il_stsfld
2271+
| 129 = @il_stobj
2272+
| 130 = @il_conv_ovf_I1_Un
2273+
| 131 = @il_conv_ovf_I2_Un
2274+
| 132 = @il_conv_ovf_I4_Un
2275+
| 133 = @il_conv_ovf_I8_Un
2276+
| 134 = @il_conv_ovf_U1_Un
2277+
| 135 = @il_conv_ovf_U2_Un
2278+
| 136 = @il_conv_ovf_U4_Un
2279+
| 137 = @il_conv_ovf_U8_Un
2280+
| 138 = @il_conv_ovf_I_Un
2281+
| 139 = @il_conv_ovf_U_Un
2282+
| 140 = @il_box
2283+
| 141 = @il_newarr
2284+
| 142 = @il_ldlen
2285+
| 143 = @il_ldelema
2286+
| 144 = @il_ldelem_I1
2287+
| 145 = @il_ldelem_U1
2288+
| 146 = @il_ldelem_I2
2289+
| 147 = @il_ldelem_U2
2290+
| 148 = @il_ldelem_I4
2291+
| 149 = @il_ldelem_U4
2292+
| 150 = @il_ldelem_I8
2293+
| 151 = @il_ldelem_I
2294+
| 152 = @il_ldelem_R4
2295+
| 153 = @il_ldelem_R8
2296+
| 154 = @il_ldelem_Ref
2297+
| 155 = @il_stelem_I
2298+
| 156 = @il_stelem_I1
2299+
| 157 = @il_stelem_I2
2300+
| 158 = @il_stelem_I4
2301+
| 159 = @il_stelem_I8
2302+
| 160 = @il_stelem_R4
2303+
| 161 = @il_stelem_R8
2304+
| 162 = @il_stelem_Ref
2305+
| 163 = @il_ldelem
2306+
| 164 = @il_stelem
2307+
| 165 = @il_unbox_any
2308+
| 179 = @il_conv_ovf_I1
2309+
| 180 = @il_conv_ovf_U1
2310+
| 181 = @il_conv_ovf_I2
2311+
| 182 = @il_conv_ovf_U2
2312+
| 183 = @il_conv_ovf_I4
2313+
| 184 = @il_conv_ovf_U4
2314+
| 185 = @il_conv_ovf_I8
2315+
| 186 = @il_conv_ovf_U8
2316+
| 194 = @il_refanyval
2317+
| 195 = @il_ckfinite
2318+
| 198 = @il_mkrefany
2319+
| 208 = @il_ldtoken
2320+
| 209 = @il_conv_U2
2321+
| 210 = @il_conv_U1
2322+
| 211 = @il_conv_I
2323+
| 212 = @il_conv_ovf_I
2324+
| 213 = @il_conv_ovf_U
2325+
| 214 = @il_add_ovf
2326+
| 215 = @il_add_ovf_un
2327+
| 216 = @il_mul_ovf
2328+
| 217 = @il_mul_ovf_un
2329+
| 218 = @il_sub_ovf
2330+
| 219 = @il_sub_ovf_un
2331+
| 220 = @il_endfinally
2332+
| 221 = @il_leave
2333+
| 222 = @il_leave_s
2334+
| 223 = @il_stind_i
2335+
| 224 = @il_conv_U
2336+
| 248 = @il_prefix7
2337+
| 249 = @il_prefix6
2338+
| 250 = @il_prefix5
2339+
| 251 = @il_prefix4
2340+
| 252 = @il_prefix3
2341+
| 253 = @il_prefix2
2342+
| 254 = @il_prefix1
2343+
| 255 = @il_prefixref
2344+
| 65024 = @il_arglist
2345+
| 65025 = @il_ceq
2346+
| 65026 = @il_cgt
2347+
| 65027 = @il_cgt_un
2348+
| 65028 = @il_clt
2349+
| 65029 = @il_clt_un
2350+
| 65030 = @il_ldftn
2351+
| 65031 = @il_ldvirtftn
2352+
| 65033 = @il_ldarg
2353+
| 65034 = @il_ldarga
2354+
| 65035 = @il_starg
2355+
| 65036 = @il_ldloc
2356+
| 65037 = @il_ldloca
2357+
| 65038 = @il_stloc
2358+
| 65039 = @il_localloc
2359+
| 65041 = @il_endfilter
2360+
| 65042 = @il_unaligned
2361+
| 65043 = @il_volatile
2362+
| 65044 = @il_tail
2363+
| 65045 = @il_initobj
2364+
| 65046 = @il_constrained
2365+
| 65047 = @il_cpblk
2366+
| 65048 = @il_initblk
2367+
| 65050 = @il_rethrow
2368+
| 65052 = @il_sizeof
2369+
| 65053 = @il_refanytype
2370+
| 65054 = @il_readonly
2371+
;
2372+
2373+
/**
2374+
* IL (Intermediate Language) instructions within method bodies.
2375+
* Each instruction represents a single IL opcode with its operand.
2376+
*
2377+
* The opcode_num is the numeric value from System.Reflection.Emit.OpCodes.
2378+
* The opcode_name is the mnemonic (e.g., "ldloc", "call", "br.s").
2379+
* The offset is the byte offset of the instruction within the method body.
2380+
*/
2381+
il_instruction(
2382+
unique int id: @il_instruction,
2383+
int offset: int ref,
2384+
int mnemonic: int ref
2385+
);
2386+
2387+
il_instruction_method(
2388+
unique int instr: @il_instruction ref,
2389+
int method: @method ref
2390+
);
2391+
2392+
/**
2393+
* Parent relationship between instructions and methods.
2394+
* The index represents the sequential position of the instruction (0-based).
2395+
* This allows instructions to be ordered even when offsets are non-sequential.
2396+
*/
2397+
#keyset[instruction, index]
2398+
il_instruction_parent(
2399+
int instruction: @il_instruction ref,
2400+
int index: int ref,
2401+
int parent: @method ref
2402+
);
2403+
2404+
/**
2405+
* Branch target for branch instructions.
2406+
* The target_offset is the byte offset of the instruction that is the target of the branch.
2407+
* Used for control flow analysis.
2408+
*/
2409+
il_branch_target(
2410+
int instruction: @il_instruction ref,
2411+
int target_offset: int ref
2412+
);
2413+
2414+
/**
2415+
* Unresolved method call targets.
2416+
* The target_method_name is the fully qualified name of the called method.
2417+
* These are stored as strings because they may reference methods in other assemblies
2418+
* that haven't been extracted yet.
2419+
*/
2420+
il_call_target_unresolved(
2421+
int instruction: @il_instruction ref,
2422+
string target_method_name: string ref
2423+
);
2424+
2425+
/**
2426+
* String operands for IL instructions.
2427+
* Used for ldstr (load string) instructions.
2428+
*/
2429+
il_operand_string(
2430+
int instruction: @il_instruction ref,
2431+
string value: string ref
2432+
);
2433+
2434+
/**
2435+
* Integer operands for IL instructions.
2436+
* Used for ldc.i4 (load constant int32) and similar instructions.
2437+
*/
2438+
il_operand_int(
2439+
int instruction: @il_instruction ref,
2440+
int value: int ref
2441+
);
2442+
2443+
/**
2444+
* Long integer operands for IL instructions.
2445+
* Used for ldc.i8 (load constant int64) and similar instructions.
2446+
*/
2447+
il_operand_long(
2448+
int instruction: @il_instruction ref,
2449+
int value: int ref
2450+
);
2451+
2452+
/**
2453+
* Exception handlers (try/catch/finally blocks) in methods.
2454+
* Each handler represents a try block with its associated catch/finally/fault handler.
2455+
*
2456+
* The handler_type indicates the type of handler:
2457+
* - "Catch": catch block for specific exception types
2458+
* - "Finally": finally block
2459+
* - "Fault": fault block (like finally but only runs on exception)
2460+
* - "Filter": exception filter block
2461+
*
2462+
* Offsets indicate the start and end positions of the try and handler blocks.
2463+
* An offset of -1 indicates the position is not applicable or not set.
2464+
*/
2465+
il_exception_handler(
2466+
unique int id: @il_exception_handler,
2467+
int method: @method ref,
2468+
string handler_type: string ref,
2469+
int try_start: int ref,
2470+
int try_end: int ref,
2471+
int handler_start: int ref,
2472+
int handler_end: int ref
2473+
);

0 commit comments

Comments
 (0)