Page 1 of 1

Removing Sensitive Paths from Executable (.exe)

Posted: Tue Sep 09, 2014 12:50 am
by purplex88
I'm using Visual Studio v11 to statically link libraries to produce an executable file in release mode. Upon analyzing it in Hex editor mode I found some paths which point to the wxWidgets library E.g. C:\Users\Purplex\AppData\Roaming\wxWidgets-3.0.0\include\wx/strvararg.h and 48 other files in same path.

So, what I did was to move my "wxWidgets-3.0.0" directory to another location and start a project from scratch and rebuild it. But still the same paths are showing up even when the above path isn't a valid location anymore. How can I strip this extra information and clean up or reduce the size a bit if possible?

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Tue Sep 09, 2014 3:49 am
by eranif
Have you tried running strip.exe on your code?
It should remove all extra strings from the executable

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Tue Sep 09, 2014 5:18 am
by PB
Just a wild guess, aren't those paths there to be eventually used with wxASSERT and such? These may be compiled in even, in the release mode, unless wxWidgets were built with wxDEBUG_LEVEL is set to 0 in wx/msw/setup.h.

If you want the paths to change, you probably have to rebuild wxWidgets themselves from the new path, not just your project.

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Tue Sep 09, 2014 7:36 pm
by purplex88
Isn't "strip.exe" part of GNU project? If so, then should it work to remove debug info from Visual Studio executable?

I just re-built the wxWidgets libraries and set the debug level to 0 and it seems the paths are all cleared. Is there still way to further strip the debug symbols used by Visual Studio v11?

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Tue Sep 09, 2014 8:31 pm
by doublemax
AFAIK you don't need an external tool like this for VS. Just check the settings under project properties -> Linker -> Debugging

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Wed Sep 10, 2014 6:54 am
by purplex88
I don't know what went wrong but in one of my project solutions the "wxWidgets debug errors" have completely stopped both in debug and release mode after I edited "wx/msw/setup.h" to set the wxDEBUG_LEVEL to 0.

But in my other project, they won't go away both in debug and release build.

I have checked the Preprocessor definitions and they are same for both of the projects with NDEBUG only defined for release builds.

Here's how:
10-Sep-14 1-06-06 PM.jpg
10-Sep-14 1-06-06 PM.jpg (70.83 KiB) Viewed 10774 times
For both projects built in debug mode, one of them shows this:
10-Sep-14 1-06-31 PM.jpg
10-Sep-14 1-06-31 PM.jpg (9.27 KiB) Viewed 10774 times
and other one:
10-Sep-14 1-08-04 PM.jpg
10-Sep-14 1-08-04 PM.jpg (11.9 KiB) Viewed 10774 times

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Wed Sep 10, 2014 7:46 am
by PB
Something must be really wrong here, as the debug messages should still pop up in configurations where NDEBUG is not defined in the project settings. Also both projects have to behave the same as long as they have same project settings and link with the same wxWidgets build. Just to be sure, you do realize you have to set NDEBUG in your project settings too (in the release configuration, matching the wxWidgets build you link against)?

After any change in wx/msw/setup.h be sure to clean and rebuild wxWidgets and check if the setup.h file was properly copied into the build directories (e.g. lib\vc_dll\mswu\wx for release shared build) do match.

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Wed Sep 10, 2014 8:00 am
by purplex88
I already deleted the other wxWidgets build and rebuilt the projects several times.

But still it should only show the "Debug dialog" only in debug mode and switching from debug to release mode built has no affect.
So, the same debug dialog is still shown in release mode.

Here are my processors from debug mode:
WIN32
_DEBUG
_WINDOWS
_UNICODE
__WXMSW__
__WXDEBUG__
WXUSINGDLL
and release mode:
WIN32
_WINDOWS
__WXMSW__
_UNICODE
NDEBUG

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Wed Sep 10, 2014 8:33 am
by PB
Well then, I am out of ideas, assuming you didn't somewhat manage to link to debug build version even in the release build of your project.

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Wed Sep 10, 2014 8:42 am
by purplex88
I created a project this time and added the preprocessors as above with include and library paths to the new wxWidgets build

and then I edit all the setup.h files in the following paths:
wxWidgets-3.0.0\lib\vc_dll\mswud\wx\setup.h
wxWidgets-3.0.0\lib\vc_lib\mswu\wx\setup.h
wxWidgets-3.0.0\lib\vc_lib\mswud\wx\setup.h
wxWidgets-3.0.0\include\wx\msw\setup.h
But still the same "debug" dialog shows in release build.

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Wed Sep 10, 2014 8:49 am
by PB
AFAIK for what you need it should be enough to change the master setup.h in include/wx/msw, which is then copied to the respective lib directories during their build process. Just to be sure I say it again, after any change in the setup.h, you have to rebuild wxWidgets clean.

Anyway, the error dialog posted in your screenshots does not look like a debug message. It looks as a standard error message produced by wxLogError() or similar. To suppress these, use wxLogNull class in general. To avoid this one error message do not attempt to add an invalid image to a list, e.g. do not add bitmaps for which IsOk() returns false.

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Wed Sep 10, 2014 9:24 am
by doublemax
Messages like "Couldn't add an image to the image list." are not debug messages. There are similar (annoying) messages when you open a file that doesn't exist or want to open a registry key under windows that doesn't exist. They will appear in both debug in release versions unless you wrap the code with a wxLogNull instance or disable logging completely in release mode.

Code: Select all

#ifndef _DEBUG
	wxLog::SetLogLevel(0);
#endif

Re: Removing Sensitive Paths from Executable (.exe)

Posted: Sun Jun 03, 2018 5:33 pm
by Rytz
Necro-ing this thread to add a tidbit.

Defining/setting wxDEBUG_LEVEL to zero in setup.h for my build got rid of most of the path strings in my executable. To get the remainder, I needed to also define/set wxUSE_LOG to zero. An example of this requirement was for the following:

Code: Select all

wxOleInitialize
<MY_BUILD_PATH>wx/msw/ole/oleutils.h
Cannot initialize OLE
Only way I could get rid of the line with "oleutils.h" was to disable logging.