Skip to content

Commit 570b7b9

Browse files
committed
Merge pull request #13 from rainers/master
changes for v0.3.38beta4
2 parents ddc3a87 + b8506f1 commit 570b7b9

20 files changed

+1500
-835
lines changed

CHANGES

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ unreleased Version 0.3.38
594594
* updated to cv2pdb 0.28
595595
- support mspdb120.dll from VS 2013
596596
- bugzilla 11537: improved search for appropriate mspdb*.dll if multiple version of VS installed
597+
- fix support for DWARF conversion for gcc 4.8
597598
* updated to mago 0.9
598599
- bugzilla 11547: remove error message when stopping debugging
599600
- bugzilla 11437: debug info rejected if records don't have "recommended" order
@@ -613,4 +614,10 @@ unreleased Version 0.3.38
613614
* Windows SDK 8.0/8.1 detection
614615
* fix bad "\n" in default x64 library search path
615616
* x64 executable and library search path not correctly saved for next VS start
616-
* improve project automation to mute NuGet (still empty project pretended)
617+
* improve project automation to mute NuGet (still empty project pretended)
618+
619+
* add source control support for git in VS2013 (and maybe others)
620+
* fix DnD of project items in VS2013
621+
* disguise functionality of pipedmd.exe and filemonitor.dll to let it pass
622+
most anti-virus checks
623+
* added option to select the C runtime library when compiling for x64

TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Project:
3939
- custom command: quotes in dependencies not supported
4040
- VS2013: property pages don't follow resize
4141
- custom command: writes build batch to souce folder
42+
- does not work with VS2013 git integration
4243

4344
Language service:
4445
-----------------
@@ -148,3 +149,4 @@ Unsorted
148149
- save file before "Compile & run"
149150
- coverage line highlight after "Compile & run" doesn't update
150151
- better keeping track of line changes
152+

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#define VERSION_MINOR 3
33
#define VERSION_REVISION 38
44
#define VERSION_BETA -beta
5-
#define VERSION_BUILD 3
5+
#define VERSION_BUILD 4

build/build.visualdproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@
185185
<useStdLibPath>1</useStdLibPath>
186186
<additionalOptions />
187187
<preBuildCommand />
188-
<postBuildCommand>echo Success &gt;$(TargetPath)</postBuildCommand>
188+
<postBuildCommand>echo Success &gt;$(TargetPath)
189+
echo. &gt;$(TargetDir)\build.dep</postBuildCommand>
189190
<filesToClean>*.obj;*.cmd;*.build;*.json;*.dep</filesToClean>
190191
</Config>
191192
<Folder name="build">
@@ -194,7 +195,7 @@ if errorlevel 1 goto reportError
194195
call $(InputPath) &quot;$(OutDir)\tlb2idl.exe&quot; &quot;$(OutDir)\dte_idl.success&quot;" outfile="$(OutDir)\dte_idl.success" />
195196
<File tool="Custom" path="..\tools\filemonitor.d" customcmd="dmd -map $(OutDir)\$(InputName).map -of$(OutDir)\$(InputName).dll -defaultlib=user32.lib -L/ENTRY:_DllMain@12 $(InputPath)" outfile="$(OutDir)\$(InputName).dll" />
196197
<File tool="Custom" path="..\tools\largeadr.d" customcmd="dmd -map $(OutDir)\$(InputName).map -of$(OutDir)\$(InputName).exe $(InputPath)" outfile="$(OutDir)\$(InputName).exe" />
197-
<File tool="Custom" path="..\tools\pipedmd.d" customcmd="dmd -map $(OutDir)\$(InputName).map -of$(OutDir)\$(InputName).exe $(InputPath)" outfile="$(OutDir)\$(InputName).exe" />
198+
<File tool="Custom" path="..\tools\pipedmd.d" dependencies="..\tools\nostacktrace.d" customcmd="dmd -map $(OutDir)\$(InputName).map -of$(OutDir)\$(InputName).exe $(InputPath) ..\tools\nostacktrace.d" outfile="$(OutDir)\$(InputName).exe" />
198199
<File tool="Custom" path="sdk.bat" dependencies="$(OutDir)\dte_idl.success $(OutDir)\vsi2d.exe" customcmd="call $(VSINSTALLDIR)\Common7\Tools\vsvars32.bat
199200
if errorlevel 1 goto reportError
200201
call $(InputPath) &quot;$(OutDir)\vsi2d.exe&quot; &quot;$(OutDir)\sdk.success&quot;" outfile="$(OutDir)\sdk.success" />

tools/filemonitor.d

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,56 +51,67 @@ BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
5151
g_hInst = hInstance;
5252
if(ulReason == DLL_PROCESS_ATTACH)
5353
{
54-
RedirectCreateFileA();
55-
RedirectCreateFileW();
54+
if (dumpFile[0]) // only execute if it was injected by pipedmd
55+
{
56+
//origWriteFile = getWriteFileFunc();
57+
RedirectCreateFileA();
58+
RedirectCreateFileW();
59+
}
5660
}
5761
return true;
5862
}
5963

6064
alias typeof(&CreateFileA) fnCreateFileA;
6165
alias typeof(&CreateFileW) fnCreateFileW;
66+
alias typeof(&WriteFile) fnWriteFile;
6267
__gshared fnCreateFileA origCreateFileA;
6368
__gshared fnCreateFileW origCreateFileW;
69+
__gshared fnWriteFile origWriteFile;
70+
71+
__gshared fnCreateFileA myCF = &MyCreateFileA;
6472

6573
alias typeof(&VirtualProtect) fnVirtualProtect;
6674

67-
void RedirectCreateFileA()
75+
fnVirtualProtect getVirtualProtectFunc()
6876
{
69-
version(msgbox) MessageBoxA(null, "RedirectCreateFileA", "filemonitor", MB_OK);
70-
ubyte* jmpAdr = cast(ubyte*)&CreateFileA;
71-
auto impTableEntry = cast(fnCreateFileA*) (*cast(void**)(jmpAdr + 2));
72-
origCreateFileA = *impTableEntry;
73-
74-
DWORD oldProtect, newProtect;
7577
version(all)
7678
{
77-
VirtualProtect(impTableEntry, (*impTableEntry).sizeof, PAGE_READWRITE, &oldProtect);
78-
*impTableEntry = &MyCreateFileA;
79-
VirtualProtect(impTableEntry, (*impTableEntry).sizeof, oldProtect, &newProtect);
79+
HANDLE krnl = GetModuleHandleA("kernel32.dll");
80+
return cast(fnVirtualProtect) GetProcAddress(krnl, "VirtualProtect");
8081
}
8182
else
8283
{
83-
char[16] func;
84-
char*p = func.ptr;
85-
mixin({
86-
string s;
87-
foreach(c; [ 'V','i','r','t','u','a','l','P','r','o','t','e','c','t' ])
88-
{ s ~= "*p++ = '"; s ~= c; s ~= "';"; }
89-
return s;
90-
}());
91-
*p = 0;
84+
return &VirtualProtect;
85+
}
86+
}
9287

88+
fnWriteFile getWriteFileFunc()
89+
{
90+
version(all)
91+
{
9392
HANDLE krnl = GetModuleHandleA("kernel32.dll");
94-
if(fnVirtualProtect fn = cast(fnVirtualProtect) GetProcAddress(krnl, func.ptr))
95-
{
96-
DWORD oldProtect, newProtect;
97-
fn(impTableEntry, (*impTableEntry).sizeof, PAGE_READWRITE, &oldProtect);
98-
*impTableEntry = &MyCreateFileA;
99-
fn(impTableEntry, (*impTableEntry).sizeof, oldProtect, &newProtect);
100-
}
93+
return cast(fnWriteFile) GetProcAddress(krnl, "WriteFile");
94+
}
95+
else
96+
{
97+
return &WriteFile;
10198
}
10299
}
103100

101+
void RedirectCreateFileA()
102+
{
103+
version(msgbox) MessageBoxA(null, "RedirectCreateFileA", "filemonitor", MB_OK);
104+
ubyte* jmpAdr = cast(ubyte*)&CreateFileA;
105+
auto impTableEntry = cast(fnCreateFileA*) (*cast(void**)(jmpAdr + 2));
106+
origCreateFileA = *impTableEntry;
107+
108+
DWORD oldProtect, newProtect;
109+
auto pfnVirtualProtect = getVirtualProtectFunc();
110+
pfnVirtualProtect(impTableEntry, (*impTableEntry).sizeof, PAGE_READWRITE, &oldProtect);
111+
*impTableEntry = &MyCreateFileA;
112+
pfnVirtualProtect(impTableEntry, (*impTableEntry).sizeof, oldProtect, &newProtect);
113+
}
114+
104115
void RedirectCreateFileW()
105116
{
106117
version(msgbox) MessageBoxA(null, "RedirectCreateFileW", "filemonitor", MB_OK);
@@ -109,12 +120,10 @@ void RedirectCreateFileW()
109120
origCreateFileW = *impTableEntry;
110121

111122
DWORD oldProtect, newProtect;
112-
version(all)
113-
{
114-
VirtualProtect(impTableEntry, (*impTableEntry).sizeof, PAGE_READWRITE, &oldProtect);
115-
*impTableEntry = &MyCreateFileW;
116-
VirtualProtect(impTableEntry, (*impTableEntry).sizeof, oldProtect, &newProtect);
117-
}
123+
auto pfnVirtualProtect = getVirtualProtectFunc();
124+
pfnVirtualProtect(impTableEntry, (*impTableEntry).sizeof, PAGE_READWRITE, &oldProtect);
125+
*impTableEntry = &MyCreateFileW;
126+
pfnVirtualProtect(impTableEntry, (*impTableEntry).sizeof, oldProtect, &newProtect);
118127
}
119128

120129
extern(Windows) HANDLE
@@ -146,8 +155,8 @@ MyCreateFileA(
146155
WaitForSingleObject(hndMutex, INFINITE);
147156

148157
size_t length = mystrlen(lpFileName);
149-
WriteFile(hndDumpFile, lpFileName, length, &length, null);
150-
WriteFile(hndDumpFile, "\n".ptr, 1, &length, null);
158+
origWriteFile(hndDumpFile, lpFileName, length, &length, null);
159+
origWriteFile(hndDumpFile, "\n".ptr, 1, &length, null);
151160

152161
if(hndMutex != INVALID_HANDLE_VALUE)
153162
ReleaseMutex(hndMutex);
@@ -185,7 +194,7 @@ MyCreateFileW(
185194
ushort bom = 0xFEFF;
186195
size_t written;
187196
if(hndDumpFile != INVALID_HANDLE_VALUE)
188-
WriteFile(hndDumpFile, &bom, 2, &written, null);
197+
origWriteFile(hndDumpFile, &bom, 2, &written, null);
189198

190199
if(hndMutex != INVALID_HANDLE_VALUE)
191200
ReleaseMutex(hndMutex);
@@ -197,8 +206,8 @@ MyCreateFileW(
197206
WaitForSingleObject(hndMutex, INFINITE);
198207

199208
size_t length = mystrlen(lpFileName);
200-
WriteFile(hndDumpFile, lpFileName, 2*length, &length, null);
201-
WriteFile(hndDumpFile, "\n".ptr, 2, &length, null);
209+
origWriteFile(hndDumpFile, lpFileName, 2*length, &length, null);
210+
origWriteFile(hndDumpFile, "\n".ptr, 2, &length, null);
202211

203212
if(hndMutex != INVALID_HANDLE_VALUE)
204213
ReleaseMutex(hndMutex);
@@ -239,6 +248,7 @@ size_t mystrlen(const(wchar)* str) nothrow
239248
///////// shut up compiler generated GC info failing to link
240249
extern(C)
241250
{
251+
__gshared int D10TypeInfo_i6__initZ;
242252
__gshared int D10TypeInfo_v6__initZ;
243253
__gshared int D16TypeInfo_Pointer6__vtblZ;
244254
__gshared int D17TypeInfo_Function6__vtblZ;

tools/nostacktrace.d

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// replacement module to disable stack traces and avoid the default stacktrace code
2+
// to be linked in
3+
4+
module core.sys.windows.stacktrace;
5+
6+
import core.sys.windows.windows;
7+
8+
class StackTrace : Throwable.TraceInfo
9+
{
10+
public:
11+
this(size_t skip, CONTEXT* context)
12+
{
13+
}
14+
int opApply(scope int delegate(ref const(char[])) dg) const
15+
{
16+
return 0;
17+
}
18+
int opApply(scope int delegate(ref size_t, ref const(char[])) dg) const
19+
{
20+
return 0;
21+
}
22+
override string toString() const
23+
{
24+
return null;
25+
}
26+
static ulong[] trace(size_t skip = 0, CONTEXT* context = null)
27+
{
28+
return null;
29+
}
30+
static char[][] resolve(const(ulong)[] addresses)
31+
{
32+
return [];
33+
}
34+
private:
35+
ulong[] m_trace;
36+
}

tools/pipedmd.d

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,13 @@ void InjectDLL(HANDLE hProcess, string depsfile)
455455
// copy path to other process
456456
auto wdll = to!wstring(dll) ~ cast(wchar)0;
457457
auto wdllRemote = VirtualAllocEx(hProcess, null, wdll.length * 2, MEM_COMMIT, PAGE_READWRITE);
458-
WriteProcessMemory(hProcess, wdllRemote, wdll.ptr, wdll.length * 2, null);
458+
auto procWrite = getWriteProcFunc();
459+
procWrite(hProcess, wdllRemote, wdll.ptr, wdll.length * 2, null);
459460

460461
// load dll into other process, assuming LoadLibraryW is at the same address in all processes
461462
HMODULE mod = GetModuleHandleA("Kernel32");
462463
auto proc = GetProcAddress(mod, "LoadLibraryW");
463-
hThread = CreateRemoteThread(hProcess, null, 0, cast(LPTHREAD_START_ROUTINE)proc, wdllRemote, 0, null);
464+
hThread = getCreateRemoteThreadFunc()(hProcess, null, 0, cast(LPTHREAD_START_ROUTINE)proc, wdllRemote, 0, null);
464465
WaitForSingleObject(hThread, INFINITE);
465466

466467
// Get handle of the loaded module
@@ -472,6 +473,19 @@ void InjectDLL(HANDLE hProcess, string depsfile)
472473

473474
void* pDumpFile = cast(char*)hRemoteModule + 0x3000; // offset taken from map file
474475
auto szDepsFile = toMBSz(depsfile);
475-
WriteProcessMemory(hProcess, pDumpFile, szDepsFile, strlen(szDepsFile) + 1, null);
476+
procWrite(hProcess, pDumpFile, szDepsFile, strlen(szDepsFile) + 1, null);
476477
}
477478

479+
typeof(WriteProcessMemory)* getWriteProcFunc ()
480+
{
481+
HMODULE mod = GetModuleHandleA("Kernel32");
482+
auto proc = GetProcAddress(mod, "WriteProcessMemory");
483+
return cast(typeof(WriteProcessMemory)*)proc;
484+
}
485+
486+
typeof(CreateRemoteThread)* getCreateRemoteThreadFunc ()
487+
{
488+
HMODULE mod = GetModuleHandleA("Kernel32");
489+
auto proc = GetProcAddress(mod, "CreateRemoteThread");
490+
return cast(typeof(CreateRemoteThread)*)proc;
491+
}

vdc/abothe/VDServer.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ public void AddPackage(string packageName)
141141
addExpansion(packageName, "PKG", "");
142142
}
143143

144+
public void AddCodeGeneratingNodeItem(INode node, string codeToGenerate)
145+
{
146+
addExpansion(codeToGenerate, "OVR", codeToGenerate);
147+
}
148+
144149
void addExpansion(string name, string type, string desc)
145150
{
146151
if(!string.IsNullOrEmpty(name))
@@ -277,7 +282,7 @@ public static string GeneratePrototype(DMethod dm, bool isTemplateParamInsight=f
277282
foreach (var attr in dm.Attributes)
278283
{
279284
var m = attr as Modifier;
280-
if (m != null && DTokens.StorageClass[m.Token])
285+
if (m != null && DTokens.IsStorageClass(m.Token))
281286
{
282287
sb.Append(DTokens.GetTokenString(m.Token));
283288
sb.Append(" ");

0 commit comments

Comments
 (0)