go my file uploader
This commit is contained in:
BIN
tools/fixlib/bin/Release/fixlib.exe
Normal file
BIN
tools/fixlib/bin/Release/fixlib.exe
Normal file
Binary file not shown.
113
tools/fixlib/fixlib.c
Normal file
113
tools/fixlib/fixlib.c
Normal file
@@ -0,0 +1,113 @@
|
||||
#include <ph.h>
|
||||
#include <mapimg.h>
|
||||
|
||||
#define ARG_OUTFILE 1
|
||||
|
||||
PPH_STRING inFile = NULL;
|
||||
PPH_STRING outFile = NULL;
|
||||
|
||||
BOOLEAN NTAPI CommandLineCallback(
|
||||
_In_opt_ PPH_COMMAND_LINE_OPTION Option,
|
||||
_In_opt_ PPH_STRING Value,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
if (Option)
|
||||
{
|
||||
switch (Option->Id)
|
||||
{
|
||||
case ARG_OUTFILE:
|
||||
{
|
||||
PhSwapReference(&outFile, Value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PhSwapReference(&inFile, Value);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int __cdecl main(int argc, char *argv[])
|
||||
{
|
||||
static PH_COMMAND_LINE_OPTION options[] =
|
||||
{
|
||||
{ ARG_OUTFILE, L"o", MandatoryArgumentType }
|
||||
};
|
||||
NTSTATUS status;
|
||||
PH_STRINGREF commandLine;
|
||||
PH_MAPPED_ARCHIVE mappedArchive;
|
||||
PH_MAPPED_ARCHIVE_MEMBER member;
|
||||
PH_MAPPED_ARCHIVE_IMPORT_ENTRY entry;
|
||||
|
||||
if (!NT_SUCCESS(PhInitializePhLib()))
|
||||
return 1;
|
||||
|
||||
PhUnicodeStringToStringRef(&NtCurrentPeb()->ProcessParameters->CommandLine, &commandLine);
|
||||
|
||||
if (!PhParseCommandLine(
|
||||
&commandLine,
|
||||
options,
|
||||
sizeof(options) / sizeof(PH_COMMAND_LINE_OPTION),
|
||||
PH_COMMAND_LINE_IGNORE_FIRST_PART,
|
||||
CommandLineCallback,
|
||||
NULL
|
||||
) || !inFile)
|
||||
{
|
||||
wprintf(L"Usage: fixlib [-o outfile] infile\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!outFile)
|
||||
outFile = inFile;
|
||||
|
||||
CopyFile(inFile->Buffer, outFile->Buffer, FALSE);
|
||||
|
||||
status = PhLoadMappedArchive(outFile->Buffer, NULL, FALSE, &mappedArchive);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
wprintf(L"Error: %s\n", PhGetStringOrDefault(PhGetNtMessage(status), L"unknown"));
|
||||
return status;
|
||||
}
|
||||
|
||||
member = *(mappedArchive.LastStandardMember);
|
||||
|
||||
while (NT_SUCCESS(PhGetNextMappedArchiveMember(&member, &member)))
|
||||
{
|
||||
if (NT_SUCCESS(PhGetMappedArchiveImportEntry(&member, &entry)))
|
||||
{
|
||||
IMPORT_OBJECT_HEADER *header;
|
||||
PWSTR type = L"unknown";
|
||||
|
||||
switch (entry.NameType)
|
||||
{
|
||||
case IMPORT_OBJECT_ORDINAL:
|
||||
type = L"ordinal";
|
||||
break;
|
||||
case IMPORT_OBJECT_NAME:
|
||||
type = L"name";
|
||||
break;
|
||||
case IMPORT_OBJECT_NAME_NO_PREFIX:
|
||||
type = L"name-noprefix";
|
||||
break;
|
||||
case IMPORT_OBJECT_NAME_UNDECORATE:
|
||||
type = L"name-undecorate";
|
||||
break;
|
||||
}
|
||||
|
||||
wprintf(L"%S: %S (%s)\n", entry.DllName, entry.Name, type);
|
||||
|
||||
header = (IMPORT_OBJECT_HEADER *)member.Data;
|
||||
|
||||
// Changes
|
||||
|
||||
header->NameType = IMPORT_OBJECT_NAME_UNDECORATE;
|
||||
}
|
||||
}
|
||||
|
||||
PhUnloadMappedArchive(&mappedArchive);
|
||||
}
|
||||
109
tools/fixlib/fixlib.vcxproj
Normal file
109
tools/fixlib/fixlib.vcxproj
Normal file
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{31F4AA06-7ED5-4A6D-B901-19AD4BD16175}</ProjectGuid>
|
||||
<RootNamespace>fixlib</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\phnt\include;..\..\phlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_PHLIB_;_CONSOLE;WIN32;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>phlib.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\phlib\bin\$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<MinimumRequiredVersion>5.01</MinimumRequiredVersion>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>..\..\phnt\include;..\..\phlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_PHLIB_;_CONSOLE;WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>phlib.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\phlib\bin\$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<SetChecksum>true</SetChecksum>
|
||||
<MinimumRequiredVersion>5.01</MinimumRequiredVersion>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="fixlib.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\phlib\phlib.vcxproj">
|
||||
<Project>{477d0215-f252-41a1-874b-f27e3ea1ed17}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
14
tools/fixlib/fixlib.vcxproj.filters
Normal file
14
tools/fixlib/fixlib.vcxproj.filters
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="fixlib.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user