I want to debug a program in kernel mode, and I want to break on the entry point of the program like ollydbg
. But I can't break it with bp
because the program is not start and the symbol can't be loaded. I have found some way to do it but I think it's not so good.
1.Break on the CreateProcess
function in kernel. But I don't know which function exactly should I break and I think there is a long way between CreateProcess
and the entry point of the program.
2.Change the entry point of the program with cc
. But it needs other tools and I should change the code where the byte changed back. I think it is annoying.
3.With the help of ollydbg
. Debugging the program with ollydbg
in a virtual machine which is debugged with windbg. I don't think that it is a good idea.
4.Use sxe ld
. It can be found on Listing 3.29
in <<Advanced Windows Debugging>>
. I have tried it but I found that it only works on the first time. And I don't know what exactly should I do after the break.
5.Break on the entry function with bu
. But I don't know what exactly I should do either. For example, how to load the symbol?
6.Use .create
. I don't know whether it is properly or not to do what I said.
I think that it is a common use to break on the entry point of a program when debug in kernel mode with windbg
, and I think that there must be a good way to do that with the powerful windbg
. What's the best way to do it?
By the way, I want to debug a program in kernel mode because I want to get the token vaule of the program. I found that the windbg can identify the token with !token
in user mode, but I don't know how to get the value of token in user mode. It seems that I can only get the value of token in the kernel mode, right or wrong?
!token <address>
in kernel debugger. In user mode tokens surface out through HANDLE's, so if you know the value of the handle, you can dump properties in user mode debugger with command!token <handle>
. In your case you seem to be talking about a token of the user account under which process was started, right? If so, then invoking!token
without parameters will display the right token, assuming the thread is not impersonating. So you don't need to mess with kd at all. – Lollis!token
can show me the information of token, even there is a impersonation token. But I can only get TS Session ID,User/Groups GUID,Primary Group,Privs,Auth ID,Impersonation level,TokenType,Is restricted token from!token
. It seems that I can't get the handle of the token? – Mall!token
obtains a thread token by calling OpenThreadToken, then queries the properties of the token, and closes the handle. So the handle might not be an internal HANDLE of the process being debugged, it is internal to WinDbg itself. What other type of information you need from the token? – LollisPsReferenceImpersonationToken
orPsReferencePrimaryToken
and I want to check for it. – Mall.wtitle
to distinguish them. Use AeDebug to start the debugger automatically for the process you're interested in. – TintinnabulumPsReferenceImpersonationToken
. – Mall