Skip to content

Commit

Permalink
Freeing legit product list
Browse files Browse the repository at this point in the history
  • Loading branch information
acidicoala committed Mar 3, 2021
1 parent f401156 commit 2b7a892
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
3 changes: 2 additions & 1 deletion UplayR2Unlocker.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
5539,
5540,
5541,
5542
5542,
5724
],
"items": [
5507,
Expand Down
Binary file modified UplayR2Unlocker/UplayR2Unlocker.aps
Binary file not shown.
2 changes: 1 addition & 1 deletion UplayR2Unlocker/UplayR2Unlocker.rc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ BEGIN
VALUE "FileDescription", "Legit DLC Unlocker for Ubisoft Connect"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", "UplayR2U.dll"
VALUE "LegalCopyright", "Fuck the copyright >:D"
VALUE "LegalCopyright", "Credit to Mr_Goldberg"
VALUE "OriginalFilename", "uplay_r264.dll"
VALUE "ProductName", "Uplay R2 Unlocker"
VALUE "ProductVersion", "1.0.0.0"
Expand Down
18 changes: 14 additions & 4 deletions UplayR2Unlocker/UplayR2Unlocker.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)Build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)Build\$(Platform)\$(Configuration)\</IntDir>
<TargetName>uplay_r2</TargetName>
<TargetName>uplay_r2_loader</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)Build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)Build\$(Platform)\$(Configuration)\</IntDir>
<TargetName>uplay_r2</TargetName>
<TargetName>uplay_r2_loader</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetName>uplay_r264</TargetName>
<TargetName>uplay_r2_loader64</TargetName>
<IntDir>$(ProjectDir)Build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)Build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>uplay_r264</TargetName>
<TargetName>uplay_r2_loader64</TargetName>
<IntDir>$(ProjectDir)Build\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)Build\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
Expand Down Expand Up @@ -147,6 +147,11 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<PostBuildEvent>
<Command>powershell Compress-Archive -Update ^
-Path "$(TargetPath)","$(SolutionDir)UplayR2Unlocker.json" ^
-DestinationPath "$(SolutionDir)Build\UplayR2Unlocker.zip"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand Down Expand Up @@ -185,6 +190,11 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<PostBuildEvent>
<Command>powershell Compress-Archive -Update ^
-Path "$(TargetPath)","$(SolutionDir)UplayR2Unlocker.json" ^
-DestinationPath "$(SolutionDir)Build\UplayR2Unlocker.zip"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Config.h" />
Expand Down
41 changes: 21 additions & 20 deletions UplayR2Unlocker/upc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ EXPORT int UPC_Init(unsigned version, int appID)
return proxyFunc(version, appID);
}

EXPORT int UPC_ProductListFree(void* context, ProductList* inProductList)
{
logger->debug(__func__);
if(inProductList)
{
for(unsigned i = 0; i < inProductList->length; ++i)
{
delete inProductList->data[i];
}

delete[] inProductList->data;
}

delete inProductList;
return 0;
}

void ProductListGetCallback(unsigned long arg1, void* data)
{
logger->debug("{} -> arg1: {}, data: {}", arg1, data);
Expand Down Expand Up @@ -105,7 +122,9 @@ void ProductListGetCallback(unsigned long arg1, void* data)
logger->warn("\tApp ID: {}, Type: {}", missingProduct->appid, productTypeToString(missingProduct->type));
}

// TODO: delete product list. Tiny memory leak, no big deal.
// Free the legit product list
GET_PROXY_FUNC(UPC_ProductListFree);
proxyFunc(callbackContainer->context, callbackContainer->legitProductList);

callbackContainer->originalCallback(arg1, callbackContainer->callbackData);

Expand All @@ -115,7 +134,6 @@ void ProductListGetCallback(unsigned long arg1, void* data)
EXPORT int UPC_ProductListGet(void* context, char* inOptUserIdUtf8, unsigned int inFilter, ProductList** outProductList, UplayCallback inCallback, void* inCallbackData) //CB: 1 argument, 0 val
{
logger->debug("{}", __func__);
logger->debug(L"\tuserID: {}", wstring((LPWCH) inOptUserIdUtf8));

auto productList = new ProductList();
productList->data = new Product * [products.size()];
Expand All @@ -128,30 +146,13 @@ EXPORT int UPC_ProductListGet(void* context, char* inOptUserIdUtf8, unsigned int
*outProductList = productList;

auto callbackContainer = new CallbackContainer{
context,
inCallback,
inCallbackData
};

GET_PROXY_FUNC(UPC_ProductListGet);
return proxyFunc(context, inOptUserIdUtf8, inFilter, &callbackContainer->legitProductList, ProductListGetCallback, callbackContainer);
//return 1 << 4;
}

EXPORT int UPC_ProductListFree(void* context, ProductList* inProductList)
{
logger->debug(__func__);
if(inProductList)
{
for(unsigned i = 0; i < inProductList->length; ++i)
{
delete inProductList->data[i];
}

delete[] inProductList->data;
}

delete inProductList;
return 0;
}

EXPORT const char* UPC_InstallLanguageGet(void* context)
Expand Down
1 change: 1 addition & 0 deletions UplayR2Unlocker/upc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef void (*UplayCallback)(unsigned long, void*);

struct CallbackContainer
{
void* context = NULL;
UplayCallback originalCallback = NULL;
void* callbackData = NULL;
ProductList* legitProductList = NULL;
Expand Down

0 comments on commit 2b7a892

Please sign in to comment.