启用新的版本标准

This commit is contained in:
gb 2022-08-04 11:37:14 +08:00
parent be9c84a2da
commit ae4b06be35
2 changed files with 61 additions and 9 deletions

Binary file not shown.

View File

@ -146,6 +146,24 @@ static oem from_str(const wchar_t* str)
return OEM_NOT; return OEM_NOT;
} }
static int oem_code(oem o)
{
if (o == OEM_HANWANG)
return 16;
else if (o == OEM_LISICHENG)
return 14;
else
return 10;
}
static oem oem_from_code(int code)
{
if (code == 16)
return OEM_HANWANG;
else if (code == 14)
return OEM_LISICHENG;
else
return OEM_NONE;
}
static int find_line(std::wstring& brand, const wchar_t* line_tag, int* end) static int find_line(std::wstring& brand, const wchar_t* line_tag, int* end)
{ {
int bgn = 0, next = 0, start = -1; int bgn = 0, next = 0, start = -1;
@ -227,7 +245,8 @@ static bool change_sub(std::wstring& brand, int sub, int main)
bgn++; bgn++;
if (brand[bgn] >= L'0' && brand[bgn] <= L'9') if (brand[bgn] >= L'0' && brand[bgn] <= L'9')
{ {
sub += _wtoi(brand.c_str() + bgn) % 100; sub = _wtoi(brand.c_str() + bgn);
//sub += _wtoi(brand.c_str() + bgn) % 100;
//if(main) //if(main)
sub++; sub++;
swprintf_s(ver, _countof(ver) - 1, L"%d\r\n", sub); swprintf_s(ver, _countof(ver) - 1, L"%d\r\n", sub);
@ -266,6 +285,36 @@ static bool change_build(std::wstring& brand, int build)
return ret; return ret;
} }
static bool change_build(std::wstring& brand, oem o, bool x86)
{
wchar_t ver[20] = { 0 };
int next = 0,
bgn = find_line(brand, L"#define VERSION_BUILD1", &next),
build = oem_code(o);
bool ret = false;
build *= 10;
build += x86 ? 0 : 1;
build *= 100;
swprintf_s(ver, _countof(ver) - 1, L"%d\r\n", build);
if (bgn >= 0)
{
bgn += lstrlenW(L"#define VERSION_BUILD1");
while (brand[bgn] == L'\t' || brand[bgn] == L' ')
bgn++;
if (brand[bgn] >= L'0' && brand[bgn] <= L'9')
{
brand.replace(bgn, next - bgn, ver);
ret = true;
}
}
if (!ret)
std::wcout << L" change VERSION_BUILD1 to '" << ver << L"+' failed.\r\n";
return ret;
}
static bool change_patch(std::wstring& brand, int patch) static bool change_patch(std::wstring& brand, int patch)
{ {
wchar_t ver[20] = { 0 }; wchar_t ver[20] = { 0 };
@ -1054,12 +1103,15 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main
build = cur->tm_year + 1900, build = cur->tm_year + 1900,
patch = (cur->tm_mon + 1) * 1000 + cur->tm_mday * 10; patch = (cur->tm_mon + 1) * 1000 + cur->tm_mday * 10;
if (vendor == OEM_HANWANG) //if (vendor == OEM_HANWANG)
patch += 6; // patch += 6;
else if (vendor == OEM_LISICHENG) //else if (vendor == OEM_LISICHENG)
patch += 7; // patch += 7;
else //else
patch += 1; // patch += 1;
patch = cur->tm_year % 100;
patch *= 1000;
patch += cur->tm_yday + 1;
while (change_oem(unic, vendor)) while (change_oem(unic, vendor))
{ {
@ -1070,7 +1122,7 @@ static bool set_ver(const wchar_t* file, oem vendor, bool x86, int pid, int main
if (!change_sub(unic, sub, main)) if (!change_sub(unic, sub, main))
break; break;
} }
if (!change_build(unic, build)) if (!change_build(unic, vendor, x86))
break; break;
if (!change_patch(unic, patch)) if (!change_patch(unic, patch))
break; break;