mirror of
https://github.com/solemnwarning/directplay-lite
synced 2024-12-30 16:45:37 +01:00
Implemented DirectPlay8Address skeleton
This commit is contained in:
parent
b2c025b530
commit
1c41ec3b76
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ CXXFLAGS := -std=c++11 -Wall
|
||||
|
||||
all: dpnet.dll
|
||||
|
||||
dpnet.dll: src/dpnet.o src/dpnet.def src/DirectPlay8Peer.o
|
||||
dpnet.dll: src/dpnet.o src/dpnet.def src/DirectPlay8Address.o src/DirectPlay8Peer.o
|
||||
$(CXX) $(CXXFLAGS) -Wl,--enable-stdcall-fixup -shared -o $@ $^ -ldxguid -static-libstdc++ -static-libgcc
|
||||
|
||||
%.o: %.cpp
|
||||
|
155
src/DirectPlay8Address.cpp
Normal file
155
src/DirectPlay8Address.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
#include <atomic>
|
||||
#include <dplay8.h>
|
||||
#include <objbase.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "DirectPlay8Address.hpp"
|
||||
|
||||
#define UNIMPLEMENTED(fmt, ...) \
|
||||
fprintf(stderr, "Unimplemented method: " fmt "\n", ## __VA_ARGS__); \
|
||||
return E_NOTIMPL;
|
||||
|
||||
DirectPlay8Address::DirectPlay8Address(std::atomic<unsigned int> *global_refcount):
|
||||
global_refcount(global_refcount),
|
||||
local_refcount(0)
|
||||
{
|
||||
AddRef();
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::QueryInterface(REFIID riid, void **ppvObject)
|
||||
{
|
||||
if(riid == IID_IDirectPlay8Address || riid == IID_IUnknown)
|
||||
{
|
||||
*((IUnknown**)(ppvObject)) = this;
|
||||
AddRef();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
else{
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
ULONG DirectPlay8Address::AddRef(void)
|
||||
{
|
||||
if(global_refcount != NULL)
|
||||
{
|
||||
++(*global_refcount);
|
||||
}
|
||||
|
||||
return ++local_refcount;
|
||||
}
|
||||
|
||||
ULONG DirectPlay8Address::Release(void)
|
||||
{
|
||||
std::atomic<unsigned int> *global_refcount = this->global_refcount;
|
||||
|
||||
ULONG rc = --local_refcount;
|
||||
if(rc == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
if(global_refcount != NULL)
|
||||
{
|
||||
--(*global_refcount);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::BuildFromURLW(WCHAR* pwszSourceURL)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::BuildFromURLW");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::BuildFromURLA(CHAR* pszSourceURL)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::BuildFromURLA");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::Duplicate(PDIRECTPLAY8ADDRESS* ppdpaNewAddress)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::Duplicate");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::SetEqual(PDIRECTPLAY8ADDRESS pdpaAddress)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::SetEqual");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::IsEqual(PDIRECTPLAY8ADDRESS pdpaAddress)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::IsEqual");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::Clear()
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::Clear");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::GetURLW(WCHAR* pwszURL, PDWORD pdwNumChars)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::GetURLW");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::GetURLA(CHAR* pszURL, PDWORD pdwNumChars)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::GetURLA");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::GetSP(GUID* pguidSP)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::GetSP");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::GetUserData(LPVOID pvUserData, PDWORD pdwBufferSize)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::GetUserData");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::SetSP(CONST GUID* CONST pguidSP)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::SetSP");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::SetUserData(CONST void* CONST pvUserData, CONST DWORD dwDataSize)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::SetUserData");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::GetNumComponents(PDWORD pdwNumComponents)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::GetNumComponents");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::GetComponentByName(CONST WCHAR* CONST pwszName, LPVOID pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::GetComponentByName");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::GetComponentByIndex(CONST DWORD dwComponentID, WCHAR* pwszName, PDWORD pdwNameLen, void* pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::GetComponentByIndex");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::AddComponent(CONST WCHAR* CONST pwszName, CONST void* CONST lpvData, CONST DWORD dwDataSize, CONST DWORD dwDataType)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::AddComponent");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::GetDevice(GUID* pDevGuid)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::GetDevice");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::SetDevice(CONST GUID* CONST devGuid)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::SetDevice");
|
||||
}
|
||||
|
||||
HRESULT DirectPlay8Address::BuildFromDirectPlay4Address(LPVOID pvAddress, DWORD dwDataSize)
|
||||
{
|
||||
UNIMPLEMENTED("DirectPlay8Address::BuildFromDirectPlay4Address");
|
||||
}
|
45
src/DirectPlay8Address.hpp
Normal file
45
src/DirectPlay8Address.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef DPLITE_DIRECTPLAY8ADDRESS_HPP
|
||||
#define DPLITE_DIRECTPLAY8ADDRESS_HPP
|
||||
|
||||
#include <atomic>
|
||||
#include <dplay8.h>
|
||||
#include <objbase.h>
|
||||
|
||||
class DirectPlay8Address: public IDirectPlay8Address
|
||||
{
|
||||
private:
|
||||
std::atomic<unsigned int> * const global_refcount;
|
||||
ULONG local_refcount;
|
||||
|
||||
public:
|
||||
DirectPlay8Address(std::atomic<unsigned int> *global_refcount);
|
||||
virtual ~DirectPlay8Address() {}
|
||||
|
||||
/* IUnknown */
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) override;
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef() override;
|
||||
virtual ULONG STDMETHODCALLTYPE Release() override;
|
||||
|
||||
/* IDirectPlay8Address */
|
||||
virtual HRESULT STDMETHODCALLTYPE BuildFromURLW(WCHAR* pwszSourceURL) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE BuildFromURLA(CHAR* pszSourceURL) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE Duplicate(PDIRECTPLAY8ADDRESS* ppdpaNewAddress) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetEqual(PDIRECTPLAY8ADDRESS pdpaAddress) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE IsEqual(PDIRECTPLAY8ADDRESS pdpaAddress) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE Clear() override;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetURLW(WCHAR* pwszURL, PDWORD pdwNumChars) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetURLA(CHAR* pszURL, PDWORD pdwNumChars) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetSP(GUID* pguidSP) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetUserData(LPVOID pvUserData, PDWORD pdwBufferSize) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetSP(CONST GUID* CONST pguidSP) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetUserData(CONST void* CONST pvUserData, CONST DWORD dwDataSize) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetNumComponents(PDWORD pdwNumComponents) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetComponentByName(CONST WCHAR* CONST pwszName, LPVOID pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetComponentByIndex(CONST DWORD dwComponentID, WCHAR* pwszName, PDWORD pdwNameLen, void* pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE AddComponent(CONST WCHAR* CONST pwszName, CONST void* CONST lpvData, CONST DWORD dwDataSize, CONST DWORD dwDataType) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDevice(GUID* pDevGuid) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE SetDevice(CONST GUID* CONST devGuid) override;
|
||||
virtual HRESULT STDMETHODCALLTYPE BuildFromDirectPlay4Address(LPVOID pvAddress, DWORD dwDataSize) override;
|
||||
};
|
||||
|
||||
#endif /* DPLITE_DIRECTPLAY8ADDRESS_HPP */
|
@ -1,7 +1,9 @@
|
||||
#include <atomic>
|
||||
#include <dplay8.h>
|
||||
#include <objbase.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "DirectPlay8Address.hpp"
|
||||
#include "DirectPlay8Peer.hpp"
|
||||
#include "Factory.hpp"
|
||||
|
||||
@ -30,7 +32,12 @@ HRESULT CALLBACK DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
}
|
||||
|
||||
if(rclsid == CLSID_DirectPlay8Peer)
|
||||
if(rclsid == CLSID_DirectPlay8Address)
|
||||
{
|
||||
*((IUnknown**)(ppv)) = new Factory<DirectPlay8Address, IID_IDirectPlay8Address>(&global_refcount);
|
||||
return S_OK;
|
||||
}
|
||||
else if(rclsid == CLSID_DirectPlay8Peer)
|
||||
{
|
||||
*((IUnknown**)(ppv)) = new Factory<DirectPlay8Peer, IID_IDirectPlay8Peer>(&global_refcount);
|
||||
return S_OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user