init commit
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.vs/
|
||||||
|
x64/
|
||||||
|
ARM/
|
||||||
|
Release/
|
||||||
|
Debug/
|
||||||
10
progwrp-CSOG/.gitignore
vendored
Normal file
10
progwrp-CSOG/.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.vs/
|
||||||
|
x64/
|
||||||
|
ARM/
|
||||||
|
Release/
|
||||||
|
Debug/
|
||||||
|
progwrp.pdb
|
||||||
|
progwrp.idb
|
||||||
|
|
||||||
|
rsrc.aps
|
||||||
|
*.user
|
||||||
9
progwrp-CSOG/ReadMe.md
Normal file
9
progwrp-CSOG/ReadMe.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# progwrp CS:OG
|
||||||
|
|
||||||
|
We use this project to make a .lib to link against instead of kernel32, shell32, etc to bring back win2k+ support.
|
||||||
|
|
||||||
|
I belive it should be OSS because I don't know why you would hide a compatiblity wrapper. That's stupid imho
|
||||||
|
|
||||||
|
Our SteamAPI can change imports in the CS:OG client based off your windows version, however that's not included here
|
||||||
|
|
||||||
|
### CS:OG 2026
|
||||||
BIN
progwrp-CSOG/Yes
Normal file
BIN
progwrp-CSOG/Yes
Normal file
Binary file not shown.
96
progwrp-CSOG/advapi.c
Normal file
96
progwrp-CSOG/advapi.c
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_AddMandatoryAce(
|
||||||
|
PACL pAcl,
|
||||||
|
DWORD dwAceRevision,
|
||||||
|
DWORD AceFlags,
|
||||||
|
DWORD MandatoryPolicy,
|
||||||
|
PSID pLabelSid
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Implementation_EventRegister(
|
||||||
|
LPCGUID ProviderId,
|
||||||
|
PENABLECALLBACK EnableCallback,
|
||||||
|
PVOID CallbackContext,
|
||||||
|
PREGHANDLE RegHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Implementation_EventSetInformation(
|
||||||
|
REGHANDLE RegHandle,
|
||||||
|
EVENT_INFO_CLASS InformationClass,
|
||||||
|
PVOID EventInformation,
|
||||||
|
ULONG InformationLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Implementation_EventUnregister(
|
||||||
|
REGHANDLE RegHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Implementation_EventWrite(
|
||||||
|
REGHANDLE RegHandle,
|
||||||
|
PCEVENT_DESCRIPTOR EventDescriptor,
|
||||||
|
ULONG UserDataCount,
|
||||||
|
PEVENT_DATA_DESCRIPTOR UserData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Implementation_EventWriteTransfer(
|
||||||
|
REGHANDLE RegHandle,
|
||||||
|
PCEVENT_DESCRIPTOR EventDescriptor,
|
||||||
|
LPCGUID ActivityId,
|
||||||
|
LPCGUID RelatedActivityId,
|
||||||
|
ULONG UserDataCount,
|
||||||
|
PEVENT_DATA_DESCRIPTOR UserData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN WINAPI Implementation_SystemFunction036(
|
||||||
|
PVOID RandomBuffer,
|
||||||
|
ULONG RandomBufferLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER qpc;
|
||||||
|
int i;
|
||||||
|
PBYTE Test;
|
||||||
|
|
||||||
|
if(!RandomBuffer)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
Test = RandomBuffer;
|
||||||
|
|
||||||
|
QueryPerformanceCounter(&qpc);
|
||||||
|
|
||||||
|
for(i = 0; i < RandomBufferLength; i++)
|
||||||
|
{
|
||||||
|
if(i % 4 == 0)
|
||||||
|
Test[i] = LOBYTE(GetTickCount() ^ qpc.LowPart);
|
||||||
|
if(i % 4 == 2)
|
||||||
|
Test[i] = HIBYTE(LOWORD(GetTickCount()));
|
||||||
|
if(i % 4 == 3)
|
||||||
|
Test[i] = HIBYTE(GetTickCount());
|
||||||
|
QueryPerformanceCounter(&qpc);
|
||||||
|
if(i % 4 == 1)
|
||||||
|
Test[i] = HIBYTE(LOWORD(qpc.LowPart)) >> i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
267
progwrp-CSOG/com_lite.h
Normal file
267
progwrp-CSOG/com_lite.h
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ULONG_PTR pfnQueryInterface;
|
||||||
|
ULONG_PTR pfnAddRef;
|
||||||
|
ULONG_PTR pfnRelease;
|
||||||
|
}IUnknownLite, *pIUnknownLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IUnknownLite IUnknown;
|
||||||
|
ULONG_PTR pfnGetSystemFontCollection;
|
||||||
|
ULONG_PTR pfnCreateCustomFontCollection;
|
||||||
|
ULONG_PTR pfnRegisterFontCollectionLoader;
|
||||||
|
ULONG_PTR pfnUnregisterFontCollectionLoader;
|
||||||
|
ULONG_PTR pfnCreateFontFileReference;
|
||||||
|
ULONG_PTR pfnCreateCustomFontFileReference;
|
||||||
|
ULONG_PTR pfnCreateFontFace;
|
||||||
|
ULONG_PTR pfnCreateRenderingParams;
|
||||||
|
ULONG_PTR pfnCreateMonitorRenderingParams;
|
||||||
|
ULONG_PTR pfnCreateCustomRenderingParams;
|
||||||
|
ULONG_PTR pfnRegisterFontFileLoader;
|
||||||
|
ULONG_PTR pfnUnregisterFontFileLoader;
|
||||||
|
ULONG_PTR pfnCreateTextFormat;
|
||||||
|
ULONG_PTR pfnCreateTypography;
|
||||||
|
ULONG_PTR pfnGetGdiInterop;
|
||||||
|
ULONG_PTR pfnCreateTextLayout;
|
||||||
|
ULONG_PTR pfnCreateGdiCompatibleTextLayout;
|
||||||
|
ULONG_PTR pfnCreateEllipsisTrimmingSign;
|
||||||
|
ULONG_PTR pfnCreateTextAnalyzer;
|
||||||
|
ULONG_PTR pfnCreateNumberSubstitution;
|
||||||
|
ULONG_PTR pfnCreateGlyphRunAnalysis;
|
||||||
|
}IDWriteFactoryLiteTbl, *pIDWriteFactoryLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IUnknownLite IUnknown;
|
||||||
|
ULONG_PTR pfnGetFontFamilyCount;
|
||||||
|
ULONG_PTR pfnGetFontFamily;
|
||||||
|
ULONG_PTR pfnFindFamilyName;
|
||||||
|
ULONG_PTR pfnGetFontFromFontFace;
|
||||||
|
}IDWriteFontCollectionLiteTbl, * pIDWriteFontCollectionLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteFontCollectionLiteTbl Vtbl;
|
||||||
|
ULONG RefCount;
|
||||||
|
}IDWriteFontCollectionLite, * pIDWriteFontCollectionLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IUnknownLite IUnknown;
|
||||||
|
ULONG_PTR pfnGetAlphaTextureBounds;
|
||||||
|
ULONG_PTR pfnGetAlphaBlendParams;
|
||||||
|
ULONG_PTR pfnCreateAlphaTexture;
|
||||||
|
}IDWriteGlyphRunAnalysisLiteTbl, * pIDWriteGlyphRunAnalysisLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteGlyphRunAnalysisLiteTbl Vtbl;
|
||||||
|
ULONG RefCount;
|
||||||
|
}IDWriteGlyphRunAnalysisLite, * pIDWriteGlyphRunAnalysisLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IUnknownLite IUnknown;
|
||||||
|
ULONG_PTR pfnSetTextAlignment;
|
||||||
|
ULONG_PTR pfnSetParagraphAlignment;
|
||||||
|
ULONG_PTR pfnSetWordWrapping;
|
||||||
|
ULONG_PTR pfnSetReadingDirection;
|
||||||
|
ULONG_PTR pfnSetFlowDirection;
|
||||||
|
ULONG_PTR pfnSetIncrementalTabStop;
|
||||||
|
ULONG_PTR pfnSetTrimming;
|
||||||
|
ULONG_PTR pfnSetLineSpacing;
|
||||||
|
ULONG_PTR pfnGetTextAlignment;
|
||||||
|
ULONG_PTR pfnGetParagraphAlignment;
|
||||||
|
ULONG_PTR pfnGetWordWrapping;
|
||||||
|
ULONG_PTR pfnGetReadingDirection;
|
||||||
|
ULONG_PTR pfnGetFlowDirection;
|
||||||
|
ULONG_PTR pfnGetIncrementalTabStop;
|
||||||
|
ULONG_PTR pfnGetTrimming;
|
||||||
|
ULONG_PTR pfnGetLineSpacing;
|
||||||
|
ULONG_PTR pfnGetFontCollection;
|
||||||
|
ULONG_PTR pfnGetFontFamilyNameLength;
|
||||||
|
ULONG_PTR pfnGetFontFamilyName;
|
||||||
|
ULONG_PTR pfnGetFontWeight;
|
||||||
|
ULONG_PTR pfnGetFontStyle;
|
||||||
|
ULONG_PTR pfnGetFontStretch;
|
||||||
|
ULONG_PTR pfnGetFontSize;
|
||||||
|
ULONG_PTR pfnGetLocaleNameLength;
|
||||||
|
ULONG_PTR pfnGetLocaleName;
|
||||||
|
}IDWriteTextFormatLiteTbl, * pIDWriteTextFormatLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteTextFormatLiteTbl Vtbl;
|
||||||
|
ULONG RefCount;
|
||||||
|
}IDWriteTextFormatLite, * pIDWriteTextFormatLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IDWriteTextFormatLiteTbl IDWriteTextFormat;
|
||||||
|
ULONG_PTR pfnSetMaxWidth;
|
||||||
|
ULONG_PTR pfnSetMaxHeight;
|
||||||
|
ULONG_PTR pfnSetFontCollection;
|
||||||
|
ULONG_PTR pfnSetFontFamilyName;
|
||||||
|
ULONG_PTR pfnSetFontWeight; // 0x100
|
||||||
|
ULONG_PTR pfnSetFontStyle;
|
||||||
|
ULONG_PTR pfnSetFontStretch;
|
||||||
|
ULONG_PTR pfnSetFontSize;
|
||||||
|
ULONG_PTR pfnSetUnderline;
|
||||||
|
ULONG_PTR pfnSetStrikethrough;
|
||||||
|
ULONG_PTR pfnSetDrawingEffect;
|
||||||
|
ULONG_PTR pfnSetInlineObject;
|
||||||
|
ULONG_PTR pfnSetTypography;
|
||||||
|
ULONG_PTR pfnSetLocaleName;
|
||||||
|
ULONG_PTR pfnGetMaxWidth;
|
||||||
|
ULONG_PTR pfnGetMaxHeight;
|
||||||
|
ULONG_PTR pfnGetFontCollection;
|
||||||
|
ULONG_PTR pfnGetFontFamilyNameLength;
|
||||||
|
ULONG_PTR pfnGetFontFamilyName;
|
||||||
|
ULONG_PTR pfnGetFontWeight;
|
||||||
|
ULONG_PTR pfnGetFontStyle;
|
||||||
|
ULONG_PTR pfnGetFontStretch;
|
||||||
|
ULONG_PTR pfnGetFontSize;
|
||||||
|
ULONG_PTR pfnGetUnderline;
|
||||||
|
ULONG_PTR pfnGetStrikethrough;
|
||||||
|
ULONG_PTR pfnGetDrawingEffect;
|
||||||
|
ULONG_PTR pfnGetInlineObject;
|
||||||
|
ULONG_PTR pfnGetTypography;
|
||||||
|
ULONG_PTR pfnGetLocaleNameLength;
|
||||||
|
ULONG_PTR pfnGetLocaleName;
|
||||||
|
ULONG_PTR pfnDraw;
|
||||||
|
ULONG_PTR pfnGetLineMetrics;
|
||||||
|
ULONG_PTR pfnGetMetrics;
|
||||||
|
ULONG_PTR pfnGetOverhangMetrics;
|
||||||
|
ULONG_PTR pfnGetClusterMetrics;
|
||||||
|
ULONG_PTR pfnDetermineMinWidth;
|
||||||
|
ULONG_PTR pfnHitTestPoint;
|
||||||
|
ULONG_PTR pfnHitTestTextPosition;
|
||||||
|
ULONG_PTR pfnHitTestTextRange;
|
||||||
|
}IDWriteTextLayoutLiteTbl, * pIDWriteTextLayoutLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteTextLayoutLiteTbl Vtbl;
|
||||||
|
ULONG RefCount;
|
||||||
|
}IDWriteTextLayoutLite, * pIDWriteTextLayoutLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IUnknownLite IUnknown;
|
||||||
|
ULONG_PTR pfnGetFontCollection; // tentative
|
||||||
|
ULONG_PTR pfnGetFontCount;
|
||||||
|
ULONG_PTR pfnGetFont;
|
||||||
|
}IDWriteFontListLiteTbl, * pIDWriteFontListLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteFontListLiteTbl Vtbl;
|
||||||
|
}IDWriteFontListLite, * pIDWriteFontListLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IDWriteFontListLiteTbl IDWriteFontList;
|
||||||
|
ULONG_PTR pfnGetFamilyNames; // tentative
|
||||||
|
ULONG_PTR pfnGetFirstMatchingFont;
|
||||||
|
ULONG_PTR pfnGetMatchingFonts;
|
||||||
|
}IDWriteFontFamilyLiteTbl, * pIDWriteFontFamilyLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteFontFamilyLiteTbl Vtbl;
|
||||||
|
ULONG RefCount;
|
||||||
|
PCWSTR FontFamilyStr;
|
||||||
|
}IDWriteFontFamilyLite, * pIDWriteFontFamilyLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IUnknownLite IUnknown;
|
||||||
|
ULONG_PTR pfnCreateFontFace;
|
||||||
|
ULONG_PTR pfnGetFaceNames;
|
||||||
|
ULONG_PTR pfnGetFontFamily;
|
||||||
|
ULONG_PTR pfnGetInformationalStrings;
|
||||||
|
ULONG_PTR pfnIsSymbolFont;
|
||||||
|
ULONG_PTR pfnGetMetrics;
|
||||||
|
ULONG_PTR pfnGetGlyphCount; // offset 0x48
|
||||||
|
ULONG_PTR pfnGetDesignGlyphMetrics;
|
||||||
|
ULONG_PTR pfnGetGlyphIndices;
|
||||||
|
ULONG_PTR pfnTryGetFontTable;
|
||||||
|
ULONG_PTR pfnReleaseFontTable;
|
||||||
|
ULONG_PTR pfnGetMetrics2;
|
||||||
|
ULONG_PTR pfnGetPanose;
|
||||||
|
ULONG_PTR pfnGetUnicodeRanges;
|
||||||
|
ULONG_PTR pfnIsMonospacedFont;
|
||||||
|
ULONG_PTR pfnIsColorFont;
|
||||||
|
ULONG_PTR pfnCreateFontFace3;
|
||||||
|
ULONG_PTR pfnEquals;
|
||||||
|
ULONG_PTR pfnGetFontFaceReference;
|
||||||
|
ULONG_PTR pfnGetLocality;
|
||||||
|
}IDWriteFontFaceLiteTbl, * pIDWriteFontFaceLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteFontFaceLiteTbl Vtbl;
|
||||||
|
ULONG RefCount;
|
||||||
|
LOGFONTW lf;
|
||||||
|
TEXTMETRICW tm;
|
||||||
|
}IDWriteFontFaceLite, * pIDWriteFontFaceLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IUnknownLite IUnknown;
|
||||||
|
ULONG_PTR pfnIsSymbolFont;
|
||||||
|
ULONG_PTR pfnGetWeight;
|
||||||
|
ULONG_PTR pfnGetStretch;
|
||||||
|
ULONG_PTR pfnGetStyle;
|
||||||
|
ULONG_PTR pfnGetMetrics;
|
||||||
|
ULONG_PTR pfnGetFontFamily;
|
||||||
|
ULONG_PTR pfnGetInformationalStrings;
|
||||||
|
ULONG_PTR pfnGetSimulations;
|
||||||
|
ULONG_PTR pfnGetFaceNames;
|
||||||
|
ULONG_PTR pfnHasCharacter;
|
||||||
|
ULONG_PTR pfnCreateFontFace;
|
||||||
|
ULONG_PTR pfnGetMetrics2;
|
||||||
|
ULONG_PTR pfnGetPanose;
|
||||||
|
ULONG_PTR pfnGetUnicodeRanges;
|
||||||
|
ULONG_PTR pfnIsMonospacedFont;
|
||||||
|
ULONG_PTR pfnIsColorFont;
|
||||||
|
ULONG_PTR pfnCreateFontFace3;
|
||||||
|
ULONG_PTR pfnEquals;
|
||||||
|
ULONG_PTR pfnGetFontFaceReference;
|
||||||
|
ULONG_PTR pfnGetLocality;
|
||||||
|
}IDWriteFontLiteTbl, * pIDWriteFontLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteFontLiteTbl Vtbl;
|
||||||
|
ULONG RefCount;
|
||||||
|
LOGFONTW lf;
|
||||||
|
TEXTMETRICW tm;
|
||||||
|
}IDWriteFontLite, * pIDWriteFontLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDWriteFactoryLiteTbl Vtbl;
|
||||||
|
ULONG RefCount;
|
||||||
|
}IDWriteFactoryLite, *pIDWriteFactoryLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IUnknownLite IUnknown;
|
||||||
|
ULONG_PTR pfnSetPrivateData;
|
||||||
|
ULONG_PTR pfnSetPrivateDataInterface;
|
||||||
|
ULONG_PTR pfnGetPrivateData;
|
||||||
|
ULONG_PTR pfnGetParent;
|
||||||
|
}IDXGIObjectLite, *pIDXGIObjectLite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IDXGIObjectLite IDXGIObject;
|
||||||
|
ULONG_PTR pfnEnumAdapters;
|
||||||
|
ULONG_PTR pfnCreateSoftwareAdapater;
|
||||||
|
ULONG_PTR pfnCreateSwapChain;
|
||||||
|
ULONG_PTR pfnGetWindowAssociation;
|
||||||
|
ULONG_PTR pfnMakeWindowAssociation;
|
||||||
|
}IDXGIFactoryLite, *pIDXGIFactoryLite;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
IDXGIFactoryLite IDXGIFactory;
|
||||||
|
ULONG_PTR EnumAdapters1;
|
||||||
|
ULONG_PTR IsCurrent;
|
||||||
|
}IDXGIFactory1LiteTbl, *pIDXGIFactory1LiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDXGIFactory1LiteTbl Vtbl;
|
||||||
|
}IDXGIFactory1Lite, *pIDXGIFactory1Lite;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
IDXGIObjectLite IDXGIObject;
|
||||||
|
ULONG_PTR pfnEnumOutputs;
|
||||||
|
ULONG_PTR pfnGetDesc;
|
||||||
|
ULONG_PTR pfnCheckInterfaceSupport;
|
||||||
|
}IDXGIAdapterLiteTbl, *pIDXGIAdapterLiteTbl;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
pIDXGIAdapterLiteTbl Vtbl;
|
||||||
|
}IDXGIAdapterLite, *pIDXGIAdapterLite;
|
||||||
75
progwrp-CSOG/combase.c
Normal file
75
progwrp-CSOG/combase.c
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_WindowsCreateString(
|
||||||
|
PCNZWCH sourceString,
|
||||||
|
UINT32 length,
|
||||||
|
HSTRING* string
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PUNICODE_STRING pStr;
|
||||||
|
|
||||||
|
if (!string && length != 0)
|
||||||
|
return E_POINTER;
|
||||||
|
|
||||||
|
if (!string)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
pStr = (PUNICODE_STRING) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(UNICODE_STRING));
|
||||||
|
if (!pStr)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
RtlInitUnicodeString(pStr, sourceString);
|
||||||
|
|
||||||
|
*string = pStr;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_WindowsDeleteString(
|
||||||
|
HSTRING string
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!string)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, string);
|
||||||
|
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCWSTR WINAPI Implementation_WindowsGetStringRawBuffer(
|
||||||
|
HSTRING string,
|
||||||
|
UINT32* length
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_RoGetActivationFactory(
|
||||||
|
HSTRING activatableClassId,
|
||||||
|
REFIID iid,
|
||||||
|
void** factory
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_RoActivateInstance(
|
||||||
|
HSTRING activatableClassId,
|
||||||
|
PVOID** instance
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_WindowsCreateStringReference(
|
||||||
|
PCWSTR sourceString,
|
||||||
|
UINT32 length,
|
||||||
|
HSTRING_HEADER* hstringHeader,
|
||||||
|
HSTRING* string
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
280
progwrp-CSOG/condvar.c
Normal file
280
progwrp-CSOG/condvar.c
Normal file
@@ -0,0 +1,280 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
#define SEMAPHORE_BIT (1 << 31)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PULONG CondVarBitMasks;
|
||||||
|
ULONG NumberBitMasks;
|
||||||
|
}COND_VAR_BASE, * PCOND_VAR_BASE;
|
||||||
|
|
||||||
|
|
||||||
|
NTSYSAPI PVOID RtlAllocateHeap(
|
||||||
|
PVOID HeapHandle,
|
||||||
|
ULONG Flags,
|
||||||
|
SIZE_T Size
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSYSAPI VOID RtlFreeHeap(
|
||||||
|
PVOID HeapHandle,
|
||||||
|
ULONG Flags,
|
||||||
|
PVOID BaseAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
#define RtlMoveMemory RtlMoveMemory
|
||||||
|
|
||||||
|
VOID NTAPI RtlMoveMemory(
|
||||||
|
PVOID Destination,
|
||||||
|
PVOID Source,
|
||||||
|
SIZE_T Length
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
A condition variable is a synchronization object which allows many
|
||||||
|
threads to synchronize on one variable, in a pseudo-queue.
|
||||||
|
|
||||||
|
I determined that the condition variable could consist of an expandable array of bit masks.
|
||||||
|
One bit mask has two bits per thread; one to indicate that the section of the bit mask is in use
|
||||||
|
and another to indicate that the bit mask has been signalled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
HANDLE SingleWakeEvent;
|
||||||
|
HANDLE AllWakeEvent;
|
||||||
|
HANDLE AccessSemaphore;
|
||||||
|
ULONG WaiterCount;
|
||||||
|
}CONDITION_VARIABLE_INT, * PCONDITION_VARIABLE_INT;
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SleepConditionVariableSRW(
|
||||||
|
PCONDITION_VARIABLE ConditionVariable,
|
||||||
|
PSRWLOCK SRWLock,
|
||||||
|
DWORD dwMilliseconds,
|
||||||
|
ULONG Flags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
DWORD dwWaitStatus;
|
||||||
|
DWORD dwCondVarIdx;
|
||||||
|
PTEB_CUSTOM Teb;
|
||||||
|
PCONDITION_VARIABLE_INT pCondVar;
|
||||||
|
|
||||||
|
if (!(!SRWLock && Flags == 2)) {
|
||||||
|
|
||||||
|
if (!ConditionVariable || !SRWLock || Flags & ~(CONDITION_VARIABLE_LOCKMODE_SHARED))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Teb = (PTEB_CUSTOM)NtCurrentTeb();
|
||||||
|
|
||||||
|
if (!ConditionVariable->Ptr)
|
||||||
|
{
|
||||||
|
pCondVar = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CONDITION_VARIABLE_INT));
|
||||||
|
if (!pCondVar)
|
||||||
|
return FALSE;
|
||||||
|
#ifdef _M_X64
|
||||||
|
if (InterlockedCompareExchange64(ConditionVariable, pCondVar, 0))
|
||||||
|
#else
|
||||||
|
if (InterlockedCompareExchange(ConditionVariable, pCondVar, 0))
|
||||||
|
#endif
|
||||||
|
HeapFree(GetProcessHeap(), 0, pCondVar);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pCondVar->WaiterCount = 0;
|
||||||
|
pCondVar->AccessSemaphore = CreateSemaphoreA(NULL, 1, 1, NULL);
|
||||||
|
pCondVar->AllWakeEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||||
|
pCondVar->SingleWakeEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pCondVar = ConditionVariable->Ptr;
|
||||||
|
|
||||||
|
WaitForSingleObject(pCondVar->AccessSemaphore, INFINITE);
|
||||||
|
|
||||||
|
InterlockedIncrement(&pCondVar->WaiterCount);
|
||||||
|
|
||||||
|
ReleaseSemaphore(pCondVar->AccessSemaphore, 1, NULL);
|
||||||
|
|
||||||
|
if (Flags & CONDITION_VARIABLE_LOCKMODE_SHARED)
|
||||||
|
Implementation_ReleaseSRWLockShared(SRWLock);
|
||||||
|
else
|
||||||
|
Implementation_ReleaseSRWLockExclusive(SRWLock);
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE MultipleHandles[2] = { pCondVar->AllWakeEvent, pCondVar->SingleWakeEvent };
|
||||||
|
dwWaitStatus = WaitForMultipleObjects(2, MultipleHandles, FALSE, dwMilliseconds);
|
||||||
|
|
||||||
|
if (!InterlockedDecrement(&pCondVar->WaiterCount)) {
|
||||||
|
ResetEvent(pCondVar->AllWakeEvent);
|
||||||
|
ResetEvent(pCondVar->SingleWakeEvent);
|
||||||
|
ReleaseSemaphore(pCondVar->AccessSemaphore, 1, NULL);
|
||||||
|
}
|
||||||
|
else if (dwWaitStatus == WAIT_OBJECT_0 + 1)
|
||||||
|
{
|
||||||
|
ReleaseSemaphore(pCondVar->AccessSemaphore, 1, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Flags & CONDITION_VARIABLE_LOCKMODE_SHARED)
|
||||||
|
Implementation_AcquireSRWLockShared(SRWLock);
|
||||||
|
else
|
||||||
|
Implementation_AcquireSRWLockExclusive(SRWLock);
|
||||||
|
|
||||||
|
if (dwWaitStatus != WAIT_OBJECT_0 &&
|
||||||
|
dwWaitStatus != WAIT_OBJECT_0 + 1)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_TIMEOUT);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SleepConditionVariableCS(
|
||||||
|
PCONDITION_VARIABLE ConditionVariable,
|
||||||
|
PCRITICAL_SECTION CriticalSection,
|
||||||
|
DWORD dwMilliseconds
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
DWORD dwWaitStatus;
|
||||||
|
DWORD dwCondVarIdx;
|
||||||
|
PTEB_CUSTOM Teb;
|
||||||
|
PCONDITION_VARIABLE_INT pCondVar;
|
||||||
|
|
||||||
|
if (!ConditionVariable || !CriticalSection)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!ConditionVariable->Ptr)
|
||||||
|
{
|
||||||
|
pCondVar = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CONDITION_VARIABLE_INT));
|
||||||
|
|
||||||
|
#ifdef _M_X64
|
||||||
|
if (InterlockedCompareExchange64(ConditionVariable, pCondVar, 0))
|
||||||
|
#else
|
||||||
|
if (InterlockedCompareExchange(ConditionVariable, pCondVar, 0))
|
||||||
|
#endif
|
||||||
|
HeapFree(GetProcessHeap(), 0, pCondVar);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pCondVar->WaiterCount = 0;
|
||||||
|
pCondVar->AccessSemaphore = CreateSemaphoreA(NULL, 1, 1, NULL);
|
||||||
|
pCondVar->AllWakeEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||||
|
pCondVar->SingleWakeEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pCondVar = ConditionVariable->Ptr;
|
||||||
|
|
||||||
|
WaitForSingleObject(pCondVar->AccessSemaphore, INFINITE);
|
||||||
|
|
||||||
|
InterlockedIncrement(&pCondVar->WaiterCount);
|
||||||
|
|
||||||
|
ReleaseSemaphore(pCondVar->AccessSemaphore, 1, NULL);
|
||||||
|
|
||||||
|
LeaveCriticalSection(CriticalSection);
|
||||||
|
HANDLE MultipleHandles[2] = { pCondVar->AllWakeEvent, pCondVar->SingleWakeEvent };
|
||||||
|
dwWaitStatus = WaitForMultipleObjects(2, MultipleHandles, FALSE, dwMilliseconds);
|
||||||
|
|
||||||
|
if (!InterlockedDecrement(&pCondVar->WaiterCount)) {
|
||||||
|
ResetEvent(pCondVar->AllWakeEvent);
|
||||||
|
ResetEvent(pCondVar->SingleWakeEvent);
|
||||||
|
ReleaseSemaphore(pCondVar->AccessSemaphore, 1, NULL);
|
||||||
|
}
|
||||||
|
else if (dwWaitStatus == WAIT_OBJECT_0 + 1)
|
||||||
|
{
|
||||||
|
ReleaseSemaphore(pCondVar->AccessSemaphore, 1, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
EnterCriticalSection(CriticalSection);
|
||||||
|
SetLastError(dwWaitStatus);
|
||||||
|
if (dwWaitStatus != WAIT_OBJECT_0 &&
|
||||||
|
dwWaitStatus != WAIT_OBJECT_0 + 1)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_TIMEOUT);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_InitializeConditionVariable(
|
||||||
|
PCONDITION_VARIABLE ConditionVariable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ConditionVariable->Ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct _THREAD_BASIC_INFORMATION {
|
||||||
|
NTSTATUS ExitStatus;
|
||||||
|
PVOID TebBaseAddress;
|
||||||
|
CLIENT_ID ClientId;
|
||||||
|
KAFFINITY AffinityMask;
|
||||||
|
KPRIORITY Priority;
|
||||||
|
KPRIORITY BasePriority;
|
||||||
|
} THREAD_BASIC_INFORMATION, * PTHREAD_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
typedef struct _OBJECT_BASIC_INFORMATION {
|
||||||
|
ULONG Attributes;
|
||||||
|
ACCESS_MASK GrantedAccess;
|
||||||
|
ULONG HandleCount;
|
||||||
|
ULONG PointerCount;
|
||||||
|
ULONG PagedPoolCharge;
|
||||||
|
ULONG NonPagedPoolCharge;
|
||||||
|
ULONG Reserved[3];
|
||||||
|
ULONG NameInfoSize;
|
||||||
|
ULONG TypeInfoSize;
|
||||||
|
ULONG SecurityDescriptorSize;
|
||||||
|
LARGE_INTEGER CreationTime;
|
||||||
|
} OBJECT_BASIC_INFORMATION, * POBJECT_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
|
||||||
|
void WINAPI Implementation_WakeConditionVariable(
|
||||||
|
PCONDITION_VARIABLE ConditionVariable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (ConditionVariable)
|
||||||
|
{
|
||||||
|
PCONDITION_VARIABLE_INT pCondVar = ConditionVariable->Ptr;
|
||||||
|
if (ConditionVariable->Ptr) {
|
||||||
|
WaitForSingleObject(pCondVar->AccessSemaphore, INFINITE);
|
||||||
|
if (!pCondVar->WaiterCount) {
|
||||||
|
ReleaseSemaphore(pCondVar->AccessSemaphore, 1, NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetEvent(pCondVar->SingleWakeEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void WINAPI Implementation_WakeAllConditionVariable(
|
||||||
|
PCONDITION_VARIABLE ConditionVariable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (ConditionVariable)
|
||||||
|
{
|
||||||
|
PCONDITION_VARIABLE_INT pCondVar = ConditionVariable->Ptr;
|
||||||
|
if (ConditionVariable->Ptr) {
|
||||||
|
WaitForSingleObject(pCondVar->AccessSemaphore, INFINITE);
|
||||||
|
if (!pCondVar->WaiterCount) {
|
||||||
|
ReleaseSemaphore(pCondVar->AccessSemaphore, 1, NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetEvent(pCondVar->AllWakeEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
31
progwrp-CSOG/dbg.c
Normal file
31
progwrp-CSOG/dbg.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include <dbghelp.h>
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SymGetSearchPathW(
|
||||||
|
HANDLE hProcess,
|
||||||
|
PWSTR SearchPath,
|
||||||
|
DWORD SearchPathLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SymSetSearchPathW(
|
||||||
|
HANDLE hProcess,
|
||||||
|
PCWSTR SearchPath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SymFromAddr(
|
||||||
|
HANDLE hProcess,
|
||||||
|
DWORD64 Address,
|
||||||
|
PDWORD64 Displacement,
|
||||||
|
PSYMBOL_INFO Symbol
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
780
progwrp-CSOG/dllmain.c
Normal file
780
progwrp-CSOG/dllmain.c
Normal file
@@ -0,0 +1,780 @@
|
|||||||
|
// dllmain.cpp : Defines the entry point for the DLL application.
|
||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
volatile BOOLEAN g_InitCompleted = FALSE;
|
||||||
|
|
||||||
|
HANDLE hProcessClose;
|
||||||
|
|
||||||
|
#define LoadFuncPfn(x, y) pfnFunc = NULL; RtlInitAnsiString(&ansi_str, #y); LdrGetProcedureAddress(x, &ansi_str, 0, &pfnFunc); \
|
||||||
|
if (pfnFunc) { g_pfn_##y = pfnFunc;} else { g_pfn_##y = (pfnFunc_generic)Implementation_##y;}
|
||||||
|
|
||||||
|
#define LoadFuncPfnLite(x, y) RtlInitAnsiString(&ansi_str, #y); LdrGetProcedureAddress(x, &ansi_str, 0, &pfnFunc); g_pfn_##y = pfnFunc;
|
||||||
|
|
||||||
|
// This macro above covers the cases where functions are "completely" missing. But what about when functions are "partially" missing?
|
||||||
|
// (i.e. missing flags, etc.)
|
||||||
|
// In the context of this DLL, we may have three different states: fully-functional function, partially-implemented function and
|
||||||
|
// completely-missing function. We don't know at the init process if flags are missing or not. So if the function is partially implemented,
|
||||||
|
// we can try calling the original function, test for an invalid parameter error, and then try the "missing bit".
|
||||||
|
// The option to completely replace functions should also be available.
|
||||||
|
|
||||||
|
void InitPtrs_kernel32()
|
||||||
|
{
|
||||||
|
UNICODE_STRING kernel32s;
|
||||||
|
HMODULE kernel32 = NULL;
|
||||||
|
RtlInitUnicodeString(&kernel32s, L"kernel32.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &kernel32s, &kernel32))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, GetMaximumProcessorCount);
|
||||||
|
LoadFuncPfn(kernel32, GetMaximumProcessorGroupCount);
|
||||||
|
LoadFuncPfn(kernel32, GetLogicalProcessorInformationEx);
|
||||||
|
LoadFuncPfn(kernel32, GetThreadGroupAffinity);
|
||||||
|
LoadFuncPfn(kernel32, GetCurrentProcessorNumber);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, PowerCreateRequest);
|
||||||
|
LoadFuncPfn(kernel32, PowerSetRequest);
|
||||||
|
LoadFuncPfn(kernel32, PowerClearRequest);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, ResolveLocaleName);
|
||||||
|
LoadFuncPfn(kernel32, EnumSystemLocalesEx);
|
||||||
|
LoadFuncPfn(kernel32, GetCurrencyFormatEx);
|
||||||
|
LoadFuncPfn(kernel32, GetDateFormatEx);
|
||||||
|
LoadFuncPfn(kernel32, GetDynamicTimeZoneInformation);
|
||||||
|
LoadFuncPfn(kernel32, GetLocaleInfoEx);
|
||||||
|
LoadFuncPfn(kernel32, GetNumberFormatEx);
|
||||||
|
LoadFuncPfn(kernel32, GetTimeFormatEx);
|
||||||
|
LoadFuncPfn(kernel32, GetUserDefaultLocaleName);
|
||||||
|
LoadFuncPfn(kernel32, LCIDToLocaleName);
|
||||||
|
LoadFuncPfn(kernel32, LocaleNameToLCID);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, TryAcquireSRWLockExclusive); // These functions can be loaded independently of the "real"
|
||||||
|
LoadFuncPfn(kernel32, TryAcquireSRWLockShared); // SRW lock functions because they are compatible
|
||||||
|
LoadFuncPfn(kernel32, AcquireSRWLockExclusive);
|
||||||
|
if(g_pfn_AcquireSRWLockExclusive != (pfnFunc_generic)Implementation_AcquireSRWLockExclusive &&
|
||||||
|
g_pfn_TryAcquireSRWLockExclusive == (pfnFunc_generic)Implementation_TryAcquireSRWLockExclusive)
|
||||||
|
// If the real AcquireSRWLockExclusive is available but not TryAcquireSRWLockExclusive,
|
||||||
|
// load the "Vista" versions of the try acquire SRW lock functions
|
||||||
|
{
|
||||||
|
g_pfn_TryAcquireSRWLockExclusive = (pfnFunc_generic)Implementation_TryAcquireSRWLockExclusive_Vista;
|
||||||
|
g_pfn_TryAcquireSRWLockShared = (pfnFunc_generic)Implementation_TryAcquireSRWLockShared_Vista;
|
||||||
|
g_pfn_GetLogicalProcessorInformationEx = (pfnFunc_generic)Implementation_GetLogicalProcessorInformationEx;
|
||||||
|
}
|
||||||
|
LoadFuncPfn(kernel32, AcquireSRWLockShared);
|
||||||
|
LoadFuncPfn(kernel32, ReleaseSRWLockExclusive);
|
||||||
|
LoadFuncPfn(kernel32, ReleaseSRWLockShared);
|
||||||
|
LoadFuncPfn(kernel32, InitializeSRWLock);
|
||||||
|
LoadFuncPfn(kernel32, SleepConditionVariableSRW);
|
||||||
|
LoadFuncPfn(kernel32, SleepConditionVariableCS);
|
||||||
|
LoadFuncPfn(kernel32, WakeConditionVariable);
|
||||||
|
LoadFuncPfn(kernel32, WakeAllConditionVariable);
|
||||||
|
LoadFuncPfn(kernel32, InitializeConditionVariable);
|
||||||
|
LoadFuncPfn(kernel32, InitOnceExecuteOnce);
|
||||||
|
LoadFuncPfn(kernel32, InitOnceBeginInitialize);
|
||||||
|
LoadFuncPfn(kernel32, InitOnceComplete);
|
||||||
|
LoadFuncPfn(kernel32, InitOnceInitialize);
|
||||||
|
LoadFuncPfn(kernel32, CreateWaitableTimerExW);
|
||||||
|
LoadFuncPfn(kernel32, InitializeCriticalSectionEx);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, DecodePointer);
|
||||||
|
LoadFuncPfn(kernel32, EncodePointer);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, WerRegisterRuntimeExceptionModule);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, CreateRemoteThreadEx);
|
||||||
|
|
||||||
|
g_pfn_FindFirstFileExW = (pfnFunc_generic)Implementation_FindFirstFileExW;
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, CancelIoEx);
|
||||||
|
LoadFuncPfn(kernel32, GetFinalPathNameByHandleW);
|
||||||
|
LoadFuncPfn(kernel32, SetFileInformationByHandle);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, DeleteProcThreadAttributeList);
|
||||||
|
LoadFuncPfn(kernel32, UpdateProcThreadAttribute);
|
||||||
|
LoadFuncPfn(kernel32, InitializeProcThreadAttributeList);
|
||||||
|
LoadFuncPfn(kernel32, QueryFullProcessImageNameA);
|
||||||
|
LoadFuncPfn(kernel32, QueryFullProcessImageNameW);
|
||||||
|
LoadFuncPfn(kernel32, QueryProcessCycleTime);
|
||||||
|
LoadFuncPfn(kernel32, QueryThreadCycleTime);
|
||||||
|
LoadFuncPfn(kernel32, GetProductInfo);
|
||||||
|
LoadFuncPfn(kernel32, GetThreadId);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, GetNamedPipeClientProcessId);
|
||||||
|
LoadFuncPfn(kernel32, GetNamedPipeServerProcessId);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, GetThreadPreferredUILanguages);
|
||||||
|
LoadFuncPfn(kernel32, GetFileInformationByHandleEx);
|
||||||
|
LoadFuncPfn(kernel32, Wow64GetThreadContext);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, FlsAlloc);
|
||||||
|
LoadFuncPfn(kernel32, FlsFree);
|
||||||
|
//LoadFuncPfn(kernel32, FlsGetValue);
|
||||||
|
g_pfn_FlsGetValue = (pfnFunc_generic)Implementation_FlsGetValue;
|
||||||
|
LoadFuncPfn(kernel32, FlsSetValue);
|
||||||
|
LoadFuncPfn(kernel32, IsThreadAFiber);
|
||||||
|
LoadFuncPfn(kernel32, ConvertThreadToFiberEx);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, GetProcessId);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, AddVectoredExceptionHandler);
|
||||||
|
LoadFuncPfn(kernel32, RemoveVectoredExceptionHandler);
|
||||||
|
|
||||||
|
LoadFuncPfn(kernel32, AttachConsole);
|
||||||
|
LoadFuncPfn(kernel32, WTSGetActiveConsoleSessionId);
|
||||||
|
LoadFuncPfn(kernel32, CheckRemoteDebuggerPresent);
|
||||||
|
LoadFuncPfn(kernel32, CreateMemoryResourceNotification);
|
||||||
|
LoadFuncPfn(kernel32, GetGeoInfoW);
|
||||||
|
LoadFuncPfn(kernel32, GetLogicalProcessorInformation);
|
||||||
|
LoadFuncPfn(kernel32, GetModuleHandleExA);
|
||||||
|
LoadFuncPfn(kernel32, GetModuleHandleExW);
|
||||||
|
LoadFuncPfn(kernel32, GetNativeSystemInfo);
|
||||||
|
LoadFuncPfn(kernel32, GetProcessHandleCount);
|
||||||
|
LoadFuncPfn(kernel32, GetUserGeoID);
|
||||||
|
LoadFuncPfn(kernel32, GetVolumePathNamesForVolumeNameW);
|
||||||
|
LoadFuncPfn(kernel32, InitializeSListHead);
|
||||||
|
LoadFuncPfn(kernel32, InterlockedFlushSList);
|
||||||
|
LoadFuncPfn(kernel32, InterlockedPushEntrySList);
|
||||||
|
LoadFuncPfn(kernel32, IsProcessInJob);
|
||||||
|
LoadFuncPfn(kernel32, IsWow64Process);
|
||||||
|
LoadFuncPfn(kernel32, SetDllDirectoryW);
|
||||||
|
LoadFuncPfn(kernel32, TzSpecificLocalTimeToSystemTime);
|
||||||
|
LoadFuncPfn(kernel32, ConvertFiberToThread);
|
||||||
|
LoadFuncPfn(kernel32, PrefetchVirtualMemory);
|
||||||
|
LoadFuncPfn(kernel32, GetFirmwareType);
|
||||||
|
LoadFuncPfn(kernel32, GetPackagePathByFullName);
|
||||||
|
LoadFuncPfn(kernel32, GetPackagesByPackageFamily);
|
||||||
|
LoadFuncPfn(kernel32, LCMapStringEx);
|
||||||
|
LoadFuncPfn(kernel32, DuplicateHandle);
|
||||||
|
|
||||||
|
if(LOBYTE(GetVersion()) > 5 || LOBYTE(GetVersion() == 5) && LOBYTE(GetVersion() >> 8) >= 2)
|
||||||
|
{
|
||||||
|
pfnFunc = NULL; RtlInitAnsiString(&ansi_str, "CreateFiberEx"); LdrGetProcedureAddress(kernel32, &ansi_str, 0, &pfnFunc);
|
||||||
|
g_pfn_CreateFiberEx = pfnFunc;
|
||||||
|
pfnFunc = NULL; RtlInitAnsiString(&ansi_str, "SwitchToFiber"); LdrGetProcedureAddress(kernel32, &ansi_str, 0, &pfnFunc);
|
||||||
|
g_pfn_SwitchToFiber = pfnFunc;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_pfn_CreateFiberEx = (pfnFunc_generic)Implementation_CreateFiberEx;
|
||||||
|
// g_pfn_SwitchToFiber = (pfnFunc_generic)Implementation_SwitchToFiber;
|
||||||
|
pfnFunc = NULL; RtlInitAnsiString(&ansi_str, "SwitchToFiber"); LdrGetProcedureAddress(kernel32, &ansi_str, 0, &pfnFunc);
|
||||||
|
g_pfn_SwitchToFiber = pfnFunc;
|
||||||
|
}
|
||||||
|
LoadFuncPfn(kernel32, SetProcessDEPPolicy);
|
||||||
|
LoadFuncPfn(kernel32, InterlockedPopEntrySList);
|
||||||
|
LoadFuncPfn(kernel32, HeapSetInformation);
|
||||||
|
g_pfn_GetProcAddress = (pfnFunc_generic)Implementation_GetProcAddress;
|
||||||
|
g_pfn_LoadLibraryW = (pfnFunc_generic)Implementation_LoadLibraryW;
|
||||||
|
g_pfn_LoadLibraryA = (pfnFunc_generic)Implementation_LoadLibraryA;
|
||||||
|
g_pfn_LoadLibraryExW = (pfnFunc_generic)Implementation_LoadLibraryExW;
|
||||||
|
g_pfn_LoadLibraryExA = (pfnFunc_generic)Implementation_LoadLibraryExA;
|
||||||
|
if (LOBYTE(GetVersion()) < 6)
|
||||||
|
{
|
||||||
|
g_pfn_DuplicateHandle = (pfnFunc_generic)Implementation_DuplicateHandle;
|
||||||
|
}
|
||||||
|
LoadFuncPfn(kernel32, DiscardVirtualMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_shell32()
|
||||||
|
{
|
||||||
|
UNICODE_STRING shell32s;
|
||||||
|
HMODULE shell32 = NULL;
|
||||||
|
RtlInitUnicodeString(&shell32s, L"shell32.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &shell32s, &shell32))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(shell32, SHGetPropertyStoreForWindow);
|
||||||
|
LoadFuncPfn(shell32, SHGetKnownFolderPath);
|
||||||
|
LoadFuncPfn(shell32, SHQueryUserNotificationState);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_ntdll()
|
||||||
|
{
|
||||||
|
UNICODE_STRING ntdlls;
|
||||||
|
HMODULE ntdll = NULL;
|
||||||
|
RtlInitUnicodeString(&ntdlls, L"ntdll.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &ntdlls, &ntdll))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(ntdll, NtOpenKeyEx);
|
||||||
|
LoadFuncPfn(ntdll, RtlGetLastNtStatus);
|
||||||
|
RtlInitAnsiString(&ansi_str, "wcsstr");
|
||||||
|
pfnFunc = NULL;
|
||||||
|
LdrGetProcedureAddress(ntdll, &ansi_str, 0, &pfnFunc);
|
||||||
|
g_wcsstr = pfnFunc;
|
||||||
|
RtlInitAnsiString(&ansi_str, "strstr");
|
||||||
|
pfnFunc = NULL;
|
||||||
|
LdrGetProcedureAddress(ntdll, &ansi_str, 0, &pfnFunc);
|
||||||
|
g_strstr = pfnFunc;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_psapi()
|
||||||
|
{
|
||||||
|
UNICODE_STRING psapis;
|
||||||
|
HMODULE psapi = NULL;
|
||||||
|
RtlInitUnicodeString(&psapis, L"psapi.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &psapis, &psapi))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(psapi, GetModuleInformation);
|
||||||
|
LoadFuncPfn(psapi, GetProcessMemoryInfo);
|
||||||
|
LoadFuncPfn(psapi, QueryWorkingSetEx);
|
||||||
|
LoadFuncPfn(psapi, GetPerformanceInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_user32()
|
||||||
|
{
|
||||||
|
UNICODE_STRING user32s;
|
||||||
|
HMODULE user32 = NULL;
|
||||||
|
UNICODE_STRING shcores;
|
||||||
|
HMODULE shcore = NULL;
|
||||||
|
RtlInitUnicodeString(&user32s, L"user32.dll");
|
||||||
|
RtlInitUnicodeString(&shcores, L"SHCore.dll");
|
||||||
|
LdrLoadDll(NULL, 0, &shcores, &shcore);
|
||||||
|
if(!LdrLoadDll(NULL, 0, &user32s, &user32))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(user32, RegisterTouchWindow);
|
||||||
|
LoadFuncPfn(user32, GetDisplayConfigBufferSizes);
|
||||||
|
LoadFuncPfn(user32, CloseTouchInputHandle);
|
||||||
|
LoadFuncPfn(user32, GetGestureInfo);
|
||||||
|
LoadFuncPfn(user32, DisplayConfigGetDeviceInfo);
|
||||||
|
LoadFuncPfn(user32, DisplayConfigSetDeviceInfo);
|
||||||
|
LoadFuncPfn(user32, QueryDisplayConfig);
|
||||||
|
LoadFuncPfn(user32, SetProcessDPIAware);
|
||||||
|
LoadFuncPfn(user32, RegisterPowerSettingNotification);
|
||||||
|
LoadFuncPfn(user32, UnregisterPowerSettingNotification);
|
||||||
|
LoadFuncPfn(shcore, GetDpiForMonitor);
|
||||||
|
LoadFuncPfn(user32, GetLayeredWindowAttributes);
|
||||||
|
LoadFuncPfn(user32, GetRawInputDeviceInfoW);
|
||||||
|
LoadFuncPfn(user32, PrintWindow);
|
||||||
|
LoadFuncPfn(user32, DefRawInputProc);
|
||||||
|
LoadFuncPfn(user32, GetRawInputDeviceList);
|
||||||
|
LoadFuncPfn(user32, RegisterRawInputDevices);
|
||||||
|
LoadFuncPfn(user32, UnhookWindowsHookEx);
|
||||||
|
LoadFuncPfn(user32, RegisterPointerDeviceNotifications);
|
||||||
|
LoadFuncPfn(user32, GetPointerDevices);
|
||||||
|
LoadFuncPfn(user32, GetPointerDevice);
|
||||||
|
|
||||||
|
g_pfn_SystemParametersInfoW = (pfnFunc_generic)Implementation_SystemParametersInfoW;
|
||||||
|
//g_pfn_RegisterClassExW = (pfnFunc_generic)Implementation_RegisterClassExW;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_dbghelp()
|
||||||
|
{
|
||||||
|
UNICODE_STRING dbghelps;
|
||||||
|
HMODULE dbghelp = NULL;
|
||||||
|
RtlInitUnicodeString(&dbghelps, L"dbghelp.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &dbghelps, &dbghelp))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(dbghelp, SymGetSearchPathW);
|
||||||
|
LoadFuncPfn(dbghelp, SymSetSearchPathW);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_ws2_32()
|
||||||
|
{
|
||||||
|
UNICODE_STRING ws2_32s;
|
||||||
|
HMODULE ws2_32 = NULL;
|
||||||
|
RtlInitUnicodeString(&ws2_32s, L"ws2_32.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &ws2_32s, &ws2_32))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(ws2_32, inet_ntop);
|
||||||
|
LoadFuncPfn(ws2_32, freeaddrinfo);
|
||||||
|
LoadFuncPfn(ws2_32, getaddrinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_iphlpapi()
|
||||||
|
{
|
||||||
|
UNICODE_STRING iphlpapis;
|
||||||
|
HMODULE iphlpapi = NULL;
|
||||||
|
RtlInitUnicodeString(&iphlpapis, L"iphlpapi.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &iphlpapis, &iphlpapi))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(iphlpapi, FreeMibTable);
|
||||||
|
LoadFuncPfn(iphlpapi, GetIfTable2);
|
||||||
|
LoadFuncPfn(iphlpapi, CancelIPChangeNotify);
|
||||||
|
LoadFuncPfn(iphlpapi, GetAdaptersAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_advapi32()
|
||||||
|
{
|
||||||
|
UNICODE_STRING advapi32s;
|
||||||
|
HMODULE advapi32 = NULL;
|
||||||
|
RtlInitUnicodeString(&advapi32s, L"advapi32.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &advapi32s, &advapi32))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(advapi32, AddMandatoryAce);
|
||||||
|
LoadFuncPfn(advapi32, EventRegister);
|
||||||
|
LoadFuncPfn(advapi32, EventSetInformation);
|
||||||
|
LoadFuncPfn(advapi32, EventUnregister);
|
||||||
|
LoadFuncPfn(advapi32, EventWrite);
|
||||||
|
LoadFuncPfn(advapi32, EventWriteTransfer);
|
||||||
|
LoadFuncPfn(advapi32, RegDeleteKeyExW);
|
||||||
|
LoadFuncPfn(advapi32, RegGetValueW);
|
||||||
|
LoadFuncPfn(advapi32, SystemFunction036);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_wevtapi()
|
||||||
|
{
|
||||||
|
UNICODE_STRING wevtapis;
|
||||||
|
HMODULE wevtapi = NULL;
|
||||||
|
RtlInitUnicodeString(&wevtapis, L"wevtapi.dll");
|
||||||
|
// This is slightly different; the DLL was not always in Windows, so we won't verify that it exists.
|
||||||
|
LdrLoadDll(NULL, 0, &wevtapis, &wevtapi);
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(wevtapi, EvtQuery);
|
||||||
|
LoadFuncPfn(wevtapi, EvtCreateRenderContext);
|
||||||
|
LoadFuncPfn(wevtapi, EvtNext);
|
||||||
|
LoadFuncPfn(wevtapi, EvtRender);
|
||||||
|
LoadFuncPfn(wevtapi, EvtClose);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_dwmapi()
|
||||||
|
{
|
||||||
|
UNICODE_STRING dwmapis;
|
||||||
|
HMODULE dwmapi = NULL;
|
||||||
|
RtlInitUnicodeString(&dwmapis, L"dwmapi.dll");
|
||||||
|
LdrLoadDll(NULL, 0, &dwmapis, &dwmapi);
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(dwmapi, DwmSetWindowAttribute);
|
||||||
|
LoadFuncPfn(dwmapi, DwmGetWindowAttribute);
|
||||||
|
LoadFuncPfn(dwmapi, DwmGetCompositionTimingInfo);
|
||||||
|
LoadFuncPfn(dwmapi, DwmExtendFrameIntoClientArea);
|
||||||
|
LoadFuncPfn(dwmapi, DwmDefWindowProc);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_setupapi()
|
||||||
|
{
|
||||||
|
UNICODE_STRING setupapis;
|
||||||
|
HMODULE setupapi = NULL;
|
||||||
|
RtlInitUnicodeString(&setupapis, L"setupapi.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &setupapis, &setupapi))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(setupapi, SetupDiGetDevicePropertyW);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_dxgi()
|
||||||
|
{
|
||||||
|
UNICODE_STRING dxgis;
|
||||||
|
HMODULE dxgi = NULL;
|
||||||
|
RtlInitUnicodeString(&dxgis, L"dxgi.dll");
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LdrLoadDll(NULL, 0, &dxgis, &dxgi);
|
||||||
|
|
||||||
|
LoadFuncPfn(dxgi, CreateDXGIFactory);
|
||||||
|
LoadFuncPfn(dxgi, CreateDXGIFactory1);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_usp10()
|
||||||
|
{
|
||||||
|
UNICODE_STRING usp10s;
|
||||||
|
HMODULE usp10 = NULL;
|
||||||
|
RtlInitUnicodeString(&usp10s, L"usp10.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &usp10s, &usp10))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(usp10, ScriptItemize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_pdh()
|
||||||
|
{
|
||||||
|
UNICODE_STRING pdhs;
|
||||||
|
HMODULE pdh = NULL;
|
||||||
|
RtlInitUnicodeString(&pdhs, L"pdh.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &pdhs, &pdh))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(pdh, PdhAddEnglishCounterW);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_powrprof()
|
||||||
|
{
|
||||||
|
UNICODE_STRING powrprofs;
|
||||||
|
HMODULE powrprof = NULL;
|
||||||
|
RtlInitUnicodeString(&powrprofs, L"powrprof.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &powrprofs, &powrprof))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(powrprof, PowerDeterminePlatformRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_wtsapi32()
|
||||||
|
{
|
||||||
|
UNICODE_STRING wtsapi32s;
|
||||||
|
HMODULE wtsapi32 = NULL;
|
||||||
|
RtlInitUnicodeString(&wtsapi32s, L"wtsapi32.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &wtsapi32s, &wtsapi32))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(wtsapi32, WTSRegisterSessionNotification);
|
||||||
|
LoadFuncPfn(wtsapi32, WTSUnRegisterSessionNotification);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_crypt32()
|
||||||
|
{
|
||||||
|
UNICODE_STRING crypt32s;
|
||||||
|
HMODULE crypt32 = NULL;
|
||||||
|
RtlInitUnicodeString(&crypt32s, L"crypt32.dll");
|
||||||
|
if (!LdrLoadDll(NULL, 0, &crypt32s, &crypt32))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(crypt32, CryptProtectMemory);
|
||||||
|
LoadFuncPfn(crypt32, CryptUnprotectMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InitPtrs_bcryptprimitives()
|
||||||
|
{
|
||||||
|
UNICODE_STRING bcryptprimitivess;
|
||||||
|
HMODULE bcryptprimitives = NULL;
|
||||||
|
RtlInitUnicodeString(&bcryptprimitivess, L"bcryptprimitives.dll");
|
||||||
|
// if(!LdrLoadDll(NULL, 0, &bcryptprimitivess, &bcryptprimitives))
|
||||||
|
// {
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
g_pfn_ProcessPrng = g_pfn_SystemFunction036;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_uxtheme()
|
||||||
|
{
|
||||||
|
UNICODE_STRING uxthemes;
|
||||||
|
HMODULE uxtheme = NULL;
|
||||||
|
RtlInitUnicodeString(&uxthemes, L"uxtheme.dll");
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LdrLoadDll(NULL, 0, &uxthemes, &uxtheme);
|
||||||
|
|
||||||
|
LoadFuncPfn(uxtheme, CloseThemeData);
|
||||||
|
LoadFuncPfn(uxtheme, OpenThemeData);
|
||||||
|
LoadFuncPfn(uxtheme, GetThemePartSize);
|
||||||
|
LoadFuncPfn(uxtheme, DrawThemeBackground);
|
||||||
|
LoadFuncPfn(uxtheme, GetThemeBackgroundContentRect);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_ole32()
|
||||||
|
{
|
||||||
|
UNICODE_STRING ole32s;
|
||||||
|
HMODULE ole32 = NULL;
|
||||||
|
RtlInitUnicodeString(&ole32s, L"ole32.dll");
|
||||||
|
if(!LdrLoadDll(NULL, 0, &ole32s, &ole32))
|
||||||
|
{
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(ole32, CoRegisterInitializeSpy);
|
||||||
|
LoadFuncPfn(ole32, CoRevokeInitializeSpy);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_combase()
|
||||||
|
{
|
||||||
|
UNICODE_STRING combases;
|
||||||
|
HMODULE combase = NULL;
|
||||||
|
RtlInitUnicodeString(&combases, L"combase.dll");
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LdrLoadDll(NULL, 0, &combases, &combase);
|
||||||
|
|
||||||
|
LoadFuncPfn(combase, WindowsCreateString);
|
||||||
|
LoadFuncPfn(combase, WindowsGetStringRawBuffer);
|
||||||
|
LoadFuncPfn(combase, WindowsDeleteString);
|
||||||
|
LoadFuncPfn(combase, RoGetActivationFactory);
|
||||||
|
LoadFuncPfn(combase, RoActivateInstance);
|
||||||
|
LoadFuncPfn(combase, WindowsCreateStringReference);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitPtrs_dwrite()
|
||||||
|
{
|
||||||
|
UNICODE_STRING dwrites;
|
||||||
|
HMODULE dwrite = NULL;
|
||||||
|
RtlInitUnicodeString(&dwrites, L"dwrite.dll");
|
||||||
|
|
||||||
|
ANSI_STRING ansi_str;
|
||||||
|
PVOID pfnFunc = NULL;
|
||||||
|
|
||||||
|
LoadFuncPfn(dwrite, DWriteCreateFactory);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef enum _SEMAPHORE_INFORMATION_CLASS {
|
||||||
|
SemaphoreBasicInformation
|
||||||
|
} SEMAPHORE_INFORMATION_CLASS, *PSEMAPHORE_INFORMATION_CLASS;
|
||||||
|
|
||||||
|
typedef struct _SEMAPHORE_BASIC_INFORMATION {
|
||||||
|
ULONG CurrentCount;
|
||||||
|
ULONG MaximumCount;
|
||||||
|
} SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
NTSYSAPI
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
NtQuerySemaphore(
|
||||||
|
HANDLE SemaphoreHandle,
|
||||||
|
SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
|
||||||
|
PVOID SemaphoreInformation,
|
||||||
|
ULONG SemaphoreInformationLength,
|
||||||
|
PULONG ReturnLength);
|
||||||
|
|
||||||
|
typedef struct _OBJECT_BASIC_INFORMATION {
|
||||||
|
ULONG Attributes;
|
||||||
|
ACCESS_MASK GrantedAccess;
|
||||||
|
ULONG HandleCount;
|
||||||
|
ULONG PointerCount;
|
||||||
|
ULONG PagedPoolCharge;
|
||||||
|
ULONG NonPagedPoolCharge;
|
||||||
|
ULONG Reserved [3];
|
||||||
|
ULONG NameInfoSize;
|
||||||
|
ULONG TypeInfoSize;
|
||||||
|
ULONG SecurityDescriptorSize;
|
||||||
|
LARGE_INTEGER CreationTime;
|
||||||
|
} OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _THREAD_BASIC_INFORMATION {
|
||||||
|
NTSTATUS ExitStatus;
|
||||||
|
PVOID TebBaseAddress;
|
||||||
|
CLIENT_ID ClientId;
|
||||||
|
KAFFINITY AffinityMask;
|
||||||
|
KPRIORITY Priority;
|
||||||
|
KPRIORITY BasePriority;
|
||||||
|
} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
ULONG g_CoreTlsEntries = 0;
|
||||||
|
|
||||||
|
ULONG GetCoreTlsEntriesCount()
|
||||||
|
{
|
||||||
|
return g_CoreTlsEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||||
|
DWORD ul_reason_for_call,
|
||||||
|
LPVOID lpReserved
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WCHAR AppDataDir [MAX_PATH];
|
||||||
|
WCHAR AppDataDir_Exist [MAX_PATH];
|
||||||
|
DWORD tid;
|
||||||
|
PTEB_CUSTOM Teb;
|
||||||
|
PLDR_DATA_TABLE_ENTRY DataTableEntry, DataTableEntryInit;
|
||||||
|
LONG i;
|
||||||
|
PULONG_PTR ThreadLocalStoragePointer;
|
||||||
|
|
||||||
|
Teb = (PTEB_CUSTOM)NtCurrentTeb();
|
||||||
|
|
||||||
|
if(!InterlockedCompareExchange(&g_InitCompleted, 1, 0))
|
||||||
|
{
|
||||||
|
// g_hFile = CreateFileA(
|
||||||
|
// "tls_log.txt", // File path
|
||||||
|
// GENERIC_WRITE, // Desired access
|
||||||
|
// 0, // Share mode
|
||||||
|
// NULL, // Security attributes
|
||||||
|
// CREATE_ALWAYS, // Creation disposition
|
||||||
|
// FILE_ATTRIBUTE_NORMAL, // Flags and attributes
|
||||||
|
// NULL // Template file handle
|
||||||
|
// );
|
||||||
|
|
||||||
|
if (Teb->ThreadLocalStoragePointer)
|
||||||
|
{
|
||||||
|
ThreadLocalStoragePointer = (PULONG_PTR)Teb->ThreadLocalStoragePointer;
|
||||||
|
|
||||||
|
while (*ThreadLocalStoragePointer > 0 && !(*ThreadLocalStoragePointer % 4))
|
||||||
|
// Make sure only valid pointers are counted, and not padding that can also bookend the list of pointers
|
||||||
|
{
|
||||||
|
++g_CoreTlsEntries;
|
||||||
|
++ThreadLocalStoragePointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
InitializeCriticalSection(&SrwSharedCs);
|
||||||
|
InitializeCriticalSection(&SrwSharedCs2);
|
||||||
|
MutexInitOnce = CreateMutexW(NULL, FALSE, NULL);
|
||||||
|
g_SRWEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
|
g_hkProgwrp = 0;
|
||||||
|
|
||||||
|
InitPtrs_kernel32();
|
||||||
|
|
||||||
|
InitPtrs_shell32();
|
||||||
|
|
||||||
|
InitPtrs_ntdll();
|
||||||
|
|
||||||
|
InitPtrs_user32();
|
||||||
|
|
||||||
|
InitPtrs_psapi();
|
||||||
|
|
||||||
|
InitPtrs_dbghelp();
|
||||||
|
|
||||||
|
InitPtrs_ws2_32();
|
||||||
|
|
||||||
|
InitPtrs_iphlpapi();
|
||||||
|
|
||||||
|
InitPtrs_advapi32();
|
||||||
|
|
||||||
|
InitPtrs_wevtapi();
|
||||||
|
|
||||||
|
InitPtrs_dwmapi();
|
||||||
|
|
||||||
|
InitPtrs_setupapi();
|
||||||
|
|
||||||
|
InitPtrs_dxgi();
|
||||||
|
|
||||||
|
InitPtrs_usp10();
|
||||||
|
|
||||||
|
InitPtrs_pdh();
|
||||||
|
|
||||||
|
InitPtrs_wtsapi32();
|
||||||
|
|
||||||
|
InitPtrs_powrprof();
|
||||||
|
|
||||||
|
InitPtrs_bcryptprimitives();
|
||||||
|
|
||||||
|
InitPtrs_uxtheme();
|
||||||
|
|
||||||
|
InitPtrs_ole32();
|
||||||
|
|
||||||
|
InitPtrs_combase();
|
||||||
|
|
||||||
|
InitPtrs_dwrite();
|
||||||
|
|
||||||
|
InitPtrs_crypt32();
|
||||||
|
|
||||||
|
GetEnvironmentVariableW(L"LOCALAPPDATA", AppDataDir_Exist, MAX_PATH);
|
||||||
|
|
||||||
|
if(GetLastError() == ERROR_ENVVAR_NOT_FOUND)
|
||||||
|
{
|
||||||
|
SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, AppDataDir);
|
||||||
|
SetEnvironmentVariableW(L"LOCALAPPDATA", AppDataDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
MutexRegistry = CreateMutexA(NULL, TRUE, NULL);
|
||||||
|
|
||||||
|
TIMECAPS tc;
|
||||||
|
|
||||||
|
if (LOBYTE(GetVersion()) < 6) {
|
||||||
|
timeGetDevCaps(&tc, sizeof(TIMECAPS));
|
||||||
|
|
||||||
|
timeBeginPeriod(tc.wPeriodMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
switch (ul_reason_for_call)
|
||||||
|
{
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
case DLL_THREAD_ATTACH:
|
||||||
|
for (i = 0; i < TlsBasesCount; i++)
|
||||||
|
{
|
||||||
|
TLSInit_DllMain_ThreadAttach_Internal(TlsBases[i], NULL);
|
||||||
|
}
|
||||||
|
if (!Teb->SystemReserved1[0x34])
|
||||||
|
Teb->SystemReserved1[0x34] = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||||
|
case DLL_THREAD_DETACH:
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
50
progwrp-CSOG/dwmapi.c
Normal file
50
progwrp-CSOG/dwmapi.c
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_DwmSetWindowAttribute(
|
||||||
|
HWND hwnd,
|
||||||
|
DWORD dwAttribute,
|
||||||
|
LPCVOID pvAttribute,
|
||||||
|
DWORD cbAttribute
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_DwmGetWindowAttribute(
|
||||||
|
HWND hwnd,
|
||||||
|
DWORD dwAttribute,
|
||||||
|
LPCVOID pvAttribute,
|
||||||
|
DWORD cbAttribute
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_DwmDefWindowProc(
|
||||||
|
HWND hWnd,
|
||||||
|
UINT msg,
|
||||||
|
WPARAM wParam,
|
||||||
|
LPARAM lParam,
|
||||||
|
LRESULT *plResult
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_DwmExtendFrameIntoClientArea(
|
||||||
|
HWND hWnd,
|
||||||
|
const MARGINS *pMarInset
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_DwmGetCompositionTimingInfo(
|
||||||
|
HWND hwnd,
|
||||||
|
DWM_TIMING_INFO *pTimingInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
915
progwrp-CSOG/dwrite.c
Normal file
915
progwrp-CSOG/dwrite.c
Normal file
@@ -0,0 +1,915 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include "com_lite.h"
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
|
int _fltused = 0;
|
||||||
|
|
||||||
|
BOOL WINAPI IIDCMP(REFIID x, REFIID y)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if ((x->Data1 == y->Data1) && (x->Data2 == y->Data2) && (x->Data3 == y->Data3))
|
||||||
|
{
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
if (x->Data4[i] != y->Data4[i])
|
||||||
|
return FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI AddRef_DW(pIDWriteFontLite this)
|
||||||
|
{
|
||||||
|
return InterlockedIncrement(&this->RefCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Release_DW(pIDWriteFontLite this)
|
||||||
|
{
|
||||||
|
ULONG Result = InterlockedDecrement(&this->RefCount);
|
||||||
|
|
||||||
|
if (!Result)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, this->Vtbl);
|
||||||
|
HeapFree(GetProcessHeap(), 0, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI GetSimulations(pIDWriteFontLite this)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI DWrite_QueryInterface(
|
||||||
|
ULONG_PTR this,
|
||||||
|
REFIID riid,
|
||||||
|
void** ppvObject
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IID IDWriteFactory = { 0xb859ee5a, 0xd838,0x4b5b, 0xa2, 0xe8, 0x1a, 0xdc, 0x7d, 0x93, 0xdb, 0x48 };
|
||||||
|
IID IDWriteFactory1 = { 0x30572f99, 0xdac6, 0x41db, 0xa1, 0x6e, 0x48, 0x63, 0x07, 0xe6, 0x06a };
|
||||||
|
if (!ppvObject)
|
||||||
|
return E_POINTER;
|
||||||
|
if (IIDCMP(riid, &IDWriteFactory))
|
||||||
|
{
|
||||||
|
*ppvObject = this;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI TryGetFontTable(
|
||||||
|
pIDWriteFontFaceLite this,
|
||||||
|
UINT32 openTypeTableTag,
|
||||||
|
const void** tableData,
|
||||||
|
UINT32* tableSize,
|
||||||
|
void** tableContext,
|
||||||
|
BOOL* exists
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
HFONT hf, hfo;
|
||||||
|
if (!tableData || !tableSize || !tableContext || !exists)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
hf = CreateFontIndirectW(&this->lf);
|
||||||
|
hfo = SelectObject(hdc, hf);
|
||||||
|
if (GetFontData(hdc, openTypeTableTag, 0, *tableData, *tableSize) == GDI_ERROR)
|
||||||
|
*exists = FALSE;
|
||||||
|
else
|
||||||
|
*exists = TRUE;
|
||||||
|
SelectObject(hdc, hfo);
|
||||||
|
DeleteObject(hf);
|
||||||
|
DeleteDC(hdc);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI ReleaseFontTable(
|
||||||
|
pIDWriteFontFaceLite this,
|
||||||
|
void* tableContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT16 WINAPI GetGlyphCount(
|
||||||
|
pIDWriteFontFaceLite this
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
HFONT hf, hfo;
|
||||||
|
GLYPHSET gs;
|
||||||
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
hf = CreateFontIndirectW(&this->lf);
|
||||||
|
hfo = SelectObject(hdc, hf);
|
||||||
|
GetFontUnicodeRanges(hdc, &gs);
|
||||||
|
SelectObject(hdc, hfo);
|
||||||
|
DeleteObject(hf);
|
||||||
|
DeleteDC(hdc);
|
||||||
|
return gs.cGlyphsSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct _DWRITE_FONT_METRICS {
|
||||||
|
UINT16 designUnitsPerEm;
|
||||||
|
UINT16 ascent;
|
||||||
|
UINT16 descent;
|
||||||
|
INT16 lineGap;
|
||||||
|
UINT16 capHeight;
|
||||||
|
UINT16 xHeight;
|
||||||
|
INT16 underlinePosition;
|
||||||
|
UINT16 underlineThickness;
|
||||||
|
INT16 strikethroughPosition;
|
||||||
|
UINT16 strikethroughThickness;
|
||||||
|
} DWRITE_FONT_METRICS, *PDWRITE_FONT_METRICS;
|
||||||
|
|
||||||
|
typedef struct _DWRITE_GLYPH_METRICS {
|
||||||
|
INT32 leftSideBearing;
|
||||||
|
UINT32 advanceWidth;
|
||||||
|
INT32 rightSideBearing;
|
||||||
|
INT32 topSideBearing;
|
||||||
|
UINT32 advanceHeight;
|
||||||
|
INT32 bottomSideBearing;
|
||||||
|
INT32 verticalOriginY;
|
||||||
|
}DWRITE_GLYPH_METRICS, *PDWRITE_GLYPH_METRICS;
|
||||||
|
|
||||||
|
VOID WINAPI GetMetrics(
|
||||||
|
pIDWriteFontFaceLite this,
|
||||||
|
DWRITE_FONT_METRICS* fontFaceMetrics
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fontFaceMetrics->designUnitsPerEm = 1;
|
||||||
|
fontFaceMetrics->ascent = this->tm.tmAscent;
|
||||||
|
fontFaceMetrics->descent = this->tm.tmDescent;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI GetDesignGlyphMetrics(
|
||||||
|
pIDWriteFontFaceLite this,
|
||||||
|
UINT16 const* glyphIndices,
|
||||||
|
UINT32 glyphCount,
|
||||||
|
DWRITE_GLYPH_METRICS* glyphMetrics,
|
||||||
|
BOOL isSideways
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI GetGlyphIndices_DW(
|
||||||
|
pIDWriteFontFaceLite this,
|
||||||
|
UINT32 const* codePoints,
|
||||||
|
UINT32 codePointCount,
|
||||||
|
UINT16* glyphIndices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
HFONT hf, hfo;
|
||||||
|
GLYPHSET gs;
|
||||||
|
DWORD result;
|
||||||
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
hf = CreateFontIndirectW(&this->lf);
|
||||||
|
hfo = SelectObject(hdc, hf);
|
||||||
|
result = GetGlyphIndicesW(hdc, codePoints, codePointCount, glyphIndices, 0);
|
||||||
|
SelectObject(hdc, hfo);
|
||||||
|
DeleteObject(hf);
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
if (result == GDI_ERROR)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI CreateFontFace(
|
||||||
|
pIDWriteFontLite this,
|
||||||
|
pIDWriteFontFaceLite* fontFace
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pIDWriteFontFaceLite NewFontCol;
|
||||||
|
*fontFace = (pIDWriteFontFaceLite)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontFaceLite));
|
||||||
|
NewFontCol = *fontFace;
|
||||||
|
NewFontCol->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontFaceLiteTbl));
|
||||||
|
if (!NewFontCol->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
NewFontCol->lf = this->lf;
|
||||||
|
NewFontCol->tm = this->tm;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(NewFontCol);
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnRelease = Release_DW;
|
||||||
|
NewFontCol->Vtbl->pfnGetGlyphCount = GetGlyphCount;
|
||||||
|
NewFontCol->Vtbl->pfnTryGetFontTable = TryGetFontTable;
|
||||||
|
NewFontCol->Vtbl->pfnReleaseFontTable = ReleaseFontTable;
|
||||||
|
NewFontCol->Vtbl->pfnGetMetrics = GetMetrics;
|
||||||
|
NewFontCol->Vtbl->pfnGetGlyphIndices = GetGlyphIndices_DW;
|
||||||
|
NewFontCol->Vtbl->pfnGetDesignGlyphMetrics = GetDesignGlyphMetrics;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PCWSTR familyName;
|
||||||
|
UINT32* index;
|
||||||
|
} ENUMFAMILYNAME, * PENUMFAMILYNAME;
|
||||||
|
|
||||||
|
int CALLBACK EnumFamilyName(
|
||||||
|
const LOGFONTW* lpelfe,
|
||||||
|
const TEXTMETRICW* lpntme,
|
||||||
|
DWORD FontType,
|
||||||
|
PENUMFAMILYNAME lParam
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (lParam->familyName[i] != L'\0')
|
||||||
|
{
|
||||||
|
if (lpelfe->lfFaceName[i] == L'\0' ||
|
||||||
|
lpelfe->lfFaceName[i] != lParam->familyName[i])
|
||||||
|
return 1;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((lParam->familyName[i] == L'\0') && lpelfe->lfFaceName[i] != L'\0')
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
++*lParam->index;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UINT32 currentindex;
|
||||||
|
UINT32 finalindex;
|
||||||
|
PCWSTR finalstr;
|
||||||
|
} ENUMFAMILYIDX, * PENUMFAMILYIDX;
|
||||||
|
|
||||||
|
int CALLBACK EnumFamilyIdx(
|
||||||
|
const LOGFONTW* lpelfe,
|
||||||
|
const TEXTMETRICW* lpntme,
|
||||||
|
DWORD FontType,
|
||||||
|
PENUMFAMILYIDX lParam
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (lParam->currentindex == lParam->finalindex)
|
||||||
|
{
|
||||||
|
lParam->finalstr = (PCWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32 * sizeof(WCHAR));
|
||||||
|
StringCchCopyW(lParam->finalstr, 32, lpelfe->lfFaceName);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
++lParam->currentindex;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI FindFamilyName(
|
||||||
|
ULONG_PTR this,
|
||||||
|
PCWSTR familyName,
|
||||||
|
UINT32* index,
|
||||||
|
BOOL* exists
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
LOGFONTW lf;
|
||||||
|
ENUMFAMILYNAME pfname;
|
||||||
|
|
||||||
|
if (!familyName || !index || !exists)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
pfname.familyName = familyName;
|
||||||
|
pfname.index = index;
|
||||||
|
|
||||||
|
*pfname.index = 0;
|
||||||
|
|
||||||
|
lf.lfCharSet = DEFAULT_CHARSET;
|
||||||
|
lf.lfFaceName[0] = L'\0';
|
||||||
|
lf.lfPitchAndFamily = 0;
|
||||||
|
|
||||||
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
|
||||||
|
if (EnumFontFamiliesExW(hdc, &lf, EnumFamilyName, &pfname, 0) != 0)
|
||||||
|
{
|
||||||
|
*exists = FALSE;
|
||||||
|
*index = UINT_MAX;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*exists = TRUE;
|
||||||
|
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
LOGFONTW lf;
|
||||||
|
TEXTMETRICW tm;
|
||||||
|
DWORD FontType;
|
||||||
|
ULONG weight;
|
||||||
|
ULONG stretch;
|
||||||
|
ULONG style;
|
||||||
|
} FONTDATA, *PFONTDATA;
|
||||||
|
|
||||||
|
ULONG WINAPI GetStretch(ULONG_PTR this)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI GetStyle(pIDWriteFontLite this)
|
||||||
|
{
|
||||||
|
if (this->lf.lfItalic)
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI GetWeight(pIDWriteFontLite this)
|
||||||
|
{
|
||||||
|
return this->lf.lfWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
LOGFONTW lf;
|
||||||
|
TEXTMETRICW tm;
|
||||||
|
DWORD FontType;
|
||||||
|
UINT32 currentindex;
|
||||||
|
UINT32 finalindex;
|
||||||
|
} ENUMFONTLISTIDX, * PENUMFONTLISTIDX;
|
||||||
|
|
||||||
|
int CALLBACK EnumFontListIdx(
|
||||||
|
const LOGFONTW* lpelfe,
|
||||||
|
const TEXTMETRICW* lpntme,
|
||||||
|
DWORD FontType,
|
||||||
|
PENUMFONTLISTIDX lParam
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (lParam->currentindex == lParam->finalindex)
|
||||||
|
{
|
||||||
|
memcpy(&lParam->lf, lpelfe, sizeof(LOGFONTW));
|
||||||
|
memcpy(&lParam->tm, lpntme, sizeof(TEXTMETRICW));
|
||||||
|
lParam->FontType = FontType;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
++lParam->currentindex;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CALLBACK EnumFamilyFontMatch(
|
||||||
|
const LOGFONTW* lpelfe,
|
||||||
|
const TEXTMETRICW* lpntme,
|
||||||
|
DWORD FontType,
|
||||||
|
PFONTDATA lParam
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
Here is how we will determine the best-matching font, options ranking from best to worst:
|
||||||
|
-all three attributes matching
|
||||||
|
-two attributes matching
|
||||||
|
-one attribute matching
|
||||||
|
-first font enumerated
|
||||||
|
|
||||||
|
As a better font is found, the option will be revised.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if (lParam->lf.lfFaceName == L'\0')
|
||||||
|
{
|
||||||
|
memcpy(&lParam->lf, lpelfe, sizeof(LOGFONTW));
|
||||||
|
memcpy(&lParam->tm, lpntme, sizeof(TEXTMETRICW));
|
||||||
|
lParam->FontType = FontType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lParam->weight == lpelfe->lfWeight)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI GetFont(
|
||||||
|
pIDWriteFontListLite this,
|
||||||
|
UINT32 index,
|
||||||
|
pIDWriteFontLite* matchingFont
|
||||||
|
)
|
||||||
|
// At the end of the IDWriteFontFamily interface, I have added a pointer to a string containing the "font family" name.
|
||||||
|
// It will be used to iterate through all the fonts to find the one best suited to create a DWriteFont object.
|
||||||
|
{
|
||||||
|
pIDWriteFontLite NewFontCol;
|
||||||
|
HDC hdc;
|
||||||
|
LOGFONTW lf;
|
||||||
|
FONTDATA fd;
|
||||||
|
lf.lfCharSet = DEFAULT_CHARSET;
|
||||||
|
lf.lfFaceName[0] = L'\0';
|
||||||
|
lf.lfPitchAndFamily = 0;
|
||||||
|
|
||||||
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
|
||||||
|
EnumFontFamiliesExW(hdc, &lf, EnumFontListIdx, &fd, 0);
|
||||||
|
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
*matchingFont = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontLite));
|
||||||
|
NewFontCol = *matchingFont;
|
||||||
|
NewFontCol->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontLiteTbl));
|
||||||
|
if (!NewFontCol->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
NewFontCol->lf = fd.lf;
|
||||||
|
NewFontCol->tm = fd.tm;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(NewFontCol);
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnRelease = Release_DW;
|
||||||
|
NewFontCol->Vtbl->pfnGetSimulations = GetSimulations;
|
||||||
|
NewFontCol->Vtbl->pfnCreateFontFace = CreateFontFace;
|
||||||
|
NewFontCol->Vtbl->pfnGetStyle = GetStyle;
|
||||||
|
NewFontCol->Vtbl->pfnGetWeight = GetWeight;
|
||||||
|
NewFontCol->Vtbl->pfnGetStretch = GetStretch;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI GetFirstMatchingFont(
|
||||||
|
pIDWriteFontFamilyLite this,
|
||||||
|
ULONG weight,
|
||||||
|
ULONG stretch,
|
||||||
|
ULONG style,
|
||||||
|
pIDWriteFontLite* matchingFont
|
||||||
|
)
|
||||||
|
// At the end of the IDWriteFontFamily interface, I have added a pointer to a string containing the "font family" name.
|
||||||
|
// It will be used to iterate through all the fonts to find the one best suited to create a DWriteFont object.
|
||||||
|
{
|
||||||
|
pIDWriteFontLite NewFontCol;
|
||||||
|
HDC hdc;
|
||||||
|
LOGFONTW lf;
|
||||||
|
FONTDATA fd;
|
||||||
|
lf.lfCharSet = DEFAULT_CHARSET;
|
||||||
|
StringCchCopyW(&lf.lfFaceName, 32, this->FontFamilyStr);
|
||||||
|
lf.lfPitchAndFamily = 0;
|
||||||
|
|
||||||
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
|
||||||
|
EnumFontFamiliesExW(hdc, &lf, EnumFamilyFontMatch, &fd, 0);
|
||||||
|
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
*matchingFont = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontLite));
|
||||||
|
NewFontCol = *matchingFont;
|
||||||
|
NewFontCol->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontLiteTbl));
|
||||||
|
if (!NewFontCol->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
NewFontCol->lf = fd.lf;
|
||||||
|
NewFontCol->tm = fd.tm;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(NewFontCol);
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnRelease = Release_DW;
|
||||||
|
NewFontCol->Vtbl->pfnGetSimulations = GetSimulations;
|
||||||
|
NewFontCol->Vtbl->pfnCreateFontFace = CreateFontFace;
|
||||||
|
NewFontCol->Vtbl->pfnGetStyle = GetStyle;
|
||||||
|
NewFontCol->Vtbl->pfnGetWeight = GetWeight;
|
||||||
|
NewFontCol->Vtbl->pfnGetStretch = GetStretch;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 WINAPI GetFontCount(
|
||||||
|
pIDWriteFontListLite this
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI GetFontFamily(
|
||||||
|
ULONG_PTR this,
|
||||||
|
UINT32 index,
|
||||||
|
pIDWriteFontFamilyLite* fontFamily
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
LOGFONTW lf;
|
||||||
|
ENUMFAMILYIDX pfi;
|
||||||
|
int result;
|
||||||
|
pfi.currentindex = 0;
|
||||||
|
pfi.finalindex = index;
|
||||||
|
lf.lfCharSet = DEFAULT_CHARSET;
|
||||||
|
lf.lfFaceName[0] = L'\0';
|
||||||
|
lf.lfPitchAndFamily = 0;
|
||||||
|
|
||||||
|
hdc = CreateCompatibleDC(NULL);
|
||||||
|
|
||||||
|
result = EnumFontFamiliesExW(hdc, &lf, EnumFamilyIdx, &pfi, 0);
|
||||||
|
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
return E_FAIL;
|
||||||
|
pIDWriteFontFamilyLite NewFontFam;
|
||||||
|
*fontFamily = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontFamilyLite));
|
||||||
|
NewFontFam = *fontFamily;
|
||||||
|
NewFontFam->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontFamilyLiteTbl));
|
||||||
|
if (!NewFontFam->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
NewFontFam->Vtbl->IDWriteFontList.IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
NewFontFam->Vtbl->IDWriteFontList.IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(NewFontFam);
|
||||||
|
NewFontFam->Vtbl->IDWriteFontList.IUnknown.pfnRelease = Release_DW;
|
||||||
|
NewFontFam->Vtbl->pfnGetFirstMatchingFont = GetFirstMatchingFont;
|
||||||
|
NewFontFam->Vtbl->IDWriteFontList.pfnGetFont = GetFont;
|
||||||
|
NewFontFam->Vtbl->IDWriteFontList.pfnGetFontCount = GetFontCount;
|
||||||
|
NewFontFam->FontFamilyStr = pfi.finalstr;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 WINAPI GetFontFamilyCount(pIDWriteFontCollectionLite this)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI GetSystemFontCollection(
|
||||||
|
pIDWriteFactoryLite this,
|
||||||
|
pIDWriteFontCollectionLite* fontCollection,
|
||||||
|
BOOL checkForUpdates
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pIDWriteFontCollectionLite NewFontCol;
|
||||||
|
*fontCollection = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontCollectionLite));
|
||||||
|
NewFontCol = *fontCollection;
|
||||||
|
NewFontCol->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFontCollectionLiteTbl));
|
||||||
|
if (!NewFontCol->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(NewFontCol);
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnRelease = Release_DW;
|
||||||
|
NewFontCol->Vtbl->pfnGetFontFamily = GetFontFamily;
|
||||||
|
NewFontCol->Vtbl->pfnFindFamilyName = FindFamilyName;
|
||||||
|
NewFontCol->Vtbl->pfnGetFontFamilyCount = GetFontFamilyCount;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional adjustment to a glyph's position. A glyph offset changes the position of a glyph without affecting
|
||||||
|
/// the pen position. Offsets are in logical, pre-transform units.
|
||||||
|
/// </summary>
|
||||||
|
typedef struct DWRITE_GLYPH_OFFSET
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Offset in the advance direction of the run. A positive advance offset moves the glyph to the right
|
||||||
|
/// (in pre-transform coordinates) if the run is left-to-right or to the left if the run is right-to-left.
|
||||||
|
/// </summary>
|
||||||
|
FLOAT advanceOffset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Offset in the ascent direction, i.e., the direction ascenders point. A positive ascender offset moves
|
||||||
|
/// the glyph up (in pre-transform coordinates).
|
||||||
|
/// </summary>
|
||||||
|
FLOAT ascenderOffset;
|
||||||
|
}DWRITE_GLYPH_OFFSET;
|
||||||
|
|
||||||
|
typedef struct DWRITE_GLYPH_RUN
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The physical font face to draw with.
|
||||||
|
/// </summary>
|
||||||
|
pIDWriteFontFaceLite fontFace;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logical size of the font in DIPs, not points (equals 1/96 inch).
|
||||||
|
/// </summary>
|
||||||
|
FLOAT fontEmSize;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of glyphs.
|
||||||
|
/// </summary>
|
||||||
|
UINT32 glyphCount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The indices to render.
|
||||||
|
/// </summary>
|
||||||
|
_Field_size_(glyphCount) UINT16 const* glyphIndices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Glyph advance widths.
|
||||||
|
/// </summary>
|
||||||
|
_Field_size_opt_(glyphCount) FLOAT const* glyphAdvances;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Glyph offsets.
|
||||||
|
/// </summary>
|
||||||
|
_Field_size_opt_(glyphCount) DWRITE_GLYPH_OFFSET const* glyphOffsets;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true, specifies that glyphs are rotated 90 degrees to the left and
|
||||||
|
/// vertical metrics are used. Vertical writing is achieved by specifying
|
||||||
|
/// isSideways = true and rotating the entire run 90 degrees to the right
|
||||||
|
/// via a rotate transform.
|
||||||
|
/// </summary>
|
||||||
|
BOOL isSideways;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The implicit resolved bidi level of the run. Odd levels indicate
|
||||||
|
/// right-to-left languages like Hebrew and Arabic, while even levels
|
||||||
|
/// indicate left-to-right languages like English and Japanese (when
|
||||||
|
/// written horizontally). For right-to-left languages, the text origin
|
||||||
|
/// is on the right, and text should be drawn to the left.
|
||||||
|
/// </summary>
|
||||||
|
UINT32 bidiLevel;
|
||||||
|
}DWRITE_GLYPH_RUN;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The DWRITE_MATRIX structure specifies the graphics transform to be applied
|
||||||
|
/// to rendered glyphs.
|
||||||
|
/// </summary>
|
||||||
|
typedef struct DWRITE_MATRIX
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Horizontal scaling / cosine of rotation
|
||||||
|
/// </summary>
|
||||||
|
FLOAT m11;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vertical shear / sine of rotation
|
||||||
|
/// </summary>
|
||||||
|
FLOAT m12;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Horizontal shear / negative sine of rotation
|
||||||
|
/// </summary>
|
||||||
|
FLOAT m21;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vertical scaling / cosine of rotation
|
||||||
|
/// </summary>
|
||||||
|
FLOAT m22;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Horizontal shift (always orthogonal regardless of rotation)
|
||||||
|
/// </summary>
|
||||||
|
FLOAT dx;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vertical shift (always orthogonal regardless of rotation)
|
||||||
|
/// </summary>
|
||||||
|
FLOAT dy;
|
||||||
|
}DWRITE_MATRIX;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a method of rendering glyphs.
|
||||||
|
/// </summary>
|
||||||
|
typedef enum DWRITE_RENDERING_MODE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies that the rendering mode is determined automatically based on the font and size.
|
||||||
|
/// </summary>
|
||||||
|
DWRITE_RENDERING_MODE_DEFAULT,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies that no antialiasing is performed. Each pixel is either set to the foreground
|
||||||
|
/// color of the text or retains the color of the background.
|
||||||
|
/// </summary>
|
||||||
|
DWRITE_RENDERING_MODE_ALIASED,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies that antialiasing is performed in the horizontal direction and the appearance
|
||||||
|
/// of glyphs is layout-compatible with GDI using CLEARTYPE_QUALITY. Use DWRITE_MEASURING_MODE_GDI_CLASSIC
|
||||||
|
/// to get glyph advances. The antialiasing may be either ClearType or grayscale depending on
|
||||||
|
/// the text antialiasing mode.
|
||||||
|
/// </summary>
|
||||||
|
DWRITE_RENDERING_MODE_GDI_CLASSIC,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies that antialiasing is performed in the horizontal direction and the appearance
|
||||||
|
/// of glyphs is layout-compatible with GDI using CLEARTYPE_NATURAL_QUALITY. Glyph advances
|
||||||
|
/// are close to the font design advances, but are still rounded to whole pixels. Use
|
||||||
|
/// DWRITE_MEASURING_MODE_GDI_NATURAL to get glyph advances. The antialiasing may be either
|
||||||
|
/// ClearType or grayscale depending on the text antialiasing mode.
|
||||||
|
/// </summary>
|
||||||
|
DWRITE_RENDERING_MODE_GDI_NATURAL,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies that antialiasing is performed in the horizontal direction. This rendering
|
||||||
|
/// mode allows glyphs to be positioned with subpixel precision and is therefore suitable
|
||||||
|
/// for natural (i.e., resolution-independent) layout. The antialiasing may be either
|
||||||
|
/// ClearType or grayscale depending on the text antialiasing mode.
|
||||||
|
/// </summary>
|
||||||
|
DWRITE_RENDERING_MODE_NATURAL,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Similar to natural mode except that antialiasing is performed in both the horizontal
|
||||||
|
/// and vertical directions. This is typically used at larger sizes to make curves and
|
||||||
|
/// diagonal lines look smoother. The antialiasing may be either ClearType or grayscale
|
||||||
|
/// depending on the text antialiasing mode.
|
||||||
|
/// </summary>
|
||||||
|
DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies that rendering should bypass the rasterizer and use the outlines directly.
|
||||||
|
/// This is typically used at very large sizes.
|
||||||
|
/// </summary>
|
||||||
|
DWRITE_RENDERING_MODE_OUTLINE,
|
||||||
|
|
||||||
|
// The following names are obsolete, but are kept as aliases to avoid breaking existing code.
|
||||||
|
// Each of these rendering modes may result in either ClearType or grayscale antialiasing
|
||||||
|
// depending on the DWRITE_TEXT_ANTIALIASING_MODE.
|
||||||
|
DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC = DWRITE_RENDERING_MODE_GDI_CLASSIC,
|
||||||
|
DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL = DWRITE_RENDERING_MODE_GDI_NATURAL,
|
||||||
|
DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL = DWRITE_RENDERING_MODE_NATURAL,
|
||||||
|
DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC = DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC
|
||||||
|
}DWRITE_RENDERING_MODE, *PDWRITE_RENDERING_MODE;
|
||||||
|
|
||||||
|
#define DWRITE_MEASURING_MODE ULONG
|
||||||
|
#define DWRITE_TEXTURE_TYPE ULONG
|
||||||
|
#define DWRITE_FONT_WEIGHT ULONG
|
||||||
|
#define DWRITE_FONT_STYLE ULONG
|
||||||
|
#define DWRITE_FONT_STRETCH ULONG
|
||||||
|
|
||||||
|
HRESULT WINAPI GetAlphaBlendParams(
|
||||||
|
pIDWriteGlyphRunAnalysisLite this,
|
||||||
|
PVOID renderingParams,
|
||||||
|
FLOAT* blendGamma,
|
||||||
|
FLOAT* blendEnhancedContrast,
|
||||||
|
FLOAT* blendClearTypeLevel
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*blendGamma = 3.0f;
|
||||||
|
*blendEnhancedContrast = 2.0f;
|
||||||
|
//*blendClearTypeLevel = 0.0;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI GetAlphaTextureBounds(
|
||||||
|
pIDWriteGlyphRunAnalysisLite this,
|
||||||
|
DWRITE_TEXTURE_TYPE textureType,
|
||||||
|
RECT* textureBounds
|
||||||
|
)
|
||||||
|
{
|
||||||
|
textureBounds->bottom = 2.0;
|
||||||
|
textureBounds->right = 2.0;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Draw(
|
||||||
|
pIDWriteTextLayoutLite this,
|
||||||
|
void* clientDrawingContext,
|
||||||
|
void* renderer,
|
||||||
|
FLOAT originX,
|
||||||
|
FLOAT originY
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI SetFontCollection(
|
||||||
|
pIDWriteTextLayoutLite this,
|
||||||
|
pIDWriteFontCollectionLite fontCollection,
|
||||||
|
ULONG textRange
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI CreateTextFormat(
|
||||||
|
pIDWriteFactoryLite this,
|
||||||
|
WCHAR const* fontFamilyName,
|
||||||
|
IDWriteFontCollectionLite* fontCollection,
|
||||||
|
DWRITE_FONT_WEIGHT fontWeight,
|
||||||
|
DWRITE_FONT_STYLE fontStyle,
|
||||||
|
DWRITE_FONT_STRETCH fontStretch,
|
||||||
|
FLOAT fontSize,
|
||||||
|
WCHAR const* localeName,
|
||||||
|
pIDWriteTextFormatLite* textFormat
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pIDWriteTextFormatLite NewFontCol;
|
||||||
|
*textFormat = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteTextFormatLite));
|
||||||
|
NewFontCol = *textFormat;
|
||||||
|
NewFontCol->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteTextFormatLiteTbl));
|
||||||
|
if (!NewFontCol->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(NewFontCol);
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnRelease = Release_DW;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI CreateTextLayout(
|
||||||
|
pIDWriteFactoryLite this,
|
||||||
|
WCHAR const* string,
|
||||||
|
UINT32 stringLength,
|
||||||
|
IDWriteTextFormatLite* textFormat,
|
||||||
|
FLOAT maxWidth,
|
||||||
|
FLOAT maxHeight,
|
||||||
|
pIDWriteTextLayoutLite* textLayout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pIDWriteTextLayoutLite NewFontCol;
|
||||||
|
*textLayout = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteTextLayoutLite));
|
||||||
|
NewFontCol = *textLayout;
|
||||||
|
NewFontCol->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteTextLayoutLiteTbl));
|
||||||
|
if (!NewFontCol->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
NewFontCol->Vtbl->IDWriteTextFormat.IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
NewFontCol->Vtbl->IDWriteTextFormat.IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(NewFontCol);
|
||||||
|
NewFontCol->Vtbl->IDWriteTextFormat.IUnknown.pfnRelease = Release_DW;
|
||||||
|
NewFontCol->Vtbl->pfnDraw = Draw;
|
||||||
|
NewFontCol->Vtbl->pfnSetFontCollection = SetFontCollection;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI CreateGlyphRunAnalysis(
|
||||||
|
pIDWriteFactoryLite this,
|
||||||
|
DWRITE_GLYPH_RUN const* glyphRun,
|
||||||
|
FLOAT pixelsPerDip,
|
||||||
|
DWRITE_MATRIX const* transform,
|
||||||
|
DWRITE_RENDERING_MODE renderingMode,
|
||||||
|
DWRITE_MEASURING_MODE measuringMode,
|
||||||
|
FLOAT baselineOriginX,
|
||||||
|
FLOAT baselineOriginY,
|
||||||
|
pIDWriteGlyphRunAnalysisLite* glyphRunAnalysis
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pIDWriteGlyphRunAnalysisLite NewFontCol;
|
||||||
|
*glyphRunAnalysis = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteGlyphRunAnalysisLite));
|
||||||
|
NewFontCol = *glyphRunAnalysis;
|
||||||
|
NewFontCol->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteGlyphRunAnalysisLiteTbl));
|
||||||
|
if (!NewFontCol->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(NewFontCol);
|
||||||
|
NewFontCol->Vtbl->IUnknown.pfnRelease = Release_DW;
|
||||||
|
NewFontCol->Vtbl->pfnGetAlphaBlendParams = GetAlphaBlendParams;
|
||||||
|
NewFontCol->Vtbl->pfnGetAlphaTextureBounds = GetAlphaTextureBounds;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT RegisterFontCollectionLoader(
|
||||||
|
pIDWriteFactoryLite this,
|
||||||
|
PVOID fontCollectionLoader
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT RegisterFontFileLoader(
|
||||||
|
pIDWriteFactoryLite this,
|
||||||
|
PVOID fontFileLoader
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_DWriteCreateFactory(
|
||||||
|
ULONG factoryType,
|
||||||
|
REFIID iid,
|
||||||
|
IUnknown** factory
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pIDWriteFactoryLite IDWriteFactoryLite;
|
||||||
|
IID IDWriteFactory = { 0xb859ee5a, 0xd838,0x4b5b, 0xa2, 0xe8, 0x1a, 0xdc, 0x7d, 0x93, 0xdb, 0x48 };
|
||||||
|
IID IDWriteFactory1 = { 0x30572f99, 0xdac6, 0x41db, 0xa1, 0x6e, 0x48, 0x63, 0x07, 0xe6, 0x06a };
|
||||||
|
if (IIDCMP(iid, &IDWriteFactory))
|
||||||
|
{
|
||||||
|
*factory = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFactoryLite));
|
||||||
|
IDWriteFactoryLite = *factory;
|
||||||
|
IDWriteFactoryLite->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDWriteFactoryLiteTbl));
|
||||||
|
if (!IDWriteFactoryLite->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
IDWriteFactoryLite->Vtbl->IUnknown.pfnQueryInterface = DWrite_QueryInterface;
|
||||||
|
IDWriteFactoryLite->Vtbl->IUnknown.pfnAddRef = AddRef_DW;
|
||||||
|
AddRef_DW(IDWriteFactoryLite);
|
||||||
|
IDWriteFactoryLite->Vtbl->IUnknown.pfnRelease = Release_DW;
|
||||||
|
IDWriteFactoryLite->Vtbl->pfnGetSystemFontCollection = GetSystemFontCollection;
|
||||||
|
IDWriteFactoryLite->Vtbl->pfnCreateGlyphRunAnalysis = CreateGlyphRunAnalysis;
|
||||||
|
IDWriteFactoryLite->Vtbl->pfnCreateTextLayout = CreateTextLayout;
|
||||||
|
IDWriteFactoryLite->Vtbl->pfnCreateTextFormat = CreateTextFormat;
|
||||||
|
IDWriteFactoryLite->Vtbl->pfnRegisterFontCollectionLoader = RegisterFontCollectionLoader;
|
||||||
|
IDWriteFactoryLite->Vtbl->pfnRegisterFontFileLoader = RegisterFontFileLoader;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
if (IIDCMP(iid, &IDWriteFactory1))
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
147
progwrp-CSOG/dxgi.c
Normal file
147
progwrp-CSOG/dxgi.c
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include "com_lite.h"
|
||||||
|
#include "strsafe.h"
|
||||||
|
#include <d3d9.h>
|
||||||
|
#include <dxgi.h>
|
||||||
|
|
||||||
|
LPDIRECT3D9 g_pD3D = NULL;
|
||||||
|
|
||||||
|
typedef IDirect3D9*( WINAPI* d3d9create) (UINT);
|
||||||
|
|
||||||
|
HRESULT WINAPI CheckInterfaceSupport(
|
||||||
|
void* this,
|
||||||
|
REFGUID InterfaceName,
|
||||||
|
LARGE_INTEGER *pUMDVersion
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(pUMDVersion)
|
||||||
|
pUMDVersion->QuadPart = 0;
|
||||||
|
return DXGI_ERROR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI GetDesc(
|
||||||
|
void* this,
|
||||||
|
DXGI_ADAPTER_DESC *pDesc
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!pDesc)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
StringCchCopyW(pDesc->Description, 128, L"Software Adapter");
|
||||||
|
|
||||||
|
pDesc->VendorId = 0;
|
||||||
|
pDesc->DeviceId = 0;
|
||||||
|
pDesc->SubSysId = 0;
|
||||||
|
pDesc->Revision = 0;
|
||||||
|
pDesc->DedicatedVideoMemory = 4;
|
||||||
|
pDesc->DedicatedSystemMemory = 8;
|
||||||
|
pDesc->SharedSystemMemory = 1;
|
||||||
|
pDesc->AdapterLuid.LowPart = 3453;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI EnumAdapters1(
|
||||||
|
void* this,
|
||||||
|
UINT Adapter,
|
||||||
|
void **ppAdapter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Release(void* this)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI EnumAdapters(
|
||||||
|
void* this,
|
||||||
|
UINT Adapter,
|
||||||
|
void **ppAdapter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT AdapterCount;
|
||||||
|
pIDXGIAdapterLite pDXGIAdapter;
|
||||||
|
if(!ppAdapter)
|
||||||
|
return DXGI_ERROR_INVALID_CALL;
|
||||||
|
if(g_pD3D)
|
||||||
|
AdapterCount = IDirect3D9_GetAdapterCount(g_pD3D);
|
||||||
|
else
|
||||||
|
return E_FAIL;
|
||||||
|
if(AdapterCount - 1 < Adapter)
|
||||||
|
return DXGI_ERROR_NOT_FOUND;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*ppAdapter = pDXGIAdapter;
|
||||||
|
pDXGIAdapter->Vtbl = NULL;
|
||||||
|
pDXGIAdapter->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDXGIAdapterLiteTbl));
|
||||||
|
if(!pDXGIAdapter->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
pDXGIAdapter->Vtbl->IDXGIObject.IUnknown.pfnQueryInterface = pDXGIAdapter->Vtbl;
|
||||||
|
pDXGIAdapter->Vtbl->IDXGIObject.IUnknown.pfnRelease = Release;
|
||||||
|
pDXGIAdapter->Vtbl->pfnGetDesc = GetDesc;
|
||||||
|
pDXGIAdapter->Vtbl->pfnCheckInterfaceSupport = CheckInterfaceSupport;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_CreateDXGIFactory(
|
||||||
|
REFIID riid,
|
||||||
|
void **ppFactory
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL RefIdCmp(IID riid0, IID riid1)
|
||||||
|
{
|
||||||
|
if(riid0.Data1 == riid1.Data1 &&
|
||||||
|
riid0.Data2 == riid1.Data2 &&
|
||||||
|
riid0.Data3 == riid1.Data3 &&
|
||||||
|
riid0.Data4 == riid1.Data4)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_CreateDXGIFactory1(
|
||||||
|
REFIID riid,
|
||||||
|
void **ppFactory
|
||||||
|
)
|
||||||
|
{
|
||||||
|
d3d9create pfnDirect3DCreate9;
|
||||||
|
pIDXGIFactory1Lite pDXGIFactory1;
|
||||||
|
IID iid_DXGIFactory1 = {0x770AAE78, 0xF26F, 0x4DBA, 0xA8, 0x29, 0x25, 0x3C, 0x83, 0xD1, 0xB3, 0x87};
|
||||||
|
|
||||||
|
if(RefIdCmp(*riid, iid_DXGIFactory1))
|
||||||
|
{
|
||||||
|
pfnDirect3DCreate9 = (d3d9create)Implementation_GetProcAddress(LoadLibraryA("d3d9.dll"), "Direct3DCreate9");
|
||||||
|
|
||||||
|
if(!pfnDirect3DCreate9)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
g_pD3D = pfnDirect3DCreate9(D3D_SDK_VERSION);
|
||||||
|
pDXGIFactory1->Vtbl = NULL;
|
||||||
|
*ppFactory = pDXGIFactory1;
|
||||||
|
pDXGIFactory1->Vtbl = (void*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDXGIFactory1LiteTbl));
|
||||||
|
if(!pDXGIFactory1->Vtbl)
|
||||||
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDXGIFactory1->Vtbl->IDXGIFactory.IDXGIObject.IUnknown.pfnQueryInterface = pDXGIFactory1->Vtbl;
|
||||||
|
pDXGIFactory1->Vtbl->IDXGIFactory.pfnEnumAdapters = EnumAdapters;
|
||||||
|
pDXGIFactory1->Vtbl->EnumAdapters1 = EnumAdapters1;
|
||||||
|
pDXGIFactory1->Vtbl->IDXGIFactory.IDXGIObject.IUnknown.pfnRelease = Release;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DXGI_ERROR_NOT_FOUND;
|
||||||
|
}
|
||||||
54
progwrp-CSOG/evt_log.c
Normal file
54
progwrp-CSOG/evt_log.c
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
EVT_HANDLE WINAPI Implementation_EvtQuery(
|
||||||
|
EVT_HANDLE Session,
|
||||||
|
LPCWSTR Path,
|
||||||
|
LPCWSTR Query,
|
||||||
|
DWORD Flags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_EvtRender(
|
||||||
|
EVT_HANDLE Context,
|
||||||
|
EVT_HANDLE Fragment,
|
||||||
|
DWORD Flags,
|
||||||
|
DWORD BufferSize,
|
||||||
|
PVOID Buffer,
|
||||||
|
PDWORD BufferUsed,
|
||||||
|
PDWORD PropertyCount
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
EVT_HANDLE WINAPI Implementation_EvtCreateRenderContext(
|
||||||
|
DWORD ValuePathsCount,
|
||||||
|
LPCWSTR *ValuePaths,
|
||||||
|
DWORD Flags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_EvtNext(
|
||||||
|
EVT_HANDLE ResultSet,
|
||||||
|
DWORD EventsSize,
|
||||||
|
PEVT_HANDLE Events,
|
||||||
|
DWORD Timeout,
|
||||||
|
DWORD Flags,
|
||||||
|
PDWORD Returned
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_EvtClose(
|
||||||
|
EVT_HANDLE Object
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
397
progwrp-CSOG/export.h
Normal file
397
progwrp-CSOG/export.h
Normal file
@@ -0,0 +1,397 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
typedef int (*pfnFunc_generic)();
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitializeSRWLock;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_TryAcquireSRWLockExclusive;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_TryAcquireSRWLockShared;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_AcquireSRWLockExclusive;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_AcquireSRWLockShared;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_ReleaseSRWLockExclusive;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_ReleaseSRWLockShared;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DecodePointer;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EncodePointer;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetMaximumProcessorCount;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetMaximumProcessorGroupCount;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetLogicalProcessorInformationEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetThreadGroupAffinity;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_PowerCreateRequest;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_PowerSetRequest;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_PowerClearRequest;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_ResolveLocaleName;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WerRegisterRuntimeExceptionModule;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_NtOpenKeyEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SHGetPropertyStoreForWindow;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RegisterTouchWindow;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetTouchInputInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_QueryDisplayConfig;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DisplayConfigGetDeviceInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DisplayConfigSetDeviceInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetDisplayConfigBufferSizes;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CloseTouchInputHandle;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CloseGestureInfoHandle;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetGestureInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SetGestureConfig;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_UnregisterTouchWindow;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_IsTouchWindow;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CreateRemoteThreadEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetModuleInformation;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetProcessMemoryInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_FindFirstFileExW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SleepConditionVariableSRW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EnumSystemLocalesEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetCurrencyFormatEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetDateFormatEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetDynamicTimeZoneInformation;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetTimeFormatEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetLocaleInfoEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetNumberFormatEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetUserDefaultLocaleName;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_LCIDToLocaleName;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_LocaleNameToLCID;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SleepConditionVariableCS;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WakeConditionVariable;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WakeAllConditionVariable;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitializeConditionVariable;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitOnceBeginInitialize;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitOnceExecuteOnce;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitOnceComplete;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitOnceInitialize;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CreateWaitableTimerExW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitializeCriticalSectionEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CancelIoEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetFinalPathNameByHandleW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SetFileInformationByHandle;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitializeProcThreadAttributeList;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_UpdateProcThreadAttribute;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DeleteProcThreadAttributeList;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_QueryFullProcessImageNameA;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_QueryFullProcessImageNameW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_QueryThreadCycleTime;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_QueryProcessCycleTime;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetProductInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_QueryProcessCycleTime;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetProductInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetNamedPipeServerProcessId;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetNamedPipeClientProcessId;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SymGetSearchPathW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SymSetSearchPathW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_inet_ntop;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetIfTable2;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_FreeMibTable;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetThreadPreferredUILanguages;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetFileInformationByHandleEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_Wow64GetThreadContext;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_AddMandatoryAce;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EventRegister;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EventSetInformation;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EventWrite;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EventWriteTransfer;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EventUnregister;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RegisterPowerSettingNotification;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_UnregisterPowerSettingNotification;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SetProcessDPIAware;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EvtRender;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EvtNext;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EvtQuery;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EvtCreateRenderContext;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_EvtClose;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SHGetKnownFolderPath;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DwmSetWindowAttribute;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DwmGetWindowAttribute;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DwmDefWindowProc;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DwmExtendFrameIntoClientArea;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DwmGetCompositionTimingInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SetupDiGetDevicePropertyW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CreateDXGIFactory;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CreateDXGIFactory1;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_ScriptItemize;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SystemParametersInfoW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SHQueryUserNotificationState;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_IsThreadAFiber;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_FlsAlloc;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_FlsGetValue;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_FlsSetValue;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_FlsFree;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_ConvertThreadToFiberEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetThreadId;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetCurrentProcessorNumber;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CreateFiberEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SwitchToFiber;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SetProcessDEPPolicy;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RegDeleteKeyExW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RegGetValueW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_QueryWorkingSetEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_PdhAddEnglishCounterW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetProcessId;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetVolumePathNamesForVolumeNameW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_freeaddrinfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_getaddrinfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CancelIPChangeNotify;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetAdaptersAddresses;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetGeoInfoW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetUserGeoID;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_TzSpecificLocalTimeToSystemTime;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_AddVectoredExceptionHandler;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RemoveVectoredExceptionHandler;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_AttachConsole;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CheckRemoteDebuggerPresent;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CreateMemoryResourceNotification;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetNativeSystemInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InitializeSListHead;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InterlockedPushEntrySList;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InterlockedFlushSList;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WTSGetActiveConsoleSessionId;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RtlGetLastNtStatus;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetModuleHandleExA;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetModuleHandleExW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SetDllDirectoryW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetLogicalProcessorInformation;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetProcessHandleCount;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_IsProcessInJob;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_IsWow64Process;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_ConvertFiberToThread;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_SystemFunction036;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetPerformanceInfo;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WTSRegisterSessionNotification;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WTSUnRegisterSessionNotification;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_PowerDeterminePlatformRole;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_InterlockedPopEntrySList;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetProcAddress;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_LoadLibraryW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_ProcessPrng;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetDpiForMonitor;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetLayeredWindowAttributes;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_PrintWindow;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DefRawInputProc;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetRawInputData;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetRawInputDeviceInfoW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetRawInputDeviceList;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RegisterRawInputDevices;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_OpenThemeData;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CloseThemeData;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DrawThemeBackground;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetThemeBackgroundContentRect;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetThemePartSize;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CoRegisterInitializeSpy;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CoRevokeInitializeSpy;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_HeapSetInformation;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WindowsCreateString;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WindowsGetStringRawBuffer;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WindowsDeleteString;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RoGetActivationFactory;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RoActivateInstance;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_PrefetchVirtualMemory;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetFirmwareType;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_WindowsCreateStringReference;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_LoadLibraryA;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_LoadLibraryExA;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_LoadLibraryExW;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DWriteCreateFactory;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CryptProtectMemory;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_CryptUnprotectMemory;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetPackagePathByFullName;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetPackagesByPackageFamily;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_LCMapStringEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_UnhookWindowsHookEx;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DuplicateHandle;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_RegisterPointerDeviceNotifications;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetPointerDevices;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_GetPointerDevice;
|
||||||
|
|
||||||
|
pfnFunc_generic g_pfn_DiscardVirtualMemory;
|
||||||
1478
progwrp-CSOG/exports.c
Normal file
1478
progwrp-CSOG/exports.c
Normal file
File diff suppressed because it is too large
Load Diff
283
progwrp-CSOG/exports.c.bak
Normal file
283
progwrp-CSOG/exports.c.bak
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
|
||||||
|
#include "export.h"
|
||||||
|
|
||||||
|
// Parameters are there to ensure proper linking on x86. Only built-in types are used as this
|
||||||
|
// source file is purposely isolated from the common headers to avoid conflicts
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall TryAcquireSRWLockExclusive(void* SRWLock)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_TryAcquireSRWLockExclusive
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_TryAcquireSRWLockExclusive();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall TryAcquireSRWLockShared(void* SRWLock)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_TryAcquireSRWLockShared
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_TryAcquireSRWLockShared();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall AcquireSRWLockExclusive(void* SRWLock)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_AcquireSRWLockExclusive
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_AcquireSRWLockExclusive();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall AcquireSRWLockShared(void* SRWLock)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_AcquireSRWLockShared
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_AcquireSRWLockShared();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall ReleaseSRWLockExclusive(void* SRWLock)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_ReleaseSRWLockExclusive
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_ReleaseSRWLockExclusive();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall ReleaseSRWLockShared(void* SRWLock)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_ReleaseSRWLockShared
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_ReleaseSRWLockShared();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall InitializeSRWLock(void* SRWLock)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_InitializeSRWLock
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_InitializeSRWLock();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall DecodePointer(void* Ptr)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_DecodePointer
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_DecodePointer();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall EncodePointer(void* Ptr)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_DecodePointer
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_DecodePointer();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetMaximumProcessorCount()
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_GetMaximumProcessorCount
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_GetMaximumProcessorCount();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetMaximumProcessorGroupCount()
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
pop ebp
|
||||||
|
jmp g_pfn_GetMaximumProcessorGroupCount
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
g_pfn_GetMaximumProcessorGroupCount();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetLogicalProcessorInformationEx(void* v1, void* v2, void* v3)
|
||||||
|
{
|
||||||
|
g_pfn_GetLogicalProcessorInformationEx();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetThreadGroupAffinity(void* v1, void* v2)
|
||||||
|
{
|
||||||
|
g_pfn_GetThreadGroupAffinity();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall PowerCreateRequest(void* v1, void* v2)
|
||||||
|
{
|
||||||
|
g_pfn_PowerCreateRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall PowerSetRequest(void* v1)
|
||||||
|
{
|
||||||
|
g_pfn_PowerSetRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall PowerClearRequest(void* v1, void* v2)
|
||||||
|
{
|
||||||
|
g_pfn_PowerClearRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall ResolveLocaleName(void* v1, void* v2, void* v3)
|
||||||
|
{
|
||||||
|
g_pfn_ResolveLocaleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall NtOpenKeyEx(void* v1, void* v2, void* v3, void* v4)
|
||||||
|
{
|
||||||
|
g_pfn_NtOpenKeyEx();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall WerRegisterRuntimeExceptionModule(void* v1, void* v2)
|
||||||
|
{
|
||||||
|
g_pfn_WerRegisterRuntimeExceptionModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall SHGetPropertyStoreForWindow(void* v1, void* v2, void* v3)
|
||||||
|
{
|
||||||
|
g_pfn_SHGetPropertyStoreForWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall RegisterTouchWindow(void* v1, void* v2)
|
||||||
|
{
|
||||||
|
g_pfn_RegisterTouchWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetTouchInputInfo()
|
||||||
|
{
|
||||||
|
g_pfn_GetTouchInputInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall QueryDisplayConfig(void* v1, void* v2, void* v3, void* v4,
|
||||||
|
void* v5, void* v6)
|
||||||
|
{
|
||||||
|
g_pfn_QueryDisplayConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall DisplayConfigGetDeviceInfo(void* v1)
|
||||||
|
{
|
||||||
|
g_pfn_DisplayConfigGetDeviceInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall DisplayConfigSetDeviceInfo(void* v1)
|
||||||
|
{
|
||||||
|
g_pfn_DisplayConfigSetDeviceInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetDisplayConfigBufferSizes(void* v1, void* v2, void* v3)
|
||||||
|
{
|
||||||
|
g_pfn_GetDisplayConfigBufferSizes();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall CloseTouchInputHandle(void* v1)
|
||||||
|
{
|
||||||
|
g_pfn_CloseTouchInputHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall CloseGestureInfoHandle()
|
||||||
|
{
|
||||||
|
g_pfn_CloseGestureInfoHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetGestureInfo()
|
||||||
|
{
|
||||||
|
g_pfn_GetGestureInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall SetGestureConfig()
|
||||||
|
{
|
||||||
|
g_pfn_SetGestureConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall UnregisterTouchWindow()
|
||||||
|
{
|
||||||
|
g_pfn_UnregisterTouchWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall IsTouchWindow()
|
||||||
|
{
|
||||||
|
g_pfn_IsTouchWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall CreateRemoteThreadEx(void* v1, void* v2, void* v3, void* v4,
|
||||||
|
void* v5, void* v6, void* v7, void* v8)
|
||||||
|
{
|
||||||
|
g_pfn_CreateRemoteThreadEx();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetModuleInformation(void* v1, void* v2, void* v3, void* v4)
|
||||||
|
{
|
||||||
|
g_pfn_GetModuleInformation();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall GetProcessMemoryInfo(void* v1, void* v2, void* v3)
|
||||||
|
{
|
||||||
|
g_pfn_GetProcessMemoryInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall FindFirstFileExW(void* v1, void* v2, void* v3, void* v4,
|
||||||
|
void* v5, void* v6)
|
||||||
|
{
|
||||||
|
g_pfn_FindFirstFileExW();
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) void __stdcall SleepConditionVariableSRW(void* v1, void* v2, void* v3, void* v4)
|
||||||
|
{
|
||||||
|
g_pfn_SleepConditionVariableSRW();
|
||||||
|
}
|
||||||
198
progwrp-CSOG/fiber.c
Normal file
198
progwrp-CSOG/fiber.c
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_IsThreadAFiber()
|
||||||
|
// Vista uses a TEB flag to determine whether a thread is a fiber.
|
||||||
|
// XP puts the flag in a different area, and 2000 has none.
|
||||||
|
// But there is the TIB's FiberData member, which also has a "version" number assigned to it.
|
||||||
|
// On XP and Vista it is assigned 0x1E00. Anything greather than that is assumed to be fiber data.
|
||||||
|
{
|
||||||
|
PTEB_CUSTOM Teb;
|
||||||
|
|
||||||
|
Teb = (PTEB_CUSTOM)NtCurrentTeb();
|
||||||
|
|
||||||
|
if((ULONG_PTR)Teb->FiberData <= 0x1E00)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI Implementation_FlsAlloc(
|
||||||
|
PFLS_CALLBACK_FUNCTION lpCallback
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TlsAlloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_FlsFree(
|
||||||
|
DWORD dwFlsIndex
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TlsFree(dwFlsIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef PVOID(WINAPI* pfnFlsGetValue)(DWORD);
|
||||||
|
BOOLEAN IsNt6Level = FALSE;
|
||||||
|
pfnFlsGetValue pFlsGetVal = NULL;
|
||||||
|
PVOID Test = NULL;
|
||||||
|
|
||||||
|
PVOID WINAPI Implementation_FlsGetValue(
|
||||||
|
DWORD dwFlsIndex
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PTEB_CUSTOM Teb;
|
||||||
|
int i;
|
||||||
|
PLDR_DATA_TABLE_ENTRY DataTableEntry, DataTableEntryInit;
|
||||||
|
ANSI_STRING Fls;
|
||||||
|
if (!Test)
|
||||||
|
{
|
||||||
|
RtlInitAnsiString(&Fls, "FlsGetValue");
|
||||||
|
|
||||||
|
LdrGetProcedureAddress(GetModuleHandleA("kernel32.dll"), &Fls, 0, &pFlsGetVal);
|
||||||
|
RtlInitAnsiString(&Fls, "WerpInitiateRemoteRecovery");
|
||||||
|
LdrGetProcedureAddress(GetModuleHandleA("kernel32.dll"), &Fls, 0, &Test);
|
||||||
|
if (!Test) {
|
||||||
|
for (i = 0; i < TlsBasesCount; i++)
|
||||||
|
{
|
||||||
|
TLSInit_DllMain_ThreadAttach_Internal(TlsBases[i], NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pFlsGetVal)
|
||||||
|
return pFlsGetVal(dwFlsIndex);
|
||||||
|
return TlsGetValue(dwFlsIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_FlsSetValue(
|
||||||
|
DWORD dwFlsIndex,
|
||||||
|
PVOID lpFlsData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TlsSetValue(dwFlsIndex, lpFlsData);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
LPVOID lpParameter;
|
||||||
|
PVOID Reserved [4];
|
||||||
|
CONTEXT Ctx;
|
||||||
|
}FIBER, *PFIBER;
|
||||||
|
|
||||||
|
LPVOID WINAPI Implementation_ConvertThreadToFiberEx(
|
||||||
|
LPVOID lpParameter,
|
||||||
|
DWORD dwFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PFIBER Result = (PFIBER) ConvertThreadToFiber(lpParameter);
|
||||||
|
|
||||||
|
if(Result && dwFlags & FIBER_FLAG_FLOAT_SWITCH)
|
||||||
|
{
|
||||||
|
Result->Ctx.ContextFlags |= CONTEXT_FLOATING_POINT | CONTEXT_CONTROL | CONTEXT_SEGMENTS | CONTEXT_INTEGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (LPVOID) Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPVOID WINAPI Implementation_CreateFiberEx(
|
||||||
|
SIZE_T dwStackCommitSize,
|
||||||
|
SIZE_T dwStackReserveSize,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPFIBER_START_ROUTINE lpStartAddress,
|
||||||
|
LPVOID lpParameter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PFIBER Result;
|
||||||
|
typedef LPVOID (WINAPI* pfnCreateFiberEx)(SIZE_T, SIZE_T, DWORD, LPFIBER_START_ROUTINE, LPVOID);
|
||||||
|
|
||||||
|
pfnCreateFiberEx pCreateFib = (pfnCreateFiberEx)Implementation_GetProcAddress(GetModuleHandleA("kernel32.dll"), "CreateFiberEx");
|
||||||
|
|
||||||
|
if(g_pfn_ConvertThreadToFiberEx == (pfnFunc_generic)Implementation_ConvertThreadToFiberEx)
|
||||||
|
{
|
||||||
|
Result = (PFIBER) pCreateFib(dwStackCommitSize, dwStackReserveSize, 0, lpStartAddress, lpParameter);
|
||||||
|
|
||||||
|
if(Result && dwFlags & FIBER_FLAG_FLOAT_SWITCH)
|
||||||
|
{
|
||||||
|
Result->Ctx.ContextFlags |= CONTEXT_FLOATING_POINT | CONTEXT_CONTROL | CONTEXT_SEGMENTS | CONTEXT_INTEGER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Result = (PFIBER) pCreateFib(dwStackCommitSize, dwStackReserveSize, dwFlags, lpStartAddress, lpParameter);
|
||||||
|
|
||||||
|
return (LPVOID) Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_SwitchToFiber(LPVOID lpFiber)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
#ifdef _M_IX86
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov edx, fs:0x18 ; NtCurrentTeb()
|
||||||
|
mov eax, [edx+0x10] ; FiberData
|
||||||
|
mov [eax+0xB8], ebx
|
||||||
|
mov [eax+0xB0], edi
|
||||||
|
mov [eax+0xB4], esi
|
||||||
|
mov [eax+0xC8], ebp
|
||||||
|
cmp dword ptr [eax+0x14], 0x1000F ; Result->Ctx.ContextFlags & CONTEXT_FLOATING_POINT | CONTEXT_CONTROL | CONTEXT_SEGMENTS | CONTEXT_INTEGER
|
||||||
|
jnz SkipFloatingPoint
|
||||||
|
fstsw word ptr [eax+0x34]
|
||||||
|
fnstcw word ptr [eax+0x30]
|
||||||
|
cmp byte ptr ds:0x7FFE027A, 1 ; PF_XMMI_INSTRUCTIONS_AVAILABLE check, available since Windows 2000
|
||||||
|
jnz SkipFloatingPoint
|
||||||
|
nop ; stmxcsr dword ptr [eax+0x28]
|
||||||
|
SkipFloatingPoint:
|
||||||
|
mov [eax+0xD8], esp
|
||||||
|
mov ecx, [edx]
|
||||||
|
mov ebx, [edx+8]
|
||||||
|
mov [eax+4], ecx
|
||||||
|
mov [eax+0xC], ebx
|
||||||
|
mov ecx, [esp+4] ; lpFiber
|
||||||
|
mov [edx+0x10], ecx
|
||||||
|
mov esi, [ecx+4]
|
||||||
|
mov ebx, [ecx+8]
|
||||||
|
mov [edx], esi
|
||||||
|
mov [edx+4], ebx
|
||||||
|
mov esi, [ecx+0xC]
|
||||||
|
mov ebx, [ecx+0x10]
|
||||||
|
mov [edx+8], esi
|
||||||
|
mov [edx+0xE0C], ebx
|
||||||
|
cmp dword ptr [ecx+0x14], 1000Fh
|
||||||
|
jnz SkipFloatingPoint2
|
||||||
|
mov ebx, [eax+0x34]
|
||||||
|
cmp bx, [ecx+0x34]
|
||||||
|
jnz loc_7DD8105B
|
||||||
|
mov ebx, [eax+0x30]
|
||||||
|
cmp bx, [ecx+0x30]
|
||||||
|
jz loc_7DD81064
|
||||||
|
loc_7DD8105B:
|
||||||
|
mov word ptr [ecx+0x38], 0xFFFF
|
||||||
|
fldenv byte ptr [ecx+0x30]
|
||||||
|
loc_7DD81064:
|
||||||
|
cmp byte ptr ds:0x7FFE027A, 1
|
||||||
|
jnz SkipFloatingPoint2
|
||||||
|
nop ; ldmxcsr dword ptr [ecx+0x28]
|
||||||
|
SkipFloatingPoint2:
|
||||||
|
mov edi, [ecx+0xB0]
|
||||||
|
mov esi, [ecx+0xB4]
|
||||||
|
mov ebp, [ecx+0xC8]
|
||||||
|
mov ebx, [ecx+0xB8]
|
||||||
|
mov esp, [ecx+0xD8]
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_ConvertFiberToThread()
|
||||||
|
{
|
||||||
|
PTEB_CUSTOM Teb = (PTEB_CUSTOM)NtCurrentTeb();
|
||||||
|
|
||||||
|
if((ULONG_PTR)Teb->FiberData <= 0x1E00)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
Teb->FiberData = 0x1E00;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
395
progwrp-CSOG/file.c
Normal file
395
progwrp-CSOG/file.c
Normal file
@@ -0,0 +1,395 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FileDirectoryInfo = 1,
|
||||||
|
FileFullDirectoryInformation, // 2
|
||||||
|
FileBothDirectoryInformation, // 3
|
||||||
|
FileBasicInformation, // 4
|
||||||
|
FileStandardInformation, // 5
|
||||||
|
FileInternalInformation, // 6
|
||||||
|
FileEaInformation, // 7
|
||||||
|
FileAccessInformation, // 8
|
||||||
|
FileNameInformation, // 9
|
||||||
|
FileRenameInformation, // 10
|
||||||
|
FileLinkInformation, // 11
|
||||||
|
FileNamesInformation, // 12
|
||||||
|
FileDispositionInformation, // 13
|
||||||
|
FilePositionInformation, // 14
|
||||||
|
FileFullEaInformation, // 15
|
||||||
|
FileModeInformation, // 16
|
||||||
|
FileAlignmentInformation, // 17
|
||||||
|
FileAllInformation, // 18
|
||||||
|
FileAllocationInformation, // 19
|
||||||
|
FileEndOfFileInformation, // 20
|
||||||
|
FileAlternateNameInformation, // 21
|
||||||
|
FileStreamInformation, // 22
|
||||||
|
FilePipeInformation, // 23
|
||||||
|
FilePipeLocalInformation, // 24
|
||||||
|
FilePipeRemoteInformation, // 25
|
||||||
|
FileMailslotQueryInformation, // 26
|
||||||
|
FileMailslotSetInformation, // 27
|
||||||
|
FileCompressionInformation, // 28
|
||||||
|
FileObjectIdInformation, // 29
|
||||||
|
FileCompletionInformation, // 30
|
||||||
|
FileMoveClusterInformation, // 31
|
||||||
|
FileQuotaInformation, // 32
|
||||||
|
FileReparsePointInformation, // 33
|
||||||
|
FileNetworkOpenInformation, // 34
|
||||||
|
FileAttributeTagInformation, // 35
|
||||||
|
FileTrackingInformation, // 36
|
||||||
|
FileIdBothDirectoryInformation, // 37
|
||||||
|
FileIdFullDirectoryInformation, // 38
|
||||||
|
FileValidDataLengthInformation, // 39
|
||||||
|
FileShortNameInformation, // 40
|
||||||
|
FileIoCompletionNotificationInformation, // 41
|
||||||
|
FileIoStatusBlockRangeInformation, // 42
|
||||||
|
FileIoPriorityHintInformation, // 43
|
||||||
|
FileSfioReserveInformation, // 44
|
||||||
|
FileSfioVolumeInformation, // 45
|
||||||
|
FileHardLinkInformation, // 46
|
||||||
|
FileProcessIdsUsingFileInformation, // 47
|
||||||
|
FileNormalizedNameInformation, // 48
|
||||||
|
FileNetworkPhysicalNameInformation, // 49
|
||||||
|
FileIdGlobalTxDirectoryInformation, // 50
|
||||||
|
FileIsRemoteDeviceInformation, // 51
|
||||||
|
FileUnusedInformation, // 52
|
||||||
|
FileNumaNodeInformation, // 53
|
||||||
|
FileStandardLinkInformation, // 54
|
||||||
|
FileRemoteProtocolInformation, // 55
|
||||||
|
|
||||||
|
//
|
||||||
|
// These are special versions of these operations (defined earlier)
|
||||||
|
// which can be used by kernel mode drivers only to bypass security
|
||||||
|
// access checks for Rename and HardLink operations. These operations
|
||||||
|
// are only recognized by the IOManager, a file system should never
|
||||||
|
// receive these.
|
||||||
|
//
|
||||||
|
|
||||||
|
FileRenameInformationBypassAccessCheck, // 56
|
||||||
|
FileLinkInformationBypassAccessCheck, // 57
|
||||||
|
|
||||||
|
//
|
||||||
|
// End of special information classes reserved for IOManager.
|
||||||
|
//
|
||||||
|
|
||||||
|
FileVolumeNameInformation, // 58
|
||||||
|
FileIdInformation, // 59
|
||||||
|
FileIdExtdDirectoryInformation, // 60
|
||||||
|
FileReplaceCompletionInformation, // 61
|
||||||
|
FileHardLinkFullIdInformation, // 62
|
||||||
|
FileIdExtdBothDirectoryInformation, // 63
|
||||||
|
FileDispositionInformationEx, // 64
|
||||||
|
FileRenameInformationEx, // 65
|
||||||
|
FileRenameInformationExBypassAccessCheck, // 66
|
||||||
|
FileDesiredStorageClassInformation, // 67
|
||||||
|
FileStatInformation, // 68
|
||||||
|
FileMemoryPartitionInformation, // 69
|
||||||
|
FileStatLxInformation, // 70
|
||||||
|
FileCaseSensitiveInformation, // 71
|
||||||
|
FileLinkInformationEx, // 72
|
||||||
|
FileLinkInformationExBypassAccessCheck, // 73
|
||||||
|
FileStorageReserveIdInformation, // 74
|
||||||
|
FileCaseSensitiveInformationForceAccessCheck, // 75
|
||||||
|
FileKnownFolderInformation, // 76
|
||||||
|
|
||||||
|
FileMaximumInformation
|
||||||
|
} FILEINFOCLASS, *PFILEINFOCLASS;
|
||||||
|
|
||||||
|
#define ObjectNameInformation 1
|
||||||
|
|
||||||
|
typedef struct _OBJECT_NAME_INFORMATION {
|
||||||
|
UNICODE_STRING Name;
|
||||||
|
WCHAR NameBuffer[1];
|
||||||
|
} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
|
||||||
|
|
||||||
|
typedef struct _FILE_NAME_INFORMATION {
|
||||||
|
ULONG FileNameLength;
|
||||||
|
WCHAR FileName[1];
|
||||||
|
} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
NtQueryInformationFile (
|
||||||
|
_In_ HANDLE FileHandle,
|
||||||
|
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
_Out_writes_bytes_(Length) PVOID FileInformation,
|
||||||
|
_In_ ULONG Length,
|
||||||
|
_In_ FILEINFOCLASS FileInformationClass
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef enum _FSINFOCLASS {
|
||||||
|
FileFsVolumeInformation,
|
||||||
|
FileFsLabelInformation,
|
||||||
|
FileFsSizeInformation,
|
||||||
|
FileFsDeviceInformation,
|
||||||
|
FileFsAttributeInformation,
|
||||||
|
FileFsControlInformation,
|
||||||
|
FileFsFullSizeInformation,
|
||||||
|
FileFsObjectIdInformation,
|
||||||
|
FileFsDriverPathInformation,
|
||||||
|
FileFsVolumeFlagsInformation,
|
||||||
|
FileFsSectorSizeInformation,
|
||||||
|
FileFsDataCopyInformation,
|
||||||
|
FileFsMetadataSizeInformation,
|
||||||
|
FileFsFullSizeInformationEx,
|
||||||
|
FileFsGuidInformation,
|
||||||
|
FileFsMaximumInformation
|
||||||
|
} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
|
||||||
|
|
||||||
|
NTSTATUS NTAPI NtQueryVolumeInformationFile(
|
||||||
|
_In_ HANDLE FileHandle,
|
||||||
|
_Out_ PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
_Out_ PVOID FsInformation,
|
||||||
|
_In_ ULONG Length,
|
||||||
|
_In_ FS_INFORMATION_CLASS FsInformationClass
|
||||||
|
);
|
||||||
|
|
||||||
|
HANDLE WINAPI Implementation_FindFirstFileExW(LPCWSTR lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, LPVOID lpFindFileData,
|
||||||
|
FINDEX_SEARCH_OPS fSearchOp, LPVOID lpSearchFilter, DWORD dwAdditionalFlags)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(dwAdditionalFlags & FIND_FIRST_EX_LARGE_FETCH)
|
||||||
|
dwAdditionalFlags &= ~FIND_FIRST_EX_LARGE_FETCH;
|
||||||
|
|
||||||
|
typedef HANDLE (WINAPI* pfnFindFirstFileExW)(LPCWSTR, FINDEX_INFO_LEVELS, LPVOID, FINDEX_SEARCH_OPS, LPVOID, DWORD);
|
||||||
|
pfnFindFirstFileExW pFFFEXW = (pfnFindFirstFileExW)Implementation_GetProcAddress(GetModuleHandleA("kernel32.dll"), "FindFirstFileExW");
|
||||||
|
return pFFFEXW(lpFileName, FindExInfoStandard, lpFindFileData, fSearchOp, lpSearchFilter, dwAdditionalFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetFileInformationByHandleEx(
|
||||||
|
HANDLE hFile,
|
||||||
|
FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
|
||||||
|
LPVOID lpFileInformation,
|
||||||
|
DWORD dwBufferSize
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
Seems like a wrapper around NtQueryInformationFile, but with the
|
||||||
|
file information classes shifted around a little bit.
|
||||||
|
A switch statement will take care of that.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
IO_STATUS_BLOCK isb;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
switch(FileInformationClass)
|
||||||
|
{
|
||||||
|
case FileBasicInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileBasicInformation);
|
||||||
|
break;
|
||||||
|
case FileStandardInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileStandardInformation);
|
||||||
|
break;
|
||||||
|
case FileNameInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileNameInformation);
|
||||||
|
break;
|
||||||
|
case FileRenameInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileRenameInformation);
|
||||||
|
break;
|
||||||
|
case FileDispositionInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileDispositionInformation);
|
||||||
|
break;
|
||||||
|
case FileAllocationInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileAllocationInformation);
|
||||||
|
break;
|
||||||
|
case FileEndOfFileInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileEndOfFileInformation);
|
||||||
|
break;
|
||||||
|
case FileStreamInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileStreamInformation);
|
||||||
|
break;
|
||||||
|
case FileCompressionInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileCompressionInformation);
|
||||||
|
break;
|
||||||
|
case FileAttributeTagInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileAttributeTagInformation);
|
||||||
|
break;
|
||||||
|
case FileIdBothDirectoryInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileIdBothDirectoryInformation);
|
||||||
|
break;
|
||||||
|
case FileIdBothDirectoryRestartInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileIdFullDirectoryInformation); // ??
|
||||||
|
break;
|
||||||
|
case FileIoPriorityHintInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileIoPriorityHintInformation);
|
||||||
|
break;
|
||||||
|
case FileRemoteProtocolInfo:
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, lpFileInformation, dwBufferSize, FileRemoteProtocolInformation);
|
||||||
|
break;
|
||||||
|
default: // All other classes are not known to work on XP or below
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Status == 0x0)
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_CancelIoEx(HANDLE hFile, LPOVERLAPPED lpOverlapped)
|
||||||
|
{
|
||||||
|
return CancelIo(hFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI Implementation_GetFinalPathNameByHandleW(
|
||||||
|
HANDLE hFile,
|
||||||
|
LPWSTR lpszFilePath,
|
||||||
|
DWORD cchFilePath,
|
||||||
|
DWORD dwFlags
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
NtQueryInformationFile returns the path without the volume name.
|
||||||
|
NtQueryObject returns the path with the NT volume name.
|
||||||
|
The DOS volume name can be retrieved using QueryDosDeviceW to compare with the NtQueryObject value.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
IO_STATUS_BLOCK isb;
|
||||||
|
PFILE_NAME_INFORMATION fni;
|
||||||
|
NTSTATUS Status;
|
||||||
|
ULONG BufferSize, NtNameLen, VolumeNameLen, NoVolNameLen;
|
||||||
|
WCHAR DosDriveLetter [3] = L"A:";
|
||||||
|
WCHAR Path [MAX_PATH];
|
||||||
|
PWSTR VolumeName;
|
||||||
|
HANDLE hMap;
|
||||||
|
PVOID Mem;
|
||||||
|
|
||||||
|
if(dwFlags & ~(VOLUME_NAME_NONE | VOLUME_NAME_NT | FILE_NAME_OPENED)) // todo: add VOLUME_NAME_GUID support
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferSize = sizeof(FILE_NAME_INFORMATION);
|
||||||
|
fni = (PFILE_NAME_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BufferSize);
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
Status = NtQueryInformationFile(hFile, &isb, (PVOID)fni, BufferSize, FileNameInformation);
|
||||||
|
if(Status == 0)
|
||||||
|
break;
|
||||||
|
else if(Status == 0x80000005)
|
||||||
|
BufferSize += 8;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, fni);
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, fni);
|
||||||
|
fni = (PFILE_NAME_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
NoVolNameLen = fni->FileNameLength;
|
||||||
|
|
||||||
|
if(dwFlags & VOLUME_NAME_NONE)
|
||||||
|
{
|
||||||
|
if(cchFilePath >= fni->FileNameLength)
|
||||||
|
StringCchCopyW(lpszFilePath, cchFilePath, fni->FileName);
|
||||||
|
HeapFree(GetProcessHeap(), 0, fni);
|
||||||
|
return NoVolNameLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 1, NULL);
|
||||||
|
|
||||||
|
if(hMap)
|
||||||
|
{
|
||||||
|
Mem = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 1);
|
||||||
|
|
||||||
|
if(Mem)
|
||||||
|
{
|
||||||
|
NtNameLen = GetMappedFileNameW(GetCurrentProcess(), Mem, Path, MAX_PATH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CloseHandle(hMap);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CloseHandle(hMap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
BufferSize = sizeof(OBJECT_NAME_INFORMATION);
|
||||||
|
oni = (POBJECT_NAME_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BufferSize);
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
Status = NtQueryObject(hFile, ObjectNameInformation, oni, BufferSize, NULL);
|
||||||
|
if(Status == 0)
|
||||||
|
break;
|
||||||
|
else if(Status == 0x80000005)
|
||||||
|
BufferSize += 8;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, oni);
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, oni);
|
||||||
|
oni = (POBJECT_NAME_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BufferSize);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if(dwFlags & VOLUME_NAME_NT)
|
||||||
|
{
|
||||||
|
if(cchFilePath >= NtNameLen)
|
||||||
|
StringCchCopyW(lpszFilePath, cchFilePath, Path);
|
||||||
|
return NtNameLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumeName = (PWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BufferSize);
|
||||||
|
|
||||||
|
while(DosDriveLetter[0] <= L"Z")
|
||||||
|
{
|
||||||
|
VolumeNameLen = QueryDosDeviceW(DosDriveLetter, VolumeName, BufferSize / sizeof(WCHAR));
|
||||||
|
|
||||||
|
if(LimitedStrCmp(0, VolumeNameLen, Path, VolumeName))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(DosDriveLetter[0] == L"Z")
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_PATH_NOT_FOUND);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
++DosDriveLetter[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
StringCchCopyW(lpszFilePath, cchFilePath, L"\?\\");
|
||||||
|
StringCchCatW(lpszFilePath, cchFilePath, DosDriveLetter);
|
||||||
|
StringCchCatW(lpszFilePath, cchFilePath, L"\\");
|
||||||
|
StringCchCatW(lpszFilePath, cchFilePath, fni->FileName);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, VolumeName);
|
||||||
|
HeapFree(GetProcessHeap(), 0, fni);
|
||||||
|
|
||||||
|
return NoVolNameLen + 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SetFileInformationByHandle(
|
||||||
|
HANDLE hFile,
|
||||||
|
FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
|
||||||
|
LPVOID lpFileInformation,
|
||||||
|
DWORD dwBufferSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL Implementation_GetVolumePathNamesForVolumeNameW(
|
||||||
|
LPCWSTR lpszVolumeName,
|
||||||
|
LPWCH lpszVolumePathNames,
|
||||||
|
DWORD cchBufferLength,
|
||||||
|
PDWORD lpcchReturnLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
1061
progwrp-CSOG/implementations.h
Normal file
1061
progwrp-CSOG/implementations.h
Normal file
File diff suppressed because it is too large
Load Diff
148
progwrp-CSOG/initonce.c
Normal file
148
progwrp-CSOG/initonce.c
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
The InitOnce structure can be simplified.
|
||||||
|
|
||||||
|
We have 2 bits to play around with (the rest will hold the value of lpContext).
|
||||||
|
|
||||||
|
Bit 0 - indicates initialization is complete
|
||||||
|
Bit 1 - indicates that initialization is asynchronous
|
||||||
|
|
||||||
|
There is also a mutex and a critical section in use. It would be better if they were local to the
|
||||||
|
InitOnce object, but this seems to work very well. As long as the VLC InitOnce-related crashes
|
||||||
|
in Supermium cease, it is good.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define INIT_COMPLETE 0x1
|
||||||
|
#define INIT_ASYNC 0x2
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_InitOnceBeginInitialize(
|
||||||
|
LPINIT_ONCE lpInitOnce,
|
||||||
|
DWORD dwFlags,
|
||||||
|
PBOOL fPending,
|
||||||
|
LPVOID *lpContext
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
This function does not have an associated callback function,
|
||||||
|
but it can be used with the INIT_ONCE object to initialize based on the object itself.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if(dwFlags & ~(INIT_ONCE_CHECK_ONLY | INIT_ONCE_ASYNC) ||
|
||||||
|
!lpInitOnce || !fPending)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((ULONG_PTR)lpInitOnce->Ptr & INIT_ASYNC) && !(dwFlags & INIT_ONCE_ASYNC))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if(dwFlags & INIT_ONCE_ASYNC)
|
||||||
|
InterlockedOr(&lpInitOnce->Ptr, INIT_ASYNC);
|
||||||
|
|
||||||
|
if((ULONG_PTR)lpInitOnce->Ptr & INIT_COMPLETE)
|
||||||
|
{
|
||||||
|
*fPending = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!(dwFlags & INIT_ONCE_CHECK_ONLY))
|
||||||
|
InterlockedOr(&lpInitOnce->Ptr, INIT_COMPLETE);
|
||||||
|
*fPending = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lpContext && ((ULONG_PTR)lpInitOnce->Ptr & INIT_COMPLETE))
|
||||||
|
{
|
||||||
|
*lpContext = (ULONG_PTR)lpInitOnce->Ptr - ((ULONG_PTR)lpInitOnce->Ptr % 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_InitOnceExecuteOnce(
|
||||||
|
PINIT_ONCE InitOnce,
|
||||||
|
PINIT_ONCE_FN InitFn,
|
||||||
|
PVOID Parameter,
|
||||||
|
LPVOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL Result = FALSE;
|
||||||
|
|
||||||
|
if(InitFn && !InitOnce)
|
||||||
|
return InitFn(InitOnce, Parameter, Context);
|
||||||
|
|
||||||
|
if(!InitOnce || !InitFn)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((ULONG_PTR)InitOnce->Ptr & INIT_COMPLETE)
|
||||||
|
{
|
||||||
|
if(Context)
|
||||||
|
*Context = (ULONG_PTR)InitOnce->Ptr - ((ULONG_PTR)InitOnce->Ptr % 4);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&SrwSharedCs);
|
||||||
|
if(((ULONG_PTR)InitOnce->Ptr & INIT_COMPLETE) || Result)
|
||||||
|
goto Result;
|
||||||
|
Result = InitFn(InitOnce, Parameter, Context);
|
||||||
|
|
||||||
|
Result:
|
||||||
|
if(Result)
|
||||||
|
{
|
||||||
|
(ULONG_PTR)InitOnce->Ptr = (ULONG_PTR)Context | ((ULONG_PTR)InitOnce->Ptr & 0x3);
|
||||||
|
InterlockedOr(&InitOnce->Ptr, INIT_COMPLETE);
|
||||||
|
LeaveCriticalSection(&SrwSharedCs);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&SrwSharedCs);
|
||||||
|
if ((ULONG_PTR)InitOnce->Ptr & INIT_COMPLETE)
|
||||||
|
return TRUE;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_InitOnceComplete(
|
||||||
|
LPINIT_ONCE lpInitOnce,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPVOID lpContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!lpInitOnce || dwFlags & ~(INIT_ONCE_INIT_FAILED | INIT_ONCE_ASYNC))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dwFlags & INIT_ONCE_INIT_FAILED)
|
||||||
|
{
|
||||||
|
(ULONG_PTR)lpInitOnce->Ptr = 0;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
InterlockedOr(&lpInitOnce->Ptr, INIT_COMPLETE);
|
||||||
|
|
||||||
|
if(lpContext)
|
||||||
|
{
|
||||||
|
InterlockedOr(&lpInitOnce->Ptr, lpContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_InitOnceInitialize(
|
||||||
|
PINIT_ONCE InitOnce
|
||||||
|
)
|
||||||
|
{
|
||||||
|
InitOnce->Ptr = 0;
|
||||||
|
}
|
||||||
309
progwrp-CSOG/ip.c
Normal file
309
progwrp-CSOG/ip.c
Normal file
@@ -0,0 +1,309 @@
|
|||||||
|
//#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
//#include "implementations.h"
|
||||||
|
//#define NTDDI_VERSION NTDDI_WIN2K
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#include <wspiapi.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
|
void* calloc(
|
||||||
|
size_t number,
|
||||||
|
size_t size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, number * size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void free(
|
||||||
|
void* memblock
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, memblock);
|
||||||
|
}
|
||||||
|
|
||||||
|
errno_t strcpy_s(char * _Destination, rsize_t SizeInBytes, const char* _Source)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
if(!_Destination || !_Source)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
if(!SizeInBytes)
|
||||||
|
return ERANGE;
|
||||||
|
|
||||||
|
for(i = 0; i < SizeInBytes; i++)
|
||||||
|
{
|
||||||
|
_Destination[i] = _Source[i];
|
||||||
|
|
||||||
|
if(_Source[i] == '\0')
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERANGE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
errno_t strncpy_s(char * _Destination, rsize_t SizeInBytes, const char* _Source, rsize_t count)
|
||||||
|
{
|
||||||
|
return StringCchCopyNA(_Destination, SizeInBytes, _Source, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int strtoul(const char* str, char** endPtr, int radix)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCSTR WINAPI Implementation_inet_ntop(
|
||||||
|
INT Family,
|
||||||
|
const VOID *pAddr,
|
||||||
|
PSTR pStringBuf,
|
||||||
|
size_t StringBufSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;// inet_ntop(Family, pAddr, pStringBuf, StringBufSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS WINAPI Implementation_GetIfTable2(
|
||||||
|
PVOID Table
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0xC00000BB;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID WINAPI Implementation_FreeMibTable(
|
||||||
|
PVOID Memory
|
||||||
|
)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID WINAPI Implementation_freeaddrinfo(
|
||||||
|
void * pAddrInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
WspiapiLegacyFreeAddrInfo(pAddrInfo);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
INT WINAPI Implementation_getaddrinfo(
|
||||||
|
PCSTR pNodeName,
|
||||||
|
PCSTR pServiceName,
|
||||||
|
const struct addrinfo *pHints,
|
||||||
|
struct addrinfo **ppResult
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
int iError = 0;
|
||||||
|
int iFlags = 0;
|
||||||
|
int iFamily = PF_UNSPEC;
|
||||||
|
int iSocketType = 0;
|
||||||
|
int iProtocol = 0;
|
||||||
|
WORD wPort = 0;
|
||||||
|
DWORD dwAddress = 0;
|
||||||
|
|
||||||
|
struct servent *ptService = NULL;
|
||||||
|
char *pc = NULL;
|
||||||
|
BOOL bClone = FALSE;
|
||||||
|
WORD wTcpPort = 0;
|
||||||
|
WORD wUdpPort = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// initialize ppResult with default return value.
|
||||||
|
*ppResult = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// validate arguments...
|
||||||
|
//
|
||||||
|
|
||||||
|
// both the node name and the service name can't be NULL.
|
||||||
|
if ((!pNodeName) && (!pServiceName))
|
||||||
|
return EAI_NONAME;
|
||||||
|
|
||||||
|
// validate hints.
|
||||||
|
if (pHints)
|
||||||
|
{
|
||||||
|
// all members other than ai_flags, ai_family, ai_socktype
|
||||||
|
// and ai_protocol must be zero or a null pointer.
|
||||||
|
if ((pHints->ai_addrlen != 0) ||
|
||||||
|
(pHints->ai_canonname != NULL) ||
|
||||||
|
(pHints->ai_addr != NULL) ||
|
||||||
|
(pHints->ai_next != NULL))
|
||||||
|
{
|
||||||
|
return EAI_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the spec has the "bad flags" error code, so presumably we
|
||||||
|
// should check something here. insisting that there aren't
|
||||||
|
// any unspecified flags set would break forward compatibility,
|
||||||
|
// however. so we just check for non-sensical combinations.
|
||||||
|
//
|
||||||
|
// we cannot come up with a canonical name given a null node name.
|
||||||
|
iFlags = pHints->ai_flags;
|
||||||
|
if ((iFlags & AI_CANONNAME) && !pNodeName)
|
||||||
|
return EAI_BADFLAGS;
|
||||||
|
|
||||||
|
// we only support a limited number of protocol families.
|
||||||
|
iFamily = pHints->ai_family;
|
||||||
|
if ((iFamily != PF_UNSPEC) && (iFamily != PF_INET))
|
||||||
|
return EAI_FAMILY;
|
||||||
|
|
||||||
|
// we only support only these socket types.
|
||||||
|
iSocketType = pHints->ai_socktype;
|
||||||
|
if ((iSocketType != 0) &&
|
||||||
|
(iSocketType != SOCK_STREAM) &&
|
||||||
|
(iSocketType != SOCK_DGRAM) &&
|
||||||
|
(iSocketType != SOCK_RAW))
|
||||||
|
return EAI_SOCKTYPE;
|
||||||
|
|
||||||
|
// REVIEW: What if ai_socktype and ai_protocol are at odds?
|
||||||
|
iProtocol = pHints->ai_protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// do service lookup...
|
||||||
|
|
||||||
|
if (pServiceName)
|
||||||
|
{
|
||||||
|
wPort = (WORD) strtoul(pServiceName, &pc, 10);
|
||||||
|
if (*pc == '\0') // numeric port string
|
||||||
|
{
|
||||||
|
wPort = wTcpPort = wUdpPort = htons(wPort);
|
||||||
|
if (iSocketType == 0)
|
||||||
|
{
|
||||||
|
bClone = TRUE;
|
||||||
|
iSocketType = SOCK_STREAM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // non numeric port string
|
||||||
|
{
|
||||||
|
if ((iSocketType == 0) || (iSocketType == SOCK_DGRAM))
|
||||||
|
{
|
||||||
|
ptService = getservbyname(pServiceName, "udp");
|
||||||
|
if (ptService)
|
||||||
|
wPort = wUdpPort = ptService->s_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((iSocketType == 0) || (iSocketType == SOCK_STREAM))
|
||||||
|
{
|
||||||
|
ptService = getservbyname(pServiceName, "tcp");
|
||||||
|
if (ptService)
|
||||||
|
wPort = wTcpPort = ptService->s_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
// assumes 0 is an invalid service port...
|
||||||
|
if (wPort == 0) // no service exists
|
||||||
|
return (iSocketType ? EAI_SERVICE : EAI_NONAME);
|
||||||
|
|
||||||
|
if (iSocketType == 0)
|
||||||
|
{
|
||||||
|
// if both tcp and udp, process tcp now & clone udp later.
|
||||||
|
iSocketType = (wTcpPort) ? SOCK_STREAM : SOCK_DGRAM;
|
||||||
|
bClone = (wTcpPort && wUdpPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// do node name lookup...
|
||||||
|
|
||||||
|
// if we weren't given a node name,
|
||||||
|
// return the wildcard or loopback address (depending on AI_PASSIVE).
|
||||||
|
//
|
||||||
|
// if we have a numeric host address string,
|
||||||
|
// return the binary address.
|
||||||
|
///*
|
||||||
|
if ((!pNodeName) || (WspiapiParseV4Address(pNodeName, &dwAddress)))
|
||||||
|
{
|
||||||
|
if (!pNodeName)
|
||||||
|
{
|
||||||
|
dwAddress = htonl((iFlags & AI_PASSIVE)
|
||||||
|
? INADDR_ANY
|
||||||
|
: INADDR_LOOPBACK);
|
||||||
|
}
|
||||||
|
// create an addrinfo structure...
|
||||||
|
*ppResult =
|
||||||
|
WspiapiNewAddrInfo(iSocketType, iProtocol, wPort, dwAddress);
|
||||||
|
if (!(*ppResult))
|
||||||
|
iError = EAI_MEMORY;
|
||||||
|
|
||||||
|
if (!iError && pNodeName)
|
||||||
|
{
|
||||||
|
// implementation specific behavior: set AI_NUMERICHOST
|
||||||
|
// to indicate that we got a numeric host address string.
|
||||||
|
(*ppResult)->ai_flags |= AI_NUMERICHOST;
|
||||||
|
|
||||||
|
// return the numeric address string as the canonical name
|
||||||
|
if (iFlags & AI_CANONNAME)
|
||||||
|
{
|
||||||
|
(*ppResult)->ai_canonname =
|
||||||
|
#pragma warning(suppress: 4996)
|
||||||
|
WspiapiStrdup(inet_ntoa(*((struct in_addr *) &dwAddress)));
|
||||||
|
if (!(*ppResult)->ai_canonname)
|
||||||
|
iError = EAI_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// if we do not have a numeric host address string and
|
||||||
|
// AI_NUMERICHOST flag is set, return an error!
|
||||||
|
else if (iFlags & AI_NUMERICHOST)
|
||||||
|
{
|
||||||
|
iError = EAI_NONAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// since we have a non-numeric node name,
|
||||||
|
// we have to do a regular node name lookup.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iError = WspiapiLookupNode(pNodeName,
|
||||||
|
iSocketType,
|
||||||
|
iProtocol,
|
||||||
|
wPort,
|
||||||
|
(iFlags & AI_CANONNAME),
|
||||||
|
ppResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!iError && bClone)
|
||||||
|
{
|
||||||
|
iError = WspiapiClone(wUdpPort, *ppResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iError)
|
||||||
|
{
|
||||||
|
WspiapiLegacyFreeAddrInfo(*ppResult);
|
||||||
|
*ppResult = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (iError);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_CancelIPChangeNotify(
|
||||||
|
LPOVERLAPPED notifyOverlapped
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Implementation_GetAdaptersAddresses(
|
||||||
|
ULONG Family,
|
||||||
|
ULONG Flags,
|
||||||
|
PVOID Reserved,
|
||||||
|
PVOID AdapterAddresses,
|
||||||
|
PULONG SizePointer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(Family == AF_UNSPEC || Family == AF_INET)
|
||||||
|
// First seek out IPv4 adapters.
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERROR_NO_DATA;
|
||||||
|
}
|
||||||
472
progwrp-CSOG/locale.c
Normal file
472
progwrp-CSOG/locale.c
Normal file
@@ -0,0 +1,472 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include "strsafe.h"
|
||||||
|
#include "locale.h"
|
||||||
|
|
||||||
|
BOOL WINAPI LimitedStrCmp(int StartIdx, int EndIdx, PCWSTR Str0, PCWSTR Str1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < EndIdx - StartIdx; i++)
|
||||||
|
{
|
||||||
|
if(Str0[i + StartIdx] != Str1[i])
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if(Str1[i] == '\0' && i < ((EndIdx - StartIdx) - 1))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_LCIDToLocaleName(
|
||||||
|
LCID Locale,
|
||||||
|
LPWSTR lpName,
|
||||||
|
int cchName,
|
||||||
|
DWORD dwFlags)
|
||||||
|
/*
|
||||||
|
The process of the non-neutral locales will be a little more complex.
|
||||||
|
There are some that aren't even associated to a neutral locale.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int RequiredSize = 0;
|
||||||
|
size_t Length;
|
||||||
|
|
||||||
|
if(!lpName && !cchName)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dwFlags & ~(LOCALE_ALLOW_NEUTRAL_NAMES))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Locale == LOCALE_INVARIANT || (Locale % 0x400) > LOCALE_NEUTRAL_LIMIT)
|
||||||
|
{
|
||||||
|
Locale = 0x409;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Locale == LOCALE_SYSTEM_DEFAULT)
|
||||||
|
{
|
||||||
|
Locale = GetSystemDefaultLCID();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Locale == LOCALE_USER_DEFAULT)
|
||||||
|
{
|
||||||
|
Locale = GetUserDefaultLCID();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Locale < LOCALE_NEUTRAL_LIMIT) && (dwFlags & LOCALE_ALLOW_NEUTRAL_NAMES))
|
||||||
|
{
|
||||||
|
while(NeutralLangIdTbl[Locale][RequiredSize] != L'\0')
|
||||||
|
{
|
||||||
|
++RequiredSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
++RequiredSize;
|
||||||
|
|
||||||
|
if(cchName && (cchName < RequiredSize))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cchName && lpName)
|
||||||
|
StringCchCopyW(lpName, cchName, NeutralLangIdTbl[Locale]);
|
||||||
|
|
||||||
|
return RequiredSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(NeutralLangIdTbl[Locale % 0x400][RequiredSize] != L'\0')
|
||||||
|
{
|
||||||
|
++RequiredSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
++RequiredSize;
|
||||||
|
++RequiredSize;
|
||||||
|
|
||||||
|
if(StringCchLengthW(LocaleIdentifierTbl[Locale % 0x400][(Locale / 0x400) - 1], STRSAFE_MAX_CCH, &Length) == STRSAFE_E_INVALID_PARAMETER)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RequiredSize += Length;
|
||||||
|
|
||||||
|
if(cchName && (cchName < RequiredSize))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cchName && lpName)
|
||||||
|
{
|
||||||
|
StringCchCopyW(lpName, cchName, NeutralLangIdTbl[Locale % 0x400]);
|
||||||
|
StringCchCatW(lpName, cchName, L"-");
|
||||||
|
StringCchCatW(lpName, cchName, LocaleIdentifierTbl[Locale % 0x400][(Locale / 0x400) - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RequiredSize;
|
||||||
|
}
|
||||||
|
// First handle the special locale cases that aren't linked to a neutral locale,
|
||||||
|
// then handle locales linked to a neutral locale.
|
||||||
|
// Each LCID pertaining to a particular locale has an offset of 0x400 from the neutral locale.
|
||||||
|
// e.g. en is 0x9, en-US is 0x409, en-GB is 0x809... ending with 0x3009 for en-ZW (Zimbabwe).
|
||||||
|
// So all we need to do is build a table for each locale, and derive an index from (LCID / 0x400 - 1) to get the full locale name.
|
||||||
|
}
|
||||||
|
|
||||||
|
LCID WINAPI Implementation_LocaleNameToLCID(
|
||||||
|
LPCWSTR lpName,
|
||||||
|
DWORD dwFlags
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
First checks the neutral portion of the locale, which is either two or three characters long.
|
||||||
|
If it matches an entry in the table, (and it is not a neutral locale outright), then compare
|
||||||
|
locations.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int NeutralLocaleLen = 0, NeutralLocaleIdx, FullLocaleIdx = 0, LocaleLen;
|
||||||
|
if(dwFlags & ~(LOCALE_ALLOW_NEUTRAL_NAMES) || !lpName)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if(lpName == LOCALE_NAME_SYSTEM_DEFAULT)
|
||||||
|
{
|
||||||
|
return GetSystemDefaultLCID();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if(lpName[0] == L' ' && lpName[1] == L'\0')
|
||||||
|
{
|
||||||
|
return 0x409;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lpName == LOCALE_NAME_USER_DEFAULT)
|
||||||
|
{
|
||||||
|
return GetUserDefaultLCID();
|
||||||
|
}
|
||||||
|
|
||||||
|
while(lpName[NeutralLocaleLen] != L'-')
|
||||||
|
{
|
||||||
|
++NeutralLocaleLen;
|
||||||
|
|
||||||
|
if(lpName[NeutralLocaleLen] == L'\0')
|
||||||
|
{
|
||||||
|
if(dwFlags & LOCALE_ALLOW_NEUTRAL_NAMES)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(NeutralLocaleIdx = 0; NeutralLocaleIdx < LOCALE_NEUTRAL_LIMIT; NeutralLocaleIdx++)
|
||||||
|
{
|
||||||
|
if(LimitedStrCmp(0, NeutralLocaleLen, lpName, NeutralLangIdTbl[NeutralLocaleIdx]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(NeutralLocaleIdx == LOCALE_NEUTRAL_LIMIT)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(dwFlags & LOCALE_ALLOW_NEUTRAL_NAMES)
|
||||||
|
return NeutralLocaleIdx - 1;
|
||||||
|
|
||||||
|
LocaleLen = NeutralLocaleLen + 1;
|
||||||
|
|
||||||
|
while(lpName[LocaleLen] != L'\0')
|
||||||
|
{
|
||||||
|
++LocaleLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(LocaleIdentifierTbl[NeutralLocaleIdx - 1][FullLocaleIdx][0] != L'\0')
|
||||||
|
{
|
||||||
|
if(LimitedStrCmp(NeutralLocaleLen + 1, LocaleLen, lpName, LocaleIdentifierTbl[NeutralLocaleIdx - 1][FullLocaleIdx]))
|
||||||
|
{
|
||||||
|
return ((FullLocaleIdx + 1) * 0x400) + (NeutralLocaleIdx - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
++FullLocaleIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_ResolveLocaleName(
|
||||||
|
LPCWSTR lpNameToResolve,
|
||||||
|
LPWSTR lpLocaleName,
|
||||||
|
int cchLocaleName
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
This will be part and parcel of my new locale API.
|
||||||
|
|
||||||
|
The real implementation of this function was criticized for poor
|
||||||
|
results at first, so I'll outline what one can expect.
|
||||||
|
|
||||||
|
If lpNameToResolve's language label does not match any known neutral locale,
|
||||||
|
return the user locale.
|
||||||
|
|
||||||
|
If lpNameToResolve's language label matches a neutral locale, but there is
|
||||||
|
no other matching information, return the user locale if it has the same neutral
|
||||||
|
locale or return the "base locale" for the neutral locale (i.e. en-US for "en-RU"
|
||||||
|
or "en-BLAHBLAHBLAH").
|
||||||
|
|
||||||
|
If there is a valid region identifier at the end of lpNameToResolve (between the last
|
||||||
|
'-' and null character), in addition to a neutral locale that also has a valid entry
|
||||||
|
for the region, return the "lan-reg" form.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if(lpLocaleName && lpNameToResolve)
|
||||||
|
{
|
||||||
|
StringCchCopyW(lpLocaleName, cchLocaleName, lpNameToResolve);
|
||||||
|
return cchLocaleName;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_EnumSystemLocalesEx(
|
||||||
|
LOCALE_ENUMPROCEX lpLocaleEnumProcEx,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPARAM lParam,
|
||||||
|
LPVOID lpReserved
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_GetCurrencyFormatEx(
|
||||||
|
LPCWSTR lpLocaleName,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPCWSTR lpValue,
|
||||||
|
const CURRENCYFMTW *lpFormat,
|
||||||
|
LPWSTR lpCurrencyStr,
|
||||||
|
int cchCurrency
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GetCurrencyFormatW(Implementation_LocaleNameToLCID(lpLocaleName, 0), dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency);
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_GetDateFormatEx(
|
||||||
|
LPCWSTR lpLocaleName,
|
||||||
|
DWORD dwFlags,
|
||||||
|
const SYSTEMTIME *lpDate,
|
||||||
|
LPCWSTR lpFormat,
|
||||||
|
LPWSTR lpDateStr,
|
||||||
|
int cchDate,
|
||||||
|
LPCWSTR lpCalendar
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GetDateFormatW(Implementation_LocaleNameToLCID(lpLocaleName, 0), dwFlags, lpDate, lpFormat, lpDateStr, cchDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI Implementation_GetDynamicTimeZoneInformation(
|
||||||
|
PDYNAMIC_TIME_ZONE_INFORMATION pTimeZoneInformation
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DWORD Result;
|
||||||
|
TIME_ZONE_INFORMATION tzif;
|
||||||
|
|
||||||
|
if(!pTimeZoneInformation)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return TIME_ZONE_ID_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Result = GetTimeZoneInformation(pTimeZoneInformation);
|
||||||
|
|
||||||
|
pTimeZoneInformation->TimeZoneKeyName[0] = '\0';
|
||||||
|
pTimeZoneInformation->DynamicDaylightTimeDisabled = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_GetTimeFormatEx(
|
||||||
|
LPCWSTR lpLocaleName,
|
||||||
|
DWORD dwFlags,
|
||||||
|
const SYSTEMTIME *lpTime,
|
||||||
|
LPCWSTR lpFormat,
|
||||||
|
LPWSTR lpTimeStr,
|
||||||
|
int cchTime
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GetTimeFormatW(Implementation_LocaleNameToLCID(lpLocaleName, 0), dwFlags, lpTime, lpFormat, lpTimeStr, cchTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_GetLocaleInfoEx(
|
||||||
|
LPCWSTR lpLocaleName,
|
||||||
|
LCTYPE LCType,
|
||||||
|
LPWSTR lpLCData,
|
||||||
|
int cchData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GetLocaleInfoW(Implementation_LocaleNameToLCID(lpLocaleName, 0), LCType, lpLCData, cchData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_GetNumberFormatEx(
|
||||||
|
LPCWSTR lpLocaleName,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPCWSTR lpValue,
|
||||||
|
const NUMBERFMTW *lpFormat,
|
||||||
|
LPWSTR lpNumberStr,
|
||||||
|
int cchNumber
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GetNumberFormatW(Implementation_LocaleNameToLCID(lpLocaleName, 0), dwFlags, lpValue, lpFormat, lpNumberStr, cchNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_GetUserDefaultLocaleName(
|
||||||
|
LPWSTR lpLocaleName,
|
||||||
|
int cchLocaleName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return Implementation_LCIDToLocaleName(GetUserDefaultLCID(), lpLocaleName, cchLocaleName, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define THREAD_LOCALE 1
|
||||||
|
#define USER_LOCALE 2
|
||||||
|
#define SYSTEM_LOCALE 4
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetThreadPreferredUILanguages(
|
||||||
|
DWORD dwFlags,
|
||||||
|
PULONG pulNumLanguages,
|
||||||
|
PZZWSTR pwszLanguagesBuffer,
|
||||||
|
PULONG pcchLanguagesBuffer
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
Objective: get the "thread locale" first. Offer the user locale second, and the system locale third.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
LCID ThreadLocale;
|
||||||
|
LCID UserLocale;
|
||||||
|
LCID SystemLocale;
|
||||||
|
int i;
|
||||||
|
WCHAR szLocaleName [45];
|
||||||
|
int szLocaleName_lens [3] = {0, 0, 0};
|
||||||
|
|
||||||
|
if(!pulNumLanguages || !pcchLanguagesBuffer)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pulNumLanguages = 3;
|
||||||
|
|
||||||
|
ThreadLocale = GetThreadLocale();
|
||||||
|
|
||||||
|
UserLocale = GetUserDefaultLCID();
|
||||||
|
|
||||||
|
SystemLocale = GetSystemDefaultLCID();
|
||||||
|
|
||||||
|
if(dwFlags & MUI_LANGUAGE_ID)
|
||||||
|
{
|
||||||
|
*pcchLanguagesBuffer = 10;
|
||||||
|
|
||||||
|
if(pwszLanguagesBuffer)
|
||||||
|
{
|
||||||
|
pwszLanguagesBuffer[0] = HIWORD(ThreadLocale);
|
||||||
|
pwszLanguagesBuffer[1] = LOWORD(ThreadLocale);
|
||||||
|
pwszLanguagesBuffer[2] = L'\0';
|
||||||
|
pwszLanguagesBuffer[3] = HIWORD(UserLocale);
|
||||||
|
pwszLanguagesBuffer[4] = LOWORD(UserLocale);
|
||||||
|
pwszLanguagesBuffer[5] = L'\0';
|
||||||
|
pwszLanguagesBuffer[6] = HIWORD(SystemLocale);
|
||||||
|
pwszLanguagesBuffer[7] = LOWORD(SystemLocale);
|
||||||
|
pwszLanguagesBuffer[8] = L'\0';
|
||||||
|
pwszLanguagesBuffer[9] = L'\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
szLocaleName_lens[0] = Implementation_LCIDToLocaleName(ThreadLocale, szLocaleName, 45, 0);
|
||||||
|
|
||||||
|
if(pwszLanguagesBuffer)
|
||||||
|
{
|
||||||
|
StringCchCopyW(pwszLanguagesBuffer, *pcchLanguagesBuffer, szLocaleName);
|
||||||
|
StringCchCatW(pwszLanguagesBuffer, *pcchLanguagesBuffer, L";");
|
||||||
|
}
|
||||||
|
|
||||||
|
szLocaleName_lens[1] = Implementation_LCIDToLocaleName(UserLocale, szLocaleName, 45, 0);
|
||||||
|
|
||||||
|
if(pwszLanguagesBuffer)
|
||||||
|
{
|
||||||
|
StringCchCatW(pwszLanguagesBuffer, *pcchLanguagesBuffer, szLocaleName);
|
||||||
|
StringCchCatW(pwszLanguagesBuffer, *pcchLanguagesBuffer, L";");
|
||||||
|
}
|
||||||
|
|
||||||
|
szLocaleName_lens[2] = Implementation_LCIDToLocaleName(SystemLocale, szLocaleName, 45, 0);
|
||||||
|
|
||||||
|
if(pwszLanguagesBuffer)
|
||||||
|
{
|
||||||
|
StringCchCatW(pwszLanguagesBuffer, *pcchLanguagesBuffer, szLocaleName);
|
||||||
|
StringCchCatW(pwszLanguagesBuffer, *pcchLanguagesBuffer, L";");
|
||||||
|
StringCchCatW(pwszLanguagesBuffer, *pcchLanguagesBuffer, L"\0");
|
||||||
|
for(i = 0; i < *pcchLanguagesBuffer; i++)
|
||||||
|
{
|
||||||
|
if(pwszLanguagesBuffer[i] == L';')
|
||||||
|
pwszLanguagesBuffer[i] = 0;//L'\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*pcchLanguagesBuffer = (szLocaleName_lens[0] + szLocaleName_lens[1] + szLocaleName_lens[2] + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WINAPI Implementation_GetGeoInfoW(
|
||||||
|
GEOID Location,
|
||||||
|
GEOTYPE GeoType,
|
||||||
|
LPWSTR lpGeoData,
|
||||||
|
int cchData,
|
||||||
|
LANGID LangId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GEOID WINAPI Implementation_GetUserGeoID(
|
||||||
|
GEOCLASS GeoClass
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0x27;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_TzSpecificLocalTimeToSystemTime(
|
||||||
|
const TIME_ZONE_INFORMATION *lpTimeZoneInformation,
|
||||||
|
const SYSTEMTIME *lpLocalTime,
|
||||||
|
LPSYSTEMTIME lpUniversalTime
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI Implementation_LCMapStringEx(
|
||||||
|
LPCWSTR lpLocaleName,
|
||||||
|
DWORD dwMapFlags,
|
||||||
|
LPCWSTR lpSrcStr,
|
||||||
|
int cchSrc,
|
||||||
|
LPWSTR lpDestStr,
|
||||||
|
int cchDest,
|
||||||
|
LPNLSVERSIONINFO lpVersionInformation,
|
||||||
|
LPVOID lpReserved,
|
||||||
|
LPARAM sortHandle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return LCMapStringW(Implementation_LocaleNameToLCID(lpLocaleName, 0), dwMapFlags, lpSrcStr, cchSrc, lpDestStr, cchDest);
|
||||||
|
}
|
||||||
45
progwrp-CSOG/locale.h
Normal file
45
progwrp-CSOG/locale.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "progwrp.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Basic implementation of Windows name-based locale API.
|
||||||
|
The "base locales" are the neutral locales, such as "en".
|
||||||
|
|
||||||
|
A separate list will contain location identifiers attached to the neutral locales.
|
||||||
|
*/
|
||||||
|
// Note: zh is really zh-Hans
|
||||||
|
|
||||||
|
#define LOCALE_NEUTRAL_LIMIT 0x94
|
||||||
|
WCHAR NeutralLangIdTbl [][4] = {{L" "}, {L"ar"}, {L"bg"}, {L"ca"}, {L"zh"}, {L"cs"}, {L"da"}, {L"de"}, {L"el"}, {L"en"}, {L"es"},
|
||||||
|
{L"fi"}, {L"fr"}, {L"he"}, {L"hu"}, {L"is"}, {L"it"}, {L"ja"}, {L"ko"}, {L"nl"}, {L"no"}, {L"pl"},
|
||||||
|
{L"pt"}, {L"rm"}, {L"ro"}, {L"ru"}, {L"hr"}, {L"sk"}, {L"sq"}, {L"sv"}, {L"th"}, {L"tr"}, {L"ur"},
|
||||||
|
{L"id"}, {L"uk"}, {L"be"}, {L"sl"}, {L"et"}, {L"lv"}, {L"lt"}, {L"tg"}, {L"fa"}, {L"vi"}, {L"hy"},
|
||||||
|
{L"az"}, {L"eu"}, {L"hsb"}, {L"mk"}, {L"st"}, {L"ts"}, {L"tn"}, {L"ve"}, {L"xh"}, {L"zu"}, {L"af"},
|
||||||
|
{L"ka"}, {L"fo"}, {L"hi"}, {L"mt"}, {L"se"}, {L"ga"}, {L"yi"}, {L"ms"}, {L"kk"}, {L"ky"}, {L"sw"},
|
||||||
|
{L"tk"}, {L"uz"}, {L"tt"}, {L"bn"}, {L"pa"}, {L"gu"}, {L"or"}, {L"ta"}, {L"te"}, {L"kn"}, {L"ml"},
|
||||||
|
{L"as"}, {L"mr"}, {L"sa"}, {L"mn"}, {L"bo"}, {L"cy"}, {L"km"}, {L"lo"}, {L"my"}, {L"gl"}, {L"kok"},
|
||||||
|
{L"mni"}, {L"sd"}, {L"syr"}, {L"si"}, {L"chr"}, {L"iu"}, {L"am"}, {L"tzm"}, {L"ks"}, {L"ne"}, {L"fy"},
|
||||||
|
{L"ps"}, {L"fil"}, {L"dv"}, {L"bin"}, {L"ff"}, {L"ha"}, {L"ibb"}, {L"yo"}, {L"quz"}, {L"nso"}, {L"ba"},
|
||||||
|
{L"lb"}, {L"kl"}, {L"ig"}, {L"kr"}, {L"om"}, {L"ti"}, {L"gn"}, {L"haw"}, {L"la"}, {L"so"}, {L"ii"},
|
||||||
|
{L"pap"}, {L"arn"}, {L" "}, {L"moh"}, {L" "}, {L"br"}, {L" "}, {L"ug"}, {L"mi"}, {L"oc"}, {L"co"},
|
||||||
|
{L"gsw"}, {L"sah"}, {L"qut"}, {L"rw"}, {L"wo"}, {L" "}, {L" "}, {L" "}, {L"prs"}, {L" "}, {L" "},
|
||||||
|
{L" "}, {L" "}, {L"gd"}, {L"ku"}, {L"quc"}};
|
||||||
|
|
||||||
|
|
||||||
|
WCHAR LocaleIdentifierTbl [][21][15] = {{L"\0"}, {L"SA", L"IQ", L"EG", L"LY", L"DZ", L"MA", L"TN", L"OM", L"YE", L"SY", L"JO", L"LB", L"KW",
|
||||||
|
L"AE", L"BH", L"QA", L'\0'}, {L"BG"}, {L"ES", L"ca-ES-valencia", L'\0'}, {L"TW", L"CN", L"SG", L"MO", L'\0'}, {L"CZ", L'\0'},
|
||||||
|
{L"DK", L'\0'}, {L"DE", L"CH", L"AT", L"LU", L"LI", L'\0'}, {L"GR"}, {L"US", L"GB", L"AU", L"CA", L"NZ", L"IE",
|
||||||
|
L"ZA", L"JM", L"029", L"BZ", L"TT", L"ZW", L"PH", L"ID", L"HK", L"IN", L"MY", L"SG", L'\0'}, {L"ES", L"MX", L'\0'},
|
||||||
|
{L"FI"}, {L"FR"}, {L"he"}, {L"hu"}, {L"is"}, {L"it"}, {L"JA"}, {L"KO"}, {L"nl"}, {L"no"}, {L"PL"},
|
||||||
|
{L"pt"}, {L"rm"}, {L"RO"}, {L"RU"}, {L"hr"}, {L"sk"}, {L"sq"}, {L"sv"}, {L"th"}, {L"tr"}, {L"ur"},
|
||||||
|
{L"id"}, {L"uk"}, {L"be"}, {L"sl"}, {L"et"}, {L"lv"}, {L"lt"}, {L"tg"}, {L"fa"}, {L"vi"}, {L"hy"},
|
||||||
|
{L"az"}, {L"eu"}, {L"hsb"}, {L"mk"}, {L"st"}, {L"ts"}, {L"tn"}, {L"ve"}, {L"xh"}, {L"zu"}, {L"af"},
|
||||||
|
{L"ka"}, {L"fo"}, {L"hi"}, {L"mt"}, {L"se"}, {L"ga"}, {L"yi"}, {L"ms"}, {L"kk"}, {L"ky"}, {L"sw"},
|
||||||
|
{L"tk"}, {L"uz"}, {L"tt"}, {L"bn"}, {L"pa"}, {L"gu"}, {L"or"}, {L"ta"}, {L"te"}, {L"kn"}, {L"ml"},
|
||||||
|
{L"as"}, {L"mr"}, {L"sa"}, {L"mn"}, {L"bo"}, {L"cy"}, {L"km"}, {L"lo"}, {L"my"}, {L"gl"}, {L"kok"},
|
||||||
|
{L"mni"}, {L"sd"}, {L"syr"}, {L"si"}, {L"chr"}, {L"iu"}, {L"am"}, {L"tzm"}, {L"ks"}, {L"ne"}, {L"fy"},
|
||||||
|
{L"ps"}, {L"fil"}, {L"dv"}, {L"bin"}, {L"ff"}, {L"ha"}, {L"ibb"}, {L"yo"}, {L"quz"}, {L"nso"}, {L"ba"},
|
||||||
|
{L"lb"}, {L"kl"}, {L"ig"}, {L"kr"}, {L"om"}, {L"ti"}, {L"gn"}, {L"haw"}, {L"la"}, {L"so"}, {L"ii"},
|
||||||
|
{L"pap"}, {L"arn"}, {L" "}, {L"moh"}, {L" "}, {L"br"}, {L" "}, {L"ug"}, {L"mi"}, {L"oc"}, {L"co"},
|
||||||
|
{L"gsw"}, {L"sah"}, {L"qut"}, {L"rw"}, {L"wo"}, {L" "}, {L" "}, {L" "}, {L"prs"}, {L" "}, {L" "},
|
||||||
|
{L" "}, {L" "}, {L"gd"}, {L"ku"}, {L"quc"}};
|
||||||
293
progwrp-CSOG/misc.c
Normal file
293
progwrp-CSOG/misc.c
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_ScriptItemize(
|
||||||
|
const WCHAR *pwcInChars,
|
||||||
|
int cInChars,
|
||||||
|
int cMaxItems,
|
||||||
|
const SCRIPT_CONTROL *psControl,
|
||||||
|
const SCRIPT_STATE *psState,
|
||||||
|
SCRIPT_ITEM *pItems,
|
||||||
|
int *pcItems
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL; // This should never be called; ScriptItemize should always be available
|
||||||
|
}
|
||||||
|
|
||||||
|
PDH_FUNCTION Implementation_PdhAddEnglishCounterW(
|
||||||
|
PDH_HQUERY hQuery,
|
||||||
|
LPCWSTR szFullCounterPath,
|
||||||
|
DWORD_PTR dwUserData,
|
||||||
|
PDH_HCOUNTER *phCounter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PdhAddCounterW(hQuery, szFullCounterPath, dwUserData, phCounter);
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID WINAPI Implementation_AddVectoredExceptionHandler(
|
||||||
|
ULONG First,
|
||||||
|
PVECTORED_EXCEPTION_HANDLER Handler
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI Implementation_RemoveVectoredExceptionHandler(
|
||||||
|
PVOID Handle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_AttachConsole(
|
||||||
|
DWORD dwProcessId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_CheckRemoteDebuggerPresent(
|
||||||
|
HANDLE hProcess,
|
||||||
|
PBOOL pbDebuggerPresent
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(pbDebuggerPresent)
|
||||||
|
{
|
||||||
|
*pbDebuggerPresent = FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE WINAPI Implementation_CreateMemoryResourceNotification(
|
||||||
|
MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_GetNativeSystemInfo(
|
||||||
|
LPSYSTEM_INFO lpSystemInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
GetSystemInfo(lpSystemInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_InitializeSListHead(
|
||||||
|
PSLIST_HEADER ListHead
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ListHead->Alignment = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PSLIST_ENTRY WINAPI Implementation_InterlockedPushEntrySList(
|
||||||
|
PSLIST_HEADER ListHead,
|
||||||
|
__drv_aliasesMem PSLIST_ENTRY ListEntry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
PSLIST_ENTRY PreviousFirst;
|
||||||
|
// PreviousFirst = ListHead->Next.Next;
|
||||||
|
|
||||||
|
if(!PreviousFirst)
|
||||||
|
{
|
||||||
|
// InterlockedCompareExchange(ListHead->Next.Next, ListEntry, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ListEntry->Next = PreviousFirst;
|
||||||
|
// InterlockedCompareExchange(ListHead->Next.Next, ListEntry, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PreviousFirst;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
PSLIST_ENTRY WINAPI Implementation_InterlockedFlushSList(
|
||||||
|
PSLIST_HEADER ListHead
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
PSLIST_ENTRY List;
|
||||||
|
|
||||||
|
List = ListHead->Next.Next;
|
||||||
|
|
||||||
|
// InterlockedCompareExchange(ListHead->Next.Next, 0, List);
|
||||||
|
|
||||||
|
return List;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
PSLIST_ENTRY WINAPI Implementation_InterlockedPopEntrySList(
|
||||||
|
PSLIST_HEADER ListHead
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI Implementation_WTSGetActiveConsoleSessionId()
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS WINAPI Implementation_RtlGetLastNtStatus()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_WTSRegisterSessionNotification(
|
||||||
|
HWND hWnd,
|
||||||
|
DWORD dwFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_WTSUnRegisterSessionNotification(
|
||||||
|
HWND hWnd
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HTHEME WINAPI Implementation_OpenThemeData(
|
||||||
|
HWND hwnd,
|
||||||
|
LPCWSTR pszClassList
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_CloseThemeData(
|
||||||
|
HTHEME hTheme
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_DrawThemeBackground(
|
||||||
|
HTHEME hTheme,
|
||||||
|
HDC hdc,
|
||||||
|
int iPartId,
|
||||||
|
int iStateId,
|
||||||
|
LPCRECT pRect,
|
||||||
|
LPCRECT pClipRect
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_GetThemeBackgroundContentRect(
|
||||||
|
HTHEME hTheme,
|
||||||
|
HDC hdc,
|
||||||
|
int iPartId,
|
||||||
|
int iStateId,
|
||||||
|
LPCRECT pBoundingRect,
|
||||||
|
LPRECT pContentRect
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_GetThemePartSize(
|
||||||
|
HTHEME hTheme,
|
||||||
|
HDC hdc,
|
||||||
|
int iPartId,
|
||||||
|
int iStateId,
|
||||||
|
LPCRECT prc,
|
||||||
|
ULONG eSize,
|
||||||
|
SIZE *psz
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_HeapSetInformation(
|
||||||
|
HANDLE HeapHandle,
|
||||||
|
HEAP_INFORMATION_CLASS HeapInformationClass,
|
||||||
|
PVOID HeapInformation,
|
||||||
|
SIZE_T HeapInformationLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_SUPPORTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_PrefetchVirtualMemory(
|
||||||
|
HANDLE hProcess,
|
||||||
|
ULONG_PTR NumberOfEntries,
|
||||||
|
PWIN32_MEMORY_RANGE_ENTRY VirtualAddresses,
|
||||||
|
ULONG Flags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_SUPPORTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetFirmwareType(
|
||||||
|
PFIRMWARE_TYPE FirmwareType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!FirmwareType)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*FirmwareType = FirmwareTypeBios;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_CryptProtectMemory(
|
||||||
|
LPVOID pDataIn,
|
||||||
|
DWORD cbDataIn,
|
||||||
|
DWORD dwFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DATA_BLOB DataIn;
|
||||||
|
DataIn.cbData = cbDataIn;
|
||||||
|
DataIn.pbData = pDataIn;
|
||||||
|
return CryptProtectData(&DataIn, NULL, NULL, NULL, NULL, 0, &DataIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_CryptUnprotectMemory(
|
||||||
|
LPVOID pDataIn,
|
||||||
|
DWORD cbDataIn,
|
||||||
|
DWORD dwFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DATA_BLOB DataIn;
|
||||||
|
DataIn.cbData = cbDataIn;
|
||||||
|
DataIn.pbData = pDataIn;
|
||||||
|
return CryptUnprotectData(&DataIn, NULL, NULL, NULL, NULL, 0, &DataIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG WINAPI Implementation_GetPackagePathByFullName(
|
||||||
|
PCWSTR packageFullName,
|
||||||
|
UINT32* pathLength,
|
||||||
|
PWSTR path
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG WINAPI Implementation_GetPackagesByPackageFamily(
|
||||||
|
PCWSTR packageFamilyName,
|
||||||
|
UINT32* count,
|
||||||
|
PWSTR* packageFullNames,
|
||||||
|
UINT32* bufferLength,
|
||||||
|
WCHAR* buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI Implementation_DiscardVirtualMemory(
|
||||||
|
PVOID VirtualAddress,
|
||||||
|
SIZE_T Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
179
progwrp-CSOG/module.c
Normal file
179
progwrp-CSOG/module.c
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include "strsafe.h"
|
||||||
|
|
||||||
|
UNICODE_STRING g_DllPath;
|
||||||
|
|
||||||
|
HMODULE WINAPI Implementation_LoadLibraryA(LPCSTR lpLibFileName)
|
||||||
|
{
|
||||||
|
return Implementation_LoadLibraryExA(lpLibFileName, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
HMODULE WINAPI Implementation_LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
|
||||||
|
{
|
||||||
|
HMODULE hModule;
|
||||||
|
ANSI_STRING DllPathA;
|
||||||
|
UNICODE_STRING DllPath;
|
||||||
|
ULONG LoadFlags;
|
||||||
|
|
||||||
|
hModule = NULL;
|
||||||
|
|
||||||
|
RtlInitAnsiString(&DllPathA, lpLibFileName);
|
||||||
|
RtlAnsiStringToUnicodeString(&DllPath, &DllPathA, TRUE);
|
||||||
|
|
||||||
|
LoadFlags = 0;
|
||||||
|
|
||||||
|
if (dwFlags & DONT_RESOLVE_DLL_REFERENCES)
|
||||||
|
LoadFlags |= DONT_RESOLVE_DLL_REFERENCES;
|
||||||
|
|
||||||
|
if (dwFlags & LOAD_LIBRARY_AS_DATAFILE)
|
||||||
|
LoadFlags |= DONT_RESOLVE_DLL_REFERENCES;
|
||||||
|
|
||||||
|
LdrLoadDll(NULL, &LoadFlags, &DllPath, &hModule);
|
||||||
|
|
||||||
|
if (hModule)
|
||||||
|
TLSInit_DllMain_ProcessAttach_Internal(hModule);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (g_strstr(lpLibFileName, "dxgi") ||
|
||||||
|
g_strstr(lpLibFileName, "bcryptprimitives") ||
|
||||||
|
g_strstr(lpLibFileName, "api-ms-win-core-fibers-l1-1-0") ||
|
||||||
|
g_strstr(lpLibFileName, "api-ms-win-core-fibers-l1-1-1"))
|
||||||
|
return GetModuleHandleA("progwrp.dll");
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&DllPath);
|
||||||
|
|
||||||
|
return hModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
HMODULE WINAPI Implementation_LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
|
||||||
|
{
|
||||||
|
UNICODE_STRING DllPath;
|
||||||
|
HMODULE hModule = 0;
|
||||||
|
ULONG LoadFlags;
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&DllPath, lpLibFileName);
|
||||||
|
|
||||||
|
LoadFlags = 0;
|
||||||
|
|
||||||
|
if (dwFlags & DONT_RESOLVE_DLL_REFERENCES)
|
||||||
|
LoadFlags |= DONT_RESOLVE_DLL_REFERENCES;
|
||||||
|
|
||||||
|
if (dwFlags & LOAD_LIBRARY_AS_DATAFILE)
|
||||||
|
LoadFlags |= DONT_RESOLVE_DLL_REFERENCES;
|
||||||
|
|
||||||
|
LdrLoadDll(NULL, &LoadFlags, &DllPath, &hModule);
|
||||||
|
|
||||||
|
if (hModule)
|
||||||
|
TLSInit_DllMain_ProcessAttach_Internal(hModule);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (g_wcsstr(lpLibFileName, L"dxgi") ||
|
||||||
|
g_wcsstr(lpLibFileName, L"bcryptprimitives") ||
|
||||||
|
g_wcsstr(lpLibFileName, L"api-ms-win-core-fibers-l1-1-0") ||
|
||||||
|
g_wcsstr(lpLibFileName, L"api-ms-win-core-fibers-l1-1-1"))
|
||||||
|
return GetModuleHandleA("progwrp.dll");
|
||||||
|
}
|
||||||
|
|
||||||
|
return hModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
HMODULE WINAPI Implementation_LoadLibraryW(LPCWSTR lpLibFileName)
|
||||||
|
{
|
||||||
|
return Implementation_LoadLibraryExW(lpLibFileName, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FARPROC WINAPI Implementation_GetProcAddress(
|
||||||
|
HMODULE hModule,
|
||||||
|
LPCSTR lpProcName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ANSI_STRING ProcNameStr;
|
||||||
|
PANSI_STRING pStr;
|
||||||
|
ULONG_PTR pfnFunc = NULL;
|
||||||
|
ULONG Ordinal = 0;
|
||||||
|
if(lpProcName > 0x10000)
|
||||||
|
{
|
||||||
|
RtlInitAnsiString(&ProcNameStr, lpProcName);
|
||||||
|
pStr = &ProcNameStr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pStr = NULL;
|
||||||
|
|
||||||
|
if(lpProcName > 0)
|
||||||
|
Ordinal = lpProcName;
|
||||||
|
}
|
||||||
|
if(LdrGetProcedureAddress(hModule, pStr, Ordinal, &pfnFunc) != 0)
|
||||||
|
{
|
||||||
|
LdrGetProcedureAddress(GetModuleHandleA("progwrp.dll"), pStr, Ordinal, &pfnFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pfnFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetModuleHandleExA(
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPCSTR lpModuleName,
|
||||||
|
HMODULE *phModule
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (phModule) {
|
||||||
|
if (lpModuleName)
|
||||||
|
*phModule = Implementation_LoadLibraryA(lpModuleName);
|
||||||
|
else
|
||||||
|
*phModule = GetModuleHandleA(NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetModuleHandleExW(
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPCWSTR lpModuleName,
|
||||||
|
HMODULE *phModule
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (phModule) {
|
||||||
|
if (lpModuleName)
|
||||||
|
*phModule = Implementation_LoadLibraryW(lpModuleName);
|
||||||
|
else
|
||||||
|
*phModule = GetModuleHandleA(NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SetDllDirectoryW(
|
||||||
|
LPCWSTR lpPathName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/* PWSTR PathStr;
|
||||||
|
DWORD PathLen;
|
||||||
|
|
||||||
|
PathLen = GetEnvironmentVariableW(L"PATH", NULL, 0);
|
||||||
|
|
||||||
|
PathStr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (PathLen + MAX_PATH + 1)*sizeof(WCHAR));
|
||||||
|
|
||||||
|
if(PathStr)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&SrwSharedCs2);
|
||||||
|
GetEnvironmentVariableW(L"PATH", PathStr, (PathLen + MAX_PATH + 1));
|
||||||
|
StringCchCatW(PathStr, (PathLen + MAX_PATH + 1), L';');
|
||||||
|
StringCchCatW(PathStr, (PathLen + MAX_PATH + 1), lpPathName);
|
||||||
|
SetEnvironmentVariableW(L"PATH", PathStr);
|
||||||
|
LeaveCriticalSection(&SrwSharedCs2);
|
||||||
|
HeapFree(GetProcessHeap(), 0, PathStr);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else*/
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
}
|
||||||
BIN
progwrp-CSOG/ntdllex.lib
Normal file
BIN
progwrp-CSOG/ntdllex.lib
Normal file
Binary file not shown.
16
progwrp-CSOG/ole32.c
Normal file
16
progwrp-CSOG/ole32.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_CoRegisterInitializeSpy(
|
||||||
|
IInitializeSpy *pSpy,
|
||||||
|
ULARGE_INTEGER *puliCookie
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_CoRevokeInitializeSpy(
|
||||||
|
ULARGE_INTEGER uliCookie
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
104
progwrp-CSOG/power.c
Normal file
104
progwrp-CSOG/power.c
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include <winuser.h>
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_PowerClearRequest(
|
||||||
|
HANDLE PowerRequest,
|
||||||
|
POWER_REQUEST_TYPE RequestType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LONG dwQuantity;
|
||||||
|
DWORD dwSize;
|
||||||
|
switch (RequestType)
|
||||||
|
{
|
||||||
|
case PowerRequestDisplayRequired:
|
||||||
|
SetThreadExecutionState(SetThreadExecutionState(ES_CONTINUOUS) & ~ES_DISPLAY_REQUIRED);
|
||||||
|
WaitForSingleObject(MutexRegistry, INFINITE);
|
||||||
|
RegQueryValueExA(g_hkProgwrp, "NumberActiveWakeLocks", NULL, NULL, &dwQuantity, &dwSize);
|
||||||
|
--dwQuantity;
|
||||||
|
if (dwQuantity < 0)
|
||||||
|
dwQuantity = 0;
|
||||||
|
RegSetValueExA(g_hkProgwrp, "NumberActiveWakeLocks", NULL, REG_DWORD, &dwQuantity, 4);
|
||||||
|
if(!dwQuantity)
|
||||||
|
Implementation_SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, 1, NULL, SPIF_SENDCHANGE);
|
||||||
|
ReleaseMutex(MutexRegistry);
|
||||||
|
return TRUE;
|
||||||
|
case PowerRequestSystemRequired:
|
||||||
|
SetThreadExecutionState(SetThreadExecutionState(ES_CONTINUOUS) & ~ES_SYSTEM_REQUIRED);
|
||||||
|
return TRUE;
|
||||||
|
case PowerRequestAwayModeRequired:
|
||||||
|
SetThreadExecutionState(SetThreadExecutionState(ES_CONTINUOUS) & ~ES_AWAYMODE_REQUIRED);
|
||||||
|
return TRUE;
|
||||||
|
case PowerRequestExecutionRequired:
|
||||||
|
SetThreadExecutionState(SetThreadExecutionState(ES_CONTINUOUS) & ~ES_SYSTEM_REQUIRED);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
HANDLE WINAPI Implementation_PowerCreateRequest(
|
||||||
|
PREASON_CONTEXT Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DWORD dwQuantity, dwSize;
|
||||||
|
WaitForSingleObject(MutexRegistry, INFINITE);
|
||||||
|
|
||||||
|
if(!g_hkProgwrp)
|
||||||
|
RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Progwrp", &g_hkProgwrp);
|
||||||
|
if (RegQueryValueExA(g_hkProgwrp, "NumberActiveWakeLocks", NULL, NULL, &dwQuantity, &dwSize) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
dwQuantity = 0;
|
||||||
|
RegSetValueExA(g_hkProgwrp, "NumberActiveWakeLocks", 0, REG_DWORD, &dwQuantity, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReleaseMutex(MutexRegistry);
|
||||||
|
return CreateSemaphoreA(NULL, 0, 1, NULL);
|
||||||
|
}
|
||||||
|
BOOL WINAPI Implementation_PowerSetRequest(
|
||||||
|
HANDLE PowerRequest,
|
||||||
|
POWER_REQUEST_TYPE RequestType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LONG dwQuantity;
|
||||||
|
DWORD dwSize;
|
||||||
|
ULONG PreviousRequest;
|
||||||
|
switch (RequestType)
|
||||||
|
{
|
||||||
|
case PowerRequestDisplayRequired:
|
||||||
|
PreviousRequest = SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
|
||||||
|
// MS documentation says that this function has no effect on screensavers, while
|
||||||
|
// some GLFW code and issues claim otherwise, but that code has mostly Windows 10 in mind.
|
||||||
|
// On XP, this was insufficient. So I am also calling SystemParametersInfo to
|
||||||
|
// disable the screensaver.
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | PreviousRequest);
|
||||||
|
WaitForSingleObject(MutexRegistry, INFINITE);
|
||||||
|
RegQueryValueExA(g_hkProgwrp, "NumberActiveWakeLocks", NULL, NULL, &dwQuantity, &dwSize);
|
||||||
|
++dwQuantity;
|
||||||
|
RegSetValueExA(g_hkProgwrp, "NumberActiveWakeLocks", NULL, REG_DWORD, &dwQuantity, 4);
|
||||||
|
if (dwQuantity > 0)
|
||||||
|
Implementation_SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, 0, NULL, SPIF_SENDCHANGE);
|
||||||
|
ReleaseMutex(MutexRegistry);
|
||||||
|
return TRUE;
|
||||||
|
case PowerRequestSystemRequired:
|
||||||
|
PreviousRequest = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | PreviousRequest);
|
||||||
|
return TRUE;
|
||||||
|
case PowerRequestAwayModeRequired:
|
||||||
|
PreviousRequest = SetThreadExecutionState(ES_CONTINUOUS | ES_AWAYMODE_REQUIRED);
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS | ES_AWAYMODE_REQUIRED | PreviousRequest);
|
||||||
|
return TRUE;
|
||||||
|
case PowerRequestExecutionRequired:
|
||||||
|
PreviousRequest = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | PreviousRequest);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
POWER_PLATFORM_ROLE WINAPI Implementation_PowerDeterminePlatformRole()
|
||||||
|
// This function reads the registry to determine
|
||||||
|
{
|
||||||
|
return PlatformRoleDesktop;
|
||||||
|
}
|
||||||
415
progwrp-CSOG/processor.c
Normal file
415
progwrp-CSOG/processor.c
Normal file
@@ -0,0 +1,415 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include <intrin.h>
|
||||||
|
|
||||||
|
PROCESSOR_CACHE_TYPE WINAPI DetermineCacheType(BYTE Descriptor)
|
||||||
|
{
|
||||||
|
if((Descriptor >= 0x6 && Descriptor <= 0x9)
|
||||||
|
|| (Descriptor == 0x30))
|
||||||
|
{
|
||||||
|
return CacheInstruction; // Instruction cache
|
||||||
|
}
|
||||||
|
if((Descriptor == 0xA)
|
||||||
|
||(Descriptor >= 0xC && Descriptor <= 0xE)
|
||||||
|
||(Descriptor == 0x2C)
|
||||||
|
||(Descriptor == 0x60)
|
||||||
|
||(Descriptor >= 0x66 && Descriptor <= 0x68))
|
||||||
|
{
|
||||||
|
return CacheData;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CacheUnified; // no trace caches are in scope of the Lx cache descriptors
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE WINAPI DetermineCacheAssociativity(BYTE Descriptor)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WORD WINAPI DetermineCacheLineSize(BYTE Descriptor)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI DetermineCacheSize(BYTE Descriptor)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE WINAPI DetermineCacheLevel(BYTE Descriptor)
|
||||||
|
{
|
||||||
|
if((Descriptor >= 0x6 && Descriptor <= 0xA)
|
||||||
|
||(Descriptor >= 0xC && Descriptor <= 0xE)
|
||||||
|
||(Descriptor >= 0x2C && Descriptor <= 0x30)
|
||||||
|
||(Descriptor == 0x60)
|
||||||
|
||(Descriptor >= 0x66 && Descriptor <= 0x68))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if((Descriptor >= 0x1D && Descriptor <= 0x21)
|
||||||
|
||(Descriptor == 0x24)
|
||||||
|
||(Descriptor >= 0x41 && Descriptor <= 0x45)
|
||||||
|
||(Descriptor == 0x48) || (Descriptor == 0x4E)
|
||||||
|
||(Descriptor >= 0x78 && Descriptor <= 0x87))
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((Descriptor >= 0x22 && Descriptor <= 0x23)
|
||||||
|
||(Descriptor >= 0x25 && Descriptor <= 0x29)
|
||||||
|
||(Descriptor >= 0x46 && Descriptor <= 0x47)
|
||||||
|
||(Descriptor >= 0x49 && Descriptor <= 0x4D)
|
||||||
|
||(Descriptor >= 0xD0 && Descriptor <= 0xEC))
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE WINAPI BuildCacheDescriptors(int * cpuid_val, PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer)
|
||||||
|
/*
|
||||||
|
This function is intended to serve two purposes:
|
||||||
|
-identify the number of non-TLB caches available
|
||||||
|
-build the cache information based on a legacy Intel/Centaur cpuid leaf (AMD will come later)
|
||||||
|
|
||||||
|
The function returns the number of caches reported by cpuid.
|
||||||
|
However, if Buffer is not NULL, it can also modify the structs as follows:
|
||||||
|
Buffer[0] is the L1 cache struct
|
||||||
|
Buffer[1] is the L2 cache struct
|
||||||
|
Buffer[3] is the L3 cache struct
|
||||||
|
|
||||||
|
The initial call of GetLogicalProcessorInformationEx will have calculated the buffer size needed
|
||||||
|
to get all three cache structs, so this should work well.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
BYTE CacheCount, Encoding, LastCacheLvl;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if((cpuid_val[i] << 31) & 1)
|
||||||
|
{
|
||||||
|
Encoding = cpuid_val[i] & 0xFF;
|
||||||
|
|
||||||
|
LastCacheLvl = DetermineCacheLevel(Encoding);
|
||||||
|
|
||||||
|
if(LastCacheLvl)
|
||||||
|
++CacheCount;
|
||||||
|
|
||||||
|
if(Buffer && LastCacheLvl)
|
||||||
|
{
|
||||||
|
Buffer->Relationship = RelationCache;
|
||||||
|
Buffer->Cache.Level = LastCacheLvl;
|
||||||
|
Buffer->Cache.Associativity = DetermineCacheAssociativity(Encoding);
|
||||||
|
Buffer->Cache.CacheSize = DetermineCacheSize(Encoding);
|
||||||
|
Buffer->Cache.Level = DetermineCacheLevel(Encoding);
|
||||||
|
Buffer->Cache.LineSize = DetermineCacheLineSize(Encoding);
|
||||||
|
Buffer->Cache.Type = DetermineCacheType(Encoding);
|
||||||
|
Buffer->Size = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
++Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
Encoding = (cpuid_val[i] >> 8) & 0xFF;
|
||||||
|
|
||||||
|
LastCacheLvl = DetermineCacheLevel(Encoding);
|
||||||
|
|
||||||
|
if(LastCacheLvl)
|
||||||
|
++CacheCount;
|
||||||
|
|
||||||
|
if(Buffer && LastCacheLvl)
|
||||||
|
{
|
||||||
|
Buffer->Relationship = RelationCache;
|
||||||
|
Buffer->Cache.Level = LastCacheLvl;
|
||||||
|
Buffer->Cache.Associativity = DetermineCacheAssociativity(Encoding);
|
||||||
|
Buffer->Cache.CacheSize = DetermineCacheSize(Encoding);
|
||||||
|
Buffer->Cache.Level = DetermineCacheLevel(Encoding);
|
||||||
|
Buffer->Cache.LineSize = DetermineCacheLineSize(Encoding);
|
||||||
|
Buffer->Cache.Type = DetermineCacheType(Encoding);
|
||||||
|
Buffer->Size = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
++Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
Encoding = (cpuid_val[i] >> 16) & 0xFF;
|
||||||
|
|
||||||
|
LastCacheLvl = DetermineCacheLevel(Encoding);
|
||||||
|
|
||||||
|
if(LastCacheLvl)
|
||||||
|
++CacheCount;
|
||||||
|
|
||||||
|
if(Buffer && LastCacheLvl)
|
||||||
|
{
|
||||||
|
Buffer->Relationship = RelationCache;
|
||||||
|
Buffer->Cache.Level = LastCacheLvl;
|
||||||
|
Buffer->Cache.Associativity = DetermineCacheAssociativity(Encoding);
|
||||||
|
Buffer->Cache.CacheSize = DetermineCacheSize(Encoding);
|
||||||
|
Buffer->Cache.Level = DetermineCacheLevel(Encoding);
|
||||||
|
Buffer->Cache.LineSize = DetermineCacheLineSize(Encoding);
|
||||||
|
Buffer->Cache.Type = DetermineCacheType(Encoding);
|
||||||
|
Buffer->Size = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
++Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
Encoding = (cpuid_val[i] >> 24) & 0xFF;
|
||||||
|
|
||||||
|
LastCacheLvl = DetermineCacheLevel(Encoding);
|
||||||
|
|
||||||
|
if(LastCacheLvl)
|
||||||
|
++CacheCount;
|
||||||
|
|
||||||
|
if(Buffer && LastCacheLvl)
|
||||||
|
{
|
||||||
|
Buffer->Relationship = RelationCache;
|
||||||
|
Buffer->Cache.Level = LastCacheLvl;
|
||||||
|
Buffer->Cache.Associativity = DetermineCacheAssociativity(Encoding);
|
||||||
|
Buffer->Cache.CacheSize = DetermineCacheSize(Encoding);
|
||||||
|
Buffer->Cache.Level = DetermineCacheLevel(Encoding);
|
||||||
|
Buffer->Cache.LineSize = DetermineCacheLineSize(Encoding);
|
||||||
|
Buffer->Cache.Type = DetermineCacheType(Encoding);
|
||||||
|
Buffer->Size = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
++Buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return CacheCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
WORD WINAPI Implementation_GetMaximumProcessorGroupCount()
|
||||||
|
// Technically only one processor group until Windows 7.
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
WORD WINAPI Implementation_GetMaximumProcessorCount()
|
||||||
|
// Technically only one processor group until Windows 7.
|
||||||
|
{
|
||||||
|
#ifdef _AMD64_
|
||||||
|
return 64;
|
||||||
|
#else
|
||||||
|
return 32;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetLogicalProcessorInformationEx(
|
||||||
|
LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType,
|
||||||
|
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer,
|
||||||
|
PDWORD ReturnedLength
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
While the predecessor function provides a good proportion of the information in this function, this function
|
||||||
|
is not available to all operating systems targetted by this function.
|
||||||
|
|
||||||
|
So we can't go into kernel mode and only take advantage of existing user mode functions and cpuid (which will
|
||||||
|
be called on simultaneously on all CPUs via a pseudo-IPI call - well, my user mode version of it)
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Iterator;
|
||||||
|
SYSTEM_INFO sysinfo;
|
||||||
|
DWORD RequiredLength = 0, i, NumaNodeNumber, ProcessorPackages;
|
||||||
|
int cpuid_ret [4] = {0, 0, 0, 0};
|
||||||
|
|
||||||
|
#ifndef RelationProcessorModule
|
||||||
|
#define RelationProcessorModule ((LOGICAL_PROCESSOR_RELATIONSHIP)7)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!ReturnedLength || ((RelationshipType < RelationProcessorCore || RelationshipType > RelationProcessorModule) && RelationshipType != RelationAll))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlZeroMemory(&sysinfo, sizeof(SYSTEM_INFO));
|
||||||
|
|
||||||
|
GetSystemInfo(&sysinfo);
|
||||||
|
|
||||||
|
if(RelationshipType == RelationProcessorCore || RelationshipType == RelationAll)
|
||||||
|
/*
|
||||||
|
One instance of the struct for each logical processor, but divide by two if
|
||||||
|
CPUID indicates that HTT is enabled.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
__cpuid(cpuid_ret, 1);
|
||||||
|
|
||||||
|
if(cpuid_ret[3] & (1 << 28))
|
||||||
|
{
|
||||||
|
RequiredLength += (sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) * sysinfo.dwNumberOfProcessors) / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RequiredLength += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) * sysinfo.dwNumberOfProcessors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RelationshipType == RelationNumaNode || RelationshipType == RelationAll)
|
||||||
|
/*
|
||||||
|
One instance of the struct for each NUMA node in use.
|
||||||
|
Windows doesn't seem to recognize NUMA in its user-mode APIs until XP so
|
||||||
|
we'd have to assume a single node until then.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
typedef BOOL (WINAPI* NumaNodeMaxNum)(PULONG);
|
||||||
|
NumaNodeMaxNum GetNumaHighestNodeVal = (NumaNodeMaxNum)Implementation_GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetNumaHighestNodeNumber");
|
||||||
|
if(GetNumaHighestNodeVal)
|
||||||
|
{
|
||||||
|
GetNumaHighestNodeVal(&NumaNodeNumber);
|
||||||
|
RequiredLength += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) * (NumaNodeNumber + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RequiredLength += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
NumaNodeNumber = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RelationshipType == RelationCache || RelationshipType == RelationAll)
|
||||||
|
/*
|
||||||
|
One instance of the struct for each cache in use.
|
||||||
|
There doesn't seem to be a unified way to check cache between
|
||||||
|
Intel and AMD (Centaur seems to lean towards Intel) so for Intel
|
||||||
|
I will use eax 0x2 leaf. Not sure about which one I'll use for AMD.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
__cpuid(cpuid_ret, 2);
|
||||||
|
|
||||||
|
RequiredLength += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) * BuildCacheDescriptors(cpuid_ret, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RelationshipType == RelationProcessorPackage || RelationshipType == RelationAll)
|
||||||
|
/*
|
||||||
|
One instance of the struct for each socket in use.
|
||||||
|
We'll use leaf eax = 0x1 to determine the number of logical processors in a package.
|
||||||
|
It will be divided by the number of available processors as provided by the system
|
||||||
|
to determine the number of processors that is available. This should work very well
|
||||||
|
to indicate not only what is in the system, but what is actually in use.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
__cpuid(cpuid_ret, 1);
|
||||||
|
|
||||||
|
if(cpuid_ret[0] >> 16 & 0xFF)
|
||||||
|
ProcessorPackages = (cpuid_ret[0] >> 16 & 0xFF) / sysinfo.dwNumberOfProcessors;
|
||||||
|
else
|
||||||
|
ProcessorPackages = 1;
|
||||||
|
RequiredLength += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) * ProcessorPackages;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RelationshipType == RelationGroup || RelationshipType == RelationAll)
|
||||||
|
/*
|
||||||
|
One instance of the struct as there is only one group.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
RequiredLength += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*ReturnedLength < RequiredLength)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ReturnedLength = RequiredLength;
|
||||||
|
|
||||||
|
if(!Buffer)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator = Buffer;
|
||||||
|
|
||||||
|
if(RelationshipType == RelationProcessorCore || RelationshipType == RelationAll)
|
||||||
|
{
|
||||||
|
__cpuid(cpuid_ret, 1);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
if(cpuid_ret[3] & (1 << 28))
|
||||||
|
{
|
||||||
|
while(i < sysinfo.dwNumberOfProcessors / 2)
|
||||||
|
{
|
||||||
|
Iterator->Relationship = RelationProcessorCore;
|
||||||
|
Iterator->Processor.Flags = LTP_PC_SMT;
|
||||||
|
Iterator->Processor.EfficiencyClass = 0;
|
||||||
|
Iterator->Size = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
|
||||||
|
++i;
|
||||||
|
++Iterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(i < sysinfo.dwNumberOfProcessors)
|
||||||
|
{
|
||||||
|
Iterator->Relationship = RelationProcessorCore;
|
||||||
|
Iterator->Processor.Flags = 0;
|
||||||
|
Iterator->Processor.EfficiencyClass = 0;
|
||||||
|
Iterator->Size = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
|
||||||
|
++i;
|
||||||
|
++Iterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RelationshipType == RelationProcessorPackage || RelationshipType == RelationAll)
|
||||||
|
{
|
||||||
|
for(i = 0; i < ProcessorPackages; i++)
|
||||||
|
{
|
||||||
|
Iterator[i].Relationship = RelationProcessorPackage;
|
||||||
|
Iterator[i].Processor.EfficiencyClass = 0;
|
||||||
|
Iterator[i].Processor.GroupCount = 0;
|
||||||
|
Iterator[i].Processor.Flags = 0;
|
||||||
|
Iterator[i].Processor.GroupMask[0].Mask = sysinfo.dwActiveProcessorMask;
|
||||||
|
Iterator[i].Processor.GroupMask[0].Group = 0;
|
||||||
|
Iterator->Size = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
++Iterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RelationshipType == RelationCache || RelationshipType == RelationAll)
|
||||||
|
{
|
||||||
|
BuildCacheDescriptors(cpuid_ret, Iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RelationshipType == RelationGroup || RelationshipType == RelationAll)
|
||||||
|
{
|
||||||
|
Iterator->Relationship = RelationGroup;
|
||||||
|
Iterator->Group.MaximumGroupCount = 1;
|
||||||
|
Iterator->Group.ActiveGroupCount = 1;
|
||||||
|
Iterator->Group.GroupInfo[0].MaximumProcessorCount = sysinfo.dwNumberOfProcessors;
|
||||||
|
Iterator->Group.GroupInfo[0].ActiveProcessorCount = sysinfo.dwNumberOfProcessors;
|
||||||
|
Iterator->Group.GroupInfo[0].ActiveProcessorMask = sysinfo.dwActiveProcessorMask;
|
||||||
|
Iterator->Size = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetThreadGroupAffinity(
|
||||||
|
HANDLE hThread,
|
||||||
|
PGROUP_AFFINITY GroupAffinity
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!GroupAffinity || GroupAffinity->Group)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
GroupAffinity->Mask = SetThreadAffinityMask(hThread, 0);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI Implementation_GetCurrentProcessorNumber()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetLogicalProcessorInformation(
|
||||||
|
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer,
|
||||||
|
PDWORD ReturnedLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
557
progwrp-CSOG/procthread.c
Normal file
557
progwrp-CSOG/procthread.c
Normal file
@@ -0,0 +1,557 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
#ifdef _M_IX86
|
||||||
|
|
||||||
|
_allmul()
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
pop ebx ; assembler was adding push ebx by default, so adding this
|
||||||
|
mov eax, [esp+8]
|
||||||
|
mov ecx, [esp+16]
|
||||||
|
or ecx, eax
|
||||||
|
mov ecx, [esp+12]
|
||||||
|
jnz hard
|
||||||
|
mov eax, [esp+4]
|
||||||
|
mul ecx
|
||||||
|
ret 16
|
||||||
|
hard:
|
||||||
|
push ebx
|
||||||
|
mul ecx
|
||||||
|
mov ebx, eax
|
||||||
|
mov eax, [esp+8]
|
||||||
|
mul dword ptr [esp+20]
|
||||||
|
add ebx, eax
|
||||||
|
mov eax, [esp+8]
|
||||||
|
mul ecx
|
||||||
|
add edx, ebx
|
||||||
|
pop ebx
|
||||||
|
ret 16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_aulldiv()
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
pop ebx
|
||||||
|
pop esi
|
||||||
|
push ebx
|
||||||
|
push esi
|
||||||
|
mov eax, [esp+24]
|
||||||
|
or eax, eax
|
||||||
|
jnz hard
|
||||||
|
mov ecx, [esp+20]
|
||||||
|
mov eax, [esp+16]
|
||||||
|
xor edx, edx
|
||||||
|
div ecx
|
||||||
|
mov ebx, eax
|
||||||
|
mov eax, [esp+12]
|
||||||
|
div ecx
|
||||||
|
mov edx, ebx
|
||||||
|
jmp result
|
||||||
|
hard:
|
||||||
|
mov ecx, eax
|
||||||
|
mov ebx, [esp+20]
|
||||||
|
mov edx, [esp+16]
|
||||||
|
mov eax, [esp+12]
|
||||||
|
loop_shr:
|
||||||
|
shr ecx, 1
|
||||||
|
rcr ebx, 1
|
||||||
|
shr edx, 1
|
||||||
|
rcr eax, 1
|
||||||
|
or ecx, ecx
|
||||||
|
jnz loop_shr
|
||||||
|
div ebx
|
||||||
|
mov esi, eax
|
||||||
|
mul dword ptr [esp+24]
|
||||||
|
mov ecx, eax
|
||||||
|
mov eax, [esp+20]
|
||||||
|
mul esi
|
||||||
|
add edx, ecx
|
||||||
|
jb decrement
|
||||||
|
cmp edx, [esp+10]
|
||||||
|
ja decrement
|
||||||
|
jb xor_edx
|
||||||
|
cmp eax, [esp+12]
|
||||||
|
jbe xor_edx
|
||||||
|
decrement:
|
||||||
|
dec esi
|
||||||
|
xor_edx:
|
||||||
|
xor edx, edx
|
||||||
|
mov eax, esi
|
||||||
|
result:
|
||||||
|
pop esi
|
||||||
|
pop ebx
|
||||||
|
ret 16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE WINAPI Implementation_CreateRemoteThreadEx(
|
||||||
|
HANDLE hProcess,
|
||||||
|
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||||
|
SIZE_T dwStackSize,
|
||||||
|
LPTHREAD_START_ROUTINE lpStartAddress,
|
||||||
|
LPVOID lpParameter,
|
||||||
|
DWORD dwCreationFlags,
|
||||||
|
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList,
|
||||||
|
LPDWORD lpThreadId
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
Only difference is the use of thread attributes. Not applicable in XP and below...
|
||||||
|
I could add support for a few of the attributes (ideal processor, inherited handles,
|
||||||
|
nested job objects> - unless I can attach them to generic handles).
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
return CreateRemoteThread(hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter,
|
||||||
|
dwCreationFlags, lpThreadId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flags to indicate if an attribute is present in the list.
|
||||||
|
// I believe these are used so that Windows doesn't have to scan the complete list to see if an attribute is present.
|
||||||
|
#define PARENT_PROCESS (1 << ProcThreadAttributeParentProcess)
|
||||||
|
#define EXTENDED_FLAGS (1 << ProcThreadAttributeExtendedFlags)
|
||||||
|
#define HANDLE_LIST (1 << ProcThreadAttributeHandleList)
|
||||||
|
#define GROUP_AFFINITY (1 << ProcThreadAttributeGroupAffinity)
|
||||||
|
#define PREFERRED_NODE (1 << ProcThreadAttributePreferredNode)
|
||||||
|
#define IDEAL_PROCESSOR (1 << ProcThreadAttributeIdealProcessor)
|
||||||
|
#define UMS_THREAD (1 << ProcThreadAttributeUmsThread)
|
||||||
|
#define MITIGATION_POLICY (1 << ProcThreadAttributeMitigationPolicy)
|
||||||
|
|
||||||
|
// This structure stores the value for each attribute
|
||||||
|
typedef struct _PROC_THREAD_ATTRIBUTE_ENTRY
|
||||||
|
{
|
||||||
|
DWORD_PTR Attribute; // PROC_THREAD_ATTRIBUTE_xxx
|
||||||
|
SIZE_T cbSize;
|
||||||
|
PVOID lpValue;
|
||||||
|
} PROC_THREAD_ATTRIBUTE_ENTRY, *LPPROC_THREAD_ATTRIBUTE_ENTRY;
|
||||||
|
|
||||||
|
// This structure contains a list of attributes that have been added using UpdateProcThreadAttribute
|
||||||
|
typedef struct _PROC_THREAD_ATTRIBUTE_LIST
|
||||||
|
{
|
||||||
|
DWORD dwFlags;
|
||||||
|
ULONG Size;
|
||||||
|
ULONG Count;
|
||||||
|
ULONG Reserved;
|
||||||
|
PULONG Unknown;
|
||||||
|
PROC_THREAD_ATTRIBUTE_ENTRY Entries[ANYSIZE_ARRAY];
|
||||||
|
} PROC_THREAD_ATTRIBUTE_LIST, *LPPROC_THREAD_ATTRIBUTE_LIST;
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_InitializeProcThreadAttributeList(
|
||||||
|
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList,
|
||||||
|
DWORD dwAttributeCount,
|
||||||
|
DWORD dwFlags,
|
||||||
|
PSIZE_T lpSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!lpSize)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*lpSize = sizeof(PROC_THREAD_ATTRIBUTE_LIST)+ (sizeof(PROC_THREAD_ATTRIBUTE_ENTRY) * dwAttributeCount);
|
||||||
|
|
||||||
|
if(!lpAttributeList)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lpAttributeList->Count = dwAttributeCount;
|
||||||
|
lpAttributeList->Size = *lpSize;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_UpdateProcThreadAttribute(
|
||||||
|
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList,
|
||||||
|
DWORD dwFlags,
|
||||||
|
DWORD_PTR Attribute,
|
||||||
|
PVOID lpValue,
|
||||||
|
SIZE_T cbSize,
|
||||||
|
PVOID lpPreviousValue,
|
||||||
|
PSIZE_T lpReturnSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(dwFlags || !lpAttributeList)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(Attribute)
|
||||||
|
{
|
||||||
|
case PROC_THREAD_ATTRIBUTE_HANDLE_LIST:
|
||||||
|
lpAttributeList->Entries[0].Attribute = Attribute;
|
||||||
|
lpAttributeList->dwFlags |= 1;
|
||||||
|
lpAttributeList->Entries[0].lpValue = lpValue;
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_DeleteProcThreadAttributeList(
|
||||||
|
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList
|
||||||
|
)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_QueryFullProcessImageNameW(
|
||||||
|
HANDLE hProcess,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPWSTR lpExeName,
|
||||||
|
PDWORD lpdwSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_QueryFullProcessImageNameA(
|
||||||
|
HANDLE hProcess,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPSTR lpExeName,
|
||||||
|
PDWORD lpdwSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_QueryThreadCycleTime(
|
||||||
|
HANDLE ThreadHandle,
|
||||||
|
PULONG64 CycleTime
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER QpcFirst;
|
||||||
|
LARGE_INTEGER QpcLast;
|
||||||
|
LARGE_INTEGER CtFreq;
|
||||||
|
ULONG64 TscFirst;
|
||||||
|
ULONG64 TscLast;
|
||||||
|
ULONG64 TscFreq;
|
||||||
|
ULONG64 Delta;
|
||||||
|
ULONG64 Dividend;
|
||||||
|
DWORD OldTp;
|
||||||
|
ULONG64 CreationTime, ExitTime, KernelTime, UserTime;
|
||||||
|
|
||||||
|
if(!CycleTime)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
OldTp = GetThreadPriority(GetCurrentThread());
|
||||||
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
|
||||||
|
|
||||||
|
TscFirst = __rdtsc();
|
||||||
|
QueryPerformanceCounter(&QpcFirst);
|
||||||
|
|
||||||
|
TscLast = __rdtsc();
|
||||||
|
QueryPerformanceCounter(&QpcLast);
|
||||||
|
|
||||||
|
SetThreadPriority(GetCurrentThread(), OldTp);
|
||||||
|
|
||||||
|
QueryPerformanceFrequency(&CtFreq);
|
||||||
|
|
||||||
|
if(!CtFreq.QuadPart)
|
||||||
|
CtFreq.QuadPart = 1000;
|
||||||
|
|
||||||
|
Delta = QpcLast.QuadPart - QpcFirst.QuadPart;
|
||||||
|
|
||||||
|
Dividend = Delta / CtFreq.QuadPart;
|
||||||
|
|
||||||
|
if(!Dividend)
|
||||||
|
Dividend = 1;
|
||||||
|
|
||||||
|
TscFreq = (TscLast - TscFirst) / Dividend;
|
||||||
|
|
||||||
|
if(!GetThreadTimes(ThreadHandle, &CreationTime, &ExitTime, &KernelTime, &UserTime))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
*CycleTime = ((KernelTime + UserTime) / 10000000) * TscFreq;
|
||||||
|
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_QueryProcessCycleTime(
|
||||||
|
HANDLE ProcessHandle,
|
||||||
|
PULONG64 CycleTime
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER QpcFirst;
|
||||||
|
LARGE_INTEGER QpcLast;
|
||||||
|
LARGE_INTEGER CtFreq;
|
||||||
|
ULONG64 TscFirst;
|
||||||
|
ULONG64 TscLast;
|
||||||
|
ULONG64 TscFreq;
|
||||||
|
ULONG64 Delta;
|
||||||
|
ULONG64 Dividend;
|
||||||
|
DWORD OldTp;
|
||||||
|
ULONG64 CreationTime, ExitTime, KernelTime, UserTime;
|
||||||
|
|
||||||
|
if(!CycleTime)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
OldTp = GetThreadPriority(GetCurrentThread());
|
||||||
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
|
||||||
|
|
||||||
|
TscFirst = __rdtsc();
|
||||||
|
QueryPerformanceCounter(&QpcFirst);
|
||||||
|
|
||||||
|
TscLast = __rdtsc();
|
||||||
|
QueryPerformanceCounter(&QpcLast);
|
||||||
|
|
||||||
|
SetThreadPriority(GetCurrentThread(), OldTp);
|
||||||
|
|
||||||
|
QueryPerformanceFrequency(&CtFreq);
|
||||||
|
|
||||||
|
if(!CtFreq.QuadPart)
|
||||||
|
CtFreq.QuadPart = 1000;
|
||||||
|
|
||||||
|
Delta = QpcLast.QuadPart - QpcFirst.QuadPart;
|
||||||
|
|
||||||
|
Dividend = Delta / CtFreq.QuadPart;
|
||||||
|
|
||||||
|
if(!Dividend)
|
||||||
|
Dividend = 1;
|
||||||
|
|
||||||
|
TscFreq = (TscLast - TscFirst) / Dividend;
|
||||||
|
|
||||||
|
if(!GetProcessTimes(ProcessHandle, &CreationTime, &ExitTime, &KernelTime, &UserTime))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
*CycleTime = ((KernelTime + UserTime) / 10000000) * TscFreq;
|
||||||
|
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetNamedPipeServerProcessId(
|
||||||
|
HANDLE Pipe,
|
||||||
|
PULONG ServerProcessId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetNamedPipeClientProcessId(
|
||||||
|
HANDLE Pipe,
|
||||||
|
PULONG ClientProcessId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_Wow64GetThreadContext(
|
||||||
|
HANDLE hThread,
|
||||||
|
PWOW64_CONTEXT lpContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ThreadBasicInformation 0
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _THREAD_BASIC_INFORMATION {
|
||||||
|
NTSTATUS ExitStatus;
|
||||||
|
PVOID TebBaseAddress;
|
||||||
|
CLIENT_ID ClientId;
|
||||||
|
KAFFINITY AffinityMask;
|
||||||
|
KPRIORITY Priority;
|
||||||
|
KPRIORITY BasePriority;
|
||||||
|
} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
|
||||||
|
DWORD WINAPI Implementation_GetThreadId(
|
||||||
|
HANDLE Thread
|
||||||
|
)
|
||||||
|
{
|
||||||
|
THREAD_BASIC_INFORMATION tbi;
|
||||||
|
NTSTATUS Status = NtQueryInformationThread(Thread, ThreadBasicInformation, (PVOID)&tbi, sizeof(THREAD_BASIC_INFORMATION), NULL);
|
||||||
|
|
||||||
|
if(Status)
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (DWORD)tbi.ClientId.UniqueThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _M_IX86
|
||||||
|
|
||||||
|
NTSTATUS NTAPI NtSetInformationProcess(HANDLE ProcessHandle, ULONG ProcessInfoClass, PVOID ProcessInformation, ULONG InfoLength);
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SetProcessDEPPolicy(DWORD dwFlags)
|
||||||
|
{
|
||||||
|
DWORD dwFlagscpy;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
dwFlagscpy = dwFlags;
|
||||||
|
if ( (dwFlags & 0xFFFFFFFC) != 0 ) //check that only bits 0 and 1 are set
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if ( (dwFlags & PROCESS_DEP_ENABLE) != 0 )
|
||||||
|
{
|
||||||
|
dwFlags = 9;
|
||||||
|
if ( (dwFlagscpy & PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION) != 0 )
|
||||||
|
dwFlags = 13;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( (dwFlags & PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION) != 0 )
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(STATUS_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
dwFlags = 2; // Set DEP to be disabled for the process
|
||||||
|
}
|
||||||
|
Status = NtSetInformationProcess((HANDLE)-1, 0x22, (PVOID)&dwFlags,(ULONG) 4); //class ProcessExecuteFlags
|
||||||
|
if ( Status < 0 )
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SetProcessDEPPolicy(DWORD dwFlags)
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(0xC00000BB);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DWORD WINAPI Implementation_GetProcessId(
|
||||||
|
HANDLE Process
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PROCESS_BASIC_INFORMATION pbi;
|
||||||
|
NTSTATUS Status = NtQueryInformationProcess(Process, ProcessBasicInformation, (PVOID)&pbi, sizeof(PROCESS_BASIC_INFORMATION), NULL);
|
||||||
|
|
||||||
|
if(Status)
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (DWORD)pbi.UniqueProcessId;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetProcessHandleCount(
|
||||||
|
HANDLE hProcess,
|
||||||
|
PDWORD pdwHandleCount
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG ulProcessHandleCount;
|
||||||
|
|
||||||
|
if(!pdwHandleCount)
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS Status = NtQueryInformationProcess(hProcess, 20, (PVOID)&ulProcessHandleCount, sizeof(ULONG), NULL);
|
||||||
|
|
||||||
|
if(Status)
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pdwHandleCount = ulProcessHandleCount;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_IsProcessInJob(
|
||||||
|
HANDLE ProcessHandle,
|
||||||
|
HANDLE JobHandle,
|
||||||
|
PBOOL Result
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
DWORD dwProcessId;
|
||||||
|
PJOBOBJECT_BASIC_PROCESS_ID_LIST jbpil;
|
||||||
|
JOBOBJECT_BASIC_ACCOUNTING_INFORMATION jbai;
|
||||||
|
if(!Result || !QueryInformationJobObject(JobHandle, JobObjectBasicAccountingInformation, &jbai, sizeof(JOBOBJECT_BASIC_ACCOUNTING_INFORMATION), NULL))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
*Result = FALSE;
|
||||||
|
|
||||||
|
jbpil = (PJOBOBJECT_BASIC_PROCESS_ID_LIST)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||||
|
sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) * (sizeof(ULONG_PTR)* jbai.TotalProcesses));
|
||||||
|
|
||||||
|
if(QueryInformationJobObject(JobHandle, JobObjectBasicProcessIdList, &jbpil, sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) * (sizeof(ULONG_PTR)* jbai.TotalProcesses), NULL))
|
||||||
|
{
|
||||||
|
dwProcessId = Implementation_GetProcessId(ProcessHandle);
|
||||||
|
|
||||||
|
for(i = 0; i < jbpil->NumberOfProcessIdsInList; i++)
|
||||||
|
{
|
||||||
|
if(dwProcessId == jbpil->ProcessIdList[i])
|
||||||
|
{
|
||||||
|
*Result = TRUE;
|
||||||
|
HeapFree(GetProcessHeap(), 0, jbpil);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HeapFree(GetProcessHeap(), 0, jbpil);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
HeapFree(GetProcessHeap(), 0, jbpil);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_IsWow64Process(
|
||||||
|
HANDLE hProcess,
|
||||||
|
PBOOL Wow64Process
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!Wow64Process)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
*Wow64Process = TRUE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_DuplicateHandle(
|
||||||
|
HANDLE hSourceProcessHandle,
|
||||||
|
HANDLE hSourceHandle,
|
||||||
|
HANDLE hTargetProcessHandle,
|
||||||
|
LPHANDLE lpTargetHandle,
|
||||||
|
DWORD dwDesiredAccess,
|
||||||
|
BOOL bInheritHandle,
|
||||||
|
DWORD dwOptions
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typedef BOOL(WINAPI* pfnDuplicateHandle)(HANDLE, HANDLE, HANDLE, LPHANDLE, DWORD, BOOL, DWORD);
|
||||||
|
pfnDuplicateHandle pDuplicateHandle = (pfnDuplicateHandle)Implementation_GetProcAddress(GetModuleHandleA("kernel32.dll"), "DuplicateHandle");
|
||||||
|
if (dwDesiredAccess & PROCESS_QUERY_LIMITED_INFORMATION)
|
||||||
|
{
|
||||||
|
dwDesiredAccess &= ~PROCESS_QUERY_LIMITED_INFORMATION;
|
||||||
|
dwDesiredAccess |= PROCESS_QUERY_INFORMATION;
|
||||||
|
}
|
||||||
|
return pDuplicateHandle(hSourceProcessHandle, hSourceHandle, hTargetProcessHandle, lpTargetHandle, dwDesiredAccess,
|
||||||
|
bInheritHandle, dwOptions);
|
||||||
|
}
|
||||||
22
progwrp-CSOG/product.c
Normal file
22
progwrp-CSOG/product.c
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetProductInfo(
|
||||||
|
DWORD dwOSMajorVersion,
|
||||||
|
DWORD dwOSMinorVersion,
|
||||||
|
DWORD dwSpMajorVersion,
|
||||||
|
DWORD dwSpMinorVersion,
|
||||||
|
PDWORD pdwReturnedProductType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!pdwReturnedProductType)
|
||||||
|
{
|
||||||
|
SetLastError(STATUS_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pdwReturnedProductType = PRODUCT_ULTIMATE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
114
progwrp-CSOG/progwrp.h
Normal file
114
progwrp-CSOG/progwrp.h
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
#pragma once
|
||||||
|
#define PSAPI_VERSION 1
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winternl.h>
|
||||||
|
#include <psapi.h>
|
||||||
|
#include <iphlpapi.h>
|
||||||
|
#include <evntprov.h>
|
||||||
|
#include <winevt.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <dwmapi.h>
|
||||||
|
#include <setupapi.h>
|
||||||
|
#include <devpkey.h>
|
||||||
|
#include <usp10.h>
|
||||||
|
#include <pdh.h>
|
||||||
|
#include <shellscalingapi.h>
|
||||||
|
|
||||||
|
CRITICAL_SECTION SrwSharedCs, SrwSharedCs2;
|
||||||
|
HANDLE MutexInitOnce;
|
||||||
|
HANDLE g_SRWEvent;
|
||||||
|
HANDLE MutexRegistry;
|
||||||
|
HKEY g_hkProgwrp;
|
||||||
|
/**/
|
||||||
|
typedef struct _PEBS_LDR_DATA {
|
||||||
|
BYTE Reserved1[8];
|
||||||
|
PVOID Reserved2[3];
|
||||||
|
LIST_ENTRY InMemoryOrderModuleList;
|
||||||
|
} PEBS_LDR_DATA, * PPEBS_LDR_DATA;
|
||||||
|
|
||||||
|
VOID WINAPI TLSInit_DllMain_ThreadAttach_Internal(ULONG_PTR DllBase, ULONG_PTR TebAddr);
|
||||||
|
VOID WINAPI TLSInit_DllMain_ProcessAttach_Internal(ULONG_PTR DllBase);
|
||||||
|
ULONG GetCoreTlsEntriesCount();
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BOOLEAN InheritedAddressSpace;
|
||||||
|
BOOLEAN ReadImageFileExecOptions;
|
||||||
|
BOOLEAN BeingDebugged;
|
||||||
|
BOOLEAN SpareBool;
|
||||||
|
HANDLE Mutant;
|
||||||
|
PVOID ImageBaseAddress;
|
||||||
|
PPEB_LDR_DATA Ldr;
|
||||||
|
PVOID ProcessParameters;
|
||||||
|
PVOID SubSystemData;
|
||||||
|
PVOID ProcessHeap;
|
||||||
|
PVOID FastPebLock;
|
||||||
|
PVOID FastPebLockRoutine;
|
||||||
|
PVOID FastPebUnlockRoutine;
|
||||||
|
ULONG EnvironmentUpdateCount;
|
||||||
|
PVOID KernelCallbackTable;
|
||||||
|
ULONG SystemReserved;
|
||||||
|
} PEB_CUSTOM, *PPEB_CUSTOM;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PVOID ExceptionList;
|
||||||
|
PVOID StackBase;
|
||||||
|
PVOID StackLimit;
|
||||||
|
PVOID SubSystemTib;
|
||||||
|
union {
|
||||||
|
PVOID FiberData;
|
||||||
|
DWORD Version;
|
||||||
|
};
|
||||||
|
PVOID ArbitraryUserPointer;
|
||||||
|
PVOID Self;
|
||||||
|
PVOID EnvironmentPointer;
|
||||||
|
ULONG_PTR UniqueProcess;
|
||||||
|
ULONG_PTR UniqueThread;
|
||||||
|
PVOID ActiveRpcHandle;
|
||||||
|
PVOID ThreadLocalStoragePointer;
|
||||||
|
PPEB_CUSTOM ProcessEnvironmentBlock;
|
||||||
|
ULONG LastErrorValue;
|
||||||
|
ULONG CountOfOwnedCriticalSections;
|
||||||
|
PVOID CsrClientThread;
|
||||||
|
PVOID Win32ThreadInfo;
|
||||||
|
ULONG User32Reserved [0x1A];
|
||||||
|
ULONG UserReserved [5];
|
||||||
|
PVOID WOW32Reserved;
|
||||||
|
ULONG CurrentLocale;
|
||||||
|
ULONG FpSoftwareStatusRegister;
|
||||||
|
PVOID SystemReserved1 [0x36];
|
||||||
|
} TEB_CUSTOM, *PTEB_CUSTOM;
|
||||||
|
|
||||||
|
#define BaseSetLastNTError(x) SetLastError(RtlNtStatusToDosError(x))
|
||||||
|
|
||||||
|
NTSTATUS NTAPI LdrLoadDll(
|
||||||
|
PWCHAR DllPathName,
|
||||||
|
ULONG Flags,
|
||||||
|
PUNICODE_STRING ModuleName,
|
||||||
|
PHANDLE Handle);
|
||||||
|
|
||||||
|
NTSYSAPI NTSTATUS NTAPI LdrGetProcedureAddress(
|
||||||
|
IN HMODULE ModuleHandle,
|
||||||
|
IN PANSI_STRING FunctionName OPTIONAL,
|
||||||
|
IN WORD Ordinal OPTIONAL,
|
||||||
|
OUT PVOID *FunctionAddress );
|
||||||
|
|
||||||
|
BOOL WINAPI LimitedStrCmp(int StartIdx, int EndIdx, PCWSTR Str0, PCWSTR Str1);
|
||||||
|
|
||||||
|
typedef wchar_t(_cdecl *wcsstr_ntdll)(const wchar_t*, const wchar_t*);
|
||||||
|
|
||||||
|
wcsstr_ntdll g_wcsstr;
|
||||||
|
|
||||||
|
typedef char(_cdecl* strstr_ntdll)(const char*, const char*);
|
||||||
|
|
||||||
|
strstr_ntdll g_strstr;
|
||||||
|
|
||||||
|
HANDLE g_hFile;
|
||||||
|
|
||||||
|
ULONG WINAPI AddRef(void* this);
|
||||||
|
|
||||||
|
ULONG WINAPI Release(void* this);
|
||||||
|
|
||||||
|
PULONG_PTR TlsBases;
|
||||||
|
ULONG TlsBasesCount, TlsBasesLength;
|
||||||
583
progwrp-CSOG/progwrp.vcproj
Normal file
583
progwrp-CSOG/progwrp.vcproj
Normal file
@@ -0,0 +1,583 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="progwrp"
|
||||||
|
ProjectGUID="{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}"
|
||||||
|
RootNamespace="progwrp"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
<Platform
|
||||||
|
Name="x64"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|x64"
|
||||||
|
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
TargetEnvironment="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
TargetMachine="17"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="1"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="2"
|
||||||
|
EnableIntrinsicFunctions="true"
|
||||||
|
WholeProgramOptimization="false"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
BufferSecurityCheck="false"
|
||||||
|
EnableFunctionLevelLinking="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="progwrp.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="ntdllex.lib ntdll.lib psapi.lib setupapi.lib pdh.lib user32.lib ws2_32.lib ucrt.lib"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateManifest="false"
|
||||||
|
IgnoreAllDefaultLibraries="true"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
StripPrivateSymbols="Yes"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
EntryPointSymbol="DllMain"
|
||||||
|
SetChecksum="true"
|
||||||
|
BaseAddress="0x7000000"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|x64"
|
||||||
|
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="1"
|
||||||
|
WholeProgramOptimization="0"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
TargetEnvironment="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="3"
|
||||||
|
EnableIntrinsicFunctions="true"
|
||||||
|
WholeProgramOptimization="false"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
BufferSecurityCheck="false"
|
||||||
|
EnableFunctionLevelLinking="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="progwrp.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
DebugInformationFormat="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="ntdll.lib setupapi.lib psapi.lib pdh.lib ws2_32.lib"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateManifest="false"
|
||||||
|
IgnoreAllDefaultLibraries="true"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
EntryPointSymbol="DllMain"
|
||||||
|
SetChecksum="true"
|
||||||
|
BaseAddress="0x17000000"
|
||||||
|
TargetMachine="17"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\advapi.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\condvar.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dbg.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dllmain.c"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
CompileAsManaged="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|x64"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
CompileAsManaged="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
CompileAsManaged="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|x64"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
CompileAsManaged="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dwmapi.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\dxgi.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\evt_log.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\exports.c"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="1"
|
||||||
|
InlineFunctionExpansion="0"
|
||||||
|
FavorSizeOrSpeed="2"
|
||||||
|
OmitFramePointers="false"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|x64"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="1"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\fiber.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\file.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\initonce.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ip.c"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="2"
|
||||||
|
InlineFunctionExpansion="0"
|
||||||
|
EnableIntrinsicFunctions="true"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\locale.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\misc.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\module.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ole32.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\power.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\processor.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\procthread.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\product.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\psapi.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ptr.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\registry.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\setupapi.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\shell.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\srw.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\synch.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tls.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\user.c"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|x64"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\wer.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\com_lite.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\export.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\implementations.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\locale.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\progwrp.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\resource.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\rsrc.rc"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ReadMe.txt"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
355
progwrp-CSOG/progwrp.vcxproj
Normal file
355
progwrp-CSOG/progwrp.vcxproj
Normal file
@@ -0,0 +1,355 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|ARM">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>ARM</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|ARM">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>ARM</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<ProjectGuid>{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}</ProjectGuid>
|
||||||
|
<RootNamespace>progwrp</RootNamespace>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>16.0.30717.126</_ProjectFileVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<GenerateManifest>false</GenerateManifest>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<GenerateManifest>false</GenerateManifest>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<GenerateManifest>false</GenerateManifest>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeader />
|
||||||
|
<ProgramDataBaseFileName>progwrp.pdb</ProgramDataBaseFileName>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>crypt32.lib;ntdllex.lib;winmm.lib;ntdll.lib;psapi.lib;setupapi.lib;pdh.lib;user32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<StripPrivateSymbols>Yes</StripPrivateSymbols>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<EntryPointSymbol>DllMain</EntryPointSymbol>
|
||||||
|
<SetChecksum>true</SetChecksum>
|
||||||
|
<BaseAddress>0x7000000</BaseAddress>
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<ProgramDataBaseFileName>progwrp.pdb</ProgramDataBaseFileName>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>ntdllex.lib;winmm.lib;ntdll.lib;psapi.lib;setupapi.lib;pdh.lib;user32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<StripPrivateSymbols>Yes</StripPrivateSymbols>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<EntryPointSymbol>DllMain</EntryPointSymbol>
|
||||||
|
<SetChecksum>true</SetChecksum>
|
||||||
|
<BaseAddress>0x7000000</BaseAddress>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Midl>
|
||||||
|
<TargetEnvironment>X64</TargetEnvironment>
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Full</Optimization>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PROGWRP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<PrecompiledHeader />
|
||||||
|
<ProgramDataBaseFileName>progwrp.pdb</ProgramDataBaseFileName>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<DebugInformationFormat />
|
||||||
|
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>crypt32.lib;ntdll.lib;setupapi.lib;winmm.lib;psapi.lib;pdh.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<EntryPointSymbol>DllMain</EntryPointSymbol>
|
||||||
|
<SetChecksum>true</SetChecksum>
|
||||||
|
<BaseAddress>0x17000000</BaseAddress>
|
||||||
|
<TargetMachine>MachineX64</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="advapi.c" />
|
||||||
|
<ClCompile Include="combase.c" />
|
||||||
|
<ClCompile Include="condvar.c" />
|
||||||
|
<ClCompile Include="dbg.c" />
|
||||||
|
<ClCompile Include="dllmain.c">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsManaged>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsManaged>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dwmapi.c" />
|
||||||
|
<ClCompile Include="dwrite.c" />
|
||||||
|
<ClCompile Include="dxgi.c" />
|
||||||
|
<ClCompile Include="evt_log.c" />
|
||||||
|
<ClCompile Include="exports.c">
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">MinSpace</Optimization>
|
||||||
|
<InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Default</InlineFunctionExpansion>
|
||||||
|
<InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Default</InlineFunctionExpansion>
|
||||||
|
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Size</FavorSizeOrSpeed>
|
||||||
|
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Size</FavorSizeOrSpeed>
|
||||||
|
<OmitFramePointers Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</OmitFramePointers>
|
||||||
|
<OmitFramePointers Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</OmitFramePointers>
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MinSpace</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="fiber.c" />
|
||||||
|
<ClCompile Include="file.c" />
|
||||||
|
<ClCompile Include="initonce.c" />
|
||||||
|
<ClCompile Include="ip.c">
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">MaxSpeed</Optimization>
|
||||||
|
<InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Default</InlineFunctionExpansion>
|
||||||
|
<InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Default</InlineFunctionExpansion>
|
||||||
|
<IntrinsicFunctions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</IntrinsicFunctions>
|
||||||
|
<IntrinsicFunctions Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</IntrinsicFunctions>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="locale.c" />
|
||||||
|
<ClCompile Include="misc.c" />
|
||||||
|
<ClCompile Include="module.c" />
|
||||||
|
<ClCompile Include="ole32.c" />
|
||||||
|
<ClCompile Include="power.c" />
|
||||||
|
<ClCompile Include="processor.c" />
|
||||||
|
<ClCompile Include="procthread.c" />
|
||||||
|
<ClCompile Include="product.c" />
|
||||||
|
<ClCompile Include="psapi.c" />
|
||||||
|
<ClCompile Include="ptr.c" />
|
||||||
|
<ClCompile Include="registry.c" />
|
||||||
|
<ClCompile Include="setupapi.c" />
|
||||||
|
<ClCompile Include="shell.c" />
|
||||||
|
<ClCompile Include="srw.c" />
|
||||||
|
<ClCompile Include="synch.c" />
|
||||||
|
<ClCompile Include="tls.c">
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Disabled</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="user.c">
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Disabled</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="wer.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="com_lite.h" />
|
||||||
|
<ClInclude Include="export.h" />
|
||||||
|
<ClInclude Include="implementations.h" />
|
||||||
|
<ClInclude Include="locale.h" />
|
||||||
|
<ClInclude Include="progwrp.h" />
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="rsrc.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Text Include="ReadMe.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
143
progwrp-CSOG/progwrp.vcxproj.filters
Normal file
143
progwrp-CSOG/progwrp.vcxproj.filters
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="advapi.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="condvar.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dbg.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dllmain.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dwmapi.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dxgi.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="evt_log.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="exports.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="fiber.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="file.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="initonce.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ip.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="locale.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="misc.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="module.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ole32.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="power.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="processor.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="procthread.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="product.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="psapi.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ptr.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="registry.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="setupapi.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="shell.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="srw.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="synch.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tls.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="user.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="wer.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="combase.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dwrite.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="com_lite.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="export.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="implementations.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="locale.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="progwrp.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="rsrc.rc">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Text Include="ReadMe.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
50
progwrp-CSOG/psapi.c
Normal file
50
progwrp-CSOG/psapi.c
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetProcessMemoryInfo(
|
||||||
|
HANDLE Process,
|
||||||
|
PPROCESS_MEMORY_COUNTERS ppsmemCounters,
|
||||||
|
DWORD cb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetModuleInformation(
|
||||||
|
HANDLE hProcess,
|
||||||
|
HMODULE hModule,
|
||||||
|
LPMODULEINFO lpmodinfo,
|
||||||
|
DWORD cb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_QueryWorkingSetEx(
|
||||||
|
HANDLE hProcess,
|
||||||
|
PVOID pv,
|
||||||
|
DWORD cb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetPerformanceInfo(
|
||||||
|
PPERFORMANCE_INFORMATION pPerformanceInformation,
|
||||||
|
DWORD cb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(!pPerformanceInformation)
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if(cb != sizeof(PERFORMANCE_INFORMATION))
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
//pPerformanceInformation->
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
13
progwrp-CSOG/ptr.c
Normal file
13
progwrp-CSOG/ptr.c
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
PVOID WINAPI Implementation_EncodePointer(PVOID Ptr) {
|
||||||
|
|
||||||
|
return (PVOID)((ULONG_PTR)Ptr ^ (ULONG_PTR)NtCurrentTeb()->ProcessEnvironmentBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID WINAPI Implementation_DecodePointer(PVOID Ptr) {
|
||||||
|
|
||||||
|
return (PVOID)((ULONG_PTR)Ptr ^ (ULONG_PTR)NtCurrentTeb()->ProcessEnvironmentBlock);
|
||||||
|
}
|
||||||
42
progwrp-CSOG/registry.c
Normal file
42
progwrp-CSOG/registry.c
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
NTSTATUS NTAPI NtOpenKey(
|
||||||
|
PHANDLE KeyHandle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||||
|
|
||||||
|
NTSTATUS NTAPI Implementation_NtOpenKeyEx(
|
||||||
|
PHANDLE KeyHandle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
ULONG OpenOptions
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NtOpenKey(KeyHandle, DesiredAccess, ObjectAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
LSTATUS WINAPI Implementation_RegDeleteKeyExW(
|
||||||
|
HKEY hKey,
|
||||||
|
LPCWSTR lpSubKey,
|
||||||
|
REGSAM samDesired,
|
||||||
|
DWORD Reserved
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return RegDeleteKeyW(hKey, lpSubKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
LSTATUS WINAPI Implementation_RegGetValueW(
|
||||||
|
HKEY hkey,
|
||||||
|
LPCWSTR lpSubKey,
|
||||||
|
LPCWSTR lpValue,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPDWORD pdwType,
|
||||||
|
PVOID pvData,
|
||||||
|
LPDWORD pcbData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
return RegQueryValueW(hkey, lpSubKey, lpValue, pcbData);
|
||||||
|
}
|
||||||
14
progwrp-CSOG/resource.h
Normal file
14
progwrp-CSOG/resource.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by rsrc.rc
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
109
progwrp-CSOG/rsrc.rc
Normal file
109
progwrp-CSOG/rsrc.rc
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (United States) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
#pragma code_page(1252)
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include "<Windows.h>"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
#endif // English (United States) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (Canada) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENC)
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN
|
||||||
|
#pragma code_page(1252)
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Version
|
||||||
|
//
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION 1,1,0,5024
|
||||||
|
PRODUCTVERSION 1,1,0,5024
|
||||||
|
FILEFLAGSMASK 0x17L
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x4L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "100904b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "FileDescription", "Application-side Win32 API Compatibility DLL"
|
||||||
|
VALUE "FileVersion", "1.1.0.5024"
|
||||||
|
VALUE "InternalName", "progwrp"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) 2024 win32"
|
||||||
|
VALUE "OriginalFilename", "progwrp.dll"
|
||||||
|
VALUE "ProductName", "Application-side Win32 API Compatibility Pack"
|
||||||
|
VALUE "ProductVersion", "1.1.0.5024"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x1009, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // English (Canada) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
||||||
64
progwrp-CSOG/setupapi.c
Normal file
64
progwrp-CSOG/setupapi.c
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include <cfgmgr32.h>
|
||||||
|
|
||||||
|
const DEVPROPKEY DEVPKEY_Device_DeviceDesc = {0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 2 };
|
||||||
|
const DEVPROPKEY DEVPKEY_Device_BusNumber = {0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 23};
|
||||||
|
const DEVPROPKEY DEVPKEY_Device_Address = {0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 30};
|
||||||
|
const DEVPROPKEY DEVPKEY_Device_InstanceId = {0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 256};
|
||||||
|
const DEVPROPKEY DEVPKEY_Device_Parent = {0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 8};
|
||||||
|
const DEVPROPKEY DEVPKEY_Device_Children = {0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 9};
|
||||||
|
const DEVPROPKEY DEVPKEY_Device_HardwareIds = {0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 3};
|
||||||
|
|
||||||
|
BOOL DevPropKeyCmp(const DEVPROPKEY PropertyKey0, const DEVPROPKEY PropertyKey1)
|
||||||
|
{
|
||||||
|
if(PropertyKey0.fmtid.Data1 == PropertyKey1.fmtid.Data1 &&
|
||||||
|
PropertyKey0.fmtid.Data2 == PropertyKey1.fmtid.Data2 &&
|
||||||
|
PropertyKey0.fmtid.Data3 == PropertyKey1.fmtid.Data3 &&
|
||||||
|
PropertyKey0.fmtid.Data4 == PropertyKey1.fmtid.Data4 &&
|
||||||
|
PropertyKey0.pid == PropertyKey1.pid)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI DevPropKeyEqual(const DEVPROPKEY* PropertyKey)
|
||||||
|
{
|
||||||
|
if(DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_DeviceDesc))
|
||||||
|
return SPDRP_DEVICEDESC;
|
||||||
|
if(DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_BusNumber))
|
||||||
|
return SPDRP_BUSNUMBER;
|
||||||
|
if(DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_Address))
|
||||||
|
return SPDRP_ADDRESS;
|
||||||
|
if(DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_InstanceId))
|
||||||
|
return SPDRP_MAXIMUM_PROPERTY; // use SetupDiGetDeviceInstanceIdW
|
||||||
|
if(DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_Parent))
|
||||||
|
return SPDRP_MAXIMUM_PROPERTY; // CM_Get_Parent then CM_Get_Device_ID
|
||||||
|
if(DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_Children))
|
||||||
|
return SPDRP_MAXIMUM_PROPERTY; // CM_Get_Child then CM_Get_Sibling CM_Get_Device_ID
|
||||||
|
if(DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_HardwareIds))
|
||||||
|
return SPDRP_HARDWAREID;
|
||||||
|
|
||||||
|
return SPDRP_MAXIMUM_PROPERTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SetupDiGetDevicePropertyW(
|
||||||
|
HDEVINFO DeviceInfoSet,
|
||||||
|
PSP_DEVINFO_DATA DeviceInfoData,
|
||||||
|
const DEVPROPKEY *PropertyKey,
|
||||||
|
DEVPROPTYPE *PropertyType,
|
||||||
|
PBYTE PropertyBuffer,
|
||||||
|
DWORD PropertyBufferSize,
|
||||||
|
PDWORD RequiredSize,
|
||||||
|
DWORD Flags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_InstanceId)) {
|
||||||
|
return SetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData, (PWSTR)PropertyBuffer, PropertyBufferSize, RequiredSize);
|
||||||
|
}
|
||||||
|
if (DevPropKeyCmp(*PropertyKey, DEVPKEY_Device_Parent)) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, DevPropKeyEqual(PropertyKey), PropertyType, PropertyBuffer, PropertyBufferSize, RequiredSize);
|
||||||
|
}
|
||||||
100
progwrp-CSOG/shell.c
Normal file
100
progwrp-CSOG/shell.c
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
BOOL WINAPI GuidComp(const GUID PropertyKey0, const GUID PropertyKey1)
|
||||||
|
{
|
||||||
|
if(PropertyKey0.Data1 == PropertyKey1.Data1 &&
|
||||||
|
PropertyKey0.Data2 == PropertyKey1.Data2 &&
|
||||||
|
PropertyKey0.Data3 == PropertyKey1.Data3 &&
|
||||||
|
PropertyKey0.Data4 == PropertyKey1.Data4)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_SHGetPropertyStoreForWindow(
|
||||||
|
HWND hwnd,
|
||||||
|
REFIID riid,
|
||||||
|
void **ppv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_SHGetKnownFolderPath(
|
||||||
|
REFKNOWNFOLDERID rfid,
|
||||||
|
DWORD dwFlags,
|
||||||
|
HANDLE hToken,
|
||||||
|
PWSTR *ppszPath
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int csidl_conv = 0;
|
||||||
|
PWSTR pszFolderPath;
|
||||||
|
HRESULT result;
|
||||||
|
|
||||||
|
pszFolderPath = (PWSTR)CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR));
|
||||||
|
|
||||||
|
if (!pszFolderPath)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
if(GuidComp(*rfid, FOLDERID_AdminTools))
|
||||||
|
csidl_conv = CSIDL_ADMINTOOLS;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_CDBurning))
|
||||||
|
csidl_conv = CSIDL_CDBURN_AREA;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_CommonAdminTools))
|
||||||
|
csidl_conv = CSIDL_COMMON_ADMINTOOLS;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_CommonOEMLinks))
|
||||||
|
csidl_conv = CSIDL_COMMON_OEM_LINKS;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_CommonPrograms))
|
||||||
|
csidl_conv = CSIDL_COMMON_PROGRAMS;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_CommonStartMenu))
|
||||||
|
csidl_conv = CSIDL_COMMON_STARTMENU;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_CommonStartup))
|
||||||
|
csidl_conv = CSIDL_COMMON_STARTUP;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_CommonTemplates))
|
||||||
|
csidl_conv = CSIDL_COMMON_TEMPLATES;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_ComputerFolder))
|
||||||
|
csidl_conv = CSIDL_DRIVES;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_ConnectionsFolder))
|
||||||
|
csidl_conv = CSIDL_CONNECTIONS;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_ControlPanelFolder))
|
||||||
|
csidl_conv = CSIDL_CONTROLS;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_Cookies))
|
||||||
|
csidl_conv = CSIDL_COOKIES;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_Desktop))
|
||||||
|
csidl_conv = CSIDL_DESKTOP;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_Documents))
|
||||||
|
csidl_conv = CSIDL_MYDOCUMENTS;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_Downloads))
|
||||||
|
return E_NOTIMPL;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_Favorites))
|
||||||
|
csidl_conv = CSIDL_FAVORITES;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_Fonts))
|
||||||
|
csidl_conv = CSIDL_FONTS;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_History))
|
||||||
|
csidl_conv = CSIDL_HISTORY;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_InternetCache))
|
||||||
|
csidl_conv = CSIDL_INTERNET_CACHE;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_InternetFolder))
|
||||||
|
csidl_conv = CSIDL_INTERNET;
|
||||||
|
else if(GuidComp(*rfid, FOLDERID_LocalAppData))
|
||||||
|
csidl_conv = CSIDL_LOCAL_APPDATA;
|
||||||
|
|
||||||
|
if(csidl_conv)
|
||||||
|
{
|
||||||
|
result = SHGetFolderPathW(NULL, csidl_conv, hToken, dwFlags, pszFolderPath);
|
||||||
|
|
||||||
|
*ppszPath = pszFolderPath;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_SHQueryUserNotificationState(
|
||||||
|
QUERY_USER_NOTIFICATION_STATE *pquns
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
169
progwrp-CSOG/srw.c
Normal file
169
progwrp-CSOG/srw.c
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ULONG_PTR pSRWLock;
|
||||||
|
HANDLE hEvent;
|
||||||
|
} WAITER, * PWAITER;
|
||||||
|
|
||||||
|
WAITER ExclusiveWaiters[512];
|
||||||
|
WAITER SharedWaiters[512];
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
USHORT Readers;
|
||||||
|
USHORT WaitingWriters;
|
||||||
|
}SRWLOCK_INT, * PSRWLOCK_INT;
|
||||||
|
|
||||||
|
BOOLEAN WINAPI Implementation_TryAcquireSRWLockExclusive(PSRWLOCK_INT SRWLock)
|
||||||
|
{
|
||||||
|
// printf("Attempting to acquire SRW Lock holding:\n Exclusive Lock: %d\n Readers: %d\n Waiting Writers: %d\n", SRWLock->WaitingWriters & (1 << 15), SRWLock->Readers, SRWLock->WaitingWriters);
|
||||||
|
// printf("Trying to acquire exclusive SRW lock, value 0x%X at 0x%X, TID %d\n", SRWLock->Ptr, SRWLock, GetCurrentThreadId());
|
||||||
|
return !_interlockedbittestandset(SRWLock, 31);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN WINAPI Implementation_TryAcquireSRWLockShared(PSRWLOCK_INT SRWLock)
|
||||||
|
{
|
||||||
|
// printf("Attempting to acquire SRW Lock holding:\n Exclusive Lock: %d\n Readers: %d\n Waiting Writers: %d\n", SRWLock->WaitingWriters & (1 << 15), SRWLock->Readers, SRWLock->WaitingWriters);
|
||||||
|
// printf("Trying to acquire shared SRW lock, value 0x%X at 0x%X, TID %d\n", SRWLock->Ptr, SRWLock, GetCurrentThreadId());
|
||||||
|
if (!SRWLock->WaitingWriters)
|
||||||
|
{
|
||||||
|
if (!_interlockedbittestandset(SRWLock, 31))
|
||||||
|
{
|
||||||
|
InterlockedIncrement16(&SRWLock->Readers);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SRWLock->WaitingWriters && SRWLock->Readers)
|
||||||
|
{
|
||||||
|
InterlockedIncrement16(&SRWLock->Readers);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
//return !_interlockedbittestandset(SRWLock, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_AcquireSRWLockExclusive(PSRWLOCK_INT SRWLock)
|
||||||
|
{
|
||||||
|
// printf("Attempting to acquire SRW Lock holding:\n Exclusive Lock: %d\n Readers: %d\n Waiting Writers: %d\n", SRWLock->WaitingWriters & (1 << 15), SRWLock->Readers, SRWLock->WaitingWriters);
|
||||||
|
if (_interlockedbittestandset(SRWLock, 31))
|
||||||
|
{
|
||||||
|
// EnterCriticalSection(&SrwSharedCs2);
|
||||||
|
InterlockedIncrement16(&SRWLock->WaitingWriters);
|
||||||
|
// _interlockedbittestandset(SRWLock, 31);
|
||||||
|
// LeaveCriticalSection(&SrwSharedCs2);
|
||||||
|
wait:
|
||||||
|
//WaitForSingleObject(g_SRWEvent, INFINITE);
|
||||||
|
Sleep(1);
|
||||||
|
|
||||||
|
if (!_interlockedbittestandset(SRWLock, 31))
|
||||||
|
{
|
||||||
|
// EnterCriticalSection(&SrwSharedCs2);
|
||||||
|
InterlockedDecrement16(&SRWLock->WaitingWriters);
|
||||||
|
// LeaveCriticalSection(&SrwSharedCs2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
goto wait;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_AcquireSRWLockShared(PSRWLOCK_INT SRWLock)
|
||||||
|
{
|
||||||
|
// printf("Attempting to acquire SRW Lock holding:\n Exclusive Lock: %d\n Readers: %d\n Waiting Writers: %d\n", SRWLock->WaitingWriters & (1 << 15), SRWLock->Readers, SRWLock->WaitingWriters);
|
||||||
|
if (_interlockedbittestandset(SRWLock, 31))
|
||||||
|
{
|
||||||
|
if (SRWLock->Readers)
|
||||||
|
{
|
||||||
|
InterlockedIncrement16(&SRWLock->Readers);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// InterlockedIncrement16(&SRWLock->WaitingReaders);
|
||||||
|
wait:
|
||||||
|
//WaitForSingleObject(g_SRWEvent, INFINITE);
|
||||||
|
Sleep(1);
|
||||||
|
|
||||||
|
if (!SRWLock->WaitingWriters)
|
||||||
|
{
|
||||||
|
_interlockedbittestandset(SRWLock, 31);
|
||||||
|
// InterlockedDecrement16(&SRWLock->WaitingReaders);
|
||||||
|
InterlockedIncrement16(&SRWLock->Readers);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (SRWLock->Readers)
|
||||||
|
{
|
||||||
|
// InterlockedDecrement16(&SRWLock->WaitingReaders);
|
||||||
|
InterlockedIncrement16(&SRWLock->Readers);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto wait;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InterlockedIncrement16(&SRWLock->Readers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_ReleaseSRWLockShared(PSRWLOCK_INT SRWLock)
|
||||||
|
{
|
||||||
|
// printf("Release attempt made on SRW Lock holding:\n Exclusive Lock: %d\n Readers: %d\n Waiting Writers: %d\n", SRWLock->WaitingWriters & (1 << 15), SRWLock->Readers, SRWLock->WaitingWriters);
|
||||||
|
if (!InterlockedDecrement16(&SRWLock->Readers))
|
||||||
|
_interlockedbittestandreset(SRWLock, 31);
|
||||||
|
//SetEvent(g_SRWEvent);
|
||||||
|
// ResetEvent(g_SRWEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_ReleaseSRWLockExclusive(PSRWLOCK_INT SRWLock)
|
||||||
|
{
|
||||||
|
// printf("Release attempt made on SRW Lock holding:\n Exclusive Lock: %d\n Readers: %d\n Waiting Writers: %d\n", SRWLock->WaitingWriters & (1 << 15), SRWLock->Readers, SRWLock->WaitingWriters);
|
||||||
|
_interlockedbittestandreset(SRWLock, 31);
|
||||||
|
// SetEvent(g_SRWEvent);
|
||||||
|
// ResetEvent(g_SRWEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN WINAPI Implementation_TryAcquireSRWLockExclusive_Vista(PSRWLOCK SRWLock)
|
||||||
|
{
|
||||||
|
return !_interlockedbittestandset(SRWLock, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN WINAPI Implementation_TryAcquireSRWLockShared_Vista(PSRWLOCK SRWLock)
|
||||||
|
{
|
||||||
|
ULONG_PTR InterlockedVal;
|
||||||
|
ULONG_PTR NewSRWValue = 0x11;
|
||||||
|
ULONG_PTR OldSRWValue = 1;
|
||||||
|
InterlockedVal = (ULONG_PTR)InterlockedCompareExchange(SRWLock, 0x11, 0);
|
||||||
|
if (InterlockedVal)
|
||||||
|
{
|
||||||
|
if (InterlockedVal == 1)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
while (InterlockedVal)
|
||||||
|
{
|
||||||
|
InterlockedVal = InterlockedCompareExchange(SRWLock, NewSRWValue, OldSRWValue);
|
||||||
|
if (InterlockedVal == OldSRWValue)
|
||||||
|
return TRUE;
|
||||||
|
if (InterlockedVal == 1 || InterlockedVal % 0x10 != 1)
|
||||||
|
return FALSE;
|
||||||
|
NewSRWValue += 0x10;
|
||||||
|
OldSRWValue += 0x10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WINAPI Implementation_InitializeSRWLock(
|
||||||
|
PSRWLOCK SRWLock
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SRWLock->Ptr = 0;
|
||||||
|
}
|
||||||
170
progwrp-CSOG/srw_new.c
Normal file
170
progwrp-CSOG/srw_new.c
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
BOOLEAN Implementation_TryAcquireSRWLockExclusive(PSRWLOCK SRWLock)
|
||||||
|
{
|
||||||
|
return !_interlockedbittestandset(SRWLock, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN Implementation_TryAcquireSRWLockShared(PSRWLOCK SRWLock)
|
||||||
|
{
|
||||||
|
ULONG_PTR InterlockedVal;
|
||||||
|
ULONG_PTR NewSRWValue = 1001;
|
||||||
|
ULONG_PTR OldSRWValue = 1;
|
||||||
|
InterlockedVal = (ULONG_PTR)InterlockedCompareExchange(SRWLock, 1001, 0);
|
||||||
|
while(InterlockedVal)
|
||||||
|
{
|
||||||
|
if(InterlockedVal % 1000 == 1)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
while(InterlockedVal)
|
||||||
|
{
|
||||||
|
InterlockedVal = InterlockedCompareExchange(SRWLock, NewSRWValue, OldSRWValue);
|
||||||
|
if(InterlockedVal == OldSRWValue)
|
||||||
|
return TRUE;
|
||||||
|
if(InterlockedVal % 1000 == 1 || InterlockedVal % 10 != 1)
|
||||||
|
return FALSE;
|
||||||
|
NewSRWValue += 1000;
|
||||||
|
OldSRWValue += 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
/*
|
||||||
|
#ifdef __WX86
|
||||||
|
if(InterlockedAnd(SRWLock, 0xFFFFFFFF) & 1)
|
||||||
|
#else
|
||||||
|
if(InterlockedAnd(SRWLock, 0xFFFFFFFFFFFFFFFF) & 1)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SRWLockVal = (ULONG_PTR)SRWLock->Ptr;
|
||||||
|
SRWLockVal = (((SRWLockVal >> 1) + 1) << 1) | (SRWLockVal & 1);
|
||||||
|
#ifdef __WX86
|
||||||
|
if(InterlockedAnd(SRWLock, 0xFFFFFFFF) & 1)
|
||||||
|
#else
|
||||||
|
if(InterlockedAnd(SRWLock, 0xFFFFFFFFFFFFFFFF) & 1)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
InterlockedExchange(SRWLock, SRWLockVal);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void Implementation_AcquireSRWLockExclusive(PSRWLOCK SRWLock)
|
||||||
|
{
|
||||||
|
printf("Entering AcquireSRWLockExclusive: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
InterlockedAdd(SRWLock, 10);
|
||||||
|
while(_interlockedbittestandset(SRWLock, 0))
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
InterlockedAdd(SRWLock, -10);
|
||||||
|
printf("Exiting AcquireSRWLockExclusive: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Implementation_AcquireSRWLockShared(PSRWLOCK SRWLock)
|
||||||
|
/*
|
||||||
|
TODO: add a critical section to block access to the shared bits
|
||||||
|
of the SRW lock.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
|
||||||
|
ULONG_PTR InterlockedVal;
|
||||||
|
ULONG_PTR NewSRWValue = 1001;
|
||||||
|
ULONG_PTR OldSRWValue = 1;
|
||||||
|
printf("Entering AcquireSRWLockShared: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
InterlockedVal = (ULONG_PTR)InterlockedCompareExchange(SRWLock, 1001, 0);
|
||||||
|
while(InterlockedVal)
|
||||||
|
{
|
||||||
|
if(InterlockedVal < 1000)
|
||||||
|
{
|
||||||
|
if(InterlockedVal > 1)
|
||||||
|
Sleep(100);
|
||||||
|
InterlockedVal = (ULONG_PTR)InterlockedCompareExchange(SRWLock, 1001, 0);
|
||||||
|
if(!InterlockedVal)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InterlockedAdd(SRWLock, 1000);
|
||||||
|
break;
|
||||||
|
//InterlockedVal = InterlockedCompareExchange(SRWLock, NewSRWValue, OldSRWValue);
|
||||||
|
//if(InterlockedVal == OldSRWValue)
|
||||||
|
// break;
|
||||||
|
//if(InterlockedVal % 0x10 != 1)
|
||||||
|
// TerminateProcess(-1, 0xC0000194); // Deadlock all but guaranteed
|
||||||
|
//NewSRWValue += 1000;
|
||||||
|
//OldSRWValue += 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("Exiting AcquireSRWLockShared: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
/*
|
||||||
|
ULONG_PTR SRWLockVal;
|
||||||
|
#ifdef __WX86
|
||||||
|
while(InterlockedAnd(SRWLock, 0xFFFFFFFF) & 1)
|
||||||
|
#else
|
||||||
|
while(InterlockedAnd(SRWLock, 0xFFFFFFFFFFFFFFFF) & 1)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Sleep(1);
|
||||||
|
}
|
||||||
|
SRWLockVal = SRWLock->Ptr;
|
||||||
|
SRWLockVal = (((SRWLockVal >> 1) + 1) << 1) | (SRWLockVal & 1);
|
||||||
|
InterlockedExchange(SRWLock, SRWLockVal);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void Implementation_ReleaseSRWLockShared(PSRWLOCK SRWLock)
|
||||||
|
/*
|
||||||
|
TODO: add a critical section to block access to the shared bits
|
||||||
|
of the SRW lock.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
printf("Entering ReleaseSRWLockShared: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
ULONG_PTR InterlockedVal = (ULONG_PTR)InterlockedCompareExchange(SRWLock, 0, 1001);
|
||||||
|
if(InterlockedVal == 1001)
|
||||||
|
{
|
||||||
|
printf("Exiting RelaseSRWLockShared: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(InterlockedVal > 1001 && InterlockedVal < 2000)
|
||||||
|
{
|
||||||
|
InterlockedAdd(SRWLock, -1001);
|
||||||
|
printf("Exiting RelaseSRWLockShared: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(InterlockedVal > 1000 && InterlockedVal % 10 == 1)
|
||||||
|
InterlockedAdd(SRWLock, -1000);
|
||||||
|
printf("Exiting RelaseSRWLockShared: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Implementation_ReleaseSRWLockExclusive(PSRWLOCK SRWLock)
|
||||||
|
{
|
||||||
|
printf("Entering ReleaseSRWLockExclusive: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
ULONG_PTR SRWLockVal = (ULONG_PTR)InterlockedCompareExchange(SRWLock, 0, 1);
|
||||||
|
if(SRWLockVal != 1 && SRWLockVal < 1000)
|
||||||
|
{
|
||||||
|
if(SRWLockVal % 10 == 1)
|
||||||
|
InterlockedAdd(SRWLock, -1);
|
||||||
|
}
|
||||||
|
printf("Exiting ReleaseSRWLockExclusive: %d at 0x%X\n", SRWLock->Ptr, SRWLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Implementation_InitializeSRWLock(
|
||||||
|
PSRWLOCK SRWLock
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SRWLock->Ptr = 0;
|
||||||
|
}
|
||||||
48
progwrp-CSOG/synch.c
Normal file
48
progwrp-CSOG/synch.c
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
HANDLE WINAPI Implementation_CreateWaitableTimerExW(
|
||||||
|
LPSECURITY_ATTRIBUTES lpTimerAttributes,
|
||||||
|
LPCWSTR lpTimerName,
|
||||||
|
DWORD dwFlags,
|
||||||
|
DWORD dwDesiredAccess
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(dwFlags & ~(CREATE_WAITABLE_TIMER_MANUAL_RESET & 0x2)) // CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dwFlags & CREATE_WAITABLE_TIMER_MANUAL_RESET)
|
||||||
|
return CreateWaitableTimerW(lpTimerAttributes, TRUE, lpTimerName);
|
||||||
|
else
|
||||||
|
return CreateWaitableTimerW(lpTimerAttributes, FALSE, lpTimerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID NTAPI RtlGetCallersAddress(PVOID* Ptr0, PVOID* Ptr1);
|
||||||
|
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_InitializeCriticalSectionEx(
|
||||||
|
LPCRITICAL_SECTION lpCriticalSection,
|
||||||
|
DWORD dwSpinCount,
|
||||||
|
DWORD Flags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DWORD Test = ERROR_INVALID_PARAMETER;
|
||||||
|
ULONG_PTR Caller, PcVal, DllBase;
|
||||||
|
RtlGetCallersAddress(&Caller, &PcVal);
|
||||||
|
RtlPcToFileHeader(PcVal, &DllBase);
|
||||||
|
|
||||||
|
TLSInit_DllMain_ProcessAttach_Internal(DllBase);
|
||||||
|
if(Flags & ~(CRITICAL_SECTION_NO_DEBUG_INFO))
|
||||||
|
{
|
||||||
|
SetLastError(Test);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
InitializeCriticalSectionAndSpinCount(lpCriticalSection, dwSpinCount);
|
||||||
|
// TODO, investigate whether A) the critical section always allocates the memory for the debug info section and B) whether the older
|
||||||
|
// iterations of the critical section API will function without it being there.
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
414
progwrp-CSOG/tls.c
Normal file
414
progwrp-CSOG/tls.c
Normal file
@@ -0,0 +1,414 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
|
||||||
|
NTSYSAPI PVOID RtlAllocateHeap(
|
||||||
|
PVOID HeapHandle,
|
||||||
|
ULONG Flags,
|
||||||
|
SIZE_T Size
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSYSAPI VOID RtlFreeHeap(
|
||||||
|
PVOID HeapHandle,
|
||||||
|
ULONG Flags,
|
||||||
|
PVOID BaseAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
#define RtlMoveMemory RtlMoveMemory
|
||||||
|
|
||||||
|
VOID NTAPI RtlMoveMemory(
|
||||||
|
PVOID Destination,
|
||||||
|
PVOID Source,
|
||||||
|
SIZE_T Length
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ULONG Ptr0;
|
||||||
|
ULONG Ptr1;
|
||||||
|
ULONG Ptr2;
|
||||||
|
}TlsHack;
|
||||||
|
|
||||||
|
typedef struct _THREAD_BASIC_INFORMATION {
|
||||||
|
NTSTATUS ExitStatus;
|
||||||
|
PVOID TebBaseAddress;
|
||||||
|
CLIENT_ID ClientId;
|
||||||
|
KAFFINITY AffinityMask;
|
||||||
|
KPRIORITY Priority;
|
||||||
|
KPRIORITY BasePriority;
|
||||||
|
} THREAD_BASIC_INFORMATION, * PTHREAD_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
|
||||||
|
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
|
||||||
|
|
||||||
|
__declspec(dllexport) VOID WINAPI TLSInit_DllMain_ThreadAttach(ULONG_PTR DllBase);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Since I will not rewrite the entirety of the fairly complex LdrLoadDll and friends (although if you look at NT 4,
|
||||||
|
it is relatively simple), I will implement implicit TLS initialization code in DllMain.
|
||||||
|
|
||||||
|
There are two separate functions, which do two separate things:
|
||||||
|
-Process attach function: performs calls to TLS callback functions and increments the TLS index for the DLL based on the
|
||||||
|
count of pointers stashed in Teb->ThreadLocalStoragePointer.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID AddToTlsList(ULONG_PTR DllBase)
|
||||||
|
/*
|
||||||
|
The previous TLS allocation system broke down after further enhancements were made to Supermium. Evidently it was no longer doing
|
||||||
|
the job.
|
||||||
|
|
||||||
|
Now, a list of all modules is maintained; when progwrp is first initialized, the TEB is f
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&SrwSharedCs2);
|
||||||
|
|
||||||
|
LeaveCriticalSection(&SrwSharedCs2);
|
||||||
|
}
|
||||||
|
|
||||||
|
PIMAGE_TLS_DIRECTORY __stdcall GetTlsDirectory(ULONG_PTR DllBase, PULONG_PTR ImageBase)
|
||||||
|
{
|
||||||
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
|
DWORD OptionalHeaderOffset;
|
||||||
|
IMAGE_NT_HEADERS* ImageOptionalHeader;
|
||||||
|
ULONG_PTR Base;
|
||||||
|
|
||||||
|
DosHeader = (PIMAGE_DOS_HEADER)DllBase;
|
||||||
|
|
||||||
|
if (!RtlPcToFileHeader(DllBase, &Base))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
OptionalHeaderOffset = DosHeader->e_lfanew;
|
||||||
|
|
||||||
|
ImageOptionalHeader = (IMAGE_NT_HEADERS*)(OptionalHeaderOffset + DllBase);
|
||||||
|
|
||||||
|
*ImageBase = ImageOptionalHeader->OptionalHeader.ImageBase;
|
||||||
|
|
||||||
|
if (!ImageOptionalHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return (PIMAGE_TLS_DIRECTORY)(ImageOptionalHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress + DllBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) VOID WINAPI TLSInit_DllMain_ProcessAttach(ULONG_PTR DllBase)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
PIMAGE_TLS_DIRECTORY TlsDirectory;
|
||||||
|
PIMAGE_TLS_CALLBACK* TlsCallbacks;
|
||||||
|
PIMAGE_TLS_CALLBACK TlsCall;
|
||||||
|
PTEB_CUSTOM CustomTeb;
|
||||||
|
PULONG TlsIdx;
|
||||||
|
ULONG_PTR* ThreadLocalStoragePointer, ImageBase;
|
||||||
|
|
||||||
|
if (!DllBase)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CustomTeb = (PTEB_CUSTOM)NtCurrentTeb();
|
||||||
|
|
||||||
|
if (LOBYTE(GetVersion()) >= 6 || (LOBYTE(GetVersion()) < 6 && CustomTeb->ProcessEnvironmentBlock->SystemReserved == 1))
|
||||||
|
return; // Nothing to do here
|
||||||
|
|
||||||
|
TlsDirectory = GetTlsDirectory(DllBase, &ImageBase);
|
||||||
|
|
||||||
|
if (!TlsDirectory)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TlsCallbacks = (PIMAGE_TLS_CALLBACK*)((TlsDirectory->AddressOfCallBacks)); // - ImageBase) + DllBase);
|
||||||
|
|
||||||
|
TlsIdx = (PULONG)((TlsDirectory->AddressOfIndex));// - ImageBase)); + DllBase);
|
||||||
|
|
||||||
|
if (*TlsIdx)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ThreadLocalStoragePointer = CustomTeb->ThreadLocalStoragePointer;
|
||||||
|
|
||||||
|
if (ThreadLocalStoragePointer)
|
||||||
|
{
|
||||||
|
while (*ThreadLocalStoragePointer > 0 && !(*ThreadLocalStoragePointer % 4))
|
||||||
|
// Make sure only valid pointers are counted, and not padding that can also bookend the list of pointers
|
||||||
|
{
|
||||||
|
++*TlsIdx;
|
||||||
|
++ThreadLocalStoragePointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TlsCallbacks)
|
||||||
|
{
|
||||||
|
while (*TlsCallbacks)
|
||||||
|
{
|
||||||
|
TlsCall = *TlsCallbacks;
|
||||||
|
TlsCall((PVOID)DllBase, 1, NULL);
|
||||||
|
++TlsCallbacks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TLSInit_DllMain_ThreadAttach(DllBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID WINAPI TLSInit_DllMain_ProcessAttach_Internal(ULONG_PTR DllBase)
|
||||||
|
/*
|
||||||
|
This function is relatively simple:
|
||||||
|
-get the VA of the TLS directory, add the loaded image base to it
|
||||||
|
-use the size of the current ThreadLocalStoragePointer to set the TLS index in the DLL
|
||||||
|
-call the TLS callbacks
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PLDR_DATA_TABLE_ENTRY DataTableEntry, DataTableEntryInit;
|
||||||
|
PIMAGE_TLS_DIRECTORY TlsDirectory;
|
||||||
|
PIMAGE_TLS_CALLBACK* TlsCallbacks;
|
||||||
|
PIMAGE_TLS_CALLBACK TlsCall;
|
||||||
|
PTEB_CUSTOM CustomTeb;
|
||||||
|
PULONG TlsIdx;
|
||||||
|
ULONG_PTR* ThreadLocalStoragePointer, ImageBase;
|
||||||
|
ULONG ulLength;
|
||||||
|
LONG i;
|
||||||
|
PSYSTEM_PROCESS_INFORMATION spi;
|
||||||
|
PULONG_PTR TlsBaseCountTemp, TlsBasesOld;
|
||||||
|
|
||||||
|
if (!DllBase)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (DllBase == GetModuleHandleW(NtCurrentTeb()->ProcessEnvironmentBlock->ProcessParameters->ImagePathName.Buffer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CustomTeb = (PTEB_CUSTOM)NtCurrentTeb();
|
||||||
|
|
||||||
|
if ((LOBYTE(GetVersion()) >= 6))
|
||||||
|
return; // Nothing to do here
|
||||||
|
|
||||||
|
TlsDirectory = GetTlsDirectory(DllBase, &ImageBase);
|
||||||
|
|
||||||
|
if (!TlsDirectory)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TlsCallbacks = (PIMAGE_TLS_CALLBACK*)((TlsDirectory->AddressOfCallBacks)); // - ImageBase) + DllBase);
|
||||||
|
|
||||||
|
TlsIdx = (PULONG)((TlsDirectory->AddressOfIndex));// - ImageBase)); + DllBase);
|
||||||
|
|
||||||
|
if (*TlsIdx)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ThreadLocalStoragePointer = CustomTeb->ThreadLocalStoragePointer;
|
||||||
|
|
||||||
|
if (ThreadLocalStoragePointer)
|
||||||
|
{
|
||||||
|
while (*ThreadLocalStoragePointer > 0 && !(*ThreadLocalStoragePointer % 4))
|
||||||
|
// Make sure only valid pointers are counted, and not padding that can also bookend the list of pointers
|
||||||
|
{
|
||||||
|
++*TlsIdx;
|
||||||
|
++ThreadLocalStoragePointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TlsCallbacks)
|
||||||
|
{
|
||||||
|
while (*TlsCallbacks)
|
||||||
|
{
|
||||||
|
TlsCall = *TlsCallbacks;
|
||||||
|
TlsCall((PVOID)DllBase, 1, NULL);
|
||||||
|
++TlsCallbacks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TlsBasesLength || TlsBasesCount >= (TlsBasesLength - 1))
|
||||||
|
{
|
||||||
|
TlsBaseCountTemp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ULONG_PTR) * (32 + TlsBasesLength));
|
||||||
|
TlsBasesOld = TlsBases;
|
||||||
|
for (i = 0; i < TlsBasesCount; i++)
|
||||||
|
TlsBaseCountTemp[i] = TlsBases[i];
|
||||||
|
TlsBases = TlsBaseCountTemp;
|
||||||
|
TlsBasesLength += 32;
|
||||||
|
if(TlsBasesOld)
|
||||||
|
HeapFree(GetProcessHeap(), 0, TlsBasesOld);
|
||||||
|
}
|
||||||
|
|
||||||
|
TlsBases[TlsBasesCount] = DllBase;
|
||||||
|
++TlsBasesCount;
|
||||||
|
/*
|
||||||
|
NtQuerySystemInformation(SystemProcessInformation, NULL, 0, &ulLength);
|
||||||
|
|
||||||
|
spi = (PSYSTEM_PROCESS_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulLength);
|
||||||
|
|
||||||
|
if (!spi)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (NtQuerySystemInformation(SystemProcessInformation, spi, ulLength, NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (spi->UniqueProcessId != CustomTeb->UniqueProcess)
|
||||||
|
{
|
||||||
|
if (!spi->NextEntryOffset)
|
||||||
|
return;
|
||||||
|
spi = spi->NextEntryOffset + (ULONG_PTR)spi;
|
||||||
|
}
|
||||||
|
|
||||||
|
sti = (ULONG_PTR)spi + sizeof(SYSTEM_PROCESS_INFORMATION); // A slight problem here, the struct size got bigger in Windows 2000. Perhaps it will have to be derived from somewhere for anything older.
|
||||||
|
|
||||||
|
for (i = 0; i < spi->NumberOfThreads; i++)
|
||||||
|
{
|
||||||
|
hThread = OpenThread(THREAD_QUERY_INFORMATION, FALSE, sti->ClientId.UniqueThread);
|
||||||
|
if (hThread)
|
||||||
|
{
|
||||||
|
NtQueryInformationThread(hThread, 0, &tbi, sizeof(THREAD_BASIC_INFORMATION), NULL);
|
||||||
|
SuspendThread(hThread);
|
||||||
|
DataTableEntry = (PLDR_DATA_TABLE_ENTRY)NtCurrentTeb()->ProcessEnvironmentBlock->Ldr->Reserved2[1];
|
||||||
|
DataTableEntryInit = DataTableEntry;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
TLSInit_DllMain_ThreadAttach_Internal(DataTableEntry->DllBase, tbi.TebBaseAddress);
|
||||||
|
DataTableEntry = DataTableEntry->Reserved1[0];
|
||||||
|
} while (DataTableEntry != DataTableEntryInit);
|
||||||
|
ResumeThread(hThread);
|
||||||
|
CloseHandle(hThread);
|
||||||
|
}
|
||||||
|
++sti;
|
||||||
|
}*/
|
||||||
|
for (i = 0; i < TlsBasesCount; i++)
|
||||||
|
{
|
||||||
|
TLSInit_DllMain_ThreadAttach_Internal(TlsBases[i], NULL);
|
||||||
|
}
|
||||||
|
// HeapFree(GetProcessHeap(), 0, spi);
|
||||||
|
spi = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(dllexport) VOID WINAPI TLSInit_DllMain_ThreadAttach(ULONG_PTR DllBase)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
int i;
|
||||||
|
PIMAGE_TLS_DIRECTORY TlsDirectory;
|
||||||
|
PTEB_CUSTOM CustomTeb;
|
||||||
|
PULONG TlsIdx;
|
||||||
|
TlsHack* TlsHackEntry;
|
||||||
|
ULONG_PTR* ThreadLocalStoragePointer;
|
||||||
|
ULONG_PTR* ThreadLocalStoragePointerNew, ImageBase;
|
||||||
|
|
||||||
|
|
||||||
|
if (!DllBase)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CustomTeb = (PTEB_CUSTOM)NtCurrentTeb();
|
||||||
|
|
||||||
|
if (LOBYTE(GetVersion()) >= 6 || (LOBYTE(GetVersion()) < 6 && CustomTeb->ProcessEnvironmentBlock->SystemReserved == 1))
|
||||||
|
return; // Nothing to do here
|
||||||
|
|
||||||
|
TlsDirectory = GetTlsDirectory(DllBase, &ImageBase);
|
||||||
|
|
||||||
|
if (!TlsDirectory)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ThreadLocalStoragePointer = CustomTeb->ThreadLocalStoragePointer;
|
||||||
|
|
||||||
|
TlsIdx = (PULONG)((TlsDirectory->AddressOfIndex)); //- ImageBase)); + DllBase);
|
||||||
|
|
||||||
|
if (CustomTeb->SystemReserved1[0x35] >= *TlsIdx)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CustomTeb->SystemReserved1[0x35] = *TlsIdx;
|
||||||
|
ThreadLocalStoragePointerNew = (ULONG_PTR*)HeapAlloc(CustomTeb->ProcessEnvironmentBlock->ProcessHeap, HEAP_ZERO_MEMORY, (*TlsIdx + 2) * sizeof(ULONG_PTR));
|
||||||
|
|
||||||
|
if (ThreadLocalStoragePointer)
|
||||||
|
{
|
||||||
|
for (i = 0; i < *TlsIdx; i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
TlsHackEntry = (TlsHack*)ThreadLocalStoragePointer[i];
|
||||||
|
TlsHackEntry->Ptr2 = 0; // Provisional Supermium 121 hack.
|
||||||
|
}
|
||||||
|
ThreadLocalStoragePointerNew[i] = ThreadLocalStoragePointer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadLocalStoragePointerNew[*TlsIdx] = (ULONG_PTR)HeapAlloc(CustomTeb->ProcessEnvironmentBlock->ProcessHeap, HEAP_ZERO_MEMORY,
|
||||||
|
TlsDirectory->EndAddressOfRawData - TlsDirectory->StartAddressOfRawData);
|
||||||
|
|
||||||
|
if(CustomTeb->SystemReserved1[0x35] == *TlsIdx)
|
||||||
|
ThreadLocalStoragePointerNew[*TlsIdx + 1] = 0xABABABAB;
|
||||||
|
|
||||||
|
RtlMoveMemory((PVOID)ThreadLocalStoragePointerNew[*TlsIdx], (PVOID)(TlsDirectory->StartAddressOfRawData),
|
||||||
|
TlsDirectory->EndAddressOfRawData - TlsDirectory->StartAddressOfRawData);
|
||||||
|
|
||||||
|
// if (ThreadLocalStoragePointer)
|
||||||
|
// HeapFree(CustomTeb->ProcessEnvironmentBlock->ProcessHeap, 0, ThreadLocalStoragePointer);
|
||||||
|
|
||||||
|
CustomTeb->ThreadLocalStoragePointer = ThreadLocalStoragePointerNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID WINAPI TLSInit_DllMain_ThreadAttach_Internal(ULONG_PTR DllBase, ULONG_PTR TebAddr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
PIMAGE_TLS_DIRECTORY TlsDirectory;
|
||||||
|
PTEB_CUSTOM CustomTeb;
|
||||||
|
PULONG TlsIdx;
|
||||||
|
TlsHack* TlsHackEntry;
|
||||||
|
ULONG_PTR* ThreadLocalStoragePointer;
|
||||||
|
ULONG_PTR* ThreadLocalStoragePointerNew, ImageBase;
|
||||||
|
CHAR Buffer[256];
|
||||||
|
CHAR ModuleName[128];
|
||||||
|
DWORD BufferWritten;
|
||||||
|
|
||||||
|
memset(Buffer, 0, 256);
|
||||||
|
|
||||||
|
|
||||||
|
if (!DllBase)
|
||||||
|
return;
|
||||||
|
if (!TebAddr)
|
||||||
|
CustomTeb = (PTEB_CUSTOM)NtCurrentTeb();
|
||||||
|
else
|
||||||
|
CustomTeb = TebAddr;
|
||||||
|
|
||||||
|
if ((LOBYTE(GetVersion()) >= 6))
|
||||||
|
return; // Nothing to do here
|
||||||
|
|
||||||
|
TlsDirectory = GetTlsDirectory(DllBase, &ImageBase);
|
||||||
|
|
||||||
|
if (!TlsDirectory)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ThreadLocalStoragePointer = CustomTeb->ThreadLocalStoragePointer;
|
||||||
|
|
||||||
|
TlsIdx = (PULONG)((TlsDirectory->AddressOfIndex)); //- ImageBase)); + DllBase);
|
||||||
|
|
||||||
|
if (CustomTeb->SystemReserved1[0x35] >= *TlsIdx) {
|
||||||
|
// GetModuleFileNameA(DllBase, ModuleName, 128);
|
||||||
|
// int buffer_size = wsprintfA(Buffer, "Thread ID %d: TLS failed due to TlsIdx below current max slot, %d out of %d, %s\r\n", GetCurrentThreadId(),
|
||||||
|
// CustomTeb->SystemReserved1[0x35], *TlsIdx, ModuleName);
|
||||||
|
|
||||||
|
// WriteFile(g_hFile, Buffer, buffer_size, &BufferWritten, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomTeb->SystemReserved1[0x35] = *TlsIdx;
|
||||||
|
ThreadLocalStoragePointerNew = (ULONG_PTR*)HeapAlloc(CustomTeb->ProcessEnvironmentBlock->ProcessHeap, HEAP_ZERO_MEMORY, (*TlsIdx + 2) * sizeof(ULONG_PTR));
|
||||||
|
|
||||||
|
if (ThreadLocalStoragePointer)
|
||||||
|
{
|
||||||
|
for (i = 0; i < *TlsIdx; i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
TlsHackEntry = (TlsHack*)ThreadLocalStoragePointer[i];
|
||||||
|
// TlsHackEntry->Ptr2 = 0; // Provisional Supermium 121 hack.
|
||||||
|
}
|
||||||
|
ThreadLocalStoragePointerNew[i] = ThreadLocalStoragePointer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//int buffer_size = wsprintfA(Buffer, "Thread ID %d: TLS request successful\r\n", GetCurrentThreadId());
|
||||||
|
|
||||||
|
//WriteFile(g_hFile, Buffer, buffer_size, &BufferWritten, NULL);
|
||||||
|
|
||||||
|
ThreadLocalStoragePointerNew[*TlsIdx] = (ULONG_PTR)HeapAlloc(CustomTeb->ProcessEnvironmentBlock->ProcessHeap, HEAP_ZERO_MEMORY,
|
||||||
|
TlsDirectory->EndAddressOfRawData - TlsDirectory->StartAddressOfRawData);
|
||||||
|
// if (CustomTeb->SystemReserved1[0x35] == *TlsIdx)
|
||||||
|
// ThreadLocalStoragePointerNew[*TlsIdx + 1] = 0xABABABAB;
|
||||||
|
|
||||||
|
RtlMoveMemory((PVOID)ThreadLocalStoragePointerNew[*TlsIdx], (PVOID)(TlsDirectory->StartAddressOfRawData),
|
||||||
|
TlsDirectory->EndAddressOfRawData - TlsDirectory->StartAddressOfRawData);
|
||||||
|
|
||||||
|
// if (ThreadLocalStoragePointer)
|
||||||
|
// HeapFree(CustomTeb->ProcessEnvironmentBlock->ProcessHeap, 0, ThreadLocalStoragePointer);
|
||||||
|
|
||||||
|
CustomTeb->ThreadLocalStoragePointer = ThreadLocalStoragePointerNew;
|
||||||
|
}
|
||||||
244
progwrp-CSOG/user.c
Normal file
244
progwrp-CSOG/user.c
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_RegisterTouchWindow(
|
||||||
|
HWND hwnd,
|
||||||
|
ULONG ulFlags)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_SUPPORTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG WINAPI Implementation_GetDisplayConfigBufferSizes(
|
||||||
|
UINT32 flags,
|
||||||
|
UINT32 *numPathArrayElements,
|
||||||
|
UINT32 *numModeInfoArrayElements
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_CloseTouchInputHandle(
|
||||||
|
HTOUCHINPUT hTouchInput
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_SUPPORTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetGestureInfo(
|
||||||
|
HGESTUREINFO hGestureInfo,
|
||||||
|
PGESTUREINFO pGestureInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_SUPPORTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG WINAPI Implementation_DisplayConfigGetDeviceInfo(
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_HEADER *requestPacket
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG WINAPI Implementation_DisplayConfigSetDeviceInfo(
|
||||||
|
DISPLAYCONFIG_DEVICE_INFO_HEADER *setPacket
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG WINAPI Implementation_QueryDisplayConfig(
|
||||||
|
UINT32 flags,
|
||||||
|
UINT32 *numPathArrayElements,
|
||||||
|
DISPLAYCONFIG_PATH_INFO *pathArray,
|
||||||
|
UINT32 *numModeInfoArrayElements,
|
||||||
|
DISPLAYCONFIG_MODE_INFO *modeInfoArray,
|
||||||
|
DISPLAYCONFIG_TOPOLOGY_ID *currentTopologyId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
HPOWERNOTIFY WINAPI Implementation_RegisterPowerSettingNotification(
|
||||||
|
HANDLE hRecipient,
|
||||||
|
LPCGUID PowerSettingGuid,
|
||||||
|
DWORD Flags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_UnregisterPowerSettingNotification(
|
||||||
|
HPOWERNOTIFY Handle
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SetProcessDPIAware()
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_SystemParametersInfoW(
|
||||||
|
UINT uiAction,
|
||||||
|
UINT uiParam,
|
||||||
|
PVOID pvParam,
|
||||||
|
UINT fWinIni
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
The function is "moved" here in the event of possible expansion for win2k purposes.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
BOOL Result;
|
||||||
|
PNONCLIENTMETRICSW ncm;
|
||||||
|
typedef BOOL (WINAPI* pfnSystemParametersInfoW)(UINT, UINT, PVOID, UINT);
|
||||||
|
pfnSystemParametersInfoW pSysParams = (pfnSystemParametersInfoW)Implementation_GetProcAddress(GetModuleHandleA("user32.dll"), "SystemParametersInfoW");
|
||||||
|
Result = pSysParams(uiAction, uiParam, pvParam, fWinIni);
|
||||||
|
|
||||||
|
if(!Result)
|
||||||
|
{
|
||||||
|
if(uiAction == SPI_GETNONCLIENTMETRICS)
|
||||||
|
{
|
||||||
|
if(pvParam)
|
||||||
|
{
|
||||||
|
ncm = (PNONCLIENTMETRICSW)pvParam;
|
||||||
|
|
||||||
|
ncm->cbSize -= sizeof(int);
|
||||||
|
|
||||||
|
uiParam -= sizeof(int);
|
||||||
|
|
||||||
|
Result = pSysParams(uiAction, uiParam, pvParam, fWinIni);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_GetDpiForMonitor(
|
||||||
|
HMONITOR hmonitor,
|
||||||
|
MONITOR_DPI_TYPE dpiType,
|
||||||
|
UINT *dpiX,
|
||||||
|
UINT *dpiY
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HDC hDC;
|
||||||
|
INT index;
|
||||||
|
hDC = GetDC(NULL);
|
||||||
|
*dpiX = GetDeviceCaps(hDC, LOGPIXELSX);
|
||||||
|
*dpiY = GetDeviceCaps(hDC, LOGPIXELSY);
|
||||||
|
ReleaseDC(NULL, hDC);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetLayeredWindowAttributes(
|
||||||
|
HWND hwnd,
|
||||||
|
COLORREF *pcrKey,
|
||||||
|
BYTE *pbAlpha,
|
||||||
|
DWORD *pdwFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_PrintWindow(
|
||||||
|
HWND hwnd,
|
||||||
|
HDC hdcBlt,
|
||||||
|
UINT nFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT WINAPI Implementation_DefRawInputProc(
|
||||||
|
PRAWINPUT *paRawInput,
|
||||||
|
INT nInput,
|
||||||
|
UINT cbSizeHeader
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT WINAPI Implementation_GetRawInputData(
|
||||||
|
HRAWINPUT hRawInput,
|
||||||
|
UINT uiCommand,
|
||||||
|
LPVOID pData,
|
||||||
|
PUINT pcbSize,
|
||||||
|
UINT cbSizeHeader
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return(UINT)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT WINAPI Implementation_GetRawInputDeviceInfoW(
|
||||||
|
HANDLE hDevice,
|
||||||
|
UINT uiCommand,
|
||||||
|
LPVOID pData,
|
||||||
|
PUINT pcbSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return(UINT)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT WINAPI Implementation_GetRawInputDeviceList(
|
||||||
|
PRAWINPUTDEVICELIST pRawInputDeviceList,
|
||||||
|
PUINT puiNumDevices,
|
||||||
|
UINT cbSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return(UINT)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_RegisterRawInputDevices(
|
||||||
|
PCRAWINPUTDEVICE pRawInputDevices,
|
||||||
|
UINT uiNumDevices,
|
||||||
|
UINT cbSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_UnhookWindowsHookEx(
|
||||||
|
HHOOK hhk
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typedef BOOL(WINAPI* pfnUnhookWindowsHookEx)(HHOOK);
|
||||||
|
pfnUnhookWindowsHookEx pUnhookWindowsHookEx = (pfnUnhookWindowsHookEx)Implementation_GetProcAddress(GetModuleHandleA("user32.dll"), "UnhookWindowsHookEx");
|
||||||
|
return pUnhookWindowsHookEx(hhk);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_RegisterPointerDeviceNotifications(
|
||||||
|
HWND window,
|
||||||
|
BOOL notifyRange
|
||||||
|
)
|
||||||
|
// Chromium doesn't react to it. I could return TRUE because no notifications will be sent either way, but I shouldn't lie about that
|
||||||
|
// unless necessary.
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_SUPPORTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetPointerDevices(
|
||||||
|
UINT32* deviceCount,
|
||||||
|
POINTER_DEVICE_INFO* pointerDevices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_SUPPORTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI Implementation_GetPointerDevice(
|
||||||
|
HANDLE device,
|
||||||
|
POINTER_DEVICE_INFO* pointerDevice
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_SUPPORTED);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
11
progwrp-CSOG/wer.c
Normal file
11
progwrp-CSOG/wer.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "progwrp.h"
|
||||||
|
#include "export.h"
|
||||||
|
#include "implementations.h"
|
||||||
|
|
||||||
|
HRESULT WINAPI Implementation_WerRegisterRuntimeExceptionModule(
|
||||||
|
PCWSTR pwszOutOfProcessCallbackDll,
|
||||||
|
PVOID pContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
37
progwrp.sln
Normal file
37
progwrp.sln
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.37301.9
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "progwrp", "progwrp-CSOG\progwrp.vcxproj", "{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|ARM = Debug|ARM
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|ARM = Release|ARM
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Debug|ARM.Build.0 = Debug|ARM
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Release|ARM.ActiveCfg = Release|ARM
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Release|ARM.Build.0 = Release|ARM
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Release|x64.Build.0 = Release|x64
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{01C075CA-C7FB-4AB8-B5B1-510565C19C5D}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {FB84AD9B-DACA-4746-91C1-74E6EAE2E2FF}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
Reference in New Issue
Block a user