Skip to content

Commit eac7ee8

Browse files
committed
add debug build cmake preset
1 parent c133de0 commit eac7ee8

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ set(CPM_SOURCE_CACHE "${CMAKE_SOURCE_DIR}/.cache/cpm")
1515
include(cmake/CPM.cmake)
1616

1717
set(FUMO_DRIVER_DEBUG OFF CACHE BOOL "Enable driver debug logs/force reload")
18+
set(FUMO_DEBUG OFF CACHE BOOL "Disable creating new executables")
1819

1920
add_subdirectory(src)

CMakePresets.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
"architecture": {
1414
"value": "x64",
1515
"strategy": "set"
16+
},
17+
"cacheVariables": {
18+
"FUMO_DEBUG": "OFF",
19+
"FUMO_DRIVER_DEBUG": "OFF"
20+
}
21+
},
22+
{
23+
"name": "x64-windows-debug",
24+
"inherits": "x64-windows",
25+
"cacheVariables": {
26+
"FUMO_DEBUG": "ON",
27+
"FUMO_DRIVER_DEBUG": "ON"
1628
}
1729
}
1830
],
@@ -21,6 +33,11 @@
2133
"name": "Release",
2234
"configurePreset": "x64-windows",
2335
"configuration": "Release"
36+
},
37+
{
38+
"name": "Debug",
39+
"configurePreset": "x64-windows-debug",
40+
"configuration": "Release"
2441
}
2542
]
2643
}

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ find_package(WDK REQUIRED)
4242

4343
CPMAddPackage("gh:dumbasPL/[email protected]")
4444

45+
if (FUMO_DEBUG)
46+
add_compile_definitions(FUMO_DEBUG)
47+
endif()
48+
4549
add_subdirectory(driver)
4650
add_subdirectory(driver_interface)
4751
add_subdirectory(rsource_generator)

src/initial_loader/initial_loader.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ extern "C" void initial_loader(ULONG_PTR xorKey) {
212212
}
213213
}
214214

215+
#ifndef FUMO_DEBUG
215216
// allocate memory for new executable
216217
auto new_image_base = (ULONG_PTR)fnVirtualAlloc(nullptr, nt_headers->OptionalHeader.SizeOfImage, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
217218
if (!new_image_base)
@@ -339,20 +340,25 @@ extern "C" void initial_loader(ULONG_PTR xorKey) {
339340
}
340341

341342
fnVirtualFree((PVOID)new_image_base, 0, MEM_RELEASE);
343+
#endif
342344

343345
auto error = map_encrypted_sections(base);
344346
if (error != ERR_SUCCESS) {
347+
#ifndef FUMO_DEBUG
345348
fnCloseHandle(file_handle);
349+
#endif
346350
fnExitProcess(error);
347351
return;
348352
}
349353

354+
#ifndef FUMO_DEBUG
350355
disposition_info.DeleteFileW = FALSE;
351356
if (!fnSetFileInformationByHandle(file_handle, FileDispositionInfo, &disposition_info, sizeof(disposition_info))) {
352357
fnCloseHandle(file_handle);
353358
EXIT_WITH_ERROR(ERR_FAILED_TO_SET_DELETE_FILE_INFO, "Failed to set delete file info (2)");
354359
}
355360

356361
fnCloseHandle(file_handle);
362+
#endif
357363
fnExitProcess(0);
358364
}

src/stage2/stage2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ int main(HANDLE loader_process) {
1818
return fumo::error(ERR_STAGE2_FAILED_TO_WAIT_FOR_PROCESS, L"Failed to wait for loader process({}): {}", loader_process_name, wait_result);
1919
CloseHandle(loader_process);
2020

21+
#ifndef FUMO_DEBUG
2122
// delete the loader executable
2223
if (!DeleteFileW(loader_process_name.c_str()))
2324
return fumo::error(ERR_STAGE2_FAILED_TO_DELETE_LOADER, L"Failed to delete loader executable: {}", loader_process_name);
25+
#endif
2426

2527
auto driver = fumo::DriverInterface::Open(FUMO_HOOKED_DRIVER_NAME_USER);
2628
if (!driver)

0 commit comments

Comments
 (0)