dbghelp

SymEnumSymbols returns ERROR_SUCCESS but gives no results

我的未来我决定 提交于 2019-12-05 11:48:21
I'm attempting to enumerate symbols from a DLL that I have loaded. For those interested, this is part of the CPPCoverage project , and for some functionality I need symbol data. Breakdown of the problem When the process is started or a DLL is loaded, symbols need to be enumerated for some of the new functionality that has been planned. Basically, a process is created, and dbghelp is used to get symbol information. Next, symbols are iterated using SymEnumSymbols . There are two moments when this happens: When the process is started ( CREATE_PROCESS_DEBUG_EVENT ) When a DLL is loaded ( LOAD_DLL

Unresolved symbol errors within DLL

徘徊边缘 提交于 2019-12-05 05:07:15
For background, I have come across this porting a medium-sized linux codebase (compiling into a giant .so) to x64 windows (compiling into a .dll). I have had linker trouble. As a minimal testcase, if I create a Visual Studio project from just the following file: #include <Windows.h> #include <Dbghelp.h> void do_stuff(char const * s) { char buffer[4096]; long int len = UnDecorateSymbolName( s, buffer, sizeof(buffer), UNDNAME_COMPLETE); } And I set the project type to DLL and build it, I get an error "LNK2001: Unresolved external symbol __imp_UnDecorateSymbolName". That is, the file compiles

Where do I find the list of unloaded modules in a Windows process?

孤者浪人 提交于 2019-12-04 06:51:23
I have some native (as in /SUBSYSTEM:NATIVE ) Windows programs that I'd like to generate minidumps for in case they crash. Normally, I'd use dbghelp.dll , but since native processes can only use functions exported from ntdll.dll , I can't. So I've implemented the dumper myself. It's almost done, but unfortunately, I've been unable to locate the list of unloaded modules in the crashed process (the list is certainly stored somewhere, since WinDbg is able to display it). Where do I find the list of unloaded modules in a Windows process? Edit: The list is certainly stored somewhere in the process

SymGetLineFromAddr not working properly

旧城冷巷雨未停 提交于 2019-11-30 23:39:38
I have the following code: #include "stdafx.h" #include <process.h> #include <iostream> #include <Windows.h> #include "dbghelp.h" using namespace std; int LogStackTrace() { void *stack[1024]; HANDLE process = GetCurrentProcess(); SymInitialize(process, NULL, TRUE); WORD numberOfFrames = CaptureStackBackTrace(0, 1000, stack, NULL); SYMBOL_INFO *symbol = (SYMBOL_INFO *)malloc(sizeof(SYMBOL_INFO)); symbol->MaxNameLen = 1024; symbol->SizeOfStruct = sizeof(SYMBOL_INFO); IMAGEHLP_LINE *line = (IMAGEHLP_LINE *)malloc(sizeof(IMAGEHLP_LINE)); line->SizeOfStruct = sizeof(IMAGEHLP_LINE); printf("Caught

How to programatically read native DLL imports in C#?

▼魔方 西西 提交于 2019-11-30 05:32:39
How can I programatically analyze a native DLL to read its imports? [EDIT: my original question looked like the following, along with a huge chunk of defective code. Please see answers below for more correct code.] The C# code located at this link is intended to print the imports of a native DLL. I find that when I run the sample code with the original example's target, MSCOREE.DLL, it prints all the imports fine. But when I use other dlls like GDI32.DLL or WSOCK32.DLL the imports do not get printed. What's missing from this code that would let it print all the imports as, for example, DUMPBIN

How to programatically read native DLL imports in C#?

一笑奈何 提交于 2019-11-29 05:38:03
问题 How can I programatically analyze a native DLL to read its imports? [EDIT: my original question looked like the following, along with a huge chunk of defective code. Please see answers below for more correct code.] The C# code located at this link is intended to print the imports of a native DLL. I find that when I run the sample code with the original example's target, MSCOREE.DLL, it prints all the imports fine. But when I use other dlls like GDI32.DLL or WSOCK32.DLL the imports do not get

Capturing R6025 pure virtual call

久未见 提交于 2019-11-28 18:52:11
I currently capture MiniDumps of unhandled exceptions using SetUnhandledExceptionFilter however at times I am getting "R6025: pure virtual function". I understand how a pure virtual function call happens I am just wondering if it is possible to capture them so I can create a MiniDump at that point. If you want to catch all crashes you have to do more than just: SetUnhandledExceptionFilter I would also set the abort handler, the purecall handler, unexpected, terminate, and invalid parameter handler. #include <signal.h> inline void signal_handler(int) { terminator(); } inline void terminator() {

Why don't Minidumps give good call stacks?

荒凉一梦 提交于 2019-11-28 17:36:49
I've used minidumps on many game projects over the years and they seem to have about a 50% chance of having a valid call stack. What can I do to make them have better call stacks? I've tried putting the latest dbghelp.dll in the exe directory. That seems to help some. Is Visual Studio 2008 or 2010 any better? (I'm still on VS 2005). The code I use looks like this sample . One thing you can do to improve the accuracy of call stacks found in dumps is to use a debugger other than Visual Studio -- specifically, use WinDbg or another tool that uses the "Windows Debugger" debugging engine found in

Listing the exported functions of a DLL

孤者浪人 提交于 2019-11-28 06:38:47
I'm looking for a way (in C++/Windows) to list the exported functions in a DLL (and maybe even methods which are not exported) using dbgHelp. Does anybody know which method can do it? thanks :) There is code here to do this. I have cleaned it up a bit and it worked in the scenario shown below, retrieving function names from Kernel32.Dll . #include "imagehlp.h" void ListDLLFunctions(string sADllName, vector<string>& slListOfDllFunctions) { DWORD *dNameRVAs(0); _IMAGE_EXPORT_DIRECTORY *ImageExportDirectory; unsigned long cDirSize; _LOADED_IMAGE LoadedImage; string sName; slListOfDllFunctions

How can you use CaptureStackBackTrace to capture the exception stack, not the calling stack?

a 夏天 提交于 2019-11-27 19:31:33
I marked up the following code: #include "stdafx.h" #include <process.h> #include <iostream> #include <Windows.h> #include "dbghelp.h" using namespace std; #define TRACE_MAX_STACK_FRAMES 1024 #define TRACE_MAX_FUNCTION_NAME_LENGTH 1024 int printStackTrace() { void *stack[TRACE_MAX_STACK_FRAMES]; HANDLE process = GetCurrentProcess(); SymInitialize(process, NULL, TRUE); WORD numberOfFrames = CaptureStackBackTrace(0, TRACE_MAX_STACK_FRAMES, stack, NULL); SYMBOL_INFO *symbol = (SYMBOL_INFO *)malloc(sizeof(SYMBOL_INFO)+(TRACE_MAX_FUNCTION_NAME_LENGTH - 1) * sizeof(TCHAR)); symbol->MaxNameLen =