win32: add debug information to the function diversion code.

This commit is contained in:
Sam Hocevar
2012-06-11 17:05:19 +00:00
committed by sam
parent df2dfb9ffa
commit f6f9cad61f
5 changed files with 22 additions and 7 deletions
+3 -3
View File
@@ -63,7 +63,7 @@
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>ws2_32.lib;..\..\libcaca\win32\Debug\Win32\libcaca.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)zzat.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)zzat.pdb</ProgramDatabaseFile>
@@ -83,7 +83,7 @@
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>ws2_32.lib;..\..\libcaca\win32\Release\Win32\libcaca.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)zzat.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
@@ -104,4 +104,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+3 -3
View File
@@ -63,7 +63,7 @@
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>ws2_32.lib;..\..\libcaca\win32\Debug\Win32\libcaca.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)zzuf.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)zzuf.pdb</ProgramDatabaseFile>
@@ -83,7 +83,7 @@
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>ws2_32.lib;..\..\libcaca\win32\Release\Win32\libcaca.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)zzuf.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
@@ -118,4 +118,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+1 -1
View File
@@ -44,7 +44,7 @@ static HANDLE (__stdcall *ORIG(CreateFileA))(LPCTSTR, DWORD, DWORD,
LPSECURITY_ATTRIBUTES,
DWORD, DWORD, HANDLE);
#endif
#if defined HAVE_CREATEFILEA
#if defined HAVE_CREATEFILEW
static HANDLE (__stdcall *ORIG(CreateFileW))(LPCWSTR, DWORD, DWORD,
LPSECURITY_ATTRIBUTES,
DWORD, DWORD, HANDLE);
+5
View File
@@ -77,6 +77,7 @@ void _zz_sys_init(void)
void *list;
int k;
/* Enumerate all loaded objects and overwrite some functions */
VirtualQuery(_zz_sys_init, &mbi, sizeof(mbi));
list = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
entry.dwSize = sizeof(entry);
@@ -85,6 +86,7 @@ void _zz_sys_init(void)
if(entry.hModule == mbi.AllocationBase)
continue; /* Don't replace our own functions */
fprintf(stderr, "diverting functions from %s\n", entry.szModule);
insert_funcs(entry.hModule);
}
CloseHandle(list);
@@ -140,6 +142,9 @@ static void insert_funcs(void *module)
continue;
}
fprintf(stderr, "diverting method %s (from %s)\n",
diversion->name, diversion->lib);
lib = GetModuleHandleA(diversion->lib);
*diversion->old = (void *)GetProcAddress(lib, diversion->name);
+10
View File
@@ -300,7 +300,17 @@ static int run_process(struct child *child, struct opts *opts, int pipes[][2])
free(cmdline);
if (!ret)
{
LPTSTR buf;
DWORD err = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err, 0, (LPTSTR)&buf, 0, NULL);
fprintf(stderr, "error launching `%s': %s\n", child->newargv[0], buf);
LocalFree(buf);
return -1;
}
/* Insert the replacement code */
ret = dll_inject(&pinfo, SONAME);