Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Commit aad8e6c

Browse files
committed
1.4 part 2
add support quote to cmdline, restored generate .lip file from cmdline and other.
1 parent 6ecd62a commit aad8e6c

File tree

5 files changed

+222
-55
lines changed

5 files changed

+222
-55
lines changed

fallout4_test/src/patches/CKF4/Editor.cpp

Lines changed: 192 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -521,19 +521,6 @@ BOOL FIXAPI hk_call_12E852C(HWND RichEditControl, LPCSTR Text)
521521
}
522522

523523

524-
525-
/*
526-
==================
527-
hk_first_call_strtok_for_quote
528-
==================
529-
*/
530-
LPSTR FIXAPI hk_first_call_strtok_for_quote(LPSTR lpSrc, LPCSTR lpDelim)
531-
{
532-
return strtok(lpSrc, "\"");
533-
}
534-
535-
536-
537524
/*
538525
==================
539526
hk_call_2511176
@@ -747,14 +734,6 @@ VOID FIXAPI PatchMessage(VOID)
747734
Core::Classes::UI::CUIMainWindow::ProcessMessages();
748735
}
749736

750-
751-
VOID FIXAPI HiddenMovableStatic(BOOL Value)
752-
{
753-
LPVOID ptrArr = *((LPVOID*)OFFSET(0x6D54CF8, 0));
754-
((VOID(__fastcall*)(LPVOID, INT32, BOOL))OFFSET(0x7B4520, 0))(ptrArr, 0, Value);
755-
((VOID(__fastcall*)(VOID))OFFSET(0x59C820, 0))();
756-
}
757-
758737
VOID FIXAPI PatchTemplatedFormIterator(VOID)
759738
{
760739
class FormIteratorHook : public Xbyak::CodeGenerator
@@ -828,4 +807,196 @@ VOID FIXAPI PatchTemplatedFormIterator(VOID)
828807
FormIteratorHook::Generate(OFFSET(0x191D2, 0));
829808
FormIteratorHook::Generate(OFFSET(0x28CBD, 0));
830809
FormIteratorHook::Generate(OFFSET(0x118FB, 0));
810+
}
811+
812+
813+
/*
814+
==================
815+
PatchGeneratePreCombined_CmdLineWithQuote
816+
817+
Adds support for quotation marks of some commands on the command line
818+
==================
819+
*/
820+
821+
LPSTR FIXAPI Fixed_StrTok(LPSTR str, LPSTR delim, LPSTR* next_token)
822+
{
823+
if (str)
824+
{
825+
while (*str == ' ')
826+
{
827+
if (*str == '\0')
828+
return NULL;
829+
830+
str++;
831+
}
832+
833+
if (*str == '\"')
834+
return strtok_s(++str, "\"", next_token);
835+
else
836+
return strtok_s(str, " ", next_token);
837+
}
838+
else if (next_token && *next_token)
839+
{
840+
if (strchr(*next_token, '\"'))
841+
{
842+
LPSTR lpRes = strtok_s(NULL, "\"", next_token);
843+
844+
if (lpRes && !XUtil::Str::trim(lpRes).length())
845+
lpRes = strtok_s(NULL, "\"", next_token);
846+
847+
return lpRes;
848+
}
849+
else
850+
return strtok_s(NULL, " ", next_token);
851+
}
852+
else
853+
return strtok_s(str, delim, next_token);
854+
};
855+
856+
VOID FIXAPI RestoreGenerateSingleLip(LPSTR lpCmdLine, LPSTR arg2)
857+
{
858+
namespace fs = std::filesystem;
859+
860+
LPSTR next_token = NULL;
861+
862+
LPSTR token = Fixed_StrTok(lpCmdLine, " ", &next_token);
863+
if (token)
864+
{
865+
LPSTR filename = token;
866+
token = Fixed_StrTok(NULL, " ", &next_token);
867+
if (token)
868+
{
869+
auto pathAudioFile = fs::path(filename);
870+
// Replacement by .wav
871+
pathAudioFile.replace_extension(L".wav");
872+
873+
if (fs::exists(pathAudioFile))
874+
{
875+
auto AudioFilePath = XUtil::Conversion::WideToAnsi(pathAudioFile);
876+
((BOOL(__fastcall*)(HWND, LPCSTR, LPCSTR))OFFSET(0x0B66BF0, 0))(MainWindow::GetWindow(), AudioFilePath.c_str(), token);
877+
878+
return;
879+
}
880+
}
881+
}
882+
883+
((VOID(__fastcall*)(LPCSTR))OFFSET(0x2001A90, 0))(((LPSTR)OFFSET(0x3837940, 0)));
884+
}
885+
886+
VOID FIXAPI PatchCmdLineWithQuote(VOID)
887+
{
888+
// Add support quote to command line with -GeneratePreCombined
889+
// Should be: -GeneratePreCombined:"<ESMFilename>" [clean, filtered] [all, other, main, ints]
890+
891+
XUtil::DetourCall(OFFSET(0x33B9D3, 0), &Fixed_StrTok);
892+
XUtil::DetourCall(OFFSET(0x33B9F3, 0), &Fixed_StrTok);
893+
XUtil::DetourCall(OFFSET(0x33BA0C, 0), &Fixed_StrTok);
894+
895+
// -GeneratePreVisData
896+
// This command into the code section -GeneratePreCombined.
897+
// Should be: -GeneratePreVisData:"<ESMFilename>" [clean, filtered] [all, other, main, ints]
898+
899+
XUtil::DetourCall(OFFSET(0x33BB0E, 0), &Fixed_StrTok);
900+
XUtil::DetourCall(OFFSET(0x33BB2C, 0), &Fixed_StrTok);
901+
902+
// Add support quote to command line with -CheckInPlugin
903+
// Should be: -CheckInPlugin:"<PluginFilename>" "<ESMFilename>"
904+
905+
XUtil::DetourCall(OFFSET(0x33B30B, 0), &Fixed_StrTok);
906+
XUtil::DetourCall(OFFSET(0x33B32D, 0), &Fixed_StrTok);
907+
908+
// Add support quote to command line with -ConvertToESL
909+
// Should be: -ConvertToESL:"<PluginFilename>"
910+
911+
XUtil::DetourCall(OFFSET(0x33C4F4, 0), &Fixed_StrTok);
912+
913+
// Add support quote to command line with -DumpNeededFiles
914+
// Should be: -DumpNeededFiles:"<ESMFilename>" "<OutputFilepath>"
915+
916+
XUtil::DetourCall(OFFSET(0x33B43E, 0), &Fixed_StrTok);
917+
XUtil::DetourCall(OFFSET(0x33B45C, 0), &Fixed_StrTok);
918+
919+
// Add support quote to command line with -SaveDefaultPlugin
920+
// Should be: -SaveDefaultPlugin:"<PluginFilename>" "<ESMFilename>"
921+
922+
XUtil::DetourCall(OFFSET(0x33B278, 0), &Fixed_StrTok);
923+
XUtil::DetourCall(OFFSET(0x33B296, 0), &Fixed_StrTok);
924+
925+
// Add support quote to command line with -SaveDefaultPlugin
926+
// Should be: -ExportDismemberData:"<ESMFilename>" <XB1|X64|PS4|W32>
927+
928+
XUtil::DetourCall(OFFSET(0x33B1A4, 0), &Fixed_StrTok);
929+
XUtil::DetourCall(OFFSET(0x33B1C2, 0), &Fixed_StrTok);
930+
931+
// Add support quote to command line with -UpdateModelData
932+
// Should be: -UpdateModelData:"<ESMFilename>"
933+
934+
XUtil::DetourCall(OFFSET(0x33B139, 0), &Fixed_StrTok);
935+
936+
// Add support quote to command line with -OutputAreaArt
937+
// Should be: -OutputAreaArt:"<ESMFilename>" "<AreasFilename>" "<OutputFilename>"
938+
939+
XUtil::DetourCall(OFFSET(0x33B07F, 0), &Fixed_StrTok);
940+
XUtil::DetourCall(OFFSET(0x33B09D, 0), &Fixed_StrTok);
941+
XUtil::DetourCall(OFFSET(0x33B0BB, 0), &Fixed_StrTok);
942+
943+
// Add support quote to command line with -CompileTextExport
944+
// Should be: -CompileTextExport:"<ESMFilename>" "<language>" "<PathToTextExport>" ["<PathBackupToTextExport>"]
945+
946+
XUtil::DetourCall(OFFSET(0x33AF37, 0), &Fixed_StrTok);
947+
XUtil::DetourCall(OFFSET(0x33AF55, 0), &Fixed_StrTok);
948+
949+
// Add support quote to command line with -ExportFaceGenData
950+
// Should be: -ExportFaceGenData:"<ESMFilename>" <XB1|X64|PS4|W32>
951+
952+
XUtil::DetourCall(OFFSET(0x33ADD1, 0), &Fixed_StrTok);
953+
XUtil::DetourCall(OFFSET(0x33ADEF, 0), &Fixed_StrTok);
954+
955+
// Add support quote to command line with -GenerateAnimInfo
956+
// Should be: -GenerateAnimInfo:"<ESMFilename>" "<DataFilepath>" "<OutputFilepath>" [%s] [%s] [%s]
957+
958+
XUtil::DetourCall(OFFSET(0x33B4DA, 0), &Fixed_StrTok);
959+
XUtil::DetourCall(OFFSET(0x33B4F8, 0), &Fixed_StrTok);
960+
XUtil::DetourCall(OFFSET(0x33B516, 0), &Fixed_StrTok);
961+
XUtil::DetourCall(OFFSET(0x33B534, 0), &Fixed_StrTok);
962+
XUtil::DetourCall(OFFSET(0x33B694, 0), &Fixed_StrTok);
963+
964+
// Add support quote to command line with -GenerateSingleLip
965+
// Should be: -GenerateSingleLip:"<WavFilename>" "<Text>"
966+
// Warning: /Data/Sound/ this is the directory relative to which it will be stored .lip file.
967+
968+
XUtil::DetourCall(OFFSET(0x33B843, 0), &RestoreGenerateSingleLip);
969+
970+
// Add support quote to command line with -GenerateStaticCollections
971+
// Should be: -GenerateStaticCollections:"<ESMFilename>" <XB1|X64|PS4|W32>
972+
973+
XUtil::DetourCall(OFFSET(0x33B90E, 0), &Fixed_StrTok);
974+
XUtil::DetourCall(OFFSET(0x33B92C, 0), &Fixed_StrTok);
975+
976+
// Add support quote to command line with -DepersistRefs
977+
// Should be: -DepersistRefs:"<ESMFilename>"
978+
979+
XUtil::DetourCall(OFFSET(0x33BE82, 0), &Fixed_StrTok);
980+
981+
// Add support quote to command line with -MapMarker
982+
// Should be: -MapMarker:"<ESMFilename>" "<Worldspace|Interior>"
983+
984+
XUtil::DetourCall(OFFSET(0x33BEFE, 0), &Fixed_StrTok);
985+
XUtil::DetourCall(OFFSET(0x33BF1C, 0), &Fixed_StrTok);
986+
987+
// Add support quote to command line with -MapInfo
988+
// Should be: -MapInfo:"<ESMFilename>" "<Worldspace|Interior>" ["<%s>"]
989+
990+
XUtil::DetourCall(OFFSET(0x33BF87, 0), &Fixed_StrTok);
991+
XUtil::DetourCall(OFFSET(0x33BFA5, 0), &Fixed_StrTok);
992+
XUtil::DetourCall(OFFSET(0x33BFC3, 0), &Fixed_StrTok);
993+
994+
// Add support quote to command line with -ImportScalingData
995+
// Should be: -ImportScalingData:"<ESMFilename>"
996+
997+
XUtil::DetourCall(OFFSET(0x33C10D, 0), &Fixed_StrTok);
998+
999+
1000+
1001+
8311002
}

fallout4_test/src/patches/CKF4/Editor.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ VOID FIXAPI QuitHandler(VOID);
3434
VOID FIXAPI hk_call_140906407(INT64 a1, INT64 a2, INT64 a3);
3535
BOOL FIXAPI hk_call_12E852C(HWND RichEditControl, LPCSTR Text);
3636
VOID FIXAPI PatchTemplatedFormIterator(VOID);
37-
VOID FIXAPI HiddenMovableStatic(BOOL Value);
3837

3938

4039
/*
@@ -61,14 +60,6 @@ But this patch will make the button available.
6160
VOID FIXAPI PatchLip(VOID);
6261

6362

64-
/*
65-
==================
66-
hk_first_call_strtok_for_quote
67-
==================
68-
*/
69-
LPSTR FIXAPI hk_first_call_strtok_for_quote(LPSTR lpSrc, LPCSTR lpDelim);
70-
71-
7263
/*
7364
==================
7465
PatchMessage
@@ -138,4 +129,14 @@ VOID FIXAPI ArrayQuickSortRecursive(BSTArray<T>& Array, INT32(*SortFunction)(LPC
138129
std::stable_sort(&Array[0], &Array[Array.QSize()], compare);
139130
else
140131
std::sort(&Array[0], &Array[Array.QSize()], compare);
141-
}
132+
}
133+
134+
135+
/*
136+
==================
137+
PatchCmdLineWithQuote
138+
139+
Adds support for quotation marks of some commands on the command line
140+
==================
141+
*/
142+
VOID FIXAPI PatchCmdLineWithQuote(VOID);

fallout4_test/src/patches/CKF4/ShowHideWindow.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ namespace ShowHideWindow
88
Classes::CUICustomWindow ShowHideWindow;
99
static BOOL Initialize = FALSE;
1010

11-
struct ShowHideWindowControls_t
12-
{
13-
Classes::CUICheckbox CheckBtnMovableStatics;
14-
} ShowHideWindowControls;
15-
1611
DLGPROC OldDlgProc;
1712

1813
HWND FIXAPI GetWindow(VOID)
@@ -33,25 +28,8 @@ namespace ShowHideWindow
3328
{
3429
Initialize = TRUE;
3530
ShowHideWindow = DialogHwnd;
36-
ShowHideWindowControls.CheckBtnMovableStatics.CreateWnd(ShowHideWindow, ShowHideWindow.GetControl(UI_VISIBLE_CHECKBUTTON_MOVABLESTATICS), UI_VISIBLE_CHECKBUTTON_MOVABLESTATICS);
37-
// Default value
38-
ShowHideWindowControls.CheckBtnMovableStatics.Checked = TRUE;
3931
}
4032
}
41-
else if (Message == WM_DESTROY)
42-
{
43-
ShowHideWindowControls.CheckBtnMovableStatics.Release();
44-
}
45-
else if (Message == WM_COMMAND)
46-
{
47-
switch (LOWORD(wParam))
48-
{
49-
case UI_VISIBLE_CHECKBUTTON_MOVABLESTATICS:
50-
HiddenMovableStatic(ShowHideWindowControls.CheckBtnMovableStatics.Checked);
51-
ShowHideWindowControls.CheckBtnMovableStatics.Checked = !ShowHideWindowControls.CheckBtnMovableStatics.Checked;
52-
return 0;
53-
}
54-
}
5533

5634
return OldDlgProc(DialogHwnd, Message, wParam, lParam);
5735
}

fallout4_test/src/patches/patches_f4ck.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,23 @@ VOID FIXAPI F_RequiredPatches(VOID)
216216
XUtil::PatchMemory(OFFSET(0xF84521, 0), { 0xEB, 0x4D, 0x90 });
217217
XUtil::PatchMemory(OFFSET(0xF84570, 0), { 0x48, 0x85, 0xC9, 0x74, 0xB5, 0x48, 0x8B, 0x01, 0xEB, 0xAA });
218218

219+
//
220+
// Adds support for quotation marks of some commands on the command line
221+
//
222+
PatchCmdLineWithQuote();
223+
224+
//
225+
// Skipping the program update check
226+
//
227+
XUtil::PatchMemory(OFFSET(0x5C180B, 0), { 0xEB, 0x10 });
228+
229+
//
230+
// Change the default " 64-bit"
231+
//
232+
const char* newTitlePart = " Fallout 4 64-bit";
233+
XUtil::PatchMemory(OFFSET(0x5C16CB, 0), { 0x8B });
234+
XUtil::PatchMemory(OFFSET(0x3857828, 0), (uint8_t*)&newTitlePart, sizeof(newTitlePart));
235+
219236
//
220237
// Plugin loading optimizations
221238
//

fallout4_test/src/patches/patches_f4tes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ VOID FIXAPI MainFix_PatchFallout4Game(VOID)
138138
//
139139
// Loading optimizations
140140
//
141-
141+
/*
142142
INT32 cpuinfo[4];
143143
__cpuid(cpuinfo, 1);
144144
@@ -155,7 +155,7 @@ VOID FIXAPI MainFix_PatchFallout4Game(VOID)
155155
XUtil::DetourCall(it + 4, &Fix_BoostArraySearchItem);
156156
XUtil::PatchMemory(it + 9, { 0x48, 0x83, 0xC4, 0x30, 0x89, 0xC3, 0x49, 0x89, 0xD3, 0x48, 0x89, 0xCA });
157157
});
158-
}
158+
}*/
159159

160160
XUtil::DetourCall(OFFSET(0x13267D, 0), &hk_inflateInit);
161161
XUtil::DetourCall(OFFSET(0x1326AF, 0), &hk_inflate);

0 commit comments

Comments
 (0)