(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestCallstackFinalUserFrame(t *testing.T) { |
| 68 | var tests = []struct { |
| 69 | callstack Callstack |
| 70 | expectedMod string |
| 71 | expectedSym string |
| 72 | }{ |
| 73 | {callstack: callstackFromFrames( |
| 74 | Frame{Addr: 0xf259de, Module: unbacked, Symbol: "?"}, |
| 75 | Frame{Addr: 0x7ffe4fda6e3b, Module: "C:\\Windows\\System32\\KernelBase.dll", Symbol: "SetThreadContext"}, |
| 76 | Frame{Addr: 0x7ffe52942b24, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "ZwSetContextThread"}, |
| 77 | Frame{Addr: 0xfffff807e228c555, Module: "C:\\WINDOWS\\system32\\ntoskrnl.exe", Symbol: "setjmpex"}, |
| 78 | Frame{Addr: 0xfffff807e264805c, Module: "C:\\WINDOWS\\system32\\ntoskrnl.exe", Symbol: "ObOpenObjectByPointerWithTag"}), |
| 79 | expectedMod: "unbacked", |
| 80 | expectedSym: "?", |
| 81 | }, |
| 82 | {callstack: callstackFromFrames( |
| 83 | Frame{Addr: 0x7ffff0f3bf6c, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "RtlUserThreadStart"}, |
| 84 | Frame{Addr: 0x7ffff03ee8d7, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "BaseThreadInitThunk"}, |
| 85 | Frame{Addr: 0x7ffff0ee5f13, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "TpCallbackMayRunLong"}, |
| 86 | Frame{Addr: 0x7ffff0c78788, Module: "C:\\Windows\\System32\\rpcrt4.dll", Symbol: "RpcGetBufferWithObject"}, |
| 87 | Frame{Addr: 0x7ffff0c797e3, Module: "C:\\Windows\\System32\\rpcrt4.dll", Symbol: "RpcImpersonateClient"}, |
| 88 | Frame{Addr: 0x7fffee58d16a, Module: "C:\\Windows\\System32\\KernelBase.dll", Symbol: "CreateProcessInternalW"}, |
| 89 | Frame{Addr: 0x7ffff0fe1204, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "ZwCreateUserProcess"}), |
| 90 | expectedMod: "C:\\Windows\\System32\\rpcrt4.dll", |
| 91 | expectedSym: "RpcImpersonateClient", |
| 92 | }, |
| 93 | {callstack: callstackFromFrames( |
| 94 | Frame{Addr: 0x7fffa7e3bf6c, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "RtlUserThreadStart"}, |
| 95 | Frame{Addr: 0x7fffa60de8d7, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "BaseThreadInitThunk"}, |
| 96 | Frame{Addr: 0x7ff6163cfc68, Module: "C:\\Program Files\\Mozilla Firefox\\firefox.exe", Symbol: "TargetCreateThread"}, |
| 97 | Frame{Addr: 0x7fffee58d16a, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "ZwMapViewOfSection"}, |
| 98 | Frame{Addr: 0xfffff8028deeed1d, Module: "C:\\WINDOWS\\system32\\ntoskrnl.exe", Symbol: "NtMapViewOfSection"}), |
| 99 | expectedMod: "C:\\Program Files\\Mozilla Firefox\\firefox.exe", |
| 100 | expectedSym: "TargetCreateThread", |
| 101 | }, |
| 102 | {callstack: callstackFromFrames( |
| 103 | Frame{Addr: 0x7fffa7e3bf6c, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "RtlUserThreadStart"}, |
| 104 | Frame{Addr: 0x7fffa60de8d7, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "BaseThreadInitThunk"}, |
| 105 | Frame{Addr: 0x7ffff0c78788, Module: "C:\\Windows\\System32\\rpcrt4.dll", Symbol: "NdrServerCallNdr64"}, |
| 106 | Frame{Addr: 0x7ffff0c574ed, Module: "C:\\Windows\\System32\\rpcrt4.dll", Symbol: "NdrStubCall2"}, |
| 107 | Frame{Addr: 0x7ffff03fb090, Module: "C:\\Windows\\System32\\kernel32.dll", Symbol: "CreateProcessInternalW"}, |
| 108 | Frame{Addr: 0x7fffee58a923, Module: "C:\\Windows\\System32\\kernel32.dll", Symbol: "CreateProcessAsUserW"}, |
| 109 | Frame{Addr: 0x7ffff0fe1204, Module: "C:\\Windows\\System32\\ntdll.dll", Symbol: "ZwCreateUserProcess"}), |
| 110 | expectedMod: "C:\\Windows\\System32\\rpcrt4.dll", |
| 111 | expectedSym: "NdrStubCall2", |
| 112 | }, |
| 113 | } |
| 114 | |
| 115 | for _, tt := range tests { |
| 116 | t.Run(tt.expectedMod+"!"+tt.expectedSym, func(t *testing.T) { |
| 117 | f := tt.callstack.FinalUserFrame() |
| 118 | require.NotNil(t, f) |
| 119 | assert.Equal(t, tt.expectedMod, f.Module) |
| 120 | assert.Equal(t, tt.expectedSym, f.Symbol) |
| 121 | }) |
| 122 | } |
| 123 | } |
| 124 |
nothing calls this directly
no test coverage detected