windows-devel.rst
changeset 1526 1e5c611f8ab3
child 1527 2e7183c46848
equal deleted inserted replaced
1525:1bd0bcaec05f 1526:1e5c611f8ab3
       
     1 .. -*- coding: utf-8; -*-
       
     2 .. include:: HEADER.rst
       
     3 
       
     4 ============================
       
     5  Development under Windows.
       
     6 ============================
       
     7 .. contents::
       
     8 
       
     9 Dependency Walker.
       
    10 ==================
       
    11 
       
    12 Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows
       
    13 module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of
       
    14 all dependent modules. For each module found, it lists all the functions that
       
    15 are exported by that module, and which of those functions are actually being
       
    16 called by other modules. Another view displays the minimum set of required
       
    17 files, along with detailed information about each file including a full path
       
    18 to the file, base address, version numbers, machine type, debug information,
       
    19 and more.
       
    20 
       
    21 See:
       
    22 
       
    23  * http://www.dependencywalker.com/
       
    24 
       
    25 Windows 2000 Resource Kit Tools.
       
    26 ================================
       
    27 
       
    28   http://support.microsoft.com/kb/927229
       
    29                 Windows 2000 Resource Kit Tools for administrative tasks
       
    30 
       
    31 Sysinternals.
       
    32 =============
       
    33 
       
    34 TODO
       
    35 
       
    36 Application verifier.
       
    37 =====================
       
    38 
       
    39   http://www.microsoft.com/downloads/en/details.aspx?familyid=c4a25ab9-649d-4a1b-b4a7-c9d8b095df18
       
    40                 download page
       
    41   http://msdn.microsoft.com/en-us/library/ms220948.aspx
       
    42                 Application Verifier
       
    43 
       
    44 Debugging with windbg.
       
    45 ======================
       
    46 
       
    47   http://www.microsoft.com/whdc/devtools/debugging/default.mspx
       
    48                 Download and Install Debugging Tools for Windows
       
    49   http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx
       
    50                 Debugging Tools for Windows 32-bit Version
       
    51                 download page
       
    52   http://www.microsoft.com/whdc/devtools/debugging/install64bit.mspx
       
    53                 Debugging Tools for Windows 64-bit Version
       
    54                 download page
       
    55 
       
    56 Break on dll load/unload.
       
    57 =========================
       
    58 ::
       
    59 
       
    60   sxe ld <module>
       
    61   sxe ud <module>
       
    62 
       
    63 Set breakpoint by pattern and/or on specific module.
       
    64 ====================================================
       
    65 ::
       
    66 
       
    67   bm <module>!<name>    # set breakpoints on 'module' with name 'name'
       
    68   bm *!<prefix>*        # set breakpoints on all names with prefix 'prefix'
       
    69   bm <module>!*         # set breakpoints on all names in module 'module'
       
    70 
       
    71 ``bp``, ``bm`` commands sets software breakpoints, debugger replaces the processor
       
    72 instruction with a break instruction.
       
    73 
       
    74 Clear breakpoints.
       
    75 ==================
       
    76 ::
       
    77 
       
    78   bc *
       
    79 
       
    80 How to set WinDbg as a Default Windows Postmortem Debugger.
       
    81 ===========================================================
       
    82 ::
       
    83 
       
    84   cmd> WinDbg -I
       
    85 
       
    86 How analyse crash.
       
    87 ==================
       
    88 
       
    89 When program crash and use enter in WinDbg execute::
       
    90 
       
    91   !analyze -v
       
    92 
       
    93 Adding symbols from Symbol Server.
       
    94 ==================================
       
    95 
       
    96 Execute in WinDbg::
       
    97 
       
    98   .sympath SRV*D:\srv\symcache*http://msdl.microsoft.com/download/symbols
       
    99 
       
   100 or Ctrl+S and add::
       
   101 
       
   102   SRV*D:\srv\symcache*http://msdl.microsoft.com/download/symbols
       
   103 
       
   104 See:
       
   105 
       
   106   http://support.microsoft.com/kb/311503
       
   107                 Use the Microsoft Symbol Server to obtain debug symbol files
       
   108 
       
   109 Using the SymChk.exe utility to download symbols.
       
   110 =================================================
       
   111 ::
       
   112 
       
   113   symchk /r c:\windows\system32 /s SRV*c:\symbols\*http://msdl.microsoft.com/download/symbols
       
   114 
       
   115 Debugging child process.
       
   116 ========================
       
   117 ::
       
   118 
       
   119   .childdbg 1
       
   120 
       
   121 Running at startup.
       
   122 ===================
       
   123 
       
   124   HKCU\Software\Microsoft\Windows\CurrentVersion\Run
       
   125                 Launches a program automatically when a particular user logs
       
   126                 in. This key is used when you always want to launch a program
       
   127                 when a particular user is using a system.
       
   128   HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce
       
   129                 Launches a program the next time the user logs in and removes
       
   130                 its value entry from the registry. This key is typically used
       
   131                 by installation programs.
       
   132   HKLM\Software\Microsoft\Windows\CurrentVersion\Run
       
   133                 Launches a program automatically at system startup. This key
       
   134                 is used when you always want to launch a program on a
       
   135                 particular system.
       
   136   HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
       
   137                 Launches a program the next time the system starts and removes
       
   138                 its value entry from the registry. This key is typically used
       
   139                 by installation programs.
       
   140   HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices
       
   141                 Launches a service (a standard NT service or a background
       
   142                 process) automatically at startup. An example of a service is
       
   143                 a Web server such as Microsoft Internet Information Server.
       
   144   HKLM\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
       
   145                 Launches a service (a standard NT service or a background
       
   146                 process) the next time the system is started, then removes its
       
   147                 value entry from the registry.
       
   148 
       
   149 Values to registry on Windows XP can be added by::
       
   150 
       
   151   cmd> reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v run.bat /t REG_SZ /d "path\to\run.bat"
       
   152   cmd> reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run   <-- see what done
       
   153 
       
   154 Cabinet file (.cab).
       
   155 ====================
       
   156 
       
   157 Extract content from .cab file::
       
   158 
       
   159   cmd# expand my.cab
       
   160 
       
   161 See:
       
   162 
       
   163   http://support.microsoft.com/kb/198038
       
   164                 INFO: Useful Tools for Package and Deployment Issues
       
   165   http://msdn.microsoft.com/en-us/library/aa367841%28VS.85%29.aspx
       
   166                 The Makecab.exe utility is included in the Windows SDK
       
   167                 Components for Windows Installer Developers.
       
   168   http://web.archive.org/web/20070403215326/http://download.microsoft.com/download/platformsdk/cab/2.0/w98nt42kmexp/en-us/cabsdk.exe
       
   169                 download link from web archive
       
   170   http://msdn.microsoft.com/en-us/library/aa370834%28v=VS.85%29.aspx
       
   171                 The components of the Windows Installer Software Development
       
   172                 Kit are included in the Microsoft Windows Software Development
       
   173                 Kit (SDK).
       
   174   http://msdn.microsoft.com/en-us/library/bb417343.aspx
       
   175                 Microsoft Cabinet Format
       
   176 
       
   177 Internet Explorer.
       
   178 ==================
       
   179 
       
   180 Debugging IE.
       
   181 -------------
       
   182 
       
   183 Install IE 8.0 and press 'F12' key.
       
   184 
       
   185   http://msdn.microsoft.com/library/dd565626.aspx
       
   186                 Developer Tools User Interface Reference
       
   187 
       
   188 Microsoft technologies.
       
   189 =======================
       
   190 
       
   191 COM.
       
   192 ----
       
   193 
       
   194 The family of COM technologies includes COM+, Distributed COM (DCOM) and
       
   195 ActiveX® Controls.
       
   196 
       
   197   http://www.microsoft.com/com/default.mspx
       
   198                 home page
       
   199 
       
   200 OLE.
       
   201 ----
       
   202 
       
   203 OLE (Object Linking and Embedding) allows embedding and linking to documents and
       
   204 other objects.
       
   205 
       
   206 OLE 1.0 released in 1990, OLE 2.0 released in 1993, in 1994 OLE custom controls
       
   207 (OCXs) were introduced.
       
   208 
       
   209 OLE objects and containers are implemented on top of the Component Object Model.
       
   210 
       
   211 Next release after 2.0 introdused in 1996 and named as ActiveX.
       
   212 
       
   213  * http://en.wikipedia.org/wiki/Object_Linking_and_Embedding
       
   214 
       
   215 ActiveX.
       
   216 --------
       
   217 
       
   218 Faced with the complexity of OLE 2.0 and with poor support for COM in MFC,
       
   219 Microsoft rationalized the specifications to make them simpler, and rebranded
       
   220 the technology as ActiveX in 1996.
       
   221 
       
   222   http://msdn.microsoft.com/en-us/library/aa751968.aspx
       
   223                 ActiveX Controls.
       
   224   http://en.wikipedia.org/wiki/ActiveX
       
   225                 Wikipedia article.
       
   226 
       
   227 ATL.
       
   228 ----
       
   229 
       
   230 The Active Template Library (ATL) is a set of template-based C++ classes
       
   231 developed by Microsoft, intended to simplify the programming of Component Object
       
   232 Model (COM) objects.
       
   233 
       
   234   http://en.wikipedia.org/wiki/Active_Template_Library
       
   235 
       
   236 MFC.
       
   237 ----
       
   238 
       
   239 MFC (Microsoft Foundation Classes) is a library that wraps portions of the
       
   240 Windows API in C++ classes, including functionality that enables them to use a
       
   241 default application framework. Classes are defined for many of the
       
   242 handle-managed Windows objects and also for predefined windows and common
       
   243 controls.
       
   244 
       
   245 A lightweight alternative to MFC is the Windows Template Library (WTL).
       
   246 
       
   247  * http://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library
       
   248  * http://ru.wikipedia.org/wiki/Microsoft_Foundation_Classes
       
   249 
       
   250 Can I link to MFC statically.
       
   251 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   252 
       
   253 Yes, see:
       
   254 
       
   255  * http://msdn.microsoft.com/en-us/library/f22wcbea%28VS.80%29.aspx
       
   256 
       
   257 Microsoft Visual C++ Redistributable Package.
       
   258 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   259 
       
   260   http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=32bc1bee-a3f9-4c13-9c99-220b62a191ee&displayLang=en
       
   261                 This package installs runtime components of C Runtime (CRT),
       
   262                 Standard C++, ATL, MFC, OpenMP and MSDIA libraries.
       
   263 
       
   264 WTL.
       
   265 ====
       
   266 
       
   267 WTL (Windows Template Library) is a free software, object-oriented C++ template
       
   268 library for Win32 development.
       
   269 
       
   270 WTL provides support for implementing various user interface elements, to MDI,
       
   271 standard and common controls, common dialogs, property sheets and pages, GDI
       
   272 objects, and other common UI elements, such as scrollable windows, splitter
       
   273 windows, toolbars and command bars.
       
   274 
       
   275 Most of the WTL API is a mirror of the standard Win32 calls.
       
   276 
       
   277  * http://sourceforge.net/projects/wtl
       
   278  * http://en.wikipedia.org/wiki/Windows_Template_Library
       
   279 
       
   280 Windows style variable names.
       
   281 =============================
       
   282 ::
       
   283 
       
   284   Prefix   |  Data type
       
   285   ---------+-----------------------------------------
       
   286   b        |  boolean
       
   287   by       |  byte or unsigned char
       
   288   c        |  char
       
   289   cx / cy  |  short used as size
       
   290   dw       |  DWORD, double word or unsigned long
       
   291   fn       |  function
       
   292   h        |  handle
       
   293   i        |  int (integer)
       
   294   l        |  Long
       
   295   n        |  short int
       
   296   p        |  a pointer variable containing the address of a variable
       
   297   s        |  string
       
   298   sz       |  ASCIIZ null-terminated string
       
   299   w        |  WORD unsigned int
       
   300   x, y     |  short used as coordinates
       
   301 
       
   302 ::
       
   303 
       
   304   PrefixCategory  | Mean
       
   305   ----------------+----------------
       
   306   CS              | Class style
       
   307   CW              | Create window
       
   308   DT              | Draw text
       
   309   IDC             | Cursor ID
       
   310   IDI             | Icon ID
       
   311   WM              | Window message
       
   312   WS              | Window style
       
   313 
       
   314 ::
       
   315 
       
   316   Data type | Meaning
       
   317   ----------+-------------------------------------------------------------------
       
   318   FAR       | Same as far. Identifies an address that originally used the
       
   319             | segment:offset addressing schema. Now FAR simply identifies a
       
   320             | (default) 32-bit address but may be omitted entirely in many cases.
       
   321             |
       
   322   PASCAL    | Same as Pascal. The Pascal convention demanded by Windows
       
   323             | defines the order in which arguments are found in the stack when
       
   324             | passed as calling parameters.
       
   325             |
       
   326   WORD	    | Unsigned integer (16 bits)
       
   327             |
       
   328   UINT      | Unsigned integer, same as WORD
       
   329             |
       
   330   DWORD     | Double word, unsigned long int (32 bits)
       
   331             |
       
   332   LONG      | Signed long integer (32 bits)
       
   333             |
       
   334   LPSTR     | Long (far) pointer to character string
       
   335             |
       
   336   NEAR      | Obsolete, previously identified an address value within a 16KB
       
   337             | memory block.
       
   338 
       
   339 See:
       
   340 
       
   341   http://www.tenouk.com/cnotation.html
       
   342                 C/C++ NOTATION STORY