Old 10-01-2019, 06:23 AM   #41
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Quote:
Originally Posted by Xenakios View Post
Regarding the "simple extension" plugin doing nothing, which code are you specifically talking about? If it's the code I posted, you should see a message on the Reaper console
Yep the file name was inappropriate.

I finally renamed the dll to reaper_re_test.dll.

But how do I see the " Reaper console" ?

I found actions to open the debug console -> same is empty and never occurs when starting Reaper.
and to open "ReaConsole" -> allows for inputting some command.

-Michael

Last edited by mschnell; 10-01-2019 at 06:28 AM.
mschnell is offline   Reply With Quote
Old 10-03-2019, 10:30 PM   #42
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Any answer to how do I see the " Reaper console" ?

Thanks,

-Michael
mschnell is offline   Reply With Quote
Old 10-04-2019, 02:28 AM   #43
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,806
Default

It opens by itself when ShowConsoleMsg is called.
cfillion is offline   Reply With Quote
Old 10-04-2019, 02:21 PM   #44
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Supposedly this is what the "simple extension" does. So obviously I did not yet correctly install it.

-Michael
mschnell is offline   Reply With Quote
Old 10-04-2019, 03:03 PM   #45
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,806
Default

Perhaps a 32-bit vs 64-bit mismatch between the dll and REAPER?
cfillion is offline   Reply With Quote
Old 10-08-2019, 06:08 AM   #46
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

I verified that it's compiled for 64 Bit (and that Reaper is "Reaper (x64)".

I re-compiled as "Release", instead of Debug.

I moved the file as "reaper_re_test.dll" in the same directory ( c:\Users\mschnell\AppData\Roaming\REAPER\UserPlugi ns ) as Reapeck resided (as reaper_reapack64.dll ).

But I don't see anything .

Thanks for any further tips,

-Michael
mschnell is offline   Reply With Quote
Old 10-08-2019, 06:36 AM   #47
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,806
Default

You mentioned before this was a "minimal extension", but is it my barebone extension example, Xenakios's one or something else? Can you share the problematic DLL and source code?
cfillion is offline   Reply With Quote
Old 10-08-2019, 06:56 AM   #48
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

Quote:
Originally Posted by mschnell View Post

But I don't see anything .
The extension may be failing when it loads the API functions, in that case it just returns failure to Reaper before it even gets to showing the message. edit : Well, actually if it's the super simple code I posted, that doesn't even check the function is properly loaded, but Reaper would just crash if that failed. So apparently Reaper isn't even attempting to load the .dll for some reason.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 10-08-2019 at 07:02 AM.
Xenakios is online now   Reply With Quote
Old 10-08-2019, 06:58 AM   #49
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Seemingly even something else.

I compiled all three and the dlls I get are identical with only differences in two or three bytes.

I doubt that the code in main.-cpp is compiled in to the dll at all but I just get some kind of "dll frame"

-Michael
mschnell is offline   Reply With Quote
Old 10-08-2019, 07:03 AM   #50
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

Quote:
Originally Posted by mschnell View Post
I doubt that the code in main.-cpp is compiled in to the dll at all but I just get some kind of "dll frame"
Well, it isn't compiled into the dll if you haven't added the file into your VS project...(Or if you somehow managed to exclude the file from the build. The file name will have a white and red "-" sign with it in that case.)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 10-08-2019 at 07:08 AM.
Xenakios is online now   Reply With Quote
Old 10-08-2019, 07:03 AM   #51
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

OK. I tested this by writing some ninsend in main.cpp and I don't even get an error message

There is a file "dllmain.cpp in this project that seems to get compiled. But where to place this code I was provided in the forum ?

-Michael
mschnell is offline   Reply With Quote
Old 10-08-2019, 07:05 AM   #52
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,806
Default

Quote:
Originally Posted by mschnell View Post
I compiled all three and the dlls I get are identical with only differences in two or three bytes.
Then the compiler built the same source code, not three different ones (the few different bytes are likely the timestamp or some other ID).

Try building my example using the command line provided at the top and Xenakios's one using the provided .bat file.
cfillion is offline   Reply With Quote
Old 10-08-2019, 07:13 AM   #53
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

The dll project Visual Studio generates by default kind of sucks. I usually remove all the files it generates, add my own manually, and turn off using the precompiled headers thing. (If that is on, it requires some of the autogenerated files to be in the project.)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 10-08-2019, 07:31 AM   #54
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

I see.

For the moment I added main.cpp to the project and I could compile the original test code (after enabling "atoi" by adding "#include <stdlib.h>"m, and I got a much bigger DLL file (but no change when trying it).


I'll retry this but not much hope....

[edit]

Of course after removing the files from the project and just adding the main.cpp file with the suggested code, Studio does not compile the project but sais:

Severity Code Description Project File Line Suppression State
Error C1083 Cannot open precompiled header file: 'x64\Debug\Dll1.pch': No such file or directory Dll1 C:\Users\mschnell\source\repos\Dll1\main.cpp 1

(In fact i have no idea what "precompiled header file" means.)

-Michael

Last edited by mschnell; 10-08-2019 at 07:37 AM.
mschnell is offline   Reply With Quote
Old 10-17-2019, 06:34 AM   #55
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

After a lot of tweaking trying to overcome problems supposedly introduced by Visual Studio, I was able to compile the "simple-reaper-extension-plugin", but I get an error when linking.

I created a Visual Studio "Dynamic Link Library (DLL)" project and replaced the code in the automatically created dllmain.dll" by the code provided here. I also needed to create the two reaper*.h files internally in Visual Sudio and paste the content in there, as otherwise (when using a binary copy of the files) Visual Studio would not accept them as Header files.

The remaining errors are these:

Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol "char const * (__cdecl* GetExtState)(char const *,char const *)" (?GetExtState@@3P6APEBDPEBD0@ZEA) Dll3 C:\Users\mschnell\source\repos\Dll3\dllmain.obj 1

I get such errors for the functions that are defined by IMPAPI(...) :
GetExtState, GetProjectPath, GetResourcePath, HasExtState, InsertMedia, Main_On_command, and SetExt State.

Seemingly the "nasty Macro" called IMPAPI seems not to work as expected in Visual Studio 2019 .

How to proceed ?
-Michael
mschnell is offline   Reply With Quote
Old 10-17-2019, 07:11 AM   #56
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

Quote:
Originally Posted by mschnell View Post
A
I get such errors for the functions that are defined by IMPAPI(...) :
GetExtState, GetProjectPath, GetResourcePath, HasExtState, InsertMedia, Main_On_command, and SetExt State.

Seemingly the "nasty Macro" called IMPAPI seems not to work as expected in Visual Studio 2019 .
Maybe too old Reaper SDK headers. Or too new ones, so that they would still work with the IMPAPI monstrosity. The recommended way these days to import the API functions is to use the function that loads them all at once.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 10-17-2019, 02:26 PM   #57
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Quote:
Originally Posted by Xenakios View Post
Maybe too old Reaper SDK headers. Or too new ones, so that they would still work with the IMPAPI monstrosity.
Maybe too new.
Quote:
Originally Posted by Xenakios View Post
The recommended way these days to import the API functions is to use the function that loads them all at once.
Sorry, but I have no idea what function you are speaking of.

I seem to understand that the functions in question are calls from the DLL into Reaper, But that is all I grasp here.

-Michael
mschnell is offline   Reply With Quote
Old 10-17-2019, 03:15 PM   #58
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,639
Default

It's the one about 2/3 down reaper_plugin_functions.h :
Code:
#ifdef REAPERAPI_IMPLEMENT
  int REAPERAPI_LoadAPI(void *(*getAPI)(const char *))
  {
      ... etc
      return failcnt;
  }
You can see it's only available if REAPERAPI_IMPLEMENT is defined.

Here's it used in the main.cpp for the extension I posted...
Code:
#define REAPERAPI_IMPLEMENT
#include "reaper_plugin_functions.h"
#include "extension_api.hpp"


extern "C" REAPER_PLUGIN_DLL_EXPORT
auto ReaperPluginEntry(REAPER_PLUGIN_HINSTANCE hInstance, reaper_plugin_info_t* rec)
  -> int 
{
    if (!rec) return 0;
 
    if (auto fail_count = REAPERAPI_LoadAPI(rec->GetFunc) > 0)
        return 0; 
        
    API::construct();
    return 1; 
}
snooks is offline   Reply With Quote
Old 10-17-2019, 10:05 PM   #59
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Thanks !
I'll give it a try ASAP .
-Michael
mschnell is offline   Reply With Quote
Old 10-18-2019, 02:11 AM   #60
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Trying to add the "API::" code I get the error messages
" 'API': is not a class or namespace name "
" 'construct': identifyer not found " (obviously)
" function 'int ReaperPluginEntry(HINSTANCE,reaper_plugin_info_t *)' already has a body" (I understand I need to integrate the "API::" code in the existing "REAPER_PLUGIN_ENTRYPOINT" function, but with this "API" till is unknown )

But nonetheless I happily experience a kind of success !!!
I added
Code:
  #define REAPERAPI_IMPLEMENT
  #define REAPERAPI_MINIMAL  
  #define REAPERAPI_WANT_SetExtState
  #define REAPERAPI_WANT_Main_OnCommand
  #define REAPERAPI_WANT_InsertMedia
  #define REAPERAPI_WANT_GetProjectPath
  #define REAPERAPI_WANT_GetResourcePath
  #define REAPERAPI_WANT_GetExtState
  #define REAPERAPI_WANT_HasExtState
  #undef  IMPAPI
  #define IMPAPI(x) x
to the source code of the miniimal extension.

It does happily compile !
So I renamed the dll to reaper_re_test.dll.

When I now start Reaper it crashes.

In the crash dialogue I can start the debugger and Visual Studio comes up correctly with my dll Prokect and supposedly correctly shows an "unhandled exception" in the line
Code:
  const char* numberString = GetExtState("simple_extension", "toggleaction_state");
So obviously the back-link from the dll to Reaper is not installed because I was not able to add the "API::" code snippet.

-Michael

Last edited by mschnell; 10-18-2019 at 02:23 AM.
mschnell is offline   Reply With Quote
Old 10-18-2019, 02:32 AM   #61
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

I just commented out the "API::" line and so in the initialization phase just "REAPERAPI_LoadAPI(rec->GetFunc)" is called.

Starting Reaper now does not crash any more, but still, no Console window is shown.

To verify the result of REAPERAPI_LoadAPI(rec->GetFunc) I would need to debug the dll., But I still have no idea how it should be possible to set a breakpoint in a dll

-Michael
mschnell is offline   Reply With Quote
Old 10-18-2019, 02:41 AM   #62
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

Quote:
Originally Posted by mschnell View Post
Starting Reaper now does not crash any more, but still, no Console window is shown.

To verify the result of REAPERAPI_LoadAPI(rec->GetFunc) I would need to debug the dll., But I still have no idea how it should be possible to set a breakpoint in a dll
It's now completely unclear to me, what source code are you even trying to build and run. Can you please clarify that?

To debug a dll with breakpoints, you can set the host application to be the debugging "command" in Visual Studio.




While I find the idea very annoying, I guess I can create and upload a Visual Studio solution set up to build a working Reaper extension dll. *Hopefully* the solution will open and build without issues. (The issue I have with sharing Visual Studio solutions/projects is that they are prone to errors/problems when shared. There might always be some file path or setting etc I have that isn't going to work on someone else's system.)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 10-18-2019 at 03:30 AM.
Xenakios is online now   Reply With Quote
Old 10-18-2019, 03:12 AM   #63
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

Here's the minimal Visual Studio 2017 solution/project :

https://drive.google.com/open?id=175...L4eHd0snowryVP

Configured and tested only for 64 bit (x64) builds. If 32 bit (x86) builds are required, the character set needs to be set to Multibyte and precompiled headers need to be turned off. There is no compatibility for Swell in the project, but that's basically about just adding a few files from WDL. The only thing the extension does is that it loads the Reaper API functions and shows a message in the Reaper console, if the plugin loaded successfully. It uses the reaper_plugin_functions.h file generated by a recent build of Reaper, so you should be using at least the latest released 64 bit Reaper version when testing.

Don't try adding any of your own code etc before you've confirmed this exact VS solution builds and runs for you.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 10-18-2019 at 03:26 AM.
Xenakios is online now   Reply With Quote
Old 10-18-2019, 04:20 AM   #64
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Quote:
Originally Posted by Xenakios View Post
It's now completely unclear to me, what source code are you even trying to build and run. Can you please clarify that?
It starts like this;

Code:
#include "pch.h"

//#ifdef never 

// Xenakios ????

// check if the build environment is Windows, and then include the Windows API header,
// else include SWELL which provides functions with the same names but are implemented
// for another operating system (namely, OS-X)

#ifdef _WIN32
#include <windows.h>
#else
#include "../../WDL/swell/swell.h"
#endif

#include "stdio.h"
#include <stdlib.h>

// super nasty looking macro here but allows importing functions from Reaper with simple looking code
#define IMPAPI(x) if (!((*((void **)&(x)) = (void *)rec->GetFunc(#x)))) errcnt++;

...


// Action default keyboard shortcut and action text set here
gaccel_register_t acreg01 = { {0,0,0},"Simple extension test action" };
gaccel_register_t acreg02 = { {0,0,0},"Simple extension togglable test action" };

// *** HERE THE ACTIONS DO THEIR WORK ***

void doAction1()
{
    MessageBox(g_parent, "Hello World!", "Reaper extension API test", MB_OK);
}

// global variable to hold the toggle state of the togglable action
// each togglable action of course needs its own variable for this...

int g_togglestate; // will be inited in main() function to 0 or value from ini-file

void doAction2()
{
    // this action does nothing else but toggles the global variable that keeps track of the toggle state
    // so it's useless as such but you can see the action state changing in the toolbar buttons and the actions list
...

Quote:
Originally Posted by Xenakios View Post
To debug a dll with breakpoints, you can set the host application to be the debugging "command" in Visual Studio.
I already found out this, but when Visual studio tries to start reaper for debugging, seemingly Windows does not let it do so (some German error message about the exe file) Do I need to do this with a portable Reaper installation ? Do I need to do that as administrator ?



-Michael
mschnell is offline   Reply With Quote
Old 10-18-2019, 04:36 AM   #65
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

Quote:
Originally Posted by mschnell View Post
It starts like this;

Code:
...old unsupported code...
I already found out this, but when Visual studio tries to start reaper for debugging, seemingly Windows does not let it do so (some German error message about the exe file) Do I need to do this with a portable Reaper installation ? Do I need to do that as administrator ?
Yeah, that code example is ancient, I haven't tested or supported it in any way for years. I guess I should clean up any references to it from my forum posts and so on...

Sorry, no idea about Windows not wanting to debug with Reaper.exe. For me it works with a regular Reaper installation, as a normal user. If you just can't get the debugger to work, then I guess your only chance is to debug by outputting messages with the OutputDebugString win32 function and looking at them with the Dbgview.exe program. https://docs.microsoft.com/en-us/sys...oads/debugview
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 10-23-2019, 02:19 PM   #66
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

It seems a virus scanner is blocking executables from being debugged

-Michael
mschnell is offline   Reply With Quote
Old 10-27-2019, 06:51 AM   #67
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

Quote:
Originally Posted by mschnell View Post
It seems a virus scanner is blocking executables from being debugged

-Michael
Add exceptions to the virus scanner for all the relevant folders? (Reaper's main folder, your UserPlugins folder, your code development folders...)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 10-27-2019, 04:32 PM   #68
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,018
Default

Thanks.

I'll check if this is possible...
-Michael
mschnell is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:39 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.