Due to no longer being able to use CreateRemoteThreads across sessions, I’ve
been looking at other ways of injecting dlls into running processes.
I’ve realised that RtlCreateUserThread allows thread creation across
sessions at the expense of not informing CSRSS.
As I just want my thread to run a DllMain routine and then exit, I figured
the CSRSS thing wasn’t an issue.
The call the RtlCreateUserThread succeeds however the created thread seemed
to grab a lot of CPU time and wasn’t returning.
The thread stack is unexpected and raises an exception after the context
switch.
Does anyone have any ideas?
0: kd> !thread
THREAD 81cd55b0 Cid 0274.0db8 Teb: 7ffae000 Win32Thread: 00000000 RUNNING
on processor 0
Waiting for reply to LPC MessageId 001e1ff8:
Current LPC port e14c1610
Not impersonating
DeviceMap e10019a8
Owning Process 0 Image:
Attached Process 81dfada0 Image: winlogon.exe
Wait Start TickCount 31171 Ticks: 1 (0:00:00:00.015)
Context Switch Count 1935856
UserTime 00:00:00.250
KernelTime 00:01:37.796
Start Address kernel32!LoadLibraryW (0x7c80aeeb)
Stack Init f519d000 Current f519c348 Base f519d000 Limit f519a000 Call 0
Priority 14 BasePriority 13 PriorityDecrement 0 DecrementCount 16
ChildEBP RetAddr Args to Child
f519c2f4 80545161 00000001 ffdff902 000000d1
nt!RtlpBreakWithStatusInstruction (FPO: [1,0,0])
f519c2f4 806e6a9b 00000001 ffdff902 000000d1 nt!KeUpdateSystemTime+0x175
(FPO: [0,2] TrapFrame @ f519c308)
f519c380 804fcf1b 81cd5778 81cd55b0 8055d0c0
hal!KeAcquireQueuedSpinLock+0x4f (FPO: [0,0,0])
f519c398 805a3af3 81ffbcc8 00000001 00000001 nt!KeReleaseSemaphore+0x11
(FPO: [Non-Fpo])
f519c3cc 805a3c7d e14c1610 81ffbcc8 f519c400
nt!LpcpRequestWaitReplyPort+0x3ff (FPO: [Non-Fpo])
f519c3e4 80643557 e14c1610 f519c578 f519c400
nt!LpcRequestWaitReplyPortEx+0x21 (FPO: [Non-Fpo])
f519c560 80643612 f519c578 e14c1610 00000000 nt!DbgkpSendApiMessageLpc+0x49
(FPO: [Non-Fpo])
f519c5f0 804fe805 f519c9d8 00000000 00000001 nt!DbgkForwardException+0x84
(FPO: [Non-Fpo])
f519c9b0 805028d9 f519c9d8 00000000 f519cd64 nt!KiDispatchException+0x38f
(FPO: [Non-Fpo])
f519cd34 80544f2f 010efd18 010efd34 00000000 nt!KiRaiseException+0x175 (FPO:
[Non-Fpo])
f519cd50 8054164c 010efd18 010efd34 00000000 nt!NtRaiseException+0x33
f519cd50 00000000 010efd18 010efd34 00000000 nt!KiFastCallEntry+0xfc (FPO:
[0,0] TrapFrame @ f519cd64)
WARNING: Frame IP not in any known module. Following frames may be wrong.
00000000 00000000 00000000 00000000 00000000 0x0