Welcome
Ladies and Gents:

These forums are now closed and registration disabled.

Please join us at our new forum on Proboards. Our hope is that these new forums are more stable, provide more and better features, and allow continuation of the project forums in a safer, more secure, long term environment.

me3explorer.proboards.com

--The ME3Explorer Team

ME3Logger

Non-toolset utilities for the ME Trilogy developed by community coders. Note: Restricted to coder- or modder-oriented tools. User-oriented tools belong where they can be adequately supported (e.g., Nexusmods).

ME3Logger

Postby Heff » 02 Jul 2015, 19:07

While trying to work out the unknown bytescript opcodes I ran across some assert/debug output functions still in the binary, and figured I'd hook them to see if any useful info was to be found.
Turns out that the game had pretty lousy debug output, and it only ever reports fatal conditions rather than the cause, but it could be useful, so I'm releasing a modified binkw32 dll for anyone that might need it.

What it does:
Short: Logs why the game crashed with your modified pcc file.
Long: Whenever an error occurs on startup / when loading files, it is logged to ME3Log.txt in the folder where the Masseffect3.exe is located.
These errors are not always descriptive, but might be helpful in narrowing down a problem with an edit.
For example, if you had accidentally provided an export ID that was outside the range of the PCC, the game would crash, but an error about the export ID being wrong would be reported to the logfile.

How to use:
Simply place the binkw32.dll in your binaries/Win32 folder, as you would with the dlc unlocker.
I've included the dlc unlock code here as well, so any modders can use this as a replacement for the usual unlocker while still getting the logging.

For those healthily worried about their computer, the source is available on github to compile it yourself.

Note:
The pre-built download requires the Visual C++ 2013 runtime, which can be installed from http://www.microsoft.com/en-US/download ... x?id=40784 if you do not have it already.

Download:
Prebuilt DLL (Bandwidth might be slow, will upload mirrors later.)
Source repo on Github

Credits:
WV for the original binkw32 forwarding code.


Technical notes:
Spoiler:
Based the dll forwarding on WV's available source, and kept the dlc verification patch routines in.
A separate log file is created, and I've patched a hook inside the most common debud/assert printf-variant I could find in the game, bypassing the development check and jumping straight to my own version that simply prints to file.
If this is something that people use, the plan is to extend it to other logging printf-variants, as well as provide some more context in the output by hooking earlier on the loading calls to inspect filemanager classes for context related to the errors.

This first release uses a static offset, I'll replace that with a pattern search this weekend.
Unsure of when origin does it's unpacking in the load-order, possibly this would have to be done delayed as WV's scan currently is.
EDIT: Updated the order so that WV's check runs first, should let origin unpack fine, as per Erik's post.



PS.
This is very much a test release, no guarantees. Any reports of crashes are welcome!
I broke my windows install where I had origin, and thus can't test this on the origin version until the weekend.
Last edited by Heff on 12 Jul 2015, 11:28, edited 3 times in total.

Heff
Coder
 
Posts: 164
Joined: 23 Feb 2015, 20:02
Has thanked: 93 time
Have thanks: 61 time

Re: [Tool] ME3Logger

Postby Erik JS » 02 Jul 2015, 20:21

Heff wrote:but I don't expect it to work on origin as I imagine the dll is loaded before the exe is unpacked, so the currently static offset would be all wrong.


A suggestion:
DWORD WINAPI Start(LPVOID lpParam)
{
// Start the debug logging.
fopen_s(&Log, "ME3Log.txt", "w");
fprintf(Log, "ME3Log - Logging started.\n");
fflush(Log);

// WV's patcher still included for now
WVPatchChecks();


// Set up the DLL forwarding
hLib = InitLibBinkw32();

DetourPrintFunction();

return 0;
}

If you run WV's code first, then it'll eventually hit this:
while ((patch1 = FindPattern(0x401000, 0xE52000, pattern, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 0)) == 0 && count++ < 10)
{
fprintf(WVLog, "Trying again...\n");
Sleep(300);
}

If the pattern wasn't found (due to packed code), the thread sleeps for 300 ms and then tries to find it again (when code may already have been unpacked then).
By running WV's code first, it's more than likely that you'll be handling unpacked code afterwards.

Anyway, good work.
ME3 Private Server Emulator: @ ME3Tweaks | @ SourceForge | @ GitHub | @ Dropbox
Image

Erik JS has been thanked by:
User avatar
Erik JS
User
 
Posts: 124
Joined: 31 Jul 2014, 14:44
Has thanked: 13 time
Have thanks: 77 time

Re: [Tool] ME3Logger

Postby Heff » 02 Jul 2015, 20:27

Erik JS wrote:If the pattern wasn't found (due to packed code), the thread sleeps for 300 ms and then tries to find it again.
By running WV's code first, it's more than likely that you'll be handling unpacked code afterwards.


Thanks for the suggestion, definitely will try that out when I can test on origin!
I think I originally put the WV patch later due to a fear of missing any startup-calls that might happen while it slept, as the interval wasn't very narrow.
For the non-origin version the first search is never found, resulting in the game having a lot of time to encounter errors while loading before I got my hook patched in.
In hindsight it'll be very easy to simply shorten the wait time and it should work quite well.


EDIT:
Just did a quick check and this seems to work just fine for the non-origin version.
Pushed new version up, thanks for the tip!
Heff
Coder
 
Posts: 164
Joined: 23 Feb 2015, 20:02
Has thanked: 93 time
Have thanks: 61 time

Re: [Tool] ME3Logger

Postby WarrantyVoider » 03 Jul 2015, 14:38

congratz and good work! cool that someone makes use of this code^^ thanks for not making me regret releasing it :P

greetz WV
always backup your files!
mess with the best or die like the rest!
"I tried everything!" - "mkay, please list that..." ; please dont pm me for help, we have a help section

WarrantyVoider has been thanked by:
User avatar
WarrantyVoider
Emeritus
 
Posts: 2270
Joined: 22 Aug 2012, 11:33
Has thanked: 480 time
Have thanks: 626 time

Re: [Tool] ME3Logger

Postby giftfish » 11 Jul 2015, 22:30

Just got two errors when trying to use the logger, Heff.

First error was a system popup telling me I was missing MSVCR120.dll. Second, was an actual ME3 error window I've never seen before that said there was a problem with the bink32.dll and my license wasn't valid.

The MSVCR120.dll was giving Kfreon trouble a while back and seemed to be related to 64- and 32-bit variations on Win7.

I can verify that the DLL is on my machine in ME3Explorer's Debug folder.
giftfish
 

Re: [Tool] ME3Logger

Postby Heff » 12 Jul 2015, 11:27

giftfish wrote:Just got two errors when trying to use the logger, Heff.

First error was a system popup telling me I was missing MSVCR120.dll. Second, was an actual ME3 error window I've never seen before that said there was a problem with the bink32.dll and my license wasn't valid.

The MSVCR120.dll was giving Kfreon trouble a while back and seemed to be related to 64- and 32-bit variations on Win7.

I can verify that the DLL is on my machine in ME3Explorer's Debug folder.


Ah, that's most likely me being sloppy, should have specified the needed files.
As I built the .DLL with visual studio 2013, users need to have the Visual C++ 2013 runtime installed for things to work, which I forgot to mention.

If you install http://www.microsoft.com/en-US/download ... x?id=40784, that ought to fix it. The reason for the second error is most likely that the game finds the binkw32 dll, but as it can't load it due to the missing runtime, it figures the dll is invalid. If this doesn't work I'd love to get some more info like screenshots of the error popups.
Heff
Coder
 
Posts: 164
Joined: 23 Feb 2015, 20:02
Has thanked: 93 time
Have thanks: 61 time

Re: [Tool] ME3Logger

Postby giftfish » 12 Jul 2015, 15:11

Heff wrote:Ah, that's most likely me being sloppy, should have specified the needed files.
As I built the .DLL with visual studio 2013, users need to have the Visual C++ 2013 runtime installed for things to work, which I forgot to mention.

From the looks of it, I do have that runtime installed.

In my Programs and Features:

"Microsoft Visual C++ 2013 Redistributable(x64) - 12.0.30501"

Along with a a bunch of others, of course, but that's the only one for 2013.

Is it possible I also need the x86 version? Looks like I have both x86 and x64 installed for the 2012 Runtime.
giftfish
 

Re: [Tool] ME3Logger

Postby Heff » 13 Jul 2015, 05:49

giftfish wrote:Is it possible I also need the x86 version? Looks like I have both x86 and x64 installed for the 2012 Runtime.


Sorry again, I thought I had mentioned that but sunday fatigue seems to have meddled with my writing..
Yes, it is indeed the 32bit version needed in this case. As ME3 is 32bit, the binkw32 dll needs to be 32bit as well, which makes the dependency on the 32bit VS runtime. (as hinted by the number in the dll name.)
Thinking back I probably should try and get hold of the same VS version that WV compiled his binkw32 with, so users wont have to install a new runtime if they had that dll working, but for now they'll have to.

Really hoping that installing the runtime fixes the problem, otherwise I have a weird problem on my hands, and weird problems tend to take too much time :D.
Heff
Coder
 
Posts: 164
Joined: 23 Feb 2015, 20:02
Has thanked: 93 time
Have thanks: 61 time

Re: [Tool] ME3Logger

Postby giftfish » 13 Jul 2015, 13:17

@Heff -- No problem. I'll try installing it later today and see if it works. Then maybe it can help diagnose my issue with the Eva scene :)
giftfish
 

Re: [Tool] ME3Logger

Postby Heff » 14 Jul 2015, 07:57

A new version is up:
Now prints a small stack trace which is handy when doing lookups in IDA/Olly.
Switched printf to inline ASM to extract the stack.

For normal users this should not mean any difference, but please do update anyway so that when you ask for help regarding your log there is more data for others to work with :)
Heff
Coder
 
Posts: 164
Joined: 23 Feb 2015, 20:02
Has thanked: 93 time
Have thanks: 61 time

Next

Return to Third-Party Utilities

Who is online

Users browsing this forum: No registered users and 1 guest

suspicion-preferred