Updated System plugin - Win9x fixes and more

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2350 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
joostverburg 2003-03-22 11:15:53 +00:00
parent 6788c2222f
commit 3667a05636
7 changed files with 51 additions and 51 deletions

View file

@ -567,7 +567,10 @@ void ParamsIn(SystemProc *proc)
*((__int64*) place) = myatoi(realbuf);
break;
case PAT_STRING:
*((int*) place) = (int) AllocStr(realbuf);
/* if (proc->Params[i].Input == IOT_NONE)
*((int*) place) = (int) NULL;
else*/
*((int*) place) = (int) AllocStr(realbuf);
break;
case PAT_BOOLEAN:
*((int*) place) = lstrcmpi(realbuf, "true");
@ -650,6 +653,8 @@ void ParamsOut(SystemProc *proc)
while (i >= 0);
}
void _alloca_probe();
SystemProc __declspec(naked) *CallProc(SystemProc *proc)
{
int z3;
@ -669,22 +674,28 @@ SystemProc __declspec(naked) *CallProc(SystemProc *proc)
if ((CallbackIndex > 0) && ((proc->Options & POPT_GENSTACK) == 0))
{
if (LastStackPlace == 0)
{
// Create new stack
LastStackPlace = (int) GlobalAlloc(GPTR, NEW_STACK_SIZE);
// Point to stack end
LastStackPlace += NEW_STACK_SIZE;
}
_asm
{
// Save previous stack location
push ebp
// Save previous stack location
mov LastStackReal, esp
// Move stack pointer
mov esp, LastStackPlace
}
if (LastStackPlace == 0)
{
_asm
{
// Create new stack
mov eax, NEW_STACK_SIZE
call _alloca_probe
mov LastStackPlace, esp
}
} else
_asm
{
// Move stack pointer
mov esp, LastStackPlace
}
}
// Push arguments to stack
@ -735,7 +746,7 @@ SystemProc __declspec(naked) *CallProc(SystemProc *proc)
// In case of cdecl convention we should clear stack
if ((proc->Options & POPT_CDECL) != 0)
{
if ((CallbackIndex > 0) && ((LastProc->Options & POPT_GENSTACK) == 0))
if ((CallbackIndex > 0) && ((proc->Options & POPT_GENSTACK) == 0))
{
// In case of temporary stack
for (z3 = 1; z3 <= proc->ParamCount; z3++)
@ -752,6 +763,9 @@ SystemProc __declspec(naked) *CallProc(SystemProc *proc)
}
}
// In case of cleared call-proc-queue -> clear allocated stack place (more flexible)
if (LastProc == NULL) LastStackPlace = NULL;
// Save return
proc->Params[0].Value = z1;
if (proc->Params[0].Size == 2)
@ -935,6 +949,7 @@ HANDLE CreateCallback(SystemProc *cbproc)
void CallStruct(SystemProc *proc)
{
BOOL ssflag = FALSE; // structsize flag -> structure size should be loaded
int i, structsize = 0, size = 0;
char *st, *ptr;
@ -974,16 +989,12 @@ void CallStruct(SystemProc *proc)
switch (proc->Params[i].Type)
{
case PAT_VOID: ptr = NULL; break;
case PAT_INT:
// clear unused value bits
proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)];
// pointer
ptr = (char*) &(proc->Params[i].Value);
break;
case PAT_LONG:
// real structure size
proc->Params[i].Value = structsize;
proc->Params[i]._value = 0;
ssflag = TRUE;
case PAT_INT:
// clear unused value bits
proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)];
// pointer
@ -997,7 +1008,7 @@ void CallStruct(SystemProc *proc)
if (ptr != NULL)
{
// Input
if (proc->Params[i].Input != IOT_NONE)
if ((proc->Params[i].Input != IOT_NONE) || (ssflag))
copymem(st, ptr, size);
// Output
@ -1013,20 +1024,6 @@ void CallStruct(SystemProc *proc)
proc->Params[0].Value = (int) proc->Proc;
}
/*__int64 __declspec(dllexport) just(__int64 a, __int64 b, __int64 *c)
{
*c += a*b + 8402934020348;
return a*b+(*c);
}*/
/*typedef int (__stdcall *func)(int a, int b);
int __declspec(dllexport) cbtest(func f)
{
return f(5, 10);
}*/
BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
g_hInstance=hInst;

View file

@ -12,7 +12,7 @@
#define SYSTEM_API __declspec(dllimport)
#endif
#define NEW_STACK_SIZE 65536
#define NEW_STACK_SIZE 256*256
// Proc types:
#define PT_NOTHING 0

View file

@ -83,7 +83,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib user32.lib vc7ldvrm.obj vc7lmul.obj vc7lshl.obj vc7lshr.obj "
AdditionalDependencies="kernel32.lib user32.lib vc7ldvrm.obj vc7lmul.obj vc7lshl.obj vc7lshr.obj chkstk.obj"
OutputFile="$(OutDir)/System.dll"
LinkIncremental="1"
IgnoreAllDefaultLibraries="TRUE"

Binary file not shown.

View file

@ -83,22 +83,17 @@ Function systemGetFileSysTime
; close file search
System::Call '${sysFindClose}(r3)'
; Create systemtime struct for system time
System::Call '*${stSYSTEMTIME} .R1'
; Create systemtime struct for local time
System::Call '*${stSYSTEMTIME} .R0'
; Get File time
System::Call '*$2${stWIN32_FIND_DATA} (,,, .r3)'
; Convert file time (UTC) to local file time
System::Call '${sysFileTimeToLocalFileTime}(r3, .r1)'
; Convert file time to system time
System::Call '${sysFileTimeToSystemTime}(r3, R1)'
; Convert system time to local time
System::Call '${sysSystemTimeToTzSpecificLocalTime}(0, R1, R0)'
; that's all, just clear used memory
System::Free $R1
System::Call '${sysFileTimeToSystemTime}(r1, R0)'
sgfst_exit:
; free used memory for WIN32_FIND_DATA struct
@ -138,22 +133,25 @@ Function systemMessageBox
; Load module and get handle
System::Call '${sysLoadLibrary}($2) .r1'
IntCmp $1 0 "0" smbnext smbnext
IntCmp $1 0 0 smbnext smbnext
; Get module handle. This may look stupid (to call GetModuleHandle in case
; when the LoadLibrary doesn't works, but LoadLibrary couldn't return
; a handle to starting process (for 'i 0').
System::Call '${sysGetModuleHandle}($2) .r1'
smbnext:
; Indicate that LoadLibrary wasn't used
StrCpy $2 1
smbnext:
; Create MSGBOXPARAMS structure
System::Call '*${stMSGBOXPARAMS}(, $HWNDPARENT, r1, r3, r4, "$5|${MB_USERICON}", $6, _) .r0'
; call MessageBoxIndirect
System::Call '${sysMessageBoxIndirect}(r0) .R0'
; free MSGBOXPARAMS structure
System::Free $0
; have we got ready module handle at start?
; have we used load library at start?
IntCmp $2 0 0 smbskipfree smbskipfree
; No, then free the module
System::Call '${sysFreeLibrary}(r1)'
@ -331,7 +329,7 @@ Function systemSplash
Pop $3
; Create window class
System::Call "*${stWNDCLASS} (,r3,,,r7,,R9,,,s) .R9" "_sp"
System::Call "*${stWNDCLASS} (0,r3,0,0,r7,0,R9,0,i 0,'_sp') .R9"
; Register window class
System::Call "${sysRegisterClass} (R9) .R9"
@ -373,8 +371,8 @@ repeat:
finish:
; Stop the sound
System::Call "${sysPlaySound}"
System::Call "${sysPlaySound} (i 0, i 0, i 0)"
; Delete bitmap object
System::Call "${sysDeleteObject} (r6)"

View file

@ -120,6 +120,11 @@
; LPSYSTEMTIME lpSystemTime);
!define sysFileTimeToSystemTime 'kernel32::FileTimeToSystemTime(*l, i) i'
; BOOL FileTimeToLocalFileTime(
; CONST FILETIME *lpFileTime,
; LPFILETIME lpLocalFileTime);
!define sysFileTimeToLocalFileTime 'kernel32::FileTimeToLocalFileTime(*l, *l) i'
; BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION lpTimeZone,
; LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime);
!define sysSystemTimeToTzSpecificLocalTime 'kernel32::SystemTimeToTzSpecificLocalTime(i, i, i) i'

Binary file not shown.