|
The documentation for the IsUserAnAdmin[^] states that:
This function is a wrapper for CheckTokenMembership. It is recommended to call that function directly to determine Administrator group status rather than calling IsUserAnAdmin.
Note This function is available through Windows Vista. It might be altered or unavailable in subsequent versions of Microsoft Windows.
It's not a good idea to use this function, but reading the documentation is. In fact, is you look at the documentation for CheckTokenMembership[^] you'll find sample code that pretty much does what you're after.
Steve
|
|
|
|
|
Thanks Steve. But I am also getting a compilation error while using CheckTokenMembership( )
|
|
|
|
|
First read this[^]. Since the minimum OS required for the CheckTokenMembership[^] function is Windows 2000 add/modify your stdafx.h file so it contains the following:
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
Note: I haven't tried this myself.
Steve
|
|
|
|
|
Thanks Steve.. But its still not working.
|
|
|
|
|
Ok, your original post contains the following:
\Program Files\Microsoft Visual Studio\VC98\Include
Looks like you're using MSVC6, which was released in 1998. Since Windows 2000 was released in (wait for it...) 2000 it's too old. Update to a newer SDK in addition to my previous suggestion. The latest version of the SDK that can be used with MSVC6 can be found here[^] (although I haven't downloaded from here myself).
Steve
|
|
|
|
|
I trying to create button with both icon and text using CBitmap::SetIco() but have some problem.
1. how can i move the icon to the left most of the button ?
2. The icon load from resource using AfxGetApp()->LoadIcon() doesn't have a correct size.
eg the size of icon is 64 * 64 but it alway appear as 32 * 32
are there any function that can load an icon as it original size
3.since I want both text and icon and also want my button
to retain the windows current theme (XP,Vista),so I dont using owner draw button
Thank in advance
|
|
|
|
|
I can't answer all of your questions, but I can answer one.
Instead of LoadIcon, use LoadImage, then you can specify the size of icon you're interested in.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Hello everyone,
Here is the !pe output from WinDbg when there is an exception. It shows exactly the function name where exception occurs.
My question is, how to show the line in the source code which triggers the exception?
Here is WinDbg output.
0:000> !pe
Exception object: 0000000002651ac0
Exception type: System.Exception
Message: Hello Exception Debug
InnerException: <none>
StackTrace (generated):
SP IP Function
000000000012EFF0 00000642801501F4 TestDebug!TestDebug.Program.foo()+0x64
000000000012F030 000006428015014D TestDebug!TestDebug.Program.Main(System.String[])+0x2d
StackTraceString: <none>
HResult: 80131500
thanks in advance,
George
|
|
|
|
|
First check whether the source debugging is turned on or not. Also try configuring the source search path from File Menu.
Also try with the following commands
.lines enable source line information<br />
bp main set initial breakpoint<br />
l+t stepping will be done by source line<br />
l+s source lines will be displayed at prompt<br />
g run program until "main" is entered<br />
pr execute one source line, and toggle register display off<br />
p execute one source line
Please check WinDBG help file and confirm the steps specified under "Debugging in Source Mode"
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Thanks Sarath,
I have tried to type .lines and WinDbg displayed "Line number information will be loaded". Seems I enabled source code debugging, correct?
Here is my code, does it because it is managed code, and WinDbg has no ability to show managed code line number?
namespace TestDebug
{
class Program
{
static void foo()
{
int a = 100;
throw new Exception ("Hello Exception Debug");
}
static void Main(string[] args)
{
foo();
}
}
}
regards,
George
|
|
|
|
|
This is C#. This forum is for C++/MFC.
Steve
|
|
|
|
|
Thanks Steve,
I met with the same issue when using C++ code. When first chance or second chance exception occurs, then I press k to display the stack trace, in the stack trace, there is not my own code. Any ideas?
(my purpose is simple, to display the exception call stack and including source code line number.)
#include <iostream>
using namespace std;
void foo()
{
throw "Hello World";
}
int main()
{
int a = 100;
a = a + 100;
foo();
return 0;
}
regards,
George
|
|
|
|
|
First off some questions (regarding the C++ version):
- What IDE are you using?
- What debugger are you using?
- What does the stack trace you're getting look like?
Steve
|
|
|
|
|
Thanks Steve!
I am using Visual Studio 2008 to build the code into a debug version. I am using WinDbg as debugger. I want to see th stack trace like,
foo (@ line 7)
main
any ideas?
regards,
George
|
|
|
|
|
Follow these steps:
- Open program the in WinDBG.
- When loader breakpoint is hit select "Debug"->"Event Filters" from the menu.
- Find "Visual C++ exception" in the list.
- Remember the settings in the radio buttons in case you wish to put them back later.
- Select "Enabled" and "Not Handled" in the radio buttons.
- Press "Close".
- Continue execution.
Steve
|
|
|
|
|
Sure, Steve!
I followed your steps and here is my output (I pressed g when both first chance and second chance exception occured). But still no stack trace for my own code. Any ideas?
(670.ab4): WOW64 breakpoint - code 4000001f (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
ntdll32!DbgBreakPoint:
00000000`7d61002d cc int 3
0:000:x86> g
(670.ab4): C++ EH exception - code e06d7363 (first chance)
(670.ab4): C++ EH exception - code e06d7363 (!!! second chance !!!)
wow64!Wow64NotifyDebugger+0x9:
00000000`6b006369 b001 mov al,1
regards,
George
|
|
|
|
|
Is your program 64-bit or 32-bit? What about your version of Windows?
Steve
|
|
|
|
|
Thanks Steve!
My OS is Windows Server 2003, x64. I build the code into x86 binary. Any ideas?
regards,
George
|
|
|
|
|
Hi Steve,
1.
Your reply gives me some hints and I have made more experiments, here are the results for x64 binary runs on x64 platform. It looks fine. Does it because of x86 code is not supported to print out stack trace on x64?
0:000> g
(730.4f8): C++ EH exception - code e06d7363 (first chance)
(730.4f8): C++ EH exception - code e06d7363 (!!! second chance !!!)
kernel32!RaiseException+0x5c:
00000000`77d4dd10 4881c4c8000000 add rsp,0C8h
0:000> k
Child-SP RetAddr Call Site
00000000`0012fd00 00000000`1029bedc kernel32!RaiseException+0x5c
00000000`0012fdd0 00000001`40001057 MSVCR90D!CxxThrowException+0xac
00000000`0012fe60 00000001`400010a2 TestDebugSource!foo+0x37 [d:\visual studio 2008\projects\testdebugsource\testdebugsource\main.cpp @ 8]
00000000`0012fea0 00000001`400014c2 TestDebugSource!main+0x32 [d:\visual studio 2008\projects\testdebugsource\testdebugsource\main.cpp @ 18]
2.
What is the function of Handled or Not Handled in Event Filter dialog?
(I always set Execution option, but ignore the Continue option before.)
regards,
George
|
|
|
|
|
George_George wrote: It looks fine. Does it because of x86 code is not supported to print out stack trace on x64?
Try using the !wow64exts.sw command.
Steve
|
|
|
|
|
Thanks Steve,
I have tried, the stack with my own code could be printed out, but the line number is not correct (but in x64 binary it is correct).
Any comments to this question I asked before?
--------------------
What is the function of Handled or Not Handled in Event Filter dialog?
(I always set Execution option, but ignore the Continue option before.)
--------------------
regards,
George
|
|
|
|
|
George_George wrote: What is the function of Handled or Not Handled in Event Filter dialog?
(I always set Execution option, but ignore the Continue option before.)
Do a search on "Controlling Exceptions and Events" in WinDBG's help file. I have quoted from this below.
The radio buttons in the "Execution" group control the "Break Status":
- Enabled : "When this exception occurs, the target immediately breaks into the debugger. This break in occurs before any other error handlers are activated. This method is called first-chance handling."
- Disabled : "The debugger does not break in for this kind of first-chance exception (although a message is displayed). If other error handlers cannot address this exception, execution stops and the target break into the debugger. This method is called second-chance handling."
- Notify : "When this exception occurs, the target application does not break into the debugger at all. However, a message is displayed that informs the user of this exception."
- Ignore : "When this exception occurs, the target application does not break into the debugger, and no message is displayed."
The buttons in the "Continue" group control the "Handling Status":
- Handled : "The event is considered handled when execution resumes."
- Not Handled : "The event is considered not handled when execution resumes."
Steve
|
|
|
|
|
Thanks Steve,
I think the question for C++ exception is solved. For the managed code, why the line number could not be displayed when using !pe command, I am not sure whether it is supported in managed code to print the line number along with !pe command output. Any comments?
regards,
George
|
|
|
|
|
Sorry, I can't really help you there. I try to steer clear of managed code: it simply doesn't interest me.
Steve
|
|
|
|
|
It is ok, Steve!
I am trying to find help for command !wow64exts.sw in debugger.chm, but failed. Do you have any documents for this command?
regards,
George
|
|
|
|