Posted By: AndrewAMD
DLL import works - then "Error 111: Crash in script" - 04/08/17 13:51
First of all, this works in zorro script alone (zorro 1.54.5):
My objective is to replace the first function with a DLL (as a learning exercise).
I built a dll in VC++2017 with this in the main file:
In zorro, I made hellozorro.h:
Finally, my zorro script looks like this:
Outputs attached. I get an "Error 111: Crash in script". If I'm lucky, I'll even crash Zorro too at random!
Here's what I tried, to no avail:
Code:
void hellozorro (char* message) { strcpy(message, "Hello, Zorro!"); return; } void nl() { printf("\n"); return; } void dothis() { char message[101]; hellozorro(message);printf("%s",message); nl(); strcpy(message,"test1"); printf("%s",message); nl(); hellozorro(message);printf("%s",message); nl(); strcpy(message,"test2"); printf("%s",message); nl(); hellozorro(message);printf("%s",message); nl(); strcpy(message,"test3"); printf("%s",message); nl(); return; } int main() { dothis(); printf("We made it to the end!"); nl(); return(0); }
My objective is to replace the first function with a DLL (as a learning exercise).
I built a dll in VC++2017 with this in the main file:
Code:
#include "stdafx.h" #include <string> #define DLLEXPORT extern "C" __declspec(dllexport) DLLEXPORT void hellozorro(char* output) { strcpy(output, "Hello, Zorro!"); return; }
In zorro, I made hellozorro.h:
Code:
#include <windows.h> void WINAPI hellozorro(char*); API(hellozorro,hellozorro)
Finally, my zorro script looks like this:
Code:
#include <hellozorro.h> void nl() { printf("\n"); return; } void dothis() { char message[101]; hellozorro(message);printf("%s",message); nl(); strcpy(message,"test1"); printf("%s",message); nl(); hellozorro(message);printf("%s",message); nl(); strcpy(message,"test2"); printf("%s",message); nl(); hellozorro(message);printf("%s",message); nl(); strcpy(message,"test3"); printf("%s",message); nl(); return; } int main() { dothis(); printf("We made it to the end!"); nl(); return(0); }
Outputs attached. I get an "Error 111: Crash in script". If I'm lucky, I'll even crash Zorro too at random!
Here's what I tried, to no avail:
- Switch between /MD and /MT build modes
- Rebuild solution in VC++2013.
Description: zorro only output
Description: zorro with DLL output
Description: zorro script
Description: dll file