Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mika-f committed Jul 17, 2023
2 parents 52bd17f + 2358e60 commit a7931ff
Show file tree
Hide file tree
Showing 24 changed files with 395 additions and 142 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ body:
- 2.4.0
- 2.5.0
- 2.6.0
- 2.7.0
validations:
required: true
- type: dropdown
Expand All @@ -55,6 +56,7 @@ body:
- 3.4.1
- 3.5.0
- 3.5.1
- 3.6.0
- edge
- type: textarea
id: logs
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ body:
- 3.4.1
- 3.5.0
- 3.5.1
- 3.6.0
- edge
69 changes: 69 additions & 0 deletions .github/workflows/release-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release for Windows

on:
push:
tags:
- "v**"
workflow_dispatch:

jobs:
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.vars.outputs.version }}
steps:
- id: vars
run: |
VERSION=$(echo ${{ github.ref }} | sed -e 's/refs\/tags\///' | sed -e 's/refs\/heads\///' | sed -e 's/\//-/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
build:
runs-on: windows-2022
needs: [setup]
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Add MSBuild to PATH
uses: microsoft/[email protected]

- name: Build Injector for Release
run: |
msbuild -p:Configuration=Release -p:Platform=x64 -t:Rebuild src/blender-injection/blender-injection.vcxproj
- name: Build Extension for Release
shell: powershell
run: |
New-Item .\bin -Type Directory
Copy-Item -Recurse .\src\blender-extension\ .\bin\drag-and-drop-support\
- name: Collect Artifacts
shell: powershell
run: |
$Archive = ".\bin\x64\DragAndDropSupport-${{ needs.setup.outputs.version }}"
$Dest = "$Archive\drag-and-drop-support"
New-Item $Dest -Type Directory
Copy-Item .\src\blender-injection\x64\Release\*.dll $Dest\
Copy-Item .\src\blender-extension\* $Dest\
Copy-Item .\src\LICENSE.txt $Archive\
Compress-Archive "$Dest" "$Dest.zip"
Remove-Item -Recurse $Dest
- name: Packaging Artifacts
shell: powershell
run: |
$Dest = "bin/x64/DragAndDropSupport-${{ needs.setup.outputs.version }}"
Compress-Archive "$Dest" "$Dest.zip"
Remove-Item -Recure $Dest
Get-FileHash -Algorithm SHA256 "$Dest.zip" | Select-Object -ExpandProperty Hash | Tee-Object -FilePath "$Dest.zip.sha256"
Get-FileHash -Algorithm MD5 "$Dest.zip" | Select-Object -ExpandProperty Hash | Tee-Object -FilePath "$Dest.zip.md5"
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: Windows-x64-Artifacts
path: bin/x64/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ v2.0.0 supports the following versions of Blender:
- Blender 3.4.1 (x64 - Windows)
- Blender 3.5.0 (x64 - Windows)
- Blender 3.5.1 (x64 - Windows)
- Blender 3.6.0 (x64 - Windows)

## Installation

Expand Down
Binary file added assets/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 17 additions & 3 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ set VERSION=%3

if "%ARCH%" == "" (
echo usage: build.bat $arch $target $version
echo example: build.bat x64 Release 1.0.0
goto :error_exit
)

if "%TARGET%" == "" (
echo usage: build.bat $arch $target $version
echo example: build.bat x64 Release 1.0.0
goto :error_exit
)

if "%VERSION%" == "" (
echo usage: build.bat $arch $target $version
echo example: build.bat x64 Release 1.0.0
goto :error_exit
)

Expand Down Expand Up @@ -92,7 +95,7 @@ echo F | xcopy /s "src\blender-injection\%1\"%2"\*.dll" "%DEST%\drag-and-drop-su
echo F | xcopy /s "src\blender-extension\*" "%DEST%\drag-and-drop-support\"
echo F | xcopy "src\LICENSE.txt" "%DEST%\"

powershell compress-archive "%DEST%\drag-and-drop-support" "%DEST%\drag-and-drop-support.zip"
pwsh -Command compress-archive "%DEST%\drag-and-drop-support" "%DEST%\drag-and-drop-support.zip"
echo Y | rmdir /s "%DEST%\drag-and-drop-support"

echo ******************************************************************************************************
Expand All @@ -103,6 +106,17 @@ if exist "%DEST%.zip" (
del "%DEST%.zip"
)

powershell compress-archive %DEST% %DEST%.zip
pwsh -Command compress-archive %DEST% %DEST%.zip

echo "packaged -> %DEST%.zip"

set HASH=
for /F "usebackq skip=1 delims==" %%i in (`certutil -hashfile %DEST%.zip SHA256`) do (
if not defined HASH (
set HASH=%%i
)
)

echo %HASH% > "%DEST%.zip.sha256"

echo "packaged -> %DEST%.zip"
echo "hash -> %HASH%"
2 changes: 1 addition & 1 deletion src/blender-extension/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Natsuneko",
"description": "Blender add-on for import some files from drag-and-drop",
"blender": (3, 1, 0),
"version": (2, 6, 0),
"version": (2, 7, 0),
"location": "Drag and Drop Support",
"warning": "",
"category": "Import-Export"
Expand Down
127 changes: 10 additions & 117 deletions src/blender-injection/BlenderObj.h
Original file line number Diff line number Diff line change
@@ -1,119 +1,12 @@
#pragma once

// define memory layouts of Blender

struct bContext
{
int thread;

struct
{
void* manager;
void* window;
void* workspace;
void* screen;
void* area;
void* region;
void* menu;
void* gizmo_group;
void* store;

const char* operator_poll_msg;

struct PollMsgDyn_Params
{
char* (*get_fn)(bContext*, void*);
char* (*free_fn)(bContext*, void*);
void* user_data;
} operator_poll_msg_dyn_params;
} wm;

struct
{
void* main;
void* scene;
int recursion;
bool py_init;
void* py_context;
void* py_context_orig;
} data;
};

using eWM_DragFlags = enum eWM_DragFlags
{
WM_DRAG_NOP = 0,
WM_DRAG_FREE_DATA = 1,
};

using ListBase = struct ListBase
{
void *first, *last;
};

using wmDragActiveDropState = struct wmDragActiveDropState
{
struct wmDropBox* active_dropbox;
struct ScrArea* area_from;
struct ARegion* region_from;
struct bContextStore* ui_context;
const char* disabled_info;
bool free_disabled_info;
};

using wmDrag = struct wmDrag
{
struct wmDrag *next, *prev;
int icon;
int type;
void* poin;
char path[1024];
double value;
struct ImBuf* imb;
float imbuf_scale;
wmDragActiveDropState drop_state;
eWM_DragFlags flags;
ListBase ids;
ListBase asset_items;
};

using wmTabletData = struct wmTabletData
{
int active;
float pressure;
float x_tilt;
float y_tilt;
char is_motion_absolute;
};

using eWM_EventFlag = enum eWM_EventFlag
{
WM_EVENT_SCROLL_INVERT = (1 << 0),
WM_EVENT_IS_REPEAT = (1 << 1),
WM_EVENT_FORCE_DRAG_THRESHOLD = (1 << 2),
};

using wmEvent = struct wmEvent
{
struct wmEvent *next, *prev;
short type;
short val;
int xy[2];
int mval[2];
char utf8_buf[6];
uint8_t modifier;
int8_t direction;
short keymodifier;
wmTabletData tablet;
eWM_EventFlag flag;
short custom;
short customdata_free;
void* customdata;
short prev_type;
short prev_val;
int prev_xy[2];
short prev_press_type;
int prev_press_xy[2];
uint8_t prev_press_modifier;
short prev_press_keymodifier;
double prev_press_time;
};
#include "./stubs/bContext.h"
#include "./stubs/eWM_DragDataType.h"
#include "./stubs/eWM_DragFlags.h"
#include "./stubs/eWM_EventFlag.h"
#include "./stubs/ListBase.h"
#include "./stubs/wmDrag.h"
#include "./stubs/wmDragActiveDropState.h"
#include "./stubs/wmDragPath.h"
#include "./stubs/wmEvent.h"
#include "./stubs/wmTabletData.h"
9 changes: 9 additions & 0 deletions src/blender-injection/BlenderPatchPatterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,14 @@ static std::unordered_map<std::string, BlenderPatchPattern> Patchers{
"E8 7B FF FF FF 84 C0",
"E8 0B BC 00 00 48 85 C0"
}
},
{
"3.6.0", {
"E8 FC 8F 41 00 E8 C7 AD 22 04", // CALL and CALL
// "E8 DE 2F 41 00 40 84 F6", // CALL and TEST
"4C 8D 05 F9 07 00 00",
"E8 7B FF FF FF 84 C0",
"E8 EB BD 00 00 48 85 C0"
}
}
};
14 changes: 10 additions & 4 deletions src/blender-injection/BlenderPatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ void BlenderPatcher::FetchVersion()

VerQueryValue(version, "\\", reinterpret_cast<void**>(&pFileInfo), &len);

this->_version = format("%d.%d.%d", HIWORD(pFileInfo->dwFileVersionMS), LOWORD(pFileInfo->dwFileVersionMS), HIWORD(pFileInfo->dwFileVersionLS));
this->_versionString = format("%d.%d.%d", HIWORD(pFileInfo->dwFileVersionMS), LOWORD(pFileInfo->dwFileVersionMS), HIWORD(pFileInfo->dwFileVersionLS));
this->_version = std::make_tuple(HIWORD(pFileInfo->dwFileVersionMS), LOWORD(pFileInfo->dwFileVersionMS), HIWORD(pFileInfo->dwFileVersionLS));
}
}

void BlenderPatcher::ApplyInjector()
{
const auto patterns = &Patchers.at(this->_version);
const auto patterns = &Patchers.at(this->_versionString);
this->_patch = new BlenderPatch(patterns);

const auto address = this->_patch->Get_view3d_ima_empty_drop_poll();
Expand Down Expand Up @@ -126,7 +127,7 @@ void BlenderPatcher::Patch()
{
std::cout << "[ERROR] exception: out of range" << std::endl;
std::cout << "[ERROR] injector detected the unsupported version of Blender. Please upgrade Drag-and-Drop Support or downgrade Blender" << std::endl;
std::cout << "[ERROR] detected version : " << this->_version << std::endl;
std::cout << "[ERROR] detected version : " << this->_versionString << std::endl;
}
}

Expand All @@ -140,10 +141,15 @@ void BlenderPatcher::UnPatch()
{
std::cout << "[ERROR] exception: out of range" << std::endl;
std::cout << "[ERROR] injector detected the unsupported version of Blender. Please upgrade Drag-and-Drop Support or downgrade Blender" << std::endl;
std::cout << "[ERROR] detected version : " << this->_version << std::endl;
std::cout << "[ERROR] detected version : " << this->_versionString << std::endl;
}
}

std::tuple<int, int, int> BlenderPatcher::GetVersion() const
{
return this->_version;
}


bool BlenderPatcher::View3DImaDropPoll(void* c, void* drag, void* event) const
{
Expand Down
8 changes: 6 additions & 2 deletions src/blender-injection/BlenderPatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
class BlenderPatcher
{
private:
std::string _version;
std::string _versionString;
std::tuple<int, int, int> _version;

std::unordered_map<std::uintptr_t, std::vector<unsigned char>> _originals;

Expand All @@ -17,7 +18,8 @@ class BlenderPatcher

BlenderPatcher()
{
this->_version = "0.0.0";
this->_versionString = "0.0.0";
this->_version = std::make_tuple(0, 0, 0);
}

void FetchVersion();
Expand All @@ -32,7 +34,9 @@ class BlenderPatcher

void Patch();
void UnPatch();
std::tuple<int, int, int> GetVersion() const;

// reflections
bool View3DImaDropPoll(void* c, void* drag, void* event) const;
void* EDView3dGiveObjectUnderCursor(void* c, int mvals[2]) const;
void RunStringEval(void* c, const char* imports[], const char* expression) const;
Expand Down
10 changes: 10 additions & 0 deletions src/blender-injection/blender-injection.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,16 @@
<ClInclude Include="injector.hpp" />
<ClInclude Include="pch.h" />
<ClInclude Include="strings.h" />
<ClInclude Include="stubs\bContext.h" />
<ClInclude Include="stubs\eWM_DragDataType.h" />
<ClInclude Include="stubs\wmDragActiveDropState.h" />
<ClInclude Include="stubs\eWM_EventFlag.h" />
<ClInclude Include="stubs\eWM_DragFlags.h" />
<ClInclude Include="stubs\wmDragPath.h" />
<ClInclude Include="stubs\ListBase.h" />
<ClInclude Include="stubs\wmTabletData.h" />
<ClInclude Include="stubs\wmDrag.h" />
<ClInclude Include="stubs\wmEvent.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="BlenderPatch.cpp" />
Expand Down
Loading

0 comments on commit a7931ff

Please sign in to comment.