[GFLAGS] Implement imagefile options

This commit is contained in:
Mark Jansen 2018-10-13 17:11:51 +02:00
parent ec621270a1
commit 8543622a72
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
4 changed files with 295 additions and 4 deletions

View file

@ -9,6 +9,7 @@
#include "gflags.h"
static BOOL UsePageHeap = FALSE;
static BOOL UseImageFile = FALSE;
const WCHAR ImageExecOptionsString[] = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options";
@ -77,6 +78,11 @@ static BOOL ParseCmdline(int argc, LPWSTR argv[])
UsePageHeap = TRUE;
return PageHeap_ParseCmdline(i + 1, argc, argv);
}
if (argv[i][1] == L'i' && argv[i][2] == UNICODE_NULL)
{
UseImageFile = TRUE;
return ImageFile_ParseCmdline(i + 1, argc, argv);
}
}
else
{
@ -85,9 +91,9 @@ static BOOL ParseCmdline(int argc, LPWSTR argv[])
}
}
if (!UsePageHeap)
if (!UsePageHeap && !UseImageFile)
{
wprintf(L"Only page heap flags are supported\n");
wprintf(L"Only page heap / image file flags are supported\n");
return FALSE;
}
@ -99,11 +105,21 @@ int wmain(int argc, LPWSTR argv[])
{
if (!ParseCmdline(argc, argv))
{
wprintf(L"Usage: gflags /p [image.exe] [/enable|/disable [/full]]\n"
wprintf(L"Usage: gflags [/p [image.exe] [/enable|/disable [/full]]]\n"
L" [/i <image.exe> [<Flags>]]\n"
L" image.exe: Image you want to deal with\n"
L" /enable: enable page heap for the image\n"
L" /disable: disable page heap for the image\n"
L" /full: activate full debug page heap\n");
L" /full: activate full debug page heap\n"
L" <Flags>: A 32 bit hex number (0x00000001) that specifies\n"
L" one or more global flags to set.\n"
L" Without any flags, the current settings are shown.\n"
L" Specify FFFFFFFF to delete the GlobalFlags entry.\n"
L" Additionally, instead of a single hex number,\n"
L" specify a list of abbreviations prefixed with\n"
L" a '+' to add, and '-' to remove a bit.\n"
L" Valid abbreviations:\n");
PrintFlags(~0, DEST_IMAGE);
return 1;
}
@ -111,5 +127,9 @@ int wmain(int argc, LPWSTR argv[])
{
return PageHeap_Execute();
}
else if (UseImageFile)
{
return ImageFile_Execute();
}
return 2;
}