WDF files deciphered!

WDF files + wdfedit & wdftool & basic wdf file info; support/discussion/questions

Moderator: thunderchero

User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: WDF files deciphered!

Post by QuasarDonkey »

I've fixed the problem. You can get the latest version of wdftool on the sourceforge page here:
http://sourceforge.net/projects/botfwdftools/files/
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2392
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: WDF files deciphered!

Post by Tethys »

Great stuff, this helps out alot thank you.
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
DCER
Code Master
Code Master
Posts: 683
Joined: Sat Apr 26, 2008 2:00 am

Re: WDF files deciphered!

Post by DCER »

QuasarDonkey,

as you've probably noticed I managed to add wdf editing to UE based on the info you provided. Thanks again for posting it. Hope you stick around and help uncover more botf secrets :)
User avatar
Flocke
BORG Trouble Maker
BORG Trouble Maker
Posts: 3178
Joined: Sun Apr 27, 2008 2:00 am
Location: Hamburg, Germany
Contact:

Re: WDF files deciphered!

Post by Flocke »

With progress on UE it might not be relevant anymore, dunno, but I spent some time the last days to learn more on CMake and used this wdftool for practice.
For those who don't know what CMake is, it's a little tool for C++ cross platform development and can automaticly generate project and make files for several environments.

So if someone wants to try, here's the CMakeLists.txt I wrote:

Code: Select all

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(WDFTool)

set(Boost_USE_STATIC_LIBS     ON)
set(Boost_USE_MULTITHREADED   ON)
set(Boost_USE_STATIC_RUNTIME  OFF)
set(Boost_NO_SYSTEM_PATHS     TRUE)

find_package(Boost 1.36.0 REQUIRED COMPONENTS system filesystem)
find_package(SDL REQUIRED)
find_package(SDL_image REQUIRED)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR})

set(WDFTool_SRCS
	src/FileManager_Dir.hpp
	src/FileManager_Dir.cpp
	src/FileManager.hpp
	src/FileManager.cpp
	src/FileReader.hpp
	src/ImageManager.hpp
	src/ImageManager.cpp
	src/SDL_Line.h
	src/SDL_Line.c
	src/wdfFileReader.hpp
	src/wdfFileReader.cpp
	src/wdfObjects.hpp
	src/wdfReader.hpp
	src/wdfReader.cpp
	src/wdftool_cmdline.hpp
	src/wdftool_cmdline.cpp
	src/wdftool.cpp
)

add_executable(WDFTool ${WDFTool_SRCS})

target_link_libraries(WDFTool ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY})

install(TARGETS WDFTool DESTINATION .)
Instructions to compile wdftool on Windows using CMake and VS 2010:

preparation (order doesn't matter):
  • download and install Visual Studio 2010 Express or Visual C++ Express from Microsoft if you have no Visual Studio yet
  • download and install CMake from http://www.cmake.org/
  • download newest BoostPro Installer from http://boostpro.com/download/ (currently 1.47)
    install the multithreading and multithreading debug module, the others like static runtime aren't necessary here.
  • download and install SDL development library from http://www.libsdl.org/ (I used VC8 as VC10 isn't available yet)
  • download and install SDL_image devel from http://www.libsdl.org/projects/SDL_image/
    note: for sdl there's no installer, just copy zip content
  • add the following environment variables (System Properties -> Advanced tab):
    BOOST_ROOT pointing to your boost installation e.g. C:\Programme\boost\boost_1_47
    SDLDIR pointing to your SDL installation e.g. C:\Programme\SDL-1.2.14
    SDLIMAGEDIR pointing to your SDL_image installation e.g. C:\Programme\SDL_image-1.2.10
  • add CMake to the PATH variable of the environment variables, seperated by a semi-colon, e.g. prepend "C:\Programme\CMake 2.8\bin;" to the value of PATH.
  • add the above CMakeLists.txt to the root path of the source code of wdftool where also README.TXT and src folder is located
compilation:
open CMake (cmake-gui), select the path to the CMakeLists.txt for source and binaries, click 'Configure', choose VS 2010.
If configure fails, simply try again or check preparations, I often had to retry, there must be a bug in CMake.
When configure passed, press 'Generate', afterwards you should have the VS2010 project files to compile the wdftool.
There should be a 'WDFTool.sln' file, open it, this should start up Visual Studio.
In Visual Studio, you then should be able to compile without further project configuration.

However I found two things to fix in the sourcecode. One is in SDL_Line.h, there it should be "#include <SDL.h>" instead of "#include <SDL/SDL.h>" in line 8. (depends on installation- and include paths ofc)
The other is a real bug, in line 181 of wdfObjects.hpp the buf size should at least be 21 not 16, else you get a buffer overflow during runtime eventually causing a stack error like I had!
(and just as a note, I'd recommend stringstreams to be used instead of sprintf)

That's it and I find this tool a real nice attempt and am eager to see more. :)

cheers
User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: WDF files deciphered!

Post by QuasarDonkey »

That's awesome flocke, I'll include the CMake file in the source distribution when I have some time. It looks like it should solve the problems I was having building on Windows :)
Flocke wrote:However I found two things to fix in the sourcecode. One is in SDL_Line.h, there it should be "#include <SDL.h>" instead of "#include <SDL/SDL.h>" in line 8. (depends on installation- and include paths ofc)
You're correct, this is a bug. SDL_Line is some code I pulled from another old project, I'll fix that.
Flocke wrote:The other is a real bug, in line 181 of wdfObjects.hpp the buf size should at least be 21 not 16, else you get a buffer overflow during runtime eventually causing a stack error like I had!(and just as a note, I'd recommend stringstreams to be used instead of sprintf)
I can't believe I made such a noobish mistake! You're right, I should be using stringstreams.

Thanks again flocke. I'll upload the fixes as soon as I can.

P.S. I've been playing around with trek.exe in IDA for the last few days (it's addictive); I've identified a lot of functions, I might chat with you soon about it.
User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: WDF files deciphered!

Post by QuasarDonkey »

Hey DCER, I missed your message. I hadn't really been on AFC the last few days.
DCER wrote:as you've probably noticed I managed to add wdf editing to UE based on the info you provided. Thanks again for posting it. Hope you stick around and help uncover more botf secrets
That's awesome! I'll check it out. Hopefully I'll have more secrets to reveal soon :twisted:
User avatar
QuasarDonkey
Code Analyst
Code Analyst
Posts: 433
Joined: Tue Jul 26, 2011 8:29 pm
Location: Ireland

Re: WDF files deciphered!

Post by QuasarDonkey »

I kinda forgot about this. I don't know if people are still using wdftool, but I noticed a few downloads recently, so I've decided to update it for the sake of completeness. Here you can get the latest version of wdftool:
http://sourceforge.net/projects/botfwdftools/files
I've fixed the bugs that Flocke pointed out. (thanks!)

And I've also added a new feature where right clicking reverses the order the of the objects being clicked, so if one widget is covering another and you need to get it's info, just right click to get the obstructed object's info. Other than that, it's the same as before.
User avatar
Peter1981
Rear-Admiral
Rear-Admiral
Posts: 1118
Joined: Tue May 06, 2008 2:00 am
Location: England

Re: WDF files deciphered!

Post by Peter1981 »

QuasarDonkey -- Really just wanted to say well done on this and keep up your hard work, I'm using the version in UE based on your work and I'm loving it.
Post Reply

Return to “WDF files + wdfedit & wdftool & basic wdf file info”