Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
378 changes: 162 additions & 216 deletions ChangeLogs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions SuperMemoAssistant.sln
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ Global
{380A4F46-413D-49B4-884F-21C7683F093C}.1. Alpha (Debug)|Any CPU.Build.0 = Debug|Any CPU
{380A4F46-413D-49B4-884F-21C7683F093C}.1. Alpha (Debug)|x86.ActiveCfg = Debug|Any CPU
{380A4F46-413D-49B4-884F-21C7683F093C}.1. Alpha (Debug)|x86.Build.0 = Debug|Any CPU
{380A4F46-413D-49B4-884F-21C7683F093C}.2. Beta (Debug)|Any CPU.ActiveCfg = Debug|Any CPU
{380A4F46-413D-49B4-884F-21C7683F093C}.2. Beta (Debug)|Any CPU.Build.0 = Debug|Any CPU
{380A4F46-413D-49B4-884F-21C7683F093C}.2. Beta (Debug)|Any CPU.ActiveCfg = Release|x86
{380A4F46-413D-49B4-884F-21C7683F093C}.2. Beta (Debug)|Any CPU.Build.0 = Release|x86
{380A4F46-413D-49B4-884F-21C7683F093C}.2. Beta (Debug)|x86.ActiveCfg = Debug|Any CPU
{380A4F46-413D-49B4-884F-21C7683F093C}.2. Beta (Debug)|x86.Build.0 = Debug|Any CPU
{380A4F46-413D-49B4-884F-21C7683F093C}.2. Beta (Release)|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
47 changes: 46 additions & 1 deletion src/Core/SuperMemoAssistant.Core/NativeDataCfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
"ElWdw_ComponentData_ComponentCountPtr": "0x000A", // TComponentData::DComponentNo:byte
"ElWdw_ComponentData_IsModifiedPtr": "0x0013", // TComponentData::TheModifiedStatus:Boolean
"Database_InstancePtr": "0x00CA60D0", // gvar_00CA30C8:TDatabase
"Contents_InstancePtr": "0x00CA3804", // gvar_00CA3804:TContents
"Control_ParentOffset": "0x0040", // TControl::FParent:TWinControl
"Control_WindowProcOffset": "0x0048", // TControl::FWindowProc:TWndMethod
"Control_HandleOffset": "0x0288", // TWinControl::FHandle:HWND
Expand Down Expand Up @@ -696,6 +697,7 @@
"SMMain_InstancePtr": "0x00CA61C0", // gvar_00CA31B8:TSMMain (above TContents)
"Registry_FileSpaceInstance": "0x0C", // TDatabase::FileSpace:TFileSpace
"Registry_TextRegistryInstance": "0x4E2", // TDatabase::TextRegistry:TTextRegistry
"Registry_CommentRegistryInstance": "0x4E6", // TDatabase::TCommentRegistry:TextRegistry
"Registry_ImageRegistryInstance": "0x4FA", // TDatabase::ImageRegistry:TImageRegistry
"Registry_SoundRegistryInstance": "0x4FE", // TDatabase::SoundRegistry:TSoundRegistry
"Registry_VideoRegistryInstance": "0x502", // TDatabase::VideoRegistry:TVideoRegistry
Expand All @@ -715,6 +717,7 @@
"ElWdw_ComponentData_ComponentCountPtr": "0x000A", // TComponentData::DComponentNo:byte
"ElWdw_ComponentData_IsModifiedPtr": "0x0013", // TComponentData::TheModifiedStatus:Boolean
"Database_InstancePtr": "0x00CA60D0", // gvar_00CA30C8:TDatabase
"Contents_InstancePtr": "0x00CA3804", // gvar_00CA3804:TContents
"Control_ParentOffset": "0x0040", // TControl::FParent:TWinControl
"Control_WindowProcOffset": "0x0048", // TControl::FWindowProc:TWndMethod
"Control_HandleOffset": "0x0288", // TWinControl::FHandle:HWND
Expand Down Expand Up @@ -771,6 +774,10 @@
"Pattern": "E8 ? ? ? ? EB 7C B2 02",
"Offset": 1
},
"ElWdw_SetGrade": { // TElWind::SetGrade
"Pattern": "E8 ? ? ? ? EB 46 BA ? ? ? ? 8B 45 FC",
"Offset": 1
},
"ElWdw_ScheduleInInterval": { // TElWind::ScheduleInInterval
"Pattern": "E8 ? ? ? ? 80 BD ? ? ? ? ? 75 45 8D 45 8E",
"Offset": 1
Expand Down Expand Up @@ -838,6 +845,42 @@
"Queue_GetItem": { // TQueue::GetItem
"Pattern": "E8 ? ? ? ? 89 45 AB",
"Offset": 1
},
"TPriority_GetElementPriority": { // TPriority::GetElementPriority
"Pattern": "E8 ? ? ? ? DD 5D E8 9B EB 0C",
"Offset": 1
},
"ElWdw_GetElementAsText": { // TElWind::GetElementAsText
"Pattern": "E8 ? ? ? ? 8B 55 E0 8D 45 F8 E8 ? ? ? ? 8D 55 F4",
"Offset": 1
},
"ElWdw_BeginLearning": { // TElWind::BeginLearning
"Pattern": "E8 ? ? ? ? EB 24 8B 55 FC",
"Offset": 1
},
"Contents_FindText": { // TContents::FindText
"Pattern": "E8 ? ? ? ? EB 77 8D 45 F8",
"Offset": 1
},
"Database_SetTitle": { // TDatabase::SetTitle
"Pattern": "E8 ? ? ? ? 83 7D 08 00 74 14",
"Offset": 1
},
"Priority_SetPriority": { // TPriority::SetPriority
"Pattern": "E8 ? ? ? ? 8B 45 92",
"Offset": 1
},
"Database_AppendComment": { // TDatabase::AppendComment
"Pattern": "E8 ? ? ? ? 8D 55 F0 A1 ? ? ? ? 8B 00 B1 01",
"Offset": 1
},
"ElWdw_DismissElement": { // TElWind::DismissElement
"Pattern": "E8 ? ? ? ? B1 01 8B 55 E0 A1 ? ? ? ? E8 ? ? ? ? 80 7D F7 00",
"Offset": 1
},
"ElWdw_NextRepetitionClick": { // TElWind::NextRepetitionClick
"Pattern": "E8 ? ? ? ? 59 59 5D C3 8B C0 55 8B EC 51 89 45 FC 33 D2",
"Offset": 1
}
},
"NativeDataPatterns": {},
Expand All @@ -853,7 +896,9 @@
// TElWind::ForceRepetitionExt
"ElWdw_ForceRepetitionExt": "55 8B EC 81 C4 ? ? ? ? 88 4D F7 89 55 F8 89 45 FC 8D 4D 81",
// ???? TElWind::MIForgetClick or TElWind::MIJumpIntervalClick => Last call
"ElWdw_RestoreLearningMode": "55 8B EC 51 89 45 FC 8B 45 FC 80 B8 ? ? ? ? ? 75 1E"
"ElWdw_RestoreLearningMode": "55 8B EC 51 89 45 FC 8B 45 FC 80 B8 ? ? ? ? ? 75 1E",
"ElWdw_BackButtonClick": "55 8B EC 83 C4 F4 89 55 F4 89 45 FC 8B 45 FC E8 ? ? ? ? 84 C0 0F 85 ? ? ? ?",
"ElWdw_ForwardButtonClick": "55 8B EC 83 C4 F4 89 55 F4 89 45 FC A1 ? ? ? ? 8B 00 8B 80 ? ? ? ? E8 ? ? ? ?"
}
}
}
11 changes: 10 additions & 1 deletion src/Core/SuperMemoAssistant.Core/SMA/CoreEx.Hook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ public static int ExecuteOnMainThread(
this NativeMethod method,
params dynamic[] parameters)
{
return Core.Hook.ExecuteOnMainThread(method, parameters);
dynamic __unused = null;
return Core.Hook.ExecuteOnMainThread(method, parameters, out __unused);
}

public static int ExecuteOnMainThreadWithOutParameter(
this NativeMethod method,
out dynamic outParameter,
params dynamic[] parameters)
{
return Core.Hook.ExecuteOnMainThread(method, parameters, out outParameter);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,21 @@ public IEnumerable<IElement> FindByName(Regex regex)
return Elements.Values.Where(e => regex.IsMatch(e.Title)).Select(e => (IElement)e).ToList();
}

public IEnumerable<IElement> FindByComment(Regex regex)
{
return Elements.Values.Where(e => regex.IsMatch(e.Comment)).Select(e => (IElement)e).ToList();
}

public IElement FirstOrDefaultByName(Regex regex)
{
return (IElement)Elements.Values.FirstOrDefault(e => regex.IsMatch(e.Title));
}

public IElement FirstOrDefaultByComment(Regex regex)
{
return (IElement)Elements.Values.FirstOrDefault(e => e.Comment != null && regex.IsMatch(e.Comment));
}

public IElement FirstOrDefaultByName(string exactName)
{
return (IElement)Elements.Values.FirstOrDefault(e => e.Title == exactName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#region License & Metadata

// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
//
// Created On: 2022/12/17 14:51
// Modified On: 2022/12/17 14:55
// Modified By: Ki

#endregion




using SuperMemoAssistant.Interop;

namespace SuperMemoAssistant.SuperMemo.Common.Registry.Files
{
public class CommentFileDescriptor : IRegistryFileDescriptor
{
#region Properties Impl - Public

public string RegistryName => "Comment";
public string MemFileName => SMConst.Files.CommentMemFileName;
public string RtxFileName => SMConst.Files.CommentRtxFileName;
public string RtfFileName => SMConst.Files.CommentRtfFileName;
public bool IsOptional => true;

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ protected virtual IEnumerable<ISMAHookIO> GetIOCallbacks()
_registry.Element,
_registry.Component,
_registry.Text,
_registry.Comment,
_registry.Binary,
_registry.Concept,
_registry.Image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
//
//
// Created On: 2020/03/29 00:20
// Modified On: 2020/04/09 15:11
// Modified By: Alexis
// Modified On: 2022/12/17 15:11
// Modified By: - Alexis
// - Ki

#endregion

Expand Down Expand Up @@ -129,9 +130,10 @@ public override void GetExecutionParameters(out int method,
}

/// <inheritdoc />
public override void SetExecutionResult(int result)
public override void SetExecutionResult(int result, dynamic outParameter)
{
_execCtxt.ExecutionResult = result;
_execCtxt.ExecutionOutParameter = outParameter;
_mainThreadReadyEvent.Set();
}

Expand All @@ -144,13 +146,15 @@ public override void SetExecutionResult(int result)

// TODO: Not thread safe & ugly overall...
public int ExecuteOnMainThread(NativeMethod method,
dynamic[] parameters)
dynamic[] parameters,
out dynamic outParameter)
{
_mainThreadReadyEvent.Reset();

_execCtxt.ExecutionResult = 0;
_execCtxt.ExecutionMethod = method;
_execCtxt.ExecutionParameters = parameters;
_execCtxt.ExecutionOutParameter = null;

var smMem = Core.SM.SMProcess.Memory;

Expand All @@ -172,6 +176,7 @@ public int ExecuteOnMainThread(NativeMethod method,
Core.Natives.Application.TApplicationOnMessagePtr.Write<int>(smMem, 0);

_execCtxt.ExecutionParameters = null;
outParameter = _execCtxt.ExecutionOutParameter;

return _execCtxt.ExecutionResult;
}
Expand All @@ -187,6 +192,7 @@ private class ExecutionContext

public NativeMethod ExecutionMethod { get; set; }
public IEnumerable<dynamic> ExecutionParameters { get; set; }
public dynamic ExecutionOutParameter { get; set; }
public int ExecutionResult { get; set; }

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#region License & Metadata

// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
//
// Created On: 2021/12/04 15:01
// Modified On: 2021/12/04 16:04
// Modified By: Ki

#endregion




using Anotar.Serilog;
using Process.NET.Types;
using SuperMemoAssistant.SMA;
using System;

// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable InconsistentNaming

namespace SuperMemoAssistant.SuperMemo.Natives
{
public partial class SMNatives
{
public class TContents
{
#region Constructors

public TContents(NativeData nativeData)
{
InstancePtr = new IntPtr(nativeData.Pointers[NativePointer.Contents_InstancePtr]);
}

#endregion




#region Properties & Fields - Public

public IntPtr InstancePtr { get; }

#endregion

public bool FindText(IntPtr contentsPtr, string text)
{
throw new NotImplementedException();
/* This does nothing!
try
{
string str = "Testng";
return NativeMethod.Contents_FindText.ExecuteOnMainThread(
contentsPtr,
str) == 1;
}
catch (Exception ex)
{
LogTo.Error(ex, "Native method call threw an exception.");
return false;
}
*/
}
}
}
}
Loading