Skip to content

Commit

Permalink
alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilFreelancer committed Oct 11, 2017
0 parents commit cc5e172
Show file tree
Hide file tree
Showing 66 changed files with 4,954 additions and 0 deletions.
Empty file added Documentation/.gitsave
Empty file.
2 changes: 2 additions & 0 deletions Images/ApplicationFolder/WPKG Installer Parameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TODO:
<< add your help here >>
Binary file added Images/ApplicationFolder/WPKGSrv.exe
Binary file not shown.
Binary file added Images/ApplicationFolder/wpkginst.exe
Binary file not shown.
Binary file added Images/Setup/InstMsiA.Exe
Binary file not shown.
Binary file added Images/Setup/InstMsiW.Exe
Binary file not shown.
Binary file added Images/Setup/Setup.Exe
Binary file not shown.
2 changes: 2 additions & 0 deletions Images/Setup/Setup.Ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MSILoader]
MSIFileName=WPKGSetup.msi
Binary file added Images/Setup/WPKGSetup.msi
Binary file not shown.
4 changes: 4 additions & 0 deletions Images/Setup/setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
setup /i PATH=PATH FILE=FILE PATHUSER=PATHUSER PATHPASSWORD=PATHPASSWORD EXECUSER=EXECUSER EXECPASSWORD=EXECPASSWORD PARAMETERS=PARAMETERS SILENT=NO
SCRIPTVARNAME1=TOMEK SCRIPTVARVALUE1=EXAMPLEVARIALBE


Binary file added Images/SystemFolder/msvcrt.dll
Binary file not shown.
77 changes: 77 additions & 0 deletions Sources/Components/ExceptionEx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "StdAfx.h"
#include ".\exceptionex.h"

IMPLEMENT_DYNAMIC(CExceptionEx, CException)

CExceptionEx::CExceptionEx(void)
{
m_dwError = 0;
}


CExceptionEx::~CExceptionEx(void)
{
}



BOOL CExceptionEx::GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
PUINT pnHelpContext)
{
ASSERT(lpszError != NULL && AfxIsValidString(lpszError, nMaxError));

if (lpszError == NULL || nMaxError == 0)
{
return FALSE;
}

if (pnHelpContext != NULL)
*pnHelpContext = 0;

lstrcpyn(lpszError, m_strMessage, nMaxError);

return TRUE;
}

void CExceptionEx::FormatMessage(DWORD dwErrorCode)
{
CHAR szProvider[256];
m_strMessage = _T("Unknown error occured.");

if (dwErrorCode != ERROR_EXTENDED_ERROR)
{
::FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) m_strMessage.GetBufferSetLength(1025),
1024,
NULL );
}
else
{
WNetGetLastError(&dwErrorCode, // error code
(LPSTR) m_strMessage.GetBufferSetLength(1025),
// buffer for error description
1024, // size of error buffer
(LPSTR) szProvider, // buffer for provider name
sizeof(szProvider)); // size of name buffer

}

m_strMessage.ReleaseBuffer();
m_strMessage.Replace("\r\n","");

}


void CExceptionEx::ThrowError(DWORD Error)
{
CExceptionEx* exception = new CExceptionEx();
exception->FormatMessage(Error);
exception->m_dwError = Error;
throw exception;
}


22 changes: 22 additions & 0 deletions Sources/Components/ExceptionEx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once
#include "afx.h"

class CExceptionEx :
public CException
{
DECLARE_DYNAMIC(CExceptionEx)
private:
void FormatMessage(DWORD dwErrorCode);

public:
CString m_strMessage;
DWORD m_dwError;
CExceptionEx(void);
virtual ~CExceptionEx(void);
virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
PUINT pnHelpContext = NULL);

static void PASCAL ThrowError(DWORD Error);


};
133 changes: 133 additions & 0 deletions Sources/Components/NetConnection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#include "StdAfx.h"
#include ".\netconnection.h"
#include "exceptionex.h"

CNetConnection::CNetConnection(void)
{
m_bSilent = TRUE;
}

CNetConnection::~CNetConnection(void)
{
}

DWORD CNetConnection::DisconnectFromServer(CString RemotePath)
{
HANDLE hEnum;
DWORD counter=0xFFFFFFFF;
BYTE buffer[1024*16];
DWORD size=1024*16;


DWORD error = WNetOpenEnum(
RESOURCE_CONNECTED,
RESOURCETYPE_ANY,
0,
0,
&hEnum);

error = WNetEnumResource(
hEnum,
&counter,
buffer,
&size);

WNetCloseEnum(hEnum);

NETRESOURCE* nrb=(NETRESOURCE*)buffer;
CString str;
CString Server;

// find in path server name
int pos = RemotePath.Find('\\',2);
if(pos!=-1)
Server = RemotePath.Left(pos);



for( DWORD i=0; i<counter; i++ )
{
str.Empty();
str=nrb[i].lpRemoteName;
// our server? - yes: disconnect from here
if( Server.CompareNoCase( str.Left( Server.GetLength() ) ) != 0 )
continue;
if( nrb[i].lpLocalName )
{
error = WNetCancelConnection2( nrb[i].lpLocalName,0,1);
}
error = WNetCancelConnection2( str,0,1);

}

return error;
}


void CNetConnection::NetErrorHandler( DWORD dwErrorCode )
{
DWORD dwLastError;
char lpMsgBuf[1024]="Unknown error.";
CHAR szProvider[256];

if (dwErrorCode != ERROR_EXTENDED_ERROR)
{
FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
1024,
NULL );

}
else
{
WNetGetLastError(&dwLastError, // error code
(LPSTR) lpMsgBuf, // buffer for error description
sizeof(lpMsgBuf), // size of error buffer
(LPSTR) szProvider, // buffer for provider name
sizeof(szProvider)); // size of name buffer



}

if( m_bSilent )
{
}
else
AfxMessageBox(lpMsgBuf);

}

void CNetConnection::AddConnection(CString RemotePath, CString user,
CString password)
{

// disconnect - closing files
DWORD Error = DisconnectFromServer(RemotePath);

NETRESOURCE nr;
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = NULL ;
nr.lpRemoteName = RemotePath.GetBuffer();
nr.lpProvider = NULL;


Error = WNetAddConnection2( &nr,
password,
user,
0);


if( Error != 0 && Error != ERROR_ALREADY_ASSIGNED )
CExceptionEx::ThrowError(Error);

}

void CNetConnection::Disconnect(CString RemotePath)
{
WNetCancelConnection2( RemotePath,0,1);
}
15 changes: 15 additions & 0 deletions Sources/Components/NetConnection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

class CNetConnection
{
public:
BOOL m_bSilent;
CNetConnection(void);
virtual ~CNetConnection(void);
DWORD DisconnectFromServer(CString RemotePath);
void AddConnection(CString RemotePath, CString user,
CString password);
void NetErrorHandler( DWORD dwErrorCode );

void Disconnect(CString RemotePath);
};
75 changes: 75 additions & 0 deletions Sources/Components/Parameters.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include "StdAfx.h"
#include ".\parameters.h"

CParameters::CParameters(void)
{
m_strParDelimiter = "--";
m_strValDelimiter = '=';
}

CParameters::~CParameters(void)
{
}

void CParameters::SetCommandLine(CString command)
{
m_strCommandLine = command;
}

void CParameters::Compute(void)
{
int pos = 0;
int tempPos;
CString str;
m_array.RemoveAll();
//m_strCommandLine.Remove(' ');

while(pos > -1)
{
tempPos = pos;
pos = m_strCommandLine.Find(m_strParDelimiter,pos+m_strParDelimiter.GetLength());
if(pos==-1)
str = m_strCommandLine.Mid(tempPos+m_strParDelimiter.GetLength());
else
str = m_strCommandLine.Mid(tempPos+m_strParDelimiter.GetLength(),pos-tempPos-m_strParDelimiter.GetLength());

m_array.Add(str);
}


}


CString CParameters::GetParameter(CString paramName)
{
CString strResult;
CString line;
for(int i=0; i<m_array.GetSize(); i++)
{
line = m_array.GetAt(i);
if(GetName(line).CompareNoCase(paramName)==0)
{
strResult = GetValue(line);
break;
}

}
return strResult;
}

CString CParameters::GetValue(CString& line)
{
CString strResult;
int pos = line.Find(m_strValDelimiter);
strResult = line.Mid(pos+m_strValDelimiter.GetLength());
strResult.Trim();
return strResult;

}

CString CParameters::GetName(CString& line)
{
int pos = line.Find(m_strValDelimiter);
return line.Left(pos);
}

21 changes: 21 additions & 0 deletions Sources/Components/Parameters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

class CParameters
{
private:
CString m_strCommandLine;
CString m_strParDelimiter;
CString m_strValDelimiter;
CStringArray m_array;
protected:
virtual CString GetValue(CString& line);
virtual CString GetName(CString& line);

public:
CParameters(void);
virtual ~CParameters(void);
void SetCommandLine(CString command);
void Compute(void);
CString GetParameter(CString paramName);

};
Loading

0 comments on commit cc5e172

Please sign in to comment.