d2lmirrors / anolis

Anolis is the underlying project for the XPize and Vize resource switchers for Windows XP and Vista respectivly. The codebase allows for the easy swapping around of resources within Win32 executables and other files. (just adding some missing data)
GNU General Public License v2.0
1 stars 0 forks source link

ResourceEnumerator issues when loading a DLL file #23

Closed Dobby233Liu closed 1 year ago

Dobby233Liu commented 1 year ago

creation date = 2009-02-28T18:32:51.507-08:00

Bug in Anolis Resourcer 0.8 Beta:   Bug invoked when loading a DLL. In my case, error when loading 7-Zip's 7z.dll, navigating, and loading 7z.dll again... I dunno... (Can be caused when using the recent items list or the open files-navigate to folder list.)   W3bbo: dang, I saw this error /once/ before but couldn't repro W3bbo: my ResourceEnumerator class is a bit of a hack, I knew this would happen someday   -------------------------------Debug report below-------------------------------  

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.
 
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at Anolis.Core.ResourceEnumerator.MoveNext() in C:\Documents and Settings\David\My Documents\Visual Studio Projects\Anolis\Anolis.Core\Core\ResourceEnumerator.cs:line 41
   at Anolis.Core.ResourceSource.get_HasUnsavedChanges() in C:\Documents and Settings\David\My Documents\Visual Studio Projects\Anolis\Anolis.Core\Core\ResourceSourcePartial.cs:line 49
   at Anolis.Resourcer.MainForm.SourceUnload() in C:\Documents and Settings\David\My Documents\Visual Studio Projects\Anolis\Anolis.Resourcer\Forms\MainForm.Partial.cs:line 123
   at Anolis.Resourcer.MainForm.SourceLoad(String path, Boolean removeFromMruOnError) in C:\Documents and Settings\David\My Documents\Visual Studio Projects\Anolis\Anolis.Resourcer\Forms\MainForm.Partial.cs:line 67
   at Anolis.Resourcer.MainForm.SourceLoadDialog() in C:\Documents and Settings\David\My Documents\Visual Studio Projects\Anolis\Anolis.Resourcer\Forms\MainForm.Partial.cs:line 57
   at Anolis.Resourcer.MainForm.__tSrcOpen_ButtonClick(Object sender, EventArgs e) in C:\Documents and Settings\David\My Documents\Visual Studio Projects\Anolis\Anolis.Resourcer\Forms\MainForm.cs:line 232
   at System.Windows.Forms.ToolStripSplitButton.OnButtonClick(EventArgs e)
   at System.Windows.Forms.ToolStripSplitButton.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 
 
************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Anolis.Resourcer.Merged
    Assembly Version: 0.8.3330.36117
    Win32 Version: 0.8.0.0
    CodeBase: file:///C:/Documents%20and%20Settings/Stanley/Desktop/Anolis.Resourcer.Merged.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
 
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
 
For example:
 
<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>
 
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Dobby233Liu commented 1 year ago

creation date = 2009-03-04T08:37:50.153-08:00

I think I've fixed it by moving the DataIsLoaded check to GetNextLang and doing a recursive loop there rather than the iterative approach, but I'm haunted by the feeling this might result in a stack overflow.

Dobby233Liu commented 1 year ago

creation date: 2009-03-04T10:38:09.033-08:00

Your problem most likely derives from:

ResourceLang lang = GetNextLang();

            if( _onlyLoaded ) {

                while( !lang.DataIsLoaded ) {

                    lang = GetNextLang();

                    if(lang == null) return false;
                }

There may be the case where you are using the dot operator on lang when it is null (as GetNextLang may return null). Either go for a try/catch, or a do/while instead of while/do, something like this:

ResourceLang lang;

if (_onlyLoaded) do
{
lang = GetNextLang();
if (lang == null) return false;
} 
while (!lang.DataIsLoaded);

This is the safe way of doing it, as while condition doesn't get evaluated if there's no language

Dobby233Liu commented 1 year ago

creation date = 2009-03-04T12:37:19.763-08:00

Thanks dexter, that was the problem.

Disregard my earlier comment at 16:37 today, my recursive approach was buggy and I've since independently came to the same solution as you to use a do/while but I didn't use the guard expression like that. This is my solution:

            ResourceLang lang;

            do {

                lang = GetNextLang();

                if( lang == null ) return false; // lang will be null when all the langs have been iterated through

            } while( _onlyLoaded && !lang.DataIsLoaded );

            _currentData = lang.Data; // this may lazy-load the data
            return true;

It will be included in the next check-in.

Dobby233Liu commented 1 year ago

closed date = 2009-03-14T17:42:28.823-07:00