Author Topic: How to use the plugins of old SDK for new CodeBlocks?  (Read 5995 times)

Offline gonboy

  • Multiple posting newcomer
  • *
  • Posts: 29
How to use the plugins of old SDK for new CodeBlocks?
« on: September 03, 2012, 04:41:21 am »
Hello:
I have some old plugins for Codeblocks? But the plugins is stop developping and I couldn't find the source.

I copy the plugins (*.dll and *.zip)to my build Codeblocks,to run app.
show some info like below:
==============================================
one or more plugins were not loaded.
this usually happens when a plugins is build for a different version of the Code::Blocks sdk
check the application log for more info

==============================================
How Can I use the old plugins for my Codeblocks?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: How to use the plugins of old SDK for new CodeBlocks?
« Reply #1 on: September 03, 2012, 05:23:11 am »
Unlikely that you will be able to get the old binaries to work. They will need to be tweaked for changes in the SDK and recompiled. What plugins are they? Do you have sources?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: How to use the plugins of old SDK for new CodeBlocks?
« Reply #2 on: September 03, 2012, 05:23:46 am »
Quote
How Can I use the old plugins for my Codeblocks?
I think there is no such way.

The newer Codeblocks (SDK) has some interface changed, which means you can't use the old plugins for the new interface. I think the only way is : you find the plugin's source, and build them against the newer SDK.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline gonboy

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: How to use the plugins of old SDK for new CodeBlocks?
« Reply #3 on: September 03, 2012, 05:57:54 am »
Couldn't find source! That's previous enginerr's plugin,he leave office.


the Codeblocks how to find the plugins isn't suitable for App?

Can I change *.dll or *.zip ,
eg
change some version bytes to cheat the APP?

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: How to use the plugins of old SDK for new CodeBlocks?
« Reply #4 on: September 03, 2012, 06:44:43 am »
I had been working on the following patch.  It adds an option to tell Code::Blocks to ignore version numbers and load plugins anyway.  You can test it if you like.  (Be warned that just because this allows the plugin to be loaded does not mean it will actually work.)
Code
Index: src/sdk/pluginsconfigurationdlg.cpp
===================================================================
--- src/sdk/pluginsconfigurationdlg.cpp (revision 8330)
+++ src/sdk/pluginsconfigurationdlg.cpp (working copy)
@@ -67,7 +67,8 @@
     // install options
     ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("plugins"));
     bool globalInstall = cfg->ReadBool(_T("/install_globally"), true);
-    bool confirmation = cfg->ReadBool(_T("/install_confirmation"), true);
+    bool confirmation  = cfg->ReadBool(_T("/install_confirmation"), true);
+    bool ignoreVersion = cfg->ReadBool(_T("/ignore_version"), false);
 
     // verify user can install globally
     DirAccessCheck access = cbDirAccessCheck(ConfigManager::GetFolder(sdPluginsGlobal));
@@ -79,6 +80,7 @@
     }
     XRCCTRL(*this, "chkInstallGlobally", wxCheckBox)->SetValue(globalInstall);
     XRCCTRL(*this, "chkInstallConfirmation", wxCheckBox)->SetValue(confirmation);
+    XRCCTRL(*this, "chkIgnoreVersion", wxCheckBox)->SetValue(ignoreVersion);
 
     // Set default font size based on system default font size
 #ifdef __linux__
@@ -443,6 +445,7 @@
 
     cfg->Write(_T("/install_globally"), XRCCTRL(*this, "chkInstallGlobally", wxCheckBox)->GetValue());
     cfg->Write(_T("/install_confirmation"), XRCCTRL(*this, "chkInstallConfirmation", wxCheckBox)->GetValue());
+    cfg->Write(_T("/ignore_version"), XRCCTRL(*this, "chkIgnoreVersion", wxCheckBox)->GetValue());
 
     wxScrollingDialog::EndModal(retCode);
 }
Index: src/sdk/resources/plugins_configuration.xrc
===================================================================
--- src/sdk/resources/plugins_configuration.xrc (revision 8330)
+++ src/sdk/resources/plugins_configuration.xrc (working copy)
@@ -55,11 +55,18 @@
                                     </object>
                                     <object class="sizeritem">
                                         <border>5</border>
-                                        <flag>wxALL|wxALIGN_LEFT|wxALIGN_TOP|wxEXPAND</flag>
+                                        <flag>wxTOP|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP</flag>
                                         <object class="wxCheckBox" name="chkInstallConfirmation">
                                             <label>Ask for confirmation if conflicts arise.</label>
                                         </object>
                                     </object>
+                                    <object class="sizeritem">
+                                        <object class="wxCheckBox" name="chkIgnoreVersion">
+                                            <label>Ignore SDK version mismatch. Do not check unless you know what you are doing!</label>
+                                        </object>
+                                        <flag>wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP</flag>
+                                        <border>5</border>
+                                    </object>
                                 </object>
                             </object>
                         </object>
Index: src/sdk/pluginmanager.cpp
===================================================================
--- src/sdk/pluginmanager.cpp (revision 8330)
+++ src/sdk/pluginmanager.cpp (working copy)
@@ -702,7 +702,10 @@
                     PLUGIN_SDK_VERSION_MINOR,
                     PLUGIN_SDK_VERSION_RELEASE);
         Manager::Get()->GetLogManager()->LogError(fmt);
-        return;
+        if (Manager::Get()->GetConfigManager(wxT("plugins"))->ReadBool(wxT("/ignore_version"), false))
+            Manager::Get()->GetLogManager()->LogWarning(_("    SDK version ignored, loading ") + name + _(" anyways. Beware of side effects!"));
+        else
+            return;
     }
 
     // all done

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: How to use the plugins of old SDK for new CodeBlocks?
« Reply #5 on: September 03, 2012, 09:09:38 am »
It adds an option to tell Code::Blocks to ignore version numbers and load plugins anyway.
Oh dear... why would you want to do this?! :o ??? You basically screw our crash protection in case the SDK changes.

This will definitely not make it into trunk. For re-compiling 3rd party plugins in an easy way if really needed (in case SDK version changed) I've prepared an article in the WiKi based on nightly builds. An alternative is always to wait for the next nightly.

For 3rd party plugin developers I can offer the following in advance:
If their repo is based on subversion we can integrate it as remote repository into the main C::B repo. Then it remains independent but people can easily have the sources from one place. (Like we did with the FortranProject plugin for example).

Surely this requires maintaining the plugin to at least SDK compatibility. If a 3rd party plugin seem dead one can ask to take ownership of an existing repo to continue development.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline gonboy

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: How to use the plugins of old SDK for new CodeBlocks?
« Reply #6 on: September 03, 2012, 12:20:25 pm »
I Check the DLL file.
Codeblocks couldn't
    wxDynamicLibrary* LoadLibrary(const wxString& filename)
so failed.

=============================================
    wxDynamicLibrary* LoadLibrary(const wxString& filename)
    {
        Libs::iterator it = s_Libs.find(filename);
        if (it != s_Libs.end())
        {
            // existing lib./codeblocks
            it->second.ref++;
            return it->second.lib;
        }
        // new lib
        it = s_Libs.insert(s_Libs.end(), std::make_pair(filename, RefCountedLib()));
        it->second.lib = new wxDynamicLibrary;
        it->second.ref = 1;
        it->second.lib->Load(filename);
        return it->second.lib;
    }
=============================================
Normal DLL the last lines ,as follows:
Offset      0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F
000C9960   6F 67 45 76 00 5F 5F 5A  4E 4B 38 77 78 57 69 6E   ogEv.__ZNK8wxWin
000C9970   64 6F 77 31 34 47 65 74  53 63 72 6F 6C 6C 54 68   dow14GetScrollTh
000C9980   75 6D 62 45 69 00 5F 5F  5A 54 49 53 74 39 65 78   umbEi.__ZTISt9ex
000C9990   63 65 70 74 69 6F 6E 00  5F 5F 5A 4E 31 32 77 78   ception.__ZN12wx
000C99A0   53 74 72 69 6E 67 48 61  73 68 31 36 77 78 43 68   StringHash16wxCh
000C99B0   61 72 53 74 72 69 6E 67  48 61 73 68 45 50 4B 77   arStringHashEPKw
000C99C0   00    
              
But My the Dll is :
Offset      0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F
00046160   70 3F 7C 3F 80 3F 84 3F  88 3F 8C 3F 90 3F 94 3F   p?|?€??????
00046170   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
00046180   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
00046190   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
000461A0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
000461B0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
000461C0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
000461D0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
000461E0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
000461F0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................                             .

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: How to use the plugins of old SDK for new CodeBlocks?
« Reply #7 on: September 03, 2012, 03:41:22 pm »
It adds an option to tell Code::Blocks to ignore version numbers and load plugins anyway.
Oh dear... why would you want to do this?! :o ??? You basically screw our crash protection in case the SDK changes.

This will definitely not make it into trunk.
I was not planning on submitting it.  My purpose was simple convenience for not having to relink my plugins as often.  (And it has a checkbox - off by default :).)

I Check the DLL file.
Codeblocks couldn't
    wxDynamicLibrary* LoadLibrary(const wxString& filename)
so failed.
                        .
I sort of expected as much... my patch does not have any magic code in it.  All it does is let Code::Blocks try to load the plugin.
If you do not have access to the plugin's source, it seems your only real option to use the plugin would to stay with an older version Code::Blocks.