1. Question - open_dll()
- Posted by jessedavis Aug 12, 2016
- 1558 views
I have a couple of C (NOT Cpp) routines that I thought it would be nice to access from Euphoria. I packaged them in a .dll file. I cannot open the file with open_dll() function and I don't understand why. I'm obviously missing something very basic.
atom user32 = open_dll("user32.dll")
The above works OK.
atom dll_pntr = open_dll("eu.dll")
The above does not. It returns dll_pntr = 0 which says that euphoria was unable to find the file. Now, the two .dll files are in the same directory. I have also tried complete path names.
I have checked out the eu.dll library with a dll viewer and the functions are inside with addresses and indexes that look OK. I wrote a small C program that uses this .dll and it works fine.
A little help would be greately appreciated.
Thanks in advance,
jd
2. Re: Question - open_dll()
- Posted by unsteady Aug 12, 2016
- 1547 views
I have a somewhat similar problem. I have several customers using some of the software I created under Euphoria. I also created a namespace with the name EU_. Now some reports from my customers are coming back about a conflict within the software. I tried to make a different version of Euphoria to enable changeing EU: to EUPH:, but I do no know exactly how to do this.
3. Re: Question - open_dll()
- Posted by petelomax Aug 13, 2016
- 1500 views
It returns dll_pntr = 0 which says that euphoria was unable to find the file. Now, the two .dll files are in the same directory. I have also tried complete path names.
I have checked out the eu.dll library with a dll viewer and the functions are inside with addresses and indexes that look OK. I wrote a small C program that uses this .dll and it works fine.
A little help would be greatly appreciated.
First, double and treble check 32 vs 64 bit - the dll and the eui.exe[?] you are using. If it's not that, it's a path issue.
Run procmon against both. Add a filter of Path/ends with/.dll when you first run it (it will be preserved for the second run). Be sure to stop capture (the light blue microphone) asap once the test is done. There will be plenty of red herrings, but you should be able to see where it is looking, and succeeding/failing, and figure out the difference between the one that works and the one that does not. Save the results (as .PML) so you can switch between the two, and/or as .CSV, so you can post bits here. If you get really stuck, post the .dll and C test program somewhere and I'll give it a spin (but since it is likely a path issue, that may not help).
If you download a copy of Phix, there is a demo\arwendemo\filedumpN.exw that might help (but probably won't, and I've only ever tested that on Phix, not OE).
Pete
4. Re: Question - open_dll()
- Posted by petelomax Aug 13, 2016
- 1483 views
Now some reports from my customers are coming back about a conflict within the software.
If you post something more specific, someone here might be able to help.
Pete
5. Re: Question - open_dll()
- Posted by jessedavis Aug 14, 2016
- 1447 views
OK, I ran the process logger and found the following for my .dll (now called beu.dll to avoid any confusion with eu):
"2:40:17.4151586 PM","euiw.exe","4272","CreateFile","C:\Users\Jesse\Software\Euphoria\dll_test\beu.dll","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"2:40:17.4152695 PM","euiw.exe","4272","QueryBasicInformationFile","C:\Users\Jesse\Software\Euphoria\dll_test\beu.dll","SUCCESS","CreationTime: 8/12/2016 5:08:00 AM, LastAccessTime: 8/12/2016 5:08:00 AM, LastWriteTime: 8/12/2016 4:12:02 AM, ChangeTime: 8/13/2016 2:37:07 PM, FileAttributes: A"
"2:40:17.4153241 PM","euiw.exe","4272","CloseFile","C:\Users\Jesse\Software\Euphoria\dll_test\beu.dll","SUCCESS",""
"2:40:17.4157399 PM","euiw.exe","4272","CreateFile","C:\Users\Jesse\Software\Euphoria\dll_test\beu.dll","SUCCESS","Desired Access: Read Data/List Directory, Execute/Traverse, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a, OpenResult: Opened"
"2:40:17.4158588 PM","euiw.exe","4272","CreateFileMapping","C:\Users\Jesse\Software\Euphoria\dll_test\beu.dll","FILE LOCKED WITH ONLY READERS","SyncType: SyncTypeCreateSection, PageProtection: "
"2:40:17.4161461 PM","euiw.exe","4272","CreateFileMapping","C:\Users\Jesse\Software\Euphoria\dll_test\beu.dll","SUCCESS","SyncType: SyncTypeOther"
"2:40:17.4164209 PM","euiw.exe","4272","CloseFile","C:\Users\Jesse\Software\Euphoria\dll_test\beu.dll","SUCCESS",""
the file beu.dll resides in the C:\Users\Jesse\Software\Euphoria\dll_test\ directory which is the same directory that holds the eu program trying to access the .dll. It would appear that things are going along fine.
include std/dll.e include jd/jd.e atom dll_pntr = open_dll("beu.dll") --also tried atom dll_pntr = open_dll("C:\\Users\\Jesse\\Software\\Euphoria\\dll_test\\beu.dll") printf(1,"dll_pntr = %d\n",dll_pntr)
The above code prints out dll_pntr = 0
I do not follow all of this; however, it seems to me that it discovered the file, got the basic information about it, created a map and then closed it.
I will say that procmon is a neat program. Very useful.
Here is the c code for both the .dll and the test program.
//This is the code inside the .dll created with dev c++ in the C only mode #include <stdio.h> __declspec(dllexport) int add(int a, int b) { return a+b; } __declspec(dllexport) void ftn(void) { puts("Inside DLL\n"); } ----------------------------------------------------- //This is the C test program: #include <stdio.h> __declspec(dllimport) int add(int a, int b); __declspec(dllimport) void ftn(void); int main(void) { ftn(); printf("Answer is: %d\n",add(3,5)); return 1; }
Here is the output of the dll explorer:
add 0x6d3c1430 0x00001430 1 (0x1) Beu.dll ftn 0x6d3c1444 0x00001444 2 (0x2) Beu.dll
I can email you the actual .dll file; however, I think it's OK. Please don't spend too much time on this. It can always remain "just another mystery".
Thanks for your help,
jd
6. Re: Question - open_dll()
- Posted by jessedavis Aug 14, 2016
- 1417 views
Sorry... I forgot to say: 4.0.5 (362497032f33, 2012-10-11) Windows 7 Pro
7. Re: Question - open_dll()
- Posted by ne1uno Aug 14, 2016
- 1434 views
... I forgot to say: 4.0.5 (362497032f33, 2012-10-11) Windows 7 Pro
can you try running eui? by running with euiw, you are intentionally not looking at any error messages that might be generated.
maybe not related: there was an old thread that turned up in a search for dll problems about a conflict in a preprocesser dll because 'add()' was a routine in the backend. http://openeuphoria.org/forum/124939.wc
8. Re: Question - open_dll()
- Posted by jessedavis Aug 14, 2016
- 1419 views
- Last edited Aug 15, 2016
STOP STOP I got it, I'm pretty sure. You were initially correct. It's 64 vs 32 bits. More work is required to verify it but it would seem that DEV C++ produces what it thinks you need rather that what you ask for. My fault, totally.
Have a good weekend and THANKS,
jd
9. Re: Question - open_dll()
- Posted by unsteady Aug 14, 2016
- 1413 views
Now some reports from my customers are coming back about a conflict within the software.
If you post something more specific, someone here might be able to help.
Pete
The problem is two programmers somewhat inexperienced in how Euphoria works. Somebody else had done some work with small programs for businesses using Euphoria and had created groups of files with one group designated as Namespace EU. Then I took over, and continued in similar ignorance and called some namespaces EU and some EU_ and some EU_name. Anyway the point is that there are a lot of small commercial users using these small use programs occasionally and then reporting errors. Looking at their individual problems, I find that if I compile a new version of 4.05 with Euph: as the builtin, most of my stupidity will be hidden and not obstruct the use of the software.