added quick tool for fetching dlls of mdmps
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402177
This commit is contained in:
parent
e794883b1f
commit
b2d25f2a77
20
tools/fetchdlls/fetchdlls.sln
Normal file
20
tools/fetchdlls/fetchdlls.sln
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fetchdlls", "fetchdlls.vcproj", "{3C1C562B-1080-445F-A632-EA9EC9793389}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3C1C562B-1080-445F-A632-EA9EC9793389}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3C1C562B-1080-445F-A632-EA9EC9793389}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3C1C562B-1080-445F-A632-EA9EC9793389}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3C1C562B-1080-445F-A632-EA9EC9793389}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
196
tools/fetchdlls/fetchdlls.vcproj
Normal file
196
tools/fetchdlls/fetchdlls.vcproj
Normal file
@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="fetchdlls"
|
||||
ProjectGUID="{3C1C562B-1080-445F-A632-EA9EC9793389}"
|
||||
RootNamespace="fetchdlls"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfATL="0"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="dbghelp.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="dbghelp.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
192
tools/fetchdlls/main.cpp
Normal file
192
tools/fetchdlls/main.cpp
Normal file
@ -0,0 +1,192 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <DbgHelp.h>
|
||||
|
||||
void mdmp_string(void *mdmp, RVA addr, char *buffer, size_t maxlength)
|
||||
{
|
||||
int len;
|
||||
MINIDUMP_STRING *str;
|
||||
|
||||
str = (MINIDUMP_STRING *)((char *)mdmp + addr);
|
||||
len = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
str->Buffer,
|
||||
str->Length / sizeof(WCHAR),
|
||||
buffer,
|
||||
maxlength,
|
||||
NULL,
|
||||
NULL);
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
int find_revision(const char *version, MINIDUMP_MODULE *module, const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
char msg[255];
|
||||
size_t i, len;
|
||||
char path[255];
|
||||
char buffer[3000];
|
||||
int last_revision;
|
||||
|
||||
len = _snprintf(path, sizeof(path), "%s", name);
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (path[i] == '\\')
|
||||
{
|
||||
path[i] = '/';
|
||||
}
|
||||
}
|
||||
|
||||
DeleteFile("_svnlog.txt");
|
||||
_snprintf(buffer,
|
||||
sizeof(buffer),
|
||||
"svn log svn://svn.alliedmods.net/svnroot/Packages/sourcemod/sourcemod-%d.%d/windows/base/addons/sourcemod/%s > _svnlog.txt",
|
||||
(module->VersionInfo.dwFileVersionMS >> 16),
|
||||
(module->VersionInfo.dwFileVersionMS & 0xFFFF),
|
||||
path);
|
||||
system(buffer);
|
||||
|
||||
if ((fp = fopen("_svnlog.txt", "rt")) == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
_snprintf(msg,
|
||||
sizeof(msg),
|
||||
"sourcemod-%s",
|
||||
version);
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||
{
|
||||
if (buffer[0] == 'r')
|
||||
{
|
||||
last_revision = atoi(&buffer[1]);
|
||||
}
|
||||
else if (strstr(buffer, msg) != NULL)
|
||||
{
|
||||
fclose(fp);
|
||||
|
||||
_snprintf(buffer,
|
||||
sizeof(buffer),
|
||||
"svn export -q -r %d svn://svn.alliedmods.net/svnroot/Packages/sourcemod/sourcemod-%d.%d/windows/base/addons/sourcemod/%s",
|
||||
last_revision,
|
||||
(module->VersionInfo.dwFileVersionMS >> 16),
|
||||
(module->VersionInfo.dwFileVersionMS & 0xFFFF),
|
||||
path);
|
||||
system(buffer);
|
||||
|
||||
return last_revision;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rev;
|
||||
ULONG32 m;
|
||||
LPVOID mdmp;
|
||||
HANDLE hFile;
|
||||
const char *name;
|
||||
ULONG stream_size;
|
||||
char name_buf[255];
|
||||
HANDLE hFileMapping;
|
||||
MINIDUMP_MODULE *module;
|
||||
MINIDUMP_DIRECTORY *dir;
|
||||
MINIDUMP_MODULE_LIST *modules;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
fprintf(stderr, "Usage: <build> <mdmp>\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ((hFile = CreateFile(argv[2],
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL))
|
||||
== INVALID_HANDLE_VALUE)
|
||||
{
|
||||
fprintf(stderr, "Could not open file (error %d)\n", GetLastError());
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
hFileMapping = CreateFileMapping(
|
||||
hFile,
|
||||
NULL,
|
||||
PAGE_READONLY,
|
||||
0,
|
||||
0,
|
||||
NULL);
|
||||
if (hFileMapping == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not open file mapping (error %d)\n", GetLastError());
|
||||
CloseHandle(hFile);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
mdmp = MapViewOfFile(hFileMapping,
|
||||
FILE_MAP_READ,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
if (mdmp == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not create map view (error %d)\n", GetLastError());
|
||||
CloseHandle(hFileMapping);
|
||||
CloseHandle(hFile);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!MiniDumpReadDumpStream(mdmp,
|
||||
ModuleListStream,
|
||||
&dir,
|
||||
(void **)&modules,
|
||||
&stream_size))
|
||||
{
|
||||
fprintf(stderr, "Could not read the module list stream.\n");
|
||||
UnmapViewOfFile(mdmp);
|
||||
CloseHandle(hFileMapping);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
for (m = 0; m < modules->NumberOfModules; m++)
|
||||
{
|
||||
module = &modules->Modules[m];
|
||||
|
||||
mdmp_string(mdmp, module->ModuleNameRva, name_buf, sizeof(name_buf));
|
||||
|
||||
if ((name = strstr(name_buf, "sourcemod\\")) != NULL)
|
||||
{
|
||||
name += 10;
|
||||
fprintf(stdout,
|
||||
"looking for: %s (%d.%d.%d.%d of build %s)... ",
|
||||
name,
|
||||
(module->VersionInfo.dwFileVersionMS >> 16),
|
||||
(module->VersionInfo.dwFileVersionMS & 0xFFFF),
|
||||
(module->VersionInfo.dwFileVersionLS >> 16),
|
||||
(module->VersionInfo.dwFileVersionLS & 0xFFFF),
|
||||
argv[1]
|
||||
);
|
||||
fflush(stdout);
|
||||
if ((rev = find_revision(argv[1], module, name)) == -1)
|
||||
{
|
||||
fprintf(stdout, "not found :(\n");
|
||||
continue;
|
||||
}
|
||||
fprintf(stdout, "downloaded! (pkgrev %d)\n", rev);
|
||||
}
|
||||
}
|
||||
|
||||
UnmapViewOfFile(mdmp);
|
||||
CloseHandle(hFileMapping);
|
||||
CloseHandle(hFile);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user