Skip to content

Commit

Permalink
Update to the new GLib init API
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole André Vadla Ravnås committed Jul 14, 2014
1 parent 86d03c2 commit edfe73a
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 32 deletions.
4 changes: 2 additions & 2 deletions frida-clr.vcxproj
Expand Up @@ -148,7 +148,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\Application.cpp" />
<ClCompile Include="src\Runtime.cpp" />
<ClCompile Include="src\Device.cpp" />
<ClCompile Include="src\Marshal.cpp" />
<ClCompile Include="src\DeviceManager.cpp" />
Expand All @@ -157,7 +157,7 @@
<ClCompile Include="src\Session.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Application.hpp" />
<ClInclude Include="src\Runtime.hpp" />
<ClInclude Include="src\Device.hpp" />
<ClInclude Include="src\Marshal.hpp" />
<ClInclude Include="src\DeviceManager.hpp" />
Expand Down
12 changes: 6 additions & 6 deletions frida-clr.vcxproj.filters
Expand Up @@ -18,9 +18,6 @@
<ClCompile Include="src\DeviceManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Application.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Marshal.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -36,6 +33,9 @@
<ClCompile Include="src\Script.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Runtime.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Marshal.hpp">
Expand All @@ -50,14 +50,14 @@
<ClInclude Include="src\Process.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Application.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Session.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Script.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Runtime.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions src/Device.cpp
@@ -1,8 +1,8 @@
#include "Device.hpp"

#include "Application.hpp"
#include "Marshal.hpp"
#include "Process.hpp"
#include "Runtime.hpp"
#include "Session.hpp"

using System::Windows::Threading::DispatcherPriority;
Expand All @@ -16,7 +16,7 @@ namespace Frida
dispatcher (dispatcher),
icon (nullptr)
{
Application::ref ();
Runtime::Ref ();

selfHandle = new msclr::gcroot<Device ^> (this);
onLostHandler = gcnew EventHandler (this, &Device::OnLost);
Expand Down Expand Up @@ -47,7 +47,7 @@ namespace Frida
g_object_unref (handle);
handle = NULL;

Application::unref ();
Runtime::Unref ();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/DeviceManager.cpp
@@ -1,8 +1,8 @@
#include "DeviceManager.hpp"

#include "Application.hpp"
#include "Device.hpp"
#include "Marshal.hpp"
#include "Runtime.hpp"

using System::Windows::Threading::DispatcherPriority;

Expand All @@ -13,7 +13,7 @@ namespace Frida
DeviceManager::DeviceManager (Dispatcher ^ dispatcher)
: dispatcher (dispatcher)
{
Application::ref ();
Runtime::Ref ();

handle = frida_device_manager_new ();

Expand Down Expand Up @@ -42,7 +42,7 @@ namespace Frida
g_object_unref (handle);
handle = NULL;

Application::unref ();
Runtime::Unref ();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Process.cpp
@@ -1,7 +1,7 @@
#include "Process.hpp"

#include "Application.hpp"
#include "Marshal.hpp"
#include "Runtime.hpp"

namespace Frida
{
Expand All @@ -10,7 +10,7 @@ namespace Frida
smallIcon (nullptr),
largeIcon (nullptr)
{
Application::ref ();
Runtime::Ref ();
}

Process::~Process ()
Expand Down Expand Up @@ -39,7 +39,7 @@ namespace Frida
g_object_unref (handle);
handle = NULL;

Application::unref ();
Runtime::Unref ();
}
}

Expand Down
16 changes: 10 additions & 6 deletions src/Application.cpp → src/Runtime.cpp
@@ -1,34 +1,38 @@
#include "Application.hpp"
#include "Runtime.hpp"

#include <frida-core.h>

namespace Frida
{
volatile int Application::refCount = 0;
volatile int Runtime::refCount = 0;

void Application::ref ()
void Runtime::Ref ()
{
g_atomic_int_inc (&refCount);
glib_init ();
frida_init ();
}

void Application::unref ()
void Runtime::Unref ()
{
if (g_atomic_int_dec_and_test (&refCount))
{
frida_deinit ();
glib_deinit ();
}
}

class Assembly
{
public:
Assembly ()
{
Application::ref ();
Runtime::Ref ();
}

~Assembly ()
{
Application::unref ();
Runtime::Unref ();
}
};
static Assembly assembly;
Expand Down
6 changes: 3 additions & 3 deletions src/Application.hpp → src/Runtime.hpp
Expand Up @@ -2,11 +2,11 @@

namespace Frida
{
class Application
class Runtime
{
public:
static void ref ();
static void unref ();
static void Ref ();
static void Unref ();

private:
static volatile int refCount;
Expand Down
6 changes: 3 additions & 3 deletions src/Script.cpp
@@ -1,7 +1,7 @@
#include "Script.hpp"

#include "Application.hpp"
#include "Marshal.hpp"
#include "Runtime.hpp"

using System::Windows::Threading::DispatcherPriority;

Expand All @@ -13,7 +13,7 @@ namespace Frida
: handle (handle),
dispatcher (dispatcher)
{
Application::ref ();
Runtime::Ref ();

selfHandle = new msclr::gcroot<Script ^> (this);
onMessageHandler = gcnew ScriptMessageHandler (this, &Script::OnMessage);
Expand All @@ -39,7 +39,7 @@ namespace Frida
g_object_unref (handle);
handle = NULL;

Application::unref ();
Runtime::Unref ();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Session.cpp
@@ -1,7 +1,7 @@
#include "Session.hpp"

#include "Application.hpp"
#include "Marshal.hpp"
#include "Runtime.hpp"
#include "Script.hpp"

using System::Windows::Threading::DispatcherPriority;
Expand All @@ -14,7 +14,7 @@ namespace Frida
: handle (handle),
dispatcher (dispatcher)
{
Application::ref ();
Runtime::Ref ();

selfHandle = new msclr::gcroot<Session ^> (this);
onDetachedHandler = gcnew EventHandler (this, &Session::OnDetached);
Expand All @@ -40,7 +40,7 @@ namespace Frida
g_object_unref (handle);
handle = NULL;

Application::unref ();
Runtime::Unref ();
}
}

Expand Down

0 comments on commit edfe73a

Please sign in to comment.