diff --git a/Contrib/System/Source/System.c b/Contrib/System/Source/System.c index cd6edbfe..237259da 100644 --- a/Contrib/System/Source/System.c +++ b/Contrib/System/Source/System.c @@ -27,6 +27,7 @@ int ParamSizeByType[6] = {0, // PAT_VOID (Size will be equal to 1) int z1, z2; // I've made them static for easier use at callback procs int LastStackPlace = 0; int LastStackReal = 0; +DWORD LastError = 0; SystemProc *LastProc = NULL; int CallbackIndex = 0; HINSTANCE g_hInstance; @@ -211,10 +212,15 @@ PLUGINFUNCTION(Call) ParamsOut(proc); } - // Deallocate params if not callback if (proc->ProcResult != PR_CALLBACK) + { + // Deallocate params if not callback ParamsDeAllocate(proc); + // In case of POPT_ERROR - first pop will be proc error + if ((proc->Options & POPT_ERROR) != 0) pushint(LastError); + } + // If proc is permanent? if ((proc->Options & POPT_PERMANENT) == 0) GlobalFree((HANDLE) proc); // No, free it @@ -546,6 +552,9 @@ SystemProc *PrepareProc(BOOL NeedForCall) case 's': temp2 = POPT_GENSTACK; break; + case 'e': + temp2 = POPT_ERROR; + break; } // New Options @@ -626,8 +635,8 @@ void ParamsIn(SystemProc *proc) int i, *place; char *realbuf; - i = 1; - do + i = (proc->ParamCount > 0)?(1):(0); + while (TRUE) { // Step 1: retrive value if ((proc->Params[i].Input == IOT_NONE) || (proc->Params[i].Input == IOT_INLINE)) @@ -684,10 +693,10 @@ void ParamsIn(SystemProc *proc) } #endif + if (i == 0) break; if (i == proc->ParamCount) i = 0; else i++; } - while (i != 1); } void ParamsDeAllocate(SystemProc *proc) @@ -889,6 +898,12 @@ SystemProc __declspec(naked) *CallProc(SystemProc *proc) // Proc result: OK proc->ProcResult = PR_OK; + // In case of POPT_ERROR -> GetLastError + if ((proc->Options & POPT_ERROR) != 0) + { + LastError = GetLastError(); + } + SYSTEM_EVENT("\n\t\t\tAfter call ") #ifdef SYSTEM_LOG_DEBUG { diff --git a/Contrib/System/Source/System.h b/Contrib/System/Source/System.h index 7b82b742..2ce5c50e 100644 --- a/Contrib/System/Source/System.h +++ b/Contrib/System/Source/System.h @@ -45,7 +45,8 @@ #define POPT_ALWRETURN 0x4 // Always return #define POPT_NEVERREDEF 0x8 // Never redefine #define POPT_GENSTACK 0x10 // Use general stack (non temporary for callback) -#define POPT_CLONE 0x20 // This is clone callback +#define POPT_ERROR 0x20 // Call GetLastError after proc and push it to stack +#define POPT_CLONE 0x40 // This is clone callback // Our single proc parameter typedef struct diff --git a/Contrib/System/System.txt b/Contrib/System/System.txt index 62daedf4..f7d18264 100644 --- a/Contrib/System/System.txt +++ b/Contrib/System/System.txt @@ -159,6 +159,7 @@ return place. redefined either by GET or CALL. This options is never inherited to childs. s - use general Stack. Whenever the first callback defined the system starts using the temporary stacks for function calls. + e - call GetLastError() after procedure end and push result on stack, ---------------------------------- Callback: diff --git a/Plugins/System.dll b/Plugins/System.dll index c99d780c..c66c5037 100644 Binary files a/Plugins/System.dll and b/Plugins/System.dll differ