李帅的博客

软件开发爱好者

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  14 随笔 :: 3 文章 :: 4 评论 :: 0 Trackbacks

#

9. Which of the following statements provide a valid reason NOT to use RTTI for distributed (i.e. networked between different platforms) applications in C++?
A. RTTI is too slow.
B. RTTI does not have standardized run-time behavior.
C. RTTI uses too much memory.
D. RTTI's performance is unpredictable/non-deterministic.
E. RTTI frequently fails to function correctly at run-time

11. A C++ developer wants to handle a static_cast <char*>() operation for the class String shown below. Which of the following options are valid declarations that will accomplish this task?
class String {
public:
  //...
  //declaration goes here
};
A. char* operator char*();
B. operator char*();
C. char* operator();
D. String operator char*();
E. char* operator String();


16. When a Copy Constructor is not written for a class, the C++ compiler generates one. Which of the following statements correctly describe the actions of this compiler-generated Copy Constructor when invoked?
A. The compiler-generated Copy Constructor makes the object being constructed, a reference to the object passed to it as an argument.
B. The compiler-generated Copy Constructor does not do anything by default.
C. The compiler-generated Copy Constructor performs a member-wise copy of the object passed to it as an argument, into the object being constructed.
D. The compiler-generated Copy Constructor tags the object as having been Copy-Constructed by the compiler.
E. The compiler-generated Copy Constructor invokes the assignment operator of the class.

17. Which of the following must be ensured in order to implement a polymorphic function in C++?
A.        There has to be a pointer of the derived class that has implemented the polymorphic function that holds the address of the derived class object.
B.        The function must be declared as virtual in both the base class and in the derived class that overrides the function.
C.        The function must be declared as pure virtual.
D.        There has to be a base class pointer holding the address of a base or derived class object that has implemented the polymorphic function.
E.        The function must be declared as virtual in the base class.

18. Protected, or private, inheritance, as opposed to public inheritance, models which type of relationship in C++?
A.        Can-only-have-one-of
B.        Is-implemented-in-terms-of
C.        Was-a
D.        Has-a
E.        Shares-a-relationship-with

19. Which of the following statements describe correct methods of handling C++ exceptions?
A.        Once an exception is thrown, the compiler unwinds the heap, freeing any memory dynamically allocated within the block from which the exception was thrown.
B.        In a hierarchy of exception classes, the order of handling exceptions can be from the most specific class to the most general class.
C.        Catching an exception by reference is preferable to catching it by value.
D.        If an exception is caught by its address or pointer, it is the responsibility of the thrower to release the memory occupied by the exception.
E.        To write an exception handler, it is essential to know the concrete class of exception to catch.

20. Which of the following statements regarding functions' default arguments in C++ are correct?
A.        Default arguments cannot be of a user-defined type.
B.        Default arguments exist in the global heap and not on the function's stack.
C.        Default arguments cannot be of pointer type.
D.        Default arguments can never precede non-default arguments.
E.        Default arguments are not considered for generating the function's signature.

21. Which of the following classes must be instantiated so that the object can be used both for reading and writing to the same file in C++?
A.        ofstream
B.        stream
C.        ifstream
D.        fstream
E.        iostream

22.  Which of the following reasons describe why a destructor cannot throw an exception in C++?
A.        Since the object is being destroyed, it is illogical to throw an exception then.
B.        A destructor may be invoked as a result of stack unwinding while an exception is being handled.
C.        It can invoke the terminate() handler.
D.        The C++ language does not permit it; a throw statement in a destructor will be caught as an error by the compiler.
E.        A destructor in C++ cannot implement a try...catch block

24. Which of the following identify const-correctness failures in the C++ program below?
template<typename T>
class MyArray
{
public:
    MyArray();
    MyArray(MyArray& copy);
    MyArray& operator=(MyArray& copy);
    //...

};

class MyData
{
public:
    MyData(MyArray<int>& x, MyArray<int>& y);
    //...

    const MyArray<int>& x();
    const MyArray<int>& y();
};

MyArray<int> read_data(int*, char**);
void make_changes(MyData* edit);

int main(int argc, char* argv[])
{
    const MyArray<int> read_x = read_data(&argc, argv);
    const MyArray<int> read_y = read_data(&argc, argv);
     
    MyData user_data(read_x, read_y);
    MyData edit_buffer(user_data);
    make_changes(&edit_buffer);
}

A.        MyData(MyArray<int>& x, MyArray<int>& y); should be
MyData(const MyArray<int>& x, const MyArray<int>& y);

B.        MyArray(MyArray& copy); should be
MyArray(const MyArray& copy);

C.        MyArray& operator=(MyArray& copy); should be
const MyArray& operator=(const MyArray& copy);

D.        void make_changes(MyData* edit); should be
void make_changes(const MyData* edit);

E.        const MyArray& operator=(const MyArray& copy); should be
const MyArray& operator=(const MyArray& copy) const;

25. Which of the following operators must be overloaded by function objects in the Standard Template Library?
A.        operator +()
B.        operator ==()
C.        operator ++()
D.        operator ()()
E.        operator []()

======================================================

附上我的选择和疑问,欢迎大家指正和讨论:

9. AD (not quite sure)
11. A (What does this question mean?! Can anyone explain it? )
16. AC  (Is A right?! Should it be 'a CONST reference to the object passed to it as an argument')
17. E (not quite sure. Is A or D right too? )
18. A or E. I have no idea at all!!!!
19 C (Is B right too?)
20. only D?
21. DE
22. BC ?
24. only B ?
25. D
posted @ 2008-11-07 21:37 李帅 阅读(1343) | 评论 (1)编辑 收藏

softICE的安装与配置

㈠、SOFTICE安装 

1、SOFTICE目前最新版本是4.05,如你的系统是win9x,就请下载for win9x版本的SOFTICE,建议下载SOFTICE的最新版本,这样稳定性好些。运行setup.exe开始安装,出现(图一):

2、然后点击下一步,输入安装序列号(图二)(序列号一般在安装软件的readme.txt或其它说明文件里)

3、然后下面几个画面是要求选定路径和安装组件,不久你会来到显卡配制对话框(图三):

在显卡配制里两种方法:

①这种配制使SOFTICE激活状态时类似DOS全屏状态一样(也就是字符模式状态),在显卡列表选择你的显卡类型,Universal Vidoe DriverUse monochrome card/monitor这两项不要选,然后点击Test按钮,在测试过程中你能看到各种颜色的字符,说明显卡测试通过,就可点击下一步了。

② 这种配制使SOFTICE在激活状态下类似windows应用程序的一个窗口那样,这样在调试时可避免显示器不停地在图形和字符模式转换,对提高显示器寿命大有好处。配制时,显卡列表一栏忽略,不用配制,只要把
Universal Vidoe Driver这一项选上,然后test,如跳出如(图四)对话框,测试通过。(本人强烈推荐这种方式)

㈡、SOFTICE配制

1、Symbol Loader的使用

你在开始SOFTICE的菜单里有一项ymbol Loader快捷方式,运行后,在其菜单EDITSOFTICE Initialization Settings选项,打开后如图(图八)。这里你就可配制SOFTICE了。

General选项

在Initialization string里,你可填上需要SOFTICE一启动自动运行的命令。如:

WD 2; WC 14; FAULTS OFF; IXHERE OFF; IYHERE OFF; set font 2;lines 40;x;(各行以分号分开)

Exports选项

在这里可添加相关的DLL文件,以便在SOFTICE下拦截这些DLL的函数。特别是破解VB程序时,定要将VB运行库装载进去。

Keyboard Mappings选项

这里配制各功能热键。如:F5="^x;"用F5键代替命令X.

Macro Definitions选项

宏定义,你可定制各种命令宏,以方便平时的操作。
如:s7878="S 30:0 L ffffffff '78787878' " 用命令s7878代替一串命令:S 30:0 L ffffffff '78787878'

Remote Debugging

利用网络远程调试配制。

注:以上所有配制好后的参数,都保存在winice.dat文件里。

2、winice.dat配制

在Windows 9x下 SoftICE配制除了用上面的方法外,也可通过文件winice.dat来实现的。Soft-ICE 在启动的时候通过它装入一些 DLL/EXE 的信息。
你可在SOFTICE安装目录下发现winice.dat,可用任何文本编辑软件打开它(如记事本)。如我机子里的winice.dat:(你可参考我的来修改你的winice.dat)


;注意分号后是描述语言,不被执行。
PENTIUM=ON;<=Pentium Op-Codes
NMI=ON
ECHOKEYS=OFF
NOLEDS=OFF
NOPAGE=OFF
SIWVIDRANGE=ON
THREADP=ON
LOWERCASE=OFF
WDMEXPORTS=OFF
MONITOR=0

PHYSMB=128;<=这个值是你的物理内存大小
SYM=1024
HST=256;<=历史缓冲区为256K
TRA=8
MACROS=32;<=宏操作的最大个数,此处是32个
DRAWSIZE=2048;<= 我的显卡内存是2MB ,此处值是你显卡内存大小

INIT=" wd 2;wc 20;FAULTS OFF; IXHERE OFF; IYHERE OFF; set font 2;lines 40;code on;x;";<=初始化,此处默认的是800*600分分辨率
;如你是全屏请换上:lines 57

F1="h;"
F2="^wr;"
F3="^src;"
F4="^rs;"
F5="^x;"
F6="^ec;"
F7="^here;"
F8="^t;"
F9="^bpx;"
F10="^p;"
F11="^G @SS:ESP;"
F12="^p ret;"
SF3="^format;"
CF8="^XT;"
CF9="TRACE OFF;"
CF10="^XP;"
CF11="SHOW B;"
CF12="TRACE B;"
AF1="^wr;"
AF2="^wd;"
AF3="^S 0 L FFFFFFFF 8B,CA,F3,A6,74,01,9F,92,8D,5E,08;";<=VB3特征字符串
AF4="^s 0 l ffffffff 56,57,8B,7C,24,10,8B,74,24,0C,8B,4C,24,14,33,C0,F3,66,A7;" ;<=VB4特征字符串
AF5="^s 0 l ffffffff FF,75,E0,E8,85,EF,FF,FF,DC,1D,28,10,40,00,DF,E0,9E,75,03;" ;<=VB5特征字符串
                           
AF8="^XT R;"
AF11="^dd dataaddr->0;"
AF12="^dd dataaddr->4;"
CF1="altscr off; lines 60; wc 32; wd 8;"
CF2="^wr;^wd;^wc;"

;<=以下是宏操作命令:
MACRO s7878="S 30:0 L ffffffff '78787878' "
MACRO sname="S 0 L FFFFFFFF 'toye' "
MACRO swide="s 0 l FFFFFFFF '7','8,'7','8,'7','8,'7','8,'7','8,'7','8,'7','8','7','8' "
MACRO reg="bpx regqueryvalueexa if *(esp->8)>='Soft' do "d(esp->14)" "
MACRO bpxpe="bpx loadlibrarya do "dd esp->4" "
MACRO bpxgeta="bpx GetDlgItemTextA; bpx getwindowtexta; bpx getdlgitemint; bpx getdlgitemtext;"

 

; ***** Examples of sym files that can be included if you have the SDK *****
; Change the path to the appropriate drive and directory
;LOAD=c:\windows\system\user.exe
;LOAD=c:\windows\system\gdi.exe
;LOAD=c:\windows\system\krnl386.exe
;LOAD=c:\windows\system\mmsystem.dll
;LOAD=c:\windows\system\win386.exe

; Exports - change the path to the appropriate drive and directory

EXP=c:\windows\system\advapi32.dll ;<=这四行前不要加分号,否则不被装载,SOFTICE可能什么也拦不到 :
EXP=c:\windows\system\kernel32.dll
EXP=c:\windows\system\user32.dll
exp=c:\windows\system\gdi32.dll
exp=c:\windows\system\comctl32.dll ;


; 如你要破解VB程序,下面的VB运行库将要装载,SOFTICE默认值是没有这几行,你需手动加上。

;EXP=c:\windows\system\msvbvm60.dll;<= Visual Basic 6 具体参考第十五课VB破解
EXP=c:\windows\system\msvbvm50.dll ;<= Visual Basic 5 注意在这五个DLL中最好不要同时装载2个以上
; EXP=c:\windows\system\vb40032.dll;<= Visual Basic 4(32bit)
; EXP=c:\windows\system\vb40016.dll;<=Visual Basic 4(16-bit)较少见
; EXP=c:\windows\system\vbrun300.dll;<=Visual Basic 3


;EXP=c:\windows\system\vga.drv;
;EXP=c:\windows\system\vga.3gr
;EXP=c:\windows\system\sound.drv
;EXP=c:\windows\system\mouse.drv
;EXP=c:\windows\system\netware.drv
;EXP=c:\windows\system\system.drv
;EXP=c:\windows\system\keyboard.drv
;EXP=c:\windows\system\toolhelp.dll
;EXP=c:\windows\system\shell.dll
;EXP=c:\windows\system\commdlg.dll
;EXP=c:\windows\system\olesvr.dll
;EXP=c:\windows\system\olecli.dll
;EXP=c:\windows\system\mmsystem.dll
;EXP=c:\windows\system\winoldap.mod
;EXP=c:\windows\progman.exe
;EXP=c:\windows\drwatson.exe
; ***** Examples of export symbols that can be included for Windows 95 *****
; Change the path to the appropriate drive and directory
EXP=c:\windows\system\kernel32.dll
EXP=c:\windows\system\user32.dll
EXP=c:\windows\system\gdi32.dll
EXP=c:\windows\system\comdlg32.dll
EXP=c:\windows\system\shell32.dll
EXP=c:\windows\system\advapi32.dll
EXP=c:\windows\system\shell232.dll
EXP=c:\windows\system\comctl32.dll
;EXP=c:\windows\system\crtdll.dll
;EXP=c:\windows\system\version.dll
EXP=c:\windows\system\netlib32.dll
;EXP=c:\windows\system\msshrui.dll
EXP=c:\windows\system\msnet32.dll
EXP=c:\windows\system\mspwl32.dll
;EXP=c:\windows\system\mpr.dll

 启动windows装载SOFTICE后,咦!怎么没反应,没调试画面!哈哈,别着急,按CTRL+D看看,再按一下回到windows下,或按F5也能回来。此时调试窗口象windows开的一窗口,如是象全屏DOS一样窗口,那就是安装显卡时,参数没选好,此时按上文修正即可。下面的命令是调整SOFTICE窗口状态:

  set font n(n=1,2,3)设置字体;本人建议set font 2(在800*600条件下)
  set origin x,y(x,y)锁定窗口;
  lines n n=(25-128)设置显示行数;本人建议lines 40
  Ctrl+Alt+光标键 移动窗口;
  Ctrl+Alt+home 重设窗口位置原点(0,0);
  Ctrl+L 刷新。

如你以默认winice.dat启动SOFTICE,有可能需用WD打开数据窗口;用SET FONT 2 设置字体等重复工作。你可在winice.dat文件内设置自动执行命令操作,方法是在INIT这一行,各命令用分号分开,如:

INIT=" WD 2; WC 14; FAULTS OFF; IXHERE OFF; IYHERE OFF; set font 2;lines 40;x;"这样配制后界面类似TRW2000。(这些是在800*600条件下的情况,如你不是此分辩率可调整set font n;lines n)

二、SOFTICE for Windows Millennium

 由于Windows Millennium没有了DOS平台,因此不能用常用的方法来安装SOFTICE,在此平台上可以运行SOFTICE for WIN9x版本和TRW2000版本。要实现SOFTICE在Windows Millennium平台的安装,需要工具Winice Loader,安装过程如下:

1 正常安装Windows Millennium,如在C:\WIN98ME;
2 正常安装Softice 405 Build 334;
3 复制WINICE.EXE、WINICE.DAT、SIWVID.386 三个文件到 C:\WIN98ME下;
4 从Winice Loader内解压 LOADER.EXE,复制这个文件到C:\WINME98\SYSTEM\VMM32\ 下.
5 重新启动系统。

三、SOFTICE for NT/2K安装与配制

1、SOFTICE for NT/2k的安装与for 9x版本差不多,所不同的是在第五步:装载SOFTICE方式选择,如图(图九):

你可根据需要选择不同的装载方式,注:如你选择了Manual方式,要装载SOFTICE,需要来SOFTICE的菜单里运行选项:START SOFTICE快捷方式来装载SOFTICE。

2、在NT下,配制SOFTICE是用SOFTICE Loader(从你的开始菜单选),选择Edit/SoftICE,一般的选项是初始化,这里你可参考手册了解不同的开关选项的详细描述。如:

CODE ON; FAULTS OFF; I3HERE OFF; WD 3; WF; X;

其它两个重要的选项是Symbols & Exports。如果你拥有自己系统的SDK(软件开发工具包),你可用SOFTICE装载并调试它。那些没有SDK应该用exports选项从%WINNT%/System32 目录下增加下面的DLL文件。

advapi32.dll, comctl32.dll, comdlg32.dll, gdi32.dll, kernel32.dll, msvbvm(50/60).dll (如果需要), msvcrt.dll (如果需要), ole32.dll, oleaut32.dll, shell32.dll, user32.dll, version.dll.

 

4、再下一步是鼠标的配制(图五):

现在鼠标常见的一般是串行口或ps/2接口,你跟据自己的鼠标接口类型或位置选上合适的就可。如碰到鼠标在SOFTICE调试画面不能用或一用死机,可能是没选好正确的选项,你可在SOFTICE菜单里的,运行mosue setup这个菜单项重新配制鼠标。

5、最后一步是询问以何种方式装载SOFTICE的主文件winice.exe(图六):

首先要了解SOFTICE for 9x版本是如何装载的,在SOFTICE的安装目录下有winice.exe这个文件,windows启动到纯DOS环境下,运行winice.exe这个文件,将装载SOFTICE。
安装时默认将C:\PROGRA~1\NUMEGA\SOFTIC~1\WINICE.EXE这一行放时进Autoexec.bat(自动批处理文件),这样windows以后每次都运行Autoexec.bat这个文件,自动装载SOFTICE。另外,你可根据自身需要配制启动模式,具体参考第8步。

6、然后安装程序将复制文件到硬盘里,来到最后一个对话框(图七):

最后一项是电子注册,注册成功后,以后可在线升级SOFTICE版本,这里选最后一项Regiter later.

7、至此安装完成,重新启动windows,微机先到DOS下,自动或手动运行相应批处理文件,运行其内的winice.exe文件,装载windows。

8、启动菜单配制:

通过配制启动菜单,启动时根据自己的需要选择是否装载SOFTICE。

AUTOEXEC.BAT配制样例

@ECHO OFF

goto %config%

:SICE
C:\PROGRA~1\NUMEGA\SOFTIC~1\WINICE.EXE
goto common

:NORM
goto common

:common

CONFIG.SYS配制样例:

[MENU]
MENUITEM NORM,Windows 9x
MENUITEM SICE,Windows 9x with SoftICE
MENUDEFAULT NORM,2


[NORM]

[SICE]

[common]

posted @ 2008-11-06 15:22 李帅 阅读(1944) | 评论 (0)编辑 收藏

     摘要:   阅读全文
posted @ 2008-09-23 08:20 李帅 阅读(1882) | 评论 (1)编辑 收藏

RtlInitUnicodeString ( &TcpipName, L"\\Driver\\Tcpip" );

ObReferenceObjectByName( &TcpipName,
                      OBJ_CASE_INSENSITIVE,
                      NULL,
                      0,
                      *IoDriverObjectType,
                      KernelMode,                                          
                      NULL,
                      &TcpipDrvObj);

CurrentDevice = TcpipDrvObj->DeviceObject;

while(CurrentDevice != NULL )
{
CurrentDevice->AttachedDevice=0;
CurrentDevice = CurrentDevice->NextDevice;
}

posted @ 2008-09-20 10:34 李帅 阅读(381) | 评论 (0)编辑 收藏

仅列出标题
共2页: 1 2