feat: add dynamic library build

This commit is contained in:
2024-03-24 17:27:41 +08:00
parent aa7ae6128d
commit d8a0944810
2 changed files with 59 additions and 7 deletions

29
src/lib/libncmdump.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include "ncmcrypt.h"
#define API __declspec(dllexport)
extern "C" {
API NeteaseCrypt* CreateNeteaseCrypt(const char* path) {
return new NeteaseCrypt(std::string(path));
}
API int Dump(NeteaseCrypt* neteaseCrypt) {
try
{
neteaseCrypt->Dump();
}
catch (const std::invalid_argument& e)
{
return 1;
}
return 0;
}
API void FixMetadata(NeteaseCrypt* neteaseCrypt) {
neteaseCrypt->FixMetadata();
}
API void DestroyNeteaseCrypt(NeteaseCrypt* neteaseCrypt) {
delete neteaseCrypt;
}
}