Skip to content

Commit

Permalink
Upload code for v4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DoubleLabyrinth committed Sep 6, 2019
0 parents commit e83a73b
Show file tree
Hide file tree
Showing 62 changed files with 9,309 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vs/
.vscode/
bin/
obj/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Navicat Keygen

[中文版README](README.zh-CN.md)

This repository will tell you how Navicat offline activation works.

Previous code is archived in [`windows-archived`](https://github.com/DoubleLabyrinth/navicat-keygen/tree/windows-archived) branch for the reason that previos code contains 3rd binary libraries and it gets quite big :-(.

When you git-clone this repo, please add `--single-branch` flag so that archived branch won't be cloned to your computer, which saves your time and disk.

```console
$ git clone -b windows --single-branch https://github.com/DoubleLabyrinth/navicat-keygen.git
```

## 1. How does it work?

see [here](doc/how-does-it-work.md)

## 2. How to build?

see [here](doc/how-to-build.md).

## 3. How to use?

For Windows users, see [here](doc/how-to-use.windows.md).

For Linux users, see [here](doc/how-to-use.linux.md).

## 4. Contributor

* Deltafox79

* dragonflylee

* zenuo

34 changes: 34 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Navicat Keygen

这份repo将会告诉你Navicat是怎么完成离线激活的。

由于历史代码包含第三方二进制库,且大小较大,故决定将该项目的历史代码归档到 [`windows-archived`](https://github.com/DoubleLabyrinth/navicat-keygen/tree/windows-archived) 分支。

当你clone该仓库的时候,请使用 `--single-branch` 选项,以此避免clone到 `windows-archived` 分支,并且还可以节省你的时间和磁盘空间。

```console
$ git clone -b windows --single-branch https://github.com/DoubleLabyrinth/navicat-keygen.git
```

## 1. 注册机是怎么工作的?

[这里](doc/how-does-it-work.zh-CN.md)

## 2. 如何编译?

[这里](doc/how-to-build.zh-CN.md)

## 3. 如何使用这个注册机?

针对 Windows 用户,请见[这里](doc/how-to-use.windows.zh-CN.md)

针对 Linux 用户,请见[这里](doc/how-to-use.linux.zh-CN.md)

## 4. 贡献者

* Deltafox79

* dragonflylee

* zenuo

16 changes: 16 additions & 0 deletions bash/navicat-keygen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

cd `dirname "$0"`
navicat_root=`pwd`

# Wine environment variables
WINEDIR="wine"
export LANG="en_US.UTF-8"
export PATH="$navicat_root/$WINEDIR/bin":"$navicat_root":"$navicat_root/$WINEDIR/drive_c/windows":"$PATH"
export LD_LIBRARY_PATH="$navicat_root/$WINEDIR/lib":"$navicat_root/lib":"$LD_LIBRARY_PATH"
export WINEDLLPATH="$navicat_root/$WINEDIR/lib/wine"
export WINELOADER="$navicat_root/$WINEDIR/bin/wine64"
export WINESERVER="$navicat_root/$WINEDIR/bin/wineserver"
export WINEPREFIX="$HOME/.navicat64"

exec "${WINELOADER:-wine}" "navicat-keygen.exe" "-text" "RegPrivateKey.pem"
26 changes: 26 additions & 0 deletions bash/navicat-patcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

cd `dirname "$0"`
navicat_root=`pwd`

# Wine environment variables
WINEDIR="wine"
export LANG="en_US.UTF-8"
export PATH="$navicat_root/$WINEDIR/bin":"$navicat_root":"$navicat_root/$WINEDIR/drive_c/windows":"$PATH"
export LD_LIBRARY_PATH="$navicat_root/$WINEDIR/lib":"$navicat_root/lib":"$LD_LIBRARY_PATH"
export WINEDLLPATH="$navicat_root/$WINEDIR/lib/wine"
export WINELOADER="$navicat_root/$WINEDIR/bin/wine64"
export WINESERVER="$navicat_root/$WINEDIR/bin/wineserver"
export WINEPREFIX="$HOME/.navicat64"

# 将斜线替换为反斜线
navicat_root_back_slash=${navicat_root//\//\\}
# 前缀
prefix='Z:\'
# 后缀
suffix='\Navicat'
# wine环境中的navicat路径
navicat_path="$prefix$navicat_root_back_slash$suffix"

# wine执行navicat-patcher.exe
exec "${WINELOADER:-wine}" "navicat-patcher.exe" "$navicat_path"
66 changes: 66 additions & 0 deletions common/Exception.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#pragma once
#include <windows.h>
#include "xstring.hpp"
#include <vector>

namespace nkg {

class Exception {
private:

PCTSTR _SourceFile;
SIZE_T _SourceLine;
PCTSTR _Message;
std::vector<std::xstring> _Hints;

public:

Exception(PCTSTR SourceFile, SIZE_T SourceLine, PCTSTR CustomMessage) noexcept :
_SourceFile(SourceFile),
_SourceLine(SourceLine),
_Message(CustomMessage) {}

[[nodiscard]]
auto File() const noexcept {
return _SourceFile;
}

[[nodiscard]]
auto Line() const noexcept {
return _SourceLine;
}

[[nodiscard]]
auto Message() const noexcept {
return _Message;
}

auto& AddHint(const std::xstring& Hint) {
_Hints.emplace_back(Hint);
return *this;
}

[[nodiscard]]
const auto& Hints() const noexcept {
return _Hints;
}

[[nodiscard]]
virtual bool HasErrorCode() const noexcept {
return false;
}

[[nodiscard]]
virtual ULONG_PTR ErrorCode() const noexcept {
return 0;
}

[[nodiscard]]
virtual PCTSTR ErrorString() const noexcept {
return nullptr;
}

virtual ~Exception() = default;
};

}
44 changes: 44 additions & 0 deletions common/ExceptionOpenssl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once
#include "Exception.hpp"
#include <openssl/err.h>

namespace nkg {

class OpensslError final : public Exception {
private:

unsigned long _ErrorCode;
std::xstring _ErrorString;

public:

OpensslError(PCTSTR SourceFile, SIZE_T SourceLine, unsigned long OpensslErrorCode, PCTSTR CustomMessage) noexcept :
Exception(SourceFile, SourceLine, CustomMessage),
_ErrorCode(OpensslErrorCode)
{
static bool CryptoStringsLoaded = false;
if (CryptoStringsLoaded == false) {
ERR_load_crypto_strings();
CryptoStringsLoaded = true;
}

_ErrorString = std::xstring(std::xstring_extension{}, ERR_reason_error_string(_ErrorCode), CP_UTF8);
}

[[nodiscard]]
virtual bool HasErrorCode() const noexcept override {
return true;
}

[[nodiscard]]
virtual ULONG_PTR ErrorCode() const noexcept override {
return _ErrorCode;
}

[[nodiscard]]
virtual PCTSTR ErrorString() const noexcept override {
return _ErrorString.c_str();
}
};

}
28 changes: 28 additions & 0 deletions common/ExceptionUser.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include "Exception.hpp"

namespace nkg {

class UserAbortionError final : public Exception {
public:

UserAbortionError(PCTSTR SourceFile, SIZE_T SourceLine, PCTSTR CustomMessage) noexcept :
Exception(SourceFile, SourceLine, CustomMessage) {}

[[nodiscard]]
virtual bool HasErrorCode() const noexcept override {
return false;
}

[[nodiscard]]
virtual ULONG_PTR ErrorCode() const noexcept override {
return 0;
}

[[nodiscard]]
virtual PCTSTR ErrorString() const noexcept override {
return nullptr;
}
};

}
49 changes: 49 additions & 0 deletions common/ExceptionWin32.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once
#include "Exception.hpp"

namespace nkg {

class Win32Error final : public Exception {
private:

DWORD _ErrorCode;
std::xstring _ErrorString;

public:

Win32Error(PCTSTR SourceFile, SIZE_T SourceLine, DWORD Win32ErrorCode, PCTSTR CustomMessage) noexcept :
Exception(SourceFile, SourceLine, CustomMessage),
_ErrorCode(Win32ErrorCode)
{
PTSTR Text = NULL;
FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
NULL,
Win32ErrorCode,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
reinterpret_cast<PTSTR>(&Text),
0,
NULL
);
if (Text) {
_ErrorString = Text;
LocalFree(Text);
}
}

[[nodiscard]]
virtual bool HasErrorCode() const noexcept override {
return true;
}

[[nodiscard]]
virtual ULONG_PTR ErrorCode() const noexcept override {
return _ErrorCode;
}

[[nodiscard]]
virtual PCTSTR ErrorString() const noexcept override {
return _ErrorString.c_str();
}
};
}
Loading

0 comments on commit e83a73b

Please sign in to comment.