(brainsucker) fixed a bug with calling proc(void) and added e switch to get GetLastError return value.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2465 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-04-18 11:21:06 +00:00
parent e720007649
commit 96a524c1b7
4 changed files with 22 additions and 5 deletions

View file

@ -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
{

View file

@ -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

View file

@ -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:

Binary file not shown.