Debug cannot be disabled bug fixed

This commit is contained in:
Print3M
2025-08-26 11:11:50 +02:00
parent 1dce132583
commit 2e6de47e5c
5 changed files with 36 additions and 26 deletions
+4 -7
View File
@@ -47,7 +47,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release delete 1.1.0 --cleanup-tag --yes || echo "No release or tag found for 1.1.0"
gh release delete 1.1.1 --cleanup-tag --yes || echo "No release or tag found for 1.1.1"
- name: Create Release
id: create_release
@@ -55,13 +55,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: 1.1.0
release_name: DllShimmer 1.1.0
tag_name: 1.1.1
release_name: DllShimmer 1.1.1
body: |
- [x] Dynamic linking is now cached (both LoadLibraryA and GetProcAddress). Performance improved.
- [x] Better debug log format: timestamp added.
- [x] New parameter: `--debug-file`. Save debug logs to file.
- [x] README updated.
- [x] "Debug cannot be disabled" bug fixed.
draft: false
prerelease: false
+5 -1
View File
@@ -113,4 +113,8 @@ In the case of dynamic linking, we have two options:
In case of static linking, we really only have one option:
1. Move the original DLL to the `Current Directory`.
1. Move the original DLL to the `Current Directory`.
## TODO
- Support C++ mangled function names
+25 -18
View File
@@ -48,7 +48,7 @@ void initDbg() {
{{- end }}
}
char gTimeBuf[9]; // "HH:MM:SS" + null
char gTimeBuf[9]; // "HH:MM:SS" + \0
char *getCurrentTime() {
time_t t = time(NULL);
@@ -61,19 +61,21 @@ char *getCurrentTime() {
}
void dbgf(const char *fmt, ...) {
if (gCtx.dbgOut == NULL) {
initDbg();
}
#ifdef DEBUG
if (gCtx.dbgOut == NULL) {
initDbg();
}
va_list ap;
va_start(ap, fmt);
fprintf(gCtx.dbgOut, "[DBG] {{.DllName}} | %s | ", getCurrentTime());
vfprintf(gCtx.dbgOut, fmt, ap);
fprintf(gCtx.dbgOut, "\n");
fflush(gCtx.dbgOut);
va_end(ap);
va_list ap;
va_start(ap, fmt);
fprintf(gCtx.dbgOut, "[DBG] {{.DllName}} | %s | ", getCurrentTime());
vfprintf(gCtx.dbgOut, fmt, ap);
fprintf(gCtx.dbgOut, "\n");
fflush(gCtx.dbgOut);
va_end(ap);
#endif
}
void dbgCurrentDirectory() {
@@ -81,6 +83,7 @@ void dbgCurrentDirectory() {
DWORD len = GetCurrentDirectoryA(MAX_PATH, buf);
if (len == 0 || len >= MAX_PATH) {
dbgf("GetCurrentDirectoryA failed");
return;
}
@@ -92,9 +95,11 @@ FuncPtr getProxyFunc(const char *funcName) {
if (gCtx.module == NULL) {
gCtx.module = LoadLibraryA("{{.Original}}");
if (gCtx.module == NULL) {
dbgf("LoadLibraryA({{.Original}}) failed");
dbgf("\tError code: %lu", GetLastError());
dbgCurrentDirectory();
#ifdef DEBUG
dbgf("LoadLibraryA({{.Original}}) failed");
dbgf("\tError code: %lu", GetLastError());
dbgCurrentDirectory();
#endif
return NULL;
}
@@ -109,8 +114,10 @@ FuncPtr getProxyFunc(const char *funcName) {
FuncPtr pFunc = (FuncPtr)GetProcAddress(gCtx.module, funcName);
if (pFunc == NULL) {
dbgf("GetProcAddress(%s, {{.Original}}) failed", funcName);
dbgf("\tError code: %lu", GetLastError());
#ifdef DEBUG
dbgf("GetProcAddress(%s, {{.Original}}) failed", funcName);
dbgf("\tError code: %lu", GetLastError());
#endif
}
gCtx.functions[strFuncName] = pFunc;
+1
View File
@@ -11,6 +11,7 @@
{{- if eq (len $v.Forwarder) 0 }}
// {{$v.Name}}
extern "C" UINT64 {{$v.Name}}Fwd(PARAMS) {
#ifdef DEBUG
dbgf("{{$v.Name}} called");
+1
View File
@@ -30,6 +30,7 @@
extern "C" __declspec(dllimport) UINT64 {{$v.Name}}(PARAMS);
// {{$v.Name}}
extern "C" UINT64 {{$v.Name}}Fwd(PARAMS) {
#ifdef DEBUG
dbgf("{{$v.Name}} called");