-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCommandLine.cpp
57 lines (49 loc) · 1.11 KB
/
CommandLine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <windows.h>
#include "WoWMIPS.h"
char *pGlobal_FixedCommandLineA = NULL;
wchar_t *pGlobal_FixedCommandLineW = NULL;
LPSTR WINAPI Hook_GetCommandLineA()
{
return pGlobal_FixedCommandLineA;
}
LPWSTR WINAPI Hook_GetCommandLineW()
{
return pGlobal_FixedCommandLineW;
}
DWORD FixCommandLine(DWORD dwIgnoreCharacterCount)
{
// fix command line (ANSI)
pGlobal_FixedCommandLineA = GetCommandLineA();
pGlobal_FixedCommandLineA += dwIgnoreCharacterCount;
for(;;)
{
if(*pGlobal_FixedCommandLineA != ' ')
{
break;
}
pGlobal_FixedCommandLineA++;
}
// fix command line (widechar)
pGlobal_FixedCommandLineW = GetCommandLineW();
pGlobal_FixedCommandLineW += dwIgnoreCharacterCount;
for(;;)
{
if(*pGlobal_FixedCommandLineW != L' ')
{
break;
}
pGlobal_FixedCommandLineW++;
}
// hook GetCommandLineA
if(HookFunction((BYTE*)GetCommandLineA, (BYTE*)Hook_GetCommandLineA) != 0)
{
return 1;
}
// hook GetCommandLineW
if(HookFunction((BYTE*)GetCommandLineW, (BYTE*)Hook_GetCommandLineW) != 0)
{
return 1;
}
return 0;
}