Source files to Source directory

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1513 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-10-31 15:55:52 +00:00
parent a174dda1f7
commit 66ae44c5ac
14 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,106 @@
#include "stdafx.h"
#include "Plugin.h"
#include "System.h"
#include "Buffers.h"
typedef struct tagTempStack TempStack;
typedef struct tagTempStack
{
TempStack *Next;
char Data[0];
} TempStack;
TempStack *tempstack = NULL;
PLUGINFUNCTIONSHORT(Alloc)
{
int size;
if ((size = popint()) == 0)
{
pushint(0);
return;
}
pushint((int) GlobalAlloc(GPTR, size));
}
PLUGINFUNCTIONEND
PLUGINFUNCTIONSHORT(Copy)
{
int size = 0;
HANDLE source, dest;
char *str;
// Get the string
if ((str = popstring()) == NULL) return;
// Check for size option
if (str[0] == '/')
{
size = (int) myatoi(str+1);
dest = (HANDLE) popint();
}
else dest = (HANDLE) myatoi(str+1);
source = (HANDLE) popint();
// Ok, check the size
if (size == 0) size = (int) GlobalSize(source);
// and the destinantion
if ((int) dest == 0) dest = GlobalAlloc((GPTR), size);
// COPY!
copymem(dest, source, size);
GlobalFree(str);
}
PLUGINFUNCTIONEND
PLUGINFUNCTIONSHORT(Free)
{
GlobalFree((HANDLE) popint());
}
PLUGINFUNCTIONEND
PLUGINFUNCTION(Store)
{
TempStack *tmp;
int size = ((INST_R9+1)*g_stringsize);
char *command, *cmd = command = popstring();
while (*cmd != 0)
{
switch (*(cmd++))
{
case 's':
case 'S':
// Store the whole variables range
tmp = (TempStack*) GlobalAlloc(GPTR, sizeof(TempStack)+size);
tmp->Next = tempstack;
tempstack = tmp;
// Fill with data
copymem(tempstack->Data, g_variables, size);
break;
case 'l':
case 'L':
// Fill with data
copymem(g_variables, tempstack->Data, size);
// Restore stack
tmp = tempstack->Next;
GlobalFree((HANDLE) tempstack);
tempstack = tmp;
break;
case 'P':
*cmd += 10;
case 'p':
GlobalFree((HANDLE) pushstring(getuservariable(*(cmd++)-'0')));
break;
case 'R':
*cmd += 10;
case 'r':
GlobalFree((HANDLE) setuservariable(*(cmd++)-'0', popstring()));
break;
}
}
GlobalFree((HANDLE) command);
}
PLUGINFUNCTIONEND

View file

@ -0,0 +1,2 @@
#pragma once

View file

@ -0,0 +1,173 @@
#include "stdafx.h"
#include "Plugin.h"
#include "Buffers.h"
#include "System.h"
HWND g_hwndParent;
int g_stringsize;
stack_t **g_stacktop;
char *g_variables;
char *AllocString()
{
return (char*) GlobalAlloc(GPTR,g_stringsize);
}
char *AllocStr(char *str)
{
return lstrcpy(AllocString(), str);
}
char* popstring()
{
char *str;
stack_t *th;
if (!g_stacktop || !*g_stacktop) return NULL;
th=(*g_stacktop);
str = AllocString();
lstrcpy(str,th->text);
*g_stacktop = th->next;
GlobalFree((HGLOBAL)th);
return str;
}
char *pushstring(char *str)
{
stack_t *th;
if (!g_stacktop) return str;
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
lstrcpyn(th->text,str,g_stringsize);
th->next=*g_stacktop;
*g_stacktop=th;
return str;
}
char *getuservariable(int varnum)
{
if (varnum < 0 || varnum >= __INST_LAST) return AllocString();
return AllocStr(g_variables+varnum*g_stringsize);
}
char *setuservariable(int varnum, char *var)
{
if (var != NULL && varnum >= 0 && varnum < __INST_LAST) {
lstrcpy (g_variables + varnum*g_stringsize, var);
}
return var;
}
// Updated for int64 and simple bitwise operations
__int64 myatoi(char *s)
{
__int64 v=0;
// Check for right input
if (!s) return 0;
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
{
s++;
for (;;)
{
int c=*(++s);
if (c >= '0' && c <= '9') c-='0';
else if (c >= 'a' && c <= 'f') c-='a'-10;
else if (c >= 'A' && c <= 'F') c-='A'-10;
else break;
v<<=4;
v+=c;
}
}
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
{
for (;;)
{
int c=*(++s);
if (c >= '0' && c <= '7') c-='0';
else break;
v<<=3;
v+=c;
}
}
else
{
int sign=0;
if (*s == '-') sign++; else s--;
for (;;)
{
int c=*(++s) - '0';
if (c < 0 || c > 9) break;
v*=10;
v+=c;
}
if (sign) v = -v;
}
// Support for simple ORed expressions
if (*s == '|')
{
v |= myatoi(s+1);
}
return v;
}
void myitoa64(__int64 i, char *buffer)
{
char buf[128], *b = buf;
if (i < 0)
{
*(buffer++) = '-';
i = -i;
}
if (i == 0) *(buffer++) = '0';
else
{
while (i > 0)
{
*(b++) = '0' + ((char) (i%10));
i /= 10;
}
while (b > buf) *(buffer++) = *(--b);
}
*buffer = 0;
}
int popint()
{
int value;
char *str;
if ((str = popstring()) == NULL) return -1;
value = (int) myatoi(str);
GlobalFree(str);
return value;
}
void pushint(int value)
{
char buffer[1024];
wsprintf(buffer, "%d", value);
pushstring(buffer);
}
char *copymem(char *output, char *input, int size)
{
char *out = output;
if ((input != NULL) && (output != NULL))
while (size-- > 0) *(out++) = *(input++);
return output;
}
HANDLE GlobalCopy(HANDLE Old)
{
SIZE_T size = GlobalSize(Old);
return copymem(GlobalAlloc(GPTR, size), Old, (int) size);
}
#ifdef _DEBUG
void main()
{
}
#endif

View file

@ -0,0 +1,66 @@
#pragma once
typedef struct _stack_t {
struct _stack_t *next;
char text[1]; // this should be the length of string_size
} stack_t;
enum
{
INST_0, // $0
INST_1, // $1
INST_2, // $2
INST_3, // $3
INST_4, // $4
INST_5, // $5
INST_6, // $6
INST_7, // $7
INST_8, // $8
INST_9, // $9
INST_R0, // $R0
INST_R1, // $R1
INST_R2, // $R2
INST_R3, // $R3
INST_R4, // $R4
INST_R5, // $R5
INST_R6, // $R6
INST_R7, // $R7
INST_R8, // $R8
INST_R9, // $R9
INST_CMDLINE, // $CMDLINE
INST_INSTDIR, // $INSTDIR
INST_OUTDIR, // $OUTDIR
INST_EXEDIR, // $EXEDIR
INST_LANG, // $LANGUAGE
__INST_LAST
};
#define PLUGINFUNCTION(name) void __declspec(dllexport) name(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { \
/* g_hwndParent=hwndParent; */\
g_stringsize=string_size; \
g_stacktop=stacktop; \
g_variables=variables;
#define PLUGINFUNCTIONEND }
#define PLUGINFUNCTIONSHORT(name) void __declspec(dllexport) name(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { \
g_stringsize=string_size; \
g_stacktop=stacktop;
extern char *AllocStr(char *str);
extern void myitoa64(__int64 i, char *buffer);
extern char *AllocString();
extern char *getuservariable(int varnum);
extern char *setuservariable(int varnum, char *var);
extern char* popstring(); // NULL - stack empty
extern char* pushstring(char *str);
extern __int64 myatoi(char *s);
extern int popint(); // -1 -> stack empty
extern void pushint(int value);
extern HANDLE GlobalCopy(HANDLE Old);
extern char *copymem(char *output, char *input, int size);
extern HWND g_hwndParent;
extern int g_stringsize;
extern stack_t **g_stacktop;
extern char *g_variables;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,95 @@
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the SYSTEM_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// SYSTEM_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#pragma once
#ifdef SYSTEM_EXPORTS
#define SYSTEM_API __declspec(dllexport)
#else
#define SYSTEM_API __declspec(dllimport)
#endif
#define NEW_STACK_SIZE 65536
// Proc types:
#define PT_NOTHING 0
#define PT_PROC 1
#define PT_STRUCT 2
// Proc results:
#define PR_OK 0
#define PR_ERROR -1
#define PR_CALLBACK 1
// Real world argument types
#define PAT_VOID 0
#define PAT_INT 1
#define PAT_LONG 2
#define PAT_STRING 3
#define PAT_BOOLEAN 4
#define PAT_CALLBACK 5
// Input/Output Source/Destination
#define IOT_NONE 0
#define IOT_STACK -1
#define IOT_REG 1
#define IOT_INLINE (__INST_LAST+1) // should replace pointer to inline input
// #define INLINE_INPUT -> any other value, will contain pointer to input string
// Options
#define POPT_CDECL 0x1 // (Option & 0x1) == 0x1 -> cdecl, otherwise stdcall
#define POPT_PERMANENT 0x2 // Permanent proc, will not be destroyed after calling
#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
// Our single proc parameter
typedef struct
{
int Type;
int Option; // -1 -> Pointer, 1-... -> Special+1
int Value; // it can hold any 4 byte value
int _value; // value buffer for structures > 4 bytes (I hope 8 bytes will be enough)
int Size; // Value real size (should be either 1 or 2 (the number of pushes))
int Input;
int Output;
} ProcParameter;
// Our single proc (Since the user will free proc with GlobalFree,
// I've declared all variables as statics)
typedef struct tag_SystemProc SystemProc;
typedef struct tag_SystemProc
{
int ProcType;
int ProcResult;
char DllName[1024];
char ProcName[1024];
HANDLE Dll;
HANDLE Proc;
int Options;
int ParamCount;
ProcParameter Params[100]; // I hope nobody will use more than 100 params
// Callback specific
int CallbackIndex;
int ArgsSize;
// Clone of current element (used for multi-level callbacks)
SystemProc *Clone;
} SystemProc;
extern int ParamSizeByType[]; // Size of every parameter type (*4 bytes)
extern HANDLE CreateCallback(SystemProc *cbproc);
extern SystemProc *PrepareProc(BOOL NeedForCall);
extern void ParamAllocate(SystemProc *proc);
extern void ParamsDeAllocate(SystemProc *proc);
extern void ParamsIn(SystemProc *proc);
extern void ParamsOut(SystemProc *proc);
extern SystemProc *CallProc(SystemProc *proc);
extern SystemProc *CallBack(SystemProc *proc);
extern SystemProc *RealCallBack();
extern void CallStruct(SystemProc *proc);

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "System", "System.vcproj", "{2FB013AB-6FD4-4239-9974-C999F4DFD70C}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{2FB013AB-6FD4-4239-9974-C999F4DFD70C}.Debug.ActiveCfg = Debug|Win32
{2FB013AB-6FD4-4239-9974-C999F4DFD70C}.Debug.Build.0 = Debug|Win32
{2FB013AB-6FD4-4239-9974-C999F4DFD70C}.Release.ActiveCfg = Release|Win32
{2FB013AB-6FD4-4239-9974-C999F4DFD70C}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,178 @@
<?xml version="1.0" encoding = "windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="System"
ProjectGUID="{2FB013AB-6FD4-4239-9974-C999F4DFD70C}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SYSTEM_EXPORTS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="3"
AssemblerOutput="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib user32.lib RunTmChk.lib libcd.lib"
OutputFile="$(OutDir)/System.dll"
LinkIncremental="2"
IgnoreAllDefaultLibraries="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/System.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/System.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="1"
FavorSizeOrSpeed="2"
OmitFramePointers="TRUE"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SYSTEM_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="4"
BufferSecurityCheck="FALSE"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
AssemblerOutput="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib user32.lib vc7ldvrm.obj vc7lmul.obj vc7lshl.obj vc7lshr.obj "
OutputFile="$(OutDir)/System.dll"
LinkIncremental="1"
IgnoreAllDefaultLibraries="TRUE"
GenerateDebugInformation="FALSE"
GenerateMapFile="TRUE"
MapExports="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
ImportLibrary="$(OutDir)/System.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="Buffers.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="1"
GlobalOptimizations="TRUE"
FavorSizeOrSpeed="2"/>
</FileConfiguration>
</File>
<File
RelativePath="Plugin.c">
</File>
<File
RelativePath="System.c">
</File>
<File
RelativePath="stdafx.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="Buffers.h">
</File>
<File
RelativePath="Plugin.h">
</File>
<File
RelativePath="System.h">
</File>
<File
RelativePath="stdafx.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
<File
RelativePath="ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// AnyDLL.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

View file

@ -0,0 +1,12 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// TODO: reference additional headers your program requires here

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.