NO

Author Topic: AddInLoad, Add-In loader  (Read 191 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1872
AddInLoad, Add-In loader
« on: August 19, 2019, 08:59:41 pm »
Pelles C poide users can create their own Add-In loaders, an example provided.
Before starting poide, download Add-Ins to avoid file locking errors.
Put AddInLoad to Pelles C bin folder and start it from there, as admin, if necessary.
An example offers to download some of Add-Ins from my limited collection.
UI is quite simple. It create AddIns/AddIns64 folder, if needed, like in temporary folder for testing.

Generate Files.lst
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <windows.h>

#pragma comment(lib,"version.lib")
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"msvcrt.lib")

void __cdecl mainCRTStartup(void)
{
int __cdecl main(int argc, char **argv);
int __cdecl __getmainargs(int*, char***, char***, int, void*);
void __cdecl exit(int status);

int    argc;
char** argv;
char** env;
int    sinfo = 0;

__getmainargs(&argc,&argv,&env,0,&sinfo);
exit(main(argc,argv));
}

LPSTR GetVersionInfo(TCHAR *szFileName, TCHAR *szValue, TCHAR *szBuffer, ULONG nLength)
{
LPSTR csRet;
DWORD len;

csRet = NULL;
len = GetFileVersionInfoSize(szFileName, 0);
if (len) {
csRet = NULL;
LPVOID ver = LocalAlloc(LPTR, len);
if (ver != NULL)
{
DWORD *codepage;
char fmt[256];
PVOID ptr = 0;
if (GetFileVersionInfo(szFileName, 0, len, ver))
{
if (VerQueryValue(ver, "\\VarFileInfo\\Translation", (LPVOID) & codepage, &len))
{
wsprintf(fmt, "\\StringFileInfo\\%08x\\%s", (*codepage) << 16 | (*codepage) >> 16, szValue);
if (VerQueryValue(ver, fmt, &ptr, &len))
{
lstrcpyn(szBuffer, (TCHAR *)ptr, min(nLength, len));
csRet = szBuffer;
}
}
}
LocalFree(ver);
}
}
return csRet;
}

int DoWithMask(char *szMask) {
WIN32_FIND_DATA fdFile;
HANDLE hFile;
int iPos, iIdx = 1;
char szTmp[MAX_PATH];

iPos = lstrlen(szMask) - 5;
lstrcpyn(szTmp, szMask, iPos);
iPos--;
hFile = FindFirstFile(szMask, &fdFile);
if (hFile != INVALID_HANDLE_VALUE)
do {
if ((fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
!= FILE_ATTRIBUTE_DIRECTORY) {
char szVer[100];
WIN32_FILE_ATTRIBUTE_DATA fad;
*szVer = 0;
printf(fdFile.cFileName);
*(szTmp+iPos) = '\\'; // put back
lstrcpy(szTmp+iPos+1, fdFile.cFileName);
GetFileAttributesEx(szTmp, GetFileExInfoStandard,&fad);
if (GetVersionInfo(szTmp, "ProductVersion", szVer, sizeof(szVer)))
printf("\t%s", szVer);
else
printf("\t");
SYSTEMTIME st;
FileTimeToSystemTime(&fad.ftLastWriteTime, &st);
printf("\t%u-%02u-%02u", st.wYear, st.wMonth, st.wDay);
printf("\t%u", fad.nFileSizeLow);
if (GetVersionInfo(szTmp, "FileDescription", szVer, sizeof(szVer)))
printf("\t%s", szVer);
else
printf("\t");
printf("\t%llu\n", fad.ftLastWriteTime); // timestamp
iIdx++;
}
} while (FindNextFile(hFile, &fdFile));
FindClose(hFile);
return 0;
}

int main(int argc, char **argv)
{
DoWithMask(argv[1]);
return 0;
}
« Last Edit: August 20, 2019, 08:08:12 am by TimoVJL »
May the source be with you

Offline bitcoin

  • Member
  • *
  • Posts: 76
Re: AddInLoad, Add-In loader
« Reply #1 on: August 21, 2019, 02:13:11 pm »
Where I can get some descriptions about add-ins? As example, what do AddGuard?
I mean, the description will be helpfull for all.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1872
Re: AddInLoad, Add-In loader
« Reply #2 on: August 21, 2019, 03:06:06 pm »
Sorry about that.

AddGuard Add-In insert guard lines to header file.
example for foo.h
Code: [Select]
#pragma once
#ifndef _FOO_H
#define _FOO_H
#endif // _FOO_H
That an Add-In is here with sources:
https://forum.pellesc.de/index.php?topic=4968.msg18765#msg18765

In github there is no documentations yet, but later there should be *.txt file for it, maybe in a doc folder.
« Last Edit: August 21, 2019, 04:03:48 pm by TimoVJL »
May the source be with you