-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.c
More file actions
82 lines (70 loc) · 1.99 KB
/
Copy pathmain.c
File metadata and controls
82 lines (70 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#define _CRT_SECURE_NO_WARNINGS
#include "rlmpubkey.h"
#include <Windows.h>
#include "resource.h"
int replacepubkey(PubkeyInfo* pki);
int createsign(PubkeyInfo* pki, char* rlmsign);
PubkeyInfo* init();
int listFiles(char* dir, PubkeyInfo* pki, const char* isv_name);
int help()
{
printf("Usage Instructions\n");
printf("In RLM 12 new version, RLM_ISV_NAME parameter is hidden, need to find it through license file.\n");
printf("RLMpubkey.exe ISV\n");
printf("Example: For a license file content as below, ISV is demo, command is \"RLMpubkey.exe demo\".\n");
printf("HOST THIS_HOST 68f7283e08b7 \nISV demo \nLICENSE demo f1 15.1 permanent 1 hostid = 68f7283e08b7 ...\n");
return 0;
}
int freelist(PubkeyInfo* pki)
{
PubkeyInfo* tmp =pki->next,*tmq;
for (; tmp != NULL;)
{
tmq = tmp;
tmp = tmp->next;
free(tmq);
}
return 1;
}
int main(int argc, char* argv[])
{
// Handle command line arguments
const char* isv_name = NULL;
if (argc >= 2) {
isv_name = argv[1];
printf("Using ISV name from command line: %s\n", isv_name);
} else {
printf("No ISV name provided in command line.\n");
printf("Usage: %s <ISV_NAME>\n", argv[0]);
help();
return 0;
}
PubkeyInfo* pfirst = init(),*ptmp;
/* Search for public key files that need to be replaced */
listFiles(localdir, pfirst, isv_name);
if (pfirst->next ==NULL)
{
printf("\nNo files need to be replaced, program exit.\n");
freelist(pfirst);
return 0;
}
listpubkey(pfirst);
/* RC resource loading */
HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_EXE1), TEXT("EXE"));
DWORD dwSize = SizeofResource(NULL, hRsrc);
HGLOBAL hGlobal = LoadResource(NULL, hRsrc);
LPVOID pBuffer = LockResource(hGlobal);
/* Generate keygen */
if (!createsign(pfirst, (unsigned char*)pBuffer)) {
printf("Failed to create signature.\n");
FreeResource(hGlobal);
freelist(pfirst);
return 0;
}
/* Replace file public key */
replacepubkey(pfirst);
/* Release resources */
FreeResource(hGlobal);
freelist(pfirst);
return 1;
}