はみ出しRAPTの戯言

- a day after yesterday -

目次

Blog 利用状況

ニュース

書庫

日記カテゴリ

コミュニティ リンク

[Vista] 自分が現在、昇格実行されているか

Vista で自分が現在、昇格実行されているかを調査するコード

VC++.NET 2003 にて動作確認済み。

// Microsoft SDK v6 WinNT.h (最新の SDK を入れている方は、この部分は不要です。)
#define TokenElevationType    static_cast< TOKEN_INFORMATION_CLASS >( 18 )
typedef enum _TOKEN_ELEVATION_TYPE {
    TokenElevationTypeDefault = 1,
    TokenElevationTypeFull,
    TokenElevationTypeLimited,
} TOKEN_ELEVATION_TYPE, *PTOKEN_ELEVATION_TYPE;



// 昇格が必要か
bool IsNeedHigher()
{
    OSVERSIONINFO ovi = { sizeof ovi };
    ::GetVersionEx( &ovi );
    if ( ovi.dwPlatformId != VER_PLATFORM_WIN32_NT || ovi.dwMajorVersion < 6 ) {
        return false;
    }

    HMODULE hLib = ::LoadLibrary( _T( "advapi32.dll" ) );
    if ( hLib == NULL ) {
        return false;
    }

    typedef BOOL ( *LPFNOPENPROCESSTOKEN )( HANDLE, DWORD, PHANDLE );
    typedef BOOL ( *LPFNGETTOKENINFORMATION )( HANDLE, TOKEN_INFORMATION_CLASS, LPVOID, DWORD, PDWORD );

    LPFNOPENPROCESSTOKEN lpfnOpenProcessToken = reinterpret_cast< LPFNOPENPROCESSTOKEN >( ::GetProcAddress( hLib, "OpenProcessToken" ) );
    LPFNGETTOKENINFORMATION lpfnGetTokenInformation = reinterpret_cast< LPFNGETTOKENINFORMATION >( ::GetProcAddress( hLib, "GetTokenInformation" ) );

    if ( lpfnOpenProcessToken == NULL || lpfnGetTokenInformation == NULL ) {
        ::FreeLibrary( hLib );
        return false;
    }

    bool bResult = true;
    HANDLE hToken = NULL;
    if ( lpfnOpenProcessToken( ::GetCurrentProcess(), TOKEN_QUERY, &hToken ) ) {
        DWORD dwLength = 0;
        TOKEN_ELEVATION_TYPE tet;
        lpfnGetTokenInformation( hToken, TokenElevationType, &tet, sizeof tet, &dwLength );
        ::CloseHandle( hToken );
        if ( tet != TokenElevationTypeLimited ) {
            bResult = false;
        }
    }

    ::FreeLibrary( hLib );
    return bResult;
}

if ( lpfnOpenProcessToken == NULL || lpfnGetTokenInformation == NULL ) {

のところ、条件式が && になっていたのは間違い。 || じゃないとだめですよね。

ってことで修正しました。

投稿日時 : 2007年6月12日 11:02

コメントを追加

# re: [Vista] 自分が現在、昇格実行されているか 2007/06/12 11:49 シャノン

昇格実行された上で、偽装されて低権限を装っているとかいうマニアックな状態は「昇格されていない」でいいのかな。

# re: [Vista] 自分が現在、昇格実行されているか 2007/06/13 8:36 Jitta

いただきます

シャノンさん:
スプーラから実行される、ポート管理アプリケーションですね

# re: [Vista] 自分が現在、昇格実行されているか 2007/06/13 18:00 RAPT

シャノンさん>
自分がもっているプロセストークンで判別しているので、
その場合は「昇格されていない」となると思います。

Jittaさん>
どぞー

# Illikebuisse gqynf 2021/07/04 21:30 pharmacepticacom

tadalafil contraindications https://www.pharmaceptica.com/

# erectile natural remedies 2021/07/06 10:22 hydroxychloroquine tablets

do you need a prescription for hydroxychloroquine https://plaquenilx.com/# hydrochloroquine

# re: [Vista] ???????????????? 2021/07/09 16:55 side effects of hydroxychloroquine

chloroquine natural sources https://chloroquineorigin.com/# can hydroxychloroquine

# re: [Vista] ???????????????? 2021/07/25 17:37 hydroxochlorquine

chlorodine https://chloroquineorigin.com/# chloroquine phosphate vs hydroxychloroquine sulfate

# re: [Vista] ???????????????? 2021/08/09 10:13 hydroxychloroquine 200 mg tablets

cloriquine https://chloroquineorigin.com/# what is hcq

# This is the right website for anyone who wants to find out about this topic. You realize a whole lot its almost hard to argue with you (not that I really would want to…HaHa). You definitely put a brand new spin on a subject that has been written about f 2021/09/01 3:25 This is the right website for anyone who wants to

This is the right website for anyone who wants to find out about this topic.
You realize a whole lot its almost hard to argue with you (not that I
really would want to…HaHa). You definitely put a
brand new spin on a subject that has been written about for ages.
Great stuff, just excellent!

# This is the right website for anyone who wants to find out about this topic. You realize a whole lot its almost hard to argue with you (not that I really would want to…HaHa). You definitely put a brand new spin on a subject that has been written about f 2021/09/01 3:26 This is the right website for anyone who wants to

This is the right website for anyone who wants to find out about this topic.
You realize a whole lot its almost hard to argue with you (not that I
really would want to…HaHa). You definitely put a
brand new spin on a subject that has been written about for ages.
Great stuff, just excellent!

# This is the right website for anyone who wants to find out about this topic. You realize a whole lot its almost hard to argue with you (not that I really would want to…HaHa). You definitely put a brand new spin on a subject that has been written about f 2021/09/01 3:27 This is the right website for anyone who wants to

This is the right website for anyone who wants to find out about this topic.
You realize a whole lot its almost hard to argue with you (not that I
really would want to…HaHa). You definitely put a
brand new spin on a subject that has been written about for ages.
Great stuff, just excellent!

# This is the right website for anyone who wants to find out about this topic. You realize a whole lot its almost hard to argue with you (not that I really would want to…HaHa). You definitely put a brand new spin on a subject that has been written about f 2021/09/01 3:28 This is the right website for anyone who wants to

This is the right website for anyone who wants to find out about this topic.
You realize a whole lot its almost hard to argue with you (not that I
really would want to…HaHa). You definitely put a
brand new spin on a subject that has been written about for ages.
Great stuff, just excellent!

# Excellent post. I'm experiencing a few of these issues as well.. 2021/09/02 6:53 Excellent post. I'm experiencing a few of these is

Excellent post. I'm experiencing a few of these issues as well..

# Excellent post. I'm experiencing a few of these issues as well.. 2021/09/02 6:54 Excellent post. I'm experiencing a few of these is

Excellent post. I'm experiencing a few of these issues as well..

# Excellent post. I'm experiencing a few of these issues as well.. 2021/09/02 6:55 Excellent post. I'm experiencing a few of these is

Excellent post. I'm experiencing a few of these issues as well..

# Excellent post. I'm experiencing a few of these issues as well.. 2021/09/02 6:56 Excellent post. I'm experiencing a few of these is

Excellent post. I'm experiencing a few of these issues as well..

# Wow, that's what I was looking for, what a data! present here at this blog, thanks admin of this web site. 2021/09/03 4:30 Wow, that's what I was looking for, what a data! p

Wow, that's what I was looking for, what a data! present here at this blog, thanks admin of this
web site.

# My brother suggested I would possibly like this web site. He was once totally right. This post actually made my day. You cann't believe simply how so much time I had spent for this information! Thanks! 2021/09/04 21:14 My brother suggested I would possibly like this we

My brother suggested I would possibly like this web site.
He was once totally right. This post actually made my day.

You cann't believe simply how so much time I had spent for this information! Thanks!

# My brother suggested I would possibly like this web site. He was once totally right. This post actually made my day. You cann't believe simply how so much time I had spent for this information! Thanks! 2021/09/04 21:15 My brother suggested I would possibly like this we

My brother suggested I would possibly like this web site.
He was once totally right. This post actually made my day.

You cann't believe simply how so much time I had spent for this information! Thanks!

# My brother suggested I would possibly like this web site. He was once totally right. This post actually made my day. You cann't believe simply how so much time I had spent for this information! Thanks! 2021/09/04 21:16 My brother suggested I would possibly like this we

My brother suggested I would possibly like this web site.
He was once totally right. This post actually made my day.

You cann't believe simply how so much time I had spent for this information! Thanks!

# My brother suggested I would possibly like this web site. He was once totally right. This post actually made my day. You cann't believe simply how so much time I had spent for this information! Thanks! 2021/09/04 21:17 My brother suggested I would possibly like this we

My brother suggested I would possibly like this web site.
He was once totally right. This post actually made my day.

You cann't believe simply how so much time I had spent for this information! Thanks!

# Woah! I'm really digging the template/theme of this blog. It's simple, yet effective. A lot of times it's very difficult to get that "perfect balance" between usability and appearance. I must say you've done a amazing job with this. Also, the 2021/09/11 19:01 Woah! I'm really digging the template/theme of th

Woah! I'm really digging the template/theme of this blog. It's simple,
yet effective. A lot of times it's very difficult to get that "perfect balance" between usability and appearance.

I must say you've done a amazing job with this.

Also, the blog loads extremely quick for me on Safari.
Outstanding Blog! quest bars http://bit.ly/3C2tkMR quest bars

# My spouse and I stumbled over here different web address and thought I may as well check things out. I like what I see so now i'm following you. Look forward to looking into your web page yet again. scoliosis surgery https://coub.com/stories/962966-sco 2021/09/12 17:02 My spouse and I stumbled over here different web

My spouse and I stumbled over here different web address and thought I may as
well check things out. I like what I see so now i'm following you.
Look forward to looking into your web page yet again. scoliosis surgery
https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# I am regular visitor, how are you everybody? This post posted at this web site is in fact good. 2021/10/25 14:20 I am regular visitor, how are you everybody? This

I am regular visitor, how are you everybody? This post
posted at this web site is in fact good.

# ejzhepuhivkf 2021/12/03 7:50 dwedaynctf

https://hydroxychloroquine20.com/ chloroquine buy online

# What's up, its good article about media print, we all know media is a impressive source of information. 2022/03/23 15:17 What's up, its good article about media print, we

What's up, its good article about media print, we all know media
is a impressive source of information.

# What's up, its good article about media print, we all know media is a impressive source of information. 2022/03/23 15:18 What's up, its good article about media print, we

What's up, its good article about media print, we all know media
is a impressive source of information.

# What's up, its good article about media print, we all know media is a impressive source of information. 2022/03/23 15:19 What's up, its good article about media print, we

What's up, its good article about media print, we all know media
is a impressive source of information.

# What's up, its good article about media print, we all know media is a impressive source of information. 2022/03/23 15:20 What's up, its good article about media print, we

What's up, its good article about media print, we all know media
is a impressive source of information.

# Heya i am for the first time here. I came across this board and I in finding It really useful & it helped me out a lot. I hope to present one thing back and help others like you helped me. 2022/03/24 17:34 Heya i am for the first time here. I came across t

Heya i am for the first time here. I came across this board and I in finding It really useful & it helped me out a lot.
I hope to present one thing back and help others like you helped me.

# thkjfoflqdye 2022/05/29 9:43 wmbtfaep

erythromycin base https://erythromycinn.com/#

# Superb blog you have here but I was wanting to know if you knew of any message boards that cover the same topics discussed here? I'd really love to be a part of online community where I can get feed-back from other experienced individuals that share the 2022/06/05 11:39 Superb blog you have here but I was wanting to kno

Superb blog you have here but I was wanting to know if you knew of any message boards that cover the same topics
discussed here? I'd really love to be a part of online community where I can get feed-back from other experienced individuals that share the same interest.
If you have any suggestions, please let me
know. Appreciate it!

# plaquenil generic 2022/12/25 17:35 MorrisReaks

hydroxychloroquine online https://www.hydroxychloroquinex.com/

# chloroquine pills 2022/12/25 19:59 MorrisReaks

is chloroquine over the counter http://hydroxychloroquinex.com/

タイトル
名前
URL
コメント