- Code/Resource
- Windows Develop
- Linux-Unix program
- Internet-Socket-Network
- Web Server
- Browser Client
- Ftp Server
- Ftp Client
- Browser Plugins
- Proxy Server
- Email Server
- Email Client
- WEB Mail
- Firewall-Security
- Telnet Server
- Telnet Client
- ICQ-IM-Chat
- Search Engine
- Sniffer Package capture
- Remote Control
- xml-soap-webservice
- P2P
- WEB(ASP,PHP,...)
- TCP/IP Stack
- SNMP
- Grid Computing
- SilverLight
- DNS
- Cluster Service
- Network Security
- Communication-Mobile
- Game Program
- Editor
- Multimedia program
- Graph program
- Compiler program
- Compress-Decompress algrithms
- Crypt_Decrypt algrithms
- Mathimatics-Numerical algorithms
- MultiLanguage
- Disk/Storage
- Java Develop
- assembly language
- Applications
- Other systems
- Database system
- Embeded-SCM Develop
- FlashMX/Flex
- source in ebook
- Delphi VCL
- OS Develop
- MiddleWare
- MPI
- MacOS develop
- LabView
- ELanguage
- Software/Tools
- E-Books
- Artical/Document
MODULE.C
Package: MSDN_VC98.zip [view]
Upload User: bangxh
Upload Date: 2007-01-31
Package Size: 42235k
Code Size: 3k
Category:
Windows Develop
Development Platform:
Visual C++
- /*++
- Copyright (c) 1993 Microsoft Corporation
- Module Name:
- module.c
- Abstract:
- This file implements the module load debug events.
- Author:
- Wesley Witt (wesw) 1-May-1993
- Environment:
- User Mode
- --*/
- #include <windows.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include "drwatson.h"
- #include "proto.h"
- #include "messages.h"
- //
- // defines for symbol (.dbg) file searching
- //
- #define SYMBOL_PATH "_NT_SYMBOL_PATH"
- #define ALTERNATE_SYMBOL_PATH "_NT_ALT_SYMBOL_PATH"
- char szApp[MAX_PATH];
- //
- // local prototypes
- //
- LPSTR GetSymbolSearchPath( void );
- BOOL
- ProcessModuleLoad ( PDEBUGPACKET dp, LPDEBUG_EVENT de )
- /*++
- Routine Description:
- Process all module load debug events, create process & dll load.
- The purpose is to allocate a MODULEINFO structure, fill in the
- necessary values, and load the symbol table.
- Arguments:
- dp - pointer to a debug packet
- de - pointer to a debug event structure
- Return Value:
- TRUE - everything worked
- FALSE - we're hosed
- --*/
- {
- HANDLE hFile;
- DWORD dwBaseOfImage;
- LPSTR SymbolPath;
- if (de->dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT) {
- hFile = de->u.CreateProcessInfo.hFile;
- dwBaseOfImage = (DWORD)de->u.CreateProcessInfo.lpBaseOfImage;
- dp->hProcess = de->u.CreateProcessInfo.hProcess;
- dp->dwProcessId = de->dwProcessId;
- SymInitialize( dp->hProcess, NULL, FALSE );
- SymbolPath = GetSymbolSearchPath();
- SymSetSearchPath( dp->hProcess, SymbolPath );
- free( SymbolPath );
- } else if (de->dwDebugEventCode == LOAD_DLL_DEBUG_EVENT) {
- hFile = de->u.LoadDll.hFile;
- dwBaseOfImage = (DWORD)de->u.LoadDll.lpBaseOfDll;
- }
- if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) {
- return FALSE;
- }
- if (!SymLoadModule( dp->hProcess, hFile, NULL, NULL, dwBaseOfImage, 0 )) {
- return FALSE;
- } else {
- if (de->dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT) {
- IMAGEHLP_MODULE mi;
- if (SymGetModuleInfo( dp->hProcess, dwBaseOfImage, &mi )) {
- strcpy( szApp, mi.ImageName );
- }
- }
- }
- return TRUE;
- }
- LPSTR
- GetSymbolSearchPath( void )
- /*++
- Routine Description:
- Gets the search path to be used for locating a .DBG file.
- Arguments:
- None.
- Return Value:
- pointer to the path string
- --*/
- {
- LPSTR lpSymPathEnv = NULL;
- LPSTR lpAltSymPathEnv = NULL;
- LPSTR lpSystemRootEnv = NULL;
- LPSTR SymbolSearchPath = NULL;
- DWORD cbSymPath = 0;
- cbSymPath = 16;
- if (lpSymPathEnv = getenv(SYMBOL_PATH)) {
- cbSymPath += strlen(lpSymPathEnv) + 1;
- }
- if (lpAltSymPathEnv = getenv(ALTERNATE_SYMBOL_PATH)) {
- cbSymPath += strlen(lpAltSymPathEnv) + 1;
- }
- if (lpSystemRootEnv = getenv("SystemRoot")) {
- cbSymPath += strlen(lpSystemRootEnv) + 1;
- }
- SymbolSearchPath = calloc(cbSymPath,1);
- if (lpAltSymPathEnv) {
- strcat(SymbolSearchPath,lpAltSymPathEnv);
- strcat(SymbolSearchPath,";");
- }
- if (lpSymPathEnv) {
- strcat(SymbolSearchPath,lpSymPathEnv);
- strcat(SymbolSearchPath,";");
- }
- if (lpSystemRootEnv) {
- strcat(SymbolSearchPath,lpSystemRootEnv);
- strcat(SymbolSearchPath,";");
- }
- return SymbolSearchPath;
- }