Example #1
0
            public static ulong?Read(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame, string type, string[] memberOptions, ref bool available, ref int success, ref int failure)
            {
                Debug.Assert(memberOptions.Length > 0);

                long?result = null;

                foreach (var option in memberOptions)
                {
                    result = EvaluationHelpers.TryEvaluateNumberExpression($"(int)&(({type}*)0)->{option}", inspectionSession, thread, frame, DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects);

                    if (result != null)
                    {
                        break;
                    }
                }

                if (!result.HasValue)
                {
                    available = false;
                    failure++;

                    if (Log.instance != null)
                    {
                        Log.instance.Debug($"Failed to get offsetof '{memberOptions[0]}' in '{type}'");
                    }

                    return(null);
                }

                success++;
                return((ulong)result.Value);
            }
Example #2
0
            public static ulong?ReadOptional(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame, string type, string member, string message, ref int optional)
            {
                long?result = EvaluationHelpers.TryEvaluateNumberExpression($"(int)&(({type}*)0)->{member}", inspectionSession, thread, frame, DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects);

                if (!result.HasValue)
                {
                    if (Log.instance != null)
                    {
                        Log.instance.Debug($"Failed to get offsetof '{member}' in '{type}' (optional, {message})");
                    }

                    return(null);
                }

                optional++;
                return((ulong)result.Value);
            }
Example #3
0
            public static long GetSize(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame, string type, ref bool available)
            {
                long?result = EvaluationHelpers.TryEvaluateNumberExpression($"sizeof({type})", inspectionSession, thread, frame, DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects).GetValueOrDefault(0);

                if (!result.HasValue)
                {
                    available = false;

                    if (Log.instance != null)
                    {
                        Log.instance.Debug($"Failed to get sizeof '{type}'");
                    }

                    return(0);
                }

                return(result.Value);
            }