Bitdefender Hypervisor Memory Introspection
exceptions_krnusr.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
9 
10 #include "exceptions.h"
11 #include "codeblocks.h"
12 #include "crc32.h"
13 #include "decoder.h"
14 #include "hook.h"
15 #include "winpe.h"
16 
17 
18 extern char gExcLogLine[2 * ONE_KILOBYTE];
19 
20 
21 static void
24  _In_ EXCEPTION_KM_ORIGINATOR *Originator,
25  _In_ INTRO_ACTION Action,
27  )
36 {
37  KERNEL_DRIVER *pDriver = NULL;
38  KERNEL_DRIVER *pRetDriver = NULL;
39  DWORD modNameAlignment;
40  char *l;
41  int ret, rem;
42  char instr[ND_MIN_BUF_SIZE];
43 
44  pDriver = Originator->Original.Driver;
45  pRetDriver = Originator->Return.Driver;
46 
47  modNameAlignment = 0;
48  l = gExcLogLine;
49  rem = sizeof(gExcLogLine);
50 
51  if (Originator->Instruction)
52  {
53  NDSTATUS ndstatus = NdToText(Originator->Instruction, Originator->Original.Rip, sizeof(instr), instr);
54  if (!ND_SUCCESS(ndstatus))
55  {
56  memcpy(instr, EXPORT_NAME_UNKNOWN, sizeof(EXPORT_NAME_UNKNOWN));
57  }
58  }
59  else
60  {
61  memcpy(instr, EXCEPTION_NO_INSTRUCTION, sizeof(EXCEPTION_NO_INSTRUCTION));
62  }
63 
64  ret = IntExceptPrintWinKmModInfo(pDriver, "Originator-> Module: ", l, rem, modNameAlignment);
65  rem -= ret;
66  l += ret;
67 
68  ret = snprintf(l, rem, ", RIP %0*llx", gGuest.WordSize * 2, Originator->Original.Rip);
69 
70  if (ret < 0)
71  {
72  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
73  }
74  else
75  {
76  rem -= ret;
77  l += ret;
78  }
79 
80  if (Originator->Original.Section[0] != 0)
81  {
82  ret = snprintf(l, rem, " (%s)", Originator->Original.Section);
83 
84  if (ret < 0)
85  {
86  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
87  }
88  else
89  {
90  rem -= ret;
91  l += ret;
92  }
93  }
94 
95  if (instr[0] != 0)
96  {
97  ret = snprintf(l, rem, ", Instr: %s", instr);
98 
99  if (ret < 0)
100  {
101  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
102  }
103  else
104  {
105  rem -= ret;
106  l += ret;
107  }
108  }
109 
110  LOG("%s\n", gExcLogLine);
111 
112  if (Originator->Return.Driver && Originator->Original.Rip != Originator->Return.Rip)
113  {
114  l = gExcLogLine;
115  rem = sizeof(gExcLogLine);
116 
117  ret = IntExceptPrintWinKmModInfo(pRetDriver, "Return -> Module: ", l, rem, modNameAlignment);
118  rem -= ret;
119  l += ret;
120 
121  ret = snprintf(l, rem, ", RIP %0*llx", gGuest.WordSize * 2, Originator->Return.Rip);
122 
123  if (ret < 0)
124  {
125  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
126  }
127  else
128  {
129  rem -= ret;
130  l += ret;
131  }
132 
133  if (Originator->Return.Section[0] != 0)
134  {
135  ret = snprintf(l, rem, "(%s)", Originator->Return.Section);
136 
137  if (ret < 0)
138  {
139  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
140  }
141  else
142  {
143  rem -= ret;
144  l += ret;
145  }
146  }
147 
148  LOG("%s\n", gExcLogLine);
149  }
150 
151  if (Victim->Object.Type == introObjectTypeUmModule)
152  {
153  l = gExcLogLine;
154  rem = sizeof(gExcLogLine);
155 
156  ret = IntExceptPrintWinProcInfo(Victim->Object.Library.WinMod->Subsystem->Process, "Process: ",
157  l, rem, 0);
158  rem -= ret;
159  l += ret;
160 
161  LOG("%s\n", gExcLogLine);
162 
163  l = gExcLogLine;
164  rem = sizeof(gExcLogLine);
165 
166  WINUM_CACHE_EXPORT *pExport = NULL;
167 
168  ret = IntExceptPrintWinModInfo(Victim->Object.Library.WinMod, "Victim -> Module: ", l, rem, modNameAlignment);
169  rem -= ret;
170  l += ret;
171 
172  if (Victim->Object.Library.Export == NULL)
173  {
174  pExport = IntWinUmCacheGetExportFromRange(Victim->Object.Library.WinMod, Victim->Ept.Gva, 0x20);
175  }
176  else
177  {
178  pExport = Victim->Object.Library.Export;
179  }
180 
181  if (pExport != NULL)
182  {
183  ret = snprintf(l, rem, ", Exports (%u) : [", pExport->NumberOfOffsets);
184  if (ret < 0)
185  {
186  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
187  }
188  else
189  {
190  rem -= ret;
191  l += ret;
192  }
193 
194  for (DWORD export = 0; export < pExport->NumberOfOffsets; export++)
195  {
196  if (export == pExport->NumberOfOffsets - 1)
197  {
198  ret = snprintf(l, rem, "'%s'", pExport->Names[export]);
199  }
200  else
201  {
202  ret = snprintf(l, rem, "'%s',", pExport->Names[export]);
203  }
204 
205  if (ret < 0)
206  {
207  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
208  }
209  else
210  {
211  rem -= ret;
212  l += ret;
213  }
214 
215  }
216 
217  ret = snprintf(l, rem, "], Delta: +%02x, ",
218  (DWORD)(Victim->Ept.Gva - Victim->Object.Library.WinMod->VirtualBase - pExport->Rva));
219  if (ret < 0)
220  {
221  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
222  }
223  else
224  {
225  rem -= ret;
226  l += ret;
227  }
228  }
229 
230  ret = snprintf(l, rem, ", Address: (%0*llx, %0*llx)",
231  gGuest.WordSize * 2, Victim->Ept.Gva,
232  gGuest.WordSize * 2, Victim->Ept.Gpa);
233  if (ret < 0)
234  {
235  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
236  }
237  else
238  {
239  rem -= ret;
240  l += ret;
241  }
242 
243  ret = snprintf(l, rem, ", WriteInfo: (%u, %016llx -> %016llx)",
244  Victim->WriteInfo.AccessSize,
245  Victim->WriteInfo.OldValue[0],
246  Victim->WriteInfo.NewValue[0]);
247  if (ret < 0)
248  {
249  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
250  }
251  else
252  {
253  rem -= ret;
254  l += ret;
255  }
256 
257  if (Victim->ZoneFlags)
258  {
259  ret = snprintf(l, rem, ", Flags:%s%s%s%s%s (0x%llx)",
260  (Victim->ZoneFlags & ZONE_LIB_IMPORTS) ? " IMPORTS" : "",
261  (Victim->ZoneFlags & ZONE_LIB_EXPORTS) ? " EXPORTS" : "",
262  (Victim->ZoneFlags & ZONE_LIB_CODE) ? " CODE" : "",
263  (Victim->ZoneFlags & ZONE_LIB_DATA) ? " DATA" : "",
264  (Victim->ZoneFlags & ZONE_LIB_RESOURCES) ? " RSRC" : "",
265  (unsigned long long)Victim->ZoneFlags);
266  if (ret < 0)
267  {
268  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
269  }
270  else
271  {
272  rem -= ret;
273  l += ret;
274  }
275  }
276 
277  LOG("%s\n", gExcLogLine);
278  }
279 
280  if (Action == introGuestNotAllowed)
281  {
282  l = gExcLogLine;
283  rem = sizeof(gExcLogLine);
284 
285  ret = snprintf(l, rem, "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^%sROOTKIT (kernel-user mode) ",
286  Victim->Object.Library.WinMod->Subsystem->Process->BetaDetections ? " (B) " : " ");
287  if (ret < 0)
288  {
289  ERROR("[ERROR] Encoding error with snprintf: %d\n", ret);
290  }
291  else
292  {
293  rem -= ret;
294  l += ret;
295  }
296 
297  switch (Reason)
298  {
300  ret = snprintf(l, rem, "(no sig)");
301  break;
303  ret = snprintf(l, rem, "(no exc)");
304  break;
306  ret = snprintf(l, rem, "(extra)");
307  break;
309  ret = snprintf(l, rem, "(error)");
310  break;
312  ret = snprintf(l, rem, "(value)");
313  break;
315  ret = snprintf(l, rem, "(export)");
316  break;
318  ret = snprintf(l, rem, "(value code)");
319  break;
321  ret = snprintf(l, rem, "(idt)");
322  break;
324  ret = snprintf(l, rem, "(version os)");
325  break;
327  ret = snprintf(l, rem, "(version intro)");
328  break;
330  ret = snprintf(l, rem, "(process creation)");
331  break;
332  case introReasonUnknown:
333  ret = snprintf(l, rem, "(unknown)");
334  break;
335  default:
336  ret = snprintf(l, rem, "(%d)", Reason);
337  break;
338  }
339 
340  rem -= ret;
341  l += ret;
342 
343  snprintf(l, rem, " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
344 
345  LOG("%s\n\n", gExcLogLine);
346  }
347  for (DWORD t = 0; t < Originator->StackTrace.NumberOfTraces; t++)
348  {
349  if (NULL != Originator->StackTrace.Traces[t].ReturnModule)
350  {
351  LOG("[STACK TRACE] [at 0x%016llx] returning to [%s at 0x%016llx]\n",
352  Originator->StackTrace.Traces[t].CurrentRip,
353  utf16_for_log(((KERNEL_DRIVER *)Originator->StackTrace.Traces[t].ReturnModule)->Name),
354  Originator->StackTrace.Traces[t].ReturnAddress);
355  }
356  else
357  {
358  LOG("[STACK TRACE] [at 0x%016llx]\n", Originator->StackTrace.Traces[t].CurrentRip);
359  }
360  }
361 }
362 
363 
364 void
366  _In_ EXCEPTION_VICTIM_ZONE *Victim,
367  _In_ EXCEPTION_KM_ORIGINATOR *Originator,
368  _In_ INTRO_ACTION Action,
370  )
379 {
380  if ((introGuestNotAllowed != Action) && (introReasonAllowedFeedback != Reason))
381  {
382  return;
383  }
384 
386  {
387  IntExceptKernelUserLogWindowsInformation(Victim, Originator, Action, Reason);
388  }
389  else if (gGuest.OSType == introGuestLinux)
390  {
391  return;
392  }
393 
394  if (!(Victim->ZoneFlags & ZONE_INTEGRITY))
395  {
396  IntExceptDumpSignatures(Originator, Victim, TRUE, FALSE);
397  IntExceptDumpSignatures(Originator, Victim, TRUE, TRUE);
398  }
399 
400 }
401 
402 
403 static __inline BOOLEAN
405  _In_ EXCEPTION_VICTIM_ZONE *Victim,
406  _In_ KUM_EXCEPTION *Exception
407  )
416 {
417  BOOLEAN match = FALSE;
418 
419  if ((Exception->Flags & EXCEPTION_FLG_READ) &&
420  (Victim->ZoneFlags & ZONE_READ))
421  {
422  match = TRUE;
423  }
424 
425  if ((Exception->Flags & EXCEPTION_FLG_EXECUTE) &&
426  (Victim->ZoneFlags & ZONE_EXECUTE))
427  {
428  match = TRUE;
429  }
430 
431  if ((Exception->Flags & EXCEPTION_FLG_WRITE) &&
432  (Victim->ZoneFlags & ZONE_WRITE))
433  {
434  match = TRUE;
435  }
436 
437  return match;
438 }
439 
440 
441 static __inline BOOLEAN
443  _In_ KUM_EXCEPTION *Exception
444  )
452 {
453  BOOLEAN match = FALSE;
454 
455  if ((Exception->Flags & EXCEPTION_FLG_32) &&
456  (Exception->Flags & EXCEPTION_FLG_64))
457  {
458  match = TRUE;
459  }
460  else if ((Exception->Flags & EXCEPTION_FLG_64) &&
461  gGuest.Guest64)
462  {
463  match = TRUE;
464  }
465  else if ((Exception->Flags & EXCEPTION_FLG_32) &&
466  !gGuest.Guest64)
467  {
468  match = TRUE;
469  }
470 
471  return match;
472 }
473 
474 
475 static __inline BOOLEAN
477  _In_ EXCEPTION_VICTIM_ZONE *Victim,
478  _In_ KUM_EXCEPTION *Exception
479  )
488 {
489  if (Exception->Victim.NameHash == umExcNameAny ||
490  Exception->Victim.NameHash == Victim->Object.NameHash)
491  {
492  return TRUE;
493  }
494 
495  return FALSE;
496 }
497 
498 
499 static __inline BOOLEAN
501  _In_ EXCEPTION_VICTIM_ZONE *Victim,
502  _In_ KUM_EXCEPTION *Exception
503  )
513 {
514  if (Exception->Victim.ProcessHash == umExcNameAny)
515  {
516  return TRUE;
517  }
518  else
519  {
521  {
522  return (Exception->Victim.ProcessHash == Victim->Object.Library.WinMod->Subsystem->Process->NameHash);
523  }
524  else
525  {
526  WARNING("[WARNING] Not supported for Linux guest!\n");
527  }
528  }
529 
530  return FALSE;
531 }
532 
533 
534 static __inline BOOLEAN
536  _In_ EXCEPTION_VICTIM_ZONE *Victim,
537  _In_ KUM_EXCEPTION *Exception
538  )
547 {
548  switch (Exception->Type)
549  {
550  case kumObjAny:
551  return TRUE;
552 
553  case kumObjModule:
554  if (Victim->Object.Type == introObjectTypeUmModule)
555  {
556  return TRUE;
557  }
558  break;
559 
560  case kumObjModuleImports:
561  if ((Victim->Object.Type == introObjectTypeUmModule) &&
562  (Victim->ZoneFlags & ZONE_LIB_IMPORTS))
563  {
564  return TRUE;
565  }
566  break;
567 
568  case kumObjModuleExports:
569  if ((Victim->Object.Type == introObjectTypeUmModule) &&
570  (Victim->ZoneFlags & ZONE_LIB_EXPORTS))
571  {
572  return TRUE;
573  }
574  break;
575 
576  default:
577  LOG("[ERROR] This is a corruption in the update/exception. Type = %d!\n", Exception->Type);
578  break;
579  }
580 
581  return FALSE;
582 }
583 
584 
585 INTSTATUS
587  _In_ EXCEPTION_VICTIM_ZONE *Victim,
588  _In_ EXCEPTION_KM_ORIGINATOR *Originator,
589  _In_ KUM_EXCEPTION *Exception
590  )
611 {
612  BOOLEAN match = FALSE;
613 
614  if (!IntExceptKernelUserMatchZoneFlags(Victim, Exception))
615  {
617  }
618 
619  if (!IntExceptKernelUserMatchArch(Exception))
620  {
622  }
623 
624  if (!IntExceptKernelUserMatchNameHash(Victim, Exception))
625  {
627  }
628 
629  if (!IntExceptKernelUserMatchProcessHash(Victim, Exception))
630  {
632  }
633 
634  if (!IntExceptKernelUserMatchObjectType(Victim, Exception))
635  {
637  }
638 
639  if ((Exception->Flags & EXCEPTION_KM_FLG_NON_DRIVER) &&
640  (Originator->Original.Driver != NULL))
641  {
643  }
644 
645  if (Exception->Flags & EXCEPTION_FLG_INIT)
646  {
647  match = FALSE;
648 
649  // a. On integrity zones, this is all we can check
650  if ((Victim->ZoneType == exceptionZoneIntegrity) &&
651  (Victim->WriteInfo.OldValue[0] == 0))
652  {
653  match = TRUE;
654  }
655  // b. Kernel's INIT section writes
656  else if ((Exception->Flags & EXCEPTION_KM_FLG_RETURN_DRV) &&
657  (Originator->Return.NameHash == kmExcNameKernel))
658  {
659  // match anything that starts with init/INIT
661  {
662  match = 0 == memcmp(Originator->Return.Section, "INIT", 4);
663  }
664  else
665  {
666  match = 0 == memcmp(Originator->Return.Section, "init", 4);
667  }
668  }
669  else if (Originator->Original.NameHash == kmExcNameKernel)
670  {
671  // match anything that starts with init/INIT
673  {
674  match = 0 == memcmp(Originator->Original.Section, "INIT", 4);
675  }
676  else
677  {
678  match = 0 == memcmp(Originator->Original.Section, "init", 4);
679  }
680  }
681  // c. RIP is in EntryPoint
682  else if (Originator->IsEntryPoint)
683  {
684  match = TRUE;
685  }
686  // d. Old value was 0
687  else if (Victim->WriteInfo.OldValue[0] == 0)
688  {
689  match = TRUE;
690  }
691 
692  if (!match)
693  {
695  }
696  }
697 
698  // If we get here, then allow the action. Anyway, the extra checks & signatures mechanism will actually allow it
700 }
701 
702 
703 INTSTATUS
705  _In_ EXCEPTION_VICTIM_ZONE *Victim,
706  _In_ EXCEPTION_KM_ORIGINATOR *Originator,
707  _Out_ INTRO_ACTION *Action,
708  _Out_ INTRO_ACTION_REASON *Reason
709  )
726 {
728  BOOLEAN sameRip = FALSE;
729  BYTE id;
730 
731  if (NULL == Victim)
732  {
734  }
735 
736  if (NULL == Originator)
737  {
739  }
740 
741  if (NULL == Action)
742  {
744  }
745 
746  if (NULL == Reason)
747  {
749  }
750 
751  *Action = introGuestNotAllowed;
752  *Reason = introReasonNoException;
753 
755  {
756  if (pEx->OriginatorNameHash == kmExcNameAny)
757  {
758  // For now, we do not support exceptions from the alert that has originator kmExcNameAny.
759  // If an exception from the alert has no originator, kmExcNameNone will be used as the exception originator
760  goto _match_ex_alert;
761  }
762 
763  if (Originator->Original.NameHash == INITIAL_CRC_VALUE && pEx->OriginatorNameHash == kmExcNameNone)
764  {
765  goto _match_ex_alert;
766  }
767 
768  if (pEx->OriginatorNameHash > Originator->Original.NameHash)
769  {
770  break;
771  }
772  else if (pEx->OriginatorNameHash != Originator->Original.NameHash)
773  {
774  continue;
775  }
776 
777 _match_ex_alert:
778  status = IntExceptMatchException(Victim, Originator, pEx, exceptionTypeKmUm, Action, Reason);
779  if (status == INT_STATUS_EXCEPTION_ALLOW)
780  {
781  return status;
782  }
783  }
784 
785 
786  if (Originator->Original.NameHash == INITIAL_CRC_VALUE)
787  {
788  // Check the no name exceptions, and skip the generic ones
790  {
791  status = IntExceptMatchException(Victim, Originator, pEx, exceptionTypeKmUm, Action, Reason);
792  if (status == INT_STATUS_EXCEPTION_ALLOW)
793  {
794  return status;
795  }
796  }
797  }
798  else
799  {
800  // Check the generic exceptions (all of them, since originator matches anything)
802  {
803  status = IntExceptMatchException(Victim, Originator, pEx, exceptionTypeKmUm, Action, Reason);
804  if (status == INT_STATUS_EXCEPTION_ALLOW)
805  {
806  return status;
807  }
808  }
809  }
810 
811  if (Originator->Original.Driver &&
812  Originator->Return.Driver &&
813  Originator->Original.Rip == Originator->Return.Rip)
814  {
815  // Don't check by RIP since it may be in different sections
816  sameRip = TRUE;
817  }
818 
819  if (Originator->Original.NameHash != INITIAL_CRC_VALUE)
820  {
821  id = EXCEPTION_TABLE_ID(Originator->Original.NameHash);
822 
824  {
825  // Here we only check exceptions by the name, so that cannot be missing.
826  // And the return flag must be missing.
827  if (pEx->OriginatorNameHash == INITIAL_CRC_VALUE ||
828  ((pEx->Flags & EXCEPTION_KM_FLG_RETURN_DRV) &&
829  !sameRip))
830  {
831  continue;
832  }
833 
834  // Every list is ordered, so break when we got to a hash bigger than ours
835  if (pEx->OriginatorNameHash > Originator->Original.NameHash)
836  {
837  break;
838  }
839  else if (pEx->OriginatorNameHash != Originator->Original.NameHash)
840  {
841  continue;
842  }
843 
844  // The EXCEPTION_KM_FLG_RETURN_DRV will be deleted, so do the same verification again
845  if ((pEx->Flags & EXCEPTION_FLG_RETURN) && !sameRip)
846  {
847  continue;
848  }
849 
850  status = IntExceptMatchException(Victim, Originator, pEx, exceptionTypeKmUm, Action, Reason);
851  if (status == INT_STATUS_EXCEPTION_ALLOW)
852  {
853  return status;
854  }
855  }
856 
857  if (sameRip)
858  {
859  // No point in doing the same thing again
860  goto _beta_exceptions;
861  }
862  }
863 
864  // Try and match the original driver by name
865  if (Originator->Return.NameHash != INITIAL_CRC_VALUE)
866  {
867  id = EXCEPTION_TABLE_ID(Originator->Return.NameHash);
869  {
870  // Here we only check exceptions by the name, so that cannot be missing
871  // And the return flag must be set
872  if (pEx->OriginatorNameHash == INITIAL_CRC_VALUE ||
873  (0 == (pEx->Flags & EXCEPTION_KM_FLG_RETURN_DRV)))
874  {
875  continue;
876  }
877 
878  // Every list is ordered, so break when we got to a hash bigger than ours
879  if (pEx->OriginatorNameHash > Originator->Return.NameHash)
880  {
881  break;
882  }
883  else if (pEx->OriginatorNameHash != Originator->Return.NameHash)
884  {
885  continue;
886  }
887 
888  // The EXCEPTION_KM_FLG_RETURN_DRV will be deleted, so do the same verification again
889  if (0 == (pEx->Flags & EXCEPTION_FLG_RETURN))
890  {
891  continue;
892  }
893 
894  status = IntExceptMatchException(Victim, Originator, pEx, exceptionTypeKmUm, Action, Reason);
895  if (status == INT_STATUS_EXCEPTION_ALLOW)
896  {
897  return status;
898  }
899  }
900  }
901 
902 _beta_exceptions:
904  {
905  if (pEx->OriginatorNameHash == kmExcNameAny)
906  {
907  goto _match_ex;
908  }
909 
910  if (Originator->Original.NameHash == INITIAL_CRC_VALUE && pEx->OriginatorNameHash == kmExcNameNone)
911  {
912  goto _match_ex;
913  }
914 
915  if (pEx->Flags & EXCEPTION_FLG_RETURN)
916  {
917  if (pEx->OriginatorNameHash != Originator->Return.NameHash)
918  {
919  continue;
920  }
921  }
922  else
923  {
924  if (pEx->OriginatorNameHash != Originator->Original.NameHash)
925  {
926  continue;
927  }
928  }
929 _match_ex:
930  status = IntExceptMatchException(Victim, Originator, pEx, exceptionTypeKmUm, Action, Reason);
931  if (status == INT_STATUS_EXCEPTION_ALLOW)
932  {
933  return status;
934  }
935  }
936 
937  return status;
938 }
939 
940 
941 INTSTATUS
943  _In_ EXCEPTION_VICTIM_ZONE *Victim,
944  _In_ EXCEPTION_UM_ORIGINATOR *Originator,
945  _In_ UM_EXCEPTION *Exception
946  )
956 {
957  UNREFERENCED_PARAMETER(Victim);
958  UNREFERENCED_PARAMETER(Originator);
959  UNREFERENCED_PARAMETER(Exception);
960 
962 }
#define EXCEPTION_NO_INSTRUCTION
Definition: exceptions.h:30
enum _INTRO_ACTION_REASON INTRO_ACTION_REASON
The reason for which an INTRO_ACTION was taken.
#define INT_STATUS_EXCEPTION_NOT_MATCHED
Definition: introstatus.h:406
#define _Out_
Definition: intro_sal.h:22
_Bool BOOLEAN
Definition: intro_types.h:58
An internal error occurred (no memory, pages not present, etc.).
Definition: intro_types.h:195
uint8_t BYTE
Definition: intro_types.h:47
int IntExceptPrintWinProcInfo(WIN_PROCESS_OBJECT *Process, char *Header, char *Line, int MaxLength, DWORD NameAlignment)
Print the data from the provided WIN_PROCESS_OBJECT.
LIST_HEAD KernelUserExceptions[EXCEPTION_TABLE_SIZE]
Array of linked lists used for kernel-user mode exceptions.
Definition: exceptions.h:109
#define _In_
Definition: intro_sal.h:21
Describe a kernel-user mode exception.
Definition: exceptions.h:270
void IntExceptKernelUserLogInformation(EXCEPTION_VICTIM_ZONE *Victim, EXCEPTION_KM_ORIGINATOR *Originator, INTRO_ACTION Action, INTRO_ACTION_REASON Reason)
Print the information about a kernel-user mode violation and dumps the code-blocks.
The name can be any string.
Definition: exceptions.h:626
#define ZONE_LIB_RESOURCES
Used for the resources section (usually .rsrc inside a driver or dll).
Definition: exceptions.h:691
DWORD NumberOfOffsets
Number of symbols pointing to the exported RVA.
Definition: winumcache.h:27
The exception will take into consideration the return driver/dll.
Definition: exceptions.h:591
#define INT_STATUS_EXCEPTION_CHECKS_OK
Definition: introstatus.h:396
int IntExceptPrintWinModInfo(WIN_PROCESS_MODULE *Module, char *Header, char *Line, int MaxLength, DWORD NameAlignment)
Print the data from the provided WIN_PROCESS_MODULE.
The exception is valid only for read violation.
Definition: exceptions.h:595
#define ERROR(fmt,...)
Definition: glue.h:62
static void IntExceptKernelUserLogWindowsInformation(EXCEPTION_VICTIM_ZONE *Victim, EXCEPTION_KM_ORIGINATOR *Originator, INTRO_ACTION Action, INTRO_ACTION_REASON Reason)
Print the information about a kernel-user mode violation (windows guest).
Describes a user-mode originator.
Definition: exceptions.h:933
The name can be any string.
Definition: exceptions.h:652
INTSTATUS IntExceptMatchException(void *Victim, void *Originator, void *Exception, EXCEPTION_TYPE ExceptionType, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason)
This function tries to find a exception for the current violation..
Definition: exceptions.c:3127
int INTSTATUS
The status data type.
Definition: introstatus.h:24
The exception will match only for the init phase of a driver/process.
Definition: exceptions.h:589
#define ONE_KILOBYTE
Definition: introdefs.h:89
The name is missing.
Definition: exceptions.h:630
Describes a kernel-mode originator.
Definition: exceptions.h:897
The modified object is any with the modified name.
Definition: exceptions.h:189
INTRO_GUEST_TYPE OSType
The type of the guest.
Definition: guests.h:274
The exception is valid only for write violation.
Definition: exceptions.h:596
#define LOG(fmt,...)
Definition: glue.h:61
Describes a kernel driver.
Definition: drivers.h:30
#define ZONE_INTEGRITY
Used for integrity zone.
Definition: exceptions.h:702
static __inline BOOLEAN IntExceptKernelUserMatchObjectType(EXCEPTION_VICTIM_ZONE *Victim, KUM_EXCEPTION *Exception)
Checks if the zone-type of the current exception matches the object-type of the victim.
LIST_HEAD KernelUserAlertExceptions
Linked list used for kernel-user mode exceptions that are added from alert.
Definition: exceptions.h:129
#define ZONE_LIB_CODE
Used for a generic code zone.
Definition: exceptions.h:688
#define INITIAL_CRC_VALUE
Definition: introdefs.h:221
EXCEPTIONS * Exceptions
The exceptions that are currently loaded.
Definition: guests.h:388
The modified object is inside an integrity hook.
Definition: exceptions.h:713
static __inline BOOLEAN IntExceptKernelUserMatchArch(KUM_EXCEPTION *Exception)
Checks if the architecture-flags of the current exception match the architecture-flags of the origina...
#define ZONE_EXECUTE
Used for execute violation.
Definition: exceptions.h:700
The exception is valid only for execute violation.
Definition: exceptions.h:597
BOOLEAN Guest64
True if this is a 64-bit guest, False if it is a 32-bit guest.
Definition: guests.h:286
INTSTATUS IntExceptKernelUserVerifyExtra(EXCEPTION_VICTIM_ZONE *Victim, EXCEPTION_UM_ORIGINATOR *Originator, UM_EXCEPTION *Exception)
This function is used as an extra step in exception mechanism.
The name is the operating system kernel name.
Definition: exceptions.h:628
#define TRUE
Definition: intro_types.h:30
#define INT_STATUS_INVALID_PARAMETER_4
Definition: introstatus.h:71
INTSTATUS IntExceptKernelUser(EXCEPTION_VICTIM_ZONE *Victim, EXCEPTION_KM_ORIGINATOR *Originator, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason)
This function iterates through exception lists and tries to find an exception that matches the origin...
#define for_each_kum_exception(_ex_head, _var_name)
Definition: exceptions.h:1000
static __inline BOOLEAN IntExceptKernelUserMatchProcessHash(EXCEPTION_VICTIM_ZONE *Victim, KUM_EXCEPTION *Exception)
Checks if the exception process name-hash of the current exception matches the process name-hash of t...
BYTE WordSize
Guest word size. Will be 4 for 32-bit guests and 8 for 64-bit guests.
Definition: guests.h:363
LIST_HEAD KernelUserFeedbackExceptions
Linked list used for kernel-user mode exceptions that have the feedback flag.
Definition: exceptions.h:118
char gExcLogLine[2 *ONE_KILOBYTE]
The exception log line.
Definition: exceptions.c:40
#define WARNING(fmt,...)
Definition: glue.h:60
The exception will take into consideration the return driver.
Definition: exceptions.h:604
#define ZONE_LIB_EXPORTS
Used for the exports of a dll, driver, etc.
Definition: exceptions.h:687
The modified object is inside the process module&#39;s EAT.
Definition: exceptions.h:192
Describes the modified zone.
Definition: exceptions.h:847
#define UNREFERENCED_PARAMETER(P)
Definition: introdefs.h:29
INTSTATUS IntExceptKernelUserMatchVictim(EXCEPTION_VICTIM_ZONE *Victim, EXCEPTION_KM_ORIGINATOR *Originator, KUM_EXCEPTION *Exception)
This function checks if the exception matches the originator and the modified zone.
The modified object is inside the process module&#39;s IAT.
Definition: exceptions.h:191
Describe a user-mode exception.
Definition: exceptions.h:298
DWORD Rva
The RVA of this export.
Definition: winumcache.h:23
uint32_t DWORD
Definition: intro_types.h:49
User-mode library.
Definition: intro_types.h:245
enum _INTRO_ACTION INTRO_ACTION
Event actions.
int IntExceptPrintWinKmModInfo(KERNEL_DRIVER *Module, char *Header, char *Line, int MaxLength, DWORD NameAlignment)
Print the information about the provided KERNEL_DRIVER (windows guest).
static __inline BOOLEAN IntExceptKernelUserMatchNameHash(EXCEPTION_VICTIM_ZONE *Victim, KUM_EXCEPTION *Exception)
Checks if the exception name-hash of the current exception matches the name-hash of the victim...
The action was allowed, but it has the BETA flag (Introcore is in log-only mode). ...
Definition: intro_types.h:185
#define ZONE_LIB_DATA
Definition: exceptions.h:689
GUEST_STATE gGuest
The current guest state.
Definition: guests.c:48
static __inline BOOLEAN IntExceptKernelUserMatchZoneFlags(EXCEPTION_VICTIM_ZONE *Victim, KUM_EXCEPTION *Exception)
Checks if the zone-flags of the current exception match the zone flags of the victim.
LIST_HEAD NoNameKernelUserExceptions
Linked list used for kernel-user mode exceptions that don&#39;t have a valid originator (-)...
Definition: exceptions.h:103
#define EXCEPTION_TABLE_ID(H)
Definition: exceptions.h:51
#define ZONE_READ
Used for read violation.
Definition: exceptions.h:699
WINUM_CACHE_EXPORT * IntWinUmCacheGetExportFromRange(WIN_PROCESS_MODULE *Module, QWORD Gva, DWORD Length)
Tries to find an export in the range [Gva - Length, Gva].
Definition: winumcache.c:225
The action was blocked because no exception signature matched.
Definition: intro_types.h:187
PCHAR Names[MAX_OFFSETS_PER_NAME]
The names pointing to this RVA. Each name will point inside the Names structure inside WINUM_CACHE_EX...
Definition: winumcache.h:31
void IntExceptDumpSignatures(void *Originator, EXCEPTION_VICTIM_ZONE *Victim, BOOLEAN KernelMode, BOOLEAN ReturnDrv)
Dump code blocks from the originator&#39;s RIP.
Definition: exceptions.c:2938
LIST_HEAD GenericKernelUserExceptions
Linked list used for kernel-user mode exceptions that have a generic originator(*).
Definition: exceptions.h:95
char * utf16_for_log(const WCHAR *WString)
Converts a UTF-16 to a UTF-8 string to be used inside logging macros.
Definition: introcore.c:2845
#define INT_STATUS_INVALID_PARAMETER_1
Definition: introstatus.h:62
Kernel-User mode exception.
Definition: exceptions.h:64
The action was blocked because there was no exception for it.
Definition: intro_types.h:189
#define ZONE_LIB_IMPORTS
Used for the imports of a dll, driver, etc.
Definition: exceptions.h:686
The original RIP is outside a driver and it returns into a driver (which is the originator name)...
Definition: exceptions.h:602
The exception is valid only on 32 bit systems/process.
Definition: exceptions.h:586
#define EXPORT_NAME_UNKNOWN
Definition: exceptions.h:34
#define ZONE_WRITE
Used for write violation.
Definition: exceptions.h:698
#define INT_STATUS_INVALID_PARAMETER_2
Definition: introstatus.h:65
#define INT_STATUS_EXCEPTION_ALLOW
Definition: introstatus.h:391
#define FALSE
Definition: intro_types.h:34
The exception (and signature, where&#39;s the case) matched, but the extra checks failed.
Definition: intro_types.h:191
#define INT_STATUS_INVALID_PARAMETER_3
Definition: introstatus.h:68
The modified object is inside the process modules.
Definition: exceptions.h:190