置顶随笔 #
2006年9月24日 #
http://f4l.sourceforge.net/
顺便COPY段代码先扔这里:
--- d:\vsprojects\vcpros\consolepros\vckbase1\first.cpp -------------------
1: #include <stdio.h>
2:
3: int main(int argc, char** argv, char** envp)
4: {
00401010 push ebp ;save ebp(cpu->内存)
00401011 mov ebp,esp ;set stack frame pointer
00401013 sub esp,40h ;allocate space for locals
00401016 push ebx ;save registers-------下面内容均如此
00401017 push esi
00401018 push edi
00401019 lea edi,[ebp-40h]
0040101C mov ecx,10h
00401021 mov eax,0CCCCCCCCh
00401026 rep stos dword ptr [edi]
5: return 0;
00401028 xor eax,eax
6: }
0040102A pop edi
0040102B pop esi
0040102C pop ebx ;restore registers
0040102D mov esp,ebp ;restore stack pointer
0040102F pop ebp ;restore ebp
00401030 ret ;return from function
--- No source file --------------------------------------------------------
argc = 1 ;因为在VC中要读取你的*argv指向的应用程序名字(*.exe)
* argv = D:\VSPROJECTS\VCPROS\CONSOLEPROS\vckbase1\Debug\vckbase1.exe
* envp = ALLUSERSPROFILE=C:\Documents and Settings\All Users
=============================================================
Considerations when Writing Prolog/Epilog Code
Microsoft Specific —>
Before writing your own prolog and epilog code sequences, it is important to understand how the stack frame is laid out. It is also useful to know how to use the __LOCAL_SIZE predefined constant.
C Stack Frame Layout
This example shows the standard prolog code that might appear in a 32-bit function:
push ebp ; Save ebp
mov ebp, esp ; Set stack frame pointer
sub esp, localbytes ; Allocate space for locals
push <registers> ; Save registers
The localbytes variable represents the number of bytes needed on the stack for local variables, and the registers variable is a placeholder that represents the list of registers to be saved on the stack. After pushing the registers, you can place any other appropriate data on the stack. The following is the corresponding epilog code:
pop <registers> ; Restore registers
mov esp, ebp ; Restore stack pointer
pop ebp ; Restore ebp
ret ; Return from function
The stack always grows down (from high to low memory addresses). The base pointer (ebp) points to the pushed value of ebp. The local variables area begins at ebp-2. To access local variables, calculate an offset from ebp by subtracting the appropriate value from ebp.
The __LOCAL_SIZE Constant
The compiler provides a constant, __LOCAL_SIZE, for use in the inline assembler block of function prolog code. This constant is used to allocate space for local variables on the stack frame in custom prolog code.
The compiler determines the value of __LOCAL_SIZE. The value is the total number of bytes of all user-defined local variables and compiler-generated temporary variables. __LOCAL_SIZE can be used only as an immediate operand; it cannot be used in an expression. You must not change or redefine the value of this constant. For example:
mov eax, __LOCAL_SIZE ;Immediate operand--Okay
mov eax, [ebp - __LOCAL_SIZE] ;Error
The following example of a naked function containing custom prolog and epilog sequences uses __LOCAL_SIZE in the prolog sequence:
__declspec ( naked ) func()
{
int i;
int j;
__asm /* prolog */
{
push ebp
mov ebp, esp
sub esp, __LOCAL_SIZE
}
/* Function body */
__asm /* epilog */
{
mov esp, ebp
pop ebp
ret
}
}
END Microsoft Specific
2006年8月18日 #
The Code Project is constantly growing, with hundreds of new articles added monthly and more sections created to house them. Below is a quick guide to help you find the sections that most interest you.
| Desktop Development | Total: 3,332 articles |
|
|
|
|
|
| Web Development | Total: 4,051 articles |
|
|
|
|
|
| Enterprise Systems | Total: 371 articles |
|
|
|
|
|
| Multimedia | Total: 985 articles |
|
|
|
|
|
| Database | Total: 1,027 articles |
|
|
|
|
|
| Platforms, Frameworks & Libraries | Total: 3,041 articles |
|
|
|
|
|
| Languages | Total: 4,898 articles |
|
|
|
|
|
| General Programming | Total: 2,762 articles |
|
|
|
|
|
| Graphics / Design | Total: 53 articles |
|
|
|
|
|
| Development Lifecycle | Total: 821 articles |
|
|
|
|
|
| General Reading | Total: 671 articles |
|
|
|
|
|
| Third Party Products | Total: 253 articles |
|
|
|
|
|
The Microsoft Foundation Class Library can be divided into two major sections: (1) the MFC classes and (2) macros and globals. If a function or variable is not a member of a class, it is a global function or variable.
The MFC library and the Active Template Library (ATL) share string conversion macros. See String Conversion Macros in the ATL documentation for a discussion of these macros.
The MFC macros and globals offer functionality in the following categories:
General MFC
- Data types
- Type casting of MFC class objects
- Run-time object model services
- Diagnostic services
- Exception processing
- CString formatting and message-box display
- Message maps
- Application information and management
- Standard command and window IDs
- Collection class helpers
- Gray and dithered bitmap functions
Database
- Record Field Exchange (RFX) functions and Bulk Record Field Exchange (bulk RFX) functions for the MFC ODBC classes
- Record field exchange (DFX) functions for the MFC DAO classes
- Dialog data exchange (DDX) functions for CRecordView and CDaoRecordView (MFC ODBC and DAO classes)
- Dialog data exchange (DDX) functions for OLE controls
- Macros and globals to aid in calling Open Database Connectivity (ODBC) API functions directly
- DAO database engine initialization and termination
Internet
- Internet Server API (ISAPI) parse maps
- Internet URL parsing globals
- Internet Server API (ISAPI) diagnostic macros
DHTML Event Maps
OLE
In addition, MFC provides a function called AfxEnableControlContainer that enables any OLE container developed with MFC 4.0 to fully support embedded OLE controls.
OLE Controls
- Variant parameter type constants
- Type library access
- Property pages
- Event maps
- Event sink maps
- Connection maps
- Registering OLE controls
- Class factories and licensing
- Persistence of OLE controls
The first part of this section briefly discusses each of the previous categories and lists each global and macro in the category, along with a brief description of what it does. Following this alphabetically are complete descriptions of the global functions, global variables, and macros in the MFC library.
To find more information on MFC Macros and Globals, see MFC Macros and Globals.
Note Many global functions start with the prefix "Afx", but some, such as the dialog data exchange (DDX) functions and many of the database functions, deviate from this convention. All global variables start with "afx" as a prefix. Macros do not start with any particular prefix, but they are written in uppercase letters.
2006年7月27日 #
(1)袁峰
精: 很多东西都有更好的方法, 不要满足于做出来而已
深: 看看 David Solomon, Jeffrey Richter, John Robbins, 和我的书,再和 Charles Petzold 的书比
比你就知道深浅之别
迁: 找高人所在
著: 写东西是很好的学习
器: 写工具程序, 见 www.sysinternals.com
(2)各种操作系统平台开发GUI程序使用的库的介绍
High-level widget toolkits:
*On Macintosh:
**Cocoa - used in Mac OS X (see also Aqua)
**MacApp Macintosh framework
**MacZoop Macintosh C++ framework
**Powerplant Macintosh framework
*On Microsoft Windows:
**The Microsoft Foundation Classes (MFC), used by Microsoft for its own programs (e.g. Microsoft Office) and by most developers on the Microsoft Windows platform
**The Object Windows Library is sort of Borland's alternative to MFC
**The Visual Component Library (VCL) is Borland's toolkit used in its C++ Builder and Delphi products
**The Windows Forms is .NET's set of classes that handle GUI controls
*On Unix, under the X Window System:
**Xaw, the Project Athena widget set for the X Window System
**Motif used in the Common Desktop Environment
**Lesstif, an open source (LGPL) version of Motif
*Cross-platform, based on SVG:
**airWRX is an application framework that runs from a USB flash drive, and turns its PC host and other nearby PCs into a multi-screen, web-like work environment.
*Cross-platform, based on the Java programming language:
**The Abstract Windowing Toolkit is used in Java applications. It typically uses another toolkit on the selected platform in turn.
**Swing is Sun Microsystems's replacement for AWT in newer Java versions.
**The Standard Widget Toolkit is a native widget toolkit for Java that was invented as part of the Eclipse project. SWT will use the running platforms widget toolkit (such as Windows API or GTK+) underneath.
(Eclipse开发工具有很多的插件可以使用,用于C++开发的插件有CDT等,还有用于FLASH ACTIONSCRIPT开发的插件<这个要负费的>)
Cross-platform, based on the programming languages C or C++, often with bindings to other languages:
**Tk, a widget set accessed from Tcl and other high-level script languages.
**GTK+, open source (LGPL), primarily for the X Window System, ported to and emulated under other platforms; used in the GNOME desktop environment
(GNOME平台使用GTK+)
**Qt, open source (GPL) available under Unix/Linux (with X Window), MS Windows, Mac OS X and embedded systems; also available in commercial versions under these platforms; used in KDE
(KDE平台使用QT图形库)
**wxWidgets (formerly wxWindows), open source (relaxed LGPL), abstracts toolkits across several platforms for C++, Python and Perl
(C++,Python和Perl等都可以使用wxWidgets库进行开发)
**FOX toolkit, open source (LGPL), genuinely cross-platform
**FLTK, open source (LGPL), cross-platform toolkit designed to be small and fast
2006年6月10日 #
2006年3月25日 #
#include <iostream>
using namespace std;
template <size_t n> void foo( void )
{
cout << n << endl;
};
void bar1( void )
{
foo<1>();
}
void bar2( void )
{
foo<2>();
}
int main(int argc, char* argv[])
{
bar1();
bar2();
return 0;
}
// 期待输出 1 2
// 实际输出 2 2
==========================
VC的开发工程师可能以为所有的人都会这么用:
#include <iostream>
using namespace std;
template <class T>
T foo( size_t n)
{
cout << n << endl;
return 0;
};
void bar1( void )
{
foo<size_t>(1);
}
void bar2( void )
{
foo<size_t>(2);
}
int main(int argc, char* argv[])
{
bar1();
bar2();
return 0;
}
2006年3月21日 #
2006年3月17日 #
2006年3月2日 #
2006年2月26日 #
2006年2月25日 #
2006年2月24日 #
2006年1月15日 #
2005年12月17日 #
2005年12月15日 #
2005年12月14日 #
2005年8月11日 #